sfx2/source/doc/SfxRedactionHelper.cxx | 20 ++++++++++++-------- vcl/source/filter/wmf/emfwr.cxx | 4 +--- vcl/source/gdi/embeddedfontshelper.cxx | 16 ++++++++++++---- 3 files changed, 25 insertions(+), 15 deletions(-)
New commits: commit b2d517ef679365dee1de65f670259c7d4b25827a Author: Michael Stahl <[email protected]> AuthorDate: Tue Nov 12 19:24:47 2024 +0100 Commit: Michael Stahl <[email protected]> CommitDate: Tue Nov 12 21:50:07 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]> (cherry picked from commit 58948dd22464c38b2a042022f4d549ca926f0476) diff --git a/sfx2/source/doc/SfxRedactionHelper.cxx b/sfx2/source/doc/SfxRedactionHelper.cxx index f059f5aad074..d03e2b1b88a2 100644 --- a/sfx2/source/doc/SfxRedactionHelper.cxx +++ b/sfx2/source/doc/SfxRedactionHelper.cxx @@ -425,7 +425,10 @@ void SfxRedactionHelper::searchInMetaFile(const RedactionTarget* pRedactionTarge fillSearchOptions(aSearchOptions, pRedactionTarget); utl::TextSearch textSearch(aSearchOptions); - static long aLastFontHeight = 0; + + OutputDevice* pOutputDevice + = SfxObjectShell::GetShellFromComponent(xComponent)->GetDocumentRefDev(); + pOutputDevice->Push(::vcl::PushFlags::FONT); MetaAction* pCurrAct; @@ -448,18 +451,16 @@ void SfxRedactionHelper::searchInMetaFile(const RedactionTarget* pRedactionTarge // 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.getY() + (aNewRect.getHeight() - 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); } @@ -472,9 +473,12 @@ void SfxRedactionHelper::searchInMetaFile(const RedactionTarget* pRedactionTarge 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 e4e9b281d78163dd5f17db10efd0c8665b4423d2 Author: Michael Stahl <[email protected]> AuthorDate: Tue Nov 12 19:13:50 2024 +0100 Commit: Michael Stahl <[email protected]> CommitDate: Tue Nov 12 21:49:11 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 (cherry picked from commit f7368c95b6fe90aeb4f06c1eee15be770beda382) diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index 0204999672dc..bd0416f73832 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -899,10 +899,8 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, c 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(); commit 02e3aea1b2cfa3c686aab10721f9a89ecc382732 Author: Caolán McNamara <[email protected]> AuthorDate: Fri Nov 8 16:51:47 2024 +0000 Commit: Michael Stahl <[email protected]> CommitDate: Tue Nov 12 21:46:34 2024 +0100 be conservative on allowed temp font names Change-Id: Iefdc1a8c9b4c7e8c08c84f747f8287ac3c419839 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176236 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins (cherry picked from commit f761d098e9a0960554aa4fc02f84a711b50a1cff) diff --git a/vcl/source/gdi/embeddedfontshelper.cxx b/vcl/source/gdi/embeddedfontshelper.cxx index c5ab8914eb17..4902473dfcd1 100644 --- a/vcl/source/gdi/embeddedfontshelper.cxx +++ b/vcl/source/gdi/embeddedfontshelper.cxx @@ -17,6 +17,7 @@ #include <vcl/svapp.hxx> #include <vcl/embeddedfontshelper.hxx> #include <com/sun/star/io/XInputStream.hpp> +#include <comphelper/storagehelper.hxx> #include <outdev.h> #include <PhysicalFontCollection.hxx> @@ -162,10 +163,6 @@ bool EmbeddedFontsHelper::addEmbeddedFont( const uno::Reference< io::XInputStrea OUString EmbeddedFontsHelper::fileUrlForTemporaryFont( const OUString& fontName, const char* extra ) { - OUString path = "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}"; - rtl::Bootstrap::expandMacros( path ); - path += "/user/temp/embeddedfonts/fromdocs/"; - osl::Directory::createPath( path ); OUString filename = fontName; static int uniqueCounter = 0; if( strcmp( extra, "?" ) == 0 ) @@ -173,6 +170,17 @@ OUString EmbeddedFontsHelper::fileUrlForTemporaryFont( const OUString& fontName, else filename += OStringToOUString( extra, RTL_TEXTENCODING_ASCII_US ); filename += ".ttf"; // TODO is it always ttf? + + if (!::comphelper::OStorageHelper::IsValidZipEntryFileName(filename, false)) + { + SAL_WARN( "vcl.fonts", "Cannot use filename: " << filename << " for temporary font"); + filename = "font" + OUString::number(uniqueCounter++) + ".ttf"; + } + + OUString path = "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}"; + rtl::Bootstrap::expandMacros( path ); + path += "/user/temp/embeddedfonts/fromdocs/"; + osl::Directory::createPath( path ); return path + filename; }
