Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / forms / source / richtext / rtattributes.hxx
blob5e61f55dbffa18e276131591b77929454996d3b2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX
21 #define INCLUDED_FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX
23 #include <sal/types.h>
24 #include <svl/poolitem.hxx>
26 namespace frm
29 /// the id of an attribute
30 typedef sal_Int32 AttributeId;
31 /// the "which id" of an item in an SfxItemSet
32 typedef sal_uInt16 WhichId;
33 /// a SFX slot id
34 typedef sal_uInt16 SfxSlotId;
36 enum AttributeCheckState
38 eChecked,
39 eUnchecked,
40 eIndetermined
43 struct AttributeState
45 private:
46 SfxPoolItem *pItemHandleItem;
48 public:
49 AttributeCheckState eSimpleState;
51 inline AttributeState( );
52 inline explicit AttributeState( AttributeCheckState _eCheckState );
53 inline AttributeState( const AttributeState& _rSource );
54 inline ~AttributeState( );
56 inline AttributeState& operator=( const AttributeState& _rSource );
58 inline bool operator==( const AttributeState& _rRHS );
60 inline const SfxPoolItem* getItem() const;
61 inline void setItem( const SfxPoolItem* _pItem );
64 inline AttributeState::AttributeState( )
65 :pItemHandleItem ( nullptr )
66 ,eSimpleState( eIndetermined )
70 inline AttributeState::AttributeState( AttributeCheckState _eCheckState )
71 :pItemHandleItem ( nullptr )
72 ,eSimpleState( _eCheckState )
76 inline AttributeState::AttributeState( const AttributeState& _rSource )
77 :pItemHandleItem ( nullptr )
78 ,eSimpleState( eIndetermined )
80 operator=( _rSource );
83 inline AttributeState::~AttributeState( )
85 // delete(pItemHandle);
88 inline AttributeState& AttributeState::operator=( const AttributeState& _rSource )
90 if ( &_rSource == this )
91 return *this;
93 eSimpleState = _rSource.eSimpleState;
94 setItem( _rSource.getItem() );
95 return *this;
98 inline const SfxPoolItem* AttributeState::getItem() const
100 return pItemHandleItem;
103 inline void AttributeState::setItem( const SfxPoolItem* _pItem )
105 if ( pItemHandleItem )
106 delete pItemHandleItem;
107 if ( _pItem )
108 pItemHandleItem = _pItem->Clone();
109 else
110 pItemHandleItem = nullptr;
113 inline bool AttributeState::operator==( const AttributeState& _rRHS )
115 if ( eSimpleState != _rRHS.eSimpleState )
116 return false;
118 if ( pItemHandleItem && !_rRHS.pItemHandleItem )
119 return false;
121 if ( !pItemHandleItem && _rRHS.pItemHandleItem )
122 return false;
124 if ( !pItemHandleItem && !_rRHS.pItemHandleItem )
125 return true;
127 return pItemHandleItem == _rRHS.pItemHandleItem;
130 class IMultiAttributeDispatcher
132 public:
133 virtual AttributeState getState( AttributeId _nAttributeId ) const = 0;
134 virtual void executeAttribute( AttributeId _nAttributeId, const SfxPoolItem* _pArgument ) = 0;
136 protected:
137 ~IMultiAttributeDispatcher() {}
140 } // namespace frm
142 #endif // INCLUDED_FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */