1*353d8f4dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*353d8f4dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*353d8f4dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*353d8f4dSAndrew Rist  * distributed with this work for additional information
6*353d8f4dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*353d8f4dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*353d8f4dSAndrew Rist  * "License"); you may not use this file except in compliance
9*353d8f4dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*353d8f4dSAndrew Rist  *
11*353d8f4dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*353d8f4dSAndrew Rist  *
13*353d8f4dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*353d8f4dSAndrew Rist  * software distributed under the License is distributed on an
15*353d8f4dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*353d8f4dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*353d8f4dSAndrew Rist  * specific language governing permissions and limitations
18*353d8f4dSAndrew Rist  * under the License.
19*353d8f4dSAndrew Rist  *
20*353d8f4dSAndrew Rist  *************************************************************/
21*353d8f4dSAndrew Rist 
22*353d8f4dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SFX_DOCUMENTMETADATAACCESS_HXX_
25cdf0e10cSrcweir #define _SFX_DOCUMENTMETADATAACCESS_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <sal/config.h>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <sfx2/dllapi.h>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
32cdf0e10cSrcweir #include <com/sun/star/rdf/XDocumentMetadataAccess.hpp>
33cdf0e10cSrcweir #include <com/sun/star/rdf/XRepositorySupplier.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <boost/utility.hpp>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <memory>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 
42cdf0e10cSrcweir /** Implementation of the interface com.sun.star.rdf.XDocumentMetadataAccess
43cdf0e10cSrcweir 
44cdf0e10cSrcweir     This is not a service only because it needs some kind of XML ID registry
45cdf0e10cSrcweir     from the document, and i do not like defining an API for that.
46cdf0e10cSrcweir     Also, the implementation does _no_ locking, so make sure access is
47cdf0e10cSrcweir     protected externally.
48cdf0e10cSrcweir 
49cdf0e10cSrcweir     @author mst
50cdf0e10cSrcweir  */
51cdf0e10cSrcweir 
52cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace embed {
53cdf0e10cSrcweir     class XStorage;
54cdf0e10cSrcweir } } } }
55cdf0e10cSrcweir 
56cdf0e10cSrcweir namespace sfx2 {
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 
59cdf0e10cSrcweir /** create a base URI for loading metadata from an ODF (sub)document.
60cdf0e10cSrcweir 
61cdf0e10cSrcweir     @param i_xContext   component context
62cdf0e10cSrcweir     @param i_xStorage   storage for the document; FileSystemStorage is allowed
63cdf0e10cSrcweir     @param i_rPkgURI    the URI for the package
64cdf0e10cSrcweir     @param i_rSubDocument   (optional) path of the subdocument in package
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     @return a base URI suitable for XDocumentMetadataAccess::loadFromStorage
67cdf0e10cSrcweir  */
68cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XURI> SFX2_DLLPUBLIC
69cdf0e10cSrcweir createBaseURI(
70cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>
71cdf0e10cSrcweir         const & i_xContext,
72cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage>
73cdf0e10cSrcweir         const & i_xStorage,
74cdf0e10cSrcweir     ::rtl::OUString const & i_rPkgURI,
75cdf0e10cSrcweir     ::rtl::OUString const & i_rSubDocument = ::rtl::OUString());
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 
78cdf0e10cSrcweir class IXmlIdRegistrySupplier;
79cdf0e10cSrcweir struct DocumentMetadataAccess_Impl;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 
82cdf0e10cSrcweir class SFX2_DLLPUBLIC DocumentMetadataAccess :
83cdf0e10cSrcweir     private boost::noncopyable,
84cdf0e10cSrcweir     public ::cppu::WeakImplHelper1<
85cdf0e10cSrcweir         ::com::sun::star::rdf::XDocumentMetadataAccess>
86cdf0e10cSrcweir {
87cdf0e10cSrcweir public:
88cdf0e10cSrcweir     explicit DocumentMetadataAccess(::com::sun::star::uno::Reference<
89cdf0e10cSrcweir                 ::com::sun::star::uno::XComponentContext > const & i_xContext,
90cdf0e10cSrcweir                 IXmlIdRegistrySupplier const & i_rRegistrySupplier,
91cdf0e10cSrcweir                 ::rtl::OUString const & i_rBaseURI);
92cdf0e10cSrcweir     // N.B.: in contrast to previous, this constructor does _not_ initialize!
93cdf0e10cSrcweir     //       caller must immediately call loadFromStorage/Medium!
94cdf0e10cSrcweir     explicit DocumentMetadataAccess(::com::sun::star::uno::Reference<
95cdf0e10cSrcweir                 ::com::sun::star::uno::XComponentContext > const & i_xContext,
96cdf0e10cSrcweir                 IXmlIdRegistrySupplier const & i_rRegistrySupplier);
97cdf0e10cSrcweir     virtual ~DocumentMetadataAccess();
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     // ::com::sun::star::rdf::XNode:
100cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getStringValue()
101cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     // ::com::sun::star::rdf::XURI:
104cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getNamespace()
105cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
106cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getLocalName()
107cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     // ::com::sun::star::rdf::XRepositorySupplier:
110cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
111cdf0e10cSrcweir         ::com::sun::star::rdf::XRepository > SAL_CALL getRDFRepository()
112cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     // ::com::sun::star::rdf::XDocumentMetadataAccess:
115cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
116cdf0e10cSrcweir                 ::com::sun::star::rdf::XMetadatable > SAL_CALL
117cdf0e10cSrcweir         getElementByMetadataReference(
118cdf0e10cSrcweir             const ::com::sun::star::beans::StringPair & i_rReference)
119cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
120cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
121cdf0e10cSrcweir                 ::com::sun::star::rdf::XMetadatable > SAL_CALL
122cdf0e10cSrcweir         getElementByURI(const ::com::sun::star::uno::Reference<
123cdf0e10cSrcweir             ::com::sun::star::rdf::XURI > & i_xURI)
124cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException,
125cdf0e10cSrcweir             ::com::sun::star::lang::IllegalArgumentException);
126cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
127cdf0e10cSrcweir             ::com::sun::star::rdf::XURI > > SAL_CALL getMetadataGraphsWithType(
128cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
129cdf0e10cSrcweir                 ::com::sun::star::rdf::XURI > & i_xType)
130cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException,
131cdf0e10cSrcweir             ::com::sun::star::lang::IllegalArgumentException);
132cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
133cdf0e10cSrcweir                 ::com::sun::star::rdf::XURI> SAL_CALL
134cdf0e10cSrcweir         addMetadataFile(const ::rtl::OUString & i_rFileName,
135cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence<
136cdf0e10cSrcweir                 ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XURI >
137cdf0e10cSrcweir                 > & i_rTypes)
138cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException,
139cdf0e10cSrcweir             ::com::sun::star::lang::IllegalArgumentException,
140cdf0e10cSrcweir             ::com::sun::star::container::ElementExistException);
141cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
142cdf0e10cSrcweir                 ::com::sun::star::rdf::XURI> SAL_CALL
143cdf0e10cSrcweir         importMetadataFile(::sal_Int16 i_Format,
144cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
145cdf0e10cSrcweir                 ::com::sun::star::io::XInputStream > & i_xInStream,
146cdf0e10cSrcweir             const ::rtl::OUString & i_rFileName,
147cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
148cdf0e10cSrcweir                 ::com::sun::star::rdf::XURI > & i_xBaseURI,
149cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence<
150cdf0e10cSrcweir                 ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XURI >
151cdf0e10cSrcweir                 > & i_rTypes)
152cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException,
153cdf0e10cSrcweir             ::com::sun::star::lang::IllegalArgumentException,
154cdf0e10cSrcweir             ::com::sun::star::datatransfer::UnsupportedFlavorException,
155cdf0e10cSrcweir             ::com::sun::star::container::ElementExistException,
156cdf0e10cSrcweir             ::com::sun::star::rdf::ParseException,
157cdf0e10cSrcweir             ::com::sun::star::io::IOException);
158cdf0e10cSrcweir     virtual void SAL_CALL removeMetadataFile(
159cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
160cdf0e10cSrcweir                 ::com::sun::star::rdf::XURI > & i_xGraphName)
161cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException,
162cdf0e10cSrcweir             ::com::sun::star::lang::IllegalArgumentException,
163cdf0e10cSrcweir             ::com::sun::star::container::NoSuchElementException);
164cdf0e10cSrcweir     virtual void SAL_CALL addContentOrStylesFile(
165cdf0e10cSrcweir             const ::rtl::OUString & i_rFileName)
166cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException,
167cdf0e10cSrcweir             ::com::sun::star::lang::IllegalArgumentException,
168cdf0e10cSrcweir             ::com::sun::star::container::ElementExistException);
169cdf0e10cSrcweir     virtual void SAL_CALL removeContentOrStylesFile(
170cdf0e10cSrcweir             const ::rtl::OUString & i_rFileName)
171cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException,
172cdf0e10cSrcweir             ::com::sun::star::lang::IllegalArgumentException,
173cdf0e10cSrcweir             ::com::sun::star::container::NoSuchElementException);
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     virtual void SAL_CALL loadMetadataFromStorage(
176cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
177cdf0e10cSrcweir                 ::com::sun::star::embed::XStorage > & i_xStorage,
178cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
179cdf0e10cSrcweir                 ::com::sun::star::rdf::XURI > & i_xBaseURI,
180cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
181cdf0e10cSrcweir                 ::com::sun::star::task::XInteractionHandler> & i_xHandler)
182cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException,
183cdf0e10cSrcweir             ::com::sun::star::lang::IllegalArgumentException,
184cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException);
185cdf0e10cSrcweir     virtual void SAL_CALL storeMetadataToStorage(
186cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
187cdf0e10cSrcweir                 ::com::sun::star::embed::XStorage > & i_xStorage)
188cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException,
189cdf0e10cSrcweir             ::com::sun::star::lang::IllegalArgumentException,
190cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException);
191cdf0e10cSrcweir     virtual void SAL_CALL loadMetadataFromMedium(
192cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence<
193cdf0e10cSrcweir                 ::com::sun::star::beans::PropertyValue > & i_rMedium)
194cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException,
195cdf0e10cSrcweir             ::com::sun::star::lang::IllegalArgumentException,
196cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException);
197cdf0e10cSrcweir     virtual void SAL_CALL storeMetadataToMedium(
198cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence<
199cdf0e10cSrcweir                 ::com::sun::star::beans::PropertyValue > & i_rMedium)
200cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException,
201cdf0e10cSrcweir             ::com::sun::star::lang::IllegalArgumentException,
202cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException);
203cdf0e10cSrcweir 
204cdf0e10cSrcweir private:
205cdf0e10cSrcweir     std::auto_ptr<DocumentMetadataAccess_Impl> m_pImpl;
206cdf0e10cSrcweir };
207cdf0e10cSrcweir 
208cdf0e10cSrcweir } // namespace sfx2
209cdf0e10cSrcweir 
210cdf0e10cSrcweir #endif // _SFX_DOCUMENTMETADATAACCESS_HXX_
211cdf0e10cSrcweir 
212