summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2022-10-28 12:20:49 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2022-10-31 11:49:11 +0100
commit6f32f1a12be06c4da92b807d8a35cb079984e26a (patch)
tree30ce1f7048b6460b205e56c93e3a64a748c6cffe /xmloff
parent1dc8b2b9ce4c5cee03c5fec49658fa363a00341b (diff)
tdf#72238 xmloff,sd: Import of <style:table-cell-properties>
Handles fo:border*, fo:padding*, fo:background-color and style:vertical-align attributes. Export is unchanged for now, as older versions still can't read this, and on the other hand we probably want to keep the import of the wrong attributes for the long term, to not break existing documents. Also, we can't fully export fill properties anyway because of tdf#103602. Change-Id: I8687507b98602ffcd05adb2087c894bb45aa3c6c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142058 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/table/XMLTableExport.cxx14
-rw-r--r--xmloff/source/table/XMLTableImport.cxx42
2 files changed, 54 insertions, 2 deletions
diff --git a/xmloff/source/table/XMLTableExport.cxx b/xmloff/source/table/XMLTableExport.cxx
index b3d60c9402eb..366ffaa15d9e 100644
--- a/xmloff/source/table/XMLTableExport.cxx
+++ b/xmloff/source/table/XMLTableExport.cxx
@@ -92,6 +92,18 @@ const XMLPropertyMapEntry* getCellPropertiesMap()
static const XMLPropertyMapEntry aXMLCellProperties[] =
{
CELLMAP( "RotateAngle", XML_NAMESPACE_STYLE, XML_ROTATION_ANGLE, XML_SD_TYPE_CELL_ROTATION_ANGLE, 0),
+ CELLMAP( "TextVerticalAdjust", XML_NAMESPACE_STYLE, XML_VERTICAL_ALIGN, XML_SD_TYPE_VERTICAL_ALIGN|MID_FLAG_SPECIAL_ITEM_EXPORT, 0),
+ CELLMAP( "BackColor", XML_NAMESPACE_FO, XML_BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_SPECIAL_ITEM, 0),
+ CELLMAP( "LeftBorder", XML_NAMESPACE_FO, XML_BORDER, XML_TYPE_BORDER|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_CHARALLBORDER),
+ CELLMAP( "LeftBorder", XML_NAMESPACE_FO, XML_BORDER_LEFT, XML_TYPE_BORDER|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_CHARLEFTBORDER),
+ CELLMAP( "RightBorder", XML_NAMESPACE_FO, XML_BORDER_RIGHT, XML_TYPE_BORDER|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_CHARRIGHTBORDER),
+ CELLMAP( "TopBorder", XML_NAMESPACE_FO, XML_BORDER_TOP, XML_TYPE_BORDER|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_CHARTOPBORDER),
+ CELLMAP( "BottomBorder", XML_NAMESPACE_FO, XML_BORDER_BOTTOM, XML_TYPE_BORDER|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_CHARBOTTOMBORDER),
+ CELLMAP( "TextLeftDistance", XML_NAMESPACE_FO, XML_PADDING, XML_TYPE_MEASURE|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_CHARALLBORDERDISTANCE),
+ CELLMAP( "TextLeftDistance", XML_NAMESPACE_FO, XML_PADDING_LEFT, XML_TYPE_MEASURE|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_CHARLEFTBORDERDISTANCE),
+ CELLMAP( "TextRightDistance", XML_NAMESPACE_FO, XML_PADDING_RIGHT, XML_TYPE_MEASURE|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_CHARRIGHTBORDERDISTANCE),
+ CELLMAP( "TextUpperDistance", XML_NAMESPACE_FO, XML_PADDING_TOP, XML_TYPE_MEASURE|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_CHARTOPBORDERDISTANCE),
+ CELLMAP( "TextLowerDistance", XML_NAMESPACE_FO, XML_PADDING_BOTTOM, XML_TYPE_MEASURE|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_CHARBOTTOMBORDERDISTANCE),
MAP_END
};
@@ -190,7 +202,7 @@ XMLTableExport::XMLTableExport(SvXMLExport& rExp, const rtl::Reference< SvXMLExp
{
mxCellExportPropertySetMapper = xExportPropertyMapper;
mxCellExportPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(rExp));
- mxCellExportPropertySetMapper->ChainExportMapper(new SvXMLExportPropertyMapper(new XMLPropertySetMapper(getCellPropertiesMap(), xFactoryRef, true)));
+ mxCellExportPropertySetMapper->ChainExportMapper(new XMLCellExportPropertyMapper(new XMLPropertySetMapper(getCellPropertiesMap(), xFactoryRef, true)));
}
mxRowExportPropertySetMapper = new SvXMLExportPropertyMapper( new XMLPropertySetMapper( getRowPropertiesMap(), xFactoryRef, true ) );
diff --git a/xmloff/source/table/XMLTableImport.cxx b/xmloff/source/table/XMLTableImport.cxx
index 9033f5f5b09d..86b19e768e16 100644
--- a/xmloff/source/table/XMLTableImport.cxx
+++ b/xmloff/source/table/XMLTableImport.cxx
@@ -35,6 +35,8 @@
#include <utility>
#include <xmloff/table/XMLTableImport.hxx>
+#include <xmloff/xmltypes.hxx>
+#include <xmloff/maptype.hxx>
#include <xmloff/xmlprmap.hxx>
#include <xmloff/txtimp.hxx>
#include <xmloff/xmlimp.hxx>
@@ -91,6 +93,44 @@ struct MergeInfo
: mnStartColumn( nStartColumn ), mnStartRow( nStartRow ), mnEndColumn( nStartColumn + nColumnSpan - 1 ), mnEndRow( nStartRow + nRowSpan - 1 ) {};
};
+class XMLCellImportPropertyMapper : public SvXMLImportPropertyMapper
+{
+public:
+ using SvXMLImportPropertyMapper::SvXMLImportPropertyMapper;
+
+ bool handleSpecialItem(
+ XMLPropertyState& rProperty,
+ std::vector< XMLPropertyState >& rProperties,
+ const OUString& rValue,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& /*rNamespaceMap*/) const override
+ {
+ assert(getPropertySetMapper()->GetEntryXMLName(rProperty.mnIndex) == GetXMLToken(XML_BACKGROUND_COLOR));
+ (void)rProperty;
+
+ auto nIndex = getPropertySetMapper()->GetEntryIndex(XML_NAMESPACE_DRAW, GetXMLToken(XML_FILL), 0);
+ XMLPropertyState aFillProperty(nIndex);
+
+ if (IsXMLToken(rValue, XML_TRANSPARENT))
+ {
+ getPropertySetMapper()->importXML(GetXMLToken(XML_NONE), aFillProperty, rUnitConverter);
+ rProperties.push_back(aFillProperty);
+ }
+ else
+ {
+ getPropertySetMapper()->importXML(GetXMLToken(XML_SOLID), aFillProperty, rUnitConverter);
+ rProperties.push_back(aFillProperty);
+
+ nIndex = getPropertySetMapper()->GetEntryIndex(XML_NAMESPACE_DRAW, GetXMLToken(XML_FILL_COLOR), 0);
+ XMLPropertyState aColorProperty(nIndex);
+ getPropertySetMapper()->importXML(rValue, aColorProperty, rUnitConverter);
+ rProperties.push_back(aColorProperty);
+ }
+
+ return false;
+ }
+};
+
}
class XMLTableImportContext : public SvXMLImportContext
@@ -216,7 +256,7 @@ XMLTableImport::XMLTableImport( SvXMLImport& rImport, const rtl::Reference< XMLP
{
mxCellImportPropertySetMapper = new SvXMLImportPropertyMapper( xCellPropertySetMapper, rImport );
mxCellImportPropertySetMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(rImport));
- mxCellImportPropertySetMapper->ChainImportMapper(new SvXMLImportPropertyMapper(new XMLPropertySetMapper(getCellPropertiesMap(), xFactoryRef, true), rImport));
+ mxCellImportPropertySetMapper->ChainImportMapper(new XMLCellImportPropertyMapper(new XMLPropertySetMapper(getCellPropertiesMap(), xFactoryRef, true), rImport));
}
rtl::Reference < XMLPropertySetMapper > xRowMapper( new XMLPropertySetMapper( getRowPropertiesMap(), xFactoryRef, false ) );