include/sfx2/dinfdlg.hxx                      |    4 
 sc/inc/document.hxx                           |    5 
 sc/inc/unonames.hxx                           |    1 
 sc/source/core/data/documen2.cxx              |    1 
 sc/source/ui/unoobj/confuno.cxx               |   14 -
 sd/inc/drawdoc.hxx                            |    5 
 sd/source/core/drawdoc.cxx                    |    1 
 sd/source/ui/unoidl/UnoDocumentSettings.cxx   |   20 +
 sd/source/ui/view/sdview4.cxx                 |   39 ++
 sfx2/source/dialog/dinfdlg.cxx                |   59 ++++
 sfx2/uiconfig/ui/documentinfopage.ui          |  342 ++++++++++++++++----------
 sw/inc/IDocumentSettingAccess.hxx             |    3 
 sw/source/core/doc/DocumentSettingManager.cxx |    3 
 sw/source/core/inc/DocumentSettingManager.hxx |    9 
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   17 +
 sw/source/uibase/wrtsh/wrtsh1.cxx             |   19 +
 16 files changed, 399 insertions(+), 143 deletions(-)

New commits:
commit 331b1fba6b1981a867678795e2fc38185bc0cac6
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Dec 3 20:52:12 2021 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Jan 6 09:18:06 2022 +0100

    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.
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126334
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 4c00e8fb10437fcaefe8635ef390b78376938d15)
    
    Change-Id: I3ee9d409257e3c6aa2ead05144ecbba7b3b916f6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127206
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx
index 08be8bb5ea19..efdb957d3a57 100644
--- a/include/sfx2/dinfdlg.hxx
+++ b/include/sfx2/dinfdlg.hxx
@@ -192,10 +192,14 @@ private:
 
     std::unique_ptr<weld::Label> m_xTemplFt;
     std::unique_ptr<weld::Label> m_xTemplValFt;
+    std::unique_ptr<weld::CheckButton> m_xImagePreferredDpiCheckButton;
+    std::unique_ptr<weld::ComboBox> m_xImagePreferredDpiComboBox;
 
     DECL_LINK(DeleteHdl, weld::Button&, void);
     DECL_LINK(SignatureHdl, weld::Button&, void);
     DECL_LINK(ChangePassHdl, weld::Button&, void);
+    DECL_LINK(ImagePreferredDPICheckBoxClicked, weld::ToggleButton&, void);
+
     void                ImplUpdateSignatures();
     void                ImplCheckPasswordState();
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 8c3c2ec79431..91e2c5b7c0b3 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -561,6 +561,8 @@ private:
     bool mbEmbedFontScriptAsian : 1;
     bool mbEmbedFontScriptComplex : 1;
 
+    sal_Int32 mnImagenPreferredDPI;
+
     std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap;
 
     bool                mbTrackFormulasPending  : 1;
@@ -586,6 +588,9 @@ public:
     void SetEmbedFontScriptAsian(bool bUse) { mbEmbedFontScriptAsian = bUse; }
     void SetEmbedFontScriptComplex(bool bUse) { mbEmbedFontScriptComplex = 
bUse; }
 
+    void SetImagePreferredDPI(sal_Int32 nValue) { mnImagenPreferredDPI = 
nValue; }
+    sal_Int32 GetImagePreferredDPI() { return mnImagenPreferredDPI; }
+
     SC_DLLPUBLIC sal_uLong   GetCellCount() const;       // all cells
     SC_DLLPUBLIC sal_uLong   GetFormulaGroupCount() const;       // all cells
     sal_uLong                GetCodeCount() const;       // RPN-Code in 
formulas
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index 6fb5051ec249..5dda3ad674d3 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -571,6 +571,7 @@
 #define SC_UNO_UPDTEMPL             "UpdateFromTemplate"
 #define SC_UNO_FILTERED_RANGE_SELECTION       "FilteredRangeSelection"
 #define SC_UNO_VISAREASCREEN        "VisibleAreaOnScreen"
+#define SC_UNO_IMAGE_PREFERRED_DPI  "ImagePreferredDPI"
 
 /*Stampit enable/disable print cancel */
 #define SC_UNO_ALLOWPRINTJOBCANCEL  "AllowPrintJobCancel"
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 7271fdef0d43..4846c301dca7 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -163,6 +163,7 @@ ScDocument::ScDocument( ScDocumentMode eMode, 
SfxObjectShell* pDocShell ) :
         mbEmbedFontScriptLatin(true),
         mbEmbedFontScriptAsian(true),
         mbEmbedFontScriptComplex(true),
+        mnImagenPreferredDPI(0),
         mbTrackFormulasPending(false),
         mbFinalTrackFormulas(false),
         mbDocShellRecalc(false),
diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx
index 5cd457885c71..00740cd958ee 100644
--- a/sc/source/ui/unoobj/confuno.cxx
+++ b/sc/source/ui/unoobj/confuno.cxx
@@ -88,6 +88,7 @@ static const SfxItemPropertyMapEntry* 
lcl_GetConfigPropertyMap()
         {OUString(SC_UNO_EMBED_FONT_SCRIPT_LATIN),   0,  
cppu::UnoType<bool>::get(), 0, 0},
         {OUString(SC_UNO_EMBED_FONT_SCRIPT_ASIAN),   0,  
cppu::UnoType<bool>::get(), 0, 0},
         {OUString(SC_UNO_EMBED_FONT_SCRIPT_COMPLEX), 0,  
cppu::UnoType<bool>::get(), 0, 0},
+        {OUString(SC_UNO_IMAGE_PREFERRED_DPI),       0,  
cppu::UnoType<sal_Int32>::get(), 0, 0},
         {OUString(SC_UNO_SYNTAXSTRINGREF), 0,  
cppu::UnoType<sal_Int16>::get(),     0, 0},
         { OUString(), 0, css::uno::Type(), 0, 0 }
     };
@@ -388,7 +389,13 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue(
             rDoc.SetCalcConfig( aCalcConfig );
         }
     }
-
+    else if (aPropertyName == SC_UNO_IMAGE_PREFERRED_DPI)
+    {
+        if (aValue.has<sal_Int32>())
+        {
+            rDoc.SetImagePreferredDPI(aValue.get<sal_Int32>());
+        }
+    }
     else
     {
         ScGridOptions aGridOpt(aViewOpt.GetGridOptions());
@@ -589,7 +596,10 @@ uno::Any SAL_CALL 
ScDocumentConfiguration::getPropertyValue( const OUString& aPr
              }
          }
     }
-
+    else if (aPropertyName == SC_UNO_IMAGE_PREFERRED_DPI)
+    {
+        aRet <<= rDoc.GetImagePreferredDPI();
+    }
     else
     {
         const ScGridOptions& aGridOpt = aViewOpt.GetGridOptions();
diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx
index b5b6e574ca0c..79f9ea901da8 100644
--- a/sd/inc/drawdoc.hxx
+++ b/sd/inc/drawdoc.hxx
@@ -200,6 +200,8 @@ private:
     bool mbEmbedFontScriptAsian : 1;
     bool mbEmbedFontScriptComplex : 1;
 
+    sal_Int32 mnImagePreferredDPI;
+
     SAL_DLLPRIVATE virtual css::uno::Reference< css::uno::XInterface > 
createUnoModel() override;
 
 public:
@@ -626,6 +628,9 @@ public:
     SAL_DLLPRIVATE void SetEmbedFontScriptAsian(bool bUse) { 
mbEmbedFontScriptAsian = bUse; }
     SAL_DLLPRIVATE void SetEmbedFontScriptComplex(bool bUse) { 
mbEmbedFontScriptComplex = bUse; }
 
+    sal_Int32 getImagePreferredDPI() { return mnImagePreferredDPI; }
+    void setImagePreferredDPI(sal_Int32 nValue) { mnImagePreferredDPI = 
nValue; }
+
     void dumpAsXml(xmlTextWriterPtr pWriter) const override;
 
 private:
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index 93074a90ce41..65e254c4b400 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -135,6 +135,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, 
SfxObjectShell* pDrDocSh)
 , mbEmbedFontScriptLatin(true)
 , mbEmbedFontScriptAsian(true)
 , mbEmbedFontScriptComplex(true)
+, mnImagePreferredDPI(0)
 {
     mpDrawPageListWatcher.reset(new ImpDrawPageListWatcher(*this));
     mpMasterPageListWatcher.reset(new ImpMasterPageListWatcher(*this));
diff --git a/sd/source/ui/unoidl/UnoDocumentSettings.cxx 
b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
index b765dc59a0dc..7ef72d693b69 100644
--- a/sd/source/ui/unoidl/UnoDocumentSettings.cxx
+++ b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
@@ -142,6 +142,7 @@ enum SdDocumentSettingsPropertyHandles
     ,HANDLE_SLIDESPERHANDOUT, HANDLE_HANDOUTHORIZONTAL,
     HANDLE_EMBED_FONTS, HANDLE_EMBED_USED_FONTS,
     HANDLE_EMBED_LATIN_SCRIPT_FONTS, HANDLE_EMBED_ASIAN_SCRIPT_FONTS, 
HANDLE_EMBED_COMPLEX_SCRIPT_FONTS,
+    HANDLE_IMAGE_PREFERRED_DPI
 };
 
 #define MID_PRINTER 1
@@ -210,6 +211,7 @@ enum SdDocumentSettingsPropertyHandles
             { OUString("EmbedLatinScriptFonts"),   
HANDLE_EMBED_LATIN_SCRIPT_FONTS,   cppu::UnoType<bool>::get(), 0,  0 },
             { OUString("EmbedAsianScriptFonts"),   
HANDLE_EMBED_ASIAN_SCRIPT_FONTS,   cppu::UnoType<bool>::get(), 0,  0 },
             { OUString("EmbedComplexScriptFonts"), 
HANDLE_EMBED_COMPLEX_SCRIPT_FONTS, cppu::UnoType<bool>::get(), 0,  0 },
+            { OUString("ImagePreferredDPI"), HANDLE_IMAGE_PREFERRED_DPI, 
cppu::UnoType<sal_Int32>::get(), 0,  0 },
             { OUString(), 0, css::uno::Type(), 0, 0 }
         };
 
@@ -1019,6 +1021,18 @@ DocumentSettings::_setPropertyValues(const 
PropertyMapEntry** ppEntries,
             }
             break;
 
+            case HANDLE_IMAGE_PREFERRED_DPI:
+            {
+                if (pValues->has<sal_Int32>())
+                {
+                    auto nNewValue = pValues->get<sal_Int32>();
+                    bChanged = (pDoc->getImagePreferredDPI() != nNewValue);
+                    pDoc->setImagePreferredDPI(nNewValue);
+                    bOk = true;
+                }
+            }
+            break;
+
             default:
                 throw UnknownPropertyException( 
OUString::number((*ppEntries)->mnHandle), 
static_cast<cppu::OWeakObject*>(this));
         }
@@ -1293,6 +1307,12 @@ DocumentSettings::_getPropertyValues(
             }
             break;
 
+            case HANDLE_IMAGE_PREFERRED_DPI:
+            {
+                *pValue <<= pDoc->getImagePreferredDPI();
+            }
+            break;
+
             default:
                 throw UnknownPropertyException( 
OUString::number((*ppEntries)->mnHandle), 
static_cast<cppu::OWeakObject*>(this));
         }
diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx
index 0bf877f6fc02..3d804dff36e5 100644
--- a/sd/source/ui/view/sdview4.cxx
+++ b/sd/source/ui/view/sdview4.cxx
@@ -170,6 +170,8 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, 
sal_Int8& rAction,
 
     else if ( pPV )
     {
+        Size aSizePixel = rGraphic.GetSizePixel();
+
         // create  new object
         Size aSize;
 
@@ -192,15 +194,34 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, 
sal_Int8& rAction,
                                                 MapMode( MapUnit::Map100thMM ) 
);
         }
 
-        pNewGrafObj = new SdrGrafObj(
-            getSdrModelFromSdrView(),
-            rGraphic,
-            ::tools::Rectangle(rPos, aSize));
-        SdrPage* pPage = pPV->GetPage();
-        Size aPageSize( pPage->GetSize() );
-        aPageSize.AdjustWidth( -(pPage->GetLeftBorder() + 
pPage->GetRightBorder()) );
-        aPageSize.AdjustHeight( -(pPage->GetUpperBorder() + 
pPage->GetLowerBorder()) );
-        pNewGrafObj->AdjustToMaxRect( ::tools::Rectangle( Point(), aPageSize 
), true );
+        sal_Int32 nPreferredDPI = mrDoc.getImagePreferredDPI();
+        if (nPreferredDPI > 0)
+        {
+            constexpr double fTwipsInAnInch = 1444.0;
+            auto nWidth = (aSizePixel.Width() / double(nPreferredDPI)) * 
fTwipsInAnInch;
+            auto nHeight = (aSizePixel.Height() / double(nPreferredDPI)) * 
fTwipsInAnInch;
+            nWidth = convertTwipToMm100(nWidth);
+            nHeight = convertTwipToMm100(nHeight);
+
+            if (nWidth > 0 && nHeight > 0)
+                aSize = Size(nWidth, nHeight);
+        }
+
+        pNewGrafObj = new SdrGrafObj(getSdrModelFromSdrView(), rGraphic, 
::tools::Rectangle(rPos, aSize));
+
+        if (nPreferredDPI > 0)
+        {
+            // move to the center of insertion point
+            pNewGrafObj->NbcMove(Size(-aSize.Width() / 2, -aSize.Height() / 
2));
+        }
+        else
+        {
+            SdrPage* pPage = pPV->GetPage();
+            Size aPageSize( pPage->GetSize() );
+            aPageSize.AdjustWidth( -(pPage->GetLeftBorder() + 
pPage->GetRightBorder()) );
+            aPageSize.AdjustHeight( -(pPage->GetUpperBorder() + 
pPage->GetLowerBorder()) );
+            pNewGrafObj->AdjustToMaxRect( ::tools::Rectangle( Point(), 
aPageSize ), true );
+        }
 
         SdrInsertFlags nOptions = SdrInsertFlags::SETDEFLAYER;
         bool    bIsPresTarget = false;
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index af3459680517..b5dfa876446b 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -56,6 +56,7 @@
 #include <com/sun/star/util/Duration.hpp>
 #include <com/sun/star/document/XDocumentProperties.hpp>
 #include <com/sun/star/document/CmisProperty.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
 
 #include <vcl/timer.hxx>
 #include <vcl/settings.hxx>
