1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_package.hxx"
26 
27 #include "ocompinstream.hxx"
28 #include <com/sun/star/embed/StorageFormats.hpp>
29 #include <com/sun/star/lang/DisposedException.hpp>
30 #include <osl/diagnose.h>
31 
32 #include "owriteablestream.hxx"
33 #include "xstorage.hxx"
34 
35 using namespace ::com::sun::star;
36 
37 //-----------------------------------------------
OInputCompStream(OWriteStream_Impl & aImpl,uno::Reference<io::XInputStream> xStream,const uno::Sequence<beans::PropertyValue> & aProps,sal_Int32 nStorageType)38 OInputCompStream::OInputCompStream( OWriteStream_Impl& aImpl,
39 									uno::Reference < io::XInputStream > xStream,
40 									const uno::Sequence< beans::PropertyValue >& aProps,
41 									sal_Int32 nStorageType )
42 : m_pImpl( &aImpl )
43 , m_rMutexRef( m_pImpl->m_rMutexRef )
44 , m_xStream( xStream )
45 , m_pInterfaceContainer( NULL )
46 , m_aProperties( aProps )
47 , m_bDisposed( sal_False )
48 , m_nStorageType( nStorageType )
49 {
50 	OSL_ENSURE( m_pImpl->m_rMutexRef.Is(), "No mutex is provided!\n" );
51 	if ( !m_pImpl->m_rMutexRef.Is() )
52 		throw uno::RuntimeException(); // just a disaster
53 
54 	OSL_ENSURE( xStream.is(), "No stream is provided!\n" );
55 }
56 
57 //-----------------------------------------------
OInputCompStream(uno::Reference<io::XInputStream> xStream,const uno::Sequence<beans::PropertyValue> & aProps,sal_Int32 nStorageType)58 OInputCompStream::OInputCompStream( uno::Reference < io::XInputStream > xStream,
59 									const uno::Sequence< beans::PropertyValue >& aProps,
60 									sal_Int32 nStorageType )
61 : m_pImpl( NULL )
62 , m_rMutexRef( new SotMutexHolder )
63 , m_xStream( xStream )
64 , m_pInterfaceContainer( NULL )
65 , m_aProperties( aProps )
66 , m_bDisposed( sal_False )
67 , m_nStorageType( nStorageType )
68 {
69 	OSL_ENSURE( xStream.is(), "No stream is provided!\n" );
70 }
71 
72 //-----------------------------------------------
~OInputCompStream()73 OInputCompStream::~OInputCompStream()
74 {
75 	{
76 		::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
77 
78 		if ( !m_bDisposed )
79 		{
80 			m_refCount++;
81 			dispose();
82 		}
83 
84 		if ( m_pInterfaceContainer )
85 			delete m_pInterfaceContainer;
86 	}
87 }
88 
89 //-----------------------------------------------
queryInterface(const uno::Type & rType)90 uno::Any SAL_CALL OInputCompStream::queryInterface( const uno::Type& rType )
91 		throw( uno::RuntimeException )
92 {
93 	uno::Any aReturn;
94 
95 	// common interfaces
96 	aReturn <<= ::cppu::queryInterface
97 				(	rType
98 					,	static_cast<io::XInputStream*> ( this )
99 					,	static_cast<io::XStream*> ( this )
100 					,	static_cast<lang::XComponent*> ( this )
101 					,	static_cast<beans::XPropertySet*> ( this )
102 					,	static_cast<embed::XExtendedStorageStream*> ( this ) );
103 
104 	if ( aReturn.hasValue() == sal_True )
105 		return aReturn ;
106 
107 	if ( m_nStorageType == embed::StorageFormats::OFOPXML )
108 	{
109 		aReturn <<= ::cppu::queryInterface
110 					(	rType
111 						,	static_cast<embed::XRelationshipAccess*> ( this ) );
112 
113 		if ( aReturn.hasValue() == sal_True )
114 			return aReturn ;
115 	}
116 
117 	return OWeakObject::queryInterface( rType );
118 }
119 
120 //-----------------------------------------------
readBytes(uno::Sequence<sal_Int8> & aData,sal_Int32 nBytesToRead)121 sal_Int32 SAL_CALL OInputCompStream::readBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
122 		throw ( io::NotConnectedException,
123 				io::BufferSizeExceededException,
124 				io::IOException,
125 				uno::RuntimeException )
126 {
127 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
128 	if ( m_bDisposed )
129     {
130 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
131 		throw lang::DisposedException();
132     }
133 
134 	if ( !m_xStream.is() )
135     {
136 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "No stream!" ) ) );
137 		throw uno::RuntimeException();
138     }
139 
140 	return m_xStream->readBytes( aData, nBytesToRead );
141 }
142 
143 //-----------------------------------------------
readSomeBytes(uno::Sequence<sal_Int8> & aData,sal_Int32 nMaxBytesToRead)144 sal_Int32 SAL_CALL OInputCompStream::readSomeBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
145 		throw ( io::NotConnectedException,
146 				io::BufferSizeExceededException,
147 				io::IOException,
148 				uno::RuntimeException )
149 {
150 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
151 	if ( m_bDisposed )
152     {
153 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
154 		throw lang::DisposedException();
155     }
156 
157 	if ( !m_xStream.is() )
158     {
159 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "No stream!" ) ) );
160 		throw uno::RuntimeException();
161     }
162 
163 	return m_xStream->readSomeBytes( aData, nMaxBytesToRead );
164 
165 }
166 
167 //-----------------------------------------------
skipBytes(sal_Int32 nBytesToSkip)168 void SAL_CALL OInputCompStream::skipBytes( sal_Int32 nBytesToSkip )
169 		throw ( io::NotConnectedException,
170 				io::BufferSizeExceededException,
171 				io::IOException,
172 				uno::RuntimeException )
173 {
174 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
175 	if ( m_bDisposed )
176     {
177 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
178 		throw lang::DisposedException();
179     }
180 
181 	if ( !m_xStream.is() )
182     {
183 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "No stream!" ) ) );
184 		throw uno::RuntimeException();
185     }
186 
187 	m_xStream->skipBytes( nBytesToSkip );
188 
189 }
190 
191 //-----------------------------------------------
available()192 sal_Int32 SAL_CALL OInputCompStream::available(  )
193 		throw ( io::NotConnectedException,
194 				io::IOException,
195 				uno::RuntimeException )
196 {
197 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
198 	if ( m_bDisposed )
199     {
200 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
201 		throw lang::DisposedException();
202     }
203 
204 	if ( !m_xStream.is() )
205     {
206 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "No stream!" ) ) );
207 		throw uno::RuntimeException();
208     }
209 
210 	return m_xStream->available();
211 
212 }
213 
214 //-----------------------------------------------
closeInput()215 void SAL_CALL OInputCompStream::closeInput(  )
216 		throw ( io::NotConnectedException,
217 				io::IOException,
218 				uno::RuntimeException )
219 {
220 	dispose();
221 }
222 
223 //-----------------------------------------------
getInputStream()224 uno::Reference< io::XInputStream > SAL_CALL OInputCompStream::getInputStream()
225 		throw ( uno::RuntimeException )
226 {
227 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
228 	if ( m_bDisposed )
229     {
230 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
231 		throw lang::DisposedException();
232     }
233 
234 	if ( !m_xStream.is() )
235         return uno::Reference< io::XInputStream >();
236 
237 	return uno::Reference< io::XInputStream >( static_cast< io::XInputStream* >( this ), uno::UNO_QUERY );
238 }
239 
240 //-----------------------------------------------
getOutputStream()241 uno::Reference< io::XOutputStream > SAL_CALL OInputCompStream::getOutputStream()
242 		throw ( uno::RuntimeException )
243 {
244 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
245 	if ( m_bDisposed )
246     {
247 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
248 		throw lang::DisposedException();
249     }
250 
251 	return uno::Reference< io::XOutputStream >();
252 }
253 
254 //-----------------------------------------------
InternalDispose()255 void OInputCompStream::InternalDispose()
256 {
257 	// can be called only by OWriteStream_Impl
258 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
259 	if ( m_bDisposed )
260     {
261 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
262 		throw lang::DisposedException();
263     }
264 
265 	// the source object is also a kind of locker for the current object
266 	// since the listeners could dispose the object while being notified
267     lang::EventObject aSource( static_cast< ::cppu::OWeakObject*>( this ) );
268 
269 	if ( m_pInterfaceContainer )
270 		m_pInterfaceContainer->disposeAndClear( aSource );
271 
272 	try
273 	{
274 		m_xStream->closeInput();
275 	}
276 	catch( uno::Exception& )
277 	{}
278 
279 	m_pImpl = NULL;
280 	m_bDisposed = sal_True;
281 }
282 
283 //-----------------------------------------------
dispose()284 void SAL_CALL OInputCompStream::dispose(  )
285 		throw ( uno::RuntimeException )
286 {
287 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
288 	if ( m_bDisposed )
289     {
290 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
291 		throw lang::DisposedException();
292     }
293 
294 	if ( m_pInterfaceContainer )
295 	{
296     	lang::EventObject aSource( static_cast< ::cppu::OWeakObject*>( this ) );
297 		m_pInterfaceContainer->disposeAndClear( aSource );
298 	}
299 
300 	m_xStream->closeInput();
301 
302 	if ( m_pImpl )
303 	{
304 		m_pImpl->InputStreamDisposed( this );
305 		m_pImpl = NULL;
306 	}
307 
308 	m_bDisposed = sal_True;
309 }
310 
311 //-----------------------------------------------
addEventListener(const uno::Reference<lang::XEventListener> & xListener)312 void SAL_CALL OInputCompStream::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
313 		throw ( uno::RuntimeException )
314 {
315 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
316 	if ( m_bDisposed )
317     {
318 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
319 		throw lang::DisposedException();
320     }
321 
322 	if ( !m_pInterfaceContainer )
323 		m_pInterfaceContainer = new ::cppu::OInterfaceContainerHelper( m_rMutexRef->GetMutex() );
324 
325 	m_pInterfaceContainer->addInterface( xListener );
326 }
327 
328 //-----------------------------------------------
removeEventListener(const uno::Reference<lang::XEventListener> & xListener)329 void SAL_CALL OInputCompStream::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
330 		throw ( uno::RuntimeException )
331 {
332 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
333 	if ( m_bDisposed )
334     {
335 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
336 		throw lang::DisposedException();
337     }
338 
339 	if ( m_pInterfaceContainer )
340 		m_pInterfaceContainer->removeInterface( xListener );
341 }
342 
343 //-----------------------------------------------
hasByID(const::rtl::OUString & sID)344 sal_Bool SAL_CALL OInputCompStream::hasByID(  const ::rtl::OUString& sID )
345 		throw ( io::IOException,
346 				uno::RuntimeException )
347 {
348 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
349 
350 	if ( m_bDisposed )
351     {
352 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
353 		throw lang::DisposedException();
354     }
355 
356 	if ( m_nStorageType != embed::StorageFormats::OFOPXML )
357 		throw uno::RuntimeException();
358 
359 	try
360 	{
361 		getRelationshipByID( sID );
362 		return sal_True;
363 	}
364 	catch( container::NoSuchElementException& )
365 	{}
366 
367 	return sal_False;
368 }
369 
370 //-----------------------------------------------
getTargetByID(const::rtl::OUString & sID)371 ::rtl::OUString SAL_CALL OInputCompStream::getTargetByID(  const ::rtl::OUString& sID  )
372 		throw ( container::NoSuchElementException,
373 				io::IOException,
374 				uno::RuntimeException )
375 {
376 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
377 
378 	if ( m_bDisposed )
379     {
380 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
381 		throw lang::DisposedException();
382     }
383 
384 	if ( m_nStorageType != embed::StorageFormats::OFOPXML )
385 		throw uno::RuntimeException();
386 
387 	uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID );
388 	for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
389 		if ( aSeq[nInd].First.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Target" ) ) )
390 			return aSeq[nInd].Second;
391 
392 	return ::rtl::OUString();
393 }
394 
395 //-----------------------------------------------
getTypeByID(const::rtl::OUString & sID)396 ::rtl::OUString SAL_CALL OInputCompStream::getTypeByID(  const ::rtl::OUString& sID  )
397 		throw ( container::NoSuchElementException,
398 				io::IOException,
399 				uno::RuntimeException )
400 {
401 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
402 
403 	if ( m_bDisposed )
404     {
405 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
406 		throw lang::DisposedException();
407     }
408 
409 	if ( m_nStorageType != embed::StorageFormats::OFOPXML )
410 		throw uno::RuntimeException();
411 
412 	uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID );
413 	for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
414 		if ( aSeq[nInd].First.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Type" ) ) )
415 			return aSeq[nInd].Second;
416 
417 	return ::rtl::OUString();
418 }
419 
420 //-----------------------------------------------
getRelationshipByID(const::rtl::OUString & sID)421 uno::Sequence< beans::StringPair > SAL_CALL OInputCompStream::getRelationshipByID(  const ::rtl::OUString& sID  )
422 		throw ( container::NoSuchElementException,
423 				io::IOException,
424 				uno::RuntimeException )
425 {
426 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
427 
428 	if ( m_bDisposed )
429     {
430 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
431 		throw lang::DisposedException();
432     }
433 
434 	if ( m_nStorageType != embed::StorageFormats::OFOPXML )
435 		throw uno::RuntimeException();
436 
437 	// TODO/LATER: in future the unification of the ID could be checked
438 	uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships();
439 	for ( sal_Int32 nInd1 = 0; nInd1 < aSeq.getLength(); nInd1++ )
440 		for ( sal_Int32 nInd2 = 0; nInd2 < aSeq[nInd1].getLength(); nInd2++ )
441 			if ( aSeq[nInd1][nInd2].First.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Id" ) ) )
442 			{
443 				if ( aSeq[nInd1][nInd2].Second.equals( sID ) )
444 					return aSeq[nInd1];
445 				break;
446 			}
447 
448 	throw container::NoSuchElementException();
449 }
450 
451 //-----------------------------------------------
getRelationshipsByType(const::rtl::OUString & sType)452 uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OInputCompStream::getRelationshipsByType(  const ::rtl::OUString& sType  )
453 		throw ( io::IOException,
454 				uno::RuntimeException )
455 {
456 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
457 
458 	if ( m_bDisposed )
459     {
460 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
461 		throw lang::DisposedException();
462     }
463 
464 	if ( m_nStorageType != embed::StorageFormats::OFOPXML )
465 		throw uno::RuntimeException();
466 
467 	uno::Sequence< uno::Sequence< beans::StringPair > > aResult;
468 	sal_Int32 nEntriesNum = 0;
469 
470 	// TODO/LATER: in future the unification of the ID could be checked
471 	uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships();
472 	for ( sal_Int32 nInd1 = 0; nInd1 < aSeq.getLength(); nInd1++ )
473 		for ( sal_Int32 nInd2 = 0; nInd2 < aSeq[nInd1].getLength(); nInd2++ )
474 			if ( aSeq[nInd1][nInd2].First.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Type" ) ) )
475 			{
476 				if ( aSeq[nInd1][nInd2].Second.equals( sType ) )
477 				{
478 					aResult.realloc( nEntriesNum );
479 					aResult[nEntriesNum-1] = aSeq[nInd1];
480 				}
481 				break;
482 			}
483 
484 	return aResult;
485 }
486 
487 //-----------------------------------------------
getAllRelationships()488 uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OInputCompStream::getAllRelationships()
489 		throw (io::IOException, uno::RuntimeException)
490 {
491 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
492 
493 	if ( m_bDisposed )
494     {
495 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
496 		throw lang::DisposedException();
497     }
498 
499 	if ( m_nStorageType != embed::StorageFormats::OFOPXML )
500 		throw uno::RuntimeException();
501 
502 	// TODO/LATER: in future the information could be taken directly from m_pImpl when possible
503 	uno::Sequence< uno::Sequence< beans::StringPair > > aResult;
504 	for ( sal_Int32 aInd = 0; aInd < m_aProperties.getLength(); aInd++ )
505 		if ( m_aProperties[aInd].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "RelationsInfo" ) ) )
506 		{
507 			if ( m_aProperties[aInd].Value >>= aResult )
508 				return aResult;
509 
510 			break;
511 		}
512 
513 	throw io::IOException(); // the relations info could not be read
514 }
515 
516 //-----------------------------------------------
insertRelationshipByID(const::rtl::OUString &,const uno::Sequence<beans::StringPair> &,::sal_Bool)517 void SAL_CALL OInputCompStream::insertRelationshipByID(  const ::rtl::OUString& /*sID*/, const uno::Sequence< beans::StringPair >& /*aEntry*/, ::sal_Bool /*bReplace*/  )
518 		throw ( container::ElementExistException,
519 				io::IOException,
520 				uno::RuntimeException )
521 {
522 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
523 
524 	if ( m_bDisposed )
525     {
526 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
527 		throw lang::DisposedException();
528     }
529 
530 	if ( m_nStorageType != embed::StorageFormats::OFOPXML )
531 		throw uno::RuntimeException();
532 
533 	throw io::IOException(); // TODO: Access denied
534 }
535 
536 //-----------------------------------------------
removeRelationshipByID(const::rtl::OUString &)537 void SAL_CALL OInputCompStream::removeRelationshipByID(  const ::rtl::OUString& /*sID*/  )
538 		throw ( container::NoSuchElementException,
539 				io::IOException,
540 				uno::RuntimeException )
541 {
542 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
543 
544 	if ( m_bDisposed )
545     {
546 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
547 		throw lang::DisposedException();
548     }
549 
550 	if ( m_nStorageType != embed::StorageFormats::OFOPXML )
551 		throw uno::RuntimeException();
552 
553 	throw io::IOException(); // TODO: Access denied
554 }
555 
556 //-----------------------------------------------
insertRelationships(const uno::Sequence<uno::Sequence<beans::StringPair>> &,::sal_Bool)557 void SAL_CALL OInputCompStream::insertRelationships(  const uno::Sequence< uno::Sequence< beans::StringPair > >& /*aEntries*/, ::sal_Bool /*bReplace*/  )
558 		throw ( container::ElementExistException,
559 				io::IOException,
560 				uno::RuntimeException )
561 {
562 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
563 
564 	if ( m_bDisposed )
565     {
566 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
567 		throw lang::DisposedException();
568     }
569 
570 	if ( m_nStorageType != embed::StorageFormats::OFOPXML )
571 		throw uno::RuntimeException();
572 
573 	throw io::IOException(); // TODO: Access denied
574 }
575 
576 //-----------------------------------------------
clearRelationships()577 void SAL_CALL OInputCompStream::clearRelationships()
578 		throw ( io::IOException,
579 				uno::RuntimeException )
580 {
581 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
582 
583 	if ( m_bDisposed )
584     {
585 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
586 		throw lang::DisposedException();
587     }
588 
589 	if ( m_nStorageType != embed::StorageFormats::OFOPXML )
590 		throw uno::RuntimeException();
591 
592 	throw io::IOException(); // TODO: Access denied
593 }
594 
595 //-----------------------------------------------
getPropertySetInfo()596 uno::Reference< beans::XPropertySetInfo > SAL_CALL OInputCompStream::getPropertySetInfo()
597 		throw ( uno::RuntimeException )
598 {
599 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
600 
601 	if ( m_bDisposed )
602     {
603 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
604 		throw lang::DisposedException();
605     }
606 
607 	//TODO:
608 	return uno::Reference< beans::XPropertySetInfo >();
609 }
610 
611 //-----------------------------------------------
setPropertyValue(const::rtl::OUString & aPropertyName,const uno::Any &)612 void SAL_CALL OInputCompStream::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& /*aValue*/ )
613 		throw ( beans::UnknownPropertyException,
614 				beans::PropertyVetoException,
615 				lang::IllegalArgumentException,
616 				lang::WrappedTargetException,
617 				uno::RuntimeException )
618 {
619 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
620 
621 	if ( m_bDisposed )
622     {
623 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
624 		throw lang::DisposedException();
625     }
626 
627 	// all the provided properties are accessible
628 	for ( sal_Int32 aInd = 0; aInd < m_aProperties.getLength(); aInd++ )
629 	{
630 		if ( m_aProperties[aInd].Name.equals( aPropertyName ) )
631 		{
632 			throw beans::PropertyVetoException(); // TODO
633 		}
634 	}
635 
636 	throw beans::UnknownPropertyException(); // TODO
637 }
638 
639 
640 //-----------------------------------------------
getPropertyValue(const::rtl::OUString & aProp)641 uno::Any SAL_CALL OInputCompStream::getPropertyValue( const ::rtl::OUString& aProp )
642 		throw ( beans::UnknownPropertyException,
643 				lang::WrappedTargetException,
644 				uno::RuntimeException )
645 {
646 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
647 
648 	if ( m_bDisposed )
649     {
650 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
651 		throw lang::DisposedException();
652     }
653 
654 	::rtl::OUString aPropertyName;
655 	if ( aProp.equalsAscii( "IsEncrypted" ) )
656 		aPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Encrypted" ) );
657 	else
658 		aPropertyName = aProp;
659 
660 	if ( aPropertyName.equalsAscii( "RelationsInfo" ) )
661 		throw beans::UnknownPropertyException(); // TODO
662 
663 	// all the provided properties are accessible
664 	for ( sal_Int32 aInd = 0; aInd < m_aProperties.getLength(); aInd++ )
665 	{
666 		if ( m_aProperties[aInd].Name.equals( aPropertyName ) )
667 		{
668 			return m_aProperties[aInd].Value;
669 		}
670 	}
671 
672 	throw beans::UnknownPropertyException(); // TODO
673 }
674 
675 
676 //-----------------------------------------------
addPropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)677 void SAL_CALL OInputCompStream::addPropertyChangeListener(
678     const ::rtl::OUString& /*aPropertyName*/,
679     const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
680 		throw ( beans::UnknownPropertyException,
681 				lang::WrappedTargetException,
682 				uno::RuntimeException )
683 {
684 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
685 
686 	if ( m_bDisposed )
687     {
688 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
689 		throw lang::DisposedException();
690     }
691 
692 	//TODO:
693 }
694 
695 
696 //-----------------------------------------------
removePropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)697 void SAL_CALL OInputCompStream::removePropertyChangeListener(
698     const ::rtl::OUString& /*aPropertyName*/,
699     const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ )
700 		throw ( beans::UnknownPropertyException,
701 				lang::WrappedTargetException,
702 				uno::RuntimeException )
703 {
704 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
705 
706 	if ( m_bDisposed )
707     {
708 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
709 		throw lang::DisposedException();
710     }
711 
712 	//TODO:
713 }
714 
715 
716 //-----------------------------------------------
addVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)717 void SAL_CALL OInputCompStream::addVetoableChangeListener(
718     const ::rtl::OUString& /*PropertyName*/,
719     const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
720 		throw ( beans::UnknownPropertyException,
721 				lang::WrappedTargetException,
722 				uno::RuntimeException )
723 {
724 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
725 
726 	if ( m_bDisposed )
727     {
728 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
729 		throw lang::DisposedException();
730     }
731 
732 	//TODO:
733 }
734 
735 
736 //-----------------------------------------------
removeVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)737 void SAL_CALL OInputCompStream::removeVetoableChangeListener(
738     const ::rtl::OUString& /*PropertyName*/,
739     const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
740 		throw ( beans::UnknownPropertyException,
741 				lang::WrappedTargetException,
742 				uno::RuntimeException )
743 {
744 	::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
745 
746 	if ( m_bDisposed )
747     {
748 		::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
749 		throw lang::DisposedException();
750     }
751 
752 	//TODO:
753 }
754 
755 
756