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