diff options
author | Muhammet Kara <muhammet.kara@collabora.com> | 2019-01-18 14:07:56 +0300 |
---|---|---|
committer | Muhammet Kara <muhammet.kara@collabora.com> | 2019-06-17 20:50:20 +0200 |
commit | efd8813bb88ff3f3fd8c523d2f39ae595292163e (patch) | |
tree | 69b7e7f37c0164046d9deb1ed00fc648e9496ae0 /svtools/source | |
parent | 5027eab356740ae4ebb0720f30fe1c0af5e0c1d7 (diff) |
Redaction: Adjust offset for multiple Calc pages
* Add an enum and some methods to DocumentToGraphicRenderer
to differentiate between the doc/module types:
isWriter(), isCalc(), isImpress()
* Put some checks for module/doc type
* The result seems ok for a Calc document of multiple sheets
with hundreds of pages
Change-Id: Idf3e1966d4239df30a48a947a95c9085c25ee1bb
Reviewed-on: https://gerrit.libreoffice.org/66605
Tested-by: Jenkins
Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/69815
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/74195
Tested-by: Muhammet Kara <muhammet.kara@collabora.com>
Diffstat (limited to 'svtools/source')
-rw-r--r-- | svtools/source/filter/DocumentToGraphicRenderer.cxx | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/svtools/source/filter/DocumentToGraphicRenderer.cxx b/svtools/source/filter/DocumentToGraphicRenderer.cxx index 9d1becf178f8..27852455c44f 100644 --- a/svtools/source/filter/DocumentToGraphicRenderer.cxx +++ b/svtools/source/filter/DocumentToGraphicRenderer.cxx @@ -48,7 +48,7 @@ DocumentToGraphicRenderer::DocumentToGraphicRenderer( const Reference<XComponent mxController( mxModel->getCurrentController() ), mxRenderable (mxDocument, uno::UNO_QUERY ), mxToolkit( VCLUnoHelper::CreateToolkit() ), - mbIsWriter( false ) + meDocType( UNKNOWN ) { try { @@ -56,7 +56,13 @@ DocumentToGraphicRenderer::DocumentToGraphicRenderer( const Reference<XComponent if (xServiceInfo.is()) { if (xServiceInfo->supportsService("com.sun.star.text.TextDocument")) - mbIsWriter = true; + meDocType = WRITER; + else if (xServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument")) + meDocType = CALC; + else if (xServiceInfo->supportsService("com.sun.star.presentation.PresentationDocument")) + meDocType = IMPRESS; + else + meDocType = UNKNOWN; } } catch (const uno::Exception&) @@ -79,7 +85,7 @@ DocumentToGraphicRenderer::DocumentToGraphicRenderer( const Reference<XComponent * XRenderable::render() it always renders an empty page. * So disable the selection already here. The current page * the cursor is on is rendered. */ - if (!mbIsWriter) + if (!isWriter()) maSelection = aViewSelection; } } @@ -115,7 +121,7 @@ uno::Any DocumentToGraphicRenderer::getSelection() const } Size DocumentToGraphicRenderer::getDocumentSizeIn100mm(sal_Int32 nCurrentPage, - Point* pDocumentPosition) + Point* pDocumentPosition, Point* pCalcPagePosition, Size* pCalcPageSize) { Reference< awt::XDevice > xDevice(mxToolkit->createScreenCompatibleDevice( 32, 32 ) ); @@ -134,7 +140,9 @@ Size DocumentToGraphicRenderer::getDocumentSizeIn100mm(sal_Int32 nCurrentPage, renderProperties[3].Value <<= true; awt::Size aSize; + awt::Size aCalcPageSize; awt::Point aPos; + awt::Point aCalcPos; sal_Int32 nPages = mxRenderable->getRendererCount( selection, renderProperties ); if (nPages >= nCurrentPage) @@ -150,6 +158,14 @@ Size DocumentToGraphicRenderer::getDocumentSizeIn100mm(sal_Int32 nCurrentPage, { aResult[nProperty].Value >>= aPos; } + else if (aResult[nProperty].Name == "CalcPagePos") + { + aResult[nProperty].Value >>= aCalcPos; + } + else if (aResult[nProperty].Name == "CalcPageContentSize") + { + aResult[nProperty].Value >>= aCalcPageSize; + } } } @@ -157,6 +173,14 @@ Size DocumentToGraphicRenderer::getDocumentSizeIn100mm(sal_Int32 nCurrentPage, { *pDocumentPosition = Point(aPos.X, aPos.Y); } + if (pCalcPagePosition) + { + *pCalcPagePosition = Point(aCalcPos.X, aCalcPos.Y); + } + if (pCalcPageSize) + { + *pCalcPageSize = Size(aCalcPageSize.Width, aCalcPageSize.Height); + } return Size( aSize.Width, aSize.Height ); } @@ -245,7 +269,7 @@ sal_Int32 DocumentToGraphicRenderer::getCurrentPage() if (hasSelection()) return 1; - if (mbIsWriter) + if (isWriter()) return getCurrentPageWriter(); /* TODO: other application specific page detection? */ @@ -306,4 +330,28 @@ bool DocumentToGraphicRenderer::isShapeSelected( return bShape; } +bool DocumentToGraphicRenderer::isWriter() const +{ + if (meDocType == WRITER) + return true; + else + return false; +} + +bool DocumentToGraphicRenderer::isCalc() const +{ + if (meDocType == CALC) + return true; + else + return false; +} + +bool DocumentToGraphicRenderer::isImpress() const +{ + if (meDocType == IMPRESS) + return true; + else + return false; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |