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