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 <tools/debug.hxx>
25 :
26 : #include <types.hxx>
27 : #include <globals.hxx>
28 : #include <database.hxx>
29 :
30 4788 : SV_IMPL_META_FACTORY1( SvMetaAttribute, SvMetaReference );
31 17592 : SvMetaAttribute::SvMetaAttribute()
32 : : aAutomation( sal_True, sal_False )
33 : , aExport( sal_True, sal_False )
34 : , aIsCollection ( sal_False, sal_False )
35 : , aReadOnlyDoc ( sal_True, sal_False )
36 : , aHidden( sal_False, sal_False )
37 17592 : , bNewAttr( sal_False )
38 : {
39 17592 : }
40 :
41 4031 : SvMetaAttribute::SvMetaAttribute( SvMetaType * pType )
42 : : aType( pType )
43 : , aAutomation( sal_True, sal_False )
44 : , aExport( sal_True, sal_False )
45 : , aIsCollection ( sal_False, sal_False)
46 : , aReadOnlyDoc ( sal_True, sal_False)
47 : , aHidden( sal_False, sal_False )
48 4031 : , bNewAttr( sal_False )
49 : {
50 4031 : }
51 :
52 0 : void SvMetaAttribute::Load( SvPersistStream & rStm )
53 : {
54 0 : SvMetaReference::Load( rStm );
55 :
56 : sal_uInt8 nMask;
57 0 : rStm >> nMask;
58 0 : if( nMask & 0x01 )
59 : {
60 : SvMetaType * pType;
61 0 : rStm >> pType;
62 0 : aType = pType;
63 : }
64 0 : if( nMask & 0x02 ) rStm >> aSlotId;
65 0 : if( nMask & 0x04 ) rStm >> aExport;
66 0 : if( nMask & 0x08 ) rStm >> aReadonly;
67 0 : if( nMask & 0x10 ) rStm >> aAutomation;
68 0 : if( nMask & 0x20 ) rStm >> aIsCollection;
69 0 : if( nMask & 0x40 ) rStm >> aReadOnlyDoc;
70 0 : if( nMask & 0x80 ) rStm >> aHidden;
71 0 : }
72 :
73 16598 : void SvMetaAttribute::Save( SvPersistStream & rStm )
74 : {
75 16598 : SvMetaReference::Save( rStm );
76 :
77 : // create mask
78 16598 : sal_uInt8 nMask = 0;
79 16598 : if( aType.Is() ) nMask |= 0x1;
80 16598 : if( aSlotId.IsSet() ) nMask |= 0x2;
81 16598 : if( aExport.IsSet() ) nMask |= 0x4;
82 16598 : if( aReadonly.IsSet() ) nMask |= 0x8;
83 16598 : if( aAutomation.IsSet() ) nMask |= 0x10;
84 16598 : if( aIsCollection.IsSet() ) nMask |= 0x20;
85 16598 : if( aReadOnlyDoc.IsSet() ) nMask |= 0x40;
86 16598 : if( aHidden.IsSet() ) nMask |= 0x80;
87 :
88 : // write data
89 16598 : rStm << nMask;
90 16598 : if( nMask & 0x1 ) rStm << aType;
91 16598 : if( nMask & 0x2 ) rStm << aSlotId;
92 16598 : if( nMask & 0x4 ) rStm << aExport;
93 16598 : if( nMask & 0x8 ) rStm << aReadonly;
94 16598 : if( nMask & 0x10 ) rStm << aAutomation;
95 16598 : if( nMask & 0x20 ) rStm << aIsCollection;
96 16598 : if( nMask & 0x40 ) rStm << aReadOnlyDoc;
97 16598 : if( nMask & 0x80 ) rStm << aHidden;
98 16598 : }
99 :
100 264719 : SvMetaType * SvMetaAttribute::GetType() const
101 : {
102 264719 : if( aType.Is() || !GetRef() ) return aType;
103 77098 : return ((SvMetaAttribute *)GetRef())->GetType();
104 : }
105 :
106 8753405 : const SvNumberIdentifier & SvMetaAttribute::GetSlotId() const
107 : {
108 8753405 : if( aSlotId.IsSet() || !GetRef() ) return aSlotId;
109 806687 : return ((SvMetaAttribute *)GetRef())->GetSlotId();
110 : }
111 :
112 4392 : sal_Bool SvMetaAttribute::GetReadonly() const
113 : {
114 4392 : if( aReadonly.IsSet() || !GetRef() ) return aReadonly;
115 2196 : return ((SvMetaAttribute *)GetRef())->GetReadonly();
116 : }
117 :
118 41556 : sal_Bool SvMetaAttribute::GetExport() const
119 : {
120 41556 : if( aExport.IsSet() || !GetRef() ) return aExport;
121 19588 : return ((SvMetaAttribute *)GetRef())->GetExport();
122 : }
123 :
124 1566 : sal_Bool SvMetaAttribute::GetHidden() const
125 : {
126 : // when export is set, but hidden is not the default is used
127 1566 : if ( aExport.IsSet() && !aHidden.IsSet() )
128 1566 : return !aExport;
129 0 : else if( aHidden.IsSet() || !GetRef() )
130 0 : return aHidden;
131 : else
132 0 : return ((SvMetaAttribute *)GetRef())->GetHidden();
133 : }
134 :
135 0 : sal_Bool SvMetaAttribute::GetAutomation() const
136 : {
137 0 : if( aAutomation.IsSet() || !GetRef() ) return aAutomation;
138 0 : return ((SvMetaAttribute *)GetRef())->GetAutomation();
139 : }
140 :
141 0 : sal_Bool SvMetaAttribute::GetIsCollection() const
142 : {
143 : sal_Bool bRet;
144 0 : if( aIsCollection.IsSet() || !GetRef() )
145 : {
146 0 : if ( aIsCollection.IsSet() )
147 : {
148 0 : bRet = aIsCollection;
149 0 : return bRet;
150 : }
151 :
152 0 : return aIsCollection;
153 : }
154 :
155 0 : return ((SvMetaSlot *)GetRef())->GetIsCollection();
156 : }
157 :
158 10932 : sal_Bool SvMetaAttribute::GetReadOnlyDoc() const
159 : {
160 10932 : if( aReadOnlyDoc.IsSet() || !GetRef() ) return aReadOnlyDoc;
161 5423 : return ((SvMetaSlot *)GetRef())->GetReadOnlyDoc();
162 : }
163 :
164 21926 : sal_Bool SvMetaAttribute::IsMethod() const
165 : {
166 21926 : SvMetaType * pType = GetType();
167 : DBG_ASSERT( pType, "no type for attribute" );
168 21926 : return pType->GetType() == TYPE_METHOD;
169 : }
170 :
171 15336 : sal_Bool SvMetaAttribute::IsVariable() const
172 : {
173 15336 : SvMetaType * pType = GetType();
174 15336 : return pType->GetType() != TYPE_METHOD;
175 : }
176 :
177 0 : rtl::OString SvMetaAttribute::GetMangleName( sal_Bool ) const
178 : {
179 0 : return GetName().getString();
180 : }
181 :
182 16598 : sal_Bool SvMetaAttribute::Test( SvIdlDataBase & rBase,
183 : SvTokenStream & rInStm )
184 : {
185 16598 : sal_Bool bOk = sal_True;
186 16598 : if( GetType()->IsItem() && !GetSlotId().IsSet() )
187 : {
188 0 : rBase.SetError( "slot without id declared", rInStm.GetToken() );
189 0 : rBase.WriteError( rInStm );
190 0 : bOk = sal_False;
191 : }
192 16598 : return bOk;
193 : }
194 :
195 17828 : sal_Bool SvMetaAttribute::ReadSvIdl( SvIdlDataBase & rBase,
196 : SvTokenStream & rInStm )
197 : {
198 17828 : sal_uInt32 nTokPos = rInStm.Tell();
199 17828 : if( !GetType() )
200 : // no type in ctor passed on
201 17786 : aType = rBase.ReadKnownType( rInStm );
202 17828 : sal_Bool bOk = sal_False;
203 17828 : if( GetType() )
204 : {
205 12803 : ReadNameSvIdl( rBase, rInStm );
206 12803 : aSlotId.ReadSvIdl( rBase, rInStm );
207 :
208 12803 : bOk = sal_True;
209 12803 : SvToken * pTok = rInStm.GetToken();
210 12803 : if( bOk && pTok->IsChar() && pTok->GetChar() == '(' )
211 : {
212 4383 : SvMetaTypeRef xT = new SvMetaType();
213 4383 : xT->SetRef( GetType() );
214 4383 : aType = xT;
215 4383 : bOk = aType->ReadMethodArgs( rBase, rInStm );
216 : }
217 12803 : if( bOk )
218 12803 : bOk = SvMetaName::ReadSvIdl( rBase, rInStm );
219 : }
220 : else
221 5025 : rBase.SetError( "unknown type", rInStm.GetToken() );
222 :
223 17828 : if( !bOk )
224 5025 : rInStm.Seek( nTokPos );
225 17828 : return bOk;
226 : }
227 :
228 18118 : void SvMetaAttribute::WriteSvIdl
229 : (
230 : SvIdlDataBase & rBase,
231 : SvStream & rOutStm,
232 : sal_uInt16 nTab
233 : )
234 : {
235 18118 : SvMetaType * pType = GetType();
236 18118 : pType->WriteTypePrefix( rBase, rOutStm, nTab, WRITE_IDL );
237 18118 : rOutStm << ' ' << GetName().getString().getStr();
238 18118 : if( aSlotId.IsSet() )
239 14323 : rOutStm << ' ' << aSlotId.getString().getStr();
240 18118 : if( pType->GetType() == TYPE_METHOD )
241 6649 : pType->WriteMethodArgs( rBase, rOutStm, nTab, WRITE_IDL );
242 18118 : sal_uLong nPos = rOutStm.Tell();
243 18118 : rOutStm << endl;
244 18118 : SvMetaName::WriteSvIdl( rBase, rOutStm, nTab );
245 18118 : TestAndSeekSpaceOnly( rOutStm, nPos );
246 18118 : }
247 :
248 160515 : void SvMetaAttribute::ReadAttributesSvIdl( SvIdlDataBase & rBase,
249 : SvTokenStream & rInStm )
250 : {
251 160515 : SvMetaReference::ReadAttributesSvIdl( rBase, rInStm );
252 160515 : aSlotId.ReadSvIdl( rBase, SvHash_SlotId(), rInStm );
253 160515 : aExport.ReadSvIdl( SvHash_Export(), rInStm );
254 160515 : aHidden.ReadSvIdl( SvHash_Hidden(), rInStm );
255 160515 : aAutomation.ReadSvIdl( SvHash_Automation(), rInStm );
256 160515 : aIsCollection.ReadSvIdl( SvHash_IsCollection(), rInStm );
257 160515 : aReadOnlyDoc.ReadSvIdl( SvHash_ReadOnlyDoc(), rInStm );
258 160515 : if( aReadonly.ReadSvIdl( SvHash_Readonly(), rInStm ) )
259 : {
260 3406 : if( GetType()->GetType() == TYPE_METHOD )
261 : {
262 : // set error
263 0 : rBase.SetError( "Readonly in function attribute", rInStm.GetToken() );
264 0 : rBase.WriteError( rInStm );
265 : }
266 : }
267 160515 : }
268 :
269 18118 : void SvMetaAttribute::WriteAttributesSvIdl
270 : (
271 : SvIdlDataBase & rBase,
272 : SvStream & rOutStm,
273 : sal_uInt16 nTab
274 : )
275 : {
276 18118 : SvMetaReference::WriteAttributesSvIdl( rBase, rOutStm, nTab );
277 :
278 18118 : if( !aExport || !aAutomation || aReadonly )
279 : {
280 733 : WriteTab( rOutStm, nTab );
281 733 : rOutStm << "//class SvMetaAttribute" << endl;
282 733 : if( !aExport )
283 : {
284 442 : WriteTab( rOutStm, nTab );
285 442 : aExport.WriteSvIdl( SvHash_Export(), rOutStm );
286 442 : rOutStm << ';' << endl;
287 : }
288 733 : if ( aHidden != aExport )
289 : {
290 291 : WriteTab( rOutStm, nTab );
291 291 : aExport.WriteSvIdl( SvHash_Hidden(), rOutStm );
292 291 : rOutStm << ';' << endl;
293 : }
294 733 : if( aReadonly )
295 : {
296 291 : WriteTab( rOutStm, nTab );
297 291 : aReadonly.WriteSvIdl( SvHash_Readonly(), rOutStm );
298 291 : rOutStm << ';' << endl;
299 : }
300 733 : if( !aAutomation )
301 : {
302 0 : WriteTab( rOutStm, nTab );
303 0 : aAutomation.WriteSvIdl( SvHash_Automation(), rOutStm );
304 0 : rOutStm << ';' << endl;
305 : }
306 733 : if( aIsCollection )
307 : {
308 1 : WriteTab( rOutStm, nTab );
309 1 : aIsCollection.WriteSvIdl( SvHash_IsCollection(), rOutStm );
310 1 : rOutStm << ';' << endl;
311 : }
312 733 : if( !aReadOnlyDoc )
313 : {
314 34 : WriteTab( rOutStm, nTab );
315 34 : aReadOnlyDoc.WriteSvIdl( SvHash_ReadOnlyDoc(), rOutStm );
316 34 : rOutStm << ';' << endl;
317 : }
318 : }
319 18118 : }
320 :
321 0 : void SvMetaAttribute::WriteParam( SvIdlDataBase & rBase,
322 : SvStream & rOutStm,
323 : sal_uInt16 nTab,
324 : WriteType nT )
325 : {
326 0 : SvMetaType * pType = GetType();
327 : DBG_ASSERT( pType, "no type for attribute" );
328 0 : SvMetaType * pBaseType = pType->GetBaseType();
329 : DBG_ASSERT( pBaseType, "no base type for attribute" );
330 :
331 0 : if( nT == WRITE_ODL || nT == WRITE_DOCU
332 : || nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
333 : {
334 0 : if( pBaseType->GetType() == TYPE_STRUCT )
335 : {
336 0 : const SvMetaAttributeMemberList & rList = pBaseType->GetAttrList();
337 0 : sal_uLong nCount = rList.size();
338 0 : for( sal_uLong i = 0; i < nCount; i++ )
339 : {
340 0 : rList[i]->WriteParam( rBase, rOutStm, nTab, nT );
341 0 : if( i+1<nCount )
342 : {
343 0 : rOutStm << ',';
344 : }
345 : }
346 : }
347 : else
348 : {
349 0 : if ( nT != WRITE_DOCU )
350 : {
351 0 : WriteTab( rOutStm, nTab );
352 0 : pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
353 : }
354 :
355 0 : if( !GetName().getString().isEmpty() )
356 : {
357 0 : rOutStm << ' ';
358 0 : rOutStm << GetName().getString().getStr();
359 : }
360 :
361 0 : if ( nT == WRITE_DOCU )
362 : {
363 0 : if( pBaseType->GetType() == TYPE_METHOD ||
364 0 : pBaseType->GetType() == TYPE_STRUCT ||
365 0 : pBaseType->GetType() == TYPE_ENUM )
366 : {
367 : OSL_FAIL( "Falscher Parametertyp!" );
368 : }
369 : else
370 0 : rOutStm << pBaseType->GetBasicPostfix().getStr();
371 : }
372 : }
373 : }
374 0 : }
375 :
376 0 : sal_uLong SvMetaAttribute::MakeSlotValue( SvIdlDataBase & rBase, sal_Bool bVar ) const
377 : {
378 0 : const SvNumberIdentifier & rId = GetSlotId();
379 0 : sal_uLong n = rId.GetValue();
380 0 : if( !rBase.aStructSlotId.getString().isEmpty() )
381 : {
382 0 : n = n << 20;
383 0 : n += rBase.aStructSlotId.GetValue();
384 : }
385 0 : if( PTR_CAST( SvMetaSlot, this ) )
386 0 : n |= 0x20000;
387 0 : if( !bVar )
388 0 : n += 0x10000;
389 0 : else if ( GetIsCollection() )
390 0 : n += 0x40000;
391 0 : return n;
392 : }
393 :
394 0 : void SvMetaAttribute::WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm,
395 : sal_uInt16 nTab,
396 : WriteType nT, WriteAttribute nA )
397 : {
398 0 : if( nT == WRITE_ODL )
399 : {
400 0 : const SvNumberIdentifier & rId = GetSlotId();
401 0 : sal_Bool bReadonly = GetReadonly() || ( nA & WA_READONLY );
402 0 : if( (rId.IsSet() && !(nA & WA_STRUCT)) || bReadonly )
403 : {
404 0 : sal_Bool bVar = IsVariable();
405 0 : if( nA & WA_VARIABLE )
406 0 : bVar = sal_True;
407 0 : else if( nA & WA_METHOD )
408 0 : bVar = sal_False;
409 :
410 0 : WriteTab( rOutStm, nTab );
411 0 : rOutStm << "//class SvMetaAttribute" << endl;
412 0 : if( rId.IsSet() && !(nA & WA_STRUCT) )
413 : {
414 0 : WriteTab( rOutStm, nTab );
415 0 : rOutStm << "id("
416 0 : << rtl::OString::valueOf(static_cast<sal_Int32>(MakeSlotValue(rBase,bVar))).getStr()
417 0 : << ")," << endl;
418 : }
419 0 : if( bVar && (bReadonly || IsMethod()) )
420 : {
421 0 : WriteTab( rOutStm, nTab );
422 0 : rOutStm << "readonly," << endl;
423 : }
424 : }
425 : }
426 0 : }
427 :
428 0 : void SvMetaAttribute::WriteCSource( SvIdlDataBase & rBase, SvStream & rOutStm,
429 : sal_Bool bSet )
430 : {
431 0 : rOutStm << endl;
432 0 : SvMetaType * pType = GetType();
433 0 : SvMetaType * pBaseType = pType->GetBaseType();
434 :
435 : // for Set the return is always void
436 0 : sal_Bool bVoid = bSet;
437 0 : if( pBaseType->GetType() == TYPE_METHOD )
438 0 : bVoid = pBaseType->GetReturnType()->GetBaseType()->GetName().getString() == "void";
439 :
440 : // emit methods/functions body
441 0 : rOutStm << '{' << endl;
442 0 : WriteTab( rOutStm, 1 );
443 :
444 0 : if( !bVoid )
445 : {
446 0 : if ( pBaseType->GetCName() == "double" )
447 : {
448 0 : rOutStm << "return *(double*)";
449 : }
450 : else
451 : {
452 0 : rOutStm << "return (";
453 0 : pType->WriteTypePrefix( rBase, rOutStm, 2, WRITE_C_SOURCE );
454 0 : rOutStm << ") ";
455 : }
456 : }
457 0 : rOutStm << "pODKCallFunction( "
458 0 : << rtl::OString::valueOf(static_cast<sal_Int32>(MakeSlotValue(rBase, IsVariable()))).getStr();
459 0 : rOutStm << ',' << endl;
460 0 : WriteTab( rOutStm, 3 );
461 0 : rOutStm << " h" << rBase.aIFaceName.getStr() << " , ";
462 :
463 0 : rtl::OString aParserStr;
464 0 : if( pBaseType->GetType() == TYPE_METHOD || bSet )
465 0 : aParserStr = pBaseType->GetParserString();
466 0 : if( !aParserStr.isEmpty() )
467 : {
468 0 : rOutStm << '\"';
469 0 : rOutStm << aParserStr.getStr();
470 0 : rOutStm << "\", ";
471 : }
472 : else
473 0 : rOutStm << "NULL, ";
474 :
475 0 : if( pBaseType->GetType() == TYPE_METHOD && !bVoid )
476 : {
477 0 : rOutStm << "'";
478 0 : rOutStm << pBaseType->GetReturnType()->GetBaseType()->GetParserChar();
479 0 : rOutStm << "'";
480 : }
481 0 : else if ( !bSet )
482 : {
483 0 : rOutStm << "'";
484 0 : rOutStm << pBaseType->GetParserChar();
485 0 : rOutStm << "'";
486 : }
487 : else
488 0 : rOutStm << '0';
489 :
490 0 : if( !aParserStr.isEmpty() )
491 : {
492 0 : rOutStm << ", ";
493 0 : if( IsMethod() )
494 0 : pBaseType->WriteParamNames( rBase, rOutStm, rtl::OString() );
495 0 : else if( bSet )
496 0 : pBaseType->WriteParamNames( rBase, rOutStm, GetName().getString() );
497 : }
498 :
499 0 : rOutStm << " );" << endl;
500 0 : rOutStm << '}' << endl;
501 0 : }
502 :
503 0 : void SvMetaAttribute::WriteRecursiv_Impl( SvIdlDataBase & rBase,
504 : SvStream & rOutStm, sal_uInt16 nTab,
505 : WriteType nT, WriteAttribute nA )
506 : {
507 0 : const SvMetaAttributeMemberList & rList = GetType()->GetBaseType()->GetAttrList();
508 0 : sal_uLong nCount = rList.size();
509 :
510 0 : SvNumberIdentifier slotId = rBase.aStructSlotId;
511 0 : if ( !GetSlotId().getString().isEmpty() )
512 0 : rBase.aStructSlotId = GetSlotId();
513 :
514 : // offial hack interface by MM: special controls get passed with the WriteAttribute
515 0 : if ( GetReadonly() )
516 0 : nA |= WA_READONLY;
517 :
518 0 : for( sal_uLong i = 0; i < nCount; i++ )
519 : {
520 0 : SvMetaAttribute *pAttr = rList[i];
521 0 : if ( nT == WRITE_DOCU )
522 0 : pAttr->SetDescription( GetDescription().getString() );
523 0 : pAttr->Write( rBase, rOutStm, nTab, nT, nA );
524 0 : if( nT == WRITE_ODL && i +1 < nCount )
525 0 : rOutStm << ';' << endl;
526 : }
527 :
528 0 : rBase.aStructSlotId = slotId;
529 0 : }
530 :
531 0 : void SvMetaAttribute::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
532 : sal_uInt16 nTab,
533 : WriteType nT, WriteAttribute nA )
534 : {
535 : // no attributes for automation
536 0 : if( nT == WRITE_DOCU )
537 : {
538 0 : if ( GetHidden() )
539 0 : return;
540 : }
541 0 : else if ( !GetAutomation() || !GetExport() )
542 0 : return;
543 :
544 : sal_Bool bVariable;
545 0 : if( nA & WA_VARIABLE )
546 0 : bVariable = sal_True;
547 0 : else if( nA & WA_METHOD )
548 0 : bVariable = sal_False;
549 : else
550 0 : bVariable = IsVariable();
551 :
552 0 : SvMetaType * pType = GetType();
553 : DBG_ASSERT( pType, "no type for attribute" );
554 0 : SvMetaType * pBaseType = pType->GetBaseType();
555 : DBG_ASSERT( pBaseType, "no base type for attribute" );
556 0 : int nBType = pBaseType->GetType();
557 :
558 0 : if( nT == WRITE_ODL )
559 : {
560 0 : if( (bVariable && IsVariable()) || (!bVariable && IsMethod()) )
561 : {
562 0 : if( nBType == TYPE_STRUCT )
563 0 : WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA );
564 : else
565 : {
566 0 : SvMetaReference::Write( rBase, rOutStm, nTab, nT, nA );
567 0 : WriteTab( rOutStm, nTab );
568 0 : pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
569 :
570 0 : if( !GetName().getString().isEmpty() )
571 : {
572 0 : rOutStm << ' ';
573 0 : rOutStm << GetName().getString().getStr();
574 : }
575 0 : if( pType->GetType() == TYPE_METHOD )
576 0 : pType->WriteMethodArgs( rBase, rOutStm, nTab, nT );
577 : }
578 : }
579 : }
580 0 : else if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
581 : {
582 0 : if( !bVariable && IsMethod() )
583 : {
584 0 : rtl::OString name = rBase.aIFaceName + GetName().getString();
585 0 : const char * pName = name.getStr();
586 0 : WriteTab( rOutStm, nTab );
587 0 : pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
588 0 : rOutStm << ' ' << pName;
589 0 : pType->WriteMethodArgs( rBase, rOutStm, nTab, nT );
590 0 : if( nT == WRITE_C_HEADER )
591 0 : rOutStm << ';' << endl << endl;
592 : else
593 0 : WriteCSource( rBase, rOutStm, sal_False );
594 : }
595 0 : else if ( bVariable && IsVariable() )
596 : {
597 0 : if( nBType == TYPE_STRUCT )
598 : {
599 : // for assistance emit the name of the property as acomment
600 0 : rOutStm << "/* " << GetName().getString().getStr() << " */" << endl;
601 :
602 0 : WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA );
603 : }
604 : else
605 : {
606 0 : rtl::OString name = GetName().getString();
607 :
608 0 : sal_Bool bReadonly = GetReadonly() || ( nA & WA_READONLY );
609 0 : if ( !bReadonly && !IsMethod() )
610 : {
611 : // allocation
612 0 : WriteTab( rOutStm, nTab );
613 0 : rOutStm << "void ";
614 0 : rOutStm << rBase.aIFaceName.getStr()
615 0 : << "Set" << name.getStr() << "( " << C_PREF
616 0 : << "Object h" << rBase.aIFaceName.getStr() << ", " << endl;
617 0 : WriteTab( rOutStm, nTab+1 );
618 0 : pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
619 0 : rOutStm << ' ' << name.getStr() << " )";
620 0 : if( nT == WRITE_C_HEADER )
621 0 : rOutStm << ';' << endl << endl;
622 : else
623 0 : WriteCSource( rBase, rOutStm, sal_True );
624 : }
625 :
626 : // access
627 0 : WriteTab( rOutStm, nTab );
628 0 : pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
629 0 : rOutStm << ' ';
630 0 : rOutStm << rBase.aIFaceName.getStr()
631 0 : << "Get" << name.getStr() << "( " << C_PREF
632 0 : << "Object h" << rBase.aIFaceName.getStr() << " )";
633 0 : if( nT == WRITE_C_HEADER )
634 0 : rOutStm << ';' << endl << endl;
635 : else
636 0 : WriteCSource( rBase, rOutStm, sal_False );
637 : }
638 0 : }
639 : }
640 0 : else if ( nT == WRITE_DOCU )
641 : {
642 0 : if( !bVariable && IsMethod() )
643 : {
644 0 : rOutStm << "<METHOD>" << endl
645 0 : << GetSlotId().getString().getStr() << endl
646 0 : << GetName().getString().getStr() << endl
647 0 : << endl; // readonly
648 :
649 : // return type
650 0 : SvMetaType* pType2 = GetType();
651 0 : SvMetaType* pBaseType2 = pType2->GetBaseType();
652 0 : rOutStm << pBaseType2->GetReturnType()->GetBaseType()->GetBasicName().getStr() << endl;
653 :
654 : DBG_ASSERT( !pBaseType2->GetReturnType()->GetBaseType()->GetBasicName().isEmpty(),
655 : "Leerer BasicName" );
656 :
657 : // syntax
658 0 : rOutStm << GetName().getString().getStr();
659 0 : pType2->WriteMethodArgs( rBase, rOutStm, nTab, nT );
660 :
661 : // C return type
662 0 : pBaseType2->WriteTypePrefix( rBase, rOutStm, 0, WRITE_C_HEADER );
663 0 : rOutStm << endl;
664 :
665 : // for methods also C syntax
666 0 : rOutStm << "<C-SYNTAX>" << endl;
667 0 : Write( rBase, rOutStm, 0, WRITE_C_HEADER, nA );
668 0 : rOutStm << "</C-SYNTAX>" << endl;
669 :
670 : // description
671 0 : WriteDescription( rOutStm );
672 0 : rOutStm << "</METHOD>" << endl << endl;
673 : }
674 0 : else if( bVariable && IsVariable() )
675 : {
676 0 : if( nBType == TYPE_STRUCT )
677 : {
678 0 : WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA );
679 : }
680 : else
681 : {
682 0 : rOutStm << "<PROPERTY>" << endl
683 0 : << GetSlotId().getString().getStr() << endl
684 0 : << GetName().getString().getStr() << endl;
685 0 : if ( GetReadonly() )
686 0 : rOutStm << "(nur lesen)" << endl;
687 : else
688 0 : rOutStm << endl;
689 :
690 : // for properties type instead of the return value
691 0 : rOutStm << pBaseType->GetBasicName().getStr() << endl;
692 :
693 : DBG_ASSERT( !pBaseType->GetBasicName().isEmpty(),
694 : "Leerer BasicName" );
695 :
696 : // for properties no syntax
697 0 : rOutStm << endl;
698 :
699 : // C return type
700 0 : pBaseType->WriteTypePrefix( rBase, rOutStm, 0, WRITE_C_HEADER );
701 0 : rOutStm << endl;
702 :
703 : // description
704 0 : WriteDescription( rOutStm );
705 0 : rOutStm << "</PROPERTY>" << endl << endl;
706 : }
707 : }
708 : }
709 : }
710 :
711 596 : sal_uLong SvMetaAttribute::MakeSfx( rtl::OStringBuffer& rAttrArray )
712 : {
713 596 : SvMetaType * pType = GetType();
714 : DBG_ASSERT( pType, "no type for attribute" );
715 596 : SvMetaType * pBaseType = pType->GetBaseType();
716 : DBG_ASSERT( pBaseType, "no base type for attribute" );
717 596 : if( pBaseType->GetType() == TYPE_STRUCT )
718 0 : return pBaseType->MakeSfx( rAttrArray );
719 : else
720 : {
721 596 : rAttrArray.append('{');
722 596 : rAttrArray.append(GetSlotId().getString());
723 596 : rAttrArray.append(",\"");
724 596 : rAttrArray.append(GetName().getString());
725 596 : rAttrArray.append("\"}");
726 596 : return 1;
727 : }
728 : }
729 :
730 9 : void SvMetaAttribute::Insert (SvSlotElementList&, const rtl::OString&, SvIdlDataBase&)
731 : {
732 9 : }
733 :
734 16 : void SvMetaAttribute::WriteHelpId( SvIdlDataBase &, SvStream &, HelpIdTable& )
735 : {
736 16 : }
737 :
738 72968 : SV_IMPL_META_FACTORY1( SvMetaType, SvMetaExtern );
739 : #define CTOR \
740 : : aCall0( CALL_VALUE, sal_False ) \
741 : , aCall1( CALL_VALUE, sal_False ) \
742 : , aSbxDataType( 0, sal_False ) \
743 : , pAttrList( NULL ) \
744 : , nType( TYPE_BASE ) \
745 : , bIsItem( sal_False ) \
746 : , bIsShell( sal_False ) \
747 : , cParserChar( 'h' )
748 :
749 6234 : SvMetaType::SvMetaType()
750 6234 : CTOR
751 : {
752 6234 : }
753 :
754 0 : SvMetaType::SvMetaType( const rtl::OString& rName, char cPC,
755 : const rtl::OString& rCName )
756 0 : CTOR
757 : {
758 0 : SetName( rName );
759 0 : cParserChar = cPC;
760 0 : aCName.setString(rCName);
761 0 : }
762 :
763 104 : SvMetaType::SvMetaType( const rtl::OString& rName,
764 : const rtl::OString& rSbxName,
765 : const rtl::OString& rOdlName,
766 : char cPc,
767 : const rtl::OString& rCName,
768 : const rtl::OString& rBasicName,
769 : const rtl::OString& rBasicPostfix )
770 104 : CTOR
771 : {
772 104 : SetName( rName );
773 104 : aSbxName.setString(rSbxName);
774 104 : aOdlName.setString(rOdlName);
775 104 : cParserChar = cPc;
776 104 : aCName.setString(rCName);
777 104 : aBasicName.setString(rBasicName);
778 104 : aBasicPostfix.setString(rBasicPostfix);
779 104 : }
780 :
781 0 : void SvMetaType::Load( SvPersistStream & rStm )
782 : {
783 0 : SvMetaExtern::Load( rStm );
784 :
785 : sal_uInt16 nMask;
786 0 : rStm >> nMask;
787 0 : if( nMask & 0x0001 ) rStm >> aIn;
788 0 : if( nMask & 0x0002 ) rStm >> aOut;
789 0 : if( nMask & 0x0004 ) rStm >> aCall0;
790 0 : if( nMask & 0x0008 ) rStm >> aCall1;
791 0 : if( nMask & 0x0010 ) rStm >> aSbxDataType;
792 0 : if( nMask & 0x0020 ) rStm >> aSvName;
793 0 : if( nMask & 0x0040 ) rStm >> aSbxName;
794 0 : if( nMask & 0x0080 ) rStm >> aOdlName;
795 0 : if( nMask & 0x0100 ) rStm >> GetAttrList();
796 0 : if( nMask & 0x0200 ) bIsItem = sal_True;
797 0 : if( nMask & 0x0400 ) bIsShell = sal_True;
798 0 : if( nMask & 0x0800 )
799 : {
800 : sal_uInt16 nT;
801 0 : rStm >> nT;
802 0 : nType = nT;
803 : }
804 0 : if( nMask & 0x1000 ) rStm >> cParserChar;
805 0 : if( nMask & 0x2000 ) rStm >> aCName;
806 0 : if( nMask & 0x4000 ) rStm >> aBasicName;
807 0 : if( nMask & 0x8000 ) rStm >> aBasicPostfix;
808 0 : }
809 :
810 6338 : void SvMetaType::Save( SvPersistStream & rStm )
811 : {
812 6338 : SvMetaExtern::Save( rStm );
813 :
814 : // create mask
815 6338 : sal_uInt16 nMask = 0;
816 6338 : if( aIn.IsSet() ) nMask |= 0x0001;
817 6338 : if( aOut.IsSet() ) nMask |= 0x0002;
818 6338 : if( aCall0.IsSet() ) nMask |= 0x0004;
819 6338 : if( aCall1.IsSet() ) nMask |= 0x0008;
820 6338 : if( aSbxDataType.IsSet() ) nMask |= 0x0010;
821 6338 : if( aSvName.IsSet() ) nMask |= 0x0020;
822 6338 : if( aSbxName.IsSet() ) nMask |= 0x0040;
823 6338 : if( aOdlName.IsSet() ) nMask |= 0x0080;
824 6338 : if( GetAttrCount() ) nMask |= 0x0100;
825 6338 : if( bIsItem ) nMask |= 0x0200;
826 6338 : if( bIsShell ) nMask |= 0x0400;
827 6338 : if( nType != TYPE_BASE ) nMask |= 0x0800;
828 6338 : if( cParserChar != 'h' ) nMask |= 0x1000;
829 6338 : if( aCName.IsSet() ) nMask |= 0x2000;
830 6338 : if( aBasicName.IsSet() ) nMask |= 0x4000;
831 6338 : if( aBasicPostfix.IsSet() ) nMask |= 0x8000;
832 :
833 : // write data
834 6338 : rStm << nMask;
835 6338 : if( nMask & 0x0001 ) rStm << aIn;
836 6338 : if( nMask & 0x0002 ) rStm << aOut;
837 6338 : if( nMask & 0x0004 ) rStm << aCall0;
838 6338 : if( nMask & 0x0008 ) rStm << aCall1;
839 6338 : if( nMask & 0x0010 ) rStm << aSbxDataType;
840 6338 : if( nMask & 0x0020 ) rStm << aSvName;
841 6338 : if( nMask & 0x0040 ) rStm << aSbxName;
842 6338 : if( nMask & 0x0080 ) rStm << aOdlName;
843 6338 : if( nMask & 0x0100 ) rStm << *pAttrList;
844 6338 : if( nMask & 0x0800 ) rStm << (sal_uInt16)nType;
845 6338 : if( nMask & 0x1000 ) rStm << cParserChar;
846 6338 : if( nMask & 0x2000 ) rStm << aCName;
847 6338 : if( nMask & 0x4000 ) rStm << aBasicName;
848 6338 : if( nMask & 0x8000 ) rStm << aBasicPostfix;
849 6338 : }
850 :
851 8013 : SvMetaAttributeMemberList & SvMetaType::GetAttrList() const
852 : {
853 8013 : if( !pAttrList )
854 3039 : ((SvMetaType *)this)->pAttrList = new SvMetaAttributeMemberList();
855 8013 : return *pAttrList;
856 : }
857 :
858 5089 : void SvMetaType::SetType( int nT )
859 : {
860 5089 : nType = nT;
861 5089 : if( nType == TYPE_ENUM )
862 : {
863 205 : aOdlName.setString("short");
864 : }
865 4884 : else if( nType == TYPE_CLASS )
866 : {
867 194 : rtl::OStringBuffer aTmp(C_PREF);
868 194 : aTmp.append(RTL_CONSTASCII_STRINGPARAM("Object *"));
869 194 : aCName.setString(aTmp.makeStringAndClear());
870 : }
871 5089 : }
872 :
873 14073 : SvMetaType * SvMetaType::GetBaseType() const
874 : {
875 14073 : if( GetRef() && GetType() == TYPE_BASE )
876 5053 : return ((SvMetaType *)GetRef())->GetBaseType();
877 9020 : return (SvMetaType *)this;
878 : }
879 :
880 6645 : SvMetaType * SvMetaType::GetReturnType() const
881 : {
882 : DBG_ASSERT( GetType() == TYPE_METHOD, "no method" );
883 : DBG_ASSERT( GetRef(), "no return type" );
884 6645 : return (SvMetaType *)GetRef();
885 : }
886 :
887 0 : const rtl::OString& SvMetaType::GetBasicName() const
888 : {
889 0 : if( aBasicName.IsSet() || !GetRef() )
890 0 : return aBasicName.getString();
891 : else
892 0 : return ((SvMetaType*)GetRef())->GetBasicName();
893 : }
894 :
895 0 : rtl::OString SvMetaType::GetBasicPostfix() const
896 : {
897 : // MBN and Co always want "As xxx"
898 : return rtl::OStringBuffer(RTL_CONSTASCII_STRINGPARAM(" As ")).
899 0 : append(GetBasicName()).
900 0 : makeStringAndClear();
901 : }
902 :
903 88744 : sal_Bool SvMetaType::GetIn() const
904 : {
905 88744 : if( aIn.IsSet() || !GetRef() )
906 40122 : return aIn;
907 : else
908 48622 : return ((SvMetaType *)GetRef())->GetIn();
909 : }
910 :
911 44372 : sal_Bool SvMetaType::GetOut() const
912 : {
913 44372 : if( aOut.IsSet() || !GetRef() )
914 20061 : return aOut;
915 : else
916 24311 : return ((SvMetaType *)GetRef())->GetOut();
917 : }
918 :
919 0 : void SvMetaType::SetCall0( int e )
920 : {
921 0 : aCall0 = (int)e;
922 0 : if( aCall0 == CALL_VALUE && aCall1 == CALL_VALUE )
923 : {
924 0 : if( GetType() == TYPE_POINTER )
925 0 : SetType( TYPE_BASE );
926 : }
927 : else
928 : {
929 : DBG_ASSERT( nType == TYPE_POINTER || nType == TYPE_BASE,
930 : "set no base type to pointer" );
931 0 : SetType( TYPE_POINTER );
932 : }
933 0 : }
934 :
935 0 : int SvMetaType::GetCall0() const
936 : {
937 0 : if( aCall0.IsSet() || !GetRef() )
938 0 : return aCall0;
939 : else
940 0 : return ((SvMetaType *)GetRef())->GetCall0();
941 : }
942 :
943 0 : void SvMetaType::SetCall1( int e )
944 : {
945 0 : aCall1 = (int)e;
946 0 : if( aCall0 == CALL_VALUE && aCall1 == CALL_VALUE )
947 : {
948 0 : if( GetType() == TYPE_POINTER )
949 0 : SetType( TYPE_BASE );
950 : }
951 : else
952 : {
953 : DBG_ASSERT( nType == TYPE_POINTER || nType == TYPE_BASE,
954 : "set no base type to pointer" );
955 0 : SetType( TYPE_POINTER );
956 : }
957 0 : }
958 :
959 0 : int SvMetaType::GetCall1() const
960 : {
961 0 : if( aCall1.IsSet() || !GetRef() )
962 0 : return aCall1;
963 : else
964 0 : return ((SvMetaType *)GetRef())->GetCall1();
965 : }
966 :
967 26710 : const rtl::OString& SvMetaType::GetSvName() const
968 : {
969 26710 : if( aSvName.IsSet() || !GetRef() )
970 20061 : return aSvName.getString();
971 : else
972 6649 : return ((SvMetaType *)GetRef())->GetSvName();
973 : }
974 :
975 0 : const rtl::OString& SvMetaType::GetSbxName() const
976 : {
977 0 : if( aSbxName.IsSet() || !GetRef() )
978 0 : return aSbxName.getString();
979 : else
980 0 : return ((SvMetaType *)GetRef())->GetSbxName();
981 : }
982 :
983 0 : const rtl::OString& SvMetaType::GetOdlName() const
984 : {
985 0 : if( aOdlName.IsSet() || !GetRef() )
986 0 : return aOdlName.getString();
987 : else
988 0 : return ((SvMetaType *)GetRef())->GetOdlName();
989 : }
990 :
991 0 : const rtl::OString& SvMetaType::GetCName() const
992 : {
993 0 : if( aCName.IsSet() || !GetRef() )
994 0 : return aCName.getString();
995 : else
996 0 : return ((SvMetaType *)GetRef())->GetCName();
997 : }
998 :
999 1955 : sal_Bool SvMetaType::SetName( const rtl::OString& rName, SvIdlDataBase * pBase )
1000 : {
1001 1955 : aSvName.setString(rName);
1002 1955 : aSbxName.setString(rName);
1003 1955 : aCName.setString(rName);
1004 1955 : if( GetType() != TYPE_ENUM )
1005 1750 : aOdlName.setString(rName);
1006 1955 : return SvMetaReference::SetName( rName, pBase );
1007 : }
1008 :
1009 20061 : rtl::OString SvMetaType::GetCString() const
1010 : {
1011 20061 : rtl::OStringBuffer out( GetSvName() );
1012 20061 : if( aCall0 == (int)CALL_POINTER )
1013 0 : out.append(" *");
1014 20061 : else if( aCall0 == (int)CALL_REFERENCE )
1015 0 : out.append(" &");
1016 20061 : if( aCall1 == (int)CALL_POINTER )
1017 0 : out.append('*');
1018 20061 : else if( aCall1 == (int)CALL_REFERENCE )
1019 0 : out.append('&');
1020 20061 : return out.makeStringAndClear();
1021 : }
1022 :
1023 1851 : sal_Bool SvMetaType::ReadHeaderSvIdl( SvIdlDataBase & rBase,
1024 : SvTokenStream & rInStm )
1025 : {
1026 1851 : sal_Bool bOk = sal_False;
1027 1851 : sal_uInt32 nTokPos = rInStm.Tell();
1028 1851 : SvToken * pTok = rInStm.GetToken_Next();
1029 :
1030 3594 : if( pTok->Is( SvHash_interface() )
1031 1743 : || pTok->Is( SvHash_shell() ) )
1032 : {
1033 194 : if( pTok->Is( SvHash_shell() ) )
1034 86 : bIsShell = sal_True;
1035 194 : SetType( TYPE_CLASS );
1036 194 : bOk = ReadNamesSvIdl( rBase, rInStm );
1037 :
1038 : }
1039 1657 : else if( pTok->Is( SvHash_struct() ) )
1040 : {
1041 307 : SetType( TYPE_STRUCT );
1042 307 : bOk = ReadNamesSvIdl( rBase, rInStm );
1043 : }
1044 1350 : else if( pTok->Is( SvHash_union() ) )
1045 : {
1046 0 : SetType( TYPE_UNION );
1047 0 : if( ReadNameSvIdl( rBase, rInStm ) )
1048 0 : return sal_True;
1049 : }
1050 1350 : else if( pTok->Is( SvHash_enum() ) )
1051 : {
1052 205 : SetType( TYPE_ENUM );
1053 205 : bOk = ReadNameSvIdl( rBase, rInStm );
1054 : }
1055 2290 : else if( pTok->Is( SvHash_typedef() )
1056 1145 : || pTok->Is( SvHash_item() ) )
1057 : {
1058 1145 : if( pTok->Is( SvHash_item() ) )
1059 1145 : bIsItem = sal_True;
1060 :
1061 1145 : SvMetaType * pType = rBase.ReadKnownType( rInStm );
1062 1145 : if( pType )
1063 : {
1064 1145 : SetRef( pType );
1065 1145 : if( ReadNameSvIdl( rBase, rInStm ) )
1066 : {
1067 1145 : if( rInStm.Read( '(' ) )
1068 : {
1069 0 : DoReadContextSvIdl( rBase, rInStm );
1070 0 : if( rInStm.Read( ')' ) )
1071 : {
1072 0 : SetType( TYPE_METHOD );
1073 0 : bOk = sal_True;
1074 : }
1075 : }
1076 : else
1077 : {
1078 1145 : bOk = sal_True;
1079 : }
1080 : }
1081 : }
1082 : else
1083 : {
1084 0 : rtl::OString aStr("wrong typedef: ");
1085 0 : rBase.SetError( aStr, rInStm.GetToken() );
1086 0 : rBase.WriteError( rInStm );
1087 : }
1088 : }
1089 1851 : if( bOk )
1090 1851 : SetModule( rBase );
1091 : else
1092 0 : rInStm.Seek( nTokPos );
1093 1851 : return bOk;
1094 : }
1095 :
1096 1452 : sal_Bool SvMetaType::ReadSvIdl( SvIdlDataBase & rBase,
1097 : SvTokenStream & rInStm )
1098 : {
1099 1452 : if( ReadHeaderSvIdl( rBase, rInStm ) )
1100 : {
1101 1452 : rBase.Write(rtl::OString('.'));
1102 1452 : return SvMetaExtern::ReadSvIdl( rBase, rInStm );
1103 : }
1104 0 : return sal_False;
1105 : }
1106 :
1107 1452 : void SvMetaType::WriteSvIdl
1108 : (
1109 : SvIdlDataBase & rBase,
1110 : SvStream & rOutStm,
1111 : sal_uInt16 nTab
1112 : )
1113 : {
1114 1452 : WriteHeaderSvIdl( rBase, rOutStm, nTab );
1115 1452 : if( GetType() == TYPE_METHOD )
1116 0 : WriteMethodArgs( rBase, rOutStm, nTab, WRITE_IDL );
1117 :
1118 1452 : sal_uLong nOldPos = rOutStm.Tell();
1119 1452 : rOutStm << endl;
1120 1452 : SvMetaExtern::WriteSvIdl( rBase, rOutStm, nTab );
1121 1452 : if( TestAndSeekSpaceOnly( rOutStm, nOldPos ) )
1122 : // nothin written
1123 1145 : rOutStm.Seek( nOldPos );
1124 1452 : rOutStm << ';' << endl;
1125 1452 : }
1126 :
1127 0 : void SvMetaType::WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm,
1128 : sal_uInt16 nTab,
1129 : WriteType nT, WriteAttribute nA )
1130 : {
1131 0 : if( GetAttrCount() )
1132 : {
1133 0 : SvMetaAttributeMemberList::const_iterator it = pAttrList->begin();
1134 0 : while( it != pAttrList->end() )
1135 : {
1136 0 : SvMetaAttribute * pAttr = *it;
1137 0 : pAttr->Write( rBase, rOutStm, nTab, nT, nA );
1138 0 : if( GetType() == TYPE_METHOD )
1139 0 : rOutStm << ',' << endl;
1140 : else
1141 0 : rOutStm << ';' << endl;
1142 0 : ++it;
1143 : }
1144 : }
1145 0 : }
1146 :
1147 0 : void SvMetaType::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
1148 : sal_uInt16 nTab,
1149 : WriteType nT, WriteAttribute nA )
1150 : {
1151 0 : if( nT == WRITE_C_HEADER && nType != TYPE_ENUM )
1152 : // write only enum
1153 0 : return;
1154 :
1155 0 : rtl::OString name = GetName().getString();
1156 0 : if( nT == WRITE_ODL || nT == WRITE_C_HEADER || nT == WRITE_CXX_HEADER )
1157 : {
1158 0 : switch( nType )
1159 : {
1160 : case TYPE_CLASS:
1161 : {
1162 : }
1163 0 : break;
1164 : case TYPE_STRUCT:
1165 : case TYPE_UNION:
1166 : case TYPE_ENUM:
1167 : {
1168 0 : WriteStars( rOutStm );
1169 0 : if( nType == TYPE_STRUCT || nType == TYPE_UNION )
1170 0 : nA = WA_STRUCT;
1171 :
1172 0 : if( nT == WRITE_ODL || nT == WRITE_C_HEADER)
1173 : {
1174 0 : if ( nT == WRITE_C_HEADER )
1175 : {
1176 0 : rtl::OString aStr = name.toAsciiUpperCase();
1177 0 : rOutStm << "#ifndef " << C_PREF << aStr.getStr() << "_DEF " << endl;
1178 0 : rOutStm << "#define " << C_PREF << aStr.getStr() << "_DEF " << endl;
1179 : }
1180 :
1181 0 : WriteTab( rOutStm, nTab );
1182 0 : rOutStm << "typedef" << endl;
1183 0 : if ( nT == WRITE_ODL )
1184 0 : SvMetaName::Write( rBase, rOutStm, nTab, nT, nA );
1185 : }
1186 0 : WriteTab( rOutStm, nTab );
1187 0 : if( nType == TYPE_STRUCT )
1188 0 : rOutStm << "struct";
1189 0 : else if( nType == TYPE_UNION )
1190 0 : rOutStm << "union";
1191 : else
1192 0 : rOutStm << "enum";
1193 0 : if( nT != WRITE_ODL && nT != WRITE_C_HEADER)
1194 0 : rOutStm << ' ' << name.getStr();
1195 :
1196 0 : rOutStm << endl;
1197 0 : WriteTab( rOutStm, nTab );
1198 0 : rOutStm << '{' << endl;
1199 0 : WriteContext( rBase, rOutStm, nTab +1, nT, nA );
1200 0 : WriteTab( rOutStm, nTab );
1201 0 : rOutStm << '}';
1202 0 : if( nT == WRITE_ODL || nT == WRITE_C_HEADER )
1203 : {
1204 0 : rOutStm << ' ' << C_PREF << name.getStr();
1205 : }
1206 0 : rOutStm << ';' << endl;
1207 :
1208 0 : if ( nT == WRITE_C_HEADER )
1209 0 : rOutStm << "#endif";
1210 0 : rOutStm << endl;
1211 : }
1212 0 : break;
1213 : case TYPE_POINTER:
1214 : case TYPE_BASE:
1215 : {
1216 : }
1217 0 : break;
1218 : case TYPE_METHOD:
1219 : {
1220 : }
1221 0 : break;
1222 : }
1223 0 : }
1224 : }
1225 :
1226 501 : sal_Bool SvMetaType::ReadNamesSvIdl( SvIdlDataBase & rBase,
1227 : SvTokenStream & rInStm )
1228 : {
1229 501 : sal_Bool bOk = ReadNameSvIdl( rBase, rInStm );
1230 :
1231 501 : return bOk;
1232 : }
1233 :
1234 1851 : void SvMetaType::WriteHeaderSvIdl( SvIdlDataBase & rBase,
1235 : SvStream & rOutStm,
1236 : sal_uInt16 nTab )
1237 : {
1238 1851 : switch( nType )
1239 : {
1240 : case TYPE_CLASS:
1241 : {
1242 194 : if( IsShell() )
1243 86 : rOutStm << SvHash_shell()->GetName().getStr();
1244 : else
1245 108 : rOutStm << SvHash_interface()->GetName().getStr();
1246 194 : rOutStm << ' ' << GetName().getString().getStr();
1247 : }
1248 194 : break;
1249 : case TYPE_STRUCT:
1250 : {
1251 307 : rOutStm << SvHash_struct()->GetName().getStr()
1252 614 : << ' ' << GetName().getString().getStr();
1253 : }
1254 307 : break;
1255 : case TYPE_UNION:
1256 : {
1257 0 : rOutStm << SvHash_union()->GetName().getStr()
1258 0 : << ' ' << GetName().getString().getStr();
1259 : }
1260 0 : break;
1261 : case TYPE_ENUM:
1262 : {
1263 205 : rOutStm << SvHash_enum()->GetName().getStr()
1264 410 : << ' ' << GetName().getString().getStr();
1265 : }
1266 205 : break;
1267 : case TYPE_POINTER:
1268 : case TYPE_BASE:
1269 : {
1270 1145 : if( IsItem() )
1271 1145 : rOutStm << SvHash_item()->GetName().getStr() << ' ';
1272 : else
1273 0 : rOutStm << SvHash_typedef()->GetName().getStr() << ' ';
1274 1145 : if( GetRef() )
1275 : {
1276 1145 : ((SvMetaType *)GetRef())->WriteTheType( rBase, rOutStm, nTab, WRITE_IDL );
1277 1145 : rOutStm << ' ';
1278 : }
1279 1145 : rOutStm << GetName().getString().getStr();
1280 : }
1281 1145 : break;
1282 : case TYPE_METHOD:
1283 : {
1284 0 : rOutStm << SvHash_typedef()->GetName().getStr() << ' ';
1285 0 : ((SvMetaType *)GetRef())->WriteTheType( rBase, rOutStm, nTab, WRITE_IDL );
1286 0 : rOutStm << ' ' << GetName().getString().getStr() << "( ";
1287 0 : WriteContextSvIdl( rBase, rOutStm, nTab );
1288 0 : rOutStm << " )";
1289 : }
1290 0 : break;
1291 : }
1292 1851 : }
1293 :
1294 182 : void SvMetaType::ReadAttributesSvIdl( SvIdlDataBase & rBase,
1295 : SvTokenStream & rInStm )
1296 : {
1297 182 : SvMetaExtern::ReadAttributesSvIdl( rBase, rInStm );
1298 182 : aSvName.ReadSvIdl( SvHash_SvName(), rInStm );
1299 182 : aSbxName.ReadSvIdl( SvHash_SbxName(), rInStm );
1300 182 : aOdlName.ReadSvIdl( SvHash_OdlName(), rInStm );
1301 182 : }
1302 :
1303 1851 : void SvMetaType::WriteAttributesSvIdl( SvIdlDataBase & rBase,
1304 : SvStream & rOutStm,
1305 : sal_uInt16 nTab )
1306 : {
1307 1851 : SvMetaExtern::WriteAttributesSvIdl( rBase, rOutStm, nTab );
1308 1851 : rtl::OString name = GetName().getString();
1309 1851 : if( aSvName.getString() != name || aSbxName.getString() != name || aOdlName.getString() != name )
1310 : {
1311 205 : WriteTab( rOutStm, nTab );
1312 205 : rOutStm << "class SvMetaType" << endl;
1313 205 : if( aSvName.getString() != name )
1314 : {
1315 0 : WriteTab( rOutStm, nTab );
1316 0 : aSvName.WriteSvIdl( SvHash_SvName(), rOutStm, nTab );
1317 0 : rOutStm << endl;
1318 : }
1319 205 : if( aSbxName.getString() != name )
1320 : {
1321 0 : WriteTab( rOutStm, nTab );
1322 0 : aSbxName.WriteSvIdl( SvHash_SbxName(), rOutStm, nTab );
1323 0 : rOutStm << endl;
1324 : }
1325 205 : if( aOdlName.getString() != name )
1326 : {
1327 205 : WriteTab( rOutStm, nTab );
1328 205 : aOdlName.WriteSvIdl( SvHash_OdlName(), rOutStm, nTab );
1329 205 : rOutStm << endl;
1330 : }
1331 1851 : }
1332 1851 : }
1333 :
1334 9414 : void SvMetaType::ReadContextSvIdl( SvIdlDataBase & rBase,
1335 : SvTokenStream & rInStm )
1336 : {
1337 9414 : SvMetaAttributeRef xAttr = new SvMetaAttribute();
1338 9414 : if( xAttr->ReadSvIdl( rBase, rInStm ) )
1339 : {
1340 4724 : if( xAttr->Test( rBase, rInStm ) )
1341 4724 : GetAttrList().push_back( xAttr );
1342 9414 : }
1343 9414 : }
1344 :
1345 1452 : void SvMetaType::WriteContextSvIdl
1346 : (
1347 : SvIdlDataBase & rBase,
1348 : SvStream & rOutStm,
1349 : sal_uInt16 nTab
1350 : )
1351 : {
1352 1452 : if( GetAttrCount() )
1353 : {
1354 307 : SvMetaAttributeMemberList::const_iterator it = pAttrList->begin();
1355 1902 : while( it != pAttrList->end() )
1356 : {
1357 1288 : SvMetaAttribute * pAttr = *it;
1358 1288 : WriteTab( rOutStm, nTab );
1359 1288 : pAttr->WriteSvIdl( rBase, rOutStm, nTab );
1360 1288 : if( GetType() == TYPE_METHOD )
1361 0 : rOutStm << ',' << endl;
1362 : else
1363 1288 : rOutStm << ';' << endl;
1364 1288 : ++it;
1365 : }
1366 : }
1367 1452 : }
1368 :
1369 0 : void SvMetaType::WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm,
1370 : sal_uInt16 nTab,
1371 : WriteType nT, WriteAttribute nA )
1372 : {
1373 0 : SvMetaExtern::WriteAttributes( rBase, rOutStm, nTab, nT, nA );
1374 0 : }
1375 :
1376 403 : sal_uLong SvMetaType::MakeSfx( rtl::OStringBuffer& rAttrArray )
1377 : {
1378 403 : sal_uLong nC = 0;
1379 :
1380 403 : if( GetBaseType()->GetType() == TYPE_STRUCT )
1381 : {
1382 133 : sal_uLong nAttrCount = GetAttrCount();
1383 : // write the single attributes
1384 729 : for( sal_uLong n = 0; n < nAttrCount; n++ )
1385 : {
1386 596 : nC += (*pAttrList)[n]->MakeSfx( rAttrArray );
1387 596 : if( n +1 < nAttrCount )
1388 463 : rAttrArray.append(", ");
1389 : }
1390 : }
1391 403 : return nC;
1392 : }
1393 :
1394 403 : void SvMetaType::WriteSfxItem(
1395 : const rtl::OString& rItemName, SvIdlDataBase &, SvStream & rOutStm )
1396 : {
1397 403 : WriteStars( rOutStm );
1398 403 : rtl::OStringBuffer aVarName(RTL_CONSTASCII_STRINGPARAM(" a"));
1399 403 : aVarName.append(rItemName).append(RTL_CONSTASCII_STRINGPARAM("_Impl"));
1400 :
1401 403 : rtl::OStringBuffer aTypeName(RTL_CONSTASCII_STRINGPARAM("SfxType"));
1402 403 : rtl::OStringBuffer aAttrArray;
1403 403 : sal_uLong nAttrCount = MakeSfx( aAttrArray );
1404 : rtl::OString aAttrCount(
1405 403 : rtl::OString::valueOf(static_cast<sal_Int32>(nAttrCount)));
1406 403 : aTypeName.append(aAttrCount);
1407 :
1408 403 : rOutStm << "extern " << aTypeName.getStr()
1409 806 : << aVarName.getStr() << ';' << endl;
1410 :
1411 : // write the implementation part
1412 403 : rOutStm << "#ifdef SFX_TYPEMAP" << endl
1413 403 : << "#if defined(DISABLE_DYNLOADING) && (defined(ANDROID) || defined(IOS))" << endl
1414 403 : << "__attribute__((__weak__))" << endl
1415 403 : << "#endif" << endl
1416 806 : << aTypeName.getStr() << aVarName.getStr()
1417 403 : << " = " << endl;
1418 403 : rOutStm << '{' << endl
1419 806 : << "\tTYPE(" << rItemName.getStr() << "), "
1420 806 : << aAttrCount.getStr();
1421 403 : if( nAttrCount )
1422 : {
1423 133 : rOutStm << ", { ";
1424 : // write the single attributes
1425 133 : rOutStm << aAttrArray.getStr();
1426 133 : rOutStm << " }";
1427 : }
1428 403 : rOutStm << endl << "};" << endl
1429 403 : << "#endif" << endl << endl;
1430 403 : }
1431 :
1432 2243 : void SvMetaType::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
1433 : {
1434 2243 : if( IsItem() )
1435 : {
1436 403 : if( GetBaseType()->GetType() == TYPE_STRUCT )
1437 133 : GetBaseType()->WriteSfxItem( GetName().getString(), rBase, rOutStm );
1438 : else
1439 270 : WriteSfxItem( GetName().getString(), rBase, rOutStm );
1440 : }
1441 2243 : }
1442 :
1443 4383 : sal_Bool SvMetaType::ReadMethodArgs( SvIdlDataBase & rBase,
1444 : SvTokenStream & rInStm )
1445 : {
1446 4383 : sal_uInt32 nTokPos = rInStm.Tell();
1447 4383 : if( rInStm.Read( '(' ) )
1448 : {
1449 4383 : DoReadContextSvIdl( rBase, rInStm );
1450 4383 : if( rInStm.Read( ')' ) )
1451 : {
1452 4383 : SetType( TYPE_METHOD );
1453 4383 : return sal_True;
1454 : }
1455 : }
1456 0 : rInStm.Seek( nTokPos );
1457 0 : return sal_False;
1458 : }
1459 :
1460 6649 : void SvMetaType::WriteMethodArgs
1461 : (
1462 : SvIdlDataBase & rBase,
1463 : SvStream & rOutStm,
1464 : sal_uInt16 nTab, WriteType nT
1465 : )
1466 : {
1467 6649 : if( nT == WRITE_IDL )
1468 : {
1469 6649 : if( GetAttrCount() )
1470 : {
1471 2082 : rOutStm << endl;
1472 2082 : WriteTab( rOutStm, nTab );
1473 2082 : rOutStm << '(' << endl;
1474 :
1475 2082 : SvMetaAttributeMemberList::const_iterator it = pAttrList->begin();
1476 9120 : while( it != pAttrList->end() )
1477 : {
1478 4956 : SvMetaAttribute * pAttr = *it;
1479 4956 : WriteTab( rOutStm, nTab +1 );
1480 4956 : pAttr->WriteSvIdl( rBase, rOutStm, nTab +1 );
1481 4956 : ++it;
1482 4956 : if( it != pAttrList->end() )
1483 2874 : rOutStm << ',' << endl;
1484 : }
1485 2082 : rOutStm << endl;
1486 2082 : WriteTab( rOutStm, nTab );
1487 2082 : rOutStm << ')';
1488 : }
1489 : else
1490 4567 : rOutStm << "()";
1491 : }
1492 0 : else if ( nT == WRITE_DOCU )
1493 : {
1494 :
1495 0 : rOutStm << '(';
1496 0 : if( GetAttrCount() )
1497 : {
1498 0 : SvMetaAttributeMemberList::const_iterator it = pAttrList->begin();
1499 0 : while( it != pAttrList->end() )
1500 : {
1501 0 : SvMetaAttribute * pAttr = *it;
1502 0 : pAttr->WriteParam( rBase, rOutStm, nTab+1, nT );
1503 0 : ++it;
1504 0 : if( it != pAttrList->end() )
1505 0 : rOutStm << ',';
1506 : else
1507 0 : rOutStm << ' ';
1508 : }
1509 : }
1510 0 : rOutStm << ')' << endl;
1511 : }
1512 : else
1513 : {
1514 0 : rOutStm << '(';
1515 0 : if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
1516 : {
1517 0 : rOutStm << ' ' << C_PREF << "Object h" << rBase.aIFaceName.getStr();
1518 0 : if( GetAttrCount() )
1519 0 : rOutStm << ',';
1520 : else
1521 0 : rOutStm << ' ';
1522 : }
1523 :
1524 0 : if( GetAttrCount() )
1525 : {
1526 0 : rOutStm << endl;
1527 0 : SvMetaAttributeMemberList::const_iterator it = pAttrList->begin();
1528 0 : while( it != pAttrList->end() )
1529 : {
1530 0 : SvMetaAttribute* pAttr = *it;
1531 0 : switch( nT )
1532 : {
1533 : case WRITE_C_HEADER:
1534 : case WRITE_C_SOURCE:
1535 : case WRITE_ODL:
1536 : {
1537 0 : pAttr->WriteParam( rBase, rOutStm, nTab +1, nT );
1538 : }
1539 0 : break;
1540 :
1541 : default:
1542 : {
1543 : DBG_ASSERT( sal_False, "WriteType not implemented" );
1544 : }
1545 : }
1546 0 : ++it;
1547 0 : if( it != pAttrList->end() )
1548 0 : rOutStm << ',' << endl;
1549 : }
1550 0 : if( nT != WRITE_C_HEADER && nT != WRITE_C_SOURCE )
1551 : {
1552 0 : rOutStm << endl;
1553 0 : WriteTab( rOutStm, nTab +1 );
1554 : }
1555 0 : rOutStm << ' ';
1556 : }
1557 0 : rOutStm << ')';
1558 : }
1559 6649 : }
1560 :
1561 20061 : void SvMetaType::WriteTypePrefix( SvIdlDataBase & rBase, SvStream & rOutStm,
1562 : sal_uInt16 nTab, WriteType nT )
1563 : {
1564 20061 : switch( nT )
1565 : {
1566 : case WRITE_IDL:
1567 : {
1568 20061 : if( GetIn() && GetOut() )
1569 0 : rOutStm << SvHash_inout()->GetName().getStr() << ' ';
1570 20061 : else if( GetIn() )
1571 0 : rOutStm << SvHash_in()->GetName().getStr() << ' ';
1572 20061 : else if( GetOut() )
1573 0 : rOutStm << SvHash_out()->GetName().getStr() << ' ';
1574 20061 : rOutStm << GetCString().getStr();
1575 : }
1576 20061 : break;
1577 :
1578 : case WRITE_ODL:
1579 : {
1580 0 : sal_Bool bIn = GetIn();
1581 0 : sal_Bool bOut = GetOut();
1582 0 : if( bIn || bOut )
1583 : {
1584 0 : if( bIn && bOut )
1585 0 : rOutStm << "[in,out] ";
1586 0 : else if( bIn )
1587 0 : rOutStm << "[in] ";
1588 0 : else if( bOut )
1589 0 : rOutStm << "[out] ";
1590 : }
1591 :
1592 0 : rtl::OString out;
1593 0 : if( GetType() == TYPE_METHOD )
1594 0 : out = GetReturnType()->GetBaseType()->GetOdlName();
1595 : else
1596 : {
1597 0 : SvMetaType * pBType = GetBaseType();
1598 0 : out = pBType->GetOdlName();
1599 : }
1600 0 : if( aCall0 == (int)CALL_POINTER
1601 0 : || aCall0 == (int)CALL_REFERENCE )
1602 0 : rOutStm << " *";
1603 0 : if( aCall1 == (int)CALL_POINTER
1604 0 : || aCall1 == (int)CALL_REFERENCE )
1605 0 : rOutStm << " *";
1606 0 : rOutStm << out.getStr();
1607 : }
1608 0 : break;
1609 :
1610 : case WRITE_C_HEADER:
1611 : case WRITE_C_SOURCE:
1612 : case WRITE_CXX_HEADER:
1613 : case WRITE_CXX_SOURCE:
1614 : {
1615 :
1616 0 : SvMetaType * pBaseType = GetBaseType();
1617 : DBG_ASSERT( pBaseType, "no base type for attribute" );
1618 :
1619 0 : if( pBaseType->GetType() == TYPE_METHOD )
1620 : pBaseType->GetReturnType()->WriteTypePrefix(
1621 0 : rBase, rOutStm, nTab, nT );
1622 0 : else if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
1623 : {
1624 0 : if( TYPE_STRUCT == pBaseType->GetType() )
1625 0 : rOutStm << C_PREF << pBaseType->GetName().getString().getStr()
1626 0 : << " *";
1627 : else
1628 : {
1629 0 : if ( pBaseType->GetType() == TYPE_ENUM )
1630 0 : rOutStm << C_PREF;
1631 0 : rOutStm << pBaseType->GetCName().getStr();
1632 : }
1633 : }
1634 : else
1635 : {
1636 0 : if( TYPE_STRUCT == pBaseType->GetType() )
1637 0 : rOutStm << pBaseType->GetName().getString().getStr() << " *";
1638 : else
1639 0 : rOutStm << pBaseType->GetName().getString().getStr();
1640 : }
1641 : }
1642 0 : break;
1643 :
1644 : case WRITE_DOCU:
1645 : {
1646 :
1647 0 : SvMetaType * pBaseType = GetBaseType();
1648 : DBG_ASSERT( pBaseType, "no base type for attribute" );
1649 :
1650 0 : if( pBaseType->GetType() == TYPE_METHOD )
1651 : {
1652 : pBaseType->GetReturnType()->WriteTypePrefix(
1653 0 : rBase, rOutStm, nTab, nT );
1654 : }
1655 : else
1656 : {
1657 0 : if( TYPE_STRUCT == pBaseType->GetType() )
1658 0 : rOutStm << "VARIANT" << pBaseType->GetName().getString().getStr();
1659 0 : else if ( pBaseType->GetType() == TYPE_ENUM )
1660 0 : rOutStm << "integer";
1661 : else
1662 0 : rOutStm << pBaseType->GetOdlName().getStr();
1663 : }
1664 : }
1665 :
1666 : default:
1667 : {
1668 : DBG_ASSERT( sal_False, "WriteType not implemented" );
1669 : }
1670 : }
1671 20061 : }
1672 :
1673 1943 : void SvMetaType::WriteTheType( SvIdlDataBase & rBase, SvStream & rOutStm,
1674 : sal_uInt16 nTab, WriteType nT )
1675 : {
1676 1943 : WriteTypePrefix( rBase, rOutStm, nTab, nT );
1677 1943 : if( GetType() == TYPE_METHOD )
1678 0 : WriteMethodArgs( rBase, rOutStm, nTab +2, nT );
1679 1943 : }
1680 :
1681 0 : rtl::OString SvMetaType::GetParserString() const
1682 : {
1683 0 : SvMetaType * pBT = GetBaseType();
1684 0 : if( pBT != this )
1685 0 : return pBT->GetParserString();
1686 :
1687 0 : int type = GetType();
1688 0 : rtl::OString aPStr;
1689 :
1690 0 : if( TYPE_METHOD == type || TYPE_STRUCT == type )
1691 : {
1692 0 : sal_uLong nAttrCount = GetAttrCount();
1693 : // write the single attributes
1694 0 : for( sal_uLong n = 0; n < nAttrCount; n++ )
1695 : {
1696 0 : SvMetaAttribute * pT = (*pAttrList)[n];
1697 0 : aPStr += pT->GetType()->GetParserString();
1698 0 : }
1699 : }
1700 : else
1701 0 : aPStr = rtl::OString(GetParserChar());
1702 0 : return aPStr;
1703 : }
1704 :
1705 0 : void SvMetaType::WriteParamNames( SvIdlDataBase & rBase,
1706 : SvStream & rOutStm,
1707 : const rtl::OString& rChief )
1708 : {
1709 0 : SvMetaType * pBT = GetBaseType();
1710 0 : if( pBT != this )
1711 0 : pBT->WriteParamNames( rBase, rOutStm, rChief );
1712 : else
1713 : {
1714 0 : int type = GetType();
1715 :
1716 0 : if( TYPE_METHOD == type || TYPE_STRUCT == type )
1717 : {
1718 0 : sal_uLong nAttrCount = GetAttrCount();
1719 : // write the single attributes
1720 0 : for( sal_uLong n = 0; n < nAttrCount; n++ )
1721 : {
1722 0 : SvMetaAttribute * pA = (*pAttrList)[n];
1723 0 : rtl::OString aStr = pA->GetName().getString();
1724 0 : pA->GetType()->WriteParamNames( rBase, rOutStm, aStr );
1725 0 : if( n +1 < nAttrCount )
1726 0 : rOutStm << ", ";
1727 0 : }
1728 : }
1729 : else
1730 0 : rOutStm << rChief.getStr();
1731 : }
1732 0 : }
1733 :
1734 1149 : SV_IMPL_META_FACTORY1( SvMetaTypeString, SvMetaType );
1735 8 : SvMetaTypeString::SvMetaTypeString()
1736 8 : : SvMetaType( "String", "SbxSTRING", "BSTR", 's', "char *", "String", "$" )
1737 : {
1738 8 : }
1739 :
1740 0 : void SvMetaTypeString::Load( SvPersistStream & rStm )
1741 : {
1742 0 : SvMetaType::Load( rStm );
1743 0 : }
1744 :
1745 8 : void SvMetaTypeString::Save( SvPersistStream & rStm )
1746 : {
1747 8 : SvMetaType::Save( rStm );
1748 8 : }
1749 :
1750 1424 : SV_IMPL_META_FACTORY1( SvMetaEnumValue, SvMetaName );
1751 1629 : SvMetaEnumValue::SvMetaEnumValue()
1752 : {
1753 1629 : }
1754 :
1755 0 : void SvMetaEnumValue::Load( SvPersistStream & rStm )
1756 : {
1757 0 : SvMetaName::Load( rStm );
1758 :
1759 : sal_uInt8 nMask;
1760 0 : rStm >> nMask;
1761 0 : if( nMask >= 0x02 )
1762 : {
1763 0 : rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
1764 : OSL_FAIL( "wrong format" );
1765 0 : return;
1766 : }
1767 0 : if( nMask & 0x01 ) aEnumValue = read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rStm);
1768 : }
1769 :
1770 1424 : void SvMetaEnumValue::Save( SvPersistStream & rStm )
1771 : {
1772 1424 : SvMetaName::Save( rStm );
1773 :
1774 : // create mask
1775 1424 : sal_uInt8 nMask = 0;
1776 1424 : if( !aEnumValue.isEmpty() ) nMask |= 0x01;
1777 :
1778 : // write data
1779 1424 : rStm << nMask;
1780 1424 : if( nMask & 0x01 ) write_lenPrefixed_uInt8s_FromOString<sal_uInt16>(rStm, aEnumValue);
1781 1424 : }
1782 :
1783 1629 : sal_Bool SvMetaEnumValue::ReadSvIdl( SvIdlDataBase & rBase,
1784 : SvTokenStream & rInStm )
1785 : {
1786 1629 : if( !ReadNameSvIdl( rBase, rInStm ) )
1787 205 : return sal_False;
1788 1424 : return sal_True;
1789 : }
1790 :
1791 1424 : void SvMetaEnumValue::WriteSvIdl( SvIdlDataBase &, SvStream & rOutStm, sal_uInt16 )
1792 : {
1793 1424 : rOutStm << GetName().getString().getStr();
1794 1424 : }
1795 :
1796 0 : void SvMetaEnumValue::Write( SvIdlDataBase &, SvStream & rOutStm, sal_uInt16,
1797 : WriteType nT, WriteAttribute )
1798 : {
1799 0 : if ( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
1800 0 : rOutStm << C_PREF << GetName().getString().getStr();
1801 : else
1802 0 : rOutStm << GetName().getString().getStr();
1803 0 : }
1804 :
1805 18193 : SV_IMPL_META_FACTORY1( SvMetaTypeEnum, SvMetaType );
1806 205 : SvMetaTypeEnum::SvMetaTypeEnum()
1807 : {
1808 205 : SetBasicName("Integer");
1809 205 : }
1810 :
1811 0 : void SvMetaTypeEnum::Load( SvPersistStream & rStm )
1812 : {
1813 0 : SvMetaType::Load( rStm );
1814 :
1815 : sal_uInt8 nMask;
1816 0 : rStm >> nMask;
1817 0 : if( nMask >= 0x04 )
1818 : {
1819 0 : rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
1820 : OSL_FAIL( "wrong format" );
1821 0 : return;
1822 : }
1823 0 : if( nMask & 0x01 ) rStm >> aEnumValueList;
1824 0 : if( nMask & 0x02 ) aPrefix = read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rStm);
1825 : }
1826 :
1827 205 : void SvMetaTypeEnum::Save( SvPersistStream & rStm )
1828 : {
1829 205 : SvMetaType::Save( rStm );
1830 :
1831 : // create mask
1832 205 : sal_uInt8 nMask = 0;
1833 205 : if( !aEnumValueList.empty() ) nMask |= 0x01;
1834 205 : if( !aPrefix.isEmpty() ) nMask |= 0x02;
1835 :
1836 : // write data
1837 205 : rStm << nMask;
1838 205 : if( nMask & 0x01 ) rStm << aEnumValueList;
1839 205 : if( nMask & 0x02 ) write_lenPrefixed_uInt8s_FromOString<sal_uInt16>(rStm, aPrefix);
1840 205 : }
1841 :
1842 : namespace
1843 : {
1844 1219 : rtl::OString getCommonSubPrefix(const rtl::OString &rA, const rtl::OString &rB)
1845 : {
1846 1219 : sal_Int32 nMax = std::min(rA.getLength(), rB.getLength());
1847 1219 : sal_Int32 nI = 0;
1848 15689 : while (nI < nMax)
1849 : {
1850 13470 : if (rA[nI] != rB[nI])
1851 219 : break;
1852 13251 : ++nI;
1853 : }
1854 1219 : return rA.copy(0, nI);
1855 : }
1856 : }
1857 :
1858 1629 : void SvMetaTypeEnum::ReadContextSvIdl( SvIdlDataBase & rBase,
1859 : SvTokenStream & rInStm )
1860 : {
1861 1629 : sal_uInt32 nTokPos = rInStm.Tell();
1862 :
1863 1629 : SvMetaEnumValueRef aEnumVal = new SvMetaEnumValue();
1864 1629 : sal_Bool bOk = aEnumVal->ReadSvIdl( rBase, rInStm );
1865 1629 : if( bOk )
1866 : {
1867 1424 : if( aEnumValueList.empty() )
1868 : {
1869 : // the first
1870 205 : aPrefix = aEnumVal->GetName().getString();
1871 : }
1872 : else
1873 : {
1874 1219 : aPrefix = getCommonSubPrefix(aPrefix, aEnumVal->GetName().getString());
1875 : }
1876 1424 : aEnumValueList.push_back( aEnumVal );
1877 : }
1878 1629 : if( !bOk )
1879 205 : rInStm.Seek( nTokPos );
1880 1629 : }
1881 :
1882 205 : void SvMetaTypeEnum::WriteContextSvIdl( SvIdlDataBase & rBase,
1883 : SvStream & rOutStm,
1884 : sal_uInt16 nTab )
1885 : {
1886 205 : WriteTab( rOutStm, nTab +1 );
1887 1629 : for( sal_uLong n = 0; n < aEnumValueList.size(); n++ )
1888 : {
1889 1424 : aEnumValueList[n]->WriteSvIdl( rBase, rOutStm, nTab );
1890 1424 : if( n + 1 != aEnumValueList.size() )
1891 1219 : rOutStm << ", ";
1892 : else
1893 205 : rOutStm << endl;
1894 : }
1895 205 : }
1896 :
1897 205 : sal_Bool SvMetaTypeEnum::ReadSvIdl( SvIdlDataBase & rBase,
1898 : SvTokenStream & rInStm )
1899 : {
1900 205 : sal_uInt32 nTokPos = rInStm.Tell();
1901 410 : if( SvMetaType::ReadHeaderSvIdl( rBase, rInStm )
1902 205 : && GetType() == TYPE_ENUM )
1903 : {
1904 205 : if( SvMetaName::ReadSvIdl( rBase, rInStm ) )
1905 205 : return sal_True;
1906 : }
1907 0 : rInStm.Seek( nTokPos );
1908 0 : return sal_False;
1909 : }
1910 :
1911 205 : void SvMetaTypeEnum::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
1912 : sal_uInt16 nTab )
1913 : {
1914 205 : WriteHeaderSvIdl( rBase, rOutStm, nTab );
1915 205 : rOutStm << endl;
1916 205 : SvMetaName::WriteSvIdl( rBase, rOutStm, nTab );
1917 205 : rOutStm << endl;
1918 205 : }
1919 :
1920 0 : void SvMetaTypeEnum::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
1921 : sal_uInt16 nTab,
1922 : WriteType nT, WriteAttribute nA )
1923 : {
1924 0 : SvMetaType::Write( rBase, rOutStm, nTab, nT, nA );
1925 0 : }
1926 :
1927 0 : void SvMetaTypeEnum::WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm,
1928 : sal_uInt16 nTab,
1929 : WriteType nT, WriteAttribute nA )
1930 : {
1931 0 : WriteTab( rOutStm, nTab +1 );
1932 0 : for( sal_uLong n = 0; n < aEnumValueList.size(); n++ )
1933 : {
1934 0 : aEnumValueList[n]->Write( rBase, rOutStm, nTab +1, nT, nA );
1935 :
1936 0 : if( n + 1 != aEnumValueList.size() )
1937 : {
1938 0 : if( 2 == n % 3 )
1939 : {
1940 0 : rOutStm << ',' << endl;
1941 0 : WriteTab( rOutStm, nTab +1 );
1942 : }
1943 : else
1944 0 : rOutStm << ",\t";
1945 : }
1946 : else
1947 0 : rOutStm << endl;
1948 : }
1949 0 : rOutStm << endl;
1950 0 : }
1951 :
1952 193 : SV_IMPL_META_FACTORY1( SvMetaTypevoid, SvMetaType );
1953 8 : SvMetaTypevoid::SvMetaTypevoid()
1954 8 : : SvMetaType( "void", "SbxVOID", "void", 'v', "void", "", "" )
1955 : {
1956 8 : }
1957 :
1958 0 : void SvMetaTypevoid::Load( SvPersistStream & rStm )
1959 : {
1960 0 : SvMetaType::Load( rStm );
1961 0 : }
1962 :
1963 8 : void SvMetaTypevoid::Save( SvPersistStream & rStm )
1964 : {
1965 8 : SvMetaType::Save( rStm );
1966 8 : }
1967 :
1968 0 : rtl::OString SvMetaAttribute::Compare( SvMetaAttribute* pAttr )
1969 : {
1970 0 : rtl::OStringBuffer aStr;
1971 :
1972 0 : if ( aType.Is() )
1973 : {
1974 0 : if ( aType->GetType() == TYPE_METHOD )
1975 : {
1976 : // Test only when the attribute is a method not if it has one!
1977 0 : if ( !pAttr->GetType()->GetType() == TYPE_METHOD )
1978 0 : aStr.append(" IsMethod\n");
1979 0 : else if ( aType->GetReturnType() &&
1980 0 : aType->GetReturnType()->GetType() != pAttr->GetType()->GetReturnType()->GetType() )
1981 : {
1982 0 : aStr.append(" ReturnType\n");
1983 : }
1984 :
1985 0 : if ( aType->GetAttrCount() )
1986 : {
1987 0 : sal_uLong nCount = aType->GetAttrCount();
1988 0 : SvMetaAttributeMemberList& rList = aType->GetAttrList();
1989 0 : SvMetaAttributeMemberList& rOtherList = pAttr->GetType()->GetAttrList();
1990 0 : if ( pAttr->GetType()->GetAttrCount() != nCount )
1991 : {
1992 0 : aStr.append(" AttributeCount\n");
1993 : }
1994 : else
1995 : {
1996 0 : for ( sal_uInt16 n=0; n<nCount; n++ )
1997 : {
1998 0 : SvMetaAttribute *pAttr1 = rList[n];
1999 0 : SvMetaAttribute *pAttr2 = rOtherList[n];
2000 0 : pAttr1->Compare( pAttr2 );
2001 : }
2002 : }
2003 : }
2004 : }
2005 :
2006 0 : if ( GetType()->GetType() != pAttr->GetType()->GetType() )
2007 0 : aStr.append(" Type\n");
2008 :
2009 0 : if ( !GetType()->GetSvName().equals( pAttr->GetType()->GetSvName() ) )
2010 0 : aStr.append(" ItemType\n");
2011 : }
2012 :
2013 0 : if ( GetExport() != pAttr->GetExport() )
2014 0 : aStr.append(" Export\n");
2015 :
2016 0 : if ( GetAutomation() != pAttr->GetAutomation() )
2017 0 : aStr.append(" Automation\n");
2018 :
2019 0 : if ( GetIsCollection() != pAttr->GetIsCollection() )
2020 0 : aStr.append(" IsCollection\n");
2021 :
2022 0 : if ( GetReadOnlyDoc() != pAttr->GetReadOnlyDoc() )
2023 0 : aStr.append(" ReadOnlyDoc\n");
2024 :
2025 0 : if ( GetExport() && GetReadonly() != pAttr->GetReadonly() )
2026 0 : aStr.append(" Readonly\n");
2027 :
2028 0 : return aStr.makeStringAndClear();
2029 : }
2030 :
2031 0 : void SvMetaAttribute::WriteCSV( SvIdlDataBase&, SvStream& rStrm )
2032 : {
2033 0 : rStrm << GetType()->GetSvName().getStr() << ' ';
2034 0 : rStrm << GetName().getString().getStr() << ' ';
2035 0 : rStrm << GetSlotId().getString().getStr();
2036 0 : }
2037 :
2038 :
2039 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|