2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-29 10:02:42 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 09:37:05 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:37:05 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:37:05 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:37:05 +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
|
|
|
*
|
2008-04-11 09:37:05 +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
|
|
|
*
|
2008-04-11 09:37:05 +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
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 23:25:55 +00:00
|
|
|
|
2007-10-09 14:21:50 +00:00
|
|
|
#include "docsignature.hxx"
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
#define SI_NOCONTROL
|
|
|
|
#define SI_NOSBXCONTROLS
|
|
|
|
|
|
|
|
#include <ide_pch.hxx>
|
2005-04-13 08:50:08 +00:00
|
|
|
#include <basic/sbx.hxx>
|
2009-05-19 11:32:44 +00:00
|
|
|
#include "basicrenderable.hxx"
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2008-04-04 13:04:52 +00:00
|
|
|
#include <com/sun/star/frame/XTitle.hpp>
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
#include <vcl/sound.hxx>
|
|
|
|
#include <basidesh.hxx>
|
2004-11-17 09:26:41 +00:00
|
|
|
#include <basidesh.hrc>
|
2000-09-29 10:02:42 +00:00
|
|
|
#include <baside2.hxx>
|
|
|
|
#include <basdoc.hxx>
|
|
|
|
#include <basobj.hxx>
|
|
|
|
#include <svtools/texteng.hxx>
|
|
|
|
#include <svtools/textview.hxx>
|
|
|
|
#include <svtools/xtextedt.hxx>
|
2007-03-15 14:53:39 +00:00
|
|
|
#include <tools/diagnose_ex.h>
|
2000-09-29 10:02:42 +00:00
|
|
|
#include <sfx2/sfxdefs.hxx>
|
2007-11-21 15:37:21 +00:00
|
|
|
#include <sfx2/signaturestate.hxx>
|
2010-03-02 12:39:31 +00:00
|
|
|
#include <com/sun/star/container/XNameContainer.hpp>
|
|
|
|
#include <com/sun/star/container/XNamed.hpp>
|
|
|
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2001-06-28 14:26:41 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
2008-04-04 13:04:52 +00:00
|
|
|
namespace css = ::com::sun::star;
|
2001-06-28 14:26:41 +00:00
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
IMPL_LINK_INLINE_START( BasicIDEShell, ObjectDialogCancelHdl, ObjectCatalog *, EMPTYARG )
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
ShowObjectDialog( sal_False, sal_True );
|
2000-09-29 10:02:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
IMPL_LINK_INLINE_END( BasicIDEShell, ObjectDialogCancelHdl, ObjectCatalog *, EMPTYARG )
|
|
|
|
|
2009-05-19 11:32:44 +00:00
|
|
|
Reference< view::XRenderable > BasicIDEShell::GetRenderable()
|
|
|
|
{
|
|
|
|
return Reference< view::XRenderable >( new basicide::BasicRenderable( pCurWin ) );
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool BasicIDEShell::HasSelection( sal_Bool /* bText */ ) const
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bSel = sal_False;
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( pCurWin && pCurWin->ISA( ModulWindow ) )
|
|
|
|
{
|
|
|
|
TextView* pEditView = ((ModulWindow*)pCurWin)->GetEditView();
|
|
|
|
if ( pEditView && pEditView->HasSelection() )
|
2011-01-14 11:16:25 +01:00
|
|
|
bSel = sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
return bSel;
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
String BasicIDEShell::GetSelectionText( sal_Bool bWholeWord )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
String aText;
|
|
|
|
if ( pCurWin && pCurWin->ISA( ModulWindow ) )
|
|
|
|
{
|
|
|
|
TextView* pEditView = ((ModulWindow*)pCurWin)->GetEditView();
|
|
|
|
if ( pEditView )
|
|
|
|
{
|
|
|
|
if ( bWholeWord && !pEditView->HasSelection() )
|
|
|
|
{
|
|
|
|
aText = pEditView->GetTextEngine()->GetWord( pEditView->GetSelection().GetEnd() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TextSelection aSel = pEditView->GetSelection();
|
|
|
|
if ( !bWholeWord || ( aSel.GetStart().GetPara() == aSel.GetEnd().GetPara() ) )
|
|
|
|
aText = pEditView->GetSelected();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aText;
|
|
|
|
}
|
|
|
|
|
2011-03-09 16:20:50 -06:00
|
|
|
SfxPrinter* BasicIDEShell::GetPrinter( sal_Bool bCreate )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( pCurWin ) // && pCurWin->ISA( ModulWindow ) )
|
|
|
|
{
|
|
|
|
BasicDocShell* pDocShell = (BasicDocShell*)GetViewFrame()->GetObjectShell();
|
|
|
|
DBG_ASSERT( pDocShell, "DocShell ?!" );
|
|
|
|
return pDocShell->GetPrinter( bCreate );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-03-09 16:20:50 -06:00
|
|
|
sal_uInt16 BasicIDEShell::SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags, bool )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2007-01-16 15:29:35 +00:00
|
|
|
(void)nDiffFlags;
|
2000-09-29 10:02:42 +00:00
|
|
|
BasicDocShell* pDocShell = (BasicDocShell*)GetViewFrame()->GetObjectShell();
|
|
|
|
DBG_ASSERT( pDocShell, "DocShell ?!" );
|
|
|
|
pDocShell->SetPrinter( pNewPrinter );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BasicIDEShell::SetMDITitle()
|
|
|
|
{
|
2004-11-17 09:26:41 +00:00
|
|
|
String aTitle;
|
2004-07-23 11:02:25 +00:00
|
|
|
|
2004-11-17 09:26:41 +00:00
|
|
|
if ( m_aCurLibName.Len() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2007-03-15 14:53:39 +00:00
|
|
|
LibraryLocation eLocation = m_aCurDocument.getLibraryLocation( m_aCurLibName );
|
|
|
|
aTitle = m_aCurDocument.getTitle( eLocation );
|
2004-07-23 11:02:25 +00:00
|
|
|
aTitle += '.';
|
|
|
|
aTitle += m_aCurLibName;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
2004-11-17 09:26:41 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
aTitle = String( IDEResId( RID_STR_ALL ) );
|
|
|
|
}
|
2004-07-23 11:02:25 +00:00
|
|
|
|
2007-10-09 14:21:50 +00:00
|
|
|
::basctl::DocumentSignature aCurSignature( m_aCurDocument );
|
|
|
|
if ( aCurSignature.getScriptingSignatureState() == SIGNATURESTATE_SIGNATURES_OK )
|
2005-03-10 16:59:06 +00:00
|
|
|
{
|
|
|
|
aTitle += String::CreateFromAscii( " " );
|
|
|
|
aTitle += String( IDEResId( RID_STR_SIGNED ) );
|
|
|
|
aTitle += String::CreateFromAscii( " " );
|
|
|
|
}
|
|
|
|
|
2004-11-17 09:26:41 +00:00
|
|
|
SfxViewFrame* pViewFrame = GetViewFrame();
|
|
|
|
if ( pViewFrame )
|
|
|
|
{
|
|
|
|
SfxObjectShell* pShell = pViewFrame->GetObjectShell();
|
2005-02-24 15:58:42 +00:00
|
|
|
if ( pShell && aTitle != pShell->GetTitle( SFX_TITLE_CAPTION ) )
|
2004-11-17 09:26:41 +00:00
|
|
|
{
|
|
|
|
pShell->SetTitle( aTitle );
|
2011-01-14 11:16:25 +01:00
|
|
|
pShell->SetModified( sal_False );
|
2004-11-17 09:26:41 +00:00
|
|
|
}
|
2008-04-04 13:04:52 +00:00
|
|
|
|
|
|
|
css::uno::Reference< css::frame::XController > xController = GetController ();
|
|
|
|
css::uno::Reference< css::frame::XTitle > xTitle (xController, css::uno::UNO_QUERY);
|
|
|
|
if (xTitle.is ())
|
|
|
|
xTitle->setTitle (aTitle);
|
2004-11-17 09:26:41 +00:00
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BasicIDEShell::DestroyModulWindowLayout()
|
|
|
|
{
|
|
|
|
delete pModulLayout;
|
|
|
|
pModulLayout = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-23 09:11:40 +00:00
|
|
|
void BasicIDEShell::UpdateModulWindowLayout( bool bBasicStopped )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( pModulLayout )
|
|
|
|
{
|
|
|
|
pModulLayout->GetStackWindow().UpdateCalls();
|
2004-07-23 09:11:40 +00:00
|
|
|
pModulLayout->GetWatchWindow().UpdateWatches( bBasicStopped );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BasicIDEShell::CreateModulWindowLayout()
|
|
|
|
{
|
|
|
|
pModulLayout = new ModulWindowLayout( &GetViewFrame()->GetWindow() );
|
|
|
|
}
|
|
|
|
|
2007-03-15 14:53:39 +00:00
|
|
|
ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const String& rLibName, const String& rModName )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
bCreatingWindow = sal_True;
|
2001-06-28 14:26:41 +00:00
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uLong nKey = 0;
|
2000-09-29 10:02:42 +00:00
|
|
|
ModulWindow* pWin = 0;
|
|
|
|
|
2004-07-23 11:02:25 +00:00
|
|
|
String aLibName( rLibName );
|
|
|
|
String aModName( rModName );
|
|
|
|
|
|
|
|
if ( !aLibName.Len() )
|
|
|
|
aLibName = String::CreateFromAscii( "Standard" );
|
|
|
|
|
2010-03-02 12:39:31 +00:00
|
|
|
uno::Reference< container::XNameContainer > xLib = rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
|
2004-07-23 11:02:25 +00:00
|
|
|
|
|
|
|
if ( !aModName.Len() )
|
2007-03-15 14:53:39 +00:00
|
|
|
aModName = rDocument.createObjectName( E_SCRIPTS, aLibName );
|
2004-07-23 11:02:25 +00:00
|
|
|
|
2011-08-22 11:39:37 +02:00
|
|
|
// maybe there's an suspended one?
|
2011-01-14 11:16:25 +01:00
|
|
|
pWin = FindBasWin( rDocument, aLibName, aModName, sal_False, sal_True );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
if ( !pWin )
|
|
|
|
{
|
2007-03-15 14:53:39 +00:00
|
|
|
::rtl::OUString aModule;
|
|
|
|
bool bSuccess = false;
|
|
|
|
if ( rDocument.hasModule( aLibName, aModName ) )
|
|
|
|
bSuccess = rDocument.getModule( aLibName, aModName, aModule );
|
|
|
|
else
|
2011-01-14 11:16:25 +01:00
|
|
|
bSuccess = rDocument.createModule( aLibName, aModName, sal_True, aModule );
|
2007-03-15 14:53:39 +00:00
|
|
|
|
|
|
|
if ( bSuccess )
|
2001-06-28 14:26:41 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
pWin = FindBasWin( rDocument, aLibName, aModName, sal_False, sal_True );
|
2010-03-02 12:39:31 +00:00
|
|
|
if( !pWin )
|
2010-05-05 11:41:41 +01:00
|
|
|
{
|
|
|
|
// new module window
|
|
|
|
pWin = new ModulWindow( pModulLayout, rDocument, aLibName, aModName, aModule );
|
|
|
|
nKey = InsertWindowInTable( pWin );
|
|
|
|
}
|
|
|
|
else // we've gotten called recursively ( via listener from createModule above ), get outta here
|
|
|
|
return pWin;
|
2004-07-23 11:02:25 +00:00
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pWin->SetStatus( pWin->GetStatus() & ~BASWIN_SUSPENDED );
|
|
|
|
IDEBaseWindow* pTmp = aIDEWindowTable.First();
|
|
|
|
while ( pTmp && !nKey )
|
|
|
|
{
|
|
|
|
if ( pTmp == pWin )
|
|
|
|
nKey = aIDEWindowTable.GetCurKey();
|
|
|
|
pTmp = aIDEWindowTable.Next();
|
|
|
|
}
|
|
|
|
DBG_ASSERT( nKey, "CreateBasWin: Kein Key- Fenster nicht gefunden!" );
|
|
|
|
}
|
2010-03-03 16:12:54 +00:00
|
|
|
if( nKey && xLib.is() && rDocument.isInVBAMode() )
|
2010-03-02 12:39:31 +00:00
|
|
|
{
|
2010-03-03 16:12:54 +00:00
|
|
|
// display a nice friendly name in the ObjectModule tab,
|
|
|
|
// combining the objectname and module name, e.g. Sheet1 ( Financials )
|
2011-11-22 00:20:15 -05:00
|
|
|
::rtl::OUString sObjName;
|
2010-04-20 10:31:03 +01:00
|
|
|
ModuleInfoHelper::getObjectName( xLib, rModName, sObjName );
|
2011-11-22 00:20:15 -05:00
|
|
|
if( !sObjName.isEmpty() )
|
2010-03-02 12:39:31 +00:00
|
|
|
{
|
2010-03-03 16:12:54 +00:00
|
|
|
aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")");
|
2010-03-02 12:39:31 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-14 11:16:25 +01:00
|
|
|
pTabBar->InsertPage( (sal_uInt16)nKey, aModName );
|
2001-06-20 08:27:37 +00:00
|
|
|
pTabBar->Sort();
|
2000-09-29 10:02:42 +00:00
|
|
|
pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar );
|
|
|
|
if ( !pCurWin )
|
2011-01-14 11:16:25 +01:00
|
|
|
SetCurWindow( pWin, sal_False, sal_False );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
bCreatingWindow = sal_False;
|
2000-09-29 10:02:42 +00:00
|
|
|
return pWin;
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
ModulWindow* BasicIDEShell::FindBasWin( const ScriptDocument& rDocument, const String& rLibName, const String& rModName, sal_Bool bCreateIfNotExist, sal_Bool bFindSuspended )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
ModulWindow* pModWin = 0;
|
|
|
|
IDEBaseWindow* pWin = aIDEWindowTable.First();
|
|
|
|
while ( pWin && !pModWin )
|
|
|
|
{
|
|
|
|
if ( ( !pWin->IsSuspended() || bFindSuspended ) && pWin->IsA( TYPE( ModulWindow ) ) )
|
|
|
|
{
|
2011-08-22 11:39:37 +02:00
|
|
|
if ( !rLibName.Len() )
|
2000-09-29 10:02:42 +00:00
|
|
|
pModWin = (ModulWindow*)pWin;
|
2007-03-15 14:53:39 +00:00
|
|
|
else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rModName )
|
2000-09-29 10:02:42 +00:00
|
|
|
pModWin = (ModulWindow*)pWin;
|
|
|
|
}
|
|
|
|
pWin = aIDEWindowTable.Next();
|
|
|
|
}
|
|
|
|
if ( !pModWin && bCreateIfNotExist )
|
2007-03-15 14:53:39 +00:00
|
|
|
pModWin = CreateBasWin( rDocument, rLibName, rModName );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
return pModWin;
|
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void BasicIDEShell::Move()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( pCurWin && pCurWin->ISA( ModulWindow ) )
|
|
|
|
((ModulWindow*)pCurWin)->FrameWindowMoved();
|
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void BasicIDEShell::ShowCursor( bool bOn )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( pCurWin && pCurWin->ISA( ModulWindow ) )
|
2010-10-05 07:57:51 -05:00
|
|
|
((ModulWindow*)pCurWin)->ShowCursor( bOn );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2002-10-30 08:27:01 +00:00
|
|
|
// Hack for #101048
|
|
|
|
sal_Int32 getBasicIDEShellCount( void );
|
|
|
|
|
2011-08-22 11:39:37 +02:00
|
|
|
// only if basic window above:
|
2010-12-11 22:45:31 +01:00
|
|
|
void BasicIDEShell::ExecuteBasic( SfxRequest& rReq )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( !pCurWin || !pCurWin->IsA( TYPE( ModulWindow ) ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
pCurWin->ExecuteCommand( rReq );
|
2002-10-30 08:27:01 +00:00
|
|
|
sal_Int32 nCount = getBasicIDEShellCount();
|
|
|
|
if( nCount )
|
|
|
|
CheckWindows();
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|