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_sfx2.hxx" 30 31 #ifndef GCC 32 #endif 33 34 #include <sfx2/objsh.hxx> 35 //#include "objshimp.hxx" 36 #include <sfx2/objitem.hxx> 37 #include <com/sun/star/lang/XUnoTunnel.hpp> 38 39 //==================================================================== 40 41 TYPEINIT1_AUTOFACTORY(SfxObjectShellItem,SfxPoolItem) 42 TYPEINIT1_AUTOFACTORY(SfxObjectItem,SfxPoolItem) 43 44 //========================================================================= 45 46 int SfxObjectShellItem::operator==( const SfxPoolItem &rItem ) const 47 { 48 return PTR_CAST(SfxObjectShellItem, &rItem)->pObjSh == pObjSh; 49 } 50 51 //-------------------------------------------------------------------- 52 53 String SfxObjectShellItem::GetValueText() const 54 { 55 return String(); 56 } 57 58 //-------------------------------------------------------------------- 59 60 SfxPoolItem* SfxObjectShellItem::Clone( SfxItemPool *) const 61 { 62 return new SfxObjectShellItem( Which(), pObjSh ); 63 } 64 65 //-------------------------------------------------------------------- 66 67 sal_Bool SfxObjectShellItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const 68 { 69 if ( pObjSh ) 70 { 71 // This item MUST provide a model. Please don't change this, there are UNO-based 72 // implementations which need it!! 73 rVal <<= pObjSh->GetModel(); 74 } 75 else 76 { 77 rVal <<= ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >(); 78 } 79 return sal_True; 80 } 81 82 //-------------------------------------------------------------------- 83 84 sal_Bool SfxObjectShellItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) 85 { 86 // This item MUST have a model. Please don't change this, there are UNO-based 87 // implementations which need it!! 88 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel; 89 90 if ( rVal >>= xModel ) 91 { 92 if ( xModel.is() ) 93 { 94 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xTunnel( 95 xModel, ::com::sun::star::uno::UNO_QUERY ); 96 if ( xTunnel.is() ) 97 { 98 ::com::sun::star::uno::Sequence < sal_Int8 > aSeq( (sal_Int8*) SvGlobalName( SFX_GLOBAL_CLASSID ).GetBytes(), 16 ); 99 sal_Int64 nHandle = xTunnel->getSomething( aSeq ); 100 if ( nHandle ) 101 { 102 pObjSh = reinterpret_cast< SfxObjectShell* >(sal::static_int_cast<sal_IntPtr>( nHandle )); 103 return sal_True; 104 } 105 } 106 } 107 108 pObjSh = 0; 109 return sal_True; 110 } 111 112 return sal_False; 113 } 114 115 //========================================================================= 116 117 SfxObjectItem::SfxObjectItem( sal_uInt16 nWhichId, SfxShell *pSh ) 118 : SfxPoolItem( nWhichId ), 119 _pSh( pSh ) 120 {} 121 122 //-------------------------------------------------------------------- 123 124 int SfxObjectItem::operator==( const SfxPoolItem &rItem ) const 125 { 126 SfxObjectItem *pOther = PTR_CAST(SfxObjectItem, &rItem); 127 return pOther->_pSh == _pSh; 128 } 129 130 //-------------------------------------------------------------------- 131 132 SfxPoolItem* SfxObjectItem::Clone( SfxItemPool *) const 133 { 134 return new SfxObjectItem( Which(), _pSh ); 135 } 136