diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-09-05 14:24:02 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-09-06 19:29:54 +0200 |
commit | 8f9f4232ca0cc5d2f8692083caf6a5f2494e5ce3 (patch) | |
tree | f03c608a9ca1793788264b33464c7dc298809b31 | |
parent | b6d84e347eb5a7e036fca6993f18bdfe3dd793ac (diff) |
bnc#779642 VML import: fix TextHorizontalAdjust when layout-flow is vertical
The shape had no special properties about hori/vert text adjustment, so
it should be hori left / vert top. Then it has vertical layout-flow, so
vert should be top and hori should be right (vert was center).
Change-Id: Ia89d8587b6a822ead45198dc5d1ba23907cc3567
(cherry picked from commit b10afb26296e33c77e94a6eda3f2c36c4d34c2aa)
-rw-r--r-- | oox/source/vml/vmltextbox.cxx | 11 | ||||
-rw-r--r-- | sw/qa/extras/inc/swmodeltestbase.hxx | 9 | ||||
-rwxr-xr-x | sw/qa/extras/ooxmlimport/data/vml-text-vertical-adjust.docx | bin | 0 -> 10578 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 12 |
4 files changed, 32 insertions, 0 deletions
diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx index 72a18ce64748..5a5d75c970dc 100644 --- a/oox/source/vml/vmltextbox.cxx +++ b/oox/source/vml/vmltextbox.cxx @@ -22,6 +22,7 @@ #include <rtl/ustrbuf.hxx> #include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/drawing/TextHorizontalAdjust.hpp> #include <com/sun/star/text/XTextAppend.hpp> #include <com/sun/star/text/WritingMode.hpp> @@ -96,6 +97,16 @@ void TextBox::convert(uno::Reference<drawing::XShape> xShape) const if ( maLayoutFlow == "vertical" ) { uno::Reference<beans::XPropertySet> xProperties(xShape, uno::UNO_QUERY); + + // VML has the text horizontally aligned to left (all the time), + // v-text-anchor for vertical alignment, and vertical mode to swap the + // two. drawinglayer supports both horizontal and vertical alignment, + // but no vertical mode: we use T->B, R->L instead. + // As a result, we need to set horizontal adjustment here to 'right', + // that will result in vertical 'top' after writing mode is applied, + // which matches the VML behavior. + xProperties->setPropertyValue("TextHorizontalAdjust", uno::makeAny(drawing::TextHorizontalAdjust_RIGHT)); + xProperties->setPropertyValue( "TextWritingMode", uno::makeAny( text::WritingMode_TB_RL ) ); } } diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index cf37f7f01f18..17a978a2eb6b 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -260,6 +260,15 @@ protected: return xCursor->getPage(); } + /// Get shape (counted from 1) + uno::Reference<drawing::XShape> getShape(int number) + { + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(number - 1), uno::UNO_QUERY); + return xShape; + } + uno::Reference<lang::XComponent> mxComponent; xmlBufferPtr mpXmlBuffer; diff --git a/sw/qa/extras/ooxmlimport/data/vml-text-vertical-adjust.docx b/sw/qa/extras/ooxmlimport/data/vml-text-vertical-adjust.docx Binary files differnew file mode 100755 index 000000000000..1b05dbd6edab --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/vml-text-vertical-adjust.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 4d6733a59540..6f07128fbdfb 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/awt/XBitmap.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -135,6 +136,7 @@ public: void testTableStyleParprop(); void testTablePagebreak(); void testFdo68607(); + void testVmlTextVerticalAdjust(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -219,6 +221,7 @@ void Test::run() {"table-style-parprop.docx", &Test::testTableStyleParprop}, {"table-pagebreak.docx", &Test::testTablePagebreak}, {"fdo68607.docx", &Test::testFdo68607}, + {"vml-text-vertical-adjust.docx", &Test::testVmlTextVerticalAdjust}, }; for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) { @@ -1370,6 +1373,15 @@ void Test::testFdo68607() CPPUNIT_ASSERT(getPages() > 1); } +void Test::testVmlTextVerticalAdjust() +{ + uno::Reference<drawing::XShapes> xOuterGroupShape(getShape(1), uno::UNO_QUERY); + uno::Reference<drawing::XShapes> xInnerGroupShape(xOuterGroupShape->getByIndex(0), uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape(xInnerGroupShape->getByIndex(0), uno::UNO_QUERY); + // Was CENTER. + CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, getProperty<drawing::TextVerticalAdjust>(xShape, "TextVerticalAdjust")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); |