# HG changeset patch
# User Michael Stahl <mst@openoffice.org>
# Date 1285851634 -7200
# Node ID f23793c1ff4127cf6673aa257546dbf383388a02
# Parent  1548c4e4b3963296325f4766e16ebc4e60940f96
rtftok01: some stuff for lang and fonts

diff --git a/writerfilter/source/rtftok/RTFDestination.hxx b/writerfilter/source/rtftok/RTFDestination.hxx
--- a/writerfilter/source/rtftok/RTFDestination.hxx
+++ b/writerfilter/source/rtftok/RTFDestination.hxx
@@ -315,6 +315,7 @@
 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();
diff --git a/writerfilter/source/rtftok/RTFDocumentImpl.cxx b/writerfilter/source/rtftok/RTFDocumentImpl.cxx
--- a/writerfilter/source/rtftok/RTFDocumentImpl.cxx
+++ b/writerfilter/source/rtftok/RTFDocumentImpl.cxx
@@ -39,7 +39,10 @@
 #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>
@@ -200,17 +203,20 @@
     };
     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
 };
 
 
@@ -280,7 +286,7 @@
             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));
@@ -340,7 +346,7 @@
             m_String.append(" ");
         }
     }
-    virtual void addBinData(unsigned char const data)
+    virtual void addBinData(unsigned char const /*data*/)
     {
         checkStrings();
     }
@@ -399,8 +405,11 @@
         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()
@@ -431,10 +440,17 @@
     ::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);
@@ -740,18 +756,53 @@
                 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))
diff --git a/writerfilter/source/rtftok/rtfactions.xml b/writerfilter/source/rtftok/rtfactions.xml
--- a/writerfilter/source/rtftok/rtfactions.xml
+++ b/writerfilter/source/rtftok/rtfactions.xml
@@ -24,15 +24,15 @@
     <!--    <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"/>
