1*31598a22SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*31598a22SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*31598a22SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*31598a22SAndrew Rist * distributed with this work for additional information 6*31598a22SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*31598a22SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*31598a22SAndrew Rist * "License"); you may not use this file except in compliance 9*31598a22SAndrew Rist * with the License. You may obtain a copy of the License at 10*31598a22SAndrew Rist * 11*31598a22SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*31598a22SAndrew Rist * 13*31598a22SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*31598a22SAndrew Rist * software distributed under the License is distributed on an 15*31598a22SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*31598a22SAndrew Rist * KIND, either express or implied. See the License for the 17*31598a22SAndrew Rist * specific language governing permissions and limitations 18*31598a22SAndrew Rist * under the License. 19*31598a22SAndrew Rist * 20*31598a22SAndrew Rist *************************************************************/ 21*31598a22SAndrew Rist 22*31598a22SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_basctl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <vector> 28cdf0e10cSrcweir #define _BASIC_TEXTPORTIONS 29cdf0e10cSrcweir #include <basic/sbdef.hxx> 30cdf0e10cSrcweir #include <ide_pch.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <tools/urlobj.hxx> 34cdf0e10cSrcweir #include <unotools/charclass.hxx> 35cdf0e10cSrcweir #include <svl/urihelper.hxx> 36cdf0e10cSrcweir #include <basic/sbx.hxx> 37cdf0e10cSrcweir #include <vcl/sound.hxx> 38cdf0e10cSrcweir #include <svtools/xtextedt.hxx> 39cdf0e10cSrcweir #include <svtools/txtattr.hxx> 40cdf0e10cSrcweir #include <svtools/textwindowpeer.hxx> 41cdf0e10cSrcweir #include <basic/sbuno.hxx> 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include <helpid.hrc> 44cdf0e10cSrcweir #include <baside2.hrc> 45cdf0e10cSrcweir #include <baside2.hxx> 46cdf0e10cSrcweir #include <brkdlg.hxx> 47cdf0e10cSrcweir #include <objdlg.hxx> 48cdf0e10cSrcweir #include <basobj.hxx> 49cdf0e10cSrcweir #include <iderdll.hxx> 50cdf0e10cSrcweir #include <iderdll2.hxx> 51cdf0e10cSrcweir #include <vcl/taskpanelist.hxx> 52cdf0e10cSrcweir #include <vcl/help.hxx> 53cdf0e10cSrcweir 54cdf0e10cSrcweir //#ifndef _SFX_HELP_HXX //autogen 55cdf0e10cSrcweir //#include <sfx2/sfxhelp.hxx> 56cdf0e10cSrcweir //#endif 57cdf0e10cSrcweir #include <unotools/sourceviewconfig.hxx> 58cdf0e10cSrcweir 59cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SCRIPT_XLIBRYARYCONTAINER2_HPP_ 60cdf0e10cSrcweir #include <com/sun/star/script/XLibraryContainer2.hpp> 61cdf0e10cSrcweir #endif 62cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 63cdf0e10cSrcweir 64cdf0e10cSrcweir 65cdf0e10cSrcweir using namespace ::com::sun::star; 66cdf0e10cSrcweir using namespace ::com::sun::star::uno; 67cdf0e10cSrcweir 68cdf0e10cSrcweir 69cdf0e10cSrcweir long nVirtToolBoxHeight; // wird im WatchWindow init., im Stackwindow verw. 70cdf0e10cSrcweir long nHeaderBarHeight; 71cdf0e10cSrcweir 72cdf0e10cSrcweir #define SCROLL_LINE 12 73cdf0e10cSrcweir #define SCROLL_PAGE 60 74cdf0e10cSrcweir 75cdf0e10cSrcweir #define DWBORDER 3 76cdf0e10cSrcweir 77cdf0e10cSrcweir static const char cSuffixes[] = "%&!#@$"; 78cdf0e10cSrcweir 79cdf0e10cSrcweir MapUnit eEditMapUnit = MAP_100TH_MM; 80cdf0e10cSrcweir 81cdf0e10cSrcweir 82cdf0e10cSrcweir // #108672 Helper functions to get/set text in TextEngine 83cdf0e10cSrcweir // using the stream interface (get/setText() only supports 84cdf0e10cSrcweir // tools Strings limited to 64K). 85cdf0e10cSrcweir ::rtl::OUString getTextEngineText( ExtTextEngine* pEngine ) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir SvMemoryStream aMemStream; 88cdf0e10cSrcweir aMemStream.SetStreamCharSet( RTL_TEXTENCODING_UTF8 ); 89cdf0e10cSrcweir aMemStream.SetLineDelimiter( LINEEND_LF ); 90cdf0e10cSrcweir pEngine->Write( aMemStream ); 91cdf0e10cSrcweir sal_uLong nSize = aMemStream.Tell(); 92cdf0e10cSrcweir ::rtl::OUString aText( (const sal_Char*)aMemStream.GetData(), 93cdf0e10cSrcweir nSize, RTL_TEXTENCODING_UTF8 ); 94cdf0e10cSrcweir return aText; 95cdf0e10cSrcweir } 96cdf0e10cSrcweir 97cdf0e10cSrcweir void setTextEngineText( ExtTextEngine* pEngine, const ::rtl::OUString aStr ) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir pEngine->SetText( String() ); 100cdf0e10cSrcweir ::rtl::OString aUTF8Str = ::rtl::OUStringToOString( aStr, RTL_TEXTENCODING_UTF8 ); 101cdf0e10cSrcweir SvMemoryStream aMemStream( (void*)aUTF8Str.getStr(), aUTF8Str.getLength(), 102cdf0e10cSrcweir STREAM_READ | STREAM_SEEK_TO_BEGIN ); 103cdf0e10cSrcweir aMemStream.SetStreamCharSet( RTL_TEXTENCODING_UTF8 ); 104cdf0e10cSrcweir aMemStream.SetLineDelimiter( LINEEND_LF ); 105cdf0e10cSrcweir pEngine->Read( aMemStream ); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir void lcl_DrawIDEWindowFrame( DockingWindow* pWin ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir // The result of using explicit colors here appears to be harmless when 111cdf0e10cSrcweir // switching to high contrast mode: 112cdf0e10cSrcweir if ( !pWin->IsFloatingMode() ) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir Size aSz = pWin->GetOutputSizePixel(); 115cdf0e10cSrcweir const Color aOldLineColor( pWin->GetLineColor() ); 116cdf0e10cSrcweir pWin->SetLineColor( Color( COL_WHITE ) ); 117cdf0e10cSrcweir // oben eine weisse.. 118cdf0e10cSrcweir pWin->DrawLine( Point( 0, 0 ), Point( aSz.Width(), 0 ) ); 119cdf0e10cSrcweir // unten eine schwarze... 120cdf0e10cSrcweir pWin->SetLineColor( Color( COL_BLACK ) ); 121cdf0e10cSrcweir pWin->DrawLine( Point( 0, aSz.Height() - 1 ), Point( aSz.Width(), aSz.Height() - 1 ) ); 122cdf0e10cSrcweir pWin->SetLineColor( aOldLineColor ); 123cdf0e10cSrcweir } 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir void lcl_SeparateNameAndIndex( const String& rVName, String& rVar, String& rIndex ) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir rVar = rVName; 129cdf0e10cSrcweir rIndex.Erase(); 130cdf0e10cSrcweir sal_uInt16 nIndexStart = rVar.Search( '(' ); 131cdf0e10cSrcweir if ( nIndexStart != STRING_NOTFOUND ) 132cdf0e10cSrcweir { 133cdf0e10cSrcweir sal_uInt16 nIndexEnd = rVar.Search( ')', nIndexStart ); 134cdf0e10cSrcweir if ( nIndexStart != STRING_NOTFOUND ) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir rIndex = rVar.Copy( nIndexStart+1, nIndexEnd-nIndexStart-1 ); 137cdf0e10cSrcweir rVar.Erase( nIndexStart ); 138cdf0e10cSrcweir rVar.EraseTrailingChars(); 139cdf0e10cSrcweir rIndex.EraseLeadingChars(); 140cdf0e10cSrcweir rIndex.EraseTrailingChars(); 141cdf0e10cSrcweir } 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir if ( rVar.Len() ) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir sal_uInt16 nLastChar = rVar.Len()-1; 147cdf0e10cSrcweir if ( strchr( cSuffixes, rVar.GetChar( nLastChar ) ) ) 148cdf0e10cSrcweir rVar.Erase( nLastChar, 1 ); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir if ( rIndex.Len() ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir sal_uInt16 nLastChar = rIndex.Len()-1; 153cdf0e10cSrcweir if ( strchr( cSuffixes, rIndex.GetChar( nLastChar ) ) ) 154cdf0e10cSrcweir rIndex.Erase( nLastChar, 1 ); 155cdf0e10cSrcweir } 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir 159cdf0e10cSrcweir EditorWindow::EditorWindow( Window* pParent ) : 160cdf0e10cSrcweir Window( pParent, WB_BORDER ) 161cdf0e10cSrcweir { 162cdf0e10cSrcweir bDoSyntaxHighlight = sal_True; 163cdf0e10cSrcweir bDelayHighlight = sal_True; 164cdf0e10cSrcweir pModulWindow = 0; 165cdf0e10cSrcweir pEditView = 0; 166cdf0e10cSrcweir pEditEngine = 0; 167cdf0e10cSrcweir pSourceViewConfig = new utl::SourceViewConfig; 168cdf0e10cSrcweir bHighlightning = sal_False; 169cdf0e10cSrcweir pProgress = 0; 170cdf0e10cSrcweir nCurTextWidth = 0; 171cdf0e10cSrcweir SetBackground( 172cdf0e10cSrcweir Wallpaper(GetSettings().GetStyleSettings().GetFieldColor())); 173cdf0e10cSrcweir SetPointer( Pointer( POINTER_TEXT ) ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir SetHelpId( HID_BASICIDE_EDITORWINDOW ); 176cdf0e10cSrcweir pSourceViewConfig->AddListener(this); 177cdf0e10cSrcweir } 178cdf0e10cSrcweir 179cdf0e10cSrcweir 180cdf0e10cSrcweir 181cdf0e10cSrcweir __EXPORT EditorWindow::~EditorWindow() 182cdf0e10cSrcweir { 183cdf0e10cSrcweir pSourceViewConfig->RemoveListener(this); 184cdf0e10cSrcweir delete pSourceViewConfig; 185cdf0e10cSrcweir 186cdf0e10cSrcweir aSyntaxIdleTimer.Stop(); 187cdf0e10cSrcweir 188cdf0e10cSrcweir if ( pEditEngine ) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir EndListening( *pEditEngine ); 191cdf0e10cSrcweir pEditEngine->RemoveView( pEditView ); 192cdf0e10cSrcweir // pEditEngine->SetViewWin( 0 ); 193cdf0e10cSrcweir delete pEditView; 194cdf0e10cSrcweir delete pEditEngine; 195cdf0e10cSrcweir } 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir String EditorWindow::GetWordAtCursor() 199cdf0e10cSrcweir { 200cdf0e10cSrcweir String aWord; 201cdf0e10cSrcweir 202cdf0e10cSrcweir if ( pEditView ) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir TextEngine* pTextEngine = pEditView->GetTextEngine(); 205cdf0e10cSrcweir if ( pTextEngine ) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir // check first, if the cursor is at a help URL 208cdf0e10cSrcweir const TextSelection& rSelection = pEditView->GetSelection(); 209cdf0e10cSrcweir const TextPaM& rSelStart = rSelection.GetStart(); 210cdf0e10cSrcweir const TextPaM& rSelEnd = rSelection.GetEnd(); 211cdf0e10cSrcweir String aText = pTextEngine->GetText( rSelEnd.GetPara() ); 212cdf0e10cSrcweir CharClass aClass( ::comphelper::getProcessServiceFactory() , Application::GetSettings().GetLocale() ); 213cdf0e10cSrcweir xub_StrLen nSelStart = static_cast< xub_StrLen >( rSelStart.GetIndex() ); 214cdf0e10cSrcweir xub_StrLen nSelEnd = static_cast< xub_StrLen >( rSelEnd.GetIndex() ); 215cdf0e10cSrcweir xub_StrLen nLength = static_cast< xub_StrLen >( aText.Len() ); 216cdf0e10cSrcweir xub_StrLen nStart = 0; 217cdf0e10cSrcweir xub_StrLen nEnd = nLength; 218cdf0e10cSrcweir while ( nStart < nLength ) 219cdf0e10cSrcweir { 220cdf0e10cSrcweir String aURL( URIHelper::FindFirstURLInText( aText, nStart, nEnd, aClass ) ); 221cdf0e10cSrcweir INetURLObject aURLObj( aURL ); 222cdf0e10cSrcweir if ( aURLObj.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP 223cdf0e10cSrcweir && nSelStart >= nStart && nSelStart <= nEnd && nSelEnd >= nStart && nSelEnd <= nEnd ) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir aWord = aURL; 226cdf0e10cSrcweir break; 227cdf0e10cSrcweir } 228cdf0e10cSrcweir nStart = nEnd; 229cdf0e10cSrcweir nEnd = nLength; 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir // Nicht den Selektierten Bereich, sondern an der CursorPosition, 233cdf0e10cSrcweir // falls Teil eines Worts markiert. 234cdf0e10cSrcweir if ( !aWord.Len() ) 235cdf0e10cSrcweir aWord = pTextEngine->GetWord( rSelEnd ); 236cdf0e10cSrcweir 237cdf0e10cSrcweir // Kann leer sein, wenn komplettes Word markiert, da Cursor dahinter. 238cdf0e10cSrcweir if ( !aWord.Len() && pEditView->HasSelection() ) 239cdf0e10cSrcweir aWord = pTextEngine->GetWord( rSelStart ); 240cdf0e10cSrcweir } 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir return aWord; 244cdf0e10cSrcweir } 245cdf0e10cSrcweir 246cdf0e10cSrcweir void __EXPORT EditorWindow::RequestHelp( const HelpEvent& rHEvt ) 247cdf0e10cSrcweir { 248cdf0e10cSrcweir sal_Bool bDone = sal_False; 249cdf0e10cSrcweir 250cdf0e10cSrcweir // Sollte eigentlich mal aktiviert werden... 251cdf0e10cSrcweir if ( pEditEngine ) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir if ( rHEvt.GetMode() & HELPMODE_CONTEXT ) 254cdf0e10cSrcweir { 255cdf0e10cSrcweir String aKeyword = GetWordAtCursor(); 256cdf0e10cSrcweir Application::GetHelp()->SearchKeyword( aKeyword ); 257cdf0e10cSrcweir bDone = sal_True; 258cdf0e10cSrcweir } 259cdf0e10cSrcweir else if ( rHEvt.GetMode() & HELPMODE_QUICK ) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir String aHelpText; 262cdf0e10cSrcweir Point aTopLeft; 263cdf0e10cSrcweir if ( StarBASIC::IsRunning() ) 264cdf0e10cSrcweir { 265cdf0e10cSrcweir Point aWindowPos = rHEvt.GetMousePosPixel(); 266cdf0e10cSrcweir aWindowPos = ScreenToOutputPixel( aWindowPos ); 267cdf0e10cSrcweir Point aDocPos = GetEditView()->GetDocPos( aWindowPos ); 268cdf0e10cSrcweir TextPaM aCursor = GetEditView()->GetTextEngine()->GetPaM( aDocPos, sal_False ); 269cdf0e10cSrcweir TextPaM aStartOfWord; 270cdf0e10cSrcweir String aWord = GetEditView()->GetTextEngine()->GetWord( aCursor, &aStartOfWord ); 271cdf0e10cSrcweir if ( aWord.Len() && !ByteString( aWord, RTL_TEXTENCODING_UTF8 ).IsNumericAscii() ) 272cdf0e10cSrcweir { 273cdf0e10cSrcweir sal_uInt16 nLastChar =aWord.Len()-1; 274cdf0e10cSrcweir if ( strchr( cSuffixes, aWord.GetChar( nLastChar ) ) ) 275cdf0e10cSrcweir aWord.Erase( nLastChar, 1 ); 276cdf0e10cSrcweir SbxBase* pSBX = StarBASIC::FindSBXInCurrentScope( aWord ); 277cdf0e10cSrcweir if ( pSBX && pSBX->ISA( SbxVariable ) && !pSBX->ISA( SbxMethod ) ) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir SbxVariable* pVar = (SbxVariable*)pSBX; 280cdf0e10cSrcweir SbxDataType eType = pVar->GetType(); 281cdf0e10cSrcweir if ( (sal_uInt8)eType == (sal_uInt8)SbxOBJECT ) 282cdf0e10cSrcweir // Kann zu Absturz, z.B. bei Selections-Objekt fuehren 283cdf0e10cSrcweir // Type == Object heisst nicht, dass pVar == Object! 284cdf0e10cSrcweir ; // aHelpText = ((SbxObject*)pVar)->GetClassName(); 285cdf0e10cSrcweir else if ( eType & SbxARRAY ) 286cdf0e10cSrcweir ; // aHelpText = "{...}"; 287cdf0e10cSrcweir else if ( (sal_uInt8)eType != (sal_uInt8)SbxEMPTY ) 288cdf0e10cSrcweir { 289cdf0e10cSrcweir aHelpText = pVar->GetName(); 290cdf0e10cSrcweir if ( !aHelpText.Len() ) // Bei Uebergabeparametern wird der Name nicht kopiert 291cdf0e10cSrcweir aHelpText = aWord; 292cdf0e10cSrcweir aHelpText += '='; 293cdf0e10cSrcweir aHelpText += pVar->GetString(); 294cdf0e10cSrcweir } 295cdf0e10cSrcweir } 296cdf0e10cSrcweir if ( aHelpText.Len() ) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir aTopLeft = GetEditView()->GetTextEngine()->PaMtoEditCursor( aStartOfWord ).BottomLeft(); 299cdf0e10cSrcweir aTopLeft = GetEditView()->GetWindowPos( aTopLeft ); 300cdf0e10cSrcweir aTopLeft.X() += 5; 301cdf0e10cSrcweir aTopLeft.Y() += 5; 302cdf0e10cSrcweir aTopLeft = OutputToScreenPixel( aTopLeft ); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir } 305cdf0e10cSrcweir } 306cdf0e10cSrcweir Help::ShowQuickHelp( this, Rectangle( aTopLeft, Size( 1, 1 ) ), aHelpText, QUICKHELP_TOP|QUICKHELP_LEFT); 307cdf0e10cSrcweir bDone = sal_True; 308cdf0e10cSrcweir } 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir if ( !bDone ) 312cdf0e10cSrcweir Window::RequestHelp( rHEvt ); 313cdf0e10cSrcweir } 314cdf0e10cSrcweir 315cdf0e10cSrcweir 316cdf0e10cSrcweir void __EXPORT EditorWindow::Resize() 317cdf0e10cSrcweir { 318cdf0e10cSrcweir // ScrollBars, etc. passiert in Adjust... 319cdf0e10cSrcweir if ( pEditView ) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir long nVisY = pEditView->GetStartDocPos().Y(); 322cdf0e10cSrcweir // pEditView->SetOutputArea( Rectangle( Point( 0, 0 ), GetOutputSize() ) ); 323cdf0e10cSrcweir pEditView->ShowCursor(); 324cdf0e10cSrcweir Size aOutSz( GetOutputSizePixel() ); 325cdf0e10cSrcweir long nMaxVisAreaStart = pEditView->GetTextEngine()->GetTextHeight() - aOutSz.Height(); 326cdf0e10cSrcweir if ( nMaxVisAreaStart < 0 ) 327cdf0e10cSrcweir nMaxVisAreaStart = 0; 328cdf0e10cSrcweir if ( pEditView->GetStartDocPos().Y() > nMaxVisAreaStart ) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir Point aStartDocPos( pEditView->GetStartDocPos() ); 331cdf0e10cSrcweir aStartDocPos.Y() = nMaxVisAreaStart; 332cdf0e10cSrcweir pEditView->SetStartDocPos( aStartDocPos ); 333cdf0e10cSrcweir pEditView->ShowCursor(); 334cdf0e10cSrcweir pModulWindow->GetBreakPointWindow().GetCurYOffset() = aStartDocPos.Y(); 335cdf0e10cSrcweir } 336cdf0e10cSrcweir InitScrollBars(); 337cdf0e10cSrcweir if ( nVisY != pEditView->GetStartDocPos().Y() ) 338cdf0e10cSrcweir Invalidate(); 339cdf0e10cSrcweir } 340cdf0e10cSrcweir } 341cdf0e10cSrcweir 342cdf0e10cSrcweir 343cdf0e10cSrcweir 344cdf0e10cSrcweir void __EXPORT EditorWindow::MouseMove( const MouseEvent &rEvt ) 345cdf0e10cSrcweir { 346cdf0e10cSrcweir if ( pEditView ) 347cdf0e10cSrcweir pEditView->MouseMove( rEvt ); 348cdf0e10cSrcweir } 349cdf0e10cSrcweir 350cdf0e10cSrcweir 351cdf0e10cSrcweir 352cdf0e10cSrcweir void __EXPORT EditorWindow::MouseButtonUp( const MouseEvent &rEvt ) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir if ( pEditView ) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir pEditView->MouseButtonUp( rEvt ); 357cdf0e10cSrcweir SfxBindings* pBindings = BasicIDE::GetBindingsPtr(); 358cdf0e10cSrcweir if ( pBindings ) 359cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_STAT_POS ); 360cdf0e10cSrcweir } 361cdf0e10cSrcweir } 362cdf0e10cSrcweir 363cdf0e10cSrcweir void __EXPORT EditorWindow::MouseButtonDown( const MouseEvent &rEvt ) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir GrabFocus(); 366cdf0e10cSrcweir if ( pEditView ) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir pEditView->MouseButtonDown( rEvt ); 369cdf0e10cSrcweir } 370cdf0e10cSrcweir } 371cdf0e10cSrcweir 372cdf0e10cSrcweir void __EXPORT EditorWindow::Command( const CommandEvent& rCEvt ) 373cdf0e10cSrcweir { 374cdf0e10cSrcweir if ( pEditView ) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir pEditView->Command( rCEvt ); 377cdf0e10cSrcweir if ( ( rCEvt.GetCommand() == COMMAND_WHEEL ) || 378cdf0e10cSrcweir ( rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL ) || 379cdf0e10cSrcweir ( rCEvt.GetCommand() == COMMAND_AUTOSCROLL ) ) 380cdf0e10cSrcweir { 381cdf0e10cSrcweir HandleScrollCommand( rCEvt, pModulWindow->GetHScrollBar(), &pModulWindow->GetEditVScrollBar() ); 382cdf0e10cSrcweir } 383cdf0e10cSrcweir } 384cdf0e10cSrcweir } 385cdf0e10cSrcweir 386cdf0e10cSrcweir sal_Bool EditorWindow::ImpCanModify() 387cdf0e10cSrcweir { 388cdf0e10cSrcweir sal_Bool bCanModify = sal_True; 389cdf0e10cSrcweir if ( StarBASIC::IsRunning() ) 390cdf0e10cSrcweir { 391cdf0e10cSrcweir // Wenn im Trace-Mode, entweder Trace abbrechen oder 392cdf0e10cSrcweir // Eingabe verweigern 393cdf0e10cSrcweir // Im Notify bei Basic::Stoped die Markierungen in den Modulen 394cdf0e10cSrcweir // entfernen! 395cdf0e10cSrcweir if ( QueryBox( 0, WB_OK_CANCEL, String( IDEResId( RID_STR_WILLSTOPPRG ) ) ).Execute() == RET_OK ) 396cdf0e10cSrcweir { 397cdf0e10cSrcweir pModulWindow->GetBasicStatus().bIsRunning = sal_False; 398cdf0e10cSrcweir BasicIDE::StopBasic(); 399cdf0e10cSrcweir } 400cdf0e10cSrcweir else 401cdf0e10cSrcweir bCanModify = sal_False; 402cdf0e10cSrcweir } 403cdf0e10cSrcweir return bCanModify; 404cdf0e10cSrcweir } 405cdf0e10cSrcweir 406cdf0e10cSrcweir void __EXPORT EditorWindow::KeyInput( const KeyEvent& rKEvt ) 407cdf0e10cSrcweir { 408cdf0e10cSrcweir if ( !pEditView ) // Passiert unter W95 bei letzte Version, Ctrl-Tab 409cdf0e10cSrcweir return; 410cdf0e10cSrcweir 411cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 412cdf0e10cSrcweir Range aRange = pModulWindow->GetHScrollBar()->GetRange(); (void)aRange; 413cdf0e10cSrcweir long nVisSz = pModulWindow->GetHScrollBar()->GetVisibleSize(); (void)nVisSz; 414cdf0e10cSrcweir long nPapSz = pModulWindow->GetHScrollBar()->GetPageSize(); (void)nPapSz; 415cdf0e10cSrcweir long nLinSz = pModulWindow->GetHScrollBar()->GetLineSize(); (void)nLinSz; 416cdf0e10cSrcweir long nThumb = pModulWindow->GetHScrollBar()->GetThumbPos(); (void)nThumb; 417cdf0e10cSrcweir #endif 418cdf0e10cSrcweir sal_Bool bDone = sal_False; 419cdf0e10cSrcweir sal_Bool bWasModified = pEditEngine->IsModified(); 420cdf0e10cSrcweir if ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() ) 421cdf0e10cSrcweir { 422cdf0e10cSrcweir if ( ( rKEvt.GetKeyCode().GetCode() == KEY_A) && rKEvt.GetKeyCode().IsMod1() ) 423cdf0e10cSrcweir pEditView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) ); 424cdf0e10cSrcweir else if ( ( rKEvt.GetKeyCode().GetCode() == KEY_Y ) && rKEvt.GetKeyCode().IsMod1() ) 425cdf0e10cSrcweir bDone = sal_True; // CTRL-Y schlucken, damit kein Vorlagenkatalog 426cdf0e10cSrcweir else 427cdf0e10cSrcweir { 428cdf0e10cSrcweir if ( ( rKEvt.GetKeyCode().GetCode() == KEY_TAB ) && !rKEvt.GetKeyCode().IsMod1() && 429cdf0e10cSrcweir !rKEvt.GetKeyCode().IsMod2() && !GetEditView()->IsReadOnly() ) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir TextSelection aSel( pEditView->GetSelection() ); 432cdf0e10cSrcweir if ( aSel.GetStart().GetPara() != aSel.GetEnd().GetPara() ) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir bDelayHighlight = sal_False; 435cdf0e10cSrcweir if ( !rKEvt.GetKeyCode().IsShift() ) 436cdf0e10cSrcweir pEditView->IndentBlock(); 437cdf0e10cSrcweir else 438cdf0e10cSrcweir pEditView->UnindentBlock(); 439cdf0e10cSrcweir bDelayHighlight = sal_True; 440cdf0e10cSrcweir bDone = sal_True; 441cdf0e10cSrcweir } 442cdf0e10cSrcweir } 443cdf0e10cSrcweir if ( !bDone ) 444cdf0e10cSrcweir bDone = pEditView->KeyInput( rKEvt ); 445cdf0e10cSrcweir } 446cdf0e10cSrcweir } 447cdf0e10cSrcweir if ( !bDone ) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir if ( !SfxViewShell::Current()->KeyInput( rKEvt ) ) 450cdf0e10cSrcweir Window::KeyInput( rKEvt ); 451cdf0e10cSrcweir } 452cdf0e10cSrcweir else 453cdf0e10cSrcweir { 454cdf0e10cSrcweir SfxBindings* pBindings = BasicIDE::GetBindingsPtr(); 455cdf0e10cSrcweir if ( pBindings ) 456cdf0e10cSrcweir { 457cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_STAT_POS ); 458cdf0e10cSrcweir if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_CURSOR ) 459cdf0e10cSrcweir pBindings->Update( SID_BASICIDE_STAT_POS ); 460cdf0e10cSrcweir if ( !bWasModified && pEditEngine->IsModified() ) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir pBindings->Invalidate( SID_SAVEDOC ); 463cdf0e10cSrcweir pBindings->Invalidate( SID_DOC_MODIFIED ); 464cdf0e10cSrcweir pBindings->Invalidate( SID_UNDO ); 465cdf0e10cSrcweir } 466cdf0e10cSrcweir if ( rKEvt.GetKeyCode().GetCode() == KEY_INSERT ) 467cdf0e10cSrcweir pBindings->Invalidate( SID_ATTR_INSERT ); 468cdf0e10cSrcweir } 469cdf0e10cSrcweir } 470cdf0e10cSrcweir } 471cdf0e10cSrcweir 472cdf0e10cSrcweir void __EXPORT EditorWindow::Paint( const Rectangle& rRect ) 473cdf0e10cSrcweir { 474cdf0e10cSrcweir if ( !pEditEngine ) // spaetestens jetzt brauche ich sie... 475cdf0e10cSrcweir CreateEditEngine(); 476cdf0e10cSrcweir 477cdf0e10cSrcweir pEditView->Paint( rRect ); 478cdf0e10cSrcweir } 479cdf0e10cSrcweir 480cdf0e10cSrcweir void __EXPORT EditorWindow::LoseFocus() 481cdf0e10cSrcweir { 482cdf0e10cSrcweir SetSourceInBasic(); 483cdf0e10cSrcweir Window::LoseFocus(); 484cdf0e10cSrcweir } 485cdf0e10cSrcweir 486cdf0e10cSrcweir sal_Bool EditorWindow::SetSourceInBasic( sal_Bool bQuiet ) 487cdf0e10cSrcweir { 488cdf0e10cSrcweir (void)bQuiet; 489cdf0e10cSrcweir 490cdf0e10cSrcweir sal_Bool bChanged = sal_False; 491cdf0e10cSrcweir if ( pEditEngine && pEditEngine->IsModified() 492cdf0e10cSrcweir && !GetEditView()->IsReadOnly() ) // Added because of #i60626, otherwise 493cdf0e10cSrcweir // any read only bug in the text engine could lead to a crash later 494cdf0e10cSrcweir { 495cdf0e10cSrcweir if ( !StarBASIC::IsRunning() ) // Nicht zur Laufzeit! 496cdf0e10cSrcweir { 497cdf0e10cSrcweir ::rtl::OUString aModule = getTextEngineText( pEditEngine ); 498cdf0e10cSrcweir 499cdf0e10cSrcweir // update module in basic 500cdf0e10cSrcweir #ifdef DBG_UTIL 501cdf0e10cSrcweir SbModule* pModule = pModulWindow->GetSbModule(); 502cdf0e10cSrcweir #endif 503cdf0e10cSrcweir DBG_ASSERT(pModule, "EditorWindow::SetSourceInBasic: No Module found!"); 504cdf0e10cSrcweir 505cdf0e10cSrcweir // update module in module window 506cdf0e10cSrcweir pModulWindow->SetModule( aModule ); 507cdf0e10cSrcweir 508cdf0e10cSrcweir // update module in library 509cdf0e10cSrcweir ScriptDocument aDocument( pModulWindow->GetDocument() ); 510cdf0e10cSrcweir String aLibName = pModulWindow->GetLibName(); 511cdf0e10cSrcweir String aName = pModulWindow->GetName(); 512cdf0e10cSrcweir OSL_VERIFY( aDocument.updateModule( aLibName, aName, aModule ) ); 513cdf0e10cSrcweir 514cdf0e10cSrcweir pEditEngine->SetModified( sal_False ); 515cdf0e10cSrcweir BasicIDE::MarkDocumentModified( aDocument ); 516cdf0e10cSrcweir bChanged = sal_True; 517cdf0e10cSrcweir } 518cdf0e10cSrcweir } 519cdf0e10cSrcweir return bChanged; 520cdf0e10cSrcweir } 521cdf0e10cSrcweir 522cdf0e10cSrcweir 523cdf0e10cSrcweir // Returns the position of the last character of any of the following 524cdf0e10cSrcweir // EOL char combinations: CR, CR/LF, LF, return -1 if no EOL is found 525cdf0e10cSrcweir sal_Int32 searchEOL( const ::rtl::OUString& rStr, sal_Int32 fromIndex ) 526cdf0e10cSrcweir { 527cdf0e10cSrcweir sal_Int32 iRetPos = -1; 528cdf0e10cSrcweir 529cdf0e10cSrcweir sal_Int32 iLF = rStr.indexOf( LINE_SEP, fromIndex ); 530cdf0e10cSrcweir if( iLF != -1 ) 531cdf0e10cSrcweir { 532cdf0e10cSrcweir iRetPos = iLF; 533cdf0e10cSrcweir } 534cdf0e10cSrcweir else 535cdf0e10cSrcweir { 536cdf0e10cSrcweir iRetPos = rStr.indexOf( LINE_SEP_CR, fromIndex ); 537cdf0e10cSrcweir } 538cdf0e10cSrcweir return iRetPos; 539cdf0e10cSrcweir } 540cdf0e10cSrcweir 541cdf0e10cSrcweir 542cdf0e10cSrcweir void EditorWindow::CreateEditEngine() 543cdf0e10cSrcweir { 544cdf0e10cSrcweir if ( pEditEngine ) 545cdf0e10cSrcweir return; 546cdf0e10cSrcweir 547cdf0e10cSrcweir pEditEngine = new ExtTextEngine; 548cdf0e10cSrcweir pEditView = new ExtTextView( pEditEngine, this ); 549cdf0e10cSrcweir pEditView->SetAutoIndentMode( sal_True ); 550cdf0e10cSrcweir pEditEngine->SetUpdateMode( sal_False ); 551cdf0e10cSrcweir pEditEngine->InsertView( pEditView ); 552cdf0e10cSrcweir 553cdf0e10cSrcweir ImplSetFont(); 554cdf0e10cSrcweir 555cdf0e10cSrcweir aSyntaxIdleTimer.SetTimeout( 200 ); 556cdf0e10cSrcweir aSyntaxIdleTimer.SetTimeoutHdl( LINK( this, EditorWindow, SyntaxTimerHdl ) ); 557cdf0e10cSrcweir 558cdf0e10cSrcweir aHighlighter.initialize( HIGHLIGHT_BASIC ); 559cdf0e10cSrcweir 560cdf0e10cSrcweir sal_Bool bWasDoSyntaxHighlight = bDoSyntaxHighlight; 561cdf0e10cSrcweir bDoSyntaxHighlight = sal_False; // Bei grossen Texten zu langsam... 562cdf0e10cSrcweir ::rtl::OUString aOUSource( pModulWindow->GetModule() ); 563cdf0e10cSrcweir sal_Int32 nLines = 0; 564cdf0e10cSrcweir sal_Int32 nIndex = -1; 565cdf0e10cSrcweir do 566cdf0e10cSrcweir { 567cdf0e10cSrcweir nLines++; 568cdf0e10cSrcweir nIndex = searchEOL( aOUSource, nIndex+1 ); 569cdf0e10cSrcweir } 570cdf0e10cSrcweir while ( nIndex >= 0 ); 571cdf0e10cSrcweir 572cdf0e10cSrcweir // nLines*4: SetText+Formatting+DoHighlight+Formatting 573cdf0e10cSrcweir // 1 Formatting koennte eingespart werden, aber dann wartet man 574cdf0e10cSrcweir // bei einem langen Sourcecode noch laenger auf den Text... 575cdf0e10cSrcweir pProgress = new ProgressInfo( IDE_DLL()->GetShell()->GetViewFrame()->GetObjectShell(), String( IDEResId( RID_STR_GENERATESOURCE ) ), nLines*4 ); 576cdf0e10cSrcweir setTextEngineText( pEditEngine, aOUSource ); 577cdf0e10cSrcweir 578cdf0e10cSrcweir pEditView->SetStartDocPos( Point( 0, 0 ) ); 579cdf0e10cSrcweir pEditView->SetSelection( TextSelection() ); 580cdf0e10cSrcweir pModulWindow->GetBreakPointWindow().GetCurYOffset() = 0; 581cdf0e10cSrcweir pEditEngine->SetUpdateMode( sal_True ); 582cdf0e10cSrcweir Update(); // Es wurde bei UpdateMode = sal_True nur Invalidiert 583cdf0e10cSrcweir 584cdf0e10cSrcweir // Die anderen Fenster auch, damit keine halben Sachen auf dem Bildschirm! 585cdf0e10cSrcweir pModulWindow->GetLayout()->GetWatchWindow().Update(); 586cdf0e10cSrcweir pModulWindow->GetLayout()->GetStackWindow().Update(); 587cdf0e10cSrcweir pModulWindow->GetBreakPointWindow().Update(); 588cdf0e10cSrcweir 589cdf0e10cSrcweir pEditView->ShowCursor( sal_True, sal_True ); 590cdf0e10cSrcweir 591cdf0e10cSrcweir StartListening( *pEditEngine ); 592cdf0e10cSrcweir 593cdf0e10cSrcweir // Das Syntax-Highlightning legt ein rel. groesse VDev an. 594cdf0e10cSrcweir aSyntaxIdleTimer.Stop(); 595cdf0e10cSrcweir bDoSyntaxHighlight = bWasDoSyntaxHighlight; 596cdf0e10cSrcweir 597cdf0e10cSrcweir 598cdf0e10cSrcweir for ( sal_uInt16 nLine = 0; nLine < nLines; nLine++ ) 599cdf0e10cSrcweir aSyntaxLineTable.Insert( nLine, (void*)(sal_uInt16)1 ); 600cdf0e10cSrcweir ForceSyntaxTimeout(); 601cdf0e10cSrcweir 602cdf0e10cSrcweir DELETEZ( pProgress ); 603cdf0e10cSrcweir 604cdf0e10cSrcweir pEditView->EraseVirtualDevice(); 605cdf0e10cSrcweir pEditEngine->SetModified( sal_False ); 606cdf0e10cSrcweir pEditEngine->EnableUndo( sal_True ); 607cdf0e10cSrcweir 608cdf0e10cSrcweir InitScrollBars(); 609cdf0e10cSrcweir 610cdf0e10cSrcweir SfxBindings* pBindings = BasicIDE::GetBindingsPtr(); 611cdf0e10cSrcweir if ( pBindings ) 612cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_STAT_POS ); 613cdf0e10cSrcweir 614cdf0e10cSrcweir DBG_ASSERT( pModulWindow->GetBreakPointWindow().GetCurYOffset() == 0, "CreateEditEngine: Brechpunkte verschoben?" ); 615cdf0e10cSrcweir 616cdf0e10cSrcweir // set readonly mode for readonly libraries 617cdf0e10cSrcweir ScriptDocument aDocument( pModulWindow->GetDocument() ); 618cdf0e10cSrcweir ::rtl::OUString aOULibName( pModulWindow->GetLibName() ); 619cdf0e10cSrcweir Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); 620cdf0e10cSrcweir if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) 621cdf0e10cSrcweir { 622cdf0e10cSrcweir pModulWindow->SetReadOnly( sal_True ); 623cdf0e10cSrcweir } 624cdf0e10cSrcweir 625cdf0e10cSrcweir if ( aDocument.isDocument() && aDocument.isReadOnly() ) 626cdf0e10cSrcweir pModulWindow->SetReadOnly( sal_True ); 627cdf0e10cSrcweir } 628cdf0e10cSrcweir 629cdf0e10cSrcweir // virtual 630cdf0e10cSrcweir void EditorWindow::DataChanged(DataChangedEvent const & rDCEvt) 631cdf0e10cSrcweir { 632cdf0e10cSrcweir Window::DataChanged(rDCEvt); 633cdf0e10cSrcweir if (rDCEvt.GetType() == DATACHANGED_SETTINGS 634cdf0e10cSrcweir && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0) 635cdf0e10cSrcweir { 636cdf0e10cSrcweir Color aColor(GetSettings().GetStyleSettings().GetFieldColor()); 637cdf0e10cSrcweir if (aColor 638cdf0e10cSrcweir != rDCEvt.GetOldSettings()->GetStyleSettings().GetFieldColor()) 639cdf0e10cSrcweir { 640cdf0e10cSrcweir SetBackground(Wallpaper(aColor)); 641cdf0e10cSrcweir Invalidate(); 642cdf0e10cSrcweir } 643cdf0e10cSrcweir if (pEditEngine != 0) 644cdf0e10cSrcweir { 645cdf0e10cSrcweir aColor = GetSettings().GetStyleSettings().GetFieldTextColor(); 646cdf0e10cSrcweir if (aColor != rDCEvt.GetOldSettings()-> 647cdf0e10cSrcweir GetStyleSettings().GetFieldTextColor()) 648cdf0e10cSrcweir { 649cdf0e10cSrcweir Font aFont(pEditEngine->GetFont()); 650cdf0e10cSrcweir aFont.SetColor(aColor); 651cdf0e10cSrcweir pEditEngine->SetFont(aFont); 652cdf0e10cSrcweir } 653cdf0e10cSrcweir } 654cdf0e10cSrcweir } 655cdf0e10cSrcweir } 656cdf0e10cSrcweir 657cdf0e10cSrcweir void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) 658cdf0e10cSrcweir { 659cdf0e10cSrcweir if ( rHint.ISA( TextHint ) ) 660cdf0e10cSrcweir { 661cdf0e10cSrcweir const TextHint& rTextHint = (const TextHint&)rHint; 662cdf0e10cSrcweir if( rTextHint.GetId() == TEXT_HINT_VIEWSCROLLED ) 663cdf0e10cSrcweir { 664cdf0e10cSrcweir if ( pModulWindow->GetHScrollBar() ) 665cdf0e10cSrcweir pModulWindow->GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() ); 666cdf0e10cSrcweir pModulWindow->GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() ); 667cdf0e10cSrcweir pModulWindow->GetBreakPointWindow().DoScroll 668cdf0e10cSrcweir ( 0, pModulWindow->GetBreakPointWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() ); 669cdf0e10cSrcweir } 670cdf0e10cSrcweir else if( rTextHint.GetId() == TEXT_HINT_TEXTHEIGHTCHANGED ) 671cdf0e10cSrcweir { 672cdf0e10cSrcweir if ( pEditView->GetStartDocPos().Y() ) 673cdf0e10cSrcweir { 674cdf0e10cSrcweir long nOutHeight = GetOutputSizePixel().Height(); 675cdf0e10cSrcweir long nTextHeight = pEditEngine->GetTextHeight(); 676cdf0e10cSrcweir if ( nTextHeight < nOutHeight ) 677cdf0e10cSrcweir pEditView->Scroll( 0, pEditView->GetStartDocPos().Y() ); 678cdf0e10cSrcweir } 679cdf0e10cSrcweir 680cdf0e10cSrcweir SetScrollBarRanges(); 681cdf0e10cSrcweir } 682cdf0e10cSrcweir else if( rTextHint.GetId() == TEXT_HINT_TEXTFORMATTED ) 683cdf0e10cSrcweir { 684cdf0e10cSrcweir if ( pModulWindow->GetHScrollBar() ) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir sal_uLong nWidth = pEditEngine->CalcTextWidth(); 687cdf0e10cSrcweir if ( (long)nWidth != nCurTextWidth ) 688cdf0e10cSrcweir { 689cdf0e10cSrcweir nCurTextWidth = nWidth; 690cdf0e10cSrcweir pModulWindow->GetHScrollBar()->SetRange( Range( 0, (long)nCurTextWidth-1) ); 691cdf0e10cSrcweir pModulWindow->GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() ); 692cdf0e10cSrcweir } 693cdf0e10cSrcweir } 694cdf0e10cSrcweir long nPrevTextWidth = nCurTextWidth; 695cdf0e10cSrcweir nCurTextWidth = pEditEngine->CalcTextWidth(); 696cdf0e10cSrcweir if ( nCurTextWidth != nPrevTextWidth ) 697cdf0e10cSrcweir SetScrollBarRanges(); 698cdf0e10cSrcweir } 699cdf0e10cSrcweir else if( rTextHint.GetId() == TEXT_HINT_PARAINSERTED ) 700cdf0e10cSrcweir { 701cdf0e10cSrcweir ParagraphInsertedDeleted( rTextHint.GetValue(), sal_True ); 702cdf0e10cSrcweir DoDelayedSyntaxHighlight( rTextHint.GetValue() ); 703cdf0e10cSrcweir } 704cdf0e10cSrcweir else if( rTextHint.GetId() == TEXT_HINT_PARAREMOVED ) 705cdf0e10cSrcweir { 706cdf0e10cSrcweir ParagraphInsertedDeleted( rTextHint.GetValue(), sal_False ); 707cdf0e10cSrcweir } 708cdf0e10cSrcweir else if( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED ) 709cdf0e10cSrcweir { 710cdf0e10cSrcweir DoDelayedSyntaxHighlight( rTextHint.GetValue() ); 711cdf0e10cSrcweir } 712cdf0e10cSrcweir } 713cdf0e10cSrcweir } 714cdf0e10cSrcweir 715cdf0e10cSrcweir void EditorWindow::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ) 716cdf0e10cSrcweir { 717cdf0e10cSrcweir ImplSetFont(); 718cdf0e10cSrcweir } 719cdf0e10cSrcweir 720cdf0e10cSrcweir void EditorWindow::SetScrollBarRanges() 721cdf0e10cSrcweir { 722cdf0e10cSrcweir // Extra-Methode, nicht InitScrollBars, da auch fuer EditEngine-Events. 723cdf0e10cSrcweir if ( !pEditEngine ) 724cdf0e10cSrcweir return; 725cdf0e10cSrcweir 726cdf0e10cSrcweir if ( pModulWindow->GetHScrollBar() ) 727cdf0e10cSrcweir pModulWindow->GetHScrollBar()->SetRange( Range( 0, nCurTextWidth-1 ) ); 728cdf0e10cSrcweir 729cdf0e10cSrcweir pModulWindow->GetEditVScrollBar().SetRange( Range( 0, pEditEngine->GetTextHeight()-1 ) ); 730cdf0e10cSrcweir } 731cdf0e10cSrcweir 732cdf0e10cSrcweir void EditorWindow::InitScrollBars() 733cdf0e10cSrcweir { 734cdf0e10cSrcweir if ( !pEditEngine ) 735cdf0e10cSrcweir return; 736cdf0e10cSrcweir 737cdf0e10cSrcweir SetScrollBarRanges(); 738cdf0e10cSrcweir Size aOutSz( GetOutputSizePixel() ); 739cdf0e10cSrcweir pModulWindow->GetEditVScrollBar().SetVisibleSize( aOutSz.Height() ); 740cdf0e10cSrcweir pModulWindow->GetEditVScrollBar().SetPageSize( aOutSz.Height() * 8 / 10 ); 741cdf0e10cSrcweir pModulWindow->GetEditVScrollBar().SetLineSize( GetTextHeight() ); 742cdf0e10cSrcweir pModulWindow->GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() ); 743cdf0e10cSrcweir pModulWindow->GetEditVScrollBar().Show(); 744cdf0e10cSrcweir 745cdf0e10cSrcweir if ( pModulWindow->GetHScrollBar() ) 746cdf0e10cSrcweir { 747cdf0e10cSrcweir pModulWindow->GetHScrollBar()->SetVisibleSize( aOutSz.Width() ); 748cdf0e10cSrcweir pModulWindow->GetHScrollBar()->SetPageSize( aOutSz.Width() * 8 / 10 ); 749cdf0e10cSrcweir pModulWindow->GetHScrollBar()->SetLineSize( GetTextWidth( 'x' ) ); 750cdf0e10cSrcweir pModulWindow->GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() ); 751cdf0e10cSrcweir pModulWindow->GetHScrollBar()->Show(); 752cdf0e10cSrcweir } 753cdf0e10cSrcweir } 754cdf0e10cSrcweir 755cdf0e10cSrcweir void EditorWindow::ImpDoHighlight( sal_uLong nLine ) 756cdf0e10cSrcweir { 757cdf0e10cSrcweir if ( bDoSyntaxHighlight ) 758cdf0e10cSrcweir { 759cdf0e10cSrcweir String aLine( pEditEngine->GetText( nLine ) ); 760cdf0e10cSrcweir Range aChanges = aHighlighter.notifyChange( nLine, 0, &aLine, 1 ); 761cdf0e10cSrcweir if ( aChanges.Len() ) 762cdf0e10cSrcweir { 763cdf0e10cSrcweir for ( long n = aChanges.Min() + 1; n <= aChanges.Max(); n++ ) 764cdf0e10cSrcweir aSyntaxLineTable.Insert( n, (void*)(sal_uLong)1 ); 765cdf0e10cSrcweir aSyntaxIdleTimer.Start(); 766cdf0e10cSrcweir } 767cdf0e10cSrcweir 768cdf0e10cSrcweir sal_Bool bWasModified = pEditEngine->IsModified(); 769cdf0e10cSrcweir pEditEngine->RemoveAttribs( nLine, sal_True ); 770cdf0e10cSrcweir HighlightPortions aPortions; 771cdf0e10cSrcweir aHighlighter.getHighlightPortions( nLine, aLine, aPortions ); 772cdf0e10cSrcweir 773cdf0e10cSrcweir for ( size_t i = 0; i < aPortions.size(); i++ ) 774cdf0e10cSrcweir { 775cdf0e10cSrcweir HighlightPortion& r = aPortions[i]; 776cdf0e10cSrcweir const Color& rColor = ((ModulWindowLayout*)pModulWindow->GetLayoutWindow())->getSyntaxColor(r.tokenType); 777cdf0e10cSrcweir pEditEngine->SetAttrib( TextAttribFontColor( rColor ), nLine, r.nBegin, r.nEnd, sal_True ); 778cdf0e10cSrcweir } 779cdf0e10cSrcweir 780cdf0e10cSrcweir // Das Highlighten soll kein Modify setzen 781cdf0e10cSrcweir pEditEngine->SetModified( bWasModified ); 782cdf0e10cSrcweir } 783cdf0e10cSrcweir } 784cdf0e10cSrcweir 785cdf0e10cSrcweir void EditorWindow::ImplSetFont() 786cdf0e10cSrcweir { 787cdf0e10cSrcweir if ( pSourceViewConfig ) 788cdf0e10cSrcweir { 789cdf0e10cSrcweir String sFontName = pSourceViewConfig->GetFontName(); 790cdf0e10cSrcweir if ( !sFontName.Len() ) 791cdf0e10cSrcweir { 792cdf0e10cSrcweir Font aTmpFont( OutputDevice::GetDefaultFont( DEFAULTFONT_FIXED, Application::GetSettings().GetUILanguage(), 0 , this ) ); 793cdf0e10cSrcweir sFontName = aTmpFont.GetName(); 794cdf0e10cSrcweir } 795cdf0e10cSrcweir Size aFontSize( 0, pSourceViewConfig->GetFontHeight() ); 796cdf0e10cSrcweir Font aFont( sFontName, aFontSize ); 797cdf0e10cSrcweir aFont.SetColor( GetSettings().GetStyleSettings().GetFieldTextColor() ); 798cdf0e10cSrcweir SetPointFont( aFont ); 799cdf0e10cSrcweir aFont = GetFont(); 800cdf0e10cSrcweir 801cdf0e10cSrcweir if ( pModulWindow ) 802cdf0e10cSrcweir pModulWindow->GetBreakPointWindow().SetFont( aFont ); 803cdf0e10cSrcweir 804cdf0e10cSrcweir if ( pEditEngine ) 805cdf0e10cSrcweir { 806cdf0e10cSrcweir sal_Bool bModified = pEditEngine->IsModified(); 807cdf0e10cSrcweir pEditEngine->SetFont( aFont ); 808cdf0e10cSrcweir pEditEngine->SetModified( bModified ); 809cdf0e10cSrcweir } 810cdf0e10cSrcweir } 811cdf0e10cSrcweir } 812cdf0e10cSrcweir 813cdf0e10cSrcweir void EditorWindow::DoSyntaxHighlight( sal_uLong nPara ) 814cdf0e10cSrcweir { 815cdf0e10cSrcweir // Durch das DelayedSyntaxHighlight kann es passieren, 816cdf0e10cSrcweir // dass die Zeile nicht mehr existiert! 817cdf0e10cSrcweir if ( nPara < pEditEngine->GetParagraphCount() ) 818cdf0e10cSrcweir { 819cdf0e10cSrcweir // leider weis ich nicht, ob genau diese Zeile Modified() ... 820cdf0e10cSrcweir if ( pProgress ) 821cdf0e10cSrcweir pProgress->StepProgress(); 822cdf0e10cSrcweir ImpDoHighlight( nPara ); 823cdf0e10cSrcweir } 824cdf0e10cSrcweir } 825cdf0e10cSrcweir 826cdf0e10cSrcweir void EditorWindow::DoDelayedSyntaxHighlight( sal_uLong nPara ) 827cdf0e10cSrcweir { 828cdf0e10cSrcweir // Zeile wird nur in 'Liste' aufgenommen, im TimerHdl abgearbeitet. 829cdf0e10cSrcweir // => Nicht Absaetze manipulieren, waehrend EditEngine formatiert. 830cdf0e10cSrcweir if ( pProgress ) 831cdf0e10cSrcweir pProgress->StepProgress(); 832cdf0e10cSrcweir 833cdf0e10cSrcweir if ( !bHighlightning && bDoSyntaxHighlight ) 834cdf0e10cSrcweir { 835cdf0e10cSrcweir if ( bDelayHighlight ) 836cdf0e10cSrcweir { 837cdf0e10cSrcweir aSyntaxLineTable.Insert( nPara, (void*)(sal_uLong)1 ); 838cdf0e10cSrcweir aSyntaxIdleTimer.Start(); 839cdf0e10cSrcweir } 840cdf0e10cSrcweir else 841cdf0e10cSrcweir DoSyntaxHighlight( nPara ); 842cdf0e10cSrcweir } 843cdf0e10cSrcweir } 844cdf0e10cSrcweir 845cdf0e10cSrcweir IMPL_LINK( EditorWindow, SyntaxTimerHdl, Timer *, EMPTYARG ) 846cdf0e10cSrcweir { 847cdf0e10cSrcweir DBG_ASSERT( pEditView, "Noch keine View, aber Syntax-Highlight ?!" ); 848cdf0e10cSrcweir 849cdf0e10cSrcweir sal_Bool bWasModified = pEditEngine->IsModified(); 850cdf0e10cSrcweir // pEditEngine->SetUpdateMode( sal_False ); 851cdf0e10cSrcweir 852cdf0e10cSrcweir bHighlightning = sal_True; 853cdf0e10cSrcweir sal_uInt16 nLine; 854cdf0e10cSrcweir void* p = aSyntaxLineTable.First(); 855cdf0e10cSrcweir while ( p ) 856cdf0e10cSrcweir { 857cdf0e10cSrcweir nLine = (sal_uInt16)aSyntaxLineTable.GetCurKey(); 858cdf0e10cSrcweir DoSyntaxHighlight( nLine ); 859cdf0e10cSrcweir p = aSyntaxLineTable.Next(); 860cdf0e10cSrcweir } 861cdf0e10cSrcweir 862cdf0e10cSrcweir // MT: Removed, because of idle format now when set/remove attribs... 863cdf0e10cSrcweir // pEditView->SetAutoScroll( sal_False ); // #101043# Don't scroll because of syntax highlight 864cdf0e10cSrcweir // pEditEngine->SetUpdateMode( sal_True ); 865cdf0e10cSrcweir // pEditView->ShowCursor( sal_False, sal_True ); 866cdf0e10cSrcweir // pEditView->SetAutoScroll( sal_True ); 867cdf0e10cSrcweir 868cdf0e10cSrcweir // #i45572# 869cdf0e10cSrcweir if ( pEditView ) 870cdf0e10cSrcweir pEditView->ShowCursor( sal_False, sal_True ); 871cdf0e10cSrcweir 872cdf0e10cSrcweir pEditEngine->SetModified( bWasModified ); 873cdf0e10cSrcweir 874cdf0e10cSrcweir aSyntaxLineTable.Clear(); 875cdf0e10cSrcweir bHighlightning = sal_False; 876cdf0e10cSrcweir 877cdf0e10cSrcweir return 0; 878cdf0e10cSrcweir } 879cdf0e10cSrcweir 880cdf0e10cSrcweir void EditorWindow::ParagraphInsertedDeleted( sal_uLong nPara, sal_Bool bInserted ) 881cdf0e10cSrcweir { 882cdf0e10cSrcweir if ( pProgress ) 883cdf0e10cSrcweir pProgress->StepProgress(); 884cdf0e10cSrcweir 885cdf0e10cSrcweir if ( !bInserted && ( nPara == TEXT_PARA_ALL ) ) 886cdf0e10cSrcweir { 887cdf0e10cSrcweir pModulWindow->GetBreakPoints().reset(); 888cdf0e10cSrcweir pModulWindow->GetBreakPointWindow().Invalidate(); 889cdf0e10cSrcweir aHighlighter.initialize( HIGHLIGHT_BASIC ); 890cdf0e10cSrcweir } 891cdf0e10cSrcweir else 892cdf0e10cSrcweir { 893cdf0e10cSrcweir // Brechpunkte Aktualisieren... 894cdf0e10cSrcweir // keine Sonderbehandlung fuer EditEngine-CTOR ( Erste-Zeile-Problem ), 895cdf0e10cSrcweir // da in diesem Moment noch keine BreakPoints. 896cdf0e10cSrcweir // +1: Basic-Zeilen beginnen bei 1! 897cdf0e10cSrcweir pModulWindow->GetBreakPoints().AdjustBreakPoints( (sal_uInt16)nPara+1, bInserted ); 898cdf0e10cSrcweir 899cdf0e10cSrcweir // Im BreakPointWindow invalidieren... 900cdf0e10cSrcweir long nLineHeight = GetTextHeight(); 901cdf0e10cSrcweir Size aSz = pModulWindow->GetBreakPointWindow().GetOutputSize(); 902cdf0e10cSrcweir Rectangle aInvRec( Point( 0, 0 ), aSz ); 903cdf0e10cSrcweir long nY = nPara*nLineHeight - pModulWindow->GetBreakPointWindow().GetCurYOffset(); 904cdf0e10cSrcweir aInvRec.Top() = nY; 905cdf0e10cSrcweir pModulWindow->GetBreakPointWindow().Invalidate( aInvRec ); 906cdf0e10cSrcweir 907cdf0e10cSrcweir if ( bDoSyntaxHighlight ) 908cdf0e10cSrcweir { 909cdf0e10cSrcweir String aDummy; 910cdf0e10cSrcweir aHighlighter.notifyChange( nPara, bInserted ? 1 : (-1), &aDummy, 1 ); 911cdf0e10cSrcweir } 912cdf0e10cSrcweir } 913cdf0e10cSrcweir } 914cdf0e10cSrcweir 915cdf0e10cSrcweir void EditorWindow::CreateProgress( const String& rText, sal_uLong nRange ) 916cdf0e10cSrcweir { 917cdf0e10cSrcweir DBG_ASSERT( !pProgress, "ProgressInfo existiert schon" ); 918cdf0e10cSrcweir pProgress = new ProgressInfo( IDE_DLL()->GetShell()->GetViewFrame()->GetObjectShell(), rText, nRange ); 919cdf0e10cSrcweir } 920cdf0e10cSrcweir 921cdf0e10cSrcweir void EditorWindow::DestroyProgress() 922cdf0e10cSrcweir { 923cdf0e10cSrcweir DELETEZ( pProgress ); 924cdf0e10cSrcweir } 925cdf0e10cSrcweir 926cdf0e10cSrcweir void EditorWindow::ForceSyntaxTimeout() 927cdf0e10cSrcweir { 928cdf0e10cSrcweir aSyntaxIdleTimer.Stop(); 929cdf0e10cSrcweir ((Link&)aSyntaxIdleTimer.GetTimeoutHdl()).Call( &aSyntaxIdleTimer ); 930cdf0e10cSrcweir } 931cdf0e10cSrcweir 932cdf0e10cSrcweir 933cdf0e10cSrcweir 934cdf0e10cSrcweir BreakPointWindow::BreakPointWindow( Window* pParent ) : 935cdf0e10cSrcweir Window( pParent, WB_BORDER ) 936cdf0e10cSrcweir { 937cdf0e10cSrcweir pModulWindow = 0; 938cdf0e10cSrcweir nCurYOffset = 0; 939cdf0e10cSrcweir setBackgroundColor(GetSettings().GetStyleSettings().GetFieldColor()); 940cdf0e10cSrcweir m_bHighContrastMode = GetSettings().GetStyleSettings().GetHighContrastMode(); 941cdf0e10cSrcweir nMarkerPos = MARKER_NOMARKER; 942cdf0e10cSrcweir 943cdf0e10cSrcweir // nCurYOffset merken und nicht von EditEngine holen. 944cdf0e10cSrcweir // Falls in EditEngine autom. gescrollt wurde, wuesste ich sonst nicht, 945cdf0e10cSrcweir // wo ich gerade stehe. 946cdf0e10cSrcweir 947cdf0e10cSrcweir SetHelpId( HID_BASICIDE_BREAKPOINTWINDOW ); 948cdf0e10cSrcweir } 949cdf0e10cSrcweir 950cdf0e10cSrcweir 951cdf0e10cSrcweir 952cdf0e10cSrcweir __EXPORT BreakPointWindow::~BreakPointWindow() 953cdf0e10cSrcweir { 954cdf0e10cSrcweir } 955cdf0e10cSrcweir 956cdf0e10cSrcweir 957cdf0e10cSrcweir 958cdf0e10cSrcweir void __EXPORT BreakPointWindow::Resize() 959cdf0e10cSrcweir { 960cdf0e10cSrcweir /// Invalidate(); 961cdf0e10cSrcweir } 962cdf0e10cSrcweir 963cdf0e10cSrcweir 964cdf0e10cSrcweir 965cdf0e10cSrcweir void __EXPORT BreakPointWindow::Paint( const Rectangle& ) 966cdf0e10cSrcweir { 967cdf0e10cSrcweir if ( SyncYOffset() ) 968cdf0e10cSrcweir return; 969cdf0e10cSrcweir 970cdf0e10cSrcweir Size aOutSz( GetOutputSize() ); 971cdf0e10cSrcweir long nLineHeight = GetTextHeight(); 972cdf0e10cSrcweir 973cdf0e10cSrcweir Image aBrk1(((ModulWindowLayout *) pModulWindow->GetLayoutWindow())-> 974cdf0e10cSrcweir getImage(IMGID_BRKENABLED, m_bHighContrastMode)); 975cdf0e10cSrcweir Image aBrk0(((ModulWindowLayout *) pModulWindow->GetLayoutWindow())-> 976cdf0e10cSrcweir getImage(IMGID_BRKDISABLED, m_bHighContrastMode)); 977cdf0e10cSrcweir Size aBmpSz( aBrk1.GetSizePixel() ); 978cdf0e10cSrcweir aBmpSz = PixelToLogic( aBmpSz ); 979cdf0e10cSrcweir Point aBmpOff( 0, 0 ); 980cdf0e10cSrcweir aBmpOff.X() = ( aOutSz.Width() - aBmpSz.Width() ) / 2; 981cdf0e10cSrcweir aBmpOff.Y() = ( nLineHeight - aBmpSz.Height() ) / 2; 982cdf0e10cSrcweir 983cdf0e10cSrcweir BreakPoint* pBrk = GetBreakPoints().First(); 984cdf0e10cSrcweir while ( pBrk ) 985cdf0e10cSrcweir { 986cdf0e10cSrcweir sal_uLong nLine = pBrk->nLine-1; 987cdf0e10cSrcweir sal_uLong nY = nLine*nLineHeight - nCurYOffset; 988cdf0e10cSrcweir DrawImage( Point( 0, nY ) + aBmpOff, pBrk->bEnabled ? aBrk1 : aBrk0 ); 989cdf0e10cSrcweir pBrk = GetBreakPoints().Next(); 990cdf0e10cSrcweir } 991cdf0e10cSrcweir ShowMarker( sal_True ); 992cdf0e10cSrcweir } 993cdf0e10cSrcweir 994cdf0e10cSrcweir 995cdf0e10cSrcweir 996cdf0e10cSrcweir void BreakPointWindow::DoScroll( long nHorzScroll, long nVertScroll ) 997cdf0e10cSrcweir { 998cdf0e10cSrcweir nCurYOffset -= nVertScroll; 999cdf0e10cSrcweir Window::Scroll( nHorzScroll, nVertScroll ); 1000cdf0e10cSrcweir } 1001cdf0e10cSrcweir 1002cdf0e10cSrcweir 1003cdf0e10cSrcweir 1004cdf0e10cSrcweir void BreakPointWindow::SetMarkerPos( sal_uInt16 nLine, sal_Bool bError ) 1005cdf0e10cSrcweir { 1006cdf0e10cSrcweir if ( SyncYOffset() ) 1007cdf0e10cSrcweir Update(); 1008cdf0e10cSrcweir 1009cdf0e10cSrcweir ShowMarker( sal_False ); // Alten wegzeichen... 1010cdf0e10cSrcweir nMarkerPos = nLine; 1011cdf0e10cSrcweir bErrorMarker = bError; 1012cdf0e10cSrcweir ShowMarker( sal_True ); // Neuen zeichnen... 1013cdf0e10cSrcweir } 1014cdf0e10cSrcweir 1015cdf0e10cSrcweir void BreakPointWindow::ShowMarker( sal_Bool bShow ) 1016cdf0e10cSrcweir { 1017cdf0e10cSrcweir if ( nMarkerPos == MARKER_NOMARKER ) 1018cdf0e10cSrcweir return; 1019cdf0e10cSrcweir 1020cdf0e10cSrcweir Size aOutSz( GetOutputSize() ); 1021cdf0e10cSrcweir long nLineHeight = GetTextHeight(); 1022cdf0e10cSrcweir 1023cdf0e10cSrcweir Image aMarker(((ModulWindowLayout*)pModulWindow->GetLayoutWindow())-> 1024cdf0e10cSrcweir getImage(bErrorMarker 1025cdf0e10cSrcweir ? IMGID_ERRORMARKER : IMGID_STEPMARKER, 1026cdf0e10cSrcweir m_bHighContrastMode)); 1027cdf0e10cSrcweir 1028cdf0e10cSrcweir Size aMarkerSz( aMarker.GetSizePixel() ); 1029cdf0e10cSrcweir aMarkerSz = PixelToLogic( aMarkerSz ); 1030cdf0e10cSrcweir Point aMarkerOff( 0, 0 ); 1031cdf0e10cSrcweir aMarkerOff.X() = ( aOutSz.Width() - aMarkerSz.Width() ) / 2; 1032cdf0e10cSrcweir aMarkerOff.Y() = ( nLineHeight - aMarkerSz.Height() ) / 2; 1033cdf0e10cSrcweir 1034cdf0e10cSrcweir sal_uLong nY = nMarkerPos*nLineHeight - nCurYOffset; 1035cdf0e10cSrcweir Point aPos( 0, nY ); 1036cdf0e10cSrcweir aPos += aMarkerOff; 1037cdf0e10cSrcweir if ( bShow ) 1038cdf0e10cSrcweir DrawImage( aPos, aMarker ); 1039cdf0e10cSrcweir else 1040cdf0e10cSrcweir Invalidate( Rectangle( aPos, aMarkerSz ) ); 1041cdf0e10cSrcweir } 1042cdf0e10cSrcweir 1043cdf0e10cSrcweir 1044cdf0e10cSrcweir 1045cdf0e10cSrcweir 1046cdf0e10cSrcweir BreakPoint* BreakPointWindow::FindBreakPoint( const Point& rMousePos ) 1047cdf0e10cSrcweir { 1048cdf0e10cSrcweir long nLineHeight = GetTextHeight(); 1049cdf0e10cSrcweir long nYPos = rMousePos.Y() + nCurYOffset; 1050cdf0e10cSrcweir // Image aBrk( ((ModulWindowLayout*)pModulWindow->GetLayoutWindow())->GetImage( IMGID_BRKENABLED ) ); 1051cdf0e10cSrcweir // Size aBmpSz( aBrk.GetSizePixel() ); 1052cdf0e10cSrcweir // aBmpSz = PixelToLogic( aBmpSz ); 1053cdf0e10cSrcweir 1054cdf0e10cSrcweir BreakPoint* pBrk = GetBreakPoints().First(); 1055cdf0e10cSrcweir while ( pBrk ) 1056cdf0e10cSrcweir { 1057cdf0e10cSrcweir sal_uLong nLine = pBrk->nLine-1; 1058cdf0e10cSrcweir long nY = nLine*nLineHeight; 1059cdf0e10cSrcweir if ( ( nYPos > nY ) && ( nYPos < ( nY + nLineHeight ) ) ) 1060cdf0e10cSrcweir return pBrk; 1061cdf0e10cSrcweir pBrk = GetBreakPoints().Next(); 1062cdf0e10cSrcweir } 1063cdf0e10cSrcweir return 0; 1064cdf0e10cSrcweir } 1065cdf0e10cSrcweir 1066cdf0e10cSrcweir void __EXPORT BreakPointWindow::MouseButtonDown( const MouseEvent& rMEvt ) 1067cdf0e10cSrcweir { 1068cdf0e10cSrcweir if ( rMEvt.GetClicks() == 2 ) 1069cdf0e10cSrcweir { 1070cdf0e10cSrcweir Point aMousePos( PixelToLogic( rMEvt.GetPosPixel() ) ); 1071cdf0e10cSrcweir long nLineHeight = GetTextHeight(); 1072cdf0e10cSrcweir long nYPos = aMousePos.Y() + nCurYOffset; 1073cdf0e10cSrcweir long nLine = nYPos / nLineHeight + 1; 1074cdf0e10cSrcweir pModulWindow->ToggleBreakPoint( (sal_uLong)nLine ); 1075cdf0e10cSrcweir // vielleicht mal etwas genauer... 1076cdf0e10cSrcweir Invalidate(); 1077cdf0e10cSrcweir } 1078cdf0e10cSrcweir } 1079cdf0e10cSrcweir 1080cdf0e10cSrcweir 1081cdf0e10cSrcweir 1082cdf0e10cSrcweir void __EXPORT BreakPointWindow::Command( const CommandEvent& rCEvt ) 1083cdf0e10cSrcweir { 1084cdf0e10cSrcweir if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) 1085cdf0e10cSrcweir { 1086cdf0e10cSrcweir Point aPos( rCEvt.IsMouseEvent() ? rCEvt.GetMousePosPixel() : Point(1,1) ); 1087cdf0e10cSrcweir Point aEventPos( PixelToLogic( aPos ) ); 1088cdf0e10cSrcweir BreakPoint* pBrk = rCEvt.IsMouseEvent() ? FindBreakPoint( aEventPos ) : 0; 1089cdf0e10cSrcweir if ( pBrk ) 1090cdf0e10cSrcweir { 1091cdf0e10cSrcweir // prueffen, ob Brechpunkt enabled.... 1092cdf0e10cSrcweir PopupMenu aBrkPropMenu( IDEResId( RID_POPUP_BRKPROPS ) ); 1093cdf0e10cSrcweir aBrkPropMenu.CheckItem( RID_ACTIV, pBrk->bEnabled ); 1094cdf0e10cSrcweir switch ( aBrkPropMenu.Execute( this, aPos ) ) 1095cdf0e10cSrcweir { 1096cdf0e10cSrcweir case RID_ACTIV: 1097cdf0e10cSrcweir { 1098cdf0e10cSrcweir pBrk->bEnabled = pBrk->bEnabled ? sal_False : sal_True; 1099cdf0e10cSrcweir pModulWindow->UpdateBreakPoint( *pBrk ); 1100cdf0e10cSrcweir Invalidate(); 1101cdf0e10cSrcweir } 1102cdf0e10cSrcweir break; 1103cdf0e10cSrcweir case RID_BRKPROPS: 1104cdf0e10cSrcweir { 1105cdf0e10cSrcweir BreakPointDialog aBrkDlg( this, GetBreakPoints() ); 1106cdf0e10cSrcweir aBrkDlg.SetCurrentBreakPoint( pBrk ); 1107cdf0e10cSrcweir aBrkDlg.Execute(); 1108cdf0e10cSrcweir Invalidate(); 1109cdf0e10cSrcweir } 1110cdf0e10cSrcweir break; 1111cdf0e10cSrcweir } 1112cdf0e10cSrcweir } 1113cdf0e10cSrcweir else 1114cdf0e10cSrcweir { 1115cdf0e10cSrcweir PopupMenu aBrkListMenu( IDEResId( RID_POPUP_BRKDLG ) ); 1116cdf0e10cSrcweir switch ( aBrkListMenu.Execute( this, aPos ) ) 1117cdf0e10cSrcweir { 1118cdf0e10cSrcweir case RID_BRKDLG: 1119cdf0e10cSrcweir { 1120cdf0e10cSrcweir BreakPointDialog aBrkDlg( this, GetBreakPoints() ); 1121cdf0e10cSrcweir aBrkDlg.Execute(); 1122cdf0e10cSrcweir Invalidate(); 1123cdf0e10cSrcweir } 1124cdf0e10cSrcweir break; 1125cdf0e10cSrcweir } 1126cdf0e10cSrcweir } 1127cdf0e10cSrcweir } 1128cdf0e10cSrcweir } 1129cdf0e10cSrcweir 1130cdf0e10cSrcweir sal_Bool BreakPointWindow::SyncYOffset() 1131cdf0e10cSrcweir { 1132cdf0e10cSrcweir TextView* pView = pModulWindow->GetEditView(); 1133cdf0e10cSrcweir if ( pView ) 1134cdf0e10cSrcweir { 1135cdf0e10cSrcweir long nViewYOffset = pView->GetStartDocPos().Y(); 1136cdf0e10cSrcweir if ( nCurYOffset != nViewYOffset ) 1137cdf0e10cSrcweir { 1138cdf0e10cSrcweir nCurYOffset = nViewYOffset; 1139cdf0e10cSrcweir Invalidate(); 1140cdf0e10cSrcweir return sal_True; 1141cdf0e10cSrcweir } 1142cdf0e10cSrcweir } 1143cdf0e10cSrcweir return sal_False; 1144cdf0e10cSrcweir } 1145cdf0e10cSrcweir 1146cdf0e10cSrcweir // virtual 1147cdf0e10cSrcweir void BreakPointWindow::DataChanged(DataChangedEvent const & rDCEvt) 1148cdf0e10cSrcweir { 1149cdf0e10cSrcweir Window::DataChanged(rDCEvt); 1150cdf0e10cSrcweir if (rDCEvt.GetType() == DATACHANGED_SETTINGS 1151cdf0e10cSrcweir && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0) 1152cdf0e10cSrcweir { 1153cdf0e10cSrcweir Color aColor(GetSettings().GetStyleSettings().GetFieldColor()); 1154cdf0e10cSrcweir if (aColor 1155cdf0e10cSrcweir != rDCEvt.GetOldSettings()->GetStyleSettings().GetFieldColor()) 1156cdf0e10cSrcweir { 1157cdf0e10cSrcweir setBackgroundColor(aColor); 1158cdf0e10cSrcweir m_bHighContrastMode = GetSettings().GetStyleSettings().GetHighContrastMode(); 1159cdf0e10cSrcweir Invalidate(); 1160cdf0e10cSrcweir } 1161cdf0e10cSrcweir } 1162cdf0e10cSrcweir } 1163cdf0e10cSrcweir 1164cdf0e10cSrcweir void BreakPointWindow::setBackgroundColor(Color aColor) 1165cdf0e10cSrcweir { 1166cdf0e10cSrcweir SetBackground(Wallpaper(aColor)); 1167cdf0e10cSrcweir } 1168cdf0e10cSrcweir 1169cdf0e10cSrcweir 1170cdf0e10cSrcweir const sal_uInt16 ITEM_ID_VARIABLE = 1; 1171cdf0e10cSrcweir const sal_uInt16 ITEM_ID_VALUE = 2; 1172cdf0e10cSrcweir const sal_uInt16 ITEM_ID_TYPE = 3; 1173cdf0e10cSrcweir 1174cdf0e10cSrcweir WatchWindow::WatchWindow( Window* pParent ) : 1175cdf0e10cSrcweir BasicDockingWindow( pParent ), 1176cdf0e10cSrcweir aWatchStr( IDEResId( RID_STR_REMOVEWATCH ) ), 1177cdf0e10cSrcweir aXEdit( this, IDEResId( RID_EDT_WATCHEDIT ) ), 1178cdf0e10cSrcweir aRemoveWatchButton( this, IDEResId( RID_IMGBTN_REMOVEWATCH ) ), 1179cdf0e10cSrcweir aTreeListBox( this, WB_BORDER | WB_3DLOOK | WB_HASBUTTONS | WB_HASLINES | WB_HSCROLL | WB_TABSTOP 1180cdf0e10cSrcweir | WB_HASLINESATROOT | WB_HASBUTTONSATROOT ), 1181cdf0e10cSrcweir aHeaderBar( this, WB_BUTTONSTYLE | WB_BORDER ) 1182cdf0e10cSrcweir { 1183cdf0e10cSrcweir aXEdit.SetAccessibleName(String(IDEResId( RID_STR_WATCHNAME))); 1184cdf0e10cSrcweir aTreeListBox.SetAccessibleName(String(IDEResId(RID_STR_WATCHNAME))); 1185cdf0e10cSrcweir 1186cdf0e10cSrcweir nVirtToolBoxHeight = aXEdit.GetSizePixel().Height() + 7; 1187cdf0e10cSrcweir nHeaderBarHeight = 16; 1188cdf0e10cSrcweir 1189cdf0e10cSrcweir aTreeListBox.SetHelpId(HID_BASICIDE_WATCHWINDOW_LIST); 1190cdf0e10cSrcweir aTreeListBox.EnableInplaceEditing( sal_True ); 1191cdf0e10cSrcweir aTreeListBox.SetSelectHdl( LINK( this, WatchWindow, TreeListHdl ) ); 1192cdf0e10cSrcweir aTreeListBox.SetPosPixel( Point( DWBORDER, nVirtToolBoxHeight + nHeaderBarHeight ) ); 1193cdf0e10cSrcweir aTreeListBox.SetHighlightRange( 1, 5 ); 1194cdf0e10cSrcweir 1195cdf0e10cSrcweir Point aPnt( DWBORDER, nVirtToolBoxHeight + 1 ); 1196cdf0e10cSrcweir aHeaderBar.SetPosPixel( aPnt ); 1197cdf0e10cSrcweir aHeaderBar.SetEndDragHdl( LINK( this, WatchWindow, implEndDragHdl ) ); 1198cdf0e10cSrcweir 1199cdf0e10cSrcweir long nVarTabWidth = 220; 1200cdf0e10cSrcweir long nValueTabWidth = 100; 1201cdf0e10cSrcweir long nTypeTabWidth = 1250; 1202cdf0e10cSrcweir aHeaderBar.InsertItem( ITEM_ID_VARIABLE, String( IDEResId( RID_STR_WATCHVARIABLE ) ), nVarTabWidth ); 1203cdf0e10cSrcweir aHeaderBar.InsertItem( ITEM_ID_VALUE, String( IDEResId( RID_STR_WATCHVALUE ) ), nValueTabWidth ); 1204cdf0e10cSrcweir aHeaderBar.InsertItem( ITEM_ID_TYPE, String( IDEResId( RID_STR_WATCHTYPE ) ), nTypeTabWidth ); 1205cdf0e10cSrcweir 1206cdf0e10cSrcweir long tabs[ 4 ]; 1207cdf0e10cSrcweir tabs[ 0 ] = 3; // two tabs 1208cdf0e10cSrcweir tabs[ 1 ] = 0; 1209cdf0e10cSrcweir tabs[ 2 ] = nVarTabWidth; 1210cdf0e10cSrcweir tabs[ 3 ] = nVarTabWidth + nValueTabWidth; 1211cdf0e10cSrcweir aTreeListBox.SvHeaderTabListBox::SetTabs( tabs, MAP_PIXEL ); 1212cdf0e10cSrcweir aTreeListBox.InitHeaderBar( &aHeaderBar ); 1213cdf0e10cSrcweir 1214cdf0e10cSrcweir aTreeListBox.SetNodeDefaultImages( ); 1215cdf0e10cSrcweir 1216cdf0e10cSrcweir aHeaderBar.Show(); 1217cdf0e10cSrcweir 1218cdf0e10cSrcweir aRemoveWatchButton.Disable(); 1219cdf0e10cSrcweir 1220cdf0e10cSrcweir aTreeListBox.Show(); 1221cdf0e10cSrcweir 1222cdf0e10cSrcweir long nTextLen = GetTextWidth( aWatchStr ) + DWBORDER; 1223cdf0e10cSrcweir aXEdit.SetPosPixel( Point( nTextLen, 3 ) ); 1224cdf0e10cSrcweir aXEdit.SetAccHdl( LINK( this, WatchWindow, EditAccHdl ) ); 1225cdf0e10cSrcweir aXEdit.GetAccelerator().InsertItem( 1, KeyCode( KEY_RETURN ) ); 1226cdf0e10cSrcweir aXEdit.GetAccelerator().InsertItem( 2, KeyCode( KEY_ESCAPE ) ); 1227cdf0e10cSrcweir aXEdit.Show(); 1228cdf0e10cSrcweir 1229cdf0e10cSrcweir aRemoveWatchButton.SetModeImage(Image(IDEResId(RID_IMG_REMOVEWATCH_HC)), 1230cdf0e10cSrcweir BMP_COLOR_HIGHCONTRAST); 1231cdf0e10cSrcweir aRemoveWatchButton.SetClickHdl( LINK( this, WatchWindow, ButtonHdl ) ); 1232cdf0e10cSrcweir aRemoveWatchButton.SetPosPixel( Point( nTextLen + aXEdit.GetSizePixel().Width() + 4, 2 ) ); 1233cdf0e10cSrcweir Size aSz( aRemoveWatchButton.GetModeImage().GetSizePixel() ); 1234cdf0e10cSrcweir aSz.Width() += 6; 1235cdf0e10cSrcweir aSz.Height() += 6; 1236cdf0e10cSrcweir aRemoveWatchButton.SetSizePixel( aSz ); 1237cdf0e10cSrcweir aRemoveWatchButton.Show(); 1238cdf0e10cSrcweir 1239cdf0e10cSrcweir SetText( String( IDEResId( RID_STR_WATCHNAME ) ) ); 1240cdf0e10cSrcweir 1241cdf0e10cSrcweir SetHelpId( HID_BASICIDE_WATCHWINDOW ); 1242cdf0e10cSrcweir 1243cdf0e10cSrcweir // make watch window keyboard accessible 1244cdf0e10cSrcweir GetSystemWindow()->GetTaskPaneList()->AddWindow( this ); 1245cdf0e10cSrcweir } 1246cdf0e10cSrcweir 1247cdf0e10cSrcweir 1248cdf0e10cSrcweir 1249cdf0e10cSrcweir __EXPORT WatchWindow::~WatchWindow() 1250cdf0e10cSrcweir { 1251cdf0e10cSrcweir GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); 1252cdf0e10cSrcweir } 1253cdf0e10cSrcweir 1254cdf0e10cSrcweir 1255cdf0e10cSrcweir 1256cdf0e10cSrcweir void __EXPORT WatchWindow::Paint( const Rectangle& ) 1257cdf0e10cSrcweir { 1258cdf0e10cSrcweir DrawText( Point( DWBORDER, 7 ), aWatchStr ); 1259cdf0e10cSrcweir lcl_DrawIDEWindowFrame( this ); 1260cdf0e10cSrcweir } 1261cdf0e10cSrcweir 1262cdf0e10cSrcweir 1263cdf0e10cSrcweir 1264cdf0e10cSrcweir void __EXPORT WatchWindow::Resize() 1265cdf0e10cSrcweir { 1266cdf0e10cSrcweir Size aSz = GetOutputSizePixel(); 1267cdf0e10cSrcweir Size aBoxSz( aSz.Width() - 2*DWBORDER, aSz.Height() - nVirtToolBoxHeight - DWBORDER ); 1268cdf0e10cSrcweir 1269cdf0e10cSrcweir if ( aBoxSz.Width() < 4 ) // < 4, weil noch Border... 1270cdf0e10cSrcweir aBoxSz.Width() = 0; 1271cdf0e10cSrcweir if ( aBoxSz.Height() < 4 ) 1272cdf0e10cSrcweir aBoxSz.Height() = 0; 1273cdf0e10cSrcweir 1274cdf0e10cSrcweir aBoxSz.Height() -= nHeaderBarHeight; 1275cdf0e10cSrcweir aTreeListBox.SetSizePixel( aBoxSz ); 1276cdf0e10cSrcweir aTreeListBox.GetHScroll()->SetPageSize( aTreeListBox.GetHScroll()->GetVisibleSize() ); 1277cdf0e10cSrcweir 1278cdf0e10cSrcweir aBoxSz.Height() = nHeaderBarHeight; 1279cdf0e10cSrcweir aHeaderBar.SetSizePixel( aBoxSz ); 1280cdf0e10cSrcweir 1281cdf0e10cSrcweir Invalidate(); //Wegen DrawLine im Paint... 1282cdf0e10cSrcweir } 1283cdf0e10cSrcweir 1284cdf0e10cSrcweir struct MemberList 1285cdf0e10cSrcweir { 1286cdf0e10cSrcweir String* mpMemberNames; 1287cdf0e10cSrcweir int mnMemberCount; 1288cdf0e10cSrcweir 1289cdf0e10cSrcweir MemberList( void ) 1290cdf0e10cSrcweir : mpMemberNames( NULL ) 1291cdf0e10cSrcweir , mnMemberCount( 0 ) 1292cdf0e10cSrcweir {} 1293cdf0e10cSrcweir ~MemberList() 1294cdf0e10cSrcweir { 1295cdf0e10cSrcweir clear(); 1296cdf0e10cSrcweir } 1297cdf0e10cSrcweir 1298cdf0e10cSrcweir void clear( void ); 1299cdf0e10cSrcweir void allocList( int nCount ); 1300cdf0e10cSrcweir }; 1301cdf0e10cSrcweir 1302cdf0e10cSrcweir void MemberList::clear( void ) 1303cdf0e10cSrcweir { 1304cdf0e10cSrcweir if( mnMemberCount ) 1305cdf0e10cSrcweir { 1306cdf0e10cSrcweir delete[] mpMemberNames; 1307cdf0e10cSrcweir mnMemberCount = 0; 1308cdf0e10cSrcweir } 1309cdf0e10cSrcweir } 1310cdf0e10cSrcweir 1311cdf0e10cSrcweir void MemberList::allocList( int nCount ) 1312cdf0e10cSrcweir { 1313cdf0e10cSrcweir clear(); 1314cdf0e10cSrcweir if( nCount > 0 ) 1315cdf0e10cSrcweir { 1316cdf0e10cSrcweir mnMemberCount = nCount; 1317cdf0e10cSrcweir mpMemberNames = new String[ mnMemberCount ]; 1318cdf0e10cSrcweir } 1319cdf0e10cSrcweir } 1320cdf0e10cSrcweir 1321cdf0e10cSrcweir struct WatchItem 1322cdf0e10cSrcweir { 1323cdf0e10cSrcweir String maName; 1324cdf0e10cSrcweir String maDisplayName; 1325cdf0e10cSrcweir SbxObjectRef mpObject; 1326cdf0e10cSrcweir MemberList maMemberList; 1327cdf0e10cSrcweir 1328cdf0e10cSrcweir SbxDimArrayRef mpArray; 1329cdf0e10cSrcweir int nDimLevel; // 0 = Root 1330cdf0e10cSrcweir int nDimCount; 1331cdf0e10cSrcweir short* pIndices; 1332cdf0e10cSrcweir 1333cdf0e10cSrcweir WatchItem* mpArrayParentItem; 1334cdf0e10cSrcweir 1335cdf0e10cSrcweir WatchItem( void ) 1336cdf0e10cSrcweir : nDimLevel( 0 ) 1337cdf0e10cSrcweir , nDimCount( 0 ) 1338cdf0e10cSrcweir , pIndices( NULL ) 1339cdf0e10cSrcweir , mpArrayParentItem( NULL ) 1340cdf0e10cSrcweir {} 1341cdf0e10cSrcweir ~WatchItem() 1342cdf0e10cSrcweir { clearWatchItem(); } 1343cdf0e10cSrcweir 1344cdf0e10cSrcweir void clearWatchItem( bool bIncludeArrayData=true ) 1345cdf0e10cSrcweir { 1346cdf0e10cSrcweir mpObject = NULL; 1347cdf0e10cSrcweir maMemberList.clear(); 1348cdf0e10cSrcweir if( bIncludeArrayData ) 1349cdf0e10cSrcweir { 1350cdf0e10cSrcweir mpArray = NULL; 1351cdf0e10cSrcweir nDimLevel = 0; 1352cdf0e10cSrcweir nDimCount = 0; 1353cdf0e10cSrcweir delete[] pIndices; 1354cdf0e10cSrcweir pIndices = NULL; 1355cdf0e10cSrcweir } 1356cdf0e10cSrcweir } 1357cdf0e10cSrcweir 1358cdf0e10cSrcweir WatchItem* GetRootItem( void ); 1359cdf0e10cSrcweir SbxDimArray* GetRootArray( void ); 1360cdf0e10cSrcweir }; 1361cdf0e10cSrcweir 1362cdf0e10cSrcweir WatchItem* WatchItem::GetRootItem( void ) 1363cdf0e10cSrcweir { 1364cdf0e10cSrcweir WatchItem* pItem = mpArrayParentItem; 1365cdf0e10cSrcweir while( pItem ) 1366cdf0e10cSrcweir { 1367cdf0e10cSrcweir if( pItem->mpArray.Is() ) 1368cdf0e10cSrcweir break; 1369cdf0e10cSrcweir pItem = pItem->mpArrayParentItem; 1370cdf0e10cSrcweir } 1371cdf0e10cSrcweir return pItem; 1372cdf0e10cSrcweir } 1373cdf0e10cSrcweir 1374cdf0e10cSrcweir SbxDimArray* WatchItem::GetRootArray( void ) 1375cdf0e10cSrcweir { 1376cdf0e10cSrcweir WatchItem* pRootItem = GetRootItem(); 1377cdf0e10cSrcweir SbxDimArray* pRet = NULL; 1378cdf0e10cSrcweir if( pRootItem ) 1379cdf0e10cSrcweir pRet = pRootItem->mpArray; 1380cdf0e10cSrcweir return pRet; 1381cdf0e10cSrcweir } 1382cdf0e10cSrcweir 1383cdf0e10cSrcweir void WatchWindow::AddWatch( const String& rVName ) 1384cdf0e10cSrcweir { 1385cdf0e10cSrcweir WatchItem* pWatchItem = new WatchItem; 1386cdf0e10cSrcweir String aVar, aIndex; 1387cdf0e10cSrcweir lcl_SeparateNameAndIndex( rVName, aVar, aIndex ); 1388cdf0e10cSrcweir pWatchItem->maName = aVar; 1389cdf0e10cSrcweir 1390cdf0e10cSrcweir String aWatchStr_( aVar ); 1391cdf0e10cSrcweir aWatchStr_ += String( RTL_CONSTASCII_USTRINGPARAM( "\t\t" ) ); 1392cdf0e10cSrcweir SvLBoxEntry* pNewEntry = aTreeListBox.InsertEntry( aWatchStr_, 0, sal_True, LIST_APPEND ); 1393cdf0e10cSrcweir pNewEntry->SetUserData( pWatchItem ); 1394cdf0e10cSrcweir 1395cdf0e10cSrcweir aTreeListBox.Select( pNewEntry, sal_True ); 1396cdf0e10cSrcweir aTreeListBox.MakeVisible( pNewEntry ); 1397cdf0e10cSrcweir aRemoveWatchButton.Enable(); 1398cdf0e10cSrcweir } 1399cdf0e10cSrcweir 1400cdf0e10cSrcweir sal_Bool WatchWindow::RemoveSelectedWatch() 1401cdf0e10cSrcweir { 1402cdf0e10cSrcweir SvLBoxEntry* pEntry = aTreeListBox.GetCurEntry(); 1403cdf0e10cSrcweir if ( pEntry ) 1404cdf0e10cSrcweir { 1405cdf0e10cSrcweir aTreeListBox.GetModel()->Remove( pEntry ); 1406cdf0e10cSrcweir pEntry = aTreeListBox.GetCurEntry(); 1407cdf0e10cSrcweir if ( pEntry ) 1408cdf0e10cSrcweir aXEdit.SetText( ((WatchItem*)pEntry->GetUserData())->maName ); 1409cdf0e10cSrcweir else 1410cdf0e10cSrcweir aXEdit.SetText( String() ); 1411cdf0e10cSrcweir if ( !aTreeListBox.GetEntryCount() ) 1412cdf0e10cSrcweir aRemoveWatchButton.Disable(); 1413cdf0e10cSrcweir return sal_True; 1414cdf0e10cSrcweir } 1415cdf0e10cSrcweir else 1416cdf0e10cSrcweir return sal_False; 1417cdf0e10cSrcweir } 1418cdf0e10cSrcweir 1419cdf0e10cSrcweir 1420cdf0e10cSrcweir IMPL_LINK_INLINE_START( WatchWindow, ButtonHdl, ImageButton *, pButton ) 1421cdf0e10cSrcweir { 1422cdf0e10cSrcweir if ( pButton == &aRemoveWatchButton ) 1423cdf0e10cSrcweir { 1424cdf0e10cSrcweir BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); 1425cdf0e10cSrcweir SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; 1426cdf0e10cSrcweir SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; 1427cdf0e10cSrcweir if( pDispatcher ) 1428cdf0e10cSrcweir { 1429cdf0e10cSrcweir pDispatcher->Execute( SID_BASICIDE_REMOVEWATCH ); 1430cdf0e10cSrcweir } 1431cdf0e10cSrcweir } 1432cdf0e10cSrcweir return 0; 1433cdf0e10cSrcweir } 1434cdf0e10cSrcweir IMPL_LINK_INLINE_END( WatchWindow, ButtonHdl, ImageButton *, pButton ) 1435cdf0e10cSrcweir 1436cdf0e10cSrcweir 1437cdf0e10cSrcweir 1438cdf0e10cSrcweir IMPL_LINK_INLINE_START( WatchWindow, TreeListHdl, SvTreeListBox *, EMPTYARG ) 1439cdf0e10cSrcweir { 1440cdf0e10cSrcweir SvLBoxEntry* pCurEntry = aTreeListBox.GetCurEntry(); 1441cdf0e10cSrcweir if ( pCurEntry && pCurEntry->GetUserData() ) 1442cdf0e10cSrcweir aXEdit.SetText( ((WatchItem*)pCurEntry->GetUserData())->maName ); 1443cdf0e10cSrcweir 1444cdf0e10cSrcweir return 0; 1445cdf0e10cSrcweir } 1446cdf0e10cSrcweir IMPL_LINK_INLINE_END( WatchWindow, TreeListHdl, SvTreeListBox *, EMPTYARG ) 1447cdf0e10cSrcweir 1448cdf0e10cSrcweir 1449cdf0e10cSrcweir IMPL_LINK_INLINE_START( WatchWindow, implEndDragHdl, HeaderBar *, pBar ) 1450cdf0e10cSrcweir { 1451cdf0e10cSrcweir (void)pBar; 1452cdf0e10cSrcweir 1453cdf0e10cSrcweir const sal_Int32 TAB_WIDTH_MIN = 10; 1454cdf0e10cSrcweir sal_Int32 nMaxWidth = 1455cdf0e10cSrcweir aHeaderBar.GetSizePixel().getWidth() - 2 * TAB_WIDTH_MIN; 1456cdf0e10cSrcweir 1457cdf0e10cSrcweir sal_Int32 nVariableWith = aHeaderBar.GetItemSize( ITEM_ID_VARIABLE ); 1458cdf0e10cSrcweir if( nVariableWith < TAB_WIDTH_MIN ) 1459cdf0e10cSrcweir aHeaderBar.SetItemSize( ITEM_ID_VARIABLE, TAB_WIDTH_MIN ); 1460cdf0e10cSrcweir else if( nVariableWith > nMaxWidth ) 1461cdf0e10cSrcweir aHeaderBar.SetItemSize( ITEM_ID_VARIABLE, nMaxWidth ); 1462cdf0e10cSrcweir 1463cdf0e10cSrcweir sal_Int32 nValueWith = aHeaderBar.GetItemSize( ITEM_ID_VALUE ); 1464cdf0e10cSrcweir if( nValueWith < TAB_WIDTH_MIN ) 1465cdf0e10cSrcweir aHeaderBar.SetItemSize( ITEM_ID_VALUE, TAB_WIDTH_MIN ); 1466cdf0e10cSrcweir else if( nValueWith > nMaxWidth ) 1467cdf0e10cSrcweir aHeaderBar.SetItemSize( ITEM_ID_VALUE, nMaxWidth ); 1468cdf0e10cSrcweir 1469cdf0e10cSrcweir if (aHeaderBar.GetItemSize( ITEM_ID_TYPE ) < TAB_WIDTH_MIN) 1470cdf0e10cSrcweir aHeaderBar.SetItemSize( ITEM_ID_TYPE, TAB_WIDTH_MIN ); 1471cdf0e10cSrcweir 1472cdf0e10cSrcweir sal_Int32 nPos = 0; 1473cdf0e10cSrcweir sal_uInt16 nTabs = aHeaderBar.GetItemCount(); 1474cdf0e10cSrcweir // OSL_ASSERT( m_treelb->TabCount() == nTabs ); 1475cdf0e10cSrcweir for( sal_uInt16 i = 1 ; i < nTabs ; ++i ) 1476cdf0e10cSrcweir { 1477cdf0e10cSrcweir nPos += aHeaderBar.GetItemSize( i ); 1478cdf0e10cSrcweir aTreeListBox.SetTab( i, nPos, MAP_PIXEL ); 1479cdf0e10cSrcweir } 1480cdf0e10cSrcweir return 0; 1481cdf0e10cSrcweir } 1482cdf0e10cSrcweir IMPL_LINK_INLINE_END( WatchWindow, implEndDragHdl, HeaderBar *, pBar ) 1483cdf0e10cSrcweir 1484cdf0e10cSrcweir 1485cdf0e10cSrcweir IMPL_LINK( WatchWindow, EditAccHdl, Accelerator *, pAcc ) 1486cdf0e10cSrcweir { 1487cdf0e10cSrcweir switch ( pAcc->GetCurKeyCode().GetCode() ) 1488cdf0e10cSrcweir { 1489cdf0e10cSrcweir case KEY_RETURN: 1490cdf0e10cSrcweir { 1491cdf0e10cSrcweir String aCurText( aXEdit.GetText() ); 1492cdf0e10cSrcweir if ( aCurText.Len() ) 1493cdf0e10cSrcweir { 1494cdf0e10cSrcweir AddWatch( aCurText ); 1495cdf0e10cSrcweir aXEdit.SetSelection( Selection( 0, 0xFFFF ) ); 1496cdf0e10cSrcweir UpdateWatches(); 1497cdf0e10cSrcweir } 1498cdf0e10cSrcweir else 1499cdf0e10cSrcweir Sound::Beep(); 1500cdf0e10cSrcweir } 1501cdf0e10cSrcweir break; 1502cdf0e10cSrcweir case KEY_ESCAPE: 1503cdf0e10cSrcweir { 1504cdf0e10cSrcweir aXEdit.SetText( String() ); 1505cdf0e10cSrcweir } 1506cdf0e10cSrcweir break; 1507cdf0e10cSrcweir } 1508cdf0e10cSrcweir 1509cdf0e10cSrcweir return 0; 1510cdf0e10cSrcweir } 1511cdf0e10cSrcweir 1512cdf0e10cSrcweir void WatchWindow::UpdateWatches( bool bBasicStopped ) 1513cdf0e10cSrcweir { 1514cdf0e10cSrcweir aTreeListBox.UpdateWatches( bBasicStopped ); 1515cdf0e10cSrcweir } 1516cdf0e10cSrcweir 1517cdf0e10cSrcweir 1518cdf0e10cSrcweir StackWindow::StackWindow( Window* pParent ) : 1519cdf0e10cSrcweir BasicDockingWindow( pParent ), 1520cdf0e10cSrcweir aTreeListBox( this, WB_BORDER | WB_3DLOOK | WB_HSCROLL | WB_TABSTOP ), 1521cdf0e10cSrcweir aGotoCallButton( this, IDEResId( RID_IMGBTN_GOTOCALL ) ), 1522cdf0e10cSrcweir aStackStr( IDEResId( RID_STR_STACK ) ) 1523cdf0e10cSrcweir { 1524cdf0e10cSrcweir aTreeListBox.SetHelpId(HID_BASICIDE_STACKWINDOW_LIST); 1525cdf0e10cSrcweir aTreeListBox.SetAccessibleName(String( IDEResId(RID_STR_STACKNAME))); 1526cdf0e10cSrcweir aTreeListBox.SetPosPixel( Point( DWBORDER, nVirtToolBoxHeight ) ); 1527cdf0e10cSrcweir aTreeListBox.SetHighlightRange(); 1528cdf0e10cSrcweir aTreeListBox.SetSelectionMode( NO_SELECTION ); 1529cdf0e10cSrcweir aTreeListBox.InsertEntry( String(), 0, sal_False, LIST_APPEND ); 1530cdf0e10cSrcweir aTreeListBox.Show(); 1531cdf0e10cSrcweir 1532cdf0e10cSrcweir SetText( String( IDEResId( RID_STR_STACKNAME ) ) ); 1533cdf0e10cSrcweir 1534cdf0e10cSrcweir SetHelpId( HID_BASICIDE_STACKWINDOW ); 1535cdf0e10cSrcweir 1536cdf0e10cSrcweir aGotoCallButton.SetClickHdl( LINK( this, StackWindow, ButtonHdl ) ); 1537cdf0e10cSrcweir aGotoCallButton.SetPosPixel( Point( DWBORDER, 2 ) ); 1538cdf0e10cSrcweir Size aSz( aGotoCallButton.GetModeImage().GetSizePixel() ); 1539cdf0e10cSrcweir aSz.Width() += 6; 1540cdf0e10cSrcweir aSz.Height() += 6; 1541cdf0e10cSrcweir aGotoCallButton.SetSizePixel( aSz ); 1542cdf0e10cSrcweir // aGotoCallButton.Show(); // wird vom Basic noch nicht unterstuetzt! 1543cdf0e10cSrcweir aGotoCallButton.Hide(); 1544cdf0e10cSrcweir 1545cdf0e10cSrcweir // make stack window keyboard accessible 1546cdf0e10cSrcweir GetSystemWindow()->GetTaskPaneList()->AddWindow( this ); 1547cdf0e10cSrcweir } 1548cdf0e10cSrcweir 1549cdf0e10cSrcweir 1550cdf0e10cSrcweir 1551cdf0e10cSrcweir __EXPORT StackWindow::~StackWindow() 1552cdf0e10cSrcweir { 1553cdf0e10cSrcweir GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); 1554cdf0e10cSrcweir } 1555cdf0e10cSrcweir 1556cdf0e10cSrcweir 1557cdf0e10cSrcweir 1558cdf0e10cSrcweir void __EXPORT StackWindow::Paint( const Rectangle& ) 1559cdf0e10cSrcweir { 1560cdf0e10cSrcweir DrawText( Point( DWBORDER, 7 ), aStackStr ); 1561cdf0e10cSrcweir lcl_DrawIDEWindowFrame( this ); 1562cdf0e10cSrcweir } 1563cdf0e10cSrcweir 1564cdf0e10cSrcweir 1565cdf0e10cSrcweir 1566cdf0e10cSrcweir void __EXPORT StackWindow::Resize() 1567cdf0e10cSrcweir { 1568cdf0e10cSrcweir Size aSz = GetOutputSizePixel(); 1569cdf0e10cSrcweir Size aBoxSz( aSz.Width() - 2*DWBORDER, aSz.Height() - nVirtToolBoxHeight - DWBORDER ); 1570cdf0e10cSrcweir 1571cdf0e10cSrcweir if ( aBoxSz.Width() < 4 ) // < 4, weil noch Border... 1572cdf0e10cSrcweir aBoxSz.Width() = 0; 1573cdf0e10cSrcweir if ( aBoxSz.Height() < 4 ) 1574cdf0e10cSrcweir aBoxSz.Height() = 0; 1575cdf0e10cSrcweir 1576cdf0e10cSrcweir aTreeListBox.SetSizePixel( aBoxSz ); 1577cdf0e10cSrcweir 1578cdf0e10cSrcweir Invalidate(); //Wegen DrawLine im Paint... 1579cdf0e10cSrcweir } 1580cdf0e10cSrcweir 1581cdf0e10cSrcweir 1582cdf0e10cSrcweir 1583cdf0e10cSrcweir IMPL_LINK_INLINE_START( StackWindow, ButtonHdl, ImageButton *, pButton ) 1584cdf0e10cSrcweir { 1585cdf0e10cSrcweir if ( pButton == &aGotoCallButton ) 1586cdf0e10cSrcweir { 1587cdf0e10cSrcweir BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); 1588cdf0e10cSrcweir SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; 1589cdf0e10cSrcweir SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; 1590cdf0e10cSrcweir if( pDispatcher ) 1591cdf0e10cSrcweir { 1592cdf0e10cSrcweir pDispatcher->Execute( SID_BASICIDE_GOTOCALL ); 1593cdf0e10cSrcweir } 1594cdf0e10cSrcweir } 1595cdf0e10cSrcweir return 0; 1596cdf0e10cSrcweir } 1597cdf0e10cSrcweir IMPL_LINK_INLINE_END( StackWindow, ButtonHdl, ImageButton *, pButton ) 1598cdf0e10cSrcweir 1599cdf0e10cSrcweir 1600cdf0e10cSrcweir 1601cdf0e10cSrcweir void __EXPORT StackWindow::UpdateCalls() 1602cdf0e10cSrcweir { 1603cdf0e10cSrcweir aTreeListBox.SetUpdateMode( sal_False ); 1604cdf0e10cSrcweir aTreeListBox.Clear(); 1605cdf0e10cSrcweir 1606cdf0e10cSrcweir if ( StarBASIC::IsRunning() ) 1607cdf0e10cSrcweir { 1608cdf0e10cSrcweir SbxError eOld = SbxBase::GetError(); 1609cdf0e10cSrcweir aTreeListBox.SetSelectionMode( SINGLE_SELECTION ); 1610cdf0e10cSrcweir 1611cdf0e10cSrcweir sal_uInt16 nScope = 0; 1612cdf0e10cSrcweir SbMethod* pMethod = StarBASIC::GetActiveMethod( nScope ); 1613cdf0e10cSrcweir while ( pMethod ) 1614cdf0e10cSrcweir { 1615cdf0e10cSrcweir String aEntry( String::CreateFromInt32(nScope )); 1616cdf0e10cSrcweir if ( aEntry.Len() < 2 ) 1617cdf0e10cSrcweir aEntry.Insert( ' ', 0 ); 1618cdf0e10cSrcweir aEntry += String( RTL_CONSTASCII_USTRINGPARAM( ": " ) ); 1619cdf0e10cSrcweir aEntry += pMethod->GetName(); 1620cdf0e10cSrcweir SbxArray* pParams = pMethod->GetParameters(); 1621cdf0e10cSrcweir SbxInfo* pInfo = pMethod->GetInfo(); 1622cdf0e10cSrcweir if ( pParams ) 1623cdf0e10cSrcweir { 1624cdf0e10cSrcweir aEntry += '('; 1625cdf0e10cSrcweir // 0 ist der Name der Sub... 1626cdf0e10cSrcweir for ( sal_uInt16 nParam = 1; nParam < pParams->Count(); nParam++ ) 1627cdf0e10cSrcweir { 1628cdf0e10cSrcweir SbxVariable* pVar = pParams->Get( nParam ); 1629cdf0e10cSrcweir DBG_ASSERT( pVar, "Parameter?!" ); 1630cdf0e10cSrcweir if ( pVar->GetName().Len() ) 1631cdf0e10cSrcweir aEntry += pVar->GetName(); 1632cdf0e10cSrcweir else if ( pInfo ) 1633cdf0e10cSrcweir { 1634cdf0e10cSrcweir const SbxParamInfo* pParam = pInfo->GetParam( nParam ); 1635cdf0e10cSrcweir if ( pParam ) 1636cdf0e10cSrcweir aEntry += pParam->aName; 1637cdf0e10cSrcweir } 1638cdf0e10cSrcweir aEntry += '='; 1639cdf0e10cSrcweir SbxDataType eType = pVar->GetType(); 1640cdf0e10cSrcweir if( eType & SbxARRAY ) 1641cdf0e10cSrcweir aEntry += String( RTL_CONSTASCII_USTRINGPARAM( "..." ) ); 1642cdf0e10cSrcweir else if( eType != SbxOBJECT ) 1643cdf0e10cSrcweir aEntry += pVar->GetString(); 1644cdf0e10cSrcweir if ( nParam < ( pParams->Count() - 1 ) ) 1645cdf0e10cSrcweir aEntry += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) ); 1646cdf0e10cSrcweir } 1647cdf0e10cSrcweir aEntry += ')'; 1648cdf0e10cSrcweir } 1649cdf0e10cSrcweir aTreeListBox.InsertEntry( aEntry, 0, sal_False, LIST_APPEND ); 1650cdf0e10cSrcweir nScope++; 1651cdf0e10cSrcweir pMethod = StarBASIC::GetActiveMethod( nScope ); 1652cdf0e10cSrcweir } 1653cdf0e10cSrcweir 1654cdf0e10cSrcweir SbxBase::ResetError(); 1655cdf0e10cSrcweir if( eOld != SbxERR_OK ) 1656cdf0e10cSrcweir SbxBase::SetError( eOld ); 1657cdf0e10cSrcweir } 1658cdf0e10cSrcweir else 1659cdf0e10cSrcweir { 1660cdf0e10cSrcweir aTreeListBox.SetSelectionMode( NO_SELECTION ); 1661cdf0e10cSrcweir aTreeListBox.InsertEntry( String(), 0, sal_False, LIST_APPEND ); 1662cdf0e10cSrcweir } 1663cdf0e10cSrcweir 1664cdf0e10cSrcweir aTreeListBox.SetUpdateMode( sal_True ); 1665cdf0e10cSrcweir } 1666cdf0e10cSrcweir 1667cdf0e10cSrcweir 1668cdf0e10cSrcweir 1669cdf0e10cSrcweir 1670cdf0e10cSrcweir ComplexEditorWindow::ComplexEditorWindow( ModulWindow* pParent ) : 1671cdf0e10cSrcweir Window( pParent, WB_3DLOOK | WB_CLIPCHILDREN ), 1672cdf0e10cSrcweir aBrkWindow( this ), 1673cdf0e10cSrcweir aEdtWindow( this ), 1674cdf0e10cSrcweir aEWVScrollBar( this, WB_VSCROLL | WB_DRAG ) 1675cdf0e10cSrcweir { 1676cdf0e10cSrcweir aEdtWindow.SetModulWindow( pParent ); 1677cdf0e10cSrcweir aBrkWindow.SetModulWindow( pParent ); 1678cdf0e10cSrcweir aEdtWindow.Show(); 1679cdf0e10cSrcweir aBrkWindow.Show(); 1680cdf0e10cSrcweir 1681cdf0e10cSrcweir aEWVScrollBar.SetLineSize( SCROLL_LINE ); 1682cdf0e10cSrcweir aEWVScrollBar.SetPageSize( SCROLL_PAGE ); 1683cdf0e10cSrcweir aEWVScrollBar.SetScrollHdl( LINK( this, ComplexEditorWindow, ScrollHdl ) ); 1684cdf0e10cSrcweir aEWVScrollBar.Show(); 1685cdf0e10cSrcweir } 1686cdf0e10cSrcweir 1687cdf0e10cSrcweir 1688cdf0e10cSrcweir 1689cdf0e10cSrcweir void __EXPORT ComplexEditorWindow::Resize() 1690cdf0e10cSrcweir { 1691cdf0e10cSrcweir Size aOutSz = GetOutputSizePixel(); 1692cdf0e10cSrcweir Size aSz( aOutSz ); 1693cdf0e10cSrcweir aSz.Width() -= 2*DWBORDER; 1694cdf0e10cSrcweir aSz.Height() -= 2*DWBORDER; 1695cdf0e10cSrcweir long nBrkWidth = 20; 1696cdf0e10cSrcweir long nSBWidth = aEWVScrollBar.GetSizePixel().Width(); 1697cdf0e10cSrcweir 1698cdf0e10cSrcweir Size aBrkSz( Size( nBrkWidth, aSz.Height() ) ); 1699cdf0e10cSrcweir aBrkWindow.SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz ); 1700cdf0e10cSrcweir 1701cdf0e10cSrcweir Size aEWSz( Size( aSz.Width() - nBrkWidth - nSBWidth + 2, aSz.Height() ) ); 1702cdf0e10cSrcweir aEdtWindow.SetPosSizePixel( Point( DWBORDER+aBrkSz.Width()-1, DWBORDER ), aEWSz ); 1703cdf0e10cSrcweir 1704cdf0e10cSrcweir aEWVScrollBar.SetPosSizePixel( Point( aOutSz.Width()-DWBORDER-nSBWidth, DWBORDER ), Size( nSBWidth, aSz.Height() ) ); 1705cdf0e10cSrcweir 1706cdf0e10cSrcweir // Macht das EditorWindow, ausserdem hier falsch, da Pixel 1707cdf0e10cSrcweir // aEWVScrollBar.SetPageSize( aEWSz.Height() * 8 / 10 ); 1708cdf0e10cSrcweir // aEWVScrollBar.SetVisibleSize( aSz.Height() ); 1709cdf0e10cSrcweir // Invalidate(); 1710cdf0e10cSrcweir } 1711cdf0e10cSrcweir 1712cdf0e10cSrcweir IMPL_LINK( ComplexEditorWindow, ScrollHdl, ScrollBar *, pCurScrollBar ) 1713cdf0e10cSrcweir { 1714cdf0e10cSrcweir if ( aEdtWindow.GetEditView() ) 1715cdf0e10cSrcweir { 1716cdf0e10cSrcweir DBG_ASSERT( pCurScrollBar == &aEWVScrollBar, "Wer scrollt hier ?" ); 1717cdf0e10cSrcweir long nDiff = aEdtWindow.GetEditView()->GetStartDocPos().Y() - pCurScrollBar->GetThumbPos(); 1718cdf0e10cSrcweir aEdtWindow.GetEditView()->Scroll( 0, nDiff ); 1719cdf0e10cSrcweir aBrkWindow.DoScroll( 0, nDiff ); 1720cdf0e10cSrcweir aEdtWindow.GetEditView()->ShowCursor( sal_False, sal_True ); 1721cdf0e10cSrcweir pCurScrollBar->SetThumbPos( aEdtWindow.GetEditView()->GetStartDocPos().Y() ); 1722cdf0e10cSrcweir } 1723cdf0e10cSrcweir 1724cdf0e10cSrcweir return 0; 1725cdf0e10cSrcweir } 1726cdf0e10cSrcweir 1727cdf0e10cSrcweir // virtual 1728cdf0e10cSrcweir void ComplexEditorWindow::DataChanged(DataChangedEvent const & rDCEvt) 1729cdf0e10cSrcweir { 1730cdf0e10cSrcweir Window::DataChanged(rDCEvt); 1731cdf0e10cSrcweir if (rDCEvt.GetType() == DATACHANGED_SETTINGS 1732cdf0e10cSrcweir && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0) 1733cdf0e10cSrcweir { 1734cdf0e10cSrcweir Color aColor(GetSettings().GetStyleSettings().GetFaceColor()); 1735cdf0e10cSrcweir if (aColor 1736cdf0e10cSrcweir != rDCEvt.GetOldSettings()->GetStyleSettings().GetFaceColor()) 1737cdf0e10cSrcweir { 1738cdf0e10cSrcweir SetBackground(Wallpaper(aColor)); 1739cdf0e10cSrcweir Invalidate(); 1740cdf0e10cSrcweir } 1741cdf0e10cSrcweir } 1742cdf0e10cSrcweir } 1743cdf0e10cSrcweir 1744cdf0e10cSrcweir // virtual 1745cdf0e10cSrcweir uno::Reference< awt::XWindowPeer > 1746cdf0e10cSrcweir EditorWindow::GetComponentInterface(sal_Bool bCreate) 1747cdf0e10cSrcweir { 1748cdf0e10cSrcweir uno::Reference< awt::XWindowPeer > xPeer( 1749cdf0e10cSrcweir Window::GetComponentInterface(false)); 1750cdf0e10cSrcweir if (!xPeer.is() && bCreate) 1751cdf0e10cSrcweir { 1752cdf0e10cSrcweir // Make sure edit engine and view are available: 1753cdf0e10cSrcweir if (!pEditEngine) 1754cdf0e10cSrcweir CreateEditEngine(); 1755cdf0e10cSrcweir 1756cdf0e10cSrcweir xPeer = new ::svt::TextWindowPeer(*GetEditView()); 1757cdf0e10cSrcweir SetComponentInterface(xPeer); 1758cdf0e10cSrcweir } 1759cdf0e10cSrcweir return xPeer; 1760cdf0e10cSrcweir } 1761cdf0e10cSrcweir 1762cdf0e10cSrcweir WatchTreeListBox::WatchTreeListBox( Window* pParent, WinBits nWinBits ) 1763cdf0e10cSrcweir : SvHeaderTabListBox( pParent, nWinBits ) 1764cdf0e10cSrcweir {} 1765cdf0e10cSrcweir 1766cdf0e10cSrcweir WatchTreeListBox::~WatchTreeListBox() 1767cdf0e10cSrcweir { 1768cdf0e10cSrcweir // User-Daten zerstoeren... 1769cdf0e10cSrcweir SvLBoxEntry* pEntry = First(); 1770cdf0e10cSrcweir while ( pEntry ) 1771cdf0e10cSrcweir { 1772cdf0e10cSrcweir delete (WatchItem*)pEntry->GetUserData(); 1773cdf0e10cSrcweir pEntry = Next( pEntry ); 1774cdf0e10cSrcweir } 1775cdf0e10cSrcweir } 1776cdf0e10cSrcweir 1777cdf0e10cSrcweir void WatchTreeListBox::SetTabs() 1778cdf0e10cSrcweir { 1779cdf0e10cSrcweir SvHeaderTabListBox::SetTabs(); 1780cdf0e10cSrcweir sal_uInt16 nTabCount_ = aTabs.Count(); 1781cdf0e10cSrcweir for( sal_uInt16 i = 0 ; i < nTabCount_ ; i++ ) 1782cdf0e10cSrcweir { 1783cdf0e10cSrcweir SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(i); 1784cdf0e10cSrcweir if( i == 2 ) 1785cdf0e10cSrcweir pTab->nFlags |= SV_LBOXTAB_EDITABLE; 1786cdf0e10cSrcweir else 1787cdf0e10cSrcweir pTab->nFlags &= ~SV_LBOXTAB_EDITABLE; 1788cdf0e10cSrcweir } 1789cdf0e10cSrcweir } 1790cdf0e10cSrcweir 1791cdf0e10cSrcweir void WatchTreeListBox::RequestingChilds( SvLBoxEntry * pParent ) 1792cdf0e10cSrcweir { 1793cdf0e10cSrcweir if( !StarBASIC::IsRunning() ) 1794cdf0e10cSrcweir return; 1795cdf0e10cSrcweir 1796cdf0e10cSrcweir if( GetChildCount( pParent ) > 0 ) 1797cdf0e10cSrcweir return; 1798cdf0e10cSrcweir 1799cdf0e10cSrcweir SvLBoxEntry * pEntry = pParent; 1800cdf0e10cSrcweir WatchItem* pItem = (WatchItem*)pEntry->GetUserData(); 1801cdf0e10cSrcweir 1802cdf0e10cSrcweir SbxDimArray* pArray = pItem->mpArray; 1803cdf0e10cSrcweir SbxDimArray* pRootArray = pItem->GetRootArray(); 1804cdf0e10cSrcweir bool bArrayIsRootArray = false; 1805cdf0e10cSrcweir if( !pArray && pRootArray ) 1806cdf0e10cSrcweir { 1807cdf0e10cSrcweir pArray = pRootArray; 1808cdf0e10cSrcweir bArrayIsRootArray = true; 1809cdf0e10cSrcweir } 1810cdf0e10cSrcweir 1811cdf0e10cSrcweir SbxObject* pObj = pItem->mpObject; 1812cdf0e10cSrcweir if( pObj ) 1813cdf0e10cSrcweir { 1814cdf0e10cSrcweir createAllObjectProperties( pObj ); 1815cdf0e10cSrcweir SbxArray* pProps = pObj->GetProperties(); 1816cdf0e10cSrcweir sal_uInt16 nPropCount = pProps->Count(); 1817cdf0e10cSrcweir pItem->maMemberList.allocList( nPropCount ); 1818cdf0e10cSrcweir 1819cdf0e10cSrcweir for( sal_uInt16 i = 0 ; i < nPropCount - 3 ; i++ ) 1820cdf0e10cSrcweir { 1821cdf0e10cSrcweir SbxVariable* pVar = pProps->Get( i ); 1822cdf0e10cSrcweir 1823cdf0e10cSrcweir String aName( pVar->GetName() ); 1824cdf0e10cSrcweir pItem->maMemberList.mpMemberNames[i] = aName; 1825cdf0e10cSrcweir SvLBoxEntry* pChildEntry = SvTreeListBox::InsertEntry( aName, pEntry ); 1826cdf0e10cSrcweir WatchItem* pChildItem = new WatchItem(); 1827cdf0e10cSrcweir pChildItem->maName = aName; 1828cdf0e10cSrcweir pChildEntry->SetUserData( pChildItem ); 1829cdf0e10cSrcweir } 1830cdf0e10cSrcweir if( nPropCount > 0 ) 1831cdf0e10cSrcweir { 1832cdf0e10cSrcweir UpdateWatches(); 1833cdf0e10cSrcweir } 1834cdf0e10cSrcweir } 1835cdf0e10cSrcweir else if( pArray ) 1836cdf0e10cSrcweir { 1837cdf0e10cSrcweir sal_uInt16 nElementCount = 0; 1838cdf0e10cSrcweir 1839cdf0e10cSrcweir // Loop through indices of current level 1840cdf0e10cSrcweir int nParentLevel = bArrayIsRootArray ? pItem->nDimLevel : 0; 1841cdf0e10cSrcweir int nThisLevel = nParentLevel + 1; 1842cdf0e10cSrcweir sal_Int32 nMin, nMax; 1843cdf0e10cSrcweir pArray->GetDim32( nThisLevel, nMin, nMax ); 1844cdf0e10cSrcweir for( sal_Int32 i = nMin ; i <= nMax ; i++ ) 1845cdf0e10cSrcweir { 1846cdf0e10cSrcweir WatchItem* pChildItem = new WatchItem(); 1847cdf0e10cSrcweir 1848cdf0e10cSrcweir // Copy data and create name 1849cdf0e10cSrcweir String aBaseName( pItem->maName ); 1850cdf0e10cSrcweir pChildItem->maName = aBaseName; 1851cdf0e10cSrcweir 1852cdf0e10cSrcweir String aIndexStr = String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ); 1853cdf0e10cSrcweir // pChildItem->mpArray = pItem->mpArray; 1854cdf0e10cSrcweir pChildItem->mpArrayParentItem = pItem; 1855cdf0e10cSrcweir pChildItem->nDimLevel = nThisLevel; 1856cdf0e10cSrcweir pChildItem->nDimCount = pItem->nDimCount; 1857cdf0e10cSrcweir pChildItem->pIndices = new short[ pChildItem->nDimCount ]; 1858cdf0e10cSrcweir sal_uInt16 j; 1859cdf0e10cSrcweir for( j = 0 ; j < nParentLevel ; j++ ) 1860cdf0e10cSrcweir { 1861cdf0e10cSrcweir short n = pChildItem->pIndices[j] = pItem->pIndices[j]; 1862cdf0e10cSrcweir aIndexStr += String::CreateFromInt32( n ); 1863cdf0e10cSrcweir aIndexStr += String( RTL_CONSTASCII_USTRINGPARAM( "," ) ); 1864cdf0e10cSrcweir } 1865cdf0e10cSrcweir pChildItem->pIndices[ nParentLevel ] = sal::static_int_cast<short>( i ); 1866cdf0e10cSrcweir aIndexStr += String::CreateFromInt32( i ); 1867cdf0e10cSrcweir aIndexStr += String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ); 1868cdf0e10cSrcweir 1869cdf0e10cSrcweir String aDisplayName; 1870cdf0e10cSrcweir WatchItem* pArrayRootItem = pChildItem->GetRootItem(); 1871cdf0e10cSrcweir if( pArrayRootItem && pArrayRootItem->mpArrayParentItem ) 1872cdf0e10cSrcweir aDisplayName = pItem->maDisplayName; 1873cdf0e10cSrcweir else 1874cdf0e10cSrcweir aDisplayName = aBaseName; 1875cdf0e10cSrcweir aDisplayName += aIndexStr; 1876cdf0e10cSrcweir pChildItem->maDisplayName = aDisplayName; 1877cdf0e10cSrcweir 1878cdf0e10cSrcweir SvLBoxEntry* pChildEntry = SvTreeListBox::InsertEntry( aDisplayName, pEntry ); 1879cdf0e10cSrcweir nElementCount++; 1880cdf0e10cSrcweir pChildEntry->SetUserData( pChildItem ); 1881cdf0e10cSrcweir } 1882cdf0e10cSrcweir if( nElementCount > 0 ) 1883cdf0e10cSrcweir { 1884cdf0e10cSrcweir UpdateWatches(); 1885cdf0e10cSrcweir } 1886cdf0e10cSrcweir } 1887cdf0e10cSrcweir } 1888cdf0e10cSrcweir 1889cdf0e10cSrcweir SbxBase* WatchTreeListBox::ImplGetSBXForEntry( SvLBoxEntry* pEntry, bool& rbArrayElement ) 1890cdf0e10cSrcweir { 1891cdf0e10cSrcweir SbxBase* pSBX = NULL; 1892cdf0e10cSrcweir rbArrayElement = false; 1893cdf0e10cSrcweir 1894cdf0e10cSrcweir WatchItem* pItem = (WatchItem*)pEntry->GetUserData(); 1895cdf0e10cSrcweir String aVName( pItem->maName ); 1896cdf0e10cSrcweir 1897cdf0e10cSrcweir SvLBoxEntry* pParentEntry = GetParent( pEntry ); 1898cdf0e10cSrcweir WatchItem* pParentItem = pParentEntry ? (WatchItem*)pParentEntry->GetUserData() : NULL; 1899cdf0e10cSrcweir if( pParentItem ) 1900cdf0e10cSrcweir { 1901cdf0e10cSrcweir SbxObject* pObj = pParentItem->mpObject; 1902cdf0e10cSrcweir SbxDimArray* pArray; 1903cdf0e10cSrcweir if( pObj ) 1904cdf0e10cSrcweir { 1905cdf0e10cSrcweir pSBX = pObj->Find( aVName, SbxCLASS_DONTCARE ); 1906cdf0e10cSrcweir 1907cdf0e10cSrcweir SbxVariable* pVar; 1908cdf0e10cSrcweir if ( pSBX && (pVar = PTR_CAST( SbxVariable, pSBX )) != NULL 1909cdf0e10cSrcweir && !pSBX->ISA( SbxMethod ) ) 1910cdf0e10cSrcweir { 1911cdf0e10cSrcweir // Force getting value 1912cdf0e10cSrcweir SbxValues aRes; 1913cdf0e10cSrcweir aRes.eType = SbxVOID; 1914cdf0e10cSrcweir pVar->Get( aRes ); 1915cdf0e10cSrcweir } 1916cdf0e10cSrcweir } 1917cdf0e10cSrcweir // Array? 1918cdf0e10cSrcweir else if( (pArray = pItem->GetRootArray()) != NULL ) 1919cdf0e10cSrcweir // else if( (pArray = pItem->mpArray) != NULL ) 1920cdf0e10cSrcweir { 1921cdf0e10cSrcweir rbArrayElement = true; 1922cdf0e10cSrcweir if( pParentItem->nDimLevel + 1 == pParentItem->nDimCount ) 1923cdf0e10cSrcweir // if( pItem->nDimLevel == pItem->nDimCount ) 1924cdf0e10cSrcweir pSBX = pArray->Get( pItem->pIndices ); 1925cdf0e10cSrcweir // else 1926cdf0e10cSrcweir // pSBX = pArray; 1927cdf0e10cSrcweir } 1928cdf0e10cSrcweir } 1929cdf0e10cSrcweir else 1930cdf0e10cSrcweir { 1931cdf0e10cSrcweir pSBX = StarBASIC::FindSBXInCurrentScope( aVName ); 1932cdf0e10cSrcweir } 1933cdf0e10cSrcweir return pSBX; 1934cdf0e10cSrcweir } 1935cdf0e10cSrcweir 1936cdf0e10cSrcweir sal_Bool __EXPORT WatchTreeListBox::EditingEntry( SvLBoxEntry* pEntry, Selection& ) 1937cdf0e10cSrcweir { 1938cdf0e10cSrcweir WatchItem* pItem = (WatchItem*)pEntry->GetUserData(); 1939cdf0e10cSrcweir 1940cdf0e10cSrcweir sal_Bool bEdit = sal_False; 1941cdf0e10cSrcweir if ( StarBASIC::IsRunning() && StarBASIC::GetActiveMethod() && !SbxBase::IsError() ) 1942cdf0e10cSrcweir { 1943cdf0e10cSrcweir // No out of scope entries 1944cdf0e10cSrcweir bool bArrayElement; 1945cdf0e10cSrcweir SbxBase* pSBX = ImplGetSBXForEntry( pEntry, bArrayElement ); 1946cdf0e10cSrcweir if ( ( pSBX && pSBX->ISA( SbxVariable ) && !pSBX->ISA( SbxMethod ) ) || bArrayElement ) 1947cdf0e10cSrcweir { 1948cdf0e10cSrcweir // Accept no objects and only end nodes of arrays for editing 1949cdf0e10cSrcweir if( !pItem->mpObject && (pItem->mpArray == NULL || pItem->nDimLevel == pItem->nDimCount) ) 1950cdf0e10cSrcweir { 1951cdf0e10cSrcweir aEditingRes = SvHeaderTabListBox::GetEntryText( pEntry, ITEM_ID_VALUE-1 ); 1952cdf0e10cSrcweir aEditingRes.EraseLeadingChars(); 1953cdf0e10cSrcweir aEditingRes.EraseTrailingChars(); 1954cdf0e10cSrcweir bEdit = sal_True; 1955cdf0e10cSrcweir } 1956cdf0e10cSrcweir } 1957cdf0e10cSrcweir } 1958cdf0e10cSrcweir 1959cdf0e10cSrcweir if ( !bEdit ) 1960cdf0e10cSrcweir Sound::Beep(); 1961cdf0e10cSrcweir 1962cdf0e10cSrcweir return bEdit; 1963cdf0e10cSrcweir } 1964cdf0e10cSrcweir 1965cdf0e10cSrcweir sal_Bool __EXPORT WatchTreeListBox::EditedEntry( SvLBoxEntry* pEntry, const String& rNewText ) 1966cdf0e10cSrcweir { 1967cdf0e10cSrcweir WatchItem* pItem = (WatchItem*)pEntry->GetUserData(); 1968cdf0e10cSrcweir String aVName( pItem->maName ); 1969cdf0e10cSrcweir 1970cdf0e10cSrcweir String aResult = rNewText; 1971cdf0e10cSrcweir aResult.EraseLeadingChars(); 1972cdf0e10cSrcweir aResult.EraseTrailingChars(); 1973cdf0e10cSrcweir 1974cdf0e10cSrcweir sal_uInt16 nResultLen = aResult.Len(); 1975cdf0e10cSrcweir sal_Unicode cFirst = aResult.GetChar( 0 ); 1976cdf0e10cSrcweir sal_Unicode cLast = aResult.GetChar( nResultLen - 1 ); 1977cdf0e10cSrcweir if( cFirst == '\"' && cLast == '\"' ) 1978cdf0e10cSrcweir aResult = aResult.Copy( 1, nResultLen - 2 ); 1979cdf0e10cSrcweir 1980cdf0e10cSrcweir sal_Bool bResModified = ( aResult != aEditingRes ) ? sal_True : sal_False; 1981cdf0e10cSrcweir sal_Bool bError = sal_False; 1982cdf0e10cSrcweir if ( !aVName.Len() ) 1983cdf0e10cSrcweir { 1984cdf0e10cSrcweir bError = sal_True; 1985cdf0e10cSrcweir } 1986cdf0e10cSrcweir 1987cdf0e10cSrcweir sal_Bool bRet = sal_False; 1988cdf0e10cSrcweir 1989cdf0e10cSrcweir if ( bError ) 1990cdf0e10cSrcweir { 1991cdf0e10cSrcweir Sound::Beep(); 1992cdf0e10cSrcweir } 1993cdf0e10cSrcweir else if ( bResModified ) 1994cdf0e10cSrcweir { 1995cdf0e10cSrcweir bRet = ImplBasicEntryEdited( pEntry, aResult ); 1996cdf0e10cSrcweir } 1997cdf0e10cSrcweir 1998cdf0e10cSrcweir return bRet; 1999cdf0e10cSrcweir } 2000cdf0e10cSrcweir 2001cdf0e10cSrcweir sal_Bool WatchTreeListBox::ImplBasicEntryEdited( SvLBoxEntry* pEntry, const String& rResult ) 2002cdf0e10cSrcweir { 2003cdf0e10cSrcweir WatchItem* pItem = (WatchItem*)pEntry->GetUserData(); 2004cdf0e10cSrcweir String aVName( pItem->maName ); 2005cdf0e10cSrcweir 2006cdf0e10cSrcweir sal_Bool bError = sal_False; 2007cdf0e10cSrcweir String aResult( rResult ); 2008cdf0e10cSrcweir String aIndex; 2009cdf0e10cSrcweir bool bArrayElement; 2010cdf0e10cSrcweir SbxBase* pSBX = ImplGetSBXForEntry( pEntry, bArrayElement ); 2011cdf0e10cSrcweir 2012cdf0e10cSrcweir SbxBase* pToBeChanged = NULL; 2013cdf0e10cSrcweir if ( pSBX && pSBX->ISA( SbxVariable ) && !pSBX->ISA( SbxMethod ) ) 2014cdf0e10cSrcweir { 2015cdf0e10cSrcweir SbxVariable* pVar = (SbxVariable*)pSBX; 2016cdf0e10cSrcweir SbxDataType eType = pVar->GetType(); 2017cdf0e10cSrcweir if ( (sal_uInt8)eType == (sal_uInt8)SbxOBJECT ) 2018cdf0e10cSrcweir bError = sal_True; 2019cdf0e10cSrcweir else if ( eType & SbxARRAY ) 2020cdf0e10cSrcweir bError = sal_True; 2021cdf0e10cSrcweir else 2022cdf0e10cSrcweir pToBeChanged = pSBX; 2023cdf0e10cSrcweir } 2024cdf0e10cSrcweir 2025cdf0e10cSrcweir if ( pToBeChanged ) 2026cdf0e10cSrcweir { 2027cdf0e10cSrcweir if ( pToBeChanged->ISA( SbxVariable ) ) 2028cdf0e10cSrcweir { 2029cdf0e10cSrcweir // Wenn der Typ variabel ist, macht die Konvertierung des SBX nichts, 2030cdf0e10cSrcweir // bei festem Typ wird der String konvertiert. 2031cdf0e10cSrcweir ((SbxVariable*)pToBeChanged)->PutStringExt( aResult ); 2032cdf0e10cSrcweir } 2033cdf0e10cSrcweir else 2034cdf0e10cSrcweir bError = sal_True; 2035cdf0e10cSrcweir } 2036cdf0e10cSrcweir 2037cdf0e10cSrcweir // Wenn jemand z.B. einen zu grossen Wert fuer ein Int eingegeben hat, 2038cdf0e10cSrcweir // folgt beim naechsten Step() ein Runtime-Error. 2039cdf0e10cSrcweir if ( SbxBase::IsError() ) 2040cdf0e10cSrcweir { 2041cdf0e10cSrcweir bError = sal_True; 2042cdf0e10cSrcweir SbxBase::ResetError(); 2043cdf0e10cSrcweir } 2044cdf0e10cSrcweir 2045cdf0e10cSrcweir if ( bError ) 2046cdf0e10cSrcweir Sound::Beep(); 2047cdf0e10cSrcweir 2048cdf0e10cSrcweir UpdateWatches(); 2049cdf0e10cSrcweir 2050cdf0e10cSrcweir // Der Text soll niemals 1-zu-1 uebernommen werden, weil dann das 2051cdf0e10cSrcweir // UpdateWatches verlorengeht. 2052cdf0e10cSrcweir return sal_False; 2053cdf0e10cSrcweir } 2054cdf0e10cSrcweir 2055cdf0e10cSrcweir 2056cdf0e10cSrcweir static void implCollapseModifiedObjectEntry( SvLBoxEntry* pParent, WatchTreeListBox* pThis ) 2057cdf0e10cSrcweir { 2058cdf0e10cSrcweir pThis->Collapse( pParent ); 2059cdf0e10cSrcweir 2060cdf0e10cSrcweir SvLBoxTreeList* pModel = pThis->GetModel(); 2061cdf0e10cSrcweir SvLBoxEntry* pDeleteEntry; 2062cdf0e10cSrcweir while( (pDeleteEntry = pThis->SvTreeListBox::GetEntry( pParent, 0 )) != NULL ) 2063cdf0e10cSrcweir { 2064cdf0e10cSrcweir implCollapseModifiedObjectEntry( pDeleteEntry, pThis ); 2065cdf0e10cSrcweir 2066cdf0e10cSrcweir WatchItem* pItem = (WatchItem*)pDeleteEntry->GetUserData(); 2067cdf0e10cSrcweir delete pItem; 2068cdf0e10cSrcweir pModel->Remove( pDeleteEntry ); 2069cdf0e10cSrcweir } 2070cdf0e10cSrcweir } 2071cdf0e10cSrcweir 2072cdf0e10cSrcweir static String implCreateTypeStringForDimArray( WatchItem* pItem, SbxDataType eType ) 2073cdf0e10cSrcweir { 2074cdf0e10cSrcweir String aRetStr = getBasicTypeName( eType ); 2075cdf0e10cSrcweir 2076cdf0e10cSrcweir SbxDimArray* pArray = pItem->mpArray; 2077cdf0e10cSrcweir if( !pArray ) 2078cdf0e10cSrcweir pArray = pItem->GetRootArray(); 2079cdf0e10cSrcweir if( pArray ) 2080cdf0e10cSrcweir { 2081cdf0e10cSrcweir int nDimLevel = pItem->nDimLevel; 2082cdf0e10cSrcweir int nDims = pItem->nDimCount; 2083cdf0e10cSrcweir if( nDimLevel < nDims ) 2084cdf0e10cSrcweir { 2085cdf0e10cSrcweir aRetStr += '('; 2086cdf0e10cSrcweir for( int i = nDimLevel ; i < nDims ; i++ ) 2087cdf0e10cSrcweir { 2088cdf0e10cSrcweir short nMin, nMax; 2089cdf0e10cSrcweir pArray->GetDim( sal::static_int_cast<short>( i+1 ), nMin, nMax ); 2090cdf0e10cSrcweir aRetStr += String::CreateFromInt32( nMin ); 2091cdf0e10cSrcweir aRetStr += String( RTL_CONSTASCII_USTRINGPARAM( " to " ) ); 2092cdf0e10cSrcweir aRetStr += String::CreateFromInt32( nMax ); 2093cdf0e10cSrcweir if( i < nDims - 1 ) 2094cdf0e10cSrcweir aRetStr += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) ); 2095cdf0e10cSrcweir } 2096cdf0e10cSrcweir aRetStr += ')'; 2097cdf0e10cSrcweir } 2098cdf0e10cSrcweir } 2099cdf0e10cSrcweir return aRetStr; 2100cdf0e10cSrcweir } 2101cdf0e10cSrcweir 2102cdf0e10cSrcweir 2103cdf0e10cSrcweir void implEnableChildren( SvLBoxEntry* pEntry, bool bEnable ) 2104cdf0e10cSrcweir // inline void implEnableChildren( SvLBoxEntry* pEntry, bool bEnable ) 2105cdf0e10cSrcweir { 2106cdf0e10cSrcweir if( bEnable ) 2107cdf0e10cSrcweir { 2108cdf0e10cSrcweir pEntry->SetFlags( 2109cdf0e10cSrcweir (pEntry->GetFlags() & 2110cdf0e10cSrcweir ~(SV_ENTRYFLAG_NO_NODEBMP | SV_ENTRYFLAG_HAD_CHILDREN)) 2111cdf0e10cSrcweir | SV_ENTRYFLAG_CHILDS_ON_DEMAND ); 2112cdf0e10cSrcweir } 2113cdf0e10cSrcweir else 2114cdf0e10cSrcweir { 2115cdf0e10cSrcweir pEntry->SetFlags( 2116cdf0e10cSrcweir (pEntry->GetFlags() & ~(SV_ENTRYFLAG_CHILDS_ON_DEMAND)) ); 2117cdf0e10cSrcweir } 2118cdf0e10cSrcweir } 2119cdf0e10cSrcweir 2120cdf0e10cSrcweir void WatchTreeListBox::UpdateWatches( bool bBasicStopped ) 2121cdf0e10cSrcweir { 2122cdf0e10cSrcweir SbMethod* pCurMethod = StarBASIC::GetActiveMethod(); 2123cdf0e10cSrcweir 2124cdf0e10cSrcweir SbxError eOld = SbxBase::GetError(); 2125cdf0e10cSrcweir setBasicWatchMode( true ); 2126cdf0e10cSrcweir 2127cdf0e10cSrcweir SvLBoxEntry* pEntry = First(); 2128cdf0e10cSrcweir while ( pEntry ) 2129cdf0e10cSrcweir { 2130cdf0e10cSrcweir WatchItem* pItem = (WatchItem*)pEntry->GetUserData(); 2131cdf0e10cSrcweir String aVName( pItem->maName ); 2132cdf0e10cSrcweir DBG_ASSERT( aVName.Len(), "Var? - Darf nicht leer sein!" ); 2133cdf0e10cSrcweir String aWatchStr; 2134cdf0e10cSrcweir String aTypeStr; 2135cdf0e10cSrcweir if ( pCurMethod ) 2136cdf0e10cSrcweir { 2137cdf0e10cSrcweir bool bArrayElement; 2138cdf0e10cSrcweir SbxBase* pSBX = ImplGetSBXForEntry( pEntry, bArrayElement ); 2139cdf0e10cSrcweir 2140cdf0e10cSrcweir // Array? If no end node create type string 2141cdf0e10cSrcweir if( bArrayElement && pItem->nDimLevel < pItem->nDimCount ) 2142cdf0e10cSrcweir { 2143cdf0e10cSrcweir SbxDimArray* pRootArray = pItem->GetRootArray(); 2144cdf0e10cSrcweir SbxDataType eType = pRootArray->GetType(); 2145cdf0e10cSrcweir // SbxDataType eType = pItem->mpArray->GetType(); 2146cdf0e10cSrcweir aTypeStr = implCreateTypeStringForDimArray( pItem, eType ); 2147cdf0e10cSrcweir implEnableChildren( pEntry, true ); 2148cdf0e10cSrcweir } 2149cdf0e10cSrcweir 2150cdf0e10cSrcweir bool bCollapse = false; 2151cdf0e10cSrcweir if ( pSBX && pSBX->ISA( SbxVariable ) && !pSBX->ISA( SbxMethod ) ) 2152cdf0e10cSrcweir { 2153cdf0e10cSrcweir SbxVariable* pVar = (SbxVariable*)pSBX; 2154cdf0e10cSrcweir // Sonderbehandlung fuer Arrays: 2155cdf0e10cSrcweir SbxDataType eType = pVar->GetType(); 2156cdf0e10cSrcweir if ( eType & SbxARRAY ) 2157cdf0e10cSrcweir { 2158cdf0e10cSrcweir // Mehrdimensionale Arrays beruecksichtigen! 2159cdf0e10cSrcweir SbxBase* pBase = pVar->GetObject(); 2160cdf0e10cSrcweir if ( pBase && pBase->ISA( SbxDimArray ) ) 2161cdf0e10cSrcweir { 2162cdf0e10cSrcweir SbxDimArray* pNewArray = (SbxDimArray*)pBase; 2163cdf0e10cSrcweir SbxDimArray* pOldArray = pItem->mpArray; 2164cdf0e10cSrcweir 2165cdf0e10cSrcweir bool bArrayChanged = false; 2166cdf0e10cSrcweir if( pNewArray != NULL && pOldArray != NULL ) 2167cdf0e10cSrcweir { 2168cdf0e10cSrcweir // Compare Array dimensions to see if array has changed 2169cdf0e10cSrcweir // Can be a copy, so comparing pointers does not work 2170cdf0e10cSrcweir sal_uInt16 nOldDims = pOldArray->GetDims(); 2171cdf0e10cSrcweir sal_uInt16 nNewDims = pNewArray->GetDims(); 2172cdf0e10cSrcweir if( nOldDims != nNewDims ) 2173cdf0e10cSrcweir { 2174cdf0e10cSrcweir bArrayChanged = true; 2175cdf0e10cSrcweir } 2176cdf0e10cSrcweir else 2177cdf0e10cSrcweir { 2178cdf0e10cSrcweir for( int i = 0 ; i < nOldDims ; i++ ) 2179cdf0e10cSrcweir { 2180cdf0e10cSrcweir short nOldMin, nOldMax; 2181cdf0e10cSrcweir short nNewMin, nNewMax; 2182cdf0e10cSrcweir 2183cdf0e10cSrcweir pOldArray->GetDim( sal::static_int_cast<short>( i+1 ), nOldMin, nOldMax ); 2184cdf0e10cSrcweir pNewArray->GetDim( sal::static_int_cast<short>( i+1 ), nNewMin, nNewMax ); 2185cdf0e10cSrcweir if( nOldMin != nNewMin || nOldMax != nNewMax ) 2186cdf0e10cSrcweir { 2187cdf0e10cSrcweir bArrayChanged = true; 2188cdf0e10cSrcweir break; 2189cdf0e10cSrcweir } 2190cdf0e10cSrcweir } 2191cdf0e10cSrcweir } 2192cdf0e10cSrcweir } 2193cdf0e10cSrcweir else if( pNewArray == NULL || pOldArray == NULL ) 2194cdf0e10cSrcweir bArrayChanged = true; 2195cdf0e10cSrcweir 2196cdf0e10cSrcweir if( pNewArray ) 2197cdf0e10cSrcweir implEnableChildren( pEntry, true ); 2198cdf0e10cSrcweir 2199cdf0e10cSrcweir // #i37227 Clear always and replace array 2200cdf0e10cSrcweir if( pNewArray != pOldArray ) 2201cdf0e10cSrcweir { 2202cdf0e10cSrcweir pItem->clearWatchItem( false ); 2203cdf0e10cSrcweir if( pNewArray ) 2204cdf0e10cSrcweir { 2205cdf0e10cSrcweir implEnableChildren( pEntry, true ); 2206cdf0e10cSrcweir 2207cdf0e10cSrcweir pItem->mpArray = pNewArray; 2208cdf0e10cSrcweir sal_uInt16 nDims = pNewArray->GetDims(); 2209cdf0e10cSrcweir pItem->nDimLevel = 0; 2210cdf0e10cSrcweir pItem->nDimCount = nDims; 2211cdf0e10cSrcweir } 2212cdf0e10cSrcweir } 2213cdf0e10cSrcweir if( bArrayChanged && pOldArray != NULL ) 2214cdf0e10cSrcweir bCollapse = true; 2215cdf0e10cSrcweir 2216cdf0e10cSrcweir aTypeStr = implCreateTypeStringForDimArray( pItem, eType ); 2217cdf0e10cSrcweir } 2218cdf0e10cSrcweir else 2219cdf0e10cSrcweir aWatchStr += String( RTL_CONSTASCII_USTRINGPARAM( "<?>" ) ); 2220cdf0e10cSrcweir } 2221cdf0e10cSrcweir else if ( (sal_uInt8)eType == (sal_uInt8)SbxOBJECT ) 2222cdf0e10cSrcweir { 2223cdf0e10cSrcweir SbxObject* pObj = NULL; 2224cdf0e10cSrcweir SbxBase* pBase = pVar->GetObject(); 2225cdf0e10cSrcweir if( pBase && pBase->ISA( SbxObject ) ) 2226cdf0e10cSrcweir pObj = (SbxObject*)pBase; 2227cdf0e10cSrcweir 2228cdf0e10cSrcweir if( pObj ) 2229cdf0e10cSrcweir { 2230cdf0e10cSrcweir // Check if member list has changed 2231cdf0e10cSrcweir bool bObjChanged = false; 2232cdf0e10cSrcweir if( pItem->mpObject != NULL && pItem->maMemberList.mpMemberNames != NULL ) 2233cdf0e10cSrcweir { 2234cdf0e10cSrcweir SbxArray* pProps = pObj->GetProperties(); 2235cdf0e10cSrcweir sal_uInt16 nPropCount = pProps->Count(); 2236cdf0e10cSrcweir for( sal_uInt16 i = 0 ; i < nPropCount - 3 ; i++ ) 2237cdf0e10cSrcweir { 2238cdf0e10cSrcweir SbxVariable* pVar_ = pProps->Get( i ); 2239cdf0e10cSrcweir String aName( pVar_->GetName() ); 2240cdf0e10cSrcweir if( pItem->maMemberList.mpMemberNames[i] != aName ) 2241cdf0e10cSrcweir { 2242cdf0e10cSrcweir bObjChanged = true; 2243cdf0e10cSrcweir break; 2244cdf0e10cSrcweir } 2245cdf0e10cSrcweir } 2246cdf0e10cSrcweir if( bObjChanged ) 2247cdf0e10cSrcweir bCollapse = true; 2248cdf0e10cSrcweir } 2249cdf0e10cSrcweir 2250cdf0e10cSrcweir pItem->mpObject = pObj; 2251cdf0e10cSrcweir implEnableChildren( pEntry, true ); 2252cdf0e10cSrcweir aTypeStr = getBasicObjectTypeName( pObj ); 2253cdf0e10cSrcweir } 2254cdf0e10cSrcweir else 2255cdf0e10cSrcweir { 2256cdf0e10cSrcweir aWatchStr = String( RTL_CONSTASCII_USTRINGPARAM( "Null" ) ); 2257cdf0e10cSrcweir if( pItem->mpObject != NULL ) 2258cdf0e10cSrcweir { 2259cdf0e10cSrcweir bCollapse = true; 2260cdf0e10cSrcweir pItem->clearWatchItem( false ); 2261cdf0e10cSrcweir 2262cdf0e10cSrcweir implEnableChildren( pEntry, false ); 2263cdf0e10cSrcweir } 2264cdf0e10cSrcweir } 2265cdf0e10cSrcweir } 2266cdf0e10cSrcweir else 2267cdf0e10cSrcweir { 2268cdf0e10cSrcweir if( pItem->mpObject != NULL ) 2269cdf0e10cSrcweir { 2270cdf0e10cSrcweir bCollapse = true; 2271cdf0e10cSrcweir pItem->clearWatchItem( false ); 2272cdf0e10cSrcweir 2273cdf0e10cSrcweir implEnableChildren( pEntry, false ); 2274cdf0e10cSrcweir } 2275cdf0e10cSrcweir 2276cdf0e10cSrcweir bool bString = ((sal_uInt8)eType == (sal_uInt8)SbxSTRING); 2277cdf0e10cSrcweir String aStrStr( RTL_CONSTASCII_USTRINGPARAM( "\"" ) ); 2278cdf0e10cSrcweir if( bString ) 2279cdf0e10cSrcweir aWatchStr += aStrStr; 2280cdf0e10cSrcweir aWatchStr += pVar->GetString(); 2281cdf0e10cSrcweir if( bString ) 2282cdf0e10cSrcweir aWatchStr += aStrStr; 2283cdf0e10cSrcweir } 2284cdf0e10cSrcweir if( !aTypeStr.Len() ) 2285cdf0e10cSrcweir { 2286cdf0e10cSrcweir if( !pVar->IsFixed() ) 2287cdf0e10cSrcweir aTypeStr = String( RTL_CONSTASCII_USTRINGPARAM( "Variant/" ) ); 2288cdf0e10cSrcweir aTypeStr += getBasicTypeName( pVar->GetType() ); 2289cdf0e10cSrcweir } 2290cdf0e10cSrcweir } 2291cdf0e10cSrcweir else if( !bArrayElement ) 2292cdf0e10cSrcweir aWatchStr += String( RTL_CONSTASCII_USTRINGPARAM( "<Out of Scope>" ) ); 2293cdf0e10cSrcweir 2294cdf0e10cSrcweir if( bCollapse ) 2295cdf0e10cSrcweir implCollapseModifiedObjectEntry( pEntry, this ); 2296cdf0e10cSrcweir 2297cdf0e10cSrcweir } 2298cdf0e10cSrcweir else if( bBasicStopped ) 2299cdf0e10cSrcweir { 2300cdf0e10cSrcweir if( pItem->mpObject || pItem->mpArray ) 2301cdf0e10cSrcweir { 2302cdf0e10cSrcweir implCollapseModifiedObjectEntry( pEntry, this ); 2303cdf0e10cSrcweir pItem->mpObject = NULL; 2304cdf0e10cSrcweir } 2305cdf0e10cSrcweir } 2306cdf0e10cSrcweir 2307cdf0e10cSrcweir SvHeaderTabListBox::SetEntryText( aWatchStr, pEntry, ITEM_ID_VALUE-1 ); 2308cdf0e10cSrcweir SvHeaderTabListBox::SetEntryText( aTypeStr, pEntry, ITEM_ID_TYPE-1 ); 2309cdf0e10cSrcweir 2310cdf0e10cSrcweir pEntry = Next( pEntry ); 2311cdf0e10cSrcweir } 2312cdf0e10cSrcweir 2313cdf0e10cSrcweir // Force redraw 2314cdf0e10cSrcweir Invalidate(); 2315cdf0e10cSrcweir 2316cdf0e10cSrcweir SbxBase::ResetError(); 2317cdf0e10cSrcweir if( eOld != SbxERR_OK ) 2318cdf0e10cSrcweir SbxBase::SetError( eOld ); 2319cdf0e10cSrcweir setBasicWatchMode( false ); 2320cdf0e10cSrcweir } 2321cdf0e10cSrcweir 2322