/src/libreoffice/package/source/xstor/ocompinstream.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include "ocompinstream.hxx" |
21 | | #include <com/sun/star/embed/StorageFormats.hpp> |
22 | | #include <com/sun/star/io/IOException.hpp> |
23 | | #include <com/sun/star/lang/DisposedException.hpp> |
24 | | #include <comphelper/sequence.hxx> |
25 | | #include <cppuhelper/queryinterface.hxx> |
26 | | #include <osl/diagnose.h> |
27 | | #include <sal/log.hxx> |
28 | | #include <utility> |
29 | | |
30 | | #include "owriteablestream.hxx" |
31 | | |
32 | | using namespace ::com::sun::star; |
33 | | |
34 | | OInputCompStream::OInputCompStream( OWriteStream_Impl& aImpl, |
35 | | uno::Reference < io::XInputStream > xStream, |
36 | | const uno::Sequence< beans::PropertyValue >& aProps, |
37 | | sal_Int32 nStorageType ) |
38 | 150k | : m_pImpl( &aImpl ) |
39 | 150k | , m_xMutex( m_pImpl->m_xMutex ) |
40 | 150k | , m_xStream(std::move( xStream )) |
41 | 150k | , m_pByteReader( dynamic_cast<comphelper::ByteReader*>(m_xStream.get()) ) |
42 | 150k | , m_aProperties( aProps ) |
43 | 150k | , m_bDisposed( false ) |
44 | 150k | , m_nStorageType( nStorageType ) |
45 | 150k | { |
46 | 150k | OSL_ENSURE( m_pImpl->m_xMutex.is(), "No mutex is provided!" ); |
47 | 150k | if ( !m_pImpl->m_xMutex.is() ) |
48 | 0 | throw uno::RuntimeException(); // just a disaster |
49 | | |
50 | 150k | assert(m_xStream.is()); |
51 | 150k | assert(m_pByteReader); |
52 | 150k | } |
53 | | |
54 | | OInputCompStream::OInputCompStream( uno::Reference < io::XInputStream > xStream, |
55 | | const uno::Sequence< beans::PropertyValue >& aProps, |
56 | | sal_Int32 nStorageType ) |
57 | 0 | : m_pImpl( nullptr ) |
58 | 0 | , m_xMutex( new comphelper::RefCountedMutex ) |
59 | 0 | , m_xStream(std::move( xStream )) |
60 | 0 | , m_pByteReader( dynamic_cast<comphelper::ByteReader*>(m_xStream.get()) ) |
61 | 0 | , m_aProperties( aProps ) |
62 | 0 | , m_bDisposed( false ) |
63 | 0 | , m_nStorageType( nStorageType ) |
64 | 0 | { |
65 | 0 | assert(m_xStream.is()); |
66 | 0 | assert(m_pByteReader); |
67 | 0 | } |
68 | | |
69 | | OInputCompStream::~OInputCompStream() |
70 | 150k | { |
71 | 150k | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
72 | | |
73 | 150k | if ( !m_bDisposed ) |
74 | 132k | { |
75 | 132k | osl_atomic_increment(&m_refCount); |
76 | 132k | dispose(); |
77 | 132k | } |
78 | 150k | } |
79 | | |
80 | | uno::Any SAL_CALL OInputCompStream::queryInterface( const uno::Type& rType ) |
81 | 1.54M | { |
82 | | // common interfaces |
83 | 1.54M | uno::Any aReturn = ::cppu::queryInterface |
84 | 1.54M | ( rType |
85 | 1.54M | , static_cast<io::XInputStream*> ( this ) |
86 | 1.54M | , static_cast<io::XStream*> ( this ) |
87 | 1.54M | , static_cast<lang::XComponent*> ( this ) |
88 | 1.54M | , static_cast<beans::XPropertySet*> ( this ) |
89 | 1.54M | , static_cast<embed::XExtendedStorageStream*> ( this ) ); |
90 | | |
91 | 1.54M | if ( aReturn.hasValue() ) |
92 | 316k | return aReturn ; |
93 | | |
94 | 1.22M | if ( m_nStorageType == embed::StorageFormats::OFOPXML ) |
95 | 185k | { |
96 | 185k | aReturn = ::cppu::queryInterface |
97 | 185k | ( rType |
98 | 185k | , static_cast<embed::XRelationshipAccess*> ( this ) ); |
99 | | |
100 | 185k | if ( aReturn.hasValue() ) |
101 | 69.3k | return aReturn ; |
102 | 185k | } |
103 | | |
104 | 1.15M | return OWeakObject::queryInterface( rType ); |
105 | 1.22M | } |
106 | | |
107 | | sal_Int32 SAL_CALL OInputCompStream::readBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) |
108 | 18.8k | { |
109 | 18.8k | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
110 | 18.8k | if ( m_bDisposed ) |
111 | 0 | { |
112 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
113 | 0 | throw lang::DisposedException(); |
114 | 0 | } |
115 | | |
116 | 18.8k | return m_xStream->readBytes( aData, nBytesToRead ); |
117 | 18.8k | } |
118 | | |
119 | | sal_Int32 SAL_CALL OInputCompStream::readSomeBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) |
120 | 301k | { |
121 | 301k | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
122 | 301k | if ( m_bDisposed ) |
123 | 0 | { |
124 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
125 | 0 | throw lang::DisposedException(); |
126 | 0 | } |
127 | | |
128 | 301k | return m_xStream->readSomeBytes( aData, nMaxBytesToRead ); |
129 | | |
130 | 301k | } |
131 | | |
132 | | sal_Int32 OInputCompStream::readSomeBytes( sal_Int8* aData, sal_Int32 nMaxBytesToRead ) |
133 | 1.06k | { |
134 | 1.06k | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
135 | 1.06k | if ( m_bDisposed ) |
136 | 0 | { |
137 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
138 | 0 | throw lang::DisposedException(); |
139 | 0 | } |
140 | | |
141 | 1.06k | return m_pByteReader->readSomeBytes( aData, nMaxBytesToRead ); |
142 | | |
143 | 1.06k | } |
144 | | |
145 | | void SAL_CALL OInputCompStream::skipBytes( sal_Int32 nBytesToSkip ) |
146 | 270 | { |
147 | 270 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
148 | 270 | if ( m_bDisposed ) |
149 | 0 | { |
150 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
151 | 0 | throw lang::DisposedException(); |
152 | 0 | } |
153 | | |
154 | 270 | m_xStream->skipBytes( nBytesToSkip ); |
155 | | |
156 | 270 | } |
157 | | |
158 | | sal_Int32 SAL_CALL OInputCompStream::available( ) |
159 | 0 | { |
160 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
161 | 0 | if ( m_bDisposed ) |
162 | 0 | { |
163 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
164 | 0 | throw lang::DisposedException(); |
165 | 0 | } |
166 | | |
167 | 0 | return m_xStream->available(); |
168 | |
|
169 | 0 | } |
170 | | |
171 | | void SAL_CALL OInputCompStream::closeInput( ) |
172 | 16.4k | { |
173 | 16.4k | dispose(); |
174 | 16.4k | } |
175 | | |
176 | | uno::Reference< io::XInputStream > SAL_CALL OInputCompStream::getInputStream() |
177 | 54.2k | { |
178 | 54.2k | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
179 | 54.2k | if ( m_bDisposed ) |
180 | 0 | { |
181 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
182 | 0 | throw lang::DisposedException(); |
183 | 0 | } |
184 | | |
185 | 54.2k | return this; |
186 | 54.2k | } |
187 | | |
188 | | uno::Reference< io::XOutputStream > SAL_CALL OInputCompStream::getOutputStream() |
189 | 1 | { |
190 | 1 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
191 | 1 | if ( m_bDisposed ) |
192 | 0 | { |
193 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
194 | 0 | throw lang::DisposedException(); |
195 | 0 | } |
196 | | |
197 | 1 | return uno::Reference< io::XOutputStream >(); |
198 | 1 | } |
199 | | |
200 | | void OInputCompStream::InternalDispose() |
201 | 2 | { |
202 | | // can be called only by OWriteStream_Impl |
203 | 2 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
204 | 2 | if ( m_bDisposed ) |
205 | 0 | return; |
206 | | |
207 | | // the source object is also a kind of locker for the current object |
208 | | // since the listeners could dispose the object while being notified |
209 | 2 | lang::EventObject aSource( getXWeak() ); |
210 | | |
211 | 2 | if ( m_pInterfaceContainer ) |
212 | 2 | m_pInterfaceContainer->disposeAndClear( aSource ); |
213 | | |
214 | 2 | try |
215 | 2 | { |
216 | 2 | m_xStream->closeInput(); |
217 | 2 | } |
218 | 2 | catch( uno::Exception& ) |
219 | 2 | {} |
220 | | |
221 | 2 | m_pImpl = nullptr; |
222 | 2 | m_bDisposed = true; |
223 | 2 | } |
224 | | |
225 | | void SAL_CALL OInputCompStream::dispose( ) |
226 | 150k | { |
227 | 150k | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
228 | 150k | if ( m_bDisposed ) |
229 | 0 | return; |
230 | | |
231 | 150k | if ( m_pInterfaceContainer ) |
232 | 127k | { |
233 | 127k | lang::EventObject aSource( getXWeak() ); |
234 | 127k | m_pInterfaceContainer->disposeAndClear( aSource ); |
235 | 127k | } |
236 | | |
237 | 150k | m_xStream->closeInput(); |
238 | | |
239 | 150k | if ( m_pImpl ) |
240 | 150k | { |
241 | 150k | m_pImpl->InputStreamDisposed( this ); |
242 | 150k | m_pImpl = nullptr; |
243 | 150k | } |
244 | | |
245 | 150k | m_bDisposed = true; |
246 | 150k | } |
247 | | |
248 | | void SAL_CALL OInputCompStream::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) |
249 | 127k | { |
250 | 127k | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
251 | 127k | if ( m_bDisposed ) |
252 | 0 | { |
253 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
254 | 0 | throw lang::DisposedException(); |
255 | 0 | } |
256 | | |
257 | 127k | if ( !m_pInterfaceContainer ) |
258 | 127k | m_pInterfaceContainer.reset( new ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener>( m_xMutex->GetMutex() ) ); |
259 | | |
260 | 127k | m_pInterfaceContainer->addInterface( xListener ); |
261 | 127k | } |
262 | | |
263 | | void SAL_CALL OInputCompStream::removeEventListener( const uno::Reference< lang::XEventListener >& xListener ) |
264 | 0 | { |
265 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
266 | 0 | if ( m_bDisposed ) |
267 | 0 | { |
268 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
269 | 0 | throw lang::DisposedException(); |
270 | 0 | } |
271 | | |
272 | 0 | if ( m_pInterfaceContainer ) |
273 | 0 | m_pInterfaceContainer->removeInterface( xListener ); |
274 | 0 | } |
275 | | |
276 | | sal_Bool SAL_CALL OInputCompStream::hasByID( const OUString& sID ) |
277 | 0 | { |
278 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
279 | |
|
280 | 0 | if ( m_bDisposed ) |
281 | 0 | { |
282 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
283 | 0 | throw lang::DisposedException(); |
284 | 0 | } |
285 | | |
286 | 0 | if ( m_nStorageType != embed::StorageFormats::OFOPXML ) |
287 | 0 | throw uno::RuntimeException(); |
288 | | |
289 | 0 | try |
290 | 0 | { |
291 | 0 | getRelationshipByID( sID ); |
292 | 0 | return true; |
293 | 0 | } |
294 | 0 | catch( container::NoSuchElementException& ) |
295 | 0 | {} |
296 | | |
297 | 0 | return false; |
298 | 0 | } |
299 | | |
300 | | namespace |
301 | | { |
302 | | |
303 | | const beans::StringPair* lcl_findPairByName(const uno::Sequence<beans::StringPair>& rSeq, const OUString& rName) |
304 | 0 | { |
305 | 0 | return std::find_if(rSeq.begin(), rSeq.end(), |
306 | 0 | [&rName](const beans::StringPair& rPair) { return rPair.First == rName; }); |
307 | 0 | } |
308 | | |
309 | | } |
310 | | |
311 | | OUString SAL_CALL OInputCompStream::getTargetByID( const OUString& sID ) |
312 | 0 | { |
313 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
314 | |
|
315 | 0 | if ( m_bDisposed ) |
316 | 0 | { |
317 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
318 | 0 | throw lang::DisposedException(); |
319 | 0 | } |
320 | | |
321 | 0 | if ( m_nStorageType != embed::StorageFormats::OFOPXML ) |
322 | 0 | throw uno::RuntimeException(); |
323 | | |
324 | 0 | const uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID ); |
325 | 0 | auto pRel = lcl_findPairByName(aSeq, u"Target"_ustr); |
326 | 0 | if (pRel != aSeq.end()) |
327 | 0 | return pRel->Second; |
328 | | |
329 | 0 | return OUString(); |
330 | 0 | } |
331 | | |
332 | | OUString SAL_CALL OInputCompStream::getTypeByID( const OUString& sID ) |
333 | 0 | { |
334 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
335 | |
|
336 | 0 | if ( m_bDisposed ) |
337 | 0 | { |
338 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
339 | 0 | throw lang::DisposedException(); |
340 | 0 | } |
341 | | |
342 | 0 | if ( m_nStorageType != embed::StorageFormats::OFOPXML ) |
343 | 0 | throw uno::RuntimeException(); |
344 | | |
345 | 0 | const uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID ); |
346 | 0 | auto pRel = lcl_findPairByName(aSeq, u"Type"_ustr); |
347 | 0 | if (pRel != aSeq.end()) |
348 | 0 | return pRel->Second; |
349 | | |
350 | 0 | return OUString(); |
351 | 0 | } |
352 | | |
353 | | uno::Sequence< beans::StringPair > SAL_CALL OInputCompStream::getRelationshipByID( const OUString& sID ) |
354 | 0 | { |
355 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
356 | |
|
357 | 0 | if ( m_bDisposed ) |
358 | 0 | { |
359 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
360 | 0 | throw lang::DisposedException(); |
361 | 0 | } |
362 | | |
363 | 0 | if ( m_nStorageType != embed::StorageFormats::OFOPXML ) |
364 | 0 | throw uno::RuntimeException(); |
365 | | |
366 | | // TODO/LATER: in future the unification of the ID could be checked |
367 | 0 | const uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships(); |
368 | 0 | const beans::StringPair aIDRel(u"Id"_ustr, sID); |
369 | 0 | auto pRel = std::find_if(aSeq.begin(), aSeq.end(), |
370 | 0 | [&aIDRel](const uno::Sequence<beans::StringPair>& rRel){ |
371 | 0 | return std::find(rRel.begin(), rRel.end(), aIDRel) != rRel.end(); }); |
372 | 0 | if (pRel != aSeq.end()) |
373 | 0 | return *pRel; |
374 | | |
375 | 0 | throw container::NoSuchElementException(); |
376 | 0 | } |
377 | | |
378 | | uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OInputCompStream::getRelationshipsByType( const OUString& sType ) |
379 | 0 | { |
380 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
381 | |
|
382 | 0 | if ( m_bDisposed ) |
383 | 0 | { |
384 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
385 | 0 | throw lang::DisposedException(); |
386 | 0 | } |
387 | | |
388 | 0 | if ( m_nStorageType != embed::StorageFormats::OFOPXML ) |
389 | 0 | throw uno::RuntimeException(); |
390 | | |
391 | | // TODO/LATER: in future the unification of the ID could be checked |
392 | 0 | const uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships(); |
393 | 0 | const beans::StringPair aTypeRel(u"Type"_ustr, sType); |
394 | 0 | std::vector< uno::Sequence<beans::StringPair> > aResult; |
395 | 0 | aResult.reserve(aSeq.getLength()); |
396 | |
|
397 | 0 | std::copy_if(aSeq.begin(), aSeq.end(), std::back_inserter(aResult), |
398 | 0 | [&aTypeRel](const uno::Sequence<beans::StringPair>& rRel) { |
399 | 0 | return std::find(rRel.begin(), rRel.end(), aTypeRel) != rRel.end(); }); |
400 | |
|
401 | 0 | return comphelper::containerToSequence(aResult); |
402 | 0 | } |
403 | | |
404 | | uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OInputCompStream::getAllRelationships() |
405 | 123k | { |
406 | 123k | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
407 | | |
408 | 123k | if ( m_bDisposed ) |
409 | 0 | { |
410 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
411 | 0 | throw lang::DisposedException(); |
412 | 0 | } |
413 | | |
414 | 123k | if ( m_nStorageType != embed::StorageFormats::OFOPXML ) |
415 | 0 | throw uno::RuntimeException(); |
416 | | |
417 | | // TODO/LATER: in future the information could be taken directly from m_pImpl when possible |
418 | 123k | auto pProp = std::find_if(std::cbegin(m_aProperties), std::cend(m_aProperties), |
419 | 493k | [](const beans::PropertyValue& rProp) { return rProp.Name == "RelationsInfo"; }); |
420 | 123k | if (pProp != std::cend(m_aProperties)) |
421 | 123k | { |
422 | 123k | uno::Sequence< uno::Sequence< beans::StringPair > > aResult; |
423 | 123k | if (pProp->Value >>= aResult) |
424 | 123k | return aResult; |
425 | 123k | } |
426 | | |
427 | 0 | throw io::IOException(u"relations info could not be read"_ustr); // the relations info could not be read |
428 | 123k | } |
429 | | |
430 | | void SAL_CALL OInputCompStream::insertRelationshipByID( const OUString& /*sID*/, const uno::Sequence< beans::StringPair >& /*aEntry*/, sal_Bool /*bReplace*/ ) |
431 | 0 | { |
432 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
433 | |
|
434 | 0 | if ( m_bDisposed ) |
435 | 0 | { |
436 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
437 | 0 | throw lang::DisposedException(); |
438 | 0 | } |
439 | | |
440 | 0 | if ( m_nStorageType != embed::StorageFormats::OFOPXML ) |
441 | 0 | throw uno::RuntimeException(); |
442 | | |
443 | 0 | throw io::IOException(); // TODO: Access denied |
444 | 0 | } |
445 | | |
446 | | void SAL_CALL OInputCompStream::removeRelationshipByID( const OUString& /*sID*/ ) |
447 | 0 | { |
448 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
449 | |
|
450 | 0 | if ( m_bDisposed ) |
451 | 0 | { |
452 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
453 | 0 | throw lang::DisposedException(); |
454 | 0 | } |
455 | | |
456 | 0 | if ( m_nStorageType != embed::StorageFormats::OFOPXML ) |
457 | 0 | throw uno::RuntimeException(); |
458 | | |
459 | 0 | throw io::IOException(); // TODO: Access denied |
460 | 0 | } |
461 | | |
462 | | void SAL_CALL OInputCompStream::insertRelationships( const uno::Sequence< uno::Sequence< beans::StringPair > >& /*aEntries*/, sal_Bool /*bReplace*/ ) |
463 | 0 | { |
464 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
465 | |
|
466 | 0 | if ( m_bDisposed ) |
467 | 0 | { |
468 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
469 | 0 | throw lang::DisposedException(); |
470 | 0 | } |
471 | | |
472 | 0 | if ( m_nStorageType != embed::StorageFormats::OFOPXML ) |
473 | 0 | throw uno::RuntimeException(); |
474 | | |
475 | 0 | throw io::IOException(); // TODO: Access denied |
476 | 0 | } |
477 | | |
478 | | void SAL_CALL OInputCompStream::clearRelationships() |
479 | 0 | { |
480 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
481 | |
|
482 | 0 | if ( m_bDisposed ) |
483 | 0 | { |
484 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
485 | 0 | throw lang::DisposedException(); |
486 | 0 | } |
487 | | |
488 | 0 | if ( m_nStorageType != embed::StorageFormats::OFOPXML ) |
489 | 0 | throw uno::RuntimeException(); |
490 | | |
491 | 0 | throw io::IOException(); // TODO: Access denied |
492 | 0 | } |
493 | | |
494 | | uno::Reference< beans::XPropertySetInfo > SAL_CALL OInputCompStream::getPropertySetInfo() |
495 | 0 | { |
496 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
497 | |
|
498 | 0 | if ( m_bDisposed ) |
499 | 0 | { |
500 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
501 | 0 | throw lang::DisposedException(); |
502 | 0 | } |
503 | | |
504 | | //TODO: |
505 | 0 | return uno::Reference< beans::XPropertySetInfo >(); |
506 | 0 | } |
507 | | |
508 | | void SAL_CALL OInputCompStream::setPropertyValue( const OUString& aPropertyName, const uno::Any& /*aValue*/ ) |
509 | 0 | { |
510 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
511 | |
|
512 | 0 | if ( m_bDisposed ) |
513 | 0 | { |
514 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
515 | 0 | throw lang::DisposedException(); |
516 | 0 | } |
517 | | |
518 | | // all the provided properties are accessible |
519 | 0 | if (std::any_of(std::cbegin(m_aProperties), std::cend(m_aProperties), |
520 | 0 | [&aPropertyName](const beans::PropertyValue& rProp) { return rProp.Name == aPropertyName; })) |
521 | 0 | throw beans::PropertyVetoException(); // TODO |
522 | | |
523 | 0 | throw beans::UnknownPropertyException(aPropertyName); // TODO |
524 | 0 | } |
525 | | |
526 | | uno::Any SAL_CALL OInputCompStream::getPropertyValue( const OUString& aProp ) |
527 | 820 | { |
528 | 820 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
529 | | |
530 | 820 | if ( m_bDisposed ) |
531 | 0 | { |
532 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
533 | 0 | throw lang::DisposedException(); |
534 | 0 | } |
535 | | |
536 | 820 | OUString aPropertyName; |
537 | 820 | if ( aProp == "IsEncrypted" ) |
538 | 0 | aPropertyName = "Encrypted"; |
539 | 820 | else |
540 | 820 | aPropertyName = aProp; |
541 | | |
542 | 820 | if ( aPropertyName == "RelationsInfo" ) |
543 | 0 | throw beans::UnknownPropertyException(aPropertyName); // TODO |
544 | | |
545 | | // all the provided properties are accessible |
546 | 820 | auto pProp = std::find_if(std::cbegin(m_aProperties), std::cend(m_aProperties), |
547 | 885 | [&aPropertyName](const beans::PropertyValue& rProp) { return rProp.Name == aPropertyName; }); |
548 | 820 | if (pProp != std::cend(m_aProperties)) |
549 | 820 | return pProp->Value; |
550 | | |
551 | 0 | throw beans::UnknownPropertyException(aPropertyName); // TODO |
552 | 820 | } |
553 | | |
554 | | void SAL_CALL OInputCompStream::addPropertyChangeListener( |
555 | | const OUString& /*aPropertyName*/, |
556 | | const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) |
557 | 0 | { |
558 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
559 | |
|
560 | 0 | if ( m_bDisposed ) |
561 | 0 | { |
562 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
563 | 0 | throw lang::DisposedException(); |
564 | 0 | } |
565 | | |
566 | | //TODO: |
567 | 0 | } |
568 | | |
569 | | void SAL_CALL OInputCompStream::removePropertyChangeListener( |
570 | | const OUString& /*aPropertyName*/, |
571 | | const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) |
572 | 0 | { |
573 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
574 | |
|
575 | 0 | if ( m_bDisposed ) |
576 | 0 | { |
577 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
578 | 0 | throw lang::DisposedException(); |
579 | 0 | } |
580 | | |
581 | | //TODO: |
582 | 0 | } |
583 | | |
584 | | void SAL_CALL OInputCompStream::addVetoableChangeListener( |
585 | | const OUString& /*PropertyName*/, |
586 | | const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) |
587 | 0 | { |
588 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
589 | |
|
590 | 0 | if ( m_bDisposed ) |
591 | 0 | { |
592 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
593 | 0 | throw lang::DisposedException(); |
594 | 0 | } |
595 | | |
596 | | //TODO: |
597 | 0 | } |
598 | | |
599 | | void SAL_CALL OInputCompStream::removeVetoableChangeListener( |
600 | | const OUString& /*PropertyName*/, |
601 | | const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) |
602 | 0 | { |
603 | 0 | ::osl::MutexGuard aGuard( m_xMutex->GetMutex() ); |
604 | |
|
605 | 0 | if ( m_bDisposed ) |
606 | 0 | { |
607 | 0 | SAL_INFO("package.xstor", "Disposed!"); |
608 | 0 | throw lang::DisposedException(); |
609 | 0 | } |
610 | | |
611 | | //TODO: |
612 | 0 | } |
613 | | |
614 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |