sc/inc/docuno.hxx | 2 ++ sc/source/ui/inc/printfun.hxx | 3 +++ sc/source/ui/unoobj/docuno.cxx | 24 ++++++++++++++++++------ sc/source/ui/view/printfun.cxx | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 6 deletions(-)
New commits: commit e9b6eecdb962a346ef65284b35b76259091746ad Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> Date: Fri Dec 1 22:28:48 2017 +0900 Use print state when rendering a Calc document When rendering a Calc document with UNO rendering API for printing, PDF export, some data (like print X, Y sizes) can be passed from one ScPrintFunc call to the other to save us from some unnecessay recalculation and increase performance. This was used previously for preview, but not when rendering. This implements some missing functions in ScPrintFunc and implements the use of print state when rendering with UNO rendering API. Reviewed-on: https://gerrit.libreoffice.org/45687 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit f1f1dd3885cdbf00032a362275f36e408ef5ac9f) Change-Id: Ic69dee99223961befb9b5dddf8ec5c268630bf79 Reviewed-on: https://gerrit.libreoffice.org/46371 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index 80ab14d95950..b041c0e79487 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -59,6 +59,7 @@ class ScDocShell; class ScAnnotationObj; class ScMarkData; class ScPrintFuncCache; +struct ScPrintState; class ScPrintSelectionStatus; class ScTableColumnObj; class ScTableRowObj; @@ -91,6 +92,7 @@ private: ScDocShell* pDocShell; ScPrintFuncCache* pPrintFuncCache; ScPrintUIOptions* pPrinterOptions; + std::unique_ptr<ScPrintState> m_pPrintState; css::uno::Reference<css::uno::XAggregation> xNumberAgg; css::uno::Reference<css::uno::XInterface> xDrawGradTab; css::uno::Reference<css::uno::XInterface> xDrawHatchTab; diff --git a/sc/source/ui/inc/printfun.hxx b/sc/source/ui/inc/printfun.hxx index 000d58917ee9..38e697c44b45 100644 --- a/sc/source/ui/inc/printfun.hxx +++ b/sc/source/ui/inc/printfun.hxx @@ -224,6 +224,9 @@ public: const ScPrintOptions* pOptions = nullptr, ScPageBreakData* pData = nullptr ); + ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, + const ScPrintState& rState, const ScPrintOptions* pOptions ); + // ctors for device other than printer - for preview and pdf: ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab, diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 064c8b699533..c4c28780d9ae 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -22,6 +22,7 @@ #include "scitems.hxx" #include <editeng/editview.hxx> #include <editeng/outliner.hxx> +#include <o3tl/make_unique.hxx> #include <svx/fmdpage.hxx> #include <svx/fmview.hxx> #include <svx/svditer.hxx> @@ -1555,9 +1556,14 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32 aMark.GetMarkArea( aRange ); pSelRange = &aRange; } - ScPrintFunc aFunc( pDocShell, pDocShell->GetPrinter(), nTab, - pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions() ); - aFunc.SetRenderFlag( true ); + + std::unique_ptr<ScPrintFunc> pPrintFunc; + if (m_pPrintState) + pPrintFunc.reset(new ScPrintFunc(pDocShell, pDocShell->GetPrinter(), *m_pPrintState, &aStatus.GetOptions())); + else + pPrintFunc.reset(new ScPrintFunc(pDocShell, pDocShell->GetPrinter(), nTab, + pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions())); + pPrintFunc->SetRenderFlag( true ); Range aPageRange( nRenderer+1, nRenderer+1 ); MultiSelection aPage( aPageRange ); @@ -1567,13 +1573,19 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32 long nDisplayStart = pPrintFuncCache->GetDisplayStart( nTab ); long nTabStart = pPrintFuncCache->GetTabStart( nTab ); - (void)aFunc.DoPrint( aPage, nTabStart, nDisplayStart, false, nullptr ); + (void)pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart, false, nullptr ); ScRange aCellRange; - bool bWasCellRange = aFunc.GetLastSourceRange( aCellRange ); - Size aTwips = aFunc.GetPageSize(); + bool bWasCellRange = pPrintFunc->GetLastSourceRange( aCellRange ); + Size aTwips = pPrintFunc->GetPageSize(); awt::Size aPageSize( TwipsToHMM( aTwips.Width() ), TwipsToHMM( aTwips.Height() ) ); + if (!m_pPrintState) + { + m_pPrintState.reset(new ScPrintState()); + pPrintFunc->GetPrintState(*m_pPrintState); + } + long nPropCount = bWasCellRange ? 3 : 2; uno::Sequence<beans::PropertyValue> aSequence(nPropCount); beans::PropertyValue* pArray = aSequence.getArray(); diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index 292b9d1de392..6a1dd38be3ca 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -252,6 +252,41 @@ ScPrintFunc::ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTa Construct( pOptions ); } +ScPrintFunc::ScPrintFunc(ScDocShell* pShell, SfxPrinter* pNewPrinter, + const ScPrintState& rState, const ScPrintOptions* pOptions) + : pDocShell ( pShell ), + pPrinter ( pNewPrinter ), + pDrawView ( nullptr ), + pUserArea ( nullptr ), + bSourceRangeValid ( false ), + bPrintCurrentTable ( false ), + bMultiArea ( false ), + mbHasPrintRange(true), + nPagesX(0), + nPagesY(0), + nTotalY(0), + pPageData ( nullptr ) +{ + pDev = pPrinter.get(); + + nPrintTab = rState.nPrintTab; + nStartCol = rState.nStartCol; + nStartRow = rState.nStartRow; + nEndCol = rState.nEndCol; + nEndRow = rState.nEndRow; + nZoom = rState.nZoom; + nPagesX = rState.nPagesX; + nPagesY = rState.nPagesY; + nTabPages = rState.nTabPages; + nTotalPages = rState.nTotalPages; + nPageStart = rState.nPageStart; + nDocPages = rState.nDocPages; + bState = true; + + aSrcOffset = pPrinter->PixelToLogic(pPrinter->GetPageOffsetPixel(), MAP_100TH_MM); + Construct( pOptions ); +} + ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab, long nPage, long nDocP, const ScRange* pArea, const ScPrintOptions* pOptions )
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits