summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-12-03 20:52:12 +0100
committerAndras Timar <andras.timar@collabora.com>2022-02-14 11:25:41 +0100
commit3b268a9eba49947316fc4591c5ec19926f09299e (patch)
treebfc9a3d09df7ff6c60d84ad6068a8565296d6fdf
parent50c09500ad3cc78145a21dcfcd225a6aa0b21a1b (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>
-rw-r--r--include/sfx2/dinfdlg.hxx4
-rw-r--r--sc/inc/document.hxx5
-rw-r--r--sd/inc/drawdoc.hxx5
-rw-r--r--sd/source/core/drawdoc.cxx1
-rw-r--r--sd/source/ui/unoidl/UnoDocumentSettings.cxx20
-rw-r--r--sd/source/ui/view/sdview4.cxx35
-rw-r--r--sfx2/source/dialog/dinfdlg.cxx59
-rw-r--r--sfx2/uiconfig/ui/documentinfopage.ui92
-rw-r--r--sw/inc/IDocumentSettingAccess.hxx3
-rw-r--r--sw/source/core/doc/DocumentSettingManager.cxx8
-rw-r--r--sw/source/core/inc/DocumentSettingManager.hxx9
-rw-r--r--sw/source/uibase/uno/SwXDocumentSettings.cxx16
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx18
13 files changed, 246 insertions, 29 deletions
diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx
index 6301a99435fc..40cbd82c7762 100644
--- a/include/sfx2/dinfdlg.hxx
+++ b/include/sfx2/dinfdlg.hxx
@@ -185,10 +185,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::Toggleable&, void);
+
void ImplUpdateSignatures();
void ImplCheckPasswordState();
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index fec085a32733..4932c3a0ec3e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -557,6 +557,8 @@ private:
bool mbEmbedFontScriptAsian : 1;
bool mbEmbedFontScriptComplex : 1;
+ sal_Int32 mnImagenPreferredDPI;
+
std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap;
bool mbTrackFormulasPending : 1;
@@ -582,6 +584,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/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx
index 80a79955537f..aaed07cae960 100644
--- a/sd/inc/drawdoc.hxx
+++ b/sd/inc/drawdoc.hxx
@@ -187,6 +187,8 @@ private:
bool mbEmbedFontScriptAsian : 1;
bool mbEmbedFontScriptComplex : 1;
+ sal_Int32 mnImagePreferredDPI;
+
SAL_DLLPRIVATE virtual css::uno::Reference< css::uno::XInterface > createUnoModel() override;
public:
@@ -614,6 +616,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 0fea961a6902..953afd909302 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -137,6 +137,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 ec168b7e42d6..2515ea32eecc 100644
--- a/sd/source/ui/unoidl/UnoDocumentSettings.cxx
+++ b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
@@ -148,6 +148,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
};
}
@@ -218,6 +219,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 }
};
@@ -1032,6 +1034,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));
}
@@ -1306,6 +1320,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 34b1bf322d50..80a653b7b9c8 100644
--- a/sd/source/ui/view/sdview4.cxx
+++ b/sd/source/ui/view/sdview4.cxx
@@ -172,6 +172,8 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
else if ( pPV )
{
+ Size aSizePixel = rGraphic.GetSizePixel();
+
// create new object
Size aSize;
@@ -194,15 +196,30 @@ 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)
+ {
+ auto nWidth = o3tl::convert(aSizePixel.Width() / double(nPreferredDPI), o3tl::Length::in, o3tl::Length::mm100);
+ auto nHeight = o3tl::convert(aSizePixel.Height() / double(nPreferredDPI), o3tl::Length::in, o3tl::Length::mm100);
+ 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 04d70eadc0b8..2a32e9c03dc9 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>
@@ -691,6 +692,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());
@@ -703,6 +706,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
@@ -743,6 +747,12 @@ IMPL_LINK_NOARG(SfxDocumentPage, SignatureHdl, weld::Button&, void)
}
}
+IMPL_LINK_NOARG(SfxDocumentPage, ImagePreferredDPICheckBoxClicked, weld::Toggleable&, 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();
@@ -893,6 +903,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;
}
@@ -1053,6 +1083,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 49a4f8ab1c07..3ea5798caa45 100644
--- a/sfx2/uiconfig/ui/documentinfopage.ui
+++ b/sfx2/uiconfig/ui/documentinfopage.ui
@@ -2,7 +2,7 @@
<!-- Generated with glade 3.38.2 -->
<interface domain="sfx">
<requires lib="gtk+" version="3.20"/>
- <!-- n-columns=3 n-rows=13 -->
+ <!-- n-columns=3 n-rows=14 -->
<object class="GtkGrid" id="DocumentInfoPage">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -198,21 +198,6 @@
</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="draw-indicator">True</property>
- </object>
- <packing>
- <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>
@@ -228,7 +213,6 @@
<packing>
<property name="left-attach">2</property>
<property name="top-attach">11</property>
- <property name="height">2</property>
</packing>
</child>
<child>
@@ -413,6 +397,79 @@
</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="draw-indicator">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">12</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>
+ <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">13</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<placeholder/>
</child>
<child>
@@ -427,4 +484,5 @@
</object>
</child>
</object>
+ <object class="GtkAction" id="action1"/>
</interface>
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index d20130dbd3e5..11bef9d2729d 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -255,6 +255,9 @@ public:
*/
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 2776422caf8e..d47360022eee 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -103,7 +103,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
mbHeaderSpacingBelowLastPara(false),
mbFrameAutowidthWithMorePara(false),
mbGutterAtTop(false),
- mbFootnoteInColumnToPageEnd(false)
+ mbFootnoteInColumnToPageEnd(false),
+ mnImagePreferredDPI(0)
// COMPATIBILITY FLAGS END
{
@@ -1007,6 +1008,11 @@ void sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const
(void)xmlTextWriterStartElement(pWriter, BAD_CAST("mbFootnoteInColumnToPageEnd"));
(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
BAD_CAST(OString::boolean(mbFootnoteInColumnToPageEnd).getStr()));
+
+ (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mnImagePreferredDPI"));
+ (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
+ BAD_CAST(OString::number(mnImagePreferredDPI).getStr()));
+
(void)xmlTextWriterEndElement(pWriter);
(void)xmlTextWriterEndElement(pWriter);
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx
index d5604f25490c..8109e3f5a916 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -172,6 +172,7 @@ class DocumentSettingManager final :
/// Gutter position: false means left (not a compatibility setting).
bool mbGutterAtTop;
bool mbFootnoteInColumnToPageEnd;
+ sal_Int32 mnImagePreferredDPI;
public:
@@ -192,6 +193,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 881ac1540239..bc6051bd576c 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -150,6 +150,7 @@ enum SwDocumentSettingsPropertyHandles
HANDLE_FRAME_AUTOWIDTH_WITH_MORE_PARA,
HANDLE_GUTTER_AT_TOP,
HANDLE_FOOTNOTE_IN_COLUMN_TO_PAGEEND,
+ HANDLE_IMAGE_PREFERRED_DPI,
};
}
@@ -246,6 +247,7 @@ static rtl::Reference<MasterPropertySetInfo> lcl_createSettingsInfo()
{ OUString("FrameAutowidthWithMorePara"), HANDLE_FRAME_AUTOWIDTH_WITH_MORE_PARA, cppu::UnoType<bool>::get(), 0 },
{ OUString("GutterAtTop"), HANDLE_GUTTER_AT_TOP, cppu::UnoType<bool>::get(), 0 },
{ OUString("FootnoteInColumnToPageEnd"), HANDLE_FOOTNOTE_IN_COLUMN_TO_PAGEEND, 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
@@ -1028,6 +1030,15 @@ 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));
}
@@ -1540,6 +1551,11 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
DocumentSettingId::FOOTNOTE_IN_COLUMN_TO_PAGEEND);
}
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 c6dee2be2ec6..79a9096a1b9c 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -333,8 +333,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