summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-12-01 22:28:48 +0900
committerTomaž Vajngerl <quikee@gmail.com>2017-12-04 08:03:30 +0100
commitf1f1dd3885cdbf00032a362275f36e408ef5ac9f (patch)
tree8076292ee90fb6620d25db6447ee38ce5a08cf1d
parentf6b437c57d4b0b032cb7e0838e16572bdf9a05cc (diff)
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. Change-Id: Ic69dee99223961befb9b5dddf8ec5c268630bf79 Reviewed-on: https://gerrit.libreoffice.org/45687 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--sc/inc/docuno.hxx2
-rw-r--r--sc/source/ui/inc/printfun.hxx3
-rw-r--r--sc/source/ui/unoobj/docuno.cxx25
-rw-r--r--sc/source/ui/view/printfun.cxx35
4 files changed, 59 insertions, 6 deletions
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 0004b03935e7..ecb7cf494763 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;
@@ -92,6 +93,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 8adedc168cc6..6926a0b5b9fe 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 496ef70e036c..933b29cb198a 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -25,6 +25,7 @@
#include <editeng/editview.hxx>
#include <editeng/outliner.hxx>
#include <o3tl/any.hxx>
+#include <o3tl/make_unique.hxx>
#include <svx/fmdpage.hxx>
#include <svx/fmview.hxx>
#include <svx/svditer.hxx>
@@ -1781,9 +1782,13 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32
}
else
{
- ScPrintFunc aFunc( pDocShell, pDocShell->GetPrinter(), nTab,
- pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions() );
- aFunc.SetRenderFlag( true );
+ std::unique_ptr<ScPrintFunc, o3tl::default_delete<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 );
@@ -1793,10 +1798,17 @@ 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 );
+
+ bWasCellRange = pPrintFunc->GetLastSourceRange( aCellRange );
+ Size aTwips = pPrintFunc->GetPageSize();
+
+ if (!m_pPrintState)
+ {
+ m_pPrintState.reset(new ScPrintState());
+ pPrintFunc->GetPrintState(*m_pPrintState);
+ }
- bWasCellRange = aFunc.GetLastSourceRange( aCellRange );
- Size aTwips = aFunc.GetPageSize();
aPageSize.Width = TwipsToHMM( aTwips.Width());
aPageSize.Height = TwipsToHMM( aTwips.Height());
}
@@ -1916,6 +1928,7 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
// to increase performance, ScPrintState might be used here for subsequent
// pages of the same sheet
+
ScPrintFunc aFunc( pDev, pDocShell, nTab, pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions() );
aFunc.SetDrawView( aDrawViewKeeper.mpDrawView );
aFunc.SetRenderFlag( true );
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index aa83de67fbed..8ee6dd233ab8 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -248,6 +248,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(), MapMode(MapUnit::Map100thMM));
+ Construct( pOptions );
+}
+
ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
long nPage, long nDocP, const ScRange* pArea,
const ScPrintOptions* pOptions )