diff options
-rw-r--r-- | include/xmloff/xmlimp.hxx | 3 | ||||
-rw-r--r-- | include/xmloff/xmlnmspe.hxx | 26 | ||||
-rw-r--r-- | include/xmloff/xmltoken.hxx | 2 | ||||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 2 | ||||
-rw-r--r-- | test/source/xmltesttools.cxx | 2 | ||||
-rw-r--r-- | xmloff/inc/animationimport.hxx | 14 | ||||
-rw-r--r-- | xmloff/source/core/xmlimp.cxx | 27 | ||||
-rw-r--r-- | xmloff/source/core/xmltoken.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/draw/animationimport.cxx | 413 | ||||
-rw-r--r-- | xmloff/source/draw/layerimp.cxx | 9 | ||||
-rw-r--r-- | xmloff/source/draw/layerimp.hxx | 4 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlimp.cxx | 5 | ||||
-rw-r--r-- | xmloff/source/draw/ximpbody.cxx | 134 | ||||
-rw-r--r-- | xmloff/source/draw/ximpbody.hxx | 12 | ||||
-rw-r--r-- | xmloff/source/draw/ximpnote.cxx | 69 | ||||
-rw-r--r-- | xmloff/source/draw/ximpnote.hxx | 3 | ||||
-rw-r--r-- | xmloff/source/draw/ximppage.cxx | 104 | ||||
-rw-r--r-- | xmloff/source/draw/ximppage.hxx | 5 | ||||
-rw-r--r-- | xmloff/source/token/tokens.txt | 2 |
19 files changed, 509 insertions, 329 deletions
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx index 93c986f9f5bd..5bcd2531c845 100644 --- a/include/xmloff/xmlimp.hxx +++ b/include/xmloff/xmlimp.hxx @@ -244,9 +244,6 @@ protected: // This method is called after the namespace map has been updated, but // before a context for the current element has been pushed. // This base class implementation returns a context that ignores everything. - virtual SvXMLImportContext *CreateDocumentContext(sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ); virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList ); diff --git a/include/xmloff/xmlnmspe.hxx b/include/xmloff/xmlnmspe.hxx index 40cdabbc6825..3c5e679ee5d8 100644 --- a/include/xmloff/xmlnmspe.hxx +++ b/include/xmloff/xmlnmspe.hxx @@ -65,7 +65,7 @@ constexpr sal_uInt16 XML_NAMESPACE_GRDDL = 36; constexpr sal_uInt16 XML_NAMESPACE_VERSIONS_LIST = 37; // namespaces for odf extended formats -constexpr sal_uInt16 XML_NAMESPACE_EXT_BASE = 38; +constexpr sal_uInt16 XML_NAMESPACE_EXT_BASE = 50; constexpr sal_uInt16 XML_NAMESPACE_OFFICE_EXT = XML_NAMESPACE_EXT_BASE + 0; constexpr sal_uInt16 XML_NAMESPACE_TABLE_EXT = XML_NAMESPACE_EXT_BASE + 1; constexpr sal_uInt16 XML_NAMESPACE_CHART_EXT = XML_NAMESPACE_EXT_BASE + 2; @@ -74,7 +74,7 @@ constexpr sal_uInt16 XML_NAMESPACE_CALC_EXT = XML_NAMESPACE_EXT_BASE + 4; constexpr sal_uInt16 XML_NAMESPACE_LO_EXT = XML_NAMESPACE_EXT_BASE + 5; // namespaces for OOo formats -constexpr sal_uInt16 XML_NAMESPACE_OOO_BASE = 44U; +constexpr sal_uInt16 XML_NAMESPACE_OOO_BASE = 60; constexpr sal_uInt16 XML_NAMESPACE_OFFICE_OOO = XML_NAMESPACE_OOO_BASE + 0; constexpr sal_uInt16 XML_NAMESPACE_META_OOO = XML_NAMESPACE_OOO_BASE + 1; constexpr sal_uInt16 XML_NAMESPACE_STYLE_OOO = XML_NAMESPACE_OOO_BASE + 2; @@ -84,22 +84,24 @@ constexpr sal_uInt16 XML_NAMESPACE_TABLE_OOO = XML_NAMESPACE_OOO_BASE + constexpr sal_uInt16 XML_NAMESPACE_DRAW_OOO = XML_NAMESPACE_OOO_BASE + 6; constexpr sal_uInt16 XML_NAMESPACE_DR3D_OOO = XML_NAMESPACE_OOO_BASE + 7; constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION_OOO = XML_NAMESPACE_OOO_BASE + 8; -constexpr sal_uInt16 XML_NAMESPACE_CHART_OOO = XML_NAMESPACE_OOO_BASE + 9; -constexpr sal_uInt16 XML_NAMESPACE_CONFIG_OOO = XML_NAMESPACE_OOO_BASE + 10; -constexpr sal_uInt16 XML_NAMESPACE_FORM_OOO = XML_NAMESPACE_OOO_BASE + 11; -constexpr sal_uInt16 XML_NAMESPACE_SCRIPT_OOO = XML_NAMESPACE_OOO_BASE + 12; +constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION_OASIS = XML_NAMESPACE_OOO_BASE + 9; // only used for some config files in sd/ +constexpr sal_uInt16 XML_NAMESPACE_CHART_OOO = XML_NAMESPACE_OOO_BASE + 10; +constexpr sal_uInt16 XML_NAMESPACE_CONFIG_OOO = XML_NAMESPACE_OOO_BASE + 12; +constexpr sal_uInt16 XML_NAMESPACE_FORM_OOO = XML_NAMESPACE_OOO_BASE + 13; +constexpr sal_uInt16 XML_NAMESPACE_SCRIPT_OOO = XML_NAMESPACE_OOO_BASE + 14; +constexpr sal_uInt16 XML_NAMESPACE_ANIMATION_OOO = XML_NAMESPACE_OOO_BASE + 15; -constexpr sal_uInt16 XML_NAMESPACE_COMPAT_BASE = 57; +constexpr sal_uInt16 XML_NAMESPACE_COMPAT_BASE = 80; constexpr sal_uInt16 XML_NAMESPACE_SVG_COMPAT = XML_NAMESPACE_COMPAT_BASE + 0; constexpr sal_uInt16 XML_NAMESPACE_FO_COMPAT = XML_NAMESPACE_COMPAT_BASE + 1; constexpr sal_uInt16 XML_NAMESPACE_SMIL_COMPAT = XML_NAMESPACE_COMPAT_BASE + 2; -constexpr sal_uInt16 XML_NAMESPACE_OASIS_BASE = 60; +constexpr sal_uInt16 XML_NAMESPACE_OASIS_BASE = 90; constexpr sal_uInt16 XML_NAMESPACE_DB_OASIS = XML_NAMESPACE_OASIS_BASE + 0; constexpr sal_uInt16 XML_NAMESPACE_REPORT_OASIS = XML_NAMESPACE_OASIS_BASE + 1; // namespaces used in the technical preview (SO 5.2) -constexpr sal_uInt16 XML_OLD_NAMESPACE_BASE = 62; +constexpr sal_uInt16 XML_OLD_NAMESPACE_BASE = 100; constexpr sal_uInt16 XML_NAMESPACE_FO_SO52 = XML_OLD_NAMESPACE_BASE + 0; constexpr sal_uInt16 XML_NAMESPACE_XLINK_SO52 = XML_OLD_NAMESPACE_BASE + 1; constexpr sal_uInt16 XML_NAMESPACE_OFFICE_SO52 = XML_OLD_NAMESPACE_BASE + 2; @@ -114,9 +116,9 @@ constexpr sal_uInt16 XML_NAMESPACE_CHART_SO52 = XML_OLD_NAMESPACE_BASE + constexpr sal_uInt16 XML_NAMESPACE_SMIL_SO52 = XML_OLD_NAMESPACE_BASE + 11; // experimental namespaces -constexpr sal_uInt16 XML_NAMESPACE_FIELD = 100; -constexpr sal_uInt16 XML_NAMESPACE_CSS3TEXT = 103; // CSS Text Level 3 -constexpr sal_uInt16 XML_NAMESPACE_FORMX = 101; // form interop extensions +constexpr sal_uInt16 XML_NAMESPACE_FIELD = 120; +constexpr sal_uInt16 XML_NAMESPACE_CSS3TEXT = 123; // CSS Text Level 3 +constexpr sal_uInt16 XML_NAMESPACE_FORMX = 121; // form interop extensions #endif // INCLUDED_XMLOFF_XMLNMSPE_HXX diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index 40e4f5b55b02..7289d72e5e61 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -2497,6 +2497,7 @@ namespace xmloff { namespace token { XML_N_DRAW_OOO, XML_N_DR3D_OOO, XML_N_PRESENTATION_OOO, + XML_N_PRESENTATION_OASIS, XML_N_CHART_OOO, XML_N_CONFIG_OOO, XML_N_FORM_OOO, @@ -2788,6 +2789,7 @@ namespace xmloff { namespace token { XML_NP_ANIMATION, XML_N_ANIMATION, + XML_N_ANIMATION_OOO, XML_PAR, XML_SEQ, diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 4d17e314fcf5..9dfdb35c4fb4 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -801,7 +801,7 @@ void SdImportTest::testFdo64512() uno::Reference< drawing::XDrawPage > xPage( xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "no exactly three shapes", static_cast<sal_Int32>(3), xPage->getCount() ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "not exactly three shapes", static_cast<sal_Int32>(3), xPage->getCount() ); uno::Reference< beans::XPropertySet > xConnectorShape( xPage->getByIndex(2), uno::UNO_QUERY ); diff --git a/test/source/xmltesttools.cxx b/test/source/xmltesttools.cxx index 38420ba384d2..b4a74aa4a8b4 100644 --- a/test/source/xmltesttools.cxx +++ b/test/source/xmltesttools.cxx @@ -181,6 +181,8 @@ void XmlTestTools::assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, int nNu { xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, rXPath); xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + if (nNumberOfNodes != xmlXPathNodeSetGetLength(pXmlNodes)) + CPPUNIT_ASSERT_EQUAL(1, 2); CPPUNIT_ASSERT_EQUAL_MESSAGE(OString(OStringLiteral("In <") + pXmlDoc->name + ">, XPath '" + rXPath + "' number of nodes is incorrect").getStr(), nNumberOfNodes, xmlXPathNodeSetGetLength(pXmlNodes)); xmlXPathFreeObject(pXmlObj); diff --git a/xmloff/inc/animationimport.hxx b/xmloff/inc/animationimport.hxx index 14df8ca9b3d0..5633e0ca3f1a 100644 --- a/xmloff/inc/animationimport.hxx +++ b/xmloff/inc/animationimport.hxx @@ -37,22 +37,22 @@ class AnimationNodeContext final : public SvXMLImportContext std::shared_ptr<AnimationsImportHelperImpl> mpHelper; css::uno::Reference< css::animations::XAnimationNode > mxNode; - void init_node( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ); + void init_node( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ); public: AnimationNodeContext( const css::uno::Reference< css::animations::XAnimationNode >& xParentNode, SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, const std::shared_ptr<AnimationsImportHelperImpl>& pImpl = nullptr ); - 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 >& xAttrList ) override; - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override; + virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& Attribs) override; static void postProcessRootNode( const css::uno::Reference< css::animations::XAnimationNode >& xNode, css::uno::Reference< css::beans::XPropertySet > const & xPageProps ); }; diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 1d6bc5d1d0b2..0c3000175878 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -323,14 +323,6 @@ public: ::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper; }; -SvXMLImportContext *SvXMLImport::CreateDocumentContext(sal_uInt16 const nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList >& ) -{ - SAL_WARN( "xmloff.core", "CreateDocumentContext should be overridden, for element " << rLocalName); - return new SvXMLImportContext( *this, nPrefix, rLocalName ); -} - SvXMLImportContext *SvXMLImport::CreateFastContext( sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) { @@ -736,19 +728,15 @@ void SAL_CALL SvXMLImport::startElement( const OUString& rName, } else { - xContext.set(CreateDocumentContext(nPrefix, aLocalName, xAttrList)); - if( (nPrefix & XML_NAMESPACE_UNKNOWN_FLAG) != 0 && - dynamic_cast< const SvXMLImportContext*>(xContext.get()) != nullptr ) - { - Reference<xml::sax::XLocator> xDummyLocator; - Sequence < OUString > aParams { rName }; + Reference<xml::sax::XLocator> xDummyLocator; + Sequence < OUString > aParams { rName }; - SetError( XMLERROR_FLAG_SEVERE|XMLERROR_UNKNOWN_ROOT, - aParams, "Root element " + aLocalName + " unknown", xDummyLocator ); - } + SetError( XMLERROR_FLAG_SEVERE|XMLERROR_UNKNOWN_ROOT, + aParams, "Root element " + rName + " unknown", xDummyLocator ); } - SAL_WARN_IF( !xContext.is(), "xmloff.core", "SvXMLImport::startElement: missing context for element " << rName ); + if ( !xContext.is() ) + SAL_WARN_IF( !xContext.is(), "xmloff.core", "SvXMLImport::startElement: missing context for element " << rName ); if( !xContext.is() ) xContext.set(new SvXMLImportContext( *this, nPrefix, aLocalName )); @@ -2080,6 +2068,7 @@ void SvXMLImport::initializeNamespaceMaps() { const OUString& sNamespace = GetXMLToken( static_cast<XMLTokenEnum>( nNamespace ) ); const OUString& sPrefix = GetXMLToken( static_cast<XMLTokenEnum>( nPrefix ) ); + assert( aNamespaceMap.find(nToken +1) == aNamespaceMap.end() && "cannot map two namespaces to the same token here"); aNamespaceMap[ nToken + 1 ] = std::make_pair( sPrefix, sNamespace ); aNamespaceURIPrefixMap.emplace( sNamespace, sPrefix ); } @@ -2115,6 +2104,7 @@ void SvXMLImport::initializeNamespaceMaps() mapTokenToNamespace( XML_NAMESPACE_PRESENTATION, XML_NP_PRESENTATION, XML_N_PRESENTATION ); mapTokenToNamespace( XML_NAMESPACE_PRESENTATION_SO52,XML_NP_PRESENTATION, XML_N_PRESENTATION_OLD ); mapTokenToNamespace( XML_NAMESPACE_PRESENTATION_OOO, XML_NP_PRESENTATION, XML_N_PRESENTATION_OOO ); + mapTokenToNamespace( XML_NAMESPACE_PRESENTATION_OASIS, XML_NP_PRESENTATION, XML_N_PRESENTATION_OASIS ); mapTokenToNamespace( XML_NAMESPACE_SVG, XML_NP_SVG, XML_N_SVG ); mapTokenToNamespace( XML_NAMESPACE_SVG_COMPAT, XML_NP_SVG, XML_N_SVG_COMPAT ); mapTokenToNamespace( XML_NAMESPACE_CHART, XML_NP_CHART, XML_N_CHART ); @@ -2145,6 +2135,7 @@ void SvXMLImport::initializeNamespaceMaps() mapTokenToNamespace( XML_NAMESPACE_SMIL_SO52, XML_NP_SMIL, XML_N_SMIL_OLD ); mapTokenToNamespace( XML_NAMESPACE_SMIL_COMPAT, XML_NP_SMIL, XML_N_SMIL_COMPAT ); mapTokenToNamespace( XML_NAMESPACE_ANIMATION, XML_NP_ANIMATION, XML_N_ANIMATION ); + mapTokenToNamespace( XML_NAMESPACE_ANIMATION_OOO, XML_NP_ANIMATION, XML_N_ANIMATION_OOO ); mapTokenToNamespace( XML_NAMESPACE_REPORT, XML_NP_RPT, XML_N_RPT ); mapTokenToNamespace( XML_NAMESPACE_REPORT_OASIS, XML_NP_RPT, XML_N_RPT_OASIS ); mapTokenToNamespace( XML_NAMESPACE_OF, XML_NP_OF, XML_N_OF ); diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 8efa01a7b02d..9aace65cb7b5 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -2499,6 +2499,7 @@ namespace xmloff::token { TOKEN( "http://openoffice.org/2000/drawing", XML_N_DRAW_OOO ), TOKEN( "http://openoffice.org/2000/dr3d", XML_N_DR3D_OOO ), TOKEN( "http://openoffice.org/2000/presentation",XML_N_PRESENTATION_OOO ), + TOKEN( "urn:oasis:names:tc:openoffice:xmlns:presentation:1.0",XML_N_PRESENTATION_OASIS ), TOKEN( "http://openoffice.org/2000/chart", XML_N_CHART_OOO ), TOKEN( "http://openoffice.org/2001/config", XML_N_CONFIG_OOO ), TOKEN( "http://openoffice.org/2000/form", XML_N_FORM_OOO ), @@ -2787,6 +2788,7 @@ namespace xmloff::token { TOKEN( "anim", XML_NP_ANIMATION ), TOKEN( "urn:oasis:names:tc:opendocument:xmlns:animation:1.0", XML_N_ANIMATION ), + TOKEN( "urn:oasis:names:tc:openoffice:xmlns:animation:1.0", XML_N_ANIMATION_OOO ), TOKEN( "par", XML_PAR ), TOKEN( "seq", XML_SEQ ), diff --git a/xmloff/source/draw/animationimport.cxx b/xmloff/source/draw/animationimport.cxx index 5306314a028b..7c87ed009155 100644 --- a/xmloff/source/draw/animationimport.cxx +++ b/xmloff/source/draw/animationimport.cxx @@ -38,7 +38,7 @@ #include <com/sun/star/animations/Timing.hpp> #include <com/sun/star/animations/Event.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/xml/sax/XAttributeList.hpp> +#include <com/sun/star/xml/sax/XFastAttributeList.hpp> #include <com/sun/star/text/XTextCursor.hpp> #include <com/sun/star/text/XTextRangeCompare.hpp> #include <com/sun/star/presentation/ParagraphTarget.hpp> @@ -49,6 +49,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/string.hxx> +#include <sal/log.hxx> #include <sax/tools/converter.hxx> #include <vector> @@ -78,7 +79,7 @@ using namespace ::com::sun::star::drawing; using namespace ::com::sun::star::uno; using namespace ::xmloff::token; -using ::com::sun::star::xml::sax::XAttributeList; +using ::com::sun::star::xml::sax::XFastAttributeList; using ::com::sun::star::beans::NamedValue; using ::com::sun::star::text::XTextRange; using ::com::sun::star::text::XTextCursor; @@ -111,9 +112,6 @@ private: public: explicit AnimationsImportHelperImpl( SvXMLImport& rImport ); - const SvXMLTokenMap& getAnimationNodeTokenMap(); - const SvXMLTokenMap& getAnimationNodeAttributeTokenMap(); - Any convertValue( XMLTokenEnum eAttributeName, const OUString& rValue ); Sequence< Any > convertValueSequence( XMLTokenEnum eAttributeName, const OUString& rValue ); @@ -129,32 +127,6 @@ AnimationsImportHelperImpl::AnimationsImportHelperImpl( SvXMLImport& rImport ) { } -const SvXMLTokenMap& AnimationsImportHelperImpl::getAnimationNodeTokenMap() -{ - if( mpAnimationNodeTokenMap == nullptr ) - { - static const SvXMLTokenMapEntry aAnimationNodeTokenMap[] = - { - { XML_NAMESPACE_ANIMATION, XML_PAR, sal_uInt16(AnimationNodeType::PAR) }, - { XML_NAMESPACE_ANIMATION, XML_SEQ, sal_uInt16(AnimationNodeType::SEQ) }, - { XML_NAMESPACE_ANIMATION, XML_ITERATE, sal_uInt16(AnimationNodeType::ITERATE) }, - { XML_NAMESPACE_ANIMATION, XML_ANIMATE, sal_uInt16(AnimationNodeType::ANIMATE) }, - { XML_NAMESPACE_ANIMATION, XML_SET, sal_uInt16(AnimationNodeType::SET) }, - { XML_NAMESPACE_ANIMATION, XML_ANIMATEMOTION, sal_uInt16(AnimationNodeType::ANIMATEMOTION) }, - { XML_NAMESPACE_ANIMATION, XML_ANIMATECOLOR, sal_uInt16(AnimationNodeType::ANIMATECOLOR) }, - { XML_NAMESPACE_ANIMATION, XML_ANIMATETRANSFORM, sal_uInt16(AnimationNodeType::ANIMATETRANSFORM) }, - { XML_NAMESPACE_ANIMATION, XML_TRANSITIONFILTER, sal_uInt16(AnimationNodeType::TRANSITIONFILTER) }, - { XML_NAMESPACE_ANIMATION, XML_AUDIO, sal_uInt16(AnimationNodeType::AUDIO) }, - { XML_NAMESPACE_ANIMATION, XML_COMMAND, sal_uInt16(AnimationNodeType::COMMAND) }, - XML_TOKEN_MAP_END - }; - - mpAnimationNodeTokenMap = std::make_unique<SvXMLTokenMap>( aAnimationNodeTokenMap ); - } - - return *mpAnimationNodeTokenMap; -} - namespace { enum AnimationNodeAttributes @@ -212,72 +184,6 @@ enum AnimationNodeAttributes } -const SvXMLTokenMap& AnimationsImportHelperImpl::getAnimationNodeAttributeTokenMap() -{ - if( mpAnimationNodeAttributeTokenMap == nullptr ) - { - static const SvXMLTokenMapEntry aAnimationNodeAttributeTokenMap[] = - { - { XML_NAMESPACE_SMIL, XML_BEGIN, sal_uInt16(ANA_Begin) }, - { XML_NAMESPACE_SMIL, XML_DUR, sal_uInt16(ANA_Dur) }, - { XML_NAMESPACE_SMIL, XML_END, sal_uInt16(ANA_End) }, - { XML_NAMESPACE_SMIL, XML_FILL, sal_uInt16(ANA_Fill) }, - { XML_NAMESPACE_SMIL, XML_FILLDEFAULT, sal_uInt16(ANA_FillDefault) }, - { XML_NAMESPACE_SMIL, XML_RESTART, sal_uInt16(ANA_Restart) }, - { XML_NAMESPACE_SMIL, XML_RESTARTDEFAULT, sal_uInt16(ANA_RestartDefault) }, - { XML_NAMESPACE_SMIL, XML_ACCELERATE, sal_uInt16(ANA_Accelerate) }, - { XML_NAMESPACE_SMIL, XML_DECELERATE, sal_uInt16(ANA_Decelerate) }, - { XML_NAMESPACE_SMIL, XML_AUTOREVERSE, sal_uInt16(ANA_AutoReverse) }, - { XML_NAMESPACE_SMIL, XML_REPEATCOUNT, sal_uInt16(ANA_RepeatCount) }, - { XML_NAMESPACE_SMIL, XML_REPEATDUR, sal_uInt16(ANA_RepeatDur) }, - { XML_NAMESPACE_SMIL, XML_ENDSYNC, sal_uInt16(ANA_EndSync) }, - { XML_NAMESPACE_PRESENTATION, XML_NODE_TYPE, sal_uInt16(ANA_Node_Type) }, - { XML_NAMESPACE_PRESENTATION, XML_PRESET_ID, sal_uInt16(ANA_Preset_ID) }, - { XML_NAMESPACE_PRESENTATION, XML_PRESET_SUB_TYPE, sal_uInt16(ANA_Preset_Sub_Type) }, - { XML_NAMESPACE_PRESENTATION, XML_PRESET_CLASS, sal_uInt16(ANA_Preset_Class) }, - { XML_NAMESPACE_PRESENTATION, XML_AFTER_EFFECT, sal_uInt16(ANA_After_Effect) }, - { XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sal_uInt16(ANA_Target) }, - { XML_NAMESPACE_XLINK, XML_HREF, sal_uInt16(ANA_XLink) }, - { XML_NAMESPACE_PRESENTATION, XML_MASTER_ELEMENT, sal_uInt16(ANA_MasterElement) }, - { XML_NAMESPACE_ANIMATION, XML_SUB_ITEM, sal_uInt16(ANA_SubItem) }, - { XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, sal_uInt16(ANA_AttributeName) }, - { XML_NAMESPACE_SMIL, XML_VALUES, sal_uInt16(ANA_Values) }, - { XML_NAMESPACE_SMIL, XML_FROM, sal_uInt16(ANA_From) }, - { XML_NAMESPACE_SMIL, XML_BY, sal_uInt16(ANA_By) }, - { XML_NAMESPACE_SMIL, XML_TO, sal_uInt16(ANA_To) }, - { XML_NAMESPACE_SMIL, XML_KEYTIMES, sal_uInt16(ANA_KeyTimes) }, - { XML_NAMESPACE_SMIL, XML_CALCMODE, sal_uInt16(ANA_CalcMode) }, - { XML_NAMESPACE_SMIL, XML_ACCUMULATE, sal_uInt16(ANA_Accumulate) }, - { XML_NAMESPACE_PRESENTATION, XML_ADDITIVE, sal_uInt16(ANA_AdditiveMode) }, - { XML_NAMESPACE_SMIL, XML_ADDITIVE, sal_uInt16(ANA_AdditiveMode) }, - { XML_NAMESPACE_SMIL, XML_KEYSPLINES, sal_uInt16(ANA_KeySplines) }, - { XML_NAMESPACE_SVG, XML_PATH, sal_uInt16(ANA_Path) }, - { XML_NAMESPACE_ANIMATION, XML_COLOR_INTERPOLATION, sal_uInt16(ANA_ColorSpace) }, - { XML_NAMESPACE_ANIMATION, XML_COLOR_INTERPOLATION_DIRECTION, sal_uInt16(ANA_ColorDirection) }, - { XML_NAMESPACE_SVG, XML_TYPE, sal_uInt16(ANA_TransformType) }, - { XML_NAMESPACE_SMIL, XML_TYPE, sal_uInt16(ANA_TransitionType) }, - { XML_NAMESPACE_SMIL, XML_SUBTYPE, sal_uInt16(ANA_TransitionSubType) }, - { XML_NAMESPACE_SMIL, XML_MODE, sal_uInt16(ANA_Mode) }, - { XML_NAMESPACE_SMIL, XML_DIRECTION, sal_uInt16(ANA_Direction) }, - { XML_NAMESPACE_SMIL, XML_FADECOLOR, sal_uInt16(ANA_FadeColor) }, - { XML_NAMESPACE_ANIMATION, XML_ITERATE_TYPE, sal_uInt16(ANA_IterateType) }, - { XML_NAMESPACE_ANIMATION, XML_ITERATE_INTERVAL, sal_uInt16(ANA_IterateInterval) }, - { XML_NAMESPACE_ANIMATION, XML_FORMULA, sal_uInt16(ANA_Formula) }, - { XML_NAMESPACE_ANIMATION, XML_ID, sal_uInt16(ANA_ANIMID) }, - { XML_NAMESPACE_XML, XML_ID, sal_uInt16(ANA_XMLID) }, - { XML_NAMESPACE_PRESENTATION, XML_GROUP_ID, sal_uInt16(ANA_Group_Id) }, - { XML_NAMESPACE_ANIMATION, XML_AUDIO_LEVEL, sal_uInt16(ANA_Volume) }, - { XML_NAMESPACE_ANIMATION, XML_COMMAND, sal_uInt16(ANA_Command) }, - - XML_TOKEN_MAP_END - }; - - mpAnimationNodeAttributeTokenMap = std::make_unique<SvXMLTokenMap>( aAnimationNodeAttributeTokenMap ); - } - - return *mpAnimationNodeAttributeTokenMap; -} - static bool isDouble( const OUString& rValue ) { sal_Int32 nLength = rValue.getLength(); @@ -582,10 +488,10 @@ Any AnimationsImportHelperImpl::convertPath( const OUString& rValue ) AnimationNodeContext::AnimationNodeContext( const Reference< XAnimationNode >& xParentNode, - SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + SvXMLImport& rImport, sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, const std::shared_ptr<AnimationsImportHelperImpl>& pHelper ) -: SvXMLImportContext(rImport, nPrfx, rLocalName), +: SvXMLImportContext(rImport), mpHelper( pHelper ) { bool bRootContext = !pHelper; @@ -602,30 +508,38 @@ AnimationNodeContext::AnimationNodeContext( const char* pServiceName = nullptr; - sal_Int16 nNodeType = static_cast<sal_Int16>(mpHelper->getAnimationNodeTokenMap().Get( nPrfx, rLocalName )); - switch( nNodeType ) + // we see namesspace ANIMATION and ANIMATION_OOO and PRESENTATION_OASIS and PRESENTATION_SO52 and PRESENTATION_OOO + switch( nElement & TOKEN_MASK ) { - case AnimationNodeType::SEQ: pServiceName = "com.sun.star.animations.SequenceTimeContainer"; break; - case AnimationNodeType::ITERATE: pServiceName = "com.sun.star.animations.IterateContainer"; break; - case AnimationNodeType::ANIMATE: pServiceName = "com.sun.star.animations.Animate"; break; - case AnimationNodeType::SET: pServiceName = "com.sun.star.animations.AnimateSet"; break; - case AnimationNodeType::ANIMATEMOTION: pServiceName = "com.sun.star.animations.AnimateMotion"; break; - case AnimationNodeType::ANIMATECOLOR: pServiceName = "com.sun.star.animations.AnimateColor"; break; - case AnimationNodeType::ANIMATETRANSFORM: pServiceName = "com.sun.star.animations.AnimateTransform"; break; - case AnimationNodeType::TRANSITIONFILTER: pServiceName = "com.sun.star.animations.TransitionFilter"; break; - case AnimationNodeType::AUDIO: pServiceName = "com.sun.star.animations.Audio"; break; - case AnimationNodeType::COMMAND: pServiceName = "com.sun.star.animations.Command"; break; - case AnimationNodeType::PAR: + case XML_SEQ: + pServiceName = "com.sun.star.animations.SequenceTimeContainer"; break; + case XML_ITERATE: + pServiceName = "com.sun.star.animations.IterateContainer"; break; + case XML_ANIMATE: + pServiceName = "com.sun.star.animations.Animate"; break; + case XML_SET: + pServiceName = "com.sun.star.animations.AnimateSet"; break; + case XML_ANIMATEMOTION: + pServiceName = "com.sun.star.animations.AnimateMotion"; break; + case XML_ANIMATECOLOR: + pServiceName = "com.sun.star.animations.AnimateColor"; break; + case XML_ANIMATETRANSFORM: + pServiceName = "com.sun.star.animations.AnimateTransform"; break; + case XML_TRANSITIONFILTER: + pServiceName = "com.sun.star.animations.TransitionFilter"; break; + case XML_AUDIO: + pServiceName = "com.sun.star.animations.Audio"; break; + case XML_COMMAND: + pServiceName = "com.sun.star.animations.Command"; break; + case XML_PAR: { - const sal_Int16 nCount = xAttrList.is() ? xAttrList->getLength() : 0; - sal_Int16 nAttribute; - for( nAttribute = 0; nAttribute < nCount; nAttribute++ ) + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList ); + for (auto &aIter : *pAttribList) { - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( nAttribute ), &aLocalName ); - if( (nPrefix == XML_NAMESPACE_PRESENTATION) && IsXMLToken( aLocalName, XML_PRESET_ID ) ) + if( (aIter.getToken() & TOKEN_MASK) == XML_PRESET_ID) { - const OUString& rValue = xAttrList->getValueByIndex( nAttribute ); + const OUString& rValue = aIter.toString(); if ( rValue == "ooo-entrance-random" ) { nPresetClass = EffectPresetClass::ENTRANCE; @@ -647,7 +561,9 @@ AnimationNodeContext::AnimationNodeContext( } break; default: - pServiceName = nullptr; + SAL_WARN("xmloff", "unexpected token '" + SvXMLImport::getNameFromToken(nElement) + << "' 0x" << std::hex << nElement); + break; } if( pServiceName ) @@ -679,7 +595,7 @@ AnimationNodeContext::AnimationNodeContext( } } -void AnimationNodeContext::StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& ) +void AnimationNodeContext::startFastElement( sal_Int32 /*nElement*/, const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) { // code of StartElement is moved to init_node that is now called // in c'tor before appending this node to its parent. @@ -687,7 +603,7 @@ void AnimationNodeContext::StartElement( const css::uno::Reference< css::xml::sa // set when child nodes are appended. } -void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) +void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { if( mxNode.is() ) try { @@ -705,122 +621,158 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: bool bHaveXmlId( false ); OUString sXmlId; - const sal_Int16 nCount = xAttrList.is() ? xAttrList->getLength() : 0; sal_Int16 nEnum; - sal_Int16 nAttribute; - for( nAttribute = 0; nAttribute < nCount; nAttribute++ ) + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList ); + for (auto &aIter : *pAttribList) { - const OUString& rAttrName = xAttrList->getNameByIndex( nAttribute ); - const OUString& rValue = xAttrList->getValueByIndex( nAttribute ); - - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName ); - switch( mpHelper->getAnimationNodeAttributeTokenMap().Get( nPrefix, aLocalName ) ) + OUString rValue = aIter.toString(); + switch( aIter.getToken() ) { - case ANA_Begin: + case XML_ELEMENT(SMIL, XML_BEGIN): + case XML_ELEMENT(SMIL_COMPAT, XML_BEGIN): + case XML_ELEMENT(SMIL_SO52, XML_BEGIN): { mxNode->setBegin( mpHelper->convertTiming( rValue ) ); } break; - case ANA_Dur: + case XML_ELEMENT(SMIL, XML_DUR): + case XML_ELEMENT(SMIL_COMPAT, XML_DUR): + case XML_ELEMENT(SMIL_SO52, XML_DUR): { mxNode->setDuration( mpHelper->convertTiming( rValue ) ); } break; - case ANA_End: + case XML_ELEMENT(SMIL, XML_END): + case XML_ELEMENT(SMIL_COMPAT, XML_END): + case XML_ELEMENT(SMIL_SO52, XML_END): { mxNode->setEnd( mpHelper->convertTiming( rValue ) ); } break; - case ANA_Fill: + case XML_ELEMENT(SMIL, XML_FILL): + case XML_ELEMENT(SMIL_COMPAT, XML_FILL): + case XML_ELEMENT(SMIL_SO52, XML_FILL): { if( SvXMLUnitConverter::convertEnum( nEnum, rValue, aAnimations_EnumMap_Fill ) ) mxNode->setFill( nEnum ); } break; - case ANA_FillDefault: + case XML_ELEMENT(SMIL, XML_FILLDEFAULT): + case XML_ELEMENT(SMIL_COMPAT, XML_FILLDEFAULT): + case XML_ELEMENT(SMIL_SO52, XML_FILLDEFAULT): { if( SvXMLUnitConverter::convertEnum( nEnum, rValue, aAnimations_EnumMap_FillDefault ) ) mxNode->setFillDefault( nEnum ); } break; - case ANA_Restart: + case XML_ELEMENT(SMIL, XML_RESTART): + case XML_ELEMENT(SMIL_COMPAT, XML_RESTART): + case XML_ELEMENT(SMIL_SO52, XML_RESTART): { if( SvXMLUnitConverter::convertEnum( nEnum, rValue, aAnimations_EnumMap_Restart ) ) mxNode->setRestart( nEnum ); } break; - case ANA_RestartDefault: + case XML_ELEMENT(SMIL, XML_RESTARTDEFAULT): + case XML_ELEMENT(SMIL_COMPAT, XML_RESTARTDEFAULT): + case XML_ELEMENT(SMIL_SO52, XML_RESTARTDEFAULT): { if( SvXMLUnitConverter::convertEnum( nEnum, rValue, aAnimations_EnumMap_RestartDefault ) ) mxNode->setRestartDefault( nEnum ); } break; - case ANA_Accelerate: + case XML_ELEMENT(SMIL, XML_ACCELERATE): + case XML_ELEMENT(SMIL_COMPAT, XML_ACCELERATE): + case XML_ELEMENT(SMIL_SO52, XML_ACCELERATE): { if( isDouble( rValue ) ) mxNode->setAcceleration( rValue.toDouble() ); } break; - case ANA_Decelerate: + case XML_ELEMENT(SMIL, XML_DECELERATE): + case XML_ELEMENT(SMIL_COMPAT, XML_DECELERATE): + case XML_ELEMENT(SMIL_SO52, XML_DECELERATE): { if( isDouble( rValue ) ) mxNode->setDecelerate( rValue.toDouble() ); } break; - case ANA_AutoReverse: + case XML_ELEMENT(SMIL, XML_AUTOREVERSE): + case XML_ELEMENT(SMIL_COMPAT, XML_AUTOREVERSE): + case XML_ELEMENT(SMIL_SO52, XML_AUTOREVERSE): { bool bTemp; if (::sax::Converter::convertBool( bTemp, rValue )) mxNode->setAutoReverse( bTemp ); } break; - case ANA_RepeatCount: + case XML_ELEMENT(SMIL, XML_REPEATCOUNT): + case XML_ELEMENT(SMIL_COMPAT, XML_REPEATCOUNT): + case XML_ELEMENT(SMIL_SO52, XML_REPEATCOUNT): { mxNode->setRepeatCount( mpHelper->convertTiming( rValue ) ); } break; - case ANA_RepeatDur: + case XML_ELEMENT(SMIL, XML_REPEATDUR): + case XML_ELEMENT(SMIL_COMPAT, XML_REPEATDUR): + case XML_ELEMENT(SMIL_SO52, XML_REPEATDUR): { mxNode->setRepeatDuration( mpHelper->convertTiming( rValue ) ); } break; - case ANA_EndSync: + case XML_ELEMENT(SMIL, XML_ENDSYNC): + case XML_ELEMENT(SMIL_COMPAT, XML_ENDSYNC): + case XML_ELEMENT(SMIL_SO52, XML_ENDSYNC): { if( SvXMLUnitConverter::convertEnum( nEnum, rValue, aAnimations_EnumMap_Endsync ) ) mxNode->setEndSync( makeAny( nEnum ) ); } break; - case ANA_Node_Type: + case XML_ELEMENT(PRESENTATION, XML_NODE_TYPE): + case XML_ELEMENT(PRESENTATION_SO52, XML_NODE_TYPE): + case XML_ELEMENT(PRESENTATION_OOO, XML_NODE_TYPE): + case XML_ELEMENT(PRESENTATION_OASIS, XML_NODE_TYPE): { if( SvXMLUnitConverter::convertEnum( nEnum, rValue, aAnimations_EnumMap_EffectNodeType ) ) aUserData.emplace_back( GetXMLToken( XML_NODE_TYPE ), makeAny( nEnum ) ); } break; - case ANA_Preset_ID: + case XML_ELEMENT(PRESENTATION, XML_PRESET_ID): + case XML_ELEMENT(PRESENTATION_SO52, XML_PRESET_ID): + case XML_ELEMENT(PRESENTATION_OOO, XML_PRESET_ID): + case XML_ELEMENT(PRESENTATION_OASIS, XML_PRESET_ID): { aUserData.emplace_back( GetXMLToken( XML_PRESET_ID ), makeAny( rValue ) ); } break; - case ANA_Preset_Sub_Type: + case XML_ELEMENT(PRESENTATION, XML_PRESET_SUB_TYPE): + case XML_ELEMENT(PRESENTATION_SO52, XML_PRESET_SUB_TYPE): + case XML_ELEMENT(PRESENTATION_OOO, XML_PRESET_SUB_TYPE): + case XML_ELEMENT(PRESENTATION_OASIS, XML_PRESET_SUB_TYPE): { aUserData.emplace_back( GetXMLToken( XML_PRESET_SUB_TYPE ), makeAny( rValue ) ); } break; - case ANA_Preset_Class: + case XML_ELEMENT(PRESENTATION, XML_PRESET_CLASS): + case XML_ELEMENT(PRESENTATION_SO52, XML_PRESET_CLASS): + case XML_ELEMENT(PRESENTATION_OOO, XML_PRESET_CLASS): + case XML_ELEMENT(PRESENTATION_OASIS, XML_PRESET_CLASS): { if( SvXMLUnitConverter::convertEnum( nEnum, rValue, aAnimations_EnumMap_EffectPresetClass ) ) aUserData.emplace_back( GetXMLToken( XML_PRESET_CLASS ), makeAny( nEnum ) ); } break; - case ANA_After_Effect: + case XML_ELEMENT(PRESENTATION, XML_AFTER_EFFECT): + case XML_ELEMENT(PRESENTATION_SO52, XML_AFTER_EFFECT): + case XML_ELEMENT(PRESENTATION_OOO, XML_AFTER_EFFECT): { bool bTemp; if (::sax::Converter::convertBool( bTemp, rValue )) aUserData.emplace_back( GetXMLToken( XML_AFTER_EFFECT ), makeAny( bTemp ) ); } break; - case ANA_XLink: + case XML_ELEMENT(XLINK, XML_HREF): { if( nNodeType == AnimationNodeType::AUDIO ) { @@ -830,7 +782,9 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } [[fallthrough]]; } - case ANA_Target: + case XML_ELEMENT(SMIL, XML_TARGETELEMENT): + case XML_ELEMENT(SMIL_COMPAT, XML_TARGETELEMENT): + case XML_ELEMENT(SMIL_SO52, XML_TARGETELEMENT): { Any aTarget( mpHelper->convertTarget( rValue ) ); @@ -849,7 +803,8 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_Volume: + case XML_ELEMENT(ANIMATION, XML_AUDIO_LEVEL): + case XML_ELEMENT(ANIMATION_OOO, XML_AUDIO_LEVEL): { if( nNodeType == AnimationNodeType::AUDIO ) { @@ -862,14 +817,17 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_MasterElement: + case XML_ELEMENT(PRESENTATION, XML_MASTER_ELEMENT): + case XML_ELEMENT(PRESENTATION_SO52, XML_MASTER_ELEMENT): + case XML_ELEMENT(PRESENTATION_OOO, XML_MASTER_ELEMENT): { Reference< XAnimationNode > xMaster( GetImport().getInterfaceToIdentifierMapper().getReference( rValue ), UNO_QUERY ); aUserData.emplace_back( GetXMLToken( XML_MASTER_ELEMENT ), makeAny( xMaster ) ); } break; - case ANA_SubItem: + case XML_ELEMENT(ANIMATION, XML_SUB_ITEM): + case XML_ELEMENT(ANIMATION_OOO, XML_SUB_ITEM): { if( SvXMLUnitConverter::convertEnum( nEnum, rValue, aAnimations_EnumMap_SubItem ) ) { @@ -885,7 +843,9 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_AttributeName: + case XML_ELEMENT(SMIL, XML_ATTRIBUTENAME): + case XML_ELEMENT(SMIL_COMPAT, XML_ATTRIBUTENAME): + case XML_ELEMENT(SMIL_SO52, XML_ATTRIBUTENAME): { if( xAnimate.is() ) { @@ -909,57 +869,71 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_Values: + case XML_ELEMENT(SMIL, XML_VALUES): + case XML_ELEMENT(SMIL_COMPAT, XML_VALUES): + case XML_ELEMENT(SMIL_SO52, XML_VALUES): { aValues = rValue; } break; - case ANA_From: + case XML_ELEMENT(SMIL, XML_FROM): + case XML_ELEMENT(SMIL_COMPAT, XML_FROM): + case XML_ELEMENT(SMIL_SO52, XML_FROM): { aFrom = rValue; } break; - case ANA_By: + case XML_ELEMENT(SMIL, XML_BY): + case XML_ELEMENT(SMIL_COMPAT, XML_BY): + case XML_ELEMENT(SMIL_SO52, XML_BY): { aBy = rValue; } break; - case ANA_To: + case XML_ELEMENT(SMIL, XML_TO): + case XML_ELEMENT(SMIL_COMPAT, XML_TO): + case XML_ELEMENT(SMIL_SO52, XML_TO): { aTo = rValue; } break; - case ANA_KeyTimes: + case XML_ELEMENT(SMIL, XML_KEYTIMES): + case XML_ELEMENT(SMIL_COMPAT, XML_KEYTIMES): + case XML_ELEMENT(SMIL_SO52, XML_KEYTIMES): { if( xAnimate.is() ) xAnimate->setKeyTimes( AnimationsImportHelperImpl::convertKeyTimes( rValue ) ); } break; - case ANA_Formula: + case XML_ELEMENT(ANIMATION, XML_FORMULA): + case XML_ELEMENT(ANIMATION_OOO, XML_FORMULA): { if( xAnimate.is() ) xAnimate->setFormula( rValue ); } break; - case ANA_ANIMID: + case XML_ELEMENT(ANIMATION, XML_ID): + case XML_ELEMENT(ANIMATION_OOO, XML_ID): { if (!bHaveXmlId) { sXmlId = rValue; } } break; - case ANA_XMLID: + case XML_ELEMENT(XML, XML_ID): { sXmlId = rValue; bHaveXmlId = true; } break; - case ANA_CalcMode: + case XML_ELEMENT(SMIL, XML_CALCMODE): + case XML_ELEMENT(SMIL_COMPAT, XML_CALCMODE): + case XML_ELEMENT(SMIL_SO52, XML_CALCMODE): { if( xAnimate.is() ) { @@ -969,14 +943,21 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_Accumulate: + case XML_ELEMENT(SMIL, XML_ACCUMULATE): + case XML_ELEMENT(SMIL_COMPAT, XML_ACCUMULATE): + case XML_ELEMENT(SMIL_SO52, XML_ACCUMULATE): { if( xAnimate.is() ) xAnimate->setAccumulate( IsXMLToken( rValue, XML_SUM ) ); } break; - case ANA_AdditiveMode: + case XML_ELEMENT(PRESENTATION, XML_ADDITIVE): + case XML_ELEMENT(PRESENTATION_SO52, XML_ADDITIVE): + case XML_ELEMENT(PRESENTATION_OOO, XML_ADDITIVE): + case XML_ELEMENT(SMIL, XML_ADDITIVE): + case XML_ELEMENT(SMIL_COMPAT, XML_ADDITIVE): + case XML_ELEMENT(SMIL_SO52, XML_ADDITIVE): { if( xAnimate.is() ) { @@ -986,14 +967,17 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_KeySplines: + case XML_ELEMENT(SMIL, XML_KEYSPLINES): + case XML_ELEMENT(SMIL_COMPAT, XML_KEYSPLINES): + case XML_ELEMENT(SMIL_SO52, XML_KEYSPLINES): { if( xAnimate.is() ) xAnimate->setTimeFilter( AnimationsImportHelperImpl::convertTimeFilter( rValue ) ); } break; - case ANA_Path: + case XML_ELEMENT(SVG, XML_PATH): + case XML_ELEMENT(SVG_COMPAT, XML_PATH): { Reference< XAnimateMotion > xAnimateMotion( mxNode, UNO_QUERY ); if( xAnimateMotion.is() ) @@ -1001,7 +985,8 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_ColorSpace: + case XML_ELEMENT(ANIMATION, XML_COLOR_INTERPOLATION): + case XML_ELEMENT(ANIMATION_OOO, XML_COLOR_INTERPOLATION): { Reference< XAnimateColor > xAnimateColor( mxNode, UNO_QUERY ); if( xAnimateColor.is() ) @@ -1009,7 +994,8 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_ColorDirection: + case XML_ELEMENT(ANIMATION, XML_COLOR_INTERPOLATION_DIRECTION): + case XML_ELEMENT(ANIMATION_OOO, XML_COLOR_INTERPOLATION_DIRECTION): { Reference< XAnimateColor > xAnimateColor( mxNode, UNO_QUERY ); if( xAnimateColor.is() ) @@ -1017,7 +1003,8 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_TransformType: + case XML_ELEMENT(SVG, XML_TYPE): + case XML_ELEMENT(SVG_COMPAT, XML_TYPE): { Reference< XAnimateTransform > xTransform( mxNode, UNO_QUERY ); if( xTransform.is() ) @@ -1040,7 +1027,9 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_TransitionType: + case XML_ELEMENT(SMIL, XML_TYPE): + case XML_ELEMENT(SMIL_COMPAT, XML_TYPE): + case XML_ELEMENT(SMIL_SO52, XML_TYPE): { if( xTransitionFilter.is() ) { @@ -1050,7 +1039,9 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_TransitionSubType: + case XML_ELEMENT(SMIL, XML_SUBTYPE): + case XML_ELEMENT(SMIL_COMPAT, XML_SUBTYPE): + case XML_ELEMENT(SMIL_SO52, XML_SUBTYPE): { if( xTransitionFilter.is() ) { @@ -1060,21 +1051,27 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_Mode: + case XML_ELEMENT(SMIL, XML_MODE): + case XML_ELEMENT(SMIL_COMPAT, XML_MODE): + case XML_ELEMENT(SMIL_SO52, XML_MODE): { if( xTransitionFilter.is() ) xTransitionFilter->setMode( IsXMLToken( rValue, XML_IN ) ); } break; - case ANA_Direction: + case XML_ELEMENT(SMIL, XML_DIRECTION): + case XML_ELEMENT(SMIL_COMPAT, XML_DIRECTION): + case XML_ELEMENT(SMIL_SO52, XML_DIRECTION): { if( xTransitionFilter.is() ) xTransitionFilter->setDirection( IsXMLToken( rValue, XML_FORWARD ) ); } break; - case ANA_FadeColor: + case XML_ELEMENT(SMIL, XML_FADECOLOR): + case XML_ELEMENT(SMIL_COMPAT, XML_FADECOLOR): + case XML_ELEMENT(SMIL_SO52, XML_FADECOLOR): { if( xTransitionFilter.is() ) { @@ -1085,7 +1082,8 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_IterateType: + case XML_ELEMENT(ANIMATION, XML_ITERATE_TYPE): + case XML_ELEMENT(ANIMATION_OOO, XML_ITERATE_TYPE): { if( SvXMLUnitConverter::convertEnum( nEnum, rValue, aAnimations_EnumMap_IterateType ) ) { @@ -1095,7 +1093,8 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_IterateInterval: + case XML_ELEMENT(ANIMATION, XML_ITERATE_INTERVAL): + case XML_ELEMENT(ANIMATION_OOO, XML_ITERATE_INTERVAL): { if( xIter.is() ) { @@ -1120,13 +1119,16 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; - case ANA_Group_Id: + case XML_ELEMENT(PRESENTATION, XML_GROUP_ID): + case XML_ELEMENT(PRESENTATION_SO52, XML_GROUP_ID): + case XML_ELEMENT(PRESENTATION_OOO, XML_GROUP_ID): { - aUserData.emplace_back( aLocalName, makeAny( rValue.toInt32() ) ); + aUserData.emplace_back( "group-id", makeAny( rValue.toInt32() ) ); } break; - case ANA_Command: + case XML_ELEMENT(ANIMATION, XML_COMMAND): + case XML_ELEMENT(ANIMATION_OOO, XML_COMMAND): { if( xCommand.is() && nNodeType == AnimationNodeType::COMMAND ) { @@ -1139,11 +1141,19 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: break; default: + { + auto nNamespace = (aIter.getToken() & NMSP_MASK); // push all unknown attributes within the presentation namespace as user data - if( nPrefix == XML_NAMESPACE_PRESENTATION ) + if (nNamespace == NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION) + || nNamespace == NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION_SO52) + || nNamespace == NAMESPACE_TOKEN(XML_NAMESPACE_PRESENTATION_OOO)) { - aUserData.emplace_back( aLocalName, makeAny( rValue ) ); + aUserData.emplace_back( SvXMLImport::getNameFromToken(aIter.getToken()), makeAny( rValue ) ); } + else + SAL_WARN("xmloff", "unknown token '" + SvXMLImport::getNameFromToken(aIter.getToken()) + << "' 0x" << std::hex << aIter.getToken()); + } } } @@ -1187,11 +1197,11 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } } -SvXMLImportContextRef AnimationNodeContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > AnimationNodeContext::createFastChildContext(sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) { if( mxNode.is()) - return new AnimationNodeContext( mxNode, GetImport(), nPrefix, rLocalName, xAttrList, mpHelper ); + return new AnimationNodeContext( mxNode, GetImport(), nElement, xAttrList, mpHelper ); return nullptr; } @@ -1202,7 +1212,8 @@ class AnimationsImport: public SvXMLImport, public XAnimationNodeSupplier public: explicit AnimationsImport( const Reference< XComponentContext > & rxContext ); - SvXMLImportContext* CreateDocumentContext(sal_uInt16 nPrefix, const OUString& rLocalName, const Reference<XAttributeList>& xAttrList) override; + SvXMLImportContext* CreateFastContext(sal_Int32 nElement, + const Reference<XFastAttributeList>& xAttrList) override; // XInterface virtual Any SAL_CALL queryInterface( const Type& aType ) override; @@ -1224,22 +1235,6 @@ AnimationsImport::AnimationsImport( const Reference< XComponentContext > & rxCon // remains whether this should be IMPORT_META (same numerical value as // true) or default IMPORT_ALL { - // add namespaces - GetNamespaceMap().Add( - GetXMLToken(XML_NP_PRESENTATION), - GetXMLToken(XML_N_PRESENTATION), - XML_NAMESPACE_PRESENTATION); - - GetNamespaceMap().Add( - GetXMLToken(XML_NP_SMIL), - GetXMLToken(XML_N_SMIL), - XML_NAMESPACE_SMIL); - - GetNamespaceMap().Add( - GetXMLToken(XML_NP_ANIMATION), - GetXMLToken(XML_N_ANIMATION), - XML_NAMESPACE_ANIMATION); - mxRootNode.set( SequenceTimeContainer::create(rxContext), UNO_QUERY_THROW ); } @@ -1266,15 +1261,15 @@ void SAL_CALL AnimationsImport::release() throw () SvXMLImport::release(); } -SvXMLImportContext *AnimationsImport::CreateDocumentContext( - sal_uInt16 const nPrefix, const OUString& rLocalName, - const Reference<XAttributeList>& xAttrList) +SvXMLImportContext *AnimationsImport::CreateFastContext( + sal_Int32 nElement, + const Reference<XFastAttributeList>& xAttrList) { SvXMLImportContext* pContext = nullptr; - if( (XML_NAMESPACE_ANIMATION == nPrefix) && IsXMLToken( rLocalName, XML_SEQ ) ) + if( nElement == XML_ELEMENT(ANIMATION, XML_SEQ) || nElement == XML_ELEMENT(ANIMATION_OOO, XML_SEQ) ) { - pContext = new AnimationNodeContext( mxRootNode, *this, nPrefix, rLocalName, xAttrList ); + pContext = new AnimationNodeContext( mxRootNode, *this, nElement, xAttrList ); } return pContext; diff --git a/xmloff/source/draw/layerimp.cxx b/xmloff/source/draw/layerimp.cxx index 50c6d39061d7..65589c486e17 100644 --- a/xmloff/source/draw/layerimp.cxx +++ b/xmloff/source/draw/layerimp.cxx @@ -168,6 +168,15 @@ SdXMLLayerSetContext::SdXMLLayerSetContext( SvXMLImport& rImport, sal_uInt16 nPr mxLayerManager = xLayerSupplier->getLayerManager(); } +SdXMLLayerSetContext::SdXMLLayerSetContext( SvXMLImport& rImport ) +: SvXMLImportContext(rImport) +{ + Reference< XLayerSupplier > xLayerSupplier( rImport.GetModel(), UNO_QUERY ); + SAL_WARN_IF( !xLayerSupplier.is(), "xmloff", "xmloff::SdXMLLayerSetContext::SdXMLLayerSetContext(), XModel is not supporting XLayerSupplier!" ); + if( xLayerSupplier.is() ) + mxLayerManager = xLayerSupplier->getLayerManager(); +} + SdXMLLayerSetContext::~SdXMLLayerSetContext() { } diff --git a/xmloff/source/draw/layerimp.hxx b/xmloff/source/draw/layerimp.hxx index 031a4a1b44cc..5779442da6ac 100644 --- a/xmloff/source/draw/layerimp.hxx +++ b/xmloff/source/draw/layerimp.hxx @@ -36,8 +36,12 @@ public: sal_uInt16 nPrfx, const OUString& rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList); + SdXMLLayerSetContext( SvXMLImport& rImport ); virtual ~SdXMLLayerSetContext() override; + virtual void SAL_CALL startFastElement (sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttribs*/) override {} + virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override; }; diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx index 19381ce870d2..02dce77bf7cb 100644 --- a/xmloff/source/draw/sdxmlimp.cxx +++ b/xmloff/source/draw/sdxmlimp.cxx @@ -348,11 +348,6 @@ SdXMLImport::SdXMLImport( GetXMLToken(XML_NP_SMIL), GetXMLToken(XML_N_SMIL_COMPAT), XML_NAMESPACE_SMIL); - - GetNamespaceMap().Add( - GetXMLToken(XML_NP_ANIMATION), - GetXMLToken(XML_N_ANIMATION), - XML_NAMESPACE_ANIMATION); } // XImporter diff --git a/xmloff/source/draw/ximpbody.cxx b/xmloff/source/draw/ximpbody.cxx index 40efe2d0797b..147902785c57 100644 --- a/xmloff/source/draw/ximpbody.cxx +++ b/xmloff/source/draw/ximpbody.cxx @@ -40,74 +40,76 @@ using namespace ::com::sun::star; using namespace ::xmloff::token; SdXMLDrawPageContext::SdXMLDrawPageContext( SdXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, uno::Reference< drawing::XShapes > const & rShapes) -: SdXMLGenericPageContext( rImport, nPrfx, rLocalName, xAttrList, rShapes ) +: SdXMLGenericPageContext( rImport, xAttrList, rShapes ) , mbHadSMILNodes( false ) { bool bHaveXmlId( false ); OUString sXmlId, sStyleName, sContextName; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - - for(sal_Int16 i=0; i < nAttrCount; i++) + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList ); + for (auto &aIter : *pAttribList) { - OUString sAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = GetSdImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - OUString sValue = xAttrList->getValueByIndex( i ); - const SvXMLTokenMap& rAttrTokenMap = GetSdImport().GetDrawPageAttrTokenMap(); - - switch(rAttrTokenMap.Get(nPrefix, aLocalName)) + OUString sValue = aIter.toString(); + switch(aIter.getToken()) { - case XML_TOK_DRAWPAGE_NAME: + case XML_ELEMENT(DRAW, XML_NAME): { sContextName = sValue; break; } - case XML_TOK_DRAWPAGE_STYLE_NAME: + case XML_ELEMENT(DRAW, XML_STYLE_NAME): { sStyleName = sValue; break; } - case XML_TOK_DRAWPAGE_MASTER_PAGE_NAME: + case XML_ELEMENT(DRAW, XML_MASTER_PAGE_NAME): { maMasterPageName = sValue; break; } - case XML_TOK_DRAWPAGE_PAGE_LAYOUT_NAME: + case XML_ELEMENT(PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME): + case XML_ELEMENT(PRESENTATION_SO52, XML_PRESENTATION_PAGE_LAYOUT_NAME): + case XML_ELEMENT(PRESENTATION_OOO, XML_PRESENTATION_PAGE_LAYOUT_NAME): { maPageLayoutName = sValue; break; } - case XML_TOK_DRAWPAGE_USE_HEADER_NAME: + case XML_ELEMENT(PRESENTATION, XML_USE_HEADER_NAME): + case XML_ELEMENT(PRESENTATION_SO52, XML_USE_HEADER_NAME): + case XML_ELEMENT(PRESENTATION_OOO, XML_USE_HEADER_NAME): { maUseHeaderDeclName = sValue; break; } - case XML_TOK_DRAWPAGE_USE_FOOTER_NAME: + case XML_ELEMENT(PRESENTATION, XML_USE_FOOTER_NAME): + case XML_ELEMENT(PRESENTATION_SO52, XML_USE_FOOTER_NAME): + case XML_ELEMENT(PRESENTATION_OOO, XML_USE_FOOTER_NAME): { maUseFooterDeclName = sValue; break; } - case XML_TOK_DRAWPAGE_USE_DATE_TIME_NAME: + case XML_ELEMENT(PRESENTATION, XML_USE_DATE_TIME_NAME): + case XML_ELEMENT(PRESENTATION_SO52, XML_USE_DATE_TIME_NAME): + case XML_ELEMENT(PRESENTATION_OOO, XML_USE_DATE_TIME_NAME): { maUseDateTimeDeclName = sValue; break; } - case XML_TOK_DRAWPAGE_DRAWID: + case XML_ELEMENT(DRAW, XML_ID): { if (!bHaveXmlId) { sXmlId = sValue; } } break; - case XML_TOK_DRAWPAGE_XMLID: + case XML_ELEMENT(XML, XML_ID): { sXmlId = sValue; bHaveXmlId = true; } break; - case XML_TOK_DRAWPAGE_HREF: + case XML_ELEMENT(XLINK, XML_HREF): { maHREF = sValue; break; @@ -209,17 +211,15 @@ SdXMLDrawPageContext::~SdXMLDrawPageContext() { } -SvXMLImportContextRef SdXMLDrawPageContext::CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLDrawPageContext::createFastChildContext(sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) { - SvXMLImportContextRef xContext; - const SvXMLTokenMap& rTokenMap = GetSdImport().GetDrawPageElemTokenMap(); - // some special objects inside draw:page context - switch(rTokenMap.Get(nPrefix, rLocalName)) + switch(nElement) { - case XML_TOK_DRAWPAGE_NOTES: + case XML_ELEMENT(PRESENTATION, XML_NOTES): + case XML_ELEMENT(PRESENTATION_SO52, XML_NOTES): + case XML_ELEMENT(PRESENTATION_OOO, XML_NOTES): { if( GetSdImport().IsImpress() ) { @@ -231,42 +231,41 @@ SvXMLImportContextRef SdXMLDrawPageContext::CreateChildContext( sal_uInt16 nPref if(xNotesDrawPage.is()) { // presentation:notes inside draw:page context - xContext = new SdXMLNotesContext( GetSdImport(), nPrefix, rLocalName, xAttrList, xNotesDrawPage); + return new SdXMLNotesContext( GetSdImport(), xAttrList, xNotesDrawPage); } } } break; } - case XML_TOK_DRAWPAGE_PAR: - case XML_TOK_DRAWPAGE_SEQ: + case XML_ELEMENT(ANIMATION, XML_PAR): + case XML_ELEMENT(ANIMATION_OOO, XML_PAR): + case XML_ELEMENT(ANIMATION, XML_SEQ): + case XML_ELEMENT(ANIMATION_OOO, XML_SEQ): { if( GetSdImport().IsImpress() ) { uno::Reference< animations::XAnimationNodeSupplier > xNodeSupplier(GetLocalShapesContext(), uno::UNO_QUERY); if(xNodeSupplier.is()) { - xContext = new xmloff::AnimationNodeContext( xNodeSupplier->getAnimationNode(), GetSdImport(), nPrefix, rLocalName, xAttrList ); mbHadSMILNodes = true; + return new xmloff::AnimationNodeContext( xNodeSupplier->getAnimationNode(), GetSdImport(), nElement, xAttrList ); } } break; } - case XML_TOK_DRAWPAGE_LAYER_SET: + case XML_ELEMENT(DRAW, XML_LAYER_SET): { - xContext = new SdXMLLayerSetContext( GetSdImport(), nPrefix, rLocalName, xAttrList ); + return new SdXMLLayerSetContext( GetSdImport() ); } } // call parent when no own context was created - if (!xContext) - xContext = SdXMLGenericPageContext::CreateChildContext(nPrefix, rLocalName, xAttrList); - - return xContext; + return SdXMLGenericPageContext::createFastChildContext(nElement, xAttrList); } -void SdXMLDrawPageContext::EndElement() +void SdXMLDrawPageContext::endFastElement(sal_Int32 nElement) { - SdXMLGenericPageContext::EndElement(); + SdXMLGenericPageContext::endFastElement(nElement); GetImport().GetShapeImport()->endPage(GetLocalShapesContext()); if( mbHadSMILNodes ) @@ -294,31 +293,12 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLBodyContext::crea switch (nElement) { case XML_ELEMENT(PRESENTATION, XML_SETTINGS): + case XML_ELEMENT(PRESENTATION_SO52, XML_SETTINGS): + case XML_ELEMENT(PRESENTATION_OOO, XML_SETTINGS): { return new SdXMLShowsContext( GetSdImport(), xAttrList ); } - } - return nullptr; -} - -SvXMLImportContextRef SdXMLBodyContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList>& xAttrList ) -{ - SvXMLImportContextRef xContext; - const SvXMLTokenMap& rTokenMap = GetSdImport().GetBodyElemTokenMap(); - - switch(rTokenMap.Get(nPrefix, rLocalName)) - { - case XML_TOK_BODY_HEADER_DECL: - case XML_TOK_BODY_FOOTER_DECL: - case XML_TOK_BODY_DATE_TIME_DECL: - { - xContext = new SdXMLHeaderFooterDeclContext( GetImport(), nPrefix, rLocalName, xAttrList ); - break; - } - case XML_TOK_BODY_PAGE: + case XML_ELEMENT(DRAW, XML_PAGE): { // only read the first page in preview mode if( (GetSdImport().GetNewPageCount() == 0) || !GetSdImport().IsPreview() ) @@ -348,13 +328,33 @@ SvXMLImportContextRef SdXMLBodyContext::CreateChildContext( if(xNewDrawPage.is()) { // draw:page inside office:body context - xContext = new SdXMLDrawPageContext(GetSdImport(), nPrefix, rLocalName, xAttrList, - xNewDrawPage); + return new SdXMLDrawPageContext(GetSdImport(), xAttrList, xNewDrawPage); } } break; } } + return nullptr; +} + +SvXMLImportContextRef SdXMLBodyContext::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContextRef xContext; + const SvXMLTokenMap& rTokenMap = GetSdImport().GetBodyElemTokenMap(); + + switch(rTokenMap.Get(nPrefix, rLocalName)) + { + case XML_TOK_BODY_HEADER_DECL: + case XML_TOK_BODY_FOOTER_DECL: + case XML_TOK_BODY_DATE_TIME_DECL: + { + xContext = new SdXMLHeaderFooterDeclContext( GetImport(), nPrefix, rLocalName, xAttrList ); + break; + } + } return xContext; } diff --git a/xmloff/source/draw/ximpbody.hxx b/xmloff/source/draw/ximpbody.hxx index 9c527d823961..1cee8fe94422 100644 --- a/xmloff/source/draw/ximpbody.hxx +++ b/xmloff/source/draw/ximpbody.hxx @@ -34,16 +34,14 @@ class SdXMLDrawPageContext : public SdXMLGenericPageContext bool mbHadSMILNodes; public: - SdXMLDrawPageContext( SdXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + SdXMLDrawPageContext( SdXMLImport& rImport, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXMLDrawPageContext() override; - virtual SvXMLImportContextRef CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override; - virtual void EndElement() override; + virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& Attribs) override; + virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; }; diff --git a/xmloff/source/draw/ximpnote.cxx b/xmloff/source/draw/ximpnote.cxx index 503cb1c4f12d..90d9fe90dd39 100644 --- a/xmloff/source/draw/ximpnote.cxx +++ b/xmloff/source/draw/ximpnote.cxx @@ -18,8 +18,10 @@ */ #include "ximpnote.hxx" +#include <xmloff/xmlnmspe.hxx> using namespace ::com::sun::star; +using namespace ::xmloff::token; SdXMLNotesContext::SdXMLNotesContext( SdXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, @@ -87,6 +89,73 @@ SdXMLNotesContext::SdXMLNotesContext( SdXMLImport& rImport, } } +SdXMLNotesContext::SdXMLNotesContext( SdXMLImport& rImport, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, + uno::Reference< drawing::XShapes > const & rShapes) +: SdXMLGenericPageContext( rImport, xAttrList, rShapes ) +{ + OUString sStyleName, sPageMasterName; + + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList ); + for (auto &aIter : *pAttribList) + { + OUString sValue = aIter.toString(); + switch(aIter.getToken()) + { + case XML_ELEMENT(STYLE, XML_PAGE_LAYOUT_NAME): + { + sPageMasterName = sValue; + break; + } + case XML_ELEMENT(DRAW, XML_STYLE_NAME): + { + sStyleName = sValue; + break; + } + case XML_ELEMENT(PRESENTATION, XML_USE_HEADER_NAME): + case XML_ELEMENT(PRESENTATION_SO52, XML_USE_HEADER_NAME): + case XML_ELEMENT(PRESENTATION_OOO, XML_USE_HEADER_NAME): + { + maUseHeaderDeclName = sValue; + break; + } + case XML_ELEMENT(PRESENTATION, XML_USE_FOOTER_NAME): + case XML_ELEMENT(PRESENTATION_SO52, XML_USE_FOOTER_NAME): + case XML_ELEMENT(PRESENTATION_OOO, XML_USE_FOOTER_NAME): + { + maUseFooterDeclName = sValue; + break; + } + case XML_ELEMENT(PRESENTATION, XML_USE_DATE_TIME_NAME): + case XML_ELEMENT(PRESENTATION_SO52, XML_USE_DATE_TIME_NAME): + case XML_ELEMENT(PRESENTATION_OOO, XML_USE_DATE_TIME_NAME): + { + maUseDateTimeDeclName = sValue; + break; + } + + } + } + + SetStyle( sStyleName ); + + // now delete all up-to-now contained shapes from this notes page + uno::Reference< drawing::XShape > xShape; + while(rShapes->getCount()) + { + rShapes->getByIndex(0) >>= xShape; + if(xShape.is()) + rShapes->remove(xShape); + } + + // set page-master? + if(!sPageMasterName.isEmpty()) + { + SetPageMaster( sPageMasterName ); + } +} + SdXMLNotesContext::~SdXMLNotesContext() { } diff --git a/xmloff/source/draw/ximpnote.hxx b/xmloff/source/draw/ximpnote.hxx index 1e66b3ce1ced..3a1e91857b67 100644 --- a/xmloff/source/draw/ximpnote.hxx +++ b/xmloff/source/draw/ximpnote.hxx @@ -32,6 +32,9 @@ public: const OUString& rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); + SdXMLNotesContext( SdXMLImport& rImport, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, + css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXMLNotesContext() override; }; diff --git a/xmloff/source/draw/ximppage.cxx b/xmloff/source/draw/ximppage.cxx index e56e9ac9359e..ad54a1085b1e 100644 --- a/xmloff/source/draw/ximppage.cxx +++ b/xmloff/source/draw/ximppage.cxx @@ -231,6 +231,26 @@ SdXMLGenericPageContext::SdXMLGenericPageContext( } } +SdXMLGenericPageContext::SdXMLGenericPageContext( + SvXMLImport& rImport, + const Reference< xml::sax::XFastAttributeList>& xAttrList, + Reference< drawing::XShapes > const & rShapes) +: SvXMLImportContext( rImport ) +, mxShapes( rShapes ) +, mxAnnotationAccess( rShapes, UNO_QUERY ) +{ + sax_fastparser::FastAttributeList *pAttribList = + sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList ); + for (auto &aIter : *pAttribList) + { + if( aIter.getToken() == XML_ELEMENT(DRAW, XML_NAV_ORDER) ) + { + msNavOrder = aIter.toString(); + break; + } + } +} + SdXMLGenericPageContext::~SdXMLGenericPageContext() { } @@ -243,6 +263,14 @@ void SdXMLGenericPageContext::StartElement( const Reference< css::xml::sax::XAtt GetImport().GetFormImport()->startPage( Reference< drawing::XDrawPage >::query( mxShapes ) ); } +void SdXMLGenericPageContext::startFastElement( sal_Int32 /*nElement*/, const Reference< css::xml::sax::XFastAttributeList >& ) +{ + GetImport().GetShapeImport()->pushGroupForPostProcessing( mxShapes ); + + if( GetImport().IsFormsSupported() ) + GetImport().GetFormImport()->startPage( Reference< drawing::XDrawPage >::query( mxShapes ) ); +} + SvXMLImportContextRef SdXMLGenericPageContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< xml::sax::XAttributeList>& xAttrList ) @@ -349,6 +377,82 @@ void SdXMLGenericPageContext::EndElement() SetNavigationOrder(); } +void SdXMLGenericPageContext::endFastElement(sal_Int32 ) +{ + GetImport().GetShapeImport()->popGroupAndPostProcess(); + + if( GetImport().IsFormsSupported() ) + GetImport().GetFormImport()->endPage(); + + if( !maUseHeaderDeclName.isEmpty() || !maUseFooterDeclName.isEmpty() || !maUseDateTimeDeclName.isEmpty() ) + { + try + { + Reference <beans::XPropertySet> xSet(mxShapes, uno::UNO_QUERY_THROW ); + Reference< beans::XPropertySetInfo > xInfo( xSet->getPropertySetInfo() ); + + if( !maUseHeaderDeclName.isEmpty() ) + { + const OUString aStrHeaderTextProp( "HeaderText" ); + if( xInfo->hasPropertyByName( aStrHeaderTextProp ) ) + xSet->setPropertyValue( aStrHeaderTextProp, + makeAny( GetSdImport().GetHeaderDecl( maUseHeaderDeclName ) ) ); + } + + if( !maUseFooterDeclName.isEmpty() ) + { + const OUString aStrFooterTextProp( "FooterText" ); + if( xInfo->hasPropertyByName( aStrFooterTextProp ) ) + xSet->setPropertyValue( aStrFooterTextProp, + makeAny( GetSdImport().GetFooterDecl( maUseFooterDeclName ) ) ); + } + + if( !maUseDateTimeDeclName.isEmpty() ) + { + const OUString aStrDateTimeTextProp( "DateTimeText" ); + if( xInfo->hasPropertyByName( aStrDateTimeTextProp ) ) + { + bool bFixed; + OUString aDateTimeFormat; + const OUString aText( GetSdImport().GetDateTimeDecl( maUseDateTimeDeclName, bFixed, aDateTimeFormat ) ); + + xSet->setPropertyValue("IsDateTimeFixed", + makeAny( bFixed ) ); + + if( bFixed ) + { + xSet->setPropertyValue( aStrDateTimeTextProp, makeAny( aText ) ); + } + else if( !aDateTimeFormat.isEmpty() ) + { + const SdXMLStylesContext* pStyles = dynamic_cast< const SdXMLStylesContext* >( GetSdImport().GetShapeImport()->GetStylesContext() ); + if( !pStyles ) + pStyles = dynamic_cast< const SdXMLStylesContext* >( GetSdImport().GetShapeImport()->GetAutoStylesContext() ); + + if( pStyles ) + { + const SdXMLNumberFormatImportContext* pSdNumStyle = + dynamic_cast< const SdXMLNumberFormatImportContext* >( pStyles->FindStyleChildContext( XmlStyleFamily::DATA_STYLE, aDateTimeFormat, true ) ); + + if( pSdNumStyle ) + { + xSet->setPropertyValue("DateTimeFormat", + makeAny( pSdNumStyle->GetDrawKey() ) ); + } + } + } + } + } + } + catch(const uno::Exception&) + { + OSL_FAIL("xmloff::SdXMLGenericPageContext::EndElement(), unexpected exception caught!"); + } + } + + SetNavigationOrder(); +} + void SdXMLGenericPageContext::SetStyle( OUString const & rStyleName ) { // set PageProperties? diff --git a/xmloff/source/draw/ximppage.hxx b/xmloff/source/draw/ximppage.hxx index 4705726c6a2f..5e9079363200 100644 --- a/xmloff/source/draw/ximppage.hxx +++ b/xmloff/source/draw/ximppage.hxx @@ -62,13 +62,18 @@ public: SdXMLGenericPageContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, css::uno::Reference< css::drawing::XShapes > const & rShapes); + SdXMLGenericPageContext( SvXMLImport& rImport, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, + css::uno::Reference< css::drawing::XShapes > const & rShapes); virtual ~SdXMLGenericPageContext() 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 >& xAttrList ) override; virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) override; virtual void EndElement() override; + virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; const css::uno::Reference< css::drawing::XShapes >& GetLocalShapesContext() const { return mxShapes; } diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt index f9411a191330..34e145b30e46 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -2355,6 +2355,7 @@ N_TABLE_OOO_DUMMY N_DRAW_OOO_DUMMY N_DR3D_OOO_DUMMY N_PRESENTATION_OOO_DUMMY +N_PRESENTATION_OASIS_DUMMY N_CHART_OOO_DUMMY N_CONFIG_OOO_DUMMY N_FORM_OOO_DUMMY @@ -2617,6 +2618,7 @@ smil N_SMIL_DUMMY anim N_ANIMATION_DUMMY +N_ANIMATION_OOO_DUMMY par seq translate |