Anonymous avatar Anonymous committed f23793c

rtftok01: some stuff for lang and fonts

Comments (0)

Files changed (3)

writerfilter/source/rtftok/RTFDestination.hxx

 fprintf(stderr, "RTFDestination::HandleStringU: ignoring stringU\n");
     }
 
+    void SetEncodingToFont(const sal_Int32 i);
     void SetAttribute(Id const id, RTFValue::Pointer_t const& pValue);
     void SetSprm(Id const id, RTFValue::Pointer_t const& pValue);
     void ResetCharacterProperties();

writerfilter/source/rtftok/RTFDocumentImpl.cxx

 #include <comphelper/stlunosequence.hxx>
 
 #include <resourcemodel/TagLogger.hxx>
+
 #include <doctok/resourceids.hxx>
+#include <doctok/sprmids.hxx>
+
 #include <rtftok/RTFScanner.hxx>
 #include <rtftok/RTFScannerHandler.hxx>
 #include <rtftok/RTFInputSource.hxx>
     };
     CharacterProperties m_CharacterProperties;
 
-    void ResetCharacterProperties() {
+    void ResetCharacterProperties(Attributes_t const& rDefaults) {
         m_CharacterProperties = CharacterProperties();
+        m_CharacterProperties.m_Sprms = rDefaults;
     };
 
     // paragraph properties
     // section properties
     // table properties
 
+#if 0
     void Reset() {
         ResetCharacterProperties();
     }
+#endif
 };
 
 
             case RTF_u:
             {
                 sal_Int32 const v(::rtl::OString(value).toInt32());
-fprintf(stderr, "RTFScannerHandlerImpl::ctrl: \\u%d\n", v);
+fprintf(stderr, "RTFScannerHandlerImpl::ctrl: \\u%" SAL_PRIdINT32 "\n", v);
                 if ((SAL_MIN_INT16 <= v) && (v <= SAL_MAX_INT16)) {
                     RTFScannerHandlerImpl::addCharU(
                         static_cast<sal_Unicode>(v));
             m_String.append(" ");
         }
     }
-    virtual void addBinData(unsigned char const data)
+    virtual void addBinData(unsigned char const /*data*/)
     {
         checkStrings();
     }
         GetCurrentGroup().m_CharacterProperties.m_Sprms[id] = pValue;
     }
     void ResetCharacterProperties() {
-        GetCurrentGroup().ResetCharacterProperties();
-    };
+        GetCurrentGroup().ResetCharacterProperties(m_Defaults);
+    }
+    void SetDefault(Id const id, RTFValue::Pointer_t const& pValue) {
+        m_Defaults[id] = pValue;
+    }
 
 private:
     void checkStrings()
     ::std::stack< ::std::pair<int, RTFDestination::Pointer_t> > m_Destinations;
     ::std::stack< RTFGroup > m_Groups;
     FontTable_t m_FontTable;
+    RTFGroup::Attributes_t m_Defaults;
 };
 
 
 void
+RTFDestination::SetEncodingToFont(const sal_Int32 i)
+{
+    GetHandler().SetEncodingToFont(i);
+}
+
+void
 RTFDestination::SetAttribute(Id const id, RTFValue::Pointer_t const& pValue)
 {
     GetHandler().SetAttribute(id, pValue);
                 GetHandler().SetEncoding(e);
             }
             break;
+            case RTF_deff:
+            {
+                sal_Int32 const n( ::rtl::OString(value).toInt32() );
+                RTFValue::Pointer_t const pValue(new RTFValueInt(n));
+                GetHandler().SetDefault(NS_sprm::LN_CRgFtc0, pValue);
+            }
+            case RTF_adeff:
+            {
+                sal_Int32 const n( ::rtl::OString(value).toInt32() );
+                RTFValue::Pointer_t const pValue(new RTFValueInt(n));
+                GetHandler().SetDefault(NS_sprm::LN_CRgFtc2, pValue);
+            }
+            case RTF_deflang:
+            {
+                sal_Int32 const n( ::rtl::OString(value).toInt32() );
+                RTFValue::Pointer_t const pValue(new RTFValueInt(n));
+                GetHandler().SetDefault(NS_sprm::LN_CRgLid0, pValue);
+            }
+            break;
+            case RTF_deflangfe:
+            {
+                sal_Int32 const n( ::rtl::OString(value).toInt32() );
+                RTFValue::Pointer_t const pValue(new RTFValueInt(n));
+                GetHandler().SetDefault(NS_sprm::LN_CRgLid1, pValue);
+            }
+            break;
+            case RTF_adeflang:
+            {
+                sal_Int32 const n( ::rtl::OString(value).toInt32() );
+                RTFValue::Pointer_t const pValue(new RTFValueInt(n));
+                GetHandler().SetDefault(NS_sprm::LN_CLidBi, pValue);
+            }
+            break;
             case RTF_par:
             {
                 sal_uInt8 const nl(0x0d);
                 GetHandler().GetStream().text(& nl, sizeof(nl));
             }
             break;
+            /*
             case RTF_f:
             {
                 sal_Int32 const n( ::rtl::OString(value).toInt32() );
                 GetHandler().SetEncodingToFont(n);
             }
             break;
+            */
             default:
             {
                 if (!handleControl(*this, token, value))

writerfilter/source/rtftok/rtfactions.xml

     <!--    <ref name="expnd"/>-->
     <!--    <ref name="expndtw"/>-->
     <ref name="fittext" tokenid="sprm:CFitText"/>
-    <!--    <ref name="f" tokenid="sprm:CRgFtc0"/> -->
+    <ref name="f" tokenid="sprm:CRgFtc0" action="SetEncodingToFont(n)"/>
     <ref name="fs" tokenid="sprm:CHps"/>
     <ref name="i" tokenid="sprm:CFItalic"/>
     <ref name="impr" tokenid="sprm:CFImprint"/>
     <!--    <ref name="kerning" tokenid="sprm:CDxaSpace   sprm:CHpsKern"/> ??? -->
-    <!--    <ref name="langfe" tokenid="sprm:LN_CRgLid1"/> -->
-    <!--    <ref name="langfenp" tokenid="sprm:LN_CRgLid1"/> -->
-    <!--    <ref name="lang" tokenid="sprm:LN_CRgLid0"/> -->
-    <!--    <ref name="langnp" tokenid="sprm:LN_CRgLid0"/> -->
+    <ref name="langfe" tokenid="sprm:CRgLid1"/>
+    <ref name="langfenp" tokenid="sprm:CRgLid1"/>
+    <ref name="lang" tokenid="sprm:CRgLid0"/>
+    <ref name="langnp" tokenid="sprm:CRgLid0"/>
     <!--    <ref name="ltrch"/>  -->
     <!--    <ref name="noproof"/>  -->
     <ref name="nosupersub" tokenid="sprm:CIss" value="0"/>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.