summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTibor Nagy <tibor.nagy.extern@allotropia.de>2024-01-31 16:49:24 +0100
committerThorsten Behrens <thorsten.behrens@allotropia.de>2024-04-30 15:10:42 +0200
commit99867d886858cb2bb665d84cc00cce7ed48c861d (patch)
tree989d16f33b9034b476751e42670f3bcca02d59e5
parentRevert "IASS: Correct Buffering of last Slide" (diff)
downloadcore-99867d886858cb2bb665d84cc00cce7ed48c861d.tar.gz
core-99867d886858cb2bb665d84cc00cce7ed48c861d.zip
tdf#155218 sc: fix different page orientation in print dialog
The page orientation is correct if you set it in the page style first. However, if you change it in the Print dialog the page layout and size refresh but the content orientation remains the same. Change-Id: I5e494a0714e398221bee00744d7e25c419a41df7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162845 Tested-by: Jenkins Reviewed-by: Nagy Tibor <tibor.nagy.extern@allotropia.de>
-rw-r--r--include/vcl/print.hxx6
-rw-r--r--sc/qa/uitest/calc_dialogs/printDialog.py38
-rw-r--r--sc/qa/uitest/data/tdf155218.odsbin0 -> 9753 bytes
-rw-r--r--sc/source/ui/inc/pfuncache.hxx7
-rw-r--r--sc/source/ui/inc/printfun.hxx18
-rw-r--r--sc/source/ui/unoobj/docuno.cxx53
-rw-r--r--sc/source/ui/view/pfuncache.cxx15
-rw-r--r--sc/source/ui/view/printfun.cxx41
-rw-r--r--vcl/inc/printdlg.hxx2
-rw-r--r--vcl/source/gdi/print.cxx1
-rw-r--r--vcl/source/window/printdlg.cxx49
11 files changed, 200 insertions, 30 deletions
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index e7c88f56bdd8..3da922afa884 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -80,6 +80,7 @@ private:
JobSetup maJobSetup;
Point maPageOffset;
Size maPaperSize;
+ Size maPrintPageSize;
ErrCode mnError;
sal_uInt16 mnPageQueueSize;
sal_uInt16 mnCopyCount;
@@ -91,6 +92,7 @@ private:
bool mbInPrintPage;
bool mbNewJobSetup;
bool mbSinglePrintJobs;
+ bool mbUsePrintSetting;
VCL_DLLPRIVATE void ImplInitData();
VCL_DLLPRIVATE void ImplInit( SalPrinterQueueInfo* pInfo );
@@ -220,6 +222,10 @@ public:
VCL_DLLPRIVATE void SetPrinterOptions( const vcl::printer::Options& rOptions );
const vcl::printer::Options& GetPrinterOptions() const { return( *mpPrinterOptions ); }
+ void SetUsePrintDialogSetting(bool bUsed) { mbUsePrintSetting = bUsed; }
+ bool IsUsePrintDialogSetting() { return mbUsePrintSetting; }
+ void SetPrintPageSize(Size aPrintPageSize) { maPrintPageSize = aPrintPageSize; }
+ Size GetPrintPageSize() { return maPrintPageSize; }
bool SetOrientation( Orientation eOrient );
Orientation GetOrientation() const;
void SetDuplexMode( DuplexMode );
diff --git a/sc/qa/uitest/calc_dialogs/printDialog.py b/sc/qa/uitest/calc_dialogs/printDialog.py
new file mode 100644
index 000000000000..3e1290b9c8af
--- /dev/null
+++ b/sc/qa/uitest/calc_dialogs/printDialog.py
@@ -0,0 +1,38 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, select_by_text
+
+class printDialog(UITestCase):
+ def test_printDialog(self):
+ with self.ui_test.load_file(get_url_for_data_file("tdf155218.ods")):
+ with self.ui_test.execute_dialog_through_command(".uno:Print", close_button="cancel") as xDialog:
+
+ xPortraiTotalNumberPages = xDialog.getChild("totalnumpages")
+ self.assertEqual(get_state_as_dict(xPortraiTotalNumberPages)["Text"], "/ 2")
+
+ xPortraiPageRange = xDialog.getChild("pagerange")
+ self.assertEqual(get_state_as_dict(xPortraiPageRange)["Text"], "1-2")
+
+ xpageorientationbox = xDialog.getChild("pageorientationbox")
+ select_by_text(xpageorientationbox, "Landscape")
+
+ # Without the fix in place, this test would have failed with
+ # Expected: "/ 1"
+ # Actual : "/ 2"
+ xLandscapeTotalNumberPages = xDialog.getChild("totalnumpages")
+ self.assertEqual(get_state_as_dict(xLandscapeTotalNumberPages)["Text"], "/ 1")
+
+ # Without the fix in place, this test would have failed with
+ # Expected: "1"
+ # Actual : "1-2"
+ xLandscapePageRange = xDialog.getChild("pagerange")
+ self.assertEqual(get_state_as_dict(xLandscapePageRange)["Text"], "1")
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/data/tdf155218.ods b/sc/qa/uitest/data/tdf155218.ods
new file mode 100644
index 000000000000..cd6417973972
--- /dev/null
+++ b/sc/qa/uitest/data/tdf155218.ods
Binary files differ
diff --git a/sc/source/ui/inc/pfuncache.hxx b/sc/source/ui/inc/pfuncache.hxx
index 5621cd2628ac..7cd286f39223 100644
--- a/sc/source/ui/inc/pfuncache.hxx
+++ b/sc/source/ui/inc/pfuncache.hxx
@@ -90,10 +90,13 @@ class ScPrintFuncCache
std::vector<tools::Long> nFirstAttr;
std::vector<ScPrintPageLocation> aLocations;
bool bLocInitialized;
+ Size aPrintPageSize; // print page size in Print dialog
+ bool bPrintPageLandscape; // print page orientation in Print dialog
+ bool bUsePrintDialogSetting; // use Print dialog setting
public:
- ScPrintFuncCache( ScDocShell* pD, const ScMarkData& rMark,
- ScPrintSelectionStatus aStatus );
+ ScPrintFuncCache(ScDocShell* pD, const ScMarkData& rMark, ScPrintSelectionStatus aStatus,
+ Size aPageSize = {}, bool bLandscape = false, bool bUse = false);
~ScPrintFuncCache();
bool IsSameSelection( const ScPrintSelectionStatus& rStatus ) const;
diff --git a/sc/source/ui/inc/printfun.hxx b/sc/source/ui/inc/printfun.hxx
index f9780bd0e53c..2e9dd7bb49d1 100644
--- a/sc/source/ui/inc/printfun.hxx
+++ b/sc/source/ui/inc/printfun.hxx
@@ -312,15 +312,25 @@ private:
ScPageBreakData* pPageData; // for recording the breaks etc.
+ Size aPrintPageSize; // print page size in Print dialog
+ bool bPrintPageLandscape; // print page orientation in Print dialog
+ bool bUsePrintDialogSetting; // use Print dialog setting
+
public:
ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab,
tools::Long nPage = 0, tools::Long nDocP = 0,
const ScRange* pArea = nullptr,
const ScPrintOptions* pOptions = nullptr,
- ScPageBreakData* pData = nullptr );
+ ScPageBreakData* pData = nullptr,
+ Size aPrintPageSize = {},
+ bool bPrintPageLandscape = false,
+ bool bUsePrintDialogSetting = false );
ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter,
- const ScPrintState& rState, const ScPrintOptions* pOptions );
+ const ScPrintState& rState, const ScPrintOptions* pOptions,
+ Size aPrintPageSize = {},
+ bool bPrintPageLandscape = false,
+ bool bUsePrintDialogSetting = false );
// ctors for device other than printer - for preview and pdf:
@@ -331,7 +341,9 @@ public:
ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
const ScPrintState& rState,
- const ScPrintOptions* pOptions );
+ const ScPrintOptions* pOptions, Size aPrintPageSize = {},
+ bool bPrintPageLandscape = false,
+ bool bUsePrintDialogSetting = false);
~ScPrintFunc();
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 6d94542095ef..dd01202d541e 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1603,6 +1603,24 @@ 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)
+{
+ 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));
+ }
+ }
+}
+
bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
const uno::Sequence< beans::PropertyValue >& rOptions,
ScMarkData& rMark,
@@ -1789,13 +1807,19 @@ sal_Int32 SAL_CALL ScModelObj::getRendererCount(const uno::Any& aSelection,
if ( !FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr, bRenderToGraphic ) )
return 0;
+ Size aPrintPageSize;
+ bool bPrintPageLandscape = false;
+ bool bUsePrintDialogSetting = false;
+ lcl_SetPrintPage(rOptions, aPrintPageSize, bPrintPageLandscape, bUsePrintDialogSetting);
+
// 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 ) )
+ if (!pPrintFuncCache || !pPrintFuncCache->IsSameSelection(aStatus) || bUsePrintDialogSetting)
{
- pPrintFuncCache.reset(new ScPrintFuncCache( pDocShell, aMark, aStatus ));
+ pPrintFuncCache.reset(new ScPrintFuncCache(pDocShell, aMark, aStatus, aPrintPageSize,
+ bPrintPageLandscape, bUsePrintDialogSetting));
}
sal_Int32 nPages = pPrintFuncCache->GetPageCount();
@@ -2021,12 +2045,23 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32
}
else
{
+ Size aPrintPageSize;
+ bool bPrintPageLandscape = false;
+ bool bUsePrintDialogSetting = false;
+ lcl_SetPrintPage(rOptions, aPrintPageSize, bPrintPageLandscape, bUsePrintDialogSetting);
+
std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> pPrintFunc;
if (m_pPrintState && m_pPrintState->nPrintTab == nTab)
- pPrintFunc.reset(new ScPrintFunc(pDocShell, pDocShell->GetPrinter(), *m_pPrintState, &aStatus.GetOptions()));
+ pPrintFunc.reset(new ScPrintFunc(pDocShell, pDocShell->GetPrinter(), *m_pPrintState,
+ &aStatus.GetOptions(), aPrintPageSize,
+ bPrintPageLandscape,
+ bUsePrintDialogSetting));
else
pPrintFunc.reset(new ScPrintFunc(pDocShell, pDocShell->GetPrinter(), nTab,
- pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions()));
+ pPrintFuncCache->GetFirstAttr(nTab), nTotalPages,
+ pSelRange, &aStatus.GetOptions(), nullptr,
+ aPrintPageSize, bPrintPageLandscape,
+ bUsePrintDialogSetting));
pPrintFunc->SetRenderFlag( true );
sal_Int32 nContent = 0;
@@ -2419,14 +2454,20 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
aDrawViewKeeper.mpDrawView->SetPrintPreview();
}
+ Size aPrintPageSize;
+ bool bPrintPageLandscape = false;
+ bool bUsePrintDialogSetting = false;
+ lcl_SetPrintPage(rOptions, aPrintPageSize, bPrintPageLandscape, bUsePrintDialogSetting);
+
// to increase performance, ScPrintState might be used here for subsequent
// pages of the same sheet
-
std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> pPrintFunc;
if (m_pPrintState && m_pPrintState->nPrintTab == nTab
&& ! pSelRange) // tdf#120161 use selection to set required printed area
- pPrintFunc.reset(new ScPrintFunc(pDev, pDocShell, *m_pPrintState, &aStatus.GetOptions()));
+ pPrintFunc.reset(new ScPrintFunc(pDev, pDocShell, *m_pPrintState, &aStatus.GetOptions(),
+ aPrintPageSize, bPrintPageLandscape,
+ bUsePrintDialogSetting));
else
pPrintFunc.reset(new ScPrintFunc(pDev, pDocShell, nTab, pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions()));
diff --git a/sc/source/ui/view/pfuncache.cxx b/sc/source/ui/view/pfuncache.cxx
index fe563ba961df..078633da5da0 100644
--- a/sc/source/ui/view/pfuncache.cxx
+++ b/sc/source/ui/view/pfuncache.cxx
@@ -27,12 +27,17 @@
#include <prevloc.hxx>
#include <utility>
-ScPrintFuncCache::ScPrintFuncCache( ScDocShell* pD, const ScMarkData& rMark,
- ScPrintSelectionStatus aStatus ) :
+ScPrintFuncCache::ScPrintFuncCache(ScDocShell* pD, const ScMarkData& rMark,
+ ScPrintSelectionStatus aStatus, Size aPageSize, bool bLandscape,
+ bool bUsed)
+ :
aSelection(std::move( aStatus )),
pDocSh( pD ),
nTotalPages( 0 ),
- bLocInitialized( false )
+ bLocInitialized( false ),
+ aPrintPageSize( aPageSize ),
+ bPrintPageLandscape( bLandscape ),
+ bUsePrintDialogSetting( bUsed )
{
// page count uses the stored cell widths for the printer anyway,
// so ScPrintFunc with the document's printer can be used to count
@@ -62,7 +67,9 @@ ScPrintFuncCache::ScPrintFuncCache( ScDocShell* pD, const ScMarkData& rMark,
tools::Long nThisTab = 0;
if ( rMark.GetTableSelect( nTab ) )
{
- ScPrintFunc aFunc( pDocSh, pPrinter, nTab, nAttrPage, 0, pSelRange, &aSelection.GetOptions() );
+ ScPrintFunc aFunc(pDocSh, pPrinter, nTab, nAttrPage, 0, pSelRange,
+ &aSelection.GetOptions(), nullptr, aPrintPageSize,
+ bPrintPageLandscape, bUsePrintDialogSetting);
nThisTab = aFunc.GetTotalPages();
nFirstAttr.push_back( aFunc.GetFirstPageNo() ); // from page style or previous sheet
}
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index 84e21da02214..c526781d1346 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -195,10 +195,9 @@ void ScPrintFunc::Construct( const ScPrintOptions* pOptions )
pPageData = nullptr; // is only needed for initialisation
}
-ScPrintFunc::ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab,
- tools::Long nPage, tools::Long nDocP, const ScRange* pArea,
- const ScPrintOptions* pOptions,
- ScPageBreakData* pData )
+ScPrintFunc::ScPrintFunc(ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab, tools::Long nPage,
+ tools::Long nDocP, const ScRange* pArea, const ScPrintOptions* pOptions,
+ ScPageBreakData* pData, Size aSize, bool bPrintLandscape, bool bUsed)
: pDocShell ( pShell ),
rDoc(pDocShell->GetDocument()),
pPrinter ( pNewPrinter ),
@@ -215,7 +214,10 @@ ScPrintFunc::ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTa
nTabPages ( 0 ),
nTotalPages ( 0 ),
bPrintAreaValid ( false ),
- pPageData ( pData )
+ pPageData ( pData ),
+ aPrintPageSize ( aSize ),
+ bPrintPageLandscape ( bPrintLandscape ),
+ bUsePrintDialogSetting ( bUsed )
{
pDev = pPrinter.get();
aSrcOffset = pPrinter->PixelToLogic(pPrinter->GetPageOffsetPixel(), MapMode(MapUnit::Map100thMM));
@@ -225,8 +227,9 @@ ScPrintFunc::ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTa
Construct( pOptions );
}
-ScPrintFunc::ScPrintFunc(ScDocShell* pShell, SfxPrinter* pNewPrinter,
- const ScPrintState& rState, const ScPrintOptions* pOptions)
+ScPrintFunc::ScPrintFunc(ScDocShell* pShell, SfxPrinter* pNewPrinter, const ScPrintState& rState,
+ const ScPrintOptions* pOptions, Size aSize, bool bPrintLandscape,
+ bool bUsed)
: pDocShell ( pShell ),
rDoc(pDocShell->GetDocument()),
pPrinter ( pNewPrinter ),
@@ -236,7 +239,10 @@ ScPrintFunc::ScPrintFunc(ScDocShell* pShell, SfxPrinter* pNewPrinter,
bPrintCurrentTable ( false ),
bMultiArea ( false ),
mbHasPrintRange(true),
- pPageData ( nullptr )
+ pPageData ( nullptr ),
+ aPrintPageSize ( aSize ),
+ bPrintPageLandscape ( bPrintLandscape ),
+ bUsePrintDialogSetting ( bUsed )
{
pDev = pPrinter.get();
@@ -293,7 +299,10 @@ ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
nTabPages ( 0 ),
nTotalPages ( 0 ),
bPrintAreaValid ( false ),
- pPageData ( nullptr )
+ pPageData ( nullptr ),
+ aPrintPageSize ( Size() ),
+ bPrintPageLandscape ( false ),
+ bUsePrintDialogSetting ( false )
{
pDev = pOutDev;
m_aRanges.m_xPageEndX = std::make_shared<std::vector<SCCOL>>();
@@ -302,8 +311,9 @@ ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
Construct( pOptions );
}
-ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
- const ScPrintState& rState, const ScPrintOptions* pOptions )
+ScPrintFunc::ScPrintFunc(OutputDevice* pOutDev, ScDocShell* pShell, const ScPrintState& rState,
+ const ScPrintOptions* pOptions, Size aSize, bool bPrintLandscape,
+ bool bUsed)
: pDocShell ( pShell ),
rDoc(pDocShell->GetDocument()),
pPrinter ( nullptr ),
@@ -313,7 +323,10 @@ ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
bPrintCurrentTable ( false ),
bMultiArea ( false ),
mbHasPrintRange(true),
- pPageData ( nullptr )
+ pPageData ( nullptr ),
+ aPrintPageSize ( aSize ),
+ bPrintPageLandscape ( bPrintLandscape ),
+ bUsePrintDialogSetting ( bUsed )
{
pDev = pOutDev;
@@ -877,13 +890,13 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
const SvxPageItem* pPageItem = &pParamSet->Get( ATTR_PAGE );
nPageUsage = pPageItem->GetPageUsage();
- bLandscape = pPageItem->IsLandscape();
+ bLandscape = bUsePrintDialogSetting ? bPrintPageLandscape : pPageItem->IsLandscape();
aFieldData.eNumType = pPageItem->GetNumType();
bCenterHor = pParamSet->Get(ATTR_PAGE_HORCENTER).GetValue();
bCenterVer = pParamSet->Get(ATTR_PAGE_VERCENTER).GetValue();
- aPageSize = pParamSet->Get(ATTR_PAGE_SIZE).GetSize();
+ aPageSize = bUsePrintDialogSetting ? aPrintPageSize : pParamSet->Get(ATTR_PAGE_SIZE).GetSize();
if ( !aPageSize.Width() || !aPageSize.Height() )
{
OSL_FAIL("PageSize Null ?!?!?");
diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index bf058b079717..26d5ebb2777d 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -231,6 +231,8 @@ namespace vcl
void readFromSettings();
void setPaperOrientation( Orientation eOrientation, bool fromUser );
void updateOrientationBox( bool bAutomatic = true );
+ void updatePageSize( int nOrientation );
+ void updatePageRange( const sal_Int32 nPages );
bool hasOrientationChanged() const;
void setPreviewText();
void updatePrinterText();
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index 2519e5ca44fa..3697e51c338d 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -449,6 +449,7 @@ void Printer::ImplInitData()
mbInPrintPage = false;
mbNewJobSetup = false;
mbSinglePrintJobs = false;
+ mbUsePrintSetting = false;
mpInfoPrinter = nullptr;
mpPrinter = nullptr;
mpDisplayDev = nullptr;
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index c001b6e74070..976880bbd957 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -945,6 +945,9 @@ void PrintDialog::preparePreview( bool i_bMayUseCache )
sal_Int32 nPages = maPController->getFilteredPageCount();
mnCachedPages = nPages;
+ if (!i_bMayUseCache)
+ updatePageRange(nPages);
+
setPreviewText();
if ( !hasPreview() )
@@ -1001,6 +1004,43 @@ void PrintDialog::preparePreview( bool i_bMayUseCache )
mxPageEdit->set_sensitive( nPages > 1 );
}
+void PrintDialog::updatePageRange(sal_Int32 nPages)
+{
+ if (nPages > 0 && !mxPageRangesRadioButton->get_active())
+ {
+ OUStringBuffer aBuf(32);
+ aBuf.append("1");
+ if (nPages > 1)
+ {
+ aBuf.append("-" + OUString::number(nPages));
+ }
+ maPController->setValue("PageRange", css::uno::Any(aBuf.makeStringAndClear()));
+ setupOptionalUI();
+ }
+}
+
+void PrintDialog::updatePageSize(int nOrientation)
+{
+ VclPtr<Printer> aPrt(maPController->getPrinter());
+
+ PaperInfo aInfo = aPrt->GetPaperInfo(mxPaperSizeBox->get_active());
+ Size aSize(aInfo.getWidth(), aInfo.getHeight());
+ if (aSize.IsEmpty())
+ aSize = aPrt->GetSizeOfPaper();
+
+ if (nOrientation != ORIENTATION_AUTOMATIC)
+ {
+ if ((nOrientation == ORIENTATION_PORTRAIT && aSize.Width() > aSize.Height())
+ || (nOrientation == ORIENTATION_LANDSCAPE && aSize.Width() < aSize.Height()))
+ {
+ aSize = Size(aSize.Height(), aSize.Width());
+ }
+ }
+
+ aPrt->SetPrintPageSize(aSize);
+ aPrt->SetUsePrintDialogSetting(true);
+}
+
void PrintDialog::updateOrientationBox( const bool bAutomatic )
{
if ( !bAutomatic )
@@ -1913,6 +1953,9 @@ IMPL_LINK(PrintDialog, ClickHdl, weld::Button&, rButton, void)
}
updateOrientationBox( false );
+
+ updatePageSize(mxOrientationBox->get_active());
+
setupPaperSidesBox();
// tdf#63905 don't use cache: page size may change
@@ -1954,6 +1997,7 @@ IMPL_LINK( PrintDialog, SelectHdl, weld::ComboBox&, rBox, void )
maUpdatePreviewIdle.Start();
}
+ updatePageSize(mxOrientationBox->get_active());
setupPaperSidesBox();
}
else if ( &rBox == mxPaperSidesBox.get() )
@@ -1967,6 +2011,7 @@ IMPL_LINK( PrintDialog, SelectHdl, weld::ComboBox&, rBox, void )
if ( nOrientation != ORIENTATION_AUTOMATIC )
setPaperOrientation( static_cast<Orientation>( nOrientation - 1 ), true );
+ updatePageSize(nOrientation);
updateNup( false );
}
else if ( &rBox == mxNupOrderBox.get() )
@@ -1993,7 +2038,9 @@ IMPL_LINK( PrintDialog, SelectHdl, weld::ComboBox&, rBox, void )
maPController->setPaperSizeFromUser( Size( aInfo.getWidth(), aInfo.getHeight() ) );
- maUpdatePreviewIdle.Start();
+ updatePageSize(mxOrientationBox->get_active());
+
+ maUpdatePreviewNoCacheIdle.Start();
}
}