sfx2/source/doc/SfxRedactionHelper.cxx | 19 ++++++++++++------- vcl/source/filter/wmf/emfwr.cxx | 4 +--- 2 files changed, 13 insertions(+), 10 deletions(-)
New commits: commit 58948dd22464c38b2a042022f4d549ca926f0476 Author: Michael Stahl <[email protected]> AuthorDate: Tue Nov 12 19:24:47 2024 +0100 Commit: Michael Stahl <[email protected]> CommitDate: Tue Nov 12 21:39:40 2024 +0100 tdf#161775 sfx2: SfxRedactionHelper: actually use font for layout Don't just use the font's height, but set the font at the OutputDevice, to get the correct Y position of the redaction rectangle. Still need to increase the top/bottom of the rectangle a little; also add a little on the right edge, at least the "t" in Arial sticks out. Change-Id: Ic6505fc7fa8697d72a6b11259005bb308e74a50c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176498 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> diff --git a/sfx2/source/doc/SfxRedactionHelper.cxx b/sfx2/source/doc/SfxRedactionHelper.cxx index e61224cf81aa..508c76d57046 100644 --- a/sfx2/source/doc/SfxRedactionHelper.cxx +++ b/sfx2/source/doc/SfxRedactionHelper.cxx @@ -422,7 +422,10 @@ void SfxRedactionHelper::searchInMetaFile(const RedactionTarget& rRedactionTarge fillSearchOptions(aSearchOptions, rRedactionTarget); utl::TextSearch textSearch(aSearchOptions); - static tools::Long aLastFontHeight = 0; + + OutputDevice* pOutputDevice + = SfxObjectShell::GetShellFromComponent(xComponent)->GetDocumentRefDev(); + pOutputDevice->Push(::vcl::PushFlags::FONT); MetaAction* pCurrAct; @@ -445,17 +448,16 @@ void SfxRedactionHelper::searchInMetaFile(const RedactionTarget& rRedactionTarge // If found the string, add the corresponding rectangle to the collection while (bFound) { - OutputDevice* pOutputDevice - = SfxObjectShell::GetShellFromComponent(xComponent)->GetDocumentRefDev(); tools::Rectangle aNewRect( 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.Bottom() - aLastFontHeight - aLastFontHeight / 10); + auto const adj(aNewRect.GetHeight() / 20); + aNewRect.AdjustTop(-adj); + aNewRect.AdjustBottom(adj); + aNewRect.AdjustRight(adj); // also add a bit on the right aRedactionRectangles.push_back(aNewRect); } @@ -468,9 +470,12 @@ void SfxRedactionHelper::searchInMetaFile(const RedactionTarget& rRedactionTarge else if (pCurrAct->GetType() == MetaActionType::FONT) { const MetaFontAction* pFontAct = static_cast<const MetaFontAction*>(pCurrAct); - aLastFontHeight = pFontAct->GetFont().GetFontSize().getHeight(); + vcl::Font const font{ pFontAct->GetFont() }; + pOutputDevice->SetFont(font); } } + + pOutputDevice->Pop(); } void SfxRedactionHelper::addRedactionRectToPage( commit f7368c95b6fe90aeb4f06c1eee15be770beda382 Author: Michael Stahl <[email protected]> AuthorDate: Tue Nov 12 19:13:50 2024 +0100 Commit: Michael Stahl <[email protected]> CommitDate: Tue Nov 12 21:39:27 2024 +0100 tdf#161775 vcl: WMF export: remove special case of Dx in EXTTEXTOUT EMFWriter::ImplWriteTextRecord() has a special case for the last position of the DX array to write an average width of all the characters excluding the last one. This has been the case since CVS initial import, and i was unable to find any reason for it. When redacting "Schritte" (large text in bugdoc), it causes the right edge of the rectangle to be at 2964 instead of 3103, exposing the last character. Change-Id: I86391e97c4d06093adf3045b04f69153e8e3b0ef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176497 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index fb248fd9f3e0..891457153103 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -925,10 +925,8 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, K if( nLen > 1 ) { - for( i = 1; i < ( nLen - 1 ); i++ ) + for (i = 1; i < nLen; i++) ImplWriteExtent( pDX[ i ] - pDX[ i - 1 ] ); - - ImplWriteExtent( pDX[ nLen - 2 ] / ( nLen - 1 ) ); } ImplEndRecord();
