diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-06-02 09:07:48 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-06-02 14:13:59 +0200 |
commit | 413791a65597a1808d9b98e4887864f3624b70cc (patch) | |
tree | 7ba1d59e4ecf7035121747c381c53504be5c7f7d /sw | |
parent | 73477348e30c6931a537cba5557c250183fbeb9b (diff) |
tdf#133271 sw textbox: handle TextRotateAngle shape property
Shape with btlr text direction is imported as TextPreRotateAngle=-270
from DOCX. Saving this to ODT turns the property name into
TextRotateAngle and its type into double.
Handle that as well to survive the ODF roundtrip of a shape+textbox
where the textbox has a btlr text direction.
(Also add a way to make multiple tests in a suite to be more independent
from each other: depending on ordering, the new test made the old test
fail. Calling ErrorRegistry::Reset() makes that go away.)
Change-Id: Iea9212f3bbb01059caf3b0f2d809e48debf52953
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95340
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/CppunitTest_sw_core_doc.mk | 1 | ||||
-rw-r--r-- | sw/qa/core/doc/data/textbox-textrotateangle.odt | bin | 0 -> 9496 bytes | |||
-rw-r--r-- | sw/qa/core/doc/doc.cxx | 22 | ||||
-rw-r--r-- | sw/source/core/doc/textboxhelper.cxx | 14 |
4 files changed, 35 insertions, 2 deletions
diff --git a/sw/CppunitTest_sw_core_doc.mk b/sw/CppunitTest_sw_core_doc.mk index 487e02322ef4..856f007cb9b1 100644 --- a/sw/CppunitTest_sw_core_doc.mk +++ b/sw/CppunitTest_sw_core_doc.mk @@ -21,6 +21,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_core_doc, \ comphelper \ cppu \ cppuhelper \ + editeng \ sal \ sfx \ sw \ diff --git a/sw/qa/core/doc/data/textbox-textrotateangle.odt b/sw/qa/core/doc/data/textbox-textrotateangle.odt Binary files differnew file mode 100644 index 000000000000..2ce4c3e0b7ec --- /dev/null +++ b/sw/qa/core/doc/data/textbox-textrotateangle.odt diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index 882f31873bf3..a8489e01a274 100644 --- a/sw/qa/core/doc/doc.cxx +++ b/sw/qa/core/doc/doc.cxx @@ -12,6 +12,8 @@ #include <comphelper/classids.hxx> #include <tools/globname.hxx> #include <svtools/embedhlp.hxx> +#include <editeng/frmdiritem.hxx> +#include <vcl/errinf.hxx> #include <wrtsh.hxx> #include <fmtanchr.hxx> @@ -58,6 +60,26 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testMathInsertAnchorType) // - Actual : 4 // i.e. the anchor type was at-char, not as-char. CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AS_CHAR, rAnchor.GetAnchorId()); + ErrorRegistry::Reset(); +} + +CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testTextboxTextRotateAngle) +{ + // Check the writing direction of the only TextFrame in the document. + SwDoc* pDoc = createDoc("textbox-textrotateangle.odt"); + SwFrameFormats& rFrameFormats = *pDoc->GetSpzFrameFormats(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFrameFormats.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(RES_DRAWFRMFMT), rFrameFormats[0]->Which()); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(RES_FLYFRMFMT), rFrameFormats[1]->Which()); + SvxFrameDirection eActual = rFrameFormats[1]->GetAttrSet().GetItem(RES_FRAMEDIR)->GetValue(); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 5 (btlr) + // - Actual : 0 (lrtb) + // i.e. the writing direction was in the ODT file, but it was lost on import in the textbox + // case. + CPPUNIT_ASSERT_EQUAL(SvxFrameDirection::Vertical_LR_BT, eActual); + ErrorRegistry::Reset(); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 4f2550f06b52..1dcc7e242016 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -361,11 +361,21 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, const OUString& rPrope comphelper::SequenceAsHashMap aCustomShapeGeometry(rValue); auto it = aCustomShapeGeometry.find("TextPreRotateAngle"); + if (it == aCustomShapeGeometry.end()) + { + it = aCustomShapeGeometry.find("TextRotateAngle"); + } + if (it != aCustomShapeGeometry.end()) { - auto nTextPreRotateAngle = it->second.get<sal_Int32>(); + auto nAngle = it->second.has<sal_Int32>() ? it->second.get<sal_Int32>() : 0; + if (nAngle == 0) + { + nAngle = it->second.has<double>() ? it->second.get<double>() : 0; + } + sal_Int16 nDirection = 0; - switch (nTextPreRotateAngle) + switch (nAngle) { case -90: nDirection = text::WritingMode2::TB_RL; |