merged tag ooo/DEV300_m102
[LibreOffice.git] / idl / source / objects / slot.cxx
blob6c7018959a9d135d1680bd78d5beb02623ffa0c6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_idl.hxx"
31 #include <ctype.h>
32 #include <stdio.h>
33 #include <tools/debug.hxx>
34 #include <attrib.hxx>
35 #include <slot.hxx>
36 #include <globals.hxx>
37 #include <database.hxx>
39 /****************** SvMetaSlot *****************************************/
40 SV_IMPL_META_FACTORY1( SvMetaSlot, SvMetaAttribute );
42 SvMetaObject *SvMetaSlot::MakeClone() const
44 return new SvMetaSlot( *this );
47 /*************************************************************************
48 |* SvMetaSlot::SvMetaSlot()
50 |* Beschreibung Zweites sal_False bei den SvBOOL-Objekten bedeutet,
51 |* IsSet() liefert sal_False (Defaultinitialisierung).
52 *************************************************************************/
53 SvMetaSlot::SvMetaSlot()
54 : aCachable( sal_True, sal_False )
55 , aSynchron( sal_True, sal_False )
56 , aRecordPerSet( sal_True, sal_False )
57 , aRecordAbsolute( sal_False, sal_False )
58 , pLinkedSlot(0)
59 , pNextSlot(0)
60 , pEnumValue(0)
64 SvMetaSlot::SvMetaSlot( SvMetaType * pType )
65 : SvMetaAttribute( pType )
66 , aCachable( sal_True, sal_False )
67 , aSynchron( sal_True, sal_False )
68 , aRecordPerSet( sal_True, sal_False )
69 , aRecordAbsolute( sal_False, sal_False )
70 , pLinkedSlot(0)
71 , pNextSlot(0)
72 , pEnumValue(0)
77 #define TEST_READ \
78 { \
79 sal_uInt32 nPos; \
80 rStm >> nPos; \
81 DBG_ASSERT( nPos +4 == rStm.Tell(), "stream pos error" ); \
84 #define TEST_WRITE \
85 rStm << (sal_uInt32)rStm.Tell();
87 #define TEST_READ
88 #define TEST_WRITE
90 void SvMetaSlot::Load( SvPersistStream & rStm )
92 SvMetaAttribute::Load( rStm );
94 sal_uInt16 nMask;
95 rStm >> nMask;
97 TEST_READ
98 if( nMask & 0x0001 )
100 SvMetaAttribute * pMeth;
101 rStm >> pMeth;
102 aMethod = pMeth;
105 TEST_READ
106 if( nMask & 0x0002 ) rStm >> aGroupId;
107 TEST_READ
108 if( nMask & 0x0004 ) rStm >> aHasCoreId;
109 TEST_READ
110 if( nMask & 0x0008 ) rStm >> aConfigId;
111 TEST_READ
112 if( nMask & 0x0010 ) rStm >> aExecMethod;
113 TEST_READ
114 if( nMask & 0x0020 ) rStm >> aStateMethod;
115 TEST_READ
116 if( nMask & 0x0040 ) rStm >> aDefault;
117 TEST_READ
118 if( nMask & 0x0080 ) rStm >> aPseudoSlots;
119 TEST_READ
120 if( nMask & 0x0100 ) rStm >> aGet;
121 TEST_READ
122 if( nMask & 0x0200 ) rStm >> aSet;
123 TEST_READ
124 if( nMask & 0x0400 ) rStm >> aCachable;
125 TEST_READ
126 if( nMask & 0x0800 ) rStm >> aVolatile;
127 TEST_READ
128 if( nMask & 0x1000 ) rStm >> aToggle;
129 TEST_READ
130 if( nMask & 0x2000 ) rStm >> aAutoUpdate;
131 TEST_READ
132 if( nMask & 0x4000 ) rStm >> aSynchron;
133 TEST_READ
134 if( nMask & 0x8000 ) rStm >> aAsynchron;
136 nMask = 0;
137 rStm >> nMask;
139 TEST_READ
140 if( nMask & 0x0001 ) rStm >> aRecordPerItem;
141 TEST_READ
142 if( nMask & 0x0002 ) rStm >> aRecordManual;
143 TEST_READ
144 if( nMask & 0x0004 ) rStm >> aNoRecord;
145 TEST_READ
146 if( nMask & 0x0008 ) rStm >> aHasDialog;
147 TEST_READ
148 if( nMask & 0x0010 ) rStm >> aDisableFlags;
149 TEST_READ
150 if( nMask & 0x0020 ) rStm >> aPseudoPrefix;
151 TEST_READ
152 if( nMask & 0x0040 ) rStm >> aRecordPerSet;
153 TEST_READ
154 if( nMask & 0x0080 ) rStm >> aMenuConfig;
155 TEST_READ
156 if( nMask & 0x0100 ) rStm >> aToolBoxConfig;
157 TEST_READ
158 if( nMask & 0x0200 ) rStm >> aStatusBarConfig;
159 TEST_READ
160 if( nMask & 0x0400 ) rStm >> aAccelConfig;
161 TEST_READ
162 if( nMask & 0x0800 ) rStm >> aFastCall;
163 TEST_READ
164 if( nMask & 0x1000 ) rStm >> aContainer;
165 TEST_READ
167 if( nMask & 0x2000 )
169 SvMetaType * pT;
170 rStm >> pT;
171 aSlotType = pT;
174 TEST_READ
175 if( nMask & 0x4000 ) rStm >> aRecordAbsolute;
176 TEST_READ
177 if( nMask & 0x8000 ) rStm >> aImageRotation;
179 nMask = 0;
180 rStm >> nMask;
182 TEST_READ
183 if( nMask & 0x0001 ) rStm >> aUnoName;
184 if( nMask & 0x0002 ) rStm >> aImageReflection;
187 void SvMetaSlot::Save( SvPersistStream & rStm )
189 SvMetaAttribute::Save( rStm );
191 // Maske erstellen
192 sal_uInt16 nMask = 0;
193 if( aMethod.Is() ) nMask |= 0x0001;
194 if( aGroupId.Len() ) nMask |= 0x0002;
195 if( aHasCoreId.IsSet() ) nMask |= 0x0004;
196 if( aConfigId.Len() ) nMask |= 0x0008;
197 if( aExecMethod.Len() ) nMask |= 0x0010;
198 if( aStateMethod.Len() ) nMask |= 0x0020;
199 if( aDefault.Len() ) nMask |= 0x0040;
200 if( aPseudoSlots.IsSet() ) nMask |= 0x0080;
201 if( aGet.IsSet() ) nMask |= 0x0100;
202 if( aSet.IsSet() ) nMask |= 0x0200;
203 if( aCachable.IsSet() ) nMask |= 0x0400;
204 if( aVolatile.IsSet() ) nMask |= 0x0800;
205 if( aToggle.IsSet() ) nMask |= 0x1000;
206 if( aAutoUpdate.IsSet() ) nMask |= 0x2000;
207 if( aSynchron.IsSet() ) nMask |= 0x4000;
208 if( aAsynchron.IsSet() ) nMask |= 0x8000;
210 // Daten schreiben
211 rStm << nMask;
212 TEST_WRITE
213 if( nMask & 0x0001 ) rStm << aMethod;
214 TEST_WRITE
215 if( nMask & 0x0002 ) rStm << aGroupId;
216 TEST_WRITE
217 if( nMask & 0x0004 ) rStm << aHasCoreId;
218 TEST_WRITE
219 if( nMask & 0x0008 ) rStm << aConfigId;
220 TEST_WRITE
221 if( nMask & 0x0010 ) rStm << aExecMethod;
222 TEST_WRITE
223 if( nMask & 0x0020 ) rStm << aStateMethod;
224 TEST_WRITE
225 if( nMask & 0x0040 ) rStm << aDefault;
226 TEST_WRITE
227 if( nMask & 0x0080 ) rStm << aPseudoSlots;
228 TEST_WRITE
229 if( nMask & 0x0100 ) rStm << aGet;
230 TEST_WRITE
231 if( nMask & 0x0200 ) rStm << aSet;
232 TEST_WRITE
233 if( nMask & 0x0400 ) rStm << aCachable;
234 TEST_WRITE
235 if( nMask & 0x0800 ) rStm << aVolatile;
236 TEST_WRITE
237 if( nMask & 0x1000 ) rStm << aToggle;
238 TEST_WRITE
239 if( nMask & 0x2000 ) rStm << aAutoUpdate;
240 TEST_WRITE
241 if( nMask & 0x4000 ) rStm << aSynchron;
242 TEST_WRITE
243 if( nMask & 0x8000 ) rStm << aAsynchron;
245 // naechste Fuhre schreiben
246 // Maske erstellen
247 nMask = 0;
248 if( aRecordPerItem.IsSet() ) nMask |= 0x0001;
249 if( aRecordManual.IsSet() ) nMask |= 0x0002;
250 if( aNoRecord.IsSet() ) nMask |= 0x0004;
251 if( aHasDialog.IsSet() ) nMask |= 0x0008;
252 if ( aDisableFlags.IsSet() ) nMask |= 0x0010;
253 if( aPseudoPrefix.Len() ) nMask |= 0x0020;
254 if( aRecordPerSet.IsSet() ) nMask |= 0x0040;
255 if( aMenuConfig.IsSet() ) nMask |= 0x0080;
256 if( aToolBoxConfig.IsSet() ) nMask |= 0x0100;
257 if( aStatusBarConfig.IsSet() )nMask |= 0x0200;
258 if( aAccelConfig.IsSet() ) nMask |= 0x0400;
259 if( aFastCall.IsSet() ) nMask |= 0x0800;
260 if( aContainer.IsSet() ) nMask |= 0x1000;
261 if( aSlotType.Is() ) nMask |= 0x2000;
262 if( aRecordAbsolute.IsSet() ) nMask |= 0x4000;
263 if( aImageRotation.IsSet() ) nMask |= 0x8000;
265 // Daten schreiben
266 rStm << nMask;
267 TEST_WRITE
268 if( nMask & 0x0001 ) rStm << aRecordPerItem;
269 TEST_WRITE
270 if( nMask & 0x0002 ) rStm << aRecordManual;
271 TEST_WRITE
272 if( nMask & 0x0004 ) rStm << aNoRecord;
273 TEST_WRITE
274 if( nMask & 0x0008 ) rStm << aHasDialog;
275 TEST_WRITE
276 if( nMask & 0x0010 ) rStm << aDisableFlags;
277 TEST_WRITE
278 if( nMask & 0x0020 ) rStm << aPseudoPrefix;
279 TEST_WRITE
280 if( nMask & 0x0040 ) rStm << aRecordPerSet;
281 TEST_WRITE
282 if( nMask & 0x0080 ) rStm << aMenuConfig;
283 TEST_WRITE
284 if( nMask & 0x0100 ) rStm << aToolBoxConfig;
285 TEST_WRITE
286 if( nMask & 0x0200 ) rStm << aStatusBarConfig;
287 TEST_WRITE
288 if( nMask & 0x0400 ) rStm << aAccelConfig;
289 TEST_WRITE
290 if( nMask & 0x0800 ) rStm << aFastCall;
291 TEST_WRITE
292 if( nMask & 0x1000 ) rStm << aContainer;
293 TEST_WRITE
294 if( nMask & 0x2000 ) rStm << aSlotType;
295 TEST_WRITE
296 if( nMask & 0x4000 ) rStm << aRecordAbsolute;
297 TEST_WRITE
298 if( nMask & 0x8000 ) rStm << aImageRotation;
300 nMask = 0;
301 if( aUnoName.IsSet() ) nMask |= 0x0001;
302 if( aImageReflection.IsSet() ) nMask |= 0x0002;
303 rStm << nMask;
304 TEST_WRITE
305 if( nMask & 0x0001 ) rStm << aUnoName;
306 TEST_WRITE
307 if( nMask & 0x0002 ) rStm << aImageReflection;
310 /*************************************************************************
311 |* SvMetaSlot::IsVariable()
313 |* Beschreibung
314 *************************************************************************/
315 sal_Bool SvMetaSlot::IsVariable() const
317 return SvMetaAttribute::IsVariable();
320 /*************************************************************************
321 |* SvMetaSlot::IsMethod()
323 |* Beschreibung
324 *************************************************************************/
325 sal_Bool SvMetaSlot::IsMethod() const
327 sal_Bool b = SvMetaAttribute::IsMethod();
328 b |= NULL != GetMethod();
329 return b;
332 /*************************************************************************
333 |* SvMetaSlot::HasMethods()
335 |* Beschreibung
336 *************************************************************************/
337 ByteString SvMetaSlot::GetMangleName( sal_Bool bVariable ) const
339 if( !bVariable )
341 SvMetaAttribute * pMeth = GetMethod();
342 if( pMeth )
343 return pMeth->GetName();
345 return GetName();
348 /*************************************************************************
349 |* Referenz
351 |* Beschreibung Zweites sal_False bei den SvBOOL-Objekten bedeutet,
352 |* IsSet() liefert sal_False (Defaultinitialisierung).
353 *************************************************************************/
354 /** Referenz Aufloesung **/
355 SvMetaType * SvMetaSlot::GetSlotType() const
357 if( aSlotType.Is() || !GetRef() ) return aSlotType;
358 return ((SvMetaSlot *)GetRef())->GetSlotType();
360 SvMetaAttribute * SvMetaSlot::GetMethod() const
362 if( aMethod.Is() || !GetRef() ) return aMethod;
363 return ((SvMetaSlot *)GetRef())->GetMethod();
365 sal_Bool SvMetaSlot::GetHasCoreId() const
367 if( aHasCoreId.IsSet() || !GetRef() ) return aHasCoreId;
368 return ((SvMetaSlot *)GetRef())->GetHasCoreId();
370 const ByteString & SvMetaSlot::GetGroupId() const
372 if( aGroupId.Len() || !GetRef() ) return aGroupId;
373 return ((SvMetaSlot *)GetRef())->GetGroupId();
375 const ByteString & SvMetaSlot::GetDisableFlags() const
377 if( aDisableFlags.Len() || !GetRef() ) return aDisableFlags;
378 return ((SvMetaSlot *)GetRef())->GetDisableFlags();
380 const ByteString & SvMetaSlot::GetConfigId() const
382 if( aConfigId.Len() || !GetRef() ) return aConfigId;
383 return ((SvMetaSlot *)GetRef())->GetConfigId();
385 const ByteString & SvMetaSlot::GetExecMethod() const
387 if( aExecMethod.Len() || !GetRef() ) return aExecMethod;
388 return ((SvMetaSlot *)GetRef())->GetExecMethod();
390 const ByteString & SvMetaSlot::GetStateMethod() const
392 if( aStateMethod.Len() || !GetRef() ) return aStateMethod;
393 return ((SvMetaSlot *)GetRef())->GetStateMethod();
395 const ByteString & SvMetaSlot::GetDefault() const
397 if( aDefault.Len() || !GetRef() ) return aDefault;
398 return ((SvMetaSlot *)GetRef())->GetDefault();
400 sal_Bool SvMetaSlot::GetPseudoSlots() const
402 if( aPseudoSlots.IsSet() || !GetRef() ) return aPseudoSlots;
403 return ((SvMetaSlot *)GetRef())->GetPseudoSlots();
406 sal_Bool SvMetaSlot::GetGet() const
408 if( aGet.IsSet() || !GetRef() ) return aGet;
409 return ((SvMetaSlot *)GetRef())->GetGet();
411 sal_Bool SvMetaSlot::GetSet() const
413 if( aSet.IsSet() || !GetRef() ) return aSet;
414 return ((SvMetaSlot *)GetRef())->GetSet();
417 sal_Bool SvMetaSlot::GetCachable() const
419 // Cachable und Volatile sind exclusiv
420 if( !GetRef() || aCachable.IsSet() || aVolatile.IsSet() )
421 return aCachable;
422 return ((SvMetaSlot *)GetRef())->GetCachable();
424 sal_Bool SvMetaSlot::GetVolatile() const
426 // Cachable und Volatile sind exclusiv
427 if( !GetRef() || aVolatile.IsSet() || aCachable.IsSet() )
428 return aVolatile;
429 return ((SvMetaSlot *)GetRef())->GetVolatile();
431 sal_Bool SvMetaSlot::GetToggle() const
433 if( aToggle.IsSet() || !GetRef() ) return aToggle;
434 return ((SvMetaSlot *)GetRef())->GetToggle();
436 sal_Bool SvMetaSlot::GetAutoUpdate() const
438 if( aAutoUpdate.IsSet() || !GetRef() ) return aAutoUpdate;
439 return ((SvMetaSlot *)GetRef())->GetAutoUpdate();
441 sal_Bool SvMetaSlot::GetSynchron() const
443 // Synchron und Asynchron sind exclusiv
444 if( !GetRef() || aSynchron.IsSet() || aAsynchron.IsSet() )
445 return aSynchron;
446 return ((SvMetaSlot *)GetRef())->GetSynchron();
448 sal_Bool SvMetaSlot::GetAsynchron() const
450 // Synchron und Asynchron sind exclusiv
451 if( !GetRef() || aAsynchron.IsSet() || aSynchron.IsSet() )
452 return aAsynchron;
453 return ((SvMetaSlot *)GetRef())->GetAsynchron();
455 sal_Bool SvMetaSlot::GetRecordPerItem() const
457 // Record- PerItem, No, PerSet und Manual sind exclusiv
458 if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet()
459 || aRecordPerSet.IsSet() || aRecordManual.IsSet() )
460 return aRecordPerItem;
461 return ((SvMetaSlot *)GetRef())->GetRecordPerItem();
463 sal_Bool SvMetaSlot::GetRecordPerSet() const
465 // Record- PerItem, No, PerSet und Manual sind exclusiv
466 if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet()
467 || aRecordPerSet.IsSet() || aRecordManual.IsSet() )
468 return aRecordPerSet;
469 return ((SvMetaSlot *)GetRef())->GetRecordPerSet();
471 sal_Bool SvMetaSlot::GetRecordManual() const
473 // Record- PerItem, No, PerSet und Manual sind exclusiv
474 if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet()
475 || aRecordPerSet.IsSet() || aRecordManual.IsSet() )
476 return aRecordManual;
477 return ((SvMetaSlot *)GetRef())->GetRecordManual();
479 sal_Bool SvMetaSlot::GetNoRecord() const
481 // Record- PerItem, No, PerSet und Manual sind exclusiv
482 if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet()
483 || aRecordPerSet.IsSet() || aRecordManual.IsSet() )
484 return aNoRecord;
485 return ((SvMetaSlot *)GetRef())->GetNoRecord();
487 sal_Bool SvMetaSlot::GetRecordAbsolute() const
489 if( !GetRef() || aRecordAbsolute.IsSet() )
490 return aRecordAbsolute;
491 return ((SvMetaSlot *)GetRef())->GetRecordAbsolute();
493 sal_Bool SvMetaSlot::GetHasDialog() const
495 if( aHasDialog.IsSet() || !GetRef() ) return aHasDialog;
496 return ((SvMetaSlot *)GetRef())->GetHasDialog();
498 const ByteString & SvMetaSlot::GetPseudoPrefix() const
500 if( aPseudoPrefix.Len() || !GetRef() ) return aPseudoPrefix;
501 return ((SvMetaSlot *)GetRef())->GetPseudoPrefix();
503 sal_Bool SvMetaSlot::GetMenuConfig() const
505 if( aMenuConfig.IsSet() || !GetRef() ) return aMenuConfig;
506 return ((SvMetaSlot *)GetRef())->GetMenuConfig();
508 sal_Bool SvMetaSlot::GetToolBoxConfig() const
510 if( aToolBoxConfig.IsSet() || !GetRef() ) return aToolBoxConfig;
511 return ((SvMetaSlot *)GetRef())->GetToolBoxConfig();
513 sal_Bool SvMetaSlot::GetStatusBarConfig() const
515 if( aStatusBarConfig.IsSet() || !GetRef() ) return aStatusBarConfig;
516 return ((SvMetaSlot *)GetRef())->GetStatusBarConfig();
518 sal_Bool SvMetaSlot::GetAccelConfig() const
520 if( aAccelConfig.IsSet() || !GetRef() ) return aAccelConfig;
521 return ((SvMetaSlot *)GetRef())->GetAccelConfig();
523 sal_Bool SvMetaSlot::GetFastCall() const
525 if( aFastCall.IsSet() || !GetRef() ) return aFastCall;
526 return ((SvMetaSlot *)GetRef())->GetFastCall();
528 sal_Bool SvMetaSlot::GetContainer() const
530 if( aContainer.IsSet() || !GetRef() ) return aContainer;
531 return ((SvMetaSlot *)GetRef())->GetContainer();
534 sal_Bool SvMetaSlot::GetImageRotation() const
536 if( aImageRotation.IsSet() || !GetRef() ) return aImageRotation;
537 return ((SvMetaSlot *)GetRef())->GetImageRotation();
540 sal_Bool SvMetaSlot::GetImageReflection() const
542 if( aImageReflection.IsSet() || !GetRef() ) return aImageReflection;
543 return ((SvMetaSlot *)GetRef())->GetImageReflection();
546 const ByteString& SvMetaSlot::GetUnoName() const
548 if( aUnoName.IsSet() || !GetRef() ) return aUnoName;
549 return ((SvMetaSlot *)GetRef())->GetUnoName();
552 /*************************************************************************
553 |* SvMetaSlot::FillSbxObject()
555 |* Beschreibung
556 *************************************************************************/
558 void SvMetaSlot::FillSbxObject( SvIdlDataBase & rBase, SbxObject * pObj,
559 sal_Bool bVariable )
561 // keine Attribut fuer Automation
562 if( !GetAutomation() || !GetExport() )
563 return;
565 if( !bVariable )
567 SvMetaAttributeRef xM = GetMethod();
568 if( xM.Is() )
570 SvMetaType * pType = xM->GetType();
571 SvMetaType * pRetBaseType = pType->GetReturnType()->GetBaseType();
572 ByteString aName = xM->GetName();
574 SbxMethodRef xMeth = new SbxMethod( aName,
575 pRetBaseType->GetSbxDataType() );
576 pType->FillSbxObject( xMeth, bVariable );
577 xMeth->SetUserData( MakeSlotValue(rBase, sal_False) );
579 pObj->Insert( &xMeth );
580 return;
584 SvMetaAttribute::FillSbxObject( rBase, pObj, bVariable );
588 #ifdef IDL_COMPILER
589 /*************************************************************************
590 |* SvMetaSlot::ReadAttributesSvIdl()
592 |* Beschreibung
593 *************************************************************************/
594 void SvMetaSlot::ReadAttributesSvIdl( SvIdlDataBase & rBase,
595 SvTokenStream & rInStm )
597 SvMetaAttribute::ReadAttributesSvIdl( rBase, rInStm );
599 sal_Bool bOk = sal_False;
600 bOk |= aDefault.ReadSvIdl( SvHash_Default(), rInStm );
601 bOk |= aPseudoSlots.ReadSvIdl( SvHash_PseudoSlots(), rInStm );
602 bOk |= aHasCoreId.ReadSvIdl( SvHash_HasCoreId(), rInStm );
603 bOk |= aGroupId.ReadSvIdl( SvHash_GroupId(), rInStm );
604 bOk |= aExecMethod.ReadSvIdl( SvHash_ExecMethod(), rInStm );
605 bOk |= aStateMethod.ReadSvIdl( SvHash_StateMethod(), rInStm );
606 bOk |= aDisableFlags.ReadSvIdl( SvHash_DisableFlags(), rInStm );
607 if( aGet.ReadSvIdl( SvHash_Get(), rInStm ) )
609 rBase.WriteError( "warning", ByteString( rInStm.GetFileName(), RTL_TEXTENCODING_UTF8 ),
610 "<Get> old style, use Readonly",
611 rInStm.GetToken()->GetLine(),
612 rInStm.GetToken()->GetColumn() );
614 if( aSet.ReadSvIdl( SvHash_Set(), rInStm ) )
616 rBase.WriteError( "warning", ByteString( rInStm.GetFileName(), RTL_TEXTENCODING_UTF8 ),
617 "<Set> old style, use method declaration",
618 rInStm.GetToken()->GetLine(),
619 rInStm.GetToken()->GetColumn() );
622 if( aCachable.ReadSvIdl( SvHash_Cachable(), rInStm ) )
623 SetCachable( aCachable ), bOk = sal_True;
624 if( aVolatile.ReadSvIdl( SvHash_Volatile(), rInStm ) )
625 SetVolatile( aVolatile ), bOk = sal_True;
626 if( aToggle.ReadSvIdl( SvHash_Toggle(), rInStm ) )
627 SetToggle( aToggle ), bOk = sal_True;
628 if( aAutoUpdate.ReadSvIdl( SvHash_AutoUpdate(), rInStm ) )
629 SetAutoUpdate( aAutoUpdate ), bOk = sal_True;
631 if( aSynchron.ReadSvIdl( SvHash_Synchron(), rInStm ) )
632 SetSynchron( aSynchron ), bOk = sal_True;
633 if( aAsynchron.ReadSvIdl( SvHash_Asynchron(), rInStm ) )
634 SetAsynchron( aAsynchron ), bOk = sal_True;
636 if( aRecordAbsolute.ReadSvIdl( SvHash_RecordAbsolute(), rInStm ) )
637 SetRecordAbsolute( aRecordAbsolute), bOk = sal_True;
638 if( aRecordPerItem.ReadSvIdl( SvHash_RecordPerItem(), rInStm ) )
639 SetRecordPerItem( aRecordPerItem ), bOk = sal_True;
640 if( aRecordPerSet.ReadSvIdl( SvHash_RecordPerSet(), rInStm ) )
641 SetRecordPerSet( aRecordPerSet ), bOk = sal_True;
642 if( aRecordManual.ReadSvIdl( SvHash_RecordManual(), rInStm ) )
643 SetRecordManual( aRecordManual ), bOk = sal_True;
644 if( aNoRecord.ReadSvIdl( SvHash_NoRecord(), rInStm ) )
645 SetNoRecord( aNoRecord ), bOk = sal_True;
647 bOk |= aHasDialog.ReadSvIdl( SvHash_HasDialog(), rInStm );
648 bOk |= aPseudoPrefix.ReadSvIdl( SvHash_PseudoPrefix(), rInStm );
649 bOk |= aMenuConfig.ReadSvIdl( SvHash_MenuConfig(), rInStm );
650 bOk |= aToolBoxConfig.ReadSvIdl( SvHash_ToolBoxConfig(), rInStm );
651 bOk |= aStatusBarConfig.ReadSvIdl( SvHash_StatusBarConfig(), rInStm );
652 bOk |= aAccelConfig.ReadSvIdl( SvHash_AccelConfig(), rInStm );
654 SvBOOL aAllConfig;
655 if( aAllConfig.ReadSvIdl( SvHash_AllConfig(), rInStm ) )
656 SetAllConfig( aAllConfig ), bOk = sal_True;
657 bOk |= aFastCall.ReadSvIdl( SvHash_FastCall(), rInStm );
658 bOk |= aContainer.ReadSvIdl( SvHash_Container(), rInStm );
659 bOk |= aImageRotation.ReadSvIdl( SvHash_ImageRotation(), rInStm );
660 bOk |= aImageReflection.ReadSvIdl( SvHash_ImageReflection(), rInStm );
661 bOk |= aUnoName.ReadSvIdl( SvHash_UnoName(), rInStm );
663 if( !bOk )
665 if( !aSlotType.Is() )
667 sal_uInt32 nTokPos = rInStm.Tell();
668 SvToken * pTok = rInStm.GetToken_Next();
669 if( pTok->Is( SvHash_SlotType() ) )
671 sal_Bool bBraket = rInStm.Read( '(' );
672 if( bBraket || rInStm.Read( '=' ) )
674 aSlotType = rBase.ReadKnownType( rInStm );
675 if( aSlotType.Is() )
677 if( aSlotType->IsItem() )
679 if( bBraket )
681 if( rInStm.Read( ')' ) )
682 return;
684 else
685 return;
687 rBase.SetError( "the SlotType is not a item", rInStm.GetToken() );
688 rBase.WriteError( rInStm );
690 rBase.SetError( "SlotType with unknown item type", rInStm.GetToken() );
691 rBase.WriteError( rInStm );
694 rInStm.Seek( nTokPos );
697 if( !aMethod.Is() )
699 SvToken * pTok = rInStm.GetToken();
700 if( pTok->IsIdentifier() )
702 aMethod = new SvMetaSlot();
703 sal_uInt32 nTokPos = rInStm.Tell();
704 if( aMethod->ReadSvIdl( rBase, rInStm ) )
706 if( aMethod->IsMethod() )
708 aMethod->SetSlotId( GetSlotId() );
709 if( aMethod->Test( rBase, rInStm ) )
710 return;
712 rInStm.Seek( nTokPos );
714 aMethod.Clear();
720 /*************************************************************************
721 |* SvMetaSlot::WriteAttributesSvIdl()
723 |* Beschreibung
724 *************************************************************************/
725 void SvMetaSlot::WriteAttributesSvIdl( SvIdlDataBase & rBase,
726 SvStream & rOutStm,
727 sal_uInt16 nTab )
729 SvMetaAttribute::WriteAttributesSvIdl( rBase, rOutStm, nTab );
731 if( aSlotType.Is() )
733 WriteTab( rOutStm, nTab );
734 rOutStm << SvHash_SlotType()->GetName().GetBuffer() << '(';
735 aSlotType->WriteTheType( rBase, rOutStm, nTab, WRITE_IDL );
736 rOutStm << ");" << endl;
738 if( aMethod.Is() )
740 WriteTab( rOutStm, nTab );
741 aMethod->WriteSvIdl( rBase, rOutStm, nTab );
742 rOutStm << ';' << endl;
744 if( aHasCoreId )
746 aHasCoreId.WriteSvIdl( SvHash_HasCoreId(), rOutStm );
747 rOutStm << ';' << endl;
749 if( aGroupId.Len() )
751 WriteTab( rOutStm, nTab );
752 aGroupId.WriteSvIdl( SvHash_GroupId(), rOutStm, nTab +1);
753 rOutStm << ';' << endl;
755 if( aExecMethod.Len() )
757 WriteTab( rOutStm, nTab );
758 aExecMethod.WriteSvIdl( SvHash_ExecMethod(), rOutStm, nTab +1);
759 rOutStm << ';' << endl;
761 if( aStateMethod.Len() )
763 WriteTab( rOutStm, nTab );
764 aStateMethod.WriteSvIdl( SvHash_StateMethod(), rOutStm, nTab +1);
765 rOutStm << ';' << endl;
768 if( aDisableFlags.Len() )
770 WriteTab( rOutStm, nTab );
771 aDisableFlags.WriteSvIdl( SvHash_DisableFlags(), rOutStm, nTab +1);
772 rOutStm << ';' << endl;
775 if( aSet || aGet || aPseudoSlots )
777 WriteTab( rOutStm, nTab );
778 char const * p = "";
779 if( aPseudoSlots )
781 aPseudoSlots.WriteSvIdl( SvHash_PseudoSlots(), rOutStm );
782 p = ", ";
784 if( aGet )
786 rOutStm << p;
787 aGet.WriteSvIdl( SvHash_Get(), rOutStm );
788 p = ", ";
790 if( aSet )
792 rOutStm << p;
793 aSet.WriteSvIdl( SvHash_Set(), rOutStm );
795 rOutStm << ';' << endl;
798 ByteString aDel( ", " );
799 ByteString aOut;
800 if( aVolatile )
801 aOut += aVolatile.GetSvIdlString( SvHash_Volatile() );
802 else if( !aCachable )
803 // wegen Default == sal_True, nur wenn kein anderer gesetzt
804 aOut += aCachable.GetSvIdlString( SvHash_Cachable() );
805 else
806 aDel.Erase();
808 if( aToggle )
810 ( aOut += aDel ) += aToggle.GetSvIdlString( SvHash_Toggle() );
811 aDel = ", ";
813 if( aAutoUpdate )
815 (aOut += aDel ) += aAutoUpdate.GetSvIdlString( SvHash_AutoUpdate() );
816 aDel = ", ";
819 ByteString aDel1( ", " );
820 if( aAsynchron )
821 ( aOut += aDel ) += aAsynchron.GetSvIdlString( SvHash_Asynchron() );
822 else if( !aSynchron )
823 // wegen Default == sal_True, nur wenn kein anderer gesetzt
824 ( aOut += aDel ) += aSynchron.GetSvIdlString( SvHash_Synchron() );
825 else
826 aDel1 = aDel;
828 aDel = ", ";
829 if( aRecordManual )
830 ( aOut += aDel1 ) += aRecordManual.GetSvIdlString( SvHash_RecordManual() );
831 else if( aNoRecord )
832 ( aOut += aDel1 ) += aNoRecord.GetSvIdlString( SvHash_NoRecord() );
833 else if( !aRecordPerSet )
834 // wegen Default == sal_True, nur wenn kein anderer gesetzt
835 ( aOut += aDel1 ) += aRecordPerSet.GetSvIdlString( SvHash_RecordPerSet() );
836 else if( aRecordPerItem )
837 ( aOut += aDel1 ) += aRecordPerItem.GetSvIdlString( SvHash_RecordPerItem() );
838 else
839 aDel = aDel1;
841 if( aRecordAbsolute )
843 ( aOut += aDel ) += aRecordAbsolute.GetSvIdlString( SvHash_RecordAbsolute() );
844 aDel = ", ";
846 if( aHasDialog )
848 ( aOut += aDel ) += aHasDialog.GetSvIdlString( SvHash_HasDialog() );
849 aDel = ", ";
851 if( aMenuConfig )
853 ( aOut += aDel ) += aMenuConfig.GetSvIdlString( SvHash_MenuConfig() );
854 aDel = ", ";
856 if( aToolBoxConfig )
858 ( aOut += aDel ) += aToolBoxConfig.GetSvIdlString( SvHash_ToolBoxConfig() );
859 aDel = ", ";
861 if( aStatusBarConfig )
863 ( aOut += aDel ) += aStatusBarConfig.GetSvIdlString( SvHash_StatusBarConfig() );
864 aDel = ", ";
866 if( aAccelConfig )
868 ( aOut += aDel ) += aAccelConfig.GetSvIdlString( SvHash_AccelConfig() );
869 aDel = ", ";
871 if( aFastCall )
873 ( aOut += aDel ) += aFastCall.GetSvIdlString( SvHash_FastCall() );
874 aDel = ", ";
876 if( aContainer )
878 ( aOut += aDel ) += aContainer.GetSvIdlString( SvHash_Container() );
879 aDel = ", ";
881 if( aImageRotation )
883 ( aOut += aDel ) += aImageRotation.GetSvIdlString( SvHash_ImageRotation() );
884 aDel = ", ";
887 if( aImageReflection )
889 ( aOut += aDel ) += aImageReflection.GetSvIdlString( SvHash_ImageReflection() );
890 aDel = ", ";
893 if( aOut.Len() )
895 WriteTab( rOutStm, nTab );
896 rOutStm << aOut.GetBuffer() << endl;
901 /*************************************************************************
902 |* SvMetaSlot::Test()
904 |* Beschreibung
905 *************************************************************************/
906 sal_Bool SvMetaSlot::Test( SvIdlDataBase & rBase, SvTokenStream & rInStm )
908 sal_Bool bOk = SvMetaAttribute::Test( rBase, rInStm );
909 if( bOk )
911 SvMetaType * pType = GetType();
912 if( pType->GetType() == TYPE_METHOD )
913 pType = pType->GetReturnType();
914 if( !pType->IsItem() )
916 rBase.SetError( "this attribute is not a slot", rInStm.GetToken() );
917 rBase.WriteError( rInStm );
918 bOk = sal_False;
922 return bOk;
925 /*************************************************************************
926 |* SvMetaSlot::ReadSvIdl()
928 |* Beschreibung
929 *************************************************************************/
930 sal_Bool SvMetaSlot::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm )
932 sal_uInt32 nTokPos = rInStm.Tell();
933 sal_Bool bOk = sal_True;
935 SvMetaAttribute * pAttr = rBase.ReadKnownAttr( rInStm, GetType() );
936 if( pAttr )
938 // F"ur Testzwecke: Referenz bei Kurz-Syntax
939 SvMetaSlot * pKnownSlot = PTR_CAST( SvMetaSlot, pAttr );
940 if( pKnownSlot )
942 SetRef( pKnownSlot );
943 SetName( pKnownSlot->GetName(), &rBase );
944 bOk = SvMetaName::ReadSvIdl( rBase, rInStm );
946 else
948 ByteString aStr( "attribute " );
949 aStr += pAttr->GetName();
950 aStr += " is method or variable but not a slot";
951 rBase.SetError( aStr, rInStm.GetToken() );
952 rBase.WriteError( rInStm );
953 bOk = sal_False;
956 else
958 bOk = SvMetaAttribute::ReadSvIdl( rBase, rInStm );
960 SvMetaAttribute *pAttr2 = rBase.SearchKnownAttr( GetSlotId() );
961 if( pAttr2 )
963 // F"ur Testzwecke: Referenz bei kompletter Definition
964 SvMetaSlot * pKnownSlot = PTR_CAST( SvMetaSlot, pAttr2 );
965 if( pKnownSlot )
967 SetRef( pKnownSlot );
969 // Namen d"urfen abweichen, da mit angegeben
970 if ( pKnownSlot->GetName() != GetName() )
972 DBG_ERROR("Illegal definition!");
973 rInStm.Seek( nTokPos );
974 return sal_False;
977 SetName( pKnownSlot->GetName(), &rBase );
979 else
981 ByteString aStr( "attribute " );
982 aStr += pAttr2->GetName();
983 aStr += " is method or variable but not a slot";
984 rBase.SetError( aStr, rInStm.GetToken() );
985 rBase.WriteError( rInStm );
986 bOk = sal_False;
991 if( !bOk )
992 rInStm.Seek( nTokPos );
994 return bOk;
997 /*************************************************************************
998 |* SvMetaSlot::WriteSvIdl()
1000 |* Beschreibung
1001 *************************************************************************/
1002 void SvMetaSlot::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
1003 sal_uInt16 nTab )
1005 SvMetaAttribute::WriteSvIdl( rBase, rOutStm, nTab );
1008 /*************************************************************************
1009 |* SvMetaSlot::Write()
1011 |* Beschreibung
1012 *************************************************************************/
1013 void SvMetaSlot::Write( SvIdlDataBase & rBase,
1014 SvStream & rOutStm, sal_uInt16 nTab,
1015 WriteType nT, WriteAttribute nA )
1017 if ( nT == WRITE_DOCU )
1019 if ( GetHidden() )
1020 return;
1022 else
1024 // keine Attribut fuer Automation
1025 if( !GetAutomation() || !GetExport() )
1026 return;
1029 if( !(nA & WA_VARIABLE) )
1031 SvMetaAttributeRef xM = GetMethod();
1032 if( xM.Is() )
1034 xM->SetSlotId( GetSlotId() );
1035 xM->SetDescription( GetDescription() );
1036 xM->Write( rBase, rOutStm, nTab, nT, nA );
1037 return;
1041 SvMetaAttribute::Write( rBase, rOutStm, nTab, nT, nA );
1045 void SvMetaSlot::Insert( SvSlotElementList& rList, const ByteString & rPrefix,
1046 SvIdlDataBase& rBase)
1048 // Einf"ugeposition durch bin"are Suche in der SlotListe ermitteln
1049 sal_uInt16 nId = (sal_uInt16) GetSlotId().GetValue();
1050 sal_uInt16 nListCount = (sal_uInt16) rList.Count();
1051 sal_uInt16 nPos;
1052 sal_uLong m; // for inner "for" loop
1054 if ( !nListCount )
1055 nPos = 0;
1056 else if ( nListCount == 1 )
1057 nPos = rList.GetObject(0)->xSlot->GetSlotId().GetValue() >= nId ? 0 : 1;
1058 else
1060 sal_uInt16 nMid = 0, nLow = 0;
1061 sal_uInt16 nHigh = nListCount - 1;
1062 sal_Bool bFound = sal_False;
1063 while ( !bFound && nLow <= nHigh )
1065 nMid = (nLow + nHigh) >> 1;
1066 DBG_ASSERT( nMid < nListCount, "bsearch ist buggy" );
1067 int nDiff = (int) nId - (int) rList.GetObject(nMid)->xSlot->GetSlotId().GetValue();
1068 if ( nDiff < 0)
1070 if ( nMid == 0 )
1071 break;
1072 nHigh = nMid - 1;
1074 else if ( nDiff > 0 )
1076 nLow = nMid + 1;
1077 if ( nLow == 0 )
1078 break;
1080 else
1081 bFound = sal_True;
1084 DBG_ASSERT(!bFound, "Duplicate SlotId!");
1085 nPos = bFound ? nMid : nLow;
1088 DBG_ASSERT( nPos <= nListCount,
1089 "nPos too large" );
1090 DBG_ASSERT( nPos == nListCount || nId <=
1091 (sal_uInt16) rList.GetObject(nPos)->xSlot->GetSlotId().GetValue(),
1092 "Successor has lower SlotId" );
1093 DBG_ASSERT( nPos == 0 || nId >
1094 (sal_uInt16) rList.GetObject(nPos-1)->xSlot->GetSlotId().GetValue(),
1095 "Predecessor has higher SlotId" );
1096 DBG_ASSERT( nPos+1 >= nListCount || nId <
1097 (sal_uInt16) rList.GetObject(nPos+1)->xSlot->GetSlotId().GetValue(),
1098 "Successor has lower SlotId" );
1100 rList.Insert( new SvSlotElement( this, rPrefix ), nPos );
1102 // EnumSlots plattklopfen
1103 SvMetaTypeEnum * pEnum = NULL;
1104 SvMetaType * pBType = GetType()->GetBaseType();
1105 pEnum = PTR_CAST( SvMetaTypeEnum, pBType );
1106 if( GetPseudoSlots() && pEnum && pEnum->Count() )
1108 // Den MasterSlot clonen
1109 SvMetaSlotRef xEnumSlot;
1110 SvMetaSlot *pFirstEnumSlot = NULL;
1111 for( sal_uLong n = 0; n < pEnum->Count(); n++ )
1113 // Die SlotId erzeugen
1114 SvMetaEnumValue *enumValue = pEnum->GetObject(n);
1115 ByteString aValName = enumValue->GetName();
1116 ByteString aSId( GetSlotId() );
1117 if( GetPseudoPrefix().Len() )
1118 aSId = GetPseudoPrefix();
1119 aSId += '_';
1120 aSId += aValName.Copy( pEnum->GetPrefix().Len() );
1122 xEnumSlot = NULL;
1123 for( m=0; m<rBase.GetAttrList().Count(); m++ )
1125 SvMetaAttribute * pAttr = rBase.GetAttrList().GetObject( m );
1126 if( pAttr->GetSlotId() == aSId )
1128 SvMetaSlot* pSlot = PTR_CAST( SvMetaSlot, pAttr );
1129 xEnumSlot = pSlot->Clone();
1130 break;
1134 if ( m == rBase.GetAttrList().Count() )
1136 DBG_ERROR("Invalid EnumSlot!");
1137 xEnumSlot = Clone();
1138 sal_uLong nValue;
1139 if ( rBase.FindId(aSId , &nValue) )
1141 SvNumberIdentifier aId;
1142 *((SvIdentifier*)&aId) = aSId;
1143 aId.SetValue(nValue);
1144 xEnumSlot->SetSlotId(aId);
1148 // Die Slaves sind kein Master !
1149 xEnumSlot->aPseudoSlots = sal_False;
1150 xEnumSlot->SetEnumValue(enumValue);
1152 if ( !pFirstEnumSlot || xEnumSlot->GetSlotId().GetValue() < pFirstEnumSlot->GetSlotId().GetValue() )
1153 pFirstEnumSlot = xEnumSlot;
1155 // Den erzeugten Slave ebenfalls einf"ugen
1156 xEnumSlot->Insert( rList, rPrefix, rBase);
1158 // Die EnumSlots mit dem Master verketten
1159 xEnumSlot->pLinkedSlot = this;
1162 // Master zeigt auf den ersten Slave
1163 pLinkedSlot = pFirstEnumSlot;
1165 // Slaves untereinander verketten
1166 rList.Seek((sal_uLong)0);
1167 xEnumSlot = pFirstEnumSlot;
1168 SvSlotElement *pEle;
1171 pEle = rList.Next();
1172 if ( pEle && pEle->xSlot->pLinkedSlot == this )
1174 xEnumSlot->pNextSlot = pEle->xSlot;
1175 xEnumSlot = pEle->xSlot;
1178 while ( pEle );
1179 xEnumSlot->pNextSlot = pFirstEnumSlot;
1184 /*************************************************************************
1185 |* SvMetaSlot::WriteSlotMap()
1187 |* Beschreibung
1188 *************************************************************************/
1189 static ByteString MakeSlotName( SvStringHashEntry * pEntry )
1191 ByteString aName( "SFX_SLOT_" );
1192 aName += pEntry->GetName();
1193 return aName.ToUpperAscii();
1196 void SvMetaSlot::WriteSlotStubs( const ByteString & rShellName,
1197 ByteStringList & rList,
1198 SvStream & rOutStm )
1201 ByteString aName = GetName();
1202 SvMetaAttribute * pAttr = rAttrList.First();
1203 while( pAttr )
1205 if( pAttr->GetName() == aName )
1206 break;
1207 pAttr = rAttrList.Next();
1209 if( pAttr )
1210 return;
1212 if ( !GetExport() && !GetHidden() )
1213 return;
1215 ByteString aMethodName( GetExecMethod() );
1216 if ( aMethodName.Len() && aMethodName != "NoExec" )
1218 sal_Bool bIn = sal_False;
1219 for( sal_uInt16 n = 0; n < rList.Count(); n++ )
1221 if( *(rList.GetObject(n)) == aMethodName )
1223 bIn=sal_True;
1224 break;
1228 if ( !bIn )
1230 rList.Insert( new ByteString(aMethodName), LIST_APPEND );
1231 rOutStm << "SFX_EXEC_STUB("
1232 << rShellName.GetBuffer()
1233 << ','
1234 << aMethodName.GetBuffer()
1235 << ')' << endl;
1239 aMethodName = GetStateMethod();
1240 if ( aMethodName.Len() && aMethodName != "NoState" )
1242 sal_Bool bIn = sal_False;
1243 for ( sal_uInt16 n=0; n < rList.Count(); n++ )
1245 if ( *(rList.GetObject(n)) == aMethodName )
1247 bIn=sal_True;
1248 break;
1252 if ( !bIn )
1254 rList.Insert( new ByteString(aMethodName), LIST_APPEND );
1255 rOutStm << "SFX_STATE_STUB("
1256 << rShellName.GetBuffer()
1257 << ','
1258 << aMethodName.GetBuffer()
1259 << ')' << endl;
1264 void SvMetaSlot::WriteSlot( const ByteString & rShellName, sal_uInt16 nCount,
1265 const ByteString & rSlotId,
1266 SvSlotElementList& rSlotList,
1267 const ByteString & rPrefix,
1268 SvIdlDataBase & rBase, SvStream & rOutStm )
1270 if ( !GetExport() && !GetHidden() )
1271 return;
1273 // sal_Bool bIsEnumSlot = 0 != rValueName.Len();
1274 sal_Bool bIsEnumSlot = 0 != pEnumValue;
1276 rOutStm << "// Slot Nr. " << ByteString::CreateFromInt32(nListPos).GetBuffer() << " : ";
1277 ByteString aSlotIdValue( ByteString::CreateFromInt32( GetSlotId().GetValue() ) );
1278 rOutStm << aSlotIdValue.GetBuffer() << endl;
1279 WriteTab( rOutStm, 1 );
1280 if( bIsEnumSlot )
1281 rOutStm << "SFX_NEW_SLOT_ENUM( ";
1282 else
1283 rOutStm << "SFX_NEW_SLOT_ARG( " << rShellName.GetBuffer() << ',' ;
1285 rOutStm << rSlotId.GetBuffer() << ',';
1286 const SvHelpContext& rHlpCtx = GetHelpContext();
1287 if( rHlpCtx.IsSet() )
1288 rOutStm << rHlpCtx.GetBuffer() << ',';
1289 else
1290 rOutStm << rSlotId.GetBuffer() << ',';
1292 // GroupId
1293 if( GetGroupId().Len() )
1294 rOutStm << GetGroupId().GetBuffer();
1295 else
1296 rOutStm << '0';
1297 rOutStm << ',' << endl;
1298 WriteTab( rOutStm, 4 );
1300 if( bIsEnumSlot )
1302 rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl["
1303 << ByteString::CreateFromInt32(pLinkedSlot->GetListPos()).GetBuffer()
1304 << "] /*Offset Master*/, " << endl;
1305 WriteTab( rOutStm, 4 );
1306 rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl["
1307 << ByteString::CreateFromInt32(pNextSlot->GetListPos()).GetBuffer()
1308 << "] /*Offset Next*/, " << endl;
1310 WriteTab( rOutStm, 4 );
1312 // SlotId
1313 if( GetSlotId().Len() )
1314 rOutStm << pLinkedSlot->GetSlotId().GetBuffer();
1315 else
1316 rOutStm << '0';
1317 rOutStm << ',';
1318 rOutStm << pEnumValue->GetName().GetBuffer();
1320 else
1322 // Den n"achsten Slot suchen, der die gleiche StateMethod hat wie ich
1323 // Die SlotList ist auf den aktuellen Slot geseekt
1324 SvSlotElement * pEle = rSlotList.Next();
1325 pNextSlot = pEle ? &pEle->xSlot : NULL;
1326 while ( pNextSlot )
1328 if ( !pNextSlot->pNextSlot &&
1329 pNextSlot->GetStateMethod() == GetStateMethod() )
1330 break;
1331 pEle = rSlotList.Next();
1332 pNextSlot = pEle ? &pEle->xSlot : NULL;
1335 if ( !pNextSlot )
1337 // Es gibt nach mir keinen Slot mehr, der die gleiche ExecMethode
1338 // hat. Also suche ich den ersten Slot, der diese hatte (das
1339 // k"onnte auch ich selbst sein)
1340 pEle = rSlotList.First();
1341 pNextSlot = pEle ? &pEle->xSlot : NULL;
1342 while ( pNextSlot != this )
1344 if ( !pNextSlot->pEnumValue &&
1345 pNextSlot->GetStateMethod() == GetStateMethod() )
1346 break;
1347 pEle = rSlotList.Next();
1348 pNextSlot = pEle ? &pEle->xSlot : NULL;
1352 if ( !pLinkedSlot )
1354 rOutStm << "0 ,";
1356 else
1358 rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl["
1359 << ByteString::CreateFromInt32(pLinkedSlot->GetListPos()).GetBuffer()
1360 << "] /*Offset Linked*/, " << endl;
1361 WriteTab( rOutStm, 4 );
1364 rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl["
1365 << ByteString::CreateFromInt32(pNextSlot->GetListPos()).GetBuffer()
1366 << "] /*Offset Next*/, " << endl;
1368 WriteTab( rOutStm, 4 );
1370 // ExecMethod schreiben, wenn nicht angegeben, standard Namen
1371 if( GetExecMethod().Len() && GetExecMethod() != "NoExec")
1372 rOutStm << "SFX_STUB_PTR(" << rShellName.GetBuffer() << ','
1373 << GetExecMethod().GetBuffer() << ')';
1374 else
1375 rOutStm << "SFX_STUB_PTR_EXEC_NONE";
1376 rOutStm << ',';
1378 // StateMethod schreiben, wenn nicht angegeben, standard Namen
1379 if( GetStateMethod().Len() && GetStateMethod() != "NoState")
1380 rOutStm << "SFX_STUB_PTR(" << rShellName.GetBuffer() << ','
1381 << GetStateMethod().GetBuffer() << ')';
1382 else
1383 rOutStm << "SFX_STUB_PTR_STATE_NONE";
1385 rOutStm << ',' << endl;
1386 WriteTab( rOutStm, 4 );
1388 // Flags schreiben
1389 if( GetHasCoreId() )
1390 rOutStm << MakeSlotName( SvHash_HasCoreId() ).GetBuffer() << '|';
1391 if( GetCachable() )
1392 rOutStm << MakeSlotName( SvHash_Cachable() ).GetBuffer() << '|';
1393 if( GetVolatile() )
1394 rOutStm << MakeSlotName( SvHash_Volatile() ).GetBuffer() << '|';
1395 if( GetToggle() )
1396 rOutStm << MakeSlotName( SvHash_Toggle() ).GetBuffer() << '|';
1397 if( GetAutoUpdate() )
1398 rOutStm << MakeSlotName( SvHash_AutoUpdate() ).GetBuffer() << '|';
1399 if( GetSynchron() )
1400 rOutStm << MakeSlotName( SvHash_Synchron() ).GetBuffer() << '|';
1401 if( GetAsynchron() )
1402 rOutStm << MakeSlotName( SvHash_Asynchron() ).GetBuffer() << '|';
1403 if( GetRecordPerItem() )
1404 rOutStm << MakeSlotName( SvHash_RecordPerItem() ).GetBuffer() << '|';
1405 if( GetRecordPerSet() )
1406 rOutStm << MakeSlotName( SvHash_RecordPerSet() ).GetBuffer() << '|';
1407 if( GetRecordManual() )
1408 rOutStm << MakeSlotName( SvHash_RecordManual() ).GetBuffer() << '|';
1409 if( GetNoRecord() )
1410 rOutStm << MakeSlotName( SvHash_NoRecord() ).GetBuffer() << '|';
1411 if( GetRecordAbsolute() )
1412 rOutStm << MakeSlotName( SvHash_RecordAbsolute() ).GetBuffer() << '|';
1413 if( GetHasDialog() )
1414 rOutStm << MakeSlotName( SvHash_HasDialog() ).GetBuffer() << '|';
1415 if( GetMenuConfig() )
1416 rOutStm << MakeSlotName( SvHash_MenuConfig() ).GetBuffer() << '|';
1417 if( GetToolBoxConfig() )
1418 rOutStm << MakeSlotName( SvHash_ToolBoxConfig() ).GetBuffer() << '|';
1419 if( GetStatusBarConfig() )
1420 rOutStm << MakeSlotName( SvHash_StatusBarConfig() ).GetBuffer() << '|';
1421 if( GetAccelConfig() )
1422 rOutStm << MakeSlotName( SvHash_AccelConfig() ).GetBuffer() << '|';
1423 if( GetFastCall() )
1424 rOutStm << MakeSlotName( SvHash_FastCall() ).GetBuffer() << '|';
1425 if( GetContainer() )
1426 rOutStm << MakeSlotName( SvHash_Container() ).GetBuffer() << '|';
1427 if ( GetReadOnlyDoc() )
1428 rOutStm << MakeSlotName( SvHash_ReadOnlyDoc() ).GetBuffer() << '|';
1429 if( GetImageRotation() )
1430 rOutStm << MakeSlotName( SvHash_ImageRotation() ).GetBuffer() << '|';
1431 if( GetImageReflection() )
1432 rOutStm << MakeSlotName( SvHash_ImageReflection() ).GetBuffer() << '|';
1433 rOutStm << '0';
1435 rOutStm << ',' << endl;
1436 WriteTab( rOutStm, 4 );
1437 if ( !GetDisableFlags().Len() )
1438 rOutStm << "0";
1439 else
1440 rOutStm << GetDisableFlags().GetBuffer();
1442 // Attribut Typ schreiben
1443 if( !bIsEnumSlot )
1445 rOutStm << ',' << endl;
1446 WriteTab( rOutStm, 4 );
1448 SvMetaType * pT = GetSlotType();
1449 if( !pT )
1451 if( !IsVariable() )
1452 pT = rBase.FindType( "SfxVoidItem" );
1453 else
1454 pT = GetType();
1456 if( pT )
1458 rOutStm << pT->GetName().GetBuffer();
1459 if( !rBase.FindType( pT, rBase.aUsedTypes ) )
1460 rBase.aUsedTypes.Append( pT );
1462 else
1463 rOutStm << "SfxVoidItem not defined";
1465 else
1467 SvMetaType *pT = rBase.FindType( "SfxBoolItem" );
1468 if ( pT && !rBase.FindType( pT, rBase.aUsedTypes ) )
1469 rBase.aUsedTypes.Append( pT );
1472 if( !bIsEnumSlot )
1474 rOutStm << ',' << endl;
1475 WriteTab( rOutStm, 4 );
1476 rOutStm << ByteString::CreateFromInt32( nCount ).GetBuffer() << "/*Offset*/, ";
1478 if( IsMethod() )
1480 SvMetaAttribute * pMethod = GetMethod();
1481 SvMetaType * pType;
1482 if( pMethod )
1483 pType = pMethod->GetType();
1484 else
1485 pType = GetType();
1486 sal_uLong nSCount = pType->GetAttrCount();
1487 rOutStm << ByteString::CreateFromInt32( nSCount ).GetBuffer() << "/*Count*/";
1489 else
1490 rOutStm << '0';
1492 // Name f"urs Recording
1493 if ( GetExport() )
1495 rOutStm << ",\"";
1496 if( rPrefix.Len() )
1497 rOutStm << rPrefix.GetBuffer();
1498 rOutStm << '.';
1499 if ( !IsVariable() || !GetType() ||
1500 GetType()->GetBaseType()->GetType() != TYPE_STRUCT )
1501 rOutStm << GetMangleName( sal_False ).GetBuffer();
1502 rOutStm << "\",";
1504 else
1505 rOutStm << ", 0, ";
1507 // Method/Property Flags
1508 if( IsMethod() )
1509 rOutStm << "SFX_SLOT_METHOD|";
1510 if( IsVariable() )
1512 rOutStm << "SFX_SLOT_PROPGET|";
1513 if( !GetReadonly() )
1514 rOutStm << "SFX_SLOT_PROPSET|";
1517 rOutStm << '0';
1520 // if ( GetUnoName().Len() )
1522 rOutStm << ",\"";
1523 rOutStm << GetMangleName( sal_False ).GetBuffer();
1524 //rOutStm << GetUnoName().GetBuffer();
1525 rOutStm << "\"";
1527 // else
1528 // rOutStm << ", 0";
1530 rOutStm << " )," << endl;
1533 sal_uInt16 SvMetaSlot::WriteSlotParamArray( SvIdlDataBase & rBase, SvStream & rOutStm )
1535 if ( !GetExport() && !GetHidden() )
1536 return 0;
1538 SvMetaAttribute * pMethod = GetMethod();
1539 if( IsMethod() )
1541 SvMetaType * pType;
1542 if( pMethod )
1543 pType = pMethod->GetType();
1544 else
1545 pType = GetType();
1547 if( !rBase.FindType( pType, rBase.aUsedTypes ) )
1548 rBase.aUsedTypes.Append( pType );
1550 const SvMetaAttributeMemberList & rList =
1551 pType->GetAttrList();
1552 for( sal_uLong n = 0; n < rList.Count(); n++ )
1554 SvMetaAttribute * pPar = rList.GetObject( n );
1555 SvMetaType * pPType = pPar->GetType();
1556 WriteTab( rOutStm, 1 );
1557 rOutStm << "SFX_ARGUMENT("
1558 << pPar->GetSlotId().GetBuffer() << ',' // SlodId
1559 // Parameter Name
1560 << "\"" << pPar->GetName().GetBuffer() << "\","
1561 // Item Name
1562 << pPType->GetName().GetBuffer() << ")," << endl;
1563 if( !rBase.FindType( pPType, rBase.aUsedTypes ) )
1564 rBase.aUsedTypes.Append( pPType );
1566 return (sal_uInt16)rList.Count();
1568 return 0;
1571 sal_uInt16 SvMetaSlot::WriteSlotMap( const ByteString & rShellName, sal_uInt16 nCount,
1572 SvSlotElementList& rSlotList,
1573 const ByteString & rPrefix,
1574 SvIdlDataBase & rBase,
1575 SvStream & rOutStm )
1577 // SlotId, wenn nicht angegeben, aus Namen generieren
1578 ByteString slotId = GetSlotId();
1580 sal_uInt16 nSCount = 0;
1581 if( IsMethod() )
1583 SvMetaType * pType;
1584 SvMetaAttribute * pMethod = GetMethod();
1585 if( pMethod )
1586 pType = pMethod->GetType();
1587 else
1588 pType = GetType();
1590 nSCount = (sal_uInt16)pType->GetAttrCount();
1593 WriteSlot( rShellName, nCount, slotId, rSlotList, rPrefix, rBase, rOutStm );
1594 return nSCount;
1597 /*************************************************************************
1598 |* SvMetaSlot::WriteSrc()
1599 *************************************************************************/
1600 void SvMetaSlot::WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm,
1601 Table * pTable )
1603 if (!GetToolBoxConfig() && !GetAccelConfig() && !GetMenuConfig() && !GetStatusBarConfig() )
1604 return;
1606 sal_uLong nSId = GetSlotId().GetValue();
1607 if( !pTable->IsKeyValid( nSId ) )
1609 pTable->Insert( nSId, this );
1610 rOutStm << "SfxSlotInfo " << ByteString::CreateFromInt32( nSId ).GetBuffer()
1611 << endl << '{' << endl;
1613 WriteTab( rOutStm, 1 );
1614 ByteString aStr = GetConfigName();
1615 if( !aStr.Len() )
1616 aStr = GetName();
1618 rOutStm << "SlotName = \"" << aStr.GetBuffer() << "\";" << endl;
1620 aStr = GetHelpText();
1621 if( aStr.Len() )
1623 WriteTab( rOutStm, 1 );
1624 rOutStm << "HelpText = \"" << aStr.GetBuffer() << "\";" << endl;
1627 rOutStm << "};" << endl;
1630 SvMetaTypeEnum * pEnum = PTR_CAST( SvMetaTypeEnum, GetType() );
1631 if( GetPseudoSlots() && pEnum )
1633 for( sal_uLong n = 0; n < pEnum->Count(); n++ )
1635 ByteString aValName = pEnum->GetObject( n )->GetName();
1636 ByteString aSId( GetSlotId() );
1637 if( GetPseudoPrefix().Len() )
1638 aSId = GetPseudoPrefix();
1639 aSId += '_';
1640 aSId += aValName.Copy( pEnum->GetPrefix().Len() );
1642 sal_uLong nSId2;
1643 sal_Bool bIdOk = sal_False;
1644 if( rBase.FindId( aSId, &nSId2 ) )
1646 aSId = ByteString::CreateFromInt32( nSId2 );
1647 bIdOk = sal_True;
1650 // wenn Id nicht gefunden, immer schreiben
1651 if( !bIdOk || !pTable->IsKeyValid( nSId2 ) )
1653 pTable->Insert( nSId2, this );
1654 rOutStm << "SfxSlotInfo " << aSId.GetBuffer()
1655 << endl << '{' << endl;
1657 WriteTab( rOutStm, 1 );
1658 rOutStm << "SlotName = \"" << aValName.GetBuffer() << "\";" << endl;
1660 ByteString aStr = GetHelpText();
1661 if( aStr.Len() )
1663 WriteTab( rOutStm, 1 );
1664 rOutStm << "HelpText = \"" << aStr.GetBuffer() << "\";" << endl;
1666 rOutStm << "};" << endl;
1672 void SvMetaSlot::WriteHelpId( SvIdlDataBase & rBase, SvStream & rOutStm,
1673 Table * pTable )
1675 sal_uLong nSId = GetSlotId().GetValue();
1676 if( !pTable->IsKeyValid( nSId ) )
1678 pTable->Insert( nSId, this );
1679 rOutStm << "#define " << GetSlotId().GetBuffer() << '\t' << ByteString::CreateFromInt32( nSId ).GetBuffer() << endl;
1682 SvMetaTypeEnum * pEnum = PTR_CAST( SvMetaTypeEnum, GetType() );
1683 if( GetPseudoSlots() && pEnum )
1685 for( sal_uLong n = 0; n < pEnum->Count(); n++ )
1687 ByteString aValName = pEnum->GetObject( n )->GetName();
1688 ByteString aSId( GetSlotId() );
1689 if( GetPseudoPrefix().Len() )
1690 aSId = GetPseudoPrefix();
1691 aSId += '_';
1692 aSId += aValName.Copy( pEnum->GetPrefix().Len() );
1694 sal_uLong nSId2;
1695 sal_Bool bIdOk = sal_False;
1696 if( rBase.FindId( aSId, &nSId2 ) )
1698 aSId = ByteString::CreateFromInt32( nSId2 );
1699 bIdOk = sal_True;
1702 // wenn Id nicht gefunden, immer schreiben
1703 if( !bIdOk || !pTable->IsKeyValid( nSId2 ) )
1705 pTable->Insert( nSId2, this );
1707 rOutStm << "#define " << aSId.GetBuffer() << '\t'
1708 << ByteString::CreateFromInt32( nSId2 ).GetBuffer() << endl;
1714 void WriteBool( sal_Bool bSet, SvStream& rStream )
1716 if ( bSet )
1717 rStream << "sal_True" << ',';
1718 else
1719 rStream << "sal_False" << ',';
1722 void SvMetaSlot::WriteCSV( SvIdlDataBase& rBase, SvStream& rStrm )
1724 rStrm << "PROJECT,";
1725 rStrm << GetSlotId().GetBuffer() << ',';
1726 rStrm << ByteString::CreateFromInt32( GetSlotId().GetValue() ).GetBuffer() << ',';
1728 if ( GetPseudoPrefix().Len() )
1729 rStrm << GetPseudoPrefix().GetBuffer() << ',';
1730 else
1731 rStrm << ',';
1733 rStrm << GetGroupId().GetBuffer() << ',';
1735 WriteBool( GetAccelConfig(), rStrm );
1736 WriteBool( GetMenuConfig(), rStrm );
1737 WriteBool( GetStatusBarConfig(), rStrm );
1738 WriteBool( GetToolBoxConfig(), rStrm );
1740 if ( GetSlotType() )
1741 rStrm << GetSlotType()->GetName().GetBuffer() << ',';
1742 else
1743 rStrm << ',';
1745 WriteBool( GetAutoUpdate(), rStrm );
1746 if ( GetCachable() )
1747 rStrm << "Cachable" << ',';
1748 else
1749 rStrm << "Volatile" << ',';
1751 WriteBool( GetContainer(), rStrm );
1752 WriteBool( GetFastCall(), rStrm );
1753 WriteBool( GetHasCoreId(), rStrm );
1754 WriteBool( GetHasDialog(), rStrm );
1755 WriteBool( GetReadOnlyDoc(), rStrm );
1756 WriteBool( GetImageRotation(), rStrm );
1757 WriteBool( GetImageReflection(), rStrm );
1758 rStrm << GetDisableFlags().GetBuffer() << ',';
1760 if( GetSynchron() )
1761 rStrm << "Synchron" << ',';
1762 else
1763 rStrm << "Asynchron" << ',';
1765 WriteBool( GetToggle(), rStrm );
1766 WriteBool( GetReadonly(), rStrm );
1767 WriteBool( GetExport(), rStrm );
1768 if( GetRecordPerItem() )
1769 rStrm << "RecordPerItem" << ',';
1770 else if ( GetNoRecord() )
1771 rStrm << "NoRecord" << ',';
1772 else if ( GetRecordManual() )
1773 rStrm << "RecordManual" << ',';
1774 else
1775 rStrm << "RecordPerSet" << ',';
1777 WriteBool( GetRecordAbsolute(), rStrm );
1779 if ( GetType()->GetType() != TYPE_METHOD && GetMethod() )
1781 rStrm << GetMethod()->GetType()->GetReturnType()->GetName().GetBuffer() << ',';
1782 rStrm << GetMethod()->GetName().GetBuffer() << ',';
1784 else
1786 rStrm << ",,";
1789 rStrm << GetType()->GetSvName().GetBuffer() << ',';
1790 rStrm << GetName().GetBuffer() << ',';
1792 if ( GetType()->GetType() == TYPE_METHOD || GetMethod() )
1794 SvMetaAttributeMemberList *pList = &GetType()->GetAttrList();
1795 if ( GetMethod() )
1796 pList = &GetMethod()->GetType()->GetAttrList();
1798 if( pList && pList->Count() )
1800 rStrm << "\"(";
1801 SvMetaAttribute* pAttr = pList->First();
1802 while( pAttr )
1804 pAttr->WriteCSV( rBase, rStrm );
1805 pAttr = pList->Next();
1806 if( pAttr )
1807 rStrm << ',';
1809 rStrm << ")\"";
1811 else
1812 rStrm << "()";
1815 rStrm << endl;
1818 #endif // IDL_COMPILER