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
This commit is contained in:
Miklos Vajna 2020-06-02 09:07:48 +02:00
parent 73477348e3
commit 413791a655
6 changed files with 42 additions and 2 deletions

View File

@ -59,6 +59,7 @@ public:
static void RegisterDisplay(BasicDisplayErrorFunc*);
static void RegisterDisplay(WindowDisplayErrorFunc*);
static void Reset();
private:
DisplayFnPtr pDsp;

View File

@ -21,6 +21,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_core_doc, \
comphelper \
cppu \
cppuhelper \
editeng \
sal \
sfx \
sw \

Binary file not shown.

View File

@ -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();

View File

@ -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;

View File

@ -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);