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

Miklos Vajna vmiklos at suse.cz
Tue May 21 09:16:46 PDT 2013


 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    |   21 ++++++++++++++-------
 writerfilter/source/rtftok/rtfdocumentimpl.hxx    |    2 ++
 5 files changed, 45 insertions(+), 7 deletions(-)

New commits:
commit 131b66fb2d30bd5501d233284061c9f9c14def22
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
    
    (cherry picked from commit b40fe8e5a5037d2745cc7b1c9cc408ce6c79b9d9)
    
    Conflicts:
    	sw/qa/extras/rtfimport/rtfimport.cxx
    	writerfilter/source/dmapper/DomainMapper.cxx
    	writerfilter/source/rtftok/rtfdocumentimpl.cxx
    
    Change-Id: Ief71ba9a3c60356714e73d08e88d0a3105b17b1a

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 1a33f6e..58cbb4d 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3524,6 +3524,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 1b9fdca..827b72a 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -661,6 +661,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 a8dec58..5fa3f42 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -435,6 +435,7 @@ public:
     void deferBreak( BreakType deferredBreakType );
     bool isBreakDeferred( BreakType deferredBreakType );
     void clearDeferredBreaks();
+    void clearDeferredBreak(BreakType deferredBreakType);
     void finishParagraph( PropertyMapPtr pPropertyMap );
     void appendTextPortion( const ::rtl::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 445f62e..a89b3c0 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -250,6 +250,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(),
@@ -1215,6 +1216,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:
@@ -1667,6 +1669,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
                     Mapper().text(sBreak, 1);
                     if (!m_bNeedPap)
                         parBreak();
+                    m_bNeedCr = true;
                 }
             }
             break;
@@ -3547,14 +3550,18 @@ int RTFDocumentImpl::popState()
         Mapper().startShape(xShape);
         Mapper().endShape();
     }
-    else if (m_aStates.top().nDestinationState == DESTINATION_SHAPE && m_aStates.top().aFrame.inFrame())
+    else if (m_aStates.top().nDestinationState == DESTINATION_SHAPE)
     {
-        m_aStates.top().resetFrame();
-        parBreak();
-        // Save this state for later use, so we only reset frame status only for the first shape inside a frame.
-        aState = m_aStates.top();
-        bPopFrame = true;
-        m_bNeedPap = true;
+        m_bNeedCr = m_bNeedCrOrig;
+        if (m_aStates.top().aFrame.inFrame())
+        {
+            m_aStates.top().resetFrame();
+            parBreak();
+            // Save this state for later use, so we only reset frame status only for the first shape inside a frame.
+            aState = m_aStates.top();
+            bPopFrame = true;
+            m_bNeedPap = true;
+        }
     }
 
     // See if we need to end a track change
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 5e88ef8..5a4b519 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -452,6 +452,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