summaryrefslogtreecommitdiff
path: root/sfx2
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 /sfx2
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>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/dialog/dinfdlg.cxx59
-rw-r--r--sfx2/uiconfig/ui/documentinfopage.ui92
2 files changed, 134 insertions, 17 deletions
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>