diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-05-27 13:00:10 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-06-08 14:50:55 +0200 |
commit | 95ebd24a629b4c8cd62cc20c0701683512cc8fa0 (patch) | |
tree | 8bdeab41e8b4d0092f639e62fd3e20ae8243f199 /sd | |
parent | c4f615b359be56e88e4fbf9aaaf30affb29d57e2 (diff) |
editengine-columns: ODF support [API CHANGE]
This uses existing ODF markup, as used by Writer's text frame:
style::columns child element of style:graphic-properties, its
fo:column-count and fo:column-gap attributes. No ODF extension
is required.
Since currently only columns with same width and spacing are
implemented, without additional settings, style:column child
elements are exported, but ignored on import.
This adds new property to css::drawing::TextProperties service:
TextColumns (of type css::text::XTextColumns).
Change-Id: I7e63293e5814b281ceec8a9632e696322d3629e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116035
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/data/odg/two_columns.odg | bin | 0 -> 14726 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests.cxx | 69 | ||||
-rw-r--r-- | sd/source/core/stlsheet.cxx | 13 |
3 files changed, 82 insertions, 0 deletions
diff --git a/sd/qa/unit/data/odg/two_columns.odg b/sd/qa/unit/data/odg/two_columns.odg Binary files differnew file mode 100644 index 000000000000..bd721f0c0d86 --- /dev/null +++ b/sd/qa/unit/data/odg/two_columns.odg diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 0529178f43e9..7805b591b6ed 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -39,8 +39,10 @@ #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/text/WritingMode2.hpp> +#include <com/sun/star/text/XTextColumns.hpp> #include <svx/svdotable.hxx> +#include <svx/unoapi.hxx> #include <vcl/filter/PDFiumLibrary.hxx> using namespace css; @@ -89,6 +91,7 @@ public: void testTdf128550(); void testTdf140714(); void testMasterPageBackgroundFullSize(); + void testColumnsODG(); CPPUNIT_TEST_SUITE(SdExportTest); @@ -132,6 +135,7 @@ public: CPPUNIT_TEST(testTdf128550); CPPUNIT_TEST(testTdf140714); CPPUNIT_TEST(testMasterPageBackgroundFullSize); + CPPUNIT_TEST(testColumnsODG); CPPUNIT_TEST_SUITE_END(); @@ -1571,6 +1575,71 @@ void SdExportTest::testMasterPageBackgroundFullSize() tempFile.EnableKillingFile(); } +void SdExportTest::testColumnsODG() +{ + auto xDocShRef + = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odg/two_columns.odg"), ODG); + + { + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc(xDocShRef); + uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages(); + uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW); + uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCols->getColumnCount()); + uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(700)), + xColProps->getPropertyValue("AutomaticDistance")); + + auto pTextObj = dynamic_cast<SdrTextObj*>(GetSdrObjectFromXShape(xShape)); + CPPUNIT_ASSERT(pTextObj); + + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), pTextObj->GetTextColumnsNumber()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(700), pTextObj->GetTextColumnsSpacing()); + } + + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), ODG, &tempFile); + + { + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc(xDocShRef); + uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages(); + uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW); + uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCols->getColumnCount()); + uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(700)), + xColProps->getPropertyValue("AutomaticDistance")); + + auto pTextObj = dynamic_cast<SdrTextObj*>(GetSdrObjectFromXShape(xShape)); + CPPUNIT_ASSERT(pTextObj); + + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), pTextObj->GetTextColumnsNumber()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(700), pTextObj->GetTextColumnsSpacing()); + } + + xDocShRef->DoClose(); + + xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "content.xml"); + assertXPath(pXmlDoc, + "/office:document-content/office:automatic-styles/style:style/" + "style:graphic-properties/style:columns", + "column-count", "2"); + assertXPath(pXmlDoc, + "/office:document-content/office:automatic-styles/style:style/" + "style:graphic-properties/style:columns", + "column-gap", "0.7cm"); + + tempFile.EnableKillingFile(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx index 93bc3f0c8ac0..5b79e7333176 100644 --- a/sd/source/core/stlsheet.cxx +++ b/sd/source/core/stlsheet.cxx @@ -1186,6 +1186,19 @@ PropertyState SAL_CALL SdStyleSheet::getPropertyState( const OUString& PropertyN return PropertyState_AMBIGUOUS_VALUE; } } + else if (pEntry->nWID == OWN_ATTR_TEXTCOLUMNS) + { + const SfxItemSet& rSet = GetItemSet(); + + const auto eState1 = rSet.GetItemState(SDRATTR_TEXTCOLUMNS_NUMBER, false); + const auto eState2 = rSet.GetItemState(SDRATTR_TEXTCOLUMNS_SPACING, false); + if (eState1 == SfxItemState::SET || eState2 == SfxItemState::SET) + return PropertyState_DIRECT_VALUE; + else if (eState1 == SfxItemState::DEFAULT && eState2 == SfxItemState::DEFAULT) + return PropertyState_DEFAULT_VALUE; + else + return PropertyState_AMBIGUOUS_VALUE; + } else { SfxItemSet &rStyleSet = GetItemSet(); |