[Libreoffice-commits] .: 376 commits - writerfilter/debug_setup.mk writerfilter/inc writerfilter/Library_rtftok.mk writerfilter/Library_writerfilter.mk writerfilter/Module_writerfilter.mk writerfilter/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Fri Jul 1 15:55:27 PDT 2011


 writerfilter/Library_rtftok.mk                        |   39 
 writerfilter/Library_writerfilter.mk                  |    2 
 writerfilter/Module_writerfilter.mk                   |    4 
 writerfilter/debug_setup.mk                           |    1 
 writerfilter/inc/WriterFilterDllApi.hxx               |    6 
 writerfilter/inc/dmapper/DomainMapper.hxx             |    1 
 writerfilter/inc/rtftok/RTFDocument.hxx               |   72 
 writerfilter/inc/rtftok/RTFInputSource.hxx            |   45 
 writerfilter/inc/rtftok/RTFParseException.hxx         |   45 
 writerfilter/inc/rtftok/RTFScanner.hxx                |   68 
 writerfilter/inc/rtftok/RTFScannerHandler.hxx         |   53 
 writerfilter/source/dmapper/DomainMapper.cxx          |   14 
 writerfilter/source/dmapper/DomainMapper_Impl.hxx     |    4 
 writerfilter/source/dmapper/NumberingManager.cxx      |    2 
 writerfilter/source/filter/RtfFilter.cxx              |   39 
 writerfilter/source/rtftok/FlexLexer.h                |  151 -
 writerfilter/source/rtftok/RTFParseException.cxx      |   35 
 writerfilter/source/rtftok/RTFScanner.lex             |  333 --
 writerfilter/source/rtftok/RTFScanner.skl             | 1527 ----------
 writerfilter/source/rtftok/rtfcharsets.cxx            |   75 
 writerfilter/source/rtftok/rtfcontrolwords.cxx        | 1855 +++++++++++++
 writerfilter/source/rtftok/rtfcontrolwords.hxx        | 1854 +++++++++++++
 writerfilter/source/rtftok/rtfdocumentfactory.cxx     |   44 
 writerfilter/source/rtftok/rtfdocumentimpl.cxx        | 2547 ++++++++++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.hxx        |  305 ++
 writerfilter/source/rtftok/rtfreferenceproperties.cxx |   69 
 writerfilter/source/rtftok/rtfreferenceproperties.hxx |   58 
 writerfilter/source/rtftok/rtfreferencetable.cxx      |   56 
 writerfilter/source/rtftok/rtfreferencetable.hxx      |   57 
 writerfilter/source/rtftok/rtfsprm.cxx                |  121 
 writerfilter/source/rtftok/rtfsprm.hxx                |   68 
 writerfilter/source/rtftok/rtftypes.hxx               |   58 
 writerfilter/source/rtftok/rtfvalue.cxx               |  174 +
 writerfilter/source/rtftok/rtfvalue.hxx               |   76 
 34 files changed, 7576 insertions(+), 2282 deletions(-)

New commits:
commit dab107de5f3db96c0f0d463fedbd489dd3f76db4
Merge: 27ca06f... fe1d6a6...
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Sat Jul 2 00:32:58 2011 +0200

    Merge remote-tracking branch 'feature/gsoc2011_rtfimport'

commit fe1d6a6b090cf4b7512e23fdfe201650b06b6a7e
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 18:22:54 2011 +0200

    get rid of m_pCurrentKeyword

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index b7bbbd9..ff462d3 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -244,6 +244,15 @@ static int lcl_AsHex(char ch)
     return ret;
 }
 
+static const char* lcl_RtfToString(RTFKeyword nKeyword)
+{
+    for (int i = 0; i < nRTFControlWords; i++)
+    {
+        if (nKeyword == aRTFControlWords[i].nIndex)
+            return aRTFControlWords[i].sKeyword;
+    }
+    return NULL;
+}
 RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& xContext,
         uno::Reference<io::XInputStream> const& xInputStream,
         uno::Reference<lang::XComponent> const& xDstDoc,
@@ -255,7 +264,6 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
     m_nGroup(0),
     m_aDefaultState(),
     m_bSkipUnknown(false),
-    m_pCurrentKeyword(0),
     m_aFontEncodings(),
     m_aColorTable(),
     m_bFirstRun(true),
@@ -915,7 +923,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
             m_aStates.top().nDestinationState = DESTINATION_SKIP;
             break;
         default:
-            OSL_TRACE("%s: TODO handle destination '%s'", OSL_THIS_FUNC, m_pCurrentKeyword->getStr());
+            OSL_TRACE("%s: TODO handle destination '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
             // Make sure we skip destinations (even without \*) till we don't handle them
             m_aStates.top().nDestinationState = DESTINATION_SKIP;
             bParsed = false;
@@ -1054,7 +1062,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
             // Nothing to do, dmapper assumes this is the default.
             break;
         default:
-            OSL_TRACE("%s: TODO handle symbol '%s'", OSL_THIS_FUNC, m_pCurrentKeyword->getStr());
+            OSL_TRACE("%s: TODO handle symbol '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
             bParsed = false;
             break;
     }
@@ -1398,7 +1406,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
             }
             break;
         default:
-            OSL_TRACE("%s: TODO handle flag '%s'", OSL_THIS_FUNC, m_pCurrentKeyword->getStr());
+            OSL_TRACE("%s: TODO handle flag '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
             bParsed = false;
             break;
     }
@@ -1874,7 +1882,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
             }
             break;
         default:
-            OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, m_pCurrentKeyword->getStr());
+            OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
             bParsed = false;
             break;
     }
@@ -1974,7 +1982,7 @@ int RTFDocumentImpl::dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam
             }
             break;
         default:
-            OSL_TRACE("%s: TODO handle toggle '%s'", OSL_THIS_FUNC, m_pCurrentKeyword->getStr());
+            OSL_TRACE("%s: TODO handle toggle '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
             bParsed = false;
             break;
     }
@@ -2014,7 +2022,6 @@ int RTFDocumentImpl::dispatchKeyword(OString& rKeyword, bool bParam, int nParam)
         return 0;
     }
 
-    m_pCurrentKeyword = &rKeyword;
     switch (aRTFControlWords[i].nControlType)
     {
         case CONTROL_FLAG:
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index ff66164..d515850 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -262,8 +262,6 @@ namespace writerfilter {
                 /// Read by RTF_PARD.
                 RTFParserState m_aDefaultState;
                 bool m_bSkipUnknown;
-                /// For debugging purposes, where int value would not be enough
-                rtl::OString* m_pCurrentKeyword;
                 /// Font index <-> encoding map, *not* part of the parser state
                 std::map<int, rtl_TextEncoding> m_aFontEncodings;
                 /// Color index <-> RGB color value map
commit 6b4f7a6b8c3ae9d04e546febecc829419b457c16
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 18:11:25 2011 +0200

    implement RTF_LBRACE and RTF_RBRACE

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index b07850a..b7bbbd9 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -937,6 +937,8 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
         case RTF_LINE: cCh = '\n'; break;
         case RTF_TAB: cCh = '\t'; break;
         case RTF_BACKSLASH: cCh = '\\'; break;
+        case RTF_LBRACE: cCh = '{'; break;
+        case RTF_RBRACE: cCh = '}'; break;
         case RTF_EMDASH: cCh = 151; break;
         case RTF_ENDASH: cCh = 150; break;
         case RTF_BULLET: cCh = 149; break;
commit 9c408a917bedbd413954d9ad035441b33df0b9af
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 18:04:07 2011 +0200

    use the destination buffer for levelnumbers

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 0468da8..b07850a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -586,15 +586,13 @@ void RTFDocumentImpl::text(OUString& rString)
     bool bRet = true;
     switch (m_aStates.top().nDestinationState)
     {
-        case DESTINATION_LEVELTEXT:
-            m_aStates.top().aLevelText.append(rString);
-            break;
         case DESTINATION_FONTENTRY:
         case DESTINATION_STYLEENTRY:
         case DESTINATION_REVISIONENTRY:
             // drop the ; at the end if it's there
             if (rString.endsWithAsciiL(";", 1))
                 rString = rString.copy(0, rString.getLength() - 1);
+        case DESTINATION_LEVELTEXT:
         case DESTINATION_SHAPEPROPERTYNAME:
         case DESTINATION_SHAPEPROPERTYVALUE:
         case DESTINATION_BOOKMARKEND:
@@ -2254,7 +2252,7 @@ int RTFDocumentImpl::popState()
     }
     else if (m_aStates.top().nDestinationState == DESTINATION_LEVELTEXT)
     {
-        OUString aStr = m_aStates.top().aLevelText.makeStringAndClear();
+        OUString aStr = m_aDestinationText.makeStringAndClear();
 
         // The first character is the length of the string (the rest should be ignored).
         sal_Int32 nLength(aStr.toChar());
@@ -2516,7 +2514,6 @@ RTFParserState::RTFParserState()
     nCharsToSkip(0),
     nListLevelNum(0),
     aListLevelEntries(),
-    aLevelText(),
     aLevelNumbers(),
     nPictureScaleX(0),
     nPictureScaleY(0),
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 61403c5..ff66164 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -185,9 +185,6 @@ namespace writerfilter {
                 /// List level entries, which will form a list entry later.
                 RTFSprms_t aListLevelEntries;
 
-                /// Text from leveltext destination.
-                rtl::OUStringBuffer aLevelText;
-
                 /// List of character positions in leveltext to replace.
                 std::vector<sal_Int32> aLevelNumbers;
 
commit c155b4bc9242270af7cd0bc7aa57a842daace7b4
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 17:54:38 2011 +0200

    accents in bookmarks

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index e5ba6b1..0468da8 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -589,19 +589,15 @@ void RTFDocumentImpl::text(OUString& rString)
         case DESTINATION_LEVELTEXT:
             m_aStates.top().aLevelText.append(rString);
             break;
-        case DESTINATION_BOOKMARKEND:
-            Mapper().props(lcl_getBookmarkProperties(m_aBookmarks[rString]));
-            break;
         case DESTINATION_FONTENTRY:
         case DESTINATION_STYLEENTRY:
         case DESTINATION_REVISIONENTRY:
-            {
-                // drop the ; at the end if it's there
-                if (rString.endsWithAsciiL(";", 1))
-                    rString = rString.copy(0, rString.getLength() - 1);
-            }
+            // drop the ; at the end if it's there
+            if (rString.endsWithAsciiL(";", 1))
+                rString = rString.copy(0, rString.getLength() - 1);
         case DESTINATION_SHAPEPROPERTYNAME:
         case DESTINATION_SHAPEPROPERTYVALUE:
+        case DESTINATION_BOOKMARKEND:
             m_aDestinationText.append(rString);
             break;
         default: bRet = false; break;
@@ -650,11 +646,10 @@ void RTFDocumentImpl::text(OUString& rString)
         m_bNeedPap = false;
     }
 
+    // Don't return earlier, a bookmark start has to be in a paragraph group.
     if (m_aStates.top().nDestinationState == DESTINATION_BOOKMARKSTART)
     {
-        int nPos = m_aBookmarks.size();
-        m_aBookmarks[rString] = nPos;
-        Mapper().props(lcl_getBookmarkProperties(nPos, rString));
+        m_aDestinationText.append(rString);
         return;
     }
 
@@ -2310,6 +2305,15 @@ int RTFDocumentImpl::popState()
     }
     else if (m_aStates.top().nDestinationState == DESTINATION_REVISIONENTRY)
         m_aAuthors[m_aAuthors.size()] = m_aDestinationText.makeStringAndClear();
+    else if (m_aStates.top().nDestinationState == DESTINATION_BOOKMARKSTART)
+    {
+        OUString aStr = m_aDestinationText.makeStringAndClear();
+        int nPos = m_aBookmarks.size();
+        m_aBookmarks[aStr] = nPos;
+        Mapper().props(lcl_getBookmarkProperties(nPos, aStr));
+    }
+    else if (m_aStates.top().nDestinationState == DESTINATION_BOOKMARKEND)
+        Mapper().props(lcl_getBookmarkProperties(m_aBookmarks[m_aDestinationText.makeStringAndClear()]));
 
     // See if we need to end a track change
     RTFValue::Pointer_t pTrackchange = RTFSprm::find(m_aStates.top().aCharacterSprms, NS_ooxml::LN_trackchange);
commit 0eae138dd92633458c1a7fe9966578b221c65b6f
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 17:38:08 2011 +0200

    accents in shape properties

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 83f824c..e5ba6b1 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -575,10 +575,6 @@ int RTFDocumentImpl::resolveChars(char ch)
         // set components back to zero
         m_aStates.top().aCurrentColor = RTFColorTableEntry();
     }
-    else if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYNAME)
-        m_aStates.top().aShapeProperties.push_back(make_pair(aOUStr, OUString()));
-    else if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYVALUE)
-        m_aStates.top().aShapeProperties.back().second += aOUStr;
     else
         text(aOUStr);
 
@@ -603,8 +599,10 @@ void RTFDocumentImpl::text(OUString& rString)
                 // drop the ; at the end if it's there
                 if (rString.endsWithAsciiL(";", 1))
                     rString = rString.copy(0, rString.getLength() - 1);
-                m_aDestinationText.append(rString);
             }
+        case DESTINATION_SHAPEPROPERTYNAME:
+        case DESTINATION_SHAPEPROPERTYVALUE:
+            m_aDestinationText.append(rString);
             break;
         default: bRet = false; break;
     }
@@ -2299,6 +2297,10 @@ int RTFDocumentImpl::popState()
             || m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTY)
     {
         aShapeProperties = m_aStates.top().aShapeProperties;
+        if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYNAME)
+            aShapeProperties.push_back(make_pair(m_aDestinationText.makeStringAndClear(), OUString()));
+        else if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYVALUE)
+            aShapeProperties.back().second = m_aDestinationText.makeStringAndClear();
         bPopShapeProperties = true;
     }
     else if (m_aStates.top().nDestinationState == DESTINATION_PICPROP)
commit 4476d83eb58554d9a99a0f37bbf2875082d06a7e
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 17:28:09 2011 +0200

    unify strip of table entries

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 8f87407..83f824c 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -587,41 +587,30 @@ int RTFDocumentImpl::resolveChars(char ch)
 
 void RTFDocumentImpl::text(OUString& rString)
 {
-    if (m_aStates.top().nDestinationState == DESTINATION_LEVELTEXT)
+    bool bRet = true;
+    switch (m_aStates.top().nDestinationState)
     {
-        m_aStates.top().aLevelText.append(rString);
-        return;
-    }
-    else if (m_aStates.top().nDestinationState == DESTINATION_BOOKMARKEND)
-    {
-        int nPos = m_aBookmarks[rString];
-        Mapper().props(lcl_getBookmarkProperties(nPos));
-        return;
-    }
-    else if (m_aStates.top().nDestinationState == DESTINATION_REVISIONENTRY)
-    {
-        // this is an author name, drop the ; at the end if it's there
-        if (rString.endsWithAsciiL(";", 1))
-            rString = rString.copy(0, rString.getLength() - 1);
-        m_aDestinationText.append(rString);
-        return;
-    }
-    else if (m_aStates.top().nDestinationState == DESTINATION_FONTENTRY)
-    {
-        // this is a font name, drop the ; at the end if it's there
-        if (rString.endsWithAsciiL(";", 1))
-            rString = rString.copy(0, rString.getLength() - 1);
-        m_aDestinationText.append(rString);
-        return;
+        case DESTINATION_LEVELTEXT:
+            m_aStates.top().aLevelText.append(rString);
+            break;
+        case DESTINATION_BOOKMARKEND:
+            Mapper().props(lcl_getBookmarkProperties(m_aBookmarks[rString]));
+            break;
+        case DESTINATION_FONTENTRY:
+        case DESTINATION_STYLEENTRY:
+        case DESTINATION_REVISIONENTRY:
+            {
+                // drop the ; at the end if it's there
+                if (rString.endsWithAsciiL(";", 1))
+                    rString = rString.copy(0, rString.getLength() - 1);
+                m_aDestinationText.append(rString);
+            }
+            break;
+        default: bRet = false; break;
     }
-    else if (m_aStates.top().nDestinationState == DESTINATION_STYLEENTRY)
-    {
-        // this is a style name, drop the ; at the end if it's there
-        if (rString.endsWithAsciiL(";", 1))
-            rString = rString.copy(0, rString.getLength() - 1);
-        m_aDestinationText.append(rString);
+    if (bRet)
         return;
-    }
+
     if (m_aIgnoreFirst.getLength() && m_aIgnoreFirst.equals(rString))
     {
         m_aIgnoreFirst = OUString();
commit 1cdbc2cb6786bae8b57ba93cbcbf921ae14eeab4
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 17:20:01 2011 +0200

    Revert "dmapper: spelling fix in DomainMapper_Impl::handleToc"
    
    This reverts commit 2ffbb1dda9234690233f48b2bc521c97d1335237.

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 0b7ea2d..9944c8c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2255,7 +2255,7 @@ void DomainMapper_Impl::handleToc
         xTOC->setPropertyValue( rPropNameSupplier.GetName( PROP_CREATE_FROM_MARKS ), uno::makeAny( bFromEntries ));
         if( sTemplate.getLength() )
         {
-                            //the string contains coma separated the names and related levels
+                            //the string contains comma separated the names and related levels
                             //like: "Heading 1,1,Heading 2,2"
             TOCStyleMap aMap;
             sal_Int32 nLevel;
commit a6d951a927385cae84759bb14fc8014bdd0913c6
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 17:15:13 2011 +0200

    accents in style names

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index c183f6f..8f87407 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -575,16 +575,6 @@ int RTFDocumentImpl::resolveChars(char ch)
         // set components back to zero
         m_aStates.top().aCurrentColor = RTFColorTableEntry();
     }
-    else if (m_aStates.top().nDestinationState == DESTINATION_STYLEENTRY)
-    {
-        // this is a style name, drop the ; at the end if it's there
-        if (aOUStr.endsWithAsciiL(";", 1))
-        {
-            aOUStr = aOUStr.copy(0, aOUStr.getLength() - 1);
-        }
-        RTFValue::Pointer_t pValue(new RTFValue(aOUStr));
-        m_aStates.top().aTableAttributes.push_back(make_pair(NS_rtf::LN_XSTZNAME1, pValue));
-    }
     else if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYNAME)
         m_aStates.top().aShapeProperties.push_back(make_pair(aOUStr, OUString()));
     else if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYVALUE)
@@ -624,6 +614,14 @@ void RTFDocumentImpl::text(OUString& rString)
         m_aDestinationText.append(rString);
         return;
     }
+    else if (m_aStates.top().nDestinationState == DESTINATION_STYLEENTRY)
+    {
+        // this is a style name, drop the ; at the end if it's there
+        if (rString.endsWithAsciiL(";", 1))
+            rString = rString.copy(0, rString.getLength() - 1);
+        m_aDestinationText.append(rString);
+        return;
+    }
     if (m_aIgnoreFirst.getLength() && m_aIgnoreFirst.equals(rString))
     {
         m_aIgnoreFirst = OUString();
@@ -2227,6 +2225,9 @@ int RTFDocumentImpl::popState()
     }
     else if (m_aStates.top().nDestinationState == DESTINATION_STYLEENTRY)
     {
+        RTFValue::Pointer_t pValue(new RTFValue(m_aDestinationText.makeStringAndClear()));
+        m_aStates.top().aTableAttributes.push_back(make_pair(NS_rtf::LN_XSTZNAME1, pValue));
+
         bStyleEntryEnd = true;
         writerfilter::Reference<Properties>::Pointer_t const pProp(
                 new RTFReferenceProperties(mergeAttributes(), mergeSprms())
commit 3ac9270fc6f1015505d47a428819233840e87cc6
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 17:10:40 2011 +0200

    accents in font names

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 2a205b6..c183f6f 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -566,17 +566,7 @@ int RTFDocumentImpl::resolveChars(char ch)
 
     OUString aOUStr(OStringToOUString(aStr, m_aStates.top().nCurrentEncoding));
 
-    if (m_aStates.top().nDestinationState == DESTINATION_FONTENTRY)
-    {
-        // this is a font name, drop the ; at the end if it's there
-        if (aOUStr.endsWithAsciiL(";", 1))
-        {
-            aOUStr = aOUStr.copy(0, aOUStr.getLength() - 1);
-        }
-        RTFValue::Pointer_t pValue(new RTFValue(aOUStr));
-        m_aStates.top().aTableAttributes.push_back(make_pair(NS_rtf::LN_XSZFFN, pValue));
-    }
-    else if (m_aStates.top().nDestinationState == DESTINATION_COLORTABLE)
+    if (m_aStates.top().nDestinationState == DESTINATION_COLORTABLE)
     {
         // we hit a ';' at the end of each color entry
         sal_uInt32 color = (m_aStates.top().aCurrentColor.nRed << 16) | ( m_aStates.top().aCurrentColor.nGreen << 8)
@@ -622,9 +612,15 @@ void RTFDocumentImpl::text(OUString& rString)
     {
         // this is an author name, drop the ; at the end if it's there
         if (rString.endsWithAsciiL(";", 1))
-        {
             rString = rString.copy(0, rString.getLength() - 1);
-        }
+        m_aDestinationText.append(rString);
+        return;
+    }
+    else if (m_aStates.top().nDestinationState == DESTINATION_FONTENTRY)
+    {
+        // this is a font name, drop the ; at the end if it's there
+        if (rString.endsWithAsciiL(";", 1))
+            rString = rString.copy(0, rString.getLength() - 1);
         m_aDestinationText.append(rString);
         return;
     }
@@ -2219,6 +2215,9 @@ int RTFDocumentImpl::popState()
     }
     else if (m_aStates.top().nDestinationState == DESTINATION_FONTENTRY)
     {
+        RTFValue::Pointer_t pValue(new RTFValue(m_aDestinationText.makeStringAndClear()));
+        m_aStates.top().aTableAttributes.push_back(make_pair(NS_rtf::LN_XSZFFN, pValue));
+
         bFontEntryEnd = true;
         writerfilter::Reference<Properties>::Pointer_t const pProp(
                 new RTFReferenceProperties(m_aStates.top().aTableAttributes, m_aStates.top().aTableSprms)
commit bc6b16e6a68865ee1f4d4c051884ce1f773a186b
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 17:02:08 2011 +0200

    handle accents in revision entries

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 1a9821a..2a205b6 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -599,15 +599,6 @@ int RTFDocumentImpl::resolveChars(char ch)
         m_aStates.top().aShapeProperties.push_back(make_pair(aOUStr, OUString()));
     else if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYVALUE)
         m_aStates.top().aShapeProperties.back().second += aOUStr;
-    else if (m_aStates.top().nDestinationState == DESTINATION_REVISIONENTRY)
-    {
-        // this is an author name, drop the ; at the end if it's there
-        if (aOUStr.endsWithAsciiL(";", 1))
-        {
-            aOUStr = aOUStr.copy(0, aOUStr.getLength() - 1);
-        }
-        m_aAuthors[m_aAuthors.size()] = aOUStr;
-    }
     else
         text(aOUStr);
 
@@ -627,6 +618,16 @@ void RTFDocumentImpl::text(OUString& rString)
         Mapper().props(lcl_getBookmarkProperties(nPos));
         return;
     }
+    else if (m_aStates.top().nDestinationState == DESTINATION_REVISIONENTRY)
+    {
+        // this is an author name, drop the ; at the end if it's there
+        if (rString.endsWithAsciiL(";", 1))
+        {
+            rString = rString.copy(0, rString.getLength() - 1);
+        }
+        m_aDestinationText.append(rString);
+        return;
+    }
     if (m_aIgnoreFirst.getLength() && m_aIgnoreFirst.equals(rString))
     {
         m_aIgnoreFirst = OUString();
@@ -2316,6 +2317,8 @@ int RTFDocumentImpl::popState()
         aShapeProperties = m_aStates.top().aShapeProperties;
         bPicPropEnd = true;
     }
+    else if (m_aStates.top().nDestinationState == DESTINATION_REVISIONENTRY)
+        m_aAuthors[m_aAuthors.size()] = m_aDestinationText.makeStringAndClear();
 
     // See if we need to end a track change
     RTFValue::Pointer_t pTrackchange = RTFSprm::find(m_aStates.top().aCharacterSprms, NS_ooxml::LN_trackchange);
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 164e96b..61403c5 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -299,6 +299,8 @@ namespace writerfilter {
                 std::map<rtl::OUString, int> m_aBookmarks;
                 /// Revision index <-> author map.
                 std::map<int, rtl::OUString> m_aAuthors;
+                /// Text from special destinations.
+                rtl::OUStringBuffer m_aDestinationText;
         };
     } // namespace rtftok
 } // namespace writerfilter
commit de4c1a2211673b332f0c6e628d988737ee946cf0
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 16:56:23 2011 +0200

    resolveChars: make calling text() the default
    
    Ideally we should always call that, since that handles unicode
    characters.

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 2dcd97b..1a9821a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -566,13 +566,7 @@ int RTFDocumentImpl::resolveChars(char ch)
 
     OUString aOUStr(OStringToOUString(aStr, m_aStates.top().nCurrentEncoding));
 
-    if (m_aStates.top().nDestinationState == DESTINATION_NORMAL
-            || m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION
-            || m_aStates.top().nDestinationState == DESTINATION_FIELDRESULT
-            || m_aStates.top().nDestinationState == DESTINATION_LEVELTEXT || m_aStates.top().nDestinationState == DESTINATION_BOOKMARKSTART
-            || m_aStates.top().nDestinationState == DESTINATION_BOOKMARKEND)
-        text(aOUStr);
-    else if (m_aStates.top().nDestinationState == DESTINATION_FONTENTRY)
+    if (m_aStates.top().nDestinationState == DESTINATION_FONTENTRY)
     {
         // this is a font name, drop the ; at the end if it's there
         if (aOUStr.endsWithAsciiL(";", 1))
@@ -614,6 +608,8 @@ int RTFDocumentImpl::resolveChars(char ch)
         }
         m_aAuthors[m_aAuthors.size()] = aOUStr;
     }
+    else
+        text(aOUStr);
 
     return 0;
 }
commit 8781e239a818e935a980291b78ad5722f0e97a0c
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 16:39:26 2011 +0200

    add license headers

diff --git a/writerfilter/inc/rtftok/RTFDocument.hxx b/writerfilter/inc/rtftok/RTFDocument.hxx
index 8b8ad25..72fe6bd 100644
--- a/writerfilter/inc/rtftok/RTFDocument.hxx
+++ b/writerfilter/inc/rtftok/RTFDocument.hxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #ifndef _RTFDOCUMENT_HXX_
 #define _RTFDOCUMENT_HXX_
 
diff --git a/writerfilter/source/rtftok/rtfcharsets.cxx b/writerfilter/source/rtftok/rtfcharsets.cxx
index b44cbfd..96f6feb 100644
--- a/writerfilter/source/rtftok/rtfcharsets.cxx
+++ b/writerfilter/source/rtftok/rtfcharsets.cxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #include <rtftypes.hxx>
 #include <sal/macros.h>
 
diff --git a/writerfilter/source/rtftok/rtfcontrolwords.cxx b/writerfilter/source/rtftok/rtfcontrolwords.cxx
index 805aa17..9034f6f 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.cxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.cxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #include <rtfdocumentimpl.hxx>
 #include <rtftypes.hxx>
 #include <rtfcontrolwords.hxx>
diff --git a/writerfilter/source/rtftok/rtfcontrolwords.hxx b/writerfilter/source/rtftok/rtfcontrolwords.hxx
index 51950a1..a6c3531 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.hxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.hxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #ifndef _RTFCONTROLWORDS_HXX_
 #define _RTFCONTROLWORDS_HXX_
 
diff --git a/writerfilter/source/rtftok/rtfdocumentfactory.cxx b/writerfilter/source/rtftok/rtfdocumentfactory.cxx
index aec4e99..a397565 100644
--- a/writerfilter/source/rtftok/rtfdocumentfactory.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentfactory.cxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #include <rtfdocumentimpl.hxx>
 
 namespace writerfilter {
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 8a1e8c3..2dcd97b 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #include <rtfdocumentimpl.hxx>
 #include <rtftypes.hxx>
 #include <rtfcontrolwords.hxx>
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 12b6940..164e96b 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #ifndef _RTFDOCUMENTIMPL_HXX_
 #define _RTFDOCUMENTIMPL_HXX_
 
diff --git a/writerfilter/source/rtftok/rtfreferenceproperties.cxx b/writerfilter/source/rtftok/rtfreferenceproperties.cxx
index 0387b50..6ca5f1d 100644
--- a/writerfilter/source/rtftok/rtfreferenceproperties.cxx
+++ b/writerfilter/source/rtftok/rtfreferenceproperties.cxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #include <rtfreferenceproperties.hxx>
 #include <rtfsprm.hxx>
 
diff --git a/writerfilter/source/rtftok/rtfreferenceproperties.hxx b/writerfilter/source/rtftok/rtfreferenceproperties.hxx
index f47c2fa..a689e5f 100644
--- a/writerfilter/source/rtftok/rtfreferenceproperties.hxx
+++ b/writerfilter/source/rtftok/rtfreferenceproperties.hxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #ifndef _RTFREFERENCEPROPERTIES_HXX_
 #define _RTFREFERENCEPROPERTIES_HXX_
 
diff --git a/writerfilter/source/rtftok/rtfreferencetable.cxx b/writerfilter/source/rtftok/rtfreferencetable.cxx
index 6ee26a9..9966c68 100644
--- a/writerfilter/source/rtftok/rtfreferencetable.cxx
+++ b/writerfilter/source/rtftok/rtfreferencetable.cxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #include <rtfreferencetable.hxx>
 
 namespace writerfilter {
diff --git a/writerfilter/source/rtftok/rtfreferencetable.hxx b/writerfilter/source/rtftok/rtfreferencetable.hxx
index 5806399..f0e0194 100644
--- a/writerfilter/source/rtftok/rtfreferencetable.hxx
+++ b/writerfilter/source/rtftok/rtfreferencetable.hxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #ifndef _RTFREFERENCETABLE_HXX_
 #define _RTFREFERENCETABLE_HXX_
 
diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx
index a90de22..e5d3e26 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #include <rtfsprm.hxx>
 #include <rtl/strbuf.hxx>
 
diff --git a/writerfilter/source/rtftok/rtfsprm.hxx b/writerfilter/source/rtftok/rtfsprm.hxx
index d59a046..711a5e7 100644
--- a/writerfilter/source/rtftok/rtfsprm.hxx
+++ b/writerfilter/source/rtftok/rtfsprm.hxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #ifndef _RTFSPRM_HXX_
 #define _RTFSPRM_HXX_
 
diff --git a/writerfilter/source/rtftok/rtftypes.hxx b/writerfilter/source/rtftok/rtftypes.hxx
index 0a241fa..3f437f3 100644
--- a/writerfilter/source/rtftok/rtftypes.hxx
+++ b/writerfilter/source/rtftok/rtftypes.hxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #ifndef _RTFTYPES_HXX_
 #define _RTFTYPES_HXX_
 
diff --git a/writerfilter/source/rtftok/rtfvalue.cxx b/writerfilter/source/rtftok/rtfvalue.cxx
index 6d8da26..54fbd6c 100644
--- a/writerfilter/source/rtftok/rtfvalue.cxx
+++ b/writerfilter/source/rtftok/rtfvalue.cxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #include <rtfvalue.hxx>
 #include <rtfreferenceproperties.hxx>
 #include <rtl/strbuf.hxx>
diff --git a/writerfilter/source/rtftok/rtfvalue.hxx b/writerfilter/source/rtftok/rtfvalue.hxx
index 3d528e9..700de71 100644
--- a/writerfilter/source/rtftok/rtfvalue.hxx
+++ b/writerfilter/source/rtftok/rtfvalue.hxx
@@ -1,3 +1,30 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at frugalware.org>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #ifndef _RTFVALUE_HXX_
 #define _RTFVALUE_HXX_
 
commit 1c342b2918593b74488b203315f8ab2e7fa746c7
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 15:48:48 2011 +0200

    implement RTF_REVAUTH, RTF_REVDTTM and RTF_DELETED

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 15b1079..8a1e8c3 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1856,6 +1856,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
             lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
                     NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_start, pIntValue);
             break;
+        case RTF_REVAUTH:
         case RTF_REVAUTHDEL:
             {
                 RTFValue::Pointer_t pValue(new RTFValue(m_aAuthors[nParam]));
@@ -1863,6 +1864,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
                         NS_ooxml::LN_trackchange, NS_ooxml::LN_CT_TrackChange_author, pValue);
             }
             break;
+        case RTF_REVDTTM:
         case RTF_REVDTTMDEL:
             {
                 OUString aStr(OStringToOUString(lcl_DTTM22OString(nParam), m_aStates.top().nCurrentEncoding));
@@ -1964,8 +1966,9 @@ int RTFDocumentImpl::dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam
             m_aStates.top().aParagraphSprms.push_back(make_pair(NS_sprm::LN_PFAutoSpaceDE, pBoolValue));
             break;
         case RTF_DELETED:
+        case RTF_REVISED:
             {
-                RTFValue::Pointer_t pValue(new RTFValue(ooxml::OOXML_del));
+                RTFValue::Pointer_t pValue(new RTFValue(nKeyword == RTF_DELETED ? ooxml::OOXML_del : ooxml::OOXML_ins));
                 lcl_putNestedAttribute(m_aStates.top().aCharacterSprms,
                         NS_ooxml::LN_trackchange, NS_ooxml::LN_token, pValue);
             }
commit 30076c90b9229a79a26eb4810ba7b19ef321d54b
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 15:44:14 2011 +0200

    implement RTF_REVDTTMDEL

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index a986ab6..15b1079 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -130,6 +130,49 @@ static void lcl_TableBreak(Stream& rMapper)
     rMapper.startParagraphGroup();
 }
 
+// NEEDSWORK: DocxAttributeOutput's impl_AppendTwoDigits does the same.
+static void lcl_AppendTwoDigits(OStringBuffer &rBuffer, sal_Int32 nNum)
+{
+    if ( nNum < 0 || nNum > 99 )
+    {
+        rBuffer.append( "00" );
+        return;
+    }
+
+    if ( nNum < 10 )
+        rBuffer.append( '0' );
+
+    rBuffer.append( nNum );
+}
+
+// NEEDSWORK: sw::ms::DTTM2DateTime and DocxAttributeOutput's
+// impl_DateTimeToOString could be combined to do the same.
+static OString lcl_DTTM22OString(long lDTTM)
+{
+    sal_uInt16 lMin = (sal_uInt16)(lDTTM & 0x0000003F);
+    lDTTM >>= 6;
+    sal_uInt16 lHour= (sal_uInt16)(lDTTM & 0x0000001F);
+    lDTTM >>= 5;
+    sal_uInt16 lDay = (sal_uInt16)(lDTTM & 0x0000001F);
+    lDTTM >>= 5;
+    sal_uInt16 lMon = (sal_uInt16)(lDTTM & 0x0000000F);
+    lDTTM >>= 4;
+    sal_uInt16 lYear= (sal_uInt16)(lDTTM & 0x000001FF) + 1900;
+
+    OStringBuffer aBuf;
+    aBuf.append(sal_Int32(lYear));
+    aBuf.append('-');
+    lcl_AppendTwoDigits(aBuf, lMon);
+    aBuf.append('-');
+    lcl_AppendTwoDigits(aBuf, lDay);
+    aBuf.append('T');
+    lcl_AppendTwoDigits(aBuf, lHour);
+    aBuf.append(':');
+    lcl_AppendTwoDigits(aBuf, lMin);
+    aBuf.append(":00Z");
+    return aBuf.makeStringAndClear();
+}
+
 static writerfilter::Reference<Properties>::Pointer_t lcl_getBookmarkProperties(int nPos, OUString& rString)
 {
     RTFSprms_t aAttributes;
@@ -1820,6 +1863,14 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
                         NS_ooxml::LN_trackchange, NS_ooxml::LN_CT_TrackChange_author, pValue);
             }
             break;
+        case RTF_REVDTTMDEL:
+            {
+                OUString aStr(OStringToOUString(lcl_DTTM22OString(nParam), m_aStates.top().nCurrentEncoding));
+                RTFValue::Pointer_t pValue(new RTFValue(aStr));
+                lcl_putNestedAttribute(m_aStates.top().aCharacterSprms,
+                        NS_ooxml::LN_trackchange, NS_ooxml::LN_CT_TrackChange_date, pValue);
+            }
+            break;
         default:
             OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, m_pCurrentKeyword->getStr());
             bParsed = false;
commit a81b22f884b55f90e3b30382828e731f7792bfc9
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 15:18:19 2011 +0200

    implement RTF_DELETED

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 492744b..a986ab6 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -4,9 +4,10 @@
 #include <rtfvalue.hxx>
 #include <rtfsprm.hxx>
 #include <rtfreferenceproperties.hxx>
-#include <doctok/sprmids.hxx> // NS_sprm
-#include <doctok/resourceids.hxx> // NS_rtf
-#include <ooxml/resourceids.hxx> // NS_ooxml
+#include <doctok/sprmids.hxx> // NS_sprm namespace
+#include <doctok/resourceids.hxx> // NS_rtf namespace
+#include <ooxml/resourceids.hxx> // NS_ooxml namespace
+#include <ooxml/OOXMLFastTokens.hxx> // ooxml namespace
 #include <unotools/ucbstreamhelper.hxx>
 #include <rtl/strbuf.hxx>
 #include <rtl/ustrbuf.hxx>
@@ -1812,6 +1813,13 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
             lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
                     NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_start, pIntValue);
             break;
+        case RTF_REVAUTHDEL:
+            {
+                RTFValue::Pointer_t pValue(new RTFValue(m_aAuthors[nParam]));
+                lcl_putNestedAttribute(m_aStates.top().aCharacterSprms,
+                        NS_ooxml::LN_trackchange, NS_ooxml::LN_CT_TrackChange_author, pValue);
+            }
+            break;
         default:
             OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, m_pCurrentKeyword->getStr());
             bParsed = false;
@@ -1904,6 +1912,13 @@ int RTFDocumentImpl::dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam
         case RTF_ASPALPHA:
             m_aStates.top().aParagraphSprms.push_back(make_pair(NS_sprm::LN_PFAutoSpaceDE, pBoolValue));
             break;
+        case RTF_DELETED:
+            {
+                RTFValue::Pointer_t pValue(new RTFValue(ooxml::OOXML_del));
+                lcl_putNestedAttribute(m_aStates.top().aCharacterSprms,
+                        NS_ooxml::LN_trackchange, NS_ooxml::LN_token, pValue);
+            }
+            break;
         default:
             OSL_TRACE("%s: TODO handle toggle '%s'", OSL_THIS_FUNC, m_pCurrentKeyword->getStr());
             bParsed = false;
@@ -2225,6 +2240,17 @@ int RTFDocumentImpl::popState()
         bPicPropEnd = true;
     }
 
+    // See if we need to end a track change
+    RTFValue::Pointer_t pTrackchange = RTFSprm::find(m_aStates.top().aCharacterSprms, NS_ooxml::LN_trackchange);
+    if (pTrackchange.get())
+    {
+        RTFSprms_t aTCAttributes;
+        RTFValue::Pointer_t pValue(new RTFValue(0));
+        aTCAttributes.push_back(make_pair(NS_ooxml::LN_endtrackchange, pValue));
+        writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aTCAttributes));
+        Mapper().props(pProperties);
+    }
+
     // This is the end of the doc, see if we need to close the last section.
     if (m_nGroup == 1)
         sectBreak(true);
commit 5b6d0e385513e05fb4f0fa357bffabebbdd5c541
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 14:52:22 2011 +0200

    parse revtbl

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index f586099..492744b 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -200,7 +200,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
     m_bIsSubstream(false),
     m_nHeaderFooterPositions(),
     m_nGroupStartPos(0),
-    m_aBookmarks()
+    m_aBookmarks(),
+    m_aAuthors()
 {
     OSL_ENSURE(xInputStream.is(), "no input stream");
     if (!xInputStream.is())
@@ -533,6 +534,15 @@ int RTFDocumentImpl::resolveChars(char ch)
         m_aStates.top().aShapeProperties.push_back(make_pair(aOUStr, OUString()));
     else if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYVALUE)
         m_aStates.top().aShapeProperties.back().second += aOUStr;
+    else if (m_aStates.top().nDestinationState == DESTINATION_REVISIONENTRY)
+    {
+        // this is an author name, drop the ; at the end if it's there
+        if (aOUStr.endsWithAsciiL(";", 1))
+        {
+            aOUStr = aOUStr.copy(0, aOUStr.getLength() - 1);
+        }
+        m_aAuthors[m_aAuthors.size()] = aOUStr;
+    }
 
     return 0;
 }
@@ -853,6 +863,9 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
         case RTF_BKMKEND:
             m_aStates.top().nDestinationState = DESTINATION_BOOKMARKEND;
             break;
+        case RTF_REVTBL:
+            m_aStates.top().nDestinationState = DESTINATION_REVISIONTABLE;
+            break;
         case RTF_LISTTEXT:
             // Should be ignored by any reader that understands Word 97 through Word 2007 numbering.
         case RTF_NONESTTABLES:
@@ -2039,6 +2052,8 @@ int RTFDocumentImpl::pushState()
         m_aStates.top().nDestinationState = DESTINATION_STYLEENTRY;
     else if (m_aStates.top().nDestinationState == DESTINATION_FIELDRESULT)
         m_aStates.top().nDestinationState = DESTINATION_NORMAL;
+    else if (m_aStates.top().nDestinationState == DESTINATION_REVISIONTABLE)
+        m_aStates.top().nDestinationState = DESTINATION_REVISIONENTRY;
 
     return 0;
 }
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 8740160..12b6940 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -57,7 +57,9 @@ namespace writerfilter {
             DESTINATION_NESTEDTABLEPROPERTIES,
             DESTINATION_FOOTNOTE,
             DESTINATION_BOOKMARKSTART,
-            DESTINATION_BOOKMARKEND
+            DESTINATION_BOOKMARKEND,
+            DESTINATION_REVISIONTABLE,
+            DESTINATION_REVISIONENTRY
         };
 
         enum RTFBorderState
@@ -268,6 +270,8 @@ namespace writerfilter {
                 rtl::OUString m_aIgnoreFirst;
                 /// Bookmark name <-> index map.
                 std::map<rtl::OUString, int> m_aBookmarks;
+                /// Revision index <-> author map.
+                std::map<int, rtl::OUString> m_aAuthors;
         };
     } // namespace rtftok
 } // namespace writerfilter
commit 37aa6d7b2a838971b221530bda0c76454ccb33ad
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 13:13:27 2011 +0200

    No need to cache field instructions
    
    dmapper can receive them incrementally without problems.

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index e9085b7..f586099 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -494,7 +494,9 @@ int RTFDocumentImpl::resolveChars(char ch)
 
     OUString aOUStr(OStringToOUString(aStr, m_aStates.top().nCurrentEncoding));
 
-    if (m_aStates.top().nDestinationState == DESTINATION_NORMAL || m_aStates.top().nDestinationState == DESTINATION_FIELDRESULT
+    if (m_aStates.top().nDestinationState == DESTINATION_NORMAL
+            || m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION
+            || m_aStates.top().nDestinationState == DESTINATION_FIELDRESULT
             || m_aStates.top().nDestinationState == DESTINATION_LEVELTEXT || m_aStates.top().nDestinationState == DESTINATION_BOOKMARKSTART
             || m_aStates.top().nDestinationState == DESTINATION_BOOKMARKEND)
         text(aOUStr);
@@ -527,8 +529,6 @@ int RTFDocumentImpl::resolveChars(char ch)
         RTFValue::Pointer_t pValue(new RTFValue(aOUStr));
         m_aStates.top().aTableAttributes.push_back(make_pair(NS_rtf::LN_XSTZNAME1, pValue));
     }
-    else if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION)
-        m_aStates.top().aFieldInstruction.append(aStr);
     else if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYNAME)
         m_aStates.top().aShapeProperties.push_back(make_pair(aOUStr, OUString()));
     else if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYVALUE)
@@ -599,13 +599,6 @@ void RTFDocumentImpl::text(OUString& rString)
         return;
     }
 
-    if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION)
-    {
-        sal_uInt8 sFieldStart[] = { 0x13 };
-        Mapper().startCharacterGroup();
-        Mapper().text(sFieldStart, 1);
-        Mapper().endCharacterGroup();
-    }
     if (!m_bTable && !m_bSuper && m_aStates.top().nDestinationState != DESTINATION_FOOTNOTE)
         Mapper().startCharacterGroup();
     else
@@ -654,13 +647,6 @@ void RTFDocumentImpl::text(OUString& rString)
         else
             m_aSuperBuffer.push_back(make_pair(BUFFER_ENDRUN, pValue));
     }
-    if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION)
-    {
-        sal_uInt8 sFieldSep[] = { 0x14 };
-        Mapper().startCharacterGroup();
-        Mapper().text(sFieldSep, 1);
-        Mapper().endCharacterGroup();
-    }
 }
 
 void RTFDocumentImpl::replayBuffer(std::deque<std::pair<RTFBufferTypes, RTFValue::Pointer_t>>& rBuffer)
@@ -724,7 +710,13 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
             // A field consists of an fldinst and an fldrslt group.
             break;
         case RTF_FLDINST:
-            m_aStates.top().nDestinationState = DESTINATION_FIELDINSTRUCTION;
+            {
+                sal_uInt8 sFieldStart[] = { 0x13 };
+                Mapper().startCharacterGroup();
+                Mapper().text(sFieldStart, 1);
+                Mapper().endCharacterGroup();
+                m_aStates.top().nDestinationState = DESTINATION_FIELDINSTRUCTION;
+            }
             break;
         case RTF_FLDRSLT:
             m_aStates.top().nDestinationState = DESTINATION_FIELDRESULT;
@@ -889,6 +881,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
     {
         case RTF_LINE: cCh = '\n'; break;
         case RTF_TAB: cCh = '\t'; break;
+        case RTF_BACKSLASH: cCh = '\\'; break;
         case RTF_EMDASH: cCh = 151; break;
         case RTF_ENDASH: cCh = 150; break;
         case RTF_BULLET: cCh = 149; break;
@@ -928,12 +921,6 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
         case RTF_SECT:
                 sectBreak();
             break;
-        case RTF_BACKSLASH:
-            if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION)
-                m_aStates.top().aFieldInstruction.append('\\');
-            else
-                OSL_TRACE("%s: TODO handle symbol '%s' outside fields", OSL_THIS_FUNC, m_pCurrentKeyword->getStr());
-            break;
         case RTF_NOBREAK:
             {
                 OUString aStr(SVT_HARD_SPACE);
@@ -2163,8 +2150,10 @@ int RTFDocumentImpl::popState()
     }
     else if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION)
     {
-        OUString aOUStr(OStringToOUString(m_aStates.top().aFieldInstruction.makeStringAndClear(), RTL_TEXTENCODING_UTF8));
-        text(aOUStr);
+        sal_uInt8 sFieldSep[] = { 0x14 };
+        Mapper().startCharacterGroup();
+        Mapper().text(sFieldSep, 1);
+        Mapper().endCharacterGroup();
     }
     else if (m_aStates.top().nDestinationState == DESTINATION_FIELDRESULT)
     {
@@ -2407,7 +2396,6 @@ RTFParserState::RTFParserState()
     aStyleTableEntries(),
     nCurrentStyleIndex(0),
     nCurrentEncoding(0),
-    aFieldInstruction(),
     nUc(1),
     nCharsToSkip(0),
     nListLevelNum(0),
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 31b79fb..8740160 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -146,8 +146,6 @@ namespace writerfilter {
 
                 rtl_TextEncoding nCurrentEncoding;
 
-                rtl::OStringBuffer aFieldInstruction;
-
                 /// Current \uc value.
                 int nUc;
                 /// Characters to skip, set to nUc by \u.
commit 74e80f4ca29e0954ad4bb5cbd53492c29afe9f0b
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 12:53:27 2011 +0200

    RTF_LINEX: ignore zero parameter
    
    It appears where line numbering is not enabled.

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 5953668..e9085b7 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1804,8 +1804,9 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
                     NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_countBy, pIntValue);
             break;
         case RTF_LINEX:
-            lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
-                    NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_distance, pIntValue);
+            if (nParam)
+                lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
+                        NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_distance, pIntValue);
             break;
         case RTF_LINESTARTS:
             lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
commit eebefeb17cfca40abe95d04364ea50814bad34db
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 12:47:18 2011 +0200

    handle groups inside fldrslt

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index a9ceba7..5953668 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2046,13 +2046,11 @@ int RTFDocumentImpl::pushState()
     m_nGroup++;
 
     if (m_aStates.top().nDestinationState == DESTINATION_FONTTABLE)
-    {
         m_aStates.top().nDestinationState = DESTINATION_FONTENTRY;
-    }
     else if (m_aStates.top().nDestinationState == DESTINATION_STYLESHEET)
-    {
         m_aStates.top().nDestinationState = DESTINATION_STYLEENTRY;
-    }
+    else if (m_aStates.top().nDestinationState == DESTINATION_FIELDRESULT)
+        m_aStates.top().nDestinationState = DESTINATION_NORMAL;
 
     return 0;
 }
commit 7457573782131d21a27c282d554779aa6df6d83d
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 12:09:50 2011 +0200

    ignore RTF_LISTTEMPLATEID for now

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index f88881a..a9ceba7 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1642,6 +1642,8 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
                 rSprms.push_back(make_pair(NS_sprm::LN_PIlvl, pIntValue));
             }
         case RTF_LISTTEMPLATEID:
+            // This one is not referenced anywhere, so it's pointless to store it at the moment.
+            break;
         case RTF_LISTID:
             {
                 if (m_aStates.top().nDestinationState == DESTINATION_LISTENTRY)
commit 26c515505ce7cd8044f12fa4f3dc903fa266485b
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Jul 1 11:19:08 2011 +0200

    leveltext can be an empty string

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 5d9eb47..f88881a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2179,7 +2179,7 @@ int RTFDocumentImpl::popState()
         // The first character is the length of the string (the rest should be ignored).
         sal_Int32 nLength(aStr.toChar());
         OUString aValue = aStr.copy(1, nLength);
-        RTFValue::Pointer_t pValue(new RTFValue(aValue));
+        RTFValue::Pointer_t pValue(new RTFValue(aValue, true));
         m_aStates.top().aTableAttributes.push_back(make_pair(NS_ooxml::LN_CT_LevelText_val, pValue));
 
         aAttributes = m_aStates.top().aTableAttributes;
diff --git a/writerfilter/source/rtftok/rtfvalue.cxx b/writerfilter/source/rtftok/rtfvalue.cxx
index e969e94..6d8da26 100644
--- a/writerfilter/source/rtftok/rtfvalue.cxx
+++ b/writerfilter/source/rtftok/rtfvalue.cxx
@@ -15,7 +15,8 @@ RTFValue::RTFValue(int nValue, rtl::OUString sValue, RTFSprms_t rAttributes,
     m_sValue(sValue),
     m_rAttributes(rAttributes),
     m_rSprms(rSprms),
-    m_rShape(rShape)
+    m_rShape(rShape),
+    m_bForceString(false)
 {
 }
 
@@ -24,16 +25,18 @@ RTFValue::RTFValue(int nValue)
     m_sValue(),
     m_rAttributes(),
     m_rSprms(),
-    m_rShape()
+    m_rShape(),
+    m_bForceString(false)
 {
 }
 
-RTFValue::RTFValue(OUString sValue)
+RTFValue::RTFValue(OUString sValue, bool bForce)
     : m_nValue(),
     m_sValue(sValue),
     m_rAttributes(),
     m_rSprms(),
-    m_rShape()
+    m_rShape(),
+    m_bForceString(bForce)
 {
 }
 
@@ -42,7 +45,8 @@ RTFValue::RTFValue(RTFSprms_t rAttributes)
     m_sValue(),
     m_rAttributes(rAttributes),
     m_rSprms(),
-    m_rShape()
+    m_rShape(),
+    m_bForceString(false)
 {
 }
 
@@ -51,7 +55,8 @@ RTFValue::RTFValue(RTFSprms_t rAttributes, RTFSprms_t rSprms)
     m_sValue(),
     m_rAttributes(rAttributes),
     m_rSprms(rSprms),
-    m_rShape()
+    m_rShape(),
+    m_bForceString(false)
 {
 }
 
@@ -60,7 +65,8 @@ RTFValue::RTFValue(uno::Reference<drawing::XShape> rShape)
     m_sValue(),
     m_rAttributes(),
     m_rSprms(),
-    m_rShape(rShape)
+    m_rShape(rShape),
+    m_bForceString(false)
 {
 }
 
@@ -71,7 +77,7 @@ int RTFValue::getInt() const
 
 OUString RTFValue::getString() const
 {
-    if (m_sValue.getLength() > 0)
+    if (m_sValue.getLength() > 0 || m_bForceString)
         return m_sValue;
     else
         return OUString::valueOf(sal_Int32(m_nValue));
@@ -85,7 +91,7 @@ void RTFValue::setString(OUString sValue)
 uno::Any RTFValue::getAny() const
 {
     uno::Any ret;
-    if (m_sValue.getLength() > 0)
+    if (m_sValue.getLength() > 0 || m_bForceString)
         ret <<= m_sValue;
     else if (m_rShape.is())
         ret <<= m_rShape;
@@ -114,7 +120,7 @@ writerfilter::Reference<BinaryObj>::Pointer_t RTFValue::getBinary()
 
 std::string RTFValue::toString() const
 {
-    if (m_sValue.getLength() > 0)
+    if (m_sValue.getLength() > 0 || m_bForceString)
         return OUStringToOString(m_sValue, RTL_TEXTENCODING_UTF8).getStr();
     else
         return OString::valueOf(static_cast<sal_Int32>(m_nValue)).getStr();
diff --git a/writerfilter/source/rtftok/rtfvalue.hxx b/writerfilter/source/rtftok/rtfvalue.hxx
index 69f8f67..3d528e9 100644
--- a/writerfilter/source/rtftok/rtfvalue.hxx
+++ b/writerfilter/source/rtftok/rtfvalue.hxx
@@ -17,7 +17,7 @@ namespace writerfilter {
                 RTFValue(int nValue, rtl::OUString sValue, std::vector<std::pair<Id, RTFValue::Pointer_t>> rAttributes,
                         std::vector<std::pair<Id, RTFValue::Pointer_t>> rSprms, uno::Reference<drawing::XShape> rShape);
                 RTFValue(int nValue);
-                RTFValue(rtl::OUString sValue);
+                RTFValue(rtl::OUString sValue, bool bForce = false);
                 RTFValue(std::vector<std::pair<Id, RTFValue::Pointer_t>> rAttributes);
                 RTFValue(std::vector<std::pair<Id, RTFValue::Pointer_t>> rAttributes,
                         std::vector<std::pair<Id, RTFValue::Pointer_t>> rSprms);
@@ -39,6 +39,7 @@ namespace writerfilter {
                 std::vector<std::pair<Id, RTFValue::Pointer_t>> m_rAttributes;
                 std::vector<std::pair<Id, RTFValue::Pointer_t>> m_rSprms;
                 uno::Reference<drawing::XShape> m_rShape;
+                bool m_bForceString;
         };
     } // namespace rtftok
 } // namespace writerfilter
commit 9394997c7f3a15503e1cc14da1eedf697efcf0bb
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Jun 30 16:52:33 2011 +0200

    make sure we are in a paragraph when handling bookmark starts

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index ecd88ec..5d9eb47 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -544,13 +544,6 @@ void RTFDocumentImpl::text(OUString& rString)
         m_aStates.top().aLevelText.append(rString);
         return;
     }
-    else if (m_aStates.top().nDestinationState == DESTINATION_BOOKMARKSTART)
-    {
-        int nPos = m_aBookmarks.size();
-        m_aBookmarks[rString] = nPos;
-        Mapper().props(lcl_getBookmarkProperties(nPos, rString));
-        return;
-    }
     else if (m_aStates.top().nDestinationState == DESTINATION_BOOKMARKEND)
     {
         int nPos = m_aBookmarks[rString];
@@ -598,6 +591,14 @@ void RTFDocumentImpl::text(OUString& rString)
         m_bNeedPap = false;
     }
 
+    if (m_aStates.top().nDestinationState == DESTINATION_BOOKMARKSTART)
+    {
+        int nPos = m_aBookmarks.size();
+        m_aBookmarks[rString] = nPos;
+        Mapper().props(lcl_getBookmarkProperties(nPos, rString));
+        return;
+    }
+
     if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION)
     {
         sal_uInt8 sFieldStart[] = { 0x13 };
commit 4a405737a6d0eb097a3f3b5cbf6f7ad9540ba2b6
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Jun 30 13:10:52 2011 +0200

    asHex: method -> local

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index c603839..ecd88ec 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -149,6 +149,30 @@ static writerfilter::Reference<Properties>::Pointer_t lcl_getBookmarkProperties(
     return lcl_getBookmarkProperties(nPos, aStr);
 }
 
+static int lcl_AsHex(char ch)
+{
+    int ret = 0;
+    if (isdigit(ch))
+        ret = ch - '0';
+    else
+    {
+        if (islower(ch))
+        {
+            if (ch < 'a' || ch > 'f')
+                return -1;
+            ret = ch - 'a';
+        }
+        else
+        {
+            if (ch < 'A' || ch > 'F')
+                return -1;
+            ret = ch - 'A';
+        }
+        ret += 10;
+    }
+    return ret;
+}
+
 RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& xContext,
         uno::Reference<io::XInputStream> const& xInputStream,
         uno::Reference<lang::XComponent> const& xDstDoc,
@@ -336,7 +360,7 @@ int RTFDocumentImpl::resolvePict(char ch, bool bInline)
         if (ch != 0x0d && ch != 0x0a)
         {
             b = b << 4;
-            char parsed = asHex(ch);
+            char parsed = lcl_AsHex(ch);
             if (parsed == -1)
                 return ERROR_HEX_INVALID;
             b += parsed;
@@ -2279,30 +2303,6 @@ void RTFDocumentImpl::resolveShapeProperties(std::vector<std::pair<rtl::OUString
     }
 }
 
-int RTFDocumentImpl::asHex(char ch)
-{
-    int ret = 0;
-    if (isdigit(ch))
-        ret = ch - '0';
-    else
-    {
-        if (islower(ch))
-        {
-            if (ch < 'a' || ch > 'f')
-                return -1;
-            ret = ch - 'a';
-        }
-        else
-        {
-            if (ch < 'A' || ch > 'F')
-                return -1;
-            ret = ch - 'A';
-        }
-        ret += 10;
-    }
-    return ret;
-}
-
 int RTFDocumentImpl::resolveParse()
 {
     OSL_TRACE("%s", OSL_THIS_FUNC);
@@ -2351,7 +2351,7 @@ int RTFDocumentImpl::resolveParse()
                     {
                         OSL_TRACE("%s: hex internal state", OSL_THIS_FUNC);
                         b = b << 4;
-                        char parsed = asHex(ch);
+                        char parsed = lcl_AsHex(ch);
                         if (parsed == -1)
                             return ERROR_HEX_INVALID;
                         b += parsed;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index b7924a9..31b79fb 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -198,7 +198,6 @@ namespace writerfilter {
                 void skipDestination(bool bParsed);
                 RTFSprms_t mergeSprms();
                 RTFSprms_t mergeAttributes();
-                int asHex(char ch);
                 void setSubstream(bool bIsSubtream);
                 void setIgnoreFirst(rtl::OUString& rIgnoreFirst);
                 void resolveSubstream(sal_uInt32 nPos, Id nId);
commit 9e5fa5e5c5b43392ca547707aec5f9d40226525d
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Jun 30 13:00:33 2011 +0200

    NS_rtf::LN_BOOKMARKNAME should be before NS_rtf::LN_IBKL

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index e2ad4f5..c603839 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -129,6 +129,26 @@ static void lcl_TableBreak(Stream& rMapper)
     rMapper.startParagraphGroup();
 }
 
+static writerfilter::Reference<Properties>::Pointer_t lcl_getBookmarkProperties(int nPos, OUString& rString)
+{
+    RTFSprms_t aAttributes;
+    RTFValue::Pointer_t pPos(new RTFValue(nPos));
+    if (rString.getLength())
+    {
+        // If present, this should be sent first.
+        RTFValue::Pointer_t pString(new RTFValue(rString));
+        aAttributes.push_back(make_pair(NS_rtf::LN_BOOKMARKNAME, pString));
+    }
+    aAttributes.push_back(make_pair(NS_rtf::LN_IBKL, pPos));
+    return writerfilter::Reference<Properties>::Pointer_t(new RTFReferenceProperties(aAttributes));
+}
+
+static writerfilter::Reference<Properties>::Pointer_t lcl_getBookmarkProperties(int nPos)
+{
+    OUString aStr;
+    return lcl_getBookmarkProperties(nPos, aStr);
+}
+
 RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& xContext,
         uno::Reference<io::XInputStream> const& xInputStream,
         uno::Reference<lang::XComponent> const& xDstDoc,
@@ -503,28 +523,14 @@ void RTFDocumentImpl::text(OUString& rString)
     else if (m_aStates.top().nDestinationState == DESTINATION_BOOKMARKSTART)
     {
         int nPos = m_aBookmarks.size();
-        OSL_TRACE("debug, pushing bookmark #%d", nPos);
         m_aBookmarks[rString] = nPos;
-
-        RTFSprms_t aAttributes;
-        RTFValue::Pointer_t pPos(new RTFValue(nPos));
-        aAttributes.push_back(make_pair(NS_rtf::LN_IBKL, pPos));
-        RTFValue::Pointer_t pString(new RTFValue(rString));
-        aAttributes.push_back(make_pair(NS_rtf::LN_BOOKMARKNAME, pString));
-        writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes));
-        Mapper().props(pProperties);
+        Mapper().props(lcl_getBookmarkProperties(nPos, rString));
         return;
     }
     else if (m_aStates.top().nDestinationState == DESTINATION_BOOKMARKEND)
     {
         int nPos = m_aBookmarks[rString];
-        OSL_TRACE("debug, looked up bookmark #%d", nPos);
-
-        RTFSprms_t aAttributes;
-        RTFValue::Pointer_t pPos(new RTFValue(nPos));
-        aAttributes.push_back(make_pair(NS_rtf::LN_IBKL, pPos));
-        writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes));
-        Mapper().props(pProperties);
+        Mapper().props(lcl_getBookmarkProperties(nPos));
         return;
     }
     if (m_aIgnoreFirst.getLength() && m_aIgnoreFirst.equals(rString))
commit d6a40afe3dc9ba5e1c2cfbdcf86b55d831140016
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Jun 30 12:48:15 2011 +0200

    RTFReferenceProperties: make second ctor argument optional
    
    Like we have with RTFValue already.

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 9378afd..e2ad4f5 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -511,8 +511,7 @@ void RTFDocumentImpl::text(OUString& rString)
         aAttributes.push_back(make_pair(NS_rtf::LN_IBKL, pPos));
         RTFValue::Pointer_t pString(new RTFValue(rString));
         aAttributes.push_back(make_pair(NS_rtf::LN_BOOKMARKNAME, pString));
-        RTFSprms_t aSprms;
-        writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes, aSprms));
+        writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes));
         Mapper().props(pProperties);
         return;
     }
