Bump for 3.6-28
[LibreOffice.git] / extensions / source / propctrlr / controlfontdialog.cxx
blob3919a0eace41774e893fc9486210d22a4395d17f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
30 #include "controlfontdialog.hxx"
31 #include <cppuhelper/typeprovider.hxx>
32 #include "fontdialog.hxx"
33 #include "formstrings.hxx"
34 #include "pcrcommon.hxx"
36 extern "C" void SAL_CALL createRegistryInfo_OControlFontDialog()
38 ::pcr::OAutoRegistration< ::pcr::OControlFontDialog > aAutoRegistration;
41 //........................................................................
42 namespace pcr
44 //........................................................................
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::lang;
48 using namespace ::com::sun::star::beans;
50 //====================================================================
51 //= OControlFontDialog
52 //====================================================================
53 //---------------------------------------------------------------------
54 OControlFontDialog::OControlFontDialog(const Reference< XComponentContext >& _rxContext )
55 :OGenericUnoDialog( _rxContext )
56 ,m_pFontItems(NULL)
57 ,m_pItemPool(NULL)
58 ,m_pItemPoolDefaults(NULL)
60 registerProperty(PROPERTY_INTROSPECTEDOBJECT, OWN_PROPERTY_ID_INTROSPECTEDOBJECT,
61 PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT,
62 &m_xControlModel, ::getCppuType(&m_xControlModel));
65 //---------------------------------------------------------------------
66 OControlFontDialog::~OControlFontDialog()
68 if (m_pDialog)
70 ::osl::MutexGuard aGuard(m_aMutex);
71 if (m_pDialog)
72 destroyDialog();
76 //---------------------------------------------------------------------
77 Sequence<sal_Int8> SAL_CALL OControlFontDialog::getImplementationId( ) throw(RuntimeException)
79 static ::cppu::OImplementationId aId;
80 return aId.getImplementationId();
83 //---------------------------------------------------------------------
84 Reference< XInterface > SAL_CALL OControlFontDialog::Create( const Reference< XComponentContext >& _rxContext )
86 return *( new OControlFontDialog( _rxContext ) );
89 //---------------------------------------------------------------------
90 ::rtl::OUString SAL_CALL OControlFontDialog::getImplementationName() throw(RuntimeException)
92 return getImplementationName_static();
95 //---------------------------------------------------------------------
96 ::rtl::OUString OControlFontDialog::getImplementationName_static() throw(RuntimeException)
98 return ::rtl::OUString("org.openoffice.comp.form.ui.OControlFontDialog");
101 //---------------------------------------------------------------------
102 ::comphelper::StringSequence SAL_CALL OControlFontDialog::getSupportedServiceNames() throw(RuntimeException)
104 return getSupportedServiceNames_static();
107 //---------------------------------------------------------------------
108 ::comphelper::StringSequence OControlFontDialog::getSupportedServiceNames_static() throw(RuntimeException)
110 ::comphelper::StringSequence aSupported(1);
111 aSupported.getArray()[0] = ::rtl::OUString("com.sun.star.form.ControlFontDialog");
112 return aSupported;
115 //---------------------------------------------------------------------
116 Reference<XPropertySetInfo> SAL_CALL OControlFontDialog::getPropertySetInfo() throw(RuntimeException)
118 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
119 return xInfo;
122 //---------------------------------------------------------------------
123 ::cppu::IPropertyArrayHelper& OControlFontDialog::getInfoHelper()
125 return *const_cast<OControlFontDialog*>(this)->getArrayHelper();
128 //--------------------------------------------------------------------------
129 ::cppu::IPropertyArrayHelper* OControlFontDialog::createArrayHelper( ) const
131 Sequence< Property > aProps;
132 describeProperties(aProps);
133 return new ::cppu::OPropertyArrayHelper(aProps);
136 //--------------------------------------------------------------------------
137 Dialog* OControlFontDialog::createDialog(Window* _pParent)
139 ControlCharacterDialog::createItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
141 OSL_ENSURE(m_xControlModel.is(), "OControlFontDialog::createDialog: no introspectee set!");
142 if (m_xControlModel.is())
143 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.
148 ControlCharacterDialog* pDialog = new ControlCharacterDialog(_pParent, *m_pFontItems);
149 return pDialog;
152 //-------------------------------------------------------------------------
153 void OControlFontDialog::destroyDialog()
155 OGenericUnoDialog::destroyDialog();
156 ControlCharacterDialog::destroyItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
159 //-------------------------------------------------------------------------
160 void OControlFontDialog::executedDialog(sal_Int16 _nExecutionResult)
162 OSL_ENSURE(m_pDialog, "OControlFontDialog::executedDialog: no dialog anymore?!!");
163 if (m_pDialog && (sal_True == _nExecutionResult) && m_xControlModel.is())
165 const SfxItemSet* pOutput = static_cast<ControlCharacterDialog*>(m_pDialog)->GetOutputItemSet();
166 if (pOutput)
167 ControlCharacterDialog::translateItemsToProperties( *pOutput, m_xControlModel );
171 //........................................................................
172 } // namespace pcr
173 //........................................................................
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */