1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
23 #include <rtl/strbuf.hxx>
24 #include <osl/diagnose.h>
25 #include <tools/debug.hxx>
27 #include <globals.hxx>
28 #include <database.hxx>
30 TYPEINIT1( SvMetaSlot
, SvMetaAttribute
);
32 SvMetaObject
*SvMetaSlot::MakeClone() const
34 return new SvMetaSlot( *this );
37 SvMetaSlot::SvMetaSlot()
38 : aCachable( true, false )
39 , aSynchron( true, false )
40 , aRecordPerSet( true, false )
41 , aRecordAbsolute( false, false )
49 SvMetaSlot::SvMetaSlot( SvMetaType
* pType
)
50 : SvMetaAttribute( pType
)
51 , aCachable( true, false )
52 , aSynchron( true, false )
53 , aRecordPerSet( true, false )
54 , aRecordAbsolute( false, false )
62 bool SvMetaSlot::IsVariable() const
64 return SvMetaAttribute::IsVariable();
67 bool SvMetaSlot::IsMethod() const
69 bool b
= SvMetaAttribute::IsMethod();
70 b
|= NULL
!= GetMethod();
74 OString
SvMetaSlot::GetMangleName( bool bVariable
) const
78 SvMetaAttribute
* pMeth
= GetMethod();
80 return pMeth
->GetName().getString();
82 return GetName().getString();
85 /*************************************************************************
88 |* description Second FALSE in the SvBOOL-Objects means
89 |* IsSet() provides FALSE (default initialization).
90 *************************************************************************/
91 /** reference disbandment **/
92 SvMetaType
* SvMetaSlot::GetSlotType() const
94 if( aSlotType
.Is() || !GetRef() ) return aSlotType
;
95 return static_cast<SvMetaSlot
*>(GetRef())->GetSlotType();
97 SvMetaAttribute
* SvMetaSlot::GetMethod() const
99 if( aMethod
.Is() || !GetRef() ) return aMethod
;
100 return static_cast<SvMetaSlot
*>(GetRef())->GetMethod();
102 bool SvMetaSlot::GetHasCoreId() const
104 if( aHasCoreId
.IsSet() || !GetRef() ) return aHasCoreId
;
105 return static_cast<SvMetaSlot
*>(GetRef())->GetHasCoreId();
107 const OString
& SvMetaSlot::GetGroupId() const
109 if( !aGroupId
.getString().isEmpty() || !GetRef() ) return aGroupId
.getString();
110 return static_cast<SvMetaSlot
*>(GetRef())->GetGroupId();
112 const OString
& SvMetaSlot::GetDisableFlags() const
114 if( !aDisableFlags
.getString().isEmpty() || !GetRef() ) return aDisableFlags
.getString();
115 return static_cast<SvMetaSlot
*>(GetRef())->GetDisableFlags();
117 const OString
& SvMetaSlot::GetConfigId() const
119 if( !aConfigId
.getString().isEmpty() || !GetRef() ) return aConfigId
.getString();
120 return static_cast<SvMetaSlot
*>(GetRef())->GetConfigId();
122 const OString
& SvMetaSlot::GetExecMethod() const
124 if( !aExecMethod
.getString().isEmpty() || !GetRef() ) return aExecMethod
.getString();
125 return static_cast<SvMetaSlot
*>(GetRef())->GetExecMethod();
127 const OString
& SvMetaSlot::GetStateMethod() const
129 if( !aStateMethod
.getString().isEmpty() || !GetRef() ) return aStateMethod
.getString();
130 return static_cast<SvMetaSlot
*>(GetRef())->GetStateMethod();
132 const OString
& SvMetaSlot::GetDefault() const
134 if( !aDefault
.getString().isEmpty() || !GetRef() ) return aDefault
.getString();
135 return static_cast<SvMetaSlot
*>(GetRef())->GetDefault();
137 bool SvMetaSlot::GetPseudoSlots() const
139 if( aPseudoSlots
.IsSet() || !GetRef() ) return aPseudoSlots
;
140 return static_cast<SvMetaSlot
*>(GetRef())->GetPseudoSlots();
142 bool SvMetaSlot::GetCachable() const
144 // Cachable and Volatile are exclusive
145 if( !GetRef() || aCachable
.IsSet() || aVolatile
.IsSet() )
147 return static_cast<SvMetaSlot
*>(GetRef())->GetCachable();
149 bool SvMetaSlot::GetVolatile() const
151 // Cachable and Volatile are exclusive
152 if( !GetRef() || aVolatile
.IsSet() || aCachable
.IsSet() )
154 return static_cast<SvMetaSlot
*>(GetRef())->GetVolatile();
156 bool SvMetaSlot::GetToggle() const
158 if( aToggle
.IsSet() || !GetRef() ) return aToggle
;
159 return static_cast<SvMetaSlot
*>(GetRef())->GetToggle();
161 bool SvMetaSlot::GetAutoUpdate() const
163 if( aAutoUpdate
.IsSet() || !GetRef() ) return aAutoUpdate
;
164 return static_cast<SvMetaSlot
*>(GetRef())->GetAutoUpdate();
166 bool SvMetaSlot::GetSynchron() const
168 // Synchron and Asynchron are exclusive
169 if( !GetRef() || aSynchron
.IsSet() || aAsynchron
.IsSet() )
171 return static_cast<SvMetaSlot
*>(GetRef())->GetSynchron();
173 bool SvMetaSlot::GetAsynchron() const
175 // Synchron and Asynchron are exclusive
176 if( !GetRef() || aAsynchron
.IsSet() || aSynchron
.IsSet() )
178 return static_cast<SvMetaSlot
*>(GetRef())->GetAsynchron();
180 bool SvMetaSlot::GetRecordPerItem() const
182 // Record- PerItem, No, PerSet and Manual are exclusive
183 if( !GetRef() || aRecordPerItem
.IsSet() || aNoRecord
.IsSet()
184 || aRecordPerSet
.IsSet() || aRecordManual
.IsSet() )
185 return aRecordPerItem
;
186 return static_cast<SvMetaSlot
*>(GetRef())->GetRecordPerItem();
188 bool SvMetaSlot::GetRecordPerSet() const
190 // Record- PerItem, No, PerSet and Manual are exclusive
191 if( !GetRef() || aRecordPerItem
.IsSet() || aNoRecord
.IsSet()
192 || aRecordPerSet
.IsSet() || aRecordManual
.IsSet() )
193 return aRecordPerSet
;
194 return static_cast<SvMetaSlot
*>(GetRef())->GetRecordPerSet();
196 bool SvMetaSlot::GetRecordManual() const
198 // Record- PerItem, No, PerSet and Manual are exclusive
199 if( !GetRef() || aRecordPerItem
.IsSet() || aNoRecord
.IsSet()
200 || aRecordPerSet
.IsSet() || aRecordManual
.IsSet() )
201 return aRecordManual
;
202 return static_cast<SvMetaSlot
*>(GetRef())->GetRecordManual();
204 bool SvMetaSlot::GetNoRecord() const
206 // Record- PerItem, No, PerSet and Manual are exclusive
207 if( !GetRef() || aRecordPerItem
.IsSet() || aNoRecord
.IsSet()
208 || aRecordPerSet
.IsSet() || aRecordManual
.IsSet() )
210 return static_cast<SvMetaSlot
*>(GetRef())->GetNoRecord();
212 bool SvMetaSlot::GetRecordAbsolute() const
214 if( !GetRef() || aRecordAbsolute
.IsSet() )
215 return aRecordAbsolute
;
216 return static_cast<SvMetaSlot
*>(GetRef())->GetRecordAbsolute();
218 bool SvMetaSlot::GetHasDialog() const
220 if( aHasDialog
.IsSet() || !GetRef() ) return aHasDialog
;
221 return static_cast<SvMetaSlot
*>(GetRef())->GetHasDialog();
223 const OString
& SvMetaSlot::GetPseudoPrefix() const
225 if( !aPseudoPrefix
.getString().isEmpty() || !GetRef() ) return aPseudoPrefix
.getString();
226 return static_cast<SvMetaSlot
*>(GetRef())->GetPseudoPrefix();
228 bool SvMetaSlot::GetMenuConfig() const
230 if( aMenuConfig
.IsSet() || !GetRef() ) return aMenuConfig
;
231 return static_cast<SvMetaSlot
*>(GetRef())->GetMenuConfig();
233 bool SvMetaSlot::GetToolBoxConfig() const
235 if( aToolBoxConfig
.IsSet() || !GetRef() ) return aToolBoxConfig
;
236 return static_cast<SvMetaSlot
*>(GetRef())->GetToolBoxConfig();
238 bool SvMetaSlot::GetStatusBarConfig() const
240 if( aStatusBarConfig
.IsSet() || !GetRef() ) return aStatusBarConfig
;
241 return static_cast<SvMetaSlot
*>(GetRef())->GetStatusBarConfig();
243 bool SvMetaSlot::GetAccelConfig() const
245 if( aAccelConfig
.IsSet() || !GetRef() ) return aAccelConfig
;
246 return static_cast<SvMetaSlot
*>(GetRef())->GetAccelConfig();
248 bool SvMetaSlot::GetFastCall() const
250 if( aFastCall
.IsSet() || !GetRef() ) return aFastCall
;
251 return static_cast<SvMetaSlot
*>(GetRef())->GetFastCall();
253 bool SvMetaSlot::GetContainer() const
255 if( aContainer
.IsSet() || !GetRef() ) return aContainer
;
256 return static_cast<SvMetaSlot
*>(GetRef())->GetContainer();
259 bool SvMetaSlot::GetImageRotation() const
261 if( aImageRotation
.IsSet() || !GetRef() ) return aImageRotation
;
262 return static_cast<SvMetaSlot
*>(GetRef())->GetImageRotation();
265 bool SvMetaSlot::GetImageReflection() const
267 if( aImageReflection
.IsSet() || !GetRef() ) return aImageReflection
;
268 return static_cast<SvMetaSlot
*>(GetRef())->GetImageReflection();
271 const OString
& SvMetaSlot::GetUnoName() const
273 if( aUnoName
.IsSet() || !GetRef() ) return aUnoName
.getString();
274 return static_cast<SvMetaSlot
*>(GetRef())->GetUnoName();
277 void SvMetaSlot::ReadAttributesSvIdl( SvIdlDataBase
& rBase
,
278 SvTokenStream
& rInStm
)
280 SvMetaAttribute::ReadAttributesSvIdl( rBase
, rInStm
);
283 bOk
|= aDefault
.ReadSvIdl( SvHash_Default(), rInStm
);
284 bOk
|= aPseudoSlots
.ReadSvIdl( SvHash_PseudoSlots(), rInStm
);
285 bOk
|= aHasCoreId
.ReadSvIdl( SvHash_HasCoreId(), rInStm
);
286 bOk
|= aGroupId
.ReadSvIdl( SvHash_GroupId(), rInStm
);
287 bOk
|= aExecMethod
.ReadSvIdl( SvHash_ExecMethod(), rInStm
);
288 bOk
|= aStateMethod
.ReadSvIdl( SvHash_StateMethod(), rInStm
);
289 bOk
|= aDisableFlags
.ReadSvIdl( SvHash_DisableFlags(), rInStm
);
290 if( aGet
.ReadSvIdl( SvHash_Get(), rInStm
) )
292 SvIdlDataBase::WriteError( "warning", OUStringToOString(rInStm
.GetFileName(), RTL_TEXTENCODING_UTF8
),
293 "<Get> old style, use Readonly",
294 rInStm
.GetToken()->GetLine(),
295 rInStm
.GetToken()->GetColumn() );
297 if( aSet
.ReadSvIdl( SvHash_Set(), rInStm
) )
299 SvIdlDataBase::WriteError( "warning", OUStringToOString(rInStm
.GetFileName(), RTL_TEXTENCODING_UTF8
),
300 "<Set> old style, use method declaration",
301 rInStm
.GetToken()->GetLine(),
302 rInStm
.GetToken()->GetColumn() );
305 if( aCachable
.ReadSvIdl( SvHash_Cachable(), rInStm
) )
306 SetCachable( aCachable
), bOk
= true;
307 if( aVolatile
.ReadSvIdl( SvHash_Volatile(), rInStm
) )
308 SetVolatile( aVolatile
), bOk
= true;
309 if( aToggle
.ReadSvIdl( SvHash_Toggle(), rInStm
) )
310 SetToggle( aToggle
), bOk
= true;
311 if( aAutoUpdate
.ReadSvIdl( SvHash_AutoUpdate(), rInStm
) )
312 SetAutoUpdate( aAutoUpdate
), bOk
= true;
314 if( aSynchron
.ReadSvIdl( SvHash_Synchron(), rInStm
) )
315 SetSynchron( aSynchron
), bOk
= true;
316 if( aAsynchron
.ReadSvIdl( SvHash_Asynchron(), rInStm
) )
317 SetAsynchron( aAsynchron
), bOk
= true;
319 if( aRecordAbsolute
.ReadSvIdl( SvHash_RecordAbsolute(), rInStm
) )
320 SetRecordAbsolute( aRecordAbsolute
), bOk
= true;
321 if( aRecordPerItem
.ReadSvIdl( SvHash_RecordPerItem(), rInStm
) )
322 SetRecordPerItem( aRecordPerItem
), bOk
= true;
323 if( aRecordPerSet
.ReadSvIdl( SvHash_RecordPerSet(), rInStm
) )
324 SetRecordPerSet( aRecordPerSet
), bOk
= true;
325 if( aRecordManual
.ReadSvIdl( SvHash_RecordManual(), rInStm
) )
326 SetRecordManual( aRecordManual
), bOk
= true;
327 if( aNoRecord
.ReadSvIdl( SvHash_NoRecord(), rInStm
) )
328 SetNoRecord( aNoRecord
), bOk
= true;
330 bOk
|= aHasDialog
.ReadSvIdl( SvHash_HasDialog(), rInStm
);
331 bOk
|= aPseudoPrefix
.ReadSvIdl( SvHash_PseudoPrefix(), rInStm
);
332 bOk
|= aMenuConfig
.ReadSvIdl( SvHash_MenuConfig(), rInStm
);
333 bOk
|= aToolBoxConfig
.ReadSvIdl( SvHash_ToolBoxConfig(), rInStm
);
334 bOk
|= aStatusBarConfig
.ReadSvIdl( SvHash_StatusBarConfig(), rInStm
);
335 bOk
|= aAccelConfig
.ReadSvIdl( SvHash_AccelConfig(), rInStm
);
338 if( aAllConfig
.ReadSvIdl( SvHash_AllConfig(), rInStm
) )
339 SetAllConfig( aAllConfig
), bOk
= true;
340 bOk
|= aFastCall
.ReadSvIdl( SvHash_FastCall(), rInStm
);
341 bOk
|= aContainer
.ReadSvIdl( SvHash_Container(), rInStm
);
342 bOk
|= aImageRotation
.ReadSvIdl( SvHash_ImageRotation(), rInStm
);
343 bOk
|= aImageReflection
.ReadSvIdl( SvHash_ImageReflection(), rInStm
);
344 bOk
|= aUnoName
.ReadSvIdl( SvHash_UnoName(), rInStm
);
348 if( !aSlotType
.Is() )
350 sal_uInt32 nTokPos
= rInStm
.Tell();
351 SvToken
* pTok
= rInStm
.GetToken_Next();
352 if( pTok
->Is( SvHash_SlotType() ) )
354 bool bBraket
= rInStm
.Read( '(' );
355 if( bBraket
|| rInStm
.Read( '=' ) )
357 aSlotType
= rBase
.ReadKnownType( rInStm
);
360 if( aSlotType
->IsItem() )
364 if( rInStm
.Read( ')' ) )
370 rBase
.SetError( "the SlotType is not a item", rInStm
.GetToken() );
371 rBase
.WriteError( rInStm
);
373 rBase
.SetError( "SlotType with unknown item type", rInStm
.GetToken() );
374 rBase
.WriteError( rInStm
);
377 rInStm
.Seek( nTokPos
);
382 SvToken
* pTok
= rInStm
.GetToken();
383 if( pTok
->IsIdentifier() )
385 aMethod
= new SvMetaSlot();
386 sal_uInt32 nTokPos
= rInStm
.Tell();
387 if( aMethod
->ReadSvIdl( rBase
, rInStm
) )
389 if( aMethod
->IsMethod() )
391 aMethod
->SetSlotId( GetSlotId() );
392 if( aMethod
->Test( rBase
, rInStm
) )
395 rInStm
.Seek( nTokPos
);
403 bool SvMetaSlot::Test( SvIdlDataBase
& rBase
, SvTokenStream
& rInStm
)
405 bool bOk
= SvMetaAttribute::Test( rBase
, rInStm
);
408 SvMetaType
* pType
= GetType();
409 if( pType
->GetType() == TYPE_METHOD
)
410 pType
= pType
->GetReturnType();
411 if( !pType
->IsItem() )
413 rBase
.SetError( "this attribute is not a slot", rInStm
.GetToken() );
414 rBase
.WriteError( rInStm
);
422 bool SvMetaSlot::ReadSvIdl( SvIdlDataBase
& rBase
, SvTokenStream
& rInStm
)
424 sal_uInt32 nTokPos
= rInStm
.Tell();
427 SvMetaAttribute
* pAttr
= rBase
.ReadKnownAttr( rInStm
, GetType() );
431 SvMetaSlot
* pKnownSlot
= PTR_CAST( SvMetaSlot
, pAttr
);
434 SetRef( pKnownSlot
);
435 SetName( pKnownSlot
->GetName().getString(), &rBase
);
436 bOk
= SvMetaName::ReadSvIdl( rBase
, rInStm
);
440 OStringBuffer
aStr( "attribute " );
441 aStr
.append(pAttr
->GetName().getString());
442 aStr
.append(" is method or variable but not a slot");
443 rBase
.SetError( aStr
.makeStringAndClear(), rInStm
.GetToken() );
444 rBase
.WriteError( rInStm
);
450 bOk
= SvMetaAttribute::ReadSvIdl( rBase
, rInStm
);
452 SvMetaAttribute
*pAttr2
= rBase
.SearchKnownAttr( GetSlotId() );
455 // for testing purposes: reference in case of complete definition
456 SvMetaSlot
* pKnownSlot
= PTR_CAST( SvMetaSlot
, pAttr2
);
459 SetRef( pKnownSlot
);
461 // names may differ, because explicitly given
462 if ( pKnownSlot
->GetName().getString() != GetName().getString() )
464 OSL_FAIL("Illegal definition!");
465 rInStm
.Seek( nTokPos
);
469 SetName( pKnownSlot
->GetName().getString(), &rBase
);
473 OStringBuffer
aStr("attribute ");
474 aStr
.append(pAttr2
->GetName().getString());
475 aStr
.append(" is method or variable but not a slot");
476 rBase
.SetError( aStr
.makeStringAndClear(), rInStm
.GetToken() );
477 rBase
.WriteError( rInStm
);
484 rInStm
.Seek( nTokPos
);
489 void SvMetaSlot::Insert( SvSlotElementList
& rList
, const OString
& rPrefix
,
490 SvIdlDataBase
& rBase
)
492 // get insert position through binary search in slotlist
493 sal_uInt16 nId
= (sal_uInt16
) GetSlotId().GetValue();
494 sal_uInt16 nListCount
= (sal_uInt16
) rList
.size();
496 sal_uLong m
; // for inner "for" loop
500 else if ( nListCount
== 1 )
501 nPos
= rList
[ 0 ]->xSlot
->GetSlotId().GetValue() >= nId
? 0 : 1;
504 sal_uInt16 nMid
= 0, nLow
= 0;
505 sal_uInt16 nHigh
= nListCount
- 1;
507 while ( !bFound
&& nLow
<= nHigh
)
509 nMid
= (nLow
+ nHigh
) >> 1;
510 DBG_ASSERT( nMid
< nListCount
, "bsearch ist buggy" );
511 int nDiff
= (int) nId
- (int) rList
[ nMid
]->xSlot
->GetSlotId().GetValue();
518 else if ( nDiff
> 0 )
528 DBG_ASSERT(!bFound
, "Duplicate SlotId!");
529 nPos
= bFound
? nMid
: nLow
;
532 DBG_ASSERT( nPos
<= nListCount
,
534 DBG_ASSERT( nPos
== nListCount
|| nId
<=
535 (sal_uInt16
) rList
[ nPos
]->xSlot
->GetSlotId().GetValue(),
536 "Successor has lower SlotId" );
537 DBG_ASSERT( nPos
== 0 || nId
>
538 (sal_uInt16
) rList
[ nPos
-1 ]->xSlot
->GetSlotId().GetValue(),
539 "Predecessor has higher SlotId" );
540 DBG_ASSERT( nPos
+1 >= nListCount
|| nId
<
541 (sal_uInt16
) rList
[ nPos
+1 ]->xSlot
->GetSlotId().GetValue(),
542 "Successor has lower SlotId" );
544 if ( nPos
< rList
.size() )
546 SvSlotElementList::iterator it
= rList
.begin();
547 std::advance( it
, nPos
);
548 rList
.insert( it
, new SvSlotElement( this, rPrefix
) );
552 rList
.push_back( new SvSlotElement( this, rPrefix
) );
555 // iron out EnumSlots
556 SvMetaTypeEnum
* pEnum
= NULL
;
557 SvMetaType
* pBType
= GetType()->GetBaseType();
558 pEnum
= PTR_CAST( SvMetaTypeEnum
, pBType
);
559 if( GetPseudoSlots() && pEnum
&& pEnum
->Count() )
561 // clone the MasterSlot
562 SvMetaSlotRef xEnumSlot
;
563 SvMetaSlot
*pFirstEnumSlot
= NULL
;
564 for( sal_uLong n
= 0; n
< pEnum
->Count(); n
++ )
567 SvMetaEnumValue
*enumValue
= pEnum
->GetObject(n
);
568 OString aValName
= enumValue
->GetName().getString();
570 if( !GetPseudoPrefix().isEmpty() )
571 aBuf
.append(GetPseudoPrefix());
573 aBuf
.append(GetSlotId().getString());
575 aBuf
.append(aValName
.copy(pEnum
->GetPrefix().getLength()));
577 OString aSId
= aBuf
.makeStringAndClear();
580 for( m
=0; m
<rBase
.GetAttrList().size(); m
++ )
582 SvMetaAttribute
* pAttr
= rBase
.GetAttrList()[m
];
583 if (aSId
.equals(pAttr
->GetSlotId().getString()))
585 SvMetaSlot
& rSlot
= dynamic_cast<SvMetaSlot
&>(*pAttr
);
586 xEnumSlot
= rSlot
.Clone();
591 if ( m
== rBase
.GetAttrList().size() )
593 OSL_FAIL("Invalid EnumSlot!");
596 if ( rBase
.FindId(aSId
, &nValue
) )
598 SvNumberIdentifier aId
;
600 aId
.SetValue(nValue
);
601 xEnumSlot
->SetSlotId(aId
);
605 // The slaves are no master!
606 xEnumSlot
->aPseudoSlots
= false;
607 xEnumSlot
->SetEnumValue(enumValue
);
609 if ( !pFirstEnumSlot
|| xEnumSlot
->GetSlotId().GetValue() < pFirstEnumSlot
->GetSlotId().GetValue() )
610 pFirstEnumSlot
= xEnumSlot
;
612 // insert the created slave as well
613 xEnumSlot
->Insert( rList
, rPrefix
, rBase
);
615 // concatenate the EnumSlots with the master
616 xEnumSlot
->pLinkedSlot
= this;
619 // master points to the first slave
620 pLinkedSlot
= pFirstEnumSlot
;
622 // concatenate slaves among themselves
623 xEnumSlot
= pFirstEnumSlot
;
628 pEle
= ( ++i
< rList
.size() ) ? rList
[ i
] : NULL
;
629 if ( pEle
&& pEle
->xSlot
->pLinkedSlot
== this )
631 xEnumSlot
->pNextSlot
= pEle
->xSlot
;
632 xEnumSlot
= pEle
->xSlot
;
636 xEnumSlot
->pNextSlot
= pFirstEnumSlot
;
641 static OString
MakeSlotName( SvStringHashEntry
* pEntry
)
643 OStringBuffer
aName("SfxSlotMode::");
644 aName
.append(pEntry
->GetName().toAsciiUpperCase());
645 return aName
.makeStringAndClear();
648 void SvMetaSlot::WriteSlotStubs( const OString
& rShellName
,
649 ByteStringList
& rList
,
652 if ( !GetExport() && !GetHidden() )
655 OString
aMethodName( GetExecMethod() );
656 if ( !aMethodName
.isEmpty() &&
657 aMethodName
!= "NoExec" )
660 for( size_t n
= 0; n
< rList
.size(); n
++ )
662 if (rList
[n
]->equals(aMethodName
))
671 rList
.push_back( new OString(aMethodName
) );
672 rOutStm
.WriteCharPtr( "SFX_EXEC_STUB(" )
673 .WriteCharPtr( rShellName
.getStr() )
675 .WriteCharPtr( aMethodName
.getStr() )
676 .WriteChar( ')' ) << endl
;
680 aMethodName
= GetStateMethod();
681 if (!aMethodName
.isEmpty() &&
682 aMethodName
!= "NoState")
685 for ( size_t n
=0; n
< rList
.size(); n
++ )
687 if (rList
[n
]->equals(aMethodName
))
696 rList
.push_back( new OString(aMethodName
) );
697 rOutStm
.WriteCharPtr( "SFX_STATE_STUB(" )
698 .WriteCharPtr( rShellName
.getStr() )
700 .WriteCharPtr( aMethodName
.getStr() )
701 .WriteChar( ')' ) << endl
;
706 void SvMetaSlot::WriteSlot( const OString
& rShellName
, sal_uInt16 nCount
,
707 const OString
& rSlotId
,
708 SvSlotElementList
& rSlotList
,
710 SvIdlDataBase
& rBase
, SvStream
& rOutStm
)
712 if ( !GetExport() && !GetHidden() )
715 bool bIsEnumSlot
= 0 != pEnumValue
;
717 rOutStm
.WriteCharPtr( "// Slot Nr. " )
718 .WriteCharPtr( OString::number(nListPos
).getStr() )
719 .WriteCharPtr( " : " );
720 OString
aSlotIdValue(OString::number(GetSlotId().GetValue()));
721 rOutStm
.WriteCharPtr( aSlotIdValue
.getStr() ) << endl
;
722 WriteTab( rOutStm
, 1 );
724 rOutStm
.WriteCharPtr( "SFX_NEW_SLOT_ENUM( " );
726 rOutStm
.WriteCharPtr( "SFX_NEW_SLOT_ARG( " ).WriteCharPtr( rShellName
.getStr() ).WriteChar( ',' ) ;
728 rOutStm
.WriteCharPtr( rSlotId
.getStr() ).WriteChar( ',' );
729 const SvHelpContext
& rHlpCtx
= GetHelpContext();
730 if( rHlpCtx
.IsSet() )
731 rOutStm
.WriteCharPtr( rHlpCtx
.getString().getStr() ).WriteChar( ',' );
733 rOutStm
.WriteCharPtr( rSlotId
.getStr() ).WriteChar( ',' );
736 if( !GetGroupId().isEmpty() )
737 rOutStm
.WriteCharPtr( GetGroupId().getStr() );
739 rOutStm
.WriteChar( '0' );
740 rOutStm
.WriteChar( ',' ) << endl
;
741 WriteTab( rOutStm
, 4 );
745 rOutStm
.WriteCharPtr( "&a" ).WriteCharPtr( rShellName
.getStr() ).WriteCharPtr( "Slots_Impl[" )
746 .WriteCharPtr( OString::number(pLinkedSlot
->GetListPos()).getStr() )
747 .WriteCharPtr( "] /*Offset Master*/, " ) << endl
;
748 WriteTab( rOutStm
, 4 );
749 rOutStm
.WriteCharPtr( "&a" ).WriteCharPtr( rShellName
.getStr() ).WriteCharPtr( "Slots_Impl[" )
750 .WriteCharPtr( OString::number(pNextSlot
->GetListPos()).getStr() )
751 .WriteCharPtr( "] /*Offset Next*/, " ) << endl
;
753 WriteTab( rOutStm
, 4 );
756 if( !GetSlotId().getString().isEmpty() )
757 rOutStm
.WriteCharPtr( pLinkedSlot
->GetSlotId().getString().getStr() );
759 rOutStm
.WriteChar( '0' );
760 rOutStm
.WriteChar( ',' );
761 rOutStm
.WriteCharPtr( pEnumValue
->GetName().getString().getStr() );
765 // look for the next slot with the same StateMethod like me
766 // the slotlist is set to the current slot
768 SvSlotElement
* pEle
= ( ++i
< rSlotList
.size() ) ? rSlotList
[ i
] : NULL
;
769 pNextSlot
= pEle
? &pEle
->xSlot
: NULL
;
772 if ( !pNextSlot
->pNextSlot
&&
773 pNextSlot
->GetStateMethod() == GetStateMethod()
777 pEle
= ( ++i
< rSlotList
.size() ) ? rSlotList
[ i
] : NULL
;
778 pNextSlot
= pEle
? &pEle
->xSlot
: NULL
;
783 // There is no slot behind me that has the same ExecMethod.
784 // So I search for the first slot with it (could be myself).
786 pEle
= rSlotList
.empty() ? NULL
: rSlotList
[ i
];
787 pNextSlot
= pEle
? &pEle
->xSlot
: NULL
;
788 while ( pNextSlot
!= this )
790 if ( !pNextSlot
->pEnumValue
&&
791 pNextSlot
->GetStateMethod() == GetStateMethod() )
793 pEle
= ( ++i
< rSlotList
.size() ) ? rSlotList
[ i
] : NULL
;
794 pNextSlot
= pEle
? &pEle
->xSlot
: NULL
;
800 rOutStm
.WriteCharPtr( "0 ," );
804 rOutStm
.WriteCharPtr( "&a" ).WriteCharPtr( rShellName
.getStr() ).WriteCharPtr( "Slots_Impl[" )
805 .WriteCharPtr( OString::number(pLinkedSlot
->GetListPos()).getStr() )
806 .WriteCharPtr( "] /*Offset Linked*/, " ) << endl
;
807 WriteTab( rOutStm
, 4 );
810 rOutStm
.WriteCharPtr( "&a" ).WriteCharPtr( rShellName
.getStr() ).WriteCharPtr( "Slots_Impl[" )
811 .WriteCharPtr( OString::number(pNextSlot
->GetListPos()).getStr() )
812 .WriteCharPtr( "] /*Offset Next*/, " ) << endl
;
814 WriteTab( rOutStm
, 4 );
816 // write ExecMethod, with standard name if not specified
817 if( !GetExecMethod().isEmpty() &&
818 GetExecMethod() != "NoExec")
820 rOutStm
.WriteCharPtr( "SFX_STUB_PTR(" ).WriteCharPtr( rShellName
.getStr() ).WriteChar( ',' )
821 .WriteCharPtr( GetExecMethod().getStr() ).WriteChar( ')' );
824 rOutStm
.WriteCharPtr( "SFX_STUB_PTR_EXEC_NONE" );
825 rOutStm
.WriteChar( ',' );
827 // write StateMethod, with standard name if not specified
828 if( !GetStateMethod().isEmpty() &&
829 GetStateMethod() != "NoState")
831 rOutStm
.WriteCharPtr( "SFX_STUB_PTR(" ).WriteCharPtr( rShellName
.getStr() ).WriteChar( ',' )
832 .WriteCharPtr( GetStateMethod().getStr() ).WriteChar( ')' );
835 rOutStm
.WriteCharPtr( "SFX_STUB_PTR_STATE_NONE" );
837 rOutStm
.WriteChar( ',' ) << endl
;
838 WriteTab( rOutStm
, 4 );
842 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_HasCoreId() ).getStr() ).WriteChar( '|' );
844 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_Cachable() ).getStr() ).WriteChar( '|' );
846 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_Volatile() ).getStr() ).WriteChar( '|' );
848 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_Toggle() ).getStr() ).WriteChar( '|' );
849 if( GetAutoUpdate() )
850 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_AutoUpdate() ).getStr() ).WriteChar( '|' );
852 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_Synchron() ).getStr() ).WriteChar( '|' );
854 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_Asynchron() ).getStr() ).WriteChar( '|' );
855 if( GetRecordPerItem() )
856 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_RecordPerItem() ).getStr() ).WriteChar( '|' );
857 if( GetRecordPerSet() )
858 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_RecordPerSet() ).getStr() ).WriteChar( '|' );
859 if( GetRecordManual() )
860 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_RecordManual() ).getStr() ).WriteChar( '|' );
862 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_NoRecord() ).getStr() ).WriteChar( '|' );
863 if( GetRecordAbsolute() )
864 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_RecordAbsolute() ).getStr() ).WriteChar( '|' );
866 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_HasDialog() ).getStr() ).WriteChar( '|' );
867 if( GetMenuConfig() )
868 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_MenuConfig() ).getStr() ).WriteChar( '|' );
869 if( GetToolBoxConfig() )
870 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_ToolBoxConfig() ).getStr() ).WriteChar( '|' );
871 if( GetStatusBarConfig() )
872 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_StatusBarConfig() ).getStr() ).WriteChar( '|' );
873 if( GetAccelConfig() )
874 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_AccelConfig() ).getStr() ).WriteChar( '|' );
876 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_FastCall() ).getStr() ).WriteChar( '|' );
878 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_Container() ).getStr() ).WriteChar( '|' );
879 if ( GetReadOnlyDoc() )
880 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_ReadOnlyDoc() ).getStr() ).WriteChar( '|' );
881 if( GetImageRotation() )
882 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_ImageRotation() ).getStr() ).WriteChar( '|' );
883 if( GetImageReflection() )
884 rOutStm
.WriteCharPtr( MakeSlotName( SvHash_ImageReflection() ).getStr() ).WriteChar( '|' );
885 rOutStm
.WriteCharPtr( "SfxSlotMode::NONE" );
887 rOutStm
.WriteChar( ',' ) << endl
;
888 WriteTab( rOutStm
, 4 );
889 if ( GetDisableFlags().isEmpty() )
890 rOutStm
.WriteCharPtr( "0" );
892 rOutStm
.WriteCharPtr( GetDisableFlags().getStr() );
894 // write attribute type
897 rOutStm
.WriteChar( ',' ) << endl
;
898 WriteTab( rOutStm
, 4 );
900 SvMetaType
* pT
= GetSlotType();
904 pT
= rBase
.FindType( "SfxVoidItem" );
910 rOutStm
.WriteCharPtr( pT
->GetName().getString().getStr() );
911 if( !SvIdlDataBase::FindType( pT
, rBase
.aUsedTypes
) )
912 rBase
.aUsedTypes
.push_back( pT
);
915 rOutStm
.WriteCharPtr( "SfxVoidItem not defined" );
919 SvMetaType
*pT
= rBase
.FindType( "SfxBoolItem" );
920 if ( pT
&& !SvIdlDataBase::FindType( pT
, rBase
.aUsedTypes
) )
921 rBase
.aUsedTypes
.push_back( pT
);
926 rOutStm
.WriteChar( ',' ) << endl
;
927 WriteTab( rOutStm
, 4 );
929 .WriteCharPtr( OString::number(nCount
).getStr() )
930 .WriteCharPtr( "/*Offset*/, " );
934 SvMetaAttribute
* pMethod
= GetMethod();
937 pType
= pMethod
->GetType();
940 sal_uLong nSCount
= pType
->GetAttrCount();
942 .WriteCharPtr( OString::number(nSCount
).getStr() )
943 .WriteCharPtr( "/*Count*/," );
946 rOutStm
.WriteCharPtr( "0," );
948 rOutStm
.WriteCharPtr( " " );
950 // Method/Property flags
952 rOutStm
.WriteCharPtr( "SfxSlotMode::METHOD|" );
955 rOutStm
.WriteCharPtr( "SfxSlotMode::PROPGET|" );
957 rOutStm
.WriteCharPtr( "SfxSlotMode::PROPSET|" );
960 rOutStm
.WriteCharPtr( "SfxSlotMode::NONE" );
964 rOutStm
.WriteCharPtr( ",\"" );
965 rOutStm
.WriteCharPtr( GetMangleName( false ).getStr() );
966 rOutStm
.WriteCharPtr( "\"" );
969 rOutStm
.WriteCharPtr( " )," ) << endl
;
972 sal_uInt16
SvMetaSlot::WriteSlotParamArray( SvIdlDataBase
& rBase
, SvStream
& rOutStm
)
974 if ( !GetExport() && !GetHidden() )
977 SvMetaAttribute
* pMethod
= GetMethod();
982 pType
= pMethod
->GetType();
986 if( !SvIdlDataBase::FindType( pType
, rBase
.aUsedTypes
) )
987 rBase
.aUsedTypes
.push_back( pType
);
989 const SvMetaAttributeMemberList
& rList
=
990 pType
->GetAttrList();
991 for( sal_uLong n
= 0; n
< rList
.size(); n
++ )
993 SvMetaAttribute
* pPar
= rList
[n
];
994 SvMetaType
* pPType
= pPar
->GetType();
995 WriteTab( rOutStm
, 1 );
996 rOutStm
.WriteCharPtr("{ (const SfxType*) &a")
998 .WriteCharPtr(pPType
->GetName().getString().getStr()).WriteCharPtr("_Impl, ")
1000 .WriteCharPtr("\"").WriteCharPtr(pPar
->GetName().getString().getStr()).WriteCharPtr("\", ")
1002 .WriteCharPtr(pPar
->GetSlotId().getString().getStr()).WriteCharPtr(" },") << endl
;
1003 if( !SvIdlDataBase::FindType( pPType
, rBase
.aUsedTypes
) )
1004 rBase
.aUsedTypes
.push_back( pPType
);
1006 return (sal_uInt16
)rList
.size();
1011 sal_uInt16
SvMetaSlot::WriteSlotMap( const OString
& rShellName
, sal_uInt16 nCount
,
1012 SvSlotElementList
& rSlotList
,
1014 SvIdlDataBase
& rBase
,
1015 SvStream
& rOutStm
)
1017 // SlotId, if not specified generate from name
1018 OString slotId
= GetSlotId().getString();
1020 sal_uInt16 nSCount
= 0;
1024 SvMetaAttribute
* pMethod
= GetMethod();
1026 pType
= pMethod
->GetType();
1030 nSCount
= (sal_uInt16
)pType
->GetAttrCount();
1033 WriteSlot( rShellName
, nCount
, slotId
, rSlotList
, nStart
, rBase
, rOutStm
);
1037 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */