2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-12 17:02:47 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2011-11-17 00:42:15 -05:00
|
|
|
#include "helpid.hrc"
|
|
|
|
#include "baside2.hrc"
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2011-11-17 00:42:15 -05:00
|
|
|
#include "baside2.hxx"
|
|
|
|
#include "brkdlg.hxx"
|
|
|
|
#include "iderdll.hxx"
|
|
|
|
#include "iderdll2.hxx"
|
|
|
|
#include "objdlg.hxx"
|
|
|
|
|
|
|
|
#include <basic/sbmeth.hxx>
|
|
|
|
#include <basic/sbuno.hxx>
|
|
|
|
#include <com/sun/star/script/XLibraryContainer2.hpp>
|
2012-01-25 18:18:18 +01:00
|
|
|
#include <com/sun/star/beans/XMultiPropertySet.hpp>
|
|
|
|
#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
|
2011-11-17 00:42:15 -05:00
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include <comphelper/string.hxx>
|
2012-01-25 18:18:18 +01:00
|
|
|
#include <officecfg/Office/Common.hxx>
|
2011-11-17 00:42:15 -05:00
|
|
|
#include <sfx2/dispatch.hxx>
|
|
|
|
#include <sfx2/viewfrm.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#include <svl/urihelper.hxx>
|
2012-08-06 20:52:37 +02:00
|
|
|
#include <vcl/xtextedt.hxx>
|
|
|
|
#include <vcl/txtattr.hxx>
|
2007-06-27 14:43:02 +00:00
|
|
|
#include <svtools/textwindowpeer.hxx>
|
2012-08-17 07:29:20 +02:00
|
|
|
#include <svtools/syntaxhighlight.hxx>
|
2002-04-17 07:47:27 +00:00
|
|
|
#include <vcl/taskpanelist.hxx>
|
2000-12-20 15:15:59 +00:00
|
|
|
#include <vcl/help.hxx>
|
2002-09-09 14:16:04 +00:00
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
namespace basctl
|
|
|
|
{
|
|
|
|
|
2001-11-07 09:18:27 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
|
2012-08-06 14:28:28 +02:00
|
|
|
namespace
|
|
|
|
{
|
2012-08-07 14:33:56 +02:00
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
sal_uInt16 const NoMarker = 0xFFFF;
|
|
|
|
|
2010-11-17 14:35:16 +01:00
|
|
|
long nVirtToolBoxHeight; // inited in WatchWindow, used in Stackwindow
|
2004-07-23 09:11:25 +00:00
|
|
|
long nHeaderBarHeight;
|
2012-08-07 14:33:56 +02:00
|
|
|
|
|
|
|
// Returns pBase converted to SbxVariable if valid and is not an SbxMethod.
|
2012-08-07 15:22:25 +02:00
|
|
|
SbxVariable* IsSbxVariable (SbxBase* pBase)
|
2012-08-07 14:33:56 +02:00
|
|
|
{
|
2012-08-07 15:22:25 +02:00
|
|
|
if (SbxVariable* pVar = dynamic_cast<SbxVariable*>(pBase))
|
|
|
|
if (!dynamic_cast<SbxMethod*>(pVar))
|
2012-08-07 14:33:56 +02:00
|
|
|
return pVar;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
Image GetImage (unsigned nId)
|
|
|
|
{
|
|
|
|
static ImageList const aImagesNormal(IDEResId(RID_IMGLST_LAYOUT));
|
|
|
|
return aImagesNormal.GetImage(nId);
|
|
|
|
}
|
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
int const nScrollLine = 12;
|
|
|
|
int const nScrollPage = 60;
|
|
|
|
int const DWBORDER = 3;
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
char const cSuffixes[] = "%&!#@$";
|
|
|
|
|
|
|
|
} // namespace
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
|
2010-11-17 14:35:16 +01:00
|
|
|
/**
|
|
|
|
* Helper functions to get/set text in TextEngine using
|
|
|
|
* the stream interface.
|
|
|
|
*
|
|
|
|
* get/setText() only supports tools Strings limited to 64K).
|
|
|
|
*/
|
2012-09-26 23:07:35 -03:00
|
|
|
OUString getTextEngineText (ExtTextEngine& rEngine)
|
2003-04-23 15:39:07 +00:00
|
|
|
{
|
|
|
|
SvMemoryStream aMemStream;
|
|
|
|
aMemStream.SetStreamCharSet( RTL_TEXTENCODING_UTF8 );
|
|
|
|
aMemStream.SetLineDelimiter( LINEEND_LF );
|
2012-09-02 16:21:08 +02:00
|
|
|
rEngine.Write( aMemStream );
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uLong nSize = aMemStream.Tell();
|
2012-09-26 23:07:35 -03:00
|
|
|
OUString aText( (const sal_Char*)aMemStream.GetData(),
|
2003-04-23 15:39:07 +00:00
|
|
|
nSize, RTL_TEXTENCODING_UTF8 );
|
|
|
|
return aText;
|
|
|
|
}
|
|
|
|
|
2012-09-26 23:07:35 -03:00
|
|
|
void setTextEngineText (ExtTextEngine& rEngine, OUString const& aStr)
|
2003-04-23 15:39:07 +00:00
|
|
|
{
|
2012-09-02 16:21:08 +02:00
|
|
|
rEngine.SetText(String());
|
2012-09-26 23:07:35 -03:00
|
|
|
OString aUTF8Str = ::rtl::OUStringToOString( aStr, RTL_TEXTENCODING_UTF8 );
|
2003-04-23 15:39:07 +00:00
|
|
|
SvMemoryStream aMemStream( (void*)aUTF8Str.getStr(), aUTF8Str.getLength(),
|
|
|
|
STREAM_READ | STREAM_SEEK_TO_BEGIN );
|
|
|
|
aMemStream.SetStreamCharSet( RTL_TEXTENCODING_UTF8 );
|
|
|
|
aMemStream.SetLineDelimiter( LINEEND_LF );
|
2012-09-02 16:21:08 +02:00
|
|
|
rEngine.Read(aMemStream);
|
2003-04-23 15:39:07 +00:00
|
|
|
}
|
|
|
|
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
|
|
|
void lcl_DrawIDEWindowFrame( DockingWindow* pWin )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2010-11-17 14:35:16 +01:00
|
|
|
if ( pWin->IsFloatingMode() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Size aSz = pWin->GetOutputSizePixel();
|
|
|
|
const Color aOldLineColor( pWin->GetLineColor() );
|
|
|
|
pWin->SetLineColor( Color( COL_WHITE ) );
|
|
|
|
// White line on top
|
|
|
|
pWin->DrawLine( Point( 0, 0 ), Point( aSz.Width(), 0 ) );
|
|
|
|
// Black line at bottom
|
|
|
|
pWin->SetLineColor( Color( COL_BLACK ) );
|
|
|
|
pWin->DrawLine( Point( 0, aSz.Height() - 1 ),
|
|
|
|
Point( aSz.Width(), aSz.Height() - 1 ) );
|
|
|
|
pWin->SetLineColor( aOldLineColor );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void lcl_SeparateNameAndIndex( const String& rVName, String& rVar, String& rIndex )
|
|
|
|
{
|
|
|
|
rVar = rVName;
|
|
|
|
rIndex.Erase();
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nIndexStart = rVar.Search( '(' );
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( nIndexStart != STRING_NOTFOUND )
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nIndexEnd = rVar.Search( ')', nIndexStart );
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( nIndexStart != STRING_NOTFOUND )
|
|
|
|
{
|
|
|
|
rIndex = rVar.Copy( nIndexStart+1, nIndexEnd-nIndexStart-1 );
|
|
|
|
rVar.Erase( nIndexStart );
|
2012-06-11 13:15:18 +01:00
|
|
|
rVar = comphelper::string::stripEnd(rVar, ' ');
|
|
|
|
rIndex = comphelper::string::strip(rIndex, ' ');
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( rVar.Len() )
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nLastChar = rVar.Len()-1;
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( strchr( cSuffixes, rVar.GetChar( nLastChar ) ) )
|
|
|
|
rVar.Erase( nLastChar, 1 );
|
|
|
|
}
|
|
|
|
if ( rIndex.Len() )
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nLastChar = rIndex.Len()-1;
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( strchr( cSuffixes, rIndex.GetChar( nLastChar ) ) )
|
|
|
|
rIndex.Erase( nLastChar, 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
} // namespace
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// EditorWindow
|
|
|
|
// ============
|
|
|
|
//
|
|
|
|
|
2012-01-25 18:18:18 +01:00
|
|
|
class EditorWindow::ChangesListener:
|
|
|
|
public cppu::WeakImplHelper1< beans::XPropertiesChangeListener >
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ChangesListener(EditorWindow & editor): editor_(editor) {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~ChangesListener() {}
|
|
|
|
|
2012-01-29 18:20:29 +07:00
|
|
|
virtual void SAL_CALL disposing(lang::EventObject const &) throw (RuntimeException)
|
2012-01-25 18:18:18 +01:00
|
|
|
{
|
|
|
|
osl::MutexGuard g(editor_.mutex_);
|
|
|
|
editor_.notifier_.clear();
|
|
|
|
}
|
|
|
|
|
2012-01-29 18:20:29 +07:00
|
|
|
virtual void SAL_CALL propertiesChange(
|
2012-01-25 18:18:18 +01:00
|
|
|
Sequence< beans::PropertyChangeEvent > const &) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
SolarMutexGuard g;
|
|
|
|
editor_.ImplSetFont();
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorWindow & editor_;
|
|
|
|
};
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
class EditorWindow::ProgressInfo : public SfxProgress
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ProgressInfo (SfxObjectShell* pObjSh, String const& rText, sal_uLong nRange) :
|
|
|
|
SfxProgress(pObjSh, rText, nRange),
|
|
|
|
nCurState(0)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void StepProgress ()
|
|
|
|
{
|
|
|
|
SetState(++nCurState);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
sal_uLong nCurState;
|
|
|
|
};
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
EditorWindow::EditorWindow (Window* pParent, ModulWindow* pModulWindow) :
|
|
|
|
Window(pParent, WB_BORDER),
|
|
|
|
pEditView(0),
|
|
|
|
pEditEngine(0),
|
|
|
|
rModulWindow(*pModulWindow),
|
|
|
|
nCurTextWidth(0),
|
|
|
|
bHighlightning(false),
|
|
|
|
bDoSyntaxHighlight(true),
|
|
|
|
bDelayHighlight(true)
|
|
|
|
{
|
|
|
|
SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor()));
|
2000-09-29 10:02:42 +00:00
|
|
|
SetPointer( Pointer( POINTER_TEXT ) );
|
2002-05-02 12:41:52 +00:00
|
|
|
SetHelpId( HID_BASICIDE_EDITORWINDOW );
|
2012-01-25 18:18:18 +01:00
|
|
|
|
|
|
|
listener_ = new ChangesListener(*this);
|
|
|
|
Reference< beans::XMultiPropertySet > n(
|
2012-01-31 17:25:42 +01:00
|
|
|
officecfg::Office::Common::Font::SourceViewFont::get(),
|
|
|
|
UNO_QUERY_THROW);
|
2012-01-25 18:18:18 +01:00
|
|
|
{
|
|
|
|
osl::MutexGuard g(mutex_);
|
|
|
|
notifier_ = n;
|
|
|
|
}
|
2012-09-26 23:07:35 -03:00
|
|
|
Sequence< OUString > s(2);
|
|
|
|
s[0] = OUString( "FontHeight" );
|
|
|
|
s[1] = OUString( "FontName" );
|
2012-01-25 18:18:18 +01:00
|
|
|
n->addPropertiesChangeListener(s, listener_.get());
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
EditorWindow::~EditorWindow()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-01-25 18:18:18 +01:00
|
|
|
Reference< beans::XMultiPropertySet > n;
|
|
|
|
{
|
|
|
|
osl::MutexGuard g(mutex_);
|
|
|
|
n = notifier_;
|
|
|
|
}
|
|
|
|
if (n.is()) {
|
|
|
|
n->removePropertiesChangeListener(listener_.get());
|
|
|
|
}
|
2002-09-09 14:16:04 +00:00
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
aSyntaxIdleTimer.Stop();
|
|
|
|
|
|
|
|
if ( pEditEngine )
|
|
|
|
{
|
|
|
|
EndListening( *pEditEngine );
|
2012-09-02 16:21:08 +02:00
|
|
|
pEditEngine->RemoveView(pEditView.get());
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String EditorWindow::GetWordAtCursor()
|
|
|
|
{
|
2004-03-17 12:05:57 +00:00
|
|
|
String aWord;
|
|
|
|
|
|
|
|
if ( pEditView )
|
|
|
|
{
|
|
|
|
TextEngine* pTextEngine = pEditView->GetTextEngine();
|
|
|
|
if ( pTextEngine )
|
|
|
|
{
|
|
|
|
// check first, if the cursor is at a help URL
|
|
|
|
const TextSelection& rSelection = pEditView->GetSelection();
|
|
|
|
const TextPaM& rSelStart = rSelection.GetStart();
|
|
|
|
const TextPaM& rSelEnd = rSelection.GetEnd();
|
|
|
|
String aText = pTextEngine->GetText( rSelEnd.GetPara() );
|
|
|
|
CharClass aClass( ::comphelper::getProcessServiceFactory() , Application::GetSettings().GetLocale() );
|
|
|
|
xub_StrLen nSelStart = static_cast< xub_StrLen >( rSelStart.GetIndex() );
|
|
|
|
xub_StrLen nSelEnd = static_cast< xub_StrLen >( rSelEnd.GetIndex() );
|
|
|
|
xub_StrLen nLength = static_cast< xub_StrLen >( aText.Len() );
|
|
|
|
xub_StrLen nStart = 0;
|
|
|
|
xub_StrLen nEnd = nLength;
|
|
|
|
while ( nStart < nLength )
|
|
|
|
{
|
|
|
|
String aURL( URIHelper::FindFirstURLInText( aText, nStart, nEnd, aClass ) );
|
|
|
|
INetURLObject aURLObj( aURL );
|
|
|
|
if ( aURLObj.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP
|
|
|
|
&& nSelStart >= nStart && nSelStart <= nEnd && nSelEnd >= nStart && nSelEnd <= nEnd )
|
|
|
|
{
|
|
|
|
aWord = aURL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nStart = nEnd;
|
|
|
|
nEnd = nLength;
|
|
|
|
}
|
|
|
|
|
2010-11-17 14:35:16 +01:00
|
|
|
// Not the selected range, but at the CursorPosition,
|
|
|
|
// if a word is partially selected.
|
2004-03-17 12:05:57 +00:00
|
|
|
if ( !aWord.Len() )
|
|
|
|
aWord = pTextEngine->GetWord( rSelEnd );
|
|
|
|
|
2010-11-17 14:35:16 +01:00
|
|
|
// Can be empty when full word selected, as Cursor behing it
|
2004-03-17 12:05:57 +00:00
|
|
|
if ( !aWord.Len() && pEditView->HasSelection() )
|
|
|
|
aWord = pTextEngine->GetWord( rSelStart );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aWord;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void EditorWindow::RequestHelp( const HelpEvent& rHEvt )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-07-27 10:35:28 +09:00
|
|
|
bool bDone = false;
|
2001-09-07 07:35:22 +00:00
|
|
|
|
2010-11-17 14:35:16 +01:00
|
|
|
// Should have been activated at some point
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( pEditEngine )
|
|
|
|
{
|
|
|
|
if ( rHEvt.GetMode() & HELPMODE_CONTEXT )
|
|
|
|
{
|
|
|
|
String aKeyword = GetWordAtCursor();
|
2010-07-21 17:46:37 +02:00
|
|
|
Application::GetHelp()->SearchKeyword( aKeyword );
|
2012-07-27 10:35:28 +09:00
|
|
|
bDone = true;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
2001-10-25 07:01:10 +00:00
|
|
|
else if ( rHEvt.GetMode() & HELPMODE_QUICK )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
String aHelpText;
|
|
|
|
Point aTopLeft;
|
|
|
|
if ( StarBASIC::IsRunning() )
|
|
|
|
{
|
|
|
|
Point aWindowPos = rHEvt.GetMousePosPixel();
|
|
|
|
aWindowPos = ScreenToOutputPixel( aWindowPos );
|
|
|
|
Point aDocPos = GetEditView()->GetDocPos( aWindowPos );
|
2012-08-07 08:36:40 +02:00
|
|
|
TextPaM aCursor = GetEditView()->GetTextEngine()->GetPaM(aDocPos, false);
|
2000-09-29 10:02:42 +00:00
|
|
|
TextPaM aStartOfWord;
|
|
|
|
String aWord = GetEditView()->GetTextEngine()->GetWord( aCursor, &aStartOfWord );
|
2011-08-28 01:03:37 +01:00
|
|
|
if ( aWord.Len() && !comphelper::string::isdigitAsciiString(aWord) )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nLastChar =aWord.Len()-1;
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( strchr( cSuffixes, aWord.GetChar( nLastChar ) ) )
|
|
|
|
aWord.Erase( nLastChar, 1 );
|
|
|
|
SbxBase* pSBX = StarBASIC::FindSBXInCurrentScope( aWord );
|
2012-08-07 14:33:56 +02:00
|
|
|
if (SbxVariable const* pVar = IsSbxVariable(pSBX))
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
SbxDataType eType = pVar->GetType();
|
2011-01-14 11:16:25 +01:00
|
|
|
if ( (sal_uInt8)eType == (sal_uInt8)SbxOBJECT )
|
2011-08-22 11:39:37 +02:00
|
|
|
// might cause a crash e. g. at the selections-object
|
|
|
|
// Type == Object does not mean pVar == Object!
|
2000-09-29 10:02:42 +00:00
|
|
|
; // aHelpText = ((SbxObject*)pVar)->GetClassName();
|
|
|
|
else if ( eType & SbxARRAY )
|
|
|
|
; // aHelpText = "{...}";
|
2011-01-14 11:16:25 +01:00
|
|
|
else if ( (sal_uInt8)eType != (sal_uInt8)SbxEMPTY )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
aHelpText = pVar->GetName();
|
2011-08-22 11:39:37 +02:00
|
|
|
if ( !aHelpText.Len() ) // name is not copied with the passed parameters
|
2000-09-29 10:02:42 +00:00
|
|
|
aHelpText = aWord;
|
|
|
|
aHelpText += '=';
|
|
|
|
aHelpText += pVar->GetString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( aHelpText.Len() )
|
|
|
|
{
|
|
|
|
aTopLeft = GetEditView()->GetTextEngine()->PaMtoEditCursor( aStartOfWord ).BottomLeft();
|
|
|
|
aTopLeft = GetEditView()->GetWindowPos( aTopLeft );
|
|
|
|
aTopLeft.X() += 5;
|
|
|
|
aTopLeft.Y() += 5;
|
|
|
|
aTopLeft = OutputToScreenPixel( aTopLeft );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-12-20 15:15:59 +00:00
|
|
|
Help::ShowQuickHelp( this, Rectangle( aTopLeft, Size( 1, 1 ) ), aHelpText, QUICKHELP_TOP|QUICKHELP_LEFT);
|
2012-07-27 10:35:28 +09:00
|
|
|
bDone = true;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
2001-09-07 07:35:22 +00:00
|
|
|
|
|
|
|
if ( !bDone )
|
2000-09-29 10:02:42 +00:00
|
|
|
Window::RequestHelp( rHEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void EditorWindow::Resize()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2010-11-17 14:35:16 +01:00
|
|
|
// ScrollBars, etc. happens in Adjust...
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( pEditView )
|
|
|
|
{
|
|
|
|
long nVisY = pEditView->GetStartDocPos().Y();
|
2010-11-17 14:35:16 +01:00
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
pEditView->ShowCursor();
|
|
|
|
Size aOutSz( GetOutputSizePixel() );
|
|
|
|
long nMaxVisAreaStart = pEditView->GetTextEngine()->GetTextHeight() - aOutSz.Height();
|
|
|
|
if ( nMaxVisAreaStart < 0 )
|
|
|
|
nMaxVisAreaStart = 0;
|
|
|
|
if ( pEditView->GetStartDocPos().Y() > nMaxVisAreaStart )
|
|
|
|
{
|
|
|
|
Point aStartDocPos( pEditView->GetStartDocPos() );
|
|
|
|
aStartDocPos.Y() = nMaxVisAreaStart;
|
|
|
|
pEditView->SetStartDocPos( aStartDocPos );
|
|
|
|
pEditView->ShowCursor();
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.GetBreakPointWindow().GetCurYOffset() = aStartDocPos.Y();
|
|
|
|
rModulWindow.GetLineNumberWindow().GetCurYOffset() = aStartDocPos.Y();
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
InitScrollBars();
|
|
|
|
if ( nVisY != pEditView->GetStartDocPos().Y() )
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void EditorWindow::MouseMove( const MouseEvent &rEvt )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( pEditView )
|
|
|
|
pEditView->MouseMove( rEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void EditorWindow::MouseButtonUp( const MouseEvent &rEvt )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( pEditView )
|
|
|
|
{
|
|
|
|
pEditView->MouseButtonUp( rEvt );
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
if (SfxBindings* pBindings = GetBindingsPtr())
|
2006-01-03 11:42:22 +00:00
|
|
|
pBindings->Invalidate( SID_BASICIDE_STAT_POS );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void EditorWindow::MouseButtonDown( const MouseEvent &rEvt )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
GrabFocus();
|
|
|
|
if ( pEditView )
|
|
|
|
pEditView->MouseButtonDown( rEvt );
|
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void EditorWindow::Command( const CommandEvent& rCEvt )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( pEditView )
|
|
|
|
{
|
|
|
|
pEditView->Command( rCEvt );
|
|
|
|
if ( ( rCEvt.GetCommand() == COMMAND_WHEEL ) ||
|
|
|
|
( rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL ) ||
|
|
|
|
( rCEvt.GetCommand() == COMMAND_AUTOSCROLL ) )
|
|
|
|
{
|
2012-08-17 07:29:20 +02:00
|
|
|
HandleScrollCommand( rCEvt, rModulWindow.GetHScrollBar(), &rModulWindow.GetEditVScrollBar() );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-20 06:11:34 +09:00
|
|
|
bool EditorWindow::ImpCanModify()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-07-20 06:11:34 +09:00
|
|
|
bool bCanModify = true;
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( StarBASIC::IsRunning() )
|
|
|
|
{
|
2010-11-17 14:35:16 +01:00
|
|
|
// If in Trace-mode, abort the trace or refuse input
|
|
|
|
// Remove markers in the modules in Notify at Basic::Stoped
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( QueryBox( 0, WB_OK_CANCEL, String( IDEResId( RID_STR_WILLSTOPPRG ) ) ).Execute() == RET_OK )
|
|
|
|
{
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.GetBasicStatus().bIsRunning = false;
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
StopBasic();
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
else
|
2012-07-20 06:11:34 +09:00
|
|
|
bCanModify = false;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
return bCanModify;
|
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2010-11-17 14:35:16 +01:00
|
|
|
if ( !pEditView ) // Happens in Win95
|
2000-09-29 10:02:42 +00:00
|
|
|
return;
|
|
|
|
|
2003-04-15 16:50:44 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2012-08-17 07:29:20 +02:00
|
|
|
Range aRange = rModulWindow.GetHScrollBar()->GetRange(); (void)aRange;
|
|
|
|
long nVisSz = rModulWindow.GetHScrollBar()->GetVisibleSize(); (void)nVisSz;
|
|
|
|
long nPapSz = rModulWindow.GetHScrollBar()->GetPageSize(); (void)nPapSz;
|
|
|
|
long nLinSz = rModulWindow.GetHScrollBar()->GetLineSize(); (void)nLinSz;
|
|
|
|
long nThumb = rModulWindow.GetHScrollBar()->GetThumbPos(); (void)nThumb;
|
2000-09-29 10:02:42 +00:00
|
|
|
#endif
|
2012-08-07 08:36:40 +02:00
|
|
|
bool const bWasModified = pEditEngine->IsModified();
|
2011-08-21 18:12:16 -05:00
|
|
|
// see if there is an accelerator to be processed first
|
2012-08-07 08:36:40 +02:00
|
|
|
bool bDone = SfxViewShell::Current()->KeyInput( rKEvt );
|
2011-08-21 18:12:16 -05:00
|
|
|
|
|
|
|
if ( !bDone && ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() ) )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-08-30 10:18:14 +02:00
|
|
|
if ( ( rKEvt.GetKeyCode().GetCode() == KEY_TAB ) && !rKEvt.GetKeyCode().IsMod1() &&
|
|
|
|
!rKEvt.GetKeyCode().IsMod2() && !GetEditView()->IsReadOnly() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-08-30 10:18:14 +02:00
|
|
|
TextSelection aSel( pEditView->GetSelection() );
|
|
|
|
if ( aSel.GetStart().GetPara() != aSel.GetEnd().GetPara() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-08-30 10:18:14 +02:00
|
|
|
bDelayHighlight = false;
|
|
|
|
if ( !rKEvt.GetKeyCode().IsShift() )
|
|
|
|
pEditView->IndentBlock();
|
|
|
|
else
|
|
|
|
pEditView->UnindentBlock();
|
|
|
|
bDelayHighlight = true;
|
|
|
|
bDone = true;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
2012-08-30 10:18:14 +02:00
|
|
|
if ( !bDone )
|
|
|
|
bDone = pEditView->KeyInput( rKEvt );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
if ( !bDone )
|
|
|
|
{
|
|
|
|
Window::KeyInput( rKEvt );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
if (SfxBindings* pBindings = GetBindingsPtr())
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2006-01-03 11:42:22 +00:00
|
|
|
pBindings->Invalidate( SID_BASICIDE_STAT_POS );
|
|
|
|
if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_CURSOR )
|
|
|
|
pBindings->Update( SID_BASICIDE_STAT_POS );
|
|
|
|
if ( !bWasModified && pEditEngine->IsModified() )
|
|
|
|
{
|
|
|
|
pBindings->Invalidate( SID_SAVEDOC );
|
|
|
|
pBindings->Invalidate( SID_DOC_MODIFIED );
|
2011-02-17 10:40:14 +01:00
|
|
|
pBindings->Invalidate( SID_UNDO );
|
2006-01-03 11:42:22 +00:00
|
|
|
}
|
|
|
|
if ( rKEvt.GetKeyCode().GetCode() == KEY_INSERT )
|
|
|
|
pBindings->Invalidate( SID_ATTR_INSERT );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void EditorWindow::Paint( const Rectangle& rRect )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2010-11-17 14:35:16 +01:00
|
|
|
if ( !pEditEngine ) // We need it now at latest
|
2000-09-29 10:02:42 +00:00
|
|
|
CreateEditEngine();
|
|
|
|
|
|
|
|
pEditView->Paint( rRect );
|
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void EditorWindow::LoseFocus()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
SetSourceInBasic();
|
|
|
|
Window::LoseFocus();
|
|
|
|
}
|
|
|
|
|
2012-07-23 19:00:41 +09:00
|
|
|
bool EditorWindow::SetSourceInBasic()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-07-20 06:11:34 +09:00
|
|
|
bool bChanged = false;
|
2006-01-31 17:32:49 +00:00
|
|
|
if ( pEditEngine && pEditEngine->IsModified()
|
2010-11-17 14:35:16 +01:00
|
|
|
&& !GetEditView()->IsReadOnly() ) // Added for #i60626, otherwise
|
2006-01-31 17:32:49 +00:00
|
|
|
// any read only bug in the text engine could lead to a crash later
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2010-11-17 14:35:16 +01:00
|
|
|
if ( !StarBASIC::IsRunning() ) // Not at runtime!
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.UpdateModule();
|
2012-07-20 06:11:34 +09:00
|
|
|
bChanged = true;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return bChanged;
|
|
|
|
}
|
|
|
|
|
2004-05-28 13:33:32 +00:00
|
|
|
// Returns the position of the last character of any of the following
|
|
|
|
// EOL char combinations: CR, CR/LF, LF, return -1 if no EOL is found
|
2012-09-26 23:07:35 -03:00
|
|
|
sal_Int32 searchEOL( const OUString& rStr, sal_Int32 fromIndex )
|
2004-05-28 13:33:32 +00:00
|
|
|
{
|
|
|
|
sal_Int32 iRetPos = -1;
|
|
|
|
|
|
|
|
sal_Int32 iLF = rStr.indexOf( LINE_SEP, fromIndex );
|
|
|
|
if( iLF != -1 )
|
|
|
|
{
|
|
|
|
iRetPos = iLF;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iRetPos = rStr.indexOf( LINE_SEP_CR, fromIndex );
|
|
|
|
}
|
|
|
|
return iRetPos;
|
|
|
|
}
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
void EditorWindow::CreateEditEngine()
|
|
|
|
{
|
|
|
|
if ( pEditEngine )
|
|
|
|
return;
|
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
pEditEngine.reset(new ExtTextEngine);
|
|
|
|
pEditView.reset(new ExtTextView(pEditEngine.get(), this));
|
2012-08-07 08:36:40 +02:00
|
|
|
pEditView->SetAutoIndentMode(true);
|
|
|
|
pEditEngine->SetUpdateMode(false);
|
2012-09-02 16:21:08 +02:00
|
|
|
pEditEngine->InsertView(pEditView.get());
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2002-09-09 14:16:04 +00:00
|
|
|
ImplSetFont();
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
aSyntaxIdleTimer.SetTimeout( 200 );
|
|
|
|
aSyntaxIdleTimer.SetTimeoutHdl( LINK( this, EditorWindow, SyntaxTimerHdl ) );
|
|
|
|
|
|
|
|
aHighlighter.initialize( HIGHLIGHT_BASIC );
|
|
|
|
|
2012-07-20 06:11:34 +09:00
|
|
|
bool bWasDoSyntaxHighlight = bDoSyntaxHighlight;
|
|
|
|
bDoSyntaxHighlight = false; // too slow for large texts...
|
2012-09-26 23:07:35 -03:00
|
|
|
OUString aOUSource(rModulWindow.GetModule());
|
2003-04-23 15:39:07 +00:00
|
|
|
sal_Int32 nLines = 0;
|
|
|
|
sal_Int32 nIndex = -1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
nLines++;
|
2004-05-28 13:33:32 +00:00
|
|
|
nIndex = searchEOL( aOUSource, nIndex+1 );
|
2003-04-23 15:39:07 +00:00
|
|
|
}
|
|
|
|
while ( nIndex >= 0 );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
// nLines*4: SetText+Formatting+DoHighlight+Formatting
|
2011-08-22 11:39:37 +02:00
|
|
|
// it could be cut down on one formatting but you would wait even longer
|
|
|
|
// for the text then if the source code is long...
|
2012-09-02 16:21:08 +02:00
|
|
|
pProgress.reset(new ProgressInfo(
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
GetShell()->GetViewFrame()->GetObjectShell(),
|
|
|
|
String(IDEResId(RID_STR_GENERATESOURCE)),
|
|
|
|
nLines*4
|
2012-09-02 16:21:08 +02:00
|
|
|
));
|
|
|
|
setTextEngineText(*pEditEngine, aOUSource);
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
pEditView->SetStartDocPos( Point( 0, 0 ) );
|
|
|
|
pEditView->SetSelection( TextSelection() );
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.GetBreakPointWindow().GetCurYOffset() = 0;
|
|
|
|
rModulWindow.GetLineNumberWindow().GetCurYOffset() = 0;
|
2012-08-07 08:36:40 +02:00
|
|
|
pEditEngine->SetUpdateMode(true);
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.Update(); // has only been invalidated at UpdateMode = true
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-08-07 08:36:40 +02:00
|
|
|
pEditView->ShowCursor( true, true );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
StartListening( *pEditEngine );
|
|
|
|
|
|
|
|
aSyntaxIdleTimer.Stop();
|
2004-11-15 15:38:31 +00:00
|
|
|
bDoSyntaxHighlight = bWasDoSyntaxHighlight;
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
for ( sal_uInt16 nLine = 0; nLine < nLines; nLine++ )
|
2012-04-02 23:18:19 +02:00
|
|
|
aSyntaxLineTable.insert( nLine );
|
2000-09-29 10:02:42 +00:00
|
|
|
ForceSyntaxTimeout();
|
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
pProgress.reset();
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
pEditView->EraseVirtualDevice();
|
2012-08-07 08:36:40 +02:00
|
|
|
pEditEngine->SetModified( false );
|
|
|
|
pEditEngine->EnableUndo( true );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
InitScrollBars();
|
|
|
|
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
if (SfxBindings* pBindings = GetBindingsPtr())
|
2006-01-03 11:42:22 +00:00
|
|
|
pBindings->Invalidate( SID_BASICIDE_STAT_POS );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
DBG_ASSERT( rModulWindow.GetBreakPointWindow().GetCurYOffset() == 0, "CreateEditEngine: Brechpunkte verschoben?" );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2001-11-07 09:18:27 +00:00
|
|
|
// set readonly mode for readonly libraries
|
2012-08-17 07:29:20 +02:00
|
|
|
ScriptDocument aDocument(rModulWindow.GetDocument());
|
2012-09-26 23:07:35 -03:00
|
|
|
OUString aOULibName(rModulWindow.GetLibName());
|
2007-03-15 14:52:48 +00:00
|
|
|
Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
|
2001-11-07 09:18:27 +00:00
|
|
|
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) )
|
|
|
|
{
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.SetReadOnly(true);
|
2001-11-07 09:18:27 +00:00
|
|
|
}
|
|
|
|
|
2007-03-15 14:52:48 +00:00
|
|
|
if ( aDocument.isDocument() && aDocument.isReadOnly() )
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.SetReadOnly(true);
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2002-07-05 09:22:53 +00:00
|
|
|
// virtual
|
|
|
|
void EditorWindow::DataChanged(DataChangedEvent const & rDCEvt)
|
|
|
|
{
|
|
|
|
Window::DataChanged(rDCEvt);
|
|
|
|
if (rDCEvt.GetType() == DATACHANGED_SETTINGS
|
|
|
|
&& (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0)
|
|
|
|
{
|
|
|
|
Color aColor(GetSettings().GetStyleSettings().GetFieldColor());
|
|
|
|
if (aColor
|
|
|
|
!= rDCEvt.GetOldSettings()->GetStyleSettings().GetFieldColor())
|
|
|
|
{
|
|
|
|
SetBackground(Wallpaper(aColor));
|
|
|
|
Invalidate();
|
|
|
|
}
|
2002-07-15 08:01:03 +00:00
|
|
|
if (pEditEngine != 0)
|
|
|
|
{
|
|
|
|
aColor = GetSettings().GetStyleSettings().GetFieldTextColor();
|
|
|
|
if (aColor != rDCEvt.GetOldSettings()->
|
|
|
|
GetStyleSettings().GetFieldTextColor())
|
|
|
|
{
|
|
|
|
Font aFont(pEditEngine->GetFont());
|
|
|
|
aFont.SetColor(aColor);
|
|
|
|
pEditEngine->SetFont(aFont);
|
|
|
|
}
|
|
|
|
}
|
2002-07-05 09:22:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-06 07:38:24 +02:00
|
|
|
void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-08-07 14:33:56 +02:00
|
|
|
if (TextHint const* pTextHint = dynamic_cast<TextHint const*>(&rHint))
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-08-07 14:33:56 +02:00
|
|
|
TextHint const& rTextHint = *pTextHint;
|
2000-09-29 10:02:42 +00:00
|
|
|
if( rTextHint.GetId() == TEXT_HINT_VIEWSCROLLED )
|
|
|
|
{
|
2012-08-17 07:29:20 +02:00
|
|
|
if ( rModulWindow.GetHScrollBar() )
|
|
|
|
rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
|
|
|
|
rModulWindow.GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() );
|
|
|
|
rModulWindow.GetBreakPointWindow().DoScroll
|
|
|
|
( 0, rModulWindow.GetBreakPointWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() );
|
|
|
|
rModulWindow.GetLineNumberWindow().DoScroll
|
|
|
|
( 0, rModulWindow.GetLineNumberWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
else if( rTextHint.GetId() == TEXT_HINT_TEXTHEIGHTCHANGED )
|
|
|
|
{
|
|
|
|
if ( pEditView->GetStartDocPos().Y() )
|
|
|
|
{
|
|
|
|
long nOutHeight = GetOutputSizePixel().Height();
|
|
|
|
long nTextHeight = pEditEngine->GetTextHeight();
|
|
|
|
if ( nTextHeight < nOutHeight )
|
|
|
|
pEditView->Scroll( 0, pEditView->GetStartDocPos().Y() );
|
2011-11-11 14:22:11 -05:00
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.GetLineNumberWindow().Invalidate();
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetScrollBarRanges();
|
|
|
|
}
|
|
|
|
else if( rTextHint.GetId() == TEXT_HINT_TEXTFORMATTED )
|
|
|
|
{
|
2012-08-17 07:29:20 +02:00
|
|
|
if ( rModulWindow.GetHScrollBar() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uLong nWidth = pEditEngine->CalcTextWidth();
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( (long)nWidth != nCurTextWidth )
|
|
|
|
{
|
|
|
|
nCurTextWidth = nWidth;
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.GetHScrollBar()->SetRange( Range( 0, (long)nCurTextWidth-1) );
|
|
|
|
rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-12 16:13:32 +00:00
|
|
|
long nPrevTextWidth = nCurTextWidth;
|
|
|
|
nCurTextWidth = pEditEngine->CalcTextWidth();
|
|
|
|
if ( nCurTextWidth != nPrevTextWidth )
|
|
|
|
SetScrollBarRanges();
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
else if( rTextHint.GetId() == TEXT_HINT_PARAINSERTED )
|
|
|
|
{
|
2012-07-20 06:11:34 +09:00
|
|
|
ParagraphInsertedDeleted( rTextHint.GetValue(), true );
|
2003-11-12 16:13:32 +00:00
|
|
|
DoDelayedSyntaxHighlight( rTextHint.GetValue() );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
else if( rTextHint.GetId() == TEXT_HINT_PARAREMOVED )
|
|
|
|
{
|
2012-07-20 06:11:34 +09:00
|
|
|
ParagraphInsertedDeleted( rTextHint.GetValue(), false );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
2003-11-12 16:13:32 +00:00
|
|
|
else if( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DoDelayedSyntaxHighlight( rTextHint.GetValue() );
|
|
|
|
}
|
|
|
|
}
|
2009-10-06 07:38:24 +02:00
|
|
|
}
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
void EditorWindow::SetScrollBarRanges()
|
|
|
|
{
|
2011-08-22 11:39:37 +02:00
|
|
|
// extra method, not InitScrollBars, because for EditEngine events too
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( !pEditEngine )
|
|
|
|
return;
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
if ( rModulWindow.GetHScrollBar() )
|
|
|
|
rModulWindow.GetHScrollBar()->SetRange( Range( 0, nCurTextWidth-1 ) );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.GetEditVScrollBar().SetRange( Range( 0, pEditEngine->GetTextHeight()-1 ) );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::InitScrollBars()
|
|
|
|
{
|
|
|
|
if ( !pEditEngine )
|
|
|
|
return;
|
|
|
|
|
|
|
|
SetScrollBarRanges();
|
|
|
|
Size aOutSz( GetOutputSizePixel() );
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.GetEditVScrollBar().SetVisibleSize( aOutSz.Height() );
|
|
|
|
rModulWindow.GetEditVScrollBar().SetPageSize( aOutSz.Height() * 8 / 10 );
|
|
|
|
rModulWindow.GetEditVScrollBar().SetLineSize( GetTextHeight() );
|
|
|
|
rModulWindow.GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() );
|
|
|
|
rModulWindow.GetEditVScrollBar().Show();
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
if ( rModulWindow.GetHScrollBar() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.GetHScrollBar()->SetVisibleSize( aOutSz.Width() );
|
|
|
|
rModulWindow.GetHScrollBar()->SetPageSize( aOutSz.Width() * 8 / 10 );
|
2012-09-26 23:07:35 -03:00
|
|
|
rModulWindow.GetHScrollBar()->SetLineSize( GetTextWidth( OUString('x') ) );
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
|
|
|
|
rModulWindow.GetHScrollBar()->Show();
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
void EditorWindow::ImpDoHighlight( sal_uLong nLine )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2004-11-15 15:38:31 +00:00
|
|
|
if ( bDoSyntaxHighlight )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2004-11-15 15:38:31 +00:00
|
|
|
String aLine( pEditEngine->GetText( nLine ) );
|
|
|
|
Range aChanges = aHighlighter.notifyChange( nLine, 0, &aLine, 1 );
|
|
|
|
if ( aChanges.Len() )
|
|
|
|
{
|
|
|
|
for ( long n = aChanges.Min() + 1; n <= aChanges.Max(); n++ )
|
2012-04-02 23:18:19 +02:00
|
|
|
aSyntaxLineTable.insert( n );
|
2004-11-15 15:38:31 +00:00
|
|
|
aSyntaxIdleTimer.Start();
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-08-07 08:36:40 +02:00
|
|
|
bool const bWasModified = pEditEngine->IsModified();
|
|
|
|
pEditEngine->RemoveAttribs( nLine, true );
|
2004-11-15 15:38:31 +00:00
|
|
|
HighlightPortions aPortions;
|
|
|
|
aHighlighter.getHighlightPortions( nLine, aLine, aPortions );
|
2010-09-17 19:06:31 +02:00
|
|
|
|
|
|
|
for ( size_t i = 0; i < aPortions.size(); i++ )
|
2004-11-15 15:38:31 +00:00
|
|
|
{
|
|
|
|
HighlightPortion& r = aPortions[i];
|
2012-08-17 07:29:20 +02:00
|
|
|
Color const aColor = rModulWindow.GetLayout().GetSyntaxColor(r.tokenType);
|
|
|
|
pEditEngine->SetAttrib( TextAttribFontColor(aColor), nLine, r.nBegin, r.nEnd, true );
|
2004-11-15 15:38:31 +00:00
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2004-11-15 15:38:31 +00:00
|
|
|
pEditEngine->SetModified( bWasModified );
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
void EditorWindow::UpdateSyntaxHighlighting ()
|
|
|
|
{
|
|
|
|
unsigned nCount = pEditEngine->GetParagraphCount();
|
|
|
|
for (unsigned i = 0; i < nCount; ++i)
|
|
|
|
DoDelayedSyntaxHighlight(i);
|
|
|
|
}
|
|
|
|
|
2002-09-09 14:16:04 +00:00
|
|
|
void EditorWindow::ImplSetFont()
|
|
|
|
{
|
2012-09-26 23:07:35 -03:00
|
|
|
OUString sFontName(
|
2012-01-31 17:25:42 +01:00
|
|
|
officecfg::Office::Common::Font::SourceViewFont::FontName::get().
|
2012-09-26 23:07:35 -03:00
|
|
|
get_value_or( OUString() ) );
|
2012-01-25 18:18:18 +01:00
|
|
|
if ( sFontName.isEmpty() )
|
2002-09-09 14:16:04 +00:00
|
|
|
{
|
2012-01-25 18:18:18 +01:00
|
|
|
Font aTmpFont( OutputDevice::GetDefaultFont( DEFAULTFONT_FIXED, Application::GetSettings().GetUILanguage(), 0 , this ) );
|
|
|
|
sFontName = aTmpFont.GetName();
|
|
|
|
}
|
2012-08-17 07:29:20 +02:00
|
|
|
Size aFontSize(0, officecfg::Office::Common::Font::SourceViewFont::FontHeight::get());
|
2012-01-25 18:18:18 +01:00
|
|
|
Font aFont( sFontName, aFontSize );
|
|
|
|
aFont.SetColor( GetSettings().GetStyleSettings().GetFieldTextColor() );
|
|
|
|
SetPointFont( aFont );
|
|
|
|
aFont = GetFont();
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.GetBreakPointWindow().SetFont( aFont );
|
|
|
|
rModulWindow.GetLineNumberWindow().SetFont( aFont );
|
2002-09-09 14:16:04 +00:00
|
|
|
|
2012-01-25 18:18:18 +01:00
|
|
|
if ( pEditEngine )
|
|
|
|
{
|
2012-08-07 08:36:40 +02:00
|
|
|
bool const bModified = pEditEngine->IsModified();
|
2012-01-25 18:18:18 +01:00
|
|
|
pEditEngine->SetFont( aFont );
|
|
|
|
pEditEngine->SetModified( bModified );
|
2002-09-09 14:16:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
void EditorWindow::DoSyntaxHighlight( sal_uLong nPara )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-08-22 11:39:37 +02:00
|
|
|
// because of the DelayedSyntaxHighlight it's possible
|
|
|
|
// that this line does not exist anymore!
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( nPara < pEditEngine->GetParagraphCount() )
|
|
|
|
{
|
2011-08-22 11:39:37 +02:00
|
|
|
// unfortunately I'm not sure that excactly this line does Modified() ...
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( pProgress )
|
|
|
|
pProgress->StepProgress();
|
|
|
|
ImpDoHighlight( nPara );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
void EditorWindow::DoDelayedSyntaxHighlight( sal_uLong nPara )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-08-22 11:39:37 +02:00
|
|
|
// line is only added to 'Liste' (list), processed in TimerHdl
|
|
|
|
// => don't manipulate breaks while EditEngine is formatting
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( pProgress )
|
|
|
|
pProgress->StepProgress();
|
|
|
|
|
|
|
|
if ( !bHighlightning && bDoSyntaxHighlight )
|
|
|
|
{
|
|
|
|
if ( bDelayHighlight )
|
|
|
|
{
|
2012-04-02 23:18:19 +02:00
|
|
|
aSyntaxLineTable.insert( nPara );
|
2000-09-29 10:02:42 +00:00
|
|
|
aSyntaxIdleTimer.Start();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DoSyntaxHighlight( nPara );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(EditorWindow, SyntaxTimerHdl)
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( pEditView, "Noch keine View, aber Syntax-Highlight ?!" );
|
|
|
|
|
2012-08-07 08:36:40 +02:00
|
|
|
bool const bWasModified = pEditEngine->IsModified();
|
|
|
|
//pEditEngine->SetUpdateMode(false);
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-07-20 06:11:34 +09:00
|
|
|
bHighlightning = true;
|
2012-04-02 23:18:19 +02:00
|
|
|
for ( SyntaxLineSet::const_iterator it = aSyntaxLineTable.begin();
|
|
|
|
it != aSyntaxLineTable.end(); ++it )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-04-02 23:18:19 +02:00
|
|
|
sal_uInt16 nLine = *it;
|
2000-09-29 10:02:42 +00:00
|
|
|
DoSyntaxHighlight( nLine );
|
|
|
|
}
|
2002-08-23 09:27:16 +00:00
|
|
|
|
2005-04-18 10:56:16 +00:00
|
|
|
// #i45572#
|
|
|
|
if ( pEditView )
|
2012-08-07 08:36:40 +02:00
|
|
|
pEditView->ShowCursor( false, true );
|
2005-04-18 10:56:16 +00:00
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
pEditEngine->SetModified( bWasModified );
|
|
|
|
|
2012-04-02 23:18:19 +02:00
|
|
|
aSyntaxLineTable.clear();
|
2012-07-20 06:11:34 +09:00
|
|
|
bHighlightning = false;
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-20 06:11:34 +09:00
|
|
|
void EditorWindow::ParagraphInsertedDeleted( sal_uLong nPara, bool bInserted )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( pProgress )
|
|
|
|
pProgress->StepProgress();
|
|
|
|
|
|
|
|
if ( !bInserted && ( nPara == TEXT_PARA_ALL ) )
|
|
|
|
{
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.GetBreakPoints().reset();
|
|
|
|
rModulWindow.GetBreakPointWindow().Invalidate();
|
|
|
|
rModulWindow.GetLineNumberWindow().Invalidate();
|
2000-09-29 10:02:42 +00:00
|
|
|
aHighlighter.initialize( HIGHLIGHT_BASIC );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.GetBreakPoints().AdjustBreakPoints( (sal_uInt16)nPara+1, bInserted );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
long nLineHeight = GetTextHeight();
|
2012-08-17 07:29:20 +02:00
|
|
|
Size aSz = rModulWindow.GetBreakPointWindow().GetOutputSize();
|
2000-09-29 10:02:42 +00:00
|
|
|
Rectangle aInvRec( Point( 0, 0 ), aSz );
|
2012-08-17 07:29:20 +02:00
|
|
|
long nY = nPara*nLineHeight - rModulWindow.GetBreakPointWindow().GetCurYOffset();
|
2000-09-29 10:02:42 +00:00
|
|
|
aInvRec.Top() = nY;
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.GetBreakPointWindow().Invalidate( aInvRec );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
Size aLnSz(rModulWindow.GetLineNumberWindow().GetWidth(),
|
2011-11-11 14:22:11 -05:00
|
|
|
GetOutputSizePixel().Height() - 2 * DWBORDER);
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.GetLineNumberWindow().SetPosSizePixel(Point(DWBORDER + 19, DWBORDER), aLnSz);
|
|
|
|
rModulWindow.GetLineNumberWindow().Invalidate();
|
2011-11-11 14:22:11 -05:00
|
|
|
|
2004-11-15 15:38:31 +00:00
|
|
|
if ( bDoSyntaxHighlight )
|
|
|
|
{
|
|
|
|
String aDummy;
|
|
|
|
aHighlighter.notifyChange( nPara, bInserted ? 1 : (-1), &aDummy, 1 );
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
void EditorWindow::CreateProgress( const String& rText, sal_uLong nRange )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( !pProgress, "ProgressInfo existiert schon" );
|
2012-09-02 16:21:08 +02:00
|
|
|
pProgress.reset(new ProgressInfo(
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
GetShell()->GetViewFrame()->GetObjectShell(),
|
|
|
|
rText,
|
|
|
|
nRange
|
2012-09-02 16:21:08 +02:00
|
|
|
));
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::DestroyProgress()
|
|
|
|
{
|
2012-09-02 16:21:08 +02:00
|
|
|
pProgress.reset();
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::ForceSyntaxTimeout()
|
|
|
|
{
|
|
|
|
aSyntaxIdleTimer.Stop();
|
2012-09-02 16:21:08 +02:00
|
|
|
aSyntaxIdleTimer.GetTimeoutHdl().Call(&aSyntaxIdleTimer);
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
//
|
|
|
|
// BreakPointWindow
|
|
|
|
// ================
|
|
|
|
//
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
BreakPointWindow::BreakPointWindow (Window* pParent, ModulWindow* pModulWindow) :
|
|
|
|
Window(pParent, WB_BORDER),
|
|
|
|
rModulWindow(*pModulWindow),
|
|
|
|
nCurYOffset(0), // memorize nCurYOffset and not take it from EditEngine
|
2012-09-02 16:21:08 +02:00
|
|
|
nMarkerPos(NoMarker)
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2002-07-05 09:22:53 +00:00
|
|
|
setBackgroundColor(GetSettings().GetStyleSettings().GetFieldColor());
|
2012-08-17 07:29:20 +02:00
|
|
|
SetHelpId(HID_BASICIDE_BREAKPOINTWINDOW);
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
BreakPointWindow::~BreakPointWindow()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void BreakPointWindow::Paint( const Rectangle& )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( SyncYOffset() )
|
|
|
|
return;
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
Size const aOutSz = GetOutputSize();
|
|
|
|
long const nLineHeight = GetTextHeight();
|
2011-11-21 20:13:24 -05:00
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
Image const aBrk[2] = { GetImage(IMGID_BRKDISABLED), GetImage(IMGID_BRKENABLED) };
|
|
|
|
Size const aBmpSz = PixelToLogic(aBrk[1].GetSizePixel());
|
|
|
|
Point const aBmpOff(
|
|
|
|
(aOutSz.Width() - aBmpSz.Width()) / 2,
|
|
|
|
(nLineHeight - aBmpSz.Height()) / 2
|
|
|
|
);
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
for (size_t i = 0, n = GetBreakPoints().size(); i < n; ++i)
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-08-17 07:29:20 +02:00
|
|
|
BreakPoint& rBrk = *GetBreakPoints().at(i);
|
|
|
|
size_t const nLine = rBrk.nLine - 1;
|
|
|
|
size_t const nY = nLine*nLineHeight - nCurYOffset;
|
|
|
|
DrawImage(Point(0, nY) + aBmpOff, aBrk[rBrk.bEnabled]);
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
2012-08-17 07:29:20 +02:00
|
|
|
ShowMarker(true);
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-01-16 15:28:54 +00:00
|
|
|
void BreakPointWindow::DoScroll( long nHorzScroll, long nVertScroll )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
nCurYOffset -= nVertScroll;
|
|
|
|
Window::Scroll( nHorzScroll, nVertScroll );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-20 06:11:34 +09:00
|
|
|
void BreakPointWindow::SetMarkerPos( sal_uInt16 nLine, bool bError )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( SyncYOffset() )
|
|
|
|
Update();
|
|
|
|
|
2012-07-20 06:11:34 +09:00
|
|
|
ShowMarker( false );
|
2000-09-29 10:02:42 +00:00
|
|
|
nMarkerPos = nLine;
|
|
|
|
bErrorMarker = bError;
|
2012-07-20 06:11:34 +09:00
|
|
|
ShowMarker( true );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
void BreakPointWindow::SetNoMarker ()
|
|
|
|
{
|
|
|
|
SetMarkerPos(NoMarker);
|
|
|
|
}
|
|
|
|
|
2012-07-20 06:11:34 +09:00
|
|
|
void BreakPointWindow::ShowMarker( bool bShow )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-09-02 16:21:08 +02:00
|
|
|
if ( nMarkerPos == NoMarker )
|
2000-09-29 10:02:42 +00:00
|
|
|
return;
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
Size const aOutSz = GetOutputSize();
|
|
|
|
long const nLineHeight = GetTextHeight();
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
Image aMarker = GetImage(bErrorMarker ? IMGID_ERRORMARKER : IMGID_STEPMARKER);
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
Size aMarkerSz( aMarker.GetSizePixel() );
|
|
|
|
aMarkerSz = PixelToLogic( aMarkerSz );
|
|
|
|
Point aMarkerOff( 0, 0 );
|
|
|
|
aMarkerOff.X() = ( aOutSz.Width() - aMarkerSz.Width() ) / 2;
|
|
|
|
aMarkerOff.Y() = ( nLineHeight - aMarkerSz.Height() ) / 2;
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uLong nY = nMarkerPos*nLineHeight - nCurYOffset;
|
2000-09-29 10:02:42 +00:00
|
|
|
Point aPos( 0, nY );
|
|
|
|
aPos += aMarkerOff;
|
|
|
|
if ( bShow )
|
|
|
|
DrawImage( aPos, aMarker );
|
|
|
|
else
|
|
|
|
Invalidate( Rectangle( aPos, aMarkerSz ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BreakPoint* BreakPointWindow::FindBreakPoint( const Point& rMousePos )
|
|
|
|
{
|
2010-12-11 07:39:25 -08:00
|
|
|
size_t nLineHeight = GetTextHeight();
|
|
|
|
size_t nYPos = rMousePos.Y() + nCurYOffset;
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2010-12-11 07:39:25 -08:00
|
|
|
for ( size_t i = 0, n = GetBreakPoints().size(); i < n ; ++i )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2010-12-11 07:39:25 -08:00
|
|
|
BreakPoint* pBrk = GetBreakPoints().at( i );
|
|
|
|
size_t nLine = pBrk->nLine-1;
|
|
|
|
size_t nY = nLine*nLineHeight;
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( ( nYPos > nY ) && ( nYPos < ( nY + nLineHeight ) ) )
|
|
|
|
return pBrk;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void BreakPointWindow::MouseButtonDown( const MouseEvent& rMEvt )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( rMEvt.GetClicks() == 2 )
|
|
|
|
{
|
|
|
|
Point aMousePos( PixelToLogic( rMEvt.GetPosPixel() ) );
|
|
|
|
long nLineHeight = GetTextHeight();
|
|
|
|
long nYPos = aMousePos.Y() + nCurYOffset;
|
|
|
|
long nLine = nYPos / nLineHeight + 1;
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.ToggleBreakPoint( (sal_uLong)nLine );
|
2000-09-29 10:02:42 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void BreakPointWindow::Command( const CommandEvent& rCEvt )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
|
|
|
|
{
|
|
|
|
Point aPos( rCEvt.IsMouseEvent() ? rCEvt.GetMousePosPixel() : Point(1,1) );
|
|
|
|
Point aEventPos( PixelToLogic( aPos ) );
|
|
|
|
BreakPoint* pBrk = rCEvt.IsMouseEvent() ? FindBreakPoint( aEventPos ) : 0;
|
|
|
|
if ( pBrk )
|
|
|
|
{
|
2011-08-22 11:39:37 +02:00
|
|
|
// test if break point is enabled...
|
2000-09-29 10:02:42 +00:00
|
|
|
PopupMenu aBrkPropMenu( IDEResId( RID_POPUP_BRKPROPS ) );
|
|
|
|
aBrkPropMenu.CheckItem( RID_ACTIV, pBrk->bEnabled );
|
|
|
|
switch ( aBrkPropMenu.Execute( this, aPos ) )
|
|
|
|
{
|
|
|
|
case RID_ACTIV:
|
|
|
|
{
|
2012-08-07 08:36:40 +02:00
|
|
|
pBrk->bEnabled = !pBrk->bEnabled;
|
2012-08-17 07:29:20 +02:00
|
|
|
rModulWindow.UpdateBreakPoint( *pBrk );
|
2000-09-29 10:02:42 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RID_BRKPROPS:
|
|
|
|
{
|
|
|
|
BreakPointDialog aBrkDlg( this, GetBreakPoints() );
|
2003-11-05 11:38:14 +00:00
|
|
|
aBrkDlg.SetCurrentBreakPoint( pBrk );
|
2000-09-29 10:02:42 +00:00
|
|
|
aBrkDlg.Execute();
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PopupMenu aBrkListMenu( IDEResId( RID_POPUP_BRKDLG ) );
|
|
|
|
switch ( aBrkListMenu.Execute( this, aPos ) )
|
|
|
|
{
|
|
|
|
case RID_BRKDLG:
|
|
|
|
{
|
|
|
|
BreakPointDialog aBrkDlg( this, GetBreakPoints() );
|
|
|
|
aBrkDlg.Execute();
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-20 06:11:34 +09:00
|
|
|
bool BreakPointWindow::SyncYOffset()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-08-17 07:29:20 +02:00
|
|
|
TextView* pView = rModulWindow.GetEditView();
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( pView )
|
|
|
|
{
|
|
|
|
long nViewYOffset = pView->GetStartDocPos().Y();
|
|
|
|
if ( nCurYOffset != nViewYOffset )
|
|
|
|
{
|
|
|
|
nCurYOffset = nViewYOffset;
|
|
|
|
Invalidate();
|
2012-07-20 06:11:34 +09:00
|
|
|
return true;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
2012-07-20 06:11:34 +09:00
|
|
|
return false;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2002-07-05 09:22:53 +00:00
|
|
|
// virtual
|
|
|
|
void BreakPointWindow::DataChanged(DataChangedEvent const & rDCEvt)
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2002-07-05 09:22:53 +00:00
|
|
|
Window::DataChanged(rDCEvt);
|
|
|
|
if (rDCEvt.GetType() == DATACHANGED_SETTINGS
|
|
|
|
&& (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0)
|
|
|
|
{
|
|
|
|
Color aColor(GetSettings().GetStyleSettings().GetFieldColor());
|
|
|
|
if (aColor
|
|
|
|
!= rDCEvt.GetOldSettings()->GetStyleSettings().GetFieldColor())
|
|
|
|
{
|
|
|
|
setBackgroundColor(aColor);
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2002-07-05 09:22:53 +00:00
|
|
|
void BreakPointWindow::setBackgroundColor(Color aColor)
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2002-07-05 09:22:53 +00:00
|
|
|
SetBackground(Wallpaper(aColor));
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2004-07-23 09:11:25 +00:00
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
//
|
|
|
|
// WatchWindow
|
|
|
|
// ===========
|
|
|
|
//
|
2004-07-23 09:11:25 +00:00
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
const sal_uInt16 ITEM_ID_VARIABLE = 1;
|
|
|
|
const sal_uInt16 ITEM_ID_VALUE = 2;
|
|
|
|
const sal_uInt16 ITEM_ID_TYPE = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
WatchWindow::WatchWindow (Layout* pParent) :
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
DockingWindow(pParent),
|
2007-01-16 15:28:54 +00:00
|
|
|
aWatchStr( IDEResId( RID_STR_REMOVEWATCH ) ),
|
|
|
|
aXEdit( this, IDEResId( RID_EDT_WATCHEDIT ) ),
|
|
|
|
aRemoveWatchButton( this, IDEResId( RID_IMGBTN_REMOVEWATCH ) ),
|
2004-07-23 09:11:25 +00:00
|
|
|
aTreeListBox( this, WB_BORDER | WB_3DLOOK | WB_HASBUTTONS | WB_HASLINES | WB_HSCROLL | WB_TABSTOP
|
|
|
|
| WB_HASLINESATROOT | WB_HASBUTTONSATROOT ),
|
2007-01-16 15:28:54 +00:00
|
|
|
aHeaderBar( this, WB_BUTTONSTYLE | WB_BORDER )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-01-19 18:42:37 +01:00
|
|
|
aXEdit.SetAccessibleName(String(IDEResId( RID_STR_WATCHNAME)));
|
|
|
|
aTreeListBox.SetAccessibleName(String(IDEResId(RID_STR_WATCHNAME)));
|
|
|
|
|
2012-02-13 16:06:03 +01:00
|
|
|
long nTextLen = GetTextWidth( aWatchStr ) + DWBORDER + 3;
|
|
|
|
aXEdit.SetPosPixel( Point( nTextLen, 3 ) );
|
|
|
|
aXEdit.SetAccHdl( LINK( this, WatchWindow, EditAccHdl ) );
|
|
|
|
aXEdit.GetAccelerator().InsertItem( 1, KeyCode( KEY_RETURN ) );
|
|
|
|
aXEdit.GetAccelerator().InsertItem( 2, KeyCode( KEY_ESCAPE ) );
|
|
|
|
aXEdit.Show();
|
|
|
|
|
|
|
|
aRemoveWatchButton.Disable();
|
|
|
|
aRemoveWatchButton.SetClickHdl( LINK( this, WatchWindow, ButtonHdl ) );
|
|
|
|
aRemoveWatchButton.SetPosPixel( Point( nTextLen + aXEdit.GetSizePixel().Width() + 4, 2 ) );
|
|
|
|
Size aSz( aRemoveWatchButton.GetModeImage().GetSizePixel() );
|
|
|
|
aSz.Width() += 6;
|
|
|
|
aSz.Height() += 6;
|
|
|
|
aRemoveWatchButton.SetSizePixel( aSz );
|
|
|
|
aRemoveWatchButton.Show();
|
|
|
|
|
|
|
|
long nRWBtnSize = aRemoveWatchButton.GetModeImage().GetSizePixel().Height() + 10;
|
2000-09-29 10:02:42 +00:00
|
|
|
nVirtToolBoxHeight = aXEdit.GetSizePixel().Height() + 7;
|
2012-02-13 16:06:03 +01:00
|
|
|
|
|
|
|
if ( nRWBtnSize > nVirtToolBoxHeight )
|
|
|
|
nVirtToolBoxHeight = nRWBtnSize;
|
|
|
|
|
2004-07-23 09:11:25 +00:00
|
|
|
nHeaderBarHeight = 16;
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2002-07-09 13:49:04 +00:00
|
|
|
aTreeListBox.SetHelpId(HID_BASICIDE_WATCHWINDOW_LIST);
|
2012-08-07 08:36:40 +02:00
|
|
|
aTreeListBox.EnableInplaceEditing(true);
|
2000-09-29 10:02:42 +00:00
|
|
|
aTreeListBox.SetSelectHdl( LINK( this, WatchWindow, TreeListHdl ) );
|
2004-07-23 09:11:25 +00:00
|
|
|
aTreeListBox.SetPosPixel( Point( DWBORDER, nVirtToolBoxHeight + nHeaderBarHeight ) );
|
|
|
|
aTreeListBox.SetHighlightRange( 1, 5 );
|
|
|
|
|
|
|
|
Point aPnt( DWBORDER, nVirtToolBoxHeight + 1 );
|
|
|
|
aHeaderBar.SetPosPixel( aPnt );
|
|
|
|
aHeaderBar.SetEndDragHdl( LINK( this, WatchWindow, implEndDragHdl ) );
|
|
|
|
|
2005-01-13 16:25:04 +00:00
|
|
|
long nVarTabWidth = 220;
|
|
|
|
long nValueTabWidth = 100;
|
|
|
|
long nTypeTabWidth = 1250;
|
|
|
|
aHeaderBar.InsertItem( ITEM_ID_VARIABLE, String( IDEResId( RID_STR_WATCHVARIABLE ) ), nVarTabWidth );
|
|
|
|
aHeaderBar.InsertItem( ITEM_ID_VALUE, String( IDEResId( RID_STR_WATCHVALUE ) ), nValueTabWidth );
|
|
|
|
aHeaderBar.InsertItem( ITEM_ID_TYPE, String( IDEResId( RID_STR_WATCHTYPE ) ), nTypeTabWidth );
|
|
|
|
|
|
|
|
long tabs[ 4 ];
|
2004-07-23 09:11:25 +00:00
|
|
|
tabs[ 0 ] = 3; // two tabs
|
|
|
|
tabs[ 1 ] = 0;
|
|
|
|
tabs[ 2 ] = nVarTabWidth;
|
|
|
|
tabs[ 3 ] = nVarTabWidth + nValueTabWidth;
|
|
|
|
aTreeListBox.SvHeaderTabListBox::SetTabs( tabs, MAP_PIXEL );
|
|
|
|
aTreeListBox.InitHeaderBar( &aHeaderBar );
|
|
|
|
|
|
|
|
aTreeListBox.SetNodeDefaultImages( );
|
|
|
|
|
|
|
|
aHeaderBar.Show();
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
aTreeListBox.Show();
|
|
|
|
|
|
|
|
SetText( String( IDEResId( RID_STR_WATCHNAME ) ) );
|
2002-04-17 07:47:27 +00:00
|
|
|
|
2002-05-02 12:41:52 +00:00
|
|
|
SetHelpId( HID_BASICIDE_WATCHWINDOW );
|
|
|
|
|
2002-04-17 07:47:27 +00:00
|
|
|
// make watch window keyboard accessible
|
|
|
|
GetSystemWindow()->GetTaskPaneList()->AddWindow( this );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
WatchWindow::~WatchWindow()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2002-04-17 07:47:27 +00:00
|
|
|
GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void WatchWindow::Paint( const Rectangle& )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DrawText( Point( DWBORDER, 7 ), aWatchStr );
|
|
|
|
lcl_DrawIDEWindowFrame( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void WatchWindow::Resize()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
Size aSz = GetOutputSizePixel();
|
|
|
|
Size aBoxSz( aSz.Width() - 2*DWBORDER, aSz.Height() - nVirtToolBoxHeight - DWBORDER );
|
|
|
|
|
2011-08-22 11:39:37 +02:00
|
|
|
if ( aBoxSz.Width() < 4 )
|
2000-09-29 10:02:42 +00:00
|
|
|
aBoxSz.Width() = 0;
|
|
|
|
if ( aBoxSz.Height() < 4 )
|
|
|
|
aBoxSz.Height() = 0;
|
|
|
|
|
2004-07-23 09:11:25 +00:00
|
|
|
aBoxSz.Height() -= nHeaderBarHeight;
|
2000-09-29 10:02:42 +00:00
|
|
|
aTreeListBox.SetSizePixel( aBoxSz );
|
2001-10-04 15:49:24 +00:00
|
|
|
aTreeListBox.GetHScroll()->SetPageSize( aTreeListBox.GetHScroll()->GetVisibleSize() );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2004-07-23 09:11:25 +00:00
|
|
|
aBoxSz.Height() = nHeaderBarHeight;
|
|
|
|
aHeaderBar.SetSizePixel( aBoxSz );
|
|
|
|
|
2011-08-22 11:39:37 +02:00
|
|
|
Invalidate();
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2004-07-23 09:11:25 +00:00
|
|
|
struct WatchItem
|
|
|
|
{
|
|
|
|
String maName;
|
2005-01-13 17:50:52 +00:00
|
|
|
String maDisplayName;
|
2004-07-23 09:11:25 +00:00
|
|
|
SbxObjectRef mpObject;
|
2012-09-02 16:21:08 +02:00
|
|
|
std::vector<String> maMemberList;
|
2004-07-23 09:11:25 +00:00
|
|
|
|
|
|
|
SbxDimArrayRef mpArray;
|
|
|
|
int nDimLevel; // 0 = Root
|
|
|
|
int nDimCount;
|
2012-09-02 16:21:08 +02:00
|
|
|
std::vector<short> vIndices;
|
2004-07-23 09:11:25 +00:00
|
|
|
|
2005-01-13 17:50:52 +00:00
|
|
|
WatchItem* mpArrayParentItem;
|
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
WatchItem (String const& rName):
|
|
|
|
maName(rName),
|
|
|
|
nDimLevel(0),
|
|
|
|
nDimCount(0),
|
|
|
|
mpArrayParentItem(0)
|
|
|
|
{ }
|
2004-07-23 09:11:25 +00:00
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
void clearWatchItem ()
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
|
|
|
maMemberList.clear();
|
|
|
|
}
|
|
|
|
|
2005-01-13 17:50:52 +00:00
|
|
|
WatchItem* GetRootItem( void );
|
|
|
|
SbxDimArray* GetRootArray( void );
|
2004-07-23 09:11:25 +00:00
|
|
|
};
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2005-01-13 17:50:52 +00:00
|
|
|
WatchItem* WatchItem::GetRootItem( void )
|
|
|
|
{
|
|
|
|
WatchItem* pItem = mpArrayParentItem;
|
|
|
|
while( pItem )
|
|
|
|
{
|
|
|
|
if( pItem->mpArray.Is() )
|
|
|
|
break;
|
|
|
|
pItem = pItem->mpArrayParentItem;
|
|
|
|
}
|
|
|
|
return pItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
SbxDimArray* WatchItem::GetRootArray( void )
|
|
|
|
{
|
|
|
|
WatchItem* pRootItem = GetRootItem();
|
2005-01-17 13:24:52 +00:00
|
|
|
SbxDimArray* pRet = NULL;
|
|
|
|
if( pRootItem )
|
|
|
|
pRet = pRootItem->mpArray;
|
2005-01-13 17:50:52 +00:00
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
void WatchWindow::AddWatch( const String& rVName )
|
|
|
|
{
|
2004-07-23 09:11:25 +00:00
|
|
|
String aVar, aIndex;
|
|
|
|
lcl_SeparateNameAndIndex( rVName, aVar, aIndex );
|
2012-09-02 16:21:08 +02:00
|
|
|
WatchItem* pWatchItem = new WatchItem(aVar);
|
2004-07-23 09:11:25 +00:00
|
|
|
|
2012-09-26 23:07:35 -03:00
|
|
|
OUString aWatchStr_( aVar );
|
|
|
|
aWatchStr_ += OUString( "\t\t" );
|
2012-08-07 08:36:40 +02:00
|
|
|
SvLBoxEntry* pNewEntry = aTreeListBox.InsertEntry( aWatchStr_, 0, true, LIST_APPEND );
|
2004-07-23 09:11:25 +00:00
|
|
|
pNewEntry->SetUserData( pWatchItem );
|
|
|
|
|
2012-08-07 08:36:40 +02:00
|
|
|
aTreeListBox.Select(pNewEntry, true);
|
|
|
|
aTreeListBox.MakeVisible(pNewEntry);
|
2000-09-29 10:02:42 +00:00
|
|
|
aRemoveWatchButton.Enable();
|
2012-08-17 07:29:20 +02:00
|
|
|
|
|
|
|
UpdateWatches();
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2012-07-20 06:11:34 +09:00
|
|
|
bool WatchWindow::RemoveSelectedWatch()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
SvLBoxEntry* pEntry = aTreeListBox.GetCurEntry();
|
|
|
|
if ( pEntry )
|
|
|
|
{
|
|
|
|
aTreeListBox.GetModel()->Remove( pEntry );
|
|
|
|
pEntry = aTreeListBox.GetCurEntry();
|
|
|
|
if ( pEntry )
|
2004-07-23 09:11:25 +00:00
|
|
|
aXEdit.SetText( ((WatchItem*)pEntry->GetUserData())->maName );
|
2000-09-29 10:02:42 +00:00
|
|
|
else
|
|
|
|
aXEdit.SetText( String() );
|
|
|
|
if ( !aTreeListBox.GetEntryCount() )
|
|
|
|
aRemoveWatchButton.Disable();
|
2012-07-20 06:11:34 +09:00
|
|
|
return true;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
else
|
2012-07-20 06:11:34 +09:00
|
|
|
return false;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IMPL_LINK_INLINE_START( WatchWindow, ButtonHdl, ImageButton *, pButton )
|
|
|
|
{
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
if (pButton == &aRemoveWatchButton)
|
|
|
|
if (SfxDispatcher* pDispatcher = GetDispatcher())
|
|
|
|
pDispatcher->Execute(SID_BASICIDE_REMOVEWATCH);
|
2000-09-29 10:02:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
IMPL_LINK_INLINE_END( WatchWindow, ButtonHdl, ImageButton *, pButton )
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG_INLINE_START(WatchWindow, TreeListHdl)
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
SvLBoxEntry* pCurEntry = aTreeListBox.GetCurEntry();
|
|
|
|
if ( pCurEntry && pCurEntry->GetUserData() )
|
2004-07-23 09:11:25 +00:00
|
|
|
aXEdit.SetText( ((WatchItem*)pCurEntry->GetUserData())->maName );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG_INLINE_END(WatchWindow, TreeListHdl)
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
|
2004-07-23 09:11:25 +00:00
|
|
|
IMPL_LINK_INLINE_START( WatchWindow, implEndDragHdl, HeaderBar *, pBar )
|
|
|
|
{
|
2007-01-16 15:28:54 +00:00
|
|
|
(void)pBar;
|
|
|
|
|
2004-07-23 09:11:25 +00:00
|
|
|
const sal_Int32 TAB_WIDTH_MIN = 10;
|
|
|
|
sal_Int32 nMaxWidth =
|
|
|
|
aHeaderBar.GetSizePixel().getWidth() - 2 * TAB_WIDTH_MIN;
|
|
|
|
|
|
|
|
sal_Int32 nVariableWith = aHeaderBar.GetItemSize( ITEM_ID_VARIABLE );
|
|
|
|
if( nVariableWith < TAB_WIDTH_MIN )
|
|
|
|
aHeaderBar.SetItemSize( ITEM_ID_VARIABLE, TAB_WIDTH_MIN );
|
|
|
|
else if( nVariableWith > nMaxWidth )
|
|
|
|
aHeaderBar.SetItemSize( ITEM_ID_VARIABLE, nMaxWidth );
|
|
|
|
|
|
|
|
sal_Int32 nValueWith = aHeaderBar.GetItemSize( ITEM_ID_VALUE );
|
|
|
|
if( nValueWith < TAB_WIDTH_MIN )
|
|
|
|
aHeaderBar.SetItemSize( ITEM_ID_VALUE, TAB_WIDTH_MIN );
|
|
|
|
else if( nValueWith > nMaxWidth )
|
|
|
|
aHeaderBar.SetItemSize( ITEM_ID_VALUE, nMaxWidth );
|
|
|
|
|
|
|
|
if (aHeaderBar.GetItemSize( ITEM_ID_TYPE ) < TAB_WIDTH_MIN)
|
|
|
|
aHeaderBar.SetItemSize( ITEM_ID_TYPE, TAB_WIDTH_MIN );
|
|
|
|
|
|
|
|
sal_Int32 nPos = 0;
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nTabs = aHeaderBar.GetItemCount();
|
|
|
|
for( sal_uInt16 i = 1 ; i < nTabs ; ++i )
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
|
|
|
nPos += aHeaderBar.GetItemSize( i );
|
|
|
|
aTreeListBox.SetTab( i, nPos, MAP_PIXEL );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
IMPL_LINK_INLINE_END( WatchWindow, implEndDragHdl, HeaderBar *, pBar )
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
IMPL_LINK( WatchWindow, EditAccHdl, Accelerator *, pAcc )
|
|
|
|
{
|
|
|
|
switch ( pAcc->GetCurKeyCode().GetCode() )
|
|
|
|
{
|
|
|
|
case KEY_RETURN:
|
|
|
|
{
|
|
|
|
String aCurText( aXEdit.GetText() );
|
|
|
|
if ( aCurText.Len() )
|
|
|
|
{
|
|
|
|
AddWatch( aCurText );
|
|
|
|
aXEdit.SetSelection( Selection( 0, 0xFFFF ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KEY_ESCAPE:
|
|
|
|
{
|
|
|
|
aXEdit.SetText( String() );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-23 09:11:25 +00:00
|
|
|
void WatchWindow::UpdateWatches( bool bBasicStopped )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2004-07-23 09:11:25 +00:00
|
|
|
aTreeListBox.UpdateWatches( bBasicStopped );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
//
|
|
|
|
// StackWindow
|
|
|
|
// ===========
|
|
|
|
//
|
|
|
|
|
|
|
|
StackWindow::StackWindow (Layout* pParent) :
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
DockingWindow(pParent),
|
2002-04-17 07:47:27 +00:00
|
|
|
aTreeListBox( this, WB_BORDER | WB_3DLOOK | WB_HSCROLL | WB_TABSTOP ),
|
2000-09-29 10:02:42 +00:00
|
|
|
aStackStr( IDEResId( RID_STR_STACK ) )
|
|
|
|
{
|
2012-08-06 14:28:28 +02:00
|
|
|
aTreeListBox.SetHelpId(HID_BASICIDE_STACKWINDOW_LIST);
|
2011-01-19 18:42:37 +01:00
|
|
|
aTreeListBox.SetAccessibleName(String( IDEResId(RID_STR_STACKNAME)));
|
2000-09-29 10:02:42 +00:00
|
|
|
aTreeListBox.SetPosPixel( Point( DWBORDER, nVirtToolBoxHeight ) );
|
|
|
|
aTreeListBox.SetHighlightRange();
|
2003-11-05 11:38:14 +00:00
|
|
|
aTreeListBox.SetSelectionMode( NO_SELECTION );
|
2012-08-07 08:36:40 +02:00
|
|
|
aTreeListBox.InsertEntry( String(), 0, false, LIST_APPEND );
|
2000-09-29 10:02:42 +00:00
|
|
|
aTreeListBox.Show();
|
|
|
|
|
|
|
|
SetText( String( IDEResId( RID_STR_STACKNAME ) ) );
|
|
|
|
|
2002-05-02 12:41:52 +00:00
|
|
|
SetHelpId( HID_BASICIDE_STACKWINDOW );
|
|
|
|
|
2002-04-17 07:47:27 +00:00
|
|
|
// make stack window keyboard accessible
|
|
|
|
GetSystemWindow()->GetTaskPaneList()->AddWindow( this );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
StackWindow::~StackWindow()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2002-04-17 07:47:27 +00:00
|
|
|
GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void StackWindow::Paint( const Rectangle& )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DrawText( Point( DWBORDER, 7 ), aStackStr );
|
|
|
|
lcl_DrawIDEWindowFrame( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void StackWindow::Resize()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
Size aSz = GetOutputSizePixel();
|
|
|
|
Size aBoxSz( aSz.Width() - 2*DWBORDER, aSz.Height() - nVirtToolBoxHeight - DWBORDER );
|
|
|
|
|
2011-08-22 11:39:37 +02:00
|
|
|
if ( aBoxSz.Width() < 4 )
|
2000-09-29 10:02:42 +00:00
|
|
|
aBoxSz.Width() = 0;
|
|
|
|
if ( aBoxSz.Height() < 4 )
|
|
|
|
aBoxSz.Height() = 0;
|
|
|
|
|
|
|
|
aTreeListBox.SetSizePixel( aBoxSz );
|
|
|
|
|
2011-08-22 11:39:37 +02:00
|
|
|
Invalidate();
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void StackWindow::UpdateCalls()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-08-07 08:36:40 +02:00
|
|
|
aTreeListBox.SetUpdateMode(false);
|
2000-09-29 10:02:42 +00:00
|
|
|
aTreeListBox.Clear();
|
|
|
|
|
2003-11-05 11:38:14 +00:00
|
|
|
if ( StarBASIC::IsRunning() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2003-11-05 11:38:14 +00:00
|
|
|
SbxError eOld = SbxBase::GetError();
|
|
|
|
aTreeListBox.SetSelectionMode( SINGLE_SELECTION );
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nScope = 0;
|
2003-11-05 11:38:14 +00:00
|
|
|
SbMethod* pMethod = StarBASIC::GetActiveMethod( nScope );
|
|
|
|
while ( pMethod )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2003-11-05 11:38:14 +00:00
|
|
|
String aEntry( String::CreateFromInt32(nScope ));
|
|
|
|
if ( aEntry.Len() < 2 )
|
|
|
|
aEntry.Insert( ' ', 0 );
|
2012-09-26 23:07:35 -03:00
|
|
|
aEntry += OUString( ": " );
|
2003-11-05 11:38:14 +00:00
|
|
|
aEntry += pMethod->GetName();
|
|
|
|
SbxArray* pParams = pMethod->GetParameters();
|
|
|
|
SbxInfo* pInfo = pMethod->GetInfo();
|
|
|
|
if ( pParams )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2003-11-05 11:38:14 +00:00
|
|
|
aEntry += '(';
|
2011-08-22 11:39:37 +02:00
|
|
|
// 0 is the sub's name...
|
2011-01-14 11:16:25 +01:00
|
|
|
for ( sal_uInt16 nParam = 1; nParam < pParams->Count(); nParam++ )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2003-11-05 11:38:14 +00:00
|
|
|
SbxVariable* pVar = pParams->Get( nParam );
|
|
|
|
DBG_ASSERT( pVar, "Parameter?!" );
|
|
|
|
if ( pVar->GetName().Len() )
|
|
|
|
aEntry += pVar->GetName();
|
|
|
|
else if ( pInfo )
|
|
|
|
{
|
|
|
|
const SbxParamInfo* pParam = pInfo->GetParam( nParam );
|
|
|
|
if ( pParam )
|
|
|
|
aEntry += pParam->aName;
|
|
|
|
}
|
|
|
|
aEntry += '=';
|
2010-09-15 15:07:53 +02:00
|
|
|
SbxDataType eType = pVar->GetType();
|
|
|
|
if( eType & SbxARRAY )
|
2012-09-26 23:07:35 -03:00
|
|
|
aEntry += OUString( "..." );
|
2010-09-15 15:07:53 +02:00
|
|
|
else if( eType != SbxOBJECT )
|
2003-11-05 11:38:14 +00:00
|
|
|
aEntry += pVar->GetString();
|
|
|
|
if ( nParam < ( pParams->Count() - 1 ) )
|
2012-09-26 23:07:35 -03:00
|
|
|
aEntry += OUString( ", " );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
2003-11-05 11:38:14 +00:00
|
|
|
aEntry += ')';
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
2012-08-07 08:36:40 +02:00
|
|
|
aTreeListBox.InsertEntry( aEntry, 0, false, LIST_APPEND );
|
2003-11-05 11:38:14 +00:00
|
|
|
nScope++;
|
|
|
|
pMethod = StarBASIC::GetActiveMethod( nScope );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2003-11-05 11:38:14 +00:00
|
|
|
SbxBase::ResetError();
|
|
|
|
if( eOld != SbxERR_OK )
|
|
|
|
SbxBase::SetError( eOld );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aTreeListBox.SetSelectionMode( NO_SELECTION );
|
2012-08-07 08:36:40 +02:00
|
|
|
aTreeListBox.InsertEntry( String(), 0, false, LIST_APPEND );
|
2003-11-05 11:38:14 +00:00
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-08-07 08:36:40 +02:00
|
|
|
aTreeListBox.SetUpdateMode(true);
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// ComplexEditorWindow
|
|
|
|
// ===================
|
|
|
|
//
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
ComplexEditorWindow::ComplexEditorWindow( ModulWindow* pParent ) :
|
2002-07-05 09:22:53 +00:00
|
|
|
Window( pParent, WB_3DLOOK | WB_CLIPCHILDREN ),
|
2012-08-17 07:29:20 +02:00
|
|
|
aBrkWindow(this, pParent),
|
|
|
|
aLineNumberWindow(this, pParent),
|
|
|
|
aEdtWindow(this, pParent),
|
|
|
|
aEWVScrollBar( this, WB_VSCROLL | WB_DRAG )
|
|
|
|
{
|
2000-09-29 10:02:42 +00:00
|
|
|
aEdtWindow.Show();
|
|
|
|
aBrkWindow.Show();
|
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
aEWVScrollBar.SetLineSize(nScrollLine);
|
|
|
|
aEWVScrollBar.SetPageSize(nScrollPage);
|
2000-09-29 10:02:42 +00:00
|
|
|
aEWVScrollBar.SetScrollHdl( LINK( this, ComplexEditorWindow, ScrollHdl ) );
|
|
|
|
aEWVScrollBar.Show();
|
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ComplexEditorWindow::Resize()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
Size aOutSz = GetOutputSizePixel();
|
|
|
|
Size aSz( aOutSz );
|
|
|
|
aSz.Width() -= 2*DWBORDER;
|
|
|
|
aSz.Height() -= 2*DWBORDER;
|
|
|
|
long nBrkWidth = 20;
|
|
|
|
long nSBWidth = aEWVScrollBar.GetSizePixel().Width();
|
|
|
|
|
2011-11-11 14:22:11 -05:00
|
|
|
Size aBrkSz(nBrkWidth, aSz.Height());
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2011-11-11 14:22:11 -05:00
|
|
|
Size aLnSz(aLineNumberWindow.GetWidth(), aSz.Height());
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
if (aLineNumberWindow.IsVisible())
|
2011-11-16 16:45:38 -05:00
|
|
|
{
|
2012-03-11 21:40:02 +01:00
|
|
|
aBrkWindow.SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz );
|
|
|
|
aLineNumberWindow.SetPosSizePixel(Point(DWBORDER + aBrkSz.Width() - 1, DWBORDER), aLnSz);
|
2011-11-16 16:45:38 -05:00
|
|
|
Size aEWSz(aSz.Width() - nBrkWidth - aLineNumberWindow.GetWidth() - nSBWidth + 2, aSz.Height());
|
2012-03-11 21:40:02 +01:00
|
|
|
aEdtWindow.SetPosSizePixel( Point( DWBORDER + aBrkSz.Width() + aLnSz.Width() - 1, DWBORDER ), aEWSz );
|
2011-11-16 16:45:38 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-11 21:40:02 +01:00
|
|
|
aBrkWindow.SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz );
|
|
|
|
Size aEWSz(aSz.Width() - nBrkWidth - nSBWidth + 2, aSz.Height());
|
2011-11-16 16:45:38 -05:00
|
|
|
aEdtWindow.SetPosSizePixel(Point(DWBORDER + aBrkSz.Width() - 1, DWBORDER), aEWSz);
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-03-11 21:40:02 +01:00
|
|
|
aEWVScrollBar.SetPosSizePixel( Point( aOutSz.Width() - DWBORDER - nSBWidth, DWBORDER ), Size( nSBWidth, aSz.Height() ) );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( ComplexEditorWindow, ScrollHdl, ScrollBar *, pCurScrollBar )
|
|
|
|
{
|
|
|
|
if ( aEdtWindow.GetEditView() )
|
|
|
|
{
|
|
|
|
DBG_ASSERT( pCurScrollBar == &aEWVScrollBar, "Wer scrollt hier ?" );
|
|
|
|
long nDiff = aEdtWindow.GetEditView()->GetStartDocPos().Y() - pCurScrollBar->GetThumbPos();
|
|
|
|
aEdtWindow.GetEditView()->Scroll( 0, nDiff );
|
2007-01-16 15:28:54 +00:00
|
|
|
aBrkWindow.DoScroll( 0, nDiff );
|
2011-11-17 00:19:47 -05:00
|
|
|
aLineNumberWindow.DoScroll(0, nDiff);
|
2012-08-07 08:36:40 +02:00
|
|
|
aEdtWindow.GetEditView()->ShowCursor(false, true);
|
2000-09-29 10:02:42 +00:00
|
|
|
pCurScrollBar->SetThumbPos( aEdtWindow.GetEditView()->GetStartDocPos().Y() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-07-05 09:22:53 +00:00
|
|
|
void ComplexEditorWindow::DataChanged(DataChangedEvent const & rDCEvt)
|
|
|
|
{
|
|
|
|
Window::DataChanged(rDCEvt);
|
|
|
|
if (rDCEvt.GetType() == DATACHANGED_SETTINGS
|
|
|
|
&& (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0)
|
|
|
|
{
|
|
|
|
Color aColor(GetSettings().GetStyleSettings().GetFaceColor());
|
|
|
|
if (aColor
|
|
|
|
!= rDCEvt.GetOldSettings()->GetStyleSettings().GetFaceColor())
|
|
|
|
{
|
|
|
|
SetBackground(Wallpaper(aColor));
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2011-11-16 16:45:38 -05:00
|
|
|
void ComplexEditorWindow::SetLineNumberDisplay(bool b)
|
|
|
|
{
|
2012-08-17 07:29:20 +02:00
|
|
|
aLineNumberWindow.Show(b);
|
2011-11-16 16:45:38 -05:00
|
|
|
Resize();
|
|
|
|
}
|
|
|
|
|
2002-07-24 12:01:28 +00:00
|
|
|
uno::Reference< awt::XWindowPeer >
|
2011-01-14 11:16:25 +01:00
|
|
|
EditorWindow::GetComponentInterface(sal_Bool bCreate)
|
2002-07-24 12:01:28 +00:00
|
|
|
{
|
|
|
|
uno::Reference< awt::XWindowPeer > xPeer(
|
|
|
|
Window::GetComponentInterface(false));
|
|
|
|
if (!xPeer.is() && bCreate)
|
|
|
|
{
|
|
|
|
// Make sure edit engine and view are available:
|
|
|
|
if (!pEditEngine)
|
|
|
|
CreateEditEngine();
|
|
|
|
|
2007-06-27 14:43:02 +00:00
|
|
|
xPeer = new ::svt::TextWindowPeer(*GetEditView());
|
2002-07-24 12:01:28 +00:00
|
|
|
SetComponentInterface(xPeer);
|
|
|
|
}
|
|
|
|
return xPeer;
|
|
|
|
}
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// WatchTreeListBox
|
|
|
|
// ================
|
|
|
|
//
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
WatchTreeListBox::WatchTreeListBox( Window* pParent, WinBits nWinBits )
|
2004-07-23 09:11:25 +00:00
|
|
|
: SvHeaderTabListBox( pParent, nWinBits )
|
|
|
|
{}
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
WatchTreeListBox::~WatchTreeListBox()
|
|
|
|
{
|
2010-11-17 14:35:16 +01:00
|
|
|
// Destroy user data
|
2000-09-29 10:02:42 +00:00
|
|
|
SvLBoxEntry* pEntry = First();
|
|
|
|
while ( pEntry )
|
|
|
|
{
|
2004-07-23 09:11:25 +00:00
|
|
|
delete (WatchItem*)pEntry->GetUserData();
|
2000-09-29 10:02:42 +00:00
|
|
|
pEntry = Next( pEntry );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-23 09:11:25 +00:00
|
|
|
void WatchTreeListBox::SetTabs()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2004-07-23 09:11:25 +00:00
|
|
|
SvHeaderTabListBox::SetTabs();
|
2012-06-28 10:06:59 +02:00
|
|
|
sal_uInt16 nTabCount_ = aTabs.size();
|
2011-01-14 11:16:25 +01:00
|
|
|
for( sal_uInt16 i = 0 ; i < nTabCount_ ; i++ )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-06-28 10:06:59 +02:00
|
|
|
SvLBoxTab* pTab = aTabs[i];
|
2004-07-23 09:11:25 +00:00
|
|
|
if( i == 2 )
|
|
|
|
pTab->nFlags |= SV_LBOXTAB_EDITABLE;
|
2000-09-29 10:02:42 +00:00
|
|
|
else
|
2004-07-23 09:11:25 +00:00
|
|
|
pTab->nFlags &= ~SV_LBOXTAB_EDITABLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-07 02:33:51 -08:00
|
|
|
void WatchTreeListBox::RequestingChildren( SvLBoxEntry * pParent )
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
|
|
|
if( !StarBASIC::IsRunning() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( GetChildCount( pParent ) > 0 )
|
|
|
|
return;
|
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
SvLBoxEntry* pEntry = pParent;
|
2004-07-23 09:11:25 +00:00
|
|
|
WatchItem* pItem = (WatchItem*)pEntry->GetUserData();
|
|
|
|
|
|
|
|
SbxDimArray* pArray = pItem->mpArray;
|
2005-01-13 17:50:52 +00:00
|
|
|
SbxDimArray* pRootArray = pItem->GetRootArray();
|
|
|
|
bool bArrayIsRootArray = false;
|
|
|
|
if( !pArray && pRootArray )
|
|
|
|
{
|
|
|
|
pArray = pRootArray;
|
|
|
|
bArrayIsRootArray = true;
|
|
|
|
}
|
|
|
|
|
2004-07-23 09:11:25 +00:00
|
|
|
SbxObject* pObj = pItem->mpObject;
|
|
|
|
if( pObj )
|
|
|
|
{
|
|
|
|
createAllObjectProperties( pObj );
|
2012-09-02 16:21:08 +02:00
|
|
|
SbxArray* pProps = pObj->GetProperties();
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nPropCount = pProps->Count();
|
2012-09-02 16:21:08 +02:00
|
|
|
pItem->maMemberList.reserve(nPropCount);
|
2004-07-23 09:11:25 +00:00
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
for( sal_uInt16 i = 0 ; i < nPropCount - 3 ; i++ )
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
|
|
|
SbxVariable* pVar = pProps->Get( i );
|
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
pItem->maMemberList.push_back(String(pVar->GetName()));
|
|
|
|
String const& rName = pItem->maMemberList.back();
|
|
|
|
SvLBoxEntry* pChildEntry = SvTreeListBox::InsertEntry( rName, pEntry );
|
|
|
|
pChildEntry->SetUserData(new WatchItem(rName));
|
2004-07-23 09:11:25 +00:00
|
|
|
}
|
|
|
|
if( nPropCount > 0 )
|
|
|
|
{
|
|
|
|
UpdateWatches();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( pArray )
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nElementCount = 0;
|
2004-07-23 09:11:25 +00:00
|
|
|
|
|
|
|
// Loop through indices of current level
|
2005-01-13 17:50:52 +00:00
|
|
|
int nParentLevel = bArrayIsRootArray ? pItem->nDimLevel : 0;
|
2004-07-23 09:11:25 +00:00
|
|
|
int nThisLevel = nParentLevel + 1;
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Int32 nMin, nMax;
|
2007-01-16 15:28:54 +00:00
|
|
|
pArray->GetDim32( nThisLevel, nMin, nMax );
|
2011-01-14 11:16:25 +01:00
|
|
|
for( sal_Int32 i = nMin ; i <= nMax ; i++ )
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
2012-09-02 16:21:08 +02:00
|
|
|
WatchItem* pChildItem = new WatchItem(pItem->maName);
|
2004-07-23 09:11:25 +00:00
|
|
|
|
|
|
|
// Copy data and create name
|
|
|
|
|
2012-09-26 23:07:35 -03:00
|
|
|
String aIndexStr = OUString( "(" );
|
2005-01-13 17:50:52 +00:00
|
|
|
pChildItem->mpArrayParentItem = pItem;
|
|
|
|
pChildItem->nDimLevel = nThisLevel;
|
2004-07-23 09:11:25 +00:00
|
|
|
pChildItem->nDimCount = pItem->nDimCount;
|
2012-09-02 16:21:08 +02:00
|
|
|
pChildItem->vIndices.resize(pChildItem->nDimCount);
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 j;
|
2004-07-23 09:11:25 +00:00
|
|
|
for( j = 0 ; j < nParentLevel ; j++ )
|
|
|
|
{
|
2012-09-02 16:21:08 +02:00
|
|
|
short n = pChildItem->vIndices[j] = pItem->vIndices[j];
|
2005-01-13 17:50:52 +00:00
|
|
|
aIndexStr += String::CreateFromInt32( n );
|
2012-09-26 23:07:35 -03:00
|
|
|
aIndexStr += OUString( "," );
|
2004-07-23 09:11:25 +00:00
|
|
|
}
|
2012-09-02 16:21:08 +02:00
|
|
|
pChildItem->vIndices[nParentLevel] = sal::static_int_cast<short>( i );
|
2005-01-13 17:50:52 +00:00
|
|
|
aIndexStr += String::CreateFromInt32( i );
|
2012-09-26 23:07:35 -03:00
|
|
|
aIndexStr += OUString( ")" );
|
2004-07-23 09:11:25 +00:00
|
|
|
|
2005-01-13 17:50:52 +00:00
|
|
|
String aDisplayName;
|
|
|
|
WatchItem* pArrayRootItem = pChildItem->GetRootItem();
|
|
|
|
if( pArrayRootItem && pArrayRootItem->mpArrayParentItem )
|
|
|
|
aDisplayName = pItem->maDisplayName;
|
|
|
|
else
|
2012-09-02 16:21:08 +02:00
|
|
|
aDisplayName = pItem->maName;
|
2005-01-13 17:50:52 +00:00
|
|
|
aDisplayName += aIndexStr;
|
|
|
|
pChildItem->maDisplayName = aDisplayName;
|
|
|
|
|
|
|
|
SvLBoxEntry* pChildEntry = SvTreeListBox::InsertEntry( aDisplayName, pEntry );
|
2004-07-23 09:11:25 +00:00
|
|
|
nElementCount++;
|
|
|
|
pChildEntry->SetUserData( pChildItem );
|
|
|
|
}
|
|
|
|
if( nElementCount > 0 )
|
|
|
|
{
|
|
|
|
UpdateWatches();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SbxBase* WatchTreeListBox::ImplGetSBXForEntry( SvLBoxEntry* pEntry, bool& rbArrayElement )
|
|
|
|
{
|
|
|
|
SbxBase* pSBX = NULL;
|
|
|
|
rbArrayElement = false;
|
|
|
|
|
|
|
|
WatchItem* pItem = (WatchItem*)pEntry->GetUserData();
|
|
|
|
String aVName( pItem->maName );
|
|
|
|
|
|
|
|
SvLBoxEntry* pParentEntry = GetParent( pEntry );
|
|
|
|
WatchItem* pParentItem = pParentEntry ? (WatchItem*)pParentEntry->GetUserData() : NULL;
|
|
|
|
if( pParentItem )
|
|
|
|
{
|
|
|
|
SbxObject* pObj = pParentItem->mpObject;
|
|
|
|
SbxDimArray* pArray;
|
|
|
|
if( pObj )
|
|
|
|
{
|
|
|
|
pSBX = pObj->Find( aVName, SbxCLASS_DONTCARE );
|
2012-08-07 14:33:56 +02:00
|
|
|
if (SbxVariable const* pVar = IsSbxVariable(pSBX))
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
|
|
|
// Force getting value
|
|
|
|
SbxValues aRes;
|
|
|
|
aRes.eType = SbxVOID;
|
|
|
|
pVar->Get( aRes );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Array?
|
2005-01-13 17:50:52 +00:00
|
|
|
else if( (pArray = pItem->GetRootArray()) != NULL )
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
|
|
|
rbArrayElement = true;
|
2005-01-13 17:50:52 +00:00
|
|
|
if( pParentItem->nDimLevel + 1 == pParentItem->nDimCount )
|
2012-09-02 16:21:08 +02:00
|
|
|
pSBX = pArray->Get(pItem->vIndices.empty() ? 0 : &*pItem->vIndices.begin());
|
2004-07-23 09:11:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSBX = StarBASIC::FindSBXInCurrentScope( aVName );
|
|
|
|
}
|
|
|
|
return pSBX;
|
|
|
|
}
|
|
|
|
|
2011-03-09 16:20:50 -06:00
|
|
|
sal_Bool WatchTreeListBox::EditingEntry( SvLBoxEntry* pEntry, Selection& )
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
|
|
|
WatchItem* pItem = (WatchItem*)pEntry->GetUserData();
|
|
|
|
|
2012-08-07 08:36:40 +02:00
|
|
|
bool bEdit = false;
|
2004-07-23 09:11:25 +00:00
|
|
|
if ( StarBASIC::IsRunning() && StarBASIC::GetActiveMethod() && !SbxBase::IsError() )
|
|
|
|
{
|
|
|
|
// No out of scope entries
|
|
|
|
bool bArrayElement;
|
2012-08-07 15:22:25 +02:00
|
|
|
SbxBase* pSbx = ImplGetSBXForEntry( pEntry, bArrayElement );
|
2012-08-07 14:33:56 +02:00
|
|
|
if (IsSbxVariable(pSbx) || bArrayElement)
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
|
|
|
// Accept no objects and only end nodes of arrays for editing
|
|
|
|
if( !pItem->mpObject && (pItem->mpArray == NULL || pItem->nDimLevel == pItem->nDimCount) )
|
|
|
|
{
|
|
|
|
aEditingRes = SvHeaderTabListBox::GetEntryText( pEntry, ITEM_ID_VALUE-1 );
|
2012-06-11 13:15:18 +01:00
|
|
|
aEditingRes = comphelper::string::strip(aEditingRes, ' ');
|
2012-08-07 08:36:40 +02:00
|
|
|
bEdit = true;
|
2004-07-23 09:11:25 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bEdit;
|
|
|
|
}
|
|
|
|
|
2012-09-26 23:07:35 -03:00
|
|
|
sal_Bool WatchTreeListBox::EditedEntry( SvLBoxEntry* pEntry, const OUString& rNewText )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2004-07-23 09:11:25 +00:00
|
|
|
WatchItem* pItem = (WatchItem*)pEntry->GetUserData();
|
|
|
|
String aVName( pItem->maName );
|
|
|
|
|
2012-06-11 13:15:18 +01:00
|
|
|
String aResult = comphelper::string::strip(rNewText, ' ');
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nResultLen = aResult.Len();
|
2004-07-23 09:11:25 +00:00
|
|
|
sal_Unicode cFirst = aResult.GetChar( 0 );
|
|
|
|
sal_Unicode cLast = aResult.GetChar( nResultLen - 1 );
|
|
|
|
if( cFirst == '\"' && cLast == '\"' )
|
|
|
|
aResult = aResult.Copy( 1, nResultLen - 2 );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2012-08-07 08:36:40 +02:00
|
|
|
return aResult != aEditingRes && ImplBasicEntryEdited(pEntry, aResult);
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2012-08-07 08:36:40 +02:00
|
|
|
bool WatchTreeListBox::ImplBasicEntryEdited( SvLBoxEntry* pEntry, const String& rResult )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2004-07-23 09:11:25 +00:00
|
|
|
bool bArrayElement;
|
|
|
|
SbxBase* pSBX = ImplGetSBXForEntry( pEntry, bArrayElement );
|
|
|
|
|
2012-08-07 15:22:25 +02:00
|
|
|
if (SbxVariable* pVar = IsSbxVariable(pSBX))
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
SbxDataType eType = pVar->GetType();
|
2012-07-23 20:23:05 +02:00
|
|
|
if ( (sal_uInt8)eType != (sal_uInt8)SbxOBJECT
|
|
|
|
&& ( eType & SbxARRAY ) == 0 )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-08-22 11:39:37 +02:00
|
|
|
// If the type is variable, the conversion of the SBX does not matter,
|
|
|
|
// else the string is converted.
|
2012-07-23 20:23:05 +02:00
|
|
|
pVar->PutStringExt( rResult );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( SbxBase::IsError() )
|
|
|
|
{
|
|
|
|
SbxBase::ResetError();
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateWatches();
|
|
|
|
|
2010-11-17 14:35:16 +01:00
|
|
|
// The text should never be taken/copied 1:1,
|
|
|
|
// as the UpdateWatches will be lost
|
2012-08-07 08:36:40 +02:00
|
|
|
return false;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
|
|
|
void implCollapseModifiedObjectEntry( SvLBoxEntry* pParent, WatchTreeListBox* pThis )
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
|
|
|
pThis->Collapse( pParent );
|
|
|
|
|
|
|
|
SvLBoxTreeList* pModel = pThis->GetModel();
|
|
|
|
SvLBoxEntry* pDeleteEntry;
|
|
|
|
while( (pDeleteEntry = pThis->SvTreeListBox::GetEntry( pParent, 0 )) != NULL )
|
|
|
|
{
|
|
|
|
implCollapseModifiedObjectEntry( pDeleteEntry, pThis );
|
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
delete (WatchItem*)pDeleteEntry->GetUserData();
|
2004-07-23 09:11:25 +00:00
|
|
|
pModel->Remove( pDeleteEntry );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
String implCreateTypeStringForDimArray( WatchItem* pItem, SbxDataType eType )
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
|
|
|
String aRetStr = getBasicTypeName( eType );
|
|
|
|
|
|
|
|
SbxDimArray* pArray = pItem->mpArray;
|
2005-01-13 17:50:52 +00:00
|
|
|
if( !pArray )
|
|
|
|
pArray = pItem->GetRootArray();
|
|
|
|
if( pArray )
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
2005-01-13 17:50:52 +00:00
|
|
|
int nDimLevel = pItem->nDimLevel;
|
|
|
|
int nDims = pItem->nDimCount;
|
|
|
|
if( nDimLevel < nDims )
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
2005-01-13 17:50:52 +00:00
|
|
|
aRetStr += '(';
|
|
|
|
for( int i = nDimLevel ; i < nDims ; i++ )
|
|
|
|
{
|
|
|
|
short nMin, nMax;
|
2007-01-16 15:28:54 +00:00
|
|
|
pArray->GetDim( sal::static_int_cast<short>( i+1 ), nMin, nMax );
|
2005-01-13 17:50:52 +00:00
|
|
|
aRetStr += String::CreateFromInt32( nMin );
|
2012-09-26 23:07:35 -03:00
|
|
|
aRetStr += OUString( " to " );
|
2005-01-13 17:50:52 +00:00
|
|
|
aRetStr += String::CreateFromInt32( nMax );
|
|
|
|
if( i < nDims - 1 )
|
2012-09-26 23:07:35 -03:00
|
|
|
aRetStr += OUString( ", " );
|
2005-01-13 17:50:52 +00:00
|
|
|
}
|
|
|
|
aRetStr += ')';
|
2004-07-23 09:11:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return aRetStr;
|
|
|
|
}
|
|
|
|
|
2005-01-13 17:50:52 +00:00
|
|
|
void implEnableChildren( SvLBoxEntry* pEntry, bool bEnable )
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
|
|
|
if( bEnable )
|
|
|
|
{
|
|
|
|
pEntry->SetFlags(
|
|
|
|
(pEntry->GetFlags() &
|
|
|
|
~(SV_ENTRYFLAG_NO_NODEBMP | SV_ENTRYFLAG_HAD_CHILDREN))
|
2011-12-07 02:33:51 -08:00
|
|
|
| SV_ENTRYFLAG_CHILDREN_ON_DEMAND );
|
2004-07-23 09:11:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pEntry->SetFlags(
|
2011-12-07 02:33:51 -08:00
|
|
|
(pEntry->GetFlags() & ~(SV_ENTRYFLAG_CHILDREN_ON_DEMAND)) );
|
2004-07-23 09:11:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-02 16:21:08 +02:00
|
|
|
} // namespace
|
|
|
|
|
2004-07-23 09:11:25 +00:00
|
|
|
void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
SbMethod* pCurMethod = StarBASIC::GetActiveMethod();
|
|
|
|
|
|
|
|
SbxError eOld = SbxBase::GetError();
|
2004-11-15 12:39:57 +00:00
|
|
|
setBasicWatchMode( true );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
SvLBoxEntry* pEntry = First();
|
|
|
|
while ( pEntry )
|
|
|
|
{
|
2004-07-23 09:11:25 +00:00
|
|
|
WatchItem* pItem = (WatchItem*)pEntry->GetUserData();
|
|
|
|
String aVName( pItem->maName );
|
2010-11-17 14:35:16 +01:00
|
|
|
DBG_ASSERT( aVName.Len(), "Var? - Must not be empty!" );
|
2004-07-23 09:11:25 +00:00
|
|
|
String aWatchStr;
|
|
|
|
String aTypeStr;
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( pCurMethod )
|
|
|
|
{
|
2004-07-23 09:11:25 +00:00
|
|
|
bool bArrayElement;
|
|
|
|
SbxBase* pSBX = ImplGetSBXForEntry( pEntry, bArrayElement );
|
|
|
|
|
|
|
|
// Array? If no end node create type string
|
|
|
|
if( bArrayElement && pItem->nDimLevel < pItem->nDimCount )
|
|
|
|
{
|
2005-01-13 17:50:52 +00:00
|
|
|
SbxDimArray* pRootArray = pItem->GetRootArray();
|
|
|
|
SbxDataType eType = pRootArray->GetType();
|
2004-07-23 09:11:25 +00:00
|
|
|
aTypeStr = implCreateTypeStringForDimArray( pItem, eType );
|
|
|
|
implEnableChildren( pEntry, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool bCollapse = false;
|
2012-08-07 14:33:56 +02:00
|
|
|
if (SbxVariable const* pVar = IsSbxVariable(pSBX))
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2010-11-17 14:35:16 +01:00
|
|
|
// extra treatment of arrays
|
2000-09-29 10:02:42 +00:00
|
|
|
SbxDataType eType = pVar->GetType();
|
2006-11-02 10:05:59 +00:00
|
|
|
if ( eType & SbxARRAY )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-08-22 11:39:37 +02:00
|
|
|
// consider multidimensinal arrays!
|
2012-08-07 14:33:56 +02:00
|
|
|
if (SbxDimArray* pNewArray = dynamic_cast<SbxDimArray*>(pVar->GetObject()))
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2004-07-23 09:11:25 +00:00
|
|
|
SbxDimArray* pOldArray = pItem->mpArray;
|
|
|
|
|
|
|
|
bool bArrayChanged = false;
|
|
|
|
if( pNewArray != NULL && pOldArray != NULL )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2004-07-23 09:11:25 +00:00
|
|
|
// Compare Array dimensions to see if array has changed
|
|
|
|
// Can be a copy, so comparing pointers does not work
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nOldDims = pOldArray->GetDims();
|
|
|
|
sal_uInt16 nNewDims = pNewArray->GetDims();
|
2004-07-23 09:11:25 +00:00
|
|
|
if( nOldDims != nNewDims )
|
|
|
|
{
|
|
|
|
bArrayChanged = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for( int i = 0 ; i < nOldDims ; i++ )
|
|
|
|
{
|
|
|
|
short nOldMin, nOldMax;
|
|
|
|
short nNewMin, nNewMax;
|
|
|
|
|
2007-01-16 15:28:54 +00:00
|
|
|
pOldArray->GetDim( sal::static_int_cast<short>( i+1 ), nOldMin, nOldMax );
|
|
|
|
pNewArray->GetDim( sal::static_int_cast<short>( i+1 ), nNewMin, nNewMax );
|
2004-07-23 09:11:25 +00:00
|
|
|
if( nOldMin != nNewMin || nOldMax != nNewMax )
|
|
|
|
{
|
|
|
|
bArrayChanged = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
2004-07-23 09:11:25 +00:00
|
|
|
else if( pNewArray == NULL || pOldArray == NULL )
|
|
|
|
bArrayChanged = true;
|
|
|
|
|
2005-01-13 17:50:52 +00:00
|
|
|
if( pNewArray )
|
|
|
|
implEnableChildren( pEntry, true );
|
2004-07-23 09:11:25 +00:00
|
|
|
|
2005-01-13 17:50:52 +00:00
|
|
|
// #i37227 Clear always and replace array
|
|
|
|
if( pNewArray != pOldArray )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2012-09-02 16:21:08 +02:00
|
|
|
pItem->clearWatchItem();
|
2004-07-23 09:11:25 +00:00
|
|
|
if( pNewArray )
|
|
|
|
{
|
|
|
|
implEnableChildren( pEntry, true );
|
|
|
|
|
|
|
|
pItem->mpArray = pNewArray;
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nDims = pNewArray->GetDims();
|
2004-07-23 09:11:25 +00:00
|
|
|
pItem->nDimLevel = 0;
|
|
|
|
pItem->nDimCount = nDims;
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
2005-01-13 17:50:52 +00:00
|
|
|
if( bArrayChanged && pOldArray != NULL )
|
|
|
|
bCollapse = true;
|
|
|
|
|
2004-07-23 09:11:25 +00:00
|
|
|
aTypeStr = implCreateTypeStringForDimArray( pItem, eType );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
else
|
2012-09-26 23:07:35 -03:00
|
|
|
aWatchStr += OUString( "<?>" );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
2011-01-14 11:16:25 +01:00
|
|
|
else if ( (sal_uInt8)eType == (sal_uInt8)SbxOBJECT )
|
2006-11-02 10:05:59 +00:00
|
|
|
{
|
2012-08-07 14:33:56 +02:00
|
|
|
if (SbxObject* pObj = dynamic_cast<SbxObject*>(pVar->GetObject()))
|
2006-11-02 10:05:59 +00:00
|
|
|
{
|
|
|
|
// Check if member list has changed
|
|
|
|
bool bObjChanged = false;
|
2012-09-02 16:21:08 +02:00
|
|
|
if (pItem->mpObject && !pItem->maMemberList.empty())
|
2006-11-02 10:05:59 +00:00
|
|
|
{
|
|
|
|
SbxArray* pProps = pObj->GetProperties();
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nPropCount = pProps->Count();
|
|
|
|
for( sal_uInt16 i = 0 ; i < nPropCount - 3 ; i++ )
|
2006-11-02 10:05:59 +00:00
|
|
|
{
|
2007-01-16 15:28:54 +00:00
|
|
|
SbxVariable* pVar_ = pProps->Get( i );
|
|
|
|
String aName( pVar_->GetName() );
|
2012-09-02 16:21:08 +02:00
|
|
|
if( pItem->maMemberList[i] != aName )
|
2006-11-02 10:05:59 +00:00
|
|
|
{
|
|
|
|
bObjChanged = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( bObjChanged )
|
|
|
|
bCollapse = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
pItem->mpObject = pObj;
|
|
|
|
implEnableChildren( pEntry, true );
|
|
|
|
aTypeStr = getBasicObjectTypeName( pObj );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-26 23:07:35 -03:00
|
|
|
aWatchStr = OUString( "Null" );
|
2006-11-02 10:05:59 +00:00
|
|
|
if( pItem->mpObject != NULL )
|
|
|
|
{
|
|
|
|
bCollapse = true;
|
2012-09-02 16:21:08 +02:00
|
|
|
pItem->clearWatchItem();
|
2006-11-02 10:05:59 +00:00
|
|
|
|
|
|
|
implEnableChildren( pEntry, false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
else
|
2004-07-23 09:11:25 +00:00
|
|
|
{
|
|
|
|
if( pItem->mpObject != NULL )
|
|
|
|
{
|
|
|
|
bCollapse = true;
|
2012-09-02 16:21:08 +02:00
|
|
|
pItem->clearWatchItem();
|
2004-07-23 09:11:25 +00:00
|
|
|
|
|
|
|
implEnableChildren( pEntry, false );
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
bool bString = ((sal_uInt8)eType == (sal_uInt8)SbxSTRING);
|
2012-09-26 23:07:35 -03:00
|
|
|
OUString aStrStr( "\"" );
|
2004-07-23 09:11:25 +00:00
|
|
|
if( bString )
|
|
|
|
aWatchStr += aStrStr;
|
2000-09-29 10:02:42 +00:00
|
|
|
aWatchStr += pVar->GetString();
|
2004-07-23 09:11:25 +00:00
|
|
|
if( bString )
|
|
|
|
aWatchStr += aStrStr;
|
|
|
|
}
|
|
|
|
if( !aTypeStr.Len() )
|
|
|
|
{
|
|
|
|
if( !pVar->IsFixed() )
|
2012-09-26 23:07:35 -03:00
|
|
|
aTypeStr = OUString( "Variant/" );
|
2004-07-23 09:11:25 +00:00
|
|
|
aTypeStr += getBasicTypeName( pVar->GetType() );
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
2004-07-23 09:11:25 +00:00
|
|
|
else if( !bArrayElement )
|
2012-09-26 23:07:35 -03:00
|
|
|
aWatchStr += OUString( "<Out of Scope>" );
|
2004-07-23 09:11:25 +00:00
|
|
|
|
|
|
|
if( bCollapse )
|
|
|
|
implCollapseModifiedObjectEntry( pEntry, this );
|
|
|
|
|
|
|
|
}
|
|
|
|
else if( bBasicStopped )
|
|
|
|
{
|
|
|
|
if( pItem->mpObject || pItem->mpArray )
|
|
|
|
{
|
|
|
|
implCollapseModifiedObjectEntry( pEntry, this );
|
|
|
|
pItem->mpObject = NULL;
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
2004-07-23 09:11:25 +00:00
|
|
|
|
|
|
|
SvHeaderTabListBox::SetEntryText( aWatchStr, pEntry, ITEM_ID_VALUE-1 );
|
|
|
|
SvHeaderTabListBox::SetEntryText( aTypeStr, pEntry, ITEM_ID_TYPE-1 );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
pEntry = Next( pEntry );
|
|
|
|
}
|
|
|
|
|
2004-07-23 09:11:25 +00:00
|
|
|
// Force redraw
|
|
|
|
Invalidate();
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
SbxBase::ResetError();
|
|
|
|
if( eOld != SbxERR_OK )
|
|
|
|
SbxBase::SetError( eOld );
|
2004-11-15 12:39:57 +00:00
|
|
|
setBasicWatchMode( false );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
|
|
|
|
} // namespace basctl
|
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|