xref: /trunk/main/xmloff/inc/xmlversion.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _XMLOFF_XMLVERSION_HXX
28 #define _XMLOFF_XMLVERSION_HXX
29 
30 #include <com/sun/star/uno/Sequence.hxx>
31 #include <com/sun/star/document/XDocumentRevisionListPersistence.hpp>
32 #include <com/sun/star/util/RevisionTag.hpp>
33 #include <com/sun/star/embed/XStorage.hpp>
34 
35 #include <cppuhelper/implbase1.hxx>
36 #include <xmloff/xmlictxt.hxx>
37 #include <xmloff/xmlexp.hxx>
38 #include <xmloff/xmlimp.hxx>
39 #include <xmloff/nmspmap.hxx>
40 #include <xmloff/xmlnmspe.hxx>
41 #include <xmloff/xmltoken.hxx>
42 
43 // ------------------------------------------------------------------------
44 class XMLVersionListExport : public SvXMLExport
45 {
46 private:
47     const com::sun::star::uno::Sequence < com::sun::star::util::RevisionTag >& maVersions;
48 public:
49     XMLVersionListExport(
50         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
51         const com::sun::star::uno::Sequence < com::sun::star::util::RevisionTag >& rVersions,
52         const rtl::OUString &rFileName,
53         com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler > &rHandler );
54     virtual     ~XMLVersionListExport() {}
55 
56     sal_uInt32  exportDoc( enum ::xmloff::token::XMLTokenEnum eClass );
57     void        _ExportAutoStyles() {}
58     void        _ExportMasterStyles () {}
59     void        _ExportContent() {}
60 };
61 
62 // ------------------------------------------------------------------------
63 class XMLVersionListImport : public SvXMLImport
64 {
65 private:
66     com::sun::star::uno::Sequence < com::sun::star::util::RevisionTag >& maVersions;
67 
68 protected:
69 
70     // This method is called after the namespace map has been updated, but
71     // before a context for the current element has been pushed.
72     virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
73                     const ::rtl::OUString& rLocalName,
74                     const ::com::sun::star::uno::Reference<
75                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
76 
77 public:
78 
79     // #110897#
80     XMLVersionListImport(
81         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
82         com::sun::star::uno::Sequence < com::sun::star::util::RevisionTag >& rVersions );
83     ~XMLVersionListImport() throw();
84 
85     com::sun::star::uno::Sequence < com::sun::star::util::RevisionTag >&
86         GetList() { return maVersions; }
87 };
88 
89 // ------------------------------------------------------------------------
90 class XMLVersionListContext : public SvXMLImportContext
91 {
92 private:
93     XMLVersionListImport & rLocalRef;
94 
95 public:
96 
97     XMLVersionListContext( XMLVersionListImport& rImport,
98                            sal_uInt16 nPrefix,
99                            const rtl::OUString& rLocalName,
100                            const ::com::sun::star::uno::Reference<
101                            ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
102 
103     ~XMLVersionListContext();
104 
105     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
106                            const rtl::OUString& rLocalName,
107                            const ::com::sun::star::uno::Reference<
108                            ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
109 
110 };
111 
112 // ------------------------------------------------------------------------
113 class XMLVersionContext: public SvXMLImportContext
114 {
115 private:
116     XMLVersionListImport&  rLocalRef;
117 
118     static sal_Bool         ParseISODateTimeString(
119                                 const rtl::OUString& rString,
120                                 com::sun::star::util::DateTime& rDateTime );
121 
122 public:
123 
124     XMLVersionContext( XMLVersionListImport& rImport,
125                           sal_uInt16 nPrefix,
126                           const rtl::OUString& rLocalName,
127                           const ::com::sun::star::uno::Reference<
128                           ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
129 
130     ~XMLVersionContext();
131 };
132 
133 
134 // ------------------------------------------------------------------------
135 class XMLVersionListPersistence : public ::cppu::WeakImplHelper1< ::com::sun::star::document::XDocumentRevisionListPersistence >
136 {
137 public:
138     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::util::RevisionTag > SAL_CALL load( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
139     virtual void SAL_CALL store( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage, const ::com::sun::star::uno::Sequence< ::com::sun::star::util::RevisionTag >& List ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
140 };
141 
142 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
143     XMLVersionListPersistence_getSupportedServiceNames()
144     throw();
145 
146 ::rtl::OUString SAL_CALL XMLVersionPersistence_getImplementationName()
147     throw();
148 
149 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
150     XMLVersionListPersistence_createInstance(
151         const ::com::sun::star::uno::Reference<
152             ::com::sun::star::lang::XMultiServiceFactory > & )
153     throw( ::com::sun::star::uno::Exception );
154 
155 #endif
156