include/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 b399c1a38cf7217bf530af3a78e8472d97890ac8 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. (cherry picked from commit 51d5e90b7c09cb980bc72a2c6b1a65303ef15ea2) Conflicts: oox/inc/oox/vml/vmlshape.hxx sw/qa/extras/ooxmlimport/ooxmlimport.cxx Change-Id: I8ab158641afcf6b9945c52238e7f5adb9e8b3adf diff --git a/include/oox/vml/vmlshape.hxx b/include/oox/vml/vmlshape.hxx index 7b6a4a9..e16fe90 100644 --- a/include/oox/vml/vmlshape.hxx +++ b/include/oox/vml/vmlshape.hxx @@ -93,6 +93,8 @@ struct OOX_DLLPUBLIC ShapeTypeModel OptValue< OUString > moGraphicTitle; ///< Title of the graphic. OptValue< OUString > moWrapAnchorX; ///< The base object from which our horizontal positioning should be calculated. OptValue< 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 2430580..fb3e5a5 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -465,6 +465,7 @@ StringItemList Subtotals SubViewSize Suffix +Surround SwapXAndYAxis Symbol SymbolColor diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 3239151..0af325d 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -36,6 +36,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> @@ -405,6 +406,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" ) @@ -449,6 +468,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 awt::Rectangle& rShapeRect ) const diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index c5edd00..e0f8cfb 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -360,6 +360,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; case VML_TOKEN( shadow ): { 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 25e4495..423900f 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -107,6 +107,8 @@ public: void testTableWidth(); void testConditionalstylesTbllook(); void testFdo63685(); + void testN592908_Frame(); + void testN592908_Picture(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -184,6 +186,8 @@ void Test::run() {"table_width.docx", &Test::testTableWidth}, {"conditionalstyles-tbllook.docx", &Test::testConditionalstylesTbllook}, {"fdo63685.docx", &Test::testFdo63685}, + {"n592908-frame.docx", &Test::testN592908_Frame}, + {"n592908-picture.docx", &Test::testN592908_Picture}, }; header(); for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) @@ -1315,6 +1319,26 @@ void Test::testFdo63685() CPPUNIT_ASSERT_EQUAL(sal_Int32(318), getProperty<sal_Int32>(xDraws->getByIndex(0), "TopMargin")); } +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 8c02cca..f4a7924 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -2283,11 +2283,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()) { @@ -2302,10 +2305,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