xref: /aoo41x/main/sw/source/ui/shells/txtattr.cxx (revision cdf0e10c)
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_sw.hxx"
30 
31 
32 #include <hintids.hxx>
33 
34 #ifndef _MSGBOX_HXX //autogen
35 #include <vcl/msgbox.hxx>
36 #endif
37 #include <svl/whiter.hxx>
38 #include <svl/stritem.hxx>
39 #include <svl/itemiter.hxx>
40 #include <svl/ctloptions.hxx>
41 #include <swmodule.hxx>
42 #include <sfx2/bindings.hxx>
43 #include <sfx2/request.hxx>
44 #include <editeng/fhgtitem.hxx>
45 #include <editeng/adjitem.hxx>
46 #include <editeng/lspcitem.hxx>
47 #include <editeng/udlnitem.hxx>
48 #include <editeng/escpitem.hxx>
49 #include <svx/htmlmode.hxx>
50 #include <editeng/scripttypeitem.hxx>
51 #include <editeng/frmdiritem.hxx>
52 #include "paratr.hxx"
53 
54 #include <fmtinfmt.hxx>
55 #ifndef _DOCSH_HXX
56 #include <docsh.hxx>
57 #endif
58 #include <wrtsh.hxx>
59 #ifndef _VIEW_HXX
60 #include <view.hxx>
61 #endif
62 #include <viewopt.hxx>
63 #include <uitool.hxx>
64 #ifndef _TEXTSH_HXX
65 #include <textsh.hxx>
66 #endif
67 #include <num.hxx>
68 #include <swundo.hxx>
69 #include <fmtcol.hxx>
70 
71 #ifndef _CMDID_H
72 #include <cmdid.h>
73 #endif
74 #include <globals.h>
75 #ifndef _SHELLS_HRC
76 #include <shells.hrc>
77 #endif
78 #include <SwStyleNameMapper.hxx>
79 #include "swabstdlg.hxx"
80 #include "chrdlg.hrc"
81 const SwTwips lFontInc = 2 * 20;		   // ==> PointToTwips(2)
82 const SwTwips lFontMaxSz = 72 * 20; 	   // ==> PointToTwips(72)
83 
84 
85 
86 
87 void SwTextShell::ExecCharAttr(SfxRequest &rReq)
88 {
89 	SwWrtShell &rSh = GetShell();
90 	const SfxItemSet  *pArgs   = rReq.GetArgs();
91 		  int          eState = STATE_TOGGLE;
92 	sal_uInt16 nWhich = rReq.GetSlot();
93 
94 	if(pArgs )
95 	{
96 		const SfxPoolItem* pItem;
97 		pArgs->GetItemState(nWhich, sal_False, &pItem);
98 		eState =  ((const SfxBoolItem &) pArgs->
99 								Get( nWhich )).GetValue() ? STATE_ON : STATE_OFF;
100 	}
101 
102 
103 	SfxItemSet aSet( GetPool(), RES_CHRATR_BEGIN, RES_CHRATR_END-1 );
104 	if (STATE_TOGGLE == eState)
105         rSh.GetCurAttr( aSet );
106 
107 	switch ( nWhich )
108 	{
109 		case FN_SET_SUB_SCRIPT:
110 		case FN_SET_SUPER_SCRIPT:
111 		{
112             SvxEscapement eEscape = SVX_ESCAPEMENT_SUBSCRIPT;
113 			switch (eState)
114 			{
115 			case STATE_TOGGLE:
116 			{
117 				short nTmpEsc = ((const SvxEscapementItem&)
118 							aSet.Get( RES_CHRATR_ESCAPEMENT )).GetEsc();
119 				eEscape = nWhich == FN_SET_SUPER_SCRIPT ?
120 								SVX_ESCAPEMENT_SUPERSCRIPT:
121 								SVX_ESCAPEMENT_SUBSCRIPT;
122 				if( (nWhich == FN_SET_SUB_SCRIPT && nTmpEsc < 0) ||
123 							(nWhich == FN_SET_SUPER_SCRIPT && nTmpEsc > 0) )
124 					eEscape = SVX_ESCAPEMENT_OFF;
125 
126 				SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
127 				if( nWhich == FN_SET_SUB_SCRIPT )
128 					rBind.SetState( SfxBoolItem( FN_SET_SUPER_SCRIPT,
129 																	sal_False ) );
130 				else
131 					rBind.SetState( SfxBoolItem( FN_SET_SUB_SCRIPT,
132 																	sal_False ) );
133 
134 			}
135 			break;
136 			case STATE_ON:
137 				eEscape = nWhich == FN_SET_SUPER_SCRIPT ?
138 								SVX_ESCAPEMENT_SUPERSCRIPT:
139 								SVX_ESCAPEMENT_SUBSCRIPT;
140 				break;
141 			case STATE_OFF:
142 				eEscape = SVX_ESCAPEMENT_OFF;
143 				break;
144 			}
145             SvxEscapementItem aEscape( eEscape, RES_CHRATR_ESCAPEMENT );
146 			if(eEscape == SVX_ESCAPEMENT_SUPERSCRIPT)
147 				aEscape.GetEsc() = DFLT_ESC_AUTO_SUPER;
148 			else if(eEscape == SVX_ESCAPEMENT_SUBSCRIPT)
149 				aEscape.GetEsc() = DFLT_ESC_AUTO_SUB;
150 			if(eState != STATE_OFF )
151 			{
152 				if(eEscape == FN_SET_SUPER_SCRIPT)
153 					aEscape.GetEsc() *= -1;
154 			}
155 			rSh.SetAttr( aEscape );
156             rReq.AppendItem( aEscape );
157             rReq.Done();
158 		}
159 		break;
160 
161 		case FN_UPDATE_STYLE_BY_EXAMPLE:
162 			rSh.QuickUpdateStyle();
163             rReq.Done();
164 			break;
165 		case FN_UNDERLINE_DOUBLE:
166 		{
167 			FontUnderline eUnderline =  ((const SvxUnderlineItem&)
168 							aSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle();
169 			switch( eState )
170 			{
171 				case STATE_TOGGLE:
172 					eUnderline = eUnderline == UNDERLINE_DOUBLE ?
173 						UNDERLINE_NONE :
174 							UNDERLINE_DOUBLE;
175 				break;
176 				case STATE_ON:
177 					eUnderline = UNDERLINE_DOUBLE;
178 				break;
179 				case STATE_OFF:
180 					eUnderline = UNDERLINE_NONE;
181 				break;
182 			}
183             SvxUnderlineItem aUnderline(eUnderline, RES_CHRATR_UNDERLINE );
184             rSh.SetAttr( aUnderline );
185             rReq.AppendItem( aUnderline );
186             rReq.Done();
187 		}
188 		break;
189         case FN_REMOVE_DIRECT_CHAR_FORMATS:
190             if( !rSh.HasReadonlySel() && rSh.IsEndPara())
191                 rSh.DontExpandFmt();
192         break;
193 		default:
194 			ASSERT(sal_False, falscher Dispatcher);
195 			return;
196 	}
197 }
198 
199 
200 void SwTextShell::ExecCharAttrArgs(SfxRequest &rReq)
201 {
202     sal_uInt16 nSlot = rReq.GetSlot();
203 	const SfxItemSet* pArgs = rReq.GetArgs();
204 	sal_Bool bArgs = pArgs != 0 && pArgs->Count() > 0;
205 	int bGrow = sal_False;
206 	SwWrtShell& rWrtSh = GetShell();
207 	SwTxtFmtColl* pColl = 0;
208 
209 	// nur gesetzt, wenn gesamter Absatz selektiert ist und AutoUpdateFmt gesetzt ist
210 	if( rWrtSh.HasSelection() && rWrtSh.IsSelFullPara() )
211 	{
212 		pColl = rWrtSh.GetCurTxtFmtColl();
213 		if(pColl && !pColl->IsAutoUpdateFmt())
214 			pColl = 0;
215 	}
216 	SfxItemPool& rPool = GetPool();
217 	sal_uInt16 nWhich = rPool.GetWhich(nSlot);
218 	switch ( nSlot )
219 	{
220 		case FN_TXTATR_INET:
221 		// Sonderbehandlung der PoolId des SwFmtInetFmt
222 		if(bArgs)
223 		{
224 			const SfxPoolItem& rItem = pArgs->Get(nWhich );
225 
226 			SwFmtINetFmt aINetFmt((const SwFmtINetFmt&)rItem);
227 			if( USHRT_MAX == aINetFmt.GetVisitedFmtId() )
228 			{
229 				aINetFmt.SetVisitedFmtId(
230 						SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetVisitedFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT));
231 			}
232 			if( USHRT_MAX == aINetFmt.GetINetFmtId() )
233 			{
234 				aINetFmt.SetINetFmtId(
235 						SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetINetFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT));
236 			}
237 
238 			if ( pColl )
239                 pColl->SetFmtAttr( aINetFmt );
240 			else rWrtSh.SetAttr( aINetFmt );
241             rReq.Done();
242 		}
243 		break;
244 
245 		case FN_GROW_FONT_SIZE:
246 			bGrow = sal_True;
247 			// kein break !!
248 		case FN_SHRINK_FONT_SIZE:
249 		{
250 			SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, rPool );
251             rWrtSh.GetCurAttr( aSetItem.GetItemSet() );
252 			SfxItemSet aAttrSet( rPool, aSetItem.GetItemSet().GetRanges() );
253 
254 			const SfxPoolItem* pI;
255 			static const sal_uInt16 aScrTypes[] = {
256 				SCRIPTTYPE_LATIN, SCRIPTTYPE_ASIAN, SCRIPTTYPE_COMPLEX, 0 };
257 			sal_uInt16 nScriptType = rWrtSh.GetScriptType();
258 			for( const sal_uInt16* pScrpTyp = aScrTypes; *pScrpTyp; ++pScrpTyp )
259 				if( ( nScriptType & *pScrpTyp ) &&
260 					0 != ( pI = aSetItem.GetItemOfScript( *pScrpTyp )))
261 				{
262 					SvxFontHeightItem aSize( *(const SvxFontHeightItem*)pI );
263 					SwTwips lSize = (SwTwips) aSize.GetHeight();
264 
265 					if (bGrow)
266 					{
267 						if( lSize == lFontMaxSz )
268 							break;		// das wars, hoeher gehts nicht
269 						if( ( lSize += lFontInc ) > lFontMaxSz )
270 							lSize = lFontMaxSz;
271 					}
272 					else
273 					{
274 						if( 4 == lSize )
275 							break;
276 						if( ( lSize -= lFontInc ) < 4 )
277 							lSize = 4;
278 					}
279 					aSize.SetHeight( lSize );
280 					aAttrSet.Put( aSize );
281 				}
282 				if( aAttrSet.Count() )
283 				{
284 					if( pColl )
285                         pColl->SetFmtAttr( aAttrSet );
286 					else
287 						rWrtSh.SetAttr( aAttrSet );
288 				}
289             rReq.Done();
290 		}
291 		break;
292 
293 		default:
294 			ASSERT(sal_False, falscher Dispatcher);
295 			return;
296 	}
297 }
298 
299 
300 
301 #ifdef CFRONT
302 
303 void lcl_SetAdjust(SvxAdjust eAdjst, SfxItemSet& rSet)
304 {
305 	rSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST ));
306 }
307 
308 
309 
310 void lcl_SetLineSpace(sal_uInt8 ePropL,SfxItemSet& rSet)
311 {
312 	SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING );
313 	aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
314 	if( 100 == ePropL )
315 		aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
316 	else
317 		aLineSpacing.SetPropLineSpace(ePropL);
318 	rSet.Put( aLineSpacing );
319 }
320 
321 
322 
323 void SwTextShell::ExecParaAttr(SfxRequest &rReq)
324 {
325 	// gleiche beide Attribute holen, ist nicht teuerer !!
326 	SfxItemSet aSet( GetPool(), RES_PARATR_LINESPACING, RES_PARATR_ADJUST );
327 
328 	switch (rReq.GetSlot())
329 	{
330 	case FN_SET_LEFT_PARA:			lcl_SetAdjust(ADJLEFT,aSet); 	break;
331 	case FN_SET_RIGHT_PARA:			lcl_SetAdjust(ADJRIGHT,aSet); 	break;
332 	case FN_SET_CENTER_PARA:        lcl_SetAdjust(ADJCENTER,aSet); 	break;
333 	case SID_ATTR_PARA_ADJUST_BLOCK:lcl_SetAdjust(ADJBLOCK,aSet); 	break;
334 
335 	case FN_SET_LINE_SPACE_1:	lcl_SetLineSpace(100,aSet); 	break;
336 	case FN_SET_LINE_SPACE_15:  lcl_SetLineSpace(150,aSet); 	break;
337 	case FN_SET_LINE_SPACE_2:	lcl_SetLineSpace(200,aSet); 	break;
338 
339 	default:
340 		DBG_ERROR("SwTextShell::ExecParaAttr falscher Dispatcher");
341 		return;
342 	}
343 	SwWrtShell& rWrtSh = GetShell();
344 	SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
345 	if(pColl && pColl->IsAutoUpdateFmt())
346 	{
347 		rWrtSh.AutoUpdatePara(pColl, *pSet);
348 	}
349 	else
350     {
351 		rWrtSh.SetAttr( aSet );
352         rReq.Done( aSet );
353     }
354 }
355 
356 #else
357 
358 
359 
360 void SwTextShell::ExecParaAttr(SfxRequest &rReq)
361 {
362 	SvxAdjust eAdjst;
363 	sal_uInt8 ePropL;
364 	const SfxItemSet* pArgs = rReq.GetArgs();
365 
366 	// gleich beide Attribute holen, ist nicht teuerer !!
367     SfxItemSet aSet( GetPool(),
368         RES_PARATR_LINESPACING, RES_PARATR_ADJUST,
369         RES_FRAMEDIR, RES_FRAMEDIR,
370         0 );
371 
372 	sal_uInt16 nSlot = rReq.GetSlot();
373 	switch (nSlot)
374 	{
375 		case SID_ATTR_PARA_ADJUST:
376 		{
377 			if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_PARATR_ADJUST) )
378 			{
379 				const SvxAdjustItem& rAdj = (const SvxAdjustItem&) pArgs->Get(RES_PARATR_ADJUST);
380 				SvxAdjustItem aAdj( rAdj.GetAdjust(), RES_PARATR_ADJUST );
381 				if ( rAdj.GetAdjust() == SVX_ADJUST_BLOCK )
382 				{
383 					aAdj.SetLastBlock( rAdj.GetLastBlock() );
384 					aAdj.SetOneWord( rAdj.GetOneWord() );
385 				}
386 
387 				aSet.Put(aAdj);
388 			}
389 		}
390 		break;
391 		case SID_ATTR_PARA_ADJUST_LEFT:		eAdjst =  SVX_ADJUST_LEFT;		goto SET_ADJUST;
392 		case SID_ATTR_PARA_ADJUST_RIGHT:	eAdjst =  SVX_ADJUST_RIGHT;		goto SET_ADJUST;
393 		case SID_ATTR_PARA_ADJUST_CENTER:   eAdjst =  SVX_ADJUST_CENTER;	goto SET_ADJUST;
394 		case SID_ATTR_PARA_ADJUST_BLOCK:	eAdjst =  SVX_ADJUST_BLOCK;		goto SET_ADJUST;
395 SET_ADJUST:
396 		{
397 			aSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST));
398             rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), sal_True ) );
399 		}
400 		break;
401 
402 		case SID_ATTR_PARA_LINESPACE:
403 			if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( GetPool().GetWhich(nSlot) ))
404 			{
405 				SvxLineSpacingItem aLineSpace = (const SvxLineSpacingItem&)pArgs->Get(
406 															GetPool().GetWhich(nSlot));
407 				aSet.Put( aLineSpace );
408 			}
409 		break;
410 		case SID_ATTR_PARA_LINESPACE_10:	ePropL = 100;	goto SET_LINESPACE;
411 		case SID_ATTR_PARA_LINESPACE_15:	ePropL = 150;	goto SET_LINESPACE;
412 		case SID_ATTR_PARA_LINESPACE_20:	ePropL = 200;	goto SET_LINESPACE;
413 
414 SET_LINESPACE:
415 		{
416 
417 			SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING );
418 			aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
419 			if( 100 == ePropL )
420 				aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
421 			else
422 				aLineSpacing.SetPropLineSpace(ePropL);
423 			aSet.Put( aLineSpacing );
424 		}
425 		break;
426 
427         case SID_ATTR_PARA_LEFT_TO_RIGHT :
428         case SID_ATTR_PARA_RIGHT_TO_LEFT :
429         {
430             sal_Bool bSet = sal_True;
431             int eState = pArgs ? pArgs->GetItemState(nSlot) : SFX_ITEM_DISABLED;
432             if (pArgs && SFX_ITEM_SET == eState)
433                 bSet = ((const SfxBoolItem&)pArgs->Get(nSlot)).GetValue();
434 /*
435 // toggling of the slots not used anymore
436 
437            if(!bSet)
438 				nSlot = SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot ?
439 					SID_ATTR_PARA_RIGHT_TO_LEFT :
440 					SID_ATTR_PARA_LEFT_TO_RIGHT;
441 */
442             SfxItemSet aAdjustSet( GetPool(),
443                     RES_PARATR_ADJUST, RES_PARATR_ADJUST );
444             GetShell().GetCurAttr(aAdjustSet);
445             sal_Bool bChgAdjust = sal_False;
446             SfxItemState eAdjustState = aAdjustSet.GetItemState(RES_PARATR_ADJUST, sal_False);
447             if(eAdjustState  >= SFX_ITEM_DEFAULT)
448             {
449                 int eAdjust = (int)(( const SvxAdjustItem& )
450 						aAdjustSet.Get(RES_PARATR_ADJUST)).GetAdjust();
451 //                bChgAdjust = SVX_ADJUST_CENTER  != eAdjust  &&  SVX_ADJUST_BLOCK != eAdjust;
452                 bChgAdjust = (SVX_ADJUST_LEFT  == eAdjust  &&  SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot) ||
453                              (SVX_ADJUST_RIGHT == eAdjust  &&  SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot);
454             }
455             else
456                 bChgAdjust = sal_True;
457 
458             SvxFrameDirection eFrmDirection =
459                     (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
460                         FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
461             aSet.Put( SvxFrameDirectionItem( eFrmDirection, RES_FRAMEDIR ) );
462 
463             if (bChgAdjust)
464             {
465                 SvxAdjust eAdjust = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
466                         SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT;
467                 SvxAdjustItem aAdjust( eAdjust, RES_PARATR_ADJUST );
468                 aSet.Put( aAdjust );
469                 aAdjust.SetWhich(SID_ATTR_PARA_ADJUST);
470                 GetView().GetViewFrame()->GetBindings().SetState( aAdjust );
471                 // Toggle numbering alignment
472                 const SwNumRule* pCurRule = GetShell().GetCurNumRule();
473                 if( pCurRule )
474                 {
475                     SvxNumRule aRule = pCurRule->MakeSvxNumRule();
476 
477                     for(sal_uInt16 i = 0; i < aRule.GetLevelCount(); i++)
478                     {
479                         SvxNumberFormat aFmt(aRule.GetLevel(i));
480                         if(SVX_ADJUST_LEFT == aFmt.GetNumAdjust())
481                             aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
482 
483                         else if(SVX_ADJUST_RIGHT == aFmt.GetNumAdjust())
484                             aFmt.SetNumAdjust( SVX_ADJUST_LEFT );
485 
486                         aRule.SetLevel(i, aFmt, aRule.Get(i) != 0);
487                     }
488                     // --> OD 2008-02-11 #newlistlevelattrs#
489                     SwNumRule aSetRule( pCurRule->GetName(),
490                                         pCurRule->Get( 0 ).GetPositionAndSpaceMode() );
491                     // <--
492                     aSetRule.SetSvxRule( aRule, GetShell().GetDoc());
493                     aSetRule.SetAutoRule( sal_True );
494                     // --> OD 2008-03-17 #refactorlists#
495                     // no start or continuation of a list - list style is only changed
496                     GetShell().SetCurNumRule( aSetRule, false );
497                     // <--
498                 }
499             }
500         }
501         break;
502 
503 		default:
504 			ASSERT(sal_False, falscher Dispatcher);
505 			return;
506 	}
507 	SwWrtShell& rWrtSh = GetShell();
508 	SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
509 	if(pColl && pColl->IsAutoUpdateFmt())
510 	{
511 		rWrtSh.AutoUpdatePara(pColl, aSet);
512 	}
513 	else
514 		rWrtSh.SetAttr( aSet );
515     rReq.Done();
516 }
517 
518 #endif
519 
520 
521 
522 void SwTextShell::ExecParaAttrArgs(SfxRequest &rReq)
523 {
524 	SwWrtShell &rSh = GetShell();
525 	const SfxItemSet *pArgs = rReq.GetArgs();
526 	const SfxPoolItem *pItem = 0;
527 
528 	sal_uInt16 nSlot = rReq.GetSlot();
529 	if(pArgs)
530 		pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem);
531 	switch ( nSlot )
532 	{
533         case FN_DROP_CHAR_STYLE_NAME:
534             if( pItem )
535             {
536                 String sCharStyleName = ((const SfxStringItem*)pItem)->GetValue();
537                 SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP, 0L);
538                 rSh.GetCurAttr(aSet);
539                 SwFmtDrop aDropItem((const SwFmtDrop&)aSet.Get(RES_PARATR_DROP));
540                 SwCharFmt* pFmt = 0;
541                 if(sCharStyleName.Len())
542                     pFmt = rSh.FindCharFmtByName( sCharStyleName );
543                 aDropItem.SetCharFmt( pFmt );
544                 aSet.Put(aDropItem);
545                 rSh.SetAttr(aSet);
546             }
547         break;
548         case FN_FORMAT_DROPCAPS:
549         {
550 			if(pItem)
551             {
552 				rSh.SetAttr(*pItem);
553                 rReq.Done();
554             }
555 			else
556 			{
557 				SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP,
558 										   HINT_END, HINT_END, 0);
559                 rSh.GetCurAttr(aSet);
560                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
561                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
562 
563                 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aSet,
564 					rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), DLG_SWDROPCAPS );
565                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
566 				if (pDlg->Execute() == RET_OK)
567 				{
568 					rSh.StartAction();
569 					rSh.StartUndo( UNDO_START );
570 					if ( SFX_ITEM_SET == aSet.GetItemState(HINT_END,sal_False,&pItem) )
571 					{
572 						if ( ((SfxStringItem*)pItem)->GetValue().Len() )
573 							rSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue());
574 					}
575 					rSh.SetAttr(*pDlg->GetOutputItemSet());
576 					rSh.StartUndo( UNDO_END );
577 					rSh.EndAction();
578                     rReq.Done(*pDlg->GetOutputItemSet());
579 				}
580 				delete pDlg;
581 			}
582 		}
583  		break;
584 		case SID_ATTR_PARA_PAGEBREAK:
585 			if(pItem)
586 			{
587 				rSh.SetAttr( *pItem );
588                 rReq.Done();
589 			}
590 		break;
591 		case SID_ATTR_PARA_MODEL:
592 		{
593 			if(pItem)
594 			{
595 				SfxItemSet aCoreSet( GetPool(),
596 					RES_PAGEDESC,	RES_PAGEDESC,
597 					SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL, 0);
598 				aCoreSet.Put(*pItem);
599 				SfxToSwPageDescAttr( rSh, aCoreSet);
600 				rSh.SetAttr(aCoreSet);
601                 rReq.Done();
602 			}
603 		}
604 		break;
605 
606         default:
607 			ASSERT(sal_False, falscher Dispatcher);
608 			return;
609 	}
610 }
611 
612 
613 
614 void SwTextShell::GetAttrState(SfxItemSet &rSet)
615 {
616 	SwWrtShell &rSh = GetShell();
617 	SfxItemPool& rPool = GetPool();
618 	SfxItemSet aCoreSet(rPool, aTxtFmtCollSetRange);
619     rSh.GetCurAttr(aCoreSet); // *alle* Textattribute von der Core erfragen
620 
621 	SfxWhichIter aIter(rSet);
622 	sal_uInt16 nSlot = aIter.FirstWhich();
623     sal_Bool bFlag = sal_False;
624 	SfxBoolItem aFlagItem;
625 	const SfxPoolItem* pItem = 0;
626 	int eAdjust = -1;	// Illegaler Wert, um DONTCARE zu erkennen
627 	SfxItemState eState = aCoreSet.GetItemState(RES_PARATR_ADJUST, sal_False, &pItem);
628 
629 	if( SFX_ITEM_DEFAULT == eState )
630 		pItem = &rPool.GetDefaultItem(RES_PARATR_ADJUST);
631 	if( SFX_ITEM_DEFAULT <= eState )
632 		eAdjust = (int)(( SvxAdjustItem* ) pItem)->GetAdjust();
633 
634 	short nEsc = 0;
635 	eState =  aCoreSet.GetItemState(RES_CHRATR_ESCAPEMENT, sal_False, &pItem);
636 	if( SFX_ITEM_DEFAULT == eState )
637 		pItem = &rPool.GetDefaultItem(RES_CHRATR_ESCAPEMENT);
638 	if( eState >= SFX_ITEM_DEFAULT )
639 		nEsc = ((SvxEscapementItem* )pItem)->GetEsc();
640 
641 	sal_uInt16 nLineSpace = 0;
642 	eState =  aCoreSet.GetItemState(RES_PARATR_LINESPACING, sal_False, &pItem);
643 	if( SFX_ITEM_DEFAULT == eState )
644 		pItem = &rPool.GetDefaultItem(RES_PARATR_LINESPACING);
645 	if( SFX_ITEM_DEFAULT <= eState &&
646 			((SvxLineSpacingItem* )pItem)->GetLineSpaceRule() == SVX_LINE_SPACE_AUTO )
647 	{
648 		if(SVX_INTER_LINE_SPACE_OFF ==
649 					((SvxLineSpacingItem* )pItem)->GetInterLineSpaceRule())
650 			nLineSpace = 100;
651 		else
652 			nLineSpace = ((SvxLineSpacingItem* )pItem)->GetPropLineSpace();
653 	}
654 
655 	while (nSlot)
656 	{
657 		switch(nSlot)
658 		{
659 			case FN_SET_SUPER_SCRIPT:
660 					bFlag = 0 < nEsc;
661 				break;
662 			case FN_SET_SUB_SCRIPT:
663 					bFlag = 0 > nEsc;
664 				break;
665 			case SID_ATTR_PARA_ADJUST_LEFT:
666 				if (eAdjust == -1)
667 				{
668 					rSet.InvalidateItem( nSlot );
669 					nSlot = 0;
670 				}
671 				else
672 					bFlag = SVX_ADJUST_LEFT == eAdjust;
673 				break;
674 			case SID_ATTR_PARA_ADJUST_RIGHT:
675 				if (eAdjust == -1)
676 				{
677 					rSet.InvalidateItem( nSlot );
678 					nSlot = 0;
679 				}
680 				else
681 					bFlag = SVX_ADJUST_RIGHT == eAdjust;
682 				break;
683 			case SID_ATTR_PARA_ADJUST_CENTER:
684 				if (eAdjust == -1)
685 				{
686 					rSet.InvalidateItem( nSlot );
687 					nSlot = 0;
688 				}
689 				else
690 					bFlag = SVX_ADJUST_CENTER == eAdjust;
691 				break;
692 			case SID_ATTR_PARA_ADJUST_BLOCK:
693 			{
694 				if (eAdjust == -1)
695 				{
696 					rSet.InvalidateItem( nSlot );
697 					nSlot = 0;
698 				}
699 				else
700 				{
701 					bFlag = SVX_ADJUST_BLOCK == eAdjust;
702 					sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
703 					if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & (HTMLMODE_FULL_STYLES|HTMLMODE_FIRSTLINE) ))
704 					{
705 						rSet.DisableItem( nSlot );
706 						nSlot = 0;
707 					}
708 				}
709 			}
710 			break;
711 			case SID_ATTR_PARA_LINESPACE_10:
712 				bFlag = nLineSpace == 100;
713 			break;
714 			case SID_ATTR_PARA_LINESPACE_15:
715 				bFlag = nLineSpace == 150;
716 			break;
717 			case SID_ATTR_PARA_LINESPACE_20:
718 				bFlag = nLineSpace == 200;
719 			break;
720 			case FN_GROW_FONT_SIZE:
721 			case FN_SHRINK_FONT_SIZE:
722 			{
723 				SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT,
724 											*rSet.GetPool() );
725 				aSetItem.GetItemSet().Put( aCoreSet, sal_False );
726 				if( !aSetItem.GetItemOfScript( rSh.GetScriptType() ))
727 					rSet.DisableItem( nSlot );
728 				nSlot = 0;
729 			}
730 			break;
731 			case FN_UNDERLINE_DOUBLE:
732 			{
733 				eState = aCoreSet.GetItemState(RES_CHRATR_UNDERLINE);
734 				if( eState >= SFX_ITEM_DEFAULT )
735 				{
736 					FontUnderline eUnderline =  ((const SvxUnderlineItem&)
737 							aCoreSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle();
738 					rSet.Put(SfxBoolItem(nSlot, eUnderline == UNDERLINE_DOUBLE));
739 				}
740 				else
741 					rSet.InvalidateItem(nSlot);
742 				nSlot = 0;
743 			}
744 			break;
745 			case SID_ATTR_PARA_ADJUST:
746 				if (eAdjust == -1)
747 					rSet.InvalidateItem( nSlot );
748 				else
749 					rSet.Put(SvxAdjustItem((SvxAdjust)eAdjust, SID_ATTR_PARA_ADJUST ));
750 				nSlot = 0;
751 			break;
752 
753             case SID_ATTR_PARA_LEFT_TO_RIGHT :
754             case SID_ATTR_PARA_RIGHT_TO_LEFT :
755             {
756                 if ( !SW_MOD()->GetCTLOptions().IsCTLFontEnabled() )
757 				{
758 					rSet.DisableItem( nSlot );
759 					nSlot = 0;
760 				}
761 				else
762 				{
763                     // is the item set?
764                     sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
765                     if((!(nHtmlMode & HTMLMODE_ON) || (0 != (nHtmlMode & HTMLMODE_SOME_STYLES))) &&
766                     aCoreSet.GetItemState( RES_FRAMEDIR, sal_False ) >= SFX_ITEM_DEFAULT)
767 					{
768 						SvxFrameDirection eFrmDir = (SvxFrameDirection)
769 								((const SvxFrameDirectionItem& )aCoreSet.Get(RES_FRAMEDIR)).GetValue();
770 						if (FRMDIR_ENVIRONMENT == eFrmDir)
771 						{
772 							eFrmDir = rSh.IsInRightToLeftText() ?
773 									FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP;
774 						}
775 						bFlag = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot &&
776 											FRMDIR_HORI_LEFT_TOP == eFrmDir) ||
777 								(SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot &&
778 											FRMDIR_HORI_RIGHT_TOP == eFrmDir);
779 					}
780 					else
781 					{
782 						rSet.InvalidateItem(nSlot);
783 						nSlot = 0;
784 					}
785 				}
786             }
787             break;
788 
789 			case SID_ATTR_CHAR_LANGUAGE:
790 			case SID_ATTR_CHAR_KERNING:
791 			case RES_PARATR_DROP:
792 			{
793 #if OSL_DEBUG_LEVEL > 1
794 				const SfxPoolItem& rItem = aCoreSet.Get(GetPool().GetWhich(nSlot), sal_True);
795 				rSet.Put(rItem);
796 #else
797 				rSet.Put(aCoreSet.Get( GetPool().GetWhich(nSlot), sal_True));
798 #endif
799 				nSlot = 0;
800 			}
801 			break;
802 			case SID_ATTR_PARA_MODEL:
803 			{
804 				SfxItemSet aTemp(GetPool(),
805 						RES_PAGEDESC,RES_PAGEDESC,
806 						SID_ATTR_PARA_MODEL,SID_ATTR_PARA_MODEL,
807 						0L);
808 				aTemp.Put(aCoreSet);
809 				::SwToSfxPageDescAttr(aTemp);
810 				rSet.Put(aTemp.Get(SID_ATTR_PARA_MODEL));
811 				nSlot = 0;
812 			}
813 			break;
814 			case RES_TXTATR_INETFMT:
815 			{
816 				SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
817                 rSh.GetCurAttr(aSet);
818 #if OSL_DEBUG_LEVEL > 1
819 				const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT, sal_True);
820 				rSet.Put(rItem);
821 #else
822 				rSet.Put(aSet.Get( RES_TXTATR_INETFMT, sal_True));
823 #endif
824 				nSlot = 0;
825 			}
826 			break;
827 
828 			default:
829 			// Nichts tun
830 			nSlot = 0;
831 			break;
832 
833 		}
834 		if( nSlot )
835 		{
836 			aFlagItem.SetWhich( nSlot );
837 			aFlagItem.SetValue( bFlag );
838 			rSet.Put( aFlagItem );
839 		}
840 		nSlot = aIter.NextWhich();
841 	}
842 
843 	rSet.Put(aCoreSet,sal_False);
844 }
845 
846 
847 
848