1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_automation.hxx"
24 #include <com/sun/star/frame/XFramesSupplier.hpp>
25 #include <com/sun/star/frame/XDispatch.hpp>
26 #include <com/sun/star/frame/XDispatchProvider.hpp>
27 #include <com/sun/star/util/XURLTransformer.hpp>
28 #include <comphelper/processfactory.hxx>
29 #include <comphelper/uieventslogger.hxx>
30
31 #include <tools/wintypes.hxx>
32 #include <vcl/dialog.hxx>
33 #include <vcl/button.hxx>
34 #include <vcl/menubtn.hxx>
35 #include <svtools/svtreebx.hxx>
36 #include <svtools/brwbox.hxx>
37 #include <vcl/msgbox.hxx>
38 #include <vcl/dockwin.hxx>
39 #include <vcl/floatwin.hxx>
40 #include <vcl/lstbox.hxx>
41 #include <vcl/combobox.hxx>
42 #include <vcl/morebtn.hxx>
43 #include <vcl/field.hxx>
44 #include <vcl/toolbox.hxx>
45 #include <vcl/tabctrl.hxx>
46 #include <vcl/tabpage.hxx>
47 #include <vcl/menu.hxx>
48 #include <vcl/status.hxx>
49 #include <svtools/prgsbar.hxx>
50 #include <svtools/editbrowsebox.hxx>
51 #include <vcl/splitwin.hxx>
52 #include <vcl/group.hxx>
53 #include <vcl/fixed.hxx>
54 #include <vcl/wrkwin.hxx>
55 #include <osl/diagnose.h>
56 #include <svtools/valueset.hxx>
57 #include <svtools/roadmap.hxx>
58 #include <svtools/table/tablecontrol.hxx>
59 #include <svtools/table/tablecontrolinterface.hxx>
60 #include <svl/poolitem.hxx>
61 #include <svtools/extensionlistbox.hxx>
62 #include <svtools/svtdata.hxx>
63 #include <tools/time.hxx>
64 #include <svtools/stringtransfer.hxx>
65 #include <tools/stream.hxx>
66 #include <tools/fsys.hxx>
67 #include <svl/stritem.hxx>
68 #include <svtools/ttprops.hxx>
69 #include <basic/ttstrhlp.hxx>
70 #include <basic/dispdefs.hxx>
71 #include <basic/sbuno.hxx>
72 #include <vos/socket.hxx>
73 #include <svl/pickerhistory.hxx>
74 #include <com/sun/star/util/XCancellable.hpp>
75 #include <sot/storage.hxx>
76 #include <sot/storinfo.hxx>
77 #include "statemnt.hxx"
78 #include "scmdstrm.hxx"
79 #include "retstrm.hxx"
80 #if OSL_DEBUG_LEVEL > 1
81 #include "editwin.hxx"
82 #endif
83 #include "rcontrol.hxx"
84 #include <automation/communi.hxx>
85 #include "testtool.hxx"
86 #include "profiler.hxx"
87 #include "recorder.hxx"
88 #include "testtool.hrc"
89 #include <basic/svtmsg.hrc>
90 #include <algorithm>
91 #include <vcl/dibtools.hxx>
92
93 using namespace com::sun::star::frame;
94 using namespace com::sun::star::uno;
95 //using namespace com::sun::star::util; can't be done because of Color
96 using namespace com::sun::star::beans;
97 using namespace svt;
98 //using namespace svt::table;
99
100 #ifndef SBX_VALUE_DECL_DEFINED
101 #define SBX_VALUE_DECL_DEFINED
102 SV_DECL_REF(SbxValue)
103 #endif
104 SV_IMPL_REF(SbxValue)
105
106 CommunicationLink *StatementFlow::pCommLink = NULL;
107 sal_Bool StatementFlow::bUseIPC = sal_True;
108 sal_Bool StatementFlow::bSending = sal_False;
109 ImplRemoteControl *StatementFlow::pRemoteControl = NULL;
110
111 sal_uInt16 StatementCommand::nDirPos = 0;
112 Dir *StatementCommand::pDir = NULL;
113 pfunc_osl_printDebugMessage StatementCommand::pOriginal_osl_DebugMessageFunc = NULL;
114
115 #define RESET_APPLICATION_TO_BACKING_WINDOW
116
117 #define SET_WINP_CLOSING(pWin) \
118 pWindowWaitPointer = pWin; \
119 aWindowWaitUId = pControl->GetUniqueOrHelpId(); \
120 aWindowWaitOldHelpId = pWin->GetHelpId(); \
121 aWindowWaitOldUniqueId = pWin->GetUniqueId(); \
122 pWin->SetHelpId( rtl::OString("TT_Win_is_closing_HID") ); \
123 pWin->SetUniqueId( rtl::OString("TT_Win_is_closing_UID") );
124
125 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
126
StatementFlow(StatementList * pAfterThis,sal_uInt16 nArtP)127 StatementFlow::StatementFlow( StatementList *pAfterThis, sal_uInt16 nArtP )
128 : nArt(nArtP)
129 , nParams(0)
130 , nSNr1(0)
131 , nLNr1(0)
132 , aString1()
133 , bBool1(sal_False)
134 {
135 QueStatement( pAfterThis );
136 }
137
StatementFlow(sal_uLong nServiceId,SCmdStream * pCmdIn,ImplRemoteControl * pRC)138 StatementFlow::StatementFlow( sal_uLong nServiceId, SCmdStream *pCmdIn, ImplRemoteControl *pRC )
139 : nArt(0)
140 , nParams(0)
141 , nSNr1(0)
142 , nLNr1(0)
143 , aString1()
144 , bBool1(sal_False)
145 {
146 QueStatement( NULL );
147 bUseIPC = (nServiceId == SI_IPCCommandBlock);
148 pRemoteControl = pRC;
149 pCmdIn->Read( nArt );
150 pCmdIn->Read( nParams );
151
152 if( nParams & PARAM_USHORT_1 ) pCmdIn->Read( nSNr1 );
153 if( nParams & PARAM_ULONG_1 ) pCmdIn->Read( nLNr1 );
154 if( nParams & PARAM_STR_1 ) pCmdIn->Read( aString1 );
155 if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 ); // should never occur!!
156
157 #if OSL_DEBUG_LEVEL > 1
158 m_pDbgWin->AddText( "Reading FlowControl: " );
159 m_pDbgWin->AddText( String::CreateFromInt32( nArt ) );
160 m_pDbgWin->AddText( " Params:" );
161 if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nSNr1 ) );}
162 if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " l1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
163 if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
164 if( nParams & PARAM_BOOL_1 ) {m_pDbgWin->AddText( " b2:" );m_pDbgWin->AddText( bBool1 ? "TRUE" : "FALSE" );}
165 m_pDbgWin->AddText( "\n" );
166 #endif
167 }
168
SendViaSocket()169 void StatementFlow::SendViaSocket()
170 {
171 if ( bSending )
172 {
173 #if OSL_DEBUG_LEVEL > 1
174 m_pDbgWin->AddText( "SendViaSocket called recursively. Aborted!!!\n" );
175 #endif
176 DBG_ERROR("SendViaSocket called recursively. Aborted!!!");
177 return;
178 }
179 bSending = sal_True;
180 if ( pCommLink )
181 {
182 if ( !pCommLink->TransferDataStream( pRet->GetStream() ) ) // If an error occurs, it is deleted immediately. ...
183 pCommLink = NULL;
184 }
185 else
186 {
187 // It doesn't matter if there is no basic core for the testtool.
188 DBG_ERROR("Cannot send results to TestTool");
189 }
190
191 pRet->Reset();
192 bSending = sal_False;
193 IsError = sal_False;
194 }
195
Execute()196 sal_Bool StatementFlow::Execute()
197 {
198 #if OSL_DEBUG_LEVEL > 1
199 m_pDbgWin->AddText( "Executing Flow: " );
200 m_pDbgWin->AddText( String::CreateFromInt32( nArt ) );
201 m_pDbgWin->AddText( "\n" );
202 #endif
203 switch ( nArt )
204 {
205 case F_EndCommandBlock:
206 {
207
208 if ( !bUseIPC )
209 {
210 // bBool1 was initialized to sal_False in CTOR
211 if ( !bBool1 ) // so first run
212 {
213 pRemoteControl->pRetStream = pRet->GetStream();
214 bBool1 = sal_True; // was initialized to sal_False in CTOR
215 nRetryCount = nRetryCount * 4;
216 }
217 if ( pRemoteControl->pRetStream && (nRetryCount--) ) // unless you picked up it.
218 {
219 return sal_False; // Please get off the call stack once.
220 }
221 }
222
223 }
224 break;
225 }
226
227 Advance();
228 switch ( nArt )
229 {
230 case F_EndCommandBlock:
231 if ( !bUseIPC )
232 { // is discussed above
233 pRet->Reset();
234 IsError = sal_False;
235 }
236 else
237 SendViaSocket();
238
239 break;
240
241 case F_Sequence:
242
243 pRet->GenReturn(RET_Sequence,nLNr1);
244 #if OSL_DEBUG_LEVEL > 1
245 m_pDbgWin->AddText( "Sending Sequence Nr: " );
246 m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );
247 m_pDbgWin->AddText( "\n" );
248 #endif
249
250 break;
251 // case RET_:
252 default:
253 DBG_ERROR( "Unknown Flowcontrol" );
254 break;
255 }
256
257 delete this;
258 return sal_True;
259 }
260
261 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
262
263 // new auxiliary function, which must be constantly extended
ImpGetRType(Window * pWin)264 static short ImpGetRType( Window *pWin )
265 {
266 short nRT = C_NoType;
267 WindowType eRT = pWin->GetType();
268 switch( eRT ) {
269 case WINDOW_WINDOW: nRT = C_Window ; break;
270
271 case WINDOW_TABCONTROL: nRT = C_TabControl ; break;
272 case WINDOW_RADIOBUTTON: nRT = C_RadioButton ; break;
273 case WINDOW_CHECKBOX: nRT = C_CheckBox ; break;
274 case WINDOW_TRISTATEBOX: nRT = C_TriStateBox ; break;
275 case WINDOW_EDIT: nRT = C_Edit ; break;
276 case WINDOW_MULTILINEEDIT: nRT = C_MultiLineEdit ; break;
277 case WINDOW_MULTILISTBOX: nRT = C_MultiListBox ; break;
278 case WINDOW_LISTBOX: nRT = C_ListBox ; break;
279 case WINDOW_COMBOBOX: nRT = C_ComboBox ; break;
280 case WINDOW_PUSHBUTTON: nRT = C_PushButton ; break;
281 case WINDOW_SPINFIELD: nRT = C_SpinField ; break;
282 case WINDOW_PATTERNFIELD: nRT = C_PatternField ; break;
283 case WINDOW_NUMERICFIELD: nRT = C_NumericField ; break;
284 case WINDOW_METRICFIELD: nRT = C_MetricField ; break;
285 case WINDOW_CURRENCYFIELD: nRT = C_CurrencyField ; break;
286 case WINDOW_DATEFIELD: nRT = C_DateField ; break;
287 case WINDOW_TIMEFIELD: nRT = C_TimeField ; break;
288 case WINDOW_IMAGERADIOBUTTON: nRT = C_ImageRadioButton ; break;
289 case WINDOW_NUMERICBOX: nRT = C_NumericBox ; break;
290 case WINDOW_METRICBOX: nRT = C_MetricBox ; break;
291 case WINDOW_CURRENCYBOX: nRT = C_CurrencyBox ; break;
292 case WINDOW_DATEBOX: nRT = C_DateBox ; break;
293 case WINDOW_TIMEBOX: nRT = C_TimeBox ; break;
294 case WINDOW_IMAGEBUTTON: nRT = C_ImageButton ; break;
295 case WINDOW_MENUBUTTON: nRT = C_MenuButton ; break;
296 case WINDOW_MOREBUTTON: nRT = C_MoreButton ; break;
297
298
299 case WINDOW_TABPAGE: nRT = C_TabPage; break;
300 case WINDOW_MODALDIALOG: nRT = C_ModalDlg; break;
301 case WINDOW_FLOATINGWINDOW: nRT = C_FloatWin; break;
302 case WINDOW_MODELESSDIALOG: nRT = C_ModelessDlg; break;
303 case WINDOW_WORKWINDOW: nRT = C_WorkWin; break;
304 case WINDOW_DOCKINGWINDOW: nRT = C_DockingWin; break;
305
306 case WINDOW_MESSBOX: nRT = C_MessBox; break;
307 case WINDOW_INFOBOX: nRT = C_InfoBox; break;
308 case WINDOW_WARNINGBOX: nRT = C_WarningBox; break;
309 case WINDOW_ERRORBOX: nRT = C_ErrorBox; break;
310 case WINDOW_QUERYBOX: nRT = C_QueryBox; break;
311 #if 0 //ifndef VCL
312 case WINDOW_FILEDIALOG: nRT = C_FileDlg; break;
313 case WINDOW_PATHDIALOG: nRT = C_PathDlg; break;
314 case WINDOW_PRINTDIALOG: nRT = C_PrintDlg; break;
315 case WINDOW_PRINTERSETUPDIALOG: nRT = C_PrinterSetupDlg;break;
316 case WINDOW_COLORDIALOG: nRT = C_ColorDlg; break;
317 #endif
318 case WINDOW_TABDIALOG: nRT = C_TabDlg; break;
319 // case WINDOW_TABDIALOG: nRT = C_SingleTabDlg; break;
320
321 case WINDOW_PATTERNBOX: nRT = C_PatternBox; break;
322 case WINDOW_TOOLBOX: nRT = C_ToolBox; break;
323 // Doesn't exist case WINDOW_VALUESET: nRT = C_ValueSet; break;
324 case WINDOW_CONTROL: nRT = C_Control; break;
325 case WINDOW_OKBUTTON: nRT = C_OkButton; break;
326 case WINDOW_CANCELBUTTON: nRT = C_CancelButton; break;
327 case WINDOW_BUTTONDIALOG: nRT = C_ButtonDialog; break;
328 case WINDOW_TREELISTBOX: nRT = C_TreeListBox; break;
329
330 case WINDOW_DIALOG: nRT = C_Dialog; break;
331 }
332 return nRT;
333 }
334
335 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
336
StatementSlot(SCmdStream * pCmdIn)337 StatementSlot::StatementSlot( SCmdStream *pCmdIn )
338 : pItemArr(NULL)
339 {
340 QueStatement( NULL );
341 pCmdIn->Read( nFunctionId );
342 #if OSL_DEBUG_LEVEL > 1
343 m_pDbgWin->AddText( "Reading Slot: " );
344 m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
345 m_pDbgWin->AddText( "\n" );
346 #endif
347 pCmdIn->Read( nAnzahl );
348 if ( nAnzahl )
349 {
350 switch ( pCmdIn->GetNextType() )
351 {
352 case BinUSHORT: // use old calling method
353 {
354 nAnzahl++;
355 pItemArr = new SfxPoolItem*[nAnzahl];
356 for (sal_uInt16 i = 0 ; i+1 < nAnzahl ; i++)
357 pCmdIn->Read( pItemArr[i] );
358 pItemArr[nAnzahl-1] = NULL;
359 }
360 break;
361 case BinString: // new Method
362 {
363 aArgs.realloc(nAnzahl);
364 PropertyValue* pArg = aArgs.getArray();
365 for (sal_uInt16 i = 0 ; i < nAnzahl ; i++)
366 pCmdIn->Read( pArg[i] );
367 }
368 break;
369 }
370 }
371 }
372
373 // Constructor for UnoSlot
StatementSlot()374 StatementSlot::StatementSlot()
375 : nAnzahl( 0 )
376 , pItemArr(NULL)
377 , nFunctionId( 0 )
378 , bMenuClosed(sal_False)
379 {}
380
StatementSlot(sal_uLong nSlot,SfxPoolItem * pItem)381 StatementSlot::StatementSlot( sal_uLong nSlot, SfxPoolItem* pItem )
382 : pItemArr(NULL)
383 , bMenuClosed(sal_False)
384 {
385 QueStatement( NULL );
386 nFunctionId = sal_uInt16(nSlot);
387 #if OSL_DEBUG_LEVEL > 1
388 m_pDbgWin->AddText( "Reading Slot: " );
389 m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
390 m_pDbgWin->AddText( "\n" );
391 #endif
392 if ( pItem )
393 {
394 nAnzahl = 2;
395 pItemArr = new SfxPoolItem*[2];
396 pItemArr[0] = pItem;
397 pItemArr[1] = NULL;
398 }
399 else
400 nAnzahl = 0;
401 }
402
~StatementSlot()403 StatementSlot::~StatementSlot()
404 {
405 if (nAnzahl)
406 {
407 if ( pItemArr )
408 {
409 for (sal_uInt16 i = 0 ; i+1 < nAnzahl ; i++)
410 delete pItemArr[i];
411 delete[] pItemArr;
412 }
413
414 aArgs.realloc( 0 );
415 }
416 }
417
AddReferer()418 void StatementSlot::AddReferer()
419 {
420 HACK( "only to test!" );
421 // because slot 6102 /*SID_VERB_START*/ crashes when called with Property Referer
422 // We return to the previous behavior (which was a bug really) of not adding this Property to calls which have no properties at all
423 // according to MBA most likely this Property can be removed at all and is maybe only needed for Slots with URLs
424 if ( !nAnzahl )
425 return;
426
427 PropertyValue* pArg;
428
429 nAnzahl++;
430 aArgs.realloc(nAnzahl);
431 pArg = aArgs.getArray();
432 pArg[nAnzahl-1].Name = rtl::OUString::createFromAscii("Referer");
433 pArg[nAnzahl-1].Value <<= ::rtl::OUString::createFromAscii("private:user");
434
435 nAnzahl++;
436 aArgs.realloc(nAnzahl);
437 pArg = aArgs.getArray();
438 pArg[nAnzahl-1].Name = rtl::OUString::createFromAscii("SynchronMode");
439 pArg[nAnzahl-1].Value <<= sal_Bool( sal_True );
440 }
441
442 class SlotStatusListener : public cppu::WeakImplHelper1< XStatusListener >
443 {
444 public:
445 SlotStatusListener();
446
447 // XStatusListener
448 virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
449 // XEventListener
450 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
451
452 // local Members
453 sal_Bool bDisposed;
454 sal_Bool bEnabled;
455 };
456 /*
457 struct FeatureStateEvent : public ::com::sun::star::lang::EventObject
458 ::com::sun::star::util::URL FeatureURL;
459 ::rtl::OUString FeatureDescriptor;
460 sal_Bool IsEnabled;
461 sal_Bool Requery;
462 ::com::sun::star::uno::Any State;
463
464 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Source;
465 */
466
SlotStatusListener()467 SlotStatusListener::SlotStatusListener()
468 : bDisposed( sal_False )
469 , bEnabled( sal_True )
470 {}
471
472 // XStatusListener
statusChanged(const::com::sun::star::frame::FeatureStateEvent & Event)473 void SAL_CALL SlotStatusListener::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
474 {
475 // DBG_ERROR1("FeatureURL: %s", ByteString( String( Event.FeatureURL.Complete ), RTL_TEXTENCODING_UTF8 ).GetBuffer() );
476 // DBG_ERROR1("FeatureDescriptor: %s", ByteString( String( Event.FeatureDescriptor ), RTL_TEXTENCODING_UTF8 ).GetBuffer() );
477 bEnabled = Event.IsEnabled;
478 // DBG_ASSERT( Event.IsEnabled, "Not enabled" );
479 // DBG_ASSERT( !Event.Requery, "Requery" );
480 }
481
482 // XEventListener
disposing(const::com::sun::star::lang::EventObject &)483 void SAL_CALL SlotStatusListener::disposing( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
484 {
485 bDisposed = sal_True;
486 }
487
Execute()488 sal_Bool StatementSlot::Execute()
489 {
490 if ( IsError )
491 {
492 #if OSL_DEBUG_LEVEL > 1
493 m_pDbgWin->AddText( "Skipping Slot: " );
494 m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
495 m_pDbgWin->AddText( "\n" );
496 #endif
497
498 Advance();
499 delete this;
500 return sal_True;
501 }
502
503 InitProfile();
504 #if OSL_DEBUG_LEVEL > 1
505 m_pDbgWin->AddText( "Executing Slot: " );
506 m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) );
507 m_pDbgWin->AddText( "\n" );
508 #endif
509
510 PopupMenu *pPopup = NULL;
511 MenuBar *pMenuBar = NULL;
512 Menu *pMenu;
513
514 GetCurrentMenues( pPopup, pMenuBar, pMenu );
515 if ( pPopup )
516 {
517 if ( !bMenuClosed )
518 {
519 pPopup->EndExecute(0);
520 aSubMenuId1 = 0;
521 aSubMenuId2 = 0;
522 aSubMenuId3 = 0;
523 pMenuWindow = NULL;
524 bMenuClosed = sal_True;
525 #if OSL_DEBUG_LEVEL > 1
526 m_pDbgWin->AddText( "Closed contextmenu\n" );
527 #endif
528 return sal_False;
529 }
530 else if ( nRetryCount-- )
531 {
532 #if OSL_DEBUG_LEVEL > 1
533 m_pDbgWin->AddText( "Waiting for contextmenu to close\n" );
534 #endif
535 return sal_False;
536 }
537 else
538 ReportError( GEN_RES_STR0( S_MENU_NOT_CLOSING ) );
539 }
540
541 Advance();
542
543 if ( !IsError )
544 {
545 if ( ( nAnzahl == 0 && !getenv("OLDSLOTHANDLING") ) || aArgs.hasElements() )
546 { // trying to call slots via uno
547 AddReferer();
548 if ( !aUnoUrl.Len() )
549 aUnoUrl = CUniString("slot:").Append( String::CreateFromInt32( nFunctionId ) );
550 ::com::sun::star::util::URL aTargetURL;
551 aTargetURL.Complete = aUnoUrl;
552 Reference < XFramesSupplier > xDesktop = Reference < XFramesSupplier >( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.frame.Desktop") ), UNO_QUERY );
553 Reference < XFrame > xFrame;
554
555 if ( xDesktop.is() )
556 {
557 xFrame = xDesktop->getActiveFrame();
558 if ( !xFrame.is() )
559 {
560 Reference < XFrames > xFrames;
561 xFrames = xDesktop->getFrames();
562 if ( xFrames.is() && xFrames->getCount() > 0 )
563 {
564 Any aFrame = xFrames->getByIndex( xFrames->getCount() -1 );
565 aFrame >>= xFrame;
566 }
567 }
568 if ( !xFrame.is() )
569 {
570 if ( GetFirstDocFrame() )
571 GetFirstDocFrame()->ToTop();
572 xFrame = xDesktop->getActiveFrame();
573 }
574 }
575
576 if ( xFrame.is() )
577 xDesktop = Reference < XFramesSupplier >( xFrame, UNO_QUERY );
578 else
579 xDesktop.clear();
580
581 while ( xDesktop.is() && xDesktop->getActiveFrame().is() )
582 {
583 xFrame = xDesktop->getActiveFrame();
584 #if OSL_DEBUG_LEVEL > 1
585 ::rtl::OUString aName;
586 if ( xFrame.is() )
587 aName = xFrame->getName();
588 #endif
589 xDesktop = Reference < XFramesSupplier >( xFrame, UNO_QUERY );
590 }
591
592 if ( !xFrame.is() )
593 ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_NO_FRAME, aTargetURL.Complete ) );
594 else
595 {
596 Reference < ::com::sun::star::util::XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.util.URLTransformer" )), UNO_QUERY );
597 xTrans->parseStrict( aTargetURL );
598
599 Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY );
600 Reference < XDispatch > xDisp;
601 while ( xProv.is() && !xDisp.is() )
602 {
603 xDisp = xProv->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
604 if ( !xDisp.is() )
605 {
606 xFrame = Reference < XFrame > ( xFrame->getCreator(), UNO_QUERY );
607 xProv = Reference < XDispatchProvider > ( xFrame, UNO_QUERY );
608 }
609 }
610
611 if ( xDisp.is() )
612 {
613 Reference < XStatusListener > xListener = ( XStatusListener* )new SlotStatusListener;
614 xDisp->addStatusListener( xListener, aTargetURL );
615 if ( static_cast< SlotStatusListener* >(xListener.get())->bEnabled )
616 {
617 if ( bIsSlotInExecute )
618 ReportError( GEN_RES_STR0( S_SLOT_IN_EXECUTE ) );
619 else
620 {
621 bIsSlotInExecute = sal_True;
622 xDisp->dispatch( aTargetURL, aArgs );
623 bIsSlotInExecute = sal_False;
624 }
625 }
626 else
627 ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_DISABLED, aTargetURL.Complete ) );
628 xDisp->removeStatusListener( xListener, aTargetURL );
629 }
630 else
631 ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_NO_DISPATCHER, aTargetURL.Complete ) );
632 }
633 }
634 else
635 {
636 DirectLog( S_QAError, GEN_RES_STR0( S_DEPRECATED ) );
637 if ( !pTTProperties )
638 pTTProperties = new TTProperties();
639
640 switch ( pTTProperties->ExecuteFunction( nFunctionId, pItemArr, EXECUTEMODE_DIALOGASYNCHRON | nUseBindings ) )
641 {
642 case TT_PR_ERR_NODISPATCHER:
643 {
644 ReportError( rtl::OString::valueOf((sal_Int32)nFunctionId), GEN_RES_STR0( S_SID_EXECUTE_FAILED_NO_DISPATCHER ) );
645 }
646 break;
647 case TT_PR_ERR_NOEXECUTE:
648 {
649 ReportError( rtl::OString::valueOf((sal_Int32)nFunctionId), GEN_RES_STR0( S_SID_EXECUTE_FAILED ) );
650 }
651 break;
652 }
653 }
654 }
655
656
657 /* New method from the line 334!
658 New method for setting that modal dialogs are always called asynchronously
659 and a real return value, whether slot has worked
660 and testing whether slot can be called by UI at all */
661
662
663 SendProfile( SlotString( nFunctionId ) );
664 delete this;
665 return sal_True;
666 }
667
668 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
669
StatementUnoSlot(SCmdStream * pIn)670 StatementUnoSlot::StatementUnoSlot(SCmdStream *pIn)
671 {
672 QueStatement( NULL );
673
674 pIn->Read( aUnoUrl );
675
676 #if OSL_DEBUG_LEVEL > 1
677 StatementList::m_pDbgWin->AddText( "UnoUrl:" );
678 StatementList::m_pDbgWin->AddText( aUnoUrl );
679 StatementList::m_pDbgWin->AddText( "\n" );
680 #endif
681
682 }
683
684 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
685
StatementCommand(StatementList * pAfterThis,sal_uInt16 MethodId,sal_uInt16 Params,sal_uInt16 Nr1)686 StatementCommand::StatementCommand( StatementList *pAfterThis, sal_uInt16 MethodId, sal_uInt16 Params, sal_uInt16 Nr1 )
687 : nMethodId( MethodId )
688 , nParams(Params)
689 , nNr1(Nr1)
690 , nNr2(0)
691 , nNr3(0)
692 , nNr4(0)
693 , nLNr1(0)
694 , aString1()
695 , aString2()
696 , bBool1(sal_False)
697 , bBool2(sal_False)
698 {
699 QueStatement( pAfterThis );
700
701 #if OSL_DEBUG_LEVEL > 1
702 m_pDbgWin->AddText( "Directly adding Conmmand:" );
703 m_pDbgWin->AddText( " Methode: " );
704 m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
705 m_pDbgWin->AddText( " Params:" );
706 if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr1 ) );}
707 if( nParams & PARAM_USHORT_2 ) {m_pDbgWin->AddText( " n2:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr2 ) );}
708 if( nParams & PARAM_USHORT_3 ) {m_pDbgWin->AddText( " n3:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr3 ) );}
709 if( nParams & PARAM_USHORT_4 ) {m_pDbgWin->AddText( " n4:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr4 ) );}
710 if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " nl1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
711 if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
712 if( nParams & PARAM_STR_2 ) {m_pDbgWin->AddText( " s2:" );m_pDbgWin->AddText( aString2 );}
713 if( nParams & PARAM_BOOL_1 ) {m_pDbgWin->AddText( " b1:" );m_pDbgWin->AddText( bBool1 ? "TRUE" : "FALSE" );}
714 if( nParams & PARAM_BOOL_2 ) {m_pDbgWin->AddText( " b2:" );m_pDbgWin->AddText( bBool2 ? "TRUE" : "FALSE" );}
715 m_pDbgWin->AddText( "\n" );
716 #endif
717 }
718
719
StatementCommand(SCmdStream * pCmdIn)720 StatementCommand::StatementCommand( SCmdStream *pCmdIn )
721 : nMethodId(0)
722 , nParams(0)
723 , nNr1(0)
724 , nNr2(0)
725 , nNr3(0)
726 , nNr4(0)
727 , nLNr1(0)
728 , aString1()
729 , aString2()
730 , bBool1(sal_False)
731 , bBool2(sal_False)
732 {
733 QueStatement( NULL );
734 pCmdIn->Read( nMethodId );
735 pCmdIn->Read( nParams );
736
737 if( nParams & PARAM_USHORT_1 ) pCmdIn->Read( nNr1 );
738 if( nParams & PARAM_USHORT_2 ) pCmdIn->Read( nNr2 );
739 if( nParams & PARAM_USHORT_3 ) pCmdIn->Read( nNr3 );
740 if( nParams & PARAM_USHORT_4 ) pCmdIn->Read( nNr4 );
741 if( nParams & PARAM_ULONG_1 ) pCmdIn->Read( nLNr1 );
742 if( nParams & PARAM_STR_1 ) pCmdIn->Read( aString1 );
743 if( nParams & PARAM_STR_2 ) pCmdIn->Read( aString2 );
744 if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 );
745 if( nParams & PARAM_BOOL_2 ) pCmdIn->Read( bBool2 );
746
747 #if OSL_DEBUG_LEVEL > 1
748 m_pDbgWin->AddText( "Reading Conmmand:" );
749 m_pDbgWin->AddText( " Methode: " );
750 m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
751 m_pDbgWin->AddText( " Params:" );
752 if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr1 ) );}
753 if( nParams & PARAM_USHORT_2 ) {m_pDbgWin->AddText( " n2:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr2 ) );}
754 if( nParams & PARAM_USHORT_3 ) {m_pDbgWin->AddText( " n3:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr3 ) );}
755 if( nParams & PARAM_USHORT_4 ) {m_pDbgWin->AddText( " n4:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr4 ) );}
756 if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " nl1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
757 if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
758 if( nParams & PARAM_STR_2 ) {m_pDbgWin->AddText( " s2:" );m_pDbgWin->AddText( aString2 );}
759 if( nParams & PARAM_BOOL_1 ) {m_pDbgWin->AddText( " b1:" );m_pDbgWin->AddText( bBool1 ? "TRUE" : "FALSE" );}
760 if( nParams & PARAM_BOOL_2 ) {m_pDbgWin->AddText( " b2:" );m_pDbgWin->AddText( bBool2 ? "TRUE" : "FALSE" );}
761 m_pDbgWin->AddText( "\n" );
762 #endif
763
764 if ( nMethodId == RC_AppAbort )
765 {
766 #if OSL_DEBUG_LEVEL > 1
767 m_pDbgWin->AddText( "*Deleting all Commands:\n" );
768 #endif
769 bReadingCommands = sal_False;
770 while ( StatementList::pFirst != this ) // Delete everything except myself
771 {
772 StatementList *pDeQue = StatementList::pFirst;
773 pDeQue->Advance();
774 delete pDeQue;
775 }
776 bReadingCommands = sal_True;
777 #if OSL_DEBUG_LEVEL > 1
778 m_pDbgWin->AddText( "*Done deleting all Commands:\n" );
779 #endif
780 }
781
782 }
783
WriteControlData(Window * pBase,sal_uLong nConf,sal_Bool bFirst)784 void StatementCommand::WriteControlData( Window *pBase, sal_uLong nConf, sal_Bool bFirst )
785 {
786
787 if ( IsDialog(pBase) && !bFirst )
788 return;
789
790 if ( bFirst )
791 pRet->GenReturn ( RET_WinInfo, rtl::OString(), (comm_ULONG)nConf | DH_MODE_DATA_VALID, UniString(), sal_True );
792
793 if ( bFirst )
794 {
795 if ( pBase->GetType() == WINDOW_WINDOW && pBase->GetParent() && pBase->GetParent()->GetType() == WINDOW_CONTROL &&
796 dynamic_cast< svt::table::TableControl* > ( pBase->GetParent() ) )
797 pBase = pBase->GetParent();
798 }
799
800 { // KParentheses, so that the string does not persist during recursion.
801 String aName;
802 sal_Bool bSkip = sal_False;
803
804 switch ( pBase->GetType() )
805 {
806 case WINDOW_RADIOBUTTON:
807 case WINDOW_CHECKBOX:
808 case WINDOW_TRISTATEBOX:
809 case WINDOW_PUSHBUTTON:
810 case WINDOW_OKBUTTON:
811 case WINDOW_CANCELBUTTON:
812 case WINDOW_IMAGERADIOBUTTON:
813 case WINDOW_IMAGEBUTTON:
814 case WINDOW_MENUBUTTON:
815 case WINDOW_MOREBUTTON:
816 case WINDOW_TABPAGE:
817 case WINDOW_MODALDIALOG:
818 case WINDOW_FLOATINGWINDOW:
819 case WINDOW_MODELESSDIALOG:
820 case WINDOW_WORKWINDOW:
821 case WINDOW_DOCKINGWINDOW:
822 case WINDOW_CONTROL:
823
824 case WINDOW_FILEDIALOG:
825 case WINDOW_PATHDIALOG:
826 case WINDOW_PRINTDIALOG:
827 case WINDOW_PRINTERSETUPDIALOG:
828 case WINDOW_COLORDIALOG:
829 case WINDOW_TABDIALOG:
830
831 case WINDOW_BUTTONDIALOG:
832
833 case WINDOW_MENUBARWINDOW:
834 aName = pBase->GetText().EraseAllChars('~');
835 break;
836
837 case WINDOW_EDIT:
838 case WINDOW_MULTILINEEDIT:
839 case WINDOW_MULTILISTBOX:
840 case WINDOW_LISTBOX:
841 case WINDOW_COMBOBOX:
842 case WINDOW_SPINFIELD:
843 case WINDOW_PATTERNFIELD:
844 case WINDOW_NUMERICFIELD:
845 case WINDOW_METRICFIELD:
846 case WINDOW_CURRENCYFIELD:
847 case WINDOW_DATEFIELD:
848 case WINDOW_TIMEFIELD:
849 case WINDOW_NUMERICBOX:
850 case WINDOW_METRICBOX:
851 case WINDOW_CURRENCYBOX:
852 case WINDOW_DATEBOX:
853 case WINDOW_TIMEBOX:
854 case WINDOW_PATTERNBOX:
855 case WINDOW_TOOLBOX:
856 aName = pBase->GetQuickHelpText();
857 break;
858
859 case WINDOW_MESSBOX:
860 case WINDOW_INFOBOX:
861 case WINDOW_WARNINGBOX:
862 case WINDOW_ERRORBOX:
863 case WINDOW_QUERYBOX:
864 aName = ((MessBox*)pBase)->GetMessText();
865 break;
866
867 default:
868 if ( pBase->GetUniqueOrHelpId().isEmpty() && !( nConf & DH_MODE_ALLWIN ) )
869 bSkip = sal_True;
870 break;
871 }
872
873 if ( !bSkip )
874 {
875 if ( aName.Len() == 0 )
876 aName = pBase->GetQuickHelpText();
877 if ( aName.Len() == 0 )
878 aName = pBase->GetHelpText();
879 if ( aName.Len() == 0 )
880 aName = pBase->GetText();
881
882
883 String aTypeSuffix;
884 if ( pBase->GetType() == WINDOW_CONTROL )
885 {
886 if ( dynamic_cast< EditBrowseBox* >(pBase) )
887 aTypeSuffix.AppendAscii( "/BrowseBox", 10 );
888 else if ( dynamic_cast< ValueSet* >(pBase) )
889 aTypeSuffix.AppendAscii( "/ValueSet", 9 );
890 else if ( dynamic_cast< ORoadmap* >(pBase) )
891 aTypeSuffix.AppendAscii( "/RoadMap", 8 );
892 else if ( dynamic_cast< IExtensionListBox* >(pBase) )
893 aTypeSuffix.AppendAscii( "/ExtensionListBox" );
894 else if ( dynamic_cast< svt::table::TableControl* >(pBase) )
895 aTypeSuffix.AppendAscii( "/TableControl" );
896 else
897 aTypeSuffix.AppendAscii( "/Unknown", 8 );
898 }
899
900 rtl::OString aId = pBase->GetUniqueOrHelpId();
901 pRet->GenReturn ( RET_WinInfo, aId, (comm_ULONG)pBase->GetType(),
902 TypeString(pBase->GetType()).Append(aTypeSuffix).AppendAscii(": ").Append(aName), sal_False );
903
904
905 if ( pBase->GetType() == WINDOW_TOOLBOX ) // Buttons and Controls in Toolboxes.
906 {
907 ToolBox *pTB = ((ToolBox*)pBase);
908 sal_uInt16 i;
909 for ( i = 0; i < pTB->GetItemCount() ; i++ )
910 {
911 aName = String();
912 // if ( aName.Len() == 0 )
913 // aName = pTB->GetQuickHelpText();
914 if ( aName.Len() == 0 )
915 aName = pTB->GetHelpText( pTB->GetItemId( i ) );
916 if ( aName.Len() == 0 )
917 aName = pTB->GetItemText( pTB->GetItemId( i ) );
918
919 Window *pItemWin;
920 pItemWin = pTB->GetItemWindow( pTB->GetItemId( i ) );
921 if ( pTB->GetItemType( i ) == TOOLBOXITEM_BUTTON && ( !pItemWin || !pItemWin->IsVisible() ) )
922 {
923 if ( pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
924 pRet->GenReturn ( RET_WinInfo, Str2Id(pTB->GetItemCommand(pTB->GetItemId( i ))), (comm_ULONG)WINDOW_BUTTON,
925 TypeString(WINDOW_BUTTON).AppendAscii(": ").Append(aName), sal_False );
926 if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
927 pRet->GenReturn ( RET_WinInfo, pTB->GetHelpId(pTB->GetItemId( i )), (comm_ULONG)WINDOW_BUTTON,
928 TypeString(WINDOW_BUTTON).AppendAscii(": ").Append(aName), sal_False );
929 }
930 else
931 {
932 if ( pItemWin )
933 {
934 if ( pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
935 pRet->GenReturn ( RET_WinInfo, Str2Id(pTB->GetItemCommand(pTB->GetItemId( i ))), (comm_ULONG)pItemWin->GetType(),
936 TypeString(pItemWin->GetType()).AppendAscii(": ").Append(aName), sal_False );
937 if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
938 pRet->GenReturn ( RET_WinInfo, pTB->GetHelpId(pTB->GetItemId( i )), (comm_ULONG)pItemWin->GetType(),
939 TypeString(pItemWin->GetType()).AppendAscii(": ").Append(aName), sal_False );
940 sal_uInt16 ii;
941 for( ii = 0 ; ii < pItemWin->GetChildCount(); ii++ )
942 WriteControlData( pItemWin->GetChild(ii), nConf, sal_False );
943 }
944 else
945 {
946 if ( nConf & DH_MODE_ALLWIN )
947 {
948 String aToolBoxItemType;
949 switch ( pTB->GetItemType( i ) )
950 {
951 case TOOLBOXITEM_DONTKNOW:
952 aToolBoxItemType.AssignAscii("TOOLBOXITEM_DONTKNOW");
953 break;
954 case TOOLBOXITEM_BUTTON:
955 aToolBoxItemType.AssignAscii("TOOLBOXITEM_BUTTON");
956 break;
957 case TOOLBOXITEM_SPACE:
958 aToolBoxItemType.AssignAscii("TOOLBOXITEM_SPACE");
959 break;
960 case TOOLBOXITEM_SEPARATOR:
961 aToolBoxItemType.AssignAscii("TOOLBOXITEM_SEPARATOR");
962 break;
963 case TOOLBOXITEM_BREAK:
964 aToolBoxItemType.AssignAscii("TOOLBOXITEM_BREAK");
965 break;
966 default:
967 DBG_ERROR1( "Unknown TOOLBOXITEM %i", pTB->GetItemType( i ) );
968 }
969 if ( pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
970 pRet->GenReturn ( RET_WinInfo, Str2Id( pTB->GetItemCommand(pTB->GetItemId( i )) ), (comm_ULONG)WINDOW_BASE,
971 aToolBoxItemType.AppendAscii(": ").Append(aName), sal_False );
972 if ( !pTB->GetItemCommand(pTB->GetItemId( i )).Len() || ( nConf & DH_MODE_ALLWIN ) )
973 pRet->GenReturn ( RET_WinInfo, pTB->GetHelpId(pTB->GetItemId( i )), (comm_ULONG)WINDOW_BASE,
974 aToolBoxItemType.AppendAscii(": ").Append(aName), sal_False );
975 }
976 }
977 }
978 }
979
980 return; // ToolBox is already completely covered here..
981 }
982
983
984 if ( pBase->GetType() == WINDOW_BUTTONDIALOG // Buttons on button dialogs with ID
985 || pBase->GetType() == WINDOW_MESSBOX
986 || pBase->GetType() == WINDOW_INFOBOX
987 || pBase->GetType() == WINDOW_WARNINGBOX
988 || pBase->GetType() == WINDOW_ERRORBOX
989 || pBase->GetType() == WINDOW_QUERYBOX )
990 {
991 ButtonDialog *pBD = ((ButtonDialog*)pBase);
992 sal_uInt16 i;
993 for ( i = 0; i < pBD->GetButtonCount() ; i++ )
994 {
995 aName = String();
996 if ( aName.Len() == 0 )
997 aName = pBD->GetPushButton( pBD->GetButtonId(i) )->GetText();
998 ByteString aID;
999 switch ( pBD->GetButtonId(i) )
1000 {
1001 case BUTTONID_OK:
1002 aID.Assign("Ok");
1003 break;
1004 case BUTTONID_CANCEL:
1005 aID.Assign("Cancel");
1006 break;
1007 case BUTTONID_YES:
1008 aID.Assign("Yes");
1009 break;
1010 case BUTTONID_NO:
1011 aID.Assign("No");
1012 break;
1013 case BUTTONID_RETRY:
1014 aID.Assign("Retry");
1015 break;
1016 case BUTTONID_HELP:
1017 aID.Assign("Help");
1018 break;
1019 default:
1020 aID = ByteString::CreateFromInt32( pBD->GetButtonId(i) );
1021 break;
1022 }
1023
1024 pRet->GenReturn ( RET_WinInfo, aID, (comm_ULONG)pBD->GetPushButton( pBD->GetButtonId(i) )->GetType(), // so the text is displayed!
1025 TypeString(pBD->GetPushButton( pBD->GetButtonId(i) )->GetType()).AppendAscii(": ").Append(aName)
1026 .AppendAscii(" ButtonId = ").AppendAscii( aID.GetBuffer() ), sal_False );
1027 }
1028
1029 return; // ButtonDialog is already completely covered here.
1030 }
1031
1032
1033 Menu* pMenu = GetMatchingMenu( pBase );
1034
1035 if ( pMenu ) // Menus
1036 {
1037 sal_uInt16 i;
1038 for ( i = 0; i < pMenu->GetItemCount() ; i++ )
1039 {
1040 sal_uInt16 nID = pMenu->GetItemId( i );
1041
1042 aName = String();
1043 if ( aName.Len() == 0 )
1044 aName = pMenu->GetHelpText( nID );
1045 if ( aName.Len() == 0 )
1046 aName = pMenu->GetItemText( nID );
1047
1048
1049 if ( pMenu->GetItemType( i ) == MENUITEM_STRING || pMenu->GetItemType( i ) == MENUITEM_IMAGE || pMenu->GetItemType( i ) == MENUITEM_STRINGIMAGE || (nConf & DH_MODE_ALLWIN) )
1050 {
1051 String aMenuItemType;
1052 switch ( pMenu->GetItemType( i ) )
1053 {
1054 case MENUITEM_STRING:
1055 aMenuItemType.AssignAscii("MENUITEM_STRING");
1056 break;
1057 case MENUITEM_STRINGIMAGE:
1058 aMenuItemType.AssignAscii("MENUITEM_STRINGIMAGE");
1059 break;
1060 case MENUITEM_IMAGE:
1061 aMenuItemType.AssignAscii("MENUITEM_IMAGE");
1062 break;
1063 case MENUITEM_SEPARATOR:
1064 aMenuItemType.AssignAscii("MENUITEM_SEPARATOR");
1065 break;
1066 case MENUITEM_DONTKNOW:
1067 aMenuItemType.AssignAscii("MENUITEM_DONTKNOW");
1068 break;
1069 default:
1070 DBG_ERROR1( "Unknown MENUITEM %i", pMenu->GetItemType( i ) );
1071 }
1072 if ( pMenu->GetItemCommand(nID).Len() || ( nConf & DH_MODE_ALLWIN ) )
1073 pRet->GenReturn ( RET_WinInfo, Str2Id( pMenu->GetItemCommand(nID) ), (comm_ULONG)0,
1074 aMenuItemType.AppendAscii(": ").Append(aName), sal_False );
1075 if ( !pMenu->GetItemCommand(nID).Len() || ( nConf & DH_MODE_ALLWIN ) )
1076 pRet->GenReturn ( RET_WinInfo, rtl::OString::valueOf( (sal_Int32)nID ), (comm_ULONG)0,
1077 aMenuItemType.AppendAscii(": ").Append(aName), sal_False );
1078 }
1079 }
1080
1081 return; // Menu is already completely covered here
1082 }
1083 }
1084 }
1085
1086 for( sal_uInt16 i = 0 ; i < pBase->GetChildCount(); i++ )
1087 WriteControlData( pBase->GetChild(i), nConf, sal_False );
1088 }
1089
1090 class SysWinContainer : public WorkWindow
1091 {
1092 private:
1093 ToolBox *pClientWin;
1094 DockingWindow *pDock;
1095 public:
1096 SysWinContainer( ToolBox *pClient );
1097 ~SysWinContainer();
1098 virtual void Resize();
1099 virtual void Resizing( Size& rSize );
1100 };
1101
SysWinContainer(ToolBox * pClient)1102 SysWinContainer::SysWinContainer( ToolBox *pClient )
1103 : WorkWindow( NULL, WB_BORDER | WB_SIZEMOVE | WB_CLOSEABLE )
1104 , pClientWin( pClient )
1105 {
1106 pDock = new DockingWindow( this );
1107 pClientWin->SetParent( pDock );
1108 pClientWin->SetFloatingMode( sal_False );
1109 SetText( pClient->GetText() );
1110 SetPosPixel( Point( 1,40 ) );
1111 Resize();
1112 pDock->Show();
1113 EnableAlwaysOnTop();
1114 Show();
1115 }
1116
~SysWinContainer()1117 SysWinContainer::~SysWinContainer()
1118 {
1119 delete pDock;
1120 }
1121
Resize()1122 void SysWinContainer::Resize()
1123 {
1124 Size aSize( GetOutputSizePixel() );
1125 Resizing( aSize );
1126 // aSize = pClientWin->GetSizePixel();
1127 // aSize = pClientWin->CalcWindowSizePixel();
1128 if ( aSize != GetSizePixel() )
1129 {
1130 SetOutputSizePixel( aSize );
1131 pDock->SetSizePixel( aSize );
1132 pClientWin->SetSizePixel( aSize );
1133 }
1134 }
1135
Resizing(Size & rSize)1136 void SysWinContainer::Resizing( Size& rSize )
1137 {
1138 Size aSize;
1139 Size aBestSize;
1140 sal_uInt16 i;
1141 sal_Bool bHasValue = sal_False;
1142 sal_uLong nBestValue = 0;
1143 sal_uLong nThisValue;
1144 for ( i=1 ; i<=1 ; i++ )
1145 {
1146 aSize = pClientWin->CalcWindowSizePixel( i );
1147 nThisValue = Abs( aSize.Width() - rSize.Width() ) + Abs( aSize.Height() - rSize.Height() );
1148 if ( !bHasValue || ( nThisValue < nBestValue ) )
1149 {
1150 nBestValue = nThisValue;
1151 aBestSize = aSize;
1152 bHasValue = sal_True;
1153 }
1154 }
1155 rSize = aBestSize;
1156 }
1157
1158 class DisplayHidWin : public ToolBox
1159 {
1160 Edit *pEdit;
1161 Size aMinEditSize;
1162 sal_uInt16 nLastItemID;
1163 sal_Bool bIsDraging;
1164 sal_Bool bIsPermanentDraging;
1165 void SetDraging( sal_Bool bNewDraging );
1166 Image *pShow, *pShow2;
1167 sal_Bool bConfigChanged;
1168 void EnableButtons( sal_uLong nConf );
1169
1170 sal_uLong nEventHookID;
stub_VCLEventHookProc(NotifyEvent & rEvt,void * pData)1171 static long stub_VCLEventHookProc( NotifyEvent& rEvt, void* pData )
1172 {
1173 return ((DisplayHidWin*)pData)->VCLEventHook( rEvt );
1174 }
1175
1176 long VCLEventHook( NotifyEvent& rEvt );
1177 Window *pLastMouseMoveWin;
1178
1179 SysWinContainer *pContainer;
1180
1181 // aborting by pressing shift twice
1182 sal_Bool bOldShift;
1183 Time aLatest;
1184 sal_uInt16 nShiftCount;
1185
1186 public:
1187 DisplayHidWin();
1188 ~DisplayHidWin();
1189
1190 virtual void Tracking( const TrackingEvent& rTEvt );
1191 virtual void Click();
1192 virtual void Select();
1193 virtual void SetText( const XubString& rStr );
1194
SetDisplayText(const String & aNewText)1195 void SetDisplayText( const String &aNewText ){ pEdit->SetText(aNewText); }
GetDisplayText() const1196 String GetDisplayText() const { return pEdit->GetText(); }
IsDisplayTextModified() const1197 sal_Bool IsDisplayTextModified() const { return pEdit->IsModified(); }
ClearDisplayTextModified() const1198 void ClearDisplayTextModified() const { pEdit->ClearModifyFlag(); }
1199
1200 void SetConfig( sal_uLong nConf );
1201 sal_uLong GetConfig();
1202
IsConfigChanged()1203 sal_Bool IsConfigChanged() { return bConfigChanged; }
ConfigSent()1204 void ConfigSent() { bConfigChanged = sal_False; }
1205
IsSendData()1206 sal_Bool IsSendData() { return GetItemState( TT_SEND_DATA ) == STATE_CHECK; }
1207 // sal_Bool IsAllWin() { return GetItemState( TT_ALLWIN ) == STATE_CHECK; }
1208
IsDraging()1209 sal_Bool IsDraging() { return bIsDraging; }
1210
LastMouseMoveWin()1211 Window* LastMouseMoveWin() { return pLastMouseMoveWin; }
1212 };
1213
DisplayHidWin()1214 DisplayHidWin::DisplayHidWin()
1215 : ToolBox( StatementList::GetFirstDocFrame(), TTProperties::GetSvtResId(DisplayHidToolBox) )
1216 , bIsDraging( sal_False )
1217 , bIsPermanentDraging( sal_False )
1218 , pShow( NULL )
1219 , pShow2( NULL )
1220 , pLastMouseMoveWin( NULL )
1221 , bOldShift( 0 )
1222 , nShiftCount( 0 )
1223 {
1224 SetOutStyle( TOOLBOX_STYLE_HANDPOINTER | TOOLBOX_STYLE_FLAT );
1225 pEdit = new Edit( this, WB_CENTER | WB_BORDER );
1226 aMinEditSize = GetItemRect( TT_OUTPUT ).GetSize();
1227 /**/ aMinEditSize=Size(20,20);
1228 aMinEditSize.Width() *= 12;
1229 pEdit->SetSizePixel( aMinEditSize );
1230 pEdit->Show();
1231 SetItemWindow( TT_OUTPUT, pEdit );
1232 Resize();
1233 pContainer = new SysWinContainer( this );
1234 nEventHookID = Application::AddEventHook( stub_VCLEventHookProc, this );
1235 }
1236
~DisplayHidWin()1237 DisplayHidWin::~DisplayHidWin()
1238 {
1239 Application::RemoveEventHook( nEventHookID );
1240 Hide(); // so GetFirstDocFrame won't return ourselves (needed for SOPlayer)
1241 SetParent( StatementList::GetFirstDocFrame() );
1242 delete pContainer;
1243 delete pEdit;
1244 }
1245
SetDraging(sal_Bool bNewDraging)1246 void DisplayHidWin::SetDraging( sal_Bool bNewDraging )
1247 {
1248 if ( !pShow )
1249 pShow = new Image( GetItemImage( TT_SHOW ) );
1250 if ( !pShow2 )
1251 pShow2 = new Image( Bitmap( TTProperties::GetSvtResId( TT_SHOW2 ) ) );
1252
1253 if ( bNewDraging )
1254 SetItemImage( TT_SHOW, *pShow2 );
1255 else
1256 SetItemImage( TT_SHOW, *pShow );
1257
1258 bIsDraging = bNewDraging;
1259 }
1260
EnableButtons(sal_uLong nConf)1261 void DisplayHidWin::EnableButtons( sal_uLong nConf )
1262 {
1263 sal_Bool bSend = sal_Bool(nConf & DH_MODE_SEND_DATA);
1264 EnableItem( TT_ALLWIN, bSend );
1265 EnableItem( TT_KURZNAME, bSend );
1266 EnableItem( TT_LANGNAME, bSend );
1267 }
1268
Tracking(const TrackingEvent & rTEvt)1269 void DisplayHidWin::Tracking( const TrackingEvent& rTEvt )
1270 {
1271 // if ( nLastItemID == TT_SHOW && GetItemState( TT_SHOW ) == STATE_NOCHECK && ( rTEvt.IsTrackingEnded() || rTEvt.IsTrackingCanceled() ) )
1272 // SetDraging( sal_False );
1273 if ( nLastItemID == TT_SHOW && GetItemState( TT_SHOW ) == STATE_NOCHECK )
1274 EndTracking( ENDTRACK_CANCEL );
1275 ToolBox::Tracking( rTEvt);
1276 }
1277
Click()1278 void DisplayHidWin::Click()
1279 {
1280 nLastItemID = GetCurItemId();
1281 if ( nLastItemID == TT_SHOW )
1282 {
1283 SetDraging( sal_True );
1284 }
1285 ToolBox::Click();
1286 }
1287
Select()1288 void DisplayHidWin::Select()
1289 {
1290 if ( GetItemState( GetCurItemId() ) == STATE_NOCHECK )
1291 {
1292 SetItemState( GetCurItemId(), STATE_CHECK );
1293 if ( GetCurItemId() == TT_SHOW )
1294 {
1295 bIsPermanentDraging = sal_True;
1296 SetDraging( sal_True );
1297 }
1298 }
1299 else
1300 {
1301 SetItemState( GetCurItemId(), STATE_NOCHECK );
1302 if ( GetCurItemId() == TT_SHOW )
1303 {
1304 bIsPermanentDraging = sal_False;
1305 SetDraging( sal_False );
1306 }
1307 }
1308 if ( GetCurItemId() == TT_SEND_DATA )
1309 {
1310 EnableButtons( GetConfig() );
1311 }
1312 }
1313
SetConfig(sal_uLong nConf)1314 void DisplayHidWin::SetConfig( sal_uLong nConf )
1315 {
1316 SetItemState( TT_KURZNAME, ( nConf & DH_MODE_KURZNAME ) ? STATE_CHECK : STATE_NOCHECK );
1317 SetItemState( TT_LANGNAME, ( nConf & DH_MODE_LANGNAME ) ? STATE_CHECK : STATE_NOCHECK );
1318 SetItemState( TT_ALLWIN, ( nConf & DH_MODE_ALLWIN ) ? STATE_CHECK : STATE_NOCHECK );
1319 SetItemState( TT_SEND_DATA, ( nConf & DH_MODE_SEND_DATA ) ? STATE_CHECK : STATE_NOCHECK );
1320 EnableButtons( nConf );
1321 }
1322
GetConfig()1323 sal_uLong DisplayHidWin::GetConfig()
1324 {
1325 sal_uLong nConf = 0;
1326 if ( GetItemState( TT_KURZNAME ) == STATE_CHECK )
1327 nConf |= DH_MODE_KURZNAME;
1328 if ( GetItemState( TT_LANGNAME ) == STATE_CHECK )
1329 nConf |= DH_MODE_LANGNAME;
1330 if ( GetItemState( TT_ALLWIN ) == STATE_CHECK )
1331 nConf |= DH_MODE_ALLWIN;
1332 if ( IsSendData() )
1333 nConf |= DH_MODE_SEND_DATA;
1334
1335 return nConf;
1336 }
1337
SetText(const XubString & rStr)1338 void DisplayHidWin::SetText( const XubString& rStr )
1339 {
1340 pContainer->SetText( rStr );
1341 }
1342
VCLEventHook(NotifyEvent & rEvt)1343 long DisplayHidWin::VCLEventHook( NotifyEvent& rEvt )
1344 {
1345 if ( EVENT_MOUSEMOVE == rEvt.GetType() )
1346 {
1347 pLastMouseMoveWin = rEvt.GetWindow();
1348
1349 // check if abort with pressing shift twice
1350 MouseEvent* pMEvt = (MouseEvent*)rEvt.GetMouseEvent();
1351
1352 if ( ( pMEvt->IsShift() && !bOldShift ) ) // Shift pressed
1353 {
1354 if ( aLatest < Time() )
1355 {
1356 nShiftCount = 0;
1357 aLatest = Time()+Time( 0, 0, 0, 50 );
1358 }
1359 nShiftCount++;
1360 }
1361 if ( ( !pMEvt->IsShift() && bOldShift ) ) // Shift released
1362 {
1363 nShiftCount++;
1364 if ( nShiftCount == 4 && aLatest > Time() )
1365 {
1366 bIsPermanentDraging = sal_False;
1367 SetDraging( sal_False );
1368 SetItemState( TT_SHOW, STATE_NOCHECK );
1369 }
1370 }
1371 bOldShift = pMEvt->IsShift();
1372 }
1373 if ( ( ( EVENT_MOUSEBUTTONUP == rEvt.GetType() && rEvt.GetMouseEvent()->GetButtons() == MOUSE_LEFT) || ( EVENT_MOUSEMOVE == rEvt.GetType() && !rEvt.GetMouseEvent()->GetButtons() ) )
1374 && IsDraging() && !bIsPermanentDraging )
1375 SetDraging( sal_False );
1376 return 0;
1377 }
1378
1379
DisplayHID()1380 sal_Bool StatementCommand::DisplayHID()
1381 {
1382 // Return sal_True -> reexecute command
1383
1384 if ( !bBool2 ) // Wird auf sal_False initialisiert
1385 {
1386 bBool2 = sal_True; // Wir sind initialisiert.
1387 GetTTSettings()->pDisplayInstance = this; // Und haben die Macht (Alle anderen beenden sich)
1388
1389 if ( !(nParams & PARAM_ULONG_1) )
1390 {
1391 if( GetTTSettings()->pDisplayHidWin ) // Nichts verändern
1392 nLNr1 = GetTTSettings()->pDisplayHidWin->GetConfig();
1393 else // Beim ersten Aufruf wollen wir alles richtig einstellen
1394 nLNr1 = DH_MODE_KURZNAME | DH_MODE_LANGNAME;
1395
1396 if( ((nParams & PARAM_BOOL_1) && bBool1) )
1397 nLNr1 |= DH_MODE_SEND_DATA;
1398 else
1399 nLNr1 &= ( ~DH_MODE_SEND_DATA );
1400 }
1401
1402 if ( GetTTSettings()->pDisplayHidWin )
1403 GetTTSettings()->pDisplayHidWin->SetConfig( nLNr1 );
1404 }
1405
1406 if ( GetTTSettings()->pDisplayInstance && GetTTSettings()->pDisplayInstance != this )
1407 {
1408 DBG_WARNING("Mehrere DisplayHID am laufen");
1409 return sal_False; // Noch eine andere Instanz macht das gleiche!
1410 }
1411
1412 if ( !GetTTSettings()->pDisplayHidWin )
1413 {
1414 GetTTSettings()->pDisplayHidWin = new DisplayHidWin();
1415 GetTTSettings()->aOriginalCaption = GetTTSettings()->pDisplayHidWin->GetText();
1416 GetTTSettings()->pDisplayHidWin->Show();
1417 if ( bBool1 )
1418 nLNr1 |= DH_MODE_SEND_DATA;
1419 GetTTSettings()->pDisplayHidWin->SetConfig( nLNr1 );
1420
1421 GetTTSettings()->Old = NULL;
1422 GetTTSettings()->Act = NULL;
1423 GetTTSettings()->pDisplayInstance = this;
1424 }
1425 else
1426 {
1427 GetTTSettings()->pDisplayHidWin->GetWindow( WINDOW_OVERLAP )->Enable( sal_True, sal_True );
1428 GetTTSettings()->pDisplayHidWin->GetWindow( WINDOW_OVERLAP )->EnableInput( sal_True, sal_True );
1429 }
1430
1431
1432 if ( GetTTSettings()->pDisplayHidWin->IsVisible() && !bDying )
1433 {
1434
1435 if ( GetTTSettings()->pDisplayHidWin->IsDraging() )
1436 {
1437
1438
1439 #define HIGHLIGHT_WIN( WinPtr ) \
1440 { \
1441 Color aLineColMem = WinPtr->GetLineColor(); \
1442 WinPtr->SetLineColor( Color( COL_WHITE ) ); \
1443 Color aFillColMem = WinPtr->GetFillColor(); \
1444 WinPtr->SetFillColor( Color( COL_LIGHTRED ) ); \
1445 RasterOp aROp = WinPtr->GetRasterOp(); \
1446 WinPtr->SetRasterOp( ROP_XOR ); \
1447 Size aSz = WinPtr->PixelToLogic( WinPtr->GetSizePixel() );\
1448 sal_uLong nMaxCornerRadius = WinPtr->PixelToLogic( Point( 80, 0 ) ).X();\
1449 sal_uLong iCorner = std::max ((sal_uLong) 8, (sal_uLong) std::min( nMaxCornerRadius, (sal_uLong) std::min((sal_uLong) (aSz.Width() / 6), (sal_uLong)(aSz.Height() / 6))));\
1450 WinPtr->DrawRect(Rectangle(Point(),aSz), iCorner, iCorner);\
1451 WinPtr->SetLineColor( aLineColMem ); \
1452 WinPtr->SetFillColor( aFillColMem ); \
1453 WinPtr->SetRasterOp( aROp ); \
1454 }
1455
1456
1457 #define SET_WIN( WinPtr ) \
1458 if ( StatementList::WinPtrValid(WinPtr) ) \
1459 { \
1460 HIGHLIGHT_WIN ( WinPtr ); \
1461 }
1462
1463 #define RESET_WIN( WinPtr ) \
1464 if ( StatementList::WinPtrValid(WinPtr) ) \
1465 { \
1466 WinPtr->Invalidate( INVALIDATE_NOTRANSPARENT ); \
1467 WinPtr->Update(); \
1468 }
1469
1470
1471 GetTTSettings()->Old = GetTTSettings()->Act;
1472 // GetTTSettings()->Act = GetMouseWin();
1473 GetTTSettings()->Act = GetTTSettings()->pDisplayHidWin->LastMouseMoveWin();
1474
1475 if ( !StatementList::WinPtrValid ( GetTTSettings()->Old ) )
1476 GetTTSettings()->Old = NULL;
1477 if ( !StatementList::WinPtrValid ( GetTTSettings()->Act ) )
1478 GetTTSettings()->Act = NULL;
1479
1480 if ( GetTTSettings()->Act && GetTTSettings()->Act->GetType() == WINDOW_BORDERWINDOW )
1481 GetTTSettings()->Act = GetTTSettings()->Act->GetWindow( WINDOW_CLIENT );
1482
1483 if ( GetTTSettings()->Act != GetTTSettings()->Old )
1484 {
1485 if ( GetTTSettings()->Old )
1486 {
1487 RESET_WIN(GetTTSettings()->Old);
1488 }
1489 if ( GetTTSettings()->Act )
1490 {
1491 SET_WIN(GetTTSettings()->Act);
1492 GetTTSettings()->pDisplayHidWin->SetDisplayText( Id2Str(GetTTSettings()->Act->GetUniqueOrHelpId()).AppendAscii(" WinType: ")
1493 .Append(UniString::CreateFromInt64(GetTTSettings()->Act->GetType())).AppendAscii(" ").Append(GetTTSettings()->Act->GetText()));
1494 if ( GetTTSettings()->Act && !GetTTSettings()->Act->GetUniqueId().equals( GetTTSettings()->Act->GetHelpId() ) )
1495 GetTTSettings()->pDisplayHidWin->SetText(UniString( TTProperties::GetSvtResId( TT_ALTERNATE_CAPTION ) ).AppendAscii(GetTTSettings()->Act->GetHelpId().getStr()));
1496 else
1497 GetTTSettings()->pDisplayHidWin->SetText( GetTTSettings()->aOriginalCaption );
1498 }
1499 else
1500 GetTTSettings()->pDisplayHidWin->SetDisplayText(CUniString("Kein Window/Control gefunden"));
1501 }
1502 else if ( GetTTSettings()->Act )
1503 {
1504 // SET_WIN(GetTTSettings()->Act);
1505 // allow setting a HelpID manually (just enter the ID in the displayHID Window and terminate it by |
1506 if ( GetTTSettings()->pDisplayHidWin->IsDisplayTextModified() && GetTTSettings()->pDisplayHidWin->GetDisplayText().GetTokenCount( '|' ) > 1 )
1507 {
1508 GetTTSettings()->Act->SetUniqueId( Str2Id( GetTTSettings()->pDisplayHidWin->GetDisplayText().GetToken( '|' ) ) );
1509 GetTTSettings()->pDisplayHidWin->ClearDisplayTextModified();
1510 }
1511 }
1512 /* if ( Application::GetLastInputInterval() > 5000 ) // 5 Sekunden lang nichts geschehen
1513 {
1514 GetTTSettings()->pDisplayHidWin->ToTop( TOTOP_NOGRABFOCUS );
1515 }
1516 */
1517 if ( GetTTSettings()->pDisplayHidWin->IsSendData() /*&& bBool2*/ && GetTTSettings()->Act )
1518 {
1519 if ( !StatementFlow::bSending )
1520 { // Normalerweise syncronisierung über Protokoll. Hier ist das aber asyncron!!!
1521 WriteControlData( GetTTSettings()->Act, GetTTSettings()->pDisplayHidWin->GetConfig() );
1522 new StatementFlow( this, F_EndCommandBlock ); // Kommando zum Senden erzeugen und in que eintragen
1523 }
1524 }
1525 } //if ( GetTTSettings()->pDisplayHidWin->IsDraging() )
1526 else
1527 {
1528 if ( GetTTSettings()->Act )
1529 {
1530 RESET_WIN(GetTTSettings()->Act);
1531 GetTTSettings()->Act = NULL;
1532 }
1533 }
1534
1535 if ( pFirst == this ) // Sollte immer so sein, aber besser ist es
1536 if ( pNext ) // Befehle warten auf Ausführung
1537 { // An Ende neu einsortieren
1538 Advance();
1539 QueStatement( NULL );
1540 }
1541 // { // Ersten und 2. austauschen.
1542 // pFirst = pNext;
1543 // pNext = pNext->pNext;
1544 // pFirst->pNext = this;
1545 // }
1546
1547 }
1548 else
1549 {
1550 delete GetTTSettings()->pDisplayHidWin;
1551 GetTTSettings()->pDisplayHidWin = NULL;
1552 GetTTSettings()->pDisplayInstance = NULL;
1553 }
1554
1555 return GetTTSettings()->pDisplayHidWin != NULL;
1556 }
1557
1558 class TranslateWin : public WorkWindow
1559 {
1560 private:
1561 DECL_LINK( DoAccept, PushButton* );
1562 DECL_LINK( DoNext, PushButton* );
1563 DECL_LINK( DoSelect, PushButton* );
1564 DECL_LINK( DoRestore, PushButton* );
1565 DECL_LINK( TranslationChanged, Edit* );
1566 DECL_LINK( ShowInplace, Timer* );
1567
1568 Timer InplaceTimer;
1569
1570 // virtual void MouseButtonUp( const MouseEvent& rMEvt );
1571 // virtual void MouseMove( const MouseEvent& rMEvt );
1572
1573 PushButton PushButtonTT_PB_NEXT;
1574 GroupBox GroupBoxTT_GB_TRANSLATION;
1575 Edit EditTT_E_NEW;
1576 GroupBox GroupBoxTT_GB_COMMENT;
1577 Edit EditTT_E_COMMENT;
1578 PushButton PushButtonTT_PB_ACCEPT;
1579 FixedText FixedTextTT_FT_OLD;
1580 PushButton PushButtonTT_PB_SELECT;
1581 PushButton PushButtonTT_PB_RESTORE;
1582
1583 Window *Old;
1584 Window *Act;
1585 Window *pTranslateWin;
1586 sal_Bool bSelecting;
1587
1588 sal_Bool bAvailable;
1589 sal_Bool bNext;
1590
1591 sal_Bool TestChangedDataSaved();
1592
1593
1594 sal_uLong nEventHookID;
stub_VCLEventHookProc(NotifyEvent & rEvt,void * pData)1595 static long stub_VCLEventHookProc( NotifyEvent& rEvt, void* pData )
1596 {
1597 return ((TranslateWin*)pData)->VCLEventHook( rEvt );
1598 }
1599
1600 long VCLEventHook( NotifyEvent& rEvt );
1601
1602 public:
1603 TranslateWin();
1604 ~TranslateWin();
1605
1606 static String MarkShortcutErrors( Window* pBase, sal_Bool bMark );
1607
IsTranslationAvailable()1608 sal_Bool IsTranslationAvailable(){ return bAvailable; }
IsNextDialog()1609 sal_Bool IsNextDialog(){ return bNext; }
ResetNextDialog()1610 void ResetNextDialog(){ bNext = sal_False; }
1611
GetTranslationWindow()1612 Window* GetTranslationWindow(){ return pTranslateWin; }
GetOriginalText()1613 String GetOriginalText(){ return FixedTextTT_FT_OLD.GetText(); }
GetTranslationText()1614 String GetTranslationText(){ return EditTT_E_NEW.GetText(); }
GetComment()1615 String GetComment(){ return EditTT_E_COMMENT.GetText(); }
1616
1617 void EnableTranslation();
1618 };
1619
TranslateWin()1620 TranslateWin::TranslateWin()
1621 : WorkWindow( NULL, TTProperties::GetSvtResId( TT_INLINE_TRANSLATION ) )
1622 , PushButtonTT_PB_NEXT( this, TTProperties::GetSvtResId( TT_PB_NEXT ) )
1623 , GroupBoxTT_GB_TRANSLATION( this, TTProperties::GetSvtResId( TT_GB_TRANSLATION ) )
1624 , EditTT_E_NEW( this, TTProperties::GetSvtResId( TT_E_NEW ) )
1625 , GroupBoxTT_GB_COMMENT( this, TTProperties::GetSvtResId( TT_GB_COMMENT ) )
1626 , EditTT_E_COMMENT( this, TTProperties::GetSvtResId( TT_E_COMMENT ) )
1627 , PushButtonTT_PB_ACCEPT( this, TTProperties::GetSvtResId( TT_PB_ACCEPT ) )
1628 , FixedTextTT_FT_OLD( this, TTProperties::GetSvtResId( TT_FT_OLD ) )
1629 , PushButtonTT_PB_SELECT( this, TTProperties::GetSvtResId( TT_PB_SELECT ) )
1630 , PushButtonTT_PB_RESTORE( this, TTProperties::GetSvtResId( TT_PB_RESTORE ) )
1631 , Old( NULL )
1632 , Act( NULL )
1633 , pTranslateWin( NULL )
1634 , bSelecting( sal_False )
1635 , bAvailable( sal_False )
1636 , bNext( sal_False )
1637 {
1638 FreeResource();
1639 PushButtonTT_PB_NEXT.SetClickHdl( LINK( this, TranslateWin, DoNext ) );
1640 PushButtonTT_PB_ACCEPT.SetClickHdl( LINK( this, TranslateWin, DoAccept ) );
1641 PushButtonTT_PB_SELECT.SetClickHdl( LINK( this, TranslateWin, DoSelect ) );
1642 PushButtonTT_PB_RESTORE.SetClickHdl( LINK( this, TranslateWin, DoRestore ) );
1643 EditTT_E_NEW.SetModifyHdl( LINK( this, TranslateWin, TranslationChanged ) );
1644 InplaceTimer.SetTimeout( 250 );
1645 InplaceTimer.SetTimeoutHdl( LINK( this, TranslateWin, ShowInplace ) );
1646 EnableAlwaysOnTop();
1647 nEventHookID = Application::AddEventHook( stub_VCLEventHookProc, this );
1648 }
1649
~TranslateWin()1650 TranslateWin::~TranslateWin()
1651 {
1652 Application::RemoveEventHook( nEventHookID );
1653 }
1654
TestChangedDataSaved()1655 sal_Bool TranslateWin::TestChangedDataSaved()
1656 {
1657 if ( ( EditTT_E_NEW.GetText().CompareTo( FixedTextTT_FT_OLD.GetText() ) != COMPARE_EQUAL
1658 || EditTT_E_COMMENT.GetText().Len() )
1659 && PushButtonTT_PB_ACCEPT.IsEnabled() )
1660 {
1661 return MessBox( this, TTProperties::GetSvtResId( TT_DISCARD_CHANGED_DATA ) ).Execute() == RET_YES;
1662 }
1663 else
1664 return sal_True;
1665 }
1666
IMPL_LINK(TranslateWin,DoAccept,PushButton *,EMPTYARG)1667 IMPL_LINK( TranslateWin, DoAccept, PushButton*, EMPTYARG )
1668 {
1669 PushButtonTT_PB_SELECT.Disable();
1670 PushButtonTT_PB_NEXT.Disable();
1671 PushButtonTT_PB_RESTORE.Disable();
1672 EditTT_E_NEW.Disable();
1673 EditTT_E_COMMENT.Disable();
1674 PushButtonTT_PB_ACCEPT.Disable();
1675 bAvailable = sal_True;
1676 return 0;
1677 }
1678
IMPL_LINK(TranslateWin,DoNext,PushButton *,EMPTYARG)1679 IMPL_LINK( TranslateWin, DoNext, PushButton*, EMPTYARG )
1680 {
1681 if ( TestChangedDataSaved() )
1682 {
1683 PushButtonTT_PB_SELECT.Disable();
1684 PushButtonTT_PB_NEXT.Disable();
1685 PushButtonTT_PB_RESTORE.Disable();
1686 EditTT_E_NEW.Disable();
1687 EditTT_E_COMMENT.Disable();
1688 PushButtonTT_PB_ACCEPT.Disable();
1689 bNext = sal_True;
1690 }
1691 return 0;
1692 }
1693
IMPL_LINK(TranslateWin,DoSelect,PushButton *,EMPTYARG)1694 IMPL_LINK( TranslateWin, DoSelect, PushButton*, EMPTYARG )
1695 {
1696 if ( bSelecting )
1697 {
1698 // ReleaseMouse();
1699 bSelecting = sal_False;
1700 }
1701 else
1702 {
1703 if ( TestChangedDataSaved() )
1704 {
1705 PushButtonTT_PB_RESTORE.Disable();
1706 // CaptureMouse();
1707 bSelecting = sal_True;
1708 }
1709 }
1710 return 0;
1711 }
1712
IMPL_LINK(TranslateWin,DoRestore,PushButton *,EMPTYARG)1713 IMPL_LINK( TranslateWin, DoRestore, PushButton*, EMPTYARG )
1714 {
1715 String sTT_E_OLD( FixedTextTT_FT_OLD.GetText());
1716 sTT_E_OLD.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") );
1717 sTT_E_OLD.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") );
1718
1719 String sTT_E_NEW( EditTT_E_NEW.GetText());
1720 sTT_E_NEW.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") );
1721 sTT_E_NEW.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") );
1722
1723 if ( StatementList::WinPtrValid( pTranslateWin ) && pTranslateWin->GetText().CompareTo( sTT_E_NEW ) == COMPARE_EQUAL )
1724 { // Im ersten schritt nur in der UI zurück
1725 pTranslateWin->SetText( sTT_E_OLD );
1726 }
1727 else
1728 { // Im zweite Schritt auch den eingegebenen Text
1729 EditTT_E_NEW.SetText( FixedTextTT_FT_OLD.GetText() );
1730 PushButtonTT_PB_RESTORE.Disable();
1731 }
1732 if ( StatementList::WinPtrValid( pTranslateWin ) )
1733 MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), sal_True );
1734 return 0;
1735 }
1736
IMPL_LINK(TranslateWin,TranslationChanged,Edit *,pEdit)1737 IMPL_LINK( TranslateWin, TranslationChanged, Edit*, pEdit )
1738 {
1739 (void) pEdit; /* avoid warning about unused parameter */
1740 PushButtonTT_PB_RESTORE.Enable();
1741 InplaceTimer.Start();
1742 return 0;
1743 }
1744
IMPL_LINK(TranslateWin,ShowInplace,Timer *,EMPTYARG)1745 IMPL_LINK( TranslateWin, ShowInplace, Timer*, EMPTYARG )
1746 {
1747 PushButtonTT_PB_RESTORE.Enable();
1748 if ( StatementList::WinPtrValid( pTranslateWin ) )
1749 {
1750 String sTT_E_NEW( EditTT_E_NEW.GetText());
1751 // alle CRs UnQuoten
1752 sTT_E_NEW.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") );
1753 // alle TABSs UnQuoten
1754 sTT_E_NEW.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") );
1755 pTranslateWin->SetText( sTT_E_NEW );
1756
1757 MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), sal_True );
1758 }
1759 return 0;
1760 }
1761
VCLEventHook(NotifyEvent & rEvt)1762 long TranslateWin::VCLEventHook( NotifyEvent& rEvt )
1763 {
1764 if ( EVENT_MOUSEMOVE == rEvt.GetType() )
1765 {
1766 if ( bSelecting )
1767 {
1768 const MouseEvent *pMEvt = rEvt.GetMouseEvent();
1769 Old = Act;
1770 Act = rEvt.GetWindow();
1771
1772 if ( Act )
1773 {
1774 Window *pWin = Act;
1775 sal_uInt16 i;
1776 for ( i = 0 ; i < Act->GetChildCount() ; i++ )
1777 {
1778 pWin = Act->GetChild(i);
1779 Rectangle aWinPosSize( pWin->GetPosPixel(), pWin->GetSizePixel() );
1780
1781 if ( ( pWin->IsMouseTransparent() || !pWin->IsEnabled() ) && aWinPosSize.IsInside( pMEvt->GetPosPixel() ) )
1782 {
1783 Act = pWin;
1784 break;
1785 }
1786 }
1787 }
1788
1789 if ( !StatementList::WinPtrValid ( Old ) )
1790 Old = NULL;
1791
1792 if ( Act != Old )
1793 {
1794 if ( Old )
1795 {
1796 Window *pWin;
1797 if ( Old->IsMouseTransparent() && Old->GET_REAL_PARENT() )
1798 pWin = Old->GET_REAL_PARENT();
1799 else
1800 pWin = Old;
1801 RESET_WIN(pWin);
1802 }
1803 if ( Act )
1804 {
1805 SET_WIN(Act);
1806 FixedTextTT_FT_OLD.SetText( Act->GetText() );
1807 }
1808 else
1809 FixedTextTT_FT_OLD.SetText( String() );
1810 }
1811 else if ( Act )
1812 {
1813 // SET_WIN(Act);
1814 }
1815 /* if ( Application::GetLastInputInterval() > 5000 ) // 5 Sekunden lang nichts geschehen
1816 {
1817 ToTop();
1818 }
1819 */
1820 } //if ( bSelecting )
1821 else
1822 {
1823 if ( Act )
1824 {
1825 if ( Act->IsMouseTransparent() && Act->GET_REAL_PARENT() )
1826 Act = Act->GET_REAL_PARENT();
1827 RESET_WIN(Act);
1828 Act = NULL;
1829 }
1830 }
1831 }
1832 else if ( EVENT_MOUSEBUTTONUP == rEvt.GetType() )
1833 {
1834 if ( bSelecting )
1835 {
1836 pTranslateWin = Act;
1837 if ( pTranslateWin )
1838 {
1839 MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), sal_True );
1840 // alle CRs quoten (NF)
1841 String sTT_E_NEW( pTranslateWin->GetText());
1842 sTT_E_NEW.SearchAndReplaceAll( CUniString("\n"), CUniString("\\n") );
1843 // alle TABSs quoten ()
1844 sTT_E_NEW.SearchAndReplaceAll( CUniString("\t"), CUniString("\\t") );
1845
1846 FixedTextTT_FT_OLD.SetText( sTT_E_NEW );
1847 EditTT_E_NEW.SetText( sTT_E_NEW );
1848 EditTT_E_NEW.Enable();
1849 EditTT_E_NEW.GrabFocus();
1850 EditTT_E_COMMENT.SetText( String() );
1851 EditTT_E_COMMENT.Enable();
1852 PushButtonTT_PB_ACCEPT.Enable();
1853 }
1854 // ReleaseMouse();
1855 bSelecting = sal_False;
1856 }
1857 }
1858
1859 return 0;
1860 }
1861
1862 #define FDS_ACTION_COLLECT 1
1863 #define FDS_ACTION_MARK 2
1864 #define FDS_ACTION_UNMARK 3
1865
1866 class FindShortcutErrors: public Search
1867 {
1868 String aShortcuts,aDoubleShortcuts;
1869 sal_uInt16 nAction;
1870 public:
1871 FindShortcutErrors();
1872 virtual sal_Bool IsWinOK( Window *pWin );
1873 void SetAction( sal_uInt16 nA );
GetDoubleShortcuts()1874 String GetDoubleShortcuts() { return aDoubleShortcuts; }
1875 };
1876
FindShortcutErrors()1877 FindShortcutErrors::FindShortcutErrors()
1878 : Search( SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN )
1879 {
1880 SetAction( FDS_ACTION_COLLECT ); // Wir fange immer mit sammeln an, ODER??
1881 }
1882
SetAction(sal_uInt16 nA)1883 void FindShortcutErrors::SetAction( sal_uInt16 nA )
1884 {
1885 nAction = nA;
1886 if ( FDS_ACTION_COLLECT == nAction )
1887 {
1888 aShortcuts = UniString();
1889 aDoubleShortcuts = UniString();
1890 }
1891 }
1892
IsWinOK(Window * pWin)1893 sal_Bool FindShortcutErrors::IsWinOK( Window *pWin )
1894 {
1895 if ( pWin->IsReallyVisible() )
1896 {
1897 String aText = pWin->GetText();
1898 xub_StrLen nPos = aText.Search('~');
1899 String aShortcut;
1900 sal_Bool bHasAccel = sal_False;
1901 if ( nPos != STRING_NOTFOUND )
1902 {
1903 aShortcut = aText.Copy( nPos+1, 1 );
1904 aShortcut.ToLowerAscii();
1905 bHasAccel = aShortcut.Len() == 1;
1906 }
1907
1908 switch ( nAction )
1909 {
1910 case FDS_ACTION_COLLECT:
1911 {
1912 if ( aShortcuts.Search( aShortcut ) != STRING_NOTFOUND )
1913 aDoubleShortcuts += aShortcut;
1914 else
1915 aShortcuts += aShortcut;
1916 }
1917 break;
1918 case FDS_ACTION_MARK:
1919 {
1920 sal_Bool bMissing = sal_False;
1921 if ( !bHasAccel && aText.Len() ) // should there be an accelerator defined
1922 {
1923
1924 Window* pChild;
1925 pChild = pWin->GetWindow( WINDOW_CLIENT );
1926
1927 if ( (pChild->GetType() == WINDOW_RADIOBUTTON) ||
1928 (pChild->GetType() == WINDOW_IMAGERADIOBUTTON) ||
1929 (pChild->GetType() == WINDOW_CHECKBOX) ||
1930 (pChild->GetType() == WINDOW_TRISTATEBOX) ||
1931 (pChild->GetType() == WINDOW_PUSHBUTTON) )
1932 {
1933 if ( !pChild->GetText().EqualsAscii( "..." ) )
1934 bMissing = sal_True;
1935 }
1936
1937 if ( pChild->GetType() == WINDOW_FIXEDTEXT )
1938 {
1939 Window* pTempChild = pWin->GetWindow( WINDOW_NEXT );
1940 if ( pTempChild )
1941 pTempChild = pTempChild->GetWindow( WINDOW_CLIENT );
1942
1943 if ( pTempChild && pChild->GetText().Len() )
1944 {
1945 if ( (pTempChild->GetType() == WINDOW_EDIT) ||
1946 (pTempChild->GetType() == WINDOW_MULTILINEEDIT) ||
1947 (pTempChild->GetType() == WINDOW_SPINFIELD) ||
1948 (pTempChild->GetType() == WINDOW_PATTERNFIELD) ||
1949 (pTempChild->GetType() == WINDOW_NUMERICFIELD) ||
1950 (pTempChild->GetType() == WINDOW_METRICFIELD) ||
1951 (pTempChild->GetType() == WINDOW_CURRENCYFIELD) ||
1952 (pTempChild->GetType() == WINDOW_DATEFIELD) ||
1953 (pTempChild->GetType() == WINDOW_TIMEFIELD) ||
1954 (pTempChild->GetType() == WINDOW_LISTBOX) ||
1955 (pTempChild->GetType() == WINDOW_MULTILISTBOX) ||
1956 (pTempChild->GetType() == WINDOW_COMBOBOX) ||
1957 (pTempChild->GetType() == WINDOW_PATTERNBOX) ||
1958 (pTempChild->GetType() == WINDOW_NUMERICBOX) ||
1959 (pTempChild->GetType() == WINDOW_METRICBOX) ||
1960 (pTempChild->GetType() == WINDOW_CURRENCYBOX) ||
1961 (pTempChild->GetType() == WINDOW_DATEBOX) ||
1962 (pTempChild->GetType() == WINDOW_TIMEBOX) )
1963 {
1964 bMissing = sal_True;
1965 }
1966 }
1967 }
1968 }
1969
1970 if ( bHasAccel && aDoubleShortcuts.Search( aShortcut ) != STRING_NOTFOUND )
1971 {
1972 if ( pWin->GetType() == WINDOW_GROUPBOX )
1973 pWin->SetControlForeground( Color( COL_LIGHTRED ) );
1974 else
1975 {
1976 pWin->SetControlBackground();
1977 Color aCol(COL_GRAY);
1978 aCol.SetRed( 0xff );
1979 pWin->SetControlBackground( aCol );
1980 }
1981 }
1982 else if ( bMissing )
1983 {
1984 pWin->SetControlBackground();
1985 Color aCol(COL_GRAY);
1986 aCol.SetRed( 0xff );
1987 aCol.SetGreen( 0xff );
1988 pWin->SetControlBackground( aCol );
1989 }
1990 else
1991 {
1992 pWin->SetControlForeground();
1993 pWin->SetControlBackground();
1994 }
1995 }
1996 break;
1997 case FDS_ACTION_UNMARK:
1998 {
1999 pWin->SetControlForeground();
2000 pWin->SetControlBackground();
2001 }
2002 break;
2003 }
2004 }
2005 else
2006 if ( FDS_ACTION_MARK == nAction || FDS_ACTION_UNMARK == nAction )
2007 {
2008 pWin->SetControlForeground();
2009 pWin->SetControlBackground();
2010 }
2011
2012 return sal_False;
2013 }
2014
MarkShortcutErrors(Window * pBase,sal_Bool bMark)2015 String TranslateWin::MarkShortcutErrors( Window* pBase, sal_Bool bMark )
2016 {
2017 if ( pBase )
2018 {
2019 FindShortcutErrors aFinder;
2020 if ( bMark )
2021 {
2022 StatementList::SearchAllWin( pBase, aFinder, sal_True ); // collect Shortcuts first
2023 aFinder.SetAction( FDS_ACTION_MARK );
2024 }
2025 else
2026 aFinder.SetAction( FDS_ACTION_UNMARK );
2027 StatementList::SearchAllWin( pBase, aFinder, sal_True );
2028 return aFinder.GetDoubleShortcuts();
2029 }
2030 return UniString();
2031 }
2032
EnableTranslation()2033 void TranslateWin::EnableTranslation()
2034 {
2035 PushButtonTT_PB_SELECT.Enable();
2036 PushButtonTT_PB_NEXT.Enable();
2037 bAvailable = sal_False;
2038 bNext = sal_False;
2039 }
2040
Translate()2041 void StatementCommand::Translate()
2042 {
2043 // Es wurde eine initale UniqueId mitgegeben. Dann nur die dopelten Shortcuts liefern
2044 if( (nParams & PARAM_STR_1) && nLNr1 )
2045 {
2046 String aDouble;
2047 Window *pWin = SearchTree( Str2Id( aString1 ) ,sal_False );
2048 if ( pWin )
2049 {
2050 pWin = pWin->GetWindow( WINDOW_OVERLAP );
2051 aDouble = TranslateWin::MarkShortcutErrors( pWin, sal_True );
2052 }
2053 pRet->GenReturn ( RET_Value, nMethodId, aDouble );
2054 return;
2055 }
2056
2057 if ( !GetTTSettings()->pTranslateWin )
2058 {
2059 GetTTSettings()->pTranslateWin = new TranslateWin;
2060 GetTTSettings()->bToTop = sal_True;
2061 }
2062
2063 GetTTSettings()->pTranslateWin->Show();
2064 if ( GetTTSettings()->bToTop )
2065 {
2066 GetTTSettings()->pTranslateWin->ToTop();
2067 GetTTSettings()->bToTop = sal_False;
2068 }
2069
2070 // GetTTSettings()->pTranslateWin->GetWindow( WINDOW_OVERLAP )->Enable( sal_True, sal_True );
2071 GetTTSettings()->pTranslateWin->GetWindow( WINDOW_OVERLAP )->EnableInput( sal_True, sal_True );
2072
2073 if ( GetTTSettings()->pTranslateWin->IsTranslationAvailable() )
2074 {
2075 String aTranslation;
2076 Window* pTranslationWindow = GetTTSettings()->pTranslateWin->GetTranslationWindow();
2077
2078 DBG_ASSERT( pTranslationWindow, "Kein Translation Window" );
2079
2080 if ( WinPtrValid( pTranslationWindow ) )
2081 {
2082 if ( pTranslationWindow->GetType() == WINDOW_BORDERWINDOW && pTranslationWindow->GetWindow( WINDOW_CLIENT ) )
2083 {
2084 Window* pNew = pTranslationWindow->GetWindow( WINDOW_CLIENT );
2085 // Bei Dockingwindows das ganze Geraffel von Docking Floating überspringen
2086 while ( IsDialog( pNew ) && pNew->GetUniqueOrHelpId().isEmpty() && pNew->GetChildCount() == 1 )
2087 pNew = pNew->GetChild( 0 );
2088 pTranslationWindow = pNew;
2089 }
2090
2091 aTranslation = CUniString("0;");
2092
2093 aTranslation += Id2Str( pTranslationWindow->GetUniqueOrHelpId() );
2094 aTranslation += ';';
2095
2096 aTranslation += TypeString( pTranslationWindow->GetType() );
2097 aTranslation += ';';
2098
2099 Window* pParentDialog = pTranslationWindow;
2100 while ( pParentDialog && !IsDialog( pParentDialog ) )
2101 {
2102 pParentDialog = pParentDialog->GET_REAL_PARENT();
2103 }
2104
2105 if ( pParentDialog )
2106 {
2107 aTranslation += Id2Str(pParentDialog->GetUniqueOrHelpId());
2108 aTranslation += ';';
2109 aTranslation += TypeString( pParentDialog->GetType() );
2110 }
2111 else
2112 aTranslation.AppendAscii( "0;" ); // Zahl + leerer String
2113 aTranslation += ';';
2114
2115 aTranslation += '\"';
2116 aTranslation += GetTTSettings()->pTranslateWin->GetOriginalText();
2117 aTranslation += '\"';
2118
2119 aTranslation += ';';
2120
2121 aTranslation += '\"';
2122 aTranslation += GetTTSettings()->pTranslateWin->GetTranslationText();
2123 aTranslation += '\"';
2124
2125 aTranslation += ';';
2126
2127 aTranslation += '\"';
2128 aTranslation += GetTTSettings()->pTranslateWin->GetComment();
2129 aTranslation += '\"';
2130
2131 // alle CRs quoten (NF)
2132 aTranslation.SearchAndReplaceAll( CUniString("\n"), CUniString("\\n") );
2133 // alle TABSs quoten ()
2134 aTranslation.SearchAndReplaceAll( CUniString("\t"), CUniString("\\t") );
2135
2136 pRet->GenReturn ( RET_Value, nMethodId, aTranslation );
2137 GetTTSettings()->pTranslateWin->EnableTranslation();
2138 GetTTSettings()->bToTop = sal_True;
2139 }
2140 else
2141 {
2142 pRet->GenReturn ( RET_Value, nMethodId, String() );
2143 GetTTSettings()->pTranslateWin->EnableTranslation();
2144 ErrorBox err( GetTTSettings()->pTranslateWin, TTProperties::GetSvtResId( TT_NO_CONTROL ));
2145 err.Execute();
2146 GetTTSettings()->bToTop = sal_True;
2147 }
2148
2149 }
2150 else if ( GetTTSettings()->pTranslateWin->IsNextDialog() )
2151 {
2152 pRet->GenReturn ( RET_Value, nMethodId, CUniString("1") );
2153 GetTTSettings()->pTranslateWin->ResetNextDialog();
2154 GetTTSettings()->pTranslateWin->LoseFocus();
2155 GetTTSettings()->bToTop = sal_True;
2156 }
2157 else
2158 {
2159 GetTTSettings()->pTranslateWin->EnableTranslation();
2160 pRet->GenReturn ( RET_Value, nMethodId, String() );
2161 }
2162 }
2163
GetNextOverlap(Window * pBase)2164 Window* StatementCommand::GetNextOverlap( Window* pBase )
2165 { // Findet irgendwelche Overlap-Fenster, die schließbar aussehen
2166 // Eventuell muß noch die Auswahl verfeinert werden.
2167
2168 if ( pBase->GetType() != WINDOW_BORDERWINDOW )
2169 pBase = pBase->GetWindow( WINDOW_OVERLAP );
2170
2171 Window *pControl = NULL;
2172 if ( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) )
2173 {
2174 pControl = GetNextOverlap( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) );
2175 }
2176
2177 if ( !pControl && pBase->GetWindow( WINDOW_NEXT ) )
2178 {
2179 pControl = GetNextOverlap( pBase->GetWindow( WINDOW_NEXT ) );
2180 }
2181
2182 if ( !pControl )
2183 {
2184 Window *pTest = pBase->GetWindow( WINDOW_CLIENT );
2185 if ( IsAccessable (pTest)
2186 && pTest->IsEnabled()
2187 && pTest->IsVisible()
2188 && ((pTest->GetStyle() & WB_CLOSEABLE ) || (pBase->GetStyle() & WB_CLOSEABLE )) )
2189 return pTest;
2190 else
2191 return NULL;
2192 }
2193 else
2194 return pControl;
2195 }
2196
GetNextRecoverWin()2197 Window* StatementCommand::GetNextRecoverWin()
2198 {
2199 // über die TopLevelWindows der App iterieren
2200 Window* pBase = Application::GetFirstTopLevelWindow();
2201 Window *pControl = NULL;
2202 Window* pMyFirstDocFrame = NULL;
2203 while ( pBase )
2204 {
2205 // zuerst weitere Fenster auf dem Fenster suchen und schliessen
2206 pControl = GetNextOverlap( pBase );
2207 if ( pControl && pControl->GetType() == WINDOW_HELPTEXTWINDOW )
2208 {} // skip it
2209 else
2210 {
2211 if ( pControl && pControl->IsVisible() && !IsFirstDocFrame( pControl ) && !IsIMEWin( pControl ) )
2212 {
2213 Window* pTB = pControl->GetChild( 0 );
2214 if ( pControl->GetChildCount() == 1 && pTB->GetType() == WINDOW_TOOLBOX )
2215 // return pTB;
2216 ; // do not act on floating toolboxes #i38796
2217 else
2218 return pControl;
2219 }
2220
2221 // dann das Fenster selbst schliessen
2222 // erstes DocWin überspringen
2223 // Assumption that Doc Windows are Borderwindows and ButtonDialog and such are not
2224 if ( pBase->IsVisible() && !IsFirstDocFrame( pBase ) && pBase->GetType() != WINDOW_BORDERWINDOW && !IsIMEWin( pBase ) )
2225 return pBase;
2226
2227 if ( !pMyFirstDocFrame && IsFirstDocFrame( pBase ) )
2228 pMyFirstDocFrame = pBase;
2229 }
2230
2231 pBase = Application::GetNextTopLevelWindow( pBase );
2232 }
2233 #ifdef RESET_APPLICATION_TO_BACKING_WINDOW
2234 // close the FirstDocFrame last, It will not be closed, but the Document inside will be closed.
2235 if ( IsDocWin( pMyFirstDocFrame ) )
2236 return pMyFirstDocFrame;
2237 #endif // def RESET_APPLICATION_TO_BACKING_WINDOW
2238
2239 return NULL;
2240 }
2241
Execute()2242 sal_Bool StatementCommand::Execute()
2243 {
2244 if ( IsError )
2245 {
2246 #if OSL_DEBUG_LEVEL > 1
2247 m_pDbgWin->AddText( "Skipping Command: " );
2248 m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
2249 m_pDbgWin->AddText( "\n" );
2250 #endif
2251
2252 Advance();
2253 delete this;
2254 return sal_True;
2255 }
2256
2257 InitProfile();
2258 #if OSL_DEBUG_LEVEL > 1
2259 m_pDbgWin->AddText( "Executing Command: " );
2260 m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
2261 m_pDbgWin->AddText( "\n" );
2262 #endif
2263
2264
2265
2266
2267
2268 #if OSL_DEBUG_LEVEL > 1
2269 #define REPORT_WIN_CLOSED(pControl, aInfo) \
2270 _REPORT_WIN_CLOSED(pControl, aInfo) \
2271 m_pDbgWin->AddText( aInfo.AppendAscii(" \"").Append( pControl->GetText() ).AppendAscii("\" geschlossen, RType = ").Append( TypeString(pControl->GetType()) ).AppendAscii(", UId = ").Append( UIdString( pControl->GetUniqueOrHelpId() ) ) );
2272 #else
2273 #define REPORT_WIN_CLOSED(pControl, aInfo) _REPORT_WIN_CLOSED(pControl, aInfo)
2274 #endif
2275
2276 #define REPORT_WIN_CLOSEDc(pControl, aInfo ) \
2277 REPORT_WIN_CLOSED(pControl, CUniString(aInfo) )
2278
2279 #define _REPORT_WIN_CLOSED(pControl, aInfo) \
2280 if ( aString1.Len() ) \
2281 aString1 += '\n'; \
2282 aString1 += aInfo; \
2283 aString1.AppendAscii(" \""); \
2284 aString1 += pControl->GetText(); \
2285 aString1.AppendAscii("\" geschlossen, RType = ");\
2286 aString1 += TypeString(pControl->GetType()); \
2287 aString1.AppendAscii(", UId = "); \
2288 aString1 += UIdString(pControl->GetUniqueOrHelpId());
2289
2290
2291 switch ( nMethodId )
2292 {
2293 case RC_AppDelay:
2294 if ( !bBool1 )
2295 {
2296 nLNr1 = Time().GetTime() + nNr1/10;
2297 bBool1 = sal_True;
2298 }
2299 if ( Time().GetTime() < long(nLNr1) ) // Aktuelle Zeit kleiner Endzeit
2300 return sal_False;
2301 break;
2302 case RC_DisplayHid:
2303 if ( DisplayHID() )
2304 return sal_False;
2305 break;
2306 case RC_ResetApplication:
2307 {
2308 if ( !bBool1 )
2309 {
2310 nRetryCount = 150; // das sollte reichen.
2311 bBool1 = sal_True; // Nur beim ersten mal!
2312 nNr1 = 1; // Welcher Button ist dran?
2313 nLNr1 = 0; // Speichern des AppWin
2314 aString1 = UniString(); // Liste der geschlossenen Fenster
2315
2316 // So daß nacher auch wieder alles auf Default steht
2317 nUseBindings = 0;
2318 bCatchGPF = sal_True;
2319 bUsePostEvents = sal_True;
2320
2321 aSubMenuId1 = 0;
2322 aSubMenuId2 = 0;
2323 aSubMenuId3 = 0;
2324 pMenuWindow = NULL;
2325 }
2326 if ( !nRetryCount )
2327 ReportError( GEN_RES_STR0( S_RESETAPPLICATION_FAILED_COMPLEX ) );
2328
2329 Window *pControl = GetNextRecoverWin();
2330
2331 if ( pControl )
2332 {
2333 bBool2 = sal_False; // flag for wait when all windows are closed
2334 pControl->GrabFocus();
2335
2336 if ( pControl->GetType() != WINDOW_DOCKINGWINDOW
2337 && pControl->GetType() != WINDOW_FLOATINGWINDOW
2338 && pControl->GetType() != WINDOW_MODELESSDIALOG
2339 && pControl->GetType() != WINDOW_WORKWINDOW
2340 && pControl->GetType() != WINDOW_TOOLBOX
2341 && pControl->GetType() != WINDOW_BORDERWINDOW
2342 && nRetryCount-- )
2343 {
2344 short nRT = ImpGetRType( pControl );
2345
2346 if ( nRT == C_TabControl && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
2347 { // Bei Tabcontrol den zugehörigen Tabdialog nehmen
2348 pControl = pControl->GET_REAL_PARENT();
2349 nRT = ImpGetRType( pControl );
2350 }
2351
2352 switch( nRT )
2353 {
2354 case C_ModalDlg:
2355 case C_Dialog:
2356 case C_TabDlg:
2357 REPORT_WIN_CLOSEDc(pControl, "Dialog");
2358 SET_WINP_CLOSING(pControl);
2359 ((SystemWindow*)pControl)->Close();
2360 break;
2361 case C_WorkWin:
2362 break;
2363 case C_MessBox:
2364 case C_InfoBox:
2365 case C_WarningBox:
2366 case C_ErrorBox:
2367 case C_QueryBox:
2368 case C_ButtonDialog:
2369 {
2370 ButtonDialog* pBD = (ButtonDialog*)pControl;
2371 // nNr1 >= 10 bedeutet (Custom)-Buttons durchgehen
2372 if ( nNr1 >= 10+pBD->GetButtonCount() ) nNr1 = 1;
2373 switch( nNr1 )
2374 {
2375 case 5:
2376 if ( pBD->GetPushButton( BUTTONID_OK ) )
2377 {
2378 REPORT_WIN_CLOSEDc(pControl, "Message Box (OK)");
2379 SET_WINP_CLOSING(pControl);
2380 pBD->EndDialog(RET_OK);
2381 }
2382 nNr1 = 10; // Nochmal alle Buttons der Reihe nach
2383 break;
2384 case 4:
2385 if ( pBD->GetPushButton( BUTTONID_CANCEL ) )
2386 {
2387 REPORT_WIN_CLOSEDc(pControl, "Message Box (Cancel)");
2388 SET_WINP_CLOSING(pControl);
2389 pBD->EndDialog(RET_CANCEL);
2390 }
2391 nNr1++;
2392 break;
2393 case 3:
2394 if ( pBD->GetPushButton( BUTTONID_YES ) )
2395 {
2396 REPORT_WIN_CLOSEDc(pControl, "Message Box (Yes)");
2397 SET_WINP_CLOSING(pControl);
2398 pBD->EndDialog(RET_YES);
2399 }
2400 nNr1++;
2401 break;
2402 case 2: // BUG 48239
2403 case 1:
2404 if ( pBD->GetPushButton( BUTTONID_NO ) )
2405 {
2406 REPORT_WIN_CLOSEDc(pControl, "Message Box (No)");
2407 SET_WINP_CLOSING(pControl);
2408 pBD->EndDialog(RET_NO);
2409 }
2410 nNr1++;
2411 break;
2412 default:
2413 {
2414 sal_uInt16 nID = pBD->GetButtonId( nNr1-10 );
2415 if ( nID != BUTTONID_HELP )
2416 {
2417 REPORT_WIN_CLOSED(pControl, CUniString("Message Box (").Append( UniString::CreateFromInt32(nID) ).AppendAscii(")"));
2418 SET_WINP_CLOSING(pControl);
2419 pBD->EndDialog(nID);
2420 }
2421 nNr1++;
2422 }
2423 }
2424 break;
2425 }
2426 default:
2427 DBG_ERROR( "Unknown Windowtype" );
2428 REPORT_WIN_CLOSEDc(pControl, "Unknown Windowtype");
2429 ReportError( GEN_RES_STR0( S_RESETAPPLICATION_FAILED_UNKNOWN ), pControl->GetType() );
2430 #if OSL_DEBUG_LEVEL > 1
2431 m_pDbgWin->AddText( " Unbekannter Objekttyp aus UId" );
2432 #endif
2433 break;
2434 }
2435 return sal_False;
2436 }
2437 else
2438 {
2439 if ( (pControl->GetType() == WINDOW_DOCKINGWINDOW || pControl->GetType() == WINDOW_TOOLBOX) && nRetryCount-- )
2440 {
2441 if ( (((DockingWindow*)pControl)->GetStyle() | ((DockingWindow*)pControl)->GetFloatStyle()) & WB_CLOSEABLE )
2442 {
2443 REPORT_WIN_CLOSED(pControl, TypeString(pControl->GetType()));
2444 SET_WINP_CLOSING(pControl);
2445 ((DockingWindow*)pControl)->Close();
2446
2447 // Eigentlich nur bei TaskWindows! Hoffen wir mal, daß keine anderen DockingWindows dazwischen hauen.
2448 if ( (Window*)nLNr1 != pControl )
2449 nNr1 = 1; // Zum durchprobieren der Buttons beim schließen
2450 nLNr1 = (sal_uLong)pControl;
2451
2452 return sal_False;
2453 }
2454 }
2455 if ( nRetryCount--
2456 && ( (pControl->GetType() == WINDOW_FLOATINGWINDOW)
2457 || (pControl->GetType() == WINDOW_MODELESSDIALOG)
2458 || (pControl->GetType() == WINDOW_WORKWINDOW)
2459 || (pControl->GetType() == WINDOW_BORDERWINDOW) ) )
2460 {
2461 // if ( pControl->GetStyle() & WB_CLOSEABLE )
2462 {
2463 #ifdef RESET_APPLICATION_TO_BACKING_WINDOW
2464 // Special handling for last Document; do not close the Frame, only the Document
2465 if ( GetDocWinCount() == 1 && IsDocFrame( pControl ) )
2466 {
2467 if ( IsDocWin( pControl ) )
2468 {
2469 if ( GetDocFrameMenuBar( pControl ) )
2470 {
2471 MenuBar* pMenu = GetDocFrameMenuBar( pControl );
2472 if ( pMenu->HasCloser() )
2473 {
2474 REPORT_WIN_CLOSED( pControl, TypeString(pControl->GetType()));
2475 SET_WINP_CLOSING(pControl);
2476
2477 pMenu->GetCloserHdl().Call( pMenu );
2478
2479 // nur bei TaskWindows!
2480 if ( (Window*)nLNr1 != pControl )
2481 nNr1 = 1; // Zum durchprobieren der Buttons beim Schließen
2482 nLNr1 = (sal_uLong)pControl;
2483
2484 return sal_False;
2485 }
2486 }
2487 }
2488 }
2489 else
2490 #endif // def RESET_APPLICATION_TO_BACKING_WINDOW
2491 {
2492 REPORT_WIN_CLOSED( pControl, TypeString(pControl->GetType()));
2493 SET_WINP_CLOSING(pControl);
2494 ((SystemWindow*)pControl)->Close();
2495
2496 // Eigentlich nur bei TaskWindows!
2497 if ( (Window*)nLNr1 != pControl )
2498 nNr1 = 1; // Zum durchprobieren der Buttons beim Schließen
2499 nLNr1 = (sal_uLong)pControl;
2500
2501 return sal_False;
2502 }
2503 }
2504 }
2505 }
2506 }
2507 // wait for some time if more windows show up
2508 // E.g.: Floating toolbars on a Task which was hidden by another Task before
2509 if ( !bBool2 )
2510 {
2511 nLNr1 = Time().GetTime() + 100; // 100 = 1 Second
2512 bBool2 = sal_True;
2513 }
2514 if ( Time().GetTime() < long(nLNr1) ) // Aktuelle Zeit kleiner Endzeit
2515 return sal_False;
2516 else
2517 pRet->GenReturn ( RET_Value, nMethodId, aString1);
2518 }
2519 break;
2520 case RC_WaitSlot:
2521 {
2522 if ( ! (nParams & PARAM_USHORT_1) )
2523 nNr1 = 1000; // defaults to 1000 = 1 Sec.
2524 if ( !bBool1 )
2525 {
2526 nLNr1 = Time().GetTime() + nNr1/10;
2527 bBool1 = sal_True;
2528 }
2529
2530 if ( !bIsSlotInExecute )
2531 pRet->GenReturn ( RET_Value, nMethodId, comm_USHORT(CONST_WSFinished) );
2532 else
2533 {
2534 if ( Time().GetTime() < long(nLNr1) ) // Aktuelle Zeit kleiner Endzeit
2535 return sal_False;
2536 pRet->GenReturn ( RET_Value, nMethodId, comm_USHORT(CONST_WSTimeout) );
2537 }
2538 }
2539 break;
2540 }
2541
2542
2543 Advance();
2544
2545
2546 switch ( nMethodId )
2547 {
2548 case RC_AppDelay: // Diese Befehle werden anderswo behandelt
2549 case RC_DisplayHid:
2550 case RC_ResetApplication:
2551 case RC_WaitSlot:
2552
2553 case RC_AppAbort: // Sofortiges Löschen aller Befehle
2554 break;
2555 case RC_Assert:
2556 {
2557 ByteString aAssertion( "Diese Assertion wurde vom Testtool per Befehl ausgelöst" );
2558 aAssertion = ByteString( String( aAssertion, RTL_TEXTENCODING_MS_1252 ), RTL_TEXTENCODING_UTF8 );
2559 DBG_ASSERT( !aString1.Len(), ByteString( aString1, RTL_TEXTENCODING_UTF8 ).GetBuffer() );
2560 DBG_ASSERT( aString1.Len(), aAssertion.GetBuffer() );
2561 OSL_ENSURE( !aString1.Len(), ByteString( aString1, RTL_TEXTENCODING_UTF8 ).GetBuffer() );
2562 OSL_ENSURE( aString1.Len(), aAssertion.GetBuffer() );
2563 }
2564 break;
2565 case RC_CaptureAssertions:
2566 #ifdef DBG_UTIL
2567 if( !(nParams & PARAM_BOOL_1) || bBool1 )
2568 {
2569 DBG_INSTOUTERROR( DBG_OUT_TESTTOOL );
2570 osl_setDebugMessageFunc( osl_TestToolDebugPrint );
2571 }
2572 else
2573 {
2574 DBG_INSTOUTERROR( DBG_OUT_MSGBOX );
2575 osl_setDebugMessageFunc( pOriginal_osl_DebugMessageFunc );
2576 }
2577 #endif
2578 break;
2579 case RC_Translate:
2580 Translate();
2581 break;
2582 case RC_ApplicationBusy:
2583 {
2584 sal_Bool bWait = sal_False;
2585 ReportError( GEN_RES_STR0( S_NO_ACTIVE_WINDOW ) );
2586 // if ( Application::GetAppWindow() )
2587 // bWait = Application::GetAppWindow()->IsWait();
2588 pRet->GenReturn ( RET_Value, nMethodId, bWait );
2589 break;
2590 }
2591 case RC_GetClipboard:
2592 {
2593 ::rtl::OUString aTemp;
2594 ::svt::OStringTransfer::PasteString( aTemp, GetFirstDocFrame() );
2595 pRet->GenReturn ( RET_Value, nMethodId, String( aTemp ) );
2596 }
2597 break;
2598 case RC_SetClipboard:
2599 ::svt::OStringTransfer::CopyString(aString1,GetFirstDocFrame());
2600 break;
2601 case RC_WinTree:
2602 pRet->GenReturn ( RET_Value, nMethodId, Tree( NULL, 0));
2603 break;
2604 #if OSL_DEBUG_LEVEL > 1
2605 case RC_NoDebug:
2606 m_pDbgWin->bQuiet = sal_True;
2607 m_pDbgWin->Hide();
2608 m_pDbgWin->Clear();
2609 break;
2610 case RC_Debug:
2611 m_pDbgWin->bQuiet = sal_False;
2612 m_pDbgWin->Show();
2613 break;
2614 #endif
2615 case RC_GPF:
2616 ((TabControl*)NULL)->SetCurPageId( 12345 );
2617 break;
2618 case RC_GetNextCloseWindow:
2619 {
2620 Window *pWin = GetActive( WINDOW_BASE ); // WINDOW_ANYTYPE
2621 if ( !pWin )
2622 ReportError( GEN_RES_STR0( S_NO_ACTIVE_WINDOW ) );
2623 else if ( !IsDialog(pWin) )
2624 ReportError( GEN_RES_STR0( S_NO_DIALOG_IN_GETACTIVE ) );
2625 else
2626 {
2627 pRet->GenReturn( RET_Value, nMethodId, Id2Str(pWin->GetUniqueOrHelpId()) );
2628 }
2629 }
2630 break;
2631 case RC_UseBindings:
2632 if( !(nParams & PARAM_BOOL_1) || bBool1 )
2633 nUseBindings = SFX_USE_BINDINGS;
2634 else
2635 nUseBindings = 0;
2636 break;
2637 case RC_Profile:
2638 // Bei folgenden Parametern passiert folgendes:
2639 // ein boolean=false Alles Profiling stoppen (Ergebnisse liefern)
2640 // ein boolean=true, 1-4 ints Einteilung der Zeiten in Kästchen
2641 // kein! boolean keine ints loggen jeden Befehls
2642 // kein! boolean 1 int loggen alle int Millisekunden
2643 // ein String wird in das Logfile übernommen(sonst passiert nichts)
2644 if( !(nParams & PARAM_BOOL_1) || bBool1 )
2645 {
2646 if ( !pProfiler )
2647 {
2648 pProfiler = new TTProfiler;
2649 InitProfile();
2650 }
2651
2652 if( !(nParams & PARAM_BOOL_1) && (nParams & PARAM_USHORT_1) )
2653 { // Autoprofiling: Profile nNr
2654 if ( pProfiler->IsProfilingPerCommand() )
2655 {
2656 pProfiler->StopProfilingPerCommand();
2657 }
2658 pProfiler->StartAutoProfiling( nNr1 );
2659
2660 // Der Header ist abhängig vom Modus
2661 pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetProfileHeader() );
2662 }
2663 else if ( nParams & PARAM_USHORT_1 )
2664 { // Partitioning initialisieren: Profile true [,nNr][,nNr][,nNr][,nNr]
2665 comm_ULONG nAnzahl=0;
2666 if ( nParams & PARAM_USHORT_1 ) { nAnzahl++; };
2667 if ( nParams & PARAM_USHORT_2 ) { nAnzahl++; };
2668 if ( nParams & PARAM_USHORT_3 ) { nAnzahl++; };
2669 if ( nParams & PARAM_USHORT_4 ) { nAnzahl++; };
2670
2671 // Hier werden die Parameter ans Testtool zurück übertragen.
2672 // Das ist zwar etwas eigenartig, aber ansonsten müsste man im Testtool
2673 // die einfache Struktur der Remotebefehle aufbrechen.
2674 pRet->GenReturn( RET_ProfileInfo, S_ProfileReset, nAnzahl );
2675
2676 // Und die einzelnen Grenzen
2677 if ( nParams & PARAM_USHORT_1 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder1, (comm_ULONG)nNr1 ); };
2678 if ( nParams & PARAM_USHORT_2 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder2, (comm_ULONG)nNr2 ); };
2679 if ( nParams & PARAM_USHORT_3 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder3, (comm_ULONG)nNr3 ); };
2680 if ( nParams & PARAM_USHORT_4 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder4, (comm_ULONG)nNr4 ); };
2681
2682 pProfiler->StartPartitioning();
2683 }
2684 else if( nParams == PARAM_STR_1 ) // Genau ein String!
2685 { // Nur einen String ins Profiling aufnehmen
2686 aString1 += '\n';
2687 pRet->GenReturn( RET_ProfileInfo, 0, aString1 );
2688 }
2689 else
2690 { // Normales Profiling je Kommando: profile
2691 if ( pProfiler->IsAutoProfiling() )
2692 {
2693 pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetAutoProfiling() );
2694 pProfiler->StopAutoProfiling();
2695 }
2696 pProfiler->StartProfilingPerCommand();
2697
2698 // Der Header ist abhängig vom Modus
2699 pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetProfileHeader() );
2700 }
2701 }
2702 else // Profiling wieder ausschalten: Profile false
2703 if ( pProfiler )
2704 {
2705 if ( pProfiler->IsProfilingPerCommand() )
2706 pProfiler->StopProfilingPerCommand();
2707
2708 if ( pProfiler->IsAutoProfiling() )
2709 {
2710 pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetAutoProfiling() );
2711 pProfiler->StopAutoProfiling();
2712 }
2713
2714 if ( pProfiler->IsPartitioning() )
2715 {
2716 pRet->GenReturn( RET_ProfileInfo, S_ProfileDump, (comm_ULONG)0 );
2717 pProfiler->StopPartitioning();
2718 }
2719
2720 delete pProfiler;
2721 pProfiler = NULL;
2722 }
2723 break;
2724 case RC_MenuGetItemCount:
2725 case RC_MenuGetItemId:
2726 case RC_MenuGetItemPos:
2727 case RC_MenuIsSeperator:
2728 case RC_MenuIsItemChecked:
2729 case RC_MenuIsItemEnabled:
2730 case RC_MenuGetItemText:
2731 case RC_MenuGetItemCommand:
2732 case RC_MenuHasSubMenu:
2733 case RC_MenuSelect:
2734 {
2735 PopupMenu *pPopup = NULL;
2736 MenuBar *pMenuBar = NULL;
2737 Menu *pMenu;
2738
2739 sal_uInt16 nErr = GetCurrentMenues( pPopup, pMenuBar, pMenu );
2740
2741 if ( !pMenu )
2742 {
2743 if ( nErr == 1 )
2744 ReportError( GEN_RES_STR0( S_NO_POPUP ) );
2745 else
2746 ReportError( GEN_RES_STR0( S_NO_SUBMENU ) );
2747 break;
2748 }
2749
2750 sal_uInt16 nItemCount = 0;
2751 switch ( nMethodId )
2752 {
2753 case RC_MenuGetItemCount:
2754 case RC_MenuGetItemId:
2755 case RC_MenuIsSeperator:
2756 {
2757 nItemCount = pMenu->GetItemCount();
2758 if ( pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES )
2759 { // jep, we have to adjust the count
2760 sal_Bool bLastWasSeperator = sal_True; // sal_True for Separator at the top
2761 for ( sal_uInt16 i = 0 ; i < pMenu->GetItemCount() ; i++ )
2762 {
2763 if ( !pMenu->IsItemEnabled( pMenu->GetItemId( i ) ) )
2764 nItemCount--;
2765 else
2766 {
2767 if ( pMenu->GetItemType( i ) == MENUITEM_SEPARATOR && bLastWasSeperator )
2768 nItemCount--;
2769 bLastWasSeperator = pMenu->GetItemType( i ) == MENUITEM_SEPARATOR;
2770 }
2771 }
2772 if ( bLastWasSeperator ) // Separator at bottom
2773 nItemCount--;
2774 }
2775 }
2776 break;
2777 }
2778
2779 // for certain methods calculate the physical index (reinserting the hidden entries)
2780 sal_uInt16 nPhysicalIndex = 0;
2781 switch ( nMethodId )
2782 {
2783 case RC_MenuGetItemId:
2784 case RC_MenuIsSeperator:
2785 {
2786 nPhysicalIndex = nNr1;
2787 if ( pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES )
2788 { // jep, we have to adjust the position
2789 sal_Bool bLastWasSeperator = sal_True; // sal_True for Separator at the top
2790 sal_uInt16 nVisibleCount = 0;
2791 for ( sal_uInt16 i = 0 ; i < pMenu->GetItemCount() && nVisibleCount < nNr1 ; i++ )
2792 {
2793 if ( pMenu->IsItemEnabled( pMenu->GetItemId( i ) )
2794 && !( pMenu->GetItemType( i ) == MENUITEM_SEPARATOR && bLastWasSeperator ) )
2795 {
2796 nVisibleCount++;
2797 bLastWasSeperator = pMenu->GetItemType( i ) == MENUITEM_SEPARATOR;
2798 }
2799 else
2800 nPhysicalIndex++;
2801 }
2802 DBG_ASSERT( nVisibleCount == nNr1, "Adaption of Index failed: nVisibleCount != nNr1" );
2803 }
2804 }
2805 break;
2806 }
2807
2808
2809
2810 switch ( nMethodId )
2811 {
2812 case RC_MenuGetItemCount:
2813 {
2814 pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)nItemCount );
2815 }
2816 break;
2817 case RC_MenuGetItemId:
2818 {
2819 if ( ValueOK( rtl::OString(), RcString( nMethodId ),nNr1,nItemCount) )
2820 pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)pMenu->GetItemId(nPhysicalIndex-1) );
2821 }
2822 break;
2823 case RC_MenuGetItemPos:
2824 {
2825 sal_uInt16 nLogicalPos = pMenu->GetItemPos(nNr1);
2826 if ( MENU_ITEM_NOTFOUND != nLogicalPos && pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES )
2827 { // jep, we have to adjust the position
2828 if ( !pMenu->IsItemEnabled( nNr1 ) )
2829 nLogicalPos = MENU_ITEM_NOTFOUND;
2830 else
2831 {
2832 sal_Bool bLastWasSeperator = sal_False;
2833 for ( int i = nLogicalPos ; i >= 0 ; i-- )
2834 {
2835 if ( !pMenu->IsItemEnabled( pMenu->GetItemId( sal::static_int_cast< sal_uInt16 >(i) ) ) ||
2836 ( pMenu->GetItemType( sal::static_int_cast< sal_uInt16 >(i) ) == MENUITEM_SEPARATOR && bLastWasSeperator ) )
2837 nLogicalPos--;
2838 bLastWasSeperator = pMenu->GetItemType( sal::static_int_cast< sal_uInt16 >(i) ) == MENUITEM_SEPARATOR;
2839 }
2840 }
2841 }
2842 pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)(nLogicalPos+1) );
2843 }
2844 break;
2845 case RC_MenuIsSeperator:
2846 {
2847 if ( ValueOK( rtl::OString(), RcString( nMethodId ),nNr1,nItemCount) )
2848 pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)(pMenu->GetItemType(nPhysicalIndex-1) == MENUITEM_SEPARATOR) );
2849 }
2850 break;
2851 case RC_MenuIsItemChecked:
2852 {
2853 pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)pMenu->IsItemChecked(nNr1) );
2854 }
2855 break;
2856 case RC_MenuIsItemEnabled:
2857 {
2858 pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)pMenu->IsItemEnabled(nNr1) );
2859 }
2860 break;
2861 case RC_MenuGetItemText:
2862 {
2863 pRet->GenReturn ( RET_Value, nMethodId, (String)pMenu->GetItemText(nNr1) );
2864 }
2865 break;
2866 case RC_MenuGetItemCommand:
2867 {
2868 pRet->GenReturn ( RET_Value, nMethodId, (String)pMenu->GetItemCommand(nNr1) );
2869 }
2870 break;
2871 case RC_MenuHasSubMenu:
2872 {
2873 pRet->GenReturn ( RET_Value, nMethodId, (sal_Bool)(pMenu->GetPopupMenu(nNr1) != NULL) );
2874 }
2875 break;
2876 case RC_MenuSelect:
2877 {
2878 if ( pMenu->GetPopupMenu(nNr1) )
2879 {
2880 if ( !aSubMenuId1 )
2881 aSubMenuId1 = nNr1;
2882 else if ( !aSubMenuId2 )
2883 aSubMenuId2 = nNr1;
2884 else if ( !aSubMenuId3 )
2885 aSubMenuId3 = nNr1;
2886
2887 if ( pPopup )
2888 pPopup->SelectEntry(nNr1);
2889 else
2890 pMenuBar->SelectEntry(nNr1);
2891 }
2892 else
2893 {
2894 if ( pPopup )
2895 {
2896 pPopup->EndExecute(nNr1);
2897 aSubMenuId1 = 0;
2898 aSubMenuId2 = 0;
2899 aSubMenuId3 = 0;
2900 pMenuWindow = NULL;
2901 }
2902 else
2903 {
2904 pMenuBar->SelectEntry(nNr1);
2905 aSubMenuId1 = 0;
2906 aSubMenuId2 = 0;
2907 aSubMenuId3 = 0;
2908 pMenuWindow = NULL;
2909 }
2910 }
2911 }
2912 break;
2913 }
2914 }
2915 break;
2916 case RC_SetControlType:
2917 {
2918 DirectLog( S_QAError, GEN_RES_STR0( S_DEPRECATED ) );
2919 }
2920 break;
2921 case RC_Kill:
2922 case RC_RmDir:
2923 case RC_MkDir:
2924 case RC_FileCopy:
2925 case RC_Name:
2926 case RC_Dir:
2927 case RC_FileLen:
2928 case RC_FileDateTime:
2929 {
2930 long nErrorcode = FSYS_ERR_OK;
2931 switch ( nMethodId )
2932 {
2933 case RC_Kill:
2934 {
2935 DirEntry aFile( aString1 );
2936 nErrorcode = aFile.GetError();
2937 if ( FSYS_ERR_OK == nErrorcode && FileStat( aFile ).IsKind( FSYS_KIND_FILE ) )
2938 nErrorcode = aFile.Kill();
2939 else
2940 nErrorcode = FSYS_ERR_NOTAFILE;
2941 }
2942 break;
2943 case RC_RmDir:
2944 {
2945 DirEntry aDir( aString1 );
2946 nErrorcode = aDir.GetError();
2947 if ( FSYS_ERR_OK == nErrorcode && FileStat( aDir ).IsKind( FSYS_KIND_DIR ) )
2948 nErrorcode = aDir.Kill();
2949 else
2950 nErrorcode = FSYS_ERR_NOTADIRECTORY;
2951 }
2952 break;
2953 case RC_MkDir:
2954 {
2955 DirEntry aDir( aString1 );
2956 nErrorcode = aDir.GetError();
2957 if ( !nErrorcode && !aDir.MakeDir() )
2958 nErrorcode = FSYS_ERR_UNKNOWN;
2959 // Workaround für Bug 60693
2960 // nErrorcode = aDir.GetError();
2961 }
2962 break;
2963 case RC_FileCopy:
2964 {
2965 nErrorcode = DirEntry( aString1 ).CopyTo( DirEntry( aString2 ), FSYS_ACTION_COPYFILE );
2966 }
2967 break;
2968 case RC_Name:
2969 {
2970 nErrorcode = DirEntry( aString1 ).MoveTo( DirEntry( aString2 ) );
2971 }
2972 break;
2973 case RC_Dir:
2974 {
2975
2976 String aPath;
2977 sal_uInt16 nDirFlags = 0;
2978 // from basic/source/inc/runtime.hxx
2979 #define Sb_ATTR_NORMAL 0x0000
2980 #define Sb_ATTR_HIDDEN 0x0002
2981 #define Sb_ATTR_SYSTEM 0x0004
2982 #define Sb_ATTR_VOLUME 0x0008
2983 #define Sb_ATTR_DIRECTORY 0x0010
2984 #define Sb_ATTR_ARCHIVE 0x0020
2985 // copied from Basic and adapted basic/source/runtime/methods.cxx Revision 1.54
2986 if ( (nParams & PARAM_STR_1) )
2987 {
2988 delete pDir;
2989 pDir = NULL; // wg. Sonderbehandlung Sb_ATTR_VOLUME
2990 DirEntry aEntry( aString1 );
2991 FileStat aStat( aEntry );
2992 if(!aStat.GetError() && (aStat.GetKind() & FSYS_KIND_FILE))
2993 {
2994 // OK, only a filename
2995 // cut off path (VB4)
2996 aPath = aEntry.GetName();
2997 }
2998 else
2999 {
3000 sal_uInt16 nFlags = 0;
3001 if ( (nParams & PARAM_USHORT_1) )
3002 nDirFlags = nFlags = nNr1;
3003 else
3004 nDirFlags = nFlags = Sb_ATTR_HIDDEN | Sb_ATTR_SYSTEM | Sb_ATTR_DIRECTORY;
3005
3006 // Nur diese Bitmaske ist unter Windows erlaubt
3007 // Sb_ATTR_VOLUME wird getrennt gehandelt
3008 if( nDirFlags & Sb_ATTR_VOLUME )
3009 aPath = aEntry.GetVolume();
3010 else
3011 {
3012 // Die richtige Auswahl treffen
3013 sal_uInt16 nMode = FSYS_KIND_FILE;
3014 if( nFlags & Sb_ATTR_DIRECTORY )
3015 nMode |= FSYS_KIND_DIR;
3016 if( nFlags == Sb_ATTR_DIRECTORY )
3017 nMode = FSYS_KIND_DIR;
3018 pDir = new Dir( aEntry, (DirEntryKind) nMode );
3019 nErrorcode = pDir->GetError();
3020 nDirPos = 0;
3021 }
3022 }
3023 }
3024
3025 if( pDir )
3026 {
3027 for( ;; )
3028 {
3029 if( nDirPos >= pDir->Count() )
3030 {
3031 delete pDir;
3032 pDir = NULL;
3033 aPath.Erase();
3034 break;
3035 }
3036 DirEntry aNextEntry=(*(pDir))[nDirPos++];
3037 aPath = aNextEntry.GetName(); //Full();
3038 break;
3039 }
3040 }
3041 if ( !nErrorcode )
3042 {
3043 pRet->GenReturn ( RET_Value, nMethodId, aPath );
3044 }
3045
3046 /* keep old Implementation for now
3047 // neues Verzeichnis einlesen
3048 if ( (nParams & PARAM_STR_1) )
3049 {
3050 if ( pDir )
3051 {
3052 delete pDir;
3053 pDir = NULL;
3054 }
3055 DirEntryKind aDirEntryKind = FSYS_KIND_FILE | FSYS_KIND_DIR;
3056 if ( (nParams & PARAM_USHORT_1) && nNr1 )
3057 {
3058 if ( nNr1 & 16 )
3059 aDirEntryKind = FSYS_KIND_DIR;
3060 else
3061 ReportError( GEN_RES_STR0( S_SELECTION_BY_ATTRIBUTE_ONLY_DIRECTORIES ) );
3062 }
3063
3064 DirEntry aEntry( aString1 );
3065 nErrorcode = aEntry.GetError();
3066 if ( !nErrorcode )
3067 {
3068 nDirPos = 0;
3069 FileStat aFS( aEntry );
3070 if ( !aFS.IsKind( FSYS_KIND_WILD ) && !aFS.IsKind( FSYS_KIND_DIR ) && aEntry.Exists() )
3071 { // Sonderbehandlung für genau einen Eintrag
3072 if ( !aFS.IsKind( FSYS_KIND_DIR ) && ( aDirEntryKind == FSYS_KIND_DIR ) )
3073 pRet->GenReturn ( RET_Value, nMethodId, String() );
3074 else
3075 pRet->GenReturn ( RET_Value, nMethodId, (String)(aEntry.GetName()) );
3076
3077 break;
3078 }
3079 else
3080 {
3081 pDir = new Dir( aEntry, aDirEntryKind );
3082 nErrorcode = pDir->GetError();
3083 }
3084 }
3085 }
3086
3087 if ( !pDir )
3088 pDir = new Dir;
3089
3090 if ( !nErrorcode && ValueOK( nMethodId, GEN_RES_STR0( S_NO_MORE_FILES ), nDirPos+1, pDir->Count()+1 ) )
3091 {
3092 if ( nDirPos == pDir->Count() )
3093 pRet->GenReturn ( RET_Value, nMethodId, String() );
3094 else
3095 pRet->GenReturn ( RET_Value, nMethodId, (String)((*pDir)[ nDirPos ].GetName()) );
3096 nDirPos++;
3097 }*/
3098 }
3099 break;
3100 case RC_FileLen:
3101 {
3102 DirEntry aFile( aString1 );
3103 nErrorcode = aFile.GetError();
3104 if ( FSYS_ERR_OK == nErrorcode )
3105 {
3106 FileStat aFS( aFile );
3107 pRet->GenReturn ( RET_Value, nMethodId, static_cast<comm_ULONG>(aFS.GetSize()) ); //GetSize() sal_uLong != comm_ULONG on 64bit
3108 nErrorcode = aFS.GetError();
3109 }
3110 }
3111 break;
3112 case RC_FileDateTime:
3113 {
3114 DirEntry aFile( aString1 );
3115 nErrorcode = aFile.GetError();
3116 if ( FSYS_ERR_OK == nErrorcode )
3117 {
3118 FileStat aStat( aFile );
3119 Time aTime( aStat.TimeModified() );
3120 Date aDate( aStat.DateModified() );
3121 nErrorcode = aStat.GetError();
3122
3123 double fSerial = (double)( aDate - Date(30,12,1899) );
3124 long nSeconds = aTime.GetHour();
3125 nSeconds *= 3600;
3126 nSeconds += aTime.GetMin() * 60;
3127 nSeconds += aTime.GetSec();
3128 double nDays = ((double)nSeconds) / (double)(24.0*3600.0);
3129 fSerial += nDays;
3130
3131 SbxValueRef xValue = new SbxValue( SbxDATE );
3132 xValue->PutDate( fSerial );
3133
3134 pRet->GenReturn ( RET_Value, nMethodId, *xValue );
3135 }
3136 }
3137 break;
3138 }
3139 switch ( nErrorcode )
3140 {
3141 case FSYS_ERR_OK:
3142 break;
3143 case FSYS_ERR_MISPLACEDCHAR:
3144 {
3145 ReportError( CUniString("MISPLACEDCHAR") );
3146 }
3147 break;
3148 case FSYS_ERR_INVALIDCHAR:
3149 {
3150 ReportError( CUniString("INVALIDCHAR") );
3151 }
3152 break;
3153 case FSYS_ERR_NOTEXISTS:
3154 {
3155 ReportError( CUniString("NOTEXISTS") );
3156 }
3157 break;
3158 case FSYS_ERR_ALREADYEXISTS:
3159 {
3160 ReportError( CUniString("ALREADYEXISTS") );
3161 }
3162 break;
3163 case FSYS_ERR_NOTADIRECTORY:
3164 {
3165 ReportError( CUniString("NOTADIRECTORY") );
3166 }
3167 break;
3168 case FSYS_ERR_NOTAFILE:
3169 {
3170 ReportError( CUniString("NOTAFILE") );
3171 }
3172 break;
3173 case FSYS_ERR_INVALIDDEVICE:
3174 {
3175 ReportError( CUniString("INVALIDDEVICE") );
3176 }
3177 break;
3178 case FSYS_ERR_ACCESSDENIED:
3179 {
3180 ReportError( CUniString("ACCESSDENIED") );
3181 }
3182 break;
3183 case FSYS_ERR_LOCKVIOLATION:
3184 {
3185 ReportError( CUniString("LOCKVIOLATION") );
3186 }
3187 break;
3188 case FSYS_ERR_VOLUMEFULL:
3189 {
3190 ReportError( CUniString("VOLUMEFULL") );
3191 }
3192 break;
3193 case FSYS_ERR_ISWILDCARD:
3194 {
3195 ReportError( CUniString("ISWILDCARD") );
3196 }
3197 break;
3198 case FSYS_ERR_NOTSUPPORTED:
3199 {
3200 ReportError( CUniString("NOTSUPPORTED") );
3201 }
3202 break;
3203 case FSYS_ERR_UNKNOWN:
3204 {
3205 ReportError( CUniString("UNKNOWN") );
3206 }
3207 break;
3208 default:
3209 {
3210 ReportError( CUniString("Not an FSYS Error") );
3211 }
3212 }
3213
3214 }
3215 break;
3216 case RC_TypeKeysDelay:
3217 {
3218 if( (nParams & PARAM_BOOL_1) )
3219 {
3220 bDoTypeKeysDelay = bBool1;
3221 }
3222 else if( nParams & PARAM_USHORT_1 )
3223 {
3224 nMinTypeKeysDelay = nNr1;
3225 if( nParams & PARAM_USHORT_2 )
3226 nMaxTypeKeysDelay = nNr2;
3227 else
3228 nMaxTypeKeysDelay = nMinTypeKeysDelay;
3229 }
3230 else
3231 ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3232 }
3233 break;
3234 case RC_GetMouseStyle:
3235 {
3236 Pointer aPointer;
3237 // if ( DragManager::GetDragManager() )
3238 // aPointer = DragManager::GetDragManager()->GetDragPointer();
3239 // else
3240 {
3241 Window *pActualWin = GetMouseWin();
3242 if ( pActualWin )
3243 aPointer = pActualWin->GetPointer();
3244 else
3245 {
3246 ReportError( GEN_RES_STR1( S_POINTER_OUTSIDE_APPWIN, RcString( nMethodId ) ) );
3247 aPointer = Pointer( POINTER_NULL );
3248 }
3249 }
3250 pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)aPointer.GetStyle() );
3251 }
3252 break;
3253 case RC_UnpackStorage:
3254 {
3255 if( (nParams & PARAM_STR_1) )
3256 {
3257 String aFileName( aString1 );
3258 DirEntry aDestPath;
3259 if( (nParams & PARAM_STR_2) )
3260 aDestPath = DirEntry( aString2 );
3261 else
3262 {
3263 aDestPath = DirEntry( aFileName );
3264 aDestPath.SetExtension( CUniString( "plaintext" ) );
3265 }
3266
3267 #if OSL_DEBUG_LEVEL > 1
3268 sal_uInt16 nEntries = Dir( aDestPath, FSYS_KIND_FILE | FSYS_KIND_DIR ).Count();
3269 (void) nEntries; /* avoid warning about unused parameter */
3270 #endif
3271 // The Count is only larger than 2 is the path is a directory which is not empty
3272 // the Count of 2 results from the "." and ".." directory
3273 if ( Dir( aDestPath, FSYS_KIND_FILE | FSYS_KIND_DIR ).Count() > 2 )
3274 DirectLog( S_QAError, GEN_RES_STR1( S_DIRECTORY_NOT_EMPTY, aDestPath.GetFull() ) );
3275
3276 SotStorageRef xStorage = new SotStorage( aFileName, STREAM_STD_READ );
3277 if ( xStorage->GetError() )
3278 ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aFileName, aDestPath.GetFull()) );
3279 else
3280 UnpackStorage( xStorage, aDestPath );
3281 }
3282 else
3283 ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3284 }
3285 break;
3286 case RC_CloseSysDialog:
3287 case RC_ExistsSysDialog:
3288 {
3289 if( (nParams & PARAM_USHORT_1) )
3290 {
3291 Reference < ::com::sun::star::util::XCancellable > xPicker;
3292 switch( nNr1 )
3293 {
3294 case CONST_FilePicker:
3295 {
3296 xPicker.set( Reference < ::com::sun::star::util::XCancellable >( svt::GetTopMostFilePicker(), UNO_QUERY ) );
3297 }
3298 break;
3299 case CONST_FolderPicker:
3300 {
3301 xPicker.set( Reference < ::com::sun::star::util::XCancellable >( svt::GetTopMostFolderPicker(), UNO_QUERY ) );
3302 }
3303 break;
3304 default:
3305 ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3306 }
3307 switch( nMethodId )
3308 {
3309 case RC_CloseSysDialog:
3310 {
3311 if ( xPicker.is() )
3312 xPicker->cancel();
3313 else
3314 ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3315 }
3316 break;
3317 case RC_ExistsSysDialog:
3318 {
3319 pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)xPicker.is() );
3320 }
3321 break;
3322 default:
3323 ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3324 }
3325 }
3326 else
3327 ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3328 }
3329 break;
3330 case RC_SAXCheckWellformed:
3331 case RC_SAXReadFile:
3332
3333 case RC_SAXGetNodeType:
3334 case RC_SAXGetAttributeCount:
3335 case RC_SAXGetAttributeName:
3336 case RC_SAXGetAttributeValue:
3337 case RC_SAXGetChildCount:
3338 case RC_SAXGetElementName:
3339 case RC_SAXGetChars:
3340
3341 case RC_SAXSeekElement:
3342 case RC_SAXHasElement:
3343 case RC_SAXGetElementPath:
3344
3345 case RC_SAXRelease:
3346 {
3347 HandleSAXParser();
3348 }
3349 break;
3350 case RC_RecordMacro:
3351 {
3352 if ( ! (nParams & PARAM_BOOL_1) )
3353 bBool1 = sal_True;
3354
3355 MacroRecorder::GetMacroRecorder()->SetActionRecord( bBool1 );
3356 }
3357 break;
3358 case RC_GetDocumentCount :
3359 {
3360 pRet->GenReturn ( RET_Value, nMethodId, (comm_USHORT)GetDocWinCount() );
3361 }
3362 break;
3363 case RC_ActivateDocument :
3364 {
3365 if( nParams & PARAM_USHORT_1 )
3366 {
3367 if ( ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, GetDocWinCount() ) )
3368 {
3369 Window* pWin = GetDocWin( nNr1-1 );
3370 if ( pWin )
3371 {
3372 pWin->ToTop();
3373 pWin->GrabFocus();
3374 }
3375 }
3376 }
3377 else
3378 ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
3379 }
3380 break;
3381 case RC_GetSystemLanguage :
3382 {
3383 pRet->GenReturn ( RET_Value, nMethodId, (comm_USHORT)Application::GetSettings().GetLanguage() );
3384 }
3385 break;
3386 case RC_CatchGPF :
3387 {
3388 if( (nParams & PARAM_BOOL_1) )
3389 bCatchGPF = bBool1;
3390 else
3391 bCatchGPF = sal_True;
3392 }
3393 break;
3394 case RC_IsProduct :
3395 {
3396 sal_Bool bIsProduct;
3397 #ifdef DBG_UTIL
3398 bIsProduct = sal_False;
3399 #else
3400 bIsProduct = sal_True;
3401 #endif
3402 pRet->GenReturn ( RET_Value, nMethodId, (sal_Bool)bIsProduct );
3403 }
3404 break;
3405 case RC_UsePostEvents :
3406 {
3407 if( (nParams & PARAM_BOOL_1) )
3408 bUsePostEvents = bBool1;
3409 else
3410 bUsePostEvents = sal_True;
3411 }
3412 break;
3413 default:
3414 ReportError( GEN_RES_STR1( S_UNKNOWN_COMMAND, RcString( nMethodId ) ) );
3415 }
3416 SendProfile( RcString(nMethodId) );
3417 delete this;
3418 return sal_True;
3419 }
3420
3421
UnpackStorage(SotStorageRef xStorage,DirEntry & aBaseDir)3422 sal_Bool StatementCommand::UnpackStorage( SotStorageRef xStorage, DirEntry &aBaseDir )
3423 {
3424 SvStorageInfoList aList;
3425 xStorage->FillInfoList( &aList );
3426
3427 for( sal_uInt16 i = 0; i < aList.Count(); i++ )
3428 {
3429 SvStorageInfo& rInfo = aList.GetObject( i );
3430 String aName = rInfo.GetName();
3431 DirEntry aPath ( aBaseDir );
3432 aPath += DirEntry( aName );
3433 sal_Bool bIsStorage = xStorage->IsStorage( aName );
3434 if ( bIsStorage )
3435 {
3436 SotStorageRef xSubStorage = xStorage->OpenSotStorage( aName, STREAM_STD_READ );
3437 if ( xSubStorage->GetError() )
3438 {
3439 ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aName, aPath.GetFull()) );
3440 return sal_False;
3441 }
3442 UnpackStorage( xSubStorage, aPath );
3443 }
3444 else
3445 {
3446 if ( !aPath.MakeDir( sal_True ) )
3447 {
3448 ReportError( GEN_RES_STR1(S_CANNOT_CREATE_DIRECTORY, aPath.GetFull()) );
3449 return sal_False;
3450 }
3451 SotStorageStreamRef xStream = xStorage->OpenSotStream( aName, STREAM_STD_READ );
3452 SvFileStream aDestination( aPath.GetFull(), STREAM_STD_READWRITE | STREAM_TRUNC );
3453 (*xStream) >> aDestination;
3454 if ( aDestination.GetError() != ERRCODE_NONE )
3455 {
3456 ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aName, aPath.GetFull()) );
3457 return sal_False;
3458 }
3459 aDestination.Close();
3460 }
3461 }
3462 return sal_True;
3463 }
3464
3465
3466 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3467
StatementControl(SCmdStream * pCmdIn,sal_uInt16 nControlIdType)3468 StatementControl::StatementControl( SCmdStream *pCmdIn, sal_uInt16 nControlIdType )
3469 : StatementList()
3470 , nNr1( 0 )
3471 , nNr2( 0 )
3472 , nNr3( 0 )
3473 , nNr4( 0 )
3474 , nLNr1( 0 )
3475 , aString1()
3476 , aString2()
3477 , bBool1(sal_False)
3478 , bBool2(sal_False)
3479 {
3480 QueStatement( NULL );
3481 //HELPID BACKWARD (SIControl is no longer needed)
3482 if ( nControlIdType == SIControl )
3483 {
3484 comm_ULONG nId;
3485 pCmdIn->Read( nId );
3486 aUId = rtl::OString( nId );
3487 if ( nId == 0 )
3488 aUId = UID_ACTIVE;
3489 else
3490 ReportError( aUId, GEN_RES_STR1c( S_INTERNAL_ERROR, "using numeric HelpID from old Testtool" ) );
3491 }
3492 else if ( nControlIdType == SIStringControl )
3493 {
3494 String aId;
3495 pCmdIn->Read( aId );
3496 aUId = Str2Id( aId );
3497 }
3498 else
3499 {
3500 DBG_ERROR( "Wrong ControlType" );
3501 }
3502
3503 pCmdIn->Read( nMethodId );
3504 pCmdIn->Read( nParams );
3505
3506 if( nParams & PARAM_USHORT_1 ) pCmdIn->Read( nNr1 );
3507 if( nParams & PARAM_USHORT_2 ) pCmdIn->Read( nNr2 );
3508 if( nParams & PARAM_USHORT_3 ) pCmdIn->Read( nNr3 );
3509 if( nParams & PARAM_USHORT_4 ) pCmdIn->Read( nNr4 );
3510 if( nParams & PARAM_ULONG_1 ) pCmdIn->Read( nLNr1 );
3511 if( nParams & PARAM_STR_1 ) pCmdIn->Read( aString1 );
3512 if( nParams & PARAM_STR_2 ) pCmdIn->Read( aString2 );
3513 if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 );
3514 if( nParams & PARAM_BOOL_2 ) pCmdIn->Read( bBool2 );
3515
3516 #if OSL_DEBUG_LEVEL > 1
3517 m_pDbgWin->AddText( "Reading Control: UId: " );
3518 m_pDbgWin->AddText( Id2Str( aUId ) );
3519 m_pDbgWin->AddText( " Methode: " );
3520 m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
3521 m_pDbgWin->AddText( " Params:" );
3522 if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr1 ) );}
3523 if( nParams & PARAM_USHORT_2 ) {m_pDbgWin->AddText( " n2:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr2 ) );}
3524 if( nParams & PARAM_USHORT_3 ) {m_pDbgWin->AddText( " n3:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr3 ) );}
3525 if( nParams & PARAM_USHORT_4 ) {m_pDbgWin->AddText( " n4:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr4 ) );}
3526 if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " nl1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );}
3527 if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );}
3528 if( nParams & PARAM_STR_2 ) {m_pDbgWin->AddText( " s2:" );m_pDbgWin->AddText( aString2 );}
3529 /* if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 );
3530 if( nParams & PARAM_BOOL_2 ) pCmdIn->Read( bBool2 );*/
3531 m_pDbgWin->AddText( "\n" );
3532 #endif
3533 }
3534
IsDialog(Window * pWin)3535 sal_Bool IsDialog(Window *pWin)
3536 { // Alles was von SystemWindow abgeleitet ist
3537 if ( !pWin )
3538 return sal_False;
3539
3540 switch (pWin->GetType())
3541 {
3542 case WINDOW_FLOATINGWINDOW:
3543 case WINDOW_DOCKINGWINDOW:
3544 case WINDOW_MODELESSDIALOG:
3545 case WINDOW_DIALOG:
3546 case WINDOW_MODALDIALOG:
3547 case WINDOW_WORKWINDOW:
3548 case WINDOW_TABDIALOG:
3549
3550 case WINDOW_MESSBOX:
3551 case WINDOW_INFOBOX:
3552 case WINDOW_WARNINGBOX:
3553 case WINDOW_ERRORBOX:
3554 case WINDOW_QUERYBOX:
3555 case WINDOW_BUTTONDIALOG:
3556 case WINDOW_FILEDIALOG:
3557 case WINDOW_PRINTDIALOG:
3558 case WINDOW_PRINTERSETUPDIALOG:
3559
3560 // ab hier nicht ansprechbar (da nicht implementiert)
3561 case WINDOW_SYSWINDOW:
3562 case WINDOW_SYSTEMDIALOG:
3563 case WINDOW_COLORDIALOG:
3564 case WINDOW_FONTDIALOG:
3565 case WINDOW_PATHDIALOG:
3566
3567
3568 return sal_True;
3569 // break;
3570 default:
3571 return sal_False;
3572 // break;
3573 }
3574 }
3575
3576
IsAccessable(Window * pWin)3577 sal_Bool IsAccessable(Window *pWin)
3578 {
3579 if ( pWin == NULL )
3580 return sal_False;
3581
3582 return pWin->IsEnabled() && pWin->IsInputEnabled();
3583 }
3584
3585
3586
3587 // neue Hilfsfunktion
ImpGetButton(Window * pBase,WinBits nMask,WinBits nWinBits)3588 static Window*ImpGetButton( Window *pBase, WinBits nMask, WinBits nWinBits )
3589 {
3590 sal_uInt16 n = pBase->GetChildCount();
3591 for( sal_uInt16 i = 0 ; i < n; i++ ) {
3592 Window *pChild = pBase->GetChild(i);
3593 if( pChild->GetType() == WINDOW_OKBUTTON
3594 || pChild->GetType() == WINDOW_CANCELBUTTON
3595 || pChild->GetType() == WINDOW_HELPBUTTON
3596 || pChild->GetType() == WINDOW_PUSHBUTTON )
3597 if( !nMask || ( pChild->GetStyle() & nMask ) == nWinBits )
3598 return pChild;
3599 }
3600 return NULL;
3601 }
3602
ControlOK(Window * pControl,const sal_Char * cBezeichnung)3603 sal_Bool StatementControl::ControlOK( Window *pControl, const sal_Char* cBezeichnung )
3604 {
3605 if ( pControl && ( ( ( IsAccessable(pControl) || (nMethodId & M_WITH_RETURN) ) &&
3606 pControl->IsVisible() ) ||
3607 aUId.equals( UID_ACTIVE ) ) )
3608 return sal_True;
3609 else
3610 {
3611 UniString aBezeichnung( cBezeichnung, RTL_TEXTENCODING_ASCII_US );
3612 if ( aBezeichnung.Len() > 0 )
3613 {
3614 if (!pControl)
3615 ReportError( aUId, GEN_RES_STR1( S_WIN_NOT_FOUND, aBezeichnung ) );
3616 else if ( !pControl->IsVisible() )
3617 ReportError( aUId, GEN_RES_STR1( S_WIN_INVISIBLE, aBezeichnung ) );
3618 else
3619 ReportError( aUId, GEN_RES_STR1( S_WIN_DISABLED, aBezeichnung ) );
3620 }
3621 #if OSL_DEBUG_LEVEL > 1
3622 m_pDbgWin->AddText( aBezeichnung.AppendAscii(" NotFound or Disabled or Invisible") );
3623 #endif
3624
3625 return sal_False;
3626 }
3627 }
3628
3629
ValueOK(rtl::OString aId,String aBezeichnung,sal_uLong nValue,sal_uLong nMax)3630 sal_Bool StatementList::ValueOK( rtl::OString aId, String aBezeichnung, sal_uLong nValue, sal_uLong nMax )
3631 {
3632
3633 if ( nMax < nValue )
3634 {
3635 if ( aBezeichnung.Len() > 0 )
3636 ReportError( aId, GEN_RES_STR3( S_NUMBER_TOO_BIG, aBezeichnung, UniString::CreateFromInt32( nValue ), UniString::CreateFromInt32( nMax ) ) );
3637 return sal_False;
3638 }
3639 if ( nValue < 1 )
3640 {
3641 if ( aBezeichnung.Len() > 0 )
3642 ReportError( aId, GEN_RES_STR3c3( S_NUMBER_TOO_SMALL, aBezeichnung, UniString::CreateFromInt32( nValue ), "1" ) );
3643 return sal_False;
3644 }
3645 return sal_True;
3646 }
3647
GetCurrentMenues(PopupMenu * & pPopup,MenuBar * & pMenuBar,Menu * & pMenu)3648 sal_uInt16 StatementList::GetCurrentMenues( PopupMenu *&pPopup, MenuBar *&pMenuBar, Menu *&pMenu )
3649 {
3650 if ( WinPtrValid( pMenuWindow ) )
3651 pMenuBar = pMenuWindow->GetMenuBar();
3652
3653 if ( pMenuBar ) // use MenuBar as base
3654 pMenu = pMenuBar;
3655 else // use contextmenu as base
3656 {
3657 pMenu = PopupMenu::GetActivePopupMenu();
3658 pPopup = PopupMenu::GetActivePopupMenu();
3659 }
3660
3661 if ( !pMenu )
3662 return 1;
3663
3664 if ( aSubMenuId1 )
3665 {
3666 pPopup = pMenu->GetPopupMenu( aSubMenuId1 );
3667 pMenu = pPopup;
3668 }
3669
3670 if ( pMenu && aSubMenuId2 )
3671 {
3672 pPopup = pMenu->GetPopupMenu( aSubMenuId2 );
3673 pMenu = pPopup;
3674 }
3675
3676 if ( pMenu && aSubMenuId3 )
3677 {
3678 pPopup = pMenu->GetPopupMenu( aSubMenuId3 );
3679 pMenu = pPopup;
3680 }
3681
3682 return 0;
3683 }
3684
AnimateMouse(Window * pControl,TTHotSpots aWohin)3685 void StatementControl::AnimateMouse( Window *pControl, TTHotSpots aWohin )
3686 {
3687 Point aZiel;
3688
3689 switch (aWohin)
3690 {
3691 case MitteLinks:
3692 {
3693 long nHeight = pControl->GetSizePixel().Height();
3694 aZiel.X() += 5;
3695 aZiel.Y() += nHeight / 2;
3696 }
3697 break;
3698 case Mitte:
3699 {
3700 Size aSize = pControl->GetOutputSizePixel();
3701 aZiel.Move( aSize.Width() / 2, aSize.Height() / 2 );
3702 }
3703 break;
3704 case MitteOben:
3705 {
3706 long nWidth = pControl->GetSizePixel().Width();
3707 aZiel.X() += nWidth / 2;
3708 aZiel.Y() += 5;
3709 }
3710 break;
3711 }
3712 AnimateMouse( pControl, aZiel );
3713 }
3714
3715
AnimateMouse(Window * pControl,Point aWohin)3716 void StatementControl::AnimateMouse( Window *pControl, Point aWohin )
3717 {
3718 Point aAkt = pControl->GetPointerPosPixel();
3719 Point aZiel = aWohin;
3720
3721 long nSteps;
3722 Point aDiff = aAkt - aZiel;
3723
3724 if ( Abs(aDiff.X()) < Abs(aDiff.Y()) )
3725 nSteps = Abs(aDiff.Y()) / 5;
3726 else
3727 nSteps = Abs(aDiff.X()) / 5;
3728 if ( nSteps == 0 )
3729 return;
3730
3731 aDiff *= 1000;
3732 aDiff /= nSteps;
3733
3734 StatementList::bExecuting = sal_True; // Bah ist das ein ekliger Hack
3735 // Das verhindert, daß schon der nächste Befehl ausgeführt wird.
3736
3737 for ( ; nSteps ; nSteps-- )
3738 {
3739 if ( Abs((aAkt - pControl->GetPointerPosPixel()).X()) > 5 ||
3740 Abs((aAkt - pControl->GetPointerPosPixel()).Y()) > 5 )
3741 nSteps = 1;
3742 aAkt = aZiel + aDiff * nSteps / 1000;
3743 pControl->SetPointerPosPixel(aAkt);
3744 SafeReschedule();
3745 }
3746 pControl->SetPointerPosPixel(aZiel);
3747 StatementList::bExecuting = sal_False; // Bah ist das ein ekliger Hack
3748 }
3749
3750
MaybeDoTypeKeysDelay(Window * pTestWindow)3751 sal_Bool StatementControl::MaybeDoTypeKeysDelay( Window *pTestWindow )
3752 {
3753 if ( bDoTypeKeysDelay )
3754 {
3755 sal_uLong nTimeWait = nMinTypeKeysDelay;
3756 if ( nMaxTypeKeysDelay != nMinTypeKeysDelay )
3757 nTimeWait += Time::GetSystemTicks() % ( nMaxTypeKeysDelay - nMinTypeKeysDelay );
3758 Timer aTimer;
3759 aTimer.SetTimeout( nTimeWait );
3760 aTimer.Start();
3761 StatementList::bExecuting = sal_True; // Bah ist das ein ekliger Hack
3762 // Das verhindert, daß schon der nächste Befehl ausgeführt wird.
3763 while ( aTimer.IsActive() )
3764 {
3765 SafeReschedule( sal_True );
3766 }
3767 StatementList::bExecuting = sal_False; // Bah ist das ein ekliger Hack
3768 if ( !WinPtrValid(pTestWindow ) )
3769 {
3770 ReportError( aUId, GEN_RES_STR1( S_WINDOW_DISAPPEARED, MethodString( nMethodId ) ) );
3771 return sal_False;
3772 }
3773 }
3774 return sal_True;
3775 }
3776
HandleVisibleControls(Window * pControl)3777 sal_Bool StatementControl::HandleVisibleControls( Window *pControl )
3778 {
3779 if( pControl ) // Also auch bei Disabled nicht jedoch bei Invisible
3780 {
3781 switch( nMethodId )
3782 {
3783 case M_IsEnabled:
3784 pRet->GenReturn ( RET_Value, aUId, IsAccessable(pControl) );
3785 break;
3786 case M_IsVisible:
3787 pRet->GenReturn ( RET_Value, aUId, pControl->IsVisible() );
3788 break;
3789 case M_GetPosX:
3790 if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3791 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
3792 if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3793 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
3794 if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3795 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
3796 if ( (nParams & PARAM_BOOL_1) && bBool1 )
3797 pControl = pControl->GetWindow( WINDOW_OVERLAP );
3798
3799 if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_SPLITWINDOW )
3800 {
3801 Point aPos = pControl->GetPosPixel();
3802 aPos = pControl->GET_REAL_PARENT()->OutputToScreenPixel( aPos );
3803 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)aPos.X() );
3804 }
3805 else
3806 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetPosPixel().X() );
3807 break;
3808 case M_GetPosY:
3809 if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3810 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
3811 if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3812 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
3813 if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3814 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
3815 if ( (nParams & PARAM_BOOL_1) && bBool1 )
3816 pControl = pControl->GetWindow( WINDOW_OVERLAP );
3817
3818 if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_SPLITWINDOW )
3819 {
3820 Point aPos = pControl->GetPosPixel();
3821 aPos = pControl->GET_REAL_PARENT()->OutputToScreenPixel( aPos );
3822 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)aPos.Y() );
3823 }
3824 else
3825 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetPosPixel().Y() );
3826 break;
3827 case M_GetSizeX:
3828 if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3829 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
3830 if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3831 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
3832 if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3833 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
3834 if ( (nParams & PARAM_BOOL_1) && bBool1 )
3835 pControl = pControl->GetWindow( WINDOW_OVERLAP );
3836
3837 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetSizePixel().Width() );
3838 break;
3839 case M_GetSizeY:
3840 if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3841 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
3842 if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3843 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
3844 if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3845 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
3846 if ( (nParams & PARAM_BOOL_1) && bBool1 )
3847 pControl = pControl->GetWindow( WINDOW_OVERLAP );
3848
3849 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetSizePixel().Height() );
3850 break;
3851 case M_SnapShot:
3852 {
3853 if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
3854 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows
3855 if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG )
3856 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge
3857 if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW )
3858 pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border
3859 if ( (nParams & PARAM_BOOL_1) && bBool1 )
3860 pControl = pControl->GetWindow( WINDOW_OVERLAP );
3861
3862 Bitmap aBmp = pControl->SnapShot();
3863 if ( pControl->GetType() == WINDOW_WORKWINDOW )
3864 {
3865 Point aStart = pControl->GetPosPixel();
3866 if ( !(nParams & PARAM_USHORT_4) )
3867 {
3868 nParams |= PARAM_USHORT_1;
3869 nParams |= PARAM_USHORT_2;
3870 nParams |= PARAM_USHORT_3;
3871 nParams |= PARAM_USHORT_4;
3872 nNr1 = (sal_uInt16)-aStart.X();
3873 nNr2 = (sal_uInt16)-aStart.Y();
3874 nNr3 = (sal_uInt16)pControl->GetSizePixel().Width() + 2*(sal_uInt16)aStart.X();
3875 nNr4 = (sal_uInt16)pControl->GetSizePixel().Height() + 2*(sal_uInt16)aStart.Y();
3876 }
3877 nNr1 = std::max((sal_uInt16)-aStart.X(),nNr1);
3878 nNr2 = std::max((sal_uInt16)-aStart.Y(),nNr2);
3879 nNr3 = std::min((sal_uInt16)(pControl->GetSizePixel().Width() + 2*(sal_uInt16)aStart.X()),nNr3);
3880 nNr4 = std::min((sal_uInt16)(pControl->GetSizePixel().Height() + 2*(sal_uInt16)aStart.Y()),nNr4);
3881 }
3882 if( nParams & PARAM_USHORT_4 )
3883 { // Zuschneiden
3884 Point aPt(-nNr1,-nNr2);
3885 Size aSz(nNr3,nNr4);
3886 VirtualDevice aVDev( *pControl );
3887
3888 aVDev.SetOutputSizePixel( aSz );
3889 aVDev.DrawBitmap( aPt, aBmp );
3890 aBmp = aVDev.GetBitmap( Point(), aSz );
3891 }
3892
3893 SvFileStream fOut;
3894 fOut.Open(aString1,STREAM_STD_WRITE);
3895 WriteDIB(aBmp, fOut, true, true);
3896 if ( fOut.GetError() )
3897 ReportError( aUId, GEN_RES_STR1( S_ERROR_SAVING_IMAGE, UniString::CreateFromInt32( fOut.GetError() ) ) );
3898 fOut.Close();
3899 }
3900 break;
3901 case M_GetFixedTextCount:
3902 {
3903 pRet->GenReturn ( RET_Value, aUId, CountWinByRT( pControl, WINDOW_FIXEDTEXT, sal_True ) );
3904 }
3905 break;
3906 case M_GetFixedText:
3907 {
3908 if( ( nParams & PARAM_USHORT_1 ) == 0 )
3909 nNr1 = 1;
3910
3911 FixedText* pFixedText = (FixedText*)GetWinByRT( pControl, WINDOW_FIXEDTEXT, sal_True, nNr1-1 );
3912 if ( pFixedText )
3913 pRet->GenReturn ( RET_Value, aUId, pFixedText->GetText() );
3914 else
3915 ValueOK(aUId, MethodString( nMethodId ),nNr1,CountWinByRT( pControl, WINDOW_FIXEDTEXT, sal_True ) );
3916 }
3917 break;
3918 case M_HasFocus:
3919 {
3920 pRet->GenReturn ( RET_Value, aUId, pControl->HasFocus() );
3921 break;
3922 }
3923 case M_GetScreenRectangle:
3924 {
3925 Rectangle aRect = bBool1 ? pControl->GetClientWindowExtentsRelative(NULL) : pControl->GetWindowExtentsRelative( NULL );
3926 pRet->GenReturn ( RET_Value, aUId,
3927 UniString::CreateFromInt32(aRect.Left()).
3928 AppendAscii(",").Append(UniString::CreateFromInt32(aRect.Top())).
3929 AppendAscii(",").Append(UniString::CreateFromInt32(aRect.GetWidth())).
3930 AppendAscii(",").Append(UniString::CreateFromInt32(aRect.GetHeight()))
3931 );
3932 }
3933 break;
3934 case M_GetHelpText:
3935 {
3936 pRet->GenReturn ( RET_Value, aUId, pControl->GetHelpText());
3937 }
3938 break;
3939 case M_GetQuickHelpText:
3940 {
3941 pRet->GenReturn ( RET_Value, aUId,pControl->GetQuickHelpText());
3942 }
3943 break;
3944 default:
3945 return sal_False;
3946 }
3947 SendProfile( UIdString( aUId ).Append('.').Append( MethodString( nMethodId ) ) );
3948 return sal_True;
3949 }
3950 return sal_False;
3951 }
3952
HandleCommonMethods(Window * pControl)3953 sal_Bool StatementControl::HandleCommonMethods( Window *pControl )
3954 {
3955 switch( nMethodId ) // Diese können an jedem Window ausgeführt werden
3956 {
3957 case M_Exists: // Oben schon behandelt. Unterdrückt hier nur Fehler
3958 case M_NotExists:
3959 case M_IsEnabled:
3960 case M_IsVisible:
3961 case M_SnapShot:
3962 break;
3963 case M_Caption :
3964 {
3965 if ( pControl->GetText().Len() == 0 && IsDocFrame( pControl->GetWindow( WINDOW_FRAME ) ) )
3966 pRet->GenReturn ( RET_Value, aUId, pControl->GetWindow( WINDOW_FRAME )->GetText());
3967 else
3968 pRet->GenReturn ( RET_Value, aUId, pControl->GetText());
3969 }
3970 break;
3971 case M_GetRT:
3972 {
3973 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pControl->GetType() );
3974 }
3975 break;
3976 case M_TypeKeys:
3977 {
3978 if( !(nParams & PARAM_USHORT_1) ) // Anzahl Wiederholungen
3979 nNr1 = 1;
3980 if( !(nParams & PARAM_BOOL_1) ) // Follow Focus
3981 bBool1 = sal_False; // so bleibt das bisherige Verhalten
3982
3983 if ( !bBool1 ) // Altes Verhalten
3984 pControl->GrabFocus();
3985 else // If focus is not inside given control we grab it once.
3986 {
3987 Window *pFocus = GetpApp()->GetFocusWindow();
3988 if ( !pFocus || !pControl->IsWindowOrChild( pFocus, sal_True ) )
3989 pControl->GrabFocus();
3990 }
3991
3992
3993 // maybe this can get removed since we are using GetPreferredKeyInputWindow()
3994 if ( pControl->GetType() == WINDOW_COMBOBOX )
3995 { // Bei COMBOBOX an das Edit direkt liefern
3996 Window *pTemp = NULL;
3997 for ( sal_uInt16 i = 0 ; i < pControl->GetChildCount() && !pTemp ; i++ )
3998 if ( pControl->GetChild( i )->GetType() == WINDOW_EDIT )
3999 pTemp = pControl->GetChild( i );
4000 if ( pTemp )
4001 pControl = pTemp;
4002 }
4003
4004 Window *pDeliverHere = pControl;
4005 for (int j = 0; j < nNr1; j++)
4006 for (xub_StrLen i = 0; i < aString1.Len(); i++)
4007 {
4008 if ( StatementList::bUsePostEvents )
4009 { // grab focus every time
4010 Window *pFocus = GetpApp()->GetFocusWindow();
4011 if ( !pFocus || !pControl->IsWindowOrChild( pFocus, sal_True ) )
4012 pControl->GrabFocus();
4013 }
4014 if ( bBool1 ) // Jedesmal das FocusWindow finden
4015 {
4016 Window *pFocus = GetpApp()->GetFocusWindow();
4017 if ( pFocus && pControl->IsWindowOrChild( pFocus, sal_True ) )
4018 pDeliverHere = pFocus;
4019 else // sonst Fallback auf das Basisfenster
4020 pDeliverHere = pControl;
4021 }
4022 pDeliverHere = pDeliverHere->GetPreferredKeyInputWindow();
4023 KeyEvent aEvent;
4024 if ( ((sal_uInt16)aString1.GetChar(i)) <= 7 )
4025 {
4026 sal_uInt16 nVal = 0;
4027 switch (aString1.GetChar(i))
4028 {
4029 case 1: nVal = aString1.GetChar(i+1) + (aString1.GetChar(i+2) << 8);
4030 i += 2;
4031 break;
4032 case 3: nVal = (aString1.GetChar(i+1) << 8);
4033 i++;
4034 break;
4035 case 5: nVal = aString1.GetChar(i+1);
4036 i++;
4037 break;
4038 case 7: nVal = 0;
4039 break;
4040 }
4041 // #105672#
4042 // find out the keycode
4043 sal_uInt16 nKeygroup = nVal & KEYGROUP_TYPE;
4044 sal_uInt16 nKeyCode = nVal & KEY_CODE;
4045 sal_Unicode aCh;
4046 switch (nKeygroup)
4047 {
4048 case KEYGROUP_NUM:
4049 aCh = nKeyCode - KEY_0 + '0';
4050 break;
4051 case KEYGROUP_ALPHA:
4052 aCh = nKeyCode - KEY_A;
4053 if ( nVal & KEY_MOD1 )
4054 {}
4055 else if ( nVal & KEY_SHIFT )
4056 aCh += 'A';
4057 else
4058 aCh += 'a';
4059 break;
4060 case KEYGROUP_MISC:
4061 { // CR ESC TAB BACK
4062 ByteString aPrintableMisc("\x0d\x1b\x09\x08 **+-*/.,<>=",16);
4063 if ( nKeyCode-KEY_RETURN < aPrintableMisc.Len()
4064 && nKeyCode != KEY_INSERT && nKeyCode != KEY_DELETE )
4065 aCh = aPrintableMisc.GetChar( nKeyCode-KEY_RETURN );
4066 else
4067 aCh = 0;
4068 }
4069 break;
4070 case KEYGROUP_CURSOR:
4071 case KEYGROUP_FKEYS:
4072 default:
4073 aCh = 0;
4074 }
4075 aEvent = KeyEvent(aCh,KeyCode(nVal & 0xFFF,nVal & 0xF000));
4076 }
4077 else
4078 {
4079 // CR ESC TAB BACK
4080 String aPrintableMisc = CUniString("\x0d\x1b\x09\x08 xx+-*/.,<>=");
4081 sal_Unicode aCh = aString1.GetChar(i);
4082 if ( aCh >= 'a' && aCh <= 'z' )
4083 aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_ALPHA + aCh-'a', 0));
4084 else if ( aCh >= 'A' && aCh <= 'Z' )
4085 aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_ALPHA + aCh-'a', KEY_SHIFT));
4086 else if ( aCh >= '0' && aCh <= '9' )
4087 aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_NUM + aCh-'0', 0));
4088 else if ( aPrintableMisc.Search(aCh) != STRING_NOTFOUND )
4089 aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_MISC + (sal_uInt16)aPrintableMisc.Search(aCh), 0));
4090 else // Sollte eigentlich nicht auftreten
4091 aEvent = KeyEvent(aCh, KeyCode());
4092 }
4093 ImplKeyInput( pDeliverHere, aEvent );
4094 if ( !MaybeDoTypeKeysDelay( pControl ) )
4095 break;
4096 else
4097 SafeReschedule();SafeReschedule();SafeReschedule();
4098 }
4099 }
4100 break;
4101
4102 #define CalcMouseButton\
4103 sal_uInt16 nButton = MOUSE_LEFT;\
4104 if ( (nParams & PARAM_USHORT_3) )\
4105 {\
4106 switch ( nNr3 )\
4107 {\
4108 case 1: nButton = MOUSE_LEFT; break;\
4109 case 2: nButton = MOUSE_MIDDLE; break;\
4110 case 3: nButton = MOUSE_RIGHT; break;\
4111 }\
4112 }\
4113
4114 case M_MouseDown:
4115 {
4116 CalcMouseButton;
4117 Size aS = pControl->GetOutputSizePixel();
4118 Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
4119 Window *pActualWin = pControl->FindWindow( aPos );
4120 // AnimateMouse( pControl, aPos );
4121
4122 if ( pActualWin )
4123 aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4124 // aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4125 else
4126 pActualWin = pControl;
4127
4128 AnimateMouse( pActualWin, aPos );
4129 pActualWin->GrabFocus();
4130 MouseEvent aMEvnt(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton);
4131 ImplMouseButtonDown( pActualWin, aMEvnt );
4132 }
4133 break;
4134 case M_MouseUp:
4135 {
4136 CalcMouseButton;
4137 Size aS = pControl->GetOutputSizePixel();
4138 Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
4139 Window *pActualWin = pControl->FindWindow( aPos );
4140
4141 if ( pActualWin )
4142 aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4143 // aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4144 else
4145 pActualWin = pControl;
4146
4147 AnimateMouse( pActualWin, aPos );
4148 // pActualWin->GrabFocus();
4149 MouseEvent aMEvt( aPos, 1, MOUSE_SIMPLECLICK|MOUSE_SELECT, nButton );
4150 ImplMouseButtonUp( pActualWin, aMEvt );
4151 }
4152 break;
4153 case M_MouseMove:
4154 {
4155 CalcMouseButton;
4156 Size aS = pControl->GetOutputSizePixel();
4157 Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
4158 Window *pActualWin = pControl->FindWindow( aPos );
4159
4160 if ( pActualWin )
4161 {
4162 aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4163 // aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4164 }
4165 else
4166 pActualWin = pControl;
4167
4168 AnimateMouse( pActualWin, aPos );
4169 // pActualWin->GrabFocus();
4170 MouseEvent aMEvt( aPos, 0, MOUSE_SIMPLEMOVE|MOUSE_DRAGMOVE, nButton );
4171 ImplMouseMove( pActualWin, aMEvt );
4172 }
4173 break;
4174 case M_MouseDoubleClick:
4175 {
4176 CalcMouseButton;
4177 Size aS = pControl->GetOutputSizePixel();
4178 Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100);
4179 Window *pActualWin = pControl->FindWindow( aPos );
4180
4181 if ( pActualWin )
4182 {
4183 aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4184 // aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4185 }
4186 else
4187 pActualWin = pControl;
4188
4189 AnimateMouse( pActualWin, aPos );
4190 pActualWin->GrabFocus();
4191 MouseEvent aMEvnt;
4192 aMEvnt = MouseEvent(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton);
4193 ImplMouseButtonDown( pActualWin, aMEvnt );
4194 ImplMouseButtonUp ( pActualWin, aMEvnt );
4195 aMEvnt = MouseEvent(aPos,2,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton);
4196 ImplMouseButtonDown( pActualWin, aMEvnt );
4197 ImplMouseButtonUp ( pActualWin, aMEvnt );
4198 }
4199 break;
4200 case M_DisplayPercent:
4201 {
4202 ModelessDialog *pDlg = new ModelessDialog(NULL);
4203 pDlg->SetOutputSizePixel(Size(100,30));
4204
4205 Edit *pMyEd = new Edit(pDlg,WB_CENTER | WB_BORDER );
4206 pMyEd->SetSizePixel(Size(100,30));
4207 pDlg->SetText(UniString("Schließen", RTL_TEXTENCODING_ISO_8859_1));
4208 pDlg->Show();
4209 pMyEd->Show();
4210 sal_uLong nTime = Time().GetTime();
4211
4212 while (pDlg->IsVisible())
4213 {
4214 pDlg->ToTop();
4215 for (int i = 1 ; i<10 ; i++)
4216 SafeReschedule();
4217 Point Pos = pControl->GetPointerPosPixel();
4218 Size Siz=pControl->GetOutputSizePixel();
4219 if ( Time().GetTime() - nTime > 10 )
4220 {
4221 nTime = Time().GetTime();
4222 pMyEd->SetText(UniString::CreateFromInt32(Pos.X()*100/Siz.Width()).AppendAscii("%x").Append( UniString::CreateFromInt32(Pos.Y()*100/Siz.Height()) ).Append('%'));
4223 }
4224 }
4225
4226 delete pMyEd;
4227 delete pDlg;
4228 }
4229 break;
4230 case M_OpenContextMenu:
4231 {
4232 aSubMenuId1 = 0;
4233 aSubMenuId2 = 0;
4234 aSubMenuId3 = 0;
4235 pMenuWindow = NULL;
4236 Point aPos;
4237 ToolBox* pTB = (ToolBox*)pControl;
4238 if ( (pControl->GetType() == WINDOW_TOOLBOX) && pTB->IsMenuEnabled() )
4239 {
4240 pTB->ExecuteCustomMenu();
4241 /* Rectangle aRect = pTB->GetMenubuttonRect();
4242 AnimateMouse( pControl, aRect.Center() );
4243 MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
4244 ImplMouseButtonDown( pTB, aMEvnt );*/
4245 }
4246 else
4247 {
4248 sal_Bool bAtMousePos = ( nParams & PARAM_BOOL_1 ) && bBool1;
4249 if ( bAtMousePos )
4250 {
4251 aPos = pControl->GetPointerPosPixel();
4252 Window *pActualWin = pControl->FindWindow( aPos );
4253
4254 if ( pActualWin )
4255 {
4256 aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) );
4257 // aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) );
4258 pControl = pActualWin;
4259 }
4260 }
4261 CommandEvent aEvent( aPos, COMMAND_CONTEXTMENU, bAtMousePos );
4262 ImplCommand( pControl, aEvent );
4263 }
4264 }
4265 break;
4266 case M_UseMenu:
4267 {
4268 aSubMenuId1 = 0;
4269 aSubMenuId2 = 0;
4270 aSubMenuId3 = 0;
4271 pMenuWindow = NULL;
4272
4273 while ( pControl && !( ( pControl->GetType() == WINDOW_SYSWINDOW || pControl->GetType() == WINDOW_WORKWINDOW ) && ControlOK( pControl, "" ) ) )
4274 pControl = pControl->GET_REAL_PARENT();
4275
4276 if ( pControl && ((SystemWindow*)pControl)->GetMenuBar() )
4277 pMenuWindow = ((SystemWindow*)pControl);
4278 else
4279 ReportError( GEN_RES_STR1( S_NO_MENU, MethodString( nMethodId ) ) );
4280 }
4281 break;
4282 case M_FadeIn:
4283 case M_FadeOut:
4284 case M_Pin:
4285 case M_IsFadeIn:
4286 case M_IsPin:
4287 {
4288 WindowAlign aWindowAlign = WINDOWALIGN_LEFT;
4289 if ( (nParams & PARAM_USHORT_1) )
4290 {
4291 switch ( nNr1 )
4292 {
4293 case CONST_ALIGN_LEFT:
4294 aWindowAlign = WINDOWALIGN_LEFT;
4295 break;
4296 case CONST_ALIGN_TOP:
4297 aWindowAlign = WINDOWALIGN_TOP;
4298 break;
4299 case CONST_ALIGN_RIGHT:
4300 aWindowAlign = WINDOWALIGN_RIGHT;
4301 break;
4302 case CONST_ALIGN_BOTTOM:
4303 aWindowAlign = WINDOWALIGN_BOTTOM;
4304 break;
4305 default:
4306 ReportError( aUId, GEN_RES_STR1( S_INVALID_POSITION, MethodString( nMethodId ) ) );
4307 }
4308 }
4309
4310 Window* pTemp = NULL;
4311 while ( !pTemp && pControl )
4312 {
4313 pTemp = GetFadeSplitWin( pControl, aWindowAlign );
4314 pControl = pControl->GET_REAL_PARENT();
4315 }
4316
4317 if ( !pTemp )
4318 {
4319 ReportError( aUId, GEN_RES_STR1( S_SPLITWIN_NOT_FOUND, MethodString( nMethodId ) ) );
4320 break;
4321 }
4322
4323 pControl = pTemp; // So daß wir unten ohne Fehler durchkommen
4324 SplitWindow *pSW = (SplitWindow*) pTemp;
4325
4326 // Rectangle GetAutoHideRect() const;
4327 // Rectangle GetFadeInRect() const;
4328 // Rectangle GetFadeOutRect() const;
4329
4330 switch( nMethodId )
4331 {
4332 case M_FadeIn:
4333 if ( pSW->IsFadeInButtonVisible() )
4334 pSW->FadeIn();
4335 break;
4336 case M_FadeOut:
4337 if ( pSW->IsFadeOutButtonVisible() )
4338 pSW->FadeOut();
4339 break;
4340 case M_Pin:
4341 if ( ( pSW->GetAutoHideState() && bBool1 )
4342 || ( !pSW->GetAutoHideState() && !bBool1 ) )
4343 {
4344 MouseEvent aMEvnt;
4345 Point aPt( pSW->GetAutoHideRect().Center() );
4346 aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
4347 ImplMouseButtonDown( pControl, aMEvnt, FORCE_DIRECT_CALL );
4348 ImplMouseButtonUp ( pControl, aMEvnt, FORCE_DIRECT_CALL );
4349 }
4350 // pSW->AutoHide();
4351 break;
4352 case M_IsFadeIn:
4353 pRet->GenReturn ( RET_Value, aUId, pSW->IsFadeOutButtonVisible() );
4354 break;
4355 case M_IsPin:
4356 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)!pSW->GetAutoHideState() );
4357 break;
4358 default:
4359 ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
4360 }
4361 SendProfile( UIdString( aUId ).Append('.').Append( MethodString( nMethodId ) ) );
4362 }
4363 break;
4364 case M_StatusGetText:
4365 case M_StatusIsProgress:
4366 case M_StatusGetItemCount:
4367 case M_StatusGetItemId:
4368 {
4369 StatusBar *pStatus = NULL;
4370 while ( !pStatus && pControl )
4371 {
4372 pStatus = (StatusBar*)GetWinByRT( pControl, WINDOW_STATUSBAR, sal_True );
4373 pControl = pControl->GET_REAL_PARENT();
4374 }
4375
4376 if ( !pStatus )
4377 {
4378 ReportError( aUId, GEN_RES_STR1( S_NO_STATUSBAR, MethodString( nMethodId ) ) );
4379 break;
4380 }
4381
4382 switch ( nMethodId )
4383 {
4384 case M_StatusGetText:
4385 {
4386 if ( (nParams & PARAM_USHORT_1) )
4387 {
4388 if ( pStatus->AreItemsVisible() )
4389 pRet->GenReturn ( RET_Value, aUId, String(pStatus->GetItemText(nNr1)));
4390 else
4391 ReportError( aUId, GEN_RES_STR1( S_ITEMS_INVISIBLE, MethodString( nMethodId ) ) );
4392 }
4393 else
4394 {
4395 if ( pStatus->AreItemsVisible() )
4396 {
4397 if ( pStatus->GetItemCount() == 1 )
4398 {
4399 pRet->GenReturn ( RET_Value, aUId, pStatus->GetItemText( pStatus->GetItemId(0) ));
4400 }
4401 else
4402 {
4403 pRet->GenReturn ( RET_Value, aUId, String() );
4404 }
4405 }
4406 else
4407 pRet->GenReturn ( RET_Value, aUId, (String)pStatus->GetText() );
4408 }
4409 }
4410 break;
4411 case M_StatusIsProgress:
4412 {
4413 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)pStatus->IsProgressMode() );
4414 }
4415 break;
4416 case M_StatusGetItemCount:
4417 if ( pStatus->AreItemsVisible() )
4418 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pStatus->GetItemCount()));
4419 else
4420 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
4421 break;
4422 case M_StatusGetItemId:
4423 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pStatus->GetItemCount()) )
4424 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pStatus->GetItemId(nNr1-1)));
4425 break;
4426 }
4427 }
4428 break;
4429 case M_HasScrollBar:
4430 case M_IsScrollBarEnabled:
4431 {
4432 if ( (nParams | PARAM_USHORT_1) != PARAM_USHORT_1 ) // so there are other params
4433 {
4434 ReportError( aUId, GEN_RES_STR0( S_INVALID_PARAMETERS ) );
4435 break;
4436 }
4437
4438 if( !(nParams & PARAM_USHORT_1) )
4439 nNr1 = CONST_ALIGN_RIGHT; // default is right Scrollbar (vertical)
4440
4441 if ( (nNr1 != CONST_ALIGN_RIGHT) && (nNr1 != CONST_ALIGN_BOTTOM) )
4442 {
4443 ReportError( aUId, GEN_RES_STR1( S_INVALID_POSITION, MethodString( nMethodId ) ) );
4444 break;
4445 }
4446
4447 ScrollBar *pScroll = NULL;
4448
4449 sal_uInt16 nSteps = 2;
4450 while ( !pScroll && pControl && nSteps-- )
4451 {
4452 pScroll = GetScrollBar( pControl, nNr1, sal_True );
4453 pControl = pControl->GET_REAL_PARENT();
4454 }
4455
4456 switch ( nMethodId )
4457 {
4458 case M_HasScrollBar:
4459 {
4460 if ( pScroll )
4461 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)sal_True );
4462 else
4463 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)sal_False );
4464 }
4465 break;
4466 case M_IsScrollBarEnabled:
4467 {
4468 if ( !pScroll )
4469 {
4470 ReportError( aUId, GEN_RES_STR1( S_NO_SCROLLBAR, MethodString( nMethodId ) ) );
4471 break;
4472 }
4473 pRet->GenReturn ( RET_Value, aUId, pScroll->IsEnabled() );
4474 }
4475 break;
4476 }
4477 }
4478 break;
4479 default:
4480 return sal_False;
4481 }
4482 return sal_True;
4483 }
4484
4485
Execute()4486 sal_Bool StatementControl::Execute()
4487 {
4488 Window *pControl;
4489 sal_Bool bStatementDone = sal_True;
4490
4491
4492 if ( IsError )
4493 {
4494 #if OSL_DEBUG_LEVEL > 1
4495 m_pDbgWin->AddText( "Skipping Window: " );
4496 m_pDbgWin->AddText( Id2Str( aUId ) );
4497 m_pDbgWin->AddText( " Method: " );
4498 m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
4499 m_pDbgWin->AddText( "\n" );
4500 #endif
4501 Advance();
4502 delete this;
4503 return sal_True;
4504 }
4505
4506 InitProfile();
4507 #if OSL_DEBUG_LEVEL > 1
4508 m_pDbgWin->AddText( "Executing Window: " );
4509 m_pDbgWin->AddText( Id2Str( aUId ) );
4510 m_pDbgWin->AddText( " Method: " );
4511 m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) );
4512 m_pDbgWin->AddText( "\n" );
4513 #endif
4514
4515
4516 if ( aUId.equals( UID_ACTIVE ) )
4517 pControl = GetAnyActive();
4518 else
4519 {
4520 sal_Bool bSearchButtonOnToolbox = (nParams == PARAM_NONE) && ((M_Click == nMethodId) || (M_TearOff == nMethodId) || (M_IsEnabled == nMethodId) || (M_OpenMenu == nMethodId));
4521 bSearchButtonOnToolbox |= (nParams == PARAM_USHORT_1) && (M_GetState == nMethodId);
4522 if ( nMethodId == M_TypeKeys || nMethodId == M_MouseDown
4523 || nMethodId == M_MouseUp || nMethodId == M_MouseMove
4524 || nMethodId == M_SnapShot )
4525 {
4526 pControl = NULL;
4527 if ( /*(nMethodId == M_SnapShot || nMethodId == M_TypeKeys) &&*/ !pControl )
4528 pControl = SearchTree( aUId ,bSearchButtonOnToolbox );
4529 }
4530 else
4531 pControl = SearchTree( aUId ,bSearchButtonOnToolbox );
4532 }
4533
4534
4535 if ( pControl && pControl->GetType() == WINDOW_TOOLBOX )
4536 {
4537 if ( !aUId.equals( pControl->GetUniqueOrHelpId() ) )
4538 { // Also wenn wir irgendwas auf einer Toolbox gefunden haben
4539 switch ( nMethodId )
4540 {
4541 case M_Click:
4542 case M_TearOff:
4543 case M_OpenMenu:
4544 case M_GetState:
4545 break;
4546 case M_IsEnabled:
4547 nMethodId = _M_IsEnabled; // Umlabeln, da die Behandlung essentiell anders ist!
4548 break;
4549 default:
4550 pControl = NULL;
4551 }
4552 }
4553 }
4554
4555
4556 switch ( nMethodId )
4557 {
4558 case M_Exists:
4559 case M_NotExists:
4560 Time aT;
4561 sal_uInt16 aSeconds = aT.GetMin()*60+aT.GetSec();
4562 if ( !bBool2 ) // wurde im Konstruktor auf sal_False gesetzt
4563 {
4564 bBool2 = sal_True;
4565 nNr2 = aSeconds;
4566 if( !(nParams & PARAM_USHORT_1) )
4567 nNr1 = 0; // defaultmäßig sofort zurück
4568 }
4569 if ( aSeconds < nNr2 ) // Falls die Stunde umgesprungen ist
4570 aSeconds += 60*60;
4571
4572 if ( /* !IsAccessable(pControl)#87019# */ !pControl || !pControl->IsVisible() )
4573 pControl = NULL;
4574 if ( ((nMethodId == M_Exists) && pControl) ||
4575 ((nMethodId == M_NotExists) && !pControl) )
4576 { // Wenn Bedingung erfüllt
4577 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)sal_True );
4578 }
4579 else
4580 if ( aSeconds <= nNr2 + nNr1 ) // Zeit ist noch nicht abgelaufen
4581 return sal_False;
4582 else
4583 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)sal_False );
4584
4585 Advance();
4586 delete this;
4587 return sal_True;
4588 // break;
4589 }
4590
4591
4592 short nRT = 0;
4593
4594 if( pControl ) // Das Fenster existiert irgendwo, kann aber auch hidden sein!
4595 {
4596 nRT = ImpGetRType( pControl );
4597 #if OSL_DEBUG_LEVEL > 1
4598 m_pDbgWin->AddText( "Type is: " );
4599 m_pDbgWin->AddText( String::CreateFromInt32( nRT ) );
4600 m_pDbgWin->AddText( "\n" );
4601 #endif
4602 }
4603
4604 if ( nRT == C_Window && // Search for WorkWindow to satisfy these commands
4605 ( nMethodId == M_Close
4606 // || nMethodId == M_Size
4607 // || nMethodId == M_Move
4608 || nMethodId == M_IsMax
4609 || nMethodId == M_IsMin
4610 || nMethodId == M_IsRestore
4611 || nMethodId == M_Minimize
4612 || nMethodId == M_Maximize
4613 || nMethodId == M_Restore ) )
4614 {
4615 Window* pNewControl = pControl;
4616 while ( pNewControl && pNewControl->GetType() != WINDOW_WORKWINDOW )
4617 pNewControl = pNewControl->GET_REAL_PARENT();
4618
4619 if ( pNewControl )
4620 {
4621 pControl = pNewControl;
4622 nRT = C_WorkWin;
4623 }
4624 }
4625
4626
4627 if ( (!ControlOK( pControl, "" )) && ( nMethodId != M_SnapShot ) && (nRetryCount--))
4628 {
4629 #if OSL_DEBUG_LEVEL > 1
4630 m_pDbgWin->AddText( CUniString("Reschedule command (").Append( UniString::CreateFromInt32(nRetryCount) ).AppendAscii(")\n") );
4631 #endif
4632 return sal_False;
4633 }
4634
4635 if( ControlOK( pControl, "" ) )
4636 {
4637 if ( nMethodId == M_OpenContextMenu && !bBool2 )
4638 {
4639 pControl->GrabFocus(); // to get asyncron focus on unix
4640 bBool2 = sal_True;
4641 return sal_False;
4642 }
4643 // TODO: handle GetFocus for all Methods and Windows like this (remove part below)
4644 // See for impact of changed focus for HandleVisibleControls() (taking Snapshots might be different, possible exclude those methods)
4645 if (( (nRT == C_TreeListBox) && !bBool2 )
4646 && nMethodId != M_TypeKeys // TypeKeys macht das selbst, falls eigenes Focushandling gewünscht
4647 && nMethodId != M_MouseDown
4648 && nMethodId != M_MouseUp
4649 && nMethodId != M_MouseMove
4650 /*&& nMethodId != M_MouseDoubleClick*/ )
4651 {
4652 if ( !pControl->HasFocus() )
4653 {
4654 pControl->GrabFocus();
4655 int i = 10;
4656 while ( i-- && !pControl->HasFocus() ) // reschedule a bit
4657 {
4658 SafeReschedule();
4659 if ( !WinPtrValid( pControl ) )
4660 return sal_False;
4661 }
4662 if ( !pControl->HasFocus() ) // to get asynchronous focus
4663 {
4664 bBool2 = sal_True;
4665 return sal_False;
4666 }
4667 }
4668 }
4669 }
4670
4671 Advance();
4672
4673 if ( HandleVisibleControls( pControl ) )
4674 {
4675 delete this;
4676 return sal_True;
4677 }
4678 if( ControlOK( pControl, "Window/Control" ) )
4679 {
4680 if (((( nRT < C_TabPage && nRT > C_TabControl )
4681 || nRT == C_PatternBox
4682 || nRT == C_ToolBox
4683 || nRT == C_ValueSet
4684 || nRT == C_Control
4685 || nRT == C_TreeListBox
4686 )
4687 || nMethodId == M_OpenContextMenu )
4688 && nMethodId != M_TypeKeys // TypeKeys macht das selbst, falls eigenes Focushandling gewünscht
4689 && nMethodId != M_MouseDown
4690 && nMethodId != M_MouseUp
4691 && nMethodId != M_MouseMove
4692 /*&& nMethodId != M_MouseDoubleClick*/ )
4693 pControl->GrabFocus();
4694
4695 /* leads to problems because settext sets the text whereas typekeys adds to the text.
4696 if ( bDoTypeKeysDelay && nMethodId == M_SetText && ( nParams & PARAM_STR_1 ) )
4697 { // Here the statement is bent to a TypeKeys
4698 nMethodId = M_TypeKeys;
4699 nParams = PARAM_BOOL_1 | PARAM_STR_1;
4700 bBool1 = sal_True;
4701 pControl->GrabFocus();
4702 }
4703 */
4704 if ( !HandleCommonMethods( pControl ) )
4705 {
4706 switch( nRT )
4707 {
4708 case C_TabControl:
4709 switch( nMethodId )
4710 {
4711 case M_GetPageId:
4712 if ( (nParams & PARAM_USHORT_1) )
4713 {
4714 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((TabControl*)pControl)->GetPageCount() ) )
4715 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)((TabControl*)pControl)->GetPageId(nNr1-1));
4716 }
4717 else
4718 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)((TabControl*)pControl)->GetCurPageId());
4719 break;
4720 case M_GetPageCount:
4721 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)((TabControl*)pControl)->GetPageCount());
4722 break;
4723 case M_SetPageId:
4724 if (((TabControl*)pControl)->GetCurPageId())
4725 ((TabControl*)pControl)->DeactivatePage();
4726 ((TabControl*)pControl)->SetCurPageId( nNr1 );
4727 ((TabControl*)pControl)->ActivatePage();
4728 break;
4729 case M_SetPageNr:
4730 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((TabControl*)pControl)->GetPageCount() ) )
4731 {
4732 if (((TabControl*)pControl)->GetCurPageId())
4733 ((TabControl*)pControl)->DeactivatePage();
4734 ((TabControl*)pControl)->SetCurPageId( ((TabControl*)pControl)->GetPageId( nNr1-1 ) );
4735 ((TabControl*)pControl)->ActivatePage();
4736 }
4737 break;
4738 case M_GetPage:
4739 pRet->GenReturn ( RET_Value, aUId, Id2Str( ((TabControl*)pControl)->GetTabPage(((TabControl*)pControl)->GetCurPageId())->GetUniqueOrHelpId() ) );
4740 break;
4741 case M_SetPage :
4742 { // Due to local variables
4743 TabControl *pTControl = ((TabControl*)pControl);
4744 sal_uInt16 nActive = pTControl->GetCurPageId();
4745 sal_uInt16 i,anz;
4746 rtl::OString aID;
4747 rtl::OString aWantedID;
4748 //HELPID BACKWARD (No numbers please (remove PARAM_ULONG_1 part)
4749 if ( (nParams & PARAM_ULONG_1) )
4750 {
4751 //aWantedID = rtl::OString( nLNr1 );
4752 ReportError( aUId, GEN_RES_STR1c( S_INTERNAL_ERROR, "using numeric HelpID from old Testtool" ) );
4753 }
4754 else if ( (nParams & PARAM_STR_1) )
4755 {
4756 aWantedID = Str2Id( aString1 );
4757 }
4758 else
4759 ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
4760
4761 i = pTControl->GetPagePos( pTControl->GetCurPageId() );
4762 for ( anz=0 ; anz < pTControl->GetPageCount() && !aID.equals( aWantedID ) ; anz++ )
4763 {
4764 pTControl->SelectTabPage( pTControl->GetPageId(i) );
4765 /*if (pTControl->GetCurPageId())
4766 pTControl->DeactivatePage();
4767 pTControl->SetCurPageId( pTControl->GetPageId(i) );
4768 pTControl->ActivatePage();*/
4769 aID = pTControl->GetTabPage(pTControl->GetCurPageId())->GetUniqueOrHelpId();
4770 i++;
4771 if ( i >= pTControl->GetPageCount() )
4772 i = 0;
4773 if ( !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) ) // Call up 3 times
4774 break;
4775 }
4776 if ( !aID.equals( aWantedID ) )
4777 {
4778 pTControl->SelectTabPage( nActive );
4779 /*if (pTControl->GetCurPageId())
4780 pTControl->DeactivatePage();
4781 pTControl->SetCurPageId( nActive );
4782 pTControl->ActivatePage();*/
4783 ReportError( aWantedID, GEN_RES_STR1( S_TABPAGE_NOT_FOUND, MethodString( nMethodId ) ) );
4784 }
4785 }
4786 break;
4787 default:
4788 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TabControl" ) );
4789 break;
4790 }
4791 break;
4792 case C_RadioButton:
4793 case C_ImageRadioButton:
4794 switch( nMethodId )
4795 {
4796 case M_AnimateMouse :
4797 AnimateMouse( pControl, MitteLinks);
4798 break;
4799 case M_IsChecked :
4800 pRet->GenReturn ( RET_Value, aUId, ((RadioButton*)pControl)->IsChecked());
4801 break;
4802 case M_Check :
4803 ((RadioButton*)pControl)->Check();
4804 ((RadioButton*)pControl)->Click();
4805 break;
4806 default:
4807 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RadioButton" ) );
4808 break;
4809 }
4810 break;
4811 case C_CheckBox:
4812 case C_TriStateBox:
4813 switch( nMethodId )
4814 {
4815 case M_AnimateMouse :
4816 AnimateMouse( pControl, MitteLinks);
4817 break;
4818 case M_IsChecked :
4819 pRet->GenReturn ( RET_Value, aUId, comm_BOOL( ((TriStateBox*)pControl)->GetState() == STATE_CHECK) );
4820 break;
4821 case M_IsTristate :
4822 pRet->GenReturn ( RET_Value, aUId, comm_BOOL( ((TriStateBox*)pControl)->GetState() == STATE_DONTKNOW) );
4823 break;
4824 case M_GetState :
4825 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((TriStateBox*)pControl)->GetState()));
4826 break;
4827 case M_Check :
4828 ((TriStateBox*)pControl)->SetState( STATE_CHECK );
4829 ((TriStateBox*)pControl)->Click();
4830 break;
4831 case M_UnCheck :
4832 ((TriStateBox*)pControl)->SetState( STATE_NOCHECK );
4833 ((TriStateBox*)pControl)->Click();
4834 break;
4835 case M_TriState :
4836 if ( ((TriStateBox*)pControl)->IsTriStateEnabled() )
4837 {
4838 ((TriStateBox*)pControl)->SetState( STATE_DONTKNOW );
4839 ((TriStateBox*)pControl)->Click();
4840 }
4841 else
4842 {
4843 ReportError( aUId, GEN_RES_STR0( S_TRISTATE_NOT_ALLOWED ) );
4844 }
4845 break;
4846 case M_Click :
4847 {
4848 TriStateBox *pTB = ((TriStateBox*)pControl);
4849 if ( pTB->GetState() == STATE_NOCHECK )
4850 pTB->SetState( STATE_CHECK );
4851 else if ( pTB->GetState() == STATE_CHECK )
4852 {
4853 if ( pTB->IsTriStateEnabled() )
4854 pTB->SetState( STATE_DONTKNOW );
4855 else
4856 pTB->SetState( STATE_NOCHECK );
4857 }
4858 else
4859 pTB->SetState( STATE_NOCHECK );
4860 pTB->Click();
4861 }
4862 break;
4863 default:
4864 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TriStateBox" ) );
4865 break;
4866 }
4867 break;
4868 case C_Edit:
4869 case C_MultiLineEdit:
4870 switch( nMethodId )
4871 {
4872 case M_AnimateMouse :
4873 AnimateMouse( pControl, Mitte);
4874 break;
4875 case M_GetText :
4876 pRet->GenReturn ( RET_Value, aUId, ((Edit*)pControl)->GetText());
4877 break;
4878 case M_IsWritable:
4879 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((Edit*)pControl)->IsReadOnly() );
4880 break;
4881 default:
4882 if ( ! ((Edit*)pControl)->IsReadOnly() )
4883 {
4884 switch( nMethodId )
4885 {
4886 case M_SetText :
4887 ((Edit*)pControl)->SetText( aString1 );
4888 if ( nRT == C_MultiLineEdit ) // since SetModifyFlag is not virtual we have to do this
4889 ((MultiLineEdit*)pControl)->SetModifyFlag();
4890 else
4891 ((Edit*)pControl)->SetModifyFlag();
4892 ((Edit*)pControl)->Modify();
4893 if ( ((Edit*)pControl)->GetText().CompareTo(aString1) != COMPARE_EQUAL )
4894 ReportError( aUId, GEN_RES_STR1( S_ERROR_IN_SET_TEXT, MethodString( nMethodId ) ) );
4895 break;
4896 default:
4897 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "(MultiLine)Edit" ) );
4898 break;
4899 }
4900 }
4901 else
4902 ReportError( aUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "(MultiLine)Edit" ) );
4903 }
4904 break;
4905 case C_MultiListBox:
4906 case C_ListBox:
4907 switch( nMethodId )
4908 {
4909 case M_AnimateMouse :
4910 AnimateMouse( pControl, MitteOben);
4911 break;
4912 case M_GetSelCount :
4913 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ListBox*)pControl)->GetSelectEntryCount()));
4914 break;
4915 case M_GetSelIndex :
4916 if ( ! (nParams & PARAM_USHORT_1) )
4917 {
4918 if ( ((ListBox*)pControl)->GetSelectEntryCount() == 0 )
4919 {
4920 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
4921 break;
4922 }
4923 nNr1 = 1;
4924 }
4925 ValueOK(aUId, MethodString( nMethodId ),nNr1,((ListBox*)pControl)->GetSelectEntryCount());
4926 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ListBox*)pControl)->GetSelectEntryPos(nNr1-1)) +1);
4927 break;
4928 case M_GetSelText :
4929 if ( ! (nParams & PARAM_USHORT_1) )
4930 nNr1 = 1;
4931 pRet->GenReturn ( RET_Value, aUId, ((ListBox*)pControl)->GetSelectEntry(nNr1-1));
4932 break;
4933 case M_GetItemCount :
4934 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ListBox*)pControl)->GetEntryCount()));
4935 break;
4936 case M_GetItemText :
4937 pRet->GenReturn ( RET_Value, aUId, ((ListBox*)pControl)->GetEntry(nNr1-1));
4938 break;
4939 case M_Select:
4940 case M_MultiSelect:
4941 {
4942 sal_Bool bUnselectBeforeSelect = ( nMethodId == M_Select );
4943 sal_Bool bFehler = sal_False;
4944 if ( ! (nParams & PARAM_BOOL_1) )
4945 bBool1 = sal_True;
4946
4947 if ( nMethodId == M_MultiSelect && nRT == C_ListBox )
4948 {
4949 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ListBox" ) );
4950 bFehler = sal_True;
4951 }
4952
4953 if ( !bBool1 && nMethodId == M_Select )
4954 {
4955 ReportError( aUId, GEN_RES_STR1( S_NO_SELECT_FALSE, MethodString( nMethodId ) ) );
4956 bFehler = sal_True;
4957 }
4958
4959 if ( !bFehler )
4960 {
4961 if( nParams & PARAM_STR_1 )
4962 {
4963 ListBox *pLB = ((ListBox*)pControl);
4964 sal_uInt16 nPos;
4965 if ( (nPos = pLB->GetEntryPos( aString1 )) == LISTBOX_ENTRY_NOTFOUND )
4966 ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
4967 else
4968 {
4969 if ( bUnselectBeforeSelect )
4970 pLB->SetNoSelection();
4971 pLB->SelectEntryPos( nPos, bBool1 );
4972 if ( pLB->IsEntryPosSelected( nPos ) ? !bBool1 : bBool1 ) // XOR into with BOOL
4973 ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) );
4974 }
4975 }
4976 else
4977 {
4978 ListBox *pLB = ((ListBox*)pControl);
4979 pLB = static_cast<ListBox*>(pControl);
4980 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pLB->GetEntryCount()) )
4981 {
4982 if ( bUnselectBeforeSelect )
4983 pLB->SetNoSelection();
4984 pLB->SelectEntryPos( nNr1-1, bBool1 );
4985 if ( pLB->IsEntryPosSelected( nNr1-1 ) ? !bBool1 : bBool1 ) // XOR into with BOOL
4986 ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), UniString::CreateFromInt32( nNr1 ) ) );
4987 }
4988 }
4989 ((ListBox*)pControl)->Select();
4990 }
4991 }
4992 break;
4993 case M_SetNoSelection :
4994 ((ListBox*)pControl)->SetNoSelection();
4995 ((ListBox*)pControl)->Select();
4996 break;
4997 default:
4998 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "(Multi)ListBox" ) );
4999 break;
5000 }
5001 break;
5002 case C_ComboBox:
5003 case C_PatternBox:
5004 case C_NumericBox:
5005 case C_MetricBox:
5006 case C_CurrencyBox:
5007 case C_DateBox:
5008 case C_TimeBox:
5009 switch( nMethodId )
5010 {
5011 case M_AnimateMouse :
5012 AnimateMouse( pControl, MitteOben);
5013 break;
5014 case M_GetSelText :
5015 pRet->GenReturn ( RET_Value, aUId, ((ComboBox*)pControl)->GetText());
5016 break;
5017 case M_GetSelIndex :
5018 {
5019 sal_uInt16 nPos = ((ComboBox*)pControl)->GetEntryPos(((ComboBox*)pControl)->GetText());
5020 if ( nPos == COMBOBOX_ENTRY_NOTFOUND )
5021 nPos = 0;
5022 else
5023 nPos++;
5024 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG) nPos);
5025 }
5026 break;
5027 case M_GetItemCount :
5028 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((ComboBox*)pControl)->GetEntryCount()));
5029 break;
5030 case M_GetItemText :
5031 pRet->GenReturn ( RET_Value, aUId, ((ComboBox*)pControl)->GetEntry(nNr1-1));
5032 break;
5033 case M_IsWritable:
5034 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((ComboBox*)pControl)->IsReadOnly() );
5035 break;
5036 case M_Select :
5037 if( nParams & PARAM_USHORT_1 )
5038 {
5039 if ( !ValueOK(aUId, MethodString( nMethodId ),nNr1,((ComboBox*)pControl)->GetEntryCount()) )
5040 break;
5041 aString1 = ((ComboBox*)pControl)->GetEntry(nNr1-1);
5042 }
5043 else
5044 {
5045 if ( ((ComboBox*)pControl)->GetEntryPos( aString1 ) == COMBOBOX_ENTRY_NOTFOUND )
5046 {
5047 ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
5048 break;
5049 }
5050 }
5051
5052
5053 ((ComboBox*)pControl)->SetText( aString1 );
5054 ((ComboBox*)pControl)->SetModifyFlag();
5055 ((ComboBox*)pControl)->Modify();
5056 break;
5057 case M_SetText :
5058 if ( ! ((ComboBox*)pControl)->IsReadOnly() )
5059 {
5060 if ( ! (nParams & PARAM_STR_1) )
5061 aString1 = String();
5062 ((ComboBox*)pControl)->SetText( aString1 );
5063 ((ComboBox*)pControl)->SetModifyFlag();
5064 ((ComboBox*)pControl)->Modify();
5065 }
5066 else
5067 ReportError( aUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "ComboBox" ) );
5068 break;
5069 default:
5070 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ComboBox" ) );
5071 break;
5072 }
5073 break;
5074 case C_PushButton:
5075 case C_OkButton:
5076 case C_CancelButton:
5077 case C_ImageButton:
5078 switch( nMethodId )
5079 {
5080 case M_AnimateMouse :
5081 AnimateMouse( pControl, Mitte);
5082 break;
5083 case M_Click :
5084 ((PushButton*)pControl)->Click();
5085 break;
5086 default:
5087 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "PushButton" ) );
5088 break;
5089 }
5090 break;
5091 case C_MoreButton:
5092 switch( nMethodId )
5093 {
5094 case M_AnimateMouse :
5095 AnimateMouse( pControl, Mitte);
5096 break;
5097 case M_IsOpen :
5098 pRet->GenReturn ( RET_Value, aUId, ((MoreButton*)pControl)->GetState());
5099 break;
5100 case M_Click :
5101 ((MoreButton*)pControl)->Click();
5102 break;
5103 case M_Open :
5104 ((MoreButton*)pControl)->SetState(sal_True);
5105 break;
5106 case M_Close :
5107 ((MoreButton*)pControl)->SetState(sal_False);
5108 break;
5109 default:
5110 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MoreButton" ) );
5111 break;
5112 }
5113 break;
5114 case C_SpinField:
5115 case C_PatternField:
5116 case C_NumericField:
5117 case C_MetricField:
5118 case C_CurrencyField:
5119 case C_DateField:
5120 case C_TimeField:
5121 switch( nMethodId )
5122 {
5123 case M_AnimateMouse :
5124 AnimateMouse( pControl, Mitte);
5125 break;
5126 case M_GetText :
5127 pRet->GenReturn ( RET_Value, aUId, ((SpinField*)pControl)->GetText());
5128 break;
5129 case M_IsWritable:
5130 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((SpinField*)pControl)->IsReadOnly() );
5131 break;
5132 case M_SetText :
5133 if ( ! ((SpinField*)pControl)->IsReadOnly() )
5134 {
5135 ((SpinField*)pControl)->SetText( aString1 );
5136 ((SpinField*)pControl)->SetModifyFlag();
5137 ((SpinField*)pControl)->Modify();
5138 }
5139 else
5140 ReportError( aUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "SpinField" ) );
5141 break;
5142 case M_More :
5143 {
5144 if ( !(nParams & PARAM_USHORT_1) )
5145 nNr1 = 1;
5146 for (int i = 1; i<= nNr1; i++)
5147 {
5148 ((SpinField*)pControl)->Up();
5149 ((SpinField*)pControl)->SetModifyFlag();
5150 ((SpinField*)pControl)->Modify();
5151 }
5152 }
5153 break;
5154 case M_Less :
5155 {
5156 if ( !(nParams & PARAM_USHORT_1) )
5157 nNr1 = 1;
5158 for (int i = 1; i<= nNr1; i++)
5159 {
5160 ((SpinField*)pControl)->Down();
5161 ((SpinField*)pControl)->SetModifyFlag();
5162 ((SpinField*)pControl)->Modify();
5163 }
5164 }
5165 break;
5166 case M_ToMin :
5167 ((SpinField*)pControl)->First();
5168 ((SpinField*)pControl)->SetModifyFlag();
5169 ((SpinField*)pControl)->Modify();
5170 break;
5171 case M_ToMax :
5172 ((SpinField*)pControl)->Last();
5173 ((SpinField*)pControl)->SetModifyFlag();
5174 ((SpinField*)pControl)->Modify();
5175 break;
5176 default:
5177 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "SpinField" ) );
5178 break;
5179 }
5180 break;
5181
5182 case C_MenuButton:
5183 switch( nMethodId )
5184 {
5185 case M_AnimateMouse :
5186 AnimateMouse( pControl, Mitte);
5187 break;
5188 case M_Click :
5189 {
5190 MouseEvent aMEvnt;
5191 Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 );
5192 aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
5193 ImplMouseButtonDown( pControl, aMEvnt, FORCE_DIRECT_CALL );
5194 ImplMouseButtonUp ( pControl, aMEvnt, FORCE_DIRECT_CALL );
5195 }
5196 break;
5197 case M_Open :
5198 case M_OpenMenu :
5199 {
5200 MouseEvent aMEvnt;
5201 Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 );
5202 aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
5203 ImplMouseButtonDown( pControl, aMEvnt, FORCE_DIRECT_CALL );
5204
5205 sal_uLong nStart = Time::GetSystemTicks();
5206 sal_uLong nDelay = pControl->GetSettings().GetMouseSettings().GetActionDelay();
5207 while ( ( Time::GetSystemTicks() - nStart ) < nDelay + 100 )
5208 SafeReschedule();
5209
5210 ImplMouseButtonUp ( pControl, aMEvnt, FORCE_DIRECT_CALL );
5211
5212 aSubMenuId1 = 0;
5213 aSubMenuId2 = 0;
5214 aSubMenuId3 = 0;
5215 pMenuWindow = NULL;
5216 }
5217 break;
5218 default:
5219 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MenuButton" ) );
5220 break;
5221 }
5222 break;
5223 case C_ToolBox:
5224 {
5225 ToolBox *pTB = ((ToolBox*)pControl);
5226 if ( !aUId.equals( pTB->GetUniqueOrHelpId() ) ) // So we found a Button on the ToolBox
5227 {
5228 if ( (nParams == PARAM_NONE) || (nParams == PARAM_USHORT_1) )
5229 { // We fake a parameter
5230 nParams |= PARAM_STR_1;
5231 aString1 = Id2Str( aUId );
5232 }
5233 else
5234 ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
5235 }
5236
5237 #define FIND_ITEM\
5238 sal_uInt16 nItemPos = 0;\
5239 sal_Bool bItemFound = sal_False;\
5240 {\
5241 rtl::OString aButtonId;\
5242 if( nParams & PARAM_STR_1 )\
5243 aButtonId = Str2Id( aString1 );\
5244 else\
5245 ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );\
5246 for ( nItemPos = 0; nItemPos < pTB->GetItemCount() && !aButtonId.equals(Str2Id( pTB->GetItemCommand(pTB->GetItemId(nItemPos)) )) &&\
5247 !aButtonId.equals(pTB->GetHelpId(pTB->GetItemId(nItemPos))) ; nItemPos++ ) {}\
5248 bItemFound = aButtonId.equals(Str2Id( pTB->GetItemCommand(pTB->GetItemId(nItemPos)) )) || aButtonId.equals(pTB->GetHelpId(pTB->GetItemId(nItemPos)));\
5249 if ( !bItemFound )\
5250 ReportError( aUId, GEN_RES_STR1( S_HELPID_ON_TOOLBOX_NOT_FOUND, MethodString( nMethodId ) ) );\
5251 else\
5252 {\
5253 if ( !pTB->IsItemEnabled( pTB->GetItemId(nItemPos) ) && nMethodId != _M_IsEnabled && nMethodId != M_GetState )\
5254 {\
5255 ReportError( aUId, GEN_RES_STR1( S_BUTTON_DISABLED_ON_TOOLBOX, MethodString( nMethodId ) ) );\
5256 bItemFound = sal_False;\
5257 }\
5258 else if ( !pTB->IsItemVisible( pTB->GetItemId(nItemPos) ) && nMethodId != M_GetState )\
5259 {\
5260 ReportError( aUId, GEN_RES_STR1( S_BUTTON_HIDDEN_ON_TOOLBOX, MethodString( nMethodId ) ) );\
5261 bItemFound = sal_False;\
5262 }\
5263 else\
5264 {\
5265 if ( pTB->IsMenuEnabled() )\
5266 { /* button is in Menu */\
5267 }\
5268 else\
5269 { /* Try the multi line way */\
5270 if ( pTB->GetItemRect(pTB->GetItemId(nItemPos)).IsEmpty() )\
5271 {\
5272 sal_uInt16 nLine = pTB->GetCurLine();\
5273 do\
5274 {\
5275 pTB->ShowLine( sal_False );\
5276 for ( int i = 1 ; i < 30 ; i++ )\
5277 SafeReschedule();\
5278 }\
5279 while ( pTB->GetCurLine() != nLine && pTB->GetItemRect(pTB->GetItemId(nItemPos)).IsEmpty() );\
5280 pTB->Invalidate( pTB->GetScrollRect() );\
5281 }\
5282 if ( pTB->GetItemRect(pTB->GetItemId(nItemPos)).IsEmpty() )\
5283 {\
5284 ReportError( aUId, GEN_RES_STR1( S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX, MethodString( nMethodId ) ) );\
5285 bItemFound = sal_False;\
5286 }\
5287 }\
5288 }\
5289 }\
5290 }
5291
5292 switch( nMethodId )
5293 {
5294 case M_AnimateMouse :
5295 AnimateMouse( pControl, MitteLinks);
5296 break;
5297 case M_Click :
5298 {
5299 FIND_ITEM;
5300 if ( bItemFound ) // FIND_ITEM successful
5301 {
5302 Rectangle aRect = pTB->GetItemRect(pTB->GetItemId(nItemPos));
5303 if ( aRect.IsEmpty() )
5304 {
5305 pTB->ExecuteCustomMenu();
5306 /* aRect = pTB->GetMenubuttonRect();
5307 MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5308 ImplMouseButtonDown( pTB, aMEvnt );*/
5309
5310 aSubMenuId1 = 0;
5311 aSubMenuId2 = 0;
5312 aSubMenuId3 = 0;
5313 pMenuWindow = NULL;
5314
5315 new StatementCommand( this, RC_MenuSelect, PARAM_USHORT_1, pTB->GetItemId(nItemPos) + TOOLBOX_MENUITEM_START );
5316 }
5317 else
5318 {
5319 aRect = pTB->GetItemRect(pTB->GetItemId(nItemPos));
5320 MouseEvent aMEvnt;
5321 aMEvnt = MouseEvent(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5322 ImplMouseButtonDown( pTB, aMEvnt, FORCE_DIRECT_CALL );
5323 ImplMouseButtonUp ( pTB, aMEvnt, FORCE_DIRECT_CALL );
5324 }
5325 }
5326 }
5327 break;
5328 case M_TearOff :
5329 {
5330 FIND_ITEM;
5331 if ( bItemFound ) // FIND_ITEM successful
5332 {
5333 Rectangle aRect = pTB->GetItemPosDropDownRect( nItemPos );
5334 AnimateMouse( pControl, aRect.Center() );
5335 MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5336 ImplMouseButtonDown( pTB, aMEvnt, FORCE_DIRECT_CALL );
5337
5338 Window *pWin = NULL;
5339 // Wait for the window to open.
5340 StatementList::bExecuting = sal_True; // Bah, that's a nasty hack.
5341 { // This prevents the next command from being executed.
5342 Time aDelay;
5343 while ( !pWin && ( (pWin = GetPopupFloatingWin()) == NULL ) && ( Time() - aDelay ).GetSec() < 15 )
5344 SafeReschedule();
5345 }
5346 StatementList::bExecuting = sal_False; // Bah, that's a nasty hack.
5347
5348 if ( pWin && pWin->GetType() == WINDOW_FLOATINGWINDOW )
5349 {
5350 aMEvnt = MouseEvent(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5351 ImplMouseButtonUp( pTB, aMEvnt, FORCE_DIRECT_CALL );
5352 ((FloatingWindow*)pWin)->EndPopupMode( FLOATWIN_POPUPMODEEND_TEAROFF );
5353 }
5354 else
5355 {
5356 aMEvnt = MouseEvent(Point(1,-10), 1, MOUSE_SIMPLECLICK,MOUSE_LEFT);
5357 ImplMouseButtonUp( pTB, aMEvnt, FORCE_DIRECT_CALL );
5358 ReportError( aUId, GEN_RES_STR1( S_TEAROFF_FAILED, MethodString( nMethodId ) ) );
5359 }
5360 }
5361 }
5362 break;
5363 case M_OpenMenu :
5364 {
5365 FIND_ITEM;
5366 if ( bItemFound ) // FIND_ITEM successful
5367 {
5368 Rectangle aRect = pTB->GetItemPosDropDownRect( nItemPos );
5369 AnimateMouse( pControl, aRect.Center() );
5370 MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT);
5371 ImplMouseButtonDown( pTB, aMEvnt);
5372 ImplMouseButtonUp( pTB, aMEvnt);
5373
5374 // The window is open
5375 aSubMenuId1 = 0;
5376 aSubMenuId2 = 0;
5377 aSubMenuId3 = 0;
5378 pMenuWindow = NULL;
5379 }
5380 }
5381 break;
5382 case _M_IsEnabled:
5383 {
5384 FIND_ITEM;
5385 if ( bItemFound ) // FIND_ITEM successful
5386 {
5387 pRet->GenReturn ( RET_Value, aUId, pTB->IsItemEnabled( pTB->GetItemId(nItemPos) ) );
5388 }
5389 }
5390 break;
5391 case M_GetState :
5392 {
5393 FIND_ITEM;
5394 if ( bItemFound ) // FIND_ITEM successful
5395 {
5396 if ( ValueOK( aUId, CUniString("GetState"), nNr1, 4 ) )
5397 switch (nNr1)
5398 {
5399 case 0:
5400 pRet->GenReturn ( RET_Value, aUId, Id2Str( pTB->GetHelpId(pTB->GetItemId(nItemPos)) ) );
5401 break;
5402 case 1:
5403 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemType(nItemPos));
5404 break;
5405 case 2:
5406 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemState(pTB->GetItemId(nItemPos)));
5407 break;
5408 case 3:
5409 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemId(nItemPos));
5410 break;
5411 case 11:
5412 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG) nItemPos + 1);
5413 break;
5414 case 12:
5415 pRet->GenReturn ( RET_Value, aUId, Id2Str(pTB->GetHelpId())); // The toolbox's help id
5416 break;
5417 case 13:
5418 {
5419 Rectangle aRect = pTB->GetItemPosRect( nItemPos );
5420 Rectangle aTBRect = pTB->GetWindowExtentsRelative( NULL );
5421 pRet->GenReturn ( RET_Value, aUId,
5422 UniString::CreateFromInt32(aRect.Left()+aTBRect.Left()).
5423 AppendAscii(",").Append(UniString::CreateFromInt32(aRect.Top()+aTBRect.Top())).
5424 AppendAscii(",").Append(UniString::CreateFromInt32(aRect.GetWidth())).
5425 AppendAscii(",").Append(UniString::CreateFromInt32(aRect.GetHeight()))
5426 );
5427 break;
5428 }
5429 default:
5430 ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
5431 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
5432 break;
5433 }
5434 }
5435 }
5436 break;
5437 case M_GetItemHelpText :
5438 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTB->GetItemCount() ))
5439 pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetHelpText(pTB->GetItemId(nNr1-1)));
5440 break;
5441 case M_GetItemQuickHelpText :
5442 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTB->GetItemCount() ))
5443 pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetQuickHelpText(pTB->GetItemId(nNr1-1)));
5444 break;
5445 case M_GetItemText2:
5446 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTB->GetItemCount() ))
5447 pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetItemText(pTB->GetItemId(nNr1-1)));
5448 break;
5449 case M_GetItemText :
5450 pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetItemText(nNr1));
5451 break;
5452 case M_GetText :
5453 pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetText());
5454 break;
5455 case M_GetItemCount :
5456 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTB->GetItemCount());
5457 break;
5458 case M_SetNextToolBox :
5459 if ( (nParams & PARAM_STR_1) )
5460 pTB->SetNextToolBox( aString1 );
5461 else
5462 pTB->SetNextToolBox( pTB->GetNextToolBox() );
5463 pTB->NextToolBox();
5464 break;
5465 case M_GetNextToolBox :
5466 pRet->GenReturn ( RET_Value, aUId, (String)pTB->GetNextToolBox());
5467 break;
5468 case M_Dock :
5469 case M_Undock :
5470 case M_IsDocked :
5471 case M_Close:
5472 case M_Size:
5473 case M_Move:
5474 case M_IsMax:
5475 case M_Minimize:
5476 case M_Maximize:
5477 case M_Help: // Everything to be treated below
5478 goto DockingWin;
5479 default:
5480 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ToolBox" ) );
5481 break;
5482 }
5483 }
5484 break;
5485
5486 case C_TreeListBox:
5487 switch( nMethodId )
5488 {
5489
5490
5491
5492 #define GET_NTH_ENTRY_LBOX( First, Next, Anzahl) \
5493 SvLBoxEntry *pThisEntry = ((SvTreeListBox*)pControl)->First(); \
5494 { \
5495 int niTemp = Anzahl; \
5496 while ( niTemp-- ) \
5497 { \
5498 pThisEntry = ((SvTreeListBox*)pControl)->Next( pThisEntry ); \
5499 } \
5500 }
5501
5502 case M_GetText : // Get the first text of the given (default=1) line
5503 { // should get removed some time
5504 SvTreeListBox *pTree = (SvTreeListBox*)pControl;
5505 SvLBoxEntry *pThisEntry = pTree->GetCurEntry();
5506 if ( ! (nParams & PARAM_USHORT_1) )
5507 nNr1 = 1;
5508 if ( pThisEntry )
5509 {
5510 SvLBoxString* pItem = NULL;
5511 sal_uInt16 nValidTextItemCount = 0;
5512 {
5513 sal_uInt16 nIndex = 0;
5514 SvLBoxItem *pMyItem;
5515 while ( ( nValidTextItemCount < nNr1 ) && nIndex < pThisEntry->ItemCount() )
5516 {
5517 pMyItem = pThisEntry->GetItem( nIndex );
5518 if ( pMyItem->IsA() == SV_ITEM_ID_LBOXSTRING )
5519 {
5520 pItem = (SvLBoxString*)pMyItem;
5521 nValidTextItemCount++;
5522 }
5523 nIndex++;
5524 }
5525 }
5526 if ( ValueOK( aUId, CUniString("GetText"), nNr1, nValidTextItemCount ) )
5527 pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5528 }
5529 else
5530 ReportError( aUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "TreeListBox" ) );
5531 }
5532 break;
5533 case M_GetSelCount :
5534 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetSelectionCount()));
5535 break;
5536 case M_GetItemCount :
5537 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetVisibleCount()) );
5538 break;
5539 case M_GetSelIndex :
5540 if ( ! (nParams & PARAM_USHORT_1) )
5541 nNr1 = 1;
5542 if ( ValueOK(aUId, CUniString("GetSelIndex"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
5543 {
5544 nNr1--;
5545 GET_NTH_ENTRY_LBOX( FirstSelected, NextSelected, nNr1);
5546 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( ((SvTreeListBox*)pControl)->GetVisiblePos( pThisEntry )) +1 );
5547 }
5548 break;
5549 case M_Select :
5550 if ( ! (nParams & PARAM_BOOL_1) )
5551 bBool1 = sal_True;
5552 if( nParams & PARAM_STR_1 )
5553 {
5554 /* ListBox *pLB = ((ListBox*)pControl);
5555 if ( pLB->GetEntryPos( aString1 ) == LISTBOX_ENTRY_NOTFOUND )
5556 ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
5557 else
5558 {
5559 pLB->SelectEntry( aString1, bBool1 );
5560 if ( pLB->IsEntrySelected( aString1 ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL
5561 ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) );
5562 }
5563 */ ReportError( aUId, GEN_RES_STR1( S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED, MethodString( nMethodId ) ) );
5564 }
5565 else
5566 {
5567 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5568 {
5569 SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
5570 ((SvTreeListBox*)pControl)->Select ( pEntry, bBool1 );
5571 }
5572 }
5573 break;
5574 case M_Collapse :
5575 if( nParams & PARAM_STR_1 )
5576 {
5577 ReportError( aUId, GEN_RES_STR1( S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED, MethodString( nMethodId ) ) );
5578 }
5579 else
5580 {
5581 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5582 {
5583 SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
5584 ((SvTreeListBox*)pControl)->Collapse ( pEntry );
5585 }
5586 }
5587 break;
5588 case M_Expand :
5589 if( nParams & PARAM_STR_1 )
5590 {
5591 ReportError( aUId, GEN_RES_STR1( S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED, MethodString( nMethodId ) ) );
5592 }
5593 else
5594 {
5595 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5596 {
5597 SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
5598 ((SvTreeListBox*)pControl)->Expand ( pEntry );
5599 }
5600 }
5601 break;
5602 case M_GetSelText :
5603 if ( ! (nParams & PARAM_USHORT_1) )
5604 nNr1 = 1;
5605 if ( ! (nParams & PARAM_USHORT_2) )
5606 nNr2 = 1;
5607 if ( ValueOK(aUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
5608 {
5609 nNr1--;
5610 GET_NTH_ENTRY_LBOX( FirstSelected, NextSelected, nNr1);
5611 if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
5612 {
5613 SvLBoxString* pItem = NULL;
5614 if ( ! (nParams & PARAM_USHORT_2) )
5615 pItem = (SvLBoxString*)pThisEntry->GetFirstItem( SV_ITEM_ID_LBOXSTRING );
5616 else
5617 {
5618 SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
5619 if ( pMyItem->IsA() == SV_ITEM_ID_LBOXSTRING )
5620 pItem = (SvLBoxString*)pMyItem;
5621 }
5622
5623 if ( pItem )
5624 pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5625 else
5626 ReportError( aUId, GEN_RES_STR1( S_NO_LIST_BOX_STRING, MethodString( nMethodId ) ) );
5627 }
5628 }
5629 break;
5630 case M_GetItemText :
5631 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5632 {
5633 SvLBoxEntry *pThisEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
5634 if ( ! (nParams & PARAM_USHORT_2) )
5635 nNr2 = 1;
5636 if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
5637 {
5638 SvLBoxString* pItem = NULL;
5639 if ( ! (nParams & PARAM_USHORT_2) )
5640 pItem = (SvLBoxString*)pThisEntry->GetFirstItem( SV_ITEM_ID_LBOXSTRING );
5641 else
5642 {
5643 SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
5644 if ( pMyItem->IsA() == SV_ITEM_ID_LBOXSTRING )
5645 pItem = (SvLBoxString*)pMyItem;
5646 }
5647
5648 if ( pItem )
5649 pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5650 else
5651 ReportError( aUId, GEN_RES_STR1( S_NO_LIST_BOX_STRING, MethodString( nMethodId ) ) );
5652 }
5653 }
5654 break;
5655 case M_IsChecked :
5656 case M_IsTristate :
5657 case M_GetState :
5658 case M_Check :
5659 case M_UnCheck :
5660 case M_TriState :
5661 {
5662 SvTreeListBox *pTree = (SvTreeListBox*)pControl;
5663 SvLBoxEntry *pThisEntry = NULL;
5664
5665 if ( ! (nParams & PARAM_USHORT_1) )
5666 {
5667 pThisEntry = pTree->GetCurEntry();
5668 if ( !pThisEntry )
5669 ReportError( aUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "TreeListBox" ) );
5670 }
5671 else
5672 {
5673 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5674 {
5675 pThisEntry = (SvLBoxEntry*)pTree->GetEntryAtVisPos( nNr1-1 );
5676 }
5677 }
5678
5679 if ( ! (nParams & PARAM_USHORT_2) )
5680 nNr2 = 1;
5681
5682 if ( pThisEntry )
5683 {
5684 if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
5685 {
5686 SvLBoxButton* pItem = NULL;
5687 if ( ! (nParams & PARAM_USHORT_2) )
5688 pItem = (SvLBoxButton*)pThisEntry->GetFirstItem( SV_ITEM_ID_LBOXBUTTON );
5689 else
5690 {
5691 SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
5692 if ( pMyItem->IsA() == SV_ITEM_ID_LBOXBUTTON )
5693 pItem = (SvLBoxButton*)pMyItem;
5694 }
5695
5696 if ( pItem )
5697 {
5698 switch( nMethodId )
5699 {
5700 case M_IsChecked :
5701 pRet->GenReturn ( RET_Value, aUId, comm_BOOL( pItem->IsStateChecked() ) );
5702 break;
5703 case M_IsTristate :
5704 pRet->GenReturn ( RET_Value, aUId, comm_BOOL( pItem->IsStateTristate() ) );
5705 break;
5706 case M_GetState :
5707 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pItem->GetButtonFlags() & ~SV_STATE_MASK ));
5708 break;
5709 case M_Check :
5710 if ( !pItem->IsStateChecked() )
5711 {
5712 pItem->SetStateChecked();
5713 pTree->CheckButtonHdl();
5714 pTree->InvalidateEntry( pThisEntry );
5715 }
5716 break;
5717 case M_UnCheck :
5718 if ( pItem->IsStateChecked() || pItem->IsStateTristate() )
5719 {
5720 pItem->SetStateUnchecked();
5721 pTree->CheckButtonHdl();
5722 pTree->InvalidateEntry( pThisEntry );
5723 }
5724 break;
5725 case M_TriState :
5726 if ( !pItem->IsStateTristate() )
5727 {
5728 pItem->SetStateTristate();
5729 pTree->CheckButtonHdl();
5730 pTree->InvalidateEntry( pThisEntry );
5731 }
5732 break;
5733 default:
5734 ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
5735 break;
5736 }
5737 }
5738 else
5739 ReportError( aUId, GEN_RES_STR1( S_NO_LIST_BOX_BUTTON, MethodString( nMethodId ) ) );
5740 }
5741 }
5742 }
5743 break;
5744 case M_GetItemType :
5745 {
5746 SvTreeListBox *pTree = (SvTreeListBox*)pControl;
5747 SvLBoxEntry *pThisEntry = NULL;
5748
5749 if ( ! (nParams & PARAM_USHORT_1) )
5750 {
5751 pThisEntry = pTree->GetCurEntry();
5752 if ( !pThisEntry )
5753 ReportError( aUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "TreeListBox" ) );
5754 }
5755 else
5756 {
5757 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5758 {
5759 pThisEntry = (SvLBoxEntry*)pTree->GetEntryAtVisPos( nNr1-1 );
5760 }
5761 }
5762
5763 if ( pThisEntry )
5764 {
5765 if ( ! (nParams & PARAM_USHORT_2) )
5766 nNr2 = 1;
5767 if ( ValueOK( aUId, MethodString( nMethodId ),nNr2,pThisEntry->ItemCount() ) )
5768 {
5769 SvLBoxItem *pMyItem = pThisEntry->GetItem( nNr2-1 );
5770 comm_USHORT nType;
5771 switch ( pMyItem->IsA() )
5772 {
5773 case SV_ITEM_ID_LBOXSTRING: nType = CONST_ItemTypeText ; break;
5774 case SV_ITEM_ID_LBOXBMP: nType = CONST_ItemTypeBMP ; break;
5775 case SV_ITEM_ID_LBOXBUTTON: nType = CONST_ItemTypeCheckbox ; break;
5776 case SV_ITEM_ID_LBOXCONTEXTBMP: nType = CONST_ItemTypeContextBMP ; break;
5777 default: nType = CONST_ItemTypeUnknown;
5778 }
5779 pRet->GenReturn ( RET_Value, aUId, nType );
5780 }
5781 }
5782 }
5783 break;
5784 default:
5785 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TreeListBox" ) );
5786 break;
5787 }
5788 break;
5789 case C_Control:
5790 {
5791 sal_uInt16 nRealControlType = 0;
5792 if ( dynamic_cast< EditBrowseBox* >(pControl) )
5793 nRealControlType = CONST_CTBrowseBox;
5794 else if ( dynamic_cast< ValueSet* >(pControl) )
5795 nRealControlType = CONST_CTValueSet;
5796 else if ( dynamic_cast< ORoadmap* >(pControl) )
5797 nRealControlType = CONST_CTORoadmap;
5798 else if ( dynamic_cast< IExtensionListBox* >(pControl) )
5799 nRealControlType = CONST_CTIExtensionListBox;
5800 else if ( dynamic_cast< ::svt::table::TableControl* >(pControl) )
5801 nRealControlType = CONST_CTTableControl;
5802 else
5803 nRealControlType = CONST_CTUnknown;
5804
5805 switch( nMethodId )
5806 {
5807 case M_AnimateMouse :
5808 AnimateMouse( pControl, MitteOben);
5809 break;
5810 default:
5811 switch( nRealControlType )
5812 {
5813 case CONST_CTBrowseBox:
5814 {
5815 EditBrowseBox* pEBBox = dynamic_cast< EditBrowseBox* >(pControl);
5816 switch( nMethodId )
5817 {
5818
5819 /*
5820 sal_Bool MakeFieldVisible( long nRow, sal_uInt16 nColId, sal_Bool bComplete = sal_False );
5821 // access to dynamic values of cursor row
5822 String GetColumnTitle( sal_uInt16 nColumnId ) const;
5823 sal_uInt16 GetColumnId( sal_uInt16 nPos ) const;
5824 sal_uInt16 GetColumnPos( sal_uInt16 nColumnId ) const;
5825 // access and movement of cursor
5826 long GetCurRow() const { return nCurRow; }
5827 sal_uInt16 GetCurColumnId() const { return nCurColId; }
5828 sal_Bool GoToRow( long nRow );
5829 sal_Bool GoToRowAndDoNotModifySelection( long nRow );
5830 sal_Bool GoToColumnId( sal_uInt16 nColId );
5831 sal_Bool GoToRowColumnId( long nRow, sal_uInt16 nColId );
5832 // selections
5833 void SetNoSelection();
5834 void SelectAll();
5835 void SelectRow( long nRow, sal_Bool bSelect = sal_True, sal_Bool bExpand = sal_True );
5836 void SelectColumnPos( sal_uInt16 nCol, sal_Bool bSelect = sal_True )
5837 { SelectColumnPos( nCol, bSelect, sal_True); }
5838 void SelectColumnId( sal_uInt16 nColId, sal_Bool bSelect = sal_True )
5839 { SelectColumnPos( GetColumnPos(nColId), bSelect, sal_True); }
5840 long GetSelectRowCount() const;
5841 sal_uInt16 GetSelectColumnCount() const;
5842 sal_Bool IsRowSelected( long nRow ) const;
5843 sal_Bool IsColumnSelected( sal_uInt16 nColumnId ) const;
5844 long FirstSelectedRow( sal_Bool bInverse = sal_False );
5845 long LastSelectedRow( sal_Bool bInverse = sal_False );
5846 long PrevSelectedRow();
5847 long NextSelectedRow();
5848 const MultiSelection* GetSelection() const
5849 { return bMultiSelection ? uRow.pSel : 0; }
5850 void SetSelection( const MultiSelection &rSelection );
5851
5852 virtual String GetCellText(long _nRow, sal_uInt16 _nColId) const;
5853 sal_uInt16 GetColumnCount() const { return ColCount(); }
5854 protected:
5855 virtual long GetRowCount() const;
5856
5857
5858 EditBrowseBox
5859
5860 sal_Bool IsEditing() const {return aController.Is();}
5861 void InvalidateStatusCell(long nRow) {RowModified(nRow, 0);}
5862 void InvalidateHandleColumn();
5863
5864 CellControllerRef Controller() const { return aController; }
5865 sal_Int32 GetBrowserFlags() const { return m_nBrowserFlags; }
5866
5867 virtual void ActivateCell(long nRow, sal_uInt16 nCol, sal_Bool bSetCellFocus = sal_True);
5868 virtual void DeactivateCell(sal_Bool bUpdate = sal_True);
5869 */
5870
5871 case M_GetSelText :
5872 {
5873 pRet->GenReturn ( RET_Value, aUId, pEBBox->GetCellText( pEBBox->GetCurrRow(), pEBBox->GetColumnId( pEBBox->GetCurrColumn() )));
5874 }
5875 break;
5876 case M_GetColumnCount :
5877 {
5878 sal_uInt16 nColCount = pEBBox->GetColumnCount();
5879 comm_USHORT nUnfrozenColCount = 0;
5880 sal_uInt16 i;
5881 for ( i=0 ; i < nColCount ; i++ )
5882 {
5883 if ( !pEBBox->IsFrozen( pEBBox->GetColumnId( i ) ) )
5884 nUnfrozenColCount++;
5885 }
5886 pRet->GenReturn ( RET_Value, aUId, nUnfrozenColCount );
5887 }
5888 break;
5889 case M_GetRowCount :
5890 {
5891 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pEBBox->GetRowCount() );
5892 }
5893 break;
5894 case M_IsEditing :
5895 {
5896 CellControllerRef aControler;
5897 aControler = pEBBox->Controller();
5898 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)aControler.Is() );
5899 }
5900 break;
5901 case M_Select :
5902 {
5903 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pEBBox->GetRowCount() ) )
5904 {
5905 sal_uInt16 nColCount = pEBBox->GetColumnCount();
5906 comm_USHORT nUnfrozenColCount = 0;
5907 sal_uInt16 i;
5908 for ( i=0 ; i < nColCount ; i++ )
5909 {
5910 if ( !pEBBox->IsFrozen( pEBBox->GetColumnId( i ) ) )
5911 nUnfrozenColCount++;
5912 }
5913 if ( ValueOK(aUId, MethodString( nMethodId ),nNr2,nUnfrozenColCount ) )
5914 pEBBox->GoToRowColumnId( nNr1-1, pEBBox->GetColumnId( nNr2 ) );
5915 }
5916 }
5917 break;
5918
5919 /*
5920 case M_GetSelCount :
5921 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetSelectionCount()));
5922 break;
5923 case M_GetSelIndex :
5924 if ( ! (nParams & PARAM_USHORT_1) )
5925 nNr1 = 1;
5926 if ( ValueOK(aUId, CUniString("GetSelIndex"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
5927 {
5928 nNr1--;
5929 COUNT_LBOX( FirstSelected, NextSelected, nNr1);
5930 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( ((SvTreeListBox*)pControl)->GetVisiblePos( pThisEntry )) +1 );
5931 }
5932 break;
5933 case M_GetSelText :
5934 if ( ! (nParams & PARAM_USHORT_1) )
5935 nNr1 = 1;
5936 if ( ValueOK(aUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
5937 {
5938 nNr1--;
5939 COUNT_LBOX( FirstSelected, NextSelected, nNr1);
5940 GetFirstValidTextItem( pThisEntry );
5941 pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5942 }
5943 break;
5944 case M_GetItemCount :
5945 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(((SvLBox*)pControl)->GetVisibleCount()) );
5946 break;
5947 case M_GetItemText :
5948 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5949 {
5950 SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
5951 GetFirstValidTextItem( pEntry );
5952 pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
5953 }
5954 break;
5955 case M_Select :
5956 if ( ! (nParams & PARAM_BOOL_1) )
5957 bBool1 = sal_True;
5958 if( nParams & PARAM_STR_1 )
5959 {
5960 / * ListBox *pLB = ((ListBox*)pControl);
5961 if ( pLB->GetEntryPos( aString1 ) == LISTBOX_ENTRY_NOTFOUND )
5962 ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
5963 else
5964 {
5965 pLB->SelectEntry( aString1, bBool1 );
5966 if ( pLB->IsEntrySelected( aString1 ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL
5967 ReportError( aUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) );
5968 }
5969 * / ReportError( aUId, GEN_RES_STR1( S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED, MethodString( nMethodId ) ) );
5970 }
5971 else
5972 {
5973 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) )
5974 {
5975 SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 );
5976 ((SvTreeListBox*)pControl)->Select ( pEntry, bBool1 );
5977 }
5978 }
5979 break;*/
5980 default:
5981 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "EditBrowseBox" ) );
5982 break;
5983 }
5984 }
5985 break;
5986 case CONST_CTValueSet:
5987 {
5988 ValueSet *pVS = dynamic_cast< ValueSet* >(pControl);
5989 switch ( nMethodId )
5990 {
5991 case M_GetItemCount:
5992 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pVS->GetItemCount()));
5993 break;
5994 case M_GetItemText:
5995 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pVS->GetItemCount() ))
5996 pRet->GenReturn ( RET_Value, aUId, pVS->GetItemText( pVS->GetItemId( nNr1-1 ) ) );
5997 break;
5998 case M_Select:
5999 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pVS->GetItemCount() ))
6000 pVS->SelectItem( pVS->GetItemId( nNr1-1 ) );
6001 break;
6002 case M_GetSelIndex :
6003 if ( pVS->IsNoSelection() )
6004 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(0));
6005 else
6006 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pVS->GetItemPos( pVS->GetSelectItemId() ) +1));
6007 break;
6008 case M_GetSelText :
6009 if ( pVS->IsNoSelection() )
6010 pRet->GenReturn ( RET_Value, aUId, String() );
6011 else
6012 pRet->GenReturn ( RET_Value, aUId, pVS->GetItemText( pVS->GetSelectItemId() ) );
6013 break;
6014 case M_SetNoSelection :
6015 pVS->SetNoSelection();
6016 break;
6017 default:
6018 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ValueSet" ) );
6019 break;
6020 }
6021 }
6022 break;
6023 case CONST_CTORoadmap:
6024 {
6025 ORoadmap *pRM = dynamic_cast< ORoadmap* >(pControl);
6026 switch ( nMethodId )
6027 {
6028 case M_GetItemCount:
6029 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pRM->GetItemCount()));
6030 break;
6031 case M_GetItemText:
6032 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pRM->GetItemCount() ))
6033 pRet->GenReturn ( RET_Value, aUId, pRM->GetRoadmapItemLabel( pRM->GetItemID( nNr1-1 ) ) );
6034 break;
6035 case M_Select:
6036 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pRM->GetItemCount() ))
6037 {
6038 if ( pRM->IsRoadmapItemEnabled( pRM->GetItemID( nNr1-1 ) ) )
6039 pRM->SelectRoadmapItemByID( pRM->GetItemID( nNr1-1 ) );
6040 else
6041 ReportError( aUId, GEN_RES_STR1c( S_WIN_DISABLED, "RoadmapItem" ) );
6042 }
6043 break;
6044 case M_GetSelIndex :
6045 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pRM->GetItemIndex( pRM->GetCurrentRoadmapItemID() ) +1));
6046 break;
6047 case M_GetSelText :
6048 pRet->GenReturn ( RET_Value, aUId, pRM->GetRoadmapItemLabel( pRM->GetCurrentRoadmapItemID() ) );
6049 break;
6050 case M_IsItemEnabled :
6051 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pRM->GetItemCount() ))
6052 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)pRM->IsRoadmapItemEnabled( pRM->GetItemID( nNr1-1 ) ) );
6053 break;
6054 default:
6055 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RoadMap" ) );
6056 break;
6057 }
6058 }
6059 break;
6060 case CONST_CTIExtensionListBox:
6061 {
6062 IExtensionListBox *pELB = dynamic_cast< IExtensionListBox* >(pControl);
6063 switch ( nMethodId )
6064 {
6065 case M_GetItemCount:
6066 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pELB->getItemCount()));
6067 break;
6068 case M_GetItemText:
6069 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pELB->getItemCount() ))
6070 switch ( nNr2 )
6071 {
6072 case 1:
6073 pRet->GenReturn ( RET_Value, aUId, pELB->getItemName( nNr1 -1 ) );
6074 break;
6075 case 2:
6076 pRet->GenReturn ( RET_Value, aUId, pELB->getItemVersion( nNr1 -1 ) );
6077 break;
6078 case 3:
6079 pRet->GenReturn ( RET_Value, aUId, pELB->getItemDescription( nNr1 -1 ) );
6080 break;
6081 case 4:
6082 pRet->GenReturn ( RET_Value, aUId, pELB->getItemPublisher( nNr1 -1 ) );
6083 break;
6084 case 5:
6085 pRet->GenReturn ( RET_Value, aUId, pELB->getItemPublisherLink( nNr1 -1 ) );
6086 break;
6087 default:
6088 ValueOK( aUId, MethodString( nMethodId ).AppendAscii(" String Number"), nNr2, 5 );
6089 }
6090 break;
6091 case M_Select:
6092 if ( (nParams & PARAM_USHORT_1) )
6093 {
6094 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pELB->getItemCount() ))
6095 {
6096 pELB->select( nNr1-1 );
6097 }
6098 }
6099 else if ( (nParams & PARAM_STR_1) )
6100 {
6101 pELB->select( aString1 );
6102 sal_Bool bSuccess = sal_True;
6103 if ( pELB->getSelIndex() == EXTENSION_LISTBOX_ENTRY_NOTFOUND )
6104 bSuccess = sal_False;
6105 else
6106 {
6107 if ( !aString1.Equals( String( pELB->getItemName( pELB->getSelIndex() ) ) ) )
6108 bSuccess = sal_False;
6109 }
6110 if ( !bSuccess )
6111 ReportError( aUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) );
6112 }
6113 break;
6114 case M_GetSelCount :
6115 if ( pELB->getSelIndex() == EXTENSION_LISTBOX_ENTRY_NOTFOUND )
6116 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( 0 ));
6117 else
6118 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( 1 ));
6119 break;
6120 case M_GetSelIndex :
6121 if ( pELB->getSelIndex() == EXTENSION_LISTBOX_ENTRY_NOTFOUND )
6122 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( 0 ));
6123 else
6124 pRet->GenReturn ( RET_Value, aUId, comm_ULONG( pELB->getSelIndex() +1));
6125 break;
6126 /* xxxcase M_SetNoSelection :
6127 ((ListBox*)pControl)->SetNoSelection();
6128 ((ListBox*)pControl)->Select();
6129 break; */
6130 default:
6131 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RoadMap" ) );
6132 break;
6133 }
6134 }
6135 break;
6136
6137 case CONST_CTTableControl:
6138 {
6139 ::svt::table::TableControl *pTC = dynamic_cast< ::svt::table::TableControl* >(pControl);
6140 switch ( nMethodId )
6141 {
6142 case M_GetItemType :
6143 {
6144 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTC->GetColumnCount() ) &&
6145 ValueOK( aUId, MethodString( nMethodId ), nNr2, pTC->GetRowCount() ))
6146 {
6147 ::svt::table::PTableModel pModel = pTC->GetModel();
6148 Any aCell;
6149 pModel->getCellContent( nNr1-1, nNr2-1, aCell );
6150 pRet->GenReturn ( RET_Value, aUId, String( aCell.getValueTypeName() ));
6151 }
6152 }
6153 break;
6154 case M_GetItemText :
6155 {
6156 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTC->GetColumnCount() ) &&
6157 ValueOK( aUId, MethodString( nMethodId ), nNr2, pTC->GetRowCount() ))
6158 {
6159 ::svt::table::PTableModel pModel = pTC->GetModel();
6160 Any aCell;
6161 pModel->getCellContent( nNr1-1, nNr2-1, aCell );
6162 /* doesn't work ATM since it gets casted to SbxDATE in VCLTestTool unfortunately
6163 SbxVariableRef xRes = new SbxVariable( SbxVARIANT );
6164 unoToSbxValue( xRes, aCell );
6165 pRet->GenReturn ( RET_Value, aUId, *xRes );*/
6166
6167 Type aType = aCell.getValueType();
6168 TypeClass eTypeClass = aType.getTypeClass();
6169 switch( eTypeClass )
6170 {
6171 /*case TypeClass_ENUM:
6172 {
6173 sal_Int32 nEnum = 0;
6174 enum2int( nEnum, aValue );
6175 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)nEnum );
6176 }
6177 break;*/
6178 case TypeClass_BOOLEAN:
6179 pRet->GenReturn ( RET_Value, aUId, *(sal_Bool*)aCell.getValue() );
6180 break;
6181 case TypeClass_CHAR:
6182 {
6183 ::rtl::OUString aContent( *(sal_Unicode*)aCell.getValue() );
6184 pRet->GenReturn ( RET_Value, aUId, aContent );
6185 }
6186 break;
6187 case TypeClass_STRING:
6188 {
6189 ::rtl::OUString aContent;
6190 aCell >>= aContent;
6191 pRet->GenReturn ( RET_Value, aUId, aContent );
6192 }
6193 break;
6194 //case TypeClass_FLOAT: break;
6195 //case TypeClass_DOUBLE: break;
6196 //case TypeClass_OCTET: break;
6197 case TypeClass_BYTE:
6198 case TypeClass_SHORT:
6199 case TypeClass_LONG:
6200 case TypeClass_HYPER:
6201 case TypeClass_UNSIGNED_LONG:
6202 case TypeClass_UNSIGNED_HYPER:
6203 {
6204 comm_ULONG val = 0;
6205 aCell >>= val;
6206 pRet->GenReturn ( RET_Value, aUId, val );
6207 }
6208 break;
6209 //case TypeClass_UNSIGNED_OCTET:break;
6210 case TypeClass_UNSIGNED_SHORT:
6211 {
6212 comm_USHORT val = 0;
6213 aCell >>= val;
6214 pRet->GenReturn ( RET_Value, aUId, val );
6215 }
6216 break;
6217 default:
6218 pRet->GenReturn ( RET_Value, aUId, comm_USHORT(0) );
6219 break;
6220 }
6221 }
6222 }
6223 break;
6224 case M_GetColumnCount :
6225 {
6226 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTC->GetColumnCount() );
6227 }
6228 break;
6229 case M_GetRowCount :
6230 {
6231 pRet->GenReturn ( RET_Value, aUId, (comm_ULONG)pTC->GetRowCount() );
6232 }
6233 break;
6234 case M_Select :
6235 {
6236 if ( ValueOK( aUId, MethodString( nMethodId ), nNr1, pTC->GetRowCount() ))
6237 {
6238 if ( pTC->GoToRow( ::svt::table::RowPos( nNr1-1 ) ) )
6239 {
6240 Size aSize( pTC->GetSizePixel() );
6241 // DirectLog( S_QAError, UniString::CreateFromInt32( aSize.Width() ).Append( UniString::CreateFromInt32( aSize.Height() ) ) );
6242 Point aPos( aSize.Width() / 2, aSize.Height() / 2 );
6243 long nStep = aSize.Height() / 4;
6244 ::svt::table::RowPos nLastPos;
6245 while ( ( nLastPos = pTC->getTableControlInterface().hitTest( aPos ).nRow ) != nNr1-1 && nStep > 0 )
6246 {
6247 if ( nLastPos > nNr1-1 || nLastPos == ROW_INVALID )
6248 aPos.Y() -= nStep;
6249 else
6250 aPos.Y() += nStep;
6251 nStep /= 2;
6252 }
6253 if ( pTC->getTableControlInterface().hitTest( aPos ).nRow == nNr1-1 )
6254 {
6255 MouseEvent aMEvnt(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,MOUSE_LEFT,KEY_MOD1);
6256 pTC->getSelEngine()->SelMouseButtonDown( aMEvnt );
6257 pTC->getSelEngine()->SelMouseButtonUp( aMEvnt );
6258 if ( pTC->IsRowSelected( nNr1-1 ) )
6259 pTC->Select();
6260 }
6261 else
6262 ReportError( aUId, GEN_RES_STR2c2( S_METHOD_FAILED, MethodString( nMethodId ), "find pos" ) );
6263 }
6264 else
6265 ReportError( aUId, GEN_RES_STR2c2( S_METHOD_FAILED, MethodString( nMethodId ), "GoTo" ) );
6266 }
6267 }
6268 break;
6269 case M_GetSelCount :
6270 pRet->GenReturn ( RET_Value, aUId, comm_USHORT( pTC->GetSelectedRowCount() ));
6271 break;
6272 case M_GetSelIndex :
6273 if ( ! (nParams & PARAM_USHORT_1) )
6274 nNr1 = 1;
6275 if ( ValueOK( aUId, CUniString("GetSelIndex"), nNr1, pTC->GetSelectedRowCount() ) )
6276 pRet->GenReturn ( RET_Value, aUId, comm_USHORT( pTC->GetSelectedRowIndex( nNr1-1 ) +1 ) );
6277 break;
6278 /* case M_GetSelText :
6279 if ( ! (nParams & PARAM_USHORT_1) )
6280 nNr1 = 1;
6281 if ( ValueOK(aUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) )
6282 {
6283 nNr1--;
6284 COUNT_LBOX( FirstSelected, NextSelected, nNr1);
6285 GetFirstValidTextItem( pThisEntry );
6286 pRet->GenReturn ( RET_Value, aUId, pItem->GetText() );
6287 }
6288 break;
6289 */
6290 default:
6291 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TableControl" ) );
6292 break;
6293 }
6294 }
6295 break;
6296
6297 case CONST_CTUnknown:
6298 ReportError( aUId, GEN_RES_STR2( S_UNKNOWN_TYPE, UniString::CreateFromInt32( nRT ), MethodString(nMethodId) ) );
6299 break;
6300 default:
6301 ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
6302 break;
6303 }
6304 }
6305 break;
6306 }
6307 case C_Window:
6308 switch( nMethodId )
6309 {
6310 case M_AnimateMouse :
6311 AnimateMouse( pControl, MitteOben);
6312 break;
6313 default:
6314 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Window" ) );
6315 break;
6316 }
6317 break;
6318
6319 case C_DockingWin:
6320 DockingWin:
6321 switch( nMethodId )
6322 {
6323 case M_AnimateMouse :
6324 AnimateMouse( pControl, MitteOben);
6325 break;
6326 case M_Dock :
6327 if ( ((DockingWindow*)pControl)->IsFloatingMode() )
6328 ((DockingWindow*)pControl)->SetFloatingMode(sal_False);
6329 else
6330 ReportError( aUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
6331 break;
6332 case M_Undock :
6333 if ( !((DockingWindow*)pControl)->IsFloatingMode() )
6334 ((DockingWindow*)pControl)->SetFloatingMode(sal_True);
6335 else
6336 ReportError( aUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
6337 break;
6338 case M_IsDocked :
6339 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL) !((DockingWindow*)pControl)->IsFloatingMode());
6340 break;
6341 case M_Close:
6342 //aWindowWaitUId = aUId;
6343 DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6344 SET_WINP_CLOSING(pControl);
6345 ((DockingWindow*)pControl)->Close();
6346 break;
6347 case M_Size:
6348 case M_Move:
6349 case M_IsMax:
6350 case M_Minimize:
6351 case M_Maximize:
6352 if ( ((DockingWindow*)pControl)->IsFloatingMode() )
6353 {
6354 Window* pFloat = ((DockingWindow*)pControl)->GetFloatingWindow();
6355 if ( !pFloat && ((DockingWindow*)pControl)->IsFloatingMode() )
6356 {
6357 if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW )
6358 pFloat = pControl->GET_REAL_PARENT();
6359 else
6360 {
6361 DBG_ERROR("FloatingMode set but Parent is no FloatingWindow");
6362 }
6363 }
6364 if ( pFloat && pFloat->GetType() == WINDOW_FLOATINGWINDOW )
6365 {
6366 pControl = pFloat;
6367 goto FloatWin;
6368 }
6369 else
6370 ReportError( aUId, GEN_RES_STR1( S_CANNOT_FIND_FLOATING_WIN, MethodString( nMethodId ) ) );
6371 }
6372 else
6373 ReportError( aUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_DOCKING_MODE, MethodString( nMethodId ) ) );
6374 break;
6375 case M_Help: // Everything to be treated below
6376 goto MoreDialog;
6377
6378 default:
6379 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "DockingWindow" ) );
6380 break;
6381 }
6382 break;
6383 case C_FloatWin:
6384 FloatWin:
6385 switch( nMethodId )
6386 {
6387 case M_AnimateMouse :
6388 AnimateMouse( pControl, MitteOben);
6389 break;
6390 case M_IsMax :
6391 pRet->GenReturn ( RET_Value, aUId, (comm_BOOL)!((FloatingWindow*)pControl)->IsRollUp());
6392 break;
6393 case M_Minimize :
6394 ((FloatingWindow*)pControl)->RollUp();
6395 break;
6396 case M_Maximize :
6397 ((FloatingWindow*)pControl)->RollDown();
6398 break;
6399 case M_Size:
6400 {
6401 if ( pControl->GetStyle() & WB_SIZEABLE )
6402 {
6403 Size aMin = ((FloatingWindow*)pControl)->GetMinOutputSizePixel();
6404 if ( aMin.Width() <= nNr1 && aMin.Height() <= nNr2 )
6405 {
6406 pControl->SetSizePixel(Size(nNr1,nNr2));
6407 pControl->Resize();
6408 }
6409 else
6410 {
6411 ReportError( aUId, GEN_RES_STR2( S_SIZE_BELOW_MINIMUM, String::CreateFromInt32( aMin.Width() ), String::CreateFromInt32( aMin.Height() ) ) );
6412 }
6413 }
6414 else
6415 ReportError( aUId, GEN_RES_STR1( S_SIZE_NOT_CHANGEABLE, MethodString( nMethodId ) ) );
6416 break;
6417 }
6418 case M_Close:
6419 DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6420 SET_WINP_CLOSING(pControl);
6421 ((FloatingWindow*)pControl)->Close();
6422 break;
6423 case M_Help: // Everything to be treated below
6424 case M_Move:
6425 goto MoreDialog;
6426 default:
6427 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "FloatingWin" ) );
6428 break;
6429 }
6430 break;
6431 case C_ModelessDlg:
6432 case C_ModalDlg:
6433 case C_Dialog:
6434 case C_TabDlg:
6435 MoreDialog:
6436 switch( nMethodId )
6437 {
6438 case M_AnimateMouse :
6439 AnimateMouse( pControl, MitteOben);
6440 break;
6441 case M_Close:
6442 DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6443 SET_WINP_CLOSING(pControl);
6444 ((SystemWindow*)pControl)->Close();
6445 break;
6446 case M_OK:
6447 {
6448 Window *pChild = GetWinByRT( pControl, WINDOW_OKBUTTON );
6449 if( ControlOK( pChild, "OK Button" ) )
6450 {
6451 DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6452 SET_WINP_CLOSING(pControl);
6453 ((Button*)pChild)->Click();
6454 }
6455 break;
6456 }
6457 case M_Cancel:
6458 {
6459 Window *pChild = GetWinByRT( pControl, WINDOW_CANCELBUTTON );
6460 if( ControlOK( pChild, "Cancel Button" ) )
6461 {
6462 DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6463 SET_WINP_CLOSING(pControl);
6464 ((Button*)pChild)->Click();
6465 }
6466 break;
6467 }
6468 case M_Help:
6469 {
6470 Window *pChild = GetWinByRT( pControl, WINDOW_HELPBUTTON );
6471 if( ControlOK( pChild, "Help Button" ) )
6472 ((Button*)pChild)->Click();
6473 break;
6474 }
6475 case M_Default:
6476 {
6477 Window *pChild = ImpGetButton( pControl, WB_DEFBUTTON, WB_DEFBUTTON );
6478 if( ControlOK( pChild, "Default Button" ) )
6479 ((Button*)pChild)->Click();
6480 break;
6481 }
6482 case M_Move:
6483 {
6484 pControl->SetPosPixel(Point(nNr1,nNr2));
6485 break;
6486 }
6487 default:
6488 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Dialog" ) );
6489 break;
6490 }
6491 break;
6492 case C_WorkWin:
6493 switch( nMethodId )
6494 {
6495 case M_AnimateMouse :
6496 AnimateMouse( pControl, MitteOben);
6497 break;
6498 case M_Close:
6499 DBG_ASSERT( aUId.equals( pControl->GetUniqueOrHelpId() ), "aUID != UniqueOrHelpId");
6500 SET_WINP_CLOSING(pControl);
6501 ((WorkWindow*)pControl)->Close();
6502 break;
6503 case M_Size:
6504 case M_Move:
6505 goto FloatWin;
6506 // break;
6507 case M_IsMax :
6508 pRet->GenReturn ( RET_Value, aUId, ((WorkWindow*)pControl)->IsMaximized() );
6509 break;
6510 case M_IsMin :
6511 pRet->GenReturn ( RET_Value, aUId, ((WorkWindow*)pControl)->IsMinimized() );
6512 break;
6513 case M_IsRestore :
6514 pRet->GenReturn ( RET_Value, aUId, comm_BOOL (!((WorkWindow*)pControl)->IsMaximized() && !((WorkWindow*)pControl)->IsMinimized()) );
6515 break;
6516 case M_Minimize :
6517 ((WorkWindow*)pControl)->Maximize( sal_False );
6518 ((WorkWindow*)pControl)->Minimize();
6519 break;
6520 case M_Maximize :
6521 ((WorkWindow*)pControl)->Maximize();
6522 break;
6523 case M_Restore :
6524 ((WorkWindow*)pControl)->Maximize( sal_False );
6525 ((WorkWindow*)pControl)->Restore();
6526 break;
6527 case M_Help: // Everything to be treated below
6528 goto MoreDialog;
6529 default:
6530 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "WorkWindow" ) );
6531 break;
6532 }
6533 break;
6534 case C_TabPage:
6535 ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
6536 break;
6537 case C_MessBox:
6538 case C_InfoBox:
6539 case C_WarningBox:
6540 case C_ErrorBox:
6541 case C_QueryBox:
6542 {
6543 sal_Bool bDone = sal_True;
6544 MessBox* pMB = (MessBox*)pControl;
6545 switch( nMethodId )
6546 {
6547 case M_GetCheckBoxText:
6548 pRet->GenReturn ( RET_Value, aUId, pMB->GetCheckBoxText() );
6549 break;
6550 case M_IsChecked :
6551 pRet->GenReturn ( RET_Value, aUId, comm_BOOL( pMB->GetCheckBoxState() == STATE_CHECK) );
6552 break;
6553 case M_Check :
6554 pMB->SetCheckBoxState( sal_True );
6555 break;
6556 case M_UnCheck :
6557 pMB->SetCheckBoxState( sal_False );
6558 break;
6559 case M_GetText :
6560 pRet->GenReturn ( RET_Value, aUId, pMB->GetMessText());
6561 break;
6562
6563 default:
6564 bDone = sal_False;
6565 break;
6566 }
6567 if ( bDone )
6568 break; // break the case here else continue at C_ButtonDialog
6569 }
6570 case C_ButtonDialog:
6571 {
6572 ButtonDialog* pBD = (ButtonDialog*)pControl;
6573 #if OSL_DEBUG_LEVEL > 1
6574 m_pDbgWin->AddText( "Working MessBox: " );
6575 if (pControl->IsVisible())
6576 m_pDbgWin->AddText("*(Visible)\n");
6577 else
6578 m_pDbgWin->AddText("*(nicht Visible)\n");
6579 #endif
6580 switch( nMethodId )
6581 {
6582 case M_AnimateMouse :
6583 AnimateMouse( pControl, Mitte);
6584 break;
6585 case M_OK:
6586 if ( pBD->GetPushButton( BUTTONID_OK ) )
6587 {
6588 SET_WINP_CLOSING(pControl);
6589 pBD->EndDialog(RET_OK);
6590 }
6591 else
6592 ReportError( aUId, GEN_RES_STR1( S_NO_OK_BUTTON, MethodString( nMethodId ) ) );
6593 break;
6594 case M_Cancel:
6595 if ( pBD->GetPushButton( BUTTONID_CANCEL ) )
6596 {
6597 SET_WINP_CLOSING(pControl);
6598 pBD->EndDialog(RET_CANCEL);
6599 }
6600 else
6601 ReportError( aUId, GEN_RES_STR1( S_NO_CANCEL_BUTTON, MethodString( nMethodId ) ) );
6602 break;
6603 case M_Yes:
6604 if ( pBD->GetPushButton( BUTTONID_YES ) )
6605 {
6606 SET_WINP_CLOSING(pControl);
6607 pBD->EndDialog(RET_YES);
6608 }
6609 else
6610 ReportError( aUId, GEN_RES_STR1( S_NO_YES_BUTTON, MethodString( nMethodId ) ) );
6611 break;
6612 case M_No:
6613 if ( pBD->GetPushButton( BUTTONID_NO ) )
6614 {
6615 SET_WINP_CLOSING(pControl);
6616 pBD->EndDialog(RET_NO);
6617 }
6618 else
6619 ReportError( aUId, GEN_RES_STR1( S_NO_NO_BUTTON, MethodString( nMethodId ) ) );
6620 break;
6621 case M_Repeat:
6622 if ( pBD->GetPushButton( BUTTONID_RETRY ) )
6623 {
6624 SET_WINP_CLOSING(pControl);
6625 pBD->EndDialog(RET_RETRY);
6626 }
6627 else
6628 ReportError( aUId, GEN_RES_STR1( S_NO_RETRY_BUTTON, MethodString( nMethodId ) ) );
6629 break;
6630 case M_Help:
6631 if ( pBD->GetPushButton( BUTTONID_HELP ) )
6632 {
6633 SET_WINP_CLOSING(pControl);
6634 pBD->EndDialog(BUTTONID_HELP);
6635 }
6636 else
6637 ReportError( aUId, GEN_RES_STR1( S_NO_HELP_BUTTON, MethodString( nMethodId ) ) );
6638 break;
6639 case M_Default:
6640 {
6641 WinBits Style = pControl->GetStyle();
6642 if ( Style & WB_DEF_OK )
6643 {
6644 SET_WINP_CLOSING(pControl);
6645 pBD->EndDialog(RET_OK);
6646 }
6647 else if ( Style & WB_DEF_CANCEL )
6648 {
6649 SET_WINP_CLOSING(pControl);
6650 pBD->EndDialog(RET_CANCEL);
6651 }
6652 else if ( Style & WB_DEF_YES )
6653 {
6654 SET_WINP_CLOSING(pControl);
6655 pBD->EndDialog(RET_YES);
6656 }
6657 else if ( Style & WB_DEF_NO )
6658 {
6659 SET_WINP_CLOSING(pControl);
6660 pBD->EndDialog(RET_NO);
6661 }
6662 else if ( Style & WB_DEF_RETRY )
6663 {
6664 SET_WINP_CLOSING(pControl);
6665 pBD->EndDialog(RET_RETRY);
6666 }
6667 else
6668 ReportError( aUId, GEN_RES_STR1( S_NO_DEFAULT_BUTTON, MethodString( nMethodId ) ) );
6669 }
6670 break;
6671 case M_GetText :
6672 pRet->GenReturn ( RET_Value, aUId, pControl->GetText());
6673 break;
6674 case M_Click:
6675 if ( nParams & PARAM_USHORT_1 )
6676 {
6677 if ( pBD->GetPushButton( nNr1 ) )
6678 {
6679 if ( nNr1 != BUTTONID_HELP )
6680 {
6681 SET_WINP_CLOSING(pControl);
6682 }
6683 pBD->GetPushButton( nNr1 )->Click();
6684 }
6685 else
6686 ReportError( aUId, GEN_RES_STR2( S_NO_DEFAULT_BUTTON, UniString::CreateFromInt32( nNr1 ), MethodString( nMethodId ) ) );
6687 }
6688 else
6689 ReportError( aUId, GEN_RES_STR1( S_BUTTONID_REQUIRED, MethodString( nMethodId ) ) );
6690 break;
6691 case M_GetButtonCount :
6692 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pBD->GetButtonCount()));
6693 break;
6694 case M_GetButtonId :
6695 if ( ValueOK(aUId, MethodString( nMethodId ),nNr1,pBD->GetButtonCount()) )
6696 pRet->GenReturn ( RET_Value, aUId, comm_ULONG(pBD->GetButtonId(nNr1-1)));
6697 break;
6698 default:
6699 ReportError( aUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MessageBox" ) );
6700 break;
6701 }
6702 break;
6703 }
6704 default:
6705 DBG_ERROR( "Unknown object type from UId or Method not supported" );
6706 ReportError( aUId, GEN_RES_STR2( S_UNKNOWN_TYPE, UniString::CreateFromInt32( nRT ), MethodString(nMethodId) ) );
6707 #if OSL_DEBUG_LEVEL > 1
6708 m_pDbgWin->AddText( " Unknown object type from UId or Method not supported" );
6709 #endif
6710 break;
6711 }
6712 }
6713 for( int i = 0; i < 32; i++ )
6714 SafeReschedule();
6715 }
6716 #if OSL_DEBUG_LEVEL > 1
6717 m_pDbgWin->AddText( "\n" );
6718 #endif
6719 if ( bStatementDone )
6720 {
6721 SendProfile( UIdString( aUId ).Append('.').Append( MethodString( nMethodId ) ) );
6722 delete this;
6723 }
6724 else
6725 {
6726 if ( nRetryCount-- )
6727 {
6728 #if OSL_DEBUG_LEVEL > 1
6729 m_pDbgWin->AddText( CUniString("Reschedule command (requed) (").Append( UniString::CreateFromInt32(nRetryCount) ).AppendAscii(")\n") );
6730 #endif
6731 QueStatement( this ); // will que at the start of the list
6732 }
6733 else
6734 {
6735 bStatementDone=sal_True;
6736 }
6737 }
6738 return bStatementDone;
6739
6740 #define FINISH_NEXT
6741 #define FINISH_SAME
6742
6743 }
6744
6745 /* vim: set noet sw=4 ts=4: */
6746