@@ -715,6 +716,8 @@ SfxDocumentPage::SfxDocumentPage(weld::Container* pPage, 
weld::DialogController*
     , m_xUseThumbnailSaveCB(m_xBuilder->weld_check_button("thumbnailsavecb"))
     , m_xTemplFt(m_xBuilder->weld_label("templateft"))
     , m_xTemplValFt(m_xBuilder->weld_label("showtemplate"))
+    , 
m_xImagePreferredDpiCheckButton(m_xBuilder->weld_check_button("image-preferred-dpi-checkbutton"))
+    , 
m_xImagePreferredDpiComboBox(m_xBuilder->weld_combo_box("image-preferred-dpi-combobox"))
 {
     m_aUnknownSize = m_xShowSizeFT->get_label();
     m_xShowSizeFT->set_label(OUString());
@@ -727,6 +730,7 @@ SfxDocumentPage::SfxDocumentPage(weld::Container* pPage, 
weld::DialogController*
     m_xChangePassBtn->connect_clicked( LINK( this, SfxDocumentPage, 
ChangePassHdl ) );
     m_xSignatureBtn->connect_clicked( LINK( this, SfxDocumentPage, 
SignatureHdl ) );
     m_xDeleteBtn->connect_clicked( LINK( this, SfxDocumentPage, DeleteHdl ) );
+    m_xImagePreferredDpiCheckButton->connect_toggled(LINK(this, 
SfxDocumentPage, ImagePreferredDPICheckBoxClicked));
 
     // [i96288] Check if the document signature command is enabled
     // on the main list enable/disable the pushbutton accordingly
@@ -767,6 +771,12 @@ IMPL_LINK_NOARG(SfxDocumentPage, SignatureHdl, 
weld::Button&, void)
     }
 }
 
+IMPL_LINK_NOARG(SfxDocumentPage, ImagePreferredDPICheckBoxClicked, 
weld::ToggleButton&, void)
+{
+    bool bEnabled = m_xImagePreferredDpiCheckButton->get_state() == 
TRISTATE_TRUE;
+    m_xImagePreferredDpiComboBox->set_sensitive(bEnabled);
+}
+
 IMPL_LINK_NOARG(SfxDocumentPage, ChangePassHdl, weld::Button&, void)
 {
     SfxObjectShell* pShell = SfxObjectShell::Current();
@@ -917,6 +927,26 @@ bool SfxDocumentPage::FillItemSet( SfxItemSet* rSet )
         }
     }
 
+    SfxObjectShell* pDocSh = SfxObjectShell::Current();
+    if (pDocSh)
+    {
+        uno::Reference<lang::XMultiServiceFactory> xFac(pDocSh->GetModel(), 
uno::UNO_QUERY);
+        if (xFac.is())
+        {
+            uno::Reference<beans::XPropertySet> 
xProps(xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY);
+            if (xProps.is())
+            {
+                sal_Int32 nImagePreferredDPI = 0;
+                if (m_xImagePreferredDpiCheckButton->get_state() == 
TRISTATE_TRUE)
+                {
+                    OUString aImagePreferredDPIString = 
m_xImagePreferredDpiComboBox->get_active_text();
+                    nImagePreferredDPI = aImagePreferredDPIString.toInt32();
+                }
+                xProps->setPropertyValue("ImagePreferredDPI", 
uno::makeAny(nImagePreferredDPI));
+            }
+        }
+    }
+
     return bRet;
 }
 
@@ -1071,6 +1101,35 @@ void SfxDocumentPage::Reset( const SfxItemSet* rSet )
     m_xDeleteBtn->set_sensitive( bEnableUseUserData );
     m_xUseThumbnailSaveCB->set_active(bUseThumbnailSave);
     m_xUseThumbnailSaveCB->save_state();
+
+    SfxObjectShell* pDocSh = SfxObjectShell::Current();
+    sal_Int32 nImagePreferredDPI = 0;
+    if (pDocSh)
+    {
+        try
+        {
+            uno::Reference< lang::XMultiServiceFactory > xFac( 
pDocSh->GetModel(), uno::UNO_QUERY_THROW );
+            uno::Reference< beans::XPropertySet > xProps( 
xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY_THROW );
+
+            xProps->getPropertyValue("ImagePreferredDPI") >>= 
nImagePreferredDPI;
+        }
+        catch( uno::Exception& )
+        {
+        }
+    }
+    if (nImagePreferredDPI > 0)
+    {
+        m_xImagePreferredDpiCheckButton->set_state(TRISTATE_TRUE);
+        m_xImagePreferredDpiComboBox->set_sensitive(true);
+        
m_xImagePreferredDpiComboBox->set_entry_text(OUString::number(nImagePreferredDPI));
+    }
+    else
+    {
+        m_xImagePreferredDpiCheckButton->set_state(TRISTATE_FALSE);
+        m_xImagePreferredDpiComboBox->set_sensitive(false);
+        m_xImagePreferredDpiComboBox->set_entry_text("");
+    }
+
 }
 
 SfxDocumentInfoDialog::SfxDocumentInfoDialog(weld::Window* pParent, const 
SfxItemSet& rItemSet)
diff --git a/sfx2/uiconfig/ui/documentinfopage.ui 
b/sfx2/uiconfig/ui/documentinfopage.ui
index 6799a99f5665..d51a82876170 100644
--- a/sfx2/uiconfig/ui/documentinfopage.ui
+++ b/sfx2/uiconfig/ui/documentinfopage.ui
@@ -1,224 +1,225 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.1 -->
+<!-- Generated with glade 3.38.2 -->
 <interface domain="sfx">
   <requires lib="gtk+" version="3.18"/>
+  <!-- n-columns=3 n-rows=14 -->
   <object class="GtkGrid" id="DocumentInfoPage">
     <property name="visible">True</property>
-    <property name="can_focus">False</property>
+    <property name="can-focus">False</property>
     <property name="hexpand">True</property>
     <property name="vexpand">True</property>
-    <property name="border_width">12</property>
-    <property name="row_spacing">6</property>
-    <property name="column_spacing">12</property>
+    <property name="border-width">12</property>
+    <property name="row-spacing">6</property>
+    <property name="column-spacing">12</property>
     <child>
       <object class="GtkLabel" id="label13">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="halign">end</property>
         <property name="label" translatable="yes" 
context="documentinfopage|label13">_Created:</property>
-        <property name="use_underline">True</property>
-        <property name="mnemonic_widget">showcreate</property>
+        <property name="use-underline">True</property>
+        <property name="mnemonic-widget">showcreate</property>
       </object>
       <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">4</property>
+        <property name="left-attach">0</property>
+        <property name="top-attach">4</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="label14">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="halign">end</property>
         <property name="label" translatable="yes" 
context="documentinfopage|label14">_Modified:</property>
-        <property name="use_underline">True</property>
-        <property name="mnemonic_widget">showmodify</property>
+        <property name="use-underline">True</property>
+        <property name="mnemonic-widget">showmodify</property>
       </object>
       <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">5</property>
+        <property name="left-attach">0</property>
+        <property name="top-attach">5</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="label15">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="halign">end</property>
         <property name="label" translatable="yes" 
context="documentinfopage|label15">_Digitally signed:</property>
-        <property name="use_underline">True</property>
-        <property name="mnemonic_widget">showsigned</property>
+        <property name="use-underline">True</property>
+        <property name="mnemonic-widget">showsigned</property>
       </object>
       <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">7</property>
+        <property name="left-attach">0</property>
+        <property name="top-attach">7</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="label16">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="halign">end</property>
         <property name="label" translatable="yes" 
context="documentinfopage|label16">Last pri_nted:</property>
-        <property name="use_underline">True</property>
-        <property name="mnemonic_widget">showprint</property>
+        <property name="use-underline">True</property>
+        <property name="mnemonic-widget">showprint</property>
       </object>
       <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">8</property>
+        <property name="left-attach">0</property>
+        <property name="top-attach">8</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="label17">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="halign">end</property>
         <property name="label" translatable="yes" 
context="documentinfopage|label17">Total _editing time:</property>
-        <property name="use_underline">True</property>
-        <property name="mnemonic_widget">showedittime</property>
+        <property name="use-underline">True</property>
+        <property name="mnemonic-widget">showedittime</property>
       </object>
       <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">9</property>
+        <property name="left-attach">0</property>
+        <property name="top-attach">9</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="label18">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="halign">end</property>
         <property name="label" translatable="yes" 
context="documentinfopage|label18">Re_vision number:</property>
-        <property name="use_underline">True</property>
-        <property name="mnemonic_widget">showrevision</property>
+        <property name="use-underline">True</property>
+        <property name="mnemonic-widget">showrevision</property>
       </object>
       <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">10</property>
+        <property name="left-attach">0</property>
+        <property name="top-attach">10</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="showcreate">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="hexpand">True</property>
         <property name="selectable">True</property>
         <property name="xalign">0</property>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">4</property>
+        <property name="left-attach">1</property>
+        <property name="top-attach">4</property>
         <property name="width">2</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="showmodify">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="hexpand">True</property>
         <property name="selectable">True</property>
         <property name="xalign">0</property>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">5</property>
+        <property name="left-attach">1</property>
+        <property name="top-attach">5</property>
         <property name="width">2</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="showsigned">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="hexpand">True</property>
         <property name="label" translatable="yes" 
context="documentinfopage|showsigned">Multiply signed document</property>
         <property name="selectable">True</property>
         <property name="xalign">0</property>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">7</property>
