Kaydet (Commit) e3ee0653 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Various loplugin in --enable-gtk3-kde5 code

Change-Id: Ic12464f01950a5037bb6819a2722aba5a7e3e2e6
üst 862d2fc5
...@@ -80,13 +80,7 @@ inline void readIpcArg(std::istream& stream, Commands& value) ...@@ -80,13 +80,7 @@ inline void readIpcArg(std::istream& stream, Commands& value)
value = static_cast<Commands>(v); value = static_cast<Commands>(v);
} }
inline void readIpcArg(std::istream& stream, sal_Bool& value) void readIpcArg(std::istream&, sal_Bool) = delete;
{
bool v = false;
stream >> v;
value = v;
stream.ignore(); // skip space
}
inline void readIpcArg(std::istream& stream, bool& value) inline void readIpcArg(std::istream& stream, bool& value)
{ {
...@@ -133,10 +127,7 @@ inline void sendIpcArg(std::ostream& stream, Commands value) ...@@ -133,10 +127,7 @@ inline void sendIpcArg(std::ostream& stream, Commands value)
stream << static_cast<uint16_t>(value) << ' '; stream << static_cast<uint16_t>(value) << ' ';
} }
inline void sendIpcArg(std::ostream& stream, sal_Bool value) void sendIpcArg(std::ostream&, sal_Bool) = delete;
{
stream << static_cast<bool>(value) << ' ';
}
inline void sendIpcArg(std::ostream& stream, bool value) { stream << value << ' '; } inline void sendIpcArg(std::ostream& stream, bool value) { stream << value << ' '; }
......
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
#undef Region #undef Region
#include "unx/geninst.h" #include <unx/geninst.h>
#include "strings.hrc" #include <strings.hrc>
#include <future> #include <future>
...@@ -64,7 +64,7 @@ namespace bf = boost::filesystem; ...@@ -64,7 +64,7 @@ namespace bf = boost::filesystem;
namespace namespace
{ {
uno::Sequence<OUString> SAL_CALL FilePicker_getSupportedServiceNames() uno::Sequence<OUString> FilePicker_getSupportedServiceNames()
{ {
uno::Sequence<OUString> aRet(3); uno::Sequence<OUString> aRet(3);
aRet[0] = "com.sun.star.ui.dialogs.FilePicker"; aRet[0] = "com.sun.star.ui.dialogs.FilePicker";
...@@ -107,7 +107,7 @@ sal_Int16 SAL_CALL Gtk3KDE5FilePicker::execute() { return m_ipc.execute(); } ...@@ -107,7 +107,7 @@ sal_Int16 SAL_CALL Gtk3KDE5FilePicker::execute() { return m_ipc.execute(); }
void SAL_CALL Gtk3KDE5FilePicker::setMultiSelectionMode(sal_Bool multiSelect) void SAL_CALL Gtk3KDE5FilePicker::setMultiSelectionMode(sal_Bool multiSelect)
{ {
m_ipc.sendCommand(Commands::SetMultiSelectionMode, multiSelect); m_ipc.sendCommand(Commands::SetMultiSelectionMode, bool(multiSelect));
} }
void SAL_CALL Gtk3KDE5FilePicker::setDefaultName(const OUString& name) void SAL_CALL Gtk3KDE5FilePicker::setDefaultName(const OUString& name)
...@@ -176,9 +176,9 @@ void SAL_CALL Gtk3KDE5FilePicker::appendFilterGroup(const OUString& /*rGroupTitl ...@@ -176,9 +176,9 @@ void SAL_CALL Gtk3KDE5FilePicker::appendFilterGroup(const OUString& /*rGroupTitl
void SAL_CALL Gtk3KDE5FilePicker::setValue(sal_Int16 controlId, sal_Int16 nControlAction, void SAL_CALL Gtk3KDE5FilePicker::setValue(sal_Int16 controlId, sal_Int16 nControlAction,
const uno::Any& value) const uno::Any& value)
{ {
if (value.has<sal_Bool>()) if (value.has<bool>())
{ {
m_ipc.sendCommand(Commands::SetValue, controlId, nControlAction, value.get<sal_Bool>()); m_ipc.sendCommand(Commands::SetValue, controlId, nControlAction, value.get<bool>());
} }
else else
{ {
...@@ -198,7 +198,7 @@ uno::Any SAL_CALL Gtk3KDE5FilePicker::getValue(sal_Int16 controlId, sal_Int16 nC ...@@ -198,7 +198,7 @@ uno::Any SAL_CALL Gtk3KDE5FilePicker::getValue(sal_Int16 controlId, sal_Int16 nC
auto id = m_ipc.sendCommand(Commands::GetValue, controlId, nControlAction); auto id = m_ipc.sendCommand(Commands::GetValue, controlId, nControlAction);
sal_Bool value = false; bool value = false;
m_ipc.readResponse(id, value); m_ipc.readResponse(id, value);
return uno::Any(value); return uno::Any(value);
...@@ -206,7 +206,7 @@ uno::Any SAL_CALL Gtk3KDE5FilePicker::getValue(sal_Int16 controlId, sal_Int16 nC ...@@ -206,7 +206,7 @@ uno::Any SAL_CALL Gtk3KDE5FilePicker::getValue(sal_Int16 controlId, sal_Int16 nC
void SAL_CALL Gtk3KDE5FilePicker::enableControl(sal_Int16 controlId, sal_Bool enable) void SAL_CALL Gtk3KDE5FilePicker::enableControl(sal_Int16 controlId, sal_Bool enable)
{ {
m_ipc.sendCommand(Commands::EnableControl, controlId, enable); m_ipc.sendCommand(Commands::EnableControl, controlId, bool(enable));
} }
void SAL_CALL Gtk3KDE5FilePicker::setLabel(sal_Int16 controlId, const OUString& label) void SAL_CALL Gtk3KDE5FilePicker::setLabel(sal_Int16 controlId, const OUString& label)
...@@ -284,7 +284,7 @@ void Gtk3KDE5FilePicker::addCustomControl(sal_Int16 controlId) ...@@ -284,7 +284,7 @@ void Gtk3KDE5FilePicker::addCustomControl(sal_Int16 controlId)
{ {
// the checkbox is created even for CHECKBOX_AUTOEXTENSION to simplify // the checkbox is created even for CHECKBOX_AUTOEXTENSION to simplify
// code, but the checkbox is hidden and ignored // code, but the checkbox is hidden and ignored
sal_Bool hidden = controlId == CHECKBOX_AUTOEXTENSION; bool hidden = controlId == CHECKBOX_AUTOEXTENSION;
m_ipc.sendCommand(Commands::AddCheckBox, controlId, hidden, getResString(resId)); m_ipc.sendCommand(Commands::AddCheckBox, controlId, hidden, getResString(resId));
...@@ -308,8 +308,7 @@ void SAL_CALL Gtk3KDE5FilePicker::initialize(const uno::Sequence<uno::Any>& args ...@@ -308,8 +308,7 @@ void SAL_CALL Gtk3KDE5FilePicker::initialize(const uno::Sequence<uno::Any>& args
uno::Any arg; uno::Any arg;
if (args.getLength() == 0) if (args.getLength() == 0)
{ {
throw lang::IllegalArgumentException(OUString("no arguments"), throw lang::IllegalArgumentException("no arguments", static_cast<XFilePicker2*>(this), 1);
static_cast<XFilePicker2*>(this), 1);
} }
arg = args[0]; arg = args[0];
...@@ -317,14 +316,14 @@ void SAL_CALL Gtk3KDE5FilePicker::initialize(const uno::Sequence<uno::Any>& args ...@@ -317,14 +316,14 @@ void SAL_CALL Gtk3KDE5FilePicker::initialize(const uno::Sequence<uno::Any>& args
if ((arg.getValueType() != cppu::UnoType<sal_Int16>::get()) if ((arg.getValueType() != cppu::UnoType<sal_Int16>::get())
&& (arg.getValueType() != cppu::UnoType<sal_Int8>::get())) && (arg.getValueType() != cppu::UnoType<sal_Int8>::get()))
{ {
throw lang::IllegalArgumentException(OUString("invalid argument type"), throw lang::IllegalArgumentException("invalid argument type",
static_cast<XFilePicker2*>(this), 1); static_cast<XFilePicker2*>(this), 1);
} }
sal_Int16 templateId = -1; sal_Int16 templateId = -1;
arg >>= templateId; arg >>= templateId;
sal_Bool saveDialog = false; bool saveDialog = false;
switch (templateId) switch (templateId)
{ {
case FILEOPEN_SIMPLE: case FILEOPEN_SIMPLE:
...@@ -411,7 +410,7 @@ void SAL_CALL Gtk3KDE5FilePicker::cancel() ...@@ -411,7 +410,7 @@ void SAL_CALL Gtk3KDE5FilePicker::cancel()
// TODO // TODO
} }
void SAL_CALL Gtk3KDE5FilePicker::disposing(const lang::EventObject& rEvent) void Gtk3KDE5FilePicker::disposing(const lang::EventObject& rEvent)
{ {
uno::Reference<XFilePickerListener> xFilePickerListener(rEvent.Source, uno::UNO_QUERY); uno::Reference<XFilePickerListener> xFilePickerListener(rEvent.Source, uno::UNO_QUERY);
......
...@@ -56,7 +56,7 @@ protected: ...@@ -56,7 +56,7 @@ protected:
public: public:
explicit Gtk3KDE5FilePicker(const css::uno::Reference<css::uno::XComponentContext>&); explicit Gtk3KDE5FilePicker(const css::uno::Reference<css::uno::XComponentContext>&);
virtual ~Gtk3KDE5FilePicker(); virtual ~Gtk3KDE5FilePicker() override;
// XFilePickerNotifier // XFilePickerNotifier
virtual void SAL_CALL addFilePickerListener( virtual void SAL_CALL addFilePickerListener(
...@@ -115,7 +115,7 @@ public: ...@@ -115,7 +115,7 @@ public:
virtual void SAL_CALL cancel() override; virtual void SAL_CALL cancel() override;
// XEventListener // XEventListener
virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent); virtual void disposing(const css::lang::EventObject& rEvent);
using cppu::WeakComponentImplHelperBase::disposing; using cppu::WeakComponentImplHelperBase::disposing;
// XServiceInfo // XServiceInfo
......
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
#undef Region #undef Region
#include "unx/geninst.h" #include <unx/geninst.h>
#include "strings.hrc" #include <strings.hrc>
#include <future> #include <future>
...@@ -125,12 +125,12 @@ Gtk3KDE5FilePickerIpc::~Gtk3KDE5FilePickerIpc() ...@@ -125,12 +125,12 @@ Gtk3KDE5FilePickerIpc::~Gtk3KDE5FilePickerIpc()
m_process.wait_for(std::chrono::milliseconds(100)); m_process.wait_for(std::chrono::milliseconds(100));
} }
sal_Int16 SAL_CALL Gtk3KDE5FilePickerIpc::execute() sal_Int16 Gtk3KDE5FilePickerIpc::execute()
{ {
auto restoreMainWindow = blockMainWindow(); auto restoreMainWindow = blockMainWindow();
auto id = sendCommand(Commands::Execute); auto id = sendCommand(Commands::Execute);
sal_Bool accepted = false; bool accepted = false;
readResponse(id, accepted); readResponse(id, accepted);
if (restoreMainWindow) if (restoreMainWindow)
...@@ -145,7 +145,7 @@ static gboolean ignoreDeleteEvent(GtkWidget* /*widget*/, GdkEvent* /*event*/, ...@@ -145,7 +145,7 @@ static gboolean ignoreDeleteEvent(GtkWidget* /*widget*/, GdkEvent* /*event*/,
return true; return true;
} }
std::function<void()> SAL_CALL Gtk3KDE5FilePickerIpc::blockMainWindow() std::function<void()> Gtk3KDE5FilePickerIpc::blockMainWindow()
{ {
vcl::Window* pParentWin = Application::GetDefDialogParent(); vcl::Window* pParentWin = Application::GetDefDialogParent();
if (!pParentWin) if (!pParentWin)
...@@ -157,7 +157,7 @@ std::function<void()> SAL_CALL Gtk3KDE5FilePickerIpc::blockMainWindow() ...@@ -157,7 +157,7 @@ std::function<void()> SAL_CALL Gtk3KDE5FilePickerIpc::blockMainWindow()
sendCommand(Commands::SetWinId, pSysData->aWindow); sendCommand(Commands::SetWinId, pSysData->aWindow);
auto* pMainWindow = reinterpret_cast<GtkWidget*>(pSysData->pWidget); auto* pMainWindow = static_cast<GtkWidget*>(pSysData->pWidget);
if (!pMainWindow) if (!pMainWindow)
return {}; return {};
...@@ -190,7 +190,7 @@ std::function<void()> SAL_CALL Gtk3KDE5FilePickerIpc::blockMainWindow() ...@@ -190,7 +190,7 @@ std::function<void()> SAL_CALL Gtk3KDE5FilePickerIpc::blockMainWindow()
}; };
} }
void SAL_CALL Gtk3KDE5FilePickerIpc::await(const std::future<void>& future) void Gtk3KDE5FilePickerIpc::await(const std::future<void>& future)
{ {
while (future.wait_for(std::chrono::milliseconds(1)) != std::future_status::ready) while (future.wait_for(std::chrono::milliseconds(1)) != std::future_status::ready)
{ {
......
...@@ -36,12 +36,6 @@ ...@@ -36,12 +36,6 @@
#include <mutex> #include <mutex>
#include <thread> #include <thread>
void readIpcArg(std::istream& stream, OUString& str);
void readIpcArg(std::istream& stream, css::uno::Sequence<OUString>& seq);
void sendIpcArg(std::ostream& stream, const OUString& string);
OUString getResString(const char* pResId); OUString getResString(const char* pResId);
class Gtk3KDE5FilePickerIpc class Gtk3KDE5FilePickerIpc
...@@ -60,7 +54,7 @@ public: ...@@ -60,7 +54,7 @@ public:
explicit Gtk3KDE5FilePickerIpc(); explicit Gtk3KDE5FilePickerIpc();
~Gtk3KDE5FilePickerIpc(); ~Gtk3KDE5FilePickerIpc();
sal_Int16 SAL_CALL execute(); sal_Int16 execute();
template <typename... Args> uint64_t sendCommand(Commands command, const Args&... args) template <typename... Args> uint64_t sendCommand(Commands command, const Args&... args)
{ {
...@@ -101,9 +95,9 @@ public: ...@@ -101,9 +95,9 @@ public:
} }
private: private:
std::function<void()> SAL_CALL blockMainWindow(); std::function<void()> blockMainWindow();
static void SAL_CALL await(const std::future<void>& future); static void await(const std::future<void>& future);
}; };
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
// constructor // constructor
explicit Gtk3KDE5FolderPicker( explicit Gtk3KDE5FolderPicker(
const css::uno::Reference<css::uno::XComponentContext>& xServiceMgr); const css::uno::Reference<css::uno::XComponentContext>& xServiceMgr);
virtual ~Gtk3KDE5FolderPicker(); virtual ~Gtk3KDE5FolderPicker() override;
// XExecutableDialog functions // XExecutableDialog functions
virtual void SAL_CALL setTitle(const OUString& aTitle) override; virtual void SAL_CALL setTitle(const OUString& aTitle) override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment