LibreOffice Module svtools (master) 1
genericunodialog.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <svtools/svtdllapi.h>
23
24#include <com/sun/star/lang/XServiceInfo.hpp>
25#include <com/sun/star/lang/XInitialization.hpp>
26#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
27
29#include <comphelper/uno3.hxx>
32#include <vcl/weld.hxx>
33
34namespace com :: sun :: star :: awt { class XWindow; }
35namespace com :: sun :: star :: uno { class XComponentContext; }
36
37class VclWindowEvent;
38
39
40namespace svt
41{
42
43
44#define UNODIALOG_PROPERTY_ID_TITLE 1
45#define UNODIALOG_PROPERTY_ID_PARENT 2
46
47inline constexpr OUStringLiteral UNODIALOG_PROPERTY_TITLE = u"Title";
48inline constexpr OUStringLiteral UNODIALOG_PROPERTY_PARENT = u"ParentWindow";
49
50 typedef cppu::WeakImplHelper< css::ui::dialogs::XExecutableDialog,
51 css::lang::XServiceInfo,
52 css::lang::XInitialization > OGenericUnoDialogBase;
53
60 {
61 protected:
62 std::unique_ptr<weld::DialogController> m_xDialog;
63 bool m_bExecuting : 1;
65 bool m_bInitialized : 1;
66
67 // <properties>
68 OUString m_sTitle;
69 css::uno::Reference<css::awt::XWindow> m_xParent;
70 // </properties>
71
72 css::uno::Reference<css::uno::XComponentContext> m_aContext;
73
74 protected:
75 OGenericUnoDialog(const css::uno::Reference< css::uno::XComponentContext >& _rxContext);
76 virtual ~OGenericUnoDialog() override;
77
78 public:
79 // UNO
81 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
82
83 // XTypeProvider
84 virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes( ) override;
85 virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) override = 0;
86
87 // XServiceInfo
88 virtual OUString SAL_CALL getImplementationName() override = 0;
89 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
90 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override = 0;
91
92 // OPropertySetHelper
93 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override;
94 virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any& rConvertedValue, css::uno::Any& rOldValue, sal_Int32 nHandle, const css::uno::Any& rValue) override;
95
96 // XExecutableDialog
97 virtual void SAL_CALL setTitle( const OUString& aTitle ) override;
98 virtual sal_Int16 SAL_CALL execute( ) override;
99
100 // XInitialization
101 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
102
103 protected:
108 virtual std::unique_ptr<weld::DialogController> createDialog(const css::uno::Reference<css::awt::XWindow>& rParent) = 0;
109
111 void destroyDialog();
112
116 virtual void executedDialog(sal_Int16 /*_nExecutionResult*/) { }
117
124 virtual void implInitialize(const css::uno::Any& _rValue);
125
126 private:
127
141 bool impl_ensureDialog_lck();
142 };
143
146 {
147 public:
149 :m_aGuard( _rDialog.GetMutex() )
150 {
151 }
152
153 private:
154 ::osl::MutexGuard m_aGuard;
155 };
156
157
158} // namespace svt
159
160/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
abstract base class for implementing UNO objects representing dialogs (com.sun.star....
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override=0
std::unique_ptr< weld::DialogController > m_xDialog
virtual std::unique_ptr< weld::DialogController > createDialog(const css::uno::Reference< css::awt::XWindow > &rParent)=0
create the concrete dialog instance.
virtual void executedDialog(sal_Int16)
called after the dialog has been executed
virtual OUString SAL_CALL getImplementationName() override=0
css::uno::Reference< css::awt::XWindow > m_xParent
title of the dialog
OUString m_sTitle
has "initialize" been called?
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override=0
bool m_bExecuting
the dialog to execute
css::uno::Reference< css::uno::XComponentContext > m_aContext
parent window
bool m_bInitialized
m_sTitle has not been set yet
bool m_bTitleAmbiguous
we're currently executing the dialog
helper class for guarding access to methods of an OGenericUnoDialog
UnoDialogEntryGuard(OGenericUnoDialog &_rDialog)
float u
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr OUStringLiteral UNODIALOG_PROPERTY_TITLE
constexpr OUStringLiteral UNODIALOG_PROPERTY_PARENT
cppu::WeakImplHelper< css::ui::dialogs::XExecutableDialog, css::lang::XServiceInfo, css::lang::XInitialization > OGenericUnoDialogBase
#define SVT_DLLPUBLIC
Definition: svtdllapi.h:27
unsigned char sal_Bool
#define DECLARE_UNO3_DEFAULTS(classname, baseclass)