xref: /aoo41x/main/sfx2/source/doc/objitem.cxx (revision d119d52d)
1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d119d52dSAndrew Rist  * distributed with this work for additional information
6*d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d119d52dSAndrew Rist  *
11*d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist  *
13*d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*d119d52dSAndrew Rist  * specific language governing permissions and limitations
18*d119d52dSAndrew Rist  * under the License.
19*d119d52dSAndrew Rist  *
20*d119d52dSAndrew Rist  *************************************************************/
21*d119d52dSAndrew Rist 
22*d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef GCC
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <sfx2/objsh.hxx>
31cdf0e10cSrcweir //#include "objshimp.hxx"
32cdf0e10cSrcweir #include <sfx2/objitem.hxx>
33cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //====================================================================
36cdf0e10cSrcweir 
37cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(SfxObjectShellItem,SfxPoolItem)
38cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(SfxObjectItem,SfxPoolItem)
39cdf0e10cSrcweir 
40cdf0e10cSrcweir //=========================================================================
41cdf0e10cSrcweir 
42cdf0e10cSrcweir int SfxObjectShellItem::operator==( const SfxPoolItem &rItem ) const
43cdf0e10cSrcweir {
44cdf0e10cSrcweir 	 return PTR_CAST(SfxObjectShellItem, &rItem)->pObjSh == pObjSh;
45cdf0e10cSrcweir }
46cdf0e10cSrcweir 
47cdf0e10cSrcweir //--------------------------------------------------------------------
48cdf0e10cSrcweir 
GetValueText() const49cdf0e10cSrcweir String SfxObjectShellItem::GetValueText() const
50cdf0e10cSrcweir {
51cdf0e10cSrcweir 	return String();
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
54cdf0e10cSrcweir //--------------------------------------------------------------------
55cdf0e10cSrcweir 
Clone(SfxItemPool *) const56cdf0e10cSrcweir SfxPoolItem* SfxObjectShellItem::Clone( SfxItemPool *) const
57cdf0e10cSrcweir {
58cdf0e10cSrcweir 	return new SfxObjectShellItem( Which(), pObjSh );
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir //--------------------------------------------------------------------
62cdf0e10cSrcweir 
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const63cdf0e10cSrcweir sal_Bool SfxObjectShellItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
64cdf0e10cSrcweir {
65cdf0e10cSrcweir     if ( pObjSh )
66cdf0e10cSrcweir     {
67cdf0e10cSrcweir         // This item MUST provide a model. Please don't change this, there are UNO-based
68cdf0e10cSrcweir         // implementations which need it!!
69cdf0e10cSrcweir         rVal <<= pObjSh->GetModel();
70cdf0e10cSrcweir     }
71cdf0e10cSrcweir     else
72cdf0e10cSrcweir     {
73cdf0e10cSrcweir         rVal <<= ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >();
74cdf0e10cSrcweir     }
75cdf0e10cSrcweir     return sal_True;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir //--------------------------------------------------------------------
79cdf0e10cSrcweir 
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)80cdf0e10cSrcweir sal_Bool SfxObjectShellItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir     // This item MUST have a model. Please don't change this, there are UNO-based
83cdf0e10cSrcweir     // implementations which need it!!
84cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     if ( rVal >>= xModel )
87cdf0e10cSrcweir     {
88cdf0e10cSrcweir         if ( xModel.is() )
89cdf0e10cSrcweir         {
90cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xTunnel(
91cdf0e10cSrcweir                 xModel, ::com::sun::star::uno::UNO_QUERY );
92cdf0e10cSrcweir             if ( xTunnel.is() )
93cdf0e10cSrcweir             {
94cdf0e10cSrcweir                 ::com::sun::star::uno::Sequence < sal_Int8 > aSeq( (sal_Int8*) SvGlobalName( SFX_GLOBAL_CLASSID ).GetBytes(), 16 );
95cdf0e10cSrcweir                 sal_Int64 nHandle = xTunnel->getSomething( aSeq );
96cdf0e10cSrcweir                 if ( nHandle )
97cdf0e10cSrcweir                 {
98cdf0e10cSrcweir                     pObjSh = reinterpret_cast< SfxObjectShell* >(sal::static_int_cast<sal_IntPtr>( nHandle ));
99cdf0e10cSrcweir                     return sal_True;
100cdf0e10cSrcweir                 }
101cdf0e10cSrcweir             }
102cdf0e10cSrcweir         }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir         pObjSh = 0;
105cdf0e10cSrcweir         return sal_True;
106cdf0e10cSrcweir     }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     return sal_False;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir //=========================================================================
112cdf0e10cSrcweir 
SfxObjectItem(sal_uInt16 nWhichId,SfxShell * pSh)113cdf0e10cSrcweir SfxObjectItem::SfxObjectItem( sal_uInt16 nWhichId, SfxShell *pSh )
114cdf0e10cSrcweir :	SfxPoolItem( nWhichId ),
115cdf0e10cSrcweir     _pSh( pSh )
116cdf0e10cSrcweir {}
117cdf0e10cSrcweir 
118cdf0e10cSrcweir //--------------------------------------------------------------------
119cdf0e10cSrcweir 
operator ==(const SfxPoolItem & rItem) const120cdf0e10cSrcweir int SfxObjectItem::operator==( const SfxPoolItem &rItem ) const
121cdf0e10cSrcweir {
122cdf0e10cSrcweir 	 SfxObjectItem *pOther = PTR_CAST(SfxObjectItem, &rItem);
123cdf0e10cSrcweir      return pOther->_pSh == _pSh;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir //--------------------------------------------------------------------
127cdf0e10cSrcweir 
Clone(SfxItemPool *) const128cdf0e10cSrcweir SfxPoolItem* SfxObjectItem::Clone( SfxItemPool *) const
129cdf0e10cSrcweir {
130cdf0e10cSrcweir     return new SfxObjectItem( Which(), _pSh );
131cdf0e10cSrcweir }
132