[Libreoffice-commits] core.git: oox/source sw/qa

Miklos Vajna vmiklos at collabora.co.uk
Thu Sep 5 05:48:23 PDT 2013


 oox/source/vml/vmltextbox.cxx                               |   11 +++++++++++
 sw/qa/extras/ooxmlimport/data/vml-text-vertical-adjust.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx                    |   11 +++++++++++
 3 files changed, 22 insertions(+)

New commits:
commit b10afb26296e33c77e94a6eda3f2c36c4d34c2aa
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 5 14:24:02 2013 +0200

    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

diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx
index e3d07b8..553b6f0 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>
 #include <com/sun/star/style/ParagraphAdjust.hpp>
@@ -126,6 +127,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/ooxmlimport/data/vml-text-vertical-adjust.docx b/sw/qa/extras/ooxmlimport/data/vml-text-vertical-adjust.docx
new file mode 100755
index 0000000..1b05dbd
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/vml-text-vertical-adjust.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 973f3b1..08b2bfc 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -131,6 +131,7 @@ public:
     void testTableStyleParprop();
     void testTablePagebreak();
     void testFdo68607();
+    void testVmlTextVerticalAdjust();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -228,6 +229,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},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1540,6 +1542,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();


More information about the Libreoffice-commits mailing list