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 );
428 aBuf.append( nPages );
430 xController->setValue(
"PageRange", css::uno::Any(
aBuf.makeStringAndClear()));
437 css::beans::PropertyValue* pReverseVal =
xController->getValue(
"PrintReverse");
440 bool bReverse =
false;
441 pReverseVal->Value >>= bReverse;
445 css::beans::PropertyValue* pPapersizeFromSetupVal =
xController->getValue(
"PapersizeFromSetup");
446 if( pPapersizeFromSetupVal )
448 bool bPapersizeFromSetup =
false;
449 pPapersizeFromSetupVal->Value >>= bPapersizeFromSetup;
450 xController->setPapersizeFromSetup(bPapersizeFromSetup);
454 sal_Int32 nRows =
xController->getIntProperty(
"NUpRows", 1);
455 sal_Int32 nCols =
xController->getIntProperty(
"NUpColumns", 1);
456 if( nRows > 1 || nCols > 1 )
459 aMPS.
nRows = std::max<sal_Int32>(nRows, 1);
460 aMPS.
nColumns = std::max<sal_Int32>(nCols, 1);
482 css::beans::PropertyValue* pPgSizeVal =
xController->getValue(
"NUpPaperSize" );
483 css::awt::Size aSizeVal;
484 if( pPgSizeVal && (pPgSizeVal->Value >>= aSizeVal) )
500 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"ErrorNoContentDialog"));
524 if( aFile.isEmpty() )
530 css::uno::Any( aFile ) );
534 xController->getPrinter()->SetSinglePrintJobs(
true);
537 catch (
const std::bad_alloc&)
559 css::beans::PropertyValue* pJobNameVal =
xController->getValue(
"JobName" );
561 pJobNameVal->Value >>= aJobName;
582bool Printer::StartJob(
const OUString& i_rJobName, std::shared_ptr<vcl::PrinterController>
const & i_xController)
586 if ( IsDisplayPrinter() )
589 if ( IsJobActive() || IsPrinting() )
592 sal_uInt32 nCopies = mnCopyCount;
593 bool bCollateCopy = mbCollateCopy;
594 bool bUserCopy =
false;
598 const sal_uInt32 nDevCopy = GetCapabilities( bCollateCopy
603 if ( nCopies > nDevCopy )
607 bCollateCopy =
false;
611 bCollateCopy =
false;
619 bool bSinglePrintJobs = i_xController->getPrinter()->IsSinglePrintJobs();
621 css::beans::PropertyValue* pFileValue = i_xController->getValue(
"LocalFileName");
625 pFileValue->Value >>= aFile;
626 if( !aFile.isEmpty() )
630 bSinglePrintJobs =
false;
634 OUString* pPrintFile =
nullptr;
636 pPrintFile = &maPrintFile;
637 mpPrinterOptions->ReadFromConfig( mbPrintFile );
647 if( mpPrinter->StartJob( pPrintFile,
650 &maJobSetup.ImplGetData(),
657 mnError = ImplSalPrinterErrorCodeToVCL(mpPrinter->GetErrorCode());
665 i_xController->setLastPage(
true);
666 i_xController->getFilteredPageFile(0, aDummyFile);
675 i_xController->setJobState( css::view::PrintableState_JOB_STARTED );
676 i_xController->jobStarted();
679 int nOuterRepeatCount = 1;
680 int nInnerRepeatCount = 1;
684 nOuterRepeatCount = mnCopyCount;
686 nInnerRepeatCount = mnCopyCount;
688 if( bSinglePrintJobs )
692 nOuterRepeatCount = nInnerRepeatCount = 1;
695 for(
int nJobIteration = 0; nJobIteration < nJobs; nJobIteration++ )
698 if( mpPrinter->StartJob( pPrintFile,
703 i_xController->isDirectPrint(),
704 &maJobSetup.ImplGetData() ) )
706 bool bAborted =
false;
708 i_xController->createProgressDialog();
709 const int nPages = i_xController->getFilteredPageCount();
713 i_xController->abortJob();
716 for(
int nOuterIteration = 0; nOuterIteration < nOuterRepeatCount && ! bAborted; nOuterIteration++ )
718 for(
int nPage = 0; nPage < nPages && ! bAborted; nPage++ )
720 for(
int nInnerIteration = 0; nInnerIteration < nInnerRepeatCount && ! bAborted; nInnerIteration++ )
722 if( nPage == nPages-1 &&
723 nOuterIteration == nOuterRepeatCount-1 &&
724 nInnerIteration == nInnerRepeatCount-1 &&
725 nJobIteration == nJobs-1 )
727 i_xController->setLastPage(
true);
729 i_xController->printFilteredPage(nPage);
730 if (i_xController->isProgressCanceled())
732 i_xController->abortJob();
734 if (i_xController->getJobState() ==
735 css::view::PrintableState_JOB_ABORTED)
745 if( nJobIteration < nJobs-1 )
760 mnError = mpPrinter ? ImplSalPrinterErrorCodeToVCL(mpPrinter->GetErrorCode()) :
ERRCODE_NONE;
764 ? css::view::PrintableState_JOB_ABORTED
765 : css::view::PrintableState_JOB_FAILED );
773 if (i_xController->getJobState() == css::view::PrintableState_JOB_STARTED)
774 i_xController->setJobState(css::view::PrintableState_JOB_SPOOLED);
778 if (i_xController->isShowDialogs() && !i_xController->isDirectPrint())
831 bool bSavedSizeOrientation =
false;
838 bSavedSizeOrientation =
true;
843 css::uno::Any( i_rPrinter->
GetName() ) );
849 if ( bSavedSizeOrientation )
851 mpImplData->mxPrinter->SetPaperSizeUser(aPaperSize);
852 mpImplData->mxPrinter->SetOrientation(eOrientation);
863 vcl::printer::Options aOpt;
864 aOpt.ReadFromConfig( i_bFileOutput );
865 mpImplData->mxPrinter->SetPrinterOptions( aOpt );
898 "Printer changed underneath us during setup");
904 bool bInvalidateCache =
false;
909 if (aNewPaperSize !=
mpImplData->maDefaultPageSize)
911 mpImplData->maDefaultPageSize = aNewPaperSize;
917 if (nNewPaperBin != nPaperBin)
920 bInvalidateCache =
true;
923 if (bInvalidateCache)
932 if (aPaperSize != aNewPaperSize)
941 aPageSize.
aSize = mxPrinter->GetPaperSize();
942 css::awt::Size aSetSize, aIsSize;
943 sal_Int32 nPaperBin = mnDefaultPaperBin;
944 for(
const auto& rProp : i_rProps )
946 if ( rProp.Name ==
"PreferredPageSize" )
948 rProp.Value >>= aSetSize;
950 else if ( rProp.Name ==
"PageSize" )
952 rProp.Value >>= aIsSize;
954 else if ( rProp.Name ==
"PageIncludesNonprintableArea" )
957 rProp.Value >>= bVal;
960 else if ( rProp.Name ==
"PrinterPaperTray" )
963 rProp.Value >>= nBin;
969 Size aCurSize( mxPrinter->GetPaperSize() );
970 if( aSetSize.Width && aSetSize.Height )
972 Size aSetPaperSize( aSetSize.Width, aSetSize.Height );
973 Size aRealPaperSize( getRealPaperSize( aSetPaperSize,
true ) );
974 if( aRealPaperSize != aCurSize )
978 if( aIsSize.Width && aIsSize.Height )
983 Size aRealPaperSize( getRealPaperSize( aPageSize.
aSize,
true ) );
984 if( aRealPaperSize != aCurSize )
985 mxPrinter->SetPaperSizeUser( aRealPaperSize );
990 if ( mnFixedPaperBin != -1 )
991 nPaperBin = mnFixedPaperBin;
993 if( nPaperBin != -1 && nPaperBin != mxPrinter->GetPaperBin() )
994 mxPrinter->SetPaperBin( nPaperBin );
1011 mxPrinter->SetMapMode(
MapMode(MapUnit::Map100thMM));
1012 Size aCurSize(mxPrinter->GetPaperSize());
1013 if (aCurSize != maDefaultPageSize)
1014 mxPrinter->SetPaperSizeUser(maDefaultPageSize);
1020 const MapMode aMapMode( MapUnit::Map100thMM );
1023 mpImplData->mxPrinter->SetMapMode( aMapMode );
1031 const MapMode aMapMode( MapUnit::Map100thMM );
1034 mpImplData->mxPrinter->SetMapMode( aMapMode );
1035 css::uno::Sequence< css::beans::PropertyValue > aResult(
getPageParameters( i_nPage ) );
1052 if( i_bMayUseCache )
1055 if(
mpImplData->maPageCache.get( i_nUnfilteredPage, o_rMtf, aPageSize ) )
1067 const MapMode aMapMode( MapUnit::Map100thMM );
1070 mpImplData->mxPrinter->SetMapMode( aMapMode );
1078 mpImplData->mxPrinter->EnableOutput(
false );
1088 if( i_bMayUseCache )
1089 mpImplData->maPageCache.insert( i_nUnfilteredPage, o_rMtf, aPageSize );
1101 io_rSubPage.
Clip( i_rClipRect );
1111 io_rSubPage.
Play( o_rMtf );
1117 if( !i_bDrawBorder )
1144 i_nFilteredPage = nDocPages - 1 - i_nFilteredPage;
1150 if( nSubPages == 1 &&
1155 if (
mpImplData->meJobState != css::view::PrintableState_JOB_STARTED)
1161 mpImplData->mxPrinter->SetPaperSizeUser( aPaperSize );
1162 if( aPaperSize != aPageSize.
aSize )
1171 aPageSize.
aSize = aPaperSize;
1185 Size aMPArea( aPaperSize );
1204 if (
mpImplData->meJobState != css::view::PrintableState_JOB_STARTED)
1208 for(
int nSubPage = 0; nSubPage < nSubPages; nSubPage++ )
1211 int nPage = i_nFilteredPage * nSubPages + nSubPage;
1212 if( nSubPage == nSubPages-1 ||
1213 nPage == nDocPages-1 )
1217 if( nPage >= 0 && nPage < nDocPages )
1227 nCellX = (nSubPage % rMPS.
nColumns);
1228 nCellY = (nSubPage / rMPS.
nColumns);
1231 nCellX = (nSubPage / rMPS.
nRows);
1232 nCellY = (nSubPage % rMPS.
nRows);
1236 nCellY = (nSubPage / rMPS.
nColumns);
1240 nCellY = (nSubPage % rMPS.
nRows);
1244 double fScaleX = double(aSubPageSize.
Width())/double(aPageSize.
aSize.
Width());
1245 double fScaleY = double(aSubPageSize.
Height())/double(aPageSize.
aSize.
Height());
1246 double fScale = std::min( fScaleX, fScaleY );
1247 aPageFile.
Scale( fScale, fScale );
1271 mpImplData->mxPrinter->SetPaperSizeUser( aPaperSize );
1287 sal_Int32 nMaxBmpDPIX =
mpImplData->mxPrinter->GetDPIX();
1288 sal_Int32 nMaxBmpDPIY =
mpImplData->mxPrinter->GetDPIY();
1290 const vcl::printer::Options& rPrinterOptions =
mpImplData->mxPrinter->GetPrinterOptions();
1292 static const sal_Int32 OPTIMAL_BMP_RESOLUTION = 300;
1293 static const sal_Int32 NORMAL_BMP_RESOLUTION = 200;
1295 if( rPrinterOptions.IsReduceBitmaps() )
1300 nMaxBmpDPIX = std::min( sal_Int32(OPTIMAL_BMP_RESOLUTION), nMaxBmpDPIX );
1301 nMaxBmpDPIY = std::min( sal_Int32(OPTIMAL_BMP_RESOLUTION), nMaxBmpDPIY );
1305 nMaxBmpDPIX = std::min( sal_Int32(NORMAL_BMP_RESOLUTION), nMaxBmpDPIX );
1306 nMaxBmpDPIY = std::min( sal_Int32(NORMAL_BMP_RESOLUTION), nMaxBmpDPIY );
1310 nMaxBmpDPIX = std::min( sal_Int32(rPrinterOptions.GetReducedBitmapResolution()), nMaxBmpDPIX );
1311 nMaxBmpDPIY = std::min( sal_Int32(rPrinterOptions.GetReducedBitmapResolution()), nMaxBmpDPIY );
1316 if( rPrinterOptions.IsConvertToGreyscales() )
1337 mpImplData->mxPrinter->RemoveTransparenciesFromMetaFile( i_rIn, o_rOut, nMaxBmpDPIX, nMaxBmpDPIY,
1338 rPrinterOptions.IsReduceTransparency(),
1340 rPrinterOptions.IsReduceBitmaps() && rPrinterOptions.IsReducedBitmapIncludesTransparency(),
1343 return nRestoreDrawMode;
1348 if(
mpImplData->meJobState != css::view::PrintableState_JOB_STARTED )
1359 setJobState( css::view::PrintableState_JOB_ABORTED );
1379 aPageFile.
Move( -aPageOffset.X(), -aPageOffset.Y(),
mpImplData->mxPrinter->GetDPIX(),
mpImplData->mxPrinter->GetDPIY() );
1397 mpImplData->mxPrinter->SetDrawMode( nRestoreDrawMode );
1410 setJobState( css::view::PrintableState_JOB_ABORTED );
1437 mpImplData->mbPapersizeFromSetup = i_bPapersizeFromSetup;
1438 mpImplData->mxPrinter->SetPrinterSettingsPreferred( i_bPapersizeFromSetup );
1439 if ( i_bPapersizeFromSetup )
1455 mpImplData->mxPrinter->SetPrinterSettingsPreferred(
false );
1463 mpImplData->meUserOrientation = eOrientation;
1468 mpImplData->mbPrinterModified = i_bPrinterModified;
1478 std::unordered_set< OUString > aMergeSet;
1479 size_t nResultLen = size_t(i_rMergeList.getLength()) +
mpImplData->maUIProperties.size() + 3;
1480 for(
const auto& rPropVal : i_rMergeList )
1481 aMergeSet.insert( rPropVal.Name );
1483 css::uno::Sequence< css::beans::PropertyValue > aResult( nResultLen );
1484 auto pResult = aResult.getArray();
1485 std::copy(i_rMergeList.begin(), i_rMergeList.end(), pResult);
1486 int nCur = i_rMergeList.getLength();
1487 for(
const css::beans::PropertyValue & rPropVal :
mpImplData->maUIProperties)
1489 if( aMergeSet.find( rPropVal.Name ) == aMergeSet.end() )
1490 pResult[nCur++] = rPropVal;
1493 if( aMergeSet.find(
"IsFirstPage" ) == aMergeSet.end() )
1495 css::beans::PropertyValue aVal;
1496 aVal.Name =
"IsFirstPage";
1498 pResult[nCur++] = aVal;
1501 if( aMergeSet.find(
"IsLastPage" ) == aMergeSet.end() )
1503 css::beans::PropertyValue aVal;
1504 aVal.Name =
"IsLastPage";
1506 pResult[nCur++] = aVal;
1509 if( aMergeSet.find(
"IsPrinter" ) == aMergeSet.end() )
1511 css::beans::PropertyValue aVal;
1512 aVal.Name =
"IsPrinter";
1513 aVal.Value <<=
true;
1514 pResult[nCur++] = aVal;
1516 aResult.realloc( nCur );
1527 std::unordered_map< OUString, size_t >::const_iterator it =
1528 mpImplData->maPropertyToIndex.find( i_rProperty );
1529 return it !=
mpImplData->maPropertyToIndex.end() ? &
mpImplData->maUIProperties[it->second] :
nullptr;
1534 std::unordered_map< OUString, size_t >::const_iterator it =
1535 mpImplData->maPropertyToIndex.find( i_rProperty );
1536 return it !=
mpImplData->maPropertyToIndex.end() ? &
mpImplData->maUIProperties[it->second] :
nullptr;
1541 css::beans::PropertyValue aVal;
1542 aVal.Name = i_rPropertyName;
1543 aVal.Value = i_rValue;
1550 std::unordered_map< OUString, size_t >::const_iterator it =
1551 mpImplData->maPropertyToIndex.find( i_rPropertyValue.Name );
1552 if( it !=
mpImplData->maPropertyToIndex.end() )
1553 mpImplData->maUIProperties[ it->second ] = i_rPropertyValue;
1558 mpImplData->maUIProperties.push_back( i_rPropertyValue );
1559 mpImplData->maUIPropertyEnabled.push_back(
true );
1569 for(
const auto& rOpt : i_rOptions )
1571 css::uno::Sequence< css::beans::PropertyValue > aOptProp;
1572 rOpt.Value >>= aOptProp;
1574 bool bHaveProperty =
false;
1577 css::uno::Sequence< sal_Bool > aChoicesDisabled;
1578 for(
const css::beans::PropertyValue& rEntry : std::as_const(aOptProp) )
1580 if ( rEntry.Name ==
"Property" )
1582 css::beans::PropertyValue aVal;
1583 rEntry.Value >>= aVal;
1585 ==
mpImplData->maPropertyToIndex.end(),
"duplicate property entry" );
1588 bHaveProperty =
true;
1590 else if ( rEntry.Name ==
"Enabled" )
1593 rEntry.Value >>= bValue;
1596 else if ( rEntry.Name ==
"DependsOnName" )
1600 else if ( rEntry.Name ==
"DependsOnEntry" )
1604 else if ( rEntry.Name ==
"ChoicesDisabled" )
1606 rEntry.Value >>= aChoicesDisabled;
1611 vcl::ImplPrinterControllerData::PropertyToIndexMap::const_iterator it =
1614 if( it !=
mpImplData->maPropertyToIndex.end() )
1620 if( aChoicesDisabled.hasElements() )
1628 bool bEnabled =
false;
1629 std::unordered_map< OUString, size_t >::const_iterator prop_it =
1630 mpImplData->maPropertyToIndex.find( i_rProperty );
1631 if( prop_it !=
mpImplData->maPropertyToIndex.end() )
1633 bEnabled =
mpImplData->maUIPropertyEnabled[prop_it->second];
1638 vcl::ImplPrinterControllerData::ControlDependencyMap::const_iterator it =
1639 mpImplData->maControlDependencies.find( i_rProperty );
1640 if( it !=
mpImplData->maControlDependencies.end() )
1649 const css::beans::PropertyValue* pVal =
getValue( it->second.maDependsOnName );
1650 OSL_ENSURE( pVal,
"unknown property in dependency" );
1653 sal_Int32 nDepVal = 0;
1654 bool bDepVal =
false;
1655 if( pVal->Value >>= nDepVal )
1657 bEnabled = (nDepVal == it->second.mnDependsOnEntry) || (it->second.mnDependsOnEntry == -1);
1659 else if( pVal->Value >>= bDepVal )
1663 bEnabled = ( bDepVal && it->second.mnDependsOnEntry != 0) ||
1664 ( ! bDepVal && it->second.mnDependsOnEntry == 0);
1669 OSL_FAIL(
"strange type in control dependency" );
1682 bool bEnabled =
true;
1683 ImplPrinterControllerData::ChoiceDisableMap::const_iterator it =
1684 mpImplData->maChoiceDisableMap.find( i_rProperty );
1685 if(it !=
mpImplData->maChoiceDisableMap.end() )
1687 const css::uno::Sequence< sal_Bool >& rDisabled( it->second );
1688 if( i_nValue >= 0 && i_nValue < rDisabled.getLength() )
1689 bEnabled = ! rDisabled[i_nValue];
1696 OUString aDependency;
1698 vcl::ImplPrinterControllerData::ControlDependencyMap::const_iterator it =
1699 mpImplData->maControlDependencies.find( i_rProperty );
1700 if( it !=
mpImplData->maControlDependencies.end() )
1704 aDependency = it->second.maDependsOnName;
1705 const css::beans::PropertyValue* pVal =
getValue( aDependency );
1706 OSL_ENSURE( pVal,
"unknown property in dependency" );
1709 sal_Int32 nDepVal = 0;
1710 bool bDepVal =
false;
1711 if( pVal->Value >>= nDepVal )
1713 if( it->second.mnDependsOnEntry != -1 )
1715 setValue( aDependency, css::uno::Any( sal_Int32( it->second.mnDependsOnEntry ) ) );
1718 else if( pVal->Value >>= bDepVal )
1720 setValue( aDependency, css::uno::Any( it->second.mnDependsOnEntry != 0 ) );
1725 OSL_FAIL(
"strange type in control dependency" );
1739 css::beans::PropertyValue* pMonitor =
getValue(
"MonitorVisible" );
1741 pMonitor->Value >>= bShow;
1744 const css::beans::PropertyValue* pVal =
getValue(
"IsApi" );
1748 pVal->Value >>= bApi;
1788 sal_Int32 nCopyCount = 1;
1790 const css::beans::PropertyValue* pVal =
getValue(
"CopyCount" );
1792 pVal->Value >>= nCopyCount;
1793 bool bCollate =
false;
1796 pVal->Value >>= bCollate;
1797 mpImplData->mxPrinter->SetCopyCount(
static_cast<sal_uInt16
>(nCopyCount), bCollate );
1799 pVal =
getValue(
"SinglePrintJobs");
1800 bool bSinglePrintJobs =
false;
1802 pVal->Value >>= bSinglePrintJobs;
1803 mpImplData->mxPrinter->SetSinglePrintJobs(bSinglePrintJobs);
1809 sal_Int16 nDuplex = css::view::DuplexMode::UNKNOWN;
1810 pVal->Value >>= nDuplex;
1834 bool bRet = i_bFallback;
1835 const css::beans::PropertyValue* pVal =
getValue( i_rProperty );
1837 pVal->Value >>= bRet;
1843 sal_Int32 nRet = i_nFallback;
1844 const css::beans::PropertyValue* pVal =
getValue( i_rProperty );
1846 pVal->Value >>= nRet;
1856 std::unordered_map< OUString, css::uno::Any >::const_iterator it =
1866 css::uno::Any aVal(
getValue( i_rPropertyName ) );
1867 return (aVal >>= bRet) ? bRet : i_bDefault;
1873 css::uno::Any aVal(
getValue( i_rPropertyName ) );
1874 return (aVal >>= nRet) ? nRet : i_nDefault;
1880 css::uno::Any aVal(
getValue( i_rPropertyName ) );
1881 return (aVal >>= aRet) ? aRet : OUString();
1886 bool bChanged =
false;
1888 for(
const auto& rVal : i_rNewProp )
1890 std::unordered_map< OUString, css::uno::Any >::iterator it =
1893 bool bElementChanged = (it ==
m_aPropertyMap.end()) || (it->second != rVal.Value);
1894 if( bElementChanged )
1907 sal_Int32
nIndex = io_rProps.getLength();
1908 io_rProps.realloc(
nIndex+1 );
1915 const OUString& i_rTitle,
1916 const css::uno::Sequence< OUString >& i_rHelpIds,
1917 const OUString& i_rType,
1918 const css::beans::PropertyValue* i_pVal,
1923 + (i_rTitle.isEmpty() ? 0 : 1)
1924 + (i_rHelpIds.hasElements() ? 1 : 0)
1927 + (i_rControlOptions.
maGroupHint.isEmpty() ? 0 : 1)
1940 css::uno::Sequence< css::beans::PropertyValue > aCtrl(
nElements );
1941 auto pCtrl = aCtrl.getArray();
1942 sal_Int32 nUsed = 0;
1943 if( !i_rTitle.isEmpty() )
1945 pCtrl[nUsed ].Name =
"Text";
1946 pCtrl[nUsed++].Value <<= i_rTitle;
1948 if( i_rHelpIds.hasElements() )
1950 pCtrl[nUsed ].Name =
"HelpId";
1951 pCtrl[nUsed++].Value <<= i_rHelpIds;
1953 pCtrl[nUsed ].Name =
"ControlType";
1954 pCtrl[nUsed++].Value <<= i_rType;
1955 pCtrl[nUsed ].Name =
"ID";
1956 pCtrl[nUsed++].Value <<= i_rIDs;
1959 pCtrl[nUsed ].Name =
"Property";
1960 pCtrl[nUsed++].Value <<= *i_pVal;
1964 pCtrl[nUsed ].Name =
"DependsOnName";
1968 pCtrl[nUsed ].Name =
"DependsOnEntry";
1973 pCtrl[nUsed ].Name =
"AttachToDependency";
1979 pCtrl[nUsed ].Name =
"GroupingHint";
1980 pCtrl[nUsed++].Value <<= i_rControlOptions.
maGroupHint;
1984 pCtrl[nUsed ].Name =
"InternalUIOnly";
1985 pCtrl[nUsed++].Value <<=
true;
1989 pCtrl[nUsed ].Name =
"Enabled";
1990 pCtrl[nUsed++].Value <<=
false;
1993 sal_Int32 nAddProps = i_rControlOptions.
maAddProps.size();
1994 for( sal_Int32
i = 0;
i < nAddProps;
i++ )
1995 pCtrl[ nUsed++ ] = i_rControlOptions.
maAddProps[
i];
1999 return css::uno::Any( aCtrl );
2003 const OUString& i_rTitle,
2004 const OUString& i_rHelpId)
2006 css::uno::Sequence< OUString > aHelpId;
2007 if( !i_rHelpId.isEmpty() )
2009 aHelpId.realloc( 1 );
2010 *aHelpId.getArray() = i_rHelpId;
2012 css::uno::Sequence< OUString > aIds { i_rID };
2017 const OUString& i_rTitle,
2018 const OUString& i_rHelpId,
2021 css::uno::Sequence< OUString > aHelpId;
2022 if( !i_rHelpId.isEmpty() )
2024 aHelpId.realloc( 1 );
2025 *aHelpId.getArray() = i_rHelpId;
2027 css::uno::Sequence< OUString > aIds { i_rID };
2028 return setUIControlOpt(aIds, i_rTitle, aHelpId,
"Subgroup",
nullptr, i_rControlOptions);
2032 const OUString& i_rTitle,
2033 const OUString& i_rHelpId,
2034 const OUString& i_rProperty,
2038 css::uno::Sequence< OUString > aHelpId;
2039 if( !i_rHelpId.isEmpty() )
2041 aHelpId.realloc( 1 );
2042 *aHelpId.getArray() = i_rHelpId;
2044 css::beans::PropertyValue aVal;
2045 aVal.Name = i_rProperty;
2046 aVal.Value <<= i_bValue;
2047 css::uno::Sequence< OUString > aIds { i_rID };
2048 return setUIControlOpt(aIds, i_rTitle, aHelpId,
"Bool", &aVal, i_rControlOptions);
2052 const OUString& i_rTitle,
2053 const css::uno::Sequence< OUString >& i_rHelpId,
2054 const OUString& i_rProperty,
2055 const css::uno::Sequence< OUString >& i_rChoices,
2057 const css::uno::Sequence< sal_Bool >& i_rDisabledChoices,
2062 aOpt.
maAddProps.resize( nUsed + 1 + (i_rDisabledChoices.hasElements() ? 1 : 0) );
2065 if( i_rDisabledChoices.hasElements() )
2067 aOpt.
maAddProps[nUsed+1].Name =
"ChoicesDisabled";
2068 aOpt.
maAddProps[nUsed+1].Value <<= i_rDisabledChoices;
2071 css::beans::PropertyValue aVal;
2072 aVal.Name = i_rProperty;
2073 aVal.Value <<= i_nValue;
2074 return setUIControlOpt(i_rIDs, i_rTitle, i_rHelpId,
"Radio", &aVal, aOpt);
2078 const OUString& i_rTitle,
2079 const css::uno::Sequence< OUString >& i_rHelpId,
2080 const OUString& i_rProperty,
2081 const css::uno::Sequence< OUString >& i_rChoices,
2083 const css::uno::Sequence< sal_Bool >& i_rDisabledChoices,
2088 aOpt.
maAddProps.resize( nUsed + 1 + (i_rDisabledChoices.hasElements() ? 1 : 0) );
2091 if( i_rDisabledChoices.hasElements() )
2093 aOpt.
maAddProps[nUsed+1].Name =
"ChoicesDisabled";
2094 aOpt.
maAddProps[nUsed+1].Value <<= i_rDisabledChoices;
2097 css::beans::PropertyValue aVal;
2098 aVal.Name = i_rProperty;
2099 aVal.Value <<= i_nValue;
2100 css::uno::Sequence< OUString > aIds { i_rID };
2101 return setUIControlOpt(aIds, i_rTitle, i_rHelpId,
"List", &aVal, aOpt);
2105 const OUString& i_rTitle,
2106 const OUString& i_rHelpId,
2107 const OUString& i_rProperty,
2109 sal_Int32 i_nMinValue,
2110 sal_Int32 i_nMaxValue,
2114 if( i_nMaxValue >= i_nMinValue )
2119 aOpt.
maAddProps[nUsed++].Value <<= i_nMinValue;
2121 aOpt.
maAddProps[nUsed++].Value <<= i_nMaxValue;
2124 css::uno::Sequence< OUString > aHelpId;
2125 if( !i_rHelpId.isEmpty() )
2127 aHelpId.realloc( 1 );
2128 *aHelpId.getArray() = i_rHelpId;
2130 css::beans::PropertyValue aVal;
2131 aVal.Name = i_rProperty;
2132 aVal.Value <<= i_nValue;
2133 css::uno::Sequence< OUString > aIds { i_rID };
2134 return setUIControlOpt(aIds, i_rTitle, aHelpId,
"Range", &aVal, aOpt);
2138 const OUString& i_rTitle,
2139 const OUString& i_rHelpId,
2140 const OUString& i_rProperty,
2141 const OUString& i_rValue,
2144 css::uno::Sequence< OUString > aHelpId;
2145 if( !i_rHelpId.isEmpty() )
2147 aHelpId.realloc( 1 );
2148 *aHelpId.getArray() = i_rHelpId;
2150 css::beans::PropertyValue aVal;
2151 aVal.Name = i_rProperty;
2152 aVal.Value <<= i_rValue;
2153 css::uno::Sequence< OUString > aIds { i_rID };
2154 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)
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