diff options
author | Michael Stahl <mstahl@redhat.com> | 2011-12-22 23:10:14 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2011-12-22 23:57:45 +0100 |
commit | c1e1ef80e8428514499b061e00801a6a6298d0b0 (patch) | |
tree | c4591d23c504bdc2f9444ccf5dd60e314e1f9bd0 /xmloff | |
parent | f277d0c88a478917002b4da370cc170b29a219ed (diff) |
fdo#44073: ODF export: fix layout grid invalid ODF
The following 3 attributes have been added in ODF 1.2, so don't write
them into ODF 1.1 files:
style:layout-grid-base-width 20.297
style:layout-grid-snap-to 20.305
style:layout-grid-standard-mode 20.306
Additionally, style:layout-grid-snap-to was written wrongly as
style:layout-grid-snap-to-characters, which does not exist in any ODF
spec.
For backward compatibility with previous OOo/LO versions, write the
wrong attribute in addition to the correct one in ODF extended mode,
even though validators complain about it (consider removing that
some years from now).
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/inc/xmloff/PageMasterStyleMap.hxx | 1 | ||||
-rw-r--r-- | xmloff/source/style/PageMasterExportPropMapper.cxx | 7 | ||||
-rw-r--r-- | xmloff/source/style/PageMasterStyleMap.cxx | 21 |
3 files changed, 22 insertions, 7 deletions
diff --git a/xmloff/inc/xmloff/PageMasterStyleMap.hxx b/xmloff/inc/xmloff/PageMasterStyleMap.hxx index 573d8836bafb..1c90b3289e21 100644 --- a/xmloff/inc/xmloff/PageMasterStyleMap.hxx +++ b/xmloff/inc/xmloff/PageMasterStyleMap.hxx @@ -102,6 +102,7 @@ #define CTF_PM_STANDARD_MODE (XML_PM_CTF_START + 0x0055) #define CTP_PM_GRID_BASE_WIDTH (XML_PM_CTF_START + 0x0056) #define CTP_PM_GRID_SNAP_TO_CHARS (XML_PM_CTF_START + 0x0057) +#define CTP_PM_GRID_SNAP_TO (XML_PM_CTF_START + 0x0058) // header #define CTF_PM_HEADERBORDERALL (CTF_PM_HEADERFLAG|CTF_PM_BORDERALL) #define CTF_PM_HEADERBORDERTOP (CTF_PM_HEADERFLAG|CTF_PM_BORDERTOP) diff --git a/xmloff/source/style/PageMasterExportPropMapper.cxx b/xmloff/source/style/PageMasterExportPropMapper.cxx index 3a1c0a080f31..ba0f45b34506 100644 --- a/xmloff/source/style/PageMasterExportPropMapper.cxx +++ b/xmloff/source/style/PageMasterExportPropMapper.cxx @@ -360,7 +360,9 @@ void XMLPageMasterExportPropMapper::ContextFilter( XMLPropertyState* pPMScaleToY = NULL; XMLPropertyState* pPMStandardMode = NULL; XMLPropertyState* pPMGridBaseWidth = NULL; + // same as pPMGridSnapTo but for backward compatibility only XMLPropertyState* pPMGridSnapToChars = NULL; + XMLPropertyState* pPMGridSnapTo = NULL; XMLPropertyState* pPrint = NULL; @@ -421,6 +423,7 @@ void XMLPageMasterExportPropMapper::ContextFilter( case CTF_PM_STANDARD_MODE: pPMStandardMode = pProp; break; case CTP_PM_GRID_BASE_WIDTH: pPMGridBaseWidth = pProp; break; case CTP_PM_GRID_SNAP_TO_CHARS: pPMGridSnapToChars = pProp; break; + case CTP_PM_GRID_SNAP_TO: pPMGridSnapTo = pProp; break; } if (nPrintId == CTF_PM_PRINTMASK) { @@ -436,6 +439,10 @@ void XMLPageMasterExportPropMapper::ContextFilter( lcl_RemoveState(pPMGridBaseWidth); if( pPMGridSnapToChars ) lcl_RemoveState(pPMGridSnapToChars); + if (pPMGridSnapTo) + { + lcl_RemoveState(pPMGridSnapTo); + } } if( pPMGridBaseWidth && pPMStandardMode ) diff --git a/xmloff/source/style/PageMasterStyleMap.cxx b/xmloff/source/style/PageMasterStyleMap.cxx index c4c591604dd9..231ec3706536 100644 --- a/xmloff/source/style/PageMasterStyleMap.cxx +++ b/xmloff/source/style/PageMasterStyleMap.cxx @@ -33,11 +33,15 @@ using namespace ::xmloff::token; -#define _MAP(name,prefix,token,type,context) { name, sizeof(name)-1, prefix, token, type, context, SvtSaveOptions::ODFVER_010 } +#define MAP(name,prefix,token,type,context,version) { name, sizeof(name)-1, prefix, token, type, context, version } #define PLMAP(name,prefix,token,type,context) \ - _MAP(name,prefix,token,type|XML_TYPE_PROP_PAGE_LAYOUT,context) + MAP(name,prefix,token,type|XML_TYPE_PROP_PAGE_LAYOUT,context, SvtSaveOptions::ODFVER_010) +#define PLMAP_12(name,prefix,token,type,context) \ + MAP(name,prefix,token,type|XML_TYPE_PROP_PAGE_LAYOUT,context, SvtSaveOptions::ODFVER_012) +#define PLMAP_EX(name,prefix,token,type,context) \ + MAP(name,prefix,token,type|XML_TYPE_PROP_PAGE_LAYOUT,context, SvtSaveOptions::ODFVER_LATEST) #define HFMAP(name,prefix,token,type,context) \ - _MAP(name,prefix,token,type|XML_TYPE_PROP_HEADER_FOOTER,context) + MAP(name,prefix,token,type|XML_TYPE_PROP_HEADER_FOOTER,context, SvtSaveOptions::ODFVER_010) //______________________________________________________________________________ @@ -108,11 +112,14 @@ const XMLPropertyMapEntry aXMLPageMasterStyleMap[] = PLMAP( "GridDisplay", XML_NAMESPACE_STYLE, XML_LAYOUT_GRID_DISPLAY, XML_TYPE_BOOL, 0 ), //text grid enhancement for better CJK support - PLMAP( "GridBaseWidth", XML_NAMESPACE_STYLE, XML_LAYOUT_GRID_BASE_WIDTH, XML_TYPE_MEASURE, CTP_PM_GRID_BASE_WIDTH ), - PLMAP( "GridSnapToChars", XML_NAMESPACE_STYLE, XML_LAYOUT_GRID_SNAP_TO, XML_TYPE_BOOL, CTP_PM_GRID_SNAP_TO_CHARS ), - PLMAP( "GridSnapToChars", XML_NAMESPACE_STYLE, XML_LAYOUT_GRID_SNAP_TO_CHARS, XML_TYPE_BOOL, CTP_PM_GRID_SNAP_TO_CHARS ), + PLMAP_12( "GridBaseWidth", XML_NAMESPACE_STYLE, XML_LAYOUT_GRID_BASE_WIDTH, XML_TYPE_MEASURE, CTP_PM_GRID_BASE_WIDTH ), + PLMAP_12( "GridSnapToChars", XML_NAMESPACE_STYLE, XML_LAYOUT_GRID_SNAP_TO, XML_TYPE_BOOL, CTP_PM_GRID_SNAP_TO ), + // fdo#44073: layout-grid-snap-to-characters does not exist in ODF: + // write this in extended mode purely for backward compatibility so old + // OOo/LO versions that don't understand layout-grid-snap-to read it + PLMAP_EX( "GridSnapToChars", XML_NAMESPACE_STYLE, XML_LAYOUT_GRID_SNAP_TO_CHARS, XML_TYPE_BOOL, CTP_PM_GRID_SNAP_TO_CHARS ), //export as a default attribute - PLMAP( "StandardPageMode", XML_NAMESPACE_STYLE, XML_LAYOUT_GRID_STANDARD_MODE, XML_TYPE_BOOL|MID_FLAG_DEFAULT_ITEM_EXPORT, CTF_PM_STANDARD_MODE ), + PLMAP_12( "StandardPageMode", XML_NAMESPACE_STYLE, XML_LAYOUT_GRID_STANDARD_MODE, XML_TYPE_BOOL|MID_FLAG_DEFAULT_ITEM_EXPORT, CTF_PM_STANDARD_MODE ), PLMAP( "UserDefinedAttributes", XML_NAMESPACE_TEXT, XML_XMLNS, XML_TYPE_ATTRIBUTE_CONTAINER | MID_FLAG_SPECIAL_ITEM, 0 ), |