[PATCH 3/4] 2 Part of Replace WW8Bytes with ww::bytes

Maciej Rumianowski maciej.rumianowski at gmail.com
Wed Oct 5 00:35:03 PDT 2011


Use prefered methods from SwWW8Writer
---
 sw/source/filter/ww8/wrtw8esh.cxx |    6 ++--
 sw/source/filter/ww8/wrtw8nds.cxx |   28 +++++++++-----------
 sw/source/filter/ww8/wrtw8num.cxx |    6 ++--
 sw/source/filter/ww8/wrtww8.cxx   |   50 +++----------------------------------
 sw/source/filter/ww8/wrtww8.hxx   |   11 +-------
 sw/source/filter/ww8/wrtww8gr.cxx |   10 +++---
 sw/source/filter/ww8/ww8atr.cxx   |   18 ++++++-------
 7 files changed, 37 insertions(+), 92 deletions(-)

diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index a0f7ca2..da071fc 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1403,13 +1403,13 @@ sal_Int32 SwBasicEscherEx::WriteGrfFlyFrame(const SwFrmFmt& rFmt, sal_uInt32 nSh
         String sURL;
         pGrfNd->GetFileFilterNms( &sURL, 0 );
 
-        WW8Bytes aBuf;
+        ww::bytes aBuf;
         SwWW8Writer::InsAsString16( aBuf, sURL );
         SwWW8Writer::InsUInt16( aBuf, 0 );
 
-        sal_uInt16 nArrLen = aBuf.Count();
+        sal_uInt16 nArrLen = aBuf.size();
         sal_uInt8* pArr = new sal_uInt8[ nArrLen ];
-        memcpy( pArr, aBuf.GetData(), nArrLen );
+        std::copy( aBuf.begin(), aBuf.end(), pArr);
 
         aPropOpt.AddOpt(ESCHER_Prop_pibName, true, nArrLen, pArr, nArrLen);
         nFlags = ESCHER_BlipFlagLinkToFile | ESCHER_BlipFlagURL |
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 2b06b30..65250ca 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -627,11 +627,9 @@ const SfxPoolItem* SwWW8AttrIter::HasTextItem( sal_uInt16 nWhich ) const
     return pRet;
 }
 
-void WW8Export::GetCurrentItems(WW8Bytes& rItems) const
+void WW8Export::GetCurrentItems(ww::bytes &rItems) const
 {
-    sal_uInt16 nEnd = pO ? pO->size() : 0;
-    for (sal_uInt16 nI = 0; nI < nEnd; ++nI)
-        rItems.Insert((*pO)[nI], rItems.Count());
+    rItems.insert(rItems.end(), pO->begin(), pO->end());
 }
 
 const SfxPoolItem& SwWW8AttrIter::GetItem(sal_uInt16 nWhich) const
@@ -1047,35 +1045,35 @@ void SwWW8AttrIter::OutSwFmtRefMark(const SwFmtRefMark& rAttr, bool)
 
 void WW8AttributeOutput::FieldVanish( const String& rTxt, ww::eField /*eType*/ )
 {
-    WW8Bytes aItems;
+    ww::bytes aItems;
     m_rWW8Export.GetCurrentItems( aItems );
 
     // sprmCFFldVanish
     if ( m_rWW8Export.bWrtWW8 )
         SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CFFldVanish );
     else
-        aItems.Insert( 67, aItems.Count() );
-    aItems.Insert( 1, aItems.Count() );
+        aItems.push_back( 67 );
+    aItems.push_back( 1 );
 
-    sal_uInt16 nStt_sprmCFSpec = aItems.Count();
+    sal_uInt16 nStt_sprmCFSpec = aItems.size();
 
     // sprmCFSpec --  fSpec-Attribut true
     if ( m_rWW8Export.bWrtWW8 )
         SwWW8Writer::InsUInt16( aItems, 0x855 );
     else
-        aItems.Insert( 117, aItems.Count() );
-    aItems.Insert( 1, aItems.Count() );
+        aItems.push_back( 117 );
+    aItems.push_back( 1 );
 
     m_rWW8Export.WriteChar( '\x13' );
-    m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), aItems.Count(),
-                                    aItems.GetData() );
+    m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), aItems.size(),
+                                    &aItems[0] );
     m_rWW8Export.OutSwString( rTxt, 0, rTxt.Len(), m_rWW8Export.IsUnicode(),
                         RTL_TEXTENCODING_MS_1252 );
     m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), nStt_sprmCFSpec,
-                                    aItems.GetData() );
+                                    &aItems[0] );
     m_rWW8Export.WriteChar( '\x15' );
-    m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), aItems.Count(),
-                                    aItems.GetData() );
+    m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), aItems.size(),
+                                    &aItems[0] );
 }
 
 void AttributeOutputBase::TOXMark( const SwTxtNode& rNode, const SwTOXMark& rAttr )
diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
index e7d476e..b7ee16c 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -745,14 +745,14 @@ static void SwWw8_InsertAnlText( const String& rStr, sal_uInt8*& rpCh,
                                  sal_uInt16& rCharLen, SVBT8& r8Len )
 {
     sal_uInt8 nb = 0;
-    WW8Bytes aO;
+    ww::bytes aO;
     SwWW8Writer::InsAsString8( aO, rStr, RTL_TEXTENCODING_MS_1252 );
 
-    sal_uInt16 nCnt = aO.Count();
+    sal_uInt16 nCnt = aO.size();
     if( nCnt && nCnt < rCharLen )
     {
         nb = (sal_uInt8)nCnt;
-        memcpy( rpCh, aO.GetData(), nCnt );
+        std::copy( aO.begin(), aO.end(), rpCh );
         rpCh += nCnt;
         rCharLen = rCharLen - nCnt;
     }
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index e0a3074..0461b5e 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -1555,48 +1555,6 @@ void SwWW8Writer::InsAsString8(ww::bytes &rO, const String& rStr,
     std::copy(pStart, pEnd, std::inserter(rO, rO.end()));
 }
 
-#ifdef __WW8_NEEDS_COPY
-
-void SwWW8Writer::InsUInt16( WW8Bytes& rO, sal_uInt16 n )
-{
-    SVBT16 nL;
-    ShortToSVBT16( n, nL );
-    rO.Insert( nL, 2, rO.Count() );
-}
-void SwWW8Writer::InsUInt32( WW8Bytes& rO, sal_uInt32 n )
-{
-    SVBT32 nL;
-    UInt32ToSVBT32( n, nL );
-    rO.Insert( nL, 4, rO.Count() );
-}
-
-#else
-
-void SwWW8Writer::InsUInt16( WW8Bytes& rO, sal_uInt16 n )
-{
-    rO.Insert( (sal_uInt8*)&n, 2, rO.Count() );
-}
-void SwWW8Writer::InsUInt32( WW8Bytes& rO, sal_uInt32 n )
-{
-    rO.Insert( (sal_uInt8*)&n, 4, rO.Count() );
-}
-
-#endif // defined __WW8_NEEDS_COPY
-
-void SwWW8Writer::InsAsString16( WW8Bytes& rO, const String& rStr )
-{
-    const sal_Unicode* pStr = rStr.GetBuffer();
-    for( xub_StrLen n = 0, nLen = rStr.Len(); n < nLen; ++n, ++pStr )
-        SwWW8Writer::InsUInt16( rO, *pStr );
-}
-
-void SwWW8Writer::InsAsString8( WW8Bytes& rO, const String& rStr,
-                                rtl_TextEncoding eCodeSet )
-{
-    rtl::OString sTmp(rtl::OUStringToOString(rStr, eCodeSet));
-    rO.Insert((sal_uInt8*)sTmp.getStr(), sTmp.getLength(), rO.Count());
-}
-
 void SwWW8Writer::WriteString16(SvStream& rStrm, const String& rStr,
     bool bAddZero)
 {
@@ -1640,7 +1598,7 @@ void WW8Export::WriteStringAsPara( const String& rTxt, sal_uInt16 nStyleId )
         OutSwString( rTxt, 0, rTxt.Len(), IsUnicode(), RTL_TEXTENCODING_MS_1252 );
     WriteCR();              // CR danach
 
-    WW8Bytes aArr( 10, 10 );
+    ww::bytes aArr;
     SwWW8Writer::InsUInt16( aArr, nStyleId );
     if( bOutTable )
     {                                               // Tab-Attr
@@ -1648,12 +1606,12 @@ void WW8Export::WriteStringAsPara( const String& rTxt, sal_uInt16 nStyleId )
         if( bWrtWW8 )
             SwWW8Writer::InsUInt16( aArr, NS_sprm::LN_PFInTable );
         else
-            aArr.Insert( 24, aArr.Count() );
-        aArr.Insert( 1, aArr.Count() );
+            aArr.push_back( 24 );
+        aArr.push_back( 1 );
     }
 
     sal_uLong nPos = Strm().Tell();
-    pPapPlc->AppendFkpEntry( nPos, aArr.Count(), aArr.GetData() );
+    pPapPlc->AppendFkpEntry( nPos, aArr.size(), &aArr[0] );
     pChpPlc->AppendFkpEntry( nPos );
 }
 
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 691c912..2b8438d 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -863,20 +863,11 @@ public:
     using Writer::getIDocumentSettingAccess;
 
 public:
-#if 1
-    /// Prefer ww::bytes to WW8Bytes, migrate away from the other ones.
     static void InsUInt16(ww::bytes &rO, sal_uInt16 n);
     static void InsUInt32(ww::bytes &rO, sal_uInt32 n);
     static void InsAsString16(ww::bytes &rO, const String& rStr);
     static void InsAsString8(ww::bytes & O, const String& rStr,
         rtl_TextEncoding eCodeSet);
-#endif
-
-    static void InsUInt16( WW8Bytes& rO, sal_uInt16 );
-    static void InsUInt32( WW8Bytes& rO, sal_uInt32 );
-    static void InsAsString16( WW8Bytes& rO, const String& );
-    static void InsAsString8( WW8Bytes& rO, const String& rStr,
-                                rtl_TextEncoding eCodeSet );
 
     static sal_uLong FillUntil( SvStream& rStrm, sal_uLong nEndPos = 0 );
     static void FillCount( SvStream& rStrm, sal_uLong nCount );
@@ -1098,7 +1089,7 @@ public:
 
     virtual void DoFormText(const SwInputField * pFld);
 
-    void GetCurrentItems(WW8Bytes &rItems) const;
+    void GetCurrentItems(ww::bytes &rItems) const;
 
     /// Write the data of the form field
     virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark );
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index 2c54d5b..c56c6a5 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -379,20 +379,20 @@ void WW8Export::OutputLinkedOLE( const rtl::OUString& rOleId )
             xOleDst->Commit();
 
             // Ouput the cPicLocation attribute
-            WW8Bytes* pBuf = new WW8Bytes( 128, 128 );
+            ww::bytes* pBuf = new ww::bytes();
             GetWriter().InsUInt16( *pBuf, NS_sprm::LN_CPicLocation );
             GetWriter().InsUInt32( *pBuf, rOleId.copy( 1 ).toInt32() );
 
             GetWriter().InsUInt16( *pBuf, NS_sprm::LN_CFOle2 );
-            pBuf->Insert( 1, pBuf->Count() );
+            pBuf->push_back( 1 );
 
             GetWriter().InsUInt16( *pBuf, NS_sprm::LN_CFSpec );
-            pBuf->Insert( 1, pBuf->Count() );
+            pBuf->push_back( 1 );
 
             GetWriter().InsUInt16( *pBuf, NS_sprm::LN_CFObj );
-            pBuf->Insert( 1, pBuf->Count() );
+            pBuf->push_back( 1 );
 
-            pChpPlc->AppendFkpEntry( Strm().Tell(), pBuf->Count(), pBuf->GetData() );
+            pChpPlc->AppendFkpEntry( Strm().Tell(), pBuf->size(), &(*pBuf)[0] );
             delete pBuf;
         }
     }
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index ddca1a8..36d0461 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -1658,14 +1658,13 @@ static void InsertSpecialChar( WW8Export& rWrt, sal_uInt8 c,
                                String* pLinkStr = 0L,
                                bool bIncludeEmptyPicLocation = false )
 {
-    WW8Bytes aItems;
+    ww::bytes aItems;
     rWrt.GetCurrentItems(aItems);
 
     if (c == 0x13)
         rWrt.pChpPlc->AppendFkpEntry(rWrt.Strm().Tell());
     else
-        rWrt.pChpPlc->AppendFkpEntry(rWrt.Strm().Tell(), aItems.Count(),
-            aItems.GetData());
+        rWrt.pChpPlc->AppendFkpEntry(rWrt.Strm().Tell(), aItems.size(), &aItems[0]);
 
     rWrt.WriteChar(c);
 
@@ -1715,11 +1714,11 @@ static void InsertSpecialChar( WW8Export& rWrt, sal_uInt8 c,
 
         // write attributes of hyperlink character 0x01
         SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CFFldVanish );
-        aItems.Insert( (sal_uInt8)0x81, aItems.Count() );
+        aItems.push_back( (sal_uInt8)0x81 );
         SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CPicLocation );
         SwWW8Writer::InsUInt32( aItems, nLinkPosInDataStrm );
         SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CFData );
-        aItems.Insert( (sal_uInt8)0x01, aItems.Count() );
+        aItems.push_back( (sal_uInt8)0x01 );
     }
 
     //Technically we should probably Remove all attribs
@@ -1730,16 +1729,15 @@ static void InsertSpecialChar( WW8Export& rWrt, sal_uInt8 c,
     if( rWrt.bWrtWW8 )
     {
         SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CFSpec );
-        aItems.Insert( 1, aItems.Count() );
+        aItems.push_back( 1 );
     }
     else
     {
-        aItems.Insert( 117, aItems.Count() ); //sprmCFSpec
-        aItems.Insert( 1, aItems.Count() );
+        aItems.push_back( 117 ); //sprmCFSpec
+        aItems.push_back( 1 );
     }
 
-    rWrt.pChpPlc->AppendFkpEntry(rWrt.Strm().Tell(), aItems.Count(),
-        aItems.GetData());
+    rWrt.pChpPlc->AppendFkpEntry(rWrt.Strm().Tell(), aItems.size(), &aItems[0]);
 }
 
 String lcl_GetExpandedField(const SwField &rFld)
-- 
1.7.4.1


--=-QA4DNqzTCL/OKykWUufJ
Content-Disposition: attachment; filename="0004-Remove-Declaration-of-WW8Bytes-now-not-used.patch"
Content-Type: text/x-patch; name="0004-Remove-Declaration-of-WW8Bytes-now-not-used.patch"; charset="UTF-8"
Content-Transfer-Encoding: 7bit



More information about the LibreOffice mailing list