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

Caolán McNamara caolan at kemper.freedesktop.org
Tue Jun 19 01:27:31 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 9073da554f407c7aed8af6231313c5355cc266e0
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)
    (cherry picked from commit 3c5a75208b41239b2e840a2ea9932a9f5b872b36)
    
    Signed-off-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 99dbbf6..c2820ee 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3508,6 +3508,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 0a3ccb8..bafec8f 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -213,9 +213,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 289b3c0..d533cad 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -306,6 +306,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;
@@ -551,6 +552,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 314acc4..361ad89 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -278,6 +278,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
     m_bNeedPap(true),
     m_bNeedCr(false),
     m_bNeedPar(true),
+    m_bNeedFinalPar(false),
     m_aListTableSprms(),
     m_aSettingsTableSprms(),
     m_xStorage(),
@@ -505,6 +506,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();
@@ -656,6 +663,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));
@@ -1498,6 +1509,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
                 m_bWasInFrame = m_aStates.top().aFrame.inFrame();
                 if (!m_bWasInFrame)
                     m_bNeedPar = false;
+                m_bNeedFinalPar = false;
             }
             break;
         case RTF_SECT:
@@ -1602,6 +1614,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();
@@ -3552,6 +3565,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 9d097bc..aa2f756 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -438,6 +438,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.


More information about the Libreoffice-commits mailing list