include/vcl/errinf.hxx | 1 + sw/CppunitTest_sw_core_doc.mk | 1 + sw/qa/core/doc/data/textbox-textrotateangle.odt |binary sw/qa/core/doc/doc.cxx | 22 ++++++++++++++++++++++ sw/source/core/doc/textboxhelper.cxx | 14 ++++++++++++-- vcl/source/window/errinf.cxx | 6 ++++++ 6 files changed, 42 insertions(+), 2 deletions(-)
New commits: commit 413791a65597a1808d9b98e4887864f3624b70cc Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue Jun 2 09:07:48 2020 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Jun 2 14:13:59 2020 +0200 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 <vmik...@collabora.com> Tested-by: Jenkins diff --git a/include/vcl/errinf.hxx b/include/vcl/errinf.hxx index 6d57954aff2b..4a0edc75b259 100644 --- a/include/vcl/errinf.hxx +++ b/include/vcl/errinf.hxx @@ -59,6 +59,7 @@ public: static void RegisterDisplay(BasicDisplayErrorFunc*); static void RegisterDisplay(WindowDisplayErrorFunc*); + static void Reset(); private: DisplayFnPtr pDsp; 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 new file mode 100644 index 000000000000..2ce4c3e0b7ec Binary files /dev/null and b/sw/qa/core/doc/data/textbox-textrotateangle.odt differ 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; diff --git a/vcl/source/window/errinf.cxx b/vcl/source/window/errinf.cxx index 5307d60df716..8e08dc361acd 100644 --- a/vcl/source/window/errinf.cxx +++ b/vcl/source/window/errinf.cxx @@ -74,6 +74,12 @@ void ErrorRegistry::RegisterDisplay(WindowDisplayErrorFunc *aDsp) rData.pDsp = reinterpret_cast< DisplayFnPtr >(aDsp); } +void ErrorRegistry::Reset() +{ + ErrorRegistry &rData = TheErrorRegistry::get(); + rData = ErrorRegistry(); +} + static void aDspFunc(const OUString &rErr, const OUString &rAction) { SAL_WARN("vcl", "Action: " << rAction << " Error: " << rErr); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits