summaryrefslogtreecommitdiff
path: root/writerfilter/source/rtftok/rtfdocumentimpl.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-11-04 11:27:44 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-11-04 12:47:40 +0100
commit995a6b38d5b8ac8aabca54f991caaaf35e6db395 (patch)
tree4461ac03328bde76115358da09dd9f4809fcc12d /writerfilter/source/rtftok/rtfdocumentimpl.cxx
parent8b7dbd220dbdfd286de2d770503dae8bf6d2e53e (diff)
RTF import: fix too small graphic size when both picwgoal and picw are provided
The original document provided \picwgoal and \pichgoal, stating the desired size of the image in twips. \picw and \pich is not provided, but we write it on export. The value of \picw and \pich is ignored by Word (it can calculate both the current and the original size from picw/hgoal and picscalex/h), so it displays the document correctly. Use the same trick in our RTF import: picscalex/y has a specified default value (100%), so if we have picwgoal and pichgoal, then we can also ignore picw and pich. This is needed, otherwise the much smaller size from picw/pich is used as the original size, so the layout "zooms in" so much that only a small white rectangle of the top left area is visible, as if the images would be all lost. Change-Id: I924e5f8b68613c654c857a57561c8a2e3a6db2f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124679 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'writerfilter/source/rtftok/rtfdocumentimpl.cxx')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx18
1 files changed, 12 insertions, 6 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 486a5bde6444..a67cbe904089 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -899,12 +899,18 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
uno::Reference<io::XInputStream> xInputStream(new utl::OInputStreamWrapper(pStream));
WmfExternal aExtHeader;
aExtHeader.mapMode = m_aStates.top().getPicture().eWMetafile;
- aExtHeader.xExt = sal_uInt16(
- std::clamp<sal_Int32>(m_aStates.top().getPicture().nWidth, 0,
- SAL_MAX_UINT16)); //TODO: better way to handle out-of-bounds values?
- aExtHeader.yExt = sal_uInt16(
- std::clamp<sal_Int32>(m_aStates.top().getPicture().nHeight, 0,
- SAL_MAX_UINT16)); //TODO: better way to handle out-of-bounds values?
+ if (m_aStates.top().getPicture().nGoalWidth == 0
+ || m_aStates.top().getPicture().nGoalHeight == 0)
+ {
+ // Don't use the values provided by picw and pich if the desired size is provided.
+
+ aExtHeader.xExt = sal_uInt16(std::clamp<sal_Int32>(
+ m_aStates.top().getPicture().nWidth, 0,
+ SAL_MAX_UINT16)); //TODO: better way to handle out-of-bounds values?
+ aExtHeader.yExt = sal_uInt16(std::clamp<sal_Int32>(
+ m_aStates.top().getPicture().nHeight, 0,
+ SAL_MAX_UINT16)); //TODO: better way to handle out-of-bounds values?
+ }
WmfExternal* pExtHeader = &aExtHeader;
uno::Reference<lang::XServiceInfo> xServiceInfo(m_aStates.top().getDrawingObject().getShape(),
uno::UNO_QUERY);