[Libreoffice-commits] .: 3 commits - writerfilter/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Mon Aug 22 09:23:50 PDT 2011


 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   15 +++++++++++++--
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    4 +++-
 2 files changed, 16 insertions(+), 3 deletions(-)

New commits:
commit a789d8a487c2bcc9687e859337b6d6a1b6bbf8bc
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Mon Aug 22 18:21:31 2011 +0200

    Implement RTF_ANSICPG

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index b6ceeed..0fef1e8 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2020,6 +2020,9 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
                 m_aFontEncodings[m_nCurrentFontIndex] = rtl_getTextEncodingFromWindowsCodePage(aRTFEncodings[i].codepage);
             }
             break;
+        case RTF_ANSICPG:
+            m_aStates.top().nCurrentEncoding = rtl_getTextEncodingFromWindowsCodePage(nParam);
+            break;
         case RTF_CF:
             {
                 // NS_sprm::LN_CIco won't work, that would be an index in a static table
commit ea190eaa0459c3cca3c242d45ca386db8188d047
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Mon Aug 22 17:40:34 2011 +0200

    Make frame start/end a bit more robust
    
    Don't try to start a started frame, don't try to end a not started
    frame.

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 9aa9a26..b6ceeed 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -296,7 +296,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
     m_aStyleTableEntries(),
     m_nCurrentStyleIndex(0),
     m_bEq(false),
-    m_bWasInFrame(false)
+    m_bWasInFrame(false),
+    m_bIsInShape(false)
 {
     OSL_ASSERT(xInputStream.is());
     m_pInStream = utl::UcbStreamHelper::CreateStream(xInputStream, sal_True);
@@ -723,6 +724,8 @@ void RTFDocumentImpl::checkChangedFrame()
     // Check if this is a frame.
     if (inFrame() && !m_bWasInFrame)
     {
+        if (m_bIsInShape)
+            return;
         OSL_TRACE("%s starting frame", OSL_THIS_FUNC);
         uno::Reference<text::XTextFrame> xTextFrame;
         xTextFrame.set(getModelFactory()->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))), uno::UNO_QUERY);
@@ -749,16 +752,20 @@ void RTFDocumentImpl::checkChangedFrame()
 
         Mapper().startShape(xShape);
         Mapper().startParagraphGroup();
+        m_bIsInShape = true;
     }
     else if (!inFrame() && m_bWasInFrame)
     {
+        if (!m_bIsInShape)
+            return;
         OSL_TRACE("%s ending frame", OSL_THIS_FUNC);
         finishSubstream();
         Mapper().endParagraphGroup();
         Mapper().endShape();
         Mapper().endParagraphGroup();
         Mapper().startParagraphGroup();
-        m_bWasInFrame = false;
+        m_bWasInFrame = false; // this is needed by invalid nested flies where the result is separate frames
+        m_bIsInShape = false;
     }
 }
 
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index d48b049..aee3f79 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -421,8 +421,10 @@ namespace writerfilter {
                 RTFReferenceTable::Entries_t m_aStyleTableEntries;
                 int m_nCurrentStyleIndex;
                 bool m_bEq;
-                /// If we are in a frame.
+                /// If we were in a frame.
                 bool m_bWasInFrame;
+                /// If a shape is already started (nesting them is not OK).
+                bool m_bIsInShape;
 
         };
     } // namespace rtftok
commit b50403171cfea3d9eff7c4b7505cf0212291d967
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Mon Aug 22 16:46:35 2011 +0200

    Make sure runs are closed before we end a frame

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 1bd9d54..9aa9a26 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -753,6 +753,7 @@ void RTFDocumentImpl::checkChangedFrame()
     else if (!inFrame() && m_bWasInFrame)
     {
         OSL_TRACE("%s ending frame", OSL_THIS_FUNC);
+        finishSubstream();
         Mapper().endParagraphGroup();
         Mapper().endShape();
         Mapper().endParagraphGroup();


More information about the Libreoffice-commits mailing list