1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "DialogModelProvider.hxx"
22 #include "dlgprov.hxx"
23 #include "dlgevtatt.hxx"
24 #include <com/sun/star/awt/UnoControlDialog.hpp>
25 #include <com/sun/star/awt/Toolkit.hpp>
26 #include <com/sun/star/awt/XControlContainer.hpp>
27 #include <com/sun/star/awt/XWindowPeer.hpp>
28 #include <com/sun/star/beans/theIntrospection.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/document/XEmbeddedScripts.hpp>
31 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
32 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
33 #include <com/sun/star/io/XInputStreamProvider.hpp>
34 #include <com/sun/star/resource/XStringResourceWithLocation.hpp>
35 #include <com/sun/star/resource/XStringResourceSupplier.hpp>
36 #include <com/sun/star/resource/XStringResourceManager.hpp>
37 #include <com/sun/star/script/XLibraryContainer.hpp>
38 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
39 #include <com/sun/star/uri/XUriReference.hpp>
40 #include <com/sun/star/uri/UriReferenceFactory.hpp>
41 #include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
42 #include <com/sun/star/uri/XVndSunStarExpandUrl.hpp>
43 #include <com/sun/star/util/theMacroExpander.hpp>
45 #include <cppuhelper/implementationentry.hxx>
46 #include <cppuhelper/exc_hlp.hxx>
47 #include <cppuhelper/supportsservice.hxx>
48 #include <sfx2/app.hxx>
49 #include <sfx2/objsh.hxx>
50 #include <xmlscript/xmldlg_imexp.hxx>
51 #include <tools/urlobj.hxx>
52 #include <comphelper/namedvaluecollection.hxx>
53 #include <util/MiscUtils.hxx>
54 #include <vcl/settings.hxx>
56 using namespace ::com::sun::star
;
60 using namespace script
;
61 using namespace beans
;
62 using namespace document
;
63 using namespace ::sf_misc
;
65 // component helper namespace
66 namespace comp_DialogModelProvider
69 OUString SAL_CALL
_getImplementationName()
71 return OUString("com.sun.star.comp.scripting.DialogModelProvider");
74 uno::Sequence
< OUString
> SAL_CALL
_getSupportedServiceNames()
76 uno::Sequence
< OUString
> s(1);
77 s
[0] = "com.sun.star.awt.UnoControlDialogModelProvider";
81 uno::Reference
< uno::XInterface
> SAL_CALL
_create(const uno::Reference
< uno::XComponentContext
> & context
)
83 return static_cast< ::cppu::OWeakObject
* >(new dlgprov::DialogModelProvider(context
));
85 } // closing component helper namespace
91 static const char aResourceResolverPropName
[] = "ResourceResolver";
93 Reference
< resource::XStringResourceManager
> lcl_getStringResourceManager(const Reference
< XComponentContext
>& i_xContext
,const OUString
& i_sURL
)
95 INetURLObject
aInetObj( i_sURL
);
96 OUString aDlgName
= aInetObj
.GetBase();
97 aInetObj
.removeSegment();
98 OUString aDlgLocation
= aInetObj
.GetMainURL( INetURLObject::NO_DECODE
);
99 bool bReadOnly
= true;
100 ::com::sun::star::lang::Locale aLocale
= Application::GetSettings().GetUILanguageTag().getLocale();
103 Sequence
<Any
> aArgs( 6 );
104 aArgs
[0] <<= aDlgLocation
;
105 aArgs
[1] <<= bReadOnly
;
106 aArgs
[2] <<= aLocale
;
107 aArgs
[3] <<= aDlgName
;
108 aArgs
[4] <<= aComment
;
110 Reference
< task::XInteractionHandler
> xDummyHandler
;
111 aArgs
[5] <<= xDummyHandler
;
112 Reference
< XMultiComponentFactory
> xSMgr_( i_xContext
->getServiceManager(), UNO_QUERY_THROW
);
114 Reference
< resource::XStringResourceManager
> xStringResourceManager( xSMgr_
->createInstanceWithContext
115 ( OUString("com.sun.star.resource.StringResourceWithLocation"),
116 i_xContext
), UNO_QUERY
);
117 if( xStringResourceManager
.is() )
119 Reference
< XInitialization
> xInit( xStringResourceManager
, UNO_QUERY
);
121 xInit
->initialize( aArgs
);
123 return xStringResourceManager
;
125 Reference
< container::XNameContainer
> lcl_createControlModel(const Reference
< XComponentContext
>& i_xContext
)
127 Reference
< XMultiComponentFactory
> xSMgr_( i_xContext
->getServiceManager(), UNO_QUERY_THROW
);
128 Reference
< container::XNameContainer
> xControlModel( xSMgr_
->createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", i_xContext
), UNO_QUERY_THROW
);
129 return xControlModel
;
131 Reference
< container::XNameContainer
> lcl_createDialogModel( const Reference
< XComponentContext
>& i_xContext
,
132 const Reference
< io::XInputStream
>& xInput
,
133 const Reference
< frame::XModel
>& xModel
,
134 const Reference
< resource::XStringResourceManager
>& xStringResourceManager
,
135 const Any
&aDialogSourceURL
) throw ( Exception
)
137 Reference
< container::XNameContainer
> xDialogModel( lcl_createControlModel(i_xContext
) );
139 OUString
aDlgSrcUrlPropName( "DialogSourceURL" );
140 Reference
< beans::XPropertySet
> xDlgPropSet( xDialogModel
, UNO_QUERY
);
141 xDlgPropSet
->setPropertyValue( aDlgSrcUrlPropName
, aDialogSourceURL
);
143 // #TODO we really need to detect the source of the Dialog, is it
144 // the dialog. E.g. if the dialog was created from basic ( then we just
145 // can't tell where its from )
146 // If we are happy to always substitute the form model for the awt
147 // one then maybe the presence of a document model is enough to trigger
148 // swapping out the models ( or perhaps we only want to do this
149 // for vba mode ) there are a number of feasible and valid possibilities
150 ::xmlscript::importDialogModel( xInput
, xDialogModel
, i_xContext
, xModel
);
152 // Set resource property
153 if( xStringResourceManager
.is() )
155 Reference
< beans::XPropertySet
> xDlgPSet( xDialogModel
, UNO_QUERY
);
156 Any aStringResourceManagerAny
;
157 aStringResourceManagerAny
<<= xStringResourceManager
;
158 xDlgPSet
->setPropertyValue( aResourceResolverPropName
, aStringResourceManagerAny
);
164 // component operations
167 static OUString
getImplementationName_DialogProviderImpl()
169 return OUString( "com.sun.star.comp.scripting.DialogProvider" );
174 static Sequence
< OUString
> getSupportedServiceNames_DialogProviderImpl()
176 Sequence
< OUString
> aNames(3);
177 aNames
[0] = "com.sun.star.awt.DialogProvider";
178 aNames
[1] = "com.sun.star.awt.DialogProvider2";
179 aNames
[2] = "com.sun.star.awt.ContainerWindowProvider";
188 ::osl::Mutex
& getMutex()
190 static ::osl::Mutex
* s_pMutex
= 0;
193 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
196 static ::osl::Mutex s_aMutex
;
197 s_pMutex
= &s_aMutex
;
205 // DialogProviderImpl
208 DialogProviderImpl::DialogProviderImpl( const Reference
< XComponentContext
>& rxContext
)
209 :m_xContext( rxContext
)
216 DialogProviderImpl::~DialogProviderImpl()
222 Reference
< resource::XStringResourceManager
> getStringResourceFromDialogLibrary
223 ( Reference
< container::XNameContainer
> xDialogLib
)
225 Reference
< resource::XStringResourceManager
> xStringResourceManager
;
226 if( xDialogLib
.is() )
228 Reference
< resource::XStringResourceSupplier
> xStringResourceSupplier( xDialogLib
, UNO_QUERY
);
229 if( xStringResourceSupplier
.is() )
231 Reference
< resource::XStringResourceResolver
>
232 xStringResourceResolver
= xStringResourceSupplier
->getStringResource();
234 xStringResourceManager
=
235 Reference
< resource::XStringResourceManager
>( xStringResourceResolver
, UNO_QUERY
);
238 return xStringResourceManager
;
241 Reference
< container::XNameContainer
> DialogProviderImpl::createDialogModel(
242 const Reference
< io::XInputStream
>& xInput
,
243 const Reference
< resource::XStringResourceManager
>& xStringResourceManager
,
244 const Any
&aDialogSourceURL
) throw ( Exception
)
246 return lcl_createDialogModel(m_xContext
,xInput
,m_xModel
,xStringResourceManager
,aDialogSourceURL
);
249 Reference
< XControlModel
> DialogProviderImpl::createDialogModelForBasic() throw ( Exception
)
251 if ( !m_BasicInfo
.get() )
253 throw RuntimeException("No information to create dialog" );
254 Reference
< resource::XStringResourceManager
> xStringResourceManager
= getStringResourceFromDialogLibrary( m_BasicInfo
->mxDlgLib
);
257 Any aDialogSourceURL
;
258 aDialogSourceURL
<<= aURL
;
259 Reference
< XControlModel
> xCtrlModel( createDialogModel( m_BasicInfo
->mxInput
, xStringResourceManager
, aDialogSourceURL
), UNO_QUERY_THROW
);
263 Reference
< XControlModel
> DialogProviderImpl::createDialogModel( const OUString
& sURL
)
266 OUString
aURL( sURL
);
269 // TODO: use URL parsing class
270 // TODO: decoding of location
272 Reference
< uri::XUriReferenceFactory
> xFac ( uri::UriReferenceFactory::create( m_xContext
) );
274 // i75778: Support non-script URLs
275 Reference
< io::XInputStream
> xInput
;
276 Reference
< container::XNameContainer
> xDialogLib
;
278 // Accept file URL to single dialog
279 bool bSingleDialog
= false;
281 Reference
< util::XMacroExpander
> xMacroExpander
=
282 util::theMacroExpander::get(m_xContext
);
284 Reference
< uri::XUriReference
> uriRef
;
287 uriRef
= Reference
< uri::XUriReference
>( xFac
->parse( aURL
), UNO_QUERY
);
290 OUString
errorMsg("DialogProviderImpl::getDialogModel: failed to parse URI: ");
292 throw IllegalArgumentException( errorMsg
,
293 Reference
< XInterface
>(), 1 );
295 Reference
< uri::XVndSunStarExpandUrl
> sxUri( uriRef
, UNO_QUERY
);
299 aURL
= sxUri
->expand( xMacroExpander
);
302 Reference
< uri::XVndSunStarScriptUrl
> sfUri( uriRef
, UNO_QUERY
);
305 bSingleDialog
= true;
307 // Try any other URL with SimpleFileAccess
308 Reference
< ucb::XSimpleFileAccess3
> xSFI
= ucb::SimpleFileAccess::create(m_xContext
);
312 xInput
= xSFI
->openFileRead( aURL
);
319 OUString sDescription
= sfUri
->getName();
321 sal_Int32 nIndex
= 0;
323 OUString sLibName
= sDescription
.getToken( 0, (sal_Unicode
)'.', nIndex
);
326 sDlgName
= sDescription
.getToken( 0, (sal_Unicode
)'.', nIndex
);
328 OUString sLocation
= sfUri
->getParameter(
329 OUString("location") );
332 // get dialog library container
333 // TODO: dialogs in packages
334 Reference
< XLibraryContainer
> xLibContainer
;
336 if ( sLocation
== "application" )
338 xLibContainer
= Reference
< XLibraryContainer
>( SfxGetpApp()->GetDialogContainer(), UNO_QUERY
);
340 else if ( sLocation
== "document" )
342 Reference
< XEmbeddedScripts
> xDocumentScripts( m_xModel
, UNO_QUERY
);
343 if ( xDocumentScripts
.is() )
345 xLibContainer
.set( xDocumentScripts
->getDialogLibraries(), UNO_QUERY
);
346 OSL_ENSURE( xLibContainer
.is(),
347 "DialogProviderImpl::createDialogModel: invalid dialog container!" );
352 Sequence
< OUString
> aOpenDocsTdocURLs( MiscUtils::allOpenTDocUrls( m_xContext
) );
353 const OUString
* pTdocURL
= aOpenDocsTdocURLs
.getConstArray();
354 const OUString
* pTdocURLEnd
= aOpenDocsTdocURLs
.getConstArray() + aOpenDocsTdocURLs
.getLength();
355 for ( ; pTdocURL
!= pTdocURLEnd
; ++pTdocURL
)
357 Reference
< frame::XModel
> xModel( MiscUtils::tDocUrlToModel( *pTdocURL
) );
358 OSL_ENSURE( xModel
.is(), "DialogProviderImpl::createDialogModel: invalid document model!" );
362 OUString sDocURL
= xModel
->getURL();
363 if ( sDocURL
.isEmpty() )
365 ::comphelper::NamedValueCollection
aModelArgs( xModel
->getArgs() );
366 sDocURL
= aModelArgs
.getOrDefault( "Title", sDocURL
);
369 if ( sLocation
!= sDocURL
)
372 Reference
< XEmbeddedScripts
> xDocumentScripts( m_xModel
, UNO_QUERY
);
373 if ( !xDocumentScripts
.is() )
376 xLibContainer
.set( xDocumentScripts
->getDialogLibraries(), UNO_QUERY
);
377 OSL_ENSURE( xLibContainer
.is(),
378 "DialogProviderImpl::createDialogModel: invalid dialog container!" );
382 // get input stream provider
383 Reference
< io::XInputStreamProvider
> xISP
;
384 if ( xLibContainer
.is() )
386 // load dialog library
387 if ( !xLibContainer
->isLibraryLoaded( sLibName
) )
388 xLibContainer
->loadLibrary( sLibName
);
390 // get dialog library
391 if ( xLibContainer
->hasByName( sLibName
) )
393 Any aElement
= xLibContainer
->getByName( sLibName
);
394 aElement
>>= xDialogLib
;
397 if ( xDialogLib
.is() )
399 // get input stream provider
400 if ( xDialogLib
->hasByName( sDlgName
) )
402 Any aElement
= xDialogLib
->getByName( sDlgName
);
408 throw IllegalArgumentException(
409 "DialogProviderImpl::getDialogModel: dialog not found!",
410 Reference
< XInterface
>(), 1 );
415 throw IllegalArgumentException(
416 "DialogProviderImpl::getDialogModel: library not found!",
417 Reference
< XInterface
>(), 1 );
422 throw IllegalArgumentException(
423 "DialogProviderImpl::getDialog: library container not found!",
424 Reference
< XInterface
>(), 1 );
428 xInput
= xISP
->createInputStream();
429 msDialogLibName
= sLibName
;
432 // import dialog model
433 Reference
< XControlModel
> xCtrlModel
;
434 if ( xInput
.is() && m_xContext
.is() )
436 Reference
< resource::XStringResourceManager
> xStringResourceManager
;
439 xStringResourceManager
= lcl_getStringResourceManager(m_xContext
,aURL
);
441 else if( xDialogLib
.is() )
443 xStringResourceManager
= getStringResourceFromDialogLibrary( xDialogLib
);
446 Any aDialogSourceURLAny
;
447 aDialogSourceURLAny
<<= aURL
;
449 Reference
< container::XNameContainer
> xDialogModel( createDialogModel( xInput
, xStringResourceManager
, aDialogSourceURLAny
), UNO_QUERY_THROW
);
451 xCtrlModel
= Reference
< XControlModel
>( xDialogModel
, UNO_QUERY
);
458 Reference
< XUnoControlDialog
> DialogProviderImpl::createDialogControl
459 ( const Reference
< XControlModel
>& rxDialogModel
, const Reference
< XWindowPeer
>& xParent
)
461 OSL_ENSURE( rxDialogModel
.is(), "DialogProviderImpl::getDialogControl: no dialog model" );
463 Reference
< XUnoControlDialog
> xDialogControl
;
465 if ( m_xContext
.is() )
467 xDialogControl
= UnoControlDialog::create( m_xContext
);
470 if ( rxDialogModel
.is() )
471 xDialogControl
->setModel( rxDialogModel
);
474 xDialogControl
->setVisible( sal_False
);
476 // get the parent of the dialog control
477 Reference
< XWindowPeer
> xPeer
;
482 else if ( m_xModel
.is() )
484 Reference
< frame::XController
> xController( m_xModel
->getCurrentController(), UNO_QUERY
);
485 if ( xController
.is() )
487 Reference
< frame::XFrame
> xFrame( xController
->getFrame(), UNO_QUERY
);
489 xPeer
= Reference
< XWindowPeer
>( xFrame
->getContainerWindow(), UNO_QUERY
);
494 Reference
< XToolkit
> xToolkit( Toolkit::create( m_xContext
), UNO_QUERY_THROW
);
495 xDialogControl
->createPeer( xToolkit
, xPeer
);
498 return xDialogControl
;
503 void DialogProviderImpl::attachControlEvents(
504 const Reference
< XControl
>& rxControl
,
505 const Reference
< XInterface
>& rxHandler
,
506 const Reference
< XIntrospectionAccess
>& rxIntrospectionAccess
,
507 bool bDialogProviderMode
)
509 if ( rxControl
.is() )
511 Reference
< XControlContainer
> xControlContainer( rxControl
, UNO_QUERY
);
513 if ( xControlContainer
.is() )
515 Sequence
< Reference
< XControl
> > aControls
= xControlContainer
->getControls();
516 const Reference
< XControl
>* pControls
= aControls
.getConstArray();
517 sal_Int32 nControlCount
= aControls
.getLength();
519 Sequence
< Reference
< XInterface
> > aObjects( nControlCount
+ 1 );
520 Reference
< XInterface
>* pObjects
= aObjects
.getArray();
521 for ( sal_Int32 i
= 0; i
< nControlCount
; ++i
)
523 pObjects
[i
] = Reference
<XInterface
>( pControls
[i
], UNO_QUERY
);
526 // also add the dialog control itself to the sequence
527 pObjects
[nControlCount
] = Reference
<XInterface
>( rxControl
, UNO_QUERY
);
529 Reference
< XScriptEventsAttacher
> xScriptEventsAttacher
= new DialogEventsAttacherImpl
530 ( m_xContext
, m_xModel
, rxControl
, rxHandler
, rxIntrospectionAccess
,
531 bDialogProviderMode
, ( m_BasicInfo
.get() ? m_BasicInfo
->mxBasicRTLListener
: NULL
), msDialogLibName
);
534 xScriptEventsAttacher
->attachEvents( aObjects
, Reference
< XScriptListener
>(), aHelper
);
539 Reference
< XIntrospectionAccess
> DialogProviderImpl::inspectHandler( const Reference
< XInterface
>& rxHandler
)
541 Reference
< XIntrospectionAccess
> xIntrospectionAccess
;
542 static Reference
< XIntrospection
> xIntrospection
;
544 if( !rxHandler
.is() )
545 return xIntrospectionAccess
;
547 if( !xIntrospection
.is() )
549 // Get introspection service
550 xIntrospection
= theIntrospection::get( m_xContext
);
557 aHandlerAny
<<= rxHandler
;
558 xIntrospectionAccess
= xIntrospection
->inspect( aHandlerAny
);
560 catch( RuntimeException
& )
562 xIntrospectionAccess
.clear();
564 return xIntrospectionAccess
;
572 OUString
DialogProviderImpl::getImplementationName( ) throw (RuntimeException
, std::exception
)
574 return getImplementationName_DialogProviderImpl();
577 sal_Bool
DialogProviderImpl::supportsService( const OUString
& rServiceName
) throw (RuntimeException
, std::exception
)
579 return cppu::supportsService(this, rServiceName
);
582 Sequence
< OUString
> DialogProviderImpl::getSupportedServiceNames( ) throw (RuntimeException
, std::exception
)
584 return getSupportedServiceNames_DialogProviderImpl();
591 void DialogProviderImpl::initialize( const Sequence
< Any
>& aArguments
) throw (Exception
, RuntimeException
, std::exception
)
593 ::osl::MutexGuard
aGuard( getMutex() );
595 if ( aArguments
.getLength() == 1 )
597 aArguments
[0] >>= m_xModel
;
599 if ( !m_xModel
.is() )
601 throw RuntimeException( "DialogProviderImpl::initialize: invalid argument format!" );
604 else if ( aArguments
.getLength() == 4 )
606 // call from RTL_Impl_CreateUnoDialog
607 aArguments
[0] >>= m_xModel
;
608 m_BasicInfo
.reset( new BasicRTLParams() );
609 m_BasicInfo
->mxInput
.set( aArguments
[ 1 ], UNO_QUERY_THROW
);
610 // allow null mxDlgLib, a document dialog instantiated from
611 // from application basic is unable to provide ( or find ) it's
613 aArguments
[ 2 ] >>= m_BasicInfo
->mxDlgLib
;
614 // leave the possibility to optionally allow the old dialog creation
615 // to use the new XScriptListener ( which converts the old style macro
617 m_BasicInfo
->mxBasicRTLListener
.set( aArguments
[ 3 ], UNO_QUERY
);
619 else if ( aArguments
.getLength() > 4 )
621 throw RuntimeException( "DialogProviderImpl::initialize: invalid number of arguments!" );
629 static const char aDecorationPropName
[] = "Decoration";
630 static const char aTitlePropName
[] = "Title";
632 Reference
< XControl
> DialogProviderImpl::createDialogImpl(
633 const OUString
& URL
, const Reference
< XInterface
>& xHandler
,
634 const Reference
< XWindowPeer
>& xParent
, bool bDialogProviderMode
)
635 throw (IllegalArgumentException
, RuntimeException
)
637 // if the dialog is located in a document, the document must already be open!
639 ::osl::MutexGuard
aGuard( getMutex() );
642 // m_xHandler = xHandler;
644 //Reference< XDialog > xDialog;
645 Reference
< XControl
> xCtrl
;
646 Reference
< XControlModel
> xCtrlMod
;
649 // add support for basic RTL_FUNCTION
650 if ( m_BasicInfo
.get() )
651 xCtrlMod
= createDialogModelForBasic();
654 OSL_ENSURE( !URL
.isEmpty(), "DialogProviderImpl::getDialog: no URL!" );
655 xCtrlMod
= createDialogModel( URL
);
658 catch ( const RuntimeException
& ) { throw; }
659 catch ( const Exception
& )
661 const Any
aError( ::cppu::getCaughtException() );
662 throw WrappedTargetRuntimeException( OUString(), *this, aError
);
666 // i83963 Force decoration
667 if( bDialogProviderMode
)
669 uno::Reference
< beans::XPropertySet
> xDlgModPropSet( xCtrlMod
, uno::UNO_QUERY
);
670 if( xDlgModPropSet
.is() )
674 bool bDecoration
= true;
675 Any aDecorationAny
= xDlgModPropSet
->getPropertyValue( aDecorationPropName
);
676 aDecorationAny
>>= bDecoration
;
679 xDlgModPropSet
->setPropertyValue( aDecorationPropName
, makeAny( true ) );
680 xDlgModPropSet
->setPropertyValue( aTitlePropName
, makeAny( OUString() ) );
683 catch( UnknownPropertyException
& )
688 xCtrl
= Reference
< XControl
>( createDialogControl( xCtrlMod
, xParent
) );
691 //xDialog = Reference< XDialog >( xCtrl, UNO_QUERY );
692 Reference
< XIntrospectionAccess
> xIntrospectionAccess
= inspectHandler( xHandler
);
693 attachControlEvents( xCtrl
, xHandler
, xIntrospectionAccess
, bDialogProviderMode
);
700 Reference
< XDialog
> DialogProviderImpl::createDialog( const OUString
& URL
)
701 throw (IllegalArgumentException
, RuntimeException
, std::exception
)
703 Reference
< XInterface
> xDummyHandler
;
704 Reference
< XWindowPeer
> xDummyPeer
;
705 Reference
< XControl
> xControl
= DialogProviderImpl::createDialogImpl( URL
, xDummyHandler
, xDummyPeer
, true );
706 Reference
< XDialog
> xDialog( xControl
, UNO_QUERY
);
710 Reference
< XDialog
> DialogProviderImpl::createDialogWithHandler(
711 const OUString
& URL
, const Reference
< XInterface
>& xHandler
)
712 throw (IllegalArgumentException
, RuntimeException
, std::exception
)
716 throw IllegalArgumentException(
717 "DialogProviderImpl::createDialogWithHandler: Invalid xHandler!",
718 Reference
< XInterface
>(), 1 );
720 Reference
< XWindowPeer
> xDummyPeer
;
721 Reference
< XControl
> xControl
= DialogProviderImpl::createDialogImpl( URL
, xHandler
, xDummyPeer
, true );
722 Reference
< XDialog
> xDialog( xControl
, UNO_QUERY
);
726 Reference
< XDialog
> DialogProviderImpl::createDialogWithArguments(
727 const OUString
& URL
, const Sequence
< NamedValue
>& Arguments
)
728 throw (IllegalArgumentException
, RuntimeException
, std::exception
)
730 ::comphelper::NamedValueCollection
aArguments( Arguments
);
732 Reference
< XWindowPeer
> xParentPeer
;
733 if ( aArguments
.has( "ParentWindow" ) )
735 const Any
aParentWindow( aArguments
.get( "ParentWindow" ) );
736 if ( !( aParentWindow
>>= xParentPeer
) )
738 const Reference
< XControl
> xParentControl( aParentWindow
, UNO_QUERY
);
739 if ( xParentControl
.is() )
740 xParentPeer
= xParentControl
->getPeer();
744 const Reference
< XInterface
> xHandler( aArguments
.get( "EventHandler" ), UNO_QUERY
);
746 Reference
< XControl
> xControl
= DialogProviderImpl::createDialogImpl( URL
, xHandler
, xParentPeer
, true );
747 Reference
< XDialog
> xDialog( xControl
, UNO_QUERY
);
751 Reference
< XWindow
> DialogProviderImpl::createContainerWindow(
752 const OUString
& URL
, const OUString
& WindowType
,
753 const Reference
< XWindowPeer
>& xParent
, const Reference
< XInterface
>& xHandler
)
754 throw (lang::IllegalArgumentException
, RuntimeException
, std::exception
)
756 (void)WindowType
; // for future use
759 throw IllegalArgumentException(
760 "DialogProviderImpl::createContainerWindow: Invalid xParent!",
761 Reference
< XInterface
>(), 1 );
763 Reference
< XControl
> xControl
= DialogProviderImpl::createDialogImpl( URL
, xHandler
, xParent
, false );
764 Reference
< XWindow
> xWindow( xControl
, UNO_QUERY
);
770 // component operations
773 static Reference
< XInterface
> SAL_CALL
create_DialogProviderImpl(
774 Reference
< XComponentContext
> const & xContext
)
776 return static_cast< lang::XTypeProvider
* >( new DialogProviderImpl( xContext
) );
781 static struct ::cppu::ImplementationEntry s_component_entries
[] =
783 {create_DialogProviderImpl
, getImplementationName_DialogProviderImpl
,getSupportedServiceNames_DialogProviderImpl
, ::cppu::createSingleComponentFactory
,0, 0},
784 { &comp_DialogModelProvider::_create
,&comp_DialogModelProvider::_getImplementationName
,&comp_DialogModelProvider::_getSupportedServiceNames
,&::cppu::createSingleComponentFactory
, 0, 0 },
791 } // namespace dlgprov
801 SAL_DLLPUBLIC_EXPORT
void * SAL_CALL
dlgprov_component_getFactory(
802 const sal_Char
* pImplName
, void * pServiceManager
,
803 void * pRegistryKey
)
805 return ::cppu::component_getFactoryHelper(
806 pImplName
, pServiceManager
, pRegistryKey
, ::dlgprov::s_component_entries
);
810 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */