editeng/source/outliner/outliner.cxx | 20 ++++++++++---------- editeng/source/outliner/overflowingtxt.cxx | 4 ++-- include/editeng/outliner.hxx | 7 +++---- include/editeng/overflowingtxt.hxx | 9 +++++---- 4 files changed, 20 insertions(+), 20 deletions(-)
New commits: commit 7322fb1ed21cefe9faecc8cd5d088a3476283b5a Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri Aug 13 22:27:34 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Aug 14 11:11:28 2021 +0200 flatten OFlowChainedText Change-Id: I0836d1f850c71700f8691cf8847e4f4d30d4dbb5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120475 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index ff126e75446a..b30de5d206a0 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -2013,7 +2013,7 @@ bool Outliner::IsPageOverflow() return pEditEngine->IsPageOverflow(); } -std::unique_ptr<NonOverflowingText> Outliner::GetNonOverflowingText() const +std::optional<NonOverflowingText> Outliner::GetNonOverflowingText() const { /* XXX: * nCount should be the number of paragraphs of the non overflowing text @@ -2021,7 +2021,7 @@ std::unique_ptr<NonOverflowingText> Outliner::GetNonOverflowingText() const */ if ( GetParagraphCount() < 1 ) - return nullptr; + return {}; // last non-overflowing paragraph is before the first overflowing one sal_Int32 nCount = pEditEngine->GetOverflowingParaNum(); @@ -2032,14 +2032,14 @@ std::unique_ptr<NonOverflowingText> Outliner::GetNonOverflowingText() const SAL_INFO("editeng.chaining", "[Overflowing] Ops, trying to retrieve para " << nCount << " when max index is " << GetParagraphCount()-1 ); - return nullptr; + return {}; } if (nCount < 0) { SAL_INFO("editeng.chaining", "[Overflowing] No Overflowing text but GetNonOverflowinText called?!"); - return nullptr; + return {}; } // NOTE: We want the selection of the overflowing text from here @@ -2077,7 +2077,7 @@ std::unique_ptr<NonOverflowingText> Outliner::GetNonOverflowingText() const ESelection aEmptySel(0,0,0,0); //EditTextObject *pTObj = pEditEngine->CreateTextObject(aEmptySel); bool const bLastParaInterrupted = true; // Last Para was interrupted since everything overflew - return std::make_unique<NonOverflowingText>(aEmptySel, bLastParaInterrupted); + return NonOverflowingText(aEmptySel, bLastParaInterrupted); } else { // Get the lines that of the overflowing para fit in the box sal_Int32 nOverflowingPara = nCount; @@ -2114,7 +2114,7 @@ std::unique_ptr<NonOverflowingText> Outliner::GetNonOverflowingText() const bool bLastParaInterrupted = pEditEngine->GetOverflowingLineNum() > 0; - return std::make_unique<NonOverflowingText>(aOverflowingTextSelection, bLastParaInterrupted); + return NonOverflowingText(aOverflowingTextSelection, bLastParaInterrupted); } } @@ -2126,10 +2126,10 @@ std::unique_ptr<OutlinerParaObject> Outliner::GetEmptyParaObject() const return pPObj; } -std::unique_ptr<OverflowingText> Outliner::GetOverflowingText() const +std::optional<OverflowingText> Outliner::GetOverflowingText() const { if ( pEditEngine->GetOverflowingParaNum() < 0) - return nullptr; + return {}; // Defensive check: overflowing para index beyond actual # of paragraphs? @@ -2138,7 +2138,7 @@ std::unique_ptr<OverflowingText> Outliner::GetOverflowingText() const "[Overflowing] Ops, trying to retrieve para " << pEditEngine->GetOverflowingParaNum() << " when max index is " << GetParagraphCount()-1 ); - return nullptr; + return {}; } sal_Int32 nHeadPara = pEditEngine->GetOverflowingParaNum(); @@ -2157,7 +2157,7 @@ std::unique_ptr<OverflowingText> Outliner::GetOverflowingText() const sal_Int32 nLastParaLen = GetText(GetParagraph(nLastPara)).getLength(); aOverflowingTextSel = ESelection(nOverflowingPara, nLen, nLastPara, nLastParaLen); - return std::make_unique<OverflowingText>(pEditEngine->CreateTransferable(aOverflowingTextSel)); + return OverflowingText(pEditEngine->CreateTransferable(aOverflowingTextSel)); } diff --git a/editeng/source/outliner/overflowingtxt.cxx b/editeng/source/outliner/overflowingtxt.cxx index 16be74813704..0c038dbfb311 100644 --- a/editeng/source/outliner/overflowingtxt.cxx +++ b/editeng/source/outliner/overflowingtxt.cxx @@ -173,7 +173,7 @@ ESelection OFlowChainedText::GetOverflowPointSel() const std::unique_ptr<OutlinerParaObject> OFlowChainedText::InsertOverflowingText(Outliner *pOutliner, OutlinerParaObject const *pTextToBeMerged) { // Just return the roughly merged paras for now - if (mpOverflowingTxt == nullptr) + if (!mpOverflowingTxt) return nullptr; if (mbIsDeepMerge) { @@ -188,7 +188,7 @@ std::unique_ptr<OutlinerParaObject> OFlowChainedText::InsertOverflowingText(Outl std::unique_ptr<OutlinerParaObject> OFlowChainedText::RemoveOverflowingText(Outliner *pOutliner) { - if (mpNonOverflowingTxt == nullptr) + if (!mpNonOverflowingTxt) return nullptr; return mpNonOverflowingTxt->RemoveOverflowingText(pOutliner); diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index b28cdd39ac4b..23ff675707c1 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -21,6 +21,7 @@ #include <editeng/editdata.hxx> #include <editeng/editstat.hxx> +#include <editeng/overflowingtxt.hxx> #include <i18nlangtag/lang.h> #include <rtl/ustring.hxx> #include <svl/SfxBroadcaster.hxx> @@ -68,8 +69,6 @@ class SvxNumberFormat; class EditEngine; class SvKeyValueIterator; class SvxForbiddenCharactersTable; -class OverflowingText; -class NonOverflowingText; class OutlinerViewShell; enum class CharCompressType; enum class TransliterationFlags; @@ -734,8 +733,8 @@ public: void SetParaRemovingHdl(const Link<ParagraphHdlParam,void>& rLink){aParaRemovingHdl=rLink;} const Link<ParagraphHdlParam,void>& GetParaRemovingHdl() const { return aParaRemovingHdl; } - std::unique_ptr<NonOverflowingText> GetNonOverflowingText() const; - std::unique_ptr<OverflowingText> GetOverflowingText() const; + std::optional<NonOverflowingText> GetNonOverflowingText() const; + std::optional<OverflowingText> GetOverflowingText() const; void ClearOverflowingParaNum(); bool IsPageOverflow(); diff --git a/include/editeng/overflowingtxt.hxx b/include/editeng/overflowingtxt.hxx index 5edfdfa00ac6..3ec7a34354a9 100644 --- a/include/editeng/overflowingtxt.hxx +++ b/include/editeng/overflowingtxt.hxx @@ -26,6 +26,7 @@ #include <com/sun/star/uno/Reference.h> #include <memory> +#include <optional> namespace com::sun::star { namespace datatransfer { class XTransferable; } @@ -87,8 +88,8 @@ public: bool IsLastParaInterrupted() const; private: - const ESelection maContentSel; - const bool mbLastParaInterrupted; + ESelection maContentSel; + bool mbLastParaInterrupted; }; @@ -112,8 +113,8 @@ public: bool IsLastParaInterrupted() const; private: - std::unique_ptr<NonOverflowingText> mpNonOverflowingTxt; - std::unique_ptr<OverflowingText> mpOverflowingTxt; + std::optional<NonOverflowingText> mpNonOverflowingTxt; + std::optional<OverflowingText> mpOverflowingTxt; bool mbIsDeepMerge; };