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
46 namespace com
{ namespace sun
{ namespace star
{ namespace embed
{
53 /** create a base URI for loading metadata from an ODF (sub)document.
55 @param i_xContext component context
56 @param i_xStorage storage for the document; FileSystemStorage is allowed
57 @param i_rPkgURI the URI for the package
58 @param i_rSubDocument (optional) path of the subdocument in package
60 @return a base URI suitable for XDocumentMetadataAccess::loadFromStorage
62 ::com::sun::star::uno::Reference
< ::com::sun::star::rdf::XURI
> SFX2_DLLPUBLIC
64 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>
66 ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>
68 OUString
const & i_rPkgURI
,
69 OUString
const & i_rSubDocument
= OUString());
72 class IXmlIdRegistrySupplier
;
73 struct DocumentMetadataAccess_Impl
;
76 class SFX2_DLLPUBLIC DocumentMetadataAccess
:
77 private boost::noncopyable
,
78 public ::cppu::WeakImplHelper1
<
79 ::com::sun::star::rdf::XDocumentMetadataAccess
>
82 explicit DocumentMetadataAccess(::com::sun::star::uno::Reference
<
83 ::com::sun::star::uno::XComponentContext
> const & i_xContext
,
84 IXmlIdRegistrySupplier
const & i_rRegistrySupplier
,
85 OUString
const & i_rBaseURI
);
86 // N.B.: in contrast to previous, this constructor does _not_ initialize!
87 // caller must immediately call loadFromStorage/Medium!
88 explicit DocumentMetadataAccess(::com::sun::star::uno::Reference
<
89 ::com::sun::star::uno::XComponentContext
> const & i_xContext
,
90 IXmlIdRegistrySupplier
const & i_rRegistrySupplier
);
91 virtual ~DocumentMetadataAccess();
93 // ::com::sun::star::rdf::XNode:
94 virtual OUString SAL_CALL
getStringValue()
95 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
97 // ::com::sun::star::rdf::XURI:
98 virtual OUString SAL_CALL
getNamespace()
99 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
100 virtual OUString SAL_CALL
getLocalName()
101 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
103 // ::com::sun::star::rdf::XRepositorySupplier:
104 virtual ::com::sun::star::uno::Reference
<
105 ::com::sun::star::rdf::XRepository
> SAL_CALL
getRDFRepository()
106 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
108 // ::com::sun::star::rdf::XDocumentMetadataAccess:
109 virtual ::com::sun::star::uno::Reference
<
110 ::com::sun::star::rdf::XMetadatable
> SAL_CALL
111 getElementByMetadataReference(
112 const ::com::sun::star::beans::StringPair
& i_rReference
)
113 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
114 virtual ::com::sun::star::uno::Reference
<
115 ::com::sun::star::rdf::XMetadatable
> SAL_CALL
116 getElementByURI(const ::com::sun::star::uno::Reference
<
117 ::com::sun::star::rdf::XURI
> & i_xURI
)
118 throw (::com::sun::star::uno::RuntimeException
,
119 ::com::sun::star::lang::IllegalArgumentException
, std::exception
) SAL_OVERRIDE
;
120 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
<
121 ::com::sun::star::rdf::XURI
> > SAL_CALL
getMetadataGraphsWithType(
122 const ::com::sun::star::uno::Reference
<
123 ::com::sun::star::rdf::XURI
> & i_xType
)
124 throw (::com::sun::star::uno::RuntimeException
,
125 ::com::sun::star::lang::IllegalArgumentException
, std::exception
) SAL_OVERRIDE
;
126 virtual ::com::sun::star::uno::Reference
<
127 ::com::sun::star::rdf::XURI
> SAL_CALL
128 addMetadataFile(const OUString
& i_rFileName
,
129 const ::com::sun::star::uno::Sequence
<
130 ::com::sun::star::uno::Reference
< ::com::sun::star::rdf::XURI
>
132 throw (::com::sun::star::uno::RuntimeException
,
133 ::com::sun::star::lang::IllegalArgumentException
,
134 ::com::sun::star::container::ElementExistException
, std::exception
) SAL_OVERRIDE
;
135 virtual ::com::sun::star::uno::Reference
<
136 ::com::sun::star::rdf::XURI
> SAL_CALL
137 importMetadataFile(::sal_Int16 i_Format
,
138 const ::com::sun::star::uno::Reference
<
139 ::com::sun::star::io::XInputStream
> & i_xInStream
,
140 const OUString
& i_rFileName
,
141 const ::com::sun::star::uno::Reference
<
142 ::com::sun::star::rdf::XURI
> & i_xBaseURI
,
143 const ::com::sun::star::uno::Sequence
<
144 ::com::sun::star::uno::Reference
< ::com::sun::star::rdf::XURI
>
146 throw (::com::sun::star::uno::RuntimeException
,
147 ::com::sun::star::lang::IllegalArgumentException
,
148 ::com::sun::star::datatransfer::UnsupportedFlavorException
,
149 ::com::sun::star::container::ElementExistException
,
150 ::com::sun::star::rdf::ParseException
,
151 ::com::sun::star::io::IOException
, std::exception
) SAL_OVERRIDE
;
152 virtual void SAL_CALL
removeMetadataFile(
153 const ::com::sun::star::uno::Reference
<
154 ::com::sun::star::rdf::XURI
> & i_xGraphName
)
155 throw (::com::sun::star::uno::RuntimeException
,
156 ::com::sun::star::lang::IllegalArgumentException
,
157 ::com::sun::star::container::NoSuchElementException
, std::exception
) SAL_OVERRIDE
;
158 virtual void SAL_CALL
addContentOrStylesFile(
159 const OUString
& i_rFileName
)
160 throw (::com::sun::star::uno::RuntimeException
,
161 ::com::sun::star::lang::IllegalArgumentException
,
162 ::com::sun::star::container::ElementExistException
, std::exception
) SAL_OVERRIDE
;
163 virtual void SAL_CALL
removeContentOrStylesFile(
164 const OUString
& i_rFileName
)
165 throw (::com::sun::star::uno::RuntimeException
,
166 ::com::sun::star::lang::IllegalArgumentException
,
167 ::com::sun::star::container::NoSuchElementException
, std::exception
) SAL_OVERRIDE
;
169 virtual void SAL_CALL
loadMetadataFromStorage(
170 const ::com::sun::star::uno::Reference
<
171 ::com::sun::star::embed::XStorage
> & i_xStorage
,
172 const ::com::sun::star::uno::Reference
<
173 ::com::sun::star::rdf::XURI
> & i_xBaseURI
,
174 const ::com::sun::star::uno::Reference
<
175 ::com::sun::star::task::XInteractionHandler
> & i_xHandler
)
176 throw (::com::sun::star::uno::RuntimeException
,
177 ::com::sun::star::lang::IllegalArgumentException
,
178 ::com::sun::star::lang::WrappedTargetException
, std::exception
) SAL_OVERRIDE
;
179 virtual void SAL_CALL
storeMetadataToStorage(
180 const ::com::sun::star::uno::Reference
<
181 ::com::sun::star::embed::XStorage
> & i_xStorage
)
182 throw (::com::sun::star::uno::RuntimeException
,
183 ::com::sun::star::lang::IllegalArgumentException
,
184 ::com::sun::star::lang::WrappedTargetException
, std::exception
) SAL_OVERRIDE
;
185 virtual void SAL_CALL
loadMetadataFromMedium(
186 const ::com::sun::star::uno::Sequence
<
187 ::com::sun::star::beans::PropertyValue
> & i_rMedium
)
188 throw (::com::sun::star::uno::RuntimeException
,
189 ::com::sun::star::lang::IllegalArgumentException
,
190 ::com::sun::star::lang::WrappedTargetException
, std::exception
) SAL_OVERRIDE
;
191 virtual void SAL_CALL
storeMetadataToMedium(
192 const ::com::sun::star::uno::Sequence
<
193 ::com::sun::star::beans::PropertyValue
> & i_rMedium
)
194 throw (::com::sun::star::uno::RuntimeException
,
195 ::com::sun::star::lang::IllegalArgumentException
,
196 ::com::sun::star::lang::WrappedTargetException
, std::exception
) SAL_OVERRIDE
;
199 std::unique_ptr
<DocumentMetadataAccess_Impl
> m_pImpl
;
204 #endif // INCLUDED_SFX2_DOCUMENTMETADATAACCESS_HXX
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */