[Libreoffice-commits] core.git: Branch 'distro/suse/suse-4.0' - sw/qa writerfilter/source

Miklos Vajna vmiklos at suse.cz
Tue May 21 08:57:50 PDT 2013


 sw/qa/extras/rtfimport/data/n818997.rtf           |   77 ++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx              |    8 ++
 writerfilter/source/dmapper/DomainMapper.cxx      |   13 +++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   15 ++++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    1 
 writerfilter/source/rtftok/rtfdocumentimpl.cxx    |    4 +
 writerfilter/source/rtftok/rtfdocumentimpl.hxx    |    2 
 7 files changed, 120 insertions(+)

New commits:
commit 5177c2d7a970bf1cdefed8a068e1069a83a34396
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Tue May 21 14:56:45 2013 +0200

    bnc#818997 RTF import: don't ignore page breaks between shapes
    
    Change-Id: Ief71ba9a3c60356714e73d08e88d0a3105b17b1a
    (cherry picked from commit b40fe8e5a5037d2745cc7b1c9cc408ce6c79b9d9)
    
    Conflicts:
    	sw/qa/extras/rtfimport/rtfimport.cxx
    	writerfilter/source/dmapper/DomainMapper.cxx
    	writerfilter/source/rtftok/rtfdocumentimpl.cxx

diff --git a/sw/qa/extras/rtfimport/data/n818997.rtf b/sw/qa/extras/rtfimport/data/n818997.rtf
new file mode 100644
index 0000000..2ce4404
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/n818997.rtf
@@ -0,0 +1,77 @@
+{\rtf 
+{\shp 
+{\*\shpinst\shpleft2310\shpright6060\shptop8685\shpbottom8985\shpbxpage
+\shpbypage\shpwr3\shpz2 
+{\sp 
+{\sn shapeType}
+{\sv 202}
+}
+{\sp 
+{\sn dxTextLeft}
+{\sv 
+0}
+}
+{\sp 
+{\sn dxTextRight}
+{\sv 0}
+}
+{\sp 
+{\sn dyTextTop}
+{\sv 0}
+}
+{\sp 
+{\sn 
+dyTextBottom}
+{\sv 0}
+}
+{\sp 
+{\sn fLine}
+{\sv 0}
+}
+{\shptxt\plain\pard\f29\fs24 
+On first page.\par}
+{\sp 
+{\sn fFilled}
+{\sv 0}
+}
+}
+}
+\page
+{\shp 
+{\*\shpinst\shpleft4800\shpright8025\shptop780\shpbottom1080\shpbxpage
+\shpbypage\shpwr3\shpz2 
+{\sp 
+{\sn shapeType}
+{\sv 202}
+}
+{\sp 
+{\sn dxTextLeft}
+{\sv 
+0}
+}
+{\sp 
+{\sn dxTextRight}
+{\sv 0}
+}
+{\sp 
+{\sn dyTextTop}
+{\sv 0}
+}
+{\sp 
+{\sn 
+dyTextBottom}
+{\sv 0}
+}
+{\sp 
+{\sn fLine}
+{\sv 0}
+}
+{\shptxt\plain\pard\f29\fs24\b 
+On second page.\par}
+{\sp 
+{\sn fFilled}
+{\sv 0}
+}
+}
+}
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index c02dac5..a22159d 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -147,6 +147,7 @@ public:
     void testFdo51916();
     void testFdo61193();
     void testFdo63023();
+    void testN818997();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -264,6 +265,7 @@ void Test::run()
         {"fdo51916.rtf", &Test::testFdo51916},
         {"hello.rtf", &Test::testFdo61193},
         {"fdo63023.rtf", &Test::testFdo63023},
+        {"n818997.rtf", &Test::testN818997},
     };
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
     {
@@ -1214,6 +1216,12 @@ void Test::testFdo63023()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFF99), getProperty<sal_Int32>(getRun(getParagraphOfText(1, xHeaderText), 1), "CharBackColor"));
 }
 
+void Test::testN818997()
+{
+    // \page was ignored between two \shp tokens.
+    CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 0e10907..66b1e6c 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3462,6 +3462,19 @@ void DomainMapper::markLastParagraphInSection( )
 
 void DomainMapper::lcl_startShape( uno::Reference< drawing::XShape > xShape )
 {
+    // If there is a deferred page break, handle it now, so that the
+    // started shape will be on the correct page.
+    if (m_pImpl->isBreakDeferred(PAGE_BREAK))
+    {
+        m_pImpl->clearDeferredBreak(PAGE_BREAK);
+        lcl_startCharacterGroup();
+        sal_uInt8 sBreak[] = { 0xd };
+        lcl_text(sBreak, 1);
+        lcl_endCharacterGroup();
+        lcl_endParagraphGroup();
+        lcl_startParagraphGroup();
+        m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, true, uno::makeAny( com::sun::star::style::BreakType_PAGE_BEFORE));
+    }
     m_pImpl->PushShapeContext( xShape );
     lcl_startParagraphGroup();
 }
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 55ae949..94a535f 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -648,6 +648,21 @@ bool DomainMapper_Impl::isBreakDeferred( BreakType deferredBreakType )
     }
 }
 
+void DomainMapper_Impl::clearDeferredBreak(BreakType deferredBreakType)
+{
+    switch (deferredBreakType)
+    {
+    case COLUMN_BREAK:
+        m_bIsColumnBreakDeferred = false;
+        break;
+    case PAGE_BREAK:
+        m_bIsPageBreakDeferred = false;
+        break;
+    default:
+        break;
+    }
+}
+
 void DomainMapper_Impl::clearDeferredBreaks()
 {
     m_bIsColumnBreakDeferred = false;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 769636d..8d513bb 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -445,6 +445,7 @@ public:
     void deferBreak( BreakType deferredBreakType );
     bool isBreakDeferred( BreakType deferredBreakType );
     void clearDeferredBreaks();
+    void clearDeferredBreak(BreakType deferredBreakType);
     void finishParagraph( PropertyMapPtr pPropertyMap );
     void appendTextPortion( const OUString& rString, PropertyMapPtr pPropertyMap );
     void appendTextContent( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >,
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 0a2348d..15ff924 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -245,6 +245,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
     m_bFirstRun(true),
     m_bNeedPap(true),
     m_bNeedCr(false),
+    m_bNeedCrOrig(false),
     m_bNeedPar(true),
     m_bNeedFinalPar(false),
     m_aListTableSprms(),
@@ -1289,6 +1290,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
             m_aStates.top().nDestinationState = DESTINATION_SHAPEPROPERTYVALUE;
             break;
         case RTF_SHP:
+            m_bNeedCrOrig = m_bNeedCr;
             m_aStates.top().nDestinationState = DESTINATION_SHAPE;
             break;
         case RTF_SHPINST:
@@ -1907,6 +1909,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
                     Mapper().text(sBreak, 1);
                     if (!m_bNeedPap)
                         parBreak();
+                    m_bNeedCr = true;
                 }
             }
             break;
@@ -4024,6 +4027,7 @@ int RTFDocumentImpl::popState()
     }
     break;
     case DESTINATION_SHAPE:
+    m_bNeedCr = m_bNeedCrOrig;
     if (m_aStates.top().aFrame.inFrame())
     {
         m_aStates.top().resetFrame();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 0e0c467..130b272 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -528,6 +528,8 @@ namespace writerfilter {
                 bool m_bNeedPap;
                 /// If we need to emit a CR at the end of substream.
                 bool m_bNeedCr;
+                /// Original value of m_bNeedCr -- saved/restored before/after textframes.
+                bool m_bNeedCrOrig;
                 bool m_bNeedPar;
                 /// If set, an empty paragraph will be added at the end of the document.
                 bool m_bNeedFinalPar;


More information about the Libreoffice-commits mailing list