1b5088357SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3b5088357SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4b5088357SAndrew Rist * or more contributor license agreements. See the NOTICE file 5b5088357SAndrew Rist * distributed with this work for additional information 6b5088357SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7b5088357SAndrew Rist * to you under the Apache License, Version 2.0 (the 8b5088357SAndrew Rist * "License"); you may not use this file except in compliance 9b5088357SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11b5088357SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13b5088357SAndrew Rist * Unless required by applicable law or agreed to in writing, 14b5088357SAndrew Rist * software distributed under the License is distributed on an 15b5088357SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16b5088357SAndrew Rist * KIND, either express or implied. See the License for the 17b5088357SAndrew Rist * specific language governing permissions and limitations 18b5088357SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20b5088357SAndrew Rist *************************************************************/ 21b5088357SAndrew Rist 22b5088357SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_unotools.hxx" 26cdf0e10cSrcweir #ifndef GCC 27cdf0e10cSrcweir #endif 28cdf0e10cSrcweir 29cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 30cdf0e10cSrcweir // includes 31cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <unotools/printwarningoptions.hxx> 34cdf0e10cSrcweir #include <unotools/configmgr.hxx> 35cdf0e10cSrcweir #include <unotools/configitem.hxx> 36cdf0e10cSrcweir #include <tools/debug.hxx> 37cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 38cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <itemholder1.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 43cdf0e10cSrcweir // namespaces 44cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 45cdf0e10cSrcweir 46cdf0e10cSrcweir using namespace ::utl ; 47cdf0e10cSrcweir using namespace ::rtl ; 48cdf0e10cSrcweir using namespace ::osl ; 49cdf0e10cSrcweir using namespace ::com::sun::star::uno ; 50cdf0e10cSrcweir 51cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 52cdf0e10cSrcweir // const 53cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 54cdf0e10cSrcweir 55cdf0e10cSrcweir #define ROOTNODE_START OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Print")) 56cdf0e10cSrcweir 57cdf0e10cSrcweir #define PROPERTYNAME_PAPERSIZE OUString(RTL_CONSTASCII_USTRINGPARAM("Warning/PaperSize")) 58cdf0e10cSrcweir #define PROPERTYNAME_PAPERORIENTATION OUString(RTL_CONSTASCII_USTRINGPARAM("Warning/PaperOrientation")) 59cdf0e10cSrcweir #define PROPERTYNAME_NOTFOUND OUString(RTL_CONSTASCII_USTRINGPARAM("Warning/NotFound")) 60cdf0e10cSrcweir #define PROPERTYNAME_TRANSPARENCY OUString(RTL_CONSTASCII_USTRINGPARAM("Warning/Transparency")) 61cdf0e10cSrcweir #define PROPERTYNAME_PRINTINGMODIFIESDOCUMENT OUString(RTL_CONSTASCII_USTRINGPARAM("PrintingModifiesDocument")) 62cdf0e10cSrcweir 63cdf0e10cSrcweir #define PROPERTYHANDLE_PAPERSIZE 0 64cdf0e10cSrcweir #define PROPERTYHANDLE_PAPERORIENTATION 1 65cdf0e10cSrcweir #define PROPERTYHANDLE_NOTFOUND 2 66cdf0e10cSrcweir #define PROPERTYHANDLE_TRANSPARENCY 3 67cdf0e10cSrcweir #define PROPERTYHDL_PRINTINGMODIFIESDOCUMENT 4 68cdf0e10cSrcweir 69cdf0e10cSrcweir #define PROPERTYCOUNT 5 70cdf0e10cSrcweir 71cdf0e10cSrcweir class SvtPrintWarningOptions_Impl : public ConfigItem 72cdf0e10cSrcweir { 73cdf0e10cSrcweir public: 74cdf0e10cSrcweir 75cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 76cdf0e10cSrcweir // constructor / destructor 77cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 78cdf0e10cSrcweir 79cdf0e10cSrcweir SvtPrintWarningOptions_Impl(); 80cdf0e10cSrcweir ~SvtPrintWarningOptions_Impl(); 81cdf0e10cSrcweir 82cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 83cdf0e10cSrcweir // overloaded methods of baseclass 84cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 85cdf0e10cSrcweir 86cdf0e10cSrcweir virtual void Commit(); 87cdf0e10cSrcweir virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames ); 88cdf0e10cSrcweir 89cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 90cdf0e10cSrcweir // public interface 91cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 92cdf0e10cSrcweir 93cdf0e10cSrcweir sal_Bool IsPaperSize() const { return m_bPaperSize; } 94cdf0e10cSrcweir sal_Bool IsPaperOrientation() const { return m_bPaperOrientation; } 95cdf0e10cSrcweir sal_Bool IsNotFound() const { return m_bNotFound; } 96cdf0e10cSrcweir sal_Bool IsTransparency() const { return m_bTransparency; } 97cdf0e10cSrcweir sal_Bool IsModifyDocumentOnPrintingAllowed() const { return m_bModifyDocumentOnPrintingAllowed; } 98cdf0e10cSrcweir 99cdf0e10cSrcweir void SetPaperSize( sal_Bool bState ) { m_bPaperSize = bState; SetModified(); } 100cdf0e10cSrcweir void SetPaperOrientation( sal_Bool bState ) { m_bPaperOrientation = bState; SetModified(); } 101cdf0e10cSrcweir void SetNotFound( sal_Bool bState ) { m_bNotFound = bState; SetModified(); } 102cdf0e10cSrcweir void SetTransparency( sal_Bool bState ) { m_bTransparency = bState; SetModified(); } 103cdf0e10cSrcweir void SetModifyDocumentOnPrintingAllowed( sal_Bool bState ) { m_bModifyDocumentOnPrintingAllowed = bState; SetModified(); } 104cdf0e10cSrcweir 105cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 106cdf0e10cSrcweir // private methods 107cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 108cdf0e10cSrcweir 109cdf0e10cSrcweir private: 110cdf0e10cSrcweir 111cdf0e10cSrcweir static Sequence< OUString > impl_GetPropertyNames(); 112cdf0e10cSrcweir 113cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 114cdf0e10cSrcweir // private member 115cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 116cdf0e10cSrcweir 117cdf0e10cSrcweir private: 118cdf0e10cSrcweir 119cdf0e10cSrcweir sal_Bool m_bPaperSize; 120cdf0e10cSrcweir sal_Bool m_bPaperOrientation; 121cdf0e10cSrcweir sal_Bool m_bNotFound; 122cdf0e10cSrcweir sal_Bool m_bTransparency; 123cdf0e10cSrcweir sal_Bool m_bModifyDocumentOnPrintingAllowed; 124cdf0e10cSrcweir }; 125cdf0e10cSrcweir 126cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 127cdf0e10cSrcweir // definitions 128cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 129cdf0e10cSrcweir 130cdf0e10cSrcweir //***************************************************************************************************************** 131cdf0e10cSrcweir // constructor 132cdf0e10cSrcweir //***************************************************************************************************************** 133cdf0e10cSrcweir SvtPrintWarningOptions_Impl::SvtPrintWarningOptions_Impl() : 134cdf0e10cSrcweir ConfigItem( ROOTNODE_START ), 135cdf0e10cSrcweir m_bPaperSize( sal_False ), 136cdf0e10cSrcweir m_bPaperOrientation( sal_False ), 137cdf0e10cSrcweir m_bNotFound( sal_False ), 138cdf0e10cSrcweir m_bTransparency( sal_True ), 139cdf0e10cSrcweir m_bModifyDocumentOnPrintingAllowed( sal_True ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir Sequence< OUString > seqNames( impl_GetPropertyNames() ); 142cdf0e10cSrcweir Sequence< Any > seqValues( GetProperties( seqNames ) ); 143cdf0e10cSrcweir 144cdf0e10cSrcweir DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtPrintWarningOptions_Impl::SvtPrintWarningOptions_Impl()\nI miss some values of configuration keys!\n" ); 145cdf0e10cSrcweir 146cdf0e10cSrcweir // Copy values from list in right order to our internal member. 147cdf0e10cSrcweir sal_Int32 nPropertyCount = seqValues.getLength(); 148cdf0e10cSrcweir sal_Int32 nProperty = 0; 149cdf0e10cSrcweir 150cdf0e10cSrcweir for( nProperty=0; nProperty<nPropertyCount; ++nProperty ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtPrintWarningOptions_Impl::SvtPrintWarningOptions_Impl()\nInvalid property value for property detected!\n" ); 153cdf0e10cSrcweir 154cdf0e10cSrcweir switch( nProperty ) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir case PROPERTYHANDLE_PAPERSIZE: 157cdf0e10cSrcweir { 158cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" ); 159cdf0e10cSrcweir seqValues[nProperty] >>= m_bPaperSize; 160cdf0e10cSrcweir } 161cdf0e10cSrcweir break; 162cdf0e10cSrcweir 163cdf0e10cSrcweir case PROPERTYHANDLE_PAPERORIENTATION: 164cdf0e10cSrcweir { 165cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" ); 166cdf0e10cSrcweir seqValues[nProperty] >>= m_bPaperOrientation; 167cdf0e10cSrcweir } 168cdf0e10cSrcweir break; 169cdf0e10cSrcweir 170cdf0e10cSrcweir case PROPERTYHANDLE_NOTFOUND: 171cdf0e10cSrcweir { 172cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" ); 173cdf0e10cSrcweir seqValues[nProperty] >>= m_bNotFound; 174cdf0e10cSrcweir } 175cdf0e10cSrcweir break; 176cdf0e10cSrcweir 177cdf0e10cSrcweir case PROPERTYHANDLE_TRANSPARENCY: 178cdf0e10cSrcweir { 179cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" ); 180cdf0e10cSrcweir seqValues[nProperty] >>= m_bTransparency; 181cdf0e10cSrcweir } 182cdf0e10cSrcweir break; 183cdf0e10cSrcweir case PROPERTYHDL_PRINTINGMODIFIESDOCUMENT: 184cdf0e10cSrcweir { 185cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "Invalid type" ); 186cdf0e10cSrcweir seqValues[nProperty] >>= m_bModifyDocumentOnPrintingAllowed; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir break; 189cdf0e10cSrcweir 190cdf0e10cSrcweir } 191cdf0e10cSrcweir } 192cdf0e10cSrcweir } 193cdf0e10cSrcweir 194cdf0e10cSrcweir //***************************************************************************************************************** 195cdf0e10cSrcweir // destructor 196cdf0e10cSrcweir //***************************************************************************************************************** 197cdf0e10cSrcweir SvtPrintWarningOptions_Impl::~SvtPrintWarningOptions_Impl() 198cdf0e10cSrcweir { 199cdf0e10cSrcweir if( IsModified() ) 200cdf0e10cSrcweir Commit(); 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir //***************************************************************************************************************** 204cdf0e10cSrcweir // Commit 205cdf0e10cSrcweir //***************************************************************************************************************** 206cdf0e10cSrcweir void SvtPrintWarningOptions_Impl::Commit() 207cdf0e10cSrcweir { 208cdf0e10cSrcweir Sequence< OUString > aSeqNames( impl_GetPropertyNames() ); 209cdf0e10cSrcweir Sequence< Any > aSeqValues( aSeqNames.getLength() ); 210cdf0e10cSrcweir 211cdf0e10cSrcweir for( sal_Int32 nProperty = 0, nCount = aSeqNames.getLength(); nProperty < nCount; ++nProperty ) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir switch( nProperty ) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir case PROPERTYHANDLE_PAPERSIZE: 216cdf0e10cSrcweir aSeqValues[nProperty] <<= m_bPaperSize; 217cdf0e10cSrcweir break; 218cdf0e10cSrcweir 219cdf0e10cSrcweir case PROPERTYHANDLE_PAPERORIENTATION: 220cdf0e10cSrcweir aSeqValues[nProperty] <<= m_bPaperOrientation; 221cdf0e10cSrcweir break; 222cdf0e10cSrcweir 223cdf0e10cSrcweir case PROPERTYHANDLE_NOTFOUND: 224cdf0e10cSrcweir aSeqValues[nProperty] <<= m_bNotFound; 225cdf0e10cSrcweir break; 226cdf0e10cSrcweir 227cdf0e10cSrcweir case PROPERTYHANDLE_TRANSPARENCY: 228cdf0e10cSrcweir aSeqValues[nProperty] <<= m_bTransparency; 229cdf0e10cSrcweir break; 230cdf0e10cSrcweir case PROPERTYHDL_PRINTINGMODIFIESDOCUMENT: 231cdf0e10cSrcweir aSeqValues[nProperty] <<= m_bModifyDocumentOnPrintingAllowed; 232cdf0e10cSrcweir break; 233cdf0e10cSrcweir } 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir PutProperties( aSeqNames, aSeqValues ); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir 239cdf0e10cSrcweir void SvtPrintWarningOptions_Impl::Notify( const Sequence< rtl::OUString >& ) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir //***************************************************************************************************************** 244cdf0e10cSrcweir // private method 245cdf0e10cSrcweir //***************************************************************************************************************** 246cdf0e10cSrcweir Sequence< OUString > SvtPrintWarningOptions_Impl::impl_GetPropertyNames() 247cdf0e10cSrcweir { 248cdf0e10cSrcweir // Build static list of configuration key names. 249cdf0e10cSrcweir static const OUString pProperties[] = 250cdf0e10cSrcweir { 251cdf0e10cSrcweir PROPERTYNAME_PAPERSIZE, 252cdf0e10cSrcweir PROPERTYNAME_PAPERORIENTATION, 253cdf0e10cSrcweir PROPERTYNAME_NOTFOUND, 254cdf0e10cSrcweir PROPERTYNAME_TRANSPARENCY, 255cdf0e10cSrcweir PROPERTYNAME_PRINTINGMODIFIESDOCUMENT 256cdf0e10cSrcweir }; 257cdf0e10cSrcweir 258cdf0e10cSrcweir // Initialize return sequence with these list ... 259cdf0e10cSrcweir static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT ); 260cdf0e10cSrcweir 261cdf0e10cSrcweir return seqPropertyNames; 262cdf0e10cSrcweir } 263cdf0e10cSrcweir 264cdf0e10cSrcweir //***************************************************************************************************************** 265cdf0e10cSrcweir // initialize static member 266cdf0e10cSrcweir // DON'T DO IT IN YOUR HEADER! 267cdf0e10cSrcweir // see definition for further informations 268cdf0e10cSrcweir //***************************************************************************************************************** 269cdf0e10cSrcweir SvtPrintWarningOptions_Impl* SvtPrintWarningOptions::m_pDataContainer = NULL; 270cdf0e10cSrcweir sal_Int32 SvtPrintWarningOptions::m_nRefCount = 0; 271cdf0e10cSrcweir 272cdf0e10cSrcweir //***************************************************************************************************************** 273cdf0e10cSrcweir // constructor 274cdf0e10cSrcweir //***************************************************************************************************************** 275cdf0e10cSrcweir SvtPrintWarningOptions::SvtPrintWarningOptions() 276cdf0e10cSrcweir { 277cdf0e10cSrcweir // Global access, must be guarded (multithreading!). 278cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 279*b12a77c9Smseidel // Increase our refcount ... 280cdf0e10cSrcweir ++m_nRefCount; 281*b12a77c9Smseidel // ... and initialize our data container only if it not already! 282cdf0e10cSrcweir if( m_pDataContainer == NULL ) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir m_pDataContainer = new SvtPrintWarningOptions_Impl(); 285cdf0e10cSrcweir ItemHolder1::holdConfigItem(E_PRINTWARNINGOPTIONS); 286cdf0e10cSrcweir } 287cdf0e10cSrcweir } 288cdf0e10cSrcweir 289cdf0e10cSrcweir //***************************************************************************************************************** 290cdf0e10cSrcweir // destructor 291cdf0e10cSrcweir //***************************************************************************************************************** 292cdf0e10cSrcweir SvtPrintWarningOptions::~SvtPrintWarningOptions() 293cdf0e10cSrcweir { 294cdf0e10cSrcweir // Global access, must be guarded (multithreading!) 295cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 296*b12a77c9Smseidel // Decrease our refcount. 297cdf0e10cSrcweir --m_nRefCount; 298cdf0e10cSrcweir // If last instance was deleted ... 299*b12a77c9Smseidel // we must destroy our static data container! 300cdf0e10cSrcweir if( m_nRefCount <= 0 ) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir delete m_pDataContainer; 303cdf0e10cSrcweir m_pDataContainer = NULL; 304cdf0e10cSrcweir } 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir //***************************************************************************************************************** 308cdf0e10cSrcweir // public method 309cdf0e10cSrcweir //***************************************************************************************************************** 310cdf0e10cSrcweir sal_Bool SvtPrintWarningOptions::IsPaperSize() const 311cdf0e10cSrcweir { 312cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 313cdf0e10cSrcweir return m_pDataContainer->IsPaperSize(); 314cdf0e10cSrcweir } 315cdf0e10cSrcweir 316cdf0e10cSrcweir //***************************************************************************************************************** 317cdf0e10cSrcweir // public method 318cdf0e10cSrcweir //***************************************************************************************************************** 319cdf0e10cSrcweir sal_Bool SvtPrintWarningOptions::IsPaperOrientation() const 320cdf0e10cSrcweir { 321cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 322cdf0e10cSrcweir return m_pDataContainer->IsPaperOrientation(); 323cdf0e10cSrcweir } 324cdf0e10cSrcweir 325cdf0e10cSrcweir //***************************************************************************************************************** 326cdf0e10cSrcweir // public method 327cdf0e10cSrcweir //***************************************************************************************************************** 328cdf0e10cSrcweir sal_Bool SvtPrintWarningOptions::IsNotFound() const 329cdf0e10cSrcweir { 330cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 331cdf0e10cSrcweir return m_pDataContainer->IsNotFound(); 332cdf0e10cSrcweir } 333cdf0e10cSrcweir 334cdf0e10cSrcweir //***************************************************************************************************************** 335cdf0e10cSrcweir // public method 336cdf0e10cSrcweir //***************************************************************************************************************** 337cdf0e10cSrcweir sal_Bool SvtPrintWarningOptions::IsTransparency() const 338cdf0e10cSrcweir { 339cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 340cdf0e10cSrcweir return m_pDataContainer->IsTransparency(); 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir //***************************************************************************************************************** 344cdf0e10cSrcweir // public method 345cdf0e10cSrcweir //***************************************************************************************************************** 346cdf0e10cSrcweir void SvtPrintWarningOptions::SetPaperSize( sal_Bool bState ) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 349cdf0e10cSrcweir m_pDataContainer->SetPaperSize( bState ); 350cdf0e10cSrcweir } 351cdf0e10cSrcweir 352cdf0e10cSrcweir //***************************************************************************************************************** 353cdf0e10cSrcweir // public method 354cdf0e10cSrcweir //***************************************************************************************************************** 355cdf0e10cSrcweir void SvtPrintWarningOptions::SetPaperOrientation( sal_Bool bState ) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 358cdf0e10cSrcweir m_pDataContainer->SetPaperOrientation( bState ); 359cdf0e10cSrcweir } 360cdf0e10cSrcweir 361cdf0e10cSrcweir //***************************************************************************************************************** 362cdf0e10cSrcweir // public method 363cdf0e10cSrcweir //***************************************************************************************************************** 364cdf0e10cSrcweir void SvtPrintWarningOptions::SetNotFound( sal_Bool bState ) 365cdf0e10cSrcweir { 366cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 367cdf0e10cSrcweir m_pDataContainer->SetNotFound( bState ); 368cdf0e10cSrcweir } 369cdf0e10cSrcweir 370cdf0e10cSrcweir //***************************************************************************************************************** 371cdf0e10cSrcweir // public method 372cdf0e10cSrcweir //***************************************************************************************************************** 373cdf0e10cSrcweir void SvtPrintWarningOptions::SetTransparency( sal_Bool bState ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 376cdf0e10cSrcweir m_pDataContainer->SetTransparency( bState ); 377cdf0e10cSrcweir } 378cdf0e10cSrcweir // ----------------------------------------------------------------------------- 379cdf0e10cSrcweir 380cdf0e10cSrcweir sal_Bool SvtPrintWarningOptions::IsModifyDocumentOnPrintingAllowed() const 381cdf0e10cSrcweir { 382cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 383cdf0e10cSrcweir return m_pDataContainer->IsModifyDocumentOnPrintingAllowed(); 384cdf0e10cSrcweir } 385cdf0e10cSrcweir 386cdf0e10cSrcweir // ----------------------------------------------------------------------------- 387cdf0e10cSrcweir 388cdf0e10cSrcweir void SvtPrintWarningOptions::SetModifyDocumentOnPrintingAllowed( sal_Bool bState ) 389cdf0e10cSrcweir { 390cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 391cdf0e10cSrcweir m_pDataContainer->SetModifyDocumentOnPrintingAllowed( bState ) ; 392cdf0e10cSrcweir } 393cdf0e10cSrcweir 394cdf0e10cSrcweir //***************************************************************************************************************** 395cdf0e10cSrcweir // private method 396cdf0e10cSrcweir //***************************************************************************************************************** 397cdf0e10cSrcweir Mutex& SvtPrintWarningOptions::GetOwnStaticMutex() 398cdf0e10cSrcweir { 399cdf0e10cSrcweir // Initialize static mutex only for one time! 400cdf0e10cSrcweir static Mutex* pMutex = NULL; 401cdf0e10cSrcweir // If these method first called (Mutex not already exist!) ... 402cdf0e10cSrcweir if( pMutex == NULL ) 403cdf0e10cSrcweir { 404cdf0e10cSrcweir // ... we must create a new one. Protect follow code with the global mutex - 405cdf0e10cSrcweir // It must be - we create a static variable! 406cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() ); 407*b12a77c9Smseidel // We must check our pointer again - because it can be that another instance of our class will be faster than these! 408cdf0e10cSrcweir if( pMutex == NULL ) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir // Create the new mutex and set it for return on static variable. 411cdf0e10cSrcweir static Mutex aMutex; 412cdf0e10cSrcweir pMutex = &aMutex; 413cdf0e10cSrcweir } 414cdf0e10cSrcweir } 415cdf0e10cSrcweir // Return new created or already existing mutex object. 416cdf0e10cSrcweir return *pMutex; 417cdf0e10cSrcweir } 418