xref: /trunk/main/xmloff/source/style/StyleMap.cxx (revision 63bba73c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include <osl/mutex.hxx>
27 #include <rtl/uuid.h>
28 #include <rtl/memory.h>
29 
30 #include "StyleMap.hxx"
31 
32 using namespace ::osl;
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::lang;
35 
36 
StyleMap()37 StyleMap::StyleMap()
38 {
39 }
40 
41 
42 
~StyleMap()43 StyleMap::~StyleMap()
44 {
45 }
46 
47 
48 // XUnoTunnel & co
getUnoTunnelId()49 const Sequence< sal_Int8 > & StyleMap::getUnoTunnelId() throw()
50 {
51 	static Sequence< sal_Int8 > * pSeq = 0;
52 	if( !pSeq )
53 	{
54 		Guard< Mutex > aGuard( Mutex::getGlobalMutex() );
55 		if( !pSeq )
56 		{
57 			static Sequence< sal_Int8 > aSeq( 16 );
58 			rtl_createUuid( reinterpret_cast<sal_uInt8*>( aSeq.getArray() ),
59 							0, sal_True );
60 			pSeq = &aSeq;
61 		}
62 	}
63 	return *pSeq;
64 }
65 
getImplementation(Reference<XInterface> xInt)66 StyleMap* StyleMap::getImplementation( Reference< XInterface > xInt ) throw()
67 {
68 	Reference< XUnoTunnel > xUT( xInt, UNO_QUERY );
69 	if( xUT.is() )
70 		return reinterpret_cast<StyleMap *>(
71 				xUT->getSomething( StyleMap::getUnoTunnelId() ) );
72 	else
73 		return 0;
74 }
75 
76 // XUnoTunnel
getSomething(const Sequence<sal_Int8> & rId)77 sal_Int64 SAL_CALL StyleMap::getSomething(
78 		const Sequence< sal_Int8 >& rId )
79 	throw( RuntimeException )
80 {
81 	if( rId.getLength() == 16 &&
82 		0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
83 											 rId.getConstArray(), 16 ) )
84 	{
85 		return reinterpret_cast<sal_Int64>( this );
86 	}
87 	return 0;
88 }
89 
90 
91