diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-07-21 18:38:50 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-07-21 18:38:50 +0200 |
commit | 112be98c928c38c5cc63c99e86e0b58b8d2dfe29 (patch) | |
tree | 053e3d7dfa670c6c1924d4095d9cfbe622b4b5ba /oox | |
parent | 03e6f1338cc18d047582fdb22787ebf0f693d8a2 (diff) | |
parent | d90e0b5999ff65ab9bceb4cbd5ecbd5af232ac3b (diff) |
resyncing to master
Diffstat (limited to 'oox')
58 files changed, 826 insertions, 720 deletions
diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk index 2abfb960c461..69ddb25d65ea 100644 --- a/oox/Library_oox.mk +++ b/oox/Library_oox.mk @@ -34,7 +34,6 @@ $(eval $(call gb_Library_add_package_headers,oox,\ $(eval $(call gb_Library_set_include,oox,\ $$(INCLUDE) \ -I$(OUTDIR)/inc \ - -I$(OUTDIR)/inc/offuh \ -I$(realpath $(SRCDIR)/oox/inc) \ )) @@ -42,6 +41,11 @@ $(eval $(call gb_Library_add_defs,oox,\ -DOOX_DLLIMPLEMENTATION \ )) +$(eval $(call gb_Library_add_api,oox,\ + offapi \ + udkapi \ +)) + $(eval $(call gb_Library_add_linked_libs,oox,\ basegfx \ comphelper \ diff --git a/oox/Package_inc.mk b/oox/Package_inc.mk index d9b23dbfd266..b51b51b79559 100644 --- a/oox/Package_inc.mk +++ b/oox/Package_inc.mk @@ -48,6 +48,7 @@ $(eval $(call gb_Package_add_file,oox_inc,inc/oox/helper/refmap.hxx,oox/helper/r $(eval $(call gb_Package_add_file,oox_inc,inc/oox/helper/refvector.hxx,oox/helper/refvector.hxx)) $(eval $(call gb_Package_add_file,oox_inc,inc/oox/helper/storagebase.hxx,oox/helper/storagebase.hxx)) $(eval $(call gb_Package_add_file,oox_inc,inc/oox/helper/zipstorage.hxx,oox/helper/zipstorage.hxx)) +$(eval $(call gb_Package_add_file,oox_inc,inc/oox/ole/olehelper.hxx,oox/ole/olehelper.hxx)) $(eval $(call gb_Package_add_file,oox_inc,inc/oox/ole/oleobjecthelper.hxx,oox/ole/oleobjecthelper.hxx)) $(eval $(call gb_Package_add_file,oox_inc,inc/oox/ole/olestorage.hxx,oox/ole/olestorage.hxx)) $(eval $(call gb_Package_add_file,oox_inc,inc/oox/ole/vbaproject.hxx,oox/ole/vbaproject.hxx)) diff --git a/oox/inc/oox/core/contexthandler.hxx b/oox/inc/oox/core/contexthandler.hxx index 118d9396e354..94a095b22c0c 100644 --- a/oox/inc/oox/core/contexthandler.hxx +++ b/oox/inc/oox/core/contexthandler.hxx @@ -63,7 +63,7 @@ typedef ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XFastContextHandler class ContextHandler : public ContextHandler_BASE { public: - explicit ContextHandler( ContextHandler& rParent ); + explicit ContextHandler( const ContextHandler& rParent ); virtual ~ContextHandler(); /** Returns the filter instance. */ diff --git a/oox/inc/oox/ole/axcontrol.hxx b/oox/inc/oox/ole/axcontrol.hxx index 273bacd5121a..2f06aca5ee7d 100644 --- a/oox/inc/oox/ole/axcontrol.hxx +++ b/oox/inc/oox/ole/axcontrol.hxx @@ -77,6 +77,11 @@ const sal_uInt16 COMCTL_VERSION_60 = 6; #define AX_GUID_SCROLLBAR "{DFD181E0-5E2F-11CE-A449-00AA004A803D}" #define AX_GUID_FRAME "{6E182020-F460-11CE-9BCD-00AA00608E01}" +// Html control GUID(s) + +#define HTML_GUID_SELECT "{5512D122-5CC6-11CF-8D67-00AA00BDCE1D}" +#define HTML_GUID_TEXTBOX "{5512D124-5CC6-11CF-8D67-00AA00BDCE1D}" + const sal_uInt32 AX_SYSCOLOR_WINDOWBACK = 0x80000005; const sal_uInt32 AX_SYSCOLOR_WINDOWFRAME = 0x80000006; const sal_uInt32 AX_SYSCOLOR_WINDOWTEXT = 0x80000008; @@ -853,6 +858,22 @@ public: virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; }; +class HtmlSelectModel : public AxListBoxModel +{ + com::sun::star::uno::Sequence< rtl::OUString > msListData; + com::sun::star::uno::Sequence< sal_Int16 > msIndices; +public: + HtmlSelectModel(); + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); + virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const; +}; + +class HtmlTextBoxModel : public AxTextBoxModel +{ +public: + explicit HtmlTextBoxModel(); + virtual bool importBinaryModel( BinaryInputStream& rInStrm ); +}; // ============================================================================ /** A form control embedded in a document draw page. Contains a specific model diff --git a/oox/inc/oox/ole/olehelper.hxx b/oox/inc/oox/ole/olehelper.hxx index 9881eebc21dc..efe0b40c2938 100644 --- a/oox/inc/oox/ole/olehelper.hxx +++ b/oox/inc/oox/ole/olehelper.hxx @@ -31,15 +31,29 @@ #include <rtl/ustring.hxx> #include "oox/helper/binarystreambase.hxx" +#include "oox/helper/storagebase.hxx" +#include "oox/helper/graphichelper.hxx" +#include "com/sun/star/form/XFormComponent.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/frame/XModel.hpp" +#include "com/sun/star/frame/XFrame.hpp" +#include "com/sun/star/awt/XControl.hpp" +#include "com/sun/star/io/XInputStream.hpp" +#include "oox/dllapi.h" namespace oox { class BinaryInputStream; + class BinaryXInputStream; class GraphicHelper; } namespace oox { + +typedef ::boost::shared_ptr< oox::BinaryXInputStream > BinaryXInputStreamRef; + namespace ole { + // ============================================================================ #define OLE_GUID_STDFONT "{0BE35203-8F91-11CE-9DE3-00AA004BB851}" @@ -87,7 +101,7 @@ struct StdHlinkInfo // ============================================================================ /** Static helper functions for OLE import/export. */ -class OleHelper +class OOX_DLLPUBLIC OleHelper { public: /** Returns the UNO RGB color from the passed encoded OLE color. @@ -139,6 +153,30 @@ private: ~OleHelper(); // not implemented }; +class OOX_DLLPUBLIC OleFormCtrlImportHelper +{ + ::oox::StorageRef mpRoot; + ::oox::StorageRef mpPoolStrg; + ::oox::BinaryXInputStreamRef mpCtlsStrm; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxCtx; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxModel; + ::oox::GraphicHelper maGrfHelper; + bool importControlFromStream( ::oox::BinaryInputStream& rInStrm, + ::com::sun::star::uno::Reference< com::sun::star::form::XFormComponent > & rxFormComp, + const ::rtl::OUString& rGuidString ); + bool importControlFromStorage( ::oox::StorageRef rxObjStrg, + ::com::sun::star::uno::Reference< com::sun::star::form::XFormComponent > & rxFormComp ); +public: + OleFormCtrlImportHelper( const ::com::sun::star::uno::Reference< com::sun::star::io::XInputStream > & xInStrm, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxCtx, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel ); + ~OleFormCtrlImportHelper(); + bool importFormControlFromObjStorage( ::com::sun::star::uno::Reference< com::sun::star::form::XFormComponent > & rxFormComp); + bool importFormControlFromCtls( ::com::sun::star::uno::Reference< com::sun::star::form::XFormComponent > & rxFormComp, + sal_Int32 nPos, sal_Int32 nSize ); + bool importFormControlFromObjPool( ::com::sun::star::uno::Reference< com::sun::star::form::XFormComponent > & rxFormComp, + const ::rtl::OUString& rPoolName ); +}; // ============================================================================ } // namespace ole diff --git a/oox/inc/oox/ppt/backgroundproperties.hxx b/oox/inc/oox/ppt/backgroundproperties.hxx index 7f254e8c386e..4be1177fc55f 100644 --- a/oox/inc/oox/ppt/backgroundproperties.hxx +++ b/oox/inc/oox/ppt/backgroundproperties.hxx @@ -29,18 +29,18 @@ #ifndef OOX_POWERPOINT_BACKGROUNDPROPERTIES_HXX #define OOX_POWERPOINT_BACKGROUNDPROPERTIES_HXX -#include "oox/core/contexthandler.hxx" +#include "oox/core/fragmenthandler2.hxx" #include "oox/drawingml/fillproperties.hxx" namespace oox { namespace ppt { // --------------------------------------------------------------------- -class BackgroundPropertiesContext : public ::oox::core::ContextHandler +class BackgroundPropertiesContext : public ::oox::core::FragmentHandler2 { public: - BackgroundPropertiesContext( ::oox::core::ContextHandler& rParent, ::oox::drawingml::FillProperties& rFillProperties ) throw(); - 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); + BackgroundPropertiesContext( ::oox::core::FragmentHandler2& rParent, ::oox::drawingml::FillProperties& rFillProperties ); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); protected: ::oox::drawingml::FillProperties& mrFillProperties; diff --git a/oox/inc/oox/ppt/customshowlistcontext.hxx b/oox/inc/oox/ppt/customshowlistcontext.hxx index df5ca3a7a6fe..d10976b3ad46 100644 --- a/oox/inc/oox/ppt/customshowlistcontext.hxx +++ b/oox/inc/oox/ppt/customshowlistcontext.hxx @@ -31,7 +31,7 @@ #ifndef OOX_POWERPOINT_CUSTOMSHOWLISTCONTEXT_HXX #define OOX_POWERPOINT_CUSTOMSHOWLISTCONTEXT_HXX -#include "oox/core/contexthandler.hxx" +#include "oox/core/fragmenthandler2.hxx" #include <vector> namespace oox { namespace ppt { @@ -45,18 +45,16 @@ namespace oox { namespace ppt { }; /** CT_ */ - class CustomShowListContext : public ::oox::core::ContextHandler + class CustomShowListContext : public ::oox::core::FragmentHandler2 { std::vector< CustomShow >& mrCustomShowList; public: - CustomShowListContext( ::oox::core::ContextHandler& rParent, + CustomShowListContext( ::oox::core::FragmentHandler2& rParent, std::vector< CustomShow >& rCustomShowList ); ~CustomShowListContext( ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL - createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) - throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); }; } } diff --git a/oox/inc/oox/ppt/layoutfragmenthandler.hxx b/oox/inc/oox/ppt/layoutfragmenthandler.hxx index bc29d732ee28..4e7ae5d28f8e 100644 --- a/oox/inc/oox/ppt/layoutfragmenthandler.hxx +++ b/oox/inc/oox/ppt/layoutfragmenthandler.hxx @@ -41,8 +41,7 @@ public: LayoutFragmentHandler( ::oox::core::XmlFilterBase& rFilter, const ::rtl::OUString& rFragmentPath, SlidePersistPtr pMasterPersistPtr ) throw(); virtual ~LayoutFragmentHandler() 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 aElementToken, const AttributeList& rAttribs ); }; } } diff --git a/oox/inc/oox/ppt/presentationfragmenthandler.hxx b/oox/inc/oox/ppt/presentationfragmenthandler.hxx index f4d46dba9afc..77db0d6dbdb4 100644 --- a/oox/inc/oox/ppt/presentationfragmenthandler.hxx +++ b/oox/inc/oox/ppt/presentationfragmenthandler.hxx @@ -33,7 +33,9 @@ #include <com/sun/star/awt/Size.hpp> #include "oox/drawingml/textliststyle.hxx" #include "oox/ppt/slidepersist.hxx" +#include "oox/core/contexthandler.hxx" #include "oox/core/fragmenthandler.hxx" +#include "oox/core/fragmenthandler2.hxx" #include "oox/core/relations.hxx" #include "oox/ppt/customshowlistcontext.hxx" @@ -42,15 +44,13 @@ namespace oox { namespace ppt { -class PresentationFragmentHandler : public ::oox::core::FragmentHandler +class PresentationFragmentHandler : public ::oox::core::FragmentHandler2 { public: PresentationFragmentHandler( ::oox::core::XmlFilterBase& rFilter, const ::rtl::OUString& rFragmentPath ) throw(); virtual ~PresentationFragmentHandler() throw(); - - virtual void SAL_CALL startDocument( ) 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); - 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 finalizeImport(); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); protected: bool importSlide( const ::oox::core::FragmentHandlerRef& rxSlideFragmentHandler, diff --git a/oox/inc/oox/ppt/slidefragmenthandler.hxx b/oox/inc/oox/ppt/slidefragmenthandler.hxx index b530d8cb2550..ce518e214511 100644 --- a/oox/inc/oox/ppt/slidefragmenthandler.hxx +++ b/oox/inc/oox/ppt/slidefragmenthandler.hxx @@ -31,7 +31,7 @@ #include <com/sun/star/drawing/XDrawPage.hpp> #include "oox/helper/propertymap.hxx" -#include "oox/core/fragmenthandler.hxx" +#include "oox/core/fragmenthandler2.hxx" #include "oox/ppt/slidepersist.hxx" #include <stack> @@ -40,14 +40,14 @@ namespace oox { namespace ppt { -class SlideFragmentHandler : public ::oox::core::FragmentHandler +class SlideFragmentHandler : public ::oox::core::FragmentHandler2 { public: SlideFragmentHandler( ::oox::core::XmlFilterBase& rFilter, const ::rtl::OUString& rFragmentPath, SlidePersistPtr pPersistPtr, const ShapeLocation eShapeLocation ) throw(); virtual ~SlideFragmentHandler() 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 finalizeImport(); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); protected: SlidePersistPtr mpSlidePersistPtr; diff --git a/oox/inc/oox/ppt/slidemastertextstylescontext.hxx b/oox/inc/oox/ppt/slidemastertextstylescontext.hxx index 9f232ee853c8..4381a289a6e1 100644 --- a/oox/inc/oox/ppt/slidemastertextstylescontext.hxx +++ b/oox/inc/oox/ppt/slidemastertextstylescontext.hxx @@ -31,17 +31,17 @@ #include "oox/drawingml/theme.hxx" #include "oox/core/contexthandler.hxx" -#include "oox/core/fragmenthandler.hxx" +#include "oox/core/fragmenthandler2.hxx" #include "oox/ppt/slidepersist.hxx" namespace oox { namespace ppt { -class SlideMasterTextStylesContext : public oox::core::ContextHandler +class SlideMasterTextStylesContext : public oox::core::FragmentHandler2 { public: - SlideMasterTextStylesContext( ::oox::core::ContextHandler& rParent, SlidePersistPtr pSlidePersistPtr ); + SlideMasterTextStylesContext( ::oox::core::FragmentHandler2& rParent, SlidePersistPtr pSlidePersistPtr ); ~SlideMasterTextStylesContext(); - 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 aElementToken, const AttributeList& rAttribs ); protected: SlidePersistPtr mpSlidePersistPtr; diff --git a/oox/inc/oox/ppt/slidetimingcontext.hxx b/oox/inc/oox/ppt/slidetimingcontext.hxx index 76dbb7cd2790..a1ba2dd5e936 100644 --- a/oox/inc/oox/ppt/slidetimingcontext.hxx +++ b/oox/inc/oox/ppt/slidetimingcontext.hxx @@ -31,23 +31,20 @@ #include <com/sun/star/animations/XTimeContainer.hpp> #include "oox/ppt/timenode.hxx" -#include "oox/core/contexthandler.hxx" +#include "oox/core/fragmenthandler2.hxx" #include <stack> #include <vector> namespace oox { namespace ppt { -class SlideTimingContext : public ::oox::core::ContextHandler +class SlideTimingContext : public ::oox::core::FragmentHandler2 { public: - SlideTimingContext( ::oox::core::ContextHandler& rParent, TimeNodePtrList & aTimeNodeList ) throw(); + SlideTimingContext( ::oox::core::FragmentHandler2& rParent, TimeNodePtrList & aTimeNodeList ) throw(); virtual ~SlideTimingContext() throw(); - virtual void SAL_CALL endDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL endFastElement( sal_Int32 aElement ) 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 aElementToken, const AttributeList& rAttribs ); private: TimeNodePtrList & maTimeNodeList; diff --git a/oox/inc/oox/ppt/slidetransitioncontext.hxx b/oox/inc/oox/ppt/slidetransitioncontext.hxx index 361a06f4b556..e6d2cbb729b1 100644 --- a/oox/inc/oox/ppt/slidetransitioncontext.hxx +++ b/oox/inc/oox/ppt/slidetransitioncontext.hxx @@ -29,26 +29,24 @@ #ifndef OOX_PPT_SLIDETRANSITIONCONTEXT #define OOX_PPT_SLIDETRANSITIONCONTEXT -#include "oox/core/contexthandler.hxx" +#include "oox/core/fragmenthandler2.hxx" #include "oox/ppt/slidetransition.hxx" namespace oox { class PropertyMap; } namespace oox { namespace ppt { - class SlideTransitionContext : public ::oox::core::ContextHandler + class SlideTransitionContext : public ::oox::core::FragmentHandler2 { public: - SlideTransitionContext( ::oox::core::ContextHandler& rParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, + SlideTransitionContext( ::oox::core::FragmentHandler2& rParent, + const AttributeList& rAttributes, PropertyMap & aProperties ) throw(); virtual ~SlideTransitionContext() throw(); - virtual void SAL_CALL endFastElement( sal_Int32 aElement ) 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 onEndElement(); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); + private: PropertyMap& maSlideProperties; diff --git a/oox/inc/oox/ppt/soundactioncontext.hxx b/oox/inc/oox/ppt/soundactioncontext.hxx index 0ee8a88dc5dc..d368c1fad649 100644 --- a/oox/inc/oox/ppt/soundactioncontext.hxx +++ b/oox/inc/oox/ppt/soundactioncontext.hxx @@ -30,20 +30,20 @@ #ifndef OOX_PPT_SOUNDACTIONCONTEXT #define OOX_PPT_SOUNDACTIONCONTEXT -#include "oox/core/contexthandler.hxx" +#include "oox/core/fragmenthandler2.hxx" namespace oox { class PropertyMap; } namespace oox { namespace ppt { -class SoundActionContext : public ::oox::core::ContextHandler +class SoundActionContext : public ::oox::core::FragmentHandler2 { public: - SoundActionContext( ::oox::core::ContextHandler& rParent, PropertyMap & aProperties ) throw(); + SoundActionContext( ::oox::core::FragmentHandler2& rParent, PropertyMap & aProperties ) throw(); virtual ~SoundActionContext() throw(); - virtual void SAL_CALL endFastElement( sal_Int32 aElement ) 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 onEndElement(); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); private: PropertyMap& maSlideProperties; diff --git a/oox/inc/oox/ppt/timenodelistcontext.hxx b/oox/inc/oox/ppt/timenodelistcontext.hxx index 25c929cdaf67..75949a419077 100644 --- a/oox/inc/oox/ppt/timenodelistcontext.hxx +++ b/oox/inc/oox/ppt/timenodelistcontext.hxx @@ -29,7 +29,7 @@ #ifndef OOX_PPT_TIMENODELISTCONTEXT #define OOX_PPT_TIMENODELISTCONTEXT -#include "oox/core/contexthandler.hxx" +#include "oox/core/fragmenthandler2.hxx" #include "oox/ppt/timenode.hxx" #include <com/sun/star/animations/XTimeContainer.hpp> @@ -37,15 +37,15 @@ namespace oox { namespace ppt { - class TimeNodeContext : public ::oox::core::ContextHandler + class TimeNodeContext : public ::oox::core::FragmentHandler2 { public: virtual ~TimeNodeContext() throw(); - static TimeNodeContext * SAL_CALL makeContext( ::oox::core::ContextHandler& rParent, sal_Int32 aElement, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ); + static TimeNodeContext * SAL_CALL makeContext( ::oox::core::FragmentHandler2& rParent, sal_Int32 aElement, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ); protected: - TimeNodeContext( ::oox::core::ContextHandler& rParent, sal_Int32 aElement, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) throw(); + TimeNodeContext( ::oox::core::FragmentHandler2& rParent, sal_Int32 aElement, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) throw(); sal_Int32 mnElement; TimeNodePtr mpNode; @@ -54,17 +54,14 @@ namespace oox { namespace ppt { /** FastParser context for XML_tnLst, XML_subTnLst and XML_childTnLst */ -class TimeNodeListContext : public ::oox::core::ContextHandler +class TimeNodeListContext : public ::oox::core::FragmentHandler2 { public: - TimeNodeListContext( ::oox::core::ContextHandler& rParent, TimeNodePtrList & aList ) throw(); + TimeNodeListContext( ::oox::core::FragmentHandler2& rParent, TimeNodePtrList & aList ) throw(); virtual ~TimeNodeListContext() throw(); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); - 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); private: TimeNodePtrList & maList; diff --git a/oox/inc/oox/xls/worksheethelper.hxx b/oox/inc/oox/xls/worksheethelper.hxx index e31c8f69711b..c824c4eb922b 100644 --- a/oox/inc/oox/xls/worksheethelper.hxx +++ b/oox/inc/oox/xls/worksheethelper.hxx @@ -43,6 +43,7 @@ namespace com { namespace sun { namespace star { namespace sheet { class XSheetCellRanges; } namespace sheet { class XSpreadsheet; } namespace table { class XCell; } + namespace table { class XCell2; } namespace table { class XCellRange; } namespace table { class XTableColumns; } namespace table { class XTableRows; } @@ -323,6 +324,13 @@ public: void putValue( const ::com::sun::star::table::CellAddress& rAddress, double fValue ) const; + void putFormulaResult( + const ::com::sun::star::table::CellAddress& rAddress, + double fValue ) const; + void putFormulaString( + const ::com::sun::star::table::CellAddress& rAddress, + const ::rtl::OUString& rText ) const; + /** Inserts a string cell directly into the Calc sheet. */ void putString( const ::com::sun::star::table::CellAddress& rAddress, diff --git a/oox/source/core/contexthandler.cxx b/oox/source/core/contexthandler.cxx index d781a811d520..8b73a5f47885 100644 --- a/oox/source/core/contexthandler.cxx +++ b/oox/source/core/contexthandler.cxx @@ -42,7 +42,7 @@ using ::rtl::OUString; // ============================================================================ -ContextHandler::ContextHandler( ContextHandler& rParent ) : +ContextHandler::ContextHandler( const ContextHandler& rParent ) : ContextHandler_BASE(), mxBaseData( rParent.mxBaseData ) { diff --git a/oox/source/core/services.cxx b/oox/source/core/services.cxx index f05524f4d046..199d8a695048 100644 --- a/oox/source/core/services.cxx +++ b/oox/source/core/services.cxx @@ -81,17 +81,7 @@ static ::cppu::ImplementationEntry const spServices[] = } // namespace -// ---------------------------------------------------------------------------- - -extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( - const sal_Char** ppEnvironmentTypeName, uno_Environment** /*ppEnvironment*/ ) -{ - *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; -} - extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const char* pImplName, void* pServiceManager, void* pRegistryKey ) { return ::cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, spServices ); } - -// ============================================================================ diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 6638ffe5d4d9..1daea946eb33 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -538,13 +538,13 @@ XmlFilterBase& XmlFilterBase::exportDocumentProperties( Reference< XDocumentProp writeCoreProperties( *this, xProperties ); writeAppProperties( *this, xProperties ); Sequence< ::com::sun::star::beans::NamedValue > aStats = xProperties->getDocumentStatistics(); - printf( "# Document Statistics:\n" ); + OSL_TRACE( "# Document Statistics:\n" ); for( sal_Int32 i = 0, end = aStats.getLength(); i < end; ++i ) { ::com::sun::star::uno::Any aValue = aStats[ i ].Value; ::rtl::OUString sValue; bool bHaveString = aValue >>= sValue; - printf ("#\t%s=%s [%s]\n", + OSL_TRACE ("#\t%s=%s [%s]\n", OUStringToOString( aStats[ i ].Name, RTL_TEXTENCODING_UTF8 ).getStr(), bHaveString ? OUStringToOString( sValue, RTL_TEXTENCODING_UTF8 ).getStr() diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx index 2225d7f5ae27..d07d28c79ae8 100644 --- a/oox/source/drawingml/chart/axisconverter.cxx +++ b/oox/source/drawingml/chart/axisconverter.cxx @@ -315,7 +315,11 @@ void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCo // number format ------------------------------------------------------ if( (aScaleData.AxisType == cssc2::AxisType::REALNUMBER) || (aScaleData.AxisType == cssc2::AxisType::PERCENT) ) + { + if( mrModel.maNumberFormat.maFormatCode.indexOfAsciiL("%",1) >= 0) + mrModel.maNumberFormat.mbSourceLinked = false; getFormatter().convertNumberFormat( aAxisProp, mrModel.maNumberFormat ); + } // position of crossing axis ------------------------------------------ diff --git a/oox/source/drawingml/chart/chartconverter.cxx b/oox/source/drawingml/chart/chartconverter.cxx index e66eca6bc0e2..261494327efd 100644 --- a/oox/source/drawingml/chart/chartconverter.cxx +++ b/oox/source/drawingml/chart/chartconverter.cxx @@ -59,7 +59,7 @@ static const sal_Unicode API_TOKEN_ARRAY_CLOSE = '}'; static const sal_Unicode API_TOKEN_ARRAY_ROWSEP = '|'; static const sal_Unicode API_TOKEN_ARRAY_COLSEP = ';'; -// Code similar to oox/source/xls/FormulaParser.cxx +// Code similar to oox/source/xls/formulabase.cxx static OUString lclGenerateApiString( const OUString& rString ) { OUString aRetString = rString; @@ -69,7 +69,7 @@ static OUString lclGenerateApiString( const OUString& rString ) return OUStringBuffer().append( sal_Unicode( '"' ) ).append( aRetString ).append( sal_Unicode( '"' ) ).makeStringAndClear(); } - static ::rtl::OUString lclGenerateApiArray( const Matrix< Any >& rMatrix ) +static ::rtl::OUString lclGenerateApiArray( const Matrix< Any >& rMatrix ) { OSL_ENSURE( !rMatrix.empty(), "ChartConverter::lclGenerateApiArray - missing matrix values" ); OUStringBuffer aBuffer; @@ -156,7 +156,7 @@ Reference< XDataSequence > ChartConverter::createDataSequence( const Reference< } catch( Exception& ) { - OSL_FAIL( "ExcelChartConverter::createDataSequence - cannot create data sequence" ); + OSL_FAIL( "ChartConverter::createDataSequence - cannot create data sequence" ); } } diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index f6f1ad8523ec..8a98471abca9 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/chart2/XRegressionCurve.hpp> #include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <com/sun/star/chart2/data/XDataSink.hpp> +#include <basegfx/numeric/ftools.hxx> #include "oox/drawingml/chart/datasourceconverter.hxx" #include "oox/drawingml/chart/seriesmodel.hxx" #include "oox/drawingml/chart/titleconverter.hxx" @@ -59,6 +60,15 @@ using ::rtl::OUString; namespace { +/** nastied-up sgn function - employs some gratuity around 0 - values + smaller than 0.33 are clamped to 0 + */ +int lclSgn( double nVal ) +{ + const int intVal=nVal*3; + return intVal == 0 ? 0 : (intVal < 0 ? -1 : 1); +} + Reference< XLabeledDataSequence > lclCreateLabeledDataSequence( const ConverterRoot& rParent, DataSourceModel* pValues, const OUString& rRole, @@ -114,6 +124,13 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatt bool bShowValue = !rDataLabel.mbDeleted && rDataLabel.mobShowVal.get( false ); bool bShowPercent = !rDataLabel.mbDeleted && rDataLabel.mobShowPercent.get( false ) && (rTypeInfo.meTypeCategory == TYPECATEGORY_PIE); + if( bShowValue && + !bShowPercent && rTypeInfo.meTypeCategory == TYPECATEGORY_PIE && + rDataLabel.maNumberFormat.maFormatCode.indexOfAsciiL("%", 1) >= 0 ) + { + bShowValue = false; + bShowPercent = true; + } bool bShowCateg = !rDataLabel.mbDeleted && rDataLabel.mobShowCatName.get( false ); bool bShowSymbol = !rDataLabel.mbDeleted && rDataLabel.mobShowLegendKey.get( false ); @@ -178,6 +195,27 @@ void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDat { PropertySet aPropSet( rxDataSeries->getDataPointByIndex( mrModel.mnIndex ) ); lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, false ); + + if( !mrModel.mxLayout->mbAutoLayout ) + { + // bnc#694340 - nasty hack - chart2 cannot individually + // place data labels, let's try to find a useful + // compromise instead + namespace csscd = ::com::sun::star::chart::DataLabelPlacement; + const sal_Int32 aPositionsLookupTable[] = + { + csscd::TOP_LEFT, csscd::TOP, csscd::TOP_RIGHT, + csscd::LEFT, csscd::CENTER, csscd::RIGHT, + csscd::BOTTOM_LEFT, csscd::BOTTOM, csscd::BOTTOM_RIGHT + }; + const double nMax=std::max( + fabs(mrModel.mxLayout->mfX), + fabs(mrModel.mxLayout->mfY)); + const int simplifiedX=lclSgn(mrModel.mxLayout->mfX/nMax); + const int simplifiedY=lclSgn(mrModel.mxLayout->mfY/nMax); + aPropSet.setProperty( PROP_LabelPlacement, + aPositionsLookupTable[ simplifiedX+1 + 3*(simplifiedY+1) ] ); + } } catch( Exception& ) { @@ -206,6 +244,7 @@ void DataLabelsConverter::convertFromModel( const Reference< XDataSeries >& rxDa // data point label settings for( DataLabelsModel::DataLabelVector::iterator aIt = mrModel.maPointLabels.begin(), aEnd = mrModel.maPointLabels.end(); aIt != aEnd; ++aIt ) { + (*aIt)->maNumberFormat.maFormatCode = mrModel.maNumberFormat.maFormatCode; DataLabelConverter aLabelConv( *this, **aIt ); aLabelConv.convertFromModel( rxDataSeries, rTypeGroup ); } @@ -596,6 +635,12 @@ Reference< XDataSeries > SeriesConverter::createDataSeries( const TypeGroupConve ModelRef< DataLabelsModel > xLabels = mrModel.mxLabels.is() ? mrModel.mxLabels : rTypeGroup.getModel().mxLabels; if( xLabels.is() ) { + if( xLabels->maNumberFormat.maFormatCode.isEmpty() ) + { + // Use number format code from Value series + DataSourceModel* pValues = mrModel.maSources.get( SeriesModel::VALUES ).get(); + xLabels->maNumberFormat.maFormatCode = pValues->mxDataSeq->maFormatCode; + } DataLabelsConverter aLabelsConv( *this, *xLabels ); aLabelsConv.convertFromModel( xDataSeries, rTypeGroup ); } diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 4bb7663daf34..fb4d01356b59 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -377,30 +377,6 @@ sal_Int32 lcl_getSequenceLengthByRole( return 0; } -bool lcl_hasChartType( const Reference< chart2::XDiagram > & xDiagram, const OUString & rChartType ) -{ - try - { - Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); - Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); - for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx ) - { - Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW ); - Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); - for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx ) - { - if( aChartTypes[nCTIdx]->getChartType().equals( rChartType )) - return true; - } - } - } - catch( uno::Exception & ) - { - OSL_FAIL( "Exception while searching for chart type in diagram" ); - } - return false; -} - OUString lcl_flattenStringSequence( const Sequence< OUString > & rSequence ) { OUStringBuffer aResult; diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index 9e971e602da6..95a791d86b11 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -61,6 +61,7 @@ #include "oox/helper/containerhelper.hxx" #include "oox/helper/graphichelper.hxx" #include "oox/helper/propertymap.hxx" +#include "tools/string.hxx" namespace oox { namespace ole { @@ -1748,6 +1749,103 @@ void AxUserFormModel::convertProperties( PropertyMap& rPropMap, const ControlCon AxContainerModelBase::convertProperties( rPropMap, rConv ); } +HtmlSelectModel::HtmlSelectModel() +{ +} + +bool +HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm ) +{ + static OUString sTerm( RTL_CONSTASCII_USTRINGPARAM("</SELECT") ); + static String sMultiple( RTL_CONSTASCII_USTRINGPARAM("<SELECT MULTIPLE") ); + static String sSelected( RTL_CONSTASCII_USTRINGPARAM("OPTION SELECTED") ); + + OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() ); + + String data = sStringContents; + + // replace crlf with lf + data.SearchAndReplaceAll( String( RTL_CONSTASCII_USTRINGPARAM( "\x0D\x0A" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "\x0A" ) ) ); + std::vector< rtl::OUString > listValues; + std::vector< sal_Int16 > selectedIndices; + + // Ultra hacky parser for the info + sal_Int32 nTokenCount = data.GetTokenCount( '\n' ); + + for ( sal_Int32 nToken = 0; nToken < nTokenCount; ++nToken ) + { + String sLine( data.GetToken( nToken, '\n' ) ); + if ( !nToken ) // first line will tell us if multiselect is enabled + { + if ( sLine.CompareTo( sMultiple, sMultiple.Len() ) == COMPARE_EQUAL ) + mnMultiSelect = true; + } + // skip first and last lines, no data there + else if ( nToken < nTokenCount - 1) + { + if ( sLine.GetTokenCount( '>' ) ) + { + String displayValue = sLine.GetToken( 1, '>' ); + if ( displayValue.Len() ) + { + // Really we should be using a proper html parser + // escaping some common bits to be escaped + displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "<" ) ), String( RTL_CONSTASCII_USTRINGPARAM("<") ) ); + displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( ">" ) ), String( RTL_CONSTASCII_USTRINGPARAM(">") ) ); + displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( """ ) ), String( RTL_CONSTASCII_USTRINGPARAM("\"") ) ); + displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&" ) ), String( RTL_CONSTASCII_USTRINGPARAM("&") ) ); + listValues.push_back( displayValue ); + if( sLine.Search( sSelected ) != STRING_NOTFOUND ) + selectedIndices.push_back( static_cast< sal_Int16 >( listValues.size() ) - 1 ); + } + } + } + } + if ( listValues.size() ) + { + msListData.realloc( listValues.size() ); + sal_Int32 index = 0; + for( std::vector< rtl::OUString >::iterator it = listValues.begin(); it != listValues.end(); ++it, ++index ) + msListData[ index ] = *it; + } + if ( selectedIndices.size() ) + { + msIndices.realloc( selectedIndices.size() ); + sal_Int32 index = 0; + for( std::vector< sal_Int16 >::iterator it = selectedIndices.begin(); it != selectedIndices.end(); ++it, ++index ) + msIndices[ index ] = *it; + } + return sal_True; +} + + +void +HtmlSelectModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const +{ + rPropMap.setProperty( PROP_StringItemList, msListData ); + rPropMap.setProperty( PROP_SelectedItems, msIndices ); + rPropMap.setProperty( PROP_Dropdown, true ); + AxListBoxModel::convertProperties( rPropMap, rConv ); +} + +HtmlTextBoxModel::HtmlTextBoxModel() +{ +} + +bool +HtmlTextBoxModel::importBinaryModel( BinaryInputStream& rInStrm ) +{ + OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() ); +#ifdef DEBUG + // in msocximex ( where this is ported from, it appears *nothing* is read + // from the control stream ), surely there is some useful info there ? + OSL_TRACE("HtmlTextBoxModel::importBinaryModel - string contents of stream :"); + OSL_TRACE("%s", rtl::OUStringToOString( sStringContents, RTL_TEXTENCODING_UTF8 ).getStr() ); +#else + (void) rInStrm; +#endif + return true; +} // ============================================================================ EmbeddedControl::EmbeddedControl( const OUString& rName ) : @@ -1776,6 +1874,8 @@ ControlModelBase* EmbeddedControl::createModelFromGuid( const OUString& rClassId if( aClassId.equalsAscii( AX_GUID_SCROLLBAR ) ) return &createModel< AxScrollBarModel >(); if( aClassId.equalsAscii( AX_GUID_FRAME ) ) return &createModel< AxFrameModel >(); if( aClassId.equalsAscii( COMCTL_GUID_SCROLLBAR_60 ) ) return &createModel< ComCtlScrollBarModel >( COMCTL_VERSION_60 ); + if( aClassId.equalsAscii( HTML_GUID_SELECT ) ) return &createModel< HtmlSelectModel >(); + if( aClassId.equalsAscii( HTML_GUID_TEXTBOX ) ) return &createModel< HtmlTextBoxModel >(); mxModel.reset(); return 0; diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx index 95678f147cd4..2bcafc9a2882 100644 --- a/oox/source/ole/olehelper.cxx +++ b/oox/source/ole/olehelper.cxx @@ -32,6 +32,11 @@ #include "oox/helper/binaryinputstream.hxx" #include "oox/helper/graphichelper.hxx" #include "oox/token/tokens.hxx" +#include "oox/ole/axcontrol.hxx" +#include <com/sun/star/beans/XPropertySet.hpp> +#include "oox/helper/propertymap.hxx" +#include "oox/helper/propertyset.hxx" +#include "oox/ole/olestorage.hxx" namespace oox { namespace ole { @@ -41,6 +46,12 @@ namespace ole { using ::rtl::OUString; using ::rtl::OUStringBuffer; +using ::com::sun::star::form::XFormComponent; +using ::com::sun::star::awt::XControlModel; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::UNO_QUERY; + // ============================================================================ namespace { @@ -308,6 +319,132 @@ StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, return !rInStrm.isEof(); } +Reference< ::com::sun::star::frame::XFrame > +lcl_getFrame( const Reference< ::com::sun::star::frame::XModel >& rxModel ) +{ + Reference< ::com::sun::star::frame::XFrame > xFrame; + if ( rxModel.is() ) + { + Reference< ::com::sun::star::frame::XController > xController = rxModel->getCurrentController(); + xFrame = xController.is() ? xController->getFrame() : NULL; + } + return xFrame; +} + +OleFormCtrlImportHelper::OleFormCtrlImportHelper( const Reference< com::sun::star::io::XInputStream > & rxInStrm, const Reference< ::com::sun::star::uno::XComponentContext >& rxCtx, const Reference< ::com::sun::star::frame::XModel >& rxModel ) : mpRoot( new ::oox::ole::OleStorage( rxCtx, rxInStrm, true ) ), mxCtx( rxCtx ), mxModel( rxModel ), maGrfHelper( rxCtx, lcl_getFrame( rxModel ), mpRoot ) +{ +} + +OleFormCtrlImportHelper::~OleFormCtrlImportHelper() +{ +} + +bool +OleFormCtrlImportHelper::importControlFromStream( ::oox::BinaryInputStream& rInStrm, Reference< XFormComponent >& rxFormComp, const ::rtl::OUString& rGuidString ) +{ + ::oox::ole::EmbeddedControl aControl( CREATE_OUSTRING( "Unknown" ) ); + if( ::oox::ole::ControlModelBase* pModel = aControl.createModelFromGuid( rGuidString ) ) + { + pModel->importBinaryModel( rInStrm ); + rxFormComp.set( mxCtx->getServiceManager()->createInstanceWithContext( pModel->getServiceName(), mxCtx ), UNO_QUERY ); + Reference< XControlModel > xCtlModel( rxFormComp, UNO_QUERY ); + ::oox::ole::ControlConverter aConv( mxModel, maGrfHelper ); + aControl.convertProperties( xCtlModel, aConv ); + } + return rxFormComp.is(); +} + +bool +OleFormCtrlImportHelper::importFormControlFromCtls( Reference< XFormComponent > & rxFormComp, + sal_Int32 nPos, + sal_Int32 nStreamSize) +{ + if ( mpRoot.get() && mpRoot->isStorage() ) + { + if ( !mpCtlsStrm.get() ) + mpCtlsStrm.reset( new BinaryXInputStream( mpRoot->openInputStream( CREATE_OUSTRING( "Ctls" ) ), true ) ); + mpCtlsStrm->seek( nPos ); + OUString aStrmClassId = ::oox::ole::OleHelper::importGuid( *mpCtlsStrm ); + + bool bOneOfHtmlControls = false; + if ( aStrmClassId.toAsciiUpperCase().equalsAscii( HTML_GUID_SELECT ) + || aStrmClassId.toAsciiUpperCase().equalsAscii( HTML_GUID_TEXTBOX ) ) + bOneOfHtmlControls = false; + + if ( bOneOfHtmlControls ) + { + // html controls don't seem have a handy record length following the GUID + // in the binary stream. + // Given the control stream length create a stream of nStreamSize bytes starting from + // nPos ( offset by the guid already read in ) + const int nGuidSize = 0x10; + StreamDataSequence aDataSeq; + sal_Int32 nBytesToRead = nStreamSize - nGuidSize; + while ( nBytesToRead ) + nBytesToRead -= mpCtlsStrm->readData( aDataSeq, nBytesToRead ); + SequenceInputStream aInSeqStream( aDataSeq ); + importControlFromStream( aInSeqStream, rxFormComp, aStrmClassId ); + } + else + { + importControlFromStream( *mpCtlsStrm, rxFormComp, aStrmClassId ); + } + } + return rxFormComp.is(); +} + +bool OleFormCtrlImportHelper::importControlFromStorage( ::oox::StorageRef xObjStrg, + Reference< XFormComponent > & rxFormComp ) +{ + if ( xObjStrg.get() && xObjStrg->isStorage() ) + { + BinaryXInputStream aNameStream( xObjStrg->openInputStream( CREATE_OUSTRING("\3OCXNAME") ), true ); + BinaryXInputStream aInStrm( xObjStrg->openInputStream( CREATE_OUSTRING("contents") ), true ); + BinaryXInputStream aClsStrm( xObjStrg->openInputStream( CREATE_OUSTRING("\1CompObj") ), true ); + aClsStrm.skip(12); + OUString aStrmClassId = ::oox::ole::OleHelper::importGuid( aClsStrm ); + if ( importControlFromStream( aInStrm, rxFormComp, aStrmClassId ) ) + { + OUString aName = aNameStream.readNulUnicodeArray(); + Reference< XControlModel > xCtlModel( rxFormComp, UNO_QUERY ); + if ( aName.getLength() && xCtlModel.is() ) + { + PropertyMap aPropMap; + aPropMap.setProperty( PROP_Name, aName ); + PropertySet aPropSet( xCtlModel ); + aPropSet.setProperties( aPropMap ); + } + } + } + return rxFormComp.is(); +} + +bool +OleFormCtrlImportHelper::importFormControlFromObjStorage( Reference< XFormComponent > & rxFormComp ) +{ + return importControlFromStorage( mpRoot, rxFormComp ); +} + +bool +OleFormCtrlImportHelper::importFormControlFromObjPool( Reference< XFormComponent > & rxFormComp, + const ::rtl::OUString& rPoolName ) +{ + bool bRet = false; + if ( mpRoot.get() ) + { + if ( !mpPoolStrg.get() ) + mpPoolStrg = mpRoot->openSubStorage( CREATE_OUSTRING( "ObjectPool" ), false ); + if ( !mpPoolStrg.get() ) + return false; + if ( mpPoolStrg->isStorage() ) + { + StorageRef xObjStrg = mpPoolStrg->openSubStorage( rPoolName, false ); + bRet = importControlFromStorage( xObjStrg, rxFormComp ); + } + } + return bRet; +} + // ============================================================================ } // namespace ole diff --git a/oox/source/ppt/animvariantcontext.cxx b/oox/source/ppt/animvariantcontext.cxx index 7d0c9a6c153e..c559cbb56d18 100644 --- a/oox/source/ppt/animvariantcontext.cxx +++ b/oox/source/ppt/animvariantcontext.cxx @@ -48,8 +48,8 @@ using namespace ::com::sun::star::xml::sax; namespace oox { namespace ppt { - AnimVariantContext::AnimVariantContext( ContextHandler& rParent, sal_Int32 aElement, Any & aValue ) - : ContextHandler( rParent ) + AnimVariantContext::AnimVariantContext( FragmentHandler2& rParent, sal_Int32 aElement, Any & aValue ) + : FragmentHandler2( rParent ) , mnElement( aElement ) , maValue( aValue ) { @@ -59,63 +59,52 @@ namespace oox { namespace ppt { { } - void SAL_CALL AnimVariantContext::endFastElement( sal_Int32 aElement ) - throw ( SAXException, RuntimeException) + void AnimVariantContext::onEndElement() { - if( ( aElement == mnElement ) && maColor.isUsed() ) + if( isCurrentElement( mnElement ) && maColor.isUsed() ) { maValue = makeAny( maColor.getColor( getFilter().getGraphicHelper() ) ); } } - Reference< XFastContextHandler > - SAL_CALL AnimVariantContext::createFastChildContext( ::sal_Int32 aElementToken, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) + ContextHandlerRef AnimVariantContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - AttributeList attribs(xAttribs); - switch( aElementToken ) { case PPT_TOKEN( boolVal ): { - bool val = attribs.getBool( XML_val, false ); + bool val = rAttribs.getBool( XML_val, false ); maValue = makeAny( val ); - break; + return this; } case PPT_TOKEN( clrVal ): - xRet.set( new ::oox::drawingml::ColorContext( *this, maColor ) ); + return new ::oox::drawingml::ColorContext( *this, maColor ); // we'll defer setting the Any until the end. - break; case PPT_TOKEN( fltVal ): { - double val = attribs.getDouble( XML_val, 0.0 ); + double val = rAttribs.getDouble( XML_val, 0.0 ); maValue = makeAny( val ); - break; + return this; } case PPT_TOKEN( intVal ): { - sal_Int32 val = attribs.getInteger( XML_val, 0 ); + sal_Int32 val = rAttribs.getInteger( XML_val, 0 ); maValue = makeAny( val ); - break; + return this; } case PPT_TOKEN( strVal ): { - OUString val = attribs.getString( XML_val, OUString() ); + OUString val = rAttribs.getString( XML_val, OUString() ); convertMeasure( val ); // ignore success or failure if it fails, use as is maValue = makeAny( val ); - break; + return this; } default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } diff --git a/oox/source/ppt/animvariantcontext.hxx b/oox/source/ppt/animvariantcontext.hxx index 7508cbef40b9..3c0c2a029bb5 100644 --- a/oox/source/ppt/animvariantcontext.hxx +++ b/oox/source/ppt/animvariantcontext.hxx @@ -34,20 +34,20 @@ #include <com/sun/star/uno/Any.hxx> -#include "oox/core/contexthandler.hxx" +#include "oox/core/fragmenthandler2.hxx" #include "oox/drawingml/color.hxx" namespace oox { namespace ppt { /** context CT_TLAnimVariant */ class AnimVariantContext - : public ::oox::core::ContextHandler + : public ::oox::core::FragmentHandler2 { public: - AnimVariantContext( ::oox::core::ContextHandler& rParent, ::sal_Int32 aElement, ::com::sun::star::uno::Any & aValue ); + AnimVariantContext( ::oox::core::FragmentHandler2& rParent, ::sal_Int32 aElement, ::com::sun::star::uno::Any & aValue ); ~AnimVariantContext( ) throw( ); - virtual void SAL_CALL endFastElement( sal_Int32 /*aElement*/ ) 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 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual void onEndElement(); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); private: ::sal_Int32 mnElement; diff --git a/oox/source/ppt/backgroundproperties.cxx b/oox/source/ppt/backgroundproperties.cxx index e3a3714417ff..bbc9940ad10b 100644 --- a/oox/source/ppt/backgroundproperties.cxx +++ b/oox/source/ppt/backgroundproperties.cxx @@ -29,6 +29,7 @@ #include "oox/ppt/backgroundproperties.hxx" #include "oox/drawingml/fillpropertiesgroupcontext.hxx" #include "oox/drawingml/drawingmltypes.hxx" +#include "oox/core/contexthandler2.hxx" using ::rtl::OUString; using namespace ::oox::core; @@ -38,27 +39,22 @@ using namespace ::com::sun::star::xml::sax; namespace oox { namespace ppt { // --------------------------------------------------------------------- -BackgroundPropertiesContext::BackgroundPropertiesContext( ContextHandler& rParent, ::oox::drawingml::FillProperties& rFillProperties ) throw() -: ContextHandler( rParent ) +BackgroundPropertiesContext::BackgroundPropertiesContext( FragmentHandler2& rParent, ::oox::drawingml::FillProperties& rFillProperties ) +: FragmentHandler2( rParent ) , mrFillProperties( rFillProperties ) { } -Reference< XFastContextHandler > BackgroundPropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +::oox::core::ContextHandlerRef BackgroundPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( aElementToken ) { case PPT_TOKEN( fill ): // a:CT_FillEffect - break; + return this; } // FillPropertiesGroupContext - if( !xRet.is() ) - xRet = ::oox::drawingml::FillPropertiesContext::createFillContext( *this, aElementToken, xAttribs, mrFillProperties ); - - return xRet; + return dynamic_cast <ContextHandler *> (::oox::drawingml::FillPropertiesContext::createFillContext( *this, aElementToken, rAttribs.getFastAttributeList(), mrFillProperties ).get()); } } } diff --git a/oox/source/ppt/buildlistcontext.cxx b/oox/source/ppt/buildlistcontext.cxx index 11c07c484a91..cd0ea90964a6 100644 --- a/oox/source/ppt/buildlistcontext.cxx +++ b/oox/source/ppt/buildlistcontext.cxx @@ -38,10 +38,10 @@ using ::rtl::OUString; namespace oox { namespace ppt { - BuildListContext::BuildListContext( ContextHandler& rParent, + BuildListContext::BuildListContext( FragmentHandler2& rParent, const Reference< XFastAttributeList >& /*xAttribs*/, TimeNodePtrList & aTimeNodeList) - : ContextHandler( rParent ) + : FragmentHandler2( rParent ) , maTimeNodeList( aTimeNodeList ) , mbInBldGraphic( false ) , mbBuildAsOne( false ) @@ -52,9 +52,9 @@ namespace oox { namespace ppt { { } - void SAL_CALL BuildListContext::endFastElement( sal_Int32 aElement ) throw ( SAXException, RuntimeException) + void BuildListContext::onEndElement() { - switch( aElement ) + switch( getCurrentElement() ) { case PPT_TOKEN( bldGraphic ): mbInBldGraphic = false; @@ -64,12 +64,8 @@ namespace oox { namespace ppt { } } - Reference< XFastContextHandler > SAL_CALL BuildListContext::createFastChildContext( ::sal_Int32 aElementToken, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) + ::oox::core::ContextHandlerRef BuildListContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( aElementToken ) { case PPT_TOKEN( bldAsOne ): @@ -77,36 +73,31 @@ namespace oox { namespace ppt { { mbBuildAsOne = true; } - break; + return this; case PPT_TOKEN( bldSub ): if( mbInBldGraphic ) { } - break; + return this; case PPT_TOKEN( bldGraphic ): { mbInBldGraphic = true; - AttributeList attribs( xAttribs ); - OUString sShapeId = xAttribs->getOptionalValue( XML_spid ); + OUString sShapeId = rAttribs.getString( XML_spid, OUString() ); // TODO -// bool uiExpand = attribs.getBool( XML_uiExpand, true ); +// bool uiExpand = rAttribs.getBool( XML_uiExpand, true ); /* this is unsigned */ -// sal_uInt32 nGroupId = attribs.getUnsignedInteger( XML_grpId, 0 ); - break; +// sal_uInt32 nGroupId = rAttribs.getUnsignedInteger( XML_grpId, 0 ); + return this; } case A_TOKEN( bldDgm ): case A_TOKEN( bldOleChart ): case A_TOKEN( bldP ): - - break; + return this; default: break; } - if( !xRet.is() ) - xRet.set(this); - - return xRet; + return this; } diff --git a/oox/source/ppt/buildlistcontext.hxx b/oox/source/ppt/buildlistcontext.hxx index 1c4e3949fa7b..f147fa8af215 100644 --- a/oox/source/ppt/buildlistcontext.hxx +++ b/oox/source/ppt/buildlistcontext.hxx @@ -32,25 +32,25 @@ #define OOX_PPT_BUILDLISTCONTEXT #include "oox/ppt/timenode.hxx" -#include "oox/core/contexthandler.hxx" +#include "oox/core/fragmenthandler2.hxx" namespace oox { namespace ppt { /** CT_BuildList */ class BuildListContext - : public ::oox::core::ContextHandler + : public ::oox::core::FragmentHandler2 { public: - BuildListContext( ::oox::core::ContextHandler& rParent, + BuildListContext( ::oox::core::FragmentHandler2& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, TimeNodePtrList & aTimeNodeList); ~BuildListContext( ); - virtual void SAL_CALL endFastElement( sal_Int32 aElement ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void onEndElement(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); private: TimeNodePtrList & maTimeNodeList; bool mbInBldGraphic; diff --git a/oox/source/ppt/commonbehaviorcontext.cxx b/oox/source/ppt/commonbehaviorcontext.cxx index 72c59f730053..2e24aa43adb6 100644 --- a/oox/source/ppt/commonbehaviorcontext.cxx +++ b/oox/source/ppt/commonbehaviorcontext.cxx @@ -53,7 +53,7 @@ using namespace ::com::sun::star::animations; namespace oox { namespace ppt { - CommonBehaviorContext::CommonBehaviorContext( ContextHandler& rParent, + CommonBehaviorContext::CommonBehaviorContext( FragmentHandler2& rParent, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) : TimeNodeContext( rParent, PPT_TOKEN( cBhvr ), xAttribs, pNode ) @@ -69,10 +69,9 @@ namespace oox { namespace ppt { - void SAL_CALL CommonBehaviorContext::endFastElement( sal_Int32 aElement ) - throw ( SAXException, RuntimeException) + void CommonBehaviorContext::onEndElement() { - switch( aElement ) + switch( getCurrentElement() ) { case PPT_TOKEN( cBhvr ): { @@ -126,8 +125,7 @@ namespace oox { namespace ppt { } - void CommonBehaviorContext::characters( const OUString& aChars ) - throw( SAXException, RuntimeException ) + void CommonBehaviorContext::onCharacters( const OUString& aChars ) { if( mbIsInAttrName ) { @@ -136,23 +134,17 @@ namespace oox { namespace ppt { } - Reference< XFastContextHandler > SAL_CALL CommonBehaviorContext::createFastChildContext( ::sal_Int32 aElementToken, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) + ::oox::core::ContextHandlerRef CommonBehaviorContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch ( aElementToken ) { case PPT_TOKEN( cTn ): - xRet.set( new CommonTimeNodeContext( *this, aElementToken, xAttribs, mpNode ) ); - break; + return new CommonTimeNodeContext( *this, aElementToken, rAttribs.getFastAttributeList(), mpNode ); case PPT_TOKEN( tgtEl ): - xRet.set( new TimeTargetElementContext( *this, mpNode->getTarget() ) ); - break; + return new TimeTargetElementContext( *this, mpNode->getTarget() ); case PPT_TOKEN( attrNameLst ): mbInAttrList = true; - break; + return this; case PPT_TOKEN( attrName ): { if( mbInAttrList ) @@ -164,16 +156,13 @@ namespace oox { namespace ppt { { OSL_TRACE( "OOX: Attribute Name outside an Attribute List" ); } - break; + return this; } default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } } } diff --git a/oox/source/ppt/commonbehaviorcontext.hxx b/oox/source/ppt/commonbehaviorcontext.hxx index e047bbc46c7f..4415687f0b06 100644 --- a/oox/source/ppt/commonbehaviorcontext.hxx +++ b/oox/source/ppt/commonbehaviorcontext.hxx @@ -50,24 +50,17 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - CommonBehaviorContext( ::oox::core::ContextHandler& rParent, + CommonBehaviorContext( ::oox::core::FragmentHandler2& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ); ~CommonBehaviorContext( ) throw( ); - virtual void SAL_CALL endFastElement( sal_Int32 aElement ) - throw ( ::com::sun::star::xml::sax::SAXException, - ::com::sun::star::uno::RuntimeException ); + virtual void onEndElement(); - virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) - throw ( ::com::sun::star::xml::sax::SAXException, - ::com::sun::star::uno::RuntimeException ); + virtual void onCharacters( const ::rtl::OUString& aChars ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, - const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) - throw ( ::com::sun::star::xml::sax::SAXException, - ::com::sun::star::uno::RuntimeException ); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); private: bool mbInAttrList; diff --git a/oox/source/ppt/commontimenodecontext.cxx b/oox/source/ppt/commontimenodecontext.cxx index ac88c8c67a1a..30b630cacf72 100644 --- a/oox/source/ppt/commontimenodecontext.cxx +++ b/oox/source/ppt/commontimenodecontext.cxx @@ -374,7 +374,7 @@ static OUString getConvertedSubType( sal_Int16 nPresetClass, sal_Int32 nPresetId // END CommonTimeNodeContext::CommonTimeNodeContext( - ContextHandler& rParent, + FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) @@ -614,39 +614,34 @@ static OUString getConvertedSubType( sal_Int16 nPresetClass, sal_Int32 nPresetId } - void SAL_CALL CommonTimeNodeContext::endFastElement( sal_Int32 aElement ) throw ( SAXException, RuntimeException) + void CommonTimeNodeContext::onEndElement() { - if( aElement == ( PPT_TOKEN( iterate ) ) ) + if( isCurrentElement( PPT_TOKEN( iterate ) ) ) { mbIterate = false; } } - Reference< XFastContextHandler > SAL_CALL CommonTimeNodeContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + ::oox::core::ContextHandlerRef CommonTimeNodeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; switch ( aElementToken ) { case PPT_TOKEN( childTnLst ): case PPT_TOKEN( subTnLst ): - xRet.set( new TimeNodeListContext( *this, mpNode->getChildren() ) ); - break; + return new TimeNodeListContext( *this, mpNode->getChildren() ); case PPT_TOKEN( stCondLst ): - xRet.set( new CondListContext( *this, aElementToken, xAttribs, mpNode, mpNode->getStartCondition() ) ); - break; + return new CondListContext( *this, aElementToken, rAttribs.getFastAttributeList(), mpNode, mpNode->getStartCondition() ); case PPT_TOKEN( endCondLst ): - xRet.set( new CondListContext( *this, aElementToken, xAttribs, mpNode, mpNode->getEndCondition() ) ); - break; + return new CondListContext( *this, aElementToken, rAttribs.getFastAttributeList(), mpNode, mpNode->getEndCondition() ); case PPT_TOKEN( endSync ): - xRet.set( new CondContext( *this, xAttribs, mpNode, mpNode->getEndSyncValue() ) ); - break; + return new CondContext( *this, rAttribs.getFastAttributeList(), mpNode, mpNode->getEndSyncValue() ); case PPT_TOKEN( iterate ): { - sal_Int32 nVal = xAttribs->getOptionalValueToken( XML_type, XML_el ); + sal_Int32 nVal = rAttribs.getToken( XML_type, XML_el ); if( nVal != 0 ) { // TODO put that in a function @@ -671,37 +666,31 @@ static OUString getConvertedSubType( sal_Int16 nPresetClass, sal_Int32 nPresetId mpNode->getNodeProperties()[ NP_ITERATETYPE ] <<= nEnum; } // in case of exception we ignore the whole tag. - AttributeList attribs( xAttribs ); // TODO what to do with this - /*bool bBackwards =*/ attribs.getBool( XML_backwards, false ); + /*bool bBackwards =*/ rAttribs.getBool( XML_backwards, false ); mbIterate = true; - break; + return this; } case PPT_TOKEN( tmAbs ): if( mbIterate ) { - AttributeList attribs( xAttribs ); - double fTime = attribs.getUnsigned( XML_val, 0 ); + double fTime = rAttribs.getUnsigned( XML_val, 0 ); // time in ms. property is in % TODO mpNode->getNodeProperties()[ NP_ITERATEINTERVAL ] <<= fTime; } - break; + return this; case PPT_TOKEN( tmPct ): if( mbIterate ) { - AttributeList attribs( xAttribs ); - double fPercent = (double)attribs.getUnsigned( XML_val, 0 ) / 100000.0; + double fPercent = (double)rAttribs.getUnsigned( XML_val, 0 ) / 100000.0; mpNode->getNodeProperties()[ NP_ITERATEINTERVAL ] <<= fPercent; } - break; + return this; default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } } } diff --git a/oox/source/ppt/commontimenodecontext.hxx b/oox/source/ppt/commontimenodecontext.hxx index cb67433ee398..0cdb8be7868e 100644 --- a/oox/source/ppt/commontimenodecontext.hxx +++ b/oox/source/ppt/commontimenodecontext.hxx @@ -44,12 +44,12 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - CommonTimeNodeContext( ::oox::core::ContextHandler& rParent, sal_Int32 aElement, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, const TimeNodePtr & pNode); + CommonTimeNodeContext( ::oox::core::FragmentHandler2& rParent, sal_Int32 aElement, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, const TimeNodePtr & pNode); ~CommonTimeNodeContext( ) throw( ); - virtual void SAL_CALL endFastElement( sal_Int32 aElement ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void onEndElement(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); private: bool mbIterate; diff --git a/oox/source/ppt/conditioncontext.cxx b/oox/source/ppt/conditioncontext.cxx index 97dd7f9bfcd5..6be6b1f0753a 100644 --- a/oox/source/ppt/conditioncontext.cxx +++ b/oox/source/ppt/conditioncontext.cxx @@ -51,7 +51,7 @@ using namespace ::com::sun::star::animations; namespace oox { namespace ppt { - CondContext::CondContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, + CondContext::CondContext( FragmentHandler2& rParent, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode, AnimationCondition & aValue ) : TimeNodeContext( rParent, PPT_TOKEN( cond ), xAttribs, pNode ) , maCond( aValue ) @@ -116,10 +116,8 @@ namespace oox { namespace ppt { } } - Reference< XFastContextHandler > SAL_CALL CondContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + ::oox::core::ContextHandlerRef CondContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( aElementToken ) { case PPT_TOKEN( rtn ): @@ -127,7 +125,7 @@ namespace oox { namespace ppt { // ST_TLTriggerRuntimeNode { first, last, all } sal_Int32 aTok; sal_Int16 nEnum; - aTok = xAttribs->getOptionalValueToken( XML_val, XML_first ); + aTok = rAttribs.getToken( XML_val, XML_first ); switch( aTok ) { case XML_first: @@ -144,28 +142,23 @@ namespace oox { namespace ppt { } maCond.mnType = aElementToken; maCond.maValue = makeAny( nEnum ); - break; + return this; } case PPT_TOKEN( tn ): { maCond.mnType = aElementToken; - AttributeList attribs( xAttribs ); - sal_uInt32 nId = attribs.getUnsigned( XML_val, 0 ); + sal_uInt32 nId = rAttribs.getUnsigned( XML_val, 0 ); maCond.maValue = makeAny( nId ); - break; + return this; } case PPT_TOKEN( tgtEl ): // CT_TLTimeTargetElement - xRet.set( new TimeTargetElementContext( *this, maCond.getTarget() ) ); - break; + return new TimeTargetElementContext( *this, maCond.getTarget() ); default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } @@ -173,7 +166,7 @@ namespace oox { namespace ppt { /** CT_TLTimeConditionList */ CondListContext::CondListContext( - ContextHandler& rParent, sal_Int32 aElement, + FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode, AnimationConditionList & aCond ) @@ -187,25 +180,19 @@ namespace oox { namespace ppt { { } - Reference< XFastContextHandler > CondListContext::createFastChildContext( ::sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + ::oox::core::ContextHandlerRef CondListContext::onCreateContext( sal_Int32 aElement, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( aElement ) { case PPT_TOKEN( cond ): // add a condition to the list maConditions.push_back( AnimationCondition() ); - xRet.set( new CondContext( *this, xAttribs, mpNode, maConditions.back() ) ); + return new CondContext( *this, rAttribs.getFastAttributeList(), mpNode, maConditions.back() ); break; default: break; } - - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } diff --git a/oox/source/ppt/conditioncontext.hxx b/oox/source/ppt/conditioncontext.hxx index 3abd050da006..ff387a123193 100644 --- a/oox/source/ppt/conditioncontext.hxx +++ b/oox/source/ppt/conditioncontext.hxx @@ -46,11 +46,11 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - CondContext( ::oox::core::ContextHandler& rParent, + CondContext( ::oox::core::FragmentHandler2& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, const TimeNodePtr & pNode, AnimationCondition & aCond ); ~CondContext( ) throw( ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); private: // ::com::sun::star::uno::Any & maCond; @@ -66,13 +66,13 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - CondListContext( ::oox::core::ContextHandler& rParent, + CondListContext( ::oox::core::FragmentHandler2& rParent, sal_Int32 aElement, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, const TimeNodePtr & pNode, AnimationConditionList & aCondList ); ~CondListContext( ) throw( ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); private: AnimationConditionList & maConditions; diff --git a/oox/source/ppt/customshowlistcontext.cxx b/oox/source/ppt/customshowlistcontext.cxx index 76bac5b7467c..c75ee4e8a370 100644 --- a/oox/source/ppt/customshowlistcontext.cxx +++ b/oox/source/ppt/customshowlistcontext.cxx @@ -34,24 +34,22 @@ using namespace ::com::sun::star::xml::sax; namespace oox { namespace ppt { -class CustomShowContext : public ::oox::core::ContextHandler +class CustomShowContext : public ::oox::core::FragmentHandler2 { CustomShow mrCustomShow; public: - CustomShowContext( ::oox::core::ContextHandler& rParent, + CustomShowContext( ::oox::core::FragmentHandler2& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, CustomShow& rCustomShow ); ~CustomShowContext( ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL - createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) - throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); }; -CustomShowContext::CustomShowContext( ContextHandler& rParent, +CustomShowContext::CustomShowContext( FragmentHandler2& rParent, const Reference< XFastAttributeList >& rxAttribs, CustomShow& rCustomShow ) -: ContextHandler( rParent ) +: FragmentHandler2( rParent ) , mrCustomShow( rCustomShow ) { mrCustomShow.maName = rxAttribs->getOptionalValue( XML_name ); @@ -62,29 +60,25 @@ CustomShowContext::~CustomShowContext( ) { } -Reference< XFastContextHandler > SAL_CALL CustomShowContext::createFastChildContext( sal_Int32 aElementToken, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) +::oox::core::ContextHandlerRef CustomShowContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; switch( aElementToken ) { case PPT_TOKEN( sld ) : - mrCustomShow.maSldLst.push_back( xAttribs->getOptionalValue( R_TOKEN( id ) ) ); + mrCustomShow.maSldLst.push_back( rAttribs.getString( R_TOKEN( id ), rtl::OUString() ) ); + return this; default: break; } - if( !xRet.is() ) - xRet.set( this ); - return xRet; + return this; } //--------------------------------------------------------------------------- -CustomShowListContext::CustomShowListContext( ContextHandler& rParent, +CustomShowListContext::CustomShowListContext( FragmentHandler2& rParent, std::vector< CustomShow >& rCustomShowList ) -: ContextHandler( rParent ) +: FragmentHandler2( rParent ) , mrCustomShowList( rCustomShowList ) { } @@ -93,26 +87,21 @@ CustomShowListContext::~CustomShowListContext( ) { } -Reference< XFastContextHandler > SAL_CALL CustomShowListContext::createFastChildContext( sal_Int32 aElementToken, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) +::oox::core::ContextHandlerRef CustomShowListContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; switch( aElementToken ) { case PPT_TOKEN( custShow ) : { CustomShow aCustomShow; mrCustomShowList.push_back( aCustomShow ); - xRet = new CustomShowContext( *this, xAttribs, mrCustomShowList.back() ); + return new CustomShowContext( *this, rAttribs.getFastAttributeList(), mrCustomShowList.back() ); } default: break; } - if( !xRet.is() ) - xRet.set( this ); - return xRet; + return this; } diff --git a/oox/source/ppt/headerfootercontext.cxx b/oox/source/ppt/headerfootercontext.cxx index 88a1e7c60894..83963585bd0d 100644 --- a/oox/source/ppt/headerfootercontext.cxx +++ b/oox/source/ppt/headerfootercontext.cxx @@ -35,26 +35,25 @@ using namespace ::com::sun::star::xml::sax; namespace oox { namespace ppt { - HeaderFooterContext::HeaderFooterContext( ContextHandler& rParent, - const Reference< XFastAttributeList >& xAttribs, HeaderFooter& rHeaderFooter ) - : ContextHandler( rParent ) + HeaderFooterContext::HeaderFooterContext( FragmentHandler2& rParent, + const AttributeList& rAttribs, HeaderFooter& rHeaderFooter ) + : FragmentHandler2( rParent ) { - AttributeList aAttribs( xAttribs ); - if ( xAttribs->hasAttribute( XML_sldNum ) ) + if ( rAttribs.hasAttribute( XML_sldNum ) ) { - rHeaderFooter.mbSlideNumber = aAttribs.getBool( XML_sldNum, sal_True ); + rHeaderFooter.mbSlideNumber = rAttribs.getBool( XML_sldNum, sal_True ); } - if ( xAttribs->hasAttribute( XML_hdr ) ) + if ( rAttribs.hasAttribute( XML_hdr ) ) { - rHeaderFooter.mbHeader = aAttribs.getBool( XML_hdr, sal_True ); + rHeaderFooter.mbHeader = rAttribs.getBool( XML_hdr, sal_True ); } - if ( xAttribs->hasAttribute( XML_ftr ) ) + if ( rAttribs.hasAttribute( XML_ftr ) ) { - rHeaderFooter.mbFooter = aAttribs.getBool( XML_ftr, sal_True ); + rHeaderFooter.mbFooter = rAttribs.getBool( XML_ftr, sal_True ); } - if ( xAttribs->hasAttribute( XML_dt ) ) + if ( rAttribs.hasAttribute( XML_dt ) ) { - rHeaderFooter.mbDateTime = aAttribs.getBool( XML_dt, sal_True ); + rHeaderFooter.mbDateTime = rAttribs.getBool( XML_dt, sal_True ); } } diff --git a/oox/source/ppt/headerfootercontext.hxx b/oox/source/ppt/headerfootercontext.hxx index 7cd83b5f53e4..4cc78b9e7dcf 100644 --- a/oox/source/ppt/headerfootercontext.hxx +++ b/oox/source/ppt/headerfootercontext.hxx @@ -32,16 +32,16 @@ #define OOX_PPT_HEADERFOOTERCONTEXT #include "oox/ppt/headerfooter.hxx" -#include "oox/core/contexthandler.hxx" +#include "oox/core/fragmenthandler2.hxx" namespace oox { namespace ppt { /** CT_HeaderFooter */ - class HeaderFooterContext : public ::oox::core::ContextHandler + class HeaderFooterContext : public ::oox::core::FragmentHandler2 { public: - HeaderFooterContext( ::oox::core::ContextHandler& rParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, HeaderFooter& rHeaderFooter ); + HeaderFooterContext( ::oox::core::FragmentHandler2& rParent, + const AttributeList& rAttribs, HeaderFooter& rHeaderFooter ); ~HeaderFooterContext( ); }; diff --git a/oox/source/ppt/layoutfragmenthandler.cxx b/oox/source/ppt/layoutfragmenthandler.cxx index 19a9e6ead026..6697f8190db2 100644 --- a/oox/source/ppt/layoutfragmenthandler.cxx +++ b/oox/source/ppt/layoutfragmenthandler.cxx @@ -60,27 +60,20 @@ LayoutFragmentHandler::~LayoutFragmentHandler() } -Reference< XFastContextHandler > LayoutFragmentHandler::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) - throw (SAXException, RuntimeException) +ContextHandlerRef LayoutFragmentHandler::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet = getFastContextHandler(); switch( aElementToken ) { case PPT_TOKEN( sldLayout ): // CT_SlideLayout - mpSlidePersistPtr->setLayoutValueToken( xAttribs->getOptionalValueToken( XML_type, 0 ) ); // CT_SlideLayoutType + mpSlidePersistPtr->setLayoutValueToken( rAttribs.getToken( XML_type, 0 ) ); // CT_SlideLayoutType break; case PPT_TOKEN( hf ): // CT_HeaderFooter - xRet.set( new HeaderFooterContext( *this, xAttribs, mpSlidePersistPtr->getHeaderFooter() ) ); + return new HeaderFooterContext( *this, rAttribs, mpSlidePersistPtr->getHeaderFooter() ); break; default: - xRet.set( SlideFragmentHandler::createFastChildContext( aElementToken, xAttribs ) ); + return SlideFragmentHandler::onCreateContext( aElementToken, rAttribs ); } - return xRet; -} - -void SAL_CALL LayoutFragmentHandler::endDocument() - throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) -{ + return this; } } } diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index 31a2781d845b..e9fe6994472e 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -61,7 +61,7 @@ using namespace ::com::sun::star::xml::sax; namespace oox { namespace ppt { PresentationFragmentHandler::PresentationFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath ) throw() -: FragmentHandler( rFilter, rFragmentPath ) +: FragmentHandler2( rFilter, rFragmentPath ) , mpTextListStyle( new TextListStyle ) { TextParagraphPropertiesVector& rParagraphDefaulsVector( mpTextListStyle->getListStyle() ); @@ -76,10 +76,6 @@ PresentationFragmentHandler::PresentationFragmentHandler( XmlFilterBase& rFilter PresentationFragmentHandler::~PresentationFragmentHandler() throw() { - -} -void PresentationFragmentHandler::startDocument() throw (SAXException, RuntimeException) -{ } void ResolveTextFields( XmlFilterBase& rFilter ) @@ -142,7 +138,7 @@ void ResolveTextFields( XmlFilterBase& rFilter ) } } -void PresentationFragmentHandler::endDocument() throw (SAXException, RuntimeException) +void PresentationFragmentHandler::finalizeImport() { // todo: localized progress bar text const Reference< task::XStatusIndicator >& rxStatusIndicator( getFilter().getStatusIndicator() ); @@ -300,41 +296,36 @@ void PresentationFragmentHandler::endDocument() throw (SAXException, RuntimeExce } // CT_Presentation -Reference< XFastContextHandler > PresentationFragmentHandler::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +::oox::core::ContextHandlerRef PresentationFragmentHandler::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; switch( aElementToken ) { case PPT_TOKEN( presentation ): case PPT_TOKEN( sldMasterIdLst ): case PPT_TOKEN( notesMasterIdLst ): case PPT_TOKEN( sldIdLst ): - break; + return this; case PPT_TOKEN( sldMasterId ): - maSlideMasterVector.push_back( xAttribs->getOptionalValue( R_TOKEN( id ) ) ); - break; + maSlideMasterVector.push_back( rAttribs.getString( R_TOKEN( id ), OUString() ) ); + return this; case PPT_TOKEN( sldId ): - maSlidesVector.push_back( xAttribs->getOptionalValue( R_TOKEN( id ) ) ); - break; + maSlidesVector.push_back( rAttribs.getString( R_TOKEN( id ), OUString() ) ); + return this; case PPT_TOKEN( notesMasterId ): - maNotesMasterVector.push_back( xAttribs->getOptionalValue(R_TOKEN( id ) ) ); - break; + maNotesMasterVector.push_back( rAttribs.getString( R_TOKEN( id ), OUString() ) ); + return this; case PPT_TOKEN( sldSz ): - maSlideSize = GetSize2D( xAttribs ); - break; + maSlideSize = GetSize2D( rAttribs.getFastAttributeList() ); + return this; case PPT_TOKEN( notesSz ): - maNotesSize = GetSize2D( xAttribs ); - break; + maNotesSize = GetSize2D( rAttribs.getFastAttributeList() ); + return this; case PPT_TOKEN( custShowLst ): - xRet.set( new CustomShowListContext( *this, maCustomShowList ) ); - break; + return new CustomShowListContext( *this, maCustomShowList ); case PPT_TOKEN( defaultTextStyle ): - xRet.set( new TextListStyleContext( *this, *mpTextListStyle ) ); - break; + return new TextListStyleContext( *this, *mpTextListStyle ); } - if ( !xRet.is() ) - xRet = getFastContextHandler(); - return xRet; + return this; } bool PresentationFragmentHandler::importSlide( const FragmentHandlerRef& rxSlideFragmentHandler, diff --git a/oox/source/ppt/slidefragmenthandler.cxx b/oox/source/ppt/slidefragmenthandler.cxx index 48a53a5f7e1f..4652690e7765 100644 --- a/oox/source/ppt/slidefragmenthandler.cxx +++ b/oox/source/ppt/slidefragmenthandler.cxx @@ -59,7 +59,7 @@ using namespace ::com::sun::star::container; namespace oox { namespace ppt { SlideFragmentHandler::SlideFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath, SlidePersistPtr pPersistPtr, const ShapeLocation eShapeLocation ) throw() -: FragmentHandler( rFilter, rFragmentPath ) +: FragmentHandler2( rFilter, rFragmentPath ) , mpSlidePersistPtr( pPersistPtr ) , meShapeLocation( eShapeLocation ) { @@ -75,109 +75,102 @@ SlideFragmentHandler::~SlideFragmentHandler() throw() mpSlidePersistPtr->getDrawing()->convertAndInsert(); } -Reference< XFastContextHandler > SlideFragmentHandler::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +::oox::core::ContextHandlerRef SlideFragmentHandler::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - AttributeList aAttribs( xAttribs ); - switch( aElementToken ) { case PPT_TOKEN( sldMaster ): // CT_SlideMaster case PPT_TOKEN( handoutMaster ): // CT_HandoutMaster case PPT_TOKEN( sld ): // CT_CommonSlideData { - AttributeList attribs( xAttribs ); - Reference< XDrawPage > xSlide( mpSlidePersistPtr->getPage() ); PropertyMap aPropMap; PropertySet aSlideProp( xSlide ); - aPropMap[ PROP_Visible ] = Any( attribs.getBool( XML_show, sal_True ) ); + aPropMap[ PROP_Visible ] = Any( rAttribs.getBool( XML_show, sal_True ) ); aSlideProp.setProperties( aPropMap ); - break; + return this; } case PPT_TOKEN( notes ): // CT_NotesSlide case PPT_TOKEN( notesMaster ): // CT_NotesMaster - break; + return this; case PPT_TOKEN( cSld ): // CT_CommonSlideData - maSlideName = xAttribs->getOptionalValue(XML_name); - break; + maSlideName = rAttribs.getString(XML_name, OUString()); + return this; case PPT_TOKEN( spTree ): // CT_GroupShape { - xRet.set( new PPTShapeGroupContext( + // TODO Convert this to FragmentHandler2 + return new PPTShapeGroupContext( *this, mpSlidePersistPtr, meShapeLocation, mpSlidePersistPtr->getShapes(), - oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GroupShape" ) ) ) ); + oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GroupShape" ) ) ); } break; case PPT_TOKEN( controls ): - xRet = getFastContextHandler(); - break; + return this; case PPT_TOKEN( control ): { ::oox::vml::ControlInfo aInfo; - aInfo.setShapeId( aAttribs.getInteger( XML_spid, 0 ) ); - aInfo.maFragmentPath = getFragmentPathFromRelId( aAttribs.getString( R_TOKEN( id ), OUString() ) ); - aInfo.maName = aAttribs.getXString( XML_name, OUString() ); + aInfo.setShapeId( rAttribs.getInteger( XML_spid, 0 ) ); + aInfo.maFragmentPath = getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ); + aInfo.maName = rAttribs.getXString( XML_name, OUString() ); mpSlidePersistPtr->getDrawing()->registerControl( aInfo ); } - return xRet; + return this; case PPT_TOKEN( timing ): // CT_SlideTiming - xRet.set( new SlideTimingContext( *this, mpSlidePersistPtr->getTimeNodeList() ) ); - break; + return new SlideTimingContext( *this, mpSlidePersistPtr->getTimeNodeList() ); case PPT_TOKEN( transition ): // CT_SlideTransition - xRet.set( new SlideTransitionContext( *this, xAttribs, maSlideProperties ) ); - break; + return new SlideTransitionContext( *this, rAttribs, maSlideProperties ); case PPT_TOKEN( hf ): - xRet.set( new HeaderFooterContext( *this, xAttribs, mpSlidePersistPtr->getHeaderFooter() ) ); - break; + return new HeaderFooterContext( *this, rAttribs, mpSlidePersistPtr->getHeaderFooter() ); // BackgroundGroup + case PPT_TOKEN( bg ): + return this; case PPT_TOKEN( bgPr ): // CT_BackgroundProperties { FillPropertiesPtr pFillPropertiesPtr( new FillProperties ); - xRet.set( new BackgroundPropertiesContext( *this, *pFillPropertiesPtr ) ); mpSlidePersistPtr->setBackgroundProperties( pFillPropertiesPtr ); + return new BackgroundPropertiesContext( *this, *pFillPropertiesPtr ); } break; case PPT_TOKEN( bgRef ): // a:CT_StyleMatrixReference { FillPropertiesPtr pFillPropertiesPtr( new FillProperties( - *mpSlidePersistPtr->getTheme()->getFillStyle( xAttribs->getOptionalValue( XML_idx ).toInt32() ) ) ); - xRet.set( new ColorContext( *this, mpSlidePersistPtr->getBackgroundColor() ) ); + *mpSlidePersistPtr->getTheme()->getFillStyle( rAttribs.getInteger( XML_idx, -1 ) ) ) ); + ContextHandlerRef ret = new ColorContext( *this, mpSlidePersistPtr->getBackgroundColor() ); mpSlidePersistPtr->setBackgroundProperties( pFillPropertiesPtr ); + return ret; } break; case PPT_TOKEN( clrMap ): // CT_ColorMapping { oox::drawingml::ClrMapPtr pClrMapPtr( new oox::drawingml::ClrMap() ); - xRet.set( new oox::drawingml::clrMapContext( *this, xAttribs, *pClrMapPtr ) ); + ContextHandlerRef ret = new oox::drawingml::clrMapContext( *this, rAttribs.getFastAttributeList(), *pClrMapPtr ); mpSlidePersistPtr->setClrMap( pClrMapPtr ); + return ret; } break; case PPT_TOKEN( clrMapOvr ): // CT_ColorMappingOverride case PPT_TOKEN( sldLayoutIdLst ): // CT_SlideLayoutIdList - break; + return this; case PPT_TOKEN( txStyles ): // CT_SlideMasterTextStyles - xRet.set( new SlideMasterTextStylesContext( *this, mpSlidePersistPtr ) ); + return new SlideMasterTextStylesContext( *this, mpSlidePersistPtr ); break; case PPT_TOKEN( custDataLst ): // CT_CustomerDataList case PPT_TOKEN( tagLst ): // CT_TagList - break; + return this; } - if( !xRet.is() ) - xRet = getFastContextHandler(); - - return xRet; + return this; } -void SAL_CALL SlideFragmentHandler::endDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +void SlideFragmentHandler::finalizeImport() { try { diff --git a/oox/source/ppt/slidemastertextstylescontext.cxx b/oox/source/ppt/slidemastertextstylescontext.cxx index 08b7aaf4af7c..2d1e59c0382d 100644 --- a/oox/source/ppt/slidemastertextstylescontext.cxx +++ b/oox/source/ppt/slidemastertextstylescontext.cxx @@ -37,8 +37,8 @@ using namespace ::com::sun::star::xml::sax; namespace oox { namespace ppt { -SlideMasterTextStylesContext::SlideMasterTextStylesContext( ContextHandler& rParent, SlidePersistPtr pSlidePersistPtr ) -: ContextHandler( rParent ) +SlideMasterTextStylesContext::SlideMasterTextStylesContext( FragmentHandler2& rParent, SlidePersistPtr pSlidePersistPtr ) +: FragmentHandler2( rParent ) , mpSlidePersistPtr( pSlidePersistPtr ) { } @@ -47,10 +47,9 @@ SlideMasterTextStylesContext::~SlideMasterTextStylesContext() { } -Reference< XFastContextHandler > SlideMasterTextStylesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& /* xAttribs */ ) throw (SAXException, RuntimeException) +::oox::core::ContextHandlerRef SlideMasterTextStylesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& /*rAttribs*/ ) { oox::drawingml::TextListStylePtr aTextListStylePtr; - Reference< XFastContextHandler > xRet; switch( aElementToken ) { case PPT_TOKEN( titleStyle ): @@ -78,12 +77,10 @@ Reference< XFastContextHandler > SlideMasterTextStylesContext::createFastChildCo { // are obtained. i got some documents without having the textsize set at for ( int i = 0; i < 9; i++ ) // any point, the master reference application is using 18pt then aTextListStylePtr->getListStyle()[ i ]->getTextCharacterProperties().moHeight = 1800; - xRet.set( new oox::drawingml::TextListStyleContext( *this, *aTextListStylePtr ) ); + return new oox::drawingml::TextListStyleContext( *this, *aTextListStylePtr ); } - if( !xRet.is() ) - xRet.set( this ); - return xRet; + return this; } } } diff --git a/oox/source/ppt/slidetimingcontext.cxx b/oox/source/ppt/slidetimingcontext.cxx index 6c4fcf76a9d2..31738a580e57 100644 --- a/oox/source/ppt/slidetimingcontext.cxx +++ b/oox/source/ppt/slidetimingcontext.cxx @@ -49,8 +49,8 @@ using namespace ::com::sun::star::container; namespace oox { namespace ppt { -SlideTimingContext::SlideTimingContext( ContextHandler& rParent, TimeNodePtrList & aTimeNodeList ) throw() - : ContextHandler( rParent ) +SlideTimingContext::SlideTimingContext( FragmentHandler2& rParent, TimeNodePtrList & aTimeNodeList ) throw() + : FragmentHandler2( rParent ) , maTimeNodeList( aTimeNodeList ) { } @@ -60,42 +60,26 @@ SlideTimingContext::~SlideTimingContext() throw() } -void SlideTimingContext::endFastElement( sal_Int32 /*aElement*/ ) throw ( SAXException, RuntimeException) +::oox::core::ContextHandlerRef SlideTimingContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { -} - - -Reference< XFastContextHandler > SlideTimingContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) -{ - Reference< XFastContextHandler > xRet; - switch( aElementToken ) { case PPT_TOKEN( bldLst ): - xRet.set( new BuildListContext( *this, xAttribs, maTimeNodeList ) ); - break; + return new BuildListContext( *this, rAttribs.getFastAttributeList(), maTimeNodeList ); case PPT_TOKEN( extLst ): - return xRet; + return this; case PPT_TOKEN( tnLst ): // timing nodes { - xRet.set( new TimeNodeListContext( *this, maTimeNodeList ) ); + return new TimeNodeListContext( *this, maTimeNodeList ); } break; default: - break; + return this; } - if( !xRet.is() ) - xRet.set(this); - - return xRet; -} - -void SAL_CALL SlideTimingContext::endDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) -{ - + return this; } } } diff --git a/oox/source/ppt/slidetransitioncontext.cxx b/oox/source/ppt/slidetransitioncontext.cxx index c7f61912f44e..c74e0d89a2a7 100644 --- a/oox/source/ppt/slidetransitioncontext.cxx +++ b/oox/source/ppt/slidetransitioncontext.cxx @@ -51,23 +51,21 @@ using namespace ::com::sun::star::container; namespace oox { namespace ppt { -SlideTransitionContext::SlideTransitionContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, PropertyMap & aProperties ) throw() -: ContextHandler( rParent ) +SlideTransitionContext::SlideTransitionContext( FragmentHandler2& rParent, const AttributeList& rAttribs, PropertyMap & aProperties ) throw() +: FragmentHandler2( rParent ) , maSlideProperties( aProperties ) , mbHasTransition( sal_False ) { - AttributeList attribs(xAttribs); - // ST_TransitionSpeed - maTransition.setOoxTransitionSpeed( xAttribs->getOptionalValueToken( XML_spd, XML_fast ) ); + maTransition.setOoxTransitionSpeed( rAttribs.getToken( XML_spd, XML_fast ) ); // TODO - attribs.getBool( XML_advClick, true ); + rAttribs.getBool( XML_advClick, true ); // careful. if missing, no auto advance... 0 looks like a valid value // for auto advance - if(attribs.hasAttribute( XML_advTm )) - maTransition.setOoxAdvanceTime( attribs.getInteger( XML_advTm, -1 ) ); + if(rAttribs.hasAttribute( XML_advTm )) + maTransition.setOoxAdvanceTime( rAttribs.getInteger( XML_advTm, -1 ) ); } SlideTransitionContext::~SlideTransitionContext() throw() @@ -75,10 +73,8 @@ SlideTransitionContext::~SlideTransitionContext() throw() } -Reference< XFastContextHandler > SlideTransitionContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +::oox::core::ContextHandlerRef SlideTransitionContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( aElementToken ) { case PPT_TOKEN( blinds ): @@ -88,67 +84,65 @@ Reference< XFastContextHandler > SlideTransitionContext::createFastChildContext( if (!mbHasTransition) { mbHasTransition = true; - maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_horz ), 0); + maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_horz ), 0); // ST_Direction { XML_horz, XML_vert } } - break; + return this; case PPT_TOKEN( cover ): case PPT_TOKEN( pull ): if (!mbHasTransition) { mbHasTransition = true; - maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_l ), 0 ); + maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_l ), 0 ); // ST_TransitionEightDirectionType { ST_TransitionSideDirectionType { // XML_d, XML_d, XML_r, XML_u }, // ST_TransitionCornerDirectionType { // XML_ld, XML_lu, XML_rd, XML_ru } } - break; + return this; case PPT_TOKEN( cut ): case PPT_TOKEN( fade ): if (!mbHasTransition) { mbHasTransition = true; - AttributeList attribs(xAttribs); // CT_OptionalBlackTransition xdb:bool - maTransition.setOoxTransitionType( aElementToken, attribs.getBool( XML_thruBlk, false ), 0); + maTransition.setOoxTransitionType( aElementToken, rAttribs.getBool( XML_thruBlk, false ), 0); } - break; + return this; case PPT_TOKEN( push ): case PPT_TOKEN( wipe ): if (!mbHasTransition) { mbHasTransition = true; - maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_l ), 0 ); + maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_l ), 0 ); // ST_TransitionSideDirectionType { XML_d, XML_l, XML_r, XML_u } } - break; + return this; case PPT_TOKEN( split ): if (!mbHasTransition) { mbHasTransition = true; - maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_orient, XML_horz ), xAttribs->getOptionalValueToken( XML_dir, XML_out ) ); + maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_orient, XML_horz ), rAttribs.getToken( XML_dir, XML_out ) ); // ST_Direction { XML_horz, XML_vert } // ST_TransitionInOutDirectionType { XML_out, XML_in } } - break; + return this; case PPT_TOKEN( zoom ): if (!mbHasTransition) { mbHasTransition = true; - maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_out ), 0 ); + maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_out ), 0 ); // ST_TransitionInOutDirectionType { XML_out, XML_in } } - break; + return this; case PPT_TOKEN( wheel ): if (!mbHasTransition) { mbHasTransition = true; - AttributeList attribs(xAttribs); - maTransition.setOoxTransitionType( aElementToken, attribs.getUnsigned( XML_spokes, 4 ), 0 ); + maTransition.setOoxTransitionType( aElementToken, rAttribs.getUnsigned( XML_spokes, 4 ), 0 ); // unsignedInt } - break; + return this; case PPT_TOKEN( circle ): case PPT_TOKEN( diamond ): case PPT_TOKEN( dissolve ): @@ -162,28 +156,23 @@ Reference< XFastContextHandler > SlideTransitionContext::createFastChildContext( mbHasTransition = true; maTransition.setOoxTransitionType( aElementToken, 0, 0 ); } - break; - + return this; case PPT_TOKEN( sndAc ): // CT_TransitionSoundAction //"Sound" - xRet.set( new SoundActionContext ( *this, maSlideProperties ) ); - break; + return new SoundActionContext ( *this, maSlideProperties ); case PPT_TOKEN( extLst ): // CT_OfficeArtExtensionList - return xRet; + return this; default: break; } - if( !xRet.is() ) - xRet.set(this); - - return xRet; + return this; } -void SlideTransitionContext::endFastElement( sal_Int32 aElement ) throw (::com::sun::star::xml::sax::SAXException, RuntimeException) +void SlideTransitionContext::onEndElement() { - if( aElement == (PPT_TOKEN( transition )) ) + if( isCurrentElement(PPT_TOKEN( transition )) ) { if( mbHasTransition ) { diff --git a/oox/source/ppt/soundactioncontext.cxx b/oox/source/ppt/soundactioncontext.cxx index 64a24963ab66..7b510beda983 100644 --- a/oox/source/ppt/soundactioncontext.cxx +++ b/oox/source/ppt/soundactioncontext.cxx @@ -44,8 +44,8 @@ using namespace ::com::sun::star::uno; namespace oox { namespace ppt { - SoundActionContext::SoundActionContext( ContextHandler& rParent, PropertyMap & aProperties ) throw() - : ContextHandler( rParent ) + SoundActionContext::SoundActionContext( FragmentHandler2& rParent, PropertyMap & aProperties ) throw() + : FragmentHandler2( rParent ) , maSlideProperties( aProperties ) , mbHasStartSound( false ) , mbLoopSound( false ) @@ -59,9 +59,9 @@ namespace oox { namespace ppt { } - void SoundActionContext::endFastElement( sal_Int32 aElement ) throw (SAXException, RuntimeException) + void SoundActionContext::onEndElement() { - if ( aElement == PPT_TOKEN( sndAc ) ) + if ( isCurrentElement( PPT_TOKEN( sndAc ) ) ) { if( mbHasStartSound ) { @@ -97,37 +97,32 @@ namespace oox { namespace ppt { } - Reference< XFastContextHandler > SoundActionContext::createFastChildContext( ::sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) + ::oox::core::ContextHandlerRef SoundActionContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - AttributeList attribs(xAttribs); - - switch( aElement ) + switch( aElementToken ) { case PPT_TOKEN( snd ): if( mbHasStartSound ) { drawingml::EmbeddedWAVAudioFile aAudio; - drawingml::getEmbeddedWAVAudioFile( getRelations(), xAttribs, aAudio); + drawingml::getEmbeddedWAVAudioFile( getRelations(), rAttribs.getFastAttributeList(), aAudio); msSndName = ( aAudio.mbBuiltIn ? aAudio.msName : aAudio.msEmbed ); } - break; + return this; case PPT_TOKEN( endSnd ): // CT_Empty mbStopSound = true; - break; + return this; case PPT_TOKEN( stSnd ): mbHasStartSound = true; - mbLoopSound = attribs.getBool( XML_loop, false ); + mbLoopSound = rAttribs.getBool( XML_loop, false ); + return this; default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } diff --git a/oox/source/ppt/timeanimvaluecontext.cxx b/oox/source/ppt/timeanimvaluecontext.cxx index fd247de41a86..8feb1e623d28 100644 --- a/oox/source/ppt/timeanimvaluecontext.cxx +++ b/oox/source/ppt/timeanimvaluecontext.cxx @@ -36,10 +36,10 @@ using namespace ::com::sun::star::xml::sax; namespace oox { namespace ppt { - TimeAnimValueListContext::TimeAnimValueListContext( ContextHandler& rParent, + TimeAnimValueListContext::TimeAnimValueListContext( FragmentHandler2& rParent, const Reference< XFastAttributeList >& /*xAttribs*/, TimeAnimationValueList & aTavList ) - : ContextHandler( rParent ) + : FragmentHandler2( rParent ) , maTavList( aTavList ) , mbInValue( false ) { @@ -51,21 +51,17 @@ namespace oox { namespace ppt { } - void SAL_CALL TimeAnimValueListContext::endFastElement( sal_Int32 aElement ) - throw ( SAXException, RuntimeException) + void TimeAnimValueListContext::onEndElement() { - if( aElement == PPT_TOKEN( tav ) ) + if( isCurrentElement( PPT_TOKEN( tav ) ) ) { mbInValue = false; } } - Reference< XFastContextHandler > SAL_CALL TimeAnimValueListContext::createFastChildContext( ::sal_Int32 aElementToken, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) + ::oox::core::ContextHandlerRef TimeAnimValueListContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; switch ( aElementToken ) { @@ -73,26 +69,23 @@ namespace oox { namespace ppt { { mbInValue = true; TimeAnimationValue val; - val.msFormula = xAttribs->getOptionalValue( XML_fmla ); - val.msTime = xAttribs->getOptionalValue( XML_tm ); + val.msFormula = rAttribs.getString( XML_fmla, rtl::OUString() ); + val.msTime = rAttribs.getString( XML_tm, rtl::OUString() ); maTavList.push_back( val ); - break; + return this; } case PPT_TOKEN( val ): if( mbInValue ) { // CT_TLAnimVariant - xRet.set( new AnimVariantContext( *this, aElementToken, maTavList.back().maValue ) ); + return new AnimVariantContext( *this, aElementToken, maTavList.back().maValue ); } break; default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } diff --git a/oox/source/ppt/timeanimvaluecontext.hxx b/oox/source/ppt/timeanimvaluecontext.hxx index 10041e2ac413..173e9c19bf5b 100644 --- a/oox/source/ppt/timeanimvaluecontext.hxx +++ b/oox/source/ppt/timeanimvaluecontext.hxx @@ -31,26 +31,25 @@ #ifndef OOX_PPT_TIMEANIMVALUELISTCONTEXT #define OOX_PPT_TIMEANIMVALUELISTCONTEXT -#include "oox/core/contexthandler.hxx" +#include "oox/core/fragmenthandler2.hxx" #include "oox/ppt/animationspersist.hxx" namespace oox { namespace ppt { /** CT_TLTimeAnimateValueList */ class TimeAnimValueListContext - : public ::oox::core::ContextHandler + : public ::oox::core::FragmentHandler2 { public: - TimeAnimValueListContext( ::oox::core::ContextHandler& rParent, + TimeAnimValueListContext( ::oox::core::FragmentHandler2& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, TimeAnimationValueList & aTavList ); ~TimeAnimValueListContext( ); - virtual void SAL_CALL endFastElement( sal_Int32 aElement ) 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 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual void onEndElement(); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); private: TimeAnimationValueList & maTavList; diff --git a/oox/source/ppt/timenodelistcontext.cxx b/oox/source/ppt/timenodelistcontext.cxx index 9aa72213dfe6..ab250d98d10f 100644 --- a/oox/source/ppt/timenodelistcontext.cxx +++ b/oox/source/ppt/timenodelistcontext.cxx @@ -117,7 +117,7 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - MediaNodeContext( ContextHandler& rParent, sal_Int32 aElement, + MediaNodeContext( FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) : TimeNodeContext( rParent, aElement, xAttribs, pNode ) @@ -139,9 +139,9 @@ namespace oox { namespace ppt { } } - virtual void SAL_CALL endFastElement( sal_Int32 aElement ) - throw ( SAXException, RuntimeException) + virtual void onEndElement() { + sal_Int32 aElement = getCurrentElement(); if( aElement == PPT_TOKEN( audio ) ) { // TODO deal with mbIsNarration @@ -152,25 +152,18 @@ namespace oox { namespace ppt { } } - virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch ( aElementToken ) { case PPT_TOKEN( cBhvr ): - xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); + return new CommonBehaviorContext ( *this, rAttribs.getFastAttributeList(), mpNode ); break; default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } private: @@ -185,7 +178,7 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - SetTimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, + SetTimeNodeContext( FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) : TimeNodeContext( rParent, aElement, xAttribs, pNode ) @@ -212,35 +205,20 @@ namespace oox { namespace ppt { } - virtual void SAL_CALL endFastElement( sal_Int32 /*aElement*/ ) - throw ( SAXException, RuntimeException) + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - } - - - virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) - { - Reference< XFastContextHandler > xRet; - switch ( aElementToken ) { case PPT_TOKEN( cBhvr ): - xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); - break; + return new CommonBehaviorContext ( *this, rAttribs.getFastAttributeList(), mpNode ); case PPT_TOKEN( to ): // CT_TLAnimVariant - xRet.set( new AnimVariantContext( *this, aElementToken, maTo ) ); - break; + return new AnimVariantContext( *this, aElementToken, maTo ); default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } private: Any maTo; @@ -252,7 +230,7 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - CmdTimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, + CmdTimeNodeContext( FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) : TimeNodeContext( rParent, aElement, xAttribs, pNode ) @@ -273,10 +251,9 @@ namespace oox { namespace ppt { { } - virtual void SAL_CALL endFastElement( sal_Int32 aElement ) - throw ( SAXException, RuntimeException) + virtual void onEndElement() { - if( aElement == PPT_TOKEN( cmd ) ) + if( isCurrentElement( PPT_TOKEN( cmd ) ) ) { try { // see sd/source/filter/ppt/pptinanimations.cxx @@ -347,25 +324,17 @@ namespace oox { namespace ppt { } - virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch ( aElementToken ) { case PPT_TOKEN( cBhvr ): - xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); - break; + return new CommonBehaviorContext ( *this, rAttribs.getFastAttributeList(), mpNode ); default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } private: @@ -380,7 +349,7 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - SequenceTimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, + SequenceTimeNodeContext( FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) : TimeNodeContext( rParent, aElement, xAttribs, pNode ) @@ -400,33 +369,23 @@ namespace oox { namespace ppt { } - virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch ( aElementToken ) { case PPT_TOKEN( cTn ): - xRet.set( new CommonTimeNodeContext( *this, aElementToken, xAttribs, mpNode ) ); - break; + return new CommonTimeNodeContext( *this, aElementToken, rAttribs.getFastAttributeList(), mpNode ); case PPT_TOKEN( nextCondLst ): - xRet.set( new CondListContext( *this, aElementToken, xAttribs, mpNode, - mpNode->getNextCondition() ) ); - break; + return new CondListContext( *this, aElementToken, rAttribs.getFastAttributeList(), mpNode, + mpNode->getNextCondition() ); case PPT_TOKEN( prevCondLst ): - xRet.set( new CondListContext( *this, aElementToken, xAttribs, mpNode, - mpNode->getPrevCondition() ) ); - break; + return new CondListContext( *this, aElementToken, rAttribs.getFastAttributeList(), mpNode, + mpNode->getPrevCondition() ); default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } private: bool mbConcurrent; @@ -441,32 +400,24 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - ParallelExclTimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, + ParallelExclTimeNodeContext( FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) : TimeNodeContext( rParent, aElement, xAttribs, pNode ) { } - virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch ( aElementToken ) { case PPT_TOKEN( cTn ): - xRet.set( new CommonTimeNodeContext( *this, aElementToken, xAttribs, mpNode ) ); - break; + return new CommonTimeNodeContext( *this, aElementToken, rAttribs.getFastAttributeList(), mpNode ); default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } protected: @@ -479,7 +430,7 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - AnimColorContext( ContextHandler& rParent, sal_Int32 aElement, + AnimColorContext( FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) throw() : TimeNodeContext( rParent, aElement, xAttribs, pNode ) @@ -495,10 +446,10 @@ namespace oox { namespace ppt { { } - virtual void SAL_CALL endFastElement( sal_Int32 aElement ) throw ( SAXException, RuntimeException) + virtual void onEndElement() { //xParentNode - if( aElement == mnElement ) + if( isCurrentElement( mnElement ) ) { NodePropertyMap & pProps(mpNode->getNodeProperties()); pProps[ NP_DIRECTION ] = makeAny( mnDir == XML_cw ); @@ -514,10 +465,8 @@ namespace oox { namespace ppt { } - virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch ( aElementToken ) { case PPT_TOKEN( hsl ): @@ -526,12 +475,11 @@ namespace oox { namespace ppt { if( mbHasByColor ) { m_byColor.colorSpace = AnimationColorSpace::HSL; - m_byColor.one = xAttribs->getOptionalValue( XML_h ).toInt32( ); - m_byColor.two = xAttribs->getOptionalValue( XML_s ).toInt32( ); - m_byColor.three = xAttribs->getOptionalValue( XML_l ).toInt32( ); + m_byColor.one = rAttribs.getInteger( XML_h, 0 ); + m_byColor.two = rAttribs.getInteger( XML_s, 0 ); + m_byColor.three = rAttribs.getInteger( XML_l, 0 ); } - xRet.set(this); - break; + return this; } case PPT_TOKEN( rgb ): { @@ -539,38 +487,30 @@ namespace oox { namespace ppt { { // CT_TLByRgbColorTransform m_byColor.colorSpace = AnimationColorSpace::RGB; - m_byColor.one = xAttribs->getOptionalValue( XML_r ).toInt32(); - m_byColor.two = xAttribs->getOptionalValue( XML_g ).toInt32(); - m_byColor.three = xAttribs->getOptionalValue( XML_b ).toInt32(); + m_byColor.one = rAttribs.getInteger( XML_r, 0 ); + m_byColor.two = rAttribs.getInteger( XML_g, 0 ); + m_byColor.three = rAttribs.getInteger( XML_b, 0 ); } - xRet.set(this); - break; + return this; } case PPT_TOKEN( by ): // CT_TLByAnimateColorTransform mbHasByColor = true; - xRet.set(this); - break; + return this; case PPT_TOKEN( cBhvr ): - xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); - break; + return new CommonBehaviorContext ( *this, rAttribs.getFastAttributeList(), mpNode ); case PPT_TOKEN( to ): // CT_Color - xRet.set( new ColorContext( *this, maToClr ) ); - break; + return new ColorContext( *this, maToClr ); case PPT_TOKEN( from ): // CT_Color - xRet.set( new ColorContext( *this, maFromClr ) ); - break; + return new ColorContext( *this, maFromClr ); default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } @@ -589,7 +529,7 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - AnimContext( ContextHandler& rParent, sal_Int32 aElement, + AnimContext( FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) throw() : TimeNodeContext( rParent, aElement, xAttribs, pNode ) @@ -671,26 +611,21 @@ namespace oox { namespace ppt { } - virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch ( aElementToken ) { case PPT_TOKEN( cBhvr ): - xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); + return new CommonBehaviorContext ( *this, rAttribs.getFastAttributeList(), mpNode ); break; case PPT_TOKEN( tavLst ): - xRet.set( new TimeAnimValueListContext ( *this, xAttribs, maTavList ) ); + return new TimeAnimValueListContext ( *this, rAttribs.getFastAttributeList(), maTavList ); break; default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } private: sal_Int32 mnValueType; @@ -703,7 +638,7 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - AnimScaleContext( ContextHandler& rParent, sal_Int32 aElement, + AnimScaleContext( FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) throw() : TimeNodeContext( rParent, aElement, xAttribs, pNode ) @@ -720,9 +655,9 @@ namespace oox { namespace ppt { { } - virtual void SAL_CALL endFastElement( sal_Int32 aElement ) throw ( SAXException, RuntimeException) + virtual void onEndElement() { - if( aElement == mnElement ) + if( isCurrentElement( mnElement ) ) { if( maTo.hasValue() ) { @@ -739,49 +674,41 @@ namespace oox { namespace ppt { } } - virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch ( aElementToken ) { case PPT_TOKEN( cBhvr ): - xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); - break; + return new CommonBehaviorContext ( *this, rAttribs.getFastAttributeList(), mpNode ); case PPT_TOKEN( to ): { // CT_TLPoint - Point p = GetPointPercent( xAttribs ); + Point p = GetPointPercent( rAttribs.getFastAttributeList() ); maTo <<= p.X; maTo <<= p.Y; - break; + return this; } case PPT_TOKEN( from ): { // CT_TLPoint - Point p = GetPointPercent( xAttribs ); + Point p = GetPointPercent( rAttribs.getFastAttributeList() ); maFrom <<= p.X; maFrom <<= p.Y; - break; + return this; } case PPT_TOKEN( by ): { // CT_TLPoint - Point p = GetPointPercent( xAttribs ); + Point p = GetPointPercent( rAttribs.getFastAttributeList() ); maBy <<= p.X; maBy <<= p.Y; - break; + return this; } default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } private: Any maBy; @@ -796,7 +723,7 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - AnimRotContext( ContextHandler& rParent, sal_Int32 aElement, + AnimRotContext( FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) throw() : TimeNodeContext( rParent, aElement, xAttribs, pNode ) @@ -827,23 +754,17 @@ namespace oox { namespace ppt { { } - virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch ( aElementToken ) { case PPT_TOKEN( cBhvr ): - xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); - break; + return new CommonBehaviorContext ( *this, rAttribs.getFastAttributeList(), mpNode ); default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } }; @@ -854,7 +775,7 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - AnimMotionContext( ContextHandler& rParent, sal_Int32 aElement, + AnimMotionContext( FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) throw() : TimeNodeContext( rParent, aElement, xAttribs, pNode ) @@ -893,63 +814,55 @@ namespace oox { namespace ppt { } - virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch ( aElementToken ) { case PPT_TOKEN( cBhvr ): - xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); - break; + return new CommonBehaviorContext ( *this, rAttribs.getFastAttributeList(), mpNode ); case PPT_TOKEN( to ): { // CT_TLPoint - Point p = GetPointPercent( xAttribs ); + Point p = GetPointPercent( rAttribs.getFastAttributeList() ); Any rAny; rAny <<= p.X; rAny <<= p.Y; mpNode->setTo( rAny ); - break; + return this; } case PPT_TOKEN( from ): { // CT_TLPoint - Point p = GetPointPercent( xAttribs ); + Point p = GetPointPercent( rAttribs.getFastAttributeList() ); Any rAny; rAny <<= p.X; rAny <<= p.Y; mpNode->setFrom( rAny ); - break; + return this; } case PPT_TOKEN( by ): { // CT_TLPoint - Point p = GetPointPercent( xAttribs ); + Point p = GetPointPercent( rAttribs.getFastAttributeList() ); Any rAny; rAny <<= p.X; rAny <<= p.Y; mpNode->setBy( rAny ); - break; + return this; } case PPT_TOKEN( rCtr ): { // CT_TLPoint - Point p = GetPointPercent( xAttribs ); + Point p = GetPointPercent( rAttribs.getFastAttributeList() ); // TODO push (void)p; - break; + return this; } default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } private: OUString msPtsTypes; @@ -963,7 +876,7 @@ namespace oox { namespace ppt { : public TimeNodeContext { public: - AnimEffectContext( ContextHandler& rParent, sal_Int32 aElement, + AnimEffectContext( FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) throw() : TimeNodeContext( rParent, aElement, xAttribs, pNode ) @@ -987,27 +900,20 @@ namespace oox { namespace ppt { } - virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch ( aElementToken ) { case PPT_TOKEN( cBhvr ): - xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); - break; + return new CommonBehaviorContext ( *this, rAttribs.getFastAttributeList(), mpNode ); case PPT_TOKEN( progress ): - xRet.set( new AnimVariantContext( *this, aElementToken, maProgress ) ); + return new AnimVariantContext( *this, aElementToken, maProgress ); // TODO handle it. - break; default: break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } private: Any maProgress; @@ -1018,7 +924,7 @@ namespace oox { namespace ppt { TimeNodeContext * TimeNodeContext::makeContext( - ContextHandler& rParent, sal_Int32 aElement, + FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const TimeNodePtr & pNode ) { @@ -1069,10 +975,10 @@ namespace oox { namespace ppt { } - TimeNodeContext::TimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, + TimeNodeContext::TimeNodeContext( FragmentHandler2& rParent, sal_Int32 aElement, const Reference< XFastAttributeList >& /*xAttribs*/, const TimeNodePtr & pNode ) throw() - : ContextHandler( rParent ) + : FragmentHandler2( rParent ) , mnElement( aElement ) , mpNode( pNode ) { @@ -1085,9 +991,9 @@ namespace oox { namespace ppt { } - TimeNodeListContext::TimeNodeListContext( ContextHandler& rParent, TimeNodePtrList & aList ) + TimeNodeListContext::TimeNodeListContext( FragmentHandler2& rParent, TimeNodePtrList & aList ) throw() - : ContextHandler( rParent ) + : FragmentHandler2( rParent ) , maList( aList ) { } @@ -1098,10 +1004,8 @@ namespace oox { namespace ppt { } - Reference< XFastContextHandler > SAL_CALL TimeNodeListContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) + ::oox::core::ContextHandlerRef TimeNodeListContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - sal_Int16 nNodeType; switch( aElementToken ) @@ -1155,10 +1059,9 @@ namespace oox { namespace ppt { TimeNodePtr pNode(new TimeNode(nNodeType)); maList.push_back( pNode ); - ContextHandler * pContext = TimeNodeContext::makeContext( *this, aElementToken, xAttribs, pNode ); - xRet.set( pContext ? pContext : this ); + FragmentHandler2 * pContext = TimeNodeContext::makeContext( *this, aElementToken, rAttribs.getFastAttributeList(), pNode ); - return xRet; + return pContext ? pContext : this; } diff --git a/oox/source/ppt/timetargetelementcontext.cxx b/oox/source/ppt/timetargetelementcontext.cxx index 2a0f61c0c4a3..93cbcf701625 100644 --- a/oox/source/ppt/timetargetelementcontext.cxx +++ b/oox/source/ppt/timetargetelementcontext.cxx @@ -49,55 +49,49 @@ namespace oox { namespace ppt { // CT_TLShapeTargetElement class ShapeTargetElementContext - : public ContextHandler + : public FragmentHandler2 { public: - ShapeTargetElementContext( ContextHandler& rParent, ShapeTargetElement & aValue ) - : ContextHandler( rParent ) + ShapeTargetElementContext( FragmentHandler2& rParent, ShapeTargetElement & aValue ) + : FragmentHandler2( rParent ) , bTargetSet(false) , maShapeTarget(aValue) { } - virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, - const Reference< XFastAttributeList >& xAttribs ) - throw ( SAXException, RuntimeException ) + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( aElementToken ) { case PPT_TOKEN( bg ): bTargetSet = true; maShapeTarget.mnType = XML_bg; - break; + return this; case PPT_TOKEN( txEl ): bTargetSet = true; maShapeTarget.mnType = XML_txEl; - break; + return this; case PPT_TOKEN( subSp ): bTargetSet = true; maShapeTarget.mnType = XML_subSp; - maShapeTarget.msSubShapeId = xAttribs->getOptionalValue( XML_spid ); - break; + maShapeTarget.msSubShapeId = rAttribs.getString( XML_spid, OUString() ); + return this; case PPT_TOKEN( graphicEl ): case PPT_TOKEN( oleChartEl ): bTargetSet = true; // TODO - break; + return this; case PPT_TOKEN( charRg ): case PPT_TOKEN( pRg ): if( bTargetSet && maShapeTarget.mnType == XML_txEl ) { maShapeTarget.mnRangeType = getBaseToken( aElementToken ); - maShapeTarget.maRange = drawingml::GetIndexRange( xAttribs ); + maShapeTarget.maRange = drawingml::GetIndexRange( rAttribs.getFastAttributeList() ); } - break; + return this; default: break; } - if( !xRet.is() ) - xRet.set( this ); - return xRet; + return this; } private: @@ -107,8 +101,8 @@ namespace oox { namespace ppt { - TimeTargetElementContext::TimeTargetElementContext( ContextHandler& rParent, const AnimTargetElementPtr & pValue ) - : ContextHandler( rParent ), + TimeTargetElementContext::TimeTargetElementContext( FragmentHandler2& rParent, const AnimTargetElementPtr & pValue ) + : FragmentHandler2( rParent ), mpTarget( pValue ) { OSL_ENSURE( mpTarget, "no valid target passed" ); @@ -119,34 +113,28 @@ namespace oox { namespace ppt { { } - void SAL_CALL TimeTargetElementContext::endFastElement( sal_Int32 /*aElement*/ ) throw ( SAXException, RuntimeException) - { - } - - Reference< XFastContextHandler > SAL_CALL TimeTargetElementContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + ::oox::core::ContextHandlerRef TimeTargetElementContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) { - Reference< XFastContextHandler > xRet; - switch( aElementToken ) { case PPT_TOKEN( inkTgt ): { mpTarget->mnType = XML_inkTgt; - OUString aId = xAttribs->getOptionalValue( XML_spid ); + OUString aId = rAttribs.getString( XML_spid, OUString() ); if( aId.getLength() ) { mpTarget->msValue = aId; } - break; + return this; } case PPT_TOKEN( sldTgt ): mpTarget->mnType = XML_sldTgt; - break; + return this; case PPT_TOKEN( sndTgt ): { mpTarget->mnType = XML_sndTgt; drawingml::EmbeddedWAVAudioFile aAudio; - drawingml::getEmbeddedWAVAudioFile( getRelations(), xAttribs, aAudio); + drawingml::getEmbeddedWAVAudioFile( getRelations(), rAttribs.getFastAttributeList(), aAudio); OUString sSndName = ( aAudio.mbBuiltIn ? aAudio.msName : aAudio.msEmbed ); mpTarget->msValue = sSndName; @@ -155,20 +143,16 @@ namespace oox { namespace ppt { case PPT_TOKEN( spTgt ): { mpTarget->mnType = XML_spTgt; - OUString aId = xAttribs->getOptionalValue( XML_spid ); + OUString aId = rAttribs.getString( XML_spid, OUString() ); mpTarget->msValue = aId; - xRet.set( new ShapeTargetElementContext( *this, mpTarget->maShapeTarget ) ); - break; + return new ShapeTargetElementContext( *this, mpTarget->maShapeTarget ); } default: OSL_TRACE( "OOX: unhandled tag %ld in TL_TimeTargetElement.", getBaseToken( aElementToken ) ); break; } - if( !xRet.is() ) - xRet.set( this ); - - return xRet; + return this; } diff --git a/oox/source/ppt/timetargetelementcontext.hxx b/oox/source/ppt/timetargetelementcontext.hxx index 8ee22fd26aae..f20890f1899a 100644 --- a/oox/source/ppt/timetargetelementcontext.hxx +++ b/oox/source/ppt/timetargetelementcontext.hxx @@ -29,20 +29,19 @@ #ifndef OOX_PPT_TIMETARGETELEMENTCONTEXT #define OOX_PPT_TIMETARGETELEMENTCONTEXT -#include "oox/core/contexthandler.hxx" +#include "oox/core/fragmenthandler2.hxx" #include "oox/ppt/animationspersist.hxx" namespace oox { namespace ppt { /** context CT_TLTimeTargetElement */ class TimeTargetElementContext - : public ::oox::core::ContextHandler + : public ::oox::core::FragmentHandler2 { public: - TimeTargetElementContext( ::oox::core::ContextHandler& rParent, const AnimTargetElementPtr & aValue ); + TimeTargetElementContext( ::oox::core::FragmentHandler2& rParent, const AnimTargetElementPtr & aValue ); ~TimeTargetElementContext( ) throw( ); - virtual void SAL_CALL endFastElement( sal_Int32 /*aElement*/ ) 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 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); private: AnimTargetElementPtr mpTarget; diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index d3bf0b776c25..a4b270ab4124 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -383,6 +383,7 @@ ScrollValue ScrollValueMax ScrollValueMin Segments +SelectedItems SelectedPage Show ShowBorder @@ -426,6 +427,7 @@ StartPosition StartWith StartingAngle State +StringItemList Subtotals Suffix SwapXAndYAxis diff --git a/oox/source/vml/vmldrawingfragment.cxx b/oox/source/vml/vmldrawingfragment.cxx index 12dd0a42fabf..0f92632f0e00 100644 --- a/oox/source/vml/vmldrawingfragment.cxx +++ b/oox/source/vml/vmldrawingfragment.cxx @@ -50,6 +50,13 @@ DrawingFragment::DrawingFragment( XmlFilterBase& rFilter, const OUString& rFragm FragmentHandler2( rFilter, rFragmentPath, false ), // do not trim whitespace, has been preprocessed by the input stream mrDrawing( rDrawing ) { + RelationsRef xLegacyRels = getRelations().getRelationsFromType( CREATE_MSOFFICE_RELATION_TYPE( "legacyDiagramText" ) ); + for( Relations::const_iterator aIt = xLegacyRels->begin(), aEnd = xLegacyRels->end(); aIt != aEnd; ++aIt ) + { + OUString aLegacyFragmentPath = getFragmentPathFromRelation( aIt->second ); + // TODO: import legacyDiagramText from aLegacyFragmentPath - this is a binary import. + // printf("legacyDiagram: %s\n", ::rtl::OUStringToOString( aLegacyFragmentPath, RTL_TEXTENCODING_UTF8).getStr()); + } } Reference< XInputStream > DrawingFragment::openFragmentStream() const diff --git a/oox/source/xls/formulaparser.cxx b/oox/source/xls/formulaparser.cxx index fa96869afadc..fb4ca7b6bd50 100644 --- a/oox/source/xls/formulaparser.cxx +++ b/oox/source/xls/formulaparser.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/sheet/ComplexReference.hpp> #include <com/sun/star/sheet/ExternalReference.hpp> #include <com/sun/star/sheet/FormulaToken.hpp> +#include <com/sun/star/sheet/NameToken.hpp> #include <com/sun/star/sheet/ReferenceFlags.hpp> #include <com/sun/star/sheet/SingleReference.hpp> #include "oox/core/filterbase.hxx" @@ -2860,7 +2861,10 @@ ApiTokenSequence FormulaParser::convertNameToFormula( sal_Int32 nTokenIndex ) co ApiTokenSequence aTokens( 1 ); aTokens[ 0 ].OpCode = OPCODE_NAME; - aTokens[ 0 ].Data <<= nTokenIndex; + NameToken aNameTokenData; + aNameTokenData.Global = sal_True; + aNameTokenData.Index = nTokenIndex; + aTokens[ 0 ].Data <<= aNameTokenData; return aTokens; } diff --git a/oox/source/xls/sheetdatabuffer.cxx b/oox/source/xls/sheetdatabuffer.cxx index 4eb1349e9438..04551e21840e 100755 --- a/oox/source/xls/sheetdatabuffer.cxx +++ b/oox/source/xls/sheetdatabuffer.cxx @@ -238,6 +238,9 @@ void CellBlockBuffer::setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpan CellBlock* CellBlockBuffer::getCellBlock( const CellAddress& rCellAddr ) { + // Temporarily disabled. TODO: Fix this. + return NULL; + OSL_ENSURE( rCellAddr.Row >= mnCurrRow, "CellBlockBuffer::getCellBlock - passed row out of order" ); // prepare cell blocks, if row changes if( rCellAddr.Row != mnCurrRow ) diff --git a/oox/source/xls/sheetdatacontext.cxx b/oox/source/xls/sheetdatacontext.cxx index 569126e0ebad..dfb9db03ed0e 100644 --- a/oox/source/xls/sheetdatacontext.cxx +++ b/oox/source/xls/sheetdatacontext.cxx @@ -163,8 +163,15 @@ void SheetDataContext::onCharacters( const OUString& rChars ) maCellValue = rChars; break; case XLS_TOKEN( f ): - if( maFmlaData.mnFormulaType != XML_TOKEN_INVALID ) + if( 0 && maFmlaData.mnFormulaType == XML_normal ) + { + maCellValue = rChars; + mrSheetData.putFormulaString( maCellData.maCellAddr, maCellValue ); + } + else if( maFmlaData.mnFormulaType != XML_TOKEN_INVALID ) + { maTokens = mrFormulaParser.importFormula( maCellData.maCellAddr, rChars ); + } break; } } @@ -178,7 +185,7 @@ void SheetDataContext::onEndElement() { case XML_normal: mrSheetData.setFormulaCell( maCellData, maTokens ); - break; + break; case XML_shared: if( maFmlaData.mnSharedId >= 0 ) { @@ -240,6 +247,13 @@ void SheetDataContext::onEndElement() mrSheetData.setBlankCell( maCellData ); } } + else if( maCellValue.getLength() > 0 ) switch( maCellData.mnCellType ) + { + case XML_n: + /* Set the pre-loaded value */ + mrSheetData.putFormulaResult( maCellData.maCellAddr, maCellValue.toDouble() ); + break; + } } } diff --git a/oox/source/xls/workbookfragment.cxx b/oox/source/xls/workbookfragment.cxx index 96fd34f0c100..9d22f5fdf937 100644 --- a/oox/source/xls/workbookfragment.cxx +++ b/oox/source/xls/workbookfragment.cxx @@ -29,6 +29,7 @@ #include "oox/xls/workbookfragment.hxx" #include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/sheet/XCalculatable.hpp> #include "oox/core/filterbase.hxx" #include "oox/drawingml/themefragmenthandler.hxx" #include "oox/helper/attributelist.hxx" @@ -59,6 +60,7 @@ namespace xls { using namespace ::com::sun::star::io; using namespace ::com::sun::star::table; using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sheet; using namespace ::oox::core; using ::oox::drawingml::ThemeFragmentHandler; @@ -313,6 +315,11 @@ void WorkbookFragment::finalizeImport() // final conversions, e.g. calculation settings and view settings finalizeWorkbookImport(); + + // Recalculate (only changed ones) + Reference< XCalculatable > xCalculatable( getDocument(), UNO_QUERY ); + if( xCalculatable.is() ) + xCalculatable->calculate(); } // private -------------------------------------------------------------------- diff --git a/oox/source/xls/worksheethelper.cxx b/oox/source/xls/worksheethelper.cxx index 068c89cde2d9..a74e24f3343b 100644 --- a/oox/source/xls/worksheethelper.cxx +++ b/oox/source/xls/worksheethelper.cxx @@ -48,6 +48,7 @@ #include <com/sun/star/sheet/XSheetOutline.hpp> #include <com/sun/star/sheet/XSpreadsheet.hpp> #include <com/sun/star/table/XColumnRowRange.hpp> +#include <com/sun/star/table/XCell2.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/text/XText.hpp> #include <rtl/ustrbuf.hxx> @@ -1654,6 +1655,19 @@ void WorksheetHelper::putValue( const CellAddress& rAddress, double fValue ) con if( xCell.is() ) xCell->setValue( fValue ); } +void WorksheetHelper::putFormulaResult( const CellAddress& rAddress, double fValue ) const +{ + Reference< XCell2 > xCell( getCell( rAddress ), UNO_QUERY ); + OSL_ENSURE( xCell.is(), "WorksheetHelper::putFormulaResult - missing cell interface" ); + if( xCell.is() ) xCell->setFormulaResult( fValue ); +} + +void WorksheetHelper::putFormulaString( const CellAddress& rAddress, const OUString& rFormula ) const +{ + Reference< XCell2 > xCell( getCell( rAddress ), UNO_QUERY ); + if( xCell.is() ) xCell->setFormulaString( rFormula ); +} + void WorksheetHelper::putString( const CellAddress& rAddress, const OUString& rText ) const { Reference< XText > xText( getCell( rAddress ), UNO_QUERY ); |