summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
Diffstat (limited to 'vcl')
-rw-r--r--vcl/Library_vcl.mk1
-rw-r--r--vcl/inc/print.hrc2
-rw-r--r--vcl/source/gdi/print.cxx117
-rw-r--r--vcl/source/gdi/print2.cxx5
-rw-r--r--vcl/source/gdi/print3.cxx40
-rw-r--r--vcl/source/printer/Options.cxx110
-rw-r--r--vcl/source/window/printdlg.cxx30
-rw-r--r--vcl/unx/generic/print/genprnpsp.cxx1
8 files changed, 166 insertions, 140 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 99632be5c5ef..41d3ee3e7fc9 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -101,6 +101,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/animate/AnimationBitmap \
vcl/source/cnttype/mcnttfactory \
vcl/source/cnttype/mcnttype \
+ vcl/source/printer/Options \
vcl/source/printer/QueueInfo \
vcl/source/window/bubblewindow \
vcl/source/window/errinf \
diff --git a/vcl/inc/print.hrc b/vcl/inc/print.hrc
index ddc0e3e1699a..b654a77ec3b8 100644
--- a/vcl/inc/print.hrc
+++ b/vcl/inc/print.hrc
@@ -20,6 +20,8 @@
#ifndef INCLUDED_VCL_INC_PRINT_HRC
#define INCLUDED_VCL_INC_PRINT_HRC
+#include <unotools/resmgr.hxx>
+
#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
const TranslateId RID_STR_PAPERNAMES[] =
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
);
diff --git a/vcl/source/printer/Options.cxx b/vcl/source/printer/Options.cxx
new file mode 100644
index 000000000000..bc695622f670
--- /dev/null
+++ b/vcl/source/printer/Options.cxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <comphelper/processfactory.hxx>
+
+#include <vcl/printer/Options.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/configuration/theDefaultProvider.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+namespace vcl::printer
+{
+void Options::ReadFromConfig(bool i_bFile)
+{
+ bool bSuccess = false;
+ // save old state in case something goes wrong
+ Options 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<TransparencyMode>(nValue));
+ if (xSet->getPropertyValue("ReduceGradients") >>= bValue)
+ SetReduceGradients(bValue);
+ if (xSet->getPropertyValue("ReducedGradientMode") >>= nValue)
+ SetReducedGradientMode(static_cast<GradientMode>(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<BitmapMode>(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;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 32a973a284ac..c6fde48ef28c 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -17,31 +17,31 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <printdlg.hxx>
-#include <svdata.hxx>
-#include <strings.hrc>
-#include <bitmaps.hlst>
+#include <sal/log.hxx>
+#include <osl/diagnose.h>
+#include <rtl/ustrbuf.hxx>
+#include <unotools/localedatawrapper.hxx>
#include <officecfg/Office/Common.hxx>
-#include <vcl/windowstate.hxx>
#include <vcl/QueueInfo.hxx>
#include <vcl/commandevent.hxx>
-#include <vcl/naturalsort.hxx>
-#include <vcl/print.hxx>
-#include <vcl/wall.hxx>
#include <vcl/decoview.hxx>
-#include <configsettings.hxx>
#include <vcl/help.hxx>
-#include <vcl/svapp.hxx>
+#include <vcl/naturalsort.hxx>
+#include <vcl/print.hxx>
+#include <vcl/printer/Options.hxx>
#include <vcl/settings.hxx>
+#include <vcl/svapp.hxx>
#include <vcl/virdev.hxx>
+#include <vcl/wall.hxx>
#include <vcl/weldutils.hxx>
+#include <vcl/windowstate.hxx>
-#include <unotools/localedatawrapper.hxx>
-
-#include <sal/log.hxx>
-#include <osl/diagnose.h>
-#include <rtl/ustrbuf.hxx>
+#include <bitmaps.hlst>
+#include <configsettings.hxx>
+#include <printdlg.hxx>
+#include <strings.hrc>
+#include <svdata.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx
index 19ec3206287f..aa81b67e6ae7 100644
--- a/vcl/unx/generic/print/genprnpsp.cxx
+++ b/vcl/unx/generic/print/genprnpsp.cxx
@@ -46,6 +46,7 @@
#include <vcl/gdimtf.hxx>
#include <vcl/idle.hxx>
+#include <vcl/printer/Options.hxx>
#include <vcl/print.hxx>
#include <vcl/QueueInfo.hxx>
#include <vcl/pdfwriter.hxx>