summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@collabora.com>2019-01-18 14:07:56 +0300
committerAndras Timar <andras.timar@collabora.com>2019-03-27 21:41:10 +0100
commitad32e6a65bfbcf439470e16c3442a499a9f6b40a (patch)
treed067773e21e0bbbb3cde332ca9eedd19610e3614 /sfx2
parentd132d2206926c8b25a11384844d5afe446901826 (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>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/objserv.cxx36
1 files changed, 32 insertions, 4 deletions
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 6c5819cd3f78..ee8d25987845 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -534,7 +534,16 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
uno::Reference< lang::XComponent > xSourceDoc( xModel );
- DocumentToGraphicRenderer aRenderer(xSourceDoc, /*bSelectionOnly=*/false);
+ DocumentToGraphicRenderer aRenderer(xSourceDoc, false);
+
+ bool bIsWriter = aRenderer.isWriter();
+ bool bIsCalc = aRenderer.isCalc();
+
+ if (!bIsWriter && !bIsCalc)
+ {
+ SAL_WARN( "sfx.doc", "Redaction is supported only for Writer and Calc! (for now...)");
+ return;
+ }
sal_Int32 nPages = aRenderer.getPageCount();
@@ -544,7 +553,9 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
{
::Size aDocumentSizePixel = aRenderer.getDocumentSizeInPixels(nPage);
::Point aLogicPos;
- ::Size aLogic = aRenderer.getDocumentSizeIn100mm(nPage, &aLogicPos);
+ ::Point aCalcPageLogicPos;
+ ::Size aCalcPageContentSize;
+ ::Size aLogic = aRenderer.getDocumentSizeIn100mm(nPage, &aLogicPos, &aCalcPageLogicPos, &aCalcPageContentSize);
// FIXME: This is a temporary hack. Need to figure out a proper way to derive this scale factor.
::Size aTargetSize(aDocumentSizePixel.Width() * 1.23, aDocumentSizePixel.Height() * 1.23);
@@ -556,9 +567,21 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
MapMode aMapMode;
aMapMode.SetMapUnit(MapUnit::Map100thMM);
// FIXME: This is a temporary hack. Need to figure out a proper way to derive these magic numbers.
- aMapMode.SetOrigin(::Point(-(aLogicPos.getX() - 512) * 1.53, -((aLogicPos.getY() - 501)* 1.53 + (nPage-1)*740 )));
+ if (bIsWriter)
+ aMapMode.SetOrigin(::Point(-(aLogicPos.getX() - 512) * 1.53, -((aLogicPos.getY() - 501)* 1.53 + (nPage-1)*740 )));
+ else if (bIsCalc)
+ rGDIMetaFile.Scale(0.566, 0.566);
+
rGDIMetaFile.SetPrefMapMode(aMapMode);
- rGDIMetaFile.SetPrefSize(aLogic);
+
+ if (bIsCalc)
+ {
+ double aWidthRatio = static_cast<double>(aCalcPageContentSize.Width()) / aLogic.Width();
+ // FIXME: Get rid of these magic numbers. Also watch for floating point rounding errors
+ rGDIMetaFile.Move(-2400 + aCalcPageLogicPos.X() * (aWidthRatio - 0.0887), -3300 + aCalcPageLogicPos.Y() * 0.64175);
+ }
+
+ rGDIMetaFile.SetPrefSize( bIsCalc ? aCalcPageContentSize : aLogic );
aMetaFiles.push_back(rGDIMetaFile);
}
@@ -591,6 +614,11 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
xShape->setSize(awt::Size(rGDIMetaFile.GetPrefSize().Width(),rGDIMetaFile.GetPrefSize().Height()) );
xPage->add(xShape);
+
+ // Shapes from Calc have the size of the content instead of the whole standard page (like A4)
+ // so it needs positioning on the draw page
+ if (bIsCalc)
+ xShape->setPosition(awt::Point(1000,1000));
}
// Remove the extra page at the beginning