sfx2/source/doc/SfxRedactionHelper.cxx |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

New commits:
commit afab434ede6cde5426b3b8760b221708211d6599
Author:     Onur Yilmaz <onuryilmaz0...@gmail.com>
AuthorDate: Sun Jan 26 01:04:50 2020 +0300
Commit:     Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
CommitDate: Tue Jun 25 07:08:44 2024 +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 cdbc91f450af..f059f5aad074 100644
--- a/sfx2/source/doc/SfxRedactionHelper.cxx
+++ b/sfx2/source/doc/SfxRedactionHelper.cxx
@@ -159,9 +159,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;
@@ -428,14 +425,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);
@@ -456,7 +454,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;
@@ -464,6 +469,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();
+        }
     }
 }
 

Reply via email to