Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / extensions / source / propctrlr / controlfontdialog.cxx
bloba598665b29e2e18cc2d44c7f4bd94e8a6e10f057
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 "controlfontdialog.hxx"
22 #include <cppuhelper/typeprovider.hxx>
23 #include "fontdialog.hxx"
24 #include "formstrings.hxx"
25 #include "pcrcommon.hxx"
26 #include "pcrservices.hxx"
28 extern "C" void SAL_CALL createRegistryInfo_OControlFontDialog()
30 ::pcr::OAutoRegistration< ::pcr::OControlFontDialog > aAutoRegistration;
34 namespace pcr
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::lang;
40 using namespace ::com::sun::star::beans;
42 OControlFontDialog::OControlFontDialog(const Reference< XComponentContext >& _rxContext )
43 :OGenericUnoDialog( _rxContext )
44 ,m_pFontItems(nullptr)
45 ,m_pItemPool(nullptr)
46 ,m_pItemPoolDefaults(nullptr)
48 registerProperty(PROPERTY_INTROSPECTEDOBJECT, OWN_PROPERTY_ID_INTROSPECTEDOBJECT,
49 PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT,
50 &m_xControlModel, cppu::UnoType<decltype(m_xControlModel)>::get());
54 OControlFontDialog::~OControlFontDialog()
56 if (m_pDialog)
58 ::osl::MutexGuard aGuard(m_aMutex);
59 if (m_pDialog)
61 destroyDialog();
62 ControlCharacterDialog::destroyItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
68 Sequence<sal_Int8> SAL_CALL OControlFontDialog::getImplementationId( )
70 return css::uno::Sequence<sal_Int8>();
74 Reference< XInterface > SAL_CALL OControlFontDialog::Create( const Reference< XComponentContext >& _rxContext )
76 return *( new OControlFontDialog( _rxContext ) );
80 OUString SAL_CALL OControlFontDialog::getImplementationName()
82 return getImplementationName_static();
86 OUString OControlFontDialog::getImplementationName_static()
88 return OUString("org.openoffice.comp.form.ui.OControlFontDialog");
92 css::uno::Sequence<OUString> SAL_CALL OControlFontDialog::getSupportedServiceNames()
94 return getSupportedServiceNames_static();
98 css::uno::Sequence<OUString> OControlFontDialog::getSupportedServiceNames_static()
100 css::uno::Sequence<OUString> aSupported { "com.sun.star.form.ControlFontDialog" };
101 return aSupported;
104 void OControlFontDialog::initialize( const Sequence< Any >& aArguments )
106 Reference<XPropertySet> xGridModel;
107 if (aArguments.getLength() == 1 && (aArguments[0] >>= xGridModel))
109 PropertyValue aArg;
110 aArg.Name = "IntrospectedObject";
111 aArg.Value <<= xGridModel;
112 Sequence< Any > aNewArguments(1);
113 aNewArguments[0] <<= aArg;
114 OControlFontDialog_DBase::initialize(aNewArguments);
116 else
117 OControlFontDialog_DBase::initialize(aArguments);
121 Reference<XPropertySetInfo> SAL_CALL OControlFontDialog::getPropertySetInfo()
123 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
124 return xInfo;
128 ::cppu::IPropertyArrayHelper& OControlFontDialog::getInfoHelper()
130 return *getArrayHelper();
134 ::cppu::IPropertyArrayHelper* OControlFontDialog::createArrayHelper( ) const
136 Sequence< Property > aProps;
137 describeProperties(aProps);
138 return new ::cppu::OPropertyArrayHelper(aProps);
142 VclPtr<Dialog> OControlFontDialog::createDialog(vcl::Window* _pParent)
144 ControlCharacterDialog::createItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
146 OSL_ENSURE(m_xControlModel.is(), "OControlFontDialog::createDialog: no introspectee set!");
147 if (m_xControlModel.is())
148 ControlCharacterDialog::translatePropertiesToItems(m_xControlModel, m_pFontItems);
149 // TODO: we need a mechanism to prevent that somebody creates us, sets an introspectee, executes us,
150 // sets a new introspectee and re-executes us. In this case, the dialog returned here (upon the first
151 // execute) will be re-used upon the second execute, and thus it won't be initialized correctly.
153 return VclPtr<ControlCharacterDialog>::Create(_pParent, *m_pFontItems);
156 void OControlFontDialog::executedDialog(sal_Int16 _nExecutionResult)
158 OSL_ENSURE(m_pDialog, "OControlFontDialog::executedDialog: no dialog anymore?!!");
159 if (m_pDialog && (RET_OK == _nExecutionResult) && m_xControlModel.is())
161 const SfxItemSet* pOutput = static_cast<ControlCharacterDialog*>(m_pDialog.get())->GetOutputItemSet();
162 if (pOutput)
163 ControlCharacterDialog::translateItemsToProperties( *pOutput, m_xControlModel );
168 } // namespace pcr
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */