/* -*- 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 .
*/
class GDIMetaFile; class SalInfoPrinter; struct SalPrinterQueueInfo; class QueueInfo; class SalPrinter; class VirtualDevice; enumclass SalPrinterError;
namespace vcl { class PrinterController;
namespace printer { class Options;
}
}
namespace weld { class Window; }
class VCL_DLLPUBLIC Printer : public OutputDevice
{ friendclass ::OutputDevice;
Color GetBackgroundColor() const override { return COL_WHITE; }
Color GetReadableFontColor(const Color&, const Color&) const override { return COL_BLACK; }
/** SetPrinterOptions is used internally only now
in earlier times it was used only to set the options loaded directly from the configuration in SfxPrinter::InitJob, this is now handled internally should the need arise to set the printer options outside vcl, also a method would have to be devised to not override these again internally
*/
SAL_DLLPRIVATE void SetPrinterOptions( const vcl::printer::Options& rOptions ); const vcl::printer::Options& GetPrinterOptions() const { return( *mpPrinterOptions ); }
bool SetPaperBin( sal_uInt16 nPaperBin );
sal_uInt16 GetPaperBin() const;
sal_uInt16 GetPaperBinBySourceIndex(sal_uInt16 nPaperSource) const;
sal_uInt16 GetSourceIndexByPaperBin(sal_uInt16 nPaperBin) const; void SetPaper( Paper ePaper ); bool SetPaperSizeUser( const Size& rSize ); /** @return The paper format of the printer's current "jobsetup". Note that if PAPER_USER the actual size can be anything. */
Paper GetPaper() const; /** @return Size of the paper of the printer's current "jobsetup". */
SAL_DLLPRIVATE Size GetSizeOfPaper() const; static OUString GetPaperName( Paper ePaper );
/** @return Number of available paper formats */
SAL_DLLPRIVATE int GetPaperInfoCount() const;
/** @return Info about paper format nPaper */
SAL_DLLPRIVATE const PaperInfo& GetPaperInfo( int nPaper ) const;
sal_uInt16 GetPaperBinCount() const;
OUString GetPaperBinName( sal_uInt16 nPaperBin ) const;
/** Checks the printer list and updates it necessary
sends a DataChanged event of type DataChangedEventType::PRINTER if the printer list changed
*/ staticvoid updatePrinters();
/** Execute a print job
starts a print job asynchronously that is will return
*/ staticvoid PrintJob( const std::shared_ptr<vcl::PrinterController>& i_pController, const JobSetup& i_rInitSetup );
// These 3 together are more modular PrintJob(), allowing printing more documents as one print job // by repeated calls to ExecutePrintJob(). Used by mailmerge.
SAL_DLLPRIVATE staticbool PreparePrintJob( std::shared_ptr<vcl::PrinterController> i_pController, const JobSetup& i_rInitSetup );
SAL_DLLPRIVATE staticbool ExecutePrintJob(const std::shared_ptr<vcl::PrinterController>& i_pController); staticvoid FinishPrintJob( const std::shared_ptr<vcl::PrinterController>& i_pController );
/** Implementation detail of PrintJob being asynchronous
not exported, not usable outside vcl
*/ staticvoid SAL_DLLPRIVATE ImplPrintJob( const std::shared_ptr<vcl::PrinterController>& i_pController, const JobSetup& i_rInitSetup );
};
/** For implementations: get current job properties as changed by e.g. print dialog
this gets the current set of properties initially told to Printer::PrintJob
For convenience a second sequence will be merged in to get a combined sequence. In case of duplicate property names, the value of i_MergeList wins.
*/
css::uno::Sequence< css::beans::PropertyValue >
getJobProperties(const css::uno::Sequence< css::beans::PropertyValue >& i_rMergeList ) const;
/// Get the PropertyValue of a Property
css::beans::PropertyValue* getValue( const OUString& i_rPropertyName ); const css::beans::PropertyValue* getValue( const OUString& i_rPropertyName ) const;
/** Get a bool property
in case the property is unknown or not convertible to bool, i_bFallback is returned
*/
SAL_DLLPRIVATE bool getBoolProperty( const OUString& i_rPropertyName, bool i_bFallback ) const;
/** Get an int property
in case the property is unknown or not convertible to bool, i_nFallback is returned
*/
SAL_DLLPRIVATE sal_Int32 getIntProperty( const OUString& i_rPropertyName, sal_Int32 i_nFallback ) const;
/// Set a property value - can also be used to add another UI property void setValue( const OUString& i_rPropertyName, const css::uno::Any& i_rValue );
SAL_DLLPRIVATE void setValue( const css::beans::PropertyValue& i_rValue );
/** @return The currently active UI options. These are the same that were passed to setUIOptions. */ const css::uno::Sequence< css::beans::PropertyValue >&
getUIOptions() const;
/** Set possible UI options.
should only be done once before passing the PrinterListener to Printer::PrintJob
*/ void setUIOptions( const css::uno::Sequence< css::beans::PropertyValue >& );
/// Enable/disable an option; this can be used to implement dialog logic. bool isUIOptionEnabled( const OUString& rPropName ) const;
SAL_DLLPRIVATE bool isUIChoiceEnabled( const OUString& rPropName, sal_Int32 nChoice ) const;
/// Defines which options in a UI element should be disabled or enabled. void setUIChoicesDisabled(const OUString& rPropName, css::uno::Sequence<sal_Bool>& rChoicesDisabled);
/** MakeEnabled will change the property rPropName depends on to the value
that makes rPropName enabled. If the dependency itself is also disabled, no action will be performed.
@return The property name rPropName depends on or an empty string if no change was made.
*/
SAL_DLLPRIVATE OUString makeEnabled( const OUString& rPropName );
/// App must override this virtualint getPageCount() const = 0;
/** Get the page parameters
namely the jobsetup that should be active for the page (describing among others the physical page size) and the "page size". In writer case this would probably be the same as the JobSetup since writer sets the page size draw/impress for example print their page on the paper set on the printer, possibly adjusting the page size to fit. That means the page size can be different from the paper size.
App must override this
@return Page size in 1/100th mm
*/ virtual css::uno::Sequence< css::beans::PropertyValue >
getPageParameters( int i_nPage ) const = 0; /// App must override this virtualvoid printPage(int i_nPage) const = 0;
/// Will be called after a possible dialog has been shown and the real printjob starts
SAL_DLLPRIVATE virtualvoid jobStarted();
SAL_DLLPRIVATE virtualvoid jobFinished( css::view::PrintableState );
/// Create without ui properties
PrinterOptionsHelper() {}
/** Process a new set of properties
merges changed properties and returns "true" if any occurred
*/ bool processProperties( const css::uno::Sequence< css::beans::PropertyValue >& i_rNewProp );
/** Append to a sequence of property values the ui property sequence passed at creation
as the "ExtraPrintUIOptions" property. if that sequence was empty, no "ExtraPrintUIOptions" property will be appended.
*/ void appendPrintUIOptions( css::uno::Sequence< css::beans::PropertyValue >& io_rProps ) const;
/** @return An empty Any for not existing properties */
css::uno::Any getValue( const OUString& i_rPropertyName ) const;
// helper functions for user to create a single control struct UIControlOptions
{
OUString maDependsOnName;
OUString maGroupHint;
std::vector< css::beans::PropertyValue >
maAddProps;
sal_Int32 mnDependsOnEntry; bool mbAttachToDependency; bool mbInternalOnly; bool mbEnabled;
// note: in the following helper functions HelpIds are expected as an OUString // the normal HelpId form is OString (byte string instead of UTF16 string) // this is because the whole interface is base on UNO properties; in fact the structures // are passed over UNO interfaces. UNO does not know a byte string, hence the string is // transported via UTF16 strings.
/// Show and set the title of a TagPage of id i_rID static css::uno::Any setGroupControlOpt( const OUString& i_rID, const OUString& i_rTitle, const OUString& i_rHelpId);
/// Show and set the label of a VclFrame of id i_rID static css::uno::Any setSubgroupControlOpt( const OUString& i_rID, const OUString& i_rTitle, const OUString& i_rHelpId, const UIControlOptions& i_rControlOptions = UIControlOptions());
/// Show a bool option as a checkbox static css::uno::Any setBoolControlOpt( const OUString& i_rID, const OUString& i_rTitle, const OUString& i_rHelpId, const OUString& i_rProperty, bool i_bValue, const UIControlOptions& i_rControlOptions = UIControlOptions());
/// Show a set of choices in a list box static css::uno::Any setChoiceListControlOpt( const OUString& i_rID, const OUString& i_rTitle, const css::uno::Sequence< OUString >& i_rHelpId, const OUString& i_rProperty, const css::uno::Sequence< OUString >& i_rChoices, sal_Int32 i_nValue, const css::uno::Sequence< sal_Bool >& i_rDisabledChoices = css::uno::Sequence< sal_Bool >(), const UIControlOptions& i_rControlOptions = UIControlOptions());
/// Show a set of choices as radio buttons static css::uno::Any setChoiceRadiosControlOpt( const css::uno::Sequence< OUString >& i_rIDs, const OUString& i_rTitle, const css::uno::Sequence< OUString >& i_rHelpId, const OUString& i_rProperty, const css::uno::Sequence< OUString >& i_rChoices,
sal_Int32 i_nValue, const css::uno::Sequence< sal_Bool >& i_rDisabledChoices = css::uno::Sequence< sal_Bool >(), const UIControlOptions& i_rControlOptions = UIControlOptions());
/** Show an integer range (e.g. a spin field)
note: max value < min value means do not apply min/max values
*/ static css::uno::Any setRangeControlOpt( const OUString& i_rID, const OUString& i_rTitle, const OUString& i_rHelpId, const OUString& i_rProperty, sal_Int32 i_nValue, sal_Int32 i_nMinValue,
sal_Int32 i_nMaxValue, const UIControlOptions& i_rControlOptions);
/** Show a string field
note: max value < min value means do not apply min/max values
*/ static css::uno::Any setEditControlOpt( const OUString& i_rID, const OUString& i_rTitle, const OUString& i_rHelpId, const OUString& i_rProperty, const OUString& i_rValue, const UIControlOptions& i_rControlOptions);
}; // class PrinterOptionsHelper
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.