[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - include/vcl sw/CppunitTest_sw_core_doc.mk sw/qa sw/source vcl/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 5 09:31:56 UTC 2020


 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 69d99ea0a10cb54e67d20f155c81346064f26631
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Jun 2 09:07:48 2020 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Fri Jun 5 11:31:26 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 <vmiklos at collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit 413791a65597a1808d9b98e4887864f3624b70cc)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95318
    (cherry picked from commit e05a39f75cd304bfc1bd59aa2eebe4889cae109f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95411
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/include/vcl/errinf.hxx b/include/vcl/errinf.hxx
index 37805b7f710c..76ee7aca37aa 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 3141c12011cc..72895861f713 100644
--- a/sw/qa/core/doc/doc.cxx
+++ b/sw/qa/core/doc/doc.cxx
@@ -13,6 +13,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 37939224daf6..4656e3bec14c 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -358,11 +358,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 f1e9109f5afb..31bec6e085a0 100644
--- a/vcl/source/window/errinf.cxx
+++ b/vcl/source/window/errinf.cxx
@@ -69,6 +69,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);


More information about the Libreoffice-commits mailing list