summaryrefslogtreecommitdiff
path: root/sfx2/source/doc/SfxRedactionHelper.cxx
diff options
context:
space:
mode:
authorOnur Yilmaz <onuryilmaz0750@gmail.com>2020-01-26 01:04:50 +0300
committerMuhammet Kara <muhammet.kara@collabora.com>2020-01-28 08:35:21 +0100
commit0025b74e8099ed79e7824a8d22335e882e0c635c (patch)
treeda5afd163e820f0ced34dc26bf1e85cea19b9548 /sfx2/source/doc/SfxRedactionHelper.cxx
parentf772ccb8008c4e9429982a226eab3341da1cdeed (diff)
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.kara@collabora.com>
Diffstat (limited to 'sfx2/source/doc/SfxRedactionHelper.cxx')
-rw-r--r--sfx2/source/doc/SfxRedactionHelper.cxx20
1 files changed, 15 insertions, 5 deletions
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();
+ }
}
}