fdo#69636 DOCX drawingML shape import: handle vert=vert270 prop for sw frames

Change-Id: I95b4cfa0494c8115ebf23c76f4712b48d17bd463
This commit is contained in:
Miklos Vajna
2013-11-28 15:31:05 +01:00
parent 51a423cd75
commit efcc8ddd21
4 changed files with 42 additions and 12 deletions
+13 -6
View File
@@ -117,17 +117,23 @@ uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getChartShape
return mxChartShapeContext;
}
uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getWpsContext(sal_Int32 nElement)
uno::Reference<xml::sax::XFastContextHandler> ShapeContextHandler::getWpsContext(sal_Int32 nStartElement, sal_Int32 nElement)
{
if (!mxWpsContext.is())
{
FragmentHandler2Ref rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
ShapePtr pMasterShape;
switch (getBaseToken(nElement))
uno::Reference<drawing::XShape> xShape;
// No element happens in case of pretty-printed XML, bodyPr is the case when we are called again after <wps:txbx>.
if (!nElement || nElement == WPS_TOKEN(bodyPr))
// Assume that this is just a continuation of the previous shape.
xShape = mxSavedShape;
switch (getBaseToken(nStartElement))
{
case XML_wsp:
mxWpsContext.set(new WpsContext(*rFragmentHandler));
mxWpsContext.set(new WpsContext(*rFragmentHandler, xShape));
break;
default:
break;
@@ -215,7 +221,7 @@ ShapeContextHandler::getDiagramShapeContext()
}
uno::Reference<xml::sax::XFastContextHandler>
ShapeContextHandler::getContextHandler()
ShapeContextHandler::getContextHandler(sal_Int32 nElement)
{
uno::Reference<xml::sax::XFastContextHandler> xResult;
@@ -235,7 +241,7 @@ ShapeContextHandler::getContextHandler()
xResult.set(getChartShapeContext(mnStartToken));
break;
case NMSP_wps:
xResult.set(getWpsContext(mnStartToken));
xResult.set(getWpsContext(mnStartToken, nElement));
break;
case NMSP_wpg:
xResult.set(getWpgContext(mnStartToken));
@@ -336,7 +342,7 @@ ShapeContextHandler::createFastChildContext
throw (uno::RuntimeException, xml::sax::SAXException)
{
uno::Reference< xml::sax::XFastContextHandler > xResult;
uno::Reference< xml::sax::XFastContextHandler > xContextHandler(getContextHandler());
uno::Reference< xml::sax::XFastContextHandler > xContextHandler(getContextHandler(Element));
if (xContextHandler.is())
xResult.set(xContextHandler->createFastChildContext
@@ -453,6 +459,7 @@ ShapeContextHandler::getShape() throw (uno::RuntimeException)
pShape->setPosition(maPosition);
pShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties());
xResult = pShape->getXShape();
mxSavedShape = xResult;
mxWpsContext.clear();
}
}
+3 -2
View File
@@ -155,6 +155,7 @@ private:
css::uno::Reference<XFastContextHandler> mxDiagramShapeContext;
css::uno::Reference<XFastContextHandler> mxLockedCanvasContext;
css::uno::Reference<XFastContextHandler> mxWpsContext;
css::uno::Reference<css::drawing::XShape> mxSavedShape;
css::uno::Reference<XFastContextHandler> mxWpgContext;
css::uno::Reference<XFastContextHandler> mxChartShapeContext;
@@ -169,9 +170,9 @@ private:
css::uno::Reference<XFastContextHandler> getDrawingShapeContext();
css::uno::Reference<XFastContextHandler> getDiagramShapeContext();
css::uno::Reference<XFastContextHandler> getLockedCanvasContext(sal_Int32 nElement);
css::uno::Reference<XFastContextHandler> getWpsContext(sal_Int32 nElement);
css::uno::Reference<XFastContextHandler> getWpsContext(sal_Int32 nStartElement, sal_Int32 nElement);
css::uno::Reference<XFastContextHandler> getWpgContext(sal_Int32 nElement);
css::uno::Reference<XFastContextHandler> getContextHandler();
css::uno::Reference<XFastContextHandler> getContextHandler(sal_Int32 nElement = 0);
};
}}
+24 -3
View File
@@ -10,13 +10,15 @@
#include "WpsContext.hxx"
#include <oox/drawingml/shapepropertiescontext.hxx>
#include <oox/drawingml/shapestylecontext.hxx>
#include <com/sun/star/beans/XPropertyState.hpp>
using namespace com::sun::star;
namespace oox { namespace shape {
WpsContext::WpsContext(ContextHandler2Helper& rParent)
: ContextHandler2(rParent)
WpsContext::WpsContext(ContextHandler2Helper& rParent, uno::Reference<drawing::XShape> xShape)
: ContextHandler2(rParent),
mxShape(xShape)
{
mpShape.reset(new oox::drawingml::Shape("com.sun.star.drawing.CustomShape"));
mpShape->setWps(true);
@@ -31,7 +33,7 @@ oox::drawingml::ShapePtr WpsContext::getShape()
return mpShape;
}
oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken, const oox::AttributeList& /*rAttribs*/)
oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken, const oox::AttributeList& rAttribs)
{
switch (getBaseToken(nElementToken))
{
@@ -48,6 +50,25 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
return new oox::drawingml::ShapeStyleContext(*this, *mpShape);
break;
case XML_bodyPr:
if (mxShape.is())
{
OptValue<OUString> oVert = rAttribs.getString(XML_vert);
if (oVert.has() && oVert.get() == "vert270")
{
// No support for this in core, work around by char rotation, as we do so for table cells already.
uno::Reference<text::XText> xText(mxShape, uno::UNO_QUERY);
uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor();
xTextCursor->gotoStart(false);
xTextCursor->gotoEnd(true);
uno::Reference<beans::XPropertyState> xPropertyState(xTextCursor, uno::UNO_QUERY);
beans::PropertyState aState = xPropertyState->getPropertyState("CharRotation");
if (aState == beans::PropertyState_DEFAULT_VALUE)
{
uno::Reference<beans::XPropertySet> xPropertySet(xTextCursor, uno::UNO_QUERY);
xPropertySet->setPropertyValue("CharRotation", uno::makeAny(sal_Int16(900)));
}
}
}
break;
case XML_txbx:
mpShape->setServiceName("com.sun.star.text.TextFrame");
+2 -1
View File
@@ -19,7 +19,7 @@ namespace oox { namespace shape {
class WpsContext : public oox::core::ContextHandler2
{
public:
WpsContext(oox::core::ContextHandler2Helper& rParent);
WpsContext(oox::core::ContextHandler2Helper& rParent, css::uno::Reference<css::drawing::XShape> xShape);
virtual ~WpsContext();
virtual oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElementToken, const oox::AttributeList& rAttribs) SAL_OVERRIDE;
@@ -28,6 +28,7 @@ public:
protected:
oox::drawingml::ShapePtr mpShape;
css::uno::Reference<css::drawing::XShape> mxShape;
};