[Libreoffice-commits] .: Branch 'libreoffice-3-6' - writerfilter/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Mon Jun 11 09:06:01 PDT 2012


 writerfilter/source/dmapper/DomainMapper.cxx      |    3 +++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    4 ++--
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    7 +++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx    |   15 +++++++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.hxx    |    2 ++
 5 files changed, 29 insertions(+), 2 deletions(-)

New commits:
commit 3c5a75208b41239b2e840a2ea9932a9f5b872b36
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Jun 11 11:19:19 2012 +0200

    fdo#49659 three RTF fixes
    
    1) fix RTF import of pictures with inner groups
    
    One would think that with {\pict{\foo1}}, the inner group has no effect
    in the outer group, but this turns out to be valid, so we should handle
    it as well.
    
    (cherry picked from commit c5c3ce5e625a31d78a21fbbc339ee30ba99f3044)
    
    2) handle RTF import of tables at the very end of the document
    
    If the documents ends with a table, both Word/Writer produces a
    non-table empty paragraph after that table. However, it's valid not to
    emit that empty paragraph, so handle the situation in the importer.
    
    (cherry picked from commit e08ab74b918be1473d91ed234ee7870cab137c7e)
    
    3) dmapper: handle tables in substreams
    
    (cherry picked from commit 61ba6e49f5bbadaf1334ce71459647c3d0a3a37d)

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 5c45373..9f3d115 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3491,6 +3491,9 @@ void DomainMapper::lcl_table(Id name, writerfilter::Reference<Table>::Pointer_t
 void DomainMapper::lcl_substream(Id rName, ::writerfilter::Reference<Stream>::Pointer_t ref)
 {
     m_pImpl->appendTableManager( );
+    // Appending a TableManager resets its TableHandler, so we need to append
+    // that as well, or tables won't be imported properly in headers/footers.
+    m_pImpl->appendTableHandler( );
     m_pImpl->getTableManager().startLevel();
 
     //import of page header/footer
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 08e189b..546613a 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -216,9 +216,9 @@ DomainMapper_Impl::DomainMapper_Impl(
 
     //todo: does it make sense to set the body text as static text interface?
     uno::Reference< text::XTextAppendAndConvert > xBodyTextAppendAndConvert( m_xBodyText, uno::UNO_QUERY );
-    TableDataHandler_t::Pointer_t pTableHandler
+    m_pTableHandler.reset
         (new DomainMapperTableHandler(xBodyTextAppendAndConvert, *this));
-    getTableManager( ).setHandler(pTableHandler);
+    getTableManager( ).setHandler(m_pTableHandler);
 
     getTableManager( ).startLevel();
     m_bUsingEnhancedFields = lcl_IsUsingEnhancedFields( uno::Reference< lang::XMultiServiceFactory >( m_xComponentContext->getServiceManager(), uno::UNO_QUERY ) );
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 1dc1ebc..07f6934 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -311,6 +311,7 @@ private:
 
     // TableManagers are stacked: one for each stream to avoid any confusion
     std::stack< boost::shared_ptr< DomainMapperTableManager > > m_aTableManagers;
+    TableDataHandler_t::Pointer_t m_pTableHandler;
 
     //each context needs a stack of currently used attributes
     FIB                     m_aFIB;
@@ -556,6 +557,12 @@ public:
         m_aTableManagers.push( pMngr );
     }
 
+    void appendTableHandler( )
+    {
+        if (m_pTableHandler.get())
+            m_aTableManagers.top()->setHandler(m_pTableHandler);
+    }
+
     void popTableManager( )
     {
         if ( m_aTableManagers.size( ) > 0 )
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 3acbddc..a01e08d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -249,6 +249,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
     m_bNeedPap(true),
     m_bNeedCr(false),
     m_bNeedPar(true),
+    m_bNeedFinalPar(false),
     m_aListTableSprms(),
     m_aSettingsTableAttributes(),
     m_aSettingsTableSprms(),
@@ -481,6 +482,12 @@ 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);
+    // It's allowed to not have a non-table paragraph at the end of an RTF doc, add it now if required.
+    if (m_bNeedFinalPar && bFinal)
+    {
+        dispatchFlag(RTF_PARD);
+        dispatchSymbol(RTF_PAR);
+    }
     while (m_nHeaderFooterPositions.size())
     {
         std::pair<Id, sal_uInt32> aPair = m_nHeaderFooterPositions.front();
@@ -620,6 +627,10 @@ int RTFDocumentImpl::resolvePict(bool bInline)
     else
         pStream = m_pBinaryData.get();
 
+    if (!pStream->Tell())
+        // No destination text? Then we'll get it later.
+        return 0;
+
     // Store, and get its URL.
     pStream->Seek(0);
     uno::Reference<io::XInputStream> xInputStream(new utl::OInputStreamWrapper(pStream));
@@ -1430,6 +1441,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
                 m_bNeedPap = true;
                 if (!m_aStates.top().aFrame.inFrame())
                     m_bNeedPar = false;
+                m_bNeedFinalPar = false;
             }
             break;
         case RTF_SECT:
@@ -1534,6 +1546,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
 
                 tableBreak();
                 m_bNeedPap = true;
+                m_bNeedFinalPar = true;
                 m_aTableBuffer.clear();
                 m_aStates.top().nCells = 0;
                 m_aStates.top().aTableCellsSprms.clear();
@@ -3526,6 +3539,8 @@ int RTFDocumentImpl::popState()
         if (aState.nFieldStatus == FIELD_INSTRUCTION)
             singleChar(0x15);
     }
+    else if (m_aStates.size() && m_aStates.top().nDestinationState == DESTINATION_PICT)
+        m_aStates.top().aPicture = aState.aPicture;
     else if (bPopShapeProperties)
     {
         m_aStates.top().aShape = aShape;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 93ed15d..9bb994d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -444,6 +444,8 @@ namespace writerfilter {
                 /// If we need to emit a CR at the end of substream.
                 bool m_bNeedCr;
                 bool m_bNeedPar;
+                /// If set, an empty paragraph will be added at the end of the document.
+                bool m_bNeedFinalPar;
                 /// The list table and list override table combined.
                 RTFSprms m_aListTableSprms;
                 /// The settings table attributes.


More information about the Libreoffice-commits mailing list