+        <property name="left-attach">1</property>
+        <property name="top-attach">7</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="showprint">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="hexpand">True</property>
         <property name="selectable">True</property>
         <property name="xalign">0</property>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">8</property>
+        <property name="left-attach">1</property>
+        <property name="top-attach">8</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="showedittime">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="hexpand">True</property>
         <property name="selectable">True</property>
         <property name="xalign">0</property>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">9</property>
+        <property name="left-attach">1</property>
+        <property name="top-attach">9</property>
         <property name="width">2</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="showrevision">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="hexpand">True</property>
         <property name="selectable">True</property>
         <property name="xalign">0</property>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">10</property>
+        <property name="left-attach">1</property>
+        <property name="top-attach">10</property>
         <property name="width">2</property>
       </packing>
     </child>
     <child>
       <object class="GtkCheckButton" id="userdatacb">
         <property name="label" translatable="yes" 
context="documentinfopage|userdatacb">_Apply user data</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">False</property>
-        <property name="no_show_all">True</property>
-        <property name="use_underline">True</property>
+        <property name="can-focus">True</property>
+        <property name="receives-default">False</property>
+        <property name="no-show-all">True</property>
+        <property name="use-underline">True</property>
         <property name="xalign">0</property>
-        <property name="draw_indicator">True</property>
+        <property name="draw-indicator">True</property>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">11</property>
+        <property name="left-attach">1</property>
+        <property name="top-attach">11</property>
       </packing>
     </child>
     <child>
       <object class="GtkCheckButton" id="thumbnailsavecb">
         <property name="label" translatable="yes" 
context="documentinfopage|thumbnailsavecb">Save preview image with this 
document</property>
         <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">False</property>
-        <property name="no_show_all">True</property>
-        <property name="use_underline">True</property>
+        <property name="can-focus">True</property>
+        <property name="receives-default">False</property>
+        <property name="no-show-all">True</property>
+        <property name="use-underline">True</property>
         <property name="xalign">0</property>
-        <property name="draw_indicator">True</property>
+        <property name="draw-indicator">True</property>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">12</property>
+        <property name="left-attach">1</property>
+        <property name="top-attach">12</property>
       </packing>
     </child>
     <child>
       <object class="GtkButton" id="reset">
         <property name="label" translatable="yes" 
context="documentinfopage|reset">Reset Properties</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">True</property>
-        <property name="no_show_all">True</property>
+        <property name="can-focus">True</property>
+        <property name="receives-default">True</property>
+        <property name="no-show-all">True</property>
         <property name="valign">center</property>
       </object>
       <packing>
-        <property name="left_attach">2</property>
-        <property name="top_attach">11</property>
+        <property name="left-attach">2</property>
+        <property name="top-attach">11</property>
         <property name="height">2</property>
       </packing>
     </child>
@@ -226,179 +227,256 @@
       <object class="GtkButton" id="signature">
         <property name="label" translatable="yes" 
context="documentinfopage|signature">Di_gital Signatures...</property>
         <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="has_focus">True</property>
-        <property name="receives_default">True</property>
+        <property name="can-focus">True</property>
+        <property name="has-focus">True</property>
+        <property name="receives-default">True</property>
         <property name="valign">center</property>
-        <property name="use_underline">True</property>
+        <property name="use-underline">True</property>
       </object>
       <packing>
-        <property name="left_attach">2</property>
-        <property name="top_attach">6</property>
+        <property name="left-attach">2</property>
+        <property name="top-attach">6</property>
         <property name="height">3</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="label11">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="halign">end</property>
         <property name="label" translatable="yes" 
context="documentinfopage|label11">_Size:</property>
-        <property name="use_underline">True</property>
-        <property name="mnemonic_widget">showsize</property>
+        <property name="use-underline">True</property>
+        <property name="mnemonic-widget">showsize</property>
       </object>
       <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">3</property>
+        <property name="left-attach">0</property>
+        <property name="top-attach">3</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="showsize">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="label" translatable="yes" 
context="documentinfopage|showsize">unknown</property>
         <property name="selectable">True</property>
         <property name="xalign">0</property>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">3</property>
+        <property name="left-attach">1</property>
+        <property name="top-attach">3</property>
         <property name="width">2</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="label8">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="halign">end</property>
         <property name="label" translatable="yes" 
context="documentinfopage|label8">_Location:</property>
-        <property name="use_underline">True</property>
-        <property name="mnemonic_widget">showlocation</property>
+        <property name="use-underline">True</property>
+        <property name="mnemonic-widget">showlocation</property>
       </object>
       <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">2</property>
+        <property name="left-attach">0</property>
+        <property name="top-attach">2</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="showlocation">
         <property name="visible">True</property>
-        <property name="can_focus">True</property>
+        <property name="can-focus">True</property>
         <property name="hexpand">True</property>
         <property name="selectable">True</property>
         <property name="ellipsize">middle</property>
