1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_XMLOFF_XMLMETAE_HXX
21 #define INCLUDED_XMLOFF_XMLMETAE_HXX
23 #include <sal/config.h>
24 #include <xmloff/dllapi.h>
25 #include <sal/types.h>
27 #include <cppuhelper/implbase1.hxx>
28 #include <xmloff/xmltoken.hxx>
32 #include <com/sun/star/beans/StringPair.hpp>
33 #include <com/sun/star/util/DateTime.hpp>
34 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
35 #include <com/sun/star/document/XDocumentProperties.hpp>
40 /** export meta data from an XDocumentProperties instance.
43 This class will start the export at the office:meta element,
44 not at the root element. This means that when <method>Export</method>
45 is called here, the document root element must already be written, but
46 office:meta must <em>not</em> be written.
49 class XMLOFF_DLLPUBLIC SvXMLMetaExport
: public ::cppu::WeakImplHelper1
<
50 ::com::sun::star::xml::sax::XDocumentHandler
>
53 SvXMLExport
& mrExport
;
54 ::com::sun::star::uno::Reference
<
55 ::com::sun::star::document::XDocumentProperties
> mxDocProps
;
56 /// counts levels of the xml document. necessary for special handling.
58 /// preserved namespaces. necessary because we do not write the root node.
59 std::vector
< ::com::sun::star::beans::StringPair
> m_preservedNSs
;
61 SAL_DLLPRIVATE
void SimpleStringElement(
62 const OUString
& rText
, sal_uInt16 nNamespace
,
63 enum ::xmloff::token::XMLTokenEnum eElementName
);
64 SAL_DLLPRIVATE
void SimpleDateTimeElement(
65 const ::com::sun::star::util::DateTime
& rDate
, sal_uInt16 nNamespace
,
66 enum ::xmloff::token::XMLTokenEnum eElementName
);
68 /// currently unused; for exporting via the XDocumentProperties interface
69 SAL_DLLPRIVATE
void _MExport();
72 SvXMLMetaExport( SvXMLExport
& i_rExport
,
73 const ::com::sun::star::uno::Reference
<
74 ::com::sun::star::document::XDocumentProperties
>& i_rDocProps
);
76 virtual ~SvXMLMetaExport();
78 /// export via XSAXWriter interface, with fallback to _MExport
81 static OUString
GetISODateTimeString(
82 const ::com::sun::star::util::DateTime
& rDateTime
);
84 // ::com::sun::star::xml::sax::XDocumentHandler:
85 virtual void SAL_CALL
startDocument()
86 throw (::com::sun::star::uno::RuntimeException
,
87 ::com::sun::star::xml::sax::SAXException
, std::exception
) SAL_OVERRIDE
;
88 virtual void SAL_CALL
endDocument()
89 throw (::com::sun::star::uno::RuntimeException
,
90 ::com::sun::star::xml::sax::SAXException
, std::exception
) SAL_OVERRIDE
;
91 virtual void SAL_CALL
startElement(const OUString
& i_rName
,
92 const ::com::sun::star::uno::Reference
<
93 ::com::sun::star::xml::sax::XAttributeList
> & i_xAttribs
)
94 throw (::com::sun::star::uno::RuntimeException
,
95 ::com::sun::star::xml::sax::SAXException
, std::exception
) SAL_OVERRIDE
;
96 virtual void SAL_CALL
endElement(const OUString
& i_rName
)
97 throw (::com::sun::star::uno::RuntimeException
,
98 ::com::sun::star::xml::sax::SAXException
, std::exception
) SAL_OVERRIDE
;
99 virtual void SAL_CALL
characters(const OUString
& i_rChars
)
100 throw (::com::sun::star::uno::RuntimeException
,
101 ::com::sun::star::xml::sax::SAXException
, std::exception
) SAL_OVERRIDE
;
102 virtual void SAL_CALL
ignorableWhitespace(
103 const OUString
& i_rWhitespaces
)
104 throw (::com::sun::star::uno::RuntimeException
,
105 ::com::sun::star::xml::sax::SAXException
, std::exception
) SAL_OVERRIDE
;
106 virtual void SAL_CALL
processingInstruction(
107 const OUString
& i_rTarget
, const OUString
& i_rData
)
108 throw (::com::sun::star::uno::RuntimeException
,
109 ::com::sun::star::xml::sax::SAXException
, std::exception
) SAL_OVERRIDE
;
110 virtual void SAL_CALL
setDocumentLocator(
111 const ::com::sun::star::uno::Reference
<
112 ::com::sun::star::xml::sax::XLocator
> & i_xLocator
)
113 throw (::com::sun::star::uno::RuntimeException
,
114 ::com::sun::star::xml::sax::SAXException
, std::exception
) SAL_OVERRIDE
;
118 #endif // INCLUDED_XMLOFF_XMLMETAE_HXX
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */