sfx2/source/doc/SfxRedactionHelper.cxx | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
New commits: commit 0025b74e8099ed79e7824a8d22335e882e0c635c Author: Onur Yilmaz <onuryilmaz0...@gmail.com> AuthorDate: Sun Jan 26 01:04:50 2020 +0300 Commit: Muhammet Kara <muhammet.k...@collabora.com> CommitDate: Tue Jan 28 08:35:21 2020 +0100 tdf#127169: Auto-redaction doesn't cover the title completely Change-Id: I5283ce535f436f066859467cf6ef50ee9a2d2fdd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87436 Tested-by: Jenkins Reviewed-by: Muhammet Kara <muhammet.k...@collabora.com> diff --git a/sfx2/source/doc/SfxRedactionHelper.cxx b/sfx2/source/doc/SfxRedactionHelper.cxx index bbcdeac79401..408c733c77e9 100644 --- a/sfx2/source/doc/SfxRedactionHelper.cxx +++ b/sfx2/source/doc/SfxRedactionHelper.cxx @@ -156,9 +156,6 @@ tools::Rectangle ImplCalcActionBounds(const MetaAction& rAct, const OutputDevice aActionBounds.SetLeft(rOut.PixelToLogic(aBoundRect1).getX() + rOut.PixelToLogic(aBoundRect1).getWidth()); } - - // FIXME: Is this really needed? - aActionBounds.SetTop(aActionBounds.getY() + 100); } } break; @@ -425,14 +422,15 @@ void SfxRedactionHelper::searchInMetaFile(const RedactionTarget* pRedactionTarge fillSearchOptions(aSearchOptions, pRedactionTarget); utl::TextSearch textSearch(aSearchOptions); + static long aLastFontHeight = 0; MetaAction* pCurrAct; - // Watch for TEXTARRAY actions. - // They contain the text of paragraphs. for (pCurrAct = const_cast<GDIMetaFile&>(rMtf).FirstAction(); pCurrAct; pCurrAct = const_cast<GDIMetaFile&>(rMtf).NextAction()) { + // Watch for TEXTARRAY actions. + // They contain the text of paragraphs. if (pCurrAct->GetType() == MetaActionType::TEXTARRAY) { MetaTextArrayAction* pMetaTextArrayAction = static_cast<MetaTextArrayAction*>(pCurrAct); @@ -453,7 +451,14 @@ void SfxRedactionHelper::searchInMetaFile(const RedactionTarget* pRedactionTarge ImplCalcActionBounds(*pMetaTextArrayAction, *pOutputDevice, nStart, nEnd)); if (!aNewRect.IsEmpty()) + { + // Calculate the difference between current wrong value and value should it be. + // Add the difference to current value. + // Then increase 10% of the new value to make it look better. + aNewRect.SetTop(aNewRect.getY() + (aNewRect.getHeight() - aLastFontHeight) + - aLastFontHeight / 10); aRedactionRectangles.push_back(aNewRect); + } // Search for the next occurrence nStart = nEnd; @@ -461,6 +466,11 @@ void SfxRedactionHelper::searchInMetaFile(const RedactionTarget* pRedactionTarge bFound = textSearch.SearchForward(sText, &nStart, &nEnd); } } + else if (pCurrAct->GetType() == MetaActionType::FONT) + { + const MetaFontAction* pFontAct = static_cast<const MetaFontAction*>(pCurrAct); + aLastFontHeight = pFontAct->GetFont().GetFontSize().getHeight(); + } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits