Author: orw
Date: Wed May  9 13:51:10 2012
New Revision: 1336208

URL: http://svn.apache.org/viewvc?rev=1336208&view=rev
Log:
119292 - remove misusage of <SwDoc::Set|IsLoaded()> for the adjustments of 
certain AT_PAGE anchored objects

Modified:
    incubator/ooo/trunk/main/sw/inc/doc.hxx
    incubator/ooo/trunk/main/sw/source/core/doc/doclay.cxx
    incubator/ooo/trunk/main/sw/source/core/doc/docnew.cxx
    incubator/ooo/trunk/main/sw/source/core/layout/frmtool.cxx
    incubator/ooo/trunk/main/sw/source/filter/basflt/shellio.cxx

Modified: incubator/ooo/trunk/main/sw/inc/doc.hxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/inc/doc.hxx?rev=1336208&r1=1336207&r2=1336208&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/inc/doc.hxx (original)
+++ incubator/ooo/trunk/main/sw/inc/doc.hxx Wed May  9 13:51:10 2012
@@ -495,6 +495,10 @@ private:
     bool mbApplyWorkaroundForB6375613 : 1;
     // <--
 
+    // 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
     //
@@ -1038,6 +1042,15 @@ public:
     void SetXMLExport( bool bFlag )     { mbXMLExport = bFlag; }
 #endif
 
+    void SetContainsAtPageObjWithContentAnchor( const bool bFlag )
+    {
+        mbContainsAtPageObjWithContentAnchor = bFlag;
+    }
+    bool DoesContainAtPageObjWithContentAnchor()
+    {
+        return mbContainsAtPageObjWithContentAnchor;
+    }
+
        // liefert zu allen fliegenden Rahmen die Position im Dokument.
        // Wird ein Pam-Pointer uebergeben, muessen die absatzgebundenen
        // FlyFrames von der ::com::sun::star::awt::Selection vollstaendig 
umschlossen sein

Modified: incubator/ooo/trunk/main/sw/source/core/doc/doclay.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/doc/doclay.cxx?rev=1336208&r1=1336207&r2=1336208&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/doc/doclay.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/doc/doclay.cxx Wed May  9 13:51:10 
2012
@@ -2146,7 +2146,7 @@ void SwDoc::SetAllUniqueFlyNames()
                n = 255;
        SwSpzFrmFmts aArr( (sal_Int8)n, 10 );
        SwFrmFmtPtr pFlyFmt;
-       sal_Bool bLoadedFlag = sal_True;                        // noch etwas 
fuers Layout
+       bool bContainsAtPageObjWithContentAnchor = false;
 
        for( n = GetSpzFrmFmts()->Count(); n; )
        {
@@ -2172,22 +2172,17 @@ void SwDoc::SetAllUniqueFlyNames()
                                aArr.Insert( pFlyFmt, aArr.Count() );
 
                }
-               if( bLoadedFlag )
+               if ( !bContainsAtPageObjWithContentAnchor )
                {
                        const SwFmtAnchor& rAnchor = pFlyFmt->GetAnchor();
-            if (((FLY_AT_PAGE == rAnchor.GetAnchorId()) &&
-                 rAnchor.GetCntntAnchor()) ||
-                               // oder werden DrawObjecte rel. zu irgendetwas 
ausgerichtet?
-                               ( 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 = sal_False;
+                               bContainsAtPageObjWithContentAnchor = true;
             }
                }
        }
+    SetContainsAtPageObjWithContentAnchor( bContainsAtPageObjWithContentAnchor 
);
 
        const SwNodeIndex* pIdx;
 
@@ -2234,11 +2229,6 @@ void SwDoc::SetAllUniqueFlyNames()
             GetFtnIdxs().UpdateFtn( aTmp );
         }
     }
-
-       // neues Document und keine seitengebundenen Rahmen/DrawObjecte 
gefunden,
-       // die an einem Node verankert sind.
-       if( bLoadedFlag )
-               SetLoaded( sal_True );
 }
 
 sal_Bool SwDoc::IsInHeaderFooter( const SwNodeIndex& rIdx ) const

Modified: incubator/ooo/trunk/main/sw/source/core/doc/docnew.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/doc/docnew.cxx?rev=1336208&r1=1336207&r2=1336208&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/doc/docnew.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/doc/docnew.cxx Wed May  9 13:51:10 
2012
@@ -292,6 +292,7 @@ SwDoc::SwDoc()
     mbLinksUpdated( sal_False ),
     mbClipBoard( false ),
     mbColumnSelection( false ),
+    mbContainsAtPageObjWithContentAnchor( false ),
     // i#78591#
        mbProtectForm(false),
     mbLastBrowseMode( false ),

Modified: incubator/ooo/trunk/main/sw/source/core/layout/frmtool.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/layout/frmtool.cxx?rev=1336208&r1=1336207&r2=1336208&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/layout/frmtool.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/layout/frmtool.cxx Wed May  9 
13:51:10 2012
@@ -871,7 +871,7 @@ SwCntntNotify::~SwCntntNotify()
         }
     }
 
-    sal_Bool bFirst = (aFrm.*fnRect->fnGetWidth)() == 0;
+    const bool bFirst = (aFrm.*fnRect->fnGetWidth)() == 0;
 
        if ( pCnt->IsNoTxtFrm() )
        {
@@ -947,57 +947,49 @@ SwCntntNotify::~SwCntntNotify()
 
                SwDoc *pDoc = pCnt->GetNode()->GetDoc();
                if ( pDoc->GetSpzFrmFmts()->Count() &&
-                        !pDoc->IsLoaded() && !pDoc->IsNewDoc() )
+                        pDoc->DoesContainAtPageObjWithContentAnchor() && 
!pDoc->IsNewDoc() )
                {
-                       //Der Frm wurde wahrscheinlich zum ersten mal 
formatiert.
-                       //Wenn ein Filter Flys oder Zeichenobjekte einliest und 
diese
-                       //Seitengebunden sind, hat er ein Problem, weil er 
i.d.R. die
-                       //Seitennummer nicht kennt. Er weiss lediglich welches 
der Inhalt
-                       //(CntntNode) an dieser Stelle ist.
-                       //Die Filter stellen dazu das Ankerattribut der Objekte 
so ein, dass
-                       //sie vom Typ zwar Seitengebunden sind, aber der Index 
des Ankers
-                       //auf diesen CntntNode zeigt.
-                       //Hier werden diese vorlauefigen Verbindungen 
aufgeloest.
-
-                       const SwPageFrm *pPage = 0;
-                       SwNodeIndex   *pIdx  = 0;
-                       SwSpzFrmFmts *pTbl = pDoc->GetSpzFrmFmts();
-
-                       for ( sal_uInt16 i = 0; i < pTbl->Count(); ++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 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;
+            SwSpzFrmFmts *pTbl = pDoc->GetSpzFrmFmts();
+            for ( sal_uInt16 i = 0; i < pTbl->Count(); ++i )
+            {
+                SwFrmFmt *pFmt = (*pTbl)[i];
+                const SwFmtAnchor &rAnch = pFmt->GetAnchor();
+                if ( FLY_AT_PAGE != rAnch.GetAnchorId() ||
+                     rAnch.GetCntntAnchor() == 0 )
                 {
-                                       continue;       //#60878# nicht etwa 
zeichengebundene.
+                    continue;
                 }
 
-                               sal_Bool bCheckPos = sal_False;
-                               if ( rAnch.GetCntntAnchor() )
-                               {
-                                       if ( !pIdx )
-                                       {
-                                               pIdx = new SwNodeIndex( 
*pCnt->GetNode() );
-                                       }
-                                       if ( rAnch.GetCntntAnchor()->nNode == 
*pIdx )
-                                       {
-                        bCheckPos = sal_True;
-                        if (FLY_AT_PAGE == rAnch.GetAnchorId())
-                        {
-                            ASSERT( false, "<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();
-                                               }
-                                       }
-                               }
+                if ( !pIdx )
+                {
+                    pIdx = new SwNodeIndex( *pCnt->GetNode() );
+                }
+                if ( rAnch.GetCntntAnchor()->nNode == *pIdx )
+                {
+                    ASSERT( false, "<SwCntntNotify::~SwCntntNotify()> - to 
page anchored object with content position. Please inform OD." );
+                    if ( !pPage )
+                    {
+                        pPage = pCnt->FindPageFrm();
+                    }
+                    SwFmtAnchor aAnch( rAnch );
+                    aAnch.SetAnchor( 0 );
+                    aAnch.SetPageNum( pPage->GetPhyPageNum() );
+                    pFmt->SetFmtAttr( aAnch );
+                    if ( RES_DRAWFRMFMT != pFmt->Which() )
+                    {
+                        pFmt->MakeFrms();
+                    }
+                }
             }
             delete pIdx;
         }

Modified: incubator/ooo/trunk/main/sw/source/filter/basflt/shellio.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/filter/basflt/shellio.cxx?rev=1336208&r1=1336207&r2=1336208&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/filter/basflt/shellio.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/filter/basflt/shellio.cxx Wed May  9 
13:51:10 2012
@@ -290,10 +290,7 @@ sal_uLong SwReader::Read( const Reader& 
                                 }
                                                                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
@@ -352,6 +349,7 @@ sal_uLong SwReader::Read( const Reader& 
     pDoc->UpdateNumRule();
     pDoc->ChkCondColls();
        pDoc->SetAllUniqueFlyNames();
+    pDoc->SetLoaded( true );
 
     pDoc->GetIDocumentUndoRedo().DoUndo(bDocUndo);
     if (!bReadPageDescs)


Reply via email to