diff options
Diffstat (limited to 'include/sfx2')
133 files changed, 18343 insertions, 0 deletions
diff --git a/include/sfx2/AccessibilityCheck.hxx b/include/sfx2/AccessibilityCheck.hxx new file mode 100644 index 0000000000..4c90ad31df --- /dev/null +++ b/include/sfx2/AccessibilityCheck.hxx @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include <sfx2/dllapi.h> +#include <sfx2/AccessibilityIssue.hxx> + +namespace sfx +{ +class SFX2_DLLPUBLIC AccessibilityCheck +{ +protected: + AccessibilityIssueCollection m_aIssueCollection; + +public: + AccessibilityCheck() = default; + virtual ~AccessibilityCheck(); + + virtual void check() = 0; + + AccessibilityIssueCollection& getIssueCollection(); +}; + +} // end sfx namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/AccessibilityIssue.hxx b/include/sfx2/AccessibilityIssue.hxx new file mode 100644 index 0000000000..92bef3d7d6 --- /dev/null +++ b/include/sfx2/AccessibilityIssue.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/. + * + */ + +#pragma once + +#include <sfx2/dllapi.h> + +#include <vcl/weld.hxx> +#include <rtl/ustring.hxx> + +#include <vector> +#include <memory> + +namespace sfx +{ +enum class AccessibilityIssueID +{ + UNSPECIFIED, // TODO: remove - temporary + DOCUMENT_TITLE, + DOCUMENT_LANGUAGE, + DOCUMENT_BACKGROUND, + STYLE_LANGUAGE, + LINKED_GRAPHIC, + NO_ALT_OLE, + NO_ALT_GRAPHIC, + NO_ALT_SHAPE, + TABLE_MERGE_SPLIT, + TEXT_FORMATTING, + TABLE_FORMATTING, + HYPERLINK_IS_TEXT, + HYPERLINK_SHORT, + FAKE_FOOTNOTE, + FAKE_CAPTION, + MANUAL_NUMBERING +}; + +class SFX2_DLLPUBLIC AccessibilityIssue +{ +public: + AccessibilityIssue(AccessibilityIssueID eIssueID = AccessibilityIssueID::UNSPECIFIED); + AccessibilityIssue(AccessibilityIssue const&) = default; + virtual ~AccessibilityIssue(); + + virtual bool canGotoIssue() const = 0; + virtual void gotoIssue() const = 0; + + virtual bool canQuickFixIssue() const = 0; + virtual void quickFixIssue() const = 0; + + void setParent(weld::Window* pParent) { m_pParent = pParent; } + + AccessibilityIssue& operator=(const AccessibilityIssue&) = default; + + AccessibilityIssueID m_eIssueID; + OUString m_aIssueText; + + weld::Window* m_pParent; +}; + +class SFX2_DLLPUBLIC AccessibilityIssueCollection +{ +private: + std::vector<std::shared_ptr<AccessibilityIssue>> m_aIssues; + +public: + AccessibilityIssueCollection() = default; + + std::vector<std::shared_ptr<AccessibilityIssue>>& getIssues(); + + void clear(); +}; + +} // end sfx namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/DocumentMetadataAccess.hxx b/include/sfx2/DocumentMetadataAccess.hxx new file mode 100644 index 0000000000..bcbf9f1b38 --- /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, + std::u16string_view i_rSubDocument = std::u16string_view()); + + +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 0000000000..2fe0f7d7d2 --- /dev/null +++ b/include/sfx2/DocumentSigner.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/. + * + */ + +#ifndef INCLUDED_SFX2_DOCUMENTSIGNER_HXX +#define INCLUDED_SFX2_DOCUMENTSIGNER_HXX + +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <rtl/ustring.hxx> +#include <utility> + +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 aUrl) + : m_aUrl(std::move(aUrl)) + { + } + + 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/LokControlHandler.hxx b/include/sfx2/LokControlHandler.hxx new file mode 100644 index 0000000000..d8ff381124 --- /dev/null +++ b/include/sfx2/LokControlHandler.hxx @@ -0,0 +1,195 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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/lokhelper.hxx> +#include <svx/svdouno.hxx> +#include <svx/svditer.hxx> +#include <vcl/virdev.hxx> +#include <vcl/DocWindow.hxx> +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/awt/XWindowPeer.hpp> +#include <com/sun/star/awt/XGraphics.hpp> +#include <com/sun/star/awt/XView.hpp> +#include <toolkit/helper/vclunohelper.hxx> +#include <tools/UnitConversion.hxx> + +#include <optional> + +class LokControlHandler +{ +public: + static bool postMouseEvent(const SdrPage* pPage, const SdrView* pDrawView, + vcl::DocWindow& rMainWindow, int nType, Point aPointHmm, int nCount, + int nButtons, int nModifier) + { + static std::optional<PointerStyle> eDocPointerStyle; + + o3tl::Length eControlUnitLength = MapToO3tlLength(rMainWindow.GetMapMode().GetMapUnit()); + SdrObjListIter aIterator(pPage, SdrIterMode::Flat); + while (aIterator.IsMore()) + { + SdrObject* pObject = aIterator.Next(); + SdrUnoObj* pUnoObect = dynamic_cast<SdrUnoObj*>(pObject); + if (pUnoObect) + { + tools::Rectangle aControlRect = pUnoObect->GetLogicRect(); + tools::Rectangle aControlRectHMM + = o3tl::convert(aControlRect, eControlUnitLength, o3tl::Length::mm100); + + if (aControlRectHMM.Contains(aPointHmm)) + { + css::uno::Reference<css::awt::XControl> xControl + = pUnoObect->GetUnoControl(*pDrawView, *rMainWindow.GetOutDev()); + if (!xControl.is()) + return false; + + css::uno::Reference<css::awt::XWindow> xControlWindow(xControl, + css::uno::UNO_QUERY); + if (!xControlWindow.is()) + return false; + + css::uno::Reference<css::awt::XWindowPeer> xWindowPeer(xControl->getPeer()); + + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindowPeer); + if (pWindow) + { + tools::Rectangle aControlRectPx + = o3tl::convert(aControlRectHMM, o3tl::Length::mm100, o3tl::Length::px); + // used by Control::LogicInvalidate + pWindow->SetPosPixel(aControlRectPx.TopLeft()); + + // when entering into control area save current pointer style + // and set pointer style to arrow + if (!eDocPointerStyle) + { + eDocPointerStyle = rMainWindow.GetPointer(); + rMainWindow.SetPointer(pWindow->GetPointer()); + } + + Point aControlRelativePositionHMM = aPointHmm - aControlRectHMM.TopLeft(); + Point aControlRelativePosition = o3tl::convert( + aControlRelativePositionHMM, o3tl::Length::mm100, o3tl::Length::px); + + LokMouseEventData aMouseEventData(nType, aControlRelativePosition, nCount, + MouseEventModifiers::SIMPLECLICK, + nButtons, nModifier); + SfxLokHelper::postMouseEventAsync(pWindow, aMouseEventData); + return true; + } + } + } + } + + // when exiting from control area restore document pointer style + if (eDocPointerStyle) + { + rMainWindow.SetPointer(*eDocPointerStyle); + eDocPointerStyle.reset(); + } + return false; + } + + static void drawUnoControl(const SdrView* pDrawView, const SdrUnoObj* pUnoObect, + vcl::Window const& rMainWindow, VirtualDevice& rDevice, + tools::Rectangle const& rTileRectHMM, double scaleX, double scaleY) + { + css::uno::Reference<css::awt::XControl> xControl + = pUnoObect->GetUnoControl(*pDrawView, *rMainWindow.GetOutDev()); + if (!xControl.is()) + return; + + css::uno::Reference<css::awt::XWindow> xControlWindow(xControl, css::uno::UNO_QUERY); + if (!xControlWindow.is()) + return; + + css::uno::Reference<css::awt::XGraphics> xGraphics(rDevice.CreateUnoGraphics()); + if (!xGraphics.is()) + return; + + css::uno::Reference<css::awt::XView> xControlView(xControl, css::uno::UNO_QUERY); + if (!xControlView.is()) + return; + + o3tl::Length eControlUnitLength = MapToO3tlLength(rMainWindow.GetMapMode().GetMapUnit()); + tools::Rectangle aControlRect = pUnoObect->GetLogicRect(); + tools::Rectangle aObjectRectHMM + = o3tl::convert(aControlRect, eControlUnitLength, o3tl::Length::mm100); + tools::Rectangle aControltRectPx + = o3tl::convert(aObjectRectHMM, o3tl::Length::mm100, o3tl::Length::px); + + Point aOffsetFromTile(aObjectRectHMM.Left() - rTileRectHMM.Left(), + aObjectRectHMM.Top() - rTileRectHMM.Top()); + tools::Rectangle aRectangleHMM(aOffsetFromTile, aObjectRectHMM.GetSize()); + tools::Rectangle aRectanglePx + = o3tl::convert(aRectangleHMM, o3tl::Length::mm100, o3tl::Length::px); + + xControlWindow->setPosSize(aControltRectPx.Left(), aControltRectPx.Top(), + aRectanglePx.GetWidth(), aRectanglePx.GetHeight(), + css::awt::PosSize::POSSIZE); + + xControlView->setGraphics(xGraphics); + // required for getting text label rendered with the correct scale + xControlView->setZoom(1, 1); + + xControlView->draw(aRectanglePx.Left() * scaleX, aRectanglePx.Top() * scaleY); + } + + static void paintControlTile(const SdrPage* pPage, const SdrView* pDrawView, + vcl::Window const& rMainWindow, VirtualDevice& rDevice, + Size aOutputSize, tools::Rectangle const& rTileRect) + { + tools::Rectangle aTileRectHMM + = o3tl::convert(rTileRect, o3tl::Length::twip, o3tl::Length::mm100); + + // Resizes the virtual device so to contain the entries context + rDevice.SetOutputSizePixel(aOutputSize); + + rDevice.Push(vcl::PushFlags::MAPMODE); + MapMode aDeviceMapMode(rDevice.GetMapMode()); + + const Fraction scale = conversionFract(o3tl::Length::px, o3tl::Length::twip); + Fraction scaleX = Fraction(aOutputSize.Width(), rTileRect.GetWidth()) * scale; + Fraction scaleY = Fraction(aOutputSize.Height(), rTileRect.GetHeight()) * scale; + aDeviceMapMode.SetScaleX(scaleX); + aDeviceMapMode.SetScaleY(scaleY); + aDeviceMapMode.SetMapUnit(MapUnit::MapPixel); + rDevice.SetMapMode(aDeviceMapMode); + + o3tl::Length eControlUnitLength = MapToO3tlLength(rMainWindow.GetMapMode().GetMapUnit()); + SdrObjListIter aIterator(pPage, SdrIterMode::Flat); + + while (aIterator.IsMore()) + { + SdrObject* pObject = aIterator.Next(); + SdrUnoObj* pUnoObect = dynamic_cast<SdrUnoObj*>(pObject); + if (pUnoObect) + { + tools::Rectangle aControlRect = pUnoObect->GetLogicRect(); + tools::Rectangle aObjectRectHMM + = o3tl::convert(aControlRect, eControlUnitLength, o3tl::Length::mm100); + + // Check if we intersect with the tile rectangle and we + // need to draw the control. + if (aObjectRectHMM.Overlaps(aTileRectHMM)) + { + drawUnoControl(pDrawView, pUnoObect, rMainWindow, rDevice, aTileRectHMM, + double(scaleX), double(scaleY)); + } + } + } + + rDevice.Pop(); + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/Metadatable.hxx b/include/sfx2/Metadatable.hxx new file mode 100644 index 0000000000..ffd9b616e6 --- /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 SAL_LOPLUGIN_ANNOTATE("crosscast") 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 0000000000..2d800be80d --- /dev/null +++ b/include/sfx2/QuerySaveDocument.hxx @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_QUERYSAVEDOCUMENT_HXX +#define INCLUDED_SFX2_QUERYSAVEDOCUMENT_HXX + +#include <sal/config.h> + +#include <string_view> + +#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, std::u16string_view _rTitle); + +#endif // INCLUDED_SFX2_QUERYSAVEDOCUMENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/StyleManager.hxx b/include/sfx2/StyleManager.hxx new file mode 100644 index 0000000000..1c19b981d6 --- /dev/null +++ b/include/sfx2/StyleManager.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SFX2_STYLEMANAGER_HXX +#define INCLUDED_SFX2_STYLEMANAGER_HXX + +#include <sfx2/dllapi.h> + +#include <svl/style.hxx> +#include <tools/long.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(std::u16string_view rStyleName, SfxStyleFamily eFamily); + + virtual std::unique_ptr<StylePreviewRenderer> CreateStylePreviewRenderer( + OutputDevice& rOutputDev, SfxStyleSheetBase* pStyle, + tools::Long nMaxHeight) = 0; +}; + +} // end namespace sfx2 + +#endif //INCLUDED_SFX2_STYLEMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/StylePreviewRenderer.hxx b/include/sfx2/StylePreviewRenderer.hxx new file mode 100644 index 0000000000..1692182bd1 --- /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; + tools::Long mnMaxHeight; + +public: + enum class RenderAlign + { + TOP, CENTER + }; + + StylePreviewRenderer(const SfxObjectShell& rShell, + OutputDevice& rOutputDev, + SfxStyleSheetBase* pStyle, + tools::Long nMaxHeight) + : mrShell(rShell) + , mrOutputDev(rOutputDev) + , mpStyle(pStyle) + , mnMaxHeight(nMaxHeight) + {} + + virtual ~StylePreviewRenderer() + {} + + virtual bool recalculate() = 0; + virtual bool render(const tools::Rectangle& aRectangle, RenderAlign eRenderAlign = RenderAlign::CENTER) = 0; +}; + +} // end namespace sfx2 + +#endif // INCLUDED_SVX_STYLEPREVIEWRENDERER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/XmlIdRegistry.hxx b/include/sfx2/XmlIdRegistry.hxx new file mode 100644 index 0000000000..494c830208 --- /dev/null +++ b/include/sfx2/XmlIdRegistry.hxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SFX2_XMLIDREGISTRY_HXX +#define INCLUDED_SFX2_XMLIDREGISTRY_HXX + +#include <sal/config.h> + +#include <string_view> + +#include <sfx2/dllapi.h> + +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(std::u16string_view i_rIdref); + +bool SFX2_DLLPUBLIC isValidXmlId(std::u16string_view i_rStreamName, + std::u16string_view i_rIdref); + +// XML ID handling --------------------------------------------------- + +/** interface for getElementByMetadataReference; + for use by sfx2::DocumentMetadataAccess + */ +class SFX2_DLLPUBLIC IXmlIdRegistry +{ + +public: + virtual ~IXmlIdRegistry() { } + + virtual css::uno::Reference< css::rdf::XMetadatable > + GetElementByMetadataReference( + const css::beans::StringPair & i_rXmlId) const = 0; + +}; + +} // namespace sfx2 + +#endif // INCLUDED_SFX2_XMLIDREGISTRY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/app.hxx b/include/sfx2/app.hxx new file mode 100644 index 0000000000..96bce367fd --- /dev/null +++ b/include/sfx2/app.hxx @@ -0,0 +1,239 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <comphelper/errcode.hxx> +#include <svl/poolitem.hxx> +#include <vcl/bitmapex.hxx> +#include <tools/link.hxx> +#include <com/sun/star/ui/XAcceleratorConfiguration.hpp> +#include <unordered_map> + +#include <sfx2/shell.hxx> + +namespace com::sun::star::frame { class XFrame; } +namespace com::sun::star::script { class XLibraryContainer; } + +namespace weld { class Window; } + +class BasicManager; +class DdeService; +class SfxAppData_Impl; +class SfxDispatcher; +class SfxEventHint; +class SfxItemSet; +class SfxObjectShell; +class SfxObjectShellLock; +class SfxProgress; +class SfxSlotPool; +class SfxViewFrame; +class StarBASIC; +class SfxWorkWindow; +class SfxFilterMatcher; +class SfxModule; +struct SfxChildWinFactory; +struct SfxStbCtrlFactory; +struct SfxTbxCtrlFactory; +class SbxArray; +class SbxValue; + +namespace sfx2 +{ + namespace sidebar { + class Theme; + } +} + +enum class SfxToolsModule +{ + Math = 0, + Calc = 1, + Draw = 2, + Writer = 3, + Basic = 4, + LAST = Basic +}; + +class SFX2_DLLPUBLIC SfxLinkItem final : public SfxPoolItem +{ + Link<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 bool DdeExecute( const OUString& rCmd ); +#endif + bool InitializeDde(); + const DdeService* GetDdeService() const; + DdeService* GetDdeService(); +#if defined(_WIN32) + void AddDdeTopic( SfxObjectShell* ); +#endif + void RemoveDdeTopic( SfxObjectShell const * ); + + // "static" methods + /** + * @param pArgs Takes ownership + */ + ErrCodeMsg LoadTemplate( SfxObjectShellLock& xDoc, const OUString& rFileName, std::unique_ptr<SfxItemSet> pArgs ); + weld::Window* GetTopWindow() const; + + // members + SfxFilterMatcher& GetFilterMatcher(); + SfxProgress* GetProgress() const; + sal_uInt16 GetFreeIndex(); + void ReleaseIndex(sal_uInt16 i); + + // Basic/Scripting + static bool IsXScriptURL( const OUString& rScriptURL ); + static OUString ChooseScript(weld::Window *pParent); + // if xDocFrame is present, then select that document in the macro organizer by default, otherwise it is typically "Application Macros" + // that is preselected + static void MacroOrganizer(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 nTabId); + static ErrCode CallBasic( const OUString&, BasicManager*, SbxArray *pArgs, SbxValue *pRet ); + static ErrCode CallAppBasic( const OUString& i_macroName ) + { return CallBasic( i_macroName, SfxApplication::GetBasicManager(), nullptr, nullptr ); } + static BasicManager* GetBasicManager(); + css::script::XLibraryContainer * GetDialogContainer(); + css::script::XLibraryContainer * GetBasicContainer(); + static StarBASIC* GetBasic(); + void SaveBasicAndDialogContainer() const; + + // misc. + static void GetOptions(SfxItemSet &); + static 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 Initialize_Impl(); + + SAL_DLLPRIVATE SfxAppData_Impl* Get_Impl() const { return pImpl.get(); } + + // Object-Factories/global arrays + SAL_DLLPRIVATE void RegisterChildWindow_Impl(SfxModule*, const SfxChildWinFactory&); + SAL_DLLPRIVATE void RegisterStatusBarControl_Impl(SfxModule*, const SfxStbCtrlFactory&); + SAL_DLLPRIVATE void RegisterToolBoxControl_Impl( SfxModule*, const SfxTbxCtrlFactory&); + SAL_DLLPRIVATE SfxTbxCtrlFactory* GetTbxCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const; + SAL_DLLPRIVATE SfxStbCtrlFactory* GetStbCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const; + SAL_DLLPRIVATE SfxChildWinFactory* GetChildWinFactoryById(sal_uInt16 nId) const; + SAL_DLLPRIVATE std::vector<SfxViewFrame*>& GetViewFrames_Impl() const; + SAL_DLLPRIVATE std::vector<SfxViewShell*>& GetViewShells_Impl() const; + /* unordered_map<ModuleName+Language, acceleratorConfigurationClassInstance> */ + SAL_DLLPRIVATE std::unordered_map<OUString, css::uno::Reference<css::ui::XAcceleratorConfiguration>>& GetAcceleratorConfs_Impl() const; + SAL_DLLPRIVATE std::vector<SfxObjectShell*>& GetObjectShells_Impl() const; + SAL_DLLPRIVATE void SetViewFrame_Impl(SfxViewFrame *pViewFrame); + + // Slot Methods + // TODO/CLEANUP: still needed? + SAL_DLLPRIVATE void NewDocDirectExec_Impl(SfxRequest &); + SAL_DLLPRIVATE static void NewDocDirectState_Impl(SfxItemSet &); + SAL_DLLPRIVATE void NewDocExec_Impl(SfxRequest &); + SAL_DLLPRIVATE void OpenDocExec_Impl(SfxRequest &); + SAL_DLLPRIVATE void OpenRemoteExec_Impl(SfxRequest &); + SAL_DLLPRIVATE void SignPDFExec_Impl(SfxRequest&); + SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &); + SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &); + SAL_DLLPRIVATE static void PropExec_Impl(SfxRequest const &); + SAL_DLLPRIVATE static void PropState_Impl(SfxItemSet &); + SAL_DLLPRIVATE void OfaExec_Impl(SfxRequest &); + SAL_DLLPRIVATE static void OfaState_Impl(SfxItemSet &); + + SAL_DLLPRIVATE void SetProgress_Impl(SfxProgress *); + SAL_DLLPRIVATE const OUString& GetLastDir_Impl() const; + SAL_DLLPRIVATE void SetLastDir_Impl( const OUString & ); + + SAL_DLLPRIVATE static void Registrations_Impl(); + SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl(const SfxViewFrame *pFrame) const; + + // TODO/CLEANUP: still needed? -- unclear whether this comment + // refers to the GetDisabledSlotList_Impl() method which was + // already removed, or the below methods? + SAL_DLLPRIVATE SfxSlotPool& GetAppSlotPool_Impl() const; + SAL_DLLPRIVATE static SfxModule* GetModule_Impl(); + + static void SetModule(SfxToolsModule nSharedLib, std::unique_ptr<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(tools::Long nWidth); + + /** if true then dialog/infobar notifications like the tip of the day or + version change infobar should be suppressed */ + static bool IsHeadlessOrUITest(); + + static bool IsTipOfTheDayDue(); + + /** this Theme contains Images so must be deleted before DeInitVCL */ + sfx2::sidebar::Theme & GetSidebarTheme(); +}; + +inline SfxApplication* SfxGetpApp() +{ + return SfxApplication::Get(); +} + +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx new file mode 100644 index 0000000000..e182b9aa77 --- /dev/null +++ b/include/sfx2/basedlgs.hxx @@ -0,0 +1,141 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <vcl/weld.hxx> + +class SfxTabPage; +class SfxBindings; +class SfxChildWindow; +struct SfxChildWinInfo; +class SfxItemSet; +struct WhichRangesContainer; + +class SFX2_DLLPUBLIC SfxDialogController : public weld::GenericDialogController +{ +private: + DECL_DLLPRIVATE_STATIC_LINK(SfxDialogController, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*); + + DECL_DLLPRIVATE_LINK(FocusChangeHdl, weld::Container&, void); + +public: + SfxDialogController(weld::Widget* pParent, const OUString& rUIFile, const OUString& rDialogId); + // dialog gets focus + virtual void Activate() {} + // dialog loses focus + virtual void Deactivate() {} + + // when the dialog has an associated SfxChildWin, typically for Modeless interaction + virtual void ChildWinDispose() {} // called from the associated SfxChildWin dtor + virtual void Close(); // called by the SfxChildWin when the dialog is closed + virtual void EndDialog(int nResponse); // called by the SfxChildWin to close the dialog + virtual bool CloseOnHide() const { return true; } // called from ScValidationDlg +}; + +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 OUString& rID); + +public: + virtual ~SfxModelessDialogController() override; + + void Initialize (SfxChildWinInfo const * pInfo); + bool IsClosing() const; + virtual void Close() override; + virtual void EndDialog(int nResponse) override; + virtual void Activate() override; + virtual void Deactivate() override; + virtual void ChildWinDispose() override; + virtual void FillInfo(SfxChildWinInfo&) const; + SfxBindings& GetBindings() const { return *m_pBindings; } +}; + +typedef WhichRangesContainer (*GetTabPageRanges)(); // provides international Which values + +class SFX2_DLLPUBLIC SfxOkDialogController : public SfxDialogController +{ +public: + SfxOkDialogController(weld::Widget* pParent, const OUString& rUIXMLDescription, + const OUString& 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 OUString& rID = OUString("SingleTabDialog")); + + SfxSingleTabDialogController(weld::Widget* pParent, const SfxItemSet* pOptionsSet, + const OUString& rContainerId, const OUString& rUIXMLDescription, + const OUString& rID); + + 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 0000000000..8cd92a2410 --- /dev/null +++ b/include/sfx2/bindings.hxx @@ -0,0 +1,210 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <optional> +#include <string_view> + +#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; +class SfxPoolItemHolder; + +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 final : 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 SfxPoolItemHolder Execute_Impl( sal_uInt16 nSlot, const SfxPoolItem **pArgs, sal_uInt16 nModi, + SfxCallMode nCall, const SfxPoolItem **pInternalArgs, bool bGlobalOnly=false); + SAL_DLLPRIVATE void SetSubBindings_Impl( SfxBindings* ); + SAL_DLLPRIVATE void UpdateSlotServer_Impl(); // Update SlotServer + SAL_DLLPRIVATE std::optional<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 ); + template<class T> + SfxItemState QueryState( TypedWhichId<T> nSID, std::unique_ptr<T> &rpState ) + { + std::unique_ptr<SfxPoolItem> tmp; + auto ret = QueryState(sal_uInt16(nSID), tmp); + rpState.reset(static_cast<T*>(tmp.release())); + return ret; + } + + void QueryControlState ( sal_uInt16 nSID, boost::property_tree::ptree& rState ); + + sal_uInt16 QuerySlotId( const css::util::URL& aURL ); + + SfxPoolItemHolder 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( std::string_view pFile = {}, int nLine = 0); + void LeaveRegistrations( std::string_view pFile = {}, int nLine = 0 ); + void Register( SfxControllerItem& rBinding ); + void Release( SfxControllerItem& rBinding ); + SfxDispatcher* GetDispatcher() const + { return pDispatcher; } + const css::uno::Reference< css::frame::XDispatchRecorder >& GetRecorder() const; + css::uno::Reference < css::frame::XDispatch > + GetDispatch( const SfxSlot*, const css::util::URL& aURL, bool bMasterCommand ); + SAL_DLLPRIVATE void ContextChanged_Impl(); + SAL_DLLPRIVATE void Execute_Impl( SfxRequest& rReq, const SfxSlot* pSlot, SfxShell* pShell ); + SAL_DLLPRIVATE void DeleteControllers_Impl(); + SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl() { return pDispatcher; } + SAL_DLLPRIVATE void ClearCache_Impl( sal_uInt16 nSlotId ); + SAL_DLLPRIVATE void RegisterInternal_Impl( SfxControllerItem& rBinding ); + SAL_DLLPRIVATE void Register_Impl( SfxControllerItem& rBinding, bool ); + SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl() const; + SAL_DLLPRIVATE void SetWorkWindow_Impl( std::unique_ptr<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( Concat2View(OString::Concat(__FILE__) + "(" + OString::number(reinterpret_cast<sal_Int64>(this)) + ")"), __LINE__ ) +#define DLEAVEREGISTRATIONS( ) \ + LeaveRegistrations( Concat2View(OString::Concat(__FILE__) + "(" + OString::number(reinterpret_cast<sal_Int64>(this)) + ")"), __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 0000000000..37c98540a6 --- /dev/null +++ b/include/sfx2/brokenpackageint.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SFX2_BROKENPACKAGEINT_HXX +#define INCLUDED_SFX2_BROKENPACKAGEINT_HXX + +#include <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() const; +}; + +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() const; +}; + +#endif // INCLUDED_SFX2_BROKENPACKAGEINT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/chalign.hxx b/include/sfx2/chalign.hxx new file mode 100644 index 0000000000..d63646ea1c --- /dev/null +++ b/include/sfx2/chalign.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_CHALIGN_HXX +#define INCLUDED_SFX2_CHALIGN_HXX + +// New order: first, navigation bar, then vertically docked child windows +// (Explorer!), then horizontally docked child windows (Browser!), +// then the format bar, status bar, and at the end of the toolbar. + +enum class SfxChildAlignment +{ + HIGHESTTOP, // for example Navigation bar + LOWESTBOTTOM, + FIRSTLEFT, + LASTRIGHT, + LEFT, // for example SplitWindow + RIGHT, + LASTLEFT, + FIRSTRIGHT, + TOP, // for example Hyperlink-Builder, SplitWindow + BOTTOM, // for example SplitWindow + TOOLBOXTOP, // for example Object bar + TOOLBOXBOTTOM, + LOWESTTOP, // for example Calc bar + HIGHESTBOTTOM, // for example Status bar + TOOLBOXLEFT, // for example Tool bar + TOOLBOXRIGHT, + NOALIGNMENT // all FloatingWindows +}; + +// Verifies that a valid alignment is used +inline bool SfxChildAlignValid( SfxChildAlignment eAlign ) +{ + return ( eAlign >= SfxChildAlignment::HIGHESTTOP && eAlign <= SfxChildAlignment::NOALIGNMENT ); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/charwin.hxx b/include/sfx2/charwin.hxx new file mode 100644 index 0000000000..f8e4d662cf --- /dev/null +++ b/include/sfx2/charwin.hxx @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SFX2_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> +#include <deque> + +class SFX2_DLLPUBLIC SvxCharView final : public weld::CustomWidgetController +{ +private: + VclPtr<VirtualDevice> mxVirDev; + tools::Long mnY; + vcl::Font maFont; + bool maHasInsert; + OUString m_sText; + + Link<SvxCharView*, void> maFocusInHdl; + 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 OUString RequestHelp(tools::Rectangle&rHelpRect) override; + virtual bool KeyInput(const KeyEvent&) override; + virtual bool Command(const CommandEvent&) override; + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + bool GetDecimalValueAndCharName(sal_UCS4& rDecimalValue, OUString& rCharName); +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; } + OUString GetCharInfoText(); + void SetHasInsert( bool bInsert ); + void InsertCharToDoc(); + + void createContextMenu(const Point& rPosition); + + Size get_preferred_size() const { return GetDrawingArea()->get_preferred_size(); } + + void setFocusInHdl(const Link<SvxCharView*,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(std::u16string_view rIdent); +}; + +class SFX2_DLLPUBLIC SfxCharmapContainer +{ + std::deque<OUString> m_aRecentCharList; + std::deque<OUString> m_aRecentCharFontList; + std::deque<OUString> m_aFavCharList; + std::deque<OUString> m_aFavCharFontList; + + SvxCharView m_aRecentCharView[16]; + SvxCharView m_aFavCharView[16]; + std::unique_ptr<weld::CustomWeld> m_xRecentCharView[16]; + std::unique_ptr<weld::CustomWeld> m_xFavCharView[16]; + + std::unique_ptr<weld::Widget> m_xRecentGrid; + std::unique_ptr<weld::Widget> m_xFavGrid; + + Link<void*, void> m_aUpdateFavHdl; + Link<void*, void> m_aUpdateRecentHdl; + + DECL_DLLPRIVATE_LINK(RecentClearClickHdl, SvxCharView*, void); + DECL_DLLPRIVATE_LINK(FavClearClickHdl, SvxCharView*, void); + DECL_DLLPRIVATE_LINK(RecentClearAllClickHdl, SvxCharView*, void); + DECL_DLLPRIVATE_LINK(FavClearAllClickHdl, SvxCharView*, void); + +public: + SfxCharmapContainer(weld::Builder& rBuilder, const VclPtr<VirtualDevice>& rVirDev, bool bLockGridSizes); + + void init(bool bHasInsert, const Link<SvxCharView*,void> &rMouseClickHdl, + const Link<void*,void> &rUpdateFavHdl, + const Link<void*,void> &rUpdateRecentHdl, + const Link<SvxCharView *,void> &rFocusInHdl = Link<SvxCharView *,void>()); + + void getFavCharacterList(); + void updateFavCharControl(); + + void getRecentCharacterList(); //gets both recent char and recent char font list + void updateRecentCharControl(); + + void updateRecentCharacterList(const OUString& sTitle, const OUString& rFont); + void updateFavCharacterList(const OUString& sTitle, const OUString& rFont); + void deleteFavCharacterFromList(std::u16string_view sTitle, std::u16string_view rFont); + + bool isFavChar(std::u16string_view sTitle, std::u16string_view rFont); + bool hasRecentChars() const; + + bool FavCharListIsFull() const; + + void GrabFocusToFirstFavorite(); + +private: + std::pair<std::deque<OUString>::const_iterator, std::deque<OUString>::const_iterator> + getRecentChar(std::u16string_view sTitle, std::u16string_view rFont) const; + + std::pair<std::deque<OUString>::const_iterator, std::deque<OUString>::const_iterator> + getFavChar(std::u16string_view sTitle, std::u16string_view rFont) const; +}; + +#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 0000000000..57c2369233 --- /dev/null +++ b/include/sfx2/childwin.hxx @@ -0,0 +1,235 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_CHILDWIN_HXX +#define INCLUDED_SFX2_CHILDWIN_HXX + +#include <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 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 +{ + OUString aExtraString; + OUString aModule; + OUString aWinState; + Point aPos; + Size aSize; + SfxChildWindowFlags nFlags; + bool bVisible; + + SfxChildWinInfo() + { + bVisible = false; + nFlags = SfxChildWindowFlags::NONE; + } + bool GetExtraData_Impl( SfxChildAlignment *pAlign ) const; +}; + +// ChildWindow factory methods +typedef std::unique_ptr<SfxChildWindow> (*SfxChildWinCtor)( vcl::Window *pParentWindow, + sal_uInt16 nId, + SfxBindings *pBindings, + SfxChildWinInfo *pInfo); + +struct SFX2_DLLPUBLIC SfxChildWinFactory +{ + SfxChildWinCtor pCtor; // Factory method + SfxChildWinInfo aInfo; // Configuration + sal_uInt16 nId; // ChildWindow-Id ( SlotId ) + sal_uInt16 nPos; // Position in UI + + SfxChildWinFactory( SfxChildWinCtor pTheCtor, sal_uInt16 nID, sal_uInt16 n ); +}; + +struct SfxChildWindow_Impl; + +extern SFX2_DLLPUBLIC bool ParentIsFloatingWindow(const vcl::Window *pParent); + +class SFX2_DLLPUBLIC SfxChildWindow +{ + VclPtr<vcl::Window> pParent; // parent window ( Topwindow ) + VclPtr<vcl::Window> pWindow; // actual contents + std::unique_ptr< SfxChildWindow_Impl> pImpl; // Implementation data + std::shared_ptr<SfxDialogController> xController; // actual contents + SfxChildAlignment eChildAlignment; // Current css::drawing::Alignment + // Another window in pWindow + sal_uInt16 nType; // ChildWindow-Id + SAL_DLLPRIVATE void ClearWorkwin(); + +protected: + void SetWindow(const VclPtr<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; } + + virtual SfxChildWinInfo GetInfo() const; + void SaveStatus(const SfxChildWinInfo& rInfo); + + static void RegisterChildWindow(SfxModule*, const 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 void SetFactory_Impl( const SfxChildWinFactory* ); +}; + +const int nCloseResponseToJustHide = -42; + +#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) \ + { \ + SfxChildWinFactory aFact( \ + Class::CreateImpl, MyID, Pos ); \ + aFact.aInfo.nFlags |= nFlags; \ + aFact.aInfo.bVisible = bVis; \ + SfxChildWindow::RegisterChildWindow(pMod, aFact); \ + } + +#define SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, Pos) \ + SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \ + sal_uInt16 Class::GetChildWindowId () \ + { return MyID; } \ + +#define SFX_IMPL_MODELESSDIALOGCONTOLLER(Class, MyID) \ + SFX_IMPL_CHILDWINDOW(Class, MyID) \ + SfxChildWinInfo Class::GetInfo() const \ + { \ + SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \ + static_cast<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( std::u16string_view rStr, Point& rPos, Size& rSize ); + +bool GetSplitSizeFromString( std::u16string_view rStr, Size& rSize ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx new file mode 100644 index 0000000000..5a4fa6b1ee --- /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 <string_view> +#include <vector> + +#include <o3tl/string_view.hxx> +#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(std::u16string_view 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(std::u16string_view rType); + /// Returns the string representation of a SfxClassificationPolicyType element. + static const OUString& policyTypeToString(SfxClassificationPolicyType eType); + + /// Brief text located at the top of each document's pages. + static const OUString& PROP_DOCHEADER(); + /// Brief text located at the bottom of each document's pages. + static const OUString& PROP_DOCFOOTER(); + /// Brief text formatted as a watermark on each document's page. + static const OUString& PROP_DOCWATERMARK(); + /// Get the property prefix for the IntellectualProperty policy type. + static const OUString& PROP_PREFIX_INTELLECTUALPROPERTY(); + + static SfxClassificationPolicyType getPolicyType(); +}; + +namespace sfx +{ +/// Specifies the origin: either defined by the BAF policy or manual via. the advanced classification dialog +enum class ClassificationCreationOrigin +{ + NONE, + BAF_POLICY, + MANUAL +}; + +class ClassificationKeyCreator +{ +private: + const SfxClassificationPolicyType m_ePolicyType; + const OUString m_sPolicy; + sal_Int32 m_nTextNumber; + sal_Int32 m_nIPPartNumber; + sal_Int32 m_nMarkingNumber; + + OUString const& getPolicyKey() const { return m_sPolicy; } + +public: + ClassificationKeyCreator(SfxClassificationPolicyType ePolicyType) + : m_ePolicyType(ePolicyType) + , m_sPolicy(SfxClassificationHelper::policyTypeToString(m_ePolicyType)) + , m_nTextNumber(1) + , m_nIPPartNumber(1) + , m_nMarkingNumber(1) + { + } + + OUString makeTextKey() const { return getPolicyKey() + "Custom:Text"; } + + OUString makeNumberedTextKey() + { + return makeTextKey() + ":n" + OUString::number(m_nTextNumber++); + } + + bool isMarkingTextKey(std::u16string_view aKey) const + { + return o3tl::starts_with(aKey, makeTextKey()); + } + + OUString makeCategoryNameKey() const + { + return getPolicyKey() + "BusinessAuthorizationCategory:Name"; + } + + bool isCategoryNameKey(std::u16string_view aKey) const + { + return o3tl::starts_with(aKey, makeCategoryNameKey()); + } + + OUString makeCategoryIdentifierKey() const + { + return getPolicyKey() + "BusinessAuthorizationCategory:Identifier"; + } + + bool isCategoryIdentifierKey(std::u16string_view aKey) const + { + return o3tl::starts_with(aKey, makeCategoryIdentifierKey()); + } + + OUString makeMarkingKey() const { return getPolicyKey() + "Custom:Marking"; } + + OUString makeNumberedMarkingKey() + { + return makeMarkingKey() + ":n" + OUString::number(m_nMarkingNumber++); + } + + bool isMarkingKey(std::u16string_view aKey) const + { + return o3tl::starts_with(aKey, makeMarkingKey()); + } + + OUString makeIntellectualPropertyPartKey() const + { + return getPolicyKey() + "Custom:IntellectualPropertyPart"; + } + + OUString makeNumberedIntellectualPropertyPartKey() + { + return makeIntellectualPropertyPartKey() + ":n" + OUString::number(m_nIPPartNumber++); + } + + bool isIntellectualPropertyPartKey(std::u16string_view aKey) const + { + return o3tl::starts_with(aKey, makeIntellectualPropertyPartKey()); + } + + OUString makeFullTextualRepresentationKey() const + { + return getPolicyKey() + "Custom:FullTexturalRepresentation"; + } + + /// Classification creation origin key + OUString makeCreationOriginKey() const { return getPolicyKey() + "CreationOrigin"; } +}; + +SFX2_DLLPUBLIC sfx::ClassificationCreationOrigin getCreationOriginProperty( + css::uno::Reference<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 0000000000..03e530c782 --- /dev/null +++ b/include/sfx2/ctrlitem.hxx @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_CTRLITEM_HXX +#define INCLUDED_SFX2_CTRLITEM_HXX + +#include <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: + SfxControllerItem* pNext; // to notify next ControllerItem + SfxBindings* pBindings; + MapUnit eFallbackCoreMetric; + sal_uInt16 nId; + +public: + SfxBindings & GetBindings() { + DBG_ASSERT(pBindings, "no Bindings"); + return *pBindings; + } + const SfxBindings & GetBindings() const { + DBG_ASSERT(pBindings, "no Bindings"); + return *pBindings; + } + + SfxControllerItem(); // for arrays + SfxControllerItem( sal_uInt16 nId, SfxBindings & ); + virtual ~SfxControllerItem(); + virtual void dispose(); + + void Bind( sal_uInt16 nNewId, SfxBindings *); // Register in SfxBindings + void UnBind(); + void ReBind(); + bool IsBound() const; + void ClearCache(); + + SfxControllerItem* GetItemLink(); + SfxControllerItem* ChangeItemLink( SfxControllerItem* pNewLink ); + + void SetId( sal_uInt16 nItemId ); + sal_uInt16 GetId() const { return nId; } + + virtual void StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState ); + + virtual void GetControlState( sal_uInt16 nSID, boost::property_tree::ptree& ); + + MapUnit GetCoreMetric() const; + // override what GetCoreMetric will return if it cannot determine the current CoreMetric + void SetFallbackCoreMetric(MapUnit eFallback) + { + eFallbackCoreMetric = eFallback; + } + + static SfxItemState GetItemState( const SfxPoolItem* pState ); + + SAL_DLLPRIVATE void BindInternal_Impl( sal_uInt16 nNewId, SfxBindings* ); +}; + + +class SFX2_DLLPUBLIC SfxStatusForwarder final : public SfxControllerItem +{ + SfxControllerItem* pMaster; + + virtual void StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState ) override; + +public: + SfxStatusForwarder( sal_uInt16 nSlotId, + SfxControllerItem&rMaster ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/devtools/DevelopmentToolChildWindow.hxx b/include/sfx2/devtools/DevelopmentToolChildWindow.hxx new file mode 100644 index 0000000000..d78ac5c2e2 --- /dev/null +++ b/include/sfx2/devtools/DevelopmentToolChildWindow.hxx @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include <sfx2/dllapi.h> +#include <sfx2/childwin.hxx> + +/** + * Necessary child window for the development tools docking window + */ +class SAL_WARN_UNUSED SFX2_DLLPUBLIC DevelopmentToolChildWindow final : public SfxChildWindow +{ + SFX_DECL_CHILDWINDOW_WITHID(DevelopmentToolChildWindow); + + DevelopmentToolChildWindow(vcl::Window* pParentWindow, sal_uInt16 nId, SfxBindings* pBindings, + SfxChildWinInfo* pInfo); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx b/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx new file mode 100644 index 0000000000..de576e797a --- /dev/null +++ b/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include <sfx2/dllapi.h> +#include <sfx2/dockwin.hxx> +#include <vcl/weld.hxx> + +#include <sfx2/devtools/ObjectInspectorWidgets.hxx> +#include <sfx2/devtools/DocumentModelTreeHandler.hxx> +#include <sfx2/devtools/ObjectInspectorTreeHandler.hxx> + +#include <com/sun/star/uno/XInterface.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/view/XSelectionChangeListener.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> + +/** Development tool main docking window + * + * Contains two sides. Left side contains the simplified DOM tree and + * the right side the object inspector tree. + */ +class SFX2_DLLPUBLIC DevelopmentToolDockingWindow final : public SfxDockingWindow +{ +private: + std::unique_ptr<ObjectInspectorWidgets> mpObjectInspectorWidgets; + std::unique_ptr<weld::TreeView> mpDocumentModelTreeView; + std::unique_ptr<weld::Toolbar> mpDomToolbar; + + // Reference to the root object for the current document + css::uno::Reference<css::uno::XInterface> mxRoot; + // Stores the current selected object in the document + css::uno::Reference<css::uno::XInterface> mxCurrentSelection; + css::uno::Reference<css::view::XSelectionChangeListener> mxSelectionListener; + css::uno::Reference<css::view::XSelectionSupplier> mxSelectionSupplier; + + // Handler for the DOM tree + DocumentModelTreeHandler maDocumentModelTreeHandler; + // Handler for the object inspector tree + ObjectInspectorTreeHandler maObjectInspectorTreeHandler; + + DECL_DLLPRIVATE_LINK(DocumentModelTreeViewSelectionHandler, weld::TreeView&, void); + DECL_DLLPRIVATE_LINK(DomToolbarButtonClicked, const OUString&, void); + + void updateSelection(); + +public: + DevelopmentToolDockingWindow(SfxBindings* pBindings, SfxChildWindow* pChildWindow, + vcl::Window* pParent); + + virtual ~DevelopmentToolDockingWindow() override; + + void dispose() override; + + void ToggleFloatingMode() override; + + // Signals that the selected object in the document changes + void selectionChanged(css::uno::Reference<css::uno::XInterface> const& xInterface); + + // Signals to change to the current selected object in the object inspector + void changeToCurrentSelection(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/devtools/DocumentModelTreeHandler.hxx b/include/sfx2/devtools/DocumentModelTreeHandler.hxx new file mode 100644 index 0000000000..f26af793c9 --- /dev/null +++ b/include/sfx2/devtools/DocumentModelTreeHandler.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include <vcl/weld.hxx> + +#include <com/sun/star/uno/XInterface.hpp> +#include <com/sun/star/uno/Reference.hxx> + +/** Document model tree handler + * + * Handles the DOM tree part of DevTools, which includes interaction with + * the DOM tree view UI elements and the DOM model. + */ +class DocumentModelTreeHandler +{ +private: + std::unique_ptr<weld::TreeView>& mpDocumentModelTree; + css::uno::Reference<css::uno::XInterface> mxDocument; + + // Clears all children of a tree node, where the parent is + // identified by the input tree iter. + void clearChildren(weld::TreeIter const& rParent); + + // Clear all tree view nodes. + void clearAll(); + +public: + DocumentModelTreeHandler(std::unique_ptr<weld::TreeView>& pDocumentModelTree, + css::uno::Reference<css::uno::XInterface> xDocument); + + DECL_LINK(ExpandingHandler, const weld::TreeIter&, bool); + + void inspectDocument(); + + static css::uno::Reference<css::uno::XInterface> getObjectByID(OUString const& rID); + + void dispose(); + + // selects the input object if it exists in the DOM tree view + void selectObject(css::uno::Reference<css::uno::XInterface> const& xInterface); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/devtools/ObjectInspectorTreeHandler.hxx b/include/sfx2/devtools/ObjectInspectorTreeHandler.hxx new file mode 100644 index 0000000000..f4d460a2bf --- /dev/null +++ b/include/sfx2/devtools/ObjectInspectorTreeHandler.hxx @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include <vcl/weld.hxx> +#include <vcl/commandevent.hxx> +#include <comphelper/string.hxx> + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/XInterface.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <sfx2/devtools/ObjectInspectorWidgets.hxx> + +#include <memory> +#include <deque> + +/** Object inspector tree handler + * + * Handles the object inspector part of DevTools - mainly interaction + * between UI objects that consist of the object inspector. + * + */ +class ObjectInspectorTreeHandler +{ +private: + std::unique_ptr<ObjectInspectorWidgets>& mpObjectInspectorWidgets; + + // object stack to remember previously inspected objects so it is + // possible to return back to them + std::deque<css::uno::Any> maInspectionStack; + + // just the current context + css::uno::Reference<css::uno::XComponentContext> mxContext; + + // treeview sort and compare + comphelper::string::NaturalStringSorter mxSorter; + void setSortFunction(std::unique_ptr<weld::TreeView>& pTreeView); + sal_Int32 compare(std::unique_ptr<weld::TreeView>& pTreeView, const weld::TreeIter& rLeft, + const weld::TreeIter& rRight); + + // treeview manipulation + static void clearObjectInspectorChildren(std::unique_ptr<weld::TreeView>& pTreeView, + weld::TreeIter const& rParent); + static void handleExpanding(std::unique_ptr<weld::TreeView>& pTreeView, + weld::TreeIter const& rParent); + static void clearAll(std::unique_ptr<weld::TreeView>& pTreeView); + + void appendInterfaces(css::uno::Reference<css::uno::XInterface> const& xInterface); + void appendServices(css::uno::Reference<css::uno::XInterface> const& xInterface); + void appendProperties(css::uno::Reference<css::uno::XInterface> const& xInterface); + void appendMethods(css::uno::Reference<css::uno::XInterface> const& xInterface); + + void inspectObject(css::uno::Reference<css::uno::XInterface> const& xInterface); + + // Object stack handling + void clearStack(); + void addToStack(css::uno::Any const& rAny); + css::uno::Any popFromStack(); + + void updateBackButtonState(); + +public: + ObjectInspectorTreeHandler(std::unique_ptr<ObjectInspectorWidgets>& pObjectInspectorWidgets); + + // callbacks when a node in the tree view is expanded + DECL_LINK(ExpandingHandlerInterfaces, const weld::TreeIter&, bool); + DECL_LINK(ExpandingHandlerServices, const weld::TreeIter&, bool); + DECL_LINK(ExpandingHandlerProperties, const weld::TreeIter&, bool); + DECL_LINK(ExpandingHandlerMethods, const weld::TreeIter&, bool); + + // callback when the tree view selection changed to a different node + DECL_LINK(SelectionChanged, weld::TreeView&, void); + + // callback when a pop-up is triggered on a tree view node + DECL_LINK(PopupMenuHandler, const CommandEvent&, bool); + + // callback when a button is clicked on a toolbar + DECL_LINK(ToolbarButtonClicked, const OUString&, void); + + // callback when a page is entered or left on the notebook bar for + // different categories + DECL_LINK(NotebookEnterPage, const OUString&, void); + DECL_LINK(NotebookLeavePage, const OUString&, bool); + + DECL_LINK(HeaderBarClick, int, void); + + void introspect(css::uno::Reference<css::uno::XInterface> const& xInterface); + + void dispose(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/devtools/ObjectInspectorWidgets.hxx b/include/sfx2/devtools/ObjectInspectorWidgets.hxx new file mode 100644 index 0000000000..9c719d2aab --- /dev/null +++ b/include/sfx2/devtools/ObjectInspectorWidgets.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include <vcl/weld.hxx> + +struct ObjectInspectorWidgets +{ + ObjectInspectorWidgets(const std::unique_ptr<weld::Builder>& rxBuilder) + : mpClassNameLabel(rxBuilder->weld_label("class_name_value_id")) + , mpInterfacesTreeView(rxBuilder->weld_tree_view("interfaces_treeview_id")) + , mpServicesTreeView(rxBuilder->weld_tree_view("services_treeview_id")) + , mpPropertiesTreeView(rxBuilder->weld_tree_view("properties_treeview_id")) + , mpMethodsTreeView(rxBuilder->weld_tree_view("methods_treeview_id")) + , mpToolbar(rxBuilder->weld_toolbar("object_inspector_toolbar")) + , mpNotebook(rxBuilder->weld_notebook("object_inspector_notebookbar")) + , mpTextView(rxBuilder->weld_text_view("object_inspector_text_view")) + , mpPaned(rxBuilder->weld_paned("object_inspector_paned")) + { + } + + ~ObjectInspectorWidgets() + { + // dispose welded objects + mpClassNameLabel.reset(); + mpInterfacesTreeView.reset(); + mpServicesTreeView.reset(); + mpPropertiesTreeView.reset(); + mpMethodsTreeView.reset(); + mpToolbar.reset(); + mpNotebook.reset(); + mpTextView.reset(); + mpPaned.reset(); + } + + std::unique_ptr<weld::Label> mpClassNameLabel; + std::unique_ptr<weld::TreeView> mpInterfacesTreeView; + std::unique_ptr<weld::TreeView> mpServicesTreeView; + std::unique_ptr<weld::TreeView> mpPropertiesTreeView; + std::unique_ptr<weld::TreeView> mpMethodsTreeView; + std::unique_ptr<weld::Toolbar> mpToolbar; + std::unique_ptr<weld::Notebook> mpNotebook; + std::unique_ptr<weld::TextView> mpTextView; + std::unique_ptr<weld::Paned> mpPaned; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/dialoghelper.hxx b/include/sfx2/dialoghelper.hxx new file mode 100644 index 0000000000..a853d5d9de --- /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; +class OutputDevice; + +//when two tab pages both have the same basic layout with a preview on the +//right, get both of their non-preview areas to request the same size so that +//the preview appears in the same place in each one so flipping between tabs +//isn't distracting as it jumps around + +Size SFX2_DLLPUBLIC getParagraphPreviewOptimalSize(const OutputDevice& rReference); + +Size SFX2_DLLPUBLIC getDrawPreviewOptimalSize(const OutputDevice& rReference); + +Size SFX2_DLLPUBLIC getPreviewStripSize(const OutputDevice& rReference); + +Size SFX2_DLLPUBLIC getPreviewOptionsSize(const OutputDevice& rReference); + +OUString SFX2_DLLPUBLIC getWidestDateTime(const LocaleDataWrapper& rWrapper, bool bWithSec); + +OUString SFX2_DLLPUBLIC formatDateTime(const DateTime& rDateTime, const LocaleDataWrapper& rWrapper, + bool bWithSec); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/digitalsignatures.hxx b/include/sfx2/digitalsignatures.hxx new file mode 100644 index 0000000000..b46cdd52e9 --- /dev/null +++ b/include/sfx2/digitalsignatures.hxx @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/io/XStream.hpp> +#include <com/sun/star/security/XCertificate.hpp> + +#include <sal/types.h> + +namespace sfx2 +{ +/// Extension of css::security::XDocumentDigitalSignatures for internal purposes. +class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") DigitalSignatures +{ +public: + /// Same as signDocumentWithCertificate(), but passes the xModel as well. + virtual bool + SignModelWithCertificate(const css::uno::Reference<css::frame::XModel>& xModel, + const css::uno::Reference<css::security::XCertificate>& xCertificate, + const css::uno::Reference<css::embed::XStorage>& xStorage, + const css::uno::Reference<css::io::XStream>& xStream) + = 0; + +protected: + ~DigitalSignatures() noexcept = default; +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx new file mode 100644 index 0000000000..874e127f20 --- /dev/null +++ b/include/sfx2/dinfdlg.hxx @@ -0,0 +1,632 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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/numformat.hxx> +#include <svl/stritem.hxx> +#include <svtools/ctrlbox.hxx> + +#include <vcl/idle.hxx> +#include <vcl/weldutils.hxx> + +#include <sfx2/tabdlg.hxx> + +#include <optional> +#include <memory> +#include <vcl/abstdlg.hxx> + +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_Contributor; + OUString m_Coverage; + OUString m_Identifier; + OUString m_Publisher; + OUString m_Relation; + OUString m_Rights; + OUString m_Source; + OUString m_Type; + 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& getContributor() const { return m_Contributor; } + void setContributor(const OUString& i_val) { m_Contributor = i_val; } + const OUString& getCoverage() const { return m_Coverage; } + void setCoverage(const OUString& i_val) { m_Coverage = i_val; } + const OUString& getIdentifier() const { return m_Identifier; } + void setIdentifier(const OUString& i_val) { m_Identifier = i_val; } + const OUString& getPublisher() const { return m_Publisher; } + void setPublisher(const OUString& i_val) { m_Publisher = i_val; } + const OUString& getRelation() const { return m_Relation; } + void setRelation(const OUString& i_val) { m_Relation = i_val; } + const OUString& getRights() const { return m_Rights; } + void setRights(const OUString& i_val) { m_Rights = i_val; } + const OUString& getSource() const { return m_Source; } + void setSource(const OUString& i_val) { m_Source = i_val; } + const OUString& getType() const { return m_Type; } + void setType(const OUString& i_val) { m_Type = 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::LinkButton> 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; + std::unique_ptr<weld::CheckButton> m_xImagePreferredDpiCheckButton; + std::unique_ptr<weld::ComboBox> m_xImagePreferredDpiComboBox; + + DECL_LINK(DeleteHdl, weld::Button&, void); + DECL_LINK(SignatureHdl, weld::Button&, void); + DECL_LINK(ChangePassHdl, weld::Button&, void); + DECL_LINK(ImagePreferredDPICheckBoxClicked, weld::Toggleable&, void); + + void ImplUpdateSignatures(); + void ImplCheckPasswordState(); + + virtual bool FillItemSet( SfxItemSet* ) override; + virtual void Reset( const SfxItemSet* ) override; + VclPtr<AbstractPasswordToOpenModifyDialog> m_xPasswordDialog; + +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::Entry> m_xContributorEd; + std::unique_ptr<weld::Entry> m_xCoverageEd; + std::unique_ptr<weld::Entry> m_xIdentifierEd; + std::unique_ptr<weld::Entry> m_xPublisherEd; + std::unique_ptr<weld::Entry> m_xRelationEd; + std::unique_ptr<weld::Entry> m_xRightsEd; + std::unique_ptr<weld::Entry> m_xSourceEd; + std::unique_ptr<weld::Entry> m_xTypeEd; + 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 OUString& 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(); +}; + +namespace weld +{ + class TimeFormatter; +} + +class CustomPropertiesTimeField +{ +public: + std::unique_ptr<weld::FormattedSpinButton> m_xTimeField; + std::unique_ptr<weld::TimeFormatter> m_xFormatter; + bool m_isUTC; + + CustomPropertiesTimeField(std::unique_ptr<weld::FormattedSpinButton> xTimeField); + void set_visible(bool bVisible) { m_xTimeField->set_visible(bVisible); } + tools::Time get_value() const; + void set_value(const tools::Time& rTime); + + ~CustomPropertiesTimeField(); +}; + +class DurationDialog_Impl final : public weld::GenericDialogController +{ + std::unique_ptr<weld::CheckButton> m_xNegativeCB; + std::unique_ptr<weld::SpinButton> m_xYearNF; + std::unique_ptr<weld::SpinButton> m_xMonthNF; + std::unique_ptr<weld::SpinButton> m_xDayNF; + std::unique_ptr<weld::SpinButton> m_xHourNF; + std::unique_ptr<weld::SpinButton> m_xMinuteNF; + std::unique_ptr<weld::SpinButton> m_xSecondNF; + std::unique_ptr<weld::SpinButton> m_xMSecondNF; + +public: + DurationDialog_Impl(weld::Widget* pParent, const css::util::Duration& rDuration); + css::util::Duration GetDuration() const; +}; + +class CustomPropertiesDurationField +{ + css::util::Duration m_aDuration; + std::unique_ptr<weld::Entry> m_xEntry; + std::unique_ptr<weld::Button> m_xEditButton; + std::shared_ptr<DurationDialog_Impl> m_xDurationDialog; + + 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); + + ~CustomPropertiesDurationField(); +}; + +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::FormattedSpinButton> m_xTimeField; + std::unique_ptr<weld::TimeFormatter> m_xFormatter; + + 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 0000000000..7216fc92ba --- /dev/null +++ b/include/sfx2/dispatch.hxx @@ -0,0 +1,182 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <span> +#include <sal/config.h> +#include <rtl/ref.hxx> +#include <sfx2/dllapi.h> +#include <sfx2/toolbarids.hxx> +#include <sal/types.h> + +#include <sfx2/bindings.hxx> +#include <o3tl/typed_flags_set.hxx> + +#include <boost/property_tree/ptree_fwd.hpp> +#include <initializer_list> + +class SfxSlotServer; +class SfxRequest; +class SfxViewFrame; +class SfxItemSet; +class SfxModule; +class Point; +struct SfxDispatcher_Impl; +class VCLXPopupMenu; +class SfxPoolItemHolder; + +namespace com::sun::star::awt { class XPopupMenu; } +namespace vcl { class Window; } + +enum class SfxDispatcherPopFlags +{ + NONE = 0, + POP_UNTIL = 4, + POP_DELETE = 2, + PUSH = 1, +}; +namespace o3tl +{ + template<> struct typed_flags<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(); + + SfxPoolItemHolder Execute( sal_uInt16 nSlot, + SfxCallMode nCall = SfxCallMode::SLOT, + const SfxPoolItem **pArgs = nullptr, + sal_uInt16 nModi = 0, + const SfxPoolItem **pInternalArgs = nullptr); + + SfxPoolItemHolder Execute(sal_uInt16 nSlot, + SfxCallMode nCall, + SfxItemSet const * pArgs, + SfxItemSet const * pInternalArgs, + sal_uInt16 nModi); + + SfxPoolItemHolder ExecuteList(sal_uInt16 nSlot, + SfxCallMode nCall, + std::initializer_list<SfxPoolItem const*> args, + std::initializer_list<SfxPoolItem const*> internalargs = std::initializer_list<SfxPoolItem const*>()); + + SfxPoolItemHolder 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, + std::span<sal_uInt16 const> pSIDs = std::span<sal_uInt16 const>()); + + void HideUI( bool bHide = true ); + ToolbarId GetObjectBarId( sal_uInt16 nPos ) const; + + SfxItemState QueryState( sal_uInt16 nSID, SfxPoolItemHolder& rState ); + SfxItemState QueryState( sal_uInt16 nSID, css::uno::Any& rAny ); + + void SetDisableFlags( SfxDisableFlags nFlags ); + SfxDisableFlags GetDisableFlags() const; + + SAL_DLLPRIVATE void SetMenu_Impl(); + SAL_DLLPRIVATE void Update_Impl( bool bForce = false ); // ObjectBars etc. + SAL_DLLPRIVATE bool IsUpdated_Impl() const; + SAL_DLLPRIVATE bool GetShellAndSlot_Impl( sal_uInt16 nSlot, SfxShell **ppShell, const SfxSlot **ppSlot, + bool bOwnShellsOnly, bool bRealSlot ); + SAL_DLLPRIVATE void SetReadOnly_Impl( bool bOn ); + SAL_DLLPRIVATE bool GetReadOnly_Impl() const; + SAL_DLLPRIVATE SfxSlotFilterState IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const; + SAL_DLLPRIVATE void SetQuietMode_Impl( bool bOn ); + SAL_DLLPRIVATE bool IsReadOnlyShell_Impl( sal_uInt16 nShell ) const; + SAL_DLLPRIVATE void RemoveShell_Impl( SfxShell& rShell ); + SAL_DLLPRIVATE void DoActivate_Impl( bool bMDI ); + SAL_DLLPRIVATE void DoDeactivate_Impl( bool bMDI, SfxViewFrame const * pNew ); + SAL_DLLPRIVATE void InvalidateBindings_Impl(bool); + + static boost::property_tree::ptree fillPopupMenu(const rtl::Reference<VCLXPopupMenu>& rMenu); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/dllapi.h b/include/sfx2/dllapi.h new file mode 100644 index 0000000000..a6877f769b --- /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 0000000000..b3fcd63dc9 --- /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, OUString sFactoryName ); + ~SfxObjectFactory(); + + const SvGlobalName& GetClassId() const; + OUString GetFactoryURL() const; // shortcut for "private:factory/GetShortName()" + const OUString& GetFactoryName() const { return m_sFactoryName; } + OUString GetModuleName() const; + SfxFilterContainer *GetFilterContainer() const; + + // Views + void RegisterViewFactory(SfxViewFactory &rFactory); + sal_uInt16 GetViewFactoryCount() const; + SfxViewFactory& GetViewFactory(sal_uInt16 i = 0) const; + + /// returns the view factory whose GetAPIViewName or GetLegacyViewName delivers the requested logical name + SfxViewFactory* GetViewFactoryByViewName( std::u16string_view i_rViewName ) const; + + // Filter + std::shared_ptr<const SfxFilter> GetTemplateFilter() const; + static OUString GetStandardTemplate( std::u16string_view rServiceName ); + static void SetStandardTemplate( const OUString& rServiceName, const OUString& rTemplateName ); + static void SetSystemTemplate( const OUString& rServiceName, const OUString& rTemplateName ); + + void SetDocumentServiceName( const OUString& rServiceName ); + const OUString& GetDocumentServiceName() const; + + SfxModule* GetModule() const; + + SAL_DLLPRIVATE void SetModule_Impl( SfxModule* ); + SAL_DLLPRIVATE sal_uInt16 GetViewNo_Impl( const SfxInterfaceId i_nViewId, const sal_uInt16 i_nFallback ) const; + +private: + SfxObjectFactory(const SfxObjectFactory&) = delete; + const SfxObjectFactory& operator=(const SfxObjectFactory &) = delete; +}; + +#define SFX_DECL_OBJECTFACTORY() \ +public: \ + static SfxObjectFactory& Factory(); \ + virtual SfxObjectFactory& GetFactory() const override { return Factory(); } + +#define SFX_IMPL_OBJECTFACTORY(ClassName,GlobName,ShortName) \ + SfxObjectFactory& ClassName::Factory() \ + { \ + static SfxObjectFactory aObjectFactory(GlobName, ShortName); \ + return aObjectFactory; \ + } +#endif // INCLUDED_SFX2_DOCFAC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx new file mode 100644 index 0000000000..fb8039f6b8 --- /dev/null +++ b/include/sfx2/docfile.hxx @@ -0,0 +1,315 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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> +#include <mutex> + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::embed { class XStorage; } +namespace com::sun::star::graphic { class XGraphic; } +namespace com::sun::star::io { class XInputStream; } +namespace com::sun::star::security { class XCertificate; } +namespace com::sun::star::task { class XInteractionHandler; } +namespace com::sun::star::ucb { class XCommandEnvironment; } +namespace com::sun::star::ucb { class XContent; } +namespace com::sun::star::util { struct DateTime; } +namespace com::sun::star::util { struct RevisionTag; } +namespace com::sun::star::frame +{ +class XModel; +} +namespace ucbhelper { class Content; } + +class SvKeyValueIterator; +class SfxFilter; +class SfxMedium_Impl; +class INetURLObject; +class SfxFrame; +class DateTime; +struct ImplSVEvent; + +namespace weld +{ + class Window; +} + +class SFX2_DLLPUBLIC SfxMedium final : public SvRefBase +{ + std::unique_ptr< SfxMedium_Impl > pImpl; + + SAL_DLLPRIVATE void SetIsRemote_Impl(); + SAL_DLLPRIVATE void CloseInStream_Impl(bool bInDestruction = false); + SAL_DLLPRIVATE void CloseOutStream_Impl(); + SAL_DLLPRIVATE void CloseStreams_Impl(bool bInDestruction = false); + + SAL_DLLPRIVATE bool 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; + + DECL_DLLPRIVATE_STATIC_LINK(SfxMedium, ShowReloadEditableDialog, void*, void); + bool CheckCanGetLockfile() const; + void SetOriginallyReadOnly(bool val); + void AddToCheckEditableWorkerList(); + void SetWorkerReloadEvent(ImplSVEvent* pEvent); + ImplSVEvent* GetWorkerReloadEvent() const; + const std::shared_ptr<std::recursive_mutex>& GetCheckEditableMutex() const; + void CancelCheckEditableEntry(bool bRemoveEvent = true); + + void UseInteractionHandler( bool ); + css::uno::Reference< css::task::XInteractionHandler > + GetInteractionHandler( bool bGetAlways = false ); + + void setStreamToLoadFrom( + const css::uno::Reference<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); + const 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 ); + + ErrCodeMsg GetErrorCode() const; + ErrCodeMsg GetErrorIgnoreWarning() const + { return GetErrorCode().IgnoreWarning(); } + ErrCodeMsg const & GetWarningError() const; + ErrCodeMsg const & GetLastStorageCreationState() const; + + void SetError(ErrCodeMsg nError); + void SetWarningError(const ErrCodeMsg& nWarningError); + + 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 css::uno::Reference<css::embed::XStorage> GetScriptingStorageToSign_Impl(); + 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 SetInnerStorage_Impl(const css::uno::Reference<css::embed::XStorage>& xStorage); + SAL_DLLPRIVATE css::uno::Reference<css::embed::XStorage> + TryEncryptedInnerPackage(css::uno::Reference<css::embed::XStorage> xStorage); + + 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(bool bForceUsingBackupPath); + SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent ); + SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent, + std::u16string_view aPrefix, + std::u16string_view 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( + const css::uno::Reference<css::frame::XModel>& xModel, 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( std::u16string_view aURL ); + static bool CallApproveHandler(const css::uno::Reference< css::task::XInteractionHandler >& xHandler, const css::uno::Any& rRequest, bool bAllowAbort); + + static bool SetWritableForUserOnly( const OUString& aURL ); + static sal_uInt32 CreatePasswordToModifyHash( std::u16string_view aPasswd, bool bWriter ); + +private: + enum class ShowLockResult { NoLock, Succeeded, Try }; + ShowLockResult ShowLockedDocumentDialog(const LockFileEntry& aData, + bool bIsLoading, bool bOwnLock, bool bHandleSysLocked); + enum class MessageDlg { LockFileIgnore, LockFileCorrupt }; + bool ShowLockFileProblemDialog(MessageDlg nWhichDlg); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/docfilt.hxx b/include/sfx2/docfilt.hxx new file mode 100644 index 0000000000..45dd0efb9b --- /dev/null +++ b/include/sfx2/docfilt.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_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> +#include <string_view> + +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( OUString aProvider, OUString aFilterName ); + + SfxFilter( OUString aName, + std::u16string_view rWildCard, + SfxFilterFlags nFormatType, + SotClipboardFormatId lFormat, + OUString aTypeName, + OUString aMimeType, + OUString aUserData, + OUString aServiceName, + 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); } + bool IsMSOFormat() const { return aTypeName.startsWith("MS"); } + /// 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( std::u16string_view 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 0000000000..218f801489 --- /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 <comphelper/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 0000000000..73eb2e4370 --- /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 <comphelper/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_DLLPRIVATE_LINK(DialogClosedHdl, sfx2::FileDialogHelper*, void); + +public: + enum class Mode { + Insert, + InsertMulti, + Compare, + Merge + }; + DocumentInserter(weld::Window* pParent, OUString aFactory, 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 0000000000..4054770002 --- /dev/null +++ b/include/sfx2/dockwin.hxx @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_DOCKWIN_HXX +#define INCLUDED_SFX2_DOCKWIN_HXX + +#include <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, std::u16string_view rDockingWindowName ); +bool IsDockingWindowVisible( const css::uno::Reference< css::frame::XFrame >& rFrame, std::u16string_view rDockingWindowName ); + +class SFX2_DLLPUBLIC SfxDockingWindow : public ResizableDockingWindow +{ +protected: + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Box> 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 OUString& rID, const OUString& rUIXMLDescription ); + virtual ~SfxDockingWindow() override; + virtual void dispose() override; + + void Initialize (SfxChildWinInfo* pInfo); + virtual void FillInfo(SfxChildWinInfo&) const; + virtual void StateChanged( StateChangedType nStateChange ) override; + + void SetDockingRects(const tools::Rectangle& rOuter, const tools::Rectangle& rInner) + { aInnerRect = rInner; aOuterRect = rOuter; } + const tools::Rectangle& GetInnerRect() const { return aInnerRect; } + const tools::Rectangle& GetOuterRect() const { return aOuterRect; } + SfxBindings& GetBindings() const { return *pBindings; } + sal_uInt16 GetType() const { return pMgr->GetType(); } + SfxChildAlignment GetAlignment() const { return pMgr->GetAlignment(); } + void SetAlignment(SfxChildAlignment eAlign) { pMgr->SetAlignment(eAlign); } + const Size& GetFloatingSize() const { return aFloatSize; } + void SetFloatingSize(const Size& rSize) { aFloatSize=rSize; } + + void SetMinOutputSizePixel( const Size& rSize ); + const Size& GetMinOutputSizePixel() const; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + DECL_DLLPRIVATE_LINK(TimerHdl, Timer *, void); + + SAL_DLLPRIVATE void Initialize_Impl(); + SAL_DLLPRIVATE void SetItemSize_Impl( const Size& rSize ); + SAL_DLLPRIVATE void Disappear_Impl(); + SAL_DLLPRIVATE void Reappear_Impl(); + SAL_DLLPRIVATE bool IsAutoHide_Impl() const; + SAL_DLLPRIVATE void AutoShow_Impl(); + SAL_DLLPRIVATE void ReleaseChildWindow_Impl(); +}; + +class SfxDockingWrapper final : public SfxChildWindow +{ + public: + SfxDockingWrapper( vcl::Window* pParent , + sal_uInt16 nId , + SfxBindings* pBindings , + SfxChildWinInfo* pInfo ); + + SFX_DECL_CHILDWINDOW(SfxDockingWrapper); +}; + +#endif // INCLUDED_SFX2_DOCKWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/docmacromode.hxx b/include/sfx2/docmacromode.hxx new file mode 100644 index 0000000000..688297f265 --- /dev/null +++ b/include/sfx2/docmacromode.hxx @@ -0,0 +1,319 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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. + + @param _rxInteraction + A handler for interactions which might become necessary to trust a correct + but not yet trusted signature, possibly also adding the author certificate to + trusted list. + + If the user needs to be asked, and if this parameter is <NULL/>, the most + defensive assumptions will be made, i.e. false will be returned. + + @seealso <sfx2/signaturestate.hxx> + */ + virtual bool + hasTrustedScriptingSignature( const css::uno::Reference< css::task::XInteractionHandler >& _rxInteraction ) = 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. + + @param bHasValidContentSignature + Whether the document content is signed and the signature is valid. + + @return + <TRUE/> if and only if macro execution in this document is allowed. + */ + bool adjustMacroMode( + const css::uno::Reference< css::task::XInteractionHandler >& _rxInteraction, + bool bHasValidContentSignature = false + ); + + /** determines whether macro execution is disallowed + + There's a number of reasons why macro execution could be disallowed: + <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; + + bool hasUnsignedContentError() 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 ); + + bool hasMacros() const; + + static bool containerHasBasicMacros( const css::uno::Reference< css::script::XLibraryContainer >& xContainer ); + /** checks the macro execution mode while loading the document. + + This must be called when the loading is effectively finished, but before any macro action + happened. + + The method will disallow macro execution for this document if it is disabled + globally (SvtSecurityOptions::IsMacroDisabled). Otherwise, it will check whether + the document contains a macro storage or macro libraries. If so, it will + properly calculate the MacroExecutionMode by calling adjustMacroMode. + + If the document doesn't contain macros, yet, then the macro execution for this + document will be allowed (again: unless disabled globally), since in this case + macros which later are newly created by the user should be allowed, of course. + + @return + <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, + bool bHasValidContentSignature, bool bHasMacros + ); + + 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 0000000000..8530711cad --- /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 0000000000..029c8e8b27 --- /dev/null +++ b/include/sfx2/doctempl.hxx @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_DOCTEMPL_HXX +#define INCLUDED_SFX2_DOCTEMPL_HXX + +#include <sal/config.h> + +#include <string_view> + +#include <rtl/ustring.hxx> +#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(std::u16string_view aGroupName, + std::u16string_view aTitle ); + + // Convert a resource string - a template name - to its localised pair + // if it exists in sfx2/inc/strings.hxx + static OUString ConvertResourceString(const OUString& rString); + + bool Copy(sal_uInt16 nTargetRegion, + sal_uInt16 nTargetIdx, + sal_uInt16 nSourceRegion, + sal_uInt16 nSourceIdx); + bool Move(sal_uInt16 nTargetRegion, + sal_uInt16 nTargetIdx, + sal_uInt16 nSourceRegion, + sal_uInt16 nSourceIdx); + bool Delete(sal_uInt16 nRegion, sal_uInt16 nIdx); + bool InsertDir(const OUString &rText, sal_uInt16 nRegion); + + bool InsertTemplate (sal_uInt16 nSourceRegion, sal_uInt16 nIdx, const OUString &rName, const OUString &rPath); + + /** Change the name of an entry or a directory + + \param rName + The new name to set + \param nRegion + The id of the region to rename or containing the template to rename + \param nIdx + The id of the template to rename or USHRT_MAX to rename the region. + + \return + sal_True if the action could be performed, sal_False otherwise + + */ + bool SetName(const OUString &rName, sal_uInt16 nRegion, sal_uInt16 nIdx); + + bool CopyTo(sal_uInt16 nRegion, sal_uInt16 nIdx, std::u16string_view rName) const; + bool CopyFrom(sal_uInt16 nRegion, sal_uInt16 nIdx, OUString &rName); + + bool GetFull( + std::u16string_view rRegion, std::u16string_view rName, OUString& rPath ); + bool GetLogicNames( std::u16string_view rPath, OUString& rRegion, OUString& rName ) const; + + /** updates the configuration where the document templates structure is stored. + + <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/event.hxx b/include/sfx2/event.hxx new file mode 100644 index 0000000000..1024dd5b24 --- /dev/null +++ b/include/sfx2/event.hxx @@ -0,0 +1,271 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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> +#include <utility> + +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, OUString aName, SfxObjectShell *pObj) + : SfxHint(SfxHintId::ThisIsAnSfxEventHint) + , pObjShell(pObj) + , aEventName(std::move(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, css::uno::Reference< css::frame::XController2 > xController ) + : SfxEventHint( nId, aName, pObj ) + , xViewController(std::move( 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 0000000000..6716678813 --- /dev/null +++ b/include/sfx2/evntconf.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_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 <utility> +#include <vector> + +class SfxObjectShell; +class SvxMacro; + +struct SFX2_DLLPUBLIC SfxEventName +{ + SvMacroItemId mnId; + OUString maEventName; + OUString maUIName; + + SfxEventName( SvMacroItemId nId, + OUString aEventName, + OUString aUIName ) + : mnId( nId ) + , maEventName(std::move( aEventName )) + , maUIName(std::move( aUIName )) {} +}; + +class SFX2_DLLPUBLIC SfxEventNamesList +{ +private: + ::std::vector< SfxEventName > aEventNamesList; + +public: + SfxEventNamesList() {} + SfxEventNamesList( const SfxEventNamesList &rCpy ) { *this = rCpy; } + ~SfxEventNamesList(); + SfxEventNamesList& operator=( const SfxEventNamesList &rCpy ); + + size_t size() const { return aEventNamesList.size(); }; + + SfxEventName& at( size_t Index ) { return aEventNamesList[ Index ]; } + SfxEventName const & at( size_t Index ) const { return aEventNamesList[ Index ]; } + + void push_back( SfxEventName Item ) { aEventNamesList.push_back( std::move(Item) ); } +}; + +class SFX2_DLLPUBLIC SfxEventNamesItem final : public SfxPoolItem +{ + SfxEventNamesList aEventsList; + +public: + + SfxEventNamesItem ( const sal_uInt16 nId ) : SfxPoolItem( nId ) {} + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual bool GetPresentation( SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString &rText, + const IntlWrapper& ) const override; + virtual SfxEventNamesItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const SfxEventNamesList& GetEvents() const { return aEventsList;} + void AddEvent( const OUString&, const OUString&, SvMacroItemId ); +}; + + +inline constexpr OUString PROP_EVENT_TYPE = u"EventType"_ustr; +inline constexpr OUString PROP_LIBRARY = u"Library"_ustr; +inline constexpr OUString PROP_SCRIPT = u"Script"_ustr; +inline constexpr OUString PROP_MACRO_NAME = u"MacroName"_ustr; +#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 0000000000..026f0e1c1b --- /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( std::u16string_view ); +}; + +class SfxFilterMatcher_Impl; + +class SFX2_DLLPUBLIC SfxFilterMatcher +{ + friend class SfxFilterMatcherIter; + SfxFilterMatcher_Impl &m_rImpl; +public: + SfxFilterMatcher( const OUString& rFact ); + SfxFilterMatcher(); + ~SfxFilterMatcher(); + SfxFilterMatcher(const SfxFilterMatcher&) = delete; + SfxFilterMatcher& operator=( const SfxFilterMatcher& ) = delete; + + SAL_DLLPRIVATE static bool IsFilterInstalled_Impl( const std::shared_ptr<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( std::u16string_view 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 0000000000..d637a4194c --- /dev/null +++ b/include/sfx2/filedlghelper.hxx @@ -0,0 +1,317 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <comphelper/errcode.hxx> +#include <o3tl/typed_flags_set.hxx> + +#include <memory> +#include <optional> +#include <vector> + +namespace com::sun::star::ui::dialogs +{ + class XFilePicker3; + class XFolderPicker2; + struct FilePickerEvent; + struct DialogClosedEvent; +} +namespace com::sun::star::awt { class XWindow; } +namespace com::sun::star::uno { template <typename > class Reference; } +namespace com::sun::star::uno { class XComponentContext; } +namespace weld { class Window; } + +class Graphic; +class SfxFilter; +class SfxItemSet; +class SfxAllItemSet; + +enum class FileDialogFlags { + NONE = 0x00, + Insert = 0x01, // turn Open into Insert dialog + Export = 0x02, // turn Save into Export dialog + SaveACopy = 0x04, // turn Save into Save a Copy dialog + MultiSelection = 0x08, + Graphic = 0x10, // register graphic formats + /// Sign existing PDF. + SignPDF = 0x20, + InsertCompare = 0x40, /// Special insertion ("Compare" caption) + InsertMerge = 0x80, /// Special insertion ("Merge" caption) +}; +namespace o3tl { + template<> struct typed_flags<FileDialogFlags> : is_typed_flags<FileDialogFlags, 0xFF> {}; +} + +inline constexpr OUString FILEDIALOG_FILTER_ALL = u"*.*"_ustr; + +namespace sfx2 { + +class FileDialogHelper_Impl; + +class SFX2_DLLPUBLIC FileDialogHelper +{ +public: + // context where the FileDialogHelper is used + enum Context + { + UnknownContext, + AcceleratorConfig, + AutoRedact, + BaseDataSource, + BaseSaveAs, + BasicExportPackage, + BasicExportDialog, + BasicExportSource, + BasicImportDialog, + BasicImportSource, + BasicInsertLib, + BulletsAddImage, + ExtensionManager, + CalcDataProvider, + CalcDataStream, + CalcExport, + CalcSaveAs, + CalcXMLSource, + DrawExport, + DrawImpressInsertFile, + DrawImpressOpenSound, + DrawSaveAs, + ExportImage, + FormsAddInstance, + FormsInsertImage, + IconImport, + ImpressClickAction, + ImpressExport, + ImpressPhotoDialog, + ImpressSaveAs, + LinkClientOLE, + LinkClientFile, + ImageMap, + InsertDoc, + InsertImage, + InsertMedia, + InsertOLE, + JavaClassPath, + ReportInsertImage, + ScreenshotAnnotation, + SignatureLine, + TemplateImport, + WriterCreateAddressList, + WriterInsertImage, + WriterInsertScript, + WriterExport, + WriterImportAutotext, + WriterInsertHyperlink, + WriterLoadTemplate, + WriterMailMerge, + WriterMailMergeSaveAs, + WriterNewHTMLGlobalDoc, + WriterRegisterDataSource, + WriterSaveAs, + WriterSaveHTML, + XMLFilterSettings + }; + static OUString contextToString(Context context); + +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 >& rDenyList, + weld::Window* pPreferredParent); + + FileDialogHelper(sal_Int16 nDialogType, + FileDialogFlags nFlags, + const OUString& aFilterUIName, + std::u16string_view aExtName, + const OUString& rStandardDir, + const css::uno::Sequence< OUString >& rDenyList, + weld::Window* pPreferredParent); + + virtual ~FileDialogHelper(); + + FileDialogHelper& operator=(const FileDialogHelper &) = delete; + FileDialogHelper(const FileDialogHelper &) = delete; + + ErrCode Execute(); + void StartExecuteModal( const Link<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 + This will also store the last used directory for this context, so that the last directory + gets preselected on next filepicker launch (with the same context) + @param _eNewContext + New context for the dialog. + */ + void SetContext( Context _eNewContext ); + + DECL_DLLPRIVATE_LINK( ExecuteSystemFilePicker, void*, void ); + + ErrCode Execute( std::vector<OUString>& rpURLList, + std::optional<SfxAllItemSet>& rpSet, + OUString& rFilter, + const OUString& rDirPath ); + ErrCode Execute( std::optional<SfxAllItemSet>& 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::optional<SfxAllItemSet>& rpSet, + const OUString* pPath, + sal_Int16 nDialog, + const OUString& rStandardDir, + const css::uno::Sequence< OUString >& rDenyList = css::uno::Sequence< OUString >()); + +css::uno::Reference<css::ui::dialogs::XFolderPicker2> SFX2_DLLPUBLIC createFolderPicker(const css::uno::Reference<css::uno::XComponentContext>& rContext, weld::Window* pPreferredParent); + +ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, OUString const & aURL, SfxItemSet* pSet, const css::uno::Reference<css::awt::XWindow>& rParent); +ErrCode SetPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, SfxItemSet* pSet, + const OUString& rPasswordToOpen, std::u16string_view rPasswordToModify, + bool bAllowPasswordReset = false); +bool IsOOXML(const std::shared_ptr<const SfxFilter>& pCurrentFilter); +bool IsMSType(const std::shared_ptr<const SfxFilter>& pCurrentFilter); +} + +#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 0000000000..cf71475fb6 --- /dev/null +++ b/include/sfx2/flatpak.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_INCLUDE_SFX2_FLATPAK_HXX +#define INCLUDED_INCLUDE_SFX2_FLATPAK_HXX + +#include <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 0000000000..888a1631f8 --- /dev/null +++ b/include/sfx2/frame.hxx @@ -0,0 +1,203 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_FRAME_HXX +#define INCLUDED_SFX2_FRAME_HXX + +#include <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::sun::star::frame +{ + class XFrame; + class XController; +} + +class SvBorder; +class SfxWorkWindow; +namespace vcl { class Window; } +class SfxFrame_Impl; +class SfxObjectShell; +class SfxViewFrame; +class SfxFrameDescriptor; +namespace tools { class Rectangle; } +class SystemWindow; + +typedef ::std::vector<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 > m_pImpl; + VclPtr<vcl::Window> m_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 *m_pWindow;} + void CancelTransfers(); + bool DoClose(); + + void SetPresentationMode( bool bSet ); + SystemWindow* GetSystemWindow() const; + + SAL_WARN_UNUSED_RESULT static SfxFrame* GetFirst(); + SAL_WARN_UNUSED_RESULT static SfxFrame* GetNext( SfxFrame& ); + + SAL_WARN_UNUSED_RESULT SfxObjectShell* GetCurrentDocument() const; + SAL_WARN_UNUSED_RESULT SfxViewFrame* GetCurrentViewFrame() const; + + bool GetHasTitle() const; + static void GetDefaultTargetList( TargetList& ); + void UpdateDescriptor( SfxObjectShell const *pDoc ); + void Resize(); + const css::uno::Reference< css::frame::XFrame >& + GetFrameInterface() const; + void Appear(); + void AppearWithUpdate(); + css::uno::Reference< css::frame::XController > + GetController() const; + + bool IsInPlace() const; + + SAL_DLLPRIVATE void DoClose_Impl(); + SAL_DLLPRIVATE void SetFrameInterface_Impl( const css::uno::Reference< css::frame::XFrame >& rFrame ); + SAL_DLLPRIVATE void ReleasingComponent_Impl(); + SAL_DLLPRIVATE void GetViewData_Impl(); + SAL_DLLPRIVATE void SetHasTitle( bool ); + SAL_DLLPRIVATE bool PrepareClose_Impl( bool bUI ); + SAL_DLLPRIVATE bool DocIsModified_Impl(); + SAL_DLLPRIVATE void SetCurrentViewFrame_Impl( SfxViewFrame* ); + bool IsClosing_Impl() const; + SAL_DLLPRIVATE void SetIsClosing_Impl(); + + // Methods for accessing the current set + SAL_DLLPRIVATE SfxFrameDescriptor* GetDescriptor() const; + + SAL_DLLPRIVATE bool IsAutoLoadLocked_Impl() const; + + SAL_DLLPRIVATE static void InsertTopFrame_Impl( SfxFrame* pFrame ); + SAL_DLLPRIVATE static void RemoveTopFrame_Impl( SfxFrame* pFrame ); + SAL_DLLPRIVATE void SetOwnsBindings_Impl( bool bSet ); + SAL_DLLPRIVATE bool OwnsBindings_Impl() const; + SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl() const; + SAL_DLLPRIVATE void SetToolSpaceBorderPixel_Impl( const SvBorder& ); + SAL_DLLPRIVATE tools::Rectangle GetTopOuterRectPixel_Impl() const; + SAL_DLLPRIVATE void CreateWorkWindow_Impl(); + SAL_DLLPRIVATE void GrabFocusOnComponent_Impl(); + + SAL_DLLPRIVATE void PrepareForDoc_Impl( const SfxObjectShell& i_rDoc ); + SAL_DLLPRIVATE void LockResize_Impl( bool bLock ); + SAL_DLLPRIVATE void SetMenuBarOn_Impl( bool bOn ); + SAL_DLLPRIVATE bool IsMenuBarOn_Impl() const; + SAL_DLLPRIVATE SystemWindow* GetTopWindow_Impl() const; + SAL_DLLPRIVATE bool IsMarkedHidden_Impl() const; +private: + SAL_DLLPRIVATE void Construct_Impl(); +}; + +typedef SvCompatWeakRef<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( 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, css::uno::Reference< css::frame::XFrame > i_xFrame ); + 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 0000000000..67c0c7e389 --- /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( std::u16string_view rURL ); + void SetActualURL(); + + // FrameName + const OUString& GetName() const + { return aName; } + void SetName( const OUString& rName ) + { aName = rName; } + + // Margin, Scrolling + const Size& GetMargin() const + { return aMargin; } + void SetMargin( const Size& rMargin ) + { aMargin = rMargin; } + ScrollingMode GetScrollingMode() const + { return eScroll; } + void SetScrollingMode( ScrollingMode eMode ) + { eScroll = eMode; } + + // FrameBorder + bool HasFrameBorder() const + { return bHasBorder; } + bool IsFrameBorderOn() const + { return bHasBorder; } + void SetFrameBorder( bool bBorder ) + { bHasBorder = bBorder; bHasBorderSet = true; } + bool IsFrameBorderSet() const + { return bHasBorderSet; } + void ResetBorder() + { bHasBorder = false; bHasBorderSet = false; } +}; + +#endif // INCLUDED_SFX2_FRMDESCR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/frmhtml.hxx b/include/sfx2/frmhtml.hxx new file mode 100644 index 0000000000..205c320fe8 --- /dev/null +++ b/include/sfx2/frmhtml.hxx @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SFX2_FRMHTML_HXX +#define INCLUDED_SFX2_FRMHTML_HXX + +#include <sal/config.h> +#include <sfx2/dllapi.h> + +#include <svtools/parhtml.hxx> + +class SfxFrameDescriptor; + +namespace SfxFrameHTMLParser +{ +// These methods can also be used by other parsers. +SFX2_DLLPUBLIC void ParseFrameOptions(SfxFrameDescriptor*, const HTMLOptions&, std::u16string_view); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/frmhtmlw.hxx b/include/sfx2/frmhtmlw.hxx new file mode 100644 index 0000000000..10faf52abc --- /dev/null +++ b/include/sfx2/frmhtmlw.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_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, + OUString *pNonConvertableChars = nullptr ); + SAL_DLLPRIVATE inline static void OutMeta( SvStream& rStrm, + const char *pIndent, const char *pName, + const OUString& rContent, bool bHTTPEquiv, + OUString *pNonConvertableChars = nullptr ); + +public: + static void Out_DocInfo( SvStream& rStrm, const OUString& rBaseURL, + const css::uno::Reference< css::document::XDocumentProperties>&, + const char *pIndent, + OUString *pNonConvertableChars = nullptr ); + + static void Out_FrameDescriptor( + SvStream&, const OUString& rBaseURL, const css::uno::Reference < css::beans::XPropertySet >& xSet); +}; + +inline void SfxFrameHTMLWriter::OutMeta( SvStream& rStrm, + const char *pIndent, const char *pName, + const OUString& rContent, bool bHTTPEquiv, + OUString *pNonConvertableChars ) +{ + OUString sTmp = OUString::createFromAscii(pName); + OutMeta( rStrm, pIndent, sTmp, rContent, bHTTPEquiv, pNonConvertableChars ); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/groupid.hxx b/include/sfx2/groupid.hxx new file mode 100644 index 0000000000..fd31785ae3 --- /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 0000000000..cd2b7d1fed --- /dev/null +++ b/include/sfx2/htmlmode.hxx @@ -0,0 +1,31 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_HTMLMODE_HXX +#define INCLUDED_SFX2_HTMLMODE_HXX + +enum +{ + HTMLMODE_ON = 0x0001, + HTMLMODE_SOME_STYLES = 0x0020, /* mind. MS IE */ + HTMLMODE_FULL_STYLES = 0x0040 /* == SW */ +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx new file mode 100644 index 0000000000..675a8fb018 --- /dev/null +++ b/include/sfx2/infobar.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef INCLUDED_SFX2_INFOBAR_HXX +#define INCLUDED_SFX2_INFOBAR_HXX + +#include <vector> + +#include <basegfx/color/bcolor.hxx> + +#include <sfx2/childwin.hxx> +#include <sfx2/dllapi.h> +#include <vcl/InterimItemWindow.hxx> + +// These must match the values in offapi/com/sun/star/frame/InfobarType.idl +enum class InfobarType +{ + INFO = 0, + SUCCESS = 1, + WARNING = 2, + DANGER = 3 +}; + +class InfobarData +{ +public: + OUString msId; + OUString msPrimaryMessage; + OUString msSecondaryMessage; + InfobarType maInfobarType; + bool mbShowCloseButton; +}; + +/** SfxChildWindow for positioning the InfoBar in the view. + */ +class SFX2_DLLPUBLIC SfxInfoBarContainerChild final : public SfxChildWindow +{ +private: + SfxBindings* m_pBindings; + +public: + SfxInfoBarContainerChild(vcl::Window* pParent, sal_uInt16 nId, SfxBindings* pBindings, + SfxChildWinInfo* pInfo); + virtual ~SfxInfoBarContainerChild() override; + + SFX_DECL_CHILDWINDOW_WITHID(SfxInfoBarContainerChild); + + void Update(); +}; + +class ExtraButton; + +/** Class representing a single InfoBar to be added in a SfxInfoBarContainerWindow. + */ +class SFX2_DLLPUBLIC SfxInfoBarWindow final : public InterimItemWindow +{ +private: + OUString m_sId; + InfobarType m_eType; + Size m_aMessageSize; + Size m_aOrigMessageSize; + bool m_bLayingOut; + std::unique_ptr<weld::Image> m_xImage; + std::unique_ptr<weld::Label> m_xPrimaryMessage; + std::unique_ptr<weld::TextView> m_xSecondaryMessage; + std::unique_ptr<weld::Container> m_xButtonBox; + std::unique_ptr<weld::Toolbar> m_xCloseBtn; + std::vector<std::unique_ptr<ExtraButton>> m_aActionBtns; + + DECL_DLLPRIVATE_LINK(SizeAllocHdl, const Size&, void); + + void SetForeAndBackgroundColors(InfobarType eType); + void SetCloseButtonImage(); + +public: + SfxInfoBarWindow(vcl::Window* parent, OUString sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, InfobarType InfobarType, + bool bShowCloseButton); + Size DoLayout(); + virtual void Layout() override; + virtual ~SfxInfoBarWindow() override; + virtual void dispose() override; + + const OUString& getId() const { return m_sId; } + void Update(const OUString& sPrimaryMessage, const OUString& sSecondaryMessage, + InfobarType eType); + basegfx::BColor m_aBackgroundColor; + basegfx::BColor m_aForegroundColor; + + /** Add button to Infobar. + * Infobar takes ownership of the button so the button is + * destroyed when the infobar gets destroyed. + * + * The optional "pCommand" is used by extensions, via XInfobarProvider, to + * dispatch pCommand on click. + */ + weld::Button& addButton(const OUString* pCommand = nullptr); + + void SetCommandHandler(weld::Button& rBtn, const OUString& aCommand); + +private: + DECL_DLLPRIVATE_LINK(CloseHandler, const OUString&, void); +}; + +class SfxInfoBarContainerWindow final : public vcl::Window +{ +private: + SfxInfoBarContainerChild* m_pChildWin; + std::vector<VclPtr<SfxInfoBarWindow>> m_pInfoBars; + Idle m_aLayoutIdle; + bool m_bResizing; + + DECL_LINK(DoUpdateLayout, Timer*, void); + +public: + SfxInfoBarContainerWindow(SfxInfoBarContainerChild* pChildWin); + virtual ~SfxInfoBarContainerWindow() override; + virtual void dispose() override; + + VclPtr<SfxInfoBarWindow> appendInfoBar(const OUString& sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, InfobarType ibType, + bool bShowCloseButton); + VclPtr<SfxInfoBarWindow> getInfoBar(std::u16string_view sId); + bool hasInfoBarWithID(std::u16string_view sId); + void removeInfoBar(VclPtr<SfxInfoBarWindow> const& pInfoBar); + static bool isInfobarEnabled(std::u16string_view sId); + + void TriggerUpdateLayout(); + + virtual void Resize() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/inputdlg.hxx b/include/sfx2/inputdlg.hxx new file mode 100644 index 0000000000..840844d182 --- /dev/null +++ b/include/sfx2/inputdlg.hxx @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SFX2_SOURCE_INC_INPUTDLG_HXX +#define INCLUDED_SFX2_SOURCE_INC_INPUTDLG_HXX + +#include <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; + std::unique_ptr<weld::Button> m_xOk; + std::function<bool(OUString)> mCheckEntry; + DECL_DLLPRIVATE_LINK(EntryChangedHdl, weld::Entry&, void); + +public: + InputDialog(weld::Widget* pParent, const OUString& rLabelText); + OUString GetEntryText() const; + void SetEntryText(const OUString& rStr); + void HideHelpBtn(); + void SetEntryMessageType(weld::EntryMessageType aType); + void SetTooltip(const OUString& rStr); + void setCheckEntry(std::function<bool(OUString)> aFunc); +}; + +#endif // INCLUDED_SFX2_SOURCE_INC_INPUTDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/ipclient.hxx b/include/sfx2/ipclient.hxx new file mode 100644 index 0000000000..2e58f5e339 --- /dev/null +++ b/include/sfx2/ipclient.hxx @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_IPCLIENT_HXX +#define INCLUDED_SFX2_IPCLIENT_HXX + +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <rtl/ref.hxx> + +#include <tools/gen.hxx> + +#include <comphelper/errcode.hxx> +#include <vcl/vclptr.hxx> + +namespace com::sun::star::embed { class XEmbeddedObject; } +namespace com::sun::star::uno { template <typename > class Reference; } +namespace vcl { class Window; } + +class SfxInPlaceClient_Impl; +class SfxViewShell; +class SfxObjectShell; +class Fraction; + + +class SFX2_DLLPUBLIC SfxInPlaceClient +{ +friend class SfxInPlaceClient_Impl; + + rtl::Reference<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; + ErrCodeMsg DoVerb(sal_Int32 nVerb); + void VisAreaChanged(); + void ResetObject(); + bool IsUIActive() const; + + /// To indicate that negated document X coordinates are used + void SetNegativeX(bool bSet); + bool IsNegativeX() const; + + virtual void FormatChanged(); // object format was changed (used for StarMath formulas aligning) + + virtual bool IsProtected() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/linkmgr.hxx b/include/sfx2/linkmgr.hxx new file mode 100644 index 0000000000..dddd8a54e2 --- /dev/null +++ b/include/sfx2/linkmgr.hxx @@ -0,0 +1,187 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_LINKMGR_HXX +#define INCLUDED_SFX2_LINKMGR_HXX + +#include <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 <string_view> +#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 + + bool InsertLink( SvBaseLink* pLink, SvBaseLinkObjectType nObjType, SfxLinkUpdateMode nUpdateType, + const OUString* pName ); +public: + + enum LinkState + { + STATE_LOAD_OK, + STATE_LOAD_ERROR, + STATE_LOAD_ABORT + }; + + LinkManager( SfxObjectShell * pCacheCont ); + ~LinkManager(); + + /** + * Insert a component loaded during link update, which needs to be closed + * when the update is complete. + * + * @param xComp component loaded during link update. + */ + void InsertCachedComp(const css::uno::Reference< css::lang::XComponent >& xComp); + + void CloseCachedComps(); + + SfxObjectShell* GetPersist() const { return pPersist; } + void SetPersist( SfxObjectShell * p ) { pPersist = p; } + + void Remove( SvBaseLink const *pLink ); + void Remove( size_t nPos, size_t nCnt = 1 ); + bool Insert( SvBaseLink* pLink ); + + // the links connect to a SvLinkSource and adds to the list + void InsertDDELink( SvBaseLink*, + const OUString& rServer, + std::u16string_view rTopic, + std::u16string_view rItem ); + + // if everything is already set at the link! + void InsertDDELink( SvBaseLink* ); + + // Connect the links to a pseudo-object and add to the list + void InsertFileLink( sfx2::SvBaseLink&, + SvBaseLinkObjectType nFileType, + std::u16string_view rFileNm, + const OUString* pFilterNm = nullptr, + const OUString* pRange = nullptr ); + + void ReconnectDdeLink(SfxObjectShell& rServer); + + /** + * Reconnect the server document shell to a DDE link object. + * + * @param rPath path to the server document + * @param rServer server document shell instance + * @param rLink link object of the client document + */ + static void LinkServerShell(const OUString& rPath, SfxObjectShell& rServer, ::sfx2::SvBaseLink& rLink); + + // Obtain the string for the dialog + static bool GetDisplayNames( const SvBaseLink *, + OUString* pType, + OUString* pFile = nullptr, + OUString* pLink = nullptr, + OUString* pFilter = nullptr ); + + static SvLinkSourceRef CreateObj( SvBaseLink const * ); + + void UpdateAllLinks(bool bAskUpdate, + bool bUpdateGrfLinks, + weld::Window* pParentWin); + + // Call for list of links (eg for link-dialog) + const SvBaseLinks& GetLinks() const { return aLinkTbl; } + + // ----------------- Server-side management -------------------- + + // Call with list of links to server + const SvLinkSources& GetServers() const { return aServerTbl; } + // Link register/delete + bool InsertServer( SvLinkSource* rObj ); + void RemoveServer( SvLinkSource* rObj ); + + // A transfer is aborted, so cancel all download media + // (for the time being this is only of interest for the FileLinks!) + void CancelTransfers(); + + // To send status information from the FileObject to the Baselink, + // for this there exist a separate ClipBoardId. The SvData-object has + // got the appropriate information as a string. + // Is now required for FileObject in conjunction with JavaScript + // this needs information about Load/Abort/Error + static SotClipboardFormatId RegisterStatusInfoId(); + + // if the mimetype says graphic/bitmap/gdimetafile then get the + // graphic from the Any. Return says no errors + bool GetGraphicFromAny(std::u16string_view rMimeType, + const css::uno::Any & rValue, + Graphic& rGrf, + weld::Window* pParentWin); + +private: + LinkManager( const LinkManager& ) = delete; + LinkManager& operator=( const LinkManager& ) = delete; +}; + +// Separator in the link name for the DDE-/File-/Graphics- links +// (only those who need to construct a SvLinkName) +const sal_Unicode cTokenSeparator = 0xFFFF; + +// create a string for the SvLinkName. For: +// - DDE the first 3 Strings, (Server, Topic, Item) +// - File-/Graphics-LinkNames the last 3 Strings (FileName, Region, Filter) +SFX2_DLLPUBLIC void MakeLnkName( OUString& rName, + const OUString* pType, // Can also be null!! + std::u16string_view rFile, + std::u16string_view rLink, + const OUString* pFilter = nullptr ); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/linksrc.hxx b/include/sfx2/linksrc.hxx new file mode 100644 index 0000000000..bac48b1858 --- /dev/null +++ b/include/sfx2/linksrc.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_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> +#include <utility> + +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( + css::uno::Reference<css::io::XInputStream> xInputStream, bool bIsReadOnly ) + :m_xInputStreamToLoadFrom(std::move(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/listview.hxx b/include/sfx2/listview.hxx new file mode 100644 index 0000000000..72d4ae7e79 --- /dev/null +++ b/include/sfx2/listview.hxx @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <vcl/weld.hxx> + +enum TemplateViewMode +{ + eListView, + eThumbnailView +}; +class SfxDocumentTemplates; +class TemplateContainerItem; +struct ListViewItem; + +class ListView +{ +public: + ListView(std::unique_ptr<weld::TreeView> xTreeView); + ~ListView(); + + void AppendItem(const OUString& rId, const OUString& rTitle, const OUString& rSubtitle, + const OUString& rPath, bool bDefault); + + void AppendRow(const OUString& rImage, const OUString& rTitle, const OUString& rSubtitle, + const OUString& rApplication, const OUString& rModify, const OUString& rSize, + const OUString& rId); + + void UpdateRow(int nIndex, const OUString& rImage, const OUString& rTitle, + const OUString& rSubtitle, const OUString& rApplication, const OUString& rModify, + const OUString& rSize, const OUString& rId); + + void ReloadRows(); + + bool UpdateRows(); + + void sortColumn(const int col); + + void sort(); + + void clearListView(); + + void ShowListView() { mxTreeView->show(); } + + void HideListView() { mxTreeView->hide(); } + + void unselect_all() { mxTreeView->unselect_all(); } + + void grab_focus() { mxTreeView->grab_focus(); } + + void rename(const OUString& rId, const OUString& rTitle); + + void refreshDefaultColumn(); + +protected: + sal_uInt16 get_nId(int pos) const; + + void select_id(const OUString& sId) { mxTreeView->select_id(sId); } + + int get_selected_index() const { return mxTreeView->get_selected_index(); } + + std::vector<int> get_selected_rows() const { return mxTreeView->get_selected_rows(); } + + bool IsListViewVisible() const { return mxTreeView->is_visible(); } + + OUString get_id(int pos) const { return mxTreeView->get_id(pos); } + + void set_cursor(int pos) { mxTreeView->set_cursor(pos); } + + int get_cursor_index() const { return mxTreeView->get_cursor_index(); } + + sal_uInt16 get_cursor_nId() const { return get_nId(mxTreeView->get_cursor_index()); } + + void select(int pos) { mxTreeView->select(pos); } + + int get_index(sal_uInt16 nId) const { return mxTreeView->find_id(OUString::number(nId)); } + + DECL_LINK(ColumnClickedHdl, const int, void); + + DECL_LINK(QueryTooltipHdl, const weld::TreeIter&, OUString); + +protected: + std::unique_ptr<weld::TreeView> mxTreeView; + std::vector<std::unique_ptr<ListViewItem>> mListViewItems; + int mnSortColumn; +}; + +struct ListViewItem +{ +public: + OUString maId; + OUString maTitle; + OUString maSubtitle; + OUString maApplication; + OUString maPath; + bool mbDefault; + + /** Last modify time in seconds since 1/1/1970. */ + sal_uInt32 mnModify; + /** Size in bytes of the file. */ + sal_uInt64 mnSize; + + OUString maDisplayModify; + OUString maDisplaySize; + OUString maDisplayPath; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/lnkbase.hxx b/include/sfx2/lnkbase.hxx new file mode 100644 index 0000000000..00f48067bb --- /dev/null +++ b/include/sfx2/lnkbase.hxx @@ -0,0 +1,178 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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; +} + +class SFX2_DLLPUBLIC SvBaseLink : public SvRefBase +{ +private: + friend class LinkManager; + friend class SvLinkSource; + + Link<SvBaseLink&,void> m_aEndEditLink; + LinkManager* m_pLinkMgr; + weld::Window* m_pParentWin; + std::unique_ptr<FileDialogHelper> + m_pFileDlg; + SvLinkSourceRef xObj; + OUString aLinkName; + std::unique_ptr<ImplBaseLinkData> pImplData; + SvBaseLinkObjectType mnObjType; + bool bVisible : 1; + bool bSynchron : 1; + bool bWasLastEditOK : 1; + bool m_bIsConnect : 1; + bool m_bIsReadOnly; + css::uno::Reference<css::io::XInputStream> + m_xInputStreamToLoadFrom; + + DECL_DLLPRIVATE_LINK( EndEditHdl, const OUString&, void ); + + bool ExecuteEdit( const OUString& _rNewName ); + +protected: + void SetObjType( SvBaseLinkObjectType ); + + // Set LinkSourceName without action + void SetName( const OUString & rLn ); + + 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); +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/lokcallback.hxx b/include/sfx2/lokcallback.hxx new file mode 100644 index 0000000000..6da464e904 --- /dev/null +++ b/include/sfx2/lokcallback.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/. + */ + +#pragma once + +#include <sal/types.h> + +namespace rtl +{ +class OString; +class OStringBuffer; +} +namespace tools +{ +class Rectangle; +} + +// An extended callback type that allows passing in also some binary data, +// so that post-processing the messages does not require conversions +// from and to strings. + +// TODO: It might possibly make sense to drop the generic type/payload function +// and have only a dedicated function for each message type? + +class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI SfxLokCallbackInterface +{ +public: + virtual ~SfxLokCallbackInterface() {} + // LibreOfficeKitCallback equivalent. + virtual void libreOfficeKitViewCallback(int nType, const rtl::OString& pPayload) = 0; + // Callback that explicitly provides view id (which is also included in the payload). + virtual void libreOfficeKitViewCallbackWithViewId(int nType, const rtl::OString& pPayload, + int nViewId) + = 0; + // LOK_CALLBACK_INVALIDATE_TILES + // nPart is either part, -1 for all-parts, or INT_MIN if + // comphelper::LibreOfficeKit::isPartInInvalidation() is not set + virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart, + int nMode) + = 0; + // A message of the given type should be sent, for performance purpose only a notification + // is given here, details about the message should be queried from SfxViewShell when necessary. + // This is used for messages that are generated often but only the last one is needed. + virtual void libreOfficeKitViewUpdatedCallback(int nType) = 0; + // Like libreOfficeKitViewUpdatedCallback(), but a last message is needed for each nViewId value. + // SfxViewShell:getLOKPayload() will be called on nSourceViewId view. + virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, + int nSourceViewId) + = 0; + // There are pending invalidate tiles calls that need to be processed. + // A call to SfxViewShell::flushPendingLOKInvalidateTiles() should be scheduled. + virtual void libreOfficeKitViewAddPendingInvalidateTiles() = 0; + virtual void dumpState(rtl::OStringBuffer& rState) = 0; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/lokcomponenthelpers.hxx b/include/sfx2/lokcomponenthelpers.hxx new file mode 100644 index 0000000000..c76067bc13 --- /dev/null +++ b/include/sfx2/lokcomponenthelpers.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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/vclptr.hxx> +#include <vcl/window.hxx> + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::frame { class XController; } +namespace com::sun::star::frame { class XDispatch; } +namespace com::sun::star::frame { class XFrame; } +namespace com::sun::star::uno { template<class E> class Sequence; } + +class SfxInPlaceClient; +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; + bool mbNegativeX; + +public: + LokChartHelper(SfxViewShell* pViewShell, bool bNegativeX = false) + : mpViewShell(pViewShell) + , mpWindow(nullptr) + , mbNegativeX(bNegativeX) + {} + + 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, bool bNegativeX = false); + void PaintTile(VirtualDevice& rRenderContext, const tools::Rectangle& rTileRect); + static void PaintAllChartsOnTile(VirtualDevice& rDevice, + int nOutputWidth, int nOutputHeight, + int nTilePosX, int nTilePosY, + tools::Long nTileWidth, tools::Long nTileHeight, + bool bNegativeX = false); + bool postMouseEvent(int nType, int nX, int nY, + int nCount, int nButtons, int nModifier, + double fScaleX = 1.0, double fScaleY = 1.0); + bool setTextSelection(int nType, int nX, int nY); + bool setGraphicSelection(int nType, int nX, int nY, + double fScaleX = 1.0, double fScaleY = 1.0); +}; + +/// A class for math editing support via LibreOfficeKit. +class SFX2_DLLPUBLIC LokStarMathHelper +{ +public: + LokStarMathHelper(const SfxViewShell* pViewShell); + + vcl::Window* GetGraphicWindow(); + vcl::Window* GetWidgetWindow(); + const SfxViewShell* GetSmViewShell(); + tools::Rectangle GetBoundingBox() const; + + void Dispatch(const OUString& cmd, const css::uno::Sequence<css::beans::PropertyValue>& rArguments) const; + + bool postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier, + double fPPTScaleX, double fPPTScaleY); + + static void PaintAllInPlaceOnTile(VirtualDevice& rDevice, int nOutputWidth, int nOutputHeight, + int nTilePosX, int nTilePosY, tools::Long nTileWidth, + tools::Long nTileHeight); + +private: + void PaintTile(VirtualDevice& rDevice, const tools::Rectangle& rTileRect); + + const SfxViewShell* mpViewShell; + const SfxInPlaceClient* mpIPClient = nullptr; // not nullptr when the object is valid + css::uno::Reference<css::frame::XFrame> mxFrame; // not empty when the object is valid + VclPtr<vcl::Window> mpGraphicWindow; + VclPtr<vcl::Window> mpWidgetWindow; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx new file mode 100644 index 0000000000..98eeccb744 --- /dev/null +++ b/include/sfx2/lokhelper.hxx @@ -0,0 +1,250 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <com/sun/star/ui/XAcceleratorConfiguration.hpp> + +#include <vcl/IDialogRenderable.hxx> +#include <vcl/ITiledRenderable.hxx> +#include <vcl/event.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/window.hxx> +#include <sfx2/dllapi.h> +#include <sfx2/viewsh.hxx> +#include <tools/gen.hxx> +#include <cstddef> +#include <rtl/strbuf.hxx> +#include <rtl/string.hxx> +#include <optional> +#include <string_view> + +#define LOK_NOTIFY_LOG_TO_CLIENT 1 + +#define LOK_LOG_STREAM(level, area, stream) \ + do { \ + ::std::ostringstream lok_detail_stream; \ + lok_detail_stream << level << ':'; \ + if (std::strcmp(level, "debug") != 0) \ + lok_detail_stream << area << ':'; \ + const char* const where = SAL_WHERE; \ + lok_detail_stream << where << stream; \ + SfxLokHelper::notifyLog(lok_detail_stream); \ + } while (false) + +#if LOK_NOTIFY_LOG_TO_CLIENT > 0 +#define LOK_INFO(area, stream) \ + LOK_LOG_STREAM("info", area, stream) \ + +#define LOK_WARN(area, stream) \ + LOK_LOG_STREAM("warn", area, stream) + +#else +#define LOK_INFO(area, stream) \ + SAL_INFO(area, stream) \ + +#define LOK_WARN(area, stream) \ + SAL_WARN(area, stream) + +#endif + +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) + {} +}; + +#include <boost/property_tree/ptree_fwd.hpp> + +namespace com::sun::star::ui { struct ContextChangeEventObject; }; + +class SFX2_DLLPUBLIC SfxLokHelper +{ +public: + /// Gets the short cut accelerators. + static std::unordered_map<OUString, css::uno::Reference<com::sun::star::ui::XAcceleratorConfiguration>>& getAcceleratorConfs(); + /// Create a new view shell from the current view frame. + /// This assumes a single document is ever loaded. + static int createView(); + /// Create a new view shell for the given DocId, for multi-document support. + static int createView(int nDocId); + /// Destroy a view shell from the global shell list. + static void destroyView(int nId); + /// Set a view shell as current one. + static void setView(int nId); + /// Set the edit mode for a document with callbacks disabled. + static void setEditMode(int nMode, vcl::ITiledRenderable* pDoc); + /// Get view shell with id + static SfxViewShell* getViewOfId(int nId); + /// Get the currently active view. + static int getView(const SfxViewShell* pViewShell = nullptr); + /// Get the number of views of the current DocId. + static std::size_t getViewsCount(int nDocId); + /// Get viewIds of views of the current DocId. + static bool getViewIds(int nDocId, int* pArray, size_t nSize); + /// Set View Blocked for some uno commands + static void setBlockedCommandList(int nViewId, const char* blockedCommandList); + /// Get the document id for a view + static int getDocumentIdOfView(int nViewId); + /// Get the default language that should be used for views + static const LanguageTag & getDefaultLanguage(); + /// Set language of the given view. + static void setViewLanguage(int nId, const OUString& rBcp47LanguageTag); + /// Set the default language for views. + static void setDefaultLanguage(const OUString& rBcp47LanguageTag); + /// Enable/Disable AT support for the given view. + static void setAccessibilityState(int nId, bool nEnabled); + /// Get the language used by the loading view (used for all save operations). + static const LanguageTag & getLoadLanguage(); + /// Set the language used by the loading view (used for all save operations). + static void setLoadLanguage(const OUString& rBcp47LanguageTag); + /// Set the locale for the given view. + static void setViewLocale(int nId, const OUString& rBcp47LanguageTag); + /// Get the device form factor that should be used for a new view. + static LOKDeviceFormFactor getDeviceFormFactor(); + /// Set the device form factor that should be used for a new view. + static void setDeviceFormFactor(std::u16string_view rDeviceFormFactor); + + /// Set timezone of the given view. + /// @isSet true to use @rTimezone, even if it's empty. Otherwise, no timezone. + /// @rTimezone the value to set (which could be empty). + static void setDefaultTimezone(bool isSet, const OUString& rTimezone); + /// Get timezone of the given view. See @setDefaultTimezone. + static std::pair<bool, OUString> getDefaultTimezone(); + /// Set the timezone of the given view. + static void setViewTimezone(int nId, bool isSet, const OUString& rTimezone); + /// Get the timezone of the given view. + static std::pair<bool, OUString> getViewTimezone(int nId); + + /// 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 other views showing the same document as pThisView, with a payload of rKey-rPayload. + static void notifyOtherViews(const SfxViewShell* pThisView, int nType, std::string_view rKey, + const OString& rPayload); + /// Invoke the LOK callback of all views except pThisView, with a JSON payload created from the given property tree. + static void notifyOtherViews(const SfxViewShell* pThisView, int nType, + const boost::property_tree::ptree& rTree); + /// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them. + static void notifyOtherView(const SfxViewShell* pThisView, SfxViewShell const* pOtherView, + int nType, std::string_view rKey, const OString& rPayload); + /// Same as notifyOtherViews(), the property-tree version, but works on a selected "other" view, not on all of them. + static void notifyOtherView(const SfxViewShell* pThisView, SfxViewShell const* pOtherView, + int nType, const boost::property_tree::ptree& rTree); + + /// Emits a LOK_CALLBACK_STATE_CHANGED + static void sendUnoStatus(const SfxViewShell* pShell, const SfxPoolItem* pItem); + /// Emits a LOK_CALLBACK_WINDOW + static void notifyWindow(const SfxViewShell* pThisView, + vcl::LOKWindowId nWindowId, + std::u16string_view rAction, + const std::vector<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 of the same document - if @bInvalidateAll - first invalidates all parts + static void notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc, bool bInvalidateAll = true); + /// Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED for all views of the same document with the same part + static void notifyPartSizeChangedAllViews(vcl::ITiledRenderable* pDoc, int nPart); + /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed. + static void notifyInvalidation(SfxViewShell const* pThisView, int nPart, tools::Rectangle const *); + /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed + /// uses the Part reported by pThisView + static void notifyInvalidation(SfxViewShell const* pThisView, tools::Rectangle const *); + /// Notifies all views with the given type and payload. + static void notifyAllViews(int nType, const OString& rPayload); + + /// Notify about the editing context change. + static void notifyContextChange(const css::ui::ContextChangeEventObject& rEvent); + + /// Emits an LOK_CALLBACK_VIEW_RENDER_STATE + static void notifyViewRenderState(SfxViewShell const* pViewShell, vcl::ITiledRenderable* pDoc); + + // Notify about the given type needing an update. + static void notifyUpdate(SfxViewShell const* pViewShell, int nType); + // Notify about the given type needing a per-viewid update. + static void notifyUpdatePerViewId(SfxViewShell const* pViewShell, int nType); + /// Same as notifyUpdatePerViewId(), pTargetShell will be notified, relevant viewId in pViewShell, + /// pSourceView->getLOKPayload() will be called to get the data. + static void notifyUpdatePerViewId(SfxViewShell const* pTargetShell, SfxViewShell const* pViewShell, + SfxViewShell const* pSourceShell, int nType); + // Notify other views about the given type needing a per-viewid update. + static void notifyOtherViewsUpdatePerViewId(SfxViewShell const* pViewShell, int nType); + + static OString makePayloadJSON(const SfxViewShell* pThisView, int nViewId, std::string_view rKey, const OString& rPayload); + /// Makes a LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR payload, but tweaks it according to setOptionalFeatures() if needed. + static OString makeVisCursorInvalidation(int nViewId, const OString& rRectangle, + bool bMispelledWord = false, const OString& rHyperlink = ""_ostr); + + /// 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 tools::Long MaxTwips = 1e9; + + /// Helper for diagnosing run-time problems + static void dumpState(rtl::OStringBuffer &rState); + + /// Process the mouse event in the currently active in-place component (if any). + /// Returns true if the event has been processed, and no further processing is necessary. + static bool testInPlaceComponentMouseEventHit(SfxViewShell* pViewShell, int nType, int nX, + int nY, int nCount, int nButtons, int nModifier, + double fScaleX, double fScaleY, + bool bNegativeX = false); + + static VclPtr<vcl::Window> getInPlaceDocWindow(SfxViewShell* pViewShell); + + static void notifyLog(const std::ostringstream& stream); + +private: + static int createView(SfxViewFrame& rViewFrame, ViewShellDocId docId); +}; + +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 && pOtherViewShell->GetDocId() == pThisViewShell->GetDocId()) + { + f(pOtherViewShell); + } + pViewShell = SfxViewShell::GetNext(*pViewShell); + } +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/mailmodelapi.hxx b/include/sfx2/mailmodelapi.hxx new file mode 100644 index 0000000000..47d5b40865 --- /dev/null +++ b/include/sfx2/mailmodelapi.hxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_MAILMODELAPI_HXX +#define INCLUDED_SFX2_MAILMODELAPI_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <rtl/ustring.hxx> +#include <sfx2/dllapi.h> +#include <vector> +#include <string_view> +#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_SUCCESSFUL, + SAVE_CANCELLED, + SAVE_ERROR + }; + ::std::vector< OUString > maAttachedDocuments; + static SaveResult SaveDocumentAsFormat( const OUString& aSaveFileName, + const css::uno::Reference< css::uno::XInterface >& xFrameOrModel, + const OUString& rType, + OUString& rFileNamePath ); + +private: + std::unique_ptr<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, + std::u16string_view rType, + bool bModified, + sal_Int32& rNumArgs, + css::uno::Sequence< css::beans::PropertyValue >& rArgs ); + +public: + enum SendMailResult + { + SEND_MAIL_OK, + SEND_MAIL_CANCELLED, + SEND_MAIL_ERROR + }; + + SfxMailModel(); + ~SfxMailModel(); + + void AddToAddress( const OUString& rAddress ); + + /** attaches a document to the current attachment list, can be called more than once. + * at the moment there will be a dialog for export executed for every model which is going to be attached. + * + * \param xModel + The current model to attach + * \param sAttachmentTitle + The title which will be used as attachment title + * \return @see error code + */ + SendMailResult AttachDocument( const css::uno::Reference< css::uno::XInterface >& xFrameOrModel, + const OUString& sAttachmentTitle ); + + SendMailResult SaveAndSend( const css::uno::Reference< css::frame::XFrame >& xFrame, + const OUString& rType ); + SendMailResult Send( const css::uno::Reference< css::frame::XFrame >& xFrame ); + + bool IsEmpty() const; +}; + +bool CreateFromAddress_Impl( OUString& rFrom ); + +#endif // INCLUDED_SFX2_MAILMODELAPI_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/mieclip.hxx b/include/sfx2/mieclip.hxx new file mode 100644 index 0000000000..bc2a431b3a --- /dev/null +++ b/include/sfx2/mieclip.hxx @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SFX2_MIECLIP_HXX +#define INCLUDED_SFX2_MIECLIP_HXX + +#include <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 0000000000..c89705726e --- /dev/null +++ b/include/sfx2/minfitem.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <rtl/ustring.hxx> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <svl/poolitem.hxx> +#include <config_features.h> + +#if HAVE_FEATURE_SCRIPTING + +class BasicManager; + +class SFX2_DLLPUBLIC SfxMacroInfoItem final : public SfxPoolItem +{ + const BasicManager* pBasicManager; + OUString aLibName; + OUString aModuleName; + OUString aMethodName; + OUString aCommentText; + +public: + static SfxPoolItem* CreateDefault(); + SfxMacroInfoItem( sal_uInt16 nWhich, + const BasicManager* pMgr, + OUString aLibName, + OUString aModuleName, + OUString aMethodName, + OUString aComment); + + 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 0000000000..099222c1aa --- /dev/null +++ b/include/sfx2/module.hxx @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_MODULE_HXX +#define INCLUDED_SFX2_MODULE_HXX + +#include <memory> +#include <optional> +#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; + +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(const 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::optional<SfxStyleFamilies> CreateStyleFamilies() { return {}; } + + static SfxModule* GetActiveModule( SfxViewFrame* pFrame=nullptr ); + static FieldUnit GetCurrentFieldUnit(); + /** retrieves the field unit of the module belonging to the document displayed in the given frame + + Effectively, this method looks up the SfxViewFrame belonging to the given XFrame, then the SfxModule belonging to + the document in this frame, then this module's field unit. + + Failures in any of those steps are reported as assertion in non-product builds, and then FieldUnit::MM_100TH is returned. + */ + static FieldUnit GetModuleFieldUnit( css::uno::Reference< css::frame::XFrame > const & i_frame ); + FieldUnit GetFieldUnit() const; + + SAL_DLLPRIVATE SfxTbxCtrlFactory* GetTbxCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const; + SAL_DLLPRIVATE SfxStbCtrlFactory* GetStbCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const; + SAL_DLLPRIVATE SfxChildWinFactory* GetChildWinFactoryById(sal_uInt16 nId) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/msg.hxx b/include/sfx2/msg.hxx new file mode 100644 index 0000000000..c8d343b04b --- /dev/null +++ b/include/sfx2/msg.hxx @@ -0,0 +1,283 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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/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 = 0x0000, // default + + TOGGLE = 0x0004, // inverted for Execute old value + AUTOUPDATE = 0x0008, // invalidated the status automatically after execute + ASYNCHRON = 0x0020, // via Post-Message + + NORECORD = 0x0100, // no recording + RECORDPERITEM = 0x0200, // each item, one statement + RECORDPERSET = 0x0400, // The whole Set is a Statement, default + RECORDABSOLUTE = 0x1000000, // Recording with absolute Target + + METHOD = 0x4000, + + FASTCALL = 0x8000, // No test if disabled before Execute + + MENUCONFIG = 0x20000, // configurable Menu + TOOLBOXCONFIG = 0x40000, // configurable Toolboxen + ACCELCONFIG = 0x80000, // configurable keys + + CONTAINER = 0x100000, // Operated by the container at InPlace + READONLYDOC = 0x200000 // also available for read-only Documents +}; + +namespace o3tl +{ + template<> struct typed_flags<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 + OUString pUnoName; // UnoName for the Slots + +public: + + template <size_t N> + SfxSlot(sal_uInt16 sId, SfxGroupId gId, SfxSlotMode flags, sal_uInt16 masterSlotId, + sal_uInt16 value, SfxExecFunc exec, SfxStateFunc state, const SfxType* type, + const SfxSlot* nextSlot, const SfxFormalArgument* firstArgDef, sal_uInt16 argDefCount, + SfxDisableFlags disableFlags, const char (&literal)[N]) + : nSlotId(sId) + , nGroupId(gId) + , nFlags(flags) + , nMasterSlotId(masterSlotId) + , nValue(value) + , fnExec(exec) + , fnState(state) + , pType(type) + , pNextSlot(nextSlot) + , pFirstArgDef(firstArgDef) + , nArgDefCount(argDefCount) + , nDisableFlags(disableFlags) + , pUnoName(literal) + { + } + + 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 OUString& GetUnoName() const { return pUnoName; } + SFX2_DLLPUBLIC OUString GetCommand() 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 0000000000..7aa38904c3 --- /dev/null +++ b/include/sfx2/msgpool.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_MSGPOOL_HXX +#define INCLUDED_SFX2_MSGPOOL_HXX + +#include <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 ); + + 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/namedcolor.hxx b/include/sfx2/namedcolor.hxx new file mode 100644 index 0000000000..1c5fe24b51 --- /dev/null +++ b/include/sfx2/namedcolor.hxx @@ -0,0 +1,61 @@ +/* -*- 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/. + */ + +#pragma once + +#include <sal/config.h> +#include <sfx2/dllapi.h> + +#include <docmodel/color/ComplexColor.hxx> +#include <docmodel/theme/ThemeColorType.hxx> + +struct SFX2_DLLPUBLIC NamedColor +{ + Color m_aColor; + OUString m_aName; + sal_Int16 m_nThemeIndex = -1; + sal_Int16 m_nLumMod = 10000; + sal_Int16 m_nLumOff = 0; + + NamedColor() = default; + + NamedColor(Color const& rColor, OUString const& rName) + : m_aColor(rColor) + , m_aName(rName) + { + } + + model::ComplexColor getComplexColor() + { + model::ComplexColor aComplexColor; + + auto eThemeColorType = model::convertToThemeColorType(m_nThemeIndex); + + if (eThemeColorType != model::ThemeColorType::Unknown) + { + aComplexColor.setThemeColor(eThemeColorType); + + if (m_nLumMod != 10000) + aComplexColor.addTransformation({ model::TransformationType::LumMod, m_nLumMod }); + + if (m_nLumOff != 0) + aComplexColor.addTransformation({ model::TransformationType::LumOff, m_nLumOff }); + + aComplexColor.setFinalColor(m_aColor); + } + else + { + aComplexColor.setColor(m_aColor); + } + + return aComplexColor; + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/sfx2/navigat.hxx b/include/sfx2/navigat.hxx new file mode 100644 index 0000000000..febdefa817 --- /dev/null +++ b/include/sfx2/navigat.hxx @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SFX2_NAVIGAT_HXX +#define INCLUDED_SFX2_NAVIGAT_HXX + +#include <sfx2/childwin.hxx> +#include <sfx2/dockwin.hxx> + +class SFX2_DLLPUBLIC SfxNavigatorWrapper : public SfxChildWindow +{ +protected: + void Initialize(); +public: + SfxNavigatorWrapper(vcl::Window* pParent, sal_uInt16 nId); +}; + +class SFX2_DLLPUBLIC SfxNavigator : public SfxDockingWindow +{ +public: + SfxNavigator(SfxBindings* pBindings, SfxChildWindow* pChildWin, + vcl::Window* pParent, SfxChildWinInfo* pInfo); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/new.hxx b/include/sfx2/new.hxx new file mode 100644 index 0000000000..8cb2bd9b4e --- /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_DLLPRIVATE_LINK( Update, Timer *, void ); + + DECL_DLLPRIVATE_LINK(RegionSelect, weld::TreeView&, void); + DECL_DLLPRIVATE_LINK(TemplateSelect, weld::TreeView&, void); + DECL_DLLPRIVATE_LINK(DoubleClick, weld::TreeView&, bool); + DECL_DLLPRIVATE_LINK(Expand, weld::Expander&, void); + sal_uInt16 GetSelectedTemplatePos() const; + +public: + SfxNewFileDialog(weld::Window *pParent, SfxNewFileDialogMode nFlags); + virtual ~SfxNewFileDialog() override; + + // Returns false, when '- No -' is set as Template + // Template names can only be obtained when IsTemplate() returns true. + bool IsTemplate() const; + OUString GetTemplateFileName() const; + + // load template methods + SfxTemplateFlags GetTemplateFlags() const; + void SetTemplateFlags(SfxTemplateFlags nSet); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/newstyle.hxx b/include/sfx2/newstyle.hxx new file mode 100644 index 0000000000..23dbfa6121 --- /dev/null +++ b/include/sfx2/newstyle.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_NEWSTYLE_HXX +#define INCLUDED_SFX2_NEWSTYLE_HXX + +#include <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::Widget* pParent, SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam); + virtual ~SfxNewStyleDlg() override; + + OUString GetName() const + { + return comphelper::string::stripStart(m_xColBox->get_active_text(), ' '); + } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/notebookbar/SfxNotebookBar.hxx b/include/sfx2/notebookbar/SfxNotebookBar.hxx new file mode 100644 index 0000000000..7bf34d1cbf --- /dev/null +++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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> +#include <vcl/notebookbar/notebookbar.hxx> +#include <vcl/WeldedTabbedNotebookbar.hxx> +#include <vcl/EnumContext.hxx> + +#include <map> +#include <memory> +#include <string_view> + +namespace com::sun::star::frame +{ +class XFrame; +} +namespace com::sun::star::uno +{ +template <typename> class Reference; +} + +class SfxBindings; +class SfxViewFrame; +class SfxViewShell; +class SystemWindow; +class WeldedTabbedNotebookbar; + +namespace sfx2 +{ +/** Helpers for easier access to NotebookBar via the sfx2 infrastructure. +*/ +class SFX2_DLLPUBLIC SfxNotebookBar +{ +public: + static void CloseMethod(SfxBindings& rBindings); + static void CloseMethod(SystemWindow* pSysWindow); + + static bool IsActive(bool bConsiderSingleToolbar = false); + + /// Function to be called from the sdi's ExecMethod. + static void ExecMethod(SfxBindings& rBindings, const OUString& rUIName); + + /// Function to be called from the sdi's StateMethod. + static bool StateMethod(SfxBindings& rBindings, std::u16string_view rUIFile, + bool bReloadNotebookbar = false); + static bool StateMethod(SystemWindow* pSysWindow, + const css::uno::Reference<css::frame::XFrame>& xFrame, + std::u16string_view rUIFile, bool bReloadNotebookbar = false); + + /// Method temporarily blocks showing of the NotebookBar + static void LockNotebookBar(); + /// Method restores normal behaviour of the Notebookbar + static void UnlockNotebookBar(); + + static void RemoveListeners(SystemWindow const* pSysWindow); + + /** Show menu bar in all frames of current application */ + static void ShowMenubar(bool bShow); + /** Show menu bar only in current frame */ + static void ShowMenubar(SfxViewFrame const* pViewFrame, bool bShow); + static void ToggleMenubar(); + static void ReloadNotebookBar(std::u16string_view sUIPath); + +private: + static bool m_bLock; + static bool m_bHide; + + static std::map<const SfxViewShell*, std::shared_ptr<WeldedTabbedNotebookbar>> + m_pNotebookBarWeldedWrapper; + static std::map<const SfxViewShell*, VclPtr<NotebookBar>> m_pNotebookBarInstance; + + static void ResetActiveToolbarModeToDefault(vcl::EnumContext::Application eApp); + static void RemoveCurrentLOKWrapper(); + + DECL_DLLPRIVATE_STATIC_LINK(SfxNotebookBar, VclDisposeHdl, const SfxViewShell*, void); +}; + +} // namespace sfx2 + +#endif // INCLUDED_SFX2_NOTEBOOKBAR_SFXNOTEBOOKBAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/objface.hxx b/include/sfx2/objface.hxx new file mode 100644 index 0000000000..fadf510ca9 --- /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( const SfxModule* ); + + SAL_DLLPRIVATE bool ContainsSlot_Impl( const SfxSlot *pSlot ) const + { return pSlot >= pSlots && pSlot < pSlots + Count(); } +}; + + +// returns the number of functions in this cluster + +inline sal_uInt16 SfxInterface::Count() const +{ + return nCount; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/objitem.hxx b/include/sfx2/objitem.hxx new file mode 100644 index 0000000000..17b7f0cf1d --- /dev/null +++ b/include/sfx2/objitem.hxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_OBJITEM_HXX +#define INCLUDED_SFX2_OBJITEM_HXX + +#include <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; + + virtual bool QueryValue(css::uno::Any&, sal_uInt8 nMemberId = 0) const override; + virtual bool PutValue(const css::uno::Any&, sal_uInt8) override; + + SfxShell* GetShell() const + { return _pSh; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx new file mode 100644 index 0000000000..20e497b6e4 --- /dev/null +++ b/include/sfx2/objsh.hxx @@ -0,0 +1,939 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <comphelper/errcode.hxx> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/frame/XModel3.hpp> +#include <vcl/bitmapex.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 <string_view> + +#include <o3tl/typed_flags_set.hxx> +#include <functional> +#include <sfx2/AccessibilityIssue.hxx> + +namespace weld {class Button; } +namespace model {class ColorSet; } +struct NamedColor; +class SbxValue; +class SbxArray; +class BasicManager; +class SfxMedium; +class SfxObjectFactory; +class SfxDocumentInfoDialog; +class SfxStyleSheetBasePool; +class StarBASIC; +class Printer; +class SvKeyValueIterator; +class SfxBaseModel; +class SfxModule; +class SfxProgress; +class GDIMetaFile; +class INetURLObject; +class IndexBitSet; +class JobSetup; +class OutputDevice; +class Color; +class Fraction; +class SvGlobalName; +class InfobarData; +class VirtualDevice; + +enum class SfxModelFlags; +enum class SfxEventHintId; +enum class InfobarType; + +// These values presumably must match exactly the corresponding +// css::embed::Aspects ones (in offapi/com/sun/star/embed/Aspects.idl) +// and the DVASPECT_* ones in the Win32 API. + +#define ASPECT_CONTENT 1 +#define ASPECT_THUMBNAIL 2 /* 120 * 120, 6 Colors DIB in MetaFile */ +#define ASPECT_ICON 4 +#define ASPECT_DOCPRINT 8 + +namespace sfx2 +{ + class SvLinkSource; + class StyleManager; +} + +namespace com::sun::star::awt { class XWindow; } +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::document { struct CmisVersion; } +namespace com::sun::star::document { class XDocumentProperties; } +namespace com::sun::star::embed { class XStorage; } +namespace com::sun::star::frame { class XModel; } +namespace com::sun::star::graphic { class XGraphic; } +namespace com::sun::star::io { class XStream; } +namespace com::sun::star::script { class XLibraryContainer; } +namespace com::sun::star::security { class XCertificate; } +namespace com::sun::star::security { class XDocumentDigitalSignatures; } +namespace com::sun::star::security { struct DocumentSignatureInformation; } +namespace com::sun::star::task { class XInteractionHandler; } +namespace com::sun::star::lang { class XComponent; } +namespace com::sun::star::text { class XTextRange; } + +namespace sfx2 { class IXmlIdRegistry; } + +#define SFX_TITLE_TITLE 0 +#define SFX_TITLE_FILENAME 1 +#define SFX_TITLE_FULLNAME 2 +#define SFX_TITLE_APINAME 3 +#define SFX_TITLE_DETECT 4 +#define SFX_TITLE_CAPTION 5 +#define SFX_TITLE_PICKLIST 6 +#define SFX_TITLE_HISTORY 7 +#define SFX_TITLE_MAXLEN 10 // this gives the limits on length + +enum class SfxLoadedFlags +{ + NONE = 0, + MAINDOCUMENT = 1, + IMAGES = 2, + ALL = MAINDOCUMENT | IMAGES +}; +namespace o3tl +{ + template<> struct typed_flags<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. + There can be multiple edit windows (SfxViewShell) for one SfxObjectShell. +*/ + +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. + bool bRememberSignature; // Do we want to remember the signature. + + 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); + + css::uno::Sequence< css::security::DocumentSignatureInformation > rSignatureInfosRemembered; + + SAL_DLLPRIVATE bool SaveTo_Impl(SfxMedium &rMedium, const SfxItemSet* pSet ); + + // true if the document had macros (or similar) on load to trigger warning user + SAL_DLLPRIVATE bool GetHadCheckedMacrosOnLoad() const; + +protected: + SfxObjectShell(SfxObjectCreateMode); + SfxObjectShell(SfxModelFlags); // see sfxmodelfactory.hxx + virtual ~SfxObjectShell() override; + + void ModifyChanged(); + virtual bool Close() override; + + /// template method, called by FlushDocInfo; this implementation is empty + virtual void DoFlushDocInfo(); + + // helper method + void AddToRecentlyUsedList(); + + // Parent class for actual guard objects that would do useful work + class LockAllViewsGuard + { + public: + virtual ~LockAllViewsGuard() {} + }; + +public: + SFX_DECL_INTERFACE(SFX_INTERFACE_SFXDOCSH) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + static const css::uno::Sequence<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 + SAL_WARN_UNUSED_RESULT static SfxObjectShell* GetFirst( const std::function<bool ( const SfxObjectShell* )>& isObjectShell = nullptr, + bool bOnlyVisible = true ); + SAL_WARN_UNUSED_RESULT static SfxObjectShell* GetNext( const SfxObjectShell& rPrev, + const std::function<bool ( const SfxObjectShell* )>& isObjectShell = nullptr, + bool bOnlyVisible = true ); + SAL_WARN_UNUSED_RESULT 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(); + ErrCodeMsg GetErrorIgnoreWarning() const; + ErrCodeMsg GetErrorCode() const; + void SetError(const ErrCodeMsg& rErr); + + /** + * Initialize bare minimum just enough for unit test runs. + * + * @return true if the initialization is successful, false otherwise. + */ + void DoInitUnitTest(); + bool DoInitNew(); + bool DoLoad( SfxMedium* pMedium ); + bool DoLoadExternal( SfxMedium* pMed ); + bool DoSave(); + bool DoSaveAs( SfxMedium &rNewStor ); + bool DoSaveObjectAs( SfxMedium &rNewStor, bool bCommit ); + + // TODO/LATER: currently only overridden in Calc, should be made non-virtual + virtual bool DoSaveCompleted( SfxMedium* pNewStor=nullptr, bool bRegisterRecent=true ); + /// Terminate any in-flight editing. Used before saving, primarily by Calc to commit cell changes. + virtual void TerminateEditing() {} + + bool LoadOwnFormat( SfxMedium& pMedium ); + virtual bool SaveAsOwnFormat( SfxMedium& pMedium ); + virtual bool ConvertFrom( SfxMedium &rMedium ); + virtual bool ConvertTo( SfxMedium &rMedium ); + virtual bool InitNew( const css::uno::Reference< css::embed::XStorage >& xStorage ); + virtual bool Load( SfxMedium &rMedium ); + virtual bool LoadFrom( SfxMedium& rMedium ); + virtual bool Save(); + virtual bool SaveAs( SfxMedium &rMedium ); + virtual bool SaveCompleted( const css::uno::Reference< css::embed::XStorage >& xStorage ); + bool SwitchPersistence( + const css::uno::Reference< css::embed::XStorage >& xStorage ); + virtual void UpdateLinks(); + virtual bool LoadExternal( SfxMedium& rMedium ); + bool IsConfigOptionsChecked() const; + void SetConfigOptionsChecked( bool bChecked ); + + // called for a few slots like SID_SAVE[AS]DOC, SID_PRINTDOC[DIRECT], derived classes may abort the action + virtual bool QuerySlotExecutable( sal_uInt16 nSlotId ); + + void SaveChildren(bool bObjectsOnly=false); + bool SaveAsChildren( SfxMedium &rMedium ); + bool SwitchChildrenPersistence( + const css::uno::Reference< css::embed::XStorage >& xStorage, + bool bForceNonModified = false ); + bool SaveCompletedChildren(); + + /** a very special case to insert at a position in Writer from UNO, + via OwnSubFilterService */ + virtual bool InsertGeneratedStream(SfxMedium& rMedium, + css::uno::Reference<css::text::XTextRange> const& xInsertPosition); + virtual bool ImportFrom( SfxMedium &rMedium, + css::uno::Reference<css::text::XTextRange> const& xInsertPosition); + bool ExportTo( SfxMedium &rMedium ); + + /** Returns true if preparing was successful, else false. */ + bool PrepareForSigning(weld::Window* pDialogParent); + bool CheckIsReadonly(bool bSignScriptingContent, weld::Window* pDialogParent = nullptr); + void RecheckSignature(bool bAlsoRecheckScriptingSignature); + void AfterSigning(bool bSignSuccess, bool bSignScriptingContent); + bool HasValidSignatures() const; + SignatureState GetDocumentSignatureState(); + bool 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); + bool ResignDocument(css::uno::Sequence< css::security::DocumentSignatureInformation >& rSignaturesInfo); + + 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(); + bool SignScriptingContent(weld::Window* pDialogParent); + DECL_DLLPRIVATE_LINK(SignDocumentHandler, weld::Button&, void); + + virtual std::shared_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet& rItemSet); + + ErrCode CallBasic( std::u16string_view rMacro, std::u16string_view rBasicName, + SbxArray* pArgs, SbxValue* pRet = nullptr ); + + ErrCode CallXScript( + const OUString& rScriptURL, + const css::uno::Sequence< css::uno::Any >& aParams, + css::uno::Any& aRet, + css::uno::Sequence< sal_Int16 >& aOutParamIndex, + css::uno::Sequence< css::uno::Any >& aOutParam, + bool bRaiseError = true, + const css::uno::Any* aCaller = nullptr ); + + static ErrCode CallXScript( + const css::uno::Reference< css::uno::XInterface >& _rxScriptContext, + const OUString& rScriptURL, + const css::uno::Sequence< css::uno::Any >& aParams, + css::uno::Any& aRet, + css::uno::Sequence< sal_Int16 >& aOutParamIndex, + css::uno::Sequence< css::uno::Any >& aOutParam, + bool bRaiseError = true, + const css::uno::Any* aCaller = nullptr + ); + + /** adjusts the internal macro mode, according to the current security settings + + Finally, the macro mode is either NEVER_EXECUTE or ALWAYS_EXECUTE_NO_WARN. + + @return + whether macros from this document should be executed + */ + bool AdjustMacroMode(); + + static bool UnTrustedScript(const OUString& rScriptURL); + + static bool isScriptAccessAllowed(const css::uno::Reference<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, std::u16string_view 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; + + // true if this type of link, from a document, is allowed by the user to be passed to uno:OpenDoc + static bool AllowedLinkProtocolFromDocument(const OUString& rUrl, SfxObjectShell* pObjShell, weld::Window* pDialogParent); + + 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 ); + void QueryHiddenInformation( HiddenWarningFact eFact ); + bool IsSecurityOptOpenReadOnly() const; + void SetSecurityOptOpenReadOnly( bool bOpenReadOnly ); + + Size GetFirstPageSize() const; + bool DoClose(); + std::shared_ptr<GDIMetaFile> GetPreviewMetaFile( bool bFullContent = false ) const; + BitmapEx GetPreviewBitmap() const; + virtual void CancelTransfers(); + + bool GenerateAndStoreThumbnail( + bool bEncrypted, + const css::uno::Reference< css::embed::XStorage >& xStor ); + + bool WriteThumbnail( + bool bEncrypted, + const css::uno::Reference< css::io::XStream >& xStream ); + + bool IsInGenerateAndStoreThumbnail() const {return bIsInGenerateThumbnail;}//optimize thumbnail generate and store procedure to improve odt saving performance, i120030 + + /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted. + bool IsAvoidRecentDocs() const { return mbAvoidRecentDocs; } + + bool IsRememberingSignature() const { return bRememberSignature; } + + /// 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(); + + // Transfer IFace + bool IsAbortingImport() const; + void FinishedLoading( SfxLoadedFlags nWhich = SfxLoadedFlags::ALL ); + + void TemplateDisconnectionAfterLoad(); + void SetLoading(SfxLoadedFlags nFlags); + bool IsLoading() const; + bool IsLoadingFinished() const; + void SetAutoLoad( const INetURLObject&, sal_uInt32 nTime, bool bReload ); + bool IsAutoLoadLocked() const; + + // Misc + bool IsPreview() const; + SfxObjectCreateMode GetCreateMode() const { return eCreateMode; } + SfxProgress* GetProgress() const; + void SetWaitCursor( bool bSet ) const; + + // Naming Interface + void SetTitle( const OUString& rTitle ); + /* Small non-zero values of nMaxLen don't mean length, but have a magic meaning: + 0 (default) + the title itself, as it is + + 1 (==SFX_TITLE_FILENAME) + provides the logical file name without path + (under WNT depending on the system settings + without extension) + + 2 (==SFX_TITLE_FULLNAME) + provides the logical file names with full path + (remote =>:: com:: sun:: star:: util:: URL) + + 3 (==SFX_TITLE_APINAME) + provides the logical filename without path + and extension + + 4 (==SFX_TITLE_DETECT) + provides the complete title, if not set yet + it will be created from DocInfo or the name of + the medium. + + 5 (==SFX_TITLE_CAPTION) + provides the Title just like MB now in the + CaptionBar view + + 6 (==SFX_TITLE_PICKLIST) + returns the Title, just like MB now would + display it in the PickList + + 7 (==SFX_TITLE_HISTORY) + returns the Title just like MB now would + display it in the History + + 10 bis USHRT_MAX + provides the 'nMaxLength' of the logical + file name including the path + (remote => css::util::URL) + */ + OUString GetTitle( sal_uInt16 nMaxLen = 0 ) const; + void InvalidateName(); // Re-set to unnamed + +#if defined(_WIN32) + // DDE-Interface + bool DdeExecute( const OUString& rCmd ); + virtual bool DdeGetData( const OUString& rItem, + const OUString& rMimeType, + css::uno::Any & rValue ); + virtual bool DdeSetData( const OUString& rItem, + const OUString& rMimeType, + const css::uno::Any & rValue ); +#endif + virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem ); + virtual void ReconnectDdeLink(SfxObjectShell& rServer); + + static void ReconnectDdeLinks(SfxObjectShell& rServer); + + // Contents + virtual SfxStyleSheetBasePool* GetStyleSheetPool(); + + virtual void LoadStyles(SfxObjectShell &rSource); + + virtual sfx2::StyleManager* GetStyleManager(); + + // Determine the position of the "Automatic" filter in the stylist + void SetAutoStyleFilterIndex(sal_uInt16 nSet); + sal_uInt16 GetAutoStyleFilterIndex() const; + bool HasBasic() const; + BasicManager* GetBasicManager() const; + css::uno::Reference< css::script::XLibraryContainer > + GetBasicContainer(); + css::uno::Reference< css::script::XLibraryContainer > + GetDialogContainer(); + StarBASIC* GetBasic() const; + + std::optional<NamedColor> GetRecentColor(sal_uInt16 nSlotId); + void SetRecentColor(sal_uInt16 nSlotId, const NamedColor& rColor); + + virtual std::set<Color> GetDocColors(); + virtual std::shared_ptr<model::ColorSet> GetThemeColors(); + + // Accessibility Check + virtual sfx::AccessibilityIssueCollection runAccessibilityCheck(); + + // Documents, for which to format the view size + + virtual SfxObjectShell* GetObjectShell() override; + + css::uno::Reference< css::frame::XModel3 > + GetModel() const; + // Only temporarily for the applications! + void SetBaseModel( SfxBaseModel* pModel ); + css::uno::Reference< css::frame::XModel3 > GetBaseModel() const; + // Only temporarily for the applications! + + virtual css::uno::Sequence< OUString > GetEventNames(); + + css::uno::Reference<css::awt::XWindow> GetDialogParent(SfxMedium const* pMedium = nullptr); + static SfxObjectShell* CreateObject( const OUString& rServiceName, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD ); + static SfxObjectShell* CreateObjectByFactoryName( const OUString& rURL, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD ); + static css::uno::Reference< css::lang::XComponent > + CreateAndLoadComponent( const SfxItemSet& rSet ); + static SfxObjectShell* GetShellFromComponent(const css::uno::Reference< css::uno::XInterface >& xComp); + static SfxObjectShell* GetParentShell(const css::uno::Reference<css::uno::XInterface>& xChild); + static OUString GetServiceNameFromFactory( const OUString& rFact ); + bool IsInPlaceActive() const; + bool IsUIActive() const; + + static bool CopyStoragesOfUnknownMediaType( + const css::uno::Reference< css::embed::XStorage >& xSource, + const css::uno::Reference<css::embed::XStorage>& xTarget, + const css::uno::Sequence<OUString>& rExceptions = css::uno::Sequence<OUString>()); + + bool isEditDocLocked() const; + bool isContentExtractionLocked() const; + bool isExportLocked() const; + bool isPrintLocked() const; + bool isSaveLocked() const; + + // The functions from SvPersist + void EnableSetModified( bool bEnable = true ); + bool IsEnableSetModified() const; + virtual void SetModified( bool bModified = true ); + bool IsModified() const; + + /** + * @param bChart true if the file is a chart doc and FillClass should not be called + */ + void SetupStorage( + const css::uno::Reference< css::embed::XStorage >& xStorage, + sal_Int32 nVersion, bool bTemplate ) const; + + css::uno::Reference< css::embed::XStorage > const & GetStorage(); + + SvGlobalName const & GetClassName() const; + + // comphelper::IEmbeddedHelper + virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const override; + virtual css::uno::Reference < css::embed::XStorage > getStorage() const override + { + return const_cast<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, + bool bOutputForScreen = false ); + virtual void Draw( OutputDevice *, const JobSetup & rSetup, + sal_uInt16 nAspect, bool bOutputForScreen ) = 0; + + + virtual void FillClass( SvGlobalName * pClassName, + SotClipboardFormatId * pFormat, + OUString * pFullTypeName, + sal_Int32 nVersion, + bool bTemplate = false) const = 0; + + // change recording and respective passwword protection for Writer and Calc + // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON + // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT + virtual bool IsChangeRecording() const; + virtual bool HasChangeRecordProtection() const; + virtual void SetChangeRecording( bool bActivate, bool bLockAllViews = false ); + virtual void SetProtectionPassword( const OUString &rPassword ); + virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash ); + + static bool IsOwnStorageFormat(const SfxMedium &); + + /** Append Infobar once the frame is ready. + Useful when you want to register an Infobar before the doc/frame is fully loaded. */ + void AppendInfoBarWhenReady(const OUString& sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, InfobarType aInfobarType, + bool bShowCloseButton = true); + std::vector<InfobarData>& getPendingInfobars(); + + SAL_DLLPRIVATE bool CreatePreview_Impl(bool bFullContent, VirtualDevice* pDevice, GDIMetaFile* pFile) const; + + SAL_DLLPRIVATE static bool IsPackageStorageFormat_Impl(const SfxMedium &); + + SAL_DLLPRIVATE bool ConnectTmpStorage_Impl( const css::uno::Reference< css::embed::XStorage >& xStorage, SfxMedium* pMedium ); + SAL_DLLPRIVATE bool DisconnectStorage_Impl( SfxMedium& rSrcMedium, SfxMedium& rTargetMedium ); + + SAL_DLLPRIVATE bool PutURLContentsToVersionStream_Impl( + const OUString& aURL, + const css::uno::Reference< css::embed::XStorage >& xDocStorage, + const OUString& aStreamName ); + + SAL_DLLPRIVATE OUString CreateTempCopyOfStorage_Impl( + const css::uno::Reference< css::embed::XStorage >& xStorage ); + + SAL_DLLPRIVATE void InitOwnModel_Impl(); + SAL_DLLPRIVATE void BreakMacroSign_Impl( bool bBreakMacroSing ); + SAL_DLLPRIVATE void CheckSecurityOnLoading_Impl(); + SAL_DLLPRIVATE void CheckForBrokenDocSignatures_Impl(); + SAL_DLLPRIVATE void CheckEncryption_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler ); + SAL_DLLPRIVATE void SetModifyPasswordEntered( bool bEntered = true ); + SAL_DLLPRIVATE bool IsModifyPasswordEntered() const; + + SAL_DLLPRIVATE void InitBasicManager_Impl(); + SAL_DLLPRIVATE SfxObjectShell_Impl* Get_Impl() { return pImpl.get(); } + + SAL_DLLPRIVATE static bool UseInteractionToHandleError( + const css::uno::Reference< css::task::XInteractionHandler >& xHandler, + const ErrCodeMsg& 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, + bool bOutputForScreen ); + + // 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(std::u16string_view 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 ); + + // configuration items + SAL_DLLPRIVATE SignatureState ImplGetSignatureState( bool bScriptingContent = false ); + + SAL_DLLPRIVATE bool QuerySaveSizeExceededModules_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler ); + SAL_DLLPRIVATE static bool QueryAllowExoticFormat_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler, + const OUString& rURL, + const OUString& rFilterUIName); + + SAL_DLLPRIVATE void CheckOut( ); + SAL_DLLPRIVATE void CancelCheckOut( ); + SAL_DLLPRIVATE void CheckIn( ); + SAL_DLLPRIVATE css::uno::Sequence< css::document::CmisVersion > GetCmisVersions() const; + + /** override this if you have a XmlIdRegistry. */ + virtual const sfx2::IXmlIdRegistry* GetXmlIdRegistry() const { return nullptr; } + + /// Is this read-only object shell opened via .uno:SignPDF? + bool IsSignPDF() const; + + /// Gets the certificate that is already picked by the user but not yet used for signing. + css::uno::Reference<css::security::XCertificate> GetSignPDFCertificate() const; + + /// Gets grab-bagged password info to unprotect change tracking with verification + css::uno::Sequence< css::beans::PropertyValue > GetDocumentProtectionFromGrabBag() const; + + // Lock all unlocked views, and returns a guard object which unlocks those views when destructed + virtual std::unique_ptr<LockAllViewsGuard> LockAllViews() + { + return std::make_unique<LockAllViewsGuard>(); + } + +}; + +#define SFX_GLOBAL_CLASSID \ + 0x9eaba5c3, 0xb232, 0x4309, \ + 0x84, 0x5f, 0x5f, 0x15, 0xea, 0x50, 0xd0, 0x74 + + struct ModifyBlocker_Impl + { + private: + SfxObjectShell* pPersist; + bool bWasEnabled; + public: + 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 +{ + 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 0000000000..c23e10989b --- /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 <comphelper/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 0000000000..1464ec40c5 --- /dev/null +++ b/include/sfx2/pageids.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_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) +#define RID_SVXPAGE_LANGTOOL_OPTIONS (RID_SVX_START + 210) +#define RID_SVXPAGE_DEEPL_OPTIONS (RID_SVX_START + 211) + +// 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 0000000000..3ddffed196 --- /dev/null +++ b/include/sfx2/passwd.hxx @@ -0,0 +1,141 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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::LevelBar> m_xPassword1StrengthBar; + std::unique_ptr<weld::Label> m_xPassword1PolicyLabel; + 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::LevelBar> m_xPassword2StrengthBar; + std::unique_ptr<weld::Label> m_xPassword2PolicyLabel; + 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::Label> m_xOnlyAsciiFT; + + std::unique_ptr<weld::Button> m_xOKBtn; + + std::shared_ptr<weld::MessageDialog> m_xConfirmFailedDialog; + + OUString maMinLenPwdStr; + OUString maMinLenPwdStr1; + OUString maEmptyPwdStr; + OUString maMainPwdStr; + sal_uInt16 mnMinLen; + SfxShowExtras mnExtras; + std::optional<OUString> moPasswordPolicy; + + 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 OUString& 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 OUString& rId) + { + m_xConfirm1ED->set_help_id(rId); + } + + void ShowExtras(SfxShowExtras nExtras) + { + mnExtras = nExtras; + } + + void AllowAsciiOnly(); + void ShowMinLengthText(bool bShow); + + void PreRun(); + + virtual short run() override; + + ~SfxPasswordDialog(); +}; + +#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 0000000000..8d10b2cc77 --- /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 0000000000..e01991dad3 --- /dev/null +++ b/include/sfx2/printopt.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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/printer/Options.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::Widget> m_xReduceTransparencyImg; + std::unique_ptr<weld::RadioButton> m_xReduceTransparencyAutoRB; + std::unique_ptr<weld::RadioButton> m_xReduceTransparencyNoneRB; + std::unique_ptr<weld::Widget> m_xReduceTransparencyModeImg; + std::unique_ptr<weld::CheckButton> m_xReduceGradientsCB; + std::unique_ptr<weld::Widget> m_xReduceGradientsImg; + std::unique_ptr<weld::RadioButton> m_xReduceGradientsStripesRB; + std::unique_ptr<weld::RadioButton> m_xReduceGradientsColorRB; + std::unique_ptr<weld::Widget> m_xReduceGradientsModeImg; + std::unique_ptr<weld::SpinButton> m_xReduceGradientsStepCountNF; + std::unique_ptr<weld::CheckButton> m_xReduceBitmapsCB; + std::unique_ptr<weld::Widget> m_xReduceBitmapsImg; + 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::Widget> m_xReduceBitmapsModeImg; + std::unique_ptr<weld::ComboBox> m_xReduceBitmapsResolutionLB; + std::unique_ptr<weld::CheckButton> m_xReduceBitmapsTransparencyCB; + std::unique_ptr<weld::Widget> m_xReduceBitmapsTransparencyImg; + std::unique_ptr<weld::CheckButton> m_xConvertToGreyscalesCB; + std::unique_ptr<weld::Widget> m_xConvertToGreyscalesImg; + std::unique_ptr<weld::CheckButton> m_xPaperSizeCB; + std::unique_ptr<weld::Widget> m_xPaperSizeImg; + std::unique_ptr<weld::CheckButton> m_xPaperOrientationCB; + std::unique_ptr<weld::Widget> m_xPaperOrientationImg; + std::unique_ptr<weld::CheckButton> m_xTransparencyCB; + std::unique_ptr<weld::Widget> m_xTransparencyImg; + +private: + + vcl::printer::Options maPrinterOptions; + vcl::printer::Options maPrintFileOptions; + + DECL_DLLPRIVATE_LINK( ToggleOutputPrinterRBHdl, weld::Toggleable&, void ); + DECL_DLLPRIVATE_LINK( ToggleOutputPrintFileRBHdl, weld::Toggleable&, void); + + DECL_DLLPRIVATE_LINK( ClickReduceTransparencyCBHdl, weld::Toggleable&, void ); + DECL_DLLPRIVATE_LINK( ClickReduceGradientsCBHdl, weld::Toggleable&, void ); + DECL_DLLPRIVATE_LINK( ClickReduceBitmapsCBHdl, weld::Toggleable&, void ); + + DECL_DLLPRIVATE_LINK( ToggleReduceGradientsStripesRBHdl, weld::Toggleable&, void ); + DECL_DLLPRIVATE_LINK( ToggleReduceBitmapsResolutionRBHdl, weld::Toggleable&, void ); + + SAL_DLLPRIVATE void ImplUpdateControls( const vcl::printer::Options* pCurrentOptions ); + SAL_DLLPRIVATE void ImplSaveControls( vcl::printer::Options* pCurrentOptions ); + + virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; + +public: + + SfxCommonPrintOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); + virtual ~SfxCommonPrintOptionsTabPage() override; + + virtual OUString GetAllStrings() 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 0000000000..ceee49b6c5 --- /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 0000000000..63c6544bfe --- /dev/null +++ b/include/sfx2/request.hxx @@ -0,0 +1,128 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <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 weld { class Window; } + +class SFX2_DLLPUBLIC SfxRequest final +{ +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 ); + ~SfxRequest(); + + 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 nullptr; + return pArgs->GetItem<T>(nSlotId, false); + } + template<class T> const T* GetArg(TypedWhichId<T> nSlotId) const + { + if (!pArgs) + return nullptr; + return pArgs->GetItem(nSlotId, false); + } + + void ReleaseArgs(); + void SetReturnValue(const SfxPoolItem &); + const SfxPoolItemHolder& GetReturnValue() const; + + static css::uno::Reference< css::frame::XDispatchRecorder > GetMacroRecorder(const SfxViewFrame& rFrame); + static bool HasMacroRecorder(const SfxViewFrame& rFrame); + SfxCallMode GetCallMode() const; + void AllowRecording( bool ); + bool AllowsRecording() const; + bool IsAPI() const; + bool IsSynchronCall() const; + void SetSynchronCall( bool bSynchron ); + + bool IsDone() const; + void Done( bool bRemove = false ); + + void Ignore(); + void Cancel(); + bool IsCancelled() const; + void Done(const SfxItemSet &); + + void ForgetAllArgs(); + + /** Return the window that should be used as the parent for any dialogs this request creates + */ + weld::Window* GetFrameWeld() const; +private: + const SfxRequest& operator=(const SfxRequest &) = delete; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/safemode.hxx b/include/sfx2/safemode.hxx new file mode 100644 index 0000000000..34602c4ea6 --- /dev/null +++ b/include/sfx2/safemode.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SFX2_SAFEMODE_HXX +#define INCLUDED_SFX2_SAFEMODE_HXX + +#include <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 0000000000..978cd5669d --- /dev/null +++ b/include/sfx2/sfxbasecontroller.hxx @@ -0,0 +1,222 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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; } +namespace weld { class Button; } + +struct IMPL_SfxBaseController_DataContainer ; // impl. struct to hold member of class SfxBaseController + +class NotifyEvent; +class SfxViewFrame; +class SfxViewShell; + +sal_Int16 MapGroupIDToCommandGroup( SfxGroupId nGroupID ); + + + + +typedef ::cppu::WeakImplHelper < css::frame::XController2 + , css::frame::XControllerBorder + , css::frame::XDispatchProvider + , css::task::XStatusIndicatorSupplier + , css::ui::XContextMenuInterception + , css::awt::XUserInputInterception + , css::frame::XDispatchInformationProvider + , css::frame::XInfobarProvider + , css::frame::XTitle + , css::frame::XTitleChangeBroadcaster + , css::lang::XInitialization + > SfxBaseController_Base; + +class SFX2_DLLPUBLIC SfxBaseController :public SfxBaseController_Base + ,public ::cppu::BaseMutex +{ + +// public methods + + +public: + + + // constructor/destructor + + + SfxBaseController( SfxViewShell* pView ) ; + + virtual ~SfxBaseController() override ; + + SAL_DLLPRIVATE void ReleaseShell_Impl(); + SAL_DLLPRIVATE void BorderWidthsChanged_Impl(); + + css::uno::Reference< css::task::XStatusIndicator > SAL_CALL getStatusIndicator( ) override; + + + // XController2 + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL getComponentWindow() override; + virtual OUString SAL_CALL getViewControllerName() override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCreationArguments() override; + + virtual css::uno::Reference< css::ui::XSidebarProvider > SAL_CALL getSidebar() override; + + + // XController + + + virtual void SAL_CALL attachFrame( const css::uno::Reference< css::frame::XFrame >& xFrame ) override ; + + virtual sal_Bool SAL_CALL attachModel( const css::uno::Reference< css::frame::XModel >& xModel ) override ; + + virtual sal_Bool SAL_CALL suspend( sal_Bool bSuspend ) override ; + + css::uno::Any SAL_CALL getViewData() override ; + + void SAL_CALL restoreViewData( const css::uno::Any& aValue ) override ; + + css::uno::Reference< css::frame::XFrame > SAL_CALL getFrame() override ; + + css::uno::Reference< css::frame::XModel > SAL_CALL getModel() override ; + + + // XDispatchProvider + + + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL & aURL , + const OUString & sTargetFrameName, + sal_Int32 eSearchFlags ) override ; + + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& seqDescriptor ) override ; + + + // XControllerBorder + + + virtual css::frame::BorderWidths SAL_CALL getBorder() override; + virtual void SAL_CALL addBorderResizeListener( const css::uno::Reference< css::frame::XBorderResizeListener >& xListener ) override; + virtual void SAL_CALL removeBorderResizeListener( const css::uno::Reference< css::frame::XBorderResizeListener >& xListener ) override; + virtual css::awt::Rectangle SAL_CALL queryBorderedArea( const css::awt::Rectangle& aPreliminaryRectangle ) override; + + + // XComponent + + + virtual void SAL_CALL dispose() override ; + + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override ; + + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override ; + virtual void SAL_CALL registerContextMenuInterceptor( const css::uno::Reference< css::ui::XContextMenuInterceptor >& xInterceptor ) override; + virtual void SAL_CALL releaseContextMenuInterceptor( const css::uno::Reference< css::ui::XContextMenuInterceptor >& xInterceptor ) override; + + virtual void SAL_CALL addKeyHandler( const css::uno::Reference< css::awt::XKeyHandler >& xHandler ) override; + virtual void SAL_CALL removeKeyHandler( const css::uno::Reference< css::awt::XKeyHandler >& xHandler ) override; + virtual void SAL_CALL addMouseClickHandler( const css::uno::Reference< css::awt::XMouseClickHandler >& xHandler ) override; + virtual void SAL_CALL removeMouseClickHandler( const css::uno::Reference< css::awt::XMouseClickHandler >& xHandler ) override; + + + // XDispatchInformationProvider + virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedCommandGroups() override; + virtual css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation( sal_Int16 nCommandGroup ) override; + + // css::frame::XTitle + virtual OUString SAL_CALL getTitle( ) override; + virtual void SAL_CALL setTitle( const OUString& sTitle ) override; + + // css::frame::XTitleChangeBroadcaster + virtual void SAL_CALL addTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener ) override; + virtual void SAL_CALL removeTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener ) override; + + // css::lang::XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XInfobarProvider + virtual void SAL_CALL + appendInfobar(const OUString& sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, sal_Int32 aInfobarType, + const css::uno::Sequence<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 (); + +protected: + void CopyLokViewCallbackFromFrameCreator(); + +private: + enum ConnectSfxFrame + { + E_CONNECT, + E_DISCONNECT, + E_RECONNECT + }; + SAL_DLLPRIVATE void ConnectSfxFrame_Impl( const ConnectSfxFrame i_eConnect ); + SAL_DLLPRIVATE SfxViewFrame& GetViewFrame_Impl() const; + SAL_DLLPRIVATE void ShowInfoBars( ); + + DECL_DLLPRIVATE_LINK( CheckOutHandler, weld::Button&, void ); + + std::unique_ptr<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 0000000000..de76611044 --- /dev/null +++ b/include/sfx2/sfxbasemodel.hxx @@ -0,0 +1,757 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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/XDocumentRecovery2.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/XModel3.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 ErrCodeMsg; +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::XDocumentRecovery2 + , css::document::XUndoManagerSupplier + , css::document::XShapeEventBroadcaster + , css::document::XDocumentEventBroadcaster + , css::lang::XEventListener + , css::document::XEventsSupplier + , css::document::XEmbeddedScripts + , css::document::XScriptInvocationContext + , css::frame::XModel3 + , css::util::XModifiable2 + , css::view::XPrintable + , css::view::XPrintJobBroadcaster + , css::frame::XStorable2 + , css::frame::XLoadable + , css::script::XStarBasicAccess + , css::document::XViewDataSupplier + , css::util::XCloseable // => css::util::XCloseBroadcaster + , css::datatransfer::XTransferable + , css::document::XDocumentSubStorageSupplier + , css::document::XStorageBasedDocument + , css::script::provider::XScriptProviderSupplier + , css::ui::XUIConfigurationManagerSupplier + , css::embed::XVisualObject + , css::lang::XUnoTunnel + , css::frame::XModule + , css::frame::XTitle + , css::frame::XTitleChangeBroadcaster + , css::frame::XUntitledNumbers + > SfxBaseModel_Base; + +class SFX2_DLLPUBLIC SfxBaseModel : protected ::cppu::BaseMutex + , public SfxBaseModel_Base + , public SfxListener +{ + + +// public methods + + +public: + + + // constructor/destructor + + + SfxBaseModel( SfxObjectShell *pObjectShell ) ; + + virtual ~SfxBaseModel() override ; + + + // XInterface + + + /**___________________________________________________________________________________________________ + @short give answer, if interface is supported + @descr The interfaces are searched by type. + + @seealso XInterface + + @param "rType" is the type of searched interface. + + @return Any information about found interface + + @onerror A RuntimeException is thrown. + */ + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& rType ) override ; + + /**___________________________________________________________________________________________________ + @short increment refcount + @seealso XInterface + @seealso release() + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL acquire() noexcept override + { OWeakObject::acquire(); } + + /**___________________________________________________________________________________________________ + @short decrement refcount + @seealso XInterface + @seealso acquire() + @onerror A RuntimeException is thrown. + */ + + virtual void SAL_CALL release() noexcept override + { OWeakObject::release(); } + + + // XTypeProvider + + + /**___________________________________________________________________________________________________ + @short get information about supported interfaces + @seealso XTypeProvider + @return Sequence of types of all supported interfaces + + @onerror A RuntimeException is thrown. + */ + + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override ; + + /**___________________________________________________________________________________________________ + @short get implementation id + @descr This ID is necessary for UNO-caching. If there no ID, cache is disabled. + Another way, cache is enabled. + + @seealso XTypeProvider + @return ID as Sequence of byte + + @onerror A RuntimeException is thrown. + */ + + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override ; + + + // XStarBasicAccess + + + /**___________________________________________________________________________________________________ + @seealso XStarBasicAccess + */ + virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getLibraryContainer() override; + + /**___________________________________________________________________________________________________ + @seealso XStarBasicAccess + */ + virtual void SAL_CALL createLibrary( const OUString& LibName, const OUString& Password, + const OUString& ExternalSourceURL, const OUString& LinkTargetURL ) override; + + /**___________________________________________________________________________________________________ + @seealso XStarBasicAccess + */ + virtual void SAL_CALL addModule( const OUString& LibraryName, const OUString& ModuleName, + const OUString& Language, const OUString& Source ) override; + + /**___________________________________________________________________________________________________ + @seealso XStarBasicAccess + */ + virtual void SAL_CALL addDialog( const OUString& LibraryName, const OUString& DialogName, + const css::uno::Sequence< sal_Int8 >& Data ) override; + + + // XChild + + + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override ; + + virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& xParent ) override; + + + // XComponent + + + virtual void SAL_CALL dispose() override; + + virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener >& aListener) override; + + virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + + // XDocumentPropertiesSupplier + virtual css::uno::Reference< css::document::XDocumentProperties > + SAL_CALL getDocumentProperties() override; + + + // XEventListener + + + virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override; + + + // XModel + + + virtual sal_Bool SAL_CALL attachResource(const OUString& sURL, + const css::uno::Sequence< css::beans::PropertyValue >& aArgs) override; + + virtual OUString SAL_CALL getURL() override; + + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getArgs() override; + + virtual void SAL_CALL connectController( const css::uno::Reference< css::frame::XController >& xController ) override; + + virtual void SAL_CALL disconnectController( const css::uno::Reference< css::frame::XController >& xController ) override; + + virtual void SAL_CALL lockControllers() override; + + virtual void SAL_CALL unlockControllers() override; + + virtual sal_Bool SAL_CALL hasControllersLocked() override; + + virtual css::uno::Reference< css::frame::XController > SAL_CALL getCurrentController() override; + + virtual void SAL_CALL setCurrentController( const css::uno::Reference< css::frame::XController >& xController ) override; + + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getCurrentSelection() override; + + + // XModel2 + + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL getControllers() override; + + virtual css::uno::Sequence< OUString > SAL_CALL getAvailableViewControllerNames() override; + + virtual css::uno::Reference< css::frame::XController2 > SAL_CALL createDefaultViewController(const css::uno::Reference< css::frame::XFrame >& Frame ) override; + + virtual css::uno::Reference< css::frame::XController2 > SAL_CALL createViewController(const OUString& ViewName , + const css::uno::Sequence< css::beans::PropertyValue >& Arguments , + const css::uno::Reference< css::frame::XFrame >& Frame ) override; + + virtual void SAL_CALL setArgs(const css::uno::Sequence<css::beans::PropertyValue>& aArgs) override; + + + // XModel3 + + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getArgs2( const css::uno::Sequence< OUString > & requestedArgs ) override; + + // XModifiable2 + + + virtual sal_Bool SAL_CALL disableSetModified( ) override; + virtual sal_Bool SAL_CALL enableSetModified( ) override; + virtual sal_Bool SAL_CALL isSetModifiedEnabled( ) override; + + virtual sal_Bool SAL_CALL isModified() override; + + virtual void SAL_CALL setModified( sal_Bool bModified ) override; + + virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& xListener ) override ; + + virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > & xListener) override ; + + + // XCloseable + + + virtual void SAL_CALL close( sal_Bool bDeliverOwnership ) override; + + + // XCloseBroadcaster + + + virtual void SAL_CALL addCloseListener( const css::uno::Reference< css::util::XCloseListener >& xListener ) override; + virtual void SAL_CALL removeCloseListener( const css::uno::Reference< css::util::XCloseListener >& xListener ) override; + + + // XPrintJobBroadcaster + + + virtual void SAL_CALL addPrintJobListener( const css::uno::Reference< css::view::XPrintJobListener >& xListener ) override; + virtual void SAL_CALL removePrintJobListener( const css::uno::Reference< css::view::XPrintJobListener >& xListener ) override; + + + // XPrintable + + + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPrinter() override; + + virtual void SAL_CALL setPrinter( const css::uno::Sequence< css::beans::PropertyValue >& seqPrinter ) override; + virtual void SAL_CALL print( const css::uno::Sequence< css::beans::PropertyValue >& seqOptions ) override; + + + // XStorable2 + + + virtual void SAL_CALL storeSelf( const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override; + + + // XStorable + + + virtual sal_Bool SAL_CALL hasLocation() override; + + virtual OUString SAL_CALL getLocation() override; + + virtual sal_Bool SAL_CALL isReadonly() override; + + virtual void SAL_CALL store() override; + + virtual void SAL_CALL storeAsURL( const OUString& sURL, + const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override ; + + virtual void SAL_CALL storeToURL( const OUString& sURL, + const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override; + + SAL_DLLPRIVATE void + impl_store(const OUString& sURL, + const css::uno::Sequence<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.XDocumentRecovery2 + virtual sal_Int64 SAL_CALL getModifiedStateDuration() override; + + // css.document.XUndoManagerSupplier + virtual css::uno::Reference< css::document::XUndoManager > SAL_CALL getUndoManager( ) override; + + + // css::rdf::XNode: + virtual OUString SAL_CALL getStringValue() override; + + // css::rdf::XURI: + virtual OUString SAL_CALL getNamespace() override; + virtual OUString SAL_CALL getLocalName() override; + + // css::rdf::XRepositorySupplier: + virtual css::uno::Reference< + css::rdf::XRepository > SAL_CALL getRDFRepository() override; + + // css::rdf::XDocumentMetadataAccess: + virtual css::uno::Reference< + css::rdf::XMetadatable > SAL_CALL + getElementByMetadataReference( + const css::beans::StringPair & i_rReference) override; + virtual css::uno::Reference< + css::rdf::XMetadatable > SAL_CALL + getElementByURI(const css::uno::Reference< + css::rdf::XURI > & i_xURI) override; + virtual css::uno::Sequence< css::uno::Reference< + css::rdf::XURI > > SAL_CALL getMetadataGraphsWithType( + const css::uno::Reference< + css::rdf::XURI > & i_xType) override; + virtual css::uno::Reference< + css::rdf::XURI> SAL_CALL + addMetadataFile(const OUString & i_rFileName, + const css::uno::Sequence< + css::uno::Reference< css::rdf::XURI > + > & i_rTypes) override; + virtual css::uno::Reference< + css::rdf::XURI> SAL_CALL + importMetadataFile(::sal_Int16 i_Format, + const css::uno::Reference< + css::io::XInputStream > & i_xInStream, + const OUString & i_rFileName, + const css::uno::Reference< + css::rdf::XURI > & i_xBaseURI, + const css::uno::Sequence< + css::uno::Reference< css::rdf::XURI > + > & i_rTypes) override; + virtual void SAL_CALL removeMetadataFile( + const css::uno::Reference< + css::rdf::XURI > & i_xGraphName) override; + virtual void SAL_CALL addContentOrStylesFile( + const OUString & i_rFileName) override; + virtual void SAL_CALL removeContentOrStylesFile( + const OUString & i_rFileName) override; + + virtual void SAL_CALL loadMetadataFromStorage( + const css::uno::Reference< + css::embed::XStorage > & i_xStorage, + const css::uno::Reference< + css::rdf::XURI > & i_xBaseURI, + const css::uno::Reference< + css::task::XInteractionHandler> & i_xHandler) override; + virtual void SAL_CALL storeMetadataToStorage( + const css::uno::Reference< + css::embed::XStorage > & i_xStorage) override; + virtual void SAL_CALL loadMetadataFromMedium( + const css::uno::Sequence< + css::beans::PropertyValue > & i_rMedium) override; + virtual void SAL_CALL storeMetadataToMedium( + const css::uno::Sequence< + css::beans::PropertyValue > & i_rMedium) override; + + // XCmisDocument + + virtual css::uno::Sequence< css::document::CmisProperty > + SAL_CALL getCmisProperties() override; + virtual void SAL_CALL setCmisProperties( + const css::uno::Sequence< + css::document::CmisProperty >& _cmisproperties ) override; + + virtual void SAL_CALL updateCmisProperties( + const css::uno::Sequence< + css::document::CmisProperty >& _cmisproperties ) override; + + virtual css::uno::Sequence< css::document::CmisVersion > SAL_CALL getAllVersions ( ) override; + + virtual void SAL_CALL checkOut( ) override; + virtual void SAL_CALL cancelCheckOut( ) override; + virtual void SAL_CALL checkIn( sal_Bool bIsMajor, const OUString & rMessage ) override; + + virtual sal_Bool SAL_CALL isVersionable( ) override; + virtual sal_Bool SAL_CALL canCheckOut( ) override; + virtual sal_Bool SAL_CALL canCancelCheckOut( ) override; + virtual sal_Bool SAL_CALL canCheckIn( ) override; + + /// @throws css::uno::RuntimeException + bool getBoolPropertyValue( const OUString& rName ); + + + // SfxListener + + + void Notify( SfxBroadcaster& aBC , + const SfxHint& aHint ) override ; + + + // public IMPL? + + + void changing() ; + + SfxObjectShell* GetObjectShell() const ; + + SAL_DLLPRIVATE bool impl_isDisposed() const ; + bool IsInitialized() const; + void MethodEntryCheck( const bool i_mustBeInitialized ) const; + + css::uno::Reference < css::container::XIndexAccess > SAL_CALL getViewData() override; + void SAL_CALL setViewData( const css::uno::Reference < css::container::XIndexAccess >& aData ) override; + + /** calls all XEventListeners */ + void notifyEvent( const css::document::EventObject& aEvent ) const; + + /** returns true if someone added a XEventListener to this XEventBroadcaster */ + bool hasEventListeners() const; + +protected: + + /* returns a unique id for the model that is valid as long as the document + is loaded. The id is not saved across document close/reload. */ + OUString const & getRuntimeUID() const; + + /* returns true if the document signatures are valid, otherwise false */ + bool hasValidSignatures() const; + + /* GrabBagItem for interim interop purposes */ + void getGrabBagItem(css::uno::Any& rVal) const; + + void setGrabBagItem(const css::uno::Any& rVal); + + +// private methods + + +private: + /// @throws css::uno::RuntimeException + css::uno::Reference< css::ui::XUIConfigurationManager2 > getUIConfigurationManager2(); + void impl_getPrintHelper(); + SAL_DLLPRIVATE void ListenForStorage_Impl( const css::uno::Reference< css::embed::XStorage >& xStorage ); + SAL_DLLPRIVATE OUString GetMediumFilterName_Impl() const; + + SAL_DLLPRIVATE void postEvent_Impl( const OUString& aName, const css::uno::Reference< css::frame::XController2 >& xController = css::uno::Reference< css::frame::XController2 >(), const css::uno::Any& aSupplement = css::uno::Any()); + + SAL_DLLPRIVATE css::uno::Reference< css::frame::XTitle > impl_getTitleHelper (); + SAL_DLLPRIVATE css::uno::Reference< css::frame::XUntitledNumbers > impl_getUntitledHelper (); + + SAL_DLLPRIVATE SfxViewFrame* FindOrCreateViewFrame_Impl( + const css::uno::Reference< css::frame::XFrame >& i_rFrame, + ::sfx::intern::ViewCreationGuard& i_rGuard + ) const; + + SAL_DLLPRIVATE void NotifyModifyListeners_Impl() const; + + SAL_DLLPRIVATE void loadCmisProperties(); + + SAL_DLLPRIVATE SfxMedium* handleLoadError( const ErrCodeMsg& 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 0000000000..2513bbbb00 --- /dev/null +++ b/include/sfx2/sfxdlg.hxx @@ -0,0 +1,157 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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; +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 OUString &rName ) = 0; + virtual WhichRangesContainer GetInputRanges( const SfxItemPool& ) = 0; + virtual void SetInputSet( const SfxItemSet* pInSet ) = 0; +}; + +class SfxAbstractApplyTabDialog : virtual public SfxAbstractTabDialog +{ +protected: + virtual ~SfxAbstractApplyTabDialog() override = default; +public: + virtual void SetApplyHdl( const Link<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, sal_uInt16 nPageId, 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 void ShowAsyncScriptErrorDialog( weld::Window* pParent, const css::uno::Any& rException ) = 0; + + virtual VclPtr<VclAbstractDialog> CreateOptionsDialog( + weld::Window* pParent, const OUString& rExtensionId ) = 0; + + virtual VclPtr<VclAbstractDialog> CreateAboutDialog(weld::Window* _pParent) = 0; + + virtual VclPtr<VclAbstractDialog> CreateTipOfTheDayDialog(weld::Window* _pParent) = 0; + + virtual VclPtr<VclAbstractDialog> CreateToolbarmodeDialog(weld::Window* _pParent) = 0; + + virtual VclPtr<VclAbstractDialog> CreateWidgetTestDialog(weld::Window* _pParent) = 0; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxhelp.hxx b/include/sfx2/sfxhelp.hxx new file mode 100644 index 0000000000..212188063c --- /dev/null +++ b/include/sfx2/sfxhelp.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SFXHELP_HXX +#define INCLUDED_SFX2_SFXHELP_HXX + +#include <sal/config.h> + +#include <string_view> + +#include <rtl/ustring.hxx> +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <vcl/help.hxx> + +class SFX2_DLLPUBLIC SfxHelp final : public Help +{ + bool bIsDebug; + bool bLaunchingHelp; // tdf#140539 don't allow help to be re-launched during help launch + +private: + SAL_DLLPRIVATE static bool Start_Impl(const OUString& rURL, weld::Widget* pWidget, const OUString& rKeyword); + SAL_DLLPRIVATE virtual void SearchKeyword( const OUString& rKeyWord ) override; + SAL_DLLPRIVATE virtual bool Start(const OUString& rURL, weld::Widget* pWidget = nullptr) override; + SAL_DLLPRIVATE static OUString GetHelpModuleName_Impl(std::u16string_view rHelpId); + SAL_DLLPRIVATE static OUString CreateHelpURL_Impl( const OUString& aCommandURL, const OUString& rModuleName ); + + SAL_DLLPRIVATE static bool Start_Impl( const OUString& rURL, const vcl::Window* pWindow ); + SAL_DLLPRIVATE virtual bool Start( const OUString& rURL, const vcl::Window* pWindow ) override; + +public: + SfxHelp(); + virtual ~SfxHelp() override; + + virtual OUString GetHelpText(const OUString&, const vcl::Window* pWindow) override; + virtual OUString GetHelpText(const OUString&, const weld::Widget* pWindow) override; + + static OUString CreateHelpURL( const OUString& aCommandURL, const OUString& rModuleName ); + static OUString GetDefaultHelpModule(); + static OUString GetCurrentModuleIdentifier(); + // Check for built-in help + static bool IsHelpInstalled(); + + static OUString GetURLHelpText(std::u16string_view); +}; + +#endif // INCLUDED_SFX2_SFXHELP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxhtml.hxx b/include/sfx2/sfxhtml.hxx new file mode 100644 index 0000000000..9f5a03f5b2 --- /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, std::u16string_view rBaseURL, + const HTMLOptions& rOptions, + SvMacroItemId nEventMouseOver, + SvMacroItemId nEventMouseOut ); + inline bool ParseAreaOptions(ImageMap * pImageMap, std::u16string_view rBaseURL, + SvMacroItemId nEventMouseOver, + SvMacroItemId nEventMouseOut); + + // <TD SDVAL="..." SDNUM="..."> + static double GetTableDataOptionsValNum( sal_uInt32& nNumForm, + LanguageType& eNumLang, const OUString& aValStr, + std::u16string_view aNumStr, SvNumberFormatter& rFormatter ); + +protected: + // Start a file download. This is done asynchronously or synchronously. + // In the synchronous case, the parser is in the working state after + // it has been called. The read file can then be picked up directly with + // FinishFileDownload. In the asynchronous case, the parser is in the + // pending state after it hs been called. The parser then has to leave + // over the Continue (without Reschedule!). If the file is loaded, + // a Continue is called with passed on token. The file can then be picked + // up by FinishFileDownload. To cancel the download should a shell be + // left. It can only exist a single download at the same time, For every + // started download FinishFileDownload must be called. + void StartFileDownload(const OUString& rURL); + + // End of an asynchronous file download. Returns TRUE if the download + // was successful. The read file is then passed into String. + bool FinishFileDownload( OUString& rStr ); + + // Returns TRUE if a file was downloaded and if FileDownloadFinished + // has not yet been called + bool ShouldFinishFileDownload() const { return pDLMedium != nullptr; } + + SfxMedium *GetMedium() { return pMedium; } + const SfxMedium *GetMedium() const { return pMedium; } + + // Default (without iterator) is JavaScript + ScriptType GetScriptType( SvKeyValueIterator* ) const; + const OUString& GetScriptTypeString( SvKeyValueIterator* ) const; +}; + +inline bool SfxHTMLParser::ParseAreaOptions(ImageMap * pImageMap, std::u16string_view rBaseURL, + SvMacroItemId nEventMouseOver, + SvMacroItemId nEventMouseOut) +{ + return ParseAreaOptions( pImageMap, rBaseURL, GetOptions(), + nEventMouseOver, nEventMouseOut ); +} + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxmodelfactory.hxx b/include/sfx2/sfxmodelfactory.hxx new file mode 100644 index 0000000000..4d166c4d4e --- /dev/null +++ b/include/sfx2/sfxmodelfactory.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SFX2_SFXMODELFACTORY_HXX +#define INCLUDED_SFX2_SFXMODELFACTORY_HXX + +#include <sfx2/dllapi.h> + +#include <com/sun/star/uno/Reference.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <functional> + +namespace com::sun::star::lang { class XMultiServiceFactory; } +namespace com::sun::star::lang { class XSingleServiceFactory; } +namespace com::sun::star::uno { class XInterface; } +namespace com::sun::star::uno { class XComponentContext; } +namespace com::sun::star::uno { template <class 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 +{ + /** + * Intended to be called from UNO constructor functions + * This evaluates certain creation arguments (passed to createInstanceWithArguments) + * and passes them to the factory function of the derived class. + */ + css::uno::Reference<css::uno::XInterface> + SFX2_DLLPUBLIC createSfxModelInstance( + const css::uno::Sequence<css::uno::Any> & rxArgs, + std::function<css::uno::Reference<css::uno::XInterface>( SfxModelFlags )> creationFunc + ); + +} // namespace sfx2 + + +#endif // INCLUDED_SFX2_SFXMODELFACTORY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxresid.hxx b/include/sfx2/sfxresid.hxx new file mode 100644 index 0000000000..f5cd1aca4c --- /dev/null +++ b/include/sfx2/sfxresid.hxx @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SFXRESID_HXX +#define INCLUDED_SFX2_SFXRESID_HXX + +#include <sfx2/dllapi.h> +#include <rtl/ustring.hxx> +#include <unotools/resmgr.hxx> + +SFX2_DLLPUBLIC OUString SfxResId(TranslateId aId); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc new file mode 100644 index 0000000000..3e1775788d --- /dev/null +++ b/include/sfx2/sfxsids.hrc @@ -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 . + */ +#ifndef INCLUDED_SFX2_SFXSIDS_HRC +#define INCLUDED_SFX2_SFXSIDS_HRC + +#include <svl/solar.hrc> +#include <svl/memberid.h> +#include <svl/typedwhich.hxx> + +class SfxBoolItem; +class SfxDocumentInfoItem; +class SfxEventNamesItem; +class SfxFlagItem; +class SfxGlobalNameItem; +class SfxHyphenRegionItem; +class SfxImageItem; +class SfxInt16Item; +class SfxInt32Item; +class SfxMacroInfoItem; +class SfxScriptOrganizerItem; +class SfxStringItem; +class SfxStringListItem; +class SfxUInt16Item; +class SfxUnoAnyItem; +class SfxUnoFrameItem; +class SfxWatermarkItem; +class SfxVisibilityItem; +class SvxClipboardFormatItem; +class SvxHyperlinkItem; +class SvxLanguageItem; +class SvxSearchItem; +class SvxZoomItem; + +// Please be careful: +// Changing just one part here doesn't add new +// docking windows automatically! + +#define SID_DOCKWIN_0 SID_DOCKWIN_START +#define SID_DOCKWIN_1 SID_DOCKWIN_START+1 +#define SID_DOCKWIN_2 SID_DOCKWIN_START+2 +#define SID_DOCKWIN_3 SID_DOCKWIN_START+3 +#define SID_DOCKWIN_4 SID_DOCKWIN_START+4 +#define SID_DOCKWIN_5 SID_DOCKWIN_START+5 +#define SID_DOCKWIN_6 SID_DOCKWIN_START+6 +#define SID_DOCKWIN_7 SID_DOCKWIN_START+7 +#define SID_DOCKWIN_8 SID_DOCKWIN_START+8 +#define SID_DOCKWIN_9 SID_DOCKWIN_START+9 + +// default-ids for application +#define SID_QUITAPP (SID_SFX_START + 300) +#define SID_ABOUT (SID_SFX_START + 301) +#define SID_SETUPPRINTER (SID_SFX_START + 302) +#define SID_SAFE_MODE (SID_SFX_START + 303) + +#define SID_DEVELOPMENT_TOOLS_DOCKING_WINDOW (SID_SFX_START + 306) +#define SID_INSPECT_SELECTED_OBJECT (SID_SFX_START + 307) + +#define SID_CONTEXT TypedWhichId<SfxStringItem>(SID_SFX_START + 310) + +#define SID_PASTE_SPECIAL (SID_SFX_START + 311) +#define SID_CLIPBOARD_FORMAT_ITEMS TypedWhichId<SvxClipboardFormatItem>(SID_SFX_START + 312) + +#define SID_PASTE_UNFORMATTED (SID_SFX_START + 314) +#define SID_PRINTER_NOTFOUND_WARN TypedWhichId<SfxBoolItem>(SID_SFX_START + 320) +#define SID_PRINTER_NAME TypedWhichId<SfxStringItem>(SID_SFX_START + 322) +#define SID_PRINTER_CHANGESTODOC TypedWhichId<SfxFlagItem>(SID_SFX_START + 324) +#define SID_PRINTPREVIEW (SID_SFX_START + 325) + +#define SID_MAIL_SUBJECT (SID_SFX_START + 328) +#define SID_MAIL_SENDDOC (SID_SFX_START + 331) +#define SID_MAIL_SENDDOCASPDF (SID_SFX_START + 1672) + +#define SID_MAIL_RECIPIENT (SID_SFX_START + 334) +#define SID_MAIL_TEXT (SID_SFX_START + 335) +#define SID_MAIL_PRIORITY (SID_SFX_START + 337) + +#define SID_MAIL_PREPAREEXPORT (SID_SFX_START + 385) + +#define SID_MAIL_EXPORT_FINISHED (SID_SFX_START + 388) +#define SID_WEBHTML (SID_SFX_START + 393) +#define SID_MAIL_SCROLLBODY_PAGEDOWN (SID_SFX_START + 1588) + +#define SID_PROGRESS_STATUSBAR_CONTROL TypedWhichId<SfxUnoAnyItem>(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 TypedWhichId<SfxBoolItem>(SID_SFX_START + 403) +#define SID_HELPTIPS TypedWhichId<SfxBoolItem>(SID_SFX_START + 404) +// free (SID_SFX_START + 405) +#define SID_CHARMAP_CONTROL (SID_SFX_START + 406) +#define SID_TIPOFTHEDAY (SID_SFX_START + 407) + +// free (SID_SFX_START + 410) +#define SID_SEND_FEEDBACK (SID_SFX_START + 421) +#define SID_Q_AND_A (SID_SFX_START + 422) +#define SID_DOCUMENTATION (SID_SFX_START + 423) +#define SID_DONATION (SID_SFX_START + 424) +#define SID_GETINVOLVED (SID_SFX_START + 425) +#define SID_WHATSNEW (SID_SFX_START + 426) +#define SID_HYPHENATIONMISSING (SID_SFX_START + 427) + +#define SID_SHOW_LICENSE (SID_SFX_START + 1683) +#define SID_SHOW_CREDITS (SID_SFX_START + 1711) + +// default-ids for document +#define SID_NEWDOC (SID_SFX_START + 500) +#define SID_OPENDOC (SID_SFX_START + 501) +#define SID_OPENREMOTE (SID_SFX_START + 517) +#define SID_OPENURL (SID_SFX_START + 596) +#define SID_JUMPTOMARK TypedWhichId<SfxStringItem>(SID_SFX_START + 598) +#define SID_OPENTEMPLATE (SID_SFX_START + 594) +#define SID_SAVEASDOC TypedWhichId<SfxStringItem>(SID_SFX_START + 502) +#define SID_SAVEASREMOTE (SID_SFX_START + 516) +#define SID_SAVESIMPLE (SID_SFX_START + 518) +#define SID_SIGNPDF TypedWhichId<SfxBoolItem>(SID_SFX_START + 519) +// this is either SfxBoolItem or SfxStringItem +#define SID_SAVEACOPY (SID_SFX_START + 999) +#define SID_SAVEACOPYITEM TypedWhichId<SfxBoolItem>(SID_SFX_START + 998) +#define SID_CONVERT_IMAGES TypedWhichId<SfxStringItem>(SID_SFX_START + 997) +#define SID_CLOSING TypedWhichId<SfxBoolItem>(SID_SFX_START +1539) +#define SID_CLOSEDOC TypedWhichId<SfxStringItem>(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 TypedWhichId<SfxInt16Item>(SID_SFX_START + 3) +#define SID_PRINT_PAGES TypedWhichId<SfxStringItem>(SID_SFX_START +1589) +#define SID_PRINT_COLLATE (SID_SFX_START +1590) +#define SID_PRINT_SORT (SID_SFX_START +1591) +#define SID_SAVEDOC TypedWhichId<SfxStringItem>(SID_SFX_START + 505) +#define SID_FILE_NAME TypedWhichId<SfxStringItem>(SID_SFX_START + 507) +#define SID_DOCINFO_TITLE TypedWhichId<SfxStringItem>(SID_SFX_START + 557) +#define SID_FILE_FILTEROPTIONS TypedWhichId<SfxStringItem>(SID_SFX_START + 527) +#define SID_RELOAD (SID_SFX_START + 508) +#define SID_PRINTDOCDIRECT TypedWhichId<SfxStringItem>(SID_SFX_START + 509) +#define SID_DOC_REPAIR TypedWhichId<SfxBoolItem>(SID_SFX_START + 510) +#define SID_DOC_SERVICE TypedWhichId<SfxStringItem>(SID_SFX_START + 511) +#define SID_PLUGIN_MODE TypedWhichId<SfxUInt16Item>(SID_SFX_START + 827) +#define SID_EXPORTDOC (SID_SFX_START + 829) +#define SID_EXPORTDOCASPDF (SID_SFX_START + 1673) +#define SID_DIRECTEXPORTDOCASPDF (SID_SFX_START + 1674) +#define SID_EXPORTDOCASEPUB (SID_SFX_START + 1677) +#define SID_DIRECTEXPORTDOCASEPUB (SID_SFX_START + 1678) +#define SID_REDACTDOC (SID_SFX_START + 1732) +#define SID_AUTOREDACTDOC (SID_SFX_START + 1736) +#define SID_UPDATEDOCMODE TypedWhichId<SfxUInt16Item>(SID_SFX_START + 1668) +#define SID_CHECKOUT TypedWhichId<SfxVisibilityItem>(SID_SFX_START + 512) +#define SID_CANCELCHECKOUT TypedWhichId<SfxVisibilityItem>(SID_SFX_START + 513) +#define SID_CHECKIN TypedWhichId<SfxVisibilityItem>(SID_SFX_START + 514) +#define SID_FILTER_PROVIDER TypedWhichId<SfxStringItem>(SID_SFX_START + 515) + +#define SID_FORCERELOAD TypedWhichId<SfxBoolItem>(SID_SFX_START + 1502) +#define SID_FILE_DIALOG TypedWhichId<SfxBoolItem>(SID_SFX_START + 304) +#define SID_REMOTE_DIALOG TypedWhichId<SfxBoolItem>(SID_SFX_START + 305) +#define SID_PATH TypedWhichId<SfxStringItem>(SID_SFX_START + 308) +#define SID_SAVEDOCS (SID_SFX_START + 309) +#define SID_STANDARD_DIR TypedWhichId<SfxStringItem>(SID_SFX_START + 450) +#define SID_DENY_LIST TypedWhichId<SfxStringListItem>(SID_SFX_START + 451) + +// browse-ids +#define SID_BROWSE_FORWARD (SID_SFX_START + 1300) +#define SID_BROWSE_BACKWARD (SID_SFX_START + 1301) +#define SID_CREATELINK (SID_SFX_START + 1309) +#define SID_EDITDOC TypedWhichId<SfxBoolItem>(SID_SFX_START + 1312) +#define SID_BROWSER_MODE (SID_SFX_START + 1313) +#define SID_READONLYDOC TypedWhichId<SfxBoolItem>(SID_SFX_START + 1314) +#define SID_BROWSER TypedWhichId<SfxBoolItem>(SID_SFX_START + 1318) +#define SID_MACROEXECMODE TypedWhichId<SfxUInt16Item>(SID_SFX_START + 1319) + +#define SID_FILTER_DATA TypedWhichId<SfxUnoAnyItem>(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 TypedWhichId<SfxStringItem>(SID_SFX_START + 1410) +// SID_EXPLORER_PROPS_END (SID_SFX_START + 1499) + +#define SID_AUTOLOAD TypedWhichId<SfxBoolItem>(SID_SFX_START + 1509) +#define SID_FILLFRAME TypedWhichId<SfxUnoFrameItem>(SID_SFX_START + 1516) +#define SID_BASEURL TypedWhichId<SfxStringItem>(SID_SFX_START + 1518) +#define SID_TEMPLATE TypedWhichId<SfxBoolItem>(SID_SFX_START + 1519) + +#define SID_CONTENTTYPE TypedWhichId<SfxStringItem>(SID_SFX_START + 1541) + +#define SID_SAVETO TypedWhichId<SfxBoolItem>(SID_SFX_START + 1546) + +#define SID_VERSION TypedWhichId<SfxInt16Item>(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 TypedWhichId<SfxStringItem>(SID_SFX_START + 1613) + +#define SID_CHARSET TypedWhichId<SfxStringItem>(SID_SFX_START + 1633) +#define SID_OVERWRITE (SID_SFX_START + 1634) + // FREE (was: SID_CRASH) +#define SID_FAIL_ON_WARNING TypedWhichId<SfxBoolItem>(SID_SFX_START + 1646) +#define SID_INPUTSTREAM TypedWhichId<SfxUnoAnyItem>(SID_SFX_START + 1648) +#define SID_LOGOUT (SID_SFX_START + 1652) +#define SID_JUMPMARK TypedWhichId<SfxStringItem>(SID_SFX_START + 1654) +#define SID_BROWSE (SID_SFX_START + 1658) + // FREE (was: SID_BACKTOWEBTOP) +#define SID_VIEW_DATA_SOURCE_BROWSER TypedWhichId<SfxBoolItem>(SID_SFX_START + 1660) +#define SID_UNPACK TypedWhichId<SfxBoolItem>(SID_SFX_START + 1662) +// (SID_SFX_START + 1663) used further down +#define SID_ATTR_TARGETLANG_STR (SID_SFX_START + 1664) + // FREE +#define SID_OUTPUTSTREAM TypedWhichId<SfxUnoAnyItem>(SID_SFX_START + 1666) +#define SID_IMAGE_ORIENTATION TypedWhichId<SfxImageItem>(SID_SFX_START + 1667) + +#define SID_STOP_RECORDING (SID_SFX_START + 1671) +#define SID_INTERACTIONHANDLER TypedWhichId<SfxUnoAnyItem>(SID_SFX_START + 1675) +#define SID_OPENHYPERLINK (SID_SFX_START + 1676) +#define SID_CONTENT TypedWhichId<SfxUnoAnyItem>(SID_SFX_START + 1679) +#define SID_VIEWONLY TypedWhichId<SfxBoolItem>(SID_SFX_START + 1682) +#define SID_REPAIRPACKAGE TypedWhichId<SfxBoolItem>(SID_SFX_START + 1683) +#define SID_MINIMIZED TypedWhichId<SfxBoolItem>(SID_SFX_START + 1687) +#define SID_COMPONENTDATA TypedWhichId<SfxUnoAnyItem>(SID_SFX_START + 1688) +#define SID_COMPONENTCONTEXT TypedWhichId<SfxUnoAnyItem>(SID_SFX_START + 1689) +#define SID_SCRIPTORGANIZER TypedWhichId<SfxScriptOrganizerItem>(SID_SFX_START + 1690) +#define SID_MACROORGANIZER TypedWhichId<SfxUInt16Item>(SID_SFX_START + 1691) +#define SID_RUNMACRO (SID_SFX_START + 1692) +#define SID_AVMEDIA_TOOLBOX TypedWhichId<::avmedia::MediaItem>(SID_SFX_START + 1693) +#define SID_AVMEDIA_PLAYER (SID_SFX_START + 1694) +#define SID_INSERT_AVMEDIA TypedWhichId<SfxStringItem>(SID_SFX_START + 1696) +#define SID_RECENTFILELIST (SID_SFX_START + 1697) +#define SID_AVAILABLE_TOOLBARS (SID_SFX_START + 1698) +#define SID_STREAM TypedWhichId<SfxUnoAnyItem>(SID_SFX_START + 1699) +#define SID_DOC_BASEURL TypedWhichId<SfxStringItem>(SID_SFX_START + 1700) +#define SID_DOC_HIERARCHICALNAME TypedWhichId<SfxStringItem>(SID_SFX_START + 1701) +#define SID_TERMINATE_INPLACEACTIVATION (SID_SFX_START + 1702) +#define SID_APPLY_STYLE (SID_SFX_START + 1703) +#define SID_MACRO_SIGNATURE TypedWhichId<SfxUInt16Item>(SID_SFX_START + 1704) +#define SID_ATTR_WARNALIENFORMAT TypedWhichId<SfxBoolItem>(SID_SFX_START + 1705) +#define SID_COPY_STREAM_IF_POSSIBLE TypedWhichId<SfxBoolItem>(SID_SFX_START + 1706) +#define SID_MAIL_SENDDOCASFORMAT (SID_SFX_START + 1707) +#define SID_MAIL_SENDDOCASMS (SID_SFX_START + 1708) +#define SID_MAIL_SENDDOCASOOO (SID_SFX_START + 1709) +#define SID_NO_ACCEPT_DIALOG TypedWhichId<SfxBoolItem>(SID_SFX_START + 1710) +#define SID_NOAUTOSAVE TypedWhichId<SfxBoolItem>(SID_SFX_START + 1711) +#define SID_PRINT_SELECTEDSHEET TypedWhichId<SfxBoolItem>(SID_SFX_START + 1712) +#define SID_OPTIONS_PAGEURL TypedWhichId<SfxStringItem>(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 TypedWhichId<SfxStringItem>(SID_SFX_START + 1716) +#define SID_DEFAULTFILENAME (SID_SFX_START + 1717) +#define SID_MODIFYPASSWORDINFO TypedWhichId<SfxUnoAnyItem>(SID_SFX_START + 1718) +#define SID_RECOMMENDREADONLY TypedWhichId<SfxBoolItem>(SID_SFX_START + 1719) +#define SID_SUGGESTEDSAVEASDIR TypedWhichId<SfxStringItem>(SID_SFX_START + 1720) +#define SID_SUGGESTEDSAVEASNAME TypedWhichId<SfxStringItem>(SID_SFX_START + 1721) +#define SID_ENCRYPTIONDATA TypedWhichId<SfxUnoAnyItem>(SID_SFX_START + 1722) +#define SID_PASSWORDINTERACTION TypedWhichId<SfxBoolItem>(SID_SFX_START + 1723) +#define SID_GOTOLINE (SID_SFX_START + 1724) +#define SID_SHOWLINES TypedWhichId<SfxBoolItem>(SID_SFX_START + 1725) +#define SID_BLUETOOTH_SENDDOC (SID_SFX_START + 1726) +#define SID_TEMPLATE_MANAGER TypedWhichId<SfxVisibilityItem>(SID_SFX_START + 1727) +#define SID_TOOLBAR_MODE (SID_SFX_START + 1728) +#define SID_NO_FILE_SYNC (SID_SFX_START + 1729) +#define SID_NO_THUMBNAIL (SID_SFX_START + 1730) +#define SID_LOCK_CONTENT_EXTRACTION TypedWhichId<SfxBoolItem>(SID_SFX_START + 1731) +#define SID_LOCK_EXPORT TypedWhichId<SfxBoolItem>(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 TypedWhichId<SfxUnoAnyItem>(SID_SFX_START + 1735) +#define SID_LOCK_PRINT TypedWhichId<SfxBoolItem>(SID_SFX_START + 1736) +#define SID_LOCK_SAVE TypedWhichId<SfxBoolItem>(SID_SFX_START + 1737) +#define SID_LOCK_EDITDOC TypedWhichId<SfxBoolItem>(SID_SFX_START + 1738) +#define SID_REPLACEABLE TypedWhichId<SfxBoolItem>(SID_SFX_START + 1739) +#define SID_ADDITIONS_DIALOG (SID_SFX_START + 1740) +#define FN_PARAM_ADDITIONS_TAG TypedWhichId<SfxStringItem>(SID_SFX_START + 1741) +#define SID_TOOLBAR_MODE_UI (SID_SFX_START + 1742) +#define SID_TOOLBAR_LOCK TypedWhichId<SfxBoolItem>(SID_SFX_START + 1743) +#define SID_WIDGET_TEST_DIALOG (SID_SFX_START + 1744) +#define FN_CHANGE_THEME (SID_SFX_START + 1745) +#define FN_PARAM_NEW_THEME TypedWhichId<SfxStringItem>(SID_SFX_START + 1746) +#define SID_OPTIONS_PAGEID TypedWhichId<SfxUInt16Item>(SID_SFX_START + 1747) + +// SID_SFX_free_END (SID_SFX_START + 3999) + +#define SID_OPEN_NEW_VIEW TypedWhichId<SfxBoolItem>(SID_SFX_START + 520) + // FREE, was SID_VIEW_ZOOM_MODE + // FREE, was SID_VIEW_POS_SIZE +#define SID_VIEW_ID TypedWhichId<SfxUInt16Item>(SID_SFX_START + 523) + // FREE, was SID_USER_DATA +#define SID_VIEW_DATA TypedWhichId<SfxUnoAnyItem>(SID_SFX_START + 1582) +#define SID_SILENT TypedWhichId<SfxBoolItem>(SID_SFX_START + 528) +#define SID_HIDDEN TypedWhichId<SfxBoolItem>(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 TypedWhichId<SfxBoolItem>(SID_SFX_START + 526) + +#define SID_FILTER_NAME TypedWhichId<SfxStringItem>(SID_SFX_START + 530) +#define SID_DOC_SALVAGE TypedWhichId<SfxStringItem>(SID_SFX_START + 531) +#define SID_INSERTDOC TypedWhichId<SfxStringItem>(SID_SFX_START + 532) +#define SID_TYPE_NAME TypedWhichId<SfxStringItem>(SID_SFX_START + 533) + +#define SID_DOC_READONLY TypedWhichId<SfxBoolItem>(SID_SFX_START + 590) +#define SID_DOC_MODIFIED TypedWhichId<SfxBoolItem>(SID_SFX_START + 584) +#define SID_DOC_LOADING TypedWhichId<SfxBoolItem>(SID_SFX_START + 585) +#define SID_IMG_LOADING TypedWhichId<SfxBoolItem>(SID_SFX_START + 586) +#define SID_DOC_SAVED TypedWhichId<SfxBoolItem>(SID_SFX_START + 599) +#define SID_DOCINFO TypedWhichId<SfxDocumentInfoItem>(SID_SFX_START + 535) +#define SID_DOCINFO_KEYWORDS TypedWhichId<SfxStringItem>(SID_SFX_START + 591) +#define SID_DOCINFO_COMMENTS TypedWhichId<SfxStringItem>(SID_SFX_START + 592) +#define SID_DOCINFO_AUTHOR TypedWhichId<SfxStringItem>(SID_SFX_START + 593) +#define SID_DOCINFO_MAJOR (SID_SFX_START + 594) +#define SID_NEWDOCDIRECT TypedWhichId<SfxStringItem>(SID_SFX_START + 537) +#define SID_DOCFRAME (SID_SFX_START + 598) +#define SID_TARGETNAME TypedWhichId<SfxStringItem>(SID_SFX_START + 560) +#define SID_POSTDATA TypedWhichId<SfxUnoAnyItem>(SID_SFX_START + 1536) +#define SID_DONELINK (SID_SFX_START + 646) +#define SID_REFERER TypedWhichId<SfxStringItem>(SID_SFX_START + 654) +#define SID_PAGE_NUMBER TypedWhichId<SfxInt32Item>(SID_SFX_START + 655) +#define SID_MODIFIER TypedWhichId<SfxUInt16Item>(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 TypedWhichId<SfxBoolItem>(SID_SFX_START + 696) + +#define SID_DOCTEMPLATE (SID_SFX_START + 538) +#define SID_AUTOPILOTMENU (SID_SFX_START + 1381) + +// Floating Window Template +#define SID_STYLE_DESIGNER TypedWhichId<SfxBoolItem>(SID_SFX_START + 539) + +#define SID_SIDEBAR_DECK TypedWhichId<SfxStringItem>(SID_SFX_START + 850) +#define SID_SIDEBAR_DECK_TOGGLE TypedWhichId<SfxBoolItem>(SID_SFX_START + 851) + +#define SID_TEMPLATE_ADDRESSBOOKSOURCE (SID_SFX_START + 1655) + +// Ruby dialog +#define SID_RUBY_DIALOG (SID_SFX_START + 1656) + +#define SID_STYLE_FAMILY_START (SID_SFX_START + 541) +#define SID_STYLE_FAMILY1 (SID_STYLE_FAMILY_START) +#define SID_STYLE_FAMILY2 (SID_STYLE_FAMILY_START + 1) +#define SID_STYLE_FAMILY3 (SID_STYLE_FAMILY_START + 2) +#define SID_STYLE_FAMILY4 (SID_STYLE_FAMILY_START + 3) +#define SID_STYLE_FAMILY5 (SID_STYLE_FAMILY_START + 4) +#define SID_STYLE_FAMILY6 (SID_STYLE_FAMILY_START + 5) + +#define SID_STYLE_NEW TypedWhichId<SfxStringItem>(SID_SFX_START + 549) +#define SID_STYLE_EDIT TypedWhichId<SfxStringItem>(SID_SFX_START + 550) +#define SID_STYLE_DELETE TypedWhichId<SfxStringItem>(SID_SFX_START + 551) +#define SID_STYLE_APPLY TypedWhichId<SfxStringItem>(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_FONT TypedWhichId<SfxStringItem>(SID_SFX_START + 558) +#define SID_STYLE_WATERCAN TypedWhichId<SfxBoolItem>(SID_SFX_START + 554) +#define SID_STYLE_NEW_BY_EXAMPLE TypedWhichId<SfxStringItem>(SID_SFX_START + 555) +#define SID_STYLE_UPDATE_BY_EXAMPLE TypedWhichId<SfxStringItem>(SID_SFX_START + 556) +#define SID_STYLE_DRAGHIERARCHIE (SID_SFX_START + 565) +#define SID_STYLE_MASK TypedWhichId<SfxUInt16Item>(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 TypedWhichId<SfxStringItem>(SID_SFX_START + 1603) +#define SID_STYLE_SHOW TypedWhichId<SfxStringItem>(SID_SFX_START + 1604) +#define SID_STYLE_UPD_BY_EX_NAME TypedWhichId<SfxStringItem>(SID_SFX_START + 1585) +#define SID_STYLE_REFERENCE TypedWhichId<SfxStringItem>(SID_SFX_START + 1602) + +#define SID_SPOTLIGHT_PARASTYLES TypedWhichId<SfxBoolItem>(SID_SFX_START + 1605) +#define SID_SPOTLIGHT_CHARSTYLES TypedWhichId<SfxBoolItem>(SID_SFX_START + 1606) + +#define SID_TEMPLATE_NAME TypedWhichId<SfxStringItem>(SID_SFX_START + 660) +#define SID_TEMPLATE_REGIONNAME TypedWhichId<SfxStringItem>(SID_SFX_START + 662) +#define SID_TEMPLATE_LOAD TypedWhichId<SfxInt32Item>(SID_SFX_START + 663) + +#define SID_INSERT_OBJECT TypedWhichId<SfxGlobalNameItem>(SID_SFX_START + 561) +#define SID_INSERT_FLOATINGFRAME (SID_SFX_START + 563) +#define SID_CLASSIFICATION_APPLY (SID_SFX_START + 672) +#define SID_WATERMARK TypedWhichId<SfxWatermarkItem>(SID_SFX_START + 676) +#define SID_WATERMARK_FONT TypedWhichId<SfxStringItem>(SID_SFX_START + 677) +#define SID_WATERMARK_TRANSPARENCY TypedWhichId<SfxInt16Item>(SID_SFX_START + 805) +#define SID_WATERMARK_COLOR TypedWhichId<SfxUInt32Item>(SID_SFX_START + 806) +#define SID_WATERMARK_ANGLE TypedWhichId<SfxInt16Item>(SID_SFX_START + 807) + +#define SID_HYPERLINK_DIALOG TypedWhichId<SfxBoolItem>(SID_SFX_START + 678) + +#define SID_DEFAULTFILEPATH (SID_SFX_START + 571) +#define SID_OBJECT TypedWhichId<SfxInt16Item>(SID_SFX_START + 575) + +// Doc-Properties +#define SID_DOCFULLNAME TypedWhichId<SfxStringItem>(SID_SFX_START + 581) +#define SID_DOCPATH (SID_SFX_START + 582) +#define SID_DOCTITLE TypedWhichId<SfxStringItem>(SID_SFX_START + 583) + +#define SID_DOCUMENT TypedWhichId<SfxUnoAnyItem>(SID_SFX_START + 588) + +// default-ids for windows + +#define SID_COMMAND_POPUP (SID_SFX_START + 610) +#define SID_NEWWINDOW (SID_SFX_START + 620) +#define SID_CLOSEWIN (SID_SFX_START + 621) +#define SID_VIEWSHELL TypedWhichId<SfxUInt16Item>(SID_SFX_START + 623) +#define SID_WIN_FULLSCREEN TypedWhichId<SfxBoolItem>(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 TypedWhichId<SfxStringItem>(SID_SFX_START + 698) +#define FN_PARAM_THES_WORD_REPLACE TypedWhichId<SfxStringItem>(SID_SFX_START + 699) + +// default-ids for editing, cursor travelling and selection +// this is sometimes SfxStringItem and sometimes SfxUInt16Item +#define SID_REDO (SID_SFX_START + 700) +// this is sometimes SfxStringItem and sometimes SfxUInt16Item +#define SID_UNDO (SID_SFX_START + 701) +#define SID_REPEAT TypedWhichId<SfxStringItem>(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 TypedWhichId<SfxStringItem>(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 TypedWhichId<SfxBoolItem>(SID_SFX_START + 1669) + +// Paste Special +#define SID_PASTE_ONLY_TEXT (SID_SFX_START + 802) +#define SID_PASTE_ONLY_FORMULA (SID_SFX_START + 803) +#define SID_PASTE_ONLY_VALUE (SID_SFX_START + 804) +#define SID_PASTE_TEXTIMPORT_DIALOG (SID_SFX_START + 805) +#define SID_PASTE_TRANSPOSED (SID_SFX_START + 808) +#define SID_PASTE_AS_LINK (SID_SFX_START + 809) + +// Used for redaction +#define SID_SHAPE_NAME (SID_SFX_START + 810) +#define SID_GRAPHIC_SIZE_CHECK (SID_SFX_START + 811) +#define SID_ASYNCHRON (SID_SFX_START + 813) +#define SID_ACCESSIBILITY_CHECK_ONLINE (SID_SFX_START + 814) +#define SID_THEME_DIALOG (SID_SFX_START + 815) + +// default-ids for configuration +#define SID_CONFIG TypedWhichId<SfxStringItem>(SID_SFX_START + 904) +#define SID_TOOLBOXOPTIONS (SID_SFX_START + 907) +#define SID_TOGGLEFUNCTIONBAR (SID_SFX_START + 910) +#define SID_MACROINFO TypedWhichId<SfxMacroInfoItem>(SID_SFX_START + 919) +#define SID_TOGGLESTATUSBAR TypedWhichId<SfxBoolItem>(SID_SFX_START + 920) +#define SID_CONFIGSTATUSBAR (SID_SFX_START + 921) +#define SID_CONFIGMENU (SID_SFX_START + 924) +#define SID_CONFIGACCEL (SID_SFX_START + 925) +#define SID_CONFIGEVENT (SID_SFX_START + 926) +#define SID_CFGFILE (SID_SFX_START + 927) +#define SID_SHOWPOPUPS (SID_SFX_START + 929) + +// Item-Id for the assigned event Tabpage. +// FIXME this has two different associated pool item types, SvxMacroItem and SfxBoolItem +#define SID_ATTR_MACROITEM TypedWhichId<SvxMacroItem>(SID_SFX_START + 934) + +#define SID_OPTIONS TypedWhichId<SfxStringItem>(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_SEARCH (SID_SFX_START + 1685) +#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 TypedWhichId<SfxEventNamesItem>(SID_SFX_START + 1101) +#define SID_VERB_START (SID_SFX_START + 1100) +#define SID_VERB_END (SID_SFX_START + 1121) + +#define SID_SIGNATURE TypedWhichId<SfxUInt16Item>(SID_SFX_START + 1643) + +// SaveTabPage +#define SID_ATTR_DOCINFO TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 0) +#define SID_ATTR_BACKUP TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 1) +#define SID_ATTR_BACKUP_BESIDE_ORIGINAL TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 2) +#define SID_ATTR_AUTOSAVE TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 3) +#define SID_ATTR_USERAUTOSAVE TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 4) +#define SID_ATTR_AUTOSAVEMINUTE TypedWhichId<SfxUInt16Item>(SID_OPTIONS_START + 5) +#define SID_ATTR_UNDO_COUNT TypedWhichId<SfxUInt16Item>(SID_OPTIONS_START + 16) + +// GeneralTabPage + +#define SID_ATTR_METRIC TypedWhichId<SfxUInt16Item>(SID_OPTIONS_START + 8) +#define SID_ATTR_DEFTABSTOP TypedWhichId<SfxUInt16Item>(SID_OPTIONS_START + 14) +#define SID_ATTR_QUICKLAUNCHER TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 74) +#define SID_ATTR_YEAR2000 TypedWhichId<SfxUInt16Item>(SID_OPTIONS_START + 87) +#define SID_ATTR_APPLYCHARUNIT TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 88) + +// LinguTabPage +#define SID_ATTR_LANGUAGE TypedWhichId<SvxLanguageItem>(SID_OPTIONS_START + 7) +#define SID_ATTR_HYPHENREGION TypedWhichId<SfxHyphenRegionItem>(SID_OPTIONS_START + 12) +#define SID_AUTOSPELL_CHECK TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 21) + +// InetTabPage + +#define SID_INET_PROXY_TYPE TypedWhichId<SfxUInt16Item>(SID_OPTIONS_START + 23) + +#define SID_SAVEREL_INET TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 30) +#define SID_SAVEREL_FSYS TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 31) + +#define SID_PASSWORD TypedWhichId<SfxStringItem>(SID_OPTIONS_START + 36) + +#define SID_INET_NOPROXY TypedWhichId<SfxStringItem>(SID_OPTIONS_START + 37) + +#define SID_INET_HTTP_PROXY_NAME TypedWhichId<SfxStringItem>(SID_OPTIONS_START + 38) +#define SID_INET_HTTP_PROXY_PORT TypedWhichId<SfxInt32Item>(SID_OPTIONS_START + 39) + +// Automatic update of Styles - manage TabPage +#define SID_ATTR_AUTO_STYLE_UPDATE TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 65) + +#define SID_SECURE_URL TypedWhichId<SfxStringListItem>(SID_OPTIONS_START + 66) + +// configured locale changed +#define SID_OPT_LOCALE_CHANGED TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 94) +//middle mouse button +#define SID_ATTR_PRETTYPRINTING TypedWhichId<SfxBoolItem>(SID_OPTIONS_START + 98) + +// 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 TypedWhichId<SfxUInt16Item>(SID_SVX_START + 281) +#define SID_SEARCH_ITEM TypedWhichId<SvxSearchItem>(SID_SVX_START + 291) +#define SID_SIDEBAR TypedWhichId<SfxBoolItem>(SID_SVX_START + 336) +#define SID_NOTEBOOKBAR TypedWhichId<SfxStringItem>(SID_SVX_START + 338) +#define SID_MENUBAR TypedWhichId<SfxBoolItem>(SID_SVX_START + 339) +#define SID_HYPERLINK_GETLINK TypedWhichId<SvxHyperlinkItem>(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_COMP_BIBLIOGRAPHY (SID_SVX_START + 880) +#define SID_ADDRESS_DATA_SOURCE (SID_SVX_START + 934) +#define SID_OPEN_SMARTTAGOPTIONS TypedWhichId<SfxBoolItem>(SID_SVX_START + 1062) +#define SID_RULER_MARGIN1 TypedWhichId<SfxStringItem>(SID_SVX_START + 1063) +#define SID_RULER_MARGIN2 TypedWhichId<SfxStringItem>(SID_SVX_START + 1064) +#define SID_TABLE_BORDER_TYPE TypedWhichId<SfxStringItem>(SID_SVX_START + 1065) +#define SID_TABLE_BORDER_INDEX TypedWhichId<SfxUInt16Item>(SID_SVX_START + 1066) +#define SID_TABLE_BORDER_OFFSET TypedWhichId<SfxInt32Item>(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 TypedWhichId<SfxBoolItem>(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 TypedWhichId<SfxBoolItem>( 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 TypedWhichId<SfxStringItem>( 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 TypedWhichId<SfxStringItem>( SID_BASICIDE_START + 38 ) +#define SID_BASICIDE_STAT_DATE TypedWhichId<SfxStringItem>( SID_BASICIDE_START + 39 ) +#define SID_BASICIDE_STAT_TITLE TypedWhichId<SfxStringItem>( 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 TypedWhichId<SfxStringItem>( SID_BASICIDE_START + 53 ) +#define SID_BASICIDE_CURRENT_ZOOM TypedWhichId<SfxStringItem>( SID_BASICIDE_START + 54 ) +#define SID_BASICIDE_WATCH TypedWhichId<SfxBoolItem>( SID_BASICIDE_START + 55 ) +#define SID_BASICIDE_STACK TypedWhichId<SfxBoolItem>( SID_BASICIDE_START + 56 ) +#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_NOUPDATE TypedWhichId<SfxBoolItem>(FN_PARAM+66) +#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 TypedWhichId<SfxBoolItem>(FN_EDIT2 + 23) +#define FN_REDLINE_ON TypedWhichId<SfxBoolItem>(FN_EDIT2 + 25) + +#define SID_HTML_MODE TypedWhichId<SfxUInt16Item>(SID_SVX_START + 414) + +// Calc-Id's used for SfxSecurityPage +#ifndef SC_FUNCTION_START +#define SC_FUNCTION_START (SID_SC_START + 200) +#endif +#ifndef FILE_MENU_END +#define FILE_MENU_END (SC_FUNCTION_START + 20) +#endif +#ifndef EDIT_MENU_START +#define EDIT_MENU_START (FILE_MENU_END) +#endif +#ifndef SC_VIEW_START +#define SC_VIEW_START (SID_SC_START) +#endif +#define FID_CHG_RECORD TypedWhichId<SfxBoolItem>(EDIT_MENU_START + 18) +#define SID_CHG_PROTECT TypedWhichId<SfxBoolItem>(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 0000000000..384d5ac19e --- /dev/null +++ b/include/sfx2/sfxstatuslistener.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SFX2_SFXSTATUSLISTENER_HXX +#define INCLUDED_SFX2_SFXSTATUSLISTENER_HXX + +#include <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 SFX2_DLLPUBLIC SfxStatusListener : public cppu::WeakImplHelper< + css::frame::XStatusListener, + css::lang::XComponent> +{ + public: + + SfxStatusListener( const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider, sal_uInt16 nSlotId, const OUString& aCommand ); + virtual ~SfxStatusListener() override; + + // old methods from SfxControllerItem + sal_uInt16 GetId() const { return m_nSlotID; } + void UnBind(); + void ReBind(); + + virtual void StateChangedAtStatusListener( SfxItemState eState, const SfxPoolItem* pState ); + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + + // XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + + // XStatusListener + virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& Event) override; + + private: + SfxStatusListener( const SfxStatusListener& ) = delete; + SfxStatusListener& operator=( const SfxStatusListener& ) = delete; + + sal_uInt16 m_nSlotID; + css::util::URL m_aCommand; + css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchProvider; + css::uno::Reference< css::frame::XDispatch > m_xDispatch; +}; + +#endif // INCLUDED_SFX2_SFXSTATUSLISTENER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxuno.hxx b/include/sfx2/sfxuno.hxx new file mode 100644 index 0000000000..6c6253f37f --- /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 0000000000..b454547970 --- /dev/null +++ b/include/sfx2/shell.hxx @@ -0,0 +1,588 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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> +#include <optional> + +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; +class SfxPoolItemHolder; + +/** + 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, + FormShowProperties = 0x0020, + FormShowExplorer = 0x0040, + FormShowFilterBar = 0x0080, + FormShowFilterNavigator = 0x0100, + FormShowTextControlBar = 0x0200, + FormTBControls = 0x0400, + FormTBDesign = 0x1000, + FormShowDataNavigator = 0x2000, + // masks to make sure modules don't use flags from another + SwMask = 0x0001, + BasicMask = 0x0004, + FormMask = 0x3ff8 +}; +namespace o3tl +{ + template<> struct typed_flags<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; + + 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&)> + */ + SfxPoolItemHolder 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 SfxPoolItemHolder& 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::optional<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* s_pInterface; \ + static SfxInterface* GetStaticInterface(); \ + static SfxInterfaceId GetInterfaceId() {return nId;} \ + static void RegisterInterface(const SfxModule* pMod=nullptr); \ + virtual SfxInterface* GetInterface() const override; + +#define SFX_TMPL_INTERFACE(Class,SuperClass,Abstract) \ + \ + SfxInterface* Class::s_pInterface = nullptr; \ + SfxInterface* Class::GetStaticInterface() \ + { \ + if ( !s_pInterface ) \ + { \ + s_pInterface = \ + new SfxInterface( \ + #Class, Abstract, GetInterfaceId(), \ + SuperClass::GetStaticInterface(), \ + a##Class##Slots_Impl[0], \ + sal_uInt16(sizeof(a##Class##Slots_Impl) / sizeof(SfxSlot) ) ); \ + InitInterface_Impl(); \ + } \ + return s_pInterface; \ + } \ + \ + SfxInterface* Class::GetInterface() const \ + { \ + return GetStaticInterface(); \ + } \ + \ + void Class::RegisterInterface(const SfxModule* pMod) \ + { \ + GetStaticInterface()->Register(pMod); \ + } + +#define SFX_IMPL_INTERFACE(Class,SuperClass) \ +SFX_TMPL_INTERFACE(Class,SuperClass,false) \ + +#define SFX_IMPL_SUPERCLASS_INTERFACE(Class,SuperClass) \ +SFX_TMPL_INTERFACE(Class,SuperClass,true) \ + +enum class SfxVisibilityFlags { + Invisible = 0x0000, // Never visible + Viewer = 0x0040, + ReadonlyDoc = 0x0400, + Standard = 0x1000, + FullScreen = 0x2000, + Client = 0x4000, + Server = 0x8000, +}; +namespace o3tl { + template<> struct typed_flags<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 0000000000..c7e522401d --- /dev/null +++ b/include/sfx2/sidebar/AsynchronousCall.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <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(Action aAction); + ~AsynchronousCall(); + + void RequestCall(); + void CancelRequest(); + void Sync(); + +private: + Action maAction; + ImplSVEvent* mnCallId; + + DECL_LINK(HandleUserCall, void*, void); +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Context.hxx b/include/sfx2/sidebar/Context.hxx new file mode 100644 index 0000000000..c1ea1f5e4a --- /dev/null +++ b/include/sfx2/sidebar/Context.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <rtl/ustring.hxx> + +#include <sfx2/dllapi.h> + +namespace sfx2::sidebar +{ +class SFX2_DLLPUBLIC Context +{ +public: + OUString msApplication; + OUString msContext; + + Context(); + Context(OUString sApplication, OUString sContext); + + /** When two contexts are matched against each other, then + application or context name may have the wildcard value 'any'. + In order to prefer matches without wildcards over matches with + wildcards we introduce an integer evaluation for matches. + */ + const static sal_Int32 NoMatch; + const static sal_Int32 OptimalMatch; + const static sal_Int32 ApplicationWildcardMatch; + const static sal_Int32 ContextWildcardMatch; + + /** Return the numeric value that describes how good the match + between two contexts is. + Smaller values represent better matches. + */ + sal_Int32 EvaluateMatch(const Context& rOther) const; + + bool operator==(const Context& rOther) const; + bool operator!=(const Context& rOther) const; +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/ControllerItem.hxx b/include/sfx2/sidebar/ControllerItem.hxx new file mode 100644 index 0000000000..a8f82195a4 --- /dev/null +++ b/include/sfx2/sidebar/ControllerItem.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <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 StateChangedAtToolBoxControl (sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem* pState) override; + virtual void GetControlState (sal_uInt16 nSId, boost::property_tree::ptree& rState) override; + + ItemUpdateReceiverInterface& mrItemUpdateReceiver; +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Deck.hxx b/include/sfx2/sidebar/Deck.hxx new file mode 100644 index 0000000000..215d3d2156 --- /dev/null +++ b/include/sfx2/sidebar/Deck.hxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * 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 <sfx2/sidebar/Panel.hxx> +#include <vcl/InterimItemWindow.hxx> +#include <vcl/weld.hxx> + +namespace sfx2::sidebar +{ +class DeckDescriptor; +class DeckTitleBar; +class SidebarDockingWindow; + +/** This is the parent window of the panels. + It displays the deck title. + + A deck consists of multiple panels. + E.g. Properties, Styles, Navigator. +*/ +class Deck final : public InterimItemWindow +{ +public: + Deck(const DeckDescriptor& rDeckDescriptor, SidebarDockingWindow* pParentWindow, + const std::function<void()>& rCloserAction); + virtual ~Deck() override; + virtual void dispose() override; + + const OUString& GetId() const { return msId; } + + DeckTitleBar* GetTitleBar() const; + tools::Rectangle GetContentArea() const; + void ResetPanels(SharedPanelContainer&& rPanels); + const SharedPanelContainer& GetPanels() const { return maPanels; } + + std::shared_ptr<Panel> GetPanel(std::u16string_view panelId); + + void RequestLayout(); + weld::Widget* GetPanelParentWindow(); + + /** Try to make the panel completely visible. + When the whole panel does not fit then make its top visible + and it off at the bottom. + */ + void ShowPanel(const Panel& rPanel); + + virtual void DataChanged(const DataChangedEvent& rEvent) override; + + virtual void DumpAsPropertyTree(tools::JsonWriter&) override; + + sal_Int32 GetMinimalWidth() const { return mnMinimalWidth; } + + static void LOKSendSidebarFullUpdate(); + +private: + void RequestLayoutInternal(); + +private: + const OUString msId; + sal_Int32 mnMinimalWidth; + sal_Int32 mnScrolledWindowExtraWidth; + sal_Int32 mnMinimalHeight; + SharedPanelContainer maPanels; + + VclPtr<SidebarDockingWindow> mxParentWindow; + std::unique_ptr<DeckTitleBar> mxTitleBar; + std::unique_ptr<weld::ScrolledWindow> mxVerticalScrollBar; + std::unique_ptr<weld::Box> mxContents; +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/FocusManager.hxx b/include/sfx2/sidebar/FocusManager.hxx new file mode 100644 index 0000000000..6eaa877b4d --- /dev/null +++ b/include/sfx2/sidebar/FocusManager.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 . + */ +#pragma once + +#include <sfx2/sidebar/Panel.hxx> +#include <tools/link.hxx> +#include <vcl/keycod.hxx> + +namespace weld { +class Widget; +} + +namespace sfx2::sidebar { + +class DeckTitleBar; + +/** Concentrate all focus handling in this class. + + There is one ring of windows that accept the input focus which are + cycled through with the arrow keys: + - the closer in the deck title (present only when docked) + - the panel title bars + - the tab bar items + + When the focus is in a panel title then focus travels over + - the panel title + - the panel closer + - the panel content + + Once the focus is in the panel content then focus cycles through + all controls inside the panel but not back to the title bar of + the panel. Escape places the focus back in the panel title. +*/ +class FocusManager +{ +public: + FocusManager(std::function<void(const Panel&)> aShowPanelFunctor); + ~FocusManager(); + + /** Forget all panels and buttons. Remove all window listeners. + */ + void Clear(); + + /** Transfer the focus into the sidebar tree of windows. This is + typically called from the SidebarChildWindow as result of + pressing the F6 key. + */ + void GrabFocus(); + void GrabFocusPanel(); + + void SetDeck(Deck* pDeck); + void SetPanels(const SharedPanelContainer& rPanels); + void SetButtons(const std::vector<weld::Widget*>& rButtons); + +private: + VclPtr<Deck> mxDeck; + DeckTitleBar* mpDeckTitleBar; + SharedPanelContainer maPanels; + std::vector<weld::Widget*> maButtons; + const std::function<void(const Panel&)> maShowPanelFunctor; + + enum PanelComponent + { + PC_DeckToolBox, + PC_PanelTitle, + PC_PanelToolBox, + PC_PanelContent, + PC_TabBar, + PC_None + }; + class FocusLocation + { + public: + PanelComponent meComponent; + sal_Int32 mnIndex; + FocusLocation(const PanelComponent eComponent, const sal_Int32 nIndex); + }; + + /** Listen for key events for panels and buttons. + */ + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + + void ClearPanels(); + void ClearButtons(); + + /** Let the focus manager listen for window events for the given + window. + */ + void RegisterWindow(weld::Widget& rWidget); + static void UnregisterWindow(weld::Widget& rWidget); + + void FocusDeckTitle(); + bool IsDeckTitleVisible() const; + + /** Set the focus to the title bar of the panel or, if the + title bar is not visible, directly to the panel. + @param nPanelIndex + Index of the panel to focus. + @param bFallbackToDeckTitle + When the panel title bar is not visible then The fallback + bias defines whether to focus the deck (true) or the panel + content (false) will be focused instead. + */ + void FocusPanel(const sal_Int32 nPanelIndex, + const bool bFallbackToDeckTitle); + + void FocusPanelContent(const sal_Int32 nPanelIndex); + void FocusButton(const sal_Int32 nButtonIndex); + void MoveFocusInsidePanel(const FocusLocation& rLocation, + const sal_Int32 nDirection); + + bool HandleKeyEvent(const vcl::KeyCode& rKeyCode, + const FocusLocation& rLocation); + + FocusLocation GetFocusLocation() const; + +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/IContextChangeReceiver.hxx b/include/sfx2/sidebar/IContextChangeReceiver.hxx new file mode 100644 index 0000000000..2667201444 --- /dev/null +++ b/include/sfx2/sidebar/IContextChangeReceiver.hxx @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <sfx2/dllapi.h> + +namespace vcl +{ +class EnumContext; +} + +namespace sfx2::sidebar +{ +class SFX2_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") IContextChangeReceiver +{ +public: + virtual ~IContextChangeReceiver(); + + virtual void HandleContextChange(const vcl::EnumContext& rContext) = 0; +}; + +} // end of namespace ::sd::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/ILayoutableWindow.hxx b/include/sfx2/sidebar/ILayoutableWindow.hxx new file mode 100644 index 0000000000..d5124a8983 --- /dev/null +++ b/include/sfx2/sidebar/ILayoutableWindow.hxx @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <com/sun/star/ui/LayoutSize.hpp> + +namespace sfx2::sidebar +{ +class SFX2_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") ILayoutableWindow +{ +public: + virtual ~ILayoutableWindow(); + + /** Return the preferred height with the constraint, that the + window will be set to the given width. + */ + virtual css::ui::LayoutSize GetHeightForWidth(const sal_Int32 nWidth) = 0; +}; + +} // end of namespace ::sd::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Panel.hxx b/include/sfx2/sidebar/Panel.hxx new file mode 100644 index 0000000000..c04c6a53a1 --- /dev/null +++ b/include/sfx2/sidebar/Panel.hxx @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <sfx2/dllapi.h> +#include <vcl/weld.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 Context; +class Deck; +class PanelDescriptor; +class PanelTitleBar; + +/** + * Multiple panels form a single deck. + * E.g. the Properties deck has panels like Styles, Character, paragraph. + */ +class SFX2_DLLPUBLIC Panel final +{ +public: + Panel(const PanelDescriptor& rPanelDescriptor, weld::Widget* pParentWindow, + const bool bIsInitiallyExpanded, Deck* pDeck, std::function<Context()> aContextAccess, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + + ~Panel(); + + PanelTitleBar* GetTitleBar() const; + weld::Box* GetContents() const; + void Show(bool bShow); + 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; + } + const css::uno::Reference<css::awt::XWindow>& GetElementParentWindow(); + css::uno::Reference<css::awt::XWindow> GetElementWindow(); + void SetExpanded(const bool bIsExpanded); + bool IsExpanded() const { return mbIsExpanded; } + bool HasIdPredicate(std::u16string_view rsId) const; + const OUString& GetId() const { return msPanelId; } + const OUString& GetTitle() const { return msTitle; } + void TriggerDeckLayouting(); + + void SetHeightPixel(int nHeight); + + bool get_extents(tools::Rectangle& rExtents) const; + + /// Set whether a panel should be present but invisible / inactive + void SetLurkMode(bool bLurk); + bool IsLurking() const { return mbLurking; } + + void set_margin_top(int nMargin); + void set_margin_bottom(int nMargin); + void set_vexpand(bool bExpand); + + weld::Window* GetFrameWeld(); + + void DataChanged(); + +private: + std::unique_ptr<weld::Builder> mxBuilder; + const OUString msPanelId; + const OUString msTitle; + const bool mbIsTitleBarOptional; + const bool mbWantsAWT; + css::uno::Reference<css::ui::XUIElement> mxElement; + css::uno::Reference<css::ui::XSidebarPanel> mxPanelComponent; + bool mbIsExpanded; + bool mbLurking; + const std::function<Context()> maContextAccess; + const css::uno::Reference<css::frame::XFrame>& mxFrame; + weld::Widget* mpParentWindow; + VclPtr<Deck> mxDeck; + std::unique_ptr<weld::Box> mxContainer; + std::unique_ptr<PanelTitleBar> mxTitleBar; + std::unique_ptr<weld::Box> mxContents; + css::uno::Reference<css::awt::XWindow> mxXWindow; + + DECL_DLLPRIVATE_LINK(DumpAsPropertyTreeHdl, tools::JsonWriter&, void); +}; + +typedef std::vector<std::shared_ptr<Panel>> SharedPanelContainer; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/PanelLayout.hxx b/include/sfx2/sidebar/PanelLayout.hxx new file mode 100644 index 0000000000..3058c9d514 --- /dev/null +++ b/include/sfx2/sidebar/PanelLayout.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <sfx2/dllapi.h> +#include <vcl/weld.hxx> + +class DataChangedEvent; +class VclSimpleEvent; +namespace sfx2 { namespace sidebar { class Panel; } } +namespace tools { class JsonWriter; } + +/// This class is the base for the Widget Layout-based sidebar panels. +class SFX2_DLLPUBLIC PanelLayout +{ +protected: + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xContainer; + sfx2::sidebar::Panel* m_pPanel; + + virtual void DataChanged(const DataChangedEvent& rEvent); + virtual void DumpAsPropertyTree(tools::JsonWriter&); + + virtual weld::Window* GetFrameWeld() const; + +private: + DECL_DLLPRIVATE_LINK(DataChangedEventListener, VclSimpleEvent&, void); + DECL_DLLPRIVATE_LINK(DumpAsPropertyTreeHdl, tools::JsonWriter&, void); + +public: + PanelLayout(weld::Widget* pParent, const OUString& rID, const OUString& rUIXMLDescription); + + void SetPanel(sfx2::sidebar::Panel* pPanel); + + virtual ~PanelLayout(); + + Size get_preferred_size() const + { + return m_xContainer->get_preferred_size(); + } + + void queue_resize(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/ResourceManager.hxx b/include/sfx2/sidebar/ResourceManager.hxx new file mode 100644 index 0000000000..9ac1130cc2 --- /dev/null +++ b/include/sfx2/sidebar/ResourceManager.hxx @@ -0,0 +1,132 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <unotools/confignode.hxx> +#include <map> +#include <vector> +#include <set> + +#include <sfx2/dllapi.h> + +namespace com::sun::star::frame { class XController; } +namespace com::sun::star::frame { class XModel; } +namespace sfx2::sidebar { class DeckDescriptor; } +namespace sfx2::sidebar { class PanelDescriptor; } + +namespace sfx2::sidebar { + +class Context; +class ContextList; + +/** Read the content of the Sidebar.xcu file and provide access + methods so that the sidebar can easily decide which content panels + to display for a certain context. +*/ +class SFX2_DLLPUBLIC ResourceManager +{ +public: + + ResourceManager(); + ~ResourceManager(); + + std::shared_ptr<DeckDescriptor> GetDeckDescriptor(std::u16string_view rsDeckId) const; + std::shared_ptr<PanelDescriptor> GetPanelDescriptor(std::u16string_view 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, + std::u16string_view 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(std::u16string_view 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; + + 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(std::u16string_view rsDeckId, + const Context& rContext, + const css::uno::Reference<css::frame::XController>& rxController); + + std::shared_ptr<DeckDescriptor> ImplGetDeckDescriptor(std::u16string_view rsDeckId) const; + std::shared_ptr<PanelDescriptor> ImplGetPanelDescriptor(std::u16string_view rsPanelId) const; +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Sidebar.hxx b/include/sfx2/sidebar/Sidebar.hxx new file mode 100644 index 0000000000..f4d0c1cc9b --- /dev/null +++ b/include/sfx2/sidebar/Sidebar.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/. + * + * 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 <sfx2/dllapi.h> +#include <sfx2/viewfrm.hxx> + +#include <string_view> + +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: + static void ShowDeck(std::u16string_view rsDeckId, SfxViewFrame* pViewFrame, + bool bToggle); + + /** Switch to the deck that contains the specified panel and make + sure that the panel is visible (expanded and scrolled into the + visible area.) + Note that most of the work is done asynchronously and that + this function probably returns before the requested panel is visible. + */ + static void ShowPanel ( + std::u16string_view rsPanelId, + const css::uno::Reference<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 ( + std::u16string_view rsPanelId, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + + static bool IsPanelVisible( + std::u16string_view rsPanelId, + const css::uno::Reference<css::frame::XFrame>& rxFrame); +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarChildWindow.hxx b/include/sfx2/sidebar/SidebarChildWindow.hxx new file mode 100644 index 0000000000..279aa79b5f --- /dev/null +++ b/include/sfx2/sidebar/SidebarChildWindow.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <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 + +/* 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 0000000000..06e092bcee --- /dev/null +++ b/include/sfx2/sidebar/SidebarController.hxx @@ -0,0 +1,303 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <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/XPropertySet.hpp> +#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 <comphelper/compbase.hxx> + +namespace com::sun::star::awt { class XWindow; } +namespace com::sun::star::frame { class XDispatch; } +namespace com::sun::star::ui { class XUIElement; } + +typedef comphelper::WeakComponentImplHelper < + css::ui::XContextChangeEventListener, + css::beans::XPropertyChangeListener, + css::ui::XSidebar, + css::frame::XStatusListener, + css::frame::XFrameActionListener + > SidebarControllerInterfaceBase; + +class SfxSplitWindow; +class SfxViewShell; + +namespace sfx2::sidebar { + +class DeckDescriptor; +class SidebarDockingWindow; + +class SFX2_DLLPUBLIC SidebarController final + : public SidebarControllerInterfaceBase +{ +public: + static rtl::Reference<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); + + void registerSidebarForFrame(const css::uno::Reference<css::frame::XController>& xFrame); + + void unregisterSidebarForFrame(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(std::u16string_view rsDeckId); + void OpenThenToggleDeck(const OUString& rsDeckId); + + /** Show only the tab bar, not the deck. + */ + void RequestCloseDeck(); + + /** Open the deck area and restore the parent window to its old width. + */ + void RequestOpenDeck(); + + /** Returns true when the given deck is the currently visible deck + */ + bool IsDeckVisible(std::u16string_view rsDeckId); + + bool IsDeckOpen(const sal_Int32 nIndex = -1); + + FocusManager& GetFocusManager() { return maFocusManager;} + + ResourceManager* GetResourceManager() { return mpResourceManager.get();} + + // std::unique_ptr<ResourceManager> GetResourceManager() { return mpResourceManager;} + + const Context& GetCurrentContext() const { return maCurrentContext;} + bool IsDocumentReadOnly (void) const { return mbIsDocumentReadOnly;} + + void SwitchToDeck(std::u16string_view rsDeckId); + void SwitchToDefaultDeck(); + bool WasFloatingDeckClosed() const { return mbFloatingDeckClosed; } + void SetFloatingDeckClosed(bool bWasClosed) { mbFloatingDeckClosed = bWasClosed; } + + void CreateDeck(std::u16string_view rDeckId); + void CreateDeck(std::u16string_view rDeckId, const Context& rContext, bool bForceCreate = false); + + ResourceManager::DeckContextDescriptorContainer GetMatchingDecks(); + ResourceManager::PanelContextDescriptorContainer GetMatchingPanels(std::u16string_view rDeckId); + + void notifyDeckTitle(std::u16string_view targetDeckId); + + void updateModel(const css::uno::Reference<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(); + + // Used to avoid wrong context update when an embedded object activation is in progress + bool hasChartOrMathContextCurrently() const; + + static SidebarController* GetSidebarControllerForView(const SfxViewShell* pViewShell); + +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; + bool mbMinimumSidebarWidth; + OUString msCurrentDeckId; + AsynchronousCall maPropertyChangeForwarder; + AsynchronousCall maContextChangeUpdate; + css::uno::Reference<css::beans::XPropertySet> mxThemePropertySet; + + /** Two flags control whether the deck is displayed or if only the + tab bar remains visible. + The mbIsDeckOpen flag stores the current state while + mbIsDeckRequestedOpen stores how this state should be. User + actions like clicking on the deck closer affect the + mbIsDeckRequestedOpen. Normally both flags have the same + value. A document being read-only can prevent the deck from opening. + */ + ::std::optional<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_DLLPRIVATE_LINK(WindowEventHandler, VclWindowEvent&, void); + /** Make maRequestedContext the current context. + */ + void UpdateConfigurations(); + + css::uno::Reference<css::ui::XUIElement> CreateUIElement ( + const css::uno::Reference<css::awt::XWindow>& rxWindow, + const OUString& rsImplementationURL, + const bool bWantsCanvas, + const Context& rContext); + + void CreatePanels( + std::u16string_view rDeckId, + const Context& rContext); + std::shared_ptr<Panel> CreatePanel ( + std::u16string_view rsPanelId, + weld::Widget* pParentWindow, + const bool bIsInitiallyExpanded, + const Context& rContext, + const VclPtr<Deck>& pDeck); + + void SwitchToDeck ( + const DeckDescriptor& rDeckDescriptor, + const Context& rContext); + + void ShowPopupMenu ( + weld::Menu& rMainMenu, + weld::Menu& rSubMenu, + const ::std::vector<TabBar::DeckMenuData>& rMenuData) const; + void PopulatePopupMenus( + weld::Menu& rMainButton, + weld::Menu& rSubMenu, + const ::std::vector<TabBar::DeckMenuData>& rMenuData) const; + DECL_DLLPRIVATE_LINK(OnMenuItemSelected, const OUString&, void); + DECL_DLLPRIVATE_LINK(OnSubMenuItemSelected, const OUString&, void); + void BroadcastPropertyChange(); + + /** The close of the deck changes the width of the child window. + That is only possible if there is no other docking window docked above or below the sidebar. + Return whether the width of the child window can be modified. + */ + bool CanModifyChildWindowWidth(); + + /** Set the child window container to a new width. + Return the old width. + */ + sal_Int32 SetChildWindowWidth (const sal_Int32 nNewWidth); + + /** Update the icons displayed in the title bars of the deck and + the panels. This is called once when a deck is created and + every time when a data change event is processed. + */ + void UpdateTitleBarIcons(); + + void UpdateDeckOpenState(); + void RestrictWidth (sal_Int32 nWidth); + SfxSplitWindow* GetSplitWindow(); + void ProcessNewWidth (const sal_Int32 nNewWidth); + void UpdateCloseIndicator (const bool bIsIndicatorVisible); + + /** Typically called when a panel is focused via keyboard. + Tries to scroll the deck up or down to make the given panel + completely visible. + */ + void ShowPanel (const Panel& rPanel); + + virtual void disposing(std::unique_lock<std::mutex>&) override; + + std::unique_ptr<ResourceManager> mpResourceManager; + +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarDockingWindow.hxx b/include/sfx2/sidebar/SidebarDockingWindow.hxx new file mode 100644 index 0000000000..f433086297 --- /dev/null +++ b/include/sfx2/sidebar/SidebarDockingWindow.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <sfx2/dockwin.hxx> + +#include <rtl/ref.hxx> + +class SfxViewShell; + +namespace svt { class AcceleratorExecute; } + +namespace sfx2::sidebar { + +class SidebarChildWindow; + +class SidebarController; + +class SFX2_DLLPUBLIC SidebarDockingWindow final : public SfxDockingWindow +{ +public: + SidebarDockingWindow(SfxBindings* pBindings, SidebarChildWindow& rChildWindow, + vcl::Window* pParent, WinBits nBits); + virtual ~SidebarDockingWindow() override; + virtual void dispose() override; + virtual bool EventNotify(NotifyEvent& rEvent) override; + virtual bool Close() override; + + /// Force generation of all panels by completion. + void SyncUpdate(); + + rtl::Reference<sfx2::sidebar::SidebarController>& GetOrCreateSidebarController(); + using SfxDockingWindow::Close; + +private: + // Window overridables + virtual void GetFocus() override; + + virtual SfxChildAlignment CheckAlignment ( + SfxChildAlignment eCurrentAlignment, + SfxChildAlignment eRequestedAlignment) override; + + ::rtl::Reference<sfx2::sidebar::SidebarController> mpSidebarController; + bool mbIsReadyToDrag; + std::unique_ptr<svt::AcceleratorExecute> mpAccel; +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarModelUpdate.hxx b/include/sfx2/sidebar/SidebarModelUpdate.hxx new file mode 100644 index 0000000000..33b273f143 --- /dev/null +++ b/include/sfx2/sidebar/SidebarModelUpdate.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <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 SAL_LOPLUGIN_ANNOTATE("crosscast") SidebarModelUpdate +{ +public: + virtual ~SidebarModelUpdate(); + virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) = 0; +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarPanelBase.hxx b/include/sfx2/sidebar/SidebarPanelBase.hxx new file mode 100644 index 0000000000..c1c99cd24a --- /dev/null +++ b/include/sfx2/sidebar/SidebarPanelBase.hxx @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <sal/config.h> + +#include <memory> + +#include <sfx2/dllapi.h> + +#include <comphelper/compbase.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> + +class PanelLayout; + +namespace sfx2::sidebar { + +class Panel; + +typedef comphelper::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 : public SidebarPanelBaseInterfaceBase +{ +public: + static css::uno::Reference<css::ui::XUIElement> Create(const OUString& rsResourceURL, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + std::unique_ptr<PanelLayout> xControl, + const css::ui::LayoutSize& rLayoutSize); + + // XContextChangeEventListener + virtual void SAL_CALL notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) override; + + // XEventListener + virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent) override; + + // XUIElement + virtual css::uno::Reference<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; + + void SetParentPanel(sfx2::sidebar::Panel* pPanel); + +private: + SidebarPanelBase(OUString sResourceURL, css::uno::Reference<css::frame::XFrame> xFrame, + std::unique_ptr<PanelLayout> xControl, const css::ui::LayoutSize& rLayoutSize); + virtual ~SidebarPanelBase() override; + SidebarPanelBase(const SidebarPanelBase&) = delete; + SidebarPanelBase& operator=( const SidebarPanelBase& ) = delete; + + virtual void disposing(std::unique_lock<std::mutex>&) override; + + css::uno::Reference<css::frame::XFrame> mxFrame; + std::unique_ptr<PanelLayout> mxControl; + const OUString msResourceURL; + const css::ui::LayoutSize maLayoutSize; +}; + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/TabBar.hxx b/include/sfx2/sidebar/TabBar.hxx new file mode 100644 index 0000000000..6ef0fc9c3d --- /dev/null +++ b/include/sfx2/sidebar/TabBar.hxx @@ -0,0 +1,138 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <sfx2/sidebar/ResourceManager.hxx> + +#include <vcl/InterimItemWindow.hxx> + +#include <functional> + +namespace com::sun::star::frame { class XFrame; } + +namespace svt { class AcceleratorExecute; } + +namespace weld { class Toolbar; } + +namespace sfx2::sidebar { + +class FocusManager; +class SidebarController; + +/** The tab bar is the container for the individual tabs. +*/ +class TabBar final : public InterimItemWindow +{ + friend class TabBarUIObject; +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 ( + weld::Menu& rMainMenu, weld::Menu& rSubMenu, + const ::std::vector<DeckMenuData>& rMenuData)> PopupMenuProvider; + TabBar ( + vcl::Window* pParentWindow, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + ::std::function<void (const OUString& rsDeckId)> aDeckActivationFunctor, + PopupMenuProvider aPopupMenuProvider, + SidebarController* rParentSidebarController); + + weld::Container* GetContainer() { return m_xContainer.get(); } + + virtual ~TabBar() override; + virtual void dispose() override; + + virtual void DataChanged (const DataChangedEvent& rDataChangedEvent) override; + virtual bool EventNotify (NotifyEvent& rEvent) override; + + static sal_Int32 GetDefaultWidth(); + + void SetDecks ( + const ResourceManager::DeckContextDescriptorContainer& rDecks); + void HighlightDeck (std::u16string_view rsDeckId); + void RemoveDeckHighlight (); + OUString const & GetDeckIdForIndex (const sal_Int32 nIndex) const; + void ToggleHideFlag (const sal_Int32 nIndex); + void RestoreHideFlags(); + + void UpdateFocusManager (FocusManager& rFocusManager); + + /// Enables/Disables the menu button. Used by LoKit. + void EnableMenuButton(const bool bEnable); + + virtual FactoryFunction GetUITestFactory() const override; +private: + css::uno::Reference<css::frame::XFrame> mxFrame; + + // This unusual auxiliary builder is because without a toplevel GtkWindow + // gtk will warn on loading a .ui with an accelerator defined, so use a + // temporary toplevel to suppress that and move the contents after load + std::unique_ptr<weld::Builder> mxAuxBuilder; + std::unique_ptr<weld::Box> mxTempToplevel; + std::unique_ptr<weld::Widget> mxContents; + + std::unique_ptr<weld::MenuButton> mxMenuButton; + std::unique_ptr<weld::Menu> mxMainMenu; + std::unique_ptr<weld::Menu> mxSubMenu; + std::unique_ptr<weld::Widget> mxMeasureBox; + class Item + { + private: + TabBar& mrTabBar; + std::unique_ptr<weld::Builder> mxBuilder; + public: + Item(TabBar& rTabBar); + ~Item(); + DECL_LINK(HandleClick, const OUString&, void); + std::unique_ptr<weld::Toolbar> mxButton; + OUString msDeckId; + ::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor; + bool mbIsHidden; + bool mbIsHiddenByDefault; + }; + typedef ::std::vector<std::unique_ptr<Item>> ItemContainer; + ItemContainer maItems; + const ::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor; + PopupMenuProvider maPopupMenuProvider; + + void CreateTabItem(weld::Toolbar& rButton, const DeckDescriptor& rDeckDescriptor); + css::uno::Reference<css::graphic::XGraphic> GetItemImage(const DeckDescriptor& rDeskDescriptor) const; + void UpdateButtonIcons(); + + DECL_LINK(OnToolboxClicked, weld::Toggleable&, void); + + SidebarController* pParentSidebarController; + std::unique_ptr<svt::AcceleratorExecute> mpAccel; + +}; + + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Theme.hxx b/include/sfx2/sidebar/Theme.hxx new file mode 100644 index 0000000000..a3f827f4a5 --- /dev/null +++ b/include/sfx2/sidebar/Theme.hxx @@ -0,0 +1,184 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <sfx2/dllapi.h> + +#include <tools/color.hxx> +#include <comphelper/compbase.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> + +#include <map> +#include <unordered_map> + + +namespace sfx2::sidebar { + +typedef comphelper::WeakComponentImplHelper < + css::beans::XPropertySet, + css::beans::XPropertySetInfo + > ThemeInterfaceBase; + +/** Simple collection of colors, gradients, fonts that define the + look of the sidebar and its controls. +*/ +class SFX2_DLLPUBLIC Theme final + : public ThemeInterfaceBase +{ +public: + enum ThemeItem + { + Begin_, + Pre_Color_ = Begin_, + + AnyItem_ = Pre_Color_, + + Image_Color_, + + Color_Highlight, + Color_HighlightText, + Color_DeckBackground, + Color_DeckTitleBarBackground, + Color_PanelBackground, + Color_PanelTitleBarBackground, + Color_TabBarBackground, + + Color_Int_, + + Int_DeckBorderSize, + Int_DeckSeparatorHeight, + Int_DeckLeftPadding, + Int_DeckTopPadding, + Int_DeckRightPadding, + Int_DeckBottomPadding, + + Int_Bool_, + + Bool_UseSystemColors, + Bool_IsHighContrastModeActive, + + Post_Bool_, + End_=Post_Bool_ + }; + + static Color GetColor (const ThemeItem eItem); + static sal_Int32 GetInteger (const ThemeItem eItem); + + static bool IsHighContrastMode(); + + static void HandleDataChange(); + + void InitializeTheme(); + + Theme(); + virtual ~Theme() override; + Theme(const Theme&) = delete; + Theme& operator=( const Theme& ) = delete; + + virtual void disposing(std::unique_lock<std::mutex>&) 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<Color> maColors; + std::vector<sal_Int32> maIntegers; + std::vector<bool> maBooleans; + 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_Color, + PT_Integer, + PT_Boolean, + PT_Invalid + }; + + void SetupPropertyMaps(); + void UpdateTheme(); + static PropertyType GetPropertyType (const ThemeItem eItem); + static css::uno::Type const & GetCppuType (const PropertyType eType); + static sal_Int32 GetIndex ( + const ThemeItem eItem, + const PropertyType eType); + + VetoableListenerContainer* GetVetoableListeners ( + const ThemeItem eItem, + const bool bCreate); + ChangeListenerContainer* GetChangeListeners ( + const ThemeItem eItem, + const bool bCreate); + static bool DoVetoableListenersVeto ( + const VetoableListenerContainer* pListeners, + const css::beans::PropertyChangeEvent& rEvent); + static void BroadcastPropertyChange ( + const ChangeListenerContainer* pListeners, + const css::beans::PropertyChangeEvent& rEvent); + void ProcessNewValue ( + const css::uno::Any& rValue, + const ThemeItem eItem, + const PropertyType eType); +}; + + +} // end of namespace sfx2::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/signaturestate.hxx b/include/sfx2/signaturestate.hxx new file mode 100644 index 0000000000..d63498d1cb --- /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 0000000000..67c88c6871 --- /dev/null +++ b/include/sfx2/stbitem.hxx @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_STBITEM_HXX +#define INCLUDED_SFX2_STBITEM_HXX + +#include <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; + +rtl::Reference<svt::StatusbarController> SfxStatusBarControllerFactory( + const css::uno::Reference< css::frame::XFrame >& rFrame, + StatusBar* pStatusBar, + unsigned short nID, + const OUString& aCommandURL ); +typedef rtl::Reference<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; + +public: + // new controller API + // XInterface + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + +protected: + // XEventListener + using svt::StatusbarController::disposing; + + // XComponent + using svt::StatusbarController::dispose; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + // XStatusbarController + virtual sal_Bool SAL_CALL mouseButtonDown( const css::awt::MouseEvent& aMouseEvent ) override; + virtual sal_Bool SAL_CALL mouseMove( const css::awt::MouseEvent& aMouseEvent ) override; + virtual sal_Bool SAL_CALL mouseButtonUp( const css::awt::MouseEvent& aMouseEvent ) override; + virtual void SAL_CALL command( const css::awt::Point& aPos, + ::sal_Int32 nCommand, + sal_Bool bMouseEvent, + const css::uno::Any& aData ) override; + virtual void SAL_CALL paint( const css::uno::Reference< css::awt::XGraphics >& xGraphics, + const css::awt::Rectangle& rOutputRectangle, + ::sal_Int32 nStyle ) override; + virtual void SAL_CALL click( const css::awt::Point& aPos ) override; + virtual void SAL_CALL doubleClick( const css::awt::Point& aPos ) override; + + // Old sfx2 interface + virtual void StateChangedAtStatusBarControl( sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState ); + virtual void Click(); + virtual void Command( const CommandEvent& rCEvt ); + virtual bool MouseButtonDown( const MouseEvent & ); + virtual bool MouseMove( const MouseEvent & ); + virtual bool MouseButtonUp( const MouseEvent & ); + virtual void Paint( const UserDrawEvent &rUDEvt ); + + static sal_uInt16 convertAwtToVCLMouseButtons( sal_Int16 nAwtMouseButtons ); + +public: + SfxStatusBarControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar& rBar ); + virtual ~SfxStatusBarControl() override; + + sal_uInt16 GetSlotId() const { return nSlotId; } + sal_uInt16 GetId() const { return nId; } + StatusBar& GetStatusBar() const { return *pBar; } + + static rtl::Reference<SfxStatusBarControl> CreateControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar *pBar, SfxModule const * ); + static void RegisterStatusBarControl(SfxModule*, const SfxStbCtrlFactory&); + +}; + + +#define SFX_DECL_STATUSBAR_CONTROL() \ + static rtl::Reference<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) \ + rtl::Reference<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 0000000000..d28fa1cc22 --- /dev/null +++ b/include/sfx2/strings.hrc @@ -0,0 +1,366 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SFX2_INC_STRINGS_HRC +#define INCLUDED_SFX2_INC_STRINGS_HRC + +#define NC_(Context, String) TranslateId(Context, u8##String) + +#define STR_TEMPLATE_FILTER NC_("STR_TEMPLATE_FILTER", "Templates") +#define STR_SAVEDOC NC_("STR_SAVEDOC", "~Save") +#define STR_SAVEASDOC NC_("STR_SAVEASDOC", "Save ~As...") +#define STR_SAVEACOPY NC_("STR_SAVEACOPY", "Save a Copy...") +#define STR_CLOSEDOC NC_("STR_CLOSEDOC", "~Close") +#define STR_OPEN NC_("STR_OPEN", "~Open") +#define STR_EDIT_TEMPLATE NC_("STR_EDIT_TEMPLATE", "~Edit") +#define STR_DEFAULT_TEMPLATE NC_("STR_DEFAULT_TEMPLATE", "Set as De~fault") +#define STR_RESET_DEFAULT NC_("STR_RESET_DEFAULT", "Reset De~fault") +#define STR_DELETE_TEMPLATE NC_("STR_DELETE_TEMPLATE", "~Delete") +#define STR_SFX_RENAME NC_("STR_SFX_RENAME", "~Rename") +#define STR_MOVE NC_("STR_ACTION_MOVE","~Move") +#define STR_EXPORT NC_("STR_ACTION_EXPORT","E~xport") +#define STR_CATEGORY_RENAME NC_("STR_CATEGORY_RENAME", "Ren~ame Category") +#define STR_RENAME_TEMPLATE NC_("STR_RENAME_TEMPLATE", "Enter new template name:") +#define STR_TEMPLATE_TOOLTIP NC_("STR_TEMPLATE_TOOLTIP", "Title: $1\nCategory: $2") +#define STR_TEMPLATE_SELECTION NC_("STR_TEMPLATE_SELECTION", "Select a Template") +#define STR_AUTOMATICVERSION NC_("STR_AUTOMATICVERSION", "Automatically saved version") +#define STR_EXPORTBUTTON NC_("STR_EXPORTBUTTON", "Export") +#define STR_LABEL_FILEFORMAT NC_("STR_LABEL_FILEFORMAT", "File format:") +#define STR_HIDDENINFO_CONTAINS NC_("STR_HIDDENINFO_CONTAINS", "This document contains:\n\n") +#define STR_HIDDENINFO_RECORDCHANGES NC_("STR_HIDDENINFO_RECORDCHANGES", "Recorded changes") +#define STR_HIDDENINFO_NOTES NC_("STR_HIDDENINFO_NOTES", "Notes") +#define STR_HIDDENINFO_DOCVERSIONS NC_("STR_HIDDENINFO_DOCVERSIONS", "Document versions") +#define STR_NEW_FILENAME_SAVE NC_("STR_NEW_FILENAME_SAVE", "If you do not want to overwrite the original document, you should save your work under a new filename.") +// Used in the title of a shared document. +#define STR_SHARED NC_("STR_SHARED", " (shared)") +#define STR_XMLSEC_ODF12_EXPECTED NC_("STR_XMLSEC_ODF12_EXPECTED", "The document format version is set to ODF 1.1 (OpenOffice.org 2.x) in Tools-Options-Load/Save-General. Signing documents requires ODF 1.2 (OpenOffice.org 3.x).") +#define STR_XMLSEC_QUERY_SAVESIGNEDBEFORESIGN NC_("STR_XMLSEC_QUERY_SAVESIGNEDBEFORESIGN", "The document has to be saved before it can be signed. Saving the document removes all present signatures.\nDo you want to save the document?") +#define STR_QRYTEMPL_MESSAGE NC_("STR_QRYTEMPL_MESSAGE", "The template '$(ARG1)' on which this document is based, has been modified. Do you want to update the styles of the current document, using the modified template?") +#define STR_QRYTEMPL_UPDATE_BTN NC_("STR_QRYTEMPL_UPDATE_BTN", "~Update Styles") +#define STR_QRYTEMPL_KEEP_BTN NC_("STR_QRYTEMPL_KEEP_BTN", "~Keep Old Styles") +#define STR_CATEGORY_NEW NC_("STR_CATEGORY_NEW", "~New Category") +#define STR_CATEGORY_DELETE NC_("STR_CATEGORY_DELETE", "~Delete Category") +#define STR_MSG_EXPORT_SUCCESS NC_("STR_MSG_EXPORT_SUCCESS", "$1 templates successfully exported.") +#define STR_MSG_QUERY_COPY NC_("STR_MSG_QUERY_COPY", "$1 could not be moved to the category \"$2\". Do you want to copy the template instead?") +#define STR_CREATE_ERROR NC_("STR_CREATE_ERROR", "Cannot create category: $1") +#define STR_ERROR_SAVEAS NC_("STR_ERROR_SAVEAS", "Cannot save template: $1") +#define STR_INPUT_NEW NC_("STR_INPUT_NEW", "Enter new category name:") +#define STR_MSG_ERROR_LOCAL_MOVE NC_("STR_MSG_ERROR_LOCAL_MOVE", "Error moving the following templates to $1.\n$2") +#define STR_MSG_ERROR_EXPORT NC_("STR_MSG_ERROR_EXPORT", "Error exporting the following templates:\n$1") +#define STR_MSG_ERROR_IMPORT NC_("STR_MSG_ERROR_IMPORT", "Error importing the following templates to $1:\n$2") +#define STR_MSG_ERROR_DELETE_TEMPLATE NC_("STR_MSG_ERROR_DELETE_TEMPLATE", "The following templates cannot be deleted:\n$1") +#define STR_MSG_ERROR_DELETE_FOLDER NC_("STR_MSG_ERROR_DELETE_FOLDER", "The following folders cannot be deleted:\n$1") +#define STR_TOOLTIP_ERROR_RENAME_TEMPLATE NC_("STR_TOOLTIP_ERROR_RENAME_TEMPLATE", "There is another template with the name $1 in $2.") +#define STR_QMSG_SEL_FOLDER_DELETE NC_("STR_QMSG_SEL_FOLDER_DELETE", "Do you want to delete the selected category?") +#define STR_QMSG_TEMPLATE_OVERWRITE NC_("STR_QMSG_TEMPLATE_OVERWRITE", "A template named $1 already exists in $2. Do you want to overwrite it?") +#define STR_QMSG_SEL_TEMPLATE_DELETE NC_("STR_QMSG_SEL_TEMPLATE_DELETE", "Do you want to delete the selected templates?") + +#define STR_HELP_WINDOW_TITLE NC_("STR_HELP_WINDOW_TITLE", "%PRODUCTNAME Help") +#define STR_HELP_BUTTON_INDEX_ON NC_("STR_HELP_BUTTON_INDEX_ON", "Show Navigation Pane") +#define STR_HELP_BUTTON_INDEX_OFF NC_("STR_HELP_BUTTON_INDEX_OFF", "Hide Navigation Pane") +#define STR_HELP_BUTTON_START NC_("STR_HELP_BUTTON_START", "First Page") +#define STR_HELP_BUTTON_PREV NC_("STR_HELP_BUTTON_PREV", "Previous Page") +#define STR_HELP_BUTTON_NEXT NC_("STR_HELP_BUTTON_NEXT", "Next Page") +#define STR_HELP_BUTTON_PRINT NC_("STR_HELP_BUTTON_PRINT", "Print...") +#define STR_HELP_BUTTON_ADDBOOKMARK NC_("STR_HELP_BUTTON_ADDBOOKMARK", "Add to Bookmarks...") +#define STR_HELP_BUTTON_SEARCHDIALOG NC_("STR_HELP_BUTTON_SEARCHDIALOG", "Find on this Page...") +#define STR_HELP_BUTTON_SOURCEVIEW NC_("STR_HELP_BUTTON_SOURCEVIEW", "HTML Source") +#define STR_HELP_MENU_TEXT_SELECTION_MODE NC_("STR_HELP_MENU_TEXT_SELECTION_MODE", "Select Text") +#define STR_HELP_MENU_TEXT_COPY NC_("STR_HELP_MENU_TEXT_COPY", "~Copy") +#define STR_INFO_NOSEARCHRESULTS NC_("STR_INFO_NOSEARCHRESULTS", "No topics found.") +#define STR_INFO_NOSEARCHTEXTFOUND NC_("STR_INFO_NOSEARCHTEXTFOUND", "The text you entered was not found.") +#define RID_HELP_ONSTARTUP_TEXT NC_("RID_HELP_ONSTARTUP_TEXT", "~Display %PRODUCTNAME %MODULENAME Help at Startup") + +#define STR_NONAME NC_("STR_NONAME", "Untitled") +#define STR_STANDARD_SHORTCUT NC_("STR_STANDARD_SHORTCUT", "Standard") +#define STR_BYTES NC_("STR_BYTES", "Bytes") +#define STR_KB NC_("STR_KB", "kB") +#define STR_MB NC_("STR_MB", "MB") +#define STR_GB NC_("STR_GB", "GB") +#define STR_QUERY_LASTVERSION NC_("STR_QUERY_LASTVERSION", "Cancel all changes?") +#define STR_NO_WEBBROWSER_FOUND NC_("STR_NO_WEBBROWSER_FOUND", "Opening \"$(ARG1)\" failed with error code $(ARG2) and message: \"$(ARG3)\"\nMaybe no web browser could be found on your system. In that case, please check your Desktop Preferences or install a web browser (for example, Firefox) in the default location requested during the browser installation.") +#define STR_DANGEROUS_TO_OPEN NC_("STR_DANGEROUS_TO_OPEN", "It might be dangerous to open \"$(ARG1)\".\nDo you really want to open it?") +#define STR_NO_ABS_URI_REF NC_("STR_NO_ABS_URI_REF", "\"$(ARG1)\" cannot be passed to an external application to open it (e.g., it might not be an absolute URL, or might denote no existing file).") +#define STR_GID_INTERN NC_("STR_GID_INTERN", "Internal") +#define STR_GID_APPLICATION NC_("STR_GID_APPLICATION", "Application") +#define STR_GID_VIEW NC_("STR_GID_VIEW", "View") +#define STR_GID_DOCUMENT NC_("STR_GID_DOCUMENT", "Documents") +#define STR_GID_EDIT NC_("STR_GID_EDIT", "Edit") +#define STR_GID_MACRO NC_("STR_GID_MACRO", "BASIC") +#define STR_GID_OPTIONS NC_("STR_GID_OPTIONS", "Options") +#define STR_GID_MATH NC_("STR_GID_MATH", "Math") +#define STR_GID_NAVIGATOR NC_("STR_GID_NAVIGATOR", "Navigate") +#define STR_GID_INSERT NC_("STR_GID_INSERT", "Insert") +#define STR_GID_FORMAT NC_("STR_GID_FORMAT", "Format") +#define STR_GID_TEMPLATE NC_("STR_GID_TEMPLATE", "Templates") +#define STR_GID_TEXT NC_("STR_GID_TEXT", "Text") +#define STR_GID_FRAME NC_("STR_GID_FRAME", "Frame") +#define STR_GID_GRAPHIC NC_("STR_GID_GRAPHIC", "Image") +#define STR_GID_TABLE NC_("STR_GID_TABLE", "Table") +#define STR_GID_ENUMERATION NC_("STR_GID_ENUMERATION", "Numbering") +#define STR_GID_DATA NC_("STR_GID_DATA", "Data") +#define STR_GID_SPECIAL NC_("STR_GID_SPECIAL", "Special Functions") +#define STR_GID_IMAGE NC_("STR_GID_IMAGE", "Image") +#define STR_GID_CHART NC_("STR_GID_CHART", "Chart") +#define STR_GID_EXPLORER NC_("STR_GID_EXPLORER", "Explorer") +#define STR_GID_CONNECTOR NC_("STR_GID_CONNECTOR", "Connector") +#define STR_GID_MODIFY NC_("STR_GID_MODIFY", "Modify") +#define STR_GID_DRAWING NC_("STR_GID_DRAWING", "Drawing") +#define STR_GID_CONTROLS NC_("STR_GID_CONTROLS", "Controls") +#define STR_QUITAPP NC_("STR_QUITAPP", "E~xit %PRODUCTNAME") +#define RID_STR_HELP NC_("RID_STR_HELP", "Help") +#define RID_STR_HLPFILENOTEXIST NC_("RID_STR_HLPFILENOTEXIST", "The help file for this topic is not installed.") +#define STR_QUICKSTART_EXIT NC_("STR_QUICKSTART_EXIT", "Exit Quickstarter") +#define STR_QUICKSTART_TIP NC_("STR_QUICKSTART_TIP", "%PRODUCTNAME %PRODUCTVERSION Quickstarter") +#define STR_QUICKSTART_FILEOPEN NC_("STR_QUICKSTART_FILEOPEN", "Open Document...") +#define STR_QUICKSTART_FROMTEMPLATE NC_("STR_QUICKSTART_FROMTEMPLATE", "Template Manager...") +#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_QUERY_REMEMBERSIGNATURE NC_("STR_QUERY_REMEMBERSIGNATURE", "Do you want to remember that signature for each save?") +#define STR_INFO_WRONGDOCFORMAT NC_("STR_INFO_WRONGDOCFORMAT", "This document must be saved in OpenDocument file format before it can be digitally signed.") +#define RID_XMLSEC_DOCUMENTSIGNED NC_("RID_XMLSEC_DOCUMENTSIGNED", " (Signed)") +#define STR_EMBEDDED_TITLE NC_("STR_EMBEDDED_TITLE", " (Embedded document)") +#define STR_STANDARD NC_("STR_STANDARD", "Standard") +#define RID_SVXSTR_FILELINK NC_("RID_SVXSTR_FILELINK", "Document") +#define STR_NONE NC_("STR_NONE", "- None -") +#define STR_CATEGORY_NONE NC_("saveastemplatedlg|categorylist", "None") +#define RID_SVXSTR_GRAPHICLINK NC_("RID_SVXSTR_GRAPHICLINK", "Image") +#define STR_SFX_FILTERNAME_ALL NC_("STR_SFX_FILTERNAME_ALL", "All files") +#define STR_SFX_FILTERNAME_PDF NC_("STR_SFX_FILTERNAME_PDF", "PDF files") +#define RID_SVXSTR_EDITGRFLINK NC_("RID_SVXSTR_EDITGRFLINK", "Link Image") +// i66948 used in project scripting +#define STR_ERRUNOEVENTBINDUNG NC_("STR_ERRUNOEVENTBINDUNG", "An appropriate component method %1\ncould not be found.\n\nCheck spelling of method name.") +#define RID_SVXSTR_GRFILTER_OPENERROR NC_("RID_SVXSTR_GRFILTER_OPENERROR", "Image file cannot be opened") +#define RID_SVXSTR_GRFILTER_IOERROR NC_("RID_SVXSTR_GRFILTER_IOERROR", "Image file cannot be read") +#define RID_SVXSTR_GRFILTER_FORMATERROR NC_("RID_SVXSTR_GRFILTER_FORMATERROR", "Unknown image format") +#define RID_SVXSTR_GRFILTER_VERSIONERROR NC_("RID_SVXSTR_GRFILTER_VERSIONERROR", "This version of the image file is not supported") +#define RID_SVXSTR_GRFILTER_FILTERERROR NC_("RID_SVXSTR_GRFILTER_FILTERERROR", "Image filter not found") +#define RID_SVXSTR_TXTFILTER_FILTERERROR NC_("RID_SVXSTR_TXTFILTER_FILTERERROR", "This is not a text document") +#define RID_SVXSTR_END_REDLINING_WARNING NC_("RID_SVXSTR_END_REDLINING_WARNING", "This action will exit the change recording mode.\nNo information about changes will be recorded from now on.\n\nExit change recording mode?\n\n") +#define RID_SVXSTR_INCORRECT_PASSWORD NC_("RID_SVXSTR_INCORRECT_PASSWORD", "Incorrect password") +#define RID_SVXSTR_GPG_ENCRYPT_FAILURE NC_("RID_SVXSTR_GPG_ENCRYPT_FAILURE", "OpenPGP key not trusted, damaged, or encryption failure. Please try again.") + +#define STR_PASSWD_MIN_LEN NC_("STR_PASSWD_MIN_LEN", "(Minimum $(MINLEN) characters)") +#define STR_PASSWD_MIN_LEN1 NC_("STR_PASSWD_MIN_LEN1", "(Minimum 1 character)") +#define STR_PASSWD_EMPTY NC_("STR_PASSWD_EMPTY", "(The password can be empty)") +#define STR_MODULENOTINSTALLED NC_("STR_MODULENOTINSTALLED", "The action could not be executed. The %PRODUCTNAME program module needed for this action is currently not installed.") + +#define STR_FILTER_NOT_INSTALLED NC_("STR_FILTER_NOT_INSTALLED", "The selected filter $(FILTER) has not been installed.\nWould you like to do this now?") +#define STR_FILTER_CONSULT_SERVICE NC_("STR_FILTER_CONSULT_SERVICE", "The selected filter $(FILTER) is not included in your edition.\nYou can find information about orders on our homepage.") + +#define STR_WELCOME_LINE1 NC_("STR_WELCOME_LINE1", "Welcome to %PRODUCTNAME.") +#define STR_WELCOME_LINE2 NC_("STR_WELCOME_LINE2", "Drop a document here or open an app to create one.") + +// Translators: Target types in Auto-redaction dialog +#define STR_REDACTION_TARGET_TYPE_TEXT NC_("STR_REDACTION_TARGET_TYPE_TEXT", "Text") +#define STR_REDACTION_TARGET_TYPE_REGEX NC_("STR_REDACTION_TARGET_TYPE_REGEX", "Regular expression") +#define STR_REDACTION_TARGET_TYPE_PREDEF NC_("STR_REDACTION_TARGET_TYPE_PREDEF", "Predefined") +#define STR_REDACTION_TARGET_TYPE_UNKNOWN NC_("STR_REDACTION_TARGET_TYPE_UNKNOWN", "Unknown") + +// Translators: Values for the Case Sensitive and the Whole Words columns in Auto-redaction dialog +#define STR_REDACTION_YES NC_("STR_REDACTION_YES", "Yes") +#define STR_REDACTION_NO NC_("STR_REDACTION_NO", "No") + +// Translators: Misc strings of the Auto Redaction dialog +#define STR_REDACTION_TARGET NC_("STR_REDACTION_TARGET", "Target") +#define STR_REDACTION_LOAD_TARGETS NC_("STR_REDACTION_LOAD_TARGETS", "Load Targets") +#define STR_REDACTION_SAVE_TARGETS NC_("STR_REDACTION_SAVE_TARGETS", "Save Targets") +#define STR_REDACTION_FIELDS_REQUIRED NC_("STR_REDACTION_FIELDS_REQUIRED", "All fields are required") +#define STR_REDACTION_TARGET_NAME_CLASH NC_("STR_REDACTION_TARGET_NAME_CLASH", "There is already a target with this name") +#define STR_REDACTION_MULTI_EDIT NC_("STR_REDACTION_MULTI_EDIT", "You have selected multiple targets, but only one target can be edited at once.") +#define STR_REDACTION_MULTI_DELETE NC_("STR_REDACTION_MULTI_DELETE", "Are you sure you would like to delete $(TARGETSCOUNT) targets at once?") +#define STR_REDACTION_JSON_FILE_FILTER NC_("STR_REDACTION_JSON_FILE_FILTER", "Target Set (*.json)") +#define STR_REDACTION_EDIT_TARGET NC_("STR_REDACTION_EDIT_TARGET", "Edit Target") +#define STR_REDACTION_TARGET_ADD_ERROR NC_("STR_REDACTION_TARGET_ADD_ERROR", "An error occurred while adding new target. Please report this incident.") +#define STR_REDACTION_NO_DRAW_WARNING NC_("STR_REDACTION_NO_DRAW_WARNING", "Draw module is needed for redaction. Please make sure you have %PRODUCTNAME Draw installed and working correctly.") + +#define STR_SFX_FILEDLG_ACTUALVERSION NC_("STR_SFX_FILEDLG_ACTUALVERSION", "Current version") +#define STR_SFX_EXPLORERFILE_EXPORT NC_("STR_SFX_EXPLORERFILE_EXPORT", "Export") +#define STR_SFX_EXPLORERFILE_INSERT NC_("STR_SFX_EXPLORERFILE_INSERT", "Insert") +#define STR_SFX_EXPLORERFILE_BUTTONINSERT NC_("STR_SFX_EXPLORERFILE_BUTTONINSERT", "~Insert") +#define STR_SFX_IMPORT_ALL_IMAGES NC_("STR_SFX_IMPORT_ALL_IMAGES", "<All images>") +#define STR_PB_SAVEACOPY NC_("STR_PB_SAVEACOPY", "Save a Copy") +#define STR_PB_COMPAREDOC NC_("STR_PB_COMPAREDOC", "Compare to Original Document") +#define STR_PB_MERGEDOC NC_("STR_PB_MERGEDOC", "Merge with") + +#define STR_SFX_NEWOFFICEDOC NC_("STR_SFX_NEWOFFICEDOC", "%PRODUCTNAME document") +#define SFX_ST_DURATION_FORMAT NC_("SFX_ST_DURATION_FORMAT", " Y: %1 M: %2 D: %3 H: %4 M: %5 S: %6") +#define STR_SFX_QUERY_WRONG_TYPE NC_("STR_SFX_QUERY_WRONG_TYPE", "The value entered does not match the specified type.\nThe value will be stored as text.") + +#define STR_QUERY_OVERWRITE NC_("STR_QUERY_OVERWRITE", "Style already exists. Overwrite?") + +#define STR_RESET NC_("STR_RESET", "~Reset") +#define STR_TABPAGE_INVALIDNAME NC_("STR_TABPAGE_INVALIDNAME", "This name is already in use.") +#define STR_TABPAGE_INVALIDSTYLE NC_("STR_TABPAGE_INVALIDSTYLE", "This Style does not exist.") +#define STR_TABPAGE_INVALIDPARENT NC_("STR_TABPAGE_INVALIDPARENT", "This Style cannot be used as a base Style,\nbecause it would result in a recursive reference.") +#define STR_POOL_STYLE_NAME NC_("STR_POOL_STYLE_NAME", "Name already exists as a default Style.\nPlease choose another name.") +#define STR_DELETE_STYLE_USED NC_("STR_DELETE_STYLE_USED", "One or more of the selected styles is in use in this document.\nIf you will delete it, text or objects using these styles will revert to the parent style.\nDo you still wish to delete these styles?\n") +#define STR_DELETE_STYLE NC_("STR_DELETE_STYLE", "Styles in use: ") +#define STR_SID_NAVIGATOR NC_("STR_SID_NAVIGATOR", "Navigator") +#define STR_ERROR_WRONG_CONFIRM NC_("STR_ERROR_WRONG_CONFIRM", "Faulty password confirmation") +#define STR_PDF_EXPORT_SEND NC_("STR_PDF_EXPORT_SEND", "Send") +#define STR_FONT_TABPAGE NC_("STR_FONT_TABPAGE", "Font") + +#define STR_VIEWVERSIONCOMMENT NC_("STR_VIEWVERSIONCOMMENT", "View Version Comment") +#define STR_NO_NAME_SET NC_("STR_NO_NAME_SET", "(no name set)") + +#define STR_STYLE_FILTER_HIERARCHICAL NC_("STR_STYLE_FILTER_HIERARCHICAL", "Hierarchical") + +#define STR_MACRO_LOSS NC_("STR_MACRO_LOSS", "Do you really want to cancel the recording? Any steps recorded up to this point will be lost.") +#define STR_CANCEL_RECORDING NC_("STR_CANCEL_RECORDING", "Cancel Recording") + +#define RID_CNT_STR_WAITING NC_("RID_CNT_STR_WAITING", "The templates are being initialized for first-time usage.") + +#define STR_NODEFPRINTER NC_("STR_NODEFPRINTER", "No default printer found.\nPlease choose a printer and try again.") +#define STR_NOSTARTPRINTER NC_("STR_NOSTARTPRINTER", "Could not start printer.\nPlease check your printer configuration.") +#define STR_ERROR_PRINTER_BUSY NC_("STR_ERROR_PRINTER_BUSY", "Printer busy") +#define STR_READONLY NC_("STR_READONLY", " (read-only)") +#define STR_PRINT_NEWORI NC_("STR_PRINT_NEWORI", "The page size and orientation have been modified.\nWould you like to save the new settings in the\nactive document?") +#define STR_PRINT_NEWSIZE NC_("STR_PRINT_NEWSIZE", "The page size has been modified.\nShould the new settings be saved\nin the active document?") +#define STR_PRINT_NEWORISIZE NC_("STR_PRINT_NEWORISIZE", "The page size and orientation have been modified.\nWould you like to save the new settings in the\nactive document?") +#define STR_CANT_CLOSE NC_("STR_CANT_CLOSE", "The document cannot be closed because a\n print job is being carried out.") +#define STR_ERROR_SEND_MAIL NC_("STR_ERROR_SEND_MAIL", "An error occurred in sending the message. Possible errors could be a missing user account or a defective setup.\nPlease check the %PRODUCTNAME settings or your email program settings.") +// Error codes look like "MAPI_E_FAILURE" or "1234" +#define STR_ERROR_SEND_MAIL_CODE NC_("STR_ERROR_SEND_MAIL_CODE", "An error occurred in sending the message. Possible errors could be a missing user account or a defective setup.\n\nError code is $1") +#define STR_ERROR_SEND_MAIL_HEADER NC_("STR_ERROR_SEND_MAIL_HEADER", "Error sending mail") +#define STR_QUERY_OPENASTEMPLATE NC_("STR_QUERY_OPENASTEMPLATE", "This document cannot be edited, possibly due to missing access rights. Do you want to edit a copy of the document?") +#define STR_QUERY_OPENASTEMPLATE_LOCKED NC_("STR_QUERY_OPENASTEMPLATE_LOCKED", "This document cannot be edited, because it is locked in another session.%LOCKINFO\nDo you want to edit a copy of the document?") +#define STR_QUERY_OPENASTEMPLATE_ALLOW_IGNORE NC_("STR_QUERY_OPENASTEMPLATE_ALLOW_IGNORE", "You can also try to ignore the lock and open the file for editing.") +#define STR_QUERY_OPENASTEMPLATE_OPENCOPY_BTN NC_("STR_QUERY_OPENASTEMPLATE_OPENCOPY_BTN", "Open ~Copy") +#define STR_QUERY_OPENASTEMPLATE_OPEN_BTN NC_("STR_QUERY_OPENASTEMPLATE_OPEN_BTN", "~Open") +#define STR_REPAIREDDOCUMENT NC_("STR_REPAIREDDOCUMENT", " (repaired document)") +#define STR_NONCHECKEDOUT_DOCUMENT NC_("STR_NONCHECKEDOUT_DOCUMENT", "This document is not checked out on the server.") +#define STR_GET_INVOLVED_TEXT NC_("STR_GET_INVOLVED_TEXT", "Help us make %PRODUCTNAME even better!") +#define STR_GET_INVOLVED_BUTTON NC_("STR_GET_INVOLVED_BUTTON", "Get involved") +#define STR_DONATE_TEXT NC_("STR_DONATE_TEXT", "Your donations support our worldwide community.") +#define STR_DONATE_BUTTON NC_("STR_DONATE_BUTTON", "Donate") +#define STR_WHATSNEW_TEXT NC_("STR_WHATSNEW", "You are running version %PRODUCTVERSION of %PRODUCTNAME for the first time. Do you want to learn what's new?") +#define STR_WHATSNEW_BUTTON NC_("STR_WHATSNEW_BUTTON", "Release Notes") +#define STR_READONLY_DOCUMENT NC_("STR_READONLY_DOCUMENT", "This document is open in read-only mode.") +#define STR_READONLY_PDF NC_("STR_READONLY_PDF", "This PDF is open in read-only mode to allow signing the existing file.") +#define STR_CLASSIFIED_DOCUMENT NC_("STR_CLASSIFIED_DOCUMENT", "The classification label of this document is %1.") +#define STR_TARGET_DOC_NOT_CLASSIFIED NC_("STR_TARGET_DOC_NOT_CLASSIFIED", "This document must be classified before the clipboard can be pasted.") +#define STR_DOC_CLASSIFICATION_TOO_LOW NC_("STR_DOC_CLASSIFICATION_TOO_LOW", "This document has a lower classification level than the clipboard.") +#define STR_CLASSIFIED_INTELLECTUAL_PROPERTY NC_("STR_CLASSIFIED_INTELLECTUAL_PROPERTY", "Level") +#define STR_CLASSIFIED_NATIONAL_SECURITY NC_("STR_CLASSIFIED_NATIONAL_SECURITY", "National Security:") +#define STR_CLASSIFIED_EXPORT_CONTROL NC_("STR_CLASSIFIED_EXPORT_CONTROL", "Export Control:") +#define STR_CHECKOUT NC_("STR_CHECKOUT", "Check Out") +#define STR_READONLY_EDIT NC_("STR_READONLY_EDIT", "Edit Document") +#define STR_READONLY_SIGN NC_("STR_READONLY_SIGN", "Sign Document") +#define STR_READONLY_FINISH_SIGN NC_("STR_READONLY_FINISH_SIGN", "Finish Signing") +#define STR_SIGNATURE_BROKEN NC_("STR_SIGNATURE_BROKEN", "This document has an invalid signature.") +#define STR_SIGNATURE_INVALID NC_("STR_SIGNATURE_INVALID", "The signature was valid, but the document has been modified") +#define STR_SIGNATURE_NOTVALIDATED NC_("STR_SIGNATURE_NOTVALIDATED", "At least one signature has problems: the certificate could not be validated.") +#define STR_SIGNATURE_PARTIAL_OK NC_("STR_SIGNATURE_PARTIAL_OK", "At least one signature has problems: the document is only partially signed.") +#define STR_SIGNATURE_NOTVALIDATED_PARTIAL_OK NC_("STR_SIGNATURE_NOTVALIDATED_PARTIAL_OK", "The certificate could not be validated and the document is only partially signed.") +#define STR_SIGNATURE_OK NC_("STR_SIGNATURE_OK", "This document is digitally signed and the signature is valid.") +#define STR_SIGNATURE_SHOW NC_("STR_SIGNATURE_SHOW", "Show Signatures") +#define STR_TRACK_CHANGES_BUTTON NC_("STR_TRACK_CHANGES_BUTTON", "Show Toolbar") +#define STR_TRACK_CHANGES_BUTTON_HIDE NC_("STR_TRACK_CHANGES_BUTTON_HIDE", "Hide Toolbar") +#define STR_HYPHENATION_BUTTON NC_("STR_HYPHENATION_BUTTON", "Learn more") +#define STR_REFRESH_MASTER_PASSWORD NC_("STR_REFRESH_MASTER_PASSWORD", "The master password is stored in an outdated format, you should refresh it") +#define STR_REFRESH_PASSWORD NC_("STR_REFRESH_PASSWORD", "Refresh Password") +#define STR_MACROS_DISABLED_TITLE NC_("STR_MACROS_DISABLED_TITLE", "Macros disabled") +#define STR_CONTAINS_MACROS NC_("STR_CONTAINS_MACROS", "Macros in this document are disabled due to the Macro Security settings.") +#define STR_MACROS_DISABLED NC_("STR_MACROS_DISABLED", "Macros are disabled due to the Macro Security settings.") +#define STR_MACROS_DISABLED_CONTENT_UNSIGNED NC_("STR_MACROS_DISABLED_CONTENT_UNSIGNED", "Macros are signed, but the document (containing document events) is not signed.") +#define STR_MACROS NC_("STR_MACROS", "Show Macros") +#define STR_SECURITY_OPTIONS NC_("STR_MACROS", "Show Security Options") +#define STR_EVENTS NC_("STR_EVENTS", "Show Events") + +// Translators: default Impress template names +#define STR_TEMPLATE_NAME1 NC_("STR_TEMPLATE_NAME1", "Grey Elegant") +#define STR_TEMPLATE_NAME2 NC_("STR_TEMPLATE_NAME2", "Beehive") +#define STR_TEMPLATE_NAME3 NC_("STR_TEMPLATE_NAME3", "Blue Curve") +#define STR_TEMPLATE_NAME4 NC_("STR_TEMPLATE_NAME4", "Blueprint Plans") +#define STR_TEMPLATE_NAME5 NC_("STR_TEMPLATE_NAME5", "Candy") +#define STR_TEMPLATE_NAME6 NC_("STR_TEMPLATE_NAME6", "Yellow Idea") +#define STR_TEMPLATE_NAME7 NC_("STR_TEMPLATE_NAME7", "DNA") +#define STR_TEMPLATE_NAME8 NC_("STR_TEMPLATE_NAME8", "Focus") +#define STR_TEMPLATE_NAME9 NC_("STR_TEMPLATE_NAME9", "Forestbird") +#define STR_TEMPLATE_NAME10 NC_("STR_TEMPLATE_NAME10", "Freshes") +#define STR_TEMPLATE_NAME11 NC_("STR_TEMPLATE_NAME11", "Inspiration") +#define STR_TEMPLATE_NAME12 NC_("STR_TEMPLATE_NAME12", "Lights") +#define STR_TEMPLATE_NAME13 NC_("STR_TEMPLATE_NAME13", "Growing Liberty") +#define STR_TEMPLATE_NAME14 NC_("STR_TEMPLATE_NAME14", "Metropolis") +#define STR_TEMPLATE_NAME15 NC_("STR_TEMPLATE_NAME15", "Midnightblue") +#define STR_TEMPLATE_NAME16 NC_("STR_TEMPLATE_NAME16", "Nature Illustration") +#define STR_TEMPLATE_NAME17 NC_("STR_TEMPLATE_NAME17", "Pencil") +#define STR_TEMPLATE_NAME18 NC_("STR_TEMPLATE_NAME18", "Piano") +#define STR_TEMPLATE_NAME19 NC_("STR_TEMPLATE_NAME19", "Portfolio") +#define STR_TEMPLATE_NAME20 NC_("STR_TEMPLATE_NAME20", "Progress") +#define STR_TEMPLATE_NAME21 NC_("STR_TEMPLATE_NAME21", "Sunset") +#define STR_TEMPLATE_NAME22 NC_("STR_TEMPLATE_NAME22", "Vintage") +#define STR_TEMPLATE_NAME23 NC_("STR_TEMPLATE_NAME23", "Vivid") +// Translators: default Writer template names +#define STR_TEMPLATE_NAME24 NC_("STR_TEMPLATE_NAME24", "CV") +#define STR_TEMPLATE_NAME25 NC_("STR_TEMPLATE_NAME25", "Resume") +#define STR_TEMPLATE_NAME26 NC_("STR_TEMPLATE_NAME26", "Default") +#define STR_TEMPLATE_NAME27 NC_("STR_TEMPLATE_NAME27", "Modern") +#define STR_TEMPLATE_NAME28 NC_("STR_TEMPLATE_NAME28", "Modern business letter sans-serif") +#define STR_TEMPLATE_NAME29 NC_("STR_TEMPLATE_NAME29", "Modern business letter serif") +#define STR_TEMPLATE_NAME30 NC_("STR_TEMPLATE_NAME30", "Businesscard with logo") +#define STR_TEMPLATE_NAME31 NC_("STR_TEMPLATE_NAME31", "Simple") +#define STR_TEMPLATE_NAME32 NC_("STR_TEMPLATE_NAME32", "BPMN") +#define STR_TEMPLATE_NAME33 NC_("STR_TEMPLATE_NAME33", "Simplified Chinese Normal") +#define STR_TEMPLATE_NAME34 NC_("STR_TEMPLATE_NAME34", "Japanese Normal") + +#define STR_CLEAR_CHAR NC_("STR_CLEAR_CHAR", "Remove") +#define STR_CLEAR_ALL_CHAR NC_("STR_CLEAR_ALL_CHAR", "Clear All") + +#define STR_PASSWORD_LEN NC_("STR_PASSWORD_LEN", "Password length") +#define STR_PASSWORD_WARNING NC_("STR_PASSWORD_WARNING", "The password you have entered causes interoperability issues. Please enter a password that is shorter than 52 bytes, or longer than 55 bytes.") + +#define STR_CTRLCLICKHYPERLINK NC_("STR_CTRLCLICKHYPERLINK", "%{key}-click to open hyperlink: %{link}") +#define STR_CLICKHYPERLINK NC_("STR_CLICKHYPERLINK", "Click to open hyperlink: %{link}") + +#define STR_STYLEUSEDBY NC_("STR_STYLEUSEDBY", "(used by: %STYLELIST)") + +#define STR_DOCUMENT NC_("STR_DOCUMENT", "Document") +#define STR_SPREADSHEET NC_("STR_SPREADSHEET", "Spreadsheet") +#define STR_PRESENTATION NC_("STR_PRESENTATION", "Presentation") +#define STR_DRAWING NC_("STR_DRAWING", "Drawing") +#define STR_RECENT NC_("STR_RECENT", "Recently used") +#define STR_NORECENT NC_("STR_NORECENT", "No recent characters") + +#define STR_ACTION_RESET_ALL_DEFAULT_TEMPLATES NC_("STR_ACTION_RESET_ALL_DEFAULT_TEMPLATES","Reset All De~fault Templates") +#define STR_ACTION_RESET_WRITER_TEMPLATE NC_("STR_ACTION_RESET_WRITER_TEMPLATE","Reset De~fault Text Document") +#define STR_ACTION_RESET_CALC_TEMPLATE NC_("STR_ACTION_RESET_CALC_TEMPLATE","Reset De~fault Spreadsheet") +#define STR_ACTION_RESET_IMPRESS_TEMPLATE NC_("STR_ACTION_RESET_IMPRESS_TEMPLATE","Reset De~fault Presentation") +#define STR_ACTION_RESET_DRAW_TEMPLATE NC_("STR_ACTION_RESET_DRAW_TEMPLATE","Reset De~fault Drawing") +#define STR_ACTION_IMPORT NC_("STR_ACTION_IMPORT","~Import") +#define STR_ACTION_EXTENSIONS NC_("STR_ACTION_EXTENSIONS","E~xtensions") +#define STR_WINDOW_TITLE_RENAME_TEMPLATE NC_("STR_WINDOW_TITLE_RENAME_TEMPLATE","Rename") +#define STR_WINDOW_TITLE_RENAME_CATEGORY NC_("STR_WINDOW_TITLE_RENAME_CATEGORY","Rename Category") +#define STR_WINDOW_TITLE_RENAME_NEW_CATEGORY NC_("STR_WINDOW_TITLE_RENAME_NEW_CATEGORY","New Category") + +#define STR_OBJECT_INSPECTOR NC_("STR_OBJECT_INSPECTOR", "UNO Object Inspector") +#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 0000000000..d53f9fcdc0 --- /dev/null +++ b/include/sfx2/styfitem.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_STYFITEM_HXX +#define INCLUDED_SFX2_STYFITEM_HXX + +#include <rtl/ustring.hxx> +#include <sal/config.h> +#include <sfx2/dllapi.h> +#include <svl/style.hxx> +#include <unotools/resmgr.hxx> +#include <utility> +#include <vector> + +struct SFX2_DLLPUBLIC SfxFilterTuple +{ + OUString aName; + SfxStyleSearchBits nFlags; + SfxFilterTuple(OUString _aName, SfxStyleSearchBits nArg) + : aName(std::move(_aName)) + , nFlags(nArg) + { + } +}; + +typedef std::vector<SfxFilterTuple> SfxStyleFilter; + +class SFX2_DLLPUBLIC SfxStyleFamilyItem +{ + SfxStyleFamily nFamily; + OUString aText; + OUString aImage; + SfxStyleFilter aFilterList; + +public: + SfxStyleFamilyItem(SfxStyleFamily nFamily, OUString rName, OUString rImage, const std::pair<TranslateId, 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 0000000000..0cfd39a233 --- /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 OUString& 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 0000000000..1b2bbadd99 --- /dev/null +++ b/include/sfx2/tabdlg.hxx @@ -0,0 +1,289 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <unordered_map> +#include <string_view> + +#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 <svl/setitem.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 WhichRangesContainer (*GetTabPageRanges)(); // provides international Which-value +struct TabPageImpl; + +struct TabDlg_Impl; + +namespace com::sun::star::frame { class XFrame; } + +#define RET_USER 100 +#define RET_USER_CANCEL 101 + +class SFX2_DLLPUBLIC SfxTabDialogItem final : public SfxSetItem +{ +public: + SfxTabDialogItem( sal_uInt16 nId, const SfxItemSet& rItemSet ); + SfxTabDialogItem(const SfxTabDialogItem& rAttr, SfxItemPool* pItemPool); + virtual SfxTabDialogItem* Clone(SfxItemPool* pToPool = nullptr) const override; +}; + +class SFX2_DLLPUBLIC SfxTabDialogController : public SfxOkDialogController +{ +protected: + std::unique_ptr<weld::Notebook> m_xTabCtrl; + + DECL_LINK(OkHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(ResetHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(BaseFmtHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(UserHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(CancelHdl, weld::Button&, void); +private: + std::unique_ptr<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; + WhichRangesContainer m_pRanges; + OUString m_sAppPageId; + bool m_bStandardPushed; + std::unique_ptr<SfxAllItemSet> m_xItemSet; + + DECL_DLLPRIVATE_LINK(ActivatePageHdl, const OUString&, void); + DECL_DLLPRIVATE_LINK(DeactivatePageHdl, const OUString&, 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 OUString& rName); + virtual void PageCreated(const OUString &rName, SfxTabPage &rPage); + + virtual void ActivatePage(const OUString& rPage); + bool DeactivatePage(std::u16string_view aPage); + + std::unique_ptr<SfxItemSet> m_xExampleSet; + SfxItemSet* GetInputSetImpl(); + SfxTabPage* GetTabPage(std::u16string_view rPageId) const; + + /** prepare to leave the current page. Calls the DeactivatePage method of the current page, (if necessary), + handles the item sets to copy. + @return sal_True if it is allowed to leave the current page, sal_False otherwise + */ + bool PrepareLeaveCurrentPage(); + + /** save the position of the TabDialog and which tab page is the currently active one + */ + void SavePosAndId(); +public: + SfxTabDialogController(weld::Widget* pParent, const OUString& rUIXMLDescription, const OUString& rID, + const SfxItemSet * = nullptr, bool bEditFmt = false); + virtual ~SfxTabDialogController() override; + + void AddTabPage(const OUString& rName, // Name of the label for the existing page in the notebook .ui + CreateTabPage pCreateFunc, // != 0 + GetTabPageRanges pRangesFunc); // can be 0 + + void AddTabPage(const OUString& 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 OUString& 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 OUString& 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 OUString& rName ); // Name of the label for the page in the notebook .ui + + void SetCurPageId(const OUString& rName); + void ShowPage(const OUString& rName); // SetCurPageId + call Activate on it + OUString GetCurPageId() const; + SfxTabPage* GetCurTabPage() const { return GetTabPage(GetCurPageId()); } + + // may provide local slots converted by Map + const WhichRangesContainer& GetInputRanges( const SfxItemPool& ); + void SetInputSet( const SfxItemSet* pInSet ); + const SfxItemSet* GetOutputItemSet() const { return m_pOutSet.get(); } + const SfxItemSet* GetInputItemSet() const { return m_pSet.get(); } + + virtual weld::Button& GetOKButton() const override { return *m_xOKBtn; } + weld::Button& GetCancelButton() const { return *m_xCancelBtn; } + weld::Button* GetUserButton() const { return m_xUserBtn.get(); } + weld::Button* GetStandardButton() const { return m_xBaseFmtBtn.get(); } + weld::Button* GetApplyButton() const { return m_xApplyBtn.get(); } + weld::Button* GetResetButton() const { return m_xResetBtn.get(); } + void RemoveResetButton(); + void RemoveStandardButton(); + + virtual short run() override; + static bool runAsync(const std::shared_ptr<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<OUString> getAllPageUIXMLDescriptions() const; + bool selectPageByUIXMLDescription(const OUString& rUIXMLDescription); + BitmapEx createScreenshot() const; + OUString 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* mpSet; + OUString maUserString; + bool mbHasExchangeSupport; + std::unordered_map<OUString, css::uno::Any> maAdditionalProperties; + + std::unique_ptr<TabPageImpl> mpImpl; + +protected: + SfxTabPage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OUString& rID, const SfxItemSet *rAttrSet); + + sal_uInt16 GetWhich( sal_uInt16 nSlot, bool bDeep = true ) const + { + return mpSet->GetPool()->GetWhich(nSlot, bDeep); + } + template<class T> + TypedWhichId<T> GetWhich( TypedWhichId<T> nSlot, bool bDeep = true ) const + { + return TypedWhichId<T>(GetWhich(sal_uInt16(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 *mpSet; + } + + virtual bool FillItemSet( SfxItemSet* ); + virtual void Reset( const SfxItemSet* ); + // Allows to postpone some initialization to the first activation + virtual bool DeferResetToFirstActivation(); + + bool HasExchangeSupport() const + { + return mbHasExchangeSupport; + } + + void SetExchangeSupport() + { + mbHasExchangeSupport = true; + } + + virtual void ActivatePage( const SfxItemSet& ); + virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ); + void SetUserData(const OUString& rString) + { + maUserString = rString; + } + const OUString& GetUserData() const + { + return maUserString; + } + 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)); + } + + virtual OUString GetAllStrings(); + void SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame); + css::uno::Reference< css::frame::XFrame > GetFrame() const; + + const SfxItemSet* GetDialogExampleSet() const; + + OUString GetHelpId() const; + OUString GetConfigId() const { return GetHelpId(); } + bool IsVisible() const { return m_xContainer->get_visible(); } + + weld::Window* GetFrameWeld() const; + + std::unordered_map<OUString, css::uno::Any>& getAdditionalProperties() + { + return maAdditionalProperties; + } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/tbxctrl.hxx b/include/sfx2/tbxctrl.hxx new file mode 100644 index 0000000000..d513c0807b --- /dev/null +++ b/include/sfx2/tbxctrl.hxx @@ -0,0 +1,141 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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/vclptr.hxx> + +namespace com::sun::star::frame { class XDispatchProvider; } +namespace com::sun::star::frame { class XFrame; } +namespace vcl { class Window; } + +class InterimItemWindow; +class SfxToolBoxControl; +class SfxModule; + +rtl::Reference<svt::ToolboxController> SfxToolBoxControllerFactory( const css::uno::Reference< css::frame::XFrame >& rFrame, ToolBox* pToolbox, ToolBoxItemId nID, const OUString& aCommandURL ); + +typedef rtl::Reference<SfxToolBoxControl> (*SfxToolBoxControlCtor)( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rBox ); + +struct SfxTbxCtrlFactory +{ + SfxToolBoxControlCtor pCtor; + const std::type_info& nTypeId; + sal_uInt16 nSlotId; + + SfxTbxCtrlFactory( SfxToolBoxControlCtor pTheCtor, + const std::type_info& nTheTypeId, sal_uInt16 nTheSlotId ): + pCtor(pTheCtor), + nTypeId(nTheTypeId), + nSlotId(nTheSlotId) + {} +}; + + +#define SFX_DECL_TOOLBOX_CONTROL() \ + static rtl::Reference<SfxToolBoxControl> CreateImpl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx ); \ + static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=nullptr) + +/* For special ToolBox controls, such as a font selection box or toolbox + tear-off floating windows, an appropriate Item-Subclass of SfxTooBoxControl + has to be implemented. + + This class has to be registered in SfxApplication:Init() with the static + control method RegisterControl(). The SFx then automatically creates these + controls in the toolbox, if the associated slots are of the specific type. + */ + +struct SfxToolBoxControl_Impl; +class SFX2_DLLPUBLIC SfxToolBoxControl: public svt::ToolboxController +{ +friend struct SfxTbxCtrlFactory; + + std::unique_ptr< SfxToolBoxControl_Impl> pImpl; + +protected: + // old SfxToolBoxControl methods + virtual void StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ); + virtual void Select( sal_uInt16 nSelectModifier ); + + virtual void DoubleClick(); + virtual void Click(); + virtual void CreatePopupWindow(); + virtual VclPtr<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, ToolBoxItemId nId, ToolBox& rBox, bool bShowStrings = false ); + virtual ~SfxToolBoxControl() override; + + ToolBox& GetToolBox() const; + ToolBoxItemId GetId() const; + unsigned short GetSlotId() const; + + void Dispatch( const OUString& aCommand, + css::uno::Sequence< css::beans::PropertyValue > const & aArgs ); + static void Dispatch( const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider, + const OUString& rCommand, + css::uno::Sequence< css::beans::PropertyValue > const & aArgs ); + + static SfxItemState GetItemState( const SfxPoolItem* pState ); + static rtl::Reference<SfxToolBoxControl> CreateControl( sal_uInt16 nSlotId, ToolBoxItemId nTbxId, ToolBox *pBox, SfxModule const *pMod ); + static void RegisterToolBoxControl( SfxModule*, const SfxTbxCtrlFactory&); +}; + +#define SFX_IMPL_TOOLBOX_CONTROL(Class, nItemClass) \ + rtl::Reference<SfxToolBoxControl> Class::CreateImpl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx ) \ + { return new Class( nSlotId, nId, rTbx ); } \ + void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \ + { SfxToolBoxControl::RegisterToolBoxControl( pMod, SfxTbxCtrlFactory( \ + Class::CreateImpl, typeid(nItemClass), nSlotId ) ); } + +#define SFX_IMPL_TOOLBOX_CONTROL_ARG(Class, nItemClass, Arg) \ + rtl::Reference<SfxToolBoxControl> Class::CreateImpl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx ) \ + { return new Class( nSlotId, nId, rTbx, Arg); } \ + void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \ + { SfxToolBoxControl::RegisterToolBoxControl( pMod, SfxTbxCtrlFactory( \ + Class::CreateImpl, typeid(nItemClass), nSlotId ) ); } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/templatedlg.hxx b/include/sfx2/templatedlg.hxx new file mode 100644 index 0000000000..5aea4ec82a --- /dev/null +++ b/include/sfx2/templatedlg.hxx @@ -0,0 +1,190 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <string_view> + +#include <vcl/idle.hxx> +#include <vcl/timer.hxx> +#include <vcl/weld.hxx> + +#include <sfx2/templatedlglocalview.hxx> + +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); + void setTemplateViewMode(TemplateViewMode eViewMode); + TemplateViewMode getTemplateViewMode() const; + +protected: + void getApplicationSpecificSettings(); + + void readSettings(); + + void writeSettings(); + + void fillFolderComboBox(); + + DECL_DLLPRIVATE_LINK(SelectApplicationHdl, weld::ComboBox&, void); + DECL_DLLPRIVATE_LINK(SelectRegionHdl, weld::ComboBox&, void); + + DECL_DLLPRIVATE_LINK(OkClickHdl, weld::Button&, void); + void ImportActionHdl(); + static void ExtensionsActionHdl(); + + DECL_DLLPRIVATE_LINK(TVItemStateHdl, const ThumbnailViewItem*, void); + + DECL_DLLPRIVATE_LINK(MenuSelectHdl, const OUString&, void); + void DefaultTemplateMenuSelectHdl(std::u16string_view rIdent); + + DECL_DLLPRIVATE_LINK(OpenRegionHdl, void*, void); + DECL_DLLPRIVATE_LINK(CreateContextMenuHdl, ThumbnailViewItem*, void); + DECL_DLLPRIVATE_LINK(OpenTemplateHdl, ThumbnailViewItem*, void); + DECL_DLLPRIVATE_LINK(EditTemplateHdl, ThumbnailViewItem*, void); + DECL_DLLPRIVATE_LINK(DeleteTemplateHdl, void*, void); + DECL_DLLPRIVATE_LINK(DefaultTemplateHdl, ThumbnailViewItem*, void); + DECL_DLLPRIVATE_LINK(MoveTemplateHdl, void*, void); + DECL_DLLPRIVATE_LINK(ExportTemplateHdl, void*, void); + + void SearchUpdate(); + + DECL_DLLPRIVATE_LINK(SearchUpdateHdl, weld::Entry&, void); + DECL_DLLPRIVATE_LINK(GetFocusHdl, weld::Widget&, void); + DECL_DLLPRIVATE_LINK(LoseFocusHdl, weld::Widget&, void); + DECL_DLLPRIVATE_LINK(ImplUpdateDataHdl, Timer*, void); + DECL_DLLPRIVATE_LINK(KeyInputHdl, const KeyEvent&, bool); + + DECL_DLLPRIVATE_LINK(ListViewHdl, weld::Toggleable&, void); + DECL_DLLPRIVATE_LINK(ThumbnailViewHdl, weld::Toggleable&, void); + DECL_DLLPRIVATE_LINK(FocusRectLocalHdl, weld::Widget&, tools::Rectangle); + + void OnTemplateImportCategory(std::u16string_view sCategory); + // static void OnTemplateLink (); + void OnTemplateOpen(); + void OnTemplateExport(); + + void OnTemplateState(const ThumbnailViewItem* pItem); + + void OnCategoryNew(); + void OnCategoryRename(); + void OnCategoryDelete(); + + void updateMenuItems(); + + /** + * + * Move templates stored in the filesystem to another folder. + * + **/ + + void localMoveTo(sal_uInt16 nMenuId); + + /// Return filter according to the currently selected application filter. + FILTER_APPLICATION getCurrentApplicationFilter() const; + +protected: + std::set<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::CheckButton> mxCBXHideDlg; + std::unique_ptr<weld::MenuButton> mxActionBar; + std::unique_ptr<TemplateDlgLocalView> mxLocalView; + std::unique_ptr<weld::CustomWeld> mxLocalViewWeld; + std::unique_ptr<weld::Toggleable> mxListViewButton; + std::unique_ptr<weld::Toggleable> mxThumbnailViewButton; + TemplateViewMode mViewMode; + bool bMakeSelItemVisible; +}; + +// class SfxTemplateCategoryDialog ------------------------------------------------------------------- + +class SfxTemplateCategoryDialog final : public weld::GenericDialogController +{ +private: + OUString msSelectedCategory; + bool mbIsNewCategory; + + std::unique_ptr<weld::TreeView> mxLBCategory; + std::unique_ptr<weld::Entry> mxNewCategoryEdit; + 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); + + const OUString& GetSelectedCategory() const { return msSelectedCategory; }; + + bool IsNewCategoryCreated() const { return mbIsNewCategory; } + +public: + explicit SfxTemplateCategoryDialog(weld::Window* pParent); + + virtual ~SfxTemplateCategoryDialog() override; +}; + +// class SfxTemplateSelectionDialog ------------------------------------------------------------------- + +class SFX2_DLLPUBLIC SfxTemplateSelectionDlg final : public SfxTemplateManagerDlg +{ +public: + SfxTemplateSelectionDlg(weld::Window* parent); + + virtual ~SfxTemplateSelectionDlg() override; + virtual short run() override; + + OUString const& getTemplatePath() const { return msTemplatePath; }; + bool IsStartWithTemplate() const { return mxCBXHideDlg->get_active(); }; + +private: + DECL_DLLPRIVATE_LINK(OpenTemplateHdl, ThumbnailViewItem*, void); + DECL_DLLPRIVATE_LINK(OkClickHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(TimeOut, Timer*, void); + + OUString msTemplatePath; + Idle maIdle; +}; + +#endif // INCLUDED_SFX2_INC_TEMPLATEDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/templatedlglocalview.hxx b/include/sfx2/templatedlglocalview.hxx new file mode 100644 index 0000000000..2d035c2cfe --- /dev/null +++ b/include/sfx2/templatedlglocalview.hxx @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#pragma once + +#include <sfx2/templatelocalview.hxx> +#include <sfx2/listview.hxx> + +class TemplateDlgLocalView final : public TemplateLocalView, public ListView +{ +public: + TemplateDlgLocalView(std::unique_ptr<weld::ScrolledWindow> xWindow, + std::unique_ptr<weld::Menu> xMenu, + std::unique_ptr<weld::TreeView> xTreeView); + + void setTemplateViewMode(TemplateViewMode eMode); + + virtual void showAllTemplates() override; + + void showRegion(TemplateContainerItem const* pItem); + + void showRegion(std::u16string_view rName); + + void reload(); + + virtual bool KeyInput(const KeyEvent& rKEvt) override; + + void createContextMenu(const bool bIsDefault, const bool bIsBuiltIn, const bool bIsSingleSel, + const OUString& rDefaultImg); + + virtual void Show() override; + + virtual void Hide() override; + + bool IsVisible() const; + + void connect_focus_rect(const Link<weld::Widget&, tools::Rectangle>& rLink) + { + GetDrawingArea()->connect_focus_rect(rLink); + } + + void MakeItemVisible(sal_uInt16 nId) { ThumbnailView::MakeItemVisible(nId); } + + void insertItems(const std::vector<TemplateItemProperties>& rTemplates, bool isRegionSelected, + bool bShowCategoryInTooltip); + +private: + void ContextMenuSelectHdl(std::u16string_view rIdent); + + void insertFilteredItems(); + + void syncCursor(); + + void updateSelection(); + + DECL_LINK(RowActivatedHdl, weld::TreeView&, bool); + + DECL_LINK(ListViewChangedHdl, weld::TreeView&, void); + + DECL_LINK(PopupMenuHdl, const CommandEvent&, bool); + + DECL_LINK(KeyPressHdl, const KeyEvent&, bool); + + TemplateViewMode mViewMode; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/templatelocalview.hxx b/include/sfx2/templatelocalview.hxx new file mode 100644 index 0000000000..9d44e54d7c --- /dev/null +++ b/include/sfx2/templatelocalview.hxx @@ -0,0 +1,192 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SFX2_TEMPLATELOCALVIEW_HXX +#define INCLUDED_SFX2_TEMPLATELOCALVIEW_HXX + +#include <sfx2/thumbnailview.hxx> +#include <sfx2/templateproperties.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, std::u16string_view rExt); + bool isValid (std::u16string_view rPath) const; + +private: + + FILTER_APPLICATION mApp; +}; + +class TemplateLocalView : public ThumbnailView +{ + typedef bool (*selection_cmp_fn)(const ThumbnailViewItem*,const ThumbnailViewItem*); + +public: + + TemplateLocalView(std::unique_ptr<weld::ScrolledWindow> xWindow, + std::unique_ptr<weld::Menu> xMenu); + + virtual ~TemplateLocalView () 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 (); + + virtual void showAllTemplates (); + + void showRegion (TemplateContainerItem const *pItem); + + void ContextMenuSelectHdl(std::u16string_view rIdent); + + TemplateContainerItem* getRegion(std::u16string_view sStr); + + sal_uInt16 getRegionId (size_t pos) const; + + sal_uInt16 getRegionId (std::u16string_view sRegionName) const; + + OUString getRegionName(const sal_uInt16 nRegionId) const; + + OUString getRegionItemName(const sal_uInt16 nItemId) const; + + std::vector<OUString> getFolderNames (); + + std::vector<TemplateItemProperties> + getFilteredItems (const std::function<bool (const TemplateItemProperties&) > &rFunc) const; + + sal_uInt16 createRegion (const OUString &rName); + + bool renameRegion(std::u16string_view rTitle, const OUString &rNewTitle); + + bool removeRegion (const sal_uInt16 nItemId); + + bool removeTemplate (const sal_uInt16 nItemId, const sal_uInt16 nSrcItemId); + + void moveTemplates (const std::set<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, std::u16string_view rName); + + virtual bool renameItem(ThumbnailViewItem* pItem, const OUString& sNewTitle) override; + + virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; + + virtual bool Command(const CommandEvent& rPos) override; + + virtual bool KeyInput( const KeyEvent& rKEvt ) override; + + sal_uInt16 getCurRegionId () const { return mnCurRegionId;} + + void setCurRegionId (sal_uInt16 nCurRegionId) { mnCurRegionId = nCurRegionId;} + + void setOpenRegionHdl(const Link<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<void*,void> &rLink); + + void setDefaultTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink); + + void setMoveTemplateHdl(const Link<void*,void> &rLink); + + void setExportTemplateHdl(const Link<void*,void> &rLink); + + void updateThumbnailDimensions(tools::Long itemMaxSize); + + void RemoveDefaultTemplateIcon( std::u16string_view rPath); + + bool IsBuiltInRegion(const OUString& rRegionName); + + static BitmapEx scaleImg (const BitmapEx &rImg, tools::Long width, tools::Long height); + + static BitmapEx getDefaultThumbnail( std::u16string_view rPath ); + + static BitmapEx fetchThumbnail (const OUString &msURL, tools::Long width, tools::Long height); + + static bool IsDefaultTemplate(const OUString& rPath); + + static bool IsInternalTemplate(const OUString& rPath); + +protected: + virtual void OnItemDblClicked(ThumbnailViewItem *pItem) override; + + sal_uInt16 mnCurRegionId; + + TemplateViewItem *maSelectedItem; + + tools::Long mnThumbnailWidth; + tools::Long mnThumbnailHeight; + + Point maPosition; //store the point of click event + + Link<void*,void> maOpenRegionHdl; + Link<ThumbnailViewItem*,void> maCreateContextMenuHdl; + Link<ThumbnailViewItem*,void> maOpenTemplateHdl; + Link<ThumbnailViewItem*,void> maEditTemplateHdl; + Link<void*,void> maDeleteTemplateHdl; + Link<ThumbnailViewItem*,void> maDefaultTemplateHdl; + Link<void*,void> maMoveTemplateHdl; + Link<void*,void> maExportTemplateHdl; + + 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 0000000000..2c1de01257 --- /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 0000000000..254fcc790f --- /dev/null +++ b/include/sfx2/templdlg.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_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> +#include <sfx2/sidebar/ControllerItem.hxx> + +class SfxBindings; +class SfxTemplateDialog_Impl; + +class UNLESS_MERGELIBS(SFX2_DLLPUBLIC) SfxTemplatePanelControl final + : public PanelLayout, + public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface +{ +public: + SfxTemplatePanelControl(SfxBindings* pBindings, weld::Widget* pParent); + virtual ~SfxTemplatePanelControl() override; + + weld::Builder* get_builder() { return m_xBuilder.get(); } + weld::Container* get_container() { return m_xContainer.get(); } + + virtual void NotifyItemUpdate(const sal_uInt16 nSId, const SfxItemState eState, + const SfxPoolItem* pState) override; + + virtual void GetControlState(const sal_uInt16 /*nSId*/, + boost::property_tree::ptree& /*rState*/) override{}; + +private: + ::sfx2::sidebar::ControllerItem m_aSpotlightParaStyles; + ::sfx2::sidebar::ControllerItem m_aSpotlightCharStyles; + + 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 0000000000..54e8440ad3 --- /dev/null +++ b/include/sfx2/thumbnailview.hxx @@ -0,0 +1,330 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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/customweld.hxx> + +class BitmapEx; +class MouseEvent; +class KeyEvent; +class DataChangedEvent; +class ScrollBar; +class ThumbnailViewItem; +typedef ::std::vector< ThumbnailViewItem* > ThumbnailValueItemList; +class ThumbnailViewAcc; +struct ThumbnailItemAttributes; + +/************************************************************************* + + Description + ============ + + class ThumbnailView + + This class allows the selection of an item. In the process items are + drawn side by side. The selection of items can be more clear than in a + ListBox shape for example in case of colors or samples. + The amount of columns drawn by the control and whether the items + should be encircled can be specified. Optional a NoSelection or name + field could be shown. By default image and color items are supported. + Items could be drawn by oneself if InsertItem() is only called with + an ID. To achieve this the UserDraw handler needs to be overridden. The + description text could be specified afterwards in case of UserDraw + and any other items. + + Cross references + + class ListBox + + -------------------------------------------------------------------------- + + WinBits + + WB_VSCROLL A scrollbar will be always shown. The visible number of + lines have to be specified with SetLineCount() if this + flag is set. + WB_TABSTOP It is possible to jump into the ValueSet with the tab key. + WB_NOTABSTOP It is not possible to jump into the ValueSet with the + tab key. + -------------------------------------------------------------------------- + + The number of columns must be either set with SetColCount() or + SetItemWidth(). If the number of columns is specified by SetColCount() + the width of the items will be calculated by the visible range. + If the items should have a static width, it has to be specified + with SetItemWidth(). In this case the number of columns will be calculated + by the visible range. + + The number of rows is given by the number of items / number of columns. The + number of visible rows must either specified by SetLineCount() or + SetItemWidth(). If the number of visible rows is specified by SetLineCount(), + the height of the items will be calculated from the visible height. If the + items should have a fixed height it has to be specified with SetItemHeight(). + In this case the number of visible rows is then calculated from the visible + height. If the number of visible rows is neither specified by SetLineCount() + nor by SetItemHeight() all rows will be shown. The height of the items will + be calculated by the visible height. If the number of visible rows is + specified by SetLineCount() or SetItemHeight() ValueSet does scroll + automatically when more lines are available, as are visible. If scrolling + should be also possible with a ScrollBar WB_VSCROLL needs to be set. + + The distance between the items can be increased by SetExtraSpacing(). The + distance, which will be shown between two items (both in x and in y), is + measured in pixels. + + The exact window size for a specific item size can be calculated by + CalcWindowSizePixel(). To do this all relevant data (number of columns/...) + have to be specified and if no number of rows was set, all items need to + be inserted. If the window was created with WB_BORDER/Border=sal_True the + size has to be specified with SetOutputSizePixel(). In other cases different + size-methods can be used. With CalcItemSize() the inner and outer size of + an item could be calculated (for this the free space defined by + SetExtraSpacing() will not be included). + + The background color could be specified by SetColor(), with which the image + or UserDraw items will be underlaid. If no color is specified the color + of other windows (WindowColor) will be used for the background. + + -------------------------------------------------------------------------- + + At first all items should be inserted and only then Show() should be called + since the output area will be precomputed. If this is not done the first + Paint will appear a little bit slower. Therefore the Control, if it is loaded + from the resource and only supplied with items during runtime, should be + loaded with Hide = sal_True and then displayed with Show(). + + In case of a visible Control the creation of the new output area could be + activated before Paint by calling Format(). + + -------------------------------------------------------------------------- + + If Drag and Drop will be called from the ValueSet the Command-Handler has to + be overridden. From this StartDrag needs to be called. If this method returns + sal_True the drag-process could be initiated by ExecuteDrag(), otherwise no + processing will take place. This method makes sure that ValueSet stops its + processing and as appropriate selects the entry. Therefore the calling of + Select-Handler within this function must be expected. + + For dropping QueryDrop() and Drop() need to be overridden and ShowDropPos() + and HideDropPos() should be called within these methods. + To show the insertion point ShowDropPos() has to be called within the + QueryDrop-Handler. ShowDropPos() also scrolls the ValueSet if the passed + position is located at the window border. Furthermore ShowDropPos() returns + the position, at which the item should be inserted respectively which + insertion point was shown. If no insertion point was determined + VALUESET_ITEM_NOTFOUND will be returned. If the window was left during dragging + or the drag process is terminated HideDropPos() should be called in any case. + + -------------------------------------------------------------------------- + + This class is currently still in the SV-Tools. That's why the ValueSet needs + to be loaded as a Control out of the resource and the desired WinBits have + to be set (before Show) with SetStyle(). + +*************************************************************************/ + +/* ThumbnailView types */ + +#define THUMBNAILVIEW_ITEM_NOTFOUND (sal_uInt16(-1)) + +// Display all the available items in the thumbnail. +class ViewFilterAll +{ +public: + + bool operator () (const ThumbnailViewItem*) const + { + return true; + } +}; + +/** + * + * Class to display thumbnails with their names below their respective icons + * + **/ + +class SFX2_DLLPUBLIC ThumbnailView : public weld::CustomWidgetController +{ + friend class ThumbnailViewAcc; + friend class ThumbnailViewItemAcc; + +public: + ThumbnailView(std::unique_ptr<weld::ScrolledWindow> xWindow, std::unique_ptr<weld::Menu> xMenu); + + virtual ~ThumbnailView() override; + + ThumbnailView& operator=( ThumbnailView const & ) = delete; // MSVC workaround + ThumbnailView( ThumbnailView const & ) = delete; // MSVC workaround + + virtual bool MouseMove(const MouseEvent& rMEvt) override; + + /// Updates information in the view; used only in RecentDocsView ATM. + virtual void Reload() {} + + void AppendItem(std::unique_ptr<ThumbnailViewItem> pItem); + + void RemoveItem(sal_uInt16 nItemId); + + virtual void Clear(); + + // Change current thumbnail item list with new one (invalidates all pointers to a thumbnail item) + void updateItems(std::vector<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; + + virtual bool renameItem(ThumbnailViewItem* pItem, const OUString& sNewTitle); + + bool isDrawMnemonic() const { return mbDrawMnemonics; } + + void setItemMaxTextLength (sal_uInt32 nLength); + + void setItemDimensions (tools::Long ItemWidth, tools::Long ThumbnailHeight, + tools::Long DisplayHeight, int itemPadding); + + void SelectItem( sal_uInt16 nItemId ); + + bool IsItemSelected( sal_uInt16 nItemId ) const; + + /** + * + * @brief deselect all current selected items. + * + **/ + + void deselectItems (); + + void ShowTooltips( bool bShowTooltips ); + + void DrawMnemonics( bool bDrawMnemonics ); + + void filterItems (const std::function<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; + + static BitmapEx readThumbnail(const OUString &msURL); + +protected: + + virtual bool KeyInput( const KeyEvent& rKEvt ) override; + + virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; + + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + + virtual void GetFocus() override; + + virtual void LoseFocus() override; + + virtual OUString RequestHelp(tools::Rectangle& rRect) override; + + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; + + const rtl::Reference<ThumbnailViewAcc> & getAccessible() const; + +protected: + + // Drawing item related functions, override them to make your own custom ones. + + void DrawItem (ThumbnailViewItem const *pItem); + + virtual void OnItemDblClicked (ThumbnailViewItem *pItem); + + // Set Item colors from the ThumbnailView colors + void UpdateColors(); + +protected: + + friend class ThumbnailViewAcc; + friend class ThumbnailViewItemAcc; + + void CalculateItemPositions (bool bScrollBarUsed = false); + void MakeItemVisible( sal_uInt16 nId ); + + void ImplInit(); + + void ImplDeleteItems(); + size_t ImplGetItem( const Point& rPoint ) const; + ThumbnailViewItem* ImplGetItem( size_t nPos ); + sal_uInt16 ImplGetVisibleItemCount() const; + ThumbnailViewItem* ImplGetVisibleItem(sal_uInt16 nVisiblePos); + void ImplFireAccessibleEvent( short nEventId, const css::uno::Any& rOldValue, const css::uno::Any& rNewValue ); + bool ImplHasAccessibleListeners() const; + DECL_DLLPRIVATE_LINK( ImplScrollHdl, weld::ScrolledWindow&, void ); + +protected: + + std::vector< std::unique_ptr<ThumbnailViewItem> > mItemList; + rtl::Reference<ThumbnailViewAcc> mxAccessible; + ThumbnailValueItemList mFilteredItemList; ///< Cache to store the filtered items + ThumbnailValueItemList::iterator mpStartSelRange; + tools::Long mnItemWidth; + tools::Long mnItemHeight; + tools::Long mnItemPadding; + tools::Long mnThumbnailHeight; // Maximum height of the thumbnail + tools::Long mnDisplayHeight; // Height of the data display box (name, etc) + tools::Long mnVItemSpace; // Vertical spacing between rows, -1 to use excess unused height split up between items + tools::Long mnVisLines; + tools::Long mnLines; + + sal_uInt16 mnCols; + sal_uInt16 mnFirstLine; + bool mbScroll : 1; // Whether we need to scroll + bool mbAllowVScrollBar : 1; // Whether to show a visible scrollbar + bool mbHasVisibleItems : 1; + bool mbShowTooltips : 1; + bool mbDrawMnemonics : 1; + bool mbSelectOnFocus : 1; + bool mbAllowMultiSelection : 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. + 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/thumbnailviewitem.hxx b/include/sfx2/thumbnailviewitem.hxx new file mode 100644 index 0000000000..22020c4772 --- /dev/null +++ b/include/sfx2/thumbnailviewitem.hxx @@ -0,0 +1,141 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <basegfx/vector/b2dvector.hxx> +#include <drawinglayer/attribute/fontattribute.hxx> +#include <vcl/bitmapex.hxx> +#include <sfx2/dllapi.h> +#include <rtl/ref.hxx> + +namespace com::sun::star::accessibility { class XAccessible; } +namespace drawinglayer::primitive2d { class Primitive2DContainer; } +class ThumbnailViewItemAcc; + +#define THUMBNAILVIEW_ITEM_NONEITEM 0xFFFE + +const int THUMBNAILVIEW_ITEM_CORNER = 5; + +class ThumbnailView; +class MouseEvent; + +namespace basegfx { + class B2DPolygon; +} + +namespace drawinglayer { + namespace processor2d { + class BaseProcessor2D; + } + namespace primitive2d { + class PolygonHairlinePrimitive2D; + } +} + +struct ThumbnailItemAttributes +{ + sal_uInt32 nMaxTextLength; + basegfx::BColor aFillColor; + basegfx::BColor aTextColor; + basegfx::BColor aHighlightColor; + basegfx::BColor aHighlightTextColor; + double fHighlightTransparence; + basegfx::B2DVector aFontSize; + drawinglayer::attribute::FontAttribute aFontAttr; +}; + +class SFX2_DLLPUBLIC ThumbnailViewItem +{ +public: + + ThumbnailView& mrParent; + sal_uInt16 mnId; + bool mbVisible; + bool mbBorder; + bool mbSelected; + bool mbHover; + BitmapEx maPreview1; + OUString maTitle; + OUString maHelpText; + rtl::Reference< ThumbnailViewItemAcc > mxAcc; + + ThumbnailViewItem(ThumbnailView& rView, sal_uInt16 nId); + + virtual ~ThumbnailViewItem (); + + ThumbnailViewItem& operator=( ThumbnailViewItem const & ) = delete; // MSVC workaround + ThumbnailViewItem( ThumbnailViewItem const & ) = delete; // MSVC workaround + + bool isVisible () const { return mbVisible; } + + void show (bool bVisible); + + bool isSelected () const { return mbSelected; } + + void setSelection (bool state); + + bool isHighlighted () const { return mbHover; } + + void setHighlight (bool state); + + /** Updates own highlight status based on the aPoint position. + + Returns rectangle that needs to be invalidated. + */ + virtual tools::Rectangle updateHighlight(bool bVisible, const Point& rPoint); + + /// Text to be used for the tooltip. + + void setHelpText (const OUString &sText) { maHelpText = sText; } + + virtual OUString getHelpText() const { return maHelpText; }; + OUString const & getTitle() const { return maTitle; }; + + void setTitle (const OUString& rTitle); + + rtl::Reference< ThumbnailViewItemAcc > const & + GetAccessible( bool bIsTransientChildrenDisabled ); + + void setDrawArea (const tools::Rectangle &area); + + const tools::Rectangle& getDrawArea () const { return maDrawArea; } + + void calculateItemsPosition (const tools::Long nThumbnailHeight, + const tools::Long nPadding, sal_uInt32 nMaxTextLength, + const ThumbnailItemAttributes *pAttrs); + + virtual void Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor, + const ThumbnailItemAttributes *pAttrs); + void addTextPrimitives (const OUString& rText, const ThumbnailItemAttributes *pAttrs, Point aPos, drawinglayer::primitive2d::Primitive2DContainer& rSeq); + + static rtl::Reference<drawinglayer::primitive2d::PolygonHairlinePrimitive2D> + createBorderLine (const basegfx::B2DPolygon &rPolygon); + + virtual void MouseButtonUp(const MouseEvent&) {} + +protected: + + Point maTextPos; + Point maPrev1Pos; + Point maPinPos; + tools::Rectangle maDrawArea; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/toolbarids.hxx b/include/sfx2/toolbarids.hxx new file mode 100644 index 0000000000..1aedb4eda3 --- /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 0000000000..d367daa8bb --- /dev/null +++ b/include/sfx2/tplpitem.hxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_TPLPITEM_HXX +#define INCLUDED_SFX2_TPLPITEM_HXX + +#include <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; + OUString aStyleIdentifier; +public: + static SfxPoolItem* CreateDefault(); + SfxTemplateItem(); + SfxTemplateItem( sal_uInt16 nWhich, + OUString aStyle, + OUString aStyleIdentifier = "" ); + + const OUString& GetStyleName() const { return aStyle; } + const OUString& GetStyleIdentifier() const { return aStyleIdentifier; } + + virtual SfxTemplateItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool operator==( const SfxPoolItem& ) const override; + virtual sal_uInt8 GetFlagCount() const override; + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; + SfxStyleSearchBits GetValue() const { return static_cast<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 0000000000..f948579785 --- /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 0000000000..c09791216f --- /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& rViewFrame, 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 0000000000..7e038e9d6b --- /dev/null +++ b/include/sfx2/viewfrm.hxx @@ -0,0 +1,283 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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> + +namespace weld { + class Button; + class Window; +} +class SvBorder; +class SfxDispatcher; +class SfxBindings; +class SfxProgress; +class SfxViewShell; +class Point; +class Size; +class SfxChildWindow; +class SfxInfoBarWindow; +enum class InfobarType; +class CommandPopupHandler; + +class SFX2_DLLPUBLIC SfxViewFrame final : public SfxShell, public SfxListener +{ + std::unique_ptr<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; + + std::unique_ptr<CommandPopupHandler> m_pCommandPopupHandler; + + SAL_DLLPRIVATE void Construct_Impl( SfxObjectShell *pObjSh ); + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + DECL_DLLPRIVATE_LINK(GetInvolvedHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(DonationHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(WhatsNewHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(MacroButtonHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(SecurityButtonHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(EventButtonHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(SwitchReadOnlyHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(SignDocumentHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(HiddenTrackChangesHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(HyphenationMissingHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(RefreshMasterPasswordHdl, weld::Button&, void); + DECL_DLLPRIVATE_STATIC_LINK(SfxViewFrame, HelpMasterPasswordHdl, weld::Button&, void); + SAL_DLLPRIVATE void KillDispatcher_Impl(); + + virtual ~SfxViewFrame() override; + +public: + SfxViewFrame( SfxFrame& rFrame, SfxObjectShell *pDoc ); + + SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWFRM) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + + void AppendContainsMacrosInfobar(); +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 ); + + SAL_WARN_UNUSED_RESULT static SfxViewFrame* Current(); + SAL_WARN_UNUSED_RESULT static SfxViewFrame* GetFirst( const SfxObjectShell* pDoc = nullptr, bool bOnlyVisible = true ); + SAL_WARN_UNUSED_RESULT static SfxViewFrame* GetNext( const SfxViewFrame& rPrev, const SfxObjectShell* pDoc = nullptr, bool bOnlyVisible = true ); + + SAL_WARN_UNUSED_RESULT static SfxViewFrame* Get( const css::uno::Reference< css::frame::XController>& i_rController, const SfxObjectShell* i_pDoc ); + + void DoActivate(bool bMDI); + void DoDeactivate(bool bMDI, SfxViewFrame const *pOld); + + using SfxShell::GetDispatcher; + SfxDispatcher* GetDispatcher() { return m_pDispatcher.get(); } + SfxBindings& GetBindings() { return *m_pBindings; } + const SfxBindings& GetBindings() const { return *m_pBindings; } + vcl::Window& GetWindow() const; + weld::Window* GetFrameWeld() const; + + SfxProgress* GetProgress() const; + + void LockAdjustPosSizePixel() + { m_nAdjustPosPixelLock++; } + void UnlockAdjustPosSizePixel() + { m_nAdjustPosPixelLock--; } + void DoAdjustPosSizePixel( SfxViewShell * pSh, + const Point &rPos, const Size &rSize, + bool inplaceEditModeChange ); + void Show(); + bool IsVisible() const; + void ToTop(); + void Enable( bool bEnable ); + void Close(); + virtual void Activate( bool bUI ) override; + virtual void Deactivate( bool bUI ) override; + + void UpdateTitle(); + + // interne Handler + SAL_DLLPRIVATE void SetBorderPixelImpl( const SfxViewShell *pSh, const SvBorder &rBorder ); + SAL_DLLPRIVATE const SvBorder& GetBorderPixelImpl() const; + SAL_DLLPRIVATE void InvalidateBorderImpl( const SfxViewShell *pSh ); + + virtual SfxObjectShell* GetObjectShell() override; + SfxInterfaceId GetCurViewId() const; + SfxFrame& GetFrame() const; + SfxViewFrame* GetTopViewFrame() const; + + bool DoClose(); + static void GetTargetList( TargetList& rList ) + { SfxFrame::GetDefaultTargetList( rList ); } + + void SetModalMode( bool ); + bool IsInModalMode() const; + void Resize(bool bForce=false); + + void SetChildWindow(sal_uInt16 nId, bool bVisible, bool bSetFocus=true); + void ToggleChildWindow(sal_uInt16); + bool HasChildWindow(sal_uInt16); + bool KnowsChildWindow(sal_uInt16); + void ShowChildWindow(sal_uInt16,bool bVisible=true); + SfxChildWindow* GetChildWindow(sal_uInt16); + void ChildWindowExecute(SfxRequest&); + void ChildWindowState(SfxItemSet&); + + /** Append a new InfoBar (see https://wiki.documentfoundation.org/Design/Whiteboards/Infobar). + + The buttons will be added from Right to Left at the right of the info bar. The parent, size + and position of each button will be changed: only the width will remain unchanged. + */ + VclPtr<SfxInfoBarWindow> AppendInfoBar(const OUString& sId, + const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, + InfobarType aInfobarType, + bool bShowCloseButton=true); + void RemoveInfoBar(std::u16string_view sId); + void UpdateInfoBar(std::u16string_view sId, const OUString& sPrimaryMessage, + const OUString& sSecondaryMessage, + InfobarType eType); + bool HasInfoBarWithID(std::u16string_view sId); + void AppendReadOnlyInfobar(); + void HandleSecurityInfobar(const OUString& sSecondaryMessage); + + SAL_DLLPRIVATE void GetDocNumber_Impl(); + SAL_DLLPRIVATE void SetViewShell_Impl( SfxViewShell *pVSh ); + SAL_DLLPRIVATE void ReleaseObjectShell_Impl(); + + SAL_DLLPRIVATE void GetState_Impl( SfxItemSet &rSet ); + void ExecReload_Impl(SfxRequest& rReq); + SAL_DLLPRIVATE void StateReload_Impl( SfxItemSet &rSet ); + SAL_DLLPRIVATE void ExecView_Impl( SfxRequest &rReq ); + SAL_DLLPRIVATE void StateView_Impl( SfxItemSet &rSet ); + SAL_DLLPRIVATE void ExecHistory_Impl( SfxRequest &rReq ); + SAL_DLLPRIVATE void StateHistory_Impl( SfxItemSet &rSet ); + SAL_DLLPRIVATE void ForceOuterResize_Impl(); + SAL_DLLPRIVATE void UpdateDocument_Impl(); + + SAL_DLLPRIVATE void LockObjectShell_Impl(); + + SAL_DLLPRIVATE void MakeActive_Impl( bool bActivate ); + SAL_DLLPRIVATE const Size& GetMargin_Impl() const; + SAL_DLLPRIVATE OUString GetActualPresentationURL_Impl() const; + SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &); + SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &); + SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl(); + SAL_DLLPRIVATE void AddDispatchMacroToBasic_Impl(const OUString& sMacro); + + SAL_DLLPRIVATE void Exec_Impl(SfxRequest &); + SAL_DLLPRIVATE void INetExecute_Impl(SfxRequest &); + SAL_DLLPRIVATE void INetState_Impl(SfxItemSet &); + + SAL_DLLPRIVATE void SetCurViewId_Impl( const SfxInterfaceId i_nID ); + +private: + SAL_DLLPRIVATE bool SwitchToViewShell_Impl( sal_uInt16 nNo, bool bIsIndex = false ); + SAL_DLLPRIVATE void PopShellAndSubShells_Impl( SfxViewShell& i_rViewShell ); + SAL_DLLPRIVATE void SaveCurrentViewData_Impl( const SfxInterfaceId i_nNewViewId ); + + /** loads the given existing document into the given frame + + This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked. + + @param i_rDoc + the document to load + @param i_rFrame + the frame to load the document into + @param i_rLoadArgs + the arguments to pass to the component loader. If this sequence is empty, then the current arguments of the + model will be obtained, and passed to the loader. This ensures that any arguments in the model will be preserved, + instead of being reset. + @param i_nViewId + the ID of the view to create + @throws Exception + if something goes wrong. The caller is responsible for handling this. + */ + SAL_DLLPRIVATE static SfxViewShell* LoadViewIntoFrame_Impl( + const SfxObjectShell& i_rDoc, + const css::uno::Reference< css::frame::XFrame >& i_rFrame, + const css::uno::Sequence< css::beans::PropertyValue >& i_rLoadArgs, + const SfxInterfaceId i_nViewId, + const bool i_bHidden + ); + + /** loads the given existing document into the given frame + + This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked. + + If no frame is given, a blank top level frame is created. + + If anything fails during the process, as much as possible is cleaned up. + + @param i_rDoc + the document to load + @param i_rFrame + the frame to load the document into. Might be <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 0000000000..c1a2bc90a1 --- /dev/null +++ b/include/sfx2/viewsh.hxx @@ -0,0 +1,493 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.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 <optional> +#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 <comphelper/errcode.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <vcl/vclptr.hxx> +#include <editeng/outliner.hxx> +#include <functional> +#include <unordered_set> +#include <unordered_map> + +class SfxTabPage; +class SfxBaseController; +class Size; +class Point; +class Fraction; +namespace weld { + class Container; + class DialogController; + class Window; +} +class KeyEvent; +class SvBorder; +class SdrView; +class SfxModule; +class SfxViewFrame; +class Printer; +class SfxPrinter; +class NotifyEvent; +class SfxInPlaceClient; +class SfxLokCallbackInterface; +class LOKDocumentFocusListener; +class SfxStoringHelper; +class VCLXPopupMenu; +namespace rtl { class OStringBuffer; } +namespace vcl { class PrinterController; } + +namespace com::sun::star::awt{ class XPopupMenu; } +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::datatransfer::clipboard { class XClipboardListener; } +namespace com::sun::star::datatransfer::clipboard { class XClipboardNotifier; } +namespace com::sun::star::embed { class XEmbeddedObject; } +namespace com::sun::star::frame { class XController; } +namespace com::sun::star::frame { class XModel; } +namespace com::sun::star::ui { class XContextMenuInterceptor; } +namespace com::sun::star::ui { struct ContextMenuExecuteEvent; } +namespace com::sun::star::view { class XRenderable; } +namespace tools { class Rectangle; } +namespace svtools { enum ColorConfigEntry : int; } + +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 *s_pFactory; \ +public: \ + static SfxViewShell *CreateInstance(SfxViewFrame& rFrame, SfxViewShell *pOldView); \ + static void RegisterFactory( SfxInterfaceId nPrio ); \ + static SfxViewFactory*Factory() { return s_pFactory; } \ + static void InitFactory() + +#define SFX_IMPL_NAMED_VIEWFACTORY(Class, AsciiViewName) \ + SfxViewFactory* Class::s_pFactory; \ + SfxViewShell* Class::CreateInstance(SfxViewFrame& rFrame, SfxViewShell *pOldView) \ + { return new Class(rFrame, pOldView); } \ + void Class::RegisterFactory( SfxInterfaceId nPrio ) \ + { \ + s_pFactory = new SfxViewFactory(&CreateInstance,nPrio,AsciiViewName);\ + InitFactory(); \ + } \ + void Class::InitFactory() + +#define SFX_VIEW_REGISTRATION(DocClass) \ + DocClass::Factory().RegisterViewFactory( *Factory() ) + +template<class T> bool checkSfxViewShell(const SfxViewShell* pShell) +{ + return dynamic_cast<const T*>(pShell) != nullptr; +} + +typedef std::unordered_map<OUString, std::pair<Color, int>> StylesHighlighterColorMap; + +/** + * One SfxViewShell more or less represents one edit window for a document, there can be multiple + * ones for a single opened document (SfxObjectShell). + */ +class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener, public OutlinerViewShell, public vcl::ILibreOfficeKitNotifier +{ +friend class SfxViewFrame; +friend class SfxBaseController; +friend class SfxPrinterController; + + std::unique_ptr<struct SfxViewShell_Impl> pImpl; + SfxViewFrame& rFrame; + VclPtr<vcl::Window> pWindow; + bool bNoNewWindow; + bool mbPrinterSettingsModified; + LanguageTag maLOKLanguageTag; + LanguageTag maLOKLocale; + LOKDeviceFormFactor maLOKDeviceFormFactor; + bool mbLOKAccessibilityEnabled; + rtl::Reference<LOKDocumentFocusListener> mpLOKDocumentFocusListener; + std::unordered_set<OUString> mvLOKBlockedCommandList; + OUString maLOKTimezone; + bool maLOKIsTimezoneSet; + + /// Used to set the DocId at construction time. See SetCurrentDocId. + static ViewShellDocId mnCurrentDocId; + + /// Used for async export + std::shared_ptr<SfxStoringHelper> m_xHelper; + + StylesHighlighterColorMap ParaStylesColorMap; + StylesHighlighterColorMap CharStylesColorMap; + +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 + SAL_WARN_UNUSED_RESULT static SfxViewShell* GetFirst( bool bOnlyVisible = true, const std::function<bool ( const SfxViewShell* )>& isViewShell = nullptr ); + SAL_WARN_UNUSED_RESULT static SfxViewShell* GetNext( const SfxViewShell& rPrev, + bool bOnlyVisible = true, + const std::function<bool ( const SfxViewShell* )>& isViewShell = nullptr ); + SAL_WARN_UNUSED_RESULT static SfxViewShell* Current(); + + SAL_WARN_UNUSED_RESULT 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(); + + LOKDocumentFocusListener& GetLOKDocumentFocusListener(); + const LOKDocumentFocusListener& GetLOKDocumentFocusListener() const; + +public: + + SfxViewShell( SfxViewFrame& rFrame, SfxViewShellFlags nFlags ); + virtual ~SfxViewShell() override; + + /// Informs the view shell that it'll be deleted before the main loop processes the next user + /// input. + virtual void SetDying() {} + + SfxInPlaceClient* GetIPClient() const; + SfxInPlaceClient* GetUIActiveClient() const; + SfxInPlaceClient* FindIPClient( const css::uno::Reference < css::embed::XEmbeddedObject >& xObj, vcl::Window *pObjParentWin ) const; + + virtual ErrCode DoVerb(sal_Int32 nVerb); + + void OutplaceActivated( bool bActive ); + virtual void UIActivating( SfxInPlaceClient* pClient ); + virtual void UIDeactivated( SfxInPlaceClient* pClient ); + + void JumpToMark( const OUString& rMark ); + void VisAreaChanged(); + + // Misc + + /** + * Initialize is called after the frame has been loaded and the controller + * has been set. By the time this is called the document has been fully + * imported. + * @param bOnlyASample used by some dialogs to avoid constructing monster strings e.g. in calc + */ + virtual bool PrepareClose( bool bUI = true ); + virtual OUString GetSelectionText( bool bCompleteWords = false, bool bOnlyASample = false ); + virtual bool HasSelection( bool bText = true ) const; + virtual SdrView* GetDrawView() const; + + void AddSubShell( SfxShell& rShell ); + void RemoveSubShell( SfxShell *pShell=nullptr ); + SfxShell* GetSubShell( sal_uInt16 ); + + virtual SfxShell* GetFormShell() { return nullptr; }; + virtual const SfxShell* GetFormShell() const { return nullptr; }; + + // ILibreOfficeKitNotifier + virtual void notifyWindow(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const std::vector<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(); + + /* [Description] + + This method returns a reference 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 reference + is a valid SfxViewFrame instance. + + [Cross-reference] + + <SfxShell::GetFrame()const> + */ + SfxViewFrame& GetViewFrame() const + { + return rFrame; + } + + // 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(const rtl::Reference<VCLXPopupMenu>& rIn, + const OUString& rMenuIdentifier, + rtl::Reference<VCLXPopupMenu>& rOut, + css::ui::ContextMenuExecuteEvent aEvent); + bool TryContextMenuInterception(const rtl::Reference<VCLXPopupMenu>&, + 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); + + /// Set up a more efficient internal callback instead of LibreOfficeKitCallback. + void setLibreOfficeKitViewCallback(SfxLokCallbackInterface* pCallback); + SfxLokCallbackInterface* getLibreOfficeKitViewCallback() const; + /// dump view state for diagnostics + void dumpLibreOfficeKitViewState(rtl::OStringBuffer &rState); + /// Invokes the registered callback, if there are any. + virtual void libreOfficeKitViewCallback(int nType, const OString& pPayload) const override; + virtual void libreOfficeKitViewCallbackWithViewId(int nType, const OString& pPayload, int nViewId) const override; + virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart, int nMode) const override; + virtual void libreOfficeKitViewUpdatedCallback(int nType) const override; + virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, int nSourceViewId) const override; + // Performs any pending calls to libreOfficeKitViewInvalidateTilesCallback() as necessary. + virtual void flushPendingLOKInvalidateTiles(); + virtual void libreOfficeKitViewAddPendingInvalidateTiles() override; + // Returns current payload for nType, after libreOfficeKitViewUpdatedCallback() or + // libreOfficeKitViewUpdatedCallbackPerViewId() were called. If no payload should + // be generated, the ignore flag should be set. + virtual std::optional<OString> getLOKPayload(int nType, int nViewId) const; + + /// Set if we are doing tiled searching. + void setTiledSearching(bool bTiledSearching); + /// See lok::Document::getPart(). + virtual int getPart() const; + /// See lok::Document::getMode(). + virtual int getEditMode() const; + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; + /// See OutlinerViewShell::GetViewShellId(). + ViewShellId GetViewShellId() const override; + + /// Set the current DocId, which is used by Mobile LOKit to + /// load multiple documents and yet identify the views of each. + /// There are events that are fired while creating a new view, + /// and if we don't have a DocId, we can't know which other views + /// within the same document (if any) should get those events. + /// By setting this static value, we are able to set the DocId + /// of each SfxViewShell at construction time. + static void SetCurrentDocId(ViewShellDocId nId); + /// Get the DocId used by Mobile LOKit to load multiple documents. + ViewShellDocId GetDocId() const override; + + /// ILibreOfficeKitNotifier. Emits a LOK_CALLBACK_INVALIDATE_TILES. + virtual void notifyInvalidation(tools::Rectangle const *) 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; + /// Get a color config color from this view + virtual ::Color GetColorConfigColor(svtools::ColorConfigEntry nColorType) const; + + /// 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; } + /// Enable/Disable LibreOfficeKit AT support for this view. + void SetLOKAccessibilityState(bool bEnabled); + /// Get LibreOfficeKit AT support state for this view. + bool GetLOKAccessibilityState() const { return mbLOKAccessibilityEnabled; } + + /// Get the LibreOfficeKit timezone of this view. See @SetLOKTimezone. + std::pair<bool, OUString> GetLOKTimezone() const + { + return { maLOKIsTimezoneSet, maLOKTimezone }; + } + + /// Set the LibreOfficeKit timezone of this view. + /// @isSet true to use @rTimezone, even if it's empty. Otherwise, no timezone. + /// @rTimezone the value to set (which could be empty). + void SetLOKTimezone(bool isSet, const OUString& rTimezone) + { + maLOKIsTimezoneSet = isSet; + maLOKTimezone = rTimezone; + } + + /// Set the LibreOfficeKit locale of this view. + void SetLOKLocale(const OUString& rBcp47LanguageTag); + /// Get the LibreOfficeKit locale of this view. + const LanguageTag& GetLOKLocale() const { return maLOKLocale; } + /// Get the form factor of the device where the lok client is running. + LOKDeviceFormFactor GetLOKDeviceFormFactor() const { return maLOKDeviceFormFactor; } + /// Check if the lok client is running on a desktop machine. + bool isLOKDesktop() const { return maLOKDeviceFormFactor == LOKDeviceFormFactor::DESKTOP; } + /// Check if the lok client is running on a tablet. + bool isLOKTablet() const { return maLOKDeviceFormFactor == LOKDeviceFormFactor::TABLET; } + /// Check if the lok client is running on a mobile device. + bool isLOKMobilePhone() const { return maLOKDeviceFormFactor == LOKDeviceFormFactor::MOBILE; } + + virtual tools::Rectangle getLOKVisibleArea() const { return tools::Rectangle(); } + + // Blocked Command view settings + void setBlockedCommandList(const char* blockedCommandList); + bool isBlockedCommand(OUString command); + + void SetStoringHelper(std::shared_ptr<SfxStoringHelper> xHelper) { m_xHelper = xHelper; } + + StylesHighlighterColorMap& GetStylesHighlighterParaColorMap() { return ParaStylesColorMap; } + StylesHighlighterColorMap& GetStylesHighlighterCharColorMap() { return CharStylesColorMap; } + + OUString getA11yFocusedParagraph() const; + int getA11yCaretPosition() const; +}; + +#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 0000000000..c298894bb5 --- /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 0000000000..8ed6671a66 --- /dev/null +++ b/include/sfx2/weldutils.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_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/weld.hxx> + +#include <map> + +namespace weld +{ +class Builder; +class Toolbar; +} + +class SFX2_DLLPUBLIC ToolbarUnoDispatcher +{ +private: + css::uno::Reference<css::frame::XFrame> m_xFrame; + css::uno::Reference<css::lang::XComponent> m_xImageController; + SvtMiscOptions m_aToolbarOptions; + weld::Toolbar* m_pToolbar; + weld::Builder* m_pBuilder; + bool m_bSideBar; + + DECL_DLLPRIVATE_LINK(SelectHdl, const OUString&, void); + DECL_DLLPRIVATE_LINK(ToggleMenuHdl, const OUString&, void); + DECL_DLLPRIVATE_LINK(ChangedIconSizeHandler, LinkParamNone*, void); + + void CreateController(const OUString& rCommand); + static vcl::ImageType GetIconSize(); + + 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; + + const css::uno::Reference<css::frame::XFrame>& GetFrame() const { return m_xFrame; } + + 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 0000000000..fa1fd9b9d7 --- /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 final : public SfxUInt16Item +{ + SvxZoomEnableFlags nValueSet; // allowed values (see #defines below) + SvxZoomType eType; + +public: + static SfxPoolItem* CreateDefault(); + + SvxZoomItem( SvxZoomType eZoomType = SvxZoomType::PERCENT, + sal_uInt16 nVal = 0, TypedWhichId<SvxZoomItem> 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: */ |