Kaydet (Commit) b10afb26 authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 8c1d8ab9
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/beans/XPropertySet.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/XTextAppend.hpp>
#include <com/sun/star/text/WritingMode.hpp> #include <com/sun/star/text/WritingMode.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp> #include <com/sun/star/style/ParagraphAdjust.hpp>
...@@ -126,6 +127,16 @@ void TextBox::convert(uno::Reference<drawing::XShape> xShape) const ...@@ -126,6 +127,16 @@ void TextBox::convert(uno::Reference<drawing::XShape> xShape) const
if ( maLayoutFlow == "vertical" ) if ( maLayoutFlow == "vertical" )
{ {
uno::Reference<beans::XPropertySet> xProperties(xShape, uno::UNO_QUERY); 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 ) ); xProperties->setPropertyValue( "TextWritingMode", uno::makeAny( text::WritingMode_TB_RL ) );
} }
} }
......
...@@ -131,6 +131,7 @@ public: ...@@ -131,6 +131,7 @@ public:
void testTableStyleParprop(); void testTableStyleParprop();
void testTablePagebreak(); void testTablePagebreak();
void testFdo68607(); void testFdo68607();
void testVmlTextVerticalAdjust();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT) #if !defined(MACOSX) && !defined(WNT)
...@@ -228,6 +229,7 @@ void Test::run() ...@@ -228,6 +229,7 @@ void Test::run()
{"table-style-parprop.docx", &Test::testTableStyleParprop}, {"table-style-parprop.docx", &Test::testTableStyleParprop},
{"table-pagebreak.docx", &Test::testTablePagebreak}, {"table-pagebreak.docx", &Test::testTablePagebreak},
{"fdo68607.docx", &Test::testFdo68607}, {"fdo68607.docx", &Test::testFdo68607},
{"vml-text-vertical-adjust.docx", &Test::testVmlTextVerticalAdjust},
}; };
header(); header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
...@@ -1540,6 +1542,15 @@ void Test::testFdo68607() ...@@ -1540,6 +1542,15 @@ void Test::testFdo68607()
CPPUNIT_ASSERT(getPages() > 1); 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_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
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