sc/source/filter/inc/rtfexp.hxx |    3 +-
 sc/source/filter/rtf/rtfexp.cxx |   58 ++++++++++++++++++++--------------------
 2 files changed, 32 insertions(+), 29 deletions(-)

New commits:
commit 18e8c72d680b91da730dd8bb7c26c60b954ee074
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Tue Jul 25 15:28:39 2023 -0400
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Sep 1 16:19:27 2023 +0200

    sc: filter: rtf: prefix m_* private members
    
    Signed-off-by: Henry Castro <hcas...@collabora.com>
    Change-Id: If8389b6e63a90616131d0dd9fbb5a7b8b96ffe3d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154904
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156413
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/source/filter/inc/rtfexp.hxx b/sc/source/filter/inc/rtfexp.hxx
index 9a4fe43d9d02..14ee8ec023f7 100644
--- a/sc/source/filter/inc/rtfexp.hxx
+++ b/sc/source/filter/inc/rtfexp.hxx
@@ -25,7 +25,7 @@
 
 class ScRTFExport : public ScExportBase
 {
-    std::unique_ptr<sal_uLong[]>  pCellX;     // cumulative range in a table
+    std::unique_ptr<sal_uLong[]>  m_pCellX;     // cumulative range in a table
     SvMemoryStream m_aDocStrm;
 
     void                WriteTab( SCTAB nTab );
diff --git a/sc/source/filter/rtf/rtfexp.cxx b/sc/source/filter/rtf/rtfexp.cxx
index 5cef70300617..99336e6f022c 100644
--- a/sc/source/filter/rtf/rtfexp.cxx
+++ b/sc/source/filter/rtf/rtfexp.cxx
@@ -46,7 +46,7 @@ void ScFormatFilterPluginImpl::ScExportRTF( SvStream& rStrm, 
ScDocument* pDoc,
 ScRTFExport::ScRTFExport( SvStream& rStrmP, ScDocument* pDocP, const ScRange& 
rRangeP )
             :
             ScExportBase( rStrmP, pDocP, rRangeP ),
-            pCellX( new sal_uLong[ pDoc->MaxCol()+2 ] )
+            m_pCellX( new sal_uLong[ pDoc->MaxCol()+2 ] )
 {
 }
 
@@ -77,12 +77,12 @@ void ScRTFExport::WriteTab( SCTAB nTab )
     m_aDocStrm.WriteChar( '{' ).WriteOString( SAL_NEWLINE_STRING );
     if ( pDoc->HasTable( nTab ) )
     {
-        memset( &pCellX[0], 0, (pDoc->MaxCol()+2) * sizeof(sal_uLong) );
+        memset( &m_pCellX[0], 0, (pDoc->MaxCol()+2) * sizeof(sal_uLong) );
         SCCOL nCol;
         SCCOL nEndCol = aRange.aEnd.Col();
         for ( nCol = aRange.aStart.Col(); nCol <= nEndCol; nCol++ )
         {
-            pCellX[nCol+1] = pCellX[nCol] + pDoc->GetColWidth( nCol, nTab );
+            m_pCellX[nCol+1] = m_pCellX[nCol] + pDoc->GetColWidth( nCol, nTab 
);
         }
 
         SCROW nEndRow = aRange.aEnd.Row();
@@ -128,7 +128,7 @@ void ScRTFExport::WriteRow( SCTAB nTab, SCROW nRow )
         if ( pChar )
             m_aDocStrm.WriteOString( pChar );
 
-        m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CELLX ).WriteOString( 
OString::number(pCellX[nCol+1]) );
+        m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CELLX ).WriteOString( 
OString::number(m_pCellX[nCol+1]) );
         if ( (nCol & 0x0F) == 0x0F )
             m_aDocStrm.WriteOString( SAL_NEWLINE_STRING ); // Do not let lines 
get too long
     }
commit a0a3500c58ae5bcb8ffb4126c43227ba0544f8bf
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Tue Jul 25 15:18:10 2023 -0400
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Sep 1 16:19:12 2023 +0200

    sc: filter: rtf: use a separate document stream
    
    "An RTF file has the following syntax:
    '{' <header> <document>'}' "
    
    In order to build the header:
    
    <header>
            \rtf <charset> \deff? <fonttbl> <filetbl>? <colortbl>? 
<stylesheet>? <listtables>? <revtbl>?
    
    The font table should be created while visiting the column/rows.
    
    Signed-off-by: Henry Castro <hcas...@collabora.com>
    Change-Id: Id72a3c87acab6cfc7889cf81f7e83a0d73e378a2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154903
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156412
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/source/filter/inc/rtfexp.hxx b/sc/source/filter/inc/rtfexp.hxx
index 0d5e69f79d8e..9a4fe43d9d02 100644
--- a/sc/source/filter/inc/rtfexp.hxx
+++ b/sc/source/filter/inc/rtfexp.hxx
@@ -26,6 +26,7 @@
 class ScRTFExport : public ScExportBase
 {
     std::unique_ptr<sal_uLong[]>  pCellX;     // cumulative range in a table
+    SvMemoryStream m_aDocStrm;
 
     void                WriteTab( SCTAB nTab );
     void                WriteRow( SCTAB nTab, SCROW nRow );
diff --git a/sc/source/filter/rtf/rtfexp.cxx b/sc/source/filter/rtf/rtfexp.cxx
index 32549cbff377..5cef70300617 100644
--- a/sc/source/filter/rtf/rtfexp.cxx
+++ b/sc/source/filter/rtf/rtfexp.cxx
@@ -63,16 +63,18 @@ void ScRTFExport::Write()
     for ( SCTAB nTab = aRange.aStart.Tab(); nTab <= aRange.aEnd.Tab(); nTab++ )
     {
         if ( nTab > aRange.aStart.Tab() )
-            rStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_PAR );
+            m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_PAR );
         WriteTab( nTab );
     }
 
+    m_aDocStrm.Seek(0);
+    rStrm.WriteStream(m_aDocStrm);
     rStrm.WriteChar( '}' ).WriteOString( SAL_NEWLINE_STRING );
 }
 
 void ScRTFExport::WriteTab( SCTAB nTab )
 {
-    rStrm.WriteChar( '{' ).WriteOString( SAL_NEWLINE_STRING );
+    m_aDocStrm.WriteChar( '{' ).WriteOString( SAL_NEWLINE_STRING );
     if ( pDoc->HasTable( nTab ) )
     {
         memset( &pCellX[0], 0, (pDoc->MaxCol()+2) * sizeof(sal_uLong) );
@@ -89,13 +91,13 @@ void ScRTFExport::WriteTab( SCTAB nTab )
             WriteRow( nTab, nRow );
         }
     }
-    rStrm.WriteChar( '}' ).WriteOString( SAL_NEWLINE_STRING );
+    m_aDocStrm.WriteChar( '}' ).WriteOString( SAL_NEWLINE_STRING );
 }
 
 void ScRTFExport::WriteRow( SCTAB nTab, SCROW nRow )
 {
-    rStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_TROWD ).WriteOString( 
OOO_STRING_SVTOOLS_RTF_TRGAPH ).WriteOString( "30" ).WriteOString( 
OOO_STRING_SVTOOLS_RTF_TRLEFT ).WriteOString( "-30" );
-    rStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_TRRH ).WriteOString( 
OString::number(pDoc->GetRowHeight(nRow, nTab)) );
+    m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_TROWD ).WriteOString( 
OOO_STRING_SVTOOLS_RTF_TRGAPH ).WriteOString( "30" ).WriteOString( 
OOO_STRING_SVTOOLS_RTF_TRLEFT ).WriteOString( "-30" );
+    m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_TRRH ).WriteOString( 
OString::number(pDoc->GetRowHeight(nRow, nTab)) );
     SCCOL nCol;
     SCCOL nEndCol = aRange.aEnd.Col();
     for ( nCol = aRange.aStart.Col(); nCol <= nEndCol; nCol++ )
@@ -107,12 +109,12 @@ void ScRTFExport::WriteRow( SCTAB nTab, SCROW nRow )
         const char* pChar;
 
         if ( rMergeAttr.GetColMerge() != 0 )
-            rStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CLMGF );
+            m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CLMGF );
         else
         {
             const ScMergeFlagAttr& rMergeFlagAttr = pAttr->GetItem( 
ATTR_MERGE_FLAG );
             if ( rMergeFlagAttr.IsHorOverlapped() )
-                rStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CLMRG );
+                m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CLMRG );
         }
 
         switch( rVerJustifyItem.GetValue() )
@@ -124,25 +126,25 @@ void ScRTFExport::WriteRow( SCTAB nTab, SCROW nRow )
             default:                           pChar = nullptr;           
break;
         }
         if ( pChar )
-            rStrm.WriteOString( pChar );
+            m_aDocStrm.WriteOString( pChar );
 
-        rStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CELLX ).WriteOString( 
OString::number(pCellX[nCol+1]) );
+        m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CELLX ).WriteOString( 
OString::number(pCellX[nCol+1]) );
         if ( (nCol & 0x0F) == 0x0F )
-            rStrm.WriteOString( SAL_NEWLINE_STRING ); // Do not let lines get 
too long
+            m_aDocStrm.WriteOString( SAL_NEWLINE_STRING ); // Do not let lines 
get too long
     }
-    rStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_PARD ).WriteOString( 
OOO_STRING_SVTOOLS_RTF_PLAIN ).WriteOString( OOO_STRING_SVTOOLS_RTF_INTBL 
).WriteOString( SAL_NEWLINE_STRING );
+    m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_PARD ).WriteOString( 
OOO_STRING_SVTOOLS_RTF_PLAIN ).WriteOString( OOO_STRING_SVTOOLS_RTF_INTBL 
).WriteOString( SAL_NEWLINE_STRING );
 
-    sal_uInt64 nStrmPos = rStrm.Tell();
+    sal_uInt64 nStrmPos = m_aDocStrm.Tell();
     for ( nCol = aRange.aStart.Col(); nCol <= nEndCol; nCol++ )
     {
         WriteCell( nTab, nRow, nCol );
-        if ( rStrm.Tell() - nStrmPos > 255 )
+        if ( m_aDocStrm.Tell() - nStrmPos > 255 )
         {   // Do not let lines get too long
-            rStrm.WriteOString( SAL_NEWLINE_STRING );
-            nStrmPos = rStrm.Tell();
+            m_aDocStrm.WriteOString( SAL_NEWLINE_STRING );
+            nStrmPos = m_aDocStrm.Tell();
         }
     }
-    rStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_ROW ).WriteOString( 
SAL_NEWLINE_STRING );
+    m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_ROW ).WriteOString( 
SAL_NEWLINE_STRING );
 }
 
 void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol )
@@ -152,7 +154,7 @@ void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL 
nCol )
     const ScMergeFlagAttr& rMergeFlagAttr = pAttr->GetItem( ATTR_MERGE_FLAG );
     if ( rMergeFlagAttr.IsHorOverlapped() )
     {
-        rStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CELL );
+        m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CELL );
         return ;
     }
 
@@ -204,30 +206,30 @@ void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, 
SCCOL nCol )
         case SvxCellHorJustify::Repeat:
         default:                        pChar = OOO_STRING_SVTOOLS_RTF_QL;  
break;
     }
-    rStrm.WriteOString( pChar );
+    m_aDocStrm.WriteOString( pChar );
 
     if ( rWeightItem.GetWeight() >= WEIGHT_BOLD )
     {   // bold
         bResetAttr = true;
-        rStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_B );
+        m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_B );
     }
     if ( rPostureItem.GetPosture() != ITALIC_NONE )
     {   // italic
         bResetAttr = true;
-        rStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_I );
+        m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_I );
     }
     if ( rUnderlineItem.GetLineStyle() != LINESTYLE_NONE )
     {   // underline
         bResetAttr = true;
-        rStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_UL );
+        m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_UL );
     }
 
-    rStrm.WriteChar( ' ' );
-    RTFOutFuncs::Out_String( rStrm, aContent );
-    rStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CELL );
+    m_aDocStrm.WriteChar( ' ' );
+    RTFOutFuncs::Out_String( m_aDocStrm, aContent );
+    m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CELL );
 
     if ( bResetAttr )
-        rStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_PLAIN );
+        m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_PLAIN );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to