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