cui/source/tabpages/grfpage.cxx  |    7 +++----
 include/sfx2/tabdlg.hxx          |    8 ++++++++
 svx/source/tbxctrls/grafctrl.cxx |    4 ++--
 sw/source/ui/frmdlg/frmdlg.cxx   |    6 +++---
 4 files changed, 16 insertions(+), 9 deletions(-)

New commits:
commit 69fb0fb44d8d60d3bb550f0117f91f64b6194369
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Tue Dec 21 13:07:33 2021 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Tue Dec 21 09:51:14 2021 +0100

    Transfer preferred DPI into SfxTabPage with additional properties
    
    This adds to SfxTabPage a new member maAdditionalProperties, to
    make it easier to transfer additional properties into a tab page.
    This is then used to transfer the preferred DPI into the tab page,
    which was previously done by user data, which is less than ideal
    and always doesn't work.
    
    Change-Id: Ia4daa72093d96310009b0065f8a0e26be6bedec3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127205
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/cui/source/tabpages/grfpage.cxx b/cui/source/tabpages/grfpage.cxx
index b83e0bbc0426..905415f70928 100644
--- a/cui/source/tabpages/grfpage.cxx
+++ b/cui/source/tabpages/grfpage.cxx
@@ -288,10 +288,9 @@ void SvxGrfCropPage::ActivatePage(const SfxItemSet& rSet)
     DBG_ASSERT( pPool, "Where is the pool?" );
 #endif
 
-    if (!GetUserData().isEmpty())
-    {
-        m_aPreferredDPI = GetUserData().toInt32();
-    }
+    auto& aProperties = getAdditionalProperties();
+    if (aProperties.find("PreferredDPI") != aProperties.end())
+        m_aPreferredDPI = aProperties.at("PreferredDPI").get<sal_Int32>();
 
     bSetOrigSize = false;
 
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index 2f9b1c669ef3..2b3de379a627 100644
--- a/include/sfx2/tabdlg.hxx
+++ b/include/sfx2/tabdlg.hxx
@@ -20,6 +20,7 @@
 #define INCLUDED_SFX2_TABDLG_HXX
 
 #include <memory>
+#include <unordered_map>
 #include <string_view>
 
 #include <sal/config.h>
@@ -187,6 +188,8 @@ private:
     const SfxItemSet*   pSet;
     OUString            aUserString;
     bool                bHasExchangeSupport;
+    std::unordered_map<OString, css::uno::Any> maAdditionalProperties;
+
     std::unique_ptr< TabPageImpl >        pImpl;
 
 protected:
@@ -248,6 +251,11 @@ public:
     bool            IsVisible() const { return m_xContainer->get_visible(); }
 
     weld::Window*   GetFrameWeld() const;
+
+    std::unordered_map<OString, css::uno::Any>& getAdditionalProperties()
+    {
+        return maAdditionalProperties;
+    }
 };
 
 #endif
diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx
index 0d1913fb4780..22631d149691 100644
--- a/svx/source/tbxctrls/grafctrl.cxx
+++ b/svx/source/tbxctrls/grafctrl.cxx
@@ -654,8 +654,8 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, 
SdrView& rView )
                     SfxAbstractDialogFactory* pFact = 
SfxAbstractDialogFactory::Create();
                     ::CreateTabPage fnCreatePage = 
pFact->GetTabPageCreatorFunc( RID_SVXPAGE_GRFCROP );
                     std::unique_ptr<SfxTabPage> xTabPage = 
(*fnCreatePage)(aCropDialog.get_content_area(), &aCropDialog, &aCropDlgAttr);
-                    OUString sPreferredDPI = 
OUString::number(rView.getSdrModelFromSdrView().getImagePreferredDPI());
-                    xTabPage->SetUserData(sPreferredDPI);
+                    sal_Int32 nPreferredDPI = 
rView.getSdrModelFromSdrView().getImagePreferredDPI();
+                    
xTabPage->getAdditionalProperties().emplace("PreferredDPI", 
css::uno::makeAny(nPreferredDPI));
                     xTabPage->SetPageTitle(aCropStr);
                     aCropDialog.SetTabPage(std::move(xTabPage));
 
diff --git a/sw/source/ui/frmdlg/frmdlg.cxx b/sw/source/ui/frmdlg/frmdlg.cxx
index fbb27c7d5f94..134785415221 100644
--- a/sw/source/ui/frmdlg/frmdlg.cxx
+++ b/sw/source/ui/frmdlg/frmdlg.cxx
@@ -192,9 +192,9 @@ void SwFrameDlg::PageCreated(const OString& rId, SfxTabPage 
&rPage)
     }
     else if (rId == "crop")
     {
-        sal_Int32 nDPI = 
m_pWrtShell->GetDoc()->getIDocumentSettingAccess().getImagePreferredDPI();
-        if (nDPI)
-            rPage.SetUserData(OUString::number(nDPI));
+        sal_Int32 nPreferredDPI = 
m_pWrtShell->GetDoc()->getIDocumentSettingAccess().getImagePreferredDPI();
+        if (nPreferredDPI)
+            rPage.getAdditionalProperties().emplace("PreferredDPI", 
css::uno::makeAny(nPreferredDPI));
     }
 }
 

Reply via email to