1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <com/sun/star/beans/PropertyAttribute.hpp>
22 #include "controlfontdialog.hxx"
24 #include <comphelper/propertyvalue.hxx>
25 #include <vcl/svapp.hxx>
26 #include "fontdialog.hxx"
27 #include "formstrings.hxx"
28 #include "pcrcommon.hxx"
34 using namespace ::com::sun::star::uno
;
35 using namespace ::com::sun::star::lang
;
36 using namespace ::com::sun::star::beans
;
38 OControlFontDialog::OControlFontDialog(const Reference
< XComponentContext
>& _rxContext
)
39 :OGenericUnoDialog( _rxContext
)
40 ,m_pItemPoolDefaults(nullptr)
42 registerProperty(PROPERTY_INTROSPECTEDOBJECT
, static_cast<sal_Int32
>(OwnPropertyId::INTROSPECTEDOBJECT
),
43 PropertyAttribute::BOUND
| PropertyAttribute::TRANSIENT
,
44 &m_xControlModel
, cppu::UnoType
<decltype(m_xControlModel
)>::get());
48 OControlFontDialog::~OControlFontDialog()
52 ::osl::MutexGuard
aGuard(m_aMutex
);
56 ControlCharacterDialog::destroyItemSet(m_pFontItems
, m_pItemPool
, m_pItemPoolDefaults
);
62 Sequence
<sal_Int8
> SAL_CALL
OControlFontDialog::getImplementationId( )
64 return css::uno::Sequence
<sal_Int8
>();
68 OUString SAL_CALL
OControlFontDialog::getImplementationName()
70 return "org.openoffice.comp.form.ui.OControlFontDialog";
74 css::uno::Sequence
<OUString
> SAL_CALL
OControlFontDialog::getSupportedServiceNames()
76 return { "com.sun.star.form.ControlFontDialog" };
79 void OControlFontDialog::initialize( const Sequence
< Any
>& aArguments
)
81 Reference
<XPropertySet
> xGridModel
;
82 if (aArguments
.getLength() == 1 && (aArguments
[0] >>= xGridModel
))
84 Sequence aNewArguments
{ Any(comphelper::makePropertyValue("IntrospectedObject",
86 OControlFontDialog_DBase::initialize(aNewArguments
);
89 OControlFontDialog_DBase::initialize(aArguments
);
93 Reference
<XPropertySetInfo
> SAL_CALL
OControlFontDialog::getPropertySetInfo()
95 Reference
<XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
100 ::cppu::IPropertyArrayHelper
& OControlFontDialog::getInfoHelper()
102 return *getArrayHelper();
106 ::cppu::IPropertyArrayHelper
* OControlFontDialog::createArrayHelper( ) const
108 Sequence
< Property
> aProps
;
109 describeProperties(aProps
);
110 return new ::cppu::OPropertyArrayHelper(aProps
);
113 std::unique_ptr
<weld::DialogController
> OControlFontDialog::createDialog(const css::uno::Reference
<css::awt::XWindow
>& rParent
)
115 ControlCharacterDialog::createItemSet(m_pFontItems
, m_pItemPool
, m_pItemPoolDefaults
);
117 OSL_ENSURE(m_xControlModel
.is(), "OControlFontDialog::createDialog: no introspectee set!");
118 if (m_xControlModel
.is())
119 ControlCharacterDialog::translatePropertiesToItems(m_xControlModel
, m_pFontItems
.get());
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.
124 return std::make_unique
<ControlCharacterDialog
>(Application::GetFrameWeld(rParent
), *m_pFontItems
);
127 void OControlFontDialog::executedDialog(sal_Int16 _nExecutionResult
)
129 OSL_ENSURE(m_xDialog
, "OControlFontDialog::executedDialog: no dialog anymore?!!");
130 if (m_xDialog
&& (RET_OK
== _nExecutionResult
) && m_xControlModel
.is())
132 const SfxItemSet
* pOutput
= static_cast<ControlCharacterDialog
*>(m_xDialog
.get())->GetOutputItemSet();
134 ControlCharacterDialog::translateItemsToProperties( *pOutput
, m_xControlModel
);
141 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
142 extensions_propctrlr_OControlFontDialog_get_implementation(
143 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const&)
145 return cppu::acquire(new pcr::OControlFontDialog(context
));
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */