Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <ctype.h>
22 : #include <stdio.h>
23 :
24 : #include <rtl/strbuf.hxx>
25 :
26 : #include <object.hxx>
27 : #include <globals.hxx>
28 : #include <database.hxx>
29 :
30 0 : SV_IMPL_PERSIST1( SvClassElement, SvPersistBase );
31 :
32 0 : SvClassElement::SvClassElement()
33 : {
34 0 : };
35 :
36 0 : void SvClassElement::Load( SvPersistStream & rStm )
37 : {
38 : sal_uInt8 nMask;
39 0 : rStm.ReadUChar( nMask );
40 0 : if( nMask >= 0x08 )
41 : {
42 0 : rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
43 : OSL_FAIL( "wrong format" );
44 0 : return;
45 : }
46 0 : if( nMask & 0x01 ) rStm >> aAutomation;
47 0 : if( nMask & 0x02 ) aPrefix = read_uInt16_lenPrefixed_uInt8s_ToOString(rStm);
48 0 : if( nMask & 0x04 )
49 : {
50 : SvMetaClass * p;
51 0 : rStm >> p;
52 0 : xClass = p;
53 : }
54 : }
55 :
56 0 : void SvClassElement::Save( SvPersistStream & rStm )
57 : {
58 : // create mask
59 0 : sal_uInt8 nMask = 0;
60 0 : if( aAutomation.IsSet() ) nMask |= 0x1;
61 0 : if( !aPrefix.isEmpty() ) nMask |= 0x2;
62 0 : if( xClass.Is() ) nMask |= 0x4;
63 :
64 : // write data
65 0 : rStm.WriteUChar( nMask );
66 0 : if( nMask & 0x01 ) rStm.WriteUChar( aAutomation );
67 0 : if( nMask & 0x02 ) write_uInt16_lenPrefixed_uInt8s_FromOString(rStm, aPrefix);
68 0 : if( nMask & 0x04 ) WriteSvPersistBase( rStm, xClass );
69 0 : }
70 :
71 0 : SV_IMPL_META_FACTORY1( SvMetaClass, SvMetaType );
72 0 : SvMetaClass::SvMetaClass()
73 0 : : aAutomation( sal_True, sal_False )
74 : {
75 0 : }
76 :
77 0 : void SvMetaClass::Load( SvPersistStream & rStm )
78 : {
79 0 : SvMetaType::Load( rStm );
80 :
81 : sal_uInt8 nMask;
82 0 : rStm.ReadUChar( nMask );
83 0 : if( nMask >= 0x20 )
84 : {
85 0 : rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
86 : OSL_FAIL( "wrong format" );
87 0 : return;
88 : }
89 0 : if( nMask & 0x01 ) rStm >> aAttrList;
90 0 : if( nMask & 0x02 )
91 : {
92 : SvMetaClass * pSuper;
93 0 : rStm >> pSuper;
94 0 : aSuperClass = pSuper;
95 : }
96 0 : if( nMask & 0x04 ) rStm >> aClassList;
97 0 : if( nMask & 0x8 )
98 : {
99 : SvMetaClass * p;
100 0 : rStm >> p;
101 0 : xAutomationInterface = p;
102 : }
103 0 : if( nMask & 0x10 ) rStm >> aAutomation;
104 : }
105 :
106 0 : void SvMetaClass::Save( SvPersistStream & rStm )
107 : {
108 0 : SvMetaType::Save( rStm );
109 :
110 : // create mask
111 0 : sal_uInt8 nMask = 0;
112 0 : if( !aAttrList.empty() ) nMask |= 0x1;
113 0 : if( aSuperClass.Is() ) nMask |= 0x2;
114 0 : if( !aClassList.empty() ) nMask |= 0x4;
115 0 : if( xAutomationInterface.Is() ) nMask |= 0x8;
116 0 : if( aAutomation.IsSet() ) nMask |= 0x10;
117 :
118 : // write data
119 0 : rStm.WriteUChar( nMask );
120 0 : if( nMask & 0x01 ) WriteSvDeclPersistList( rStm, aAttrList );
121 0 : if( nMask & 0x02 ) WriteSvPersistBase( rStm, aSuperClass );
122 0 : if( nMask & 0x04 ) WriteSvDeclPersistList( rStm, aClassList );
123 0 : if( nMask & 0x08 ) WriteSvPersistBase( rStm, xAutomationInterface );
124 0 : if( nMask & 0x10 ) rStm.WriteUChar( aAutomation );
125 0 : }
126 :
127 0 : void SvMetaClass::ReadAttributesSvIdl( SvIdlDataBase & rBase,
128 : SvTokenStream & rInStm )
129 : {
130 0 : SvMetaType::ReadAttributesSvIdl( rBase, rInStm );
131 0 : aAutomation.ReadSvIdl( SvHash_Automation(), rInStm );
132 0 : }
133 :
134 0 : void SvMetaClass::WriteAttributesSvIdl( SvIdlDataBase & rBase,
135 : SvStream & rOutStm, sal_uInt16 nTab )
136 : {
137 0 : SvMetaType::WriteAttributesSvIdl( rBase, rOutStm, nTab );
138 :
139 0 : if( !aAutomation )
140 : {
141 0 : WriteTab( rOutStm, nTab );
142 0 : rOutStm.WriteCharPtr( "//class SvMetaClass" ) << endl;
143 0 : if( !aAutomation )
144 : {
145 0 : WriteTab( rOutStm, nTab );
146 0 : aAutomation.WriteSvIdl( SvHash_Automation(), rOutStm );
147 0 : rOutStm.WriteChar( ';' ) << endl;
148 : }
149 : }
150 0 : }
151 :
152 0 : void SvMetaClass::ReadContextSvIdl( SvIdlDataBase & rBase,
153 : SvTokenStream & rInStm )
154 : {
155 0 : sal_uInt32 nTokPos = rInStm.Tell();
156 0 : SvToken * pTok = rInStm.GetToken_Next();
157 :
158 0 : if( pTok->Is( SvHash_import() ) )
159 : {
160 0 : SvMetaClass * pClass = rBase.ReadKnownClass( rInStm );
161 0 : if( pClass )
162 : {
163 0 : SvClassElementRef xEle = new SvClassElement();
164 0 : xEle->SetClass( pClass );
165 0 : aClassList.push_back( xEle );
166 :
167 0 : if( rInStm.Read( '[' ) )
168 : {
169 0 : pTok = rInStm.GetToken_Next();
170 0 : if( pTok->Is( SvHash_Automation() ) )
171 : {
172 0 : if( rInStm.Read( ']' ) )
173 : {
174 0 : if( xAutomationInterface.Is() )
175 : {
176 : // set error
177 : rBase.SetError( "Automation already set",
178 0 : rInStm.GetToken() );
179 0 : rBase.WriteError( rInStm );
180 : }
181 0 : xAutomationInterface = pClass;
182 0 : xEle->SetAutomation( sal_True );
183 : }
184 : else
185 : {
186 : // set error
187 0 : rBase.SetError( "missing ]", rInStm.GetToken() );
188 0 : rBase.WriteError( rInStm );
189 : }
190 : }
191 : else
192 : {
193 : // set error
194 : rBase.SetError( "only attribute Automation allowed",
195 0 : rInStm.GetToken() );
196 0 : rBase.WriteError( rInStm );
197 : }
198 : }
199 0 : pTok = rInStm.GetToken();
200 0 : if( pTok->IsString() )
201 : {
202 0 : xEle->SetPrefix( pTok->GetString() );
203 0 : rInStm.GetToken_Next();
204 : }
205 0 : return;
206 : }
207 : else
208 : {
209 : // set error
210 0 : rBase.SetError( "unknown imported interface", rInStm.GetToken() );
211 0 : rBase.WriteError( rInStm );
212 : }
213 : }
214 : else
215 : {
216 0 : rInStm.Seek( nTokPos );
217 0 : SvMetaType * pType = rBase.ReadKnownType( rInStm );
218 :
219 0 : sal_Bool bOk = sal_False;
220 0 : SvMetaAttributeRef xAttr;
221 0 : if( !pType || pType->IsItem() )
222 : {
223 0 : xAttr = new SvMetaSlot( pType );
224 0 : if( xAttr->ReadSvIdl( rBase, rInStm ) )
225 0 : bOk = xAttr->Test( rBase, rInStm );
226 : }
227 : else
228 : {
229 0 : xAttr = new SvMetaAttribute( pType );
230 0 : if( xAttr->ReadSvIdl( rBase, rInStm ) )
231 0 : bOk = xAttr->Test( rBase, rInStm );
232 : }
233 :
234 0 : if( bOk )
235 0 : bOk = TestAttribute( rBase, rInStm, *xAttr );
236 0 : if( bOk )
237 : {
238 0 : if( !xAttr->GetSlotId().IsSet() )
239 : {
240 0 : SvNumberIdentifier aI;
241 0 : aI.SetValue( rBase.GetUniqueId() );
242 0 : xAttr->SetSlotId( aI );
243 : }
244 0 : aAttrList.push_back( xAttr );
245 0 : return;
246 0 : }
247 : }
248 0 : rInStm.Seek( nTokPos );
249 : }
250 :
251 0 : void SvMetaClass::WriteContextSvIdl
252 : (
253 : SvIdlDataBase & rBase,
254 : SvStream & rOutStm,
255 : sal_uInt16 nTab
256 : )
257 : {
258 : sal_uLong n;
259 0 : for( n = 0; n < aAttrList.size(); n++ )
260 : {
261 0 : WriteTab( rOutStm, nTab );
262 0 : aAttrList[n]->WriteSvIdl( rBase, rOutStm, nTab );
263 0 : rOutStm.WriteChar( ';' ) << endl;
264 : }
265 0 : for( n = 0; n < aClassList.size(); n++ )
266 : {
267 0 : SvClassElement * pEle = aClassList[n];
268 0 : WriteTab( rOutStm, nTab );
269 0 : rOutStm.WriteCharPtr( SvHash_import()->GetName().getStr() ).WriteChar( ' ' )
270 0 : .WriteCharPtr( pEle->GetPrefix().getStr() );
271 0 : if( pEle->GetAutomation() )
272 0 : rOutStm.WriteCharPtr( " [ " ).WriteCharPtr( SvHash_Automation()->GetName().getStr() )
273 0 : .WriteCharPtr( " ]" );
274 0 : if( !pEle->GetPrefix().isEmpty() )
275 0 : rOutStm.WriteChar( ' ' ).WriteCharPtr( pEle->GetPrefix().getStr() );
276 0 : rOutStm.WriteChar( ';' ) << endl;
277 : }
278 0 : }
279 :
280 0 : sal_Bool SvMetaClass::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm )
281 : {
282 0 : sal_uLong nTokPos = rInStm.Tell();
283 0 : if( SvMetaType::ReadHeaderSvIdl( rBase, rInStm ) && GetType() == TYPE_CLASS )
284 : {
285 0 : sal_Bool bOk = sal_True;
286 0 : if( rInStm.Read( ':' ) )
287 : {
288 0 : aSuperClass = rBase.ReadKnownClass( rInStm );
289 0 : bOk = aSuperClass.Is();
290 0 : if( !bOk )
291 : {
292 : // set error
293 : rBase.SetError( "unknown super class",
294 0 : rInStm.GetToken() );
295 0 : rBase.WriteError( rInStm );
296 : }
297 : }
298 0 : if( bOk )
299 : {
300 0 : rBase.Write(OString('.'));
301 0 : bOk = SvMetaName::ReadSvIdl( rBase, rInStm );
302 : }
303 0 : if( bOk )
304 0 : return bOk;
305 : }
306 0 : rInStm.Seek( nTokPos );
307 0 : return sal_False;
308 : }
309 :
310 0 : sal_Bool SvMetaClass::TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm,
311 : SvMetaAttribute & rAttr ) const
312 : {
313 0 : if ( !rAttr.GetRef() && rAttr.IsA( TYPE( SvMetaSlot ) ) )
314 : {
315 : OSL_FAIL( "Neuer Slot : " );
316 : OSL_FAIL( rAttr.GetSlotId().getString().getStr() );
317 : }
318 :
319 0 : for( sal_uLong n = 0; n < aAttrList.size(); n++ )
320 : {
321 0 : SvMetaAttribute * pS = aAttrList[n];
322 0 : if( pS->GetName().getString() == rAttr.GetName().getString() )
323 : {
324 : // values have to match
325 0 : if( pS->GetSlotId().GetValue() != rAttr.GetSlotId().GetValue() )
326 : {
327 : OSL_FAIL( "Gleicher Name in MetaClass : " );
328 : OSL_FAIL( pS->GetName().getString().getStr() );
329 : OSL_FAIL( pS->GetSlotId().getString().getStr() );
330 : OSL_FAIL( rAttr.GetSlotId().getString().getStr() );
331 :
332 0 : OStringBuffer aStr("Attribute's ");
333 0 : aStr.append(pS->GetName().getString());
334 0 : aStr.append(" with different id's");
335 0 : rBase.SetError(aStr.makeStringAndClear(), rInStm.GetToken());
336 0 : rBase.WriteError( rInStm );
337 0 : return sal_False;
338 : }
339 : }
340 : else
341 : {
342 0 : sal_uInt32 nId1 = pS->GetSlotId().GetValue();
343 0 : sal_uInt32 nId2 = rAttr.GetSlotId().GetValue();
344 0 : if( nId1 == nId2 && nId1 != 0 )
345 : {
346 : OSL_FAIL( "Gleiche Id in MetaClass : " );
347 : OSL_FAIL(OString::number(pS->GetSlotId().GetValue()).getStr());
348 : OSL_FAIL( pS->GetSlotId().getString().getStr() );
349 : OSL_FAIL( rAttr.GetSlotId().getString().getStr() );
350 :
351 0 : OStringBuffer aStr("Attribute ");
352 0 : aStr.append(pS->GetName().getString());
353 0 : aStr.append(" and Attribute ");
354 0 : aStr.append(rAttr.GetName().getString());
355 0 : aStr.append(" with equal id's");
356 0 : rBase.SetError(aStr.makeStringAndClear(), rInStm.GetToken());
357 0 : rBase.WriteError( rInStm );
358 0 : return sal_False;
359 : }
360 : }
361 : }
362 0 : SvMetaClass * pSC = aSuperClass;
363 0 : if( pSC )
364 0 : return pSC->TestAttribute( rBase, rInStm, rAttr );
365 0 : return sal_True;
366 : }
367 :
368 0 : void SvMetaClass::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
369 : sal_uInt16 nTab )
370 : {
371 0 : WriteHeaderSvIdl( rBase, rOutStm, nTab );
372 0 : if( aSuperClass.Is() )
373 0 : rOutStm.WriteCharPtr( " : " ).WriteCharPtr( aSuperClass->GetName().getString().getStr() );
374 0 : rOutStm << endl;
375 0 : SvMetaName::WriteSvIdl( rBase, rOutStm, nTab );
376 0 : rOutStm << endl;
377 0 : }
378 :
379 0 : void SvMetaClass::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
380 : sal_uInt16 nTab,
381 : WriteType nT, WriteAttribute )
382 : {
383 0 : rBase.aIFaceName = GetName().getString();
384 0 : switch( nT )
385 : {
386 : case WRITE_ODL:
387 : {
388 : OSL_FAIL( "Not supported anymore!" );
389 0 : break;
390 : }
391 : case WRITE_C_SOURCE:
392 : case WRITE_C_HEADER:
393 : {
394 : OSL_FAIL( "Not supported anymore!" );
395 0 : break;
396 : }
397 : case WRITE_DOCU:
398 : {
399 0 : rOutStm.WriteCharPtr( "<INTERFACE>" ) << endl;
400 0 : rOutStm.WriteCharPtr( GetName().getString().getStr() );
401 0 : if ( GetAutomation() )
402 0 : rOutStm.WriteCharPtr( " ( Automation ) " );
403 0 : rOutStm << endl;
404 0 : WriteDescription( rOutStm );
405 0 : rOutStm.WriteCharPtr( "</INTERFACE>" ) << endl << endl;
406 :
407 : // write all attributes
408 : sal_uLong n;
409 0 : for( n = 0; n < aAttrList.size(); n++ )
410 : {
411 0 : SvMetaAttribute * pAttr = aAttrList[n];
412 0 : if( !pAttr->GetHidden() )
413 : {
414 0 : if( pAttr->IsMethod() )
415 0 : pAttr->Write( rBase, rOutStm, nTab, nT, WA_METHOD );
416 :
417 0 : if( pAttr->IsVariable() )
418 0 : pAttr->Write( rBase, rOutStm, nTab, nT, WA_VARIABLE );
419 : }
420 : }
421 :
422 0 : break;
423 : }
424 : default:
425 0 : break;
426 : }
427 0 : }
428 :
429 0 : sal_uInt16 SvMetaClass::WriteSlotParamArray( SvIdlDataBase & rBase,
430 : SvSlotElementList & rSlotList,
431 : SvStream & rOutStm )
432 : {
433 0 : sal_uInt16 nCount = 0;
434 0 : for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
435 : {
436 0 : SvSlotElement *pEle = rSlotList[ i ];
437 0 : SvMetaSlot *pAttr = pEle->xSlot;
438 0 : nCount = nCount + pAttr->WriteSlotParamArray( rBase, rOutStm );
439 : }
440 :
441 0 : return nCount;
442 : }
443 :
444 0 : sal_uInt16 SvMetaClass::WriteSlots( const OString& rShellName,
445 : sal_uInt16 nCount, SvSlotElementList & rSlotList,
446 : SvIdlDataBase & rBase,
447 : SvStream & rOutStm )
448 : {
449 0 : sal_uInt16 nSCount = 0;
450 0 : for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
451 : {
452 0 : SvSlotElement * pEle = rSlotList[ i ];
453 0 : SvMetaSlot * pAttr = pEle->xSlot;
454 : nSCount = nSCount + pAttr->WriteSlotMap( rShellName, nCount + nSCount,
455 : rSlotList, i, pEle->aPrefix, rBase,
456 0 : rOutStm );
457 : }
458 :
459 0 : return nSCount;
460 : }
461 :
462 0 : void SvMetaClass::InsertSlots( SvSlotElementList& rList, std::vector<sal_uLong>& rSuperList,
463 : SvMetaClassList &rClassList,
464 : const OString& rPrefix, SvIdlDataBase& rBase)
465 : {
466 : // was this class already written?
467 0 : for ( size_t i = 0, n = rClassList.size(); i < n ; ++i )
468 0 : if ( rClassList[ i ] == this )
469 0 : return;
470 :
471 0 : rClassList.push_back( this );
472 :
473 : // write all direct attributes
474 : sal_uLong n;
475 0 : for( n = 0; n < aAttrList.size(); n++ )
476 : {
477 0 : SvMetaAttribute * pAttr = aAttrList[n];
478 :
479 0 : sal_uLong nId = pAttr->GetSlotId().GetValue();
480 :
481 : std::vector<sal_uLong>::iterator iter = std::find(rSuperList.begin(),
482 0 : rSuperList.end(),nId);
483 :
484 0 : if( iter == rSuperList.end() )
485 : {
486 : // Write only if not already written by subclass or
487 : // imported interface.
488 0 : rSuperList.push_back(nId);
489 0 : pAttr->Insert(rList, rPrefix, rBase);
490 : }
491 : }
492 :
493 : // All Interfaces already imported by SuperShells should not be
494 : // written any more.
495 : // It is prohibited that Shell and SuperShell directly import the same
496 : //class.
497 0 : if( IsShell() && aSuperClass.Is() )
498 0 : aSuperClass->FillClasses( rClassList );
499 :
500 : // Write all attributes of the imported classes, as long as they have
501 : // not already been imported by the superclass.
502 0 : for( n = 0; n < aClassList.size(); n++ )
503 : {
504 0 : SvClassElement * pEle = aClassList[n];
505 0 : SvMetaClass * pCl = pEle->GetClass();
506 0 : OStringBuffer rPre(rPrefix);
507 0 : if( !rPre.isEmpty() && !pEle->GetPrefix().isEmpty() )
508 0 : rPre.append('.');
509 0 : rPre.append(pEle->GetPrefix());
510 :
511 : // first of all write direct imported interfaces
512 : pCl->InsertSlots( rList, rSuperList, rClassList,
513 0 : rPre.makeStringAndClear(), rBase );
514 0 : }
515 :
516 : // only write superclass if no shell and not in the list
517 0 : if( !IsShell() && aSuperClass.Is() )
518 : {
519 0 : aSuperClass->InsertSlots( rList, rSuperList, rClassList, rPrefix, rBase );
520 : }
521 : }
522 :
523 0 : void SvMetaClass::FillClasses( SvMetaClassList & rList )
524 : {
525 : // Am I not yet in?
526 0 : for ( size_t i = 0, n = rList.size(); i < n; ++i )
527 0 : if ( rList[ i ] == this )
528 0 : return;
529 :
530 0 : rList.push_back( this );
531 :
532 : // my imports
533 0 : for( sal_uInt32 n = 0; n < aClassList.size(); n++ )
534 : {
535 0 : SvClassElement * pEle = aClassList[n];
536 0 : SvMetaClass * pCl = pEle->GetClass();
537 0 : pCl->FillClasses( rList );
538 : }
539 :
540 : // my superclass
541 0 : if( aSuperClass.Is() )
542 0 : aSuperClass->FillClasses( rList );
543 : }
544 :
545 :
546 0 : void SvMetaClass::WriteSlotStubs( const OString& rShellName,
547 : SvSlotElementList & rSlotList,
548 : ByteStringList & rList,
549 : SvStream & rOutStm )
550 : {
551 : // write all attributes
552 0 : for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
553 : {
554 0 : SvSlotElement *pEle = rSlotList[ i ];
555 0 : SvMetaSlot *pAttr = pEle->xSlot;
556 0 : pAttr->WriteSlotStubs( rShellName, rList, rOutStm );
557 : }
558 0 : }
559 :
560 0 : void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
561 : {
562 0 : WriteStars( rOutStm );
563 : // define class
564 0 : rOutStm.WriteCharPtr( "#ifdef " ).WriteCharPtr( GetName().getString().getStr() ) << endl;
565 0 : rOutStm.WriteCharPtr( "#undef ShellClass" ) << endl;
566 0 : rOutStm.WriteCharPtr( "#undef " ).WriteCharPtr( GetName().getString().getStr() ) << endl;
567 0 : rOutStm.WriteCharPtr( "#define ShellClass " ).WriteCharPtr( GetName().getString().getStr() ) << endl;
568 :
569 : // no slotmaps get written for interfaces
570 0 : if( !IsShell() )
571 : {
572 0 : rOutStm.WriteCharPtr( "#endif" ) << endl << endl;
573 0 : return;
574 : }
575 : // write parameter array
576 0 : rOutStm.WriteCharPtr( "SFX_ARGUMENTMAP(" ).WriteCharPtr( GetName().getString().getStr() ).WriteChar( ')' ) << endl;
577 0 : rOutStm.WriteChar( '{' ) << endl;
578 :
579 0 : std::vector<sal_uLong> aSuperList;
580 0 : SvMetaClassList classList;
581 0 : SvSlotElementList aSlotList;
582 0 : InsertSlots(aSlotList, aSuperList, classList, OString(), rBase);
583 0 : for ( size_t i = 0, n = aSlotList.size(); i < n; ++i )
584 : {
585 0 : SvSlotElement *pEle = aSlotList[ i ];
586 0 : SvMetaSlot *pSlot = pEle->xSlot;
587 0 : pSlot->SetListPos( i );
588 : }
589 :
590 0 : size_t nSlotCount = aSlotList.size();
591 :
592 : // write all attributes
593 0 : sal_uInt16 nArgCount = WriteSlotParamArray( rBase, aSlotList, rOutStm );
594 0 : if( nArgCount )
595 0 : Back2Delemitter( rOutStm );
596 : else
597 : {
598 : // at leaast one dummy
599 0 : WriteTab( rOutStm, 1 );
600 0 : rOutStm.WriteCharPtr( "SFX_ARGUMENT( 0, 0, SfxVoidItem )" ) << endl;
601 : }
602 0 : rOutStm << endl;
603 0 : rOutStm.WriteCharPtr( "};" ) << endl << endl;
604 :
605 0 : ByteStringList aStringList;
606 0 : WriteSlotStubs( GetName().getString(), aSlotList, aStringList, rOutStm );
607 0 : for ( size_t i = 0, n = aStringList.size(); i < n; ++i )
608 0 : delete aStringList[ i ];
609 0 : aStringList.clear();
610 :
611 0 : rOutStm << endl;
612 :
613 : // write slotmap
614 0 : rOutStm.WriteCharPtr( "SFX_SLOTMAP_ARG(" ).WriteCharPtr( GetName().getString().getStr() ).WriteChar( ')' ) << endl;
615 0 : rOutStm.WriteChar( '{' ) << endl;
616 :
617 : // write all attributes
618 0 : WriteSlots( GetName().getString(), 0, aSlotList, rBase, rOutStm );
619 0 : if( nSlotCount )
620 0 : Back2Delemitter( rOutStm );
621 : else
622 : {
623 : // at least one dummy
624 0 : WriteTab( rOutStm, 1 );
625 0 : rOutStm.WriteCharPtr( "SFX_SLOT_ARG(" ).WriteCharPtr( GetName().getString().getStr() )
626 0 : .WriteCharPtr( ", 0, 0, " )
627 0 : .WriteCharPtr( "SFX_STUB_PTR_EXEC_NONE," )
628 0 : .WriteCharPtr( "SFX_STUB_PTR_STATE_NONE," )
629 0 : .WriteCharPtr( "0, SfxVoidItem, 0, 0, \"\", 0 )" ) << endl;
630 : }
631 0 : rOutStm << endl;
632 0 : rOutStm.WriteCharPtr( "};" ) << endl;
633 0 : rOutStm.WriteCharPtr( "#endif" ) << endl << endl;
634 :
635 0 : for( size_t i = 0, n = aSlotList.size(); i < n; ++i )
636 : {
637 0 : SvSlotElement* pEle = aSlotList[ i ];
638 0 : SvMetaSlot* pAttr = pEle->xSlot;
639 0 : pAttr->ResetSlotPointer();
640 : }
641 :
642 0 : for( size_t i = 0, n = aSlotList.size(); i < n; ++i )
643 0 : delete aSlotList[ i ];
644 0 : aSlotList.clear();
645 : }
646 :
647 0 : void SvMetaClass::WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm,
648 : HelpIdTable& rTable )
649 : {
650 0 : for( sal_uLong n=0; n<aAttrList.size(); n++ )
651 : {
652 0 : SvMetaAttribute * pAttr = aAttrList[n];
653 0 : pAttr->WriteHelpId( rBase, rOutStm, rTable );
654 : }
655 0 : }
656 :
657 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|