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 #include "udlg_module.hxx" 29 #include "roadmapskeleton.hxx" 30 31 /** === begin UNO includes === **/ 32 /** === end UNO includes === **/ 33 34 #include <comphelper/componentcontext.hxx> 35 #include "svtools/genericunodialog.hxx" 36 37 //........................................................................ 38 namespace udlg 39 { 40 //........................................................................ 41 42 /** === begin UNO using === **/ 43 using ::com::sun::star::uno::Reference; 44 using ::com::sun::star::uno::XInterface; 45 using ::com::sun::star::uno::UNO_QUERY; 46 using ::com::sun::star::uno::UNO_QUERY_THROW; 47 using ::com::sun::star::uno::UNO_SET_THROW; 48 using ::com::sun::star::uno::Exception; 49 using ::com::sun::star::uno::RuntimeException; 50 using ::com::sun::star::uno::Any; 51 using ::com::sun::star::uno::makeAny; 52 using ::com::sun::star::uno::XComponentContext; 53 using ::com::sun::star::uno::Sequence; 54 using ::com::sun::star::beans::XPropertySetInfo; 55 using ::com::sun::star::beans::Property; 56 /** === end UNO using === **/ 57 58 //==================================================================== 59 //= UnoDialogSkeleton 60 //==================================================================== 61 class UnoDialogSkeleton; 62 typedef ::svt::OGenericUnoDialog UnoDialogSkeleton_Base; 63 typedef ::comphelper::OPropertyArrayUsageHelper< UnoDialogSkeleton > UnoDialogSkeleton_PBase; 64 65 class UnoDialogSkeleton 66 :public UnoDialogSkeleton_Base 67 ,public UnoDialogSkeleton_PBase 68 ,public UdlgClient 69 { 70 public: 71 UnoDialogSkeleton( const Reference< XComponentContext >& _rxContext ); 72 73 // XTypeProvider 74 virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(RuntimeException); 75 76 // XServiceInfo 77 virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException); 78 virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException); 79 80 // XPropertySet 81 virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(RuntimeException); 82 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 83 84 // OPropertyArrayUsageHelper 85 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 86 87 // helper for factories 88 static Reference< XInterface > SAL_CALL Create( const Reference< XComponentContext >& _rxContext ); 89 static ::rtl::OUString SAL_CALL getImplementationName_static() throw(RuntimeException); 90 static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static() throw(RuntimeException); 91 92 protected: 93 ~UnoDialogSkeleton(); 94 95 protected: 96 virtual Dialog* createDialog( Window* _pParent ); 97 virtual void destroyDialog(); 98 99 private: 100 ::comphelper::ComponentContext m_aContext; 101 }; 102 103 //==================================================================== 104 //= UnoDialogSkeleton 105 //==================================================================== 106 //-------------------------------------------------------------------- 107 UnoDialogSkeleton::UnoDialogSkeleton( const Reference< XComponentContext >& _rxContext ) 108 :UnoDialogSkeleton_Base( _rxContext ) 109 ,m_aContext( _rxContext ) 110 { 111 } 112 113 //-------------------------------------------------------------------- 114 UnoDialogSkeleton::~UnoDialogSkeleton() 115 { 116 // we do this here cause the base class' call to destroyDialog won't reach us anymore : we're within an dtor, 117 // so this virtual-method-call the base class does does not work, we're already dead then ... 118 if ( m_pDialog ) 119 { 120 ::osl::MutexGuard aGuard( m_aMutex ); 121 if ( m_pDialog ) 122 destroyDialog(); 123 } 124 } 125 126 //-------------------------------------------------------------------- 127 Reference< XInterface > SAL_CALL UnoDialogSkeleton::Create( const Reference< XComponentContext >& _rxContext ) 128 { 129 return *(new UnoDialogSkeleton( _rxContext ) ); 130 } 131 132 //-------------------------------------------------------------------- 133 Dialog* UnoDialogSkeleton::createDialog( Window* _pParent ) 134 { 135 return new RoadmapSkeletonDialog( m_aContext, _pParent ); 136 } 137 138 //-------------------------------------------------------------------- 139 void UnoDialogSkeleton::destroyDialog() 140 { 141 UnoDialogSkeleton_Base::destroyDialog(); 142 } 143 144 //-------------------------------------------------------------------- 145 Sequence< sal_Int8 > SAL_CALL UnoDialogSkeleton::getImplementationId() throw(RuntimeException) 146 { 147 static ::cppu::OImplementationId* pId = NULL; 148 if ( !pId ) 149 { 150 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 151 if ( !pId ) 152 { 153 static ::cppu::OImplementationId aId; 154 pId = &aId; 155 } 156 } 157 return pId->getImplementationId(); 158 } 159 160 //-------------------------------------------------------------------- 161 ::rtl::OUString SAL_CALL UnoDialogSkeleton::getImplementationName_static() throw(RuntimeException) 162 { 163 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.workben.UnoDialogSkeleton" ) ); 164 } 165 166 //-------------------------------------------------------------------- 167 Sequence< ::rtl::OUString > SAL_CALL UnoDialogSkeleton::getSupportedServiceNames_static() throw(RuntimeException) 168 { 169 Sequence< ::rtl::OUString > aServices(1); 170 aServices[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.example.UnoDialogSample" ) ); 171 return aServices; 172 } 173 174 //-------------------------------------------------------------------- 175 ::rtl::OUString SAL_CALL UnoDialogSkeleton::getImplementationName() throw(RuntimeException) 176 { 177 return getImplementationName_static(); 178 } 179 180 //-------------------------------------------------------------------- 181 Sequence< ::rtl::OUString > SAL_CALL UnoDialogSkeleton::getSupportedServiceNames() throw(RuntimeException) 182 { 183 return getSupportedServiceNames_static(); 184 } 185 186 //-------------------------------------------------------------------- 187 Reference< XPropertySetInfo > SAL_CALL UnoDialogSkeleton::getPropertySetInfo() throw(RuntimeException) 188 { 189 return createPropertySetInfo( getInfoHelper() ); 190 } 191 192 //-------------------------------------------------------------------- 193 ::cppu::IPropertyArrayHelper& SAL_CALL UnoDialogSkeleton::getInfoHelper() 194 { 195 return *const_cast< UnoDialogSkeleton* >( this )->getArrayHelper(); 196 } 197 198 //-------------------------------------------------------------------- 199 ::cppu::IPropertyArrayHelper* UnoDialogSkeleton::createArrayHelper( ) const 200 { 201 Sequence< Property > aProps; 202 describeProperties( aProps ); 203 return new ::cppu::OPropertyArrayHelper( aProps ); 204 } 205 206 //-------------------------------------------------------------------- 207 void createRegistryInfo_UnoDialogSkeleton() 208 { 209 static OAutoRegistration< UnoDialogSkeleton > aAutoRegistration; 210 } 211 212 //........................................................................ 213 } // namespace udlg 214 //........................................................................ 215