1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: moduldl2.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_basctl.hxx"
35 #define GLOBALOVERFLOW
37 #include <ide_pch.hxx>
39 #include <svtools/filedlg.hxx>
42 #include <sot/storinfo.hxx>
44 #include <moduldlg.hrc>
45 #include <moduldlg.hxx>
46 #include <basidesh.hrc>
47 #include <basidesh.hxx>
48 #include <bastypes.hxx>
50 #include <baside2.hrc>
51 #include <iderdll.hxx>
52 #include <iderdll2.hxx>
53 #include <svx/passwd.hxx>
54 #include <sbxitem.hxx>
56 #include <ucbhelper/content.hxx>
57 #include "rtl/uri.hxx"
58 #include <tools/urlobj.hxx>
59 #include <tools/diagnose_ex.h>
61 #include <sot/storage.hxx>
62 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
63 #include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
64 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
65 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
66 #ifndef _COM_SUN_STAR_SCRIPT_XLIBRYARYCONTAINER2_HPP_
67 #include <com/sun/star/script/XLibraryContainer2.hpp>
69 #include <com/sun/star/script/XLibraryContainerPassword.hpp>
70 #include <com/sun/star/script/XLibraryContainerExport.hpp>
71 #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
72 #include "com/sun/star/ucb/XCommandEnvironment.hpp"
73 #include <com/sun/star/ucb/NameClash.hpp>
74 #include "com/sun/star/packages/manifest/XManifestWriter.hpp"
75 #include <svtools/pathoptions.hxx>
76 #include <comphelper/processfactory.hxx>
78 #include <com/sun/star/util/VetoException.hpp>
79 #include <com/sun/star/script/ModuleSizeExceededRequest.hpp>
81 using namespace ::comphelper
;
82 using ::rtl::OUString
;
83 using namespace ::com::sun::star
;
84 using namespace ::com::sun::star::uno
;
85 using namespace ::com::sun::star::lang
;
86 using namespace ::com::sun::star::ucb
;
87 using namespace ::com::sun::star::ui::dialogs
;
90 typedef ::cppu::WeakImplHelper1
< task::XInteractionHandler
> HandlerImpl_BASE
;
92 class DummyInteractionHandler
: public HandlerImpl_BASE
94 Reference
< task::XInteractionHandler
> m_xHandler
;
96 DummyInteractionHandler( const Reference
< task::XInteractionHandler
>& xHandler
) : m_xHandler( xHandler
){}
98 virtual void SAL_CALL
handle( const Reference
< task::XInteractionRequest
>& rRequest
) throw (::com::sun::star::uno::RuntimeException
)
100 if ( m_xHandler
.is() )
102 script::ModuleSizeExceededRequest aModSizeException
;
103 if ( rRequest
->getRequest() >>= aModSizeException
)
104 m_xHandler
->handle( rRequest
);
109 //----------------------------------------------------------------------------
111 //----------------------------------------------------------------------------
112 class BasicLibUserData
115 ScriptDocument m_aDocument
;
118 BasicLibUserData( const ScriptDocument
& rDocument
) : m_aDocument( rDocument
) { }
119 virtual ~BasicLibUserData() {};
121 const ScriptDocument
&
122 GetDocument() const { return m_aDocument
; }
126 //----------------------------------------------------------------------------
127 // BasicLibLBoxString
128 //----------------------------------------------------------------------------
130 class BasicLibLBoxString
: public SvLBoxString
133 BasicLibLBoxString( SvLBoxEntry
* pEntry
, USHORT nFlags
, const String
& rTxt
) :
134 SvLBoxString( pEntry
, nFlags
, rTxt
) {}
136 virtual void Paint( const Point
& rPos
, SvLBox
& rDev
, USHORT nFlags
, SvLBoxEntry
* pEntry
);
139 //----------------------------------------------------------------------------
141 void BasicLibLBoxString::Paint( const Point
& rPos
, SvLBox
& rDev
, USHORT
, SvLBoxEntry
* pEntry
)
143 // Change text color if library is read only:
144 bool bReadOnly
= false;
145 if (pEntry
&& pEntry
->GetUserData())
147 ScriptDocument
aDocument(
148 static_cast< BasicLibUserData
* >(pEntry
->GetUserData())->
151 rtl::OUString
aLibName(
152 static_cast< SvLBoxString
* >(pEntry
->GetItem(1))->GetText());
153 Reference
< script::XLibraryContainer2
> xModLibContainer(
154 aDocument
.getLibraryContainer( E_SCRIPTS
), UNO_QUERY
);
155 Reference
< script::XLibraryContainer2
> xDlgLibContainer(
156 aDocument
.getLibraryContainer( E_DIALOGS
), UNO_QUERY
);
158 = (xModLibContainer
.is() && xModLibContainer
->hasByName(aLibName
)
159 && xModLibContainer
->isLibraryReadOnly(aLibName
))
160 || (xDlgLibContainer
.is() && xDlgLibContainer
->hasByName(aLibName
)
161 && xDlgLibContainer
->isLibraryReadOnly(aLibName
));
164 rDev
.DrawCtrlText(rPos
, GetText(), 0, STRING_LEN
, TEXT_DRAW_DISABLE
);
166 rDev
.DrawText(rPos
, GetText());
170 //----------------------------------------------------------------------------
172 //----------------------------------------------------------------------------
174 BasicCheckBox::BasicCheckBox( Window
* pParent
, const ResId
& rResId
)
175 :SvTabListBox( pParent
, rResId
)
176 ,m_aDocument( ScriptDocument::getApplicationScriptDocument() )
178 nMode
= LIBMODE_MANAGER
;
179 long aTabs_
[] = { 1, 12 }; // Mindestens einen braucht die TabPos...
180 // 12 wegen der Checkbox
185 //----------------------------------------------------------------------------
187 __EXPORT
BasicCheckBox::~BasicCheckBox()
192 SvLBoxEntry
* pEntry
= First();
195 delete (BasicLibUserData
*)pEntry
->GetUserData();
196 pEntry
= Next( pEntry
);
200 //----------------------------------------------------------------------------
202 void BasicCheckBox::Init()
204 pCheckButton
= new SvLBoxButtonData(this);
206 if ( nMode
== LIBMODE_CHOOSER
)
207 EnableCheckButton( pCheckButton
);
209 EnableCheckButton( 0 );
214 //----------------------------------------------------------------------------
216 void BasicCheckBox::SetMode( USHORT n
)
220 if ( nMode
== LIBMODE_CHOOSER
)
221 EnableCheckButton( pCheckButton
);
223 EnableCheckButton( 0 );
226 //----------------------------------------------------------------------------
228 SvLBoxEntry
* BasicCheckBox::DoInsertEntry( const String
& rStr
, ULONG nPos
)
230 return SvTabListBox::InsertEntryToColumn( rStr
, nPos
, 0 );
233 //----------------------------------------------------------------------------
235 SvLBoxEntry
* BasicCheckBox::FindEntry( const String
& rName
)
237 ULONG nCount
= GetEntryCount();
238 for ( ULONG i
= 0; i
< nCount
; i
++ )
240 SvLBoxEntry
* pEntry
= GetEntry( i
);
241 DBG_ASSERT( pEntry
, "pEntry?!" );
242 if ( rName
.CompareIgnoreCaseToAscii( GetEntryText( pEntry
, 0 ) ) == COMPARE_EQUAL
)
248 //----------------------------------------------------------------------------
250 void BasicCheckBox::CheckEntryPos( ULONG nPos
, BOOL bCheck
)
252 if ( nPos
< GetEntryCount() )
254 SvLBoxEntry
* pEntry
= GetEntry( nPos
);
256 if ( bCheck
!= GetCheckButtonState( pEntry
) )
257 SetCheckButtonState( pEntry
,
259 ? SvButtonState(SV_BUTTON_CHECKED
)
260 : SvButtonState(SV_BUTTON_UNCHECKED
) );
264 //----------------------------------------------------------------------------
266 BOOL
BasicCheckBox::IsChecked( ULONG nPos
) const
268 if ( nPos
< GetEntryCount() )
269 return (GetCheckButtonState( GetEntry( nPos
) ) == SV_BUTTON_CHECKED
);
273 //----------------------------------------------------------------------------
275 void BasicCheckBox::InitEntry( SvLBoxEntry
* pEntry
, const XubString
& rTxt
, const Image
& rImg1
, const Image
& rImg2
, SvLBoxButtonKind eButtonKind
)
277 SvTabListBox::InitEntry( pEntry
, rTxt
, rImg1
, rImg2
, eButtonKind
);
279 if ( nMode
== LIBMODE_MANAGER
)
281 // initialize all columns with own string class (column 0 == bitmap)
282 USHORT nCount
= pEntry
->ItemCount();
283 for ( USHORT nCol
= 1; nCol
< nCount
; ++nCol
)
285 SvLBoxString
* pCol
= (SvLBoxString
*)pEntry
->GetItem( nCol
);
286 BasicLibLBoxString
* pStr
= new BasicLibLBoxString( pEntry
, 0, pCol
->GetText() );
287 pEntry
->ReplaceItem( pStr
, nCol
);
292 //----------------------------------------------------------------------------
294 BOOL __EXPORT
BasicCheckBox::EditingEntry( SvLBoxEntry
* pEntry
, Selection
& )
296 if ( nMode
!= LIBMODE_MANAGER
)
299 DBG_ASSERT( pEntry
, "Kein Eintrag?" );
301 // check, if Standard library
302 String aLibName
= GetEntryText( pEntry
, 0 );
303 if ( aLibName
.EqualsIgnoreCaseAscii( "Standard" ) )
305 ErrorBox( this, WB_OK
| WB_DEF_OK
, String( IDEResId( RID_STR_CANNOTCHANGENAMESTDLIB
) ) ).Execute();
309 // check, if library is readonly
310 ::rtl::OUString
aOULibName( aLibName
);
311 Reference
< script::XLibraryContainer2
> xModLibContainer( m_aDocument
.getLibraryContainer( E_SCRIPTS
), UNO_QUERY
);
312 Reference
< script::XLibraryContainer2
> xDlgLibContainer( m_aDocument
.getLibraryContainer( E_DIALOGS
), UNO_QUERY
);
313 if ( ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) && xModLibContainer
->isLibraryReadOnly( aOULibName
) && !xModLibContainer
->isLibraryLink( aOULibName
) ) ||
314 ( xDlgLibContainer
.is() && xDlgLibContainer
->hasByName( aOULibName
) && xDlgLibContainer
->isLibraryReadOnly( aOULibName
) && !xDlgLibContainer
->isLibraryLink( aOULibName
) ) )
316 ErrorBox( this, WB_OK
| WB_DEF_OK
, String( IDEResId( RID_STR_LIBISREADONLY
) ) ).Execute();
320 // i24094: Password verification necessary for renaming
322 if ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) && !xModLibContainer
->isLibraryLoaded( aOULibName
) )
325 Reference
< script::XLibraryContainerPassword
> xPasswd( xModLibContainer
, UNO_QUERY
);
326 if ( xPasswd
.is() && xPasswd
->isLibraryPasswordProtected( aOULibName
) && !xPasswd
->isLibraryPasswordVerified( aOULibName
) )
329 Reference
< script::XLibraryContainer
> xModLibContainer1( xModLibContainer
, UNO_QUERY
);
330 bOK
= QueryPassword( xModLibContainer1
, aLibName
, aPassword
);
336 // TODO: check if library is reference/link
338 // Prueffen, ob Referenz...
340 USHORT nLib = pBasMgr->GetLibId( GetEntryText( pEntry, 0 ) );
341 DBG_ASSERT( nLib != LIB_NOTFOUND, "LibId ?!" );
342 if ( pBasMgr->IsReference( nLib ) )
344 ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_CANNOTCHANGENAMEREFLIB ) ) ).Execute();
351 //----------------------------------------------------------------------------
353 BOOL __EXPORT
BasicCheckBox::EditedEntry( SvLBoxEntry
* pEntry
, const String
& rNewText
)
355 BOOL bValid
= ( rNewText
.Len() <= 30 ) && BasicIDE::IsValidSbxName( rNewText
);
356 String
aCurText( GetEntryText( pEntry
, 0 ) );
357 if ( bValid
&& ( aCurText
!= rNewText
) )
361 ::rtl::OUString
aOUOldName( aCurText
);
362 ::rtl::OUString
aOUNewName( rNewText
);
364 Reference
< script::XLibraryContainer2
> xModLibContainer( m_aDocument
.getLibraryContainer( E_SCRIPTS
), UNO_QUERY
);
365 if ( xModLibContainer
.is() )
367 xModLibContainer
->renameLibrary( aOUOldName
, aOUNewName
);
370 Reference
< script::XLibraryContainer2
> xDlgLibContainer( m_aDocument
.getLibraryContainer( E_DIALOGS
), UNO_QUERY
);
371 if ( xDlgLibContainer
.is() )
373 xDlgLibContainer
->renameLibrary( aOUOldName
, aOUNewName
);
376 BasicIDE::MarkDocumentModified( m_aDocument
);
377 SfxBindings
* pBindings
= BasicIDE::GetBindingsPtr();
380 pBindings
->Invalidate( SID_BASICIDE_LIBSELECTOR
);
381 pBindings
->Update( SID_BASICIDE_LIBSELECTOR
);
384 catch ( container::ElementExistException
& )
386 ErrorBox( this, WB_OK
| WB_DEF_OK
, String( IDEResId( RID_STR_SBXNAMEALLREADYUSED
) ) ).Execute();
389 catch ( container::NoSuchElementException
& )
391 DBG_UNHANDLED_EXCEPTION();
398 if ( rNewText
.Len() > 30 )
399 ErrorBox( this, WB_OK
| WB_DEF_OK
, String( IDEResId( RID_STR_LIBNAMETOLONG
) ) ).Execute();
401 ErrorBox( this, WB_OK
| WB_DEF_OK
, String( IDEResId( RID_STR_BADSBXNAME
) ) ).Execute();
407 //----------------------------------------------------------------------------
409 //----------------------------------------------------------------------------
411 IMPL_LINK(NewObjectDialog
, OkButtonHandler
, Button
*, EMPTYARG
)
413 if (BasicIDE::IsValidSbxName(aEdit
.GetText()))
417 ErrorBox(this, WB_OK
| WB_DEF_OK
,
418 String(IDEResId(RID_STR_BADSBXNAME
))).Execute();
424 NewObjectDialog::NewObjectDialog(Window
* pParent
, USHORT nMode
,
426 : ModalDialog( pParent
, IDEResId( RID_DLG_NEWLIB
) ),
427 aText( this, IDEResId( RID_FT_NEWLIB
) ),
428 aEdit( this, IDEResId( RID_ED_LIBNAME
) ),
429 aOKButton( this, IDEResId( RID_PB_OK
) ),
430 aCancelButton( this, IDEResId( RID_PB_CANCEL
) )
435 if ( nMode
== NEWOBJECTMODE_LIB
)
437 SetText( String( IDEResId( RID_STR_NEWLIB
) ) );
439 else if ( nMode
== NEWOBJECTMODE_MOD
)
441 SetText( String( IDEResId( RID_STR_NEWMOD
) ) );
443 else if ( nMode
== NEWOBJECTMODE_METH
)
445 SetText( String( IDEResId( RID_STR_NEWMETH
) ) );
449 SetText( String( IDEResId( RID_STR_NEWDLG
) ) );
453 aOKButton
.SetClickHdl(LINK(this, NewObjectDialog
, OkButtonHandler
));
456 //----------------------------------------------------------------------------
458 NewObjectDialog::~NewObjectDialog()
462 //----------------------------------------------------------------------------
464 //----------------------------------------------------------------------------
466 IMPL_LINK(ExportDialog
, OkButtonHandler
, Button
*, EMPTYARG
)
468 mbExportAsPackage
= maExportAsPackageButton
.IsChecked();
473 ExportDialog::ExportDialog( Window
* pParent
)
474 : ModalDialog( pParent
, IDEResId( RID_DLG_EXPORT
) ),
475 maExportAsPackageButton( this, IDEResId( RB_EXPORTASPACKAGE
) ),
476 maExportAsBasicButton( this, IDEResId( RB_EXPORTASBASIC
) ),
477 maOKButton( this, IDEResId( RID_PB_OK
) ),
478 maCancelButton( this, IDEResId( RID_PB_CANCEL
) )
481 maExportAsPackageButton
.Check();
482 maOKButton
.SetClickHdl(LINK(this, ExportDialog
, OkButtonHandler
));
485 //----------------------------------------------------------------------------
487 ExportDialog::~ExportDialog()
491 //----------------------------------------------------------------------------
493 //----------------------------------------------------------------------------
495 LibPage::LibPage( Window
* pParent
)
496 :TabPage( pParent
, IDEResId( RID_TP_LIBS
) )
497 ,aBasicsText( this, IDEResId( RID_STR_BASICS
) )
498 ,aBasicsBox( this, IDEResId( RID_LB_BASICS
) )
499 ,aLibText( this, IDEResId( RID_STR_LIB
) )
500 ,aLibBox( this, IDEResId( RID_TRLBOX
) )
501 ,aEditButton( this, IDEResId( RID_PB_EDIT
) )
502 ,aCloseButton( this, IDEResId( RID_PB_CLOSE
) )
503 ,aPasswordButton( this, IDEResId( RID_PB_PASSWORD
) )
504 ,aExportButton( this, IDEResId( RID_PB_EXPORT
) )
505 ,aNewLibButton( this, IDEResId( RID_PB_NEWLIB
) )
506 ,aInsertLibButton( this, IDEResId( RID_PB_APPEND
) )
507 ,aDelButton( this, IDEResId( RID_PB_DELETE
) )
508 ,m_aCurDocument( ScriptDocument::getApplicationScriptDocument() )
509 ,m_eCurLocation( LIBRARY_LOCATION_UNKNOWN
)
514 aEditButton
.SetClickHdl( LINK( this, LibPage
, ButtonHdl
) );
515 aNewLibButton
.SetClickHdl( LINK( this, LibPage
, ButtonHdl
) );
516 aPasswordButton
.SetClickHdl( LINK( this, LibPage
, ButtonHdl
) );
517 aExportButton
.SetClickHdl( LINK( this, LibPage
, ButtonHdl
) );
518 aInsertLibButton
.SetClickHdl( LINK( this, LibPage
, ButtonHdl
) );
519 aDelButton
.SetClickHdl( LINK( this, LibPage
, ButtonHdl
) );
520 aCloseButton
.SetClickHdl( LINK( this, LibPage
, ButtonHdl
) );
521 aLibBox
.SetSelectHdl( LINK( this, LibPage
, TreeListHighlightHdl
) );
523 aBasicsBox
.SetSelectHdl( LINK( this, LibPage
, BasicSelectHdl
) );
525 aLibBox
.SetMode( LIBMODE_MANAGER
);
526 aLibBox
.EnableInplaceEditing( TRUE
);
527 aLibBox
.SetWindowBits( WB_HSCROLL
);
528 aCloseButton
.GrabFocus();
530 long aTabs
[] = { 2, 30, 120 };
531 aLibBox
.SetTabs( aTabs
, MAP_PIXEL
);
534 aBasicsBox
.SelectEntryPos( 0 );
540 //----------------------------------------------------------------------------
544 USHORT nCount
= aBasicsBox
.GetEntryCount();
545 for ( USHORT i
= 0; i
< nCount
; ++i
)
547 BasicDocumentEntry
* pEntry
= (BasicDocumentEntry
*)aBasicsBox
.GetEntryData( i
);
552 //----------------------------------------------------------------------------
554 void LibPage::CheckButtons()
556 SvLBoxEntry
* pCur
= aLibBox
.GetCurEntry();
559 String aLibName
= aLibBox
.GetEntryText( pCur
, 0 );
560 ::rtl::OUString
aOULibName( aLibName
);
561 Reference
< script::XLibraryContainer2
> xModLibContainer( m_aCurDocument
.getLibraryContainer( E_SCRIPTS
), UNO_QUERY
);
562 Reference
< script::XLibraryContainer2
> xDlgLibContainer( m_aCurDocument
.getLibraryContainer( E_DIALOGS
), UNO_QUERY
);
564 if ( m_eCurLocation
== LIBRARY_LOCATION_SHARE
)
566 aPasswordButton
.Disable();
567 aNewLibButton
.Disable();
568 aInsertLibButton
.Disable();
569 aDelButton
.Disable();
571 else if ( aLibName
.EqualsIgnoreCaseAscii( "Standard" ) )
573 aPasswordButton
.Disable();
574 aNewLibButton
.Enable();
575 aInsertLibButton
.Enable();
576 aExportButton
.Disable();
577 aDelButton
.Disable();
578 if ( !aLibBox
.HasFocus() )
579 aCloseButton
.GrabFocus();
581 else if ( ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) && xModLibContainer
->isLibraryReadOnly( aOULibName
) ) ||
582 ( xDlgLibContainer
.is() && xDlgLibContainer
->hasByName( aOULibName
) && xDlgLibContainer
->isLibraryReadOnly( aOULibName
) ) )
584 aPasswordButton
.Disable();
585 aNewLibButton
.Enable();
586 aInsertLibButton
.Enable();
587 if ( ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) && xModLibContainer
->isLibraryReadOnly( aOULibName
) && !xModLibContainer
->isLibraryLink( aOULibName
) ) ||
588 ( xDlgLibContainer
.is() && xDlgLibContainer
->hasByName( aOULibName
) && xDlgLibContainer
->isLibraryReadOnly( aOULibName
) && !xDlgLibContainer
->isLibraryLink( aOULibName
) ) )
589 aDelButton
.Disable();
595 if ( xModLibContainer
.is() && !xModLibContainer
->hasByName( aOULibName
) )
596 aPasswordButton
.Disable();
598 aPasswordButton
.Enable();
600 aNewLibButton
.Enable();
601 aInsertLibButton
.Enable();
602 aExportButton
.Enable();
608 //----------------------------------------------------------------------------
610 void __EXPORT
LibPage::ActivatePage()
615 //----------------------------------------------------------------------------
618 void __EXPORT
LibPage::DeactivatePage()
622 //----------------------------------------------------------------------------
625 IMPL_LINK_INLINE_START( LibPage
, TreeListHighlightHdl
, SvTreeListBox
*, pBox
)
627 if ( pBox
->IsSelected( pBox
->GetHdlEntry() ) )
631 IMPL_LINK_INLINE_END( LibPage
, TreeListHighlightHdl
, SvTreeListBox
*, pBox
)
633 //----------------------------------------------------------------------------
635 IMPL_LINK_INLINE_START( LibPage
, BasicSelectHdl
, ListBox
*, pBox
)
642 IMPL_LINK_INLINE_END( LibPage
, BasicSelectHdl
, ListBox
*, pBox
)
644 //----------------------------------------------------------------------------
646 IMPL_LINK( LibPage
, ButtonHdl
, Button
*, pButton
)
648 if ( pButton
== &aEditButton
)
650 SfxAllItemSet
aArgs( SFX_APP()->GetPool() );
651 SfxRequest
aRequest( SID_BASICIDE_APPEAR
, SFX_CALLMODE_SYNCHRON
, aArgs
);
652 SFX_APP()->ExecuteSlot( aRequest
);
654 SfxUsrAnyItem
aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL
, makeAny( m_aCurDocument
.getDocumentOrNull() ) );
655 SvLBoxEntry
* pCurEntry
= aLibBox
.GetCurEntry();
656 DBG_ASSERT( pCurEntry
, "Entry?!" );
657 String
aLibName( aLibBox
.GetEntryText( pCurEntry
, 0 ) );
658 SfxStringItem
aLibNameItem( SID_BASICIDE_ARG_LIBNAME
, aLibName
);
659 BasicIDEShell
* pIDEShell
= IDE_DLL()->GetShell();
660 SfxViewFrame
* pViewFrame
= pIDEShell
? pIDEShell
->GetViewFrame() : NULL
;
661 SfxDispatcher
* pDispatcher
= pViewFrame
? pViewFrame
->GetDispatcher() : NULL
;
664 pDispatcher
->Execute( SID_BASICIDE_LIBSELECTED
,
665 SFX_CALLMODE_ASYNCHRON
, &aDocItem
, &aLibNameItem
, 0L );
670 else if ( pButton
== &aNewLibButton
)
672 else if ( pButton
== &aInsertLibButton
)
674 else if ( pButton
== &aExportButton
)
676 else if ( pButton
== &aDelButton
)
678 else if ( pButton
== &aCloseButton
)
683 else if ( pButton
== &aPasswordButton
)
685 SvLBoxEntry
* pCurEntry
= aLibBox
.GetCurEntry();
686 String
aLibName( aLibBox
.GetEntryText( pCurEntry
, 0 ) );
687 ::rtl::OUString
aOULibName( aLibName
);
689 // load module library (if not loaded)
690 Reference
< script::XLibraryContainer
> xModLibContainer
= m_aCurDocument
.getLibraryContainer( E_SCRIPTS
);
691 if ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) && !xModLibContainer
->isLibraryLoaded( aOULibName
) )
693 BasicIDEShell
* pIDEShell
= IDE_DLL()->GetShell();
695 pIDEShell
->GetViewFrame()->GetWindow().EnterWait();
696 xModLibContainer
->loadLibrary( aOULibName
);
698 pIDEShell
->GetViewFrame()->GetWindow().LeaveWait();
701 // load dialog library (if not loaded)
702 Reference
< script::XLibraryContainer
> xDlgLibContainer
= m_aCurDocument
.getLibraryContainer( E_DIALOGS
);
703 if ( xDlgLibContainer
.is() && xDlgLibContainer
->hasByName( aOULibName
) && !xDlgLibContainer
->isLibraryLoaded( aOULibName
) )
705 BasicIDEShell
* pIDEShell
= IDE_DLL()->GetShell();
707 pIDEShell
->GetViewFrame()->GetWindow().EnterWait();
708 xDlgLibContainer
->loadLibrary( aOULibName
);
710 pIDEShell
->GetViewFrame()->GetWindow().LeaveWait();
713 // check, if library is password protected
714 if ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) )
716 Reference
< script::XLibraryContainerPassword
> xPasswd( xModLibContainer
, UNO_QUERY
);
719 BOOL bProtected
= xPasswd
->isLibraryPasswordProtected( aOULibName
);
721 // change password dialog
722 SvxPasswordDialog
* pDlg
= new SvxPasswordDialog( this, TRUE
, !bProtected
);
723 pDlg
->SetCheckPasswordHdl( LINK( this, LibPage
, CheckPasswordHdl
) );
725 if ( pDlg
->Execute() == RET_OK
)
727 BOOL bNewProtected
= xPasswd
->isLibraryPasswordProtected( aOULibName
);
729 if ( bNewProtected
!= bProtected
)
731 ULONG nPos
= (ULONG
)aLibBox
.GetModel()->GetAbsPos( pCurEntry
);
732 aLibBox
.GetModel()->Remove( pCurEntry
);
733 ImpInsertLibEntry( aLibName
, nPos
);
734 aLibBox
.SetCurEntry( aLibBox
.GetEntry( nPos
) );
737 BasicIDE::MarkDocumentModified( m_aCurDocument
);
747 //----------------------------------------------------------------------------
749 IMPL_LINK_INLINE_START( LibPage
, CheckPasswordHdl
, SvxPasswordDialog
*, pDlg
)
753 SvLBoxEntry
* pCurEntry
= aLibBox
.GetCurEntry();
754 ::rtl::OUString
aOULibName( aLibBox
.GetEntryText( pCurEntry
, 0 ) );
755 Reference
< script::XLibraryContainerPassword
> xPasswd( m_aCurDocument
.getLibraryContainer( E_SCRIPTS
), UNO_QUERY
);
761 ::rtl::OUString
aOUOldPassword( pDlg
->GetOldPassword() );
762 ::rtl::OUString
aOUNewPassword( pDlg
->GetNewPassword() );
763 xPasswd
->changeLibraryPassword( aOULibName
, aOUOldPassword
, aOUNewPassword
);
773 IMPL_LINK_INLINE_END( LibPage
, CheckPasswordHdl
, SvxPasswordDialog
*, pDlg
)
775 //----------------------------------------------------------------------------
777 void LibPage::NewLib()
779 createLibImpl( static_cast<Window
*>( this ), m_aCurDocument
, &aLibBox
, NULL
);
782 //----------------------------------------------------------------------------
784 void LibPage::InsertLib()
787 Reference
< lang::XMultiServiceFactory
> xMSF( ::comphelper::getProcessServiceFactory() );
788 Reference
< XFilePicker
> xFP
;
791 Sequence
<Any
> aServiceType(1);
792 aServiceType
[0] <<= TemplateDescription::FILEOPEN_SIMPLE
;
793 xFP
= Reference
< XFilePicker
>( xMSF
->createInstanceWithArguments(
794 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType
), UNO_QUERY
);
796 xFP
->setTitle( String( IDEResId( RID_STR_APPENDLIBS
) ) );
799 ::rtl::OUString aTitle
= String( IDEResId( RID_STR_BASIC
) );
800 ::rtl::OUString aFilter
;
801 aFilter
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.sbl;*.xlc;*.xlb" ) ); // library files
802 aFilter
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sdw;*.sxw;*.odt" ) ); // text
803 aFilter
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.vor;*.stw;*.ott" ) ); // text template
804 aFilter
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sgl;*.sxg;*.odm" ) ); // master document
805 aFilter
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.oth" ) ); // html document template
806 aFilter
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sdc;*.sxc;*.ods" ) ); // spreadsheet
807 aFilter
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.stc;*.ots" ) ); // spreadsheet template
808 aFilter
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sda;*.sxd;*.odg" ) ); // drawing
809 aFilter
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.std;*.otg" ) ); // drawing template
810 aFilter
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sdd;*.sxi;*.odp" ) ); // presentation
811 aFilter
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sti;*.otp" ) ); // presentation template
812 aFilter
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sxm;*.odf" ) ); // formula
813 Reference
< XFilterManager
> xFltMgr(xFP
, UNO_QUERY
);
814 xFltMgr
->appendFilter( aTitle
, aFilter
);
816 // set display directory and filter
817 String
aPath( IDE_DLL()->GetExtraData()->GetAddLibPath() );
820 xFP
->setDisplayDirectory( aPath
);
824 // macro path from configuration management
825 xFP
->setDisplayDirectory( SvtPathOptions().GetWorkPath() );
828 String
aLastFilter( IDE_DLL()->GetExtraData()->GetAddLibFilter() );
829 if ( aLastFilter
.Len() )
831 xFltMgr
->setCurrentFilter( aLastFilter
);
835 xFltMgr
->setCurrentFilter( String( IDEResId( RID_STR_BASIC
) ) );
838 if ( xFP
->execute() == RET_OK
)
840 IDE_DLL()->GetExtraData()->SetAddLibPath( xFP
->getDisplayDirectory() );
841 IDE_DLL()->GetExtraData()->SetAddLibFilter( xFltMgr
->getCurrentFilter() );
843 // library containers for import
844 Reference
< script::XLibraryContainer2
> xModLibContImport
;
845 Reference
< script::XLibraryContainer2
> xDlgLibContImport
;
848 Sequence
< ::rtl::OUString
> aFiles
= xFP
->getFiles();
849 INetURLObject
aURLObj( aFiles
[0] );
850 INetURLObject
aModURLObj( aURLObj
);
851 INetURLObject
aDlgURLObj( aURLObj
);
853 String aBase
= aURLObj
.getBase();
854 String aModBase
= String::CreateFromAscii( "script" );
855 String aDlgBase
= String::CreateFromAscii( "dialog" );
857 if ( aBase
== aModBase
|| aBase
== aDlgBase
)
859 aModURLObj
.setBase( aModBase
);
860 aDlgURLObj
.setBase( aDlgBase
);
865 Reference
< XSimpleFileAccess
> xSFA( xMSF
->createInstance(
866 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" ) ) ), UNO_QUERY
);
870 ::rtl::OUString
aModURL( aModURLObj
.GetMainURL( INetURLObject::NO_DECODE
) );
871 if ( xSFA
->exists( aModURL
) )
873 Sequence
<Any
> aSeqModURL(1);
874 aSeqModURL
[0] <<= aModURL
;
875 xModLibContImport
= Reference
< script::XLibraryContainer2
>( xMSF
->createInstanceWithArguments(
876 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.DocumentScriptLibraryContainer" ) ), aSeqModURL
), UNO_QUERY
);
879 ::rtl::OUString
aDlgURL( aDlgURLObj
.GetMainURL( INetURLObject::NO_DECODE
) );
880 if ( xSFA
->exists( aDlgURL
) )
882 Sequence
<Any
> aSeqDlgURL(1);
883 aSeqDlgURL
[0] <<= aDlgURL
;
884 xDlgLibContImport
= Reference
< script::XLibraryContainer2
>( xMSF
->createInstanceWithArguments(
885 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.DocumentDialogLibraryContainer" ) ), aSeqDlgURL
), UNO_QUERY
);
890 if ( xModLibContImport
.is() || xDlgLibContImport
.is() )
892 LibDialog
* pLibDlg
= 0;
894 Reference
< script::XLibraryContainer
> xModLibContImp( xModLibContImport
, UNO_QUERY
);
895 Reference
< script::XLibraryContainer
> xDlgLibContImp( xDlgLibContImport
, UNO_QUERY
);
896 Sequence
< ::rtl::OUString
> aLibNames
= BasicIDE::GetMergedLibraryNames( xModLibContImp
, xDlgLibContImp
);
897 sal_Int32 nLibCount
= aLibNames
.getLength();
898 const ::rtl::OUString
* pLibNames
= aLibNames
.getConstArray();
899 for ( sal_Int32 i
= 0 ; i
< nLibCount
; i
++ )
901 // library import dialog
904 pLibDlg
= new LibDialog( this );
905 pLibDlg
->SetStorageName( aURLObj
.getName() );
906 pLibDlg
->GetLibBox().SetMode( LIBMODE_CHOOSER
);
910 String
aLibName( pLibNames
[ i
] );
911 String
aOULibName( aLibName
);
912 if ( !( ( xModLibContImport
.is() && xModLibContImport
->hasByName( aOULibName
) && xModLibContImport
->isLibraryLink( aOULibName
) ) ||
913 ( xDlgLibContImport
.is() && xDlgLibContImport
->hasByName( aOULibName
) && xDlgLibContImport
->isLibraryLink( aOULibName
) ) ) )
915 SvLBoxEntry
* pEntry
= pLibDlg
->GetLibBox().DoInsertEntry( aLibName
);
916 USHORT nPos
= (USHORT
) pLibDlg
->GetLibBox().GetModel()->GetAbsPos( pEntry
);
917 pLibDlg
->GetLibBox().CheckEntryPos( nPos
, TRUE
);
922 InfoBox( this, String( IDEResId( RID_STR_NOLIBINSTORAGE
) ) ).Execute();
925 BOOL bChanges
= FALSE
;
926 String
aExtension( aURLObj
.getExtension() );
927 String
aLibExtension( String::CreateFromAscii( "xlb" ) );
928 String
aContExtension( String::CreateFromAscii( "xlc" ) );
930 // disable reference checkbox for documents and sbls
931 if ( aExtension
!= aLibExtension
&& aExtension
!= aContExtension
)
932 pLibDlg
->EnableReference( FALSE
);
934 if ( pLibDlg
->Execute() )
936 ULONG nNewPos
= aLibBox
.GetEntryCount();
937 BOOL bRemove
= FALSE
;
938 BOOL bReplace
= pLibDlg
->IsReplace();
939 BOOL bReference
= pLibDlg
->IsReference();
940 for ( USHORT nLib
= 0; nLib
< pLibDlg
->GetLibBox().GetEntryCount(); nLib
++ )
942 if ( pLibDlg
->GetLibBox().IsChecked( nLib
) )
944 SvLBoxEntry
* pEntry
= pLibDlg
->GetLibBox().GetEntry( nLib
);
945 DBG_ASSERT( pEntry
, "Entry?!" );
946 String
aLibName( pLibDlg
->GetLibBox().GetEntryText( pEntry
, 0 ) );
947 ::rtl::OUString
aOULibName( aLibName
);
948 Reference
< script::XLibraryContainer2
> xModLibContainer( m_aCurDocument
.getLibraryContainer( E_SCRIPTS
), UNO_QUERY
);
949 Reference
< script::XLibraryContainer2
> xDlgLibContainer( m_aCurDocument
.getLibraryContainer( E_DIALOGS
), UNO_QUERY
);
951 // check, if the library is already existing
952 if ( ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) ) ||
953 ( xDlgLibContainer
.is() && xDlgLibContainer
->hasByName( aOULibName
) ) )
957 // check, if the library is the Standard library
958 if ( aLibName
.EqualsAscii( "Standard" ) )
960 ErrorBox( this, WB_OK
| WB_DEF_OK
, String( IDEResId( RID_STR_REPLACESTDLIB
) ) ).Execute();
964 // check, if the library is readonly and not a link
965 if ( ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) && xModLibContainer
->isLibraryReadOnly( aOULibName
) && !xModLibContainer
->isLibraryLink( aOULibName
) ) ||
966 ( xDlgLibContainer
.is() && xDlgLibContainer
->hasByName( aOULibName
) && xDlgLibContainer
->isLibraryReadOnly( aOULibName
) && !xDlgLibContainer
->isLibraryLink( aOULibName
) ) )
968 String
aErrStr( IDEResId( RID_STR_REPLACELIB
) );
969 aErrStr
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "XX" ) ), aLibName
);
971 aErrStr
+= String( IDEResId( RID_STR_LIBISREADONLY
) );
972 ErrorBox( this, WB_OK
| WB_DEF_OK
, aErrStr
).Execute();
976 // remove existing libraries
983 aErrStr
= String( IDEResId( RID_STR_REFNOTPOSSIBLE
) );
985 aErrStr
= String( IDEResId( RID_STR_IMPORTNOTPOSSIBLE
) );
986 aErrStr
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "XX" ) ), aLibName
);
988 aErrStr
+= String( IDEResId( RID_STR_SBXNAMEALLREADYUSED
) );
989 ErrorBox( this, WB_OK
| WB_DEF_OK
, aErrStr
).Execute();
994 // check, if the library is password protected
997 if ( xModLibContImport
.is() && xModLibContImport
->hasByName( aOULibName
) )
999 Reference
< script::XLibraryContainerPassword
> xPasswd( xModLibContImport
, UNO_QUERY
);
1000 if ( xPasswd
.is() && xPasswd
->isLibraryPasswordProtected( aOULibName
) && !xPasswd
->isLibraryPasswordVerified( aOULibName
) && !bReference
)
1002 bOK
= QueryPassword( xModLibContImp
, aLibName
, aPassword
, TRUE
, TRUE
);
1006 String
aErrStr( IDEResId( RID_STR_NOIMPORT
) );
1007 aErrStr
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "XX" ) ), aLibName
);
1008 ErrorBox( this, WB_OK
| WB_DEF_OK
, aErrStr
).Execute();
1014 // remove existing libraries
1017 // remove listbox entry
1018 SvLBoxEntry
* pEntry_
= aLibBox
.FindEntry( aLibName
);
1020 aLibBox
.SvTreeListBox::GetModel()->Remove( pEntry_
);
1022 // remove module library
1023 if ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) )
1024 xModLibContainer
->removeLibrary( aOULibName
);
1026 // remove dialog library
1027 if ( xDlgLibContainer
.is() && xDlgLibContainer
->hasByName( aOULibName
) )
1028 xDlgLibContainer
->removeLibrary( aOULibName
);
1031 // copy module library
1032 if ( xModLibContImport
.is() && xModLibContImport
->hasByName( aOULibName
) && xModLibContainer
.is() && !xModLibContainer
->hasByName( aOULibName
) )
1034 Reference
< container::XNameContainer
> xModLib
;
1038 INetURLObject
aModStorageURLObj( aModURLObj
);
1039 if ( aExtension
== aContExtension
)
1041 sal_Int32 nCount
= aModStorageURLObj
.getSegmentCount();
1042 aModStorageURLObj
.insertName( aLibName
, false, nCount
-1 );
1043 aModStorageURLObj
.setExtension( aLibExtension
);
1044 aModStorageURLObj
.setFinalSlash();
1046 ::rtl::OUString
aModStorageURL( aModStorageURLObj
.GetMainURL( INetURLObject::NO_DECODE
) );
1048 // create library link
1049 xModLib
= Reference
< container::XNameContainer
>( xModLibContainer
->createLibraryLink( aOULibName
, aModStorageURL
, TRUE
), UNO_QUERY
);
1054 xModLib
= xModLibContainer
->createLibrary( aOULibName
);
1057 // get import library
1058 Reference
< container::XNameContainer
> xModLibImport
;
1059 Any aElement
= xModLibContImport
->getByName( aOULibName
);
1060 aElement
>>= xModLibImport
;
1062 if ( xModLibImport
.is() )
1065 if ( !xModLibContImport
->isLibraryLoaded( aOULibName
) )
1066 xModLibContImport
->loadLibrary( aOULibName
);
1069 Sequence
< ::rtl::OUString
> aModNames
= xModLibImport
->getElementNames();
1070 sal_Int32 nModCount
= aModNames
.getLength();
1071 const ::rtl::OUString
* pModNames
= aModNames
.getConstArray();
1072 for ( sal_Int32 i
= 0 ; i
< nModCount
; i
++ )
1074 ::rtl::OUString
aOUModName( pModNames
[ i
] );
1075 Any aElement_
= xModLibImport
->getByName( aOUModName
);
1076 xModLib
->insertByName( aOUModName
, aElement_
);
1082 Reference
< script::XLibraryContainerPassword
> xPasswd( xModLibContainer
, UNO_QUERY
);
1087 ::rtl::OUString
aOUPassword( aPassword
);
1088 xPasswd
->changeLibraryPassword( aOULibName
, ::rtl::OUString(), aOUPassword
);
1100 // copy dialog library
1101 if ( xDlgLibContImport
.is() && xDlgLibContImport
->hasByName( aOULibName
) && xDlgLibContainer
.is() && !xDlgLibContainer
->hasByName( aOULibName
) )
1103 Reference
< container::XNameContainer
> xDlgLib
;
1107 INetURLObject
aDlgStorageURLObj( aDlgURLObj
);
1108 if ( aExtension
== aContExtension
)
1110 sal_Int32 nCount
= aDlgStorageURLObj
.getSegmentCount();
1111 aDlgStorageURLObj
.insertName( aLibName
, false, nCount
- 1 );
1112 aDlgStorageURLObj
.setExtension( aLibExtension
);
1113 aDlgStorageURLObj
.setFinalSlash();
1115 ::rtl::OUString
aDlgStorageURL( aDlgStorageURLObj
.GetMainURL( INetURLObject::NO_DECODE
) );
1117 // create library link
1118 xDlgLib
= Reference
< container::XNameContainer
>( xDlgLibContainer
->createLibraryLink( aOULibName
, aDlgStorageURL
, TRUE
), UNO_QUERY
);
1123 xDlgLib
= xDlgLibContainer
->createLibrary( aOULibName
);
1126 // get import library
1127 Reference
< container::XNameContainer
> xDlgLibImport
;
1128 Any aElement
= xDlgLibContImport
->getByName( aOULibName
);
1129 aElement
>>= xDlgLibImport
;
1131 if ( xDlgLibImport
.is() )
1134 if ( !xDlgLibContImport
->isLibraryLoaded( aOULibName
) )
1135 xDlgLibContImport
->loadLibrary( aOULibName
);
1138 Sequence
< ::rtl::OUString
> aDlgNames
= xDlgLibImport
->getElementNames();
1139 sal_Int32 nDlgCount
= aDlgNames
.getLength();
1140 const ::rtl::OUString
* pDlgNames
= aDlgNames
.getConstArray();
1141 for ( sal_Int32 i
= 0 ; i
< nDlgCount
; i
++ )
1143 ::rtl::OUString
aOUDlgName( pDlgNames
[ i
] );
1144 Any aElement_
= xDlgLibImport
->getByName( aOUDlgName
);
1145 xDlgLib
->insertByName( aOUDlgName
, aElement_
);
1152 // insert listbox entry
1153 ImpInsertLibEntry( aLibName
, aLibBox
.GetEntryCount() );
1158 SvLBoxEntry
* pFirstNew
= aLibBox
.GetEntry( nNewPos
);
1160 aLibBox
.SetCurEntry( pFirstNew
);
1165 BasicIDE::MarkDocumentModified( m_aCurDocument
);
1171 //----------------------------------------------------------------------------
1173 void LibPage::Export( void )
1175 SvLBoxEntry
* pCurEntry
= aLibBox
.GetCurEntry();
1176 String
aLibName( aLibBox
.GetEntryText( pCurEntry
, 0 ) );
1178 // Password verification
1179 ::rtl::OUString
aOULibName( aLibName
);
1180 Reference
< script::XLibraryContainer2
> xModLibContainer( m_aCurDocument
.getLibraryContainer( E_SCRIPTS
), UNO_QUERY
);
1182 if ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) && !xModLibContainer
->isLibraryLoaded( aOULibName
) )
1187 Reference
< script::XLibraryContainerPassword
> xPasswd( xModLibContainer
, UNO_QUERY
);
1188 if ( xPasswd
.is() && xPasswd
->isLibraryPasswordProtected( aOULibName
) && !xPasswd
->isLibraryPasswordVerified( aOULibName
) )
1191 Reference
< script::XLibraryContainer
> xModLibContainer1( xModLibContainer
, UNO_QUERY
);
1192 bOK
= QueryPassword( xModLibContainer1
, aLibName
, aPassword
);
1199 Window
* pWin
= static_cast<Window
*>( this );
1200 std::auto_ptr
< ExportDialog
> xNewDlg( new ExportDialog( pWin
) );
1202 if ( xNewDlg
->Execute() == RET_OK
)
1206 if( xNewDlg
->isExportAsPackage() )
1207 ExportAsPackage( aLibName
);
1209 ExportAsBasic( aLibName
);
1211 catch( util::VetoException
& ) // user cancled operation
1217 void LibPage::implExportLib( const String
& aLibName
, const String
& aTargetURL
,
1218 const Reference
< task::XInteractionHandler
>& Handler
)
1220 ::rtl::OUString
aOULibName( aLibName
);
1221 Reference
< script::XLibraryContainerExport
> xModLibContainerExport
1222 ( m_aCurDocument
.getLibraryContainer( E_SCRIPTS
), UNO_QUERY
);
1223 Reference
< script::XLibraryContainerExport
> xDlgLibContainerExport
1224 ( m_aCurDocument
.getLibraryContainer( E_DIALOGS
), UNO_QUERY
);
1225 if ( xModLibContainerExport
.is() )
1226 xModLibContainerExport
->exportLibrary( aOULibName
, aTargetURL
, Handler
);
1228 if ( xDlgLibContainerExport
.is() )
1229 xDlgLibContainerExport
->exportLibrary( aOULibName
, aTargetURL
, Handler
);
1233 //===========================================================================
1234 // Implementation XCommandEnvironment
1236 typedef cppu::WeakImplHelper1
< XCommandEnvironment
> LibCommandEnvironmentHelper
;
1238 class OLibCommandEnvironment
: public LibCommandEnvironmentHelper
1240 Reference
< task::XInteractionHandler
> mxInteraction
;
1243 OLibCommandEnvironment( Reference
< task::XInteractionHandler
> xInteraction
)
1244 : mxInteraction( xInteraction
)
1248 virtual Reference
< task::XInteractionHandler
> SAL_CALL
getInteractionHandler()
1249 throw(RuntimeException
);
1250 virtual Reference
< XProgressHandler
> SAL_CALL
getProgressHandler()
1251 throw(RuntimeException
);
1254 Reference
< task::XInteractionHandler
> OLibCommandEnvironment::getInteractionHandler()
1255 throw(RuntimeException
)
1257 return mxInteraction
;
1260 Reference
< XProgressHandler
> OLibCommandEnvironment::getProgressHandler()
1261 throw(RuntimeException
)
1263 Reference
< XProgressHandler
> xRet
;
1269 void LibPage::ExportAsPackage( const String
& aLibName
)
1272 Reference
< lang::XMultiServiceFactory
> xMSF( ::comphelper::getProcessServiceFactory() );
1273 Reference
< task::XInteractionHandler
> xHandler
;
1274 Reference
< XSimpleFileAccess
> xSFA
;
1275 Reference
< XFilePicker
> xFP
;
1278 xHandler
= Reference
< task::XInteractionHandler
>( xMSF
->createInstance
1279 ( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ), UNO_QUERY
);
1281 xSFA
= Reference
< XSimpleFileAccess
> ( xMSF
->createInstance(
1282 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" ) ) ), UNO_QUERY
);
1285 DBG_ERROR( "No simpleFileAccess" );
1289 Sequence
<Any
> aServiceType(1);
1290 aServiceType
[0] <<= TemplateDescription::FILESAVE_SIMPLE
;
1291 xFP
= Reference
< XFilePicker
>( xMSF
->createInstanceWithArguments(
1292 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType
), UNO_QUERY
);
1294 xFP
->setTitle( String( IDEResId( RID_STR_EXPORTPACKAGE
) ) );
1297 ::rtl::OUString aTitle
= String( IDEResId( RID_STR_PACKAGE_BUNDLE
) );
1298 ::rtl::OUString aFilter
;
1299 aFilter
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.oxt" ) ); // library files
1300 Reference
< XFilterManager
> xFltMgr(xFP
, UNO_QUERY
);
1301 xFltMgr
->appendFilter( aTitle
, aFilter
);
1303 // set display directory and filter
1304 String
aPath( IDE_DLL()->GetExtraData()->GetAddLibPath() );
1307 xFP
->setDisplayDirectory( aPath
);
1311 // macro path from configuration management
1312 xFP
->setDisplayDirectory( SvtPathOptions().GetWorkPath() );
1314 xFltMgr
->setCurrentFilter( aTitle
);
1316 if ( xFP
->execute() == RET_OK
)
1318 IDE_DLL()->GetExtraData()->SetAddLibPath( xFP
->getDisplayDirectory() );
1320 Sequence
< ::rtl::OUString
> aFiles
= xFP
->getFiles();
1321 INetURLObject
aURL( aFiles
[0] );
1322 if( !aURL
.getExtension().getLength() )
1323 aURL
.setExtension( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "oxt" ) ) );
1325 ::rtl::OUString
aPackageURL( aURL
.GetMainURL( INetURLObject::NO_DECODE
) );
1327 String aTmpPath
= SvtPathOptions().GetTempPath();
1328 INetURLObject
aInetObj( aTmpPath
);
1329 aInetObj
.insertName( aLibName
, sal_True
, INetURLObject::LAST_SEGMENT
, sal_True
, INetURLObject::ENCODE_ALL
);
1330 OUString aSourcePath
= aInetObj
.GetMainURL( INetURLObject::NO_DECODE
);
1331 if( xSFA
->exists( aSourcePath
) )
1332 xSFA
->kill( aSourcePath
);
1333 Reference
< task::XInteractionHandler
> xDummyHandler( new DummyInteractionHandler( xHandler
) );
1334 implExportLib( aLibName
, aTmpPath
, xDummyHandler
);
1336 Reference
< XCommandEnvironment
> xCmdEnv
=
1337 static_cast<XCommandEnvironment
*>( new OLibCommandEnvironment( xHandler
) );
1339 ::ucbhelper::Content
sourceContent( aSourcePath
, xCmdEnv
);
1341 ::rtl::OUStringBuffer buf
;
1342 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.zip://") );
1343 buf
.append( ::rtl::Uri::encode( aPackageURL
,
1344 rtl_UriCharClassRegName
,
1345 rtl_UriEncodeIgnoreEscapes
,
1346 RTL_TEXTENCODING_UTF8
) );
1347 buf
.append( static_cast<sal_Unicode
>('/') );
1348 OUString
destFolder( buf
.makeStringAndClear() );
1350 if( xSFA
->exists( aPackageURL
) )
1351 xSFA
->kill( aPackageURL
);
1353 ::ucbhelper::Content
destFolderContent( destFolder
, xCmdEnv
);
1354 destFolderContent
.transferContent(
1355 sourceContent
, ::ucbhelper::InsertOperation_COPY
,
1356 OUString(), NameClash::OVERWRITE
);
1358 INetURLObject
aMetaInfInetObj( aTmpPath
);
1359 aMetaInfInetObj
.insertName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) ),
1360 sal_True
, INetURLObject::LAST_SEGMENT
, sal_True
, INetURLObject::ENCODE_ALL
);
1361 OUString aMetaInfFolder
= aMetaInfInetObj
.GetMainURL( INetURLObject::NO_DECODE
);
1362 if( xSFA
->exists( aMetaInfFolder
) )
1363 xSFA
->kill( aMetaInfFolder
);
1364 xSFA
->createFolder( aMetaInfFolder
);
1366 ::std::vector
< Sequence
<beans::PropertyValue
> > manifest
;
1367 const OUString strMediaType
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) );
1368 const OUString strFullPath
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FullPath" ) );
1369 const OUString strBasicMediaType
= ::rtl::OUString
1370 ( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.star.basic-library" ) );
1372 Sequence
<beans::PropertyValue
> attribs( 2 );
1373 beans::PropertyValue
* pattribs
= attribs
.getArray();
1374 pattribs
[ 0 ].Name
= strFullPath
;
1375 OUString fullPath
= aLibName
;
1376 fullPath
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/") );
1377 pattribs
[ 0 ].Value
<<= fullPath
;
1378 pattribs
[ 1 ].Name
= strMediaType
;
1379 pattribs
[ 1 ].Value
<<= strBasicMediaType
;
1380 manifest
.push_back( attribs
);
1383 Reference
<packages::manifest::XManifestWriter
> xManifestWriter( xMSF
->createInstance
1384 ( DEFINE_CONST_UNICODE("com.sun.star.packages.manifest.ManifestWriter") ), UNO_QUERY
);
1385 Reference
<io::XOutputStream
> xPipe( xMSF
->createInstance
1386 ( DEFINE_CONST_UNICODE("com.sun.star.io.Pipe") ), UNO_QUERY
);
1387 xManifestWriter
->writeManifestSequence(
1388 xPipe
, Sequence
< Sequence
<beans::PropertyValue
> >(
1389 &manifest
[ 0 ], manifest
.size() ) );
1391 aMetaInfInetObj
.insertName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "manifest.xml" ) ),
1392 sal_True
, INetURLObject::LAST_SEGMENT
, sal_True
, INetURLObject::ENCODE_ALL
);
1394 // write buffered pipe data to content:
1395 ::ucbhelper::Content
manifestContent( aMetaInfInetObj
.GetMainURL( INetURLObject::NO_DECODE
), xCmdEnv
);
1396 manifestContent
.writeStream( Reference
<io::XInputStream
>( xPipe
, UNO_QUERY_THROW
), true );
1398 ::ucbhelper::Content
MetaInfContent( aMetaInfFolder
, xCmdEnv
);
1399 destFolderContent
.transferContent(
1400 MetaInfContent
, ::ucbhelper::InsertOperation_COPY
,
1401 OUString(), NameClash::OVERWRITE
);
1403 if( xSFA
->exists( aSourcePath
) )
1404 xSFA
->kill( aSourcePath
);
1405 if( xSFA
->exists( aMetaInfFolder
) )
1406 xSFA
->kill( aMetaInfFolder
);
1410 void LibPage::ExportAsBasic( const String
& aLibName
)
1413 Reference
< lang::XMultiServiceFactory
> xMSF( ::comphelper::getProcessServiceFactory() );
1414 Reference
< XFolderPicker
> xFolderPicker
;
1415 Reference
< task::XInteractionHandler
> xHandler
;
1418 xFolderPicker
= Reference
< XFolderPicker
>( xMSF
->createInstance(
1419 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FolderPicker" ) ) ), UNO_QUERY
);
1421 xHandler
= Reference
< task::XInteractionHandler
>( xMSF
->createInstance
1422 ( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ), UNO_QUERY
);
1425 if( xFolderPicker
.is() )
1427 xFolderPicker
->setTitle( String( IDEResId( RID_STR_EXPORTBASIC
) ) );
1429 // set display directory and filter
1430 String
aPath( IDE_DLL()->GetExtraData()->GetAddLibPath() );
1432 aPath
= SvtPathOptions().GetWorkPath();
1434 // INetURLObject aURL(m_sSavePath, INET_PROT_FILE);
1435 xFolderPicker
->setDisplayDirectory( aPath
);
1436 short nRet
= xFolderPicker
->execute();
1437 if( nRet
== RET_OK
)
1439 String aTargetURL
= xFolderPicker
->getDirectory();
1440 IDE_DLL()->GetExtraData()->SetAddLibPath( aTargetURL
);
1442 Reference
< task::XInteractionHandler
> xDummyHandler( new DummyInteractionHandler( xHandler
) );
1443 implExportLib( aLibName
, aTargetURL
, xDummyHandler
);
1448 //----------------------------------------------------------------------------
1450 void LibPage::DeleteCurrent()
1452 SvLBoxEntry
* pCurEntry
= aLibBox
.GetCurEntry();
1453 String
aLibName( aLibBox
.GetEntryText( pCurEntry
, 0 ) );
1455 // check, if library is link
1456 BOOL bIsLibraryLink
= FALSE
;
1457 ::rtl::OUString
aOULibName( aLibName
);
1458 Reference
< script::XLibraryContainer2
> xModLibContainer( m_aCurDocument
.getLibraryContainer( E_SCRIPTS
), UNO_QUERY
);
1459 Reference
< script::XLibraryContainer2
> xDlgLibContainer( m_aCurDocument
.getLibraryContainer( E_DIALOGS
), UNO_QUERY
);
1460 if ( ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) && xModLibContainer
->isLibraryLink( aOULibName
) ) ||
1461 ( xDlgLibContainer
.is() && xDlgLibContainer
->hasByName( aOULibName
) && xDlgLibContainer
->isLibraryLink( aOULibName
) ) )
1463 bIsLibraryLink
= TRUE
;
1466 if ( QueryDelLib( aLibName
, bIsLibraryLink
, this ) )
1469 SfxUsrAnyItem
aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL
, makeAny( m_aCurDocument
.getDocumentOrNull() ) );
1470 SfxStringItem
aLibNameItem( SID_BASICIDE_ARG_LIBNAME
, aLibName
);
1471 BasicIDEShell
* pIDEShell
= IDE_DLL()->GetShell();
1472 SfxViewFrame
* pViewFrame
= pIDEShell
? pIDEShell
->GetViewFrame() : NULL
;
1473 SfxDispatcher
* pDispatcher
= pViewFrame
? pViewFrame
->GetDispatcher() : NULL
;
1476 pDispatcher
->Execute( SID_BASICIDE_LIBREMOVED
,
1477 SFX_CALLMODE_SYNCHRON
, &aDocItem
, &aLibNameItem
, 0L );
1480 // remove library from module and dialog library containers
1481 if ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) )
1482 xModLibContainer
->removeLibrary( aOULibName
);
1483 if ( xDlgLibContainer
.is() && xDlgLibContainer
->hasByName( aOULibName
) )
1484 xDlgLibContainer
->removeLibrary( aOULibName
);
1486 ((SvLBox
&)aLibBox
).GetModel()->Remove( pCurEntry
);
1487 BasicIDE::MarkDocumentModified( m_aCurDocument
);
1491 //----------------------------------------------------------------------------
1493 void LibPage::EndTabDialog( USHORT nRet
)
1495 DBG_ASSERT( pTabDlg
, "TabDlg nicht gesetzt!" );
1497 pTabDlg
->EndDialog( nRet
);
1500 //----------------------------------------------------------------------------
1502 void LibPage::FillListBox()
1504 InsertListBoxEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER
);
1505 InsertListBoxEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_SHARE
);
1507 ScriptDocuments
aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::DocumentsSorted
) );
1508 for ( ScriptDocuments::const_iterator doc
= aDocuments
.begin();
1509 doc
!= aDocuments
.end();
1513 InsertListBoxEntry( *doc
, LIBRARY_LOCATION_DOCUMENT
);
1517 //----------------------------------------------------------------------------
1519 void LibPage::InsertListBoxEntry( const ScriptDocument
& rDocument
, LibraryLocation eLocation
)
1521 String
aEntryText( rDocument
.getTitle( eLocation
) );
1522 USHORT nPos
= aBasicsBox
.InsertEntry( aEntryText
, LISTBOX_APPEND
);
1523 aBasicsBox
.SetEntryData( nPos
, new BasicDocumentEntry( rDocument
, eLocation
) );
1526 //----------------------------------------------------------------------------
1528 void LibPage::SetCurLib()
1530 USHORT nSelPos
= aBasicsBox
.GetSelectEntryPos();
1531 BasicDocumentEntry
* pEntry
= (BasicDocumentEntry
*)aBasicsBox
.GetEntryData( nSelPos
);
1534 ScriptDocument
aDocument( pEntry
->GetDocument() );
1535 DBG_ASSERT( aDocument
.isAlive(), "LibPage::SetCurLib: no document, or document is dead!" );
1536 if ( !aDocument
.isAlive() )
1538 LibraryLocation eLocation
= pEntry
->GetLocation();
1539 if ( aDocument
!= m_aCurDocument
|| eLocation
!= m_eCurLocation
)
1541 m_aCurDocument
= aDocument
;
1542 m_eCurLocation
= eLocation
;
1543 aLibBox
.SetDocument( aDocument
);
1546 // get a sorted list of library names
1547 Sequence
< ::rtl::OUString
> aLibNames
= aDocument
.getLibraryNames();
1548 sal_Int32 nLibCount
= aLibNames
.getLength();
1549 const ::rtl::OUString
* pLibNames
= aLibNames
.getConstArray();
1551 for ( sal_Int32 i
= 0 ; i
< nLibCount
; i
++ )
1553 String
aLibName( pLibNames
[ i
] );
1554 if ( eLocation
== aDocument
.getLibraryLocation( aLibName
) )
1555 ImpInsertLibEntry( aLibName
, i
);
1558 SvLBoxEntry
* pEntry_
= aLibBox
.FindEntry( String::CreateFromAscii( "Standard" ) );
1560 pEntry_
= aLibBox
.GetEntry( 0 );
1561 aLibBox
.SetCurEntry( pEntry_
);
1566 //----------------------------------------------------------------------------
1568 SvLBoxEntry
* LibPage::ImpInsertLibEntry( const String
& rLibName
, ULONG nPos
)
1570 // check, if library is password protected
1571 BOOL bProtected
= FALSE
;
1572 ::rtl::OUString
aOULibName( rLibName
);
1573 Reference
< script::XLibraryContainer2
> xModLibContainer( m_aCurDocument
.getLibraryContainer( E_SCRIPTS
), UNO_QUERY
);
1574 if ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) )
1576 Reference
< script::XLibraryContainerPassword
> xPasswd( xModLibContainer
, UNO_QUERY
);
1579 bProtected
= xPasswd
->isLibraryPasswordProtected( aOULibName
);
1583 SvLBoxEntry
* pNewEntry
= aLibBox
.DoInsertEntry( rLibName
, nPos
);
1584 pNewEntry
->SetUserData( new BasicLibUserData( m_aCurDocument
) );
1588 Image
aImage(IDEResId(RID_IMG_LOCKED
));
1589 aLibBox
.SetExpandedEntryBmp(pNewEntry
, aImage
, BMP_COLOR_NORMAL
);
1590 aLibBox
.SetCollapsedEntryBmp(pNewEntry
, aImage
, BMP_COLOR_NORMAL
);
1591 aImage
= Image(IDEResId(RID_IMG_LOCKED_HC
));
1592 aLibBox
.SetExpandedEntryBmp(pNewEntry
, aImage
,
1593 BMP_COLOR_HIGHCONTRAST
);
1594 aLibBox
.SetCollapsedEntryBmp(pNewEntry
, aImage
,
1595 BMP_COLOR_HIGHCONTRAST
);
1598 // check, if library is link
1599 if ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) && xModLibContainer
->isLibraryLink( aOULibName
) )
1601 String aLinkURL
= xModLibContainer
->getLibraryLinkURL( aOULibName
);
1602 aLibBox
.SetEntryText( aLinkURL
, pNewEntry
, 1 );
1608 //----------------------------------------------------------------------------
1611 void createLibImpl( Window
* pWin
, const ScriptDocument
& rDocument
,
1612 BasicCheckBox
* pLibBox
, BasicTreeListBox
* pBasicBox
)
1614 OSL_ENSURE( rDocument
.isAlive(), "createLibImpl: invalid document!" );
1615 if ( !rDocument
.isAlive() )
1618 // create library name
1620 String
aLibStdName( String( RTL_CONSTASCII_USTRINGPARAM( "Library" ) ) );
1621 //String aLibStdName( IDEResId( RID_STR_STDLIBNAME ) );
1622 BOOL bValid
= FALSE
;
1626 aLibName
= aLibStdName
;
1627 aLibName
+= String::CreateFromInt32( i
);
1628 if ( !rDocument
.hasLibrary( E_SCRIPTS
, aLibName
) && !rDocument
.hasLibrary( E_DIALOGS
, aLibName
) )
1633 std::auto_ptr
< NewObjectDialog
> xNewDlg( new NewObjectDialog( pWin
, NEWOBJECTMODE_LIB
) );
1634 xNewDlg
->SetObjectName( aLibName
);
1636 if ( xNewDlg
->Execute() )
1638 if ( xNewDlg
->GetObjectName().Len() )
1639 aLibName
= xNewDlg
->GetObjectName();
1641 if ( aLibName
.Len() > 30 )
1643 ErrorBox( pWin
, WB_OK
| WB_DEF_OK
, String( IDEResId( RID_STR_LIBNAMETOLONG
) ) ).Execute();
1645 else if ( !BasicIDE::IsValidSbxName( aLibName
) )
1647 ErrorBox( pWin
, WB_OK
| WB_DEF_OK
,
1648 String( IDEResId( RID_STR_BADSBXNAME
) ) ).Execute();
1650 else if ( rDocument
.hasLibrary( E_SCRIPTS
, aLibName
) || rDocument
.hasLibrary( E_DIALOGS
, aLibName
) )
1652 ErrorBox( pWin
, WB_OK
| WB_DEF_OK
,
1653 String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2
) ) ).Execute();
1659 // create module and dialog library
1660 Reference
< container::XNameContainer
> xModLib( rDocument
.getOrCreateLibrary( E_SCRIPTS
, aLibName
) );
1661 Reference
< container::XNameContainer
> xDlgLib( rDocument
.getOrCreateLibrary( E_DIALOGS
, aLibName
) );
1665 SvLBoxEntry
* pEntry
= pLibBox
->DoInsertEntry( aLibName
);
1666 pEntry
->SetUserData( new BasicLibUserData( rDocument
) );
1667 pLibBox
->SetCurEntry( pEntry
);
1671 String aModName
= rDocument
.createObjectName( E_SCRIPTS
, aLibName
);
1672 ::rtl::OUString sModuleCode
;
1673 if ( !rDocument
.createModule( aLibName
, aModName
, TRUE
, sModuleCode
) )
1676 SbxItem
aSbxItem( SID_BASICIDE_ARG_SBX
, rDocument
, aLibName
, aModName
, BASICIDE_TYPE_MODULE
);
1677 BasicIDEShell
* pIDEShell
= IDE_DLL()->GetShell();
1678 SfxViewFrame
* pViewFrame
= pIDEShell
? pIDEShell
->GetViewFrame() : NULL
;
1679 SfxDispatcher
* pDispatcher
= pViewFrame
? pViewFrame
->GetDispatcher() : NULL
;
1682 pDispatcher
->Execute( SID_BASICIDE_SBXINSERTED
,
1683 SFX_CALLMODE_SYNCHRON
, &aSbxItem
, 0L );
1688 SvLBoxEntry
* pEntry
= pBasicBox
->GetCurEntry();
1689 SvLBoxEntry
* pRootEntry
= NULL
;
1692 pRootEntry
= pEntry
;
1693 pEntry
= pBasicBox
->GetParent( pEntry
);
1696 USHORT nMode
= pBasicBox
->GetMode();
1697 bool bDlgMode
= ( nMode
& BROWSEMODE_DIALOGS
) && !( nMode
& BROWSEMODE_MODULES
);
1698 USHORT nId
= bDlgMode
? RID_IMG_DLGLIB
: RID_IMG_MODLIB
;
1699 USHORT nIdHC
= bDlgMode
? RID_IMG_DLGLIB_HC
: RID_IMG_MODLIB_HC
;
1700 SvLBoxEntry
* pNewLibEntry
= pBasicBox
->AddEntry(
1702 Image( IDEResId( nId
) ),
1703 Image( IDEResId( nIdHC
) ),
1705 std::auto_ptr
< BasicEntry
>( new BasicEntry( OBJ_TYPE_LIBRARY
) ) );
1706 DBG_ASSERT( pNewLibEntry
, "InsertEntry fehlgeschlagen!" );
1710 SvLBoxEntry
* pEntry_
= pBasicBox
->AddEntry(
1712 Image( IDEResId( RID_IMG_MODULE
) ),
1713 Image( IDEResId( RID_IMG_MODULE_HC
) ),
1714 pNewLibEntry
, false,
1715 std::auto_ptr
< BasicEntry
>( new BasicEntry( OBJ_TYPE_MODULE
) ) );
1716 DBG_ASSERT( pEntry_
, "InsertEntry fehlgeschlagen!" );
1717 pBasicBox
->SetCurEntry( pEntry_
);
1718 pBasicBox
->Select( pBasicBox
->GetCurEntry() ); // OV-Bug?!
1722 catch ( uno::Exception
& )
1724 DBG_UNHANDLED_EXCEPTION();
1730 //----------------------------------------------------------------------------