bump product version to 4.1.6.2
[LibreOffice.git] / forms / source / richtext / rtattributes.hxx
blob825ed17c3fa1d053cdf05845af46018192208e33
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 FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX
21 #define FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX
23 #include <tools/solar.h>
24 #include <sal/types.h>
25 #include <svl/poolitem.hxx>
27 namespace frm
30 //====================================================================
31 //= misc
32 //====================================================================
33 /// the id of an attribute
34 typedef sal_Int32 AttributeId;
35 /// the "which id" of an item in an SfxItemSet
36 typedef sal_uInt16 WhichId;
37 /// a SFX slot id
38 typedef sal_uInt16 SfxSlotId;
39 /// a script type
40 typedef sal_uInt16 ScriptType;
42 //====================================================================
43 //= AttributeCheckState
44 //====================================================================
45 enum AttributeCheckState
47 eChecked,
48 eUnchecked,
49 eIndetermined
52 //====================================================================
53 //= AttributeState
54 //====================================================================
55 struct AttributeState
57 private:
58 SfxItemHandle* pItemHandle;
60 public:
61 AttributeCheckState eSimpleState;
63 inline AttributeState( );
64 inline explicit AttributeState( AttributeCheckState _eCheckState );
65 inline AttributeState( const AttributeState& _rSource );
66 inline ~AttributeState( );
68 inline AttributeState& operator=( const AttributeState& _rSource );
70 inline bool operator==( const AttributeState& _rRHS );
72 inline const SfxPoolItem* getItem() const;
73 inline void setItem( const SfxPoolItem* _pItem );
76 //====================================================================
77 //= AttributeState (inline implementation)
78 //====================================================================
79 inline AttributeState::AttributeState( )
80 :pItemHandle( NULL )
81 ,eSimpleState( eIndetermined )
85 inline AttributeState::AttributeState( AttributeCheckState _eCheckState )
86 :pItemHandle( NULL )
87 ,eSimpleState( _eCheckState )
91 inline AttributeState::AttributeState( const AttributeState& _rSource )
92 :pItemHandle( NULL )
93 ,eSimpleState( eIndetermined )
95 operator=( _rSource );
98 inline AttributeState::~AttributeState( )
100 delete(pItemHandle);
103 inline AttributeState& AttributeState::operator=( const AttributeState& _rSource )
105 if ( &_rSource == this )
106 return *this;
108 eSimpleState = _rSource.eSimpleState;
109 setItem( _rSource.getItem() );
110 return *this;
113 inline const SfxPoolItem* AttributeState::getItem() const
115 return pItemHandle ? &pItemHandle->GetItem() : NULL;
118 inline void AttributeState::setItem( const SfxPoolItem* _pItem )
120 if ( pItemHandle )
121 delete pItemHandle;
122 if ( _pItem )
123 pItemHandle = new SfxItemHandle( *const_cast< SfxPoolItem* >( _pItem ) );
124 else
125 pItemHandle = NULL;
128 inline bool AttributeState::operator==( const AttributeState& _rRHS )
130 if ( eSimpleState != _rRHS.eSimpleState )
131 return false;
133 if ( pItemHandle && !_rRHS.pItemHandle )
134 return false;
136 if ( !pItemHandle && _rRHS.pItemHandle )
137 return false;
139 if ( !pItemHandle && !_rRHS.pItemHandle )
140 return true;
142 return ( pItemHandle->GetItem() == _rRHS.pItemHandle->GetItem() );
145 //====================================================================
146 //= IMultiAttributeDispatcher
147 //====================================================================
148 class IMultiAttributeDispatcher
150 public:
151 virtual AttributeState getState( AttributeId _nAttributeId ) const = 0;
152 virtual void executeAttribute( AttributeId _nAttributeId, const SfxPoolItem* _pArgument ) = 0;
154 protected:
155 ~IMultiAttributeDispatcher() {}
158 } // namespace frm
160 #endif // FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */