Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / extensions / source / propctrlr / controlfontdialog.cxx
blob03d1db272e60edab2032fd29e1b1222cd68b52a1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <com/sun/star/beans/PropertyValue.hpp>
23 #include "controlfontdialog.hxx"
24 #include <cppuhelper/typeprovider.hxx>
25 #include <vcl/svapp.hxx>
26 #include "fontdialog.hxx"
27 #include "formstrings.hxx"
28 #include "pcrcommon.hxx"
29 #include "pcrservices.hxx"
31 extern "C" void createRegistryInfo_OControlFontDialog()
33 ::pcr::OAutoRegistration< ::pcr::OControlFontDialog > aAutoRegistration;
37 namespace pcr
41 using namespace ::com::sun::star::uno;
42 using namespace ::com::sun::star::lang;
43 using namespace ::com::sun::star::beans;
45 OControlFontDialog::OControlFontDialog(const Reference< XComponentContext >& _rxContext )
46 :OGenericUnoDialog( _rxContext )
47 ,m_pItemPool(nullptr)
48 ,m_pItemPoolDefaults(nullptr)
50 registerProperty(PROPERTY_INTROSPECTEDOBJECT, OWN_PROPERTY_ID_INTROSPECTEDOBJECT,
51 PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT,
52 &m_xControlModel, cppu::UnoType<decltype(m_xControlModel)>::get());
56 OControlFontDialog::~OControlFontDialog()
58 if (m_xDialog)
60 ::osl::MutexGuard aGuard(m_aMutex);
61 if (m_xDialog)
63 destroyDialog();
64 ControlCharacterDialog::destroyItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
70 Sequence<sal_Int8> SAL_CALL OControlFontDialog::getImplementationId( )
72 return css::uno::Sequence<sal_Int8>();
76 Reference< XInterface > OControlFontDialog::Create( const Reference< XComponentContext >& _rxContext )
78 return *( new OControlFontDialog( _rxContext ) );
82 OUString SAL_CALL OControlFontDialog::getImplementationName()
84 return getImplementationName_static();
88 OUString OControlFontDialog::getImplementationName_static()
90 return "org.openoffice.comp.form.ui.OControlFontDialog";
94 css::uno::Sequence<OUString> SAL_CALL OControlFontDialog::getSupportedServiceNames()
96 return getSupportedServiceNames_static();
100 css::uno::Sequence<OUString> OControlFontDialog::getSupportedServiceNames_static()
102 css::uno::Sequence<OUString> aSupported { "com.sun.star.form.ControlFontDialog" };
103 return aSupported;
106 void OControlFontDialog::initialize( const Sequence< Any >& aArguments )
108 Reference<XPropertySet> xGridModel;
109 if (aArguments.getLength() == 1 && (aArguments[0] >>= xGridModel))
111 PropertyValue aArg;
112 aArg.Name = "IntrospectedObject";
113 aArg.Value <<= xGridModel;
114 Sequence< Any > aNewArguments(1);
115 aNewArguments[0] <<= aArg;
116 OControlFontDialog_DBase::initialize(aNewArguments);
118 else
119 OControlFontDialog_DBase::initialize(aArguments);
123 Reference<XPropertySetInfo> SAL_CALL OControlFontDialog::getPropertySetInfo()
125 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
126 return xInfo;
130 ::cppu::IPropertyArrayHelper& OControlFontDialog::getInfoHelper()
132 return *getArrayHelper();
136 ::cppu::IPropertyArrayHelper* OControlFontDialog::createArrayHelper( ) const
138 Sequence< Property > aProps;
139 describeProperties(aProps);
140 return new ::cppu::OPropertyArrayHelper(aProps);
143 std::unique_ptr<weld::DialogController> OControlFontDialog::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent)
145 ControlCharacterDialog::createItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
147 OSL_ENSURE(m_xControlModel.is(), "OControlFontDialog::createDialog: no introspectee set!");
148 if (m_xControlModel.is())
149 ControlCharacterDialog::translatePropertiesToItems(m_xControlModel, m_pFontItems.get());
150 // TODO: we need a mechanism to prevent that somebody creates us, sets an introspectee, executes us,
151 // sets a new introspectee and re-executes us. In this case, the dialog returned here (upon the first
152 // execute) will be re-used upon the second execute, and thus it won't be initialized correctly.
154 return std::make_unique<ControlCharacterDialog>(Application::GetFrameWeld(rParent), *m_pFontItems);
157 void OControlFontDialog::executedDialog(sal_Int16 _nExecutionResult)
159 OSL_ENSURE(m_xDialog, "OControlFontDialog::executedDialog: no dialog anymore?!!");
160 if (m_xDialog && (RET_OK == _nExecutionResult) && m_xControlModel.is())
162 const SfxItemSet* pOutput = static_cast<ControlCharacterDialog*>(m_xDialog.get())->GetOutputItemSet();
163 if (pOutput)
164 ControlCharacterDialog::translateItemsToProperties( *pOutput, m_xControlModel );
169 } // namespace pcr
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */