diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /include/sfx2 | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
125 files changed, 17206 insertions, 0 deletions
diff --git a/include/sfx2/AccessibilityCheck.hxx b/include/sfx2/AccessibilityCheck.hxx new file mode 100644 index 000000000..6de1069e5 --- /dev/null +++ b/include/sfx2/AccessibilityCheck.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/. + * + */ + +#ifndef INCLUDED_SFX2_ACCESSIBILITYCHECKDIALOG_HXX +#define INCLUDED_SFX2_ACCESSIBILITYCHECKDIALOG_HXX + +#include <sfx2/dllapi.h> +#include <vector> +#include <memory> +#include <rtl/ustring.hxx> +#include <sfx2/AccessibilityIssue.hxx> + +namespace sfx +{ +class SFX2_DLLPUBLIC AccessibilityCheck +{ +protected: + AccessibilityIssueCollection m_aIssueCollection; + +public: + AccessibilityCheck() = default; + virtual ~AccessibilityCheck(); + + virtual void check() = 0; + + AccessibilityIssueCollection& getIssueCollecton(); +}; + +} // end sfx namespace + +#endif // INCLUDED_SFX2_ACCESSIBILITYCHECKDIALOG_HXX + +/* 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..32522ff63 --- /dev/null +++ b/include/sfx2/AccessibilityIssue.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/. + * + */ + +#ifndef INCLUDED_SFX2_ACCESSIBILITYISSUE_HXX +#define INCLUDED_SFX2_ACCESSIBILITYISSUE_HXX + +#include <sfx2/dllapi.h> +#include <rtl/ustring.hxx> +#include <vector> +#include <memory> + +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<std::shared_ptr<AccessibilityIssue>> m_aIssues; + +public: + AccessibilityIssueCollection() = default; + + std::vector<std::shared_ptr<AccessibilityIssue>>& getIssues(); +}; + +} // end sfx namespace + +#endif // INCLUDED_SFX2_ACCESSIBILITYISSUE_HXX + +/* 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..196676671 --- /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 <sal/config.h> + +#include <sfx2/dllapi.h> + +#include <com/sun/star/rdf/XDocumentMetadataAccess.hpp> + +#include <cppuhelper/implbase.hxx> + +#include <memory> + + +/** 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<css::uno::XComponentContext> const & i_xContext, + css::uno::Reference<css::frame::XModel> const & i_xModel, + OUString const & i_rPkgURI, + OUString const & i_rSubDocument = OUString()); + + +struct DocumentMetadataAccess_Impl; + +class DocumentMetadataAccess final : + public cppu::WeakImplHelper<css::rdf::XDocumentMetadataAccess> +{ + 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<DocumentMetadataAccess_Impl> 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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <rtl/ustring.hxx> + +namespace com::sun::star::security +{ +class XCertificate; +} +namespace com::sun::star::uno +{ +template <typename> 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<css::security::XCertificate> const& rxCertificate); +}; + +} // namespace sfx2 + +#endif // INCLUDED_SFX2_DOCUMENTSIGNER_HXX + +/* 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 <sal/config.h> + +#include <sfx2/dllapi.h> + +#include <cppuhelper/implbase.hxx> +#include <com/sun/star/rdf/XMetadatable.hpp> + +#include <memory> + + +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. + + <p>The interface of this class consists of 3 parts: + <ul><li>implementations that are used by the MetadatableMixin + below</li> + <li>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.)</li> + <li>abstract methods that are called by the implementation of the + previous hooks</li></ul> + </p> + */ +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<MetadatableUndo> CreateUndo() const; + std::shared_ptr<MetadatableUndo> CreateUndoForDelete(); + + /** restore this from Undo Metadatable */ + void RestoreMetadata(std::shared_ptr<MetadatableUndo> 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 <em>must not</em> 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. + + <p>An instance of this base class is associated with an instance of + Metadatable.</p> + */ +class SFX2_DLLPUBLIC MetadatableMixin : + public cppu::WeakImplHelper<css::rdf::XMetadatable> +{ + +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..00aecfeae --- /dev/null +++ b/include/sfx2/QuerySaveDocument.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_QUERYSAVEDOCUMENT_HXX +#define INCLUDED_SFX2_QUERYSAVEDOCUMENT_HXX + +#include <rtl/ustring.hxx> +#include <sfx2/dllapi.h> + +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, const OUString& _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..625c9350b --- /dev/null +++ b/include/sfx2/StyleManager.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/. + */ + +#ifndef INCLUDED_SFX2_STYLEMANAGER_HXX +#define INCLUDED_SFX2_STYLEMANAGER_HXX + +#include <sfx2/dllapi.h> + +#include <svl/style.hxx> + +#include <memory> + +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(const OUString& rStyleName, SfxStyleFamily eFamily); + + virtual std::unique_ptr<StylePreviewRenderer> CreateStylePreviewRenderer( + OutputDevice& rOutputDev, SfxStyleSheetBase* pStyle, + 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..3065c8b31 --- /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 <sfx2/dllapi.h> +#include <sfx2/objsh.hxx> + +class OutputDevice; +class SfxStyleSheetBase; + +namespace sfx2 +{ + +class SFX2_DLLPUBLIC StylePreviewRenderer +{ +protected: + const SfxObjectShell& mrShell; + OutputDevice& mrOutputDev; + SfxStyleSheetBase* mpStyle; + long mnMaxHeight; + +public: + enum class RenderAlign + { + TOP, CENTER + }; + + StylePreviewRenderer(const SfxObjectShell& rShell, + OutputDevice& rOutputDev, + SfxStyleSheetBase* pStyle, + 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..7cae9df1e --- /dev/null +++ b/include/sfx2/XmlIdRegistry.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_XMLIDREGISTRY_HXX +#define INCLUDED_SFX2_XMLIDREGISTRY_HXX + +#include <sal/config.h> + +#include <sfx2/dllapi.h> +#include <rtl/ustring.hxx> + +namespace com::sun::star::beans { struct StringPair; } +namespace com::sun::star::uno { template <typename > class Reference; } + +namespace com::sun::star::rdf { + class XMetadatable; +} + +namespace sfx2 { + +// XML ID utilities -------------------------------------------------- + +/** is i_rIdref a valid NCName ? */ +bool SFX2_DLLPUBLIC isValidNCName(OUString const & i_rIdref); + +bool SFX2_DLLPUBLIC isValidXmlId(OUString const & i_rStreamName, + OUString const & 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..f08855ee8 --- /dev/null +++ b/include/sfx2/app.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_APP_HXX +#define INCLUDED_SFX2_APP_HXX + +#include <memory> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <vcl/errcode.hxx> +#include <svl/poolitem.hxx> +#include <vcl/bitmapex.hxx> +#include <tools/link.hxx> + +#include <sfx2/shell.hxx> + +namespace com::sun::star::script { class XLibraryContainer; } + +namespace weld { class Window; } + +class BasicManager; +class DdeService; +struct SfxChildWinContextFactory; +class SfxAppData_Impl; +class SfxChildWinFactArr_Impl; +class SfxDispatcher; +class SfxEventHint; +class SfxItemSet; +class SfxObjectShell; +class SfxObjectShellArr_Impl; +class SfxObjectShellLock; +class SfxProgress; +class SfxSlotPool; +class SfxStbCtrlFactArr_Impl; +class SfxTbxCtrlFactArr_Impl; +class SfxViewFrame; +class SfxViewFrameArr_Impl; +class SfxViewShellArr_Impl; +class StarBASIC; +class SfxWorkWindow; +class SfxFilterMatcher; +class SfxModule; +namespace vcl { class Window; } +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<SfxPoolItem const *, void> aLink; +public: + SfxLinkItem( sal_uInt16 nWhichId, const Link<SfxPoolItem const *, void>& 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<const SfxLinkItem&>(rL).aLink == aLink; } + const Link<SfxPoolItem const *, void>& + 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<SfxAppData_Impl> 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 long 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<SfxItemSet> pArgs ); + vcl::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. + 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*, std::unique_ptr<SfxChildWinFactory>); + SAL_DLLPRIVATE void RegisterChildWindowContext_Impl(SfxModule*, sal_uInt16, std::unique_ptr<SfxChildWinContextFactory>); + SAL_DLLPRIVATE void RegisterStatusBarControl_Impl(SfxModule*, const SfxStbCtrlFactory&); + SAL_DLLPRIVATE void RegisterToolBoxControl_Impl( SfxModule*, const SfxTbxCtrlFactory&); + SAL_DLLPRIVATE SfxTbxCtrlFactArr_Impl& GetTbxCtrlFactories_Impl() const; + SAL_DLLPRIVATE SfxStbCtrlFactArr_Impl& GetStbCtrlFactories_Impl() const; + SAL_DLLPRIVATE SfxChildWinFactArr_Impl& GetChildWinFactories_Impl() const; + SAL_DLLPRIVATE SfxViewFrameArr_Impl& GetViewFrames_Impl() const; + SAL_DLLPRIVATE SfxViewShellArr_Impl& GetViewShells_Impl() const; + SAL_DLLPRIVATE SfxObjectShellArr_Impl& GetObjectShells_Impl() const; + SAL_DLLPRIVATE void SetViewFrame_Impl(SfxViewFrame *pViewFrame); + + // Slot Methods + // TODO/CLEANUP: still needed? + SAL_DLLPRIVATE void NewDocDirectExec_Impl(SfxRequest &); + 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<SfxModule> 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(long nWidth); + + /** 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..92da31ed1 --- /dev/null +++ b/include/sfx2/basedlgs.hxx @@ -0,0 +1,137 @@ +/* -*- 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 <memory> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <vcl/weld.hxx> + +class SfxTabPage; +class SfxBindings; +class SfxChildWindow; +struct SfxChildWinInfo; +class SfxItemSet; +class Timer; + +class SFX2_DLLPUBLIC SfxDialogController : public weld::GenericDialogController +{ +private: + DECL_DLLPRIVATE_STATIC_LINK(SfxDialogController, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*); + + DECL_DLLPRIVATE_LINK(FocusChangeHdl, weld::Widget&, 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(); // called by the SfxChildWin to close the dialog +}; + +class SfxModelessDialog_Impl; + +class SFX2_DLLPUBLIC SfxModelessDialogController : public SfxDialogController +{ + SfxBindings* m_pBindings; + std::unique_ptr<SfxModelessDialog_Impl> 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() 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 const sal_uInt16* (*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<SfxItemSet> 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<SfxTabPage> 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<SfxTabPage> m_xSfxPage; + std::unique_ptr<weld::Container> m_xContainer; + std::unique_ptr<weld::Button> m_xOKBtn; + std::unique_ptr<weld::Button> 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..28b4d5248 --- /dev/null +++ b/include/sfx2/bindings.hxx @@ -0,0 +1,197 @@ +/* -*- 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 <sal/config.h> + +#include <cstddef> +#include <memory> + +#include <o3tl/typed_flags_set.hxx> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <tools/link.hxx> +#include <com/sun/star/uno/Reference.h> +#include <svl/poolitem.hxx> +#include <svl/SfxBroadcaster.hxx> +#include <sfx2/shell.hxx> + +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<SfxCallMode>: is_typed_flags<SfxCallMode, 0x0F> +{}; + +} + +class SFX2_DLLPUBLIC SfxBindings: public SfxBroadcaster + +/* [Description] + + In each SFx application one instance of the SfxBindings-Class will + exists from <SfxApplication::Init()> until <SfxApplication::Exit()>. + This instance is automatically created and destroyed by SfxApplication. + However these instances will be handled by the Macro <SFX_BINDINGS> + or the associated <SfxViewFrame>. + + The SfxBindings manages all of its Slot-Ids bound by the registered + controllers and keeps a cache of the <Slot-Server> 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 <Pseudo-Slots>. +*/ + +{ +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::unique_ptr<SfxItemSet> 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<SfxPoolItem> &rpState ); + + void QueryControlState ( sal_uInt16 nSID, boost::property_tree::ptree& rState ); + + 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( SfxWorkWindow* ); + 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<sal_Int64>(this)).append(')').getStr(), __LINE__ ) +#define DLEAVEREGISTRATIONS( ) \ + LeaveRegistrations( OStringBuffer(__FILE__).append('(').append(reinterpret_cast<sal_Int64>(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..8f6b4a580 --- /dev/null +++ b/include/sfx2/brokenpackageint.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 . + */ + +#ifndef INCLUDED_SFX2_BROKENPACKAGEINT_HXX +#define INCLUDED_SFX2_BROKENPACKAGEINT_HXX + +#include <sal/config.h> +#include <rtl/ref.hxx> +#include <sfx2/dllapi.h> + +#include <com/sun/star/uno/Reference.hxx> + +namespace com::sun::star::task { class XInteractionRequest; } + +class RequestPackageReparation_Impl; +class SFX2_DLLPUBLIC RequestPackageReparation +{ + rtl::Reference<RequestPackageReparation_Impl> mxImpl; +public: + RequestPackageReparation( const OUString& aName ); + ~RequestPackageReparation(); + RequestPackageReparation( const RequestPackageReparation&) = delete; + RequestPackageReparation& operator=( const RequestPackageReparation&) = delete; + bool isApproved() const; + css::uno::Reference < css::task::XInteractionRequest > GetRequest(); +}; + +class NotifyBrokenPackage_Impl; +class SFX2_DLLPUBLIC NotifyBrokenPackage +{ + rtl::Reference<NotifyBrokenPackage_Impl> mxImpl; +public: + NotifyBrokenPackage( const OUString& aName ); + ~NotifyBrokenPackage(); + NotifyBrokenPackage( const NotifyBrokenPackage&) = delete; + NotifyBrokenPackage& operator=( const NotifyBrokenPackage&) = delete; + css::uno::Reference < css::task::XInteractionRequest > GetRequest(); +}; + +#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/charmappopup.hxx b/include/sfx2/charmappopup.hxx new file mode 100644 index 000000000..e9bb6244b --- /dev/null +++ b/include/sfx2/charmappopup.hxx @@ -0,0 +1,45 @@ +/* -*- 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_CHARMAPPOPUP_HXX +#define INCLUDED_SFX2_INC_CHARMAPPOPUP_HXX + +#include <svtools/popupwindowcontroller.hxx> +#include <sfx2/dllapi.h> + +class CharmapPopup final : public svt::PopupWindowController +{ +public: + CharmapPopup(const css::uno::Reference<css::uno::XComponentContext>& rContext); + virtual ~CharmapPopup() override; + + virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override; + virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& rArguments ) override; +}; + +#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..26337be09 --- /dev/null +++ b/include/sfx2/charwin.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_INC_CHARWIN_HXX +#define INCLUDED_SFX2_INC_CHARWIN_HXX + +#include <sfx2/dllapi.h> +#include <vcl/customweld.hxx> +#include <vcl/virdev.hxx> +#include <vcl/weld.hxx> + +class SFX2_DLLPUBLIC SvxCharView final : public weld::CustomWidgetController +{ +private: + VclPtr<VirtualDevice> mxVirDev; + long mnY; + Point maPosition; + vcl::Font maFont; + bool maHasInsert; + OUString m_sText; + + Link<SvxCharView*, void> maMouseClickHdl; + Link<SvxCharView*, void> maClearClickHdl; + Link<SvxCharView*, void> 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<VirtualDevice>& 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 connect_focus_in(const Link<weld::Widget&, void>& rLink); + void connect_focus_out(const Link<weld::Widget&, void>& rLink); + + void setMouseClickHdl(const Link<SvxCharView*,void> &rLink); + void setClearClickHdl(const Link<SvxCharView*,void> &rLink); + void setClearAllClickHdl(const Link<SvxCharView*,void> &rLink); + + void ContextMenuSelect(const OString& 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..3a945b47b --- /dev/null +++ b/include/sfx2/childwin.hxx @@ -0,0 +1,312 @@ +/* -*- 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 <memory> +#include <sal/config.h> + +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <o3tl/typed_flags_set.hxx> +#include <vcl/window.hxx> + +#include <sfx2/chalign.hxx> +#include <sfx2/basedlgs.hxx> + +namespace com::sun::star::frame { class XFrame; } + +class SfxWorkWindow; +class SfxModule; +class SfxChildWindow; +class SfxChildWindowContext; +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<SfxChildWindowFlags> : is_typed_flags<SfxChildWindowFlags, 0x1f4> {}; +} + + +#define CHILDWIN_NOPOS USHRT_MAX + +// ChildWindow Configuration +struct SAL_DLLPUBLIC_RTTI SfxChildWinInfo +{ + bool bVisible; + Point aPos; + Size aSize; + SfxChildWindowFlags nFlags; + OUString aExtraString; + OUString aModule; + OString aWinState; + + SfxChildWinInfo() + { + bVisible = false; + nFlags = SfxChildWindowFlags::NONE; + } + bool GetExtraData_Impl( SfxChildAlignment *pAlign ) const; +}; + +// ChildWindow factory methods +typedef std::unique_ptr<SfxChildWindow> (*SfxChildWinCtor)( vcl::Window *pParentWindow, + sal_uInt16 nId, + SfxBindings *pBindings, + SfxChildWinInfo *pInfo); + +// ChildWindowsContexts factory methods +typedef std::unique_ptr<SfxChildWindowContext> (*SfxChildWinContextCtor)( vcl::Window *pParentWindow, + SfxBindings *pBindings, + SfxChildWinInfo *pInfo); +struct SfxChildWinContextFactory +{ + SfxChildWinContextCtor pCtor; // Factory method + sal_uInt16 nContextId; // Identifier for SfxInterface + + SfxChildWinContextFactory( SfxChildWinContextCtor pTheCtor, sal_uInt16 nID ) + : pCtor(pTheCtor) + , nContextId(nID) + {} +}; + +class SfxChildWinContextArr_Impl; + +struct SFX2_DLLPUBLIC SfxChildWinFactory +{ + SfxChildWinCtor pCtor; // Factory method + sal_uInt16 nId; // ChildWindow-Id ( SlotId ) + SfxChildWinInfo aInfo; // Configuration + sal_uInt16 nPos; // Position in UI + std::unique_ptr<SfxChildWinContextArr_Impl> pArr; // Array for Contexts + + SfxChildWinFactory( SfxChildWinCtor pTheCtor, sal_uInt16 nID, sal_uInt16 n ); + ~SfxChildWinFactory(); +}; + +class FloatingWindow; +struct SfxChildWindow_Impl; +class SFX2_DLLPUBLIC SfxChildWindowContext +{ +friend class SfxChildWindow; + VclPtr<vcl::Window> pWindow; + sal_uInt16 nContextId; + +protected: + SfxChildWindowContext( sal_uInt16 nId ); + +public: + virtual ~SfxChildWindowContext(); + + void SetWindow( vcl::Window* pWin ) + { pWindow=pWin; } + vcl::Window* GetWindow() const + { return pWindow; } + sal_uInt16 GetContextId() const + { return nContextId; } + + static FloatingWindow* GetFloatingWindow(vcl::Window *pParent); + + static void RegisterChildWindowContext(SfxModule*, sal_uInt16, std::unique_ptr<SfxChildWinContextFactory>); +}; + +class SFX2_DLLPUBLIC SfxChildWindow +{ + VclPtr<vcl::Window> pParent; // parent window ( Topwindow ) + sal_uInt16 nType; // ChildWindow-Id + VclPtr<vcl::Window> pWindow; // actual contents + std::shared_ptr<SfxDialogController> xController; // actual contents + SfxChildAlignment eChildAlignment; // Current css::drawing::Alignment + std::unique_ptr< SfxChildWindow_Impl> pImpl; // Implementation data + std::unique_ptr<SfxChildWindowContext> pContext; // With context-sensitive ChildWindows: + // Another window in pWindow + SAL_DLLPRIVATE void ClearWorkwin(); + +protected: + void SetWindow(const VclPtr<vcl::Window>& 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<SfxDialogController> controller) { xController = controller; } + void ClearController() { xController.reset(); } + std::shared_ptr<SfxDialogController>& GetController() { return xController; } + const std::shared_ptr<SfxDialogController>& 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; } + + void CreateContext( sal_uInt16 nContextId, SfxBindings& ); + sal_uInt16 GetContextId() const + { return pContext ? pContext->GetContextId(): 0; } + + vcl::Window* GetContextWindow() const + { return pContext ? pContext->GetWindow(): nullptr; } + + vcl::Window* GetContextWindow( SfxModule const *pModule ) const; + + virtual SfxChildWinInfo GetInfo() const; + void SaveStatus(const SfxChildWinInfo& rInfo); + + static void RegisterChildWindow(SfxModule*, std::unique_ptr<SfxChildWinFactory>); + + static std::unique_ptr<SfxChildWindow> 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 SfxChildWindowContext* + GetContext_Impl() const + { return pContext.get(); } + SAL_DLLPRIVATE void SetFactory_Impl( SfxChildWinFactory* ); +}; + + +//! The Macro of the future ... +#define SFX_DECL_CHILDWINDOWCONTEXT(Class) \ + static std::unique_ptr<SfxChildWindowContext> CreateImpl(vcl::Window *pParent, \ + SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \ + static void RegisterChildWindowContext(sal_uInt16, SfxModule *pMod=nullptr); \ + +//! The Macro of the future ... +// As a parameter and because of ContextId, CreateImpl must be handed the +// factory. As long as Id is set to 0 and patched in +// SfxChildWindow::CreateContext +#define SFX_IMPL_CHILDWINDOWCONTEXT(Class, MyID) \ + std::unique_ptr<SfxChildWindowContext> Class::CreateImpl( vcl::Window *pParent, \ + SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \ + { \ + return std::make_unique<Class>(pParent,0,pBindings,pInfo);\ + } \ + void Class::RegisterChildWindowContext(sal_uInt16 nId, SfxModule* pMod) \ + { \ + auto pFact = std::make_unique<SfxChildWinContextFactory>( \ + Class::CreateImpl, nId ); \ + SfxChildWindowContext::RegisterChildWindowContext(pMod, MyID, std::move(pFact)); \ + } + +#define SFX_DECL_CHILDWINDOW(Class) \ + public : \ + static std::unique_ptr<SfxChildWindow> 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<SfxChildWindow> Class::CreateImpl( vcl::Window *pParent, \ + sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \ + { \ + return std::make_unique<Class>(pParent, nId, pBindings, pInfo);\ + } \ + void Class::RegisterChildWindow (bool bVis, SfxModule *pMod, SfxChildWindowFlags nFlags) \ + { \ + auto pFact = std::make_unique<SfxChildWinFactory>( \ + Class::CreateImpl, MyID, Pos ); \ + pFact->aInfo.nFlags |= nFlags; \ + pFact->aInfo.bVisible = bVis; \ + SfxChildWindow::RegisterChildWindow(pMod, std::move(pFact)); \ + } + +#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<const SfxModelessDialogController*>(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<const SfxModelessDialogController*>(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<SfxDockingWindow*>(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<SfxDockingWindow*>(GetWindow())->FillInfo( aInfo ); \ + return aInfo; } + +bool GetPosSizeFromString( const OUString& rStr, Point& rPos, Size& rSize ); + +bool GetSplitSizeFromString( const OUString& 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..777001fd9 --- /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 <memory> +#include <vector> + +#include <rtl/ustring.hxx> +#include <sfx2/dllapi.h> +#include <sfx2/infobar.hxx> + +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<Impl> m_pImpl; + +public: + /// Does the document have any BAILS properties? + static bool IsClassified(const css::uno::Reference<css::document::XDocumentProperties>& xDocumentProperties); + /// Checks if pasting from xSource to xDestination would leak information. + static SfxClassificationCheckPasteResult CheckPaste(const css::uno::Reference<css::document::XDocumentProperties>& xSource, + const css::uno::Reference<css::document::XDocumentProperties>& 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<css::document::XDocumentProperties>& 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<OUString> GetBACNames(); + /// Return all possible valid category identifiers, based on the policy. + std::vector<OUString> 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(const OUString& sIdentifier); + /// Return all possible valid abbreviated category names, based on the policy. + std::vector<OUString> 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<OUString> const & GetMarkings() const; + std::vector<OUString> const & GetIntellectualPropertyParts() const; + std::vector<OUString> const & GetIntellectualPropertyPartNumbers() const; + + /// Does a best-effort conversion of rType to SfxClassificationPolicyType. + static SfxClassificationPolicyType stringToPolicyType(const OUString& 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(OUString const & aKey) const + { + return aKey.startsWith(makeTextKey()); + } + + OUString makeCategoryNameKey() const + { + return getPolicyKey() + "BusinessAuthorizationCategory:Name"; + } + + bool isCategoryNameKey(OUString const & aKey) const + { + return aKey.startsWith(makeCategoryNameKey()); + } + + OUString makeCategoryIdentifierKey() const + { + return getPolicyKey() + "BusinessAuthorizationCategory:Identifier"; + } + + bool isCategoryIdentifierKey(OUString const & aKey) const + { + return aKey.startsWith(makeCategoryIdentifierKey()); + } + + OUString makeMarkingKey() const + { + return getPolicyKey() + "Custom:Marking"; + } + + OUString makeNumberedMarkingKey() + { + return makeMarkingKey() + ":n" + OUString::number(m_nMarkingNumber++); + } + + bool isMarkingKey(OUString const & aKey) const + { + return aKey.startsWith(makeMarkingKey()); + } + + OUString makeIntellectualPropertyPartKey() const + { + return getPolicyKey() + "Custom:IntellectualPropertyPart"; + } + + OUString makeNumberedIntellectualPropertyPartKey() + { + return makeIntellectualPropertyPartKey() + ":n" + OUString::number(m_nIPPartNumber++); + } + + bool isIntellectualPropertyPartKey(OUString const & aKey) const + { + return aKey.startsWith(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<css::beans::XPropertyContainer> 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..489fdb946 --- /dev/null +++ b/include/sfx2/ctrlitem.hxx @@ -0,0 +1,91 @@ +/* -*- 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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <svl/poolitem.hxx> +#include <tools/debug.hxx> + +class SfxBindings; + +class SFX2_DLLPUBLIC SfxControllerItem +{ +private: + sal_uInt16 nId; + SfxControllerItem* pNext; // to notify next ControllerItem + SfxBindings* pBindings; + +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 StateChanged( sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState ); + + virtual void GetControlState( sal_uInt16 nSID, boost::property_tree::ptree& ); + + MapUnit GetCoreMetric() const; + + 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 StateChanged( 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/dialoghelper.hxx b/include/sfx2/dialoghelper.hxx new file mode 100644 index 000000000..c18545a75 --- /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 <sfx2/dllapi.h> +#include <rtl/ustring.hxx> +#include <tools/gen.hxx> + +class DateTime; +class LocaleDataWrapper; +namespace vcl { class Window; } +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 getWidestTime(const LocaleDataWrapper& rWrapper); + +OUString SFX2_DLLPUBLIC formatTime(const DateTime& rDateTime, const LocaleDataWrapper& rWrapper); + +#endif + +/* 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..09e2473b9 --- /dev/null +++ b/include/sfx2/dinfdlg.hxx @@ -0,0 +1,565 @@ +/* -*- 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 <config_options.h> +#include <sal/config.h> +#include <sfx2/dllapi.h> + +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/util/DateTime.hpp> +#include <com/sun/star/util/Duration.hpp> +#include <com/sun/star/document/CmisProperty.hpp> + +#include <svl/stritem.hxx> +#include <svl/zforlist.hxx> + +#include <vcl/idle.hxx> + +#include <sfx2/tabdlg.hxx> + +#include <optional> +#include <memory> + +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<CustomProperty> > 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<CustomProperty> > 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<weld::Image> m_xBmp; + std::unique_ptr<weld::Label> m_xNameED; + std::unique_ptr<weld::Button> m_xChangePassBtn; + + std::unique_ptr<weld::Label> m_xShowTypeFT; + std::unique_ptr<weld::Label> m_xFileValEd; + std::unique_ptr<weld::Label> m_xShowSizeFT; + + std::unique_ptr<weld::Label> m_xCreateValFt; + std::unique_ptr<weld::Label> m_xChangeValFt; + std::unique_ptr<weld::Label> m_xSignedValFt; + std::unique_ptr<weld::Button> m_xSignatureBtn; + std::unique_ptr<weld::Label> m_xPrintValFt; + std::unique_ptr<weld::Label> m_xTimeLogValFt; + std::unique_ptr<weld::Label> m_xDocNoValFt; + + std::unique_ptr<weld::CheckButton> m_xUseUserDataCB; + std::unique_ptr<weld::Button> m_xDeleteBtn; + std::unique_ptr<weld::CheckButton> m_xUseThumbnailSaveCB; + + std::unique_ptr<weld::Label> m_xTemplFt; + std::unique_ptr<weld::Label> m_xTemplValFt; + + DECL_LINK(DeleteHdl, weld::Button&, void); + DECL_LINK(SignatureHdl, weld::Button&, void); + DECL_LINK(ChangePassHdl, weld::Button&, 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<SfxTabPage> 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<weld::Entry> m_xTitleEd; + std::unique_ptr<weld::Entry> m_xThemaEd; + std::unique_ptr<weld::Entry> m_xKeywordsEd; + std::unique_ptr<weld::TextView> 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<SfxTabPage> 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<SvtCalendarBox> m_xDateField; +public: + ::std::optional<sal_Int16> m_TZ; + + CustomPropertiesDateField(SvtCalendarBox* pDateField); + void set_visible(bool bVisible); + Date get_date() const; + void set_date(const Date& rDate); + ~CustomPropertiesDateField(); +}; + +class CustomPropertiesTimeField +{ +public: + std::unique_ptr<weld::TimeSpinButton> m_xTimeField; + bool m_isUTC; + + CustomPropertiesTimeField(std::unique_ptr<weld::TimeSpinButton> xTimeField); + void set_visible(bool bVisible) { m_xTimeField->set_visible(bVisible); } + tools::Time get_value() const { return m_xTimeField->get_value(); } + void set_value(const tools::Time& rTime) { m_xTimeField->set_value(rTime); } + ~CustomPropertiesTimeField(); +}; + +class CustomPropertiesDurationField +{ + css::util::Duration m_aDuration; + std::unique_ptr<weld::Entry> m_xEntry; + std::unique_ptr<weld::Button> m_xEditButton; + + DECL_LINK(ClickHdl, weld::Button&, void); +public: + CustomPropertiesDurationField(std::unique_ptr<weld::Entry> xEntry, + std::unique_ptr<weld::Button> 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<weld::Widget> m_xTopLevel; + std::unique_ptr<weld::RadioButton> m_xYesButton; + std::unique_ptr<weld::RadioButton> m_xNoButton; + +public: + CustomPropertiesYesNoButton(std::unique_ptr<weld::Widget>, + std::unique_ptr<weld::RadioButton> xYesButton, + std::unique_ptr<weld::RadioButton> 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<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xLine; + std::unique_ptr<weld::ComboBox> m_xNameBox; + std::unique_ptr<weld::ComboBox> m_xTypeBox; + std::unique_ptr<weld::Entry> m_xValueEdit; + std::unique_ptr<weld::Widget> m_xDateTimeBox; + std::unique_ptr<CustomPropertiesDateField> m_xDateField; + std::unique_ptr<CustomPropertiesTimeField> m_xTimeField; + std::unique_ptr<weld::Widget> m_xDurationBox; + std::unique_ptr<CustomPropertiesDurationField> m_xDurationField; + std::unique_ptr<CustomPropertiesYesNoButton> m_xYesNoButton; + std::unique_ptr<weld::Button> 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<std::unique_ptr<CustomProperty>> m_aCustomProperties; + std::vector<std::unique_ptr<CustomPropertyLine>> m_aCustomPropertiesLines; + CustomPropertyLine* m_pCurrentLine; + SvNumberFormatter m_aNumberFormatter; + Idle m_aEditLoseFocusIdle; + Idle m_aBoxLoseFocusIdle; + Link<void*,void> 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<CustomProperty> >&& rProperties); + void SetRemovedHdl( const Link<void*,void>& 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<weld::Widget> m_xBox; + std::unique_ptr<weld::Container> m_xBody; + std::unique_ptr<weld::ScrolledWindow> m_xVertScroll; + std::unique_ptr<CustomPropertiesWindow> m_xPropertiesWin; + std::unique_ptr<weld::Label> m_xName; + std::unique_ptr<weld::Label> m_xType; + std::unique_ptr<weld::Label> 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<css::beans::PropertyValue> + GetCustomProperties() const + { return m_xPropertiesWin->GetCustomProperties(); } + void SetCustomProperties(std::vector< std::unique_ptr<CustomProperty> >&& rProperties); + + void Init(weld::Builder& rParent); +}; + +// class SfxCustomPropertiesPage ----------------------------------------- + +class SfxCustomPropertiesPage final : public SfxTabPage +{ +private: + DECL_LINK(AddHdl, weld::Button&, void); + + std::unique_ptr<CustomPropertiesControl> m_xPropertiesCtrl; + std::unique_ptr<weld::Button> 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<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* ); + virtual ~SfxCustomPropertiesPage() override; +}; + +struct CmisValue +{ + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Frame> m_xFrame; + std::unique_ptr<weld::Entry> m_xValueEdit; + + CmisValue(weld::Widget* pParent, const OUString& rStr); +}; + +struct CmisDateTime +{ + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Frame> m_xFrame; + std::unique_ptr<SvtCalendarBox> m_xDateField; + std::unique_ptr<weld::TimeSpinButton> m_xTimeField; + + CmisDateTime(weld::Widget* pParent, const css::util::DateTime& rDateTime); +}; + +struct CmisYesNo +{ + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Frame> m_xFrame; + std::unique_ptr<weld::RadioButton> m_xYesButton; + std::unique_ptr<weld::RadioButton> m_xNoButton; + + CmisYesNo(weld::Widget* pParent, bool bValue); +}; + +// struct CmisPropertyLine --------------------------------------------- + +struct CmisPropertyLine +{ + std::unique_ptr<weld::Builder> m_xBuilder; + OUString m_sId; + OUString m_sType; + bool m_bUpdatable; + bool m_bRequired; + bool m_bMultiValued; + bool m_bOpenChoice; + std::unique_ptr<weld::Frame> m_xFrame; + std::unique_ptr<weld::Label> m_xName; + std::unique_ptr<weld::Label> m_xType; + std::vector< std::unique_ptr<CmisValue> > m_aValues; + std::vector< std::unique_ptr<CmisDateTime> > m_aDateTimes; + std::vector< std::unique_ptr<CmisYesNo> > m_aYesNos; + CmisPropertyLine(weld::Widget* pParent); + ~CmisPropertyLine(); +}; + +// class CmisPropertiesWindow ------------------------------------------ + +class CmisPropertiesWindow +{ +private: + std::unique_ptr<weld::Container> m_xBox; + SvNumberFormatter m_aNumberFormatter; + std::vector< std::unique_ptr<CmisPropertyLine> > m_aCmisPropertiesLines; +public: + CmisPropertiesWindow(std::unique_ptr<weld::Container> 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<weld::ScrolledWindow> 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<CmisPropertiesControl> 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<SfxTabPage> 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..ee46d5c89 --- /dev/null +++ b/include/sfx2/dispatch.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 . + */ +#ifndef INCLUDED_SFX2_DISPATCH_HXX +#define INCLUDED_SFX2_DISPATCH_HXX + +#include <memory> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sfx2/toolbarids.hxx> +#include <sal/types.h> + +#include <sfx2/bindings.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <o3tl/span.hxx> + +#include <boost/property_tree/ptree_fwd.hpp> +#include <vcl/menu.hxx> +#include <initializer_list> + +class SfxSlotServer; +class SfxRequest; +class SfxViewFrame; +class SfxItemSet; +class SfxModule; +class Point; +struct SfxDispatcher_Impl; + +namespace vcl { class Window; } + +enum class SfxDispatcherPopFlags +{ + NONE = 0, + POP_UNTIL = 4, + POP_DELETE = 2, + PUSH = 1, +}; +namespace o3tl +{ + template<> struct typed_flags<SfxDispatcherPopFlags> : is_typed_flags<SfxDispatcherPopFlags, 0x07> {}; +} + +enum class SfxSlotFilterState +{ + DISABLED, + ENABLED, + // enabled even if ReadOnlyDoc + ENABLED_READONLY, +}; + + +class SFX2_DLLPUBLIC SfxDispatcher final +{ + std::unique_ptr<SfxDispatcher_Impl> 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<SfxRequest>); + + 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<SfxPoolItem const*> args, + std::initializer_list<SfxPoolItem const*> internalargs = std::initializer_list<SfxPoolItem const*>()); + + 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<sal_uInt16 const> pSIDs = o3tl::span<sal_uInt16 const>()); + + void HideUI( bool bHide = true ); + ToolbarId GetObjectBarId( sal_uInt16 nPos ) const; + + SfxItemState QueryState( sal_uInt16 nSID, const SfxPoolItem* &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(Menu* pMenu); +}; + +#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 <sal/config.h> +#include <sal/types.h> + +#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..38716ea34 --- /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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> + +#include <rtl/ustring.hxx> +#include <sfx2/shell.hxx> +#include <memory> + +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<SfxObjectFactory_Impl> 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( const OUString& i_rViewName ) const; + + // Filter + std::shared_ptr<const SfxFilter> GetTemplateFilter() const; + static OUString GetStandardTemplate( const OUString& 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..288634808 --- /dev/null +++ b/include/sfx2/docfile.hxx @@ -0,0 +1,295 @@ +/* -*- 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 <memory> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sfx2/signaturestate.hxx> +#include <svl/lockfilecommon.hxx> +#include <sal/types.h> +#include <rtl/ustring.hxx> +#include <svl/itemset.hxx> +#include <tools/link.hxx> +#include <tools/stream.hxx> + +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 ucbhelper { class Content; } + +class SvKeyValueIterator; +class SfxFilter; +class SfxMedium_Impl; +class INetURLObject; +class SfxFrame; +class DateTime; + +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<const SfxFilter> pFilter = nullptr, + const std::shared_ptr<SfxItemSet>& pSet = nullptr ); + SfxMedium( const OUString &rName, + const OUString &rReferer, + StreamMode nOpenMode, + std::shared_ptr<const SfxFilter> pFilter = nullptr, + const std::shared_ptr<SfxItemSet>& pSet = nullptr ); + SfxMedium( const css::uno::Reference< css::embed::XStorage >& xStorage, + const OUString& rBaseURL, + const std::shared_ptr<SfxItemSet>& pSet = nullptr ); + SfxMedium( const css::uno::Reference< css::embed::XStorage >& xStorage, + const OUString& rBaseURL, + const OUString& rTypeName, + const std::shared_ptr<SfxItemSet>& pSet = nullptr ); + SfxMedium( const css::uno::Sequence< css::beans::PropertyValue >& aArgs ); + + virtual ~SfxMedium() override; + + void UseInteractionHandler( bool ); + css::uno::Reference< css::task::XInteractionHandler > + GetInteractionHandler( bool bGetAlways = false ); + + void setStreamToLoadFrom( + const css::uno::Reference<css::io::XInputStream>& 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<const SfxFilter>& pFilter); + const std::shared_ptr<const SfxFilter>& GetFilter() const; + const OUString& GetOrigURL() const; + + SfxItemSet * GetItemSet() const; + void SetArgs(const css::uno::Sequence<css::beans::PropertyValue>& rArgs); + css::uno::Sequence<css::beans::PropertyValue> 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<void*,void>& aLink = Link<void*,void>()); + void SetDoneLink( const Link<void*,void>& 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, + const OUString& 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<css::security::XCertificate>& xCert + = css::uno::Reference<css::security::XCertificate>(), + const css::uno::Reference<css::graphic::XGraphic>& xValidGraphic + = css::uno::Reference<css::graphic::XGraphic>(), + const css::uno::Reference<css::graphic::XGraphic>& xInvalidGraphic + = css::uno::Reference<css::graphic::XGraphic>(), + const OUString& aComment = OUString()); + + SAL_DLLPRIVATE bool + SignDocumentContentUsingCertificate(bool bHasValidDocumentSignature, + const css::uno::Reference<css::security::XCertificate>& 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( const OUString& 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( const OUString& 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..80bb7734d --- /dev/null +++ b/include/sfx2/docfilt.hxx @@ -0,0 +1,124 @@ +/* -*- 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 <comphelper/documentconstants.hxx> +#include <rtl/ustring.hxx> +#include <sal/config.h> +#include <sal/types.h> +#include <sot/formats.hxx> +#include <sfx2/dllapi.h> +#include <tools/wldcrd.hxx> + +#include <memory> + +namespace com::sun::star::embed { class XStorage; } +namespace com::sun::star::uno { template <typename > 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, + const OUString &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<const SfxFilter> GetDefaultFilter( const OUString& rName ); + static std::shared_ptr<const SfxFilter> GetFilterByName( const OUString& rName ); + static std::shared_ptr<const SfxFilter> 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<css::embed::XStorage>& 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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <vcl/errcode.hxx> + + +class GDIMetaFile; +class SotStorage; + +namespace com::sun::star { + namespace document { + class XDocumentProperties; + } +} + +namespace com::sun::star::uno { template <typename > class Reference; } +namespace com::sun::star::uno { template <typename > 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<sal_Int8> * i_pThumb = nullptr, + const css::uno::Sequence<sal_Int8> * i_pGuid = nullptr, + const css::uno::Sequence<sal_Int8> * i_pHyperlinks = nullptr); + + +css::uno::Sequence<sal_Int8> 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..ab75ddd18 --- /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 <rtl/ustring.hxx> +#include <sfx2/dllapi.h> +#include <vcl/errcode.hxx> +#include <tools/link.hxx> +#include <memory> +#include <vector> + +namespace sfx2 { class FileDialogHelper; } +namespace weld { class Window; } +class SfxItemSet; +class SfxMedium; +enum class FileDialogFlags; + +typedef ::std::vector< std::unique_ptr<SfxMedium> > SfxMediumList; + +namespace sfx2 { + +class SFX2_DLLPUBLIC DocumentInserter +{ +private: + weld::Window* m_pParent; + OUString m_sDocFactory; + OUString m_sFilter; + Link<sfx2::FileDialogHelper*,void> m_aDialogClosedLink; + + FileDialogFlags const m_nDlgFlags; + ErrCode m_nError; + + std::unique_ptr<sfx2::FileDialogHelper> + m_pFileDlg; + std::shared_ptr<SfxItemSet> m_xItemSet; + std::vector<OUString> m_pURLList; + + DECL_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<sfx2::FileDialogHelper*,void>& _rDialogClosedLink ); + std::unique_ptr<SfxMedium> 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..217c9f962 --- /dev/null +++ b/include/sfx2/dockwin.hxx @@ -0,0 +1,131 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_DOCKWIN_HXX +#define INCLUDED_SFX2_DOCKWIN_HXX + +#include <memory> +#include <sal/config.h> +#include <sal/types.h> +#include <vcl/dockwin.hxx> + +#include <com/sun/star/uno/Reference.hxx> + +#include <sfx2/dllapi.h> +#include <sfx2/childwin.hxx> + +namespace com::sun::star::frame { class XFrame; } + +class SfxDockingWindow_Impl; +enum class SplitWindowItemFlags; + +void SfxDockingWindowFactory( const css::uno::Reference< css::frame::XFrame >& rFrame, const OUString& rDockingWindowName ); +bool IsDockingWindowVisible( const css::uno::Reference< css::frame::XFrame >& rFrame, const OUString& rDockingWindowName ); + +class SFX2_DLLPUBLIC SfxDockingWindow : public DockingWindow +{ +protected: + std::unique_ptr<weld::Builder> m_xBuilder; + VclPtr<vcl::Window> m_xVclContentArea; + std::unique_ptr<weld::Container> 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_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..a15bbbe9b --- /dev/null +++ b/include/sfx2/docmacromode.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 . + */ + +#ifndef INCLUDED_SFX2_DOCMACROMODE_HXX +#define INCLUDED_SFX2_DOCMACROMODE_HXX + +#include <sfx2/dllapi.h> +#include <sfx2/signaturestate.hxx> + +#include <com/sun/star/uno/Reference.hxx> + +#include <memory> + +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 <NULL/> 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 <sfx2/signaturestate.hxx> + */ + 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 <sfx2/signaturestate.hxx> + */ + 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 + <TRUE/>, always + */ + bool allowMacroExecution(); + + /** disallows macro execution in the document + + Effectively, the macro mode is set to MacroExecMode::NEVER_EXECUTE. + + @return + <TRUE/>, 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 + <ul><li>Asking the user for confirmation for macro execution.</li> + <li>Telling the user that macro execution is disabled.</li> + </ul> + + If the user needs to be asked for macro execution confirmation, and if + this parameter is <NULL/>, the most defensive assumptions will be made, + effectively disabling macro execution. + + @return + <TRUE/> if and only if macro execution in this document is allowed. + */ + bool adjustMacroMode( + const css::uno::Reference< css::task::XInteractionHandler >& _rxInteraction + ); + + /** determines whether macro execution is disallowed + + There's a number of reasons why macro execution could be disallowed: + <ul><li>Somebody called ->disallowMacroExecution</li> + <li>Macro execution is disabled globally, via the security options</li> + <li>Macro execution mode was not defined initially, and the user denied + executing macros for this particular document.</li> + </ul> + + Note that if this method returns <FALSE/>, then subsequent calls of + ->adjustMacroMode can still return <FALSE/>. + That is, if the current macro execution mode for the document is not yet known + (and in particular <em>not</em> MacroExecMode::NEVER_EXECUTE), then ->isMacroExecutionDisallowed + will return <FALSE/>. + However, a subsequent call to ->adjustMacroMode can result in the user + denying macro execution, in which ->adjustMacroMode will return <FALSE/>, + and the next call to isMacroExecutionDisallowed will return <TRUE/>. + */ + 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 >& xContainter ); + /** 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 + <TRUE/> 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 + ); + + 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 <sfx2/dllapi.h> + +#include <com/sun/star/util/XModifyListener.hpp> + +#include <cppuhelper/implbase.hxx> + +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<css::util::XModifyListener> + { + 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..6ad16ceb6 --- /dev/null +++ b/include/sfx2/doctempl.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_DOCTEMPL_HXX +#define INCLUDED_SFX2_DOCTEMPL_HXX + +#include <rtl/ustring.hxx> +#include <sal/config.h> +#include <sal/types.h> +#include <sfx2/dllapi.h> +#include <tools/ref.hxx> + +// CLASS ----------------------------------------------------------------- + +class SfxDocTemplate_Impl; + +// class SfxDocumentTemplates -------------------------------------------- + +class SFX2_DLLPUBLIC SfxDocumentTemplates +{ +private: + tools::SvRef<SfxDocTemplate_Impl> 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( const OUString& aGroupName, + const OUString& 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, const OUString &rName) const; + bool CopyFrom(sal_uInt16 nRegion, sal_uInt16 nIdx, OUString &rName); + + bool GetFull( const OUString& rRegion, const OUString& rName, OUString& rPath ); + bool GetLogicNames( const OUString& rPath, OUString& rRegion, OUString& rName ) const; + + /** updates the configuration where the document templates structure is stored. + + <p>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.</p> + */ + void Update(); +}; + +#endif // INCLUDED_SFX2_DOCTEMPL_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/emojipopup.hxx b/include/sfx2/emojipopup.hxx new file mode 100644 index 000000000..20d1e493c --- /dev/null +++ b/include/sfx2/emojipopup.hxx @@ -0,0 +1,44 @@ +/* -*- 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_EMOJIPOPUP_HXX +#define INCLUDED_SFX2_INC_EMOJIPOPUP_HXX + +#include <svtools/popupwindowcontroller.hxx> +#include <sfx2/dllapi.h> + +class EmojiPopup final : public svt::PopupWindowController +{ +public: + EmojiPopup(const css::uno::Reference<css::uno::XComponentContext>& rContext); + virtual ~EmojiPopup() override; + + virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& rArguments ) override; +}; + +#endif + +/* 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 <sal/config.h> + +#include <ostream> + +#include <sfx2/dllapi.h> +#include <svl/hint.hxx> +#include <unotools/eventcfg.hxx> +#include <rtl/ustring.hxx> + +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/frame/XController2.hpp> +#include <com/sun/star/view/PrintableState.hpp> + +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<charT, traits> & operator <<( + std::basic_ostream<charT, traits> & 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<charT, traits> & operator <<( + std::basic_ostream<charT, traits> & 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..0233f0810 --- /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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <sfx2/event.hxx> +#include <svl/poolitem.hxx> +#include <memory> +#include <vector> + +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 ); +}; + + +#define PROP_EVENT_TYPE "EventType" +#define PROP_LIBRARY "Library" +#define PROP_SCRIPT "Script" +#define PROP_MACRO_NAME "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<SvxMacro> 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..86f20bf11 --- /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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <rtl/ustring.hxx> +#include <tools/link.hxx> +#include <comphelper/documentconstants.hxx> +#include <sot/formats.hxx> + +#include <memory> + +namespace com::sun::star::beans { struct NamedValue; } +namespace com::sun::star::container { class XNameAccess; } +namespace com::sun::star::uno { template <typename > class Sequence; } +namespace com::sun::star::uno { template <typename > class Reference; } + +class ErrCode; +class SfxFilter; +class SfxMedium; +class SfxFilterContainer_Impl; + + +class SFX2_DLLPUBLIC SfxFilterContainer +{ + std::unique_ptr<SfxFilterContainer_Impl> pImpl; + +public: + SfxFilterContainer( const OUString& rName ); + ~SfxFilterContainer(); + + + OUString const & GetName() const; + + std::shared_ptr<const SfxFilter> GetAnyFilter( SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr<const SfxFilter> GetFilter4EA( const OUString& rEA, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr<const SfxFilter> GetFilter4Extension( const OUString& rExt, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr<const SfxFilter> 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<const SfxFilter> GetDefaultFilter_Impl( const OUString& ); +}; + +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<const SfxFilter>& pFilter ); + DECL_DLLPRIVATE_LINK( MaybeFileHdl_Impl, OUString*, bool ); + + ErrCode GuessFilterIgnoringContent( SfxMedium const & rMedium, std::shared_ptr<const SfxFilter>& ) const; + ErrCode GuessFilter( SfxMedium& rMedium, std::shared_ptr<const SfxFilter>& , SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + ErrCode GuessFilterControlDefaultUI( SfxMedium& rMedium, std::shared_ptr<const SfxFilter>&, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + ErrCode DetectFilter( SfxMedium& rMedium, std::shared_ptr<const SfxFilter>& ) const; + + std::shared_ptr<const SfxFilter> GetFilter4Mime( const OUString& rMime, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED) const; + std::shared_ptr<const SfxFilter> GetFilter4ClipBoardId( SotClipboardFormatId nId, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr<const SfxFilter> GetFilter4EA( const OUString& rEA, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr<const SfxFilter> GetFilter4Extension( const OUString& rExt, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr<const SfxFilter> GetFilter4FilterName( const OUString& rName, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr<const SfxFilter> GetFilter4UIName( const OUString& rName, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr<const SfxFilter> GetFilterForProps( const css::uno::Sequence < css::beans::NamedValue >& aSeq, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const; + std::shared_ptr<const SfxFilter> 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<const SfxFilter> 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<const SfxFilter> First(); + std::shared_ptr<const SfxFilter> 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..42d6b53c0 --- /dev/null +++ b/include/sfx2/filedlghelper.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_FILEDLGHELPER_HXX +#define INCLUDED_SFX2_FILEDLGHELPER_HXX + +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <com/sun/star/uno/Sequence.hxx> +#include <rtl/ref.hxx> +#include <rtl/ustring.hxx> +#include <comphelper/documentconstants.hxx> +#include <tools/link.hxx> +#include <vcl/errcode.hxx> +#include <o3tl/typed_flags_set.hxx> + +#include <memory> +#include <vector> + +namespace com +{ + namespace sun + { + namespace star + { + namespace ui + { + namespace dialogs + { + class XFilePicker3; + struct FilePickerEvent; + struct DialogClosedEvent; + } + } + } + } +} + +namespace com::sun::star::awt { class XWindow; } +namespace com::sun::star::uno { template <typename > class Reference; } +namespace weld { class Window; } + +class Graphic; +class SfxFilter; +class SfxItemSet; + +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<FileDialogFlags> : is_typed_flags<FileDialogFlags, 0xFF> {}; +} + +#define FILEDIALOG_FILTER_ALL "*.*" + +namespace sfx2 { + +class FileDialogHelper_Impl; + +class SFX2_DLLPUBLIC FileDialogHelper +{ +public: + enum Context // context where the FileDialogHelper is used + { + UNKNOWN_CONTEXT, // unknown context + SW_INSERT_GRAPHIC, // insert graphic in writer + SD_EXPORT, // export in draw + SI_EXPORT, // export in impress + SW_EXPORT // export in writer + }; + +private: + Link<FileDialogHelper*,void> 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 >& rBlackList, + weld::Window* pPreferredParent); + + FileDialogHelper(sal_Int16 nDialogType, + FileDialogFlags nFlags, + const OUString& aFilterUIName, + const OUString& aExtName, + const OUString& rStandardDir, + const css::uno::Sequence< OUString >& rBlackList, + weld::Window* pPreferredParent); + + virtual ~FileDialogHelper(); + + FileDialogHelper& operator=(const FileDialogHelper &) = delete; + FileDialogHelper(const FileDialogHelper &) = delete; + + ErrCode Execute(); + void StartExecuteModal( const Link<FileDialogHelper*,void>& 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.<br/> + 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 <code>GetFilePicker().setDefaultName( _rFileName )</code>, + with the following differences: + <ul><li>The FileDialogHelper remembers the given file name, and upon execution, + strips its extension if the dialog is set up for "automatic file name extension".</li> + <li>Exceptions thrown from the <code>XFilePicker3</code> are caught and silenced.</li> + </ul> + */ + 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 + @param _eNewContext + New context for the dialog. + */ + void SetContext( Context _eNewContext ); + + DECL_LINK( ExecuteSystemFilePicker, void*, void ); + + ErrCode Execute( std::vector<OUString>& rpURLList, + std::unique_ptr<SfxItemSet>& rpSet, + OUString& rFilter, + const OUString& rDirPath ); + ErrCode Execute( std::unique_ptr<SfxItemSet>& 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<OUString>& rpURLList, + OUString& rFilter, + std::unique_ptr<SfxItemSet>& rpSet, + const OUString* pPath, + sal_Int16 nDialog, + const OUString& rStandardDir, + const css::uno::Sequence< OUString >& rBlackList = css::uno::Sequence< OUString >()); + + +ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, OUString const & aURL, SfxItemSet* pSet, const css::uno::Reference<css::awt::XWindow>& 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..cb5d758b5 --- /dev/null +++ b/include/sfx2/flatpak.hxx @@ -0,0 +1,34 @@ +/* -*- 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 <sal/config.h> + +#include <rtl/ustring.hxx> +#include <sfx2/dllapi.h> + +// 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..4eb2c6115 --- /dev/null +++ b/include/sfx2/frame.hxx @@ -0,0 +1,213 @@ +/* -*- 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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <sfx2/shell.hxx> +#include <sal/types.h> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Any.hxx> +#include <vcl/vclptr.hxx> +#include <rtl/ustring.hxx> +#include <svl/poolitem.hxx> +#include <tools/ref.hxx> +#include <memory> +#include <vector> + + +namespace com +{ + namespace sun + { + namespace star + { + namespace 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<OUString> 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<SfxFrame> +{ + friend class SfxFrameIterator; + friend class SfxFrameWindow_Impl; + +private: + std::unique_ptr< SfxFrame_Impl > pImpl; + VclPtr<vcl::Window> 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* ); + SAL_DLLPRIVATE 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( 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<SfxFrame> 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(); + 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..196a2ccc9 --- /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 <memory> +#include <rtl/ustring.hxx> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <tools/gen.hxx> +#include <tools/urlobj.hxx> + +// 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<SfxItemSet> m_pArgs; + +public: + SfxFrameDescriptor(); + ~SfxFrameDescriptor(); + + // FileName/URL + SfxItemSet* GetArgs(); + const INetURLObject& GetURL() const + { return aURL; } + void SetURL( const OUString& rURL ); + void SetActualURL( const OUString& rURL ); + + // 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..c489390ec --- /dev/null +++ b/include/sfx2/frmhtml.hxx @@ -0,0 +1,39 @@ +/* -*- 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 <sal/config.h> +#include <sfx2/dllapi.h> + +#include <sfx2/sfxhtml.hxx> + +class SfxFrameDescriptor; + +namespace SfxFrameHTMLParser +{ + // These methods can also be used by other parsers. + SFX2_DLLPUBLIC void ParseFrameOptions(SfxFrameDescriptor*, const HTMLOptions&, const OUString& ); + +}; + +#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..dfc0d1645 --- /dev/null +++ b/include/sfx2/frmhtmlw.hxx @@ -0,0 +1,76 @@ +/* -*- 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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <rtl/ustring.hxx> + +class SvStream; + +namespace com::sun::star { + namespace document { + class XDocumentProperties; + } +} + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::uno { template <class interface_type> class Reference; } + +class SFX2_DLLPUBLIC SfxFrameHTMLWriter +{ + SAL_DLLPRIVATE static void OutMeta( SvStream& rStrm, + const char *pIndent, const OUString& rName, + const OUString& rContent, bool bHTTPEquiv, + rtl_TextEncoding eDestEnc, + OUString *pNonConvertableChars = nullptr ); + SAL_DLLPRIVATE inline static void OutMeta( SvStream& rStrm, + const char *pIndent, const char *pName, + const OUString& rContent, bool bHTTPEquiv, + rtl_TextEncoding eDestEnc, + OUString *pNonConvertableChars = nullptr ); + +public: + static void Out_DocInfo( SvStream& rStrm, const OUString& rBaseURL, + const css::uno::Reference< css::document::XDocumentProperties>&, + const char *pIndent, + rtl_TextEncoding eDestEnc = RTL_TEXTENCODING_MS_1252, + OUString *pNonConvertableChars = nullptr ); + + static void Out_FrameDescriptor( + SvStream&, const OUString& rBaseURL, const css::uno::Reference < css::beans::XPropertySet >& xSet, + rtl_TextEncoding eDestEnc = RTL_TEXTENCODING_MS_1252, + OUString *pNonConvertableChars = nullptr ); +}; + +inline void SfxFrameHTMLWriter::OutMeta( SvStream& rStrm, + const char *pIndent, const char *pName, + const OUString& rContent, bool bHTTPEquiv, + rtl_TextEncoding eDestEnc, + OUString *pNonConvertableChars ) +{ + OUString sTmp = OUString::createFromAscii(pName); + OutMeta( rStrm, pIndent, sTmp, rContent, bHTTPEquiv, eDestEnc, 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..7829fa8c0 --- /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 <sal/types.h> + +#include <functional> + +// !! 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<SfxGroupId> + { + std::size_t operator()(const SfxGroupId& k) const + { + return std::hash<sal_uInt16>()(static_cast<sal_uInt16>(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..4888c48e4 --- /dev/null +++ b/include/sfx2/htmlmode.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_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..40a1b1ff9 --- /dev/null +++ b/include/sfx2/infobar.hxx @@ -0,0 +1,124 @@ +/* -*- 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 <vector> + +#include <basegfx/color/bcolor.hxx> + +#include <sfx2/childwin.hxx> +#include <sfx2/dllapi.h> + +class FixedImage; +class FixedText; +class Button; +class PushButton; + +// 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 representing a single InfoBar to be added in a SfxInfoBarContainerWindow. + */ +class SFX2_DLLPUBLIC SfxInfoBarWindow final : public vcl::Window +{ +private: + OUString m_sId; + InfobarType m_eType; + VclPtr<FixedImage> m_pImage; + VclPtr<FixedText> m_pPrimaryMessage; + VclPtr<FixedText> m_pSecondaryMessage; + VclPtr<Button> m_pCloseBtn; + std::vector<VclPtr<PushButton>> m_aActionBtns; + + void SetForeAndBackgroundColors(InfobarType eType); + +public: + SfxInfoBarWindow(vcl::Window* parent, const OUString& sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, InfobarType InfobarType, + WinBits nMessageStyle, bool bShowCloseButton); + virtual ~SfxInfoBarWindow() override; + virtual void dispose() override; + + const OUString& getId() const { return m_sId; } + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override; + virtual void Resize() override; + 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. + */ + void addButton(PushButton* pButton); + +private: + DECL_LINK(CloseHandler, Button*, void); +}; + +class SfxInfoBarContainerWindow final : public vcl::Window +{ +private: + SfxInfoBarContainerChild* m_pChildWin; + std::vector<VclPtr<SfxInfoBarWindow>> m_pInfoBars; + +public: + SfxInfoBarContainerWindow(SfxInfoBarContainerChild* pChildWin); + virtual ~SfxInfoBarContainerWindow() override; + virtual void dispose() override; + + VclPtr<SfxInfoBarWindow> appendInfoBar(const OUString& sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, InfobarType ibType, + WinBits nMessageStyle, bool bShowCloseButton); + VclPtr<SfxInfoBarWindow> getInfoBar(const OUString& sId); + bool hasInfoBarWithID(const OUString& sId); + void removeInfoBar(VclPtr<SfxInfoBarWindow> const& pInfoBar); + static bool isInfobarEnabled(const OUString& sId); + + 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..d578407ad --- /dev/null +++ b/include/sfx2/inputdlg.hxx @@ -0,0 +1,32 @@ +/* -*- 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 <sfx2/dllapi.h> +#include <vcl/weld.hxx> + +class SFX2_DLLPUBLIC InputDialog final : public weld::GenericDialogController +{ +private: + std::unique_ptr<weld::Entry> m_xEntry; + std::unique_ptr<weld::Label> m_xLabel; + std::unique_ptr<weld::Button> m_xHelp; + +public: + InputDialog(weld::Widget* pParent, const OUString &rLabelText); + OUString GetEntryText() const; + void SetEntryText(const OUString& rStr); + void HideHelpBtn(); +}; + +#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..62c421c3c --- /dev/null +++ b/include/sfx2/ipclient.hxx @@ -0,0 +1,94 @@ +/* -*- 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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <rtl/ref.hxx> + +#include <tools/gen.hxx> + +#include <vcl/window.hxx> +#include <vcl/errcode.hxx> + +namespace com::sun::star::embed { class XEmbeddedObject; } +namespace com::sun::star::uno { template <typename > class Reference; } + +class SfxInPlaceClient_Impl; +class SfxViewShell; +class SfxObjectShell; +class Fraction; + + +class SFX2_DLLPUBLIC SfxInPlaceClient +{ +friend class SfxInPlaceClient_Impl; + + rtl::Reference<SfxInPlaceClient_Impl> m_xImp; + SfxViewShell* m_pViewSh; + VclPtr<vcl::Window> 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( long nVerb ); + void VisAreaChanged(); + void ResetObject(); + bool IsUIActive() const; + + virtual void FormatChanged(); // object format was changed (used for StarMath formulas aligning) +}; + +#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..deb9f00c0 --- /dev/null +++ b/include/sfx2/linkmgr.hxx @@ -0,0 +1,185 @@ +/* -*- 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 <rtl/ustring.hxx> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sfx2/linksrc.hxx> +#include <sfx2/lnkbase.hxx> +#include <o3tl/sorted_vector.hxx> +#include <vector> + +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<tools::SvRef<SvBaseLink> > SvBaseLinks; + +typedef o3tl::sorted_vector<SvLinkSource*> 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 +protected: + 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, + const OUString& rTopic, + const OUString& 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, + const OUString& 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!! + const OUString& rFile, + const OUString& 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 <sal/config.h> +#include <sfx2/dllapi.h> + +#include <tools/ref.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <memory> + +namespace com::sun::star::uno +{ + class Any; +} +namespace weld { class Window; } + +template <typename Arg, typename Ret> 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<SvLinkSource_Impl> 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<const OUString&, void>& 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<css::io::XInputStream>& xInputStream, bool bIsReadOnly ) + :m_xInputStreamToLoadFrom(xInputStream), + m_bIsReadOnly(bIsReadOnly) + { + } + + css::uno::Reference<css::io::XInputStream> + m_xInputStreamToLoadFrom; + bool m_bIsReadOnly; + }; + + StreamToLoadFrom getStreamToLoadFrom(); + void setStreamToLoadFrom(const css::uno::Reference<css::io::XInputStream>& xInputStream, bool bIsReadOnly ); + void clearStreamToLoadFrom(); +}; + +typedef tools::SvRef<SvLinkSource> SvLinkSourceRef; + +} +#endif + +/* 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..332702b88 --- /dev/null +++ b/include/sfx2/lnkbase.hxx @@ -0,0 +1,177 @@ +/* -*- 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 <rtl/ustring.hxx> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sfx2/linksrc.hxx> +#include <sot/formats.hxx> +#include <tools/ref.hxx> +#include <tools/link.hxx> +#include <memory> + +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<int>(t) & static_cast<int>(SvBaseLinkObjectType::ClientSo); +} +constexpr bool isClientFileType(SvBaseLinkObjectType t) +{ + auto check = static_cast<int>(SvBaseLinkObjectType::ClientFile); + return (static_cast<int>(t) & check) == check; +} + +struct BaseLink_Impl; + +class SFX2_DLLPUBLIC SvBaseLink : public SvRefBase +{ +private: + friend class LinkManager; + friend class SvLinkSource; + + SvLinkSourceRef xObj; + OUString aLinkName; + std::unique_ptr<BaseLink_Impl> pImpl; + SvBaseLinkObjectType mnObjType; + bool bVisible : 1; + bool bSynchron : 1; + bool bWasLastEditOK : 1; + + DECL_LINK( EndEditHdl, const OUString&, void ); + + bool ExecuteEdit( const OUString& _rNewName ); + +protected: + void SetObjType( SvBaseLinkObjectType ); + + // Set LinkSourceName without action + void SetName( const OUString & rLn ); + + std::unique_ptr<ImplBaseLinkData> pImplData; + + bool m_bIsReadOnly; + css::uno::Reference<css::io::XInputStream> + 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<SvBaseLink&,void>& 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<css::io::XInputStream>& xInputStream, + bool bIsReadOnly ) + { m_xInputStreamToLoadFrom = xInputStream; + m_bIsReadOnly = bIsReadOnly; } + // #i88291# + void clearStreamToLoadFrom(); + + bool WasLastEditOK() const { return bWasLastEditOK; } + FileDialogHelper & GetInsertFileDialog(const OUString& rFactory) const; +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/lokcharthelper.hxx b/include/sfx2/lokcharthelper.hxx new file mode 100644 index 000000000..8998010d1 --- /dev/null +++ b/include/sfx2/lokcharthelper.hxx @@ -0,0 +1,61 @@ +/* -*- 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 <sfx2/dllapi.h> +#include <tools/gen.hxx> +#include <vcl/window.hxx> + +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<css::frame::XController> mxController; + css::uno::Reference<css::frame::XDispatch> mxDispatcher; + VclPtr<vcl::Window> mpWindow; + +public: + LokChartHelper(SfxViewShell* pViewShell) + : mpViewShell(pViewShell) + , mpWindow(nullptr) + {} + + css::uno::Reference<css::frame::XController>& GetXController(); + css::uno::Reference<css::frame::XDispatch>& GetXDispatcher(); + vcl::Window* GetWindow(); + tools::Rectangle GetChartBoundingBox(); + void Invalidate(); + + bool Hit(const Point& aPos); + static bool HitAny(const Point& aPos); + void PaintTile(VirtualDevice& rRenderContext, const tools::Rectangle& rTileRect); + static void PaintAllChartsOnTile(VirtualDevice& rDevice, + int nOutputWidth, int nOutputHeight, + int nTilePosX, int nTilePosY, + long nTileWidth, long nTileHeight); + 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); +}; + +#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..05a94c486 --- /dev/null +++ b/include/sfx2/lokhelper.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/. + */ + +#ifndef INCLUDED_SFX2_LOKHELPER_HXX +#define INCLUDED_SFX2_LOKHELPER_HXX + +#include <vcl/IDialogRenderable.hxx> +#include <vcl/ITiledRenderable.hxx> +#include <vcl/event.hxx> +#include <sfx2/dllapi.h> +#include <sfx2/viewsh.hxx> +#include <cstddef> +#include <rtl/string.hxx> +#include <optional> + +struct SFX2_DLLPUBLIC LokMouseEventData +{ + int mnType; + Point maPosition; + int mnCount; + MouseEventModifiers meModifiers; + int mnButtons; + int mnModifier; + std::optional<Point> 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) + {} +}; + +class SFX2_DLLPUBLIC SfxLokHelper +{ +public: + /// Create a new view shell from the current view frame. + static int createView(); + /// 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 the currently active view. + static int getView(SfxViewShell* pViewShell = nullptr); + /// Get the number of views of the current object shell. + static std::size_t getViewsCount(); + /// Get viewIds of all existing views. + static bool getViewIds(int* pArray, size_t nSize); + /// Get the default language that should be used for views + static 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(const OUString& rDeviceFormFactor); + /// Iterate over any view shell, except pThisViewShell, passing it to the f function. + template<typename ViewShellType, typename FunctionType> + static void forEachOtherView(ViewShellType* pThisViewShell, FunctionType f); + /// Invoke the LOK callback of all views except pThisView, with a payload of rKey-rPayload. + static void notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload); + /// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them. + static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload); + /// 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, + const OUString& rAction, + const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()); + /// 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 - 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, const OString& rPayload); + /// Emits a LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, but tweaks it according to setOptionalFeatures() if needed. + static void notifyVisCursorInvalidation(OutlinerViewShell const* pThisView, const OString& rRectangle, bool bMispelledWord = false, const OString& rHyperlink = ""); + /// 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); + + /// Helper for posting async key event + static void postKeyEventAsync(const VclPtr<vcl::Window> &xWindow, + int nType, int nCharCode, int nKeyCode, int nRepeat = 0); + + /// Helper for posting input event + static void postExtTextEventAsync(const VclPtr<vcl::Window> &xWindow, + int nType, const OUString &rText); + + /// Helper for posting async mouse event + static void postMouseEventAsync(const VclPtr<vcl::Window> &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 long MaxTwips = 1e9; +}; + +template<typename ViewShellType, typename FunctionType> +void SfxLokHelper::forEachOtherView(ViewShellType* pThisViewShell, FunctionType f) +{ + SfxViewShell* pViewShell = SfxViewShell::GetFirst(); + while (pViewShell) + { + auto pOtherViewShell = dynamic_cast<ViewShellType*>(pViewShell); + if (pOtherViewShell != nullptr && pOtherViewShell != pThisViewShell) + { + 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..8ee361cd7 --- /dev/null +++ b/include/sfx2/mailmodelapi.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_MAILMODELAPI_HXX +#define INCLUDED_SFX2_MAILMODELAPI_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <rtl/ustring.hxx> +#include <sfx2/dllapi.h> +#include <vector> +#include <memory> + +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 E> class Sequence; } + +// class AddressList_Impl ------------------------------------------------ +typedef ::std::vector< OUString > AddressList_Impl; + +// class SfxMailModel_Impl ----------------------------------------------- + +class SFX2_DLLPUBLIC SfxMailModel +{ +protected: + enum SaveResult + { + SAVE_SUCCESSFULL, + 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<AddressList_Impl> 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, + const OUString& 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..103f93a3f --- /dev/null +++ b/include/sfx2/mieclip.hxx @@ -0,0 +1,44 @@ +/* -*- 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 <memory> +#include <rtl/ustring.hxx> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <tools/stream.hxx> + +class SFX2_DLLPUBLIC MSE40HTMLClipFormatObj +{ + std::unique_ptr<SvStream> 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..6a3eb5a65 --- /dev/null +++ b/include/sfx2/minfitem.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_MINFITEM_HXX +#define INCLUDED_SFX2_MINFITEM_HXX + +#include <rtl/ustring.hxx> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <svl/poolitem.hxx> + +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..fbffbc6ad --- /dev/null +++ b/include/sfx2/module.hxx @@ -0,0 +1,105 @@ +/* -*- 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 <memory> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sfx2/shell.hxx> +#include <sfx2/styfitem.hxx> +#include <sal/types.h> +#include <tools/fldunit.hxx> +#include <com/sun/star/uno/Reference.hxx> + +class SfxObjectFactory; +class SfxModule_Impl; +class SfxSlotPool; +struct SfxChildWinFactory; +struct SfxStbCtrlFactory; +struct SfxTbxCtrlFactory; +class SfxTabPage; +class SfxTbxCtrlFactArr_Impl; +class SfxStbCtrlFactArr_Impl; +class SfxChildWinFactArr_Impl; + +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<SfxObjectFactory*> pFactoryList); + virtual ~SfxModule() override; + + std::locale GetResLocale() const; + SfxSlotPool* GetSlotPool() const; + + void RegisterToolBoxControl(const SfxTbxCtrlFactory&); + void RegisterChildWindow(std::unique_ptr<SfxChildWinFactory>); + void RegisterStatusBarControl(const SfxStbCtrlFactory&); + + virtual std::unique_ptr<SfxTabPage> CreateTabPage( sal_uInt16 nId, + weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rSet ); + virtual void Invalidate(sal_uInt16 nId = 0) override; + + virtual std::unique_ptr<SfxStyleFamilies> CreateStyleFamilies() { return nullptr; } + + 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 SfxTbxCtrlFactArr_Impl* GetTbxCtrlFactories_Impl() const; + SAL_DLLPRIVATE SfxStbCtrlFactArr_Impl* GetStbCtrlFactories_Impl() const; + SAL_DLLPRIVATE SfxChildWinFactArr_Impl* GetChildWinFactories_Impl() 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..5e5a15f1d --- /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 <sfx2/shell.hxx> +#include <rtl/string.hxx> +#include <rtl/ustring.hxx> +#include <svl/poolitem.hxx> +#include <sfx2/dllapi.h> +#include <o3tl/typed_flags_set.hxx> +#include <sfx2/groupid.hxx> +#include <functional> + +#include <climits> + +class SfxItemPool; + +enum class SfxSlotMode { + NONE = 0x0000L, // default + + TOGGLE = 0x0004L, // inverted for Execute old value + AUTOUPDATE = 0x0008L, // invalidated the status automatically after execute + ASYNCHRON = 0x0020L, // via Post-Message + + NORECORD = 0x0100L, // no recording + RECORDPERITEM = 0x0200L, // each item, one statement + RECORDPERSET = 0x0400L, // The whole Set is a Statement, default + RECORDABSOLUTE = 0x1000000L, // Recording with absolute Target + + METHOD = 0x4000L, + + FASTCALL = 0x8000L, // No test if disabled before Execute + + MENUCONFIG = 0x20000L, // configurable Menu + TOOLBOXCONFIG = 0x40000L, // configurable Toolboxen + ACCELCONFIG = 0x80000L, // configurable keys + + CONTAINER = 0x100000L, // Operated by the container at InPlace + READONLYDOC = 0x200000L // also available for read-only Documents +}; + +namespace o3tl +{ + template<> struct typed_flags<SfxSlotMode> : is_typed_flags<SfxSlotMode, 0x13ec72cL> {}; +} + +#define SFX_EXEC_STUB( aShellClass, aExecMethod) \ + void SfxStub##aShellClass##aExecMethod( \ + SfxShell *pShell, SfxRequest& rReq) \ + { \ + ::tools::detail::castTo<aShellClass*>(pShell)->aExecMethod( rReq ); \ + } + +#define SFX_STATE_STUB( aShellClass, aStateMethod) \ + void SfxStub##aShellClass##aStateMethod( \ + SfxShell *pShell, SfxItemSet& rSet) \ + { \ + static_cast<aShellClass*>(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<class T> SfxPoolItem* createSfxPoolItem() +{ + return T::CreateDefault(); +} +struct SfxType +{ + std::function<SfxPoolItem* ()> 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<SfxPoolItem> CreateItem() const + { return std::unique_ptr<SfxPoolItem>(createSfxPoolItemFunc()); } +}; + +struct SfxType0 +{ + std::function<SfxPoolItem* ()> 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<SfxPoolItem* ()> 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<SfxPoolItem> 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..357d86d67 --- /dev/null +++ b/include/sfx2/msgpool.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_MSGPOOL_HXX +#define INCLUDED_SFX2_MSGPOOL_HXX + +#include <rtl/ustring.hxx> +#include <sal/config.h> +#include <sal/types.h> +#include <sfx2/dllapi.h> +#include <sfx2/groupid.hxx> +#include <vector> + +class SfxInterface; +class SfxSlot; +class SfxViewFrame; + +class SFX2_DLLPUBLIC SfxSlotPool +{ + std::vector<SfxGroupId> _vGroups; + SfxSlotPool* _pParentPool; + std::vector<SfxInterface*> _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 ); + void ReleaseInterface( 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..29b7c84f4 --- /dev/null +++ b/include/sfx2/navigat.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_NAVIGAT_HXX +#define INCLUDED_SFX2_NAVIGAT_HXX + +#include <sfx2/childwin.hxx> +#include <sfx2/dockwin.hxx> + +class SfxNavigatorWrapper final : public SfxChildWindow +{ + +public: + SfxNavigatorWrapper( vcl::Window* pParent , + sal_uInt16 nId , + SfxBindings* pBindings , + SfxChildWinInfo* pInfo ); + + SFX_DECL_CHILDWINDOW(SfxNavigatorWrapper); +}; + +class SFX2_DLLPUBLIC SfxNavigator final : public SfxDockingWindow +{ + SfxChildWindow* pWrapper; + +public: + SfxNavigator( SfxBindings* pBindings , + SfxChildWindow* pChildWin , + vcl::Window* pParent , + WinBits nBits ); + + virtual void Resize() override; + virtual bool Close() override; +}; + +#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..9be8586c7 --- /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 <memory> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sfx2/basedlgs.hxx> +#include <sfx2/objsh.hxx> + +#include <vcl/idle.hxx> +#include <sfx2/doctempl.hxx> +#include <o3tl/typed_flags_set.hxx> + +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<SfxTemplateFlags> : is_typed_flags<SfxTemplateFlags, 0x1f> {}; +} + +#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<SfxPreviewWin_Impl> m_xPreviewController; + + std::unique_ptr<weld::TreeView> m_xRegionLb; + std::unique_ptr<weld::TreeView> m_xTemplateLb; + std::unique_ptr<weld::CheckButton> m_xTextStyleCB; + std::unique_ptr<weld::CheckButton> m_xFrameStyleCB; + std::unique_ptr<weld::CheckButton> m_xPageStyleCB; + std::unique_ptr<weld::CheckButton> m_xNumStyleCB; + std::unique_ptr<weld::CheckButton> m_xMergeStyleCB; + std::unique_ptr<weld::Button> m_xLoadFilePB; + std::unique_ptr<weld::Expander> m_xMoreBt; + std::unique_ptr<weld::CustomWeld> m_xPreviewWin; + std::unique_ptr<weld::Label> m_xAltTitleFt; + + DECL_LINK( Update, Timer *, void ); + + DECL_LINK(RegionSelect, weld::TreeView&, void); + DECL_LINK(TemplateSelect, weld::TreeView&, void); + DECL_LINK(DoubleClick, weld::TreeView&, bool); + DECL_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..ea20fc9fc --- /dev/null +++ b/include/sfx2/newstyle.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_NEWSTYLE_HXX +#define INCLUDED_SFX2_NEWSTYLE_HXX + +#include <comphelper/string.hxx> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <svl/style.hxx> +#include <vcl/weld.hxx> + +class SFX2_DLLPUBLIC SfxNewStyleDlg final : public weld::GenericDialogController +{ +private: + SfxStyleSheetBasePool& m_rPool; + SfxStyleFamily m_eSearchFamily; + + std::unique_ptr<weld::EntryTreeView> m_xColBox; + std::unique_ptr<weld::Button> m_xOKBtn; + + std::unique_ptr<weld::MessageDialog> 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::Window* 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..1a3babd53 --- /dev/null +++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx @@ -0,0 +1,68 @@ +/* -*- 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 <sfx2/dllapi.h> +#include <rtl/ustring.hxx> + +namespace com::sun::star::frame { class XFrame; } +namespace com::sun::star::uno { template <typename > class Reference; } + +class SfxBindings; +class SfxViewFrame; +class SystemWindow; + +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, const OUString& rUIFile, + bool bReloadNotebookbar = false); + static bool StateMethod(SystemWindow* pSysWindow, + const css::uno::Reference<css::frame::XFrame>& xFrame, + const OUString& 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(const OUString& sUIPath); + +private: + static bool m_bLock; + static bool m_bHide; +}; + +} // 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..bda6ecc05 --- /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 <memory> +#include <rtl/ustring.hxx> +#include <sal/config.h> +#include <sal/types.h> +#include <sfx2/dllapi.h> +#include <sfx2/msg.hxx> +#include <sfx2/toolbarids.hxx> + +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<SfxInterface_Impl> 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( 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..7fb199c88 --- /dev/null +++ b/include/sfx2/objitem.hxx @@ -0,0 +1,45 @@ +/* -*- 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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <svl/poolitem.hxx> + +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; + + 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..be90b2bfa --- /dev/null +++ b/include/sfx2/objsh.hxx @@ -0,0 +1,897 @@ +/* -*- 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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <sfx2/signaturestate.hxx> +#include <sal/types.h> +#include <vcl/errcode.hxx> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Sequence.hxx> + +#include <svl/poolitem.hxx> +#include <sot/formats.hxx> +#include <sot/object.hxx> +#include <tools/gen.hxx> +#include <tools/link.hxx> + +#include <sfx2/shell.hxx> +#include <comphelper/embeddedobjectcontainer.hxx> +#include <memory> +#include <set> +#include <o3tl/typed_flags_set.hxx> +#include <functional> +#include <sfx2/AccessibilityIssue.hxx> + +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 Button; +class OutputDevice; +class Color; +class Fraction; +class SvGlobalName; +class InfobarData; + +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 vcl { class Window; } +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::document { struct CmisVersion; } +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 { + namespace document { + class XDocumentProperties; + } + namespace lang { + class XComponent; + } + namespace 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<SfxLoadedFlags> : is_typed_flags<SfxLoadedFlags, 0x03> {}; +} + +enum class HiddenInformation +{ + NONE = 0x0000, + RECORDEDCHANGES = 0x0001, + NOTES = 0x0002, + DOCUMENTVERSIONS = 0x0004 +}; +namespace o3tl +{ + template<> struct typed_flags<HiddenInformation> : is_typed_flags<HiddenInformation, 0x07> {}; +} + +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. +*/ + +struct TransferableObjectDescriptor; +template<class T> bool checkSfxObjectShell(const SfxObjectShell* pShell) +{ + return dynamic_cast<const T*>(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<struct SfxObjectShell_Impl> 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(); + +public: + SFX_DECL_INTERFACE(SFX_INTERFACE_SFXDOCSH) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + static const css::uno::Sequence<sal_Int8>& 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<bool ( const SfxObjectShell* )>& isObjectShell = nullptr, + bool bOnlyVisible = true ); + static SfxObjectShell* GetNext( const SfxObjectShell& rPrev, + const std::function<bool ( const SfxObjectShell* )>& 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( SfxMedium* pMedium=nullptr ); + 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 SwitchPersistance( + 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 SwitchChildrenPersistance( + 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<css::text::XTextRange> const& xInsertPosition); + virtual bool ImportFrom( SfxMedium &rMedium, + css::uno::Reference<css::text::XTextRange> const& xInsertPosition); + bool ExportTo( SfxMedium &rMedium ); + + /** Returns to if preparing was successful, else false. */ + bool PrepareForSigning(weld::Window* pDialogParent); + bool CheckIsReadonly(bool bSignScriptingContent); + void RecheckSignature(bool bAlsoRecheckScriptingSignature); + void AfterSigning(bool bSignSuccess, bool bSignScriptingContent); + bool HasValidSignatures() const; + SignatureState GetDocumentSignatureState(); + void SignDocumentContent(weld::Window* pDialogParent); + css::uno::Sequence<css::security::DocumentSignatureInformation> GetDocumentSignatureInformation( + bool bScriptingContent, + const css::uno::Reference<css::security::XDocumentDigitalSignatures>& xSigner + = css::uno::Reference<css::security::XDocumentDigitalSignatures>()); + + bool SignDocumentContentUsingCertificate(const css::uno::Reference<css::security::XCertificate>& xCertificate); + + void SignSignatureLine(weld::Window* pDialogParent, const OUString& aSignatureLineId, + const css::uno::Reference<css::security::XCertificate>& xCert, + const css::uno::Reference<css::graphic::XGraphic>& xValidGraphic, + const css::uno::Reference<css::graphic::XGraphic>& xInvalidGraphic, + const OUString& aComment); + SignatureState GetScriptingSignatureState(); + void SignScriptingContent(weld::Window* pDialogParent); + DECL_LINK(SignDocumentHandler, Button*, void); + + virtual std::shared_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet& rItemSet); + + ErrCode CallBasic( const OUString& rMacro, const OUString& 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<css::uno::XInterface>& 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<GDIMetaFile> GetPreviewMetaFile( bool bFullContent = false ) 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(const OUString& 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 + long 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<Color> GetDocColors(); + + // Accessibility Check + virtual sfx::AccessibilityIssueCollection runAccessibilityCheck(); + + // Documents, for which to format the view size + + virtual SfxObjectShell* GetObjectShell() override; + + css::uno::Reference< css::frame::XModel > + GetModel() const; + // Only temporarily for the applications! + void SetBaseModel( SfxBaseModel* pModel ); + css::uno::Reference< css::frame::XModel > GetBaseModel() const; + // Only temporarily for the applications! + + virtual css::uno::Sequence< OUString > GetEventNames(); + + vcl::Window* 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::lang::XComponent >& xComp ); + 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<css::embed::XStorage>& xTarget, + const css::uno::Sequence<OUString>& rExceptions = css::uno::Sequence<OUString>()); + + bool isEditDocLocked(); + bool isContentExtractionLocked(); + bool isExportLocked(); + bool isPrintLocked(); + bool isSaveLocked(); + + // 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<SfxObjectShell*>(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 ); + 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<InfobarData>& getPendingInfobars(); + + SAL_DLLPRIVATE std::shared_ptr<GDIMetaFile> CreatePreviewMetaFile_Impl(bool bFullContent) 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<css::beans::PropertyValue>& rArgs); + SAL_DLLPRIVATE bool APISaveAs_Impl(const OUString& aFileName, SfxItemSet& rItemSet, + const css::uno::Sequence<css::beans::PropertyValue>& rArgs); + SAL_DLLPRIVATE bool + CommonSaveAs_Impl(const INetURLObject& aURL, const OUString& aFilterName, SfxItemSet& rItemSet, + const css::uno::Sequence<css::beans::PropertyValue>& 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 ); + SAL_DLLPRIVATE SfxObjectShell* GetParentShellByModel_Impl(); + + // 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; } +}; + +#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<SfxObjectShell> SfxObjectShellRef; + +class SfxObjectShellLock +{ +protected: + 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 <memory> +#include <sfx2/dllapi.h> +#include <rtl/ustring.hxx> +#include <vcl/errcode.hxx> + +namespace com::sun::star::ui::dialogs { class XFilePickerControlAccess; } +namespace com::sun::star::uno { template <class interface_type> 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<css::ui::dialogs::XFilePickerControlAccess> 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..1dcba1219 --- /dev/null +++ b/include/sfx2/pageids.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 . + */ + +#ifndef INCLUDED_SFX2_PAGEIDS_HXX +#define INCLUDED_SFX2_PAGEIDS_HXX + +#include <svl/solar.hrc> + +#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) + +// 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..cbbbf7a4a --- /dev/null +++ b/include/sfx2/passwd.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 . + */ +#ifndef INCLUDED_SFX2_PASSWD_HXX +#define INCLUDED_SFX2_PASSWD_HXX + +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <vcl/weld.hxx> +#include <o3tl/typed_flags_set.hxx> + +// defines --------------------------------------------------------------- + +enum class SfxShowExtras +{ + NONE = 0x0000, + USER = 0x0001, + CONFIRM = 0x0002, + PASSWORD2 = 0x0004, + CONFIRM2 = 0x0008, + ALL = USER | CONFIRM +}; +namespace o3tl +{ + template<> struct typed_flags<SfxShowExtras> : is_typed_flags<SfxShowExtras, 0x0f> {}; +} + +// class SfxPasswordDialog ----------------------------------------------- + +class SFX2_DLLPUBLIC SfxPasswordDialog final : public weld::GenericDialogController +{ +private: + std::unique_ptr<weld::Frame> m_xPassword1Box; + std::unique_ptr<weld::Label> m_xUserFT; + std::unique_ptr<weld::Entry> m_xUserED; + std::unique_ptr<weld::Label> m_xPassword1FT; + std::unique_ptr<weld::Entry> m_xPassword1ED; + std::unique_ptr<weld::Label> m_xConfirm1FT; + std::unique_ptr<weld::Entry> m_xConfirm1ED; + + std::unique_ptr<weld::Frame> m_xPassword2Box; + std::unique_ptr<weld::Label> m_xPassword2FT; + std::unique_ptr<weld::Entry> m_xPassword2ED; + std::unique_ptr<weld::Label> m_xConfirm2FT; + std::unique_ptr<weld::Entry> m_xConfirm2ED; + + std::unique_ptr<weld::Label> m_xMinLengthFT; + + std::unique_ptr<weld::Button> 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() + { + mbAsciiOnly = true; + } + + 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 <memory> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <vcl/print.hxx> + +class SfxItemSet; + +// class SfxPrinter ------------------------------------------------------ + +class SFX2_DLLPUBLIC SfxPrinter final : public Printer +{ +private: + std::unique_ptr<SfxItemSet> pOptions; + bool bKnown; + + SfxPrinter& operator =(SfxPrinter const &) = delete; + +public: + SfxPrinter( std::unique_ptr<SfxItemSet> &&pTheOptions ); + SfxPrinter( std::unique_ptr<SfxItemSet> &&pTheOptions, + const OUString &rPrinterName ); + SfxPrinter( std::unique_ptr<SfxItemSet> &&pTheOptions, + const JobSetup &rTheOrigJobSetup ); + SfxPrinter( const SfxPrinter &rPrinter ); + virtual ~SfxPrinter() override; + virtual void dispose() override; + + VclPtr<SfxPrinter> Clone() const; + + static VclPtr<SfxPrinter> Create( SvStream &rStream, std::unique_ptr<SfxItemSet> &&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..d93284f34 --- /dev/null +++ b/include/sfx2/printopt.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 . + */ + +#ifndef INCLUDED_SFX2_PRINTOPT_HXX +#define INCLUDED_SFX2_PRINTOPT_HXX + +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sfx2/tabdlg.hxx> +#include <sal/types.h> +#include <vcl/print.hxx> + + +class SFX2_DLLPUBLIC SfxCommonPrintOptionsTabPage final : public SfxTabPage +{ +private: + + std::unique_ptr<weld::RadioButton> m_xPrinterOutputRB; + std::unique_ptr<weld::RadioButton> m_xPrintFileOutputRB; + std::unique_ptr<weld::CheckButton> m_xReduceTransparencyCB; + std::unique_ptr<weld::RadioButton> m_xReduceTransparencyAutoRB; + std::unique_ptr<weld::RadioButton> m_xReduceTransparencyNoneRB; + std::unique_ptr<weld::CheckButton> m_xReduceGradientsCB; + std::unique_ptr<weld::RadioButton> m_xReduceGradientsStripesRB; + std::unique_ptr<weld::RadioButton> m_xReduceGradientsColorRB; + std::unique_ptr<weld::SpinButton> m_xReduceGradientsStepCountNF; + std::unique_ptr<weld::CheckButton> m_xReduceBitmapsCB; + std::unique_ptr<weld::RadioButton> m_xReduceBitmapsOptimalRB; + std::unique_ptr<weld::RadioButton> m_xReduceBitmapsNormalRB; + std::unique_ptr<weld::RadioButton> m_xReduceBitmapsResolutionRB; + std::unique_ptr<weld::ComboBox> m_xReduceBitmapsResolutionLB; + std::unique_ptr<weld::CheckButton> m_xReduceBitmapsTransparencyCB; + std::unique_ptr<weld::CheckButton> m_xConvertToGreyscalesCB; + std::unique_ptr<weld::CheckButton> m_xPDFCB; + std::unique_ptr<weld::CheckButton> m_xPaperSizeCB; + std::unique_ptr<weld::CheckButton> m_xPaperOrientationCB; + std::unique_ptr<weld::CheckButton> m_xTransparencyCB; + +private: + + PrinterOptions maPrinterOptions; + PrinterOptions maPrintFileOptions; + + DECL_DLLPRIVATE_LINK( ToggleOutputPrinterRBHdl, weld::ToggleButton&, void ); + DECL_DLLPRIVATE_LINK( ToggleOutputPrintFileRBHdl, weld::ToggleButton&, void); + + DECL_DLLPRIVATE_LINK( ClickReduceTransparencyCBHdl, weld::Button&, void ); + DECL_DLLPRIVATE_LINK( ClickReduceGradientsCBHdl, weld::Button&, void ); + DECL_DLLPRIVATE_LINK( ClickReduceBitmapsCBHdl, weld::Button&, void ); + + DECL_DLLPRIVATE_LINK( ToggleReduceGradientsStripesRBHdl, weld::ToggleButton&, void ); + DECL_DLLPRIVATE_LINK( ToggleReduceBitmapsResolutionRBHdl, weld::ToggleButton&, void ); + + SAL_DLLPRIVATE void ImplUpdateControls( const PrinterOptions* pCurrentOptions ); + SAL_DLLPRIVATE void ImplSaveControls( PrinterOptions* 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<SfxTabPage> 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 <rtl/ustring.hxx> +#include <sal/config.h> +#include <sal/types.h> +#include <sfx2/dllapi.h> +#include <memory> + + +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..90058a5b1 --- /dev/null +++ b/include/sfx2/request.hxx @@ -0,0 +1,126 @@ +/* -*- 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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <svl/itemset.hxx> +#include <svl/hint.hxx> + +#include <memory> + +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 E> class Sequence; } +namespace vcl { class Window; } +namespace weld { class Window; } + +class SFX2_DLLPUBLIC SfxRequest final : public SfxHint +{ +friend struct SfxRequest_Impl; + + sal_uInt16 nSlot; + std::unique_ptr<SfxAllItemSet> 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<SfxInt32Item>(SID_POS); + */ + template<class T> const T* GetArg(sal_uInt16 nSlotId) const + { + if (pArgs) + return pArgs->GetItem<T>(nSlotId, false); + + return nullptr; + } + + 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 + */ + vcl::Window* GetFrameWindow() const; + 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..47034f621 --- /dev/null +++ b/include/sfx2/safemode.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/. + */ + +#ifndef INCLUDED_SFX2_SAFEMODE_HXX +#define INCLUDED_SFX2_SAFEMODE_HXX + +#include <sfx2/dllapi.h> + +#include <rtl/ustring.hxx> + +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..7fd536a14 --- /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 <memory> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/XDispatchInformationProvider.hpp> +#include <com/sun/star/frame/XController2.hpp> +#include <com/sun/star/frame/XControllerBorder.hpp> +#include <com/sun/star/frame/XInfobarProvider.hpp> +#include <com/sun/star/frame/XTitle.hpp> +#include <com/sun/star/frame/XTitleChangeBroadcaster.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include <com/sun/star/task/XStatusIndicatorSupplier.hpp> +#include <com/sun/star/ui/XContextMenuInterception.hpp> +#include <com/sun/star/awt/XUserInputInterception.hpp> +#include <tools/link.hxx> + +#include <sfx2/groupid.hxx> + +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; } + +struct IMPL_SfxBaseController_DataContainer ; // impl. struct to hold member of class SfxBaseController + +class Button; +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<css::beans::StringPair>& 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_LINK( CheckOutHandler, Button*, void ); + + std::unique_ptr<IMPL_SfxBaseController_DataContainer> 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..8fa52fbfa --- /dev/null +++ b/include/sfx2/sfxbasemodel.hxx @@ -0,0 +1,749 @@ +/* -*- 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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <com/sun/star/frame/XModule.hpp> +#include <com/sun/star/frame/XTitle.hpp> +#include <com/sun/star/frame/XTitleChangeBroadcaster.hpp> +#include <com/sun/star/frame/XUntitledNumbers.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/document/XCmisDocument.hpp> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/document/XDocumentRecovery.hpp> +#include <com/sun/star/document/XUndoManagerSupplier.hpp> +#include <com/sun/star/rdf/XDocumentMetadataAccess.hpp> +#include <com/sun/star/document/XEventBroadcaster.hpp> +#include <com/sun/star/document/XShapeEventBroadcaster.hpp> +#include <com/sun/star/document/XDocumentEventBroadcaster.hpp> +#include <com/sun/star/document/XEventsSupplier.hpp> +#include <com/sun/star/document/XEmbeddedScripts.hpp> +#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp> +#include <com/sun/star/document/XStorageBasedDocument.hpp> +#include <com/sun/star/document/XScriptInvocationContext.hpp> +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/frame/XModel2.hpp> +#include <com/sun/star/util/XModifiable2.hpp> +#include <com/sun/star/util/XCloseable.hpp> +#include <com/sun/star/view/XPrintable.hpp> +#include <com/sun/star/view/XPrintJobBroadcaster.hpp> +#include <com/sun/star/frame/XStorable2.hpp> +#include <com/sun/star/frame/XLoadable.hpp> +#include <com/sun/star/lang/EventObject.hpp> +#include <com/sun/star/datatransfer/XTransferable.hpp> +#include <com/sun/star/script/provider/XScriptProviderSupplier.hpp> +#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> +#include <com/sun/star/embed/XVisualObject.hpp> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Any.hxx> +#include <cppuhelper/basemutex.hxx> +#include <com/sun/star/script/XStarBasicAccess.hpp> + +#include <com/sun/star/document/XViewDataSupplier.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <cppuhelper/implbase.hxx> +#include <svl/lstner.hxx> + +#include <memory> + +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::XModel2 + , 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() throw() override + { OWeakObject::acquire(); } + + /**___________________________________________________________________________________________________ + @short decrement refcount + @seealso XInterface + @seealso acquire() + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL release() throw() 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<css::beans::PropertyValue>& aArgs) 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<css::beans::PropertyValue>& 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 >() ); + + 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<IMPL_SfxBaseModel_DataContainer> 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..6d03dc0f8 --- /dev/null +++ b/include/sfx2/sfxdlg.hxx @@ -0,0 +1,150 @@ +/* -*- 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 <sal/config.h> +#include <sfx2/dllapi.h> + +#include <vcl/abstdlg.hxx> + +#include <sot/formats.hxx> +#include <sfx2/tabdlg.hxx> +#include <com/sun/star/uno/Reference.h> + +class SfxItemSet; +namespace vcl { class Window; } +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 const sal_uInt16* 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<LinkParamNone*,void>& 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<VclAbstractDialog> CreateFrameDialog(weld::Window* pParent, const css::uno::Reference< css::frame::XFrame >& rFrame, sal_uInt32 nResId, const OUString& rParameter) = 0; + virtual VclPtr<SfxAbstractTabDialog> CreateAutoCorrTabDialog(weld::Window* pParent, const SfxItemSet* pAttrSet) = 0; + virtual VclPtr<SfxAbstractTabDialog> 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<SfxAbstractInsertObjectDialog> CreateInsertObjectDialog(weld::Window* pParent, const OUString& rCommand, + const css::uno::Reference < css::embed::XStorage >& xStor, + const SvObjectServerList* pList )=0; + virtual VclPtr<VclAbstractDialog> CreateEditObjectDialog(weld::Window* pParent, const OUString& rCommand, + const css::uno::Reference < css::embed::XEmbeddedObject >& xObj )=0; + virtual VclPtr<SfxAbstractPasteDialog> CreatePasteDialog(weld::Window* pParent) = 0; + virtual VclPtr<SfxAbstractLinksDialog> CreateLinksDialog(weld::Window* pParent, sfx2::LinkManager* pMgr, bool bHTML=false, sfx2::SvBaseLink* p=nullptr) = 0; + virtual VclPtr<VclAbstractDialog> CreateSvxScriptOrgDialog(weld::Window* pParent, const OUString& rLanguage) = 0; + + virtual VclPtr<AbstractScriptSelectorDialog> CreateScriptSelectorDialog(weld::Window* pParent, + const css::uno::Reference< css::frame::XFrame >& rxFrame) = 0; + + virtual VclPtr<VclAbstractDialog> CreateScriptErrorDialog( const css::uno::Any& rException ) = 0; + + virtual VclPtr<VclAbstractDialog> CreateOptionsDialog( + weld::Window* pParent, const OUString& rExtensionId ) = 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..06cd21c6e --- /dev/null +++ b/include/sfx2/sfxhelp.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SFXHELP_HXX +#define INCLUDED_SFX2_SFXHELP_HXX + +#include <rtl/ustring.hxx> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <vcl/help.hxx> + +class SFX2_DLLPUBLIC SfxHelp final : public Help +{ + bool bIsDebug; + +private: + SAL_DLLPRIVATE static bool Start_Impl( const OUString& rURL, const vcl::Window* pWindow, const OUString& rKeyword ); + 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, const vcl::Window* pWindow ) override; + SAL_DLLPRIVATE virtual bool Start(const OUString& rURL, weld::Widget* pWidget) override; + SAL_DLLPRIVATE static OUString GetHelpModuleName_Impl(const OUString &rHelpId); + SAL_DLLPRIVATE static OUString CreateHelpURL_Impl( const OUString& aCommandURL, const OUString& rModuleName ); + +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(const OUString&); +}; + +#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..0cab447c8 --- /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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <i18nlangtag/lang.h> +#include <svtools/parhtml.hxx> +#include <svl/macitem.hxx> +#include <memory> + + +class ImageMap; +class SfxMedium; +class SvNumberFormatter; + +class SFX2_DLLPUBLIC SfxHTMLParser : public HTMLParser +{ + OUString aScriptType; + + SfxMedium* pMedium; + std::unique_ptr<SfxMedium> 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 + // <MAP>: sal_True = Image-Map has a name + // <AREA>: 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, const OUString& rBaseURL, + const HTMLOptions& rOptions, + SvMacroItemId nEventMouseOver, + SvMacroItemId nEventMouseOut ); + inline bool ParseAreaOptions(ImageMap * pImageMap, const OUString& rBaseURL, + SvMacroItemId nEventMouseOver, + SvMacroItemId nEventMouseOut); + + // <TD SDVAL="..." SDNUM="..."> + static double GetTableDataOptionsValNum( sal_uInt32& nNumForm, + LanguageType& eNumLang, const OUString& aValStr, + const OUString& 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 FinshFileDownload 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, const OUString& 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..1010fc0e3 --- /dev/null +++ b/include/sfx2/sfxmodelfactory.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_SFXMODELFACTORY_HXX +#define INCLUDED_SFX2_SFXMODELFACTORY_HXX + +#include <sfx2/dllapi.h> + +#include <com/sun/star/uno/Reference.hxx> +#include <o3tl/typed_flags_set.hxx> + +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 { template <class E> 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<SfxModelFlags> : is_typed_flags<SfxModelFlags, 0x0f> {}; +} + +namespace sfx2 +{ + typedef css::uno::Reference< css::uno::XInterface > ( * SfxModelFactoryFunc ) ( + const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory, + SfxModelFlags _nCreationFlags + ); + + + //= createSfxModelFactory + + /** creates a XSingleServiceFactory which can be used to created instances + of classes derived from SfxBaseModel + + In opposite to the default implementations from module cppuhelper, this + factory evaluates certain creation arguments (passed to createInstanceWithArguments) + and passes them to the factory function of the derived class. + */ + css::uno::Reference< css::lang::XSingleServiceFactory > + SFX2_DLLPUBLIC createSfxModelFactory( + const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxServiceFactory, + const OUString& _rImplementationName, + const SfxModelFactoryFunc _pComponentFactoryFunc, + const css::uno::Sequence< OUString >& _rServiceNames + ); + + +} // 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..922c59941 --- /dev/null +++ b/include/sfx2/sfxresid.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/. + * + * 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 <sfx2/dllapi.h> +#include <rtl/ustring.hxx> + +SFX2_DLLPUBLIC OUString SfxResId(const char* pId); + +#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..ff2854861 --- /dev/null +++ b/include/sfx2/sfxsids.hrc @@ -0,0 +1,710 @@ +/* -*- 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 <svl/solar.hrc> +#include <svl/memberid.h> +#include <svl/typedwhich.hxx> + +class SvxZoomItem; +class SfxUInt16Item; +class SvxHyperlinkItem; +class SfxDocumentInfoItem; +class SvxSearchItem; + +// 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_CONTEXT (SID_SFX_START + 310) + +#define SID_PASTE_SPECIAL (SID_SFX_START + 311) +#define SID_CLIPBOARD_FORMAT_ITEMS (SID_SFX_START + 312) + +#define SID_PASTE_UNFORMATTED (SID_SFX_START + 314) +#define SID_PRINTER_NOTFOUND_WARN (SID_SFX_START + 320) +#define SID_PRINTER_NAME (SID_SFX_START + 322) +#define SID_PRINTER_CHANGESTODOC (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 (SID_SFX_START + 1597) + +#define SID_SELECTION TypedWhichId<SfxBoolItem>(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 (SID_SFX_START + 403) +#define SID_HELPTIPS (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_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 (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 (SID_SFX_START + 507) +#define SID_DOCINFO_TITLE (SID_SFX_START + 557) +#define SID_FILE_FILTEROPTIONS (SID_SFX_START + 527) +#define SID_RELOAD (SID_SFX_START + 508) +#define SID_PRINTDOCDIRECT (SID_SFX_START + 509) +#define SID_DOC_REPAIR (SID_SFX_START + 510) +#define SID_DOC_SERVICE (SID_SFX_START + 511) +#define SID_PLUGIN_MODE (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 (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 (SID_SFX_START + 515) + +#define SID_FORCERELOAD (SID_SFX_START + 1502) +#define SID_FILE_DIALOG (SID_SFX_START + 304) +#define SID_REMOTE_DIALOG (SID_SFX_START + 305) +#define SID_PATH (SID_SFX_START + 308) +#define SID_SAVEDOCS (SID_SFX_START + 309) +#define SID_STANDARD_DIR (SID_SFX_START + 450) +#define SID_BLACK_LIST (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 (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 (SID_SFX_START + 1319) + +#define SID_FILTER_DATA (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<SvxZoomItem>(SID_SVX_START + 0) + +#define SID_EXPLORER_PROPS_START (SID_SFX_START + 1410) +// SID_EXPLORER_PROPS_END (SID_SFX_START + 1499) + +#define SID_AUTOLOAD (SID_SFX_START + 1509) +#define SID_FILLFRAME (SID_SFX_START + 1516) +#define SID_BASEURL (SID_SFX_START + 1518) +#define SID_TEMPLATE (SID_SFX_START + 1519) + +#define SID_CONTENTTYPE (SID_SFX_START + 1541) + +#define SID_SAVETO TypedWhichId<SfxBoolItem>(SID_SFX_START + 1546) + +#define SID_VERSION (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 (SID_SFX_START + 1633) +#define SID_OVERWRITE (SID_SFX_START + 1634) + // FREE (was: SID_CRASH) +#define SID_FAIL_ON_WARNING (SID_SFX_START + 1646) +#define SID_INPUTSTREAM (SID_SFX_START + 1648) +#define SID_LOGOUT (SID_SFX_START + 1652) +#define SID_JUMPMARK (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 +#define SID_MACRO_WARNING (SID_SFX_START + 1664) +#define SID_MACRO_CONFIRMATION (SID_SFX_START + 1665) +#define SID_OUTPUTSTREAM (SID_SFX_START + 1666) +#define SID_IMAGE_ORIENTATION (SID_SFX_START + 1667) + +#define SID_STOP_RECORDING (SID_SFX_START + 1671) +#define SID_INTERACTIONHANDLER (SID_SFX_START + 1675) +#define SID_OPENHYPERLINK (SID_SFX_START + 1676) +#define SID_CONTENT (SID_SFX_START + 1679) +#define SID_VIEWONLY (SID_SFX_START + 1682) +#define SID_REPAIRPACKAGE (SID_SFX_START + 1683) +#define SID_MINIMIZED (SID_SFX_START + 1687) +#define SID_COMPONENTDATA (SID_SFX_START + 1688) +#define SID_COMPONENTCONTEXT (SID_SFX_START + 1689) +#define SID_SCRIPTORGANIZER (SID_SFX_START + 1690) +#define SID_MACROORGANIZER (SID_SFX_START + 1691) +#define SID_RUNMACRO (SID_SFX_START + 1692) +#define SID_AVMEDIA_TOOLBOX (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 (SID_SFX_START + 1699) +#define SID_DOC_BASEURL (SID_SFX_START + 1700) +#define SID_DOC_HIERARCHICALNAME (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 (SID_SFX_START + 1705) +#define SID_COPY_STREAM_IF_POSSIBLE (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 (SID_SFX_START + 1710) +#define SID_NOAUTOSAVE (SID_SFX_START + 1711) +#define SID_PRINT_SELECTEDSHEET (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 (SID_SFX_START + 1718) +#define SID_RECOMMENDREADONLY (SID_SFX_START + 1719) +#define SID_SUGGESTEDSAVEASDIR (SID_SFX_START + 1720) +#define SID_SUGGESTEDSAVEASNAME (SID_SFX_START + 1721) +#define SID_ENCRYPTIONDATA (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 (SID_SFX_START + 1731) +#define SID_LOCK_EXPORT (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<SfxBoolItem>(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 (SID_SFX_START + 1735) +#define SID_LOCK_PRINT (SID_SFX_START + 1736) +#define SID_LOCK_SAVE (SID_SFX_START + 1737) +#define SID_LOCK_EDITDOC (SID_SFX_START + 1738) +#define SID_REPLACEABLE (SID_SFX_START + 1739) + +// SID_SFX_free_END (SID_SFX_START + 3999) + +#define SID_OPEN_NEW_VIEW (SID_SFX_START + 520) + // FREE, was SID_VIEW_ZOOM_MODE + // FREE, was SID_VIEW_POS_SIZE +#define SID_VIEW_ID (SID_SFX_START + 523) + // FREE, was SID_USER_DATA +#define SID_VIEW_DATA (SID_SFX_START + 1582) +#define SID_SILENT (SID_SFX_START + 528) +#define SID_HIDDEN (SID_SFX_START + 534) +#define SID_PREVIEW TypedWhichId<SfxBoolItem>(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 (SID_SFX_START + 530) +#define SID_DOC_SALVAGE (SID_SFX_START + 531) +#define SID_INSERTDOC (SID_SFX_START + 532) +#define SID_TYPE_NAME (SID_SFX_START + 533) + +#define SID_DOC_READONLY (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<SfxDocumentInfoItem>(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 (SID_SFX_START + 560) +#define SID_POSTDATA (SID_SFX_START + 1536) +#define SID_DONELINK (SID_SFX_START + 646) +#define SID_REFERER (SID_SFX_START + 654) +#define SID_MODIFIER (SID_SFX_START + 669) +#define SID_SETOPTIONS (SID_SFX_START + 670) +#define SID_SOURCEVIEW (SID_SFX_START + 675) +#define SID_DOC_STARTPRESENTATION TypedWhichId<SfxBoolItem>(SID_SFX_START + 695) +#define SID_DDE_RECONNECT_ONLOAD (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 (SID_SFX_START + 539) + +#define SID_TEMPLATE_ADDRESSBOKSOURCE (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<SfxUInt16Item>(SID_SFX_START + 553) +#define SID_STYLE_FAMILYNAME TypedWhichId<SfxStringItem>(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 (SID_SFX_START + 1585) +#define SID_STYLE_REFERENCE TypedWhichId<SfxStringItem>(SID_SFX_START + 1602) + +#define SID_TEMPLATE_NAME (SID_SFX_START + 660) +#define SID_TEMPLATE_REGIONNAME (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 (SID_SFX_START + 676) +#define SID_WATERMARK_FONT (SID_SFX_START + 677) +#define SID_WATERMARK_TRANSPARENCY (SID_SFX_START + 805) +#define SID_WATERMARK_COLOR (SID_SFX_START + 806) +#define SID_WATERMARK_ANGLE (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<SfxStringItem>(SID_SFX_START + 583) + +#define SID_DOCUMENT (SID_SFX_START + 588) + +// default-ids for windows + +// free (SID_SFX_START + 610) +#define SID_NEWWINDOW (SID_SFX_START + 620) +#define SID_CLOSEWIN (SID_SFX_START + 621) +#define SID_VIEWSHELL (SID_SFX_START + 623) +#define SID_WIN_FULLSCREEN (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) + +// 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<SfxBoolItem>(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 (SID_SFX_START + 1669) +#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) + +// Used for redaction +#define SID_SHAPE_NAME (SID_SFX_START + 808) + // FREE: 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 (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 +#define SID_ATTR_MACROITEM TypedWhichId<SvxMacroItem>(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_BASIC_ENABLED (SID_SFX_START + 964) +#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<SfxRectangleItem>(SID_SFX_START + 1000) + +#define SID_EVENTCONFIG (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 (SID_OPTIONS_START + 0) +#define SID_ATTR_BACKUP (SID_OPTIONS_START + 1) +#define SID_ATTR_AUTOSAVE (SID_OPTIONS_START + 2) +#define SID_ATTR_AUTOSAVEPROMPT (SID_OPTIONS_START + 3) +#define SID_ATTR_USERAUTOSAVE (SID_OPTIONS_START + 4) +#define SID_ATTR_AUTOSAVEMINUTE (SID_OPTIONS_START + 5) +#define SID_ATTR_WORKINGSET (SID_OPTIONS_START + 13) +#define SID_ATTR_UNDO_COUNT (SID_OPTIONS_START + 16) + // unused +#define SID_ATTR_SAVEDOCVIEW (SID_OPTIONS_START + 18) + +// GeneralTabPage + +#define SID_ATTR_METRIC TypedWhichId<SfxUInt16Item>(SID_OPTIONS_START + 8) +#define SID_ATTR_DEFTABSTOP (SID_OPTIONS_START + 14) +#define SID_ATTR_BUTTON_OUTSTYLE3D (SID_OPTIONS_START + 62) +#define SID_ATTR_BUTTON_BIGSIZE (SID_OPTIONS_START + 63) +#define SID_ATTR_QUICKLAUNCHER (SID_OPTIONS_START + 74) +#define SID_ATTR_YEAR2000 (SID_OPTIONS_START + 87) +#define SID_ATTR_APPLYCHARUNIT (SID_OPTIONS_START + 88) + +// PathTabPage +#define SID_ATTR_PATHNAME (SID_OPTIONS_START + 11) + +// LinguTabPage +#define SID_ATTR_LANGUAGE (SID_OPTIONS_START + 7) +#define SID_ATTR_HYPHENREGION (SID_OPTIONS_START + 12) +#define SID_AUTOSPELL_CHECK (SID_OPTIONS_START + 21) + +// InetTabPage + +#define SID_INET_PROXY_TYPE (SID_OPTIONS_START + 23) + +#define SID_PASSWORD (SID_OPTIONS_START + 36) + +#define SID_INET_NOPROXY (SID_OPTIONS_START + 37) + +#define SID_INET_HTTP_PROXY_NAME (SID_OPTIONS_START + 38) +#define SID_INET_HTTP_PROXY_PORT (SID_OPTIONS_START + 39) +#define SID_INET_FTP_PROXY_NAME (SID_OPTIONS_START + 40) +#define SID_INET_FTP_PROXY_PORT (SID_OPTIONS_START + 41) + +#define SID_INET_EXE_PLUGIN (SID_OPTIONS_START + 52) + +#define SID_SAVEREL_INET (SID_OPTIONS_START + 30) +#define SID_SAVEREL_FSYS (SID_OPTIONS_START + 31) + +// Automatic update of Styles - manage TabPage +#define SID_ATTR_AUTO_STYLE_UPDATE (SID_OPTIONS_START + 65) + +#define SID_SECURE_URL (SID_OPTIONS_START + 66) + +// configured locale changed +#define SID_OPT_LOCALE_CHANGED (SID_OPTIONS_START + 94) +//middle mouse button +#define SID_ATTR_PRETTYPRINTING (SID_OPTIONS_START + 98) +#define SID_HELP_STYLESHEET (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<SvxSearchItem>(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 (SID_SVX_START + 361) +#define SID_HYPERLINK_SETLINK TypedWhichId<SvxHyperlinkItem>(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 (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 (SID_SVX_START + 1062) +#define SID_RULER_MARGIN1 (SID_SVX_START + 1063) +#define SID_RULER_MARGIN2 (SID_SVX_START + 1064) +#define SID_TABLE_BORDER_TYPE (SID_SVX_START + 1065) +#define SID_TABLE_BORDER_INDEX (SID_SVX_START + 1066) +#define SID_TABLE_BORDER_OFFSET (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<SfxUInt16Item>( SID_BASICIDE_START + 30 ) +#define SID_BASICIDE_ARG_SBX TypedWhichId<SbxItem>( SID_BASICIDE_START + 31 ) +#define SID_BASICIDE_ARG_MACROINFO TypedWhichId<SfxMacroInfoItem>( SID_BASICIDE_START + 32 ) +#define SID_BASICIDE_ARG_LIBNAME TypedWhichId<SfxStringItem>( SID_BASICIDE_START + 34 ) +#define SID_BASICIDE_ARG_MODULENAME TypedWhichId<SfxStringItem>( 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<SfxUnoAnyItem>( 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<SfxUnoAnyItem>( 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<SfxBoolItem>(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 (FN_EDIT2 + 23) +#define FN_REDLINE_ON (FN_EDIT2 + 25) + +#define SID_HTML_MODE (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 (EDIT_MENU_START + 18) +#define SID_CHG_PROTECT (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..1361f2f16 --- /dev/null +++ b/include/sfx2/sfxstatuslistener.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_SFXSTATUSLISTENER_HXX +#define INCLUDED_SFX2_SFXSTATUSLISTENER_HXX + +#include <config_options.h> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <svl/poolitem.hxx> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> + +#include <cppuhelper/implbase.hxx> + +namespace com::sun::star::frame { class XDispatch; } +namespace com::sun::star::frame { class XDispatchProvider; } +namespace com::sun::star::frame { struct FeatureStateEvent; } + +class UNLESS_MERGELIBS(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 StateChanged( 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 <sal/config.h> +#include <sfx2/dllapi.h> + +namespace com::sun::star::beans { struct NamedValue; } +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::uno { template <class E> 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..36374f384 --- /dev/null +++ b/include/sfx2/shell.hxx @@ -0,0 +1,591 @@ +/* -*- 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 <memory> +#include <rtl/ustring.hxx> +#include <sal/config.h> +#include <sal/types.h> +#include <svl/typedwhich.hxx> +#include <sfx2/dllapi.h> +#include <svl/SfxBroadcaster.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <o3tl/strong_int.hxx> + +namespace com::sun::star::embed { struct VerbDescriptor; } +namespace com::sun::star::uno { template <class E> 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 <SfxInterface>s, gives a quasi-static access to the interface + through an array to <SfxApplication>. +*/ +typedef o3tl::strong_int<sal_uInt16, struct SfxInterfaceIdTag> 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, + FormShowProperies = 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<SfxShellFeature> : is_typed_flags<SfxShellFeature, 0x37fd> {}; +} + +/* 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<SfxDisableFlags> : is_typed_flags<SfxDisableFlags, 0x0003> {}; +} + +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 <Slot>s. + + Each instance has a reference to an interface description, which is + obtainable through <SfxShell::GetInterface()const>. 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 <Type-Library>, which is generated from an IDL-file by + the <SVIDL-Compiler>. 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 <SFX_DECL_INTERFACE>, one can access + each of the <SfxInterface> 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; + + void CallExec( SfxExecFunc pFunc, SfxRequest &rReq ) + { (*pFunc)(this, rReq); } + void CallState( SfxStateFunc pFunc, SfxItemSet &rSet ) + { (*pFunc)(this, rSet); } + + 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 <SfxShell> 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] + + <SfxShell::ExecuteSlot(SfxRequest&)> + */ + const SfxPoolItem* GetSlotState( sal_uInt16 nSlotId, const SfxInterface *pIF = nullptr, SfxItemSet *pStateSet = nullptr ); + + /** + This method allows you to forward a <SfxRequest> to the specified + base <SfxShell>. + + [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] + + <SfxShell::GetSlotState(sal_uInt16,const SfxInterface*,SfxItemSet*)> + */ + 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 <SfxUndoManager>. This can be set in + the derived class with <SfxShell:SetUndoManager()>. + + The class SfxShell itself does not have a SfxUndoManager, a NULL-pointer + is therefore returned. + */ + virtual SfxUndoManager* GetUndoManager(); + + /** + Sets a <SfxUndoManager> for this <SfxShell> Instance. For the undo + is only the undo-manager used for SfxShell at the top of the stack of each + <SfxDispatcher>. + + On the given <SfxUndoManager> 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 <SfxRepeatTarget> instance that is used in + SID_REPEAT as repeat target when it is addressed from the <SfxUndoManager> + supplied by this SfxShell. The return value can be NULL. + + [Note] + + A derivation of <SfxShell> or one of its subclasses of <SfxRepeatTarget> + is not recommended, as compiler errors are provoked. + (due to Call-to-Pointer-to-Member-Function to the subclass). + */ + SfxRepeatTarget* GetRepeatTarget() const; + + /** + Sets the <SfxRepeatTarget> instance that is used in SID_REPEAT as + RepeatTarget, when the current supplied by this <SfxUndoManager> 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 <SfxShell> or one of its subclasses of <SfxRepeatTarget> + 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] + + <SfxBindings::Invalidate(sal_uInt16)> + <SfxBindings::InvalidateAll(sal_Bool)> + */ + 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 <SfxDispatcher>, when the SfxShell + is currently <UI-active> 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 <SfxViewFrame> to which this SfxShell + instance is associated or in which they currently is <UI-active>. + 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] + + <SfxViewShell::GetViewFrame()const> + */ + SfxViewFrame* GetFrame() const; + + virtual bool HasUIFeature(SfxShellFeature nFeature) const; + void UIFeatureChanged(); + + // Items + /** + With this method any objects of <SfxPoolItemu> subclasses can be accessed. + This exchange method is needed if, for example special <SfxToolBoxControl> + subclasses need access to certain data such as the <SfxObjectShell>. + + The returned instance belongs to the particular SfxShell and may be + used only in the immediate context of the method call. + + [Cross-reference] + + <SfxShell::PutItem(const SfxPoolItem&)> + <SfxShell::RemoveItem(sal_uInt16)> + */ + const SfxPoolItem* GetItem( sal_uInt16 nSlotId ) const; + template<class T> const T* GetItem( TypedWhichId<T> nWhich ) const + { + return static_cast<const T*>(GetItem(sal_uInt16(nWhich))); + } + + /** + With this method, any objects of subclasses of <SfxPoolItem> can be made + available. This exchange technology is needed if, for example, special + <SfxToolBoxControl> Subclasses need access to certain data such as the + <SfxObjectShell> + + If a SfxPoolItem exists with the same slot ID, it is deleted automatically. + + [Cross-reference] + + <SfxShell::RemoveItem(sal_uInt16)> + <SfxShell::GetItem(sal_uInt16)> + */ + 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::unique_ptr<SfxItemSet> 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 <TRUE/> then broadcast the context name that was + defined with an earlier call to SetContextName(). + When <FALSE/> 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 <SfxShell::Activate(sal_Bool)> 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 <SfxShell::Deactivate(sal_Bool)>. + */ + 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 <SfxViewShell>). 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 <SfxItemPool> + 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* pInterface; \ + static SfxInterface* GetStaticInterface(); \ + static SfxInterfaceId GetInterfaceId() {return nId;} \ + static void RegisterInterface(SfxModule* pMod=nullptr); \ + virtual SfxInterface* GetInterface() const override; + +#define SFX_TMPL_INTERFACE(Class,SuperClass,Abstract) \ + \ + SfxInterface* Class::pInterface = nullptr; \ + SfxInterface* Class::GetStaticInterface() \ + { \ + if ( !pInterface ) \ + { \ + 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 pInterface; \ + } \ + \ + SfxInterface* Class::GetInterface() const \ + { \ + return GetStaticInterface(); \ + } \ + \ + void Class::RegisterInterface(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<SfxVisibilityFlags> : is_typed_flags<SfxVisibilityFlags, 0xf440> {}; +} +#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..675e53b58 --- /dev/null +++ b/include/sfx2/sidebar/AsynchronousCall.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_SOURCE_SIDEBAR_ASYNCHRONOUSCALL_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_ASYNCHRONOUSCALL_HXX + +#include <tools/link.hxx> + +#include <functional> + +struct ImplSVEvent; + +namespace sfx2::sidebar { + +/** A simple asynchronous call via Application::PostUserCall. +*/ +class AsynchronousCall +{ +public: + typedef ::std::function<void()> 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 + +#endif + +/* 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..b69838a8f --- /dev/null +++ b/include/sfx2/sidebar/Context.hxx @@ -0,0 +1,61 @@ +/* -*- 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_SOURCE_SIDEBAR_CONTEXT_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_CONTEXT_HXX + +#include <rtl/ustring.hxx> + +namespace sfx2::sidebar { + +class 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 + +#endif + +/* 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..ef75d0dc9 --- /dev/null +++ b/include/sfx2/sidebar/ControllerItem.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_SIDEBAR_CONTROLLERITEM_HXX +#define INCLUDED_SFX2_SIDEBAR_CONTROLLERITEM_HXX + +#include <sfx2/ctrlitem.hxx> + +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 StateChanged (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 + +#endif + +/* 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..21e7dfad5 --- /dev/null +++ b/include/sfx2/sidebar/Deck.hxx @@ -0,0 +1,111 @@ +/* -*- 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_SOURCE_SIDEBAR_DECK_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_DECK_HXX + +#include <sfx2/sidebar/Panel.hxx> + +#include <vcl/window.hxx> + +class ScrollBar; + +namespace sfx2::sidebar { + +class DeckDescriptor; +class DeckTitleBar; + +/** 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 vcl::Window +{ +public: + Deck(const DeckDescriptor& rDeckDescriptor, + vcl::Window* pParentWindow, + const std::function<void()>& rCloserAction); + virtual ~Deck() override; + virtual void dispose() override; + + const OUString& GetId() const { return msId; } + + VclPtr<DeckTitleBar> const & GetTitleBar() const; + tools::Rectangle GetContentArea() const; + void ResetPanels (const SharedPanelContainer& rPanels); + const SharedPanelContainer& GetPanels() const { return maPanels; } + + Panel* GetPanel(OUString const & panelId); + + void RequestLayout(); + vcl::Window* 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 ApplySettings(vcl::RenderContext& rRenderContext) override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rUpdateArea) override; + virtual void DataChanged (const DataChangedEvent& rEvent) override; + virtual bool EventNotify(NotifyEvent& rEvent) override; + virtual void Resize() override; + + virtual boost::property_tree::ptree DumpAsPropertyTree() override; + + static void PrintWindowSubTree (vcl::Window* pRoot, int nIndentation); + + sal_Int32 GetMinimalWidth() const { return mnMinimalWidth; } + + class ScrollContainerWindow final : public vcl::Window + { + public: + ScrollContainerWindow(vcl::Window* pParentWindow); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rUpdateArea) override; + void SetSeparators(const ::std::vector<sal_Int32>& rSeparators); + private: + std::vector<sal_Int32> maSeparators; + }; + +private: + void RequestLayoutInternal(); + +private: + const OUString msId; + sal_Int32 mnMinimalWidth; + sal_Int32 mnMinimalHeight; + SharedPanelContainer maPanels; + VclPtr<DeckTitleBar> mpTitleBar; + VclPtr<vcl::Window> mpScrollClipWindow; + VclPtr<ScrollContainerWindow> mpScrollContainer; + VclPtr<vcl::Window> mpFiller; + VclPtr<ScrollBar> mpVerticalScrollBar; + + DECL_LINK(HandleVerticalScrollBarChange, ScrollBar*, void); + bool ProcessWheelEvent(CommandEvent const * pCommandEvent); + +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* 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..afd32d017 --- /dev/null +++ b/include/sfx2/sidebar/FocusManager.hxx @@ -0,0 +1,149 @@ +/* -*- 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_SOURCE_SIDEBAR_FOCUSMANAGER_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_FOCUSMANAGER_HXX + +#include <sfx2/sidebar/Panel.hxx> +#include <tools/link.hxx> +#include <vcl/keycod.hxx> + +class Button; + +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<void(const Panel&)>& rShowPanelFunctor, + const std::function<bool(const sal_Int32)> &rIsDeckOpenFunctor); + ~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 SetDeckTitle(DeckTitleBar* pDeckTitleBar); + void SetPanels(const SharedPanelContainer& rPanels); + void SetButtons(const ::std::vector<Button*>& rButtons); + +private: + VclPtr<DeckTitleBar> mpDeckTitleBar; + std::vector<VclPtr<Panel> > maPanels; + std::vector<VclPtr<Button> > maButtons; + const std::function<void(const Panel&)> maShowPanelFunctor; + const std::function<bool(const sal_Int32)> mbIsDeckOpenFunctor; + + enum PanelComponent + { + PC_DeckTitle, + 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( WindowEventListener, VclWindowEvent&, void); + DECL_LINK(ChildEventListener, VclWindowEvent&, void); + + void ClearPanels(); + void ClearButtons(); + + /** Let the focus manager listen for window events for the given + window. + */ + void RegisterWindow(vcl::Window& rWindow); + void UnregisterWindow(vcl::Window& rWindow); + + /** Remove the window from the panel or the button container. + */ + void RemoveWindow(vcl::Window& rWindow); + + 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 ClickButton(const sal_Int32 nButtonIndex); + void MoveFocusInsidePanel(const FocusLocation& rLocation, + const sal_Int32 nDirection); + void MoveFocusInsideDeckTitle(const FocusLocation& rLocation, + const sal_Int32 nDirection); + + void HandleKeyEvent(const vcl::KeyCode& rKeyCode, + const vcl::Window& rWindow); + + FocusLocation GetFocusLocation(const vcl::Window& rWindow) const; + +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* 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..c3138c3f3 --- /dev/null +++ b/include/sfx2/sidebar/IContextChangeReceiver.hxx @@ -0,0 +1,42 @@ +/* -*- 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_SIDEBAR_ICONTEXTCHANGERECEIVER_HXX +#define INCLUDED_SFX2_SIDEBAR_ICONTEXTCHANGERECEIVER_HXX + +#include <sfx2/dllapi.h> + +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 + +#endif + +/* 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..cb78ec5ad --- /dev/null +++ b/include/sfx2/sidebar/ILayoutableWindow.hxx @@ -0,0 +1,45 @@ +/* -*- 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_SIDEBAR_ILAYOUTABLEWINDOW_HXX +#define INCLUDED_SFX2_SIDEBAR_ILAYOUTABLEWINDOW_HXX + +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <com/sun/star/ui/LayoutSize.hpp> + +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 + +#endif + +/* 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..cae82bbc1 --- /dev/null +++ b/include/sfx2/sidebar/Panel.hxx @@ -0,0 +1,94 @@ +/* -*- 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_SOURCE_SIDEBAR_PANEL_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_PANEL_HXX + +#include <sfx2/dllapi.h> + +#include <vcl/window.hxx> + +#include <vector> + +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 PanelDescriptor; +class PanelTitleBar; +class Context; + +/** + * Multiple panels form a single deck. + * E.g. the Properties deck has panels like Styles, Character, paragraph. + */ +class SFX2_DLLPUBLIC Panel final : public vcl::Window +{ +public: + Panel(const PanelDescriptor& rPanelDescriptor, vcl::Window* pParentWindow, + const bool bIsInitiallyExpanded, const std::function<void()>& rDeckLayoutTrigger, + const std::function<Context()>& rContextAccess, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + + virtual ~Panel() override; + virtual void dispose() override; + + VclPtr<PanelTitleBar> const & GetTitleBar() const; + bool IsTitleBarOptional() const { return mbIsTitleBarOptional;} + void SetUIElement (const css::uno::Reference<css::ui::XUIElement>& rxElement); + const css::uno::Reference<css::ui::XSidebarPanel>& GetPanelComponent() const { return mxPanelComponent;} + css::uno::Reference<css::awt::XWindow> GetElementWindow(); + void SetExpanded (const bool bIsExpanded); + bool IsExpanded() const { return mbIsExpanded;} + bool HasIdPredicate (const OUString& rsId) const; + const OUString& GetId() const { return msPanelId;} + void TriggerDeckLayouting() { maDeckLayoutTrigger(); } + + /// Set whether a panel should be present but invisible / inactive + void SetLurkMode(bool bLurk); + bool IsLurking() const { return mbLurking; } + + virtual void Resize() override; + virtual void DataChanged (const DataChangedEvent& rEvent) override; + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + virtual boost::property_tree::ptree DumpAsPropertyTree() override; + +private: + const OUString msPanelId; + VclPtr<PanelTitleBar> mpTitleBar; + const bool mbIsTitleBarOptional; + css::uno::Reference<css::ui::XUIElement> mxElement; + css::uno::Reference<css::ui::XSidebarPanel> mxPanelComponent; + bool mbIsExpanded; + bool mbLurking; + const std::function<void()> maDeckLayoutTrigger; + const std::function<Context()> maContextAccess; + + const css::uno::Reference<css::frame::XFrame>& mxFrame; + +}; +typedef std::vector<VclPtr<Panel> > SharedPanelContainer; + +} // end of namespace sfx2::sidebar + +#endif + +/* 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..c3a22d868 --- /dev/null +++ b/include/sfx2/sidebar/PanelLayout.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/. + */ + +#pragma once + +#include <sfx2/dllapi.h> + +#include <vcl/ctrl.hxx> +#include <vcl/timer.hxx> +#include <vcl/idle.hxx> +#include <vcl/weld.hxx> + +#include <com/sun/star/frame/XFrame.hpp> + +/// This class is the base for the Widget Layout-based sidebar panels. +class SFX2_DLLPUBLIC PanelLayout : public Control +{ +protected: + std::unique_ptr<weld::Builder> m_xBuilder; + VclPtr<vcl::Window> m_xVclContentArea; + std::unique_ptr<weld::Container> m_xContainer; + +private: + Idle m_aPanelLayoutIdle; + bool m_bInClose; + css::uno::Reference<css::frame::XFrame> mxFrame; + + DECL_DLLPRIVATE_LINK(ImplHandlePanelLayoutTimerHdl, Timer*, void); + +public: + PanelLayout(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription, + const css::uno::Reference<css::frame::XFrame> &rFrame); + virtual ~PanelLayout() override; + virtual void dispose() override; + + virtual Size GetOptimalSize() const override; + virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All) override; + virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override; + virtual bool EventNotify(NotifyEvent& rNEvt) override; +}; + +/* 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..97987ea1a --- /dev/null +++ b/include/sfx2/sidebar/ResourceManager.hxx @@ -0,0 +1,135 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_RESOURCEMANAGER_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_RESOURCEMANAGER_HXX + +#include <unotools/confignode.hxx> +#include <map> +#include <set> +#include <svtools/miscopt.hxx> + +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 ResourceManager +{ +public: + + ResourceManager(); + ~ResourceManager(); + + std::shared_ptr<DeckDescriptor> GetDeckDescriptor(const OUString& rsDeckId) const; + std::shared_ptr<PanelDescriptor> GetPanelDescriptor(const OUString& rsPanelId) const; + + void UpdateModel(const css::uno::Reference<css::frame::XModel>& 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<DeckContextDescriptor> DeckContextDescriptorContainer; + + class PanelContextDescriptor + { + public: + OUString msId; + OUString msMenuCommand; + bool mbIsInitiallyVisible; + bool mbShowForReadOnlyDocuments; + }; + typedef std::vector<PanelContextDescriptor> PanelContextDescriptorContainer; + + const DeckContextDescriptorContainer& GetMatchingDecks( + DeckContextDescriptorContainer& rDeckDescriptors, + const Context& rContext, + const bool bIsDocumentReadOnly, + const css::uno::Reference<css::frame::XController>& rxController); + + const PanelContextDescriptorContainer& GetMatchingPanels( + PanelContextDescriptorContainer& rPanelDescriptors, + const Context& rContext, + const OUString& rsDeckId, + const css::uno::Reference<css::frame::XController>& 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(const OUString& rsPanelId, + const bool bExpansionState, + const Context& rContext); + +private: + + + typedef std::vector<std::shared_ptr<DeckDescriptor>> DeckContainer; + DeckContainer maDecks; + + typedef std::vector<std::shared_ptr<PanelDescriptor>> PanelContainer; + PanelContainer maPanels; + mutable std::set<OUString> maProcessedApplications; + std::map<OUString, OUString> maLastActiveDecks; + + SvtMiscOptions maMiscOptions; + + void ReadDeckList(); + void ReadPanelList(); + void ReadLastActive(); + static void ReadContextList(const utl::OConfigurationNode& rNode, + ContextList& rContextList, + const OUString& rsDefaultMenuCommand); + + void ReadLegacyAddons(const css::uno::Reference<css::frame::XController>& rxController); + static utl::OConfigurationTreeRoot GetLegacyAddonRootNode(const OUString& rsModuleName); + static void GetToolPanelNodeNames(std::vector<OUString>& rMatchingNames, + const utl::OConfigurationTreeRoot& aRoot); + bool IsDeckEnabled(const OUString& rsDeckId, + const Context& rContext, + const css::uno::Reference<css::frame::XController>& rxController); + + std::shared_ptr<DeckDescriptor> ImplGetDeckDescriptor(const OUString& rsDeckId) const; + std::shared_ptr<PanelDescriptor> ImplGetPanelDescriptor(const OUString& rsPanelId) const; +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* 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..2ac3b0e6a --- /dev/null +++ b/include/sfx2/sidebar/Sidebar.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_SIDEBAR_SIDEBAR_HXX +#define INCLUDED_SFX2_SIDEBAR_SIDEBAR_HXX + +#include <sfx2/dllapi.h> +#include <rtl/ustring.hxx> + +namespace com::sun::star::frame { class XFrame; } +namespace com::sun::star::uno { template <typename > class Reference; } + + +namespace sfx2::sidebar { + +/** Accept requests for switching to certain panels or decks. +*/ +class SFX2_DLLPUBLIC Sidebar +{ +public: + /** 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 ( + const OUString& rsPanelId, + const css::uno::Reference<css::frame::XFrame>& 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 ( + const OUString& rsPanelId, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + + static bool IsPanelVisible( + const OUString& rsPanelId, + const css::uno::Reference<css::frame::XFrame>& rxFrame); +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* 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..6a9254df5 --- /dev/null +++ b/include/sfx2/sidebar/SidebarChildWindow.hxx @@ -0,0 +1,49 @@ +/* -*- 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_SIDEBAR_SIDEBARCHILDWINDOW_HXX +#define INCLUDED_SFX2_SIDEBAR_SIDEBARCHILDWINDOW_HXX + +#include <sfx2/childwin.hxx> + + +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 + +#endif + +/* 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..d03576b34 --- /dev/null +++ b/include/sfx2/sidebar/SidebarController.hxx @@ -0,0 +1,295 @@ +/* -*- 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_SOURCE_SIDEBAR_SIDEBARCONTROLLER_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARCONTROLLER_HXX + +#include <memory> +#include <sal/config.h> + +#include <sfx2/sidebar/AsynchronousCall.hxx> +#include <sfx2/sidebar/Context.hxx> +#include <sfx2/sidebar/Deck.hxx> +#include <sfx2/sidebar/FocusManager.hxx> +#include <sfx2/sidebar/ResourceManager.hxx> +#include <sfx2/sidebar/TabBar.hxx> +#include <sfx2/viewfrm.hxx> + +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/ui/XContextChangeEventListener.hpp> +#include <com/sun/star/ui/XSidebar.hpp> + +#include <optional> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> + +namespace com::sun::star::awt { class XWindowPeer; } +namespace com::sun::star::frame { class XDispatch; } +namespace com::sun::star::ui { class XUIElement; } + +typedef cppu::WeakComponentImplHelper < + css::ui::XContextChangeEventListener, + css::beans::XPropertyChangeListener, + css::ui::XSidebar, + css::frame::XStatusListener, + css::frame::XFrameActionListener + > SidebarControllerInterfaceBase; + +class SfxSplitWindow; + +namespace sfx2::sidebar { + +class DeckDescriptor; +class SidebarDockingWindow; + +class SFX2_DLLPUBLIC SidebarController + : private ::cppu::BaseMutex, + public SidebarControllerInterfaceBase +{ +public: + static rtl::Reference<SidebarController> 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 <NULL/> is returned. + */ + static SidebarController* GetSidebarControllerForFrame ( + const css::uno::Reference<css::frame::XFrame>& rxFrame); + + static void registerSidebarForFrame(SidebarController* pController, const css::uno::Reference<css::frame::XController>& xFrame); + + static void unregisterSidebarForFrame(SidebarController* pController, const css::uno::Reference<css::frame::XController>& 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(const OUString& 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(const OUString& rsDeckId); + + bool IsDeckOpen(const sal_Int32 nIndex = -1); + + FocusManager& GetFocusManager() { return maFocusManager;} + + ResourceManager* GetResourceManager() { return mpResourceManager.get();} + + // std::unique_ptr<ResourceManager> GetResourceManager() { return mpResourceManager;} + + const Context& GetCurrentContext() const { return maCurrentContext;} + bool IsDocumentReadOnly (void) const { return mbIsDocumentReadOnly;} + + void SwitchToDeck(const OUString& rsDeckId); + void SwitchToDefaultDeck(); + bool WasFloatingDeckClosed() const { return mbFloatingDeckClosed; } + void SetFloatingDeckClosed(bool bWasClosed) { mbFloatingDeckClosed = bWasClosed; } + + void CreateDeck(const OUString& rDeckId); + void CreateDeck(const OUString& rDeckId, const Context& rContext, bool bForceCreate = false); + + ResourceManager::DeckContextDescriptorContainer GetMatchingDecks(); + ResourceManager::PanelContextDescriptorContainer GetMatchingPanels(const OUString& rDeckId); + + void notifyDeckTitle(const OUString& targetDeckId); + + void updateModel(const css::uno::Reference<css::frame::XModel>& xModel); + + void disposeDecks(); + + void FadeIn(); + void FadeOut(); + + tools::Rectangle GetDeckDragArea() const; + + css::uno::Reference<css::frame::XFrame> const & getXFrame() const {return mxFrame;} + + sal_Int32 getMaximumWidth() const { return mnMaximumSidebarWidth; } + void setMaximumWidth(sal_Int32 nMaximumWidth) { mnMaximumSidebarWidth = nMaximumWidth; } + + void saveDeckState(); + + void SyncUpdate(); + +private: + SidebarController(SidebarDockingWindow* pParentWindow, const SfxViewFrame* pViewFrame); + + VclPtr<Deck> mpCurrentDeck; + VclPtr<SidebarDockingWindow> mpParentWindow; + const SfxViewFrame* mpViewFrame; + css::uno::Reference<css::frame::XFrame> mxFrame; + VclPtr<TabBar> mpTabBar; + Context maCurrentContext; + Context maRequestedContext; + css::uno::Reference<css::frame::XController> mxCurrentController; + /// Use a combination of SwitchFlag_* as value. + sal_Int32 mnRequestedForceFlags; + sal_Int32 mnMaximumSidebarWidth; + OUString msCurrentDeckId; + AsynchronousCall maPropertyChangeForwarder; + AsynchronousCall maContextChangeUpdate; + + /** 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<bool> mbIsDeckRequestedOpen; + ::std::optional<bool> 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<css::frame::XDispatch> mxReadOnlyModeDispatch; + bool mbIsDocumentReadOnly; + VclPtr<SfxSplitWindow> 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<vcl::Window> mpCloseIndicator; + + DECL_LINK(WindowEventHandler, VclWindowEvent&, void); + /** Make maRequestedContext the current context. + */ + void UpdateConfigurations(); + + css::uno::Reference<css::ui::XUIElement> CreateUIElement ( + const css::uno::Reference<css::awt::XWindowPeer>& rxWindow, + const OUString& rsImplementationURL, + const bool bWantsCanvas, + const Context& rContext); + + void CreatePanels( + const OUString& rDeckId, + const Context& rContext); + VclPtr<Panel> CreatePanel ( + const OUString& rsPanelId, + vcl::Window* pParentWindow, + const bool bIsInitiallyExpanded, + const Context& rContext, + const VclPtr<Deck>& pDeck); + + void SwitchToDeck ( + const DeckDescriptor& rDeckDescriptor, + const Context& rContext); + + void ShowPopupMenu ( + const tools::Rectangle& rButtonBox, + const ::std::vector<TabBar::DeckMenuData>& rMenuData) const; + VclPtr<PopupMenu> CreatePopupMenu ( + const ::std::vector<TabBar::DeckMenuData>& rMenuData) const; + DECL_LINK(OnMenuItemSelected, Menu*, bool); + 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 SAL_CALL disposing() override; + + std::unique_ptr<ResourceManager> mpResourceManager; + +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* 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..6d726ddd1 --- /dev/null +++ b/include/sfx2/sidebar/SidebarDockingWindow.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 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARDOCKINGWINDOW_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARDOCKINGWINDOW_HXX + +#include <sfx2/dockwin.hxx> + +#include <rtl/ref.hxx> + +class SfxViewShell; + +namespace svt { class AcceleratorExecute; } + +namespace sfx2::sidebar { + +class SidebarChildWindow; + +class SidebarController; + +class SidebarNotifyIdle; + +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(); + + void NotifyResize(); + + using SfxDockingWindow::Close; + +private: + // Window overridables + virtual void GetFocus() override; + virtual void Resize() override; + + virtual SfxChildAlignment CheckAlignment ( + SfxChildAlignment eCurrentAlignment, + SfxChildAlignment eRequestedAlignment) override; + + /// Notify LOKit that we closed and release the LOKNotifier. + void LOKClose(); + + ::rtl::Reference<sfx2::sidebar::SidebarController> mpSidebarController; + bool mbIsReadyToDrag; + std::unique_ptr<svt::AcceleratorExecute> mpAccel; + + std::unique_ptr<SidebarNotifyIdle> mpIdleNotify; +}; + +} // end of namespace sfx2::sidebar + + +#endif + +/* 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..0ecb988e5 --- /dev/null +++ b/include/sfx2/sidebar/SidebarModelUpdate.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/. + */ + +#ifndef INCLUDED_INCLUDE_SFX2_SIDEBAR_SIDEBARUPDATEMODEL_HXX +#define INCLUDED_INCLUDE_SFX2_SIDEBAR_SIDEBARUPDATEMODEL_HXX + +#include <sfx2/dllapi.h> + +namespace com::sun::star::frame { class XModel; } +namespace com::sun::star::uno { template <typename > class Reference; } + +namespace sfx2::sidebar { + +class SFX2_DLLPUBLIC SidebarModelUpdate +{ +public: + virtual ~SidebarModelUpdate(); + virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) = 0; +}; + +} + +#endif + +/* 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..84a3e4dfb --- /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 . + */ +#ifndef INCLUDED_SFX2_SIDEBAR_SIDEBARPANELBASE_HXX +#define INCLUDED_SFX2_SIDEBAR_SIDEBARPANELBASE_HXX + +#include <sfx2/dllapi.h> + +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> + +#include <com/sun/star/ui/XContextChangeEventListener.hpp> +#include <com/sun/star/ui/XUIElement.hpp> +#include <com/sun/star/ui/XToolPanel.hpp> +#include <com/sun/star/ui/XSidebarPanel.hpp> +#include <com/sun/star/ui/XUpdateModel.hpp> + +#include <vcl/vclptr.hxx> + + +namespace vcl { class Window; } + +namespace sfx2::sidebar { + +typedef cppu::WeakComponentImplHelper<css::ui::XContextChangeEventListener, + css::ui::XUIElement, + css::ui::XToolPanel, + css::ui::XSidebarPanel, + css::ui::XUpdateModel> + SidebarPanelBaseInterfaceBase; + +/** Base class for sidebar panels that provides some convenience + functionality. +*/ +class SFX2_DLLPUBLIC SidebarPanelBase final : private ::cppu::BaseMutex, + public SidebarPanelBaseInterfaceBase +{ +public: + static css::uno::Reference<css::ui::XUIElement> Create(const OUString& rsResourceURL, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + vcl::Window* pControl, + 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<css::frame::XFrame> SAL_CALL getFrame() override; + virtual OUString SAL_CALL getResourceURL() override; + virtual sal_Int16 SAL_CALL getType() override; + virtual css::uno::Reference<css::uno::XInterface> SAL_CALL getRealInterface() override; + + // XToolPanel + virtual css::uno::Reference<css::accessibility::XAccessible> SAL_CALL createAccessible( + const css::uno::Reference<css::accessibility::XAccessible>& rxParentAccessible) override; + virtual css::uno::Reference<css::awt::XWindow> 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<css::frame::XModel>& xModel) override; + +private: + SidebarPanelBase(const OUString& rsResourceURL, const css::uno::Reference<css::frame::XFrame>& rxFrame, + vcl::Window* pWindow, const css::ui::LayoutSize& rLayoutSize); + virtual ~SidebarPanelBase() override; + SidebarPanelBase(const SidebarPanelBase&) = delete; + SidebarPanelBase& operator=( const SidebarPanelBase& ) = delete; + + virtual void SAL_CALL disposing() override; + + css::uno::Reference<css::frame::XFrame> mxFrame; + VclPtr<vcl::Window> mpControl; + const OUString msResourceURL; + const css::ui::LayoutSize maLayoutSize; +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarToolBox.hxx b/include/sfx2/sidebar/SidebarToolBox.hxx new file mode 100644 index 000000000..bf0fbf60c --- /dev/null +++ b/include/sfx2/sidebar/SidebarToolBox.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_SIDEBAR_SIDEBARTOOLBOX_HXX +#define INCLUDED_SFX2_SIDEBAR_SIDEBARTOOLBOX_HXX + +#include <config_options.h> +#include <sfx2/dllapi.h> +#include <vcl/toolbox.hxx> +#include <map> + +namespace com::sun::star::frame { class XToolbarController; } + +namespace sfx2::sidebar { + +/** The sidebar tool box has two responsibilities: + 1. Coordinated location, size, and other states with its parent + background window. + 2. Create and handle tool bar controller for its items. +*/ +class UNLESS_MERGELIBS(SFX2_DLLPUBLIC) SidebarToolBox : public ToolBox +{ +public: + SidebarToolBox(vcl::Window* pParentWindow); + virtual ~SidebarToolBox() override; + virtual void dispose() override; + + virtual ToolBoxButtonSize GetDefaultButtonSize() const; + + using ToolBox::InsertItem; + virtual void InsertItem(const OUString& rCommand, + const css::uno::Reference<css::frame::XFrame>& rFrame, + ToolBoxItemBits nBits, + const Size& rRequestedSize, + ImplToolItems::size_type nPos = APPEND) override; + + virtual bool EventNotify(NotifyEvent& rEvent) override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + + void SetController(const sal_uInt16 nItemId, + const css::uno::Reference<css::frame::XToolbarController>& rxController); + + void InitToolBox(VclBuilder::stringmap& rMap); + +protected: + typedef std::map<sal_uInt16, css::uno::Reference<css::frame::XToolbarController>> ControllerContainer; + ControllerContainer maControllers; + bool mbAreHandlersRegistered; + bool mbUseDefaultButtonSize; + bool mbSideBar; + + DECL_LINK(DropDownClickHandler, ToolBox*, void); + DECL_LINK(ClickHandler, ToolBox*, void); + DECL_LINK(DoubleClickHandler, ToolBox*, void); + DECL_LINK(SelectHandler, ToolBox*, void); + DECL_LINK(ChangedIconSizeHandler, LinkParamNone*, void ); + + css::uno::Reference<css::frame::XToolbarController> GetControllerForItemId(const sal_uInt16 nItemId) const; + + void CreateController(const sal_uInt16 nItemId, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + const sal_Int32 nItemWidth, bool bSideBar); + void RegisterHandlers(); +}; + + +} // end of namespace sfx2::sidebar + +#endif + +/* 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..0d10efa82 --- /dev/null +++ b/include/sfx2/sidebar/TabBar.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_SOURCE_SIDEBAR_TABBAR_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_TABBAR_HXX + +#include <config_options.h> +#include <sfx2//dllapi.h> +#include <sfx2/sidebar/ResourceManager.hxx> + + +#include <vcl/menu.hxx> +#include <vcl/window.hxx> + +#include <functional> + +class Button; +class CheckBox; +class RadioButton; + +namespace svt { class AcceleratorExecute; } + +namespace sfx2::sidebar { + +class FocusManager; +class SidebarController; + +/** The tab bar is the container for the individual tabs. +*/ +class UNLESS_MERGELIBS(SFX2_DLLPUBLIC) TabBar final + : public vcl::Window +{ +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<void ( + const tools::Rectangle&, + const ::std::vector<DeckMenuData>& rMenuData)> PopupMenuProvider; + TabBar ( + vcl::Window* pParentWindow, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + const ::std::function<void (const OUString& rsDeckId)>& rDeckActivationFunctor, + const PopupMenuProvider& rPopupMenuProvider, + SidebarController* rParentSidebarController); + + virtual ~TabBar() override; + virtual void dispose() override; + + virtual void Paint (vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle& rUpdateArea) 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 (const OUString& 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<css::frame::XFrame> mxFrame; + VclPtr<CheckBox> mpMenuButton; + class Item + { + public: + DECL_LINK(HandleClick, Button*, void); + VclPtr<RadioButton> mpButton; + OUString msDeckId; + ::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor; + bool mbIsHidden; + bool mbIsHiddenByDefault; + }; + typedef ::std::vector<Item> ItemContainer; + ItemContainer maItems; + const ::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor; + sal_Int32 mnMenuSeparatorY; + PopupMenuProvider maPopupMenuProvider; + + VclPtr<RadioButton> CreateTabItem (const DeckDescriptor& rDeckDescriptor); + Image GetItemImage (const DeckDescriptor& rDeskDescriptor) const; + void Layout(); + void UpdateButtonIcons(); + + DECL_LINK(OnToolboxClicked, Button*, void); + + SidebarController* pParentSidebarController; + std::unique_ptr<svt::AcceleratorExecute> mpAccel; + +}; + + +} // end of namespace sfx2::sidebar + +#endif + +/* 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..a1500364d --- /dev/null +++ b/include/sfx2/sidebar/Theme.hxx @@ -0,0 +1,245 @@ +/* -*- 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_SIDEBAR_THEME_HXX +#define INCLUDED_SFX2_SIDEBAR_THEME_HXX + +#include <sfx2/dllapi.h> + +#include <tools/color.hxx> +#include <vcl/image.hxx> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include <tools/gen.hxx> +#include <vcl/wall.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> + +#include <map> +#include <unordered_map> + + +namespace sfx2::sidebar { + +typedef cppu::WeakComponentImplHelper < + css::beans::XPropertySet, + css::beans::XPropertySetInfo + > ThemeInterfaceBase; + +class Paint; + +/** Simple collection of colors, gradients, fonts that define the + look of the sidebar and its controls. +*/ +class SFX2_DLLPUBLIC Theme final + : private ::cppu::BaseMutex, + public ThemeInterfaceBase +{ +public: + enum ThemeItem + { + Begin_, + Pre_Image_ = Begin_, + + AnyItem_ = Pre_Image_, + + Image_Grip, + Image_Expand, + Image_Collapse, + Image_TabBarMenu, + Image_PanelMenu, + Image_Closer, + Image_CloseIndicator, + + Image_Color_, + + Color_DeckTitleFont, + Color_PanelTitleFont, + Color_TabMenuSeparator, + Color_TabItemBorder, + Color_DropDownBorder, + Color_Highlight, + Color_HighlightText, + + Color_Paint_, + + Paint_DeckBackground, + Paint_DeckTitleBarBackground, + Paint_PanelBackground, + Paint_PanelTitleBarBackground, + Paint_TabBarBackground, + Paint_TabItemBackgroundNormal, + Paint_TabItemBackgroundHighlight, + Paint_HorizontalBorder, + Paint_VerticalBorder, + Paint_ToolBoxBackground, + Paint_ToolBoxBorderTopLeft, + Paint_ToolBoxBorderCenterCorners, + Paint_ToolBoxBorderBottomRight, + Paint_DropDownBackground, + + Paint_Int_, + + Int_DeckTitleBarHeight, + Int_DeckBorderSize, + Int_DeckSeparatorHeight, + Int_PanelTitleBarHeight, + Int_TabMenuPadding, + Int_TabMenuSeparatorPadding, + Int_TabItemWidth, + Int_TabItemHeight, + Int_DeckLeftPadding, + Int_DeckTopPadding, + Int_DeckRightPadding, + Int_DeckBottomPadding, + Int_TabBarLeftPadding, + Int_TabBarTopPadding, + Int_TabBarRightPadding, + Int_TabBarBottomPadding, + Int_ButtonCornerRadius, + + Int_Bool_, + + Bool_UseSystemColors, + Bool_IsHighContrastModeActive, + + Bool_Rect_, + + Rect_ToolBoxPadding, + Rect_ToolBoxBorder, + + Post_Rect_, + End_=Post_Rect_ + }; + + static Image GetImage (const ThemeItem eItem); + static Color GetColor (const ThemeItem eItem); + static const Paint& GetPaint (const ThemeItem eItem); + static Wallpaper GetWallpaper (const ThemeItem eItem); + static sal_Int32 GetInteger (const ThemeItem eItem); + static bool GetBoolean (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 SAL_CALL disposing() override; + + static css::uno::Reference<css::beans::XPropertySet> GetPropertySet(); + + // beans::XPropertySet + virtual css::uno::Reference<css::beans::XPropertySetInfo> 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<css::beans::XPropertyChangeListener>& rxListener) override; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rsPropertyName, + const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener) override; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rsPropertyName, + const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener) override; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rsPropertyName, + const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener) override; + + // beans::XPropertySetInfo + virtual css::uno::Sequence<css::beans::Property> 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<Image> maImages; + std::vector<Color> maColors; + std::vector<Paint> maPaints; + std::vector<sal_Int32> maIntegers; + std::vector<bool> maBooleans; + std::vector<tools::Rectangle> maRectangles; + bool mbIsHighContrastMode; + bool mbIsHighContrastModeSetManually; + + typedef std::unordered_map<OUString,ThemeItem> PropertyNameToIdMap; + PropertyNameToIdMap maPropertyNameToIdMap; + typedef std::vector<OUString> PropertyIdToNameMap; + PropertyIdToNameMap maPropertyIdToNameMap; + typedef ::std::vector<css::uno::Any> RawValueContainer; + RawValueContainer maRawValues; + + typedef std::vector<css::uno::Reference<css::beans::XPropertyChangeListener> > ChangeListenerContainer; + typedef std::map<ThemeItem,ChangeListenerContainer> ChangeListeners; + ChangeListeners maChangeListeners; + typedef std::vector<css::uno::Reference<css::beans::XVetoableChangeListener> > VetoableListenerContainer; + typedef std::map<ThemeItem,VetoableListenerContainer> VetoableListeners; + VetoableListeners maVetoableListeners; + + enum PropertyType + { + PT_Image, + PT_Color, + PT_Paint, + PT_Integer, + PT_Boolean, + PT_Rectangle, + 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 + +#endif + +/* 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..e480e56b0 --- /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 <sfx2/dllapi.h> + +#include <com/sun/star/security/DocumentSignatureInformation.hpp> + +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<css::security::DocumentSignatureInformation>& 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..8929e2efb --- /dev/null +++ b/include/sfx2/stbitem.hxx @@ -0,0 +1,133 @@ +/* -*- 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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <svl/poolitem.hxx> +#include <svtools/statusbarcontroller.hxx> +#include <vcl/vclptr.hxx> + +class SfxModule; +class SfxStatusBarControl; +class StatusBar; + +svt::StatusbarController* SfxStatusBarControllerFactory( + const css::uno::Reference< css::frame::XFrame >& rFrame, + StatusBar* pStatusBar, + unsigned short nID, + const OUString& aCommandURL ); +typedef SfxStatusBarControl* (*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<StatusBar> pBar; + +protected: + // new controller API + // XInterface + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + + // 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 StateChanged( 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 SfxStatusBarControl* CreateControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar *pBar, SfxModule const * ); + static void RegisterStatusBarControl(SfxModule*, const SfxStbCtrlFactory&); + +}; + + +#define SFX_DECL_STATUSBAR_CONTROL() \ + static SfxStatusBarControl* 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) \ + SfxStatusBarControl* 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..d7c6635b7 --- /dev/null +++ b/include/sfx2/strings.hrc @@ -0,0 +1,352 @@ +/* -*- 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) reinterpret_cast<char const *>(Context "\004" 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 Default") +#define STR_RESET_DEFAULT NC_("STR_RESET_DEFAULT", "Reset Default") +#define STR_DELETE NC_("STR_DELETE", "Delete") +#define STR_SFX_RENAME NC_("STR_SFX_RENAME", "Rename") +#define STR_CATEGORY_RENAME NC_("STR_CATEGORY_RENAME", "Rename Category") +#define STR_RENAME_TEMPLATE NC_("STR_RENAME_TEMPLATE", "Enter New 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 style based formatting according to 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_ACTION_REFRESH NC_("STR_ACTION_REFRESH", "Refresh") +#define STR_CATEGORY_NEW NC_("STR_CATEGORY_NEW", "New Category") +#define STR_CATEGORY_DELETE NC_("STR_CATEGORY_DELETE", "Delete Category") +#define STR_CATEGORY_SELECT NC_("STR_CATEGORY_SELECT", "Select 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 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_QMSG_SEL_FOLDER_DELETE NC_("STR_QMSG_SEL_FOLDER_DELETE", "Do you want to delete the selected folders?") +#define STR_QMSG_TEMPLATE_OVERWRITE NC_("STR_QMSG_TEMPLATE_OVERWRITE", "A template named $1 already exist 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_NO_ABS_URI_REF NC_("STR_NO_ABS_URI_REF", "\"$(ARG1)\" is not an absolute URL that can be passed to an external application to open it.") +#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_GRAFIKLINK NC_("RID_SVXSTR_GRAFIKLINK", "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_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 pick an app from the left side 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: Column headers in Auto-redaction dialog's targets list +#define STR_REDACTION_TARGET_NAME NC_("STR_REDACTION_TARGET_NAME", "Target Name") +#define STR_REDACTION_TYPE NC_("STR_REDACTION_TYPE", "Type") +#define STR_REDACTION_CONTENT NC_("STR_REDACTION_CONTENT", "Content") +#define STR_REDACTION_CASE_SENSITIVE NC_("STR_REDACTION_CASE_SENSITIVE", "Case Sensitive") +#define STR_REDACTION_WHOLE_WORDS NC_("STR_REDACTION_WHOLE_WORDS", "Whole Words") + +// 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 LibreOffice 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", "<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_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_CLOSE_PANE NC_("STR_CLOSE_PANE", "Close Pane") +#define STR_SFX_DOCK NC_("STR_SFX_DOCK", "Dock") +#define STR_SFX_UNDOCK NC_("STR_SFX_UNDOCK", "Undock") + +#define SFX_STR_SIDEBAR_MORE_OPTIONS NC_("SFX_STR_SIDEBAR_MORE_OPTIONS", "More Options") +#define SFX_STR_SIDEBAR_CLOSE_DECK NC_("SFX_STR_SIDEBAR_CLOSE_DECK", "Close Sidebar Deck") +#define SFX_STR_SIDEBAR_SETTINGS NC_("SFX_STR_SIDEBAR_SETTINGS", "Sidebar Settings") +#define SFX_STR_SIDEBAR_CUSTOMIZATION NC_("SFX_STR_SIDEBAR_CUSTOMIZATION", "Customization") +#define SFX_STR_SIDEBAR_RESTORE NC_("SFX_STR_SIDEBAR_RESTORE", "Restore Default") +#define SFX_STR_SIDEBAR_HIDE_SIDEBAR NC_("SFX_STR_SIDEBAR_HIDE_SIDEBAR", "Close Sidebar") + +// Translators: default Impress template names +#define STR_TEMPLATE_NAME1 NC_("STR_TEMPLATE_NAME1", "Alizarin") +#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", "Bright Blue") +#define STR_TEMPLATE_NAME6 NC_("STR_TEMPLATE_NAME6", "Classy Red") +#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", "Impress") +#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", "Lush Green") +#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)") +#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..dc9393426 --- /dev/null +++ b/include/sfx2/styfitem.hxx @@ -0,0 +1,61 @@ +/* -*- 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 <rtl/ustring.hxx> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <svl/style.hxx> +#include <vector> + +struct SFX2_DLLPUBLIC SfxFilterTuple +{ + OUString aName; + SfxStyleSearchBits nFlags; + SfxFilterTuple(const OUString& rName, SfxStyleSearchBits nArg) + : aName(rName) + , nFlags(nArg) + { + } +}; + +typedef std::vector<SfxFilterTuple> 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<const char*, SfxStyleSearchBits>* 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<SfxStyleFamilyItem>; + +#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 <sal/config.h> +#include <sfx2/dllapi.h> +#include <sfx2/tabdlg.hxx> + +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..0d770572f --- /dev/null +++ b/include/sfx2/tabdlg.hxx @@ -0,0 +1,246 @@ +/* -*- 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 <memory> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sfx2/basedlgs.hxx> +#include <sal/types.h> +#include <vcl/bitmapex.hxx> +#include <vcl/builderpage.hxx> +#include <svl/itempool.hxx> +#include <svl/itemset.hxx> +#include <o3tl/typed_flags_set.hxx> + +class SfxTabPage; + +typedef std::unique_ptr<SfxTabPage> (*CreateTabPage)(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rAttrSet); +typedef const sal_uInt16* (*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<weld::Notebook> m_xTabCtrl; + + DECL_LINK(OkHdl, weld::Button&, void); + DECL_LINK(ResetHdl, weld::Button&, void); + DECL_LINK(BaseFmtHdl, weld::Button&, void); + DECL_LINK(UserHdl, weld::Button&, void); + DECL_LINK(CancelHdl, weld::Button&, void); +private: + std::unique_ptr<weld::Button> m_xOKBtn; + std::unique_ptr<weld::Button> m_xApplyBtn; + std::unique_ptr<weld::Button> m_xUserBtn; + std::unique_ptr<weld::Button> m_xCancelBtn; + std::unique_ptr<weld::Button> m_xResetBtn; + std::unique_ptr<weld::Button> m_xBaseFmtBtn; + std::unique_ptr<weld::SizeGroup> m_xSizeGroup; + + std::unique_ptr<SfxItemSet> m_pSet; + std::unique_ptr<SfxItemSet> m_pOutSet; + std::unique_ptr<TabDlg_Impl> m_pImpl; + std::unique_ptr<sal_uInt16[]> m_pRanges; + OString m_sAppPageId; + bool m_bStandardPushed; + + 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<SfxItemSet> m_xExampleSet; + SfxItemSet* GetInputSetImpl(); + SfxTabPage* GetTabPage(const OString& 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 sal_uInt16* 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(); } + void RemoveResetButton(); + void RemoveStandardButton(); + + virtual short run() override; + static bool runAsync(const std::shared_ptr<SfxTabDialogController>& rController, + const std::function<void(sal_Int32)>&); + + virtual const SfxItemSet* GetExampleSet() const override { return m_xExampleSet.get(); } + + void SetApplyHandler(const Link<weld::Button&,void>& _rHdl); + + //calls Ok without closing dialog + bool Apply(); + void Applied() { m_xExampleSet->Put(*GetInputSetImpl()); } + + //screenshotting + std::vector<OString> 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<DeactivateRC> : is_typed_flags<DeactivateRC, 0x03> {}; +} + +class SFX2_DLLPUBLIC SfxTabPage : public BuilderPage +{ +friend class SfxTabDialog; +friend class SfxTabDialogController; + +private: + const SfxItemSet* pSet; + OUString aUserString; + bool bHasExchangeSupport; + 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 ); } + const SfxPoolItem* GetOldItem( const SfxItemSet& rSet, sal_uInt16 nSlot, bool bDeep = true ); + template<class T> const T* GetOldItem( const SfxItemSet& rSet, TypedWhichId<T> nSlot, bool bDeep = true ) + { + return static_cast<const T*>(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* ); + + 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<class T> static const T* GetItem( const SfxItemSet& rSet, TypedWhichId<T> nSlot, bool bDeep = true ) + { + return static_cast<const T*>(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; +}; + +#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..4785c4de7 --- /dev/null +++ b/include/sfx2/tbxctrl.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 . + */ +#ifndef INCLUDED_SFX2_TBXCTRL_HXX +#define INCLUDED_SFX2_TBXCTRL_HXX + +#include <memory> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <svl/poolitem.hxx> +#include <svtools/toolboxcontroller.hxx> +#include <rtl/ref.hxx> +#include <vcl/window.hxx> + +namespace com::sun::star::frame { class XDispatchProvider; } +namespace com::sun::star::frame { class XFrame; } + +class InterimItemWindow; +class SfxToolBoxControl; +class SfxModule; + +svt::ToolboxController* SfxToolBoxControllerFactory( const css::uno::Reference< css::frame::XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const OUString& aCommandURL ); + +typedef SfxToolBoxControl* (*SfxToolBoxControlCtor)( sal_uInt16 nSlotId, sal_uInt16 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 SfxToolBoxControl* CreateImpl( sal_uInt16 nSlotId, sal_uInt16 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 StateChanged( 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<InterimItemWindow> 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, sal_uInt16 nId, ToolBox& rBox, bool bShowStrings = false ); + virtual ~SfxToolBoxControl() override; + + ToolBox& GetToolBox() const; + unsigned short 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 SfxToolBoxControl* CreateControl( sal_uInt16 nSlotId, sal_uInt16 nTbxId, ToolBox *pBox, SfxModule const *pMod ); + static void RegisterToolBoxControl( SfxModule*, const SfxTbxCtrlFactory&); +}; + +#define SFX_IMPL_TOOLBOX_CONTROL(Class, nItemClass) \ + SfxToolBoxControl* Class::CreateImpl( sal_uInt16 nSlotId, sal_uInt16 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) \ + SfxToolBoxControl* Class::CreateImpl( sal_uInt16 nSlotId, sal_uInt16 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..b6e8bca39 --- /dev/null +++ b/include/sfx2/templatedlg.hxx @@ -0,0 +1,209 @@ +/* -*- 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 <sal/config.h> +#include <sfx2/dllapi.h> + +#include <set> + +#include <vcl/idle.hxx> +#include <vcl/timer.hxx> +#include <vcl/weld.hxx> + +#include <sfx2/templatelocalview.hxx> + +class TemplateSearchView; +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<css::frame::XModel> &rModel); + +protected: + + void getApplicationSpecificSettings(); + + void readSettings (); + + void writeSettings (); + + void fillFolderComboBox(); + + DECL_LINK(SelectApplicationHdl, weld::ComboBox&, void); + DECL_LINK(SelectRegionHdl, weld::ComboBox&, void); + + DECL_LINK(OkClickHdl, weld::Button&, void); + DECL_LINK(MoveClickHdl, weld::Button&, void); + DECL_LINK(ExportClickHdl, weld::Button&, void); + DECL_LINK(ImportClickHdl, weld::Button&, void); + DECL_STATIC_LINK(SfxTemplateManagerDlg, LinkClickHdl, weld::Button&, void); + + DECL_LINK(TVItemStateHdl, const ThumbnailViewItem*, void); + + DECL_LINK(MenuSelectHdl, const OString&, void); + void DefaultTemplateMenuSelectHdl(const OString& rIdent); + + DECL_LINK(OpenRegionHdl, void*, void); + DECL_LINK(CreateContextMenuHdl, ThumbnailViewItem*, void); + DECL_LINK(OpenTemplateHdl, ThumbnailViewItem*, void); + DECL_LINK(EditTemplateHdl, ThumbnailViewItem*, void); + DECL_LINK(DeleteTemplateHdl, ThumbnailViewItem*, void); + DECL_LINK(DefaultTemplateHdl, ThumbnailViewItem*, void); + + void SearchUpdate(); + + DECL_LINK(SearchUpdateHdl, weld::Entry&, void); + DECL_LINK(GetFocusHdl, weld::Widget&, void); + DECL_LINK(LoseFocusHdl, weld::Widget&, void); + DECL_LINK(ImplUpdateDataHdl, Timer*, void); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + + void OnTemplateImportCategory(const OUString& sCategory); + static void OnTemplateLink (); + void OnTemplateOpen (); + void OnTemplateExport (); + + void OnTemplateState (const ThumbnailViewItem *pItem); + + void OnCategoryNew (); + void OnCategoryRename(); + void OnCategoryDelete(); + + void createDefaultTemplateMenu (); + + /** + * + * Move templates stored in the filesystem to another folder. + * + **/ + + void localMoveTo (sal_uInt16 nMenuId); + + /** + * + * Move search result templates stored in the filesystem to another folder. + * + **/ + + void localSearchMoveTo (sal_uInt16 nMenuId); + + /// Return filter according to the currently selected application filter. + FILTER_APPLICATION getCurrentApplicationFilter() const; + +protected: + std::set<const ThumbnailViewItem*,selection_cmp_fn> maSelTemplates; + css::uno::Reference< css::frame::XModel > m_xModel; + css::uno::Reference< css::frame::XDesktop2 > mxDesktop; + + Timer m_aUpdateDataTimer; + + std::unique_ptr<weld::Entry> mxSearchFilter; + std::unique_ptr<weld::ComboBox> mxCBApp; + std::unique_ptr<weld::ComboBox> mxCBFolder; + + std::unique_ptr<weld::Button> mxOKButton; + std::unique_ptr<weld::Button> mxMoveButton; + std::unique_ptr<weld::Button> mxExportButton; + std::unique_ptr<weld::Button> mxImportButton; + std::unique_ptr<weld::Button> mxLinkButton; + std::unique_ptr<weld::CheckButton> mxCBXHideDlg; + std::unique_ptr<weld::MenuButton> mxActionBar; + std::unique_ptr<TemplateSearchView> mxSearchView; + std::unique_ptr<SfxTemplateLocalView> mxLocalView; + std::unique_ptr<weld::Menu> mxTemplateDefaultMenu; + std::unique_ptr<weld::CustomWeld> mxSearchViewWeld; + std::unique_ptr<weld::CustomWeld> mxLocalViewWeld; +}; + +// class SfxTemplateCategoryDialog ------------------------------------------------------------------- + +class SfxTemplateCategoryDialog final : public weld::GenericDialogController +{ +private: + OUString msSelectedCategory; + bool mbIsNewCategory; + + std::unique_ptr<weld::TreeView> mxLBCategory; + std::unique_ptr<weld::Label> mxSelectLabel; + std::unique_ptr<weld::Entry> mxNewCategoryEdit; + std::unique_ptr<weld::Label> mxCreateLabel; + std::unique_ptr<weld::Button> mxOKButton; + +public: + DECL_LINK(NewCategoryEditHdl, weld::Entry&, void); + DECL_LINK(SelectCategoryHdl, weld::TreeView&, void); + + void SetCategoryLBEntries(std::vector<OUString> names); + + void HideNewCategoryOption(); + + const OUString& GetSelectedCategory() const { + return msSelectedCategory; + }; + + void SetSelectLabelText(OUString const & sText) const { + mxSelectLabel->set_label(sText); + }; + + 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_LINK(OpenTemplateHdl, ThumbnailViewItem*, void); + DECL_LINK(OkClickHdl, weld::Button&, void); + DECL_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/templatelocalview.hxx b/include/sfx2/templatelocalview.hxx new file mode 100644 index 000000000..8144340a0 --- /dev/null +++ b/include/sfx2/templatelocalview.hxx @@ -0,0 +1,257 @@ +/* -*- 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 <sfx2/thumbnailview.hxx> +#include <sfx2/templateproperties.hxx> +#include <vcl/menu.hxx> +#include <functional> +#include <memory> +#include <set> + +//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, const OUString &rExt); + bool isValid (const OUString& rPath) const; + +private: + + FILTER_APPLICATION mApp; +}; + + +class TemplateLocalView : public ThumbnailView +{ + typedef bool (*selection_cmp_fn)(const ThumbnailViewItem*,const ThumbnailViewItem*); + +public: + + TemplateLocalView ( vcl::Window* pParent ); + + virtual ~TemplateLocalView () override; + virtual void dispose() override; + + // Fill view with new item list + void insertItems (const std::vector<TemplateItemProperties> &rTemplates, bool isRegionSelected = true, bool bShowCategoryInTooltip = false); + + // Fill view with template folders thumbnails + void Populate (); + + virtual void reload (); + + virtual void showAllTemplates (); + + void showRegion (TemplateContainerItem const *pItem); + + DECL_LINK(ContextMenuSelectHdl, Menu*, bool); + + virtual bool renameItem(ThumbnailViewItem* pItem, const OUString& sNewTitle) override; + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + + virtual void RequestHelp( const HelpEvent& rHEvt ) override; + + virtual void Command( const CommandEvent& rCEvt ) override; + + virtual void KeyInput( const KeyEvent& rKEvt ) override; + + void setCreateContextMenuHdl(const Link<ThumbnailViewItem*,void> &rLink); + + void setOpenTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink); + + void setEditTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink); + + void updateThumbnailDimensions(long itemMaxSize); + + static BitmapEx scaleImg (const BitmapEx &rImg, long width, long height); + + static BitmapEx getDefaultThumbnail( const OUString& rPath ); + + static BitmapEx fetchThumbnail (const OUString &msURL, long width, long height); + + static bool IsDefaultTemplate(const OUString& rPath); + +protected: + virtual void OnItemDblClicked(ThumbnailViewItem *pItem) override; + +protected: + sal_uInt16 mnCurRegionId; + + TemplateViewItem *maSelectedItem; + + long mnThumbnailWidth; + long mnThumbnailHeight; + + Point maPosition; //store the point of click event + + Link<ThumbnailViewItem*,void> maCreateContextMenuHdl; + Link<ThumbnailViewItem*,void> maOpenTemplateHdl; + Link<ThumbnailViewItem*,void> maEditTemplateHdl; + + std::unique_ptr<SfxDocumentTemplates> mpDocTemplates; + std::vector<std::unique_ptr<TemplateContainerItem> > maRegions; + std::vector<TemplateItemProperties > maAllTemplates; +}; + +class SfxTemplateLocalView final : public SfxThumbnailView +{ + typedef bool (*selection_cmp_fn)(const ThumbnailViewItem*,const ThumbnailViewItem*); + +public: + + SfxTemplateLocalView(std::unique_ptr<weld::ScrolledWindow> xWindow, + std::unique_ptr<weld::Menu> xMenu); + + virtual ~SfxTemplateLocalView () override; + + // Fill view with new item list + void insertItems (const std::vector<TemplateItemProperties> &rTemplates, bool isRegionSelected = true, bool bShowCategoryInTooltip = false); + + // Fill view with template folders thumbnails + void Populate (); + + void reload (); + + void showAllTemplates (); + + void showRegion (TemplateContainerItem const *pItem); + + void showRegion (const OUString &rName); + + void createContextMenu(const bool bIsDefault ); + + void ContextMenuSelectHdl(const OString& rIdent); + + TemplateContainerItem* getRegion(OUString const & sStr); + + sal_uInt16 getRegionId (size_t pos) const; + + sal_uInt16 getRegionId (OUString const & sRegionName) const; + + OUString getRegionName(const sal_uInt16 nRegionId) const; + + OUString getRegionItemName(const sal_uInt16 nItemId) const; + + std::vector<OUString> getFolderNames (); + + std::vector<TemplateItemProperties> + getFilteredItems (const std::function<bool (const TemplateItemProperties&) > &rFunc) const; + + sal_uInt16 createRegion (const OUString &rName); + + bool renameRegion(const OUString &rTitle, const OUString &rNewTitle); + + bool removeRegion (const sal_uInt16 nItemId); + + bool removeTemplate (const sal_uInt16 nItemId, const sal_uInt16 nSrcItemId); + + bool moveTemplate (const ThumbnailViewItem* pItem, const sal_uInt16 nSrcItem, + const sal_uInt16 nTargetItem); + + void moveTemplates (const std::set<const ThumbnailViewItem*,selection_cmp_fn> &rItems, const sal_uInt16 nTargetItem); + + bool copyFrom(TemplateContainerItem *pItem, const OUString &rPath); + + bool exportTo (const sal_uInt16 nItemId, const sal_uInt16 nRegionItemId, const OUString &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 setOpenRegionHdl(const Link<void*,void> &rLink); + + void setCreateContextMenuHdl(const Link<ThumbnailViewItem*,void> &rLink); + + void setOpenTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink); + + void setEditTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink); + + void setDeleteTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink); + + void setDefaultTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink); + + void RemoveDefaultTemplateIcon( const OUString& rPath); + + static BitmapEx scaleImg (const BitmapEx &rImg, long width, long height); + + static BitmapEx getDefaultThumbnail( const OUString& rPath ); + + static BitmapEx fetchThumbnail (const OUString &msURL, long width, long height); + + static bool IsDefaultTemplate(const OUString& rPath); + +private: + virtual void OnItemDblClicked(ThumbnailViewItem *pItem) override; + + sal_uInt16 mnCurRegionId; + + TemplateViewItem *maSelectedItem; + + Point maPosition; //store the point of click event + + Link<void*,void> maOpenRegionHdl; + Link<ThumbnailViewItem*,void> maCreateContextMenuHdl; + Link<ThumbnailViewItem*,void> maOpenTemplateHdl; + Link<ThumbnailViewItem*,void> maEditTemplateHdl; + Link<ThumbnailViewItem*,void> maDeleteTemplateHdl; + Link<ThumbnailViewItem*,void> maDefaultTemplateHdl; + + std::unique_ptr<SfxDocumentTemplates> mpDocTemplates; + std::vector<std::unique_ptr<TemplateContainerItem> > maRegions; + std::vector<TemplateItemProperties > 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..ea2831ba2 --- /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 <rtl/ustring.hxx> +#include <vcl/bitmapex.hxx> + +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..99b7200a9 --- /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 <config_options.h> +#include <memory> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sfx2/sidebar/PanelLayout.hxx> + +class SfxBindings; +class SfxTemplateDialog_Impl; + +class UNLESS_MERGELIBS(SFX2_DLLPUBLIC) SfxTemplatePanelControl final : public PanelLayout +{ +public: + SfxTemplatePanelControl(SfxBindings* pBindings, vcl::Window* pParentWindow); + virtual ~SfxTemplatePanelControl() override; + virtual void dispose() override; + + weld::Builder* get_builder() { return m_xBuilder.get(); } + +private: + std::unique_ptr<SfxTemplateDialog_Impl> 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..b924da0f6 --- /dev/null +++ b/include/sfx2/thumbnailview.hxx @@ -0,0 +1,468 @@ +/* -*- 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 <sfx2/dllapi.h> + +#include <functional> +#include <memory> +#include <vector> + +#include <vcl/ctrl.hxx> +#include <vcl/customweld.hxx> + +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 ThumbnailViewBase +{ + friend class ThumbnailViewAcc; + friend class ThumbnailViewItemAcc; + + virtual sal_uInt16 ImplGetVisibleItemCount() const = 0; + virtual ThumbnailViewItem* ImplGetVisibleItem(sal_uInt16 nVisiblePos) = 0; + + virtual css::uno::Reference<css::accessibility::XAccessible> getAccessible() = 0; + +public: + /// Updates information in the view; used only in RecentDocsView ATM. + virtual void Reload() {} + + virtual bool renameItem(ThumbnailViewItem* pItem, const OUString& sNewTitle); + + virtual ~ThumbnailViewBase(); +}; + +class SFX2_DLLPUBLIC ThumbnailView : public Control, public ThumbnailViewBase +{ +public: + + ThumbnailView(vcl::Window* pParent, WinBits nWinStyle = WB_TABSTOP); + + virtual ~ThumbnailView() override; + virtual void dispose() override; + + virtual void MouseMove(const MouseEvent& rMEvt) override; + + void AppendItem(std::unique_ptr<ThumbnailViewItem> pItem); + + virtual void Clear(); + + // Change current thumbnail item list with new one (invalidates all pointers to a thumbnail item) + void updateItems(std::vector<std::unique_ptr<ThumbnailViewItem>> 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; + + void setItemMaxTextLength (sal_uInt32 nLength); + + void setItemDimensions (long ItemWidth, long ThumbnailHeight, + 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 filterItems (const std::function<bool (const ThumbnailViewItem*) > &func); + + virtual void Resize() override; + + static BitmapEx readThumbnail(const OUString &msURL); + +protected: + + virtual void KeyInput( const KeyEvent& rKEvt ) override; + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + + virtual void Command( const CommandEvent& rCEvt ) override; + + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + + virtual void GetFocus() override; + + virtual void LoseFocus() override; + + virtual void StateChanged( StateChangedType nStateChange ) override; + + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; + + virtual css::uno::Reference<css::accessibility::XAccessible> getAccessible() override; + +protected: + + // Drawing item related functions, override them to make your own custom ones. + + void DrawItem (ThumbnailViewItem const *pItem); + + virtual void OnItemDblClicked (ThumbnailViewItem *pItem); + +protected: + + friend class ThumbnailViewAcc; + friend class ThumbnailViewItemAcc; + using Window::ImplInit; + + void CalculateItemPositions (bool bScrollBarUsed = false); + void MakeItemVisible( sal_uInt16 nId ); + + SFX2_DLLPRIVATE void ImplInit(); + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + + SFX2_DLLPRIVATE void ImplDeleteItems(); + SFX2_DLLPRIVATE size_t ImplGetItem( const Point& rPoint ) const; + SFX2_DLLPRIVATE ThumbnailViewItem* ImplGetItem( size_t nPos ); + SFX2_DLLPRIVATE virtual sal_uInt16 ImplGetVisibleItemCount() const override; + SFX2_DLLPRIVATE virtual ThumbnailViewItem* ImplGetVisibleItem(sal_uInt16 nVisiblePos) override; + SFX2_DLLPRIVATE void ImplFireAccessibleEvent( short nEventId, const css::uno::Any& rOldValue, const css::uno::Any& rNewValue ); + SFX2_DLLPRIVATE bool ImplHasAccessibleListeners(); + DECL_DLLPRIVATE_LINK( ImplScrollHdl, ScrollBar*, void ); + +protected: + + std::vector< std::unique_ptr<ThumbnailViewItem> > mItemList; + ThumbnailValueItemList mFilteredItemList; ///< Cache to store the filtered items + ThumbnailValueItemList::iterator mpStartSelRange; + VclPtr<ScrollBar> mpScrBar; + long mnItemWidth; + long mnItemHeight; + long mnItemPadding; + long mnThumbnailHeight; // Maximum height of the thumbnail + long mnDisplayHeight; // Height of the data display box (name, etc) + long mnVisLines; + long mnLines; + + sal_uInt16 mnCols; + sal_uInt16 mnFirstLine; + bool mbScroll : 1; + bool mbHasVisibleItems : 1; + bool mbShowTooltips : 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. + + std::unique_ptr<ThumbnailItemAttributes> mpItemAttrs; + + std::function<bool (const ThumbnailViewItem*)> maFilterFunc; +}; + +class SfxThumbnailView : public weld::CustomWidgetController, public ThumbnailViewBase +{ +public: + SfxThumbnailView(std::unique_ptr<weld::ScrolledWindow> xWindow, std::unique_ptr<weld::Menu> xMenu); + + virtual ~SfxThumbnailView() override; + + virtual bool MouseMove(const MouseEvent& rMEvt) override; + + void AppendItem(std::unique_ptr<ThumbnailViewItem> pItem); + + void RemoveItem(sal_uInt16 nItemId); + + void Clear(); + + // Change current thumbnail item list with new one (invalidates all pointers to a thumbnail item) + void updateItems(std::vector<std::unique_ptr<ThumbnailViewItem>> 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; + + void setItemMaxTextLength (sal_uInt32 nLength); + + void setItemDimensions (long ItemWidth, long ThumbnailHeight, + 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 SetMultiSelectionEnabled( bool bIsMultiSelectionEnabled ); + + void filterItems (const std::function<bool (const ThumbnailViewItem*) > &func); + + void setItemStateHdl (const Link<const ThumbnailViewItem*,void> &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; + +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; + + virtual css::uno::Reference<css::accessibility::XAccessible> getAccessible() override; + +protected: + + // Drawing item related functions, override them to make your own custom ones. + + void DrawItem (ThumbnailViewItem const *pItem); + + virtual void OnItemDblClicked (ThumbnailViewItem *pItem); + +protected: + + friend class SfxThumbnailViewAcc; + 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 ); + virtual sal_uInt16 ImplGetVisibleItemCount() const override; + virtual ThumbnailViewItem* ImplGetVisibleItem(sal_uInt16 nVisiblePos) override; + void ImplFireAccessibleEvent( short nEventId, const css::uno::Any& rOldValue, const css::uno::Any& rNewValue ); + bool ImplHasAccessibleListeners(); + DECL_LINK( ImplScrollHdl, weld::ScrolledWindow&, void ); + +protected: + + std::vector< std::unique_ptr<ThumbnailViewItem> > mItemList; + css::uno::Reference<css::accessibility::XAccessible> mxAccessible; + ThumbnailValueItemList mFilteredItemList; ///< Cache to store the filtered items + ThumbnailValueItemList::iterator mpStartSelRange; + long mnItemWidth; + long mnItemHeight; + long mnItemPadding; + long mnThumbnailHeight; // Maximum height of the thumbnail + long mnDisplayHeight; // Height of the data display box (name, etc) + long mnVisLines; + long mnLines; + + sal_uInt16 mnCols; + sal_uInt16 mnFirstLine; + bool mbScroll : 1; + bool mbHasVisibleItems : 1; + bool mbShowTooltips : 1; + bool mbIsMultiSelectionEnabled: 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<const ThumbnailViewItem*, void> maItemStateHdl; + std::unique_ptr<ThumbnailItemAttributes> mpItemAttrs; + std::unique_ptr<weld::ScrolledWindow> mxScrolledWindow; + std::unique_ptr<weld::Menu> mxContextMenu; + + std::function<bool (const ThumbnailViewItem*)> maFilterFunc; +}; + + +#endif // INCLUDED_SFX2_THUMBNAILVIEW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/titledockwin.hxx b/include/sfx2/titledockwin.hxx new file mode 100644 index 000000000..976c4bb9f --- /dev/null +++ b/include/sfx2/titledockwin.hxx @@ -0,0 +1,106 @@ +/* -*- 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_TITLEDOCKWIN_HXX +#define INCLUDED_SFX2_TITLEDOCKWIN_HXX + +#include <sfx2/dllapi.h> +#include <sfx2/dockwin.hxx> + +#include <vcl/toolbox.hxx> +#include <vcl/vclptr.hxx> +#include <tools/svborder.hxx> + +namespace sfx2 +{ + class SFX2_DLLPUBLIC TitledDockingWindow : public SfxDockingWindow + { + public: + TitledDockingWindow( + SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow, + vcl::Window* i_pParent + ); + + virtual ~TitledDockingWindow() override; + virtual void dispose() override; + + /** sets a title to be displayed in the docking window + */ + void SetTitle( const OUString& i_rTitle ); + + /** returns the content window, which is to be used as parent window for any content to be displayed + in the docking window. + */ + vcl::Window& GetContentWindow() { return *m_aContentWindow; } + const vcl::Window& GetContentWindow() const { return *m_aContentWindow; } + + /** Return the border that is painted around the inner window as + decoration. + */ + const SvBorder& GetDecorationBorder() const { return m_aBorder; } + + protected: + // Window overridables + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& i_rArea) override; + virtual void Resize() override; + virtual void StateChanged( StateChangedType i_nType ) override; + virtual void DataChanged( const DataChangedEvent& i_rDataChangedEvent ) override; + virtual void SetText( const OUString& i_rText ) override; + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + protected: + /** internal version of ResetToolBox + */ + void impl_resetToolBox(); + + private: + DECL_LINK( OnToolboxItemSelected, ToolBox*, void ); + + void impl_layout(); + void impl_scheduleLayout(); + + private: + OUString m_sTitle; + VclPtr<ToolBox> m_aToolbox; + VclPtr<Window> m_aContentWindow; + + /** The border that is painted around the inner window. The bevel + shadow lines are part of the border, so where the border is 0 no + such line is painted. + */ + SvBorder m_aBorder; + + /** Remember that a layout is pending, i.e. Resize() has been called + since the last Paint(). + */ + bool m_bLayoutPending; + + /** Height of the title bar. Calculated in impl_layout(). + */ + int m_nTitleBarHeight; + + }; + + +} // namespace sfx2 + + +#endif // INCLUDED_SFX2_TITLEDOCKWIN_HXX + +/* 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 <sal/types.h> + +//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..927d67e89 --- /dev/null +++ b/include/sfx2/tplpitem.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_TPLPITEM_HXX +#define INCLUDED_SFX2_TPLPITEM_HXX + +#include <rtl/ustring.hxx> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <svl/flagitem.hxx> +#include <svl/style.hxx> + +class SFX2_DLLPUBLIC SfxTemplateItem final : public SfxFlagItem +{ + OUString aStyle; +public: + static SfxPoolItem* CreateDefault(); + SfxTemplateItem(); + SfxTemplateItem( sal_uInt16 nWhich, + const OUString &rStyle ); + + const OUString& GetStyleName() const { return aStyle; } + + 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<SfxStyleSearchBits>(SfxFlagItem::GetValue()); } + void SetValue(SfxStyleSearchBits n) { SfxFlagItem::SetValue(static_cast<sal_uInt16>(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 <sfx2/dllapi.h> + +#include <memory> + +namespace com::sun::star::awt { class XKeyHandler; } +namespace com::sun::star::awt { class XMouseClickHandler; } +namespace com::sun::star::uno { template <typename > 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 <rtl/ustring.hxx> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sfx2/shell.hxx> + +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..0a40a4179 --- /dev/null +++ b/include/sfx2/viewfrm.hxx @@ -0,0 +1,270 @@ +/* -*- 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 <memory> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <svl/lstner.hxx> +#include <sfx2/frame.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/shell.hxx> +#include <svl/poolitem.hxx> +#include <vcl/svapp.hxx> + +class Button; +class SvBorder; +class SfxDispatcher; +class SfxBindings; +class SfxProgress; +class SfxViewShell; +class Point; +class Size; +class SfxChildWindow; +class SfxInfoBarWindow; +enum class InfobarType; + +class SFX2_DLLPUBLIC SfxViewFrame: public SfxShell, public SfxListener +{ + std::unique_ptr<struct SfxViewFrame_Impl> m_pImpl; + + SfxObjectShellRef m_xObjSh; + std::unique_ptr<SfxDispatcher> m_pDispatcher; + SfxBindings* m_pBindings; + ImplSVHelpData* m_pHelpData; + ImplSVWinData* m_pWinData; + sal_uInt16 m_nAdjustPosPixelLock; + +private: + SAL_DLLPRIVATE void Construct_Impl( SfxObjectShell *pObjSh ); + +protected: + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + DECL_LINK(GetInvolvedHandler, Button*, void); + DECL_LINK(DonationHandler, Button*, void); + DECL_LINK(WhatsNewHandler, Button*, void); + DECL_LINK(SwitchReadOnlyHandler, Button*, void); + DECL_LINK(SignDocumentHandler, 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; + + 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<SfxInfoBarWindow> AppendInfoBar(const OUString& sId, + const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, + InfobarType aInfobarType, + bool bShowCloseButton=true); + void RemoveInfoBar(const OUString& sId); + void UpdateInfoBar(const OUString& sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, + InfobarType eType); + bool HasInfoBarWithID(const OUString& sId); + + SAL_DLLPRIVATE void GetDocNumber_Impl(); + SAL_DLLPRIVATE void SetViewShell_Impl( SfxViewShell *pVSh ); + SAL_DLLPRIVATE void ReleaseObjectShell_Impl(); + + SAL_DLLPRIVATE void GetState_Impl( SfxItemSet &rSet ); + SAL_DLLPRIVATE 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 <NULL/>, 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..d4d7d2039 --- /dev/null +++ b/include/sfx2/viewsh.hxx @@ -0,0 +1,390 @@ +/* -*- 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 <sal/config.h> +#include <memory> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <com/sun/star/uno/Reference.h> +#include <svl/lstner.hxx> +#include <sfx2/shell.hxx> +#include <i18nlangtag/languagetag.hxx> +#include <vcl/IDialogRenderable.hxx> +#include <vcl/errcode.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <vcl/vclptr.hxx> +#include <LibreOfficeKit/LibreOfficeKitTypes.h> +#include <editeng/outliner.hxx> +#include <functional> + +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 Menu; +class NotifyEvent; +class SfxInPlaceClient; +namespace vcl { class PrinterController; } + +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<SfxPrinterChangeFlags> : is_typed_flags<SfxPrinterChangeFlags, 31> {}; +} +#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<SfxViewShellFlags> : is_typed_flags<SfxViewShellFlags, 0x0110> {}; +} + +/* [Description] + + The SfxViewShell flags control the behavior of SfxViewShell for the + duration of its lifetime. They are defined in the constructor of + <SfxViewShell>. +*/ + +enum class LOKDeviceFormFactor +{ + UNKNOWN = 0, + DESKTOP = 1, + TABLET = 2, + MOBILE = 3 +}; + +class SfxViewFactory; +#define SFX_DECL_VIEWFACTORY(Class) \ +private: \ + static SfxViewFactory *pFactory; \ +public: \ + static SfxViewShell *CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldView); \ + static void RegisterFactory( SfxInterfaceId nPrio ); \ + static SfxViewFactory*Factory() { return pFactory; } \ + static void InitFactory() + +#define SFX_IMPL_NAMED_VIEWFACTORY(Class, AsciiViewName) \ + SfxViewFactory* Class::pFactory; \ + SfxViewShell* Class::CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldView) \ + { return new Class(pFrame, pOldView); } \ + void Class::RegisterFactory( SfxInterfaceId nPrio ) \ + { \ + pFactory = new SfxViewFactory(&CreateInstance,nPrio,AsciiViewName);\ + InitFactory(); \ + } \ + void Class::InitFactory() + +#define SFX_VIEW_REGISTRATION(DocClass) \ + DocClass::Factory().RegisterViewFactory( *Factory() ) + +template<class T> bool checkSfxViewShell(const SfxViewShell* pShell) +{ + return dynamic_cast<const T*>(pShell) != nullptr; +} + +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<struct SfxViewShell_Impl> pImpl; + SfxViewFrame* pFrame; + VclPtr<vcl::Window> pWindow; + bool bNoNewWindow; + bool mbPrinterSettingsModified; + LanguageTag maLOKLanguageTag; + LanguageTag maLOKLocale; + LOKDeviceFormFactor maLOKDeviceFormFactor; + +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<bool ( const SfxViewShell* )>& isViewShell = nullptr ); + static SfxViewShell* GetNext( const SfxViewShell& rPrev, + bool bOnlyVisible = true, + const std::function<bool ( const SfxViewShell* )>& 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(long 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. + */ + virtual bool PrepareClose( bool bUI = true ); + virtual OUString GetSelectionText( bool bCompleteWords = 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<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) 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<SfxTabPage> 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<css::frame::XController> GetController() const; + + bool TryContextMenuInterception( Menu& rIn, const OUString& rMenuIdentifier, VclPtr<Menu>& rpOut, css::ui::ContextMenuExecuteEvent aEvent ); + bool TryContextMenuInterception( Menu& rMenu, 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<SfxPrinter>& 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); + + /// The actual per-view implementation of lok::Document::registerCallback(). + void registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData); + /// Invokes the registered callback, if there are any. + void libreOfficeKitViewCallback(int nType, const char* pPayload) const override; + /// 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; + /// 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; } +}; + + +inline SfxViewFrame* SfxViewShell::GetViewFrame() const + +/* [Description] + + This method returns a pointer to the <SfxViewFrame> 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] + + <SfxShell::GetFrame()const> +*/ + +{ + 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 <sfx2/dllapi.h> +#include <svl/poolitem.hxx> +#include <tools/color.hxx> + +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..c72a473c4 --- /dev/null +++ b/include/sfx2/weldutils.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/. + */ + +#ifndef INCLUDED_SFX2_WELDUTILS_HXX +#define INCLUDED_SFX2_WELDUTILS_HXX + +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XToolbarController.hpp> + +#include <com/sun/star/uno/Reference.hxx> +#include <tools/link.hxx> +#include <sfx2/dllapi.h> +#include <svtools/miscopt.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> + +#include <map> + +namespace weld +{ +class Builder; +class Toolbar; +} + +class SFX2_DLLPUBLIC ToolbarUnoDispatcher +{ +private: + css::uno::Reference<css::frame::XFrame> m_xFrame; + SvtMiscOptions m_aToolbarOptions; + weld::Toolbar* m_pToolbar; + weld::Builder* m_pBuilder; + bool m_bSideBar; + + DECL_LINK(SelectHdl, const OString&, void); + DECL_LINK(ToggleMenuHdl, const OString&, void); + DECL_LINK(ChangedIconSizeHandler, LinkParamNone*, void); + + void CreateController(const OUString& rCommand); + vcl::ImageType GetIconSize() const; + + typedef std::map<OUString, css::uno::Reference<css::frame::XToolbarController>> + 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<css::frame::XFrame>& rFrame, + bool bSideBar = true); + + css::uno::Reference<css::frame::XToolbarController> + GetControllerForCommand(const OUString& rCommand) const; + + void dispose(); + ~ToolbarUnoDispatcher(); +}; + +#endif + +/* 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..32285cb70 --- /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 <svl/intitem.hxx> +#include <sfx2/sfxsids.hrc> +#include <sfx2/dllapi.h> +#include <o3tl/typed_flags_set.hxx> + + +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<SvxZoomEnableFlags> : is_typed_flags<SvxZoomEnableFlags, 0x701f> {}; +} + +class SFX2_DLLPUBLIC SvxZoomItem: 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: */ |