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