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/frame/XModel.hpp>
24 
25 
CreateDefault()26 SfxPoolItem* SfxObjectShellItem::CreateDefault() { return new SfxObjectShellItem; }
27 
CreateDefault()28 SfxPoolItem* SfxObjectItem::CreateDefault() { return new SfxObjectItem; }
29 
operator ==(const SfxPoolItem & rItem) const30 bool SfxObjectShellItem::operator==( const SfxPoolItem &rItem ) const
31 {
32      return SfxPoolItem::operator==(rItem) &&
33         static_cast<const SfxObjectShellItem&>(rItem).pObjSh == pObjSh;
34 }
35 
Clone(SfxItemPool *) const36 SfxObjectShellItem* SfxObjectShellItem::Clone( SfxItemPool *) const
37 {
38     return new SfxObjectShellItem( *this );
39 }
40 
QueryValue(css::uno::Any & rVal,sal_uInt8) const41 bool SfxObjectShellItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
42 {
43     if ( pObjSh )
44     {
45         // This item MUST provide a model. Please don't change this, there are UNO-based
46         // implementations which need it!!
47         rVal <<= pObjSh->GetModel();
48     }
49     else
50     {
51         rVal <<= css::uno::Reference< css::frame::XModel >();
52     }
53     return true;
54 }
55 
PutValue(const css::uno::Any & rVal,sal_uInt8)56 bool SfxObjectShellItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
57 {
58     // This item MUST have a model. Please don't change this, there are UNO-based
59     // implementations which need it!!
60     css::uno::Reference< css::frame::XModel > xModel;
61 
62     if ( rVal >>= xModel )
63     {
64         pObjSh = SfxObjectShell::GetShellFromComponent(xModel);
65         return true;
66     }
67 
68     return true;
69 }
70 
SfxObjectItem(sal_uInt16 nWhichId,SfxShell * pSh)71 SfxObjectItem::SfxObjectItem( sal_uInt16 nWhichId, SfxShell *pSh )
72 :   SfxPoolItem( nWhichId ),
73     _pSh( pSh )
74 {}
75 
operator ==(const SfxPoolItem & rItem) const76 bool SfxObjectItem::operator==( const SfxPoolItem &rItem ) const
77 {
78      return SfxPoolItem::operator==(rItem) &&
79         static_cast<const SfxObjectItem&>(rItem)._pSh == _pSh;
80 }
81 
Clone(SfxItemPool *) const82 SfxObjectItem* SfxObjectItem::Clone( SfxItemPool *) const
83 {
84     return new SfxObjectItem( *this );
85 }
86 
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
88