diff options
-rw-r--r-- | include/vcl/print.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 63 | ||||
-rw-r--r-- | vcl/source/gdi/print3.cxx | 10 | ||||
-rw-r--r-- | vcl/source/window/printdlg.cxx | 7 |
4 files changed, 63 insertions, 21 deletions
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx index 3da922afa884..2948ec3d823c 100644 --- a/include/vcl/print.hxx +++ b/include/vcl/print.hxx @@ -93,6 +93,7 @@ private: bool mbNewJobSetup; bool mbSinglePrintJobs; bool mbUsePrintSetting; + bool mbResetPrintArea; VCL_DLLPRIVATE void ImplInitData(); VCL_DLLPRIVATE void ImplInit( SalPrinterQueueInfo* pInfo ); @@ -222,6 +223,8 @@ public: VCL_DLLPRIVATE void SetPrinterOptions( const vcl::printer::Options& rOptions ); const vcl::printer::Options& GetPrinterOptions() const { return( *mpPrinterOptions ); } + void ResetPrintArea(bool bReset) { mbResetPrintArea = bReset; } + bool IsPrintAreaReset() { return mbResetPrintArea; } void SetUsePrintDialogSetting(bool bUsed) { mbUsePrintSetting = bUsed; } bool IsUsePrintDialogSetting() { return mbUsePrintSetting; } void SetPrintPageSize(Size aPrintPageSize) { maPrintPageSize = aPrintPageSize; } @@ -483,6 +486,7 @@ public: bool getPrinterModified() const; VCL_DLLPRIVATE void pushPropertiesToPrinter(); VCL_DLLPRIVATE void resetPaperToLastConfigured(); + VCL_DLLPRIVATE void resetPrintArea(); void setJobState( css::view::PrintableState ); VCL_DLLPRIVATE void setupPrinter( weld::Window* i_pDlgParent ); diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index bb36b29068ac..c46e10b23832 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1637,22 +1637,20 @@ static bool lcl_ParseTarget( const OUString& rTarget, ScRange& rTargetRange, too return bRangeValid; } - static void lcl_SetPrintPage(const uno::Sequence<beans::PropertyValue>& rOptions, Size& aSize, - bool& bLandscape, bool& bUsed) +static Printer* lcl_GetPrinter(const uno::Sequence<beans::PropertyValue>& rOptions) { + Printer* pPrinter = nullptr; OutputDevice* pDev = lcl_GetRenderDevice(rOptions); if (pDev && pDev->GetOutDevType() == OUTDEV_PRINTER) - { - Printer* pPrinter = dynamic_cast<Printer*>(pDev); - if (pPrinter && pPrinter->IsUsePrintDialogSetting()) - { - bUsed = true; - bLandscape = (pPrinter->GetOrientation() == Orientation::Landscape); - aSize = pPrinter->GetPrintPageSize(); - aSize.setWidth(o3tl::convert(aSize.Width(), o3tl::Length::mm100, o3tl::Length::twip)); - aSize.setHeight(o3tl::convert(aSize.Height(), o3tl::Length::mm100, o3tl::Length::twip)); - } - } + pPrinter = dynamic_cast<Printer*>(pDev); + return pPrinter; +} + +static Size lcl_GetPrintPageSize(Size aSize) +{ + aSize.setWidth(o3tl::convert(aSize.Width(), o3tl::Length::mm100, o3tl::Length::twip)); + aSize.setHeight(o3tl::convert(aSize.Height(), o3tl::Length::mm100, o3tl::Length::twip)); + return aSize; } bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection, @@ -1842,15 +1840,28 @@ sal_Int32 SAL_CALL ScModelObj::getRendererCount(const uno::Any& aSelection, return 0; Size aPrintPageSize; + bool bPrintAreaReset = false; bool bPrintPageLandscape = false; bool bUsePrintDialogSetting = false; - lcl_SetPrintPage(rOptions, aPrintPageSize, bPrintPageLandscape, bUsePrintDialogSetting); + Printer* pPrinter = lcl_GetPrinter(rOptions); + if (pPrinter) + { + if (pPrinter->IsUsePrintDialogSetting()) + { + bUsePrintDialogSetting = true; + bPrintPageLandscape = (pPrinter->GetOrientation() == Orientation::Landscape); + aPrintPageSize = lcl_GetPrintPageSize(pPrinter->GetPrintPageSize()); + } + else // reset the print area created by the Print Dialog to the page style's print area. + bPrintAreaReset = pPrinter->IsPrintAreaReset(); + } // The same ScPrintFuncCache object in pPrintFuncCache is used as long as // the same selection is used (aStatus) and the document isn't changed // (pPrintFuncCache is cleared in Notify handler) - if (!pPrintFuncCache || !pPrintFuncCache->IsSameSelection(aStatus) || bUsePrintDialogSetting) + if (!pPrintFuncCache || !pPrintFuncCache->IsSameSelection(aStatus) || bUsePrintDialogSetting + || bPrintAreaReset) { pPrintFuncCache.reset(new ScPrintFuncCache(pDocShell, aMark, aStatus, aPrintPageSize, bPrintPageLandscape, bUsePrintDialogSetting)); @@ -2082,7 +2093,16 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32 Size aPrintPageSize; bool bPrintPageLandscape = false; bool bUsePrintDialogSetting = false; - lcl_SetPrintPage(rOptions, aPrintPageSize, bPrintPageLandscape, bUsePrintDialogSetting); + Printer* pPrinter = lcl_GetPrinter(rOptions); + if (pPrinter) + { + if (pPrinter->IsUsePrintDialogSetting()) + { + bUsePrintDialogSetting = true; + bPrintPageLandscape = (pPrinter->GetOrientation() == Orientation::Landscape); + aPrintPageSize = lcl_GetPrintPageSize(pPrinter->GetPrintPageSize()); + } + } std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> pPrintFunc; if (m_pPrintState && m_pPrintState->nPrintTab == nTab) @@ -2503,7 +2523,16 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec Size aPrintPageSize; bool bPrintPageLandscape = false; bool bUsePrintDialogSetting = false; - lcl_SetPrintPage(rOptions, aPrintPageSize, bPrintPageLandscape, bUsePrintDialogSetting); + Printer* pPrinter = lcl_GetPrinter(rOptions); + if (pPrinter) + { + if (pPrinter->IsUsePrintDialogSetting()) + { + bUsePrintDialogSetting = true; + bPrintPageLandscape = (pPrinter->GetOrientation() == Orientation::Landscape); + aPrintPageSize = lcl_GetPrintPageSize(pPrinter->GetPrintPageSize()); + } + } // to increase performance, ScPrintState might be used here for subsequent // pages of the same sheet diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index a43bc41599cd..6b15615f2bc9 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -514,7 +514,6 @@ bool Printer::PreparePrintJob(std::shared_ptr<PrinterController> xController, PrintDialog aDlg(xController->getWindow(), xController); if (!aDlg.run()) { - xController->getPrinter()->SetUsePrintDialogSetting(false); xController->abortJob(); return false; } @@ -565,6 +564,7 @@ bool Printer::ExecutePrintJob(const std::shared_ptr<PrinterController>& xControl void Printer::FinishPrintJob(const std::shared_ptr<PrinterController>& xController) { + xController->resetPrintArea(); xController->resetPaperToLastConfigured(); xController->jobFinished( xController->getJobState() ); } @@ -1015,6 +1015,14 @@ void vcl::ImplPrinterControllerData::resetPaperToLastConfigured() mxPrinter->Pop(); } +// reset the print area created by the Print Dialog to the page style's print area. +void PrinterController::resetPrintArea() +{ + mpImplData->mxPrinter->ResetPrintArea(true); + mpImplData->mxPrinter->SetUsePrintDialogSetting(false); + getPageCount(); +} + int PrinterController::getPageCountProtected() const { const MapMode aMapMode( MapUnit::Map100thMM ); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 5b80ca57fa69..3acd7ddb1ab1 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1014,8 +1014,9 @@ void PrintDialog::updatePageRange(sal_Int32 nPages) { aBuf.append("-" + OUString::number(nPages)); } - maPController->setValue("PageRange", css::uno::Any(aBuf.makeStringAndClear())); - setupOptionalUI(); + OUString sRange = aBuf.makeStringAndClear(); + mxPageRangeEdit->set_text(sRange); + maPController->setValue("PageRange", Any(sRange)); } } @@ -2186,7 +2187,7 @@ IMPL_LINK( PrintDialog, UIOption_SpinModifyHdl, weld::SpinButton&, i_rBox, void IMPL_LINK( PrintDialog, UIOption_EntryModifyHdl, weld::Entry&, i_rBox, void ) { PropertyValue* pVal = getValueForWindow( &i_rBox ); - if( pVal ) + if( pVal && mxPageRangesRadioButton->get_active() ) { makeEnabled( &i_rBox ); |