offapi/com/sun/star/view/PrintOptions.idl | 8 ++++++++ sfx2/source/doc/printhelper.cxx | 9 +++++++++ sfx2/source/view/viewprn.cxx | 12 ++++++++---- 3 files changed, 25 insertions(+), 4 deletions(-)
New commits: commit f3ecfbc0b7647d962662b72ced932300a3adc3ce Author: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> AuthorDate: Thu Jul 28 14:01:45 2022 +0200 Commit: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> CommitDate: Thu Jul 28 14:18:22 2022 +0200 Add 'JobName' to PrintOptions Allow users to specify a job name which is sent to the printer (by default this is the current document name). Usage: Sub PrintWithCustomJobname Dim mPOpts(1) As New com.sun.star.beans.PropertyValue mPOpts(0).Name = "JobName" mPOpts(0).Value = "My Job Name" ThisComponent.Print(mPOpts()) End Sub Change-Id: Id7c1c0da7f581b1c050bb3e6d61dd01b7e8205f0 diff --git a/offapi/com/sun/star/view/PrintOptions.idl b/offapi/com/sun/star/view/PrintOptions.idl index 4ed8b23baaf0..4bef0fec5288 100644 --- a/offapi/com/sun/star/view/PrintOptions.idl +++ b/offapi/com/sun/star/view/PrintOptions.idl @@ -80,6 +80,14 @@ published service PrintOptions /** advises the printer to create a single print job for each copy. */ [optional, property] boolean SinglePrintJobs; + + /** The job name which is sent to the printer (can be seen in the Printer job queue). + * + * If omitted, the document title will be used as default. + * + * @since LibreOffice 7.5 + */ + [optional, property] boolean JobName; }; diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx index 42936e53fe99..263c20b58e26 100644 --- a/sfx2/source/doc/printhelper.cxx +++ b/sfx2/source/doc/printhelper.cxx @@ -711,6 +711,15 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& aCheckedArgs[nProps++].Value <<= bTemp; } + else if ( rProp.Name == "JobName" ) + { + OUString sTemp; + if( !(rProp.Value >>= sTemp) ) + throw css::lang::IllegalArgumentException(); + aCheckedArgs[nProps].Name = rProp.Name; + aCheckedArgs[nProps++].Value <<= sTemp; + } + // Pages-Property else if ( rProp.Name == "Pages" ) { diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index b67267a61b53..f9cd9c005c39 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -616,10 +616,14 @@ void SfxViewShell::StartPrint( const uno::Sequence < beans::PropertyValue >& rPr )); pImpl->m_xPrinterController = xNewController; - SfxObjectShell *pObjShell = GetObjectShell(); - xNewController->setValue( "JobName", - makeAny( pObjShell->GetTitle(1) ) ); - xNewController->setPrinterModified( mbPrinterSettingsModified ); + // When no JobName was specified via com::sun::star::view::PrintOptions::JobName , + // use the document title as default job name + css::beans::PropertyValue* pJobNameVal = xNewController->getValue("JobName"); + if (!pJobNameVal) + { + xNewController->setValue("JobName", Any(GetObjectShell()->GetTitle(1))); + xNewController->setPrinterModified(mbPrinterSettingsModified); + } } void SfxViewShell::ExecPrint( const uno::Sequence < beans::PropertyValue >& rProps, bool bIsAPI, bool bIsDirect )