diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-04-29 20:01:21 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-04-30 09:11:07 +0200 |
commit | cd2a7acd789297e613424a59b2fe24cedd9a72b6 (patch) | |
tree | 31a6051541900d7ed55369d4ac19ee8d779ce68c | |
parent | 267d97ccca46a1c7eb729be7f333e1b8137b8a08 (diff) |
sw btlr writing mode: implement ODF filter for textframes
Layout is still not yet correct right after the import, though.
Change-Id: Icdba2e8d608f35b6b5b43b88ffb223f779af1b89
Reviewed-on: https://gerrit.libreoffice.org/71552
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | sw/qa/extras/odfexport/data/btlr-frame.odt | bin | 0 -> 8564 bytes | |||
-rw-r--r-- | sw/qa/extras/odfexport/odfexport.cxx | 12 | ||||
-rw-r--r-- | xmloff/source/style/prhdlfac.cxx | 1 | ||||
-rw-r--r-- | xmloff/source/style/xmlexppr.cxx | 15 | ||||
-rw-r--r-- | xmloff/source/text/txtprmap.cxx | 1 |
5 files changed, 28 insertions, 1 deletions
diff --git a/sw/qa/extras/odfexport/data/btlr-frame.odt b/sw/qa/extras/odfexport/data/btlr-frame.odt Binary files differnew file mode 100644 index 000000000000..31cb03849c53 --- /dev/null +++ b/sw/qa/extras/odfexport/data/btlr-frame.odt diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 8348438437a1..4ef1128d3118 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -1409,6 +1409,18 @@ DECLARE_ODFEXPORT_TEST(testBtlrCell, "btlr-cell.odt") CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, getProperty<sal_Int16>(xC1, "WritingMode")); } +DECLARE_ODFEXPORT_TEST(testBtlrFrame, "btlr-frame.odt") +{ + // Without the accompanying fix in place, this test would have failed, as + // the btlr text direction in the text frame was lost on ODF import and + // export. + uno::Reference<beans::XPropertySet> xTextFrame(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(xTextFrame.is()); + + auto nActual = getProperty<sal_Int16>(xTextFrame, "WritingMode"); + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, nActual); +} + DECLARE_ODFEXPORT_TEST(testFdo86963, "fdo86963.odt") { // Export of this document failed with beans::UnknownPropertyException. diff --git a/xmloff/source/style/prhdlfac.cxx b/xmloff/source/style/prhdlfac.cxx index a67fa04c781b..8dede8e8faa3 100644 --- a/xmloff/source/style/prhdlfac.cxx +++ b/xmloff/source/style/prhdlfac.cxx @@ -91,6 +91,7 @@ static SvXMLEnumMapEntry<sal_uInt16> const aXML_WritingDirection_Enum[] = { XML_RL_TB, text::WritingMode2::RL_TB }, { XML_TB_RL, text::WritingMode2::TB_RL }, { XML_TB_LR, text::WritingMode2::TB_LR }, + { XML_BT_LR, text::WritingMode2::BT_LR }, // alternative names of the above, as accepted by XSL { XML_LR, text::WritingMode2::LR_TB }, diff --git a/xmloff/source/style/xmlexppr.cxx b/xmloff/source/style/xmlexppr.cxx index 5b2f073453fa..63994492afbc 100644 --- a/xmloff/source/style/xmlexppr.cxx +++ b/xmloff/source/style/xmlexppr.cxx @@ -973,7 +973,7 @@ void SvXMLExportPropertyMapper::_exportXML( else if ((mpImpl->mxPropMapper->GetEntryFlags(rProperty.mnIndex) & MID_FLAG_ELEMENT_ITEM_EXPORT ) == 0) { OUString aValue; - const OUString sName = rNamespaceMap.GetQNameByKey( + OUString sName = rNamespaceMap.GetQNameByKey( mpImpl->mxPropMapper->GetEntryNameSpace(rProperty.mnIndex), mpImpl->mxPropMapper->GetEntryXMLName(rProperty.mnIndex)); @@ -988,6 +988,19 @@ void SvXMLExportPropertyMapper::_exportXML( { if( bRemove ) rAttrList.RemoveAttribute( sName ); + + if (IsXMLToken(mpImpl->mxPropMapper->GetEntryXMLName(rProperty.mnIndex), XML_WRITING_MODE)) + { + // We don't seem to have a generic mechanism to write an attribute in the extension + // namespace in case of certain attribute values only, so do this manually. + if (IsXMLToken(aValue, XML_BT_LR)) + { + sName = rNamespaceMap.GetQNameByKey( + XML_NAMESPACE_LO_EXT, + mpImpl->mxPropMapper->GetEntryXMLName(rProperty.mnIndex)); + } + } + rAttrList.AddAttribute( sName, aValue ); } } diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx index 7817bbfc2101..2cd5005dfc64 100644 --- a/xmloff/source/text/txtprmap.cxx +++ b/xmloff/source/text/txtprmap.cxx @@ -850,6 +850,7 @@ XMLPropertyMapEntry const aXMLFramePropMap[] = // RES_GRFATR_DRAWMODE MG_E( "GraphicColorMode", DRAW, COLOR_MODE, XML_TYPE_COLOR_MODE, 0 ), MG_E( "WritingMode", STYLE, WRITING_MODE, XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT, 0 ), + MAP_EXT_I("WritingMode", XML_NAMESPACE_LO_EXT, XML_WRITING_MODE, XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT|XML_TYPE_PROP_GRAPHIC, 0), // RES_FOLLOW_TEXT_FLOW - DVO #i18732# MG_E( "IsFollowingTextFlow", DRAW, FLOW_WITH_TEXT, XML_TYPE_BOOL|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_OLD_FLOW_WITH_TEXT ), MG_E( "IsFollowingTextFlow", STYLE, FLOW_WITH_TEXT, XML_TYPE_BOOL, 0 ), |