diff options
-rw-r--r-- | include/xmloff/xmltoken.hxx | 6 | ||||
-rw-r--r-- | svx/source/inc/xmlxtimp.hxx | 5 | ||||
-rw-r--r-- | svx/source/xml/xmlxtimp.cxx | 108 | ||||
-rw-r--r-- | xmloff/source/core/xmltoken.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/style/ImageStyle.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/token/tokens.txt | 6 |
6 files changed, 86 insertions, 47 deletions
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index 1175958548ff..f6695d54de3e 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -314,6 +314,7 @@ namespace xmloff { namespace token { XML_BIBLIOGRAPHY_TYPE, XML_BIND_STYLES_TO_CONTENT, XML_BITMAP, + XML_BITMAP_TABLE, XML_BLACK, XML_BLEND, XML_BLINKING, @@ -435,6 +436,7 @@ namespace xmloff { namespace token { XML_COLOR_MODE, XML_COLOR_SCALE, XML_COLOR_SCALE_ENTRY, + XML_COLOR_TABLE, XML_COLUMN, XML_COLUMN_COUNT, XML_COLUMN_GAP, @@ -546,6 +548,7 @@ namespace xmloff { namespace token { XML_DASH, XML_DASH_DOT, XML_DASH_DOT_DOT, + XML_DASH_TABLE, XML_DASHED, XML_DATA, XML_DATA_BAR, @@ -930,6 +933,7 @@ namespace xmloff { namespace token { XML_GRADIENT_BORDER, XML_GRADIENT_STEP_COUNT, XML_GRADIENT_STYLE, + XML_GRADIENT_TABLE, XML_GRADIENTSTYLE_AXIAL, XML_GRADIENTSTYLE_ELLIPSOID, XML_GRADIENTSTYLE_LINEAR, @@ -956,6 +960,7 @@ namespace xmloff { namespace token { XML_HATCH, XML_HATCH_DISTANCE, XML_HATCH_STYLE, + XML_HATCH_TABLE, XML_HATCHSTYLE_DOUBLE, XML_HATCHSTYLE_SINGLE, XML_HATCHSTYLE_TRIPLE, @@ -1197,6 +1202,7 @@ namespace xmloff { namespace token { XML_MARKER_START, XML_MARKER_START_CENTER, XML_MARKER_START_WIDTH, + XML_MARKER_TABLE, XML_MAROON, XML_MASTER_PAGE, XML_MASTER_PAGE_NAME, diff --git a/svx/source/inc/xmlxtimp.hxx b/svx/source/inc/xmlxtimp.hxx index 600b32f23adc..e52e8b0178f3 100644 --- a/svx/source/inc/xmlxtimp.hxx +++ b/svx/source/inc/xmlxtimp.hxx @@ -45,9 +45,8 @@ public: const css::uno::Reference< css::container::XNameContainer >& xTable, bool *bOptLoadedFromStorage ) throw(); protected: - virtual SvXMLImportContext *CreateDocumentContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override; + virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element, + const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList ) override; private: const css::uno::Reference< css::container::XNameContainer > & mrTable; diff --git a/svx/source/xml/xmlxtimp.cxx b/svx/source/xml/xmlxtimp.cxx index 548f3c7009aa..8bd042570309 100644 --- a/svx/source/xml/xmlxtimp.cxx +++ b/svx/source/xml/xmlxtimp.cxx @@ -52,6 +52,7 @@ #include <xmloff/attrlist.hxx> #include <xmlxtimp.hxx> +#include <tools/diagnose_ex.h> #include <cstdio> @@ -72,10 +73,15 @@ enum class SvxXMLTableImportContextEnum { Color, Marker, Dash, Hatch, Gradient, class SvxXMLTableImportContext : public SvXMLImportContext { public: - SvxXMLTableImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, SvxXMLTableImportContextEnum eContext, const uno::Reference< XNameContainer >& xTable, + SvxXMLTableImportContext( SvXMLImport& rImport, SvxXMLTableImportContextEnum eContext, const uno::Reference< XNameContainer >& xTable, bool bOOoFormat ); - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList ) override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext(sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override; protected: void importColor( const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName ); @@ -93,27 +99,36 @@ private: } -SvxXMLTableImportContext::SvxXMLTableImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, SvxXMLTableImportContextEnum eContext, const uno::Reference< XNameContainer >& xTable, bool bOOoFormat ) -: SvXMLImportContext( rImport, nPrfx, rLName ), mxTable( xTable ), meContext( eContext ), +SvxXMLTableImportContext::SvxXMLTableImportContext( SvXMLImport& rImport, SvxXMLTableImportContextEnum eContext, const uno::Reference< XNameContainer >& xTable, bool bOOoFormat ) +: SvXMLImportContext( rImport ), mxTable( xTable ), meContext( eContext ), mbOOoFormat( bOOoFormat ) { } -SvXMLImportContextRef SvxXMLTableImportContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< XAttributeList >& rAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > + SvxXMLTableImportContext::createFastChildContext(sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & rAttrList) { - if( XML_NAMESPACE_DRAW == nPrefix ) + sal_Int32 nNamespace = nElement & NMSP_MASK; + if( NAMESPACE_TOKEN(XML_NAMESPACE_DRAW) == nNamespace || + NAMESPACE_TOKEN(XML_NAMESPACE_DRAW_OOO) == nNamespace ) { - uno::Reference< XAttributeList > xAttrList( rAttrList ); + sax_fastparser::FastAttributeList *pFastAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( rAttrList ); + SvXMLAttributeList *pAttrList = new SvXMLAttributeList; + for (auto& aIter : *pFastAttribList) + pAttrList->AddAttribute( + SvXMLImport::getNamespacePrefixFromToken(aIter.getToken(), nullptr) + ":" + + GetXMLToken(static_cast<XMLTokenEnum>(aIter.getToken() & TOKEN_MASK)), + aIter.toString()); if( mbOOoFormat && (SvxXMLTableImportContextEnum::Dash == meContext || SvxXMLTableImportContextEnum::Hatch == meContext || SvxXMLTableImportContextEnum::Bitmap == meContext) ) { - SvXMLAttributeList *pAttrList = new SvXMLAttributeList( rAttrList ); - xAttrList = pAttrList; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + sal_Int16 nAttrCount = pAttrList->getLength(); for( sal_Int16 i=0; i < nAttrCount; i++ ) { - const OUString& rAttrName = xAttrList->getNameByIndex( i ); + const OUString& rAttrName = pAttrList->getNameByIndex( i ); OUString aLocalName; sal_uInt16 nPrefix_ = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, @@ -122,11 +137,11 @@ SvXMLImportContextRef SvxXMLTableImportContext::CreateChildContext( sal_uInt16 n SvxXMLTableImportContextEnum::Bitmap == meContext && IsXMLToken( aLocalName, XML_HREF ) ) { - const OUString rValue = xAttrList->getValueByIndex( i ); + const OUString rValue = pAttrList->getValueByIndex( i ); if( !rValue.isEmpty() && '#' == rValue[0] ) pAttrList->SetValueByIndex( i, rValue.copy( 1 ) ); } - else if( XML_NAMESPACE_DRAW == nPrefix_ && + else if( (XML_NAMESPACE_DRAW == nPrefix_ || XML_NAMESPACE_DRAW_OOO == nPrefix_) && ( ( SvxXMLTableImportContextEnum::Dash == meContext && (IsXMLToken( aLocalName, XML_DOTS1_LENGTH ) || IsXMLToken( aLocalName, XML_DOTS2_LENGTH ) || @@ -134,7 +149,7 @@ SvXMLImportContextRef SvxXMLTableImportContext::CreateChildContext( sal_uInt16 n ( SvxXMLTableImportContextEnum::Hatch == meContext && IsXMLToken( aLocalName, XML_HATCH_DISTANCE ) ) ) ) { - const OUString rValue = xAttrList->getValueByIndex( i ); + const OUString rValue = pAttrList->getValueByIndex( i ); sal_Int32 nPos = rValue.getLength(); while( nPos && rValue[nPos-1] <= ' ' ) --nPos; @@ -155,22 +170,22 @@ SvXMLImportContextRef SvxXMLTableImportContext::CreateChildContext( sal_uInt16 n switch( meContext ) { case SvxXMLTableImportContextEnum::Color: - importColor( xAttrList, aAny, aName ); + importColor( pAttrList, aAny, aName ); break; case SvxXMLTableImportContextEnum::Marker: - importMarker( xAttrList, aAny, aName ); + importMarker( pAttrList, aAny, aName ); break; case SvxXMLTableImportContextEnum::Dash: - importDash( xAttrList, aAny, aName ); + importDash( pAttrList, aAny, aName ); break; case SvxXMLTableImportContextEnum::Hatch: - importHatch( xAttrList, aAny, aName ); + importHatch( pAttrList, aAny, aName ); break; case SvxXMLTableImportContextEnum::Gradient: - importGradient( xAttrList, aAny, aName ); + importGradient( pAttrList, aAny, aName ); break; case SvxXMLTableImportContextEnum::Bitmap: - importBitmap( xAttrList, aAny, aName ); + importBitmap( pAttrList, aAny, aName ); break; } @@ -188,10 +203,11 @@ SvXMLImportContextRef SvxXMLTableImportContext::CreateChildContext( sal_uInt16 n } catch (const uno::Exception&) { + DBG_UNHANDLED_EXCEPTION("svx"); } + return new SvXMLImportContext( GetImport() ); } - - return new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + return nullptr; } void SvxXMLTableImportContext::importColor( const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName ) @@ -204,7 +220,7 @@ void SvxXMLTableImportContext::importColor( const uno::Reference< XAttributeList sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rFullAttrName, &aLocalName ); - if( XML_NAMESPACE_DRAW == nPrefix ) + if( XML_NAMESPACE_DRAW == nPrefix || XML_NAMESPACE_DRAW_OOO == nPrefix ) { if( aLocalName == GetXMLToken(XML_NAME) ) { @@ -303,9 +319,12 @@ SvxXMLXTableImport::SvxXMLXTableImport( { SetGraphicStorageHandler(xGraphicStorageHandler); + GetNamespaceMap().Add( GetXMLToken(XML_NP_OOO), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO); + GetNamespaceMap().Add( GetXMLToken(XML_NP_OFFICE), GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE); + GetNamespaceMap().Add( GetXMLToken(XML_NP_DRAW), GetXMLToken(XML_N_DRAW), XML_NAMESPACE_DRAW); + GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK); + GetNamespaceMap().Add( "__ooo", GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO ); - GetNamespaceMap().Add( "__office", GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE ); - GetNamespaceMap().Add( "__draw", GetXMLToken(XML_N_DRAW), XML_NAMESPACE_DRAW ); GetNamespaceMap().Add( "__xlink", GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK ); // OOo namespaces for reading OOo 1.1 files @@ -416,45 +435,48 @@ bool SvxXMLXTableImport::load( const OUString &rPath, const OUString &rReferer, return bRet; } -SvXMLImportContext *SvxXMLXTableImport::CreateDocumentContext( - sal_uInt16 const nPrefix, const OUString& rLocalName, - const uno::Reference< XAttributeList >& /*xAttrList*/) +SvXMLImportContext *SvxXMLXTableImport::CreateFastContext( sal_Int32 nElement, + const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) { - if( XML_NAMESPACE_OOO == nPrefix || - XML_NAMESPACE_OFFICE == nPrefix ) + sal_Int32 nNamespace = nElement & NMSP_MASK; + if( NAMESPACE_TOKEN(XML_NAMESPACE_OOO) == nNamespace || + NAMESPACE_TOKEN(XML_NAMESPACE_OFFICE) == nNamespace || + NAMESPACE_TOKEN(XML_NAMESPACE_OFFICE_OOO) == nNamespace ) { - bool bOOoFormat = (XML_NAMESPACE_OFFICE == nPrefix); + bool bOOoFormat = (NAMESPACE_TOKEN(XML_NAMESPACE_OFFICE) == nNamespace) || + (NAMESPACE_TOKEN(XML_NAMESPACE_OFFICE_OOO) == nNamespace); Type aType = mrTable->getElementType(); + sal_Int32 nToken = nElement & TOKEN_MASK; - if ( rLocalName == "color-table" ) + if ( nToken == XML_COLOR_TABLE ) { if( aType == ::cppu::UnoType<sal_Int32>::get() ) - return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, SvxXMLTableImportContextEnum::Color, mrTable, bOOoFormat ); + return new SvxXMLTableImportContext( *this, SvxXMLTableImportContextEnum::Color, mrTable, bOOoFormat ); } - else if ( rLocalName == "marker-table" ) + else if ( nToken == XML_MARKER_TABLE ) { if( aType == cppu::UnoType<drawing::PolyPolygonBezierCoords>::get()) - return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, SvxXMLTableImportContextEnum::Marker, mrTable, bOOoFormat ); + return new SvxXMLTableImportContext( *this, SvxXMLTableImportContextEnum::Marker, mrTable, bOOoFormat ); } - else if ( rLocalName == "dash-table" ) + else if ( nToken == XML_DASH_TABLE ) { if( aType == cppu::UnoType<drawing::LineDash>::get()) - return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, SvxXMLTableImportContextEnum::Dash, mrTable, bOOoFormat ); + return new SvxXMLTableImportContext( *this, SvxXMLTableImportContextEnum::Dash, mrTable, bOOoFormat ); } - else if ( rLocalName == "hatch-table" ) + else if ( nToken == XML_HATCH_TABLE ) { if( aType == cppu::UnoType<drawing::Hatch>::get()) - return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, SvxXMLTableImportContextEnum::Hatch, mrTable, bOOoFormat ); + return new SvxXMLTableImportContext( *this, SvxXMLTableImportContextEnum::Hatch, mrTable, bOOoFormat ); } - else if ( rLocalName == "gradient-table" ) + else if ( nToken == XML_GRADIENT_TABLE ) { if( aType == cppu::UnoType<awt::Gradient>::get()) - return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, SvxXMLTableImportContextEnum::Gradient, mrTable, bOOoFormat ); + return new SvxXMLTableImportContext( *this, SvxXMLTableImportContextEnum::Gradient, mrTable, bOOoFormat ); } - else if ( rLocalName == "bitmap-table" ) + else if ( nToken == XML_BITMAP_TABLE ) { if( aType == ::cppu::UnoType<awt::XBitmap>::get()) - return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, SvxXMLTableImportContextEnum::Bitmap, mrTable, bOOoFormat ); + return new SvxXMLTableImportContext( *this, SvxXMLTableImportContextEnum::Bitmap, mrTable, bOOoFormat ); } } diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 6efad44b6206..dddb49ed2980 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -315,6 +315,7 @@ namespace xmloff { namespace token { TOKEN( "bibliography-type", XML_BIBLIOGRAPHY_TYPE ), TOKEN( "bind-styles-to-content", XML_BIND_STYLES_TO_CONTENT ), TOKEN( "bitmap", XML_BITMAP ), + TOKEN( "bitmap-table", XML_BITMAP_TABLE ), TOKEN( "black", XML_BLACK ), TOKEN( "blend", XML_BLEND ), TOKEN( "blinking", XML_BLINKING ), @@ -436,6 +437,7 @@ namespace xmloff { namespace token { TOKEN( "color-mode", XML_COLOR_MODE ), TOKEN( "color-scale", XML_COLOR_SCALE ), TOKEN( "color-scale-entry", XML_COLOR_SCALE_ENTRY ), + TOKEN( "color-table", XML_COLOR_TABLE ), TOKEN( "column", XML_COLUMN ), TOKEN( "column-count", XML_COLUMN_COUNT ), TOKEN( "column-gap", XML_COLUMN_GAP ), @@ -547,6 +549,7 @@ namespace xmloff { namespace token { TOKEN( "dash", XML_DASH ), TOKEN( "dash-dot", XML_DASH_DOT ), TOKEN( "dash-dot-dot", XML_DASH_DOT_DOT ), + TOKEN( "dash-table", XML_DASH_TABLE ), TOKEN( "dashed", XML_DASHED ), TOKEN( "data", XML_DATA ), TOKEN( "data-bar", XML_DATA_BAR ), @@ -931,6 +934,7 @@ namespace xmloff { namespace token { TOKEN( "border", XML_GRADIENT_BORDER ), TOKEN( "gradient-step-count", XML_GRADIENT_STEP_COUNT ), TOKEN( "gradient-style", XML_GRADIENT_STYLE ), + TOKEN( "gradient-table", XML_GRADIENT_TABLE ), TOKEN( "axial", XML_GRADIENTSTYLE_AXIAL ), TOKEN( "ellipsoid", XML_GRADIENTSTYLE_ELLIPSOID ), TOKEN( "linear", XML_GRADIENTSTYLE_LINEAR ), @@ -957,6 +961,7 @@ namespace xmloff { namespace token { TOKEN( "hatch", XML_HATCH ), TOKEN( "distance", XML_HATCH_DISTANCE ), TOKEN( "style", XML_HATCH_STYLE ), + TOKEN( "hatch-table", XML_HATCH_TABLE ), TOKEN( "double", XML_HATCHSTYLE_DOUBLE ), TOKEN( "single", XML_HATCHSTYLE_SINGLE ), TOKEN( "triple", XML_HATCHSTYLE_TRIPLE ), @@ -1199,6 +1204,7 @@ namespace xmloff { namespace token { TOKEN( "marker-start", XML_MARKER_START ), TOKEN( "marker-start-center", XML_MARKER_START_CENTER ), TOKEN( "marker-start-width", XML_MARKER_START_WIDTH ), + TOKEN( "marker-table", XML_MARKER_TABLE ), TOKEN( "maroon", XML_MAROON ), TOKEN( "master-page", XML_MASTER_PAGE ), TOKEN( "master-page-name", XML_MASTER_PAGE_NAME ), diff --git a/xmloff/source/style/ImageStyle.cxx b/xmloff/source/style/ImageStyle.cxx index 6fe12b40b2bc..c96ab9996abe 100644 --- a/xmloff/source/style/ImageStyle.cxx +++ b/xmloff/source/style/ImageStyle.cxx @@ -146,7 +146,7 @@ bool XMLImageStyle::importXML(uno::Reference<xml::sax::XAttributeList> const & x // ignore break; default: - SAL_INFO("xmloff.style", "Unknown token at import fill bitmap style"); + SAL_WARN("xmloff.style", "Unknown token at import fill bitmap style"); } } diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt index 921ff2b63b5a..cc25b084ce33 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -238,6 +238,7 @@ bibliography-source bibliography-type bind-styles-to-content bitmap +bitmap-table black blend blinking @@ -359,6 +360,7 @@ color-inversion color-mode color-scale color-scale-entry +color-table column column-count column-gap @@ -470,6 +472,7 @@ d dash dash-dot dash-dot-dot +dash-table dashed data data-bar @@ -854,6 +857,7 @@ angle GRADIENT_BORDER_DUMMY gradient-step-count gradient-style +gradient-table axial ellipsoid GRADIENTSTYLE_LINEAR_DUMMY @@ -880,6 +884,7 @@ has-persistent-data hatch HATCH_DISTANCE_DUMMY HATCH_STYLE_DUMMY +hatch-table HATCHSTYLE_DOUBLE_DUMMY HATCHSTYLE_SINGLE_DUMMY triple @@ -1117,6 +1122,7 @@ marker-end-width marker-start marker-start-center marker-start-width +marker-table maroon master-page master-page-name |