oox/inc/oox/vml/vmlshape.hxx | 2 + oox/source/token/properties.txt | 1 oox/source/vml/vmlshape.cxx | 20 +++++++++++++++ oox/source/vml/vmlshapecontext.cxx | 2 + sw/qa/extras/ooxmlimport/data/n592908-frame.docx |binary sw/qa/extras/ooxmlimport/data/n592908-picture.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 24 ++++++++++++++++++ writerfilter/source/dmapper/OLEHandler.cxx | 12 --------- writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 8 +++--- writerfilter/source/ooxml/OOXMLFastContextHandler.hxx | 2 + 10 files changed, 56 insertions(+), 15 deletions(-)
New commits: commit 51d5e90b7c09cb980bc72a2c6b1a65303ef15ea2 Author: Cédric Bosdonnat <cedric.bosdon...@free.fr> Date: Mon Apr 29 15:41:37 2013 +0200 n#592908: docx import, fixed handling of w10:wrap commit f837c4288cdae4921b3fb6747ba2e2cd5ce2dcd2 moved the handling of w10:wrap tag in oox, but thus no wrapping was imported any more. The fix consists in letting the w10:wrap element be handled by writerfilter's dmapper if the shape has already been retrieved from oox (which is the case for textboxes). In other cases, make sure that we don't set the Surround property once again in writerfilter as that would override what has been done in oox. Change-Id: I8ab158641afcf6b9945c52238e7f5adb9e8b3adf diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx index bd7ced4..1c289b2 100644 --- a/oox/inc/oox/vml/vmlshape.hxx +++ b/oox/inc/oox/vml/vmlshape.hxx @@ -92,6 +92,8 @@ struct OOX_DLLPUBLIC ShapeTypeModel OptValue< ::rtl::OUString > moGraphicTitle; ///< Title of the graphic. OptValue< ::rtl::OUString > moWrapAnchorX; ///< The base object from which our horizontal positioning should be calculated. OptValue< ::rtl::OUString > moWrapAnchorY; ///< The base object from which our vertical positioning should be calculated. + OptValue< ::rtl::OUString > moWrapType; ///< How to wrap the text around the object + OptValue< ::rtl::OUString > moWrapSide; ///< On which side to wrap the text around the object explicit ShapeTypeModel(); diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index a252bb2..730f61e 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -464,6 +464,7 @@ StringItemList Subtotals SubViewSize Suffix +Surround SwapXAndYAxis Symbol SymbolColor diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 6dfa35a..5a4a165 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/text/RelOrientation.hpp> #include <com/sun/star/text/SizeType.hpp> #include <com/sun/star/text/VertOrientation.hpp> +#include <com/sun/star/text/WrapTextMode.hpp> #include <com/sun/star/text/XTextContent.hpp> #include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/text/XTextFrame.hpp> @@ -380,6 +381,24 @@ SimpleShape::SimpleShape( Drawing& rDrawing, const OUString& rService ) : { } +void lcl_setSurround(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel) +{ + sal_Int32 nSurround = com::sun::star::text::WrapTextMode_THROUGHT; + if ( rTypeModel.moWrapType.get() == "square" || rTypeModel.moWrapType .get()== "tight" || + rTypeModel.moWrapType.get() == "through" ) + { + nSurround = com::sun::star::text::WrapTextMode_PARALLEL; + if ( rTypeModel.moWrapSide.get() == "left" ) + nSurround = com::sun::star::text::WrapTextMode_LEFT; + else if ( rTypeModel.moWrapSide.get() == "right" ) + nSurround = com::sun::star::text::WrapTextMode_RIGHT; + } + else if ( rTypeModel.moWrapType.get() == "topAndBottom" ) + nSurround = com::sun::star::text::WrapTextMode_NONE; + + rPropSet.setProperty(PROP_Surround, nSurround); +} + void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel) { if ( rTypeModel.maPositionHorizontal == "center" ) @@ -424,6 +443,7 @@ void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel) { rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AS_CHARACTER); } + lcl_setSurround( rPropSet, rTypeModel ); } Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index f734999..6a53f17 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -332,6 +332,8 @@ ContextHandlerRef ShapeTypeContext::onCreateContext( sal_Int32 nElement, const A case NMSP_vmlWord | XML_wrap: mrTypeModel.moWrapAnchorX = rAttribs.getString(XML_anchorx); mrTypeModel.moWrapAnchorY = rAttribs.getString(XML_anchory); + mrTypeModel.moWrapType = rAttribs.getString(XML_type); + mrTypeModel.moWrapSide = rAttribs.getString(XML_side); break; } return 0; diff --git a/sw/qa/extras/ooxmlimport/data/n592908-frame.docx b/sw/qa/extras/ooxmlimport/data/n592908-frame.docx new file mode 100644 index 0000000..ff59cac Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/n592908-frame.docx differ diff --git a/sw/qa/extras/ooxmlimport/data/n592908-picture.docx b/sw/qa/extras/ooxmlimport/data/n592908-picture.docx new file mode 100644 index 0000000..2766d36 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/n592908-picture.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 3f5a070..54a1478 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -114,6 +114,8 @@ public: void testFdo53985(); void testFdo59638(); void testFdo61343(); + void testN592908_Frame(); + void testN592908_Picture(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -180,6 +182,8 @@ void Test::run() {"fdo53985.docx", &Test::testFdo53985}, {"fdo59638.docx", &Test::testFdo59638}, {"fdo61343.docx", &Test::testFdo61343}, + {"n592908-frame.docx", &Test::testN592908_Frame}, + {"n592908-picture.docx", &Test::testN592908_Picture}, }; for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) { @@ -1132,6 +1136,26 @@ void Test::testFdo61343() CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); } +void Test::testN592908_Frame() +{ + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY); + text::WrapTextMode eValue; + xPropertySet->getPropertyValue("Surround") >>= eValue; + CPPUNIT_ASSERT_EQUAL(eValue, text::WrapTextMode_PARALLEL); +} + +void Test::testN592908_Picture() +{ + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY); + text::WrapTextMode eValue; + xPropertySet->getPropertyValue("Surround") >>= eValue; + CPPUNIT_ASSERT_EQUAL(eValue, text::WrapTextMode_PARALLEL); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/OLEHandler.cxx b/writerfilter/source/dmapper/OLEHandler.cxx index ae4490f..e2a3335 100644 --- a/writerfilter/source/dmapper/OLEHandler.cxx +++ b/writerfilter/source/dmapper/OLEHandler.cxx @@ -113,17 +113,7 @@ void OLEHandler::lcl_attribute(Id rName, Value & rVal) { SAL_WARN("writerfilter", "Exception in OLE Handler: " << e.Message); } - - try - { - xShapeProps->setPropertyValue( - rNameSupplier.GetName( PROP_SURROUND ), - uno::makeAny( m_nWrapMode ) ); - } - catch( const uno::Exception& e ) - { - SAL_WARN("writerfilter", "Exception while setting wrap mode: " << e.Message); - } + // No need to set the wrapping here as it's either set in oox or will be set later } } break; diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index 5865846..11e8523 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -2272,11 +2272,14 @@ OOXMLFastContextHandlerWrapper::lcl_createFastChildContext bool bInNamespaces = mMyNamespaces.find(nNameSpace) != mMyNamespaces.end(); bool bInTokens = mMyTokens.find( Element ) != mMyTokens.end( ); + OOXMLFastContextHandlerShape* pShapeCtx = (OOXMLFastContextHandlerShape*)mpParent; + // We have methods to _add_ individual tokens or whole namespaces to be // processed by writerfilter (instead of oox), but we have no method to // filter out a single token. Just hardwire the wrap token here till we // need a more generic solution. - if ( bInNamespaces && Element != static_cast<sal_Int32>(NS_vml_wordprocessingDrawing | OOXML_wrap) ) + bool bIsWrap = Element == static_cast<sal_Int32>(NS_vml_wordprocessingDrawing | OOXML_wrap); + if ( bInNamespaces && ((pShapeCtx->isShapeSent() && bIsWrap) || !bIsWrap) ) xResult.set(OOXMLFactory::getInstance()->createFastChildContextFromStart(this, Element)); else if (mxContext.is()) { @@ -2291,10 +2294,7 @@ OOXMLFastContextHandlerWrapper::lcl_createFastChildContext xResult.set(this); if ( bInTokens ) - { - OOXMLFastContextHandlerShape* pShapeCtx = (OOXMLFastContextHandlerShape*)mpParent; pShapeCtx->sendShape( Element ); - } return xResult; } diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx index b47f611..b1941b6 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx @@ -531,6 +531,7 @@ public: virtual ResourceEnum_t getResource() const { return SHAPE; } void sendShape( Token_t Element ); + bool isShapeSent( ) { return m_bShapeSent; } protected: typedef uno::Reference<XFastShapeContextHandler> ShapeContextRef; @@ -633,6 +634,7 @@ private: set<Id> mMyNamespaces; set<Token_t> mMyTokens; OOXMLPropertySet::Pointer_t mpPropertySet; + bool mbShapeSent; OOXMLFastContextHandler * getFastContextHandler() const; };
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits