LibreOffice Module forms (master) 1
rtattributes.hxx
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#pragma once
21
22#include <sal/types.h>
23#include <svl/poolitem.hxx>
24
25namespace frm
26{
27
29 typedef sal_Int32 AttributeId;
31 typedef sal_uInt16 WhichId;
33 typedef sal_uInt16 SfxSlotId;
34
36 {
40 };
41
43 {
44 private:
45 std::unique_ptr<SfxPoolItem> pItemHandleItem;
46
47 public:
49
50 inline AttributeState( );
51 inline explicit AttributeState( AttributeCheckState _eCheckState );
52 inline AttributeState( const AttributeState& _rSource );
53
54 inline AttributeState& operator=( const AttributeState& _rSource );
55
56 inline bool operator==( const AttributeState& _rRHS );
57
58 inline const SfxPoolItem* getItem() const;
59 inline void setItem( const SfxPoolItem* _pItem );
60 };
61
63 :eSimpleState( eIndetermined )
64 {
65 }
66
68 :eSimpleState( _eCheckState )
69 {
70 }
71
73 :eSimpleState( eIndetermined )
74 {
75 operator=( _rSource );
76 }
77
79 {
80 if ( &_rSource == this )
81 return *this;
82
83 eSimpleState = _rSource.eSimpleState;
84 setItem( _rSource.getItem() );
85 return *this;
86 }
87
89 {
90 return pItemHandleItem.get();
91 }
92
93 inline void AttributeState::setItem( const SfxPoolItem* _pItem )
94 {
95 if ( _pItem )
96 pItemHandleItem.reset(_pItem->Clone());
97 else
98 pItemHandleItem.reset();
99 }
100
101 inline bool AttributeState::operator==( const AttributeState& _rRHS )
102 {
103 if ( eSimpleState != _rRHS.eSimpleState )
104 return false;
105
106 if ( pItemHandleItem && !_rRHS.pItemHandleItem )
107 return false;
108
109 if ( !pItemHandleItem && _rRHS.pItemHandleItem )
110 return false;
111
112 if ( pItemHandleItem == _rRHS.pItemHandleItem )
113 return true;
114
115 assert(pItemHandleItem && _rRHS.pItemHandleItem && "otherwise have already returned");
116
117 return *pItemHandleItem == *_rRHS.pItemHandleItem;
118 }
119
121 {
122 public:
123 virtual AttributeState getState( AttributeId _nAttributeId ) const = 0;
124 virtual void executeAttribute( AttributeId _nAttributeId, const SfxPoolItem* _pArgument ) = 0;
125
126 protected:
128 };
129
130} // namespace frm
131
132/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
virtual void executeAttribute(AttributeId _nAttributeId, const SfxPoolItem *_pArgument)=0
virtual AttributeState getState(AttributeId _nAttributeId) const =0
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25
sal_uInt16 WhichId
the "which id" of an item in an SfxItemSet
AttributeCheckState
@ eUnchecked
@ eIndetermined
@ eChecked
sal_uInt16 SfxSlotId
a SFX slot id
sal_Int32 AttributeId
the id of an attribute
std::unique_ptr< SfxPoolItem > pItemHandleItem
const SfxPoolItem * getItem() const
void setItem(const SfxPoolItem *_pItem)
AttributeState & operator=(const AttributeState &_rSource)
bool operator==(const AttributeState &_rRHS)
AttributeCheckState eSimpleState