1*89b56da7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*89b56da7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*89b56da7SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*89b56da7SAndrew Rist * distributed with this work for additional information
6*89b56da7SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*89b56da7SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*89b56da7SAndrew Rist * "License"); you may not use this file except in compliance
9*89b56da7SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*89b56da7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*89b56da7SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*89b56da7SAndrew Rist * software distributed under the License is distributed on an
15*89b56da7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*89b56da7SAndrew Rist * KIND, either express or implied. See the License for the
17*89b56da7SAndrew Rist * specific language governing permissions and limitations
18*89b56da7SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*89b56da7SAndrew Rist *************************************************************/
21*89b56da7SAndrew Rist
22*89b56da7SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_tools.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <ctype.h>
28cdf0e10cSrcweir #include <stdio.h>
29cdf0e10cSrcweir #include <string.h>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <tools/stream.hxx>
32cdf0e10cSrcweir #include <tools/globname.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir /************** class ImpSvGlobalName ************************************/
ImpSvGlobalName(const ImpSvGlobalName & rObj)35cdf0e10cSrcweir ImpSvGlobalName::ImpSvGlobalName( const ImpSvGlobalName & rObj )
36cdf0e10cSrcweir {
37cdf0e10cSrcweir nRefCount = 0;
38cdf0e10cSrcweir memcpy( szData, rObj.szData, sizeof( szData ) );
39cdf0e10cSrcweir }
40cdf0e10cSrcweir
41cdf0e10cSrcweir /************** class ImpSvGlobalName ************************************/
ImpSvGlobalName(int)42cdf0e10cSrcweir ImpSvGlobalName::ImpSvGlobalName( int )
43cdf0e10cSrcweir {
44cdf0e10cSrcweir nRefCount = 1;
45cdf0e10cSrcweir memset( szData, 0, sizeof( szData ) );
46cdf0e10cSrcweir }
47cdf0e10cSrcweir
48cdf0e10cSrcweir /*************************************************************************
49cdf0e10cSrcweir |* ImpSvGlobalName::operator ==()
50cdf0e10cSrcweir *************************************************************************/
operator ==(const ImpSvGlobalName & rObj) const51cdf0e10cSrcweir sal_Bool ImpSvGlobalName::operator == ( const ImpSvGlobalName & rObj ) const
52cdf0e10cSrcweir {
53cdf0e10cSrcweir return !memcmp( szData, rObj.szData, sizeof( szData ) );
54cdf0e10cSrcweir }
55cdf0e10cSrcweir
56cdf0e10cSrcweir /*************************************************************************
57cdf0e10cSrcweir |* SvGlobalName::SvGlobalName()
58cdf0e10cSrcweir *************************************************************************/
SvGlobalName()59cdf0e10cSrcweir SvGlobalName::SvGlobalName()
60cdf0e10cSrcweir {
61cdf0e10cSrcweir static ImpSvGlobalName aNoName( 0 );
62cdf0e10cSrcweir
63cdf0e10cSrcweir pImp = &aNoName;
64cdf0e10cSrcweir pImp->nRefCount++;
65cdf0e10cSrcweir }
66cdf0e10cSrcweir
67cdf0e10cSrcweir // locker die Struktur von Windows kopiert
68cdf0e10cSrcweir #ifdef WNT
69cdf0e10cSrcweir struct _GUID
70cdf0e10cSrcweir #else
71cdf0e10cSrcweir struct GUID
72cdf0e10cSrcweir #endif
73cdf0e10cSrcweir {
74cdf0e10cSrcweir sal_uInt32 Data1;
75cdf0e10cSrcweir sal_uInt16 Data2;
76cdf0e10cSrcweir sal_uInt16 Data3;
77cdf0e10cSrcweir sal_uInt8 Data4[8];
78cdf0e10cSrcweir };
SvGlobalName(const CLSID & rId)79cdf0e10cSrcweir SvGlobalName::SvGlobalName( const CLSID & rId )
80cdf0e10cSrcweir {
81cdf0e10cSrcweir pImp = new ImpSvGlobalName();
82cdf0e10cSrcweir pImp->nRefCount++;
83cdf0e10cSrcweir memcpy( pImp->szData, &rId, sizeof( pImp->szData ) );
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
SvGlobalName(sal_uInt32 n1,sal_uInt16 n2,sal_uInt16 n3,sal_uInt8 b8,sal_uInt8 b9,sal_uInt8 b10,sal_uInt8 b11,sal_uInt8 b12,sal_uInt8 b13,sal_uInt8 b14,sal_uInt8 b15)86cdf0e10cSrcweir SvGlobalName::SvGlobalName( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
87cdf0e10cSrcweir sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11,
88cdf0e10cSrcweir sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15 )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir pImp = new ImpSvGlobalName();
91cdf0e10cSrcweir pImp->nRefCount++;
92cdf0e10cSrcweir
93cdf0e10cSrcweir *(sal_uInt32 *)pImp->szData = n1;
94cdf0e10cSrcweir *(sal_uInt16 *)&pImp->szData[ 4 ] = n2;
95cdf0e10cSrcweir *(sal_uInt16 *)&pImp->szData[ 6 ] = n3;
96cdf0e10cSrcweir pImp->szData[ 8 ] = b8;
97cdf0e10cSrcweir pImp->szData[ 9 ] = b9;
98cdf0e10cSrcweir pImp->szData[ 10 ] = b10;
99cdf0e10cSrcweir pImp->szData[ 11 ] = b11;
100cdf0e10cSrcweir pImp->szData[ 12 ] = b12;
101cdf0e10cSrcweir pImp->szData[ 13 ] = b13;
102cdf0e10cSrcweir pImp->szData[ 14 ] = b14;
103cdf0e10cSrcweir pImp->szData[ 15 ] = b15;
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
106cdf0e10cSrcweir /*************************************************************************
107cdf0e10cSrcweir |* SvGlobalName::~SvGlobalName()
108cdf0e10cSrcweir *************************************************************************/
~SvGlobalName()109cdf0e10cSrcweir SvGlobalName::~SvGlobalName()
110cdf0e10cSrcweir {
111cdf0e10cSrcweir pImp->nRefCount--;
112cdf0e10cSrcweir if( !pImp->nRefCount )
113cdf0e10cSrcweir delete pImp;
114cdf0e10cSrcweir }
115cdf0e10cSrcweir
116cdf0e10cSrcweir /*************************************************************************
117cdf0e10cSrcweir |* SvGlobalName::operator = ()
118cdf0e10cSrcweir *************************************************************************/
operator =(const SvGlobalName & rObj)119cdf0e10cSrcweir SvGlobalName & SvGlobalName::operator = ( const SvGlobalName & rObj )
120cdf0e10cSrcweir {
121cdf0e10cSrcweir rObj.pImp->nRefCount++;
122cdf0e10cSrcweir pImp->nRefCount--;
123cdf0e10cSrcweir if( !pImp->nRefCount )
124cdf0e10cSrcweir delete pImp;
125cdf0e10cSrcweir pImp = rObj.pImp;
126cdf0e10cSrcweir return *this;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir
129cdf0e10cSrcweir /*************************************************************************
130cdf0e10cSrcweir |* SvGlobalName::NewImp()
131cdf0e10cSrcweir *************************************************************************/
NewImp()132cdf0e10cSrcweir void SvGlobalName::NewImp()
133cdf0e10cSrcweir {
134cdf0e10cSrcweir if( pImp->nRefCount > 1 )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir pImp->nRefCount--;
137cdf0e10cSrcweir pImp = new ImpSvGlobalName( *pImp );
138cdf0e10cSrcweir pImp->nRefCount++;
139cdf0e10cSrcweir }
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
142cdf0e10cSrcweir /*************************************************************************
143cdf0e10cSrcweir |* SvGlobalName::operator << ()
144cdf0e10cSrcweir |* SvGlobalName::operator >> ()
145cdf0e10cSrcweir *************************************************************************/
operator <<(SvStream & rOStr,const SvGlobalName & rObj)146cdf0e10cSrcweir SvStream& operator << ( SvStream& rOStr, const SvGlobalName & rObj )
147cdf0e10cSrcweir {
148cdf0e10cSrcweir rOStr << *(sal_uInt32 *)rObj.pImp->szData;
149cdf0e10cSrcweir rOStr << *(sal_uInt16 *)&rObj.pImp->szData[ 4 ];
150cdf0e10cSrcweir rOStr << *(sal_uInt16 *)&rObj.pImp->szData[ 6 ];
151cdf0e10cSrcweir rOStr.Write( (sal_Char *)&rObj.pImp->szData[ 8 ], 8 );
152cdf0e10cSrcweir return rOStr;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir
operator >>(SvStream & rStr,SvGlobalName & rObj)155cdf0e10cSrcweir SvStream& operator >> ( SvStream& rStr, SvGlobalName & rObj )
156cdf0e10cSrcweir {
157cdf0e10cSrcweir rObj.NewImp(); // kopieren, falls noetig
158cdf0e10cSrcweir rStr >> *(sal_uInt32 *)rObj.pImp->szData;
159cdf0e10cSrcweir rStr >> *(sal_uInt16 *)&rObj.pImp->szData[ 4 ];
160cdf0e10cSrcweir rStr >> *(sal_uInt16 *)&rObj.pImp->szData[ 6 ];
161cdf0e10cSrcweir rStr.Read( (sal_Char *)&rObj.pImp->szData[ 8 ], 8 );
162cdf0e10cSrcweir return rStr;
163cdf0e10cSrcweir }
164cdf0e10cSrcweir
165cdf0e10cSrcweir
166cdf0e10cSrcweir /*************************************************************************
167cdf0e10cSrcweir |* SvGlobalName::operator < ()
168cdf0e10cSrcweir *************************************************************************/
operator <(const SvGlobalName & rObj) const169cdf0e10cSrcweir sal_Bool SvGlobalName::operator < ( const SvGlobalName & rObj ) const
170cdf0e10cSrcweir {
171cdf0e10cSrcweir int n = memcmp( pImp->szData +6, rObj.pImp->szData +6,
172cdf0e10cSrcweir sizeof( pImp->szData ) -6);
173cdf0e10cSrcweir if( n < 0 )
174cdf0e10cSrcweir return sal_True;
175cdf0e10cSrcweir else if( n > 0 )
176cdf0e10cSrcweir return sal_False;
177cdf0e10cSrcweir else if( *(sal_uInt16 *)&pImp->szData[ 4 ] < *(sal_uInt16 *)&rObj.pImp->szData[ 4 ] )
178cdf0e10cSrcweir return sal_True;
179cdf0e10cSrcweir else if( *(sal_uInt16 *)&pImp->szData[ 4 ] == *(sal_uInt16 *)&rObj.pImp->szData[ 4 ] )
180cdf0e10cSrcweir return *(sal_uInt32 *)pImp->szData < *(sal_uInt32 *)rObj.pImp->szData;
181cdf0e10cSrcweir else
182cdf0e10cSrcweir return sal_False;
183cdf0e10cSrcweir
184cdf0e10cSrcweir }
185cdf0e10cSrcweir
186cdf0e10cSrcweir /*************************************************************************
187cdf0e10cSrcweir |* SvGlobalName::operator +=()
188cdf0e10cSrcweir *************************************************************************/
operator +=(sal_uInt32 n)189cdf0e10cSrcweir SvGlobalName & SvGlobalName::operator += ( sal_uInt32 n )
190cdf0e10cSrcweir {
191cdf0e10cSrcweir NewImp();
192cdf0e10cSrcweir sal_uInt32 nOld = (*(sal_uInt32 *)pImp->szData);
193cdf0e10cSrcweir (*(sal_uInt32 *)pImp->szData) += n;
194cdf0e10cSrcweir if( nOld > *(sal_uInt32 *)pImp->szData )
195cdf0e10cSrcweir // ueberlauf
196cdf0e10cSrcweir (*(sal_uInt16 *)&pImp->szData[ 4 ])++;
197cdf0e10cSrcweir return *this;
198cdf0e10cSrcweir }
199cdf0e10cSrcweir
200cdf0e10cSrcweir /*************************************************************************
201cdf0e10cSrcweir |* SvGlobalName::operator ==()
202cdf0e10cSrcweir *************************************************************************/
operator ==(const SvGlobalName & rObj) const203cdf0e10cSrcweir sal_Bool SvGlobalName::operator == ( const SvGlobalName & rObj ) const
204cdf0e10cSrcweir {
205cdf0e10cSrcweir return *pImp == *rObj.pImp;
206cdf0e10cSrcweir }
207cdf0e10cSrcweir
MakeFromMemory(void * pData)208cdf0e10cSrcweir void SvGlobalName::MakeFromMemory( void * pData )
209cdf0e10cSrcweir {
210cdf0e10cSrcweir NewImp();
211cdf0e10cSrcweir memcpy( pImp->szData, pData, sizeof( pImp->szData ) );
212cdf0e10cSrcweir }
213cdf0e10cSrcweir
214cdf0e10cSrcweir /*************************************************************************
215cdf0e10cSrcweir |* SvGlobalName::MakeId()
216cdf0e10cSrcweir *************************************************************************/
MakeId(const String & rIdStr)217cdf0e10cSrcweir sal_Bool SvGlobalName::MakeId( const String & rIdStr )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir ByteString aStr( rIdStr, RTL_TEXTENCODING_ASCII_US );
220cdf0e10cSrcweir sal_Char * pStr = (sal_Char *)aStr.GetBuffer();
221cdf0e10cSrcweir if( rIdStr.Len() == 36
222cdf0e10cSrcweir && '-' == pStr[ 8 ] && '-' == pStr[ 13 ]
223cdf0e10cSrcweir && '-' == pStr[ 18 ] && '-' == pStr[ 23 ] )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir sal_uInt32 nFirst = 0;
226cdf0e10cSrcweir int i = 0;
227cdf0e10cSrcweir for( i = 0; i < 8; i++ )
228cdf0e10cSrcweir {
229cdf0e10cSrcweir if( isxdigit( *pStr ) )
230cdf0e10cSrcweir if( isdigit( *pStr ) )
231cdf0e10cSrcweir nFirst = nFirst * 16 + (*pStr - '0');
232cdf0e10cSrcweir else
233cdf0e10cSrcweir nFirst = nFirst * 16 + (toupper( *pStr ) - 'A' + 10 );
234cdf0e10cSrcweir else
235cdf0e10cSrcweir return sal_False;
236cdf0e10cSrcweir pStr++;
237cdf0e10cSrcweir }
238cdf0e10cSrcweir
239cdf0e10cSrcweir sal_uInt16 nSec = 0;
240cdf0e10cSrcweir pStr++;
241cdf0e10cSrcweir for( i = 0; i < 4; i++ )
242cdf0e10cSrcweir {
243cdf0e10cSrcweir if( isxdigit( *pStr ) )
244cdf0e10cSrcweir if( isdigit( *pStr ) )
245cdf0e10cSrcweir nSec = nSec * 16 + (*pStr - '0');
246cdf0e10cSrcweir else
247cdf0e10cSrcweir nSec = nSec * 16 + (sal_uInt16)(toupper( *pStr ) - 'A' + 10 );
248cdf0e10cSrcweir else
249cdf0e10cSrcweir return sal_False;
250cdf0e10cSrcweir pStr++;
251cdf0e10cSrcweir }
252cdf0e10cSrcweir
253cdf0e10cSrcweir sal_uInt16 nThird = 0;
254cdf0e10cSrcweir pStr++;
255cdf0e10cSrcweir for( i = 0; i < 4; i++ )
256cdf0e10cSrcweir {
257cdf0e10cSrcweir if( isxdigit( *pStr ) )
258cdf0e10cSrcweir if( isdigit( *pStr ) )
259cdf0e10cSrcweir nThird = nThird * 16 + (*pStr - '0');
260cdf0e10cSrcweir else
261cdf0e10cSrcweir nThird = nThird * 16 + (sal_uInt16)(toupper( *pStr ) - 'A' + 10 );
262cdf0e10cSrcweir else
263cdf0e10cSrcweir return sal_False;
264cdf0e10cSrcweir pStr++;
265cdf0e10cSrcweir }
266cdf0e10cSrcweir
267cdf0e10cSrcweir sal_Int8 szRemain[ 8 ];
268cdf0e10cSrcweir memset( szRemain, 0, sizeof( szRemain ) );
269cdf0e10cSrcweir pStr++;
270cdf0e10cSrcweir for( i = 0; i < 16; i++ )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir if( isxdigit( *pStr ) )
273cdf0e10cSrcweir if( isdigit( *pStr ) )
274cdf0e10cSrcweir szRemain[i/2] = szRemain[i/2] * 16 + (*pStr - '0');
275cdf0e10cSrcweir else
276cdf0e10cSrcweir szRemain[i/2] = szRemain[i/2] * 16 + (sal_Int8)(toupper( *pStr ) - 'A' + 10 );
277cdf0e10cSrcweir else
278cdf0e10cSrcweir return sal_False;
279cdf0e10cSrcweir pStr++;
280cdf0e10cSrcweir if( i == 3 )
281cdf0e10cSrcweir pStr++;
282cdf0e10cSrcweir }
283cdf0e10cSrcweir
284cdf0e10cSrcweir NewImp();
285cdf0e10cSrcweir *(sal_uInt32 *)pImp->szData = nFirst;
286cdf0e10cSrcweir *(sal_uInt16 *)&pImp->szData[ 4 ] = nSec;
287cdf0e10cSrcweir *(sal_uInt16 *)&pImp->szData[ 6 ] = nThird;
288cdf0e10cSrcweir memcpy( &pImp->szData[ 8 ], szRemain, 8 );
289cdf0e10cSrcweir return sal_True;
290cdf0e10cSrcweir }
291cdf0e10cSrcweir return sal_False;
292cdf0e10cSrcweir }
293cdf0e10cSrcweir
294cdf0e10cSrcweir /*************************************************************************
295cdf0e10cSrcweir |* SvGlobalName::GetctorName()
296cdf0e10cSrcweir *************************************************************************/
GetctorName() const297cdf0e10cSrcweir String SvGlobalName::GetctorName() const
298cdf0e10cSrcweir {
299cdf0e10cSrcweir ByteString aRet;
300cdf0e10cSrcweir
301cdf0e10cSrcweir sal_Char buf[ 20 ];
302cdf0e10cSrcweir sprintf( buf, "0x%8.8lX", (sal_uIntPtr)*(sal_uInt32 *)pImp->szData );
303cdf0e10cSrcweir aRet += buf;
304cdf0e10cSrcweir sal_uInt16 i;
305cdf0e10cSrcweir for( i = 4; i < 8; i += 2 )
306cdf0e10cSrcweir {
307cdf0e10cSrcweir aRet += ',';
308cdf0e10cSrcweir sprintf( buf, "0x%4.4X", *(sal_uInt16 *)&pImp->szData[ i ] );
309cdf0e10cSrcweir aRet += buf;
310cdf0e10cSrcweir }
311cdf0e10cSrcweir for( i = 8; i < 16; i++ )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir aRet += ',';
314cdf0e10cSrcweir sprintf( buf, "0x%2.2x", pImp->szData[ i ] );
315cdf0e10cSrcweir aRet += buf;
316cdf0e10cSrcweir }
317cdf0e10cSrcweir return String( aRet, RTL_TEXTENCODING_ASCII_US );
318cdf0e10cSrcweir }
319cdf0e10cSrcweir
320cdf0e10cSrcweir /*************************************************************************
321cdf0e10cSrcweir |* SvGlobalName::GetHexName()
322cdf0e10cSrcweir *************************************************************************/
GetHexName() const323cdf0e10cSrcweir String SvGlobalName::GetHexName() const
324cdf0e10cSrcweir {
325cdf0e10cSrcweir ByteString aRet;
326cdf0e10cSrcweir
327cdf0e10cSrcweir sal_Char buf[ 10 ];
328cdf0e10cSrcweir sprintf( buf, "%8.8lX", (sal_uIntPtr)*(sal_uInt32 *)pImp->szData );
329cdf0e10cSrcweir aRet += buf;
330cdf0e10cSrcweir aRet += '-';
331cdf0e10cSrcweir sal_uInt16 i ;
332cdf0e10cSrcweir for( i = 4; i < 8; i += 2 )
333cdf0e10cSrcweir {
334cdf0e10cSrcweir sprintf( buf, "%4.4X", *(sal_uInt16 *)&pImp->szData[ i ] );
335cdf0e10cSrcweir aRet += buf;
336cdf0e10cSrcweir aRet += '-';
337cdf0e10cSrcweir }
338cdf0e10cSrcweir for( i = 8; i < 10; i++ )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir sprintf( buf, "%2.2x", pImp->szData[ i ] );
341cdf0e10cSrcweir aRet += buf;
342cdf0e10cSrcweir }
343cdf0e10cSrcweir aRet += '-';
344cdf0e10cSrcweir for( i = 10; i < 16; i++ )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir sprintf( buf, "%2.2x", pImp->szData[ i ] );
347cdf0e10cSrcweir aRet += buf;
348cdf0e10cSrcweir }
349cdf0e10cSrcweir return String( aRet, RTL_TEXTENCODING_ASCII_US );
350cdf0e10cSrcweir }
351cdf0e10cSrcweir
352cdf0e10cSrcweir /************** SvGlobalNameList ****************************************/
353cdf0e10cSrcweir /************************************************************************/
354cdf0e10cSrcweir /*************************************************************************
355cdf0e10cSrcweir |* SvGlobalNameList::SvGlobalNameList()
356cdf0e10cSrcweir *************************************************************************/
SvGlobalNameList()357cdf0e10cSrcweir SvGlobalNameList::SvGlobalNameList()
358cdf0e10cSrcweir : aList( 1, 1 )
359cdf0e10cSrcweir {
360cdf0e10cSrcweir }
361cdf0e10cSrcweir
362cdf0e10cSrcweir /*************************************************************************
363cdf0e10cSrcweir |* SvGlobalNameList::~SvGlobalNameList()
364cdf0e10cSrcweir *************************************************************************/
~SvGlobalNameList()365cdf0e10cSrcweir SvGlobalNameList::~SvGlobalNameList()
366cdf0e10cSrcweir {
367cdf0e10cSrcweir for( sal_uIntPtr i = Count(); i > 0; i-- )
368cdf0e10cSrcweir {
369cdf0e10cSrcweir ImpSvGlobalName * pImp = (ImpSvGlobalName *)aList.GetObject( i -1 );
370cdf0e10cSrcweir pImp->nRefCount--;
371cdf0e10cSrcweir if( !pImp->nRefCount )
372cdf0e10cSrcweir delete pImp;
373cdf0e10cSrcweir }
374cdf0e10cSrcweir }
375cdf0e10cSrcweir
376cdf0e10cSrcweir /*************************************************************************
377cdf0e10cSrcweir |* SvGlobalNameList::Append()
378cdf0e10cSrcweir *************************************************************************/
Append(const SvGlobalName & rName)379cdf0e10cSrcweir void SvGlobalNameList::Append( const SvGlobalName & rName )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir rName.pImp->nRefCount++;
382cdf0e10cSrcweir aList.Insert( rName.pImp, LIST_APPEND );
383cdf0e10cSrcweir }
384cdf0e10cSrcweir
385cdf0e10cSrcweir /*************************************************************************
386cdf0e10cSrcweir |* SvGlobalNameList::GetObject()
387cdf0e10cSrcweir *************************************************************************/
GetObject(sal_uLong nPos)388cdf0e10cSrcweir SvGlobalName SvGlobalNameList::GetObject( sal_uLong nPos )
389cdf0e10cSrcweir {
390cdf0e10cSrcweir return SvGlobalName( (ImpSvGlobalName *)aList.GetObject( nPos ) );
391cdf0e10cSrcweir }
392cdf0e10cSrcweir
393cdf0e10cSrcweir /*************************************************************************
394cdf0e10cSrcweir |* SvGlobalNameList::IsEntry()
395cdf0e10cSrcweir *************************************************************************/
IsEntry(const SvGlobalName & rName)396cdf0e10cSrcweir sal_Bool SvGlobalNameList::IsEntry( const SvGlobalName & rName )
397cdf0e10cSrcweir {
398cdf0e10cSrcweir for( sal_uIntPtr i = Count(); i > 0; i-- )
399cdf0e10cSrcweir {
400cdf0e10cSrcweir if( *rName.pImp == *(ImpSvGlobalName *)aList.GetObject( i -1 ) )
401cdf0e10cSrcweir return sal_True;
402cdf0e10cSrcweir }
403cdf0e10cSrcweir return sal_False;
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
GetByteSequence() const406cdf0e10cSrcweir com::sun::star::uno::Sequence < sal_Int8 > SvGlobalName::GetByteSequence() const
407cdf0e10cSrcweir {
408cdf0e10cSrcweir // platform independent representation of a "GlobalName"
409cdf0e10cSrcweir // maybe transported remotely
410cdf0e10cSrcweir com::sun::star::uno::Sequence< sal_Int8 > aResult( 16 );
411cdf0e10cSrcweir
412cdf0e10cSrcweir aResult[0] = (sal_Int8) (*(sal_uInt32 *)pImp->szData >> 24);
413cdf0e10cSrcweir aResult[1] = (sal_Int8) ((*(sal_uInt32 *)pImp->szData << 8 ) >> 24);
414cdf0e10cSrcweir aResult[2] = (sal_Int8) ((*(sal_uInt32 *)pImp->szData << 16 ) >> 24);
415cdf0e10cSrcweir aResult[3] = (sal_Int8) ((*(sal_uInt32 *)pImp->szData << 24 ) >> 24);
416cdf0e10cSrcweir aResult[4] = (sal_Int8) (*(sal_uInt16 *)&pImp->szData[ 4 ] >> 8);
417cdf0e10cSrcweir aResult[5] = (sal_Int8) ((*(sal_uInt16 *)&pImp->szData[ 4 ] << 8 ) >> 8);
418cdf0e10cSrcweir aResult[6] = (sal_Int8) (*(sal_uInt16 *)&pImp->szData[ 6 ] >> 8);
419cdf0e10cSrcweir aResult[7] = (sal_Int8) ((*(sal_uInt16 *)&pImp->szData[ 6 ] << 8 ) >> 8);
420cdf0e10cSrcweir aResult[8] = pImp->szData[ 8 ];
421cdf0e10cSrcweir aResult[9] = pImp->szData[ 9 ];
422cdf0e10cSrcweir aResult[10] = pImp->szData[ 10 ];
423cdf0e10cSrcweir aResult[11] = pImp->szData[ 11 ];
424cdf0e10cSrcweir aResult[12] = pImp->szData[ 12 ];
425cdf0e10cSrcweir aResult[13] = pImp->szData[ 13 ];
426cdf0e10cSrcweir aResult[14] = pImp->szData[ 14 ];
427cdf0e10cSrcweir aResult[15] = pImp->szData[ 15 ];
428cdf0e10cSrcweir
429cdf0e10cSrcweir return aResult;
430cdf0e10cSrcweir }
431cdf0e10cSrcweir
SvGlobalName(const com::sun::star::uno::Sequence<sal_Int8> & aSeq)432cdf0e10cSrcweir SvGlobalName::SvGlobalName( const com::sun::star::uno::Sequence < sal_Int8 >& aSeq )
433cdf0e10cSrcweir {
434cdf0e10cSrcweir // create SvGlobalName from a platform independent representation
435cdf0e10cSrcweir GUID aResult;
436cdf0e10cSrcweir memset( &aResult, 0, sizeof( aResult ) );
437cdf0e10cSrcweir if ( aSeq.getLength() == 16 )
438cdf0e10cSrcweir {
439cdf0e10cSrcweir aResult.Data1 = ( ( ( ( ( ( sal_uInt8 )aSeq[0] << 8 ) + ( sal_uInt8 )aSeq[1] ) << 8 ) + ( sal_uInt8 )aSeq[2] ) << 8 ) + ( sal_uInt8 )aSeq[3];
440cdf0e10cSrcweir aResult.Data2 = ( ( sal_uInt8 )aSeq[4] << 8 ) + ( sal_uInt8 )aSeq[5];
441cdf0e10cSrcweir aResult.Data3 = ( ( sal_uInt8 )aSeq[6] << 8 ) + ( sal_uInt8 )aSeq[7];
442cdf0e10cSrcweir for( int nInd = 0; nInd < 8; nInd++ )
443cdf0e10cSrcweir aResult.Data4[nInd] = ( sal_uInt8 )aSeq[nInd+8];
444cdf0e10cSrcweir }
445cdf0e10cSrcweir
446cdf0e10cSrcweir pImp = new ImpSvGlobalName();
447cdf0e10cSrcweir pImp->nRefCount++;
448cdf0e10cSrcweir memcpy( pImp->szData, &aResult, sizeof( pImp->szData ) );
449cdf0e10cSrcweir }
450