[Libreoffice-commits] core.git: Branch 'feature/gsoc14-draw-chained-text-boxes' - 2 commits - editeng/source include/editeng include/svx svx/source
matteocam
matteo.campanelli at gmail.com
Tue Jun 30 10:05:57 PDT 2015
editeng/source/outliner/outliner.cxx | 6 +++
editeng/source/outliner/overflowingtxt.cxx | 23 ++++++++++----
include/editeng/outliner.hxx | 2 +
include/editeng/overflowingtxt.hxx | 17 +++++++++-
include/svx/textchainflow.hxx | 11 +++---
svx/source/svdraw/textchainflow.cxx | 47 ++++++++++++-----------------
6 files changed, 67 insertions(+), 39 deletions(-)
New commits:
commit 191ed1adffa8b33ffdb1b0c18a3555503c907123
Author: matteocam <matteo.campanelli at gmail.com>
Date: Tue Jun 30 13:04:25 2015 -0400
Added UFlowChainedText constructor
Change-Id: Iad9542c624148a4d717724a9f6bc7a453c650c90
diff --git a/editeng/source/outliner/overflowingtxt.cxx b/editeng/source/outliner/overflowingtxt.cxx
index 8ccbf6f..533be0d 100644
--- a/editeng/source/outliner/overflowingtxt.cxx
+++ b/editeng/source/outliner/overflowingtxt.cxx
@@ -149,6 +149,12 @@ OutlinerParaObject *OFlowChainedText::CreateNonOverflowingParaObject(Outliner *p
return pOutliner->CreateParaObject();
}
+
+UFlowChainedText::UFlowChainedText(Outliner *pOutl)
+{
+ mpUnderflowPObj = pOutl->CreateParaObject();
+}
+
OutlinerParaObject *UFlowChainedText::CreateMergedUnderflowParaObject(Outliner *pOutl, OutlinerParaObject *pNextLinkWholeText)
{
OutlinerParaObject *pCurText = mpUnderflowPObj;
commit fa9b4a5d9782252417a89a1ba8ccdf6b3d93485b
Author: matteocam <matteo.campanelli at gmail.com>
Date: Tue Jun 30 13:02:34 2015 -0400
UFlowChainedText used to deal with underflow
Change-Id: I6942b09f016756a81f411ba27ba3f7fcc2fa1aa1
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 060e628..e63c7ff 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -415,6 +415,12 @@ OutlinerParaObject* Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32
return pPObj;
}
+void Outliner::SetToEmptyText()
+{
+ OutlinerParaObject *pEmptyTxt = GetEmptyParaObject();
+ SetText(*pEmptyTxt);
+}
+
void Outliner::SetText( const OUString& rText, Paragraph* pPara )
{
DBG_ASSERT(pPara,"SetText:No Para");
diff --git a/editeng/source/outliner/overflowingtxt.cxx b/editeng/source/outliner/overflowingtxt.cxx
index 9e1ee3d..8ccbf6f 100644
--- a/editeng/source/outliner/overflowingtxt.cxx
+++ b/editeng/source/outliner/overflowingtxt.cxx
@@ -71,7 +71,7 @@ OutlinerParaObject *OFlowChainedText::CreateOverflowingParaObject(Outliner *pOut
if (pOldPara0) {
//pOutliner->Clear(); // you need a clear outliner here
- impSetOutlinerToEmptyTxt(pOutliner);
+ pOutliner->SetToEmptyText();
pTmpPara0 = pOutliner->GetParagraph(0);
pOutliner->SetText(mpOverflowingTxt->GetEndingLines() + aOldPara0Txt, pTmpPara0);
@@ -84,7 +84,7 @@ OutlinerParaObject *OFlowChainedText::CreateOverflowingParaObject(Outliner *pOut
// start actual composition
//pOutliner->Clear();
- impSetOutlinerToEmptyTxt(pOutliner);
+ pOutliner->SetToEmptyText();
// Set headText at the beginning of box
OUString aHeadTxt = mpOverflowingTxt->GetHeadingLines();
@@ -127,7 +127,7 @@ OutlinerParaObject *OFlowChainedText::CreateNonOverflowingParaObject(Outliner *p
} else { // We have to include the non-overflowing lines from the overfl. para
// first make a ParaObject for the strings
- impSetOutlinerToEmptyTxt(pOutliner);
+ pOutliner->SetToEmptyText();
Paragraph *pTmpPara0 = pOutliner->GetParagraph(0);
pOutliner->SetText(mpNonOverflowingTxt->mPreOverflowingTxt, pTmpPara0);
OutlinerParaObject *pPObj = pOutliner->CreateParaObject();
@@ -149,11 +149,16 @@ OutlinerParaObject *OFlowChainedText::CreateNonOverflowingParaObject(Outliner *p
return pOutliner->CreateParaObject();
}
-void OFlowChainedText::impSetOutlinerToEmptyTxt(Outliner *pOutliner)
+OutlinerParaObject *UFlowChainedText::CreateMergedUnderflowParaObject(Outliner *pOutl, OutlinerParaObject *pNextLinkWholeText)
{
- OutlinerParaObject *pEmptyTxt = pOutliner->GetEmptyParaObject();
- pOutliner->SetText(*pEmptyTxt);
-}
+ OutlinerParaObject *pCurText = mpUnderflowPObj;
+
+ // NewTextForCurBox = Txt(CurBox) ++ Txt(NextBox)
+ pOutl->SetText(*pCurText);
+ pOutl->AddText(*pNextLinkWholeText);
+ OutlinerParaObject *pNewText = pOutl->CreateParaObject();
+ return pNewText;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 0cef0cc..ffbb1b7 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -698,6 +698,8 @@ public:
void SetText( const OUString& rText, Paragraph* pParagraph );
OUString GetText( Paragraph* pPara, sal_Int32 nParaCount=1 ) const;
+ void SetToEmptyText();
+
OutlinerParaObject* CreateParaObject( sal_Int32 nStartPara = 0, sal_Int32 nParaCount = EE_PARA_ALL ) const;
const SfxItemSet& GetEmptyItemSet() const;
diff --git a/include/editeng/overflowingtxt.hxx b/include/editeng/overflowingtxt.hxx
index a2602ad..58ff247 100644
--- a/include/editeng/overflowingtxt.hxx
+++ b/include/editeng/overflowingtxt.hxx
@@ -79,10 +79,11 @@ class EDITENG_DLLPUBLIC NonOverflowingText {
// XXX: Do we also need a class for Underflow here?
/*
- * class ChainedText:
+ * classes ?FlowChainedText:
* contains and handles the state of a text broken _after_ a flow event.
*
*/
+
class EDITENG_DLLPUBLIC OFlowChainedText {
public:
OFlowChainedText(Outliner *);
@@ -102,6 +103,20 @@ class EDITENG_DLLPUBLIC OFlowChainedText {
};
+// UFlowChainedText is a simpler class than OFlowChainedText: it almost only joins para-objects
+class EDITENG_DLLPUBLIC UFlowChainedText {
+ public:
+ UFlowChainedText(Outliner *);
+
+ OutlinerParaObject *CreateMergedUnderflowParaObject(Outliner *, OutlinerParaObject *);
+
+ protected:
+
+
+ private:
+ OutlinerParaObject *mpUnderflowPObj;
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/textchainflow.hxx b/include/svx/textchainflow.hxx
index ce6d728..5489bb1 100644
--- a/include/svx/textchainflow.hxx
+++ b/include/svx/textchainflow.hxx
@@ -27,6 +27,7 @@ class OverflowingText;
class TextChain;
class OutlinerParaObject;
class OFlowChainedText;
+class UFlowChainedText;
// XXX: const qualifiers?
@@ -40,7 +41,7 @@ class TextChainFlow {
// Check for flow events in Outliner
virtual void CheckForFlowEvents(SdrOutliner *);
- void ExecuteUnderflow(SdrOutliner *);
+ virtual void ExecuteUnderflow(SdrOutliner *);
// Uses two outliners: one for the non-overfl text and one for overflowing (might be the same)
virtual void ExecuteOverflow(SdrOutliner *, SdrOutliner *);
@@ -54,6 +55,7 @@ class TextChainFlow {
SdrTextObj *GetNextLink() const;
OFlowChainedText *GetOverflowChainedText() const;
+ UFlowChainedText *GetUnderflowChainedText() const;
// -- Protected Members --
protected:
@@ -70,7 +72,7 @@ class TextChainFlow {
OutlinerParaObject *impGetNonOverflowingParaObject(SdrOutliner *pOutliner);
OutlinerParaObject *impGetOverflowingParaObject(SdrOutliner *pOutliner);
// impGetMergedUnderflowingParaObject merges underflowing text with the one in the next box
- OutlinerParaObject *impGetMergedUnderflowingParaObject(SdrOutliner *pOutliner);
+ OutlinerParaObject *impGetMergedUnderflowParaObject(SdrOutliner *pOutliner);
// -- Private Members --
private:
@@ -85,11 +87,8 @@ class TextChainFlow {
bool bOverflow;
OFlowChainedText *mpOverflChText;
+ UFlowChainedText *mpUnderflChText;
- //OverflowingText *mpOverflowingTxt;
- //NonOverflowingText *mpNonOverflowingTxt;
-
- OutlinerParaObject *mpUnderflowingPObj;
};
diff --git a/svx/source/svdraw/textchainflow.cxx b/svx/source/svdraw/textchainflow.cxx
index 93bb2f1..2d23aa5 100644
--- a/svx/source/svdraw/textchainflow.cxx
+++ b/svx/source/svdraw/textchainflow.cxx
@@ -35,12 +35,7 @@ TextChainFlow::TextChainFlow(SdrTextObj *pChainTarget)
bUnderflow = bOverflow = false;
mpOverflChText = NULL;
- //mpOverflowingTxt = NULL;
- //mpNonOverflowingTxt = NULL;
-
- mpUnderflowingPObj = NULL;
-
- // XXX: Set the next link here?
+ mpUnderflChText = NULL;
}
@@ -69,10 +64,11 @@ void TextChainFlow::impCheckForFlowEvents(SdrOutliner *pFlowOutl, SdrOutliner *p
// NOTE: Nah you probably don't need this
if (pParamOutl != NULL)
{
- // XXX: Set parameters
- // XXX: does this work if you do it before setting the text? Seems so.
+ // We need this since it's required to check overflow
pFlowOutl->SetUpdateMode(true);
- impSetFlowOutlinerParams(pFlowOutl, pParamOutl);
+
+ // XXX: does this work if you do it before setting the text? Seems so.
+ impSetFlowOutlinerParams(pFlowOutl, pParamOutl);
}
bool bIsPageOverflow = pFlowOutl->IsPageOverflow();
@@ -86,14 +82,11 @@ void TextChainFlow::impCheckForFlowEvents(SdrOutliner *pFlowOutl, SdrOutliner *p
bOverflow = bIsPageOverflow && mpNextLink;
bUnderflow = !bIsPageOverflow && mpNextLink && mpNextLink->HasText();
- // Set (Non)OverflowingTxt here
+ // Set (Non)OverflowingTxt here (if any)
mpOverflChText = bOverflow ? new OFlowChainedText(pFlowOutl) : NULL;
- //mpOverflowingTxt = bOverflow ? pFlowOutl->GetOverflowingText() : NULL;
- //mpNonOverflowingTxt = bOverflow ? pFlowOutl->GetNonOverflowingText() : NULL;
-
// Set current underflowing text (if any)
- mpUnderflowingPObj = bUnderflow ? pFlowOutl->CreateParaObject() : NULL;
+ mpUnderflChText = bUnderflow ? new UFlowChainedText(pFlowOutl) : NULL;
}
@@ -119,26 +112,17 @@ bool TextChainFlow::IsUnderflow() const
// XXX:Would it be possible to unify undeflow and its possibly following overrflow?
void TextChainFlow::ExecuteUnderflow(SdrOutliner *pOutl)
{
- OutlinerParaObject *pNextLinkWholeText = mpNextLink->GetOutlinerParaObject();
-
// making whole text
- OutlinerParaObject *pCurText;
- // We saved this text already
- pCurText = mpUnderflowingPObj;
+ OutlinerParaObject *pNewText = impGetMergedUnderflowParaObject(pOutl);
- // NewTextForCurBox = Txt(CurBox) ++ Txt(NextBox)
- pOutl->SetText(*pCurText);
- pOutl->AddText(*pNextLinkWholeText);
- OutlinerParaObject *pNewText = pOutl->CreateParaObject();
-
- // Set the other box empty so if overflow does not occur we are fine
+ // Set the other box empty; it will be replaced by the rest of the text if overflow occurs
if (!mpTargetLink->GetPreventChainable())
mpNextLink->NbcSetOutlinerParaObject(pOutl->GetEmptyParaObject());
mpTargetLink->NbcSetOutlinerParaObject(pNewText);
// Check for new overflow
- CheckForFlowEvents(pOutl); // XXX: How do you know you don't need to set parameters here?
+ CheckForFlowEvents(pOutl);
}
void TextChainFlow::ExecuteOverflow(SdrOutliner *pNonOverflOutl, SdrOutliner *pOverflOutl)
@@ -196,6 +180,12 @@ OutlinerParaObject *TextChainFlow::impGetOverflowingParaObject(SdrOutliner *pOut
return mpOverflChText->CreateOverflowingParaObject(pOutliner, mpNextLink->GetOutlinerParaObject());
}
+OutlinerParaObject *TextChainFlow::impGetMergedUnderflowParaObject(SdrOutliner *pOutliner)
+{
+ // Should check whether to merge paragraphs or not
+ return mpUnderflChText->CreateMergedUnderflowParaObject(pOutliner, mpNextLink->GetOutlinerParaObject());
+}
+
TextChain *TextChainFlow::GetTextChain()
{
return mpTextChain;
@@ -206,6 +196,11 @@ OFlowChainedText *TextChainFlow::GetOverflowChainedText() const
return mpOverflChText;
}
+UFlowChainedText *TextChainFlow::GetUnderflowChainedText() const
+{
+ return mpUnderflChText;
+}
+
// EditingTextChainFlow
More information about the Libreoffice-commits
mailing list