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