@@ -524,8 +523,7 @@ void RTFDocumentImpl::text(OUString& rString)
         RTFSprms_t aAttributes;
         RTFValue::Pointer_t pPos(new RTFValue(nPos));
         aAttributes.push_back(make_pair(NS_rtf::LN_IBKL, pPos));
-        RTFSprms_t aSprms;
-        writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes, aSprms));
+        writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes));
         Mapper().props(pProperties);
         return;
     }
@@ -542,8 +540,8 @@ void RTFDocumentImpl::text(OUString& rString)
     if (m_bFirstRun)
     {
         // output settings table
-        RTFSprms_t aDummyAttributes;
-        writerfilter::Reference<Properties>::Pointer_t const pProp(new RTFReferenceProperties(aDummyAttributes, m_aSettingsTableSprms));
+        RTFSprms_t aAttributes;
+        writerfilter::Reference<Properties>::Pointer_t const pProp(new RTFReferenceProperties(aAttributes, m_aSettingsTableSprms));
         RTFReferenceTable::Entries_t aSettingsTableEntries;
         aSettingsTableEntries.insert(make_pair(0, pProp));
         writerfilter::Reference<Table>::Pointer_t const pTable(new RTFReferenceTable(aSettingsTableEntries));
@@ -606,23 +604,14 @@ void RTFDocumentImpl::text(OUString& rString)
         }
     }
     if (!m_bTable && !m_bSuper)
-    {
-        OSL_TRACE("not table or super");
         Mapper().utext(reinterpret_cast<sal_uInt8 const*>(rString.getStr()), rString.getLength());
-    }
     else
     {
         RTFValue::Pointer_t pValue(new RTFValue(rString));
         if (m_bTable)
-        {
-            OSL_TRACE("table");
             m_aTableBuffer.push_back(make_pair(BUFFER_UTEXT, pValue));
-        }
         else
-        {
-            OSL_TRACE("pushing utext to super buffer");
             m_aSuperBuffer.push_back(make_pair(BUFFER_UTEXT, pValue));
-        }
     }
     if (!m_bTable && !m_bSuper && m_aStates.top().nDestinationState != DESTINATION_FOOTNOTE)
         Mapper().endCharacterGroup();
@@ -2094,8 +2083,8 @@ int RTFDocumentImpl::popState()
     }
     else if (m_aStates.top().nDestinationState == DESTINATION_LISTOVERRIDETABLE)
     {
-        RTFSprms_t aDummyAttributes;
-        writerfilter::Reference<Properties>::Pointer_t const pProp(new RTFReferenceProperties(aDummyAttributes, m_aListTableSprms));
+        RTFSprms_t aListTableAttributes;
+        writerfilter::Reference<Properties>::Pointer_t const pProp(new RTFReferenceProperties(aListTableAttributes, m_aListTableSprms));
         RTFReferenceTable::Entries_t aListTableEntries;
         aListTableEntries.insert(make_pair(0, pProp));
         writerfilter::Reference<Table>::Pointer_t const pTable(new RTFReferenceTable(aListTableEntries));
diff --git a/writerfilter/source/rtftok/rtfreferenceproperties.cxx b/writerfilter/source/rtftok/rtfreferenceproperties.cxx
index f170123..0387b50 100644
--- a/writerfilter/source/rtftok/rtfreferenceproperties.cxx
+++ b/writerfilter/source/rtftok/rtfreferenceproperties.cxx
@@ -10,6 +10,12 @@ RTFReferenceProperties::RTFReferenceProperties(RTFSprms_t rAttributes, RTFSprms_
 {
 }
 
+RTFReferenceProperties::RTFReferenceProperties(RTFSprms_t rAttributes)
+    : m_rAttributes(rAttributes),
+    m_rSprms()
+{
+}
+
 RTFReferenceProperties::~RTFReferenceProperties()
 {
 }
diff --git a/writerfilter/source/rtftok/rtfreferenceproperties.hxx b/writerfilter/source/rtftok/rtfreferenceproperties.hxx
index a1418c1..f47c2fa 100644
--- a/writerfilter/source/rtftok/rtfreferenceproperties.hxx
+++ b/writerfilter/source/rtftok/rtfreferenceproperties.hxx
@@ -15,6 +15,7 @@ namespace writerfilter {
         {
             public:
                 RTFReferenceProperties(RTFSprms_t rAttributes, RTFSprms_t rSprms);
+                RTFReferenceProperties(RTFSprms_t rAttributes);
                 virtual ~RTFReferenceProperties();
                 virtual void resolve(Properties & rHandler);
                 virtual std::string getType() const;
commit ff3607cf21833e2b39bf7c0022f476cea2a05da0
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Jun 30 12:43:33 2011 +0200

    implement bookmarks

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 58add90..9378afd 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -155,7 +155,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
     m_bHasFootnote(false),
     m_bIsSubstream(false),
     m_nHeaderFooterPositions(),
-    m_nGroupStartPos(0)
+    m_nGroupStartPos(0),
+    m_aBookmarks()
 {
     OSL_ENSURE(xInputStream.is(), "no input stream");
     if (!xInputStream.is())
@@ -450,7 +451,8 @@ int RTFDocumentImpl::resolveChars(char ch)
     OUString aOUStr(OStringToOUString(aStr, m_aStates.top().nCurrentEncoding));
 
     if (m_aStates.top().nDestinationState == DESTINATION_NORMAL || m_aStates.top().nDestinationState == DESTINATION_FIELDRESULT
-            || m_aStates.top().nDestinationState == DESTINATION_LEVELTEXT)
+            || m_aStates.top().nDestinationState == DESTINATION_LEVELTEXT || m_aStates.top().nDestinationState == DESTINATION_BOOKMARKSTART
+            || m_aStates.top().nDestinationState == DESTINATION_BOOKMARKEND)
         text(aOUStr);
     else if (m_aStates.top().nDestinationState == DESTINATION_FONTENTRY)
     {
@@ -498,6 +500,35 @@ void RTFDocumentImpl::text(OUString& rString)
         m_aStates.top().aLevelText.append(rString);
         return;
     }
+    else if (m_aStates.top().nDestinationState == DESTINATION_BOOKMARKSTART)
+    {
+        int nPos = m_aBookmarks.size();
+        OSL_TRACE("debug, pushing bookmark #%d", nPos);
+        m_aBookmarks[rString] = nPos;
+
+        RTFSprms_t aAttributes;
+        RTFValue::Pointer_t pPos(new RTFValue(nPos));
+        aAttributes.push_back(make_pair(NS_rtf::LN_IBKL, pPos));
+        RTFValue::Pointer_t pString(new RTFValue(rString));
+        aAttributes.push_back(make_pair(NS_rtf::LN_BOOKMARKNAME, pString));
+        RTFSprms_t aSprms;
+        writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes, aSprms));
+        Mapper().props(pProperties);
+        return;
+    }
+    else if (m_aStates.top().nDestinationState == DESTINATION_BOOKMARKEND)
+    {
+        int nPos = m_aBookmarks[rString];
+        OSL_TRACE("debug, looked up bookmark #%d", nPos);
+
+        RTFSprms_t aAttributes;
+        RTFValue::Pointer_t pPos(new RTFValue(nPos));
+        aAttributes.push_back(make_pair(NS_rtf::LN_IBKL, pPos));
+        RTFSprms_t aSprms;
+        writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes, aSprms));
+        Mapper().props(pProperties);
+        return;
+    }
     if (m_aIgnoreFirst.getLength() && m_aIgnoreFirst.equals(rString))
     {
         m_aIgnoreFirst = OUString();
@@ -804,6 +835,12 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
                 m_aStates.top().nDestinationState = DESTINATION_SKIP;
             }
             break;
