2000-09-29 05:02:42 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-07 14:07:25 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-29 05:02:42 -05:00
|
|
|
*
|
2005-09-07 14:07:25 -05:00
|
|
|
* $RCSfile: moduldlg.cxx,v $
|
2000-09-29 05:02:42 -05:00
|
|
|
*
|
2005-09-07 14:07:25 -05:00
|
|
|
* $Revision: 1.28 $
|
2000-09-29 05:02:42 -05:00
|
|
|
*
|
2005-09-07 14:07:25 -05:00
|
|
|
* last change: $Author: rt $ $Date: 2005-09-07 20:07:25 $
|
2000-09-29 05:02:42 -05:00
|
|
|
*
|
2005-09-07 14:07:25 -05:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-09-29 05:02:42 -05:00
|
|
|
*
|
|
|
|
*
|
2005-09-07 14:07:25 -05:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-09-29 05:02:42 -05:00
|
|
|
*
|
2005-09-07 14:07:25 -05:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2000-09-29 05:02:42 -05:00
|
|
|
*
|
2005-09-07 14:07:25 -05:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2000-09-29 05:02:42 -05:00
|
|
|
*
|
2005-09-07 14:07:25 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2000-09-29 05:02:42 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2002-07-09 02:12:31 -05:00
|
|
|
#include <memory>
|
2000-09-29 05:02:42 -05:00
|
|
|
|
|
|
|
#include <ide_pch.hxx>
|
|
|
|
|
|
|
|
#pragma hdrstop
|
|
|
|
|
|
|
|
#include <moduldlg.hrc>
|
|
|
|
#include <moduldlg.hxx>
|
|
|
|
#include <basidesh.hrc>
|
2001-09-06 03:21:02 -05:00
|
|
|
#include <basidesh.hxx>
|
2000-09-29 05:02:42 -05:00
|
|
|
#include <bastypes.hxx>
|
|
|
|
#include <basobj.hxx>
|
|
|
|
#include <baside2.hrc>
|
|
|
|
#include <sbxitem.hxx>
|
2001-09-06 03:21:02 -05:00
|
|
|
#include <iderdll.hxx>
|
2000-09-29 05:02:42 -05:00
|
|
|
|
2001-06-15 02:45:19 -05:00
|
|
|
#ifndef _COM_SUN_STAR_IO_XINPUTSTREAMPROVIDER_HXX_
|
|
|
|
#include <com/sun/star/io/XInputStreamProvider.hpp>
|
|
|
|
#endif
|
2001-11-12 15:39:49 -06:00
|
|
|
#ifndef _COM_SUN_STAR_SCRIPT_XLIBRYARYCONTAINER2_HPP_
|
|
|
|
#include <com/sun/star/script/XLibraryContainer2.hpp>
|
|
|
|
#endif
|
2001-11-02 06:45:10 -06:00
|
|
|
#ifndef _COM_SUN_STAR_SCRIPT_XLIBRARYCONTAINERPASSWORD_HPP_
|
|
|
|
#include <com/sun/star/script/XLibraryContainerPassword.hpp>
|
|
|
|
#endif
|
2001-06-15 02:45:19 -05:00
|
|
|
|
2000-09-29 05:02:42 -05:00
|
|
|
#ifndef _SBXCLASS_HXX //autogen
|
2005-04-13 03:52:06 -05:00
|
|
|
#include <basic/sbx.hxx>
|
2000-09-29 05:02:42 -05:00
|
|
|
#endif
|
|
|
|
|
2001-06-15 02:45:19 -05:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
|
|
|
|
|
2000-09-29 05:02:42 -05:00
|
|
|
ExtBasicTreeListBox::ExtBasicTreeListBox( Window* pParent, const ResId& rRes )
|
|
|
|
: BasicTreeListBox( pParent, rRes )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ExtBasicTreeListBox::~ExtBasicTreeListBox()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL __EXPORT ExtBasicTreeListBox::EditingEntry( SvLBoxEntry* pEntry, Selection& )
|
|
|
|
{
|
2001-11-12 15:39:49 -06:00
|
|
|
BOOL bRet = FALSE;
|
|
|
|
|
|
|
|
if ( pEntry )
|
|
|
|
{
|
|
|
|
USHORT nDepth = GetModel()->GetDepth( pEntry );
|
|
|
|
if ( nDepth == 2 )
|
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
|
|
|
|
SfxObjectShell* pShell( aDesc.GetShell() );
|
|
|
|
::rtl::OUString aOULibName( aDesc.GetLibName() );
|
|
|
|
Reference< script::XLibraryContainer2 > xModLibContainer( BasicIDE::GetModuleLibraryContainer( pShell ), UNO_QUERY );
|
|
|
|
Reference< script::XLibraryContainer2 > xDlgLibContainer( BasicIDE::GetDialogLibraryContainer( pShell ), UNO_QUERY );
|
|
|
|
if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) ||
|
|
|
|
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) ) ) )
|
2001-11-12 15:39:49 -06:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
// allow editing only for libraries, which are not readonly
|
|
|
|
bRet = TRUE;
|
2001-11-12 15:39:49 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL __EXPORT ExtBasicTreeListBox::EditedEntry( SvLBoxEntry* pEntry, const String& rNewText )
|
|
|
|
{
|
|
|
|
BOOL bValid = BasicIDE::IsValidSbxName( rNewText );
|
|
|
|
String aCurText( GetEntryText( pEntry ) );
|
|
|
|
if ( bValid && ( aCurText != rNewText ) )
|
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
|
|
|
|
SfxObjectShell* pShell( aDesc.GetShell() );
|
|
|
|
String aLibName( aDesc.GetLibName() );
|
|
|
|
BasicEntryType eType( aDesc.GetType() );
|
2001-06-28 09:26:41 -05:00
|
|
|
try
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
if ( eType == OBJ_TYPE_MODULE )
|
2001-06-28 09:26:41 -05:00
|
|
|
BasicIDE::RenameModule( pShell, aLibName, aCurText, rNewText );
|
2004-07-23 06:06:12 -05:00
|
|
|
else if ( eType == OBJ_TYPE_DIALOG )
|
2001-06-15 02:45:19 -05:00
|
|
|
BasicIDE::RenameDialog( pShell, aLibName, aCurText, rNewText );
|
2001-06-28 09:26:41 -05:00
|
|
|
|
|
|
|
BasicIDE::MarkDocShellModified( pShell );
|
|
|
|
}
|
|
|
|
catch ( container::ElementExistException& )
|
|
|
|
{
|
|
|
|
ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
catch ( container::NoSuchElementException& e )
|
|
|
|
{
|
|
|
|
ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
|
|
|
|
DBG_ERROR( aBStr.GetBuffer() );
|
2001-06-15 02:45:19 -05:00
|
|
|
}
|
2000-09-29 05:02:42 -05:00
|
|
|
|
2001-09-06 03:21:02 -05:00
|
|
|
BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
|
|
|
|
SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
|
|
|
|
SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
|
2000-09-29 05:02:42 -05:00
|
|
|
if( pDispatcher )
|
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, pShell, aLibName, rNewText, ConvertType( eType ) );
|
2000-09-29 05:02:42 -05:00
|
|
|
pDispatcher->Execute( SID_BASICIDE_SBXRENAMED,
|
|
|
|
SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
|
|
|
|
}
|
|
|
|
|
|
|
|
// OV-Bug?!
|
|
|
|
SetEntryText( pEntry, rNewText );
|
|
|
|
SetCurEntry( pEntry );
|
|
|
|
SetCurEntry( pEntry );
|
|
|
|
Select( pEntry, FALSE );
|
|
|
|
Select( pEntry ); // damit Handler gerufen wird => Edit updaten
|
|
|
|
}
|
|
|
|
if ( !bValid )
|
|
|
|
ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_BADSBXNAME ) ) ).Execute();
|
|
|
|
return bValid;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-26 03:00:01 -05:00
|
|
|
DragDropMode __EXPORT ExtBasicTreeListBox::NotifyStartDrag( TransferDataContainer& rData, SvLBoxEntry* pEntry )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2001-11-12 15:39:49 -06:00
|
|
|
DragDropMode nMode = SV_DRAGDROP_NONE;
|
|
|
|
|
|
|
|
if ( pEntry )
|
|
|
|
{
|
|
|
|
USHORT nDepth = GetModel()->GetDepth( pEntry );
|
|
|
|
if ( nDepth == 2 )
|
|
|
|
{
|
|
|
|
nMode = SV_DRAGDROP_CTRL_COPY;
|
2004-07-23 06:06:12 -05:00
|
|
|
BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
|
|
|
|
SfxObjectShell* pShell( aDesc.GetShell() );
|
|
|
|
::rtl::OUString aOULibName( aDesc.GetLibName() );
|
|
|
|
Reference< script::XLibraryContainer2 > xModLibContainer( BasicIDE::GetModuleLibraryContainer( pShell ), UNO_QUERY );
|
|
|
|
Reference< script::XLibraryContainer2 > xDlgLibContainer( BasicIDE::GetDialogLibraryContainer( pShell ), UNO_QUERY );
|
|
|
|
if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) ||
|
|
|
|
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) ) ) )
|
2001-11-12 15:39:49 -06:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
// allow MOVE mode only for libraries, which are not readonly
|
|
|
|
nMode |= SV_DRAGDROP_CTRL_MOVE;
|
2001-11-12 15:39:49 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nMode;
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-26 03:00:01 -05:00
|
|
|
BOOL __EXPORT ExtBasicTreeListBox::NotifyAcceptDrop( SvLBoxEntry* pEntry )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2001-06-26 03:00:01 -05:00
|
|
|
// don't drop on a BasicManager (nDepth == 0)
|
2000-09-29 05:02:42 -05:00
|
|
|
USHORT nDepth = pEntry ? GetModel()->GetDepth( pEntry ) : 0;
|
2001-06-26 03:00:01 -05:00
|
|
|
BOOL bValid = nDepth ? TRUE : FALSE;
|
|
|
|
|
|
|
|
// don't drop in the same library
|
2000-09-29 05:02:42 -05:00
|
|
|
SvLBoxEntry* pSelected = FirstSelected();
|
|
|
|
if ( ( nDepth == 1 ) && ( pEntry == GetParent( pSelected ) ) )
|
|
|
|
bValid = FALSE;
|
|
|
|
else if ( ( nDepth == 2 ) && ( GetParent( pEntry ) == GetParent( pSelected ) ) )
|
|
|
|
bValid = FALSE;
|
|
|
|
|
2001-11-12 15:39:49 -06:00
|
|
|
// don't drop on a library, which is not loaded, readonly or password protected
|
2004-07-23 06:06:12 -05:00
|
|
|
// or which already has a module/dialog with this name
|
|
|
|
if ( bValid && ( nDepth == 1 || nDepth == 2 ) )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
// get source module/dialog name
|
|
|
|
BasicEntryDescriptor aSourceDesc( GetEntryDescriptor( pSelected ) );
|
|
|
|
String aSourceName( aSourceDesc.GetName() );
|
|
|
|
BasicEntryType eSourceType( aSourceDesc.GetType() );
|
2001-11-02 06:45:10 -06:00
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
// get target shell and target library name
|
|
|
|
BasicEntryDescriptor aDestDesc( GetEntryDescriptor( pEntry ) );
|
|
|
|
SfxObjectShell* pDestShell( aDestDesc.GetShell() );
|
|
|
|
String aDestLibName( aDestDesc.GetLibName() );
|
|
|
|
::rtl::OUString aOUDestLibName( aDestLibName );
|
2001-11-12 15:39:49 -06:00
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
// check if module library is not loaded, readonly or password protected
|
|
|
|
Reference< script::XLibraryContainer2 > xModLibContainer( BasicIDE::GetModuleLibraryContainer( pDestShell ), UNO_QUERY );
|
|
|
|
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOUDestLibName ) )
|
|
|
|
{
|
|
|
|
if ( !xModLibContainer->isLibraryLoaded( aOUDestLibName ) )
|
|
|
|
bValid = FALSE;
|
2001-09-03 05:56:10 -05:00
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
if ( xModLibContainer->isLibraryReadOnly( aOUDestLibName ) )
|
|
|
|
bValid = FALSE;
|
2001-11-12 15:39:49 -06:00
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
|
|
|
|
if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOUDestLibName ) && !xPasswd->isLibraryPasswordVerified( aOUDestLibName ) )
|
|
|
|
bValid = FALSE;
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
2001-06-26 03:00:01 -05:00
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
// check if dialog library is not loaded or readonly
|
|
|
|
Reference< script::XLibraryContainer2 > xDlgLibContainer( BasicIDE::GetDialogLibraryContainer( pDestShell ), UNO_QUERY );
|
|
|
|
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOUDestLibName ) )
|
2001-06-26 03:00:01 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
if ( !xDlgLibContainer->isLibraryLoaded( aOUDestLibName ) )
|
|
|
|
bValid = FALSE;
|
2001-06-26 03:00:01 -05:00
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
if ( xDlgLibContainer->isLibraryReadOnly( aOUDestLibName ) )
|
|
|
|
bValid = FALSE;
|
|
|
|
}
|
2001-06-26 03:00:01 -05:00
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
// check, if module/dialog with this name is already existing in target library
|
|
|
|
if ( ( eSourceType == OBJ_TYPE_MODULE && BasicIDE::HasModule( pDestShell, aDestLibName, aSourceName ) ) ||
|
|
|
|
( eSourceType == OBJ_TYPE_DIALOG && BasicIDE::HasDialog( pDestShell, aDestLibName, aSourceName ) ) )
|
2001-06-26 03:00:01 -05:00
|
|
|
{
|
|
|
|
bValid = FALSE;
|
|
|
|
}
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
2001-06-26 03:00:01 -05:00
|
|
|
|
2000-09-29 05:02:42 -05:00
|
|
|
return bValid;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL __EXPORT ExtBasicTreeListBox::NotifyMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
|
|
|
|
SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos )
|
|
|
|
{
|
|
|
|
return NotifyCopyingMoving( pTarget, pEntry,
|
|
|
|
rpNewParent, rNewChildPos, TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL __EXPORT ExtBasicTreeListBox::NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
|
|
|
|
SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos )
|
|
|
|
{
|
|
|
|
// return FALSE; // Wie kopiere ich ein SBX ?!
|
|
|
|
return NotifyCopyingMoving( pTarget, pEntry,
|
|
|
|
rpNewParent, rNewChildPos, FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL __EXPORT ExtBasicTreeListBox::NotifyCopyingMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
|
|
|
|
SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos, BOOL bMove )
|
|
|
|
{
|
|
|
|
DBG_ASSERT( pEntry, "Kein Eintrag?" ); // Hier ASS ok, sollte nicht mit
|
|
|
|
DBG_ASSERT( pTarget, "Kein Ziel?" ); // NULL (ganz vorne) erreicht werden
|
|
|
|
USHORT nDepth = GetModel()->GetDepth( pTarget );
|
|
|
|
DBG_ASSERT( nDepth, "Tiefe?" );
|
|
|
|
if ( nDepth == 1 )
|
|
|
|
{
|
|
|
|
// Target = Basic => Modul/Dialog unter das Basic haengen...
|
|
|
|
rpNewParent = pTarget;
|
|
|
|
rNewChildPos = 0;
|
|
|
|
}
|
|
|
|
else if ( nDepth == 2 )
|
|
|
|
{
|
|
|
|
// Target = Modul/Dialog => Modul/Dialog unter das uebergeordnete Basic haengen...
|
|
|
|
rpNewParent = GetParent( pTarget );
|
|
|
|
rNewChildPos = GetModel()->GetRelPos( pTarget ) + 1;
|
|
|
|
}
|
|
|
|
|
2001-06-15 02:45:19 -05:00
|
|
|
USHORT nDestPos = (USHORT)rNewChildPos; // evtl. anpassen...
|
2000-09-29 05:02:42 -05:00
|
|
|
|
2001-06-15 02:45:19 -05:00
|
|
|
// get target shell and target library name
|
2004-07-23 06:06:12 -05:00
|
|
|
BasicEntryDescriptor aDestDesc( GetEntryDescriptor( rpNewParent ) );
|
|
|
|
SfxObjectShell* pDestShell( aDestDesc.GetShell() );
|
|
|
|
String aDestLibName( aDestDesc.GetLibName() );
|
2000-09-29 05:02:42 -05:00
|
|
|
|
2001-06-15 02:45:19 -05:00
|
|
|
// get source shell, library name and module/dialog name
|
2004-07-23 06:06:12 -05:00
|
|
|
BasicEntryDescriptor aSourceDesc( GetEntryDescriptor( FirstSelected() ) );
|
|
|
|
SfxObjectShell* pSourceShell( aSourceDesc.GetShell() );
|
|
|
|
String aSourceLibName( aSourceDesc.GetLibName() );
|
|
|
|
String aSourceName( aSourceDesc.GetName() );
|
|
|
|
BasicEntryType eType( aSourceDesc.GetType() );
|
2001-06-15 02:45:19 -05:00
|
|
|
|
|
|
|
// get dispatcher
|
2001-09-06 03:21:02 -05:00
|
|
|
BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
|
|
|
|
SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
|
|
|
|
SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
|
2001-06-15 02:45:19 -05:00
|
|
|
|
2001-06-28 09:26:41 -05:00
|
|
|
if ( bMove ) // move
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2001-06-28 09:26:41 -05:00
|
|
|
// remove source module/dialog window
|
2004-07-23 06:06:12 -05:00
|
|
|
if ( pSourceShell != pDestShell || aSourceLibName != aDestLibName )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2001-06-28 09:26:41 -05:00
|
|
|
if( pDispatcher )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, pSourceShell, aSourceLibName, aSourceName, ConvertType( eType ) );
|
2001-06-28 09:26:41 -05:00
|
|
|
pDispatcher->Execute( SID_BASICIDE_SBXDELETED,
|
|
|
|
SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
2001-06-15 02:45:19 -05:00
|
|
|
}
|
2001-06-28 09:26:41 -05:00
|
|
|
|
|
|
|
try
|
2001-06-15 02:45:19 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
if ( eType == OBJ_TYPE_MODULE ) // module
|
2001-06-15 02:45:19 -05:00
|
|
|
{
|
2001-06-28 09:26:41 -05:00
|
|
|
// get module
|
|
|
|
::rtl::OUString aModule = BasicIDE::GetModule( pSourceShell, aSourceLibName, aSourceName );
|
|
|
|
|
|
|
|
// remove module from source library
|
|
|
|
BasicIDE::RemoveModule( pSourceShell, aSourceLibName, aSourceName );
|
|
|
|
BasicIDE::MarkDocShellModified( pSourceShell );
|
2001-06-15 02:45:19 -05:00
|
|
|
|
2001-06-28 09:26:41 -05:00
|
|
|
// insert module into target library
|
|
|
|
BasicIDE::InsertModule( pDestShell, aDestLibName, aSourceName, aModule );
|
|
|
|
BasicIDE::MarkDocShellModified( pDestShell );
|
|
|
|
}
|
2004-07-23 06:06:12 -05:00
|
|
|
else if ( eType == OBJ_TYPE_DIALOG ) // dialog
|
2001-06-15 02:45:19 -05:00
|
|
|
{
|
2001-06-22 08:45:11 -05:00
|
|
|
// get dialog
|
|
|
|
Reference< io::XInputStreamProvider > xISP( BasicIDE::GetDialog( pSourceShell, aSourceLibName, aSourceName ) );
|
|
|
|
|
|
|
|
if ( xISP.is() )
|
2001-06-15 02:45:19 -05:00
|
|
|
{
|
|
|
|
// remove dialog from source library
|
|
|
|
BasicIDE::RemoveDialog( pSourceShell, aSourceLibName, aSourceName );
|
|
|
|
BasicIDE::MarkDocShellModified( pSourceShell );
|
|
|
|
|
|
|
|
// insert dialog into target library
|
|
|
|
BasicIDE::InsertDialog( pDestShell, aDestLibName, aSourceName, xISP );
|
|
|
|
BasicIDE::MarkDocShellModified( pDestShell );
|
|
|
|
}
|
2001-06-22 08:45:11 -05:00
|
|
|
}
|
2001-06-15 02:45:19 -05:00
|
|
|
}
|
2001-06-28 09:26:41 -05:00
|
|
|
catch ( container::ElementExistException& e )
|
2001-06-15 02:45:19 -05:00
|
|
|
{
|
2001-06-28 09:26:41 -05:00
|
|
|
ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
|
|
|
|
DBG_ERROR( aBStr.GetBuffer() );
|
|
|
|
}
|
|
|
|
catch ( container::NoSuchElementException& e )
|
|
|
|
{
|
|
|
|
ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
|
|
|
|
DBG_ERROR( aBStr.GetBuffer() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // copy
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
if ( eType == OBJ_TYPE_MODULE ) // module
|
2001-06-28 09:26:41 -05:00
|
|
|
{
|
|
|
|
// get module
|
|
|
|
::rtl::OUString aModule = BasicIDE::GetModule( pSourceShell, aSourceLibName, aSourceName );
|
|
|
|
|
|
|
|
// insert module into target library
|
|
|
|
BasicIDE::InsertModule( pDestShell, aDestLibName, aSourceName, aModule );
|
|
|
|
BasicIDE::MarkDocShellModified( pDestShell );
|
|
|
|
}
|
2004-07-23 06:06:12 -05:00
|
|
|
else if ( eType == OBJ_TYPE_DIALOG ) // dialog
|
2001-06-15 02:45:19 -05:00
|
|
|
{
|
2001-06-22 08:45:11 -05:00
|
|
|
// get dialog
|
|
|
|
Reference< io::XInputStreamProvider > xISP( BasicIDE::GetDialog( pSourceShell, aSourceLibName, aSourceName ) );
|
|
|
|
|
|
|
|
if ( xISP.is() )
|
2001-06-15 02:45:19 -05:00
|
|
|
{
|
|
|
|
// insert dialog into target library
|
|
|
|
BasicIDE::InsertDialog( pDestShell, aDestLibName, aSourceName, xISP );
|
|
|
|
BasicIDE::MarkDocShellModified( pDestShell );
|
|
|
|
}
|
2001-06-22 08:45:11 -05:00
|
|
|
}
|
2001-06-28 09:26:41 -05:00
|
|
|
}
|
|
|
|
catch ( container::ElementExistException& e )
|
|
|
|
{
|
|
|
|
ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
|
|
|
|
DBG_ERROR( aBStr.GetBuffer() );
|
|
|
|
}
|
|
|
|
catch ( container::NoSuchElementException& e )
|
|
|
|
{
|
|
|
|
ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
|
|
|
|
DBG_ERROR( aBStr.GetBuffer() );
|
2001-06-15 02:45:19 -05:00
|
|
|
}
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
|
|
|
|
2001-06-26 03:00:01 -05:00
|
|
|
// create target module/dialog window
|
2004-07-23 06:06:12 -05:00
|
|
|
if ( pSourceShell != pDestShell || aSourceLibName != aDestLibName )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
|
|
|
if( pDispatcher )
|
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, pDestShell, aDestLibName, aSourceName, ConvertType( eType ) );
|
2000-09-29 05:02:42 -05:00
|
|
|
pDispatcher->Execute( SID_BASICIDE_SBXINSERTED,
|
|
|
|
SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 2; // Aufklappen...
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
OrganizeDialog::OrganizeDialog( Window* pParent, INT16 tabId, BasicEntryDescriptor& rDesc )
|
|
|
|
:TabDialog( pParent, IDEResId( RID_TD_ORGANIZE ) )
|
|
|
|
,aTabCtrl( this, IDEResId( RID_TC_ORGANIZE ) )
|
|
|
|
,m_aCurEntry( rDesc )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
aTabCtrl.SetActivatePageHdl( LINK( this, OrganizeDialog, ActivatePageHdl ) );
|
2004-05-19 02:02:38 -05:00
|
|
|
if( tabId == 0 )
|
|
|
|
{
|
|
|
|
aTabCtrl.SetCurPageId( RID_TP_MOD );
|
|
|
|
}
|
|
|
|
else if ( tabId == 1 )
|
|
|
|
{
|
|
|
|
aTabCtrl.SetCurPageId( RID_TP_DLG );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aTabCtrl.SetCurPageId( RID_TP_LIB );
|
|
|
|
}
|
|
|
|
|
2000-09-29 05:02:42 -05:00
|
|
|
ActivatePageHdl( &aTabCtrl );
|
|
|
|
|
2001-09-06 03:21:02 -05:00
|
|
|
BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
|
|
|
|
SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
|
|
|
|
SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
|
2000-09-29 05:02:42 -05:00
|
|
|
if( pDispatcher )
|
|
|
|
{
|
|
|
|
pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
__EXPORT OrganizeDialog::~OrganizeDialog()
|
|
|
|
{
|
|
|
|
for ( USHORT i = 0; i < aTabCtrl.GetPageCount(); i++ )
|
|
|
|
delete aTabCtrl.GetTabPage( aTabCtrl.GetPageId( i ) );
|
|
|
|
};
|
|
|
|
|
|
|
|
short OrganizeDialog::Execute()
|
|
|
|
{
|
|
|
|
Window* pPrevDlgParent = Application::GetDefDialogParent();
|
|
|
|
Application::SetDefDialogParent( this );
|
|
|
|
short nRet = TabDialog::Execute();
|
|
|
|
Application::SetDefDialogParent( pPrevDlgParent );
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IMPL_LINK( OrganizeDialog, ActivatePageHdl, TabControl *, pTabCtrl )
|
|
|
|
{
|
|
|
|
USHORT nId = pTabCtrl->GetCurPageId();
|
|
|
|
// Wenn TabPage noch nicht erzeugt wurde, dann erzeugen
|
|
|
|
if ( !pTabCtrl->GetTabPage( nId ) )
|
|
|
|
{
|
|
|
|
TabPage* pNewTabPage = 0;
|
|
|
|
switch ( nId )
|
|
|
|
{
|
|
|
|
case RID_TP_MOD:
|
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
pNewTabPage = new ObjectPage( pTabCtrl, IDEResId( RID_TP_MODULS ), BROWSEMODE_MODULES );
|
2004-05-19 02:02:38 -05:00
|
|
|
((ObjectPage*)pNewTabPage)->SetTabDlg( this );
|
2004-07-23 06:06:12 -05:00
|
|
|
((ObjectPage*)pNewTabPage)->SetCurrentEntry( m_aCurEntry );
|
2004-05-19 02:02:38 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RID_TP_DLG:
|
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
pNewTabPage = new ObjectPage( pTabCtrl, IDEResId( RID_TP_DLGS ), BROWSEMODE_DIALOGS );
|
2000-09-29 05:02:42 -05:00
|
|
|
((ObjectPage*)pNewTabPage)->SetTabDlg( this );
|
2004-07-23 06:06:12 -05:00
|
|
|
((ObjectPage*)pNewTabPage)->SetCurrentEntry( m_aCurEntry );
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RID_TP_LIB:
|
|
|
|
{
|
|
|
|
pNewTabPage = new LibPage( pTabCtrl );
|
|
|
|
((LibPage*)pNewTabPage)->SetTabDlg( this );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: DBG_ERROR( "PageHdl: Unbekannte ID!" );
|
|
|
|
}
|
|
|
|
DBG_ASSERT( pNewTabPage, "Keine Page!" );
|
|
|
|
pTabCtrl->SetTabPage( nId, pNewTabPage );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
ObjectPage::ObjectPage( Window * pParent, const ResId& rResId, USHORT nMode ) :
|
|
|
|
TabPage( pParent, rResId ),
|
2000-09-29 05:02:42 -05:00
|
|
|
aLibText( this, IDEResId( RID_STR_LIB ) ),
|
|
|
|
aBasicBox( this, IDEResId( RID_TRLBOX ) ),
|
|
|
|
aEditButton( this, IDEResId( RID_PB_EDIT ) ),
|
|
|
|
aCloseButton( this, IDEResId( RID_PB_CLOSE ) ),
|
|
|
|
aNewModButton( this, IDEResId( RID_PB_NEWMOD ) ),
|
|
|
|
aNewDlgButton( this, IDEResId( RID_PB_NEWDLG ) ),
|
|
|
|
aDelButton( this, IDEResId( RID_PB_DELETE ) )
|
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
pTabDlg = 0;
|
|
|
|
|
|
|
|
aEditButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
|
|
|
|
aDelButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
|
|
|
|
aCloseButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
|
|
|
|
aBasicBox.SetSelectHdl( LINK( this, ObjectPage, BasicBoxHighlightHdl ) );
|
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
if( nMode & BROWSEMODE_MODULES )
|
2004-05-19 02:02:38 -05:00
|
|
|
{
|
|
|
|
aNewModButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
|
|
|
|
aNewDlgButton.Hide();
|
|
|
|
}
|
2004-07-23 06:06:12 -05:00
|
|
|
else if ( nMode & BROWSEMODE_DIALOGS )
|
2004-05-19 02:02:38 -05:00
|
|
|
{
|
|
|
|
aNewDlgButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
|
|
|
|
aNewModButton.Hide();
|
|
|
|
}
|
|
|
|
|
2000-09-29 05:02:42 -05:00
|
|
|
aBasicBox.SetDragDropMode( SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY );
|
|
|
|
aBasicBox.EnableInplaceEditing( TRUE );
|
2004-05-19 02:02:38 -05:00
|
|
|
aBasicBox.SetMode( nMode );
|
2004-07-23 06:06:12 -05:00
|
|
|
aBasicBox.SetWindowBits( WB_HASLINES | WB_HASLINESATROOT |
|
|
|
|
WB_HASBUTTONS | WB_HASBUTTONSATROOT |
|
|
|
|
WB_HSCROLL );
|
|
|
|
aBasicBox.ScanAllEntries();
|
2000-09-29 05:02:42 -05:00
|
|
|
|
|
|
|
aEditButton.GrabFocus();
|
|
|
|
CheckButtons();
|
|
|
|
}
|
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
void ObjectPage::SetCurrentEntry( BasicEntryDescriptor& rDesc )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
aBasicBox.SetCurrentEntry( rDesc );
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
void __EXPORT ObjectPage::ActivatePage()
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
aBasicBox.UpdateEntries();
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void __EXPORT ObjectPage::DeactivatePage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ObjectPage::CheckButtons()
|
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
// enable/disable edit button
|
2000-09-29 05:02:42 -05:00
|
|
|
SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
|
|
|
|
USHORT nDepth = pCurEntry ? aBasicBox.GetModel()->GetDepth( pCurEntry ) : 0;
|
|
|
|
if ( nDepth == 2 )
|
|
|
|
aEditButton.Enable();
|
|
|
|
else
|
|
|
|
aEditButton.Disable();
|
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
// enable/disable new module/dialog buttons
|
|
|
|
BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
|
|
|
|
LibraryLocation eLocation( aDesc.GetLocation() );
|
|
|
|
BOOL bReadOnly = FALSE;
|
2001-11-12 15:39:49 -06:00
|
|
|
if ( nDepth == 1 || nDepth == 2 )
|
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
SfxObjectShell* pShell( aDesc.GetShell() );
|
|
|
|
::rtl::OUString aOULibName( aDesc.GetLibName() );
|
|
|
|
Reference< script::XLibraryContainer2 > xModLibContainer( BasicIDE::GetModuleLibraryContainer( pShell ), UNO_QUERY );
|
|
|
|
Reference< script::XLibraryContainer2 > xDlgLibContainer( BasicIDE::GetDialogLibraryContainer( pShell ), UNO_QUERY );
|
|
|
|
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) ||
|
|
|
|
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) ) )
|
2001-11-12 15:39:49 -06:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
bReadOnly = TRUE;
|
2001-11-12 15:39:49 -06:00
|
|
|
}
|
|
|
|
}
|
2004-07-23 06:06:12 -05:00
|
|
|
if ( bReadOnly || eLocation == LIBRARY_LOCATION_SHARE )
|
2001-11-12 15:39:49 -06:00
|
|
|
{
|
|
|
|
aNewModButton.Disable();
|
|
|
|
aNewDlgButton.Disable();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aNewModButton.Enable();
|
|
|
|
aNewDlgButton.Enable();
|
|
|
|
}
|
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
// enable/disable delete button
|
|
|
|
if ( nDepth == 2 && !bReadOnly && eLocation != LIBRARY_LOCATION_SHARE )
|
|
|
|
aDelButton.Enable();
|
2000-09-29 05:02:42 -05:00
|
|
|
else
|
2004-07-23 06:06:12 -05:00
|
|
|
aDelButton.Disable();
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( ObjectPage, BasicBoxHighlightHdl, BasicTreeListBox *, pBox )
|
|
|
|
{
|
|
|
|
if ( !pBox->IsSelected( pBox->GetHdlEntry() ) )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
CheckButtons();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( ObjectPage, ButtonHdl, Button *, pButton )
|
|
|
|
{
|
|
|
|
if ( pButton == &aEditButton )
|
|
|
|
{
|
2001-09-06 03:21:02 -05:00
|
|
|
SfxViewFrame* pViewFrame = SfxViewFrame::Current();
|
2004-10-04 13:40:29 -05:00
|
|
|
SfxAllItemSet aArgs( SFX_APP()->GetPool() );
|
|
|
|
SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs );
|
|
|
|
SFX_APP()->ExecuteSlot( aRequest );
|
|
|
|
|
2001-09-06 03:21:02 -05:00
|
|
|
BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
|
|
|
|
pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
|
2004-10-04 13:40:29 -05:00
|
|
|
SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
|
2000-09-29 05:02:42 -05:00
|
|
|
SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
|
|
|
|
DBG_ASSERT( pCurEntry, "Entry?!" );
|
|
|
|
if ( aBasicBox.GetModel()->GetDepth( pCurEntry ) == 2 )
|
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
|
|
|
|
if ( pDispatcher )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetShell(), aDesc.GetLibName(),
|
|
|
|
aDesc.GetName(), aBasicBox.ConvertType( aDesc.GetType() ) );
|
2000-09-29 05:02:42 -05:00
|
|
|
pDispatcher->Execute( SID_BASICIDE_SHOWSBX, SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // Nur Lib selektiert
|
|
|
|
{
|
|
|
|
DBG_ASSERT( aBasicBox.GetModel()->GetDepth( pCurEntry ) == 1, "Kein LibEntry?!" );
|
2004-07-23 06:06:12 -05:00
|
|
|
SfxObjectShell* pShell = 0;
|
|
|
|
SvLBoxEntry* pParentEntry = aBasicBox.GetParent( pCurEntry );
|
|
|
|
if ( pParentEntry )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
BasicShellEntry* pBasicShellEntry = (BasicShellEntry*)pParentEntry->GetUserData();
|
|
|
|
if ( pBasicShellEntry )
|
|
|
|
pShell = pBasicShellEntry->GetShell();
|
|
|
|
}
|
|
|
|
SfxObjectShellItem aShellItem( SID_BASICIDE_ARG_SHELL, pShell );
|
|
|
|
String aLibName( aBasicBox.GetEntryText( pCurEntry ) );
|
|
|
|
SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
|
|
|
|
if ( pDispatcher )
|
|
|
|
{
|
|
|
|
pDispatcher->Execute( SID_BASICIDE_LIBSELECTED, SFX_CALLMODE_ASYNCHRON, &aShellItem, &aLibNameItem, 0L );
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
EndTabDialog( 1 );
|
|
|
|
}
|
|
|
|
else if ( pButton == &aNewModButton )
|
|
|
|
NewModule();
|
|
|
|
else if ( pButton == &aNewDlgButton )
|
|
|
|
NewDialog();
|
|
|
|
else if ( pButton == &aDelButton )
|
|
|
|
DeleteCurrent();
|
|
|
|
else if ( pButton == &aCloseButton )
|
|
|
|
EndTabDialog( 0 );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
bool ObjectPage::GetSelection( SfxObjectShell*& rpShell, String& rLibName )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
bool bRet = false;
|
2001-08-29 06:29:09 -05:00
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
|
|
|
|
BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
|
|
|
|
rpShell = aDesc.GetShell();
|
|
|
|
rLibName = aDesc.GetLibName();
|
|
|
|
if ( !rLibName.Len() )
|
|
|
|
rLibName = String::CreateFromAscii( "Standard" );
|
2001-08-29 06:29:09 -05:00
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
// check if the module library is loaded
|
|
|
|
BOOL bOK = TRUE;
|
|
|
|
::rtl::OUString aOULibName( rLibName );
|
|
|
|
Reference< script::XLibraryContainer > xModLibContainer( BasicIDE::GetModuleLibraryContainer( rpShell ), UNO_QUERY );
|
|
|
|
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
|
2001-08-29 06:29:09 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
// check password
|
|
|
|
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
|
|
|
|
if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
|
2001-11-02 06:45:10 -06:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
String aPassword;
|
|
|
|
bOK = QueryPassword( xModLibContainer, rLibName, aPassword );
|
2001-11-02 06:45:10 -06:00
|
|
|
}
|
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
// load library
|
|
|
|
if ( bOK )
|
|
|
|
xModLibContainer->loadLibrary( aOULibName );
|
2001-11-02 06:45:10 -06:00
|
|
|
}
|
2001-08-29 06:29:09 -05:00
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
// check if the dialog library is loaded
|
|
|
|
Reference< script::XLibraryContainer > xDlgLibContainer( BasicIDE::GetDialogLibraryContainer( rpShell ), UNO_QUERY );
|
|
|
|
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
// load library
|
|
|
|
if ( bOK )
|
|
|
|
xDlgLibContainer->loadLibrary( aOULibName );
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
2004-07-23 06:06:12 -05:00
|
|
|
|
|
|
|
if ( bOK )
|
|
|
|
bRet = true;
|
|
|
|
|
|
|
|
return bRet;
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void ObjectPage::NewModule()
|
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
SfxObjectShell* pShell = 0;
|
|
|
|
String aLibName;
|
|
|
|
|
|
|
|
if ( GetSelection( pShell, aLibName ) )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
String aModName;
|
|
|
|
createModImpl( static_cast<Window*>( this ), pShell,
|
|
|
|
aBasicBox, aLibName, aModName, true );
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ObjectPage::NewDialog()
|
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
SfxObjectShell* pShell = 0;
|
|
|
|
String aLibName;
|
|
|
|
|
|
|
|
if ( GetSelection( pShell, aLibName ) )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
if ( !BasicIDE::HasDialogLibrary( pShell, aLibName ) )
|
|
|
|
BasicIDE::CreateDialogLibrary( pShell, aLibName );
|
|
|
|
|
|
|
|
std::auto_ptr< NewObjectDialog > xNewDlg(
|
|
|
|
new NewObjectDialog(this, NEWOBJECTMODE_DLG, true));
|
|
|
|
xNewDlg->SetObjectName( BasicIDE::CreateDialogName( pShell, aLibName ) );
|
|
|
|
|
|
|
|
if (xNewDlg->Execute() != 0)
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
String aDlgName( xNewDlg->GetObjectName() );
|
|
|
|
if (aDlgName.Len() == 0)
|
|
|
|
aDlgName = BasicIDE::CreateDialogName(pShell, aLibName);
|
2001-06-15 02:45:19 -05:00
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
try
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
Reference< io::XInputStreamProvider > xISP( BasicIDE::CreateDialog( pShell, aLibName, aDlgName ) );
|
|
|
|
SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, pShell, aLibName, aDlgName, BASICIDE_TYPE_DIALOG );
|
|
|
|
BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
|
|
|
|
SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
|
|
|
|
SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
|
|
|
|
if( pDispatcher )
|
2000-09-29 05:02:42 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
pDispatcher->Execute( SID_BASICIDE_SBXINSERTED,
|
|
|
|
SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
|
2001-06-15 02:45:19 -05:00
|
|
|
}
|
2004-07-23 06:06:12 -05:00
|
|
|
LibraryLocation eLocation = BasicIDE::GetLibraryLocation( pShell, aLibName );
|
|
|
|
SvLBoxEntry* pRootEntry = aBasicBox.FindRootEntry( pShell, eLocation );
|
|
|
|
if ( pRootEntry )
|
2001-06-15 02:45:19 -05:00
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
if ( !aBasicBox.IsExpanded( pRootEntry ) )
|
|
|
|
aBasicBox.Expand( pRootEntry );
|
|
|
|
SvLBoxEntry* pLibEntry = aBasicBox.FindEntry( pRootEntry, aLibName, OBJ_TYPE_LIBRARY );
|
|
|
|
DBG_ASSERT( pLibEntry, "Libeintrag nicht gefunden!" );
|
|
|
|
if ( pLibEntry )
|
|
|
|
{
|
|
|
|
if ( !aBasicBox.IsExpanded( pLibEntry ) )
|
|
|
|
aBasicBox.Expand( pLibEntry );
|
|
|
|
SvLBoxEntry* pEntry = aBasicBox.FindEntry( pLibEntry, aDlgName, OBJ_TYPE_DIALOG );
|
|
|
|
if ( !pEntry )
|
|
|
|
{
|
|
|
|
pEntry = aBasicBox.AddEntry(
|
|
|
|
aDlgName,
|
|
|
|
Image( IDEResId( RID_IMG_DIALOG ) ),
|
|
|
|
Image( IDEResId( RID_IMG_DIALOG_HC ) ),
|
|
|
|
pLibEntry, false,
|
|
|
|
std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_DIALOG ) ) );
|
|
|
|
DBG_ASSERT( pEntry, "InsertEntry fehlgeschlagen!" );
|
|
|
|
}
|
|
|
|
aBasicBox.SetCurEntry( pEntry );
|
|
|
|
aBasicBox.Select( aBasicBox.GetCurEntry() ); // OV-Bug?!
|
|
|
|
}
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
|
|
|
}
|
2004-07-23 06:06:12 -05:00
|
|
|
catch ( container::ElementExistException& )
|
|
|
|
{
|
|
|
|
ErrorBox( this, WB_OK | WB_DEF_OK,
|
|
|
|
String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute();
|
|
|
|
}
|
|
|
|
catch ( container::NoSuchElementException& e )
|
|
|
|
{
|
|
|
|
ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
|
|
|
|
DBG_ERROR( aBStr.GetBuffer() );
|
|
|
|
}
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ObjectPage::DeleteCurrent()
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
|
|
|
|
DBG_ASSERT( pCurEntry, "Kein aktueller Eintrag!" );
|
2004-07-23 06:06:12 -05:00
|
|
|
BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
|
|
|
|
SfxObjectShell* pShell( aDesc.GetShell() );
|
|
|
|
String aLibName( aDesc.GetLibName() );
|
|
|
|
String aName( aDesc.GetName() );
|
|
|
|
BasicEntryType eType( aDesc.GetType() );
|
|
|
|
|
|
|
|
if ( ( eType == OBJ_TYPE_MODULE && QueryDelModule( aName, this ) ) ||
|
|
|
|
( eType == OBJ_TYPE_DIALOG && QueryDelDialog( aName, this ) ) )
|
2001-06-15 02:45:19 -05:00
|
|
|
{
|
|
|
|
aBasicBox.GetModel()->Remove( pCurEntry );
|
|
|
|
if ( aBasicBox.GetCurEntry() ) // OV-Bug ?
|
|
|
|
aBasicBox.Select( aBasicBox.GetCurEntry() );
|
2001-09-06 03:21:02 -05:00
|
|
|
BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
|
|
|
|
SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
|
|
|
|
SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
|
2001-06-15 02:45:19 -05:00
|
|
|
if( pDispatcher )
|
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, pShell, aLibName, aName, aBasicBox.ConvertType( eType ) );
|
2001-06-15 02:45:19 -05:00
|
|
|
pDispatcher->Execute( SID_BASICIDE_SBXDELETED,
|
|
|
|
SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
|
|
|
|
}
|
2001-06-28 09:26:41 -05:00
|
|
|
|
2001-06-15 02:45:19 -05:00
|
|
|
try
|
|
|
|
{
|
2004-07-23 06:06:12 -05:00
|
|
|
if ( eType == OBJ_TYPE_MODULE )
|
2001-06-28 09:26:41 -05:00
|
|
|
BasicIDE::RemoveModule( pShell, aLibName, aName );
|
2004-07-23 06:06:12 -05:00
|
|
|
else if ( eType == OBJ_TYPE_DIALOG )
|
2001-06-28 09:26:41 -05:00
|
|
|
BasicIDE::RemoveDialog( pShell, aLibName, aName );
|
|
|
|
|
2001-06-15 02:45:19 -05:00
|
|
|
BasicIDE::MarkDocShellModified( pShell );
|
|
|
|
}
|
|
|
|
catch ( container::NoSuchElementException& e )
|
|
|
|
{
|
|
|
|
ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
|
|
|
|
DBG_ERROR( aBStr.GetBuffer() );
|
|
|
|
}
|
|
|
|
}
|
2000-09-29 05:02:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ObjectPage::EndTabDialog( USHORT nRet )
|
|
|
|
{
|
|
|
|
DBG_ASSERT( pTabDlg, "TabDlg nicht gesetzt!" );
|
|
|
|
if ( pTabDlg )
|
|
|
|
pTabDlg->EndDialog( nRet );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LibDialog::LibDialog( Window* pParent )
|
|
|
|
: ModalDialog( pParent, IDEResId( RID_DLG_LIBS ) ),
|
|
|
|
aOKButton( this, IDEResId( RID_PB_OK ) ),
|
|
|
|
aCancelButton( this, IDEResId( RID_PB_CANCEL ) ),
|
|
|
|
aStorageName( this, IDEResId( RID_FT_STORAGENAME ) ),
|
|
|
|
aLibBox( this, IDEResId( RID_CTRL_LIBS ) ),
|
2001-07-31 09:07:16 -05:00
|
|
|
aFixedLine( this, IDEResId( RID_FL_OPTIONS ) ),
|
2000-09-29 05:02:42 -05:00
|
|
|
aReferenceBox( this, IDEResId( RID_CB_REF ) ),
|
|
|
|
aReplaceBox( this, IDEResId( RID_CB_REPL ) )
|
|
|
|
{
|
|
|
|
SetText( String( IDEResId( RID_STR_APPENDLIBS ) ) );
|
|
|
|
FreeResource();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LibDialog::~LibDialog()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void LibDialog::SetStorageName( const String& rName )
|
|
|
|
{
|
|
|
|
String aName( IDEResId( RID_STR_FILENAME ) );
|
|
|
|
aName += rName;
|
|
|
|
aStorageName.SetText( aName );
|
|
|
|
}
|
2002-07-30 07:10:28 -05:00
|
|
|
|
|
|
|
// Helper function
|
2004-07-23 06:06:12 -05:00
|
|
|
SbModule* createModImpl( Window* pWin, SfxObjectShell* pShell,
|
|
|
|
BasicTreeListBox& rBasicBox, const String& rLibName, String aModName, bool bMain )
|
2002-07-30 07:10:28 -05:00
|
|
|
{
|
|
|
|
SbModule* pModule = NULL;
|
|
|
|
|
2004-07-23 06:06:12 -05:00
|
|
|
String aLibName( rLibName );
|
|
|
|
if ( !aLibName.Len() )
|
|
|
|
aLibName = String::CreateFromAscii( "Standard" );
|
|
|
|
if ( !BasicIDE::HasModuleLibrary( pShell, aLibName ) )
|
|
|
|
BasicIDE::CreateModuleLibrary( pShell, aLibName );
|
|
|
|
if ( !aModName.Len() )
|
|
|
|
aModName = BasicIDE::CreateModuleName( pShell, aLibName );
|
|
|
|
|
2002-07-30 07:10:28 -05:00
|
|
|
std::auto_ptr< NewObjectDialog > xNewDlg(
|
|
|
|
new NewObjectDialog( pWin, NEWOBJECTMODE_MOD, true ) );
|
|
|
|
xNewDlg->SetObjectName( aModName );
|
|
|
|
|
|
|
|
if (xNewDlg->Execute() != 0)
|
|
|
|
{
|
2002-08-06 03:12:20 -05:00
|
|
|
if ( xNewDlg->GetObjectName().Len() )
|
|
|
|
aModName = xNewDlg->GetObjectName();
|
2002-07-30 07:10:28 -05:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2003-11-05 05:39:42 -06:00
|
|
|
::rtl::OUString aModule = BasicIDE::CreateModule( pShell, aLibName, aModName, bMain );
|
2004-07-23 06:06:12 -05:00
|
|
|
BasicManager* pBasMgr = pShell ? pShell->GetBasicManager() : SFX_APP()->GetBasicManager();
|
|
|
|
if ( pBasMgr )
|
|
|
|
{
|
|
|
|
StarBASIC* pBasic = pBasMgr->GetLib( aLibName );
|
|
|
|
if ( pBasic )
|
|
|
|
pModule = pBasic->FindModule( aModName );
|
|
|
|
}
|
2002-07-30 07:10:28 -05:00
|
|
|
SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, pShell, aLibName, aModName, BASICIDE_TYPE_MODULE );
|
|
|
|
BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
|
|
|
|
SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
|
|
|
|
SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
|
|
|
|
if( pDispatcher )
|
|
|
|
{
|
|
|
|
pDispatcher->Execute( SID_BASICIDE_SBXINSERTED,
|
|
|
|
SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
|
|
|
|
}
|
2004-07-23 06:06:12 -05:00
|
|
|
LibraryLocation eLocation = BasicIDE::GetLibraryLocation( pShell, aLibName );
|
|
|
|
SvLBoxEntry* pRootEntry = rBasicBox.FindRootEntry( pShell, eLocation );
|
|
|
|
if ( pRootEntry )
|
|
|
|
{
|
|
|
|
if ( !rBasicBox.IsExpanded( pRootEntry ) )
|
|
|
|
rBasicBox.Expand( pRootEntry );
|
|
|
|
SvLBoxEntry* pLibEntry = rBasicBox.FindEntry( pRootEntry, aLibName, OBJ_TYPE_LIBRARY );
|
|
|
|
DBG_ASSERT( pLibEntry, "Libeintrag nicht gefunden!" );
|
|
|
|
if ( pLibEntry )
|
|
|
|
{
|
|
|
|
if ( !rBasicBox.IsExpanded( pLibEntry ) )
|
|
|
|
rBasicBox.Expand( pLibEntry );
|
|
|
|
SvLBoxEntry* pEntry = rBasicBox.FindEntry( pLibEntry, aModName, OBJ_TYPE_MODULE );
|
|
|
|
if ( !pEntry )
|
|
|
|
{
|
|
|
|
pEntry = rBasicBox.AddEntry(
|
|
|
|
aModName,
|
|
|
|
Image( IDEResId( RID_IMG_MODULE ) ),
|
|
|
|
Image( IDEResId( RID_IMG_MODULE_HC ) ),
|
|
|
|
pLibEntry, false,
|
|
|
|
std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
|
|
|
|
DBG_ASSERT( pEntry, "InsertEntry fehlgeschlagen!" );
|
|
|
|
}
|
|
|
|
rBasicBox.SetCurEntry( pEntry );
|
|
|
|
rBasicBox.Select( rBasicBox.GetCurEntry() ); // OV-Bug?!
|
|
|
|
}
|
|
|
|
}
|
2002-07-30 07:10:28 -05:00
|
|
|
}
|
|
|
|
catch ( container::ElementExistException& )
|
|
|
|
{
|
|
|
|
ErrorBox( pWin, WB_OK | WB_DEF_OK,
|
|
|
|
String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute();
|
|
|
|
}
|
|
|
|
catch ( container::NoSuchElementException& e )
|
|
|
|
{
|
|
|
|
ByteString aBStr( String(e.Message), RTL_TEXTENCODING_ASCII_US );
|
|
|
|
DBG_ERROR( aBStr.GetBuffer() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pModule;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|