Commits

Anonymous committed f612667

rtftok01: now with section properties

Comments (0)

Files changed (4)

writerfilter/source/rtftok/RTFDestination.hxx

     void SetEncodingToFont(const sal_Int32 i);
     sal_uInt32 GetColorTableEntry(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 SetCharacterSprm(Id const id, RTFValue::Pointer_t const& pValue);
+    void SetParagraphSprm(Id const id, RTFValue::Pointer_t const& pValue);
+    void SetSectionSprm(Id const id, RTFValue::Pointer_t const& pValue);
     void ResetCharacterProperties();
     void ResetParagraphProperties();
+    void ResetSectionProperties();
     void ParagraphBreak();
+    void SectionBreak();
 
 protected:
     RTFScannerHandlerImpl & GetHandler() { return m_rHandler; }

writerfilter/source/rtftok/RTFDocumentImpl.cxx

     };
 
     // section properties
+    struct SectionProperties
+    {
+    public:
+        explicit SectionProperties()
+        { }
+        Attributes_t m_Attributes;
+        Attributes_t m_Sprms;
+    };
+    SectionProperties m_SectionProperties;
+
+    void ResetSectionProperties(/*Attributes_t const& rDefaults*/) {
+        m_SectionProperties = SectionProperties();
+    };
+
     // table properties
 
 #if 0
     void SetAttribute(Id const id, RTFValue::Pointer_t const& pValue) {
         GetCurrentGroup().m_CharacterProperties.m_Attributes[id] = pValue;
     }
-    void SetSprm(Id const id, RTFValue::Pointer_t const& pValue) {
+    void SetCharacterSprm(Id const id, RTFValue::Pointer_t const& pValue) {
         GetCurrentGroup().m_CharacterProperties.m_Sprms[id] = pValue;
     }
+    void SetParagraphSprm(Id const id, RTFValue::Pointer_t const& pValue) {
+        GetCurrentGroup().m_ParagraphProperties.m_Sprms[id] = pValue;
+    }
+    void SetSectionSprm(Id const id, RTFValue::Pointer_t const& pValue) {
+        GetCurrentGroup().m_SectionProperties.m_Sprms[id] = pValue;
+    }
     void ResetCharacterProperties() {
         GetCurrentGroup().ResetCharacterProperties(m_Defaults);
     }
     void ResetParagraphProperties() {
-        GetCurrentGroup().ResetCharacterProperties(m_Defaults);
+        GetCurrentGroup().ResetParagraphProperties();
+    }
+    void ResetSectionProperties() {
+        GetCurrentGroup().ResetSectionProperties();
     }
 
 private:
 }
 
 void
-RTFDestination::SetSprm(Id const id, RTFValue::Pointer_t const& pValue)
+RTFDestination::SetCharacterSprm(Id const id, RTFValue::Pointer_t const& pValue)
 {
-    GetHandler().SetSprm(id, pValue);
+    GetHandler().SetCharacterSprm(id, pValue);
+}
+
+void
+RTFDestination::SetParagraphSprm(Id const id, RTFValue::Pointer_t const& pValue)
+{
+    GetHandler().SetParagraphSprm(id, pValue);
+}
+
+void
+RTFDestination::SetSectionSprm(Id const id, RTFValue::Pointer_t const& pValue)
+{
+    GetHandler().SetSectionSprm(id, pValue);
 }
 
 void
 }
 
 void
+RTFDestination::ResetSectionProperties()
+{
+    GetHandler().ResetSectionProperties();
+}
+
+void
 RTFDestination::ParagraphBreak()
 {
+    RTFGroup const& rGroup( GetHandler().GetCurrentGroup() );
+    writerfilter::Reference<Properties>::Pointer_t const pProperties(
+        new RTFRefProperties(
+            rGroup.m_ParagraphProperties.m_Attributes,
+            rGroup.m_ParagraphProperties.m_Sprms) );
+    GetHandler().GetStream().props(pProperties);
+
     sal_uInt8 const nl(0x0d);
     GetHandler().GetStream().text(& nl, sizeof(nl));
     //FIXME when to start / end para group ???
+    //FIXME what about header/footer? (i.e. may paragraph groups nest?)
+    GetHandler().GetStream().endParagraphGroup();
+    GetHandler().GetStream().startParagraphGroup();
 }
 
+void
+RTFDestination::SectionBreak()
+{
+    RTFGroup const& rGroup( GetHandler().GetCurrentGroup() );
+    writerfilter::Reference<Properties>::Pointer_t const pProperties(
+        new RTFRefProperties(
+            rGroup.m_SectionProperties.m_Attributes,
+            rGroup.m_SectionProperties.m_Sprms) );
+    GetHandler().GetStream().props(pProperties);
+
+    //FIXME ??? how to terminate section
+    //FIXME when to start / end section group ???
+    GetHandler().GetStream().endParagraphGroup();
+    GetHandler().GetStream().endSectionGroup();
+    GetHandler().GetStream().startSectionGroup();
+    GetHandler().GetStream().startParagraphGroup();
+}
+
+
 
 
 static sal_uInt32
 public:
     explicit RTFDestinationRTF(RTFScannerHandlerImpl & rHandler)
         : RTFDestination(rHandler)
-    { }
+    {
+        GetHandler().GetStream().startSectionGroup();
+        GetHandler().GetStream().startParagraphGroup();
+    }
     virtual ~RTFDestinationRTF() { }
 
     virtual Pointer_t dest(Token_t const token, char const*const value)

writerfilter/source/rtftok/rtfactions.xml

     <!-- <ref name="txbxtwfirst"/> -->
     <!-- <ref name="txbxtwlast"/> -->
   </paraprops>
+  <sectprops>
+    <ref name="sect" action="SectionBreak()"/>
+    <ref name="sectd" action="ResetSectionProperties()"/>
+    <!-- <ref name="endnhere"/> -->
+    <!-- <ref name="binfsxn"/> -->
+    <!-- <ref name="binsxn"/> -->
+    <!-- <ref name="ds"/> -->
+    <!-- <ref name="pnseclvl"/> -->
+    <!-- <ref name="sectunlocked"/> -->
+    <!-- <ref name="sbknone"/> -->
+    <!-- <ref name="sbkcol"/> -->
+    <!-- <ref name="sbkpage"/> -->
+    <!-- <ref name="sbkeven"/> -->
+    <!-- <ref name="sbkodd"/> -->
+    <!-- <ref name="cols"/> -->
+    <!-- <ref name="colsx"/> -->
+    <!-- <ref name="colno"/> -->
+    <!-- <ref name="colsr"/> -->
+    <!-- <ref name="colw"/> -->
+    <!-- <ref name="linebetcol"/> -->
+    <!-- <ref name="sftntj"/> -->
+    <!-- <ref name="sftnbj"/> -->
+    <!-- <ref name="sftnstart"/> -->
+    <!-- <ref name="saftnstart"/> -->
+    <!-- <ref name="sftnrstpg"/> -->
+    <!-- <ref name="sftnrestart"/> -->
+    <!-- <ref name="sftnrstcont"/> -->
+    <!-- <ref name="saftnrestart"/> -->
+    <!-- <ref name="saftnrstcont"/> -->
+    <!-- <ref name="sftnnar"/> -->
+    <!-- <ref name="sftnnalc"/> -->
+    <!-- <ref name="sftnnauc"/> -->
+    <!-- <ref name="sftnnrlc"/> -->
+    <!-- <ref name="sftnnruc"/> -->
+    <!-- <ref name="sftnnchi"/> -->
+    <!-- <ref name="sftnnchosung"/> -->
+    <!-- <ref name="sftnncnum"/> -->
+    <!-- <ref name="sftnndbnum"/> -->
+    <!-- <ref name="sftnndbnumd"/> -->
+    <!-- <ref name="sftnndbnumt"/> -->
+    <!-- <ref name="sftnndbnumk"/> -->
+    <!-- <ref name="sftnndbar"/> -->
+    <!-- <ref name="sftnnganada"/> -->
+    <!-- <ref name="sftnngbnum"/> -->
+    <!-- <ref name="sftnngbnumd"/> -->
+    <!-- <ref name="sftnngbnuml"/> -->
+    <!-- <ref name="sftnngbnumk"/> -->
+    <!-- <ref name="sftnnzodiac"/> -->
+    <!-- <ref name="sftnnzodiacd"/> -->
+    <!-- <ref name="sftnnzodiacl"/> -->
+    <!-- <ref name="saftnnar"/> -->
+    <!-- <ref name="saftnnalc"/> -->
+    <!-- <ref name="saftnnauc"/> -->
+    <!-- <ref name="saftnnrlc"/> -->
+    <!-- <ref name="saftnnruc"/> -->
+    <!-- <ref name="saftnnchi"/> -->
+    <!-- <ref name="saftnnchosung"/> -->
+    <!-- <ref name="saftnncnum"/> -->
+    <!-- <ref name="saftnndbnum"/> -->
+    <!-- <ref name="saftnndbnumd"/> -->
+    <!-- <ref name="saftnndbnumt"/> -->
+    <!-- <ref name="saftnndbnumk"/> -->
+    <!-- <ref name="saftnndbar"/> -->
+    <!-- <ref name="saftnnganada"/> -->
+    <!-- <ref name="saftnngbnum"/> -->
+    <!-- <ref name="saftnngbnumd"/> -->
+    <!-- <ref name="saftnngbnuml"/> -->
+    <!-- <ref name="saftnngbnumk"/> -->
+    <!-- <ref name="saftnnzodiac"/> -->
+    <!-- <ref name="saftnnzodiacd"/> -->
+    <!-- <ref name="saftnnzodiacl"/> -->
+    <!-- <ref name="linemod"/> -->
+    <!-- <ref name="linex"/> -->
+    <!-- <ref name="linestarts"/> -->
+    <!-- <ref name="linerestart"/> -->
+    <!-- <ref name="lineppage"/> -->
+    <!-- <ref name="linecont"/> -->
+    <!-- <ref name="pgwsxn"/> -->
+    <!-- <ref name="pghsxn"/> -->
+    <!-- <ref name="marglsxn"/> -->
+    <!-- <ref name="margrsxn"/> -->
+    <!-- <ref name="margtsxn"/> -->
+    <!-- <ref name="margbsxn"/> -->
+    <!-- <ref name="guttersxn"/> -->
+    <!-- <ref name="margmirsxn"/> -->
+    <!-- <ref name="lndscpsxn"/> -->
+    <!-- <ref name="titlepg"/> -->
+    <!-- <ref name="headery"/> -->
+    <!-- <ref name="footery"/> -->
+    <!-- <ref name="pgnstarts"/> -->
+    <!-- <ref name="pgncont"/> -->
+    <!-- <ref name="pgnrestart"/> -->
+    <!-- <ref name="pgnx"/> -->
+    <!-- <ref name="pgny"/> -->
+    <!-- <ref name="pgndec"/> -->
+    <!-- <ref name="pgnucrm"/> -->
+    <!-- <ref name="pgnlcrm"/> -->
+    <!-- <ref name="pgnucltr"/> -->
+    <!-- <ref name="pgnlcltr"/> -->
+    <!-- <ref name="pgnbidia"/> -->
+    <!-- <ref name="pgnbidib"/> -->
+    <!-- <ref name="pgnchosung"/> -->
+    <!-- <ref name="pgncnum"/> -->
+    <!-- <ref name="pgndbnum"/> -->
+    <!-- <ref name="pgndbnumd"/> -->
+    <!-- <ref name="pgndbnumt"/> -->
+    <!-- <ref name="pgndbnumk"/> -->
+    <!-- <ref name="pgndecd"/> -->
+    <!-- <ref name="pgnganada"/> -->
+    <!-- <ref name="pgngbnum"/> -->
+    <!-- <ref name="pgngbnumd"/> -->
+    <!-- <ref name="pgngbnuml"/> -->
+    <!-- <ref name="pgngbnumk"/> -->
+    <!-- <ref name="pgnzodiac"/> -->
+    <!-- <ref name="pgnzodiacd"/> -->
+    <!-- <ref name="pgnzodiacl"/> -->
+    <!-- <ref name="pgnhindia"/> -->
+    <!-- <ref name="pgnhindib"/> -->
+    <!-- <ref name="pgnhindic"/> -->
+    <!-- <ref name="pgnhindid"/> -->
+    <!-- <ref name="pgnthaia"/> -->
+    <!-- <ref name="pgnthaib"/> -->
+    <!-- <ref name="pgnthaic"/> -->
+    <!-- <ref name="pgnvieta"/> -->
+    <!-- <ref name="pgnid"/> -->
+    <!-- <ref name="pgnhn"/> -->
+    <!-- <ref name="pgnhnsh"/> -->
+    <!-- <ref name="pgnhnsp"/> -->
+    <!-- <ref name="pgnhnsc"/> -->
+    <!-- <ref name="pgnhnsm"/> -->
+    <!-- <ref name="pgnhnsn"/> -->
+    <!-- <ref name="vertal"/> -->
+    <!-- <ref name="vertalt"/> -->
+    <!-- <ref name="vertalb"/> -->
+    <!-- <ref name="vertalc"/> -->
+    <!-- <ref name="vertalj"/> -->
+    <!-- <ref name="srauth"/> -->
+    <!-- <ref name="srdate"/> -->
+    <!-- <ref name="rtlsect"/> -->
+    <!-- <ref name="ltrsect"/> -->
+    <!-- <ref name="horzsect"/> -->
+    <!-- <ref name="vertsect"/> -->
+    <!-- <ref name="stextflow"/> -->
+    <!-- <ref name="pgbrdrhead"/> -->
+    <!-- <ref name="pgbrdrfoot"/> -->
+    <!-- <ref name="pgbrdrt"/> -->
+    <!-- <ref name="pgbrdrb"/> -->
+    <!-- <ref name="pgbrdrl"/> -->
+    <!-- <ref name="pgbrdrr"/> -->
+    <!-- <ref name="brdrart"/> -->
+    <!-- <ref name="pgbrdropt"/> -->
+    <!-- <ref name="pgbrdrsnap"/> -->
+    <!-- <ref name="sectexpand"/> -->
+    <!-- <ref name="sectlinegrid"/> -->
+    <!-- <ref name="sectdefaultcl"/> -->
+    <!-- <ref name="sectspecifycl"/> -->
+    <!-- <ref name="sectspecifyl"/> -->
+    <!-- <ref name="sectspecifygen"/> -->
+  </sectprops>
 </actions>
     <!--    <ref name="updnprops" tokenid="sprm:CHpsPos"/> destination??? -->

writerfilter/source/rtftok/rtfcontrols.xsl

 
   <xsl:key name="names" match="//control|//destination|//flag|//toggle|//value|//symbol" use="@name"/>
 
-  <xsl:template match="/">
-
-    <!-- header -->
-<xsl:text>
-/*
-    THIS FILE IS GENERATED! DO NOT EDIT!
-*/
-
-#include &lt;string&gt;
-
-#include &lt;sal/types.h&gt;
-
-#include &lt;doctok/resourceids.hxx&gt;
-#include &lt;doctok/sprmids.hxx&gt;
-
-#include &lt;rtftok/RTFTokens.hxx&gt;
-
-#include &lt;RTFDestination.hxx&gt;
-
-
-namespace writerfilter {
-namespace rtftok {
-
-
-bool handleControl(RTFDestination &amp; rDestination,
-        Token_t const token, char const*const value)
-{
-    OSL_ASSERT(token != RTF_TOKENS_END);
-    OSL_ASSERT(value);
-    switch (token)
-    {
-</xsl:text>
-
-    <!-- stuff -->
-    <xsl:for-each select="document('rtfactions.xml')/actions/*/ref">
+  <xsl:template name="handle-case">
+    <xsl:param name="kind"/>
       <xsl:variable name="name">
           <xsl:value-of select="@name"/>
       </xsl:variable>
                 <xsl:value-of select="@name"/>
                 <xsl:text> type is:</xsl:text>
                 <xsl:value-of select="$type"/>
+                <xsl:text> NO VALUE</xsl:text>
                 <xsl:text>&#xA;</xsl:text>
               </xsl:otherwise>
             </xsl:choose>
         </xsl:choose>
         <xsl:choose>
           <xsl:when test="starts-with(@tokenid, 'sprm') or starts-with(@tokenid, '0x')">
-            <xsl:text>rDestination.SetSprm(</xsl:text>
+            <xsl:choose>
+              <xsl:when test="$kind='character'">
+                <xsl:text>rDestination.SetCharacterSprm(</xsl:text>
+              </xsl:when>
+              <xsl:when test="$kind='paragraph'">
+                <xsl:text>rDestination.SetParagraphSprm(</xsl:text>
+              </xsl:when>
+              <xsl:when test="$kind='section'">
+                <xsl:text>rDestination.SetSectionSprm(</xsl:text>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:text>UNKNOWN KIND: </xsl:text>
+                <xsl:value-of select="$kind"/>
+              </xsl:otherwise>
+            </xsl:choose>
             <xsl:value-of select="$token"/>
             <xsl:text>, pValue);&#xA;</xsl:text>
           </xsl:when>
       <xsl:text>return true;&#xA;</xsl:text>
       <xsl:text>}&#xA;</xsl:text>
       <xsl:text>break;&#xA;</xsl:text>
+  </xsl:template>
+
+
+  <xsl:template match="/">
+
+    <!-- header -->
+<xsl:text>
+/*
+    THIS FILE IS GENERATED! DO NOT EDIT!
+*/
+
+#include &lt;string&gt;
+
+#include &lt;sal/types.h&gt;
+
+#include &lt;doctok/resourceids.hxx&gt;
+#include &lt;doctok/sprmids.hxx&gt;
+
+#include &lt;rtftok/RTFTokens.hxx&gt;
+
+#include &lt;RTFDestination.hxx&gt;
+
+
+namespace writerfilter {
+namespace rtftok {
+
+
+bool handleControl(RTFDestination &amp; rDestination,
+        Token_t const token, char const*const value)
+{
+    OSL_ASSERT(token != RTF_TOKENS_END);
+    OSL_ASSERT(value);
+    switch (token)
+    {
+</xsl:text>
+
+    <!-- stuff -->
+    <xsl:for-each select="document('rtfactions.xml')/actions/charprops/ref">
+      <xsl:call-template name="handle-case">
+        <xsl:with-param name="kind">character</xsl:with-param>
+      </xsl:call-template>
     </xsl:for-each>
+    <xsl:for-each select="document('rtfactions.xml')/actions/paraprops/ref">
+      <xsl:call-template name="handle-case">
+        <xsl:with-param name="kind">paragraph</xsl:with-param>
+      </xsl:call-template>
+    </xsl:for-each>
+    <xsl:for-each select="document('rtfactions.xml')/actions/sectprops/ref">
+      <xsl:call-template name="handle-case">
+        <xsl:with-param name="kind">section</xsl:with-param>
+      </xsl:call-template>
+    </xsl:for-each>
+
+
+
 
     <!-- footer -->
 <xsl:text>