Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "controlfontdialog.hxx"
31 : : #include <cppuhelper/typeprovider.hxx>
32 : : #include "fontdialog.hxx"
33 : : #include "formstrings.hxx"
34 : : #include "pcrcommon.hxx"
35 : :
36 : 0 : extern "C" void SAL_CALL createRegistryInfo_OControlFontDialog()
37 : : {
38 : 0 : ::pcr::OAutoRegistration< ::pcr::OControlFontDialog > aAutoRegistration;
39 : 0 : }
40 : :
41 : : //........................................................................
42 : : namespace pcr
43 : : {
44 : : //........................................................................
45 : :
46 : : using namespace ::com::sun::star::uno;
47 : : using namespace ::com::sun::star::lang;
48 : : using namespace ::com::sun::star::beans;
49 : :
50 : : //====================================================================
51 : : //= OControlFontDialog
52 : : //====================================================================
53 : : //---------------------------------------------------------------------
54 : 0 : OControlFontDialog::OControlFontDialog(const Reference< XComponentContext >& _rxContext )
55 : : :OGenericUnoDialog( _rxContext )
56 : : ,m_pFontItems(NULL)
57 : : ,m_pItemPool(NULL)
58 : 0 : ,m_pItemPoolDefaults(NULL)
59 : : {
60 : : registerProperty(PROPERTY_INTROSPECTEDOBJECT, OWN_PROPERTY_ID_INTROSPECTEDOBJECT,
61 : : PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT,
62 : 0 : &m_xControlModel, ::getCppuType(&m_xControlModel));
63 : 0 : }
64 : :
65 : : //---------------------------------------------------------------------
66 : 0 : OControlFontDialog::~OControlFontDialog()
67 : : {
68 : 0 : if (m_pDialog)
69 : : {
70 : 0 : ::osl::MutexGuard aGuard(m_aMutex);
71 : 0 : if (m_pDialog)
72 : 0 : destroyDialog();
73 : : }
74 : 0 : }
75 : :
76 : : //---------------------------------------------------------------------
77 : 0 : Sequence<sal_Int8> SAL_CALL OControlFontDialog::getImplementationId( ) throw(RuntimeException)
78 : : {
79 : 0 : static ::cppu::OImplementationId aId;
80 : 0 : return aId.getImplementationId();
81 : : }
82 : :
83 : : //---------------------------------------------------------------------
84 : 0 : Reference< XInterface > SAL_CALL OControlFontDialog::Create( const Reference< XComponentContext >& _rxContext )
85 : : {
86 : 0 : return *( new OControlFontDialog( _rxContext ) );
87 : : }
88 : :
89 : : //---------------------------------------------------------------------
90 : 0 : ::rtl::OUString SAL_CALL OControlFontDialog::getImplementationName() throw(RuntimeException)
91 : : {
92 : 0 : return getImplementationName_static();
93 : : }
94 : :
95 : : //---------------------------------------------------------------------
96 : 0 : ::rtl::OUString OControlFontDialog::getImplementationName_static() throw(RuntimeException)
97 : : {
98 : 0 : return ::rtl::OUString("org.openoffice.comp.form.ui.OControlFontDialog");
99 : : }
100 : :
101 : : //---------------------------------------------------------------------
102 : 0 : ::comphelper::StringSequence SAL_CALL OControlFontDialog::getSupportedServiceNames() throw(RuntimeException)
103 : : {
104 : 0 : return getSupportedServiceNames_static();
105 : : }
106 : :
107 : : //---------------------------------------------------------------------
108 : 0 : ::comphelper::StringSequence OControlFontDialog::getSupportedServiceNames_static() throw(RuntimeException)
109 : : {
110 : 0 : ::comphelper::StringSequence aSupported(1);
111 : 0 : aSupported.getArray()[0] = ::rtl::OUString("com.sun.star.form.ControlFontDialog");
112 : 0 : return aSupported;
113 : : }
114 : :
115 : : //---------------------------------------------------------------------
116 : 0 : Reference<XPropertySetInfo> SAL_CALL OControlFontDialog::getPropertySetInfo() throw(RuntimeException)
117 : : {
118 : 0 : Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
119 : 0 : return xInfo;
120 : : }
121 : :
122 : : //---------------------------------------------------------------------
123 : 0 : ::cppu::IPropertyArrayHelper& OControlFontDialog::getInfoHelper()
124 : : {
125 : 0 : return *const_cast<OControlFontDialog*>(this)->getArrayHelper();
126 : : }
127 : :
128 : : //--------------------------------------------------------------------------
129 : 0 : ::cppu::IPropertyArrayHelper* OControlFontDialog::createArrayHelper( ) const
130 : : {
131 : 0 : Sequence< Property > aProps;
132 : 0 : describeProperties(aProps);
133 : 0 : return new ::cppu::OPropertyArrayHelper(aProps);
134 : : }
135 : :
136 : : //--------------------------------------------------------------------------
137 : 0 : Dialog* OControlFontDialog::createDialog(Window* _pParent)
138 : : {
139 : 0 : ControlCharacterDialog::createItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
140 : :
141 : : OSL_ENSURE(m_xControlModel.is(), "OControlFontDialog::createDialog: no introspectee set!");
142 : 0 : if (m_xControlModel.is())
143 : 0 : ControlCharacterDialog::translatePropertiesToItems(m_xControlModel, m_pFontItems);
144 : : // TODO: we need a mechanism to prevent that somebody creates us, sets an introspectee, executes us,
145 : : // sets a new introspectee and re-executes us. In this case, the dialog returned here (upon the first
146 : : // execute) will be re-used upon the second execute, and thus it won't be initialized correctly.
147 : :
148 : 0 : ControlCharacterDialog* pDialog = new ControlCharacterDialog(_pParent, *m_pFontItems);
149 : 0 : return pDialog;
150 : : }
151 : :
152 : : //-------------------------------------------------------------------------
153 : 0 : void OControlFontDialog::destroyDialog()
154 : : {
155 : 0 : OGenericUnoDialog::destroyDialog();
156 : 0 : ControlCharacterDialog::destroyItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
157 : 0 : }
158 : :
159 : : //-------------------------------------------------------------------------
160 : 0 : void OControlFontDialog::executedDialog(sal_Int16 _nExecutionResult)
161 : : {
162 : : OSL_ENSURE(m_pDialog, "OControlFontDialog::executedDialog: no dialog anymore?!!");
163 : 0 : if (m_pDialog && (sal_True == _nExecutionResult) && m_xControlModel.is())
164 : : {
165 : 0 : const SfxItemSet* pOutput = static_cast<ControlCharacterDialog*>(m_pDialog)->GetOutputItemSet();
166 : 0 : if (pOutput)
167 : 0 : ControlCharacterDialog::translateItemsToProperties( *pOutput, m_xControlModel );
168 : : }
169 : 0 : }
170 : :
171 : : //........................................................................
172 : : } // namespace pcr
173 : : //........................................................................
174 : :
175 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|