summaryrefslogtreecommitdiff
path: root/sw/source/uibase/wrtsh/wrtsh1.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-12-03 20:52:12 +0100
committerTomaž Vajngerl <quikee@gmail.com>2021-12-06 12:43:00 +0100
commit4c00e8fb10437fcaefe8635ef390b78376938d15 (patch)
treefd001904cf7640a13bd4a3ef3521f1c2db93fa4b /sw/source/uibase/wrtsh/wrtsh1.cxx
parent30d6787b98131fce5a280f005b75e9d496f21573 (diff)
Add image preffered DPI document setting, use it in Writer, Impress
This adds a "image preferred DPI" document setting, which is used as a suggestion of the DPI that an image should have in the document. This is currently used when the image is inserted into the document (Writer, Impress/Draw) to resize it to the preferred DPI value. Change-Id: I3ee9d409257e3c6aa2ead05144ecbba7b3b916f6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126334 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw/source/uibase/wrtsh/wrtsh1.cxx')
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx18
1 files changed, 16 insertions, 2 deletions
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 1120bed817b9..176183ac90db 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -334,8 +334,22 @@ void SwWrtShell::Insert( const OUString &rPath, const OUString &rFilter,
if( bSetGrfSize )
{
- Size aGrfSize, aBound = GetGraphicDefaultSize();
- GetGrfSize( aGrfSize );
+ Size aSizePixel = rGrf.GetSizePixel();
+ Size aBound = GetGraphicDefaultSize();
+
+ sal_Int32 nPreferredDPI = mxDoc->getIDocumentSettingAccess().getImagePreferredDPI();
+ Size aGrfSize;
+
+ if (nPreferredDPI > 0)
+ {
+ auto nWidth = o3tl::toTwips(aSizePixel.Width() / double(nPreferredDPI), o3tl::Length::in);
+ auto nHeight = o3tl::toTwips(aSizePixel.Height() / double(nPreferredDPI), o3tl::Length::in);
+ aGrfSize = Size(nWidth, nHeight);
+ }
+ else
+ {
+ GetGrfSize(aGrfSize);
+ }
// Add the margin attributes to GrfSize,
// because these counts at the margin additionally