[Libreoffice-commits] core.git: Branch 'feature/gsoc14-draw-chained-text-boxes' - include/svx svx/source
matteocam
matteo.campanelli at gmail.com
Tue Jun 30 08:13:52 PDT 2015
include/svx/textchainflow.hxx | 30 +++++---
svx/source/svdraw/svdotext.cxx | 1
svx/source/svdraw/textchainflow.cxx | 133 ++++++------------------------------
3 files changed, 44 insertions(+), 120 deletions(-)
New commits:
commit ffc855ced5099d07fa71230448ef376fe4ba33e3
Author: matteocam <matteo.campanelli at gmail.com>
Date: Tue Jun 30 11:13:09 2015 -0400
Use OFlowChainedText in TextChainFlow
Change-Id: I2aaa472590ba90880c545ca767069860623b8089
diff --git a/include/svx/textchainflow.hxx b/include/svx/textchainflow.hxx
index 776dc22..3215194 100644
--- a/include/svx/textchainflow.hxx
+++ b/include/svx/textchainflow.hxx
@@ -26,12 +26,13 @@ class NonOverflowingText;
class OverflowingText;
class TextChain;
class OutlinerParaObject;
+class OFlowChainedText;
-// XXX: Specialize class for Editing mode and non editing mode?
// XXX: const qualifiers?
class TextChainFlow {
+ // -- Public Members --
public:
TextChainFlow(SdrTextObj *pChainTarget);
virtual ~TextChainFlow();
@@ -39,16 +40,22 @@ class TextChainFlow {
// Check for flow events in Outliner
virtual void CheckForFlowEvents(SdrOutliner *);
- bool IsOverflow();
- bool IsUnderflow();
-
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 *);
- SdrTextObj *GetLinkTarget();
+ // Getters
+
+ bool IsOverflow() const;
+ bool IsUnderflow() const;
+
+ SdrTextObj *GetLinkTarget() const;
+ SdrTextObj *GetNextLink() const;
+
+ OFlowChainedText *GetOverflowChainedText() const;
+ // -- Protected Members --
protected:
void impCheckForFlowEvents(SdrOutliner *, SdrOutliner *);
@@ -62,11 +69,11 @@ 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);
+ // -- Private Members --
private:
-
- void impSetOutlinerToEmptyTxt(SdrOutliner *pOutliner);
-
SdrTextObj *mpTargetLink;
SdrTextObj *mpNextLink;
@@ -77,8 +84,10 @@ class TextChainFlow {
bool bUnderflow;
bool bOverflow;
- OverflowingText *mpOverflowingTxt;
- NonOverflowingText *mpNonOverflowingTxt;
+ OFlowChainedText *mpOverflChText;
+
+ //OverflowingText *mpOverflowingTxt;
+ //NonOverflowingText *mpNonOverflowingTxt;
OutlinerParaObject *mpUnderflowingPObj;
@@ -93,7 +102,6 @@ class EditingTextChainFlow : public TextChainFlow
//virtual void ExecuteOverflow(SdrOutliner *, SdrOutliner *) SAL_OVERRIDE;
-
protected:
virtual void impLeaveOnlyNonOverflowingText(SdrOutliner *) SAL_OVERRIDE;
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index d0443fa..fbb76d0 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -50,7 +50,6 @@
#include <svx/textchainflow.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>
diff --git a/svx/source/svdraw/textchainflow.cxx b/svx/source/svdraw/textchainflow.cxx
index 1261175..0e4be0b 100644
--- a/svx/source/svdraw/textchainflow.cxx
+++ b/svx/source/svdraw/textchainflow.cxx
@@ -34,8 +34,9 @@ TextChainFlow::TextChainFlow(SdrTextObj *pChainTarget)
bUnderflow = bOverflow = false;
- mpOverflowingTxt = NULL;
- mpNonOverflowingTxt = NULL;
+ mpOverflChText = NULL;
+ //mpOverflowingTxt = NULL;
+ //mpNonOverflowingTxt = NULL;
mpUnderflowingPObj = NULL;
@@ -86,9 +87,10 @@ void TextChainFlow::impCheckForFlowEvents(SdrOutliner *pFlowOutl, SdrOutliner *p
bUnderflow = !bIsPageOverflow && mpNextLink && mpNextLink->HasText();
// Set (Non)OverflowingTxt here
+ mpOverflChText = bOverflow ? new OFlowChainedText(pFlowOutl, mpNextLink->GetOutlinerParaObject()) : NULL;
- mpOverflowingTxt = bOverflow ? pFlowOutl->GetOverflowingText() : NULL;
- mpNonOverflowingTxt = bOverflow ? pFlowOutl->GetNonOverflowingText() : NULL;
+ //mpOverflowingTxt = bOverflow ? pFlowOutl->GetOverflowingText() : NULL;
+ //mpNonOverflowingTxt = bOverflow ? pFlowOutl->GetNonOverflowingText() : NULL;
// Set current underflowing text (if any)
mpUnderflowingPObj = bUnderflow ? pFlowOutl->CreateParaObject() : NULL;
@@ -101,12 +103,12 @@ void TextChainFlow::CheckForFlowEvents(SdrOutliner *pFlowOutl)
}
-bool TextChainFlow::IsOverflow()
+bool TextChainFlow::IsOverflow() const
{
return bOverflow;
}
-bool TextChainFlow::IsUnderflow()
+bool TextChainFlow::IsUnderflow() const
{
return bUnderflow;
}
@@ -178,118 +180,24 @@ void TextChainFlow::impMoveChainedTextToNextLink(SdrOutliner *pOverflOutl)
OutlinerParaObject *TextChainFlow::impGetNonOverflowingParaObject(SdrOutliner *pOutliner)
{
- if (mpNonOverflowingTxt == NULL)
- return NULL;
-
- if (mpNonOverflowingTxt->mPreOverflowingTxt == "" &&
- mpNonOverflowingTxt->mpHeadParas != NULL) {
- // Only (possibly empty) paragraphs before overflowing one
- pOutliner->SetText(*mpNonOverflowingTxt->mpHeadParas);
- } else { // We have to include the non-overflowing lines from the overfl. para
-
- // first make a ParaObject for the strings
- impSetOutlinerToEmptyTxt(pOutliner);
- Paragraph *pTmpPara0 = pOutliner->GetParagraph(0);
- pOutliner->SetText(mpNonOverflowingTxt->mPreOverflowingTxt, pTmpPara0);
- OutlinerParaObject *pPObj = pOutliner->CreateParaObject();
- //pOutliner->Clear();
- //pOutliner->SetStyleSheet( 0, pEdtOutl->GetStyleSheet(0));
-
- if (mpNonOverflowingTxt->mpHeadParas != NULL) {
- pOutliner->SetText(*mpNonOverflowingTxt->mpHeadParas);
- pOutliner->AddText(*pPObj);
- } else if (mpNonOverflowingTxt->mPreOverflowingTxt != "") { // only preoverflowing txt
- //OutlinerParaObject *pEmptyPObj = pOutliner->GetEmptyParaObject();
- //pOutliner->SetText(*pEmptyPObj);
- pOutliner->SetText(*pPObj);
- } else { // no text // This case is redundant but it doesn't hurt for now
- pOutliner->Clear();
- }
- }
-
- return pOutliner->CreateParaObject();
+ return mpOverflChText->CreateNonOverflowingParaObject(pOutliner);
}
-void TextChainFlow::impSetOutlinerToEmptyTxt(SdrOutliner *pOutliner)
+
+
+SdrTextObj *TextChainFlow::GetLinkTarget() const
{
- OutlinerParaObject *pEmptyTxt = pOutliner->GetEmptyParaObject();
- pOutliner->SetText(*pEmptyTxt);
+ return mpTargetLink;
}
-SdrTextObj *TextChainFlow::GetLinkTarget()
+SdrTextObj *TextChainFlow::GetNextLink() const
{
- return mpTargetLink;
+ return mpNextLink;
}
OutlinerParaObject *TextChainFlow::impGetOverflowingParaObject(SdrOutliner *pOutliner)
{
-
- if (mpOverflowingTxt == NULL)
- return NULL;
-
- OutlinerParaObject *pCurTxt = mpNextLink->GetOutlinerParaObject();
- pOutliner->SetText(*pCurTxt);
-
- // Get text of first paragraph of destination box
- Paragraph *pOldPara0 = pOutliner->GetParagraph(0);
- OUString aOldPara0Txt;
- if (pOldPara0)
- aOldPara0Txt = pOutliner->GetText(pOldPara0);
-
- // Get other paras of destination box (from second on)
- OutlinerParaObject *pOldParasTail = NULL;
- if (pOutliner->GetParagraphCount() > 1)
- pOldParasTail = pOutliner->CreateParaObject(1);
-
- // Create ParaObject appending old first para in the dest. box
- // to last part of overflowing text
- Paragraph *pTmpPara0 = NULL;
- OutlinerParaObject *pJoiningPara = NULL;
-
- if (pOldPara0) {
- //pOutliner->Clear(); // you need a clear outliner here
- impSetOutlinerToEmptyTxt(pOutliner);
-
- pTmpPara0 = pOutliner->GetParagraph(0);
- pOutliner->SetText(mpOverflowingTxt->GetEndingLines() + aOldPara0Txt, pTmpPara0);
- pJoiningPara = pOutliner->CreateParaObject();
- }
-
- // Create a Para Object out of mpMidParas
- // (in order to use the SfxItemPool of the current outliner
- // instead of the ones currently in mpMidParas)
-
- // start actual composition
- //pOutliner->Clear();
- impSetOutlinerToEmptyTxt(pOutliner);
-
- // Set headText at the beginning of box
- OUString aHeadTxt = mpOverflowingTxt->GetHeadingLines();
- // If we haven't used heading text yet
- if (mpOverflowingTxt->HasOtherParas()) {
- Paragraph *pNewPara0 = pOutliner->GetParagraph(0);
- pOutliner->SetText(aHeadTxt, pNewPara0);
- }
-
- // Set all the intermediate Paras
- if (mpOverflowingTxt->mpMidParas)
- pOutliner->AddText(*mpOverflowingTxt->mpMidParas);
-
- // Append old first para in the destination box to
- // last part of overflowing text
- if (pJoiningPara && mpOverflowingTxt->HasOtherParas())
- pOutliner->AddText(*pJoiningPara);
- // this second case is if there is to avoid getting an empty line before pJoiningPara
- else if (pJoiningPara && !mpOverflowingTxt->HasOtherParas())
- pOutliner->SetText(*pJoiningPara);
-
- // Append all other old paras
- if (pOldParasTail)
- pOutliner->AddText(*pOldParasTail);
-
- // Draw everything
- OutlinerParaObject *pNewText = pOutliner->CreateParaObject();
- return pNewText;
+ return mpOverflChText->CreateOverflowingParaObject(pOutliner);
}
TextChain *TextChainFlow::GetTextChain()
@@ -297,6 +205,14 @@ TextChain *TextChainFlow::GetTextChain()
return mpTextChain;
}
+OFlowChainedText *TextChainFlow::GetOverflowChainedText() const
+{
+ return mpOverflChText;
+}
+
+
+// EditingTextChainFlow
+
EditingTextChainFlow::EditingTextChainFlow(SdrTextObj *pLinkTarget) :
TextChainFlow(pLinkTarget)
{
@@ -366,5 +282,6 @@ void EditingTextChainFlow::impSetFlowOutlinerParams(SdrOutliner *pFlowOutl, SdrO
*
*
*
+ */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list