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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cui.hxx"
26
27 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
28 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
29 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
30 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #include <com/sun/star/lang/XInitialization.hpp>
33 #include <comphelper/processfactory.hxx>
34 #include <com/sun/star/embed/EmbedStates.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/beans/PropertyValue.hpp>
37 #include <com/sun/star/embed/XInsertObjectDialog.hpp>
38 #include <com/sun/star/ucb/CommandAbortedException.hpp>
39 #include <com/sun/star/task/XInteractionHandler.hpp>
40
41 #include "insdlg.hxx"
42 #include <dialmgr.hxx>
43 #include <svtools/sores.hxx>
44
45 #include <stdio.h>
46 #include <tools/urlobj.hxx>
47 #include <tools/debug.hxx>
48 #include <svl/urihelper.hxx>
49 #include <svtools/svmedit.hxx>
50 #include <vcl/button.hxx>
51 #include <vcl/fixed.hxx>
52 #include <vcl/group.hxx>
53 #include <vcl/lstbox.hxx>
54 #include <vcl/msgbox.hxx>
55 #include <vcl/svapp.hxx>
56 #include <sot/clsids.hxx>
57 #include <sfx2/frmdescr.hxx>
58 #include <sfx2/viewsh.hxx>
59 #include <sfx2/filedlghelper.hxx>
60 #include <svl/ownlist.hxx>
61 #include <comphelper/seqstream.hxx>
62
63 #include "svuidlg.hrc"
64
65 #include <osl/file.hxx>
66
67 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
68 #include <com/sun/star/container/XNameAccess.hpp>
69 #include <unotools/processfactory.hxx>
70
71 using namespace ::com::sun::star;
72 using namespace ::com::sun::star::lang;
73 using namespace ::com::sun::star::uno;
74 using namespace ::com::sun::star::container;
75 using namespace ::com::sun::star::ui::dialogs;
76 using ::rtl::OUString;
77
78 #define _SVSTDARR_STRINGSDTOR
79 #include <svl/svstdarr.hxx>
80
81
impl_getSvtResString(sal_uInt32 nId)82 static String impl_getSvtResString( sal_uInt32 nId )
83 {
84 String aRet;
85 com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
86 ResMgr* pMgr = ResMgr::CreateResMgr( "svt", aLocale );
87 if( pMgr )
88 {
89 aRet = String( ResId( nId, *pMgr ) );
90 delete pMgr;
91 }
92 return aRet;
93 }
94
IsCreateNew() const95 sal_Bool InsertObjectDialog_Impl::IsCreateNew() const
96 {
97 return sal_False;
98 }
99
GetIconIfIconified(::rtl::OUString *)100 uno::Reference< io::XInputStream > InsertObjectDialog_Impl::GetIconIfIconified( ::rtl::OUString* /*pGraphicMediaType*/ )
101 {
102 return uno::Reference< io::XInputStream >();
103 }
104
InsertObjectDialog_Impl(Window * pParent,const ResId & rResId,const com::sun::star::uno::Reference<com::sun::star::embed::XStorage> & xStorage)105 InsertObjectDialog_Impl::InsertObjectDialog_Impl( Window * pParent, const ResId & rResId, const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage )
106 : ModalDialog( pParent, rResId )
107 , m_xStorage( xStorage )
108 , aCnt( m_xStorage )
109 {
110 }
111
112 // -----------------------------------------------------------------------
113
IMPL_LINK_INLINE_START(SvInsertOleDlg,DoubleClickHdl,ListBox *,EMPTYARG)114 IMPL_LINK_INLINE_START( SvInsertOleDlg, DoubleClickHdl, ListBox *, EMPTYARG )
115 {
116 EndDialog( RET_OK );
117 return 0;
118 }
IMPL_LINK_INLINE_END(SvInsertOleDlg,DoubleClickHdl,ListBox *,pListBox)119 IMPL_LINK_INLINE_END( SvInsertOleDlg, DoubleClickHdl, ListBox *, pListBox )
120
121 // -----------------------------------------------------------------------
122
123 IMPL_LINK( SvInsertOleDlg, BrowseHdl, PushButton *, EMPTYARG )
124 {
125 Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
126 if( xFactory.is() )
127 {
128 Reference< XFilePicker > xFilePicker( xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ) ), UNO_QUERY );
129 DBG_ASSERT( xFilePicker.is(), "could not get FilePicker service" );
130
131 Reference< XInitialization > xInit( xFilePicker, UNO_QUERY );
132 Reference< XFilterManager > xFilterMgr( xFilePicker, UNO_QUERY );
133 if( xInit.is() && xFilePicker.is() && xFilterMgr.is() )
134 {
135 Sequence< Any > aServiceType( 1 );
136 aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
137 xInit->initialize( aServiceType );
138
139 // add filter
140 try
141 {
142 xFilterMgr->appendFilter(
143 OUString(),
144 OUString( RTL_CONSTASCII_USTRINGPARAM( "*.*" ) )
145 );
146 }
147 catch( IllegalArgumentException& )
148 {
149 DBG_ASSERT( 0, "caught IllegalArgumentException when registering filter\n" );
150 }
151
152 if( xFilePicker->execute() == ExecutableDialogResults::OK )
153 {
154 Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
155 INetURLObject aObj( aPathSeq[0] );
156 aEdFilepath.SetText( aObj.PathToFileName() );
157 }
158 }
159 }
160
161 return 0;
162 }
163
164 // -----------------------------------------------------------------------
165
IMPL_LINK(SvInsertOleDlg,RadioHdl,RadioButton *,EMPTYARG)166 IMPL_LINK( SvInsertOleDlg, RadioHdl, RadioButton *, EMPTYARG )
167 {
168 if ( aRbNewObject.IsChecked() )
169 {
170 aLbObjecttype.Show();
171 aEdFilepath.Hide();
172 aBtnFilepath.Hide();
173 aCbFilelink.Hide();
174 aGbObject.SetText( _aOldStr );
175 }
176 else
177 {
178 aCbFilelink.Show();
179 aLbObjecttype.Hide();
180 aEdFilepath.Show();
181 aBtnFilepath.Show();
182 aCbFilelink.Show();
183 aGbObject.SetText( aStrFile );
184 }
185 return 0;
186 }
187
188 // -----------------------------------------------------------------------
189
SelectDefault()190 void SvInsertOleDlg::SelectDefault()
191 {
192 aLbObjecttype.SelectEntryPos( 0 );
193 }
194
195 // -----------------------------------------------------------------------
SvInsertOleDlg(Window * pParent,const Reference<embed::XStorage> & xStorage,const SvObjectServerList * pServers)196 SvInsertOleDlg::SvInsertOleDlg
197 (
198 Window* pParent,
199 const Reference < embed::XStorage >& xStorage,
200 const SvObjectServerList* pServers
201 )
202 : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OLEOBJECT ), xStorage ),
203 aRbNewObject( this, CUI_RES( RB_NEW_OBJECT ) ),
204 aRbObjectFromfile( this, CUI_RES( RB_OBJECT_FROMFILE ) ),
205 aGbObject( this, CUI_RES( GB_OBJECT ) ),
206 aLbObjecttype( this, CUI_RES( LB_OBJECTTYPE ) ),
207 aEdFilepath( this, CUI_RES( ED_FILEPATH ) ),
208 aBtnFilepath( this, CUI_RES( BTN_FILEPATH ) ),
209 aCbFilelink( this, CUI_RES( CB_FILELINK ) ),
210 aOKButton1( this, CUI_RES( 1 ) ),
211 aCancelButton1( this, CUI_RES( 1 ) ),
212 aHelpButton1( this, CUI_RES( 1 ) ),
213 aStrFile( CUI_RES( STR_FILE ) ),
214 m_pServers( pServers )
215 {
216 FreeResource();
217 _aOldStr = aGbObject.GetText();
218 aLbObjecttype.SetDoubleClickHdl( LINK( this, SvInsertOleDlg, DoubleClickHdl ) );
219 aBtnFilepath.SetClickHdl( LINK( this, SvInsertOleDlg, BrowseHdl ) );
220 Link aLink( LINK( this, SvInsertOleDlg, RadioHdl ) );
221 aRbNewObject.SetClickHdl( aLink );
222 aRbObjectFromfile.SetClickHdl( aLink );
223 aRbNewObject.Check( sal_True );
224 RadioHdl( NULL );
225 aBtnFilepath.SetAccessibleRelationMemberOf(&aGbObject);
226 }
227
Execute()228 short SvInsertOleDlg::Execute()
229 {
230 short nRet = RET_OK;
231 SvObjectServerList aObjS;
232 if ( !m_pServers )
233 {
234 // if no list was provided, take the complete one
235 aObjS.FillInsertObjects();
236 m_pServers = &aObjS;
237 }
238
239 // fill listbox and select default
240 ListBox& rBox = GetObjectTypes();
241 rBox.SetUpdateMode( sal_False );
242 for ( sal_uLong i = 0; i < m_pServers->Count(); i++ )
243 rBox.InsertEntry( (*m_pServers)[i].GetHumanName() );
244 rBox.SetUpdateMode( sal_True );
245 SelectDefault();
246 ::rtl::OUString aName;
247
248 DBG_ASSERT( m_xStorage.is(), "No storage!");
249 if ( m_xStorage.is() && ( nRet = Dialog::Execute() ) == RET_OK )
250 {
251 String aFileName;
252 sal_Bool bLink = sal_False;
253 sal_Bool bCreateNew = IsCreateNew();
254 if ( bCreateNew )
255 {
256 // create and insert new embedded object
257 String aServerName = rBox.GetSelectEntry();
258 const SvObjectServer* pS = m_pServers->Get( aServerName );
259 if ( pS )
260 {
261 if( pS->GetClassName() == SvGlobalName( SO3_OUT_CLASSID ) )
262 {
263 try
264 {
265 uno::Reference < embed::XInsertObjectDialog > xDialogCreator(
266 ::comphelper::getProcessServiceFactory()->createInstance(
267 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.MSOLEObjectSystemCreator")) ),
268 uno::UNO_QUERY );
269
270 if ( xDialogCreator.is() )
271 {
272 aName = aCnt.CreateUniqueObjectName();
273 embed::InsertedObjectInfo aNewInf = xDialogCreator->createInstanceByDialog(
274 m_xStorage,
275 aName,
276 uno::Sequence < beans::PropertyValue >() );
277
278 OSL_ENSURE( aNewInf.Object.is(), "The object must be created or an exception must be thrown!" );
279 m_xObj = aNewInf.Object;
280 for ( sal_Int32 nInd = 0; nInd < aNewInf.Options.getLength(); nInd++ )
281 if ( aNewInf.Options[nInd].Name.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Icon" ) ) ) )
282 {
283 aNewInf.Options[nInd].Value >>= m_aIconMetaFile;
284 }
285 else if ( aNewInf.Options[nInd].Name.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IconFormat" ) ) ) )
286 {
287 datatransfer::DataFlavor aFlavor;
288 if ( aNewInf.Options[nInd].Value >>= aFlavor )
289 m_aIconMediaType = aFlavor.MimeType;
290 }
291
292 }
293 }
294 catch( ucb::CommandAbortedException& )
295 {
296 // the user has pressed cancel
297 }
298 catch( uno::Exception& )
299 {
300 // TODO: Error handling
301 }
302 }
303 else
304 {
305 // create object with desired ClassId
306 m_xObj = aCnt.CreateEmbeddedObject( pS->GetClassName().GetByteSequence(), aName );
307 }
308
309 if ( !m_xObj.is() )
310 {
311 if( aFileName.Len() ) // from OLE Dialog
312 {
313 // Objekt konnte nicht aus Datei erzeugt werden
314 // global Resource from svtools (former so3 resource)
315 String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE_FROM_FILE ) );
316 aErr.SearchAndReplace( String( '%' ), aFileName );
317 ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
318 }
319 else
320 {
321 // Objekt konnte nicht erzeugt werden
322 // global Resource from svtools (former so3 resource)
323 String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE ) );
324 aErr.SearchAndReplace( String( '%' ), aServerName );
325 ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
326 }
327 }
328 }
329 }
330 else
331 {
332 aFileName = GetFilePath();
333 INetURLObject aURL;
334 aURL.SetSmartProtocol( INET_PROT_FILE );
335 aURL.SetSmartURL( aFileName );
336 aFileName = aURL.GetMainURL( INetURLObject::NO_DECODE );
337 bLink = IsLinked();
338
339 if ( aFileName.Len() )
340 {
341 // create MediaDescriptor for file to create object from
342 uno::Sequence < beans::PropertyValue > aMedium( 2 );
343 aMedium[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
344 aMedium[0].Value <<= ::rtl::OUString( aFileName );
345
346 uno::Reference< task::XInteractionHandler > xInteraction;
347 uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
348 if ( xFactory.is() )
349 xInteraction = uno::Reference< task::XInteractionHandler >(
350 xFactory->createInstance(
351 DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ),
352 uno::UNO_QUERY_THROW );
353
354 if ( xInteraction.is() )
355 {
356 aMedium[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ) );
357 aMedium[1].Value <<= xInteraction;
358 }
359 else
360 {
361 OSL_ASSERT( "Can not get InteractionHandler!\n" );
362 aMedium.realloc( 1 );
363 }
364
365 // create object from media descriptor
366 if ( bLink )
367 m_xObj = aCnt.InsertEmbeddedLink( aMedium, aName );
368 else
369 m_xObj = aCnt.InsertEmbeddedObject( aMedium, aName );
370 }
371
372 if ( !m_xObj.is() )
373 {
374 // Objekt konnte nicht aus Datei erzeugt werden
375 // global Resource from svtools (former so3 resource)
376 String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE_FROM_FILE ) );
377 aErr.SearchAndReplace( String( '%' ), aFileName );
378 ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
379 }
380 }
381 }
382
383 m_pServers = 0;
384 return nRet;
385 }
386
GetIconIfIconified(::rtl::OUString * pGraphicMediaType)387 uno::Reference< io::XInputStream > SvInsertOleDlg::GetIconIfIconified( ::rtl::OUString* pGraphicMediaType )
388 {
389 if ( m_aIconMetaFile.getLength() )
390 {
391 if ( pGraphicMediaType )
392 *pGraphicMediaType = m_aIconMediaType;
393
394 return uno::Reference< io::XInputStream >( new ::comphelper::SequenceInputStream( m_aIconMetaFile ) );
395 }
396
397 return uno::Reference< io::XInputStream >();
398 }
399
IMPL_LINK(SvInsertPlugInDialog,BrowseHdl,PushButton *,EMPTYARG)400 IMPL_LINK( SvInsertPlugInDialog, BrowseHdl, PushButton *, EMPTYARG )
401 {
402 Sequence< OUString > aFilterNames, aFilterTypes;
403 void fillNetscapePluginFilters( Sequence< OUString >& rNames, Sequence< OUString >& rTypes );
404 fillNetscapePluginFilters( aFilterNames, aFilterTypes );
405
406 Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
407 if( xFactory.is() )
408 {
409 Reference< XFilePicker > xFilePicker( xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ) ), UNO_QUERY );
410 DBG_ASSERT( xFilePicker.is(), "could not get FilePicker service" );
411
412 Reference< XInitialization > xInit( xFilePicker, UNO_QUERY );
413 Reference< XFilterManager > xFilterMgr( xFilePicker, UNO_QUERY );
414 if( xInit.is() && xFilePicker.is() && xFilterMgr.is() )
415 {
416 Sequence< Any > aServiceType( 1 );
417 aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
418 xInit->initialize( aServiceType );
419
420 // add the filters
421 try
422 {
423 const OUString* pNames = aFilterNames.getConstArray();
424 const OUString* pTypes = aFilterTypes.getConstArray();
425 for( int i = 0; i < aFilterNames.getLength(); i++ )
426 xFilterMgr->appendFilter( pNames[i], pTypes[i] );
427 }
428 catch( IllegalArgumentException& )
429 {
430 DBG_ASSERT( 0, "caught IllegalArgumentException when registering filter\n" );
431 }
432
433 if( xFilePicker->execute() == ExecutableDialogResults::OK )
434 {
435 Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
436 INetURLObject aObj( aPathSeq[0] );
437 aEdFileurl.SetText( aObj.PathToFileName() );
438 }
439 }
440 }
441
442 return 0;
443 }
444
445 // -----------------------------------------------------------------------
446
SvInsertPlugInDialog(Window * pParent,const uno::Reference<embed::XStorage> & xStorage)447 SvInsertPlugInDialog::SvInsertPlugInDialog( Window* pParent, const uno::Reference < embed::XStorage >& xStorage )
448 : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OBJECT_PLUGIN ), xStorage ),
449 aGbFileurl( this, CUI_RES( GB_FILEURL ) ),
450 aEdFileurl( this, CUI_RES( ED_FILEURL ) ),
451 aBtnFileurl( this, CUI_RES( BTN_FILEURL ) ),
452 aGbPluginsOptions( this, CUI_RES( GB_PLUGINS_OPTIONS ) ),
453 aEdPluginsOptions( this, CUI_RES( ED_PLUGINS_OPTIONS ) ),
454 aOKButton1( this, CUI_RES( 1 ) ),
455 aCancelButton1( this, CUI_RES( 1 ) ),
456 aHelpButton1( this, CUI_RES( 1 ) ),
457 m_pURL(0)
458 {
459 FreeResource();
460 aBtnFileurl.SetClickHdl( LINK( this, SvInsertPlugInDialog, BrowseHdl ) );
461 }
462
~SvInsertPlugInDialog()463 SvInsertPlugInDialog::~SvInsertPlugInDialog()
464 {
465 delete m_pURL;
466 }
467
468 // -----------------------------------------------------------------------
469
Plugin_ImplFillCommandSequence(const String & aCommands,uno::Sequence<beans::PropertyValue> & aCommandSequence)470 static void Plugin_ImplFillCommandSequence( const String& aCommands, uno::Sequence< beans::PropertyValue >& aCommandSequence )
471 {
472 sal_uInt16 nEaten;
473 SvCommandList aLst;
474 aLst.AppendCommands( aCommands, &nEaten );
475
476 const sal_Int32 nCount = aLst.Count();
477 aCommandSequence.realloc( nCount );
478 for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
479 {
480 const SvCommand& rCommand = aLst[ nIndex ];
481
482 aCommandSequence[nIndex].Name = rCommand.GetCommand();
483 aCommandSequence[nIndex].Handle = -1;
484 aCommandSequence[nIndex].Value = makeAny( OUString( rCommand.GetArgument() ) );
485 aCommandSequence[nIndex].State = beans::PropertyState_DIRECT_VALUE;
486 }
487 }
488
Execute()489 short SvInsertPlugInDialog::Execute()
490 {
491 short nRet = RET_OK;
492 m_aCommands.Erase();
493 DBG_ASSERT( m_xStorage.is(), "No storage!");
494 if ( m_xStorage.is() && ( nRet = Dialog::Execute() ) == RET_OK )
495 {
496 if ( !m_pURL )
497 m_pURL = new INetURLObject();
498 else
499 *m_pURL = INetURLObject();
500
501 m_aCommands = GetPlugInOptions();
502 String aURL = GetPlugInFile();
503
504 // URL can be a valid and absolute URL or a system file name
505 m_pURL->SetSmartProtocol( INET_PROT_FILE );
506 if ( !aURL.Len() || m_pURL->SetSmartURL( aURL ) )
507 {
508 // create a plugin object
509 ::rtl::OUString aName;
510 SvGlobalName aClassId( SO3_PLUGIN_CLASSID );
511 m_xObj = aCnt.CreateEmbeddedObject( aClassId.GetByteSequence(), aName );
512 }
513
514 if ( m_xObj.is() )
515 {
516 // set properties from dialog
517 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
518 m_xObj->changeState( embed::EmbedStates::RUNNING );
519
520 uno::Reference < beans::XPropertySet > xSet( m_xObj->getComponent(), uno::UNO_QUERY );
521 if ( xSet.is() )
522 {
523 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"),
524 makeAny( ::rtl::OUString( m_pURL->GetMainURL( INetURLObject::NO_DECODE ) ) ) );
525 uno::Sequence< beans::PropertyValue > aCommandSequence;
526 Plugin_ImplFillCommandSequence( m_aCommands, aCommandSequence );
527 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginCommands"), makeAny( aCommandSequence ) );
528 }
529 }
530 else
531 {
532 // PlugIn konnte nicht erzeugt werden
533 // global Resource from svtools (former so3 resource)
534 String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE_PLUGIN ) );
535 aErr.SearchAndReplace( String( '%' ), aURL );
536 ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
537 }
538 }
539
540 return nRet;
541 }
542
543 // class SvInsertAppletDlg -----------------------------------------------
544
IMPL_LINK(SvInsertAppletDialog,BrowseHdl,PushButton *,EMPTYARG)545 IMPL_LINK( SvInsertAppletDialog, BrowseHdl, PushButton *, EMPTYARG )
546 {
547 Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
548 if( xFactory.is() )
549 {
550 Reference< XFilePicker > xFilePicker( xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ) ), UNO_QUERY );
551 DBG_ASSERT( xFilePicker.is(), "could not get FilePicker service" );
552
553 Reference< XInitialization > xInit( xFilePicker, UNO_QUERY );
554 Reference< XFilterManager > xFilterMgr( xFilePicker, UNO_QUERY );
555 if( xInit.is() && xFilePicker.is() && xFilterMgr.is() )
556 {
557 Sequence< Any > aServiceType( 1 );
558 aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
559 xInit->initialize( aServiceType );
560
561 // add filter
562 try
563 {
564 xFilterMgr->appendFilter(
565 OUString( RTL_CONSTASCII_USTRINGPARAM( "Applet" ) ),
566 OUString( RTL_CONSTASCII_USTRINGPARAM( "*.class" ) )
567 );
568 }
569 catch( IllegalArgumentException& )
570 {
571 DBG_ASSERT( 0, "caught IllegalArgumentException when registering filter\n" );
572 }
573
574 if( xFilePicker->execute() == ExecutableDialogResults::OK )
575 {
576 Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
577
578 INetURLObject aObj( aPathSeq[0] );
579 aEdClassfile.SetText( aObj.getName() );
580 aObj.removeSegment();
581 aEdClasslocation.SetText( aObj.PathToFileName() );
582 }
583 }
584 }
585
586 return 0;
587 }
588
589 // -----------------------------------------------------------------------
590
SvInsertAppletDialog(Window * pParent,const uno::Reference<embed::XStorage> & xStorage)591 SvInsertAppletDialog::SvInsertAppletDialog( Window* pParent, const uno::Reference < embed::XStorage >& xStorage )
592 : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OBJECT_APPLET ), xStorage ),
593 aFtClassfile( this, CUI_RES( FT_CLASSFILE ) ),
594 aEdClassfile( this, CUI_RES( ED_CLASSFILE ) ),
595 aFtClasslocation( this, CUI_RES( FT_CLASSLOCATION ) ),
596 aEdClasslocation( this, CUI_RES( ED_CLASSLOCATION ) ),
597 aBtnClass( this, CUI_RES( BTN_CLASS ) ),
598 aGbClass( this, CUI_RES( GB_CLASS ) ),
599 aEdAppletOptions( this, CUI_RES( ED_APPLET_OPTIONS ) ),
600 aGbAppletOptions( this, CUI_RES( GB_APPLET_OPTIONS ) ),
601 aOKButton1( this, CUI_RES( 1 ) ),
602 aCancelButton1( this, CUI_RES( 1 ) ),
603 aHelpButton1( this, CUI_RES( 1 ) ),
604 m_pURL(0)
605 {
606 FreeResource();
607 aBtnClass.SetClickHdl( LINK( this, SvInsertAppletDialog, BrowseHdl ) );
608 }
609
SvInsertAppletDialog(Window * pParent,const uno::Reference<embed::XEmbeddedObject> & xObj)610 SvInsertAppletDialog::SvInsertAppletDialog( Window* pParent, const uno::Reference < embed::XEmbeddedObject >& xObj )
611 : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OBJECT_APPLET ), uno::Reference < embed::XStorage >() ),
612 aFtClassfile( this, CUI_RES( FT_CLASSFILE ) ),
613 aEdClassfile( this, CUI_RES( ED_CLASSFILE ) ),
614 aFtClasslocation( this, CUI_RES( FT_CLASSLOCATION ) ),
615 aEdClasslocation( this, CUI_RES( ED_CLASSLOCATION ) ),
616 aBtnClass( this, CUI_RES( BTN_CLASS ) ),
617 aGbClass( this, CUI_RES( GB_CLASS ) ),
618 aEdAppletOptions( this, CUI_RES( ED_APPLET_OPTIONS ) ),
619 aGbAppletOptions( this, CUI_RES( GB_APPLET_OPTIONS ) ),
620 aOKButton1( this, CUI_RES( 1 ) ),
621 aCancelButton1( this, CUI_RES( 1 ) ),
622 aHelpButton1( this, CUI_RES( 1 ) ),
623 m_pURL(0)
624 {
625 m_xObj = xObj;
626 FreeResource();
627 aBtnClass.SetClickHdl( LINK( this, SvInsertAppletDialog, BrowseHdl ) );
628 }
629
630
~SvInsertAppletDialog()631 SvInsertAppletDialog::~SvInsertAppletDialog()
632 {
633 delete m_pURL;
634 }
635
Execute()636 short SvInsertAppletDialog::Execute()
637 {
638 short nRet = RET_OK;
639 m_aClass.Erase();
640 m_aCommands.Erase();
641
642 sal_Bool bOK = sal_False;
643 uno::Reference < beans::XPropertySet > xSet;
644 if ( m_xObj.is() )
645 {
646 try
647 {
648 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
649 m_xObj->changeState( embed::EmbedStates::RUNNING );
650 xSet = uno::Reference < beans::XPropertySet >( m_xObj->getComponent(), uno::UNO_QUERY );
651 ::rtl::OUString aStr;
652 uno::Any aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCode") );
653 if ( aAny >>= aStr )
654 SetClass( aStr );
655 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCodeBase") );
656 if ( aAny >>= aStr )
657 SetClassLocation( aStr );
658 uno::Sequence< beans::PropertyValue > aCommands;
659 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCommands") );
660 if ( aAny >>= aCommands )
661 {
662 SvCommandList aList;
663 aList.FillFromSequence( aCommands );
664 SetAppletOptions( aList.GetCommands() );
665 }
666
667 String aText( CUI_RES( STR_EDIT_APPLET ) );
668 SetText( aText );
669 bOK = sal_True;
670 }
671 catch ( uno::Exception& )
672 {
673 DBG_ERROR( "No Applet!" );
674 }
675 }
676 else
677 {
678 DBG_ASSERT( m_xStorage.is(), "No storage!");
679 bOK = m_xStorage.is();
680 }
681
682 if ( bOK && ( nRet = Dialog::Execute() ) == RET_OK )
683 {
684 if ( !m_xObj.is() )
685 {
686 ::rtl::OUString aName;
687 SvGlobalName aClassId( SO3_APPLET_CLASSID );
688 m_xObj = aCnt.CreateEmbeddedObject( aClassId.GetByteSequence(), aName );
689 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
690 m_xObj->changeState( embed::EmbedStates::RUNNING );
691 xSet = uno::Reference < beans::XPropertySet >( m_xObj->getComponent(), uno::UNO_QUERY );
692 }
693
694 if ( m_xObj.is() )
695 {
696 try
697 {
698 sal_Bool bIPActive = m_xObj->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE;
699 if ( bIPActive )
700 m_xObj->changeState( embed::EmbedStates::RUNNING );
701
702 String aClassLocation = GetClassLocation();
703
704 // Hack, aFileName wird auch fuer Class benutzt
705 m_aClass = GetClass();
706 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("AppletCode"), makeAny( ::rtl::OUString( m_aClass ) ) );
707
708 ::rtl::OUString tmp = aClassLocation;
709 ::osl::File::getFileURLFromSystemPath(tmp, tmp);
710 aClassLocation = tmp;
711 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("AppletCodeBase"), makeAny( tmp ) );
712 m_aCommands = GetAppletOptions();
713
714 uno::Sequence< beans::PropertyValue > aCommandSequence;
715 Plugin_ImplFillCommandSequence( m_aCommands, aCommandSequence );
716 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("AppletCommands"), makeAny( aCommandSequence ) );
717
718 if ( bIPActive )
719 m_xObj->changeState( embed::EmbedStates::INPLACE_ACTIVE );
720 }
721 catch ( uno::Exception& )
722 {
723 DBG_ERROR( "No Applet!" );
724 }
725 }
726 }
727
728 return nRet;
729 }
730
SfxInsertFloatingFrameDialog(Window * pParent,const com::sun::star::uno::Reference<com::sun::star::embed::XStorage> & xStorage)731 SfxInsertFloatingFrameDialog::SfxInsertFloatingFrameDialog( Window *pParent,
732 const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage )
733 : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OBJECT_IFRAME ), xStorage )
734 , aFTName ( this, CUI_RES( FT_FRAMENAME ) )
735 , aEDName ( this, CUI_RES( ED_FRAMENAME ) )
736 , aFTURL ( this, CUI_RES( FT_URL ) )
737 , aEDURL ( this, CUI_RES( ED_URL ) )
738 , aBTOpen ( this, CUI_RES(BT_FILEOPEN ) )
739
740 , aFLScrolling ( this, CUI_RES( GB_SCROLLING ) )
741 , aRBScrollingOn ( this, CUI_RES( RB_SCROLLINGON ) )
742 , aRBScrollingOff ( this, CUI_RES( RB_SCROLLINGOFF ) )
743 , aRBScrollingAuto ( this, CUI_RES( RB_SCROLLINGAUTO ) )
744 , aFLSepLeft( this, CUI_RES( FL_SEP_LEFT ) )
745 , aFLFrameBorder( this, CUI_RES( GB_BORDER ) )
746 , aRBFrameBorderOn ( this, CUI_RES( RB_FRMBORDER_ON ) )
747 , aRBFrameBorderOff ( this, CUI_RES( RB_FRMBORDER_OFF ) )
748 , aFLSepRight( this, CUI_RES( FL_SEP_RIGHT ) )
749 , aFLMargin( this, CUI_RES( GB_MARGIN ) )
750 , aFTMarginWidth ( this, CUI_RES( FT_MARGINWIDTH ) )
751 , aNMMarginWidth ( this, CUI_RES( NM_MARGINWIDTH ) )
752 , aCBMarginWidthDefault( this, CUI_RES( CB_MARGINWIDTHDEFAULT ) )
753 , aFTMarginHeight ( this, CUI_RES( FT_MARGINHEIGHT ) )
754 , aNMMarginHeight ( this, CUI_RES( NM_MARGINHEIGHT ) )
755 , aCBMarginHeightDefault( this, CUI_RES( CB_MARGINHEIGHTDEFAULT ) )
756 , aOKButton1( this, CUI_RES( 1 ) )
757 , aCancelButton1( this, CUI_RES( 1 ) )
758 , aHelpButton1( this, CUI_RES( 1 ) )
759 {
760 FreeResource();
761
762 aFLSepLeft.SetStyle(aFLSepLeft.GetStyle()|WB_VERT);
763 aFLSepRight.SetStyle(aFLSepRight.GetStyle()|WB_VERT);
764
765 Link aLink( STATIC_LINK( this, SfxInsertFloatingFrameDialog, CheckHdl ) );
766 aCBMarginWidthDefault.SetClickHdl( aLink );
767 aCBMarginHeightDefault.SetClickHdl( aLink );
768
769 aCBMarginWidthDefault.Check();
770 aCBMarginHeightDefault.Check();
771 aRBScrollingAuto.Check();
772 aRBFrameBorderOn.Check();
773
774 aBTOpen.SetClickHdl( STATIC_LINK( this, SfxInsertFloatingFrameDialog, OpenHdl ) );
775 }
776
SfxInsertFloatingFrameDialog(Window * pParent,const uno::Reference<embed::XEmbeddedObject> & xObj)777 SfxInsertFloatingFrameDialog::SfxInsertFloatingFrameDialog( Window *pParent, const uno::Reference < embed::XEmbeddedObject >& xObj )
778 : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OBJECT_IFRAME ), uno::Reference < embed::XStorage >() )
779 , aFTName ( this, CUI_RES( FT_FRAMENAME ) )
780 , aEDName ( this, CUI_RES( ED_FRAMENAME ) )
781 , aFTURL ( this, CUI_RES( FT_URL ) )
782 , aEDURL ( this, CUI_RES( ED_URL ) )
783 , aBTOpen ( this, CUI_RES(BT_FILEOPEN ) )
784
785 , aFLScrolling ( this, CUI_RES( GB_SCROLLING ) )
786 , aRBScrollingOn ( this, CUI_RES( RB_SCROLLINGON ) )
787 , aRBScrollingOff ( this, CUI_RES( RB_SCROLLINGOFF ) )
788 , aRBScrollingAuto ( this, CUI_RES( RB_SCROLLINGAUTO ) )
789
790 , aFLSepLeft( this, CUI_RES( FL_SEP_LEFT ) )
791 , aFLFrameBorder( this, CUI_RES( GB_BORDER ) )
792 , aRBFrameBorderOn ( this, CUI_RES( RB_FRMBORDER_ON ) )
793 , aRBFrameBorderOff ( this, CUI_RES( RB_FRMBORDER_OFF ) )
794
795 , aFLSepRight( this, CUI_RES( FL_SEP_RIGHT ) )
796 , aFLMargin( this, CUI_RES( GB_MARGIN ) )
797 , aFTMarginWidth ( this, CUI_RES( FT_MARGINWIDTH ) )
798 , aNMMarginWidth ( this, CUI_RES( NM_MARGINWIDTH ) )
799 , aCBMarginWidthDefault( this, CUI_RES( CB_MARGINWIDTHDEFAULT ) )
800 , aFTMarginHeight ( this, CUI_RES( FT_MARGINHEIGHT ) )
801 , aNMMarginHeight ( this, CUI_RES( NM_MARGINHEIGHT ) )
802 , aCBMarginHeightDefault( this, CUI_RES( CB_MARGINHEIGHTDEFAULT ) )
803 , aOKButton1( this, CUI_RES( 1 ) )
804 , aCancelButton1( this, CUI_RES( 1 ) )
805 , aHelpButton1( this, CUI_RES( 1 ) )
806 {
807 FreeResource();
808
809 m_xObj = xObj;
810
811 aFLSepLeft.SetStyle(aFLSepLeft.GetStyle()|WB_VERT);
812 aFLSepRight.SetStyle(aFLSepRight.GetStyle()|WB_VERT);
813
814 Link aLink( STATIC_LINK( this, SfxInsertFloatingFrameDialog, CheckHdl ) );
815 aCBMarginWidthDefault.SetClickHdl( aLink );
816 aCBMarginHeightDefault.SetClickHdl( aLink );
817
818 aCBMarginWidthDefault.Check();
819 aCBMarginHeightDefault.Check();
820 aRBScrollingAuto.Check();
821 aRBFrameBorderOn.Check();
822
823 aBTOpen.SetClickHdl( STATIC_LINK( this, SfxInsertFloatingFrameDialog, OpenHdl ) );
824 }
825
Execute()826 short SfxInsertFloatingFrameDialog::Execute()
827 {
828 short nRet = RET_OK;
829 sal_Bool bOK = sal_False;
830 uno::Reference < beans::XPropertySet > xSet;
831 if ( m_xObj.is() )
832 {
833 try
834 {
835 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
836 m_xObj->changeState( embed::EmbedStates::RUNNING );
837 xSet = uno::Reference < beans::XPropertySet >( m_xObj->getComponent(), uno::UNO_QUERY );
838 ::rtl::OUString aStr;
839 uno::Any aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameURL") );
840 if ( aAny >>= aStr )
841 aEDURL.SetText( aStr );
842 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameName") );
843 if ( aAny >>= aStr )
844 aEDName.SetText( aStr );
845
846 sal_Int32 nSize = SIZE_NOT_SET;
847 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginWidth") );
848 aAny >>= nSize;
849
850 if ( nSize == SIZE_NOT_SET )
851 {
852 aCBMarginWidthDefault.Check( sal_True );
853 aNMMarginWidth.SetText( String::CreateFromInt32( DEFAULT_MARGIN_WIDTH ) );
854 aFTMarginWidth.Enable( sal_False );
855 aNMMarginWidth.Enable( sal_False );
856 }
857 else
858 aNMMarginWidth.SetText( String::CreateFromInt32( nSize ) );
859
860 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginHeight") );
861 aAny >>= nSize;
862
863 if ( nSize == SIZE_NOT_SET )
864 {
865 aCBMarginHeightDefault.Check( sal_True );
866 aNMMarginHeight.SetText( String::CreateFromInt32( DEFAULT_MARGIN_HEIGHT ) );
867 aFTMarginHeight.Enable( sal_False );
868 aNMMarginHeight.Enable( sal_False );
869 }
870 else
871 aNMMarginHeight.SetText( String::CreateFromInt32( nSize ) );
872
873 sal_Bool bScrollOn = sal_False;
874 sal_Bool bScrollOff = sal_False;
875 sal_Bool bScrollAuto = sal_False;
876
877 sal_Bool bSet = sal_False;
878 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoScroll") );
879 aAny >>= bSet;
880 if ( !bSet )
881 {
882 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsScrollingMode") );
883 aAny >>= bSet;
884 bScrollOn = bSet;
885 bScrollOff = !bSet;
886 }
887 else
888 bScrollAuto = sal_True;
889
890 aRBScrollingOn.Check( bScrollOn );
891 aRBScrollingOff.Check( bScrollOff );
892 aRBScrollingAuto.Check( bScrollAuto );
893
894 bSet = sal_False;
895 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoBorder") );
896 aAny >>= bSet;
897 if ( !bSet )
898 {
899 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsBorder") );
900 aAny >>= bSet;
901 aRBFrameBorderOn.Check( bSet );
902 aRBFrameBorderOff.Check( !bSet );
903 }
904
905 SetUpdateMode( sal_True );
906 bOK = sal_True;
907 }
908 catch ( uno::Exception& )
909 {
910 DBG_ERROR( "No IFrame!" );
911 }
912 }
913 else
914 {
915 DBG_ASSERT( m_xStorage.is(), "No storage!");
916 bOK = m_xStorage.is();
917 }
918
919 if ( bOK && ( nRet = Dialog::Execute() ) == RET_OK )
920 {
921 ::rtl::OUString aURL;
922 if ( aEDURL.GetText().Len() )
923 {
924 // URL can be a valid and absolute URL or a system file name
925 INetURLObject aObj;
926 aObj.SetSmartProtocol( INET_PROT_FILE );
927 if ( aObj.SetSmartURL( aEDURL.GetText() ) )
928 aURL = aObj.GetMainURL( INetURLObject::NO_DECODE );
929 }
930
931 if ( !m_xObj.is() && aURL.getLength() )
932 {
933 // create the object
934 ::rtl::OUString aName;
935 SvGlobalName aClassId( SO3_IFRAME_CLASSID );
936 m_xObj = aCnt.CreateEmbeddedObject( aClassId.GetByteSequence(), aName );
937 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
938 m_xObj->changeState( embed::EmbedStates::RUNNING );
939 xSet = uno::Reference < beans::XPropertySet >( m_xObj->getComponent(), uno::UNO_QUERY );
940 }
941
942 if ( m_xObj.is() )
943 {
944 try
945 {
946 sal_Bool bIPActive = m_xObj->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE;
947 if ( bIPActive )
948 m_xObj->changeState( embed::EmbedStates::RUNNING );
949
950 ::rtl::OUString aName = aEDName.GetText();
951 ScrollingMode eScroll = ScrollingNo;
952 if ( aRBScrollingOn.IsChecked() )
953 eScroll = ScrollingYes;
954 if ( aRBScrollingOff.IsChecked() )
955 eScroll = ScrollingNo;
956 if ( aRBScrollingAuto.IsChecked() )
957 eScroll = ScrollingAuto;
958
959 sal_Bool bHasBorder = aRBFrameBorderOn.IsChecked();
960
961 long lMarginWidth;
962 if ( !aCBMarginWidthDefault.IsChecked() )
963 lMarginWidth = (long) aNMMarginWidth.GetText().ToInt32();
964 else
965 lMarginWidth = SIZE_NOT_SET;
966
967 long lMarginHeight;
968 if ( !aCBMarginHeightDefault.IsChecked() )
969 lMarginHeight = (long) aNMMarginHeight.GetText().ToInt32();
970 else
971 lMarginHeight = SIZE_NOT_SET;
972
973 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameURL"), makeAny( aURL ) );
974 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameName"), makeAny( aName ) );
975
976 if ( eScroll == ScrollingAuto )
977 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoScroll"),
978 makeAny( sal_True ) );
979 else
980 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsScrollingMode"),
981 makeAny( (sal_Bool) ( eScroll == ScrollingYes) ) );
982
983 //if ( aFrmDescr.IsFrameBorderSet() )
984 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsBorder"),
985 makeAny( bHasBorder ) );
986 /*else
987 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoBorder"),
988 makeAny( sal_True ) );*/
989
990 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginWidth"),
991 makeAny( sal_Int32( lMarginWidth ) ) );
992
993 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginHeight"),
994 makeAny( sal_Int32( lMarginHeight ) ) );
995
996 if ( bIPActive )
997 m_xObj->changeState( embed::EmbedStates::INPLACE_ACTIVE );
998 }
999 catch ( uno::Exception& )
1000 {
1001 DBG_ERROR( "No IFrame!" );
1002 }
1003 }
1004 }
1005
1006 return nRet;
1007 }
1008
1009 //------------------------------------------------------------------------------
1010
IMPL_STATIC_LINK(SfxInsertFloatingFrameDialog,CheckHdl,CheckBox *,pCB)1011 IMPL_STATIC_LINK( SfxInsertFloatingFrameDialog, CheckHdl, CheckBox*, pCB )
1012 {
1013 if ( pCB == &pThis->aCBMarginWidthDefault )
1014 {
1015 if ( pCB->IsChecked() )
1016 pThis->aNMMarginWidth.SetText( String::CreateFromInt32( DEFAULT_MARGIN_WIDTH ) );
1017 pThis->aFTMarginWidth.Enable( !pCB->IsChecked() );
1018 pThis->aNMMarginWidth.Enable( !pCB->IsChecked() );
1019 }
1020
1021 if ( pCB == &pThis->aCBMarginHeightDefault )
1022 {
1023 if ( pCB->IsChecked() )
1024 pThis->aNMMarginHeight.SetText( String::CreateFromInt32( DEFAULT_MARGIN_HEIGHT ) );
1025 pThis->aFTMarginHeight.Enable( !pCB->IsChecked() );
1026 pThis->aNMMarginHeight.Enable( !pCB->IsChecked() );
1027 }
1028
1029 return 0L;
1030 }
1031
1032 //------------------------------------------------------------------------------
1033
IMPL_STATIC_LINK(SfxInsertFloatingFrameDialog,OpenHdl,PushButton *,EMPTYARG)1034 IMPL_STATIC_LINK( SfxInsertFloatingFrameDialog, OpenHdl, PushButton*, EMPTYARG )
1035 {
1036 Window* pOldParent = Application::GetDefDialogParent();
1037 Application::SetDefDialogParent( pThis );
1038
1039 // create the file dialog
1040 sfx2::FileDialogHelper aFileDlg( WB_OPEN | SFXWB_PASSWORD, String() );
1041
1042 // set the title
1043 aFileDlg.SetTitle( OUString( String( CUI_RES( MD_INSERT_OBJECT_IFRAME ) ) ) );
1044
1045 // show the dialog
1046 if ( aFileDlg.Execute() == ERRCODE_NONE )
1047 pThis->aEDURL.SetText(
1048 INetURLObject( aFileDlg.GetPath() ).GetMainURL( INetURLObject::DECODE_WITH_CHARSET ) );
1049
1050 Application::SetDefDialogParent( pOldParent );
1051 return 0L;
1052 }
1053
1054