+        case RTF_BKMKSTART:
+            m_aStates.top().nDestinationState = DESTINATION_BOOKMARKSTART;
+            break;
+        case RTF_BKMKEND:
+            m_aStates.top().nDestinationState = DESTINATION_BOOKMARKEND;
+            break;
         case RTF_LISTTEXT:
             // Should be ignored by any reader that understands Word 97 through Word 2007 numbering.
         case RTF_NONESTTABLES:
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 6af115b..b7924a9 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -55,7 +55,9 @@ namespace writerfilter {
             DESTINATION_SHAPEINSTRUCTION,
             DESTINATION_SHAPEPROPERTYVALUEPICT,
             DESTINATION_NESTEDTABLEPROPERTIES,
-            DESTINATION_FOOTNOTE
+            DESTINATION_FOOTNOTE,
+            DESTINATION_BOOKMARKSTART,
+            DESTINATION_BOOKMARKEND
         };
 
         enum RTFBorderState
@@ -267,6 +269,8 @@ namespace writerfilter {
                 sal_uInt32 m_nGroupStartPos;
                 /// Ignore the first occurrence of this text.
                 rtl::OUString m_aIgnoreFirst;
+                /// Bookmark name <-> index map.
+                std::map<rtl::OUString, int> m_aBookmarks;
         };
     } // namespace rtftok
 } // namespace writerfilter
commit 0a2398f97dc9ff00c810f3bbd869f21bf20c17b1
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Jun 30 10:36:22 2011 +0200

    implement RTF_LINEPPAGE and RTF_LINESTARTS

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index e494d8d..58add90 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1288,9 +1288,10 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
                 m_aStates.top().aCharacterSprms.push_back(make_pair(NS_ooxml::LN_EG_RPrBase_vertAlign, pValue));
             }
             break;
+        case RTF_LINEPPAGE:
         case RTF_LINECONT:
             {
-                RTFValue::Pointer_t pValue(new RTFValue(2));
+                RTFValue::Pointer_t pValue(new RTFValue(nKeyword == RTF_LINEPPAGE ? 0 : 2));
                 lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
                         NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_restart, pValue);
             }
@@ -1747,6 +1748,10 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
             lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
                     NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_distance, pIntValue);
             break;
+        case RTF_LINESTARTS:
+            lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
+                    NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_start, pIntValue);
+            break;
         default:
             OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, m_pCurrentKeyword->getStr());
             bParsed = false;
commit 699d80da8105393d08f5c2eada4200aa1d1ecc36
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Thu Jun 30 10:29:38 2011 +0200

    implement line numbering

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index f3ece1e..e494d8d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1288,6 +1288,13 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
                 m_aStates.top().aCharacterSprms.push_back(make_pair(NS_ooxml::LN_EG_RPrBase_vertAlign, pValue));
             }
             break;
+        case RTF_LINECONT:
+            {
+                RTFValue::Pointer_t pValue(new RTFValue(2));
+                lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
+                        NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_restart, pValue);
+            }
+            break;
         default:
             OSL_TRACE("%s: TODO handle flag '%s'", OSL_THIS_FUNC, m_pCurrentKeyword->getStr());
             bParsed = false;
@@ -1732,6 +1739,14 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
         case RTF_DEFTAB:
             m_aSettingsTableSprms.push_back(make_pair(NS_ooxml::LN_CT_Settings_defaultTabStop, pIntValue));
             break;
+        case RTF_LINEMOD:
+            lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
+                    NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_countBy, pIntValue);
+            break;
+        case RTF_LINEX:
+            lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
+                    NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_distance, pIntValue);
+            break;
         default:
             OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, m_pCurrentKeyword->getStr());
             bParsed = false;
commit 2590ab89fa943209c2139cacfe08d00ba3ffda37
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Wed Jun 29 17:38:12 2011 +0200

    add support for endnotes

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 53933f0..f3ece1e 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -760,6 +760,20 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
         case RTF_FOOTNOTE:
             if (!m_bIsSubstream)
             {
+                Id nId = NS_rtf::LN_footnote;
+
+                // Check if this is an endnote.
+                OStringBuffer aBuf;
+                char ch;
+                for (int i = 0; i < 7; ++i)
+                {
+                    Strm() >> ch;
+                    aBuf.append(ch);
+                }
+                OString aKeyword = aBuf.makeStringAndClear();
+                if (aKeyword.equals("\\ftnalt"))
+                    nId = NS_rtf::LN_endnote;
+
                 m_bHasFootnote = true;
                 m_bSuper = false;
                 bool bCustomMark = false;
@@ -777,7 +791,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
                 m_aStates.top().nDestinationState = DESTINATION_FOOTNOTE;
                 if (bCustomMark)
                     Mapper().startCharacterGroup();
-                resolveSubstream(m_nGroupStartPos - 1, NS_rtf::LN_footnote, aCustomMark);
+                resolveSubstream(m_nGroupStartPos - 1, nId, aCustomMark);
                 if (bCustomMark)
                 {
                     m_aStates.top().aCharacterAttributes.clear();
commit 921fe88fcfe60d99ddeda7c48e4e6f1125e27f57
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Wed Jun 29 12:57:53 2011 +0200

    RTF_FOOTNOTE: support custom marks

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 76d13bf..53933f0 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -150,6 +150,9 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
     m_xStorage(),
     m_aTableBuffer(),
     m_bTable(false),
+    m_aSuperBuffer(),
+    m_bSuper(false),
+    m_bHasFootnote(false),
     m_bIsSubstream(false),
     m_nHeaderFooterPositions(),
     m_nGroupStartPos(0)
@@ -184,12 +187,23 @@ void RTFDocumentImpl::setSubstream(bool bIsSubtream)
     m_bIsSubstream = bIsSubtream;
 }
 
-void RTFDocumentImpl::resolveSubstream(sal_uInt32& nPos, Id nId)
+void RTFDocumentImpl::setIgnoreFirst(OUString& rIgnoreFirst)
+{
+    m_aIgnoreFirst = rIgnoreFirst;
+}
+
+void RTFDocumentImpl::resolveSubstream(sal_uInt32 nPos, Id nId)
+{
+    OUString aStr;
+    resolveSubstream(nPos, nId, aStr);
+}
+void RTFDocumentImpl::resolveSubstream(sal_uInt32 nPos, Id nId, OUString& rIgnoreFirst)
 {
     sal_uInt32 nCurrent = Strm().Tell();
     // Seek to header position, parse, then seek back.
     RTFDocumentImpl::Pointer_t pImpl(new RTFDocumentImpl(m_xContext, m_xInputStream, m_xDstDoc, m_xFrame));
     pImpl->setSubstream(true);
+    pImpl->setIgnoreFirst(rIgnoreFirst);
     pImpl->seek(nPos);
     OSL_TRACE("substream start");
     Mapper().substream(nId, pImpl);
@@ -484,6 +498,11 @@ void RTFDocumentImpl::text(OUString& rString)
         m_aStates.top().aLevelText.append(rString);
         return;
     }
+    if (m_aIgnoreFirst.getLength() && m_aIgnoreFirst.equals(rString))
+    {
+        m_aIgnoreFirst = OUString();
+        return;
+    }
 
     writerfilter::Reference<Properties>::Pointer_t const pParagraphProperties(
             new RTFReferenceProperties(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms)
@@ -507,12 +526,15 @@ void RTFDocumentImpl::text(OUString& rString)
     }
     if (m_bNeedPap)
     {
-        if (!m_bTable)
+        if (!m_bTable && !m_bSuper)
             Mapper().props(pParagraphProperties);
         else
         {
             RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms));
-            m_aTableBuffer.push_back(make_pair(BUFFER_PROPS, pValue));
+            if (m_bTable)
+                m_aTableBuffer.push_back(make_pair(BUFFER_PROPS, pValue));
+            else
+                m_aSuperBuffer.push_back(make_pair(BUFFER_PROPS, pValue));
         }
         m_bNeedPap = false;
     }
@@ -524,16 +546,19 @@ void RTFDocumentImpl::text(OUString& rString)
         Mapper().text(sFieldStart, 1);
         Mapper().endCharacterGroup();
     }
-    if (!m_bTable)
+    if (!m_bTable && !m_bSuper && m_aStates.top().nDestinationState != DESTINATION_FOOTNOTE)
         Mapper().startCharacterGroup();
     else
     {
         RTFValue::Pointer_t pValue;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list