Kaydet (Commit) b399c1a3 authored tarafından Cédric Bosdonnat's avatar Cédric Bosdonnat

n#592908: docx import, fixed handling of w10:wrap

commit f837c428 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 51d5e90b)

Conflicts:
	oox/inc/oox/vml/vmlshape.hxx
	sw/qa/extras/ooxmlimport/ooxmlimport.cxx

Change-Id: I8ab158641afcf6b9945c52238e7f5adb9e8b3adf
üst e7ecf663
......@@ -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();
......
......@@ -465,6 +465,7 @@ StringItemList
Subtotals
SubViewSize
Suffix
Surround
SwapXAndYAxis
Symbol
SymbolColor
......
......@@ -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
......
......@@ -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 ):
{
......
......@@ -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();
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment