From 267c6f2ac71f92999e969232431ba04678e7437e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:54:39 +0200 Subject: Adding upstream version 4:24.2.0. Signed-off-by: Daniel Baumann --- vcl/unx/gtk3_kde5/FPServiceInfo.hxx | 28 ++ vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkaction.cxx | 12 + vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkbridge.cxx | 12 + vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkcomponent.cxx | 12 + .../gtk3_kde5/a11y/gtk3_kde5_atkeditabletext.cxx | 12 + vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkfactory.cxx | 12 + vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkhypertext.cxx | 12 + vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkimage.cxx | 12 + vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atklistener.cxx | 12 + vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkregistry.cxx | 12 + vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkselection.cxx | 12 + vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktable.cxx | 12 + vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktablecell.cxx | 12 + vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktext.cxx | 12 + .../gtk3_kde5/a11y/gtk3_kde5_atktextattributes.cxx | 12 + vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkutil.cxx | 12 + vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkvalue.cxx | 12 + vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkwrapper.cxx | 12 + vcl/unx/gtk3_kde5/filepicker_ipc_commands.hxx | 173 ++++++++ vcl/unx/gtk3_kde5/gtk3_kde5_cairo.cxx | 22 + vcl/unx/gtk3_kde5/gtk3_kde5_customcellrenderer.cxx | 12 + vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.cxx | 455 +++++++++++++++++++++ vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.hxx | 131 ++++++ vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx | 276 +++++++++++++ vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.hxx | 135 ++++++ vcl/unx/gtk3_kde5/gtk3_kde5_folderpicker.cxx | 85 ++++ vcl/unx/gtk3_kde5/gtk3_kde5_folderpicker.hxx | 59 +++ vcl/unx/gtk3_kde5/gtk3_kde5_gloactiongroup.cxx | 22 + vcl/unx/gtk3_kde5/gtk3_kde5_glomenu.cxx | 22 + vcl/unx/gtk3_kde5/gtk3_kde5_gtkdata.cxx | 22 + vcl/unx/gtk3_kde5/gtk3_kde5_gtkframe.cxx | 22 + vcl/unx/gtk3_kde5/gtk3_kde5_gtkinst.cxx | 57 +++ vcl/unx/gtk3_kde5/gtk3_kde5_gtkobject.cxx | 22 + vcl/unx/gtk3_kde5/gtk3_kde5_gtksalmenu.cxx | 22 + vcl/unx/gtk3_kde5/gtk3_kde5_gtksys.cxx | 22 + vcl/unx/gtk3_kde5/gtk3_kde5_hudawareness.cxx | 22 + .../gtk3_kde5/gtk3_kde5_salnativewidgets-gtk.cxx | 22 + vcl/unx/gtk3_kde5/kde5_filepicker.cxx | 286 +++++++++++++ vcl/unx/gtk3_kde5/kde5_filepicker.hxx | 110 +++++ vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx | 374 +++++++++++++++++ vcl/unx/gtk3_kde5/kde5_filepicker_ipc.hxx | 51 +++ vcl/unx/gtk3_kde5/kde5_lo_filepicker_main.cxx | 53 +++ 42 files changed, 2709 insertions(+) create mode 100644 vcl/unx/gtk3_kde5/FPServiceInfo.hxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkaction.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkbridge.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkcomponent.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkeditabletext.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkfactory.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkhypertext.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkimage.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atklistener.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkregistry.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkselection.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktable.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktablecell.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktext.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktextattributes.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkutil.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkvalue.cxx create mode 100644 vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkwrapper.cxx create mode 100644 vcl/unx/gtk3_kde5/filepicker_ipc_commands.hxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_cairo.cxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_customcellrenderer.cxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.cxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.hxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.hxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_folderpicker.cxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_folderpicker.hxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_gloactiongroup.cxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_glomenu.cxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_gtkdata.cxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_gtkframe.cxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_gtkinst.cxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_gtkobject.cxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_gtksalmenu.cxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_gtksys.cxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_hudawareness.cxx create mode 100644 vcl/unx/gtk3_kde5/gtk3_kde5_salnativewidgets-gtk.cxx create mode 100644 vcl/unx/gtk3_kde5/kde5_filepicker.cxx create mode 100644 vcl/unx/gtk3_kde5/kde5_filepicker.hxx create mode 100644 vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx create mode 100644 vcl/unx/gtk3_kde5/kde5_filepicker_ipc.hxx create mode 100644 vcl/unx/gtk3_kde5/kde5_lo_filepicker_main.cxx (limited to 'vcl/unx/gtk3_kde5') diff --git a/vcl/unx/gtk3_kde5/FPServiceInfo.hxx b/vcl/unx/gtk3_kde5/FPServiceInfo.hxx new file mode 100644 index 0000000000..1fbb8fd276 --- /dev/null +++ b/vcl/unx/gtk3_kde5/FPServiceInfo.hxx @@ -0,0 +1,28 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +// the service names +#define FILE_PICKER_SERVICE_NAME "com.sun.star.ui.dialogs.Gtk3KDE5FilePicker" + +// the implementation names +#define FILE_PICKER_IMPL_NAME "com.sun.star.ui.dialogs.Gtk3KDE5FilePicker" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkaction.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkaction.cxx new file mode 100644 index 0000000000..6b9f5e3d8c --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkaction.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atkaction.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkbridge.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkbridge.cxx new file mode 100644 index 0000000000..e07fc6c295 --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkbridge.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atkbridge.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkcomponent.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkcomponent.cxx new file mode 100644 index 0000000000..5eac70ebd9 --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkcomponent.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atkcomponent.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkeditabletext.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkeditabletext.cxx new file mode 100644 index 0000000000..792e432e13 --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkeditabletext.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atkeditabletext.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkfactory.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkfactory.cxx new file mode 100644 index 0000000000..2ddc5c55c4 --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkfactory.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atkfactory.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkhypertext.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkhypertext.cxx new file mode 100644 index 0000000000..f3fa99006e --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkhypertext.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atkhypertext.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkimage.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkimage.cxx new file mode 100644 index 0000000000..eb3acc7134 --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkimage.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atkimage.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atklistener.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atklistener.cxx new file mode 100644 index 0000000000..cf10d29dfd --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atklistener.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atklistener.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkregistry.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkregistry.cxx new file mode 100644 index 0000000000..cc10fbfdd5 --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkregistry.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atkregistry.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkselection.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkselection.cxx new file mode 100644 index 0000000000..4c7fc5c15f --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkselection.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atkselection.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktable.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktable.cxx new file mode 100644 index 0000000000..672125d1a8 --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktable.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atktable.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktablecell.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktablecell.cxx new file mode 100644 index 0000000000..fdbb6f6263 --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktablecell.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atktablecell.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktext.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktext.cxx new file mode 100644 index 0000000000..de1d1f06ca --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktext.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atktext.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktextattributes.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktextattributes.cxx new file mode 100644 index 0000000000..aeac0e02dc --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atktextattributes.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atktextattributes.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkutil.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkutil.cxx new file mode 100644 index 0000000000..193b08e9ab --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkutil.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atkutil.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkvalue.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkvalue.cxx new file mode 100644 index 0000000000..75825b4e12 --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkvalue.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atkvalue.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkwrapper.cxx b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkwrapper.cxx new file mode 100644 index 0000000000..a1bcc2e290 --- /dev/null +++ b/vcl/unx/gtk3_kde5/a11y/gtk3_kde5_atkwrapper.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../../gtk3/a11y/atkwrapper.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/filepicker_ipc_commands.hxx b/vcl/unx/gtk3_kde5/filepicker_ipc_commands.hxx new file mode 100644 index 0000000000..1d0925257b --- /dev/null +++ b/vcl/unx/gtk3_kde5/filepicker_ipc_commands.hxx @@ -0,0 +1,173 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include + +#include +#include + +// #define DEBUG_FILEPICKER_IPC + +namespace rtl +{ +class OUString; +} +class QString; + +enum class Commands : uint16_t +{ + SetTitle, + SetWinId, + Execute, + SetMultiSelectionMode, + SetDefaultName, + SetDisplayDirectory, + GetDisplayDirectory, + GetSelectedFiles, + AppendFilter, + SetCurrentFilter, + GetCurrentFilter, + SetValue, + GetValue, + EnableControl, + SetLabel, + GetLabel, + AddCheckBox, + Initialize, + Quit, + EnablePickFolderMode, +}; + +inline std::vector readIpcStringArg(std::istream& stream) +{ + uint32_t length = 0; + stream >> length; + stream.ignore(); // skip space separator + std::vector buffer(length, '\0'); + stream.read(buffer.data(), length); + return buffer; +} + +void readIpcArg(std::istream& stream, OUString& string); +void readIpcArg(std::istream& stream, QString& string); +void readIpcArg(std::istream& stream, css::uno::Sequence& seq); + +inline void readIpcArg(std::istream& stream, Commands& value) +{ + uint16_t v = 0; + stream >> v; + stream.ignore(); // skip space + value = static_cast(v); +} + +void readIpcArg(std::istream&, sal_Bool) = delete; + +inline void readIpcArg(std::istream& stream, bool& value) +{ + stream >> value; + stream.ignore(); // skip space +} + +inline void readIpcArg(std::istream& stream, sal_Int16& value) +{ + stream >> value; + stream.ignore(); // skip space +} + +inline void readIpcArg(std::istream& stream, sal_uIntPtr& value) +{ + stream >> value; + stream.ignore(); // skip space +} + +#if SAL_TYPES_SIZEOFPOINTER == 4 +inline void readIpcArg(std::istream& stream, uint64_t& value) +{ + stream >> value; + stream.ignore(); // skip space +} +#endif + +inline void readIpcArgs(std::istream& /*stream*/) +{ + // end of arguments, nothing to do +} + +template +inline void readIpcArgs(std::istream& stream, T& arg, Args&... args) +{ + readIpcArg(stream, arg); + readIpcArgs(stream, args...); +} + +void sendIpcArg(std::ostream& stream, const OUString& string); +void sendIpcArg(std::ostream& stream, const QString& string); + +inline void sendIpcStringArg(std::ostream& stream, uint32_t length, const char* string) +{ + stream << length << ' '; + stream.write(string, length); + stream << ' '; +} + +inline void sendIpcArg(std::ostream& stream, Commands value) +{ + stream << static_cast(value) << ' '; +} + +void sendIpcArg(std::ostream&, sal_Bool) = delete; + +inline void sendIpcArg(std::ostream& stream, bool value) { stream << value << ' '; } + +inline void sendIpcArg(std::ostream& stream, sal_Int16 value) { stream << value << ' '; } + +inline void sendIpcArg(std::ostream& stream, sal_uIntPtr value) { stream << value << ' '; } + +#if SAL_TYPES_SIZEOFPOINTER == 4 +inline void sendIpcArg(std::ostream& stream, uint64_t value) { stream << value << ' '; } +#endif + +inline void sendIpcArgsImpl(std::ostream& stream) +{ + // end of arguments, flush stream + stream << std::endl; +} + +template +inline void sendIpcArgsImpl(std::ostream& stream, const T& arg, const Args&... args) +{ + sendIpcArg(stream, arg); + sendIpcArgsImpl(stream, args...); +} + +template +inline void sendIpcArgs(std::ostream& stream, const T& arg, const Args&... args) +{ + sendIpcArgsImpl(stream, arg, args...); +#ifdef DEBUG_FILEPICKER_IPC + std::cerr << "IPC MSG: "; + sendIpcArgsImpl(std::cerr, arg, args...); +#endif +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_cairo.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_cairo.cxx new file mode 100644 index 0000000000..ed8780447f --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_cairo.cxx @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "../gtk3/gtkcairo.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_customcellrenderer.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_customcellrenderer.cxx new file mode 100644 index 0000000000..aebe2c89ed --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_customcellrenderer.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../gtk3/customcellrenderer.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.cxx new file mode 100644 index 0000000000..d3a053a080 --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.cxx @@ -0,0 +1,455 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include + +#include "gtk3_kde5_filepicker.hxx" + +#include +#include +#include +#include +#include + +#include +#include +#include "FPServiceInfo.hxx" + +#undef Region + +#include + +using namespace ::com::sun::star; +using namespace ::com::sun::star::ui::dialogs; +using namespace ::com::sun::star::ui::dialogs::TemplateDescription; +using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds; +using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; + +// helper functions + +namespace +{ +uno::Sequence FilePicker_getSupportedServiceNames() +{ + return { "com.sun.star.ui.dialogs.FilePicker", "com.sun.star.ui.dialogs.SystemFilePicker", + "com.sun.star.ui.dialogs.Gtk3KDE5FilePicker" }; +} +} + +// Gtk3KDE5FilePicker + +Gtk3KDE5FilePicker::Gtk3KDE5FilePicker(const uno::Reference&) + : Gtk3KDE5FilePicker_Base(_helperMutex) +{ + setMultiSelectionMode(false); + + // tdf#124598 dummy KWidget use to make gtk3_kde5 VCL plugin link against KIO libraries + QString sDummyStr; + QUrl aUrl = KFileWidget::getStartUrl(QUrl(), sDummyStr); + aUrl.setPath("/dev/null"); +} + +Gtk3KDE5FilePicker::~Gtk3KDE5FilePicker() = default; + +void SAL_CALL +Gtk3KDE5FilePicker::addFilePickerListener(const uno::Reference& xListener) +{ + SolarMutexGuard aGuard; + m_xListener = xListener; +} + +void SAL_CALL +Gtk3KDE5FilePicker::removeFilePickerListener(const uno::Reference&) +{ + SolarMutexGuard aGuard; + m_xListener.clear(); +} + +void SAL_CALL Gtk3KDE5FilePicker::setTitle(const OUString& title) +{ + m_ipc.sendCommand(Commands::SetTitle, title); +} + +sal_Int16 SAL_CALL Gtk3KDE5FilePicker::execute() +{ + SolarMutexGuard g; + return m_ipc.execute(); +} + +void SAL_CALL Gtk3KDE5FilePicker::setMultiSelectionMode(sal_Bool multiSelect) +{ + m_ipc.sendCommand(Commands::SetMultiSelectionMode, bool(multiSelect)); +} + +void SAL_CALL Gtk3KDE5FilePicker::setDefaultName(const OUString& name) +{ + m_ipc.sendCommand(Commands::SetDefaultName, name); +} + +void SAL_CALL Gtk3KDE5FilePicker::setDisplayDirectory(const OUString& dir) +{ + m_ipc.sendCommand(Commands::SetDisplayDirectory, dir); +} + +OUString SAL_CALL Gtk3KDE5FilePicker::getDisplayDirectory() +{ + auto id = m_ipc.sendCommand(Commands::GetDisplayDirectory); + OUString dir; + m_ipc.readResponse(id, dir); + return dir; +} + +uno::Sequence SAL_CALL Gtk3KDE5FilePicker::getFiles() +{ + uno::Sequence seq = getSelectedFiles(); + if (seq.getLength() > 1) + seq.realloc(1); + return seq; +} + +uno::Sequence SAL_CALL Gtk3KDE5FilePicker::getSelectedFiles() +{ + auto id = m_ipc.sendCommand(Commands::GetSelectedFiles); + uno::Sequence seq; + m_ipc.readResponse(id, seq); + return seq; +} + +void SAL_CALL Gtk3KDE5FilePicker::appendFilter(const OUString& title, const OUString& filter) +{ + m_ipc.sendCommand(Commands::AppendFilter, title, filter); +} + +void SAL_CALL Gtk3KDE5FilePicker::setCurrentFilter(const OUString& title) +{ + m_ipc.sendCommand(Commands::SetCurrentFilter, title); +} + +OUString SAL_CALL Gtk3KDE5FilePicker::getCurrentFilter() +{ + auto id = m_ipc.sendCommand(Commands::GetCurrentFilter); + OUString filter; + m_ipc.readResponse(id, filter); + return filter; +} + +void SAL_CALL Gtk3KDE5FilePicker::appendFilterGroup(const OUString& /*rGroupTitle*/, + const uno::Sequence& filters) +{ + const sal_uInt16 length = filters.getLength(); + for (sal_uInt16 i = 0; i < length; ++i) + { + beans::StringPair aPair = filters[i]; + appendFilter(aPair.First, aPair.Second); + } +} + +void SAL_CALL Gtk3KDE5FilePicker::setValue(sal_Int16 controlId, sal_Int16 nControlAction, + const uno::Any& value) +{ + if (value.has()) + { + m_ipc.sendCommand(Commands::SetValue, controlId, nControlAction, value.get()); + } + else + { + SAL_INFO("vcl.gtkkde5", "set value of unhandled type " << controlId); + } +} + +uno::Any SAL_CALL Gtk3KDE5FilePicker::getValue(sal_Int16 controlId, sal_Int16 nControlAction) +{ + if (CHECKBOX_AUTOEXTENSION == controlId) + // We ignore this one and rely on QFileDialog to provide the function. + // Always return false, to pretend we do not support this, otherwise + // LO core would try to be smart and cut the extension in some places, + // interfering with QFileDialog's handling of it. QFileDialog also + // saves the value of the setting, so LO core is not needed for that either. + return uno::Any(false); + + auto id = m_ipc.sendCommand(Commands::GetValue, controlId, nControlAction); + + bool value = false; + m_ipc.readResponse(id, value); + + return uno::Any(value); +} + +void SAL_CALL Gtk3KDE5FilePicker::enableControl(sal_Int16 controlId, sal_Bool enable) +{ + m_ipc.sendCommand(Commands::EnableControl, controlId, bool(enable)); +} + +void SAL_CALL Gtk3KDE5FilePicker::setLabel(sal_Int16 controlId, const OUString& label) +{ + m_ipc.sendCommand(Commands::SetLabel, controlId, label); +} + +OUString SAL_CALL Gtk3KDE5FilePicker::getLabel(sal_Int16 controlId) +{ + auto id = m_ipc.sendCommand(Commands::GetLabel, controlId); + OUString label; + m_ipc.readResponse(id, label); + return label; +} + +void Gtk3KDE5FilePicker::addCustomControl(sal_Int16 controlId) +{ + TranslateId resId; + + switch (controlId) + { + case CHECKBOX_AUTOEXTENSION: + resId = STR_SVT_FILEPICKER_AUTO_EXTENSION; + break; + case CHECKBOX_PASSWORD: + resId = STR_SVT_FILEPICKER_PASSWORD; + break; + case CHECKBOX_FILTEROPTIONS: + resId = STR_SVT_FILEPICKER_FILTER_OPTIONS; + break; + case CHECKBOX_READONLY: + resId = STR_SVT_FILEPICKER_READONLY; + break; + case CHECKBOX_LINK: + resId = STR_SVT_FILEPICKER_INSERT_AS_LINK; + break; + case CHECKBOX_PREVIEW: + resId = STR_SVT_FILEPICKER_SHOW_PREVIEW; + break; + case CHECKBOX_SELECTION: + resId = STR_SVT_FILEPICKER_SELECTION; + break; + case CHECKBOX_GPGENCRYPTION: + resId = STR_SVT_FILEPICKER_GPGENCRYPT; + break; + case PUSHBUTTON_PLAY: + resId = STR_SVT_FILEPICKER_PLAY; + break; + case LISTBOX_VERSION: + resId = STR_SVT_FILEPICKER_VERSION; + break; + case LISTBOX_TEMPLATE: + resId = STR_SVT_FILEPICKER_TEMPLATES; + break; + case LISTBOX_IMAGE_TEMPLATE: + resId = STR_SVT_FILEPICKER_IMAGE_TEMPLATE; + break; + case LISTBOX_IMAGE_ANCHOR: + resId = STR_SVT_FILEPICKER_IMAGE_ANCHOR; + break; + case LISTBOX_VERSION_LABEL: + case LISTBOX_TEMPLATE_LABEL: + case LISTBOX_IMAGE_TEMPLATE_LABEL: + case LISTBOX_IMAGE_ANCHOR_LABEL: + case LISTBOX_FILTER_SELECTOR: + break; + } + + switch (controlId) + { + case CHECKBOX_AUTOEXTENSION: + case CHECKBOX_PASSWORD: + case CHECKBOX_FILTEROPTIONS: + case CHECKBOX_READONLY: + case CHECKBOX_LINK: + case CHECKBOX_PREVIEW: + case CHECKBOX_SELECTION: + case CHECKBOX_GPGENCRYPTION: + { + // the checkbox is created even for CHECKBOX_AUTOEXTENSION to simplify + // code, but the checkbox is hidden and ignored + bool hidden = controlId == CHECKBOX_AUTOEXTENSION; + + m_ipc.sendCommand(Commands::AddCheckBox, controlId, hidden, getResString(resId)); + + break; + } + case PUSHBUTTON_PLAY: + case LISTBOX_VERSION: + case LISTBOX_TEMPLATE: + case LISTBOX_IMAGE_TEMPLATE: + case LISTBOX_IMAGE_ANCHOR: + case LISTBOX_VERSION_LABEL: + case LISTBOX_TEMPLATE_LABEL: + case LISTBOX_IMAGE_TEMPLATE_LABEL: + case LISTBOX_IMAGE_ANCHOR_LABEL: + case LISTBOX_FILTER_SELECTOR: + break; + } +} + +void SAL_CALL Gtk3KDE5FilePicker::initialize(const uno::Sequence& args) +{ + // parameter checking + uno::Any arg; + if (args.getLength() == 0) + { + throw lang::IllegalArgumentException("no arguments", static_cast(this), 1); + } + + arg = args[0]; + + if ((arg.getValueType() != cppu::UnoType::get()) + && (arg.getValueType() != cppu::UnoType::get())) + { + throw lang::IllegalArgumentException("invalid argument type", + static_cast(this), 1); + } + + sal_Int16 templateId = -1; + arg >>= templateId; + + bool saveDialog = false; + switch (templateId) + { + case FILEOPEN_SIMPLE: + break; + + case FILESAVE_SIMPLE: + saveDialog = true; + break; + + case FILESAVE_AUTOEXTENSION: + saveDialog = true; + addCustomControl(CHECKBOX_AUTOEXTENSION); + break; + + case FILESAVE_AUTOEXTENSION_PASSWORD: + { + saveDialog = true; + addCustomControl(CHECKBOX_PASSWORD); + addCustomControl(CHECKBOX_GPGENCRYPTION); + break; + } + case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS: + { + saveDialog = true; + addCustomControl(CHECKBOX_AUTOEXTENSION); + addCustomControl(CHECKBOX_PASSWORD); + addCustomControl(CHECKBOX_GPGENCRYPTION); + addCustomControl(CHECKBOX_FILTEROPTIONS); + break; + } + case FILESAVE_AUTOEXTENSION_SELECTION: + saveDialog = true; + addCustomControl(CHECKBOX_AUTOEXTENSION); + addCustomControl(CHECKBOX_SELECTION); + break; + + case FILESAVE_AUTOEXTENSION_TEMPLATE: + saveDialog = true; + addCustomControl(CHECKBOX_AUTOEXTENSION); + addCustomControl(LISTBOX_TEMPLATE); + break; + + case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE: + addCustomControl(CHECKBOX_LINK); + addCustomControl(CHECKBOX_PREVIEW); + addCustomControl(LISTBOX_IMAGE_TEMPLATE); + break; + + case FILEOPEN_LINK_PREVIEW_IMAGE_ANCHOR: + addCustomControl(CHECKBOX_LINK); + addCustomControl(CHECKBOX_PREVIEW); + addCustomControl(LISTBOX_IMAGE_ANCHOR); + break; + + case FILEOPEN_PLAY: + addCustomControl(PUSHBUTTON_PLAY); + break; + + case FILEOPEN_LINK_PLAY: + addCustomControl(CHECKBOX_LINK); + addCustomControl(PUSHBUTTON_PLAY); + break; + + case FILEOPEN_READONLY_VERSION: + addCustomControl(CHECKBOX_READONLY); + addCustomControl(LISTBOX_VERSION); + break; + + case FILEOPEN_LINK_PREVIEW: + addCustomControl(CHECKBOX_LINK); + addCustomControl(CHECKBOX_PREVIEW); + break; + + case FILEOPEN_PREVIEW: + addCustomControl(CHECKBOX_PREVIEW); + break; + + default: + SAL_INFO("vcl.gtkkde5", "unknown templates " << templateId); + return; + } + + setTitle(getResString(saveDialog ? STR_FILEDLG_SAVE : STR_FILEDLG_OPEN)); + + m_ipc.sendCommand(Commands::Initialize, saveDialog); +} + +void SAL_CALL Gtk3KDE5FilePicker::cancel() +{ + // TODO +} + +void Gtk3KDE5FilePicker::disposing(const lang::EventObject& rEvent) +{ + uno::Reference xFilePickerListener(rEvent.Source, uno::UNO_QUERY); + + if (xFilePickerListener.is()) + { + removeFilePickerListener(xFilePickerListener); + } +} + +OUString SAL_CALL Gtk3KDE5FilePicker::getImplementationName() { return FILE_PICKER_IMPL_NAME; } + +sal_Bool SAL_CALL Gtk3KDE5FilePicker::supportsService(const OUString& ServiceName) +{ + return cppu::supportsService(this, ServiceName); +} + +uno::Sequence SAL_CALL Gtk3KDE5FilePicker::getSupportedServiceNames() +{ + return FilePicker_getSupportedServiceNames(); +} + +void Gtk3KDE5FilePicker::filterChanged() +{ + FilePickerEvent aEvent; + aEvent.ElementId = LISTBOX_FILTER; + SAL_INFO("vcl.gtkkde5", "filter changed"); + if (m_xListener.is()) + m_xListener->controlStateChanged(aEvent); +} + +void Gtk3KDE5FilePicker::selectionChanged() +{ + FilePickerEvent aEvent; + SAL_INFO("vcl.gtkkde5", "file selection changed"); + if (m_xListener.is()) + m_xListener->fileSelectionChanged(aEvent); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.hxx b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.hxx new file mode 100644 index 0000000000..7ce3910048 --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker.hxx @@ -0,0 +1,131 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include + +#include +#include +#include +#include +#include + +#include + +#include "gtk3_kde5_filepicker_ipc.hxx" + +typedef ::cppu::WeakComponentImplHelper + Gtk3KDE5FilePicker_Base; + +class Gtk3KDE5FilePicker : public Gtk3KDE5FilePicker_Base +{ +protected: + css::uno::Reference m_xListener; + + osl::Mutex _helperMutex; + Gtk3KDE5FilePickerIpc m_ipc; + +public: + explicit Gtk3KDE5FilePicker(const css::uno::Reference&); + virtual ~Gtk3KDE5FilePicker() override; + + // XFilePickerNotifier + virtual void SAL_CALL addFilePickerListener( + const css::uno::Reference& xListener) override; + virtual void SAL_CALL removeFilePickerListener( + const css::uno::Reference& xListener) override; + + // XExecutableDialog functions + virtual void SAL_CALL setTitle(const OUString& rTitle) override; + virtual sal_Int16 SAL_CALL execute() override; + + // XFilePicker functions + virtual void SAL_CALL setMultiSelectionMode(sal_Bool bMode) override; + virtual void SAL_CALL setDefaultName(const OUString& rName) override; + virtual void SAL_CALL setDisplayDirectory(const OUString& rDirectory) override; + virtual OUString SAL_CALL getDisplayDirectory() override; + virtual css::uno::Sequence SAL_CALL getFiles() override; + + // XFilterManager functions + virtual void SAL_CALL appendFilter(const OUString& rTitle, const OUString& rFilter) override; + virtual void SAL_CALL setCurrentFilter(const OUString& rTitle) override; + virtual OUString SAL_CALL getCurrentFilter() override; + + // XFilterGroupManager functions + virtual void SAL_CALL + appendFilterGroup(const OUString& rGroupTitle, + const css::uno::Sequence& rFilters) override; + + // XFilePickerControlAccess functions + virtual void SAL_CALL setValue(sal_Int16 nControlId, sal_Int16 nControlAction, + const css::uno::Any& rValue) override; + virtual css::uno::Any SAL_CALL getValue(sal_Int16 nControlId, + sal_Int16 nControlAction) override; + virtual void SAL_CALL enableControl(sal_Int16 nControlId, sal_Bool bEnable) override; + virtual void SAL_CALL setLabel(sal_Int16 nControlId, const OUString& rLabel) override; + virtual OUString SAL_CALL getLabel(sal_Int16 nControlId) override; + + /* TODO XFilePreview + + virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( ); + virtual sal_Int32 SAL_CALL getTargetColorDepth( ); + virtual sal_Int32 SAL_CALL getAvailableWidth( ); + virtual sal_Int32 SAL_CALL getAvailableHeight( ); + virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const css::uno::Any &rImage ); + virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ); + virtual sal_Bool SAL_CALL getShowState( ); + */ + + // XFilePicker2 functions + virtual css::uno::Sequence SAL_CALL getSelectedFiles() override; + + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence& rArguments) override; + + // XCancellable + virtual void SAL_CALL cancel() override; + + // XEventListener + virtual void disposing(const css::lang::EventObject& rEvent); + using cppu::WeakComponentImplHelperBase::disposing; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override; + virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + +private: + Gtk3KDE5FilePicker(const Gtk3KDE5FilePicker&) = delete; + Gtk3KDE5FilePicker& operator=(const Gtk3KDE5FilePicker&) = delete; + + //add a custom control widget to the file dialog + void addCustomControl(sal_Int16 controlId); + + // emit XFilePickerListener controlStateChanged event + void filterChanged(); + // emit XFilePickerListener fileSelectionChanged event + void selectionChanged(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx new file mode 100644 index 0000000000..ebfa0fbd7e --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx @@ -0,0 +1,276 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include + +#include "gtk3_kde5_filepicker_ipc.hxx" + +#undef Region + +#include + +#include + +#include +#include +#include + +#include +#include + +#include + +#include + +#include + +using namespace ::com::sun::star::ui::dialogs; + +// helper functions + +namespace +{ +OUString applicationDirPath() +{ + OUString applicationFilePath; + osl_getExecutableFile(&applicationFilePath.pData); + OUString applicationSystemPath; + osl_getSystemPathFromFileURL(applicationFilePath.pData, &applicationSystemPath.pData); + const auto utf8Path = applicationSystemPath.toUtf8(); + auto ret = boost::filesystem::path(utf8Path.getStr(), utf8Path.getStr() + utf8Path.getLength()); + ret.remove_filename(); + return OUString::fromUtf8(std::string_view(ret.c_str())); +} + +OUString findPickerExecutable() +{ + const auto path = applicationDirPath(); + OUString ret; + osl_searchFileURL(u"lo_kde5filepicker"_ustr.pData, path.pData, &ret.pData); + if (ret.isEmpty()) + throw std::system_error(std::make_error_code(std::errc::no_such_file_or_directory), + "could not find lo_kde5filepicker executable"); + return ret; +} +} + +void readIpcArg(std::istream& stream, OUString& str) +{ + const auto buffer = readIpcStringArg(stream); + str = OUString::fromUtf8(std::string_view(buffer.data(), buffer.size())); +} + +void readIpcArg(std::istream& stream, css::uno::Sequence& seq) +{ + uint32_t numFiles = 0; + stream >> numFiles; + stream.ignore(); // skip space; + seq.realloc(numFiles); + OUString* pSeq = seq.getArray(); + for (size_t i = 0; i < numFiles; ++i) + { + readIpcArg(stream, pSeq[i]); + } +} + +void sendIpcArg(std::ostream& stream, const OUString& string) +{ + const auto utf8 = string.toUtf8(); + sendIpcStringArg(stream, utf8.getLength(), utf8.getStr()); +} + +OUString getResString(TranslateId pResId) +{ + if (!pResId) + return {}; + + return FpsResId(pResId); +} + +// handles the IPC commands for dialog execution and ends the dummy Gtk dialog once the IPC response is there +static void handleIpcForExecute(Gtk3KDE5FilePickerIpc* pFilePickerIpc, GtkWidget* pDummyDialog, + bool* bResult) +{ + auto id = pFilePickerIpc->sendCommand(Commands::Execute); + pFilePickerIpc->readResponse(id, *bResult); + + // end the dummy dialog + gtk_widget_hide(pDummyDialog); +} + +// Gtk3KDE5FilePicker + +Gtk3KDE5FilePickerIpc::Gtk3KDE5FilePickerIpc() +{ + const auto exe = findPickerExecutable(); + oslProcessError result; + oslSecurity pSecurity = osl_getCurrentSecurity(); + result = osl_executeProcess_WithRedirectedIO(exe.pData, nullptr, 0, osl_Process_NORMAL, + pSecurity, nullptr, nullptr, 0, &m_process, + &m_inputWrite, &m_outputRead, nullptr); + osl_freeSecurityHandle(pSecurity); + if (result != osl_Process_E_None) + throw std::system_error(std::make_error_code(std::errc::no_such_process), + "could not start lo_kde5filepicker executable"); +} + +Gtk3KDE5FilePickerIpc::~Gtk3KDE5FilePickerIpc() +{ + if (!m_process) + return; + + sendCommand(Commands::Quit); + osl_joinProcess(m_process); + + if (m_inputWrite) + osl_closeFile(m_inputWrite); + if (m_outputRead) + osl_closeFile(m_outputRead); + osl_freeProcessHandle(m_process); +} + +sal_Int16 Gtk3KDE5FilePickerIpc::execute() +{ + auto restoreMainWindow = blockMainWindow(); + + // dummy gtk dialog that will take care of processing events, + // not meant to be actually seen by user + GtkWidget* pDummyDialog = gtk_dialog_new(); + + bool accepted = false; + + // send IPC command and read response in a separate thread + std::thread aIpcHandler(&handleIpcForExecute, this, pDummyDialog, &accepted); + + // make dummy dialog not to be seen by user + gtk_window_set_decorated(GTK_WINDOW(pDummyDialog), false); + gtk_window_set_default_size(GTK_WINDOW(pDummyDialog), 0, 0); + gtk_window_set_accept_focus(GTK_WINDOW(pDummyDialog), false); + // gtk_widget_set_opacity() only has the desired effect when widget is already shown + gtk_widget_show(pDummyDialog); + gtk_widget_set_opacity(pDummyDialog, 0); + // run dialog, leaving event processing to GTK + // dialog will be closed by the separate 'aIpcHandler' thread once the IPC response is there + gtk_dialog_run(GTK_DIALOG(pDummyDialog)); + + aIpcHandler.join(); + + gtk_widget_destroy(pDummyDialog); + + if (restoreMainWindow) + restoreMainWindow(); + + return accepted ? ExecutableDialogResults::OK : ExecutableDialogResults::CANCEL; +} + +static gboolean ignoreDeleteEvent(GtkWidget* /*widget*/, GdkEvent* /*event*/, + gpointer /*user_data*/) +{ + return true; +} + +std::function Gtk3KDE5FilePickerIpc::blockMainWindow() +{ + weld::Window* pParentWin = Application::GetDefDialogParent(); + if (!pParentWin) + return {}; + + const SystemEnvData aSysData = pParentWin->get_system_data(); + auto* pMainWindow = static_cast(aSysData.pWidget); + if (!pMainWindow) + return {}; + + sendCommand(Commands::SetWinId, aSysData.GetWindowHandle(aSysData.pSalFrame)); + + SolarMutexGuard guard; + auto deleteEventSignalId = g_signal_lookup("delete_event", gtk_widget_get_type()); + + // disable the mainwindow + gtk_widget_set_sensitive(pMainWindow, false); + + // block the GtkSalFrame delete_event handler + auto blockedHandler = g_signal_handler_find( + pMainWindow, static_cast(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA), + deleteEventSignalId, 0, nullptr, nullptr, aSysData.pSalFrame); + g_signal_handler_block(pMainWindow, blockedHandler); + + // prevent the window from being closed + auto ignoreDeleteEventHandler + = g_signal_connect(pMainWindow, "delete_event", G_CALLBACK(ignoreDeleteEvent), nullptr); + + return [pMainWindow, ignoreDeleteEventHandler, blockedHandler] { + SolarMutexGuard cleanupGuard; + // re-enable window + gtk_widget_set_sensitive(pMainWindow, true); + + // allow it to be closed again + g_signal_handler_disconnect(pMainWindow, ignoreDeleteEventHandler); + + // unblock the GtkSalFrame handler + g_signal_handler_unblock(pMainWindow, blockedHandler); + }; +} + +void Gtk3KDE5FilePickerIpc::writeResponseLine(const std::string& line) +{ + sal_uInt64 bytesWritten = 0; + osl_writeFile(m_inputWrite, line.c_str(), line.size(), &bytesWritten); +} + +std::string Gtk3KDE5FilePickerIpc::readResponseLine() +{ + if (!m_responseBuffer.empty()) // check whether we have a line in our buffer + { + std::size_t it = m_responseBuffer.find('\n'); + if (it != std::string::npos) + { + auto ret = m_responseBuffer.substr(0, it); + m_responseBuffer.erase(0, it + 1); + return ret; + } + } + + const sal_uInt64 BUF_SIZE = 1024; + char buffer[BUF_SIZE]; + while (true) + { + sal_uInt64 bytesRead = 0; + auto err = osl_readFile(m_outputRead, buffer, BUF_SIZE, &bytesRead); + auto it = std::find(buffer, buffer + bytesRead, '\n'); + if (it != buffer + bytesRead) // check whether the chunk we read contains an EOL + { + // if so, append that part to the buffer and return it + std::string ret = m_responseBuffer.append(buffer, it); + // but keep anything else we may have read in our buffer + ++it; + m_responseBuffer.assign(it, buffer + bytesRead); + return ret; + } + // otherwise append everything we read to the buffer and try again + m_responseBuffer.append(buffer, bytesRead); + + if (err != osl_File_E_None && err != osl_File_E_AGAIN) + break; + } + return {}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.hxx b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.hxx new file mode 100644 index 0000000000..58ca3eb452 --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.hxx @@ -0,0 +1,135 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +#include "filepicker_ipc_commands.hxx" + +#include +#include +#include +#include + +OUString getResString(TranslateId pResId); + +class Gtk3KDE5FilePickerIpc +{ +protected: + oslProcess m_process; + oslFileHandle m_inputWrite; + oslFileHandle m_outputRead; + // simple multiplexing: every command gets its own ID that can be used to + // read the corresponding response + uint64_t m_msgId = 1; + std::mutex m_mutex; + uint64_t m_incomingResponse = 0; + std::string m_responseBuffer; + std::stringstream m_responseStream; + +public: + explicit Gtk3KDE5FilePickerIpc(); + ~Gtk3KDE5FilePickerIpc(); + + sal_Int16 execute(); + + void writeResponseLine(const std::string& line); + + template uint64_t sendCommand(Commands command, const Args&... args) + { + auto id = m_msgId; + ++m_msgId; + std::stringstream stream; + sendIpcArgs(stream, id, command, args...); + writeResponseLine(stream.str()); + return id; + } + + std::string readResponseLine(); + + // workaround gcc <= 4.8 bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55914 + template struct seq + { + }; + template struct gens : gens + { + }; + template struct gens<0, S...> + { + typedef seq type; + }; + template struct ArgsReader + { + ArgsReader(Args&... args) + : m_args(args...) + { + } + + void operator()(std::istream& stream) + { + callFunc(stream, typename gens::type()); + } + + private: + template void callFunc(std::istream& stream, seq) + { + readIpcArgs(stream, std::get(m_args)...); + } + + std::tuple m_args; + }; + + template void readResponse(uint64_t id, Args&... args) + { + ArgsReader argsReader(args...); + while (true) + { + // only let one thread read at any given time + std::scoped_lock lock(m_mutex); + + // check if we need to read (and potentially wait) a response ID + if (m_incomingResponse == 0) + { + m_responseStream.clear(); + m_responseStream.str(readResponseLine()); + readIpcArgs(m_responseStream, m_incomingResponse); + } + + if (m_incomingResponse == id) + { + // the response we are waiting for came in + argsReader(m_responseStream); + m_incomingResponse = 0; + break; + } + else + { + // the next response answers some other request, yield + std::this_thread::yield(); + } + } + } + +private: + std::function blockMainWindow(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_folderpicker.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_folderpicker.cxx new file mode 100644 index 0000000000..c1569e6be2 --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_folderpicker.cxx @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "gtk3_kde5_folderpicker.hxx" + +#include + +#include + +using namespace ::com::sun::star; +using namespace ::com::sun::star::ui::dialogs; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::uno; + +// constructor + +Gtk3KDE5FolderPicker::Gtk3KDE5FolderPicker( + const uno::Reference& /*xContext*/) +{ + m_ipc.sendCommand(Commands::EnablePickFolderMode); + setTitle(getResString(STR_SVT_FOLDERPICKER_DEFAULT_TITLE)); +} + +Gtk3KDE5FolderPicker::~Gtk3KDE5FolderPicker() = default; + +void SAL_CALL Gtk3KDE5FolderPicker::setDisplayDirectory(const OUString& aDirectory) +{ + m_ipc.sendCommand(Commands::SetDisplayDirectory, aDirectory); +} + +OUString SAL_CALL Gtk3KDE5FolderPicker::getDisplayDirectory() +{ + auto id = m_ipc.sendCommand(Commands::GetDisplayDirectory); + OUString ret; + m_ipc.readResponse(id, ret); + return ret; +} + +OUString SAL_CALL Gtk3KDE5FolderPicker::getDirectory() +{ + auto id = m_ipc.sendCommand(Commands::GetSelectedFiles); + uno::Sequence seq; + m_ipc.readResponse(id, seq); + return seq.hasElements() ? seq[0] : OUString(); +} + +void SAL_CALL Gtk3KDE5FolderPicker::setDescription(const OUString& /*rDescription*/) {} + +// XExecutableDialog functions + +void SAL_CALL Gtk3KDE5FolderPicker::setTitle(const OUString& aTitle) +{ + m_ipc.sendCommand(Commands::SetTitle, aTitle); +} + +sal_Int16 SAL_CALL Gtk3KDE5FolderPicker::execute() +{ + SolarMutexGuard g; + return m_ipc.execute(); +} + +// XCancellable + +void SAL_CALL Gtk3KDE5FolderPicker::cancel() +{ + // TODO +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_folderpicker.hxx b/vcl/unx/gtk3_kde5/gtk3_kde5_folderpicker.hxx new file mode 100644 index 0000000000..9801a072ac --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_folderpicker.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +#include +#include + +#include "gtk3_kde5_filepicker_ipc.hxx" + +class Gtk3KDE5FolderPicker : public cppu::WeakImplHelper +{ +protected: + Gtk3KDE5FilePickerIpc m_ipc; + +public: + // constructor + explicit Gtk3KDE5FolderPicker( + const css::uno::Reference& xServiceMgr); + virtual ~Gtk3KDE5FolderPicker() override; + + // XExecutableDialog functions + virtual void SAL_CALL setTitle(const OUString& aTitle) override; + virtual sal_Int16 SAL_CALL execute() override; + + // XFolderPicker functions + virtual void SAL_CALL setDisplayDirectory(const OUString& rDirectory) override; + virtual OUString SAL_CALL getDisplayDirectory() override; + virtual OUString SAL_CALL getDirectory() override; + virtual void SAL_CALL setDescription(const OUString& rDescription) override; + + // XCancellable + virtual void SAL_CALL cancel() override; + +private: + Gtk3KDE5FolderPicker(const Gtk3KDE5FolderPicker&) = delete; + Gtk3KDE5FolderPicker& operator=(const Gtk3KDE5FolderPicker&) = delete; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_gloactiongroup.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_gloactiongroup.cxx new file mode 100644 index 0000000000..eccf49d3df --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_gloactiongroup.cxx @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "../gtk3/gloactiongroup.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_glomenu.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_glomenu.cxx new file mode 100644 index 0000000000..979c9fba07 --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_glomenu.cxx @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "../gtk3/glomenu.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_gtkdata.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_gtkdata.cxx new file mode 100644 index 0000000000..f03dce99a7 --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_gtkdata.cxx @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "../gtk3/gtkdata.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_gtkframe.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_gtkframe.cxx new file mode 100644 index 0000000000..8d8a07a3f2 --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_gtkframe.cxx @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "../gtk3/gtkframe.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_gtkinst.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_gtkinst.cxx new file mode 100644 index 0000000000..dd6aace5dc --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_gtkinst.cxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +// make gtk3 plug advertise correctly as kde5 hybrid +#define GTK_TOOLKIT_NAME "gtk3_kde5" +#include "../gtk3/gtkinst.cxx" + +#include "gtk3_kde5_filepicker.hxx" +#include "gtk3_kde5_folderpicker.hxx" + +#include + +uno::Reference +GtkInstance::createFilePicker(const uno::Reference& xMSF) +{ + try + { + return uno::Reference(new Gtk3KDE5FilePicker(xMSF)); + } + catch (const std::system_error& error) + { + OSL_FAIL(error.what()); + return { nullptr }; + } +} + +uno::Reference +GtkInstance::createFolderPicker(const uno::Reference& xMSF) +{ + try + { + return uno::Reference(new Gtk3KDE5FolderPicker(xMSF)); + } + catch (const std::system_error& error) + { + OSL_FAIL(error.what()); + return { nullptr }; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_gtkobject.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_gtkobject.cxx new file mode 100644 index 0000000000..948c6bd3a8 --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_gtkobject.cxx @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "../gtk3/gtkobject.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_gtksalmenu.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_gtksalmenu.cxx new file mode 100644 index 0000000000..7963e6b603 --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_gtksalmenu.cxx @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "../gtk3/gtksalmenu.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_gtksys.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_gtksys.cxx new file mode 100644 index 0000000000..3f3ad9f1d3 --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_gtksys.cxx @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "../gtk3/gtksys.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_hudawareness.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_hudawareness.cxx new file mode 100644 index 0000000000..e0b8f1812d --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_hudawareness.cxx @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "../gtk3/hudawareness.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_salnativewidgets-gtk.cxx b/vcl/unx/gtk3_kde5/gtk3_kde5_salnativewidgets-gtk.cxx new file mode 100644 index 0000000000..428ff82042 --- /dev/null +++ b/vcl/unx/gtk3_kde5/gtk3_kde5_salnativewidgets-gtk.cxx @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "../gtk3/salnativewidgets-gtk.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/kde5_filepicker.cxx b/vcl/unx/gtk3_kde5/kde5_filepicker.cxx new file mode 100644 index 0000000000..28aee235a3 --- /dev/null +++ b/vcl/unx/gtk3_kde5/kde5_filepicker.cxx @@ -0,0 +1,286 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include "kde5_filepicker.hxx" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +// KDE5FilePicker + +KDE5FilePicker::KDE5FilePicker(QObject* parent) + : QObject(parent) + , _dialog(new QFileDialog(nullptr, {}, QDir::homePath())) + , _extraControls(new QWidget) + , _layout(new QGridLayout(_extraControls)) + , _winId(0) +{ + _dialog->setSupportedSchemes({ + QStringLiteral("file"), QStringLiteral("http"), QStringLiteral("https"), + QStringLiteral("webdav"), QStringLiteral("webdavs"), QStringLiteral("smb"), + QStringLiteral(""), // this makes removable devices shown + }); + + setMultiSelectionMode(false); + + connect(_dialog, &QFileDialog::filterSelected, this, &KDE5FilePicker::filterChanged); + connect(_dialog, &QFileDialog::fileSelected, this, &KDE5FilePicker::selectionChanged); + + setupCustomWidgets(); +} + +void KDE5FilePicker::enableFolderMode() +{ + _dialog->setOption(QFileDialog::ShowDirsOnly, true); + // Workaround for https://bugs.kde.org/show_bug.cgi?id=406464 : + // Don't set file mode to QFileDialog::Directory when native KDE Plasma 5 + // file dialog is used, since clicking on directory "bar" inside directory "foo" + // and then confirming would return "foo" rather than "foo/bar"; + // on the other hand, non-native file dialog needs 'QFileDialog::Directory' + // and doesn't allow folder selection otherwise + if (Application::GetDesktopEnvironment() != "PLASMA5") + { + _dialog->setFileMode(QFileDialog::Directory); + } +} + +KDE5FilePicker::~KDE5FilePicker() +{ + delete _extraControls; + delete _dialog; +} + +void KDE5FilePicker::setTitle(const QString& title) { _dialog->setWindowTitle(title); } + +bool KDE5FilePicker::execute() +{ + if (!_filters.isEmpty()) + _dialog->setNameFilters(_filters); + if (!_currentFilter.isEmpty()) + _dialog->selectNameFilter(_currentFilter); + + _dialog->show(); + //block and wait for user input + return _dialog->exec() == QFileDialog::Accepted; +} + +void KDE5FilePicker::setMultiSelectionMode(bool multiSelect) +{ + if (_dialog->acceptMode() == QFileDialog::AcceptSave) + return; + + _dialog->setFileMode(multiSelect ? QFileDialog::ExistingFiles : QFileDialog::ExistingFile); +} + +void KDE5FilePicker::setDefaultName(const QString& name) { _dialog->selectFile(name); } + +void KDE5FilePicker::setDisplayDirectory(const QString& dir) +{ + _dialog->setDirectoryUrl(QUrl(dir)); +} + +QString KDE5FilePicker::getDisplayDirectory() const { return _dialog->directoryUrl().url(); } + +QList KDE5FilePicker::getSelectedFiles() const { return _dialog->selectedUrls(); } + +void KDE5FilePicker::appendFilter(const QString& title, const QString& filter) +{ + QString t = title; + QString f = filter; + // '/' need to be escaped else they are assumed to be mime types by kfiledialog + //see the docs + t.replace("/", "\\/"); + + // openoffice gives us filters separated by ';' qt dialogs just want space separated + f.replace(";", " "); + + // make sure "*.*" is not used as "all files" + f.replace("*.*", "*"); + + _filters << QStringLiteral("%1 (%2)").arg(t, f); + _titleToFilters[t] = _filters.constLast(); +} + +void KDE5FilePicker::setCurrentFilter(const QString& title) +{ + _currentFilter = _titleToFilters.value(title); +} + +QString KDE5FilePicker::getCurrentFilter() const +{ + QString filter = _titleToFilters.key(_dialog->selectedNameFilter()); + + //default if not found + if (filter.isEmpty()) + filter = "ODF Text Document (.odt)"; + + return filter; +} + +void KDE5FilePicker::setValue(sal_Int16 controlId, sal_Int16 /*nControlAction*/, bool value) +{ + if (_customWidgets.contains(controlId)) + { + QCheckBox* cb = dynamic_cast(_customWidgets.value(controlId)); + if (cb) + cb->setChecked(value); + } + else + qWarning() << "set value on unknown control" << controlId; +} + +bool KDE5FilePicker::getValue(sal_Int16 controlId, sal_Int16 /*nControlAction*/) const +{ + bool ret = false; + if (_customWidgets.contains(controlId)) + { + QCheckBox* cb = dynamic_cast(_customWidgets.value(controlId)); + if (cb) + ret = cb->isChecked(); + } + else + qWarning() << "get value on unknown control" << controlId; + + return ret; +} + +void KDE5FilePicker::enableControl(sal_Int16 controlId, bool enable) +{ + if (_customWidgets.contains(controlId)) + _customWidgets.value(controlId)->setEnabled(enable); + else + qWarning() << "enable on unknown control" << controlId; +} + +void KDE5FilePicker::setLabel(sal_Int16 controlId, const QString& label) +{ + if (_customWidgets.contains(controlId)) + { + QCheckBox* cb = dynamic_cast(_customWidgets.value(controlId)); + if (cb) + cb->setText(label); + } + else + qWarning() << "set label on unknown control" << controlId; +} + +QString KDE5FilePicker::getLabel(sal_Int16 controlId) const +{ + QString label; + if (_customWidgets.contains(controlId)) + { + QCheckBox* cb = dynamic_cast(_customWidgets.value(controlId)); + if (cb) + label = cb->text(); + } + else + qWarning() << "get label on unknown control" << controlId; + + return label; +} + +void KDE5FilePicker::addCheckBox(sal_Int16 controlId, const QString& label, bool hidden) +{ + auto resString = label; + resString.replace('~', '&'); + + auto widget = new QCheckBox(resString, _extraControls); + widget->setHidden(hidden); + if (!hidden) + { + _layout->addWidget(widget); + } + _customWidgets.insert(controlId, widget); +} + +void KDE5FilePicker::initialize(bool saveDialog) +{ + //default is opening + QFileDialog::AcceptMode operationMode + = saveDialog ? QFileDialog::AcceptSave : QFileDialog::AcceptOpen; + + _dialog->setAcceptMode(operationMode); + + if (saveDialog) + _dialog->setFileMode(QFileDialog::AnyFile); +} + +void KDE5FilePicker::setWinId(sal_uInt64 winId) { _winId = winId; } + +void KDE5FilePicker::setupCustomWidgets() +{ + // When using the platform-native Plasma/KDE5 file picker, we currently rely on KFileWidget + // being present to add the custom controls visible (s. 'eventFilter' method). + // Since this doesn't work for other desktop environments, use a non-native + // dialog there in order not to lose the custom controls and insert the custom + // widget in the layout returned by QFileDialog::layout() + // (which returns nullptr for native file dialogs) + if (Application::GetDesktopEnvironment() == "PLASMA5") + { + qApp->installEventFilter(this); + } + else + { + _dialog->setOption(QFileDialog::DontUseNativeDialog); + QGridLayout* pLayout = static_cast(_dialog->layout()); + assert(pLayout); + const int row = pLayout->rowCount(); + pLayout->addWidget(_extraControls, row, 1); + } +} + +bool KDE5FilePicker::eventFilter(QObject* o, QEvent* e) +{ + if (e->type() == QEvent::Show && o->isWidgetType()) + { + auto* w = static_cast(o); + if (!w->parentWidget() && w->isModal()) + { + /* + To replace when baseline will include kwindowsystem >= 5.62 with: + w->setAttribute(Qt::WA_NativeWindow, true); + KWindowSystem::setMainWindow(w->windowHandle(), _winId); + */ + SAL_WNODEPRECATED_DECLARATIONS_PUSH + KWindowSystem::setMainWindow(w, _winId); + SAL_WNODEPRECATED_DECLARATIONS_POP + if (auto* fileWidget = w->findChild({}, Qt::FindDirectChildrenOnly)) + { + fileWidget->setCustomWidget(_extraControls); + // remove event filter again; the only purpose was to set the custom widget here + qApp->removeEventFilter(this); + } + } + } + return QObject::eventFilter(o, e); +} + +#include + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/kde5_filepicker.hxx b/vcl/unx/gtk3_kde5/kde5_filepicker.hxx new file mode 100644 index 0000000000..74f94d2221 --- /dev/null +++ b/vcl/unx/gtk3_kde5/kde5_filepicker.hxx @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include + +#include + +class QFileDialog; +class QWidget; +class QGridLayout; + +class KDE5FilePicker : public QObject +{ + Q_OBJECT +protected: + //the dialog to display + QFileDialog* _dialog; + + //running filter string to add to dialog + QStringList _filters; + // map of filter titles to full filter for selection + QHash _titleToFilters; + // string to set the current filter + QString _currentFilter; + + //mapping of SAL control ID's to created custom controls + QHash _customWidgets; + + //widget to contain extra custom controls + QWidget* _extraControls; + + //layout for extra custom controls + QGridLayout* _layout; + + sal_uInt64 _winId; + +public: + explicit KDE5FilePicker(QObject* parent = nullptr); + ~KDE5FilePicker() override; + + void enableFolderMode(); + + // XExecutableDialog functions + void setTitle(const QString& rTitle); + bool execute(); + + // XFilePicker functions + void setMultiSelectionMode(bool bMode); + void setDefaultName(const QString& rName); + void setDisplayDirectory(const QString& rDirectory); + QString getDisplayDirectory() const; + + // XFilterManager functions + void appendFilter(const QString& rTitle, const QString& rFilter); + void setCurrentFilter(const QString& rTitle); + QString getCurrentFilter() const; + + // XFilePickerControlAccess functions + void setValue(sal_Int16 nControlId, sal_Int16 nControlAction, bool rValue); + bool getValue(sal_Int16 nControlId, sal_Int16 nControlAction) const; + void enableControl(sal_Int16 nControlId, bool bEnable); + void setLabel(sal_Int16 nControlId, const QString& rLabel); + QString getLabel(sal_Int16 nControlId) const; + + // XFilePicker2 functions + QList getSelectedFiles() const; + + // XInitialization + void initialize(bool saveDialog); + + //add a custom control widget to the file dialog + void addCheckBox(sal_Int16 nControlId, const QString& label, bool hidden); + + void setWinId(sal_uInt64 winId); + +private: + Q_DISABLE_COPY(KDE5FilePicker) + // adds the custom controls to the dialog + void setupCustomWidgets(); + +protected: + bool eventFilter(QObject* watched, QEvent* event) override; + +Q_SIGNALS: + void filterChanged(); + void selectionChanged(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx b/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx new file mode 100644 index 0000000000..7f0bfff985 --- /dev/null +++ b/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx @@ -0,0 +1,374 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "kde5_filepicker_ipc.hxx" + +#include +#include +#include + +#include + +#include "kde5_filepicker.hxx" + +void readIpcArg(std::istream& stream, QString& string) +{ + const auto buffer = readIpcStringArg(stream); + string = QString::fromUtf8(buffer.data(), buffer.size()); +} + +void sendIpcArg(std::ostream& stream, const QString& string) +{ + const auto utf8 = string.toUtf8(); + sendIpcStringArg(stream, utf8.size(), utf8.data()); +} + +static void sendIpcArg(std::ostream& stream, const QStringList& list) +{ + stream << static_cast(list.size()) << ' '; + for (const auto& entry : list) + { + sendIpcArg(stream, entry); + } +} + +static void readCommandArgs(Commands command, QList& args) +{ + switch (command) + { + case Commands::SetTitle: + { + QString title; + readIpcArgs(std::cin, title); + args.append(title); + break; + } + case Commands::SetWinId: + { + sal_uIntPtr winId = 0; + readIpcArgs(std::cin, winId); + QVariant aWinIdVariant; + aWinIdVariant.setValue(winId); + args.append(aWinIdVariant); + break; + } + case Commands::SetMultiSelectionMode: + { + bool multiSelection = false; + readIpcArgs(std::cin, multiSelection); + args.append(multiSelection); + break; + } + case Commands::SetDefaultName: + { + QString name; + readIpcArgs(std::cin, name); + args.append(name); + break; + } + case Commands::SetDisplayDirectory: + { + QString dir; + readIpcArgs(std::cin, dir); + args.append(dir); + break; + } + case Commands::AppendFilter: + { + QString title, filter; + readIpcArgs(std::cin, title, filter); + args.append(title); + args.append(filter); + break; + } + case Commands::SetCurrentFilter: + { + QString title; + readIpcArgs(std::cin, title); + args.append(title); + break; + } + case Commands::SetValue: + { + sal_Int16 controlId = 0; + sal_Int16 nControlAction = 0; + bool value = false; + readIpcArgs(std::cin, controlId, nControlAction, value); + args.append(controlId); + args.append(nControlAction); + args.append(value); + break; + } + case Commands::GetValue: + { + sal_Int16 controlId = 0; + sal_Int16 nControlAction = 0; + readIpcArgs(std::cin, controlId, nControlAction); + args.append(controlId); + args.append(nControlAction); + break; + } + case Commands::EnableControl: + { + sal_Int16 controlId = 0; + bool enabled = false; + readIpcArgs(std::cin, controlId, enabled); + args.append(controlId); + args.append(enabled); + break; + } + case Commands::SetLabel: + { + sal_Int16 controlId = 0; + QString label; + readIpcArgs(std::cin, controlId, label); + args.append(controlId); + args.append(label); + break; + } + case Commands::GetLabel: + { + sal_Int16 controlId = 0; + readIpcArgs(std::cin, controlId); + args.append(controlId); + break; + } + case Commands::AddCheckBox: + { + sal_Int16 controlId = 0; + bool hidden = false; + QString label; + readIpcArgs(std::cin, controlId, hidden, label); + args.append(controlId); + args.append(hidden); + args.append(label); + break; + } + case Commands::Initialize: + { + bool saveDialog = false; + readIpcArgs(std::cin, saveDialog); + args.append(saveDialog); + break; + } + default: + { + // no extra parameters/arguments + break; + } + }; +} + +static void readCommands(FilePickerIpc* ipc) +{ + while (!std::cin.eof()) + { + uint64_t messageId = 0; + Commands command; + readIpcArgs(std::cin, messageId, command); + + // retrieve additional command-specific arguments + QList args; + readCommandArgs(command, args); + + emit ipc->commandReceived(messageId, command, args); + + // stop processing once 'Quit' command has been sent + if (command == Commands::Quit) + { + return; + } + } +} + +FilePickerIpc::FilePickerIpc(KDE5FilePicker* filePicker, QObject* parent) + : QObject(parent) + , m_filePicker(filePicker) +{ + // required to be able to pass those via signal/slot + qRegisterMetaType("uint64_t"); + qRegisterMetaType("Commands"); + + connect(this, &FilePickerIpc::commandReceived, this, &FilePickerIpc::handleCommand); + + // read IPC commands and their args in a separate thread, so this does not block everything else; + // 'commandReceived' signal is emitted every time a command and its args have been read; + // thread will run until the filepicker process is terminated + m_ipcReaderThread = std::make_unique(readCommands, this); +} + +FilePickerIpc::~FilePickerIpc() +{ + // join thread that reads commands + m_ipcReaderThread->join(); +}; + +bool FilePickerIpc::handleCommand(uint64_t messageId, Commands command, QList args) +{ + switch (command) + { + case Commands::SetTitle: + { + QString title = args.takeFirst().toString(); + m_filePicker->setTitle(title); + return true; + } + case Commands::SetWinId: + { + sal_uIntPtr winId = args.takeFirst().value(); + m_filePicker->setWinId(winId); + return true; + } + case Commands::Execute: + { + sendIpcArgs(std::cout, messageId, m_filePicker->execute()); + return true; + } + case Commands::SetMultiSelectionMode: + { + bool multiSelection = args.takeFirst().toBool(); + m_filePicker->setMultiSelectionMode(multiSelection); + return true; + } + case Commands::SetDefaultName: + { + QString name = args.takeFirst().toString(); + m_filePicker->setDefaultName(name); + return true; + } + case Commands::SetDisplayDirectory: + { + QString dir = args.takeFirst().toString(); + m_filePicker->setDisplayDirectory(dir); + return true; + } + case Commands::GetDisplayDirectory: + { + sendIpcArgs(std::cout, messageId, m_filePicker->getDisplayDirectory()); + return true; + } + case Commands::GetSelectedFiles: + { + QStringList files; + for (auto const& url_ : m_filePicker->getSelectedFiles()) + { + auto url = url_; + if (url.scheme() == QLatin1String("webdav") + || url.scheme() == QLatin1String("webdavs")) + { + // translate webdav and webdavs URLs into a format supported by LO + url.setScheme(QLatin1String("vnd.sun.star.") + url.scheme()); + } + else if (url.scheme() == QLatin1String("smb")) + { + // clear the user name - the GIO backend does not support this apparently + // when no username is available, it will ask for the password + url.setUserName({}); + } + files << url.toString(); + } + sendIpcArgs(std::cout, messageId, files); + return true; + } + case Commands::AppendFilter: + { + QString title = args.takeFirst().toString(); + QString filter = args.takeFirst().toString(); + m_filePicker->appendFilter(title, filter); + return true; + } + case Commands::SetCurrentFilter: + { + QString title = args.takeFirst().toString(); + m_filePicker->setCurrentFilter(title); + return true; + } + case Commands::GetCurrentFilter: + { + sendIpcArgs(std::cout, messageId, m_filePicker->getCurrentFilter()); + return true; + } + case Commands::SetValue: + { + sal_Int16 controlId = args.takeFirst().value(); + sal_Int16 nControlAction = args.takeFirst().value(); + bool value = args.takeFirst().toBool(); + m_filePicker->setValue(controlId, nControlAction, value); + return true; + } + case Commands::GetValue: + { + sal_Int16 controlId = args.takeFirst().value(); + sal_Int16 nControlAction = args.takeFirst().value(); + sendIpcArgs(std::cout, messageId, m_filePicker->getValue(controlId, nControlAction)); + return true; + } + case Commands::EnableControl: + { + sal_Int16 controlId = args.takeFirst().value(); + bool enabled = args.takeFirst().toBool(); + m_filePicker->enableControl(controlId, enabled); + return true; + } + case Commands::SetLabel: + { + sal_Int16 controlId = args.takeFirst().value(); + QString label = args.takeFirst().toString(); + m_filePicker->setLabel(controlId, label); + return true; + } + case Commands::GetLabel: + { + sal_Int16 controlId = args.takeFirst().value(); + sendIpcArgs(std::cout, messageId, m_filePicker->getLabel(controlId)); + return true; + } + case Commands::AddCheckBox: + { + sal_Int16 controlId = args.takeFirst().value(); + bool hidden = args.takeFirst().toBool(); + QString label = args.takeFirst().toString(); + m_filePicker->addCheckBox(controlId, label, hidden); + return true; + } + case Commands::Initialize: + { + bool saveDialog = args.takeFirst().toBool(); + m_filePicker->initialize(saveDialog); + return true; + } + case Commands::EnablePickFolderMode: + { + m_filePicker->enableFolderMode(); + return true; + } + case Commands::Quit: + { + QCoreApplication::quit(); + return false; + } + } + qWarning() << "unhandled command " << static_cast(command); + QCoreApplication::exit(1); + return false; +} + +#include + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.hxx b/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.hxx new file mode 100644 index 0000000000..fa9be696c5 --- /dev/null +++ b/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +#include + +#include "filepicker_ipc_commands.hxx" + +class KDE5FilePicker; +class WinIdEmbedder; +class QSocketNotifier; + +class FilePickerIpc : public QObject +{ + Q_OBJECT +public: + explicit FilePickerIpc(KDE5FilePicker* filePicker, QObject* parent = nullptr); + ~FilePickerIpc() override; + +private: + KDE5FilePicker* m_filePicker = nullptr; + std::unique_ptr m_ipcReaderThread; + +private Q_SLOTS: + bool handleCommand(uint64_t messageId, Commands command, QList args); + +Q_SIGNALS: + bool commandReceived(uint64_t messageId, Commands command, QList args); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk3_kde5/kde5_lo_filepicker_main.cxx b/vcl/unx/gtk3_kde5/kde5_lo_filepicker_main.cxx new file mode 100644 index 0000000000..4e73e9ee45 --- /dev/null +++ b/vcl/unx/gtk3_kde5/kde5_lo_filepicker_main.cxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "kde5_filepicker.hxx" +#include "kde5_filepicker_ipc.hxx" + +#include +#include + +#include + +int main(int argc, char** argv) +{ + QApplication::setOrganizationName("LibreOffice"); + QApplication::setOrganizationDomain("libreoffice.org"); + QApplication::setApplicationName(QStringLiteral("lo_kde5filepicker")); + QApplication::setQuitOnLastWindowClosed(false); + QApplication::setApplicationVersion(LIBO_VERSION_DOTTED); + + QApplication app(argc, argv); + + QCommandLineParser parser; + parser.setApplicationDescription( + QObject::tr("Helper executable for LibreOffice KDE/Plasma integration.\n" + "Do not run this executable directly. Rather, use it indirectly via " + "the gtk3_kde5 VCL plugin (SAL_USE_VCLPLUGIN=gtk3_kde5).")); + parser.addVersionOption(); + parser.addHelpOption(); + parser.process(app); + + KDE5FilePicker filePicker; + FilePickerIpc ipc(&filePicker); + + return QApplication::exec(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3