[Libreoffice-commits] core.git: Branch 'feature/gsoc14-draw-chained-text-boxes' - editeng/source include/editeng
matteocam
matteo.campanelli at gmail.com
Tue Jun 30 07:58:55 PDT 2015
editeng/source/outliner/overflowingtxt.cxx | 113 ++++++++++++++++++++++++++++-
include/editeng/overflowingtxt.hxx | 5 +
2 files changed, 117 insertions(+), 1 deletion(-)
New commits:
commit 094a55ed52794a9a676ec2d8a5e8fe401fbac13a
Author: matteocam <matteo.campanelli at gmail.com>
Date: Tue Jun 30 10:58:21 2015 -0400
OFlowChainedText now creates OutlinerParaObject-s for chainging
Change-Id: I1f3f37fa92472471f77362c029e9525523ea6d09
diff --git a/editeng/source/outliner/overflowingtxt.cxx b/editeng/source/outliner/overflowingtxt.cxx
index ca0af38..85aa0b2 100644
--- a/editeng/source/outliner/overflowingtxt.cxx
+++ b/editeng/source/outliner/overflowingtxt.cxx
@@ -21,6 +21,7 @@
#include <tools/debug.hxx>
#include <editeng/overflowingtxt.hxx>
+#include <editeng/outliner.hxx>
OUString OverflowingText::GetEndingLines() const
@@ -42,7 +43,117 @@ OUString OverflowingText::GetHeadingLines() const
OFlowChainedText::OFlowChainedText(Outliner *pOutl, OutlinerParaObject* pTextToBeMerged)
: mpTextToBeMerged(pTextToBeMerged)
{
- // Initialize stuff here
+ mpOverflowingTxt = pOutl->GetOverflowingText();
+ mpNonOverflowingTxt = pOutl->GetNonOverflowingText();
+}
+
+OutlinerParaObject *OFlowChainedText::CreateOverflowingParaObject(Outliner *pOutliner)
+{
+ if (mpOverflowingTxt == NULL)
+ return NULL;
+
+ pOutliner->SetText(*mpTextToBeMerged);
+
+ // 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;
+}
+
+OutlinerParaObject *OFlowChainedText::CreateNonOverflowingParaObject(Outliner *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();
+}
+
+void OFlowChainedText::impSetOutlinerToEmptyTxt(Outliner *pOutliner)
+{
+ OutlinerParaObject *pEmptyTxt = pOutliner->GetEmptyParaObject();
+ pOutliner->SetText(*pEmptyTxt);
}
diff --git a/include/editeng/overflowingtxt.hxx b/include/editeng/overflowingtxt.hxx
index 0c42d53..3920af3 100644
--- a/include/editeng/overflowingtxt.hxx
+++ b/include/editeng/overflowingtxt.hxx
@@ -92,7 +92,12 @@ class EDITENG_DLLPUBLIC OFlowChainedText {
OutlinerParaObject *GetTextToBeMerged() const { return mpTextToBeMerged; }
+ protected:
+ void impSetOutlinerToEmptyTxt(Outliner *);
+
private:
+
+
NonOverflowingText *mpNonOverflowingTxt;
OverflowingText *mpOverflowingTxt;
More information about the Libreoffice-commits
mailing list