editeng/source/outliner/outliner.cxx | 38 +++++++++++++++++++++++----- include/editeng/outliner.hxx | 3 +- include/editeng/overflowingtxt.hxx | 21 ++++++++++++++- include/svx/svdotext.hxx | 3 -- svx/source/svdraw/svdotext.cxx | 5 +++ svx/source/svdraw/svdotextdecomposition.cxx | 30 +++++++++++++++++++--- svx/source/svdraw/svdotxed.cxx | 12 +++++++- 7 files changed, 96 insertions(+), 16 deletions(-)
New commits: commit 598dc8b516d313da6a0b1d13d48139b7b041ae8f Author: matteocam <matteo.campane...@gmail.com> Date: Tue Jun 2 19:34:22 2015 -0400 Added NonOverflowingText and logic to leave it in editing text Change-Id: I2cf4ad519917c80c51f9f693f9e27d5e3e655ffc diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index d289e78..9e3e8f6 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -2089,7 +2089,7 @@ bool Outliner::HasParaFlag( const Paragraph* pPara, sal_uInt16 nFlag ) const return pPara && pPara->HasFlag( nFlag ); } -OutlinerParaObject *Outliner::GetNonOverflowingParaObject() const +NonOverflowingText *Outliner::GetNonOverflowingText() const { /* XXX: * nCount should be the number of paragraphs of the non overflowing text @@ -2101,7 +2101,8 @@ OutlinerParaObject *Outliner::GetNonOverflowingParaObject() const // last non-overflowing paragraph is before the first overflowing one sal_Int32 nCount = pEditEngine->GetOverflowingParaNum(); - //sal_Int32 nCount = 1; + sal_Int32 nOverflowLine = pEditEngine->GetOverflowingLineNum(); + OUString aPreOverflowingTxt(""); // Defensive check: oveflowing para index beyond actual # of paragraphs? if ( nCount > GetParagraphCount()-1) { @@ -2112,19 +2113,44 @@ OutlinerParaObject *Outliner::GetNonOverflowingParaObject() const return NULL; } - if ( nCount == 0 ) // Only overflowing text, i.e. 1st paragraph overflowing + // Only overflowing text, i.e. 1st line of 1st paragraph overflowing + if ( nCount == 0 && nOverflowLine == 0) { EditTextObject *pEmptyText = pEditEngine->GetEmptyTextObject(); OutlinerParaObject* pPObj = new OutlinerParaObject( *pEmptyText ); pPObj->SetOutlinerMode(GetMode()); delete pEmptyText; - return pPObj; + return new NonOverflowingText(pPObj, ""); - } else if (nCount < 0) // No overflowing Text + } else if (nCount < 0) { // No overflowing Text: all para-s included nCount = GetParagraphCount(); + // aPreOverflowingText == "" + } else { // Get the lines that of the overflowing para fit in the box - return CreateParaObject(0, nCount); + // XXX: Is there a proper method to join lines in a single string? + sal_Int32 nOverflowingPara = nCount; + OUString aWholeTxtHeadPara = GetText(GetParagraph(nOverflowingPara)); + sal_uInt32 nLen = 0; + + for ( sal_Int32 nLine = 0; + nLine < pEditEngine->GetOverflowingLineNum(); + nLine++) + { + nLen += GetLineLen(nOverflowingPara, nLine); + } + + // XXX: Any separator to be included? + aPreOverflowingTxt = aWholeTxtHeadPara.copy(0, nLen); + } + + OutlinerParaObject *pHeadParas; + if (nCount == 0) // No text to save expect for the one in the overflowing para (i.e. aPreOverflowingTxt) + pHeadParas = NULL; + else + pHeadParas = CreateParaObject(0, nCount); + + return new NonOverflowingText(pHeadParas, aPreOverflowingTxt); } OverflowingText *Outliner::GetOverflowingText() const diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index c493a7c..7093835 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -45,6 +45,7 @@ class EditUndo; class ParagraphList; class OutlinerParaObject; class OverflowingText; +class NonOverflowingText; class SvStream; class SvxBulletItem; class SvxFont; @@ -759,7 +760,7 @@ public: void SetParaRemovingHdl(const Link& rLink){aParaRemovingHdl=rLink;} Link GetParaRemovingHdl() const { return aParaRemovingHdl; } - OutlinerParaObject *GetNonOverflowingParaObject() const; + NonOverflowingText *GetNonOverflowingText() const; OverflowingText *GetOverflowingText() const; void ClearOverflowingParaNum(); diff --git a/include/editeng/overflowingtxt.hxx b/include/editeng/overflowingtxt.hxx index 287d237..98aa612 100644 --- a/include/editeng/overflowingtxt.hxx +++ b/include/editeng/overflowingtxt.hxx @@ -34,14 +34,31 @@ class OverflowingText { // Constructor OverflowingText( const OUString &headTxt, - const OutlinerParaObject *pMidParas = NULL, - const OUString &tailTxt = "") + const OutlinerParaObject *pMidParas, + const OUString &tailTxt) : mHeadTxt(headTxt), mpMidParas(pMidParas), mTailTxt(tailTxt) { } }; +class NonOverflowingText { + public: + const OutlinerParaObject *mpHeadParas; + OUString mPreOverflowingTxt; + // NOTE: mPreOverflowingTxt might be empty + + // Constructor + NonOverflowingText( + const OutlinerParaObject *pHeadParas, + const OUString &preOverflowingTxt) + : mpHeadParas(pHeadParas), + mPreOverflowingTxt(preOverflowingTxt) + { + DBG_ASSERT( pHeadParas != NULL, "pHeadParas is null?!" ); + } +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index 9144af4..a93f087 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -606,12 +606,11 @@ public: const drawinglayer::geometry::ViewInformation2D& aViewInformation) const; void impMoveChainedTextToNextLink(SdrTextObj *pNextTextObj) const; + void impLeaveOnlyNonOverflowingText() const; // Handler for Chained Text DECL_LINK(ImpDecomposeChainedText,EditStatus*); - void embedText() const; - // timing generators void impGetBlinkTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList) const; void impGetScrollTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList, double fFrameLength, double fTextLength) const; diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 3d13ebb..302346d 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -48,6 +48,7 @@ #include <svx/xflclit.hxx> #include <svl/style.hxx> #include <editeng/editeng.hxx> +#include <editeng/overflowingtxt.hxx> #include <svl/itemiter.hxx> #include <svx/sdr/properties/textproperties.hxx> #include <vcl/metaact.hxx> @@ -1966,6 +1967,10 @@ void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus ) if ( pEditStatus->IsPageOverflow() ) { mpOverflowingText = pEdtOutl->GetOverflowingText(); SdrTextObj *pNextTextObj = GetNextLinkInChain(); + + impLeaveOnlyNonOverflowingText(); + + // Transfer overflowing text impMoveChainedTextToNextLink(pNextTextObj); } diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index 0d57eff..e60cbb8 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -728,13 +728,37 @@ void SdrTextObj::impDecomposeContourTextPrimitive( rTarget = aConverter.getPrimitive2DSequence(); } -void SdrTextObj::embedText() const +void SdrTextObj::impLeaveOnlyNonOverflowingText() const { + // Cut non overflowing text // FIXME: Move this in separate function + NonOverflowingText *pNonOverflowingTxt = + pEdtOutl->GetNonOverflowingText(); + SdrOutliner &rOutliner = ImpGetDrawOutliner(); + rOutliner.Clear(); + + if (pNonOverflowingTxt->mPreOverflowingTxt == "" && + pNonOverflowingTxt->mpHeadParas != NULL) { + // Only (possibly empty) paragraphs before overflowing one + rOutliner.SetText(*pNonOverflowingTxt->mpHeadParas); + } else { // We have to include the non-overflowing lines from the overfl. para + + // first make a ParaObject for the strings + Paragraph *pTmpPara0 = rOutliner.GetParagraph(0); + rOutliner.SetText(pNonOverflowingTxt->mPreOverflowingTxt, pTmpPara0); + OutlinerParaObject *pPObj = rOutliner.CreateParaObject(); + rOutliner.Clear(); + if (pNonOverflowingTxt->mpHeadParas != NULL) + rOutliner.SetText(*pNonOverflowingTxt->mpHeadParas); + + rOutliner.AddText(*pPObj); + } + + OutlinerParaObject *pNewText = rOutliner.CreateParaObject(); + const_cast<SdrTextObj*>(this)->NbcSetOutlinerParaObject(pNewText); } -// A new temporary implementation of impMoveChainedTextToNextLink -// Should implement the whole logic + void SdrTextObj::impMoveChainedTextToNextLink(SdrTextObj *pNextTextObj) const { // prevent copying text in same box diff --git a/svx/source/svdraw/svdotxed.cxx b/svx/source/svdraw/svdotxed.cxx index 1bebccf..c0a5164 100644 --- a/svx/source/svdraw/svdotxed.cxx +++ b/svx/source/svdraw/svdotxed.cxx @@ -24,6 +24,7 @@ #include <editeng/editdata.hxx> #include <editeng/outliner.hxx> #include <editeng/editstat.hxx> +#include <editeng/overflowingtxt.hxx> #include <svl/itemset.hxx> #include <editeng/eeitem.hxx> #include <svx/sdtfchim.hxx> @@ -275,12 +276,19 @@ void SdrTextObj::EndTextEdit(SdrOutliner& rOutl) // TODO: move this to one level higher if ( IsToBeChained() && GetNextLinkInChain() != this) // XXX: defensive check { + // FIXME: matteocam + // for now doing the same as below - probably we don't need + // any more chain checks here but one single default behavior + sal_Int32 nParaAnz = rOutl.GetParagraphCount(); + pNewText = rOutl.CreateParaObject( 0, nParaAnz ); + // set non overflow part of text to current box - pNewText = rOutl.GetNonOverflowingParaObject(); // empty text obj. if 1st para is overflowing + + // XXX XXX XXX XXX: decomment next line and fix const conversion problem + //pNewText = rOutl.GetNonOverflowingText()->mpHeadParas; // empty text obj. if 1st para is overflowing // set overflowing text for SdrChainedTextPrimitive2D mpOverflowingText = rOutl.GetOverflowingText(); // TODO: factor the lines of code above in a single function - } else // standard case { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits