1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "udlg_module.hxx"
25 #include "roadmapskeleton.hxx"
26 
27 /** === begin UNO includes === **/
28 /** === end UNO includes === **/
29 
30 #include <comphelper/componentcontext.hxx>
31 #include "svtools/genericunodialog.hxx"
32 
33 //........................................................................
34 namespace udlg
35 {
36 //........................................................................
37 
38 	/** === begin UNO using === **/
39 	using ::com::sun::star::uno::Reference;
40 	using ::com::sun::star::uno::XInterface;
41 	using ::com::sun::star::uno::UNO_QUERY;
42 	using ::com::sun::star::uno::UNO_QUERY_THROW;
43 	using ::com::sun::star::uno::UNO_SET_THROW;
44 	using ::com::sun::star::uno::Exception;
45 	using ::com::sun::star::uno::RuntimeException;
46 	using ::com::sun::star::uno::Any;
47 	using ::com::sun::star::uno::makeAny;
48     using ::com::sun::star::uno::XComponentContext;
49     using ::com::sun::star::uno::Sequence;
50     using ::com::sun::star::beans::XPropertySetInfo;
51     using ::com::sun::star::beans::Property;
52 	/** === end UNO using === **/
53 
54 	//====================================================================
55 	//= UnoDialogSkeleton
56 	//====================================================================
57     class UnoDialogSkeleton;
58     typedef ::svt::OGenericUnoDialog                                                UnoDialogSkeleton_Base;
59     typedef ::comphelper::OPropertyArrayUsageHelper< UnoDialogSkeleton >  UnoDialogSkeleton_PBase;
60 
61     class UnoDialogSkeleton
62                 :public UnoDialogSkeleton_Base
63                 ,public UnoDialogSkeleton_PBase
64                 ,public UdlgClient
65     {
66     public:
67         UnoDialogSkeleton( const Reference< XComponentContext >& _rxContext );
68 
69         // XTypeProvider
70 		virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(RuntimeException);
71 
72 		// XServiceInfo
73 		virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException);
74         virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
75 
76 	    // XPropertySet
77 	    virtual Reference< XPropertySetInfo >  SAL_CALL getPropertySetInfo() throw(RuntimeException);
78 	    virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
79 
80 	    // OPropertyArrayUsageHelper
81 	    virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
82 
83         // helper for factories
84         static Reference< XInterface > SAL_CALL Create( const Reference< XComponentContext >& _rxContext );
85 		static ::rtl::OUString SAL_CALL getImplementationName_static() throw(RuntimeException);
86         static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static() throw(RuntimeException);
87 
88     protected:
89         ~UnoDialogSkeleton();
90 
91     protected:
92 		virtual Dialog*	createDialog( Window* _pParent );
93 	    virtual void destroyDialog();
94 
95     private:
96         ::comphelper::ComponentContext  m_aContext;
97     };
98 
99 	//====================================================================
100 	//= UnoDialogSkeleton
101 	//====================================================================
102 	//--------------------------------------------------------------------
UnoDialogSkeleton(const Reference<XComponentContext> & _rxContext)103     UnoDialogSkeleton::UnoDialogSkeleton( const Reference< XComponentContext >& _rxContext )
104         :UnoDialogSkeleton_Base( _rxContext )
105         ,m_aContext( _rxContext )
106     {
107     }
108 
109     //--------------------------------------------------------------------
~UnoDialogSkeleton()110     UnoDialogSkeleton::~UnoDialogSkeleton()
111     {
112         // we do this here cause the base class' call to destroyDialog won't reach us anymore : we're within an dtor,
113         // so this virtual-method-call the base class does does not work, we're already dead then ...
114         if ( m_pDialog )
115         {
116             ::osl::MutexGuard aGuard( m_aMutex );
117             if ( m_pDialog )
118                 destroyDialog();
119         }
120     }
121 
122     //--------------------------------------------------------------------
Create(const Reference<XComponentContext> & _rxContext)123     Reference< XInterface > SAL_CALL UnoDialogSkeleton::Create( const Reference< XComponentContext >& _rxContext )
124     {
125         return *(new UnoDialogSkeleton( _rxContext ) );
126     }
127 
128     //--------------------------------------------------------------------
createDialog(Window * _pParent)129 	Dialog*	UnoDialogSkeleton::createDialog( Window* _pParent )
130     {
131         return new RoadmapSkeletonDialog( m_aContext, _pParent );
132     }
133 
134     //--------------------------------------------------------------------
destroyDialog()135     void UnoDialogSkeleton::destroyDialog()
136     {
137 	    UnoDialogSkeleton_Base::destroyDialog();
138     }
139 
140     //--------------------------------------------------------------------
getImplementationId()141     Sequence< sal_Int8 > SAL_CALL UnoDialogSkeleton::getImplementationId() throw(RuntimeException)
142     {
143         static ::cppu::OImplementationId* pId = NULL;
144         if ( !pId )
145         {
146             ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
147             if ( !pId )
148             {
149                 static ::cppu::OImplementationId aId;
150                 pId = &aId;
151             }
152         }
153         return pId->getImplementationId();
154     }
155 
156     //--------------------------------------------------------------------
getImplementationName_static()157     ::rtl::OUString SAL_CALL UnoDialogSkeleton::getImplementationName_static() throw(RuntimeException)
158     {
159         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.workben.UnoDialogSkeleton" ) );
160     }
161 
162     //--------------------------------------------------------------------
getSupportedServiceNames_static()163     Sequence< ::rtl::OUString > SAL_CALL UnoDialogSkeleton::getSupportedServiceNames_static() throw(RuntimeException)
164     {
165         Sequence< ::rtl::OUString > aServices(1);
166         aServices[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.example.UnoDialogSample" ) );
167         return aServices;
168     }
169 
170     //--------------------------------------------------------------------
getImplementationName()171     ::rtl::OUString SAL_CALL UnoDialogSkeleton::getImplementationName() throw(RuntimeException)
172     {
173         return getImplementationName_static();
174     }
175 
176     //--------------------------------------------------------------------
getSupportedServiceNames()177     Sequence< ::rtl::OUString > SAL_CALL UnoDialogSkeleton::getSupportedServiceNames() throw(RuntimeException)
178     {
179         return getSupportedServiceNames_static();
180     }
181 
182     //--------------------------------------------------------------------
getPropertySetInfo()183 	Reference< XPropertySetInfo > SAL_CALL UnoDialogSkeleton::getPropertySetInfo() throw(RuntimeException)
184     {
185 	    return createPropertySetInfo( getInfoHelper() );
186     }
187 
188     //--------------------------------------------------------------------
getInfoHelper()189 	::cppu::IPropertyArrayHelper& SAL_CALL UnoDialogSkeleton::getInfoHelper()
190     {
191     	return *const_cast< UnoDialogSkeleton* >( this )->getArrayHelper();
192     }
193 
194     //--------------------------------------------------------------------
createArrayHelper() const195 	::cppu::IPropertyArrayHelper* UnoDialogSkeleton::createArrayHelper( ) const
196     {
197 	    Sequence< Property > aProps;
198 	    describeProperties( aProps );
199 	    return new ::cppu::OPropertyArrayHelper( aProps );
200     }
201 
202     //--------------------------------------------------------------------
createRegistryInfo_UnoDialogSkeleton()203     void createRegistryInfo_UnoDialogSkeleton()
204     {
205         static OAutoRegistration< UnoDialogSkeleton > aAutoRegistration;
206     }
207 
208 //........................................................................
209 } // namespace udlg
210 //........................................................................
211