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 | 40 ++- sfx2/source/dialog/dinfdlg.cxx | 59 ++++ sfx2/uiconfig/ui/documentinfopage.ui | 324 +++++++++++++++----------- 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, 380 insertions(+), 145 deletions(-)
New commits: commit bfd5a99e775e94531e67d5cda97740e18d907019 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Dec 3 20:52:12 2021 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Jan 5 10:04:19 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/+/127238 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 521434236cea..bea521a535fc 100644 --- a/include/sfx2/dinfdlg.hxx +++ b/include/sfx2/dinfdlg.hxx @@ -183,10 +183,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 210811968e97..dfceb3b9c165 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/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 9a71377ff116..982ed0d5c62a 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 be95822d89ba..ce6afe10c37c 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -174,6 +174,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 5e06f7b1afb2..bcb10093d3e1 100644 --- a/sc/source/ui/unoobj/confuno.cxx +++ b/sc/source/ui/unoobj/confuno.cxx @@ -88,6 +88,7 @@ static const SfxItemPropertyMapEntry* lcl_GetConfigPropertyMap() {u"" SC_UNO_EMBED_FONT_SCRIPT_LATIN, 0, cppu::UnoType<bool>::get(), 0, 0}, {u"" SC_UNO_EMBED_FONT_SCRIPT_ASIAN, 0, cppu::UnoType<bool>::get(), 0, 0}, {u"" SC_UNO_EMBED_FONT_SCRIPT_COMPLEX, 0, cppu::UnoType<bool>::get(), 0, 0}, + {u"" SC_UNO_IMAGE_PREFERRED_DPI, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, {u"" SC_UNO_SYNTAXSTRINGREF, 0, cppu::UnoType<sal_Int16>::get(), 0, 0}, { u"", 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 2d05e269ff58..8b65b4d18870 100644 --- a/sd/inc/drawdoc.hxx +++ b/sd/inc/drawdoc.hxx @@ -186,6 +186,8 @@ private: bool mbEmbedFontScriptAsian : 1; bool mbEmbedFontScriptComplex : 1; + sal_Int32 mnImagePreferredDPI; + SAL_DLLPRIVATE virtual css::uno::Reference< css::uno::XInterface > createUnoModel() override; public: @@ -612,6 +614,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 69f746150d64..237197cf7754 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -136,6 +136,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 f7265afc3844..04dec50a1109 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 } }; @@ -1027,6 +1029,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)); } @@ -1301,6 +1315,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 882258bd9231..b826254179c4 100644 --- a/sd/source/ui/view/sdview4.cxx +++ b/sd/source/ui/view/sdview4.cxx @@ -61,6 +61,7 @@ #include <svtools/soerr.hxx> #include <sfx2/ipclient.hxx> #include <tools/debug.hxx> +#include <tools/UnitConversion.hxx> using namespace com::sun::star; @@ -170,6 +171,8 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction, else if ( pPV ) { + Size aSizePixel = rGraphic.GetSizePixel(); + // create new object Size aSize; @@ -192,15 +195,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 6a7bd27aafaf..288db7e94824 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -53,6 +53,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> @@ -704,6 +705,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()); @@ -716,6 +719,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 @@ -756,6 +760,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(); @@ -906,6 +916,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; } @@ -1060,6 +1090,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 860b6e1c3348..6996793e7ff1 100644 --- a/sfx2/uiconfig/ui/documentinfopage.ui +++ b/sfx2/uiconfig/ui/documentinfopage.ui @@ -1,192 +1,192 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.36.0 --> +<!-- Generated with glade 3.38.2 --> <interface domain="sfx"> <requires lib="gtk+" version="3.20"/> - <!-- n-columns=1 n-rows=1 --> + <!-- 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> <child internal-child="accessible"> <object class="AtkObject" id="userdatacb-atkobject"> <property name="AtkObject::accessible-description" translatable="yes" context="documentinfopage|extended_tip|userdatacb">Saves the user's full name with the file. You can edit the name by choosing Tools - Options - %PRODUCTNAME - User Data.</property> @@ -194,32 +194,32 @@ </child> </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> <child internal-child="accessible"> <object class="AtkObject" id="reset-atkobject"> @@ -228,8 +228,8 @@ </child> </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> @@ -237,170 +237,170 @@ <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=1 n-rows=1 --> + <!-- n-columns=2 n-rows=1 --> <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="icon-name">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> <child internal-child="accessible"> <object class="AtkObject" id="nameed-atkobject"> <property name="AtkObject::accessible-description" translatable="yes" context="documentinfopage|extended_tip|nameed">Displays the file name.</property> @@ -408,16 +408,78 @@ </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">0</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">0</property> </packing> </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="spacing">12</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="xalign">0</property> + <property name="draw-indicator">True</property> + <accessibility> + <relation type="label-for" target="image-preferred-dpi-combobox"/> + </accessibility> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</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">13</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> <child> <placeholder/> </child> diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx index 059694ff1ceb..14a828de5e08 100644 --- a/sw/inc/IDocumentSettingAccess.hxx +++ b/sw/inc/IDocumentSettingAccess.hxx @@ -251,6 +251,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 9b8b19f71e7f..2006d9aeb0a5 100644 --- a/sw/source/core/doc/DocumentSettingManager.cxx +++ b/sw/source/core/doc/DocumentSettingManager.cxx @@ -100,7 +100,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc) mbProtectFields(false), mbHeaderSpacingBelowLastPara(false), mbFrameAutowidthWithMorePara(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 88877b26458d..e78f0fc20405 100644 --- a/sw/source/core/inc/DocumentSettingManager.hxx +++ b/sw/source/core/inc/DocumentSettingManager.hxx @@ -170,6 +170,7 @@ class DocumentSettingManager : bool mbFrameAutowidthWithMorePara; //tdf#124423 /// Gutter position: false means left (not a compatibility setting). bool mbGutterAtTop; + sal_Int32 mnImagePreferredDPI; public: @@ -190,6 +191,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 2643071e13dd..5ba5293a5031 100644 --- a/sw/source/uibase/uno/SwXDocumentSettings.cxx +++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx @@ -147,6 +147,7 @@ enum SwDocumentSettingsPropertyHandles HANDLE_HEADER_SPACING_BELOW_LAST_PARA, HANDLE_FRAME_AUTOWIDTH_WITH_MORE_PARA, HANDLE_GUTTER_AT_TOP, + HANDLE_IMAGE_PREFERRED_DPI, }; } @@ -241,6 +242,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo() { OUString("HeaderSpacingBelowLastPara"), HANDLE_HEADER_SPACING_BELOW_LAST_PARA, cppu::UnoType<bool>::get(), 0 }, { 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("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 @@ -1007,6 +1009,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)); } @@ -1508,6 +1520,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 5e888e2c2ef6..f6c5cbd195c1 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -301,8 +301,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