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