1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: objitem.cxx,v $
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"
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
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
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();
80 rVal
<<= ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>();
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
)
97 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XUnoTunnel
> xTunnel(
98 xModel
, ::com::sun::star::uno::UNO_QUERY
);
101 ::com::sun::star::uno::Sequence
< sal_Int8
> aSeq( (sal_Int8
*) SvGlobalName( SFX_GLOBAL_CLASSID
).GetBytes(), 16 );
102 sal_Int64 nHandle
= xTunnel
->getSomething( aSeq
);
105 pObjSh
= reinterpret_cast< SfxObjectShell
* >(sal::static_int_cast
<sal_IntPtr
>( nHandle
));
118 //=========================================================================
120 SfxObjectItem::SfxObjectItem( USHORT nWhichId
, SfxShell
*pSh
)
121 : SfxPoolItem( nWhichId
),
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
);