From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- include/sfx2/AccessibilityCheck.hxx | 34 + include/sfx2/AccessibilityIssue.hxx | 59 ++ include/sfx2/DocumentMetadataAccess.hxx | 152 ++++ include/sfx2/DocumentSigner.hxx | 47 ++ include/sfx2/LokControlHandler.hxx | 155 ++++ include/sfx2/Metadatable.hxx | 170 ++++ include/sfx2/QuerySaveDocument.hxx | 43 + include/sfx2/StyleManager.hxx | 51 ++ include/sfx2/StylePreviewRenderer.hxx | 57 ++ include/sfx2/XmlIdRegistry.hxx | 67 ++ include/sfx2/app.hxx | 233 ++++++ include/sfx2/basedlgs.hxx | 136 +++ include/sfx2/bindings.hxx | 208 +++++ include/sfx2/brokenpackageint.hxx | 63 ++ include/sfx2/chalign.hxx | 55 ++ include/sfx2/charwin.hxx | 72 ++ include/sfx2/childwin.hxx | 235 ++++++ include/sfx2/classificationhelper.hxx | 227 +++++ include/sfx2/ctrlitem.hxx | 97 +++ .../sfx2/devtools/DevelopmentToolChildWindow.hxx | 27 + .../sfx2/devtools/DevelopmentToolDockingWindow.hxx | 72 ++ include/sfx2/devtools/DocumentModelTreeHandler.hxx | 52 ++ .../sfx2/devtools/ObjectInspectorTreeHandler.hxx | 101 +++ include/sfx2/devtools/ObjectInspectorWidgets.hxx | 55 ++ include/sfx2/dialoghelper.hxx | 41 + include/sfx2/digitalsignatures.hxx | 38 + include/sfx2/dinfdlg.hxx | 579 +++++++++++++ include/sfx2/dispatch.hxx | 184 +++++ include/sfx2/dllapi.h | 36 + include/sfx2/docfac.hxx | 96 +++ include/sfx2/docfile.hxx | 309 +++++++ include/sfx2/docfilt.hxx | 125 +++ include/sfx2/docinf.hxx | 75 ++ include/sfx2/docinsert.hxx | 77 ++ include/sfx2/dockwin.hxx | 130 +++ include/sfx2/docmacromode.hxx | 307 +++++++ include/sfx2/docstoragemodifylistener.hxx | 82 ++ include/sfx2/doctempl.hxx | 117 +++ include/sfx2/event.hxx | 268 ++++++ include/sfx2/evntconf.hxx | 102 +++ include/sfx2/fcontnr.hxx | 119 +++ include/sfx2/filedlghelper.hxx | 313 +++++++ include/sfx2/flatpak.hxx | 33 + include/sfx2/frame.hxx | 203 +++++ include/sfx2/frmdescr.hxx | 102 +++ include/sfx2/frmhtml.hxx | 38 + include/sfx2/frmhtmlw.hxx | 71 ++ include/sfx2/groupid.hxx | 74 ++ include/sfx2/htmlmode.hxx | 31 + include/sfx2/infobar.hxx | 140 ++++ include/sfx2/inputdlg.hxx | 38 + include/sfx2/ipclient.hxx | 101 +++ include/sfx2/linkmgr.hxx | 187 +++++ include/sfx2/linksrc.hxx | 118 +++ include/sfx2/listview.hxx | 116 +++ include/sfx2/lnkbase.hxx | 179 ++++ include/sfx2/lokcallback.hxx | 51 ++ include/sfx2/lokcomponenthelpers.hxx | 90 ++ include/sfx2/lokhelper.hxx | 171 ++++ include/sfx2/mailmodelapi.hxx | 104 +++ include/sfx2/mieclip.hxx | 43 + include/sfx2/minfitem.hxx | 70 ++ include/sfx2/module.hxx | 103 +++ include/sfx2/msg.hxx | 264 ++++++ include/sfx2/msgpool.hxx | 74 ++ include/sfx2/navigat.hxx | 43 + include/sfx2/new.hxx | 108 +++ include/sfx2/newstyle.hxx | 55 ++ include/sfx2/notebookbar/SfxNotebookBar.hxx | 89 ++ include/sfx2/objface.hxx | 121 +++ include/sfx2/objitem.hxx | 48 ++ include/sfx2/objsh.hxx | 918 +++++++++++++++++++++ include/sfx2/opengrf.hxx | 72 ++ include/sfx2/pageids.hxx | 71 ++ include/sfx2/passwd.hxx | 130 +++ include/sfx2/printer.hxx | 62 ++ include/sfx2/printopt.hxx | 86 ++ include/sfx2/progress.hxx | 63 ++ include/sfx2/request.hxx | 129 +++ include/sfx2/safemode.hxx | 73 ++ include/sfx2/sfxbasecontroller.hxx | 218 +++++ include/sfx2/sfxbasemodel.hxx | 753 +++++++++++++++++ include/sfx2/sfxdlg.hxx | 155 ++++ include/sfx2/sfxhelp.hxx | 64 ++ include/sfx2/sfxhtml.hxx | 113 +++ include/sfx2/sfxmodelfactory.hxx | 66 ++ include/sfx2/sfxresid.hxx | 30 + include/sfx2/sfxsids.hrc | 739 +++++++++++++++++ include/sfx2/sfxstatuslistener.hxx | 74 ++ include/sfx2/sfxuno.hxx | 50 ++ include/sfx2/shell.hxx | 587 +++++++++++++ include/sfx2/sidebar/AsynchronousCall.hxx | 52 ++ include/sfx2/sidebar/Context.hxx | 58 ++ include/sfx2/sidebar/ControllerItem.hxx | 79 ++ include/sfx2/sidebar/Deck.hxx | 87 ++ include/sfx2/sidebar/FocusManager.hxx | 140 ++++ include/sfx2/sidebar/IContextChangeReceiver.hxx | 40 + include/sfx2/sidebar/ILayoutableWindow.hxx | 40 + include/sfx2/sidebar/Panel.hxx | 123 +++ include/sfx2/sidebar/PanelLayout.hxx | 52 ++ include/sfx2/sidebar/ResourceManager.hxx | 132 +++ include/sfx2/sidebar/Sidebar.hxx | 67 ++ include/sfx2/sidebar/SidebarChildWindow.hxx | 46 ++ include/sfx2/sidebar/SidebarController.hxx | 302 +++++++ include/sfx2/sidebar/SidebarDockingWindow.hxx | 66 ++ include/sfx2/sidebar/SidebarModelUpdate.hxx | 33 + include/sfx2/sidebar/SidebarPanelBase.hxx | 102 +++ include/sfx2/sidebar/TabBar.hxx | 136 +++ include/sfx2/sidebar/Theme.hxx | 184 +++++ include/sfx2/signaturestate.hxx | 54 ++ include/sfx2/stbitem.hxx | 134 +++ include/sfx2/strings.hrc | 361 ++++++++ include/sfx2/styfitem.hxx | 62 ++ include/sfx2/styledlg.hxx | 52 ++ include/sfx2/tabdlg.hxx | 269 ++++++ include/sfx2/tbxctrl.hxx | 142 ++++ include/sfx2/templatedlg.hxx | 193 +++++ include/sfx2/templatedlglocalview.hxx | 72 ++ include/sfx2/templatelocalview.hxx | 192 +++++ include/sfx2/templateproperties.hxx | 29 + include/sfx2/templdlg.hxx | 46 ++ include/sfx2/thumbnailview.hxx | 331 ++++++++ include/sfx2/thumbnailviewitem.hxx | 138 ++++ include/sfx2/toolbarids.hxx | 77 ++ include/sfx2/tplpitem.hxx | 53 ++ include/sfx2/userinputinterception.hxx | 82 ++ include/sfx2/viewfac.hxx | 60 ++ include/sfx2/viewfrm.hxx | 277 +++++++ include/sfx2/viewsh.hxx | 435 ++++++++++ include/sfx2/watermarkitem.hxx | 47 ++ include/sfx2/weldutils.hxx | 67 ++ include/sfx2/xmldump.hxx | 29 + include/sfx2/zoomitem.hxx | 81 ++ 133 files changed, 17806 insertions(+) create mode 100644 include/sfx2/AccessibilityCheck.hxx create mode 100644 include/sfx2/AccessibilityIssue.hxx create mode 100644 include/sfx2/DocumentMetadataAccess.hxx create mode 100644 include/sfx2/DocumentSigner.hxx create mode 100644 include/sfx2/LokControlHandler.hxx create mode 100644 include/sfx2/Metadatable.hxx create mode 100644 include/sfx2/QuerySaveDocument.hxx create mode 100644 include/sfx2/StyleManager.hxx create mode 100644 include/sfx2/StylePreviewRenderer.hxx create mode 100644 include/sfx2/XmlIdRegistry.hxx create mode 100644 include/sfx2/app.hxx create mode 100644 include/sfx2/basedlgs.hxx create mode 100644 include/sfx2/bindings.hxx create mode 100644 include/sfx2/brokenpackageint.hxx create mode 100644 include/sfx2/chalign.hxx create mode 100644 include/sfx2/charwin.hxx create mode 100644 include/sfx2/childwin.hxx create mode 100644 include/sfx2/classificationhelper.hxx create mode 100644 include/sfx2/ctrlitem.hxx create mode 100644 include/sfx2/devtools/DevelopmentToolChildWindow.hxx create mode 100644 include/sfx2/devtools/DevelopmentToolDockingWindow.hxx create mode 100644 include/sfx2/devtools/DocumentModelTreeHandler.hxx create mode 100644 include/sfx2/devtools/ObjectInspectorTreeHandler.hxx create mode 100644 include/sfx2/devtools/ObjectInspectorWidgets.hxx create mode 100644 include/sfx2/dialoghelper.hxx create mode 100644 include/sfx2/digitalsignatures.hxx create mode 100644 include/sfx2/dinfdlg.hxx create mode 100644 include/sfx2/dispatch.hxx create mode 100644 include/sfx2/dllapi.h create mode 100644 include/sfx2/docfac.hxx create mode 100644 include/sfx2/docfile.hxx create mode 100644 include/sfx2/docfilt.hxx create mode 100644 include/sfx2/docinf.hxx create mode 100644 include/sfx2/docinsert.hxx create mode 100644 include/sfx2/dockwin.hxx create mode 100644 include/sfx2/docmacromode.hxx create mode 100644 include/sfx2/docstoragemodifylistener.hxx create mode 100644 include/sfx2/doctempl.hxx create mode 100644 include/sfx2/event.hxx create mode 100644 include/sfx2/evntconf.hxx create mode 100644 include/sfx2/fcontnr.hxx create mode 100644 include/sfx2/filedlghelper.hxx create mode 100644 include/sfx2/flatpak.hxx create mode 100644 include/sfx2/frame.hxx create mode 100644 include/sfx2/frmdescr.hxx create mode 100644 include/sfx2/frmhtml.hxx create mode 100644 include/sfx2/frmhtmlw.hxx create mode 100644 include/sfx2/groupid.hxx create mode 100644 include/sfx2/htmlmode.hxx create mode 100644 include/sfx2/infobar.hxx create mode 100644 include/sfx2/inputdlg.hxx create mode 100644 include/sfx2/ipclient.hxx create mode 100644 include/sfx2/linkmgr.hxx create mode 100644 include/sfx2/linksrc.hxx create mode 100644 include/sfx2/listview.hxx create mode 100644 include/sfx2/lnkbase.hxx create mode 100644 include/sfx2/lokcallback.hxx create mode 100644 include/sfx2/lokcomponenthelpers.hxx create mode 100644 include/sfx2/lokhelper.hxx create mode 100644 include/sfx2/mailmodelapi.hxx create mode 100644 include/sfx2/mieclip.hxx create mode 100644 include/sfx2/minfitem.hxx create mode 100644 include/sfx2/module.hxx create mode 100644 include/sfx2/msg.hxx create mode 100644 include/sfx2/msgpool.hxx create mode 100644 include/sfx2/navigat.hxx create mode 100644 include/sfx2/new.hxx create mode 100644 include/sfx2/newstyle.hxx create mode 100644 include/sfx2/notebookbar/SfxNotebookBar.hxx create mode 100644 include/sfx2/objface.hxx create mode 100644 include/sfx2/objitem.hxx create mode 100644 include/sfx2/objsh.hxx create mode 100644 include/sfx2/opengrf.hxx create mode 100644 include/sfx2/pageids.hxx create mode 100644 include/sfx2/passwd.hxx create mode 100644 include/sfx2/printer.hxx create mode 100644 include/sfx2/printopt.hxx create mode 100644 include/sfx2/progress.hxx create mode 100644 include/sfx2/request.hxx create mode 100644 include/sfx2/safemode.hxx create mode 100644 include/sfx2/sfxbasecontroller.hxx create mode 100644 include/sfx2/sfxbasemodel.hxx create mode 100644 include/sfx2/sfxdlg.hxx create mode 100644 include/sfx2/sfxhelp.hxx create mode 100644 include/sfx2/sfxhtml.hxx create mode 100644 include/sfx2/sfxmodelfactory.hxx create mode 100644 include/sfx2/sfxresid.hxx create mode 100644 include/sfx2/sfxsids.hrc create mode 100644 include/sfx2/sfxstatuslistener.hxx create mode 100644 include/sfx2/sfxuno.hxx create mode 100644 include/sfx2/shell.hxx create mode 100644 include/sfx2/sidebar/AsynchronousCall.hxx create mode 100644 include/sfx2/sidebar/Context.hxx create mode 100644 include/sfx2/sidebar/ControllerItem.hxx create mode 100644 include/sfx2/sidebar/Deck.hxx create mode 100644 include/sfx2/sidebar/FocusManager.hxx create mode 100644 include/sfx2/sidebar/IContextChangeReceiver.hxx create mode 100644 include/sfx2/sidebar/ILayoutableWindow.hxx create mode 100644 include/sfx2/sidebar/Panel.hxx create mode 100644 include/sfx2/sidebar/PanelLayout.hxx create mode 100644 include/sfx2/sidebar/ResourceManager.hxx create mode 100644 include/sfx2/sidebar/Sidebar.hxx create mode 100644 include/sfx2/sidebar/SidebarChildWindow.hxx create mode 100644 include/sfx2/sidebar/SidebarController.hxx create mode 100644 include/sfx2/sidebar/SidebarDockingWindow.hxx create mode 100644 include/sfx2/sidebar/SidebarModelUpdate.hxx create mode 100644 include/sfx2/sidebar/SidebarPanelBase.hxx create mode 100644 include/sfx2/sidebar/TabBar.hxx create mode 100644 include/sfx2/sidebar/Theme.hxx create mode 100644 include/sfx2/signaturestate.hxx create mode 100644 include/sfx2/stbitem.hxx create mode 100644 include/sfx2/strings.hrc create mode 100644 include/sfx2/styfitem.hxx create mode 100644 include/sfx2/styledlg.hxx create mode 100644 include/sfx2/tabdlg.hxx create mode 100644 include/sfx2/tbxctrl.hxx create mode 100644 include/sfx2/templatedlg.hxx create mode 100644 include/sfx2/templatedlglocalview.hxx create mode 100644 include/sfx2/templatelocalview.hxx create mode 100644 include/sfx2/templateproperties.hxx create mode 100644 include/sfx2/templdlg.hxx create mode 100644 include/sfx2/thumbnailview.hxx create mode 100644 include/sfx2/thumbnailviewitem.hxx create mode 100644 include/sfx2/toolbarids.hxx create mode 100644 include/sfx2/tplpitem.hxx create mode 100644 include/sfx2/userinputinterception.hxx create mode 100644 include/sfx2/viewfac.hxx create mode 100644 include/sfx2/viewfrm.hxx create mode 100644 include/sfx2/viewsh.hxx create mode 100644 include/sfx2/watermarkitem.hxx create mode 100644 include/sfx2/weldutils.hxx create mode 100644 include/sfx2/xmldump.hxx create mode 100644 include/sfx2/zoomitem.hxx (limited to 'include/sfx2') diff --git a/include/sfx2/AccessibilityCheck.hxx b/include/sfx2/AccessibilityCheck.hxx new file mode 100644 index 000000000..4c90ad31d --- /dev/null +++ b/include/sfx2/AccessibilityCheck.hxx @@ -0,0 +1,34 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include +#include + +namespace sfx +{ +class SFX2_DLLPUBLIC AccessibilityCheck +{ +protected: + AccessibilityIssueCollection m_aIssueCollection; + +public: + AccessibilityCheck() = default; + virtual ~AccessibilityCheck(); + + virtual void check() = 0; + + AccessibilityIssueCollection& getIssueCollection(); +}; + +} // end sfx namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/AccessibilityIssue.hxx b/include/sfx2/AccessibilityIssue.hxx new file mode 100644 index 000000000..4cc9a72e7 --- /dev/null +++ b/include/sfx2/AccessibilityIssue.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/. + * + */ + +#pragma once + +#include +#include +#include +#include + +namespace sfx +{ +enum class AccessibilityIssueID +{ + UNSPECIFIED, // TODO: remove - temporary + DOCUMENT_TITLE, + DOCUMENT_LANGUAGE, + STYLE_LANGUAGE, + NO_ALT_OLE, + NO_ALT_GRAPHIC, + NO_ALT_SHAPE, + TABLE_MERGE_SPLIT, + TEXT_FORMATTING, +}; + +class SFX2_DLLPUBLIC AccessibilityIssue +{ +public: + AccessibilityIssue(AccessibilityIssueID eIssueID = AccessibilityIssueID::UNSPECIFIED); + virtual ~AccessibilityIssue(); + + virtual bool canGotoIssue() const = 0; + virtual void gotoIssue() const = 0; + + AccessibilityIssueID m_eIssueID; + OUString m_aIssueText; +}; + +class SFX2_DLLPUBLIC AccessibilityIssueCollection +{ +private: + std::vector> m_aIssues; + +public: + AccessibilityIssueCollection() = default; + + std::vector>& getIssues(); +}; + +} // end sfx namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/DocumentMetadataAccess.hxx b/include/sfx2/DocumentMetadataAccess.hxx new file mode 100644 index 000000000..bcbf9f1b3 --- /dev/null +++ b/include/sfx2/DocumentMetadataAccess.hxx @@ -0,0 +1,152 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_DOCUMENTMETADATAACCESS_HXX +#define INCLUDED_SFX2_DOCUMENTMETADATAACCESS_HXX + +#include + +#include + +#include + +#include + +#include + + +/** Implementation of the interface com.sun.star.rdf.XDocumentMetadataAccess + + This is not a service only because it needs some kind of XML ID registry + from the document, and i do not like defining an API for that. + Also, the implementation does _no_ locking, so make sure access is + protected externally. + */ + +namespace com::sun::star::embed { + class XStorage; +} +namespace com::sun::star::frame { + class XModel; +} + +namespace com::sun::star::uno { class XComponentContext; } + +class SfxObjectShell; + +namespace sfx2 { + + +/** create a base URI for loading metadata from an ODF (sub)document. + + @param i_xContext component context + @param i_xModel model of the document (required if no URI is provided) + @param i_rPkgURI the URI for the package + @param i_rSubDocument (optional) path of the subdocument in package + + @return a base URI suitable for XDocumentMetadataAccess::loadFromStorage + */ +css::uno::Reference< css::rdf::XURI> SFX2_DLLPUBLIC +createBaseURI( + css::uno::Reference const & i_xContext, + css::uno::Reference const & i_xModel, + OUString const & i_rPkgURI, + std::u16string_view i_rSubDocument = std::u16string_view()); + + +struct DocumentMetadataAccess_Impl; + +class DocumentMetadataAccess final : + public cppu::WeakImplHelper +{ + DocumentMetadataAccess(const DocumentMetadataAccess&) = delete; + DocumentMetadataAccess& operator=( const DocumentMetadataAccess& ) = delete; +public: + explicit DocumentMetadataAccess(css::uno::Reference< css::uno::XComponentContext > const & i_xContext, + SfxObjectShell const & i_rRegistrySupplier, + OUString const & i_rBaseURI); + // N.B.: in contrast to previous, this constructor does _not_ initialize! + // caller must immediately call loadFromStorage/Medium! + explicit DocumentMetadataAccess(css::uno::Reference< css::uno::XComponentContext > const & i_xContext, + SfxObjectShell const & i_rRegistrySupplier); + virtual ~DocumentMetadataAccess() override; + + // css::rdf::XNode: + virtual OUString SAL_CALL getStringValue() override; + + // css::rdf::XURI: + virtual OUString SAL_CALL getNamespace() override; + virtual OUString SAL_CALL getLocalName() override; + + // css::rdf::XRepositorySupplier: + virtual css::uno::Reference< + css::rdf::XRepository > SAL_CALL getRDFRepository() override; + + // css::rdf::XDocumentMetadataAccess: + virtual css::uno::Reference< + css::rdf::XMetadatable > SAL_CALL + getElementByMetadataReference( + const css::beans::StringPair & i_rReference) override; + virtual css::uno::Reference< css::rdf::XMetadatable > SAL_CALL + getElementByURI(const css::uno::Reference< css::rdf::XURI > & i_xURI) override; + virtual css::uno::Sequence< css::uno::Reference< css::rdf::XURI > > SAL_CALL getMetadataGraphsWithType( + const css::uno::Reference< css::rdf::XURI > & i_xType) override; + virtual css::uno::Reference< css::rdf::XURI> SAL_CALL + addMetadataFile(const OUString & i_rFileName, + const css::uno::Sequence< css::uno::Reference< css::rdf::XURI > > & i_rTypes) override; + virtual css::uno::Reference< css::rdf::XURI> SAL_CALL + importMetadataFile(::sal_Int16 i_Format, + const css::uno::Reference< css::io::XInputStream > & i_xInStream, + const OUString & i_rFileName, + const css::uno::Reference< css::rdf::XURI > & i_xBaseURI, + const css::uno::Sequence< css::uno::Reference< css::rdf::XURI > > & i_rTypes) override; + virtual void SAL_CALL removeMetadataFile( + const css::uno::Reference< + css::rdf::XURI > & i_xGraphName) override; + virtual void SAL_CALL addContentOrStylesFile( + const OUString & i_rFileName) override; + virtual void SAL_CALL removeContentOrStylesFile( + const OUString & i_rFileName) override; + + virtual void SAL_CALL loadMetadataFromStorage( + const css::uno::Reference< + css::embed::XStorage > & i_xStorage, + const css::uno::Reference< + css::rdf::XURI > & i_xBaseURI, + const css::uno::Reference< + css::task::XInteractionHandler> & i_xHandler) override; + virtual void SAL_CALL storeMetadataToStorage( + const css::uno::Reference< + css::embed::XStorage > & i_xStorage) override; + virtual void SAL_CALL loadMetadataFromMedium( + const css::uno::Sequence< + css::beans::PropertyValue > & i_rMedium) override; + virtual void SAL_CALL storeMetadataToMedium( + const css::uno::Sequence< + css::beans::PropertyValue > & i_rMedium) override; + +private: + std::unique_ptr m_pImpl; +}; + +} // namespace sfx2 + +#endif // INCLUDED_SFX2_DOCUMENTMETADATAACCESS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/DocumentSigner.hxx b/include/sfx2/DocumentSigner.hxx new file mode 100644 index 000000000..8059cb9cb --- /dev/null +++ b/include/sfx2/DocumentSigner.hxx @@ -0,0 +1,47 @@ +/* -*- 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/. + * + */ + +#ifndef INCLUDED_SFX2_DOCUMENTSIGNER_HXX +#define INCLUDED_SFX2_DOCUMENTSIGNER_HXX + +#include +#include +#include + +namespace com::sun::star::security +{ +class XCertificate; +} +namespace com::sun::star::uno +{ +template class Reference; +} + +namespace sfx2 +{ +class SFX2_DLLPUBLIC DocumentSigner +{ +private: + OUString m_aUrl; + +public: + DocumentSigner(OUString const& rUrl) + : m_aUrl(rUrl) + { + } + + bool signDocument(css::uno::Reference const& rxCertificate); +}; + +} // namespace sfx2 + +#endif // INCLUDED_SFX2_DOCUMENTSIGNER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/LokControlHandler.hxx b/include/sfx2/LokControlHandler.hxx new file mode 100644 index 000000000..c422afc97 --- /dev/null +++ b/include/sfx2/LokControlHandler.hxx @@ -0,0 +1,155 @@ +/* -*- 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/. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class LokControlHandler +{ +public: + static bool postMouseEvent(const SdrPage* pPage, const SdrView* pDrawView, + vcl::Window const& rMainWindow, int nType, Point aPointHmm, + int nCount, int nButtons, int nModifier) + { + SdrObjListIter aIterator(pPage, SdrIterMode::Flat); + while (aIterator.IsMore()) + { + SdrObject* pObject = aIterator.Next(); + SdrUnoObj* pUnoObect = dynamic_cast(pObject); + if (pUnoObect) + { + tools::Rectangle aControlRectHMM = pUnoObect->GetLogicRect(); + if (aControlRectHMM.Contains(aPointHmm)) + { + css::uno::Reference xControl + = pUnoObect->GetUnoControl(*pDrawView, *rMainWindow.GetOutDev()); + if (!xControl.is()) + return false; + + css::uno::Reference xControlWindow(xControl, + css::uno::UNO_QUERY); + if (!xControlWindow.is()) + return false; + + css::uno::Reference xWindowPeer(xControl->getPeer()); + + VclPtr pWindow = VCLUnoHelper::GetWindow(xWindowPeer); + if (pWindow) + { + Point aControlRelativePositionHMM = aPointHmm - aControlRectHMM.TopLeft(); + Point aControlRelativePosition = o3tl::convert( + aControlRelativePositionHMM, o3tl::Length::mm100, o3tl::Length::px); + + LokMouseEventData aMouseEventData(nType, aControlRelativePosition, nCount, + MouseEventModifiers::SIMPLECLICK, + nButtons, nModifier); + + SfxLokHelper::postMouseEventAsync(pWindow, aMouseEventData); + return true; + } + } + } + } + return false; + } + + static void drawUnoControl(const SdrView* pDrawView, const SdrUnoObj* pUnoObect, + vcl::Window const& rMainWindow, VirtualDevice& rDevice, + tools::Rectangle const& rTileRectHMM, double scaleX, double scaleY) + { + css::uno::Reference xControl + = pUnoObect->GetUnoControl(*pDrawView, *rMainWindow.GetOutDev()); + if (!xControl.is()) + return; + + css::uno::Reference xControlWindow(xControl, css::uno::UNO_QUERY); + if (!xControlWindow.is()) + return; + + css::uno::Reference xGraphics(rDevice.CreateUnoGraphics()); + if (!xGraphics.is()) + return; + + css::uno::Reference xControlView(xControl, css::uno::UNO_QUERY); + if (!xControlView.is()) + return; + + tools::Rectangle aObjectRectHMM = pUnoObect->GetLogicRect(); + Point aOffsetFromTile(aObjectRectHMM.Left() - rTileRectHMM.Left(), + aObjectRectHMM.Top() - rTileRectHMM.Top()); + tools::Rectangle aRectangleHMM(aOffsetFromTile, aObjectRectHMM.GetSize()); + tools::Rectangle aRectanglePx + = o3tl::convert(aRectangleHMM, o3tl::Length::mm100, o3tl::Length::px); + + xControlWindow->setPosSize(0, 0, aRectanglePx.GetWidth(), aRectanglePx.GetHeight(), + css::awt::PosSize::POSSIZE); + + xControlView->setGraphics(xGraphics); + + xControlView->draw(aRectanglePx.Left() * scaleX, aRectanglePx.Top() * scaleY); + } + + static void paintControlTile(const SdrPage* pPage, const SdrView* pDrawView, + vcl::Window const& rMainWindow, VirtualDevice& rDevice, + Size aOutputSize, tools::Rectangle const& rTileRect) + { + tools::Rectangle aTileRectHMM + = o3tl::convert(rTileRect, o3tl::Length::twip, o3tl::Length::mm100); + + // Resizes the virtual device so to contain the entries context + rDevice.SetOutputSizePixel(aOutputSize); + + rDevice.Push(vcl::PushFlags::MAPMODE); + MapMode aDeviceMapMode(rDevice.GetMapMode()); + + const Fraction scale = conversionFract(o3tl::Length::px, o3tl::Length::mm100); + Fraction scaleX = Fraction(aOutputSize.Width(), aTileRectHMM.GetWidth()) * scale; + Fraction scaleY = Fraction(aOutputSize.Height(), aTileRectHMM.GetHeight()) * scale; + aDeviceMapMode.SetScaleX(scaleX); + aDeviceMapMode.SetScaleY(scaleY); + rDevice.SetMapMode(aDeviceMapMode); + + SdrObjListIter aIterator(pPage, SdrIterMode::Flat); + + while (aIterator.IsMore()) + { + SdrObject* pObject = aIterator.Next(); + SdrUnoObj* pUnoObect = dynamic_cast(pObject); + if (pUnoObect) + { + tools::Rectangle aObjectRectHMM = pUnoObect->GetLogicRect(); + + // Check if we intersect with the tile rectangle and we + // need to draw the control. + if (aObjectRectHMM.Overlaps(aTileRectHMM)) + { + drawUnoControl(pDrawView, pUnoObect, rMainWindow, rDevice, aTileRectHMM, + double(scaleX), double(scaleY)); + } + } + } + + rDevice.Pop(); + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/Metadatable.hxx b/include/sfx2/Metadatable.hxx new file mode 100644 index 000000000..a84bddb89 --- /dev/null +++ b/include/sfx2/Metadatable.hxx @@ -0,0 +1,170 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_METADATABLE_HXX +#define INCLUDED_SFX2_METADATABLE_HXX + +#include + +#include + +#include +#include + +#include + + +namespace com::sun::star { + namespace frame { class XModel; } +} + +namespace sfx2 { + class IXmlIdRegistry; +} + +namespace sfx2 { + +class XmlIdRegistry; +class MetadatableUndo; + + +// XML ID handling --------------------------------------------------- + + +/// create a sfx2::XmlIdRegistryDocument or a sfx2::XmlIdRegistryClipboard +SFX2_DLLPUBLIC ::sfx2::IXmlIdRegistry * +createXmlIdRegistry(const bool i_DocIsClipboard); + + +/** base class for core objects that may have xml:id. + +

The interface of this class consists of 3 parts: +

  • implementations that are used by the MetadatableMixin + below
  • +
  • hooks to be called by the sw core whenever actions that are + relevant to the uniqueness of xml:ids are taken (copying, + splitting, merging, deletion, undo, etc.)
  • +
  • abstract methods that are called by the implementation of the + previous hooks
+

+ */ +class SFX2_DLLPUBLIC Metadatable +{ +public: + Metadatable() : m_pReg(nullptr) {} + + // destructor calls RemoveMetadataReference + virtual ~Metadatable(); + + // for MetadatableMixin ---------------------------------------------- + + css::beans::StringPair GetMetadataReference() const; + void SetMetadataReference( const css::beans::StringPair & i_rReference); + void EnsureMetadataReference(); + + // hooks ------------------------------------------------------------- + + // called from dtor! + void RemoveMetadataReference(); + + /** register this as a copy of i_rSource */ + void RegisterAsCopyOf(Metadatable const & i_rSource, + const bool i_bCopyPrecedesSource = false); + + /** create an Undo Metadatable, which remembers this' reference */ + std::shared_ptr CreateUndo() const; + std::shared_ptr CreateUndoForDelete(); + + /** restore this from Undo Metadatable */ + void RestoreMetadata(std::shared_ptr const& i_pUndo); + + /** merge this and i_rOther into this */ + void JoinMetadatable(Metadatable const & i_rOther, + const bool i_isMergedEmpty, const bool i_isOtherEmpty); + + // abstract methods -------------------------------------------------- + + /** get the registry from the SwDoc */ + virtual ::sfx2::IXmlIdRegistry& GetRegistry() = 0; + + /** is this in a clipboard document? */ + virtual bool IsInClipboard() const = 0; + + /** is this in undo array? */ + virtual bool IsInUndo() const = 0; + + /** which stream is this in? true: content.xml; false: styles.xml */ + virtual bool IsInContent() const = 0; + + /** create XMetadatable from this. + note: if IsInUndo or IsInClipboard return true, + MakeUnoObject must not be called! + */ + virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() = 0; + +private: + Metadatable(const Metadatable&) = delete; + Metadatable& operator=(const Metadatable&) = delete; + + friend class MetadatableClipboard; + friend class MetadatableUndo; + + // note that Reg may be a XmlIdRegistryDocument or a XmlIdRegistryClipboard + XmlIdRegistry* m_pReg; // null => no XmlId +}; + + +/** base class for UNO objects that implement XMetadatable. + +

An instance of this base class is associated with an instance of + Metadatable.

+ */ +class SFX2_DLLPUBLIC MetadatableMixin : + public cppu::WeakImplHelper +{ + +public: + MetadatableMixin() {}; + + // css::rdf::XNode: + virtual OUString SAL_CALL getStringValue() override; + + // css::rdf::XURI: + virtual OUString SAL_CALL getLocalName() override; + virtual OUString SAL_CALL getNamespace() override; + + // css::rdf::XMetadatable: + virtual css::beans::StringPair SAL_CALL getMetadataReference() override; + virtual void SAL_CALL setMetadataReference( + const css::beans::StringPair & i_rReference) override; + virtual void SAL_CALL ensureMetadataReference() override; + +protected: + /// get the core object corresponding to this UNO object. + virtual Metadatable * GetCoreObject() = 0; + /// get the XModel for the document + virtual css::uno::Reference< css::frame::XModel > + GetModel() = 0; + +}; + +} // namespace sfx2 + +#endif // INCLUDED_SFX2_METADATABLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/QuerySaveDocument.hxx b/include/sfx2/QuerySaveDocument.hxx new file mode 100644 index 000000000..2d800be80 --- /dev/null +++ b/include/sfx2/QuerySaveDocument.hxx @@ -0,0 +1,43 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_QUERYSAVEDOCUMENT_HXX +#define INCLUDED_SFX2_QUERYSAVEDOCUMENT_HXX + +#include + +#include + +#include + +namespace weld +{ +class Widget; +} + +/** Opens the general query save document dialog. + @param _pParent + The parent window. + @_rTitle + The title of the document. +*/ +SFX2_DLLPUBLIC short ExecuteQuerySaveDocument(weld::Widget* _pParent, std::u16string_view _rTitle); + +#endif // INCLUDED_SFX2_QUERYSAVEDOCUMENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/StyleManager.hxx b/include/sfx2/StyleManager.hxx new file mode 100644 index 000000000..1c19b981d --- /dev/null +++ b/include/sfx2/StyleManager.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/. + */ + +#ifndef INCLUDED_SFX2_STYLEMANAGER_HXX +#define INCLUDED_SFX2_STYLEMANAGER_HXX + +#include + +#include +#include + +#include + +class OutputDevice; +class SfxObjectShell; +namespace sfx2 { class StylePreviewRenderer; } + +namespace sfx2 +{ + +class SFX2_DLLPUBLIC StyleManager +{ +protected: + SfxObjectShell& mrShell; + +public: + StyleManager(SfxObjectShell& rShell) + : mrShell(rShell) + {} + + virtual ~StyleManager() + {} + + SfxStyleSheetBase* Search(std::u16string_view rStyleName, SfxStyleFamily eFamily); + + virtual std::unique_ptr CreateStylePreviewRenderer( + OutputDevice& rOutputDev, SfxStyleSheetBase* pStyle, + tools::Long nMaxHeight) = 0; +}; + +} // end namespace sfx2 + +#endif //INCLUDED_SFX2_STYLEMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/StylePreviewRenderer.hxx b/include/sfx2/StylePreviewRenderer.hxx new file mode 100644 index 000000000..1692182bd --- /dev/null +++ b/include/sfx2/StylePreviewRenderer.hxx @@ -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/. + */ + +#ifndef INCLUDED_SFX2_STYLEPREVIEWRENDERER_HXX +#define INCLUDED_SFX2_STYLEPREVIEWRENDERER_HXX + +#include +#include + +class OutputDevice; +class SfxStyleSheetBase; + +namespace sfx2 +{ + +class SFX2_DLLPUBLIC StylePreviewRenderer +{ +protected: + const SfxObjectShell& mrShell; + OutputDevice& mrOutputDev; + SfxStyleSheetBase* mpStyle; + tools::Long mnMaxHeight; + +public: + enum class RenderAlign + { + TOP, CENTER + }; + + StylePreviewRenderer(const SfxObjectShell& rShell, + OutputDevice& rOutputDev, + SfxStyleSheetBase* pStyle, + tools::Long nMaxHeight) + : mrShell(rShell) + , mrOutputDev(rOutputDev) + , mpStyle(pStyle) + , mnMaxHeight(nMaxHeight) + {} + + virtual ~StylePreviewRenderer() + {} + + virtual bool recalculate() = 0; + virtual bool render(const tools::Rectangle& aRectangle, RenderAlign eRenderAlign = RenderAlign::CENTER) = 0; +}; + +} // end namespace sfx2 + +#endif // INCLUDED_SVX_STYLEPREVIEWRENDERER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/XmlIdRegistry.hxx b/include/sfx2/XmlIdRegistry.hxx new file mode 100644 index 000000000..494c83020 --- /dev/null +++ b/include/sfx2/XmlIdRegistry.hxx @@ -0,0 +1,67 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_XMLIDREGISTRY_HXX +#define INCLUDED_SFX2_XMLIDREGISTRY_HXX + +#include + +#include + +#include + +namespace com::sun::star::beans { struct StringPair; } +namespace com::sun::star::uno { template class Reference; } + +namespace com::sun::star::rdf { + class XMetadatable; +} + +namespace sfx2 { + +// XML ID utilities -------------------------------------------------- + +/** is i_rIdref a valid NCName ? */ +bool SFX2_DLLPUBLIC isValidNCName(std::u16string_view i_rIdref); + +bool SFX2_DLLPUBLIC isValidXmlId(std::u16string_view i_rStreamName, + std::u16string_view i_rIdref); + +// XML ID handling --------------------------------------------------- + +/** interface for getElementByMetadataReference; + for use by sfx2::DocumentMetadataAccess + */ +class SFX2_DLLPUBLIC IXmlIdRegistry +{ + +public: + virtual ~IXmlIdRegistry() { } + + virtual css::uno::Reference< css::rdf::XMetadatable > + GetElementByMetadataReference( + const css::beans::StringPair & i_rXmlId) const = 0; + +}; + +} // namespace sfx2 + +#endif // INCLUDED_SFX2_XMLIDREGISTRY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/app.hxx b/include/sfx2/app.hxx new file mode 100644 index 000000000..3be667198 --- /dev/null +++ b/include/sfx2/app.hxx @@ -0,0 +1,233 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_APP_HXX +#define INCLUDED_SFX2_APP_HXX + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace com::sun::star::script { class XLibraryContainer; } + +namespace weld { class Window; } + +class BasicManager; +class DdeService; +class SfxAppData_Impl; +class SfxDispatcher; +class SfxEventHint; +class SfxItemSet; +class SfxObjectShell; +class SfxObjectShellLock; +class SfxProgress; +class SfxSlotPool; +class SfxViewFrame; +class StarBASIC; +class SfxWorkWindow; +class SfxFilterMatcher; +class SfxModule; +struct SfxChildWinFactory; +struct SfxStbCtrlFactory; +struct SfxTbxCtrlFactory; +class SbxArray; +class SbxValue; + +namespace sfx2 +{ + namespace sidebar { + class Theme; + } +} + +enum class SfxToolsModule +{ + Math = 0, + Calc = 1, + Draw = 2, + Writer = 3, + Basic = 4, + LAST = Basic +}; + +class SFX2_DLLPUBLIC SfxLinkItem final : public SfxPoolItem +{ + Link aLink; +public: + SfxLinkItem( sal_uInt16 nWhichId, const Link& rValue ) : SfxPoolItem( nWhichId ) + { aLink = rValue; } + + virtual SfxLinkItem* Clone( SfxItemPool* = nullptr ) const override + { return new SfxLinkItem( *this ); } + virtual bool operator==( const SfxPoolItem& rL) const override + { return static_cast(rL).aLink == aLink; } + const Link& + GetValue() const { return aLink; } +}; + +// This is a singleton class. Sad that there apparently is no other +// way than a comment like this to indicate that to the code reader. +class SFX2_DLLPUBLIC SfxApplication final : public SfxShell +{ + std::unique_ptr pImpl; + + DECL_DLLPRIVATE_STATIC_LINK( SfxApplication, GlobalBasicErrorHdl_Impl, StarBASIC*, bool ); + + void Deinitialize(); + +public: + SFX_DECL_INTERFACE(SFX_INTERFACE_SFXAPP) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + SfxApplication(); + +public: + virtual ~SfxApplication() override; + static SfxApplication* GetOrCreate(); + static SfxApplication* Get(); + + // DDE +#if defined(_WIN32) + static bool DdeExecute( const OUString& rCmd ); +#endif + bool InitializeDde(); + const DdeService* GetDdeService() const; + DdeService* GetDdeService(); +#if defined(_WIN32) + void AddDdeTopic( SfxObjectShell* ); +#endif + void RemoveDdeTopic( SfxObjectShell const * ); + + // "static" methods + /** + * @param pArgs Takes ownership + */ + ErrCode LoadTemplate( SfxObjectShellLock& xDoc, const OUString& rFileName, std::unique_ptr pArgs ); + weld::Window* GetTopWindow() const; + + // members + SfxFilterMatcher& GetFilterMatcher(); + SfxProgress* GetProgress() const; + sal_uInt16 GetFreeIndex(); + void ReleaseIndex(sal_uInt16 i); + + // Basic/Scripting + static bool IsXScriptURL( const OUString& rScriptURL ); + static OUString ChooseScript(weld::Window *pParent); + static void MacroOrganizer(weld::Window* pParent, sal_Int16 nTabId); + static ErrCode CallBasic( const OUString&, BasicManager*, SbxArray *pArgs, SbxValue *pRet ); + static ErrCode CallAppBasic( const OUString& i_macroName ) + { return CallBasic( i_macroName, SfxApplication::GetBasicManager(), nullptr, nullptr ); } + static BasicManager* GetBasicManager(); + css::script::XLibraryContainer * GetDialogContainer(); + css::script::XLibraryContainer * GetBasicContainer(); + static StarBASIC* GetBasic(); + void SaveBasicAndDialogContainer() const; + + // misc. + static void GetOptions(SfxItemSet &); + void SetOptions(const SfxItemSet &); + virtual void Invalidate(sal_uInt16 nId = 0) override; + void NotifyEvent(const SfxEventHint& rEvent, bool bSynchron = true ); + bool IsDowning() const; + void ResetLastDir(); + + SAL_DLLPRIVATE SfxDispatcher* GetAppDispatcher_Impl(); + SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl(); + + SAL_DLLPRIVATE void SetOptions_Impl(const SfxItemSet &); + SAL_DLLPRIVATE void Initialize_Impl(); + + SAL_DLLPRIVATE SfxAppData_Impl* Get_Impl() const { return pImpl.get(); } + + // Object-Factories/global arrays + SAL_DLLPRIVATE void RegisterChildWindow_Impl(SfxModule*, const SfxChildWinFactory&); + SAL_DLLPRIVATE void RegisterStatusBarControl_Impl(SfxModule*, const SfxStbCtrlFactory&); + SAL_DLLPRIVATE void RegisterToolBoxControl_Impl( SfxModule*, const SfxTbxCtrlFactory&); + SAL_DLLPRIVATE SfxTbxCtrlFactory* GetTbxCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const; + SAL_DLLPRIVATE SfxStbCtrlFactory* GetStbCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const; + SAL_DLLPRIVATE SfxChildWinFactory* GetChildWinFactoryById(sal_uInt16 nId) const; + SAL_DLLPRIVATE std::vector& GetViewFrames_Impl() const; + SAL_DLLPRIVATE std::vector& GetViewShells_Impl() const; + SAL_DLLPRIVATE std::vector& GetObjectShells_Impl() const; + SAL_DLLPRIVATE void SetViewFrame_Impl(SfxViewFrame *pViewFrame); + + // Slot Methods + // TODO/CLEANUP: still needed? + SAL_DLLPRIVATE void NewDocDirectExec_Impl(SfxRequest &); + SAL_DLLPRIVATE static void NewDocDirectState_Impl(SfxItemSet &); + SAL_DLLPRIVATE void NewDocExec_Impl(SfxRequest &); + SAL_DLLPRIVATE void OpenDocExec_Impl(SfxRequest &); + SAL_DLLPRIVATE void OpenRemoteExec_Impl(SfxRequest &); + SAL_DLLPRIVATE void SignPDFExec_Impl(SfxRequest&); + SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &); + SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &); + SAL_DLLPRIVATE static void PropExec_Impl(SfxRequest const &); + SAL_DLLPRIVATE static void PropState_Impl(SfxItemSet &); + SAL_DLLPRIVATE void OfaExec_Impl(SfxRequest &); + SAL_DLLPRIVATE static void OfaState_Impl(SfxItemSet &); + + SAL_DLLPRIVATE void SetProgress_Impl(SfxProgress *); + SAL_DLLPRIVATE const OUString& GetLastDir_Impl() const; + SAL_DLLPRIVATE void SetLastDir_Impl( const OUString & ); + + SAL_DLLPRIVATE static void Registrations_Impl(); + SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl(const SfxViewFrame *pFrame) const; + + // TODO/CLEANUP: still needed? -- unclear whether this comment + // refers to the GetDisabledSlotList_Impl() method which was + // already removed, or the below methods? + SAL_DLLPRIVATE SfxSlotPool& GetAppSlotPool_Impl() const; + SAL_DLLPRIVATE static SfxModule* GetModule_Impl(); + + static void SetModule(SfxToolsModule nSharedLib, std::unique_ptr pModule); + static SfxModule* GetModule(SfxToolsModule nSharedLib); + + static bool loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWidth); + + /** loads the application logo as used in the impress slideshow pause screen */ + static BitmapEx GetApplicationLogo(tools::Long nWidth); + + /** if true then dialog/infobar notifications like the tip of the day or + version change infobar should be suppressed */ + static bool IsHeadlessOrUITest(); + + static bool IsTipOfTheDayDue(); + + /** this Theme contains Images so must be deleted before DeInitVCL */ + sfx2::sidebar::Theme & GetSidebarTheme(); +}; + +inline SfxApplication* SfxGetpApp() +{ + return SfxApplication::Get(); +} + +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx new file mode 100644 index 000000000..b753569ef --- /dev/null +++ b/include/sfx2/basedlgs.hxx @@ -0,0 +1,136 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_BASEDLGS_HXX +#define INCLUDED_SFX2_BASEDLGS_HXX + +#include +#include +#include +#include + +class SfxTabPage; +class SfxBindings; +class SfxChildWindow; +struct SfxChildWinInfo; +class SfxItemSet; +struct WhichRangesContainer; + +class SFX2_DLLPUBLIC SfxDialogController : public weld::GenericDialogController +{ +private: + DECL_DLLPRIVATE_STATIC_LINK(SfxDialogController, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*); + + DECL_DLLPRIVATE_LINK(FocusChangeHdl, weld::Container&, void); + +public: + SfxDialogController(weld::Widget* pParent, const OUString& rUIFile, const OString& rDialogId); + // dialog gets focus + virtual void Activate() {} + // dialog loses focus + virtual void Deactivate() {} + + // when the dialog has an associated SfxChildWin, typically for Modeless interaction + virtual void ChildWinDispose() {} // called from the associated SfxChildWin dtor + virtual void Close(); // called by the SfxChildWin when the dialog is closed + virtual void EndDialog(int nResponse); // called by the SfxChildWin to close the dialog +}; + +class SfxModelessDialog_Impl; + +class SFX2_DLLPUBLIC SfxModelessDialogController : public SfxDialogController +{ + SfxBindings* m_pBindings; + std::unique_ptr m_xImpl; + + SfxModelessDialogController(SfxModelessDialogController&) = delete; + void operator =(SfxModelessDialogController&) = delete; + + void Init(SfxBindings *pBindinx, SfxChildWindow *pCW); + +protected: + SfxModelessDialogController(SfxBindings*, SfxChildWindow* pChildWin, + weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID); + +public: + virtual ~SfxModelessDialogController() override; + + void Initialize (SfxChildWinInfo const * pInfo); + bool IsClosing() const; + virtual void Close() override; + virtual void EndDialog(int nResponse) override; + virtual void Activate() override; + virtual void Deactivate() override; + virtual void ChildWinDispose() override; + virtual void FillInfo(SfxChildWinInfo&) const; + SfxBindings& GetBindings() const { return *m_pBindings; } +}; + +typedef WhichRangesContainer (*GetTabPageRanges)(); // provides international Which values + +class SFX2_DLLPUBLIC SfxOkDialogController : public SfxDialogController +{ +public: + SfxOkDialogController(weld::Widget* pParent, const OUString& rUIXMLDescription, + const OString& rID) + : SfxDialogController(pParent, rUIXMLDescription, rID) + { + } + + virtual weld::Button& GetOKButton() const = 0; + virtual const SfxItemSet* GetExampleSet() const = 0; +}; + +class SFX2_DLLPUBLIC SfxSingleTabDialogController : public SfxOkDialogController +{ +private: + std::unique_ptr m_xOutputSet; + const SfxItemSet* m_pInputSet; + +public: + SfxSingleTabDialogController(weld::Widget* pParent, const SfxItemSet* pOptionsSet, + const OUString& rUIXMLDescription = OUString("sfx/ui/singletabdialog.ui"), + const OString& rID = OString("SingleTabDialog")); + + weld::Container* get_content_area() { return m_xContainer.get(); } + + virtual ~SfxSingleTabDialogController() override; + + void SetTabPage(std::unique_ptr xTabPage); + SfxTabPage* GetTabPage() const { return m_xSfxPage.get(); } + + virtual weld::Button& GetOKButton() const override { return *m_xOKBtn; } + virtual const SfxItemSet* GetExampleSet() const override { return nullptr; } + + const SfxItemSet* GetOutputItemSet() const { return m_xOutputSet.get(); } + const SfxItemSet* GetInputItemSet() const { return m_pInputSet; } + +protected: + std::unique_ptr m_xSfxPage; + std::unique_ptr m_xContainer; + std::unique_ptr m_xOKBtn; + std::unique_ptr m_xHelpBtn; + + void CreateOutputItemSet(const SfxItemSet& rInput); + void SetInputSet(const SfxItemSet* pInSet) { m_pInputSet = pInSet; } + DECL_DLLPRIVATE_LINK(OKHdl_Impl, weld::Button&, void); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/bindings.hxx b/include/sfx2/bindings.hxx new file mode 100644 index 000000000..d058c939e --- /dev/null +++ b/include/sfx2/bindings.hxx @@ -0,0 +1,208 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_BINDINGS_HXX +#define INCLUDED_SFX2_BINDINGS_HXX + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace com::sun::star::frame { class XDispatch; } +namespace com::sun::star::frame { class XDispatchProvider; } +namespace com::sun::star::frame { class XDispatchRecorder; } +namespace com::sun::star::frame { class XFrame; } +namespace com::sun::star::util { struct URL; } + +class SfxSlot; +class SfxSlotServer; +class SfxControllerItem; +class SfxStateCache; +class SfxItemSet; +class SfxDispatcher; +class SfxBindings_Impl; +class Timer; +class SfxWorkWindow; +struct SfxFoundCache_Impl; +class SfxFoundCacheArr_Impl; + +enum class SfxCallMode : sal_uInt16 +{ + SLOT = 0x00, // sync/async from Slot + SYNCHRON = 0x01, // synchronously in the same Stackframe + ASYNCHRON = 0x02, // asynchronously via AppEvent + RECORD = 0x04, // take into account while recording + API = 0x08 // API call (silent) +}; + +namespace o3tl { + +template<> struct typed_flags: is_typed_flags +{}; + +} + +class SFX2_DLLPUBLIC SfxBindings final : public SfxBroadcaster + +/* [Description] + + In each SFx application one instance of the SfxBindings-Class will + exists from until . + This instance is automatically created and destroyed by SfxApplication. + However these instances will be handled by the Macro + or the associated . + + The SfxBindings manages all of its Slot-Ids bound by the registered + controllers and keeps a cache of the respectively. + (it is what we call the combination of SfxShell instance and SfxSlot). + In the SfxBindings it is stored, if and in this case which controllers + that are dirty and which Slot-Server-Caches are dirty respectively. + It summarizes status queries (calls to the status methods specified + in the IDL) that are served by the same state methods, and handles + the simulation of . +*/ + +{ +friend class SfxApplication; +friend class SfxShell; +friend class SfxBindings_Impl; + + std::unique_ptr< SfxBindings_Impl> pImpl; // Data of the Bindings instance + SfxDispatcher* pDispatcher; // Dispatcher, to be used + sal_uInt16 nRegLevel; // Lock-Level while Reconfig + +private: + SAL_DLLPRIVATE const SfxPoolItem* Execute_Impl( sal_uInt16 nSlot, const SfxPoolItem **pArgs, sal_uInt16 nModi, + SfxCallMode nCall, const SfxPoolItem **pInternalArgs, bool bGlobalOnly=false); + SAL_DLLPRIVATE void SetSubBindings_Impl( SfxBindings* ); + SAL_DLLPRIVATE void UpdateSlotServer_Impl(); // Update SlotServer + SAL_DLLPRIVATE std::optional CreateSet_Impl(SfxStateCache& rCache, const SfxSlot* &pRealSlot, + const SfxSlotServer**, SfxFoundCacheArr_Impl&); + SAL_DLLPRIVATE std::size_t GetSlotPos( sal_uInt16 nId, std::size_t nStartSearchAt = 0 ); + SAL_DLLPRIVATE void Update_Impl(SfxStateCache& rCache); + static SAL_DLLPRIVATE void UpdateControllers_Impl( + const SfxFoundCache_Impl& rFound, + const SfxPoolItem *pItem, + SfxItemState eItemState ); + SAL_DLLPRIVATE SfxStateCache* GetStateCache( sal_uInt16 nId, std::size_t * pPos); + DECL_DLLPRIVATE_LINK( NextJob, Timer *, void ); + SAL_DLLPRIVATE bool NextJob_Impl(Timer const * pTimer); + +public: + SfxBindings(); + virtual ~SfxBindings() override; + + void HidePopups( bool bHide = true ); + + void SetDispatcher(SfxDispatcher *pDisp); + + void Update( sal_uInt16 nId ); // For example, from Menu::Activate + void Update(); + SAL_DLLPRIVATE void StartUpdate_Impl(bool bComplete=false); + void Invalidate( sal_uInt16 nId ); + void Invalidate( const sal_uInt16* pIds ); + void InvalidateShell( const SfxShell &rSh, bool bDeep = false ); + void InvalidateAll( bool bWithMsg ); + void SetState( const SfxItemSet &rSet ); + void SetState( const SfxPoolItem &rItem ); + void Invalidate( sal_uInt16 nId, bool bWithItem, bool bWithMsg=false); + bool IsInUpdate() const; + void SetVisibleState( sal_uInt16 nId, bool bShow ); + + SfxStateCache* GetStateCache( sal_uInt16 nId); + SAL_DLLPRIVATE SfxStateCache* GetAnyStateCache_Impl( sal_uInt16 nId ); + /** + * @param rpState the caller has to delete the pointer + */ + SfxItemState QueryState( sal_uInt16 nSID, std::unique_ptr &rpState ); + template + SfxItemState QueryState( TypedWhichId nSID, std::unique_ptr &rpState ) + { + std::unique_ptr tmp; + auto ret = QueryState(sal_uInt16(nSID), tmp); + rpState.reset(static_cast(tmp.release())); + return ret; + } + + void QueryControlState ( sal_uInt16 nSID, boost::property_tree::ptree& rState ); + + sal_uInt16 QuerySlotId( const css::util::URL& aURL ); + + const SfxPoolItem* ExecuteSynchron( sal_uInt16 nSlot, + const SfxPoolItem **pArgs = nullptr); + bool Execute( sal_uInt16 nSlot, + const SfxPoolItem **pArgs = nullptr, + SfxCallMode nCall = SfxCallMode::SLOT); + + SAL_DLLPRIVATE void SetDispatchProvider_Impl( const css::uno::Reference< css::frame::XDispatchProvider > & rFrame ); + void SetActiveFrame( const css::uno::Reference< css::frame::XFrame > & rFrame ); + css::uno::Reference< css::frame::XFrame > GetActiveFrame() const; + // Reconfig + sal_uInt16 EnterRegistrations(const char *pFile = nullptr, int nLine = 0); + void LeaveRegistrations( const char *pFile = nullptr, int nLine = 0 ); + void Register( SfxControllerItem& rBinding ); + void Release( SfxControllerItem& rBinding ); + SfxDispatcher* GetDispatcher() const + { return pDispatcher; } + const css::uno::Reference< css::frame::XDispatchRecorder >& GetRecorder() const; + css::uno::Reference < css::frame::XDispatch > + GetDispatch( const SfxSlot*, const css::util::URL& aURL, bool bMasterCommand ); + SAL_DLLPRIVATE void ContextChanged_Impl(); + SAL_DLLPRIVATE void Execute_Impl( SfxRequest& rReq, const SfxSlot* pSlot, SfxShell* pShell ); + SAL_DLLPRIVATE void DeleteControllers_Impl(); + SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl() { return pDispatcher; } + SAL_DLLPRIVATE void ClearCache_Impl( sal_uInt16 nSlotId ); + SAL_DLLPRIVATE void RegisterInternal_Impl( SfxControllerItem& rBinding ); + SAL_DLLPRIVATE void Register_Impl( SfxControllerItem& rBinding, bool ); + SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl() const; + SAL_DLLPRIVATE void SetWorkWindow_Impl( std::unique_ptr ); + SAL_DLLPRIVATE SfxBindings* GetSubBindings_Impl() const; + SAL_DLLPRIVATE void SetRecorder_Impl( css::uno::Reference< css::frame::XDispatchRecorder > const & ); + SAL_DLLPRIVATE void InvalidateSlotsInMap_Impl(); + SAL_DLLPRIVATE void AddSlotToInvalidateSlotsMap_Impl( sal_uInt16 nId ); +}; + +#ifdef DBG_UTIL +#define ENTERREGISTRATIONS() EnterRegistrations(__FILE__, __LINE__) +#define LEAVEREGISTRATIONS() LeaveRegistrations(__FILE__, __LINE__) +#define DENTERREGISTRATIONS() \ + EnterRegistrations( OStringBuffer(__FILE__).append('(').append(reinterpret_cast(this)).append(')').getStr(), __LINE__ ) +#define DLEAVEREGISTRATIONS( ) \ + LeaveRegistrations( OStringBuffer(__FILE__).append('(').append(reinterpret_cast(this)).append(')').getStr(), __LINE__ ) +#else +#define ENTERREGISTRATIONS() EnterRegistrations() +#define LEAVEREGISTRATIONS() LeaveRegistrations() +#define DENTERREGISTRATIONS() EnterRegistrations() +#define DLEAVEREGISTRATIONS() LeaveRegistrations() +#endif + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/brokenpackageint.hxx b/include/sfx2/brokenpackageint.hxx new file mode 100644 index 000000000..37c98540a --- /dev/null +++ b/include/sfx2/brokenpackageint.hxx @@ -0,0 +1,63 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_BROKENPACKAGEINT_HXX +#define INCLUDED_SFX2_BROKENPACKAGEINT_HXX + +#include +#include +#include + +#include + +namespace com::sun::star::task +{ +class XInteractionRequest; +} + +class RequestPackageReparation_Impl; +class SFX2_DLLPUBLIC RequestPackageReparation +{ + rtl::Reference mxImpl; + +public: + RequestPackageReparation(const OUString& aName); + ~RequestPackageReparation(); + RequestPackageReparation(const RequestPackageReparation&) = delete; + RequestPackageReparation& operator=(const RequestPackageReparation&) = delete; + bool isApproved() const; + css::uno::Reference GetRequest() const; +}; + +class NotifyBrokenPackage_Impl; +class SFX2_DLLPUBLIC NotifyBrokenPackage +{ + rtl::Reference mxImpl; + +public: + NotifyBrokenPackage(const OUString& aName); + ~NotifyBrokenPackage(); + NotifyBrokenPackage(const NotifyBrokenPackage&) = delete; + NotifyBrokenPackage& operator=(const NotifyBrokenPackage&) = delete; + css::uno::Reference GetRequest() const; +}; + +#endif // INCLUDED_SFX2_BROKENPACKAGEINT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/chalign.hxx b/include/sfx2/chalign.hxx new file mode 100644 index 000000000..d63646ea1 --- /dev/null +++ b/include/sfx2/chalign.hxx @@ -0,0 +1,55 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_CHALIGN_HXX +#define INCLUDED_SFX2_CHALIGN_HXX + +// New order: first, navigation bar, then vertically docked child windows +// (Explorer!), then horizontally docked child windows (Browser!), +// then the format bar, status bar, and at the end of the toolbar. + +enum class SfxChildAlignment +{ + HIGHESTTOP, // for example Navigation bar + LOWESTBOTTOM, + FIRSTLEFT, + LASTRIGHT, + LEFT, // for example SplitWindow + RIGHT, + LASTLEFT, + FIRSTRIGHT, + TOP, // for example Hyperlink-Builder, SplitWindow + BOTTOM, // for example SplitWindow + TOOLBOXTOP, // for example Object bar + TOOLBOXBOTTOM, + LOWESTTOP, // for example Calc bar + HIGHESTBOTTOM, // for example Status bar + TOOLBOXLEFT, // for example Tool bar + TOOLBOXRIGHT, + NOALIGNMENT // all FloatingWindows +}; + +// Verifies that a valid alignment is used +inline bool SfxChildAlignValid( SfxChildAlignment eAlign ) +{ + return ( eAlign >= SfxChildAlignment::HIGHESTTOP && eAlign <= SfxChildAlignment::NOALIGNMENT ); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/charwin.hxx b/include/sfx2/charwin.hxx new file mode 100644 index 000000000..f4118d44c --- /dev/null +++ b/include/sfx2/charwin.hxx @@ -0,0 +1,72 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_INC_CHARWIN_HXX +#define INCLUDED_SFX2_INC_CHARWIN_HXX + +#include +#include +#include +#include + +class SFX2_DLLPUBLIC SvxCharView final : public weld::CustomWidgetController +{ +private: + VclPtr mxVirDev; + tools::Long mnY; + Point maPosition; + vcl::Font maFont; + bool maHasInsert; + OUString m_sText; + + Link maMouseClickHdl; + Link maClearClickHdl; + Link maClearAllClickHdl; + + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual void Resize() override; + virtual bool MouseButtonDown(const MouseEvent&) override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + virtual bool KeyInput(const KeyEvent&) override; + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; +public: + SvxCharView(const VclPtr& rVirDev); + + void SetFont( const vcl::Font& rFont ); + vcl::Font const & GetFont() const { return maFont; } + void SetText( const OUString& rText ); + OUString const & GetText() const { return m_sText; } + void SetHasInsert( bool bInsert ); + void InsertCharToDoc(); + + void createContextMenu(); + + Size get_preferred_size() const { return GetDrawingArea()->get_preferred_size(); } + + void setMouseClickHdl(const Link &rLink); + void setClearClickHdl(const Link &rLink); + void setClearAllClickHdl(const Link &rLink); + + void ContextMenuSelect(std::string_view rIdent); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/sfx2/childwin.hxx b/include/sfx2/childwin.hxx new file mode 100644 index 000000000..68ad6ff50 --- /dev/null +++ b/include/sfx2/childwin.hxx @@ -0,0 +1,235 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_CHILDWIN_HXX +#define INCLUDED_SFX2_CHILDWIN_HXX + +#include +#include + +#include +#include +#include +#include + +#include +#include + +namespace com::sun::star::frame { class XFrame; } + +class SfxWorkWindow; +class SfxModule; +class SfxChildWindow; +class SfxBindings; +class SfxModelessDialogController; + +enum class SfxChildWindowFlags +{ + NONE = 0x000, + FORCEDOCK = 0x004, // Float forbidden + TASK = 0x010, // ChildWindow inside the Task + CANTGETFOCUS = 0x020, // ChildWindow can not get focus + ALWAYSAVAILABLE = 0x040, // ChildWindow is never disabled + NEVERHIDE = 0x080, // ChildWindow is always visible + NEVERCLONE = 0x100, // ChildWindow is not recreated in new view +}; + +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + + +#define CHILDWIN_NOPOS USHRT_MAX + +// ChildWindow Configuration +struct SAL_DLLPUBLIC_RTTI SfxChildWinInfo +{ + OUString aExtraString; + OUString aModule; + OString aWinState; + Point aPos; + Size aSize; + SfxChildWindowFlags nFlags; + bool bVisible; + + SfxChildWinInfo() + { + bVisible = false; + nFlags = SfxChildWindowFlags::NONE; + } + bool GetExtraData_Impl( SfxChildAlignment *pAlign ) const; +}; + +// ChildWindow factory methods +typedef std::unique_ptr (*SfxChildWinCtor)( vcl::Window *pParentWindow, + sal_uInt16 nId, + SfxBindings *pBindings, + SfxChildWinInfo *pInfo); + +struct SFX2_DLLPUBLIC SfxChildWinFactory +{ + SfxChildWinCtor pCtor; // Factory method + SfxChildWinInfo aInfo; // Configuration + sal_uInt16 nId; // ChildWindow-Id ( SlotId ) + sal_uInt16 nPos; // Position in UI + + SfxChildWinFactory( SfxChildWinCtor pTheCtor, sal_uInt16 nID, sal_uInt16 n ); +}; + +struct SfxChildWindow_Impl; + +extern SFX2_DLLPUBLIC bool ParentIsFloatingWindow(const vcl::Window *pParent); + +class SFX2_DLLPUBLIC SfxChildWindow +{ + VclPtr pParent; // parent window ( Topwindow ) + VclPtr pWindow; // actual contents + std::unique_ptr< SfxChildWindow_Impl> pImpl; // Implementation data + std::shared_ptr xController; // actual contents + SfxChildAlignment eChildAlignment; // Current css::drawing::Alignment + // Another window in pWindow + sal_uInt16 nType; // ChildWindow-Id + SAL_DLLPRIVATE void ClearWorkwin(); + +protected: + void SetWindow(const VclPtr& p) { pWindow = p; } + SfxChildWindow(vcl::Window *pParentWindow, sal_uInt16 nId); + +public: + virtual ~SfxChildWindow(); + void Destroy(); + vcl::Window* GetWindow() const + { return pWindow; } + void SetController(std::shared_ptr controller) { xController = controller; } + void ClearController() { xController.reset(); } + std::shared_ptr& GetController() { return xController; } + const std::shared_ptr& GetController() const { return xController; } + vcl::Window* GetParent() const + { return pParent; } + SfxChildAlignment GetAlignment() const + { return eChildAlignment; } + void SetAlignment(SfxChildAlignment eAlign); + virtual void Hide(); + virtual void Show( ShowFlags nFlags ); + sal_uInt16 GetPosition() const; + sal_uInt16 GetType() const + { return nType; } + + virtual SfxChildWinInfo GetInfo() const; + void SaveStatus(const SfxChildWinInfo& rInfo); + + static void RegisterChildWindow(SfxModule*, const SfxChildWinFactory&); + + static std::unique_ptr CreateChildWindow( sal_uInt16, vcl::Window*, SfxBindings*, SfxChildWinInfo const &); + void SetHideNotDelete( bool bOn ); + bool IsHideNotDelete() const; + bool IsVisible() const; + void SetWantsFocus( bool ); + bool WantsFocus() const; + + virtual bool QueryClose(); + const css::uno::Reference< css::frame::XFrame >& GetFrame() const; + void SetFrame( const css::uno::Reference< css::frame::XFrame > & ); + + SAL_DLLPRIVATE static void InitializeChildWinFactory_Impl(sal_uInt16, SfxChildWinInfo&); + void SetVisible_Impl( bool bVis ); + SAL_DLLPRIVATE void SetWorkWindow_Impl( SfxWorkWindow* ); + SAL_DLLPRIVATE void Activate_Impl(); + + SAL_DLLPRIVATE void SetFactory_Impl( const SfxChildWinFactory* ); +}; + +const int nCloseResponseToJustHide = -42; + +#define SFX_DECL_CHILDWINDOW(Class) \ + public : \ + static std::unique_ptr CreateImpl(vcl::Window *pParent, sal_uInt16 nId, \ + SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \ + static void RegisterChildWindow (bool bVisible=false, SfxModule *pMod=nullptr, SfxChildWindowFlags nFlags=SfxChildWindowFlags::NONE); \ + virtual SfxChildWinInfo GetInfo() const override + +#define SFX_DECL_CHILDWINDOW_WITHID(Class) \ + SFX_DECL_CHILDWINDOW(Class); \ + static sal_uInt16 GetChildWindowId ()\ + +#define SFX_IMPL_CHILDWINDOW(Class, MyID) \ + SFX_IMPL_POS_CHILDWINDOW(Class, MyID, CHILDWIN_NOPOS) + +#define SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \ + SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, CHILDWIN_NOPOS) + +#define SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \ + std::unique_ptr Class::CreateImpl( vcl::Window *pParent, \ + sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \ + { \ + return std::make_unique(pParent, nId, pBindings, pInfo);\ + } \ + void Class::RegisterChildWindow (bool bVis, SfxModule *pMod, SfxChildWindowFlags nFlags) \ + { \ + SfxChildWinFactory aFact( \ + Class::CreateImpl, MyID, Pos ); \ + aFact.aInfo.nFlags |= nFlags; \ + aFact.aInfo.bVisible = bVis; \ + SfxChildWindow::RegisterChildWindow(pMod, aFact); \ + } + +#define SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, Pos) \ + SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \ + sal_uInt16 Class::GetChildWindowId () \ + { return MyID; } \ + +#define SFX_IMPL_MODELESSDIALOGCONTOLLER(Class, MyID) \ + SFX_IMPL_CHILDWINDOW(Class, MyID) \ + SfxChildWinInfo Class::GetInfo() const \ + { \ + SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \ + static_cast(GetController().get())->FillInfo( aInfo ); \ + return aInfo; } + +#define SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(Class, MyID) \ + SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \ + SfxChildWinInfo Class::GetInfo() const \ + { \ + SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \ + static_cast(GetController().get())->FillInfo( aInfo ); \ + return aInfo; } + +#define SFX_IMPL_DOCKINGWINDOW(Class, MyID) \ + SFX_IMPL_CHILDWINDOW(Class, MyID) \ + SfxChildWinInfo Class::GetInfo() const \ + { \ + SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \ + static_cast(GetWindow())->FillInfo( aInfo ); \ + return aInfo; } + +#define SFX_IMPL_DOCKINGWINDOW_WITHID(Class, MyID) \ + SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \ + SfxChildWinInfo Class::GetInfo() const \ + { \ + SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \ + static_cast(GetWindow())->FillInfo( aInfo ); \ + return aInfo; } + +bool GetPosSizeFromString( std::u16string_view rStr, Point& rPos, Size& rSize ); + +bool GetSplitSizeFromString( std::u16string_view rStr, Size& rSize ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx new file mode 100644 index 000000000..5a4fa6b1e --- /dev/null +++ b/include/sfx2/classificationhelper.hxx @@ -0,0 +1,227 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_CLASSIFICATIONHELPER_HXX +#define INCLUDED_SFX2_CLASSIFICATIONHELPER_HXX + +#include +#include +#include + +#include +#include +#include +#include + +namespace com::sun::star::beans +{ +class XPropertyContainer; +} +namespace com::sun::star::document +{ +class XDocumentProperties; +} + +class SfxViewFrame; + +/// Return code of SfxClassificationHelper::CheckPaste(). +enum class SfxClassificationCheckPasteResult +{ + None = 1, + TargetDocNotClassified = 2, + DocClassificationTooLow = 3 +}; + +/// Specifies a policy type, to be used with SetBACName(). Getters always use IntellectualProperty for now. +enum class SfxClassificationPolicyType +{ + ExportControl = 1, + NationalSecurity = 2, + IntellectualProperty = 3 +}; + +/// Shared code to handle Business Authorization Identification and Labeling Scheme (BAILS) properties. +class SFX2_DLLPUBLIC SfxClassificationHelper +{ + class SAL_DLLPRIVATE Impl; + std::unique_ptr m_pImpl; + +public: + /// Does the document have any BAILS properties? + static bool IsClassified( + const css::uno::Reference& xDocumentProperties); + /// Checks if pasting from xSource to xDestination would leak information. + static SfxClassificationCheckPasteResult + CheckPaste(const css::uno::Reference& xSource, + const css::uno::Reference& xDestination); + /// Wrapper around CheckPaste(): informs the user if necessary and finds out if the paste can be continued or not. + static bool ShowPasteInfo(SfxClassificationCheckPasteResult eResult); + + SfxClassificationHelper( + const css::uno::Reference& xDocumentProperties, + bool bUseLocalizedPolicy = true); + ~SfxClassificationHelper(); + /// Get the currently selected category for eType. + const OUString& GetBACName(SfxClassificationPolicyType eType) const; + /// Return all possible valid category names, based on the policy. + std::vector GetBACNames(); + /// Return all possible valid category identifiers, based on the policy. + std::vector GetBACIdentifiers(); + /// Get the currently selected category abbreviation for eType. Returns full name if no abbreviation defined. + const OUString& GetAbbreviatedBACName(const OUString& sFullName); + /// Get the currently selected category for the identifier. + OUString GetBACNameForIdentifier(std::u16string_view sIdentifier); + /// Return all possible valid abbreviated category names, based on the policy. + std::vector GetAbbreviatedBACNames(); + /// Setting this sets all the other properties, based on the policy. + void SetBACName(const OUString& rName, SfxClassificationPolicyType eType); + /// Returns the class with the higher priority (based on sensitivity). + OUString GetHigherClass(const OUString& first, const OUString& second); + /// If GetImpactScale() and GetImpactLevel*() will return something meaningful. + bool HasImpactLevel(); + InfobarType GetImpactLevelType(); + /// Larger value means more confidential. + sal_Int32 GetImpactLevel(); + /// Comparing the GetImpactLevel() result is only meaningful when the impact scale is the same. + OUString GetImpactScale(); + OUString GetDocumentWatermark(); + /// The selected category has some content for the document header. + bool HasDocumentHeader(); + /// The selected category has some content for the document footer. + bool HasDocumentFooter(); + void UpdateInfobar(SfxViewFrame& rViewFrame); + + std::vector const& GetMarkings() const; + std::vector const& GetIntellectualPropertyParts() const; + std::vector const& GetIntellectualPropertyPartNumbers() const; + + /// Does a best-effort conversion of rType to SfxClassificationPolicyType. + static SfxClassificationPolicyType stringToPolicyType(std::u16string_view rType); + /// Returns the string representation of a SfxClassificationPolicyType element. + static const OUString& policyTypeToString(SfxClassificationPolicyType eType); + + /// Brief text located at the top of each document's pages. + static const OUString& PROP_DOCHEADER(); + /// Brief text located at the bottom of each document's pages. + static const OUString& PROP_DOCFOOTER(); + /// Brief text formatted as a watermark on each document's page. + static const OUString& PROP_DOCWATERMARK(); + /// Get the property prefix for the IntellectualProperty policy type. + static const OUString& PROP_PREFIX_INTELLECTUALPROPERTY(); + + static SfxClassificationPolicyType getPolicyType(); +}; + +namespace sfx +{ +/// Specifies the origin: either defined by the BAF policy or manual via. the advanced classification dialog +enum class ClassificationCreationOrigin +{ + NONE, + BAF_POLICY, + MANUAL +}; + +class ClassificationKeyCreator +{ +private: + const SfxClassificationPolicyType m_ePolicyType; + const OUString m_sPolicy; + sal_Int32 m_nTextNumber; + sal_Int32 m_nIPPartNumber; + sal_Int32 m_nMarkingNumber; + + OUString const& getPolicyKey() const { return m_sPolicy; } + +public: + ClassificationKeyCreator(SfxClassificationPolicyType ePolicyType) + : m_ePolicyType(ePolicyType) + , m_sPolicy(SfxClassificationHelper::policyTypeToString(m_ePolicyType)) + , m_nTextNumber(1) + , m_nIPPartNumber(1) + , m_nMarkingNumber(1) + { + } + + OUString makeTextKey() const { return getPolicyKey() + "Custom:Text"; } + + OUString makeNumberedTextKey() + { + return makeTextKey() + ":n" + OUString::number(m_nTextNumber++); + } + + bool isMarkingTextKey(std::u16string_view aKey) const + { + return o3tl::starts_with(aKey, makeTextKey()); + } + + OUString makeCategoryNameKey() const + { + return getPolicyKey() + "BusinessAuthorizationCategory:Name"; + } + + bool isCategoryNameKey(std::u16string_view aKey) const + { + return o3tl::starts_with(aKey, makeCategoryNameKey()); + } + + OUString makeCategoryIdentifierKey() const + { + return getPolicyKey() + "BusinessAuthorizationCategory:Identifier"; + } + + bool isCategoryIdentifierKey(std::u16string_view aKey) const + { + return o3tl::starts_with(aKey, makeCategoryIdentifierKey()); + } + + OUString makeMarkingKey() const { return getPolicyKey() + "Custom:Marking"; } + + OUString makeNumberedMarkingKey() + { + return makeMarkingKey() + ":n" + OUString::number(m_nMarkingNumber++); + } + + bool isMarkingKey(std::u16string_view aKey) const + { + return o3tl::starts_with(aKey, makeMarkingKey()); + } + + OUString makeIntellectualPropertyPartKey() const + { + return getPolicyKey() + "Custom:IntellectualPropertyPart"; + } + + OUString makeNumberedIntellectualPropertyPartKey() + { + return makeIntellectualPropertyPartKey() + ":n" + OUString::number(m_nIPPartNumber++); + } + + bool isIntellectualPropertyPartKey(std::u16string_view aKey) const + { + return o3tl::starts_with(aKey, makeIntellectualPropertyPartKey()); + } + + OUString makeFullTextualRepresentationKey() const + { + return getPolicyKey() + "Custom:FullTexturalRepresentation"; + } + + /// Classification creation origin key + OUString makeCreationOriginKey() const { return getPolicyKey() + "CreationOrigin"; } +}; + +SFX2_DLLPUBLIC sfx::ClassificationCreationOrigin getCreationOriginProperty( + css::uno::Reference const& rxPropertyContainer, + sfx::ClassificationKeyCreator const& rKeyCreator); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/ctrlitem.hxx b/include/sfx2/ctrlitem.hxx new file mode 100644 index 000000000..03e530c78 --- /dev/null +++ b/include/sfx2/ctrlitem.hxx @@ -0,0 +1,97 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_CTRLITEM_HXX +#define INCLUDED_SFX2_CTRLITEM_HXX + +#include +#include +#include +#include +#include + +class SfxBindings; + +class SFX2_DLLPUBLIC SfxControllerItem +{ +private: + SfxControllerItem* pNext; // to notify next ControllerItem + SfxBindings* pBindings; + MapUnit eFallbackCoreMetric; + sal_uInt16 nId; + +public: + SfxBindings & GetBindings() { + DBG_ASSERT(pBindings, "no Bindings"); + return *pBindings; + } + const SfxBindings & GetBindings() const { + DBG_ASSERT(pBindings, "no Bindings"); + return *pBindings; + } + + SfxControllerItem(); // for arrays + SfxControllerItem( sal_uInt16 nId, SfxBindings & ); + virtual ~SfxControllerItem(); + virtual void dispose(); + + void Bind( sal_uInt16 nNewId, SfxBindings *); // Register in SfxBindings + void UnBind(); + void ReBind(); + bool IsBound() const; + void ClearCache(); + + SfxControllerItem* GetItemLink(); + SfxControllerItem* ChangeItemLink( SfxControllerItem* pNewLink ); + + void SetId( sal_uInt16 nItemId ); + sal_uInt16 GetId() const { return nId; } + + virtual void StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState ); + + virtual void GetControlState( sal_uInt16 nSID, boost::property_tree::ptree& ); + + MapUnit GetCoreMetric() const; + // override what GetCoreMetric will return if it cannot determine the current CoreMetric + void SetFallbackCoreMetric(MapUnit eFallback) + { + eFallbackCoreMetric = eFallback; + } + + static SfxItemState GetItemState( const SfxPoolItem* pState ); + + SAL_DLLPRIVATE void BindInternal_Impl( sal_uInt16 nNewId, SfxBindings* ); +}; + + +class SFX2_DLLPUBLIC SfxStatusForwarder final : public SfxControllerItem +{ + SfxControllerItem* pMaster; + + virtual void StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState ) override; + +public: + SfxStatusForwarder( sal_uInt16 nSlotId, + SfxControllerItem&rMaster ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/devtools/DevelopmentToolChildWindow.hxx b/include/sfx2/devtools/DevelopmentToolChildWindow.hxx new file mode 100644 index 000000000..d78ac5c2e --- /dev/null +++ b/include/sfx2/devtools/DevelopmentToolChildWindow.hxx @@ -0,0 +1,27 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include +#include + +/** + * Necessary child window for the development tools docking window + */ +class SAL_WARN_UNUSED SFX2_DLLPUBLIC DevelopmentToolChildWindow final : public SfxChildWindow +{ + SFX_DECL_CHILDWINDOW_WITHID(DevelopmentToolChildWindow); + + DevelopmentToolChildWindow(vcl::Window* pParentWindow, sal_uInt16 nId, SfxBindings* pBindings, + SfxChildWinInfo* pInfo); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx b/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx new file mode 100644 index 000000000..4da9fccd9 --- /dev/null +++ b/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx @@ -0,0 +1,72 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +/** Development tool main docking window + * + * Contains two sides. Left side contains the simplified DOM tree and + * the right side the object inspector tree. + */ +class SFX2_DLLPUBLIC DevelopmentToolDockingWindow final : public SfxDockingWindow +{ +private: + std::unique_ptr mpObjectInspectorWidgets; + std::unique_ptr mpDocumentModelTreeView; + std::unique_ptr mpDomToolbar; + + // Reference to the root object for the current document + css::uno::Reference mxRoot; + // Stores the current selected object in the document + css::uno::Reference mxCurrentSelection; + css::uno::Reference mxSelectionListener; + css::uno::Reference mxSelectionSupplier; + + // Handler for the DOM tree + DocumentModelTreeHandler maDocumentModelTreeHandler; + // Handler for the object inspector tree + ObjectInspectorTreeHandler maObjectInspectorTreeHandler; + + DECL_DLLPRIVATE_LINK(DocumentModelTreeViewSelectionHandler, weld::TreeView&, void); + DECL_DLLPRIVATE_LINK(DomToolbarButtonClicked, const OString&, void); + + void updateSelection(); + +public: + DevelopmentToolDockingWindow(SfxBindings* pBindings, SfxChildWindow* pChildWindow, + vcl::Window* pParent); + + virtual ~DevelopmentToolDockingWindow() override; + + void dispose() override; + + void ToggleFloatingMode() override; + + // Signals that the selected object in the document changes + void selectionChanged(css::uno::Reference const& xInterface); + + // Signals to change to the current selected object in the object inspector + void changeToCurrentSelection(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/devtools/DocumentModelTreeHandler.hxx b/include/sfx2/devtools/DocumentModelTreeHandler.hxx new file mode 100644 index 000000000..47294d527 --- /dev/null +++ b/include/sfx2/devtools/DocumentModelTreeHandler.hxx @@ -0,0 +1,52 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include + +#include +#include + +/** Document model tree handler + * + * Handles the DOM tree part of DevTools, which includes interaction with + * the DOM tree view UI elements and the DOM model. + */ +class DocumentModelTreeHandler +{ +private: + std::unique_ptr& mpDocumentModelTree; + css::uno::Reference mxDocument; + + // Clears all children of a tree node, where the parent is + // identified by the input tree iter. + void clearChildren(weld::TreeIter const& rParent); + + // Clear all tree view nodes. + void clearAll(); + +public: + DocumentModelTreeHandler(std::unique_ptr& pDocumentModelTree, + css::uno::Reference const& xDocument); + + DECL_LINK(ExpandingHandler, const weld::TreeIter&, bool); + + void inspectDocument(); + + static css::uno::Reference getObjectByID(OUString const& rID); + + void dispose(); + + // selects the input object if it exists in the DOM tree view + void selectObject(css::uno::Reference const& xInterface); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/devtools/ObjectInspectorTreeHandler.hxx b/include/sfx2/devtools/ObjectInspectorTreeHandler.hxx new file mode 100644 index 000000000..b6fa678de --- /dev/null +++ b/include/sfx2/devtools/ObjectInspectorTreeHandler.hxx @@ -0,0 +1,101 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include + +/** Object inspector tree handler + * + * Handles the object inspector part of DevTools - mainly interaction + * between UI objects that consist of the object inspector. + * + */ +class ObjectInspectorTreeHandler +{ +private: + std::unique_ptr& mpObjectInspectorWidgets; + + // object stack to remember previously inspected objects so it is + // possible to return back to them + std::deque maInspectionStack; + + // just the current context + css::uno::Reference mxContext; + + // treeview sort and compare + comphelper::string::NaturalStringSorter mxSorter; + void setSortFunction(std::unique_ptr& pTreeView); + sal_Int32 compare(std::unique_ptr& pTreeView, const weld::TreeIter& rLeft, + const weld::TreeIter& rRight); + + // treeview manipulation + static void clearObjectInspectorChildren(std::unique_ptr& pTreeView, + weld::TreeIter const& rParent); + static void handleExpanding(std::unique_ptr& pTreeView, + weld::TreeIter const& rParent); + static void clearAll(std::unique_ptr& pTreeView); + + void appendInterfaces(css::uno::Reference const& xInterface); + void appendServices(css::uno::Reference const& xInterface); + void appendProperties(css::uno::Reference const& xInterface); + void appendMethods(css::uno::Reference const& xInterface); + + void inspectObject(css::uno::Reference const& xInterface); + + // Object stack handling + void clearStack(); + void addToStack(css::uno::Any const& rAny); + css::uno::Any popFromStack(); + + void updateBackButtonState(); + +public: + ObjectInspectorTreeHandler(std::unique_ptr& pObjectInspectorWidgets); + + // callbacks when a node in the tree view is expanded + DECL_LINK(ExpandingHandlerInterfaces, const weld::TreeIter&, bool); + DECL_LINK(ExpandingHandlerServices, const weld::TreeIter&, bool); + DECL_LINK(ExpandingHandlerProperties, const weld::TreeIter&, bool); + DECL_LINK(ExpandingHandlerMethods, const weld::TreeIter&, bool); + + // callback when the tree view selection changed to a different node + DECL_LINK(SelectionChanged, weld::TreeView&, void); + + // callback when a pop-up is triggered on a tree view node + DECL_LINK(PopupMenuHandler, const CommandEvent&, bool); + + // callback when a button is clicked on a toolbar + DECL_LINK(ToolbarButtonClicked, const OString&, void); + + // callback when a page is entered or left on the notebook bar for + // different categories + DECL_LINK(NotebookEnterPage, const OString&, void); + DECL_LINK(NotebookLeavePage, const OString&, bool); + + DECL_LINK(HeaderBarClick, int, void); + + void introspect(css::uno::Reference const& xInterface); + + void dispose(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/devtools/ObjectInspectorWidgets.hxx b/include/sfx2/devtools/ObjectInspectorWidgets.hxx new file mode 100644 index 000000000..9c719d2aa --- /dev/null +++ b/include/sfx2/devtools/ObjectInspectorWidgets.hxx @@ -0,0 +1,55 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include + +struct ObjectInspectorWidgets +{ + ObjectInspectorWidgets(const std::unique_ptr& rxBuilder) + : mpClassNameLabel(rxBuilder->weld_label("class_name_value_id")) + , mpInterfacesTreeView(rxBuilder->weld_tree_view("interfaces_treeview_id")) + , mpServicesTreeView(rxBuilder->weld_tree_view("services_treeview_id")) + , mpPropertiesTreeView(rxBuilder->weld_tree_view("properties_treeview_id")) + , mpMethodsTreeView(rxBuilder->weld_tree_view("methods_treeview_id")) + , mpToolbar(rxBuilder->weld_toolbar("object_inspector_toolbar")) + , mpNotebook(rxBuilder->weld_notebook("object_inspector_notebookbar")) + , mpTextView(rxBuilder->weld_text_view("object_inspector_text_view")) + , mpPaned(rxBuilder->weld_paned("object_inspector_paned")) + { + } + + ~ObjectInspectorWidgets() + { + // dispose welded objects + mpClassNameLabel.reset(); + mpInterfacesTreeView.reset(); + mpServicesTreeView.reset(); + mpPropertiesTreeView.reset(); + mpMethodsTreeView.reset(); + mpToolbar.reset(); + mpNotebook.reset(); + mpTextView.reset(); + mpPaned.reset(); + } + + std::unique_ptr mpClassNameLabel; + std::unique_ptr mpInterfacesTreeView; + std::unique_ptr mpServicesTreeView; + std::unique_ptr mpPropertiesTreeView; + std::unique_ptr mpMethodsTreeView; + std::unique_ptr mpToolbar; + std::unique_ptr mpNotebook; + std::unique_ptr mpTextView; + std::unique_ptr mpPaned; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/dialoghelper.hxx b/include/sfx2/dialoghelper.hxx new file mode 100644 index 000000000..a853d5d9d --- /dev/null +++ b/include/sfx2/dialoghelper.hxx @@ -0,0 +1,41 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_DIALOGHELPER_HXX +#define INCLUDED_SFX2_DIALOGHELPER_HXX + +#include +#include +#include + +class DateTime; +class LocaleDataWrapper; +class OutputDevice; + +//when two tab pages both have the same basic layout with a preview on the +//right, get both of their non-preview areas to request the same size so that +//the preview appears in the same place in each one so flipping between tabs +//isn't distracting as it jumps around + +Size SFX2_DLLPUBLIC getParagraphPreviewOptimalSize(const OutputDevice& rReference); + +Size SFX2_DLLPUBLIC getDrawPreviewOptimalSize(const OutputDevice& rReference); + +Size SFX2_DLLPUBLIC getPreviewStripSize(const OutputDevice& rReference); + +Size SFX2_DLLPUBLIC getPreviewOptionsSize(const OutputDevice& rReference); + +OUString SFX2_DLLPUBLIC getWidestDateTime(const LocaleDataWrapper& rWrapper, bool bWithSec); + +OUString SFX2_DLLPUBLIC formatDateTime(const DateTime& rDateTime, const LocaleDataWrapper& rWrapper, + bool bWithSec); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/digitalsignatures.hxx b/include/sfx2/digitalsignatures.hxx new file mode 100644 index 000000000..8f0e161b4 --- /dev/null +++ b/include/sfx2/digitalsignatures.hxx @@ -0,0 +1,38 @@ +/* -*- 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/. + */ + +#pragma once + +#include +#include +#include +#include + +#include + +namespace sfx2 +{ +/// Extension of css::security::XDocumentDigitalSignatures for internal purposes. +class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI DigitalSignatures +{ +public: + /// Same as signDocumentWithCertificate(), but passes the xModel as well. + virtual bool + SignModelWithCertificate(const css::uno::Reference& xModel, + const css::uno::Reference& xCertificate, + const css::uno::Reference& xStorage, + const css::uno::Reference& xStream) + = 0; + +protected: + ~DigitalSignatures() noexcept = default; +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx new file mode 100644 index 000000000..fc7ebbfd4 --- /dev/null +++ b/include/sfx2/dinfdlg.hxx @@ -0,0 +1,579 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_DINFDLG_HXX +#define INCLUDED_SFX2_DINFDLG_HXX + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#include +#include + +namespace com::sun::star::beans { struct PropertyValue; } + +namespace com::sun::star { + namespace document { + class XDocumentProperties; + } +} + +struct CustomProperty; +class SvtCalendarBox; + +// class SfxDocumentInfoItem --------------------------------------------- + +class UNLESS_MERGELIBS(SFX2_DLLPUBLIC) SfxDocumentInfoItem final : public SfxStringItem +{ +private: + sal_Int32 m_AutoloadDelay; + OUString m_AutoloadURL; + bool m_isAutoloadEnabled; + OUString m_DefaultTarget; + OUString m_TemplateName; + OUString m_Author; + css::util::DateTime m_CreationDate; + OUString m_ModifiedBy; + css::util::DateTime m_ModificationDate; + OUString m_PrintedBy; + css::util::DateTime m_PrintDate; + sal_Int16 m_EditingCycles; + sal_Int32 m_EditingDuration; + OUString m_Description; + OUString m_Keywords; + OUString m_Subject; + OUString m_Title; + bool m_bHasTemplate; + bool m_bDeleteUserData; + bool m_bUseUserData; + bool m_bUseThumbnailSave; + std::vector< std::unique_ptr > m_aCustomProperties; + css::uno::Sequence< css::document::CmisProperty > m_aCmisProperties; + +public: + static SfxPoolItem* CreateDefault(); + SfxDocumentInfoItem(); + SfxDocumentInfoItem( const OUString &rFileName, + const css::uno::Reference< css::document::XDocumentProperties> & i_xDocProps, + const css::uno::Sequence< css::document::CmisProperty> & i_cmisProps, + bool bUseUserData, bool bUseThumbnailSave ); + SfxDocumentInfoItem( const SfxDocumentInfoItem& ); + virtual ~SfxDocumentInfoItem() override; + + /// update i_xDocProps with the data in this object + void UpdateDocumentInfo( + const css::uno::Reference< css::document::XDocumentProperties> & i_xDocProps, + bool i_bDoNotUpdateUserDefined = false) + const; + bool isCmisDocument() const { return m_aCmisProperties.hasElements();} + + bool isAutoloadEnabled() const { return m_isAutoloadEnabled; } + sal_Int32 getAutoloadDelay() const { return m_AutoloadDelay; } + const OUString& getAutoloadURL() const { return m_AutoloadURL; } + const OUString& getDefaultTarget() const { return m_DefaultTarget; } + const OUString& getTemplateName() const { return m_TemplateName; } + const OUString& getAuthor() const { return m_Author; } + + const css::util::DateTime& + getCreationDate() const { return m_CreationDate; } + const OUString& getModifiedBy() const { return m_ModifiedBy; } + + const css::util::DateTime& + getModificationDate() const { return m_ModificationDate; } + const OUString& getPrintedBy() const { return m_PrintedBy; } + const css::util::DateTime& + getPrintDate() const { return m_PrintDate; } + sal_Int16 getEditingCycles() const { return m_EditingCycles; } + sal_Int32 getEditingDuration() const { return m_EditingDuration; } + const OUString& getDescription() const { return m_Description; } + void setDescription(const OUString& i_val) { m_Description = i_val; } + const OUString& getKeywords() const { return m_Keywords; } + void setKeywords(const OUString& i_val) { m_Keywords = i_val; } + const OUString& getSubject() const { return m_Subject; } + void setSubject(const OUString& i_val) { m_Subject = i_val; } + const OUString& getTitle() const { return m_Title; } + void setTitle(const OUString& i_val) { m_Title = i_val; } + + /// reset user-specific data (author, modified-by, ...) + void resetUserData(const OUString & i_rAuthor); + + void SetTemplate( bool b ) { m_bHasTemplate = b; } + bool HasTemplate() const { return m_bHasTemplate; } + void SetDeleteUserData( bool bSet ); + void SetUseUserData( bool bSet ); + void SetUseThumbnailSave( bool bSet ); + bool IsUseUserData() const { return m_bUseUserData;} + bool IsUseThumbnailSave() const { return m_bUseThumbnailSave;} + + + std::vector< std::unique_ptr > GetCustomProperties() const; + void ClearCustomProperties(); + void AddCustomProperty( const OUString& sName, + const css::uno::Any& rValue ); + + const css::uno::Sequence< css::document::CmisProperty >& + GetCmisProperties() const { return m_aCmisProperties;} + + void SetCmisProperties(const css::uno::Sequence< css::document::CmisProperty >& cmisProps ); + virtual SfxDocumentInfoItem* Clone( SfxItemPool* pPool = nullptr ) const override; + virtual bool operator==( const SfxPoolItem& ) const override; + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; +}; + +// class SfxDocumentPage ------------------------------------------------- + +class SfxDocumentPage final : public SfxTabPage +{ +private: + OUString m_aUnknownSize; + OUString m_aMultiSignedStr; + + bool bEnableUseUserData : 1, + bHandleDelete : 1; + + std::unique_ptr m_xBmp; + std::unique_ptr m_xNameED; + std::unique_ptr m_xChangePassBtn; + + std::unique_ptr m_xShowTypeFT; + std::unique_ptr m_xFileValEd; + std::unique_ptr m_xShowSizeFT; + + std::unique_ptr m_xCreateValFt; + std::unique_ptr m_xChangeValFt; + std::unique_ptr m_xSignedValFt; + std::unique_ptr m_xSignatureBtn; + std::unique_ptr m_xPrintValFt; + std::unique_ptr m_xTimeLogValFt; + std::unique_ptr m_xDocNoValFt; + + std::unique_ptr m_xUseUserDataCB; + std::unique_ptr m_xDeleteBtn; + std::unique_ptr m_xUseThumbnailSaveCB; + + std::unique_ptr m_xTemplFt; + std::unique_ptr m_xTemplValFt; + std::unique_ptr m_xImagePreferredDpiCheckButton; + std::unique_ptr m_xImagePreferredDpiComboBox; + + DECL_LINK(DeleteHdl, weld::Button&, void); + DECL_LINK(SignatureHdl, weld::Button&, void); + DECL_LINK(ChangePassHdl, weld::Button&, void); + DECL_LINK(ImagePreferredDPICheckBoxClicked, weld::Toggleable&, void); + + void ImplUpdateSignatures(); + void ImplCheckPasswordState(); + + virtual bool FillItemSet( SfxItemSet* ) override; + virtual void Reset( const SfxItemSet* ) override; + +public: + SfxDocumentPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet&); + static std::unique_ptr Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* ); + virtual ~SfxDocumentPage() override; + + void EnableUseUserData(); +}; + +// class SfxDocumentDescPage --------------------------------------------- + +class SfxDocumentDescPage final : public SfxTabPage +{ +private: + SfxDocumentInfoItem* m_pInfoItem; + std::unique_ptr m_xTitleEd; + std::unique_ptr m_xThemaEd; + std::unique_ptr m_xKeywordsEd; + std::unique_ptr m_xCommentEd; + + virtual bool FillItemSet( SfxItemSet* ) override; + virtual void Reset( const SfxItemSet* ) override; + +public: + SfxDocumentDescPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet&); + virtual ~SfxDocumentDescPage() override; + static std::unique_ptr Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* ); +}; + +// class SfxDocumentInfoDialog ------------------------------------------- + +class SFX2_DLLPUBLIC SfxDocumentInfoDialog final : public SfxTabDialogController +{ + virtual void PageCreated(const OString& rId, SfxTabPage& rPage) override; + +public: + SfxDocumentInfoDialog(weld::Window* pParent, const SfxItemSet&); + void AddFontTabPage(); +}; + +// class CustomPropertiesRemoveButton ------------------------------------ +struct CustomPropertyLine; + +class CustomPropertiesDateField +{ +private: + std::unique_ptr m_xDateField; +public: + ::std::optional m_TZ; + + CustomPropertiesDateField(SvtCalendarBox* pDateField); + void set_visible(bool bVisible); + Date get_date() const; + void set_date(const Date& rDate); + ~CustomPropertiesDateField(); +}; + +namespace weld +{ + class TimeFormatter; +} + +class CustomPropertiesTimeField +{ +public: + std::unique_ptr m_xTimeField; + std::unique_ptr m_xFormatter; + bool m_isUTC; + + CustomPropertiesTimeField(std::unique_ptr xTimeField); + void set_visible(bool bVisible) { m_xTimeField->set_visible(bVisible); } + tools::Time get_value() const; + void set_value(const tools::Time& rTime); + + ~CustomPropertiesTimeField(); +}; + +class CustomPropertiesDurationField +{ + css::util::Duration m_aDuration; + std::unique_ptr m_xEntry; + std::unique_ptr m_xEditButton; + + DECL_LINK(ClickHdl, weld::Button&, void); +public: + CustomPropertiesDurationField(std::unique_ptr xEntry, + std::unique_ptr xEditButton); + + void SetDuration( const css::util::Duration& rDuration ); + const css::util::Duration& GetDuration() const { return m_aDuration; } + + void set_visible(bool bVisible); +}; + +class CustomPropertiesYesNoButton +{ +private: + std::unique_ptr m_xTopLevel; + std::unique_ptr m_xYesButton; + std::unique_ptr m_xNoButton; + +public: + CustomPropertiesYesNoButton(std::unique_ptr, + std::unique_ptr xYesButton, + std::unique_ptr xNoButton); + ~CustomPropertiesYesNoButton(); + + void CheckYes() { m_xYesButton->set_active(true); } + void CheckNo() { m_xNoButton->set_active(true); } + bool IsYesChecked() const { return m_xYesButton->get_active(); } + void set_visible(bool bVisible) { m_xTopLevel->set_visible(bVisible); } +}; + +class CustomPropertiesWindow; + +// struct CustomPropertyLine --------------------------------------------- +struct CustomPropertyLine +{ + CustomPropertiesWindow* m_pParent; + + std::unique_ptr m_xBuilder; + std::unique_ptr m_xLine; + std::unique_ptr m_xNameBox; + std::unique_ptr m_xTypeBox; + std::unique_ptr m_xValueEdit; + std::unique_ptr m_xDateTimeBox; + std::unique_ptr m_xDateField; + std::unique_ptr m_xTimeField; + std::unique_ptr m_xDurationBox; + std::unique_ptr m_xDurationField; + std::unique_ptr m_xYesNoButton; + std::unique_ptr m_xRemoveButton; + + bool m_bTypeLostFocus; + + CustomPropertyLine(CustomPropertiesWindow* pParent, weld::Widget* pContainer); + DECL_LINK(TypeHdl, weld::ComboBox&, void); + DECL_LINK(RemoveHdl, weld::Button&, void); + DECL_LINK(EditLoseFocusHdl, weld::Widget&, void); + DECL_LINK(BoxLoseFocusHdl, weld::Widget&, void); + + void DoTypeHdl(const weld::ComboBox& rBox); + + void Clear(); + void Hide(); +}; + +// class CustomPropertiesWindow ------------------------------------------ + +class CustomPropertiesWindow +{ +private: + sal_Int32 m_nHeight; + sal_Int32 m_nLineHeight; + sal_Int32 m_nScrollPos; + std::vector> m_aCustomProperties; + std::vector> m_aCustomPropertiesLines; + CustomPropertyLine* m_pCurrentLine; + SvNumberFormatter m_aNumberFormatter; + Idle m_aEditLoseFocusIdle; + Idle m_aBoxLoseFocusIdle; + Link m_aRemovedHdl; + + weld::Container& m_rBody; + weld::Label& m_rHeaderAccName; + weld::Label& m_rHeaderAccType; + weld::Label& m_rHeaderAccValue; + + DECL_LINK(EditTimeoutHdl, Timer *, void); + DECL_LINK(BoxTimeoutHdl, Timer *, void); + + bool IsLineValid( CustomPropertyLine* pLine ) const; + void ValidateLine( CustomPropertyLine* pLine, bool bIsFromTypeBox ); + void CreateNewLine(); + void StoreCustomProperties(); + sal_uInt32 GetCurrentDataModelPosition() const { return -1 * m_nScrollPos / m_nLineHeight; } + +public: + CustomPropertiesWindow(weld::Container& rParent, weld::Label& rHeaderAccName, + weld::Label& rHeaderAccType, weld::Label& rHeaderAccValue); + ~CustomPropertiesWindow(); + + sal_uInt16 GetExistingLineCount() const { return m_aCustomPropertiesLines.size(); } + sal_uInt16 GetTotalLineCount() const { return m_aCustomProperties.size(); } + void SetVisibleLineCount(sal_uInt32 nCount); + sal_Int32 GetHeight() const { return m_nHeight; } + void SetHeight(int nHeight) { m_nHeight = nHeight; } + sal_Int32 GetLineHeight() const { return m_nLineHeight; } + void SetLineHeight(sal_Int32 nLineHeight) { m_nLineHeight = nLineHeight; } + void AddLine( const OUString& sName, css::uno::Any const & rAny ); + bool AreAllLinesValid() const; + void ClearAllLines(); + void DoScroll( sal_Int32 nNewPos ); + void ReloadLinesContent(); + + css::uno::Sequence< css::beans::PropertyValue > + GetCustomProperties(); + void SetCustomProperties(std::vector< std::unique_ptr >&& rProperties); + void SetRemovedHdl( const Link& rLink ) { m_aRemovedHdl = rLink; } + + void BoxLoseFocus(CustomPropertyLine* pLine); + void EditLoseFocus(CustomPropertyLine* pLine); + void Remove(const CustomPropertyLine* pLine); +}; + +// class CustomPropertiesControl ----------------------------------------- + +class CustomPropertiesControl +{ +private: + sal_Int32 m_nThumbPos; + + std::unique_ptr m_xBox; + std::unique_ptr m_xBody; + std::unique_ptr m_xVertScroll; + std::unique_ptr m_xPropertiesWin; + std::unique_ptr m_xName; + std::unique_ptr m_xType; + std::unique_ptr m_xValue; + + DECL_LINK( ResizeHdl, const Size&, void ); + DECL_LINK( ScrollHdl, weld::ScrolledWindow&, void ); + DECL_LINK( RemovedHdl, void*, void ); + +public: + CustomPropertiesControl(); + ~CustomPropertiesControl(); + + void AddLine(css::uno::Any const & rAny); + + bool AreAllLinesValid() const { return m_xPropertiesWin->AreAllLinesValid(); } + void ClearAllLines() { m_xPropertiesWin->ClearAllLines(); } + + css::uno::Sequence + GetCustomProperties() const + { return m_xPropertiesWin->GetCustomProperties(); } + void SetCustomProperties(std::vector< std::unique_ptr >&& rProperties); + + void Init(weld::Builder& rParent); +}; + +// class SfxCustomPropertiesPage ----------------------------------------- + +class SfxCustomPropertiesPage final : public SfxTabPage +{ +private: + DECL_LINK(AddHdl, weld::Button&, void); + + std::unique_ptr m_xPropertiesCtrl; + std::unique_ptr m_xAdd; + + virtual bool FillItemSet( SfxItemSet* ) override; + virtual void Reset( const SfxItemSet* ) override; + virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; + +public: + SfxCustomPropertiesPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet&); + static std::unique_ptr Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* ); + virtual ~SfxCustomPropertiesPage() override; +}; + +struct CmisValue +{ + std::unique_ptr m_xBuilder; + std::unique_ptr m_xFrame; + std::unique_ptr m_xValueEdit; + + CmisValue(weld::Widget* pParent, const OUString& rStr); +}; + +struct CmisDateTime +{ + std::unique_ptr m_xBuilder; + std::unique_ptr m_xFrame; + std::unique_ptr m_xDateField; + std::unique_ptr m_xTimeField; + std::unique_ptr m_xFormatter; + + CmisDateTime(weld::Widget* pParent, const css::util::DateTime& rDateTime); +}; + +struct CmisYesNo +{ + std::unique_ptr m_xBuilder; + std::unique_ptr m_xFrame; + std::unique_ptr m_xYesButton; + std::unique_ptr m_xNoButton; + + CmisYesNo(weld::Widget* pParent, bool bValue); +}; + +// struct CmisPropertyLine --------------------------------------------- + +struct CmisPropertyLine +{ + std::unique_ptr m_xBuilder; + OUString m_sId; + OUString m_sType; + bool m_bUpdatable; + bool m_bRequired; + bool m_bMultiValued; + bool m_bOpenChoice; + std::unique_ptr m_xFrame; + std::unique_ptr m_xName; + std::unique_ptr m_xType; + std::vector< std::unique_ptr > m_aValues; + std::vector< std::unique_ptr > m_aDateTimes; + std::vector< std::unique_ptr > m_aYesNos; + CmisPropertyLine(weld::Widget* pParent); + ~CmisPropertyLine(); +}; + +// class CmisPropertiesWindow ------------------------------------------ + +class CmisPropertiesWindow +{ +private: + std::unique_ptr m_xBox; + SvNumberFormatter m_aNumberFormatter; + std::vector< std::unique_ptr > m_aCmisPropertiesLines; +public: + CmisPropertiesWindow(std::unique_ptr xParent); + ~CmisPropertiesWindow(); + + void AddLine( const OUString& sId, const OUString& sName, + const OUString& sType, const bool bUpdatable, + const bool bRequired, const bool bMultiValued, + const bool bOpenChoice, + css::uno::Any& aChoices, + css::uno::Any const & rAny ); + void ClearAllLines(); + + css::uno::Sequence< css::document::CmisProperty > + GetCmisProperties() const; +}; + +// class CmisPropertiesControl ----------------------------------------- + +class CmisPropertiesControl +{ +private: + CmisPropertiesWindow m_aPropertiesWin; + std::unique_ptr m_xScrolledWindow; + +public: + CmisPropertiesControl(weld::Builder& rBuilder); + + void AddLine( const OUString& sId, const OUString& sName, + const OUString& sType, const bool bUpdatable, + const bool bRequired, const bool bMultiValude, + const bool bOpenChoice, + css::uno::Any& aChoices, + css::uno::Any const & rAny ); + + void ClearAllLines(); + css::uno::Sequence< css::document::CmisProperty > + GetCmisProperties() const + { return m_aPropertiesWin.GetCmisProperties(); } +}; + +// class SfxCmisPropertiesPage ------------------------------------------------- + +class SfxCmisPropertiesPage final : public SfxTabPage +{ +private: + std::unique_ptr m_xPropertiesCtrl; + + virtual bool FillItemSet( SfxItemSet* ) override; + virtual void Reset( const SfxItemSet* ) override; + virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; + +public: + SfxCmisPropertiesPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet&); + virtual ~SfxCmisPropertiesPage() override; + static std::unique_ptr Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet*); +}; + +#endif // #ifndef _ INCLUDED_SFX2_DINFDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx new file mode 100644 index 000000000..ee445710b --- /dev/null +++ b/include/sfx2/dispatch.hxx @@ -0,0 +1,184 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_DISPATCH_HXX +#define INCLUDED_SFX2_DISPATCH_HXX + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +class SfxSlotServer; +class SfxRequest; +class SfxViewFrame; +class SfxItemSet; +class SfxModule; +class Point; +struct SfxDispatcher_Impl; + +namespace com::sun::star::awt { class XPopupMenu; } +namespace vcl { class Window; } + +enum class SfxDispatcherPopFlags +{ + NONE = 0, + POP_UNTIL = 4, + POP_DELETE = 2, + PUSH = 1, +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +enum class SfxSlotFilterState +{ + DISABLED, + ENABLED, + // enabled even if ReadOnlyDoc + ENABLED_READONLY, +}; + + +class SFX2_DLLPUBLIC SfxDispatcher final +{ + std::unique_ptr xImp; + + // Search for temporary evaluated Todos + SAL_DLLPRIVATE bool CheckVirtualStack( const SfxShell& rShell ); + +friend class SfxApplication; +friend class SfxViewFrame; +friend class SfxBindings; +friend class SfxStateCache; +friend class SfxPopupMenuManager; +friend class SfxHelp; + + DECL_DLLPRIVATE_LINK( EventHdl_Impl, Timer *, void ); + void PostMsgHandler(std::unique_ptr); + + SAL_DLLPRIVATE void Call_Impl( SfxShell& rShell, const SfxSlot &rSlot, SfxRequest &rReq, bool bRecord ); + SAL_DLLPRIVATE void Update_Impl_( bool,bool,bool,SfxWorkWindow*); + + + bool FindServer_( sal_uInt16 nId, SfxSlotServer &rServer ); + bool FillState_( const SfxSlotServer &rServer, + SfxItemSet &rState, const SfxSlot *pRealSlot ); + void Execute_( SfxShell &rShell, const SfxSlot &rSlot, + SfxRequest &rReq, + SfxCallMode eCall); + + void FlushImpl(); + +public: + SfxDispatcher(); + SfxDispatcher( SfxViewFrame *pFrame ); + + SAL_DLLPRIVATE void Construct_Impl(); + + ~SfxDispatcher(); + + const SfxPoolItem* Execute( sal_uInt16 nSlot, + SfxCallMode nCall = SfxCallMode::SLOT, + const SfxPoolItem **pArgs = nullptr, + sal_uInt16 nModi = 0, + const SfxPoolItem **pInternalArgs = nullptr); + + const SfxPoolItem* Execute(sal_uInt16 nSlot, + SfxCallMode nCall, + SfxItemSet const * pArgs, + SfxItemSet const * pInternalArgs, + sal_uInt16 nModi); + + const SfxPoolItem* ExecuteList(sal_uInt16 nSlot, + SfxCallMode nCall, + std::initializer_list args, + std::initializer_list internalargs = std::initializer_list()); + + const SfxPoolItem* Execute( sal_uInt16 nSlot, + SfxCallMode nCall, + const SfxItemSet &rArgs ); + + const SfxSlot* GetSlot( const OUString& rCommand ); + + bool IsActive( const SfxShell& rShell ); + sal_uInt16 GetShellLevel( const SfxShell &rShell ); + SfxBindings* GetBindings() const; + + void Push( SfxShell& rShell ); + void Pop( SfxShell& rShell, SfxDispatcherPopFlags nMode = SfxDispatcherPopFlags::NONE ); + + SfxShell* GetShell(sal_uInt16 nIdx) const; + SfxViewFrame* GetFrame() const; + SfxModule* GetModule() const; + + void ExecutePopup( const OUString &rResName, vcl::Window *pWin = nullptr, const Point *pPos = nullptr ); + static void ExecutePopup( vcl::Window *pWin = nullptr, const Point *pPosPixel = nullptr ); + + bool IsAppDispatcher() const; + bool IsFlushed() const; + void Flush(); + void Lock( bool bLock ); + bool IsLocked() const; + void SetSlotFilter( SfxSlotFilterState nEnable = SfxSlotFilterState::DISABLED, + o3tl::span pSIDs = o3tl::span()); + + void HideUI( bool bHide = true ); + ToolbarId GetObjectBarId( sal_uInt16 nPos ) const; + + SfxItemState QueryState( sal_uInt16 nSID, const SfxPoolItem* &rpState ); + template + SfxItemState QueryState( TypedWhichId nSID, const T* &rpState ) + { + return QueryState(sal_uInt16(nSID), reinterpret_cast(rpState)); + } + SfxItemState QueryState( sal_uInt16 nSID, css::uno::Any& rAny ); + + void SetDisableFlags( SfxDisableFlags nFlags ); + SfxDisableFlags GetDisableFlags() const; + + SAL_DLLPRIVATE void SetMenu_Impl(); + SAL_DLLPRIVATE void Update_Impl( bool bForce = false ); // ObjectBars etc. + SAL_DLLPRIVATE bool IsUpdated_Impl() const; + SAL_DLLPRIVATE bool GetShellAndSlot_Impl( sal_uInt16 nSlot, SfxShell **ppShell, const SfxSlot **ppSlot, + bool bOwnShellsOnly, bool bRealSlot ); + SAL_DLLPRIVATE void SetReadOnly_Impl( bool bOn ); + SAL_DLLPRIVATE bool GetReadOnly_Impl() const; + SAL_DLLPRIVATE SfxSlotFilterState IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const; + SAL_DLLPRIVATE void SetQuietMode_Impl( bool bOn ); + SAL_DLLPRIVATE bool IsReadOnlyShell_Impl( sal_uInt16 nShell ) const; + SAL_DLLPRIVATE void RemoveShell_Impl( SfxShell& rShell ); + SAL_DLLPRIVATE void DoActivate_Impl( bool bMDI ); + SAL_DLLPRIVATE void DoDeactivate_Impl( bool bMDI, SfxViewFrame const * pNew ); + SAL_DLLPRIVATE void InvalidateBindings_Impl(bool); + + static boost::property_tree::ptree fillPopupMenu(const css::uno::Reference& rMenu); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/dllapi.h b/include/sfx2/dllapi.h new file mode 100644 index 000000000..a6877f769 --- /dev/null +++ b/include/sfx2/dllapi.h @@ -0,0 +1,36 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_DLLAPI_H +#define INCLUDED_SFX2_DLLAPI_H + +#include +#include + +#if defined SFX2_DLLIMPLEMENTATION +#define SFX2_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define SFX2_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif + +#define SFX2_DLLPRIVATE SAL_DLLPRIVATE + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/docfac.hxx b/include/sfx2/docfac.hxx new file mode 100644 index 000000000..884112530 --- /dev/null +++ b/include/sfx2/docfac.hxx @@ -0,0 +1,96 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_DOCFAC_HXX +#define INCLUDED_SFX2_DOCFAC_HXX + +#include +#include +#include + +#include +#include +#include + +class SfxFilter; +class SfxViewFactory; +struct SfxObjectFactory_Impl; +class SfxFilterContainer; +class SvGlobalName; +class SfxModule; + +typedef void (*SfxVoidFunc)(); + + +class SFX2_DLLPUBLIC SfxObjectFactory +{ +private: + const OUString m_sFactoryName; + std::unique_ptr pImpl; // Additional Data + +public: + SfxObjectFactory( const SvGlobalName &rName, const OUString& sFactoryName ); + ~SfxObjectFactory(); + + const SvGlobalName& GetClassId() const; + OUString GetFactoryURL() const; // shortcut for "private:factory/GetShortName()" + const OUString& GetFactoryName() const { return m_sFactoryName; } + OUString GetModuleName() const; + SfxFilterContainer *GetFilterContainer() const; + + // Views + void RegisterViewFactory(SfxViewFactory &rFactory); + sal_uInt16 GetViewFactoryCount() const; + SfxViewFactory& GetViewFactory(sal_uInt16 i = 0) const; + + /// returns the view factory whose GetAPIViewName or GetLegacyViewName delivers the requested logical name + SfxViewFactory* GetViewFactoryByViewName( std::u16string_view i_rViewName ) const; + + // Filter + std::shared_ptr GetTemplateFilter() const; + static OUString GetStandardTemplate( std::u16string_view rServiceName ); + static void SetStandardTemplate( const OUString& rServiceName, const OUString& rTemplateName ); + static void SetSystemTemplate( const OUString& rServiceName, const OUString& rTemplateName ); + + void SetDocumentServiceName( const OUString& rServiceName ); + const OUString& GetDocumentServiceName() const; + + SfxModule* GetModule() const; + + SAL_DLLPRIVATE void SetModule_Impl( SfxModule* ); + SAL_DLLPRIVATE sal_uInt16 GetViewNo_Impl( const SfxInterfaceId i_nViewId, const sal_uInt16 i_nFallback ) const; + +private: + SfxObjectFactory(const SfxObjectFactory&) = delete; + const SfxObjectFactory& operator=(const SfxObjectFactory &) = delete; +}; + +#define SFX_DECL_OBJECTFACTORY() \ +public: \ + static SfxObjectFactory& Factory(); \ + virtual SfxObjectFactory& GetFactory() const override { return Factory(); } + +#define SFX_IMPL_OBJECTFACTORY(ClassName,GlobName,ShortName) \ + SfxObjectFactory& ClassName::Factory() \ + { \ + static SfxObjectFactory aObjectFactory(GlobName, ShortName); \ + return aObjectFactory; \ + } +#endif // INCLUDED_SFX2_DOCFAC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx new file mode 100644 index 000000000..bc6e0cf1e --- /dev/null +++ b/include/sfx2/docfile.hxx @@ -0,0 +1,309 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_DOCFILE_HXX +#define INCLUDED_SFX2_DOCFILE_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::embed { class XStorage; } +namespace com::sun::star::graphic { class XGraphic; } +namespace com::sun::star::io { class XInputStream; } +namespace com::sun::star::security { class XCertificate; } +namespace com::sun::star::task { class XInteractionHandler; } +namespace com::sun::star::ucb { class XCommandEnvironment; } +namespace com::sun::star::ucb { class XContent; } +namespace com::sun::star::util { struct DateTime; } +namespace com::sun::star::util { struct RevisionTag; } +namespace com::sun::star::frame +{ +class XModel; +} +namespace ucbhelper { class Content; } + +class SvKeyValueIterator; +class SfxFilter; +class SfxMedium_Impl; +class INetURLObject; +class SfxFrame; +class DateTime; +struct ImplSVEvent; + +namespace weld +{ + class Window; +} + +class SFX2_DLLPUBLIC SfxMedium final : public SvRefBase +{ + std::unique_ptr< SfxMedium_Impl > pImpl; + + SAL_DLLPRIVATE void SetIsRemote_Impl(); + SAL_DLLPRIVATE void CloseInStream_Impl(bool bInDestruction = false); + SAL_DLLPRIVATE void CloseOutStream_Impl(); + SAL_DLLPRIVATE void CloseStreams_Impl(bool bInDestruction = false); + + SAL_DLLPRIVATE void SetEncryptionDataToStorage_Impl(); + +public: + + SfxMedium(); + SfxMedium( const OUString &rName, + StreamMode nOpenMode, + std::shared_ptr pFilter = nullptr, + const std::shared_ptr& pSet = nullptr ); + SfxMedium( const OUString &rName, + const OUString &rReferer, + StreamMode nOpenMode, + std::shared_ptr pFilter = nullptr, + const std::shared_ptr& pSet = nullptr ); + SfxMedium( const css::uno::Reference< css::embed::XStorage >& xStorage, + const OUString& rBaseURL, + const std::shared_ptr& pSet = nullptr ); + SfxMedium( const css::uno::Reference< css::embed::XStorage >& xStorage, + const OUString& rBaseURL, + const OUString& rTypeName, + const std::shared_ptr& pSet = nullptr ); + SfxMedium( const css::uno::Sequence< css::beans::PropertyValue >& aArgs ); + + virtual ~SfxMedium() override; + + DECL_DLLPRIVATE_STATIC_LINK(SfxMedium, ShowReloadEditableDialog, void*, void); + bool CheckCanGetLockfile() const; + void SetOriginallyReadOnly(bool val); + void AddToCheckEditableWorkerList(); + void SetWorkerReloadEvent(ImplSVEvent* pEvent); + ImplSVEvent* GetWorkerReloadEvent() const; + const std::shared_ptr& GetCheckEditableMutex() const; + void CancelCheckEditableEntry(bool bRemoveEvent = true); + + void UseInteractionHandler( bool ); + css::uno::Reference< css::task::XInteractionHandler > + GetInteractionHandler( bool bGetAlways = false ); + + void setStreamToLoadFrom( + const css::uno::Reference& xInputStream, + bool bIsReadOnly); + + void SetLoadTargetFrame(SfxFrame* pFrame ); + SfxFrame* GetLoadTargetFrame() const; + + /** + * Does not take ownership of pFlt but pFlt needs to be around as long as the SfxMedium instance. + */ + void SetFilter(const std::shared_ptr& pFilter); + const std::shared_ptr& GetFilter() const; + const OUString& GetOrigURL() const; + + SfxItemSet * GetItemSet() const; + void SetArgs(const css::uno::Sequence& rArgs); + const css::uno::Sequence & GetArgs() const; + void Close(bool bInDestruction = false); + void CloseAndRelease(); + void ReOpen(); + void CompleteReOpen(); + const OUString& GetName() const; + const INetURLObject& GetURLObject() const; + + void CheckFileDate( const css::util::DateTime& aInitDate ); + [[nodiscard]] bool DocNeedsFileDateCheck() const; + css::util::DateTime const & GetInitFileDate( bool bIgnoreOldValue ); + + css::uno::Reference< css::ucb::XContent > GetContent() const; + const OUString& GetPhysicalName() const; + [[nodiscard]] bool IsRemote() const; + [[nodiscard]] bool IsOpen() const; // { return aStorage.Is() || pInStream; } + void Download( const Link& aLink = Link()); + void SetDoneLink( const Link& rLink ); + + ErrCode GetErrorCode() const; + ErrCode GetError() const + { return GetErrorCode().IgnoreWarning(); } + ErrCode const & GetLastStorageCreationState() const; + + void SetError(ErrCode nError); + + void CloseInStream(); + void CloseOutStream(); + + void CloseStorage(); + + StreamMode GetOpenMode() const; + void SetOpenMode( StreamMode nStorOpen, bool bDontClose = false ); + + SvStream* GetInStream(); + SvStream* GetOutStream(); + + bool Commit(); + bool IsStorage(); + + enum class LockFileResult + { + Failed, + FailedLockFile, // there was only lock file that prevented success - no syslock or IO error + Succeeded, + }; + LockFileResult LockOrigFileOnDemand(bool bLoading, bool bNoUI, bool bTryIgnoreLockFile = false, + LockFileEntry* pLockData = nullptr); + void DisableUnlockWebDAV( bool bDisableUnlockWebDAV = true ); + void UnlockFile( bool bReleaseLockStream ); + /// Lets Transfer_Impl() not fsync the output file. + void DisableFileSync(bool bDisableFileSync); + + css::uno::Reference< css::embed::XStorage > GetStorage( bool bCreateTempFile = true ); + css::uno::Reference< css::embed::XStorage > GetOutputStorage(); + void ResetError(); + [[nodiscard]] bool IsExpired() const; + void SetName( const OUString& rName, bool bSetOrigURL = false ); + + const css::uno::Sequence < css::util::RevisionTag >& + GetVersionList( bool _bNoReload = false ); + [[nodiscard]] bool IsReadOnly() const; + + // Whether the medium had originally been opened r/o (either because it is + // "physically" r/o, or because it was requested to be opened r/o, + // independent of later changes via SetOpenMode; used to keep track of the + // "true" state of the medium across toggles via SID_EDITDOC (which do + // change SetOpenMode): + [[nodiscard]] bool IsOriginallyReadOnly() const; + + // Whether the medium had originally been requested to be opened r/o, + // independent of later changes via SetOpenMode; used for SID_RELOAD: + [[nodiscard]] bool IsOriginallyLoadedReadOnly() const; + + css::uno::Reference< css::io::XInputStream > const & GetInputStream(); + + void CreateTempFile( bool bReplace = true ); + void CreateTempFileNoCopy(); + OUString SwitchDocumentToTempFile(); + bool SwitchDocumentToFile( const OUString& aURL ); + + OUString GetBaseURL( bool bForSaving=false ); + void SetInCheckIn( bool bInCheckIn ); + bool IsInCheckIn( ) const; + bool IsSkipImages( ) const; + + SAL_DLLPRIVATE bool HasStorage_Impl() const; + + SAL_DLLPRIVATE void StorageBackup_Impl(); + SAL_DLLPRIVATE OUString const & GetBackup_Impl(); + + SAL_DLLPRIVATE css::uno::Reference< css::embed::XStorage > const & GetZipStorageToSign_Impl( bool bReadOnly = true ); + SAL_DLLPRIVATE void CloseZipStorage_Impl(); + + // the storage that will be returned by the medium on GetStorage request + SAL_DLLPRIVATE void SetStorage_Impl( const css::uno::Reference< css::embed::XStorage >& xNewStorage ); + + SAL_DLLPRIVATE void CloseAndReleaseStreams_Impl(); + SAL_DLLPRIVATE void AddVersion_Impl( css::util::RevisionTag& rVersion ); + SAL_DLLPRIVATE bool TransferVersionList_Impl( SfxMedium const & rMedium ); + SAL_DLLPRIVATE void SaveVersionList_Impl(); + SAL_DLLPRIVATE void RemoveVersion_Impl( const OUString& rVersion ); + + SAL_DLLPRIVATE void SetExpired_Impl( const DateTime& rDateTime ); + SAL_DLLPRIVATE SvKeyValueIterator* GetHeaderAttributes_Impl(); + + SAL_DLLPRIVATE void Init_Impl(); + + SAL_DLLPRIVATE void GetLockingStream_Impl(); + SAL_DLLPRIVATE void GetMedium_Impl(); + SAL_DLLPRIVATE bool TryDirectTransfer( const OUString& aURL, SfxItemSet const & aTargetSet ); + SAL_DLLPRIVATE void Transfer_Impl(); + SAL_DLLPRIVATE void CreateFileStream(); + SAL_DLLPRIVATE void SetUpdatePickList(bool); + SAL_DLLPRIVATE bool IsUpdatePickList() const; + + SAL_DLLPRIVATE void SetLongName(const OUString &rName); + SAL_DLLPRIVATE const OUString & GetLongName() const; + SAL_DLLPRIVATE bool IsPreview_Impl() const; + SAL_DLLPRIVATE void ClearBackup_Impl(); + SAL_DLLPRIVATE void SetPhysicalName_Impl(const OUString& rName); + SAL_DLLPRIVATE void CanDisposeStorage_Impl( bool bDisposeStorage ); + SAL_DLLPRIVATE bool WillDisposeStorageOnClose_Impl(); + + SAL_DLLPRIVATE void DoBackup_Impl(); + SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent ); + SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent, + std::u16string_view aPrefix, + const OUString& aExtension, + const OUString& aDestDir ); + + SAL_DLLPRIVATE bool UseBackupToRestore_Impl( ::ucbhelper::Content& aOriginalContent, + const css::uno::Reference< css::ucb::XCommandEnvironment >& xComEnv ); + + SAL_DLLPRIVATE bool StorageCommit_Impl(); + + SAL_DLLPRIVATE void TransactedTransferForFS_Impl( const INetURLObject& aSource, + const INetURLObject& aDest, + const css::uno::Reference< css::ucb::XCommandEnvironment >& xComEnv ); + + SAL_DLLPRIVATE bool + SignContents_Impl(weld::Window* pDialogParent, + bool bSignScriptingContent, bool bHasValidDocumentSignature, + const OUString& aSignatureLineId = OUString(), + const css::uno::Reference& xCert + = css::uno::Reference(), + const css::uno::Reference& xValidGraphic + = css::uno::Reference(), + const css::uno::Reference& xInvalidGraphic + = css::uno::Reference(), + const OUString& aComment = OUString()); + + SAL_DLLPRIVATE bool SignDocumentContentUsingCertificate( + const css::uno::Reference& xModel, bool bHasValidDocumentSignature, + const css::uno::Reference& xCertificate); + + // the following two methods must be used and make sense only during saving currently + // TODO/LATER: in future the signature state should be controlled by the medium not by the document + // in this case the methods will be used generally, and might need to be renamed + SAL_DLLPRIVATE SignatureState GetCachedSignatureState_Impl() const; + SAL_DLLPRIVATE void SetCachedSignatureState_Impl( SignatureState nState ); + + void SetHasEmbeddedObjects(bool bHasEmbeddedObjects); + + static css::uno::Sequence < css::util::RevisionTag > GetVersionList( + const css::uno::Reference< css::embed::XStorage >& xStorage ); + static OUString CreateTempCopyWithExt( std::u16string_view aURL ); + static bool CallApproveHandler(const css::uno::Reference< css::task::XInteractionHandler >& xHandler, const css::uno::Any& rRequest, bool bAllowAbort); + + static bool SetWritableForUserOnly( const OUString& aURL ); + static sal_uInt32 CreatePasswordToModifyHash( std::u16string_view aPasswd, bool bWriter ); + +private: + enum class ShowLockResult { NoLock, Succeeded, Try }; + ShowLockResult ShowLockedDocumentDialog(const LockFileEntry& aData, + bool bIsLoading, bool bOwnLock, bool bHandleSysLocked); + enum class MessageDlg { LockFileIgnore, LockFileCorrupt }; + bool ShowLockFileProblemDialog(MessageDlg nWhichDlg); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/docfilt.hxx b/include/sfx2/docfilt.hxx new file mode 100644 index 000000000..fb5bb5505 --- /dev/null +++ b/include/sfx2/docfilt.hxx @@ -0,0 +1,125 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_DOCFILT_HXX +#define INCLUDED_SFX2_DOCFILT_HXX + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace com::sun::star::embed { class XStorage; } +namespace com::sun::star::uno { template class Reference; } + +class SotStorage; + +class SFX2_DLLPUBLIC SfxFilter +{ + friend class SfxFilterContainer; + + WildCard aWildCard; + + OUString aTypeName; + OUString aUserData; + OUString aServiceName; + OUString aMimeType; + OUString maFilterName; + OUString aUIName; + OUString aDefaultTemplate; + + /** + * Custom provider name in case the filter is provided via external + * libraries. Empty for conventional filter types. + */ + OUString maProvider; + + SfxFilterFlags nFormatType; + sal_Int32 nVersion; + SotClipboardFormatId lFormat; + bool mbEnabled; + +public: + SfxFilter( const OUString& rProvider, const OUString& rFilterName ); + + SfxFilter( const OUString &rName, + std::u16string_view rWildCard, + SfxFilterFlags nFormatType, + SotClipboardFormatId lFormat, + const OUString &rTypeName, + const OUString &rMimeType, + const OUString &rUserData, + const OUString& rServiceName, + bool bEnabled = true ); + ~SfxFilter(); + + bool IsAllowedAsTemplate() const { return bool(nFormatType & SfxFilterFlags::TEMPLATE); } + bool IsOwnFormat() const { return bool(nFormatType & SfxFilterFlags::OWN); } + /// If the filter supports digital signatures. + bool GetSupportsSigning() const { return bool(nFormatType & SfxFilterFlags::SUPPORTSSIGNING); } + bool GetGpgEncryption() const { return bool(nFormatType & SfxFilterFlags::GPGENCRYPTION); } + bool IsOwnTemplateFormat() const { return bool(nFormatType & SfxFilterFlags::TEMPLATEPATH); } + /// not our built-in format + bool IsAlienFormat() const { return bool(nFormatType & SfxFilterFlags::ALIEN); } + /// an unusual/legacy file to be loading + bool IsExoticFormat() const { return bool(nFormatType & SfxFilterFlags::EXOTIC); } + bool CanImport() const { return bool(nFormatType & SfxFilterFlags::IMPORT); } + bool CanExport() const { return bool(nFormatType & SfxFilterFlags::EXPORT); } + SfxFilterFlags GetFilterFlags() const { return nFormatType; } + const OUString& GetFilterName() const { return maFilterName; } + const OUString& GetMimeType() const { return aMimeType; } + const OUString& GetName() const { return maFilterName; } + const WildCard& GetWildcard() const { return aWildCard; } + const OUString& GetRealTypeName() const { return aTypeName; } + SotClipboardFormatId GetFormat() const { return lFormat; } + const OUString& GetTypeName() const { return aTypeName; } + const OUString& GetUIName() const { return aUIName; } + const OUString& GetUserData() const { return aUserData; } + const OUString& GetDefaultTemplate() const { return aDefaultTemplate; } + void SetDefaultTemplate( const OUString& rStr ) { aDefaultTemplate = rStr; } + bool UsesStorage() const { return GetFormat() != SotClipboardFormatId::NONE; } + void SetUIName( const OUString& rName ) { aUIName = rName; } + void SetVersion( sal_Int32 nVersionP ) { nVersion = nVersionP; } + sal_Int32 GetVersion() const { return nVersion; } + OUString GetSuffixes() const; + OUString GetDefaultExtension() const; + const OUString& GetServiceName() const { return aServiceName; } + const OUString& GetProviderName() const { return maProvider;} + + static std::shared_ptr GetDefaultFilter( std::u16string_view rName ); + static std::shared_ptr GetFilterByName( const OUString& rName ); + static std::shared_ptr GetDefaultFilterFromFactory( const OUString& rServiceName ); + + static OUString GetTypeFromStorage( const SotStorage& rStg ); + /// @throws css::beans::UnknownPropertyException + /// @throws css::lang::WrappedTargetException + /// @throws css::uno::RuntimeException + static OUString GetTypeFromStorage( + const css::uno::Reference& xStorage ); + bool IsEnabled() const { return mbEnabled; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/docinf.hxx b/include/sfx2/docinf.hxx new file mode 100644 index 000000000..09ecfff6b --- /dev/null +++ b/include/sfx2/docinf.hxx @@ -0,0 +1,75 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_DOCINF_HXX +#define INCLUDED_SFX2_DOCINF_HXX + +#include +#include +#include +#include + + +class GDIMetaFile; +class SotStorage; + +namespace com::sun::star { + namespace document { + class XDocumentProperties; + } +} + +namespace com::sun::star::uno { template class Reference; } +namespace com::sun::star::uno { template class Sequence; } + + +namespace sfx2 { + +/** load document meta-data from OLE stream + + @param i_xDocProps Document meta-data + @param i_pStorage OLE Storage + */ +ErrCode SFX2_DLLPUBLIC LoadOlePropertySet( + const css::uno::Reference< css::document::XDocumentProperties>& i_xDocProps, + SotStorage* i_pStorage ); + +/** save document meta-data to OLE stream + + @param i_xDocProps Document meta-data + @param i_pStorage OLE Storage + @param i_pThumb Thumbnail: preview bitmap + @param i_pGuid Blob: Guid blob ("_PID_GUID") + @param i_pHyperlinks Blob: Hyperlink blob ("_PID_HLINKS") + */ +bool SFX2_DLLPUBLIC SaveOlePropertySet( + const css::uno::Reference< css::document::XDocumentProperties>& i_xDocProps, + SotStorage* i_pStorage, + const css::uno::Sequence * i_pThumb = nullptr, + const css::uno::Sequence * i_pGuid = nullptr, + const css::uno::Sequence * i_pHyperlinks = nullptr); + + +css::uno::Sequence SFX2_DLLPUBLIC convertMetaFile( + GDIMetaFile const * i_pThumb); + +} // namespace sfx2 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/docinsert.hxx b/include/sfx2/docinsert.hxx new file mode 100644 index 000000000..7c4107124 --- /dev/null +++ b/include/sfx2/docinsert.hxx @@ -0,0 +1,77 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_DOCINSERT_HXX +#define INCLUDED_SFX2_DOCINSERT_HXX + +#include +#include +#include +#include +#include +#include + +namespace sfx2 { class FileDialogHelper; } +namespace weld { class Window; } +class SfxItemSet; +class SfxMedium; +enum class FileDialogFlags; + +typedef ::std::vector< std::unique_ptr > SfxMediumList; + +namespace sfx2 { + +class SFX2_DLLPUBLIC DocumentInserter +{ +private: + weld::Window* m_pParent; + OUString m_sDocFactory; + OUString m_sFilter; + Link m_aDialogClosedLink; + + FileDialogFlags const m_nDlgFlags; + ErrCode m_nError; + + std::unique_ptr + m_pFileDlg; + std::shared_ptr m_xItemSet; + std::vector m_pURLList; + + DECL_DLLPRIVATE_LINK(DialogClosedHdl, sfx2::FileDialogHelper*, void); + +public: + enum class Mode { + Insert, + InsertMulti, + Compare, + Merge + }; + DocumentInserter(weld::Window* pParent, const OUString& rFactory, const Mode mode = Mode::Insert); + ~DocumentInserter(); + + void StartExecuteModal( const Link& _rDialogClosedLink ); + std::unique_ptr CreateMedium(char const* pFallbackHack = nullptr); + SfxMediumList CreateMediumList(); +}; + +} // namespace sfx2 + +#endif // INCLUDED_SFX2_DOCINSERT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/dockwin.hxx b/include/sfx2/dockwin.hxx new file mode 100644 index 000000000..886f4ae11 --- /dev/null +++ b/include/sfx2/dockwin.hxx @@ -0,0 +1,130 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_DOCKWIN_HXX +#define INCLUDED_SFX2_DOCKWIN_HXX + +#include +#include +#include +#include + +#include + +#include +#include + +namespace com::sun::star::frame { class XFrame; } + +class SfxDockingWindow_Impl; +enum class SplitWindowItemFlags; + +void SfxDockingWindowFactory( const css::uno::Reference< css::frame::XFrame >& rFrame, std::u16string_view rDockingWindowName ); +bool IsDockingWindowVisible( const css::uno::Reference< css::frame::XFrame >& rFrame, std::u16string_view rDockingWindowName ); + +class SFX2_DLLPUBLIC SfxDockingWindow : public ResizableDockingWindow +{ +protected: + std::unique_ptr m_xBuilder; + std::unique_ptr m_xContainer; + +private: + tools::Rectangle aInnerRect; + tools::Rectangle aOuterRect; + SfxBindings* pBindings; + Size aFloatSize; + SfxChildWindow* pMgr; + std::unique_ptr< SfxDockingWindow_Impl > pImpl; + + SfxDockingWindow(SfxDockingWindow const &) = delete; + SfxDockingWindow& operator =(SfxDockingWindow const &) = delete; + +protected: + SfxChildAlignment CalcAlignment(const Point& rPos, tools::Rectangle& rRect ); + virtual Size CalcDockingSize(SfxChildAlignment); + virtual SfxChildAlignment + CheckAlignment(SfxChildAlignment,SfxChildAlignment); + + virtual void Resize() override; + virtual bool PrepareToggleFloatingMode() override; + virtual void ToggleFloatingMode() override; + virtual void StartDocking() override; + virtual bool Docking( const Point& rPos, tools::Rectangle& rRect ) override; + virtual void EndDocking( const tools::Rectangle& rRect, bool bFloatMode ) override; + virtual void Resizing( Size& rSize ) override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual bool Close() override; + virtual void Move() override; + + SAL_DLLPRIVATE SfxChildWindow* GetChildWindow_Impl() { return pMgr; } + +public: + SfxDockingWindow( SfxBindings *pBindings, + SfxChildWindow *pCW, + vcl::Window* pParent, + WinBits nWinBits); + SfxDockingWindow( SfxBindings *pBindings, + SfxChildWindow *pCW, + vcl::Window* pParent, + const OString& rID, const OUString& rUIXMLDescription ); + virtual ~SfxDockingWindow() override; + virtual void dispose() override; + + void Initialize (SfxChildWinInfo* pInfo); + virtual void FillInfo(SfxChildWinInfo&) const; + virtual void StateChanged( StateChangedType nStateChange ) override; + + void SetDockingRects(const tools::Rectangle& rOuter, const tools::Rectangle& rInner) + { aInnerRect = rInner; aOuterRect = rOuter; } + const tools::Rectangle& GetInnerRect() const { return aInnerRect; } + const tools::Rectangle& GetOuterRect() const { return aOuterRect; } + SfxBindings& GetBindings() const { return *pBindings; } + sal_uInt16 GetType() const { return pMgr->GetType(); } + SfxChildAlignment GetAlignment() const { return pMgr->GetAlignment(); } + void SetAlignment(SfxChildAlignment eAlign) { pMgr->SetAlignment(eAlign); } + const Size& GetFloatingSize() const { return aFloatSize; } + void SetFloatingSize(const Size& rSize) { aFloatSize=rSize; } + + void SetMinOutputSizePixel( const Size& rSize ); + const Size& GetMinOutputSizePixel() const; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + DECL_DLLPRIVATE_LINK(TimerHdl, Timer *, void); + + SAL_DLLPRIVATE void Initialize_Impl(); + SAL_DLLPRIVATE void SetItemSize_Impl( const Size& rSize ); + SAL_DLLPRIVATE void Disappear_Impl(); + SAL_DLLPRIVATE void Reappear_Impl(); + SAL_DLLPRIVATE bool IsAutoHide_Impl() const; + SAL_DLLPRIVATE void AutoShow_Impl(); + SAL_DLLPRIVATE void ReleaseChildWindow_Impl(); +}; + +class SfxDockingWrapper final : public SfxChildWindow +{ + public: + SfxDockingWrapper( vcl::Window* pParent , + sal_uInt16 nId , + SfxBindings* pBindings , + SfxChildWinInfo* pInfo ); + + SFX_DECL_CHILDWINDOW(SfxDockingWrapper); +}; + +#endif // INCLUDED_SFX2_DOCKWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/docmacromode.hxx b/include/sfx2/docmacromode.hxx new file mode 100644 index 000000000..7ed42f6a1 --- /dev/null +++ b/include/sfx2/docmacromode.hxx @@ -0,0 +1,307 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_DOCMACROMODE_HXX +#define INCLUDED_SFX2_DOCMACROMODE_HXX + +#include +#include + +#include + +#include + +namespace com::sun::star::document { class XEmbeddedScripts; } +namespace com::sun::star::embed { class XStorage; } +namespace com::sun::star::script { class XLibraryContainer; } +namespace com::sun::star::task { class XInteractionHandler; } + + +namespace sfx2 +{ + + + //= IMacroDocumentAccess + + /** provides access to several settings of a document, which are needed by ->DocumentMacroMode + to properly determine the current macro execution mode of this document + */ + class SAL_NO_VTABLE IMacroDocumentAccess + { + public: + /** retrieves the current MacroExecutionMode. + + Usually, this is initialized from the media descriptor used to load the document, + respectively the one passed into the document's XModel::attachResource call. + + If no such mode was passed there, document implementations should return + MacroExecMode::NEVER_EXECUTE. + + @see css::document::MediaDescriptor::MacroExecutionMode + @see css::frame::XComponentLoader::loadComponentFromURL + @see css::frame::XModel::attachResource + + @see setCurrentMacroExecMode + + @todo + Effectively, this is the MacroExecutionMode of the MediaDescriptor of + the document. Thus, this setting could be obtained from the XModel + directly. We should introduce a getDocumentModel method here, which + can be used for this and other purposes. + */ + virtual sal_Int16 + getCurrentMacroExecMode() const = 0; + + /** sets the MacroExecutionMode of the document, as calculated by the DocumentMacroMode + class. + + Effectively, the existence of this method means that the responsibility + to store the current macro execution mode is not with the DocumentMacroMode + instance, but with the document instance itself. + + Usually, a document implementation will simply put the macro execution mode + into its media descriptor, as returned by XModel::getArgs. + + @see css::document::MediaDescriptor::MacroExecutionMode + @see css::frame::XComponentLoader::loadComponentFromURL + @see css::frame::XModel::attachResource + + see getCurrentMacroExecMode + */ + virtual void + setCurrentMacroExecMode( sal_uInt16 ) = 0; + + /** returns the origin of the document + + This usually is the document's location, or, if the document has been + newly created from a template, then the location of the template. Location + here means the complete path of the document, including the file name. + + @todo + This probably can also be obtained from the XModel, by calling getURL + or getLocation. If both are empty, then we need a UNO way to obtain + the URL of the underlying template document - if any. If we have this, + we could replace this method with a newly introduced method + getDocumentModel and some internal code. + */ + virtual OUString + getDocumentLocation() const = 0; + + /** checks whether the document's storage contains sub storages with macros or scripts + + A default implementation of this method will simply call DocumentMacroMode::storageHasMacros + with the document's root storage. However, there might be document types where this + isn't sufficient (e.g. database documents which contain sub documents which can also + contain macro/script storages). + */ + virtual bool + documentStorageHasMacros() const = 0; + + /** checks whether the document's contained calls to macros or scripts after loading + + */ + virtual bool + macroCallsSeenWhileLoading() const = 0; + + /** provides access to the XEmbeddedScripts interface of the document + + Implementations are allowed to return here if and only if they + do not (yet) support embedding scripts. + + @todo + can also be replaced with a call to the (to be introduced) getDocumentModel + method, and a queryInterface. + */ + virtual css::uno::Reference< css::document::XEmbeddedScripts > + getEmbeddedDocumentScripts() const = 0; + + /** returns the state of the signatures for the scripts embedded in the document + + Note: On the medium run, the signature handling of a document should be outsourced + into a dedicated class, instead of being hard-wired into the SfxObjectShell. This + class could then be used outside the SfxObjectShell (e.g. in Base documents), too. + When this happens, this method here becomes should be replaced by a method at this + new class. + + @seealso + */ + virtual SignatureState + getScriptingSignatureState() = 0; + + /** allows to detect whether there is a trusted scripting signature + + Note: On the medium run, the signature handling of a document should be outsourced + into a dedicated class, instead of being hard-wired into the SfxObjectShell. This + class could then be used outside the SfxObjectShell (e.g. in Base documents), too. + When this happens, this method here should be replaced by a method at this + new class. + + @seealso + */ + virtual bool + hasTrustedScriptingSignature( bool bAllowUIToAddAuthor ) = 0; + + protected: + ~IMacroDocumentAccess() {} + }; + + + //= DocumentMacroMode + + struct DocumentMacroMode_Data; + + /** encapsulates handling the macro mode of a document + + @see css::document::MacroExecMode + */ + class SFX2_DLLPUBLIC DocumentMacroMode + { + public: + /** creates an instance + + @param _rDocumentAccess + access to the document which this instance works for. Must live as long as the + DocumentMacroMode instance lives, at least + */ + DocumentMacroMode( IMacroDocumentAccess& _rDocumentAccess ); + + /** allows macro execution in the document + + Effectively, the macro mode is set to MacroExecMode::ALWAYS_EXECUTE_NO_WARN. + + @return + , always + */ + bool allowMacroExecution(); + + /** disallows macro execution in the document + + Effectively, the macro mode is set to MacroExecMode::NEVER_EXECUTE. + + @return + , always + */ + bool disallowMacroExecution(); + + /** checks whether the document allows executing contained macros. + + The method transforms the current macro execution mode into either + ALWAYS_EXECUTE_NO_WARN or NEVER_EXECUTE, depending on the current value, + possible configuration settings, and possible user interaction. + + @param _rxInteraction + A handler for interactions which might become necessary. + This includes +
  • Asking the user for confirmation for macro execution.
  • +
  • Telling the user that macro execution is disabled.
  • +
+ + If the user needs to be asked for macro execution confirmation, and if + this parameter is , the most defensive assumptions will be made, + effectively disabling macro execution. + + @param bHasValidContentSignature + Whether the document content is signed and the signature is valid. + + @return + if and only if macro execution in this document is allowed. + */ + bool adjustMacroMode( + const css::uno::Reference< css::task::XInteractionHandler >& _rxInteraction, + bool bHasValidContentSignature = false + ); + + /** determines whether macro execution is disallowed + + There's a number of reasons why macro execution could be disallowed: +
  • Somebody called ->disallowMacroExecution
  • +
  • Macro execution is disabled globally, via the security options
  • +
  • Macro execution mode was not defined initially, and the user denied + executing macros for this particular document.
  • +
+ + Note that if this method returns , then subsequent calls of + ->adjustMacroMode can still return . + That is, if the current macro execution mode for the document is not yet known + (and in particular not MacroExecMode::NEVER_EXECUTE), then ->isMacroExecutionDisallowed + will return . + However, a subsequent call to ->adjustMacroMode can result in the user + denying macro execution, in which ->adjustMacroMode will return , + and the next call to isMacroExecutionDisallowed will return . + */ + bool isMacroExecutionDisallowed() const; + + /** determines whether the document actually has a macros library + + Effectively, this method checks the Basic library container (as returned by + IMacroDocumentAccess::getEmbeddedDocumentScripts().getBasicLibraries) for + content. + */ + bool hasMacroLibrary() const; + + /** determines whether the given document storage has sub storages containing scripts + or macros. + + Effectively, the method checks for the presence of a sub-storage name "Scripts" (where + BeanShell-/JavaScript-/Python-Scripts are stored, and a sub storage named "Basic" (where + Basic scripts are stored). + */ + static bool storageHasMacros( const css::uno::Reference< css::embed::XStorage >& _rxStorage ); + + static bool containerHasBasicMacros( const css::uno::Reference< css::script::XLibraryContainer >& xContainer ); + /** checks the macro execution mode while loading the document. + + This must be called when the loading is effectively finished, but before any macro action + happened. + + The method will disallow macro execution for this document if it is disabled + globally (SvtSecurityOptions::IsMacroDisabled). Otherwise, it will check whether + the document contains a macro storage or macro libraries. If so, it will + properly calculate the MacroExecutionMode by calling adjustMacroMode. + + If the document doesn't contain macros, yet, then the macro execution for this + document will be allowed (again: unless disabled globally), since in this case + macros which later are newly created by the user should be allowed, of course. + + @return + if and only if macro execution is allowed in the document + + @see isMacroExecutionDisallowed + @see IMacroDocumentAccess::documentStorageHasMacros + @see IMacroDocumentAccess::macroCallsSeenWhileLoading + @see hasMacroLibrary + @see IMacroDocumentAccess::checkForBrokenScriptingSignatures + */ + bool + checkMacrosOnLoading( + const css::uno::Reference< css::task::XInteractionHandler >& _rxInteraction, + bool bHasValidContentSignature = false + ); + + private: + std::shared_ptr< DocumentMacroMode_Data > m_xData; + }; + + +} // namespace sfx2 + + +#endif // INCLUDED_SFX2_DOCMACROMODE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/docstoragemodifylistener.hxx b/include/sfx2/docstoragemodifylistener.hxx new file mode 100644 index 000000000..8530711ca --- /dev/null +++ b/include/sfx2/docstoragemodifylistener.hxx @@ -0,0 +1,82 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_DOCSTORAGEMODIFYLISTENER_HXX +#define INCLUDED_SFX2_DOCSTORAGEMODIFYLISTENER_HXX + +#include + +#include + +#include + +namespace comphelper { class SolarMutex; } + + +namespace sfx2 +{ + + + //= IModifiableDocument + + /** callback for the DocumentStorageModifyListener class + */ + class SAL_NO_VTABLE IModifiableDocument + { + public: + /// indicates the root or a sub storage of the document has been modified + virtual void storageIsModified() = 0; + + protected: + ~IModifiableDocument() {} + }; + + + //= DocumentStorageModifyListener + + class SFX2_DLLPUBLIC DocumentStorageModifyListener final : public cppu::WeakImplHelper + { + IModifiableDocument* m_pDocument; + comphelper::SolarMutex& m_rMutex; + + public: + DocumentStorageModifyListener( IModifiableDocument& _rDocument, comphelper::SolarMutex& _rMutex ); + + void dispose(); + + // XModifyListener + virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + private: + virtual ~DocumentStorageModifyListener() override; + + DocumentStorageModifyListener( const DocumentStorageModifyListener& ) = delete; + DocumentStorageModifyListener& operator=( const DocumentStorageModifyListener& ) = delete; + }; + + +} // namespace sfx2 + + +#endif // INCLUDED_SFX2_DOCSTORAGEMODIFYLISTENER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/doctempl.hxx b/include/sfx2/doctempl.hxx new file mode 100644 index 000000000..029c8e8b2 --- /dev/null +++ b/include/sfx2/doctempl.hxx @@ -0,0 +1,117 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_DOCTEMPL_HXX +#define INCLUDED_SFX2_DOCTEMPL_HXX + +#include + +#include + +#include +#include +#include +#include + +// CLASS ----------------------------------------------------------------- + +class SfxDocTemplate_Impl; + +// class SfxDocumentTemplates -------------------------------------------- + +class SFX2_DLLPUBLIC SfxDocumentTemplates +{ +private: + tools::SvRef pImp; + + SAL_DLLPRIVATE bool CopyOrMove( sal_uInt16 nTargetRegion, sal_uInt16 nTargetIdx, + sal_uInt16 nSourceRegion, sal_uInt16 nSourceIdx, bool bMove ); +public: + SfxDocumentTemplates(); + SfxDocumentTemplates(const SfxDocumentTemplates &); + ~SfxDocumentTemplates(); + + const SfxDocumentTemplates &operator=(const SfxDocumentTemplates &); + + void ReInitFromComponent(); + + sal_uInt16 GetRegionCount() const; + OUString GetRegionName(sal_uInt16 nIdx) const; //dv! + OUString GetFullRegionName(sal_uInt16 nIdx) const; + + sal_uInt16 GetCount(sal_uInt16 nRegion) const; + OUString GetName(sal_uInt16 nRegion, sal_uInt16 nIdx) const; //dv! + OUString GetPath(sal_uInt16 nRegion, sal_uInt16 nIdx) const; + + // Allows to retrieve the target template URL from the UCB + OUString GetTemplateTargetURLFromComponent(std::u16string_view aGroupName, + std::u16string_view aTitle ); + + // Convert a resource string - a template name - to its localised pair + // if it exists in sfx2/inc/strings.hxx + static OUString ConvertResourceString(const OUString& rString); + + bool Copy(sal_uInt16 nTargetRegion, + sal_uInt16 nTargetIdx, + sal_uInt16 nSourceRegion, + sal_uInt16 nSourceIdx); + bool Move(sal_uInt16 nTargetRegion, + sal_uInt16 nTargetIdx, + sal_uInt16 nSourceRegion, + sal_uInt16 nSourceIdx); + bool Delete(sal_uInt16 nRegion, sal_uInt16 nIdx); + bool InsertDir(const OUString &rText, sal_uInt16 nRegion); + + bool InsertTemplate (sal_uInt16 nSourceRegion, sal_uInt16 nIdx, const OUString &rName, const OUString &rPath); + + /** Change the name of an entry or a directory + + \param rName + The new name to set + \param nRegion + The id of the region to rename or containing the template to rename + \param nIdx + The id of the template to rename or USHRT_MAX to rename the region. + + \return + sal_True if the action could be performed, sal_False otherwise + + */ + bool SetName(const OUString &rName, sal_uInt16 nRegion, sal_uInt16 nIdx); + + bool CopyTo(sal_uInt16 nRegion, sal_uInt16 nIdx, std::u16string_view rName) const; + bool CopyFrom(sal_uInt16 nRegion, sal_uInt16 nIdx, OUString &rName); + + bool GetFull( + std::u16string_view rRegion, std::u16string_view rName, OUString& rPath ); + bool GetLogicNames( std::u16string_view rPath, OUString& rRegion, OUString& rName ) const; + + /** updates the configuration where the document templates structure is stored. + +

The info about the document templates (which files, which groups etc.) is stored in the + configuration. This means that just by copying files into OOo's template directories, this + change is not reflected in the SfxDocumentTemplates - 'cause the configuration is not synchronous with + the file system. This can be enforced with this method.

+ */ + void Update(); +}; + +#endif // INCLUDED_SFX2_DOCTEMPL_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/event.hxx b/include/sfx2/event.hxx new file mode 100644 index 000000000..9f7cd304a --- /dev/null +++ b/include/sfx2/event.hxx @@ -0,0 +1,268 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_EVENT_HXX +#define INCLUDED_SFX2_EVENT_HXX + +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include + +namespace com::sun::star::beans { struct PropertyValue; } + +/** + these values get stored in streams in a 16-bit value +*/ +enum class SvMacroItemId : sal_uInt16 { + NONE = 0, + + // used by SwHTMLForm_Impl + HtmlOnSubmitForm, + HtmlOnResetForm, + HtmlOnGetFocus, + HtmlOnLoseFocus, + HtmlOnClick, + HtmlOnClickItem, + HtmlOnChange, + HtmlOnSelect, + + // used by SwHTMLParser + OpenDoc, + PrepareCloseDoc, + ActivateDoc, + DeactivateDoc, + + // Events for Controls etc. + OnMouseOver = 5100, + OnClick = 5101, + OnMouseOut = 5102, + + OnImageLoadDone = 10000, + OnImageLoadCancel = 10001, + OnImageLoadError = 10002, + + SwObjectSelect = 20000, + SwStartInsGlossary = 20001, + SwEndInsGlossary = 20002, + SwFrmKeyInputAlpha = 20004, + SwFrmKeyInputNoAlpha = 20005, + SwFrmResize = 20006, + SwFrmMove = 20007, +}; + +template< typename charT, typename traits > +inline std::basic_ostream & operator <<( + std::basic_ostream & stream, const SvMacroItemId& id ) +{ + switch(id) + { + case SvMacroItemId::NONE: return stream << "NONE"; + case SvMacroItemId::HtmlOnSubmitForm: return stream << "HtmlOnSubmitForm"; + case SvMacroItemId::HtmlOnResetForm: return stream << "HtmlOnResetForm"; + case SvMacroItemId::HtmlOnGetFocus: return stream << "HtmlOnGetFocus"; + case SvMacroItemId::HtmlOnLoseFocus: return stream << "HtmlOnLoseFocus"; + case SvMacroItemId::HtmlOnClick: return stream << "HtmlOnClick"; + case SvMacroItemId::HtmlOnClickItem: return stream << "HtmlOnClickItem"; + case SvMacroItemId::HtmlOnChange: return stream << "HtmlOnChange"; + case SvMacroItemId::HtmlOnSelect: return stream << "HtmlOnSelect"; + case SvMacroItemId::OpenDoc: return stream << "OpenDoc"; + case SvMacroItemId::PrepareCloseDoc: return stream << "PrepareCloseDoc"; + case SvMacroItemId::ActivateDoc: return stream << "ActivateDoc"; + case SvMacroItemId::DeactivateDoc: return stream << "DeactivateDoc"; + case SvMacroItemId::OnMouseOver: return stream << "OnMouseOver"; + case SvMacroItemId::OnClick: return stream << "OnClick"; + case SvMacroItemId::OnMouseOut: return stream << "OnMouseOut"; + case SvMacroItemId::OnImageLoadDone: return stream << "OnImageLoadDone"; + case SvMacroItemId::OnImageLoadCancel: return stream << "OnImageLoadCancel"; + case SvMacroItemId::OnImageLoadError: return stream << "OnImageLoadError"; + case SvMacroItemId::SwObjectSelect: return stream << "SwObjectSelect"; + case SvMacroItemId::SwStartInsGlossary: return stream << "SwStartInsGlossary"; + case SvMacroItemId::SwEndInsGlossary: return stream << "SwEndInsGlossary"; + case SvMacroItemId::SwFrmKeyInputAlpha: return stream << "SwFrmKeyInputAlpha"; + case SvMacroItemId::SwFrmKeyInputNoAlpha: return stream << "SwFrmKeyInputNoAlpha"; + case SvMacroItemId::SwFrmResize: return stream << "SwFrmResize"; + case SvMacroItemId::SwFrmMove: return stream << "SwFrmMove"; + default: return stream << "unk(" << std::to_string(int(id)) << ")"; + } +} + +class SfxObjectShell; + +enum class SfxEventHintId { + NONE = 0, + ActivateDoc, + CloseDoc, + CloseView, + CreateDoc, + DeactivateDoc, + DocCreated, + LoadFinished, + ModifyChanged, + OpenDoc, + PrepareCloseDoc, + PrepareCloseView, + PrintDoc, + SaveAsDoc, + SaveAsDocDone, + SaveAsDocFailed, + SaveDoc, + SaveDocDone, + SaveDocFailed, + SaveToDoc, + SaveToDocDone, + SaveToDocFailed, + StorageChanged, + ViewCreated, + VisAreaChanged, + // SW events + SwMailMerge, + SwMailMergeEnd, + SwEventPageCount, + SwEventFieldMerge, + SwEventFieldMergeFinished, + SwEventLayoutFinished, +}; + +template< typename charT, typename traits > +inline std::basic_ostream & operator <<( + std::basic_ostream & stream, const SfxEventHintId& id ) +{ + switch(id) + { + case SfxEventHintId::NONE: return stream << "NONE"; + case SfxEventHintId::ActivateDoc: return stream << "ActivateDoc"; + case SfxEventHintId::CloseDoc: return stream << "CloseDoc"; + case SfxEventHintId::CloseView: return stream << "CloseView"; + case SfxEventHintId::CreateDoc: return stream << "CreateDoc"; + case SfxEventHintId::DeactivateDoc: return stream << "DeactivateDoc"; + case SfxEventHintId::DocCreated: return stream << "DocCreated"; + case SfxEventHintId::LoadFinished: return stream << "LoadFinished"; + case SfxEventHintId::ModifyChanged: return stream << "ModifyChanged"; + case SfxEventHintId::OpenDoc: return stream << "OpenDoc"; + case SfxEventHintId::PrepareCloseDoc: return stream << "PrepareCloseDoc"; + case SfxEventHintId::PrepareCloseView: return stream << "PrepareCloseView"; + case SfxEventHintId::PrintDoc: return stream << "PrintDoc"; + case SfxEventHintId::SaveAsDoc: return stream << "SaveAsDoc"; + case SfxEventHintId::SaveAsDocDone: return stream << "SaveAsDocDone"; + case SfxEventHintId::SaveAsDocFailed: return stream << "SaveAsDocFailed"; + case SfxEventHintId::SaveDoc: return stream << "SaveDoc"; + case SfxEventHintId::SaveDocDone: return stream << "SaveDocDone"; + case SfxEventHintId::SaveDocFailed: return stream << "SaveDocFailed"; + case SfxEventHintId::SaveToDoc: return stream << "SaveToDoc"; + case SfxEventHintId::SaveToDocDone: return stream << "SaveToDocDone"; + case SfxEventHintId::SaveToDocFailed: return stream << "SaveToDocFailed"; + case SfxEventHintId::StorageChanged: return stream << "StorageChanged"; + case SfxEventHintId::ViewCreated: return stream << "ViewCreated"; + case SfxEventHintId::VisAreaChanged: return stream << "VisAreaChanged"; + case SfxEventHintId::SwMailMerge: return stream << "SwMailMerge"; + case SfxEventHintId::SwMailMergeEnd: return stream << "SwMailMergeEnd"; + case SfxEventHintId::SwEventPageCount: return stream << "SwEventPageCount"; + case SfxEventHintId::SwEventFieldMerge: return stream << "SwEventFieldMerge"; + case SfxEventHintId::SwEventFieldMergeFinished: return stream << "SwEventFieldMergeFinished"; + case SfxEventHintId::SwEventLayoutFinished: return stream << "SwEventLayoutFinished"; + default: return stream << "unk(" << std::to_string(int(id)) << ")"; + } +} + +class SFX2_DLLPUBLIC SfxEventHint : public SfxHint +{ + SfxObjectShell* pObjShell; + OUString aEventName; + SfxEventHintId nEventId; + +public: + SfxEventHint( SfxEventHintId nId, const OUString& aName, SfxObjectShell *pObj ) + : pObjShell(pObj), + aEventName(aName), + nEventId(nId) + {} + + SfxEventHintId GetEventId() const + { return nEventId; } + + const OUString& GetEventName() const + { return aEventName; } + + SfxObjectShell* GetObjShell() const + { return pObjShell; } +}; + + +class SFX2_DLLPUBLIC SfxViewEventHint : public SfxEventHint +{ + css::uno::Reference< css::frame::XController2 > xViewController; + +public: + SfxViewEventHint( SfxEventHintId nId, const OUString& aName, SfxObjectShell *pObj, const css::uno::Reference< css::frame::XController >& xController ) + : SfxEventHint( nId, aName, pObj ) + , xViewController( xController, css::uno::UNO_QUERY ) + {} + + SfxViewEventHint( SfxEventHintId nId, const OUString& aName, SfxObjectShell *pObj, const css::uno::Reference< css::frame::XController2 >& xController ) + : SfxEventHint( nId, aName, pObj ) + , xViewController( xController ) + {} + + const css::uno::Reference< css::frame::XController2 >& GetController() const + { return xViewController; } +}; + +class SfxPrintingHint final : public SfxViewEventHint +{ + css::view::PrintableState mnPrintableState; + css::uno::Sequence < css::beans::PropertyValue > aOpts; +public: + SfxPrintingHint( + css::view::PrintableState nState, + const css::uno::Sequence < css::beans::PropertyValue >& rOpts, + SfxObjectShell *pObj, + const css::uno::Reference< css::frame::XController2 >& xController ) + : SfxViewEventHint( + SfxEventHintId::PrintDoc, + GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC ), + pObj, + xController ) + , mnPrintableState( nState ) + , aOpts( rOpts ) + {} + + SfxPrintingHint( css::view::PrintableState nState ) + : SfxViewEventHint( + SfxEventHintId::PrintDoc, + GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC ), + nullptr, + css::uno::Reference< css::frame::XController >() ) + , mnPrintableState( nState ) + {} + + css::view::PrintableState GetWhich() const { return mnPrintableState; } + const css::uno::Sequence < css::beans::PropertyValue >& GetOptions() const { return aOpts; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/evntconf.hxx b/include/sfx2/evntconf.hxx new file mode 100644 index 000000000..8720a7330 --- /dev/null +++ b/include/sfx2/evntconf.hxx @@ -0,0 +1,102 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_EVNTCONF_HXX +#define INCLUDED_SFX2_EVNTCONF_HXX + +#include +#include +#include +#include +#include +#include +#include + +class SfxObjectShell; +class SvxMacro; + +struct SFX2_DLLPUBLIC SfxEventName +{ + SvMacroItemId mnId; + OUString maEventName; + OUString maUIName; + + SfxEventName( SvMacroItemId nId, + const OUString& rEventName, + const OUString& rUIName ) + : mnId( nId ) + , maEventName( rEventName ) + , maUIName( rUIName ) {} +}; + +class SFX2_DLLPUBLIC SfxEventNamesList +{ +private: + ::std::vector< SfxEventName > aEventNamesList; + +public: + SfxEventNamesList() {} + SfxEventNamesList( const SfxEventNamesList &rCpy ) { *this = rCpy; } + ~SfxEventNamesList(); + SfxEventNamesList& operator=( const SfxEventNamesList &rCpy ); + + size_t size() const { return aEventNamesList.size(); }; + + SfxEventName& at( size_t Index ) { return aEventNamesList[ Index ]; } + SfxEventName const & at( size_t Index ) const { return aEventNamesList[ Index ]; } + + void push_back( SfxEventName Item ) { aEventNamesList.push_back( std::move(Item) ); } +}; + +class SFX2_DLLPUBLIC SfxEventNamesItem final : public SfxPoolItem +{ + SfxEventNamesList aEventsList; + +public: + + SfxEventNamesItem ( const sal_uInt16 nId ) : SfxPoolItem( nId ) {} + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual bool GetPresentation( SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString &rText, + const IntlWrapper& ) const override; + virtual SfxEventNamesItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const SfxEventNamesList& GetEvents() const { return aEventsList;} + void AddEvent( const OUString&, const OUString&, SvMacroItemId ); +}; + + +inline constexpr OUStringLiteral PROP_EVENT_TYPE = u"EventType"; +inline constexpr OUStringLiteral PROP_LIBRARY = u"Library"; +inline constexpr OUStringLiteral PROP_SCRIPT = u"Script"; +inline constexpr OUStringLiteral PROP_MACRO_NAME = u"MacroName"; +#define STAR_BASIC "StarBasic" + +class SFX2_DLLPUBLIC SfxEventConfiguration +{ +public: + static void ConfigureEvent( const OUString& aName, const SvxMacro&, SfxObjectShell const * pObjSh); + static std::unique_ptr ConvertToMacro( const css::uno::Any& rElement, SfxObjectShell* pDoc ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/fcontnr.hxx b/include/sfx2/fcontnr.hxx new file mode 100644 index 000000000..026f0e1c1 --- /dev/null +++ b/include/sfx2/fcontnr.hxx @@ -0,0 +1,119 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_FCONTNR_HXX +#define INCLUDED_SFX2_FCONTNR_HXX + +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace com::sun::star::beans { struct NamedValue; } +namespace com::sun::star::container { class XNameAccess; } +namespace com::sun::star::uno { template class Sequence; } +namespace com::sun::star::uno { template class Reference; } + +class ErrCode; +class SfxFilter; +class SfxMedium; +class SfxFilterContainer_Impl; + + +class SFX2_DLLPUBLIC SfxFilterContainer +{ + std::unique_ptr pImpl; + +public: + SfxFilterContainer( const OUString& rName ); + ~SfxFilterContainer(); + + + OUString const & GetName() const; + + std::shared_ptr GetAnyFilter( SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr GetFilter4EA( const OUString& rEA, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr GetFilter4Extension( const OUString& rExt, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr GetFilter4FilterName( const OUString& rName, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + + SAL_DLLPRIVATE static void ReadFilters_Impl( bool bUpdate=false ); + SAL_DLLPRIVATE static void ReadSingleFilter_Impl( const OUString& rName, + const css::uno::Reference< css::container::XNameAccess >& xTypeCFG, + const css::uno::Reference< css::container::XNameAccess >& xFilterCFG, + bool bUpdate ); + SAL_DLLPRIVATE static std::shared_ptr GetDefaultFilter_Impl( std::u16string_view ); +}; + +class SfxFilterMatcher_Impl; + +class SFX2_DLLPUBLIC SfxFilterMatcher +{ + friend class SfxFilterMatcherIter; + SfxFilterMatcher_Impl &m_rImpl; +public: + SfxFilterMatcher( const OUString& rFact ); + SfxFilterMatcher(); + ~SfxFilterMatcher(); + SfxFilterMatcher(const SfxFilterMatcher&) = delete; + SfxFilterMatcher& operator=( const SfxFilterMatcher& ) = delete; + + SAL_DLLPRIVATE static bool IsFilterInstalled_Impl( const std::shared_ptr& pFilter ); + DECL_DLLPRIVATE_LINK( MaybeFileHdl_Impl, OUString*, bool ); + + ErrCode GuessFilterIgnoringContent( SfxMedium const & rMedium, std::shared_ptr& ) const; + ErrCode GuessFilter( SfxMedium& rMedium, std::shared_ptr& , SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + ErrCode GuessFilterControlDefaultUI( SfxMedium& rMedium, std::shared_ptr&, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + ErrCode DetectFilter( SfxMedium& rMedium, std::shared_ptr& ) const; + + std::shared_ptr GetFilter4Mime( const OUString& rMime, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED) const; + std::shared_ptr GetFilter4ClipBoardId( SotClipboardFormatId nId, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr GetFilter4EA( const OUString& rEA, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr GetFilter4Extension( const OUString& rExt, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr GetFilter4FilterName( const OUString& rName, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr GetFilter4UIName( std::u16string_view rName, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr GetFilterForProps( const css::uno::Sequence < css::beans::NamedValue >& aSeq, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr GetAnyFilter( SfxFilterFlags nMustg=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED ) const; +}; + +class SFX2_DLLPUBLIC SfxFilterMatcherIter + +{ + SfxFilterFlags nOrMask; + SfxFilterFlags nAndMask; + sal_uInt16 nCurrent; + const SfxFilterMatcher_Impl &m_rMatch; + + SAL_DLLPRIVATE std::shared_ptr Find_Impl(); + +public: + SfxFilterMatcherIter( const SfxFilterMatcher& rMatcher, SfxFilterFlags nMask = SfxFilterFlags::NONE, SfxFilterFlags nNotMask = SFX_FILTER_NOTINSTALLED ); + SfxFilterMatcherIter(const SfxFilterMatcherIter&) = delete; + SfxFilterMatcherIter& operator=( const SfxFilterMatcherIter& ) = delete; + std::shared_ptr First(); + std::shared_ptr Next(); +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/filedlghelper.hxx b/include/sfx2/filedlghelper.hxx new file mode 100644 index 000000000..b0b530398 --- /dev/null +++ b/include/sfx2/filedlghelper.hxx @@ -0,0 +1,313 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_FILEDLGHELPER_HXX +#define INCLUDED_SFX2_FILEDLGHELPER_HXX + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace com::sun::star::ui::dialogs +{ + class XFilePicker3; + class XFolderPicker2; + struct FilePickerEvent; + struct DialogClosedEvent; +} +namespace com::sun::star::awt { class XWindow; } +namespace com::sun::star::uno { template class Reference; } +namespace com::sun::star::uno { class XComponentContext; } +namespace weld { class Window; } + +class Graphic; +class SfxFilter; +class SfxItemSet; +class SfxAllItemSet; + +enum class FileDialogFlags { + NONE = 0x00, + Insert = 0x01, // turn Open into Insert dialog + Export = 0x02, // turn Save into Export dialog + SaveACopy = 0x04, // turn Save into Save a Copy dialog + MultiSelection = 0x08, + Graphic = 0x10, // register graphic formats + /// Sign existing PDF. + SignPDF = 0x20, + InsertCompare = 0x40, /// Special insertion ("Compare" caption) + InsertMerge = 0x80, /// Special insertion ("Merge" caption) +}; +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +} + +inline constexpr OUStringLiteral FILEDIALOG_FILTER_ALL = u"*.*"; + +namespace sfx2 { + +class FileDialogHelper_Impl; + +class SFX2_DLLPUBLIC FileDialogHelper +{ +public: + // context where the FileDialogHelper is used + enum Context + { + UnknownContext, + AcceleratorConfig, + AutoRedact, + BaseDataSource, + BaseSaveAs, + BasicExportPackage, + BasicExportDialog, + BasicExportSource, + BasicImportDialog, + BasicImportSource, + BasicInsertLib, + BulletsAddImage, + ExtensionManager, + CalcDataProvider, + CalcDataStream, + CalcExport, + CalcSaveAs, + CalcXMLSource, + DrawExport, + DrawImpressInsertFile, + DrawImpressOpenSound, + DrawSaveAs, + ExportImage, + FormsAddInstance, + FormsInsertImage, + IconImport, + ImpressClickAction, + ImpressExport, + ImpressPhotoDialog, + ImpressSaveAs, + LinkClientOLE, + LinkClientFile, + ImageMap, + InsertDoc, + InsertImage, + InsertMedia, + InsertOLE, + JavaClassPath, + ReportInsertImage, + ScreenshotAnnotation, + SignatureLine, + TemplateImport, + WriterCreateAddressList, + WriterInsertDoc, + WriterInsertImage, + WriterInsertScript, + WriterExport, + WriterImportAutotext, + WriterInsertHyperlink, + WriterLoadTemplate, + WriterMailMerge, + WriterMailMergeSaveAs, + WriterNewHTMLGlobalDoc, + WriterRegisterDataSource, + WriterSaveAs, + WriterSaveHTML, + XMLFilterSettings + }; + static OUString contextToString(Context context); + +private: + Link m_aDialogClosedLink; + ErrCode m_nError; + + rtl::Reference< FileDialogHelper_Impl > mpImpl; + + +public: + FileDialogHelper(sal_Int16 nDialogType, + FileDialogFlags nFlags, + weld::Window* pPreferredParent); + + FileDialogHelper(sal_Int16 nDialogType, + FileDialogFlags nFlags, + const OUString& rFactory, + SfxFilterFlags nMust, + SfxFilterFlags nDont, + weld::Window* pPreferredParent); + + FileDialogHelper(sal_Int16 nDialogType, + FileDialogFlags nFlags, + const OUString& rFactory, + sal_Int16 nDialog, + SfxFilterFlags nMust, + SfxFilterFlags nDont, + const OUString& rStandardDir, + const css::uno::Sequence< OUString >& rDenyList, + weld::Window* pPreferredParent); + + FileDialogHelper(sal_Int16 nDialogType, + FileDialogFlags nFlags, + const OUString& aFilterUIName, + std::u16string_view aExtName, + const OUString& rStandardDir, + const css::uno::Sequence< OUString >& rDenyList, + weld::Window* pPreferredParent); + + virtual ~FileDialogHelper(); + + FileDialogHelper& operator=(const FileDialogHelper &) = delete; + FileDialogHelper(const FileDialogHelper &) = delete; + + ErrCode Execute(); + void StartExecuteModal( const Link& rEndDialogHdl ); + ErrCode const & GetError() const { return m_nError; } + sal_Int16 GetDialogType() const; + bool IsPasswordEnabled() const; + OUString GetRealFilter() const; + + void SetTitle( const OUString& rNewTitle ); + OUString GetPath() const; + + /** @deprecated: Don't use this method to retrieve the selected files + There are file picker which can provide multiple selected file which belong + to different folders. As this method always provides the root folder for all selected + files this cannot work. + */ + css::uno::Sequence< OUString > GetMPath() const; + + /** Provides the selected files with full path information */ + css::uno::Sequence< OUString > GetSelectedFiles() const; + + void AddFilter( const OUString& rFilterName, const OUString& rExtension ); + void SetCurrentFilter( const OUString& rFilter ); + + /** sets an initial display directory/file name + + @deprecated + don't use this method. It contains a lot of magic in determining whether the + last segment of the given path/URL denotes a file name or a folder, and by + definition, it cannot succeed with this magic *all* the time - there will + always be scenarios where it fails. + + Use SetDisplayFolder and SetFileName. + */ + void SetDisplayDirectory( const OUString& rPath ); + + /** sets a new folder whose content is to be displayed in the file picker + + @param _rURL + specifies the URL of the folder whose content is to be displayed.
+ If the URL doesn't denote a valid (existent and accessible) folder, the + request is silently dropped. + @throws css::uno::RuntimeException + if the invocation of any of the file picker or UCB methods throws a RuntimeException. + */ + void SetDisplayFolder( const OUString& _rURL ); + + /** sets an initial file name to display + + This method is usually used in "save-as" contexts, where the application should + suggest an initial name for the file to save. + + Calling this method is nearly equivalent to calling GetFilePicker().setDefaultName( _rFileName ), + with the following differences: +
  • The FileDialogHelper remembers the given file name, and upon execution, + strips its extension if the dialog is set up for "automatic file name extension".
  • +
  • Exceptions thrown from the XFilePicker3 are caught and silenced.
  • +
+ */ + void SetFileName( const OUString& _rFileName ); + + OUString GetCurrentFilter() const; + OUString GetDisplayDirectory() const; + ErrCode GetGraphic( Graphic& rGraphic ) const; + + const css::uno::Reference < css::ui::dialogs::XFilePicker3 >& GetFilePicker() const; + + // XFilePickerListener methods + void FileSelectionChanged(); + void DirectoryChanged(); + virtual void ControlStateChanged( const css::ui::dialogs::FilePickerEvent& aEvent ); + void DialogSizeChanged(); + static OUString HelpRequested( const css::ui::dialogs::FilePickerEvent& aEvent ); + + // XDialogClosedListener methods + void DialogClosed( const css::ui::dialogs::DialogClosedEvent& _rEvent ); + + /** sets help ids for the controls in the dialog + @param _pControlId + Pointer to a 0-terminated array of control ids. They must be recruited from the + CommonFilePickerElementIds and ExtendedFilePickerElementIds values. + @param _pHelpId + Pointer to an array of help ids. For each element in _pControlId, there must be + a corresponding element herein. + */ + void SetControlHelpIds( const sal_Int16* _pControlId, const char** _pHelpId ); + void CreateMatcher( const OUString& rName ); + + /** sets the context of the dialog and trigger necessary actions e.g. loading config, setting help id + This will also store the last used directory for this context, so that the last directory + gets preselected on next filepicker launch (with the same context) + @param _eNewContext + New context for the dialog. + */ + void SetContext( Context _eNewContext ); + + DECL_DLLPRIVATE_LINK( ExecuteSystemFilePicker, void*, void ); + + ErrCode Execute( std::vector& rpURLList, + std::optional& rpSet, + OUString& rFilter, + const OUString& rDirPath ); + ErrCode Execute( std::optional& rpSet, + OUString& rFilter ); +}; + +#define SFX2_IMPL_DIALOG_CONFIG 0 +#define SFX2_IMPL_DIALOG_SYSTEM 1 +#define SFX2_IMPL_DIALOG_OOO 2 +#define SFX2_IMPL_DIALOG_REMOTE 3 + +ErrCode FileOpenDialog_Impl( weld::Window* pParent, + sal_Int16 nDialogType, + FileDialogFlags nFlags, + std::vector& rpURLList, + OUString& rFilter, + std::optional& rpSet, + const OUString* pPath, + sal_Int16 nDialog, + const OUString& rStandardDir, + const css::uno::Sequence< OUString >& rDenyList = css::uno::Sequence< OUString >()); + +css::uno::Reference SFX2_DLLPUBLIC createFolderPicker(const css::uno::Reference& rContext, weld::Window* pPreferredParent); + +ErrCode RequestPassword(const std::shared_ptr& pCurrentFilter, OUString const & aURL, SfxItemSet* pSet, const css::uno::Reference& rParent); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/flatpak.hxx b/include/sfx2/flatpak.hxx new file mode 100644 index 000000000..cf71475fb --- /dev/null +++ b/include/sfx2/flatpak.hxx @@ -0,0 +1,33 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_INCLUDE_SFX2_FLATPAK_HXX +#define INCLUDED_INCLUDE_SFX2_FLATPAK_HXX + +#include + +#include +#include + +// Functionality related to the Flatpak version of LibreOffice. + +namespace flatpak +{ +bool isFlatpak(); + +// Must only be called with SolarMutex locked: +bool createTemporaryHtmlDirectory(OUString** url); + +// Must only be called with SolarMutex locked: +SFX2_DLLPUBLIC void removeTemporaryHtmlDirectory(); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/sfx2/frame.hxx b/include/sfx2/frame.hxx new file mode 100644 index 000000000..86b5baaa7 --- /dev/null +++ b/include/sfx2/frame.hxx @@ -0,0 +1,203 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_FRAME_HXX +#define INCLUDED_SFX2_FRAME_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace com::sun::star::frame +{ + class XFrame; + class XController; +} + +class SvBorder; +class SfxWorkWindow; +namespace vcl { class Window; } +class SfxFrame_Impl; +class SfxObjectShell; +class SfxViewFrame; +class SfxFrameDescriptor; +namespace tools { class Rectangle; } +class SystemWindow; + +typedef ::std::vector TargetList; + + +// SfxFrame is a management class for windows and their content. +// A SfxApplication represent a hierarchy of SfxFrames, with which the actual +// content in the derived classes is defined. The base class SfxFrame +// implements two aspects of frames: naming and control of its lifespan. +// Inside a frame hierarchy the parent frame always controls the lifespan of +// its child frames, even though they usually are not even produced by the +// parent. By calling DoCloser() on any frame in the hierarchy, +// a part of the "framework" can be removed, where frames unsubscribe +// from their parent frames. + + +class SFX2_DLLPUBLIC SfxFrame final : public SvCompatWeakBase +{ + friend class SfxFrameIterator; + friend class SfxFrameWindow_Impl; + +private: + std::unique_ptr< SfxFrame_Impl > pImpl; + VclPtr pWindow; + + virtual ~SfxFrame(); + + SAL_DLLPRIVATE SfxFrame( vcl::Window& i_rContainerWindow ); + +public: + static SfxFrame* Create( const css::uno::Reference< css::frame::XFrame >& xFrame ); + static css::uno::Reference< css::frame::XFrame > + CreateBlankFrame(); + static SfxFrame* CreateHidden( SfxObjectShell const & rDoc, vcl::Window& rWindow, SfxInterfaceId nViewId ); + + vcl::Window& GetWindow() const { return *pWindow;} + void CancelTransfers(); + bool DoClose(); + + void SetPresentationMode( bool bSet ); + SystemWindow* GetSystemWindow() const; + + static SfxFrame* GetFirst(); + static SfxFrame* GetNext( SfxFrame& ); + + SfxObjectShell* GetCurrentDocument() const; + SfxViewFrame* GetCurrentViewFrame() const; + + bool GetHasTitle() const; + static void GetDefaultTargetList( TargetList& ); + void UpdateDescriptor( SfxObjectShell const *pDoc ); + void Resize(); + const css::uno::Reference< css::frame::XFrame >& + GetFrameInterface() const; + void Appear(); + void AppearWithUpdate(); + css::uno::Reference< css::frame::XController > + GetController() const; + + bool IsInPlace() const; + + SAL_DLLPRIVATE void DoClose_Impl(); + SAL_DLLPRIVATE void SetFrameInterface_Impl( const css::uno::Reference< css::frame::XFrame >& rFrame ); + SAL_DLLPRIVATE void ReleasingComponent_Impl(); + SAL_DLLPRIVATE void GetViewData_Impl(); + SAL_DLLPRIVATE void SetHasTitle( bool ); + SAL_DLLPRIVATE bool PrepareClose_Impl( bool bUI ); + SAL_DLLPRIVATE bool DocIsModified_Impl(); + SAL_DLLPRIVATE void SetCurrentViewFrame_Impl( SfxViewFrame* ); + bool IsClosing_Impl() const; + SAL_DLLPRIVATE void SetIsClosing_Impl(); + + // Methods for accessing the current set + SAL_DLLPRIVATE SfxFrameDescriptor* GetDescriptor() const; + + SAL_DLLPRIVATE bool IsAutoLoadLocked_Impl() const; + + SAL_DLLPRIVATE static void InsertTopFrame_Impl( SfxFrame* pFrame ); + SAL_DLLPRIVATE static void RemoveTopFrame_Impl( SfxFrame* pFrame ); + SAL_DLLPRIVATE void SetOwnsBindings_Impl( bool bSet ); + SAL_DLLPRIVATE bool OwnsBindings_Impl() const; + SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl() const; + SAL_DLLPRIVATE void SetToolSpaceBorderPixel_Impl( const SvBorder& ); + SAL_DLLPRIVATE tools::Rectangle GetTopOuterRectPixel_Impl() const; + SAL_DLLPRIVATE void CreateWorkWindow_Impl(); + SAL_DLLPRIVATE void GrabFocusOnComponent_Impl(); + + SAL_DLLPRIVATE void PrepareForDoc_Impl( const SfxObjectShell& i_rDoc ); + SAL_DLLPRIVATE void LockResize_Impl( bool bLock ); + SAL_DLLPRIVATE void SetMenuBarOn_Impl( bool bOn ); + SAL_DLLPRIVATE bool IsMenuBarOn_Impl() const; + SAL_DLLPRIVATE SystemWindow* GetTopWindow_Impl() const; + SAL_DLLPRIVATE bool IsMarkedHidden_Impl() const; +private: + SAL_DLLPRIVATE void Construct_Impl(); +}; + +typedef SvCompatWeakRef SfxFrameWeakRef; + +class SFX2_DLLPUBLIC SfxFrameItem final : public SfxPoolItem +{ + SfxFrame* pFrame; + SfxFrameWeakRef wFrame; + +public: + + SfxFrameItem( sal_uInt16 nWhich, SfxViewFrame const *p ); + SfxFrameItem( SfxFrame *p ); + SfxFrameItem( sal_uInt16 nWhich, SfxFrame *p ); + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual SfxFrameItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; + + SfxFrame* GetFrame() const { return wFrame; } +}; + +class SFX2_DLLPUBLIC SfxUnoAnyItem final : public SfxPoolItem +{ + css::uno::Any aValue; +public: + static SfxPoolItem* CreateDefault(); + SfxUnoAnyItem( sal_uInt16 nWhich, const css::uno::Any& rAny ); + const css::uno::Any& GetValue() const + { return aValue; } + virtual bool operator==( const SfxPoolItem& ) const override; + virtual SfxUnoAnyItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; +}; + +class SFX2_DLLPUBLIC SfxUnoFrameItem final : public SfxPoolItem +{ + css::uno::Reference< css::frame::XFrame > + m_xFrame; + +public: + static SfxPoolItem* CreateDefault(); + SfxUnoFrameItem(); + SfxUnoFrameItem( sal_uInt16 nWhich, const css::uno::Reference< css::frame::XFrame >& i_rFrame ); + const css::uno::Reference< css::frame::XFrame >& + GetFrame() const + { return m_xFrame; } + virtual bool operator==( const SfxPoolItem& ) const override; + virtual SfxUnoFrameItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/frmdescr.hxx b/include/sfx2/frmdescr.hxx new file mode 100644 index 000000000..67c0c7e38 --- /dev/null +++ b/include/sfx2/frmdescr.hxx @@ -0,0 +1,102 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_FRMDESCR_HXX +#define INCLUDED_SFX2_FRMDESCR_HXX + +#include +#include +#include +#include +#include +#include + +// The SfxFrame descriptors build a recursive structure, that covers all the +// required data in-order to display the frame document. +// Through a SfxFrameSetDescriptor access is given to the whole underlying +// structure. Due to the nature of the SfxFrames document, the +// SfxFramesSetDescriptor is not only the content of this document, but also +// describes the view on it. The FrameSet is made up of lines, which in turn, +// contains the actual window . A line can be horizontally or vertically +// aligned, from which also the alignment of the FrameSet is given. + + +enum class ScrollingMode +{ + Yes, + No, + Auto +}; + +#define SIZE_NOT_SET -1L + +class SfxItemSet; + +class SFX2_DLLPUBLIC SfxFrameDescriptor +{ + INetURLObject aURL; + OUString aName; + Size aMargin; + ScrollingMode eScroll; + bool bHasBorder; + bool bHasBorderSet; + std::unique_ptr m_pArgs; + +public: + SfxFrameDescriptor(); + ~SfxFrameDescriptor(); + + // FileName/URL + SfxItemSet* GetArgs(); + const INetURLObject& GetURL() const + { return aURL; } + void SetURL( std::u16string_view rURL ); + void SetActualURL(); + + // FrameName + const OUString& GetName() const + { return aName; } + void SetName( const OUString& rName ) + { aName = rName; } + + // Margin, Scrolling + const Size& GetMargin() const + { return aMargin; } + void SetMargin( const Size& rMargin ) + { aMargin = rMargin; } + ScrollingMode GetScrollingMode() const + { return eScroll; } + void SetScrollingMode( ScrollingMode eMode ) + { eScroll = eMode; } + + // FrameBorder + bool HasFrameBorder() const + { return bHasBorder; } + bool IsFrameBorderOn() const + { return bHasBorder; } + void SetFrameBorder( bool bBorder ) + { bHasBorder = bBorder; bHasBorderSet = true; } + bool IsFrameBorderSet() const + { return bHasBorderSet; } + void ResetBorder() + { bHasBorder = false; bHasBorderSet = false; } +}; + +#endif // INCLUDED_SFX2_FRMDESCR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/frmhtml.hxx b/include/sfx2/frmhtml.hxx new file mode 100644 index 000000000..205c320fe --- /dev/null +++ b/include/sfx2/frmhtml.hxx @@ -0,0 +1,38 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_FRMHTML_HXX +#define INCLUDED_SFX2_FRMHTML_HXX + +#include +#include + +#include + +class SfxFrameDescriptor; + +namespace SfxFrameHTMLParser +{ +// These methods can also be used by other parsers. +SFX2_DLLPUBLIC void ParseFrameOptions(SfxFrameDescriptor*, const HTMLOptions&, std::u16string_view); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/frmhtmlw.hxx b/include/sfx2/frmhtmlw.hxx new file mode 100644 index 000000000..1011327c2 --- /dev/null +++ b/include/sfx2/frmhtmlw.hxx @@ -0,0 +1,71 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_FRMHTMLW_HXX +#define INCLUDED_SFX2_FRMHTMLW_HXX + +#include +#include +#include +#include + +class SvStream; + +namespace com::sun::star { + namespace document { + class XDocumentProperties; + } +} + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::uno { template class Reference; } + +class SFX2_DLLPUBLIC SfxFrameHTMLWriter +{ + SAL_DLLPRIVATE static void OutMeta( SvStream& rStrm, + const char *pIndent, const OUString& rName, + const OUString& rContent, bool bHTTPEquiv, + OUString *pNonConvertableChars = nullptr ); + SAL_DLLPRIVATE inline static void OutMeta( SvStream& rStrm, + const char *pIndent, const char *pName, + const OUString& rContent, bool bHTTPEquiv, + OUString *pNonConvertableChars = nullptr ); + +public: + static void Out_DocInfo( SvStream& rStrm, const OUString& rBaseURL, + const css::uno::Reference< css::document::XDocumentProperties>&, + const char *pIndent, + OUString *pNonConvertableChars = nullptr ); + + static void Out_FrameDescriptor( + SvStream&, const OUString& rBaseURL, const css::uno::Reference < css::beans::XPropertySet >& xSet, + OUString *pNonConvertableChars = nullptr ); +}; + +inline void SfxFrameHTMLWriter::OutMeta( SvStream& rStrm, + const char *pIndent, const char *pName, + const OUString& rContent, bool bHTTPEquiv, + OUString *pNonConvertableChars ) +{ + OUString sTmp = OUString::createFromAscii(pName); + OutMeta( rStrm, pIndent, sTmp, rContent, bHTTPEquiv, pNonConvertableChars ); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/groupid.hxx b/include/sfx2/groupid.hxx new file mode 100644 index 000000000..fd31785ae --- /dev/null +++ b/include/sfx2/groupid.hxx @@ -0,0 +1,74 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_GROUPID_HXX +#define INCLUDED_SFX2_GROUPID_HXX + +#include + +#include + +// !! If you add a new group, please change sfxbasecontroller.cxx and +// !! com.sun.star.frame.CommandGroup accordingly! + +enum class SfxGroupId +{ + NONE = 0, + Intern = 32700, + Application, + Document, + View, + Edit, + Macro, + Options, + Math, + Navigator, + Insert, + Format, + Template, + Text, + Frame, + Graphic, + Table, + Enumeration, + Data, + Special, + Image, + Chart, + Explorer, + Connector, + Modify, + Drawing, + Controls +}; + +// make it hashable for storing in maps +namespace std +{ +template <> struct hash +{ + std::size_t operator()(const SfxGroupId& k) const + { + return std::hash()(static_cast(k)); + } +}; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/htmlmode.hxx b/include/sfx2/htmlmode.hxx new file mode 100644 index 000000000..cd2b7d1fe --- /dev/null +++ b/include/sfx2/htmlmode.hxx @@ -0,0 +1,31 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_HTMLMODE_HXX +#define INCLUDED_SFX2_HTMLMODE_HXX + +enum +{ + HTMLMODE_ON = 0x0001, + HTMLMODE_SOME_STYLES = 0x0020, /* mind. MS IE */ + HTMLMODE_FULL_STYLES = 0x0040 /* == SW */ +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx new file mode 100644 index 000000000..f5b948014 --- /dev/null +++ b/include/sfx2/infobar.hxx @@ -0,0 +1,140 @@ +/* -*- 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/. + */ +#ifndef INCLUDED_SFX2_INFOBAR_HXX +#define INCLUDED_SFX2_INFOBAR_HXX + +#include + +#include + +#include +#include +#include + +// These must match the values in offapi/com/sun/star/frame/InfobarType.idl +enum class InfobarType +{ + INFO = 0, + SUCCESS = 1, + WARNING = 2, + DANGER = 3 +}; + +class InfobarData +{ +public: + OUString msId; + OUString msPrimaryMessage; + OUString msSecondaryMessage; + InfobarType maInfobarType; + bool mbShowCloseButton; +}; + +/** SfxChildWindow for positioning the InfoBar in the view. + */ +class SFX2_DLLPUBLIC SfxInfoBarContainerChild final : public SfxChildWindow +{ +private: + SfxBindings* m_pBindings; + +public: + SfxInfoBarContainerChild(vcl::Window* pParent, sal_uInt16 nId, SfxBindings* pBindings, + SfxChildWinInfo* pInfo); + virtual ~SfxInfoBarContainerChild() override; + + SFX_DECL_CHILDWINDOW_WITHID(SfxInfoBarContainerChild); + + void Update(); +}; + +class ExtraButton; + +/** Class representing a single InfoBar to be added in a SfxInfoBarContainerWindow. + */ +class SFX2_DLLPUBLIC SfxInfoBarWindow final : public InterimItemWindow +{ +private: + OUString m_sId; + InfobarType m_eType; + Size m_aMessageSize; + Size m_aOrigMessageSize; + bool m_bLayingOut; + std::unique_ptr m_xImage; + std::unique_ptr m_xPrimaryMessage; + std::unique_ptr m_xSecondaryMessage; + std::unique_ptr m_xButtonBox; + std::unique_ptr m_xCloseBtn; + std::vector> m_aActionBtns; + + DECL_DLLPRIVATE_LINK(SizeAllocHdl, const Size&, void); + + void SetForeAndBackgroundColors(InfobarType eType); + void SetCloseButtonImage(); + +public: + SfxInfoBarWindow(vcl::Window* parent, const OUString& sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, InfobarType InfobarType, + bool bShowCloseButton); + Size DoLayout(); + virtual void Layout() override; + virtual ~SfxInfoBarWindow() override; + virtual void dispose() override; + + const OUString& getId() const { return m_sId; } + void Update(const OUString& sPrimaryMessage, const OUString& sSecondaryMessage, + InfobarType eType); + basegfx::BColor m_aBackgroundColor; + basegfx::BColor m_aForegroundColor; + + /** Add button to Infobar. + * Infobar takes ownership of the button so the button is + * destroyed when the infobar gets destroyed. + * + * The optional "pCommand" is used by extensions, via XInfobarProvider, to + * dispatch pCommand on click. + */ + weld::Button& addButton(const OUString* pCommand = nullptr); + + void SetCommandHandler(weld::Button& rBtn, const OUString& aCommand); + +private: + DECL_DLLPRIVATE_LINK(CloseHandler, const OString&, void); +}; + +class SfxInfoBarContainerWindow final : public vcl::Window +{ +private: + SfxInfoBarContainerChild* m_pChildWin; + std::vector> m_pInfoBars; + Idle m_aLayoutIdle; + bool m_bResizing; + + DECL_LINK(DoUpdateLayout, Timer*, void); + +public: + SfxInfoBarContainerWindow(SfxInfoBarContainerChild* pChildWin); + virtual ~SfxInfoBarContainerWindow() override; + virtual void dispose() override; + + VclPtr appendInfoBar(const OUString& sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, InfobarType ibType, + bool bShowCloseButton); + VclPtr getInfoBar(std::u16string_view sId); + bool hasInfoBarWithID(std::u16string_view sId); + void removeInfoBar(VclPtr const& pInfoBar); + static bool isInfobarEnabled(std::u16string_view sId); + + void TriggerUpdateLayout(); + + virtual void Resize() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/inputdlg.hxx b/include/sfx2/inputdlg.hxx new file mode 100644 index 000000000..840844d18 --- /dev/null +++ b/include/sfx2/inputdlg.hxx @@ -0,0 +1,38 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_SOURCE_INC_INPUTDLG_HXX +#define INCLUDED_SFX2_SOURCE_INC_INPUTDLG_HXX + +#include +#include + +class SFX2_DLLPUBLIC InputDialog final : public weld::GenericDialogController +{ +private: + std::unique_ptr m_xEntry; + std::unique_ptr m_xLabel; + std::unique_ptr m_xHelp; + std::unique_ptr m_xOk; + std::function mCheckEntry; + DECL_DLLPRIVATE_LINK(EntryChangedHdl, weld::Entry&, void); + +public: + InputDialog(weld::Widget* pParent, const OUString& rLabelText); + OUString GetEntryText() const; + void SetEntryText(const OUString& rStr); + void HideHelpBtn(); + void SetEntryMessageType(weld::EntryMessageType aType); + void SetTooltip(const OUString& rStr); + void setCheckEntry(std::function aFunc); +}; + +#endif // INCLUDED_SFX2_SOURCE_INC_INPUTDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/ipclient.hxx b/include/sfx2/ipclient.hxx new file mode 100644 index 000000000..6eddf9e9f --- /dev/null +++ b/include/sfx2/ipclient.hxx @@ -0,0 +1,101 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_IPCLIENT_HXX +#define INCLUDED_SFX2_IPCLIENT_HXX + +#include +#include +#include +#include + +#include + +#include +#include + +namespace com::sun::star::embed { class XEmbeddedObject; } +namespace com::sun::star::uno { template class Reference; } +namespace vcl { class Window; } + +class SfxInPlaceClient_Impl; +class SfxViewShell; +class SfxObjectShell; +class Fraction; + + +class SFX2_DLLPUBLIC SfxInPlaceClient +{ +friend class SfxInPlaceClient_Impl; + + rtl::Reference m_xImp; + SfxViewShell* m_pViewSh; + VclPtr m_pEditWin; + + // called after the requested new object area was negotiated + SAL_DLLPRIVATE virtual void ObjectAreaChanged(); + + // an active object was resized by the user and now asks for the new space + SAL_DLLPRIVATE virtual void RequestNewObjectArea( tools::Rectangle& ); + + // notify the client that an active object has changed its VisualAreaSize + SAL_DLLPRIVATE virtual void ViewChanged(); + +public: + SfxInPlaceClient( SfxViewShell* pViewShell, vcl::Window* pDraw, sal_Int64 nAspect ); + virtual ~SfxInPlaceClient(); + + SfxInPlaceClient(const SfxInPlaceClient &) = delete; + SfxInPlaceClient& operator=(const SfxInPlaceClient &) = delete; + + SfxViewShell* GetViewShell() const { return m_pViewSh; } + vcl::Window* GetEditWin() const { return m_pEditWin; } + const css::uno::Reference < css::embed::XEmbeddedObject >& GetObject() const; + void SetObject( const css::uno::Reference < css::embed::XEmbeddedObject >& rObject ); + void SetObjectState( sal_Int32 ); + bool IsObjectUIActive() const; + bool IsObjectInPlaceActive() const; + void DeactivateObject(); + bool SetObjArea( const tools::Rectangle & ); + const tools::Rectangle& GetObjArea() const; + tools::Rectangle GetScaledObjArea() const; + void SetSizeScale( const Fraction & rScaleWidth, const Fraction & rScaleHeight ); + void SetObjAreaAndScale( const tools::Rectangle&, const Fraction&, const Fraction& ); + const Fraction& GetScaleWidth() const; + const Fraction& GetScaleHeight() const; + void Invalidate(); + static SfxInPlaceClient* GetClient( SfxObjectShell const * pDoc, const css::uno::Reference < css::embed::XEmbeddedObject >& xObject ); + sal_Int64 GetAspect() const; + sal_Int64 GetObjectMiscStatus() const; + ErrCode DoVerb(sal_Int32 nVerb); + void VisAreaChanged(); + void ResetObject(); + bool IsUIActive() const; + + /// To indicate that negated document X coordinates are used + void SetNegativeX(bool bSet); + bool IsNegativeX() const; + + virtual void FormatChanged(); // object format was changed (used for StarMath formulas aligning) + + virtual bool IsProtected() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/linkmgr.hxx b/include/sfx2/linkmgr.hxx new file mode 100644 index 000000000..e4f58a996 --- /dev/null +++ b/include/sfx2/linkmgr.hxx @@ -0,0 +1,187 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_LINKMGR_HXX +#define INCLUDED_SFX2_LINKMGR_HXX + +#include +#include +#include +#include +#include +#include + +#include +#include + +class SfxObjectShell; +class Graphic; + +namespace com::sun::star { + namespace lang { + class XComponent; + } +} + +namespace weld { class Window; } + +namespace sfx2 +{ + // For the link to receive information about the status of graphics that + // will be loaded the FileObject sends a SvData, which contains the + // FormatID "RegisterStatusInfoId" and a string as the data container. + // This contains the following enum. + +typedef std::vector > SvBaseLinks; + +typedef o3tl::sorted_vector SvLinkSources; + +class SFX2_DLLPUBLIC LinkManager +{ + typedef ::std::vector< css::uno::Reference< css::lang::XComponent > > + CompVector; + CompVector maCachedComps; + + SvBaseLinks aLinkTbl; + SvLinkSources aServerTbl; + + SfxObjectShell *pPersist; // LinkMgr must be release before SfxObjectShell + + bool InsertLink( SvBaseLink* pLink, SvBaseLinkObjectType nObjType, SfxLinkUpdateMode nUpdateType, + const OUString* pName ); +public: + + enum LinkState + { + STATE_LOAD_OK, + STATE_LOAD_ERROR, + STATE_LOAD_ABORT + }; + + LinkManager( SfxObjectShell * pCacheCont ); + ~LinkManager(); + + /** + * Insert a component loaded during link update, which needs to be closed + * when the update is complete. + * + * @param xComp component loaded during link update. + */ + void InsertCachedComp(const css::uno::Reference< css::lang::XComponent >& xComp); + + void CloseCachedComps(); + + SfxObjectShell* GetPersist() const { return pPersist; } + void SetPersist( SfxObjectShell * p ) { pPersist = p; } + + void Remove( SvBaseLink const *pLink ); + void Remove( size_t nPos, size_t nCnt = 1 ); + bool Insert( SvBaseLink* pLink ); + + // the links connect to a SvLinkSource and adds to the list + void InsertDDELink( SvBaseLink*, + const OUString& rServer, + std::u16string_view rTopic, + std::u16string_view rItem ); + + // if everything is already set at the link! + void InsertDDELink( SvBaseLink* ); + + // Connect the links to a pseudo-object and add to the list + void InsertFileLink( sfx2::SvBaseLink&, + SvBaseLinkObjectType nFileType, + std::u16string_view rFileNm, + const OUString* pFilterNm = nullptr, + const OUString* pRange = nullptr ); + + void ReconnectDdeLink(SfxObjectShell& rServer); + + /** + * Reconnect the server document shell to a DDE link object. + * + * @param rPath path to the server document + * @param rServer server document shell instance + * @param rLink link object of the client document + */ + static void LinkServerShell(const OUString& rPath, SfxObjectShell& rServer, ::sfx2::SvBaseLink& rLink); + + // Obtain the string for the dialog + static bool GetDisplayNames( const SvBaseLink *, + OUString* pType, + OUString* pFile = nullptr, + OUString* pLink = nullptr, + OUString* pFilter = nullptr ); + + static SvLinkSourceRef CreateObj( SvBaseLink const * ); + + void UpdateAllLinks(bool bAskUpdate, + bool bUpdateGrfLinks, + weld::Window* pParentWin); + + // Call for list of links (eg for link-dialog) + const SvBaseLinks& GetLinks() const { return aLinkTbl; } + + // ----------------- Server-side management -------------------- + + // Call with list of links to server + const SvLinkSources& GetServers() const { return aServerTbl; } + // Link register/delete + bool InsertServer( SvLinkSource* rObj ); + void RemoveServer( SvLinkSource* rObj ); + + // A transfer is aborted, so cancel all download media + // (for the time being this is only of interest for the FileLinks!) + void CancelTransfers(); + + // To send status information from the FileObject to the Baselink, + // for this there exist a separate ClipBoardId. The SvData-object has + // got the appropriate information as a string. + // Is now required for FileObject in conjunction with JavaScript + // this needs information about Load/Abort/Error + static SotClipboardFormatId RegisterStatusInfoId(); + + // if the mimetype says graphic/bitmap/gdimetafile then get the + // graphic from the Any. Return says no errors + bool GetGraphicFromAny(const OUString& rMimeType, + const css::uno::Any & rValue, + Graphic& rGrf, + weld::Window* pParentWin); + +private: + LinkManager( const LinkManager& ) = delete; + LinkManager& operator=( const LinkManager& ) = delete; +}; + +// Separator in the link name for the DDE-/File-/Graphics- links +// (only those who need to construct a SvLinkName) +const sal_Unicode cTokenSeparator = 0xFFFF; + +// create a string for the SvLinkName. For: +// - DDE the first 3 Strings, (Server, Topic, Item) +// - File-/Graphics-LinkNames the last 3 Strings (FileName, Region, Filter) +SFX2_DLLPUBLIC void MakeLnkName( OUString& rName, + const OUString* pType, // Can also be null!! + std::u16string_view rFile, + std::u16string_view rLink, + const OUString* pFilter = nullptr ); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/linksrc.hxx b/include/sfx2/linksrc.hxx new file mode 100644 index 000000000..4f12d72f4 --- /dev/null +++ b/include/sfx2/linksrc.hxx @@ -0,0 +1,118 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_LINKSRC_HXX +#define INCLUDED_SFX2_LINKSRC_HXX + +#include +#include + +#include +#include +#include + +namespace com::sun::star::uno +{ + class Any; +} +namespace weld { class Window; } + +template class Link; +namespace com::sun::star::io { class XInputStream; } + +#ifndef ADVISEMODE_NODATA +// Must be the same value as Ole2 ADVF_* +#define ADVISEMODE_NODATA 0x01 +#define ADVISEMODE_PRIMEFIRST 0x02 +#define ADVISEMODE_ONLYONCE 0x04 +#define ADVISEMODE_DATAONSTOP 0x40 +#endif + +namespace sfx2 +{ + +class SvBaseLink; +struct SvLinkSource_Impl; + +class SFX2_DLLPUBLIC SvLinkSource : public SvRefBase +{ +private: + std::unique_ptr pImpl; // compatible area + +public: + + SvLinkSource(); + virtual ~SvLinkSource() override; + + bool HasDataLinks() const; + + void Closed(); + + sal_uInt64 GetUpdateTimeout() const; + void SetUpdateTimeout( sal_uInt64 nTimeMs ); + // notify the sink, the mime type is not + // a selection criterion + void DataChanged( const OUString & rMimeType, + const css::uno::Any & rVal ); + void SendDataChanged(); + void NotifyDataChanged(); + + virtual bool Connect( SvBaseLink* ); + virtual bool GetData( css::uno::Any & rData /*out param*/, + const OUString & rMimeType, + bool bSynchron = false ); + + // sal_True => waitinmg for data + virtual bool IsPending() const; + // sal_True => data complete loaded + virtual bool IsDataComplete() const; + + virtual void Edit(weld::Window *, SvBaseLink *, const Link& rEndEditHdl); + + + void AddDataAdvise( SvBaseLink *, const OUString & rMimeType, + sal_uInt16 nAdviceMode ); + void RemoveAllDataAdvise( SvBaseLink const * ); + + void AddConnectAdvise( SvBaseLink * ); + void RemoveConnectAdvise( SvBaseLink const * ); + + struct StreamToLoadFrom{ + StreamToLoadFrom( + const css::uno::Reference& xInputStream, bool bIsReadOnly ) + :m_xInputStreamToLoadFrom(xInputStream), + m_bIsReadOnly(bIsReadOnly) + { + } + + css::uno::Reference + m_xInputStreamToLoadFrom; + bool m_bIsReadOnly; + }; + + StreamToLoadFrom getStreamToLoadFrom(); + void setStreamToLoadFrom(const css::uno::Reference& xInputStream, bool bIsReadOnly ); + void clearStreamToLoadFrom(); +}; + +typedef tools::SvRef SvLinkSourceRef; + +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/listview.hxx b/include/sfx2/listview.hxx new file mode 100644 index 000000000..fbcdd0cbd --- /dev/null +++ b/include/sfx2/listview.hxx @@ -0,0 +1,116 @@ +/* -*- 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/. + */ + +#pragma once + +#include + +enum TemplateViewMode +{ + eListView, + eThumbnailView +}; +class SfxDocumentTemplates; +class TemplateContainerItem; +struct ListViewItem; + +class ListView +{ +public: + ListView(std::unique_ptr xTreeView); + ~ListView(); + + void AppendItem(const OUString& rId, const OUString& rTitle, const OUString& rSubtitle, + const OUString& rPath, bool bDefault); + + void AppendRow(const OUString& rImage, const OUString& rTitle, const OUString& rSubtitle, + const OUString& rApplication, const OUString& rModify, const OUString& rSize, + const OUString& rId); + + void UpdateRow(int nIndex, const OUString& rImage, const OUString& rTitle, + const OUString& rSubtitle, const OUString& rApplication, const OUString& rModify, + const OUString& rSize, const OUString& rId); + + void ReloadRows(); + + bool UpdateRows(); + + void sortColumn(const int col); + + void sort(); + + void clearListView(); + + void ShowListView() { mxTreeView->show(); } + + void HideListView() { mxTreeView->hide(); } + + void unselect_all() { mxTreeView->unselect_all(); } + + void grab_focus() { mxTreeView->grab_focus(); } + + void rename(const OUString& rId, const OUString& rTitle); + + void refreshDefaultColumn(); + +protected: + sal_uInt16 get_nId(int pos) const; + + void select_id(const OUString& sId) { mxTreeView->select_id(sId); } + + int get_selected_index() const { return mxTreeView->get_selected_index(); } + + std::vector get_selected_rows() const { return mxTreeView->get_selected_rows(); } + + bool IsListViewVisible() const { return mxTreeView->is_visible(); } + + OUString get_id(int pos) const { return mxTreeView->get_id(pos); } + + void set_cursor(int pos) { mxTreeView->set_cursor(pos); } + + int get_cursor_index() const { return mxTreeView->get_cursor_index(); } + + sal_uInt16 get_cursor_nId() const { return get_nId(mxTreeView->get_cursor_index()); } + + void select(int pos) { mxTreeView->select(pos); } + + int get_index(sal_uInt16 nId) const { return mxTreeView->find_id(OUString::number(nId)); } + + DECL_LINK(ColumnClickedHdl, const int, void); + + DECL_LINK(QueryTooltipHdl, const weld::TreeIter&, OUString); + +protected: + std::unique_ptr mxTreeView; + std::vector> mListViewItems; + Link maSelectionChangedHdl; + int mnSortColumn; +}; + +struct ListViewItem +{ +public: + OUString maId; + OUString maTitle; + OUString maSubtitle; + OUString maApplication; + OUString maPath; + bool mbDefault; + + /** Last modify time in seconds since 1/1/1970. */ + sal_uInt32 mnModify; + /** Size in bytes of the file. */ + sal_uInt64 mnSize; + + OUString maDisplayModify; + OUString maDisplaySize; + OUString maDisplayPath; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/lnkbase.hxx b/include/sfx2/lnkbase.hxx new file mode 100644 index 000000000..cf1083197 --- /dev/null +++ b/include/sfx2/lnkbase.hxx @@ -0,0 +1,179 @@ +/* -*- 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 + +namespace com::sun::star::uno +{ + class Any; +} + +namespace com::sun::star::io { class XInputStream; } + +enum class SfxLinkUpdateMode { + NONE = 0, + // Ole2 compatible and persistent + ALWAYS = 1, + ONCALL = 3 +}; + +namespace sfx2 +{ + +struct ImplBaseLinkData; +class LinkManager; +class FileDialogHelper; + +enum class SvBaseLinkObjectType { + Internal = 0x00, + DdeExternal = 0x02, + ClientSo = 0x80, // a Link + ClientDde = 0x81, + ClientFile = 0x90, + ClientGraphic = 0x91, + ClientOle = 0x92 // embedded link +}; + +constexpr bool isClientType(SvBaseLinkObjectType t) +{ + return static_cast(t) & static_cast(SvBaseLinkObjectType::ClientSo); +} +constexpr bool isClientFileType(SvBaseLinkObjectType t) +{ + auto check = static_cast(SvBaseLinkObjectType::ClientFile); + return (static_cast(t) & check) == check; +} + +class SFX2_DLLPUBLIC SvBaseLink : public SvRefBase +{ +private: + friend class LinkManager; + friend class SvLinkSource; + + Link m_aEndEditLink; + LinkManager* m_pLinkMgr; + weld::Window* m_pParentWin; + std::unique_ptr + m_pFileDlg; + SvLinkSourceRef xObj; + OUString aLinkName; + std::unique_ptr pImplData; + SvBaseLinkObjectType mnObjType; + bool bVisible : 1; + bool bSynchron : 1; + bool bWasLastEditOK : 1; + bool m_bIsConnect : 1; + + DECL_DLLPRIVATE_LINK( EndEditHdl, const OUString&, void ); + + bool ExecuteEdit( const OUString& _rNewName ); + +protected: + void SetObjType( SvBaseLinkObjectType ); + + // Set LinkSourceName without action + void SetName( const OUString & rLn ); + + bool m_bIsReadOnly; + css::uno::Reference + m_xInputStreamToLoadFrom; + + SvBaseLink(); + SvBaseLink( SfxLinkUpdateMode nLinkType, SotClipboardFormatId nContentType ); + virtual ~SvBaseLink() override; + + void GetRealObject_( bool bConnect = true ); + + SvLinkSource* GetRealObject() + { + if( !xObj.is() ) + GetRealObject_(); + return xObj.get(); + } + +public: + + virtual void Closed(); + +#if defined(_WIN32) + SvBaseLink( const OUString& rNm, SvBaseLinkObjectType nObjectType, + SvLinkSource* ); +#endif + + SvBaseLinkObjectType GetObjType() const { return mnObjType; } + + void SetObj( SvLinkSource * pObj ); + SvLinkSource* GetObj() const { return xObj.get(); } + + void SetLinkSourceName( const OUString & rName ); + const OUString& GetLinkSourceName() const { return aLinkName;} + + enum UpdateResult { + SUCCESS = 0, + ERROR_GENERAL = 1 + }; + + virtual UpdateResult DataChanged( + const OUString & rMimeType, const css::uno::Any & rValue ); + + void SetUpdateMode( SfxLinkUpdateMode ); + SfxLinkUpdateMode GetUpdateMode() const; + SotClipboardFormatId GetContentType() const; + void SetContentType( SotClipboardFormatId nType ); + + LinkManager* GetLinkManager(); + const LinkManager* GetLinkManager() const; + void SetLinkManager( LinkManager* _pMgr ); + + bool Update(); + void Disconnect(); + + virtual void Edit(weld::Window*, const Link& rEndEditHdl); + + // should the link appear in the dialog? (to the left in the link in the...) + bool IsVisible() const { return bVisible; } + void SetVisible( bool bFlag ) { bVisible = bFlag; } + // should the Link be loaded synchronous or asynchronous? + bool IsSynchron() const { return bSynchron; } + void SetSynchron( bool bFlag ) { bSynchron = bFlag; } + + void setStreamToLoadFrom( + const css::uno::Reference& xInputStream, + bool bIsReadOnly ) + { m_xInputStreamToLoadFrom = xInputStream; + m_bIsReadOnly = bIsReadOnly; } + // #i88291# + void clearStreamToLoadFrom(); + + bool WasLastEditOK() const { return bWasLastEditOK; } + FileDialogHelper & GetInsertFileDialog(const OUString& rFactory); +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/lokcallback.hxx b/include/sfx2/lokcallback.hxx new file mode 100644 index 000000000..32b6c08f8 --- /dev/null +++ b/include/sfx2/lokcallback.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/. + */ + +#pragma once + +#include + +namespace tools +{ +class Rectangle; +} + +// An extended callback type that allows passing in also some binary data, +// so that post-processing the messages does not require conversions +// from and to strings. + +// TODO: It might possibly make sense to drop the generic type/payload function +// and have only a dedicated function for each message type? + +class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI SfxLokCallbackInterface +{ +public: + virtual ~SfxLokCallbackInterface() {} + // LibreOfficeKitCallback equivalent. + virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) = 0; + // Callback that explicitly provides view id (which is also included in the payload). + virtual void libreOfficeKitViewCallbackWithViewId(int nType, const char* pPayload, int nViewId) + = 0; + // LOK_CALLBACK_INVALIDATE_TILES + // nPart is either part, -1 for all-parts, or INT_MIN if + // comphelper::LibreOfficeKit::isPartInInvalidation() is not set + virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart) + = 0; + // A message of the given type should be sent, for performance purpose only a notification + // is given here, details about the message should be queried from SfxViewShell when necessary. + // This is used for messages that are generated often but only the last one is needed. + virtual void libreOfficeKitViewUpdatedCallback(int nType) = 0; + // Like libreOfficeKitViewUpdatedCallback(), but a last message is needed for each nViewId value. + // SfxViewShell:getLOKPayload() will be called on nSourceViewId view. + virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, + int nSourceViewId) + = 0; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/lokcomponenthelpers.hxx b/include/sfx2/lokcomponenthelpers.hxx new file mode 100644 index 000000000..6a3d96468 --- /dev/null +++ b/include/sfx2/lokcomponenthelpers.hxx @@ -0,0 +1,90 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_LOKCHARTHELPER_HXX +#define INCLUDED_SFX2_LOKCHARTHELPER_HXX + +#include +#include +#include +#include + +namespace com::sun::star::frame { class XController; } +namespace com::sun::star::frame { class XDispatch; } + +class SfxViewShell; +class VirtualDevice; + +/// A class for chart editing support via LibreOfficeKit. +class SFX2_DLLPUBLIC LokChartHelper +{ +private: + SfxViewShell* mpViewShell; + css::uno::Reference mxController; + css::uno::Reference mxDispatcher; + VclPtr mpWindow; + bool mbNegativeX; + +public: + LokChartHelper(SfxViewShell* pViewShell, bool bNegativeX = false) + : mpViewShell(pViewShell) + , mpWindow(nullptr) + , mbNegativeX(bNegativeX) + {} + + css::uno::Reference& GetXController(); + css::uno::Reference& GetXDispatcher(); + vcl::Window* GetWindow(); + tools::Rectangle GetChartBoundingBox(); + void Invalidate(); + + bool Hit(const Point& aPos); + static bool HitAny(const Point& aPos, bool bNegativeX = false); + void PaintTile(VirtualDevice& rRenderContext, const tools::Rectangle& rTileRect); + static void PaintAllChartsOnTile(VirtualDevice& rDevice, + int nOutputWidth, int nOutputHeight, + int nTilePosX, int nTilePosY, + tools::Long nTileWidth, tools::Long nTileHeight, + bool bNegativeX = false); + bool postMouseEvent(int nType, int nX, int nY, + int nCount, int nButtons, int nModifier, + double fScaleX = 1.0, double fScaleY = 1.0); + bool setTextSelection(int nType, int nX, int nY); + bool setGraphicSelection(int nType, int nX, int nY, + double fScaleX = 1.0, double fScaleY = 1.0); +}; + +/// A class for math editing support via LibreOfficeKit. +class SFX2_DLLPUBLIC LokStarMathHelper +{ +public: + LokStarMathHelper(SfxViewShell* pViewShell) + : mpViewShell(pViewShell) + { + } + + vcl::Window* GetGraphicWindow(); + vcl::Window* GetWidgetWindow(); + + bool postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier, + double fScaleX = 1.0, double fScaleY = 1.0); + +private: + css::uno::Reference& GetXController(); + tools::Rectangle GetBoundingBox(); + + SfxViewShell* mpViewShell; + css::uno::Reference mxController; + VclPtr mpGraphicWindow; + VclPtr mpWidgetWindow; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx new file mode 100644 index 000000000..4ac50a19c --- /dev/null +++ b/include/sfx2/lokhelper.hxx @@ -0,0 +1,171 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_LOKHELPER_HXX +#define INCLUDED_SFX2_LOKHELPER_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct SFX2_DLLPUBLIC LokMouseEventData +{ + int mnType; + Point maPosition; + int mnCount; + MouseEventModifiers meModifiers; + int mnButtons; + int mnModifier; + std::optional maLogicPosition; + + LokMouseEventData(int nType, Point aPosition, int nCount, MouseEventModifiers eModifiers, int nButtons, int nModifier) + : mnType(nType) + , maPosition(aPosition) + , mnCount(nCount) + , meModifiers(eModifiers) + , mnButtons(nButtons) + , mnModifier(nModifier) + {} +}; + +#include + +class SFX2_DLLPUBLIC SfxLokHelper +{ +public: + /// Create a new view shell from the current view frame. + /// This assumes a single document is ever loaded. + static int createView(); + /// Create a new view shell for the given DocId, for multi-document support. + static int createView(int nDocId); + /// Destroy a view shell from the global shell list. + static void destroyView(int nId); + /// Set a view shell as current one. + static void setView(int nId); + /// Get view shell with id + static SfxViewShell* getViewOfId(int nId); + /// Get the currently active view. + static int getView(const SfxViewShell* pViewShell = nullptr); + /// Get the number of views of the current DocId. + static std::size_t getViewsCount(int nDocId); + /// Get viewIds of views of the current DocId. + static bool getViewIds(int nDocId, int* pArray, size_t nSize); + /// Set View Blocked for some uno commands + static void setBlockedCommandList(int nViewId, const char* blockedCommandList); + /// Get the document id for a view + static int getDocumentIdOfView(int nViewId); + /// Get the default language that should be used for views + static const LanguageTag & getDefaultLanguage(); + /// Set language of the given view. + static void setViewLanguage(int nId, const OUString& rBcp47LanguageTag); + /// Set the default language for views. + static void setDefaultLanguage(const OUString& rBcp47LanguageTag); + /// Set the locale for the given view. + static void setViewLocale(int nId, const OUString& rBcp47LanguageTag); + /// Get the device form factor that should be used for a new view. + static LOKDeviceFormFactor getDeviceFormFactor(); + /// Set the device form factor that should be used for a new view. + static void setDeviceFormFactor(std::u16string_view rDeviceFormFactor); + + /// Iterate over any view shell, except pThisViewShell, passing it to the f function. + template + static void forEachOtherView(ViewShellType* pThisViewShell, FunctionType f); + + /// Invoke the LOK callback of all other views showing the same document as pThisView, with a payload of rKey-rPayload. + static void notifyOtherViews(const SfxViewShell* pThisView, int nType, std::string_view rKey, + const OString& rPayload); + /// Invoke the LOK callback of all views except pThisView, with a JSON payload created from the given property tree. + static void notifyOtherViews(const SfxViewShell* pThisView, int nType, + const boost::property_tree::ptree& rTree); + /// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them. + static void notifyOtherView(const SfxViewShell* pThisView, SfxViewShell const* pOtherView, + int nType, std::string_view rKey, const OString& rPayload); + /// Same as notifyOtherViews(), the property-tree version, but works on a selected "other" view, not on all of them. + static void notifyOtherView(const SfxViewShell* pThisView, SfxViewShell const* pOtherView, + int nType, const boost::property_tree::ptree& rTree); + + /// Emits a LOK_CALLBACK_STATE_CHANGED + static void sendUnoStatus(const SfxViewShell* pShell, const SfxPoolItem* pItem); + /// Emits a LOK_CALLBACK_WINDOW + static void notifyWindow(const SfxViewShell* pThisView, + vcl::LOKWindowId nWindowId, + std::u16string_view rAction, + const std::vector& rPayload = std::vector()); + /// Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED - if @bInvalidateAll - first invalidates all parts + static void notifyDocumentSizeChanged(SfxViewShell const* pThisView, const OString& rPayload, vcl::ITiledRenderable* pDoc, bool bInvalidateAll = true); + /// Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED for all views of the same document - if @bInvalidateAll - first invalidates all parts + static void notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc, bool bInvalidateAll = true); + /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed. + static void notifyInvalidation(SfxViewShell const* pThisView, tools::Rectangle const *); + /// Notifies all views with the given type and payload. + static void notifyAllViews(int nType, const OString& rPayload); + + /// Notify about the editing context change. + static void notifyContextChange(SfxViewShell const* pViewShell, const OUString& aApplication, const OUString& aContext); + + // Notify about the given type needing an update. + static void notifyUpdate(SfxViewShell const* pViewShell, int nType); + // Notify about the given type needing a per-viewid update. + static void notifyUpdatePerViewId(SfxViewShell const* pViewShell, int nType); + /// Same as notifyUpdatePerViewId(), pTargetShell will be notified, relevant viewId in pViewShell, + /// pSourceView->getLOKPayload() will be called to get the data. + static void notifyUpdatePerViewId(SfxViewShell const* pTargetShell, SfxViewShell const* pViewShell, + SfxViewShell const* pSourceShell, int nType); + // Notify other views about the given type needing a per-viewid update. + static void notifyOtherViewsUpdatePerViewId(SfxViewShell const* pViewShell, int nType); + + static OString makePayloadJSON(const SfxViewShell* pThisView, int nViewId, std::string_view rKey, const OString& rPayload); + /// Makes a LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR payload, but tweaks it according to setOptionalFeatures() if needed. + static OString makeVisCursorInvalidation(int nViewId, const OString& rRectangle, + bool bMispelledWord = false, const OString& rHyperlink = ""); + + /// Helper for posting async key event + static void postKeyEventAsync(const VclPtr &xWindow, + int nType, int nCharCode, int nKeyCode, int nRepeat = 0); + + /// Helper for posting input event + static void postExtTextEventAsync(const VclPtr &xWindow, + int nType, const OUString &rText); + + /// Helper for posting async mouse event + static void postMouseEventAsync(const VclPtr &xWindow, LokMouseEventData const & rLokMouseEventData); + + /// A special value to signify 'infinity'. + /// This value is chosen such that sal_Int32 will not overflow when manipulated. + static const tools::Long MaxTwips = 1e9; + +private: + static int createView(SfxViewFrame* pViewFrame, ViewShellDocId docId); +}; + +template +void SfxLokHelper::forEachOtherView(ViewShellType* pThisViewShell, FunctionType f) +{ + SfxViewShell* pViewShell = SfxViewShell::GetFirst(); + while (pViewShell) + { + auto pOtherViewShell = dynamic_cast(pViewShell); + if (pOtherViewShell != nullptr && pOtherViewShell != pThisViewShell && pOtherViewShell->GetDocId() == pThisViewShell->GetDocId()) + { + f(pOtherViewShell); + } + pViewShell = SfxViewShell::GetNext(*pViewShell); + } +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/mailmodelapi.hxx b/include/sfx2/mailmodelapi.hxx new file mode 100644 index 000000000..47d5b4086 --- /dev/null +++ b/include/sfx2/mailmodelapi.hxx @@ -0,0 +1,104 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_MAILMODELAPI_HXX +#define INCLUDED_SFX2_MAILMODELAPI_HXX + +#include +#include +#include +#include +#include +#include + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::frame { class XFrame; } +namespace com::sun::star::frame { class XModel; } +namespace com::sun::star::lang { class XMultiServiceFactory; } +namespace com::sun::star::uno { class XInterface; } +namespace com::sun::star::uno { template class Sequence; } + +// class AddressList_Impl ------------------------------------------------ +typedef ::std::vector< OUString > AddressList_Impl; + +// class SfxMailModel_Impl ----------------------------------------------- + +class SFX2_DLLPUBLIC SfxMailModel +{ +protected: + enum SaveResult + { + SAVE_SUCCESSFUL, + SAVE_CANCELLED, + SAVE_ERROR + }; + ::std::vector< OUString > maAttachedDocuments; + static SaveResult SaveDocumentAsFormat( const OUString& aSaveFileName, + const css::uno::Reference< css::uno::XInterface >& xFrameOrModel, + const OUString& rType, + OUString& rFileNamePath ); + +private: + std::unique_ptr mpToList; + OUString maFromAddress; + + static SaveResult ShowFilterOptionsDialog( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR, + const css::uno::Reference< css::frame::XModel >& xModel, + const OUString& rFilterName, + std::u16string_view rType, + bool bModified, + sal_Int32& rNumArgs, + css::uno::Sequence< css::beans::PropertyValue >& rArgs ); + +public: + enum SendMailResult + { + SEND_MAIL_OK, + SEND_MAIL_CANCELLED, + SEND_MAIL_ERROR + }; + + SfxMailModel(); + ~SfxMailModel(); + + void AddToAddress( const OUString& rAddress ); + + /** attaches a document to the current attachment list, can be called more than once. + * at the moment there will be a dialog for export executed for every model which is going to be attached. + * + * \param xModel + The current model to attach + * \param sAttachmentTitle + The title which will be used as attachment title + * \return @see error code + */ + SendMailResult AttachDocument( const css::uno::Reference< css::uno::XInterface >& xFrameOrModel, + const OUString& sAttachmentTitle ); + + SendMailResult SaveAndSend( const css::uno::Reference< css::frame::XFrame >& xFrame, + const OUString& rType ); + SendMailResult Send( const css::uno::Reference< css::frame::XFrame >& xFrame ); + + bool IsEmpty() const; +}; + +bool CreateFromAddress_Impl( OUString& rFrom ); + +#endif // INCLUDED_SFX2_MAILMODELAPI_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/mieclip.hxx b/include/sfx2/mieclip.hxx new file mode 100644 index 000000000..bc2a431b3 --- /dev/null +++ b/include/sfx2/mieclip.hxx @@ -0,0 +1,43 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_MIECLIP_HXX +#define INCLUDED_SFX2_MIECLIP_HXX + +#include +#include +#include +#include +#include + +class SFX2_DLLPUBLIC MSE40HTMLClipFormatObj +{ + std::unique_ptr pStrm; + OUString sBaseURL; + +public: + MSE40HTMLClipFormatObj() {} + ~MSE40HTMLClipFormatObj(); + + SvStream* IsValid(SvStream&); +}; + +#endif // INCLUDED_SFX2_MIECLIP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/minfitem.hxx b/include/sfx2/minfitem.hxx new file mode 100644 index 000000000..ce6f8b25a --- /dev/null +++ b/include/sfx2/minfitem.hxx @@ -0,0 +1,70 @@ +/* -*- 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 + +#if HAVE_FEATURE_SCRIPTING + +class BasicManager; + +class SFX2_DLLPUBLIC SfxMacroInfoItem final : public SfxPoolItem +{ + const BasicManager* pBasicManager; + OUString aLibName; + OUString aModuleName; + OUString aMethodName; + OUString aCommentText; + +public: + static SfxPoolItem* CreateDefault(); + SfxMacroInfoItem( sal_uInt16 nWhich, + const BasicManager* pMgr, + const OUString &rLibName, + const OUString &rModuleName, + const OUString &rMethodName, + const OUString &rComment); + + virtual SfxMacroInfoItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool operator==( const SfxPoolItem& ) const override; + const OUString& GetMethod() const + { return aMethodName; } + void SetMethod( const OUString& r ) + { aMethodName = r; } + const OUString& GetModule() const + { return aModuleName; } + void SetModule( const OUString& r ) + { aModuleName = r; } + const OUString& GetLib() const + { return aLibName; } + void SetLib( const OUString& r ) + { aLibName = r; } + const BasicManager* GetBasicManager() const + { return pBasicManager; } + OUString GetQualifiedName() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/module.hxx b/include/sfx2/module.hxx new file mode 100644 index 000000000..099222c1a --- /dev/null +++ b/include/sfx2/module.hxx @@ -0,0 +1,103 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_MODULE_HXX +#define INCLUDED_SFX2_MODULE_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class SfxObjectFactory; +class SfxModule_Impl; +class SfxSlotPool; +struct SfxChildWinFactory; +struct SfxStbCtrlFactory; +struct SfxTbxCtrlFactory; +class SfxTabPage; + +namespace com::sun::star::frame { + class XFrame; +} + +namespace weld { + class Container; + class DialogController; +} + +class SFX2_DLLPUBLIC SfxModule : public SfxShell +{ +private: + // Warning this cannot be turned into a unique_ptr. + // SfxInterface destruction in the SfxSlotPool refers again to pImpl after deletion of pImpl has commenced. See tdf#100270 + SfxModule_Impl* pImpl; + + SAL_DLLPRIVATE void Construct_Impl(const OString& rResName); + +public: + SFX_DECL_INTERFACE(SFX_INTERFACE_SFXMODULE) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl() {} + +public: + + SfxModule(const OString& rResName, std::initializer_list pFactoryList); + virtual ~SfxModule() override; + + std::locale GetResLocale() const; + SfxSlotPool* GetSlotPool() const; + + void RegisterToolBoxControl(const SfxTbxCtrlFactory&); + void RegisterChildWindow(const SfxChildWinFactory&); + void RegisterStatusBarControl(const SfxStbCtrlFactory&); + + virtual std::unique_ptr CreateTabPage( sal_uInt16 nId, + weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rSet ); + virtual void Invalidate(sal_uInt16 nId = 0) override; + + virtual std::optional CreateStyleFamilies() { return {}; } + + static SfxModule* GetActiveModule( SfxViewFrame* pFrame=nullptr ); + static FieldUnit GetCurrentFieldUnit(); + /** retrieves the field unit of the module belonging to the document displayed in the given frame + + Effectively, this method looks up the SfxViewFrame belonging to the given XFrame, then the SfxModule belonging to + the document in this frame, then this module's field unit. + + Failures in any of those steps are reported as assertion in non-product builds, and then FieldUnit::MM_100TH is returned. + */ + static FieldUnit GetModuleFieldUnit( css::uno::Reference< css::frame::XFrame > const & i_frame ); + FieldUnit GetFieldUnit() const; + + SAL_DLLPRIVATE SfxTbxCtrlFactory* GetTbxCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const; + SAL_DLLPRIVATE SfxStbCtrlFactory* GetStbCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const; + SAL_DLLPRIVATE SfxChildWinFactory* GetChildWinFactoryById(sal_uInt16 nId) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/msg.hxx b/include/sfx2/msg.hxx new file mode 100644 index 000000000..e628e572c --- /dev/null +++ b/include/sfx2/msg.hxx @@ -0,0 +1,264 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_MSG_HXX +#define INCLUDED_SFX2_MSG_HXX + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +class SfxItemPool; + +enum class SfxSlotMode { + NONE = 0x0000, // default + + TOGGLE = 0x0004, // inverted for Execute old value + AUTOUPDATE = 0x0008, // invalidated the status automatically after execute + ASYNCHRON = 0x0020, // via Post-Message + + NORECORD = 0x0100, // no recording + RECORDPERITEM = 0x0200, // each item, one statement + RECORDPERSET = 0x0400, // The whole Set is a Statement, default + RECORDABSOLUTE = 0x1000000, // Recording with absolute Target + + METHOD = 0x4000, + + FASTCALL = 0x8000, // No test if disabled before Execute + + MENUCONFIG = 0x20000, // configurable Menu + TOOLBOXCONFIG = 0x40000, // configurable Toolboxen + ACCELCONFIG = 0x80000, // configurable keys + + CONTAINER = 0x100000, // Operated by the container at InPlace + READONLYDOC = 0x200000 // also available for read-only Documents +}; + +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +#define SFX_EXEC_STUB( aShellClass, aExecMethod) \ + void SfxStub##aShellClass##aExecMethod( \ + SfxShell *pShell, SfxRequest& rReq) \ + { \ + ::tools::detail::castTo(pShell)->aExecMethod( rReq ); \ + } + +#define SFX_STATE_STUB( aShellClass, aStateMethod) \ + void SfxStub##aShellClass##aStateMethod( \ + SfxShell *pShell, SfxItemSet& rSet) \ + { \ + static_cast(pShell)->aStateMethod( rSet ); \ + } + +#define SFX_STUB_PTR( aShellClass, aMethod ) \ + &SfxStub##aShellClass##aMethod + +#define SFX_STUB_PTR_EXEC_NONE &SfxShell::EmptyExecStub + +#define SFX_STUB_PTR_STATE_NONE &SfxShell::EmptyStateStub + + +enum class SfxSlotKind +{ + Standard, + Attribute +}; + + +struct SfxTypeAttrib +{ + sal_uInt16 nAID; + const char* pName; +}; + +template SfxPoolItem* createSfxPoolItem() +{ + return T::CreateDefault(); +} +struct SfxType +{ + std::function createSfxPoolItemFunc; + const std::type_info* pType; + sal_uInt16 nAttribs; + SfxTypeAttrib aAttrib[1]; // variable length + + const std::type_info* Type() const{return pType;} + std::unique_ptr CreateItem() const + { return std::unique_ptr(createSfxPoolItemFunc()); } +}; + +struct SfxType0 +{ + std::function createSfxPoolItemFunc; + const std::type_info* pType; + sal_uInt16 nAttribs; + const std::type_info* Type() const { return pType;} +}; +#define SFX_DECL_TYPE(n) struct SfxType##n \ + { \ + std::function createSfxPoolItemFunc; \ + const std::type_info* pType; \ + sal_uInt16 nAttribs; \ + SfxTypeAttrib aAttrib[n]; \ + } + +#define SFX_TYPE(Class) &a##Class##_Impl + +SFX_DECL_TYPE(1); +SFX_DECL_TYPE(2); +SFX_DECL_TYPE(3); +SFX_DECL_TYPE(4); +SFX_DECL_TYPE(5); +SFX_DECL_TYPE(6); +SFX_DECL_TYPE(7); +SFX_DECL_TYPE(8); +SFX_DECL_TYPE(10); // for SfxDocInfoItem +SFX_DECL_TYPE(11); + +SFX_DECL_TYPE(13); // for SwAddPrinterItem, Sd... +SFX_DECL_TYPE(14); +SFX_DECL_TYPE(16); // for SwDocDisplayItem +SFX_DECL_TYPE(17); // for SvxAddressItem +SFX_DECL_TYPE(23); // for SvxSearchItem + +// all SfxTypes must be in this header +#undef SFX_DECL_TYPE + +#define SFX_SLOT_ARG( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass, nArg0, nArgs, Name, Prop ) \ + { id, GroupId, Flags | Prop, \ + USHRT_MAX, 0, \ + ExecMethodPtr, \ + StateMethodPtr, \ + (const SfxType*) &a##ItemClass##_Impl, \ + 0, \ + &a##aShellClass##Args_Impl[nArg0], nArgs, SfxDisableFlags::NONE, Name \ + } + +#define SFX_NEW_SLOT_ARG( aShellClass, id, GroupId, pNext, ExecMethodPtr, StateMethodPtr, Flags, DisableFlags, ItemClass, nArg0, nArgs, Prop, UnoName ) \ + { id, GroupId, Flags | Prop, \ + USHRT_MAX, 0, \ + ExecMethodPtr, \ + StateMethodPtr, \ + (const SfxType*) &a##ItemClass##_Impl, \ + pNext, \ + &a##aShellClass##Args_Impl[nArg0], nArgs, DisableFlags, UnoName \ + } + +struct SfxFormalArgument +{ + const SfxType* pType; // Type of the parameter (SfxPoolItem subclass) + const char* pName; // Name of the sParameters + sal_uInt16 nSlotId; // Slot-Id for identification of the Parameters + + std::unique_ptr CreateItem() const + { return pType->CreateItem(); } +}; + + +class SfxSlot +{ +public: + sal_uInt16 nSlotId; // Unique slot-ID in Shell + SfxGroupId nGroupId; // for configuration region + SfxSlotMode nFlags; // arithmetic ordered Flags + + sal_uInt16 nMasterSlotId; // Enum-Slot for example Which-Id + sal_uInt16 nValue; // Value, in case of Enum-Slot + + SfxExecFunc fnExec; // Function to be executed + SfxStateFunc fnState; // Function for Status + + const SfxType* pType; // SfxPoolItem-Type (Status) + + const SfxSlot* pNextSlot; // with the same Status-Method + + const SfxFormalArgument* pFirstArgDef; // first formal Argument-Definition + sal_uInt16 nArgDefCount; // Number of formal Arguments + SfxDisableFlags nDisableFlags; // DisableFlags that need to be + // present, so that the Slot + // can be enabled + const char* pUnoName; // UnoName for the Slots + +public: + + SfxSlotKind GetKind() const; + sal_uInt16 GetSlotId() const; + SfxSlotMode GetMode() const; + bool IsMode( SfxSlotMode nMode ) const; + SfxGroupId GetGroupId() const; + sal_uInt16 GetWhich( const SfxItemPool &rPool ) const; + const SfxType* GetType() const { return pType; } + const char* GetUnoName() const { return pUnoName; } + SFX2_DLLPUBLIC OString GetCommand() const; + SFX2_DLLPUBLIC OUString GetCommandString() const; + + sal_uInt16 GetFormalArgumentCount() const { return nArgDefCount; } + const SfxFormalArgument& GetFormalArgument( sal_uInt16 nNo ) const + { return pFirstArgDef[nNo]; } + + SfxExecFunc GetExecFnc() const { return fnExec; } + SfxStateFunc GetStateFnc() const { return fnState; } + + const SfxSlot* GetNextSlot() const { return pNextSlot; } +}; + + +// returns the id of the function + +inline sal_uInt16 SfxSlot::GetSlotId() const +{ + return nSlotId; +} + +// returns a bitfield with flags + +inline SfxSlotMode SfxSlot::GetMode() const +{ + return nFlags; +} + + +// determines if the specified mode is assigned + +inline bool SfxSlot::IsMode( SfxSlotMode nMode ) const +{ + return bool(nFlags & nMode); +} + + +// returns the id of the associated group + +inline SfxGroupId SfxSlot::GetGroupId() const +{ + return nGroupId; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/msgpool.hxx b/include/sfx2/msgpool.hxx new file mode 100644 index 000000000..7aa38904c --- /dev/null +++ b/include/sfx2/msgpool.hxx @@ -0,0 +1,74 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_MSGPOOL_HXX +#define INCLUDED_SFX2_MSGPOOL_HXX + +#include +#include +#include +#include +#include +#include + +class SfxInterface; +class SfxSlot; +class SfxViewFrame; + +class SFX2_DLLPUBLIC SfxSlotPool +{ + std::vector _vGroups; + SfxSlotPool* _pParentPool; + std::vector _vInterfaces; + sal_uInt16 _nCurGroup; + sal_uInt16 _nCurInterface; + sal_uInt16 _nCurMsg; + +private: + const SfxSlot* SeekSlot( sal_uInt16 nObject ); + +public: + SfxSlotPool(SfxSlotPool* pParent=nullptr); + ~SfxSlotPool(); + + void RegisterInterface( SfxInterface& rFace ); + + static SfxSlotPool& GetSlotPool( SfxViewFrame *pFrame=nullptr ); + + sal_uInt16 GetGroupCount() const; + OUString SeekGroup( sal_uInt16 nNo ); + const SfxSlot* FirstSlot(); + const SfxSlot* NextSlot(); + const SfxSlot* GetSlot( sal_uInt16 nId ) const; + const SfxSlot* GetUnoSlot( const OUString& rUnoName ) const; + const std::type_info* GetSlotType( sal_uInt16 nSlotId ) const; +}; + + +// seeks to the first func in the current group + +inline const SfxSlot* SfxSlotPool::FirstSlot() +{ + return SeekSlot(0); +} + +#define SFX_SLOTPOOL() SfxSlotPool::GetSlotPool() + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/navigat.hxx b/include/sfx2/navigat.hxx new file mode 100644 index 000000000..febdefa81 --- /dev/null +++ b/include/sfx2/navigat.hxx @@ -0,0 +1,43 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_NAVIGAT_HXX +#define INCLUDED_SFX2_NAVIGAT_HXX + +#include +#include + +class SFX2_DLLPUBLIC SfxNavigatorWrapper : public SfxChildWindow +{ +protected: + void Initialize(); +public: + SfxNavigatorWrapper(vcl::Window* pParent, sal_uInt16 nId); +}; + +class SFX2_DLLPUBLIC SfxNavigator : public SfxDockingWindow +{ +public: + SfxNavigator(SfxBindings* pBindings, SfxChildWindow* pChildWin, + vcl::Window* pParent, SfxChildWinInfo* pInfo); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/new.hxx b/include/sfx2/new.hxx new file mode 100644 index 000000000..8cb2bd9b4 --- /dev/null +++ b/include/sfx2/new.hxx @@ -0,0 +1,108 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_NEW_HXX +#define INCLUDED_SFX2_NEW_HXX + +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace weld { class Button; } +namespace weld { class CheckButton; } +namespace weld { class CustomWeld; } +namespace weld { class Expander; } +namespace weld { class Label; } +namespace weld { class TreeView; } +namespace weld { class Window; } + +class SfxPreviewWin_Impl; + +enum class SfxNewFileDialogMode { + NONE, Preview, LoadTemplate +}; + +enum class SfxTemplateFlags +{ + NONE = 0x00, + LOAD_TEXT_STYLES = 0x01, + LOAD_FRAME_STYLES = 0x02, + LOAD_PAGE_STYLES = 0x04, + LOAD_NUM_STYLES = 0x08, + MERGE_STYLES = 0x10, +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +#define RET_TEMPLATE_LOAD 100 + +class SFX2_DLLPUBLIC SfxNewFileDialog final : public SfxDialogController +{ +private: + Idle m_aPrevIdle; + SfxNewFileDialogMode m_nFlags; + SfxDocumentTemplates m_aTemplates; + SfxObjectShellLock m_xDocShell; + + std::unique_ptr m_xPreviewController; + + std::unique_ptr m_xRegionLb; + std::unique_ptr m_xTemplateLb; + std::unique_ptr m_xTextStyleCB; + std::unique_ptr m_xFrameStyleCB; + std::unique_ptr m_xPageStyleCB; + std::unique_ptr m_xNumStyleCB; + std::unique_ptr m_xMergeStyleCB; + std::unique_ptr m_xLoadFilePB; + std::unique_ptr m_xMoreBt; + std::unique_ptr m_xPreviewWin; + std::unique_ptr m_xAltTitleFt; + + DECL_DLLPRIVATE_LINK( Update, Timer *, void ); + + DECL_DLLPRIVATE_LINK(RegionSelect, weld::TreeView&, void); + DECL_DLLPRIVATE_LINK(TemplateSelect, weld::TreeView&, void); + DECL_DLLPRIVATE_LINK(DoubleClick, weld::TreeView&, bool); + DECL_DLLPRIVATE_LINK(Expand, weld::Expander&, void); + sal_uInt16 GetSelectedTemplatePos() const; + +public: + SfxNewFileDialog(weld::Window *pParent, SfxNewFileDialogMode nFlags); + virtual ~SfxNewFileDialog() override; + + // Returns false, when '- No -' is set as Template + // Template names can only be obtained when IsTemplate() returns true. + bool IsTemplate() const; + OUString GetTemplateFileName() const; + + // load template methods + SfxTemplateFlags GetTemplateFlags() const; + void SetTemplateFlags(SfxTemplateFlags nSet); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/newstyle.hxx b/include/sfx2/newstyle.hxx new file mode 100644 index 000000000..23dbfa612 --- /dev/null +++ b/include/sfx2/newstyle.hxx @@ -0,0 +1,55 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_NEWSTYLE_HXX +#define INCLUDED_SFX2_NEWSTYLE_HXX + +#include +#include +#include +#include +#include + +class SFX2_DLLPUBLIC SfxNewStyleDlg final : public weld::GenericDialogController +{ +private: + SfxStyleSheetBasePool& m_rPool; + SfxStyleFamily m_eSearchFamily; + + std::unique_ptr m_xColBox; + std::unique_ptr m_xOKBtn; + + std::unique_ptr m_xQueryOverwriteBox; + + DECL_DLLPRIVATE_LINK(OKHdl, weld::TreeView&, bool); + DECL_DLLPRIVATE_LINK(OKClickHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(ModifyHdl, weld::ComboBox&, void); + +public: + SfxNewStyleDlg(weld::Widget* pParent, SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam); + virtual ~SfxNewStyleDlg() override; + + OUString GetName() const + { + return comphelper::string::stripStart(m_xColBox->get_active_text(), ' '); + } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/notebookbar/SfxNotebookBar.hxx b/include/sfx2/notebookbar/SfxNotebookBar.hxx new file mode 100644 index 000000000..66286b87c --- /dev/null +++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx @@ -0,0 +1,89 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_NOTEBOOKBAR_SFXNOTEBOOKBAR_HXX +#define INCLUDED_SFX2_NOTEBOOKBAR_SFXNOTEBOOKBAR_HXX + +#include +#include +#include +#include + +#include +#include +#include + +namespace com::sun::star::frame +{ +class XFrame; +} +namespace com::sun::star::uno +{ +template class Reference; +} + +class SfxBindings; +class SfxViewFrame; +class SfxViewShell; +class SystemWindow; +class WeldedTabbedNotebookbar; + +namespace sfx2 +{ +/** Helpers for easier access to NotebookBar via the sfx2 infrastructure. +*/ +class SFX2_DLLPUBLIC SfxNotebookBar +{ +public: + static void CloseMethod(SfxBindings& rBindings); + static void CloseMethod(SystemWindow* pSysWindow); + + static bool IsActive(); + + /// Function to be called from the sdi's ExecMethod. + static void ExecMethod(SfxBindings& rBindings, const OUString& rUIName); + + /// Function to be called from the sdi's StateMethod. + static bool StateMethod(SfxBindings& rBindings, std::u16string_view rUIFile, + bool bReloadNotebookbar = false); + static bool StateMethod(SystemWindow* pSysWindow, + const css::uno::Reference& xFrame, + std::u16string_view rUIFile, bool bReloadNotebookbar = false); + + /// Method temporarily blocks showing of the NotebookBar + static void LockNotebookBar(); + /// Method restores normal behaviour of the Notebookbar + static void UnlockNotebookBar(); + + static void RemoveListeners(SystemWindow const* pSysWindow); + + /** Show menu bar in all frames of current application */ + static void ShowMenubar(bool bShow); + /** Show menu bar only in current frame */ + static void ShowMenubar(SfxViewFrame const* pViewFrame, bool bShow); + static void ToggleMenubar(); + static void ReloadNotebookBar(std::u16string_view sUIPath); + +private: + static bool m_bLock; + static bool m_bHide; + + static std::map> + m_pNotebookBarWeldedWrapper; + + static void ResetActiveToolbarModeToDefault(vcl::EnumContext::Application eApp); + + DECL_DLLPRIVATE_STATIC_LINK(SfxNotebookBar, VclDisposeHdl, const SfxViewShell*, void); +}; + +} // namespace sfx2 + +#endif // INCLUDED_SFX2_NOTEBOOKBAR_SFXNOTEBOOKBAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/objface.hxx b/include/sfx2/objface.hxx new file mode 100644 index 000000000..fadf510ca --- /dev/null +++ b/include/sfx2/objface.hxx @@ -0,0 +1,121 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_OBJFACE_HXX +#define INCLUDED_SFX2_OBJFACE_HXX + +#include +#include +#include +#include +#include +#include +#include + +struct SfxInterface_Impl; +class SfxModule; + +#define SFX_OBJECTBAR_APPLICATION 0 +#define SFX_OBJECTBAR_OBJECT 1 +#define SFX_OBJECTBAR_TOOLS 2 +#define SFX_OBJECTBAR_MACRO 3 +#define SFX_OBJECTBAR_FULLSCREEN 4 +#define SFX_OBJECTBAR_RECORDING 5 +#define SFX_OBJECTBAR_COMMONTASK 6 +#define SFX_OBJECTBAR_OPTIONS 7 +#define SFX_OBJECTBAR_NAVIGATION 12 +#define SFX_OBJECTBAR_MAX 13 + +enum class StatusBarId : sal_uInt32 +{ + None = 0, + GenericStatusBar = 4, + WriterStatusBar = 20013, + MathStatusBar = 20816, + DrawStatusBar = 23007, + CalcStatusBar = 26005, + BasicIdeStatusBar = 30805 +}; + +class SFX2_DLLPUBLIC SfxInterface final +{ +friend class SfxSlotPool; + + const char* pName; // Sfx-internal name of interface + const SfxInterface* pGenoType; // base interface + SfxSlot* pSlots; // SlotMap + sal_uInt16 nCount; // number of slots in SlotMap + SfxInterfaceId nClassId; // Id of interface + bool bSuperClass; // Whether children inherit its toolbars etc + std::unique_ptr pImplData; + +public: + SfxInterface( const char *pClass, + bool bSuperClass, + SfxInterfaceId nClassId, + const SfxInterface* pGeno, + SfxSlot &rMessages, sal_uInt16 nMsgCount ); + ~SfxInterface(); + + void SetSlotMap( SfxSlot& rMessages, sal_uInt16 nMsgCount ); + inline sal_uInt16 Count() const; + + const SfxSlot* GetRealSlot( const SfxSlot * ) const; + const SfxSlot* GetSlot( sal_uInt16 nSlotId ) const; + const SfxSlot* GetSlot( const OUString& rCommand ) const; + + const char* GetClassName() const { return pName; } + bool UseAsSuperClass() const { return bSuperClass; } + + const SfxInterface* GetGenoType() const { return pGenoType; } + + void RegisterObjectBar(sal_uInt16, SfxVisibilityFlags nFlags, ToolbarId eId); + void RegisterObjectBar(sal_uInt16, SfxVisibilityFlags nFlags, ToolbarId eId, SfxShellFeature nFeature); + void RegisterChildWindow(sal_uInt16, bool bContext = false); + void RegisterChildWindow(sal_uInt16, bool bContext, SfxShellFeature nFeature); + void RegisterStatusBar(StatusBarId eId); + ToolbarId GetObjectBarId(sal_uInt16 nNo) const; + sal_uInt16 GetObjectBarPos( sal_uInt16 nNo ) const; + SfxVisibilityFlags GetObjectBarFlags( sal_uInt16 nNo ) const; + SfxShellFeature GetObjectBarFeature(sal_uInt16 nNo) const; + sal_uInt16 GetObjectBarCount() const; + bool IsObjectBarVisible( sal_uInt16 nNo) const; + SfxShellFeature GetChildWindowFeature(sal_uInt16 nNo) const; + sal_uInt32 GetChildWindowId( sal_uInt16 nNo ) const; + sal_uInt16 GetChildWindowCount() const; + void RegisterPopupMenu( const OUString& ); + const OUString& GetPopupMenuName() const; + StatusBarId GetStatusBarId() const; + + void Register( const SfxModule* ); + + SAL_DLLPRIVATE bool ContainsSlot_Impl( const SfxSlot *pSlot ) const + { return pSlot >= pSlots && pSlot < pSlots + Count(); } +}; + + +// returns the number of functions in this cluster + +inline sal_uInt16 SfxInterface::Count() const +{ + return nCount; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/objitem.hxx b/include/sfx2/objitem.hxx new file mode 100644 index 000000000..17b7f0cf1 --- /dev/null +++ b/include/sfx2/objitem.hxx @@ -0,0 +1,48 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_OBJITEM_HXX +#define INCLUDED_SFX2_OBJITEM_HXX + +#include +#include +#include + +class SfxShell; + +class SFX2_DLLPUBLIC SfxObjectItem final : public SfxPoolItem +{ + SfxShell* _pSh; + +public: + static SfxPoolItem* CreateDefault(); + SfxObjectItem( sal_uInt16 nWhich=0, SfxShell *pSh=nullptr ); + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual SfxObjectItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + virtual bool QueryValue(css::uno::Any&, sal_uInt8 nMemberId = 0) const override; + virtual bool PutValue(const css::uno::Any&, sal_uInt8) override; + + SfxShell* GetShell() const + { return _pSh; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx new file mode 100644 index 000000000..428995bff --- /dev/null +++ b/include/sfx2/objsh.hxx @@ -0,0 +1,918 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_OBJSH_HXX +#define INCLUDED_SFX2_OBJSH_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace weld {class Button; } +class SbxValue; +class SbxArray; +class BasicManager; +class SfxMedium; +class SfxObjectFactory; +class SfxDocumentInfoDialog; +class SfxStyleSheetBasePool; +class StarBASIC; +class Printer; +class SvKeyValueIterator; +class SfxBaseModel; +class SfxModule; +class SfxProgress; +class GDIMetaFile; +class INetURLObject; +class IndexBitSet; +class JobSetup; +class OutputDevice; +class Color; +class Fraction; +class SvGlobalName; +class InfobarData; +class VirtualDevice; + +enum class SfxModelFlags; +enum class SfxEventHintId; +enum class InfobarType; + +// These values presumably must match exactly the corresponding +// css::embed::Aspects ones (in offapi/com/sun/star/embed/Aspects.idl) +// and the DVASPECT_* ones in the Win32 API. + +#define ASPECT_CONTENT 1 +#define ASPECT_THUMBNAIL 2 /* 120 * 120, 6 Colors DIB in MetaFile */ +#define ASPECT_ICON 4 +#define ASPECT_DOCPRINT 8 + +namespace sfx2 +{ + class SvLinkSource; + class StyleManager; +} + +namespace com::sun::star::awt { class XWindow; } +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::document { struct CmisVersion; } +namespace com::sun::star::document { class XDocumentProperties; } +namespace com::sun::star::embed { class XStorage; } +namespace com::sun::star::frame { class XModel; } +namespace com::sun::star::graphic { class XGraphic; } +namespace com::sun::star::io { class XStream; } +namespace com::sun::star::script { class XLibraryContainer; } +namespace com::sun::star::security { class XCertificate; } +namespace com::sun::star::security { class XDocumentDigitalSignatures; } +namespace com::sun::star::security { struct DocumentSignatureInformation; } +namespace com::sun::star::task { class XInteractionHandler; } +namespace com::sun::star::lang { class XComponent; } +namespace com::sun::star::text { class XTextRange; } + +namespace sfx2 { class IXmlIdRegistry; } + +#define SFX_TITLE_TITLE 0 +#define SFX_TITLE_FILENAME 1 +#define SFX_TITLE_FULLNAME 2 +#define SFX_TITLE_APINAME 3 +#define SFX_TITLE_DETECT 4 +#define SFX_TITLE_CAPTION 5 +#define SFX_TITLE_PICKLIST 6 +#define SFX_TITLE_HISTORY 7 +#define SFX_TITLE_MAXLEN 10 // this gives the limits on length + +enum class SfxLoadedFlags +{ + NONE = 0, + MAINDOCUMENT = 1, + IMAGES = 2, + ALL = MAINDOCUMENT | IMAGES +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +enum class HiddenInformation +{ + NONE = 0x0000, + RECORDEDCHANGES = 0x0001, + NOTES = 0x0002, + DOCUMENTVERSIONS = 0x0004 +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +namespace weld { class Window; } + +enum class HiddenWarningFact +{ + WhenSaving = 0, + WhenPrinting, + WhenSigning, + WhenCreatingPDF +}; + +enum class SfxObjectCreateMode +{ + EMBEDDED, + STANDARD, + ORGANIZER, + INTERNAL +}; + +/* + The class SfxObjectShell is the base class for SFx-objects, ie documents + and parts of documents that can be integrated as separate objects + into foreign objects. + There can be multiple edit windows (SfxViewShell) for one SfxObjectShell. +*/ + +struct TransferableObjectDescriptor; +template bool checkSfxObjectShell(const SfxObjectShell* pShell) +{ + return dynamic_cast(pShell) != nullptr; +} + +class SFX2_DLLPUBLIC SfxObjectShell : + public SfxShell, virtual public SotObject, + public ::comphelper::IEmbeddedHelper +{ +friend struct ModifyBlocker_Impl; +friend class SfxObjectShellLock; + +private: + std::unique_ptr pImpl; // internal data + + SfxMedium * pMedium; // Description of the file for example + // storage that contains the object + SfxObjectCreateMode eCreateMode; // Purpose of the object + bool bHasName :1; // sal_True := existing object, + // sal_False := new object + bool bIsInGenerateThumbnail; //optimize thumbnail generate and store procedure to improve odt saving performance, i120030 + bool mbAvoidRecentDocs; ///< Avoid adding to the recent documents list, if not necessary. + + enum TriState {undefined, yes, no}; + TriState mbContinueImportOnFilterExceptions = undefined; // try to import as much as possible + + bool CloseInternal(); + + SAL_DLLPRIVATE void UpdateTime_Impl(const css::uno::Reference< + css::document::XDocumentProperties> & i_xDocProps); + + SAL_DLLPRIVATE bool SaveTo_Impl(SfxMedium &rMedium, const SfxItemSet* pSet ); + +protected: + SfxObjectShell(SfxObjectCreateMode); + SfxObjectShell(SfxModelFlags); // see sfxmodelfactory.hxx + virtual ~SfxObjectShell() override; + + void ModifyChanged(); + virtual bool Close() override; + + /// template method, called by FlushDocInfo; this implementation is empty + virtual void DoFlushDocInfo(); + + // helper method + void AddToRecentlyUsedList(); + + // Parent class for actual guard objects that would do useful work + class LockAllViewsGuard + { + public: + virtual ~LockAllViewsGuard() {} + }; + +public: + SFX_DECL_INTERFACE(SFX_INTERFACE_SFXDOCSH) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + static const css::uno::Sequence& getUnoTunnelId(); + /* Stampit disable/enable cancel button for print jobs + default = true = enable! */ + void Stamp_SetPrintCancelState(bool bState); + bool Stamp_GetPrintCancelState() const; + + static OUString CreateShellID( const SfxObjectShell* pShell ); + + // Document-Shell Iterator + static SfxObjectShell* GetFirst( const std::function& isObjectShell = nullptr, + bool bOnlyVisible = true ); + static SfxObjectShell* GetNext( const SfxObjectShell& rPrev, + const std::function& isObjectShell = nullptr, + bool bOnlyVisible = true ); + static SfxObjectShell* Current(); + static css::uno::Reference< css::uno::XInterface > + GetCurrentComponent(); + static void SetCurrentComponent( const css::uno::Reference< css::uno::XInterface >& _rxComponent ); + + virtual void Invalidate(sal_uInt16 nId = 0) override; + + SfxModule* GetModule() const; + + virtual SfxObjectFactory& GetFactory() const=0; + SfxMedium * GetMedium() const { return pMedium; } + css::uno::Reference< css::document::XDocumentProperties > + getDocProperties() const; + void UpdateDocInfoForSave( ); + void FlushDocInfo(); + bool HasName() const { return bHasName; } + OUString GetAPIName() const; + void SetReadOnly(); + bool IsReadOnly() const; + bool IsReadOnlyMedium() const; + bool IsOriginallyReadOnlyMedium() const; + bool IsOriginallyLoadedReadOnlyMedium() const; + void SetReadOnlyUI( bool bReadOnly = true ); + bool IsReadOnlyUI() const; + void SetNoName(); + bool IsInModalMode() const; + bool IsInPrepareClose() const; + bool AcceptStateUpdate() const; + bool IsHelpDocument() const; + + bool IsDocShared() const; + OUString GetSharedFileURL() const; + bool SwitchToShared( bool bShared, bool bSave ); + SAL_DLLPRIVATE void FreeSharedFile( const OUString& aTempFileURL ); + SAL_DLLPRIVATE void DoNotCleanShareControlFile(); + void SetSharedXMLFlag( bool bFlag ) const; + bool HasSharedXMLFlagSet() const; + + SAL_DLLPRIVATE void SetModalMode_Impl(bool bModal); + SAL_DLLPRIVATE void SetMacroMode_Impl(bool bModal=true); + + void ResetError(); + ErrCode GetError() const; + ErrCode GetErrorCode() const; + void SetError(ErrCode rErr); + + /** + * Initialize bare minimum just enough for unit test runs. + * + * @return true if the initialization is successful, false otherwise. + */ + void DoInitUnitTest(); + bool DoInitNew(); + bool DoLoad( SfxMedium* pMedium ); + bool DoLoadExternal( SfxMedium* pMed ); + bool DoSave(); + bool DoSaveAs( SfxMedium &rNewStor ); + bool DoSaveObjectAs( SfxMedium &rNewStor, bool bCommit ); + + // TODO/LATER: currently only overridden in Calc, should be made non-virtual + virtual bool DoSaveCompleted( SfxMedium* pNewStor=nullptr, bool bRegisterRecent=true ); + /// Terminate any in-flight editing. Used before saving, primarily by Calc to commit cell changes. + virtual void TerminateEditing() {} + + bool LoadOwnFormat( SfxMedium& pMedium ); + virtual bool SaveAsOwnFormat( SfxMedium& pMedium ); + virtual bool ConvertFrom( SfxMedium &rMedium ); + virtual bool ConvertTo( SfxMedium &rMedium ); + virtual bool InitNew( const css::uno::Reference< css::embed::XStorage >& xStorage ); + virtual bool Load( SfxMedium &rMedium ); + virtual bool LoadFrom( SfxMedium& rMedium ); + virtual bool Save(); + virtual bool SaveAs( SfxMedium &rMedium ); + virtual bool SaveCompleted( const css::uno::Reference< css::embed::XStorage >& xStorage ); + bool SwitchPersistence( + const css::uno::Reference< css::embed::XStorage >& xStorage ); + virtual void UpdateLinks(); + virtual bool LoadExternal( SfxMedium& rMedium ); + bool IsConfigOptionsChecked() const; + void SetConfigOptionsChecked( bool bChecked ); + + // called for a few slots like SID_SAVE[AS]DOC, SID_PRINTDOC[DIRECT], derived classes may abort the action + virtual bool QuerySlotExecutable( sal_uInt16 nSlotId ); + + void SaveChildren(bool bObjectsOnly=false); + bool SaveAsChildren( SfxMedium &rMedium ); + bool SwitchChildrenPersistence( + const css::uno::Reference< css::embed::XStorage >& xStorage, + bool bForceNonModified = false ); + bool SaveCompletedChildren(); + + /** a very special case to insert at a position in Writer from UNO, + via OwnSubFilterService */ + virtual bool InsertGeneratedStream(SfxMedium& rMedium, + css::uno::Reference const& xInsertPosition); + virtual bool ImportFrom( SfxMedium &rMedium, + css::uno::Reference const& xInsertPosition); + bool ExportTo( SfxMedium &rMedium ); + + /** Returns true if preparing was successful, else false. */ + bool PrepareForSigning(weld::Window* pDialogParent); + bool CheckIsReadonly(bool bSignScriptingContent, weld::Window* pDialogParent = nullptr); + void RecheckSignature(bool bAlsoRecheckScriptingSignature); + void AfterSigning(bool bSignSuccess, bool bSignScriptingContent); + bool HasValidSignatures() const; + SignatureState GetDocumentSignatureState(); + void SignDocumentContent(weld::Window* pDialogParent); + css::uno::Sequence GetDocumentSignatureInformation( + bool bScriptingContent, + const css::uno::Reference& xSigner + = css::uno::Reference()); + + bool SignDocumentContentUsingCertificate(const css::uno::Reference& xCertificate); + + void SignSignatureLine(weld::Window* pDialogParent, const OUString& aSignatureLineId, + const css::uno::Reference& xCert, + const css::uno::Reference& xValidGraphic, + const css::uno::Reference& xInvalidGraphic, + const OUString& aComment); + SignatureState GetScriptingSignatureState(); + void SignScriptingContent(weld::Window* pDialogParent); + DECL_DLLPRIVATE_LINK(SignDocumentHandler, weld::Button&, void); + + virtual std::shared_ptr CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet& rItemSet); + + ErrCode CallBasic( std::u16string_view rMacro, std::u16string_view rBasicName, + SbxArray* pArgs, SbxValue* pRet = nullptr ); + + ErrCode CallXScript( + const OUString& rScriptURL, + const css::uno::Sequence< css::uno::Any >& aParams, + css::uno::Any& aRet, + css::uno::Sequence< sal_Int16 >& aOutParamIndex, + css::uno::Sequence< css::uno::Any >& aOutParam, + bool bRaiseError = true, + const css::uno::Any* aCaller = nullptr ); + + static ErrCode CallXScript( + const css::uno::Reference< css::uno::XInterface >& _rxScriptContext, + const OUString& rScriptURL, + const css::uno::Sequence< css::uno::Any >& aParams, + css::uno::Any& aRet, + css::uno::Sequence< sal_Int16 >& aOutParamIndex, + css::uno::Sequence< css::uno::Any >& aOutParam, + bool bRaiseError = true, + const css::uno::Any* aCaller = nullptr + ); + + /** adjusts the internal macro mode, according to the current security settings + + Finally, the macro mode is either NEVER_EXECUTE or ALWAYS_EXECUTE_NO_WARN. + + @return + whether macros from this document should be executed + */ + bool AdjustMacroMode(); + + static bool UnTrustedScript(const OUString& rScriptURL); + + static bool isScriptAccessAllowed(const css::uno::Reference& rScriptContext); + + SvKeyValueIterator* GetHeaderAttributes(); + void ClearHeaderAttributesForSourceViewHack(); + void SetHeaderAttributesForSourceViewHack(); + + bool IsQueryLoadTemplate() const; + bool IsUseUserData() const; + bool IsUseThumbnailSave() const; + bool IsLoadReadonly() const; + bool IsSaveVersionOnClose() const; + void SetQueryLoadTemplate( bool b ); + void SetUseUserData( bool bNew ); + void SetUseThumbnailSave( bool _bNew ); + void SetLoadReadonly( bool _bReadonly ); + void SetSaveVersionOnClose( bool bSet ); + void ResetFromTemplate( const OUString& rTemplateName, const OUString& rFileName ); + + // TODO/LATER: the following two methods should be replaced by Get/SetModifPasswordInfo in future + sal_uInt32 GetModifyPasswordHash() const; + bool SetModifyPasswordHash( sal_uInt32 nHash ); + + void SetMacroCallsSeenWhileLoading(); + bool GetMacroCallsSeenWhileLoading() const; + + const css::uno::Sequence< css::beans::PropertyValue >& GetModifyPasswordInfo() const; + bool SetModifyPasswordInfo( const css::uno::Sequence< css::beans::PropertyValue >& aInfo ); + + static ErrCode HandleFilter( SfxMedium* pMedium, SfxObjectShell const * pDoc ); + + virtual bool PrepareClose(bool bUI = true); + virtual HiddenInformation GetHiddenInformationState( HiddenInformation nStates ); + sal_Int16 QueryHiddenInformation( HiddenWarningFact eFact, weld::Window* pParent ); + bool IsSecurityOptOpenReadOnly() const; + void SetSecurityOptOpenReadOnly( bool bOpenReadOnly ); + + Size GetFirstPageSize() const; + bool DoClose(); + std::shared_ptr GetPreviewMetaFile( bool bFullContent = false ) const; + BitmapEx GetPreviewBitmap() const; + virtual void CancelTransfers(); + + bool GenerateAndStoreThumbnail( + bool bEncrypted, + const css::uno::Reference< css::embed::XStorage >& xStor ); + + bool WriteThumbnail( + bool bEncrypted, + const css::uno::Reference< css::io::XStream >& xStream ); + + bool IsInGenerateAndStoreThumbnail() const {return bIsInGenerateThumbnail;}//optimize thumbnail generate and store procedure to improve odt saving performance, i120030 + + /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted. + bool IsAvoidRecentDocs() const { return mbAvoidRecentDocs; } + + /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted. + void AvoidRecentDocs(bool bAvoid) { mbAvoidRecentDocs = bAvoid; } + + /// On first error ask user if import should continue; return saved answer. + bool IsContinueImportOnFilterExceptions(std::u16string_view aErrMessage); + + // Transfer IFace + bool IsAbortingImport() const; + void FinishedLoading( SfxLoadedFlags nWhich = SfxLoadedFlags::ALL ); + + void TemplateDisconnectionAfterLoad(); + void SetLoading(SfxLoadedFlags nFlags); + bool IsLoading() const; + bool IsLoadingFinished() const; + void SetAutoLoad( const INetURLObject&, sal_uInt32 nTime, bool bReload ); + bool IsAutoLoadLocked() const; + + // Misc + bool IsPreview() const; + SfxObjectCreateMode GetCreateMode() const { return eCreateMode; } + SfxProgress* GetProgress() const; + void SetWaitCursor( bool bSet ) const; + + // Naming Interface + void SetTitle( const OUString& rTitle ); + /* Small non-zero values of nMaxLen don't mean length, but have a magic meaning: + 0 (default) + the title itself, as it is + + 1 (==SFX_TITLE_FILENAME) + provides the logical file name without path + (under WNT depending on the system settings + without extension) + + 2 (==SFX_TITLE_FULLNAME) + provides the logical file names with full path + (remote =>:: com:: sun:: star:: util:: URL) + + 3 (==SFX_TITLE_APINAME) + provides the logical filename without path + and extension + + 4 (==SFX_TITLE_DETECT) + provides the complete title, if not set yet + it will be created from DocInfo or the name of + the medium. + + 5 (==SFX_TITLE_CAPTION) + provides the Title just like MB now in the + CaptionBar view + + 6 (==SFX_TITLE_PICKLIST) + returns the Title, just like MB now would + display it in the PickList + + 7 (==SFX_TITLE_HISTORY) + returns the Title just like MB now would + display it in the History + + 10 bis USHRT_MAX + provides the 'nMaxLength' of the logical + file name including the path + (remote => css::util::URL) + */ + OUString GetTitle( sal_uInt16 nMaxLen = 0 ) const; + void InvalidateName(); // Re-set to unnamed + +#if defined(_WIN32) + // DDE-Interface + bool DdeExecute( const OUString& rCmd ); + virtual bool DdeGetData( const OUString& rItem, + const OUString& rMimeType, + css::uno::Any & rValue ); + virtual bool DdeSetData( const OUString& rItem, + const OUString& rMimeType, + const css::uno::Any & rValue ); +#endif + virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem ); + virtual void ReconnectDdeLink(SfxObjectShell& rServer); + + static void ReconnectDdeLinks(SfxObjectShell& rServer); + + // Contents + virtual SfxStyleSheetBasePool* GetStyleSheetPool(); + + virtual void LoadStyles(SfxObjectShell &rSource); + + virtual sfx2::StyleManager* GetStyleManager(); + + // Determine the position of the "Automatic" filter in the stylist + void SetAutoStyleFilterIndex(sal_uInt16 nSet); + sal_uInt16 GetAutoStyleFilterIndex() const; + bool HasBasic() const; + BasicManager* GetBasicManager() const; + css::uno::Reference< css::script::XLibraryContainer > + GetBasicContainer(); + css::uno::Reference< css::script::XLibraryContainer > + GetDialogContainer(); + StarBASIC* GetBasic() const; + + virtual std::set GetDocColors(); + virtual std::vector GetThemeColors(); + + // Accessibility Check + virtual sfx::AccessibilityIssueCollection runAccessibilityCheck(); + + // Documents, for which to format the view size + + virtual SfxObjectShell* GetObjectShell() override; + + css::uno::Reference< css::frame::XModel3 > + GetModel() const; + // Only temporarily for the applications! + void SetBaseModel( SfxBaseModel* pModel ); + css::uno::Reference< css::frame::XModel3 > GetBaseModel() const; + // Only temporarily for the applications! + + virtual css::uno::Sequence< OUString > GetEventNames(); + + css::uno::Reference GetDialogParent(SfxMedium const* pMedium = nullptr); + static SfxObjectShell* CreateObject( const OUString& rServiceName, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD ); + static SfxObjectShell* CreateObjectByFactoryName( const OUString& rURL, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD ); + static css::uno::Reference< css::lang::XComponent > + CreateAndLoadComponent( const SfxItemSet& rSet ); + static SfxObjectShell* GetShellFromComponent(const css::uno::Reference< css::uno::XInterface >& xComp); + static SfxObjectShell* GetParentShell(const css::uno::Reference& xChild); + static OUString GetServiceNameFromFactory( const OUString& rFact ); + bool IsInPlaceActive() const; + bool IsUIActive() const; + + static bool CopyStoragesOfUnknownMediaType( + const css::uno::Reference< css::embed::XStorage >& xSource, + const css::uno::Reference& xTarget, + const css::uno::Sequence& rExceptions = css::uno::Sequence()); + + bool isEditDocLocked() const; + bool isContentExtractionLocked() const; + bool isExportLocked() const; + bool isPrintLocked() const; + bool isSaveLocked() const; + + // The functions from SvPersist + void EnableSetModified( bool bEnable = true ); + bool IsEnableSetModified() const; + virtual void SetModified( bool bModified = true ); + bool IsModified() const; + + /** + * @param bChart true if the file is a chart doc and FillClass should not be called + */ + void SetupStorage( + const css::uno::Reference< css::embed::XStorage >& xStorage, + sal_Int32 nVersion, bool bTemplate ) const; + + css::uno::Reference< css::embed::XStorage > const & GetStorage(); + + SvGlobalName const & GetClassName() const; + + // comphelper::IEmbeddedHelper + virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const override; + virtual css::uno::Reference < css::embed::XStorage > getStorage() const override + { + return const_cast(this)->GetStorage(); + } + virtual comphelper::EmbeddedObjectContainer& getEmbeddedObjectContainer() const override + { + return GetEmbeddedObjectContainer(); + } + bool isEnableSetModified() const override + { + return IsEnableSetModified(); + } + virtual OUString getDocumentBaseURL() const override; + + comphelper::EmbeddedObjectContainer& GetEmbeddedObjectContainer() const; + void ClearEmbeddedObjects(); + + // The functions from SvEmbeddedObject + virtual Printer * GetDocumentPrinter(); + virtual OutputDevice* GetDocumentRefDev(); + virtual void OnDocumentPrinterChanged( Printer * pNewPrinter ); + virtual tools::Rectangle GetVisArea( sal_uInt16 nAspect ) const; + virtual void SetVisArea( const tools::Rectangle & rVisArea ); + const tools::Rectangle & GetVisArea() const; + void SetVisAreaSize( const Size & rVisSize ); + + MapUnit GetMapUnit() const; + void SetMapUnit( MapUnit nMUnit ); + + void FillTransferableObjectDescriptor( TransferableObjectDescriptor& rDesc ) const; + void DoDraw( OutputDevice *, const Point & rObjPos, + const Size & rSize, + const JobSetup & rSetup, + sal_uInt16 nAspect = ASPECT_CONTENT ); + virtual void Draw( OutputDevice *, const JobSetup & rSetup, + sal_uInt16 nAspect ) = 0; + + + virtual void FillClass( SvGlobalName * pClassName, + SotClipboardFormatId * pFormat, + OUString * pFullTypeName, + sal_Int32 nVersion, + bool bTemplate = false) const = 0; + + // change recording and respective passwword protection for Writer and Calc + // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON + // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT + virtual bool IsChangeRecording() const; + virtual bool HasChangeRecordProtection() const; + virtual void SetChangeRecording( bool bActivate, bool bLockAllViews = false ); + virtual void SetProtectionPassword( const OUString &rPassword ); + virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash ); + + static bool IsOwnStorageFormat(const SfxMedium &); + + /** Append Infobar once the frame is ready. + Useful when you want to register an Infobar before the doc/frame is fully loaded. */ + void AppendInfoBarWhenReady(const OUString& sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, InfobarType aInfobarType, + bool bShowCloseButton = true); + std::vector& getPendingInfobars(); + + SAL_DLLPRIVATE bool CreatePreview_Impl(bool bFullContent, VirtualDevice* pDevice, GDIMetaFile* pFile) const; + + SAL_DLLPRIVATE static bool IsPackageStorageFormat_Impl(const SfxMedium &); + + SAL_DLLPRIVATE bool ConnectTmpStorage_Impl( const css::uno::Reference< css::embed::XStorage >& xStorage, SfxMedium* pMedium ); + SAL_DLLPRIVATE bool DisconnectStorage_Impl( SfxMedium& rSrcMedium, SfxMedium& rTargetMedium ); + + SAL_DLLPRIVATE bool PutURLContentsToVersionStream_Impl( + const OUString& aURL, + const css::uno::Reference< css::embed::XStorage >& xDocStorage, + const OUString& aStreamName ); + + SAL_DLLPRIVATE OUString CreateTempCopyOfStorage_Impl( + const css::uno::Reference< css::embed::XStorage >& xStorage ); + + SAL_DLLPRIVATE void InitOwnModel_Impl(); + SAL_DLLPRIVATE void BreakMacroSign_Impl( bool bBreakMacroSing ); + SAL_DLLPRIVATE void CheckSecurityOnLoading_Impl(); + SAL_DLLPRIVATE void CheckForBrokenDocSignatures_Impl(); + SAL_DLLPRIVATE void CheckEncryption_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler ); + SAL_DLLPRIVATE void SetModifyPasswordEntered( bool bEntered = true ); + SAL_DLLPRIVATE bool IsModifyPasswordEntered() const; + + SAL_DLLPRIVATE void InitBasicManager_Impl(); + SAL_DLLPRIVATE SfxObjectShell_Impl* Get_Impl() { return pImpl.get(); } + + SAL_DLLPRIVATE static bool UseInteractionToHandleError( + const css::uno::Reference< css::task::XInteractionHandler >& xHandler, + ErrCode nError ); + SAL_DLLPRIVATE const SfxObjectShell_Impl* Get_Impl() const { return pImpl.get(); } + + SAL_DLLPRIVATE void SetCreateMode_Impl( SfxObjectCreateMode nMode ); + + SAL_DLLPRIVATE void DoDraw_Impl( OutputDevice* pDev, + const Point & rViewPos, + const Fraction & rScaleX, + const Fraction & rScaleY, + const JobSetup & rSetup, + sal_uInt16 nAspect ); + + // Shell Interface + SAL_DLLPRIVATE void ExecFile_Impl(SfxRequest &); + SAL_DLLPRIVATE void GetState_Impl(SfxItemSet&); + SAL_DLLPRIVATE void PrintExec_Impl(SfxRequest &); + SAL_DLLPRIVATE void PrintState_Impl(SfxItemSet&); + SAL_DLLPRIVATE void ExecProps_Impl(SfxRequest &); + SAL_DLLPRIVATE void StateProps_Impl(SfxItemSet &); + SAL_DLLPRIVATE void ExecView_Impl(SfxRequest &); + SAL_DLLPRIVATE static void StateView_Impl(SfxItemSet &); + + // Load/Save public internals + SAL_DLLPRIVATE bool ImportFromGeneratedStream_Impl( + const css::uno::Reference< css::io::XStream >& xStream, + const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescr ); + SAL_DLLPRIVATE void UpdateFromTemplate_Impl(); + SAL_DLLPRIVATE bool CanReload_Impl(); + SAL_DLLPRIVATE void SetNamedVisibility_Impl(); + SAL_DLLPRIVATE bool DoSave_Impl( const SfxItemSet* pSet ); + SAL_DLLPRIVATE bool Save_Impl( const SfxItemSet* pSet ); + SAL_DLLPRIVATE bool + PreDoSaveAs_Impl(const OUString& rFileName, const OUString& rFiltName, + SfxItemSet const& rItemSet, + const css::uno::Sequence& rArgs); + SAL_DLLPRIVATE bool APISaveAs_Impl(std::u16string_view aFileName, SfxItemSet& rItemSet, + const css::uno::Sequence& rArgs); + SAL_DLLPRIVATE bool + CommonSaveAs_Impl(const INetURLObject& aURL, const OUString& aFilterName, SfxItemSet& rItemSet, + const css::uno::Sequence& rArgs); + SAL_DLLPRIVATE bool GeneralInit_Impl( + const css::uno::Reference< css::embed::XStorage >& xStorage, + bool bTypeMustBeSetAlready ); + SAL_DLLPRIVATE void PrepareSecondTryLoad_Impl(); + SAL_DLLPRIVATE void SetInitialized_Impl( const bool i_fromInitNew ); + + // public-internals + SAL_DLLPRIVATE IndexBitSet& GetNoSet_Impl(); + SAL_DLLPRIVATE void SetProgress_Impl( SfxProgress *pProgress ); + SAL_DLLPRIVATE void PostActivateEvent_Impl( SfxViewFrame const * ); + SAL_DLLPRIVATE void SetActivateEvent_Impl(SfxEventHintId ); + + // configuration items + SAL_DLLPRIVATE SignatureState ImplGetSignatureState( bool bScriptingContent = false ); + + SAL_DLLPRIVATE bool QuerySaveSizeExceededModules_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler ); + SAL_DLLPRIVATE static bool QueryAllowExoticFormat_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler, + const OUString& rURL, + const OUString& rFilterUIName); + + SAL_DLLPRIVATE void CheckOut( ); + SAL_DLLPRIVATE void CancelCheckOut( ); + SAL_DLLPRIVATE void CheckIn( ); + SAL_DLLPRIVATE css::uno::Sequence< css::document::CmisVersion > GetCmisVersions() const; + + /** override this if you have a XmlIdRegistry. */ + virtual const sfx2::IXmlIdRegistry* GetXmlIdRegistry() const { return nullptr; } + + /// Is this read-only object shell opened via .uno:SignPDF? + bool IsSignPDF() const; + + /// Gets the certificate that is already picked by the user but not yet used for signing. + css::uno::Reference GetSignPDFCertificate() const; + + /// Gets grab-bagged password info to unprotect change tracking with verification + css::uno::Sequence< css::beans::PropertyValue > GetDocumentProtectionFromGrabBag() const; + + // Lock all unlocked views, and returns a guard object which unlocks those views when destructed + virtual std::unique_ptr LockAllViews() + { + return std::make_unique(); + } + +}; + +#define SFX_GLOBAL_CLASSID \ + 0x9eaba5c3, 0xb232, 0x4309, \ + 0x84, 0x5f, 0x5f, 0x15, 0xea, 0x50, 0xd0, 0x74 + + struct ModifyBlocker_Impl + { + SfxObjectShell* pPersist; + bool bWasEnabled; + ModifyBlocker_Impl( SfxObjectShell* pPersistP ) : pPersist( pPersistP ) + { + bWasEnabled = pPersistP->IsEnableSetModified(); + if ( bWasEnabled ) + pPersistP->EnableSetModified( false ); + } + ~ModifyBlocker_Impl() + { + if ( bWasEnabled ) + pPersist->EnableSetModified( bWasEnabled ); + } + }; + + +typedef tools::SvRef SfxObjectShellRef; + +class SfxObjectShellLock +{ + SfxObjectShell * pObj; +public: + SfxObjectShellLock() { pObj = nullptr; } + inline SfxObjectShellLock( const SfxObjectShellLock & rObj ); + inline SfxObjectShellLock( SfxObjectShellLock && rObj ) noexcept; + inline SfxObjectShellLock( SfxObjectShell * pObjP ); + inline void Clear(); + inline ~SfxObjectShellLock(); + inline SfxObjectShellLock & operator = ( const SfxObjectShellLock & rObj ); + inline SfxObjectShellLock & operator = ( SfxObjectShellLock && rObj ); + inline SfxObjectShellLock & operator = ( SfxObjectShell * pObj ); + bool Is() const { return pObj != nullptr; } + SfxObjectShell * operator & () const { return pObj; } + SfxObjectShell * operator -> () const { return pObj; } + SfxObjectShell & operator * () const { return *pObj; } + operator SfxObjectShell * () const { return pObj; } +}; +inline SfxObjectShellLock::SfxObjectShellLock( const SfxObjectShellLock & rObj ) +{ + pObj = rObj.pObj; + if( pObj ) + pObj->OwnerLock( true ); +} +inline SfxObjectShellLock::SfxObjectShellLock( SfxObjectShellLock && rObj ) noexcept +{ + pObj = rObj.pObj; + rObj.pObj = nullptr; +} +inline SfxObjectShellLock::SfxObjectShellLock( SfxObjectShell * pObjP ) +{ + pObj = pObjP; + if( pObj ) + pObj->OwnerLock( true ); +} +inline void SfxObjectShellLock::Clear() +{ + if( pObj ) + { + SfxObjectShell* const pRefObj = pObj; + pObj = nullptr; + pRefObj->OwnerLock( false ); + } +} +inline SfxObjectShellLock::~SfxObjectShellLock() +{ + if( pObj ) + pObj->OwnerLock( false ); +} +inline SfxObjectShellLock & SfxObjectShellLock::operator=( const SfxObjectShellLock & rObj ) +{ + if( rObj.pObj ) + rObj.pObj->OwnerLock( true ); + SfxObjectShell* const pRefObj = pObj; + pObj = rObj.pObj; + if( pRefObj ) + pRefObj->OwnerLock( false ); + return *this; +} +inline SfxObjectShellLock & SfxObjectShellLock::operator=( SfxObjectShellLock && rObj ) +{ + if (pObj) + pObj->OwnerLock( false ); + pObj = rObj.pObj; + rObj.pObj = nullptr; + return *this; +} +inline SfxObjectShellLock & SfxObjectShellLock::operator=( SfxObjectShell * pObjP ) +{ + *this = SfxObjectShellLock( pObjP ); + return *this; +} + +class SFX2_DLLPUBLIC SfxObjectShellItem final : public SfxPoolItem +{ + SfxObjectShell* pObjSh; + +public: + static SfxPoolItem* CreateDefault(); + + SfxObjectShellItem() : + SfxPoolItem( 0 ), + pObjSh( nullptr ) + {} + SfxObjectShellItem( sal_uInt16 nWhichId, + SfxObjectShell *pObjShell ): + SfxPoolItem( nWhichId ), + pObjSh( pObjShell ) + {} + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual SfxObjectShellItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/opengrf.hxx b/include/sfx2/opengrf.hxx new file mode 100644 index 000000000..d28f88c4f --- /dev/null +++ b/include/sfx2/opengrf.hxx @@ -0,0 +1,72 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_OPENGRF_HXX +#define INCLUDED_SFX2_OPENGRF_HXX + +#include +#include +#include +#include + +namespace com::sun::star::ui::dialogs { class XFilePickerControlAccess; } +namespace com::sun::star::uno { template class Reference; } +namespace weld { class Window; } + +class Graphic; +struct SvxOpenGrf_Impl; + +class SFX2_DLLPUBLIC SvxOpenGraphicDialog +{ +public: + SvxOpenGraphicDialog(const OUString& rTitle, weld::Window* pPreferredParent); + SvxOpenGraphicDialog(const OUString& rTitle, weld::Window* pPreferredParent, + sal_Int16 nDialogType); + ~SvxOpenGraphicDialog(); + + ErrCode Execute(); + + void SetPath( const OUString& rPath, bool bLinkState ); + OUString GetPath() const; + + ErrCode GetGraphic(Graphic&) const; + + void EnableLink(bool); + void AsLink(bool); + bool IsAsLink() const; + + //what the dialog thought the format was + OUString GetCurrentFilter() const; + void SetCurrentFilter(const OUString&); + + //what was subsequently found to be the format + OUString const & GetDetectedFilter() const; + void SetDetectedFilter(const OUString&); + + css::uno::Reference const & GetFilePickerControlAccess() const; + +private: + SvxOpenGraphicDialog (const SvxOpenGraphicDialog&) = delete; + SvxOpenGraphicDialog& operator = ( const SvxOpenGraphicDialog & ) = delete; + + const std::unique_ptr< SvxOpenGrf_Impl > mpImpl; +}; + +#endif // _SVX_OPENGRF_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/pageids.hxx b/include/sfx2/pageids.hxx new file mode 100644 index 000000000..9371848b7 --- /dev/null +++ b/include/sfx2/pageids.hxx @@ -0,0 +1,71 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_PAGEIDS_HXX +#define INCLUDED_SFX2_PAGEIDS_HXX + +#include + +#define RID_OPTIONS_START (SID_LIB_START + 2000) +// RID_OPTIONS_END (RID_OPTIONS_START + 100) + +// ResId's ------------------------------------------------------------------ + +#define RID_SFXPAGE_SAVE (RID_OPTIONS_START + 0) +#define RID_SFXPAGE_GENERAL (RID_OPTIONS_START + 1) +#define RID_SFXPAGE_PATH (RID_OPTIONS_START + 6) +#define RID_SFXPAGE_LINGU (RID_OPTIONS_START + 7) + +#define RID_SFXPAGE_PRINTOPTIONS (RID_OPTIONS_START + 12) + +// treeopt +#define RID_SVXPAGE_COLOR (RID_SVX_START + 60) +#define OFA_TP_LANGUAGES_FOR_SET_DOCUMENT_LANGUAGE ( RID_OFA_START + 256 ) + +// options +#define RID_SVXPAGE_ONLINEUPDATE (RID_SVX_START + 298) +#define RID_SVXPAGE_INET_SECURITY (RID_SVX_START + 200) +#define RID_SVXPAGE_INET_PROXY (RID_SVX_START + 157) +#define RID_SVXPAGE_INET_MAIL (RID_SVX_START + 155) +#define RID_OFAPAGE_HTMLOPT (RID_OFA_START + 100) +#define OFA_TP_LANGUAGES (RID_OFA_START + 205) +#define OFA_TP_MISC (RID_OFA_START + 200) +#define OFA_TP_VIEW (RID_OFA_START + 202) +#define RID_OFAPAGE_MSFILTEROPT2 (RID_OFA_START + 121) +#define RID_SVXPAGE_OPTIONS_CTL (RID_SVX_START + 252) +#define RID_SVXPAGE_OPTIONS_JAVA (RID_SVX_START + 253) +#define RID_SVXPAGE_ACCESSIBILITYCONFIG (RID_SVX_START + 250) +#define RID_SVXPAGE_ASIAN_LAYOUT (RID_SVX_START + 246) +#define RID_OPTPAGE_CHART_DEFCOLORS (RID_SVX_START + 299) +#define RID_SVXPAGE_PERSONALIZATION (RID_SVX_START + 247) +#define RID_SVXPAGE_COLORCONFIG (RID_SVX_START + 249) +#define RID_SVXPAGE_BASICIDE_OPTIONS (RID_SVX_START + 209) +#define RID_SVXPAGE_LANGTOOL_OPTIONS (RID_SVX_START + 210) + +// Resource-Id's ------------------------------------------------------------ + +// options +#define RID_SVXPAGE_JSEARCH_OPTIONS (RID_SVX_START + 840) +#define RID_SVX_FONT_SUBSTITUTION (RID_SVX_START + 18) + +#define RID_SVXPAGE_OPENCL (RID_SVX_START + 254) + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/passwd.hxx b/include/sfx2/passwd.hxx new file mode 100644 index 000000000..3302c370b --- /dev/null +++ b/include/sfx2/passwd.hxx @@ -0,0 +1,130 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_PASSWD_HXX +#define INCLUDED_SFX2_PASSWD_HXX + +#include +#include +#include +#include + +// defines --------------------------------------------------------------- + +enum class SfxShowExtras +{ + NONE = 0x0000, + USER = 0x0001, + CONFIRM = 0x0002, + PASSWORD2 = 0x0004, + CONFIRM2 = 0x0008, + ALL = USER | CONFIRM +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +// class SfxPasswordDialog ----------------------------------------------- + +class SFX2_DLLPUBLIC SfxPasswordDialog final : public weld::GenericDialogController +{ +private: + std::unique_ptr m_xPassword1Box; + std::unique_ptr m_xUserFT; + std::unique_ptr m_xUserED; + std::unique_ptr m_xPassword1FT; + std::unique_ptr m_xPassword1ED; + std::unique_ptr m_xConfirm1FT; + std::unique_ptr m_xConfirm1ED; + + std::unique_ptr m_xPassword2Box; + std::unique_ptr m_xPassword2FT; + std::unique_ptr m_xPassword2ED; + std::unique_ptr m_xConfirm2FT; + std::unique_ptr m_xConfirm2ED; + + std::unique_ptr m_xMinLengthFT; + std::unique_ptr m_xOnlyAsciiFT; + + std::unique_ptr m_xOKBtn; + + OUString maMinLenPwdStr; + OUString maMinLenPwdStr1; + OUString maEmptyPwdStr; + OUString maMainPwdStr; + sal_uInt16 mnMinLen; + SfxShowExtras mnExtras; + + bool mbAsciiOnly; + DECL_DLLPRIVATE_LINK(OKHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(InsertTextHdl, OUString&, bool); + DECL_DLLPRIVATE_LINK(EditModifyHdl, weld::Entry&, void); + void ModifyHdl(); + + void SetPasswdText(); + +public: + SfxPasswordDialog(weld::Widget* pParent, const OUString* pGroupText = nullptr); + + OUString GetUser() const + { + return m_xUserED->get_text(); + } + OUString GetPassword() const + { + return m_xPassword1ED->get_text(); + } + OUString GetConfirm() const + { + return m_xConfirm1ED->get_text(); + } + OUString GetPassword2() const + { + return m_xPassword2ED->get_text(); + } + void SetGroup2Text(const OUString& i_rText) + { + m_xPassword2Box->set_label(i_rText); + } + void SetMinLen(sal_uInt16 Len); + void SetEditHelpId(const OString& rId) + { + m_xPassword1ED->set_help_id(rId); + } + /* tdf#60874 we need a custom help ID for the Confirm + field of the Protect Document window */ + void SetConfirmHelpId(const OString& rId) + { + m_xConfirm1ED->set_help_id(rId); + } + + void ShowExtras(SfxShowExtras nExtras) + { + mnExtras = nExtras; + } + + void AllowAsciiOnly(); + void ShowMinLengthText(bool bShow); + + virtual short run() override; +}; + +#endif // INCLUDED_SFX2_PASSWD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/printer.hxx b/include/sfx2/printer.hxx new file mode 100644 index 000000000..8d10b2cc7 --- /dev/null +++ b/include/sfx2/printer.hxx @@ -0,0 +1,62 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_PRINTER_HXX +#define INCLUDED_SFX2_PRINTER_HXX + +#include +#include +#include +#include + +class SfxItemSet; + +// class SfxPrinter ------------------------------------------------------ + +class SFX2_DLLPUBLIC SfxPrinter final : public Printer +{ +private: + std::unique_ptr pOptions; + bool bKnown; + + SfxPrinter& operator =(SfxPrinter const &) = delete; + +public: + SfxPrinter( std::unique_ptr &&pTheOptions ); + SfxPrinter( std::unique_ptr &&pTheOptions, + const OUString &rPrinterName ); + SfxPrinter( std::unique_ptr &&pTheOptions, + const JobSetup &rTheOrigJobSetup ); + SfxPrinter( const SfxPrinter &rPrinter ); + virtual ~SfxPrinter() override; + virtual void dispose() override; + + VclPtr Clone() const; + + static VclPtr Create( SvStream &rStream, std::unique_ptr &&pOptions ); + void Store( SvStream &rStream ) const; + + const SfxItemSet& GetOptions() const { return *pOptions; } + void SetOptions( const SfxItemSet &rNewOptions ); + + bool IsKnown() const { return bKnown; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/printopt.hxx b/include/sfx2/printopt.hxx new file mode 100644 index 000000000..ef7fd4683 --- /dev/null +++ b/include/sfx2/printopt.hxx @@ -0,0 +1,86 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_PRINTOPT_HXX +#define INCLUDED_SFX2_PRINTOPT_HXX + +#include +#include +#include +#include +#include + +class SFX2_DLLPUBLIC SfxCommonPrintOptionsTabPage final : public SfxTabPage +{ +private: + + std::unique_ptr m_xPrinterOutputRB; + std::unique_ptr m_xPrintFileOutputRB; + std::unique_ptr m_xReduceTransparencyCB; + std::unique_ptr m_xReduceTransparencyAutoRB; + std::unique_ptr m_xReduceTransparencyNoneRB; + std::unique_ptr m_xReduceGradientsCB; + std::unique_ptr m_xReduceGradientsStripesRB; + std::unique_ptr m_xReduceGradientsColorRB; + std::unique_ptr m_xReduceGradientsStepCountNF; + std::unique_ptr m_xReduceBitmapsCB; + std::unique_ptr m_xReduceBitmapsOptimalRB; + std::unique_ptr m_xReduceBitmapsNormalRB; + std::unique_ptr m_xReduceBitmapsResolutionRB; + std::unique_ptr m_xReduceBitmapsResolutionLB; + std::unique_ptr m_xReduceBitmapsTransparencyCB; + std::unique_ptr m_xConvertToGreyscalesCB; + std::unique_ptr m_xPDFCB; + std::unique_ptr m_xPaperSizeCB; + std::unique_ptr m_xPaperOrientationCB; + std::unique_ptr m_xTransparencyCB; + +private: + + vcl::printer::Options maPrinterOptions; + vcl::printer::Options maPrintFileOptions; + + DECL_DLLPRIVATE_LINK( ToggleOutputPrinterRBHdl, weld::Toggleable&, void ); + DECL_DLLPRIVATE_LINK( ToggleOutputPrintFileRBHdl, weld::Toggleable&, void); + + DECL_DLLPRIVATE_LINK( ClickReduceTransparencyCBHdl, weld::Toggleable&, void ); + DECL_DLLPRIVATE_LINK( ClickReduceGradientsCBHdl, weld::Toggleable&, void ); + DECL_DLLPRIVATE_LINK( ClickReduceBitmapsCBHdl, weld::Toggleable&, void ); + + DECL_DLLPRIVATE_LINK( ToggleReduceGradientsStripesRBHdl, weld::Toggleable&, void ); + DECL_DLLPRIVATE_LINK( ToggleReduceBitmapsResolutionRBHdl, weld::Toggleable&, void ); + + SAL_DLLPRIVATE void ImplUpdateControls( const vcl::printer::Options* pCurrentOptions ); + SAL_DLLPRIVATE void ImplSaveControls( vcl::printer::Options* pCurrentOptions ); + + virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; + +public: + + SfxCommonPrintOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); + virtual ~SfxCommonPrintOptionsTabPage() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; + virtual void Reset( const SfxItemSet* rSet ) override; + + static std::unique_ptr Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet*); +}; + +#endif // INCLUDED_SFX2_PRINTOPT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/progress.hxx b/include/sfx2/progress.hxx new file mode 100644 index 000000000..ceee49b6c --- /dev/null +++ b/include/sfx2/progress.hxx @@ -0,0 +1,63 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_PROGRESS_HXX +#define INCLUDED_SFX2_PROGRESS_HXX + +#include +#include +#include +#include +#include + + +class SfxObjectShell; +struct SfxProgress_Impl; + +class SFX2_DLLPUBLIC SfxProgress +{ + std::unique_ptr< SfxProgress_Impl > pImpl; + sal_uInt32 nVal; + bool bSuspended; + +public: + SfxProgress( SfxObjectShell* pObjSh, + const OUString& rText, + sal_uInt32 nRange, + bool bWait = true); + virtual ~SfxProgress(); + + void SetState( sal_uInt32 nVal, sal_uInt32 nNewRange = 0 ); + sal_uInt32 GetState() const { return nVal; } + + void Resume(); + void Suspend(); + bool IsSuspended() const { return bSuspended; } + + static void Reschedule(); + + void Stop(); + + static SfxProgress* GetActiveProgress( SfxObjectShell const *pDocSh = nullptr ); + static void EnterLock(); + static void LeaveLock(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/request.hxx b/include/sfx2/request.hxx new file mode 100644 index 000000000..5a97cb9e6 --- /dev/null +++ b/include/sfx2/request.hxx @@ -0,0 +1,129 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_REQUEST_HXX +#define INCLUDED_SFX2_REQUEST_HXX + +#include +#include +#include +#include +#include + +#include + +class SfxPoolItem; +class SfxItemPool; +class SfxShell; +class SfxSlot; +class SfxViewFrame; +struct SfxRequest_Impl; +enum class SfxCallMode : sal_uInt16; + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::frame { class XDispatchRecorder; } +namespace com::sun::star::uno { template class Sequence; } +namespace weld { class Window; } + +class SFX2_DLLPUBLIC SfxRequest final : public SfxHint +{ +friend struct SfxRequest_Impl; + + sal_uInt16 nSlot; + std::unique_ptr pArgs; + std::unique_ptr< SfxRequest_Impl > pImpl; + +public: + SAL_DLLPRIVATE void Record_Impl( SfxShell &rSh, const SfxSlot &rSlot, + const css::uno::Reference< css::frame::XDispatchRecorder >& xRecorder, + SfxViewFrame* ); +private: + SAL_DLLPRIVATE void Done_Impl( const SfxItemSet *pSet ); + +public: + SfxRequest( SfxViewFrame*, sal_uInt16 nSlotId ); + SfxRequest( sal_uInt16 nSlot, SfxCallMode nCallMode, SfxItemPool &rPool ); + SfxRequest( const SfxSlot* pSlot, const css::uno::Sequence < css::beans::PropertyValue >& rArgs, + SfxCallMode nCallMode, SfxItemPool &rPool ); + SfxRequest(sal_uInt16 nSlot, SfxCallMode nCallMode, const SfxAllItemSet& rSfxArgs); + SfxRequest( sal_uInt16 nSlot, SfxCallMode nCallMode, const SfxAllItemSet& rSfxArgs, const SfxAllItemSet& rSfxInternalArgs ); + SfxRequest( const SfxRequest& rOrig ); + virtual ~SfxRequest() override; + + sal_uInt16 GetSlot() const { return nSlot; } + void SetSlot(sal_uInt16 nNewSlot) { nSlot = nNewSlot; } + + sal_uInt16 GetModifier() const; + void SetModifier( sal_uInt16 nModi ); + void SetInternalArgs_Impl( const SfxAllItemSet& rArgs ); + SAL_DLLPRIVATE const SfxItemSet* GetInternalArgs_Impl() const; + const SfxItemSet* GetArgs() const { return pArgs.get(); } + void SetArgs( const SfxAllItemSet& rArgs ); + void AppendItem(const SfxPoolItem &); + void RemoveItem( sal_uInt16 nSlotId ); + + /** Templatized access to the individual parameters of the SfxRequest. + + Use like: const SfxInt32Item *pPosItem = rReq.GetArg(SID_POS); + */ + template const T* GetArg(sal_uInt16 nSlotId) const + { + if (!pArgs) + return nullptr; + return pArgs->GetItem(nSlotId, false); + } + template const T* GetArg(TypedWhichId nSlotId) const + { + if (!pArgs) + return nullptr; + return pArgs->GetItem(nSlotId, false); + } + + void ReleaseArgs(); + void SetReturnValue(const SfxPoolItem &); + const SfxPoolItem* GetReturnValue() const; + + static css::uno::Reference< css::frame::XDispatchRecorder > GetMacroRecorder( SfxViewFrame const * pFrame ); + static bool HasMacroRecorder( SfxViewFrame const * pFrame ); + SfxCallMode GetCallMode() const; + void AllowRecording( bool ); + bool AllowsRecording() const; + bool IsAPI() const; + bool IsSynchronCall() const; + void SetSynchronCall( bool bSynchron ); + + bool IsDone() const; + void Done( bool bRemove = false ); + + void Ignore(); + void Cancel(); + bool IsCancelled() const; + void Done(const SfxItemSet &); + + void ForgetAllArgs(); + + /** Return the window that should be used as the parent for any dialogs this request creates + */ + weld::Window* GetFrameWeld() const; +private: + const SfxRequest& operator=(const SfxRequest &) = delete; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/safemode.hxx b/include/sfx2/safemode.hxx new file mode 100644 index 000000000..34602c4ea --- /dev/null +++ b/include/sfx2/safemode.hxx @@ -0,0 +1,73 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_SAFEMODE_HXX +#define INCLUDED_SFX2_SAFEMODE_HXX + +#include + +#include + +namespace sfx2 +{ +class SFX2_DLLPUBLIC SafeMode +{ +public: + /** + * Write a flag file to the user profile indicating that the next launch should be in safe mode. + * + * @return Whether the file could be written successfully + */ + static bool putFlag(); + + /** + * Check the existence of the safe mode flag file. + * + * @return Whether the flag file for the safe mode exists + */ + static bool hasFlag(); + + /** + * Remove the flag file for the safe mode. + * + * @return Whether the flag file could be removed successfully + */ + static bool removeFlag(); + + /** + * Write a flag to the user profile indicating that we are currently restarting from safe mode - + * that means we don't want to enter safe mode again. + * + * @return Whether the file could be written successfully + */ + static bool putRestartFlag(); + + /** + * Check the existence of the restart flag file. + * + * @return Whether the restart flag file exists + */ + static bool hasRestartFlag(); + + /** + * Remove the restart flag file. + * + * @return Whether the flag file could be removed successfully + */ + static bool removeRestartFlag(); + +private: + /** Returns the path of the safe mode flag file.*/ + static OUString getFilePath(const OUString& sFilename); +}; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxbasecontroller.hxx b/include/sfx2/sfxbasecontroller.hxx new file mode 100644 index 000000000..ac4950e5a --- /dev/null +++ b/include/sfx2/sfxbasecontroller.hxx @@ -0,0 +1,218 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_SFXBASECONTROLLER_HXX +#define INCLUDED_SFX2_SFXBASECONTROLLER_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace com::sun::star::awt { class XKeyHandler; } +namespace com::sun::star::awt { class XMouseClickHandler; } +namespace com::sun::star::frame { class XDispatch; } +namespace com::sun::star::frame { class XFrame; } +namespace com::sun::star::frame { class XModel; } +namespace com::sun::star::frame { struct DispatchDescriptor; } +namespace com::sun::star::ui { class XContextMenuInterceptor; } +namespace com::sun::star::ui { class XSidebarProvider; } +namespace com::sun::star::util { struct URL; } +namespace weld { class Button; } + +struct IMPL_SfxBaseController_DataContainer ; // impl. struct to hold member of class SfxBaseController + +class NotifyEvent; +class SfxViewFrame; +class SfxViewShell; + +sal_Int16 MapGroupIDToCommandGroup( SfxGroupId nGroupID ); + + + + +typedef ::cppu::WeakImplHelper < css::frame::XController2 + , css::frame::XControllerBorder + , css::frame::XDispatchProvider + , css::task::XStatusIndicatorSupplier + , css::ui::XContextMenuInterception + , css::awt::XUserInputInterception + , css::frame::XDispatchInformationProvider + , css::frame::XInfobarProvider + , css::frame::XTitle + , css::frame::XTitleChangeBroadcaster + , css::lang::XInitialization + > SfxBaseController_Base; + +class SFX2_DLLPUBLIC SfxBaseController :public SfxBaseController_Base + ,public ::cppu::BaseMutex +{ + +// public methods + + +public: + + + // constructor/destructor + + + SfxBaseController( SfxViewShell* pView ) ; + + virtual ~SfxBaseController() override ; + + SAL_DLLPRIVATE void ReleaseShell_Impl(); + SAL_DLLPRIVATE void BorderWidthsChanged_Impl(); + + css::uno::Reference< css::task::XStatusIndicator > SAL_CALL getStatusIndicator( ) override; + + + // XController2 + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL getComponentWindow() override; + virtual OUString SAL_CALL getViewControllerName() override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCreationArguments() override; + + virtual css::uno::Reference< css::ui::XSidebarProvider > SAL_CALL getSidebar() override; + + + // XController + + + virtual void SAL_CALL attachFrame( const css::uno::Reference< css::frame::XFrame >& xFrame ) override ; + + virtual sal_Bool SAL_CALL attachModel( const css::uno::Reference< css::frame::XModel >& xModel ) override ; + + virtual sal_Bool SAL_CALL suspend( sal_Bool bSuspend ) override ; + + css::uno::Any SAL_CALL getViewData() override ; + + void SAL_CALL restoreViewData( const css::uno::Any& aValue ) override ; + + css::uno::Reference< css::frame::XFrame > SAL_CALL getFrame() override ; + + css::uno::Reference< css::frame::XModel > SAL_CALL getModel() override ; + + + // XDispatchProvider + + + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL & aURL , + const OUString & sTargetFrameName, + sal_Int32 eSearchFlags ) override ; + + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& seqDescriptor ) override ; + + + // XControllerBorder + + + virtual css::frame::BorderWidths SAL_CALL getBorder() override; + virtual void SAL_CALL addBorderResizeListener( const css::uno::Reference< css::frame::XBorderResizeListener >& xListener ) override; + virtual void SAL_CALL removeBorderResizeListener( const css::uno::Reference< css::frame::XBorderResizeListener >& xListener ) override; + virtual css::awt::Rectangle SAL_CALL queryBorderedArea( const css::awt::Rectangle& aPreliminaryRectangle ) override; + + + // XComponent + + + virtual void SAL_CALL dispose() override ; + + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override ; + + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override ; + virtual void SAL_CALL registerContextMenuInterceptor( const css::uno::Reference< css::ui::XContextMenuInterceptor >& xInterceptor ) override; + virtual void SAL_CALL releaseContextMenuInterceptor( const css::uno::Reference< css::ui::XContextMenuInterceptor >& xInterceptor ) override; + + virtual void SAL_CALL addKeyHandler( const css::uno::Reference< css::awt::XKeyHandler >& xHandler ) override; + virtual void SAL_CALL removeKeyHandler( const css::uno::Reference< css::awt::XKeyHandler >& xHandler ) override; + virtual void SAL_CALL addMouseClickHandler( const css::uno::Reference< css::awt::XMouseClickHandler >& xHandler ) override; + virtual void SAL_CALL removeMouseClickHandler( const css::uno::Reference< css::awt::XMouseClickHandler >& xHandler ) override; + + + // XDispatchInformationProvider + virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedCommandGroups() override; + virtual css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation( sal_Int16 nCommandGroup ) override; + + // css::frame::XTitle + virtual OUString SAL_CALL getTitle( ) override; + virtual void SAL_CALL setTitle( const OUString& sTitle ) override; + + // css::frame::XTitleChangeBroadcaster + virtual void SAL_CALL addTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener ) override; + virtual void SAL_CALL removeTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener ) override; + + // css::lang::XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XInfobarProvider + virtual void SAL_CALL + appendInfobar(const OUString& sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, sal_Int32 aInfobarType, + const css::uno::Sequence& actionButtons, + sal_Bool bShowCloseButton) override; + virtual void SAL_CALL updateInfobar(const OUString& sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, + sal_Int32 aInfobarType) override; + virtual void SAL_CALL removeInfobar(const OUString& sId) override; + virtual sal_Bool SAL_CALL hasInfobar(const OUString& sId) override; + + // FIXME: TL needs this in sw/source/ui/uno/unotxdoc.cxx now; + // either the _Impl name should vanish or there should be an "official" API + SfxViewShell* GetViewShell_Impl() const; + SAL_DLLPRIVATE bool HandleEvent_Impl( NotifyEvent const & rEvent ); + SAL_DLLPRIVATE bool HasKeyListeners_Impl() const; + SAL_DLLPRIVATE bool HasMouseClickListeners_Impl() const; + SAL_DLLPRIVATE void SetCreationArguments_Impl( const css::uno::Sequence< css::beans::PropertyValue >& i_rCreationArgs ); + SAL_DLLPRIVATE css::uno::Reference< css::frame::XTitle > impl_getTitleHelper (); +private: + enum ConnectSfxFrame + { + E_CONNECT, + E_DISCONNECT, + E_RECONNECT + }; + SAL_DLLPRIVATE void ConnectSfxFrame_Impl( const ConnectSfxFrame i_eConnect ); + SAL_DLLPRIVATE SfxViewFrame& GetViewFrame_Impl() const; + SAL_DLLPRIVATE void ShowInfoBars( ); + + DECL_DLLPRIVATE_LINK( CheckOutHandler, weld::Button&, void ); + + std::unique_ptr m_pData ; + +} ; // class SfxBaseController + +#endif // _SFX_SFXBASECONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxbasemodel.hxx b/include/sfx2/sfxbasemodel.hxx new file mode 100644 index 000000000..8ccd59292 --- /dev/null +++ b/include/sfx2/sfxbasemodel.hxx @@ -0,0 +1,753 @@ +/* -*- 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +class ErrCode; +class SfxMedium; +class SfxObjectShell ; +class SfxViewFrame; +struct IMPL_SfxBaseModel_DataContainer ; // impl. struct to hold member of class SfxBaseModel + +namespace sfx::intern { + class ViewCreationGuard; +} + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::container { class XNameContainer; } +namespace com::sun::star::container { class XNameReplace; } +namespace com::sun::star::document { class XEventListener; } +namespace com::sun::star::document { struct CmisProperty; } +namespace com::sun::star::document { struct CmisVersion; } +namespace com::sun::star::document { struct EventObject; } +namespace com::sun::star::frame { class XController2; } +namespace com::sun::star::task { class XInteractionHandler; } +namespace com::sun::star::ui { class XUIConfigurationManager2; } +namespace com::sun::star::util { class XCloseListener; } +namespace com::sun::star::util { class XModifyListener; } + + + +/**_______________________________________________________________________________________________________ + @implements XChild + XComponent + document::XDocumentPropertiesSupplier + rdf::XDocumentMetadataAccess + XEventListener + XModel + XModifiable2 + XPrintable + XStorable2 + document::XEventBroadcaster + document::XEventsSupplier + document::XEmbeddedScripts + document::XScriptInvocationContext + XCloseable + XCloseBroadcaster + + @base cppu::BaseMutex + SfxListener +*/ + +typedef ::cppu::WeakImplHelper < css::container::XChild + , css::document::XDocumentPropertiesSupplier + , css::document::XCmisDocument + , css::rdf::XDocumentMetadataAccess + , css::document::XDocumentRecovery + , css::document::XUndoManagerSupplier + , css::document::XShapeEventBroadcaster + , css::document::XDocumentEventBroadcaster + , css::lang::XEventListener + , css::document::XEventsSupplier + , css::document::XEmbeddedScripts + , css::document::XScriptInvocationContext + , css::frame::XModel3 + , css::util::XModifiable2 + , css::view::XPrintable + , css::view::XPrintJobBroadcaster + , css::frame::XStorable2 + , css::frame::XLoadable + , css::script::XStarBasicAccess + , css::document::XViewDataSupplier + , css::util::XCloseable // => css::util::XCloseBroadcaster + , css::datatransfer::XTransferable + , css::document::XDocumentSubStorageSupplier + , css::document::XStorageBasedDocument + , css::script::provider::XScriptProviderSupplier + , css::ui::XUIConfigurationManagerSupplier + , css::embed::XVisualObject + , css::lang::XUnoTunnel + , css::frame::XModule + , css::frame::XTitle + , css::frame::XTitleChangeBroadcaster + , css::frame::XUntitledNumbers + > SfxBaseModel_Base; + +class SFX2_DLLPUBLIC SfxBaseModel : protected ::cppu::BaseMutex + , public SfxBaseModel_Base + , public SfxListener +{ + + +// public methods + + +public: + + + // constructor/destructor + + + SfxBaseModel( SfxObjectShell *pObjectShell ) ; + + virtual ~SfxBaseModel() override ; + + + // XInterface + + + /**___________________________________________________________________________________________________ + @short give answer, if interface is supported + @descr The interfaces are searched by type. + + @seealso XInterface + + @param "rType" is the type of searched interface. + + @return Any information about found interface + + @onerror A RuntimeException is thrown. + */ + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& rType ) override ; + + /**___________________________________________________________________________________________________ + @short increment refcount + @seealso XInterface + @seealso release() + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL acquire() noexcept override + { OWeakObject::acquire(); } + + /**___________________________________________________________________________________________________ + @short decrement refcount + @seealso XInterface + @seealso acquire() + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL release() noexcept override + { OWeakObject::release(); } + + + // XTypeProvider + + + /**___________________________________________________________________________________________________ + @short get information about supported interfaces + @seealso XTypeProvider + @return Sequence of types of all supported interfaces + + @onerror A RuntimeException is thrown. + */ + + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override ; + + /**___________________________________________________________________________________________________ + @short get implementation id + @descr This ID is necessary for UNO-caching. If there no ID, cache is disabled. + Another way, cache is enabled. + + @seealso XTypeProvider + @return ID as Sequence of byte + + @onerror A RuntimeException is thrown. + */ + + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override ; + + + // XStarBasicAccess + + + /**___________________________________________________________________________________________________ + @seealso XStarBasicAccess + */ + virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getLibraryContainer() override; + + /**___________________________________________________________________________________________________ + @seealso XStarBasicAccess + */ + virtual void SAL_CALL createLibrary( const OUString& LibName, const OUString& Password, + const OUString& ExternalSourceURL, const OUString& LinkTargetURL ) override; + + /**___________________________________________________________________________________________________ + @seealso XStarBasicAccess + */ + virtual void SAL_CALL addModule( const OUString& LibraryName, const OUString& ModuleName, + const OUString& Language, const OUString& Source ) override; + + /**___________________________________________________________________________________________________ + @seealso XStarBasicAccess + */ + virtual void SAL_CALL addDialog( const OUString& LibraryName, const OUString& DialogName, + const css::uno::Sequence< sal_Int8 >& Data ) override; + + + // XChild + + + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override ; + + virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& xParent ) override; + + + // XComponent + + + virtual void SAL_CALL dispose() override; + + virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener >& aListener) override; + + virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + + // XDocumentPropertiesSupplier + virtual css::uno::Reference< css::document::XDocumentProperties > + SAL_CALL getDocumentProperties() override; + + + // XEventListener + + + virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override; + + + // XModel + + + virtual sal_Bool SAL_CALL attachResource(const OUString& sURL, + const css::uno::Sequence< css::beans::PropertyValue >& aArgs) override; + + virtual OUString SAL_CALL getURL() override; + + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getArgs() override; + + virtual void SAL_CALL connectController( const css::uno::Reference< css::frame::XController >& xController ) override; + + virtual void SAL_CALL disconnectController( const css::uno::Reference< css::frame::XController >& xController ) override; + + virtual void SAL_CALL lockControllers() override; + + virtual void SAL_CALL unlockControllers() override; + + virtual sal_Bool SAL_CALL hasControllersLocked() override; + + virtual css::uno::Reference< css::frame::XController > SAL_CALL getCurrentController() override; + + virtual void SAL_CALL setCurrentController( const css::uno::Reference< css::frame::XController >& xController ) override; + + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getCurrentSelection() override; + + + // XModel2 + + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL getControllers() override; + + virtual css::uno::Sequence< OUString > SAL_CALL getAvailableViewControllerNames() override; + + virtual css::uno::Reference< css::frame::XController2 > SAL_CALL createDefaultViewController(const css::uno::Reference< css::frame::XFrame >& Frame ) override; + + virtual css::uno::Reference< css::frame::XController2 > SAL_CALL createViewController(const OUString& ViewName , + const css::uno::Sequence< css::beans::PropertyValue >& Arguments , + const css::uno::Reference< css::frame::XFrame >& Frame ) override; + + virtual void SAL_CALL setArgs(const css::uno::Sequence& aArgs) override; + + + // XModel3 + + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getArgs2( const css::uno::Sequence< OUString > & requestedArgs ) override; + + // XModifiable2 + + + virtual sal_Bool SAL_CALL disableSetModified( ) override; + virtual sal_Bool SAL_CALL enableSetModified( ) override; + virtual sal_Bool SAL_CALL isSetModifiedEnabled( ) override; + + virtual sal_Bool SAL_CALL isModified() override; + + virtual void SAL_CALL setModified( sal_Bool bModified ) override; + + virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& xListener ) override ; + + virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > & xListener) override ; + + + // XCloseable + + + virtual void SAL_CALL close( sal_Bool bDeliverOwnership ) override; + + + // XCloseBroadcaster + + + virtual void SAL_CALL addCloseListener( const css::uno::Reference< css::util::XCloseListener >& xListener ) override; + virtual void SAL_CALL removeCloseListener( const css::uno::Reference< css::util::XCloseListener >& xListener ) override; + + + // XPrintJobBroadcaster + + + virtual void SAL_CALL addPrintJobListener( const css::uno::Reference< css::view::XPrintJobListener >& xListener ) override; + virtual void SAL_CALL removePrintJobListener( const css::uno::Reference< css::view::XPrintJobListener >& xListener ) override; + + + // XPrintable + + + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPrinter() override; + + virtual void SAL_CALL setPrinter( const css::uno::Sequence< css::beans::PropertyValue >& seqPrinter ) override; + virtual void SAL_CALL print( const css::uno::Sequence< css::beans::PropertyValue >& seqOptions ) override; + + + // XStorable2 + + + virtual void SAL_CALL storeSelf( const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override; + + + // XStorable + + + virtual sal_Bool SAL_CALL hasLocation() override; + + virtual OUString SAL_CALL getLocation() override; + + virtual sal_Bool SAL_CALL isReadonly() override; + + virtual void SAL_CALL store() override; + + virtual void SAL_CALL storeAsURL( const OUString& sURL, + const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override ; + + virtual void SAL_CALL storeToURL( const OUString& sURL, + const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override; + + SAL_DLLPRIVATE void + impl_store(const OUString& sURL, + const css::uno::Sequence& seqArguments, bool bSaveTo); + + // XLoadable + + + virtual void SAL_CALL initNew() override; + + virtual void SAL_CALL load( const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override; + + + // XDocumentSubStorageSupplier + + + virtual css::uno::Reference< css::embed::XStorage > SAL_CALL getDocumentSubStorage( const OUString& aStorageName, sal_Int32 nMode ) override; + + virtual css::uno::Sequence< OUString > SAL_CALL getDocumentSubStoragesNames() override; + + + // XStorageBasedDocument + + + virtual void SAL_CALL loadFromStorage( const css::uno::Reference< css::embed::XStorage >& xStorage, + const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescriptor ) override; + + virtual void SAL_CALL storeToStorage( const css::uno::Reference< css::embed::XStorage >& xStorage, + const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescriptor ) override; + + virtual void SAL_CALL switchToStorage( const css::uno::Reference< css::embed::XStorage >& xStorage ) override; + + virtual css::uno::Reference< css::embed::XStorage > SAL_CALL getDocumentStorage() override; + + virtual void SAL_CALL addStorageChangeListener( + const css::uno::Reference< css::document::XStorageChangeListener >& xListener ) override; + + virtual void SAL_CALL removeStorageChangeListener( + const css::uno::Reference< css::document::XStorageChangeListener >& xListener ) override; + + + // XVisualObject + + + virtual void SAL_CALL setVisualAreaSize( sal_Int64 nAspect, const css::awt::Size& aSize ) override; + + virtual css::awt::Size SAL_CALL getVisualAreaSize( sal_Int64 nAspect ) override; + + virtual css::embed::VisualRepresentation SAL_CALL getPreferredVisualRepresentation( ::sal_Int64 nAspect ) override; + + virtual sal_Int32 SAL_CALL getMapUnit( sal_Int64 nAspect ) override; + + + // XScriptProviderSupplier + + + virtual css::uno::Reference< css::script::provider::XScriptProvider > SAL_CALL getScriptProvider() override; + + + // XUIConfigurationManagerSupplier + virtual css::uno::Reference< css::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager() override; + + + // XTransferable + + + virtual css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) override; + + virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors() override; + + virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) override; + + + // XEventsSupplier + + + /**___________________________________________________________________________________________________ + @descr - offers a list of event handlers which are be bound to events of + this object. + @return - an Events object. + */ + + virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents() override; + + + // XEmbeddedScripts + + + virtual css::uno::Reference< css::script::XStorageBasedLibraryContainer > SAL_CALL getBasicLibraries() override; + virtual css::uno::Reference< css::script::XStorageBasedLibraryContainer > SAL_CALL getDialogLibraries() override; + virtual sal_Bool SAL_CALL getAllowMacroExecution() override; + + + // XScriptInvocationContext + + + virtual css::uno::Reference< css::document::XEmbeddedScripts > SAL_CALL getScriptContainer() override; + + + // document::XEventBroadcaster + + /**___________________________________________________________________________________________________ + @descr - registers the given XEventListener. + */ + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::document::XEventListener >& xListener ) override; + + /**___________________________________________________________________________________________________ + @descr - unregisters the given XEventListener. + */ + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::document::XEventListener >& xListener ) override; + + + // document::XShapeEventBroadcaster + + /**___________________________________________________________________________________________________ + @descr - registers the given XEventListener. + */ + virtual void SAL_CALL addShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape, const css::uno::Reference< css::document::XShapeEventListener >& xListener ) override; + + /**___________________________________________________________________________________________________ + @descr - unregisters the given XEventListener. + */ + virtual void SAL_CALL removeShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape, const css::uno::Reference< css::document::XShapeEventListener >& xListener ) override; + + + // XDocumentEventBroadcaster + + virtual void SAL_CALL addDocumentEventListener( const css::uno::Reference< css::document::XDocumentEventListener >& Listener ) override; + virtual void SAL_CALL removeDocumentEventListener( const css::uno::Reference< css::document::XDocumentEventListener >& Listener ) override; + virtual void SAL_CALL notifyDocumentEvent( const OUString& EventName, const css::uno::Reference< css::frame::XController2 >& ViewController, const css::uno::Any& Supplement ) override; + + + // XUnoTunnel + + + virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; + + // css.frame.XModule + virtual void SAL_CALL setIdentifier(const OUString& sIdentifier) override; + + // css.frame.XModule + virtual OUString SAL_CALL getIdentifier() override; + + // css.frame.XTitle + virtual OUString SAL_CALL getTitle() override; + + // css.frame.XTitle + virtual void SAL_CALL setTitle( const OUString& sTitle ) override; + + // css.frame.XTitleChangeBroadcaster + virtual void SAL_CALL addTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener ) override; + + // css.frame.XTitleChangeBroadcaster + virtual void SAL_CALL removeTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener ) override; + + // css.frame.XUntitledNumbers + virtual ::sal_Int32 SAL_CALL leaseNumber( const css::uno::Reference< css::uno::XInterface >& xComponent ) override; + + // css.frame.XUntitledNumbers + virtual void SAL_CALL releaseNumber( ::sal_Int32 nNumber ) override; + + // css.frame.XUntitledNumbers + virtual void SAL_CALL releaseNumberForComponent( const css::uno::Reference< css::uno::XInterface >& xComponent ) override; + + // css.frame.XUntitledNumbers + virtual OUString SAL_CALL getUntitledPrefix() override; + + // css.document.XDocumentRecovery + virtual sal_Bool SAL_CALL wasModifiedSinceLastSave() override; + virtual void SAL_CALL storeToRecoveryFile( const OUString& i_TargetLocation, const css::uno::Sequence< css::beans::PropertyValue >& i_MediaDescriptor ) override; + virtual void SAL_CALL recoverFromFile( const OUString& i_SourceLocation, const OUString& i_SalvagedFile, const css::uno::Sequence< css::beans::PropertyValue >& i_MediaDescriptor ) override; + + // css.document.XUndoManagerSupplier + virtual css::uno::Reference< css::document::XUndoManager > SAL_CALL getUndoManager( ) override; + + + // css::rdf::XNode: + virtual OUString SAL_CALL getStringValue() override; + + // css::rdf::XURI: + virtual OUString SAL_CALL getNamespace() override; + virtual OUString SAL_CALL getLocalName() override; + + // css::rdf::XRepositorySupplier: + virtual css::uno::Reference< + css::rdf::XRepository > SAL_CALL getRDFRepository() override; + + // css::rdf::XDocumentMetadataAccess: + virtual css::uno::Reference< + css::rdf::XMetadatable > SAL_CALL + getElementByMetadataReference( + const css::beans::StringPair & i_rReference) override; + virtual css::uno::Reference< + css::rdf::XMetadatable > SAL_CALL + getElementByURI(const css::uno::Reference< + css::rdf::XURI > & i_xURI) override; + virtual css::uno::Sequence< css::uno::Reference< + css::rdf::XURI > > SAL_CALL getMetadataGraphsWithType( + const css::uno::Reference< + css::rdf::XURI > & i_xType) override; + virtual css::uno::Reference< + css::rdf::XURI> SAL_CALL + addMetadataFile(const OUString & i_rFileName, + const css::uno::Sequence< + css::uno::Reference< css::rdf::XURI > + > & i_rTypes) override; + virtual css::uno::Reference< + css::rdf::XURI> SAL_CALL + importMetadataFile(::sal_Int16 i_Format, + const css::uno::Reference< + css::io::XInputStream > & i_xInStream, + const OUString & i_rFileName, + const css::uno::Reference< + css::rdf::XURI > & i_xBaseURI, + const css::uno::Sequence< + css::uno::Reference< css::rdf::XURI > + > & i_rTypes) override; + virtual void SAL_CALL removeMetadataFile( + const css::uno::Reference< + css::rdf::XURI > & i_xGraphName) override; + virtual void SAL_CALL addContentOrStylesFile( + const OUString & i_rFileName) override; + virtual void SAL_CALL removeContentOrStylesFile( + const OUString & i_rFileName) override; + + virtual void SAL_CALL loadMetadataFromStorage( + const css::uno::Reference< + css::embed::XStorage > & i_xStorage, + const css::uno::Reference< + css::rdf::XURI > & i_xBaseURI, + const css::uno::Reference< + css::task::XInteractionHandler> & i_xHandler) override; + virtual void SAL_CALL storeMetadataToStorage( + const css::uno::Reference< + css::embed::XStorage > & i_xStorage) override; + virtual void SAL_CALL loadMetadataFromMedium( + const css::uno::Sequence< + css::beans::PropertyValue > & i_rMedium) override; + virtual void SAL_CALL storeMetadataToMedium( + const css::uno::Sequence< + css::beans::PropertyValue > & i_rMedium) override; + + // XCmisDocument + + virtual css::uno::Sequence< css::document::CmisProperty > + SAL_CALL getCmisProperties() override; + virtual void SAL_CALL setCmisProperties( + const css::uno::Sequence< + css::document::CmisProperty >& _cmisproperties ) override; + + virtual void SAL_CALL updateCmisProperties( + const css::uno::Sequence< + css::document::CmisProperty >& _cmisproperties ) override; + + virtual css::uno::Sequence< css::document::CmisVersion > SAL_CALL getAllVersions ( ) override; + + virtual void SAL_CALL checkOut( ) override; + virtual void SAL_CALL cancelCheckOut( ) override; + virtual void SAL_CALL checkIn( sal_Bool bIsMajor, const OUString & rMessage ) override; + + virtual sal_Bool SAL_CALL isVersionable( ) override; + virtual sal_Bool SAL_CALL canCheckOut( ) override; + virtual sal_Bool SAL_CALL canCancelCheckOut( ) override; + virtual sal_Bool SAL_CALL canCheckIn( ) override; + + /// @throws css::uno::RuntimeException + bool getBoolPropertyValue( const OUString& rName ); + + + // SfxListener + + + void Notify( SfxBroadcaster& aBC , + const SfxHint& aHint ) override ; + + + // public IMPL? + + + void changing() ; + + SfxObjectShell* GetObjectShell() const ; + + SAL_DLLPRIVATE bool impl_isDisposed() const ; + bool IsInitialized() const; + void MethodEntryCheck( const bool i_mustBeInitialized ) const; + + css::uno::Reference < css::container::XIndexAccess > SAL_CALL getViewData() override; + void SAL_CALL setViewData( const css::uno::Reference < css::container::XIndexAccess >& aData ) override; + + /** calls all XEventListeners */ + void notifyEvent( const css::document::EventObject& aEvent ) const; + + /** returns true if someone added a XEventListener to this XEventBroadcaster */ + bool hasEventListeners() const; + +protected: + + /* returns a unique id for the model that is valid as long as the document + is loaded. The id is not saved across document close/reload. */ + OUString const & getRuntimeUID() const; + + /* returns true if the document signatures are valid, otherwise false */ + bool hasValidSignatures() const; + + /* GrabBagItem for interim interop purposes */ + void getGrabBagItem(css::uno::Any& rVal) const; + + void setGrabBagItem(const css::uno::Any& rVal); + + +// private methods + + +private: + /// @throws css::uno::RuntimeException + css::uno::Reference< css::ui::XUIConfigurationManager2 > getUIConfigurationManager2(); + void impl_getPrintHelper(); + SAL_DLLPRIVATE void ListenForStorage_Impl( const css::uno::Reference< css::embed::XStorage >& xStorage ); + SAL_DLLPRIVATE OUString GetMediumFilterName_Impl() const; + + SAL_DLLPRIVATE void postEvent_Impl( const OUString& aName, const css::uno::Reference< css::frame::XController2 >& xController = css::uno::Reference< css::frame::XController2 >(), const css::uno::Any& aSupplement = css::uno::Any()); + + SAL_DLLPRIVATE css::uno::Reference< css::frame::XTitle > impl_getTitleHelper (); + SAL_DLLPRIVATE css::uno::Reference< css::frame::XUntitledNumbers > impl_getUntitledHelper (); + + SAL_DLLPRIVATE SfxViewFrame* FindOrCreateViewFrame_Impl( + const css::uno::Reference< css::frame::XFrame >& i_rFrame, + ::sfx::intern::ViewCreationGuard& i_rGuard + ) const; + + SAL_DLLPRIVATE void NotifyModifyListeners_Impl() const; + + SAL_DLLPRIVATE void loadCmisProperties(); + + SAL_DLLPRIVATE SfxMedium* handleLoadError( ErrCode nError, SfxMedium* pMedium ); + + +// private variables and methods + + +private: + + std::shared_ptr m_pData; + // cannot be held in m_pData, since it needs to be accessed in non-threadsafe context + const bool m_bSupportEmbeddedScripts; + const bool m_bSupportDocRecovery; + +} ; // class SfxBaseModel + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxdlg.hxx b/include/sfx2/sfxdlg.hxx new file mode 100644 index 000000000..ba3062693 --- /dev/null +++ b/include/sfx2/sfxdlg.hxx @@ -0,0 +1,155 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_SFXDLG_HXX +#define INCLUDED_SFX2_SFXDLG_HXX + +#include +#include + +#include + +#include +#include +#include + +class SfxItemSet; +class SfxItemPool; +class SvObjectServerList; +class TransferableDataHelper; +class SvGlobalName; + +namespace sfx2 +{ + class LinkManager; + class SvBaseLink; +} + +namespace com::sun::star::embed { class XEmbeddedObject; } +namespace com::sun::star::embed { class XStorage; } +namespace com::sun::star::io { class XInputStream; } +namespace com::sun::star::uno { class Any; } + +class SfxAbstractDialog : virtual public VclAbstractDialog +{ +protected: + virtual ~SfxAbstractDialog() override = default; +public: + /** Get a set of items changed in the dialog. + */ + virtual const SfxItemSet* GetOutputItemSet() const = 0; + virtual void SetText( const OUString& rStr ) = 0; +}; + +class SfxAbstractTabDialog : virtual public SfxAbstractDialog +{ +protected: + virtual ~SfxAbstractTabDialog() override = default; +public: + virtual void SetCurPageId( const OString &rName ) = 0; + virtual WhichRangesContainer GetInputRanges( const SfxItemPool& ) = 0; + virtual void SetInputSet( const SfxItemSet* pInSet ) = 0; +}; + +class SfxAbstractApplyTabDialog : virtual public SfxAbstractTabDialog +{ +protected: + virtual ~SfxAbstractApplyTabDialog() override = default; +public: + virtual void SetApplyHdl( const Link& rLink ) = 0; +}; + +class SfxAbstractInsertObjectDialog : virtual public VclAbstractDialog +{ +protected: + virtual ~SfxAbstractInsertObjectDialog() override = default; +public: + virtual css::uno::Reference < css::embed::XEmbeddedObject > GetObject()=0; + virtual css::uno::Reference< css::io::XInputStream > GetIconIfIconified( OUString* pGraphicMediaType )=0; + virtual bool IsCreateNew()=0; +}; + +class SfxAbstractPasteDialog : virtual public VclAbstractDialog +{ +protected: + virtual ~SfxAbstractPasteDialog() override = default; +public: + virtual void Insert( SotClipboardFormatId nFormat, const OUString & rFormatName ) = 0; + virtual void InsertUno( const OUString& sCmd, const OUString& sLabel ) = 0; + virtual void SetObjName( const SvGlobalName & rClass, const OUString & rObjName ) = 0; + virtual void PreGetFormat( const TransferableDataHelper& aHelper ) = 0; + virtual SotClipboardFormatId GetFormatOnly() = 0; + virtual SotClipboardFormatId GetFormat( const TransferableDataHelper& aHelper ) = 0; +}; + +class SfxAbstractLinksDialog : virtual public VclAbstractDialog +{ +protected: + virtual ~SfxAbstractLinksDialog() override = default; +}; + +class AbstractScriptSelectorDialog : virtual public VclAbstractDialog +{ +protected: + virtual ~AbstractScriptSelectorDialog() override = default; +public: + virtual OUString GetScriptURL() const = 0; + virtual void SetRunLabel() = 0; +}; + +namespace com::sun::star::frame { class XFrame; } + +class SFX2_DLLPUBLIC SfxAbstractDialogFactory : virtual public VclAbstractDialogFactory +{ +public: + virtual ~SfxAbstractDialogFactory() override; // needed for export of vtable + static SfxAbstractDialogFactory* Create(); + virtual VclPtr CreateFrameDialog(weld::Window* pParent, const css::uno::Reference< css::frame::XFrame >& rFrame, sal_uInt32 nResId, const OUString& rParameter) = 0; + virtual VclPtr CreateAutoCorrTabDialog(weld::Window* pParent, const SfxItemSet* pAttrSet) = 0; + virtual VclPtr CreateCustomizeTabDialog(weld::Window* pParent, + const SfxItemSet* pAttrSet, + const css::uno::Reference< css::frame::XFrame >& xViewFrame ) = 0; + virtual CreateTabPage GetTabPageCreatorFunc( sal_uInt16 nId ) = 0; + virtual GetTabPageRanges GetTabPageRangesFunc( sal_uInt16 nId ) = 0; + virtual VclPtr CreateInsertObjectDialog(weld::Window* pParent, const OUString& rCommand, + const css::uno::Reference < css::embed::XStorage >& xStor, + const SvObjectServerList* pList )=0; + virtual VclPtr CreateEditObjectDialog(weld::Window* pParent, const OUString& rCommand, + const css::uno::Reference < css::embed::XEmbeddedObject >& xObj )=0; + virtual VclPtr CreatePasteDialog(weld::Window* pParent) = 0; + virtual VclPtr CreateLinksDialog(weld::Window* pParent, sfx2::LinkManager* pMgr, bool bHTML=false, sfx2::SvBaseLink* p=nullptr) = 0; + virtual VclPtr CreateSvxScriptOrgDialog(weld::Window* pParent, const OUString& rLanguage) = 0; + + virtual VclPtr CreateScriptSelectorDialog(weld::Window* pParent, + const css::uno::Reference< css::frame::XFrame >& rxFrame) = 0; + + virtual void ShowAsyncScriptErrorDialog( weld::Window* pParent, const css::uno::Any& rException ) = 0; + + virtual VclPtr CreateOptionsDialog( + weld::Window* pParent, const OUString& rExtensionId ) = 0; + + virtual VclPtr CreateAboutDialog(weld::Window* _pParent) = 0; + + virtual VclPtr CreateTipOfTheDayDialog(weld::Window* _pParent) = 0; + + virtual VclPtr CreateToolbarmodeDialog(weld::Window* _pParent) = 0; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxhelp.hxx b/include/sfx2/sfxhelp.hxx new file mode 100644 index 000000000..212188063 --- /dev/null +++ b/include/sfx2/sfxhelp.hxx @@ -0,0 +1,64 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_SFXHELP_HXX +#define INCLUDED_SFX2_SFXHELP_HXX + +#include + +#include + +#include +#include +#include +#include + +class SFX2_DLLPUBLIC SfxHelp final : public Help +{ + bool bIsDebug; + bool bLaunchingHelp; // tdf#140539 don't allow help to be re-launched during help launch + +private: + SAL_DLLPRIVATE static bool Start_Impl(const OUString& rURL, weld::Widget* pWidget, const OUString& rKeyword); + SAL_DLLPRIVATE virtual void SearchKeyword( const OUString& rKeyWord ) override; + SAL_DLLPRIVATE virtual bool Start(const OUString& rURL, weld::Widget* pWidget = nullptr) override; + SAL_DLLPRIVATE static OUString GetHelpModuleName_Impl(std::u16string_view rHelpId); + SAL_DLLPRIVATE static OUString CreateHelpURL_Impl( const OUString& aCommandURL, const OUString& rModuleName ); + + SAL_DLLPRIVATE static bool Start_Impl( const OUString& rURL, const vcl::Window* pWindow ); + SAL_DLLPRIVATE virtual bool Start( const OUString& rURL, const vcl::Window* pWindow ) override; + +public: + SfxHelp(); + virtual ~SfxHelp() override; + + virtual OUString GetHelpText(const OUString&, const vcl::Window* pWindow) override; + virtual OUString GetHelpText(const OUString&, const weld::Widget* pWindow) override; + + static OUString CreateHelpURL( const OUString& aCommandURL, const OUString& rModuleName ); + static OUString GetDefaultHelpModule(); + static OUString GetCurrentModuleIdentifier(); + // Check for built-in help + static bool IsHelpInstalled(); + + static OUString GetURLHelpText(std::u16string_view); +}; + +#endif // INCLUDED_SFX2_SFXHELP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxhtml.hxx b/include/sfx2/sfxhtml.hxx new file mode 100644 index 000000000..9f5a03f5b --- /dev/null +++ b/include/sfx2/sfxhtml.hxx @@ -0,0 +1,113 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_SFXHTML_HXX +#define INCLUDED_SFX2_SFXHTML_HXX + +#include +#include +#include +#include +#include +#include +#include + + +class ImageMap; +class SfxMedium; +class SvNumberFormatter; + +class SFX2_DLLPUBLIC SfxHTMLParser : public HTMLParser +{ + OUString aScriptType; + + SfxMedium* pMedium; + std::unique_ptr pDLMedium; // Medium for Download Files + + ScriptType eScriptType; + + SAL_DLLPRIVATE void GetScriptType_Impl( SvKeyValueIterator* ); + +protected: + + SfxHTMLParser( SvStream& rStream, bool bNewDoc, SfxMedium *pMedium ); + + virtual ~SfxHTMLParser() override; + +public: + // Read the options of an image map + // : sal_True = Image-Map has a name + // : sal_True = Image-Map has now one vcl::Region more + static bool ParseMapOptions(ImageMap* pImageMap, const HTMLOptions& rOptions); + bool ParseMapOptions(ImageMap * pImageMap) + { return ParseMapOptions(pImageMap, GetOptions()); } + static bool ParseAreaOptions(ImageMap * pImageMap, std::u16string_view rBaseURL, + const HTMLOptions& rOptions, + SvMacroItemId nEventMouseOver, + SvMacroItemId nEventMouseOut ); + inline bool ParseAreaOptions(ImageMap * pImageMap, std::u16string_view rBaseURL, + SvMacroItemId nEventMouseOver, + SvMacroItemId nEventMouseOut); + + // + static double GetTableDataOptionsValNum( sal_uInt32& nNumForm, + LanguageType& eNumLang, const OUString& aValStr, + std::u16string_view aNumStr, SvNumberFormatter& rFormatter ); + +protected: + // Start a file download. This is done asynchronously or synchronously. + // In the synchronous case, the parser is in the working state after + // it has been called. The read file can then be picked up directly with + // FinishFileDownload. In the asynchronous case, the parser is in the + // pending state after it hs been called. The parser then has to leave + // over the Continue (without Reschedule!). If the file is loaded, + // a Continue is called with passed on token. The file can then be picked + // up by FinishFileDownload. To cancel the download should a shell be + // left. It can only exist a single download at the same time, For every + // started download FinishFileDownload must be called. + void StartFileDownload(const OUString& rURL); + + // End of an asynchronous file download. Returns TRUE if the download + // was successful. The read file is then passed into String. + bool FinishFileDownload( OUString& rStr ); + + // Returns TRUE if a file was downloaded and if FileDownloadFinished + // has not yet been called + bool ShouldFinishFileDownload() const { return pDLMedium != nullptr; } + + SfxMedium *GetMedium() { return pMedium; } + const SfxMedium *GetMedium() const { return pMedium; } + + // Default (without iterator) is JavaScript + ScriptType GetScriptType( SvKeyValueIterator* ) const; + const OUString& GetScriptTypeString( SvKeyValueIterator* ) const; +}; + +inline bool SfxHTMLParser::ParseAreaOptions(ImageMap * pImageMap, std::u16string_view rBaseURL, + SvMacroItemId nEventMouseOver, + SvMacroItemId nEventMouseOut) +{ + return ParseAreaOptions( pImageMap, rBaseURL, GetOptions(), + nEventMouseOver, nEventMouseOut ); +} + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxmodelfactory.hxx b/include/sfx2/sfxmodelfactory.hxx new file mode 100644 index 000000000..4d166c4d4 --- /dev/null +++ b/include/sfx2/sfxmodelfactory.hxx @@ -0,0 +1,66 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_SFXMODELFACTORY_HXX +#define INCLUDED_SFX2_SFXMODELFACTORY_HXX + +#include + +#include +#include +#include + +namespace com::sun::star::lang { class XMultiServiceFactory; } +namespace com::sun::star::lang { class XSingleServiceFactory; } +namespace com::sun::star::uno { class XInterface; } +namespace com::sun::star::uno { class XComponentContext; } +namespace com::sun::star::uno { template class Sequence; } + +enum class SfxModelFlags +{ + NONE = 0x00, + EMBEDDED_OBJECT = 0x01, + EXTERNAL_LINK = 0x02, + DISABLE_EMBEDDED_SCRIPTS = 0x04, + DISABLE_DOCUMENT_RECOVERY = 0x08, +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +namespace sfx2 +{ + /** + * Intended to be called from UNO constructor functions + * This evaluates certain creation arguments (passed to createInstanceWithArguments) + * and passes them to the factory function of the derived class. + */ + css::uno::Reference + SFX2_DLLPUBLIC createSfxModelInstance( + const css::uno::Sequence & rxArgs, + std::function( SfxModelFlags )> creationFunc + ); + +} // namespace sfx2 + + +#endif // INCLUDED_SFX2_SFXMODELFACTORY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxresid.hxx b/include/sfx2/sfxresid.hxx new file mode 100644 index 000000000..f5cd1aca4 --- /dev/null +++ b/include/sfx2/sfxresid.hxx @@ -0,0 +1,30 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_SFXRESID_HXX +#define INCLUDED_SFX2_SFXRESID_HXX + +#include +#include +#include + +SFX2_DLLPUBLIC OUString SfxResId(TranslateId aId); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc new file mode 100644 index 000000000..b48f827ae --- /dev/null +++ b/include/sfx2/sfxsids.hrc @@ -0,0 +1,739 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_SFXSIDS_HRC +#define INCLUDED_SFX2_SFXSIDS_HRC + +#include +#include +#include + +class SfxAllEnumItem; +class SfxBoolItem; +class SfxDocumentInfoItem; +class SfxEventNamesItem; +class SfxFlagItem; +class SfxInt16Item; +class SfxInt32Item; +class SfxHyphenRegionItem; +class SfxMacroInfoItem; +class SfxScriptOrganizerItem; +class SfxStringItem; +class SfxStringListItem; +class SfxUInt16Item; +class SfxUnoAnyItem; +class SfxUnoFrameItem; +class SfxWatermarkItem; +class SvxClipboardFormatItem; +class SvxHyperlinkItem; +class SvxLanguageItem; +class SvxSearchItem; +class SvxZoomItem; + +// Please be careful: +// Changing just one part here doesn't add new +// docking windows automatically! + +#define SID_DOCKWIN_0 SID_DOCKWIN_START +#define SID_DOCKWIN_1 SID_DOCKWIN_START+1 +#define SID_DOCKWIN_2 SID_DOCKWIN_START+2 +#define SID_DOCKWIN_3 SID_DOCKWIN_START+3 +#define SID_DOCKWIN_4 SID_DOCKWIN_START+4 +#define SID_DOCKWIN_5 SID_DOCKWIN_START+5 +#define SID_DOCKWIN_6 SID_DOCKWIN_START+6 +#define SID_DOCKWIN_7 SID_DOCKWIN_START+7 +#define SID_DOCKWIN_8 SID_DOCKWIN_START+8 +#define SID_DOCKWIN_9 SID_DOCKWIN_START+9 + +// default-ids for application +#define SID_QUITAPP (SID_SFX_START + 300) +#define SID_ABOUT (SID_SFX_START + 301) +#define SID_SETUPPRINTER (SID_SFX_START + 302) +#define SID_SAFE_MODE (SID_SFX_START + 303) + +#define SID_DEVELOPMENT_TOOLS_DOCKING_WINDOW (SID_SFX_START + 306) +#define SID_INSPECT_SELECTED_OBJECT (SID_SFX_START + 307) + +#define SID_CONTEXT (SID_SFX_START + 310) + +#define SID_PASTE_SPECIAL (SID_SFX_START + 311) +#define SID_CLIPBOARD_FORMAT_ITEMS TypedWhichId(SID_SFX_START + 312) + +#define SID_PASTE_UNFORMATTED (SID_SFX_START + 314) +#define SID_PRINTER_NOTFOUND_WARN TypedWhichId(SID_SFX_START + 320) +#define SID_PRINTER_NAME (SID_SFX_START + 322) +#define SID_PRINTER_CHANGESTODOC TypedWhichId(SID_SFX_START + 324) +#define SID_PRINTPREVIEW (SID_SFX_START + 325) + +#define SID_MAIL_SUBJECT (SID_SFX_START + 328) +#define SID_MAIL_SENDDOC (SID_SFX_START + 331) +#define SID_MAIL_SENDDOCASPDF (SID_SFX_START + 1672) + +#define SID_MAIL_RECIPIENT (SID_SFX_START + 334) +#define SID_MAIL_TEXT (SID_SFX_START + 335) +#define SID_MAIL_PRIORITY (SID_SFX_START + 337) + +#define SID_MAIL_PREPAREEXPORT (SID_SFX_START + 385) + +#define SID_MAIL_EXPORT_FINISHED (SID_SFX_START + 388) +#define SID_WEBHTML (SID_SFX_START + 393) +#define SID_MAIL_SCROLLBODY_PAGEDOWN (SID_SFX_START + 1588) + +#define SID_PROGRESS_STATUSBAR_CONTROL TypedWhichId(SID_SFX_START + 1597) + +#define SID_SELECTION TypedWhichId(SID_SFX_START + 346) + +// 360-400 see SID_MAIL_... + +// default-ids for help +#define SID_HELPINDEX (SID_SFX_START + 401) +#define SID_EXTENDEDHELP (SID_SFX_START + 402) +#define SID_HELPBALLOONS TypedWhichId(SID_SFX_START + 403) +#define SID_HELPTIPS TypedWhichId(SID_SFX_START + 404) +#define SID_EMOJI_CONTROL (SID_SFX_START + 405) +#define SID_CHARMAP_CONTROL (SID_SFX_START + 406) +#define SID_TIPOFTHEDAY (SID_SFX_START + 407) + +// free (SID_SFX_START + 410) +#define SID_SEND_FEEDBACK (SID_SFX_START + 421) +#define SID_Q_AND_A (SID_SFX_START + 422) +#define SID_DOCUMENTATION (SID_SFX_START + 423) +#define SID_DONATION (SID_SFX_START + 424) +#define SID_GETINVOLVED (SID_SFX_START + 425) +#define SID_WHATSNEW (SID_SFX_START + 426) +#define SID_HYPHENATIONMISSING (SID_SFX_START + 427) + +#define SID_SHOW_LICENSE (SID_SFX_START + 1683) +#define SID_SHOW_CREDITS (SID_SFX_START + 1711) + +// default-ids for document +#define SID_NEWDOC (SID_SFX_START + 500) +#define SID_OPENDOC (SID_SFX_START + 501) +#define SID_OPENREMOTE (SID_SFX_START + 517) +#define SID_OPENURL (SID_SFX_START + 596) +#define SID_JUMPTOMARK (SID_SFX_START + 598) +#define SID_OPENTEMPLATE (SID_SFX_START + 594) +#define SID_SAVEASDOC (SID_SFX_START + 502) +#define SID_SAVEASREMOTE (SID_SFX_START + 516) +#define SID_SAVESIMPLE (SID_SFX_START + 518) +#define SID_SIGNPDF (SID_SFX_START + 519) +#define SID_SAVEACOPY (SID_SFX_START + 999) +#define SID_SAVEACOPYITEM (SID_SFX_START + 998) +#define SID_CONVERT_IMAGES TypedWhichId(SID_SFX_START + 997) +#define SID_CLOSING (SID_SFX_START +1539) +#define SID_CLOSEDOC (SID_SFX_START + 503) +#define SID_CLOSEDOCS (SID_SFX_START + 595) +#define SID_CLOSEDOC_SAVE (SID_SFX_START + 1) +#define SID_CLOSEDOC_FILENAME (SID_SFX_START + 2) +#define SID_PRINTDOC (SID_SFX_START + 504) +#define SID_PRINT_COPIES (SID_SFX_START + 3) +#define SID_PRINT_PAGES (SID_SFX_START +1589) +#define SID_PRINT_COLLATE (SID_SFX_START +1590) +#define SID_PRINT_SORT (SID_SFX_START +1591) +#define SID_SAVEDOC (SID_SFX_START + 505) +#define SID_FILE_NAME TypedWhichId(SID_SFX_START + 507) +#define SID_DOCINFO_TITLE TypedWhichId(SID_SFX_START + 557) +#define SID_FILE_FILTEROPTIONS TypedWhichId(SID_SFX_START + 527) +#define SID_RELOAD (SID_SFX_START + 508) +#define SID_PRINTDOCDIRECT (SID_SFX_START + 509) +#define SID_DOC_REPAIR TypedWhichId(SID_SFX_START + 510) +#define SID_DOC_SERVICE TypedWhichId(SID_SFX_START + 511) +#define SID_PLUGIN_MODE TypedWhichId(SID_SFX_START + 827) +#define SID_EXPORTDOC (SID_SFX_START + 829) +#define SID_EXPORTDOCASPDF (SID_SFX_START + 1673) +#define SID_DIRECTEXPORTDOCASPDF (SID_SFX_START + 1674) +#define SID_EXPORTDOCASEPUB (SID_SFX_START + 1677) +#define SID_DIRECTEXPORTDOCASEPUB (SID_SFX_START + 1678) +#define SID_REDACTDOC (SID_SFX_START + 1732) +#define SID_AUTOREDACTDOC (SID_SFX_START + 1736) +#define SID_UPDATEDOCMODE TypedWhichId(SID_SFX_START + 1668) +#define SID_CHECKOUT (SID_SFX_START + 512) +#define SID_CANCELCHECKOUT (SID_SFX_START + 513) +#define SID_CHECKIN (SID_SFX_START + 514) +#define SID_FILTER_PROVIDER TypedWhichId(SID_SFX_START + 515) + +#define SID_FORCERELOAD (SID_SFX_START + 1502) +#define SID_FILE_DIALOG TypedWhichId(SID_SFX_START + 304) +#define SID_REMOTE_DIALOG (SID_SFX_START + 305) +#define SID_PATH TypedWhichId(SID_SFX_START + 308) +#define SID_SAVEDOCS (SID_SFX_START + 309) +#define SID_STANDARD_DIR TypedWhichId(SID_SFX_START + 450) +#define SID_DENY_LIST TypedWhichId(SID_SFX_START + 451) + +// browse-ids +#define SID_BROWSE_FORWARD (SID_SFX_START + 1300) +#define SID_BROWSE_BACKWARD (SID_SFX_START + 1301) +#define SID_CREATELINK (SID_SFX_START + 1309) +#define SID_EDITDOC TypedWhichId(SID_SFX_START + 1312) +#define SID_BROWSER_MODE (SID_SFX_START + 1313) +#define SID_READONLYDOC (SID_SFX_START + 1314) +#define SID_BROWSER (SID_SFX_START + 1318) +#define SID_MACROEXECMODE TypedWhichId(SID_SFX_START + 1319) + +#define SID_FILTER_DATA TypedWhichId(SID_SFX_START + 1375) + +#define SID_EXPLORER_FILEPROPS_START (SID_SFX_START + 1390) +// SID_EXPLORER_FILEPROPS_END (SID_SFX_START + 1399) + +#define SID_ATTR_ZOOM TypedWhichId(SID_SVX_START + 0) + +#define SID_EXPLORER_PROPS_START TypedWhichId(SID_SFX_START + 1410) +// SID_EXPLORER_PROPS_END (SID_SFX_START + 1499) + +#define SID_AUTOLOAD (SID_SFX_START + 1509) +#define SID_FILLFRAME TypedWhichId(SID_SFX_START + 1516) +#define SID_BASEURL (SID_SFX_START + 1518) +#define SID_TEMPLATE TypedWhichId(SID_SFX_START + 1519) + +#define SID_CONTENTTYPE TypedWhichId(SID_SFX_START + 1541) + +#define SID_SAVETO TypedWhichId(SID_SFX_START + 1546) + +#define SID_VERSION TypedWhichId(SID_SFX_START + 1583) + +#define SID_DOCUMENT_COMPARE (SID_SFX_START + 1586) +#define SID_DOCUMENT_MERGE (SID_SFX_START + 1587) + +#define SID_OFFICE_CHECK_PLZ (SID_SFX_START + 1610) +#define SID_CURRENT_URL (SID_SFX_START + 1613) + +#define SID_CHARSET TypedWhichId(SID_SFX_START + 1633) +#define SID_OVERWRITE (SID_SFX_START + 1634) + // FREE (was: SID_CRASH) +#define SID_FAIL_ON_WARNING TypedWhichId(SID_SFX_START + 1646) +#define SID_INPUTSTREAM TypedWhichId(SID_SFX_START + 1648) +#define SID_LOGOUT (SID_SFX_START + 1652) +#define SID_JUMPMARK TypedWhichId(SID_SFX_START + 1654) +#define SID_BROWSE (SID_SFX_START + 1658) + // FREE (was: SID_BACKTOWEBTOP) +#define SID_VIEW_DATA_SOURCE_BROWSER (SID_SFX_START + 1660) +#define SID_UNPACK (SID_SFX_START + 1662) +// (SID_SFX_START + 1663) used further down + // FREE +#define SID_OUTPUTSTREAM TypedWhichId(SID_SFX_START + 1666) +#define SID_IMAGE_ORIENTATION (SID_SFX_START + 1667) + +#define SID_STOP_RECORDING (SID_SFX_START + 1671) +#define SID_INTERACTIONHANDLER TypedWhichId(SID_SFX_START + 1675) +#define SID_OPENHYPERLINK (SID_SFX_START + 1676) +#define SID_CONTENT TypedWhichId(SID_SFX_START + 1679) +#define SID_VIEWONLY TypedWhichId(SID_SFX_START + 1682) +#define SID_REPAIRPACKAGE TypedWhichId(SID_SFX_START + 1683) +#define SID_MINIMIZED TypedWhichId(SID_SFX_START + 1687) +#define SID_COMPONENTDATA TypedWhichId(SID_SFX_START + 1688) +#define SID_COMPONENTCONTEXT TypedWhichId(SID_SFX_START + 1689) +#define SID_SCRIPTORGANIZER TypedWhichId(SID_SFX_START + 1690) +#define SID_MACROORGANIZER TypedWhichId(SID_SFX_START + 1691) +#define SID_RUNMACRO (SID_SFX_START + 1692) +#define SID_AVMEDIA_TOOLBOX TypedWhichId<::avmedia::MediaItem>(SID_SFX_START + 1693) +#define SID_AVMEDIA_PLAYER (SID_SFX_START + 1694) +#define SID_INSERT_AVMEDIA (SID_SFX_START + 1696) +#define SID_RECENTFILELIST (SID_SFX_START + 1697) +#define SID_AVAILABLE_TOOLBARS (SID_SFX_START + 1698) +#define SID_STREAM TypedWhichId(SID_SFX_START + 1699) +#define SID_DOC_BASEURL TypedWhichId(SID_SFX_START + 1700) +#define SID_DOC_HIERARCHICALNAME TypedWhichId(SID_SFX_START + 1701) +#define SID_TERMINATE_INPLACEACTIVATION (SID_SFX_START + 1702) +#define SID_APPLY_STYLE (SID_SFX_START + 1703) +#define SID_MACRO_SIGNATURE (SID_SFX_START + 1704) +#define SID_ATTR_WARNALIENFORMAT TypedWhichId(SID_SFX_START + 1705) +#define SID_COPY_STREAM_IF_POSSIBLE TypedWhichId(SID_SFX_START + 1706) +#define SID_MAIL_SENDDOCASFORMAT (SID_SFX_START + 1707) +#define SID_MAIL_SENDDOCASMS (SID_SFX_START + 1708) +#define SID_MAIL_SENDDOCASOOO (SID_SFX_START + 1709) +#define SID_NO_ACCEPT_DIALOG TypedWhichId(SID_SFX_START + 1710) +#define SID_NOAUTOSAVE TypedWhichId(SID_SFX_START + 1711) +#define SID_PRINT_SELECTEDSHEET TypedWhichId(SID_SFX_START + 1712) +#define SID_OPTIONS_PAGEURL (SID_SFX_START + 1713) +#define SID_MORE_DICTIONARIES (SID_SFX_START + 1714) +#define SID_ACTIVATE_STYLE_APPLY (SID_SFX_START + 1715) +#define SID_FONT_NAME (SID_SFX_START + 1716) +#define SID_DEFAULTFILENAME (SID_SFX_START + 1717) +#define SID_MODIFYPASSWORDINFO TypedWhichId(SID_SFX_START + 1718) +#define SID_RECOMMENDREADONLY (SID_SFX_START + 1719) +#define SID_SUGGESTEDSAVEASDIR TypedWhichId(SID_SFX_START + 1720) +#define SID_SUGGESTEDSAVEASNAME TypedWhichId(SID_SFX_START + 1721) +#define SID_ENCRYPTIONDATA TypedWhichId(SID_SFX_START + 1722) +#define SID_PASSWORDINTERACTION (SID_SFX_START + 1723) +#define SID_GOTOLINE (SID_SFX_START + 1724) +#define SID_SHOWLINES (SID_SFX_START + 1725) +#define SID_BLUETOOTH_SENDDOC (SID_SFX_START + 1726) +#define SID_TEMPLATE_MANAGER (SID_SFX_START + 1727) +#define SID_TOOLBAR_MODE (SID_SFX_START + 1728) +#define SID_NO_FILE_SYNC (SID_SFX_START + 1729) +#define SID_NO_THUMBNAIL (SID_SFX_START + 1730) +#define SID_LOCK_CONTENT_EXTRACTION TypedWhichId(SID_SFX_START + 1731) +#define SID_LOCK_EXPORT TypedWhichId(SID_SFX_START + 1732) +// Used to export a temporary file for preview in Mail Merge Wizard, where saving the data source is +// not required for preview, but interferes with not-yet-saved embedded data source for main document. +#define SID_NO_EMBEDDED_DS TypedWhichId(SID_SFX_START + 1731) +#define SID_IS_REDACT_MODE (SID_SFX_START + 1733) +#define SID_REDACTION_STYLE (SID_SFX_START + 1734) +#define SID_DIALOG_PARENT TypedWhichId(SID_SFX_START + 1735) +#define SID_LOCK_PRINT TypedWhichId(SID_SFX_START + 1736) +#define SID_LOCK_SAVE TypedWhichId(SID_SFX_START + 1737) +#define SID_LOCK_EDITDOC TypedWhichId(SID_SFX_START + 1738) +#define SID_REPLACEABLE TypedWhichId(SID_SFX_START + 1739) +#define SID_ADDITIONS_DIALOG (SID_SFX_START + 1740) +#define FN_PARAM_ADDITIONS_TAG TypedWhichId(SID_SFX_START + 1741) +#define SID_TOOLBAR_MODE_UI (SID_SFX_START + 1742) +#define SID_TOOLBAR_LOCK (SID_SFX_START + 1743) + +// SID_SFX_free_END (SID_SFX_START + 3999) + +#define SID_OPEN_NEW_VIEW TypedWhichId(SID_SFX_START + 520) + // FREE, was SID_VIEW_ZOOM_MODE + // FREE, was SID_VIEW_POS_SIZE +#define SID_VIEW_ID TypedWhichId(SID_SFX_START + 523) + // FREE, was SID_USER_DATA +#define SID_VIEW_DATA TypedWhichId(SID_SFX_START + 1582) +#define SID_SILENT TypedWhichId(SID_SFX_START + 528) +#define SID_HIDDEN TypedWhichId(SID_SFX_START + 534) +#define SID_PREVIEW TypedWhichId(SID_SFX_START + 1404) + +#define SID_FOCUSURLBOX (SID_SFX_START + 1406) + +#define SID_ACTIVATE (SID_SFX_START + 525) +#define SID_PRINTOUT (SID_SFX_START + 526) + +#define SID_FILTER_NAME TypedWhichId(SID_SFX_START + 530) +#define SID_DOC_SALVAGE TypedWhichId(SID_SFX_START + 531) +#define SID_INSERTDOC (SID_SFX_START + 532) +#define SID_TYPE_NAME TypedWhichId(SID_SFX_START + 533) + +#define SID_DOC_READONLY TypedWhichId(SID_SFX_START + 590) +#define SID_DOC_MODIFIED (SID_SFX_START + 584) +#define SID_DOC_LOADING (SID_SFX_START + 585) +#define SID_IMG_LOADING (SID_SFX_START + 586) +#define SID_DOC_SAVED (SID_SFX_START + 599) +#define SID_DOCINFO TypedWhichId(SID_SFX_START + 535) +#define SID_DOCINFO_KEYWORDS (SID_SFX_START + 591) +#define SID_DOCINFO_COMMENTS (SID_SFX_START + 592) +#define SID_DOCINFO_AUTHOR (SID_SFX_START + 593) +#define SID_DOCINFO_MAJOR (SID_SFX_START + 594) +#define SID_NEWDOCDIRECT (SID_SFX_START + 537) +#define SID_DOCFRAME (SID_SFX_START + 598) +#define SID_TARGETNAME TypedWhichId(SID_SFX_START + 560) +#define SID_POSTDATA TypedWhichId(SID_SFX_START + 1536) +#define SID_DONELINK (SID_SFX_START + 646) +#define SID_REFERER (SID_SFX_START + 654) +#define SID_PAGE_NUMBER (SID_SFX_START + 655) +#define SID_MODIFIER TypedWhichId(SID_SFX_START + 669) +#define SID_SETOPTIONS (SID_SFX_START + 670) +#define SID_SOURCEVIEW (SID_SFX_START + 675) +#define SID_DOC_STARTPRESENTATION TypedWhichId(SID_SFX_START + 695) +#define SID_DDE_RECONNECT_ONLOAD TypedWhichId(SID_SFX_START + 696) + +#define SID_DOCTEMPLATE (SID_SFX_START + 538) +#define SID_AUTOPILOTMENU (SID_SFX_START + 1381) + +// Floating Window Template +#define SID_STYLE_DESIGNER TypedWhichId(SID_SFX_START + 539) + +#define SID_SIDEBAR_DECK (SID_SFX_START + 850) + +#define SID_TEMPLATE_ADDRESSBOOKSOURCE (SID_SFX_START + 1655) + +// Ruby dialog +#define SID_RUBY_DIALOG (SID_SFX_START + 1656) + +#define SID_STYLE_FAMILY_START (SID_SFX_START + 541) +#define SID_STYLE_FAMILY1 (SID_STYLE_FAMILY_START) +#define SID_STYLE_FAMILY2 (SID_STYLE_FAMILY_START + 1) +#define SID_STYLE_FAMILY3 (SID_STYLE_FAMILY_START + 2) +#define SID_STYLE_FAMILY4 (SID_STYLE_FAMILY_START + 3) +#define SID_STYLE_FAMILY5 (SID_STYLE_FAMILY_START + 4) +#define SID_STYLE_FAMILY6 (SID_STYLE_FAMILY_START + 5) + +#define SID_STYLE_NEW (SID_SFX_START + 549) +#define SID_STYLE_EDIT (SID_SFX_START + 550) +#define SID_STYLE_DELETE (SID_SFX_START + 551) +#define SID_STYLE_APPLY (SID_SFX_START + 552) +#define SID_STYLE_FAMILY TypedWhichId(SID_SFX_START + 553) +#define SID_STYLE_FAMILYNAME TypedWhichId(SID_SFX_START + 566) +#define SID_STYLE_WATERCAN (SID_SFX_START + 554) +#define SID_STYLE_NEW_BY_EXAMPLE (SID_SFX_START + 555) +#define SID_STYLE_UPDATE_BY_EXAMPLE (SID_SFX_START + 556) +#define SID_STYLE_DRAGHIERARCHIE (SID_SFX_START + 565) +#define SID_STYLE_MASK (SID_SFX_START + 562) +#define SID_STYLE_PREVIEW (SID_SFX_START + 567) +#define SID_STYLE_END_PREVIEW (SID_SFX_START + 568) +#define SID_STYLE_HIDE (SID_SFX_START + 1603) +#define SID_STYLE_SHOW (SID_SFX_START + 1604) +#define SID_STYLE_UPD_BY_EX_NAME TypedWhichId(SID_SFX_START + 1585) +#define SID_STYLE_REFERENCE TypedWhichId(SID_SFX_START + 1602) + +#define SID_TEMPLATE_NAME TypedWhichId(SID_SFX_START + 660) +#define SID_TEMPLATE_REGIONNAME TypedWhichId(SID_SFX_START + 662) +#define SID_TEMPLATE_LOAD (SID_SFX_START + 663) + +#define SID_INSERT_OBJECT (SID_SFX_START + 561) +#define SID_INSERT_FLOATINGFRAME (SID_SFX_START + 563) +#define SID_CLASSIFICATION_APPLY (SID_SFX_START + 672) +#define SID_WATERMARK TypedWhichId(SID_SFX_START + 676) +#define SID_WATERMARK_FONT TypedWhichId(SID_SFX_START + 677) +#define SID_WATERMARK_TRANSPARENCY TypedWhichId(SID_SFX_START + 805) +#define SID_WATERMARK_COLOR TypedWhichId(SID_SFX_START + 806) +#define SID_WATERMARK_ANGLE TypedWhichId(SID_SFX_START + 807) + +#define SID_HYPERLINK_DIALOG (SID_SFX_START + 678) + +#define SID_DEFAULTFILEPATH (SID_SFX_START + 571) +#define SID_OBJECT (SID_SFX_START + 575) + +// Doc-Properties +#define SID_DOCFULLNAME (SID_SFX_START + 581) +#define SID_DOCPATH (SID_SFX_START + 582) +#define SID_DOCTITLE TypedWhichId(SID_SFX_START + 583) + +#define SID_DOCUMENT TypedWhichId(SID_SFX_START + 588) + +// default-ids for windows + +#define SID_COMMAND_POPUP (SID_SFX_START + 610) +#define SID_NEWWINDOW (SID_SFX_START + 620) +#define SID_CLOSEWIN (SID_SFX_START + 621) +#define SID_VIEWSHELL TypedWhichId(SID_SFX_START + 623) +#define SID_WIN_FULLSCREEN TypedWhichId(SID_SFX_START + 627) + +#define SID_VIEWSHELL0 (SID_SFX_START + 630) +#define SID_VIEWSHELL1 (SID_SFX_START + 631) +#define SID_VIEWSHELL2 (SID_SFX_START + 632) +#define SID_VIEWSHELL3 (SID_SFX_START + 633) +#define SID_VIEWSHELL4 (SID_SFX_START + 634) + +// id for thesaurus entry in context menu +#define SID_THES (SID_SFX_START + 698) +#define FN_PARAM_THES_WORD_REPLACE TypedWhichId(SID_SFX_START + 699) + +// default-ids for editing, cursor travelling and selection +#define SID_REDO (SID_SFX_START + 700) +#define SID_UNDO (SID_SFX_START + 701) +#define SID_REPEAT (SID_SFX_START + 702) +#define SID_CLEARHISTORY (SID_SFX_START + 703) +#define SID_CUT (SID_SFX_START + 710) +#define SID_COPY (SID_SFX_START + 711) +#define SID_PASTE (SID_SFX_START + 712) +#define SID_DELETE (SID_SFX_START + 713) + +#define SID_BACKSPACE (SID_SFX_START + 714) +#define SID_FORMATPAINTBRUSH TypedWhichId(SID_SFX_START + 715) +#define SID_SELECT (SID_SFX_START + 720) +#define SID_SELECTALL (SID_SFX_START + 723) +#define SID_CURSORDOWN (SID_SFX_START + 731) +#define SID_CURSORUP (SID_SFX_START + 732) +#define SID_CURSORLEFT (SID_SFX_START + 733) +#define SID_CURSORRIGHT (SID_SFX_START + 734) +#define SID_CURSORPAGEDOWN (SID_SFX_START + 735) +#define SID_CURSORPAGEUP (SID_SFX_START + 736) +#define SID_CURSORENDOFFILE (SID_SFX_START + 741) +#define SID_CURSORTOPOFFILE (SID_SFX_START + 742) +#define SID_CURSORENDOFSCREEN (SID_SFX_START + 743) +#define SID_CURSORTOPOFSCREEN (SID_SFX_START + 744) +#define SID_CURSORHOME (SID_SFX_START + 745) +#define SID_CURSOREND (SID_SFX_START + 746) +#define SID_UNICODE_NOTATION_TOGGLE (SID_SFX_START + 792) + +// default-ids for macros +#define SID_RECORDING_FLOATWINDOW (SID_SFX_START + 800) +#define SID_RECORDMACRO TypedWhichId(SID_SFX_START + 1669) + +// Paste Special +#define SID_PASTE_ONLY_TEXT (SID_SFX_START + 802) +#define SID_PASTE_ONLY_FORMULA (SID_SFX_START + 803) +#define SID_PASTE_ONLY_VALUE (SID_SFX_START + 804) +#define SID_PASTE_TEXTIMPORT_DIALOG (SID_SFX_START + 805) +#define SID_PASTE_TRANSPOSED (SID_SFX_START + 812) +#define SID_PASTE_AS_LINK (SID_SFX_START + 813) + +// Used for redaction +#define SID_SHAPE_NAME (SID_SFX_START + 808) + // FREE: SID_SFX_START + 809 +#define SID_GRAPHIC_SIZE_CHECK (SID_SFX_START + 809) +#define SID_ACCESSIBILITY_CHECK (SID_SFX_START + 810) +#define SID_ASYNCHRON (SID_SFX_START + 811) + +// default-ids for configuration +#define SID_CONFIG (SID_SFX_START + 904) +#define SID_TOOLBOXOPTIONS (SID_SFX_START + 907) +#define SID_TOGGLEFUNCTIONBAR (SID_SFX_START + 910) +#define SID_MACROINFO TypedWhichId(SID_SFX_START + 919) +#define SID_TOGGLESTATUSBAR (SID_SFX_START + 920) +#define SID_CONFIGSTATUSBAR (SID_SFX_START + 921) +#define SID_CONFIGMENU (SID_SFX_START + 924) +#define SID_CONFIGACCEL (SID_SFX_START + 925) +#define SID_CONFIGEVENT (SID_SFX_START + 926) +#define SID_CFGFILE (SID_SFX_START + 927) +#define SID_SHOWPOPUPS (SID_SFX_START + 929) + +// Item-Id for the assigned event Tabpage. +// FIXME this has two different associated pool item types, SvxMacroItem and SfxBoolItem +#define SID_ATTR_MACROITEM TypedWhichId(SID_SFX_START + 934) + +#define SID_OPTIONS (SID_SFX_START + 940) +#define SID_BASICLOAD (SID_SFX_START + 951) +#define SID_BASICSAVEAS (SID_SFX_START + 953) +#define SID_BASICCOMPILE (SID_SFX_START + 954) +#define SID_BASICRUN (SID_SFX_START + 955) +#define SID_BASICSTEPINTO (SID_SFX_START + 956) +#define SID_BASICSTEPOVER (SID_SFX_START + 957) +#define SID_BASICSTEPOUT (SID_SFX_START + 963) +#define SID_BASICSTOP (SID_SFX_START + 958) +#define SID_BASICCHOOSER (SID_SFX_START + 959) +#define SID_GALLERY (SID_SFX_START + 960) +#define SID_SEARCH_DLG (SID_SFX_START + 961) +#define SID_SEARCH_QUIET (SID_SFX_START + 1684) +#define SID_EXPORT_DIALOG (SID_SFX_START + 965) +#define SID_IMPORT_DIALOG (SID_SFX_START + 966) + +#define SID_BASICBREAK (SID_SFX_START +1521) + +#define SID_OBJECTRESIZE TypedWhichId(SID_SFX_START + 1000) + +#define SID_EVENTCONFIG TypedWhichId(SID_SFX_START + 1101) +#define SID_VERB_START (SID_SFX_START + 1100) +#define SID_VERB_END (SID_SFX_START + 1121) + +#define SID_SIGNATURE (SID_SFX_START + 1643) + +// SaveTabPage +#define SID_ATTR_DOCINFO TypedWhichId(SID_OPTIONS_START + 0) +#define SID_ATTR_BACKUP TypedWhichId(SID_OPTIONS_START + 1) +#define SID_ATTR_AUTOSAVE TypedWhichId(SID_OPTIONS_START + 2) +#define SID_ATTR_AUTOSAVEPROMPT TypedWhichId(SID_OPTIONS_START + 3) +#define SID_ATTR_USERAUTOSAVE TypedWhichId(SID_OPTIONS_START + 4) +#define SID_ATTR_AUTOSAVEMINUTE TypedWhichId(SID_OPTIONS_START + 5) +#define SID_ATTR_WORKINGSET TypedWhichId(SID_OPTIONS_START + 13) +#define SID_ATTR_UNDO_COUNT TypedWhichId(SID_OPTIONS_START + 16) + // unused +#define SID_ATTR_SAVEDOCVIEW TypedWhichId(SID_OPTIONS_START + 18) + +// GeneralTabPage + +#define SID_ATTR_METRIC TypedWhichId(SID_OPTIONS_START + 8) +#define SID_ATTR_DEFTABSTOP TypedWhichId(SID_OPTIONS_START + 14) +#define SID_ATTR_BUTTON_BIGSIZE TypedWhichId(SID_OPTIONS_START + 63) +#define SID_ATTR_QUICKLAUNCHER TypedWhichId(SID_OPTIONS_START + 74) +#define SID_ATTR_YEAR2000 TypedWhichId(SID_OPTIONS_START + 87) +#define SID_ATTR_APPLYCHARUNIT TypedWhichId(SID_OPTIONS_START + 88) + +// PathTabPage +#define SID_ATTR_PATHNAME TypedWhichId(SID_OPTIONS_START + 11) + +// LinguTabPage +#define SID_ATTR_LANGUAGE TypedWhichId(SID_OPTIONS_START + 7) +#define SID_ATTR_HYPHENREGION TypedWhichId(SID_OPTIONS_START + 12) +#define SID_AUTOSPELL_CHECK TypedWhichId(SID_OPTIONS_START + 21) + +// InetTabPage + +#define SID_INET_PROXY_TYPE TypedWhichId(SID_OPTIONS_START + 23) + +#define SID_SAVEREL_INET TypedWhichId(SID_OPTIONS_START + 30) +#define SID_SAVEREL_FSYS TypedWhichId(SID_OPTIONS_START + 31) + +#define SID_PASSWORD TypedWhichId(SID_OPTIONS_START + 36) + +#define SID_INET_NOPROXY TypedWhichId(SID_OPTIONS_START + 37) + +#define SID_INET_HTTP_PROXY_NAME TypedWhichId(SID_OPTIONS_START + 38) +#define SID_INET_HTTP_PROXY_PORT TypedWhichId(SID_OPTIONS_START + 39) +#define SID_INET_FTP_PROXY_NAME TypedWhichId(SID_OPTIONS_START + 40) +#define SID_INET_FTP_PROXY_PORT TypedWhichId(SID_OPTIONS_START + 41) + +// Automatic update of Styles - manage TabPage +#define SID_ATTR_AUTO_STYLE_UPDATE TypedWhichId(SID_OPTIONS_START + 65) + +#define SID_SECURE_URL TypedWhichId(SID_OPTIONS_START + 66) + +// configured locale changed +#define SID_OPT_LOCALE_CHANGED (SID_OPTIONS_START + 94) +//middle mouse button +#define SID_ATTR_PRETTYPRINTING TypedWhichId(SID_OPTIONS_START + 98) +#define SID_HELP_STYLESHEET TypedWhichId(SID_OPTIONS_START + 99) + +// slot IDs from SVX (svxids.hrc) --------------------------------------------- +// These SID_SVX_START entries came from include/svx/svxids.hrc, avoid +// accidentally colliding entries with include/svx/svxids.hrc and +// include/editeng/editids.hrc. Only add new SID_SVX_START entries +// to include/svx/svxids.hrc + +#define SID_ZOOM_TOOLBOX (SID_SVX_START + 96) +#define SID_ZOOM_OUT (SID_SVX_START + 97) +#define SID_ZOOM_IN (SID_SVX_START + 98) +#define SID_SIZE_REAL (SID_SVX_START + 99) +#define SID_SIZE_PAGE (SID_SVX_START + 100) +#define SID_GALLERY_BG_BRUSH (SID_SVX_START + 279) +#define SID_SEARCH_OPTIONS (SID_SVX_START + 281) +#define SID_SEARCH_ITEM TypedWhichId(SID_SVX_START + 291) +#define SID_SIDEBAR (SID_SVX_START + 336) +#define SID_NOTEBOOKBAR (SID_SVX_START + 338) +#define SID_MENUBAR (SID_SVX_START + 339) +#define SID_HYPERLINK_GETLINK TypedWhichId(SID_SVX_START + 361) +#define SID_HYPERLINK_SETLINK TypedWhichId(SID_SVX_START + 362) +#define SID_INFOBAR (SID_SVX_START + 365) +#define SID_NAVIGATOR (SID_SVX_START + 366) +#define SID_ZOOM_NEXT (SID_SVX_START + 402) +#define SID_ZOOM_PREV (SID_SVX_START + 403) +#define SID_INET_DLG (SID_SVX_START + 416) +#define SID_AUTO_CORRECT_DLG (SID_SVX_START + 424) +#define SID_ATTR_CHAR_COLOR_EXT (SID_SVX_START + 488) +#define SID_ATTR_CHAR_COLOR_BACKGROUND (SID_SVX_START + 489) +#define SID_ATTR_CHAR_COLOR_BACKGROUND_EXT (SID_SVX_START + 490) +#define SID_ATTR_CHAR_COLOR2 (SID_SVX_START + 537) +#define SID_ATTR_COLOR_STR TypedWhichId(SID_SVX_START + 540) +#define SID_COMP_BIBLIOGRAPHY (SID_SVX_START + 880) +#define SID_ADDRESS_DATA_SOURCE (SID_SVX_START + 934) +#define SID_OPEN_SMARTTAGOPTIONS TypedWhichId(SID_SVX_START + 1062) +#define SID_RULER_MARGIN1 TypedWhichId(SID_SVX_START + 1063) +#define SID_RULER_MARGIN2 TypedWhichId(SID_SVX_START + 1064) +#define SID_TABLE_BORDER_TYPE TypedWhichId(SID_SVX_START + 1065) +#define SID_TABLE_BORDER_INDEX TypedWhichId(SID_SVX_START + 1066) +#define SID_TABLE_BORDER_OFFSET TypedWhichId(SID_SVX_START + 1067) + +#define FID_SVX_START (SID_LIB_START + 500) +#define FID_SEARCH_NOW (FID_SVX_START + 2) +#define SID_BASICIDE_REPEAT_SEARCH (FID_SVX_START + 3) + +// SlotIds for Basic ------------------------------------------------------- +#define SID_BASICIDE_TOGGLEBRKPNT ( SID_BASICIDE_START + 0 ) +#define SID_BASICIDE_ADDWATCH ( SID_BASICIDE_START + 1 ) +#define SID_BASICIDE_CHOOSEMACRO ( SID_BASICIDE_START + 2 ) +#define SID_BASICIDE_EDITMACRO ( SID_BASICIDE_START + 3 ) +#define SID_BASICIDE_CREATEMACRO ( SID_BASICIDE_START + 4 ) +#define SID_BASICIDE_MODULEDLG ( SID_BASICIDE_START + 5 ) +#define SID_BASICIDE_OBJCAT ( SID_BASICIDE_START + 6 ) +#define SID_BASICIDE_REMOVEWATCH ( SID_BASICIDE_START + 7 ) +#define SID_BASICIDE_SHOWSBX ( SID_BASICIDE_START + 9 ) +#define SID_BASICIDE_HIDECURPAGE ( SID_BASICIDE_START + 10 ) +#define SID_BASICIDE_NAMECHANGEDONTAB ( SID_BASICIDE_START + 11 ) +#define SID_BASICIDE_UPDATEMODULESOURCE ( SID_BASICIDE_START + 12 ) +#define SID_BASICIDE_STOREMODULESOURCE ( SID_BASICIDE_START + 13 ) +#define SID_BASICIDE_MATCHGROUP ( SID_BASICIDE_START + 14 ) +#define SID_BASICIDE_APPEAR ( SID_BASICIDE_START + 15 ) +#define SID_BASICIDE_STOREALLMODULESOURCES ( SID_BASICIDE_START + 16 ) +#define SID_BASICIDE_UPDATEALLMODULESOURCES ( SID_BASICIDE_START + 17 ) +#define SID_BASICIDE_LIBSELECTED ( SID_BASICIDE_START + 18 ) +#define SID_BASICIDE_LIBSELECTOR ( SID_BASICIDE_START + 19 ) +#define SID_BASICIDE_NEWDIALOG ( SID_BASICIDE_START + 20 ) +#define SID_BASICIDE_NEWMODULE ( SID_BASICIDE_START + 21 ) +#define SID_BASICIDE_DELETECURRENT ( SID_BASICIDE_START + 22 ) +#define SID_BASICIDE_RENAMECURRENT ( SID_BASICIDE_START + 23 ) +#define SID_BASICIDE_SBXDELETED ( SID_BASICIDE_START + 24 ) +#define SID_BASICIDE_SBXINSERTED ( SID_BASICIDE_START + 25 ) +#define SID_BASICIDE_SBXRENAMED ( SID_BASICIDE_START + 26 ) +#define SID_BASICIDE_LIBLOADED ( SID_BASICIDE_START + 27 ) +#define SID_BASICIDE_LIBREMOVED ( SID_BASICIDE_START + 28 ) +#define SID_BASICIDE_ARG_TABID TypedWhichId( SID_BASICIDE_START + 30 ) +#define SID_BASICIDE_ARG_SBX TypedWhichId( SID_BASICIDE_START + 31 ) +#define SID_BASICIDE_ARG_MACROINFO TypedWhichId( SID_BASICIDE_START + 32 ) +#define SID_BASICIDE_ARG_LIBNAME TypedWhichId( SID_BASICIDE_START + 34 ) +#define SID_BASICIDE_ARG_MODULENAME TypedWhichId( SID_BASICIDE_START + 35 ) +#define SID_BASICIDE_BRKPNTSCHANGED ( SID_BASICIDE_START + 36 ) +#define SID_BASICIDE_STAT_POS ( SID_BASICIDE_START + 38 ) +#define SID_BASICIDE_STAT_DATE ( SID_BASICIDE_START + 39 ) +#define SID_BASICIDE_STAT_TITLE ( SID_BASICIDE_START + 40 ) +#define SID_BASICIDE_MANAGEBRKPNTS ( SID_BASICIDE_START + 42 ) +#define SID_BASICIDE_TOGGLEBRKPNTENABLED ( SID_BASICIDE_START + 43 ) +#define SID_BASICIDE_SHOWWINDOW ( SID_BASICIDE_START + 44 ) +#define SID_BASICIDE_ARG_DOCUMENT TypedWhichId( SID_BASICIDE_START + 45 ) +#define SID_BASICIDE_ARG_NAME ( SID_BASICIDE_START + 46 ) +#define SID_BASICIDE_ARG_TYPE ( SID_BASICIDE_START + 47 ) +#define SID_BASICIDE_ARG_LINE ( SID_BASICIDE_START + 48 ) +#define SID_BASICIDE_ARG_COLUMN1 ( SID_BASICIDE_START + 49 ) +#define SID_BASICIDE_ARG_COLUMN2 ( SID_BASICIDE_START + 50 ) +#define SID_BASICIDE_ARG_DOCUMENT_MODEL TypedWhichId( SID_BASICIDE_START + 51 ) +#define SID_BASICIDE_MANAGE_LANG ( SID_BASICIDE_START + 52 ) +#define SID_BASICIDE_CURRENT_LANG ( SID_BASICIDE_START + 53 ) +#define SID_OPTIONS_TREEDIALOG ( SID_BASICIDE_START + 862) + +// SlotIds for Apps -------------------------------------------------------- +#define FN_PARAM (SID_SW_START + 1100) +#define FN_PARAM_1 (FN_PARAM+60) +#define FN_PARAM_2 (FN_PARAM+61) +#define FN_PARAM_3 (FN_PARAM+62) +#define FN_PARAM_4 (FN_PARAM+63) +#define FN_PARAM_5 (FN_PARAM+64) +#define FN_PARAM_6 (FN_PARAM+65) +#define FN_FAX (SID_SW_START + 28) /* Fax */ + +#define SID_KEYFUNC_START (SID_SC_START + 521) +#define SID_CURSORDOWN_SEL (SID_KEYFUNC_START + 0) +#define SID_CURSORUP_SEL (SID_KEYFUNC_START + 1) +#define SID_CURSORLEFT_SEL (SID_KEYFUNC_START + 2) +#define SID_CURSORRIGHT_SEL (SID_KEYFUNC_START + 3) +#define SID_CURSORPAGEDOWN_SEL (SID_KEYFUNC_START + 4) +#define SID_CURSORPAGEUP_SEL (SID_KEYFUNC_START + 5) +#define SID_CURSORPAGELEFT_SEL (SID_KEYFUNC_START + 7) +#define SID_CURSORPAGERIGHT_SEL (SID_KEYFUNC_START + 9) +#define SID_CURSORTOPOFFILE_SEL (SID_KEYFUNC_START + 10) +#define SID_CURSORENDOFFILE_SEL (SID_KEYFUNC_START + 11) +#define SID_CURSORHOME_SEL (SID_KEYFUNC_START + 12) +#define SID_CURSOREND_SEL (SID_KEYFUNC_START + 13) +#define SID_REPAINT (SID_SC_START + 12) + +#define SID_MODIFIED TypedWhichId(SID_SD_START+89) +#define ID_VAL_DUMMY0 (SID_SD_START+230) +#define SID_SIZE_OPTIMAL (SID_SD_START+99) + +#define SID_ZOOM_OPTIMAL (SID_SIZE_OPTIMAL) +#define SID_ZOOM_ENTIRE_PAGE (SID_SIZE_PAGE) +#define SID_ZOOM_PAGE_WIDTH (SID_SVX_START + 1420) +#define SID_ZOOM_50_PERCENT (SID_SVX_START + 1421) +#define SID_ZOOM_75_PERCENT (SID_SVX_START + 1422) +#define SID_ZOOM_100_PERCENT (SID_SIZE_REAL) +#define SID_ZOOM_150_PERCENT (SID_SVX_START + 1423) +#define SID_ZOOM_200_PERCENT (SID_SVX_START + 1424) + +// SfxScriptOrganizerItem +#define MID_SCRIPT_ORGANIZER_LANGUAGE 1 // Don't use zero for MID's. It's forbidden to do it! + +#define SID_NEWSD (SID_SFX_START + 1686) +#define FN_LABEL (SID_SW_START + 1051 ) +#define FN_BUSINESS_CARD (SID_SW_START + 1052) +#define FN_XFORMS_INIT (SID_SW_START + 1053) + +#define SID_RESTORE_EDITING_VIEW (SID_SFX_START + 1663) + +// SfxSecurityPage related stuff + +#define FN_EDIT2 (SID_SW_START + 1800) +#define FN_REDLINE_PROTECT TypedWhichId(FN_EDIT2 + 23) +#define FN_REDLINE_ON TypedWhichId(FN_EDIT2 + 25) + +#define SID_HTML_MODE TypedWhichId(SID_SVX_START + 414) + +// Calc-Id's used for SfxSecurityPage +#ifndef SC_FUNCTION_START +#define SC_FUNCTION_START (SID_SC_START + 200) +#endif +#ifndef FILE_MENU_END +#define FILE_MENU_END (SC_FUNCTION_START + 20) +#endif +#ifndef EDIT_MENU_START +#define EDIT_MENU_START (FILE_MENU_END) +#endif +#ifndef SC_VIEW_START +#define SC_VIEW_START (SID_SC_START) +#endif +#define FID_CHG_RECORD TypedWhichId(EDIT_MENU_START + 18) +#define SID_CHG_PROTECT TypedWhichId(SC_VIEW_START + 84) + +#endif // #ifndef INCLUDED_SFX2_SFXSIDS_HRC + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxstatuslistener.hxx b/include/sfx2/sfxstatuslistener.hxx new file mode 100644 index 000000000..384d5ac19 --- /dev/null +++ b/include/sfx2/sfxstatuslistener.hxx @@ -0,0 +1,74 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_SFXSTATUSLISTENER_HXX +#define INCLUDED_SFX2_SFXSTATUSLISTENER_HXX + +#include +#include +#include +#include +#include + +#include + +namespace com::sun::star::frame { class XDispatch; } +namespace com::sun::star::frame { class XDispatchProvider; } +namespace com::sun::star::frame { struct FeatureStateEvent; } + +class SFX2_DLLPUBLIC SfxStatusListener : public cppu::WeakImplHelper< + css::frame::XStatusListener, + css::lang::XComponent> +{ + public: + + SfxStatusListener( const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider, sal_uInt16 nSlotId, const OUString& aCommand ); + virtual ~SfxStatusListener() override; + + // old methods from SfxControllerItem + sal_uInt16 GetId() const { return m_nSlotID; } + void UnBind(); + void ReBind(); + + virtual void StateChangedAtStatusListener( SfxItemState eState, const SfxPoolItem* pState ); + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + + // XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + + // XStatusListener + virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& Event) override; + + private: + SfxStatusListener( const SfxStatusListener& ) = delete; + SfxStatusListener& operator=( const SfxStatusListener& ) = delete; + + sal_uInt16 m_nSlotID; + css::util::URL m_aCommand; + css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchProvider; + css::uno::Reference< css::frame::XDispatch > m_xDispatch; +}; + +#endif // INCLUDED_SFX2_SFXSTATUSLISTENER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxuno.hxx b/include/sfx2/sfxuno.hxx new file mode 100644 index 000000000..6c6253f37 --- /dev/null +++ b/include/sfx2/sfxuno.hxx @@ -0,0 +1,50 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_SFXUNO_HXX +#define INCLUDED_SFX2_SFXUNO_HXX + +#include +#include + +namespace com::sun::star::beans { struct NamedValue; } +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::uno { template class Sequence; } + +class SfxAllItemSet ; +class SfxItemSet ; +class SfxSlot ; + +SFX2_DLLPUBLIC void TransformParameters( sal_uInt16 nSlotId , + const css::uno::Sequence< css::beans::PropertyValue >& seqArgs , + SfxAllItemSet& aSet , + const SfxSlot* pSlot = nullptr ); + +SFX2_DLLPUBLIC void TransformItems( sal_uInt16 nSlotId , + const SfxItemSet& aSet , + css::uno::Sequence< css::beans::PropertyValue >& seqArgs , + const SfxSlot* pSlot = nullptr ); + +bool GetEncryptionData_Impl( const SfxItemSet* pSet, css::uno::Sequence< css::beans::NamedValue >& aEncryptionData ); + +typedef sal_Int32 FrameSearchFlags; + +#endif // INCLUDED_SFX2_SFXUNO_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/shell.hxx b/include/sfx2/shell.hxx new file mode 100644 index 000000000..2da1472a8 --- /dev/null +++ b/include/sfx2/shell.hxx @@ -0,0 +1,587 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_SHELL_HXX +#define INCLUDED_SFX2_SHELL_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace com::sun::star::embed { struct VerbDescriptor; } +namespace com::sun::star::uno { template class Sequence; } + +class SfxItemPool; +class SfxPoolItem; +class SfxRequest; +class SfxItemSet; +class SfxInterface; +class SfxViewShell; +class SfxObjectShell; + +class SfxShell; +struct SfxShell_Impl; +class SfxDispatcher; +class SfxViewFrame; +class SfxSlot; +class SfxRepeatTarget; +class SfxBindings; +class SfxModule; +class SfxUndoManager; + +/** + Id for s, gives a quasi-static access to the interface + through an array to . +*/ +typedef o3tl::strong_int SfxInterfaceId; + +constexpr auto SFX_INTERFACE_NONE = SfxInterfaceId(0); +constexpr auto SFX_INTERFACE_SFXAPP = SfxInterfaceId(1); +constexpr auto SFX_INTERFACE_SFXDOCSH = SfxInterfaceId(2); +constexpr auto SFX_INTERFACE_SFXVIEWSH = SfxInterfaceId(3); +constexpr auto SFX_INTERFACE_SFXVIEWFRM = SfxInterfaceId(4); +constexpr auto SFX_INTERFACE_SFXMODULE = SfxInterfaceId(5); +constexpr auto SFX_INTERFACE_SC_START = SfxInterfaceId(150); +constexpr auto SFX_INTERFACE_SD_START = SfxInterfaceId(200); +constexpr auto SFX_INTERFACE_SW_START = SfxInterfaceId(250); +constexpr auto SFX_INTERFACE_SMA_START = SfxInterfaceId(340); +constexpr auto SFX_INTERFACE_IDE_START = SfxInterfaceId(400); +constexpr auto SFX_INTERFACE_IDE_END = SfxInterfaceId(409); + +enum class SfxShellFeature +{ + NONE = 0x0000, + // Writer only, class SwView + SwChildWindowLabel = 0x0001, + // Basic only, class Shell + BasicShowBrowser = 0x0004, + // Forms only, class FmFormShell + FormShowDatabaseBar = 0x0008, + FormShowField = 0x0010, + FormShowProperties = 0x0020, + FormShowExplorer = 0x0040, + FormShowFilterBar = 0x0080, + FormShowFilterNavigator = 0x0100, + FormShowTextControlBar = 0x0200, + FormTBControls = 0x0400, + FormTBDesign = 0x1000, + FormShowDataNavigator = 0x2000, + // masks to make sure modules don't use flags from another + SwMask = 0x0001, + BasicMask = 0x0004, + FormMask = 0x3ff8 +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +/* Flags that are being used in the slot definitions for the disable-features */ +enum class SfxDisableFlags { + NONE, + SwOnProtectedCursor = 0x0001, + SwOnMailboxEditor = 0x0002, +}; +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +} + +typedef void (*SfxExecFunc)(SfxShell *, SfxRequest &rReq); +typedef void (*SfxStateFunc)(SfxShell *, SfxItemSet &rSet); + +/** + The class SfxShell is the base class for all classes, which provide + the functionality of the form s. + + Each instance has a reference to an interface description, which is + obtainable through . This interface + provides the connection to specific methods and contains some other + descriptive data for controllers like menus and toolboxes, but also + for the various APIs. The main part of the interface description is in + the form of a , which is generated from an IDL-file by + the . For each SfxShell Subclass-File there is one + such IDL-file to write. +*/ +class SFX2_DLLPUBLIC SfxShell: public SfxBroadcaster +{ + friend class SfxObjectItem; + + std::unique_ptr< SfxShell_Impl > pImpl; + SfxItemPool* pPool; + SfxUndoManager* pUndoMgr; + +private: + SfxShell( const SfxShell & ) = delete; + SfxShell& operator = ( const SfxShell & ) = delete; + +protected: + /** + The constructor of the SfxShell class initializes only simple types, + the corresponding SbxObject is only created on-demand. Therefore, + the application of a SfxShell instance is very cheap. + */ + SfxShell(); + + /** + The constructor of the SfxShell class initializes only simple types, + the corresponding SbxObject is only created on-demand. Therefore, + the application of a SfxShell instance is very cheap. + */ + SfxShell( SfxViewShell *pViewSh ); + + void SetViewShell_Impl( SfxViewShell* pView ); + SAL_DLLPRIVATE void Invalidate_Impl( SfxBindings& rBindings, sal_uInt16 nId ); + static void HandleOpenXmlFilterSettings(SfxRequest &); + +public: + + /** + The connection to a possible corresponding SbxObject is dissolved. + The SbxObject may continue to exist, but can not any longer perform + any functions and can not provide any properties. + */ + virtual ~SfxShell() override; + + /** + With this virtual method, which is automatically overridden by each subclass + with its own slots through the macro , one can access + each of the instance belonging to the subclass. + + The class SfxShell itself has no own SfxInterface (no slots), therefore a + NULL-pointer is returned. + */ + virtual SfxInterface* GetInterface() const; + static SfxInterface* GetStaticInterface() { return nullptr; } + + /** + Sets the name of the Shell object. With this name, the SfxShell instance + of BASIC can be expressed. + */ + void SetName( const OUString &rName ); + + /** + Returns the name of the Shell object. With this name, the SfxShell instance + of BASIC can be expressed. + */ + const OUString& GetName() const; + + /** + Returns the SfxViewShell in which they are located in the subshells. + Otherwise, and if not specified by the App developer, this method + returns NULL. + */ + SfxViewShell* GetViewShell() const; + + static void EmptyExecStub(SfxShell *pShell, SfxRequest &); + static void EmptyStateStub(SfxShell *pShell, SfxItemSet &); + + /** + This method returns the status of the slot with the specified slot ID + on the specified interface. + + If the slot is disabled or in this SfxShell (and their parent shells) are + not known, a Null-pointer is returned. + + If the slot does not have a Status, a SfxVoidItem is returned. + + The status is set directly in this Set when pStateSet != 0 , so that + overridden Slots of the Subclasses and also in the Status + method of the base implementation can be called. + + [Example] + + In a derived class of SfxViewShell the SID_PRINTDOCDIRECT will be + intercepted. Under certain circumstances a query should appear before + you print, and the request will be aborted if necessary. + + Also in the IDL of this subclass of the above slot is entered. The status + method will contain in outline: + + void SubViewShell::PrintState( SfxItemSet &rState ) + { + if ( rState.GetItemState( SID_PRINTDOCDIRECT ) != SfxItemState::UNKNOWN ) + GetSlotState( SID_PRINTDOCDIRECT, SfxViewShell::GetInterface(), + &rState ); + ... + } + + [Cross-reference] + + + */ + const SfxPoolItem* GetSlotState( sal_uInt16 nSlotId, const SfxInterface *pIF = nullptr, SfxItemSet *pStateSet = nullptr ); + + /** + This method allows you to forward a to the specified + base . + + [Example] + + In a derived class of SfxViewShell the SID_PRINTDOCDIRECT will be + intercepted. Under certain circumstances a query should appear before + you print, and the request will be aborted if necessary. + + Also in the IDL of this subclass of the above slot is entered. The status + method will contain in outline: + + void SubViewShell::Exec( SfxRequest &rReq ) + { + if ( rReq.GetSlot() == SID_PRINTDOCDIRECT ) + { + 'dialog' + if ( 'condition' ) + ExecuteSlot( rReq, SfxViewShell::GetInterface() ); + } + } + + It usually takes no rReq.Done() to be called as that is already completed + in implementation of the SfxViewShell, for instance it has been canceled. + + [Cross-reference] + + + */ + const SfxPoolItem* ExecuteSlot( SfxRequest &rReq, const SfxInterface *pIF = nullptr ); + + /** + Asynchronous ExecuteSlot for the RELOAD + */ + void ExecuteSlot( SfxRequest &rReq, bool bAsync ); + + inline SfxItemPool& GetPool() const; + inline void SetPool( SfxItemPool *pNewPool ) ; + + /** + Each Subclass of SfxShell can have a . This can be set in + the derived class with . + + The class SfxShell itself does not have a SfxUndoManager, a NULL-pointer + is therefore returned. + */ + virtual SfxUndoManager* GetUndoManager(); + + /** + Sets a for this Instance. For the undo + is only the undo-manager used for SfxShell at the top of the stack of each + . + + On the given is automatically the current + Max-Undo-Action-Count setting set from the options. + + 'pNewUndoMgr' must exist until the Destructor of SfxShell instance is called + or until the next 'SetUndoManager()'. + */ + void SetUndoManager( SfxUndoManager *pNewUndoMgr ); + + /** + Returns a pointer to the instance that is used in + SID_REPEAT as repeat target when it is addressed from the + supplied by this SfxShell. The return value can be NULL. + + [Note] + + A derivation of or one of its subclasses of + is not recommended, as compiler errors are provoked. + (due to Call-to-Pointer-to-Member-Function to the subclass). + */ + SfxRepeatTarget* GetRepeatTarget() const; + + /** + Sets the instance that is used in SID_REPEAT as + RepeatTarget, when the current supplied by this is + addressed. By 'pTarget==0' the SID_REPEAT is disabled for this SfxShell. + The instance '*pTarget' must live as long as it is registered. + + [Note] + + A derivation of or one of its subclasses of + is not recommended, as compiler errors are provoked. + (due to Call-to-Pointer-to-Member-Function to the subclass). + */ + void SetRepeatTarget( SfxRepeatTarget *pTarget ); + + /** + With this method can the slots of the subclasses be invalidated through the + slot Id or alternatively through the Which ID. Slot IDs, which are + inherited by the subclass are also invalidated. + + [Cross-reference] + + + + */ + virtual void Invalidate(sal_uInt16 nId = 0); + + virtual bool IsDesignMode() const { return false; }; + + bool IsActive() const; + + /** + Virtual method that is called when enabling the SfxShell instance, + in order to give the Subclasses the opportunity to respond to the + to the enabling. + + [Cross-reference] + + StarView SystemWindow::Activate(bool) + */ + virtual void Activate(bool bMDI); + + /** + Virtual method that is called when disabling the SfxShell instance, + to give the Subclasses the opportunity to respond to the disabling. + + [Cross-reference] + + StarView SystemWindow::Deactivate(bool) + */ + virtual void Deactivate(bool bMDI); + + /** + This method returns a pointer to the , when the SfxShell + is currently or a NULL-pointer if it is not UI-active. + + The returned pointer is only valid in the immediate context of the method + call. + */ + SfxDispatcher* GetDispatcher() const; + + /** + This method returns a pointer to the to which this SfxShell + instance is associated or in which they currently is . + A NULL pointer is returned if this SfxShell instance is not UI-active at + the moment and also no SfxViewFrame is permanently assigned. + + The returned pointer is only valid in the immediate context of the method + call. + + [Note] + + Only instances of a subclass of SfxApplication and SfxObjectShell + should here provide a NULL-pointer. Otherwise, there is an error in the + application program (wrong constructor was called from SfxShell). + + [Cross-reference] + + + */ + SfxViewFrame* GetFrame() const; + + virtual bool HasUIFeature(SfxShellFeature nFeature) const; + void UIFeatureChanged(); + + // Items + /** + With this method any objects of subclasses can be accessed. + This exchange method is needed if, for example special + subclasses need access to certain data such as the . + + The returned instance belongs to the particular SfxShell and may be + used only in the immediate context of the method call. + + [Cross-reference] + + + + */ + const SfxPoolItem* GetItem( sal_uInt16 nSlotId ) const; + template const T* GetItem( TypedWhichId nWhich ) const + { + return static_cast(GetItem(sal_uInt16(nWhich))); + } + + /** + With this method, any objects of subclasses of can be made + available. This exchange technology is needed if, for example, special + Subclasses need access to certain data such as the + + + If a SfxPoolItem exists with the same slot ID, it is deleted automatically. + + [Cross-reference] + + + + */ + void PutItem( const SfxPoolItem& rItem ); + + // TODO/CLEANUP: still needed?! + void SetVerbs(const css::uno::Sequence < css::embed::VerbDescriptor >& aVerbs); + const css::uno::Sequence < css::embed::VerbDescriptor >& GetVerbs() const; + void VerbExec (SfxRequest&); + static void VerbState (SfxItemSet&); + SAL_DLLPRIVATE const SfxSlot* GetVerbSlot_Impl(sal_uInt16 nId) const; + + virtual SfxObjectShell* GetObjectShell(); + void SetDisableFlags( SfxDisableFlags nFlags ); + SfxDisableFlags GetDisableFlags() const; + + virtual std::optional CreateItemSet( sal_uInt16 nId ); + virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ); + + /** Set the name of the sidebar context that is broadcast on calls + to Activation(). + */ + void SetContextName (const OUString& rsContextName); + + /** Broadcast a sidebar context change. + This method is typically called from Activate() or + Deactivate(). + @param bIsActivated + When then broadcast the context name that was + defined with an earlier call to SetContextName(). + When then broadcast the 'default' context. + */ + void BroadcastContextForActivation (const bool bIsActivated); + + /** Enabled or disable the context broadcaster. Returns the old state. + */ + bool SetContextBroadcasterEnabled (const bool bIsEnabled); + + /** + + This method determines by calling the status function whether 'rSlot' + can be executed currently. + */ + SAL_DLLPRIVATE bool CanExecuteSlot_Impl( const SfxSlot &rSlot ); + + /** + + This method determines whether we need to execute without checking + the disabled state of the slot. This is used for dynamic conditions + while you can use SfxSlotMode::FASTCALL for a specific slotid in general. + */ + virtual bool IsConditionalFastCall( const SfxRequest &rReq ); + + /** + + This method controls the activation of SfxShell instance. First, by calling + the virtual method which gives the subclass the + opportunity to respond to the event. + + When bMDI == TRUE, the associated SbxObject is being 'armed', so that + unqualified methods of the object (without the name of the object) + from BASIC are found. + */ + SAL_DLLPRIVATE void DoActivate_Impl( SfxViewFrame *pFrame, bool bMDI); + + /** + + This method controls the deactivation of the SfxShell instance. When + bMDI == TRUE the SbxObject is first set to a status that only qualified + BASIC methods can be called. + + Then the subclass gets the opportunity in every case to respond to the + event by calling the virtual method . + */ + SAL_DLLPRIVATE void DoDeactivate_Impl( SfxViewFrame const *pFrame, bool bMDI); +}; + +/** + Each Subclass of SfxShell must reference a pool. This is partly set by + SFx's own set of subclasses (eg ). In particular however + this must be set directly from one derived SfxShell class and ny + derivatives of SfxObjectShell. + + The SfxShell class itself does not have any SfxItemPool, therefore a + null-pointer is returned. +*/ +SfxItemPool& SfxShell::GetPool() const +{ + assert(pPool && "no pool"); + return *pPool; +} + +/** + With this method, the subclasses register their special + in the SfxShell. Each SfxShell instance must have access to a SfxItemPool. + Usually this is the SfxItemPool of the SfxDocumentShell. The SfxShell + subclass does not take ownership of the orphaned pool. Before it is + deleted it has to be deregistered with SetPool(0). +*/ +inline void SfxShell::SetPool +( + SfxItemPool* pNewPool // Pointer to the new Pool or null +) +{ + pPool = pNewPool; +} + +#define SFX_DECL_INTERFACE(nId) \ + static SfxInterface* s_pInterface; \ + static SfxInterface* GetStaticInterface(); \ + static SfxInterfaceId GetInterfaceId() {return nId;} \ + static void RegisterInterface(const SfxModule* pMod=nullptr); \ + virtual SfxInterface* GetInterface() const override; + +#define SFX_TMPL_INTERFACE(Class,SuperClass,Abstract) \ + \ + SfxInterface* Class::s_pInterface = nullptr; \ + SfxInterface* Class::GetStaticInterface() \ + { \ + if ( !s_pInterface ) \ + { \ + s_pInterface = \ + new SfxInterface( \ + #Class, Abstract, GetInterfaceId(), \ + SuperClass::GetStaticInterface(), \ + a##Class##Slots_Impl[0], \ + sal_uInt16(sizeof(a##Class##Slots_Impl) / sizeof(SfxSlot) ) ); \ + InitInterface_Impl(); \ + } \ + return s_pInterface; \ + } \ + \ + SfxInterface* Class::GetInterface() const \ + { \ + return GetStaticInterface(); \ + } \ + \ + void Class::RegisterInterface(const SfxModule* pMod) \ + { \ + GetStaticInterface()->Register(pMod); \ + } + +#define SFX_IMPL_INTERFACE(Class,SuperClass) \ +SFX_TMPL_INTERFACE(Class,SuperClass,false) \ + +#define SFX_IMPL_SUPERCLASS_INTERFACE(Class,SuperClass) \ +SFX_TMPL_INTERFACE(Class,SuperClass,true) \ + +enum class SfxVisibilityFlags { + Invisible = 0x0000, // Never visible + Viewer = 0x0040, + ReadonlyDoc = 0x0400, + Standard = 0x1000, + FullScreen = 0x2000, + Client = 0x4000, + Server = 0x8000, +}; +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/AsynchronousCall.hxx b/include/sfx2/sidebar/AsynchronousCall.hxx new file mode 100644 index 000000000..0f2377abc --- /dev/null +++ b/include/sfx2/sidebar/AsynchronousCall.hxx @@ -0,0 +1,52 @@ +/* -*- 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 + +struct ImplSVEvent; + +namespace sfx2::sidebar +{ +/** A simple asynchronous call via Application::PostUserCall. +*/ +class AsynchronousCall +{ +public: + typedef ::std::function Action; + + AsynchronousCall(const Action& rAction); + ~AsynchronousCall(); + + void RequestCall(); + void CancelRequest(); + void Sync(); + +private: + Action maAction; + ImplSVEvent* mnCallId; + + DECL_LINK(HandleUserCall, void*, void); +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Context.hxx b/include/sfx2/sidebar/Context.hxx new file mode 100644 index 000000000..f4ca42d75 --- /dev/null +++ b/include/sfx2/sidebar/Context.hxx @@ -0,0 +1,58 @@ +/* -*- 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 + +namespace sfx2::sidebar +{ +class SFX2_DLLPUBLIC Context +{ +public: + OUString msApplication; + OUString msContext; + + Context(); + Context(const OUString& rsApplication, const OUString& rsContext); + + /** When two contexts are matched against each other, then + application or context name may have the wildcard value 'any'. + In order to prefer matches without wildcards over matches with + wildcards we introduce an integer evaluation for matches. + */ + const static sal_Int32 NoMatch; + const static sal_Int32 OptimalMatch; + const static sal_Int32 ApplicationWildcardMatch; + const static sal_Int32 ContextWildcardMatch; + + /** Return the numeric value that describes how good the match + between two contexts is. + Smaller values represent better matches. + */ + sal_Int32 EvaluateMatch(const Context& rOther) const; + + bool operator==(const Context& rOther) const; + bool operator!=(const Context& rOther) const; +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/ControllerItem.hxx b/include/sfx2/sidebar/ControllerItem.hxx new file mode 100644 index 000000000..a8f82195a --- /dev/null +++ b/include/sfx2/sidebar/ControllerItem.hxx @@ -0,0 +1,79 @@ +/* -*- 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 + +namespace com::sun::star::lang { class XComponent; } + + +namespace sfx2::sidebar { + +/** The sfx2::sidebar::ControllerItem is a wrapper around the + SfxControllerItem that becomes necessary to allow objects (think + sidebar panels) to receive state changes without having one + SfxControllerItem per supported item as base class (which is not + possible in C++ anyway). + + It also gives access to the label and icon of a slot/command. +*/ +class SFX2_DLLPUBLIC ControllerItem final + : public SfxControllerItem +{ +public: + class SFX2_DLLPUBLIC ItemUpdateReceiverInterface + { + public: + virtual void NotifyItemUpdate( + const sal_uInt16 nSId, + const SfxItemState eState, + const SfxPoolItem* pState) = 0; + virtual void GetControlState( + const sal_uInt16 nSId, + boost::property_tree::ptree& rState) = 0; + virtual ~ItemUpdateReceiverInterface(); + }; + + /** This is the simpler constructor variant that still exists for + compatibility reasons. Note that GetLabel() and GetIcon() will + return empty strings/images. + */ + ControllerItem ( + const sal_uInt16 nId, + SfxBindings &rBindings, + ItemUpdateReceiverInterface& rItemUpdateReceiver); + + virtual ~ControllerItem() override; + + /** Force the controller item to call its NotifyItemUpdate + callback with up-to-date data. + */ + void RequestUpdate(); + +private: + + virtual void StateChangedAtToolBoxControl (sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem* pState) override; + virtual void GetControlState (sal_uInt16 nSId, boost::property_tree::ptree& rState) override; + + ItemUpdateReceiverInterface& mrItemUpdateReceiver; +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Deck.hxx b/include/sfx2/sidebar/Deck.hxx new file mode 100644 index 000000000..fe73e6332 --- /dev/null +++ b/include/sfx2/sidebar/Deck.hxx @@ -0,0 +1,87 @@ +/* -*- 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 + +namespace sfx2::sidebar +{ +class DeckDescriptor; +class DeckTitleBar; +class SidebarDockingWindow; + +/** This is the parent window of the panels. + It displays the deck title. + + A deck consists of multiple panels. + E.g. Properties, Styles, Navigator. +*/ +class Deck final : public InterimItemWindow +{ +public: + Deck(const DeckDescriptor& rDeckDescriptor, SidebarDockingWindow* pParentWindow, + const std::function& rCloserAction); + virtual ~Deck() override; + virtual void dispose() override; + + const OUString& GetId() const { return msId; } + + DeckTitleBar* GetTitleBar() const; + tools::Rectangle GetContentArea() const; + void ResetPanels(SharedPanelContainer&& rPanels); + const SharedPanelContainer& GetPanels() const { return maPanels; } + + std::shared_ptr GetPanel(std::u16string_view panelId); + + void RequestLayout(); + weld::Widget* GetPanelParentWindow(); + + /** Try to make the panel completely visible. + When the whole panel does not fit then make its top visible + and it off at the bottom. + */ + void ShowPanel(const Panel& rPanel); + + virtual void DataChanged(const DataChangedEvent& rEvent) override; + + virtual void DumpAsPropertyTree(tools::JsonWriter&) override; + + sal_Int32 GetMinimalWidth() const { return mnMinimalWidth; } + +private: + void RequestLayoutInternal(); + +private: + const OUString msId; + sal_Int32 mnMinimalWidth; + sal_Int32 mnScrolledWindowExtraWidth; + sal_Int32 mnMinimalHeight; + SharedPanelContainer maPanels; + + VclPtr mxParentWindow; + std::unique_ptr mxTitleBar; + std::unique_ptr mxVerticalScrollBar; + std::unique_ptr mxContents; +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/FocusManager.hxx b/include/sfx2/sidebar/FocusManager.hxx new file mode 100644 index 000000000..c51ccbfa8 --- /dev/null +++ b/include/sfx2/sidebar/FocusManager.hxx @@ -0,0 +1,140 @@ +/* -*- 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 + +namespace weld { +class Widget; +} + +namespace sfx2::sidebar { + +class DeckTitleBar; + +/** Concentrate all focus handling in this class. + + There is one ring of windows that accept the input focus which are + cycled through with the arrow keys: + - the closer in the deck title (present only when docked) + - the panel title bars + - the tab bar items + + When the focus is in a panel title then focus travels over + - the panel title + - the panel closer + - the panel content + + Once the focus is in the panel content then focus cycles through + all controls inside the panel but not back to the title bar of + the panel. Escape places the focus back in the panel title. +*/ +class FocusManager +{ +public: + FocusManager(const std::function& rShowPanelFunctor); + ~FocusManager(); + + /** Forget all panels and buttons. Remove all window listeners. + */ + void Clear(); + + /** Transfer the focus into the sidebar tree of windows. This is + typically called from the SidebarChildWindow as result of + pressing the F6 key. + */ + void GrabFocus(); + void GrabFocusPanel(); + + void SetDeck(Deck* pDeck); + void SetPanels(const SharedPanelContainer& rPanels); + void SetButtons(const std::vector& rButtons); + +private: + VclPtr mxDeck; + DeckTitleBar* mpDeckTitleBar; + SharedPanelContainer maPanels; + std::vector maButtons; + const std::function maShowPanelFunctor; + + enum PanelComponent + { + PC_DeckToolBox, + PC_PanelTitle, + PC_PanelToolBox, + PC_PanelContent, + PC_TabBar, + PC_None + }; + class FocusLocation + { + public: + PanelComponent meComponent; + sal_Int32 mnIndex; + FocusLocation(const PanelComponent eComponent, const sal_Int32 nIndex); + }; + + /** Listen for key events for panels and buttons. + */ + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + + void ClearPanels(); + void ClearButtons(); + + /** Let the focus manager listen for window events for the given + window. + */ + void RegisterWindow(weld::Widget& rWidget); + static void UnregisterWindow(weld::Widget& rWidget); + + void FocusDeckTitle(); + bool IsDeckTitleVisible() const; + bool IsPanelTitleVisible(const sal_Int32 nPanelIndex) const; + + /** Set the focus to the title bar of the panel or, if the + title bar is not visible, directly to the panel. + @param nPanelIndex + Index of the panel to focus. + @param bFallbackToDeckTitle + When the panel title bar is not visible then The fallback + bias defines whether to focus the deck (true) or the panel + content (false) will be focused instead. + */ + void FocusPanel(const sal_Int32 nPanelIndex, + const bool bFallbackToDeckTitle); + + void FocusPanelContent(const sal_Int32 nPanelIndex); + void FocusButton(const sal_Int32 nButtonIndex); + void MoveFocusInsidePanel(const FocusLocation& rLocation, + const sal_Int32 nDirection); + bool MoveFocusInsideDeckTitle(const FocusLocation& rLocation, + const sal_Int32 nDirection); + + bool HandleKeyEvent(const vcl::KeyCode& rKeyCode, + const FocusLocation& rLocation); + + FocusLocation GetFocusLocation() const; + +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/IContextChangeReceiver.hxx b/include/sfx2/sidebar/IContextChangeReceiver.hxx new file mode 100644 index 000000000..784193c04 --- /dev/null +++ b/include/sfx2/sidebar/IContextChangeReceiver.hxx @@ -0,0 +1,40 @@ +/* -*- 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 + +namespace vcl +{ +class EnumContext; +} + +namespace sfx2::sidebar +{ +class SFX2_DLLPUBLIC IContextChangeReceiver +{ +public: + virtual ~IContextChangeReceiver(); + + virtual void HandleContextChange(const vcl::EnumContext& rContext) = 0; +}; + +} // end of namespace ::sd::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/ILayoutableWindow.hxx b/include/sfx2/sidebar/ILayoutableWindow.hxx new file mode 100644 index 000000000..344e7fd4f --- /dev/null +++ b/include/sfx2/sidebar/ILayoutableWindow.hxx @@ -0,0 +1,40 @@ +/* -*- 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 + +namespace sfx2::sidebar +{ +class SFX2_DLLPUBLIC ILayoutableWindow +{ +public: + virtual ~ILayoutableWindow(); + + /** Return the preferred height with the constraint, that the + window will be set to the given width. + */ + virtual css::ui::LayoutSize GetHeightForWidth(const sal_Int32 nWidth) = 0; +}; + +} // end of namespace ::sd::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Panel.hxx b/include/sfx2/sidebar/Panel.hxx new file mode 100644 index 000000000..1c0af8ad2 --- /dev/null +++ b/include/sfx2/sidebar/Panel.hxx @@ -0,0 +1,123 @@ +/* -*- 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 + +namespace com::sun::star::frame +{ +class XFrame; +} +namespace com::sun::star::ui +{ +class XSidebarPanel; +} +namespace com::sun::star::ui +{ +class XUIElement; +} +namespace com::sun::star::awt +{ +class XWindow; +} + +namespace sfx2::sidebar +{ +class Context; +class Deck; +class PanelDescriptor; +class PanelTitleBar; + +/** + * Multiple panels form a single deck. + * E.g. the Properties deck has panels like Styles, Character, paragraph. + */ +class SFX2_DLLPUBLIC Panel final +{ +public: + Panel(const PanelDescriptor& rPanelDescriptor, weld::Widget* pParentWindow, + const bool bIsInitiallyExpanded, Deck* pDeck, + const std::function& rContextAccess, + const css::uno::Reference& rxFrame); + + ~Panel(); + + PanelTitleBar* GetTitleBar() const; + weld::Box* GetContents() const; + void Show(bool bShow); + bool IsTitleBarOptional() const { return mbIsTitleBarOptional; } + void SetUIElement(const css::uno::Reference& rxElement); + const css::uno::Reference& GetPanelComponent() const + { + return mxPanelComponent; + } + const css::uno::Reference& GetElementParentWindow(); + css::uno::Reference GetElementWindow(); + void SetExpanded(const bool bIsExpanded); + bool IsExpanded() const { return mbIsExpanded; } + bool HasIdPredicate(std::u16string_view rsId) const; + const OUString& GetId() const { return msPanelId; } + const OUString& GetTitle() const { return msTitle; } + void TriggerDeckLayouting(); + + void SetHeightPixel(int nHeight); + + bool get_extents(tools::Rectangle& rExtents) const; + + /// Set whether a panel should be present but invisible / inactive + void SetLurkMode(bool bLurk); + bool IsLurking() const { return mbLurking; } + + void set_margin_top(int nMargin); + void set_margin_bottom(int nMargin); + void set_vexpand(bool bExpand); + + weld::Window* GetFrameWeld(); + + void DataChanged(); + +private: + std::unique_ptr mxBuilder; + const OUString msPanelId; + const OUString msTitle; + const bool mbIsTitleBarOptional; + const bool mbWantsAWT; + css::uno::Reference mxElement; + css::uno::Reference mxPanelComponent; + bool mbIsExpanded; + bool mbLurking; + const std::function maContextAccess; + const css::uno::Reference& mxFrame; + weld::Widget* mpParentWindow; + VclPtr mxDeck; + std::unique_ptr mxContainer; + std::unique_ptr mxTitleBar; + std::unique_ptr mxContents; + css::uno::Reference mxXWindow; + + DECL_DLLPRIVATE_LINK(DumpAsPropertyTreeHdl, tools::JsonWriter&, void); +}; + +typedef std::vector> SharedPanelContainer; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/PanelLayout.hxx b/include/sfx2/sidebar/PanelLayout.hxx new file mode 100644 index 000000000..301159362 --- /dev/null +++ b/include/sfx2/sidebar/PanelLayout.hxx @@ -0,0 +1,52 @@ +/* -*- 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/. + */ + +#pragma once + +#include +#include + +class DataChangedEvent; +class VclSimpleEvent; +namespace sfx2 { namespace sidebar { class Panel; } } +namespace tools { class JsonWriter; } + +/// This class is the base for the Widget Layout-based sidebar panels. +class SFX2_DLLPUBLIC PanelLayout +{ +protected: + std::unique_ptr m_xBuilder; + std::unique_ptr m_xContainer; + sfx2::sidebar::Panel* m_pPanel; + + virtual void DataChanged(const DataChangedEvent& rEvent); + virtual void DumpAsPropertyTree(tools::JsonWriter&); + + virtual weld::Window* GetFrameWeld() const; + +private: + DECL_DLLPRIVATE_LINK(DataChangedEventListener, VclSimpleEvent&, void); + DECL_DLLPRIVATE_LINK(DumpAsPropertyTreeHdl, tools::JsonWriter&, void); + +public: + PanelLayout(weld::Widget* pParent, const OString& rID, const OUString& rUIXMLDescription); + + void SetPanel(sfx2::sidebar::Panel* pPanel); + + virtual ~PanelLayout(); + + Size get_preferred_size() const + { + return m_xContainer->get_preferred_size(); + } + + void queue_resize(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/ResourceManager.hxx b/include/sfx2/sidebar/ResourceManager.hxx new file mode 100644 index 000000000..9ac1130cc --- /dev/null +++ b/include/sfx2/sidebar/ResourceManager.hxx @@ -0,0 +1,132 @@ +/* -*- 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 + +namespace com::sun::star::frame { class XController; } +namespace com::sun::star::frame { class XModel; } +namespace sfx2::sidebar { class DeckDescriptor; } +namespace sfx2::sidebar { class PanelDescriptor; } + +namespace sfx2::sidebar { + +class Context; +class ContextList; + +/** Read the content of the Sidebar.xcu file and provide access + methods so that the sidebar can easily decide which content panels + to display for a certain context. +*/ +class SFX2_DLLPUBLIC ResourceManager +{ +public: + + ResourceManager(); + ~ResourceManager(); + + std::shared_ptr GetDeckDescriptor(std::u16string_view rsDeckId) const; + std::shared_ptr GetPanelDescriptor(std::u16string_view rsPanelId) const; + + void UpdateModel(const css::uno::Reference& xModel); + + void InitDeckContext(const Context& rContex); + void SaveDecksSettings(const Context& rContext); + void SaveDeckSettings(const DeckDescriptor* pDeckDesc); + void SaveLastActiveDeck(const Context& rContext, const OUString& rActiveDeck); + + void disposeDecks(); + + class DeckContextDescriptor + { + public: + OUString msId; + bool mbIsEnabled; + }; + typedef std::vector DeckContextDescriptorContainer; + + class PanelContextDescriptor + { + public: + OUString msId; + OUString msMenuCommand; + bool mbIsInitiallyVisible; + bool mbShowForReadOnlyDocuments; + }; + typedef std::vector PanelContextDescriptorContainer; + + const DeckContextDescriptorContainer& GetMatchingDecks( + DeckContextDescriptorContainer& rDeckDescriptors, + const Context& rContext, + const bool bIsDocumentReadOnly, + const css::uno::Reference& rxController); + + const PanelContextDescriptorContainer& GetMatchingPanels( + PanelContextDescriptorContainer& rPanelDescriptors, + const Context& rContext, + std::u16string_view rsDeckId, + const css::uno::Reference& rxController); + + const OUString& GetLastActiveDeck( const Context& rContext ); + void SetLastActiveDeck( const Context& rContext, const OUString& rsDeckId ); + + /** Remember the expansions state per panel and context. + */ + void StorePanelExpansionState(std::u16string_view rsPanelId, + const bool bExpansionState, + const Context& rContext); + +private: + + + typedef std::vector> DeckContainer; + DeckContainer maDecks; + + typedef std::vector> PanelContainer; + PanelContainer maPanels; + mutable std::set maProcessedApplications; + std::map maLastActiveDecks; + + void ReadDeckList(); + void ReadPanelList(); + void ReadLastActive(); + static void ReadContextList(const utl::OConfigurationNode& rNode, + ContextList& rContextList, + const OUString& rsDefaultMenuCommand); + + void ReadLegacyAddons(const css::uno::Reference& rxController); + static utl::OConfigurationTreeRoot GetLegacyAddonRootNode(const OUString& rsModuleName); + static void GetToolPanelNodeNames(std::vector& rMatchingNames, + const utl::OConfigurationTreeRoot& aRoot); + bool IsDeckEnabled(std::u16string_view rsDeckId, + const Context& rContext, + const css::uno::Reference& rxController); + + std::shared_ptr ImplGetDeckDescriptor(std::u16string_view rsDeckId) const; + std::shared_ptr ImplGetPanelDescriptor(std::u16string_view rsPanelId) const; +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Sidebar.hxx b/include/sfx2/sidebar/Sidebar.hxx new file mode 100644 index 000000000..2520a80a4 --- /dev/null +++ b/include/sfx2/sidebar/Sidebar.hxx @@ -0,0 +1,67 @@ +/* -*- 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 + +namespace com::sun::star::frame { class XFrame; } +namespace com::sun::star::uno { template class Reference; } + + +namespace sfx2::sidebar { + +/** Accept requests for switching to certain panels or decks. +*/ +class SFX2_DLLPUBLIC Sidebar +{ +public: + static void ToggleDeck(std::u16string_view rsDeckId, SfxViewFrame *pViewFrame); + + /** Switch to the deck that contains the specified panel and make + sure that the panel is visible (expanded and scrolled into the + visible area.) + Note that most of the work is done asynchronously and that + this function probably returns before the requested panel is visible. + */ + static void ShowPanel ( + std::u16string_view rsPanelId, + const css::uno::Reference& rxFrame, bool bFocus = false); + + /** Switch to the deck that contains the specified panel and toggle + the visibility of the panel (expanded and scrolled into the + visible area when visible) + Note that most of the work is done asynchronously and that + this function probably returns before the requested panel is visible. + */ + static void TogglePanel ( + std::u16string_view rsPanelId, + const css::uno::Reference& rxFrame); + + static bool IsPanelVisible( + std::u16string_view rsPanelId, + const css::uno::Reference& rxFrame); +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarChildWindow.hxx b/include/sfx2/sidebar/SidebarChildWindow.hxx new file mode 100644 index 000000000..279aa79b5 --- /dev/null +++ b/include/sfx2/sidebar/SidebarChildWindow.hxx @@ -0,0 +1,46 @@ +/* -*- 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 + + +namespace sfx2::sidebar { + +/** Outer container of the sidebar window. + + Has to be registered for every application via the + RegisterChildWindow() method from the RegisterControllers() method + of the applications DLL. +*/ +class SFX2_DLLPUBLIC SidebarChildWindow final : public SfxChildWindow +{ +public: + SidebarChildWindow(vcl::Window* pParent, sal_uInt16 nId, + SfxBindings* pBindings, SfxChildWinInfo* pInfo); + + SFX_DECL_CHILDWINDOW_WITHID(SidebarChildWindow); + + static sal_Int32 GetDefaultWidth(vcl::Window const * pWindow); +}; + + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx new file mode 100644 index 000000000..8d8dcf215 --- /dev/null +++ b/include/sfx2/sidebar/SidebarController.hxx @@ -0,0 +1,302 @@ +/* -*- 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 +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace com::sun::star::awt { class XWindow; } +namespace com::sun::star::frame { class XDispatch; } +namespace com::sun::star::ui { class XUIElement; } + +typedef comphelper::WeakComponentImplHelper < + css::ui::XContextChangeEventListener, + css::beans::XPropertyChangeListener, + css::ui::XSidebar, + css::frame::XStatusListener, + css::frame::XFrameActionListener + > SidebarControllerInterfaceBase; + +class SfxSplitWindow; +class SfxViewShell; + +namespace sfx2::sidebar { + +class DeckDescriptor; +class SidebarDockingWindow; + +class SFX2_DLLPUBLIC SidebarController final + : public SidebarControllerInterfaceBase +{ +public: + static rtl::Reference create(SidebarDockingWindow* pParentWindow, + const SfxViewFrame* pViewFrame); + virtual ~SidebarController() override; + SidebarController(const SidebarController&) = delete; + SidebarController& operator=( const SidebarController& ) = delete; + + /** Return the SidebarController object that is associated with + the given XFrame. + @return + When there is no SidebarController object for the given + XFrame then is returned. + */ + static SidebarController* GetSidebarControllerForFrame ( + const css::uno::Reference& rxFrame); + + static void registerSidebarForFrame(SidebarController* pController, const css::uno::Reference& xFrame); + + static void unregisterSidebarForFrame(SidebarController* pController, const css::uno::Reference& xFrame); + + // ui::XContextChangeEventListener + virtual void SAL_CALL notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) override; + + // XEventListener + virtual void SAL_CALL disposing (const css::lang::EventObject& rEventObject) override; + + // beans::XPropertyChangeListener + virtual void SAL_CALL propertyChange (const css::beans::PropertyChangeEvent& rEvent) override; + + // frame::XStatusListener + virtual void SAL_CALL statusChanged (const css::frame::FeatureStateEvent& rEvent) override; + + // frame::XFrameActionListener + virtual void SAL_CALL frameAction (const css::frame::FrameActionEvent& rEvent) override; + + // ui::XSidebar + virtual void SAL_CALL requestLayout() override; + + void NotifyResize(); + + /** In some situations it is necessary to force an update of the + current deck and its panels. One reason is a change of the + view scale. Some panels can handle this only when + constructed. In this case we have to a context change and + also force that all panels are destroyed and created new. + */ + const static sal_Int32 SwitchFlag_NoForce = 0x00; + const static sal_Int32 SwitchFlag_ForceSwitch = 0x01; + const static sal_Int32 SwitchFlag_ForceNewDeck = 0x02; + const static sal_Int32 SwitchFlag_ForceNewPanels = 0x02; + + void OpenThenSwitchToDeck(std::u16string_view rsDeckId); + void OpenThenToggleDeck(const OUString& rsDeckId); + + /** Show only the tab bar, not the deck. + */ + void RequestCloseDeck(); + + /** Open the deck area and restore the parent window to its old width. + */ + void RequestOpenDeck(); + + /** Returns true when the given deck is the currently visible deck + */ + bool IsDeckVisible(std::u16string_view rsDeckId); + + bool IsDeckOpen(const sal_Int32 nIndex = -1); + + FocusManager& GetFocusManager() { return maFocusManager;} + + ResourceManager* GetResourceManager() { return mpResourceManager.get();} + + // std::unique_ptr GetResourceManager() { return mpResourceManager;} + + const Context& GetCurrentContext() const { return maCurrentContext;} + bool IsDocumentReadOnly (void) const { return mbIsDocumentReadOnly;} + + void SwitchToDeck(std::u16string_view rsDeckId); + void SwitchToDefaultDeck(); + bool WasFloatingDeckClosed() const { return mbFloatingDeckClosed; } + void SetFloatingDeckClosed(bool bWasClosed) { mbFloatingDeckClosed = bWasClosed; } + + void CreateDeck(std::u16string_view rDeckId); + void CreateDeck(std::u16string_view rDeckId, const Context& rContext, bool bForceCreate = false); + + ResourceManager::DeckContextDescriptorContainer GetMatchingDecks(); + ResourceManager::PanelContextDescriptorContainer GetMatchingPanels(std::u16string_view rDeckId); + + void notifyDeckTitle(std::u16string_view targetDeckId); + + void updateModel(const css::uno::Reference& xModel); + + void disposeDecks(); + + void FadeIn(); + void FadeOut(); + + tools::Rectangle GetDeckDragArea() const; + + css::uno::Reference const & getXFrame() const {return mxFrame;} + + sal_Int32 getMaximumWidth() const { return mnMaximumSidebarWidth; } + void setMaximumWidth(sal_Int32 nMaximumWidth) { mnMaximumSidebarWidth = nMaximumWidth; } + + void saveDeckState(); + + void SyncUpdate(); + + bool hasChartContextCurrently() const; + + static SidebarController* GetSidebarControllerForView(const SfxViewShell* pViewShell); + +private: + SidebarController(SidebarDockingWindow* pParentWindow, const SfxViewFrame* pViewFrame); + + VclPtr mpCurrentDeck; + VclPtr mpParentWindow; + const SfxViewFrame* mpViewFrame; + css::uno::Reference mxFrame; + VclPtr mpTabBar; + Context maCurrentContext; + Context maRequestedContext; + css::uno::Reference mxCurrentController; + /// Use a combination of SwitchFlag_* as value. + sal_Int32 mnRequestedForceFlags; + sal_Int32 mnMaximumSidebarWidth; + bool mbMinimumSidebarWidth; + OUString msCurrentDeckId; + AsynchronousCall maPropertyChangeForwarder; + AsynchronousCall maContextChangeUpdate; + css::uno::Reference mxThemePropertySet; + + /** Two flags control whether the deck is displayed or if only the + tab bar remains visible. + The mbIsDeckOpen flag stores the current state while + mbIsDeckRequestedOpen stores how this state should be. User + actions like clicking on the deck closer affect the + mbIsDeckRequestedOpen. Normally both flags have the same + value. A document being read-only can prevent the deck from opening. + */ + ::std::optional mbIsDeckRequestedOpen; + ::std::optional mbIsDeckOpen; + + bool mbFloatingDeckClosed; + + /** Before the deck is closed the sidebar width is saved into this variable, + so that it can be restored when the deck is reopened. + */ + sal_Int32 mnSavedSidebarWidth; + FocusManager maFocusManager; + css::uno::Reference mxReadOnlyModeDispatch; + bool mbIsDocumentReadOnly; + VclPtr mpSplitWindow; + /** When the user moves the splitter then we remember the + width at that time. + */ + sal_Int32 mnWidthOnSplitterButtonDown; + /** Control that is temporarily used as replacement for the deck + to indicate that when the current mouse drag operation ends, the + sidebar will only show the tab bar. + */ + VclPtr mpCloseIndicator; + + DECL_DLLPRIVATE_LINK(WindowEventHandler, VclWindowEvent&, void); + /** Make maRequestedContext the current context. + */ + void UpdateConfigurations(); + + css::uno::Reference CreateUIElement ( + const css::uno::Reference& rxWindow, + const OUString& rsImplementationURL, + const bool bWantsCanvas, + const Context& rContext); + + void CreatePanels( + std::u16string_view rDeckId, + const Context& rContext); + std::shared_ptr CreatePanel ( + std::u16string_view rsPanelId, + weld::Widget* pParentWindow, + const bool bIsInitiallyExpanded, + const Context& rContext, + const VclPtr& pDeck); + + void SwitchToDeck ( + const DeckDescriptor& rDeckDescriptor, + const Context& rContext); + + void ShowPopupMenu ( + weld::Menu& rMainMenu, + weld::Menu& rSubMenu, + const ::std::vector& rMenuData) const; + void PopulatePopupMenus( + weld::Menu& rMainButton, + weld::Menu& rSubMenu, + const ::std::vector& rMenuData) const; + DECL_DLLPRIVATE_LINK(OnMenuItemSelected, const OString&, void); + DECL_DLLPRIVATE_LINK(OnSubMenuItemSelected, const OString&, void); + void BroadcastPropertyChange(); + + /** The close of the deck changes the width of the child window. + That is only possible if there is no other docking window docked above or below the sidebar. + Return whether the width of the child window can be modified. + */ + bool CanModifyChildWindowWidth(); + + /** Set the child window container to a new width. + Return the old width. + */ + sal_Int32 SetChildWindowWidth (const sal_Int32 nNewWidth); + + /** Update the icons displayed in the title bars of the deck and + the panels. This is called once when a deck is created and + every time when a data change event is processed. + */ + void UpdateTitleBarIcons(); + + void UpdateDeckOpenState(); + void RestrictWidth (sal_Int32 nWidth); + SfxSplitWindow* GetSplitWindow(); + void ProcessNewWidth (const sal_Int32 nNewWidth); + void UpdateCloseIndicator (const bool bIsIndicatorVisible); + + /** Typically called when a panel is focused via keyboard. + Tries to scroll the deck up or down to make the given panel + completely visible. + */ + void ShowPanel (const Panel& rPanel); + + virtual void disposing(std::unique_lock&) override; + + std::unique_ptr mpResourceManager; + +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarDockingWindow.hxx b/include/sfx2/sidebar/SidebarDockingWindow.hxx new file mode 100644 index 000000000..9bad1f5a8 --- /dev/null +++ b/include/sfx2/sidebar/SidebarDockingWindow.hxx @@ -0,0 +1,66 @@ +/* -*- 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 + +class SfxViewShell; + +namespace svt { class AcceleratorExecute; } + +namespace sfx2::sidebar { + +class SidebarChildWindow; + +class SidebarController; + +class SFX2_DLLPUBLIC SidebarDockingWindow final : public SfxDockingWindow +{ +public: + SidebarDockingWindow(SfxBindings* pBindings, SidebarChildWindow& rChildWindow, + vcl::Window* pParent, WinBits nBits); + virtual ~SidebarDockingWindow() override; + virtual void dispose() override; + virtual bool EventNotify(NotifyEvent& rEvent) override; + virtual bool Close() override; + + /// Force generation of all panels by completion. + void SyncUpdate(); + + auto& GetSidebarController() const { return mpSidebarController; } + using SfxDockingWindow::Close; + +private: + // Window overridables + virtual void GetFocus() override; + + virtual SfxChildAlignment CheckAlignment ( + SfxChildAlignment eCurrentAlignment, + SfxChildAlignment eRequestedAlignment) override; + + ::rtl::Reference mpSidebarController; + bool mbIsReadyToDrag; + std::unique_ptr mpAccel; +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarModelUpdate.hxx b/include/sfx2/sidebar/SidebarModelUpdate.hxx new file mode 100644 index 000000000..988478bce --- /dev/null +++ b/include/sfx2/sidebar/SidebarModelUpdate.hxx @@ -0,0 +1,33 @@ +/* -*- 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/. + */ + +#pragma once + +#include + +namespace com::sun::star::frame +{ +class XModel; +} +namespace com::sun::star::uno +{ +template class Reference; +} + +namespace sfx2::sidebar +{ +class SFX2_DLLPUBLIC SidebarModelUpdate +{ +public: + virtual ~SidebarModelUpdate(); + virtual void updateModel(css::uno::Reference xModel) = 0; +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarPanelBase.hxx b/include/sfx2/sidebar/SidebarPanelBase.hxx new file mode 100644 index 000000000..b00d4ca3c --- /dev/null +++ b/include/sfx2/sidebar/SidebarPanelBase.hxx @@ -0,0 +1,102 @@ +/* -*- 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 +#include + +class PanelLayout; + +namespace sfx2::sidebar { + +class Panel; + +typedef comphelper::WeakComponentImplHelper + SidebarPanelBaseInterfaceBase; + +/** Base class for sidebar panels that provides some convenience + functionality. +*/ +class SFX2_DLLPUBLIC SidebarPanelBase final : public SidebarPanelBaseInterfaceBase +{ +public: + static css::uno::Reference Create(const OUString& rsResourceURL, + const css::uno::Reference& rxFrame, + std::unique_ptr xControl, + const css::ui::LayoutSize& rLayoutSize); + + // XContextChangeEventListener + virtual void SAL_CALL notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) override; + + // XEventListener + virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent) override; + + // XUIElement + virtual css::uno::Reference SAL_CALL getFrame() override; + virtual OUString SAL_CALL getResourceURL() override; + virtual sal_Int16 SAL_CALL getType() override; + virtual css::uno::Reference SAL_CALL getRealInterface() override; + + // XToolPanel + virtual css::uno::Reference SAL_CALL createAccessible( + const css::uno::Reference& rxParentAccessible) override; + virtual css::uno::Reference SAL_CALL getWindow() override; + + // XSidebarPanel + virtual css::ui::LayoutSize SAL_CALL getHeightForWidth(sal_Int32 nWidth) override; + virtual sal_Int32 SAL_CALL getMinimalWidth() override; + + // XUpdateModel + virtual void SAL_CALL updateModel(const css::uno::Reference& xModel) override; + + void SetParentPanel(sfx2::sidebar::Panel* pPanel); + +private: + SidebarPanelBase(const OUString& rsResourceURL, const css::uno::Reference& rxFrame, + std::unique_ptr xControl, const css::ui::LayoutSize& rLayoutSize); + virtual ~SidebarPanelBase() override; + SidebarPanelBase(const SidebarPanelBase&) = delete; + SidebarPanelBase& operator=( const SidebarPanelBase& ) = delete; + + virtual void disposing(std::unique_lock&) override; + + css::uno::Reference mxFrame; + std::unique_ptr mxControl; + const OUString msResourceURL; + const css::ui::LayoutSize maLayoutSize; +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/TabBar.hxx b/include/sfx2/sidebar/TabBar.hxx new file mode 100644 index 000000000..5cc092c23 --- /dev/null +++ b/include/sfx2/sidebar/TabBar.hxx @@ -0,0 +1,136 @@ +/* -*- 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 + +namespace com::sun::star::frame { class XFrame; } + +namespace svt { class AcceleratorExecute; } + +namespace weld { class Toolbar; } + +namespace sfx2::sidebar { + +class FocusManager; +class SidebarController; + +/** The tab bar is the container for the individual tabs. +*/ +class TabBar final : public InterimItemWindow +{ +public: + /** DeckMenuData has entries for display name, and a flag: + - isCurrentDeck for the deck selection data + - isEnabled for the show/hide menu + */ + class DeckMenuData + { + public: + OUString msDisplayName; + bool mbIsCurrentDeck; + bool mbIsActive; + bool mbIsEnabled; + }; + typedef ::std::function& rMenuData)> PopupMenuProvider; + TabBar ( + vcl::Window* pParentWindow, + const css::uno::Reference& rxFrame, + const ::std::function& rDeckActivationFunctor, + const PopupMenuProvider& rPopupMenuProvider, + SidebarController* rParentSidebarController); + + weld::Container* GetContainer() { return m_xContainer.get(); } + + virtual ~TabBar() override; + virtual void dispose() override; + + virtual void DataChanged (const DataChangedEvent& rDataChangedEvent) override; + virtual bool EventNotify (NotifyEvent& rEvent) override; + + static sal_Int32 GetDefaultWidth(); + + void SetDecks ( + const ResourceManager::DeckContextDescriptorContainer& rDecks); + void HighlightDeck (std::u16string_view rsDeckId); + void RemoveDeckHighlight (); + OUString const & GetDeckIdForIndex (const sal_Int32 nIndex) const; + void ToggleHideFlag (const sal_Int32 nIndex); + void RestoreHideFlags(); + + void UpdateFocusManager (FocusManager& rFocusManager); + + /// Enables/Disables the menu button. Used by LoKit. + void EnableMenuButton(const bool bEnable); + +private: + css::uno::Reference mxFrame; + + // This unusual auxiliary builder is because without a toplevel GtkWindow + // gtk will warn on loading a .ui with an accelerator defined, so use a + // temporary toplevel to suppress that and move the contents after load + std::unique_ptr mxAuxBuilder; + std::unique_ptr mxTempToplevel; + std::unique_ptr mxContents; + + std::unique_ptr mxMenuButton; + std::unique_ptr mxMainMenu; + std::unique_ptr mxSubMenu; + std::unique_ptr mxMeasureBox; + class Item + { + private: + TabBar& mrTabBar; + std::unique_ptr mxBuilder; + public: + Item(TabBar& rTabBar); + ~Item(); + DECL_LINK(HandleClick, const OString&, void); + std::unique_ptr mxButton; + OUString msDeckId; + ::std::function maDeckActivationFunctor; + bool mbIsHidden; + bool mbIsHiddenByDefault; + }; + typedef ::std::vector> ItemContainer; + ItemContainer maItems; + const ::std::function maDeckActivationFunctor; + PopupMenuProvider maPopupMenuProvider; + + void CreateTabItem(weld::Toolbar& rButton, const DeckDescriptor& rDeckDescriptor); + css::uno::Reference GetItemImage(const DeckDescriptor& rDeskDescriptor) const; + void UpdateButtonIcons(); + + DECL_LINK(OnToolboxClicked, weld::Toggleable&, void); + + SidebarController* pParentSidebarController; + std::unique_ptr mpAccel; + +}; + + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Theme.hxx b/include/sfx2/sidebar/Theme.hxx new file mode 100644 index 000000000..a3f827f4a --- /dev/null +++ b/include/sfx2/sidebar/Theme.hxx @@ -0,0 +1,184 @@ +/* -*- 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 + + +namespace sfx2::sidebar { + +typedef comphelper::WeakComponentImplHelper < + css::beans::XPropertySet, + css::beans::XPropertySetInfo + > ThemeInterfaceBase; + +/** Simple collection of colors, gradients, fonts that define the + look of the sidebar and its controls. +*/ +class SFX2_DLLPUBLIC Theme final + : public ThemeInterfaceBase +{ +public: + enum ThemeItem + { + Begin_, + Pre_Color_ = Begin_, + + AnyItem_ = Pre_Color_, + + Image_Color_, + + Color_Highlight, + Color_HighlightText, + Color_DeckBackground, + Color_DeckTitleBarBackground, + Color_PanelBackground, + Color_PanelTitleBarBackground, + Color_TabBarBackground, + + Color_Int_, + + Int_DeckBorderSize, + Int_DeckSeparatorHeight, + Int_DeckLeftPadding, + Int_DeckTopPadding, + Int_DeckRightPadding, + Int_DeckBottomPadding, + + Int_Bool_, + + Bool_UseSystemColors, + Bool_IsHighContrastModeActive, + + Post_Bool_, + End_=Post_Bool_ + }; + + static Color GetColor (const ThemeItem eItem); + static sal_Int32 GetInteger (const ThemeItem eItem); + + static bool IsHighContrastMode(); + + static void HandleDataChange(); + + void InitializeTheme(); + + Theme(); + virtual ~Theme() override; + Theme(const Theme&) = delete; + Theme& operator=( const Theme& ) = delete; + + virtual void disposing(std::unique_lock&) override; + + static css::uno::Reference GetPropertySet(); + + // beans::XPropertySet + virtual css::uno::Reference SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue ( + const OUString& rsPropertyName, + const css::uno::Any& rValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue ( + const OUString& rsPropertyName) override; + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rsPropertyName, + const css::uno::Reference& rxListener) override; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rsPropertyName, + const css::uno::Reference& rxListener) override; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rsPropertyName, + const css::uno::Reference& rxListener) override; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rsPropertyName, + const css::uno::Reference& rxListener) override; + + // beans::XPropertySetInfo + virtual css::uno::Sequence SAL_CALL getProperties() override; + virtual css::beans::Property SAL_CALL getPropertyByName (const OUString& rsName) override; + virtual sal_Bool SAL_CALL hasPropertyByName (const OUString& rsName) override; + +private: + static Theme& GetCurrentTheme(); + + std::vector maColors; + std::vector maIntegers; + std::vector maBooleans; + bool mbIsHighContrastMode; + bool mbIsHighContrastModeSetManually; + + typedef std::unordered_map PropertyNameToIdMap; + PropertyNameToIdMap maPropertyNameToIdMap; + typedef std::vector PropertyIdToNameMap; + PropertyIdToNameMap maPropertyIdToNameMap; + typedef ::std::vector RawValueContainer; + RawValueContainer maRawValues; + + typedef std::vector > ChangeListenerContainer; + typedef std::map ChangeListeners; + ChangeListeners maChangeListeners; + typedef std::vector > VetoableListenerContainer; + typedef std::map VetoableListeners; + VetoableListeners maVetoableListeners; + + enum PropertyType + { + PT_Color, + PT_Integer, + PT_Boolean, + PT_Invalid + }; + + void SetupPropertyMaps(); + void UpdateTheme(); + static PropertyType GetPropertyType (const ThemeItem eItem); + static css::uno::Type const & GetCppuType (const PropertyType eType); + static sal_Int32 GetIndex ( + const ThemeItem eItem, + const PropertyType eType); + + VetoableListenerContainer* GetVetoableListeners ( + const ThemeItem eItem, + const bool bCreate); + ChangeListenerContainer* GetChangeListeners ( + const ThemeItem eItem, + const bool bCreate); + static bool DoVetoableListenersVeto ( + const VetoableListenerContainer* pListeners, + const css::beans::PropertyChangeEvent& rEvent); + static void BroadcastPropertyChange ( + const ChangeListenerContainer* pListeners, + const css::beans::PropertyChangeEvent& rEvent); + void ProcessNewValue ( + const css::uno::Any& rValue, + const ThemeItem eItem, + const PropertyType eType); +}; + + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/signaturestate.hxx b/include/sfx2/signaturestate.hxx new file mode 100644 index 000000000..d63498d1c --- /dev/null +++ b/include/sfx2/signaturestate.hxx @@ -0,0 +1,54 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_SIGNATURESTATE_HXX +#define INCLUDED_SFX2_SIGNATURESTATE_HXX + +#include + +#include + +enum class SignatureState +{ + // FIXME: Do these values have to be these, and given at all, or is this just cargo cult? + UNKNOWN = 0xffff, // used to be -1 when this was a sal_uInt16 + NOSIGNATURES = 0, + OK = 1, + BROKEN = 2, + // State was SignatureState::OK, but doc is modified now + INVALID = 3, + // signature is OK, but certificate could not be validated + NOTVALIDATED = 4, + // signature and certificate are ok, but not all files are signed, as it was the case in + // OOo 2.x - OOo 3.1.1. This state is only used together with document signatures. + PARTIAL_OK = 5, + /// Certificate could not be validated and the document is only partially signed. + NOTVALIDATED_PARTIAL_OK = 6 +}; + +namespace DocumentSignatures +{ +/** Get document signature state */ +SFX2_DLLPUBLIC SignatureState +getSignatureState(const css::uno::Sequence& aInfos); +} + +#endif // INCLUDED_SFX2_SIGNATURESTATE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/stbitem.hxx b/include/sfx2/stbitem.hxx new file mode 100644 index 000000000..67c88c687 --- /dev/null +++ b/include/sfx2/stbitem.hxx @@ -0,0 +1,134 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_STBITEM_HXX +#define INCLUDED_SFX2_STBITEM_HXX + +#include +#include +#include +#include +#include + +class SfxModule; +class SfxStatusBarControl; +class StatusBar; + +rtl::Reference SfxStatusBarControllerFactory( + const css::uno::Reference< css::frame::XFrame >& rFrame, + StatusBar* pStatusBar, + unsigned short nID, + const OUString& aCommandURL ); +typedef rtl::Reference (*SfxStatusBarControlCtor)( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ); + +struct SfxStbCtrlFactory +{ + SfxStatusBarControlCtor pCtor; + const std::type_info& nTypeId; + sal_uInt16 nSlotId; + + SfxStbCtrlFactory( SfxStatusBarControlCtor pTheCtor, + const std::type_info& nTheTypeId, sal_uInt16 nTheSlotId ): + pCtor(pTheCtor), + nTypeId(nTheTypeId), + nSlotId(nTheSlotId) + {} +}; + + +class CommandEvent; +class MouseEvent; +class UserDrawEvent; + +class SFX2_DLLPUBLIC SfxStatusBarControl: public svt::StatusbarController +{ + sal_uInt16 nSlotId; + sal_uInt16 nId; + VclPtr pBar; + +public: + // new controller API + // XInterface + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + +protected: + // XEventListener + using svt::StatusbarController::disposing; + + // XComponent + using svt::StatusbarController::dispose; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + // XStatusbarController + virtual sal_Bool SAL_CALL mouseButtonDown( const css::awt::MouseEvent& aMouseEvent ) override; + virtual sal_Bool SAL_CALL mouseMove( const css::awt::MouseEvent& aMouseEvent ) override; + virtual sal_Bool SAL_CALL mouseButtonUp( const css::awt::MouseEvent& aMouseEvent ) override; + virtual void SAL_CALL command( const css::awt::Point& aPos, + ::sal_Int32 nCommand, + sal_Bool bMouseEvent, + const css::uno::Any& aData ) override; + virtual void SAL_CALL paint( const css::uno::Reference< css::awt::XGraphics >& xGraphics, + const css::awt::Rectangle& rOutputRectangle, + ::sal_Int32 nStyle ) override; + virtual void SAL_CALL click( const css::awt::Point& aPos ) override; + virtual void SAL_CALL doubleClick( const css::awt::Point& aPos ) override; + + // Old sfx2 interface + virtual void StateChangedAtStatusBarControl( sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState ); + virtual void Click(); + virtual void Command( const CommandEvent& rCEvt ); + virtual bool MouseButtonDown( const MouseEvent & ); + virtual bool MouseMove( const MouseEvent & ); + virtual bool MouseButtonUp( const MouseEvent & ); + virtual void Paint( const UserDrawEvent &rUDEvt ); + + static sal_uInt16 convertAwtToVCLMouseButtons( sal_Int16 nAwtMouseButtons ); + +public: + SfxStatusBarControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar& rBar ); + virtual ~SfxStatusBarControl() override; + + sal_uInt16 GetSlotId() const { return nSlotId; } + sal_uInt16 GetId() const { return nId; } + StatusBar& GetStatusBar() const { return *pBar; } + + static rtl::Reference CreateControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar *pBar, SfxModule const * ); + static void RegisterStatusBarControl(SfxModule*, const SfxStbCtrlFactory&); + +}; + + +#define SFX_DECL_STATUSBAR_CONTROL() \ + static rtl::Reference CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ); \ + static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=nullptr) + +#define SFX_IMPL_STATUSBAR_CONTROL(Class, nItemClass) \ + rtl::Reference Class::CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ) \ + { return new Class( nSlotId, nId, rStb ); } \ + void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \ + { SfxStatusBarControl::RegisterStatusBarControl( pMod, SfxStbCtrlFactory( \ + Class::CreateImpl, typeid(nItemClass), nSlotId ) ); } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc new file mode 100644 index 000000000..e392b1d03 --- /dev/null +++ b/include/sfx2/strings.hrc @@ -0,0 +1,361 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_INC_STRINGS_HRC +#define INCLUDED_SFX2_INC_STRINGS_HRC + +#define NC_(Context, String) TranslateId(Context, reinterpret_cast(u8##String)) + +#define STR_TEMPLATE_FILTER NC_("STR_TEMPLATE_FILTER", "Templates") +#define STR_SAVEDOC NC_("STR_SAVEDOC", "~Save") +#define STR_SAVEASDOC NC_("STR_SAVEASDOC", "Save ~As...") +#define STR_SAVEACOPY NC_("STR_SAVEACOPY", "Save a Copy...") +#define STR_CLOSEDOC NC_("STR_CLOSEDOC", "~Close") +#define STR_OPEN NC_("STR_OPEN", "~Open") +#define STR_EDIT_TEMPLATE NC_("STR_EDIT_TEMPLATE", "~Edit") +#define STR_DEFAULT_TEMPLATE NC_("STR_DEFAULT_TEMPLATE", "Set as De~fault") +#define STR_RESET_DEFAULT NC_("STR_RESET_DEFAULT", "Reset De~fault") +#define STR_DELETE_TEMPLATE NC_("STR_DELETE_TEMPLATE", "~Delete") +#define STR_SFX_RENAME NC_("STR_SFX_RENAME", "~Rename") +#define STR_MOVE NC_("STR_ACTION_MOVE","~Move") +#define STR_EXPORT NC_("STR_ACTION_EXPORT","E~xport") +#define STR_CATEGORY_RENAME NC_("STR_CATEGORY_RENAME", "Ren~ame Category") +#define STR_RENAME_TEMPLATE NC_("STR_RENAME_TEMPLATE", "Enter new template name:") +#define STR_TEMPLATE_TOOLTIP NC_("STR_TEMPLATE_TOOLTIP", "Title: $1\nCategory: $2") +#define STR_TEMPLATE_SELECTION NC_("STR_TEMPLATE_SELECTION", "Select a Template") +#define STR_AUTOMATICVERSION NC_("STR_AUTOMATICVERSION", "Automatically saved version") +#define STR_EXPORTBUTTON NC_("STR_EXPORTBUTTON", "Export") +#define STR_LABEL_FILEFORMAT NC_("STR_LABEL_FILEFORMAT", "File format:") +#define STR_HIDDENINFO_CONTAINS NC_("STR_HIDDENINFO_CONTAINS", "This document contains:\n\n") +#define STR_HIDDENINFO_RECORDCHANGES NC_("STR_HIDDENINFO_RECORDCHANGES", "Recorded changes") +#define STR_HIDDENINFO_NOTES NC_("STR_HIDDENINFO_NOTES", "Notes") +#define STR_HIDDENINFO_DOCVERSIONS NC_("STR_HIDDENINFO_DOCVERSIONS", "Document versions") +#define STR_HIDDENINFO_CONTINUE_SAVING NC_("STR_HIDDENINFO_CONTINUE_SAVING", "Do you want to continue saving the document?") +#define STR_HIDDENINFO_CONTINUE_PRINTING NC_("STR_HIDDENINFO_CONTINUE_PRINTING", "Do you want to continue printing the document?") +#define STR_HIDDENINFO_CONTINUE_SIGNING NC_("STR_HIDDENINFO_CONTINUE_SIGNING", "Do you want to continue signing the document?") +#define STR_HIDDENINFO_CONTINUE_CREATEPDF NC_("STR_HIDDENINFO_CONTINUE_CREATEPDF", "Do you want to continue creating a PDF file?") +#define STR_NEW_FILENAME_SAVE NC_("STR_NEW_FILENAME_SAVE", "If you do not want to overwrite the original document, you should save your work under a new filename.") +// Used in the title of a shared document. +#define STR_SHARED NC_("STR_SHARED", " (shared)") +#define STR_XMLSEC_ODF12_EXPECTED NC_("STR_XMLSEC_ODF12_EXPECTED", "The document format version is set to ODF 1.1 (OpenOffice.org 2.x) in Tools-Options-Load/Save-General. Signing documents requires ODF 1.2 (OpenOffice.org 3.x).") +#define STR_XMLSEC_QUERY_SAVESIGNEDBEFORESIGN NC_("STR_XMLSEC_QUERY_SAVESIGNEDBEFORESIGN", "The document has to be saved before it can be signed. Saving the document removes all present signatures.\nDo you want to save the document?") +#define STR_QRYTEMPL_MESSAGE NC_("STR_QRYTEMPL_MESSAGE", "The template '$(ARG1)' on which this document is based, has been modified. Do you want to update the styles of the current document, using the modified template?") +#define STR_QRYTEMPL_UPDATE_BTN NC_("STR_QRYTEMPL_UPDATE_BTN", "~Update Styles") +#define STR_QRYTEMPL_KEEP_BTN NC_("STR_QRYTEMPL_KEEP_BTN", "~Keep Old Styles") +#define STR_CATEGORY_NEW NC_("STR_CATEGORY_NEW", "~New Category") +#define STR_CATEGORY_DELETE NC_("STR_CATEGORY_DELETE", "~Delete Category") +#define STR_MSG_EXPORT_SUCCESS NC_("STR_MSG_EXPORT_SUCCESS", "$1 templates successfully exported.") +#define STR_MSG_QUERY_COPY NC_("STR_MSG_QUERY_COPY", "$1 could not be moved to the category \"$2\". Do you want to copy the template instead?") +#define STR_CREATE_ERROR NC_("STR_CREATE_ERROR", "Cannot create category: $1") +#define STR_ERROR_SAVEAS NC_("STR_ERROR_SAVEAS", "Cannot save template: $1") +#define STR_INPUT_NEW NC_("STR_INPUT_NEW", "Enter new category name:") +#define STR_MSG_ERROR_LOCAL_MOVE NC_("STR_MSG_ERROR_LOCAL_MOVE", "Error moving the following templates to $1.\n$2") +#define STR_MSG_ERROR_EXPORT NC_("STR_MSG_ERROR_EXPORT", "Error exporting the following templates:\n$1") +#define STR_MSG_ERROR_IMPORT NC_("STR_MSG_ERROR_IMPORT", "Error importing the following templates to $1:\n$2") +#define STR_MSG_ERROR_DELETE_TEMPLATE NC_("STR_MSG_ERROR_DELETE_TEMPLATE", "The following templates cannot be deleted:\n$1") +#define STR_MSG_ERROR_DELETE_FOLDER NC_("STR_MSG_ERROR_DELETE_FOLDER", "The following folders cannot be deleted:\n$1") +#define STR_TOOLTIP_ERROR_RENAME_TEMPLATE NC_("STR_TOOLTIP_ERROR_RENAME_TEMPLATE", "There is another template with the name $1 in $2.") +#define STR_QMSG_SEL_FOLDER_DELETE NC_("STR_QMSG_SEL_FOLDER_DELETE", "Do you want to delete the selected category?") +#define STR_QMSG_TEMPLATE_OVERWRITE NC_("STR_QMSG_TEMPLATE_OVERWRITE", "A template named $1 already exists in $2. Do you want to overwrite it?") +#define STR_QMSG_SEL_TEMPLATE_DELETE NC_("STR_QMSG_SEL_TEMPLATE_DELETE", "Do you want to delete the selected templates?") +#define STR_QMSG_ERROR_OPENING_FILE NC_("STR_QMSG_ERROR_OPENING_FILE", "An error occurred during opening the file. This may be caused by incorrect file contents.\n") +#define STR_QMSG_ERROR_OPENING_FILE_DETAILS NC_("STR_QMSG_ERROR_OPENING_FILE_DETAILS", "The error details are:\n") +#define STR_QMSG_ERROR_OPENING_FILE_CONTINUE NC_("STR_QMSG_ERROR_OPENING_FILE_CONTINUE", "\nProceeding with import may cause data loss or corruption, and application may become unstable or crash.\n\nDo you want to ignore the error and attempt to continue loading the file?") + +#define STR_HELP_WINDOW_TITLE NC_("STR_HELP_WINDOW_TITLE", "%PRODUCTNAME Help") +#define STR_HELP_BUTTON_INDEX_ON NC_("STR_HELP_BUTTON_INDEX_ON", "Show Navigation Pane") +#define STR_HELP_BUTTON_INDEX_OFF NC_("STR_HELP_BUTTON_INDEX_OFF", "Hide Navigation Pane") +#define STR_HELP_BUTTON_START NC_("STR_HELP_BUTTON_START", "First Page") +#define STR_HELP_BUTTON_PREV NC_("STR_HELP_BUTTON_PREV", "Previous Page") +#define STR_HELP_BUTTON_NEXT NC_("STR_HELP_BUTTON_NEXT", "Next Page") +#define STR_HELP_BUTTON_PRINT NC_("STR_HELP_BUTTON_PRINT", "Print...") +#define STR_HELP_BUTTON_ADDBOOKMARK NC_("STR_HELP_BUTTON_ADDBOOKMARK", "Add to Bookmarks...") +#define STR_HELP_BUTTON_SEARCHDIALOG NC_("STR_HELP_BUTTON_SEARCHDIALOG", "Find on this Page...") +#define STR_HELP_BUTTON_SOURCEVIEW NC_("STR_HELP_BUTTON_SOURCEVIEW", "HTML Source") +#define STR_HELP_MENU_TEXT_SELECTION_MODE NC_("STR_HELP_MENU_TEXT_SELECTION_MODE", "Select Text") +#define STR_HELP_MENU_TEXT_COPY NC_("STR_HELP_MENU_TEXT_COPY", "~Copy") +#define STR_INFO_NOSEARCHRESULTS NC_("STR_INFO_NOSEARCHRESULTS", "No topics found.") +#define STR_INFO_NOSEARCHTEXTFOUND NC_("STR_INFO_NOSEARCHTEXTFOUND", "The text you entered was not found.") +#define RID_HELP_ONSTARTUP_TEXT NC_("RID_HELP_ONSTARTUP_TEXT", "~Display %PRODUCTNAME %MODULENAME Help at Startup") + +#define STR_NONAME NC_("STR_NONAME", "Untitled") +#define STR_STANDARD_SHORTCUT NC_("STR_STANDARD_SHORTCUT", "Standard") +#define STR_BYTES NC_("STR_BYTES", "Bytes") +#define STR_KB NC_("STR_KB", "kB") +#define STR_MB NC_("STR_MB", "MB") +#define STR_GB NC_("STR_GB", "GB") +#define STR_QUERY_LASTVERSION NC_("STR_QUERY_LASTVERSION", "Cancel all changes?") +#define STR_NO_WEBBROWSER_FOUND NC_("STR_NO_WEBBROWSER_FOUND", "Opening \"$(ARG1)\" failed with error code $(ARG2) and message: \"$(ARG3)\"\nMaybe no web browser could be found on your system. In that case, please check your Desktop Preferences or install a web browser (for example, Firefox) in the default location requested during the browser installation.") +#define STR_DANGEROUS_TO_OPEN NC_("STR_DANGEROUS_TO_OPEN", "It might be dangerous to open \"$(ARG1)\".\nDo you really want to open it?") +#define STR_NO_ABS_URI_REF NC_("STR_NO_ABS_URI_REF", "\"$(ARG1)\" cannot be passed to an external application to open it (e.g., it might not be an absolute URL, or might denote no existing file).") +#define STR_GID_INTERN NC_("STR_GID_INTERN", "Internal") +#define STR_GID_APPLICATION NC_("STR_GID_APPLICATION", "Application") +#define STR_GID_VIEW NC_("STR_GID_VIEW", "View") +#define STR_GID_DOCUMENT NC_("STR_GID_DOCUMENT", "Documents") +#define STR_GID_EDIT NC_("STR_GID_EDIT", "Edit") +#define STR_GID_MACRO NC_("STR_GID_MACRO", "BASIC") +#define STR_GID_OPTIONS NC_("STR_GID_OPTIONS", "Options") +#define STR_GID_MATH NC_("STR_GID_MATH", "Math") +#define STR_GID_NAVIGATOR NC_("STR_GID_NAVIGATOR", "Navigate") +#define STR_GID_INSERT NC_("STR_GID_INSERT", "Insert") +#define STR_GID_FORMAT NC_("STR_GID_FORMAT", "Format") +#define STR_GID_TEMPLATE NC_("STR_GID_TEMPLATE", "Templates") +#define STR_GID_TEXT NC_("STR_GID_TEXT", "Text") +#define STR_GID_FRAME NC_("STR_GID_FRAME", "Frame") +#define STR_GID_GRAPHIC NC_("STR_GID_GRAPHIC", "Image") +#define STR_GID_TABLE NC_("STR_GID_TABLE", "Table") +#define STR_GID_ENUMERATION NC_("STR_GID_ENUMERATION", "Numbering") +#define STR_GID_DATA NC_("STR_GID_DATA", "Data") +#define STR_GID_SPECIAL NC_("STR_GID_SPECIAL", "Special Functions") +#define STR_GID_IMAGE NC_("STR_GID_IMAGE", "Image") +#define STR_GID_CHART NC_("STR_GID_CHART", "Chart") +#define STR_GID_EXPLORER NC_("STR_GID_EXPLORER", "Explorer") +#define STR_GID_CONNECTOR NC_("STR_GID_CONNECTOR", "Connector") +#define STR_GID_MODIFY NC_("STR_GID_MODIFY", "Modify") +#define STR_GID_DRAWING NC_("STR_GID_DRAWING", "Drawing") +#define STR_GID_CONTROLS NC_("STR_GID_CONTROLS", "Controls") +#define STR_QUITAPP NC_("STR_QUITAPP", "E~xit %PRODUCTNAME") +#define RID_STR_HELP NC_("RID_STR_HELP", "Help") +#define RID_STR_HLPFILENOTEXIST NC_("RID_STR_HLPFILENOTEXIST", "The help file for this topic is not installed.") +#define STR_QUICKSTART_EXIT NC_("STR_QUICKSTART_EXIT", "Exit Quickstarter") +#define STR_QUICKSTART_TIP NC_("STR_QUICKSTART_TIP", "%PRODUCTNAME %PRODUCTVERSION Quickstarter") +#define STR_QUICKSTART_FILEOPEN NC_("STR_QUICKSTART_FILEOPEN", "Open Document...") +#define STR_QUICKSTART_FROMTEMPLATE NC_("STR_QUICKSTART_FROMTEMPLATE", "From Template...") +#define STR_QUICKSTART_PRELAUNCH NC_("STR_QUICKSTART_PRELAUNCH", "Load %PRODUCTNAME During System Start-Up") +#define STR_QUICKSTART_LNKNAME NC_("STR_QUICKSTART_LNKNAME", "%PRODUCTNAME %PRODUCTVERSION") +#define STR_QUICKSTART_FILE NC_("STR_QUICKSTART_FILE", "File") +#define STR_QUICKSTART_STARTCENTER NC_("STR_QUICKSTART_STARTCENTER", "Startcenter") +#define STR_QUICKSTART_RECENTDOC NC_("STR_QUICKSTART_RECENTDOC", "Recent Documents") +#define STR_QUERY_UPDATE_LINKS NC_("STR_QUERY_UPDATE_LINKS", "The document %{filename} contains one or more links to external data.\n\nWould you like to change the document, and update all links\nto get the most recent data?") +#define STR_DDE_ERROR NC_("STR_DDE_ERROR", "DDE link to %1 for %2 area %3 are not available.") +#define STR_SECURITY_WARNING_NO_HYPERLINKS NC_("STR_SECURITY_WARNING_NO_HYPERLINKS", "For security reasons, the hyperlink cannot be executed.\nThe stated address will not be opened.") +#define RID_SECURITY_WARNING_TITLE NC_("RID_SECURITY_WARNING_TITLE", "Security Warning") +#define RID_SVXSTR_XMLSEC_QUERY_LOSINGSIGNATURE NC_("RID_SVXSTR_XMLSEC_QUERY_LOSINGSIGNATURE", "Saving will remove all existing signatures.\nDo you want to continue saving the document?") +#define RID_SVXSTR_XMLSEC_QUERY_SAVEBEFORESIGN NC_("RID_SVXSTR_XMLSEC_QUERY_SAVEBEFORESIGN", "The document has to be saved before it can be signed.\nDo you want to save the document?") +#define STR_QUERY_CANCELCHECKOUT NC_("STR_QUERY_CANCELCHECKOUT", "This will discard all changes on the server since check-out.\nDo you want to proceed?") +#define STR_INFO_WRONGDOCFORMAT NC_("STR_INFO_WRONGDOCFORMAT", "This document must be saved in OpenDocument file format before it can be digitally signed.") +#define RID_XMLSEC_DOCUMENTSIGNED NC_("RID_XMLSEC_DOCUMENTSIGNED", " (Signed)") +#define STR_EMBEDDED_TITLE NC_("STR_EMBEDDED_TITLE", " (Embedded document)") +#define STR_STANDARD NC_("STR_STANDARD", "Standard") +#define RID_SVXSTR_FILELINK NC_("RID_SVXSTR_FILELINK", "Document") +#define STR_NONE NC_("STR_NONE", "- None -") +#define STR_CATEGORY_NONE NC_("saveastemplatedlg|categorylist", "None") +#define RID_SVXSTR_GRAPHICLINK NC_("RID_SVXSTR_GRAPHICLINK", "Image") +#define STR_SFX_FILTERNAME_ALL NC_("STR_SFX_FILTERNAME_ALL", "All files") +#define STR_SFX_FILTERNAME_PDF NC_("STR_SFX_FILTERNAME_PDF", "PDF files") +#define RID_SVXSTR_EDITGRFLINK NC_("RID_SVXSTR_EDITGRFLINK", "Link Image") +// i66948 used in project scripting +#define STR_ERRUNOEVENTBINDUNG NC_("STR_ERRUNOEVENTBINDUNG", "An appropriate component method %1\ncould not be found.\n\nCheck spelling of method name.") +#define RID_SVXSTR_GRFILTER_OPENERROR NC_("RID_SVXSTR_GRFILTER_OPENERROR", "Image file cannot be opened") +#define RID_SVXSTR_GRFILTER_IOERROR NC_("RID_SVXSTR_GRFILTER_IOERROR", "Image file cannot be read") +#define RID_SVXSTR_GRFILTER_FORMATERROR NC_("RID_SVXSTR_GRFILTER_FORMATERROR", "Unknown image format") +#define RID_SVXSTR_GRFILTER_VERSIONERROR NC_("RID_SVXSTR_GRFILTER_VERSIONERROR", "This version of the image file is not supported") +#define RID_SVXSTR_GRFILTER_FILTERERROR NC_("RID_SVXSTR_GRFILTER_FILTERERROR", "Image filter not found") +#define RID_SVXSTR_TXTFILTER_FILTERERROR NC_("RID_SVXSTR_TXTFILTER_FILTERERROR", "This is not a text document") +#define RID_SVXSTR_END_REDLINING_WARNING NC_("RID_SVXSTR_END_REDLINING_WARNING", "This action will exit the change recording mode.\nNo information about changes will be recorded from now on.\n\nExit change recording mode?\n\n") +#define RID_SVXSTR_INCORRECT_PASSWORD NC_("RID_SVXSTR_INCORRECT_PASSWORD", "Incorrect password") +#define RID_SVXSTR_GPG_ENCRYPT_FAILURE NC_("RID_SVXSTR_GPG_ENCRYPT_FAILURE", "OpenPGP key not trusted, damaged, or encryption failure. Please try again.") + +#define STR_PASSWD_MIN_LEN NC_("STR_PASSWD_MIN_LEN", "(Minimum $(MINLEN) characters)") +#define STR_PASSWD_MIN_LEN1 NC_("STR_PASSWD_MIN_LEN1", "(Minimum 1 character)") +#define STR_PASSWD_EMPTY NC_("STR_PASSWD_EMPTY", "(The password can be empty)") +#define STR_MODULENOTINSTALLED NC_("STR_MODULENOTINSTALLED", "The action could not be executed. The %PRODUCTNAME program module needed for this action is currently not installed.") + +#define STR_FILTER_NOT_INSTALLED NC_("STR_FILTER_NOT_INSTALLED", "The selected filter $(FILTER) has not been installed.\nWould you like to do this now?") +#define STR_FILTER_CONSULT_SERVICE NC_("STR_FILTER_CONSULT_SERVICE", "The selected filter $(FILTER) is not included in your edition.\nYou can find information about orders on our homepage.") + +#define STR_WELCOME_LINE1 NC_("STR_WELCOME_LINE1", "Welcome to %PRODUCTNAME.") +#define STR_WELCOME_LINE2 NC_("STR_WELCOME_LINE2", "Drop a document here or open an app to create one.") + +// Translators: Target types in Auto-redaction dialog +#define STR_REDACTION_TARGET_TYPE_TEXT NC_("STR_REDACTION_TARGET_TYPE_TEXT", "Text") +#define STR_REDACTION_TARGET_TYPE_REGEX NC_("STR_REDACTION_TARGET_TYPE_REGEX", "Regular expression") +#define STR_REDACTION_TARGET_TYPE_PREDEF NC_("STR_REDACTION_TARGET_TYPE_PREDEF", "Predefined") +#define STR_REDACTION_TARGET_TYPE_UNKNOWN NC_("STR_REDACTION_TARGET_TYPE_UNKNOWN", "Unknown") + +// Translators: Values for the Case Sensitive and the Whole Words columns in Auto-redaction dialog +#define STR_REDACTION_YES NC_("STR_REDACTION_YES", "Yes") +#define STR_REDACTION_NO NC_("STR_REDACTION_NO", "No") + +// Translators: Misc strings of the Auto Redaction dialog +#define STR_REDACTION_TARGET NC_("STR_REDACTION_TARGET", "Target") +#define STR_REDACTION_LOAD_TARGETS NC_("STR_REDACTION_LOAD_TARGETS", "Load Targets") +#define STR_REDACTION_SAVE_TARGETS NC_("STR_REDACTION_SAVE_TARGETS", "Save Targets") +#define STR_REDACTION_FIELDS_REQUIRED NC_("STR_REDACTION_FIELDS_REQUIRED", "All fields are required") +#define STR_REDACTION_TARGET_NAME_CLASH NC_("STR_REDACTION_TARGET_NAME_CLASH", "There is already a target with this name") +#define STR_REDACTION_MULTI_EDIT NC_("STR_REDACTION_MULTI_EDIT", "You have selected multiple targets, but only one target can be edited at once.") +#define STR_REDACTION_MULTI_DELETE NC_("STR_REDACTION_MULTI_DELETE", "Are you sure you would like to delete $(TARGETSCOUNT) targets at once?") +#define STR_REDACTION_JSON_FILE_FILTER NC_("STR_REDACTION_JSON_FILE_FILTER", "Target Set (*.json)") +#define STR_REDACTION_EDIT_TARGET NC_("STR_REDACTION_EDIT_TARGET", "Edit Target") +#define STR_REDACTION_TARGET_ADD_ERROR NC_("STR_REDACTION_TARGET_ADD_ERROR", "An error occurred while adding new target. Please report this incident.") +#define STR_REDACTION_NO_DRAW_WARNING NC_("STR_REDACTION_NO_DRAW_WARNING", "Draw module is needed for redaction. Please make sure you have %PRODUCTNAME Draw installed and working correctly.") + +#define STR_SFX_FILEDLG_ACTUALVERSION NC_("STR_SFX_FILEDLG_ACTUALVERSION", "Current version") +#define STR_SFX_EXPLORERFILE_EXPORT NC_("STR_SFX_EXPLORERFILE_EXPORT", "Export") +#define STR_SFX_EXPLORERFILE_INSERT NC_("STR_SFX_EXPLORERFILE_INSERT", "Insert") +#define STR_SFX_EXPLORERFILE_BUTTONINSERT NC_("STR_SFX_EXPLORERFILE_BUTTONINSERT", "~Insert") +#define STR_SFX_IMPORT_ALL_IMAGES NC_("STR_SFX_IMPORT_ALL_IMAGES", "") +#define STR_PB_SAVEACOPY NC_("STR_PB_SAVEACOPY", "Save a Copy") +#define STR_PB_COMPAREDOC NC_("STR_PB_COMPAREDOC", "Compare to") +#define STR_PB_MERGEDOC NC_("STR_PB_MERGEDOC", "Merge with") + +#define STR_SFX_NEWOFFICEDOC NC_("STR_SFX_NEWOFFICEDOC", "%PRODUCTNAME document") +#define SFX_ST_DURATION_FORMAT NC_("SFX_ST_DURATION_FORMAT", " Y: %1 M: %2 D: %3 H: %4 M: %5 S: %6") +#define STR_SFX_QUERY_WRONG_TYPE NC_("STR_SFX_QUERY_WRONG_TYPE", "The value entered does not match the specified type.\nThe value will be stored as text.") + +#define STR_QUERY_OVERWRITE NC_("STR_QUERY_OVERWRITE", "Style already exists. Overwrite?") + +#define STR_RESET NC_("STR_RESET", "~Reset") +#define STR_TABPAGE_INVALIDNAME NC_("STR_TABPAGE_INVALIDNAME", "This name is already in use.") +#define STR_TABPAGE_INVALIDSTYLE NC_("STR_TABPAGE_INVALIDSTYLE", "This Style does not exist.") +#define STR_TABPAGE_INVALIDPARENT NC_("STR_TABPAGE_INVALIDPARENT", "This Style cannot be used as a base Style,\nbecause it would result in a recursive reference.") +#define STR_POOL_STYLE_NAME NC_("STR_POOL_STYLE_NAME", "Name already exists as a default Style.\nPlease choose another name.") +#define STR_DELETE_STYLE_USED NC_("STR_DELETE_STYLE_USED", "One or more of the selected styles is in use in this document.\nIf you will delete it, text or objects using these styles will revert to the parent style.\nDo you still wish to delete these styles?\n") +#define STR_DELETE_STYLE NC_("STR_DELETE_STYLE", "Styles in use: ") +#define STR_SID_NAVIGATOR NC_("STR_SID_NAVIGATOR", "Navigator") +#define STR_ERROR_WRONG_CONFIRM NC_("STR_ERROR_WRONG_CONFIRM", "Faulty password confirmation") +#define STR_PDF_EXPORT_SEND NC_("STR_PDF_EXPORT_SEND", "Send") +#define STR_FONT_TABPAGE NC_("STR_FONT_TABPAGE", "Font") + +#define STR_VIEWVERSIONCOMMENT NC_("STR_VIEWVERSIONCOMMENT", "View Version Comment") +#define STR_NO_NAME_SET NC_("STR_NO_NAME_SET", "(no name set)") + +#define STR_STYLE_FILTER_HIERARCHICAL NC_("STR_STYLE_FILTER_HIERARCHICAL", "Hierarchical") + +#define STR_MACRO_LOSS NC_("STR_MACRO_LOSS", "Do you really want to cancel the recording? Any steps recorded up to this point will be lost.") +#define STR_CANCEL_RECORDING NC_("STR_CANCEL_RECORDING", "Cancel Recording") + +#define RID_CNT_STR_WAITING NC_("RID_CNT_STR_WAITING", "The templates are being initialized for first-time usage.") + +#define STR_NODEFPRINTER NC_("STR_NODEFPRINTER", "No default printer found.\nPlease choose a printer and try again.") +#define STR_NOSTARTPRINTER NC_("STR_NOSTARTPRINTER", "Could not start printer.\nPlease check your printer configuration.") +#define STR_ERROR_PRINTER_BUSY NC_("STR_ERROR_PRINTER_BUSY", "Printer busy") +#define STR_READONLY NC_("STR_READONLY", " (read-only)") +#define STR_PRINT_NEWORI NC_("STR_PRINT_NEWORI", "The page size and orientation have been modified.\nWould you like to save the new settings in the\nactive document?") +#define STR_PRINT_NEWSIZE NC_("STR_PRINT_NEWSIZE", "The page size has been modified.\nShould the new settings be saved\nin the active document?") +#define STR_PRINT_NEWORISIZE NC_("STR_PRINT_NEWORISIZE", "The page size and orientation have been modified.\nWould you like to save the new settings in the\nactive document?") +#define STR_CANT_CLOSE NC_("STR_CANT_CLOSE", "The document cannot be closed because a\n print job is being carried out.") +#define STR_ERROR_SEND_MAIL NC_("STR_ERROR_SEND_MAIL", "An error occurred in sending the message. Possible errors could be a missing user account or a defective setup.\nPlease check the %PRODUCTNAME settings or your email program settings.") +// Error codes look like "MAPI_E_FAILURE" or "1234" +#define STR_ERROR_SEND_MAIL_CODE NC_("STR_ERROR_SEND_MAIL_CODE", "An error occurred in sending the message. Possible errors could be a missing user account or a defective setup.\n\nError code is $1") +#define STR_ERROR_SEND_MAIL_HEADER NC_("STR_ERROR_SEND_MAIL_HEADER", "Error sending mail") +#define STR_QUERY_OPENASTEMPLATE NC_("STR_QUERY_OPENASTEMPLATE", "This document cannot be edited, possibly due to missing access rights. Do you want to edit a copy of the document?") +#define STR_QUERY_OPENASTEMPLATE_LOCKED NC_("STR_QUERY_OPENASTEMPLATE_LOCKED", "This document cannot be edited, because it is locked in another session.%LOCKINFO\nDo you want to edit a copy of the document?") +#define STR_QUERY_OPENASTEMPLATE_ALLOW_IGNORE NC_("STR_QUERY_OPENASTEMPLATE_ALLOW_IGNORE", "You can also try to ignore the lock and open the file for editing.") +#define STR_QUERY_OPENASTEMPLATE_OPENCOPY_BTN NC_("STR_QUERY_OPENASTEMPLATE_OPENCOPY_BTN", "Open ~Copy") +#define STR_QUERY_OPENASTEMPLATE_OPEN_BTN NC_("STR_QUERY_OPENASTEMPLATE_OPEN_BTN", "~Open") +#define STR_REPAIREDDOCUMENT NC_("STR_REPAIREDDOCUMENT", " (repaired document)") +#define STR_NONCHECKEDOUT_DOCUMENT NC_("STR_NONCHECKEDOUT_DOCUMENT", "This document is not checked out on the server.") +#define STR_GET_INVOLVED_TEXT NC_("STR_GET_INVOLVED_TEXT", "Help us make %PRODUCTNAME even better!") +#define STR_GET_INVOLVED_BUTTON NC_("STR_GET_INVOLVED_BUTTON", "Get involved") +#define STR_DONATE_TEXT NC_("STR_DONATE_TEXT", "Your donations support our worldwide community.") +#define STR_DONATE_BUTTON NC_("STR_DONATE_BUTTON", "Donate") +#define STR_WHATSNEW_TEXT NC_("STR_WHATSNEW", "You are running version %PRODUCTVERSION of %PRODUCTNAME for the first time. Do you want to learn what's new?") +#define STR_WHATSNEW_BUTTON NC_("STR_WHATSNEW_BUTTON", "Release Notes") +#define STR_READONLY_DOCUMENT NC_("STR_READONLY_DOCUMENT", "This document is open in read-only mode.") +#define STR_READONLY_PDF NC_("STR_READONLY_PDF", "This PDF is open in read-only mode to allow signing the existing file.") +#define STR_CLASSIFIED_DOCUMENT NC_("STR_CLASSIFIED_DOCUMENT", "The classification label of this document is %1.") +#define STR_TARGET_DOC_NOT_CLASSIFIED NC_("STR_TARGET_DOC_NOT_CLASSIFIED", "This document must be classified before the clipboard can be pasted.") +#define STR_DOC_CLASSIFICATION_TOO_LOW NC_("STR_DOC_CLASSIFICATION_TOO_LOW", "This document has a lower classification level than the clipboard.") +#define STR_CLASSIFIED_INTELLECTUAL_PROPERTY NC_("STR_CLASSIFIED_INTELLECTUAL_PROPERTY", "Level") +#define STR_CLASSIFIED_NATIONAL_SECURITY NC_("STR_CLASSIFIED_NATIONAL_SECURITY", "National Security:") +#define STR_CLASSIFIED_EXPORT_CONTROL NC_("STR_CLASSIFIED_EXPORT_CONTROL", "Export Control:") +#define STR_CHECKOUT NC_("STR_CHECKOUT", "Check Out") +#define STR_READONLY_EDIT NC_("STR_READONLY_EDIT", "Edit Document") +#define STR_READONLY_SIGN NC_("STR_READONLY_SIGN", "Sign Document") +#define STR_READONLY_FINISH_SIGN NC_("STR_READONLY_FINISH_SIGN", "Finish Signing") +#define STR_SIGNATURE_BROKEN NC_("STR_SIGNATURE_BROKEN", "This document has an invalid signature.") +#define STR_SIGNATURE_INVALID NC_("STR_SIGNATURE_INVALID", "The signature was valid, but the document has been modified") +#define STR_SIGNATURE_NOTVALIDATED NC_("STR_SIGNATURE_NOTVALIDATED", "At least one signature has problems: the certificate could not be validated.") +#define STR_SIGNATURE_PARTIAL_OK NC_("STR_SIGNATURE_PARTIAL_OK", "At least one signature has problems: the document is only partially signed.") +#define STR_SIGNATURE_NOTVALIDATED_PARTIAL_OK NC_("STR_SIGNATURE_NOTVALIDATED_PARTIAL_OK", "The certificate could not be validated and the document is only partially signed.") +#define STR_SIGNATURE_OK NC_("STR_SIGNATURE_OK", "This document is digitally signed and the signature is valid.") +#define STR_SIGNATURE_SHOW NC_("STR_SIGNATURE_SHOW", "Show Signatures") +#define STR_TRACK_CHANGES_BUTTON NC_("STR_TRACK_CHANGES_BUTTON", "Show Toolbar") +#define STR_TRACK_CHANGES_BUTTON_HIDE NC_("STR_TRACK_CHANGES_BUTTON_HIDE", "Hide Toolbar") +#define STR_HYPHENATION_BUTTON NC_("STR_HYPHENATION_BUTTON", "Learn more") +#define STR_REFRESH_MASTER_PASSWORD NC_("STR_REFRESH_MASTER_PASSWORD", "The master password is stored in an outdated format, you should refresh it") +#define STR_REFRESH_PASSWORD NC_("STR_REFRESH_PASSWORD", "Refresh Password") + +// Translators: default Impress template names +#define STR_TEMPLATE_NAME1 NC_("STR_TEMPLATE_NAME1", "Grey Elegant") +#define STR_TEMPLATE_NAME2 NC_("STR_TEMPLATE_NAME2", "Beehive") +#define STR_TEMPLATE_NAME3 NC_("STR_TEMPLATE_NAME3", "Blue Curve") +#define STR_TEMPLATE_NAME4 NC_("STR_TEMPLATE_NAME4", "Blueprint Plans") +#define STR_TEMPLATE_NAME5 NC_("STR_TEMPLATE_NAME5", "Candy") +#define STR_TEMPLATE_NAME6 NC_("STR_TEMPLATE_NAME6", "Yellow Idea") +#define STR_TEMPLATE_NAME7 NC_("STR_TEMPLATE_NAME7", "DNA") +#define STR_TEMPLATE_NAME8 NC_("STR_TEMPLATE_NAME8", "Focus") +#define STR_TEMPLATE_NAME9 NC_("STR_TEMPLATE_NAME9", "Forestbird") +#define STR_TEMPLATE_NAME10 NC_("STR_TEMPLATE_NAME10", "Freshes") +#define STR_TEMPLATE_NAME11 NC_("STR_TEMPLATE_NAME11", "Inspiration") +#define STR_TEMPLATE_NAME12 NC_("STR_TEMPLATE_NAME12", "Lights") +#define STR_TEMPLATE_NAME13 NC_("STR_TEMPLATE_NAME13", "Growing Liberty") +#define STR_TEMPLATE_NAME14 NC_("STR_TEMPLATE_NAME14", "Metropolis") +#define STR_TEMPLATE_NAME15 NC_("STR_TEMPLATE_NAME15", "Midnightblue") +#define STR_TEMPLATE_NAME16 NC_("STR_TEMPLATE_NAME16", "Nature Illustration") +#define STR_TEMPLATE_NAME17 NC_("STR_TEMPLATE_NAME17", "Pencil") +#define STR_TEMPLATE_NAME18 NC_("STR_TEMPLATE_NAME18", "Piano") +#define STR_TEMPLATE_NAME19 NC_("STR_TEMPLATE_NAME19", "Portfolio") +#define STR_TEMPLATE_NAME20 NC_("STR_TEMPLATE_NAME20", "Progress") +#define STR_TEMPLATE_NAME21 NC_("STR_TEMPLATE_NAME21", "Sunset") +#define STR_TEMPLATE_NAME22 NC_("STR_TEMPLATE_NAME22", "Vintage") +#define STR_TEMPLATE_NAME23 NC_("STR_TEMPLATE_NAME23", "Vivid") +// Translators: default Writer template names +#define STR_TEMPLATE_NAME24 NC_("STR_TEMPLATE_NAME24", "CV") +#define STR_TEMPLATE_NAME25 NC_("STR_TEMPLATE_NAME25", "Resume") +#define STR_TEMPLATE_NAME26 NC_("STR_TEMPLATE_NAME26", "Default") +#define STR_TEMPLATE_NAME27 NC_("STR_TEMPLATE_NAME27", "Modern") +#define STR_TEMPLATE_NAME28 NC_("STR_TEMPLATE_NAME28", "Modern business letter sans-serif") +#define STR_TEMPLATE_NAME29 NC_("STR_TEMPLATE_NAME29", "Modern business letter serif") +#define STR_TEMPLATE_NAME30 NC_("STR_TEMPLATE_NAME30", "Businesscard with logo") +#define STR_TEMPLATE_NAME31 NC_("STR_TEMPLATE_NAME31", "Simple") +#define STR_TEMPLATE_NAME32 NC_("STR_TEMPLATE_NAME32", "BPMN") + +#define STR_CLEAR_CHAR NC_("STR_CLEAR_CHAR", "Remove") +#define STR_CLEAR_ALL_CHAR NC_("STR_CLEAR_ALL_CHAR", "Clear All") + +#define STR_PASSWORD_LEN NC_("STR_PASSWORD_LEN", "Password length") +#define STR_PASSWORD_WARNING NC_("STR_PASSWORD_WARNING", "The password you have entered causes interoperability issues. Please enter a password that is shorter than 52 bytes, or longer than 55 bytes.") + +#define STR_CTRLCLICKHYPERLINK NC_("STR_CTRLCLICKHYPERLINK", "%{key}-click to open hyperlink: %{link}") +#define STR_CLICKHYPERLINK NC_("STR_CLICKHYPERLINK", "Click to open hyperlink: %{link}") + +#define STR_STYLEUSEDBY NC_("STR_STYLEUSEDBY", "(used by: %STYLELIST)") + +#define STR_DOCUMENT NC_("STR_DOCUMENT", "Document") +#define STR_SPREADSHEET NC_("STR_SPREADSHEET", "Spreadsheet") +#define STR_PRESENTATION NC_("STR_PRESENTATION", "Presentation") +#define STR_DRAWING NC_("STR_DRAWING", "Drawing") +#define STR_RECENT NC_("STR_RECENT", "Recently used") +#define STR_NORECENT NC_("STR_NORECENT", "No recent characters") + +#define STR_ACTION_RESET_ALL_DEFAULT_TEMPLATES NC_("STR_ACTION_RESET_ALL_DEFAULT_TEMPLATES","Reset All De~fault Templates") +#define STR_ACTION_RESET_WRITER_TEMPLATE NC_("STR_ACTION_RESET_WRITER_TEMPLATE","Reset De~fault Text Document") +#define STR_ACTION_RESET_CALC_TEMPLATE NC_("STR_ACTION_RESET_CALC_TEMPLATE","Reset De~fault Spreadsheet") +#define STR_ACTION_RESET_IMPRESS_TEMPLATE NC_("STR_ACTION_RESET_IMPRESS_TEMPLATE","Reset De~fault Presentation") +#define STR_ACTION_RESET_DRAW_TEMPLATE NC_("STR_ACTION_RESET_DRAW_TEMPLATE","Reset De~fault Drawing") +#define STR_ACTION_IMPORT NC_("STR_ACTION_IMPORT","~Import") +#define STR_ACTION_EXTENSIONS NC_("STR_ACTION_EXTENSIONS","E~xtensions") +#define STR_WINDOW_TITLE_RENAME_TEMPLATE NC_("STR_WINDOW_TITLE_RENAME_TEMPLATE","Rename") +#define STR_WINDOW_TITLE_RENAME_CATEGORY NC_("STR_WINDOW_TITLE_RENAME_CATEGORY","Rename Category") +#define STR_WINDOW_TITLE_RENAME_NEW_CATEGORY NC_("STR_WINDOW_TITLE_RENAME_NEW_CATEGORY","New Category") +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/styfitem.hxx b/include/sfx2/styfitem.hxx new file mode 100644 index 000000000..dc2efd88c --- /dev/null +++ b/include/sfx2/styfitem.hxx @@ -0,0 +1,62 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_STYFITEM_HXX +#define INCLUDED_SFX2_STYFITEM_HXX + +#include +#include +#include +#include +#include +#include + +struct SFX2_DLLPUBLIC SfxFilterTuple +{ + OUString aName; + SfxStyleSearchBits nFlags; + SfxFilterTuple(const OUString& rName, SfxStyleSearchBits nArg) + : aName(rName) + , nFlags(nArg) + { + } +}; + +typedef std::vector SfxStyleFilter; + +class SFX2_DLLPUBLIC SfxStyleFamilyItem +{ + SfxStyleFamily nFamily; + OUString aText; + OUString aImage; + SfxStyleFilter aFilterList; + +public: + SfxStyleFamilyItem(SfxStyleFamily nFamily, const OUString &rName, const OUString& rImage, const std::pair* pStringArray, const std::locale& rLocale); + + const OUString& GetText() const { return aText; } + SfxStyleFamily GetFamily() const { return nFamily; } + const SfxStyleFilter& GetFilterList() const { return aFilterList; } + const OUString& GetImage() const { return aImage; } +}; + +using SfxStyleFamilies = std::vector; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/styledlg.hxx b/include/sfx2/styledlg.hxx new file mode 100644 index 000000000..6fd7afde1 --- /dev/null +++ b/include/sfx2/styledlg.hxx @@ -0,0 +1,52 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_STYLEDLG_HXX +#define INCLUDED_SFX2_STYLEDLG_HXX + +#include +#include +#include + +class SfxStyleSheetBase; +class SfxStyleSheetBasePool; +enum class SfxStyleFamily; + +class SFX2_DLLPUBLIC SfxStyleDialogController : public SfxTabDialogController +{ +private: + SfxStyleSheetBase& m_rStyle; + DECL_DLLPRIVATE_LINK(CancelHdl, weld::Button&, void); + +public: + SfxStyleDialogController(weld::Window* pParent, + const OUString& rUIXMLDescription, const OString& rID, SfxStyleSheetBase&); + + virtual ~SfxStyleDialogController() override; + + SfxStyleSheetBase& GetStyleSheet() { return m_rStyle; } + const SfxStyleSheetBase& GetStyleSheet() const { return m_rStyle; } + + virtual short Ok() override; + + static OUString GenerateUnusedName(SfxStyleSheetBasePool &rPool, SfxStyleFamily eFam); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx new file mode 100644 index 000000000..4c519964e --- /dev/null +++ b/include/sfx2/tabdlg.hxx @@ -0,0 +1,269 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_TABDLG_HXX +#define INCLUDED_SFX2_TABDLG_HXX + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class SfxTabPage; + +typedef std::unique_ptr (*CreateTabPage)(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rAttrSet); +typedef WhichRangesContainer (*GetTabPageRanges)(); // provides international Which-value +struct TabPageImpl; + +struct TabDlg_Impl; + +namespace com::sun::star::frame { class XFrame; } + +#define RET_USER 100 +#define RET_USER_CANCEL 101 + +class SFX2_DLLPUBLIC SfxTabDialogItem final : public SfxSetItem +{ +public: + SfxTabDialogItem( sal_uInt16 nId, const SfxItemSet& rItemSet ); + SfxTabDialogItem(const SfxTabDialogItem& rAttr, SfxItemPool* pItemPool); + virtual SfxTabDialogItem* Clone(SfxItemPool* pToPool = nullptr) const override; +}; + +class SFX2_DLLPUBLIC SfxTabDialogController : public SfxOkDialogController +{ +protected: + std::unique_ptr m_xTabCtrl; + + DECL_LINK(OkHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(ResetHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(BaseFmtHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(UserHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(CancelHdl, weld::Button&, void); +private: + std::unique_ptr m_xOKBtn; + std::unique_ptr m_xApplyBtn; + std::unique_ptr m_xUserBtn; + std::unique_ptr m_xCancelBtn; + std::unique_ptr m_xResetBtn; + std::unique_ptr m_xBaseFmtBtn; + std::unique_ptr m_xSizeGroup; + + std::unique_ptr m_pSet; + std::unique_ptr m_pOutSet; + std::unique_ptr m_pImpl; + WhichRangesContainer m_pRanges; + OString m_sAppPageId; + bool m_bStandardPushed; + std::unique_ptr m_xItemSet; + + DECL_DLLPRIVATE_LINK(ActivatePageHdl, const OString&, void); + DECL_DLLPRIVATE_LINK(DeactivatePageHdl, const OString&, bool); + SAL_DLLPRIVATE void Start_Impl(); + SAL_DLLPRIVATE void CreatePages(); + SAL_DLLPRIVATE void setPreviewsToSamePlace(); + +protected: + virtual short Ok(); + virtual void RefreshInputSet(); + virtual SfxItemSet* CreateInputItemSet(const OString& rName); + virtual void PageCreated(const OString &rName, SfxTabPage &rPage); + + std::unique_ptr m_xExampleSet; + SfxItemSet* GetInputSetImpl(); + SfxTabPage* GetTabPage(std::string_view rPageId) const; + + /** prepare to leave the current page. Calls the DeactivatePage method of the current page, (if necessary), + handles the item sets to copy. + @return sal_True if it is allowed to leave the current page, sal_False otherwise + */ + bool PrepareLeaveCurrentPage(); + + /** save the position of the TabDialog and which tab page is the currently active one + */ + void SavePosAndId(); +public: + SfxTabDialogController(weld::Widget* pParent, const OUString& rUIXMLDescription, const OString& rID, + const SfxItemSet * = nullptr, bool bEditFmt = false); + virtual ~SfxTabDialogController() override; + + void AddTabPage(const OString& rName, // Name of the label for the existing page in the notebook .ui + CreateTabPage pCreateFunc, // != 0 + GetTabPageRanges pRangesFunc); // can be 0 + + void AddTabPage(const OString& rName, // Name of the label for the existing page in the notebook .ui + sal_uInt16 nPageCreateId); // Identifier of the Factory Method to create the page + + void AddTabPage(const OString& rName, // Name of the label for the new page to create + const OUString& rLabel, // UI Label for the new page to create + CreateTabPage pCreateFunc); // != 0 + + void AddTabPage(const OString& rName, // Name of the label for the new page to create + const OUString& rLabel, // UI Label for the new page to create + sal_uInt16 nPageCreateId); // Identifier of the Factory Method to create the page + + void RemoveTabPage( const OString& rName ); // Name of the label for the page in the notebook .ui + + void SetCurPageId(const OString& rName); + void ShowPage(const OString& rName); // SetCurPageId + call Activate on it + OString GetCurPageId() const; + SfxTabPage* GetCurTabPage() const { return GetTabPage(GetCurPageId()); } + + // may provide local slots converted by Map + const WhichRangesContainer& GetInputRanges( const SfxItemPool& ); + void SetInputSet( const SfxItemSet* pInSet ); + const SfxItemSet* GetOutputItemSet() const { return m_pOutSet.get(); } + + virtual weld::Button& GetOKButton() const override { return *m_xOKBtn; } + weld::Button& GetCancelButton() const { return *m_xCancelBtn; } + weld::Button* GetUserButton() const { return m_xUserBtn.get(); } + weld::Button* GetStandardButton() const { return m_xBaseFmtBtn.get(); } + weld::Button* GetApplyButton() const { return m_xApplyBtn.get(); } + weld::Button* GetResetButton() const { return m_xResetBtn.get(); } + void RemoveResetButton(); + void RemoveStandardButton(); + + virtual short run() override; + static bool runAsync(const std::shared_ptr& rController, + const std::function&); + + virtual const SfxItemSet* GetExampleSet() const override { return m_xExampleSet.get(); } + + void SetApplyHandler(const Link& _rHdl); + + //calls Ok without closing dialog + bool Apply(); + void Applied() { m_xExampleSet->Put(*GetInputSetImpl()); } + + //screenshotting + std::vector getAllPageUIXMLDescriptions() const; + bool selectPageByUIXMLDescription(const OString& rUIXMLDescription); + BitmapEx createScreenshot() const; + OString GetScreenshotId() const; +}; + +enum class DeactivateRC { + KeepPage = 0x00, // Error handling; page does not change + // 2. Fill an itemset for update + // parent examples, this pointer can be NULL all the time! + LeavePage = 0x01, + // Set, refresh and update other Page + RefreshSet = 0x02 +}; +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +} + +class SFX2_DLLPUBLIC SfxTabPage : public BuilderPage +{ +friend class SfxTabDialog; +friend class SfxTabDialogController; + +private: + const SfxItemSet* pSet; + OUString aUserString; + bool bHasExchangeSupport; + std::unordered_map maAdditionalProperties; + + std::unique_ptr< TabPageImpl > pImpl; + +protected: + SfxTabPage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet *rAttrSet); + + sal_uInt16 GetWhich( sal_uInt16 nSlot, bool bDeep = true ) const + { return pSet->GetPool()->GetWhich( nSlot, bDeep ); } + template + TypedWhichId GetWhich( TypedWhichId nSlot, bool bDeep = true ) const + { + return TypedWhichId(GetWhich(sal_uInt16(nSlot), bDeep)); + } + + const SfxPoolItem* GetOldItem( const SfxItemSet& rSet, sal_uInt16 nSlot, bool bDeep = true ); + template const T* GetOldItem( const SfxItemSet& rSet, TypedWhichId nSlot, bool bDeep = true ) + { + return static_cast(GetOldItem(rSet, sal_uInt16(nSlot), bDeep)); + } + + SfxOkDialogController* GetDialogController() const; +public: + void SetDialogController(SfxOkDialogController* pDialog); +public: + virtual ~SfxTabPage() override; + + void set_visible(bool bVisible) + { + m_xContainer->set_visible(bVisible); + } + + const SfxItemSet& GetItemSet() const { return *pSet; } + + virtual bool FillItemSet( SfxItemSet* ); + virtual void Reset( const SfxItemSet* ); + // Allows to postpone some initialization to the first activation + virtual bool DeferResetToFirstActivation(); + + bool HasExchangeSupport() const + { return bHasExchangeSupport; } + void SetExchangeSupport() + { bHasExchangeSupport = true; } + + virtual void ActivatePage( const SfxItemSet& ); + virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ); + void SetUserData(const OUString& rString) + { aUserString = rString; } + const OUString& GetUserData() const { return aUserString; } + virtual void FillUserData(); + virtual bool IsReadOnly() const; + virtual void PageCreated (const SfxAllItemSet& aSet); + virtual void ChangesApplied(); + static const SfxPoolItem* GetItem( const SfxItemSet& rSet, sal_uInt16 nSlot, bool bDeep = true ); + template static const T* GetItem( const SfxItemSet& rSet, TypedWhichId nSlot, bool bDeep = true ) + { + return static_cast(GetItem(rSet, sal_uInt16(nSlot), bDeep)); + } + + void SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame); + css::uno::Reference< css::frame::XFrame > GetFrame() const; + + const SfxItemSet* GetDialogExampleSet() const; + + OString GetHelpId() const; + OString GetConfigId() const { return GetHelpId(); } + bool IsVisible() const { return m_xContainer->get_visible(); } + + weld::Window* GetFrameWeld() const; + + std::unordered_map& getAdditionalProperties() + { + return maAdditionalProperties; + } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/tbxctrl.hxx b/include/sfx2/tbxctrl.hxx new file mode 100644 index 000000000..e3953c4e5 --- /dev/null +++ b/include/sfx2/tbxctrl.hxx @@ -0,0 +1,142 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_TBXCTRL_HXX +#define INCLUDED_SFX2_TBXCTRL_HXX + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace com::sun::star::frame { class XDispatchProvider; } +namespace com::sun::star::frame { class XFrame; } +namespace vcl { class Window; } +namespace com::sun::star::frame { class XToolbarController; } + +class InterimItemWindow; +class SfxToolBoxControl; +class SfxModule; + +rtl::Reference SfxToolBoxControllerFactory( const css::uno::Reference< css::frame::XFrame >& rFrame, ToolBox* pToolbox, ToolBoxItemId nID, const OUString& aCommandURL ); + +typedef rtl::Reference (*SfxToolBoxControlCtor)( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rBox ); + +struct SfxTbxCtrlFactory +{ + SfxToolBoxControlCtor pCtor; + const std::type_info& nTypeId; + sal_uInt16 nSlotId; + + SfxTbxCtrlFactory( SfxToolBoxControlCtor pTheCtor, + const std::type_info& nTheTypeId, sal_uInt16 nTheSlotId ): + pCtor(pTheCtor), + nTypeId(nTheTypeId), + nSlotId(nTheSlotId) + {} +}; + + +#define SFX_DECL_TOOLBOX_CONTROL() \ + static rtl::Reference CreateImpl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx ); \ + static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=nullptr) + +/* For special ToolBox controls, such as a font selection box or toolbox + tear-off floating windows, an appropriate Item-Subclass of SfxTooBoxControl + has to be implemented. + + This class has to be registered in SfxApplication:Init() with the static + control method RegisterControl(). The SFx then automatically creates these + controls in the toolbox, if the associated slots are of the specific type. + */ + +struct SfxToolBoxControl_Impl; +class SFX2_DLLPUBLIC SfxToolBoxControl: public svt::ToolboxController +{ +friend struct SfxTbxCtrlFactory; + + std::unique_ptr< SfxToolBoxControl_Impl> pImpl; + +protected: + // old SfxToolBoxControl methods + virtual void StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ); + virtual void Select( sal_uInt16 nSelectModifier ); + + virtual void DoubleClick(); + virtual void Click(); + virtual void CreatePopupWindow(); + virtual VclPtr CreateItemWindow(vcl::Window *pParent); + +public: + // XComponent + virtual void SAL_CALL dispose() override; + + // new controller API + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + // XToolbarController + virtual void SAL_CALL execute( sal_Int16 KeyModifier ) override; + virtual void SAL_CALL click() override; + virtual void SAL_CALL doubleClick() override; + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createPopupWindow() override; + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& rParent ) override; + +public: + SFX_DECL_TOOLBOX_CONTROL(); + + SfxToolBoxControl( sal_uInt16 nSlotID, ToolBoxItemId nId, ToolBox& rBox, bool bShowStrings = false ); + virtual ~SfxToolBoxControl() override; + + ToolBox& GetToolBox() const; + ToolBoxItemId GetId() const; + unsigned short GetSlotId() const; + + void Dispatch( const OUString& aCommand, + css::uno::Sequence< css::beans::PropertyValue > const & aArgs ); + static void Dispatch( const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider, + const OUString& rCommand, + css::uno::Sequence< css::beans::PropertyValue > const & aArgs ); + + static SfxItemState GetItemState( const SfxPoolItem* pState ); + static rtl::Reference CreateControl( sal_uInt16 nSlotId, ToolBoxItemId nTbxId, ToolBox *pBox, SfxModule const *pMod ); + static void RegisterToolBoxControl( SfxModule*, const SfxTbxCtrlFactory&); +}; + +#define SFX_IMPL_TOOLBOX_CONTROL(Class, nItemClass) \ + rtl::Reference Class::CreateImpl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx ) \ + { return new Class( nSlotId, nId, rTbx ); } \ + void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \ + { SfxToolBoxControl::RegisterToolBoxControl( pMod, SfxTbxCtrlFactory( \ + Class::CreateImpl, typeid(nItemClass), nSlotId ) ); } + +#define SFX_IMPL_TOOLBOX_CONTROL_ARG(Class, nItemClass, Arg) \ + rtl::Reference Class::CreateImpl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx ) \ + { return new Class( nSlotId, nId, rTbx, Arg); } \ + void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \ + { SfxToolBoxControl::RegisterToolBoxControl( pMod, SfxTbxCtrlFactory( \ + Class::CreateImpl, typeid(nItemClass), nSlotId ) ); } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/templatedlg.hxx b/include/sfx2/templatedlg.hxx new file mode 100644 index 000000000..10d3107fc --- /dev/null +++ b/include/sfx2/templatedlg.hxx @@ -0,0 +1,193 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_INC_TEMPLATEDLG_HXX +#define INCLUDED_SFX2_INC_TEMPLATEDLG_HXX + +#include +#include + +#include +#include + +#include +#include +#include + +#include + +class ThumbnailViewItem; + +namespace com +{ +namespace sun::star::frame +{ +class XDesktop2; +class XModel; +} +} + +class SFX2_DLLPUBLIC SfxTemplateManagerDlg : public weld::GenericDialogController +{ + typedef bool (*selection_cmp_fn)(const ThumbnailViewItem*, const ThumbnailViewItem*); + +public: + SfxTemplateManagerDlg(weld::Window* parent); + + virtual ~SfxTemplateManagerDlg() override; + virtual short run() override; + + void setDocumentModel(const css::uno::Reference& rModel); + void setTemplateViewMode(TemplateViewMode eViewMode); + TemplateViewMode getTemplateViewMode() const; + +protected: + void getApplicationSpecificSettings(); + + void readSettings(); + + void writeSettings(); + + void fillFolderComboBox(); + + DECL_DLLPRIVATE_LINK(SelectApplicationHdl, weld::ComboBox&, void); + DECL_DLLPRIVATE_LINK(SelectRegionHdl, weld::ComboBox&, void); + + DECL_DLLPRIVATE_LINK(OkClickHdl, weld::Button&, void); + void ImportActionHdl(); + static void ExtensionsActionHdl(); + + DECL_DLLPRIVATE_LINK(TVItemStateHdl, const ThumbnailViewItem*, void); + + DECL_DLLPRIVATE_LINK(MenuSelectHdl, const OString&, void); + void DefaultTemplateMenuSelectHdl(std::string_view rIdent); + + DECL_DLLPRIVATE_LINK(OpenRegionHdl, void*, void); + DECL_DLLPRIVATE_LINK(CreateContextMenuHdl, ThumbnailViewItem*, void); + DECL_DLLPRIVATE_LINK(OpenTemplateHdl, ThumbnailViewItem*, void); + DECL_DLLPRIVATE_LINK(EditTemplateHdl, ThumbnailViewItem*, void); + DECL_DLLPRIVATE_LINK(DeleteTemplateHdl, void*, void); + DECL_DLLPRIVATE_LINK(DefaultTemplateHdl, ThumbnailViewItem*, void); + DECL_DLLPRIVATE_LINK(MoveTemplateHdl, void*, void); + DECL_DLLPRIVATE_LINK(ExportTemplateHdl, void*, void); + + void SearchUpdate(); + + DECL_DLLPRIVATE_LINK(SearchUpdateHdl, weld::Entry&, void); + DECL_DLLPRIVATE_LINK(GetFocusHdl, weld::Widget&, void); + DECL_DLLPRIVATE_LINK(LoseFocusHdl, weld::Widget&, void); + DECL_DLLPRIVATE_LINK(ImplUpdateDataHdl, Timer*, void); + DECL_DLLPRIVATE_LINK(KeyInputHdl, const KeyEvent&, bool); + + DECL_DLLPRIVATE_LINK(ListViewHdl, weld::Toggleable&, void); + DECL_DLLPRIVATE_LINK(ThumbnailViewHdl, weld::Toggleable&, void); + DECL_DLLPRIVATE_LINK(FocusRectLocalHdl, weld::Widget&, tools::Rectangle); + + void OnTemplateImportCategory(std::u16string_view sCategory); + // static void OnTemplateLink (); + void OnTemplateOpen(); + void OnTemplateExport(); + + void OnTemplateState(const ThumbnailViewItem* pItem); + + void OnCategoryNew(); + void OnCategoryRename(); + void OnCategoryDelete(); + + void updateMenuItems(); + + /** + * + * Move templates stored in the filesystem to another folder. + * + **/ + + void localMoveTo(sal_uInt16 nMenuId); + + /// Return filter according to the currently selected application filter. + FILTER_APPLICATION getCurrentApplicationFilter() const; + +protected: + std::set maSelTemplates; + css::uno::Reference m_xModel; + css::uno::Reference mxDesktop; + + Timer m_aUpdateDataTimer; + + std::unique_ptr mxSearchFilter; + std::unique_ptr mxCBApp; + std::unique_ptr mxCBFolder; + + std::unique_ptr mxOKButton; + std::unique_ptr mxCBXHideDlg; + std::unique_ptr mxActionBar; + std::unique_ptr mxLocalView; + std::unique_ptr mxTemplateDefaultMenu; + std::unique_ptr mxLocalViewWeld; + std::unique_ptr mxListViewButton; + std::unique_ptr mxThumbnailViewButton; + TemplateViewMode mViewMode; + bool bMakeSelItemVisible; +}; + +// class SfxTemplateCategoryDialog ------------------------------------------------------------------- + +class SfxTemplateCategoryDialog final : public weld::GenericDialogController +{ +private: + OUString msSelectedCategory; + bool mbIsNewCategory; + + std::unique_ptr mxLBCategory; + std::unique_ptr mxSelectLabel; + std::unique_ptr mxNewCategoryEdit; + std::unique_ptr mxCreateLabel; + std::unique_ptr mxOKButton; + +public: + DECL_LINK(NewCategoryEditHdl, weld::Entry&, void); + DECL_LINK(SelectCategoryHdl, weld::TreeView&, void); + + void SetCategoryLBEntries(std::vector names); + + const OUString& GetSelectedCategory() const { return msSelectedCategory; }; + + bool IsNewCategoryCreated() const { return mbIsNewCategory; } + +public: + explicit SfxTemplateCategoryDialog(weld::Window* pParent); + + virtual ~SfxTemplateCategoryDialog() override; +}; + +// class SfxTemplateSelectionDialog ------------------------------------------------------------------- + +class SFX2_DLLPUBLIC SfxTemplateSelectionDlg final : public SfxTemplateManagerDlg +{ +public: + SfxTemplateSelectionDlg(weld::Window* parent); + + virtual ~SfxTemplateSelectionDlg() override; + virtual short run() override; + + OUString const& getTemplatePath() const { return msTemplatePath; }; + bool IsStartWithTemplate() const { return mxCBXHideDlg->get_active(); }; + +private: + DECL_DLLPRIVATE_LINK(OpenTemplateHdl, ThumbnailViewItem*, void); + DECL_DLLPRIVATE_LINK(OkClickHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(TimeOut, Timer*, void); + + OUString msTemplatePath; + Idle maIdle; +}; + +#endif // INCLUDED_SFX2_INC_TEMPLATEDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/templatedlglocalview.hxx b/include/sfx2/templatedlglocalview.hxx new file mode 100644 index 000000000..65b77ead1 --- /dev/null +++ b/include/sfx2/templatedlglocalview.hxx @@ -0,0 +1,72 @@ +/* -*- 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/. + */ +#pragma once + +#include +#include + +class TemplateDlgLocalView final : public TemplateLocalView, public ListView +{ +public: + TemplateDlgLocalView(std::unique_ptr xWindow, + std::unique_ptr xMenu, + std::unique_ptr xTreeView); + + void setTemplateViewMode(TemplateViewMode eMode); + + virtual void showAllTemplates() override; + + void showRegion(TemplateContainerItem const* pItem); + + void showRegion(std::u16string_view rName); + + void reload(); + + virtual bool KeyInput(const KeyEvent& rKEvt) override; + + void createContextMenu(const bool bIsDefault, const bool bIsBuiltIn, const bool bIsSingleSel, + const OUString& rDefaultImg); + + virtual void Show() override; + + virtual void Hide() override; + + bool IsVisible() const; + + void connect_focus_rect(const Link& rLink) + { + GetDrawingArea()->connect_focus_rect(rLink); + } + + void MakeItemVisible(sal_uInt16 nId) { ThumbnailView::MakeItemVisible(nId); } + + void insertItems(const std::vector& rTemplates, bool isRegionSelected, + bool bShowCategoryInTooltip); + +private: + void ContextMenuSelectHdl(std::string_view rIdent); + + void insertFilteredItems(); + + void syncCursor(); + + void updateSelection(); + + DECL_LINK(RowActivatedHdl, weld::TreeView&, bool); + + DECL_LINK(ListViewChangedHdl, weld::TreeView&, void); + + DECL_LINK(PopupMenuHdl, const CommandEvent&, bool); + + DECL_LINK(KeyPressHdl, const KeyEvent&, bool); + + TemplateViewMode mViewMode; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/templatelocalview.hxx b/include/sfx2/templatelocalview.hxx new file mode 100644 index 000000000..020ad2ba3 --- /dev/null +++ b/include/sfx2/templatelocalview.hxx @@ -0,0 +1,192 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_TEMPLATELOCALVIEW_HXX +#define INCLUDED_SFX2_TEMPLATELOCALVIEW_HXX + +#include +#include +#include +#include +#include + +//template thumbnail item defines +#define TEMPLATE_ITEM_MAX_WIDTH 160 +#define TEMPLATE_ITEM_MAX_HEIGHT 148 +#define TEMPLATE_ITEM_PADDING 5 +#define TEMPLATE_ITEM_MAX_TEXT_LENGTH 20 +#define TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT 96 + +//template thumbnail height with a subtitle +#define TEMPLATE_ITEM_MAX_HEIGHT_SUB 160 + +//template thumbnail image defines +#define TEMPLATE_THUMBNAIL_MAX_HEIGHT TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT - 2*TEMPLATE_ITEM_PADDING +#define TEMPLATE_THUMBNAIL_MAX_WIDTH TEMPLATE_ITEM_MAX_WIDTH - 2*TEMPLATE_ITEM_PADDING + +class SfxDocumentTemplates; +class TemplateContainerItem; +class TemplateViewItem; + +enum class FILTER_APPLICATION +{ + NONE, + WRITER, + CALC, + IMPRESS, + DRAW +}; + +// Display template items depending on the generator application +class ViewFilter_Application final +{ +public: + + ViewFilter_Application (FILTER_APPLICATION App) + : mApp(App) + {} + + bool operator () (const ThumbnailViewItem *pItem); + + static bool isFilteredExtension(FILTER_APPLICATION filter, std::u16string_view rExt); + bool isValid (std::u16string_view rPath) const; + +private: + + FILTER_APPLICATION mApp; +}; + +class TemplateLocalView : public ThumbnailView +{ + typedef bool (*selection_cmp_fn)(const ThumbnailViewItem*,const ThumbnailViewItem*); + +public: + + TemplateLocalView(std::unique_ptr xWindow, + std::unique_ptr xMenu); + + virtual ~TemplateLocalView () override; + + // Fill view with new item list + void insertItems (const std::vector &rTemplates, bool isRegionSelected = true, bool bShowCategoryInTooltip = false); + + // Fill view with template folders thumbnails + void Populate (); + + void reload (); + + virtual void showAllTemplates (); + + void showRegion (TemplateContainerItem const *pItem); + + void ContextMenuSelectHdl(std::string_view rIdent); + + TemplateContainerItem* getRegion(std::u16string_view sStr); + + sal_uInt16 getRegionId (size_t pos) const; + + sal_uInt16 getRegionId (std::u16string_view sRegionName) const; + + OUString getRegionName(const sal_uInt16 nRegionId) const; + + OUString getRegionItemName(const sal_uInt16 nItemId) const; + + std::vector getFolderNames (); + + std::vector + getFilteredItems (const std::function &rFunc) const; + + sal_uInt16 createRegion (const OUString &rName); + + bool renameRegion(std::u16string_view rTitle, const OUString &rNewTitle); + + bool removeRegion (const sal_uInt16 nItemId); + + bool removeTemplate (const sal_uInt16 nItemId, const sal_uInt16 nSrcItemId); + + void moveTemplates (const std::set &rItems, const sal_uInt16 nTargetItem); + + bool copyFrom(TemplateContainerItem *pItem, const OUString &rPath); + + bool exportTo (const sal_uInt16 nItemId, const sal_uInt16 nRegionItemId, std::u16string_view rName); + + virtual bool renameItem(ThumbnailViewItem* pItem, const OUString& sNewTitle) override; + + virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; + + virtual bool Command(const CommandEvent& rPos) override; + + virtual bool KeyInput( const KeyEvent& rKEvt ) override; + + sal_uInt16 getCurRegionId () const { return mnCurRegionId;} + + void setCurRegionId (sal_uInt16 nCurRegionId) { mnCurRegionId = nCurRegionId;} + + void setOpenRegionHdl(const Link &rLink); + + void setCreateContextMenuHdl(const Link &rLink); + + void setOpenTemplateHdl(const Link &rLink); + + void setEditTemplateHdl(const Link &rLink); + + void setDeleteTemplateHdl(const Link &rLink); + + void setDefaultTemplateHdl(const Link &rLink); + + void setMoveTemplateHdl(const Link &rLink); + + void setExportTemplateHdl(const Link &rLink); + + void updateThumbnailDimensions(tools::Long itemMaxSize); + + void RemoveDefaultTemplateIcon( std::u16string_view rPath); + + bool IsBuiltInRegion(const OUString& rRegionName); + + static BitmapEx scaleImg (const BitmapEx &rImg, tools::Long width, tools::Long height); + + static BitmapEx getDefaultThumbnail( std::u16string_view rPath ); + + static BitmapEx fetchThumbnail (const OUString &msURL, tools::Long width, tools::Long height); + + static bool IsDefaultTemplate(const OUString& rPath); + + static bool IsInternalTemplate(const OUString& rPath); + +protected: + virtual void OnItemDblClicked(ThumbnailViewItem *pItem) override; + + sal_uInt16 mnCurRegionId; + + TemplateViewItem *maSelectedItem; + + tools::Long mnThumbnailWidth; + tools::Long mnThumbnailHeight; + + Point maPosition; //store the point of click event + + Link maOpenRegionHdl; + Link maCreateContextMenuHdl; + Link maOpenTemplateHdl; + Link maEditTemplateHdl; + Link maDeleteTemplateHdl; + Link maDefaultTemplateHdl; + Link maMoveTemplateHdl; + Link maExportTemplateHdl; + + std::unique_ptr mpDocTemplates; + std::vector > maRegions; + std::vector maAllTemplates; +}; + + +#endif // INCLUDED_SFX2_TEMPLATELOCALVIEW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/templateproperties.hxx b/include/sfx2/templateproperties.hxx new file mode 100644 index 000000000..2c1de0125 --- /dev/null +++ b/include/sfx2/templateproperties.hxx @@ -0,0 +1,29 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_TEMPLATEPROPERTIES_HXX +#define INCLUDED_SFX2_TEMPLATEPROPERTIES_HXX + +#include +#include + +struct TemplateItemProperties +{ + sal_uInt16 nId; ///< Index for ThumbnailView + sal_uInt16 nDocId; ///< Index based on SfxTemplateDocument + sal_uInt16 nRegionId; + OUString aName; + OUString aPath; + OUString aRegionName; + BitmapEx aThumbnail; +}; + +#endif // INCLUDED_SFX2_TEMPLATEPROPERTIES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/templdlg.hxx b/include/sfx2/templdlg.hxx new file mode 100644 index 000000000..5dd5b8b6b --- /dev/null +++ b/include/sfx2/templdlg.hxx @@ -0,0 +1,46 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_TEMPLDLG_HXX +#define INCLUDED_SFX2_TEMPLDLG_HXX + +#include +#include +#include +#include +#include + +class SfxBindings; +class SfxTemplateDialog_Impl; + +class UNLESS_MERGELIBS(SFX2_DLLPUBLIC) SfxTemplatePanelControl final : public PanelLayout +{ +public: + SfxTemplatePanelControl(SfxBindings* pBindings, weld::Widget* pParent); + virtual ~SfxTemplatePanelControl() override; + + weld::Builder* get_builder() { return m_xBuilder.get(); } + weld::Container* get_container() { return m_xContainer.get(); } + +private: + std::unique_ptr pImpl; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/thumbnailview.hxx b/include/sfx2/thumbnailview.hxx new file mode 100644 index 000000000..453f3c9c5 --- /dev/null +++ b/include/sfx2/thumbnailview.hxx @@ -0,0 +1,331 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_THUMBNAILVIEW_HXX +#define INCLUDED_SFX2_THUMBNAILVIEW_HXX + +#include + +#include +#include +#include + +#include + +class BitmapEx; +class MouseEvent; +class KeyEvent; +class DataChangedEvent; +class ScrollBar; +class ThumbnailViewItem; +typedef ::std::vector< ThumbnailViewItem* > ThumbnailValueItemList; + + +struct ThumbnailItemAttributes; + +/************************************************************************* + + Description + ============ + + class ThumbnailView + + This class allows the selection of an item. In the process items are + drawn side by side. The selection of items can be more clear than in a + ListBox shape for example in case of colors or samples. + The amount of columns drawn by the control and whether the items + should be encircled can be specified. Optional a NoSelection or name + field could be shown. By default image and color items are supported. + Items could be drawn by oneself if InsertItem() is only called with + an ID. To achieve this the UserDraw handler needs to be overridden. The + description text could be specified afterwards in case of UserDraw + and any other items. + + Cross references + + class ListBox + + -------------------------------------------------------------------------- + + WinBits + + WB_VSCROLL A scrollbar will be always shown. The visible number of + lines have to be specified with SetLineCount() if this + flag is set. + WB_TABSTOP It is possible to jump into the ValueSet with the tab key. + WB_NOTABSTOP It is not possible to jump into the ValueSet with the + tab key. + -------------------------------------------------------------------------- + + The number of columns must be either set with SetColCount() or + SetItemWidth(). If the number of columns is specified by SetColCount() + the width of the items will be calculated by the visible range. + If the items should have a static width, it has to be specified + with SetItemWidth(). In this case the number of columns will be calculated + by the visible range. + + The number of rows is given by the number of items / number of columns. The + number of visible rows must either specified by SetLineCount() or + SetItemWidth(). If the number of visible rows is specified by SetLineCount(), + the height of the items will be calculated from the visible height. If the + items should have a fixed height it has to be specified with SetItemHeight(). + In this case the number of visible rows is then calculated from the visible + height. If the number of visible rows is neither specified by SetLineCount() + nor by SetItemHeight() all rows will be shown. The height of the items will + be calculated by the visible height. If the number of visible rows is + specified by SetLineCount() or SetItemHeight() ValueSet does scroll + automatically when more lines are available, as are visible. If scrolling + should be also possible with a ScrollBar WB_VSCROLL needs to be set. + + The distance between the items can be increased by SetExtraSpacing(). The + distance, which will be shown between two items (both in x and in y), is + measured in pixels. + + The exact window size for a specific item size can be calculated by + CalcWindowSizePixel(). To do this all relevant data (number of columns/...) + have to be specified and if no number of rows was set, all items need to + be inserted. If the window was created with WB_BORDER/Border=sal_True the + size has to be specified with SetOutputSizePixel(). In other cases different + size-methods can be used. With CalcItemSize() the inner and outer size of + an item could be calculated (for this the free space defined by + SetExtraSpacing() will not be included). + + The background color could be specified by SetColor(), with which the image + or UserDraw items will be underlaid. If no color is specified the color + of other windows (WindowColor) will be used for the background. + + -------------------------------------------------------------------------- + + At first all items should be inserted and only then Show() should be called + since the output area will be precomputed. If this is not done the first + Paint will appear a little bit slower. Therefore the Control, if it is loaded + from the resource and only supplied with items during runtime, should be + loaded with Hide = sal_True and then displayed with Show(). + + In case of a visible Control the creation of the new output area could be + activated before Paint by calling Format(). + + -------------------------------------------------------------------------- + + If Drag and Drop will be called from the ValueSet the Command-Handler has to + be overridden. From this StartDrag needs to be called. If this method returns + sal_True the drag-process could be initiated by ExecuteDrag(), otherwise no + processing will take place. This method makes sure that ValueSet stops its + processing and as appropriate selects the entry. Therefore the calling of + Select-Handler within this function must be expected. + + For dropping QueryDrop() and Drop() need to be overridden and ShowDropPos() + and HideDropPos() should be called within these methods. + To show the insertion point ShowDropPos() has to be called within the + QueryDrop-Handler. ShowDropPos() also scrolls the ValueSet if the passed + position is located at the window border. Furthermore ShowDropPos() returns + the position, at which the item should be inserted respectively which + insertion point was shown. If no insertion point was determined + VALUESET_ITEM_NOTFOUND will be returned. If the window was left during dragging + or the drag process is terminated HideDropPos() should be called in any case. + + -------------------------------------------------------------------------- + + This class is currently still in the SV-Tools. That's why the ValueSet needs + to be loaded as a Control out of the resource and the desired WinBits have + to be set (before Show) with SetStyle(). + +*************************************************************************/ + +/* ThumbnailView types */ + +#define THUMBNAILVIEW_ITEM_NOTFOUND (sal_uInt16(-1)) + +// Display all the available items in the thumbnail. +class ViewFilterAll +{ +public: + + bool operator () (const ThumbnailViewItem*) const + { + return true; + } +}; + +/** + * + * Class to display thumbnails with their names below their respective icons + * + **/ + +class SFX2_DLLPUBLIC ThumbnailView : public weld::CustomWidgetController +{ + friend class ThumbnailViewAcc; + friend class ThumbnailViewItemAcc; + +public: + ThumbnailView(std::unique_ptr xWindow, std::unique_ptr xMenu); + + virtual ~ThumbnailView() override; + + virtual bool MouseMove(const MouseEvent& rMEvt) override; + + /// Updates information in the view; used only in RecentDocsView ATM. + virtual void Reload() {} + + void AppendItem(std::unique_ptr pItem); + + void RemoveItem(sal_uInt16 nItemId); + + virtual void Clear(); + + // Change current thumbnail item list with new one (invalidates all pointers to a thumbnail item) + void updateItems(std::vector> items); + + size_t GetItemPos( sal_uInt16 nItemId ) const; + + sal_uInt16 GetItemId( size_t nPos ) const; + + sal_uInt16 GetItemId( const Point& rPos ) const; + + sal_uInt16 getNextItemId () const; + + virtual bool renameItem(ThumbnailViewItem* pItem, const OUString& sNewTitle); + + bool isDrawMnemonic() const { return mbDrawMnemonics; } + + void setItemMaxTextLength (sal_uInt32 nLength); + + void setItemDimensions (tools::Long ItemWidth, tools::Long ThumbnailHeight, + tools::Long DisplayHeight, int itemPadding); + + void SelectItem( sal_uInt16 nItemId ); + + bool IsItemSelected( sal_uInt16 nItemId ) const; + + /** + * + * @brief deselect all current selected items. + * + **/ + + void deselectItems (); + + void ShowTooltips( bool bShowTooltips ); + + void DrawMnemonics( bool bDrawMnemonics ); + + void filterItems (const std::function &func); + + void setItemStateHdl (const Link &aLink) { maItemStateHdl = aLink; } + + virtual void Resize() override; + + virtual void Show() override + { + mxScrolledWindow->show(); + CustomWidgetController::Show(); + } + + virtual void Hide() override + { + mxScrolledWindow->hide(); + CustomWidgetController::Hide(); + } + + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + + static BitmapEx readThumbnail(const OUString &msURL); + +protected: + + virtual bool KeyInput( const KeyEvent& rKEvt ) override; + + virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; + + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + + virtual void GetFocus() override; + + virtual void LoseFocus() override; + + virtual OUString RequestHelp(tools::Rectangle& rRect) override; + + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; + + const css::uno::Reference & getAccessible() const; + +protected: + + // Drawing item related functions, override them to make your own custom ones. + + void DrawItem (ThumbnailViewItem const *pItem); + + virtual void OnItemDblClicked (ThumbnailViewItem *pItem); + + // Set Item colors from the ThumbnailView colors + void UpdateColors(); + +protected: + + friend class ThumbnailViewAcc; + friend class ThumbnailViewItemAcc; + + void CalculateItemPositions (bool bScrollBarUsed = false); + void MakeItemVisible( sal_uInt16 nId ); + + void ImplInit(); + + void ImplDeleteItems(); + size_t ImplGetItem( const Point& rPoint ) const; + ThumbnailViewItem* ImplGetItem( size_t nPos ); + sal_uInt16 ImplGetVisibleItemCount() const; + ThumbnailViewItem* ImplGetVisibleItem(sal_uInt16 nVisiblePos); + void ImplFireAccessibleEvent( short nEventId, const css::uno::Any& rOldValue, const css::uno::Any& rNewValue ); + bool ImplHasAccessibleListeners() const; + DECL_DLLPRIVATE_LINK( ImplScrollHdl, weld::ScrolledWindow&, void ); + +protected: + + std::vector< std::unique_ptr > mItemList; + css::uno::Reference mxAccessible; + ThumbnailValueItemList mFilteredItemList; ///< Cache to store the filtered items + ThumbnailValueItemList::iterator mpStartSelRange; + tools::Long mnItemWidth; + tools::Long mnItemHeight; + tools::Long mnItemPadding; + tools::Long mnThumbnailHeight; // Maximum height of the thumbnail + tools::Long mnDisplayHeight; // Height of the data display box (name, etc) + tools::Long mnVItemSpace; // Vertical spacing between rows, -1 to use excess unused height split up between items + tools::Long mnVisLines; + tools::Long mnLines; + + sal_uInt16 mnCols; + sal_uInt16 mnFirstLine; + bool mbScroll : 1; // Whether we need to scroll + bool mbAllowVScrollBar : 1; // Whether to show a visible scrollbar + bool mbHasVisibleItems : 1; + bool mbShowTooltips : 1; + bool mbDrawMnemonics : 1; + bool mbSelectOnFocus : 1; + Color maFillColor; ///< Background color of the thumbnail view widget. + Color maTextColor; ///< Text color. + Color maHighlightColor; ///< Color of the highlight (background) of the hovered item. + Color maHighlightTextColor; ///< Color of the text for the highlighted item. + Color maSelectHighlightColor; ///< Color of the highlight (background) of the selected and hovered item. + Color maSelectHighlightTextColor; ///< Color of the text of the selected and hovered item. + double mfHighlightTransparence; ///< Transparence of the highlight. + + Link maItemStateHdl; + std::unique_ptr mpItemAttrs; + std::unique_ptr mxScrolledWindow; + std::unique_ptr mxContextMenu; + + std::function maFilterFunc; +}; + + +#endif // INCLUDED_SFX2_THUMBNAILVIEW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/thumbnailviewitem.hxx b/include/sfx2/thumbnailviewitem.hxx new file mode 100644 index 000000000..d0da2edae --- /dev/null +++ b/include/sfx2/thumbnailviewitem.hxx @@ -0,0 +1,138 @@ +/* -*- 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 + +namespace com::sun::star::accessibility { class XAccessible; } +namespace drawinglayer::primitive2d { class Primitive2DContainer; } + +#define THUMBNAILVIEW_ITEM_NONEITEM 0xFFFE + +const int THUMBNAILVIEW_ITEM_CORNER = 5; + +class ThumbnailView; +class MouseEvent; + +namespace basegfx { + class B2DPolygon; +} + +namespace drawinglayer { + namespace processor2d { + class BaseProcessor2D; + } + namespace primitive2d { + class PolygonHairlinePrimitive2D; + } +} + +struct ThumbnailItemAttributes +{ + sal_uInt32 nMaxTextLength; + basegfx::BColor aFillColor; + basegfx::BColor aTextColor; + basegfx::BColor aHighlightColor; + basegfx::BColor aHighlightTextColor; + basegfx::BColor aSelectHighlightColor; + basegfx::BColor aSelectHighlightTextColor; + double fHighlightTransparence; + basegfx::B2DVector aFontSize; + drawinglayer::attribute::FontAttribute aFontAttr; +}; + +class SFX2_DLLPUBLIC ThumbnailViewItem +{ +public: + + ThumbnailView& mrParent; + sal_uInt16 mnId; + bool mbVisible; + bool mbBorder; + bool mbSelected; + bool mbHover; + BitmapEx maPreview1; + OUString maTitle; + OUString maHelpText; + css::uno::Reference< css::accessibility::XAccessible > mxAcc; + + ThumbnailViewItem(ThumbnailView& rView, sal_uInt16 nId); + + virtual ~ThumbnailViewItem (); + + bool isVisible () const { return mbVisible; } + + void show (bool bVisible); + + bool isSelected () const { return mbSelected; } + + void setSelection (bool state); + + bool isHighlighted () const { return mbHover; } + + void setHighlight (bool state); + + /** Updates own highlight status based on the aPoint position. + + Returns rectangle that needs to be invalidated. + */ + virtual tools::Rectangle updateHighlight(bool bVisible, const Point& rPoint); + + /// Text to be used for the tooltip. + + void setHelpText (const OUString &sText) { maHelpText = sText; } + + virtual OUString getHelpText() const { return maHelpText; }; + OUString const & getTitle() const { return maTitle; }; + + void setTitle (const OUString& rTitle); + + css::uno::Reference< css::accessibility::XAccessible > const & + GetAccessible( bool bIsTransientChildrenDisabled ); + + void setDrawArea (const tools::Rectangle &area); + + const tools::Rectangle& getDrawArea () const { return maDrawArea; } + + virtual void calculateItemsPosition (const tools::Long nThumbnailHeight, + const tools::Long nPadding, sal_uInt32 nMaxTextLength, + const ThumbnailItemAttributes *pAttrs); + + virtual void Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor, + const ThumbnailItemAttributes *pAttrs); + void addTextPrimitives (const OUString& rText, const ThumbnailItemAttributes *pAttrs, Point aPos, drawinglayer::primitive2d::Primitive2DContainer& rSeq); + + static rtl::Reference + createBorderLine (const basegfx::B2DPolygon &rPolygon); + + virtual void MouseButtonUp(const MouseEvent&) {} + +protected: + + Point maTextPos; + Point maPrev1Pos; + tools::Rectangle maDrawArea; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/toolbarids.hxx b/include/sfx2/toolbarids.hxx new file mode 100644 index 000000000..1aedb4eda --- /dev/null +++ b/include/sfx2/toolbarids.hxx @@ -0,0 +1,77 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_TOOLBARIDS_HXX +#define INCLUDED_SFX2_TOOLBARIDS_HXX + +#include + +//these numbers end up in the configuration to identify toolbars +//so don't blindly change their numbers +enum class ToolbarId : sal_uInt32 +{ + None = 0, + FullScreenToolbox = 558, + EnvToolbox = 560, + Svx_Extrusion_Bar = 10986, + Svx_Fontwork_Bar = 10987, + Basicide_Objectbar = 14850, + SvxTbx_Form_Navigation = 18001, + SvxTbx_Form_Filter = 18002, + SvxTbx_Text_Control_Attributes = 18003, + SvxTbx_Controls = 18004, + SvxTbx_FormDesign = 18006, + Math_Toolbox = 20050, + Webtools_Toolbox = 20402, + Webtext_Toolbox = 20403, + Webframe_Toolbox = 20408, + Webgraphic_Toolbox = 20410, + Webole_Toolbox = 20411, + Draw_Toolbox_Sd = 23011, + Slide_Toolbox = 23012, + Draw_Obj_Toolbox = 23013, + Slide_Obj_Toolbox = 23014, + Bezier_Toolbox_Sd = 23015, + Draw_Text_Toolbox_Sd = 23016, + Outline_Toolbox = 23017, + Draw_Table_Toolbox = 23018, + Gluepoints_Toolbox = 23019, + Draw_Options_Toolbox = 23020, + Draw_CommonTask_Toolbox = 23021, + FormLayer_Toolbox = 23022, + Draw_Viewer_Toolbox = 23023, + Graphic_Obj_Toolbox = 23027, + Draw_Graf_Toolbox = 23030, + Draw_Media_Toolbox = 23031, + Text_Toolbox_Sw = 23265, + Table_Toolbox = 23266, + Frame_Toolbox = 23267, + Grafik_Toolbox = 23268, + Draw_Toolbox_Sw = 23269, + Draw_Text_Toolbox_Sw = 23270, + Num_Toolbox = 23271, + Ole_Toolbox = 23272, + Tools_Toolbox = 23273, + PView_Toolbox = 23281, + Bezier_Toolbox_Sw = 23283, + Module_Toolbox = 23310, + Media_Toolbox = 23311, + Objectbar_App = 25000, + Objectbar_Format = 25001, + Text_Toolbox_Sc = 25005, + Objectbar_Preview = 25006, + Objectbar_Tools = 25035, + Draw_Objectbar = 25053, + Graphic_Objectbar = 25054, + Media_Objectbar = 25060 +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/sfx2/tplpitem.hxx b/include/sfx2/tplpitem.hxx new file mode 100644 index 000000000..647e2b8e7 --- /dev/null +++ b/include/sfx2/tplpitem.hxx @@ -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 . + */ +#ifndef INCLUDED_SFX2_TPLPITEM_HXX +#define INCLUDED_SFX2_TPLPITEM_HXX + +#include +#include +#include +#include +#include + +class SFX2_DLLPUBLIC SfxTemplateItem final : public SfxFlagItem +{ + OUString aStyle; + OUString aStyleIdentifier; +public: + static SfxPoolItem* CreateDefault(); + SfxTemplateItem(); + SfxTemplateItem( sal_uInt16 nWhich, + const OUString &rStyle, + const OUString &rStyleIdentifier = "" ); + + const OUString& GetStyleName() const { return aStyle; } + const OUString& GetStyleIdentifier() const { return aStyleIdentifier; } + + virtual SfxTemplateItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool operator==( const SfxPoolItem& ) const override; + virtual sal_uInt8 GetFlagCount() const override; + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; + SfxStyleSearchBits GetValue() const { return static_cast(SfxFlagItem::GetValue()); } + void SetValue(SfxStyleSearchBits n) { SfxFlagItem::SetValue(static_cast(n)); } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/userinputinterception.hxx b/include/sfx2/userinputinterception.hxx new file mode 100644 index 000000000..f94857978 --- /dev/null +++ b/include/sfx2/userinputinterception.hxx @@ -0,0 +1,82 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SFX2_USERINPUTINTERCEPTION_HXX +#define INCLUDED_SFX2_USERINPUTINTERCEPTION_HXX + +#include + +#include + +namespace com::sun::star::awt { class XKeyHandler; } +namespace com::sun::star::awt { class XMouseClickHandler; } +namespace com::sun::star::uno { template class Reference; } +namespace osl { class Mutex; } + +class NotifyEvent; + +namespace cppu { class OWeakObject; } + + +namespace sfx2 +{ + + + //= UserInputInterception + + struct UserInputInterception_Data; + /** helper class for implementing the XUserInputInterception interface + for a controller implementation + */ + class SFX2_DLLPUBLIC UserInputInterception + { + public: + UserInputInterception( ::cppu::OWeakObject& _rControllerImpl, ::osl::Mutex& _rMutex ); + ~UserInputInterception(); + UserInputInterception(const UserInputInterception&) = delete; + UserInputInterception& operator=( const UserInputInterception& ) = delete; + + // delegator functions for your XUserInputInterception implementation + /// @throws css::uno::RuntimeException + void addKeyHandler( const css::uno::Reference< css::awt::XKeyHandler >& xHandler ); + /// @throws css::uno::RuntimeException + void removeKeyHandler( const css::uno::Reference< css::awt::XKeyHandler >& xHandler ); + /// @throws css::uno::RuntimeException + void addMouseClickHandler( const css::uno::Reference< css::awt::XMouseClickHandler >& xHandler ); + /// @throws css::uno::RuntimeException + void removeMouseClickHandler( const css::uno::Reference< css::awt::XMouseClickHandler >& xHandler ); + + // state + bool hasKeyHandlers() const; + bool hasMouseClickListeners() const; + + // forwarding a NotifyEvent to the KeyListeners respectively MouseClickListeners + bool handleNotifyEvent( const NotifyEvent& _rEvent ); + + private: + ::std::unique_ptr< UserInputInterception_Data > m_pData; + }; + + +} // namespace sfx2 + + +#endif // INCLUDED_SFX2_USERINPUTINTERCEPTION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/viewfac.hxx b/include/sfx2/viewfac.hxx new file mode 100644 index 000000000..efd511ea2 --- /dev/null +++ b/include/sfx2/viewfac.hxx @@ -0,0 +1,60 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_VIEWFAC_HXX +#define INCLUDED_SFX2_VIEWFAC_HXX + +#include +#include +#include +#include + +class SfxViewFrame; +class SfxViewShell; + +typedef SfxViewShell* (*SfxViewCtor)(SfxViewFrame*, SfxViewShell*); + +// CLASS ----------------------------------------------------------------- +class SFX2_DLLPUBLIC SfxViewFactory +{ +public: + SfxViewFactory( SfxViewCtor fnC, + SfxInterfaceId nOrdinal, const char* asciiViewName ); + + SfxViewShell* CreateInstance(SfxViewFrame *pViewFrame, SfxViewShell *pOldSh); + SfxInterfaceId GetOrdinal() const { return nOrd; } + + /// returns a legacy view name. This is "view" with an appended ordinal/ID. + OUString GetLegacyViewName() const; + + /** returns an API-compatible view name. + + For details on which view names are specified, see the XModel2.getAvailableViewControllerNames + documentation. + */ + OUString GetAPIViewName() const; + +private: + SfxViewCtor fnCreate; + SfxInterfaceId nOrd; + const OUString m_sViewName; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx new file mode 100644 index 000000000..24d1c35db --- /dev/null +++ b/include/sfx2/viewfrm.hxx @@ -0,0 +1,277 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_VIEWFRM_HXX +#define INCLUDED_SFX2_VIEWFRM_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace weld { + class Button; + class Window; +} +class SvBorder; +class SfxDispatcher; +class SfxBindings; +class SfxProgress; +class SfxViewShell; +class Point; +class Size; +class SfxChildWindow; +class SfxInfoBarWindow; +enum class InfobarType; +class CommandPopupHandler; + +class SFX2_DLLPUBLIC SfxViewFrame final : public SfxShell, public SfxListener +{ + std::unique_ptr m_pImpl; + + SfxObjectShellRef m_xObjSh; + std::unique_ptr m_pDispatcher; + SfxBindings* m_pBindings; + ImplSVHelpData* m_pHelpData; + ImplSVWinData* m_pWinData; + sal_uInt16 m_nAdjustPosPixelLock; + + std::unique_ptr m_pCommandPopupHandler; + + SAL_DLLPRIVATE void Construct_Impl( SfxObjectShell *pObjSh ); + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + DECL_DLLPRIVATE_LINK(GetInvolvedHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(DonationHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(WhatsNewHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(SwitchReadOnlyHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(SignDocumentHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(HiddenTrackChangesHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(HyphenationMissingHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(RefreshMasterPasswordHdl, weld::Button&, void); + SAL_DLLPRIVATE void KillDispatcher_Impl(); + + virtual ~SfxViewFrame() override; + +public: + SfxViewFrame( SfxFrame& rFrame, SfxObjectShell *pDoc ); + + SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWFRM) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + + static void SetViewFrame( SfxViewFrame* ); + + static SfxViewFrame* LoadHiddenDocument( SfxObjectShell const & i_rDoc, SfxInterfaceId i_nViewId ); + static SfxViewFrame* LoadDocument( SfxObjectShell const & i_rDoc, SfxInterfaceId i_nViewId ); + static SfxViewFrame* LoadDocumentIntoFrame( SfxObjectShell const & i_rDoc, const SfxFrameItem* i_pFrameItem, SfxInterfaceId i_nViewId ); + static SfxViewFrame* LoadDocumentIntoFrame( SfxObjectShell const & i_rDoc, const css::uno::Reference< css::frame::XFrame >& i_rFrameItem ); + static SfxViewFrame* DisplayNewDocument( SfxObjectShell const & i_rDoc, const SfxRequest& i_rCreateDocRequest ); + + static SfxViewFrame* Current(); + static SfxViewFrame* GetFirst( const SfxObjectShell* pDoc = nullptr, bool bOnlyVisible = true ); + static SfxViewFrame* GetNext( const SfxViewFrame& rPrev, const SfxObjectShell* pDoc = nullptr, bool bOnlyVisible = true ); + + static SfxViewFrame* Get( const css::uno::Reference< css::frame::XController>& i_rController, const SfxObjectShell* i_pDoc ); + + void DoActivate(bool bMDI); + void DoDeactivate(bool bMDI, SfxViewFrame const *pOld); + + using SfxShell::GetDispatcher; + SfxDispatcher* GetDispatcher() { return m_pDispatcher.get(); } + SfxBindings& GetBindings() { return *m_pBindings; } + const SfxBindings& GetBindings() const { return *m_pBindings; } + vcl::Window& GetWindow() const; + weld::Window* GetFrameWeld() const; + + SfxProgress* GetProgress() const; + + void LockAdjustPosSizePixel() + { m_nAdjustPosPixelLock++; } + void UnlockAdjustPosSizePixel() + { m_nAdjustPosPixelLock--; } + void DoAdjustPosSizePixel( SfxViewShell * pSh, + const Point &rPos, const Size &rSize, + bool inplaceEditModeChange ); + void Show(); + bool IsVisible() const; + void ToTop(); + void Enable( bool bEnable ); + void Close(); + virtual void Activate( bool bUI ) override; + virtual void Deactivate( bool bUI ) override; + + void UpdateTitle(); + + // interne Handler + SAL_DLLPRIVATE void SetBorderPixelImpl( const SfxViewShell *pSh, const SvBorder &rBorder ); + SAL_DLLPRIVATE const SvBorder& GetBorderPixelImpl() const; + SAL_DLLPRIVATE void InvalidateBorderImpl( const SfxViewShell *pSh ); + + virtual SfxObjectShell* GetObjectShell() override; + SfxInterfaceId GetCurViewId() const; + SfxFrame& GetFrame() const; + SfxViewFrame* GetTopViewFrame() const; + + bool DoClose(); + static void GetTargetList( TargetList& rList ) + { SfxFrame::GetDefaultTargetList( rList ); } + + void SetModalMode( bool ); + bool IsInModalMode() const; + void Resize(bool bForce=false); + + void SetChildWindow(sal_uInt16 nId, bool bVisible, bool bSetFocus=true); + void ToggleChildWindow(sal_uInt16); + bool HasChildWindow(sal_uInt16); + bool KnowsChildWindow(sal_uInt16); + void ShowChildWindow(sal_uInt16,bool bVisible=true); + SfxChildWindow* GetChildWindow(sal_uInt16); + void ChildWindowExecute(SfxRequest&); + void ChildWindowState(SfxItemSet&); + + /** Append a new InfoBar (see https://wiki.documentfoundation.org/Design/Whiteboards/Infobar). + + The buttons will be added from Right to Left at the right of the info bar. The parent, size + and position of each button will be changed: only the width will remain unchanged. + */ + VclPtr AppendInfoBar(const OUString& sId, + const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, + InfobarType aInfobarType, + bool bShowCloseButton=true); + void RemoveInfoBar(std::u16string_view sId); + void UpdateInfoBar(std::u16string_view sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, + InfobarType eType); + bool HasInfoBarWithID(std::u16string_view sId); + void AppendReadOnlyInfobar(); + + SAL_DLLPRIVATE void GetDocNumber_Impl(); + SAL_DLLPRIVATE void SetViewShell_Impl( SfxViewShell *pVSh ); + SAL_DLLPRIVATE void ReleaseObjectShell_Impl(); + + SAL_DLLPRIVATE void GetState_Impl( SfxItemSet &rSet ); + void ExecReload_Impl(SfxRequest& rReq); + SAL_DLLPRIVATE void StateReload_Impl( SfxItemSet &rSet ); + SAL_DLLPRIVATE void ExecView_Impl( SfxRequest &rReq ); + SAL_DLLPRIVATE void StateView_Impl( SfxItemSet &rSet ); + SAL_DLLPRIVATE void ExecHistory_Impl( SfxRequest &rReq ); + SAL_DLLPRIVATE void StateHistory_Impl( SfxItemSet &rSet ); + SAL_DLLPRIVATE void ForceOuterResize_Impl(); + SAL_DLLPRIVATE void UpdateDocument_Impl(); + + SAL_DLLPRIVATE void LockObjectShell_Impl(); + + SAL_DLLPRIVATE void MakeActive_Impl( bool bActivate ); + SAL_DLLPRIVATE const Size& GetMargin_Impl() const; + SAL_DLLPRIVATE OUString GetActualPresentationURL_Impl() const; + SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &); + SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &); + SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl(); + SAL_DLLPRIVATE void AddDispatchMacroToBasic_Impl(const OUString& sMacro); + + SAL_DLLPRIVATE void Exec_Impl(SfxRequest &); + SAL_DLLPRIVATE void INetExecute_Impl(SfxRequest &); + SAL_DLLPRIVATE void INetState_Impl(SfxItemSet &); + + SAL_DLLPRIVATE void SetCurViewId_Impl( const SfxInterfaceId i_nID ); + +private: + SAL_DLLPRIVATE bool SwitchToViewShell_Impl( sal_uInt16 nNo, bool bIsIndex = false ); + SAL_DLLPRIVATE void PopShellAndSubShells_Impl( SfxViewShell& i_rViewShell ); + SAL_DLLPRIVATE void SaveCurrentViewData_Impl( const SfxInterfaceId i_nNewViewId ); + + /** loads the given existing document into the given frame + + This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked. + + @param i_rDoc + the document to load + @param i_rFrame + the frame to load the document into + @param i_rLoadArgs + the arguments to pass to the component loader. If this sequence is empty, then the current arguments of the + model will be obtained, and passed to the loader. This ensures that any arguments in the model will be preserved, + instead of being reset. + @param i_nViewId + the ID of the view to create + @throws Exception + if something goes wrong. The caller is responsible for handling this. + */ + SAL_DLLPRIVATE static SfxViewShell* LoadViewIntoFrame_Impl( + const SfxObjectShell& i_rDoc, + const css::uno::Reference< css::frame::XFrame >& i_rFrame, + const css::uno::Sequence< css::beans::PropertyValue >& i_rLoadArgs, + const SfxInterfaceId i_nViewId, + const bool i_bHidden + ); + + /** loads the given existing document into the given frame + + This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked. + + If no frame is given, a blank top level frame is created. + + If anything fails during the process, as much as possible is cleaned up. + + @param i_rDoc + the document to load + @param i_rFrame + the frame to load the document into. Might be , in which case a new frame is created. + @param i_nViewId + the ID of the view to create + */ + SAL_DLLPRIVATE static SfxViewFrame* LoadViewIntoFrame_Impl_NoThrow( + const SfxObjectShell& i_rDoc, + const css::uno::Reference< css::frame::XFrame >& i_rFrame, + const SfxInterfaceId i_nViewId, + const bool i_bHidden + ); +}; + + +class SFX2_DLLPUBLIC SfxViewFrameItem final : public SfxPoolItem +{ + SfxViewFrame* pFrame; + +public: + SfxViewFrameItem( SfxViewFrame *pViewFrame ): + SfxPoolItem( 0 ), + pFrame( pViewFrame) + {} + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual SfxViewFrameItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + SfxViewFrame* GetFrame() const + { return pFrame; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx new file mode 100644 index 000000000..31fac39ee --- /dev/null +++ b/include/sfx2/viewsh.hxx @@ -0,0 +1,435 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_VIEWSH_HXX +#define INCLUDED_SFX2_VIEWSH_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class SfxTabPage; +class SfxBaseController; +class Size; +class Point; +class Fraction; +namespace weld { + class Container; + class DialogController; + class Window; +} +class KeyEvent; +class SvBorder; +class SdrView; +class SfxModule; +class SfxViewFrame; +class Printer; +class SfxPrinter; +class NotifyEvent; +class SfxInPlaceClient; +class SfxLokCallbackInterface; +namespace vcl { class PrinterController; } + +namespace com::sun::star::awt{ class XPopupMenu; } +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::datatransfer::clipboard { class XClipboardListener; } +namespace com::sun::star::datatransfer::clipboard { class XClipboardNotifier; } +namespace com::sun::star::embed { class XEmbeddedObject; } +namespace com::sun::star::frame { class XController; } +namespace com::sun::star::frame { class XModel; } +namespace com::sun::star::ui { class XContextMenuInterceptor; } +namespace com::sun::star::ui { struct ContextMenuExecuteEvent; } +namespace com::sun::star::view { class XRenderable; } + + +enum class SfxPrinterChangeFlags +{ + NONE = 0, + PRINTER = 1, // without JOB SETUP => Temporary + JOBSETUP = 2, + OPTIONS = 4, + CHG_ORIENTATION = 8, + CHG_SIZE = 16 +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} +#define SFX_PRINTER_ALL (SfxPrinterChangeFlags::PRINTER | SfxPrinterChangeFlags::JOBSETUP | SfxPrinterChangeFlags::OPTIONS | SfxPrinterChangeFlags::CHG_ORIENTATION | SfxPrinterChangeFlags::CHG_SIZE) + +#define SFX_PRINTERROR_BUSY 1 + +// "Verified" using www.apple.com and Netscape 3.01 +#define DEFAULT_MARGIN_WIDTH 8 +#define DEFAULT_MARGIN_HEIGHT 12 + + +// @[SfxViewShell-Flags] + +enum class SfxViewShellFlags +{ + NONE = 0x0000, + HAS_PRINTOPTIONS = 0x0010, /* Options-Button and Options-Dialog in PrintDialog */ + NO_NEWWINDOW = 0x0100, /* Allow N View */ +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +/* [Description] + + The SfxViewShell flags control the behavior of SfxViewShell for the + duration of its lifetime. They are defined in the constructor of + . +*/ + +enum class LOKDeviceFormFactor +{ + UNKNOWN = 0, + DESKTOP = 1, + TABLET = 2, + MOBILE = 3 +}; + +class SfxViewFactory; +#define SFX_DECL_VIEWFACTORY(Class) \ +private: \ + static SfxViewFactory *s_pFactory; \ +public: \ + static SfxViewShell *CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldView); \ + static void RegisterFactory( SfxInterfaceId nPrio ); \ + static SfxViewFactory*Factory() { return s_pFactory; } \ + static void InitFactory() + +#define SFX_IMPL_NAMED_VIEWFACTORY(Class, AsciiViewName) \ + SfxViewFactory* Class::s_pFactory; \ + SfxViewShell* Class::CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldView) \ + { return new Class(pFrame, pOldView); } \ + void Class::RegisterFactory( SfxInterfaceId nPrio ) \ + { \ + s_pFactory = new SfxViewFactory(&CreateInstance,nPrio,AsciiViewName);\ + InitFactory(); \ + } \ + void Class::InitFactory() + +#define SFX_VIEW_REGISTRATION(DocClass) \ + DocClass::Factory().RegisterViewFactory( *Factory() ) + +template bool checkSfxViewShell(const SfxViewShell* pShell) +{ + return dynamic_cast(pShell) != nullptr; +} + +/** + * One SfxViewShell more or less represents one edit window for a document, there can be multiple + * ones for a single opened document (SfxObjectShell). + */ +class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener, public OutlinerViewShell, public vcl::ILibreOfficeKitNotifier +{ +friend class SfxViewFrame; +friend class SfxBaseController; +friend class SfxPrinterController; + + std::unique_ptr pImpl; + SfxViewFrame* pFrame; + VclPtr pWindow; + bool bNoNewWindow; + bool mbPrinterSettingsModified; + LanguageTag maLOKLanguageTag; + LanguageTag maLOKLocale; + LOKDeviceFormFactor maLOKDeviceFormFactor; + std::unordered_set mvLOKBlockedCommandList; + + /// Used to set the DocId at construction time. See SetCurrentDocId. + static ViewShellDocId mnCurrentDocId; + +protected: + virtual void Activate(bool IsMDIActivate) override; + virtual void Deactivate(bool IsMDIActivate) override; + + virtual void InnerResizePixel( const Point &rOfs, const Size &rSize, bool inplaceEditModeChange ); + virtual void OuterResizePixel( const Point &rOfs, const Size &rSize ); + virtual void SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY ); + + virtual void Move(); + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + +public: + // Iteration + static SfxViewShell* GetFirst( bool bOnlyVisible = true, const std::function& isViewShell = nullptr ); + static SfxViewShell* GetNext( const SfxViewShell& rPrev, + bool bOnlyVisible = true, + const std::function& isViewShell = nullptr ); + static SfxViewShell* Current(); + + static SfxViewShell* Get( const css::uno::Reference< css::frame::XController>& i_rController ); + + // Initialize Constructors/Destructors + SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWSH) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + + SfxViewShell( SfxViewFrame *pFrame, SfxViewShellFlags nFlags ); + virtual ~SfxViewShell() override; + + SfxInPlaceClient* GetIPClient() const; + SfxInPlaceClient* GetUIActiveClient() const; + SfxInPlaceClient* FindIPClient( const css::uno::Reference < css::embed::XEmbeddedObject >& xObj, vcl::Window *pObjParentWin ) const; + + virtual ErrCode DoVerb(sal_Int32 nVerb); + + void OutplaceActivated( bool bActive ); + virtual void UIActivating( SfxInPlaceClient* pClient ); + virtual void UIDeactivated( SfxInPlaceClient* pClient ); + + void JumpToMark( const OUString& rMark ); + void VisAreaChanged(); + + // Misc + + /** + * Initialize is called after the frame has been loaded and the controller + * has been set. By the time this is called the document has been fully + * imported. + * @param bOnlyASample used by some dialogs to avoid constructing monster strings e.g. in calc + */ + virtual bool PrepareClose( bool bUI = true ); + virtual OUString GetSelectionText( bool bCompleteWords = false, bool bOnlyASample = false ); + virtual bool HasSelection( bool bText = true ) const; + virtual SdrView* GetDrawView() const; + + void AddSubShell( SfxShell& rShell ); + void RemoveSubShell( SfxShell *pShell=nullptr ); + SfxShell* GetSubShell( sal_uInt16 ); + + virtual SfxShell* GetFormShell() { return nullptr; }; + virtual const SfxShell* GetFormShell() const { return nullptr; }; + + // ILibreOfficeKitNotifier + virtual void notifyWindow(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const std::vector& rPayload = std::vector()) const override; + + // Focus, KeyInput, Cursor + virtual void ShowCursor( bool bOn = true ); + virtual bool KeyInput( const KeyEvent &rKeyEvent ); + bool Escape(); + + // Viewing Interface + vcl::Window* GetWindow() const { return pWindow; } + weld::Window* GetFrameWeld() const; + void SetWindow( vcl::Window *pViewPort ); + const SvBorder& GetBorderPixel() const; + void SetBorderPixel( const SvBorder &rBorder ); + void InvalidateBorder(); + inline SfxViewFrame* GetViewFrame() const; + + // Printing Interface + virtual SfxPrinter* GetPrinter( bool bCreate = false ); + virtual sal_uInt16 SetPrinter( SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL ); + virtual bool HasPrintOptionsPage() const; + virtual std::unique_ptr CreatePrintOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rOptions); + Printer* GetActivePrinter() const; + + // Working set + virtual void WriteUserData( OUString&, bool bBrowse = false ); + virtual void ReadUserData( const OUString&, bool bBrowse = false ); + virtual void WriteUserDataSequence ( css::uno::Sequence < css::beans::PropertyValue >& ); + virtual void ReadUserDataSequence ( const css::uno::Sequence < css::beans::PropertyValue >& ); + virtual void QueryObjAreaPixel( tools::Rectangle& rRect ) const; + + virtual SfxObjectShell* GetObjectShell() override; + + /** retrieves the document which shall be considered the "current document" when the frame is active + + The default implementation simply returns the XModel of the associated SfxObjectShell. You will rarely + need to overwrite this behavior. + */ + virtual css::uno::Reference< css::frame::XModel > + GetCurrentDocument() const; + + /** forwards the current document, as returned by ->GetCurrentDocument, to SfxObjectShell::SetWorkingDocument + */ + void SetCurrentDocument() const; + + /** get an XRenderable instance that can render this document + */ + virtual css::uno::Reference< css::view::XRenderable > GetRenderable(); + + + virtual void MarginChanged(); + const Size& GetMargin() const; + void SetMargin( const Size& ); + void DisconnectAllClients(); + bool NewWindowAllowed() const { return !bNoNewWindow; } + void SetNewWindowAllowed( bool bSet ) { bNoNewWindow = !bSet; } + + void SetController( SfxBaseController* pController ); + css::uno::Reference GetController() const; + + bool TryContextMenuInterception(const css::uno::Reference& rIn, + const OUString& rMenuIdentifier, + css::uno::Reference& rOut, + css::ui::ContextMenuExecuteEvent aEvent); + bool TryContextMenuInterception(const css::uno::Reference&, + const OUString& rMenuIdentifier, + css::ui::ContextMenuExecuteEvent aEvent); + + void ExecPrint( const css::uno::Sequence < css::beans::PropertyValue >&, bool, bool ); + // Like ExecPrint(), but only sets up for printing. Use Printer::ExecutePrintJob() and Printer::FinishPrintJob() afterwards. + void StartPrint( const css::uno::Sequence < css::beans::PropertyValue >&, bool, bool ); + const std::shared_ptr< vcl::PrinterController >& GetPrinterController() const; + + void AddRemoveClipboardListener( const css::uno::Reference < css::datatransfer::clipboard::XClipboardListener>&, bool ); + css::uno::Reference< css::datatransfer::clipboard::XClipboardNotifier > GetClipboardNotifier() const; + + SAL_DLLPRIVATE SfxInPlaceClient* GetUIActiveIPClient_Impl() const; + SAL_DLLPRIVATE void AddContextMenuInterceptor_Impl( const css::uno::Reference < css::ui::XContextMenuInterceptor >& xInterceptor ); + SAL_DLLPRIVATE void RemoveContextMenuInterceptor_Impl( const css::uno::Reference < css::ui::XContextMenuInterceptor >& xInterceptor ); + SAL_DLLPRIVATE bool GlobalKeyInput_Impl( const KeyEvent &rKeyEvent ); + + SAL_DLLPRIVATE void NewIPClient_Impl( SfxInPlaceClient *pIPClient ); + SAL_DLLPRIVATE void IPClientGone_Impl( SfxInPlaceClient const *pIPClient ); + SAL_DLLPRIVATE void ResetAllClients_Impl( SfxInPlaceClient const *pIP ); + + SAL_DLLPRIVATE void SetPrinter_Impl( VclPtr& pNewPrinter ); + + SAL_DLLPRIVATE bool HandleNotifyEvent_Impl( NotifyEvent const & rEvent ); + SAL_DLLPRIVATE bool HasKeyListeners_Impl() const; + SAL_DLLPRIVATE bool HasMouseClickListeners_Impl() const; + + SAL_DLLPRIVATE SfxBaseController* GetBaseController_Impl() const; + + // Shell Interface + SAL_DLLPRIVATE void ExecPrint_Impl(SfxRequest &); + SAL_DLLPRIVATE void ExecMisc_Impl(SfxRequest &); + SAL_DLLPRIVATE void GetState_Impl(SfxItemSet&); + SAL_DLLPRIVATE void CheckIPClient_Impl(SfxInPlaceClient const *, const tools::Rectangle&); + SAL_DLLPRIVATE void PushSubShells_Impl( bool bPush=true ); + SAL_DLLPRIVATE void PopSubShells_Impl() { PushSubShells_Impl( false ); } + SAL_DLLPRIVATE bool ExecKey_Impl(const KeyEvent& aKey); + + /// Set up a more efficient internal callback instead of LibreOfficeKitCallback. + void setLibreOfficeKitViewCallback(SfxLokCallbackInterface* pCallback); + /// Invokes the registered callback, if there are any. + virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const override; + virtual void libreOfficeKitViewCallbackWithViewId(int nType, const char* pPayload, int nViewId) const override; + virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart) const override; + // Performs any pending calls to libreOfficeKitViewInvalidateTilesCallback() as necessary. + virtual void flushPendingLOKInvalidateTiles(); + virtual void libreOfficeKitViewUpdatedCallback(int nType) const override; + virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, int nSourceViewId) const override; + // Returns current payload for nType, after libreOfficeKitViewUpdatedCallback() or + // libreOfficeKitViewUpdatedCallbackPerViewId() were called. If no payload should + // be generated, the ignore flag should be set. + virtual OString getLOKPayload(int nType, int nViewId, bool* ignore) const; + + /// Set if we are doing tiled searching. + void setTiledSearching(bool bTiledSearching); + /// See lok::Document::getPart(). + virtual int getPart() const; + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; + /// See OutlinerViewShell::GetViewShellId(). + ViewShellId GetViewShellId() const override; + + /// Set the current DocId, which is used by Mobile LOKit to + /// load multiple documents and yet identify the views of each. + /// There are events that are fired while creating a new view, + /// and if we don't have a DocId, we can't know which other views + /// within the same document (if any) should get those events. + /// By setting this static value, we are able to set the DocId + /// of each SfxViewShell at construction time. + static void SetCurrentDocId(ViewShellDocId nId); + /// Get the DocId used by Mobile LOKit to load multiple documents. + ViewShellDocId GetDocId() const override; + + /// See OutlinerViewShell::NotifyOtherViews(). + void NotifyOtherViews(int nType, const OString& rKey, const OString& rPayload) override; + /// See OutlinerViewShell::NotifyOtherView(). + void NotifyOtherView(OutlinerViewShell* pOtherShell, int nType, const OString& rKey, const OString& rPayload) override; + /// Ask this view to send its cursor position to pViewShell. + virtual void NotifyCursor(SfxViewShell* /*pViewShell*/) const; + /// Where a new view can perform some update/initialization soon after the callback has been registered. + virtual void afterCallbackRegistered(); + /// See OutlinerViewShell::GetEditWindowForActiveOLEObj(). + virtual vcl::Window* GetEditWindowForActiveOLEObj() const override; + + /// Set the LibreOfficeKit language of this view. + void SetLOKLanguageTag(const OUString& rBcp47LanguageTag); + /// Get the LibreOfficeKit language of this view. + const LanguageTag& GetLOKLanguageTag() const { return maLOKLanguageTag; } + + /// Set the LibreOfficeKit locale of this view. + void SetLOKLocale(const OUString& rBcp47LanguageTag); + /// Get the LibreOfficeKit locale of this view. + const LanguageTag& GetLOKLocale() const { return maLOKLocale; } + /// Get the form factor of the device where the lok client is running. + LOKDeviceFormFactor GetLOKDeviceFormFactor() const { return maLOKDeviceFormFactor; } + /// Check if the lok client is running on a desktop machine. + bool isLOKDesktop() const { return maLOKDeviceFormFactor == LOKDeviceFormFactor::DESKTOP; } + /// Check if the lok client is running on a tablet. + bool isLOKTablet() const { return maLOKDeviceFormFactor == LOKDeviceFormFactor::TABLET; } + /// Check if the lok client is running on a mobile device. + bool isLOKMobilePhone() const { return maLOKDeviceFormFactor == LOKDeviceFormFactor::MOBILE; } + + virtual tools::Rectangle getLOKVisibleArea() const { return tools::Rectangle(); } + + // Blocked Command view settings + void setBlockedCommandList(const char* blockedCommandList); + bool isBlockedCommand(OUString command); +}; + + +inline SfxViewFrame* SfxViewShell::GetViewFrame() const + +/* [Description] + + This method returns a pointer to the Instance in which + this SfxViewShell is displayed. This is the instance that was passed + on in the constructor. It is guaranteed that the returned pointer + points on the valid SfxViewFrame instance. + + [Cross-reference] + + +*/ + +{ + return pFrame; +} + +#endif // INCLUDED_SFX2_VIEWSH_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/watermarkitem.hxx b/include/sfx2/watermarkitem.hxx new file mode 100644 index 000000000..c298894bb --- /dev/null +++ b/include/sfx2/watermarkitem.hxx @@ -0,0 +1,47 @@ +/* -*- 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/. + */ +#ifndef INCLUDED_SFX2_WATERMARKITEM_HXX +#define INCLUDED_SFX2_WATERMARKITEM_HXX + +#include +#include +#include + +class SFX2_DLLPUBLIC SfxWatermarkItem final : public SfxPoolItem +{ +public: + static SfxPoolItem* CreateDefault(); + SfxWatermarkItem(); + virtual SfxWatermarkItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool operator==( const SfxPoolItem& ) const override; + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; + + OUString const & GetText() const { return m_aText; } + void SetText(const OUString& aText) { m_aText = aText; } + OUString const & GetFont() const { return m_aFont; } + void SetFont(const OUString& aFont) { m_aFont = aFont; } + sal_Int16 GetAngle() const { return m_nAngle; } + void SetAngle(const sal_Int16 nAngle) { m_nAngle = nAngle; } + sal_Int16 GetTransparency() const { return m_nTransparency; } + void SetTransparency(const sal_Int16 nTransparency) { m_nTransparency = nTransparency; } + Color GetColor() const { return m_nColor; } + void SetColor(Color nColor) { m_nColor = nColor; } + +private: + OUString m_aText; + OUString m_aFont; + sal_Int16 m_nAngle; + sal_Int16 m_nTransparency; + Color m_nColor; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/sfx2/weldutils.hxx b/include/sfx2/weldutils.hxx new file mode 100644 index 000000000..8f230cee5 --- /dev/null +++ b/include/sfx2/weldutils.hxx @@ -0,0 +1,67 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_WELDUTILS_HXX +#define INCLUDED_SFX2_WELDUTILS_HXX + +#include +#include + +#include +#include +#include +#include +#include + +#include + +namespace weld +{ +class Builder; +class Toolbar; +} + +class SFX2_DLLPUBLIC ToolbarUnoDispatcher +{ +private: + css::uno::Reference m_xFrame; + SvtMiscOptions m_aToolbarOptions; + weld::Toolbar* m_pToolbar; + weld::Builder* m_pBuilder; + bool m_bSideBar; + + DECL_DLLPRIVATE_LINK(SelectHdl, const OString&, void); + DECL_DLLPRIVATE_LINK(ToggleMenuHdl, const OString&, void); + DECL_DLLPRIVATE_LINK(ChangedIconSizeHandler, LinkParamNone*, void); + + void CreateController(const OUString& rCommand); + static vcl::ImageType GetIconSize(); + + typedef std::map> + ControllerContainer; + ControllerContainer maControllers; + +public: + // fill in the label and icons for actions and dispatch the action on item click + ToolbarUnoDispatcher(weld::Toolbar& rToolbar, weld::Builder& rBuilder, + const css::uno::Reference& rFrame, + bool bSideBar = true); + + css::uno::Reference + GetControllerForCommand(const OUString& rCommand) const; + + const css::uno::Reference& GetFrame() const { return m_xFrame; } + + void dispose(); + ~ToolbarUnoDispatcher(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/xmldump.hxx b/include/sfx2/xmldump.hxx new file mode 100644 index 000000000..245a07b22 --- /dev/null +++ b/include/sfx2/xmldump.hxx @@ -0,0 +1,29 @@ +/* -*- 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/. + */ + +#pragma once + +#include + +typedef struct _xmlTextWriter* xmlTextWriterPtr; + +namespace sfx2 +{ +/// Implemented by objects that can be dumped to xml for debugging purposes. +class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI XmlDump +{ +public: + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const = 0; + +protected: + ~XmlDump() noexcept = default; +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/zoomitem.hxx b/include/sfx2/zoomitem.hxx new file mode 100644 index 000000000..4e7703dfd --- /dev/null +++ b/include/sfx2/zoomitem.hxx @@ -0,0 +1,81 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_SFX2_ZOOMITEM_HXX +#define INCLUDED_SFX2_ZOOMITEM_HXX + +#include +#include +#include +#include + + +enum class SvxZoomType +{ + PERCENT, // GetValue() is no special percentage value + OPTIMAL, // GetValue() corresponds to the optimal size + WHOLEPAGE, // GetValue() corresponds to the whole page + PAGEWIDTH, // GetValue() corresponds to the page width + PAGEWIDTH_NOBORDER // GetValue() pagewidth without border +}; + +enum class SvxZoomEnableFlags +{ + NONE = 0x0000, + N50 = 0x0001, + N75 = 0x0002, + N100 = 0x0004, + N150 = 0x0008, + N200 = 0x0010, + OPTIMAL = 0x1000, + WHOLEPAGE = 0x2000, + PAGEWIDTH = 0x4000, + ALL = 0x701F +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +class SFX2_DLLPUBLIC SvxZoomItem final : public SfxUInt16Item +{ + SvxZoomEnableFlags nValueSet; // allowed values (see #defines below) + SvxZoomType eType; + +public: + static SfxPoolItem* CreateDefault(); + + SvxZoomItem( SvxZoomType eZoomType = SvxZoomType::PERCENT, + sal_uInt16 nVal = 0, sal_uInt16 nWhich = SID_ATTR_ZOOM ); + + void SetValueSet( SvxZoomEnableFlags nValues ) { nValueSet = nValues; } + SvxZoomEnableFlags GetValueSet() const { return nValueSet; } + + SvxZoomType GetType() const { return eType; } + void SetType( SvxZoomType eNewType ) { eType = eNewType; } + + virtual SvxZoomItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool operator==( const SfxPoolItem& ) const override; + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3