1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <sfx2/objsh.hxx>
22 #include <sfx2/objitem.hxx>
23 #include <com/sun/star/lang/XUnoTunnel.hpp>
24 #include <com/sun/star/frame/XModel.hpp>
26 #include <tools/globname.hxx>
29 SfxPoolItem
* SfxObjectShellItem::CreateDefault() { return new SfxObjectShellItem
; }
31 SfxPoolItem
* SfxObjectItem::CreateDefault() { return new SfxObjectItem
; }
33 bool SfxObjectShellItem::operator==( const SfxPoolItem
&rItem
) const
35 return SfxPoolItem::operator==(rItem
) &&
36 static_cast<const SfxObjectShellItem
&>(rItem
).pObjSh
== pObjSh
;
39 SfxPoolItem
* SfxObjectShellItem::Clone( SfxItemPool
*) const
41 return new SfxObjectShellItem( *this );
44 bool SfxObjectShellItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
48 // This item MUST provide a model. Please don't change this, there are UNO-based
49 // implementations which need it!!
50 rVal
<<= pObjSh
->GetModel();
54 rVal
<<= css::uno::Reference
< css::frame::XModel
>();
59 bool SfxObjectShellItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
61 // This item MUST have a model. Please don't change this, there are UNO-based
62 // implementations which need it!!
63 css::uno::Reference
< css::frame::XModel
> xModel
;
65 if ( rVal
>>= xModel
)
69 css::uno::Reference
< css::lang::XUnoTunnel
> xTunnel( xModel
, css::uno::UNO_QUERY
);
72 css::uno::Sequence
< sal_Int8
> aSeq
= SvGlobalName( SFX_GLOBAL_CLASSID
).GetByteSequence();
73 sal_Int64 nHandle
= xTunnel
->getSomething( aSeq
);
76 pObjSh
= reinterpret_cast< SfxObjectShell
* >(sal::static_int_cast
<sal_IntPtr
>( nHandle
));
89 SfxObjectItem::SfxObjectItem( sal_uInt16 nWhichId
, SfxShell
*pSh
)
90 : SfxPoolItem( nWhichId
),
94 bool SfxObjectItem::operator==( const SfxPoolItem
&rItem
) const
96 return SfxPoolItem::operator==(rItem
) &&
97 static_cast<const SfxObjectItem
&>(rItem
)._pSh
== _pSh
;
100 SfxPoolItem
* SfxObjectItem::Clone( SfxItemPool
*) const
102 return new SfxObjectItem( *this );
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */