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