merge the formfield patch from ooo-build
[ooovba.git] / idl / source / objects / slot.cxx
blob28ef205d71072a794acac2829dde45be900f58de
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: slot.cxx,v $
10 * $Revision: 1.20 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_idl.hxx"
34 #include <ctype.h>
35 #include <stdio.h>
36 #include <tools/debug.hxx>
37 #include <attrib.hxx>
38 #include <slot.hxx>
39 #include <globals.hxx>
40 #include <database.hxx>
42 /****************** SvMetaSlot *****************************************/
43 SV_IMPL_META_FACTORY1( SvMetaSlot, SvMetaAttribute );
45 SvMetaObject *SvMetaSlot::MakeClone() const
47 return new SvMetaSlot( *this );
50 /*************************************************************************
51 |* SvMetaSlot::SvMetaSlot()
53 |* Beschreibung Zweites FALSE bei den SvBOOL-Objekten bedeutet,
54 |* IsSet() liefert FALSE (Defaultinitialisierung).
55 *************************************************************************/
56 SvMetaSlot::SvMetaSlot()
57 : aCachable( TRUE, FALSE )
58 , aSynchron( TRUE, FALSE )
59 , aRecordPerSet( TRUE, FALSE )
60 , aRecordAbsolute( FALSE, FALSE )
61 , pLinkedSlot(0)
62 , pNextSlot(0)
63 , pEnumValue(0)
67 SvMetaSlot::SvMetaSlot( SvMetaType * pType )
68 : SvMetaAttribute( pType )
69 , aCachable( TRUE, FALSE )
70 , aSynchron( TRUE, FALSE )
71 , aRecordPerSet( TRUE, FALSE )
72 , aRecordAbsolute( FALSE, FALSE )
73 , pLinkedSlot(0)
74 , pNextSlot(0)
75 , pEnumValue(0)
80 #define TEST_READ \
81 { \
82 UINT32 nPos; \
83 rStm >> nPos; \
84 DBG_ASSERT( nPos +4 == rStm.Tell(), "stream pos error" ); \
87 #define TEST_WRITE \
88 rStm << (UINT32)rStm.Tell();
90 #define TEST_READ
91 #define TEST_WRITE
93 void SvMetaSlot::Load( SvPersistStream & rStm )
95 SvMetaAttribute::Load( rStm );
97 USHORT nMask;
98 rStm >> nMask;
100 TEST_READ
101 if( nMask & 0x0001 )
103 SvMetaAttribute * pMeth;
104 rStm >> pMeth;
105 aMethod = pMeth;
108 TEST_READ
109 if( nMask & 0x0002 ) rStm >> aGroupId;
110 TEST_READ
111 if( nMask & 0x0004 ) rStm >> aHasCoreId;
112 TEST_READ
113 if( nMask & 0x0008 ) rStm >> aConfigId;
114 TEST_READ
115 if( nMask & 0x0010 ) rStm >> aExecMethod;
116 TEST_READ
117 if( nMask & 0x0020 ) rStm >> aStateMethod;
118 TEST_READ
119 if( nMask & 0x0040 ) rStm >> aDefault;
120 TEST_READ
121 if( nMask & 0x0080 ) rStm >> aPseudoSlots;
122 TEST_READ
123 if( nMask & 0x0100 ) rStm >> aGet;
124 TEST_READ
125 if( nMask & 0x0200 ) rStm >> aSet;
126 TEST_READ
127 if( nMask & 0x0400 ) rStm >> aCachable;
128 TEST_READ
129 if( nMask & 0x0800 ) rStm >> aVolatile;
130 TEST_READ
131 if( nMask & 0x1000 ) rStm >> aToggle;
132 TEST_READ
133 if( nMask & 0x2000 ) rStm >> aAutoUpdate;
134 TEST_READ
135 if( nMask & 0x4000 ) rStm >> aSynchron;
136 TEST_READ
137 if( nMask & 0x8000 ) rStm >> aAsynchron;
139 nMask = 0;
140 rStm >> nMask;
142 TEST_READ
143 if( nMask & 0x0001 ) rStm >> aRecordPerItem;
144 TEST_READ
145 if( nMask & 0x0002 ) rStm >> aRecordManual;
146 TEST_READ
147 if( nMask & 0x0004 ) rStm >> aNoRecord;
148 TEST_READ
149 if( nMask & 0x0008 ) rStm >> aHasDialog;
150 TEST_READ
151 if( nMask & 0x0010 ) rStm >> aDisableFlags;
152 TEST_READ
153 if( nMask & 0x0020 ) rStm >> aPseudoPrefix;
154 TEST_READ
155 if( nMask & 0x0040 ) rStm >> aRecordPerSet;
156 TEST_READ
157 if( nMask & 0x0080 ) rStm >> aMenuConfig;
158 TEST_READ
159 if( nMask & 0x0100 ) rStm >> aToolBoxConfig;
160 TEST_READ
161 if( nMask & 0x0200 ) rStm >> aStatusBarConfig;
162 TEST_READ
163 if( nMask & 0x0400 ) rStm >> aAccelConfig;
164 TEST_READ
165 if( nMask & 0x0800 ) rStm >> aFastCall;
166 TEST_READ
167 if( nMask & 0x1000 ) rStm >> aContainer;
168 TEST_READ
170 if( nMask & 0x2000 )
172 SvMetaType * pT;
173 rStm >> pT;
174 aSlotType = pT;
177 TEST_READ
178 if( nMask & 0x4000 ) rStm >> aRecordAbsolute;
179 TEST_READ
180 if( nMask & 0x8000 ) rStm >> aImageRotation;
182 nMask = 0;
183 rStm >> nMask;
185 TEST_READ
186 if( nMask & 0x0001 ) rStm >> aUnoName;
187 if( nMask & 0x0002 ) rStm >> aImageReflection;
190 void SvMetaSlot::Save( SvPersistStream & rStm )
192 SvMetaAttribute::Save( rStm );
194 // Maske erstellen
195 USHORT nMask = 0;
196 if( aMethod.Is() ) nMask |= 0x0001;
197 if( aGroupId.Len() ) nMask |= 0x0002;
198 if( aHasCoreId.IsSet() ) nMask |= 0x0004;
199 if( aConfigId.Len() ) nMask |= 0x0008;
200 if( aExecMethod.Len() ) nMask |= 0x0010;
201 if( aStateMethod.Len() ) nMask |= 0x0020;
202 if( aDefault.Len() ) nMask |= 0x0040;
203 if( aPseudoSlots.IsSet() ) nMask |= 0x0080;
204 if( aGet.IsSet() ) nMask |= 0x0100;
205 if( aSet.IsSet() ) nMask |= 0x0200;
206 if( aCachable.IsSet() ) nMask |= 0x0400;
207 if( aVolatile.IsSet() ) nMask |= 0x0800;
208 if( aToggle.IsSet() ) nMask |= 0x1000;
209 if( aAutoUpdate.IsSet() ) nMask |= 0x2000;
210 if( aSynchron.IsSet() ) nMask |= 0x4000;
211 if( aAsynchron.IsSet() ) nMask |= 0x8000;
213 // Daten schreiben
214 rStm << nMask;
215 TEST_WRITE
216 if( nMask & 0x0001 ) rStm << aMethod;
217 TEST_WRITE
218 if( nMask & 0x0002 ) rStm << aGroupId;
219 TEST_WRITE
220 if( nMask & 0x0004 ) rStm << aHasCoreId;
221 TEST_WRITE
222 if( nMask & 0x0008 ) rStm << aConfigId;
223 TEST_WRITE
224 if( nMask & 0x0010 ) rStm << aExecMethod;
225 TEST_WRITE
226 if( nMask & 0x0020 ) rStm << aStateMethod;
227 TEST_WRITE
228 if( nMask & 0x0040 ) rStm << aDefault;
229 TEST_WRITE
230 if( nMask & 0x0080 ) rStm << aPseudoSlots;
231 TEST_WRITE
232 if( nMask & 0x0100 ) rStm << aGet;
233 TEST_WRITE
234 if( nMask & 0x0200 ) rStm << aSet;
235 TEST_WRITE
236 if( nMask & 0x0400 ) rStm << aCachable;
237 TEST_WRITE
238 if( nMask & 0x0800 ) rStm << aVolatile;
239 TEST_WRITE
240 if( nMask & 0x1000 ) rStm << aToggle;
241 TEST_WRITE
242 if( nMask & 0x2000 ) rStm << aAutoUpdate;
243 TEST_WRITE
244 if( nMask & 0x4000 ) rStm << aSynchron;
245 TEST_WRITE
246 if( nMask & 0x8000 ) rStm << aAsynchron;
248 // naechste Fuhre schreiben
249 // Maske erstellen
250 nMask = 0;
251 if( aRecordPerItem.IsSet() ) nMask |= 0x0001;
252 if( aRecordManual.IsSet() ) nMask |= 0x0002;
253 if( aNoRecord.IsSet() ) nMask |= 0x0004;
254 if( aHasDialog.IsSet() ) nMask |= 0x0008;
255 if ( aDisableFlags.IsSet() ) nMask |= 0x0010;
256 if( aPseudoPrefix.Len() ) nMask |= 0x0020;
257 if( aRecordPerSet.IsSet() ) nMask |= 0x0040;
258 if( aMenuConfig.IsSet() ) nMask |= 0x0080;
259 if( aToolBoxConfig.IsSet() ) nMask |= 0x0100;
260 if( aStatusBarConfig.IsSet() )nMask |= 0x0200;
261 if( aAccelConfig.IsSet() ) nMask |= 0x0400;
262 if( aFastCall.IsSet() ) nMask |= 0x0800;
263 if( aContainer.IsSet() ) nMask |= 0x1000;
264 if( aSlotType.Is() ) nMask |= 0x2000;
265 if( aRecordAbsolute.IsSet() ) nMask |= 0x4000;
266 if( aImageRotation.IsSet() ) nMask |= 0x8000;
268 // Daten schreiben
269 rStm << nMask;
270 TEST_WRITE
271 if( nMask & 0x0001 ) rStm << aRecordPerItem;
272 TEST_WRITE
273 if( nMask & 0x0002 ) rStm << aRecordManual;
274 TEST_WRITE
275 if( nMask & 0x0004 ) rStm << aNoRecord;
276 TEST_WRITE
277 if( nMask & 0x0008 ) rStm << aHasDialog;
278 TEST_WRITE
279 if( nMask & 0x0010 ) rStm << aDisableFlags;
280 TEST_WRITE
281 if( nMask & 0x0020 ) rStm << aPseudoPrefix;
282 TEST_WRITE
283 if( nMask & 0x0040 ) rStm << aRecordPerSet;
284 TEST_WRITE
285 if( nMask & 0x0080 ) rStm << aMenuConfig;
286 TEST_WRITE
287 if( nMask & 0x0100 ) rStm << aToolBoxConfig;
288 TEST_WRITE
289 if( nMask & 0x0200 ) rStm << aStatusBarConfig;
290 TEST_WRITE
291 if( nMask & 0x0400 ) rStm << aAccelConfig;
292 TEST_WRITE
293 if( nMask & 0x0800 ) rStm << aFastCall;
294 TEST_WRITE
295 if( nMask & 0x1000 ) rStm << aContainer;
296 TEST_WRITE
297 if( nMask & 0x2000 ) rStm << aSlotType;
298 TEST_WRITE
299 if( nMask & 0x4000 ) rStm << aRecordAbsolute;
300 TEST_WRITE
301 if( nMask & 0x8000 ) rStm << aImageRotation;
303 nMask = 0;
304 if( aUnoName.IsSet() ) nMask |= 0x0001;
305 if( aImageReflection.IsSet() ) nMask |= 0x0002;
306 rStm << nMask;
307 TEST_WRITE
308 if( nMask & 0x0001 ) rStm << aUnoName;
309 TEST_WRITE
310 if( nMask & 0x0002 ) rStm << aImageReflection;
313 /*************************************************************************
314 |* SvMetaSlot::IsVariable()
316 |* Beschreibung
317 *************************************************************************/
318 BOOL SvMetaSlot::IsVariable() const
320 return SvMetaAttribute::IsVariable();
323 /*************************************************************************
324 |* SvMetaSlot::IsMethod()
326 |* Beschreibung
327 *************************************************************************/
328 BOOL SvMetaSlot::IsMethod() const
330 BOOL b = SvMetaAttribute::IsMethod();
331 b |= NULL != GetMethod();
332 return b;
335 /*************************************************************************
336 |* SvMetaSlot::HasMethods()
338 |* Beschreibung
339 *************************************************************************/
340 ByteString SvMetaSlot::GetMangleName( BOOL bVariable ) const
342 if( !bVariable )
344 SvMetaAttribute * pMeth = GetMethod();
345 if( pMeth )
346 return pMeth->GetName();
348 return GetName();
351 /*************************************************************************
352 |* Referenz
354 |* Beschreibung Zweites FALSE bei den SvBOOL-Objekten bedeutet,
355 |* IsSet() liefert FALSE (Defaultinitialisierung).
356 *************************************************************************/
357 /** Referenz Aufloesung **/
358 SvMetaType * SvMetaSlot::GetSlotType() const
360 if( aSlotType.Is() || !GetRef() ) return aSlotType;
361 return ((SvMetaSlot *)GetRef())->GetSlotType();
363 SvMetaAttribute * SvMetaSlot::GetMethod() const
365 if( aMethod.Is() || !GetRef() ) return aMethod;
366 return ((SvMetaSlot *)GetRef())->GetMethod();
368 BOOL SvMetaSlot::GetHasCoreId() const
370 if( aHasCoreId.IsSet() || !GetRef() ) return aHasCoreId;
371 return ((SvMetaSlot *)GetRef())->GetHasCoreId();
373 const ByteString & SvMetaSlot::GetGroupId() const
375 if( aGroupId.Len() || !GetRef() ) return aGroupId;
376 return ((SvMetaSlot *)GetRef())->GetGroupId();
378 const ByteString & SvMetaSlot::GetDisableFlags() const
380 if( aDisableFlags.Len() || !GetRef() ) return aDisableFlags;
381 return ((SvMetaSlot *)GetRef())->GetDisableFlags();
383 const ByteString & SvMetaSlot::GetConfigId() const
385 if( aConfigId.Len() || !GetRef() ) return aConfigId;
386 return ((SvMetaSlot *)GetRef())->GetConfigId();
388 const ByteString & SvMetaSlot::GetExecMethod() const
390 if( aExecMethod.Len() || !GetRef() ) return aExecMethod;
391 return ((SvMetaSlot *)GetRef())->GetExecMethod();
393 const ByteString & SvMetaSlot::GetStateMethod() const
395 if( aStateMethod.Len() || !GetRef() ) return aStateMethod;
396 return ((SvMetaSlot *)GetRef())->GetStateMethod();
398 const ByteString & SvMetaSlot::GetDefault() const
400 if( aDefault.Len() || !GetRef() ) return aDefault;
401 return ((SvMetaSlot *)GetRef())->GetDefault();
403 BOOL SvMetaSlot::GetPseudoSlots() const
405 if( aPseudoSlots.IsSet() || !GetRef() ) return aPseudoSlots;
406 return ((SvMetaSlot *)GetRef())->GetPseudoSlots();
409 BOOL SvMetaSlot::GetGet() const
411 if( aGet.IsSet() || !GetRef() ) return aGet;
412 return ((SvMetaSlot *)GetRef())->GetGet();
414 BOOL SvMetaSlot::GetSet() const
416 if( aSet.IsSet() || !GetRef() ) return aSet;
417 return ((SvMetaSlot *)GetRef())->GetSet();
420 BOOL SvMetaSlot::GetCachable() const
422 // Cachable und Volatile sind exclusiv
423 if( !GetRef() || aCachable.IsSet() || aVolatile.IsSet() )
424 return aCachable;
425 return ((SvMetaSlot *)GetRef())->GetCachable();
427 BOOL SvMetaSlot::GetVolatile() const
429 // Cachable und Volatile sind exclusiv
430 if( !GetRef() || aVolatile.IsSet() || aCachable.IsSet() )
431 return aVolatile;
432 return ((SvMetaSlot *)GetRef())->GetVolatile();
434 BOOL SvMetaSlot::GetToggle() const
436 if( aToggle.IsSet() || !GetRef() ) return aToggle;
437 return ((SvMetaSlot *)GetRef())->GetToggle();
439 BOOL SvMetaSlot::GetAutoUpdate() const
441 if( aAutoUpdate.IsSet() || !GetRef() ) return aAutoUpdate;
442 return ((SvMetaSlot *)GetRef())->GetAutoUpdate();
444 BOOL SvMetaSlot::GetSynchron() const
446 // Synchron und Asynchron sind exclusiv
447 if( !GetRef() || aSynchron.IsSet() || aAsynchron.IsSet() )
448 return aSynchron;
449 return ((SvMetaSlot *)GetRef())->GetSynchron();
451 BOOL SvMetaSlot::GetAsynchron() const
453 // Synchron und Asynchron sind exclusiv
454 if( !GetRef() || aAsynchron.IsSet() || aSynchron.IsSet() )
455 return aAsynchron;
456 return ((SvMetaSlot *)GetRef())->GetAsynchron();
458 BOOL SvMetaSlot::GetRecordPerItem() const
460 // Record- PerItem, No, PerSet und Manual sind exclusiv
461 if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet()
462 || aRecordPerSet.IsSet() || aRecordManual.IsSet() )
463 return aRecordPerItem;
464 return ((SvMetaSlot *)GetRef())->GetRecordPerItem();
466 BOOL SvMetaSlot::GetRecordPerSet() const
468 // Record- PerItem, No, PerSet und Manual sind exclusiv
469 if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet()
470 || aRecordPerSet.IsSet() || aRecordManual.IsSet() )
471 return aRecordPerSet;
472 return ((SvMetaSlot *)GetRef())->GetRecordPerSet();
474 BOOL SvMetaSlot::GetRecordManual() const
476 // Record- PerItem, No, PerSet und Manual sind exclusiv
477 if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet()
478 || aRecordPerSet.IsSet() || aRecordManual.IsSet() )
479 return aRecordManual;
480 return ((SvMetaSlot *)GetRef())->GetRecordManual();
482 BOOL SvMetaSlot::GetNoRecord() const
484 // Record- PerItem, No, PerSet und Manual sind exclusiv
485 if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet()
486 || aRecordPerSet.IsSet() || aRecordManual.IsSet() )
487 return aNoRecord;
488 return ((SvMetaSlot *)GetRef())->GetNoRecord();
490 BOOL SvMetaSlot::GetRecordAbsolute() const
492 if( !GetRef() || aRecordAbsolute.IsSet() )
493 return aRecordAbsolute;
494 return ((SvMetaSlot *)GetRef())->GetRecordAbsolute();
496 BOOL SvMetaSlot::GetHasDialog() const
498 if( aHasDialog.IsSet() || !GetRef() ) return aHasDialog;
499 return ((SvMetaSlot *)GetRef())->GetHasDialog();
501 const ByteString & SvMetaSlot::GetPseudoPrefix() const
503 if( aPseudoPrefix.Len() || !GetRef() ) return aPseudoPrefix;
504 return ((SvMetaSlot *)GetRef())->GetPseudoPrefix();
506 BOOL SvMetaSlot::GetMenuConfig() const
508 if( aMenuConfig.IsSet() || !GetRef() ) return aMenuConfig;
509 return ((SvMetaSlot *)GetRef())->GetMenuConfig();
511 BOOL SvMetaSlot::GetToolBoxConfig() const
513 if( aToolBoxConfig.IsSet() || !GetRef() ) return aToolBoxConfig;
514 return ((SvMetaSlot *)GetRef())->GetToolBoxConfig();
516 BOOL SvMetaSlot::GetStatusBarConfig() const
518 if( aStatusBarConfig.IsSet() || !GetRef() ) return aStatusBarConfig;
519 return ((SvMetaSlot *)GetRef())->GetStatusBarConfig();
521 BOOL SvMetaSlot::GetAccelConfig() const
523 if( aAccelConfig.IsSet() || !GetRef() ) return aAccelConfig;
524 return ((SvMetaSlot *)GetRef())->GetAccelConfig();
526 BOOL SvMetaSlot::GetFastCall() const
528 if( aFastCall.IsSet() || !GetRef() ) return aFastCall;
529 return ((SvMetaSlot *)GetRef())->GetFastCall();
531 BOOL SvMetaSlot::GetContainer() const
533 if( aContainer.IsSet() || !GetRef() ) return aContainer;
534 return ((SvMetaSlot *)GetRef())->GetContainer();
537 BOOL SvMetaSlot::GetImageRotation() const
539 if( aImageRotation.IsSet() || !GetRef() ) return aImageRotation;
540 return ((SvMetaSlot *)GetRef())->GetImageRotation();
543 BOOL SvMetaSlot::GetImageReflection() const
545 if( aImageReflection.IsSet() || !GetRef() ) return aImageReflection;
546 return ((SvMetaSlot *)GetRef())->GetImageReflection();
549 const ByteString& SvMetaSlot::GetUnoName() const
551 if( aUnoName.IsSet() || !GetRef() ) return aUnoName;
552 return ((SvMetaSlot *)GetRef())->GetUnoName();
555 /*************************************************************************
556 |* SvMetaSlot::FillSbxObject()
558 |* Beschreibung
559 *************************************************************************/
561 void SvMetaSlot::FillSbxObject( SvIdlDataBase & rBase, SbxObject * pObj,
562 BOOL bVariable )
564 // keine Attribut fuer Automation
565 if( !GetAutomation() || !GetExport() )
566 return;
568 if( !bVariable )
570 SvMetaAttributeRef xM = GetMethod();
571 if( xM.Is() )
573 SvMetaType * pType = xM->GetType();
574 SvMetaType * pRetBaseType = pType->GetReturnType()->GetBaseType();
575 ByteString aName = xM->GetName();
577 SbxMethodRef xMeth = new SbxMethod( aName,
578 pRetBaseType->GetSbxDataType() );
579 pType->FillSbxObject( xMeth, bVariable );
580 xMeth->SetUserData( MakeSlotValue(rBase, FALSE) );
582 pObj->Insert( &xMeth );
583 return;
587 SvMetaAttribute::FillSbxObject( rBase, pObj, bVariable );
591 #ifdef IDL_COMPILER
592 /*************************************************************************
593 |* SvMetaSlot::ReadAttributesSvIdl()
595 |* Beschreibung
596 *************************************************************************/
597 void SvMetaSlot::ReadAttributesSvIdl( SvIdlDataBase & rBase,
598 SvTokenStream & rInStm )
600 SvMetaAttribute::ReadAttributesSvIdl( rBase, rInStm );
602 BOOL bOk = FALSE;
603 bOk |= aDefault.ReadSvIdl( SvHash_Default(), rInStm );
604 bOk |= aPseudoSlots.ReadSvIdl( SvHash_PseudoSlots(), rInStm );
605 bOk |= aHasCoreId.ReadSvIdl( SvHash_HasCoreId(), rInStm );
606 bOk |= aGroupId.ReadSvIdl( SvHash_GroupId(), rInStm );
607 bOk |= aExecMethod.ReadSvIdl( SvHash_ExecMethod(), rInStm );
608 bOk |= aStateMethod.ReadSvIdl( SvHash_StateMethod(), rInStm );
609 bOk |= aDisableFlags.ReadSvIdl( SvHash_DisableFlags(), rInStm );
610 if( aGet.ReadSvIdl( SvHash_Get(), rInStm ) )
612 rBase.WriteError( "warning", ByteString( rInStm.GetFileName(), RTL_TEXTENCODING_UTF8 ),
613 "<Get> old style, use Readonly",
614 rInStm.GetToken()->GetLine(),
615 rInStm.GetToken()->GetColumn() );
617 if( aSet.ReadSvIdl( SvHash_Set(), rInStm ) )
619 rBase.WriteError( "warning", ByteString( rInStm.GetFileName(), RTL_TEXTENCODING_UTF8 ),
620 "<Set> old style, use method declaration",
621 rInStm.GetToken()->GetLine(),
622 rInStm.GetToken()->GetColumn() );
625 if( aCachable.ReadSvIdl( SvHash_Cachable(), rInStm ) )
626 SetCachable( aCachable ), bOk = TRUE;
627 if( aVolatile.ReadSvIdl( SvHash_Volatile(), rInStm ) )
628 SetVolatile( aVolatile ), bOk = TRUE;
629 if( aToggle.ReadSvIdl( SvHash_Toggle(), rInStm ) )
630 SetToggle( aToggle ), bOk = TRUE;
631 if( aAutoUpdate.ReadSvIdl( SvHash_AutoUpdate(), rInStm ) )
632 SetAutoUpdate( aAutoUpdate ), bOk = TRUE;
634 if( aSynchron.ReadSvIdl( SvHash_Synchron(), rInStm ) )
635 SetSynchron( aSynchron ), bOk = TRUE;
636 if( aAsynchron.ReadSvIdl( SvHash_Asynchron(), rInStm ) )
637 SetAsynchron( aAsynchron ), bOk = TRUE;
639 if( aRecordAbsolute.ReadSvIdl( SvHash_RecordAbsolute(), rInStm ) )
640 SetRecordAbsolute( aRecordAbsolute), bOk = TRUE;
641 if( aRecordPerItem.ReadSvIdl( SvHash_RecordPerItem(), rInStm ) )
642 SetRecordPerItem( aRecordPerItem ), bOk = TRUE;
643 if( aRecordPerSet.ReadSvIdl( SvHash_RecordPerSet(), rInStm ) )
644 SetRecordPerSet( aRecordPerSet ), bOk = TRUE;
645 if( aRecordManual.ReadSvIdl( SvHash_RecordManual(), rInStm ) )
646 SetRecordManual( aRecordManual ), bOk = TRUE;
647 if( aNoRecord.ReadSvIdl( SvHash_NoRecord(), rInStm ) )
648 SetNoRecord( aNoRecord ), bOk = TRUE;
650 bOk |= aHasDialog.ReadSvIdl( SvHash_HasDialog(), rInStm );
651 bOk |= aPseudoPrefix.ReadSvIdl( SvHash_PseudoPrefix(), rInStm );
652 bOk |= aMenuConfig.ReadSvIdl( SvHash_MenuConfig(), rInStm );
653 bOk |= aToolBoxConfig.ReadSvIdl( SvHash_ToolBoxConfig(), rInStm );
654 bOk |= aStatusBarConfig.ReadSvIdl( SvHash_StatusBarConfig(), rInStm );
655 bOk |= aAccelConfig.ReadSvIdl( SvHash_AccelConfig(), rInStm );
657 SvBOOL aAllConfig;
658 if( aAllConfig.ReadSvIdl( SvHash_AllConfig(), rInStm ) )
659 SetAllConfig( aAllConfig ), bOk = TRUE;
660 bOk |= aFastCall.ReadSvIdl( SvHash_FastCall(), rInStm );
661 bOk |= aContainer.ReadSvIdl( SvHash_Container(), rInStm );
662 bOk |= aImageRotation.ReadSvIdl( SvHash_ImageRotation(), rInStm );
663 bOk |= aImageReflection.ReadSvIdl( SvHash_ImageReflection(), rInStm );
664 bOk |= aUnoName.ReadSvIdl( SvHash_UnoName(), rInStm );
666 if( !bOk )
668 if( !aSlotType.Is() )
670 UINT32 nTokPos = rInStm.Tell();
671 SvToken * pTok = rInStm.GetToken_Next();
672 if( pTok->Is( SvHash_SlotType() ) )
674 BOOL bBraket = rInStm.Read( '(' );
675 if( bBraket || rInStm.Read( '=' ) )
677 aSlotType = rBase.ReadKnownType( rInStm );
678 if( aSlotType.Is() )
680 if( aSlotType->IsItem() )
682 if( bBraket )
684 if( rInStm.Read( ')' ) )
685 return;
687 else
688 return;
690 rBase.SetError( "the SlotType is not a item", rInStm.GetToken() );
691 rBase.WriteError( rInStm );
693 rBase.SetError( "SlotType with unknown item type", rInStm.GetToken() );
694 rBase.WriteError( rInStm );
697 rInStm.Seek( nTokPos );
700 if( !aMethod.Is() )
702 SvToken * pTok = rInStm.GetToken();
703 if( pTok->IsIdentifier() )
705 aMethod = new SvMetaSlot();
706 UINT32 nTokPos = rInStm.Tell();
707 if( aMethod->ReadSvIdl( rBase, rInStm ) )
709 if( aMethod->IsMethod() )
711 aMethod->SetSlotId( GetSlotId() );
712 if( aMethod->Test( rBase, rInStm ) )
713 return;
715 rInStm.Seek( nTokPos );
717 aMethod.Clear();
723 /*************************************************************************
724 |* SvMetaSlot::WriteAttributesSvIdl()
726 |* Beschreibung
727 *************************************************************************/
728 void SvMetaSlot::WriteAttributesSvIdl( SvIdlDataBase & rBase,
729 SvStream & rOutStm,
730 USHORT nTab )
732 SvMetaAttribute::WriteAttributesSvIdl( rBase, rOutStm, nTab );
734 if( aSlotType.Is() )
736 WriteTab( rOutStm, nTab );
737 rOutStm << SvHash_SlotType()->GetName().GetBuffer() << '(';
738 aSlotType->WriteTheType( rBase, rOutStm, nTab, WRITE_IDL );
739 rOutStm << ");" << endl;
741 if( aMethod.Is() )
743 WriteTab( rOutStm, nTab );
744 aMethod->WriteSvIdl( rBase, rOutStm, nTab );
745 rOutStm << ';' << endl;
747 if( aHasCoreId )
749 aHasCoreId.WriteSvIdl( SvHash_HasCoreId(), rOutStm );
750 rOutStm << ';' << endl;
752 if( aGroupId.Len() )
754 WriteTab( rOutStm, nTab );
755 aGroupId.WriteSvIdl( SvHash_GroupId(), rOutStm, nTab +1);
756 rOutStm << ';' << endl;
758 if( aExecMethod.Len() )
760 WriteTab( rOutStm, nTab );
761 aExecMethod.WriteSvIdl( SvHash_ExecMethod(), rOutStm, nTab +1);
762 rOutStm << ';' << endl;
764 if( aStateMethod.Len() )
766 WriteTab( rOutStm, nTab );
767 aStateMethod.WriteSvIdl( SvHash_StateMethod(), rOutStm, nTab +1);
768 rOutStm << ';' << endl;
771 if( aDisableFlags.Len() )
773 WriteTab( rOutStm, nTab );
774 aDisableFlags.WriteSvIdl( SvHash_DisableFlags(), rOutStm, nTab +1);
775 rOutStm << ';' << endl;
778 if( aSet || aGet || aPseudoSlots )
780 WriteTab( rOutStm, nTab );
781 char const * p = "";
782 if( aPseudoSlots )
784 aPseudoSlots.WriteSvIdl( SvHash_PseudoSlots(), rOutStm );
785 p = ", ";
787 if( aGet )
789 rOutStm << p;
790 aGet.WriteSvIdl( SvHash_Get(), rOutStm );
791 p = ", ";
793 if( aSet )
795 rOutStm << p;
796 aSet.WriteSvIdl( SvHash_Set(), rOutStm );
798 rOutStm << ';' << endl;
801 ByteString aDel( ", " );
802 ByteString aOut;
803 if( aVolatile )
804 aOut += aVolatile.GetSvIdlString( SvHash_Volatile() );
805 else if( !aCachable )
806 // wegen Default == TRUE, nur wenn kein anderer gesetzt
807 aOut += aCachable.GetSvIdlString( SvHash_Cachable() );
808 else
809 aDel.Erase();
811 if( aToggle )
813 ( aOut += aDel ) += aToggle.GetSvIdlString( SvHash_Toggle() );
814 aDel = ", ";
816 if( aAutoUpdate )
818 (aOut += aDel ) += aAutoUpdate.GetSvIdlString( SvHash_AutoUpdate() );
819 aDel = ", ";
822 ByteString aDel1( ", " );
823 if( aAsynchron )
824 ( aOut += aDel ) += aAsynchron.GetSvIdlString( SvHash_Asynchron() );
825 else if( !aSynchron )
826 // wegen Default == TRUE, nur wenn kein anderer gesetzt
827 ( aOut += aDel ) += aSynchron.GetSvIdlString( SvHash_Synchron() );
828 else
829 aDel1 = aDel;
831 aDel = ", ";
832 if( aRecordManual )
833 ( aOut += aDel1 ) += aRecordManual.GetSvIdlString( SvHash_RecordManual() );
834 else if( aNoRecord )
835 ( aOut += aDel1 ) += aNoRecord.GetSvIdlString( SvHash_NoRecord() );
836 else if( !aRecordPerSet )
837 // wegen Default == TRUE, nur wenn kein anderer gesetzt
838 ( aOut += aDel1 ) += aRecordPerSet.GetSvIdlString( SvHash_RecordPerSet() );
839 else if( aRecordPerItem )
840 ( aOut += aDel1 ) += aRecordPerItem.GetSvIdlString( SvHash_RecordPerItem() );
841 else
842 aDel = aDel1;
844 if( aRecordAbsolute )
846 ( aOut += aDel ) += aRecordAbsolute.GetSvIdlString( SvHash_RecordAbsolute() );
847 aDel = ", ";
849 if( aHasDialog )
851 ( aOut += aDel ) += aHasDialog.GetSvIdlString( SvHash_HasDialog() );
852 aDel = ", ";
854 if( aMenuConfig )
856 ( aOut += aDel ) += aMenuConfig.GetSvIdlString( SvHash_MenuConfig() );
857 aDel = ", ";
859 if( aToolBoxConfig )
861 ( aOut += aDel ) += aToolBoxConfig.GetSvIdlString( SvHash_ToolBoxConfig() );
862 aDel = ", ";
864 if( aStatusBarConfig )
866 ( aOut += aDel ) += aStatusBarConfig.GetSvIdlString( SvHash_StatusBarConfig() );
867 aDel = ", ";
869 if( aAccelConfig )
871 ( aOut += aDel ) += aAccelConfig.GetSvIdlString( SvHash_AccelConfig() );
872 aDel = ", ";
874 if( aFastCall )
876 ( aOut += aDel ) += aFastCall.GetSvIdlString( SvHash_FastCall() );
877 aDel = ", ";
879 if( aContainer )
881 ( aOut += aDel ) += aContainer.GetSvIdlString( SvHash_Container() );
882 aDel = ", ";
884 if( aImageRotation )
886 ( aOut += aDel ) += aImageRotation.GetSvIdlString( SvHash_ImageRotation() );
887 aDel = ", ";
890 if( aImageReflection )
892 ( aOut += aDel ) += aImageReflection.GetSvIdlString( SvHash_ImageReflection() );
893 aDel = ", ";
896 if( aOut.Len() )
898 WriteTab( rOutStm, nTab );
899 rOutStm << aOut.GetBuffer() << endl;
904 /*************************************************************************
905 |* SvMetaSlot::Test()
907 |* Beschreibung
908 *************************************************************************/
909 BOOL SvMetaSlot::Test( SvIdlDataBase & rBase, SvTokenStream & rInStm )
911 BOOL bOk = SvMetaAttribute::Test( rBase, rInStm );
912 if( bOk )
914 SvMetaType * pType = GetType();
915 if( pType->GetType() == TYPE_METHOD )
916 pType = pType->GetReturnType();
917 if( !pType->IsItem() )
919 rBase.SetError( "this attribute is not a slot", rInStm.GetToken() );
920 rBase.WriteError( rInStm );
921 bOk = FALSE;
925 return bOk;
928 /*************************************************************************
929 |* SvMetaSlot::ReadSvIdl()
931 |* Beschreibung
932 *************************************************************************/
933 BOOL SvMetaSlot::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm )
935 UINT32 nTokPos = rInStm.Tell();
936 BOOL bOk = TRUE;
938 SvMetaAttribute * pAttr = rBase.ReadKnownAttr( rInStm, GetType() );
939 if( pAttr )
941 // F"ur Testzwecke: Referenz bei Kurz-Syntax
942 SvMetaSlot * pKnownSlot = PTR_CAST( SvMetaSlot, pAttr );
943 if( pKnownSlot )
945 SetRef( pKnownSlot );
946 SetName( pKnownSlot->GetName(), &rBase );
947 bOk = SvMetaName::ReadSvIdl( rBase, rInStm );
949 else
951 ByteString aStr( "attribute " );
952 aStr += pAttr->GetName();
953 aStr += " is method or variable but not a slot";
954 rBase.SetError( aStr, rInStm.GetToken() );
955 rBase.WriteError( rInStm );
956 bOk = FALSE;
959 else
961 bOk = SvMetaAttribute::ReadSvIdl( rBase, rInStm );
963 SvMetaAttribute *pAttr2 = rBase.SearchKnownAttr( GetSlotId() );
964 if( pAttr2 )
966 // F"ur Testzwecke: Referenz bei kompletter Definition
967 SvMetaSlot * pKnownSlot = PTR_CAST( SvMetaSlot, pAttr2 );
968 if( pKnownSlot )
970 SetRef( pKnownSlot );
972 // Namen d"urfen abweichen, da mit angegeben
973 if ( pKnownSlot->GetName() != GetName() )
975 DBG_ERROR("Illegal definition!");
976 rInStm.Seek( nTokPos );
977 return FALSE;
980 SetName( pKnownSlot->GetName(), &rBase );
982 else
984 ByteString aStr( "attribute " );
985 aStr += pAttr2->GetName();
986 aStr += " is method or variable but not a slot";
987 rBase.SetError( aStr, rInStm.GetToken() );
988 rBase.WriteError( rInStm );
989 bOk = FALSE;
994 if( !bOk )
995 rInStm.Seek( nTokPos );
997 return bOk;
1000 /*************************************************************************
1001 |* SvMetaSlot::WriteSvIdl()
1003 |* Beschreibung
1004 *************************************************************************/
1005 void SvMetaSlot::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
1006 USHORT nTab )
1008 SvMetaAttribute::WriteSvIdl( rBase, rOutStm, nTab );
1011 /*************************************************************************
1012 |* SvMetaSlot::Write()
1014 |* Beschreibung
1015 *************************************************************************/
1016 void SvMetaSlot::Write( SvIdlDataBase & rBase,
1017 SvStream & rOutStm, USHORT nTab,
1018 WriteType nT, WriteAttribute nA )
1020 if ( nT == WRITE_DOCU )
1022 if ( GetHidden() )
1023 return;
1025 else
1027 // keine Attribut fuer Automation
1028 if( !GetAutomation() || !GetExport() )
1029 return;
1032 if( !(nA & WA_VARIABLE) )
1034 SvMetaAttributeRef xM = GetMethod();
1035 if( xM.Is() )
1037 xM->SetSlotId( GetSlotId() );
1038 xM->SetDescription( GetDescription() );
1039 xM->Write( rBase, rOutStm, nTab, nT, nA );
1040 return;
1044 SvMetaAttribute::Write( rBase, rOutStm, nTab, nT, nA );
1048 void SvMetaSlot::Insert( SvSlotElementList& rList, const ByteString & rPrefix,
1049 SvIdlDataBase& rBase)
1051 // Einf"ugeposition durch bin"are Suche in der SlotListe ermitteln
1052 USHORT nId = (USHORT) GetSlotId().GetValue();
1053 USHORT nListCount = (USHORT) rList.Count();
1054 USHORT nPos;
1055 ULONG m; // for inner "for" loop
1057 if ( !nListCount )
1058 nPos = 0;
1059 else if ( nListCount == 1 )
1060 nPos = rList.GetObject(0)->xSlot->GetSlotId().GetValue() >= nId ? 0 : 1;
1061 else
1063 USHORT nMid = 0, nLow = 0;
1064 USHORT nHigh = nListCount - 1;
1065 BOOL bFound = FALSE;
1066 while ( !bFound && nLow <= nHigh )
1068 nMid = (nLow + nHigh) >> 1;
1069 DBG_ASSERT( nMid < nListCount, "bsearch ist buggy" );
1070 int nDiff = (int) nId - (int) rList.GetObject(nMid)->xSlot->GetSlotId().GetValue();
1071 if ( nDiff < 0)
1073 if ( nMid == 0 )
1074 break;
1075 nHigh = nMid - 1;
1077 else if ( nDiff > 0 )
1079 nLow = nMid + 1;
1080 if ( nLow == 0 )
1081 break;
1083 else
1084 bFound = TRUE;
1087 DBG_ASSERT(!bFound, "Duplicate SlotId!");
1088 nPos = bFound ? nMid : nLow;
1091 DBG_ASSERT( nPos <= nListCount,
1092 "nPos too large" );
1093 DBG_ASSERT( nPos == nListCount || nId <=
1094 (USHORT) rList.GetObject(nPos)->xSlot->GetSlotId().GetValue(),
1095 "Successor has lower SlotId" );
1096 DBG_ASSERT( nPos == 0 || nId >
1097 (USHORT) rList.GetObject(nPos-1)->xSlot->GetSlotId().GetValue(),
1098 "Predecessor has higher SlotId" );
1099 DBG_ASSERT( nPos+1 >= nListCount || nId <
1100 (USHORT) rList.GetObject(nPos+1)->xSlot->GetSlotId().GetValue(),
1101 "Successor has lower SlotId" );
1103 rList.Insert( new SvSlotElement( this, rPrefix ), nPos );
1105 // EnumSlots plattklopfen
1106 SvMetaTypeEnum * pEnum = NULL;
1107 SvMetaType * pBType = GetType()->GetBaseType();
1108 pEnum = PTR_CAST( SvMetaTypeEnum, pBType );
1109 if( GetPseudoSlots() && pEnum && pEnum->Count() )
1111 // Den MasterSlot clonen
1112 SvMetaSlotRef xEnumSlot;
1113 SvMetaSlot *pFirstEnumSlot = NULL;
1114 for( ULONG n = 0; n < pEnum->Count(); n++ )
1116 // Die SlotId erzeugen
1117 SvMetaEnumValue *enumValue = pEnum->GetObject(n);
1118 ByteString aValName = enumValue->GetName();
1119 ByteString aSId( GetSlotId() );
1120 if( GetPseudoPrefix().Len() )
1121 aSId = GetPseudoPrefix();
1122 aSId += '_';
1123 aSId += aValName.Copy( pEnum->GetPrefix().Len() );
1125 xEnumSlot = NULL;
1126 for( m=0; m<rBase.GetAttrList().Count(); m++ )
1128 SvMetaAttribute * pAttr = rBase.GetAttrList().GetObject( m );
1129 if( pAttr->GetSlotId() == aSId )
1131 SvMetaSlot* pSlot = PTR_CAST( SvMetaSlot, pAttr );
1132 xEnumSlot = pSlot->Clone();
1133 break;
1137 if ( m == rBase.GetAttrList().Count() )
1139 DBG_ERROR("Invalid EnumSlot!");
1140 xEnumSlot = Clone();
1141 ULONG nValue;
1142 if ( rBase.FindId(aSId , &nValue) )
1144 SvNumberIdentifier aId;
1145 *((SvIdentifier*)&aId) = aSId;
1146 aId.SetValue(nValue);
1147 xEnumSlot->SetSlotId(aId);
1151 // Die Slaves sind kein Master !
1152 xEnumSlot->aPseudoSlots = FALSE;
1153 xEnumSlot->SetEnumValue(enumValue);
1155 if ( !pFirstEnumSlot || xEnumSlot->GetSlotId().GetValue() < pFirstEnumSlot->GetSlotId().GetValue() )
1156 pFirstEnumSlot = xEnumSlot;
1158 // Den erzeugten Slave ebenfalls einf"ugen
1159 xEnumSlot->Insert( rList, rPrefix, rBase);
1161 // Die EnumSlots mit dem Master verketten
1162 xEnumSlot->pLinkedSlot = this;
1165 // Master zeigt auf den ersten Slave
1166 pLinkedSlot = pFirstEnumSlot;
1168 // Slaves untereinander verketten
1169 rList.Seek((ULONG)0);
1170 xEnumSlot = pFirstEnumSlot;
1171 SvSlotElement *pEle;
1174 pEle = rList.Next();
1175 if ( pEle && pEle->xSlot->pLinkedSlot == this )
1177 xEnumSlot->pNextSlot = pEle->xSlot;
1178 xEnumSlot = pEle->xSlot;
1181 while ( pEle );
1182 xEnumSlot->pNextSlot = pFirstEnumSlot;
1187 /*************************************************************************
1188 |* SvMetaSlot::WriteSlotMap()
1190 |* Beschreibung
1191 *************************************************************************/
1192 static ByteString MakeSlotName( SvStringHashEntry * pEntry )
1194 ByteString aName( "SFX_SLOT_" );
1195 aName += pEntry->GetName();
1196 return aName.ToUpperAscii();
1199 void SvMetaSlot::WriteSlotStubs( const ByteString & rShellName,
1200 ByteStringList & rList,
1201 SvStream & rOutStm )
1204 ByteString aName = GetName();
1205 SvMetaAttribute * pAttr = rAttrList.First();
1206 while( pAttr )
1208 if( pAttr->GetName() == aName )
1209 break;
1210 pAttr = rAttrList.Next();
1212 if( pAttr )
1213 return;
1215 if ( !GetExport() && !GetHidden() )
1216 return;
1218 ByteString aMethodName( GetExecMethod() );
1219 if ( aMethodName.Len() && aMethodName != "NoExec" )
1221 BOOL bIn = FALSE;
1222 for( USHORT n = 0; n < rList.Count(); n++ )
1224 if( *(rList.GetObject(n)) == aMethodName )
1226 bIn=TRUE;
1227 break;
1231 if ( !bIn )
1233 rList.Insert( new ByteString(aMethodName), LIST_APPEND );
1234 rOutStm << "SFX_EXEC_STUB("
1235 << rShellName.GetBuffer()
1236 << ','
1237 << aMethodName.GetBuffer()
1238 << ')' << endl;
1242 aMethodName = GetStateMethod();
1243 if ( aMethodName.Len() && aMethodName != "NoState" )
1245 BOOL bIn = FALSE;
1246 for ( USHORT n=0; n < rList.Count(); n++ )
1248 if ( *(rList.GetObject(n)) == aMethodName )
1250 bIn=TRUE;
1251 break;
1255 if ( !bIn )
1257 rList.Insert( new ByteString(aMethodName), LIST_APPEND );
1258 rOutStm << "SFX_STATE_STUB("
1259 << rShellName.GetBuffer()
1260 << ','
1261 << aMethodName.GetBuffer()
1262 << ')' << endl;
1267 void SvMetaSlot::WriteSlot( const ByteString & rShellName, USHORT nCount,
1268 const ByteString & rSlotId,
1269 SvSlotElementList& rSlotList,
1270 const ByteString & rPrefix,
1271 SvIdlDataBase & rBase, SvStream & rOutStm )
1273 if ( !GetExport() && !GetHidden() )
1274 return;
1276 // BOOL bIsEnumSlot = 0 != rValueName.Len();
1277 BOOL bIsEnumSlot = 0 != pEnumValue;
1279 rOutStm << "// Slot Nr. " << ByteString::CreateFromInt32(nListPos).GetBuffer() << " : ";
1280 ByteString aSlotIdValue( ByteString::CreateFromInt32( GetSlotId().GetValue() ) );
1281 rOutStm << aSlotIdValue.GetBuffer() << endl;
1282 WriteTab( rOutStm, 1 );
1283 if( bIsEnumSlot )
1284 rOutStm << "SFX_NEW_SLOT_ENUM( ";
1285 else
1286 rOutStm << "SFX_NEW_SLOT_ARG( " << rShellName.GetBuffer() << ',' ;
1288 rOutStm << rSlotId.GetBuffer() << ',';
1289 const SvHelpContext& rHlpCtx = GetHelpContext();
1290 if( rHlpCtx.IsSet() )
1291 rOutStm << rHlpCtx.GetBuffer() << ',';
1292 else
1293 rOutStm << rSlotId.GetBuffer() << ',';
1295 // GroupId
1296 if( GetGroupId().Len() )
1297 rOutStm << GetGroupId().GetBuffer();
1298 else
1299 rOutStm << '0';
1300 rOutStm << ',' << endl;
1301 WriteTab( rOutStm, 4 );
1303 if( bIsEnumSlot )
1305 rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl["
1306 << ByteString::CreateFromInt32(pLinkedSlot->GetListPos()).GetBuffer()
1307 << "] /*Offset Master*/, " << endl;
1308 WriteTab( rOutStm, 4 );
1309 rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl["
1310 << ByteString::CreateFromInt32(pNextSlot->GetListPos()).GetBuffer()
1311 << "] /*Offset Next*/, " << endl;
1313 WriteTab( rOutStm, 4 );
1315 // SlotId
1316 if( GetSlotId().Len() )
1317 rOutStm << pLinkedSlot->GetSlotId().GetBuffer();
1318 else
1319 rOutStm << '0';
1320 rOutStm << ',';
1321 rOutStm << pEnumValue->GetName().GetBuffer();
1323 else
1325 // Den n"achsten Slot suchen, der die gleiche StateMethod hat wie ich
1326 // Die SlotList ist auf den aktuellen Slot geseekt
1327 SvSlotElement * pEle = rSlotList.Next();
1328 pNextSlot = pEle ? &pEle->xSlot : NULL;
1329 while ( pNextSlot )
1331 if ( !pNextSlot->pNextSlot &&
1332 pNextSlot->GetStateMethod() == GetStateMethod() )
1333 break;
1334 pEle = rSlotList.Next();
1335 pNextSlot = pEle ? &pEle->xSlot : NULL;
1338 if ( !pNextSlot )
1340 // Es gibt nach mir keinen Slot mehr, der die gleiche ExecMethode
1341 // hat. Also suche ich den ersten Slot, der diese hatte (das
1342 // k"onnte auch ich selbst sein)
1343 pEle = rSlotList.First();
1344 pNextSlot = pEle ? &pEle->xSlot : NULL;
1345 while ( pNextSlot != this )
1347 if ( !pNextSlot->pEnumValue &&
1348 pNextSlot->GetStateMethod() == GetStateMethod() )
1349 break;
1350 pEle = rSlotList.Next();
1351 pNextSlot = pEle ? &pEle->xSlot : NULL;
1355 if ( !pLinkedSlot )
1357 rOutStm << "0 ,";
1359 else
1361 rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl["
1362 << ByteString::CreateFromInt32(pLinkedSlot->GetListPos()).GetBuffer()
1363 << "] /*Offset Linked*/, " << endl;
1364 WriteTab( rOutStm, 4 );
1367 rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl["
1368 << ByteString::CreateFromInt32(pNextSlot->GetListPos()).GetBuffer()
1369 << "] /*Offset Next*/, " << endl;
1371 WriteTab( rOutStm, 4 );
1373 // ExecMethod schreiben, wenn nicht angegeben, standard Namen
1374 if( GetExecMethod().Len() && GetExecMethod() != "NoExec")
1375 rOutStm << "SFX_STUB_PTR(" << rShellName.GetBuffer() << ','
1376 << GetExecMethod().GetBuffer() << ')';
1377 else
1378 rOutStm << "SFX_STUB_PTR_EXEC_NONE";
1379 rOutStm << ',';
1381 // StateMethod schreiben, wenn nicht angegeben, standard Namen
1382 if( GetStateMethod().Len() && GetStateMethod() != "NoState")
1383 rOutStm << "SFX_STUB_PTR(" << rShellName.GetBuffer() << ','
1384 << GetStateMethod().GetBuffer() << ')';
1385 else
1386 rOutStm << "SFX_STUB_PTR_STATE_NONE";
1388 rOutStm << ',' << endl;
1389 WriteTab( rOutStm, 4 );
1391 // Flags schreiben
1392 if( GetHasCoreId() )
1393 rOutStm << MakeSlotName( SvHash_HasCoreId() ).GetBuffer() << '|';
1394 if( GetCachable() )
1395 rOutStm << MakeSlotName( SvHash_Cachable() ).GetBuffer() << '|';
1396 if( GetVolatile() )
1397 rOutStm << MakeSlotName( SvHash_Volatile() ).GetBuffer() << '|';
1398 if( GetToggle() )
1399 rOutStm << MakeSlotName( SvHash_Toggle() ).GetBuffer() << '|';
1400 if( GetAutoUpdate() )
1401 rOutStm << MakeSlotName( SvHash_AutoUpdate() ).GetBuffer() << '|';
1402 if( GetSynchron() )
1403 rOutStm << MakeSlotName( SvHash_Synchron() ).GetBuffer() << '|';
1404 if( GetAsynchron() )
1405 rOutStm << MakeSlotName( SvHash_Asynchron() ).GetBuffer() << '|';
1406 if( GetRecordPerItem() )
1407 rOutStm << MakeSlotName( SvHash_RecordPerItem() ).GetBuffer() << '|';
1408 if( GetRecordPerSet() )
1409 rOutStm << MakeSlotName( SvHash_RecordPerSet() ).GetBuffer() << '|';
1410 if( GetRecordManual() )
1411 rOutStm << MakeSlotName( SvHash_RecordManual() ).GetBuffer() << '|';
1412 if( GetNoRecord() )
1413 rOutStm << MakeSlotName( SvHash_NoRecord() ).GetBuffer() << '|';
1414 if( GetRecordAbsolute() )
1415 rOutStm << MakeSlotName( SvHash_RecordAbsolute() ).GetBuffer() << '|';
1416 if( GetHasDialog() )
1417 rOutStm << MakeSlotName( SvHash_HasDialog() ).GetBuffer() << '|';
1418 if( GetMenuConfig() )
1419 rOutStm << MakeSlotName( SvHash_MenuConfig() ).GetBuffer() << '|';
1420 if( GetToolBoxConfig() )
1421 rOutStm << MakeSlotName( SvHash_ToolBoxConfig() ).GetBuffer() << '|';
1422 if( GetStatusBarConfig() )
1423 rOutStm << MakeSlotName( SvHash_StatusBarConfig() ).GetBuffer() << '|';
1424 if( GetAccelConfig() )
1425 rOutStm << MakeSlotName( SvHash_AccelConfig() ).GetBuffer() << '|';
1426 if( GetFastCall() )
1427 rOutStm << MakeSlotName( SvHash_FastCall() ).GetBuffer() << '|';
1428 if( GetContainer() )
1429 rOutStm << MakeSlotName( SvHash_Container() ).GetBuffer() << '|';
1430 if ( GetReadOnlyDoc() )
1431 rOutStm << MakeSlotName( SvHash_ReadOnlyDoc() ).GetBuffer() << '|';
1432 if( GetImageRotation() )
1433 rOutStm << MakeSlotName( SvHash_ImageRotation() ).GetBuffer() << '|';
1434 if( GetImageReflection() )
1435 rOutStm << MakeSlotName( SvHash_ImageReflection() ).GetBuffer() << '|';
1436 rOutStm << '0';
1438 rOutStm << ',' << endl;
1439 WriteTab( rOutStm, 4 );
1440 if ( !GetDisableFlags().Len() )
1441 rOutStm << "0";
1442 else
1443 rOutStm << GetDisableFlags().GetBuffer();
1445 // Attribut Typ schreiben
1446 if( !bIsEnumSlot )
1448 rOutStm << ',' << endl;
1449 WriteTab( rOutStm, 4 );
1451 SvMetaType * pT = GetSlotType();
1452 if( !pT )
1454 if( !IsVariable() )
1455 pT = rBase.FindType( "SfxVoidItem" );
1456 else
1457 pT = GetType();
1459 if( pT )
1461 rOutStm << pT->GetName().GetBuffer();
1462 if( !rBase.FindType( pT, rBase.aUsedTypes ) )
1463 rBase.aUsedTypes.Append( pT );
1465 else
1466 rOutStm << "SfxVoidItem not defined";
1468 else
1470 SvMetaType *pT = rBase.FindType( "SfxBoolItem" );
1471 if ( pT && !rBase.FindType( pT, rBase.aUsedTypes ) )
1472 rBase.aUsedTypes.Append( pT );
1475 if( !bIsEnumSlot )
1477 rOutStm << ',' << endl;
1478 WriteTab( rOutStm, 4 );
1479 rOutStm << ByteString::CreateFromInt32( nCount ).GetBuffer() << "/*Offset*/, ";
1481 if( IsMethod() )
1483 SvMetaAttribute * pMethod = GetMethod();
1484 SvMetaType * pType;
1485 if( pMethod )
1486 pType = pMethod->GetType();
1487 else
1488 pType = GetType();
1489 ULONG nSCount = pType->GetAttrCount();
1490 rOutStm << ByteString::CreateFromInt32( nSCount ).GetBuffer() << "/*Count*/";
1492 else
1493 rOutStm << '0';
1495 // Name f"urs Recording
1496 if ( GetExport() )
1498 rOutStm << ",\"";
1499 if( rPrefix.Len() )
1500 rOutStm << rPrefix.GetBuffer();
1501 rOutStm << '.';
1502 if ( !IsVariable() || !GetType() ||
1503 GetType()->GetBaseType()->GetType() != TYPE_STRUCT )
1504 rOutStm << GetMangleName( FALSE ).GetBuffer();
1505 rOutStm << "\",";
1507 else
1508 rOutStm << ", 0, ";
1510 // Method/Property Flags
1511 if( IsMethod() )
1512 rOutStm << "SFX_SLOT_METHOD|";
1513 if( IsVariable() )
1515 rOutStm << "SFX_SLOT_PROPGET|";
1516 if( !GetReadonly() )
1517 rOutStm << "SFX_SLOT_PROPSET|";
1520 rOutStm << '0';
1523 // if ( GetUnoName().Len() )
1525 rOutStm << ",\"";
1526 rOutStm << GetMangleName( FALSE ).GetBuffer();
1527 //rOutStm << GetUnoName().GetBuffer();
1528 rOutStm << "\"";
1530 // else
1531 // rOutStm << ", 0";
1533 rOutStm << " )," << endl;
1536 USHORT SvMetaSlot::WriteSlotParamArray( SvIdlDataBase & rBase, SvStream & rOutStm )
1538 if ( !GetExport() && !GetHidden() )
1539 return 0;
1541 SvMetaAttribute * pMethod = GetMethod();
1542 if( IsMethod() )
1544 SvMetaType * pType;
1545 if( pMethod )
1546 pType = pMethod->GetType();
1547 else
1548 pType = GetType();
1550 if( !rBase.FindType( pType, rBase.aUsedTypes ) )
1551 rBase.aUsedTypes.Append( pType );
1553 const SvMetaAttributeMemberList & rList =
1554 pType->GetAttrList();
1555 for( ULONG n = 0; n < rList.Count(); n++ )
1557 SvMetaAttribute * pPar = rList.GetObject( n );
1558 SvMetaType * pPType = pPar->GetType();
1559 WriteTab( rOutStm, 1 );
1560 rOutStm << "SFX_ARGUMENT("
1561 << pPar->GetSlotId().GetBuffer() << ',' // SlodId
1562 // Parameter Name
1563 << "\"" << pPar->GetName().GetBuffer() << "\","
1564 // Item Name
1565 << pPType->GetName().GetBuffer() << ")," << endl;
1566 if( !rBase.FindType( pPType, rBase.aUsedTypes ) )
1567 rBase.aUsedTypes.Append( pPType );
1569 return (USHORT)rList.Count();
1571 return 0;
1574 USHORT SvMetaSlot::WriteSlotMap( const ByteString & rShellName, USHORT nCount,
1575 SvSlotElementList& rSlotList,
1576 const ByteString & rPrefix,
1577 SvIdlDataBase & rBase,
1578 SvStream & rOutStm )
1580 // SlotId, wenn nicht angegeben, aus Namen generieren
1581 ByteString slotId = GetSlotId();
1583 USHORT nSCount = 0;
1584 if( IsMethod() )
1586 SvMetaType * pType;
1587 SvMetaAttribute * pMethod = GetMethod();
1588 if( pMethod )
1589 pType = pMethod->GetType();
1590 else
1591 pType = GetType();
1593 nSCount = (USHORT)pType->GetAttrCount();
1596 WriteSlot( rShellName, nCount, slotId, rSlotList, rPrefix, rBase, rOutStm );
1597 return nSCount;
1600 /*************************************************************************
1601 |* SvMetaSlot::WriteSrc()
1602 *************************************************************************/
1603 void SvMetaSlot::WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm,
1604 Table * pTable )
1606 if (!GetToolBoxConfig() && !GetAccelConfig() && !GetMenuConfig() && !GetStatusBarConfig() )
1607 return;
1609 ULONG nSId = GetSlotId().GetValue();
1610 if( !pTable->IsKeyValid( nSId ) )
1612 pTable->Insert( nSId, this );
1613 rOutStm << "SfxSlotInfo " << ByteString::CreateFromInt32( nSId ).GetBuffer()
1614 << endl << '{' << endl;
1616 WriteTab( rOutStm, 1 );
1617 ByteString aStr = GetConfigName();
1618 if( !aStr.Len() )
1619 aStr = GetName();
1621 rOutStm << "SlotName = \"" << aStr.GetBuffer() << "\";" << endl;
1623 aStr = GetHelpText();
1624 if( aStr.Len() )
1626 WriteTab( rOutStm, 1 );
1627 rOutStm << "HelpText = \"" << aStr.GetBuffer() << "\";" << endl;
1630 rOutStm << "};" << endl;
1633 SvMetaTypeEnum * pEnum = PTR_CAST( SvMetaTypeEnum, GetType() );
1634 if( GetPseudoSlots() && pEnum )
1636 for( ULONG n = 0; n < pEnum->Count(); n++ )
1638 ByteString aValName = pEnum->GetObject( n )->GetName();
1639 ByteString aSId( GetSlotId() );
1640 if( GetPseudoPrefix().Len() )
1641 aSId = GetPseudoPrefix();
1642 aSId += '_';
1643 aSId += aValName.Copy( pEnum->GetPrefix().Len() );
1645 ULONG nSId2;
1646 BOOL bIdOk = FALSE;
1647 if( rBase.FindId( aSId, &nSId2 ) )
1649 aSId = ByteString::CreateFromInt32( nSId2 );
1650 bIdOk = TRUE;
1653 // wenn Id nicht gefunden, immer schreiben
1654 if( !bIdOk || !pTable->IsKeyValid( nSId2 ) )
1656 pTable->Insert( nSId2, this );
1657 rOutStm << "SfxSlotInfo " << aSId.GetBuffer()
1658 << endl << '{' << endl;
1660 WriteTab( rOutStm, 1 );
1661 rOutStm << "SlotName = \"" << aValName.GetBuffer() << "\";" << endl;
1663 ByteString aStr = GetHelpText();
1664 if( aStr.Len() )
1666 WriteTab( rOutStm, 1 );
1667 rOutStm << "HelpText = \"" << aStr.GetBuffer() << "\";" << endl;
1669 rOutStm << "};" << endl;
1675 void SvMetaSlot::WriteHelpId( SvIdlDataBase & rBase, SvStream & rOutStm,
1676 Table * pTable )
1678 ULONG nSId = GetSlotId().GetValue();
1679 if( !pTable->IsKeyValid( nSId ) )
1681 pTable->Insert( nSId, this );
1682 rOutStm << "#define " << GetSlotId().GetBuffer() << '\t' << ByteString::CreateFromInt32( nSId ).GetBuffer() << endl;
1685 SvMetaTypeEnum * pEnum = PTR_CAST( SvMetaTypeEnum, GetType() );
1686 if( GetPseudoSlots() && pEnum )
1688 for( ULONG n = 0; n < pEnum->Count(); n++ )
1690 ByteString aValName = pEnum->GetObject( n )->GetName();
1691 ByteString aSId( GetSlotId() );
1692 if( GetPseudoPrefix().Len() )
1693 aSId = GetPseudoPrefix();
1694 aSId += '_';
1695 aSId += aValName.Copy( pEnum->GetPrefix().Len() );
1697 ULONG nSId2;
1698 BOOL bIdOk = FALSE;
1699 if( rBase.FindId( aSId, &nSId2 ) )
1701 aSId = ByteString::CreateFromInt32( nSId2 );
1702 bIdOk = TRUE;
1705 // wenn Id nicht gefunden, immer schreiben
1706 if( !bIdOk || !pTable->IsKeyValid( nSId2 ) )
1708 pTable->Insert( nSId2, this );
1710 rOutStm << "#define " << aSId.GetBuffer() << '\t'
1711 << ByteString::CreateFromInt32( nSId2 ).GetBuffer() << endl;
1717 void WriteBool( BOOL bSet, SvStream& rStream )
1719 if ( bSet )
1720 rStream << "TRUE" << ',';
1721 else
1722 rStream << "FALSE" << ',';
1725 void SvMetaSlot::WriteCSV( SvIdlDataBase& rBase, SvStream& rStrm )
1727 rStrm << "PROJECT,";
1728 rStrm << GetSlotId().GetBuffer() << ',';
1729 rStrm << ByteString::CreateFromInt32( GetSlotId().GetValue() ).GetBuffer() << ',';
1731 if ( GetPseudoPrefix().Len() )
1732 rStrm << GetPseudoPrefix().GetBuffer() << ',';
1733 else
1734 rStrm << ',';
1736 rStrm << GetGroupId().GetBuffer() << ',';
1738 WriteBool( GetAccelConfig(), rStrm );
1739 WriteBool( GetMenuConfig(), rStrm );
1740 WriteBool( GetStatusBarConfig(), rStrm );
1741 WriteBool( GetToolBoxConfig(), rStrm );
1743 if ( GetSlotType() )
1744 rStrm << GetSlotType()->GetName().GetBuffer() << ',';
1745 else
1746 rStrm << ',';
1748 WriteBool( GetAutoUpdate(), rStrm );
1749 if ( GetCachable() )
1750 rStrm << "Cachable" << ',';
1751 else
1752 rStrm << "Volatile" << ',';
1754 WriteBool( GetContainer(), rStrm );
1755 WriteBool( GetFastCall(), rStrm );
1756 WriteBool( GetHasCoreId(), rStrm );
1757 WriteBool( GetHasDialog(), rStrm );
1758 WriteBool( GetReadOnlyDoc(), rStrm );
1759 WriteBool( GetImageRotation(), rStrm );
1760 WriteBool( GetImageReflection(), rStrm );
1761 rStrm << GetDisableFlags().GetBuffer() << ',';
1763 if( GetSynchron() )
1764 rStrm << "Synchron" << ',';
1765 else
1766 rStrm << "Asynchron" << ',';
1768 WriteBool( GetToggle(), rStrm );
1769 WriteBool( GetReadonly(), rStrm );
1770 WriteBool( GetExport(), rStrm );
1771 if( GetRecordPerItem() )
1772 rStrm << "RecordPerItem" << ',';
1773 else if ( GetNoRecord() )
1774 rStrm << "NoRecord" << ',';
1775 else if ( GetRecordManual() )
1776 rStrm << "RecordManual" << ',';
1777 else
1778 rStrm << "RecordPerSet" << ',';
1780 WriteBool( GetRecordAbsolute(), rStrm );
1782 if ( GetType()->GetType() != TYPE_METHOD && GetMethod() )
1784 rStrm << GetMethod()->GetType()->GetReturnType()->GetName().GetBuffer() << ',';
1785 rStrm << GetMethod()->GetName().GetBuffer() << ',';
1787 else
1789 rStrm << ",,";
1792 rStrm << GetType()->GetSvName().GetBuffer() << ',';
1793 rStrm << GetName().GetBuffer() << ',';
1795 if ( GetType()->GetType() == TYPE_METHOD || GetMethod() )
1797 SvMetaAttributeMemberList *pList = &GetType()->GetAttrList();
1798 if ( GetMethod() )
1799 pList = &GetMethod()->GetType()->GetAttrList();
1801 if( pList && pList->Count() )
1803 rStrm << "\"(";
1804 SvMetaAttribute* pAttr = pList->First();
1805 while( pAttr )
1807 pAttr->WriteCSV( rBase, rStrm );
1808 pAttr = pList->Next();
1809 if( pAttr )
1810 rStrm << ',';
1812 rStrm << ")\"";
1814 else
1815 rStrm << "()";
1818 rStrm << endl;
1821 #endif // IDL_COMPILER