[Libreoffice-commits] core.git: sw/inc sw/source

Oliver-Rainer Wittmann orw at apache.org
Tue Apr 2 02:54:37 PDT 2013


 sw/inc/doc.hxx                      |   13 +++++++
 sw/source/core/doc/doclay.cxx       |   22 +++---------
 sw/source/core/doc/docnew.cxx       |    1 
 sw/source/core/layout/frmtool.cxx   |   61 ++++++++++++++++--------------------
 sw/source/filter/basflt/shellio.cxx |    6 +--
 5 files changed, 50 insertions(+), 53 deletions(-)

New commits:
commit f0d001a378c64ea457e722266e60c96522c72e9b
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date:   Wed May 9 12:51:10 2012 +0000

    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
    9d32497c01475f2b5e5bec756e4dd0ca9f9d4928
    
    (cherry picked from commit b41eec25c2c6bc44eef55ae1c4ef57b9012fc8e6)
    
    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

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index a4bfb58..7c79c09 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -475,6 +475,10 @@ private:
     bool mbXMLExport : 1;                ///< sal_True: during XML export
 #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
     //
@@ -1030,6 +1034,15 @@ public:
     void SetXMLExport( bool bFlag )     { mbXMLExport = bFlag; }
 #endif
 
+    void SetContainsAtPageObjWithContentAnchor( const bool bFlag )
+    {
+        mbContainsAtPageObjWithContentAnchor = bFlag;
+    }
+    bool DoesContainAtPageObjWithContentAnchor()
+    {
+        return mbContainsAtPageObjWithContentAnchor;
+    }
+
     /** Returns positions of all FlyFrames in the document.
      If a Pam-Pointer is passed the FlyFrames attached to paragraphes
      have to be surrounded completely by ::com::sun::star::awt::Selection.
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 251ff0e..3759b6e 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -2068,7 +2068,7 @@ void SwDoc::SetAllUniqueFlyNames()
     SwFrmFmts aArr;
     aArr.reserve( n );
     SwFrmFmt* pFlyFmt;
-    bool bLoadedFlag = true;            // something for the Layout
+    bool bContainsAtPageObjWithContentAnchor = false;
 
     for( n = GetSpzFrmFmts()->size(); n; )
     {
@@ -2094,22 +2094,17 @@ void SwDoc::SetAllUniqueFlyNames()
                 aArr.push_back( pFlyFmt );
 
         }
-        if( bLoadedFlag )
+        if ( !bContainsAtPageObjWithContentAnchor )
         {
             const SwFmtAnchor& rAnchor = pFlyFmt->GetAnchor();
-            if (((FLY_AT_PAGE == rAnchor.GetAnchorId()) &&
-                 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 ))) )
+            if ( (FLY_AT_PAGE == rAnchor.GetAnchorId()) &&
+                 rAnchor.GetCntntAnchor() )
             {
-                bLoadedFlag = false;
+                bContainsAtPageObjWithContentAnchor = true;
             }
         }
     }
+    SetContainsAtPageObjWithContentAnchor( bContainsAtPageObjWithContentAnchor );
 
     const SwNodeIndex* pIdx;
 
@@ -2154,11 +2149,6 @@ void SwDoc::SetAllUniqueFlyNames()
             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
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index c978716..44428da 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -282,6 +282,7 @@ SwDoc::SwDoc()
 #ifdef DBG_UTIL
     mbXMLExport(false),
 #endif
+    mbContainsAtPageObjWithContentAnchor(false), //#i119292#, fdo#37024
 
     // COMPATIBILITY FLAGS START
 
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index e6a4433..51ab0af 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -835,7 +835,7 @@ SwCntntNotify::~SwCntntNotify()
         }
     }
 
-    bool bFirst = (aFrm.*fnRect->fnGetWidth)() == 0;
+    const bool bFirst = (aFrm.*fnRect->fnGetWidth)() == 0;
 
     if ( pCnt->IsNoTxtFrm() )
     {
@@ -909,53 +909,48 @@ SwCntntNotify::~SwCntntNotify()
 
         SwDoc *pDoc = pCnt->GetNode()->GetDoc();
         if ( !pDoc->GetSpzFrmFmts()->empty() &&
-             !pDoc->IsLoaded() && !pDoc->IsNewDoc() )
-        {
-            //The Frm has been formatted probably for the first time.
-            //If a filter read Flys or Drawingobjects and these
-            //are bound to the page, he has a problem, because he typically
-            //does not know the number of the page. He knows only wich is the
-            //content (CntntNode) at this position.
-            //The filter provides the anchor attribut of the objects so, that
-            //they are side bound type, but the index of the anchor points
-            //to this CntntNode.
-            //Here these preliminary connections are dissolved.
+             pDoc->DoesContainAtPageObjWithContentAnchor() && !pDoc->IsNewDoc() )
+        {
+            // If certain import filters for foreign file format import
+            // AT_PAGE anchored objects, the corresponding page number is
+            // typically not known. In this case the content position is
+            // stored at which the anchored object is found in the
+            // imported document.
+            // When this content is formatted it is the time at which
+            // the page is known. Thus, this data can be corrected now.
 
             const SwPageFrm *pPage = 0;
-            SwNodeIndex   *pIdx  = 0;
+            SwNodeIndex *pIdx  = 0;
             SwFrmFmts *pTbl = pDoc->GetSpzFrmFmts();
 
             for ( sal_uInt16 i = 0; i < pTbl->size(); ++i )
             {
-                if ( !pPage )
-                    pPage = pCnt->FindPageFrm();
                 SwFrmFmt *pFmt = (*pTbl)[i];
                 const SwFmtAnchor &rAnch = pFmt->GetAnchor();
-
-                if ((FLY_AT_PAGE != rAnch.GetAnchorId()) &&
-                    (FLY_AT_PARA != rAnch.GetAnchorId()))
+                if ( FLY_AT_PAGE != rAnch.GetAnchorId() ||
+                     rAnch.GetCntntAnchor() == 0 )
                 {
-                    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())
-                        {
-                            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();
-                        }
+                        pFmt->MakeFrms();
                     }
                 }
             }
diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx
index 023a373..a17f91d 100644
--- a/sw/source/filter/basflt/shellio.cxx
+++ b/sw/source/filter/basflt/shellio.cxx
@@ -288,10 +288,7 @@ sal_uLong SwReader::Read( const Reader& rOptions )
                                 }
                                 else if( pCrsr )
                                 {
-                                    // seitengebundene Flys eingefuegt, dann schalte
-                                    // die Optimierungs-Flags vom SwDoc ab. Sonst
-                                    // werden die Flys nicht an der Position erzeugt.
-                                    pDoc->SetLoaded( sal_False );
+                                    pDoc->SetContainsAtPageObjWithContentAnchor( true );
                                 }
                             }
                             else
@@ -350,6 +347,7 @@ sal_uLong SwReader::Read( const Reader& rOptions )
     pDoc->UpdateNumRule();
     pDoc->ChkCondColls();
     pDoc->SetAllUniqueFlyNames();
+    pDoc->SetLoaded( true );
 
     pDoc->GetIDocumentUndoRedo().DoUndo(bDocUndo);
     if (!bReadPageDescs)


More information about the Libreoffice-commits mailing list