include/xmloff/txtimppr.hxx | 5 +- include/xmloff/txtprmap.hxx | 1 include/xmloff/xmlimppr.hxx | 5 +- sc/source/filter/xml/xmlstyli.cxx | 12 ++++-- sc/source/filter/xml/xmlstyli.hxx | 8 ++-- xmloff/inc/XMLChartPropertySetMapper.hxx | 5 +- xmloff/qa/unit/data/tdf156707_text_form_control_borders.odt |binary xmloff/source/chart/PropertyMaps.cxx | 4 +- xmloff/source/draw/sdpropls.cxx | 2 - xmloff/source/forms/controlpropertyhdl.cxx | 7 ---- xmloff/source/style/PageMasterImportPropMapper.cxx | 6 ++- xmloff/source/style/PageMasterImportPropMapper.hxx | 5 +- xmloff/source/style/xmlimppr.cxx | 10 ++--- xmloff/source/text/txtimppr.cxx | 21 ++++++++++-- 14 files changed, 53 insertions(+), 38 deletions(-)
New commits: commit d4dad2e181fd2dc30c3916fd59c05745023a51c8 Author: Justin Luth <jl...@mail.com> AuthorDate: Wed May 21 07:36:27 2025 -0400 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu May 22 08:39:20 2025 +0200 tdf#156707 xmloff import: always provide ControlBorder property #2 In LO 7.5, ORichTextModel changed the app default to use a flat border (in order to better match how PDF/print looks) while the file-spec's default for undefined borders is 3d, so during import time we ALWAYS need to specify 3d as the border. The patch replaces 25.2 commit 5a617f77ee803eb65051e93f659ef66433879052 tdf#156707 xmloff import: always provide ControlBorder property which wasn't wrong, but just was incomplete. It only handled the situation where there was a fo:border element which didn't specify 3d/flat/none, but didn't handle the situation where there was no fo:border at all in style:graphic-properties. [On export, since the 3d property is the default value, fo:border is not even provided as something to be exported, and therefore only "solid" and "none" are ever exported as fo:border qualifiers.] I modified the unit test to remove the fo:border by clearing the unused-by-3d green border colour (although the green was seen if the wrong flat border was assigned). make CppunitTest_xmloff_style CPPUNIT_TEST_NAME=testTdf156707 Change-Id: I70718fe964a7c3578f8edbf8591fe2e3417ec60b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185619 Reviewed-by: Justin Luth <jl...@mail.com> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/include/xmloff/txtimppr.hxx b/include/xmloff/txtimppr.hxx index ca01450d825f..7078ec499f57 100644 --- a/include/xmloff/txtimppr.hxx +++ b/include/xmloff/txtimppr.hxx @@ -60,9 +60,8 @@ public: virtual ~XMLTextImportPropertyMapper() override; /** This method is called when all attributes have benn processed. It may be used to remove items that are incomplete */ - virtual void finished( - ::std::vector< XMLPropertyState >& rProperties, - sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const override; + virtual void finished(std::vector<XMLPropertyState>& rProperties, sal_Int32 nStartIndex, + sal_Int32 nEndIndex, const sal_uInt32 nPropType) const override; }; #endif // INCLUDED_XMLOFF_TXTIMPPR_HXX diff --git a/include/xmloff/txtprmap.hxx b/include/xmloff/txtprmap.hxx index 9efbb085688c..ab2cdb173424 100644 --- a/include/xmloff/txtprmap.hxx +++ b/include/xmloff/txtprmap.hxx @@ -204,6 +204,7 @@ #define CTF_FILLCOLOR (XML_TEXT_CTF_START + 174) #define CTF_PAGENUMBEROFFSET (XML_TEXT_CTF_START + 175) #define CTF_COMPLEX_COLOR (XML_TEXT_CTF_START + 176) +#define CTF_CONTROL_BORDER (XML_TEXT_CTF_START + 177) enum class TextPropMap { TEXT = 0, diff --git a/include/xmloff/xmlimppr.hxx b/include/xmloff/xmlimppr.hxx index 92f195586601..246d6de6aae6 100644 --- a/include/xmloff/xmlimppr.hxx +++ b/include/xmloff/xmlimppr.hxx @@ -112,9 +112,8 @@ public: const SvXMLNamespaceMap& rNamespaceMap ) const; /** This method is called when all attributes have benn processed. It may be used to remove items that are incomplete */ - virtual void finished( - ::std::vector< XMLPropertyState >& rProperties, - sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const; + virtual void finished(std::vector<XMLPropertyState>& rProperties, sal_Int32 nStartIndex, + sal_Int32 nEndIndex, const sal_uInt32 nPropType) const; void CheckSpecialContext( const ::std::vector< XMLPropertyState >& rProperties, diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx index 61e069401a19..b224c02d9b2f 100644 --- a/sc/source/filter/xml/xmlstyli.cxx +++ b/sc/source/filter/xml/xmlstyli.cxx @@ -76,14 +76,16 @@ ScXMLCellImportPropertyMapper::~ScXMLCellImportPropertyMapper() { } -void ScXMLCellImportPropertyMapper::finished(::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const +void ScXMLCellImportPropertyMapper::finished(std::vector<XMLPropertyState>& rProperties, + sal_Int32 nStartIndex, sal_Int32 nEndIndex, + const sal_uInt32 nPropType) const { static const sal_Int16 aPaddingCTF[4] = { CTF_SC_LEFTPADDING, CTF_SC_RIGHTPADDING, CTF_SC_TOPPADDING, CTF_SC_BOTTOMPADDING }; static const sal_Int16 aBorderCTF[4] = { CTF_SC_LEFTBORDER, CTF_SC_RIGHTBORDER, CTF_SC_TOPBORDER, CTF_SC_BOTTOMBORDER }; - SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex); + SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex, nPropType); XMLPropertyState* pAllPaddingProperty(nullptr); XMLPropertyState* pPadding[4] = { nullptr, nullptr, nullptr, nullptr }; XMLPropertyState* pNewPadding[4] = { nullptr, nullptr, nullptr, nullptr }; @@ -217,9 +219,11 @@ ScXMLRowImportPropertyMapper::~ScXMLRowImportPropertyMapper() { } -void ScXMLRowImportPropertyMapper::finished(::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const +void ScXMLRowImportPropertyMapper::finished(std::vector<XMLPropertyState>& rProperties, + sal_Int32 nStartIndex, sal_Int32 nEndIndex, + const sal_uInt32 nPropType) const { - SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex); + SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex, nPropType); XMLPropertyState* pHeight(nullptr); XMLPropertyState* pOptimalHeight(nullptr); XMLPropertyState* pPageBreak(nullptr); diff --git a/sc/source/filter/xml/xmlstyli.hxx b/sc/source/filter/xml/xmlstyli.hxx index 00749c4496b5..1d47ee618d0b 100644 --- a/sc/source/filter/xml/xmlstyli.hxx +++ b/sc/source/filter/xml/xmlstyli.hxx @@ -44,8 +44,8 @@ public: virtual ~ScXMLCellImportPropertyMapper() override; /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */ - virtual void finished( - ::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const override; + virtual void finished(std::vector<XMLPropertyState>& rProperties, sal_Int32 nStartIndex, + sal_Int32 nEndIndex, const sal_uInt32 nPropType) const override; }; class ScXMLRowImportPropertyMapper : public SvXMLImportPropertyMapper @@ -60,8 +60,8 @@ public: virtual ~ScXMLRowImportPropertyMapper() override; /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */ - virtual void finished( - ::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const override; + virtual void finished(std::vector<XMLPropertyState>& rProperties, sal_Int32 nStartIndex, + sal_Int32 nEndIndex, const sal_uInt32 nPropType) const override; }; class XMLTableStylesContext; diff --git a/xmloff/inc/XMLChartPropertySetMapper.hxx b/xmloff/inc/XMLChartPropertySetMapper.hxx index 835dd3cc9a6c..5aeb4ee6706b 100644 --- a/xmloff/inc/XMLChartPropertySetMapper.hxx +++ b/xmloff/inc/XMLChartPropertySetMapper.hxx @@ -94,9 +94,8 @@ public: const SvXMLUnitConverter& rUnitConverter, const SvXMLNamespaceMap& rNamespaceMap ) const override; - virtual void finished( - ::std::vector< XMLPropertyState >& rProperties, - sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const override; + virtual void finished(std::vector<XMLPropertyState>& rProperties, sal_Int32 nStartIndex, + sal_Int32 nEndIndex, const sal_uInt32 nPropType) const override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/qa/unit/data/tdf156707_text_form_control_borders.odt b/xmloff/qa/unit/data/tdf156707_text_form_control_borders.odt index 680832ef347d..56a4433137cb 100644 Binary files a/xmloff/qa/unit/data/tdf156707_text_form_control_borders.odt and b/xmloff/qa/unit/data/tdf156707_text_form_control_borders.odt differ diff --git a/xmloff/source/chart/PropertyMaps.cxx b/xmloff/source/chart/PropertyMaps.cxx index 141a67f35fc7..8ec82c5b0479 100644 --- a/xmloff/source/chart/PropertyMaps.cxx +++ b/xmloff/source/chart/PropertyMaps.cxx @@ -1050,7 +1050,9 @@ bool XMLChartImportPropertyMapper::handleSpecialItem( return bRet; } -void XMLChartImportPropertyMapper::finished( ::std::vector< XMLPropertyState >& /*rProperties*/, sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const +void XMLChartImportPropertyMapper::finished(std::vector<XMLPropertyState>& /*rProperties*/, + sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/, + const sal_uInt32 /*nPropMap*/) const { } diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx index 2a987ad78e6c..6706cf1400f2 100644 --- a/xmloff/source/draw/sdpropls.cxx +++ b/xmloff/source/draw/sdpropls.cxx @@ -289,7 +289,7 @@ const XMLPropertyMapEntry aXMLSDProperties[] = // control attributes (border exists one more time for the text additions of shapes) GMAP( PROP_ControlSymbolColor, XML_NAMESPACE_DRAW, XML_SYMBOL_COLOR, XML_TYPE_COLOR, 0 ), GMAP( PROP_ControlBackground, XML_NAMESPACE_FO, XML_BACKGROUND_COLOR, XML_TYPE_COLOR|MID_FLAG_MULTI_PROPERTY, 0 ), - GMAP( PROP_ControlBorder, XML_NAMESPACE_FO, XML_BORDER, XML_SD_TYPE_CONTROL_BORDER|MID_FLAG_MULTI_PROPERTY|MID_FLAG_MERGE_ATTRIBUTE, 0 ), + GMAP( PROP_ControlBorder, XML_NAMESPACE_FO, XML_BORDER, XML_SD_TYPE_CONTROL_BORDER|MID_FLAG_MULTI_PROPERTY|MID_FLAG_MERGE_ATTRIBUTE, CTF_CONTROL_BORDER ), GMAP( PROP_ControlBorderColor, XML_NAMESPACE_FO, XML_BORDER, XML_SD_TYPE_CONTROL_BORDER_COLOR|MID_FLAG_MULTI_PROPERTY|MID_FLAG_MERGE_ATTRIBUTE, 0 ), GMAP( PROP_ControlDataStyle, XML_NAMESPACE_STYLE,XML_DATA_STYLE_NAME, XML_TYPE_STRING|MID_FLAG_NO_PROPERTY_EXPORT|MID_FLAG_SPECIAL_ITEM, CTF_SD_CONTROL_SHAPE_DATA_STYLE ), GMAP( PROP_ControlTextEmphasis, XML_NAMESPACE_STYLE,XML_TEXT_EMPHASIZE, XML_TYPE_CONTROL_TEXT_EMPHASIZE, 0 ), diff --git a/xmloff/source/forms/controlpropertyhdl.cxx b/xmloff/source/forms/controlpropertyhdl.cxx index eceb9e67aab3..162fb0cbe82b 100644 --- a/xmloff/source/forms/controlpropertyhdl.cxx +++ b/xmloff/source/forms/controlpropertyhdl.cxx @@ -212,13 +212,8 @@ namespace xmloff if ( SvXMLUnitConverter::convertEnum( nStyle, sToken, aBorderTypeMap ) ) { _rValue <<= nStyle; + return true; } - else - { - // The internal LO default is flat, which deviates from the import default of 3d - _rValue <<= sal_uInt16(1); - } - return true; } // try interpreting it as color value diff --git a/xmloff/source/style/PageMasterImportPropMapper.cxx b/xmloff/source/style/PageMasterImportPropMapper.cxx index 2b3a5cb209e1..f0d1db882075 100644 --- a/xmloff/source/style/PageMasterImportPropMapper.cxx +++ b/xmloff/source/style/PageMasterImportPropMapper.cxx @@ -85,9 +85,11 @@ bool PageMasterImportPropertyMapper::handleSpecialItem( } -void PageMasterImportPropertyMapper::finished(std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const +void PageMasterImportPropertyMapper::finished(std::vector<XMLPropertyState>& rProperties, + sal_Int32 nStartIndex, sal_Int32 nEndIndex, + const sal_uInt32 nPropType) const { - SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex); + SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex, nPropType); XMLPropertyState* pAllPaddingProperty = nullptr; XMLPropertyState* pPadding[4] = { nullptr, nullptr, nullptr, nullptr }; XMLPropertyState* pNewPadding[4] = { nullptr, nullptr, nullptr, nullptr }; diff --git a/xmloff/source/style/PageMasterImportPropMapper.hxx b/xmloff/source/style/PageMasterImportPropMapper.hxx index 1493ffd6b96e..90c22f32d7a6 100644 --- a/xmloff/source/style/PageMasterImportPropMapper.hxx +++ b/xmloff/source/style/PageMasterImportPropMapper.hxx @@ -45,9 +45,8 @@ public: const SvXMLNamespaceMap& rNamespaceMap ) const override; /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */ - virtual void finished( - ::std::vector< XMLPropertyState >& rProperties, - sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const override; + virtual void finished(std::vector<XMLPropertyState>& rProperties, sal_Int32 nStartIndex, + sal_Int32 nEndIndex, const sal_uInt32 nPropType) const override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/style/xmlimppr.cxx b/xmloff/source/style/xmlimppr.cxx index ef4b2bb24513..7869bc49d42c 100644 --- a/xmloff/source/style/xmlimppr.cxx +++ b/xmloff/source/style/xmlimppr.cxx @@ -155,7 +155,7 @@ void SvXMLImportPropertyMapper::importXML( rAttribute.Name, rAttribute.NamespaceURL, rAttribute.Value); } - finished( rProperties, nStartIdx, nEndIdx ); + finished(rProperties, nStartIdx, nEndIdx, nPropType); } void SvXMLImportPropertyMapper::importXMLAttribute( @@ -747,13 +747,13 @@ bool SvXMLImportPropertyMapper::FillTolerantMultiPropertySet_( return bSuccessful; } -void SvXMLImportPropertyMapper::finished( - std::vector< XMLPropertyState >& rProperties, - sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const +void SvXMLImportPropertyMapper::finished(std::vector<XMLPropertyState>& rProperties, + sal_Int32 nStartIndex, sal_Int32 nEndIndex, + const sal_uInt32 nPropType) const { // nothing to do here if( mxNextMapper ) - mxNextMapper->finished( rProperties, nStartIndex, nEndIndex ); + mxNextMapper->finished(rProperties, nStartIndex, nEndIndex, nPropType); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx index 7fde78724227..0513be2445f3 100644 --- a/xmloff/source/text/txtimppr.cxx +++ b/xmloff/source/text/txtimppr.cxx @@ -33,6 +33,8 @@ #include <xmloff/txtimppr.hxx> #include <xmloff/maptype.hxx> +#include <xmlsdtypes.hxx> + #define XML_LINE_LEFT 0 #define XML_LINE_RIGHT 1 #define XML_LINE_TOP 2 @@ -347,14 +349,15 @@ void lcl_SeparateBorder( } -void XMLTextImportPropertyMapper::finished( - ::std::vector< XMLPropertyState >& rProperties, - sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const +void XMLTextImportPropertyMapper::finished(std::vector<XMLPropertyState>& rProperties, + sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/, + const sal_uInt32 nPropType) const { bool bHasAnyHeight = false; bool bHasAnyMinHeight = false; bool bHasAnyWidth = false; bool bHasAnyMinWidth = false; + bool bHasControlBorder = false; XMLPropertyState* pFontFamilyName = nullptr; XMLPropertyState* pFontStyleName = nullptr; @@ -420,6 +423,8 @@ void XMLTextImportPropertyMapper::finished( switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ) ) { + case CTF_CONTROL_BORDER: bHasControlBorder = true; break; + case CTF_FONTFAMILYNAME: pFontFamilyName = property; break; case CTF_FONTSTYLENAME: pFontStyleName = property; break; case CTF_FONTFAMILY: pFontFamily = property; break; @@ -781,6 +786,16 @@ void XMLTextImportPropertyMapper::finished( } } + // The internal LO default (app) is flat (at least for the ORichTextModel), + // which deviates from the import default (file) of 3d - so always provide as a property + if (!bHasControlBorder && nPropType == XML_TYPE_PROP_GRAPHIC) + { + const sal_Int32 nIndex = getPropertySetMapper()->FindEntryIndex(CTF_CONTROL_BORDER); + XMLPropertyState aControlBorderState(nIndex); + aControlBorderState.maValue <<= static_cast<sal_uInt16>(1); // 3d + rProperties.push_back(aControlBorderState); + } + if( bHasAnyHeight ) { if( m_nSizeTypeIndex == -2 )