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_SFX2_DOCUMENTMETADATAACCESS_HXX
21 #define INCLUDED_SFX2_DOCUMENTMETADATAACCESS_HXX
23 #include <sal/config.h>
25 #include <sfx2/dllapi.h>
27 #include <com/sun/star/uno/XComponentContext.hpp>
28 #include <com/sun/star/rdf/XDocumentMetadataAccess.hpp>
29 #include <com/sun/star/rdf/XRepositorySupplier.hpp>
31 #include <cppuhelper/implbase1.hxx>
33 #include <boost/utility.hpp>
38 /** Implementation of the interface com.sun.star.rdf.XDocumentMetadataAccess
40 This is not a service only because it needs some kind of XML ID registry
41 from the document, and i do not like defining an API for that.
42 Also, the implementation does _no_ locking, so make sure access is
48 namespace com
{ namespace sun
{ namespace star
{ namespace embed
{
55 /** create a base URI for loading metadata from an ODF (sub)document.
57 @param i_xContext component context
58 @param i_xStorage storage for the document; FileSystemStorage is allowed
59 @param i_rPkgURI the URI for the package
60 @param i_rSubDocument (optional) path of the subdocument in package
62 @return a base URI suitable for XDocumentMetadataAccess::loadFromStorage
64 ::com::sun::star::uno::Reference
< ::com::sun::star::rdf::XURI
> SFX2_DLLPUBLIC
66 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>
68 ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>
70 OUString
const & i_rPkgURI
,
71 OUString
const & i_rSubDocument
= OUString());
74 class IXmlIdRegistrySupplier
;
75 struct DocumentMetadataAccess_Impl
;
78 class SFX2_DLLPUBLIC DocumentMetadataAccess
:
79 private boost::noncopyable
,
80 public ::cppu::WeakImplHelper1
<
81 ::com::sun::star::rdf::XDocumentMetadataAccess
>
84 explicit DocumentMetadataAccess(::com::sun::star::uno::Reference
<
85 ::com::sun::star::uno::XComponentContext
> const & i_xContext
,
86 IXmlIdRegistrySupplier
const & i_rRegistrySupplier
,
87 OUString
const & i_rBaseURI
);
88 // N.B.: in contrast to previous, this constructor does _not_ initialize!
89 // caller must immediately call loadFromStorage/Medium!
90 explicit DocumentMetadataAccess(::com::sun::star::uno::Reference
<
91 ::com::sun::star::uno::XComponentContext
> const & i_xContext
,
92 IXmlIdRegistrySupplier
const & i_rRegistrySupplier
);
93 virtual ~DocumentMetadataAccess();
95 // ::com::sun::star::rdf::XNode:
96 virtual OUString SAL_CALL
getStringValue()
97 throw (::com::sun::star::uno::RuntimeException
);
99 // ::com::sun::star::rdf::XURI:
100 virtual OUString SAL_CALL
getNamespace()
101 throw (::com::sun::star::uno::RuntimeException
);
102 virtual OUString SAL_CALL
getLocalName()
103 throw (::com::sun::star::uno::RuntimeException
);
105 // ::com::sun::star::rdf::XRepositorySupplier:
106 virtual ::com::sun::star::uno::Reference
<
107 ::com::sun::star::rdf::XRepository
> SAL_CALL
getRDFRepository()
108 throw (::com::sun::star::uno::RuntimeException
);
110 // ::com::sun::star::rdf::XDocumentMetadataAccess:
111 virtual ::com::sun::star::uno::Reference
<
112 ::com::sun::star::rdf::XMetadatable
> SAL_CALL
113 getElementByMetadataReference(
114 const ::com::sun::star::beans::StringPair
& i_rReference
)
115 throw (::com::sun::star::uno::RuntimeException
);
116 virtual ::com::sun::star::uno::Reference
<
117 ::com::sun::star::rdf::XMetadatable
> SAL_CALL
118 getElementByURI(const ::com::sun::star::uno::Reference
<
119 ::com::sun::star::rdf::XURI
> & i_xURI
)
120 throw (::com::sun::star::uno::RuntimeException
,
121 ::com::sun::star::lang::IllegalArgumentException
);
122 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
<
123 ::com::sun::star::rdf::XURI
> > SAL_CALL
getMetadataGraphsWithType(
124 const ::com::sun::star::uno::Reference
<
125 ::com::sun::star::rdf::XURI
> & i_xType
)
126 throw (::com::sun::star::uno::RuntimeException
,
127 ::com::sun::star::lang::IllegalArgumentException
);
128 virtual ::com::sun::star::uno::Reference
<
129 ::com::sun::star::rdf::XURI
> SAL_CALL
130 addMetadataFile(const OUString
& i_rFileName
,
131 const ::com::sun::star::uno::Sequence
<
132 ::com::sun::star::uno::Reference
< ::com::sun::star::rdf::XURI
>
134 throw (::com::sun::star::uno::RuntimeException
,
135 ::com::sun::star::lang::IllegalArgumentException
,
136 ::com::sun::star::container::ElementExistException
);
137 virtual ::com::sun::star::uno::Reference
<
138 ::com::sun::star::rdf::XURI
> SAL_CALL
139 importMetadataFile(::sal_Int16 i_Format
,
140 const ::com::sun::star::uno::Reference
<
141 ::com::sun::star::io::XInputStream
> & i_xInStream
,
142 const OUString
& i_rFileName
,
143 const ::com::sun::star::uno::Reference
<
144 ::com::sun::star::rdf::XURI
> & i_xBaseURI
,
145 const ::com::sun::star::uno::Sequence
<
146 ::com::sun::star::uno::Reference
< ::com::sun::star::rdf::XURI
>
148 throw (::com::sun::star::uno::RuntimeException
,
149 ::com::sun::star::lang::IllegalArgumentException
,
150 ::com::sun::star::datatransfer::UnsupportedFlavorException
,
151 ::com::sun::star::container::ElementExistException
,
152 ::com::sun::star::rdf::ParseException
,
153 ::com::sun::star::io::IOException
);
154 virtual void SAL_CALL
removeMetadataFile(
155 const ::com::sun::star::uno::Reference
<
156 ::com::sun::star::rdf::XURI
> & i_xGraphName
)
157 throw (::com::sun::star::uno::RuntimeException
,
158 ::com::sun::star::lang::IllegalArgumentException
,
159 ::com::sun::star::container::NoSuchElementException
);
160 virtual void SAL_CALL
addContentOrStylesFile(
161 const OUString
& i_rFileName
)
162 throw (::com::sun::star::uno::RuntimeException
,
163 ::com::sun::star::lang::IllegalArgumentException
,
164 ::com::sun::star::container::ElementExistException
);
165 virtual void SAL_CALL
removeContentOrStylesFile(
166 const OUString
& i_rFileName
)
167 throw (::com::sun::star::uno::RuntimeException
,
168 ::com::sun::star::lang::IllegalArgumentException
,
169 ::com::sun::star::container::NoSuchElementException
);
171 virtual void SAL_CALL
loadMetadataFromStorage(
172 const ::com::sun::star::uno::Reference
<
173 ::com::sun::star::embed::XStorage
> & i_xStorage
,
174 const ::com::sun::star::uno::Reference
<
175 ::com::sun::star::rdf::XURI
> & i_xBaseURI
,
176 const ::com::sun::star::uno::Reference
<
177 ::com::sun::star::task::XInteractionHandler
> & i_xHandler
)
178 throw (::com::sun::star::uno::RuntimeException
,
179 ::com::sun::star::lang::IllegalArgumentException
,
180 ::com::sun::star::lang::WrappedTargetException
);
181 virtual void SAL_CALL
storeMetadataToStorage(
182 const ::com::sun::star::uno::Reference
<
183 ::com::sun::star::embed::XStorage
> & i_xStorage
)
184 throw (::com::sun::star::uno::RuntimeException
,
185 ::com::sun::star::lang::IllegalArgumentException
,
186 ::com::sun::star::lang::WrappedTargetException
);
187 virtual void SAL_CALL
loadMetadataFromMedium(
188 const ::com::sun::star::uno::Sequence
<
189 ::com::sun::star::beans::PropertyValue
> & i_rMedium
)
190 throw (::com::sun::star::uno::RuntimeException
,
191 ::com::sun::star::lang::IllegalArgumentException
,
192 ::com::sun::star::lang::WrappedTargetException
);
193 virtual void SAL_CALL
storeMetadataToMedium(
194 const ::com::sun::star::uno::Sequence
<
195 ::com::sun::star::beans::PropertyValue
> & i_rMedium
)
196 throw (::com::sun::star::uno::RuntimeException
,
197 ::com::sun::star::lang::IllegalArgumentException
,
198 ::com::sun::star::lang::WrappedTargetException
);
201 std::auto_ptr
<DocumentMetadataAccess_Impl
> m_pImpl
;
206 #endif // INCLUDED_SFX2_DOCUMENTMETADATAACCESS_HXX
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */