Line data Source code
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 : #include "rtattributehandler.hxx"
21 :
22 : #include <svx/svxids.hrc>
23 : #include <editeng/eeitem.hxx>
24 : #include <svl/itemset.hxx>
25 : #include <svl/itempool.hxx>
26 : #include <tools/mapunit.hxx>
27 : #include <vcl/mapmod.hxx>
28 : #include <vcl/outdev.hxx>
29 :
30 : #include <editeng/adjustitem.hxx>
31 : #include <editeng/wghtitem.hxx>
32 : #include <editeng/escapementitem.hxx>
33 : #include <editeng/lspcitem.hxx>
34 : #include <editeng/fhgtitem.hxx>
35 : #include <editeng/frmdiritem.hxx>
36 : #include <editeng/scripttypeitem.hxx>
37 :
38 :
39 : namespace frm
40 : {
41 :
42 :
43 : //= ReferenceBase
44 :
45 :
46 0 : oslInterlockedCount SAL_CALL ReferenceBase::acquire()
47 : {
48 0 : return osl_atomic_increment( &m_refCount );
49 : }
50 :
51 :
52 0 : oslInterlockedCount SAL_CALL ReferenceBase::release()
53 : {
54 0 : return osl_atomic_decrement( &m_refCount );
55 : }
56 :
57 :
58 0 : ReferenceBase::~ReferenceBase()
59 : {
60 0 : }
61 :
62 :
63 : //= AttributeHandler
64 :
65 :
66 0 : AttributeHandler::AttributeHandler( AttributeId _nAttributeId, WhichId _nWhichId )
67 : :m_nAttribute( _nAttributeId )
68 0 : ,m_nWhich ( _nWhichId )
69 : {
70 0 : }
71 :
72 :
73 0 : AttributeHandler::~AttributeHandler()
74 : {
75 0 : }
76 :
77 :
78 0 : oslInterlockedCount SAL_CALL AttributeHandler::acquire()
79 : {
80 0 : return ReferenceBase::acquire();
81 : }
82 :
83 :
84 0 : oslInterlockedCount SAL_CALL AttributeHandler::release()
85 : {
86 0 : return ReferenceBase::release();
87 : }
88 :
89 :
90 0 : AttributeId AttributeHandler::getAttributeId( ) const
91 : {
92 0 : return getAttribute();
93 : }
94 :
95 :
96 0 : AttributeCheckState AttributeHandler::implGetCheckState( const SfxPoolItem& /*_rItem*/ ) const
97 : {
98 : OSL_FAIL( "AttributeHandler::implGetCheckState: not to be called!" );
99 0 : return eIndetermined;
100 : }
101 :
102 :
103 0 : void AttributeHandler::putItemForScript( SfxItemSet& _rAttribs, const SfxPoolItem& _rItem, ScriptType _nForScriptType ) const
104 : {
105 0 : SvxScriptSetItem aSetItem( (WhichId)getAttributeId(), *_rAttribs.GetPool() );
106 0 : aSetItem.PutItemForScriptType( _nForScriptType, _rItem );
107 0 : _rAttribs.Put( aSetItem.GetItemSet(), false );
108 0 : }
109 :
110 :
111 0 : AttributeCheckState AttributeHandler::getCheckState( const SfxItemSet& _rAttribs ) const
112 : {
113 0 : AttributeCheckState eSimpleState( eIndetermined );
114 0 : const SfxPoolItem* pItem = _rAttribs.GetItem( getWhich() );
115 0 : if ( pItem )
116 0 : eSimpleState = implGetCheckState( *pItem );
117 0 : return eSimpleState;
118 : }
119 :
120 :
121 0 : AttributeState AttributeHandler::getState( const SfxItemSet& _rAttribs ) const
122 : {
123 0 : AttributeState aState( eIndetermined );
124 0 : aState.eSimpleState = getCheckState( _rAttribs );
125 0 : return aState;
126 : }
127 :
128 :
129 : //= AttributeHandlerFactory
130 :
131 :
132 : namespace
133 : {
134 0 : static WhichId lcl_implGetWhich( const SfxItemPool& _rPool, AttributeId _nAttributeId )
135 : {
136 0 : WhichId nWhich = 0;
137 0 : switch ( _nAttributeId )
138 : {
139 0 : case SID_ATTR_CHAR_LATIN_FONTHEIGHT:nWhich = EE_CHAR_FONTHEIGHT;break;
140 0 : case SID_ATTR_CHAR_LATIN_FONT: nWhich = EE_CHAR_FONTINFO; break;
141 0 : case SID_ATTR_CHAR_LATIN_LANGUAGE: nWhich = EE_CHAR_LANGUAGE; break;
142 0 : case SID_ATTR_CHAR_LATIN_POSTURE: nWhich = EE_CHAR_ITALIC; break;
143 0 : case SID_ATTR_CHAR_LATIN_WEIGHT: nWhich = EE_CHAR_WEIGHT; break;
144 :
145 : default:
146 0 : nWhich = _rPool.GetWhich( (SfxSlotId)_nAttributeId );
147 : }
148 0 : return nWhich;
149 : }
150 : }
151 :
152 0 : ::rtl::Reference< IAttributeHandler > AttributeHandlerFactory::getHandlerFor( AttributeId _nAttributeId, const SfxItemPool& _rEditEnginePool )
153 : {
154 0 : ::rtl::Reference< IAttributeHandler > pReturn;
155 0 : switch ( _nAttributeId )
156 : {
157 : case SID_ATTR_PARA_ADJUST_LEFT :
158 : case SID_ATTR_PARA_ADJUST_CENTER:
159 : case SID_ATTR_PARA_ADJUST_RIGHT :
160 : case SID_ATTR_PARA_ADJUST_BLOCK :
161 0 : pReturn = new ParaAlignmentHandler( _nAttributeId );
162 0 : break;
163 :
164 : case SID_ATTR_PARA_LINESPACE_10:
165 : case SID_ATTR_PARA_LINESPACE_15:
166 : case SID_ATTR_PARA_LINESPACE_20:
167 0 : pReturn = new LineSpacingHandler( _nAttributeId );
168 0 : break;
169 :
170 : case SID_SET_SUPER_SCRIPT:
171 : case SID_SET_SUB_SCRIPT:
172 0 : pReturn = new EscapementHandler( _nAttributeId );
173 0 : break;
174 :
175 : case SID_ATTR_CHAR_FONTHEIGHT:
176 : case SID_ATTR_CHAR_CTL_FONTHEIGHT:
177 : case SID_ATTR_CHAR_CJK_FONTHEIGHT:
178 : case SID_ATTR_CHAR_LATIN_FONTHEIGHT:
179 0 : pReturn = new FontSizeHandler( _nAttributeId, lcl_implGetWhich( _rEditEnginePool, _nAttributeId ) );
180 0 : break;
181 :
182 : case SID_ATTR_PARA_LEFT_TO_RIGHT:
183 : case SID_ATTR_PARA_RIGHT_TO_LEFT:
184 0 : pReturn = new ParagraphDirectionHandler( _nAttributeId );
185 0 : break;
186 :
187 : case SID_ATTR_PARA_HANGPUNCTUATION:
188 : case SID_ATTR_PARA_FORBIDDEN_RULES:
189 : case SID_ATTR_PARA_SCRIPTSPACE:
190 0 : pReturn = new BooleanHandler( _nAttributeId, lcl_implGetWhich( _rEditEnginePool, _nAttributeId ) );
191 0 : break;
192 :
193 : default:
194 0 : pReturn = new SlotHandler( (SfxSlotId)_nAttributeId, lcl_implGetWhich( _rEditEnginePool, _nAttributeId ) );
195 0 : break;
196 :
197 : }
198 :
199 0 : return pReturn;
200 : }
201 :
202 :
203 : //= ParaAlignmentHandler
204 :
205 :
206 0 : ParaAlignmentHandler::ParaAlignmentHandler( AttributeId _nAttributeId )
207 : :AttributeHandler( _nAttributeId, EE_PARA_JUST )
208 0 : ,m_eAdjust( SVX_ADJUST_CENTER )
209 : {
210 0 : switch ( getAttribute() )
211 : {
212 0 : case SID_ATTR_PARA_ADJUST_LEFT : m_eAdjust = SVX_ADJUST_LEFT; break;
213 0 : case SID_ATTR_PARA_ADJUST_CENTER: m_eAdjust = SVX_ADJUST_CENTER; break;
214 0 : case SID_ATTR_PARA_ADJUST_RIGHT : m_eAdjust = SVX_ADJUST_RIGHT; break;
215 0 : case SID_ATTR_PARA_ADJUST_BLOCK : m_eAdjust = SVX_ADJUST_BLOCK; break;
216 : default:
217 : OSL_FAIL( "ParaAlignmentHandler::ParaAlignmentHandler: invalid slot!" );
218 0 : break;
219 : }
220 0 : }
221 :
222 :
223 0 : AttributeCheckState ParaAlignmentHandler::implGetCheckState( const SfxPoolItem& _rItem ) const
224 : {
225 : OSL_ENSURE( _rItem.ISA( SvxAdjustItem ), "ParaAlignmentHandler::implGetCheckState: invalid pool item!" );
226 0 : SvxAdjust eAdjust = static_cast< const SvxAdjustItem& >( _rItem ).GetAdjust();
227 0 : return ( eAdjust == m_eAdjust ) ? eChecked : eUnchecked;
228 : }
229 :
230 :
231 0 : void ParaAlignmentHandler::executeAttribute( const SfxItemSet& /*_rCurrentAttribs*/, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType /*_nForScriptType*/ ) const
232 : {
233 : OSL_ENSURE( !_pAdditionalArg, "ParaAlignmentHandler::executeAttribute: this is a simple toggle attribute - no args possible!" );
234 : (void)_pAdditionalArg;
235 0 : _rNewAttribs.Put( SvxAdjustItem( m_eAdjust, getWhich() ) );
236 0 : }
237 :
238 :
239 : //= LineSpacingHandler
240 :
241 :
242 0 : LineSpacingHandler::LineSpacingHandler( AttributeId _nAttributeId )
243 : :AttributeHandler( _nAttributeId, EE_PARA_SBL )
244 0 : ,m_nLineSpace( 100 )
245 : {
246 0 : switch ( getAttribute() )
247 : {
248 0 : case SID_ATTR_PARA_LINESPACE_10: m_nLineSpace = 100; break;
249 0 : case SID_ATTR_PARA_LINESPACE_15: m_nLineSpace = 150; break;
250 0 : case SID_ATTR_PARA_LINESPACE_20: m_nLineSpace = 200; break;
251 : default:
252 : OSL_FAIL( "LineSpacingHandler::LineSpacingHandler: invalid slot!" );
253 0 : break;
254 : }
255 0 : }
256 :
257 :
258 0 : AttributeCheckState LineSpacingHandler::implGetCheckState( const SfxPoolItem& _rItem ) const
259 : {
260 : OSL_ENSURE( _rItem.ISA( SvxLineSpacingItem ), "LineSpacingHandler::implGetCheckState: invalid pool item!" );
261 0 : sal_uInt16 nLineSpace = static_cast< const SvxLineSpacingItem& >( _rItem ).GetPropLineSpace();
262 0 : return ( nLineSpace == m_nLineSpace ) ? eChecked : eUnchecked;
263 : }
264 :
265 :
266 0 : void LineSpacingHandler::executeAttribute( const SfxItemSet& /*_rCurrentAttribs*/, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType /*_nForScriptType*/ ) const
267 : {
268 : OSL_ENSURE( !_pAdditionalArg, "LineSpacingHandler::executeAttribute: this is a simple toggle attribute - no args possible!" );
269 : (void)_pAdditionalArg;
270 :
271 0 : SvxLineSpacingItem aLineSpacing( m_nLineSpace, getWhich() );
272 0 : aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
273 0 : if ( 100 == m_nLineSpace )
274 0 : aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
275 : else
276 0 : aLineSpacing.SetPropLineSpace( (sal_uInt8)m_nLineSpace );
277 :
278 0 : _rNewAttribs.Put( aLineSpacing );
279 0 : }
280 :
281 :
282 : //= EscapementHandler
283 :
284 :
285 0 : EscapementHandler::EscapementHandler( AttributeId _nAttributeId )
286 : :AttributeHandler( _nAttributeId, EE_CHAR_ESCAPEMENT )
287 0 : ,m_eEscapement( SVX_ESCAPEMENT_OFF )
288 : {
289 0 : switch ( getAttribute() )
290 : {
291 0 : case SID_SET_SUPER_SCRIPT : m_eEscapement = SVX_ESCAPEMENT_SUPERSCRIPT; break;
292 0 : case SID_SET_SUB_SCRIPT : m_eEscapement = SVX_ESCAPEMENT_SUBSCRIPT; break;
293 : default:
294 : OSL_FAIL( "EscapementHandler::EscapementHandler: invalid slot!" );
295 0 : break;
296 : }
297 0 : }
298 :
299 :
300 0 : AttributeCheckState EscapementHandler::implGetCheckState( const SfxPoolItem& _rItem ) const
301 : {
302 : OSL_ENSURE( _rItem.ISA( SvxEscapementItem ), "EscapementHandler::getState: invalid pool item!" );
303 0 : SvxEscapement eEscapement = static_cast< const SvxEscapementItem& >( _rItem ).GetEscapement();
304 0 : return ( eEscapement == m_eEscapement ) ? eChecked : eUnchecked;
305 : }
306 :
307 :
308 0 : void EscapementHandler::executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType /*_nForScriptType*/ ) const
309 : {
310 : OSL_ENSURE( !_pAdditionalArg, "EscapementHandler::executeAttribute: this is a simple toggle attribute - no args possible!" );
311 : // well, in theory we could allow an SvxEscapementItem here, but this is not needed
312 : (void)_pAdditionalArg;
313 :
314 0 : bool bIsChecked = getCheckState( _rCurrentAttribs ) == eChecked;
315 0 : _rNewAttribs.Put( SvxEscapementItem( bIsChecked ? SVX_ESCAPEMENT_OFF : m_eEscapement, getWhich() ) );
316 0 : }
317 :
318 :
319 : //= SlotHandler
320 :
321 :
322 0 : SlotHandler::SlotHandler( AttributeId _nAttributeId, WhichId _nWhichId )
323 : :AttributeHandler( _nAttributeId, _nWhichId )
324 0 : ,m_bScriptDependent( false )
325 : {
326 : m_bScriptDependent = ( SID_ATTR_CHAR_WEIGHT == _nAttributeId )
327 0 : || ( SID_ATTR_CHAR_POSTURE == _nAttributeId )
328 0 : || ( SID_ATTR_CHAR_FONT == _nAttributeId );
329 0 : }
330 :
331 :
332 0 : AttributeState SlotHandler::getState( const SfxItemSet& _rAttribs ) const
333 : {
334 0 : AttributeState aState( eIndetermined );
335 :
336 0 : const SfxPoolItem* pItem = _rAttribs.GetItem( getWhich() );
337 0 : if ( pItem )
338 0 : aState.setItem( pItem->Clone() );
339 :
340 0 : return aState;
341 : }
342 :
343 :
344 0 : void SlotHandler::executeAttribute( const SfxItemSet& /*_rCurrentAttribs*/, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const
345 : {
346 0 : if ( _pAdditionalArg )
347 : {
348 0 : SfxPoolItem* pCorrectWich = _pAdditionalArg->Clone();
349 0 : pCorrectWich->SetWhich( getWhich() );
350 :
351 0 : if ( m_bScriptDependent )
352 0 : putItemForScript( _rNewAttribs, *pCorrectWich, _nForScriptType );
353 : else
354 0 : _rNewAttribs.Put( *pCorrectWich );
355 0 : DELETEZ( pCorrectWich );
356 : }
357 : else
358 : OSL_FAIL( "SlotHandler::executeAttribute: need attributes to do something!" );
359 0 : }
360 :
361 :
362 : //= FontSizeHandler
363 :
364 :
365 0 : FontSizeHandler::FontSizeHandler( AttributeId _nAttributeId, WhichId _nWhichId )
366 0 : :AttributeHandler( _nAttributeId, _nWhichId )
367 : {
368 : OSL_ENSURE( ( _nAttributeId == SID_ATTR_CHAR_FONTHEIGHT ) || ( _nAttributeId == SID_ATTR_CHAR_CTL_FONTHEIGHT )
369 : || ( _nAttributeId == SID_ATTR_CHAR_CJK_FONTHEIGHT ) || ( _nAttributeId == SID_ATTR_CHAR_LATIN_FONTHEIGHT ),
370 : "FontSizeHandler::FontSizeHandler: invalid attribute id!" );
371 0 : }
372 :
373 :
374 0 : AttributeState FontSizeHandler::getState( const SfxItemSet& _rAttribs ) const
375 : {
376 0 : AttributeState aState( eIndetermined );
377 :
378 0 : const SfxPoolItem* pItem = _rAttribs.GetItem( getWhich() );
379 0 : const SvxFontHeightItem* pFontHeightItem = PTR_CAST( SvxFontHeightItem, pItem );
380 : OSL_ENSURE( pFontHeightItem || !pItem, "FontSizeHandler::getState: invalid item!" );
381 0 : if ( pFontHeightItem )
382 : {
383 : // by definition, the item should have the unit twip
384 0 : sal_uLong nHeight = pFontHeightItem->GetHeight();
385 0 : if ( _rAttribs.GetPool()->GetMetric( getWhich() ) != SFX_MAPUNIT_TWIP )
386 : {
387 : nHeight = OutputDevice::LogicToLogic(
388 : Size( 0, nHeight ),
389 0 : MapMode( (MapUnit)( _rAttribs.GetPool()->GetMetric( getWhich() ) ) ),
390 : MapMode( MAP_TWIP )
391 0 : ).Height();
392 : }
393 :
394 0 : SvxFontHeightItem* pNewItem = new SvxFontHeightItem( nHeight, 100, getWhich() );
395 0 : pNewItem->SetProp( pFontHeightItem->GetProp(), pFontHeightItem->GetPropUnit() );
396 0 : aState.setItem( pNewItem );
397 : }
398 :
399 0 : return aState;
400 : }
401 :
402 :
403 0 : void FontSizeHandler::executeAttribute( const SfxItemSet& /*_rCurrentAttribs*/, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const
404 : {
405 0 : const SvxFontHeightItem* pFontHeightItem = PTR_CAST( SvxFontHeightItem, _pAdditionalArg );
406 : OSL_ENSURE( pFontHeightItem, "FontSizeHandler::executeAttribute: need a FontHeightItem!" );
407 :
408 0 : if ( pFontHeightItem )
409 : {
410 : // correct measurement units
411 0 : SfxMapUnit eItemMapUnit = pFontHeightItem->GetPropUnit(); (void)eItemMapUnit;
412 0 : sal_uLong nHeight = pFontHeightItem->GetHeight();
413 0 : if ( _rNewAttribs.GetPool()->GetMetric( getWhich() ) != SFX_MAPUNIT_TWIP )
414 : {
415 : nHeight = OutputDevice::LogicToLogic(
416 : Size( 0, nHeight ),
417 : MapMode( (MapUnit)( SFX_MAPUNIT_TWIP ) ),
418 0 : MapMode( (MapUnit)( _rNewAttribs.GetPool()->GetMetric( getWhich() ) ) )
419 0 : ).Height();
420 : }
421 :
422 0 : SvxFontHeightItem aNewItem( nHeight, 100, getWhich() );
423 0 : aNewItem.SetProp( pFontHeightItem->GetProp(), pFontHeightItem->GetPropUnit() );
424 :
425 0 : if ( ( getAttributeId() == SID_ATTR_CHAR_FONTHEIGHT ) && _nForScriptType )
426 0 : putItemForScript( _rNewAttribs, aNewItem, _nForScriptType );
427 : else
428 0 : _rNewAttribs.Put( aNewItem );
429 : }
430 0 : }
431 :
432 :
433 : //= ParagraphDirectionHandler
434 :
435 :
436 0 : ParagraphDirectionHandler::ParagraphDirectionHandler( AttributeId _nAttributeId )
437 : :AttributeHandler( _nAttributeId, EE_PARA_WRITINGDIR )
438 : ,m_eParagraphDirection( FRMDIR_HORI_LEFT_TOP )
439 : ,m_eDefaultAdjustment( SVX_ADJUST_RIGHT )
440 0 : ,m_eOppositeDefaultAdjustment( SVX_ADJUST_LEFT )
441 : {
442 0 : switch ( getAttributeId() )
443 : {
444 0 : case SID_ATTR_PARA_LEFT_TO_RIGHT: m_eParagraphDirection = FRMDIR_HORI_LEFT_TOP; m_eDefaultAdjustment = SVX_ADJUST_LEFT; break;
445 0 : case SID_ATTR_PARA_RIGHT_TO_LEFT: m_eParagraphDirection = FRMDIR_HORI_RIGHT_TOP; m_eDefaultAdjustment = SVX_ADJUST_RIGHT; break;
446 : default:
447 : OSL_FAIL( "ParagraphDirectionHandler::ParagraphDirectionHandler: invalid attribute id!" );
448 : }
449 :
450 0 : if ( SVX_ADJUST_RIGHT == m_eDefaultAdjustment )
451 0 : m_eOppositeDefaultAdjustment = SVX_ADJUST_LEFT;
452 : else
453 0 : m_eOppositeDefaultAdjustment = SVX_ADJUST_RIGHT;
454 0 : }
455 :
456 :
457 0 : AttributeCheckState ParagraphDirectionHandler::implGetCheckState( const SfxPoolItem& _rItem ) const
458 : {
459 : OSL_ENSURE( _rItem.ISA( SvxFrameDirectionItem ), "ParagraphDirectionHandler::implGetCheckState: invalid pool item!" );
460 0 : SvxFrameDirection eDirection = static_cast< SvxFrameDirection >( static_cast< const SvxFrameDirectionItem& >( _rItem ).GetValue() );
461 0 : return ( eDirection == m_eParagraphDirection ) ? eChecked : eUnchecked;
462 : }
463 :
464 :
465 0 : void ParagraphDirectionHandler::executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* /*_pAdditionalArg*/, ScriptType /*_nForScriptType*/ ) const
466 : {
467 0 : _rNewAttribs.Put( SvxFrameDirectionItem( m_eParagraphDirection, getWhich() ) );
468 :
469 : // if the current adjustment of the was the default adjustment for the *previous* text direction,
470 : // then we toggle the adjustment, too
471 0 : SvxAdjust eCurrentAdjustment = SVX_ADJUST_LEFT;
472 0 : const SfxPoolItem* pCurrentAdjustment = NULL;
473 0 : if ( SFX_ITEM_ON == _rCurrentAttribs.GetItemState( EE_PARA_JUST, true, &pCurrentAdjustment ) )
474 0 : eCurrentAdjustment = static_cast< const SvxAdjustItem* >( pCurrentAdjustment )->GetAdjust();
475 :
476 0 : if ( eCurrentAdjustment == m_eOppositeDefaultAdjustment )
477 0 : _rNewAttribs.Put( SvxAdjustItem( m_eDefaultAdjustment, EE_PARA_JUST ) );
478 0 : }
479 :
480 :
481 : //= BooleanHandler
482 :
483 :
484 0 : BooleanHandler::BooleanHandler( AttributeId _nAttributeId, WhichId _nWhichId )
485 0 : :AttributeHandler( _nAttributeId, _nWhichId )
486 : {
487 0 : }
488 :
489 :
490 0 : AttributeCheckState BooleanHandler::implGetCheckState( const SfxPoolItem& _rItem ) const
491 : {
492 : OSL_ENSURE( _rItem.ISA( SfxBoolItem ), "BooleanHandler::implGetCheckState: invalid item!" );
493 0 : if ( _rItem.ISA( SfxBoolItem ) )
494 0 : return static_cast< const SfxBoolItem& >( _rItem ).GetValue() ? eChecked : eUnchecked;
495 :
496 0 : return eIndetermined;
497 : }
498 :
499 :
500 0 : void BooleanHandler::executeAttribute( const SfxItemSet& /*_rCurrentAttribs*/, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType /*_nForScriptType*/ ) const
501 : {
502 : OSL_ENSURE( _pAdditionalArg && _pAdditionalArg->ISA( SfxBoolItem ), "BooleanHandler::executeAttribute: invalid argument!" );
503 0 : if ( _pAdditionalArg )
504 : {
505 0 : SfxPoolItem* pCorrectWich = _pAdditionalArg->Clone();
506 0 : pCorrectWich->SetWhich( getWhich() );
507 0 : _rNewAttribs.Put( *pCorrectWich );
508 0 : DELETEZ( pCorrectWich );
509 : }
510 0 : }
511 :
512 :
513 : } // namespace frm
514 :
515 :
516 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|