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