# HG changeset patch
# User Michael Stahl <mst@openoffice.org>
# Date 1285336666 -7200
# Node ID 4fe751e3262829ab1c785b3e4ae0f4da9030db20
# Parent  5d85eb5ff5bdebd835e79edbaf37b3fcc03cb911
rtftok01: add actions, implement \plain

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
@@ -317,6 +317,7 @@
 
     void SetAttribute(Id const id, RTFValue::Pointer_t const& pValue);
     void SetSprm(Id const id, RTFValue::Pointer_t const& pValue);
+    void ResetCharacterProperties();
 
 protected:
     RTFScannerHandlerImpl & GetHandler() { return m_rHandler; }
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
@@ -180,24 +180,23 @@
     explicit RTFGroup()
         : m_TextEncoding(osl_getThreadTextEncoding())
         , m_UnicodeCharacters(1)
-#if 0
         , m_CharacterProperties()
-#endif
     { }
 
     // general properties
     rtl_TextEncoding m_TextEncoding;
     unsigned int m_UnicodeCharacters;
 
-#if 0
+    typedef ::std::map<Id, RTFValue::Pointer_t > Attributes_t;
+
     // character properties
-    class CharacterProperties
+    struct CharacterProperties
     {
-        public:
-            explicit CharacterProperties()
-                : m_bDefault(true)
-            { }
-            bool m_bDefault;
+    public:
+        explicit CharacterProperties()
+        { }
+        Attributes_t m_Attributes;
+        Attributes_t m_Sprms;
     };
     CharacterProperties m_CharacterProperties;
 
@@ -212,17 +211,6 @@
     void Reset() {
         ResetCharacterProperties();
     }
-#else
-    typedef ::std::map<Id, RTFValue::Pointer_t > Attributes_t;
-
-    Attributes_t m_Attributes;
-    Attributes_t m_Sprms;
-
-    void Reset() {
-        m_Attributes.clear();
-        m_Sprms.clear();
-    }
-#endif
 };
 
 
@@ -405,11 +393,14 @@
         }
     }
     void SetAttribute(Id const id, RTFValue::Pointer_t const& pValue) {
-        GetCurrentGroup().m_Attributes[id] = pValue;
+        GetCurrentGroup().m_CharacterProperties.m_Attributes[id] = pValue;
     }
     void SetSprm(Id const id, RTFValue::Pointer_t const& pValue) {
-        GetCurrentGroup().m_Sprms[id] = pValue;
+        GetCurrentGroup().m_CharacterProperties.m_Sprms[id] = pValue;
     }
+    void ResetCharacterProperties() {
+        GetCurrentGroup().ResetCharacterProperties();
+    };
 
 private:
     void checkStrings()
@@ -455,6 +446,13 @@
     GetHandler().SetSprm(id, pValue);
 }
 
+void
+RTFDestination::ResetCharacterProperties()
+{
+    GetHandler().ResetCharacterProperties();
+};
+
+
 
 static sal_uInt32
 lcl_CharsetToCodePage(sal_Int32 const charset)
@@ -789,9 +787,11 @@
     void SendString(sal_uInt8 const*const pStr, sal_Int32 const n)
     {
         GetHandler().GetStream().startCharacterGroup();
+        RTFGroup const& rGroup( GetHandler().GetCurrentGroup() );
         writerfilter::Reference<Properties>::Pointer_t const pProperties(
-            new RTFRefProperties(GetHandler().GetCurrentGroup().m_Attributes,
-                    GetHandler().GetCurrentGroup().m_Sprms) );
+            new RTFRefProperties(
+                rGroup.m_CharacterProperties.m_Attributes,
+                rGroup.m_CharacterProperties.m_Sprms) );
         GetHandler().GetStream().props(pProperties);
         GetHandler().GetStream().utext(pStr, n);
         GetHandler().GetStream().endCharacterGroup();
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
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <actions>
   <charprops>
+    <ref name="plain" action="ResetCharacterProperties()"/>
     <ref name="i" tokenid="sprm:CFItalic"/>
   </charprops>
 </actions>
diff --git a/writerfilter/source/rtftok/rtfcontrols.xsl b/writerfilter/source/rtftok/rtfcontrols.xsl
--- a/writerfilter/source/rtftok/rtfcontrols.xsl
+++ b/writerfilter/source/rtftok/rtfcontrols.xsl
@@ -89,35 +89,42 @@
       <xsl:value-of select="@name"/>
       <xsl:text>:&#xA;</xsl:text>
       <xsl:text>{&#xA;</xsl:text>
-      <xsl:choose>
-        <xsl:when test="$type=flag">
-        </xsl:when>
-        <xsl:when test="$type='toggle'">
-          <xsl:text>sal_Int32 const n( ('\0' == *value) ? 1 : ::rtl::OString(value).toInt32() );&#xA;</xsl:text>
-          <xsl:text>RTFValue::Pointer_t const pValue(new RTFValueBool(0 != n));&#xA;</xsl:text>
-        </xsl:when>
-        <xsl:when test="$type='value'">
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:text>#error token: </xsl:text>
-          <xsl:value-of select="@name"/>
-          <xsl:text> type is:</xsl:text>
-          <xsl:value-of select="$type"/>
-          <xsl:text>&#xA;</xsl:text>
-        </xsl:otherwise>
-      </xsl:choose>
-      <xsl:choose>
-        <xsl:when test="starts-with(@tokenid, 'sprm')">
-          <xsl:text>rDestination.SetSprm(</xsl:text>
-          <xsl:value-of select="$token"/>
-          <xsl:text>, pValue);&#xA;</xsl:text>
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:text>rDestination.SetAttribute(</xsl:text>
-          <xsl:value-of select="$token"/>
-          <xsl:text>, pValue);&#xA;</xsl:text>
-        </xsl:otherwise>
-      </xsl:choose>
+      <xsl:if test="@tokenid">
+        <xsl:choose>
+          <xsl:when test="$type=flag">
+          </xsl:when>
+          <xsl:when test="$type='toggle'">
+            <xsl:text>sal_Int32 const n( ('\0' == *value) ? 1 : ::rtl::OString(value).toInt32() );&#xA;</xsl:text>
+            <xsl:text>RTFValue::Pointer_t const pValue(new RTFValueBool(0 != n));&#xA;</xsl:text>
+          </xsl:when>
+          <xsl:when test="$type='value'">
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:text>#error token: </xsl:text>
+            <xsl:value-of select="@name"/>
+            <xsl:text> type is:</xsl:text>
+            <xsl:value-of select="$type"/>
+            <xsl:text>&#xA;</xsl:text>
+          </xsl:otherwise>
+        </xsl:choose>
+        <xsl:choose>
+          <xsl:when test="starts-with(@tokenid, 'sprm')">
+            <xsl:text>rDestination.SetSprm(</xsl:text>
+            <xsl:value-of select="$token"/>
+            <xsl:text>, pValue);&#xA;</xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:text>rDestination.SetAttribute(</xsl:text>
+            <xsl:value-of select="$token"/>
+            <xsl:text>, pValue);&#xA;</xsl:text>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:if>
+      <xsl:if test="@action">
+        <xsl:text>rDestination.</xsl:text>
+        <xsl:value-of select="@action"/>
+        <xsl:text>;&#xA;</xsl:text>
+      </xsl:if>
       <xsl:text>return true;&#xA;</xsl:text>
       <xsl:text>}&#xA;</xsl:text>
       <xsl:text>break;&#xA;</xsl:text>
