Kaydet (Commit) f1f1dd38 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

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/45687Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst f6b437c5
......@@ -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;
......
......@@ -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,
......
......@@ -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 );
......
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment