summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2023-04-22 15:54:35 -0400
committerJustin Luth <jluth@mail.com>2023-04-23 02:56:50 +0200
commitdeb1a14adb115710b5e40dd305dc5da4a4e3b065 (patch)
tree50369b59041f9c040d43422570ca16ec5af64c31
parent0ad8d644722228759abce42b0c11024e7460f6eb (diff)
tdf#97128 tdf#154703 docx export framePr: export frame textDirection
textDirection attributes were lost on framePr round-tripping No existing unit tests were affected by/matched the change. make CppunitTest_sw_ooxmlexport18 \ CPPUNIT_TEST_NAME=testTdf154703_framePrTextDirection Change-Id: I2184b9350391f510c7a2e77096b080e05d3d62da Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150820 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf154703_framePrTextDirection.docxbin0 -> 13534 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport18.cxx10
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx25
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx4
4 files changed, 39 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf154703_framePrTextDirection.docx b/sw/qa/extras/ooxmlexport/data/tdf154703_framePrTextDirection.docx
new file mode 100644
index 000000000000..e01c2cf9f495
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf154703_framePrTextDirection.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 72cfe1723870..22e1f21f5707 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -244,6 +244,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf154703_framePrWrapSpacing, "tdf154703_framePrWra
assertXPath(pXmlDoc, "//w:body/w:p/w:pPr/w:framePr", "hSpace", "2552");
}
+DECLARE_OOXMLEXPORT_TEST(testTdf154703_framePrTextDirection, "tdf154703_framePrTextDirection.docx")
+{
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(text::WritingMode2::TB_RL), getProperty<sal_Int16>(getShape(1), "WritingMode"));
+ if (!isExported())
+ return;
+
+ xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+ assertXPath(pXmlDoc, "//w:body/w:p/w:pPr/w:textDirection", "val", "tbRl");
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf153613_anchoredAfterPgBreak, "tdf153613_anchoredAfterPgBreak.docx")
{
const auto& pLayout = parseLayoutDump();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 94ed8bac2ba9..87446d03c786 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -584,6 +584,7 @@ void FramePrHelper::SetFrame(ww8::Frame* pFrame, sal_Int32 nTableDepth)
{
m_bUseFrameBorders = true;
m_bUseFrameBackground = true;
+ m_bUseFrameTextDirection = true;
}
}
@@ -603,6 +604,14 @@ bool FramePrHelper::UseFrameBackground()
return m_bUseFrameBackground;
}
+bool FramePrHelper::UseFrameTextDirection(sal_Int32 nTableDepth)
+{
+ if (!m_pFrame || m_nTableDepth < nTableDepth)
+ return false;
+
+ return m_bUseFrameTextDirection;
+}
+
void SdtBlockHelper::DeleteAndResetTheLists()
{
if (m_pTokenChildren.is() )
@@ -1571,9 +1580,24 @@ void DocxAttributeOutput::EndParagraphProperties(const SfxItemSet& rParagraphMar
}
}
+ if (m_aFramePr.UseFrameTextDirection(!m_xTableWrt ? -1 : m_tableReference.m_nTableDepth))
+ {
+ const SvxFrameDirectionItem& rFrameDir = rFrameFormat.GetFrameDir();
+ if (rFrameDir.GetValue() != SvxFrameDirection::Environment)
+ {
+ assert(!m_rExport.m_bOutPageDescs);
+ // hack: use existing variable to write out the full TextDirection attribute.
+ // This is valid for paragraphs/styles - just not native in LO, so hack for now.
+ m_rExport.m_bOutPageDescs = true;
+ FormatFrameDirection(rFrameDir);
+ m_rExport.m_bOutPageDescs = false;
+ }
+ }
+
// reset to true in preparation for the next paragraph in the frame
m_aFramePr.SetUseFrameBorders(true);
m_aFramePr.SetUseFrameBackground(true);
+ m_aFramePr.SetUseFrameTextDirection(true);
}
m_pSerializer->endElementNS( XML_w, XML_pPr );
@@ -9775,6 +9799,7 @@ void DocxAttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDi
m_pSerializer->singleElementNS(XML_w, XML_bidi, FSNS(XML_w, XML_val), "1");
else
m_pSerializer->singleElementNS(XML_w, XML_bidi, FSNS(XML_w, XML_val), "0");
+ m_aFramePr.SetUseFrameTextDirection(false);
}
}
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 5b4708936605..35171507cd38 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -133,6 +133,7 @@ class FramePrHelper
sal_Int32 m_nTableDepth;
bool m_bUseFrameBorders;
bool m_bUseFrameBackground;
+ bool m_bUseFrameTextDirection;
public:
FramePrHelper()
@@ -140,6 +141,7 @@ public:
, m_nTableDepth(0)
, m_bUseFrameBorders(true)
, m_bUseFrameBackground(true)
+ , m_bUseFrameTextDirection(true)
{}
ww8::Frame* Frame() { return m_pFrame; }
@@ -148,6 +150,8 @@ public:
void SetUseFrameBorders(bool bSet) { m_bUseFrameBorders = bSet; }
bool UseFrameBackground();
void SetUseFrameBackground(bool bSet) { m_bUseFrameBackground = bSet; }
+ bool UseFrameTextDirection(sal_Int32 nTableDepth);
+ void SetUseFrameTextDirection(bool bSet) { m_bUseFrameTextDirection = bSet; }
};
class SdtBlockHelper