Kaydet (Commit) e1a9a348 authored tarafından Michael Stahl's avatar Michael Stahl

fdo#66145: fix copying of header/footer when un-sharing

SwDoc::CopyMasterHeader/Footer(): this could result in sharing the
first-page header/footer with the left-page (!) when un-sharing
via the dialog; the reason is that what actually happens here is that
the left-page header/footer was never changed but the master one
was copied in SwDocStyleSheet::SetItemSet(), so it sort of worked
by accident before the first-page header/footer was added...

Change-Id: Ia24df6ad59cda484559f2ca48ecaa7563878120b
üst 0b7a823b
...@@ -194,7 +194,11 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, ...@@ -194,7 +194,11 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead,
const SwFrmFmt& rChgedFrmFmt = (bLeft ? rChged.GetLeft() : rChged.GetFirst()); const SwFrmFmt& rChgedFrmFmt = (bLeft ? rChged.GetLeft() : rChged.GetFirst());
rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetHeader() ); rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetHeader() );
} }
else if( (*aRCnt.GetCntntIdx()) == (*aCnt.GetCntntIdx()) ) else if ((*aRCnt.GetCntntIdx() == *aCnt.GetCntntIdx()) ||
// The CntntIdx is _always_ different when called from
// SwDocStyleSheet::SetItemSet, because it deep-copies the
// PageDesc. So check if it was previously shared.
((bLeft) ? pDesc->IsHeaderShared() : pDesc->IsFirstShared()))
{ {
SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), (bLeft ? "Left header" : "First header"), SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), (bLeft ? "Left header" : "First header"),
GetDfltFrmFmt() ); GetDfltFrmFmt() );
...@@ -250,7 +254,11 @@ void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, ...@@ -250,7 +254,11 @@ void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot,
const SwFrmFmt& rChgedFrmFmt = (bLeft ? rChged.GetLeft() : rChged.GetFirst()); const SwFrmFmt& rChgedFrmFmt = (bLeft ? rChged.GetLeft() : rChged.GetFirst());
rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetFooter() ); rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetFooter() );
} }
else if( (*aRCnt.GetCntntIdx()) == (*aLCnt.GetCntntIdx()) ) else if ((*aRCnt.GetCntntIdx() == *aLCnt.GetCntntIdx()) ||
// The CntntIdx is _always_ different when called from
// SwDocStyleSheet::SetItemSet, because it deep-copies the
// PageDesc. So check if it was previously shared.
((bLeft) ? pDesc->IsHeaderShared() : pDesc->IsFirstShared()))
{ {
SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), (bLeft ? "Left footer" : "First footer"), SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), (bLeft ? "Left footer" : "First footer"),
GetDfltFrmFmt() ); GetDfltFrmFmt() );
...@@ -344,8 +352,6 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged ) ...@@ -344,8 +352,6 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
CopyMasterHeader(rChged, rHead, pDesc, true); // Copy left header CopyMasterHeader(rChged, rHead, pDesc, true); // Copy left header
CopyMasterHeader(rChged, rHead, pDesc, false); // Copy first header CopyMasterHeader(rChged, rHead, pDesc, false); // Copy first header
pDesc->ChgHeaderShare( rChged.IsHeaderShared() ); pDesc->ChgHeaderShare( rChged.IsHeaderShared() );
// there is just one first shared flag for both header and footer?
pDesc->ChgFirstShare( rChged.IsFirstShared() );
// Synch Footer. // Synch Footer.
const SwFmtFooter &rFoot = rChged.GetMaster().GetFooter(); const SwFmtFooter &rFoot = rChged.GetMaster().GetFooter();
...@@ -362,6 +368,8 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged ) ...@@ -362,6 +368,8 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
CopyMasterFooter(rChged, rFoot, pDesc, true); // Copy left footer CopyMasterFooter(rChged, rFoot, pDesc, true); // Copy left footer
CopyMasterFooter(rChged, rFoot, pDesc, false); // Copy first footer CopyMasterFooter(rChged, rFoot, pDesc, false); // Copy first footer
pDesc->ChgFooterShare( rChged.IsFooterShared() ); pDesc->ChgFooterShare( rChged.IsFooterShared() );
// there is just one first shared flag for both header and footer?
pDesc->ChgFirstShare( rChged.IsFirstShared() );
if ( pDesc->GetName() != rChged.GetName() ) if ( pDesc->GetName() != rChged.GetName() )
pDesc->SetName( rChged.GetName() ); pDesc->SetName( rChged.GetName() );
......
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