1*e3508121SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*e3508121SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*e3508121SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*e3508121SAndrew Rist * distributed with this work for additional information 6*e3508121SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*e3508121SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*e3508121SAndrew Rist * "License"); you may not use this file except in compliance 9*e3508121SAndrew Rist * with the License. You may obtain a copy of the License at 10*e3508121SAndrew Rist * 11*e3508121SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*e3508121SAndrew Rist * 13*e3508121SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*e3508121SAndrew Rist * software distributed under the License is distributed on an 15*e3508121SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*e3508121SAndrew Rist * KIND, either express or implied. See the License for the 17*e3508121SAndrew Rist * specific language governing permissions and limitations 18*e3508121SAndrew Rist * under the License. 19*e3508121SAndrew Rist * 20*e3508121SAndrew Rist *************************************************************/ 21*e3508121SAndrew Rist 22*e3508121SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef OOX_DOCPROP_DOCPROPHANDLER_HXX 25cdf0e10cSrcweir #define OOX_DOCPROP_DOCPROPHANDLER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 28cdf0e10cSrcweir #include <com/sun/star/document/XDocumentProperties.hpp> 29cdf0e10cSrcweir #include <com/sun/star/xml/sax/XFastDocumentHandler.hpp> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include "oox/token/namespaces.hxx" 34cdf0e10cSrcweir #include "oox/token/tokens.hxx" 35cdf0e10cSrcweir 36cdf0e10cSrcweir namespace oox { 37cdf0e10cSrcweir namespace docprop { 38cdf0e10cSrcweir 39cdf0e10cSrcweir #define COREPR_TOKEN( token ) (::oox::NMSP_packageMetaCorePr | XML_##token) 40cdf0e10cSrcweir #define CUSTPR_TOKEN( token ) (::oox::NMSP_officeCustomPr | XML_##token) 41cdf0e10cSrcweir #define EXTPR_TOKEN( token ) (::oox::NMSP_officeExtPr | XML_##token) 42cdf0e10cSrcweir #define VT_TOKEN( token ) (::oox::NMSP_officeDocPropsVT | XML_##token) 43cdf0e10cSrcweir #define DC_TOKEN( token ) (::oox::NMSP_dc | XML_##token) 44cdf0e10cSrcweir #define DCT_TOKEN( token ) (::oox::NMSP_dcTerms | XML_##token) 45cdf0e10cSrcweir 46cdf0e10cSrcweir class OOXMLDocPropHandler : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XFastDocumentHandler > 47cdf0e10cSrcweir { 48cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 49cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentProperties > m_xDocProp; 50cdf0e10cSrcweir 51cdf0e10cSrcweir sal_Int32 m_nState; 52cdf0e10cSrcweir sal_Int32 m_nBlock; 53cdf0e10cSrcweir sal_Int32 m_nType; 54cdf0e10cSrcweir 55cdf0e10cSrcweir sal_Int32 m_nInBlock; 56cdf0e10cSrcweir 57cdf0e10cSrcweir ::rtl::OUString m_aCustomPropertyName; 58cdf0e10cSrcweir 59cdf0e10cSrcweir public: 60cdf0e10cSrcweir explicit OOXMLDocPropHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext, const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentProperties > xDocProp ); 61cdf0e10cSrcweir 62cdf0e10cSrcweir virtual ~OOXMLDocPropHandler(); 63cdf0e10cSrcweir 64cdf0e10cSrcweir void InitNew(); 65cdf0e10cSrcweir void AddCustomProperty( const ::com::sun::star::uno::Any& aAny ); 66cdf0e10cSrcweir 67cdf0e10cSrcweir ::com::sun::star::util::DateTime GetDateTimeFromW3CDTF( const ::rtl::OUString& aChars ); 68cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > GetKeywordsSet( const ::rtl::OUString& aChars ); 69cdf0e10cSrcweir ::com::sun::star::lang::Locale GetLanguage( const ::rtl::OUString& aChars ); 70cdf0e10cSrcweir void UpdateDocStatistic( const ::rtl::OUString& aChars ); 71cdf0e10cSrcweir 72cdf0e10cSrcweir // com.sun.star.xml.sax.XFastDocumentHandler 73cdf0e10cSrcweir 74cdf0e10cSrcweir virtual void SAL_CALL startDocument() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 75cdf0e10cSrcweir virtual void SAL_CALL endDocument() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 76cdf0e10cSrcweir virtual void SAL_CALL setDocumentLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& rxLocator ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 77cdf0e10cSrcweir 78cdf0e10cSrcweir // com.sun.star.xml.sax.XFastContextHandler 79cdf0e10cSrcweir 80cdf0e10cSrcweir virtual void SAL_CALL startFastElement( ::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); 81cdf0e10cSrcweir virtual void SAL_CALL startUnknownElement( const ::rtl::OUString& Namespace, const ::rtl::OUString& Name, 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); 82cdf0e10cSrcweir virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 83cdf0e10cSrcweir virtual void SAL_CALL endUnknownElement( const ::rtl::OUString& Namespace, const ::rtl::OUString& Name ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 84cdf0e10cSrcweir 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); 85cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext( const ::rtl::OUString& Namespace, const ::rtl::OUString& Name, 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); 86cdf0e10cSrcweir virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 87cdf0e10cSrcweir virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 88cdf0e10cSrcweir virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 89cdf0e10cSrcweir 90cdf0e10cSrcweir }; 91cdf0e10cSrcweir 92cdf0e10cSrcweir // ============================================================================ 93cdf0e10cSrcweir 94cdf0e10cSrcweir } // namespace core 95cdf0e10cSrcweir } // namespace oox 96cdf0e10cSrcweir 97cdf0e10cSrcweir #endif 98cdf0e10cSrcweir 99