44#include <com/sun/star/awt/Size.hpp>
45#include <com/sun/star/lang/IllegalArgumentException.hpp>
46#include <com/sun/star/ui/dialogs/FilePicker.hpp>
47#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
48#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
49#include <com/sun/star/view/DuplexMode.hpp>
51#include <unordered_map>
52#include <unordered_set>
66 std::vector< CacheEntry > maPages;
67 std::vector< sal_Int32 > maPageNumbers;
68 std::vector< sal_Int32 > maCacheRanking;
72 void updateRanking( sal_Int32 nLastHit )
74 if( maCacheRanking[0] != nLastHit )
76 for( sal_Int32 i = nCacheSize-1;
i > 0;
i-- )
77 maCacheRanking[i] = maCacheRanking[i-1];
78 maCacheRanking[0] = nLastHit;
89 maCacheRanking[i] = nCacheSize - i - 1;
95 sal_Int32 nReplacePage = maCacheRanking.back();
96 maPages[ nReplacePage ].aPage = i_rPage;
97 maPages[ nReplacePage ].aSize = i_rSize;
98 maPageNumbers[ nReplacePage ] = i_nPageNo;
101 updateRanking( nReplacePage );
111 if( maPageNumbers[i] == i_nPageNo )
114 o_rPageFile = maPages[
i].aPage;
115 o_rSize = maPages[
i].
aSize;
126 maPageNumbers[
i] = -1;
127 maPages[
i].aPage.Clear();
207 meJobState( css::view::PrintableState_JOB_STARTED ),
259 css::uno::Reference< css::uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
260 css::uno::Reference< css::ui::dialogs::XFilePicker3 > xFilePicker = css::ui::dialogs::FilePicker::createWithMode(xContext, css::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION);
266 bool bPS =
true, bPDF =
true;
275 xFilePicker->appendFilter(
"PostScript",
"*.ps" );
277 xFilePicker->appendFilter(
"Portable Document Format",
"*.pdf" );
280 xFilePicker->appendFilter(
"*.PRN",
"*.prn" );
283 xFilePicker->appendFilter(
VclResId(SV_STDTEXT_ALLFILETYPES),
"*.*");
285 catch (
const css::lang::IllegalArgumentException&)
290 if( xFilePicker->execute() == css::ui::dialogs::ExecutableDialogResults::OK )
292 css::uno::Sequence< OUString > aPathSeq( xFilePicker->getSelectedFiles() );
303 std::shared_ptr<PrinterController> mxController;
306 PrintJobAsync(std::shared_ptr<PrinterController> i_xController,
308 : mxController(
std::move( i_xController )), maInitSetup( i_rInitSetup )
327 bool bSynchronous =
false;
328 css::beans::PropertyValue* pVal = i_xController->getValue(
"Wait" );
330 pVal->Value >>= bSynchronous;
333 ImplPrintJob(i_xController, i_rInitSetup);
336 PrintJobAsync* pAsync =
new PrintJobAsync(i_xController, i_rInitSetup);
345 if( GetDefaultPrinterName().isEmpty() )
350 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"ErrorNoPrinterDialog"));
354 css::uno::Any(
false ) );
365 xPrinter->SetJobSetup(i_rInitSetup);
367 xController->setPapersizeFromSetup(xPrinter->GetPrinterSettingsPreferred());
383 css::beans::PropertyValue* pContentVal =
xController->getValue(
"PrintRange");
385 pContentVal =
xController->getValue(
"PrintContent");
388 css::beans::PropertyValue* pPagesVal =
xController->getValue(
"Pages");
392 pPagesVal->Value >>= aPagesVal;
393 if( !aPagesVal.isEmpty() )
400 pContentVal->Value <<= sal_Int32( 1 );
401 xController->setValue(
"PageRange", pPagesVal->Value);
406 else if( pContentVal )
408 sal_Int32 nContent = -1;
409 if( pContentVal->Value >>= nContent )
414 css::beans::PropertyValue* pRangeVal =
xController->getValue(
"PageRange");
417 pRangeVal->Value >>= aRange;
418 if( aRange.isEmpty() )
423 OUStringBuffer
aBuf( 32 );
427 aBuf.append(
"-" + OUString::number( nPages ) );
429 xController->setValue(
"PageRange", css::uno::Any(
aBuf.makeStringAndClear()));
436 css::beans::PropertyValue* pReverseVal =
xController->getValue(
"PrintReverse");
439 bool bReverse =
false;
440 pReverseVal->Value >>= bReverse;
444 css::beans::PropertyValue* pPapersizeFromSetupVal =
xController->getValue(
"PapersizeFromSetup");
445 if( pPapersizeFromSetupVal )
447 bool bPapersizeFromSetup =
false;
448 pPapersizeFromSetupVal->Value >>= bPapersizeFromSetup;
449 xController->setPapersizeFromSetup(bPapersizeFromSetup);
453 sal_Int32 nRows =
xController->getIntProperty(
"NUpRows", 1);
454 sal_Int32 nCols =
xController->getIntProperty(
"NUpColumns", 1);
455 if( nRows > 1 || nCols > 1 )
458 aMPS.
nRows = std::max<sal_Int32>(nRows, 1);
459 aMPS.
nColumns = std::max<sal_Int32>(nCols, 1);
481 css::beans::PropertyValue* pPgSizeVal =
xController->getValue(
"NUpPaperSize" );
482 css::awt::Size aSizeVal;
483 if( pPgSizeVal && (pPgSizeVal->Value >>= aSizeVal) )
499 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"ErrorNoContentDialog"));
523 if( aFile.isEmpty() )
529 css::uno::Any( aFile ) );
533 xController->getPrinter()->SetSinglePrintJobs(
true);
536 catch (
const std::bad_alloc&)
558 css::beans::PropertyValue* pJobNameVal =
xController->getValue(
"JobName" );
560 pJobNameVal->Value >>= aJobName;
581bool Printer::StartJob(
const OUString& i_rJobName, std::shared_ptr<vcl::PrinterController>
const & i_xController)
585 if ( IsDisplayPrinter() )
588 if ( IsJobActive() || IsPrinting() )
591 sal_uInt32 nCopies = mnCopyCount;
592 bool bCollateCopy = mbCollateCopy;
593 bool bUserCopy =
false;
597 const sal_uInt32 nDevCopy = GetCapabilities( bCollateCopy
602 if ( nCopies > nDevCopy )
606 bCollateCopy =
false;
610 bCollateCopy =
false;
618 bool bSinglePrintJobs = i_xController->getPrinter()->IsSinglePrintJobs();
620 css::beans::PropertyValue* pFileValue = i_xController->getValue(
"LocalFileName");
624 pFileValue->Value >>= aFile;
625 if( !aFile.isEmpty() )
629 bSinglePrintJobs =
false;
633 OUString* pPrintFile =
nullptr;
635 pPrintFile = &maPrintFile;
636 mpPrinterOptions->ReadFromConfig( mbPrintFile );
646 if( mpPrinter->StartJob( pPrintFile,
649 &maJobSetup.ImplGetData(),
656 mnError = ImplSalPrinterErrorCodeToVCL(mpPrinter->GetErrorCode());
664 i_xController->setLastPage(
true);
665 i_xController->getFilteredPageFile(0, aDummyFile);
674 i_xController->setJobState( css::view::PrintableState_JOB_STARTED );
675 i_xController->jobStarted();
678 int nOuterRepeatCount = 1;
679 int nInnerRepeatCount = 1;
683 nOuterRepeatCount = mnCopyCount;
685 nInnerRepeatCount = mnCopyCount;
687 if( bSinglePrintJobs )
691 nOuterRepeatCount = nInnerRepeatCount = 1;
694 for(
int nJobIteration = 0; nJobIteration < nJobs; nJobIteration++ )
697 if( mpPrinter->StartJob( pPrintFile,
702 i_xController->isDirectPrint(),
703 &maJobSetup.ImplGetData() ) )
705 bool bAborted =
false;
707 i_xController->createProgressDialog();
708 const int nPages = i_xController->getFilteredPageCount();
712 i_xController->abortJob();
715 for(
int nOuterIteration = 0; nOuterIteration < nOuterRepeatCount && ! bAborted; nOuterIteration++ )
717 for(
int nPage = 0; nPage < nPages && ! bAborted; nPage++ )
719 for(
int nInnerIteration = 0; nInnerIteration < nInnerRepeatCount && ! bAborted; nInnerIteration++ )
721 if( nPage == nPages-1 &&
722 nOuterIteration == nOuterRepeatCount-1 &&
723 nInnerIteration == nInnerRepeatCount-1 &&
724 nJobIteration == nJobs-1 )
726 i_xController->setLastPage(
true);
728 i_xController->printFilteredPage(nPage);
729 if (i_xController->isProgressCanceled())
731 i_xController->abortJob();
733 if (i_xController->getJobState() ==
734 css::view::PrintableState_JOB_ABORTED)
744 if( nJobIteration < nJobs-1 )
759 mnError = mpPrinter ? ImplSalPrinterErrorCodeToVCL(mpPrinter->GetErrorCode()) :
ERRCODE_NONE;
763 ? css::view::PrintableState_JOB_ABORTED
764 : css::view::PrintableState_JOB_FAILED );
772 if (i_xController->getJobState() == css::view::PrintableState_JOB_STARTED)
773 i_xController->setJobState(css::view::PrintableState_JOB_SPOOLED);
777 if (i_xController->isShowDialogs() && !i_xController->isDirectPrint())
830 bool bSavedSizeOrientation =
false;
837 bSavedSizeOrientation =
true;
842 css::uno::Any( i_rPrinter->
GetName() ) );
848 if ( bSavedSizeOrientation )
850 mpImplData->mxPrinter->SetPaperSizeUser(aPaperSize);
851 mpImplData->mxPrinter->SetOrientation(eOrientation);
862 vcl::printer::Options aOpt;
863 aOpt.ReadFromConfig( i_bFileOutput );
864 mpImplData->mxPrinter->SetPrinterOptions( aOpt );
897 "Printer changed underneath us during setup");
903 bool bInvalidateCache =
false;
908 if (aNewPaperSize !=
mpImplData->maDefaultPageSize)
910 mpImplData->maDefaultPageSize = aNewPaperSize;
916 if (nNewPaperBin != nPaperBin)
919 bInvalidateCache =
true;
922 if (bInvalidateCache)
931 if (aPaperSize != aNewPaperSize)
940 aPageSize.
aSize = mxPrinter->GetPaperSize();
941 css::awt::Size aSetSize, aIsSize;
942 sal_Int32 nPaperBin = mnDefaultPaperBin;
943 for(
const auto& rProp : i_rProps )
945 if ( rProp.Name ==
"PreferredPageSize" )
947 rProp.Value >>= aSetSize;
949 else if ( rProp.Name ==
"PageSize" )
951 rProp.Value >>= aIsSize;
953 else if ( rProp.Name ==
"PageIncludesNonprintableArea" )
956 rProp.Value >>= bVal;
959 else if ( rProp.Name ==
"PrinterPaperTray" )
962 rProp.Value >>= nBin;
968 Size aCurSize( mxPrinter->GetPaperSize() );
969 if( aSetSize.Width && aSetSize.Height )
971 Size aSetPaperSize( aSetSize.Width, aSetSize.Height );
972 Size aRealPaperSize( getRealPaperSize( aSetPaperSize,
true ) );
973 if( aRealPaperSize != aCurSize )
977 if( aIsSize.Width && aIsSize.Height )
982 Size aRealPaperSize( getRealPaperSize( aPageSize.
aSize,
true ) );
983 if( aRealPaperSize != aCurSize )
984 mxPrinter->SetPaperSizeUser( aRealPaperSize );
989 if ( mnFixedPaperBin != -1 )
990 nPaperBin = mnFixedPaperBin;
992 if( nPaperBin != -1 && nPaperBin != mxPrinter->GetPaperBin() )
993 mxPrinter->SetPaperBin( nPaperBin );
1010 mxPrinter->SetMapMode(
MapMode(MapUnit::Map100thMM));
1011 Size aCurSize(mxPrinter->GetPaperSize());
1012 if (aCurSize != maDefaultPageSize)
1013 mxPrinter->SetPaperSizeUser(maDefaultPageSize);
1019 const MapMode aMapMode( MapUnit::Map100thMM );
1022 mpImplData->mxPrinter->SetMapMode( aMapMode );
1030 const MapMode aMapMode( MapUnit::Map100thMM );
1033 mpImplData->mxPrinter->SetMapMode( aMapMode );
1034 css::uno::Sequence< css::beans::PropertyValue > aResult(
getPageParameters( i_nPage ) );
1051 if( i_bMayUseCache )
1054 if(
mpImplData->maPageCache.get( i_nUnfilteredPage, o_rMtf, aPageSize ) )
1066 const MapMode aMapMode( MapUnit::Map100thMM );
1069 mpImplData->mxPrinter->SetMapMode( aMapMode );
1077 mpImplData->mxPrinter->EnableOutput(
false );
1087 if( i_bMayUseCache )
1088 mpImplData->maPageCache.insert( i_nUnfilteredPage, o_rMtf, aPageSize );
1100 io_rSubPage.
Clip( i_rClipRect );
1110 io_rSubPage.
Play( o_rMtf );
1116 if( !i_bDrawBorder )
1143 i_nFilteredPage = nDocPages - 1 - i_nFilteredPage;
1149 if( nSubPages == 1 &&
1154 if (
mpImplData->meJobState != css::view::PrintableState_JOB_STARTED)
1160 mpImplData->mxPrinter->SetPaperSizeUser( aPaperSize );
1161 if( aPaperSize != aPageSize.
aSize )
1170 aPageSize.
aSize = aPaperSize;
1184 Size aMPArea( aPaperSize );
1203 if (
mpImplData->meJobState != css::view::PrintableState_JOB_STARTED)
1207 for(
int nSubPage = 0; nSubPage < nSubPages; nSubPage++ )
1210 int nPage = i_nFilteredPage * nSubPages + nSubPage;
1211 if( nSubPage == nSubPages-1 ||
1212 nPage == nDocPages-1 )
1216 if( nPage >= 0 && nPage < nDocPages )
1226 nCellX = (nSubPage % rMPS.
nColumns);
1227 nCellY = (nSubPage / rMPS.
nColumns);
1230 nCellX = (nSubPage / rMPS.
nRows);
1231 nCellY = (nSubPage % rMPS.
nRows);
1235 nCellY = (nSubPage / rMPS.
nColumns);
1239 nCellY = (nSubPage % rMPS.
nRows);
1243 double fScaleX = double(aSubPageSize.
Width())/double(aPageSize.
aSize.
Width());
1244 double fScaleY = double(aSubPageSize.
Height())/double(aPageSize.
aSize.
Height());
1245 double fScale = std::min( fScaleX, fScaleY );
1246 aPageFile.
Scale( fScale, fScale );
1270 mpImplData->mxPrinter->SetPaperSizeUser( aPaperSize );
1286 sal_Int32 nMaxBmpDPIX =
mpImplData->mxPrinter->GetDPIX();
1287 sal_Int32 nMaxBmpDPIY =
mpImplData->mxPrinter->GetDPIY();
1289 const vcl::printer::Options& rPrinterOptions =
mpImplData->mxPrinter->GetPrinterOptions();
1291 static const sal_Int32 OPTIMAL_BMP_RESOLUTION = 300;
1292 static const sal_Int32 NORMAL_BMP_RESOLUTION = 200;
1294 if( rPrinterOptions.IsReduceBitmaps() )
1299 nMaxBmpDPIX = std::min( sal_Int32(OPTIMAL_BMP_RESOLUTION), nMaxBmpDPIX );
1300 nMaxBmpDPIY = std::min( sal_Int32(OPTIMAL_BMP_RESOLUTION), nMaxBmpDPIY );
1304 nMaxBmpDPIX = std::min( sal_Int32(NORMAL_BMP_RESOLUTION), nMaxBmpDPIX );
1305 nMaxBmpDPIY = std::min( sal_Int32(NORMAL_BMP_RESOLUTION), nMaxBmpDPIY );
1309 nMaxBmpDPIX = std::min( sal_Int32(rPrinterOptions.GetReducedBitmapResolution()), nMaxBmpDPIX );
1310 nMaxBmpDPIY = std::min( sal_Int32(rPrinterOptions.GetReducedBitmapResolution()), nMaxBmpDPIY );
1315 if( rPrinterOptions.IsConvertToGreyscales() )
1336 mpImplData->mxPrinter->RemoveTransparenciesFromMetaFile( i_rIn, o_rOut, nMaxBmpDPIX, nMaxBmpDPIY,
1337 rPrinterOptions.IsReduceTransparency(),
1339 rPrinterOptions.IsReduceBitmaps() && rPrinterOptions.IsReducedBitmapIncludesTransparency(),
1342 return nRestoreDrawMode;
1347 if(
mpImplData->meJobState != css::view::PrintableState_JOB_STARTED )
1358 setJobState( css::view::PrintableState_JOB_ABORTED );
1396 mpImplData->mxPrinter->SetDrawMode( nRestoreDrawMode );
1409 setJobState( css::view::PrintableState_JOB_ABORTED );
1436 mpImplData->mbPapersizeFromSetup = i_bPapersizeFromSetup;
1437 mpImplData->mxPrinter->SetPrinterSettingsPreferred( i_bPapersizeFromSetup );
1438 if ( i_bPapersizeFromSetup )
1454 mpImplData->mxPrinter->SetPrinterSettingsPreferred(
false );
1462 mpImplData->meUserOrientation = eOrientation;
1467 mpImplData->mbPrinterModified = i_bPrinterModified;
1477 std::unordered_set< OUString > aMergeSet;
1478 size_t nResultLen = size_t(i_rMergeList.getLength()) +
mpImplData->maUIProperties.size() + 3;
1479 for(
const auto& rPropVal : i_rMergeList )
1480 aMergeSet.insert( rPropVal.Name );
1482 css::uno::Sequence< css::beans::PropertyValue > aResult( nResultLen );
1483 auto pResult = aResult.getArray();
1484 std::copy(i_rMergeList.begin(), i_rMergeList.end(), pResult);
1485 int nCur = i_rMergeList.getLength();
1486 for(
const css::beans::PropertyValue & rPropVal :
mpImplData->maUIProperties)
1488 if( aMergeSet.find( rPropVal.Name ) == aMergeSet.end() )
1489 pResult[nCur++] = rPropVal;
1492 if( aMergeSet.find(
"IsFirstPage" ) == aMergeSet.end() )
1494 css::beans::PropertyValue aVal;
1495 aVal.Name =
"IsFirstPage";
1497 pResult[nCur++] = aVal;
1500 if( aMergeSet.find(
"IsLastPage" ) == aMergeSet.end() )
1502 css::beans::PropertyValue aVal;
1503 aVal.Name =
"IsLastPage";
1505 pResult[nCur++] = aVal;
1508 if( aMergeSet.find(
"IsPrinter" ) == aMergeSet.end() )
1510 css::beans::PropertyValue aVal;
1511 aVal.Name =
"IsPrinter";
1512 aVal.Value <<=
true;
1513 pResult[nCur++] = aVal;
1515 aResult.realloc( nCur );
1526 std::unordered_map< OUString, size_t >::const_iterator it =
1527 mpImplData->maPropertyToIndex.find( i_rProperty );
1528 return it !=
mpImplData->maPropertyToIndex.end() ? &
mpImplData->maUIProperties[it->second] :
nullptr;
1533 std::unordered_map< OUString, size_t >::const_iterator it =
1534 mpImplData->maPropertyToIndex.find( i_rProperty );
1535 return it !=
mpImplData->maPropertyToIndex.end() ? &
mpImplData->maUIProperties[it->second] :
nullptr;
1540 css::beans::PropertyValue aVal;
1541 aVal.Name = i_rPropertyName;
1542 aVal.Value = i_rValue;
1549 std::unordered_map< OUString, size_t >::const_iterator it =
1550 mpImplData->maPropertyToIndex.find( i_rPropertyValue.Name );
1551 if( it !=
mpImplData->maPropertyToIndex.end() )
1552 mpImplData->maUIProperties[ it->second ] = i_rPropertyValue;
1557 mpImplData->maUIProperties.push_back( i_rPropertyValue );
1558 mpImplData->maUIPropertyEnabled.push_back(
true );
1568 for(
const auto& rOpt : i_rOptions )
1570 css::uno::Sequence< css::beans::PropertyValue > aOptProp;
1571 rOpt.Value >>= aOptProp;
1573 bool bHaveProperty =
false;
1576 css::uno::Sequence< sal_Bool > aChoicesDisabled;
1577 for(
const css::beans::PropertyValue& rEntry : std::as_const(aOptProp) )
1579 if ( rEntry.Name ==
"Property" )
1581 css::beans::PropertyValue aVal;
1582 rEntry.Value >>= aVal;
1584 ==
mpImplData->maPropertyToIndex.end(),
"duplicate property entry" );
1587 bHaveProperty =
true;
1589 else if ( rEntry.Name ==
"Enabled" )
1592 rEntry.Value >>= bValue;
1595 else if ( rEntry.Name ==
"DependsOnName" )
1599 else if ( rEntry.Name ==
"DependsOnEntry" )
1603 else if ( rEntry.Name ==
"ChoicesDisabled" )
1605 rEntry.Value >>= aChoicesDisabled;
1610 vcl::ImplPrinterControllerData::PropertyToIndexMap::const_iterator it =
1613 if( it !=
mpImplData->maPropertyToIndex.end() )
1619 if( aChoicesDisabled.hasElements() )
1627 bool bEnabled =
false;
1628 std::unordered_map< OUString, size_t >::const_iterator prop_it =
1629 mpImplData->maPropertyToIndex.find( i_rProperty );
1630 if( prop_it !=
mpImplData->maPropertyToIndex.end() )
1632 bEnabled =
mpImplData->maUIPropertyEnabled[prop_it->second];
1637 vcl::ImplPrinterControllerData::ControlDependencyMap::const_iterator it =
1638 mpImplData->maControlDependencies.find( i_rProperty );
1639 if( it !=
mpImplData->maControlDependencies.end() )
1648 const css::beans::PropertyValue* pVal =
getValue( it->second.maDependsOnName );
1649 OSL_ENSURE( pVal,
"unknown property in dependency" );
1652 sal_Int32 nDepVal = 0;
1653 bool bDepVal =
false;
1654 if( pVal->Value >>= nDepVal )
1656 bEnabled = (nDepVal == it->second.mnDependsOnEntry) || (it->second.mnDependsOnEntry == -1);
1658 else if( pVal->Value >>= bDepVal )
1662 bEnabled = ( bDepVal && it->second.mnDependsOnEntry != 0) ||
1663 ( ! bDepVal && it->second.mnDependsOnEntry == 0);
1668 OSL_FAIL(
"strange type in control dependency" );
1681 bool bEnabled =
true;
1682 ImplPrinterControllerData::ChoiceDisableMap::const_iterator it =
1683 mpImplData->maChoiceDisableMap.find( i_rProperty );
1684 if(it !=
mpImplData->maChoiceDisableMap.end() )
1686 const css::uno::Sequence< sal_Bool >& rDisabled( it->second );
1687 if( i_nValue >= 0 && i_nValue < rDisabled.getLength() )
1688 bEnabled = ! rDisabled[i_nValue];
1695 OUString aDependency;
1697 vcl::ImplPrinterControllerData::ControlDependencyMap::const_iterator it =
1698 mpImplData->maControlDependencies.find( i_rProperty );
1699 if( it !=
mpImplData->maControlDependencies.end() )
1703 aDependency = it->second.maDependsOnName;
1704 const css::beans::PropertyValue* pVal =
getValue( aDependency );
1705 OSL_ENSURE( pVal,
"unknown property in dependency" );
1708 sal_Int32 nDepVal = 0;
1709 bool bDepVal =
false;
1710 if( pVal->Value >>= nDepVal )
1712 if( it->second.mnDependsOnEntry != -1 )
1714 setValue( aDependency, css::uno::Any( sal_Int32( it->second.mnDependsOnEntry ) ) );
1717 else if( pVal->Value >>= bDepVal )
1719 setValue( aDependency, css::uno::Any( it->second.mnDependsOnEntry != 0 ) );
1724 OSL_FAIL(
"strange type in control dependency" );
1738 css::beans::PropertyValue* pMonitor =
getValue(
"MonitorVisible" );
1740 pMonitor->Value >>= bShow;
1743 const css::beans::PropertyValue* pVal =
getValue(
"IsApi" );
1747 pVal->Value >>= bApi;
1787 sal_Int32 nCopyCount = 1;
1789 const css::beans::PropertyValue* pVal =
getValue(
"CopyCount" );
1791 pVal->Value >>= nCopyCount;
1792 bool bCollate =
false;
1795 pVal->Value >>= bCollate;
1796 mpImplData->mxPrinter->SetCopyCount(
static_cast<sal_uInt16
>(nCopyCount), bCollate );
1798 pVal =
getValue(
"SinglePrintJobs");
1799 bool bSinglePrintJobs =
false;
1801 pVal->Value >>= bSinglePrintJobs;
1802 mpImplData->mxPrinter->SetSinglePrintJobs(bSinglePrintJobs);
1808 sal_Int16 nDuplex = css::view::DuplexMode::UNKNOWN;
1809 pVal->Value >>= nDuplex;
1833 bool bRet = i_bFallback;
1834 const css::beans::PropertyValue* pVal =
getValue( i_rProperty );
1836 pVal->Value >>= bRet;
1842 sal_Int32 nRet = i_nFallback;
1843 const css::beans::PropertyValue* pVal =
getValue( i_rProperty );
1845 pVal->Value >>= nRet;
1855 std::unordered_map< OUString, css::uno::Any >::const_iterator it =
1865 css::uno::Any aVal(
getValue( i_rPropertyName ) );
1866 return (aVal >>= bRet) ? bRet : i_bDefault;
1872 css::uno::Any aVal(
getValue( i_rPropertyName ) );
1873 return (aVal >>= nRet) ? nRet : i_nDefault;
1879 css::uno::Any aVal(
getValue( i_rPropertyName ) );
1880 return (aVal >>= aRet) ? aRet : OUString();
1885 bool bChanged =
false;
1887 for(
const auto& rVal : i_rNewProp )
1889 std::unordered_map< OUString, css::uno::Any >::iterator it =
1892 bool bElementChanged = (it ==
m_aPropertyMap.end()) || (it->second != rVal.Value);
1893 if( bElementChanged )
1906 sal_Int32
nIndex = io_rProps.getLength();
1907 io_rProps.realloc(
nIndex+1 );
1914 const OUString& i_rTitle,
1915 const css::uno::Sequence< OUString >& i_rHelpIds,
1916 const OUString& i_rType,
1917 const css::beans::PropertyValue* i_pVal,
1922 + (i_rTitle.isEmpty() ? 0 : 1)
1923 + (i_rHelpIds.hasElements() ? 1 : 0)
1926 + (i_rControlOptions.
maGroupHint.isEmpty() ? 0 : 1)
1939 css::uno::Sequence< css::beans::PropertyValue > aCtrl(
nElements );
1940 auto pCtrl = aCtrl.getArray();
1941 sal_Int32 nUsed = 0;
1942 if( !i_rTitle.isEmpty() )
1944 pCtrl[nUsed ].Name =
"Text";
1945 pCtrl[nUsed++].Value <<= i_rTitle;
1947 if( i_rHelpIds.hasElements() )
1949 pCtrl[nUsed ].Name =
"HelpId";
1950 pCtrl[nUsed++].Value <<= i_rHelpIds;
1952 pCtrl[nUsed ].Name =
"ControlType";
1953 pCtrl[nUsed++].Value <<= i_rType;
1954 pCtrl[nUsed ].Name =
"ID";
1955 pCtrl[nUsed++].Value <<= i_rIDs;
1958 pCtrl[nUsed ].Name =
"Property";
1959 pCtrl[nUsed++].Value <<= *i_pVal;
1963 pCtrl[nUsed ].Name =
"DependsOnName";
1967 pCtrl[nUsed ].Name =
"DependsOnEntry";
1972 pCtrl[nUsed ].Name =
"AttachToDependency";
1978 pCtrl[nUsed ].Name =
"GroupingHint";
1979 pCtrl[nUsed++].Value <<= i_rControlOptions.
maGroupHint;
1983 pCtrl[nUsed ].Name =
"InternalUIOnly";
1984 pCtrl[nUsed++].Value <<=
true;
1988 pCtrl[nUsed ].Name =
"Enabled";
1989 pCtrl[nUsed++].Value <<=
false;
1992 sal_Int32 nAddProps = i_rControlOptions.
maAddProps.size();
1993 for( sal_Int32
i = 0;
i < nAddProps;
i++ )
1994 pCtrl[ nUsed++ ] = i_rControlOptions.
maAddProps[
i];
1998 return css::uno::Any( aCtrl );
2002 const OUString& i_rTitle,
2003 const OUString& i_rHelpId)
2005 css::uno::Sequence< OUString > aHelpId;
2006 if( !i_rHelpId.isEmpty() )
2008 aHelpId.realloc( 1 );
2009 *aHelpId.getArray() = i_rHelpId;
2011 css::uno::Sequence< OUString > aIds { i_rID };
2016 const OUString& i_rTitle,
2017 const OUString& i_rHelpId,
2020 css::uno::Sequence< OUString > aHelpId;
2021 if( !i_rHelpId.isEmpty() )
2023 aHelpId.realloc( 1 );
2024 *aHelpId.getArray() = i_rHelpId;
2026 css::uno::Sequence< OUString > aIds { i_rID };
2027 return setUIControlOpt(aIds, i_rTitle, aHelpId,
"Subgroup",
nullptr, i_rControlOptions);
2031 const OUString& i_rTitle,
2032 const OUString& i_rHelpId,
2033 const OUString& i_rProperty,
2037 css::uno::Sequence< OUString > aHelpId;
2038 if( !i_rHelpId.isEmpty() )
2040 aHelpId.realloc( 1 );
2041 *aHelpId.getArray() = i_rHelpId;
2043 css::beans::PropertyValue aVal;
2044 aVal.Name = i_rProperty;
2045 aVal.Value <<= i_bValue;
2046 css::uno::Sequence< OUString > aIds { i_rID };
2047 return setUIControlOpt(aIds, i_rTitle, aHelpId,
"Bool", &aVal, i_rControlOptions);
2051 const OUString& i_rTitle,
2052 const css::uno::Sequence< OUString >& i_rHelpId,
2053 const OUString& i_rProperty,
2054 const css::uno::Sequence< OUString >& i_rChoices,
2056 const css::uno::Sequence< sal_Bool >& i_rDisabledChoices,
2061 aOpt.
maAddProps.resize( nUsed + 1 + (i_rDisabledChoices.hasElements() ? 1 : 0) );
2064 if( i_rDisabledChoices.hasElements() )
2066 aOpt.
maAddProps[nUsed+1].Name =
"ChoicesDisabled";
2067 aOpt.
maAddProps[nUsed+1].Value <<= i_rDisabledChoices;
2070 css::beans::PropertyValue aVal;
2071 aVal.Name = i_rProperty;
2072 aVal.Value <<= i_nValue;
2073 return setUIControlOpt(i_rIDs, i_rTitle, i_rHelpId,
"Radio", &aVal, aOpt);
2077 const OUString& i_rTitle,
2078 const css::uno::Sequence< OUString >& i_rHelpId,
2079 const OUString& i_rProperty,
2080 const css::uno::Sequence< OUString >& i_rChoices,
2082 const css::uno::Sequence< sal_Bool >& i_rDisabledChoices,
2087 aOpt.
maAddProps.resize( nUsed + 1 + (i_rDisabledChoices.hasElements() ? 1 : 0) );
2090 if( i_rDisabledChoices.hasElements() )
2092 aOpt.
maAddProps[nUsed+1].Name =
"ChoicesDisabled";
2093 aOpt.
maAddProps[nUsed+1].Value <<= i_rDisabledChoices;
2096 css::beans::PropertyValue aVal;
2097 aVal.Name = i_rProperty;
2098 aVal.Value <<= i_nValue;
2099 css::uno::Sequence< OUString > aIds { i_rID };
2100 return setUIControlOpt(aIds, i_rTitle, i_rHelpId,
"List", &aVal, aOpt);
2104 const OUString& i_rTitle,
2105 const OUString& i_rHelpId,
2106 const OUString& i_rProperty,
2108 sal_Int32 i_nMinValue,
2109 sal_Int32 i_nMaxValue,
2113 if( i_nMaxValue >= i_nMinValue )
2118 aOpt.
maAddProps[nUsed++].Value <<= i_nMinValue;
2120 aOpt.
maAddProps[nUsed++].Value <<= i_nMaxValue;
2123 css::uno::Sequence< OUString > aHelpId;
2124 if( !i_rHelpId.isEmpty() )
2126 aHelpId.realloc( 1 );
2127 *aHelpId.getArray() = i_rHelpId;
2129 css::beans::PropertyValue aVal;
2130 aVal.Name = i_rProperty;
2131 aVal.Value <<= i_nValue;
2132 css::uno::Sequence< OUString > aIds { i_rID };
2133 return setUIControlOpt(aIds, i_rTitle, aHelpId,
"Range", &aVal, aOpt);
2137 const OUString& i_rTitle,
2138 const OUString& i_rHelpId,
2139 const OUString& i_rProperty,
2140 const OUString& i_rValue,
2143 css::uno::Sequence< OUString > aHelpId;
2144 if( !i_rHelpId.isEmpty() )
2146 aHelpId.realloc( 1 );
2147 *aHelpId.getArray() = i_rHelpId;
2149 css::beans::PropertyValue aVal;
2150 aVal.Name = i_rProperty;
2151 aVal.Value <<= i_rValue;
2152 css::uno::Sequence< OUString > aIds { i_rID };
2153 return setUIControlOpt(aIds, i_rTitle, aHelpId,
"Edit", &aVal, i_rControlOptions);
static OUString GetDisplayName()
Get the default name of the application for message dialogs and printing.
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
Post a user event to the default window.
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
static bool Reschedule(bool bHandleAllCurrentEvents=false)
Attempt to process current pending event(s)
static bool IsHeadlessModeEnabled()
Determines if headless mode is enabled.
OUString PathToFileName() const
OUString const & GetPrinterName() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
constexpr tools::Long Y() const
constexpr tools::Long X() const
static void FinishPrintJob(const std::shared_ptr< vcl::PrinterController > &i_pController)
bool SetOrientation(Orientation eOrient)
bool GetPrinterSettingsPreferred() const
bool Setup(weld::Window *pWindow, PrinterSetupMode eMode=PrinterSetupMode::DocumentGlobal)
sal_uInt32 GetCapabilities(PrinterCapType nType) const
Size GetPaperSize() const
static void updatePrinters()
Checks the printer list and updates it necessary.
static void VCL_DLLPRIVATE ImplPrintJob(const std::shared_ptr< vcl::PrinterController > &i_pController, const JobSetup &i_rInitSetup)
Implementation detail of PrintJob being asynchronous.
bool SetPaperSizeUser(const Size &rSize)
VCL_DLLPRIVATE bool StartJob(const OUString &rJobName, std::shared_ptr< vcl::PrinterController > const &)
static bool PreparePrintJob(std::shared_ptr< vcl::PrinterController > i_pController, const JobSetup &i_rInitSetup)
const OUString & GetName() const
sal_uInt16 GetPaperBin() const
Orientation GetOrientation() const
static void PrintJob(const std::shared_ptr< vcl::PrinterController > &i_pController, const JobSetup &i_rInitSetup)
Execute a print job.
static bool ExecutePrintJob(const std::shared_ptr< vcl::PrinterController > &i_pController)
virtual std::unique_ptr< SalPrinter > CreatePrinter(SalInfoPrinter *pInfoPrinter)=0
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
A construction helper for a temporary VclPtr.
PropertyToIndexMap maPropertyToIndex
VclPtr< Printer > mxPrinter
std::unordered_map< OUString, css::uno::Sequence< sal_Bool > > ChoiceDisableMap
bool mbOrientationFromUser
bool mbPapersizeFromSetup
ControlDependencyMap maControlDependencies
std::unordered_map< OUString, ControlDependency > ControlDependencyMap
ImplPageCache maPageCache
PrinterController::PageSize modifyJobSetup(const css::uno::Sequence< css::beans::PropertyValue > &i_rProps)
std::vector< bool > maUIPropertyEnabled
Size getRealPaperSize(const Size &i_rPageSize, bool bNoNUP) const
sal_Int32 mnFixedPaperBin
css::uno::Sequence< css::beans::PropertyValue > maUIOptions
~ImplPrinterControllerData()
void resetPaperToLastConfigured()
css::view::PrintableState meJobState
sal_Int32 mnDefaultPaperBin
std::vector< css::beans::PropertyValue > maUIProperties
std::shared_ptr< vcl::PrintProgressDialog > mxProgress
std::unordered_map< OUString, size_t > PropertyToIndexMap
ImplPrinterControllerData()
ChoiceDisableMap maChoiceDisableMap
Orientation meUserOrientation
vcl::PrinterController::MultiPageSetup maMultiPage
bool isSingleJobs() const
bool isPrintToFile() const
VCL_DLLPRIVATE css::uno::Sequence< css::beans::PropertyValue > getPageParametersProtected(int i_nPage) const
PageSize getFilteredPageFile(int i_nFilteredPage, GDIMetaFile &o_rMtf, bool i_bMayUseCache=false)
void setLastPage(bool i_bLastPage)
virtual css::uno::Sequence< css::beans::PropertyValue > getPageParameters(int i_nPage) const =0
Get the page parameters.
bool getBoolProperty(const OUString &i_rPropertyName, bool i_bFallback) const
Get a bool property.
void setValue(const OUString &i_rPropertyName, const css::uno::Any &i_rValue)
Set a property value - can also be used to add another UI property.
VCL_DLLPRIVATE const MultiPageSetup & getMultipage() const
void printFilteredPage(int i_nPage)
void dialogsParentClosing()
css::uno::Sequence< css::beans::PropertyValue > getJobProperties(const css::uno::Sequence< css::beans::PropertyValue > &i_rMergeList) const
For implementations: get current job properties as changed by e.g.
std::unique_ptr< ImplPrinterControllerData > mpImplData
VCL_DLLPRIVATE void pushPropertiesToPrinter()
void setUIOptions(const css::uno::Sequence< css::beans::PropertyValue > &)
Set possible UI options.
VCL_DLLPRIVATE int getPageCountProtected() const
void createProgressDialog()
const css::uno::Sequence< css::beans::PropertyValue > & getUIOptions() const
VCL_DLLPRIVATE DrawModeFlags removeTransparencies(GDIMetaFile const &i_rIn, GDIMetaFile &o_rOut)
bool isUIChoiceEnabled(const OUString &rPropName, sal_Int32 nChoice) const
VCL_DLLPRIVATE void setupPrinter(weld::Window *i_pDlgParent)
virtual void jobStarted()
Will be called after a possible dialog has been shown and the real printjob starts.
VCL_DLLPRIVATE void resetPaperToLastConfigured()
bool isShowDialogs() const
VCL_DLLPRIVATE void setPapersizeFromSetup(bool i_bPapersizeFromSetup)
int getFilteredPageCount() const
weld::Window * getWindow() const
virtual void jobFinished(css::view::PrintableState)
virtual int getPageCount() const =0
App must override this.
OUString makeEnabled(const OUString &rPropName)
MakeEnabled will change the property rPropName depends on to the value.
css::beans::PropertyValue * getValue(const OUString &i_rPropertyName)
Get the PropertyValue of a Property.
bool isDirectPrint() const
void setPrinterModified(bool i_bPapersizeFromSetup)
css::view::PrintableState getJobState() const
VCL_DLLPRIVATE void setReversePrint(bool i_bReverse)
bool isUIOptionEnabled(const OUString &rPropName) const
Enable/disable an option; this can be used to implement dialog logic.
virtual void printPage(int i_nPage) const =0
App must override this.
bool getPrinterModified() const
bool isProgressCanceled() const
sal_Int32 getIntProperty(const OUString &i_rPropertyName, sal_Int32 i_nFallback) const
Get an int property.
const VclPtr< Printer > & getPrinter() const
VCL_DLLPRIVATE void setPaperSizeFromUser(Size i_aUserSize)
VCL_DLLPRIVATE void resetPrinterOptions(bool i_bFileOutput)
VCL_DLLPRIVATE bool getPapersizeFromSetup() const
VCL_DLLPRIVATE void setMultipage(const MultiPageSetup &)
void setJobState(css::view::PrintableState)
VCL_DLLPRIVATE PageSize getPageFile(int i_inUnfilteredPage, GDIMetaFile &rMtf, bool i_bMayUseCache=false)
virtual ~PrinterController()
VCL_DLLPRIVATE void setOrientationFromUser(Orientation eOrientation, bool set)
VCL_DLLPRIVATE void setPrinter(const VclPtr< Printer > &)
static css::uno::Any setGroupControlOpt(const OUString &i_rID, const OUString &i_rTitle, const OUString &i_rHelpId)
Show and set the title of a TagPage of id i_rID.
bool getBoolValue(const OUString &i_rPropertyName, bool i_bDefault) const
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 a set of choices as radio buttons.
static css::uno::Any setUIControlOpt(const css::uno::Sequence< OUString > &i_rIDs, const OUString &i_rTitle, const css::uno::Sequence< OUString > &i_rHelpId, const OUString &i_rType, const css::beans::PropertyValue *i_pValue=nullptr, const UIControlOptions &i_rControlOptions=UIControlOptions())
Show general control.
OUString getStringValue(const OUString &i_rPropertyName) const
std::vector< css::beans::PropertyValue > m_aUIProperties
sal_Int64 getIntValue(const OUString &i_rPropertyName, sal_Int64 i_nDefault) const
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 bool option as a checkbox.
static css::uno::Any setSubgroupControlOpt(const OUString &i_rID, const OUString &i_rTitle, const OUString &i_rHelpId, const UIControlOptions &i_rControlOptions=UIControlOptions())
Show and set the label of a VclFrame of id i_rID.
css::uno::Any getValue(const OUString &i_rPropertyName) const
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 an integer range (e.g.
std::unordered_map< OUString, css::uno::Any > m_aPropertyMap
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 in a list box.
bool processProperties(const css::uno::Sequence< css::beans::PropertyValue > &i_rNewProp)
Process a new set of properties.
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)
Show a string field.
void appendPrintUIOptions(css::uno::Sequence< css::beans::PropertyValue > &io_rProps) const
Append to a sequence of property values the ui property sequence passed at creation.
static SettingsConfigItem * get()
void setValue(const OUString &rGroup, const OUString &rKey, const OUString &rValue)
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
virtual OUString GetName() const override
#define PRINTER_GENERALERROR
#define LINK(Instance, Class, Member)
#define SAL_WARN_IF(condition, area, stream)
void set(css::uno::UnoInterfaceReference const &value)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
IMPL_LINK_NOARG(QuickSelectionEngine_Data, SearchStringTimeout, Timer *, void)
static OUString queryFile(Printer const *pPrinter)
static void appendSubPage(GDIMetaFile &o_rMtf, const tools::Rectangle &i_rClipRect, GDIMetaFile &io_rSubPage, bool i_bDrawBorder)
sal_Int32 mnDependsOnEntry
tools::Long nHorizontalSpacing
tools::Long nBottomMargin
tools::Long nVerticalSpacing
bool bFullPaper
Full paper, not only imageable area is printed.
sal_Int32 mnDependsOnEntry
std::vector< css::beans::PropertyValue > maAddProps
bool mbAttachToDependency
Reference< XController > xController
ImplSVData * ImplGetSVData()
OUString VclResId(TranslateId aId)
constexpr auto nCacheSize