summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2011-01-18 12:43:50 +0000
committerNoel Power <noel.power@novell.com>2011-01-18 12:45:51 +0000
commitc764fd6bbe7fc04f0518d26e146e62671544b053 (patch)
treea7ec00da7ad36d3e119a60dc91a3110064ad006a
parente7473329c8d79ba3988aa07172290beedcaaf325 (diff)
fdo#33237# fix ole object import for writer (docx)
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx41
1 files changed, 41 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index c025a5e35..95f505b41 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 >() );