sc/source/ui/inc/printfun.hxx | 35 ++++++++++++++++++++--- sc/source/ui/unoobj/docuno.cxx | 4 +- sc/source/ui/view/printfun.cxx | 61 +++++++++++++++++++++++++++++------------ 3 files changed, 77 insertions(+), 23 deletions(-)
New commits: commit c542db6e3b2d7b881b52565cdcb88886fdf9d849 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> Date: Tue Dec 12 22:24:45 2017 +0900 tdf#114384 reset the print state if the sheet changes Reviewed-on: https://gerrit.libreoffice.org/46301 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit c7a2538129f16ef1253ae974737d5c9676aaf883) Change-Id: Ia90a2bae0dab3d82cae1204a9205f386f71e5c49 Reviewed-on: https://gerrit.libreoffice.org/46375 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 286f9a407b54..8776c6490e49 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1561,7 +1561,7 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32 } std::unique_ptr<ScPrintFunc> pPrintFunc; - if (m_pPrintState) + if (m_pPrintState && m_pPrintState->nPrintTab == nTab) pPrintFunc.reset(new ScPrintFunc(pDocShell, pDocShell->GetPrinter(), *m_pPrintState, &aStatus.GetOptions())); else pPrintFunc.reset(new ScPrintFunc(pDocShell, pDocShell->GetPrinter(), nTab, @@ -1673,7 +1673,7 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec // pages of the same sheet std::unique_ptr<ScPrintFunc> pPrintFunc; - if (m_pPrintState) + if (m_pPrintState && m_pPrintState->nPrintTab == nTab) pPrintFunc.reset(new ScPrintFunc(pDev, pDocShell, *m_pPrintState, &aStatus.GetOptions())); else pPrintFunc.reset(new ScPrintFunc(pDev, pDocShell, nTab, pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions())); commit dab029a384474c613709c86fa1bab133d6a900dd Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> Date: Tue Dec 12 22:22:32 2017 +0900 tdf#114256 add cache criterium when to recalculate page range size Page range size can only be valid for the input parameters, which includes the document size, which was not taken into account at all before. Now we look at all this parameters to decide if we need to recalculate or not. Change-Id: Ic52ad7516189b395c66f59aabc374c3da85f6a89 Reviewed-on: https://gerrit.libreoffice.org/46300 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 5217a2a0bf27e496cc429ee45dff7c239b466ae6) Reviewed-on: https://gerrit.libreoffice.org/46374 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/sc/source/ui/inc/printfun.hxx b/sc/source/ui/inc/printfun.hxx index ef8b370adae7..958ab4f28352 100644 --- a/sc/source/ui/inc/printfun.hxx +++ b/sc/source/ui/inc/printfun.hxx @@ -96,6 +96,28 @@ public: namespace sc { +struct PrintPageRangesInput +{ + bool m_bSkipEmpty; + bool m_bPrintArea; + SCROW m_nStartRow; + SCROW m_nEndRow; + SCCOL m_nStartCol; + SCCOL m_nEndCol; + SCTAB m_nPrintTab; + Size m_aDocSize; + + PrintPageRangesInput() + : m_bSkipEmpty(false) + , m_bPrintArea(false) + , m_nStartRow(0) + , m_nEndRow(0) + , m_nStartCol(0) + , m_nEndCol(0) + , m_nPrintTab(0) + {} +}; + class PrintPageRanges { public: @@ -109,12 +131,16 @@ public: size_t m_nPagesY; size_t m_nTotalY; - bool m_bCalculated; + PrintPageRangesInput m_aInput; + + bool checkIfAlreadyCalculatedAndSet(bool bSkipEmpty, bool bPrintArea, + SCROW nStartRow, SCROW nEndRow, + SCCOL nStartCol, SCCOL nEndCol, + SCTAB nPrintTab, Size const & aDocSize); - void calculate(ScDocument* pDoc, ScPageTableParam const & rTableParam, - ScPageAreaParam const & rAreaParam, + void calculate(ScDocument* pDoc, bool bSkipEmpty, bool bPrintArea, SCROW nStartRow, SCROW nEndRow, SCCOL nStartCol, SCCOL nEndCol, - SCTAB nPrintTab); + SCTAB nPrintTab, Size const & aDocSize); }; } @@ -136,6 +162,7 @@ struct ScPrintState // Save Variables from ScPrintFunc // Additional state of page ranges bool bSavedStateRanges; + sc::PrintPageRangesInput aPrintPageRangesInput; size_t nTotalY; std::vector<SCCOL> aPageEndX; std::vector<SCROW> aPageEndY; diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index 2398f41ee45a..b15b0dd7ec2e 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -262,7 +262,7 @@ ScPrintFunc::ScPrintFunc(ScDocShell* pShell, SfxPrinter* pNewPrinter, m_aRanges.m_aPageEndX = rState.aPageEndX; m_aRanges.m_aPageEndY = rState.aPageEndY; m_aRanges.m_aPageRows = rState.aPageRows; - m_aRanges.m_bCalculated = true; + m_aRanges.m_aInput = rState.aPrintPageRangesInput; } aSrcOffset = pPrinter->PixelToLogic(pPrinter->GetPageOffsetPixel(), MAP_100TH_MM); Construct( pOptions ); @@ -325,7 +325,7 @@ ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, m_aRanges.m_aPageEndX = rState.aPageEndX; m_aRanges.m_aPageEndY = rState.aPageEndY; m_aRanges.m_aPageRows = rState.aPageRows; - m_aRanges.m_bCalculated = true; + m_aRanges.m_aInput = rState.aPrintPageRangesInput; } Construct( pOptions ); @@ -352,6 +352,7 @@ void ScPrintFunc::GetPrintState(ScPrintState& rState, bool bSavePageRanges) rState.aPageEndX = m_aRanges.m_aPageEndX; rState.aPageEndY = m_aRanges.m_aPageEndY; rState.aPageRows = m_aRanges.m_aPageRows; + rState.aPrintPageRangesInput = m_aRanges.m_aInput; } } @@ -3005,9 +3006,7 @@ static void lcl_SetHidden( ScDocument* pDoc, SCTAB nPrintTab, ScPageRowEntry& rP void ScPrintFunc::CalcPages() // calculates aPageRect and pages from nZoom { - pDoc->SetPageSize(nPrintTab, GetDocPageSize()); - - m_aRanges.calculate(pDoc, aTableParam, aAreaParam, nStartRow, nEndRow, nStartCol, nEndCol, nPrintTab); + m_aRanges.calculate(pDoc, aTableParam.bSkipEmpty, aAreaParam.bPrintArea, nStartRow, nEndRow, nStartCol, nEndCol, nPrintTab, GetDocPageSize()); } namespace sc @@ -3017,26 +3016,56 @@ PrintPageRanges::PrintPageRanges() : m_nPagesX(0) , m_nPagesY(0) , m_nTotalY(0) - , m_bCalculated(false) {} -void PrintPageRanges::calculate(ScDocument* pDoc, ScPageTableParam const & rTableParam, - ScPageAreaParam const & rAreaParam, +bool PrintPageRanges::checkIfAlreadyCalculatedAndSet( + bool bSkipEmpty, bool bPrintArea, + SCROW nStartRow, SCROW nEndRow, + SCCOL nStartCol, SCCOL nEndCol, + SCTAB nPrintTab, Size const & rDocSize) +{ + if (bSkipEmpty == m_aInput.m_bSkipEmpty && + bPrintArea == m_aInput.m_bPrintArea && + nStartRow == m_aInput.m_nStartRow && nEndRow == m_aInput.m_nEndRow && + nStartCol == m_aInput.m_nStartCol && nEndCol == m_aInput.m_nEndCol && + nPrintTab == m_aInput.m_nPrintTab && + rDocSize == m_aInput.m_aDocSize) + { + return true; + } + + m_aInput.m_bSkipEmpty = bSkipEmpty; + m_aInput.m_bPrintArea = bPrintArea; + m_aInput.m_nStartRow = nStartRow; + m_aInput.m_nEndRow = nEndRow; + m_aInput.m_nStartCol = nStartCol; + m_aInput.m_nEndCol = nEndCol; + m_aInput.m_nPrintTab = nPrintTab; + m_aInput.m_aDocSize = Size(rDocSize); + + return false; +} +void PrintPageRanges::calculate(ScDocument* pDoc, + bool bSkipEmpty, bool bPrintArea, SCROW nStartRow, SCROW nEndRow, SCCOL nStartCol, SCCOL nEndCol, - SCTAB nPrintTab) + SCTAB nPrintTab, Size const & rDocSize) { // Already calculated? - if (m_bCalculated) + if (checkIfAlreadyCalculatedAndSet(bSkipEmpty, bPrintArea, + nStartRow, nEndRow, nStartCol, nEndCol, + nPrintTab, rDocSize)) return; + pDoc->SetPageSize(nPrintTab, rDocSize); + // #i123672# use dynamic mem to react on size changes if (m_aPageEndX.size() < MAXCOL+1) { m_aPageEndX.resize(MAXCOL+1, SCCOL()); } - if (rAreaParam.bPrintArea) + if (bPrintArea) { ScRange aRange(nStartCol, nStartRow, nPrintTab, nEndCol, nEndRow, nPrintTab); pDoc->UpdatePageBreaks(nPrintTab, &aRange); @@ -3111,13 +3140,13 @@ void PrintPageRanges::calculate(ScDocument* pDoc, ScPageTableParam const & rTabl m_aPageEndY[m_nTotalY] = nRow - 1; ++m_nTotalY; - if (!rTableParam.bSkipEmpty || !pDoc->IsPrintEmpty(nPrintTab, nStartCol, nPageStartRow, nEndCol, nRow-1)) + if (!bSkipEmpty || !pDoc->IsPrintEmpty(nPrintTab, nStartCol, nPageStartRow, nEndCol, nRow-1)) { OSL_ENSURE(m_nPagesY < m_aPageRows.size(), "vector access error for rPageRows"); m_aPageRows[m_nPagesY].SetStartRow(nPageStartRow); m_aPageRows[m_nPagesY].SetEndRow(nRow - 1); m_aPageRows[m_nPagesY].SetPagesX(m_nPagesX); - if (rTableParam.bSkipEmpty) + if (bSkipEmpty) lcl_SetHidden(pDoc, nPrintTab, m_aPageRows[m_nPagesY], nStartCol, m_aPageEndX); ++m_nPagesY; } @@ -3151,19 +3180,17 @@ void PrintPageRanges::calculate(ScDocument* pDoc, ScPageTableParam const & rTabl m_aPageEndY[m_nTotalY] = nEndRow; ++m_nTotalY; - if (!rTableParam.bSkipEmpty || !pDoc->IsPrintEmpty(nPrintTab, nStartCol, nPageStartRow, nEndCol, nEndRow)) + if (!bSkipEmpty || !pDoc->IsPrintEmpty(nPrintTab, nStartCol, nPageStartRow, nEndCol, nEndRow)) { OSL_ENSURE(m_nPagesY < m_aPageRows.size(), "vector access error for maPageRows"); m_aPageRows[m_nPagesY].SetStartRow(nPageStartRow); m_aPageRows[m_nPagesY].SetEndRow(nEndRow); m_aPageRows[m_nPagesY].SetPagesX(m_nPagesX); - if (rTableParam.bSkipEmpty) + if (bSkipEmpty) lcl_SetHidden(pDoc, nPrintTab, m_aPageRows[m_nPagesY], nStartCol, m_aPageEndX); ++m_nPagesY; } } - - m_bCalculated = true; } } // end namespace sc
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits