Blame SOURCES/0001-Resolves-rhbz-1161238-sync-PRESOBJ_OUTLINE-para-dept.patch

ebc4bd
From a6ddf90a2c4070d9c2355b7349db9f02b2119dc4 Mon Sep 17 00:00:00 2001
ebc4bd
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
ebc4bd
Date: Fri, 7 Nov 2014 14:16:58 +0000
ebc4bd
Subject: [PATCH] Resolves: rhbz#1161238 sync PRESOBJ_OUTLINE para depths to
ebc4bd
 outline numbering
ebc4bd
ebc4bd
same problem as fdo#78151, except that pre-existing documents created
ebc4bd
before the bullet/numbering toggling UI change have PRESOBJ_OUTLINEs with
ebc4bd
paras in them with "numbering off" but the outline level they are a
ebc4bd
preview of still have numbering enabled.
ebc4bd
ebc4bd
Leave the actual numbering styles alone in this case and toggle the
ebc4bd
PRESOBJ_OUTLINEs paras back to the level they "really" are
ebc4bd
ebc4bd
Change-Id: I76508f88b5003afd1740feee3ec328326117f896
ebc4bd
---
ebc4bd
 sd/source/filter/xml/sdxmlwrp.cxx | 48 +++++++++++++++++++++++++++++++++++++++
ebc4bd
 1 file changed, 48 insertions(+)
ebc4bd
ebc4bd
diff --git a/sd/source/filter/xml/sdxmlwrp.cxx b/sd/source/filter/xml/sdxmlwrp.cxx
ebc4bd
index 411e7b1..65a52ac 100644
ebc4bd
--- a/sd/source/filter/xml/sdxmlwrp.cxx
ebc4bd
+++ b/sd/source/filter/xml/sdxmlwrp.cxx
ebc4bd
@@ -26,6 +26,7 @@
ebc4bd
 #include <sfx2/docfile.hxx>
ebc4bd
 #include <sfx2/docfilt.hxx>
ebc4bd
 #include "drawdoc.hxx"
ebc4bd
+#include "Outliner.hxx"
ebc4bd
 #include <unotools/streamwrap.hxx>
ebc4bd
 #include <svx/xmlgrhlp.hxx>
ebc4bd
 
ebc4bd
@@ -415,6 +416,51 @@ sal_Int32 ReadThroughComponent(
ebc4bd
 
ebc4bd
 
ebc4bd
 
ebc4bd
+//PRESOBJ_OUTLINEs in master pages are the preview of the outline styles
ebc4bd
+//numbering format. Since fdo#78151 toggling bullets on and off changes
ebc4bd
+//the style they are a preview of, previously toggling bullets on and off
ebc4bd
+//would only affect the preview paragraph itself without an effect on the
ebc4bd
+//style. i.e.  previews of numbering which don't match the real numbering
ebc4bd
+//they are supposed to be a preview of.
ebc4bd
+//
ebc4bd
+//But there exist documents which were saved previous to that modification
ebc4bd
+//so here we detect such cases and fix them up to ensure the previews
ebc4bd
+//numbering level matches that of the outline level it previews
ebc4bd
+void fixupOutlinePlaceholderNumberingDepths(SdDrawDocument* pDoc)
ebc4bd
+{
ebc4bd
+    for (sal_uInt16 i = 0; i < pDoc->GetMasterSdPageCount(PK_STANDARD); ++i)
ebc4bd
+    {
ebc4bd
+        SdPage *pMasterPage = pDoc->GetMasterSdPage(i, PK_STANDARD);
ebc4bd
+        SdrObject* pMasterOutline = pMasterPage->GetPresObj(PRESOBJ_OUTLINE);
ebc4bd
+        if (!pMasterOutline)
ebc4bd
+            continue;
ebc4bd
+        OutlinerParaObject* pOutlParaObj = pMasterOutline->GetOutlinerParaObject();
ebc4bd
+        if (!pOutlParaObj)
ebc4bd
+            continue;
ebc4bd
+        ::sd::Outliner* pOutliner = pDoc->GetInternalOutliner();
ebc4bd
+        pOutliner->Clear();
ebc4bd
+        pOutliner->SetText(*pOutlParaObj);
ebc4bd
+        bool bInconsistent = false;
ebc4bd
+        const sal_Int32 nParaCount = pOutliner->GetParagraphCount();
ebc4bd
+        for (sal_Int32 j = 0; j < nParaCount; ++j)
ebc4bd
+        {
ebc4bd
+            const sal_Int16 nExpectedDepth = j;
ebc4bd
+            if (nExpectedDepth != pOutliner->GetDepth(j))
ebc4bd
+            {
ebc4bd
+                Paragraph* p = pOutliner->GetParagraph(j);
ebc4bd
+                pOutliner->SetDepth(p, nExpectedDepth);
ebc4bd
+                bInconsistent = true;
ebc4bd
+            }
ebc4bd
+        }
ebc4bd
+        if (bInconsistent)
ebc4bd
+        {
ebc4bd
+            SAL_WARN("sd.filter", "Fixing inconsistent outline numbering placeholder preview depth");
ebc4bd
+            pMasterOutline->SetOutlinerParaObject(pOutliner->CreateParaObject(0, nParaCount));
ebc4bd
+        }
ebc4bd
+        pOutliner->Clear();
ebc4bd
+    }
ebc4bd
+}
ebc4bd
+
ebc4bd
 bool SdXMLFilter::Import( ErrCode& nError )
ebc4bd
 {
ebc4bd
     sal_uInt32  nRet = 0;
ebc4bd
@@ -779,6 +825,8 @@ bool SdXMLFilter::Import( ErrCode& nError )
ebc4bd
         }
ebc4bd
     }
ebc4bd
 
ebc4bd
+    fixupOutlinePlaceholderNumberingDepths(pDoc);
ebc4bd
+
ebc4bd
     pDoc->EnableUndo(true);
ebc4bd
     mrDocShell.ClearUndoBuffer();
ebc4bd
     return nRet == 0;
ebc4bd
-- 
ebc4bd
1.9.3
ebc4bd