diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-04-15 00:23:07 +0200 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-04-15 00:23:07 +0200 |
commit | a1050d6bd0eebb793a9d09d134a1489cb8e08fa0 (patch) | |
tree | 91ad2cedc615ddefa1b469961f3f8a70dc162110 | |
parent | 1bb064739c75477818352ed8beb966153d8864d6 (diff) |
ODF import / export of rotated text in Impress table
Change-Id: I57136e32ed2db5e405a45e8e4bad1b8d459b7ae8
-rwxr-xr-x | sd/qa/unit/data/pptx/tdf100926_ODP.pptx | bin | 0 -> 32382 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests.cxx | 31 | ||||
-rw-r--r-- | xmloff/inc/xmlsdtypes.hxx | 2 | ||||
-rw-r--r-- | xmloff/source/draw/sdpropls.cxx | 64 | ||||
-rw-r--r-- | xmloff/source/table/XMLTableExport.cxx | 14 | ||||
-rw-r--r-- | xmloff/source/table/XMLTableImport.cxx | 1 | ||||
-rw-r--r-- | xmloff/source/table/table.hxx | 1 |
7 files changed, 112 insertions, 1 deletions
diff --git a/sd/qa/unit/data/pptx/tdf100926_ODP.pptx b/sd/qa/unit/data/pptx/tdf100926_ODP.pptx Binary files differnew file mode 100755 index 000000000000..71627394ec84 --- /dev/null +++ b/sd/qa/unit/data/pptx/tdf100926_ODP.pptx diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index dd57ec01bf3d..80a03416d759 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -93,6 +93,7 @@ public: void testTransparentBackground(); void testEmbeddedPdf(); void testAuthorField(); + void testTdf100926(); CPPUNIT_TEST_SUITE(SdExportTest); @@ -108,6 +109,7 @@ public: CPPUNIT_TEST(testTransparentBackground); CPPUNIT_TEST(testEmbeddedPdf); CPPUNIT_TEST(testAuthorField); + CPPUNIT_TEST(testTdf100926); CPPUNIT_TEST_SUITE_END(); @@ -571,6 +573,35 @@ void SdExportTest::testAuthorField() xDocShRef->DoClose(); } +void SdExportTest::testTdf100926() +{ + sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf100926_ODP.pptx"), PPTX); + + xDocShRef = saveAndReload(xDocShRef.get(), ODP); + + const SdrPage* pPage = GetPage(1, xDocShRef); + CPPUNIT_ASSERT(pPage != nullptr); + + sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0)); + CPPUNIT_ASSERT(pTableObj != nullptr); + uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW); + + sal_Int32 nRotation = 0; + uno::Reference< beans::XPropertySet > xCell(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW); + xCell->getPropertyValue("RotateAngle") >>= nRotation; + CPPUNIT_ASSERT_EQUAL(sal_Int32(27000), nRotation); + + xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW); + xCell->getPropertyValue("RotateAngle") >>= nRotation; + CPPUNIT_ASSERT_EQUAL(sal_Int32(9000), nRotation); + + xCell.set(xTable->getCellByPosition(2, 0), uno::UNO_QUERY_THROW); + xCell->getPropertyValue("RotateAngle") >>= nRotation; + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nRotation); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/xmloff/inc/xmlsdtypes.hxx b/xmloff/inc/xmlsdtypes.hxx index 8e388cf032c7..86e81ba3ea5b 100644 --- a/xmloff/inc/xmlsdtypes.hxx +++ b/xmloff/inc/xmlsdtypes.hxx @@ -117,6 +117,8 @@ ////////////////////////////////////////////////////////////////////////////// +#define XML_SD_TYPE_CELL_ROTATION_ANGLE (XML_SD_TYPES_START + 79 ) + #define CTF_NUMBERINGRULES 1000 #define CTF_CONTROLWRITINGMODE 1001 #define CTF_WRITINGMODE 1002 diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx index b32204d11e52..83462fd3089f 100644 --- a/xmloff/source/draw/sdpropls.cxx +++ b/xmloff/source/draw/sdpropls.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/presentation/FadeEffect.hpp> #include <com/sun/star/text/WritingMode.hpp> +#include <com/sun/star/text/WritingMode2.hpp> #include <xmloff/EnumPropertyHdl.hxx> #include <xmloff/NamedBoolPropertyHdl.hxx> #include <xmloff/WordWrapPropertyHdl.hxx> @@ -58,6 +59,7 @@ #include "XMLPercentOrMeasurePropertyHandler.hxx" #include "animations.hxx" #include <sax/tools/converter.hxx> +#include "xmlsdtypes.hxx" #include "sdxmlexp_impl.hxx" @@ -843,6 +845,52 @@ bool XMLSdHeaderFooterVisibilityTypeHdl::exportXML( return bRet; } +class XMLSdRotationAngleTypeHdl : public XMLPropertyHandler +{ +public: + virtual bool importXML(const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter) const override; + virtual bool exportXML(OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter) const override; +}; + +bool XMLSdRotationAngleTypeHdl::importXML( + const OUString& rStrImpValue, + css::uno::Any& rValue, + const SvXMLUnitConverter&) const +{ + sal_Int32 nValue; + bool const bRet = ::sax::Converter::convertNumber(nValue, rStrImpValue); + if (bRet) + { + nValue = (nValue % 360); + if (nValue < 0) + nValue = 360 + nValue; + sal_Int32 nAngle; + if (nValue < 45 || nValue > 315) + nAngle = 0; + else if (nValue < 180) + nAngle = 9000; + else /* if nValalue <= 315 ) */ + nAngle = 27000; + + rValue <<= nAngle; + } + return bRet; +} + +bool XMLSdRotationAngleTypeHdl::exportXML( + OUString& rStrExpValue, + const Any& rValue, + const SvXMLUnitConverter&) const +{ + sal_Int32 nAngle; + bool bRet = (rValue >>= nAngle) && nAngle != 0; + if (bRet) + { + rStrExpValue = OUString::number(nAngle / 100); + } + return bRet; +} + XMLSdPropHdlFactory::XMLSdPropHdlFactory( uno::Reference< frame::XModel > const & xModel, SvXMLImport& rImport ) : mxModel( xModel ), mpExport(nullptr), mpImport( &rImport ) { @@ -1142,6 +1190,9 @@ const XMLPropertyHandler* XMLSdPropHdlFactory::GetPropertyHandler( sal_Int32 nTy case XML_SD_TYPE_HEADER_FOOTER_VISIBILITY_TYPE: pHdl = new XMLSdHeaderFooterVisibilityTypeHdl; break; + case XML_SD_TYPE_CELL_ROTATION_ANGLE: + pHdl = new XMLSdRotationAngleTypeHdl; + break; } if(pHdl) @@ -1264,7 +1315,18 @@ void XMLShapeExportPropertyMapper::ContextFilter( pControlWritingMode = property; break; case CTF_TEXTWRITINGMODE: - pTextWritingMode = property; + { + pTextWritingMode = property; + sal_Int32 eWritingMode; + if (property->maValue >>= eWritingMode) + { + if (text::WritingMode2::LR_TB == eWritingMode) + { + property->mnIndex = -1; + pTextWritingMode = nullptr; + } + } + } break; case CTF_REPEAT_OFFSET_X: pRepeatOffsetX = property; diff --git a/xmloff/source/table/XMLTableExport.cxx b/xmloff/source/table/XMLTableExport.cxx index 668e2b477931..6be73aa181e3 100644 --- a/xmloff/source/table/XMLTableExport.cxx +++ b/xmloff/source/table/XMLTableExport.cxx @@ -44,6 +44,7 @@ #include <xmloff/xmlexppr.hxx> #include <xmloff/xmlexp.hxx> #include <xmloff/xmltypes.hxx> +#include "xmlsdtypes.hxx" #include <xmloff/maptype.hxx> #include <xmloff/prhdlfac.hxx> #include <xmloff/txtprmap.hxx> @@ -62,6 +63,7 @@ using namespace ::com::sun::star::style; #define MAP_(name,prefix,token,type,context) { name, sizeof(name)-1, prefix, token, type, context, SvtSaveOptions::ODFVER_010, false } #define CMAP(name,prefix,token,type,context) MAP_(name,prefix,token,type|XML_TYPE_PROP_TABLE_COLUMN,context) #define RMAP(name,prefix,token,type,context) MAP_(name,prefix,token,type|XML_TYPE_PROP_TABLE_ROW,context) +#define CELLMAP(name,prefix,token,type,context) MAP_(name,prefix,token,type|XML_TYPE_PROP_TABLE_CELL,context) #define MAP_END { nullptr, 0, 0, XML_EMPTY, 0, 0, SvtSaveOptions::ODFVER_010, false } const XMLPropertyMapEntry* getColumnPropertiesMap() @@ -89,6 +91,17 @@ const XMLPropertyMapEntry* getRowPropertiesMap() return &aXMLRowProperties[0]; } +const XMLPropertyMapEntry* getCellPropertiesMap() +{ + static const XMLPropertyMapEntry aXMLCellProperties[] = + { + CELLMAP( "RotateAngle", XML_NAMESPACE_STYLE, XML_ROTATION_ANGLE, XML_SD_TYPE_CELL_ROTATION_ANGLE, 0), + MAP_END + }; + + return &aXMLCellProperties[0]; +} + class StringStatisticHelper { private: @@ -167,6 +180,7 @@ XMLTableExport::XMLTableExport(SvXMLExport& rExp, const rtl::Reference< SvXMLExp { mxCellExportPropertySetMapper = xExportPropertyMapper; mxCellExportPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(rExp)); + mxCellExportPropertySetMapper->ChainExportMapper(new SvXMLExportPropertyMapper(new XMLPropertySetMapper(getCellPropertiesMap(), xFactoryRef.get(), true))); } mxRowExportPropertySetMapper = new SvXMLExportPropertyMapper( new XMLPropertySetMapper( getRowPropertiesMap(), xFactoryRef.get(), true ) ); diff --git a/xmloff/source/table/XMLTableImport.cxx b/xmloff/source/table/XMLTableImport.cxx index 8e8db41dd068..46e5b7ed04f1 100644 --- a/xmloff/source/table/XMLTableImport.cxx +++ b/xmloff/source/table/XMLTableImport.cxx @@ -216,6 +216,7 @@ XMLTableImport::XMLTableImport( SvXMLImport& rImport, const rtl::Reference< XMLP { mxCellImportPropertySetMapper = new SvXMLImportPropertyMapper( xCellPropertySetMapper.get(), rImport ); mxCellImportPropertySetMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(rImport)); + mxCellImportPropertySetMapper->ChainImportMapper(new SvXMLImportPropertyMapper(new XMLPropertySetMapper(getCellPropertiesMap(), xFactoryRef.get(), true), rImport)); } rtl::Reference < XMLPropertySetMapper > xRowMapper( new XMLPropertySetMapper( getRowPropertiesMap(), xFactoryRef.get(), false ) ); diff --git a/xmloff/source/table/table.hxx b/xmloff/source/table/table.hxx index cb00e7cb13f4..2eddd38d5b83 100644 --- a/xmloff/source/table/table.hxx +++ b/xmloff/source/table/table.hxx @@ -34,6 +34,7 @@ extern const TableStyleElement* getTableStyleMap(); extern const TableStyleElement* getWriterSpecificTableStyleMap(); extern const XMLPropertyMapEntry* getColumnPropertiesMap(); extern const XMLPropertyMapEntry* getRowPropertiesMap(); +extern const XMLPropertyMapEntry* getCellPropertiesMap(); #endif |