xref: /aoo41x/main/xmloff/source/style/StyleMap.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmloff.hxx"
30 #include <osl/mutex.hxx>
31 #include <rtl/uuid.h>
32 #include <rtl/memory.h>
33 
34 #include "StyleMap.hxx"
35 
36 using namespace ::osl;
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::lang;
39 
40 
41 StyleMap::StyleMap()
42 {
43 }
44 
45 
46 
47 StyleMap::~StyleMap()
48 {
49 }
50 
51 
52 // XUnoTunnel & co
53 const Sequence< sal_Int8 > & StyleMap::getUnoTunnelId() throw()
54 {
55 	static Sequence< sal_Int8 > * pSeq = 0;
56 	if( !pSeq )
57 	{
58 		Guard< Mutex > aGuard( Mutex::getGlobalMutex() );
59 		if( !pSeq )
60 		{
61 			static Sequence< sal_Int8 > aSeq( 16 );
62 			rtl_createUuid( reinterpret_cast<sal_uInt8*>( aSeq.getArray() ),
63 							0, sal_True );
64 			pSeq = &aSeq;
65 		}
66 	}
67 	return *pSeq;
68 }
69 
70 StyleMap* StyleMap::getImplementation( Reference< XInterface > xInt ) throw()
71 {
72 	Reference< XUnoTunnel > xUT( xInt, UNO_QUERY );
73 	if( xUT.is() )
74 		return reinterpret_cast<StyleMap *>(
75 				xUT->getSomething( StyleMap::getUnoTunnelId() ) );
76 	else
77 		return 0;
78 }
79 
80 // XUnoTunnel
81 sal_Int64 SAL_CALL StyleMap::getSomething(
82 		const Sequence< sal_Int8 >& rId )
83 	throw( RuntimeException )
84 {
85 	if( rId.getLength() == 16 &&
86 		0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
87 											 rId.getConstArray(), 16 ) )
88 	{
89 		return reinterpret_cast<sal_Int64>( this );
90 	}
91 	return 0;
92 }
93 
94 
95