include/vcl/weld/Dialog.hxx   |    3 +++
 vcl/source/app/salvtables.cxx |   17 +----------------
 vcl/source/weld/Dialog.cxx    |   11 +++++++++++
 vcl/unx/gtk3/gtkinst.cxx      |    9 +--------
 4 files changed, 16 insertions(+), 24 deletions(-)

New commits:
commit 56ff11ab862d94d36ff575e0ab199f94155af55a
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Feb 12 17:42:21 2026 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Feb 12 22:00:23 2026 +0100

    tdf#130857 weld: Deduplicate logic to run screenshot annotation dialog
    
    Introduce weld::Dialog::executeScreenshotAnnotationDialog
    to implement the logic to run the screenshot annotation
    dialog in the base class, instead of in each of the subclasses
    separately (GtkInstanceDialog and SalInstanceDialog for now,
    QtInstanceDialog in the future as well).
    
    Replace a check by an assert as the dialog should always be
    created.
    
    Description of how the dialog can be triggered [1]:
    
    > To create dialog screenshots from running LibreOffice, you need to
    > activate screenshotting mode (akin to experimental mode) in Tools ▸
    > Options ▸ Advanced ▸ Open Expert Configuration, the relevant
    > configuration key is org.openoffice.Office.Common.Misc.ScreenshotMode.
    > Once screenshotting mode is active, right mouse click into any dialog
    > action area (where "OK", "Cancel" etc. buttons are) will make a context
    > menu appear:
    >
    > Click Screenshot item of the context menu to create screenshot of the
    > current dialog.
    
    [1] 
https://wiki.documentfoundation.org/Documentation/Screenshots#Creating_screenshots_manually
    
    Change-Id: I7c37a365c68acf8ad7c36148014d9a6c5f153b6d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199296
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/include/vcl/weld/Dialog.hxx b/include/vcl/weld/Dialog.hxx
index 1f3be2898a6b..4fb2187fb8ac 100644
--- a/include/vcl/weld/Dialog.hxx
+++ b/include/vcl/weld/Dialog.hxx
@@ -22,6 +22,9 @@ private:
                           const std::function<void(sal_Int32)>& func)
         = 0;
 
+protected:
+    void executeScreenshotAnnotationDialog();
+
 public:
     virtual void set_modal(bool bModal) = 0;
     virtual bool get_modal() const = 0;
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 474c9d2b8e7b..3f446a776659 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -50,7 +50,6 @@
 #include <unotools/fontdefs.hxx>
 #include <utility>
 #include <tools/helpers.hxx>
-#include <vcl/abstdlg.hxx>
 #include <vcl/builder.hxx>
 #include <vcl/dndlistenercontainer.hxx>
 #include <vcl/toolkit/combobox.hxx>
@@ -1990,21 +1989,7 @@ IMPL_LINK(SalInstanceDialog, PopupScreenShotMenuHdl, 
const CommandEvent&, rCEvt,
 
         // 0 == no selection (so not usable as ID)
         if (0 != nId)
-        {
-            // open screenshot annotation dialog
-            VclAbstractDialogFactory* pFact = 
VclAbstractDialogFactory::Create();
-            VclPtr<AbstractScreenshotAnnotationDlg> pTmp
-                = pFact->CreateScreenshotAnnotationDlg(*this);
-            ScopedVclPtr<AbstractScreenshotAnnotationDlg> pDialog(pTmp);
-
-            if (pDialog)
-            {
-                // currently just execute the dialog, no need to do
-                // different things for ok/cancel. This may change later,
-                // for that case use 'if (pDlg->Execute() == RET_OK)'
-                pDialog->Execute();
-            }
-        }
+            executeScreenshotAnnotationDialog();
 
         // consume event when:
         // - CommandEventId::ContextMenu
diff --git a/vcl/source/weld/Dialog.cxx b/vcl/source/weld/Dialog.cxx
index 18740cff9ab3..4272eb4f79f4 100644
--- a/vcl/source/weld/Dialog.cxx
+++ b/vcl/source/weld/Dialog.cxx
@@ -7,10 +7,21 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <vcl/abstdlg.hxx>
 #include <vcl/weld/Dialog.hxx>
 
 namespace weld
 {
+void Dialog::executeScreenshotAnnotationDialog()
+{
+    // open screenshot annotation dialog
+    VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
+    ScopedVclPtr<AbstractScreenshotAnnotationDlg> pDialog
+        = pFact->CreateScreenshotAnnotationDlg(*this);
+    assert(pDialog);
+    pDialog->Execute();
+}
+
 void Dialog::set_default_response(int nResponse)
 {
     std::unique_ptr<weld::Button> pButton = 
weld_button_for_response(nResponse);
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index ad50d36ba4e9..4d55047104e6 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -105,7 +105,6 @@
 #include <unotools/tempfile.hxx>
 #include <unx/gstsink.hxx>
 #include <vcl/ImageTree.hxx>
-#include <vcl/abstdlg.hxx>
 #include <vcl/event.hxx>
 #include <vcl/i18nhelp.hxx>
 #include <vcl/quickselectionengine.hxx>
@@ -7042,13 +7041,7 @@ private:
         gtk_menu_detach(GTK_MENU(pMenu));
 
         if (bActivate)
-        {
-            // open screenshot annotation dialog
-            VclAbstractDialogFactory* pFact = 
VclAbstractDialogFactory::Create();
-            VclPtr<AbstractScreenshotAnnotationDlg> xTmp = 
pFact->CreateScreenshotAnnotationDlg(*this);
-            ScopedVclPtr<AbstractScreenshotAnnotationDlg> xDialog(xTmp);
-            xDialog->Execute();
-        }
+            executeScreenshotAnnotationDialog();
 
         return false;
     }

Reply via email to