diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2021-09-01 02:19:27 +1000 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-07 17:59:47 +0200 |
commit | 7228a2dbfa11cd846678aaacd248c68adcda5f34 (patch) | |
tree | 5a81fa7d3f225952747c2982d4a8baf2bd17817d /vcl/source/gdi | |
parent | b42516b433c1d71487db061a058887f6dd76dd74 (diff) |
vcl: rename PrinterOptions to vcl::printer::Options
Move Options to own source and header files. Options moved to own
source and header files, however also put Options into vcl::printer
namespace.
I have renamed and moved PrinterOptions into the vcl::printer namespace
because the word "Printer" is redundant, and we want to organize the vcl
namespace better.
Change-Id: I2ef188af381dd65907d48f7b190e4ab69417606d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121389
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r-- | vcl/source/gdi/print.cxx | 117 | ||||
-rw-r--r-- | vcl/source/gdi/print2.cxx | 5 | ||||
-rw-r--r-- | vcl/source/gdi/print3.cxx | 40 |
3 files changed, 37 insertions, 125 deletions
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index 6b6b070a69f3..ea3d70053978 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -19,28 +19,27 @@ #include <sal/types.h> #include <sal/log.hxx> - -#include <tools/helpers.hxx> +#include <comphelper/processfactory.hxx> #include <tools/debug.hxx> +#include <tools/helpers.hxx> #include <vcl/QueueInfo.hxx> #include <vcl/event.hxx> #include <vcl/virdev.hxx> #include <vcl/print.hxx> +#include <vcl/printer/Options.hxx> -#include <comphelper/processfactory.hxx> - -#include <salinst.hxx> -#include <salvd.hxx> -#include <salgdi.hxx> -#include <salptype.hxx> -#include <salprn.hxx> -#include <svdata.hxx> -#include <print.hrc> #include <jobset.h> #include <outdev.h> -#include <PhysicalFontCollection.hxx> #include <print.h> +#include <PhysicalFontCollection.hxx> +#include <print.hrc> +#include <salgdi.hxx> +#include <salinst.hxx> +#include <salprn.hxx> +#include <salptype.hxx> +#include <salvd.hxx> +#include <svdata.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/configuration/theDefaultProvider.hpp> @@ -89,96 +88,6 @@ void ImplUpdateJobSetupPaper( JobSetup& rJobSetup ) } } -// PrinterOptions -PrinterOptions::PrinterOptions() : - mbReduceTransparency( false ), - meReducedTransparencyMode( PrinterTransparencyMode::Auto ), - mbReduceGradients( false ), - meReducedGradientsMode( PrinterGradientMode::Stripes ), - mnReducedGradientStepCount( 64 ), - mbReduceBitmaps( false ), - meReducedBitmapMode( PrinterBitmapMode::Normal ), - mnReducedBitmapResolution( 200 ), - mbReducedBitmapsIncludeTransparency( true ), - mbConvertToGreyscales( false ), - mbPDFAsStandardPrintJobFormat( false ) -{ -} - -void PrinterOptions::ReadFromConfig( bool i_bFile ) -{ - bool bSuccess = false; - // save old state in case something goes wrong - PrinterOptions aOldValues( *this ); - - // get the configuration service - css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider; - css::uno::Reference< css::container::XNameAccess > xConfigAccess; - try - { - // get service provider - css::uno::Reference< css::uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); - // create configuration hierarchical access name - try - { - xConfigProvider = css::configuration::theDefaultProvider::get( xContext ); - - css::beans::PropertyValue aVal; - aVal.Name = "nodepath"; - if( i_bFile ) - aVal.Value <<= OUString( "/org.openoffice.Office.Common/Print/Option/File" ); - else - aVal.Value <<= OUString( "/org.openoffice.Office.Common/Print/Option/Printer" ); - xConfigAccess.set( - xConfigProvider->createInstanceWithArguments( - "com.sun.star.configuration.ConfigurationAccess", { css::uno::Any(aVal) } ), - css::uno::UNO_QUERY ); - if( xConfigAccess.is() ) - { - css::uno::Reference< css::beans::XPropertySet > xSet( xConfigAccess, css::uno::UNO_QUERY ); - if( xSet.is() ) - { - sal_Int32 nValue = 0; - bool bValue = false; - if( xSet->getPropertyValue("ReduceTransparency") >>= bValue ) - SetReduceTransparency( bValue ); - if( xSet->getPropertyValue("ReducedTransparencyMode") >>= nValue ) - SetReducedTransparencyMode( static_cast<PrinterTransparencyMode>(nValue) ); - if( xSet->getPropertyValue("ReduceGradients") >>= bValue ) - SetReduceGradients( bValue ); - if( xSet->getPropertyValue("ReducedGradientMode") >>= nValue ) - SetReducedGradientMode( static_cast<PrinterGradientMode>(nValue) ); - if( xSet->getPropertyValue("ReducedGradientStepCount") >>= nValue ) - SetReducedGradientStepCount( static_cast<sal_uInt16>(nValue) ); - if( xSet->getPropertyValue("ReduceBitmaps") >>= bValue ) - SetReduceBitmaps( bValue ); - if( xSet->getPropertyValue("ReducedBitmapMode") >>= nValue ) - SetReducedBitmapMode( static_cast<PrinterBitmapMode>(nValue) ); - if( xSet->getPropertyValue("ReducedBitmapResolution") >>= nValue ) - SetReducedBitmapResolution( static_cast<sal_uInt16>(nValue) ); - if( xSet->getPropertyValue("ReducedBitmapIncludesTransparency") >>= bValue ) - SetReducedBitmapIncludesTransparency( bValue ); - if( xSet->getPropertyValue("ConvertToGreyscales") >>= bValue ) - SetConvertToGreyscales( bValue ); - if( xSet->getPropertyValue("PDFAsStandardPrintJobFormat") >>= bValue ) - SetPDFAsStandardPrintJobFormat( bValue ); - - bSuccess = true; - } - } - } - catch( const css::uno::Exception& ) - { - } - } - catch( const css::lang::WrappedTargetException& ) - { - } - - if( ! bSuccess ) - *this = aOldValues; -} - void Printer::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask, const Point& rDestPt, const Size& rDestSize, const Point& rSrcPtPixel, const Size& rSrcSizePixel ) @@ -414,7 +323,7 @@ tools::Rectangle Printer::GetBackgroundComponentBounds() const return tools::Rectangle( aPageOffset, aSize ); } -void Printer::SetPrinterOptions( const PrinterOptions& i_rOptions ) +void Printer::SetPrinterOptions( const vcl::printer::Options& i_rOptions ) { *mpPrinterOptions = i_rOptions; } @@ -553,7 +462,7 @@ void Printer::ImplInitData() mpInfoPrinter = nullptr; mpPrinter = nullptr; mpDisplayDev = nullptr; - mpPrinterOptions.reset(new PrinterOptions); + mpPrinterOptions.reset(new vcl::printer::Options); // Add printer to the list ImplSVData* pSVData = ImplGetSVData(); diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx index ca3f0c1901a1..4f05a779efb4 100644 --- a/vcl/source/gdi/print2.cxx +++ b/vcl/source/gdi/print2.cxx @@ -21,17 +21,18 @@ #include <vcl/metaact.hxx> #include <vcl/print.hxx> +#include <vcl/printer/Options.hxx> #include <utility> #include <vector> void Printer::DrawGradientEx( OutputDevice* pOut, const tools::Rectangle& rRect, const Gradient& rGradient ) { - const PrinterOptions& rPrinterOptions = GetPrinterOptions(); + const vcl::printer::Options& rPrinterOptions = GetPrinterOptions(); if( rPrinterOptions.IsReduceGradients() ) { - if( PrinterGradientMode::Stripes == rPrinterOptions.GetReducedGradientMode() ) + if( vcl::printer::GradientMode::Stripes == rPrinterOptions.GetReducedGradientMode() ) { if( !rGradient.GetSteps() || ( rGradient.GetSteps() > rPrinterOptions.GetReducedGradientStepCount() ) ) { diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index d4518bba4889..620a00f6e145 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -17,31 +17,33 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <vcl/weld.hxx> -#include <vcl/print.hxx> -#include <vcl/svapp.hxx> -#include <vcl/metaact.hxx> -#include <configsettings.hxx> -#include <tools/urlobj.hxx> -#include <comphelper/processfactory.hxx> -#include <comphelper/sequence.hxx> #include <sal/types.h> #include <sal/log.hxx> -#include <tools/debug.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/sequence.hxx> #include <tools/diagnose_ex.h> +#include <tools/debug.hxx> +#include <tools/urlobj.hxx> +#include <vcl/metaact.hxx> +#include <vcl/print.hxx> +#include <vcl/printer/Options.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> + +#include <configsettings.hxx> #include <printdlg.hxx> -#include <svdata.hxx> #include <salinst.hxx> #include <salprn.hxx> #include <strings.hrc> +#include <svdata.hxx> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/ui/dialogs/FilePicker.hpp> -#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> +#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/view/DuplexMode.hpp> -#include <com/sun/star/lang/IllegalArgumentException.hpp> -#include <com/sun/star/awt/Size.hpp> #include <unordered_map> #include <unordered_set> @@ -827,7 +829,7 @@ void PrinterController::setPrinter( const VclPtr<Printer>& i_rPrinter ) void PrinterController::resetPrinterOptions( bool i_bFileOutput ) { - PrinterOptions aOpt; + vcl::printer::Options aOpt; aOpt.ReadFromConfig( i_bFileOutput ); mpImplData->mxPrinter->SetPrinterOptions( aOpt ); } @@ -1254,7 +1256,7 @@ DrawModeFlags PrinterController::removeTransparencies( GDIMetaFile const & i_rIn sal_Int32 nMaxBmpDPIX = mpImplData->mxPrinter->GetDPIX(); sal_Int32 nMaxBmpDPIY = mpImplData->mxPrinter->GetDPIY(); - const PrinterOptions& rPrinterOptions = mpImplData->mxPrinter->GetPrinterOptions(); + const vcl::printer::Options& rPrinterOptions = mpImplData->mxPrinter->GetPrinterOptions(); static const sal_Int32 OPTIMAL_BMP_RESOLUTION = 300; static const sal_Int32 NORMAL_BMP_RESOLUTION = 200; @@ -1262,12 +1264,12 @@ DrawModeFlags PrinterController::removeTransparencies( GDIMetaFile const & i_rIn if( rPrinterOptions.IsReduceBitmaps() ) { // calculate maximum resolution for bitmap graphics - if( PrinterBitmapMode::Optimal == rPrinterOptions.GetReducedBitmapMode() ) + if( printer::BitmapMode::Optimal == rPrinterOptions.GetReducedBitmapMode() ) { nMaxBmpDPIX = std::min( sal_Int32(OPTIMAL_BMP_RESOLUTION), nMaxBmpDPIX ); nMaxBmpDPIY = std::min( sal_Int32(OPTIMAL_BMP_RESOLUTION), nMaxBmpDPIY ); } - else if( PrinterBitmapMode::Normal == rPrinterOptions.GetReducedBitmapMode() ) + else if( printer::BitmapMode::Normal == rPrinterOptions.GetReducedBitmapMode() ) { nMaxBmpDPIX = std::min( sal_Int32(NORMAL_BMP_RESOLUTION), nMaxBmpDPIX ); nMaxBmpDPIY = std::min( sal_Int32(NORMAL_BMP_RESOLUTION), nMaxBmpDPIY ); @@ -1288,7 +1290,7 @@ DrawModeFlags PrinterController::removeTransparencies( GDIMetaFile const & i_rIn } // disable transparency output - if( rPrinterOptions.IsReduceTransparency() && ( PrinterTransparencyMode::NONE == rPrinterOptions.GetReducedTransparencyMode() ) ) + if( rPrinterOptions.IsReduceTransparency() && ( vcl::printer::TransparencyMode::NONE == rPrinterOptions.GetReducedTransparencyMode() ) ) { mpImplData->mxPrinter->SetDrawMode( mpImplData->mxPrinter->GetDrawMode() | DrawModeFlags::NoTransparency ); } @@ -1303,7 +1305,7 @@ DrawModeFlags PrinterController::removeTransparencies( GDIMetaFile const & i_rIn } mpImplData->mxPrinter->RemoveTransparenciesFromMetaFile( i_rIn, o_rOut, nMaxBmpDPIX, nMaxBmpDPIY, rPrinterOptions.IsReduceTransparency(), - rPrinterOptions.GetReducedTransparencyMode() == PrinterTransparencyMode::Auto, + rPrinterOptions.GetReducedTransparencyMode() == vcl::printer::TransparencyMode::Auto, rPrinterOptions.IsReduceBitmaps() && rPrinterOptions.IsReducedBitmapIncludesTransparency(), aBg ); |