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

Lei De Bin leidb at apache.org
Fri Jun 14 01:41:49 PDT 2013


 sw/source/filter/ww8/wrtw8esh.cxx |   28 ++++++++++++++++++++++++++++
 sw/source/filter/ww8/wrtw8sty.cxx |   30 +++++++++++++++++++++++++++++-
 sw/source/filter/ww8/wrtww8.hxx   |    2 ++
 3 files changed, 59 insertions(+), 1 deletion(-)

New commits:
commit 7edabc8639353aeeaa7457c8f973435d4b668f2f
Author: Lei De Bin <leidb at apache.org>
Date:   Mon Aug 6 05:07:20 2012 +0000

    Resolves: #i119470# fix page number in header lost when save in web layout
    
    Reported by: luo qing le
    Patch by: Lei De Bin
    Review by: Chen Zuo Jun
    
    (cherry picked from commit 3654740a6f770631d34897aad345f006313c46b9)
    
    Conflicts:
    	sw/source/filter/ww8/wrtw8esh.cxx
    	sw/source/filter/ww8/wrtww8.hxx
    
    Change-Id: I1c25d17b1780adeddee46d500f2f0753944e9ffc

diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index e334552..ecd54e8 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -763,6 +763,16 @@ void WW8_WrPlcTxtBoxes::Append( const SdrObject& rObj, sal_uInt32 nShapeId )
 {
     aCntnt.push_back( &rObj );
     aShapeIds.push_back( nShapeId );
+    //save NULL, if we have an actual SdrObject
+    aSpareFmts.push_back(NULL);
+}
+
+void WW8_WrPlcTxtBoxes::Append( const SwFrmFmt* pFmt, sal_uInt32 nShapeId )
+{
+    //no sdr object, we insert a NULL in the aCntnt and save the real fmt in aSpareFmts.
+    aCntnt.push_back( NULL );
+    aShapeIds.push_back( nShapeId );
+    aSpareFmts.push_back(pFmt);
 }
 
 const std::vector<sal_uInt32>* WW8_WrPlcTxtBoxes::GetShapeIdArr() const
@@ -2702,6 +2712,24 @@ sal_Int32 SwEscherEx::WriteFlyFrm(const DrawObj &rObj, sal_uInt32 &rShapeId,
 
                 nBorderThick = WriteTxtFlyFrame(rObj, rShapeId, nTxtId, rPVec);
             }
+
+            //In browse mode the sdr object doesn't always exist. For example, the
+            //object is in the hidden header/footer. We save the fmt directly
+            //in such cases; we copy most of the logic from the block above
+            const bool bBrowseMode = (rFmt.getIDocumentSettingAccess())->get(IDocumentSettingAccess::BROWSE_MODE);
+            if( bBrowseMode && rFmt.GetDoc())
+            {
+                if( !rFmt.GetChain().GetPrev() )//obj in header/footer?
+                {
+                    rShapeId = GetFlyShapeId(rFmt, rObj.mnHdFtIndex, rPVec);
+                    pTxtBxs->Append( &rFmt, rShapeId );
+                    sal_uInt32 nTxtId = pTxtBxs->Count();
+
+                    nTxtId *= 0x10000;
+                    nBorderThick = WriteTxtFlyFrame(rObj, rShapeId, nTxtId, rPVec);
+                }
+            }
+
         }
     }
     return nBorderThick;
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 6d52d6b..6c02203 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -2033,6 +2033,8 @@ bool WW8_WrPlcSubDoc::WriteGenericTxt( WW8Export& rWrt, sal_uInt8 nTTyp,
                 aCps.insert( aCps.begin()+i, nCP );
                 pTxtPos->Append( nCP );
 
+                if( aCntnt[ i ] != NULL )
+                {
                 // is it an writer or sdr - textbox?
                 const SdrObject& rObj = *(SdrObject*)aCntnt[ i ];
                 if (rObj.GetObjInventor() == FmFormInventor)
@@ -2079,6 +2081,16 @@ bool WW8_WrPlcSubDoc::WriteGenericTxt( WW8Export& rWrt, sal_uInt8 nTTyp,
                         }
                     }
                 }
+                }
+                else if( i < aSpareFmts.size() )
+                {
+                    if( const SwFrmFmt* pFmt = (const SwFrmFmt*)aSpareFmts[ i ] )
+                    {
+                        const SwNodeIndex* pNdIdx = pFmt->GetCntnt().GetCntntIdx();
+                        rWrt.WriteSpecialText( pNdIdx->GetIndex() + 1,
+                                   pNdIdx->GetNode().EndOfSectionIndex(), nTTyp );
+                    }
+                }
 
                 // CR at end of one textbox text ( otherwise WW gpft :-( )
                 rWrt.WriteStringAsPara( aEmptyStr );
@@ -2213,7 +2225,7 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
                     // is it an writer or sdr - textbox?
                     const SdrObject* pObj = (SdrObject*)aCntnt[ i ];
                     sal_Int32 nCnt = 1;
-                    if ( !pObj->ISA( SdrTextObj ) )
+                    if (pObj && !pObj->ISA( SdrTextObj ) )
                     {
                         // find the "highest" SdrObject of this
                         const SwFrmFmt& rFmt = *::FindFrmFmt( pObj );
@@ -2227,6 +2239,22 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
                             pChn = &pChn->GetNext()->GetChain();
                         }
                     }
+                    if( NULL == pObj )
+                    {
+                        if( i < aSpareFmts.size() && aSpareFmts[ i ] )
+                        {
+                            const SwFrmFmt& rFmt = *(const SwFrmFmt*)aSpareFmts[ i ];
+
+                            const SwFmtChain* pChn = &rFmt.GetChain();
+                            while( pChn->GetNext() )
+                            {
+                                // has a chain?
+                                // then calc the cur pos in the chain
+                                ++nCnt;
+                                pChn = &pChn->GetNext()->GetChain();
+                            }
+                        }
+                    }
                     // long cTxbx / iNextReuse
                     SwWW8Writer::WriteLong( *rWrt.pTableStrm, nCnt );
                     // long cReusable
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index c48e101..e9ae483 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1152,6 +1152,7 @@ private:
 protected:
     std::vector<WW8_CP> aCps;
     std::vector<const void*> aCntnt;                // PTRARR of SwFmtFtn/PostIts/..
+    std::vector<const SwFrmFmt*> aSpareFmts;        //a backup for aCntnt: if there's no SdrObject, stores the fmt directly here
     WW8_WrPlc0* pTxtPos;            // positions of the individual texts
 
     WW8_WrPlcSubDoc();
@@ -1226,6 +1227,7 @@ public:
     bool WriteTxt( WW8Export& rWrt );
     void WritePlc( WW8Export& rWrt ) const;
     void Append( const SdrObject& rObj, sal_uInt32 nShapeId );
+    void Append( const SwFrmFmt* pFmt, sal_uInt32 nShapeId );
     sal_uInt16 Count() const { return aCntnt.size(); }
     sal_uInt16 GetPos( const void* p ) const
     {


More information about the Libreoffice-commits mailing list