[Libreoffice-commits] .: writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Aug 28 04:03:55 PDT 2012


 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   16 ++++---------
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    4 ---
 writerfilter/source/rtftok/rtftokenizer.cxx    |   30 +++++++++++++++++++------
 writerfilter/source/rtftok/rtftokenizer.hxx    |    8 ++++++
 4 files changed, 36 insertions(+), 22 deletions(-)

New commits:
commit b6c18e3bc78724e65c78577c6e513f894c4e93b4
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Tue Aug 28 12:57:55 2012 +0200

    Move group handling from RTFDocumentImpl to RTFTokenizer
    
    This is one step towards hiding the RTFDocument implementation from
    RTFTokenizer.
    
    Change-Id: Ief35a2440cac3147495675d344e1efc64f5fbc2e

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 330c34d..bd72dd6 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -232,7 +232,6 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
     m_xDstDoc(xDstDoc),
     m_xFrame(xFrame),
     m_xStatusIndicator(xStatusIndicator),
-    m_nGroup(0),
     m_aDefaultState(this),
     m_bSkipUnknown(false),
     m_aFontEncodings(),
@@ -3203,7 +3202,7 @@ int RTFDocumentImpl::dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam
 
 int RTFDocumentImpl::pushState()
 {
-    //SAL_INFO("writerfilter", OSL_THIS_FUNC << " before push: " << m_nGroup);
+    //SAL_INFO("writerfilter", OSL_THIS_FUNC << " before push: " << m_pTokenizer->getGroup());
 
     checkUnicode();
     m_nGroupStartPos = Strm().Tell();
@@ -3219,7 +3218,7 @@ int RTFDocumentImpl::pushState()
     m_aStates.push(aState);
     m_aStates.top().aDestinationText.setLength(0);
 
-    m_nGroup++;
+    m_pTokenizer->pushGroup();
 
     switch (m_aStates.top().nDestinationState)
     {
@@ -3297,7 +3296,7 @@ void RTFDocumentImpl::resetAttributes()
 
 int RTFDocumentImpl::popState()
 {
-    //SAL_INFO("writerfilter", OSL_THIS_FUNC << " before pop: m_nGroup " << m_nGroup <<
+    //SAL_INFO("writerfilter", OSL_THIS_FUNC << " before pop: m_pTokenizer->getGroup() " << m_pTokenizer->getGroup() <<
     //                         ", dest state: " << m_aStates.top().nDestinationState);
 
     checkUnicode();
@@ -3756,7 +3755,7 @@ int RTFDocumentImpl::popState()
     }
 
     // This is the end of the doc, see if we need to close the last section.
-    if (m_nGroup == 1 && !m_bFirstRun)
+    if (m_pTokenizer->getGroup() == 1 && !m_bFirstRun)
     {
         m_bDeferredContSectBreak = false;
         sectBreak(true);
@@ -3764,7 +3763,7 @@ int RTFDocumentImpl::popState()
 
     m_aStates.pop();
 
-    m_nGroup--;
+    m_pTokenizer->popGroup();
 
     // list table
     if (aState.nDestinationState == DESTINATION_LISTENTRY)
@@ -3935,11 +3934,6 @@ RTFParserState& RTFDocumentImpl::getState()
     return m_aStates.top();
 }
 
-int RTFDocumentImpl::getGroup() const
-{
-    return m_nGroup;
-}
-
 void RTFDocumentImpl::setDestinationText(OUString& rString)
 {
     m_aStates.top().aDestinationText.setLength(0);
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index e3120b7..e2a5aa6 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -424,8 +424,6 @@ namespace writerfilter {
                 void seek(sal_uInt32 nPos);
                 uno::Reference<lang::XMultiServiceFactory> getModelFactory();
                 RTFParserState& getState();
-                /// Number of states on the stack.
-                int getGroup() const;
                 void setDestinationText(rtl::OUString& rString);
                 /// Resolve a picture: If not inline, then anchored.
                 int resolvePict(bool bInline);
@@ -493,8 +491,6 @@ namespace writerfilter {
                 Stream* m_pMapperStream;
                 boost::shared_ptr<RTFSdrImport> m_pSdrImport;
                 boost::shared_ptr<RTFTokenizer> m_pTokenizer;
-                /// Same as m_aStates.size(), except that this can be negative for invalid input.
-                int m_nGroup;
                 std::stack<RTFParserState> m_aStates;
                 /// Read by RTF_PARD.
                 RTFParserState m_aDefaultState;
diff --git a/writerfilter/source/rtftok/rtftokenizer.cxx b/writerfilter/source/rtftok/rtftokenizer.cxx
index abe8cff..3e7a750 100644
--- a/writerfilter/source/rtftok/rtftokenizer.cxx
+++ b/writerfilter/source/rtftok/rtftokenizer.cxx
@@ -46,7 +46,8 @@ RTFTokenizer::RTFTokenizer(RTFDocumentImpl& rImport, SvStream* pInStream, uno::R
     : m_rImport(rImport),
     m_pInStream(pInStream),
     m_xStatusIndicator(xStatusIndicator),
-    m_aRTFControlWords(std::vector<RTFSymbol>(aRTFControlWords, aRTFControlWords + nRTFControlWords))
+    m_aRTFControlWords(std::vector<RTFSymbol>(aRTFControlWords, aRTFControlWords + nRTFControlWords)),
+    m_nGroup(0)
 {
     std::sort(m_aRTFControlWords.begin(), m_aRTFControlWords.end());
 }
@@ -93,9 +94,9 @@ int RTFTokenizer::resolveParse()
         if (m_xStatusIndicator.is() && (nCurrentPos = Strm().Tell()) > (nLastPos + nPercentSize))
             m_xStatusIndicator->setValue(nLastPos = nCurrentPos);
 
-        if (m_rImport.getGroup() < 0)
+        if (m_nGroup < 0)
             return ERROR_GROUP_UNDER;
-        if (m_rImport.getGroup() > 0 && m_rImport.getState().nInternalState == INTERNAL_BIN)
+        if (m_nGroup > 0 && m_rImport.getState().nInternalState == INTERNAL_BIN)
         {
             ret = m_rImport.resolveChars(ch);
             if (ret)
@@ -114,7 +115,7 @@ int RTFTokenizer::resolveParse()
                     ret = m_rImport.popState();
                     if (ret)
                         return ret;
-                    if (m_rImport.getGroup() == 0)
+                    if (m_nGroup == 0)
                     {
                         if (m_rImport.isSubstream())
                             m_rImport.finishSubstream();
@@ -130,7 +131,7 @@ int RTFTokenizer::resolveParse()
                 case 0x0a:
                     break; // ignore these
                 default:
-                    if (m_rImport.getGroup() == 0)
+                    if (m_nGroup == 0)
                         return ERROR_CHAR_OVER;
                     if (m_rImport.getState().nInternalState == INTERNAL_NORMAL)
                     {
@@ -162,9 +163,9 @@ int RTFTokenizer::resolveParse()
         }
     }
 
-    if (m_rImport.getGroup() < 0)
+    if (m_nGroup < 0)
         return ERROR_GROUP_UNDER;
-    else if (m_rImport.getGroup() > 0)
+    else if (m_nGroup > 0)
         return ERROR_GROUP_OVER;
     return 0;
 }
@@ -193,6 +194,21 @@ int RTFTokenizer::asHex(char ch)
     return ret;
 }
 
+int RTFTokenizer::getGroup() const
+{
+    return m_nGroup;
+}
+
+void RTFTokenizer::pushGroup()
+{
+    m_nGroup++;
+}
+
+void RTFTokenizer::popGroup()
+{
+    m_nGroup--;
+}
+
 int RTFTokenizer::resolveKeyword()
 {
     char ch;
diff --git a/writerfilter/source/rtftok/rtftokenizer.hxx b/writerfilter/source/rtftok/rtftokenizer.hxx
index bcaafda..2fd06ae 100644
--- a/writerfilter/source/rtftok/rtftokenizer.hxx
+++ b/writerfilter/source/rtftok/rtftokenizer.hxx
@@ -43,6 +43,12 @@ namespace writerfilter {
 
                 int resolveParse();
                 int asHex(char ch);
+                /// Number of states on the stack.
+                int getGroup() const;
+                /// To be invoked by the pushState() callback to signal when the importer enters a group.
+                void pushGroup();
+                /// To be invoked by the popState() callback to single when the importer leaves a group.
+                void popGroup();
             private:
                 SvStream& Strm();
                 int resolveKeyword();
@@ -53,6 +59,8 @@ namespace writerfilter {
                 uno::Reference<task::XStatusIndicator> const& m_xStatusIndicator;
                 // This is the same as m_aRTFControlWords, but sorted
                 std::vector<RTFSymbol> m_aRTFControlWords;
+                /// Same as the size of the importer's states, except that this can be negative for invalid input.
+                int m_nGroup;
         };
     } // namespace rtftok
 } // namespace writerfilter


More information about the Libreoffice-commits mailing list