Kaydet (Commit) f0d001a3 authored tarafından Oliver-Rainer Wittmann's avatar Oliver-Rainer Wittmann Kaydeden (comit) Caolán McNamara

Resolves: #i119292# remove misusage of <SwDoc::Set|IsLoaded()>

...for the adjustments of certain AT_PAGE anchored objects

Addresses the underlying problem of fdo#37024 fixed by
9d32497c

(cherry picked from commit b41eec25)

Conflicts:
	sw/inc/doc.hxx
	sw/source/core/doc/doclay.cxx
	sw/source/core/doc/docnew.cxx
	sw/source/core/layout/frmtool.cxx

Change-Id: I786eabdf84677e14c6f4b67d79e1e210e0532a21
üst 641d8eaa
...@@ -475,6 +475,10 @@ private: ...@@ -475,6 +475,10 @@ private:
bool mbXMLExport : 1; ///< sal_True: during XML export bool mbXMLExport : 1; ///< sal_True: during XML export
#endif #endif
// true: Document contains at least one anchored object, which is anchored AT_PAGE with a content position.
// Thus, certain adjustment needed during formatting for these kind of anchored objects.
bool mbContainsAtPageObjWithContentAnchor : 1;
// //
// COMPATIBILITY FLAGS START // COMPATIBILITY FLAGS START
// //
...@@ -1030,6 +1034,15 @@ public: ...@@ -1030,6 +1034,15 @@ public:
void SetXMLExport( bool bFlag ) { mbXMLExport = bFlag; } void SetXMLExport( bool bFlag ) { mbXMLExport = bFlag; }
#endif #endif
void SetContainsAtPageObjWithContentAnchor( const bool bFlag )
{
mbContainsAtPageObjWithContentAnchor = bFlag;
}
bool DoesContainAtPageObjWithContentAnchor()
{
return mbContainsAtPageObjWithContentAnchor;
}
/** Returns positions of all FlyFrames in the document. /** Returns positions of all FlyFrames in the document.
If a Pam-Pointer is passed the FlyFrames attached to paragraphes If a Pam-Pointer is passed the FlyFrames attached to paragraphes
have to be surrounded completely by ::com::sun::star::awt::Selection. have to be surrounded completely by ::com::sun::star::awt::Selection.
......
...@@ -2068,7 +2068,7 @@ void SwDoc::SetAllUniqueFlyNames() ...@@ -2068,7 +2068,7 @@ void SwDoc::SetAllUniqueFlyNames()
SwFrmFmts aArr; SwFrmFmts aArr;
aArr.reserve( n ); aArr.reserve( n );
SwFrmFmt* pFlyFmt; SwFrmFmt* pFlyFmt;
bool bLoadedFlag = true; // something for the Layout bool bContainsAtPageObjWithContentAnchor = false;
for( n = GetSpzFrmFmts()->size(); n; ) for( n = GetSpzFrmFmts()->size(); n; )
{ {
...@@ -2094,22 +2094,17 @@ void SwDoc::SetAllUniqueFlyNames() ...@@ -2094,22 +2094,17 @@ void SwDoc::SetAllUniqueFlyNames()
aArr.push_back( pFlyFmt ); aArr.push_back( pFlyFmt );
} }
if( bLoadedFlag ) if ( !bContainsAtPageObjWithContentAnchor )
{ {
const SwFmtAnchor& rAnchor = pFlyFmt->GetAnchor(); const SwFmtAnchor& rAnchor = pFlyFmt->GetAnchor();
if (((FLY_AT_PAGE == rAnchor.GetAnchorId()) && if ( (FLY_AT_PAGE == rAnchor.GetAnchorId()) &&
rAnchor.GetCntntAnchor()) || rAnchor.GetCntntAnchor() )
// Or are DrawObjects adjusted relatively to something?
( RES_DRAWFRMFMT == pFlyFmt->Which() && (
SFX_ITEM_SET == pFlyFmt->GetItemState(
RES_VERT_ORIENT )||
SFX_ITEM_SET == pFlyFmt->GetItemState(
RES_HORI_ORIENT ))) )
{ {
bLoadedFlag = false; bContainsAtPageObjWithContentAnchor = true;
} }
} }
} }
SetContainsAtPageObjWithContentAnchor( bContainsAtPageObjWithContentAnchor );
const SwNodeIndex* pIdx; const SwNodeIndex* pIdx;
...@@ -2154,11 +2149,6 @@ void SwDoc::SetAllUniqueFlyNames() ...@@ -2154,11 +2149,6 @@ void SwDoc::SetAllUniqueFlyNames()
GetFtnIdxs().UpdateFtn( aTmp ); GetFtnIdxs().UpdateFtn( aTmp );
} }
} }
// Found a new document, but not a page anchored Frame/DrawObjects
// that are anchored to another Node.
if( bLoadedFlag )
SetLoaded( sal_True );
} }
bool SwDoc::IsInHeaderFooter( const SwNodeIndex& rIdx ) const bool SwDoc::IsInHeaderFooter( const SwNodeIndex& rIdx ) const
......
...@@ -282,6 +282,7 @@ SwDoc::SwDoc() ...@@ -282,6 +282,7 @@ SwDoc::SwDoc()
#ifdef DBG_UTIL #ifdef DBG_UTIL
mbXMLExport(false), mbXMLExport(false),
#endif #endif
mbContainsAtPageObjWithContentAnchor(false), //#i119292#, fdo#37024
// COMPATIBILITY FLAGS START // COMPATIBILITY FLAGS START
......
...@@ -835,7 +835,7 @@ SwCntntNotify::~SwCntntNotify() ...@@ -835,7 +835,7 @@ SwCntntNotify::~SwCntntNotify()
} }
} }
bool bFirst = (aFrm.*fnRect->fnGetWidth)() == 0; const bool bFirst = (aFrm.*fnRect->fnGetWidth)() == 0;
if ( pCnt->IsNoTxtFrm() ) if ( pCnt->IsNoTxtFrm() )
{ {
...@@ -909,53 +909,48 @@ SwCntntNotify::~SwCntntNotify() ...@@ -909,53 +909,48 @@ SwCntntNotify::~SwCntntNotify()
SwDoc *pDoc = pCnt->GetNode()->GetDoc(); SwDoc *pDoc = pCnt->GetNode()->GetDoc();
if ( !pDoc->GetSpzFrmFmts()->empty() && if ( !pDoc->GetSpzFrmFmts()->empty() &&
!pDoc->IsLoaded() && !pDoc->IsNewDoc() ) pDoc->DoesContainAtPageObjWithContentAnchor() && !pDoc->IsNewDoc() )
{ {
//The Frm has been formatted probably for the first time. // If certain import filters for foreign file format import
//If a filter read Flys or Drawingobjects and these // AT_PAGE anchored objects, the corresponding page number is
//are bound to the page, he has a problem, because he typically // typically not known. In this case the content position is
//does not know the number of the page. He knows only wich is the // stored at which the anchored object is found in the
//content (CntntNode) at this position. // imported document.
//The filter provides the anchor attribut of the objects so, that // When this content is formatted it is the time at which
//they are side bound type, but the index of the anchor points // the page is known. Thus, this data can be corrected now.
//to this CntntNode.
//Here these preliminary connections are dissolved.
const SwPageFrm *pPage = 0; const SwPageFrm *pPage = 0;
SwNodeIndex *pIdx = 0; SwNodeIndex *pIdx = 0;
SwFrmFmts *pTbl = pDoc->GetSpzFrmFmts(); SwFrmFmts *pTbl = pDoc->GetSpzFrmFmts();
for ( sal_uInt16 i = 0; i < pTbl->size(); ++i ) for ( sal_uInt16 i = 0; i < pTbl->size(); ++i )
{ {
if ( !pPage )
pPage = pCnt->FindPageFrm();
SwFrmFmt *pFmt = (*pTbl)[i]; SwFrmFmt *pFmt = (*pTbl)[i];
const SwFmtAnchor &rAnch = pFmt->GetAnchor(); const SwFmtAnchor &rAnch = pFmt->GetAnchor();
if ( FLY_AT_PAGE != rAnch.GetAnchorId() ||
if ((FLY_AT_PAGE != rAnch.GetAnchorId()) && rAnch.GetCntntAnchor() == 0 )
(FLY_AT_PARA != rAnch.GetAnchorId()))
{ {
continue; //#60878# It's not that character bound. continue;
} }
if ( rAnch.GetCntntAnchor() ) if ( !pIdx )
{ {
if ( !pIdx ) pIdx = new SwNodeIndex( *pCnt->GetNode() );
}
if ( rAnch.GetCntntAnchor()->nNode == *pIdx )
{
OSL_FAIL( "<SwCntntNotify::~SwCntntNotify()> - to page anchored object with content position. Please inform OD." );
if ( !pPage )
{ {
pIdx = new SwNodeIndex( *pCnt->GetNode() ); pPage = pCnt->FindPageFrm();
} }
if ( rAnch.GetCntntAnchor()->nNode == *pIdx ) SwFmtAnchor aAnch( rAnch );
aAnch.SetAnchor( 0 );
aAnch.SetPageNum( pPage->GetPhyPageNum() );
pFmt->SetFmtAttr( aAnch );
if ( RES_DRAWFRMFMT != pFmt->Which() )
{ {
if (FLY_AT_PAGE == rAnch.GetAnchorId()) pFmt->MakeFrms();
{
OSL_FAIL( "<SwCntntNotify::~SwCntntNotify()> - to page anchored object with content position. Please inform OD." );
SwFmtAnchor aAnch( rAnch );
aAnch.SetAnchor( 0 );
aAnch.SetPageNum( pPage->GetPhyPageNum() );
pFmt->SetFmtAttr( aAnch );
if ( RES_DRAWFRMFMT != pFmt->Which() )
pFmt->MakeFrms();
}
} }
} }
} }
......
...@@ -288,10 +288,7 @@ sal_uLong SwReader::Read( const Reader& rOptions ) ...@@ -288,10 +288,7 @@ sal_uLong SwReader::Read( const Reader& rOptions )
} }
else if( pCrsr ) else if( pCrsr )
{ {
// seitengebundene Flys eingefuegt, dann schalte pDoc->SetContainsAtPageObjWithContentAnchor( true );
// die Optimierungs-Flags vom SwDoc ab. Sonst
// werden die Flys nicht an der Position erzeugt.
pDoc->SetLoaded( sal_False );
} }
} }
else else
...@@ -350,6 +347,7 @@ sal_uLong SwReader::Read( const Reader& rOptions ) ...@@ -350,6 +347,7 @@ sal_uLong SwReader::Read( const Reader& rOptions )
pDoc->UpdateNumRule(); pDoc->UpdateNumRule();
pDoc->ChkCondColls(); pDoc->ChkCondColls();
pDoc->SetAllUniqueFlyNames(); pDoc->SetAllUniqueFlyNames();
pDoc->SetLoaded( true );
pDoc->GetIDocumentUndoRedo().DoUndo(bDocUndo); pDoc->GetIDocumentUndoRedo().DoUndo(bDocUndo);
if (!bReadPageDescs) if (!bReadPageDescs)
......
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