/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #pragma once #include #include #include #include #include #include #include #include #include namespace com :: sun :: star :: awt { class XWindow; } namespace com :: sun :: star :: uno { class XComponentContext; } class VclWindowEvent; namespace svt { #define UNODIALOG_PROPERTY_ID_TITLE 1 #define UNODIALOG_PROPERTY_ID_PARENT 2 inline constexpr OUString UNODIALOG_PROPERTY_TITLE = u"Title"_ustr; inline constexpr OUString UNODIALOG_PROPERTY_PARENT = u"ParentWindow"_ustr; typedef cppu::WeakImplHelper< css::ui::dialogs::XExecutableDialog, css::lang::XServiceInfo, css::lang::XInitialization > OGenericUnoDialogBase; /** abstract base class for implementing UNO objects representing dialogs (com.sun.star.awt::XDialog) */ class SVT_DLLPUBLIC OGenericUnoDialog :public OGenericUnoDialogBase ,public ::comphelper::OMutexAndBroadcastHelper ,public ::comphelper::OPropertyContainer { protected: std::unique_ptr m_xDialog; /// the dialog to execute bool m_bExecuting : 1; /// we're currently executing the dialog bool m_bTitleAmbiguous : 1; /// m_sTitle has not been set yet bool m_bInitialized : 1; /// has "initialize" been called? // OUString m_sTitle; /// title of the dialog css::uno::Reference m_xParent; /// parent window // css::uno::Reference m_aContext; protected: OGenericUnoDialog(const css::uno::Reference< css::uno::XComponentContext >& _rxContext); virtual ~OGenericUnoDialog() override; public: // UNO DECLARE_UNO3_DEFAULTS(OGenericUnoDialog, OGenericUnoDialogBase) virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override; // XTypeProvider virtual css::uno::Sequence SAL_CALL getTypes( ) override; virtual css::uno::Sequence SAL_CALL getImplementationId( ) override = 0; // XServiceInfo virtual OUString SAL_CALL getImplementationName() override = 0; virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() override = 0; // OPropertySetHelper virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override; virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any& rConvertedValue, css::uno::Any& rOldValue, sal_Int32 nHandle, const css::uno::Any& rValue) override; // XExecutableDialog virtual void SAL_CALL setTitle( const OUString& aTitle ) override; virtual sal_Int16 SAL_CALL execute( ) override; // XInitialization virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; protected: /** create the concrete dialog instance. Note that m_aMutex is not locked when this method get called, but the application-wide solar mutex is (to guard the not thread-safe ctor of the dialog). @param pParent the parent window for the new dialog */ virtual std::unique_ptr createDialog(const css::uno::Reference& rParent) = 0; /// called to destroy the dialog used. deletes m_pDialog and resets it to NULL void destroyDialog(); /** called after the dialog has been executed @param _nExecutionResult the execution result as returned by Dialog::Execute */ virtual void executedDialog(sal_Int16 /*_nExecutionResult*/) { } /** smaller form of initialize.

The initialize method is called with a sequence of com.sun.star.uno::Any's, which is split up into the single elements, which are passed to implInitialize. The default implementation tries to extract a com.sun.star.beans::PropertyValue from the value a pass it to the com.sun.star.beans::XPropertySet interface of the object. */ virtual void implInitialize(const css::uno::Any& _rValue); private: /** ensures that m_pDialog is not This method does nothing if m_pDialog is already non-. Else, it calls createDialog and does all necessary initializations of the new dialog instance. @precond m_aMutex is locked @return if and only if m_pDialog is non- upon returning from the method. Note that the only case where m_pDialog is is when createDialog returned , which is will fire an assertion in non-product builds. */ bool impl_ensureDialog_lck(); }; /// helper class for guarding access to methods of an OGenericUnoDialog class UnoDialogEntryGuard { public: UnoDialogEntryGuard( OGenericUnoDialog& _rDialog ) :m_aGuard( _rDialog.GetMutex() ) { } private: ::osl::MutexGuard m_aGuard; }; } // namespace svt /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ istro/lhm/libreoffice-7-4+backports LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff

AgeCommit message (Expand)Author