[Libreoffice-commits] .: writerfilter/source

Noel Power noelp at kemper.freedesktop.org
Tue Jan 18 04:49:00 PST 2011


 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)

New commits:
commit c764fd6bbe7fc04f0518d26e146e62671544b053
Author: Noel Power <noel.power at novell.com>
Date:   Tue Jan 18 12:43:50 2011 +0000

    fdo#33237# fix ole object import for writer (docx)

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index c025a5e..95f505b 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -535,6 +535,38 @@ void DomainMapper_Impl::clearDeferredBreaks()
     m_bIsColumnBreakDeferred = false;
     m_bIsPageBreakDeferred = false;
 }
+
+bool lcl_removeShape( const uno::Reference<  text::XTextDocument >& rDoc, const uno::Reference< drawing::XShape >& rShape, TextContentStack& rAnchoredStack,TextAppendStack&  rTextAppendStack )
+{
+    bool bRet = false;
+    // probably unecessary but just double check that indeed the top of Anchored stack
+    // does contain the shape we intend to remove
+    uno::Reference< drawing::XShape > xAnchorShape(rAnchoredStack.top( ), uno::UNO_QUERY );
+    if ( xAnchorShape == rShape )
+    {
+        // because we only want to process the embedded object and not the associated
+        // shape we need to get rid of that shape from the Draw page and Anchored and
+        // Append stacks  so it wont be processed further
+        try
+        {
+            uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(rDoc, uno::UNO_QUERY_THROW);
+            uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+            if ( xDrawPage.is() )
+            {
+                xDrawPage->remove( rShape );
+            }
+            osl_trace("**** after removing shape ");
+            rAnchoredStack.pop();
+            rTextAppendStack.pop();
+            bRet = true;
+        }
+        catch( uno::Exception& e )
+        {
+        }
+    }
+    return bRet;
+}
+
 /*-------------------------------------------------------------------------
 
   -----------------------------------------------------------------------*/
@@ -992,6 +1024,15 @@ void DomainMapper_Impl::appendOLE( const ::rtl::OUString& rStreamName, OLEHandle
         uno::Reference< graphic::XGraphic > xGraphic = pOLEHandler->getReplacement();
         xOLEProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_GRAPHIC ),
                         uno::makeAny(xGraphic));
+        // mimic the treatment of graphics here.. it seems anchoring as character
+        // gives a better ( visually ) result
+        xOLEProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_ANCHOR_TYPE ),  uno::makeAny( text::TextContentAnchorType_AS_CHARACTER ) );
+        // remove ( if valid ) associated shape ( used for graphic replacement )
+        if ( m_bShapeContextAdded )
+        {
+            if ( lcl_removeShape(  m_xTextDocument, pOLEHandler->getShape(), m_aAnchoredStack, m_aTextAppendStack ) )
+                m_bShapeContextAdded = false; // ensure PopShapeContext processing doesn't pop the append stack
+        }
 
         //
         appendTextContent( xOLE, uno::Sequence< beans::PropertyValue >() );


More information about the Libreoffice-commits mailing list