LibreOffice Module sfx2 (master) 1
objitem.cxx
Go to the documentation of this file.
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
27
29
31{
32 return SfxPoolItem::operator==(rItem) &&
33 static_cast<const SfxObjectShellItem&>(rItem).pObjSh == pObjSh;
34}
35
37{
38 return new SfxObjectShellItem( *this );
39}
40
41bool 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
56bool 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 {
65 return true;
66 }
67
68 return true;
69}
70
71SfxObjectItem::SfxObjectItem( sal_uInt16 nWhichId, SfxShell *pSh )
72: SfxPoolItem( nWhichId ),
73 _pSh( pSh )
74{}
75
76bool SfxObjectItem::operator==( const SfxPoolItem &rItem ) const
77{
78 return SfxPoolItem::operator==(rItem) &&
79 static_cast<const SfxObjectItem&>(rItem)._pSh == _pSh;
80}
81
83{
84 return new SfxObjectItem( *this );
85}
86
87bool SfxObjectItem::QueryValue(css::uno::Any&, sal_uInt8) const
88{
89 return false;
90}
91
92bool SfxObjectItem::PutValue(const css::uno::Any&, sal_uInt8)
93{
94 return false;
95}
96
97/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static SfxPoolItem * CreateDefault()
Definition: objitem.cxx:28
virtual SfxObjectItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: objitem.cxx:82
virtual bool QueryValue(css::uno::Any &, sal_uInt8 nMemberId=0) const override
Definition: objitem.cxx:87
virtual bool operator==(const SfxPoolItem &) const override
Definition: objitem.cxx:76
SfxShell * _pSh
Definition: objitem.hxx:30
virtual bool PutValue(const css::uno::Any &, sal_uInt8) override
Definition: objitem.cxx:92
SfxObjectItem(sal_uInt16 nWhich=0, SfxShell *pSh=nullptr)
Definition: objitem.cxx:71
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: objitem.cxx:41
SfxObjectShell * pObjSh
Definition: objsh.hxx:910
static SfxPoolItem * CreateDefault()
Definition: objitem.cxx:26
virtual bool operator==(const SfxPoolItem &) const override
Definition: objitem.cxx:30
virtual SfxObjectShellItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: objitem.cxx:36
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: objitem.cxx:56
static SfxObjectShell * GetShellFromComponent(const css::uno::Reference< css::uno::XInterface > &xComp)
Definition: objxtor.cxx:1039
css::uno::Reference< css::frame::XModel3 > GetModel() const
Definition: objxtor.cxx:838
virtual bool operator==(const SfxPoolItem &) const=0
The class SfxShell is the base class for all classes, which provide the functionality of the form <Sl...
Definition: shell.hxx:128
Reference< XModel > xModel
unsigned char sal_uInt8