Update ooo320-m1
[ooovba.git] / sfx2 / source / doc / objitem.cxx
blob7a08e1b887e0a24ab80ff3c13fbfcf6de16f3518
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: objitem.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
34 #ifndef GCC
35 #endif
37 #include <sfx2/objsh.hxx>
38 //#include "objshimp.hxx"
39 #include <sfx2/objitem.hxx>
40 #include <com/sun/star/lang/XUnoTunnel.hpp>
42 //====================================================================
44 TYPEINIT1_AUTOFACTORY(SfxObjectShellItem,SfxPoolItem)
45 TYPEINIT1_AUTOFACTORY(SfxObjectItem,SfxPoolItem)
47 //=========================================================================
49 int SfxObjectShellItem::operator==( const SfxPoolItem &rItem ) const
51 return PTR_CAST(SfxObjectShellItem, &rItem)->pObjSh == pObjSh;
54 //--------------------------------------------------------------------
56 String SfxObjectShellItem::GetValueText() const
58 return String();
61 //--------------------------------------------------------------------
63 SfxPoolItem* SfxObjectShellItem::Clone( SfxItemPool *) const
65 return new SfxObjectShellItem( Which(), pObjSh );
68 //--------------------------------------------------------------------
70 sal_Bool SfxObjectShellItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ ) const
72 if ( pObjSh )
74 // This item MUST provide a model. Please don't change this, there are UNO-based
75 // implementations which need it!!
76 rVal <<= pObjSh->GetModel();
78 else
80 rVal <<= ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >();
82 return TRUE;
85 //--------------------------------------------------------------------
87 sal_Bool SfxObjectShellItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ )
89 // This item MUST have a model. Please don't change this, there are UNO-based
90 // implementations which need it!!
91 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel;
93 if ( rVal >>= xModel )
95 if ( xModel.is() )
97 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xTunnel(
98 xModel, ::com::sun::star::uno::UNO_QUERY );
99 if ( xTunnel.is() )
101 ::com::sun::star::uno::Sequence < sal_Int8 > aSeq( (sal_Int8*) SvGlobalName( SFX_GLOBAL_CLASSID ).GetBytes(), 16 );
102 sal_Int64 nHandle = xTunnel->getSomething( aSeq );
103 if ( nHandle )
105 pObjSh = reinterpret_cast< SfxObjectShell* >(sal::static_int_cast<sal_IntPtr>( nHandle ));
106 return TRUE;
111 pObjSh = 0;
112 return TRUE;
115 return FALSE;
118 //=========================================================================
120 SfxObjectItem::SfxObjectItem( USHORT nWhichId, SfxShell *pSh )
121 : SfxPoolItem( nWhichId ),
122 _pSh( pSh )
125 //--------------------------------------------------------------------
127 int SfxObjectItem::operator==( const SfxPoolItem &rItem ) const
129 SfxObjectItem *pOther = PTR_CAST(SfxObjectItem, &rItem);
130 return pOther->_pSh == _pSh;
133 //--------------------------------------------------------------------
135 SfxPoolItem* SfxObjectItem::Clone( SfxItemPool *) const
137 return new SfxObjectItem( Which(), _pSh );