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