summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2013-11-28 15:01:39 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-11-28 15:31:05 +0100
commitefcc8ddd213e7f7a341526bdcffcee75d8fef77f (patch)
tree0427612972c20ce8756e216f8cf040e162625521 /oox
parent51a423cd75240e1e70165be8c0e5f1f09e8b68b9 (diff)
fdo#69636 DOCX drawingML shape import: handle vert=vert270 prop for sw frames
Change-Id: I95b4cfa0494c8115ebf23c76f4712b48d17bd463
Diffstat (limited to 'oox')
-rw-r--r--oox/source/shape/ShapeContextHandler.cxx19
-rw-r--r--oox/source/shape/ShapeContextHandler.hxx5
-rw-r--r--oox/source/shape/WpsContext.cxx27
-rw-r--r--oox/source/shape/WpsContext.hxx3
4 files changed, 42 insertions, 12 deletions
diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index c12518d56fd6..5ac772c36a21 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -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();
}
}
diff --git a/oox/source/shape/ShapeContextHandler.hxx b/oox/source/shape/ShapeContextHandler.hxx
index 7a9b93c0f679..bf27e167a8ea 100644
--- a/oox/source/shape/ShapeContextHandler.hxx
+++ b/oox/source/shape/ShapeContextHandler.hxx
@@ -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);
};
}}
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index 6ecf320482ed..5c2a145d3618 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -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");
diff --git a/oox/source/shape/WpsContext.hxx b/oox/source/shape/WpsContext.hxx
index cb05de8ae080..b7f97f89faf5 100644
--- a/oox/source/shape/WpsContext.hxx
+++ b/oox/source/shape/WpsContext.hxx
@@ -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;
};