diff options
Diffstat (limited to 'xmloff/source/style')
-rw-r--r-- | xmloff/source/style/PagePropertySetContext.cxx | 31 | ||||
-rw-r--r-- | xmloff/source/style/PagePropertySetContext.hxx | 12 | ||||
-rw-r--r-- | xmloff/source/style/XMLBackgroundImageContext.cxx | 57 | ||||
-rw-r--r-- | xmloff/source/style/XMLElementPropertyContext.cxx | 10 | ||||
-rw-r--r-- | xmloff/source/style/XMLFootnoteSeparatorImport.cxx | 47 | ||||
-rw-r--r-- | xmloff/source/style/XMLFootnoteSeparatorImport.hxx | 7 | ||||
-rw-r--r-- | xmloff/source/style/xmlprcon.cxx | 48 | ||||
-rw-r--r-- | xmloff/source/style/xmlprmap.cxx | 32 | ||||
-rw-r--r-- | xmloff/source/style/xmltabi.cxx | 91 |
9 files changed, 163 insertions, 172 deletions
diff --git a/xmloff/source/style/PagePropertySetContext.cxx b/xmloff/source/style/PagePropertySetContext.cxx index 24fbe25bf8c1..31c541f56b35 100644 --- a/xmloff/source/style/PagePropertySetContext.cxx +++ b/xmloff/source/style/PagePropertySetContext.cxx @@ -48,12 +48,11 @@ PagePropertySetContext::~PagePropertySetContext() { } -SvXMLImportContextRef PagePropertySetContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList, - ::std::vector< XMLPropertyState > &rProperties, - const XMLPropertyState& rProp ) +css::uno::Reference< css::xml::sax::XFastContextHandler > PagePropertySetContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList, + ::std::vector< XMLPropertyState > &rProperties, + const XMLPropertyState& rProp ) { sal_Int32 nPos = CTF_PM_GRAPHICPOSITION; sal_Int32 nFil = CTF_PM_GRAPHICFILTER; @@ -74,7 +73,6 @@ SvXMLImportContextRef PagePropertySetContext::CreateChildContext( default: break; } - SvXMLImportContextRef xContext; switch( mxMapper->getPropertySetMapper() ->GetEntryContextId( rProp.mnIndex ) ) @@ -88,9 +86,9 @@ SvXMLImportContextRef PagePropertySetContext::CreateChildContext( nFil == mxMapper->getPropertySetMapper() ->GetEntryContextId( rProp.mnIndex-1 ), "invalid property map!"); - xContext = - new XMLBackgroundImageContext( GetImport(), nPrefix, - rLocalName, xAttrList, + return + new XMLBackgroundImageContext( GetImport(), nElement, + xAttrList, rProp, rProp.mnIndex-2, rProp.mnIndex-1, @@ -100,24 +98,21 @@ SvXMLImportContextRef PagePropertySetContext::CreateChildContext( break; case CTF_PM_TEXTCOLUMNS: - xContext = new XMLTextColumnsContext( GetImport(), nPrefix, - rLocalName, xAttrList, rProp, + return new XMLTextColumnsContext( GetImport(), nElement, + xAttrList, rProp, rProperties ); break; case CTF_PM_FTN_LINE_WEIGHT: - xContext = new XMLFootnoteSeparatorImport( - GetImport(), nPrefix, rLocalName, rProperties, + return new XMLFootnoteSeparatorImport( + GetImport(), nElement, rProperties, mxMapper->getPropertySetMapper(), rProp.mnIndex); break; } - if (!xContext) - xContext = SvXMLPropertySetContext::CreateChildContext( nPrefix, rLocalName, + return SvXMLPropertySetContext::createFastChildContext( nElement, xAttrList, rProperties, rProp ); - - return xContext; } diff --git a/xmloff/source/style/PagePropertySetContext.hxx b/xmloff/source/style/PagePropertySetContext.hxx index b44828b9130a..8d8cb9a2c67c 100644 --- a/xmloff/source/style/PagePropertySetContext.hxx +++ b/xmloff/source/style/PagePropertySetContext.hxx @@ -44,12 +44,12 @@ public: virtual ~PagePropertySetContext() override; - using SvXMLPropertySetContext::CreateChildContext; - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList, - ::std::vector< XMLPropertyState > &rProperties, - const XMLPropertyState& rProp) override; + using SvXMLPropertySetContext::createFastChildContext; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList, + ::std::vector< XMLPropertyState > &rProperties, + const XMLPropertyState& rProp ) override; }; #endif // INCLUDED_XMLOFF_SOURCE_STYLE_PAGEPROPERTYSETCONTEXT_HXX diff --git a/xmloff/source/style/XMLBackgroundImageContext.cxx b/xmloff/source/style/XMLBackgroundImageContext.cxx index e9008326c25d..fdfe43008081 100644 --- a/xmloff/source/style/XMLBackgroundImageContext.cxx +++ b/xmloff/source/style/XMLBackgroundImageContext.cxx @@ -23,7 +23,7 @@ #include <com/sun/star/graphic/XGraphic.hpp> #include <tools/debug.hxx> - +#include <sal/log.hxx> #include <sax/tools/converter.hxx> #include <xmloff/xmltkmap.hxx> @@ -169,37 +169,31 @@ static void lcl_xmlbic_MergeVertPos( GraphicLocation& ePos, void XMLBackgroundImageContext::ProcessAttrs( - const Reference< xml::sax::XAttributeList >& xAttrList ) + const Reference< xml::sax::XFastAttributeList >& xAttrList ) { static const SvXMLTokenMap aTokenMap( aBGImgAttributesAttrTokenMap ); ePos = GraphicLocation_NONE; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; i++ ) + for (auto &aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { - const OUString& rAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = - GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, - &aLocalName ); - const OUString& rValue = xAttrList->getValueByIndex( i ); - - switch( aTokenMap.Get( nPrefix, aLocalName ) ) + const OUString sValue = aIter.toString(); + + switch( aIter.getToken() ) { - case XML_TOK_BGIMG_HREF: - m_sURL = rValue; + case XML_ELEMENT(XLINK, XML_HREF): + m_sURL = sValue; if( GraphicLocation_NONE == ePos ) ePos = GraphicLocation_TILED; break; - case XML_TOK_BGIMG_TYPE: - case XML_TOK_BGIMG_ACTUATE: - case XML_TOK_BGIMG_SHOW: + case XML_ELEMENT(XLINK, XML_TYPE): + case XML_ELEMENT(XLINK, XML_ACTUATE): + case XML_ELEMENT(XLINK, XML_SHOW): break; - case XML_TOK_BGIMG_POSITION: + case XML_ELEMENT(STYLE, XML_POSITION): { GraphicLocation eNewPos = GraphicLocation_NONE, eTmp; - SvXMLTokenEnumerator aTokenEnum( rValue ); + SvXMLTokenEnumerator aTokenEnum( sValue ); OUString aToken; bool bHori = false, bVert = false; bool bOK = true; @@ -283,7 +277,7 @@ void XMLBackgroundImageContext::ProcessAttrs( ePos = eNewPos; } break; - case XML_TOK_BGIMG_REPEAT: + case XML_ELEMENT(STYLE, XML_REPEAT): { GraphicLocation nPos = GraphicLocation_NONE; static const SvXMLEnumMapEntry<GraphicLocation> psXML_BrushRepeat[] = @@ -293,7 +287,7 @@ void XMLBackgroundImageContext::ProcessAttrs( { XML_STRETCH, GraphicLocation_AREA }, { XML_TOKEN_INVALID, GraphicLocation(0) } }; - if( SvXMLUnitConverter::convertEnum( nPos, rValue, + if( SvXMLUnitConverter::convertEnum( nPos, sValue, psXML_BrushRepeat ) ) { if( GraphicLocation_MIDDLE_MIDDLE != nPos || @@ -304,36 +298,37 @@ void XMLBackgroundImageContext::ProcessAttrs( } } break; - case XML_TOK_BGIMG_FILTER: - sFilter = rValue; + case XML_ELEMENT(STYLE, XML_FILTER_NAME): + sFilter = sValue; break; - case XML_TOK_BGIMG_OPACITY: + case XML_ELEMENT(DRAW, XML_OPACITY): { sal_Int32 nTmp; // convert from percent and clip - if (::sax::Converter::convertPercent( nTmp, rValue )) + if (::sax::Converter::convertPercent( nTmp, sValue )) { if( (nTmp >= 0) && (nTmp <= 100) ) nTransparency = static_cast<sal_Int8>( 100-nTmp ); } } break; + default: + SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << sValue); } } } XMLBackgroundImageContext::XMLBackgroundImageContext( - SvXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList, + SvXMLImport& rImport, sal_Int32 nElement, + const Reference< xml::sax::XFastAttributeList > & xAttrList, const XMLPropertyState& rProp, sal_Int32 nPosIdx, sal_Int32 nFilterIdx, sal_Int32 nTransparencyIdx, sal_Int32 nBitmapModeIdx, ::std::vector< XMLPropertyState > &rProps ) : - XMLElementPropertyContext( rImport, nPrfx, rLName, rProp, rProps ), + XMLElementPropertyContext( rImport, nElement, rProp, rProps ), aPosProp( nPosIdx ), m_nBitmapModeIdx(nBitmapModeIdx), aFilterProp( nFilterIdx ), @@ -369,7 +364,7 @@ SvXMLImportContextRef XMLBackgroundImageContext::CreateChildContext( return pContext; } -void XMLBackgroundImageContext::EndElement() +void XMLBackgroundImageContext::endFastElement(sal_Int32 nElement) { uno::Reference<graphic::XGraphic> xGraphic; if (!m_sURL.isEmpty()) @@ -394,7 +389,7 @@ void XMLBackgroundImageContext::EndElement() aTransparencyProp.maValue <<= nTransparency; SetInsert( true ); - XMLElementPropertyContext::EndElement(); + XMLElementPropertyContext::endFastElement(nElement); if( -1 != aPosProp.mnIndex ) { diff --git a/xmloff/source/style/XMLElementPropertyContext.cxx b/xmloff/source/style/XMLElementPropertyContext.cxx index 91af29fe31f4..f065e081d7e3 100644 --- a/xmloff/source/style/XMLElementPropertyContext.cxx +++ b/xmloff/source/style/XMLElementPropertyContext.cxx @@ -21,13 +21,12 @@ XMLElementPropertyContext::XMLElementPropertyContext ( - SvXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, + SvXMLImport& rImport, sal_Int32 /*nElement*/, const XMLPropertyState& rProp, ::std::vector< XMLPropertyState > &rProps ) : - SvXMLImportContext( rImport, nPrfx, rLName ), + SvXMLImportContext( rImport ), bInsert( false ), - rProperties( rProps ), + rProperties( rProps ), aProp( rProp ) { } @@ -36,11 +35,10 @@ XMLElementPropertyContext::~XMLElementPropertyContext() { } -void XMLElementPropertyContext::EndElement( ) +void XMLElementPropertyContext::endFastElement(sal_Int32 ) { if( bInsert ) rProperties.push_back( aProp ); } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/style/XMLFootnoteSeparatorImport.cxx b/xmloff/source/style/XMLFootnoteSeparatorImport.cxx index bd52f3cb45d7..b3a790302acd 100644 --- a/xmloff/source/style/XMLFootnoteSeparatorImport.cxx +++ b/xmloff/source/style/XMLFootnoteSeparatorImport.cxx @@ -55,12 +55,11 @@ using ::com::sun::star::xml::sax::XAttributeList; XMLFootnoteSeparatorImport::XMLFootnoteSeparatorImport( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, + sal_Int32 /*nElement*/, vector<XMLPropertyState> & rProps, const rtl::Reference<XMLPropertySetMapper> & rMapperRef, sal_Int32 nIndex) : - SvXMLImportContext(rImport, nPrefix, rLocalName), + SvXMLImportContext(rImport), rProperties(rProps), rMapper(rMapperRef), nPropIndex(nIndex) @@ -71,8 +70,9 @@ XMLFootnoteSeparatorImport::~XMLFootnoteSeparatorImport() { } -void XMLFootnoteSeparatorImport::StartElement( - const Reference<XAttributeList> & xAttrList) +void XMLFootnoteSeparatorImport::startFastElement( + sal_Int32 /*nElement*/, + const Reference<css::xml::sax::XFastAttributeList> & xAttrList) { // get the values from the properties sal_Int16 nLineWeight = 0; @@ -87,39 +87,36 @@ void XMLFootnoteSeparatorImport::StartElement( sal_Int8 nLineStyle = 1; // iterate over xattribute list and fill values - sal_Int16 nLength = xAttrList->getLength(); - for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++) + for (auto &aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { - OUString sLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). - GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), - &sLocalName ); - - if (XML_NAMESPACE_STYLE == nPrefix) + OUString sAttrValue = aIter.toString(); + sal_Int32 nTmp; + switch (aIter.getToken()) { - OUString sAttrValue = xAttrList->getValueByIndex(nAttr); - sal_Int32 nTmp; - if (IsXMLToken( sLocalName, XML_WIDTH )) + case XML_ELEMENT(STYLE, XML_WIDTH): { if (GetImport().GetMM100UnitConverter().convertMeasureToCore( nTmp, sAttrValue)) { nLineWeight = static_cast<sal_Int16>(nTmp); } + break; } - else if (IsXMLToken( sLocalName, XML_DISTANCE_BEFORE_SEP )) + case XML_ELEMENT(STYLE, XML_DISTANCE_BEFORE_SEP): { if (GetImport().GetMM100UnitConverter().convertMeasureToCore( nTmp, sAttrValue)) nLineTextDistance = nTmp; + break; } - else if (IsXMLToken( sLocalName, XML_DISTANCE_AFTER_SEP )) + case XML_ELEMENT(STYLE, XML_DISTANCE_AFTER_SEP): { if (GetImport().GetMM100UnitConverter().convertMeasureToCore( nTmp, sAttrValue)) nLineDistance = nTmp; + break; } - else if (IsXMLToken( sLocalName, XML_ADJUSTMENT )) + case XML_ELEMENT(STYLE, XML_ADJUSTMENT ): { static const SvXMLEnumMapEntry<text::HorizontalAdjust> aXML_HorizontalAdjust_Enum[] = { @@ -131,20 +128,23 @@ void XMLFootnoteSeparatorImport::StartElement( SvXMLUnitConverter::convertEnum( eLineAdjust, sAttrValue, aXML_HorizontalAdjust_Enum); + break; } - else if (IsXMLToken( sLocalName, XML_REL_WIDTH )) + case XML_ELEMENT(STYLE, XML_REL_WIDTH ): { if (::sax::Converter::convertPercent(nTmp, sAttrValue)) nLineRelWidth = static_cast<sal_uInt8>(nTmp); + break; } - else if (IsXMLToken( sLocalName, XML_COLOR )) + case XML_ELEMENT(STYLE, XML_COLOR): { if (::sax::Converter::convertColor(nTmp, sAttrValue)) { nLineColor = nTmp; } + break; } - else if (IsXMLToken( sLocalName, XML_LINE_STYLE )) + case XML_ELEMENT(STYLE, XML_LINE_STYLE ): { static const SvXMLEnumMapEntry<sal_Int8> aXML_LineStyle_Enum[] = { @@ -156,7 +156,10 @@ void XMLFootnoteSeparatorImport::StartElement( }; SvXMLUnitConverter::convertEnum(nLineStyle, sAttrValue, aXML_LineStyle_Enum); + break; } + default: + SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << sAttrValue); } } diff --git a/xmloff/source/style/XMLFootnoteSeparatorImport.hxx b/xmloff/source/style/XMLFootnoteSeparatorImport.hxx index b17d6927dd17..30772b019fed 100644 --- a/xmloff/source/style/XMLFootnoteSeparatorImport.hxx +++ b/xmloff/source/style/XMLFootnoteSeparatorImport.hxx @@ -48,16 +48,15 @@ public: XMLFootnoteSeparatorImport( SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, + sal_Int32 nElement, ::std::vector<XMLPropertyState> & rProperties, const rtl::Reference<XMLPropertySetMapper> & rMapperRef, sal_Int32 nIndex); virtual ~XMLFootnoteSeparatorImport() override; - virtual void StartElement( - const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList ) override; + virtual void SAL_CALL startFastElement( sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override; }; #endif diff --git a/xmloff/source/style/xmlprcon.cxx b/xmloff/source/style/xmlprcon.cxx index 40073803e993..119e5bb86c17 100644 --- a/xmloff/source/style/xmlprcon.cxx +++ b/xmloff/source/style/xmlprcon.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/log.hxx> #include <xmloff/xmlprcon.hxx> #include <xmloff/xmlimp.hxx> #include <xmloff/xmltypes.hxx> @@ -28,27 +29,6 @@ using namespace ::com::sun::star; using namespace ::std; SvXMLPropertySetContext::SvXMLPropertySetContext( - SvXMLImport& rImp, sal_uInt16 nPrfx, - const OUString& rLName, - const uno::Reference< xml::sax::XAttributeList >& xAttrList, - sal_uInt32 nFam, - vector< XMLPropertyState > &rProps, - const rtl::Reference < SvXMLImportPropertyMapper > &rMap, - sal_Int32 nSIdx, sal_Int32 nEIdx ) -: SvXMLImportContext( rImp, nPrfx, rLName ) -, mnStartIdx( nSIdx ) -, mnEndIdx( nEIdx ) -, mnFamily( nFam ) -, mrProperties( rProps ) -, mxMapper( rMap ) -{ - mxMapper->importXML( mrProperties, xAttrList, - GetImport().GetMM100UnitConverter(), - GetImport().GetNamespaceMap(), mnFamily, - mnStartIdx, mnEndIdx ); -} - -SvXMLPropertySetContext::SvXMLPropertySetContext( SvXMLImport& rImp, sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList, sal_uInt32 nFam, @@ -72,24 +52,22 @@ SvXMLPropertySetContext::~SvXMLPropertySetContext() { } -SvXMLImportContextRef SvXMLPropertySetContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList >& xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > SvXMLPropertySetContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList) { rtl::Reference< XMLPropertySetMapper > aSetMapper( mxMapper->getPropertySetMapper() ); - sal_Int32 nEntryIndex = aSetMapper->GetEntryIndex( nPrefix, rLocalName, - mnFamily, mnStartIdx ); + sal_Int32 nEntryIndex = aSetMapper->GetEntryIndex( nElement, mnFamily, mnStartIdx ); if( ( nEntryIndex != -1 ) && (-1 == mnEndIdx || nEntryIndex < mnEndIdx ) && ( 0 != ( aSetMapper->GetEntryFlags( nEntryIndex ) & MID_FLAG_ELEMENT_ITEM_IMPORT ) ) ) { XMLPropertyState aProp( nEntryIndex ); - return CreateChildContext( nPrefix, rLocalName, xAttrList, - mrProperties, aProp ); + return createFastChildContext( nElement, xAttrList, mrProperties, aProp ); } + SAL_WARN("xmloff", "unknown element " << SvXMLImport::getPrefixAndNameFromToken(nElement)); return nullptr; } @@ -97,13 +75,13 @@ SvXMLImportContextRef SvXMLPropertySetContext::CreateChildContext( CreateChildContext if the element matches an entry in the SvXMLImportItemMapper with the mid flag MID_FLAG_ELEMENT */ -SvXMLImportContextRef SvXMLPropertySetContext::CreateChildContext( - sal_uInt16 /*nPrefix*/, - const OUString& /*rLocalName*/, - const uno::Reference< xml::sax::XAttributeList >&, - ::std::vector< XMLPropertyState > &, - const XMLPropertyState& ) +css::uno::Reference< css::xml::sax::XFastContextHandler > SvXMLPropertySetContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/, + ::std::vector< XMLPropertyState > &/*rProperties*/, + const XMLPropertyState& /*rProp*/ ) { + SAL_WARN("xmloff", "unknown element " << SvXMLImport::getPrefixAndNameFromToken(nElement)); return nullptr; } diff --git a/xmloff/source/style/xmlprmap.cxx b/xmloff/source/style/xmlprmap.cxx index b00529bc2f21..7d81ad0f3456 100644 --- a/xmloff/source/style/xmlprmap.cxx +++ b/xmloff/source/style/xmlprmap.cxx @@ -25,6 +25,7 @@ #include <xmloff/xmltoken.hxx> #include <xmloff/maptype.hxx> #include <xmloff/prhdlfac.hxx> +#include <xmloff/xmlimp.hxx> #include <com/sun/star/beans/XPropertySet.hpp> @@ -270,6 +271,37 @@ sal_Int32 XMLPropertySetMapper::GetEntryIndex( return -1; } +// Search for the given name and the namespace in the list and return +// the index of the entry +// If there is no matching entry the method returns -1 +sal_Int32 XMLPropertySetMapper::GetEntryIndex( + sal_Int32 nElement, + sal_uInt32 nPropType, + sal_Int32 nStartAt /* = -1 */ ) const +{ + sal_Int32 nEntries = GetEntryCount(); + sal_Int32 nIndex= nStartAt == - 1? 0 : nStartAt+1; + + if ( nEntries && nIndex < nEntries ) + { + sal_uInt16 nNamespace = (nElement >> NMSP_SHIFT) - 1; + const OUString& rStrName = SvXMLImport::getNameFromToken(nElement); + do + { + const XMLPropertySetMapperEntry_Impl& rEntry = mpImpl->maMapEntries[nIndex]; + if( (!nPropType || nPropType == rEntry.GetPropType()) && + rEntry.nXMLNameSpace == nNamespace && + rStrName == rEntry.sXMLAttributeName ) + return nIndex; + else + nIndex++; + + } while( nIndex<nEntries ); + } + + return -1; +} + /** searches for an entry that matches the given api name, namespace and local name or -1 if nothing found */ sal_Int32 XMLPropertySetMapper::FindEntryIndex( const char* sApiName, diff --git a/xmloff/source/style/xmltabi.cxx b/xmloff/source/style/xmltabi.cxx index 86ded9f2dc19..20b71a3fd494 100644 --- a/xmloff/source/style/xmltabi.cxx +++ b/xmloff/source/style/xmltabi.cxx @@ -18,6 +18,7 @@ */ #include <com/sun/star/style/TabAlign.hpp> +#include <sal/log.hxx> #include <xmloff/xmltkmap.hxx> #include <xmloff/namespacemap.hxx> #include <xmloff/xmlnamespace.hxx> @@ -62,19 +63,17 @@ private: public: - SvxXMLTabStopContext_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ); + SvxXMLTabStopContext_Impl( SvXMLImport& rImport, sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList > & xAttrList ); const style::TabStop& getTabStop() const { return aTabStop; } }; SvxXMLTabStopContext_Impl::SvxXMLTabStopContext_Impl( - SvXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ) -: SvXMLImportContext( rImport, nPrfx, rLName ) + SvXMLImport& rImport, sal_Int32 /*nElement*/, + const uno::Reference< xml::sax::XFastAttributeList > & xAttrList ) +: SvXMLImportContext( rImport ) { aTabStop.Position = 0; aTabStop.Alignment = style::TabAlign_LEFT; @@ -84,64 +83,60 @@ SvxXMLTabStopContext_Impl::SvxXMLTabStopContext_Impl( static const SvXMLTokenMap aTokenMap( aTabsAttributesAttrTokenMap ); - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; i++ ) + for (auto &aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { - const OUString& rAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = - GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, - &aLocalName ); - const OUString& rValue = xAttrList->getValueByIndex( i ); + const OUString sValue = aIter.toString(); sal_Int32 nVal; - switch( aTokenMap.Get( nPrefix, aLocalName ) ) + switch( aIter.getToken() ) { - case XML_TOK_TABSTOP_POSITION: + case XML_ELEMENT(STYLE, XML_POSITION): if (GetImport().GetMM100UnitConverter().convertMeasureToCore( - nVal, rValue)) + nVal, sValue)) { aTabStop.Position = nVal; } break; - case XML_TOK_TABSTOP_TYPE: - if( IsXMLToken( rValue, XML_LEFT ) ) + case XML_ELEMENT(STYLE, XML_TYPE): + if( IsXMLToken( sValue, XML_LEFT ) ) { aTabStop.Alignment = style::TabAlign_LEFT; } - else if( IsXMLToken( rValue, XML_RIGHT ) ) + else if( IsXMLToken( sValue, XML_RIGHT ) ) { aTabStop.Alignment = style::TabAlign_RIGHT; } - else if( IsXMLToken( rValue, XML_CENTER ) ) + else if( IsXMLToken( sValue, XML_CENTER ) ) { aTabStop.Alignment = style::TabAlign_CENTER; } - else if( IsXMLToken( rValue, XML_CHAR ) ) + else if( IsXMLToken( sValue, XML_CHAR ) ) { aTabStop.Alignment = style::TabAlign_DECIMAL; } - else if( IsXMLToken( rValue, XML_DEFAULT ) ) + else if( IsXMLToken( sValue, XML_DEFAULT ) ) { aTabStop.Alignment = style::TabAlign_DEFAULT; } break; - case XML_TOK_TABSTOP_CHAR: - if( !rValue.isEmpty() ) - aTabStop.DecimalChar = rValue[0]; + case XML_ELEMENT(STYLE, XML_CHAR): + if( !sValue.isEmpty() ) + aTabStop.DecimalChar = sValue[0]; break; - case XML_TOK_TABSTOP_LEADER_STYLE: - if( IsXMLToken( rValue, XML_NONE ) ) + case XML_ELEMENT(STYLE, XML_LEADER_STYLE): + if( IsXMLToken( sValue, XML_NONE ) ) aTabStop.FillChar = ' '; - else if( IsXMLToken( rValue, XML_DOTTED ) ) + else if( IsXMLToken( sValue, XML_DOTTED ) ) aTabStop.FillChar = '.'; else aTabStop.FillChar = '_'; break; - case XML_TOK_TABSTOP_LEADER_TEXT: - if( !rValue.isEmpty() ) - cTextFillChar = rValue[0]; + case XML_ELEMENT(STYLE, XML_LEADER_TEXT): + if( !sValue.isEmpty() ) + cTextFillChar = sValue[0]; break; + default: + SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << sValue); } } @@ -151,27 +146,22 @@ SvxXMLTabStopContext_Impl::SvxXMLTabStopContext_Impl( SvxXMLTabStopImportContext::SvxXMLTabStopImportContext( - SvXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, + SvXMLImport& rImport, sal_Int32 nElement, const XMLPropertyState& rProp, ::std::vector< XMLPropertyState > &rProps ) -: XMLElementPropertyContext( rImport, nPrfx, rLName, rProp, rProps ) +: XMLElementPropertyContext( rImport, nElement, rProp, rProps ) { } -SvXMLImportContextRef SvxXMLTabStopImportContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > SvxXMLTabStopImportContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList) { - SvXMLImportContext *pContext = nullptr; - - if( XML_NAMESPACE_STYLE == nPrefix && IsXMLToken( rLocalName, XML_TAB_STOP ) ) + if( nElement == XML_ELEMENT(STYLE, XML_TAB_STOP) ) { // create new tabstop import context const rtl::Reference<SvxXMLTabStopContext_Impl> xTabStopContext{ - new SvxXMLTabStopContext_Impl( GetImport(), nPrefix, rLocalName, - xAttrList )}; + new SvxXMLTabStopContext_Impl( GetImport(), nElement, xAttrList )}; // add new tabstop to array of tabstops if( !mpTabStops ) @@ -179,13 +169,15 @@ SvXMLImportContextRef SvxXMLTabStopImportContext::CreateChildContext( mpTabStops->push_back( xTabStopContext ); - pContext = xTabStopContext.get(); + return xTabStopContext.get(); } + else + SAL_WARN("xmloff", "unknown element " << SvXMLImport::getPrefixAndNameFromToken(nElement)); - return pContext; + return nullptr; } -void SvxXMLTabStopImportContext::EndElement( ) +void SvxXMLTabStopImportContext::endFastElement(sal_Int32 nElement) { sal_uInt16 nCount = mpTabStops ? mpTabStops->size() : 0; uno::Sequence< style::TabStop> aSeq( nCount ); @@ -215,8 +207,7 @@ void SvxXMLTabStopImportContext::EndElement( ) aProp.maValue <<= aSeq; SetInsert( true ); - XMLElementPropertyContext::EndElement(); - + XMLElementPropertyContext::endFastElement(nElement); } |