summaryrefslogtreecommitdiff
path: root/emfio/inc
diff options
context:
space:
mode:
authorArmin Le Grand (Allotropia) <armin.le.grand@me.com>2021-02-23 14:24:24 +0100
committerArmin Le Grand <Armin.Le.Grand@me.com>2021-02-23 20:42:34 +0100
commit3d33e4ce3987ea17e73a72e84f7f0df7af8101a6 (patch)
tree32f1f556d21d63c02a746813e2b2e993e2a3f764 /emfio/inc
parented796e0fcd47edcc1df2766a08aaf0cb85622bab (diff)
tdf#127471 Detect&Correct EMF/WMF with wrong FontScale
Before correcting our EMF/WMF export to write the Windows- specific data in the case of FontScaling, we wrote these files with wrong FontScaling. This change tries to detect and correct this at import, so that newer versions of the office on all plattforms can again load old, from us but not on Windows written EMF/WMF files. With this change we can read again all new and old EMF/WMF files (see table in task, comment 80). Change-Id: I1a0b0ab5f57c7cd40520401568af05cab4ecb4c8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111399 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'emfio/inc')
-rw-r--r--emfio/inc/mtftools.hxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx
index 70471b66ea21..286442767d3a 100644
--- a/emfio/inc/mtftools.hxx
+++ b/emfio/inc/mtftools.hxx
@@ -27,6 +27,7 @@
#include <vcl/bitmapex.hxx>
#include <vcl/lineinfo.hxx>
#include <vcl/outdevstate.hxx>
+#include <rtl/ref.hxx>
#include "emfiodllapi.h"
@@ -259,6 +260,8 @@ namespace emfio
#define HUNDREDTH_MILLIMETERS_PER_MILLIINCH 2.54
#define MILLIINCH_PER_TWIPS 1.44
+class MetaFontAction;
+
//============================ WmfReader ==================================
namespace emfio
@@ -458,6 +461,24 @@ namespace emfio
{}
};
+ // tdf#127471 implement detection and correction of wrongly scaled
+ // fonts in own-written, old (before this fix) EMF/WMF files
+ class ScaledFontDetectCorrectHelper
+ {
+ private:
+ rtl::Reference<MetaFontAction> maCurrentMetaFontAction;
+ std::vector<double> maAlternativeFontScales;
+ std::vector<std::pair<rtl::Reference<MetaFontAction>, double>> maPositiveIdentifiedCases;
+ std::vector<std::pair<rtl::Reference<MetaFontAction>, double>> maNegativeIdentifiedCases;
+
+ public:
+ ScaledFontDetectCorrectHelper();
+ void endCurrentMetaFontAction();
+ void newCurrentMetaFontAction(rtl::Reference<MetaFontAction>& rNewMetaFontAction);
+ void evaluateAlternativeFontScale(OUString const & rText, tools::Long nImportedTextLength);
+ void applyAlternativeFontScale();
+ };
+
class MtfTools
{
MtfTools(MtfTools const &) = delete;
@@ -521,6 +542,9 @@ namespace emfio
sal_uInt32 mnEndPos;
std::vector<std::unique_ptr<BSaveStruct>> maBmpSaveList;
+ // tdf#127471 always try to detect - only used with ScaledText
+ ScaledFontDetectCorrectHelper maScaledFontHelper;
+
bool mbNopMode : 1;
bool mbFillStyleSelected : 1;
bool mbClipNeedsUpdate : 1;