sc/source/filter/inc/rtfexp.hxx |    3 +++
 sc/source/filter/rtf/rtfexp.cxx |   17 +++++++++++++++++
 2 files changed, 20 insertions(+)

New commits:
commit 81d59f2c125dff57fdfa17b119d6007f25ef500a
Author:     Henry Castro <[email protected]>
AuthorDate: Tue Jul 25 15:31:22 2023 -0400
Commit:     Henry Castro <[email protected]>
CommitDate: Wed Aug 2 16:07:10 2023 +0200

    sc: filter: rtf: add method "AddFont"
    
    Create a map font name associated with unique index.
    
    "The \fonttbl control word introduces the font table group.
    Unique \fN control words define each font available in the document,
    and are used to reference that font throughout the document"..
    
    Signed-off-by: Henry Castro <[email protected]>
    Change-Id: I028226cb539865f1980f953385c887a3bd4b8e3f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154905
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155260

diff --git a/sc/source/filter/inc/rtfexp.hxx b/sc/source/filter/inc/rtfexp.hxx
index 14ee8ec023f7..1c9f1bd7a4af 100644
--- a/sc/source/filter/inc/rtfexp.hxx
+++ b/sc/source/filter/inc/rtfexp.hxx
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include <map>
 #include <memory>
 #include "expbase.hxx"
 #include <tools/solar.h>
@@ -26,8 +27,10 @@
 class ScRTFExport : public ScExportBase
 {
     std::unique_ptr<sal_uLong[]>  m_pCellX;     // cumulative range in a table
+    std::map<OUString, sal_Int32> m_pFontTable;
     SvMemoryStream m_aDocStrm;
 
+    int                 AddFont( const SvxFontItem& rFontItem );
     void                WriteTab( SCTAB nTab );
     void                WriteRow( SCTAB nTab, SCROW nRow );
     void                WriteCell( SCTAB nTab,  SCROW nRow, SCCOL nCol );
diff --git a/sc/source/filter/rtf/rtfexp.cxx b/sc/source/filter/rtf/rtfexp.cxx
index db935dddc7fa..3b9e751b1336 100644
--- a/sc/source/filter/rtf/rtfexp.cxx
+++ b/sc/source/filter/rtf/rtfexp.cxx
@@ -22,6 +22,7 @@
 #include <editeng/wghtitem.hxx>
 #include <editeng/postitem.hxx>
 #include <editeng/udlnitem.hxx>
+#include <editeng/fontitem.hxx>
 #include <editeng/justifyitem.hxx>
 #include <svtools/rtfout.hxx>
 #include <svtools/rtfkeywd.hxx>
@@ -147,6 +148,22 @@ void ScRTFExport::WriteRow( SCTAB nTab, SCROW nRow )
     m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_ROW ).WriteOString( 
SAL_NEWLINE_STRING );
 }
 
+int ScRTFExport::AddFont(const SvxFontItem& rFontItem)
+{
+    auto nRet = m_pFontTable.size();
+    auto itFont(m_pFontTable.find(rFontItem.GetFamilyName()));
+    if (itFont == m_pFontTable.end())
+    {
+        m_pFontTable[rFontItem.GetFamilyName()] = nRet;
+    }
+    else
+    {
+        nRet = itFont->second;
+    }
+
+    return nRet;
+}
+
 void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol )
 {
     const ScPatternAttr* pAttr = pDoc->GetPattern( nCol, nRow, nTab );

Reply via email to