From c7e184598540af5b609e77518abbd0f51b9e38ec Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Fri, 14 Jun 2013 16:53:52 +0300 Subject: Further MCE work As it is wrong (says Thorsten) to override the methods from XFastContextHandler in ContextHandler2 in its derived classes, mark them with SAL_FINAL to catch that (when compiling with a compiler thaty supports "final"). Do corresponding changes then; change createFastChildContext() methods to onCreateContext() ones instead. Now the unit tests work, and a sample PPTX that uses embedded OLE thingies loads without crash, but unfortunately it looks like crap... Change-Id: Ie30022f37418ba9caf8ce59fe4003b808fa900f3 Reviewed-on: https://gerrit.libreoffice.org/4578 Reviewed-by: Fridrich Strba Tested-by: Fridrich Strba --- include/oox/core/contexthandler2.hxx | 8 +- include/oox/core/fragmenthandler2.hxx | 8 +- include/oox/drawingml/connectorshapecontext.hxx | 2 +- include/oox/drawingml/graphicshapecontext.hxx | 16 ++- include/oox/drawingml/shapecontext.hxx | 3 +- include/oox/drawingml/shapegroupcontext.hxx | 2 +- include/oox/drawingml/table/tablecontext.hxx | 2 +- .../table/tablestylelistfragmenthandler.hxx | 2 +- include/oox/ppt/pptgraphicshapecontext.hxx | 2 +- include/oox/ppt/pptshapecontext.hxx | 2 +- include/oox/ppt/pptshapegroupcontext.hxx | 6 +- oox/source/drawingml/connectorshapecontext.cxx | 11 +- .../drawingml/diagram/constraintlistcontext.cxx | 43 +++----- .../drawingml/diagram/constraintlistcontext.hxx | 3 +- .../drawingml/diagram/diagramdefinitioncontext.cxx | 41 +++----- .../drawingml/diagram/diagramdefinitioncontext.hxx | 3 +- .../drawingml/diagram/diagramfragmenthandler.cxx | 17 +-- .../drawingml/diagram/diagramfragmenthandler.hxx | 2 +- oox/source/drawingml/diagram/layoutnodecontext.cxx | 117 ++++++++------------- oox/source/drawingml/diagram/layoutnodecontext.hxx | 3 +- oox/source/drawingml/graphicshapecontext.cxx | 90 ++++++---------- oox/source/drawingml/shapecontext.cxx | 43 +++----- oox/source/drawingml/shapegroupcontext.cxx | 46 +++----- oox/source/drawingml/table/tablecontext.cxx | 38 +++---- .../table/tablestylelistfragmenthandler.cxx | 15 +-- oox/source/ppt/extdrawingfragmenthandler.cxx | 19 ++-- oox/source/ppt/extdrawingfragmenthandler.hxx | 4 +- oox/source/ppt/pptgraphicshapecontext.cxx | 30 ++---- oox/source/ppt/pptshapecontext.cxx | 33 +++--- oox/source/ppt/pptshapegroupcontext.cxx | 53 ++++------ oox/source/shape/ShapeDrawingFragmentHandler.cxx | 12 +-- oox/source/shape/ShapeDrawingFragmentHandler.hxx | 4 +- sc/source/filter/inc/drawingfragment.hxx | 7 +- sc/source/filter/oox/drawingfragment.cxx | 8 +- 34 files changed, 250 insertions(+), 445 deletions(-) diff --git a/include/oox/core/contexthandler2.hxx b/include/oox/core/contexthandler2.hxx index f1a0c7db38b2..03e4f1bf1785 100644 --- a/include/oox/core/contexthandler2.hxx +++ b/include/oox/core/contexthandler2.hxx @@ -228,21 +228,21 @@ public: sal_Int32 nElement, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) throw( ::com::sun::star::xml::sax::SAXException, - ::com::sun::star::uno::RuntimeException ); + ::com::sun::star::uno::RuntimeException ) SAL_FINAL; virtual void SAL_CALL startFastElement( sal_Int32 nElement, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) throw( ::com::sun::star::xml::sax::SAXException, - ::com::sun::star::uno::RuntimeException ); + ::com::sun::star::uno::RuntimeException ) SAL_FINAL; virtual void SAL_CALL characters( const OUString& rChars ) throw( ::com::sun::star::xml::sax::SAXException, - ::com::sun::star::uno::RuntimeException ); + ::com::sun::star::uno::RuntimeException ) SAL_FINAL; virtual void SAL_CALL endFastElement( sal_Int32 nElement ) throw( ::com::sun::star::xml::sax::SAXException, - ::com::sun::star::uno::RuntimeException ); + ::com::sun::star::uno::RuntimeException ) SAL_FINAL; // oox.core.ContextHandler interface -------------------------------------- diff --git a/include/oox/core/fragmenthandler2.hxx b/include/oox/core/fragmenthandler2.hxx index 21ad03619fd1..5f2e8b6d5f8a 100644 --- a/include/oox/core/fragmenthandler2.hxx +++ b/include/oox/core/fragmenthandler2.hxx @@ -62,21 +62,21 @@ public: sal_Int32 nElement, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) throw( ::com::sun::star::xml::sax::SAXException, - ::com::sun::star::uno::RuntimeException ); + ::com::sun::star::uno::RuntimeException ) SAL_FINAL; virtual void SAL_CALL startFastElement( sal_Int32 nElement, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) throw( ::com::sun::star::xml::sax::SAXException, - ::com::sun::star::uno::RuntimeException ); + ::com::sun::star::uno::RuntimeException ) SAL_FINAL; virtual void SAL_CALL characters( const OUString& rChars ) throw( ::com::sun::star::xml::sax::SAXException, - ::com::sun::star::uno::RuntimeException ); + ::com::sun::star::uno::RuntimeException ) SAL_FINAL; virtual void SAL_CALL endFastElement( sal_Int32 nElement ) throw( ::com::sun::star::xml::sax::SAXException, - ::com::sun::star::uno::RuntimeException ); + ::com::sun::star::uno::RuntimeException ) SAL_FINAL; // com.sun.star.xml.sax.XFastDocumentHandler interface -------------------- diff --git a/include/oox/drawingml/connectorshapecontext.hxx b/include/oox/drawingml/connectorshapecontext.hxx index e320147a0458..5429fc8826b0 100644 --- a/include/oox/drawingml/connectorshapecontext.hxx +++ b/include/oox/drawingml/connectorshapecontext.hxx @@ -31,7 +31,7 @@ class OOX_DLLPUBLIC ConnectorShapeContext : public ShapeContext public: ConnectorShapeContext( ::oox::core::ContextHandler2Helper& rParent, ShapePtr pMasterShapePtr, ShapePtr pGroupShapePtr ); virtual ~ConnectorShapeContext(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; }; } } diff --git a/include/oox/drawingml/graphicshapecontext.hxx b/include/oox/drawingml/graphicshapecontext.hxx index 8d85fd0557dd..c2aa54e0d839 100644 --- a/include/oox/drawingml/graphicshapecontext.hxx +++ b/include/oox/drawingml/graphicshapecontext.hxx @@ -33,8 +33,7 @@ class OOX_DLLPUBLIC GraphicShapeContext : public ShapeContext public: GraphicShapeContext( ::oox::core::ContextHandler2Helper& rParent, ShapePtr pMasterShapePtr, ShapePtr pShapePtr ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); - + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; }; // ==================================================================== @@ -44,7 +43,7 @@ class OOX_DLLPUBLIC GraphicalObjectFrameContext : public ShapeContext public: GraphicalObjectFrameContext( ::oox::core::ContextHandler2Helper& rParent, ShapePtr pMasterShapePtr, ShapePtr pShapePtr, bool bEmbedShapesInChart ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; private: bool mbEmbedShapesInChart; @@ -57,7 +56,7 @@ class OleObjectGraphicDataContext : public ShapeContext public: OleObjectGraphicDataContext( ::oox::core::ContextHandler2Helper& rParent, ShapePtr pShapePtr ); ~OleObjectGraphicDataContext(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; private: ::oox::vml::OleObjectInfo& mrOleObjectInfo; @@ -73,7 +72,7 @@ class DiagramGraphicDataContext public: DiagramGraphicDataContext( ::oox::core::ContextHandler2Helper& rParent, ShapePtr pShapePtr ); virtual ~DiagramGraphicDataContext(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; private: OUString msDm; @@ -91,11 +90,10 @@ public: ::oox::core::ContextHandler2Helper& rParent, const ShapePtr& rxShape, bool bEmbedShapes ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL - createFastChildContext( + virtual ::oox::core::ContextHandlerRef + onCreateContext( sal_Int32 nElement, - const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) - throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + const ::oox::AttributeList& rAttribs) SAL_OVERRIDE; private: ChartShapeInfo& mrChartShapeInfo; diff --git a/include/oox/drawingml/shapecontext.hxx b/include/oox/drawingml/shapecontext.hxx index 5632656c6591..469670991319 100644 --- a/include/oox/drawingml/shapecontext.hxx +++ b/include/oox/drawingml/shapecontext.hxx @@ -35,8 +35,7 @@ public: ShapeContext( ::oox::core::ContextHandler2Helper& rParent, ShapePtr pMasterShapePtr, ShapePtr pShapePtr ); virtual ~ShapeContext(); - virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; ShapePtr getShape(); diff --git a/include/oox/drawingml/shapegroupcontext.hxx b/include/oox/drawingml/shapegroupcontext.hxx index 71df8ccec2e9..9a199589802a 100644 --- a/include/oox/drawingml/shapegroupcontext.hxx +++ b/include/oox/drawingml/shapegroupcontext.hxx @@ -31,7 +31,7 @@ class OOX_DLLPUBLIC ShapeGroupContext : public ::oox::core::ContextHandler2 public: ShapeGroupContext( ::oox::core::ContextHandler2Helper& rParent, ShapePtr pMasterShapePtr, ShapePtr pGroupShapePtr ); virtual ~ShapeGroupContext(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; protected: diff --git a/include/oox/drawingml/table/tablecontext.hxx b/include/oox/drawingml/table/tablecontext.hxx index f1d915407300..311bf90d19f7 100644 --- a/include/oox/drawingml/table/tablecontext.hxx +++ b/include/oox/drawingml/table/tablecontext.hxx @@ -33,7 +33,7 @@ public: TableContext( ::oox::core::ContextHandler2Helper& rParent, ShapePtr pShapePtr ); ~TableContext(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; private: diff --git a/include/oox/drawingml/table/tablestylelistfragmenthandler.hxx b/include/oox/drawingml/table/tablestylelistfragmenthandler.hxx index d6ef77f8614c..c145d21ae772 100644 --- a/include/oox/drawingml/table/tablestylelistfragmenthandler.hxx +++ b/include/oox/drawingml/table/tablestylelistfragmenthandler.hxx @@ -38,7 +38,7 @@ public: TableStyleList& rTableStyleList ); virtual ~TableStyleListFragmentHandler(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const AttributeList& rAttribs ) SAL_OVERRIDE; private: diff --git a/include/oox/ppt/pptgraphicshapecontext.hxx b/include/oox/ppt/pptgraphicshapecontext.hxx index ebed5902c27b..99492d6d0e32 100644 --- a/include/oox/ppt/pptgraphicshapecontext.hxx +++ b/include/oox/ppt/pptgraphicshapecontext.hxx @@ -30,7 +30,7 @@ class PPTGraphicShapeContext : public ::oox::drawingml::GraphicShapeContext public: PPTGraphicShapeContext( ::oox::core::ContextHandler2Helper& rParent, const SlidePersistPtr pSlidePersistPtr, oox::drawingml::ShapePtr pMasterShapePtr, oox::drawingml::ShapePtr pShapePtr ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; }; } } diff --git a/include/oox/ppt/pptshapecontext.hxx b/include/oox/ppt/pptshapecontext.hxx index 078bc7f8226f..f746b659d7f0 100644 --- a/include/oox/ppt/pptshapecontext.hxx +++ b/include/oox/ppt/pptshapecontext.hxx @@ -30,7 +30,7 @@ class PPTShapeContext : public ::oox::drawingml::ShapeContext public: PPTShapeContext( ::oox::core::ContextHandler2Helper& rParent, const SlidePersistPtr pSlidePersistPtr, oox::drawingml::ShapePtr pMasterShapePtr, oox::drawingml::ShapePtr pShapePtr ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; }; } } diff --git a/include/oox/ppt/pptshapegroupcontext.hxx b/include/oox/ppt/pptshapegroupcontext.hxx index aebc347f47dc..efa2c5b246e7 100644 --- a/include/oox/ppt/pptshapegroupcontext.hxx +++ b/include/oox/ppt/pptshapegroupcontext.hxx @@ -40,10 +40,10 @@ public: oox::drawingml::ShapePtr pMasterShapePtr, oox::drawingml::ShapePtr pGroupShapePtr ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL - createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef + onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; - virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL onEndElement() SAL_OVERRIDE; protected: diff --git a/oox/source/drawingml/connectorshapecontext.cxx b/oox/source/drawingml/connectorshapecontext.cxx index 461bd51ff5f4..4fa115aa99fa 100644 --- a/oox/source/drawingml/connectorshapecontext.cxx +++ b/oox/source/drawingml/connectorshapecontext.cxx @@ -48,23 +48,18 @@ ConnectorShapeContext::~ConnectorShapeContext() { } -Reference< XFastContextHandler > ConnectorShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +ContextHandlerRef ConnectorShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( getBaseToken( aElementToken ) ) { case XML_nvCxnSpPr : break; default: - xRet = ShapeContext::createFastChildContext( aElementToken, xAttribs ); + return ShapeContext::onCreateContext( aElementToken, rAttribs ); } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } } } diff --git a/oox/source/drawingml/diagram/constraintlistcontext.cxx b/oox/source/drawingml/diagram/constraintlistcontext.cxx index beb06909eec3..b93ac3d09582 100644 --- a/oox/source/drawingml/diagram/constraintlistcontext.cxx +++ b/oox/source/drawingml/diagram/constraintlistcontext.cxx @@ -41,20 +41,10 @@ ConstraintListContext::~ConstraintListContext() { } -void SAL_CALL ConstraintListContext::endFastElement( ::sal_Int32 ) - throw (SAXException, RuntimeException) +ContextHandlerRef +ConstraintListContext::onCreateContext( ::sal_Int32 aElement, + const AttributeList& rAttribs ) { -} - -Reference< XFastContextHandler > SAL_CALL -ConstraintListContext::createFastChildContext( ::sal_Int32 aElement, - const Reference< XFastAttributeList >& xAttribs ) - throw (SAXException, RuntimeException) -{ - Reference< XFastContextHandler > xRet; - - OUString aEmptyStr; - switch( aElement ) { case DGM_TOKEN( constr ): @@ -62,27 +52,24 @@ ConstraintListContext::createFastChildContext( ::sal_Int32 aElement, ConstraintAtomPtr pNode( new ConstraintAtom() ); mpNode->addChild( pNode ); - AttributeList aAttribs( xAttribs ); - pNode->setFor( aAttribs.getToken( XML_for, XML_none ) ); - pNode->setForName( aAttribs.getString( XML_forName, aEmptyStr ) ); - pNode->setPointType( aAttribs.getToken( XML_ptType, XML_none ) ); - pNode->setType( aAttribs.getToken( XML_type, XML_none ) ); - pNode->setRefFor( aAttribs.getToken( XML_refFor, XML_none ) ); - pNode->setRefForName( aAttribs.getString( XML_refForName, aEmptyStr ) ); - pNode->setRefType( aAttribs.getToken( XML_refType, XML_none ) ); - pNode->setRefPointType( aAttribs.getToken( XML_refPtType, XML_none ) ); - pNode->setFactor( aAttribs.getDouble( XML_fact, 1.0 ) ); - pNode->setValue( aAttribs.getDouble( XML_val, 0.0 ) ); - pNode->setOperator( aAttribs.getToken( XML_op, XML_none ) ); + pNode->setFor( rAttribs.getToken( XML_for, XML_none ) ); + pNode->setForName( rAttribs.getString( XML_forName, "" ) ); + pNode->setPointType( rAttribs.getToken( XML_ptType, XML_none ) ); + pNode->setType( rAttribs.getToken( XML_type, XML_none ) ); + pNode->setRefFor( rAttribs.getToken( XML_refFor, XML_none ) ); + pNode->setRefForName( rAttribs.getString( XML_refForName, "" ) ); + pNode->setRefType( rAttribs.getToken( XML_refType, XML_none ) ); + pNode->setRefPointType( rAttribs.getToken( XML_refPtType, XML_none ) ); + pNode->setFactor( rAttribs.getDouble( XML_fact, 1.0 ) ); + pNode->setValue( rAttribs.getDouble( XML_val, 0.0 ) ); + pNode->setOperator( rAttribs.getToken( XML_op, XML_none ) ); break; } default: break; } - if( !xRet.is() ) - xRet.set(this); - return xRet; + return this; } diff --git a/oox/source/drawingml/diagram/constraintlistcontext.hxx b/oox/source/drawingml/diagram/constraintlistcontext.hxx index cca5dd0052f0..78b1bd27f34c 100644 --- a/oox/source/drawingml/diagram/constraintlistcontext.hxx +++ b/oox/source/drawingml/diagram/constraintlistcontext.hxx @@ -32,8 +32,7 @@ public: ConstraintListContext( ContextHandler2Helper& rParent, const AttributeList& rAttributes, const LayoutAtomPtr &pNode ); virtual ~ConstraintListContext(); - virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const AttributeList& rAttribs ) SAL_OVERRIDE; private: LayoutAtomPtr mpNode; }; diff --git a/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx b/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx index c0efc3c91292..d5d5411bb0a0 100644 --- a/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx +++ b/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx @@ -52,59 +52,44 @@ DiagramDefinitionContext::~DiagramDefinitionContext() mpLayout->getNode()->dump(0); } -void SAL_CALL DiagramDefinitionContext::endFastElement( ::sal_Int32 ) - throw (SAXException, RuntimeException) +ContextHandlerRef +DiagramDefinitionContext::onCreateContext( ::sal_Int32 aElement, + const AttributeList& rAttribs ) { - -} - - -Reference< XFastContextHandler > SAL_CALL -DiagramDefinitionContext::createFastChildContext( ::sal_Int32 aElement, - const Reference< XFastAttributeList >& xAttribs ) - throw (SAXException, RuntimeException) -{ - Reference< XFastContextHandler > xRet; - switch( aElement ) { case DGM_TOKEN( title ): - mpLayout->setTitle( xAttribs->getOptionalValue( XML_val ) ); + mpLayout->setTitle( rAttribs.getString( XML_val ).get() ); break; case DGM_TOKEN( desc ): - mpLayout->setDesc( xAttribs->getOptionalValue( XML_val ) ); + mpLayout->setDesc( rAttribs.getString( XML_val ).get() ); break; case DGM_TOKEN( layoutNode ): { LayoutNodePtr pNode( new LayoutNode() ); mpLayout->getNode() = pNode; - pNode->setChildOrder( xAttribs->getOptionalValueToken( XML_chOrder, XML_b ) ); - pNode->setMoveWith( xAttribs->getOptionalValue( XML_moveWith ) ); - pNode->setStyleLabel( xAttribs->getOptionalValue( XML_styleLbl ) ); - xRet.set( new LayoutNodeContext( *this, AttributeList( xAttribs ), pNode ) ); - break; + pNode->setChildOrder( rAttribs.getToken( XML_chOrder, XML_b ) ); + pNode->setMoveWith( rAttribs.getString( XML_moveWith ).get() ); + pNode->setStyleLabel( rAttribs.getString( XML_styleLbl ).get() ); + return new LayoutNodeContext( *this, rAttribs, pNode ); } case DGM_TOKEN( clrData ): // TODO, does not matter for the UI. skip. - return xRet; + return 0; case DGM_TOKEN( sampData ): mpLayout->getSampData().reset( new DiagramData ); - xRet.set( new DataModelContext( *this, mpLayout->getSampData() ) ); - break; + return new DataModelContext( *this, mpLayout->getSampData() ); case DGM_TOKEN( styleData ): mpLayout->getStyleData().reset( new DiagramData ); - xRet.set( new DataModelContext( *this, mpLayout->getStyleData() ) ); - break; + return new DataModelContext( *this, mpLayout->getStyleData() ); case DGM_TOKEN( cat ): case DGM_TOKEN( catLst ): // TODO, does not matter for the UI default: break; } - if( !xRet.is() ) - xRet.set(this); - return xRet; + return this; } diff --git a/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx b/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx index aca89f8e6332..983c2dfa3591 100644 --- a/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx +++ b/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx @@ -31,8 +31,7 @@ public: DiagramDefinitionContext( ::oox::core::ContextHandler2Helper& rParent, const ::oox::AttributeList& rAttributes, const DiagramLayoutPtr &pLayout ); virtual ~DiagramDefinitionContext(); - virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; private: DiagramLayoutPtr mpLayout; diff --git a/oox/source/drawingml/diagram/diagramfragmenthandler.cxx b/oox/source/drawingml/diagram/diagramfragmenthandler.cxx index e7687c31948e..cea339ad1758 100644 --- a/oox/source/drawingml/diagram/diagramfragmenthandler.cxx +++ b/oox/source/drawingml/diagram/diagramfragmenthandler.cxx @@ -96,26 +96,19 @@ void SAL_CALL DiagramLayoutFragmentHandler::endDocument() } -Reference< XFastContextHandler > SAL_CALL -DiagramLayoutFragmentHandler::createFastChildContext( ::sal_Int32 aElement, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException) +ContextHandlerRef +DiagramLayoutFragmentHandler::onCreateContext( ::sal_Int32 aElement, + const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( aElement ) { case DGM_TOKEN( layoutDef ): - xRet.set( new DiagramDefinitionContext( *this, AttributeList( xAttribs ), mpDataPtr ) ); - break; + return new DiagramDefinitionContext( *this, AttributeList( rAttribs ), mpDataPtr ); default: break; } - if( !xRet.is() ) - xRet = getFastContextHandler(); - - return xRet; + return this; } /////////////////////// diff --git a/oox/source/drawingml/diagram/diagramfragmenthandler.hxx b/oox/source/drawingml/diagram/diagramfragmenthandler.hxx index 13385427a050..95808ce243d8 100644 --- a/oox/source/drawingml/diagram/diagramfragmenthandler.hxx +++ b/oox/source/drawingml/diagram/diagramfragmenthandler.hxx @@ -50,7 +50,7 @@ public: virtual ~DiagramLayoutFragmentHandler() throw(); virtual void SAL_CALL endDocument() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; private: diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx b/oox/source/drawingml/diagram/layoutnodecontext.cxx index 5be7ec622b8e..17c16efeae15 100644 --- a/oox/source/drawingml/diagram/layoutnodecontext.cxx +++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx @@ -58,32 +58,25 @@ public: pNode->setType(rAttribs.getToken(XML_type, 0)); } - virtual Reference< XFastContextHandler > SAL_CALL - createFastChildContext( ::sal_Int32 aElement, - const Reference< XFastAttributeList >& xAttribs ) - throw (SAXException, RuntimeException) + virtual ContextHandlerRef + onCreateContext( ::sal_Int32 aElement, + const AttributeList& rAttribs ) SAL_OVERRIDE { - Reference< XFastContextHandler > xRet; - switch( aElement ) { case DGM_TOKEN( param ): { - AttributeList aAttribs( xAttribs ); - const sal_Int32 nValTok=aAttribs.getToken( XML_val, 0 ); + const sal_Int32 nValTok = rAttribs.getToken( XML_val, 0 ); mpNode->addParam( - aAttribs.getToken( XML_type, 0 ), - nValTok>0 ? nValTok : aAttribs.getInteger( XML_val, 0 ) ); + rAttribs.getToken( XML_type, 0 ), + nValTok>0 ? nValTok : rAttribs.getInteger( XML_val, 0 ) ); break; } default: break; } - if( !xRet.is() ) - xRet.set(this); - - return xRet; + return this; } private: @@ -103,30 +96,27 @@ public: msName = rAttribs.getString( XML_name ).get(); } - virtual Reference< XFastContextHandler > SAL_CALL - createFastChildContext( ::sal_Int32 aElement, - const Reference< XFastAttributeList >& xAttribs ) - throw (SAXException, RuntimeException) + virtual ContextHandlerRef + onCreateContext( ::sal_Int32 aElement, + const AttributeList& rAttribs ) SAL_OVERRIDE { - Reference< XFastContextHandler > xRet; - switch( aElement ) { case DGM_TOKEN( if ): { // CT_When - mpConditionNode.reset( new ConditionAtom(xAttribs) ); + mpConditionNode.reset( new ConditionAtom(rAttribs.getFastAttributeList()) ); mpNode->addChild( mpConditionNode ); - xRet.set( new IfContext( *this, AttributeList( xAttribs ), mpConditionNode ) ); - break; + return new IfContext( *this, rAttribs, mpConditionNode ); } case DGM_TOKEN( else ): // CT_Otherwise if( mpConditionNode ) { mpConditionNode->readElseBranch(); - xRet.set( new IfContext( *this, AttributeList( xAttribs ), mpConditionNode ) ); + ContextHandlerRef xRet = new IfContext( *this, rAttribs, mpConditionNode ); mpConditionNode.reset(); + return xRet; } else { @@ -137,10 +127,7 @@ public: break; } - if( !xRet.is() ) - xRet.set(this); - - return xRet; + return this; } private: OUString msName; @@ -179,20 +166,16 @@ public: { } - virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs ) + virtual ContextHandlerRef onCreateContext( ::sal_Int32 aElement, const AttributeList& rAttribs ) throw (SAXException, RuntimeException) { - Reference< XFastContextHandler > xRet; - sal_Int32 nIdx = LayoutNodeContext::tagToVarIdx( getBaseToken( aElement ) ); if( nIdx != -1 ) { - mVariables[ nIdx ] = makeAny( xAttribs->getOptionalValue( XML_val ) ); + mVariables[ nIdx ] = makeAny( rAttribs.getString( XML_val ).get() ); } - if( !xRet.is() ) - xRet.set(this); - return xRet; + return this; } private: LayoutNode::VarMap & mVariables; @@ -215,12 +198,6 @@ LayoutNodeContext::~LayoutNodeContext() { } -void SAL_CALL LayoutNodeContext::endFastElement( ::sal_Int32 ) - throw (SAXException, RuntimeException) -{ - -} - /** convert the XML tag to a variable index in the array * @param aTag the tag, without namespace * @return the variable index. -1 is an error @@ -264,24 +241,20 @@ sal_Int32 LayoutNodeContext::tagToVarIdx( sal_Int32 aTag ) } -Reference< XFastContextHandler > SAL_CALL -LayoutNodeContext::createFastChildContext( ::sal_Int32 aElement, - const Reference< XFastAttributeList >& xAttribs ) - throw (SAXException, RuntimeException) +ContextHandlerRef +LayoutNodeContext::onCreateContext( ::sal_Int32 aElement, + const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( aElement ) { case DGM_TOKEN( layoutNode ): { LayoutNodePtr pNode( new LayoutNode() ); mpNode->addChild( pNode ); - pNode->setChildOrder( xAttribs->getOptionalValueToken( XML_chOrder, XML_b ) ); - pNode->setMoveWith( xAttribs->getOptionalValue( XML_moveWith ) ); - pNode->setStyleLabel( xAttribs->getOptionalValue( XML_styleLbl ) ); - xRet.set( new LayoutNodeContext( *this, AttributeList( xAttribs ), pNode ) ); - break; + pNode->setChildOrder( rAttribs.getToken( XML_chOrder, XML_b ) ); + pNode->setMoveWith( rAttribs.getString( XML_moveWith ).get() ); + pNode->setStyleLabel( rAttribs.getString( XML_styleLbl ).get() ); + return new LayoutNodeContext( *this, rAttribs, pNode ); } case DGM_TOKEN( shape ): { @@ -290,10 +263,10 @@ LayoutNodeContext::createFastChildContext( ::sal_Int32 aElement, { ShapePtr pShape; - if( xAttribs->hasAttribute( XML_type ) ) + if( rAttribs.hasAttribute( XML_type ) ) { pShape.reset( new Shape("com.sun.star.drawing.CustomShape") ); - const sal_Int32 nType(xAttribs->getOptionalValueToken( XML_type, XML_obj )); + const sal_Int32 nType(rAttribs.getToken( XML_type, XML_obj )); pShape->setSubType( nType ); pShape->getCustomShapeProperties()->setShapePresetType( nType ); } @@ -303,7 +276,7 @@ LayoutNodeContext::createFastChildContext( ::sal_Int32 aElement, } pNode->setShape( pShape ); - xRet.set( new ShapeContext( *this, ShapePtr(), pShape ) ); + return new ShapeContext( *this, ShapePtr(), pShape ); } else { @@ -312,45 +285,41 @@ LayoutNodeContext::createFastChildContext( ::sal_Int32 aElement, break; } case DGM_TOKEN( extLst ): - return xRet; + return 0; case DGM_TOKEN( alg ): { // CT_Algorithm AlgAtomPtr pAtom( new AlgAtom ); mpNode->addChild( pAtom ); - xRet.set( new AlgorithmContext( *this, AttributeList( xAttribs ), pAtom ) ); - break; + return new AlgorithmContext( *this, rAttribs, pAtom ); } case DGM_TOKEN( choose ): { // CT_Choose LayoutAtomPtr pAtom( new ChooseAtom ); mpNode->addChild( pAtom ); - xRet.set( new ChooseContext( *this, AttributeList( xAttribs ), pAtom ) ); - break; + return new ChooseContext( *this, rAttribs, pAtom ); } case DGM_TOKEN( forEach ): { // CT_ForEach - ForEachAtomPtr pAtom( new ForEachAtom(xAttribs) ); + ForEachAtomPtr pAtom( new ForEachAtom(rAttribs.getFastAttributeList()) ); mpNode->addChild( pAtom ); - xRet.set( new ForEachContext( *this, AttributeList( xAttribs ), pAtom ) ); - break; + return new ForEachContext( *this, rAttribs, pAtom ); } case DGM_TOKEN( constrLst ): // CT_Constraints - xRet.set( new ConstraintListContext( *this, AttributeList( xAttribs ), mpNode ) ); - break; + return new ConstraintListContext( *this, rAttribs, mpNode ); case DGM_TOKEN( presOf ): { // CT_PresentationOf // TODO - xAttribs->getOptionalValue( XML_axis ); - xAttribs->getOptionalValue( XML_cnt ); - xAttribs->getOptionalValue( XML_hideLastTrans ); - xAttribs->getOptionalValue( XML_ptType ); - xAttribs->getOptionalValue( XML_st ); - xAttribs->getOptionalValue( XML_step ); + rAttribs.getString( XML_axis ); + rAttribs.getString( XML_cnt ); + rAttribs.getString( XML_hideLastTrans ); + rAttribs.getString( XML_ptType ); + rAttribs.getString( XML_st ); + rAttribs.getString( XML_step ); break; } case DGM_TOKEN( ruleLst ): @@ -362,7 +331,7 @@ LayoutNodeContext::createFastChildContext( ::sal_Int32 aElement, LayoutNodePtr pNode( boost::dynamic_pointer_cast< LayoutNode >( mpNode ) ); if( pNode ) { - xRet.set( new LayoutVariablePropertySetContext( *this, pNode->variables() ) ); + return new LayoutVariablePropertySetContext( *this, pNode->variables() ); } else { @@ -373,10 +342,8 @@ LayoutNodeContext::createFastChildContext( ::sal_Int32 aElement, default: break; } - if( !xRet.is() ) - xRet.set(this); - return xRet; + return this; } diff --git a/oox/source/drawingml/diagram/layoutnodecontext.hxx b/oox/source/drawingml/diagram/layoutnodecontext.hxx index 6aede0edb94f..69055fd2e37e 100644 --- a/oox/source/drawingml/diagram/layoutnodecontext.hxx +++ b/oox/source/drawingml/diagram/layoutnodecontext.hxx @@ -32,8 +32,7 @@ public: LayoutNodeContext( ::oox::core::ContextHandler2Helper& rParent, const ::oox::AttributeList& rAttributes, const LayoutAtomPtr &pNode ); virtual ~LayoutNodeContext(); - virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; static ::sal_Int32 tagToVarIdx( ::sal_Int32 aTag ); private: diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx index a2106b0a7baa..22ad713cb19b 100644 --- a/oox/source/drawingml/graphicshapecontext.cxx +++ b/oox/source/drawingml/graphicshapecontext.cxx @@ -57,22 +57,18 @@ GraphicShapeContext::GraphicShapeContext( ContextHandler2Helper& rParent, ShapeP { } -Reference< XFastContextHandler > GraphicShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +ContextHandlerRef GraphicShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( getBaseToken( aElementToken ) ) { // CT_ShapeProperties case XML_xfrm: - xRet.set( new Transform2DContext( *this, xAttribs, *mpShapePtr ) ); - break; + return new Transform2DContext( *this, rAttribs.getFastAttributeList(), *mpShapePtr ); case XML_blipFill: - xRet.set( new BlipFillContext( *this, xAttribs, mpShapePtr->getGraphicProperties().maBlipProps ) ); - break; + return new BlipFillContext( *this, rAttribs.getFastAttributeList(), mpShapePtr->getGraphicProperties().maBlipProps ); case XML_wavAudioFile: { - getEmbeddedWAVAudioFile( getRelations(), xAttribs, mpShapePtr->getGraphicProperties().maAudio ); + getEmbeddedWAVAudioFile( getRelations(), rAttribs.getFastAttributeList(), mpShapePtr->getGraphicProperties().maAudio ); if( !mpShapePtr->getGraphicProperties().maAudio.msEmbed.isEmpty() ) { Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); @@ -99,10 +95,7 @@ Reference< XFastContextHandler > GraphicShapeContext::createFastChildContext( sa pCstmShpProps->setShapePresetType( getBaseToken( aElementToken ) ); } - if( !xRet.is() ) - xRet.set( ShapeContext::createFastChildContext( aElementToken, xAttribs ) ); - - return xRet; + return ShapeContext::onCreateContext( aElementToken, rAttribs ); } // ============================================================================ @@ -114,45 +107,39 @@ GraphicalObjectFrameContext::GraphicalObjectFrameContext( ContextHandler2Helper& { } -Reference< XFastContextHandler > GraphicalObjectFrameContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +ContextHandlerRef GraphicalObjectFrameContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( getBaseToken( aElementToken ) ) { // CT_ShapeProperties case XML_nvGraphicFramePr: // CT_GraphicalObjectFrameNonVisual break; case XML_xfrm: // CT_Transform2D - xRet.set( new Transform2DContext( *this, xAttribs, *mpShapePtr ) ); - break; + return new Transform2DContext( *this, rAttribs.getFastAttributeList(), *mpShapePtr ); case XML_graphic: // CT_GraphicalObject - xRet.set( this ); - break; + return this; case XML_graphicData : // CT_GraphicalObjectData { - OUString sUri( xAttribs->getOptionalValue( XML_uri ) ); + OUString sUri( rAttribs.getString( XML_uri ).get() ); if ( sUri == "http://schemas.openxmlformats.org/presentationml/2006/ole" ) - xRet.set( new OleObjectGraphicDataContext( *this, mpShapePtr ) ); + return new OleObjectGraphicDataContext( *this, mpShapePtr ); else if ( sUri == "http://schemas.openxmlformats.org/drawingml/2006/diagram" ) - xRet.set( new DiagramGraphicDataContext( *this, mpShapePtr ) ); + return new DiagramGraphicDataContext( *this, mpShapePtr ); else if ( sUri == "http://schemas.openxmlformats.org/drawingml/2006/chart" ) - xRet.set( new ChartGraphicDataContext( *this, mpShapePtr, mbEmbedShapesInChart ) ); + return new ChartGraphicDataContext( *this, mpShapePtr, mbEmbedShapesInChart ); else if ( sUri.compareToAscii( "http://schemas.openxmlformats.org/drawingml/2006/table" ) == 0 ) - xRet.set( new table::TableContext( *this, mpShapePtr ) ); + return new table::TableContext( *this, mpShapePtr ); else { OSL_TRACE( "OOX: Ignore graphicsData of %s", OUSTRING_TO_CSTR( sUri ) ); - return xRet; + return 0; } } break; } - if( !xRet.is() ) - xRet.set( ShapeContext::createFastChildContext( aElementToken, xAttribs ) ); - return xRet; + return ShapeContext::onCreateContext( aElementToken, rAttribs ); } // ============================================================================ @@ -172,17 +159,14 @@ OleObjectGraphicDataContext::~OleObjectGraphicDataContext() pVmlDrawing->registerOleObject( mrOleObjectInfo ); } -Reference< XFastContextHandler > OleObjectGraphicDataContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +ContextHandlerRef OleObjectGraphicDataContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - AttributeList aAttribs( xAttribs ); - switch( nElement ) { case PPT_TOKEN( oleObj ): { - mrOleObjectInfo.maShapeId = aAttribs.getXString( XML_spid, OUString() ); - const Relation* pRelation = getRelations().getRelationFromRelId( aAttribs.getString( R_TOKEN( id ), OUString() ) ); + mrOleObjectInfo.maShapeId = rAttribs.getXString( XML_spid, OUString() ); + const Relation* pRelation = getRelations().getRelationFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ); OSL_ENSURE( pRelation, "OleObjectGraphicDataContext::createFastChildContext - missing relation for OLE object" ); if( pRelation ) { @@ -198,10 +182,10 @@ Reference< XFastContextHandler > OleObjectGraphicDataContext::createFastChildCon getFilter().importBinaryData( mrOleObjectInfo.maEmbeddedData, aFragmentPath ); } } - mrOleObjectInfo.maName = aAttribs.getXString( XML_name, OUString() ); - mrOleObjectInfo.maProgId = aAttribs.getXString( XML_progId, OUString() ); - mrOleObjectInfo.mbShowAsIcon = aAttribs.getBool( XML_showAsIcon, false ); - xRet.set( this ); + mrOleObjectInfo.maName = rAttribs.getXString( XML_name, OUString() ); + mrOleObjectInfo.maProgId = rAttribs.getXString( XML_progId, OUString() ); + mrOleObjectInfo.mbShowAsIcon = rAttribs.getBool( XML_showAsIcon, false ); + return this; } break; @@ -211,13 +195,13 @@ Reference< XFastContextHandler > OleObjectGraphicDataContext::createFastChildCon case PPT_TOKEN( link ): OSL_ENSURE( mrOleObjectInfo.mbLinked, "OleObjectGraphicDataContext::createFastChildContext - unexpected child element" ); - mrOleObjectInfo.mbAutoUpdate = aAttribs.getBool( XML_updateAutomatic, false ); + mrOleObjectInfo.mbAutoUpdate = rAttribs.getBool( XML_updateAutomatic, false ); break; case PPT_TOKEN( pic ): - xRet.set( new GraphicShapeContext( *this, mpMasterShapePtr, mpShapePtr ) ); + return new GraphicShapeContext( *this, mpMasterShapePtr, mpShapePtr ); break; } - return xRet; + return 0; } // ============================================================================ @@ -232,19 +216,16 @@ DiagramGraphicDataContext::~DiagramGraphicDataContext() { } -Reference< XFastContextHandler > DiagramGraphicDataContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) - throw (SAXException, RuntimeException) +ContextHandlerRef DiagramGraphicDataContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( aElementToken ) { case DGM_TOKEN( relIds ): { - msDm = xAttribs->getOptionalValue( R_TOKEN( dm ) ); - msLo = xAttribs->getOptionalValue( R_TOKEN( lo ) ); - msQs = xAttribs->getOptionalValue( R_TOKEN( qs ) ); - msCs = xAttribs->getOptionalValue( R_TOKEN( cs ) ); + msDm = rAttribs.getString( R_TOKEN( dm ) ).get(); + msLo = rAttribs.getString( R_TOKEN( lo ) ).get(); + msQs = rAttribs.getString( R_TOKEN( qs ) ).get(); + msCs = rAttribs.getString( R_TOKEN( cs ) ).get(); loadDiagram(mpShapePtr, getFilter(), getFragmentPathFromRelId( msDm ), @@ -264,10 +245,7 @@ Reference< XFastContextHandler > DiagramGraphicDataContext::createFastChildConte break; } - if( !xRet.is() ) - xRet.set( ShapeContext::createFastChildContext( aElementToken, xAttribs ) ); - - return xRet; + return ShapeContext::onCreateContext( aElementToken, rAttribs ); } // ============================================================================ @@ -278,13 +256,11 @@ ChartGraphicDataContext::ChartGraphicDataContext( ContextHandler2Helper& rParent { } -Reference< XFastContextHandler > ChartGraphicDataContext::createFastChildContext( ::sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs ) - throw (SAXException, RuntimeException) +ContextHandlerRef ChartGraphicDataContext::onCreateContext( ::sal_Int32 nElement, const AttributeList& rAttribs ) { if( nElement == C_TOKEN( chart ) ) { - AttributeList aAttribs( rxAttribs ); - mrChartShapeInfo.maFragmentPath = getFragmentPathFromRelId( aAttribs.getString( R_TOKEN( id ), OUString() ) ); + mrChartShapeInfo.maFragmentPath = getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ); } return 0; } diff --git a/oox/source/drawingml/shapecontext.cxx b/oox/source/drawingml/shapecontext.cxx index 8e9c75f0cb14..db49d4f40b74 100644 --- a/oox/source/drawingml/shapecontext.cxx +++ b/oox/source/drawingml/shapecontext.cxx @@ -62,14 +62,8 @@ ShapePtr ShapeContext::getShape() return mpShapePtr; } -void ShapeContext::endFastElement( sal_Int32 /* aElementToken */ ) throw( SAXException, RuntimeException ) +ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { -} - -Reference< XFastContextHandler > ShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) -{ - Reference< XFastContextHandler > xRet; - switch( getBaseToken( aElementToken ) ) { // nvSpPr CT_ShapeNonVisual begin @@ -77,53 +71,42 @@ Reference< XFastContextHandler > ShapeContext::createFastChildContext( sal_Int32 // break; case XML_cNvPr: { - AttributeList aAttribs( xAttribs ); - mpShapePtr->setHidden( aAttribs.getBool( XML_hidden, false ) ); - mpShapePtr->setId( xAttribs->getOptionalValue( XML_id ) ); - mpShapePtr->setName( xAttribs->getOptionalValue( XML_name ) ); + mpShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) ); + mpShapePtr->setId( rAttribs.getString( XML_id ).get() ); + mpShapePtr->setName( rAttribs.getString( XML_name ).get() ); break; } case XML_hlinkMouseOver: case XML_hlinkClick: - xRet = new HyperLinkContext( *this, xAttribs, getShape()->getShapeProperties() ); + return new HyperLinkContext( *this, rAttribs.getFastAttributeList(), getShape()->getShapeProperties() ); break; case XML_ph: - mpShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) ); - if( xAttribs->hasAttribute( XML_idx ) ) - mpShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); + mpShapePtr->setSubType( rAttribs.getToken( XML_type, XML_obj ) ); + if( rAttribs.hasAttribute( XML_idx ) ) + mpShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).get().toInt32() ); break; // nvSpPr CT_ShapeNonVisual end case XML_spPr: - xRet = new ShapePropertiesContext( *this, *mpShapePtr ); - break; + return new ShapePropertiesContext( *this, *mpShapePtr ); case XML_style: - xRet = new ShapeStyleContext( *this, *mpShapePtr ); - break; + return new ShapeStyleContext( *this, *mpShapePtr ); case XML_txBody: { TextBodyPtr xTextBody( new TextBody ); mpShapePtr->setTextBody( xTextBody ); - xRet = new TextBodyContext( *this, *xTextBody ); - break; + return new TextBodyContext( *this, *xTextBody ); } case XML_txXfrm: { - AttributeList aAttribs( xAttribs ); - mpShapePtr->getTextBody()->getTextProperties().moRotation = aAttribs.getInteger( XML_rot ); + mpShapePtr->getTextBody()->getTextProperties().moRotation = rAttribs.getInteger( XML_rot ); break; } } - if( !xRet.is() ) - { - uno::Reference xTmp(this); - xRet.set( xTmp ); - } - - return xRet; + return this; } diff --git a/oox/source/drawingml/shapegroupcontext.cxx b/oox/source/drawingml/shapegroupcontext.cxx index 87f468bc2f1d..bae6d4c55015 100644 --- a/oox/source/drawingml/shapegroupcontext.cxx +++ b/oox/source/drawingml/shapegroupcontext.cxx @@ -53,63 +53,49 @@ ShapeGroupContext::~ShapeGroupContext() mpMasterShapePtr->addChild( mpGroupShapePtr ); } -Reference< XFastContextHandler > ShapeGroupContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +ContextHandlerRef ShapeGroupContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( getBaseToken( aElementToken ) ) { case XML_cNvPr: { - AttributeList aAttribs( xAttribs ); - mpGroupShapePtr->setHidden( aAttribs.getBool( XML_hidden, false ) ); - mpGroupShapePtr->setId( xAttribs->getOptionalValue( XML_id ) ); - mpGroupShapePtr->setName( xAttribs->getOptionalValue( XML_name ) ); + mpGroupShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) ); + mpGroupShapePtr->setId( rAttribs.getString( XML_id ).get() ); + mpGroupShapePtr->setName( rAttribs.getString( XML_name ).get() ); break; } case XML_ph: - mpGroupShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, FastToken::DONTKNOW ) ); - if( xAttribs->hasAttribute( XML_idx ) ) - mpGroupShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); + mpGroupShapePtr->setSubType( rAttribs.getToken( XML_type, FastToken::DONTKNOW ) ); + if( rAttribs.hasAttribute( XML_idx ) ) + mpGroupShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).get().toInt32() ); break; // nvSpPr CT_ShapeNonVisual end case XML_grpSpPr: - xRet = new ShapePropertiesContext( *this, *mpGroupShapePtr ); - break; + return new ShapePropertiesContext( *this, *mpGroupShapePtr ); case XML_spPr: - xRet = new ShapePropertiesContext( *this, *mpGroupShapePtr ); - break; + return new ShapePropertiesContext( *this, *mpGroupShapePtr ); /* case XML_style: - xRet = new ShapeStyleContext( getParser() ); - break; + return new ShapeStyleContext( getParser() ); */ case XML_cxnSp: // connector shape { ShapePtr pShape(new Shape("com.sun.star.drawing.ConnectorShape")); pShape->setLockedCanvas(mpGroupShapePtr->getLockedCanvas()); - xRet.set( new ConnectorShapeContext( *this, mpGroupShapePtr, pShape ) ); + return new ConnectorShapeContext( *this, mpGroupShapePtr, pShape ); } - break; case XML_grpSp: // group shape - xRet.set( new ShapeGroupContext( *this, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.GroupShape" ) ) ) ); - break; + return new ShapeGroupContext( *this, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.GroupShape" ) ) ); case XML_sp: // shape - xRet.set( new ShapeContext( *this, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.CustomShape" ) ) ) ); - break; + return new ShapeContext( *this, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.CustomShape" ) ) ); case XML_pic: // CT_Picture - xRet.set( new GraphicShapeContext( *this, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.GraphicObjectShape" ) ) ) ); - break; + return new GraphicShapeContext( *this, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.GraphicObjectShape" ) ) ); case XML_graphicFrame: // CT_GraphicalObjectFrame - xRet.set( new GraphicalObjectFrameContext( *this, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.GraphicObjectShape" ) ), true ) ); - break; + return new GraphicalObjectFrameContext( *this, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.GraphicObjectShape" ) ), true ); } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } } } diff --git a/oox/source/drawingml/table/tablecontext.cxx b/oox/source/drawingml/table/tablecontext.cxx index 87900526ac1a..f83e2877b2b6 100644 --- a/oox/source/drawingml/table/tablecontext.cxx +++ b/oox/source/drawingml/table/tablecontext.cxx @@ -41,58 +41,48 @@ TableContext::~TableContext() { } -uno::Reference< xml::sax::XFastContextHandler > SAL_CALL -TableContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs ) - throw ( xml::sax::SAXException, uno::RuntimeException) +ContextHandlerRef +TableContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& rAttribs ) { - uno::Reference< xml::sax::XFastContextHandler > xRet; - switch( aElementToken ) { case A_TOKEN( tblPr ): // CT_TableProperties { - AttributeList aAttribs( xAttribs ); - mrTableProperties.isRtl() = aAttribs.getBool( XML_rtl, sal_False ); - mrTableProperties.isFirstRow() = aAttribs.getBool( XML_firstRow, sal_False ); - mrTableProperties.isFirstCol() = aAttribs.getBool( XML_firstCol, sal_False ); - mrTableProperties.isLastRow() = aAttribs.getBool( XML_lastRow, sal_False ); - mrTableProperties.isLastCol() = aAttribs.getBool( XML_lastCol, sal_False ); - mrTableProperties.isBandRow() = aAttribs.getBool( XML_bandRow, sal_False ); - mrTableProperties.isBandCol() = aAttribs.getBool( XML_bandCol, sal_False ); + mrTableProperties.isRtl() = rAttribs.getBool( XML_rtl, sal_False ); + mrTableProperties.isFirstRow() = rAttribs.getBool( XML_firstRow, sal_False ); + mrTableProperties.isFirstCol() = rAttribs.getBool( XML_firstCol, sal_False ); + mrTableProperties.isLastRow() = rAttribs.getBool( XML_lastRow, sal_False ); + mrTableProperties.isLastCol() = rAttribs.getBool( XML_lastCol, sal_False ); + mrTableProperties.isBandRow() = rAttribs.getBool( XML_bandRow, sal_False ); + mrTableProperties.isBandCol() = rAttribs.getBool( XML_bandCol, sal_False ); } break; case A_TOKEN( tableStyle ): // CT_TableStyle { boost::shared_ptr< TableStyle >& rTableStyle = mrTableProperties.getTableStyle(); rTableStyle.reset( new TableStyle() ); - xRet = new TableStyleContext( *this, xAttribs, *rTableStyle ); + return new TableStyleContext( *this, rAttribs.getFastAttributeList(), *rTableStyle ); } - break; case A_TOKEN( tableStyleId ): // ST_Guid - xRet.set( new oox::drawingml::GuidContext( *this, mrTableProperties.getStyleId() ) ); - break; + return new oox::drawingml::GuidContext( *this, mrTableProperties.getStyleId() ); case A_TOKEN( tblGrid ): // CT_TableGrid break; case A_TOKEN( gridCol ): // CT_TableCol { std::vector< sal_Int32 >& rvTableGrid( mrTableProperties.getTableGrid() ); - rvTableGrid.push_back( xAttribs->getOptionalValue( XML_w ).toInt32() ); + rvTableGrid.push_back( rAttribs.getString( XML_w ).get().toInt32() ); } break; case A_TOKEN( tr ): // CT_TableRow { std::vector< TableRow >& rvTableRows( mrTableProperties.getTableRows() ); rvTableRows.resize( rvTableRows.size() + 1 ); - xRet.set( new TableRowContext( *this, xAttribs, rvTableRows.back() ) ); + return new TableRowContext( *this, rAttribs.getFastAttributeList(), rvTableRows.back() ); } - break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } } } } diff --git a/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx b/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx index b189d6332b9f..18d9df6a58bb 100644 --- a/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx +++ b/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx @@ -43,25 +43,20 @@ TableStyleListFragmentHandler::~TableStyleListFragmentHandler() } // CT_TableStyleList -Reference< XFastContextHandler > TableStyleListFragmentHandler::createFastChildContext( - sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) +ContextHandlerRef TableStyleListFragmentHandler::onCreateContext( + sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; switch( aElementToken ) { case A_TOKEN( tblStyleLst ): // CT_TableStyleList - mrTableStyleList.getDefaultStyleId() = xAttribs->getOptionalValue( XML_def ); + mrTableStyleList.getDefaultStyleId() = rAttribs.getString( XML_def ).get(); break; case A_TOKEN( tblStyle ): // CT_TableStyle std::vector< TableStyle >& rTableStyles = mrTableStyleList.getTableStyles(); rTableStyles.resize( rTableStyles.size() + 1 ); - xRet = new TableStyleContext( *this, xAttribs, rTableStyles.back() ); - break; + return new TableStyleContext( *this, rAttribs.getFastAttributeList(), rTableStyles.back() ); } - if ( !xRet.is() ) - xRet = getFastContextHandler(); - return xRet; + return this; } // ============================================================================ diff --git a/oox/source/ppt/extdrawingfragmenthandler.cxx b/oox/source/ppt/extdrawingfragmenthandler.cxx index 2058a5877c37..e6d4b2f5ce97 100644 --- a/oox/source/ppt/extdrawingfragmenthandler.cxx +++ b/oox/source/ppt/extdrawingfragmenthandler.cxx @@ -37,31 +37,24 @@ ExtDrawingFragmentHandler::~ExtDrawingFragmentHandler( ) throw () } -Reference< XFastContextHandler > SAL_CALL -ExtDrawingFragmentHandler::createFastChildContext( ::sal_Int32 aElement, - const Reference< XFastAttributeList >& ) - throw ( SAXException, RuntimeException) +ContextHandlerRef +ExtDrawingFragmentHandler::onCreateContext( ::sal_Int32 aElement, + const AttributeList& ) { - Reference< XFastContextHandler > xRet; - switch( aElement ) { case DSP_TOKEN( drawing ): break; case DSP_TOKEN( spTree ): mpShapePtr = oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GroupShape" ) ); - xRet.set( new PPTShapeGroupContext( + return new PPTShapeGroupContext( *this, mpSlidePersistPtr, meShapeLocation, mpSlidePersistPtr->getShapes(), - mpShapePtr ) ); - break; + mpShapePtr ); default: break; } - if( !xRet.is() ) - xRet = getFastContextHandler(); - - return xRet; + return this; } void SAL_CALL ExtDrawingFragmentHandler::endDocument() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) { diff --git a/oox/source/ppt/extdrawingfragmenthandler.hxx b/oox/source/ppt/extdrawingfragmenthandler.hxx index 24fa1ed231b5..0b186eb93abc 100644 --- a/oox/source/ppt/extdrawingfragmenthandler.hxx +++ b/oox/source/ppt/extdrawingfragmenthandler.hxx @@ -30,8 +30,8 @@ public: oox::drawingml::ShapePtr pShapePtr ) throw(); virtual ~ExtDrawingFragmentHandler() throw(); - virtual void SAL_CALL endDocument() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL endDocument() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE; + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const AttributeList& rAttribs ) SAL_OVERRIDE; private: const oox::ppt::SlidePersistPtr mpSlidePersistPtr; diff --git a/oox/source/ppt/pptgraphicshapecontext.cxx b/oox/source/ppt/pptgraphicshapecontext.cxx index 63ced6609439..99c7328d9952 100644 --- a/oox/source/ppt/pptgraphicshapecontext.cxx +++ b/oox/source/ppt/pptgraphicshapecontext.cxx @@ -60,27 +60,25 @@ static oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sa return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : PPTShape::findPlaceholder( nSecondPlaceholder, rShapes ); } -Reference< XFastContextHandler > PPTGraphicShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +ContextHandlerRef PPTGraphicShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( aElementToken ) { // nvSpPr CT_ShapeNonVisual begin // case NMSP_PPT|XML_drElemPr: // break; case PPT_TOKEN(cNvPr): - mpShapePtr->setId( xAttribs->getOptionalValue( XML_id ) ); - mpShapePtr->setName( xAttribs->getOptionalValue( XML_name ) ); + mpShapePtr->setId( rAttribs.getString( XML_id ).get() ); + mpShapePtr->setName( rAttribs.getString( XML_name ).get() ); break; case PPT_TOKEN(ph): { - sal_Int32 nSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) ); + sal_Int32 nSubType( rAttribs.getToken( XML_type, XML_obj ) ); mpShapePtr->setSubType( nSubType ); - OUString sIdx( xAttribs->getOptionalValue( XML_idx ) ); + OUString sIdx( rAttribs.getString( XML_idx ).get() ); sal_Bool bHasIdx = !sIdx.isEmpty(); sal_Int32 nIdx = sIdx.toInt32(); - if( xAttribs->hasAttribute( XML_idx ) ) + if( rAttribs.hasAttribute( XML_idx ) ) mpShapePtr->setSubTypeIndex( nIdx ); if ( nSubType || bHasIdx ) @@ -95,7 +93,7 @@ Reference< XFastContextHandler > PPTGraphicShapeContext::createFastChildContext( { // TODO: use id to shape map SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() ); - if ( pMasterPersist.get() && xAttribs->hasAttribute( XML_idx ) ) + if ( pMasterPersist.get() && rAttribs.hasAttribute( XML_idx ) ) pPlaceholder = PPTShape::findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() ); } if ( !pPlaceholder.get() && ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) ) ) @@ -165,26 +163,20 @@ Reference< XFastContextHandler > PPTGraphicShapeContext::createFastChildContext( // nvSpPr CT_ShapeNonVisual end case PPT_TOKEN(spPr): - xRet = new PPTShapePropertiesContext( *this, *mpShapePtr ); - break; + return new PPTShapePropertiesContext( *this, *mpShapePtr ); case PPT_TOKEN(style): - xRet = new oox::drawingml::ShapeStyleContext( *this, *mpShapePtr ); - break; + return new oox::drawingml::ShapeStyleContext( *this, *mpShapePtr ); case PPT_TOKEN(txBody): { oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody ); mpShapePtr->setTextBody( xTextBody ); - xRet = new oox::drawingml::TextBodyContext( *this, *xTextBody ); - break; + return new oox::drawingml::TextBodyContext( *this, *xTextBody ); } } - if( !xRet.is() ) - xRet.set( GraphicShapeContext::createFastChildContext( aElementToken, xAttribs ) ); - - return xRet; + return GraphicShapeContext::onCreateContext( aElementToken, rAttribs ); } diff --git a/oox/source/ppt/pptshapecontext.cxx b/oox/source/ppt/pptshapecontext.cxx index 170ee420c427..c8a4eff4fe05 100644 --- a/oox/source/ppt/pptshapecontext.cxx +++ b/oox/source/ppt/pptshapecontext.cxx @@ -92,9 +92,8 @@ oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : findPlaceholder( nSecondPlaceholder, oSubTypeIndex, rShapes ); } -Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +ContextHandlerRef PPTShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; if( getNamespace( aElementToken ) == NMSP_dsp ) aElementToken = NMSP_ppt | getBaseToken( aElementToken ); @@ -105,18 +104,17 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In // break; case PPT_TOKEN( cNvPr ): { - AttributeList aAttribs( xAttribs ); - mpShapePtr->setHidden( aAttribs.getBool( XML_hidden, false ) ); - mpShapePtr->setId( xAttribs->getOptionalValue( XML_id ) ); - mpShapePtr->setName( xAttribs->getOptionalValue( XML_name ) ); + mpShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) ); + mpShapePtr->setId( rAttribs.getString( XML_id ).get() ); + mpShapePtr->setName( rAttribs.getString( XML_name ).get() ); break; } case PPT_TOKEN( ph ): { - sal_Int32 nSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) ); + sal_Int32 nSubType( rAttribs.getToken( XML_type, XML_obj ) ); mpShapePtr->setSubType( nSubType ); - if( xAttribs->hasAttribute( XML_idx ) ) - mpShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); + if( rAttribs.hasAttribute( XML_idx ) ) + mpShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).get().toInt32() ); if ( nSubType ) { PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() ); @@ -208,32 +206,25 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In // nvSpPr CT_ShapeNonVisual end case PPT_TOKEN( spPr ): - xRet = new PPTShapePropertiesContext( *this, *mpShapePtr ); - break; + return new PPTShapePropertiesContext( *this, *mpShapePtr ); case PPT_TOKEN( style ): - xRet = new oox::drawingml::ShapeStyleContext( *this, *mpShapePtr ); - break; + return new oox::drawingml::ShapeStyleContext( *this, *mpShapePtr ); case PPT_TOKEN( txBody ): { oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody( mpShapePtr->getTextBody() ) ); xTextBody->getTextProperties().maPropertyMap[ PROP_FontIndependentLineSpacing ] <<= static_cast< sal_Bool >( sal_True ); mpShapePtr->setTextBody( xTextBody ); - xRet = new oox::drawingml::TextBodyContext( *this, *xTextBody ); - break; + return new oox::drawingml::TextBodyContext( *this, *xTextBody ); } case PPT_TOKEN( txXfrm ): { - xRet = new oox::drawingml::Transform2DContext( *this, xAttribs, *mpShapePtr, true ); - break; + return new oox::drawingml::Transform2DContext( *this, rAttribs.getFastAttributeList(), *mpShapePtr, true ); } } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx index 450fb7dbf0bb..e25bf6561d0b 100644 --- a/oox/source/ppt/pptshapegroupcontext.cxx +++ b/oox/source/ppt/pptshapegroupcontext.cxx @@ -58,9 +58,8 @@ PPTShapeGroupContext::PPTShapeGroupContext( { } -Reference< XFastContextHandler > PPTShapeGroupContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +ContextHandlerRef PPTShapeGroupContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; if( getNamespace( aElementToken ) == NMSP_dsp ) aElementToken = NMSP_ppt | getBaseToken( aElementToken ); @@ -68,41 +67,34 @@ Reference< XFastContextHandler > PPTShapeGroupContext::createFastChildContext( s { case PPT_TOKEN( cNvPr ): { - AttributeList aAttribs( xAttribs ); - mpGroupShapePtr->setHidden( aAttribs.getBool( XML_hidden, false ) ); - mpGroupShapePtr->setId( xAttribs->getOptionalValue( XML_id ) ); - mpGroupShapePtr->setName( xAttribs->getOptionalValue( XML_name ) ); + mpGroupShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) ); + mpGroupShapePtr->setId( rAttribs.getString( XML_id ).get() ); + mpGroupShapePtr->setName( rAttribs.getString( XML_name ).get() ); break; } case PPT_TOKEN( ph ): - mpGroupShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, FastToken::DONTKNOW ) ); - if( xAttribs->hasAttribute( XML_idx ) ) - mpGroupShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); + mpGroupShapePtr->setSubType( rAttribs.getToken( XML_type, FastToken::DONTKNOW ) ); + if( rAttribs.hasAttribute( XML_idx ) ) + mpGroupShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).get().toInt32() ); break; // nvSpPr CT_ShapeNonVisual end case PPT_TOKEN( grpSpPr ): - xRet = new oox::drawingml::ShapePropertiesContext( *this, *mpGroupShapePtr ); - break; + return new oox::drawingml::ShapePropertiesContext( *this, *mpGroupShapePtr ); case PPT_TOKEN( spPr ): - xRet = new oox::drawingml::ShapePropertiesContext( *this, *mpGroupShapePtr ); - break; + return new oox::drawingml::ShapePropertiesContext( *this, *mpGroupShapePtr ); /* case PPT_TOKEN( style ): - xRet = new ShapeStyleContext( getParser() ); - break; + return new ShapeStyleContext( getParser() ); */ case PPT_TOKEN( cxnSp ): // connector shape - xRet.set( new oox::drawingml::ConnectorShapeContext( *this, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.ConnectorShape" ) ) ) ); - break; + return new oox::drawingml::ConnectorShapeContext( *this, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.ConnectorShape" ) ) ); case PPT_TOKEN( grpSp ): // group shape - xRet.set( new PPTShapeGroupContext( *this, mpSlidePersistPtr, meShapeLocation, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GroupShape" ) ) ) ); - break; + return new PPTShapeGroupContext( *this, mpSlidePersistPtr, meShapeLocation, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GroupShape" ) ) ); case PPT_TOKEN( sp ): // Shape { - AttributeList aAttribs( xAttribs ); boost::shared_ptr pShape( new PPTShape( meShapeLocation, "com.sun.star.drawing.CustomShape" ) ); - if( aAttribs.getBool( XML_useBgFill, false ) ) + if( rAttribs.getBool( XML_useBgFill, false ) ) { ::oox::drawingml::FillProperties &aFill = pShape->getFillProperties(); aFill.moFillType = XML_solidFill; @@ -110,28 +102,21 @@ Reference< XFastContextHandler > PPTShapeGroupContext::createFastChildContext( s // TODO: We are using white here, because thats the closest we can assume (?) aFill.maFillColor.setSrgbClr( API_RGB_WHITE ); } - pShape->setModelId(xAttribs->getOptionalValue( XML_modelId )); - xRet.set( new PPTShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, pShape ) ); + pShape->setModelId(rAttribs.getString( XML_modelId ).get()); + return new PPTShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, pShape ); } - break; case PPT_TOKEN( pic ): // CT_Picture - xRet.set( new PPTGraphicShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GraphicObjectShape" ) ) ) ); - break; + return new PPTGraphicShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GraphicObjectShape" ) ) ); case PPT_TOKEN( graphicFrame ): // CT_GraphicalObjectFrame { if( pGraphicShape ) importExtDrawings(); pGraphicShape = oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.OLE2Shape" ) ); - xRet.set( new oox::drawingml::GraphicalObjectFrameContext( *this, mpGroupShapePtr, pGraphicShape, true ) ); + return new oox::drawingml::GraphicalObjectFrameContext( *this, mpGroupShapePtr, pGraphicShape, true ); } - break; - } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } void PPTShapeGroupContext::importExtDrawings( ) @@ -152,7 +137,7 @@ void PPTShapeGroupContext::importExtDrawings( ) } } -void PPTShapeGroupContext::endFastElement( sal_Int32 /*nElement*/ ) throw (SAXException, RuntimeException) +void PPTShapeGroupContext::onEndElement() { importExtDrawings(); } diff --git a/oox/source/shape/ShapeDrawingFragmentHandler.cxx b/oox/source/shape/ShapeDrawingFragmentHandler.cxx index 53d693ec65cf..a0a968142c34 100644 --- a/oox/source/shape/ShapeDrawingFragmentHandler.cxx +++ b/oox/source/shape/ShapeDrawingFragmentHandler.cxx @@ -27,23 +27,17 @@ void SAL_CALL ShapeDrawingFragmentHandler::endDocument() throw (xml::sax::SAXExc { } -uno::Reference SAL_CALL ShapeDrawingFragmentHandler::createFastChildContext(sal_Int32 Element, const uno::Reference& /*Attribs*/ ) throw (xml::sax::SAXException, uno::RuntimeException) +::oox::core::ContextHandlerRef ShapeDrawingFragmentHandler::onCreateContext(sal_Int32 Element, const AttributeList& /*Attribs*/ ) { - uno::Reference< XFastContextHandler > xRet; - switch( Element ) { case DSP_TOKEN( spTree ): - xRet.set( new oox::drawingml::ShapeGroupContext(*this, oox::drawingml::ShapePtr((oox::drawingml::Shape*)0), mpGroupShapePtr)); - break; + return new oox::drawingml::ShapeGroupContext(*this, oox::drawingml::ShapePtr((oox::drawingml::Shape*)0), mpGroupShapePtr); default: break; } - if( !xRet.is() ) - xRet = getFastContextHandler(); - - return xRet; + return this; } } } diff --git a/oox/source/shape/ShapeDrawingFragmentHandler.hxx b/oox/source/shape/ShapeDrawingFragmentHandler.hxx index 64887b0f53eb..09612dd1bea7 100644 --- a/oox/source/shape/ShapeDrawingFragmentHandler.hxx +++ b/oox/source/shape/ShapeDrawingFragmentHandler.hxx @@ -21,8 +21,8 @@ class ShapeDrawingFragmentHandler : public oox::core::FragmentHandler2 public: ShapeDrawingFragmentHandler( oox::core::XmlFilterBase& rFilter, const OUString& rFragmentPath, oox::drawingml::ShapePtr pGroupShapePtr ) throw(); virtual ~ShapeDrawingFragmentHandler() throw(); - virtual void SAL_CALL endDocument() throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); - virtual com::sun::star::uno::Reference SAL_CALL createFastChildContext(sal_Int32 Element, const com::sun::star::uno::Reference& Attribs ) throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException); + virtual void SAL_CALL endDocument() throw (com::sun::star::xml::sax::SAXException, com::sun::star::uno::RuntimeException) SAL_OVERRIDE; + virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 Element, const AttributeList& rAttribs ) SAL_OVERRIDE; private: oox::drawingml::ShapePtr mpGroupShapePtr; diff --git a/sc/source/filter/inc/drawingfragment.hxx b/sc/source/filter/inc/drawingfragment.hxx index 27459e0f68cb..3c149c4a3e94 100644 --- a/sc/source/filter/inc/drawingfragment.hxx +++ b/sc/source/filter/inc/drawingfragment.hxx @@ -98,11 +98,10 @@ public: ::oox::drawingml::ShapePtr* pxShape = 0 ); protected: - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL - createFastChildContext( + virtual ::oox::core::ContextHandlerRef + onCreateContext( sal_Int32 nElement, - const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) - throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; }; // ============================================================================ diff --git a/sc/source/filter/oox/drawingfragment.cxx b/sc/source/filter/oox/drawingfragment.cxx index b4c1fa7229cc..7c864cc63de1 100644 --- a/sc/source/filter/oox/drawingfragment.cxx +++ b/sc/source/filter/oox/drawingfragment.cxx @@ -169,11 +169,11 @@ GroupShapeContext::GroupShapeContext( ContextHandler2Helper& rParent, return 0; } -Reference< XFastContextHandler > SAL_CALL GroupShapeContext::createFastChildContext( - sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs ) throw (SAXException, RuntimeException) +ContextHandlerRef GroupShapeContext::onCreateContext( + sal_Int32 nElement, const AttributeList& rAttribs ) { - ContextHandlerRef xContext = createShapeContext( *this, *this, nElement, AttributeList( rxAttribs ), mpGroupShapePtr ); - return xContext.get() ? xContext.get() : ShapeGroupContext::createFastChildContext( nElement, rxAttribs ); + ContextHandlerRef xContext = createShapeContext( *this, *this, nElement, rAttribs, mpGroupShapePtr ); + return xContext.get() ? xContext.get() : ShapeGroupContext::onCreateContext( nElement, rAttribs ); } // ============================================================================ -- cgit v1.2.3