Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include <sfx2/objsh.hxx>
22 : #include <sfx2/objitem.hxx>
23 : #include <com/sun/star/lang/XUnoTunnel.hpp>
24 :
25 59 : TYPEINIT1_AUTOFACTORY(SfxObjectShellItem,SfxPoolItem)
26 197 : TYPEINIT1_AUTOFACTORY(SfxObjectItem,SfxPoolItem)
27 :
28 0 : bool SfxObjectShellItem::operator==( const SfxPoolItem &rItem ) const
29 : {
30 0 : return PTR_CAST(SfxObjectShellItem, &rItem)->pObjSh == pObjSh;
31 : }
32 :
33 0 : SfxPoolItem* SfxObjectShellItem::Clone( SfxItemPool *) const
34 : {
35 0 : return new SfxObjectShellItem( Which(), pObjSh );
36 : }
37 :
38 0 : bool SfxObjectShellItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
39 : {
40 0 : if ( pObjSh )
41 : {
42 : // This item MUST provide a model. Please don't change this, there are UNO-based
43 : // implementations which need it!!
44 0 : rVal <<= pObjSh->GetModel();
45 : }
46 : else
47 : {
48 0 : rVal <<= ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >();
49 : }
50 0 : return true;
51 : }
52 :
53 0 : bool SfxObjectShellItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
54 : {
55 : // This item MUST have a model. Please don't change this, there are UNO-based
56 : // implementations which need it!!
57 0 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel;
58 :
59 0 : if ( rVal >>= xModel )
60 : {
61 0 : if ( xModel.is() )
62 : {
63 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xTunnel(
64 0 : xModel, ::com::sun::star::uno::UNO_QUERY );
65 0 : if ( xTunnel.is() )
66 : {
67 0 : ::com::sun::star::uno::Sequence < sal_Int8 > aSeq = SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence();
68 0 : sal_Int64 nHandle = xTunnel->getSomething( aSeq );
69 0 : if ( nHandle )
70 : {
71 0 : pObjSh = reinterpret_cast< SfxObjectShell* >(sal::static_int_cast<sal_IntPtr>( nHandle ));
72 0 : return true;
73 0 : }
74 0 : }
75 : }
76 :
77 0 : pObjSh = 0;
78 0 : return true;
79 : }
80 :
81 0 : return true;
82 : }
83 :
84 0 : SfxObjectItem::SfxObjectItem( sal_uInt16 nWhichId, SfxShell *pSh )
85 : : SfxPoolItem( nWhichId ),
86 0 : _pSh( pSh )
87 0 : {}
88 :
89 0 : bool SfxObjectItem::operator==( const SfxPoolItem &rItem ) const
90 : {
91 0 : const SfxObjectItem *pOther = PTR_CAST(SfxObjectItem, &rItem);
92 0 : return pOther->_pSh == _pSh;
93 : }
94 :
95 :
96 :
97 0 : SfxPoolItem* SfxObjectItem::Clone( SfxItemPool *) const
98 : {
99 0 : return new SfxObjectItem( Which(), _pSh );
100 : }
101 :
102 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|