1*2a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*2a97ec55SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*2a97ec55SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*2a97ec55SAndrew Rist * distributed with this work for additional information
6*2a97ec55SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*2a97ec55SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*2a97ec55SAndrew Rist * "License"); you may not use this file except in compliance
9*2a97ec55SAndrew Rist * with the License. You may obtain a copy of the License at
10*2a97ec55SAndrew Rist *
11*2a97ec55SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*2a97ec55SAndrew Rist *
13*2a97ec55SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*2a97ec55SAndrew Rist * software distributed under the License is distributed on an
15*2a97ec55SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2a97ec55SAndrew Rist * KIND, either express or implied. See the License for the
17*2a97ec55SAndrew Rist * specific language governing permissions and limitations
18*2a97ec55SAndrew Rist * under the License.
19*2a97ec55SAndrew Rist *
20*2a97ec55SAndrew Rist *************************************************************/
21*2a97ec55SAndrew Rist
22*2a97ec55SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #ifndef _EXTENSIONS_PROPCTRLR_FONTITEMIDS_HXX_
28cdf0e10cSrcweir #include "controlfontdialog.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
31cdf0e10cSrcweir #include "fontdialog.hxx"
32cdf0e10cSrcweir #include "formstrings.hxx"
33cdf0e10cSrcweir #include "pcrcommon.hxx"
34cdf0e10cSrcweir
createRegistryInfo_OControlFontDialog()35cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_OControlFontDialog()
36cdf0e10cSrcweir {
37cdf0e10cSrcweir ::pcr::OAutoRegistration< ::pcr::OControlFontDialog > aAutoRegistration;
38cdf0e10cSrcweir }
39cdf0e10cSrcweir
40cdf0e10cSrcweir //........................................................................
41cdf0e10cSrcweir namespace pcr
42cdf0e10cSrcweir {
43cdf0e10cSrcweir //........................................................................
44cdf0e10cSrcweir
45cdf0e10cSrcweir using namespace ::com::sun::star::uno;
46cdf0e10cSrcweir using namespace ::com::sun::star::lang;
47cdf0e10cSrcweir using namespace ::com::sun::star::beans;
48cdf0e10cSrcweir
49cdf0e10cSrcweir //====================================================================
50cdf0e10cSrcweir //= OControlFontDialog
51cdf0e10cSrcweir //====================================================================
52cdf0e10cSrcweir //---------------------------------------------------------------------
OControlFontDialog(const Reference<XComponentContext> & _rxContext)53cdf0e10cSrcweir OControlFontDialog::OControlFontDialog(const Reference< XComponentContext >& _rxContext )
54cdf0e10cSrcweir :OGenericUnoDialog( _rxContext )
55cdf0e10cSrcweir ,m_pFontItems(NULL)
56cdf0e10cSrcweir ,m_pItemPool(NULL)
57cdf0e10cSrcweir ,m_pItemPoolDefaults(NULL)
58cdf0e10cSrcweir {
59cdf0e10cSrcweir registerProperty(PROPERTY_INTROSPECTEDOBJECT, OWN_PROPERTY_ID_INTROSPECTEDOBJECT,
60cdf0e10cSrcweir PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT,
61cdf0e10cSrcweir &m_xControlModel, ::getCppuType(&m_xControlModel));
62cdf0e10cSrcweir }
63cdf0e10cSrcweir
64cdf0e10cSrcweir //---------------------------------------------------------------------
~OControlFontDialog()65cdf0e10cSrcweir OControlFontDialog::~OControlFontDialog()
66cdf0e10cSrcweir {
67cdf0e10cSrcweir if (m_pDialog)
68cdf0e10cSrcweir {
69cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex);
70cdf0e10cSrcweir if (m_pDialog)
71cdf0e10cSrcweir destroyDialog();
72cdf0e10cSrcweir }
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
75cdf0e10cSrcweir //---------------------------------------------------------------------
getImplementationId()76cdf0e10cSrcweir Sequence<sal_Int8> SAL_CALL OControlFontDialog::getImplementationId( ) throw(RuntimeException)
77cdf0e10cSrcweir {
78cdf0e10cSrcweir static ::cppu::OImplementationId aId;
79cdf0e10cSrcweir return aId.getImplementationId();
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
82cdf0e10cSrcweir //---------------------------------------------------------------------
Create(const Reference<XComponentContext> & _rxContext)83cdf0e10cSrcweir Reference< XInterface > SAL_CALL OControlFontDialog::Create( const Reference< XComponentContext >& _rxContext )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir return *( new OControlFontDialog( _rxContext ) );
86cdf0e10cSrcweir }
87cdf0e10cSrcweir
88cdf0e10cSrcweir //---------------------------------------------------------------------
getImplementationName()89cdf0e10cSrcweir ::rtl::OUString SAL_CALL OControlFontDialog::getImplementationName() throw(RuntimeException)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir return getImplementationName_static();
92cdf0e10cSrcweir }
93cdf0e10cSrcweir
94cdf0e10cSrcweir //---------------------------------------------------------------------
getImplementationName_static()95cdf0e10cSrcweir ::rtl::OUString OControlFontDialog::getImplementationName_static() throw(RuntimeException)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir return ::rtl::OUString::createFromAscii("org.openoffice.comp.form.ui.OControlFontDialog");
98cdf0e10cSrcweir }
99cdf0e10cSrcweir
100cdf0e10cSrcweir //---------------------------------------------------------------------
getSupportedServiceNames()101cdf0e10cSrcweir ::comphelper::StringSequence SAL_CALL OControlFontDialog::getSupportedServiceNames() throw(RuntimeException)
102cdf0e10cSrcweir {
103cdf0e10cSrcweir return getSupportedServiceNames_static();
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
106cdf0e10cSrcweir //---------------------------------------------------------------------
getSupportedServiceNames_static()107cdf0e10cSrcweir ::comphelper::StringSequence OControlFontDialog::getSupportedServiceNames_static() throw(RuntimeException)
108cdf0e10cSrcweir {
109cdf0e10cSrcweir ::comphelper::StringSequence aSupported(1);
110cdf0e10cSrcweir aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.form.ControlFontDialog");
111cdf0e10cSrcweir return aSupported;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
114cdf0e10cSrcweir //---------------------------------------------------------------------
getPropertySetInfo()115cdf0e10cSrcweir Reference<XPropertySetInfo> SAL_CALL OControlFontDialog::getPropertySetInfo() throw(RuntimeException)
116cdf0e10cSrcweir {
117cdf0e10cSrcweir Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
118cdf0e10cSrcweir return xInfo;
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
121cdf0e10cSrcweir //---------------------------------------------------------------------
getInfoHelper()122cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& OControlFontDialog::getInfoHelper()
123cdf0e10cSrcweir {
124cdf0e10cSrcweir return *const_cast<OControlFontDialog*>(this)->getArrayHelper();
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
127cdf0e10cSrcweir //--------------------------------------------------------------------------
createArrayHelper() const128cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* OControlFontDialog::createArrayHelper( ) const
129cdf0e10cSrcweir {
130cdf0e10cSrcweir Sequence< Property > aProps;
131cdf0e10cSrcweir describeProperties(aProps);
132cdf0e10cSrcweir return new ::cppu::OPropertyArrayHelper(aProps);
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
135cdf0e10cSrcweir //--------------------------------------------------------------------------
createDialog(Window * _pParent)136cdf0e10cSrcweir Dialog* OControlFontDialog::createDialog(Window* _pParent)
137cdf0e10cSrcweir {
138cdf0e10cSrcweir ControlCharacterDialog::createItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
139cdf0e10cSrcweir
140cdf0e10cSrcweir OSL_ENSURE(m_xControlModel.is(), "OControlFontDialog::createDialog: no introspectee set!");
141cdf0e10cSrcweir if (m_xControlModel.is())
142cdf0e10cSrcweir ControlCharacterDialog::translatePropertiesToItems(m_xControlModel, m_pFontItems);
143cdf0e10cSrcweir // TODO: we need a mechanism to prevent that somebody creates us, sets an introspectee, executes us,
144cdf0e10cSrcweir // sets a new introspectee and re-executes us. In this case, the dialog returned here (upon the first
145cdf0e10cSrcweir // execute) will be re-used upon the second execute, and thus it won't be initialized correctly.
146cdf0e10cSrcweir
147cdf0e10cSrcweir ControlCharacterDialog* pDialog = new ControlCharacterDialog(_pParent, *m_pFontItems);
148cdf0e10cSrcweir return pDialog;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir
151cdf0e10cSrcweir //-------------------------------------------------------------------------
destroyDialog()152cdf0e10cSrcweir void OControlFontDialog::destroyDialog()
153cdf0e10cSrcweir {
154cdf0e10cSrcweir OGenericUnoDialog::destroyDialog();
155cdf0e10cSrcweir ControlCharacterDialog::destroyItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
156cdf0e10cSrcweir }
157cdf0e10cSrcweir
158cdf0e10cSrcweir //-------------------------------------------------------------------------
executedDialog(sal_Int16 _nExecutionResult)159cdf0e10cSrcweir void OControlFontDialog::executedDialog(sal_Int16 _nExecutionResult)
160cdf0e10cSrcweir {
161cdf0e10cSrcweir OSL_ENSURE(m_pDialog, "OControlFontDialog::executedDialog: no dialog anymore?!!");
162cdf0e10cSrcweir if (m_pDialog && (sal_True == _nExecutionResult) && m_xControlModel.is())
163cdf0e10cSrcweir {
164cdf0e10cSrcweir const SfxItemSet* pOutput = static_cast<ControlCharacterDialog*>(m_pDialog)->GetOutputItemSet();
165cdf0e10cSrcweir if (pOutput)
166cdf0e10cSrcweir ControlCharacterDialog::translateItemsToProperties( *pOutput, m_xControlModel );
167cdf0e10cSrcweir }
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir //........................................................................
171cdf0e10cSrcweir } // namespace pcr
172cdf0e10cSrcweir //........................................................................
173cdf0e10cSrcweir
174