LibreOffice Module extensions (master) 1
controlfontdialog.cxx
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
21#include <com/sun/star/beans/PropertyAttribute.hpp>
22#include "controlfontdialog.hxx"
23
25#include <vcl/svapp.hxx>
26#include "fontdialog.hxx"
27#include "formstrings.hxx"
28#include "pcrcommon.hxx"
29
30namespace pcr
31{
32
33
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::lang;
36 using namespace ::com::sun::star::beans;
37
38 OControlFontDialog::OControlFontDialog(const Reference< XComponentContext >& _rxContext )
39 :OGenericUnoDialog( _rxContext )
40 ,m_pItemPoolDefaults(nullptr)
41 {
42 registerProperty(PROPERTY_INTROSPECTEDOBJECT, static_cast<sal_Int32>(OwnPropertyId::INTROSPECTEDOBJECT),
43 PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT,
45 }
46
47
49 {
50 if (m_xDialog)
51 {
52 ::osl::MutexGuard aGuard(m_aMutex);
53 if (m_xDialog)
54 {
57 }
58 }
59 }
60
61
62 Sequence<sal_Int8> SAL_CALL OControlFontDialog::getImplementationId( )
63 {
64 return css::uno::Sequence<sal_Int8>();
65 }
66
67
69 {
70 return "org.openoffice.comp.form.ui.OControlFontDialog";
71 }
72
73
74 css::uno::Sequence<OUString> SAL_CALL OControlFontDialog::getSupportedServiceNames()
75 {
76 return { "com.sun.star.form.ControlFontDialog" };
77 }
78
79 void OControlFontDialog::initialize( const Sequence< Any >& aArguments )
80 {
81 Reference<XPropertySet> xGridModel;
82 if (aArguments.getLength() == 1 && (aArguments[0] >>= xGridModel))
83 {
84 Sequence aNewArguments{ Any(comphelper::makePropertyValue("IntrospectedObject",
85 xGridModel)) };
87 }
88 else
90 }
91
92
93 Reference<XPropertySetInfo> SAL_CALL OControlFontDialog::getPropertySetInfo()
94 {
95 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
96 return xInfo;
97 }
98
99
101 {
102 return *getArrayHelper();
103 }
104
105
107 {
108 Sequence< Property > aProps;
109 describeProperties(aProps);
110 return new ::cppu::OPropertyArrayHelper(aProps);
111 }
112
113 std::unique_ptr<weld::DialogController> OControlFontDialog::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent)
114 {
116
117 OSL_ENSURE(m_xControlModel.is(), "OControlFontDialog::createDialog: no introspectee set!");
118 if (m_xControlModel.is())
120 // TODO: we need a mechanism to prevent that somebody creates us, sets an introspectee, executes us,
121 // sets a new introspectee and re-executes us. In this case, the dialog returned here (upon the first
122 // execute) will be re-used upon the second execute, and thus it won't be initialized correctly.
123
124 return std::make_unique<ControlCharacterDialog>(Application::GetFrameWeld(rParent), *m_pFontItems);
125 }
126
127 void OControlFontDialog::executedDialog(sal_Int16 _nExecutionResult)
128 {
129 OSL_ENSURE(m_xDialog, "OControlFontDialog::executedDialog: no dialog anymore?!!");
130 if (m_xDialog && (RET_OK == _nExecutionResult) && m_xControlModel.is())
131 {
132 const SfxItemSet* pOutput = static_cast<ControlCharacterDialog*>(m_xDialog.get())->GetOutputItemSet();
133 if (pOutput)
135 }
136 }
137
138
139} // namespace pcr
140
141extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
143 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
144{
145 return cppu::acquire(new pcr::OControlFontDialog(context));
146}
147
148/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
::cppu::IPropertyArrayHelper * getArrayHelper()
static void translateItemsToProperties(const SfxItemSet &_rSet, const css::uno::Reference< css::beans::XPropertySet > &_rxModel)
fills the given property set with values obtained from the given item set
static void destroyItemSet(std::unique_ptr< SfxItemSet > &_rpSet, rtl::Reference< SfxItemPool > &_rpPool, std::vector< SfxPoolItem * > *&_rpDefaults)
destroys an item previously created with <method>createItemSet</method>
Definition: fontdialog.cxx:565
static void createItemSet(std::unique_ptr< SfxItemSet > &_rpSet, rtl::Reference< SfxItemPool > &_rpPool, std::vector< SfxPoolItem * > *&_rpDefaults)
creates an item set to be used with this dialog
Definition: fontdialog.cxx:495
static void translatePropertiesToItems(const css::uno::Reference< css::beans::XPropertySet > &_rxModel, SfxItemSet *_pSet)
fills the given item set with values obtained from the given property set
Definition: fontdialog.cxx:213
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void executedDialog(sal_Int16 _nExecutionResult) override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
std::vector< SfxPoolItem * > * m_pItemPoolDefaults
std::unique_ptr< SfxItemSet > m_pFontItems
virtual OUString SAL_CALL getImplementationName() override
virtual ~OControlFontDialog() override
rtl::Reference< SfxItemPool > m_pItemPool
OControlFontDialog(const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual std::unique_ptr< weld::DialogController > createDialog(const css::uno::Reference< css::awt::XWindow > &rParent) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
css::uno::Reference< css::beans::XPropertySet > m_xControlModel
std::unique_ptr< weld::DialogController > m_xDialog
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * extensions_propctrlr_OControlFontDialog_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
virtual const SfxItemSet * GetOutputItemSet() const override
constexpr OUStringLiteral PROPERTY_INTROSPECTEDOBJECT
Definition: formstrings.hxx:25
Sequence< PropertyValue > aArguments
::osl::Mutex m_aMutex
Definition: logger.cxx:98
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
a property handler for any virtual string properties
Definition: browserline.cxx:39
RET_OK