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

Miklos Vajna vmiklos at kemper.freedesktop.org
Fri Aug 19 08:20:28 PDT 2011


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

New commits:
commit 49f5d94f40fddae3d34a8f330965719f8f64eb04
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Aug 19 16:06:27 2011 +0200

    pictures in fly frames are already handled

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index e46c1b9..e9d2efa 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1032,6 +1032,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
             m_aStates.top().nDestinationState = DESTINATION_LEVELNUMBERS;
             break;
         case RTF_SHPPICT:
+            m_aStates.top().aFrame = RTFFrame();
             m_aStates.top().nDestinationState = DESTINATION_SHPPICT;
             break;
         case RTF_PICT:
@@ -2992,7 +2993,8 @@ int RTFDocumentImpl::popState()
         aSprms = m_aStates.top().aTableSprms;
         bFaltEnd = true;
     }
-    else if (m_aStates.top().nDestinationState == DESTINATION_FLYMAINCONTENT)
+    else if (m_aStates.top().nDestinationState == DESTINATION_FLYMAINCONTENT
+            || m_aStates.top().nDestinationState == DESTINATION_SHPPICT)
     {
         aFrame = m_aStates.top().aFrame;
         bPopFrame = true;
commit 8807969ef37ed9b4ff0d3f259802982e49b55805
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Aug 19 15:10:03 2011 +0200

    a pard between two frame definitions means two frames

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index da82ede..e46c1b9 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1632,6 +1632,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
             m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms;
             m_aStates.top().aParagraphAttributes = m_aDefaultState.aParagraphAttributes;
             m_aStates.top().aFrame = RTFFrame();
+            checkChangedFrame();
             m_pCurrentBuffer = 0;
             break;
         case RTF_SECTD:
commit 72d09b8a1c7a5fd6cf14517efba273c53aa87837
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Aug 19 14:45:57 2011 +0200

    paragraphs inside frames do not count

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 02f5d79..da82ede 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1299,7 +1299,8 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
                 // but don't emit properties yet, since they may change till the first text token arrives
                 m_bNeedPap = true;
                 m_bWasInFrame = inFrame();
-                m_bNeedPar = false;
+                if (!m_bWasInFrame)
+                    m_bNeedPar = false;
             }
             break;
         case RTF_SECT:
commit c9bdee0b19174214bfbc04a944ff8266b0303351
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Aug 19 13:08:13 2011 +0200

    handle sections containing no paragraphs

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 214f0cd..02f5d79 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -271,6 +271,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
     m_bFirstRow(true),
     m_bNeedPap(false),
     m_bNeedCr(false),
+    m_bNeedPar(true),
     m_aListTableSprms(),
     m_aSettingsTableSprms(),
     m_xStorage(),
@@ -440,6 +441,9 @@ void RTFDocumentImpl::parBreak()
 
 void RTFDocumentImpl::sectBreak(bool bFinal = false)
 {
+    // If there is no paragraph in this section, then insert a dummy one, as required by Writer
+    if (m_bNeedPar)
+        dispatchSymbol(RTF_PAR);
     checkChangedFrame();
     while (m_nHeaderFooterPositions.size())
     {
@@ -471,6 +475,7 @@ void RTFDocumentImpl::sectBreak(bool bFinal = false)
         Mapper().startSectionGroup();
         Mapper().startParagraphGroup();
     }
+    m_bNeedPar = true;
 }
 
 void RTFDocumentImpl::seek(sal_uInt32 nPos)
@@ -1294,6 +1299,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
                 // but don't emit properties yet, since they may change till the first text token arrives
                 m_bNeedPap = true;
                 m_bWasInFrame = inFrame();
+                m_bNeedPar = false;
             }
             break;
         case RTF_SECT:
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index e10c727..d48b049 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -371,6 +371,8 @@ namespace writerfilter {
                 bool m_bNeedPap;
                 /// If we need to emit a CR at the end of substream.
                 bool m_bNeedCr;
+                /// If we need to add a dummy paragraph before a section break.
+                bool m_bNeedPar;
                 /// The list table and list override table combined.
                 RTFSprms m_aListTableSprms;
                 /// The settings table.
commit 82336dbc53a9e88e6e97e4d6653e132633a4fdec
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Aug 19 12:25:41 2011 +0200

    multiple sections in a frame are not allowed

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 362ed11..214f0cd 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -440,6 +440,7 @@ void RTFDocumentImpl::parBreak()
 
 void RTFDocumentImpl::sectBreak(bool bFinal = false)
 {
+    checkChangedFrame();
     while (m_nHeaderFooterPositions.size())
     {
         std::pair<Id, sal_uInt32> aPair = m_nHeaderFooterPositions.front();
commit 4dd70db964fb691af07cdbdea9dc36a4803f7e65
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Aug 19 12:01:06 2011 +0200

    make sure frame props are always emitted

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index fa9ac86..362ed11 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1960,6 +1960,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
     }
     if (pSprm)
     {
+        m_bNeedPap = true;
         *pSprm = TWIP_TO_MM100(nParam);
         return 0;
     }
commit 6229149a1bd6ada0ff952d86f6b346b8b2fd07ce
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Fri Aug 19 11:57:54 2011 +0200

    have the twip->mm100 conversion code for frame props at a single place

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index f0743dd..fa9ac86 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -717,6 +717,7 @@ void RTFDocumentImpl::checkChangedFrame()
     // Check if this is a frame.
     if (inFrame() && !m_bWasInFrame)
     {
+        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);
         uno::Reference<drawing::XShape> xShape(xTextFrame, uno::UNO_QUERY);
@@ -745,6 +746,7 @@ void RTFDocumentImpl::checkChangedFrame()
     }
     else if (!inFrame() && m_bWasInFrame)
     {
+        OSL_TRACE("%s ending frame", OSL_THIS_FUNC);
         Mapper().endParagraphGroup();
         Mapper().endShape();
         Mapper().endParagraphGroup();
@@ -1946,6 +1948,22 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
     if (nSprm > 0)
         return 0;
 
+    // Frame size / position.
+    int *pSprm = 0;
+    switch (nKeyword)
+    {
+        case RTF_ABSW: pSprm = &m_aStates.top().aFrame.nW; break;
+        case RTF_ABSH: pSprm = &m_aStates.top().aFrame.nH; break;
+        case RTF_POSX: pSprm = &m_aStates.top().aFrame.nX; m_aStates.top().aFrame.nHoriOrient = text::HoriOrientation::NONE; break;
+        case RTF_POSY: pSprm = &m_aStates.top().aFrame.nY; m_aStates.top().aFrame.nVertOrient = text::VertOrientation::NONE; break;
+        default: break;
+    }
+    if (pSprm)
+    {
+        *pSprm = TWIP_TO_MM100(nParam);
+        return 0;
+    }
+
     // Then check for the more complex ones.
     switch (nKeyword)
     {
@@ -2418,20 +2436,6 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
         case RTF_AFTNSTART:
             lcl_putNestedSprm(m_aDefaultState.aParagraphSprms, NS_ooxml::LN_EG_SectPrContents_endnotePr, NS_ooxml::LN_EG_FtnEdnNumProps_numStart, pIntValue);
             break;
-        case RTF_ABSW:
-            m_aStates.top().aFrame.nW = TWIP_TO_MM100(nParam);
-            break;
-        case RTF_ABSH:
-            m_aStates.top().aFrame.nH = TWIP_TO_MM100(nParam);
-            break;
-        case RTF_POSX:
-            m_aStates.top().aFrame.nHoriOrient = text::HoriOrientation::NONE;
-            m_aStates.top().aFrame.nX = TWIP_TO_MM100(nParam);
-            break;
-        case RTF_POSY:
-            m_aStates.top().aFrame.nVertOrient = text::VertOrientation::NONE;
-            m_aStates.top().aFrame.nY = TWIP_TO_MM100(nParam);
-            break;
         case RTF_DFRMTXTX:
             m_aStates.top().aFrame.nLeftMargin = m_aStates.top().aFrame.nRightMargin = TWIP_TO_MM100(nParam);
             break;


More information about the Libreoffice-commits mailing list