Update ooo320-m1
[ooovba.git] / extensions / source / propctrlr / controlfontdialog.cxx
blob365ac57b6de0723243b6e40d269ab4cffcb189bf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: controlfontdialog.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
34 #ifndef _EXTENSIONS_PROPCTRLR_FONTITEMIDS_HXX_
35 #include "controlfontdialog.hxx"
36 #endif
37 #include <cppuhelper/typeprovider.hxx>
38 #include "fontdialog.hxx"
39 #include "formstrings.hxx"
40 #include "pcrcommon.hxx"
42 extern "C" void SAL_CALL createRegistryInfo_OControlFontDialog()
44 ::pcr::OAutoRegistration< ::pcr::OControlFontDialog > aAutoRegistration;
47 //........................................................................
48 namespace pcr
50 //........................................................................
52 using namespace ::com::sun::star::uno;
53 using namespace ::com::sun::star::lang;
54 using namespace ::com::sun::star::beans;
56 //====================================================================
57 //= OControlFontDialog
58 //====================================================================
59 //---------------------------------------------------------------------
60 OControlFontDialog::OControlFontDialog(const Reference< XComponentContext >& _rxContext )
61 :OGenericUnoDialog( _rxContext )
62 ,m_pFontItems(NULL)
63 ,m_pItemPool(NULL)
64 ,m_pItemPoolDefaults(NULL)
66 registerProperty(PROPERTY_INTROSPECTEDOBJECT, OWN_PROPERTY_ID_INTROSPECTEDOBJECT,
67 PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT,
68 &m_xControlModel, ::getCppuType(&m_xControlModel));
71 //---------------------------------------------------------------------
72 OControlFontDialog::~OControlFontDialog()
74 if (m_pDialog)
76 ::osl::MutexGuard aGuard(m_aMutex);
77 if (m_pDialog)
78 destroyDialog();
82 //---------------------------------------------------------------------
83 Sequence<sal_Int8> SAL_CALL OControlFontDialog::getImplementationId( ) throw(RuntimeException)
85 static ::cppu::OImplementationId aId;
86 return aId.getImplementationId();
89 //---------------------------------------------------------------------
90 Reference< XInterface > SAL_CALL OControlFontDialog::Create( const Reference< XComponentContext >& _rxContext )
92 return *( new OControlFontDialog( _rxContext ) );
95 //---------------------------------------------------------------------
96 ::rtl::OUString SAL_CALL OControlFontDialog::getImplementationName() throw(RuntimeException)
98 return getImplementationName_static();
101 //---------------------------------------------------------------------
102 ::rtl::OUString OControlFontDialog::getImplementationName_static() throw(RuntimeException)
104 return ::rtl::OUString::createFromAscii("org.openoffice.comp.form.ui.OControlFontDialog");
107 //---------------------------------------------------------------------
108 ::comphelper::StringSequence SAL_CALL OControlFontDialog::getSupportedServiceNames() throw(RuntimeException)
110 return getSupportedServiceNames_static();
113 //---------------------------------------------------------------------
114 ::comphelper::StringSequence OControlFontDialog::getSupportedServiceNames_static() throw(RuntimeException)
116 ::comphelper::StringSequence aSupported(1);
117 aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.form.ControlFontDialog");
118 return aSupported;
121 //---------------------------------------------------------------------
122 Reference<XPropertySetInfo> SAL_CALL OControlFontDialog::getPropertySetInfo() throw(RuntimeException)
124 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
125 return xInfo;
128 //---------------------------------------------------------------------
129 ::cppu::IPropertyArrayHelper& OControlFontDialog::getInfoHelper()
131 return *const_cast<OControlFontDialog*>(this)->getArrayHelper();
134 //--------------------------------------------------------------------------
135 ::cppu::IPropertyArrayHelper* OControlFontDialog::createArrayHelper( ) const
137 Sequence< Property > aProps;
138 describeProperties(aProps);
139 return new ::cppu::OPropertyArrayHelper(aProps);
142 //--------------------------------------------------------------------------
143 Dialog* OControlFontDialog::createDialog(Window* _pParent)
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);
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 ControlCharacterDialog* pDialog = new ControlCharacterDialog(_pParent, *m_pFontItems);
155 return pDialog;
158 //-------------------------------------------------------------------------
159 void OControlFontDialog::destroyDialog()
161 OGenericUnoDialog::destroyDialog();
162 ControlCharacterDialog::destroyItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
165 //-------------------------------------------------------------------------
166 void OControlFontDialog::executedDialog(sal_Int16 _nExecutionResult)
168 OSL_ENSURE(m_pDialog, "OControlFontDialog::executedDialog: no dialog anymore?!!");
169 if (m_pDialog && (sal_True == _nExecutionResult) && m_xControlModel.is())
171 const SfxItemSet* pOutput = static_cast<ControlCharacterDialog*>(m_pDialog)->GetOutputItemSet();
172 if (pOutput)
173 ControlCharacterDialog::translateItemsToProperties( *pOutput, m_xControlModel );
177 //........................................................................
178 } // namespace pcr
179 //........................................................................