15900e8ecSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 35900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 45900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file 55900e8ecSAndrew Rist * distributed with this work for additional information 65900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file 75900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the 85900e8ecSAndrew Rist * "License"); you may not use this file except in compliance 95900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 115900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 135900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing, 145900e8ecSAndrew Rist * software distributed under the License is distributed on an 155900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 165900e8ecSAndrew Rist * KIND, either express or implied. See the License for the 175900e8ecSAndrew Rist * specific language governing permissions and limitations 185900e8ecSAndrew Rist * under the License. 19cdf0e10cSrcweir * 205900e8ecSAndrew Rist *************************************************************/ 215900e8ecSAndrew Rist 225900e8ecSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svtools.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 28cdf0e10cSrcweir // includes 29cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <svtools/printoptions.hxx> 32cdf0e10cSrcweir #include <unotools/configmgr.hxx> 33cdf0e10cSrcweir #include <unotools/configitem.hxx> 34cdf0e10cSrcweir #include <tools/debug.hxx> 35cdf0e10cSrcweir #include <vcl/print.hxx> 36cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 37cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ 40cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir 43cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ 44cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 45cdf0e10cSrcweir #endif 46cdf0e10cSrcweir 47cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ 48cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp> 49cdf0e10cSrcweir #endif 50cdf0e10cSrcweir 51cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ 52cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp> 53cdf0e10cSrcweir #endif 54cdf0e10cSrcweir 55cdf0e10cSrcweir #ifndef _COMPHELPER_CONFIGURATIONHELPER_HXX_ 56cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx> 57cdf0e10cSrcweir #endif 58cdf0e10cSrcweir 59cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX_ 60cdf0e10cSrcweir #include <unotools/processfactory.hxx> 61cdf0e10cSrcweir #endif 62cdf0e10cSrcweir 63cdf0e10cSrcweir #ifndef _SVT_LOGHELPER_HXX 64cdf0e10cSrcweir #include <unotools/loghelper.hxx> 65cdf0e10cSrcweir #endif 66cdf0e10cSrcweir 67cdf0e10cSrcweir #include <itemholder2.hxx> 68cdf0e10cSrcweir 69cdf0e10cSrcweir 70cdf0e10cSrcweir // ----------- 71cdf0e10cSrcweir // - statics - 72cdf0e10cSrcweir // ----------- 73cdf0e10cSrcweir 74cdf0e10cSrcweir static sal_uInt16 aDPIArray[] = { 72, 96, 150, 200, 300, 600 }; 75cdf0e10cSrcweir 76cdf0e10cSrcweir #define DPI_COUNT (sizeof(aDPIArray)/sizeof(aDPIArray[0 ])) 77cdf0e10cSrcweir 78cdf0e10cSrcweir // ----------- 79cdf0e10cSrcweir // - Defines - 80cdf0e10cSrcweir // ----------- 81cdf0e10cSrcweir 82cdf0e10cSrcweir #define ROOTNODE_START OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Print/Option")) 83cdf0e10cSrcweir #define ROOTNODE_PRINTOPTION OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Common/Print/Option")) 84cdf0e10cSrcweir 85cdf0e10cSrcweir #define PROPERTYNAME_REDUCETRANSPARENCY OUString(RTL_CONSTASCII_USTRINGPARAM("ReduceTransparency")) 86cdf0e10cSrcweir #define PROPERTYNAME_REDUCEDTRANSPARENCYMODE OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedTransparencyMode")) 87cdf0e10cSrcweir #define PROPERTYNAME_REDUCEGRADIENTS OUString(RTL_CONSTASCII_USTRINGPARAM("ReduceGradients")) 88cdf0e10cSrcweir #define PROPERTYNAME_REDUCEDGRADIENTMODE OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedGradientMode")) 89cdf0e10cSrcweir #define PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedGradientStepCount")) 90cdf0e10cSrcweir #define PROPERTYNAME_REDUCEBITMAPS OUString(RTL_CONSTASCII_USTRINGPARAM("ReduceBitmaps")) 91cdf0e10cSrcweir #define PROPERTYNAME_REDUCEDBITMAPMODE OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedBitmapMode")) 92cdf0e10cSrcweir #define PROPERTYNAME_REDUCEDBITMAPRESOLUTION OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedBitmapResolution")) 93cdf0e10cSrcweir #define PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedBitmapIncludesTransparency")) 94cdf0e10cSrcweir #define PROPERTYNAME_CONVERTTOGREYSCALES OUString(RTL_CONSTASCII_USTRINGPARAM("ConvertToGreyscales")) 95cdf0e10cSrcweir 96cdf0e10cSrcweir // -------------- 97cdf0e10cSrcweir // - Namespaces - 98cdf0e10cSrcweir // -------------- 99cdf0e10cSrcweir 100cdf0e10cSrcweir using namespace ::utl; 101cdf0e10cSrcweir using namespace ::rtl; 102cdf0e10cSrcweir using namespace ::osl; 103cdf0e10cSrcweir using namespace ::com::sun::star::uno; 104cdf0e10cSrcweir namespace css = com::sun::star; 105cdf0e10cSrcweir 106cdf0e10cSrcweir // ----------- 107cdf0e10cSrcweir // - statics - 108cdf0e10cSrcweir // ----------- 109cdf0e10cSrcweir 110cdf0e10cSrcweir static SvtPrintOptions_Impl* pPrinterOptionsDataContainer = NULL; 111cdf0e10cSrcweir static SvtPrintOptions_Impl* pPrintFileOptionsDataContainer = NULL; 112cdf0e10cSrcweir 113cdf0e10cSrcweir SvtPrintOptions_Impl* SvtPrinterOptions::m_pStaticDataContainer = NULL; 114cdf0e10cSrcweir sal_Int32 SvtPrinterOptions::m_nRefCount = 0; 115cdf0e10cSrcweir 116cdf0e10cSrcweir SvtPrintOptions_Impl* SvtPrintFileOptions::m_pStaticDataContainer = NULL; 117cdf0e10cSrcweir sal_Int32 SvtPrintFileOptions::m_nRefCount = 0; 118cdf0e10cSrcweir 119cdf0e10cSrcweir // ------------------------ 120cdf0e10cSrcweir // - SvtPrintOptions_Impl - 121cdf0e10cSrcweir // ------------------------ 122cdf0e10cSrcweir 123cdf0e10cSrcweir class SvtPrintOptions_Impl 124cdf0e10cSrcweir { 125cdf0e10cSrcweir public: 126cdf0e10cSrcweir 127cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 128cdf0e10cSrcweir // constructor / destructor 129cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 130cdf0e10cSrcweir 131cdf0e10cSrcweir SvtPrintOptions_Impl( const OUString& rConfigRoot ); 132cdf0e10cSrcweir ~SvtPrintOptions_Impl(); 133cdf0e10cSrcweir 134cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 135cdf0e10cSrcweir // public interface 136cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 137cdf0e10cSrcweir 138cdf0e10cSrcweir sal_Bool IsReduceTransparency() const ; 139cdf0e10cSrcweir sal_Int16 GetReducedTransparencyMode() const ; 140cdf0e10cSrcweir sal_Bool IsReduceGradients() const ; 141cdf0e10cSrcweir sal_Int16 GetReducedGradientMode() const ; 142cdf0e10cSrcweir sal_Int16 GetReducedGradientStepCount() const ; 143cdf0e10cSrcweir sal_Bool IsReduceBitmaps() const ; 144cdf0e10cSrcweir sal_Int16 GetReducedBitmapMode() const ; 145cdf0e10cSrcweir sal_Int16 GetReducedBitmapResolution() const ; 146cdf0e10cSrcweir sal_Bool IsReducedBitmapIncludesTransparency() const ; 147cdf0e10cSrcweir sal_Bool IsConvertToGreyscales() const; 148cdf0e10cSrcweir 149cdf0e10cSrcweir void SetReduceTransparency( sal_Bool bState ) ; 150cdf0e10cSrcweir void SetReducedTransparencyMode( sal_Int16 nMode ) ; 151cdf0e10cSrcweir void SetReduceGradients( sal_Bool bState ) ; 152cdf0e10cSrcweir void SetReducedGradientMode( sal_Int16 nMode ) ; 153cdf0e10cSrcweir void SetReducedGradientStepCount( sal_Int16 nStepCount ) ; 154cdf0e10cSrcweir void SetReduceBitmaps( sal_Bool bState ) ; 155cdf0e10cSrcweir void SetReducedBitmapMode( sal_Int16 nMode ) ; 156cdf0e10cSrcweir void SetReducedBitmapResolution( sal_Int16 nResolution ) ; 157cdf0e10cSrcweir void SetReducedBitmapIncludesTransparency( sal_Bool bState ) ; 158cdf0e10cSrcweir void SetConvertToGreyscales( sal_Bool bState ) ; 159cdf0e10cSrcweir 160cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 161cdf0e10cSrcweir // private API 162cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 163cdf0e10cSrcweir 164cdf0e10cSrcweir private: 165cdf0e10cSrcweir void impl_setValue (const ::rtl::OUString& sProp, 166cdf0e10cSrcweir ::sal_Bool bNew ); 167cdf0e10cSrcweir void impl_setValue (const ::rtl::OUString& sProp, 168cdf0e10cSrcweir ::sal_Int16 nNew ); 169cdf0e10cSrcweir 170cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 171cdf0e10cSrcweir // private member 172cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 173cdf0e10cSrcweir 174cdf0e10cSrcweir private: 175cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > m_xCfg; 176cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > m_xNode; 177cdf0e10cSrcweir }; 178cdf0e10cSrcweir 179cdf0e10cSrcweir SvtPrintOptions_Impl::SvtPrintOptions_Impl(const OUString& rConfigRoot) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir try 182cdf0e10cSrcweir { 183cdf0e10cSrcweir m_xCfg = css::uno::Reference< css::container::XNameAccess >( 184cdf0e10cSrcweir ::comphelper::ConfigurationHelper::openConfig( 185cdf0e10cSrcweir utl::getProcessServiceFactory(), 186cdf0e10cSrcweir ROOTNODE_PRINTOPTION, 187cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_STANDARD), 188cdf0e10cSrcweir css::uno::UNO_QUERY); 189cdf0e10cSrcweir 190cdf0e10cSrcweir if (m_xCfg.is()) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir UniString sTmp = UniString(rConfigRoot); 193cdf0e10cSrcweir xub_StrLen nTokenCount = sTmp.GetTokenCount('/'); 194cdf0e10cSrcweir sTmp = sTmp.GetToken(nTokenCount - 1, '/'); 195cdf0e10cSrcweir m_xCfg->getByName(OUString(sTmp.GetBuffer())) >>= m_xNode; 196cdf0e10cSrcweir } 197cdf0e10cSrcweir } 198cdf0e10cSrcweir catch (const css::uno::Exception& ex) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir m_xNode.clear(); 201cdf0e10cSrcweir m_xCfg.clear(); 202cdf0e10cSrcweir LogHelper::logIt(ex); 203cdf0e10cSrcweir } 204cdf0e10cSrcweir } 205cdf0e10cSrcweir 206cdf0e10cSrcweir sal_Bool SvtPrintOptions_Impl::IsReduceTransparency() const 207cdf0e10cSrcweir { 208cdf0e10cSrcweir sal_Bool bRet = sal_False; 209cdf0e10cSrcweir try 210cdf0e10cSrcweir { 211cdf0e10cSrcweir if (m_xNode.is()) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertySet > xSet(m_xNode, css::uno::UNO_QUERY); 214cdf0e10cSrcweir if (xSet.is()) 215cdf0e10cSrcweir xSet->getPropertyValue(PROPERTYNAME_REDUCETRANSPARENCY) >>= bRet; 216cdf0e10cSrcweir } 217cdf0e10cSrcweir } 218cdf0e10cSrcweir catch (const css::uno::Exception& ex) 219cdf0e10cSrcweir { 220cdf0e10cSrcweir LogHelper::logIt(ex); 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir return bRet; 224cdf0e10cSrcweir } 225cdf0e10cSrcweir 226cdf0e10cSrcweir sal_Int16 SvtPrintOptions_Impl::GetReducedTransparencyMode() const 227cdf0e10cSrcweir { 228cdf0e10cSrcweir sal_Int16 nRet = 0; 229cdf0e10cSrcweir try 230cdf0e10cSrcweir { 231cdf0e10cSrcweir if (m_xNode.is()) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertySet > xSet(m_xNode, css::uno::UNO_QUERY); 234cdf0e10cSrcweir if (xSet.is()) 235cdf0e10cSrcweir xSet->getPropertyValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE) >>= nRet; 236cdf0e10cSrcweir } 237cdf0e10cSrcweir } 238cdf0e10cSrcweir catch (const css::uno::Exception& ex) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir LogHelper::logIt(ex); 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir return nRet; 244cdf0e10cSrcweir } 245cdf0e10cSrcweir 246cdf0e10cSrcweir sal_Bool SvtPrintOptions_Impl::IsReduceGradients() const 247cdf0e10cSrcweir { 248cdf0e10cSrcweir sal_Bool bRet = sal_False; 249cdf0e10cSrcweir try 250cdf0e10cSrcweir { 251cdf0e10cSrcweir if (m_xNode.is()) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); 254cdf0e10cSrcweir if (xSet.is()) 255cdf0e10cSrcweir { 256cdf0e10cSrcweir xSet->getPropertyValue(PROPERTYNAME_REDUCEGRADIENTS) >>= bRet; 257cdf0e10cSrcweir } 258cdf0e10cSrcweir } 259cdf0e10cSrcweir } 260cdf0e10cSrcweir catch (const css::uno::Exception& ex) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir LogHelper::logIt(ex); 263cdf0e10cSrcweir } 264cdf0e10cSrcweir 265cdf0e10cSrcweir return bRet; 266cdf0e10cSrcweir } 267cdf0e10cSrcweir 268cdf0e10cSrcweir sal_Int16 SvtPrintOptions_Impl::GetReducedGradientMode() const 269cdf0e10cSrcweir { 270cdf0e10cSrcweir sal_Int16 nRet = 0; 271cdf0e10cSrcweir try 272cdf0e10cSrcweir { 273cdf0e10cSrcweir if (m_xNode.is()) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); 276cdf0e10cSrcweir if (xSet.is()) 277cdf0e10cSrcweir { 278cdf0e10cSrcweir xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTMODE) >>= nRet; 279cdf0e10cSrcweir } 280cdf0e10cSrcweir } 281cdf0e10cSrcweir } 282cdf0e10cSrcweir catch (const css::uno::Exception& ex) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir LogHelper::logIt(ex); 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir return nRet; 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir sal_Int16 SvtPrintOptions_Impl::GetReducedGradientStepCount() const 291cdf0e10cSrcweir { 292cdf0e10cSrcweir sal_Int16 nRet = 64; 293cdf0e10cSrcweir try 294cdf0e10cSrcweir { 295cdf0e10cSrcweir if (m_xNode.is()) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); 298cdf0e10cSrcweir if (xSet.is()) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT) >>= nRet; 301cdf0e10cSrcweir } 302cdf0e10cSrcweir } 303cdf0e10cSrcweir } 304cdf0e10cSrcweir catch (const css::uno::Exception& ex) 305cdf0e10cSrcweir { 306cdf0e10cSrcweir LogHelper::logIt(ex); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir 309cdf0e10cSrcweir return nRet; 310cdf0e10cSrcweir } 311cdf0e10cSrcweir 312cdf0e10cSrcweir sal_Bool SvtPrintOptions_Impl::IsReduceBitmaps() const 313cdf0e10cSrcweir { 314cdf0e10cSrcweir sal_Bool bRet = sal_False; 315cdf0e10cSrcweir try 316cdf0e10cSrcweir { 317cdf0e10cSrcweir if (m_xNode.is()) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); 320cdf0e10cSrcweir if (xSet.is()) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir xSet->getPropertyValue(PROPERTYNAME_REDUCEBITMAPS) >>= bRet; 323cdf0e10cSrcweir } 324cdf0e10cSrcweir } 325cdf0e10cSrcweir } 326cdf0e10cSrcweir catch (const css::uno::Exception& ex) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir LogHelper::logIt(ex); 329cdf0e10cSrcweir } 330cdf0e10cSrcweir 331cdf0e10cSrcweir return bRet; 332cdf0e10cSrcweir } 333cdf0e10cSrcweir 334cdf0e10cSrcweir sal_Int16 SvtPrintOptions_Impl::GetReducedBitmapMode() const 335cdf0e10cSrcweir { 336cdf0e10cSrcweir sal_Int16 nRet = 1; 337cdf0e10cSrcweir try 338cdf0e10cSrcweir { 339cdf0e10cSrcweir if (m_xNode.is()) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); 342cdf0e10cSrcweir if (xSet.is()) 343cdf0e10cSrcweir { 344cdf0e10cSrcweir xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPMODE) >>= nRet; 345cdf0e10cSrcweir } 346cdf0e10cSrcweir } 347cdf0e10cSrcweir } 348cdf0e10cSrcweir catch (const css::uno::Exception& ex) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir LogHelper::logIt(ex); 351cdf0e10cSrcweir } 352cdf0e10cSrcweir 353cdf0e10cSrcweir return nRet; 354cdf0e10cSrcweir } 355cdf0e10cSrcweir 356cdf0e10cSrcweir sal_Int16 SvtPrintOptions_Impl::GetReducedBitmapResolution() const 357cdf0e10cSrcweir { 358cdf0e10cSrcweir sal_Int16 nRet = 3; 359cdf0e10cSrcweir try 360cdf0e10cSrcweir { 361cdf0e10cSrcweir if (m_xNode.is()) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); 364cdf0e10cSrcweir if (xSet.is()) 365cdf0e10cSrcweir { 366cdf0e10cSrcweir xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION) >>= nRet; 367cdf0e10cSrcweir } 368cdf0e10cSrcweir } 369cdf0e10cSrcweir } 370cdf0e10cSrcweir catch (const css::uno::Exception& ex) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir LogHelper::logIt(ex); 373cdf0e10cSrcweir } 374cdf0e10cSrcweir 375cdf0e10cSrcweir return nRet; 376cdf0e10cSrcweir } 377cdf0e10cSrcweir 378cdf0e10cSrcweir sal_Bool SvtPrintOptions_Impl::IsReducedBitmapIncludesTransparency() const 379cdf0e10cSrcweir { 380cdf0e10cSrcweir sal_Bool bRet = sal_True; 381cdf0e10cSrcweir try 382cdf0e10cSrcweir { 383cdf0e10cSrcweir if (m_xNode.is()) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); 386cdf0e10cSrcweir if (xSet.is()) 387cdf0e10cSrcweir { 388cdf0e10cSrcweir xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY) >>= bRet; 389cdf0e10cSrcweir } 390cdf0e10cSrcweir } 391cdf0e10cSrcweir } 392cdf0e10cSrcweir catch (const css::uno::Exception& ex) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir LogHelper::logIt(ex); 395cdf0e10cSrcweir } 396cdf0e10cSrcweir 397cdf0e10cSrcweir return bRet; 398cdf0e10cSrcweir } 399cdf0e10cSrcweir 400cdf0e10cSrcweir sal_Bool SvtPrintOptions_Impl::IsConvertToGreyscales() const 401cdf0e10cSrcweir { 402cdf0e10cSrcweir sal_Bool bRet = sal_False; 403cdf0e10cSrcweir try 404cdf0e10cSrcweir { 405cdf0e10cSrcweir if (m_xNode.is()) 406cdf0e10cSrcweir { 407cdf0e10cSrcweir css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); 408cdf0e10cSrcweir if (xSet.is()) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir xSet->getPropertyValue(PROPERTYNAME_CONVERTTOGREYSCALES) >>= bRet; 411cdf0e10cSrcweir } 412cdf0e10cSrcweir } 413cdf0e10cSrcweir } 414cdf0e10cSrcweir catch (const css::uno::Exception& ex) 415cdf0e10cSrcweir { 416cdf0e10cSrcweir LogHelper::logIt(ex); 417cdf0e10cSrcweir } 418cdf0e10cSrcweir 419cdf0e10cSrcweir return bRet; 420cdf0e10cSrcweir 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir void SvtPrintOptions_Impl::SetReduceTransparency(sal_Bool bState) 424cdf0e10cSrcweir { 425cdf0e10cSrcweir impl_setValue(PROPERTYNAME_REDUCETRANSPARENCY, bState); 426cdf0e10cSrcweir } 427cdf0e10cSrcweir 428cdf0e10cSrcweir void SvtPrintOptions_Impl::SetReducedTransparencyMode(sal_Int16 nMode) 429cdf0e10cSrcweir { 430cdf0e10cSrcweir impl_setValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE, nMode); 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir void SvtPrintOptions_Impl::SetReduceGradients(sal_Bool bState) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir impl_setValue(PROPERTYNAME_REDUCEGRADIENTS, bState); 436cdf0e10cSrcweir } 437cdf0e10cSrcweir 438cdf0e10cSrcweir void SvtPrintOptions_Impl::SetReducedGradientMode(sal_Int16 nMode) 439cdf0e10cSrcweir { 440cdf0e10cSrcweir impl_setValue(PROPERTYNAME_REDUCEDGRADIENTMODE, nMode); 441cdf0e10cSrcweir } 442cdf0e10cSrcweir 443cdf0e10cSrcweir void SvtPrintOptions_Impl::SetReducedGradientStepCount(sal_Int16 nStepCount ) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir impl_setValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT, nStepCount); 446cdf0e10cSrcweir } 447cdf0e10cSrcweir 448cdf0e10cSrcweir void SvtPrintOptions_Impl::SetReduceBitmaps(sal_Bool bState ) 449cdf0e10cSrcweir { 450cdf0e10cSrcweir impl_setValue(PROPERTYNAME_REDUCEBITMAPS, bState); 451cdf0e10cSrcweir } 452cdf0e10cSrcweir 453cdf0e10cSrcweir void SvtPrintOptions_Impl::SetReducedBitmapMode(sal_Int16 nMode ) 454cdf0e10cSrcweir { 455cdf0e10cSrcweir impl_setValue(PROPERTYNAME_REDUCEDBITMAPMODE, nMode); 456cdf0e10cSrcweir } 457cdf0e10cSrcweir 458cdf0e10cSrcweir void SvtPrintOptions_Impl::SetReducedBitmapResolution(sal_Int16 nResolution ) 459cdf0e10cSrcweir { 460cdf0e10cSrcweir impl_setValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION, nResolution); 461cdf0e10cSrcweir } 462cdf0e10cSrcweir 463cdf0e10cSrcweir void SvtPrintOptions_Impl::SetReducedBitmapIncludesTransparency(sal_Bool bState ) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir impl_setValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY, bState); 466cdf0e10cSrcweir } 467cdf0e10cSrcweir 468cdf0e10cSrcweir void SvtPrintOptions_Impl::SetConvertToGreyscales(sal_Bool bState) 469cdf0e10cSrcweir { 470cdf0e10cSrcweir impl_setValue(PROPERTYNAME_CONVERTTOGREYSCALES, bState); 471cdf0e10cSrcweir } 472cdf0e10cSrcweir 473cdf0e10cSrcweir SvtPrintOptions_Impl::~SvtPrintOptions_Impl() 474cdf0e10cSrcweir { 475cdf0e10cSrcweir m_xNode.clear(); 476cdf0e10cSrcweir m_xCfg.clear(); 477cdf0e10cSrcweir } 478cdf0e10cSrcweir 479cdf0e10cSrcweir void SvtPrintOptions_Impl::impl_setValue (const ::rtl::OUString& sProp, 480cdf0e10cSrcweir ::sal_Bool bNew ) 481cdf0e10cSrcweir { 482cdf0e10cSrcweir try 483cdf0e10cSrcweir { 484cdf0e10cSrcweir if ( ! m_xNode.is()) 485cdf0e10cSrcweir return; 486cdf0e10cSrcweir 487cdf0e10cSrcweir css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); 488cdf0e10cSrcweir if ( ! xSet.is()) 489cdf0e10cSrcweir return; 490cdf0e10cSrcweir 491cdf0e10cSrcweir ::sal_Bool bOld = ! bNew; 492cdf0e10cSrcweir if ( ! (xSet->getPropertyValue(sProp) >>= bOld)) 493cdf0e10cSrcweir return; 494cdf0e10cSrcweir 495cdf0e10cSrcweir if (bOld != bNew) 496cdf0e10cSrcweir { 497cdf0e10cSrcweir xSet->setPropertyValue(sProp, css::uno::makeAny(bNew)); 498cdf0e10cSrcweir ::comphelper::ConfigurationHelper::flush(m_xCfg); 499cdf0e10cSrcweir } 500cdf0e10cSrcweir } 501cdf0e10cSrcweir catch(const css::uno::Exception& ex) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir LogHelper::logIt(ex); 504cdf0e10cSrcweir } 505cdf0e10cSrcweir } 506cdf0e10cSrcweir 507cdf0e10cSrcweir void SvtPrintOptions_Impl::impl_setValue (const ::rtl::OUString& sProp, 508cdf0e10cSrcweir ::sal_Int16 nNew ) 509cdf0e10cSrcweir { 510cdf0e10cSrcweir try 511cdf0e10cSrcweir { 512cdf0e10cSrcweir if ( ! m_xNode.is()) 513cdf0e10cSrcweir return; 514cdf0e10cSrcweir 515cdf0e10cSrcweir css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); 516cdf0e10cSrcweir if ( ! xSet.is()) 517cdf0e10cSrcweir return; 518cdf0e10cSrcweir 519cdf0e10cSrcweir ::sal_Int16 nOld = nNew+1; 520cdf0e10cSrcweir if ( ! (xSet->getPropertyValue(sProp) >>= nOld)) 521cdf0e10cSrcweir return; 522cdf0e10cSrcweir 523cdf0e10cSrcweir if (nOld != nNew) 524cdf0e10cSrcweir { 525cdf0e10cSrcweir xSet->setPropertyValue(sProp, css::uno::makeAny(nNew)); 526cdf0e10cSrcweir ::comphelper::ConfigurationHelper::flush(m_xCfg); 527cdf0e10cSrcweir } 528cdf0e10cSrcweir } 529cdf0e10cSrcweir catch(const css::uno::Exception& ex) 530cdf0e10cSrcweir { 531cdf0e10cSrcweir LogHelper::logIt(ex); 532cdf0e10cSrcweir } 533cdf0e10cSrcweir } 534cdf0e10cSrcweir 535cdf0e10cSrcweir // ----------------------------------------------------------------------------- 536cdf0e10cSrcweir 537cdf0e10cSrcweir 538cdf0e10cSrcweir // ----------------------- 539cdf0e10cSrcweir // - SvtBasePrintOptions - 540cdf0e10cSrcweir // ----------------------- 541cdf0e10cSrcweir 542cdf0e10cSrcweir SvtBasePrintOptions::SvtBasePrintOptions() 543cdf0e10cSrcweir { 544cdf0e10cSrcweir } 545cdf0e10cSrcweir 546cdf0e10cSrcweir // ----------------------------------------------------------------------------- 547cdf0e10cSrcweir 548cdf0e10cSrcweir SvtBasePrintOptions::~SvtBasePrintOptions() 549cdf0e10cSrcweir { 550cdf0e10cSrcweir } 551cdf0e10cSrcweir 552cdf0e10cSrcweir // ----------------------------------------------------------------------------- 553cdf0e10cSrcweir 554cdf0e10cSrcweir Mutex& SvtBasePrintOptions::GetOwnStaticMutex() 555cdf0e10cSrcweir { 556cdf0e10cSrcweir // Initialize static mutex only for one time! 557cdf0e10cSrcweir static Mutex* pMutex = NULL; 558cdf0e10cSrcweir // If these method first called (Mutex not already exist!) ... 559cdf0e10cSrcweir if( pMutex == NULL ) 560cdf0e10cSrcweir { 561cdf0e10cSrcweir // ... we must create a new one. Protect follow code with the global mutex - 562cdf0e10cSrcweir // It must be - we create a static variable! 563cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() ); 564*b12a77c9Smseidel // We must check our pointer again - because it can be that another instance of our class will be faster than these! 565cdf0e10cSrcweir if( pMutex == NULL ) 566cdf0e10cSrcweir { 567cdf0e10cSrcweir // Create the new mutex and set it for return on static variable. 568cdf0e10cSrcweir static Mutex aMutex; 569cdf0e10cSrcweir pMutex = &aMutex; 570cdf0e10cSrcweir } 571cdf0e10cSrcweir } 572cdf0e10cSrcweir // Return new created or already existing mutex object. 573cdf0e10cSrcweir return *pMutex; 574cdf0e10cSrcweir } 575cdf0e10cSrcweir 576cdf0e10cSrcweir // ----------------------------------------------------------------------------- 577cdf0e10cSrcweir 578cdf0e10cSrcweir sal_Bool SvtBasePrintOptions::IsReduceTransparency() const 579cdf0e10cSrcweir { 580cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 581cdf0e10cSrcweir return m_pDataContainer->IsReduceTransparency(); 582cdf0e10cSrcweir } 583cdf0e10cSrcweir 584cdf0e10cSrcweir // ----------------------------------------------------------------------------- 585cdf0e10cSrcweir 586cdf0e10cSrcweir sal_Int16 SvtBasePrintOptions::GetReducedTransparencyMode() const 587cdf0e10cSrcweir { 588cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 589cdf0e10cSrcweir return m_pDataContainer->GetReducedTransparencyMode(); 590cdf0e10cSrcweir } 591cdf0e10cSrcweir 592cdf0e10cSrcweir // ----------------------------------------------------------------------------- 593cdf0e10cSrcweir 594cdf0e10cSrcweir sal_Bool SvtBasePrintOptions::IsReduceGradients() const 595cdf0e10cSrcweir { 596cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 597cdf0e10cSrcweir return m_pDataContainer->IsReduceGradients(); 598cdf0e10cSrcweir } 599cdf0e10cSrcweir 600cdf0e10cSrcweir // ----------------------------------------------------------------------------- 601cdf0e10cSrcweir 602cdf0e10cSrcweir sal_Int16 SvtBasePrintOptions::GetReducedGradientMode() const 603cdf0e10cSrcweir { 604cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 605cdf0e10cSrcweir return m_pDataContainer->GetReducedGradientMode(); 606cdf0e10cSrcweir } 607cdf0e10cSrcweir 608cdf0e10cSrcweir // ----------------------------------------------------------------------------- 609cdf0e10cSrcweir 610cdf0e10cSrcweir sal_Int16 SvtBasePrintOptions::GetReducedGradientStepCount() const 611cdf0e10cSrcweir { 612cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 613cdf0e10cSrcweir return m_pDataContainer->GetReducedGradientStepCount(); 614cdf0e10cSrcweir } 615cdf0e10cSrcweir 616cdf0e10cSrcweir // ----------------------------------------------------------------------------- 617cdf0e10cSrcweir 618cdf0e10cSrcweir sal_Bool SvtBasePrintOptions::IsReduceBitmaps() const 619cdf0e10cSrcweir { 620cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 621cdf0e10cSrcweir return m_pDataContainer->IsReduceBitmaps(); 622cdf0e10cSrcweir } 623cdf0e10cSrcweir 624cdf0e10cSrcweir // ----------------------------------------------------------------------------- 625cdf0e10cSrcweir 626cdf0e10cSrcweir sal_Int16 SvtBasePrintOptions::GetReducedBitmapMode() const 627cdf0e10cSrcweir { 628cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 629cdf0e10cSrcweir return m_pDataContainer->GetReducedBitmapMode(); 630cdf0e10cSrcweir } 631cdf0e10cSrcweir 632cdf0e10cSrcweir // ----------------------------------------------------------------------------- 633cdf0e10cSrcweir 634cdf0e10cSrcweir sal_Int16 SvtBasePrintOptions::GetReducedBitmapResolution() const 635cdf0e10cSrcweir { 636cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 637cdf0e10cSrcweir return m_pDataContainer->GetReducedBitmapResolution(); 638cdf0e10cSrcweir } 639cdf0e10cSrcweir 640cdf0e10cSrcweir // ----------------------------------------------------------------------------- 641cdf0e10cSrcweir 642cdf0e10cSrcweir sal_Bool SvtBasePrintOptions::IsReducedBitmapIncludesTransparency() const 643cdf0e10cSrcweir { 644cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 645cdf0e10cSrcweir return m_pDataContainer->IsReducedBitmapIncludesTransparency(); 646cdf0e10cSrcweir } 647cdf0e10cSrcweir 648cdf0e10cSrcweir // ----------------------------------------------------------------------------- 649cdf0e10cSrcweir 650cdf0e10cSrcweir sal_Bool SvtBasePrintOptions::IsConvertToGreyscales() const 651cdf0e10cSrcweir { 652cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 653cdf0e10cSrcweir return m_pDataContainer->IsConvertToGreyscales(); 654cdf0e10cSrcweir } 655cdf0e10cSrcweir 656cdf0e10cSrcweir // ----------------------------------------------------------------------------- 657cdf0e10cSrcweir 658cdf0e10cSrcweir void SvtBasePrintOptions::SetReduceTransparency( sal_Bool bState ) 659cdf0e10cSrcweir { 660cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 661cdf0e10cSrcweir m_pDataContainer->SetReduceTransparency( bState ) ; 662cdf0e10cSrcweir } 663cdf0e10cSrcweir 664cdf0e10cSrcweir // ----------------------------------------------------------------------------- 665cdf0e10cSrcweir 666cdf0e10cSrcweir void SvtBasePrintOptions::SetReducedTransparencyMode( sal_Int16 nMode ) 667cdf0e10cSrcweir { 668cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 669cdf0e10cSrcweir m_pDataContainer->SetReducedTransparencyMode( nMode ); 670cdf0e10cSrcweir } 671cdf0e10cSrcweir 672cdf0e10cSrcweir // ----------------------------------------------------------------------------- 673cdf0e10cSrcweir 674cdf0e10cSrcweir void SvtBasePrintOptions::SetReduceGradients( sal_Bool bState ) 675cdf0e10cSrcweir { 676cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 677cdf0e10cSrcweir m_pDataContainer->SetReduceGradients( bState ); 678cdf0e10cSrcweir } 679cdf0e10cSrcweir 680cdf0e10cSrcweir // ----------------------------------------------------------------------------- 681cdf0e10cSrcweir 682cdf0e10cSrcweir void SvtBasePrintOptions::SetReducedGradientMode( sal_Int16 nMode ) 683cdf0e10cSrcweir { 684cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 685cdf0e10cSrcweir m_pDataContainer->SetReducedGradientMode( nMode ); 686cdf0e10cSrcweir } 687cdf0e10cSrcweir 688cdf0e10cSrcweir // ----------------------------------------------------------------------------- 689cdf0e10cSrcweir 690cdf0e10cSrcweir void SvtBasePrintOptions::SetReducedGradientStepCount( sal_Int16 nStepCount ) 691cdf0e10cSrcweir { 692cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 693cdf0e10cSrcweir m_pDataContainer->SetReducedGradientStepCount( nStepCount ); 694cdf0e10cSrcweir } 695cdf0e10cSrcweir 696cdf0e10cSrcweir // ----------------------------------------------------------------------------- 697cdf0e10cSrcweir 698cdf0e10cSrcweir void SvtBasePrintOptions::SetReduceBitmaps( sal_Bool bState ) 699cdf0e10cSrcweir { 700cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 701cdf0e10cSrcweir m_pDataContainer->SetReduceBitmaps( bState ); 702cdf0e10cSrcweir } 703cdf0e10cSrcweir 704cdf0e10cSrcweir // ----------------------------------------------------------------------------- 705cdf0e10cSrcweir 706cdf0e10cSrcweir void SvtBasePrintOptions::SetReducedBitmapMode( sal_Int16 nMode ) 707cdf0e10cSrcweir { 708cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 709cdf0e10cSrcweir m_pDataContainer->SetReducedBitmapMode( nMode ); 710cdf0e10cSrcweir } 711cdf0e10cSrcweir 712cdf0e10cSrcweir // ----------------------------------------------------------------------------- 713cdf0e10cSrcweir 714cdf0e10cSrcweir void SvtBasePrintOptions::SetReducedBitmapResolution( sal_Int16 nResolution ) 715cdf0e10cSrcweir { 716cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 717cdf0e10cSrcweir m_pDataContainer->SetReducedBitmapResolution( nResolution ); 718cdf0e10cSrcweir } 719cdf0e10cSrcweir 720cdf0e10cSrcweir // ----------------------------------------------------------------------------- 721cdf0e10cSrcweir 722cdf0e10cSrcweir void SvtBasePrintOptions::SetReducedBitmapIncludesTransparency( sal_Bool bState ) 723cdf0e10cSrcweir { 724cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 725cdf0e10cSrcweir m_pDataContainer->SetReducedBitmapIncludesTransparency( bState ); 726cdf0e10cSrcweir } 727cdf0e10cSrcweir 728cdf0e10cSrcweir // ----------------------------------------------------------------------------- 729cdf0e10cSrcweir 730cdf0e10cSrcweir void SvtBasePrintOptions::SetConvertToGreyscales( sal_Bool bState ) 731cdf0e10cSrcweir { 732cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 733cdf0e10cSrcweir m_pDataContainer->SetConvertToGreyscales( bState ); 734cdf0e10cSrcweir } 735cdf0e10cSrcweir 736cdf0e10cSrcweir // ----------------------------------------------------------------------------- 737cdf0e10cSrcweir 738cdf0e10cSrcweir void SvtBasePrintOptions::GetPrinterOptions( PrinterOptions& rOptions ) const 739cdf0e10cSrcweir { 740cdf0e10cSrcweir rOptions.SetReduceTransparency( IsReduceTransparency() ); 741cdf0e10cSrcweir rOptions.SetReducedTransparencyMode( (PrinterTransparencyMode) GetReducedTransparencyMode() ); 742cdf0e10cSrcweir rOptions.SetReduceGradients( IsReduceGradients() ); 743cdf0e10cSrcweir rOptions.SetReducedGradientMode( (PrinterGradientMode) GetReducedGradientMode() ); 744cdf0e10cSrcweir rOptions.SetReducedGradientStepCount( GetReducedGradientStepCount() ); 745cdf0e10cSrcweir rOptions.SetReduceBitmaps( IsReduceBitmaps() ); 746cdf0e10cSrcweir rOptions.SetReducedBitmapMode( (PrinterBitmapMode) GetReducedBitmapMode() ); 747cdf0e10cSrcweir rOptions.SetReducedBitmapResolution( aDPIArray[ Min( (sal_uInt16) GetReducedBitmapResolution(), (sal_uInt16)( DPI_COUNT - 1 ) ) ] ); 748cdf0e10cSrcweir rOptions.SetReducedBitmapIncludesTransparency( IsReducedBitmapIncludesTransparency() ); 749cdf0e10cSrcweir rOptions.SetConvertToGreyscales( IsConvertToGreyscales() ); 750cdf0e10cSrcweir } 751cdf0e10cSrcweir 752cdf0e10cSrcweir // ----------------------------------------------------------------------------- 753cdf0e10cSrcweir 754cdf0e10cSrcweir void SvtBasePrintOptions::SetPrinterOptions( const PrinterOptions& rOptions ) 755cdf0e10cSrcweir { 756cdf0e10cSrcweir SetReduceTransparency( rOptions.IsReduceTransparency() ); 757cdf0e10cSrcweir SetReducedTransparencyMode( 758cdf0e10cSrcweir sal::static_int_cast< sal_Int16 >( 759cdf0e10cSrcweir rOptions.GetReducedTransparencyMode()) ); 760cdf0e10cSrcweir SetReduceGradients( rOptions.IsReduceGradients() ); 761cdf0e10cSrcweir SetReducedGradientMode( 762cdf0e10cSrcweir sal::static_int_cast< sal_Int16 >(rOptions.GetReducedGradientMode()) ); 763cdf0e10cSrcweir SetReducedGradientStepCount( rOptions.GetReducedGradientStepCount() ); 764cdf0e10cSrcweir SetReduceBitmaps( rOptions.IsReduceBitmaps() ); 765cdf0e10cSrcweir SetReducedBitmapMode( 766cdf0e10cSrcweir sal::static_int_cast< sal_Int16 >(rOptions.GetReducedBitmapMode()) ); 767cdf0e10cSrcweir SetReducedBitmapIncludesTransparency( rOptions.IsReducedBitmapIncludesTransparency() ); 768cdf0e10cSrcweir SetConvertToGreyscales( rOptions.IsConvertToGreyscales() ); 769cdf0e10cSrcweir 770cdf0e10cSrcweir const sal_uInt16 nDPI = rOptions.GetReducedBitmapResolution(); 771cdf0e10cSrcweir 772cdf0e10cSrcweir if( nDPI < aDPIArray[ 0 ] ) 773cdf0e10cSrcweir SetReducedBitmapResolution( 0 ); 774cdf0e10cSrcweir else 775cdf0e10cSrcweir { 776cdf0e10cSrcweir for( long i = ( DPI_COUNT - 1 ); i >= 0; i-- ) 777cdf0e10cSrcweir { 778cdf0e10cSrcweir if( nDPI >= aDPIArray[ i ] ) 779cdf0e10cSrcweir { 780cdf0e10cSrcweir SetReducedBitmapResolution( (sal_Int16) i ); 781cdf0e10cSrcweir i = -1; 782cdf0e10cSrcweir } 783cdf0e10cSrcweir } 784cdf0e10cSrcweir } 785cdf0e10cSrcweir } 786cdf0e10cSrcweir 787cdf0e10cSrcweir // --------------------- 788cdf0e10cSrcweir // - SvtPrinterOptions - 789cdf0e10cSrcweir // --------------------- 790cdf0e10cSrcweir 791cdf0e10cSrcweir SvtPrinterOptions::SvtPrinterOptions() 792cdf0e10cSrcweir { 793cdf0e10cSrcweir // Global access, must be guarded (multithreading!). 794cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 795*b12a77c9Smseidel // Increase our refcount ... 796cdf0e10cSrcweir ++m_nRefCount; 797*b12a77c9Smseidel // ... and initialize our data container only if it not already! 798cdf0e10cSrcweir if( m_pStaticDataContainer == NULL ) 799cdf0e10cSrcweir { 800cdf0e10cSrcweir OUString aRootPath( ROOTNODE_START ); 801cdf0e10cSrcweir m_pStaticDataContainer = new SvtPrintOptions_Impl( aRootPath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/Printer" ) ) ); 802cdf0e10cSrcweir pPrinterOptionsDataContainer = m_pStaticDataContainer; 803cdf0e10cSrcweir ItemHolder2::holdConfigItem(E_PRINTOPTIONS); 804cdf0e10cSrcweir } 805cdf0e10cSrcweir 806cdf0e10cSrcweir SetDataContainer( m_pStaticDataContainer ); 807cdf0e10cSrcweir } 808cdf0e10cSrcweir 809cdf0e10cSrcweir // ----------------------------------------------------------------------------- 810cdf0e10cSrcweir 811cdf0e10cSrcweir SvtPrinterOptions::~SvtPrinterOptions() 812cdf0e10cSrcweir { 813cdf0e10cSrcweir // Global access, must be guarded (multithreading!) 814cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 815*b12a77c9Smseidel // Decrease our refcount. 816cdf0e10cSrcweir --m_nRefCount; 817cdf0e10cSrcweir // If last instance was deleted ... 818*b12a77c9Smseidel // we must destroy our static data container! 819cdf0e10cSrcweir if( m_nRefCount <= 0 ) 820cdf0e10cSrcweir { 821cdf0e10cSrcweir delete m_pStaticDataContainer; 822cdf0e10cSrcweir m_pStaticDataContainer = NULL; 823cdf0e10cSrcweir pPrinterOptionsDataContainer = NULL; 824cdf0e10cSrcweir } 825cdf0e10cSrcweir } 826cdf0e10cSrcweir 827cdf0e10cSrcweir // --------------------- 828cdf0e10cSrcweir // - SvtPrintFileOptions - 829cdf0e10cSrcweir // --------------------- 830cdf0e10cSrcweir 831cdf0e10cSrcweir SvtPrintFileOptions::SvtPrintFileOptions() 832cdf0e10cSrcweir { 833cdf0e10cSrcweir // Global access, must be guarded (multithreading!). 834cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 835*b12a77c9Smseidel // Increase our refcount ... 836cdf0e10cSrcweir ++m_nRefCount; 837*b12a77c9Smseidel // ... and initialize our data container only if it not already! 838cdf0e10cSrcweir if( m_pStaticDataContainer == NULL ) 839cdf0e10cSrcweir { 840cdf0e10cSrcweir OUString aRootPath( ROOTNODE_START ); 841cdf0e10cSrcweir m_pStaticDataContainer = new SvtPrintOptions_Impl( aRootPath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/File" ) ) ); 842cdf0e10cSrcweir pPrintFileOptionsDataContainer = m_pStaticDataContainer; 843cdf0e10cSrcweir 844cdf0e10cSrcweir ItemHolder2::holdConfigItem(E_PRINTFILEOPTIONS); 845cdf0e10cSrcweir } 846cdf0e10cSrcweir 847cdf0e10cSrcweir SetDataContainer( m_pStaticDataContainer ); 848cdf0e10cSrcweir } 849cdf0e10cSrcweir 850cdf0e10cSrcweir // ----------------------------------------------------------------------------- 851cdf0e10cSrcweir 852cdf0e10cSrcweir SvtPrintFileOptions::~SvtPrintFileOptions() 853cdf0e10cSrcweir { 854cdf0e10cSrcweir // Global access, must be guarded (multithreading!) 855cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 856*b12a77c9Smseidel // Decrease our refcount. 857cdf0e10cSrcweir --m_nRefCount; 858cdf0e10cSrcweir // If last instance was deleted ... 859*b12a77c9Smseidel // we must destroy our static data container! 860cdf0e10cSrcweir if( m_nRefCount <= 0 ) 861cdf0e10cSrcweir { 862cdf0e10cSrcweir delete m_pStaticDataContainer; 863cdf0e10cSrcweir m_pStaticDataContainer = NULL; 864cdf0e10cSrcweir pPrintFileOptionsDataContainer = NULL; 865cdf0e10cSrcweir } 866cdf0e10cSrcweir } 867