xref: /aoo4110/main/xmloff/inc/xmloff/xmlmetae.hxx (revision b1cdbd2c)
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 _XMLOFF_XMLMETAE_HXX
25 #define _XMLOFF_XMLMETAE_HXX
26 
27 #include "sal/config.h"
28 #include "xmloff/dllapi.h"
29 #include "sal/types.h"
30 
31 #include <cppuhelper/implbase1.hxx>
32 #include <xmloff/xmltoken.hxx>
33 
34 #include <vector>
35 
36 #include <com/sun/star/beans/StringPair.hpp>
37 #include <com/sun/star/util/DateTime.hpp>
38 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
39 #include <com/sun/star/document/XDocumentProperties.hpp>
40 
41 
42 class SvXMLExport;
43 
44 /** export meta data from an <type>XDocumentProperties</type> instance.
45 
46     <p>
47     This class will start the export at the office:meta element,
48     not at the root element. This means that when <method>Export</method>
49     is called here, the document root element must already be written, but
50     office:meta must <em>not</em> be written.
51     </p>
52  */
53 class XMLOFF_DLLPUBLIC SvXMLMetaExport : public ::cppu::WeakImplHelper1<
54                 ::com::sun::star::xml::sax::XDocumentHandler >
55 {
56 private:
57     SvXMLExport& mrExport;
58 	::com::sun::star::uno::Reference<
59 		::com::sun::star::document::XDocumentProperties> mxDocProps;
60     /// counts levels of the xml document. necessary for special handling.
61     int m_level;
62     /// preserved namespaces. necessary because we do not write the root node.
63     std::vector< ::com::sun::star::beans::StringPair > m_preservedNSs;
64 
65 	SAL_DLLPRIVATE void SimpleStringElement(
66         const ::rtl::OUString& rText, sal_uInt16 nNamespace,
67         enum ::xmloff::token::XMLTokenEnum eElementName );
68 	SAL_DLLPRIVATE void SimpleDateTimeElement(
69         const ::com::sun::star::util::DateTime & rDate, sal_uInt16 nNamespace,
70         enum ::xmloff::token::XMLTokenEnum eElementName );
71 
72     /// currently unused; for exporting via the XDocumentProperties interface
73 	SAL_DLLPRIVATE void _MExport();
74 
75 public:
76 	SvXMLMetaExport( SvXMLExport& i_rExport,
77 		const ::com::sun::star::uno::Reference<
78                 ::com::sun::star::document::XDocumentProperties>& i_rDocProps);
79 
80 	virtual ~SvXMLMetaExport();
81 
82     /// export via XSAXWriter interface, with fallback to _MExport
83 	void Export();
84 
85 	static ::rtl::OUString GetISODateTimeString(
86 						const ::com::sun::star::util::DateTime& rDateTime );
87 
88     // ::com::sun::star::xml::sax::XDocumentHandler:
89     virtual void SAL_CALL startDocument()
90         throw (::com::sun::star::uno::RuntimeException,
91                ::com::sun::star::xml::sax::SAXException);
92     virtual void SAL_CALL endDocument()
93         throw (::com::sun::star::uno::RuntimeException,
94                ::com::sun::star::xml::sax::SAXException);
95     virtual void SAL_CALL startElement(const ::rtl::OUString & i_rName,
96         const ::com::sun::star::uno::Reference<
97                 ::com::sun::star::xml::sax::XAttributeList > & i_xAttribs)
98         throw (::com::sun::star::uno::RuntimeException,
99                ::com::sun::star::xml::sax::SAXException);
100     virtual void SAL_CALL endElement(const ::rtl::OUString & i_rName)
101         throw (::com::sun::star::uno::RuntimeException,
102                ::com::sun::star::xml::sax::SAXException);
103     virtual void SAL_CALL characters(const ::rtl::OUString & i_rChars)
104         throw (::com::sun::star::uno::RuntimeException,
105                ::com::sun::star::xml::sax::SAXException);
106     virtual void SAL_CALL ignorableWhitespace(
107         const ::rtl::OUString & i_rWhitespaces)
108         throw (::com::sun::star::uno::RuntimeException,
109                ::com::sun::star::xml::sax::SAXException);
110     virtual void SAL_CALL processingInstruction(
111         const ::rtl::OUString & i_rTarget, const ::rtl::OUString & i_rData)
112         throw (::com::sun::star::uno::RuntimeException,
113                ::com::sun::star::xml::sax::SAXException);
114     virtual void SAL_CALL setDocumentLocator(
115         const ::com::sun::star::uno::Reference<
116                 ::com::sun::star::xml::sax::XLocator > & i_xLocator)
117         throw (::com::sun::star::uno::RuntimeException,
118                ::com::sun::star::xml::sax::SAXException);
119 
120 };
121 
122 #endif // _XMLOFF_XMLMETAE_HXX
123 
124