vcl: Drop SalGenericSystem indirection to show error dlg
So far, SalGenericSystem was implementing
the purely virtual base class method
SalSystem::ShowNativeMessageBox by
providing another purely virtual
ShowNativeDialog method and calling
that one from ShowNativeMessageBox.
Now, after previous commits
Change-Id: Iaf2c803071698911f4834070ad00b9ad325374c9
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Fri Feb 27 22:27:37 2026 +0100
vcl: Drop SalSystem::ShowNativeMessageBox return value
and
Change-Id: I8eb68974f7b89235f54f8600a940295093dc0bb7
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Fri Feb 27 22:41:46 2026 +0100
vcl: Call ImplHideSplash from Application::ShowNativeErrorBox
, this doesn't really add any value.
Therefore, drop SalGenericSystem::ShowNativeMessageBox and
instead override that method directly in the
SalGenericSystem subclasses.
The behavior as described in
Change-Id: Iaf2c803071698911f4834070ad00b9ad325374c9
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Fri Feb 27 22:27:37 2026 +0100
vcl: Drop SalSystem::ShowNativeMessageBox return value
can still be observed the same way.
Change-Id: I9206286d109fbfa8ac1b8cf3c8cea3b016ae7448
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200659
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
@@ -86,9 +86,8 @@ class AndroidSalSystem : public SvpSalSystem {
|
||||
public:
|
||||
AndroidSalSystem() : SvpSalSystem() {}
|
||||
virtual ~AndroidSalSystem() {}
|
||||
virtual int ShowNativeDialog( const OUString& rTitle,
|
||||
const OUString& rMessage,
|
||||
const std::vector< OUString >& rButtons );
|
||||
|
||||
virtual void ShowNativeMessageBox(const OUString& rTitle, const OUString& rMessage) override;
|
||||
};
|
||||
|
||||
SalSystem *AndroidSalInstance::CreateSalSystem()
|
||||
@@ -163,11 +162,8 @@ extern "C" SalInstance *create_SalInstance()
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
int AndroidSalSystem::ShowNativeDialog( const OUString& rTitle,
|
||||
const OUString& rMessage,
|
||||
const std::vector< OUString >& rButtons )
|
||||
void AndroidSalSystem::ShowNativeMessageBox(const OUString& rTitle, const OUString& rMessage)
|
||||
{
|
||||
(void)rButtons;
|
||||
LOGI("LibreOffice native dialog '%s': '%s'",
|
||||
OUStringToOString(rTitle, RTL_TEXTENCODING_ASCII_US).getStr(),
|
||||
OUStringToOString(rMessage, RTL_TEXTENCODING_ASCII_US).getStr());
|
||||
@@ -192,7 +188,6 @@ int AndroidSalSystem::ShowNativeDialog( const OUString& rTitle,
|
||||
}
|
||||
else
|
||||
LOGE("VCL not initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -30,15 +30,13 @@ HeadlessSalInstance::HeadlessSalInstance(std::unique_ptr<SalYieldMutex> pMutex)
|
||||
class HeadlessSalSystem : public SvpSalSystem {
|
||||
public:
|
||||
HeadlessSalSystem() : SvpSalSystem() {}
|
||||
virtual int ShowNativeDialog( const OUString& rTitle,
|
||||
const OUString& rMessage,
|
||||
const std::vector< OUString >& ) override
|
||||
|
||||
virtual void ShowNativeMessageBox(const OUString& rTitle, const OUString& rMessage) override
|
||||
{
|
||||
SAL_INFO("vcl.headless",
|
||||
"LibreOffice - dialog '"
|
||||
<< rTitle << "': '"
|
||||
<< rMessage << "'");
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -47,10 +47,8 @@ AbsoluteScreenPixelRectangle SvpSalSystem::GetDisplayScreenPosSizePixel( unsigne
|
||||
return aRect;
|
||||
}
|
||||
|
||||
int SvpSalSystem::ShowNativeDialog( const OUString&, const OUString&,
|
||||
const std::vector< OUString >& )
|
||||
void SvpSalSystem::ShowNativeMessageBox(const OUString&, const OUString&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -51,9 +51,7 @@ public:
|
||||
virtual unsigned int GetDisplayScreenCount() override;
|
||||
virtual AbsoluteScreenPixelRectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ) override;
|
||||
|
||||
virtual int ShowNativeDialog( const OUString& rTitle,
|
||||
const OUString& rMessage,
|
||||
const std::vector< OUString >& rButtons ) override;
|
||||
virtual void ShowNativeMessageBox(const OUString& rTitle, const OUString& rMessage) override;
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -17,8 +17,7 @@ public:
|
||||
virtual unsigned int GetDisplayScreenCount() override;
|
||||
virtual AbsoluteScreenPixelRectangle
|
||||
GetDisplayScreenPosSizePixel(unsigned int nScreen) override;
|
||||
virtual int ShowNativeDialog(const OUString& rTitle, const OUString& rMessage,
|
||||
const std::vector<OUString>& rButtons) override;
|
||||
virtual void ShowNativeMessageBox(const OUString& rTitle, const OUString& rMessage) override;
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
#include <vcl/dllapi.h>
|
||||
#include <rtl/ustring.hxx>
|
||||
|
||||
// Button identifier for ShowNativeMessageBox
|
||||
const int SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK = 1;
|
||||
|
||||
class VCL_PLUGIN_PUBLIC SalSystem
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -20,21 +20,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <salsys.hxx>
|
||||
#include <vector>
|
||||
|
||||
/*
|
||||
* Helps de-tangle the rather horrible ShowNativeMessageBox API
|
||||
*/
|
||||
class VCL_DLLPUBLIC SalGenericSystem : public SalSystem
|
||||
{
|
||||
public:
|
||||
SalGenericSystem();
|
||||
virtual ~SalGenericSystem() override;
|
||||
virtual int ShowNativeDialog( const OUString& rTitle,
|
||||
const OUString& rMessage,
|
||||
const std::vector< OUString >& rButtons ) = 0;
|
||||
|
||||
virtual void ShowNativeMessageBox(const OUString& rTitle, const OUString& rMessage) override;
|
||||
|
||||
#if !defined(ANDROID) && !defined(IOS)
|
||||
// Simple helpers for X11 WM_CLASS hints
|
||||
|
||||
@@ -29,9 +29,7 @@ public:
|
||||
virtual unsigned int GetDisplayScreenCount() override;
|
||||
virtual unsigned int GetDisplayBuiltInScreen() override;
|
||||
virtual AbsoluteScreenPixelRectangle GetDisplayScreenPosSizePixel(unsigned int nScreen) override;
|
||||
virtual int ShowNativeDialog (const OUString& rTitle,
|
||||
const OUString& rMessage,
|
||||
const std::vector< OUString >& rButtons) override;
|
||||
virtual void ShowNativeMessageBox(const OUString& rTitle, const OUString& rMessage) override;
|
||||
SalX11Screen GetDisplayDefaultXScreen()
|
||||
{ return getXScreenFromDisplayScreen( GetDisplayBuiltInScreen() ); }
|
||||
SalX11Screen getXScreenFromDisplayScreen(unsigned int nDisplayScreen);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <unx/gensys.h>
|
||||
#include <vector>
|
||||
|
||||
class X11SalSystem final : public SalGenericSystem
|
||||
{
|
||||
@@ -31,9 +32,7 @@ public:
|
||||
virtual unsigned int GetDisplayScreenCount() override;
|
||||
virtual unsigned int GetDisplayBuiltInScreen() override;
|
||||
virtual AbsoluteScreenPixelRectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ) override;
|
||||
virtual int ShowNativeDialog( const OUString& rTitle,
|
||||
const OUString& rMessage,
|
||||
const std::vector< OUString >& rButtons ) override;
|
||||
virtual void ShowNativeMessageBox(const OUString& rTitle, const OUString& rMessage) override;
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
+2
-8
@@ -59,9 +59,7 @@ class IosSalSystem : public SvpSalSystem {
|
||||
public:
|
||||
IosSalSystem() : SvpSalSystem() {}
|
||||
virtual ~IosSalSystem() {}
|
||||
virtual int ShowNativeDialog( const OUString& rTitle,
|
||||
const OUString& rMessage,
|
||||
const std::vector< OUString >& rButtons );
|
||||
virtual void ShowNativeMessageBox(const OUString& rTitle, const OUString& rMessage) override;
|
||||
};
|
||||
|
||||
SalSystem *IosSalInstance::CreateSalSystem()
|
||||
@@ -148,12 +146,8 @@ extern "C" SalInstance *create_SalInstance()
|
||||
return new IosSalInstance(std::make_unique<SvpSalYieldMutex>());
|
||||
}
|
||||
|
||||
int IosSalSystem::ShowNativeDialog( const OUString& rTitle,
|
||||
const OUString& rMessage,
|
||||
const std::vector< OUString >& rButtons )
|
||||
void IosSalSystem::ShowNativeMessageBox(const OUString& rTitle, const OUString& rMessage)
|
||||
{
|
||||
(void)rButtons;
|
||||
|
||||
NSLog(@"%@: %@", [CreateNSString(rTitle) autorelease], [CreateNSString(rMessage) autorelease]);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -22,9 +22,6 @@ AbsoluteScreenPixelRectangle QtSystem::GetDisplayScreenPosSizePixel(unsigned int
|
||||
return AbsoluteScreenPixelRectangle(toRectangle(scaledQRect(qRect, qApp->devicePixelRatio())));
|
||||
}
|
||||
|
||||
int QtSystem::ShowNativeDialog(const OUString&, const OUString&, const std::vector<OUString>&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
void QtSystem::ShowNativeMessageBox(const OUString&, const OUString&) {}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
|
||||
@@ -37,14 +37,6 @@ SalGenericSystem::~SalGenericSystem()
|
||||
{
|
||||
}
|
||||
|
||||
void SalGenericSystem::ShowNativeMessageBox(const OUString& rTitle, const OUString& rMessage)
|
||||
{
|
||||
std::vector< OUString > aButtons;
|
||||
|
||||
aButtons.push_back( u"OK"_ustr );
|
||||
ShowNativeDialog(rTitle, rMessage, aButtons);
|
||||
}
|
||||
|
||||
#if !defined(ANDROID) && !defined(IOS)
|
||||
|
||||
// X11-specific
|
||||
|
||||
+4
-11
@@ -297,8 +297,7 @@ gint gtk_dialog_run(GtkDialog* pDialog)
|
||||
|
||||
#endif
|
||||
|
||||
int GtkSalSystem::ShowNativeDialog (const OUString& rTitle, const OUString& rMessage,
|
||||
const std::vector< OUString >& rButtonNames)
|
||||
void GtkSalSystem::ShowNativeMessageBox(const OUString& rTitle, const OUString& rMessage)
|
||||
{
|
||||
OString aTitle (OUStringToOString (rTitle, RTL_TEXTENCODING_UTF8));
|
||||
OString aMessage (OUStringToOString (rMessage, RTL_TEXTENCODING_UTF8));
|
||||
@@ -309,22 +308,16 @@ int GtkSalSystem::ShowNativeDialog (const OUString& rTitle, const OUString& rMes
|
||||
"message-type", int(GTK_MESSAGE_WARNING),
|
||||
"text", aMessage.getStr(),
|
||||
nullptr));
|
||||
int nButton = 0;
|
||||
for (auto const& buttonName : rButtonNames)
|
||||
gtk_dialog_add_button (pDialog, MapToGtkAccelerator(buttonName).getStr(), nButton++);
|
||||
gtk_dialog_set_default_response (pDialog, 0/*nDefaultButton*/);
|
||||
gtk_dialog_add_button (pDialog, MapToGtkAccelerator(u"OK"_ustr).getStr(), 0);
|
||||
gtk_dialog_set_default_response (pDialog, 0);
|
||||
|
||||
nButton = gtk_dialog_run (pDialog);
|
||||
if (nButton < 0)
|
||||
nButton = -1;
|
||||
gtk_dialog_run (pDialog);
|
||||
|
||||
#if !GTK_CHECK_VERSION(4, 0, 0)
|
||||
gtk_widget_destroy(GTK_WIDGET(pDialog));
|
||||
#else
|
||||
gtk_window_destroy(GTK_WINDOW(pDialog));
|
||||
#endif
|
||||
|
||||
return nButton;
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -77,7 +77,7 @@ AbsoluteScreenPixelRectangle X11SalSystem::GetDisplayScreenPosSizePixel( unsigne
|
||||
return aRet;
|
||||
}
|
||||
|
||||
int X11SalSystem::ShowNativeDialog( const OUString& rTitle, const OUString& rMessage, const std::vector< OUString >& rButtons )
|
||||
void X11SalSystem::ShowNativeMessageBox(const OUString& rTitle, const OUString& rMessage)
|
||||
{
|
||||
ImplSVData* pSVData = ImplGetSVData();
|
||||
if( pSVData->mpIntroWindow )
|
||||
@@ -88,12 +88,10 @@ int X11SalSystem::ShowNativeDialog( const OUString& rTitle, const OUString& rMes
|
||||
rMessage));
|
||||
xWarn->set_title(rTitle);
|
||||
|
||||
sal_uInt16 nButton = 0;
|
||||
for (auto const& button : rButtons)
|
||||
xWarn->add_button(button, nButton++);
|
||||
xWarn->add_button(u"OK"_ustr, 0);
|
||||
xWarn->set_default_response(0);
|
||||
|
||||
return xWarn->run();
|
||||
xWarn->run();
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
Reference in New Issue
Block a user