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