Kaydet (Commit) 4139f124 authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: rhbz#1161238 sync PRESOBJ_OUTLINE para depths to outline numbering

same problem as fdo#78151, except that pre-existing documents created
before the bullet/numbering toggling UI change have PRESOBJ_OUTLINEs with
paras in them with "numbering off" but the outline level they are a
preview of still have numbering enabled.

Leave the actual numbering styles alone in this case and toggle the
PRESOBJ_OUTLINEs paras back to the level they "really" are

Change-Id: I76508f88b5003afd1740feee3ec328326117f896
üst dce20aa0
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <sfx2/docfile.hxx> #include <sfx2/docfile.hxx>
#include <sfx2/docfilt.hxx> #include <sfx2/docfilt.hxx>
#include "drawdoc.hxx" #include "drawdoc.hxx"
#include "Outliner.hxx"
#include <unotools/streamwrap.hxx> #include <unotools/streamwrap.hxx>
#include <svx/xmlgrhlp.hxx> #include <svx/xmlgrhlp.hxx>
...@@ -415,6 +416,51 @@ sal_Int32 ReadThroughComponent( ...@@ -415,6 +416,51 @@ sal_Int32 ReadThroughComponent(
} }
//PRESOBJ_OUTLINEs in master pages are the preview of the outline styles
//numbering format. Since fdo#78151 toggling bullets on and off changes
//the style they are a preview of, previously toggling bullets on and off
//would only affect the preview paragraph itself without an effect on the
//style. i.e. previews of numbering which don't match the real numbering
//they are supposed to be a preview of.
//
//But there exist documents which were saved previous to that modification
//so here we detect such cases and fix them up to ensure the previews
//numbering level matches that of the outline level it previews
void fixupOutlinePlaceholderNumberingDepths(SdDrawDocument* pDoc)
{
for (sal_uInt16 i = 0; i < pDoc->GetMasterSdPageCount(PK_STANDARD); ++i)
{
SdPage *pMasterPage = pDoc->GetMasterSdPage(i, PK_STANDARD);
SdrObject* pMasterOutline = pMasterPage->GetPresObj(PRESOBJ_OUTLINE);
if (!pMasterOutline)
continue;
OutlinerParaObject* pOutlParaObj = pMasterOutline->GetOutlinerParaObject();
if (!pOutlParaObj)
continue;
::sd::Outliner* pOutliner = pDoc->GetInternalOutliner();
pOutliner->Clear();
pOutliner->SetText(*pOutlParaObj);
bool bInconsistent = false;
const sal_Int32 nParaCount = pOutliner->GetParagraphCount();
for (sal_Int32 j = 0; j < nParaCount; ++j)
{
const sal_Int16 nExpectedDepth = j;
if (nExpectedDepth != pOutliner->GetDepth(j))
{
Paragraph* p = pOutliner->GetParagraph(j);
pOutliner->SetDepth(p, nExpectedDepth);
bInconsistent = true;
}
}
if (bInconsistent)
{
SAL_WARN("sd.filter", "Fixing inconsistent outline numbering placeholder preview depth");
pMasterOutline->SetOutlinerParaObject(pOutliner->CreateParaObject(0, nParaCount));
}
pOutliner->Clear();
}
}
bool SdXMLFilter::Import( ErrCode& nError ) bool SdXMLFilter::Import( ErrCode& nError )
{ {
sal_uInt32 nRet = 0; sal_uInt32 nRet = 0;
...@@ -763,6 +809,8 @@ bool SdXMLFilter::Import( ErrCode& nError ) ...@@ -763,6 +809,8 @@ bool SdXMLFilter::Import( ErrCode& nError )
} }
} }
fixupOutlinePlaceholderNumberingDepths(pDoc);
pDoc->EnableUndo(true); pDoc->EnableUndo(true);
mrDocShell.ClearUndoBuffer(); mrDocShell.ClearUndoBuffer();
return nRet == 0; return nRet == 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment