1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove
25*b1cdbd2cSJim Jagielski #include "precompiled_svtools.hxx"
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielski #include "svtools/genericunodialog.hxx"
28*b1cdbd2cSJim Jagielski
29*b1cdbd2cSJim Jagielski #include <com/sun/star/beans/NamedValue.hpp>
30*b1cdbd2cSJim Jagielski #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
31*b1cdbd2cSJim Jagielski
32*b1cdbd2cSJim Jagielski #include <toolkit/awt/vclxwindow.hxx>
33*b1cdbd2cSJim Jagielski #include <comphelper/extract.hxx>
34*b1cdbd2cSJim Jagielski #include <cppuhelper/typeprovider.hxx>
35*b1cdbd2cSJim Jagielski #include <comphelper/property.hxx>
36*b1cdbd2cSJim Jagielski #include <osl/diagnose.h>
37*b1cdbd2cSJim Jagielski #include <tools/diagnose_ex.h>
38*b1cdbd2cSJim Jagielski #include <vcl/msgbox.hxx>
39*b1cdbd2cSJim Jagielski #include <vos/mutex.hxx>
40*b1cdbd2cSJim Jagielski #include <vcl/svapp.hxx>
41*b1cdbd2cSJim Jagielski
42*b1cdbd2cSJim Jagielski using namespace ::comphelper;
43*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::uno;
44*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::lang;
45*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::beans;
46*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::ucb;
47*b1cdbd2cSJim Jagielski
48*b1cdbd2cSJim Jagielski //.........................................................................
49*b1cdbd2cSJim Jagielski namespace svt
50*b1cdbd2cSJim Jagielski {
51*b1cdbd2cSJim Jagielski //.........................................................................
52*b1cdbd2cSJim Jagielski
53*b1cdbd2cSJim Jagielski //=========================================================================
54*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
OGenericUnoDialog(const Reference<XMultiServiceFactory> & _rxORB)55*b1cdbd2cSJim Jagielski OGenericUnoDialog::OGenericUnoDialog(const Reference< XMultiServiceFactory >& _rxORB)
56*b1cdbd2cSJim Jagielski :OPropertyContainer(GetBroadcastHelper())
57*b1cdbd2cSJim Jagielski ,m_pDialog(NULL)
58*b1cdbd2cSJim Jagielski ,m_bExecuting(sal_False)
59*b1cdbd2cSJim Jagielski ,m_bCanceled(sal_False)
60*b1cdbd2cSJim Jagielski ,m_bTitleAmbiguous(sal_True)
61*b1cdbd2cSJim Jagielski ,m_bInitialized( false )
62*b1cdbd2cSJim Jagielski ,m_bNeedInitialization( false )
63*b1cdbd2cSJim Jagielski ,m_aContext( _rxORB )
64*b1cdbd2cSJim Jagielski {
65*b1cdbd2cSJim Jagielski registerProperty(::rtl::OUString::createFromAscii(UNODIALOG_PROPERTY_TITLE), UNODIALOG_PROPERTY_ID_TITLE, PropertyAttribute::TRANSIENT,
66*b1cdbd2cSJim Jagielski &m_sTitle, getCppuType(&m_sTitle));
67*b1cdbd2cSJim Jagielski registerProperty(::rtl::OUString::createFromAscii(UNODIALOG_PROPERTY_PARENT), UNODIALOG_PROPERTY_ID_PARENT, PropertyAttribute::TRANSIENT,
68*b1cdbd2cSJim Jagielski &m_xParent, getCppuType(&m_xParent));
69*b1cdbd2cSJim Jagielski }
70*b1cdbd2cSJim Jagielski
71*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
OGenericUnoDialog(const Reference<XComponentContext> & _rxContext)72*b1cdbd2cSJim Jagielski OGenericUnoDialog::OGenericUnoDialog(const Reference< XComponentContext >& _rxContext)
73*b1cdbd2cSJim Jagielski :OPropertyContainer(GetBroadcastHelper())
74*b1cdbd2cSJim Jagielski ,m_pDialog(NULL)
75*b1cdbd2cSJim Jagielski ,m_bExecuting(sal_False)
76*b1cdbd2cSJim Jagielski ,m_bCanceled(sal_False)
77*b1cdbd2cSJim Jagielski ,m_bTitleAmbiguous(sal_True)
78*b1cdbd2cSJim Jagielski ,m_bInitialized( false )
79*b1cdbd2cSJim Jagielski ,m_bNeedInitialization( false )
80*b1cdbd2cSJim Jagielski ,m_aContext(_rxContext)
81*b1cdbd2cSJim Jagielski {
82*b1cdbd2cSJim Jagielski registerProperty(::rtl::OUString::createFromAscii(UNODIALOG_PROPERTY_TITLE), UNODIALOG_PROPERTY_ID_TITLE, PropertyAttribute::TRANSIENT,
83*b1cdbd2cSJim Jagielski &m_sTitle, getCppuType(&m_sTitle));
84*b1cdbd2cSJim Jagielski registerProperty(::rtl::OUString::createFromAscii(UNODIALOG_PROPERTY_PARENT), UNODIALOG_PROPERTY_ID_PARENT, PropertyAttribute::TRANSIENT,
85*b1cdbd2cSJim Jagielski &m_xParent, getCppuType(&m_xParent));
86*b1cdbd2cSJim Jagielski }
87*b1cdbd2cSJim Jagielski
88*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
~OGenericUnoDialog()89*b1cdbd2cSJim Jagielski OGenericUnoDialog::~OGenericUnoDialog()
90*b1cdbd2cSJim Jagielski {
91*b1cdbd2cSJim Jagielski if ( m_pDialog )
92*b1cdbd2cSJim Jagielski {
93*b1cdbd2cSJim Jagielski ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
94*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
95*b1cdbd2cSJim Jagielski if ( m_pDialog )
96*b1cdbd2cSJim Jagielski destroyDialog();
97*b1cdbd2cSJim Jagielski }
98*b1cdbd2cSJim Jagielski }
99*b1cdbd2cSJim Jagielski
100*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
queryInterface(const Type & _rType)101*b1cdbd2cSJim Jagielski Any SAL_CALL OGenericUnoDialog::queryInterface(const Type& _rType) throw (RuntimeException)
102*b1cdbd2cSJim Jagielski {
103*b1cdbd2cSJim Jagielski Any aReturn = OGenericUnoDialogBase::queryInterface(_rType);
104*b1cdbd2cSJim Jagielski
105*b1cdbd2cSJim Jagielski if (!aReturn.hasValue())
106*b1cdbd2cSJim Jagielski aReturn = ::cppu::queryInterface(_rType
107*b1cdbd2cSJim Jagielski ,static_cast<XPropertySet*>(this)
108*b1cdbd2cSJim Jagielski ,static_cast<XMultiPropertySet*>(this)
109*b1cdbd2cSJim Jagielski ,static_cast<XFastPropertySet*>(this)
110*b1cdbd2cSJim Jagielski );
111*b1cdbd2cSJim Jagielski
112*b1cdbd2cSJim Jagielski return aReturn;
113*b1cdbd2cSJim Jagielski }
114*b1cdbd2cSJim Jagielski
115*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
getTypes()116*b1cdbd2cSJim Jagielski Sequence<Type> SAL_CALL OGenericUnoDialog::getTypes( ) throw(RuntimeException)
117*b1cdbd2cSJim Jagielski {
118*b1cdbd2cSJim Jagielski return ::comphelper::concatSequences(
119*b1cdbd2cSJim Jagielski OGenericUnoDialogBase::getTypes(),
120*b1cdbd2cSJim Jagielski ::comphelper::OPropertyContainer::getTypes()
121*b1cdbd2cSJim Jagielski );
122*b1cdbd2cSJim Jagielski }
123*b1cdbd2cSJim Jagielski
124*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
getImplementationId()125*b1cdbd2cSJim Jagielski Sequence<sal_Int8> SAL_CALL OGenericUnoDialog::getImplementationId( ) throw(RuntimeException)
126*b1cdbd2cSJim Jagielski {
127*b1cdbd2cSJim Jagielski static ::cppu::OImplementationId aId;
128*b1cdbd2cSJim Jagielski return aId.getImplementationId();
129*b1cdbd2cSJim Jagielski }
130*b1cdbd2cSJim Jagielski
131*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
supportsService(const::rtl::OUString & ServiceName)132*b1cdbd2cSJim Jagielski sal_Bool SAL_CALL OGenericUnoDialog::supportsService(const ::rtl::OUString& ServiceName) throw(RuntimeException)
133*b1cdbd2cSJim Jagielski {
134*b1cdbd2cSJim Jagielski Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
135*b1cdbd2cSJim Jagielski const ::rtl::OUString* pArray = aSupported.getConstArray();
136*b1cdbd2cSJim Jagielski for (sal_Int32 i = 0; i < aSupported.getLength(); ++i, ++pArray)
137*b1cdbd2cSJim Jagielski if (pArray->equals(ServiceName))
138*b1cdbd2cSJim Jagielski return sal_True;
139*b1cdbd2cSJim Jagielski return sal_False;
140*b1cdbd2cSJim Jagielski }
141*b1cdbd2cSJim Jagielski
142*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any & rValue)143*b1cdbd2cSJim Jagielski void OGenericUnoDialog::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw(Exception)
144*b1cdbd2cSJim Jagielski {
145*b1cdbd2cSJim Jagielski // TODO : need some handling if we're currently executing ...
146*b1cdbd2cSJim Jagielski
147*b1cdbd2cSJim Jagielski OPropertyContainer::setFastPropertyValue_NoBroadcast(nHandle, rValue);
148*b1cdbd2cSJim Jagielski
149*b1cdbd2cSJim Jagielski if (UNODIALOG_PROPERTY_ID_TITLE == nHandle)
150*b1cdbd2cSJim Jagielski {
151*b1cdbd2cSJim Jagielski // from now on m_sTitle is valid
152*b1cdbd2cSJim Jagielski m_bTitleAmbiguous = sal_False;
153*b1cdbd2cSJim Jagielski
154*b1cdbd2cSJim Jagielski if (m_pDialog)
155*b1cdbd2cSJim Jagielski m_pDialog->SetText(String(m_sTitle));
156*b1cdbd2cSJim Jagielski }
157*b1cdbd2cSJim Jagielski }
158*b1cdbd2cSJim Jagielski
159*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
convertFastPropertyValue(Any & rConvertedValue,Any & rOldValue,sal_Int32 nHandle,const Any & rValue)160*b1cdbd2cSJim Jagielski sal_Bool OGenericUnoDialog::convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue) throw(IllegalArgumentException)
161*b1cdbd2cSJim Jagielski {
162*b1cdbd2cSJim Jagielski switch (nHandle)
163*b1cdbd2cSJim Jagielski {
164*b1cdbd2cSJim Jagielski case UNODIALOG_PROPERTY_ID_PARENT:
165*b1cdbd2cSJim Jagielski {
166*b1cdbd2cSJim Jagielski Reference<starawt::XWindow> xNew;
167*b1cdbd2cSJim Jagielski ::cppu::extractInterface(xNew, rValue);
168*b1cdbd2cSJim Jagielski if (xNew != m_xParent)
169*b1cdbd2cSJim Jagielski {
170*b1cdbd2cSJim Jagielski rConvertedValue <<= xNew;
171*b1cdbd2cSJim Jagielski rOldValue <<= m_xParent;
172*b1cdbd2cSJim Jagielski return sal_True;
173*b1cdbd2cSJim Jagielski }
174*b1cdbd2cSJim Jagielski return sal_False;
175*b1cdbd2cSJim Jagielski }
176*b1cdbd2cSJim Jagielski }
177*b1cdbd2cSJim Jagielski return OPropertyContainer::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue);
178*b1cdbd2cSJim Jagielski }
179*b1cdbd2cSJim Jagielski
180*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
setTitle(const::rtl::OUString & _rTitle)181*b1cdbd2cSJim Jagielski void SAL_CALL OGenericUnoDialog::setTitle( const ::rtl::OUString& _rTitle ) throw(RuntimeException)
182*b1cdbd2cSJim Jagielski {
183*b1cdbd2cSJim Jagielski UnoDialogEntryGuard aGuard( *this );
184*b1cdbd2cSJim Jagielski
185*b1cdbd2cSJim Jagielski try
186*b1cdbd2cSJim Jagielski {
187*b1cdbd2cSJim Jagielski setPropertyValue(::rtl::OUString::createFromAscii(UNODIALOG_PROPERTY_TITLE), makeAny(_rTitle));
188*b1cdbd2cSJim Jagielski }
189*b1cdbd2cSJim Jagielski catch(RuntimeException&)
190*b1cdbd2cSJim Jagielski {
191*b1cdbd2cSJim Jagielski // allowed to pass
192*b1cdbd2cSJim Jagielski throw;
193*b1cdbd2cSJim Jagielski }
194*b1cdbd2cSJim Jagielski catch( const Exception& )
195*b1cdbd2cSJim Jagielski {
196*b1cdbd2cSJim Jagielski DBG_UNHANDLED_EXCEPTION();
197*b1cdbd2cSJim Jagielski // not allowed to pass
198*b1cdbd2cSJim Jagielski }
199*b1cdbd2cSJim Jagielski }
200*b1cdbd2cSJim Jagielski
201*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
impl_ensureDialog_lck()202*b1cdbd2cSJim Jagielski bool OGenericUnoDialog::impl_ensureDialog_lck()
203*b1cdbd2cSJim Jagielski {
204*b1cdbd2cSJim Jagielski if ( m_pDialog )
205*b1cdbd2cSJim Jagielski return true;
206*b1cdbd2cSJim Jagielski
207*b1cdbd2cSJim Jagielski // get the parameters for the dialog from the current settings
208*b1cdbd2cSJim Jagielski
209*b1cdbd2cSJim Jagielski // the parent window
210*b1cdbd2cSJim Jagielski Window* pParent = NULL;
211*b1cdbd2cSJim Jagielski VCLXWindow* pImplementation = VCLXWindow::GetImplementation(m_xParent);
212*b1cdbd2cSJim Jagielski if (pImplementation)
213*b1cdbd2cSJim Jagielski pParent = pImplementation->GetWindow();
214*b1cdbd2cSJim Jagielski
215*b1cdbd2cSJim Jagielski // the title
216*b1cdbd2cSJim Jagielski String sTitle = m_sTitle;
217*b1cdbd2cSJim Jagielski
218*b1cdbd2cSJim Jagielski Dialog* pDialog = createDialog( pParent );
219*b1cdbd2cSJim Jagielski OSL_ENSURE( pDialog, "OGenericUnoDialog::impl_ensureDialog_lck: createDialog returned nonsense!" );
220*b1cdbd2cSJim Jagielski if ( !pDialog )
221*b1cdbd2cSJim Jagielski return false;
222*b1cdbd2cSJim Jagielski
223*b1cdbd2cSJim Jagielski // do some initialisations
224*b1cdbd2cSJim Jagielski if ( !m_bTitleAmbiguous )
225*b1cdbd2cSJim Jagielski pDialog->SetText( sTitle );
226*b1cdbd2cSJim Jagielski
227*b1cdbd2cSJim Jagielski // be notified when the dialog is killed by somebody else
228*b1cdbd2cSJim Jagielski // #i65958# / 2006-07-07 / frank.schoenheit@sun.com
229*b1cdbd2cSJim Jagielski pDialog->AddEventListener( LINK( this, OGenericUnoDialog, OnDialogDying ) );
230*b1cdbd2cSJim Jagielski
231*b1cdbd2cSJim Jagielski m_pDialog = pDialog;
232*b1cdbd2cSJim Jagielski
233*b1cdbd2cSJim Jagielski return true;
234*b1cdbd2cSJim Jagielski }
235*b1cdbd2cSJim Jagielski
236*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
execute()237*b1cdbd2cSJim Jagielski sal_Int16 SAL_CALL OGenericUnoDialog::execute( ) throw(RuntimeException)
238*b1cdbd2cSJim Jagielski {
239*b1cdbd2cSJim Jagielski // both creation and execution of the dialog must be guarded with the SolarMutex, so be generous here
240*b1cdbd2cSJim Jagielski ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
241*b1cdbd2cSJim Jagielski
242*b1cdbd2cSJim Jagielski Dialog* pDialogToExecute = NULL;
243*b1cdbd2cSJim Jagielski // create the dialog, if neccessary
244*b1cdbd2cSJim Jagielski {
245*b1cdbd2cSJim Jagielski UnoDialogEntryGuard aGuard( *this );
246*b1cdbd2cSJim Jagielski
247*b1cdbd2cSJim Jagielski if (m_bExecuting)
248*b1cdbd2cSJim Jagielski throw RuntimeException(
249*b1cdbd2cSJim Jagielski ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "already executing the dialog (recursive call)" ) ),
250*b1cdbd2cSJim Jagielski *this
251*b1cdbd2cSJim Jagielski );
252*b1cdbd2cSJim Jagielski
253*b1cdbd2cSJim Jagielski m_bCanceled = sal_False;
254*b1cdbd2cSJim Jagielski m_bExecuting = sal_True;
255*b1cdbd2cSJim Jagielski
256*b1cdbd2cSJim Jagielski if ( !impl_ensureDialog_lck() )
257*b1cdbd2cSJim Jagielski return 0;
258*b1cdbd2cSJim Jagielski
259*b1cdbd2cSJim Jagielski pDialogToExecute = m_pDialog;
260*b1cdbd2cSJim Jagielski }
261*b1cdbd2cSJim Jagielski
262*b1cdbd2cSJim Jagielski // start execution
263*b1cdbd2cSJim Jagielski sal_Int16 nReturn(0);
264*b1cdbd2cSJim Jagielski if ( pDialogToExecute )
265*b1cdbd2cSJim Jagielski nReturn = pDialogToExecute->Execute();
266*b1cdbd2cSJim Jagielski
267*b1cdbd2cSJim Jagielski {
268*b1cdbd2cSJim Jagielski ::osl::MutexGuard aExecutionGuard(m_aExecutionMutex);
269*b1cdbd2cSJim Jagielski if (m_bCanceled)
270*b1cdbd2cSJim Jagielski nReturn = RET_CANCEL;
271*b1cdbd2cSJim Jagielski }
272*b1cdbd2cSJim Jagielski
273*b1cdbd2cSJim Jagielski {
274*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard(m_aMutex);
275*b1cdbd2cSJim Jagielski
276*b1cdbd2cSJim Jagielski // get the settings of the dialog
277*b1cdbd2cSJim Jagielski executedDialog( nReturn );
278*b1cdbd2cSJim Jagielski
279*b1cdbd2cSJim Jagielski m_bExecuting = sal_False;
280*b1cdbd2cSJim Jagielski }
281*b1cdbd2cSJim Jagielski
282*b1cdbd2cSJim Jagielski // outta here
283*b1cdbd2cSJim Jagielski return nReturn;
284*b1cdbd2cSJim Jagielski }
285*b1cdbd2cSJim Jagielski
286*b1cdbd2cSJim Jagielski #ifdef AWT_DIALOG
287*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
endExecute()288*b1cdbd2cSJim Jagielski void SAL_CALL OGenericUnoDialog::endExecute( ) throw(RuntimeException)
289*b1cdbd2cSJim Jagielski {
290*b1cdbd2cSJim Jagielski UnoDialogEntryGuard aGuard( *this );
291*b1cdbd2cSJim Jagielski if (!m_bExecuting)
292*b1cdbd2cSJim Jagielski throw RuntimeException();
293*b1cdbd2cSJim Jagielski
294*b1cdbd2cSJim Jagielski {
295*b1cdbd2cSJim Jagielski ::osl::MutexGuard aExecutionGuard(m_aExecutionMutex);
296*b1cdbd2cSJim Jagielski OSL_ENSURE(m_pDialog, "OGenericUnoDialog::endExecute : executing which dialog ?");
297*b1cdbd2cSJim Jagielski // m_bExecuting is true but we have no dialog ?
298*b1cdbd2cSJim Jagielski if (!m_pDialog)
299*b1cdbd2cSJim Jagielski throw RuntimeException();
300*b1cdbd2cSJim Jagielski
301*b1cdbd2cSJim Jagielski if (!m_pDialog->IsInExecute())
302*b1cdbd2cSJim Jagielski // we tighly missed it ... another thread finished the execution of the dialog,
303*b1cdbd2cSJim Jagielski // but did not manage it to reset m_bExecuting, it currently tries to acquire
304*b1cdbd2cSJim Jagielski // m_aMutex or m_aExecutionMutex
305*b1cdbd2cSJim Jagielski // => nothing to do
306*b1cdbd2cSJim Jagielski return;
307*b1cdbd2cSJim Jagielski
308*b1cdbd2cSJim Jagielski m_pDialog->EndDialog(RET_CANCEL);
309*b1cdbd2cSJim Jagielski m_bCanceled = sal_True;
310*b1cdbd2cSJim Jagielski }
311*b1cdbd2cSJim Jagielski }
312*b1cdbd2cSJim Jagielski #endif
313*b1cdbd2cSJim Jagielski
314*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
implInitialize(const Any & _rValue)315*b1cdbd2cSJim Jagielski void OGenericUnoDialog::implInitialize(const Any& _rValue)
316*b1cdbd2cSJim Jagielski {
317*b1cdbd2cSJim Jagielski try
318*b1cdbd2cSJim Jagielski {
319*b1cdbd2cSJim Jagielski PropertyValue aProperty;
320*b1cdbd2cSJim Jagielski NamedValue aValue;
321*b1cdbd2cSJim Jagielski if ( _rValue >>= aProperty )
322*b1cdbd2cSJim Jagielski {
323*b1cdbd2cSJim Jagielski setPropertyValue( aProperty.Name, aProperty.Value );
324*b1cdbd2cSJim Jagielski }
325*b1cdbd2cSJim Jagielski else if ( _rValue >>= aValue )
326*b1cdbd2cSJim Jagielski {
327*b1cdbd2cSJim Jagielski setPropertyValue( aValue.Name, aValue.Value );
328*b1cdbd2cSJim Jagielski }
329*b1cdbd2cSJim Jagielski }
330*b1cdbd2cSJim Jagielski catch(const Exception&)
331*b1cdbd2cSJim Jagielski {
332*b1cdbd2cSJim Jagielski DBG_UNHANDLED_EXCEPTION();
333*b1cdbd2cSJim Jagielski }
334*b1cdbd2cSJim Jagielski }
335*b1cdbd2cSJim Jagielski
336*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
initialize(const Sequence<Any> & aArguments)337*b1cdbd2cSJim Jagielski void SAL_CALL OGenericUnoDialog::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException)
338*b1cdbd2cSJim Jagielski {
339*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
340*b1cdbd2cSJim Jagielski if ( m_bInitialized )
341*b1cdbd2cSJim Jagielski throw AlreadyInitializedException( ::rtl::OUString(), *this );
342*b1cdbd2cSJim Jagielski
343*b1cdbd2cSJim Jagielski const Any* pArguments = aArguments.getConstArray();
344*b1cdbd2cSJim Jagielski for (sal_Int32 i=0; i<aArguments.getLength(); ++i, ++pArguments)
345*b1cdbd2cSJim Jagielski implInitialize(*pArguments);
346*b1cdbd2cSJim Jagielski
347*b1cdbd2cSJim Jagielski m_bInitialized = true;
348*b1cdbd2cSJim Jagielski }
349*b1cdbd2cSJim Jagielski
350*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
destroyDialog()351*b1cdbd2cSJim Jagielski void OGenericUnoDialog::destroyDialog()
352*b1cdbd2cSJim Jagielski {
353*b1cdbd2cSJim Jagielski delete m_pDialog;
354*b1cdbd2cSJim Jagielski m_pDialog = NULL;
355*b1cdbd2cSJim Jagielski }
356*b1cdbd2cSJim Jagielski
357*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------------
IMPL_LINK(OGenericUnoDialog,OnDialogDying,VclWindowEvent *,_pEvent)358*b1cdbd2cSJim Jagielski IMPL_LINK( OGenericUnoDialog, OnDialogDying, VclWindowEvent*, _pEvent )
359*b1cdbd2cSJim Jagielski {
360*b1cdbd2cSJim Jagielski OSL_ENSURE( _pEvent->GetWindow() == m_pDialog, "OGenericUnoDialog::OnDialogDying: where does this come from?" );
361*b1cdbd2cSJim Jagielski if ( _pEvent->GetId() == VCLEVENT_OBJECT_DYING )
362*b1cdbd2cSJim Jagielski m_pDialog = NULL;
363*b1cdbd2cSJim Jagielski return 0L;
364*b1cdbd2cSJim Jagielski }
365*b1cdbd2cSJim Jagielski
366*b1cdbd2cSJim Jagielski //.........................................................................
367*b1cdbd2cSJim Jagielski } // namespace svt
368*b1cdbd2cSJim Jagielski //.........................................................................
369*b1cdbd2cSJim Jagielski
370