Files
libreoffice/basctl/source/basicide/moduldl2.cxx

1738 lines
72 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-29 10:02:42 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-29 10:02:42 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-29 10:02:42 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-29 10:02:42 +00:00
*
* This file is part of OpenOffice.org.
2000-09-29 10:02:42 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-29 10:02:42 +00:00
*
* OpenOffice.org 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 version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-29 10:02:42 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-29 10:02:42 +00:00
*
************************************************************************/
2000-09-29 10:02:42 +00:00
#include <ide_pch.hxx>
2011-11-21 23:33:54 -05:00
#include <vcl/msgbox.hxx>
2000-09-29 10:02:42 +00:00
#include <sot/storinfo.hxx>
#include <moduldlg.hrc>
#include <moduldlg.hxx>
#include <basidesh.hrc>
2001-09-06 08:21:02 +00:00
#include <basidesh.hxx>
2000-09-29 10:02:42 +00:00
#include <bastypes.hxx>
#include <basobj.hxx>
#include <baside2.hrc>
#include <iderdll.hxx>
#include <iderdll2.hxx>
#include <svx/passwd.hxx>
#include <sbxitem.hxx>
#include <basdoc.hxx>
#include <ucbhelper/content.hxx>
#include "rtl/uri.hxx"
2000-11-20 07:32:42 +00:00
#include <tools/urlobj.hxx>
#include <tools/diagnose_ex.h>
2000-09-29 10:02:42 +00:00
#include <sot/storage.hxx>
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
2001-09-25 08:14:46 +00:00
#include <com/sun/star/script/XLibraryContainer2.hpp>
#include <com/sun/star/script/XLibraryContainerPassword.hpp>
#include <com/sun/star/script/XLibraryContainerExport.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include "com/sun/star/ucb/XCommandEnvironment.hpp"
#include <com/sun/star/ucb/NameClash.hpp>
#include "com/sun/star/packages/manifest/XManifestWriter.hpp"
#include <unotools/pathoptions.hxx>
2000-11-20 07:32:42 +00:00
#include <comphelper/processfactory.hxx>
#include <com/sun/star/util/VetoException.hpp>
#include <com/sun/star/script/ModuleSizeExceededRequest.hpp>
using namespace ::comphelper;
using ::rtl::OUString;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::ucb;
using namespace ::com::sun::star::ui::dialogs;
2000-11-20 07:32:42 +00:00
typedef ::cppu::WeakImplHelper1< task::XInteractionHandler > HandlerImpl_BASE;
class DummyInteractionHandler : public HandlerImpl_BASE
{
Reference< task::XInteractionHandler > m_xHandler;
public:
DummyInteractionHandler( const Reference< task::XInteractionHandler >& xHandler ) : m_xHandler( xHandler ){}
virtual void SAL_CALL handle( const Reference< task::XInteractionRequest >& rRequest ) throw (::com::sun::star::uno::RuntimeException)
{
if ( m_xHandler.is() )
{
script::ModuleSizeExceededRequest aModSizeException;
if ( rRequest->getRequest() >>= aModSizeException )
m_xHandler->handle( rRequest );
}
}
};
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
// BasicLibUserData
//----------------------------------------------------------------------------
class BasicLibUserData
2000-09-29 10:02:42 +00:00
{
2001-11-07 09:18:27 +00:00
private:
ScriptDocument m_aDocument;
2000-09-29 10:02:42 +00:00
2001-11-07 09:18:27 +00:00
public:
BasicLibUserData( const ScriptDocument& rDocument ) : m_aDocument( rDocument ) { }
2001-11-07 09:18:27 +00:00
virtual ~BasicLibUserData() {};
2000-09-29 10:02:42 +00:00
const ScriptDocument&
GetDocument() const { return m_aDocument; }
2001-11-07 09:18:27 +00:00
};
2000-09-29 10:02:42 +00:00
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
// BasicLibLBoxString
//----------------------------------------------------------------------------
2000-09-29 10:02:42 +00:00
2001-11-07 09:18:27 +00:00
class BasicLibLBoxString : public SvLBoxString
{
public:
BasicLibLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, const String& rTxt ) :
2001-11-07 09:18:27 +00:00
SvLBoxString( pEntry, nFlags, rTxt ) {}
2000-09-29 10:02:42 +00:00
virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry );
2001-11-07 09:18:27 +00:00
};
2000-09-29 10:02:42 +00:00
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
void BasicLibLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16, SvLBoxEntry* pEntry )
2000-09-29 10:02:42 +00:00
{
2002-07-05 09:27:37 +00:00
// Change text color if library is read only:
bool bReadOnly = false;
if (pEntry && pEntry->GetUserData())
{
ScriptDocument aDocument(
static_cast< BasicLibUserData * >(pEntry->GetUserData())->
GetDocument() );
2002-07-05 09:27:37 +00:00
rtl::OUString aLibName(
static_cast< SvLBoxString * >(pEntry->GetItem(1))->GetText());
Reference< script::XLibraryContainer2 > xModLibContainer(
aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY);
2002-07-05 09:27:37 +00:00
Reference< script::XLibraryContainer2 > xDlgLibContainer(
aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY);
2002-07-05 09:27:37 +00:00
bReadOnly
= (xModLibContainer.is() && xModLibContainer->hasByName(aLibName)
&& xModLibContainer->isLibraryReadOnly(aLibName))
|| (xDlgLibContainer.is() && xDlgLibContainer->hasByName(aLibName)
&& xDlgLibContainer->isLibraryReadOnly(aLibName));
}
2002-07-05 09:27:37 +00:00
if (bReadOnly)
rDev.DrawCtrlText(rPos, GetText(), 0, STRING_LEN, TEXT_DRAW_DISABLE);
else
rDev.DrawText(rPos, GetText());
}
2000-09-29 10:02:42 +00:00
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
// BasicCheckBox
//----------------------------------------------------------------------------
BasicCheckBox::BasicCheckBox( Window* pParent, const ResId& rResId )
:SvTabListBox( pParent, rResId )
,m_aDocument( ScriptDocument::getApplicationScriptDocument() )
2000-09-29 10:02:42 +00:00
{
nMode = LIBMODE_MANAGER;
long aTabs_[] = { 1, 12 }; // TabPos needs at least one...
// 12 because of the CheckBox
SetTabs( aTabs_ );
2001-11-07 09:18:27 +00:00
Init();
2000-09-29 10:02:42 +00:00
}
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
2000-09-29 10:02:42 +00:00
2010-12-11 22:45:31 +01:00
BasicCheckBox::~BasicCheckBox()
2000-09-29 10:02:42 +00:00
{
delete pCheckButton;
2000-09-29 10:02:42 +00:00
// delete user data
SvLBoxEntry* pEntry = First();
while ( pEntry )
{
2011-11-21 20:13:24 -05:00
delete static_cast<BasicLibUserData*>(pEntry->GetUserData());
pEntry = Next( pEntry );
}
}
2000-09-29 10:02:42 +00:00
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
2000-09-29 10:02:42 +00:00
2001-11-07 09:18:27 +00:00
void BasicCheckBox::Init()
2000-09-29 10:02:42 +00:00
{
pCheckButton = new SvLBoxButtonData(this);
if ( nMode == LIBMODE_CHOOSER )
EnableCheckButton( pCheckButton );
else
EnableCheckButton( 0 );
2001-11-07 09:18:27 +00:00
SetHighlightRange();
}
2000-09-29 10:02:42 +00:00
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
2000-09-29 10:02:42 +00:00
void BasicCheckBox::SetMode( sal_uInt16 n )
{
nMode = n;
if ( nMode == LIBMODE_CHOOSER )
EnableCheckButton( pCheckButton );
else
EnableCheckButton( 0 );
}
//----------------------------------------------------------------------------
SvLBoxEntry* BasicCheckBox::DoInsertEntry( const String& rStr, sal_uLong nPos )
2000-09-29 10:02:42 +00:00
{
return SvTabListBox::InsertEntryToColumn( rStr, nPos, 0 );
2000-09-29 10:02:42 +00:00
}
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
SvLBoxEntry* BasicCheckBox::FindEntry( const String& rName )
2000-09-29 10:02:42 +00:00
{
sal_uLong nCount = GetEntryCount();
for ( sal_uLong i = 0; i < nCount; i++ )
2000-09-29 10:02:42 +00:00
{
2001-11-07 09:18:27 +00:00
SvLBoxEntry* pEntry = GetEntry( i );
DBG_ASSERT( pEntry, "pEntry?!" );
if ( rName.CompareIgnoreCaseToAscii( GetEntryText( pEntry, 0 ) ) == COMPARE_EQUAL )
return pEntry;
2000-09-29 10:02:42 +00:00
}
2001-11-07 09:18:27 +00:00
return 0;
}
2000-09-29 10:02:42 +00:00
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
void BasicCheckBox::CheckEntryPos( sal_uLong nPos, sal_Bool bCheck )
2001-11-07 09:18:27 +00:00
{
if ( nPos < GetEntryCount() )
{
SvLBoxEntry* pEntry = GetEntry( nPos );
if ( bCheck != GetCheckButtonState( pEntry ) )
SetCheckButtonState( pEntry,
bCheck
? SvButtonState(SV_BUTTON_CHECKED)
: SvButtonState(SV_BUTTON_UNCHECKED) );
}
}
//----------------------------------------------------------------------------
sal_Bool BasicCheckBox::IsChecked( sal_uLong nPos ) const
2001-11-07 09:18:27 +00:00
{
if ( nPos < GetEntryCount() )
return (GetCheckButtonState( GetEntry( nPos ) ) == SV_BUTTON_CHECKED);
return sal_False;
2001-11-07 09:18:27 +00:00
}
//----------------------------------------------------------------------------
void BasicCheckBox::InitEntry( SvLBoxEntry* pEntry, const XubString& rTxt, const Image& rImg1, const Image& rImg2, SvLBoxButtonKind eButtonKind )
2001-11-07 09:18:27 +00:00
{
SvTabListBox::InitEntry( pEntry, rTxt, rImg1, rImg2, eButtonKind );
2001-11-07 09:18:27 +00:00
if ( nMode == LIBMODE_MANAGER )
2001-11-07 09:18:27 +00:00
{
// initialize all columns with own string class (column 0 == bitmap)
sal_uInt16 nCount = pEntry->ItemCount();
for ( sal_uInt16 nCol = 1; nCol < nCount; ++nCol )
{
SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nCol );
BasicLibLBoxString* pStr = new BasicLibLBoxString( pEntry, 0, pCol->GetText() );
pEntry->ReplaceItem( pStr, nCol );
}
2001-11-07 09:18:27 +00:00
}
}
//----------------------------------------------------------------------------
Merge commit 'ooo/DEV300_m101' into integration/dev300_m101 * commit 'ooo/DEV300_m101': (185 commits) masterfix DEV300: #i10000# usage of L10N build_type masterfix: #i10000# INT16 -> sal_Int16 fixed compile errors after resync to m100, part2 gridsort: post-rebase fixes CWS gnumake3: found another tools integer type removetooltypes01: Fix build problems after rebase to DEV300m99 in basctl, cui, reportdesign, sw native359: #i114398# changing mac langpack icon native359: #i115669# fixing package description for solaris packages gnumake3: remove comphelper version; fix including extract.hxx locales34: #i106785# add Haitian_Haiti [ht-HT] to language list and locale data; locale data contributed by <jcpoulard> sb138: #i116659# timely termination of OnLogRotateThread accfixes: removed include of obsolete header file accfixes: removed obsolete file removetooltypes01: #i112600# Fix build problems on non-pro accfixes: moved some shared strings to svx part2 accfixes: moved some shared strings to svx accfixes: added more accessibility information and fixed tab orders in multiple dialogs (cui module) removetooltypes01: #i112600# Remove tools types for Mac specific parts fixed tab order in BasicIDE, Library dialog tab page added some accessible names in BasicIDE ... Conflicts: UnoControls/source/base/registercontrols.cxx accessibility/inc/accessibility/standard/vclxaccessiblelistboxlist.hxx automation/inc/automation/communi.hxx automation/inc/automation/simplecm.hxx automation/source/communi/communi.cxx automation/source/inc/rcontrol.hxx automation/source/miniapp/servuid.hxx automation/source/server/XMLParser.cxx automation/source/server/cmdbasestream.cxx automation/source/server/profiler.hxx automation/source/server/recorder.cxx automation/source/server/retstrm.hxx automation/source/server/server.cxx automation/source/server/sta_list.cxx automation/source/server/statemnt.cxx automation/source/server/statemnt.hxx automation/source/simplecm/packethandler.cxx automation/source/simplecm/simplecm.cxx automation/source/simplecm/tcpio.cxx automation/source/simplecm/tcpio.hxx automation/source/testtool/comm_bas.hxx automation/source/testtool/cretstrm.hxx automation/source/testtool/httprequest.cxx automation/source/testtool/httprequest.hxx automation/source/testtool/objtest.cxx automation/source/testtool/objtest.hxx basctl/source/basicide/baside2.cxx basctl/source/basicide/baside2.hxx basctl/source/basicide/baside2b.cxx basctl/source/basicide/baside3.cxx basctl/source/basicide/basides1.cxx basctl/source/basicide/basides2.cxx basctl/source/basicide/basidesh.cxx basctl/source/basicide/basidesh.src basctl/source/basicide/basobj3.cxx basctl/source/basicide/bastype2.cxx basctl/source/basicide/bastype3.cxx basctl/source/basicide/bastypes.cxx basctl/source/basicide/brkdlg.cxx basctl/source/basicide/iderdll.cxx basctl/source/basicide/macrodlg.cxx basctl/source/basicide/moduldl2.cxx basctl/source/basicide/moduldlg.cxx basctl/source/basicide/objdlg.cxx basctl/source/basicide/scriptdocument.cxx basctl/source/basicide/tbxctl.cxx basctl/source/basicide/tbxctl.hxx basctl/source/basicide/tbxctl.src basctl/source/dlged/dlged.cxx basctl/source/dlged/dlgedfunc.cxx basctl/source/dlged/dlgedobj.cxx basctl/source/inc/basidesh.hxx basctl/source/inc/bastypes.hxx basctl/source/inc/dlgedmod.hxx basctl/source/inc/dlgedpage.hxx crashrep/prj/build.lst cui/inc/pch/precompiled_cui.hxx cui/source/customize/acccfg.cxx cui/source/customize/acccfg.hrc cui/source/customize/acccfg.src cui/source/customize/cfg.cxx cui/source/customize/cfgutil.cxx cui/source/customize/macropg.cxx cui/source/customize/macropg.src cui/source/customize/selector.cxx cui/source/dialogs/SpellDialog.cxx cui/source/dialogs/commonlingui.cxx cui/source/dialogs/cuicharmap.cxx cui/source/dialogs/cuifmsearch.cxx cui/source/dialogs/cuigaldlg.cxx cui/source/dialogs/cuigrfflt.cxx cui/source/dialogs/hldocntp.cxx cui/source/dialogs/hldoctp.cxx cui/source/dialogs/hlinettp.cxx cui/source/dialogs/hlmailtp.cxx cui/source/dialogs/hlmarkwn.cxx cui/source/dialogs/hlmarkwn.src cui/source/dialogs/hltpbase.cxx cui/source/dialogs/iconcdlg.cxx cui/source/dialogs/passwdomdlg.cxx cui/source/dialogs/pastedlg.cxx cui/source/dialogs/scriptdlg.cxx cui/source/dialogs/thesdlg.cxx cui/source/dialogs/zoom.cxx cui/source/factory/dlgfact.hxx cui/source/inc/SpellDialog.hxx cui/source/inc/autocdlg.hxx cui/source/inc/backgrnd.hxx cui/source/inc/bbdlg.hxx cui/source/inc/cfg.hxx cui/source/inc/cfgutil.hxx cui/source/inc/cuigaldlg.hxx cui/source/inc/cuigrfflt.hxx cui/source/inc/cuitabarea.hxx cui/source/inc/cuitabline.hxx cui/source/inc/hldocntp.hxx cui/source/inc/hltpbase.hxx cui/source/inc/iconcdlg.hxx cui/source/inc/numpages.hxx cui/source/inc/page.hxx cui/source/inc/postdlg.hxx cui/source/inc/scriptdlg.hxx cui/source/inc/transfrm.hxx cui/source/inc/zoom.hxx cui/source/options/cfgchart.cxx cui/source/options/cuisrchdlg.cxx cui/source/options/dbregister.cxx cui/source/options/dbregister.src cui/source/options/fontsubs.cxx cui/source/options/internationaloptions.cxx cui/source/options/optasian.cxx cui/source/options/optchart.cxx cui/source/options/optcolor.cxx cui/source/options/optcolor.src cui/source/options/optfltr.cxx cui/source/options/optfltr.src cui/source/options/optgdlg.cxx cui/source/options/optgdlg.src cui/source/options/optgenrl.cxx cui/source/options/opthtml.cxx cui/source/options/optimprove.cxx cui/source/options/optinet2.cxx cui/source/options/optinet2.hxx cui/source/options/optjava.cxx cui/source/options/optlingu.cxx cui/source/options/optsave.cxx cui/source/options/optsave.hxx cui/source/options/treeopt.cxx cui/source/options/webconninfo.cxx cui/source/tabpages/autocdlg.cxx cui/source/tabpages/backgrnd.cxx cui/source/tabpages/border.cxx cui/source/tabpages/chardlg.cxx cui/source/tabpages/dstribut.cxx cui/source/tabpages/grfpage.cxx cui/source/tabpages/macroass.cxx cui/source/tabpages/measure.cxx cui/source/tabpages/numfmt.cxx cui/source/tabpages/numpages.cxx cui/source/tabpages/page.cxx cui/source/tabpages/paragrph.cxx cui/source/tabpages/swpossizetabpage.cxx cui/source/tabpages/tabarea.src cui/source/tabpages/textanim.cxx cui/source/tabpages/textattr.cxx cui/source/tabpages/tparea.cxx cui/source/tabpages/tpbitmap.cxx cui/source/tabpages/tpcolor.cxx cui/source/tabpages/tpgradnt.cxx cui/source/tabpages/tphatch.cxx cui/source/tabpages/tpline.cxx cui/source/tabpages/tplnedef.cxx cui/source/tabpages/tplneend.cxx cui/source/tabpages/tpshadow.cxx cui/source/tabpages/transfrm.cxx embedserv/source/embed/register.cxx extensions/inc/pch/precompiled_extensions.hxx extensions/inc/propctrlr.hrc extensions/source/abpilot/abpservices.cxx extensions/source/bibliography/bibload.cxx extensions/source/bibliography/datman.cxx extensions/source/bibliography/general.cxx extensions/source/dbpilots/dbpservices.cxx extensions/source/inc/componentmodule.cxx extensions/source/nsplugin/source/so_env.cxx extensions/source/ole/oleobjw.cxx extensions/source/ole/oleobjw.hxx extensions/source/oooimprovement/invite_job.cxx extensions/source/oooimprovement/onlogrotate_job.cxx extensions/source/plugin/base/service.cxx extensions/source/plugin/inc/plugin/unx/mediator.hxx extensions/source/plugin/inc/plugin/unx/plugcon.hxx extensions/source/plugin/unx/mediator.cxx extensions/source/plugin/unx/nppapi.cxx extensions/source/plugin/unx/plugcon.cxx extensions/source/preload/services.cxx extensions/source/propctrlr/formmetadata.cxx extensions/source/propctrlr/pcrservices.cxx extensions/source/resource/resource.cxx extensions/source/scanner/sane.hxx extensions/source/scanner/sanedlg.cxx extensions/source/scanner/scanunx.cxx extensions/source/scanner/scanwin.cxx extensions/source/scanner/twain.cxx extensions/source/scanner/twain.hxx extensions/source/update/check/updatecheckconfig.cxx extensions/test/stm/datatest.cxx extensions/test/stm/marktest.cxx extensions/test/stm/pipetest.cxx extensions/test/stm/testfactreg.cxx extensions/workben/testpgp.cxx forms/qa/complex/forms/CheckOGroupBoxModel.java forms/qa/makefile.mk forms/source/component/Button.cxx forms/source/component/Button.hxx forms/source/component/ListBox.cxx forms/source/inc/forms_module_impl.hxx forms/source/misc/services.cxx forms/source/solar/control/navtoolbar.cxx javainstaller2/prj/build.lst javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java lingucomponent/prj/build.lst lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx lingucomponent/source/spellcheck/spell/sreg.cxx lingucomponent/source/spellcheck/spell/sspellimp.cxx package/source/manifest/ManifestExport.cxx package/source/manifest/UnoRegister.cxx package/source/xstor/owriteablestream.cxx package/source/xstor/owriteablestream.hxx package/source/xstor/xstorage.hxx package/source/zippackage/ZipPackageFolder.cxx package/source/zippackage/ZipPackageStream.cxx setup_native/source/mac/ooo/DS_Store setup_native/source/win32/customactions/shellextensions/registerextensions.cxx xmlsecurity/prj/build.lst xmlsecurity/source/component/registerservices.cxx xmlsecurity/source/dialogs/stbcontrl.cxx xmlsecurity/source/framework/xsec_framework.cxx xmlsecurity/source/xmlsec/xsec_xmlsec.cxx xmlsecurity/tools/demo/util.hxx xmlsecurity/workben/signaturetest.cxx
2011-03-09 16:20:50 -06:00
sal_Bool BasicCheckBox::EditingEntry( SvLBoxEntry* pEntry, Selection& )
2001-11-07 09:18:27 +00:00
{
if ( nMode != LIBMODE_MANAGER )
return sal_False;
2001-11-07 09:18:27 +00:00
DBG_ASSERT( pEntry, "Kein Eintrag?" );
// check, if Standard library
String aLibName = GetEntryText( pEntry, 0 );
if ( aLibName.EqualsIgnoreCaseAscii( "Standard" ) )
{
ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_CANNOTCHANGENAMESTDLIB ) ) ).Execute();
return sal_False;
2001-11-07 09:18:27 +00:00
}
// check, if library is readonly
::rtl::OUString aOULibName( aLibName );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
2001-11-07 09:18:27 +00:00
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) && !xModLibContainer->isLibraryLink( aOULibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) && !xDlgLibContainer->isLibraryLink( aOULibName ) ) )
{
ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_LIBISREADONLY ) ) ).Execute();
return sal_False;
2001-11-07 09:18:27 +00:00
}
// i24094: Password verification necessary for renaming
sal_Bool bOK = sal_True;
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
{
// check password
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
{
String aPassword;
Reference< script::XLibraryContainer > xModLibContainer1( xModLibContainer, UNO_QUERY );
bOK = QueryPassword( xModLibContainer1, aLibName, aPassword );
}
if ( !bOK )
return sal_False;
}
2001-11-07 09:18:27 +00:00
// TODO: check if library is reference/link
return sal_True;
2001-11-07 09:18:27 +00:00
}
//----------------------------------------------------------------------------
Merge commit 'ooo/DEV300_m101' into integration/dev300_m101 * commit 'ooo/DEV300_m101': (185 commits) masterfix DEV300: #i10000# usage of L10N build_type masterfix: #i10000# INT16 -> sal_Int16 fixed compile errors after resync to m100, part2 gridsort: post-rebase fixes CWS gnumake3: found another tools integer type removetooltypes01: Fix build problems after rebase to DEV300m99 in basctl, cui, reportdesign, sw native359: #i114398# changing mac langpack icon native359: #i115669# fixing package description for solaris packages gnumake3: remove comphelper version; fix including extract.hxx locales34: #i106785# add Haitian_Haiti [ht-HT] to language list and locale data; locale data contributed by <jcpoulard> sb138: #i116659# timely termination of OnLogRotateThread accfixes: removed include of obsolete header file accfixes: removed obsolete file removetooltypes01: #i112600# Fix build problems on non-pro accfixes: moved some shared strings to svx part2 accfixes: moved some shared strings to svx accfixes: added more accessibility information and fixed tab orders in multiple dialogs (cui module) removetooltypes01: #i112600# Remove tools types for Mac specific parts fixed tab order in BasicIDE, Library dialog tab page added some accessible names in BasicIDE ... Conflicts: UnoControls/source/base/registercontrols.cxx accessibility/inc/accessibility/standard/vclxaccessiblelistboxlist.hxx automation/inc/automation/communi.hxx automation/inc/automation/simplecm.hxx automation/source/communi/communi.cxx automation/source/inc/rcontrol.hxx automation/source/miniapp/servuid.hxx automation/source/server/XMLParser.cxx automation/source/server/cmdbasestream.cxx automation/source/server/profiler.hxx automation/source/server/recorder.cxx automation/source/server/retstrm.hxx automation/source/server/server.cxx automation/source/server/sta_list.cxx automation/source/server/statemnt.cxx automation/source/server/statemnt.hxx automation/source/simplecm/packethandler.cxx automation/source/simplecm/simplecm.cxx automation/source/simplecm/tcpio.cxx automation/source/simplecm/tcpio.hxx automation/source/testtool/comm_bas.hxx automation/source/testtool/cretstrm.hxx automation/source/testtool/httprequest.cxx automation/source/testtool/httprequest.hxx automation/source/testtool/objtest.cxx automation/source/testtool/objtest.hxx basctl/source/basicide/baside2.cxx basctl/source/basicide/baside2.hxx basctl/source/basicide/baside2b.cxx basctl/source/basicide/baside3.cxx basctl/source/basicide/basides1.cxx basctl/source/basicide/basides2.cxx basctl/source/basicide/basidesh.cxx basctl/source/basicide/basidesh.src basctl/source/basicide/basobj3.cxx basctl/source/basicide/bastype2.cxx basctl/source/basicide/bastype3.cxx basctl/source/basicide/bastypes.cxx basctl/source/basicide/brkdlg.cxx basctl/source/basicide/iderdll.cxx basctl/source/basicide/macrodlg.cxx basctl/source/basicide/moduldl2.cxx basctl/source/basicide/moduldlg.cxx basctl/source/basicide/objdlg.cxx basctl/source/basicide/scriptdocument.cxx basctl/source/basicide/tbxctl.cxx basctl/source/basicide/tbxctl.hxx basctl/source/basicide/tbxctl.src basctl/source/dlged/dlged.cxx basctl/source/dlged/dlgedfunc.cxx basctl/source/dlged/dlgedobj.cxx basctl/source/inc/basidesh.hxx basctl/source/inc/bastypes.hxx basctl/source/inc/dlgedmod.hxx basctl/source/inc/dlgedpage.hxx crashrep/prj/build.lst cui/inc/pch/precompiled_cui.hxx cui/source/customize/acccfg.cxx cui/source/customize/acccfg.hrc cui/source/customize/acccfg.src cui/source/customize/cfg.cxx cui/source/customize/cfgutil.cxx cui/source/customize/macropg.cxx cui/source/customize/macropg.src cui/source/customize/selector.cxx cui/source/dialogs/SpellDialog.cxx cui/source/dialogs/commonlingui.cxx cui/source/dialogs/cuicharmap.cxx cui/source/dialogs/cuifmsearch.cxx cui/source/dialogs/cuigaldlg.cxx cui/source/dialogs/cuigrfflt.cxx cui/source/dialogs/hldocntp.cxx cui/source/dialogs/hldoctp.cxx cui/source/dialogs/hlinettp.cxx cui/source/dialogs/hlmailtp.cxx cui/source/dialogs/hlmarkwn.cxx cui/source/dialogs/hlmarkwn.src cui/source/dialogs/hltpbase.cxx cui/source/dialogs/iconcdlg.cxx cui/source/dialogs/passwdomdlg.cxx cui/source/dialogs/pastedlg.cxx cui/source/dialogs/scriptdlg.cxx cui/source/dialogs/thesdlg.cxx cui/source/dialogs/zoom.cxx cui/source/factory/dlgfact.hxx cui/source/inc/SpellDialog.hxx cui/source/inc/autocdlg.hxx cui/source/inc/backgrnd.hxx cui/source/inc/bbdlg.hxx cui/source/inc/cfg.hxx cui/source/inc/cfgutil.hxx cui/source/inc/cuigaldlg.hxx cui/source/inc/cuigrfflt.hxx cui/source/inc/cuitabarea.hxx cui/source/inc/cuitabline.hxx cui/source/inc/hldocntp.hxx cui/source/inc/hltpbase.hxx cui/source/inc/iconcdlg.hxx cui/source/inc/numpages.hxx cui/source/inc/page.hxx cui/source/inc/postdlg.hxx cui/source/inc/scriptdlg.hxx cui/source/inc/transfrm.hxx cui/source/inc/zoom.hxx cui/source/options/cfgchart.cxx cui/source/options/cuisrchdlg.cxx cui/source/options/dbregister.cxx cui/source/options/dbregister.src cui/source/options/fontsubs.cxx cui/source/options/internationaloptions.cxx cui/source/options/optasian.cxx cui/source/options/optchart.cxx cui/source/options/optcolor.cxx cui/source/options/optcolor.src cui/source/options/optfltr.cxx cui/source/options/optfltr.src cui/source/options/optgdlg.cxx cui/source/options/optgdlg.src cui/source/options/optgenrl.cxx cui/source/options/opthtml.cxx cui/source/options/optimprove.cxx cui/source/options/optinet2.cxx cui/source/options/optinet2.hxx cui/source/options/optjava.cxx cui/source/options/optlingu.cxx cui/source/options/optsave.cxx cui/source/options/optsave.hxx cui/source/options/treeopt.cxx cui/source/options/webconninfo.cxx cui/source/tabpages/autocdlg.cxx cui/source/tabpages/backgrnd.cxx cui/source/tabpages/border.cxx cui/source/tabpages/chardlg.cxx cui/source/tabpages/dstribut.cxx cui/source/tabpages/grfpage.cxx cui/source/tabpages/macroass.cxx cui/source/tabpages/measure.cxx cui/source/tabpages/numfmt.cxx cui/source/tabpages/numpages.cxx cui/source/tabpages/page.cxx cui/source/tabpages/paragrph.cxx cui/source/tabpages/swpossizetabpage.cxx cui/source/tabpages/tabarea.src cui/source/tabpages/textanim.cxx cui/source/tabpages/textattr.cxx cui/source/tabpages/tparea.cxx cui/source/tabpages/tpbitmap.cxx cui/source/tabpages/tpcolor.cxx cui/source/tabpages/tpgradnt.cxx cui/source/tabpages/tphatch.cxx cui/source/tabpages/tpline.cxx cui/source/tabpages/tplnedef.cxx cui/source/tabpages/tplneend.cxx cui/source/tabpages/tpshadow.cxx cui/source/tabpages/transfrm.cxx embedserv/source/embed/register.cxx extensions/inc/pch/precompiled_extensions.hxx extensions/inc/propctrlr.hrc extensions/source/abpilot/abpservices.cxx extensions/source/bibliography/bibload.cxx extensions/source/bibliography/datman.cxx extensions/source/bibliography/general.cxx extensions/source/dbpilots/dbpservices.cxx extensions/source/inc/componentmodule.cxx extensions/source/nsplugin/source/so_env.cxx extensions/source/ole/oleobjw.cxx extensions/source/ole/oleobjw.hxx extensions/source/oooimprovement/invite_job.cxx extensions/source/oooimprovement/onlogrotate_job.cxx extensions/source/plugin/base/service.cxx extensions/source/plugin/inc/plugin/unx/mediator.hxx extensions/source/plugin/inc/plugin/unx/plugcon.hxx extensions/source/plugin/unx/mediator.cxx extensions/source/plugin/unx/nppapi.cxx extensions/source/plugin/unx/plugcon.cxx extensions/source/preload/services.cxx extensions/source/propctrlr/formmetadata.cxx extensions/source/propctrlr/pcrservices.cxx extensions/source/resource/resource.cxx extensions/source/scanner/sane.hxx extensions/source/scanner/sanedlg.cxx extensions/source/scanner/scanunx.cxx extensions/source/scanner/scanwin.cxx extensions/source/scanner/twain.cxx extensions/source/scanner/twain.hxx extensions/source/update/check/updatecheckconfig.cxx extensions/test/stm/datatest.cxx extensions/test/stm/marktest.cxx extensions/test/stm/pipetest.cxx extensions/test/stm/testfactreg.cxx extensions/workben/testpgp.cxx forms/qa/complex/forms/CheckOGroupBoxModel.java forms/qa/makefile.mk forms/source/component/Button.cxx forms/source/component/Button.hxx forms/source/component/ListBox.cxx forms/source/inc/forms_module_impl.hxx forms/source/misc/services.cxx forms/source/solar/control/navtoolbar.cxx javainstaller2/prj/build.lst javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java lingucomponent/prj/build.lst lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx lingucomponent/source/spellcheck/spell/sreg.cxx lingucomponent/source/spellcheck/spell/sspellimp.cxx package/source/manifest/ManifestExport.cxx package/source/manifest/UnoRegister.cxx package/source/xstor/owriteablestream.cxx package/source/xstor/owriteablestream.hxx package/source/xstor/xstorage.hxx package/source/zippackage/ZipPackageFolder.cxx package/source/zippackage/ZipPackageStream.cxx setup_native/source/mac/ooo/DS_Store setup_native/source/win32/customactions/shellextensions/registerextensions.cxx xmlsecurity/prj/build.lst xmlsecurity/source/component/registerservices.cxx xmlsecurity/source/dialogs/stbcontrl.cxx xmlsecurity/source/framework/xsec_framework.cxx xmlsecurity/source/xmlsec/xsec_xmlsec.cxx xmlsecurity/tools/demo/util.hxx xmlsecurity/workben/signaturetest.cxx
2011-03-09 16:20:50 -06:00
sal_Bool BasicCheckBox::EditedEntry( SvLBoxEntry* pEntry, const String& rNewText )
2001-11-07 09:18:27 +00:00
{
sal_Bool bValid = ( rNewText.Len() <= 30 ) && BasicIDE::IsValidSbxName( rNewText );
2001-11-07 09:18:27 +00:00
String aCurText( GetEntryText( pEntry, 0 ) );
if ( bValid && ( aCurText != rNewText ) )
{
try
{
::rtl::OUString aOUOldName( aCurText );
::rtl::OUString aOUNewName( rNewText );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
2001-11-07 09:18:27 +00:00
if ( xModLibContainer.is() )
{
xModLibContainer->renameLibrary( aOUOldName, aOUNewName );
}
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
2001-11-07 09:18:27 +00:00
if ( xDlgLibContainer.is() )
{
xDlgLibContainer->renameLibrary( aOUOldName, aOUNewName );
}
BasicIDE::MarkDocumentModified( m_aDocument );
SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
if ( pBindings )
{
pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR );
pBindings->Update( SID_BASICIDE_LIBSELECTOR );
}
2001-11-07 09:18:27 +00:00
}
catch (const container::ElementExistException& )
2001-11-07 09:18:27 +00:00
{
ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_SBXNAMEALLREADYUSED ) ) ).Execute();
return sal_False;
2001-11-07 09:18:27 +00:00
}
catch (const container::NoSuchElementException& )
2001-11-07 09:18:27 +00:00
{
DBG_UNHANDLED_EXCEPTION();
return sal_False;
2001-11-07 09:18:27 +00:00
}
}
if ( !bValid )
{
if ( rNewText.Len() > 30 )
ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_LIBNAMETOLONG ) ) ).Execute();
else
ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_BADSBXNAME ) ) ).Execute();
}
return bValid;
}
//----------------------------------------------------------------------------
// NewObjectDialog
//----------------------------------------------------------------------------
IMPL_LINK(NewObjectDialog, OkButtonHandler, Button *, EMPTYARG)
{
if (BasicIDE::IsValidSbxName(aEdit.GetText()))
EndDialog(1);
else
{
ErrorBox(this, WB_OK | WB_DEF_OK,
String(IDEResId(RID_STR_BADSBXNAME))).Execute();
aEdit.GrabFocus();
}
return 0;
}
NewObjectDialog::NewObjectDialog(Window * pParent, sal_uInt16 nMode,
bool bCheckName)
2001-11-07 09:18:27 +00:00
: ModalDialog( pParent, IDEResId( RID_DLG_NEWLIB ) ),
aText( this, IDEResId( RID_FT_NEWLIB ) ),
aEdit( this, IDEResId( RID_ED_LIBNAME ) ),
aOKButton( this, IDEResId( RID_PB_OK ) ),
aCancelButton( this, IDEResId( RID_PB_CANCEL ) )
{
FreeResource();
aEdit.GrabFocus();
if ( nMode == NEWOBJECTMODE_LIB )
{
SetText( String( IDEResId( RID_STR_NEWLIB ) ) );
}
else if ( nMode == NEWOBJECTMODE_MOD )
{
SetText( String( IDEResId( RID_STR_NEWMOD ) ) );
}
else if ( nMode == NEWOBJECTMODE_METH )
{
SetText( String( IDEResId( RID_STR_NEWMETH ) ) );
}
2001-11-07 09:18:27 +00:00
else
{
SetText( String( IDEResId( RID_STR_NEWDLG ) ) );
}
if (bCheckName)
aOKButton.SetClickHdl(LINK(this, NewObjectDialog, OkButtonHandler));
2001-11-07 09:18:27 +00:00
}
//----------------------------------------------------------------------------
NewObjectDialog::~NewObjectDialog()
{
}
//----------------------------------------------------------------------------
// GotoLineDialog
//----------------------------------------------------------------------------
GotoLineDialog::GotoLineDialog(Window * pParent )
: ModalDialog( pParent, IDEResId( RID_DLG_GOTOLINE ) ),
aText( this, IDEResId( RID_FT_LINE ) ),
aEdit( this, IDEResId( RID_ED_LINE ) ),
aOKButton( this, IDEResId( RID_PB_OK ) ),
aCancelButton( this, IDEResId( RID_PB_CANCEL ) )
{
FreeResource();
aEdit.GrabFocus();
SetText( String( IDEResId( RID_STR_GETLINE ) ) );
aOKButton.SetClickHdl(LINK(this, GotoLineDialog, OkButtonHandler));
}
sal_Int32 GotoLineDialog::GetLineNumber()
{
return rtl::OUString( aEdit.GetText() ).toInt32();
}
IMPL_LINK(GotoLineDialog, OkButtonHandler, Button *, EMPTYARG)
{
if ( GetLineNumber() )
EndDialog(1);
else
aEdit.SetText( aEdit.GetText(), Selection(0, aEdit.GetText().Len() ));
return 0;
}
//----------------------------------------------------------------------------
// ExportDialog
//----------------------------------------------------------------------------
IMPL_LINK(ExportDialog, OkButtonHandler, Button *, EMPTYARG)
{
mbExportAsPackage = maExportAsPackageButton.IsChecked();
EndDialog(1);
return 0;
}
ExportDialog::ExportDialog( Window * pParent )
: ModalDialog( pParent, IDEResId( RID_DLG_EXPORT ) ),
maExportAsPackageButton( this, IDEResId( RB_EXPORTASPACKAGE ) ),
maExportAsBasicButton( this, IDEResId( RB_EXPORTASBASIC ) ),
maOKButton( this, IDEResId( RID_PB_OK ) ),
maCancelButton( this, IDEResId( RID_PB_CANCEL ) )
{
FreeResource();
maExportAsPackageButton.Check();
maOKButton.SetClickHdl(LINK(this, ExportDialog, OkButtonHandler));
}
//----------------------------------------------------------------------------
ExportDialog::~ExportDialog()
{
}
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
// LibPage
//----------------------------------------------------------------------------
LibPage::LibPage( Window * pParent )
:TabPage( pParent, IDEResId( RID_TP_LIBS ) )
,aBasicsText( this, IDEResId( RID_STR_BASICS ) )
,aBasicsBox( this, IDEResId( RID_LB_BASICS ) )
,aLibText( this, IDEResId( RID_STR_LIB ) )
,aLibBox( this, IDEResId( RID_TRLBOX ) )
,aEditButton( this, IDEResId( RID_PB_EDIT ) )
,aCloseButton( this, IDEResId( RID_PB_CLOSE ) )
,aPasswordButton( this, IDEResId( RID_PB_PASSWORD ) )
,aNewLibButton( this, IDEResId( RID_PB_NEWLIB ) )
,aInsertLibButton( this, IDEResId( RID_PB_APPEND ) )
,aExportButton( this, IDEResId( RID_PB_EXPORT ) )
,aDelButton( this, IDEResId( RID_PB_DELETE ) )
,m_aCurDocument( ScriptDocument::getApplicationScriptDocument() )
,m_eCurLocation( LIBRARY_LOCATION_UNKNOWN )
2001-11-07 09:18:27 +00:00
{
FreeResource();
pTabDlg = 0;
aEditButton.SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
aNewLibButton.SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
aPasswordButton.SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
aExportButton.SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
2001-11-07 09:18:27 +00:00
aInsertLibButton.SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
aDelButton.SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
aCloseButton.SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
aLibBox.SetSelectHdl( LINK( this, LibPage, TreeListHighlightHdl ) );
aBasicsBox.SetSelectHdl( LINK( this, LibPage, BasicSelectHdl ) );
aLibBox.SetMode( LIBMODE_MANAGER );
aLibBox.EnableInplaceEditing( sal_True );
aLibBox.SetStyle( WB_HSCROLL | WB_BORDER | WB_TABSTOP );
2001-11-07 09:18:27 +00:00
aCloseButton.GrabFocus();
long aTabs[] = { 2, 30, 120 };
aLibBox.SetTabs( aTabs, MAP_PIXEL );
FillListBox();
aBasicsBox.SelectEntryPos( 0 );
SetCurLib();
CheckButtons();
}
//----------------------------------------------------------------------------
LibPage::~LibPage()
2001-11-07 09:18:27 +00:00
{
sal_uInt16 nCount = aBasicsBox.GetEntryCount();
for ( sal_uInt16 i = 0; i < nCount; ++i )
2001-11-07 09:18:27 +00:00
{
BasicDocumentEntry* pEntry = (BasicDocumentEntry*)aBasicsBox.GetEntryData( i );
delete pEntry;
2001-11-07 09:18:27 +00:00
}
}
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
2001-11-07 09:18:27 +00:00
void LibPage::CheckButtons()
{
2001-11-07 09:18:27 +00:00
SvLBoxEntry* pCur = aLibBox.GetCurEntry();
if ( pCur )
{
String aLibName = aLibBox.GetEntryText( pCur, 0 );
::rtl::OUString aOULibName( aLibName );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
2001-11-07 09:18:27 +00:00
if ( m_eCurLocation == LIBRARY_LOCATION_SHARE )
{
aPasswordButton.Disable();
aNewLibButton.Disable();
aInsertLibButton.Disable();
aDelButton.Disable();
}
else if ( aLibName.EqualsIgnoreCaseAscii( "Standard" ) )
2001-11-07 09:18:27 +00:00
{
aPasswordButton.Disable();
aNewLibButton.Enable();
aInsertLibButton.Enable();
aExportButton.Disable();
2001-11-07 09:18:27 +00:00
aDelButton.Disable();
if ( !aLibBox.HasFocus() )
aCloseButton.GrabFocus();
2001-11-07 09:18:27 +00:00
}
else if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) ) )
{
aPasswordButton.Disable();
aNewLibButton.Enable();
aInsertLibButton.Enable();
2001-11-07 09:18:27 +00:00
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) && !xModLibContainer->isLibraryLink( aOULibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) && !xDlgLibContainer->isLibraryLink( aOULibName ) ) )
aDelButton.Disable();
else
aDelButton.Enable();
}
else
{
if ( xModLibContainer.is() && !xModLibContainer->hasByName( aOULibName ) )
aPasswordButton.Disable();
else
aPasswordButton.Enable();
aNewLibButton.Enable();
aInsertLibButton.Enable();
aExportButton.Enable();
2001-11-07 09:18:27 +00:00
aDelButton.Enable();
}
}
}
//----------------------------------------------------------------------------
2010-12-11 22:45:31 +01:00
void LibPage::ActivatePage()
2001-11-07 09:18:27 +00:00
{
SetCurLib();
}
//----------------------------------------------------------------------------
2010-12-11 22:45:31 +01:00
void LibPage::DeactivatePage()
2001-11-07 09:18:27 +00:00
{
}
//----------------------------------------------------------------------------
IMPL_LINK_INLINE_START( LibPage, TreeListHighlightHdl, SvTreeListBox *, pBox )
{
if ( pBox->IsSelected( pBox->GetHdlEntry() ) )
CheckButtons();
return 0;
}
IMPL_LINK_INLINE_END( LibPage, TreeListHighlightHdl, SvTreeListBox *, pBox )
//----------------------------------------------------------------------------
IMPL_LINK_INLINE_START( LibPage, BasicSelectHdl, ListBox *, pBox )
{
(void)pBox;
2001-11-07 09:18:27 +00:00
SetCurLib();
CheckButtons();
return 0;
}
IMPL_LINK_INLINE_END( LibPage, BasicSelectHdl, ListBox *, pBox )
//----------------------------------------------------------------------------
IMPL_LINK( LibPage, ButtonHdl, Button *, pButton )
{
if ( pButton == &aEditButton )
{
SfxAllItemSet aArgs( SFX_APP()->GetPool() );
SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs );
SFX_APP()->ExecuteSlot( aRequest );
SfxUsrAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( m_aCurDocument.getDocumentOrNull() ) );
2001-11-07 09:18:27 +00:00
SvLBoxEntry* pCurEntry = aLibBox.GetCurEntry();
DBG_ASSERT( pCurEntry, "Entry?!" );
String aLibName( aLibBox.GetEntryText( pCurEntry, 0 ) );
SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
2011-08-24 11:13:33 +01:00
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
2001-11-07 09:18:27 +00:00
if ( pDispatcher )
{
pDispatcher->Execute( SID_BASICIDE_LIBSELECTED,
SFX_CALLMODE_ASYNCHRON, &aDocItem, &aLibNameItem, 0L );
2001-11-07 09:18:27 +00:00
}
EndTabDialog( 1 );
return 0;
2001-11-07 09:18:27 +00:00
}
else if ( pButton == &aNewLibButton )
NewLib();
else if ( pButton == &aInsertLibButton )
InsertLib();
else if ( pButton == &aExportButton )
Export();
2001-11-07 09:18:27 +00:00
else if ( pButton == &aDelButton )
DeleteCurrent();
else if ( pButton == &aCloseButton )
{
EndTabDialog( 0 );
return 0;
2001-11-07 09:18:27 +00:00
}
else if ( pButton == &aPasswordButton )
{
SvLBoxEntry* pCurEntry = aLibBox.GetCurEntry();
String aLibName( aLibBox.GetEntryText( pCurEntry, 0 ) );
::rtl::OUString aOULibName( aLibName );
// load module library (if not loaded)
Reference< script::XLibraryContainer > xModLibContainer = m_aCurDocument.getLibraryContainer( E_SCRIPTS );
2001-11-07 09:18:27 +00:00
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
{
2011-08-24 11:13:33 +01:00
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
if ( pIDEShell )
pIDEShell->GetViewFrame()->GetWindow().EnterWait();
2001-11-07 09:18:27 +00:00
xModLibContainer->loadLibrary( aOULibName );
if ( pIDEShell )
pIDEShell->GetViewFrame()->GetWindow().LeaveWait();
2001-11-07 09:18:27 +00:00
}
// load dialog library (if not loaded)
Reference< script::XLibraryContainer > xDlgLibContainer = m_aCurDocument.getLibraryContainer( E_DIALOGS );
2001-11-07 09:18:27 +00:00
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
{
2011-08-24 11:13:33 +01:00
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
if ( pIDEShell )
pIDEShell->GetViewFrame()->GetWindow().EnterWait();
2001-11-07 09:18:27 +00:00
xDlgLibContainer->loadLibrary( aOULibName );
if ( pIDEShell )
pIDEShell->GetViewFrame()->GetWindow().LeaveWait();
2001-11-07 09:18:27 +00:00
}
// check, if library is password protected
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
{
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
if ( xPasswd.is() )
{
sal_Bool bProtected = xPasswd->isLibraryPasswordProtected( aOULibName );
2001-11-07 09:18:27 +00:00
// change password dialog
SvxPasswordDialog* pDlg = new SvxPasswordDialog( this, sal_True, !bProtected );
2001-11-07 09:18:27 +00:00
pDlg->SetCheckPasswordHdl( LINK( this, LibPage, CheckPasswordHdl ) );
if ( pDlg->Execute() == RET_OK )
{
sal_Bool bNewProtected = xPasswd->isLibraryPasswordProtected( aOULibName );
2001-11-07 09:18:27 +00:00
if ( bNewProtected != bProtected )
{
sal_uLong nPos = (sal_uLong)aLibBox.GetModel()->GetAbsPos( pCurEntry );
2001-11-07 09:18:27 +00:00
aLibBox.GetModel()->Remove( pCurEntry );
ImpInsertLibEntry( aLibName, nPos );
aLibBox.SetCurEntry( aLibBox.GetEntry( nPos ) );
}
BasicIDE::MarkDocumentModified( m_aCurDocument );
2001-11-07 09:18:27 +00:00
}
delete pDlg;
}
}
}
CheckButtons();
return 0;
}
//----------------------------------------------------------------------------
IMPL_LINK_INLINE_START( LibPage, CheckPasswordHdl, SvxPasswordDialog *, pDlg )
{
long nRet = 0;
SvLBoxEntry* pCurEntry = aLibBox.GetCurEntry();
::rtl::OUString aOULibName( aLibBox.GetEntryText( pCurEntry, 0 ) );
Reference< script::XLibraryContainerPassword > xPasswd( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
if ( xPasswd.is() )
{
try
{
::rtl::OUString aOUOldPassword( pDlg->GetOldPassword() );
::rtl::OUString aOUNewPassword( pDlg->GetNewPassword() );
xPasswd->changeLibraryPassword( aOULibName, aOUOldPassword, aOUNewPassword );
nRet = 1;
}
catch (...)
{
}
}
return nRet;
}
IMPL_LINK_INLINE_END( LibPage, CheckPasswordHdl, SvxPasswordDialog *, pDlg )
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
2000-09-29 10:02:42 +00:00
void LibPage::NewLib()
{
createLibImpl( static_cast<Window*>( this ), m_aCurDocument, &aLibBox, NULL);
2000-09-29 10:02:42 +00:00
}
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
2000-09-29 10:02:42 +00:00
void LibPage::InsertLib()
{
// file open dialog
Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
Reference < XFilePicker > xFP;
if( xMSF.is() )
{
Sequence <Any> aServiceType(1);
aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType ), UNO_QUERY );
}
xFP->setTitle( String( IDEResId( RID_STR_APPENDLIBS ) ) );
// filter
::rtl::OUString aTitle = String( IDEResId( RID_STR_BASIC ) );
::rtl::OUString aFilter;
aFilter = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.sbl;*.xlc;*.xlb" ) ); // library files
aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sdw;*.sxw;*.odt" ) ); // text
aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.vor;*.stw;*.ott" ) ); // text template
aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sgl;*.sxg;*.odm" ) ); // master document
aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.oth" ) ); // html document template
aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sdc;*.sxc;*.ods" ) ); // spreadsheet
aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.stc;*.ots" ) ); // spreadsheet template
aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sda;*.sxd;*.odg" ) ); // drawing
aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.std;*.otg" ) ); // drawing template
aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sdd;*.sxi;*.odp" ) ); // presentation
aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sti;*.otp" ) ); // presentation template
aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sxm;*.odf" ) ); // formula
Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
xFltMgr->appendFilter( aTitle, aFilter );
2000-09-29 10:02:42 +00:00
// set display directory and filter
2011-08-24 11:13:33 +01:00
String aPath( BasicIDEGlobals::GetExtraData()->GetAddLibPath() );
2000-09-29 10:02:42 +00:00
if ( aPath.Len() )
{
xFP->setDisplayDirectory( aPath );
2000-09-29 10:02:42 +00:00
}
else
{
2000-11-14 13:25:01 +00:00
// macro path from configuration management
xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() );
}
2011-08-24 11:13:33 +01:00
String aLastFilter( BasicIDEGlobals::GetExtraData()->GetAddLibFilter() );
if ( aLastFilter.Len() )
{
xFltMgr->setCurrentFilter( aLastFilter );
}
else
{
xFltMgr->setCurrentFilter( String( IDEResId( RID_STR_BASIC ) ) );
2000-09-29 10:02:42 +00:00
}
if ( xFP->execute() == RET_OK )
2000-09-29 10:02:42 +00:00
{
2011-08-24 11:13:33 +01:00
BasicIDEGlobals::GetExtraData()->SetAddLibPath( xFP->getDisplayDirectory() );
BasicIDEGlobals::GetExtraData()->SetAddLibFilter( xFltMgr->getCurrentFilter() );
2000-11-20 07:32:42 +00:00
// library containers for import
Reference< script::XLibraryContainer2 > xModLibContImport;
Reference< script::XLibraryContainer2 > xDlgLibContImport;
// file URLs
Sequence< ::rtl::OUString > aFiles = xFP->getFiles();
INetURLObject aURLObj( aFiles[0] );
INetURLObject aModURLObj( aURLObj );
INetURLObject aDlgURLObj( aURLObj );
2000-11-20 07:32:42 +00:00
String aBase = aURLObj.getBase();
String aModBase = String::CreateFromAscii( "script" );
String aDlgBase = String::CreateFromAscii( "dialog" );
if ( aBase == aModBase || aBase == aDlgBase )
{
aModURLObj.setBase( aModBase );
aDlgURLObj.setBase( aDlgBase );
}
if ( xMSF.is() )
{
Reference< XSimpleFileAccess > xSFA( xMSF->createInstance(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" ) ) ), UNO_QUERY );
if ( xSFA.is() )
{
::rtl::OUString aModURL( aModURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
if ( xSFA->exists( aModURL ) )
{
Sequence <Any> aSeqModURL(1);
aSeqModURL[0] <<= aModURL;
xModLibContImport = Reference< script::XLibraryContainer2 >( xMSF->createInstanceWithArguments(
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.DocumentScriptLibraryContainer" ) ), aSeqModURL ), UNO_QUERY );
}
::rtl::OUString aDlgURL( aDlgURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
if ( xSFA->exists( aDlgURL ) )
{
Sequence <Any> aSeqDlgURL(1);
aSeqDlgURL[0] <<= aDlgURL;
xDlgLibContImport = Reference< script::XLibraryContainer2 >( xMSF->createInstanceWithArguments(
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.DocumentDialogLibraryContainer" ) ), aSeqDlgURL ), UNO_QUERY );
}
}
}
if ( xModLibContImport.is() || xDlgLibContImport.is() )
{
LibDialog* pLibDlg = 0;
Reference< script::XLibraryContainer > xModLibContImp( xModLibContImport, UNO_QUERY );
Reference< script::XLibraryContainer > xDlgLibContImp( xDlgLibContImport, UNO_QUERY );
Sequence< ::rtl::OUString > aLibNames = BasicIDE::GetMergedLibraryNames( xModLibContImp, xDlgLibContImp );
sal_Int32 nLibCount = aLibNames.getLength();
const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
{
// library import dialog
if ( !pLibDlg )
{
pLibDlg = new LibDialog( this );
pLibDlg->SetStorageName( aURLObj.getName() );
pLibDlg->GetLibBox().SetMode( LIBMODE_CHOOSER );
}
// libbox entries
String aLibName( pLibNames[ i ] );
String aOULibName( aLibName );
if ( !( ( xModLibContImport.is() && xModLibContImport->hasByName( aOULibName ) && xModLibContImport->isLibraryLink( aOULibName ) ) ||
( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aOULibName ) && xDlgLibContImport->isLibraryLink( aOULibName ) ) ) )
{
SvLBoxEntry* pEntry = pLibDlg->GetLibBox().DoInsertEntry( aLibName );
sal_uInt16 nPos = (sal_uInt16) pLibDlg->GetLibBox().GetModel()->GetAbsPos( pEntry );
pLibDlg->GetLibBox().CheckEntryPos( nPos, sal_True);
}
}
if ( !pLibDlg )
InfoBox( this, String( IDEResId( RID_STR_NOLIBINSTORAGE ) ) ).Execute();
else
{
sal_Bool bChanges = sal_False;
String aExtension( aURLObj.getExtension() );
String aLibExtension( String::CreateFromAscii( "xlb" ) );
String aContExtension( String::CreateFromAscii( "xlc" ) );
// disable reference checkbox for documents and sbls
if ( aExtension != aLibExtension && aExtension != aContExtension )
pLibDlg->EnableReference( sal_False );
if ( pLibDlg->Execute() )
{
sal_uLong nNewPos = aLibBox.GetEntryCount();
sal_Bool bRemove = sal_False;
sal_Bool bReplace = pLibDlg->IsReplace();
sal_Bool bReference = pLibDlg->IsReference();
for ( sal_uInt16 nLib = 0; nLib < pLibDlg->GetLibBox().GetEntryCount(); nLib++ )
{
if ( pLibDlg->GetLibBox().IsChecked( nLib ) )
{
SvLBoxEntry* pEntry = pLibDlg->GetLibBox().GetEntry( nLib );
DBG_ASSERT( pEntry, "Entry?!" );
String aLibName( pLibDlg->GetLibBox().GetEntryText( pEntry, 0 ) );
::rtl::OUString aOULibName( aLibName );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
// check, if the library is already existing
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) ) )
{
if ( bReplace )
{
// check, if the library is the Standard library
if ( aLibName.EqualsAscii( "Standard" ) )
{
ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_REPLACESTDLIB ) ) ).Execute();
continue;
}
// check, if the library is readonly and not a link
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) && !xModLibContainer->isLibraryLink( aOULibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) && !xDlgLibContainer->isLibraryLink( aOULibName ) ) )
{
String aErrStr( IDEResId( RID_STR_REPLACELIB ) );
aErrStr.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "XX" ) ), aLibName );
aErrStr += '\n';
aErrStr += String( IDEResId( RID_STR_LIBISREADONLY ) );
ErrorBox( this, WB_OK | WB_DEF_OK, aErrStr ).Execute();
continue;
}
// remove existing libraries
bRemove = sal_True;
}
else
{
String aErrStr;
if ( bReference )
aErrStr = String( IDEResId( RID_STR_REFNOTPOSSIBLE ) );
else
aErrStr = String( IDEResId( RID_STR_IMPORTNOTPOSSIBLE ) );
aErrStr.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "XX" ) ), aLibName );
aErrStr += '\n';
aErrStr += String( IDEResId( RID_STR_SBXNAMEALLREADYUSED ) );
ErrorBox( this, WB_OK | WB_DEF_OK, aErrStr ).Execute();
continue;
}
}
// check, if the library is password protected
sal_Bool bOK = sal_False;
String aPassword;
if ( xModLibContImport.is() && xModLibContImport->hasByName( aOULibName ) )
{
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContImport, UNO_QUERY );
if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) && !bReference )
{
bOK = QueryPassword( xModLibContImp, aLibName, aPassword, sal_True, sal_True );
if ( !bOK )
{
String aErrStr( IDEResId( RID_STR_NOIMPORT ) );
aErrStr.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "XX" ) ), aLibName );
ErrorBox( this, WB_OK | WB_DEF_OK, aErrStr ).Execute();
continue;
}
}
}
// remove existing libraries
if ( bRemove )
{
// remove listbox entry
SvLBoxEntry* pEntry_ = aLibBox.FindEntry( aLibName );
if ( pEntry_ )
aLibBox.SvTreeListBox::GetModel()->Remove( pEntry_ );
// remove module library
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
xModLibContainer->removeLibrary( aOULibName );
// remove dialog library
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) )
xDlgLibContainer->removeLibrary( aOULibName );
}
// copy module library
if ( xModLibContImport.is() && xModLibContImport->hasByName( aOULibName ) && xModLibContainer.is() && !xModLibContainer->hasByName( aOULibName ) )
{
Reference< container::XNameContainer > xModLib;
if ( bReference )
{
// storage URL
INetURLObject aModStorageURLObj( aModURLObj );
if ( aExtension == aContExtension )
{
sal_Int32 nCount = aModStorageURLObj.getSegmentCount();
aModStorageURLObj.insertName( aLibName, false, nCount-1 );
aModStorageURLObj.setExtension( aLibExtension );
aModStorageURLObj.setFinalSlash();
}
::rtl::OUString aModStorageURL( aModStorageURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
// create library link
xModLib = Reference< container::XNameContainer >( xModLibContainer->createLibraryLink( aOULibName, aModStorageURL, sal_True ), UNO_QUERY);
}
else
{
// create library
xModLib = xModLibContainer->createLibrary( aOULibName );
if ( xModLib.is() )
{
// get import library
Reference< container::XNameContainer > xModLibImport;
Any aElement = xModLibContImport->getByName( aOULibName );
aElement >>= xModLibImport;
if ( xModLibImport.is() )
{
// load library
if ( !xModLibContImport->isLibraryLoaded( aOULibName ) )
xModLibContImport->loadLibrary( aOULibName );
// copy all modules
Sequence< ::rtl::OUString > aModNames = xModLibImport->getElementNames();
sal_Int32 nModCount = aModNames.getLength();
const ::rtl::OUString* pModNames = aModNames.getConstArray();
for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
{
::rtl::OUString aOUModName( pModNames[ i ] );
Any aElement_ = xModLibImport->getByName( aOUModName );
xModLib->insertByName( aOUModName, aElement_ );
}
// set password
if ( bOK )
{
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
if ( xPasswd.is() )
{
try
{
::rtl::OUString aOUPassword( aPassword );
xPasswd->changeLibraryPassword( aOULibName, ::rtl::OUString(), aOUPassword );
}
catch (...)
{
}
}
}
}
}
}
}
// copy dialog library
if ( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aOULibName ) && xDlgLibContainer.is() && !xDlgLibContainer->hasByName( aOULibName ) )
{
Reference< container::XNameContainer > xDlgLib;
if ( bReference )
{
// storage URL
INetURLObject aDlgStorageURLObj( aDlgURLObj );
if ( aExtension == aContExtension )
{
sal_Int32 nCount = aDlgStorageURLObj.getSegmentCount();
aDlgStorageURLObj.insertName( aLibName, false, nCount - 1 );
aDlgStorageURLObj.setExtension( aLibExtension );
aDlgStorageURLObj.setFinalSlash();
}
::rtl::OUString aDlgStorageURL( aDlgStorageURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
// create library link
xDlgLib = Reference< container::XNameContainer >( xDlgLibContainer->createLibraryLink( aOULibName, aDlgStorageURL, sal_True ), UNO_QUERY);
}
else
{
// create library
xDlgLib = xDlgLibContainer->createLibrary( aOULibName );
if ( xDlgLib.is() )
{
// get import library
Reference< container::XNameContainer > xDlgLibImport;
Any aElement = xDlgLibContImport->getByName( aOULibName );
aElement >>= xDlgLibImport;
if ( xDlgLibImport.is() )
{
// load library
if ( !xDlgLibContImport->isLibraryLoaded( aOULibName ) )
xDlgLibContImport->loadLibrary( aOULibName );
// copy all dialogs
Sequence< ::rtl::OUString > aDlgNames = xDlgLibImport->getElementNames();
sal_Int32 nDlgCount = aDlgNames.getLength();
const ::rtl::OUString* pDlgNames = aDlgNames.getConstArray();
for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
{
::rtl::OUString aOUDlgName( pDlgNames[ i ] );
Any aElement_ = xDlgLibImport->getByName( aOUDlgName );
xDlgLib->insertByName( aOUDlgName, aElement_ );
}
}
}
}
}
// insert listbox entry
ImpInsertLibEntry( aLibName, aLibBox.GetEntryCount() );
bChanges = sal_True;
}
}
SvLBoxEntry* pFirstNew = aLibBox.GetEntry( nNewPos );
if ( pFirstNew )
aLibBox.SetCurEntry( pFirstNew );
}
delete pLibDlg;
if ( bChanges )
BasicIDE::MarkDocumentModified( m_aCurDocument );
}
}
2000-09-29 10:02:42 +00:00
}
}
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
void LibPage::Export( void )
{
SvLBoxEntry* pCurEntry = aLibBox.GetCurEntry();
String aLibName( aLibBox.GetEntryText( pCurEntry, 0 ) );
// Password verification
::rtl::OUString aOULibName( aLibName );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
{
sal_Bool bOK = sal_True;
// check password
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
{
String aPassword;
Reference< script::XLibraryContainer > xModLibContainer1( xModLibContainer, UNO_QUERY );
bOK = QueryPassword( xModLibContainer1, aLibName, aPassword );
}
if ( !bOK )
return;
}
Window* pWin = static_cast<Window*>( this );
std::auto_ptr< ExportDialog > xNewDlg( new ExportDialog( pWin ) );
if ( xNewDlg->Execute() == RET_OK )
{
try
{
if( xNewDlg->isExportAsPackage() )
ExportAsPackage( aLibName );
else
ExportAsBasic( aLibName );
}
catch(const util::VetoException& ) // user cancled operation
{
}
}
}
void LibPage::implExportLib( const String& aLibName, const String& aTargetURL,
const Reference< task::XInteractionHandler >& Handler )
{
::rtl::OUString aOULibName( aLibName );
Reference< script::XLibraryContainerExport > xModLibContainerExport
( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainerExport > xDlgLibContainerExport
( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
if ( xModLibContainerExport.is() )
xModLibContainerExport->exportLibrary( aOULibName, aTargetURL, Handler );
if ( xDlgLibContainerExport.is() )
xDlgLibContainerExport->exportLibrary( aOULibName, aTargetURL, Handler );
}
//===========================================================================
// Implementation XCommandEnvironment
typedef cppu::WeakImplHelper1< XCommandEnvironment > LibCommandEnvironmentHelper;
class OLibCommandEnvironment : public LibCommandEnvironmentHelper
{
Reference< task::XInteractionHandler > mxInteraction;
public:
OLibCommandEnvironment( Reference< task::XInteractionHandler > xInteraction )
: mxInteraction( xInteraction )
{}
// Methods
virtual Reference< task::XInteractionHandler > SAL_CALL getInteractionHandler()
throw(RuntimeException);
virtual Reference< XProgressHandler > SAL_CALL getProgressHandler()
throw(RuntimeException);
};
Reference< task::XInteractionHandler > OLibCommandEnvironment::getInteractionHandler()
throw(RuntimeException)
{
return mxInteraction;
}
Reference< XProgressHandler > OLibCommandEnvironment::getProgressHandler()
throw(RuntimeException)
{
Reference< XProgressHandler > xRet;
return xRet;
}
void LibPage::ExportAsPackage( const String& aLibName )
{
// file open dialog
Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
Reference< task::XInteractionHandler > xHandler;
Reference< XSimpleFileAccess > xSFA;
Reference < XFilePicker > xFP;
if( xMSF.is() )
{
xHandler = Reference< task::XInteractionHandler >( xMSF->createInstance
( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ), UNO_QUERY );
xSFA = Reference< XSimpleFileAccess > ( xMSF->createInstance(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" ) ) ), UNO_QUERY );
if( !xSFA.is() )
{
2011-03-01 17:55:09 +01:00
OSL_FAIL( "No simpleFileAccess" );
return;
}
Sequence <Any> aServiceType(1);
aServiceType[0] <<= TemplateDescription::FILESAVE_SIMPLE;
xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType ), UNO_QUERY );
}
xFP->setTitle( String( IDEResId( RID_STR_EXPORTPACKAGE ) ) );
// filter
::rtl::OUString aTitle = String( IDEResId( RID_STR_PACKAGE_BUNDLE ) );
::rtl::OUString aFilter;
aFilter = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.oxt" ) ); // library files
Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
xFltMgr->appendFilter( aTitle, aFilter );
// set display directory and filter
2011-08-24 11:13:33 +01:00
String aPath( BasicIDEGlobals::GetExtraData()->GetAddLibPath() );
if ( aPath.Len() )
{
xFP->setDisplayDirectory( aPath );
}
else
{
// macro path from configuration management
xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() );
}
xFltMgr->setCurrentFilter( aTitle );
if ( xFP->execute() == RET_OK )
{
2011-08-24 11:13:33 +01:00
BasicIDEGlobals::GetExtraData()->SetAddLibPath( xFP->getDisplayDirectory() );
Sequence< ::rtl::OUString > aFiles = xFP->getFiles();
INetURLObject aURL( aFiles[0] );
if( !aURL.getExtension().getLength() )
aURL.setExtension( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "oxt" ) ) );
::rtl::OUString aPackageURL( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
String aTmpPath = SvtPathOptions().GetTempPath();
INetURLObject aInetObj( aTmpPath );
aInetObj.insertName( aLibName, sal_True, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
OUString aSourcePath = aInetObj.GetMainURL( INetURLObject::NO_DECODE );
if( xSFA->exists( aSourcePath ) )
xSFA->kill( aSourcePath );
Reference< task::XInteractionHandler > xDummyHandler( new DummyInteractionHandler( xHandler ) );
implExportLib( aLibName, aTmpPath, xDummyHandler );
Reference< XCommandEnvironment > xCmdEnv =
static_cast<XCommandEnvironment*>( new OLibCommandEnvironment( xHandler ) );
::ucbhelper::Content sourceContent( aSourcePath, xCmdEnv );
::rtl::OUStringBuffer buf;
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.zip://") );
buf.append( ::rtl::Uri::encode( aPackageURL,
rtl_UriCharClassRegName,
rtl_UriEncodeIgnoreEscapes,
RTL_TEXTENCODING_UTF8 ) );
buf.append( static_cast<sal_Unicode>('/') );
OUString destFolder( buf.makeStringAndClear() );
if( xSFA->exists( aPackageURL ) )
xSFA->kill( aPackageURL );
::ucbhelper::Content destFolderContent( destFolder, xCmdEnv );
destFolderContent.transferContent(
sourceContent, ::ucbhelper::InsertOperation_COPY,
OUString(), NameClash::OVERWRITE );
INetURLObject aMetaInfInetObj( aTmpPath );
aMetaInfInetObj.insertName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) ),
sal_True, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
OUString aMetaInfFolder = aMetaInfInetObj.GetMainURL( INetURLObject::NO_DECODE );
if( xSFA->exists( aMetaInfFolder ) )
xSFA->kill( aMetaInfFolder );
xSFA->createFolder( aMetaInfFolder );
::std::vector< Sequence<beans::PropertyValue> > manifest;
const OUString strMediaType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) );
const OUString strFullPath = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FullPath" ) );
const OUString strBasicMediaType = ::rtl::OUString
( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.star.basic-library" ) );
Sequence<beans::PropertyValue> attribs( 2 );
beans::PropertyValue * pattribs = attribs.getArray();
pattribs[ 0 ].Name = strFullPath;
OUString fullPath = aLibName;
fullPath += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/") );
pattribs[ 0 ].Value <<= fullPath;
pattribs[ 1 ].Name = strMediaType;
pattribs[ 1 ].Value <<= strBasicMediaType;
manifest.push_back( attribs );
// write into pipe:
Reference<packages::manifest::XManifestWriter> xManifestWriter( xMSF->createInstance
( DEFINE_CONST_UNICODE("com.sun.star.packages.manifest.ManifestWriter") ), UNO_QUERY );
Reference<io::XOutputStream> xPipe( xMSF->createInstance
( DEFINE_CONST_UNICODE("com.sun.star.io.Pipe") ), UNO_QUERY );
xManifestWriter->writeManifestSequence(
xPipe, Sequence< Sequence<beans::PropertyValue> >(
&manifest[ 0 ], manifest.size() ) );
aMetaInfInetObj.insertName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "manifest.xml" ) ),
sal_True, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
// write buffered pipe data to content:
::ucbhelper::Content manifestContent( aMetaInfInetObj.GetMainURL( INetURLObject::NO_DECODE ), xCmdEnv );
manifestContent.writeStream( Reference<io::XInputStream>( xPipe, UNO_QUERY_THROW ), true );
::ucbhelper::Content MetaInfContent( aMetaInfFolder, xCmdEnv );
destFolderContent.transferContent(
MetaInfContent, ::ucbhelper::InsertOperation_COPY,
OUString(), NameClash::OVERWRITE );
if( xSFA->exists( aSourcePath ) )
xSFA->kill( aSourcePath );
if( xSFA->exists( aMetaInfFolder ) )
xSFA->kill( aMetaInfFolder );
}
}
void LibPage::ExportAsBasic( const String& aLibName )
{
// Folder picker
Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
Reference< XFolderPicker > xFolderPicker;
Reference< task::XInteractionHandler > xHandler;
if( xMSF.is() )
{
xFolderPicker = Reference< XFolderPicker >( xMSF->createInstance(
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FolderPicker" ) ) ), UNO_QUERY );
xHandler = Reference< task::XInteractionHandler >( xMSF->createInstance
( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ), UNO_QUERY );
}
if( xFolderPicker.is() )
{
xFolderPicker->setTitle( String( IDEResId( RID_STR_EXPORTBASIC ) ) );
// set display directory and filter
2011-08-24 11:13:33 +01:00
String aPath( BasicIDEGlobals::GetExtraData()->GetAddLibPath() );
if( !aPath.Len() )
aPath = SvtPathOptions().GetWorkPath();
// INetURLObject aURL(m_sSavePath, INET_PROT_FILE);
xFolderPicker->setDisplayDirectory( aPath );
short nRet = xFolderPicker->execute();
if( nRet == RET_OK )
{
String aTargetURL = xFolderPicker->getDirectory();
2011-08-24 11:13:33 +01:00
BasicIDEGlobals::GetExtraData()->SetAddLibPath( aTargetURL );
Reference< task::XInteractionHandler > xDummyHandler( new DummyInteractionHandler( xHandler ) );
implExportLib( aLibName, aTargetURL, xDummyHandler );
}
}
}
//----------------------------------------------------------------------------
2000-09-29 10:02:42 +00:00
void LibPage::DeleteCurrent()
{
SvLBoxEntry* pCurEntry = aLibBox.GetCurEntry();
String aLibName( aLibBox.GetEntryText( pCurEntry, 0 ) );
// check, if library is link
sal_Bool bIsLibraryLink = sal_False;
::rtl::OUString aOULibName( aLibName );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryLink( aOULibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryLink( aOULibName ) ) )
{
bIsLibraryLink = sal_True;
}
if ( QueryDelLib( aLibName, bIsLibraryLink, this ) )
2000-09-29 10:02:42 +00:00
{
// inform BasicIDE
SfxUsrAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( m_aCurDocument.getDocumentOrNull() ) );
SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
2011-08-24 11:13:33 +01:00
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
2001-09-06 08:21:02 +00:00
SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
2000-09-29 10:02:42 +00:00
if( pDispatcher )
{
pDispatcher->Execute( SID_BASICIDE_LIBREMOVED,
SFX_CALLMODE_SYNCHRON, &aDocItem, &aLibNameItem, 0L );
2000-09-29 10:02:42 +00:00
}
// remove library from module and dialog library containers
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
xModLibContainer->removeLibrary( aOULibName );
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) )
xDlgLibContainer->removeLibrary( aOULibName );
2000-09-29 10:02:42 +00:00
((SvLBox&)aLibBox).GetModel()->Remove( pCurEntry );
BasicIDE::MarkDocumentModified( m_aCurDocument );
2000-09-29 10:02:42 +00:00
}
}
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
2000-09-29 10:02:42 +00:00
void LibPage::EndTabDialog( sal_uInt16 nRet )
2000-09-29 10:02:42 +00:00
{
DBG_ASSERT( pTabDlg, "TabDlg nicht gesetzt!" );
if ( pTabDlg )
pTabDlg->EndDialog( nRet );
}
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
2000-09-29 10:02:42 +00:00
void LibPage::FillListBox()
{
InsertListBoxEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER );
InsertListBoxEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_SHARE );
ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::DocumentsSorted ) );
for ( ScriptDocuments::const_iterator doc = aDocuments.begin();
doc != aDocuments.end();
++doc
)
{
InsertListBoxEntry( *doc, LIBRARY_LOCATION_DOCUMENT );
2001-11-07 09:18:27 +00:00
}
2000-09-29 10:02:42 +00:00
}
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
2000-09-29 10:02:42 +00:00
void LibPage::InsertListBoxEntry( const ScriptDocument& rDocument, LibraryLocation eLocation )
2000-09-29 10:02:42 +00:00
{
String aEntryText( rDocument.getTitle( eLocation ) );
sal_uInt16 nPos = aBasicsBox.InsertEntry( aEntryText, LISTBOX_APPEND );
aBasicsBox.SetEntryData( nPos, new BasicDocumentEntry( rDocument, eLocation ) );
2000-09-29 10:02:42 +00:00
}
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
2000-09-29 10:02:42 +00:00
void LibPage::SetCurLib()
2000-09-29 10:02:42 +00:00
{
sal_uInt16 nSelPos = aBasicsBox.GetSelectEntryPos();
BasicDocumentEntry* pEntry = (BasicDocumentEntry*)aBasicsBox.GetEntryData( nSelPos );
if ( pEntry )
2000-09-29 10:02:42 +00:00
{
ScriptDocument aDocument( pEntry->GetDocument() );
DBG_ASSERT( aDocument.isAlive(), "LibPage::SetCurLib: no document, or document is dead!" );
if ( !aDocument.isAlive() )
return;
LibraryLocation eLocation = pEntry->GetLocation();
if ( aDocument != m_aCurDocument || eLocation != m_eCurLocation )
2001-11-07 09:18:27 +00:00
{
m_aCurDocument = aDocument;
m_eCurLocation = eLocation;
aLibBox.SetDocument( aDocument );
aLibBox.Clear();
2000-09-29 10:02:42 +00:00
// get a sorted list of library names
Sequence< ::rtl::OUString > aLibNames = aDocument.getLibraryNames();
sal_Int32 nLibCount = aLibNames.getLength();
const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
{
String aLibName( pLibNames[ i ] );
if ( eLocation == aDocument.getLibraryLocation( aLibName ) )
ImpInsertLibEntry( aLibName, i );
2001-11-07 09:18:27 +00:00
}
SvLBoxEntry* pEntry_ = aLibBox.FindEntry( String::CreateFromAscii( "Standard" ) );
if ( !pEntry_ )
pEntry_ = aLibBox.GetEntry( 0 );
aLibBox.SetCurEntry( pEntry_ );
2001-11-07 09:18:27 +00:00
}
2000-09-29 10:02:42 +00:00
}
}
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
2000-09-29 10:02:42 +00:00
SvLBoxEntry* LibPage::ImpInsertLibEntry( const String& rLibName, sal_uLong nPos )
2000-09-29 10:02:42 +00:00
{
2001-11-07 09:18:27 +00:00
// check, if library is password protected
sal_Bool bProtected = sal_False;
2001-11-07 09:18:27 +00:00
::rtl::OUString aOULibName( rLibName );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
2001-11-07 09:18:27 +00:00
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
2000-09-29 10:02:42 +00:00
{
2001-11-07 09:18:27 +00:00
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
if ( xPasswd.is() )
{
bProtected = xPasswd->isLibraryPasswordProtected( aOULibName );
}
2000-09-29 10:02:42 +00:00
}
SvLBoxEntry* pNewEntry = aLibBox.DoInsertEntry( rLibName, nPos );
pNewEntry->SetUserData( new BasicLibUserData( m_aCurDocument ) );
if (bProtected)
{
Image aImage(IDEResId(RID_IMG_LOCKED));
aLibBox.SetExpandedEntryBmp(pNewEntry, aImage);
aLibBox.SetCollapsedEntryBmp(pNewEntry, aImage);
}
2001-11-07 09:18:27 +00:00
// check, if library is link
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryLink( aOULibName ) )
2000-09-29 10:02:42 +00:00
{
2001-11-07 09:18:27 +00:00
String aLinkURL = xModLibContainer->getLibraryLinkURL( aOULibName );
aLibBox.SetEntryText( aLinkURL, pNewEntry, 1 );
2000-09-29 10:02:42 +00:00
}
2001-11-07 09:18:27 +00:00
return pNewEntry;
2000-09-29 10:02:42 +00:00
}
2001-11-07 09:18:27 +00:00
//----------------------------------------------------------------------------
// Helper function
void createLibImpl( Window* pWin, const ScriptDocument& rDocument,
BasicCheckBox* pLibBox, BasicTreeListBox* pBasicBox )
{
OSL_ENSURE( rDocument.isAlive(), "createLibImpl: invalid document!" );
if ( !rDocument.isAlive() )
return;
// create library name
String aLibName;
String aLibStdName( String( RTL_CONSTASCII_USTRINGPARAM( "Library" ) ) );
//String aLibStdName( IDEResId( RID_STR_STDLIBNAME ) );
sal_Bool bValid = sal_False;
sal_uInt16 i = 1;
while ( !bValid )
{
aLibName = aLibStdName;
aLibName += String::CreateFromInt32( i );
if ( !rDocument.hasLibrary( E_SCRIPTS, aLibName ) && !rDocument.hasLibrary( E_DIALOGS, aLibName ) )
bValid = sal_True;
i++;
}
std::auto_ptr< NewObjectDialog > xNewDlg( new NewObjectDialog( pWin, NEWOBJECTMODE_LIB ) );
xNewDlg->SetObjectName( aLibName );
if ( xNewDlg->Execute() )
{
if ( xNewDlg->GetObjectName().Len() )
aLibName = xNewDlg->GetObjectName();
if ( aLibName.Len() > 30 )
{
ErrorBox( pWin, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_LIBNAMETOLONG ) ) ).Execute();
}
else if ( !BasicIDE::IsValidSbxName( aLibName ) )
{
ErrorBox( pWin, WB_OK | WB_DEF_OK,
String( IDEResId( RID_STR_BADSBXNAME ) ) ).Execute();
}
else if ( rDocument.hasLibrary( E_SCRIPTS, aLibName ) || rDocument.hasLibrary( E_DIALOGS, aLibName ) )
{
ErrorBox( pWin, WB_OK | WB_DEF_OK,
String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute();
}
else
{
try
{
// create module and dialog library
Reference< container::XNameContainer > xModLib( rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName ) );
Reference< container::XNameContainer > xDlgLib( rDocument.getOrCreateLibrary( E_DIALOGS, aLibName ) );
if( pLibBox )
{
SvLBoxEntry* pEntry = pLibBox->DoInsertEntry( aLibName );
pEntry->SetUserData( new BasicLibUserData( rDocument ) );
pLibBox->SetCurEntry( pEntry );
}
// create a module
String aModName = rDocument.createObjectName( E_SCRIPTS, aLibName );
::rtl::OUString sModuleCode;
if ( !rDocument.createModule( aLibName, aModName, sal_True, sModuleCode ) )
throw Exception();
SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, BASICIDE_TYPE_MODULE );
2011-08-24 11:13:33 +01:00
BasicIDEShell* pIDEShell = BasicIDEGlobals::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 );
}
if( pBasicBox )
{
SvLBoxEntry* pEntry = pBasicBox->GetCurEntry();
SvLBoxEntry* pRootEntry = NULL;
while( pEntry )
{
pRootEntry = pEntry;
pEntry = pBasicBox->GetParent( pEntry );
}
sal_uInt16 nMode = pBasicBox->GetMode();
bool bDlgMode = ( nMode & BROWSEMODE_DIALOGS ) && !( nMode & BROWSEMODE_MODULES );
sal_uInt16 nId = bDlgMode ? RID_IMG_DLGLIB : RID_IMG_MODLIB;
SvLBoxEntry* pNewLibEntry = pBasicBox->AddEntry(
aLibName,
Image( IDEResId( nId ) ),
pRootEntry, false,
std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_LIBRARY ) ) );
DBG_ASSERT( pNewLibEntry, "InsertEntry fehlgeschlagen!" );
if( pNewLibEntry )
{
SvLBoxEntry* pEntry_ = pBasicBox->AddEntry(
aModName,
Image( IDEResId( RID_IMG_MODULE ) ),
pNewLibEntry, false,
std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
DBG_ASSERT( pEntry_, "InsertEntry fehlgeschlagen!" );
pBasicBox->SetCurEntry( pEntry_ );
pBasicBox->Select( pBasicBox->GetCurEntry() ); // OV-Bug?!
}
}
}
catch (const uno::Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
}
}
}
//----------------------------------------------------------------------------
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */