22#include <osl/diagnose.h>
23#include <rtl/ustrbuf.hxx>
25#include <officecfg/Office/Common.hxx>
42#include <bitmaps.hlst>
48#include <com/sun/star/beans/PropertyValue.hpp>
65 bool lcl_ListBoxCompare(
const OUString& rStr1,
const OUString& rStr2 )
71PrintDialog::PrintPreviewWindow::PrintPreviewWindow(
PrintDialog* pDialog)
73 , maOrigSize( 10, 10 )
74 , mnDPIX(
Application::GetDefaultDevice()->GetDPIX())
75 , mnDPIY(
Application::GetDefaultDevice()->GetDPIY())
76 , mbGreyscale( false )
86 Size aNewSize(GetOutputSizePixel());
87 tools::Long nTextHeight = GetDrawingArea()->get_text_height();
95 Size aOrigSize( maOrigSize );
96 if( aOrigSize.
Width() < 1 )
98 if( aOrigSize.
Height() < 1 )
104 fScale = double(aNewSize.
Height())/double(aScaledSize.
Height());
110 fScale = double(aNewSize.
Width())/double(aScaledSize.
Width());
115 maPreviewSize = aScaledSize;
118 preparePreviewBitmap();
123 rRenderContext.
Push();
127 rRenderContext.
Erase();
130 Size aSize(GetOutputSizePixel());
131 Point aOffset((aSize.
Width() - maPreviewSize.Width() + nTextHeight) / 2,
132 (aSize.
Height() - maPreviewSize.Height() + nTextHeight) / 2);
138 auto nStart = aOffset.
X() + (maPreviewSize.Width() - nWidth) / 2;
139 rRenderContext.
DrawText(
Point(nStart, aOffset.
Y() - nTextHeight), maHorzText, 0, maHorzText.getLength());
142 auto nTop = aOffset.
Y() - (nTextHeight / 2);
154 auto nLeft = aOffset.
X() - nTextHeight;
157 auto nStart = aOffset.
Y() + (maPreviewSize.Height() + nWidth) / 2;
159 rRenderContext.
DrawText(
Point(nLeft, nStart), maVertText, 0, maVertText.getLength());
162 nLeft = aOffset.
X() - (nTextHeight / 2);
166 rRenderContext.
Pop();
169 if (!maReplacementString.isEmpty())
173 rRenderContext.
DrawText(aTextRect, maReplacementString,
179 BitmapEx aPreviewBitmap(maPreviewBitmap);
193 rRenderContext.
Pop();
202 mpDialog->previewForward();
203 else if (pWheelData->
GetDelta() < 0)
204 mpDialog->previewBackward();
207 return CustomWidgetController::Command(rEvt);
211 const Size& i_rOrigSize,
212 std::u16string_view i_rPaperName,
213 const OUString& i_rReplacement,
219 maMtf = i_rNewPreview;
222 maOrigSize = i_rOrigSize;
223 maReplacementString = i_rReplacement;
224 mbGreyscale = i_bGreyscale;
236 OUString aNumText( rLocWrap.
getNum( aLogicPaperSize.
Width(), nDigits ) );
237 OUStringBuffer
aBuf( aNumText +
" " );
239 if( !i_rPaperName.empty() )
241 aBuf.append( OUString::Concat(
" (") + i_rPaperName +
")" );
243 maHorzText =
aBuf.makeStringAndClear();
245 aNumText = rLocWrap.
getNum( aLogicPaperSize.
Height(), nDigits );
246 aBuf.append( aNumText +
" " );
248 maVertText =
aBuf.makeStringAndClear();
252 maPreviewBitmap =
Bitmap();
263 if(maPreviewSize.IsEmpty())
272 const sal_uInt32 nMaxSquarePixels(500000);
276 const sal_uInt32 nCurrentSquarePixels(
279 static_cast<sal_uInt32
>(maPreviewBitmap.GetSizePixel().getWidth())
280 *
static_cast<sal_uInt32
>(maPreviewBitmap.GetSizePixel().getHeight())));
284 const sal_uInt32 nRequiredSquarePixels(
287 static_cast<sal_uInt32
>(maPreviewSize.getWidth())
288 *
static_cast<sal_uInt32
>(maPreviewSize.getHeight())));
295 static const double fPreventAwkwardFactor(1.35);
296 if(nCurrentSquarePixels >=
static_cast<sal_uInt32
>(nRequiredSquarePixels * fPreventAwkwardFactor))
307 if(nRequiredSquarePixels < 64)
315 static const double fExtraSpaceFactor(1.65);
316 const sal_uInt32 nPlannedSquarePixels(
319 static_cast<sal_uInt32
>(maPreviewSize.getWidth() * fExtraSpaceFactor)
320 *
static_cast<sal_uInt32
>(maPreviewSize.getHeight() * fExtraSpaceFactor)));
325 const double fRatio(
static_cast<double>(maPreviewSize.getWidth()) /
static_cast<double>(maPreviewSize.getHeight()));
326 const double fNewWidth(sqrt(
static_cast<double>(nPlannedSquarePixels) * fRatio));
327 const double fNewHeight(sqrt(
static_cast<double>(nPlannedSquarePixels) / fRatio));
334 const double fScaledSizeSquare(
static_cast<double>(aScaledSize.
getWidth() * aScaledSize.
getHeight()));
335 const double fPreviewSizeSquare(
static_cast<double>(maPreviewBitmap.GetSizePixel().getWidth() * maPreviewBitmap.GetSizePixel().getHeight()));
338 if(fPreviewSizeSquare != 0.0 && fabs((fScaledSizeSquare / fPreviewSizeSquare) - 1.0) < 0.001)
347 pPrerenderVDev->SetOutputSizePixel(aScaledSize,
false);
348 pPrerenderVDev->SetReferenceDevice( mnDPIX, mnDPIY );
351 Size aLogicSize( pPrerenderVDev->PixelToLogic( pPrerenderVDev->GetOutputSizePixel(),
MapMode( MapUnit::Map100thMM ) ) );
352 Size aOrigSize( maOrigSize );
353 if( aOrigSize.
Width() < 1 )
355 if( aOrigSize.
Height() < 1 )
357 double fScale = double(aLogicSize.
Width())/double(aOrigSize.
Width());
381 static const double fMinimumScale(0.2);
383 if(fScale < fMinimumScale)
385 fFactor = fMinimumScale / fScale;
386 fScale = fMinimumScale;
388 double fWidth(aScaledSize.
getWidth() * fFactor);
389 double fHeight(aScaledSize.
getHeight() * fFactor);
390 const double fNewNeededPixels(fWidth * fHeight);
397 static const double fMaximumQualitySquare(1396221.0);
399 if(fNewNeededPixels > fMaximumQualitySquare)
401 const double fCorrection(fMaximumQualitySquare/fNewNeededPixels);
402 fWidth *= fCorrection;
403 fHeight *= fCorrection;
404 fScale *= fCorrection;
408 pPrerenderVDev->SetOutputSizePixel(aScaledSize2,
false);
409 aLogicSize = pPrerenderVDev->PixelToLogic( aScaledSize2,
MapMode( MapUnit::Map100thMM ) );
412 pPrerenderVDev->EnableOutput();
414 pPrerenderVDev->Erase();
415 pPrerenderVDev->SetMapMode(
MapMode(MapUnit::Map100thMM));
417 pPrerenderVDev->SetDrawMode( pPrerenderVDev->GetDrawMode() |
424 aMtf.
Scale( fScale, fScale );
426 aMtf.
Play(*pPrerenderVDev,
Point(0, 0), aLogicSize);
428 pPrerenderVDev->SetMapMode(
MapMode(MapUnit::MapPixel));
429 maPreviewBitmap = pPrerenderVDev->GetBitmapEx(
Point(0, 0), pPrerenderVDev->GetOutputSizePixel());
451 CustomWidgetController::SetDrawingArea(pDrawingArea);
452 SetOutputSizePixel(aSize);
460 rRenderContext.
Erase();
462 int nPages = mnRows * mnColumns;
467 Size aOutSize(GetOutputSizePixel());
468 Size aSubSize(aOutSize.
Width() / mnColumns, aOutSize.
Height() / mnRows);
470 double fX = double(aSubSize.
Width()) / double(aSampleTextSize.
Width());
471 double fY = double(aSubSize.
Height()) / double(aSampleTextSize.
Height());
472 double fScale = (fX < fY) ? fX : fY;
479 for (
int i = 0;
i < nPages;
i++)
486 nX = (
i % mnColumns);
487 nY = (
i / mnColumns);
494 nX = mnColumns - 1 - (
i % mnColumns);
495 nY = (
i / mnColumns);
498 nX = mnColumns - 1 - (
i / mnRows);
503 int nDeltaX = (aSubSize.
Width() - aTextSize.
Width()) / 2;
504 int nDeltaY = (aSubSize.
Height() - aTextSize.
Height()) / 2;
601 std::sort( rQueues.begin(), rQueues.end(), lcl_ListBoxCompare );
602 for(
const auto& rQueue : rQueues )
613 OUString aValue( pItem->
getValue(
"PrintDialog",
718 officecfg::Office::Common::Print::Dialog::RangeSectionExpanded::get());
720 officecfg::Office::Common::Print::Dialog::LayoutSectionExpanded::get());
733 officecfg::Office::Common::Print::Dialog::RangeSectionExpanded::set(
mxRangeExpander->get_expanded(), batch);
734 officecfg::Office::Common::Print::Dialog::LayoutSectionExpanded::set(
mxLayoutExpander->get_expanded(), batch);
798 OUString aValue = pItem->
getValue(
"PrintDialog",
803 OUString sPageId =
mxTabCtrl->get_page_ident(
i);
804 if (aValue ==
mxTabCtrl->get_tab_label_text(sPageId))
812 aValue = pItem->
getValue(
"PrintDialog",
814 if (!aValue.isEmpty())
818 aValue = pItem->
getValue(
"PrintDialog",
820 if( aValue.equalsIgnoreAsciiCase(
"alwaysoff") )
829 aValue = pItem->
getValue(
"PrintDialog",
831 mxCollateBox->set_active( aValue.equalsIgnoreAsciiCase(
"true") );
835 aValue = pItem->
getValue(
"PrintDialog",
836 "CollateSingleJobs" );
840 aValue = pItem->
getValue(
"PrintDialog",
842 if ( aValue.equalsIgnoreAsciiCase(
"false") )
881 OUString aWidth( rLocWrap.
getNum( aLogicPaperSize.
Width(), nDigits ) );
882 OUString aHeight( rLocWrap.
getNum( aLogicPaperSize.
Height(), nDigits ) );
883 OUString aUnit = eUnit ==
o3tl::Length::mm ? OUString(
"mm") : OUString(
"in");
891 aPaperName += aWidth + aUnit +
" x " + aHeight + aUnit;
930 preparePreview(
true);
935 preparePreview(
false);
954 mxPreview->setPreview( aMtf, aCurPageSize,
984 const MapMode aMapMode( MapUnit::Map100thMM );
986 aMtf.
Move( aOff.
X(), aOff.
Y() );
992 mxPreview->setPreview( aMtf, aCurPageSize,
1033 maPController->setOrientationFromUser( eOrientation, fromUser );
1049 OUString aImg(
mxCollateBox->get_active() ? OUString(SV_PRINT_COLLATE_BMP) : OUString(SV_PRINT_NOCOLLATE_BMP));
1062 bool bShouldbeEnabled =
maPController->isUIOptionEnabled( rEntry.second );
1069 bShouldbeEnabled =
maPController->isUIChoiceEnabled( rEntry.second, r_it->second );
1073 bool bIsEnabled = rEntry.first->get_sensitive();
1076 rEntry.first->set_sensitive( bShouldbeEnabled );
1089 sal_uInt16 nDigits = 0;
1092 eUnit = FieldUnit::INCH;
1150 Size aMultiSize( aPageSize.
Width() * nCols, aPageSize.
Height() * nRows );
1180 bool bCustom =
false;
1188 else if( nPages == 2 || nPages == 4 || nPages == 6 || nPages == 9 || nPages == 16 )
1191 bool bPortrait = aJobPageSize.
Width() < aJobPageSize.
Height();
1205 else if( nPages == 4 )
1207 else if( nPages == 6 )
1220 else if( nPages == 9 )
1222 else if( nPages == 16 )
1238 if( nSheetMargin > nHorzMax )
1239 nSheetMargin = nHorzMax;
1240 if( nSheetMargin > nVertMax )
1241 nSheetMargin = nVertMax;
1245 std::min(nHorzMax, nVertMax) ), FieldUnit::MM_100TH );
1248 nHorzMax = (aSize.
Width() - 2*nSheetMargin);
1250 nHorzMax /= (nCols-1);
1251 nVertMax = (aSize.
Height() - 2*nSheetMargin);
1253 nHorzMax /= (nRows-1);
1255 if( nPageMargin > nHorzMax )
1256 nPageMargin = nHorzMax;
1257 if( nPageMargin > nVertMax )
1258 nPageMargin = nVertMax;
1262 std::min(nHorzMax, nVertMax ) ), FieldUnit::MM_100TH );
1311 if( i_nIndex >= 0 && i_nIndex < i_rHelpIds.getLength() )
1312 i_pWindow->
set_help_id( i_rHelpIds.getConstArray()[i_nIndex] );
1319 if( i_nIndex >= 0 && i_nIndex < i_rHelpTexts.getLength() )
1327 for(
const auto& rOption : rOptions )
1329 if (rOption.Name ==
"OptionsUIFile")
1331 OUString sOptionsUIFile;
1332 rOption.Value >>= sOptionsUIFile;
1340 rOption.Value >>= aOptProp;
1346 OUString aPropertyName;
1352 sal_Int64 nMinValue = 0, nMaxValue = 0;
1353 OUString aGroupingHint;
1355 for(
const beans::PropertyValue& rEntry : std::as_const(aOptProp) )
1357 if ( rEntry.Name ==
"ID" )
1359 rEntry.Value >>= aIDs;
1362 if ( rEntry.Name ==
"Text" )
1364 rEntry.Value >>= aText;
1366 else if ( rEntry.Name ==
"ControlType" )
1368 rEntry.Value >>= aCtrlType;
1370 else if ( rEntry.Name ==
"Choices" )
1372 rEntry.Value >>= aChoices;
1374 else if ( rEntry.Name ==
"ChoicesDisabled" )
1376 rEntry.Value >>= aChoicesDisabled;
1378 else if ( rEntry.Name ==
"Property" )
1381 rEntry.Value >>= aVal;
1382 aPropertyName = aVal.Name;
1384 else if ( rEntry.Name ==
"Enabled" )
1387 else if ( rEntry.Name ==
"GroupingHint" )
1389 rEntry.Value >>= aGroupingHint;
1391 else if ( rEntry.Name ==
"DependsOnName" )
1394 else if ( rEntry.Name ==
"DependsOnEntry" )
1397 else if ( rEntry.Name ==
"AttachToDependency" )
1400 else if ( rEntry.Name ==
"MinValue" )
1402 rEntry.Value >>= nMinValue;
1404 else if ( rEntry.Name ==
"MaxValue" )
1406 rEntry.Value >>= nMaxValue;
1408 else if ( rEntry.Name ==
"HelpText" )
1410 if( ! (rEntry.Value >>= aHelpTexts) )
1413 if( rEntry.Value >>= aHelpText )
1415 aHelpTexts.realloc( 1 );
1416 *aHelpTexts.getArray() = aHelpText;
1420 else if ( rEntry.Name ==
"HelpId" )
1422 if( ! (rEntry.Value >>= aHelpIds ) )
1425 if( rEntry.Value >>= aHelpId )
1427 aHelpIds.realloc( 1 );
1428 *aHelpIds.getArray() = aHelpId;
1432 else if ( rEntry.Name ==
"HintNoLayoutPage" )
1434 bool bHasLayoutFrame =
false;
1435 rEntry.Value >>= bHasLayoutFrame;
1440 if (aCtrlType ==
"Group")
1448 mxTabCtrl->set_tab_label_text(aID, aText);
1451 if (aHelpIds.hasElements())
1455 if (aHelpTexts.hasElements())
1460 else if (aCtrlType ==
"Subgroup" && !aID.isEmpty())
1462 std::unique_ptr<weld::Widget> xWidget;
1464 if (aID ==
"fromwhich")
1466 std::unique_ptr<weld::Label> xLabel =
m_xBuilder->weld_label(aID);
1467 xLabel->set_label(aText);
1468 xWidget = std::move(xLabel);
1477 xFrame->set_label(aText);
1478 xWidget = std::move(
xFrame);
1486 setHelpId(xWidget.get(), aHelpIds, 0);
1488 setHelpText(xWidget.get(), aHelpTexts, 0);
1493 else if( aCtrlType ==
"Bool" && aGroupingHint ==
"LayoutPage" && aPropertyName ==
"PrintProspect" )
1499 PropertyValue* pVal =
maPController->getValue( aPropertyName );
1501 pVal->Value >>= bVal;
1513 else if (aCtrlType ==
"Bool")
1516 std::unique_ptr<weld::CheckButton> xNewBox =
m_xBuilder->weld_check_button(aID);
1522 xNewBox->set_label( aText );
1526 PropertyValue* pVal =
maPController->getValue( aPropertyName );
1528 pVal->Value >>= bVal;
1529 xNewBox->set_active( bVal );
1530 xNewBox->connect_toggled(
LINK(
this,
PrintDialog, UIOption_CheckHdl ) );
1540 setHelpId(pWidget, aHelpIds, 0);
1542 setHelpText(pWidget, aHelpTexts, 0);
1544 else if (aCtrlType ==
"Radio")
1546 sal_Int32 nCurHelpText = 0;
1549 sal_Int32 nSelectVal = 0;
1550 PropertyValue* pVal =
maPController->getValue( aPropertyName );
1551 if( pVal && pVal->Value.hasValue() )
1552 pVal->Value >>= nSelectVal;
1553 for( sal_Int32
m = 0;
m < aChoices.getLength();
m++ )
1556 std::unique_ptr<weld::RadioButton> xBtn =
m_xBuilder->weld_radio_button(aID);
1562 xBtn->set_label( aChoices[
m] );
1563 xBtn->set_active(
m == nSelectVal );
1564 xBtn->connect_toggled(
LINK(
this,
PrintDialog, UIOption_RadioHdl ) );
1565 if( aChoicesDisabled.getLength() >
m && aChoicesDisabled[
m] )
1566 xBtn->set_sensitive(
false );
1578 setHelpId( pWidget, aHelpIds, nCurHelpText );
1580 setHelpText( pWidget, aHelpTexts, nCurHelpText );
1584 else if ( aCtrlType ==
"List" )
1586 std::unique_ptr<weld::ComboBox> xList =
m_xBuilder->weld_combo_box(aID);
1593 for(
const auto& rChoice : std::as_const(aChoices) )
1594 xList->append_text(rChoice);
1596 sal_Int32 nSelectVal = 0;
1597 PropertyValue* pVal =
maPController->getValue( aPropertyName );
1598 if( pVal && pVal->Value.hasValue() )
1599 pVal->Value >>= nSelectVal;
1600 xList->set_active(nSelectVal);
1601 xList->connect_changed(
LINK(
this,
PrintDialog, UIOption_SelectHdl ) );
1612 setHelpId( pWidget, aHelpIds, 0 );
1614 setHelpText( pWidget, aHelpTexts, 0 );
1616 else if ( aCtrlType ==
"Range" )
1618 std::unique_ptr<weld::SpinButton> xField =
m_xBuilder->weld_spin_button(aID);
1625 if(nMinValue != nMaxValue)
1626 xField->set_range(nMinValue, nMaxValue);
1628 sal_Int64 nCurVal = 0;
1629 PropertyValue* pVal =
maPController->getValue( aPropertyName );
1630 if( pVal && pVal->Value.hasValue() )
1631 pVal->Value >>= nCurVal;
1632 xField->set_value( nCurVal );
1633 xField->connect_value_changed(
LINK(
this,
PrintDialog, UIOption_SpinModifyHdl ) );
1644 setHelpId( pWidget, aHelpIds, 0 );
1646 setHelpText( pWidget, aHelpTexts, 0 );
1648 else if (aCtrlType ==
"Edit")
1650 std::unique_ptr<weld::Entry> xField =
m_xBuilder->weld_entry(aID);
1657 PropertyValue* pVal =
maPController->getValue( aPropertyName );
1658 if( pVal && pVal->Value.hasValue() )
1659 pVal->Value >>= aCurVal;
1660 xField->set_text( aCurVal );
1661 xField->connect_changed(
LINK(
this,
PrintDialog, UIOption_EntryModifyHdl ) );
1672 setHelpId( pWidget, aHelpIds, 0 );
1674 setHelpText( pWidget, aHelpTexts, 0 );
1678 SAL_WARN(
"vcl",
"Unsupported UI option: \"" << aCtrlType <<
'"');
1711 OUString aDependency(
maPController->makeEnabled( it->second ) );
1712 if( !aDependency.isEmpty() )
1719 beans::PropertyValue* pValue =
maPController->getValue( i_rProperty );
1724 const auto& rWindows( it->second );
1725 if( rWindows.empty() )
1729 sal_Int32 nVal = -1;
1730 if( pValue->Value >>= bVal )
1738 else if ( i_rProperty ==
"PrintProspect" )
1748 SAL_WARN(
"vcl",
"missing a checkbox" );
1751 else if( pValue->Value >>= nVal )
1757 pList->
set_active(
static_cast< sal_uInt16
>(nVal) );
1762 SAL_WARN_IF( !pBtn,
"vcl",
"unexpected control for property" );
1791 PropertyValue* pVal =
nullptr;
1796 SAL_WARN_IF( !pVal,
"vcl",
"property value not found" );
1800 OSL_FAIL(
"changed control not in property map" );
1807 if (&rButton == mxPreviewBox.get())
1809 maUpdatePreviewIdle.Start();
1811 else if( &rButton == mxBorderCB.get() )
1815 else if (&rButton == mxSingleJobsBox.get())
1817 maPController->setValue(
"SinglePrintJobs",
1818 Any( isSingleJobs() ) );
1819 checkControlDependencies();
1821 else if( &rButton == mxCollateBox.get() )
1823 maPController->setValue(
"Collate",
1824 Any( isCollate() ) );
1825 checkControlDependencies();
1827 else if( &rButton == mxReverseOrderBox.get() )
1829 bool bChecked = mxReverseOrderBox->get_active();
1830 maPController->setReversePrint( bChecked );
1831 maPController->setValue(
"PrintReverse",
1833 maUpdatePreviewIdle.Start();
1835 else if (&rButton == mxBrochureBtn.get())
1837 PropertyValue* pVal = getValueForWindow(mxBrochureBtn.get());
1840 bool bVal = mxBrochureBtn->get_active();
1841 pVal->Value <<= bVal;
1843 checkOptionalControlDependencies();
1846 maUpdatePreviewNoCacheIdle.Start();
1848 if (mxBrochureBtn->get_active())
1850 mxOrientationBox->set_sensitive(
false );
1852 mxNupPagesBox->set_active( 0 );
1853 updateNupFromPages();
1854 showAdvancedControls(
false );
1855 enableNupControls(
false );
1859 mxOrientationBox->set_sensitive(
true );
1861 enableNupControls(
true );
1862 updateNupFromPages();
1870 if (&rButton == mxOKButton.get() || &rButton == mxCancelButton.get())
1875 else if( &rButton == mxHelpButton.get() )
1881 pHelp->
Start(
"vcl/ui/printdialog/PrintDialog", mxOKButton.get());
1884 else if( &rButton == mxForwardBtn.get() )
1888 else if( &rButton == mxBackwardBtn.get() )
1892 else if( &rButton == mxFirstBtn.get() )
1896 else if( &rButton == mxLastBtn.get() )
1902 if( &rButton == mxSetupButton.get() )
1904 maPController->setupPrinter(
m_xDialog.get());
1906 if ( !isPrintToFile() )
1917 if ( mePaper == ePaper )
1919 mxPaperSizeBox->set_active( nPaper );
1925 updateOrientationBox(
false );
1926 setupPaperSidesBox();
1929 maUpdatePreviewNoCacheIdle.Start();
1931 checkControlDependencies();
1938 if (&rBox == mxPrinters.get())
1940 if ( !isPrintToFile() )
1942 OUString aNewPrinter(rBox.get_active_text());
1945 maPController->resetPrinterOptions(
false );
1947 updateOrientationBox();
1950 mxOKButton->set_label(maPrintText);
1951 updatePrinterText();
1953 maUpdatePreviewIdle.Start();
1959 mxOKButton->set_label(maPrintToFileText);
1960 maPController->resetPrinterOptions(
true );
1963 updateOrientationBox();
1964 maUpdatePreviewIdle.Start();
1967 setupPaperSidesBox();
1969 else if ( &rBox == mxPaperSidesBox.get() )
1972 maPController->getPrinter()->SetDuplexMode( eDuplex );
1974 else if( &rBox == mxOrientationBox.get() )
1976 int nOrientation = mxOrientationBox->get_active();
1978 setPaperOrientation(
static_cast<Orientation>( nOrientation - 1 ),
true );
1982 else if ( &rBox == mxNupOrderBox.get() )
1986 else if( &rBox == mxNupPagesBox.get() )
1988 if( !mxPagesBtn->get_active() )
1989 mxPagesBtn->set_active(
true);
1990 updateNupFromPages(
false );
1992 else if ( &rBox == mxPaperSizeBox.get() )
2006 maUpdatePreviewIdle.Start();
2012 checkControlDependencies();
2013 updateNupFromPages();
2018 ActivateHdl(*mxPageEdit);
2023 sal_Int32 nPage = mxPageEdit->get_text().toInt32();
2027 mxPageEdit->set_text(
"1");
2029 else if (nPage > mnCachedPages)
2031 nPage = mnCachedPages;
2032 mxPageEdit->set_text(OUString::number(mnCachedPages));
2034 int nNewCurPage = nPage - 1;
2035 if (nNewCurPage != mnCurPage)
2037 mnCurPage = nNewCurPage;
2038 maUpdatePreviewIdle.Start();
2045 checkControlDependencies();
2046 if (&rEdit == mxNupRowsEdt.get() || &rEdit == mxNupColEdt.get())
2048 updateNupFromPages();
2050 else if( &rEdit == mxCopyCountField.get() )
2052 maPController->setValue(
"CopyCount",
2053 Any( sal_Int32(mxCopyCountField->get_value()) ) );
2054 maPController->setValue(
"Collate",
2055 Any( isCollate() ) );
2061 PropertyValue* pVal = getValueForWindow( &i_rBox );
2064 makeEnabled( &i_rBox );
2066 bool bVal = i_rBox.get_active();
2067 pVal->Value <<= bVal;
2069 checkOptionalControlDependencies();
2072 maUpdatePreviewNoCacheIdle.Start();
2081 if( !i_rBtn.get_active() )
2084 PropertyValue* pVal = getValueForWindow( &i_rBtn );
2085 auto it = maControlToNumValMap.find( &i_rBtn );
2086 if( !(pVal && it != maControlToNumValMap.end()) )
2089 makeEnabled( &i_rBtn );
2091 sal_Int32 nVal = it->second;
2092 pVal->Value <<= nVal;
2094 updateOrientationBox();
2096 checkOptionalControlDependencies();
2099 if (pVal->Name ==
"PrintContent" && mxPageRangesRadioButton->get_active())
2100 mxPageRangeEdit->grab_focus();
2103 maUpdatePreviewNoCacheIdle.Start();
2108 PropertyValue* pVal = getValueForWindow( &i_rBox );
2112 makeEnabled( &i_rBox );
2114 sal_Int32 nVal( i_rBox.get_active() );
2115 pVal->Value <<= nVal;
2122 if (pVal->Name ==
"PageContentType")
2123 maFirstPageSize =
Size();
2125 checkOptionalControlDependencies();
2128 maUpdatePreviewNoCacheIdle.Start();
2133 PropertyValue* pVal = getValueForWindow( &i_rBox );
2136 makeEnabled( &i_rBox );
2138 sal_Int64 nVal = i_rBox.get_value();
2139 pVal->Value <<= nVal;
2141 checkOptionalControlDependencies();
2144 maUpdatePreviewNoCacheIdle.Start();
2150 PropertyValue* pVal = getValueForWindow( &i_rBox );
2153 makeEnabled( &i_rBox );
2155 OUString aVal( i_rBox.get_text() );
2156 pVal->Value <<= aVal;
2158 checkOptionalControlDependencies();
2161 maUpdatePreviewNoCacheIdle.Start();
2198static OUString
getNewLabel(
const OUString& aLabel,
int i_nCurr,
int i_nMax)
2200 OUString aNewText(
aLabel.replaceFirst(
"%p", OUString::number( i_nCurr ) ) );
2201 aNewText = aNewText.replaceFirst(
"%n", OUString::number( i_nMax ) );
2208 : GenericDialogController(i_pParent,
"vcl/ui/printprogressdialog.ui",
"PrintProgressDialog")
2212 ,
mxText(m_xBuilder->weld_label(
"label"))
2213 , mxProgress(m_xBuilder->weld_progress_bar(
"progressbar"))
2214 , mxButton(m_xBuilder->weld_button(
"cancel"))
2224 mxText->set_size_request(
mxText->get_preferred_size().Width(), -1);
Reference< XExecutableDialog > m_xDialog
const StyleSettings & GetStyleSettings() const
Base class used mainly for the LibreOffice Desktop class.
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
static const AllSettings & GetSettings()
Gets the application's settings.
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
static Help * GetHelp()
Gets the application's help.
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
CommandEventId GetCommand() const
const CommandWheelData * GetWheelData() const
tools::Long GetDelta() const
void DrawFrame(const tools::Rectangle &rRect, const Color &rLeftTopColor, const Color &rRightBottomColor)
void DrawSeparator(const Point &rStart, const Point &rStop, bool bVertical=true)
virtual bool Start(const OUString &rHelpId, weld::Widget *pWidget=nullptr)
virtual void Start(bool bStartTimer=true) override
Schedules the task for execution.
OUString getNum(sal_Int64 nNumber, sal_uInt16 nDecimals, bool bUseThousandSep=true, bool bTrailingZeros=true) const
MeasurementSystem getMeasurementSystemEnum() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
SAL_DLLPRIVATE sal_Int32 GetDPIX() const
Get the output device's DPI x-axis value.
const vcl::Font & GetFont() const
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
void SetFont(const vcl::Font &rNewFont)
SAL_DLLPRIVATE sal_Int32 GetDPIY() const
Get the output device's DPI y-axis value.
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
void SetTextColor(const Color &rColor)
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
const AllSettings & GetSettings() const
bool sloppyEqual(const PaperInfo &rOther) const
tools::Long getWidth() const
void doSloppyFit(bool bAlsoTryRotated=false)
tools::Long getHeight() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
static OUString GetDefaultPrinterName()
bool SetOrientation(Orientation eOrient)
const Point & GetPageOffsetPixel() const
void SetPaper(Paper ePaper)
Size GetPaperSize() const
static void updatePrinters()
Checks the printer list and updates it necessary.
int GetPaperInfoCount() const
static const std::vector< OUString > & GetPrinterQueues()
static OUString GetPaperName(Paper ePaper)
bool SetPaperSizeUser(const Size &rSize)
static const QueueInfo * GetQueueInfo(const OUString &rPrinterName, bool bStatusUpdate)
Size GetSizeOfPaper() const
const PaperInfo & GetPaperInfo(int nPaper) const
const Size & GetPaperSizePixel() const
const vcl::printer::Options & GetPrinterOptions() const
const OUString & GetPrinterName() const
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
constexpr tools::Long getWidth() const
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
const Color & GetFieldTextColor() const
const vcl::Font & GetFieldFont() const
const vcl::Font & GetLabelFont() const
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
A construction helper for a temporary VclPtr.
static std::shared_ptr< ConfigurationChanges > create()
void SetFontSize(const Size &)
void SetOrientation(Degree10 nLineOrientation)
virtual ~PrintPreviewWindow() override
virtual void Resize() override
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
void setPreview(const GDIMetaFile &, const Size &i_rPaperSize, std::u16string_view i_rPaperName, const OUString &i_rNoPageString, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY, bool i_bGreyscale)
virtual bool Command(const CommandEvent &) override
void preparePreviewBitmap()
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
std::unique_ptr< weld::Image > mxCollateImage
std::unique_ptr< weld::CheckButton > mxSingleJobsBox
void updateOrientationBox(bool bAutomatic=true)
std::unique_ptr< weld::Label > mxNupNumPagesTxt
std::unique_ptr< weld::Frame > mxPageLayoutFrame
void setupPaperSidesBox()
std::unique_ptr< weld::Label > mxNupOrderTxt
std::unique_ptr< weld::MetricSpinButton > mxPageMarginEdt
std::vector< std::unique_ptr< weld::Widget > > maExtraControls
Idle maUpdatePreviewNoCacheIdle
void updateWindowFromProperty(const OUString &)
std::unique_ptr< weld::RadioButton > mxPageRangesRadioButton
std::unique_ptr< weld::Entry > mxPageEdit
bool isSingleJobs() const
std::unique_ptr< weld::CustomWeld > mxNupOrderWin
void enableNupControls(bool bEnable)
PrintDialog(weld::Window *, std::shared_ptr< PrinterController >)
std::unique_ptr< weld::MetricSpinButton > mxSheetMarginEdt
void showAdvancedControls(bool)
Size maFirstPageSize
internal, used for automatic Nup-Portrait/landscape
std::unique_ptr< weld::ComboBox > mxPrinters
std::unique_ptr< weld::Notebook > mxTabCtrl
bool hasOrientationChanged() const
std::unique_ptr< weld::ComboBox > mxNupPagesBox
std::shared_ptr< PrinterController > maPController
void updateNup(bool i_bMayUseCache=true)
std::unique_ptr< weld::CheckButton > mxBorderCB
border around each page
std::unique_ptr< weld::Label > mxPageMarginTxt1
std::unique_ptr< weld::Label > mxPagesBoxTitleTxt
std::unique_ptr< weld::SpinButton > mxNupColEdt
std::unique_ptr< weld::Button > mxBackwardBtn
virtual ~PrintDialog() override
std::map< weld::Widget *, OUString > maControlToPropertyMap
void makeEnabled(weld::Widget *)
std::map< OUString, std::vector< weld::Widget * > > maPropertyToWindowMap
std::unique_ptr< weld::ComboBox > mxNupOrderBox
std::unique_ptr< weld::ComboBox > mxOrientationBox
std::unique_ptr< weld::SpinButton > mxNupRowsEdt
std::unique_ptr< weld::Button > mxHelpButton
std::unique_ptr< weld::CheckButton > mxCollateBox
std::unique_ptr< weld::Button > mxSetupButton
std::unique_ptr< weld::Button > mxFirstBtn
std::unique_ptr< weld::CheckButton > mxReverseOrderBox
std::unique_ptr< weld::Label > mxSheetMarginTxt1
std::unique_ptr< weld::Button > mxLastBtn
std::unique_ptr< weld::SpinButton > mxCopyCountField
std::unique_ptr< weld::Label > mxSheetMarginTxt2
void setPaperOrientation(Orientation eOrientation, bool fromUser)
std::unique_ptr< weld::ComboBox > mxPaperSidesBox
std::unique_ptr< weld::Builder > mxCustomOptionsUIBuilder
std::unique_ptr< weld::RadioButton > mxPagesBtn
bool isPrintToFile() const
std::unique_ptr< weld::Label > mxNupTimesTxt
std::unique_ptr< weld::RadioButton > mxBrochureBtn
std::unique_ptr< weld::Label > mxStatusTxt
OUString maPrintToFileText
std::map< weld::Widget *, sal_Int32 > maControlToNumValMap
std::unique_ptr< ShowNupOrderWindow > mxNupOrder
std::unique_ptr< weld::ScrolledWindow > mxScrolledWindow
std::unique_ptr< weld::Expander > mxRangeExpander
void checkControlDependencies()
std::unique_ptr< weld::ComboBox > mxPaperSizeBox
void preparePreview(bool i_bMayUseCache)
std::unique_ptr< PrintPreviewWindow > mxPreview
void initFromMultiPageSetup(const vcl::PrinterController::MultiPageSetup &)
std::unique_ptr< weld::Expander > mxLayoutExpander
css::beans::PropertyValue * getValueForWindow(weld::Widget *) const
std::unique_ptr< weld::Label > mxPageMarginTxt2
std::unique_ptr< weld::Entry > mxPageRangeEdit
std::unique_ptr< weld::Widget > mxCustom
void updateNupFromPages(bool i_bMayUseCache=true)
std::unique_ptr< weld::CustomWeld > mxPreviewWindow
void checkOptionalControlDependencies()
std::unique_ptr< weld::Button > mxForwardBtn
std::unique_ptr< weld::Button > mxCancelButton
std::unique_ptr< weld::Button > mxOKButton
Size const & getJobPageSize()
std::unique_ptr< weld::Label > mxNumPagesText
std::unique_ptr< weld::CheckButton > mxPreviewBox
void setProgress(int i_nCurrent)
std::unique_ptr< weld::Button > mxButton
std::unique_ptr< weld::Label > mxText
std::unique_ptr< weld::ProgressBar > mxProgress
virtual ~PrintProgressDialog() override
PrintProgressDialog(weld::Window *i_pParent, int i_nMax)
OUString getValue(const OUString &rGroup, const OUString &rKey) const
static SettingsConfigItem * get()
void setValue(const OUString &rGroup, const OUString &rKey, const OUString &rValue)
A widget used to choose from a list of items.
virtual void set_active(int pos)=0
std::shared_ptr< weld::Dialog > m_xDialog
GenericDialogController(weld::Widget *pParent, const OUString &rUIFile, const OUString &rDialogId, bool bMobile=false)
std::unique_ptr< weld::Builder > m_xBuilder
virtual void set_active(bool active)=0
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
#define LINK(Instance, Class, Member)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
B2IRange fround(const B2DRange &rRange)
const LocaleDataWrapper & GetLocaleDataWrapper(LanguageType nLang)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
sal_Int32 NaturalSortCompare(const OUString &rA, const OUString &rB)
IMPL_LINK(ORoadmap, ImplClickHdl, HyperLabel *, CurHyperLabel, void)
IMPL_LINK_NOARG(QuickSelectionEngine_Data, SearchStringTimeout, Timer *, void)
void SetPointFont(OutputDevice &rDevice, const vcl::Font &rFont)
Reference< text::XText > mxText
static OUString getNewLabel(const OUString &aLabel, int i_nCurr, int i_nMax)
tools::Long nHorizontalSpacing
tools::Long nBottomMargin
tools::Long nVerticalSpacing
bool bFullPaper
Full paper, not only imageable area is printed.
Reference< XFrame > xFrame
OUString VclResId(TranslateId aId)
@ POST_PAINT
Everything running directly after painting.