-        <property name="max_width_chars">50</property>
+        <property name="max-width-chars">50</property>
         <property name="xalign">0</property>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">2</property>
+        <property name="left-attach">1</property>
+        <property name="top-attach">2</property>
         <property name="width">2</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="label7">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="halign">end</property>
         <property name="xpad">1</property>
         <property name="label" translatable="yes" 
context="documentinfopage|label7">_Type:</property>
-        <property name="use_underline">True</property>
-        <property name="mnemonic_widget">showtype</property>
+        <property name="use-underline">True</property>
+        <property name="mnemonic-widget">showtype</property>
       </object>
       <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">1</property>
+        <property name="left-attach">0</property>
+        <property name="top-attach">1</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="showtype">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="selectable">True</property>
         <property name="xalign">0</property>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">1</property>
+        <property name="left-attach">1</property>
+        <property name="top-attach">1</property>
       </packing>
     </child>
     <child>
       <object class="GtkButton" id="changepass">
         <property name="label" translatable="yes" 
context="documentinfopage|changepass">Change _Password</property>
         <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">True</property>
+        <property name="can-focus">True</property>
+        <property name="receives-default">True</property>
         <property name="valign">start</property>
-        <property name="use_underline">True</property>
+        <property name="use-underline">True</property>
       </object>
       <packing>
-        <property name="left_attach">2</property>
-        <property name="top_attach">0</property>
+        <property name="left-attach">2</property>
+        <property name="top-attach">0</property>
         <property name="height">2</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="templateft">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="halign">end</property>
         <property name="label" translatable="yes" 
context="documentinfopage|templateft">Template:</property>
-        <property name="use_underline">True</property>
-        <property name="mnemonic_widget">showtemplate</property>
+        <property name="use-underline">True</property>
+        <property name="mnemonic-widget">showtemplate</property>
       </object>
       <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">6</property>
+        <property name="left-attach">0</property>
+        <property name="top-attach">6</property>
       </packing>
     </child>
     <child>
       <object class="GtkLabel" id="showtemplate">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="selectable">True</property>
-        <property name="max_width_chars">56</property>
+        <property name="max-width-chars">56</property>
         <property name="xalign">0</property>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">6</property>
+        <property name="left-attach">1</property>
+        <property name="top-attach">6</property>
       </packing>
     </child>
     <child>
+      <!-- n-columns=3 n-rows=3 -->
       <object class="GtkGrid" id="grid1">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="column_spacing">12</property>
+        <property name="can-focus">False</property>
+        <property name="column-spacing">12</property>
         <child>
           <object class="GtkImage" id="icon">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="can-focus">False</property>
             <property name="valign">center</property>
             <property name="stock">gtk-missing-image</property>
           </object>
           <packing>
-            <property name="left_attach">0</property>
-            <property name="top_attach">0</property>
+            <property name="left-attach">0</property>
+            <property name="top-attach">0</property>
           </packing>
         </child>
         <child>
           <object class="GtkLabel" id="nameed">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="can-focus">False</property>
             <property name="selectable">True</property>
-            <property name="single_line_mode">True</property>
-            <property name="max_width_chars">56</property>
+            <property name="single-line-mode">True</property>
+            <property name="max-width-chars">56</property>
           </object>
           <packing>
-            <property name="left_attach">1</property>
-            <property name="top_attach">0</property>
+            <property name="left-attach">1</property>
+            <property name="top-attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+      <packing>
+        <property name="left-attach">1</property>
+        <property name="top-attach">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">True</property>
+        <property name="can-focus">False</property>
+        <child>
+          <object class="GtkCheckButton" id="image-preferred-dpi-checkbutton">
+            <property name="label" translatable="yes" 
context="documentinfopage|image-preferred-dpi-checkbutton">Image preferred 
DPI</property>
+            <property name="visible">True</property>
+            <property name="can-focus">True</property>
+            <property name="receives-default">False</property>
+            <property name="hexpand">True</property>
+            <property name="draw-indicator">True</property>
+            <accessibility>
+              <relation type="label-for" 
target="image-preferred-dpi-combobox"/>
+            </accessibility>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkComboBoxText" id="image-preferred-dpi-combobox">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="has-entry">True</property>
+            <items>
+              <item>96</item>
+              <item>150</item>
+              <item>200</item>
+              <item>300</item>
+              <item>600</item>
+            </items>
+            <child internal-child="entry">
+              <object class="GtkEntry">
+                <property name="can-focus">False</property>
+              </object>
+            </child>
+            <accessibility>
+              <relation type="labelled-by" 
target="image-preferred-dpi-checkbutton"/>
+            </accessibility>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
           </packing>
         </child>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">0</property>
+        <property name="left-attach">1</property>
+        <property name="top-attach">13</property>
       </packing>
     </child>
     <child>
@@ -410,5 +488,11 @@
     <child>
       <placeholder/>
     </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
   </object>
 </interface>
diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index 287a12604850..4a223b6fb563 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -242,6 +242,9 @@ enum class DocumentSettingId
     */
     virtual void Setn32DummyCompatibilityOptions2( const sal_uInt32 
CompatibilityOptions2 ) = 0;
 
+    virtual sal_Int32 getImagePreferredDPI() = 0;
+    virtual void setImagePreferredDPI(sal_Int32 nValue) = 0;
+
 protected:
     virtual ~IDocumentSettingAccess() {};
  };
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx 
b/sw/source/core/doc/DocumentSettingManager.cxx
index e69d50d123e6..afabba5c5215 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -95,7 +95,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc 
&rDoc)
     mbLastBrowseMode( false ),
     mbDisableOffPagePositioning ( false ),
     mbHeaderSpacingBelowLastPara(false),
-    mbGutterAtTop(false)
+    mbGutterAtTop(false),
+    mnImagePreferredDPI(0)
 
     // COMPATIBILITY FLAGS END
 {
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx 
b/sw/source/core/inc/DocumentSettingManager.hxx
index 6b65839259d7..1e34319e56b4 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -166,6 +166,7 @@ class DocumentSettingManager :
     bool mbHeaderSpacingBelowLastPara;
     /// Gutter position: false means left (not a compatibility setting).
     bool mbGutterAtTop;
+    sal_Int32 mnImagePreferredDPI;
 
 public:
 
@@ -186,6 +187,14 @@ public:
     virtual CharCompressType getCharacterCompressionType() const override;
     virtual void setCharacterCompressionType( /*[in]*/CharCompressType nType ) 
override;
 
+    sal_Int32 getImagePreferredDPI() override
+    {
+         return mnImagePreferredDPI;
+    }
+    void setImagePreferredDPI(sal_Int32 nValue) override
+    {
+         mnImagePreferredDPI = nValue;
+    }
 
 // Replace all compatibility options with those from rSource.
     void ReplaceCompatibilityOptions(const DocumentSettingManager& rSource);
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx 
b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index b33be85354f2..458123d88871 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -148,6 +148,7 @@ enum SwDocumentSettingsPropertyHandles
     HANDLE_CONTINUOUS_ENDNOTES,
     HANDLE_HEADER_SPACING_BELOW_LAST_PARA,
     HANDLE_GUTTER_AT_TOP,
+    HANDLE_IMAGE_PREFERRED_DPI,
 };
 
 static MasterPropertySetInfo * lcl_createSettingsInfo()
@@ -237,6 +238,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo()
         { OUString("ContinuousEndnotes"), HANDLE_CONTINUOUS_ENDNOTES, 
cppu::UnoType<bool>::get(), 0 },
         { OUString("HeaderSpacingBelowLastPara"), 
HANDLE_HEADER_SPACING_BELOW_LAST_PARA, cppu::UnoType<bool>::get(), 0 },
         { OUString("GutterAtTop"), HANDLE_GUTTER_AT_TOP, 
cppu::UnoType<bool>::get(), 0 },
+        { OUString("ImagePreferredDPI"), HANDLE_IMAGE_PREFERRED_DPI, 
cppu::UnoType<sal_Int32>::get(), 0 },
 
 /*
  * As OS said, we don't have a view when we need to set this, so I have to
@@ -977,6 +979,16 @@ void SwXDocumentSettings::_setSingleValue( const 
comphelper::PropertyInfo & rInf
             }
         }
         break;
+        case HANDLE_IMAGE_PREFERRED_DPI:
+        {
+            sal_uInt32 nValue = 0;
+            if (rValue >>= nValue)
+            {
+                
mpDoc->getIDocumentSettingAccess().setImagePreferredDPI(nValue);
+            }
+        }
+        break;
+
         default:
             throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
     }
@@ -1460,6 +1472,11 @@ void SwXDocumentSettings::_getSingleValue( const 
comphelper::PropertyInfo & rInf
             rValue <<= 
mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::GUTTER_AT_TOP);
         }
         break;
+        case HANDLE_IMAGE_PREFERRED_DPI:
+        {
+            rValue <<= 
mpDoc->getIDocumentSettingAccess().getImagePreferredDPI();
+        }
+        break;
         default:
             throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
     }
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx 
b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 077a1b5f2968..87e33096ffa5 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -344,8 +344,23 @@ 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)
+        {
+            constexpr double fTwipsInAnInch = 1444.0;
+            auto nWidth = (aSizePixel.Width() / double(nPreferredDPI)) * 
fTwipsInAnInch;
+            auto nHeight = (aSizePixel.Height() / double(nPreferredDPI)) * 
fTwipsInAnInch;
+            aGrfSize = Size(nWidth, nHeight);
+        }
+        else
+        {
+            GetGrfSize(aGrfSize);
+        }
 
         // Add the margin attributes to GrfSize,
         // because these counts at the margin additionally

Reply via email to