diff options
author | David Tardon <dtardon@redhat.com> | 2011-11-23 09:25:07 +0100 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2011-12-05 15:11:45 +0100 |
commit | 18cf5cea5b25b3705c35d04e824b9965b0f9836a (patch) | |
tree | 3cc111723d7101c4bba6fbe2988b395e8568bc29 /vcl | |
parent | a5f78432218627960159f14e272b08bc9de69e24 (diff) |
move the check function to vcl
Other plugins may want to use it too.
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/aqua/source/gdi/salprn.cxx | 70 | ||||
-rw-r--r-- | vcl/inc/vcl/print.hxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/print3.cxx | 69 |
3 files changed, 72 insertions, 69 deletions
diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 6153e3cddf2d..67122430cf20 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -30,7 +30,6 @@ #include <boost/bind.hpp> #include "vcl/print.hxx" -#include "vcl/unohelp.hxx" #include <sal/macros.h> #include "aqua/salinst.h" @@ -42,8 +41,6 @@ #include "jobset.h" #include "salptype.hxx" -#include "com/sun/star/lang/XMultiServiceFactory.hpp" -#include "com/sun/star/container/XNameAccess.hpp" #include "com/sun/star/beans/PropertyValue.hpp" #include "com/sun/star/awt/Size.hpp" @@ -51,10 +48,7 @@ using namespace vcl; using namespace com::sun::star; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; using namespace com::sun::star::beans; -using namespace com::sun::star::container; using ::rtl::OUString; using ::rtl::OStringToOUString; @@ -305,68 +299,6 @@ rtl::OUString AquaSalInfoPrinter::GetPaperBinName( const ImplJobSetup*, sal_uLon // ----------------------------------------------------------------------- -static bool getUseNativeDialog() -{ - bool bNative = true; - try - { - // get service provider - uno::Reference< XMultiServiceFactory > xSMgr( unohelper::GetMultiServiceFactory() ); - // create configuration hierachical access name - if( xSMgr.is() ) - { - try - { - uno::Reference< XMultiServiceFactory > xConfigProvider( - uno::Reference< XMultiServiceFactory >( - xSMgr->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationProvider" ))), - UNO_QUERY ) - ); - if( xConfigProvider.is() ) - { - Sequence< Any > aArgs(1); - PropertyValue aVal; - aVal.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ); - aVal.Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/Misc" ) ); - aArgs.getArray()[0] <<= aVal; - uno::Reference< XNameAccess > xConfigAccess( - uno::Reference< XNameAccess >( - xConfigProvider->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationAccess" )), - aArgs ), - UNO_QUERY ) - ); - if( xConfigAccess.is() ) - { - try - { - sal_Bool bValue = sal_False; - Any aAny = xConfigAccess->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseSystemPrintDialog" ) ) ); - if( aAny >>= bValue ) - bNative = bValue; - } - catch( NoSuchElementException& ) - { - } - catch( WrappedTargetException& ) - { - } - } - } - } - catch( Exception& ) - { - } - } - } - catch( WrappedTargetException& ) - { - } - - return bNative; -} - sal_uLong AquaSalInfoPrinter::GetCapabilities( const ImplJobSetup*, sal_uInt16 i_nType ) { switch( i_nType ) @@ -388,7 +320,7 @@ sal_uLong AquaSalInfoPrinter::GetCapabilities( const ImplJobSetup*, sal_uInt16 i case PRINTER_CAPABILITIES_SETPAPER: return 1; case PRINTER_CAPABILITIES_EXTERNALDIALOG: - return getUseNativeDialog() ? 1 : 0; + return useSystemPrintDialog() ? 1 : 0; case PRINTER_CAPABILITIES_PDF: return 1; case PRINTER_CAPABILITIES_USEPULLMODEL: diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 54bcc42ec359..bbb827dc5708 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -677,6 +677,8 @@ class VCL_DLLPUBLIC PrinterOptionsHelper ); }; +VCL_DLLPUBLIC bool useSystemPrintDialog(); + } diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index afc5a8c5b950..f8a2387589c7 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -32,6 +32,7 @@ #include "vcl/metaact.hxx" #include "vcl/msgbox.hxx" #include "vcl/configsettings.hxx" +#include "vcl/unohelp.hxx" #include "printdlg.hxx" #include "svdata.hxx" @@ -41,6 +42,7 @@ #include "tools/urlobj.hxx" +#include "com/sun/star/container/XNameAccess.hpp" #include "com/sun/star/ui/dialogs/XFilePicker.hpp" #include "com/sun/star/ui/dialogs/XFilterManager.hpp" #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" @@ -1909,4 +1911,71 @@ Any PrinterOptionsHelper::getEditControlOpt( const rtl::OUString& i_rTitle, ); } +namespace vcl +{ + +bool useSystemPrintDialog() +{ + bool bNative = true; + try + { + // get service provider + uno::Reference< lang::XMultiServiceFactory > xSMgr( unohelper::GetMultiServiceFactory() ); + // create configuration hierachical access name + if( xSMgr.is() ) + { + try + { + uno::Reference< lang::XMultiServiceFactory > xConfigProvider( + uno::Reference< lang::XMultiServiceFactory >( + xSMgr->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.ConfigurationProvider" ))), + UNO_QUERY ) + ); + if( xConfigProvider.is() ) + { + uno::Sequence< uno::Any > aArgs(1); + beans::PropertyValue aVal; + aVal.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ); + aVal.Value <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/Misc" ) ); + aArgs.getArray()[0] <<= aVal; + uno::Reference< container::XNameAccess > xConfigAccess( + uno::Reference< container::XNameAccess >( + xConfigProvider->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.ConfigurationAccess" )), + aArgs ), + UNO_QUERY ) + ); + if( xConfigAccess.is() ) + { + try + { + sal_Bool bValue = sal_False; + uno::Any aAny = xConfigAccess->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseSystemPrintDialog" ) ) ); + if( aAny >>= bValue ) + bNative = bValue; + } + catch( const container::NoSuchElementException& ) + { + } + catch( const lang::WrappedTargetException& ) + { + } + } + } + } + catch( const uno::Exception& ) + { + } + } + } + catch( const lang::WrappedTargetException& ) + { + } + + return bNative; +} + +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |