summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-05-27 13:27:37 +0200
committerCaolán McNamara <caolanm@redhat.com>2014-06-07 14:40:10 +0000
commita710e9307153885537ea3a0257b533bd6b8d2df3 (patch)
tree007560695156348d5552050feed52ae52cb384d1
parentc5607ee9ab4a55521c5a72a015c3c5f371fccfc3 (diff)
fdo#77454: sw: ww8 import: add heuristic to ignore mangled crop values
Older versions of OOo/LO would mangle negative crop values on round-trip of WW8, which now (since the drawing-layer does not ignore them) causes the images to be rendered invisible; probably large factors don't make sense anyway, so ignore the crop if it's 50x the image size, which happens to work for the bugdoc. Change-Id: I9f36d37e3be27234554bc91e80bfe719b1ce86af (cherry picked from commit 7e91dd0a3885ac561aee9cf7907632677b9886c1) Reviewed-on: https://gerrit.libreoffice.org/9508 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit a1f385b74a542ab3caaa8abbefc39f14bf27ca72) Reviewed-on: https://gerrit.libreoffice.org/9531 Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sw/source/filter/ww8/ww8graf.cxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 8051810875a7..6a298878b807 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -1994,8 +1994,14 @@ void SwWW8ImplReader::MapWrapIntoFlyFmt(SvxMSDffImportRec* pRecord,
static sal_Int32 lcl_ConvertCrop(sal_uInt32 const nCrop, sal_Int32 const nSize)
{
// cast to sal_Int32 to handle negative crop properly
- return ((static_cast<sal_Int32>(nCrop) >> 16) * nSize)
- + (((nCrop & 0xffff) * nSize) >> 16) ;
+ sal_Int32 const nIntegral(static_cast<sal_Int32>(nCrop) >> 16);
+ // fdo#77454: heuristic to detect mangled values written by old OOo/LO
+ if (abs(nIntegral) >= 50) // FIXME: what's a good cut-off?
+ {
+ SAL_INFO("sw.ww8", "ignoring suspiciously large crop: " << nIntegral);
+ return 0;
+ }
+ return (nIntegral * nSize) + (((nCrop & 0xffff) * nSize) >> 16);
}
void