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