xref: /aoo41x/main/sw/source/ui/shells/txtattr.cxx (revision 782a276c)
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 
ExecCharAttr(SfxRequest & rReq)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 
ExecCharAttrArgs(SfxRequest & rReq)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                 ASSERT( false, "<SwTextShell::ExecCharAttrArgs(..)> - unexpected visited character format ID at hyperlink attribute" );
227                 aINetFmt.SetVisitedFmtAndId(
228                         aINetFmt.GetVisitedFmt(),
229                         SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetVisitedFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ) );
230             }
231             if ( USHRT_MAX == aINetFmt.GetINetFmtId() )
232             {
233                 ASSERT( false, "<SwTextShell::ExecCharAttrArgs(..)> - unexpected unvisited character format ID at hyperlink attribute" );
234                 aINetFmt.SetINetFmtAndId(
235                         aINetFmt.GetINetFmt(),
236                         SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetINetFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ) );
237             }
238 
239             if ( pColl )
240                 pColl->SetFmtAttr( aINetFmt );
241             else
242                 rWrtSh.SetAttrItem( aINetFmt );
243             rReq.Done();
244         }
245         break;
246 
247 		case FN_GROW_FONT_SIZE:
248 			bGrow = sal_True;
249 			// kein break !!
250 		case FN_SHRINK_FONT_SIZE:
251 		{
252 			SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, rPool );
253             rWrtSh.GetCurAttr( aSetItem.GetItemSet() );
254 			SfxItemSet aAttrSet( rPool, aSetItem.GetItemSet().GetRanges() );
255 
256 			const SfxPoolItem* pI;
257 			static const sal_uInt16 aScrTypes[] = {
258 				SCRIPTTYPE_LATIN, SCRIPTTYPE_ASIAN, SCRIPTTYPE_COMPLEX, 0 };
259 			sal_uInt16 nScriptType = rWrtSh.GetScriptType();
260 			for( const sal_uInt16* pScrpTyp = aScrTypes; *pScrpTyp; ++pScrpTyp )
261 				if( ( nScriptType & *pScrpTyp ) &&
262 					0 != ( pI = aSetItem.GetItemOfScript( *pScrpTyp )))
263 				{
264 					SvxFontHeightItem aSize( *(const SvxFontHeightItem*)pI );
265 					SwTwips lSize = (SwTwips) aSize.GetHeight();
266 
267 					if (bGrow)
268 					{
269 						if( lSize == lFontMaxSz )
270 							break;		// das wars, hoeher gehts nicht
271 						if( ( lSize += lFontInc ) > lFontMaxSz )
272 							lSize = lFontMaxSz;
273 					}
274 					else
275 					{
276 						if( 4 == lSize )
277 							break;
278 						if( ( lSize -= lFontInc ) < 4 )
279 							lSize = 4;
280 					}
281 					aSize.SetHeight( lSize );
282 					aAttrSet.Put( aSize );
283 				}
284 				if( aAttrSet.Count() )
285 				{
286 					if( pColl )
287                         pColl->SetFmtAttr( aAttrSet );
288 					else
289 						rWrtSh.SetAttrSet( aAttrSet );
290 				}
291             rReq.Done();
292 		}
293 		break;
294 
295 		default:
296 			ASSERT(sal_False, falscher Dispatcher);
297 			return;
298 	}
299 }
300 
301 
302 
303 #ifdef CFRONT
304 
lcl_SetAdjust(SvxAdjust eAdjst,SfxItemSet & rSet)305 void lcl_SetAdjust(SvxAdjust eAdjst, SfxItemSet& rSet)
306 {
307 	rSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST ));
308 }
309 
310 
311 
lcl_SetLineSpace(sal_uInt8 ePropL,SfxItemSet & rSet)312 void lcl_SetLineSpace(sal_uInt8 ePropL,SfxItemSet& rSet)
313 {
314 	SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING );
315 	aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
316 	if( 100 == ePropL )
317 		aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
318 	else
319 		aLineSpacing.SetPropLineSpace(ePropL);
320 	rSet.Put( aLineSpacing );
321 }
322 
323 
324 
ExecParaAttr(SfxRequest & rReq)325 void SwTextShell::ExecParaAttr(SfxRequest &rReq)
326 {
327 	// gleiche beide Attribute holen, ist nicht teuerer !!
328 	SfxItemSet aSet( GetPool(), RES_PARATR_LINESPACING, RES_PARATR_ADJUST );
329 
330 	switch (rReq.GetSlot())
331 	{
332 	case FN_SET_LEFT_PARA:			lcl_SetAdjust(ADJLEFT,aSet); 	break;
333 	case FN_SET_RIGHT_PARA:			lcl_SetAdjust(ADJRIGHT,aSet); 	break;
334 	case FN_SET_CENTER_PARA:        lcl_SetAdjust(ADJCENTER,aSet); 	break;
335 	case SID_ATTR_PARA_ADJUST_BLOCK:lcl_SetAdjust(ADJBLOCK,aSet); 	break;
336 
337 	case FN_SET_LINE_SPACE_1:	lcl_SetLineSpace(100,aSet); 	break;
338 	case FN_SET_LINE_SPACE_15:  lcl_SetLineSpace(150,aSet); 	break;
339 	case FN_SET_LINE_SPACE_2:	lcl_SetLineSpace(200,aSet); 	break;
340 
341 	default:
342 		DBG_ERROR("SwTextShell::ExecParaAttr falscher Dispatcher");
343 		return;
344 	}
345 	SwWrtShell& rWrtSh = GetShell();
346 	SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
347 	if(pColl && pColl->IsAutoUpdateFmt())
348 	{
349 		rWrtSh.AutoUpdatePara(pColl, *pSet);
350 	}
351 	else
352     {
353 		rWrtSh.SetAttrSet( aSet );
354         rReq.Done( aSet );
355     }
356 }
357 
358 #else
359 
360 
361 
ExecParaAttr(SfxRequest & rReq)362 void SwTextShell::ExecParaAttr(SfxRequest &rReq)
363 {
364 	SvxAdjust eAdjst;
365 	sal_uInt8 ePropL;
366 	const SfxItemSet* pArgs = rReq.GetArgs();
367 
368 	// gleich beide Attribute holen, ist nicht teuerer !!
369     SfxItemSet aSet( GetPool(),
370         RES_PARATR_LINESPACING, RES_PARATR_ADJUST,
371         RES_FRAMEDIR, RES_FRAMEDIR,
372         0 );
373 
374 	sal_uInt16 nSlot = rReq.GetSlot();
375 	switch (nSlot)
376 	{
377 		case SID_ATTR_PARA_ADJUST:
378 		{
379 			if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_PARATR_ADJUST) )
380 			{
381 				const SvxAdjustItem& rAdj = (const SvxAdjustItem&) pArgs->Get(RES_PARATR_ADJUST);
382 				SvxAdjustItem aAdj( rAdj.GetAdjust(), RES_PARATR_ADJUST );
383 				if ( rAdj.GetAdjust() == SVX_ADJUST_BLOCK )
384 				{
385 					aAdj.SetLastBlock( rAdj.GetLastBlock() );
386 					aAdj.SetOneWord( rAdj.GetOneWord() );
387 				}
388 
389 				aSet.Put(aAdj);
390 			}
391 		}
392 		break;
393 		case SID_ATTR_PARA_ADJUST_LEFT:		eAdjst =  SVX_ADJUST_LEFT;		goto SET_ADJUST;
394 		case SID_ATTR_PARA_ADJUST_RIGHT:	eAdjst =  SVX_ADJUST_RIGHT;		goto SET_ADJUST;
395 		case SID_ATTR_PARA_ADJUST_CENTER:   eAdjst =  SVX_ADJUST_CENTER;	goto SET_ADJUST;
396 		case SID_ATTR_PARA_ADJUST_BLOCK:	eAdjst =  SVX_ADJUST_BLOCK;		goto SET_ADJUST;
397 SET_ADJUST:
398 		{
399 			aSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST));
400             rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), sal_True ) );
401 		}
402 		break;
403 
404 		case SID_ATTR_PARA_LINESPACE:
405 			if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( GetPool().GetWhich(nSlot) ))
406 			{
407 				SvxLineSpacingItem aLineSpace = (const SvxLineSpacingItem&)pArgs->Get(
408 															GetPool().GetWhich(nSlot));
409 				aSet.Put( aLineSpace );
410 			}
411 		break;
412 		case SID_ATTR_PARA_LINESPACE_10:	ePropL = 100;	goto SET_LINESPACE;
413 		case SID_ATTR_PARA_LINESPACE_15:	ePropL = 150;	goto SET_LINESPACE;
414 		case SID_ATTR_PARA_LINESPACE_20:	ePropL = 200;	goto SET_LINESPACE;
415 
416 SET_LINESPACE:
417 		{
418 
419 			SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING );
420 			aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
421 			if( 100 == ePropL )
422 				aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
423 			else
424 				aLineSpacing.SetPropLineSpace(ePropL);
425 			aSet.Put( aLineSpacing );
426 		}
427 		break;
428 
429         case SID_ATTR_PARA_LEFT_TO_RIGHT :
430         case SID_ATTR_PARA_RIGHT_TO_LEFT :
431         {
432             sal_Bool bSet = sal_True;
433             int eState = pArgs ? pArgs->GetItemState(nSlot) : SFX_ITEM_DISABLED;
434             if (pArgs && SFX_ITEM_SET == eState)
435                 bSet = ((const SfxBoolItem&)pArgs->Get(nSlot)).GetValue();
436 /*
437 // toggling of the slots not used anymore
438 
439            if(!bSet)
440 				nSlot = SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot ?
441 					SID_ATTR_PARA_RIGHT_TO_LEFT :
442 					SID_ATTR_PARA_LEFT_TO_RIGHT;
443 */
444             SfxItemSet aAdjustSet( GetPool(),
445                     RES_PARATR_ADJUST, RES_PARATR_ADJUST );
446             GetShell().GetCurAttr(aAdjustSet);
447             sal_Bool bChgAdjust = sal_False;
448             SfxItemState eAdjustState = aAdjustSet.GetItemState(RES_PARATR_ADJUST, sal_False);
449             if(eAdjustState  >= SFX_ITEM_DEFAULT)
450             {
451                 int eAdjust = (int)(( const SvxAdjustItem& )
452 						aAdjustSet.Get(RES_PARATR_ADJUST)).GetAdjust();
453 //                bChgAdjust = SVX_ADJUST_CENTER  != eAdjust  &&  SVX_ADJUST_BLOCK != eAdjust;
454                 bChgAdjust = (SVX_ADJUST_LEFT  == eAdjust  &&  SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot) ||
455                              (SVX_ADJUST_RIGHT == eAdjust  &&  SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot);
456             }
457             else
458                 bChgAdjust = sal_True;
459 
460             SvxFrameDirection eFrmDirection =
461                     (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
462                         FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
463             aSet.Put( SvxFrameDirectionItem( eFrmDirection, RES_FRAMEDIR ) );
464 
465             if (bChgAdjust)
466             {
467                 SvxAdjust eAdjust = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
468                         SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT;
469                 SvxAdjustItem aAdjust( eAdjust, RES_PARATR_ADJUST );
470                 aSet.Put( aAdjust );
471                 aAdjust.SetWhich(SID_ATTR_PARA_ADJUST);
472                 GetView().GetViewFrame()->GetBindings().SetState( aAdjust );
473                 // Toggle numbering alignment
474                 const SwNumRule* pCurRule = GetShell().GetCurNumRule();
475                 if( pCurRule )
476                 {
477                     SvxNumRule aRule = pCurRule->MakeSvxNumRule();
478 
479                     for(sal_uInt16 i = 0; i < aRule.GetLevelCount(); i++)
480                     {
481                         SvxNumberFormat aFmt(aRule.GetLevel(i));
482                         if(SVX_ADJUST_LEFT == aFmt.GetNumAdjust())
483                             aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
484 
485                         else if(SVX_ADJUST_RIGHT == aFmt.GetNumAdjust())
486                             aFmt.SetNumAdjust( SVX_ADJUST_LEFT );
487 
488                         aRule.SetLevel(i, aFmt, aRule.Get(i) != 0);
489                     }
490                     // --> OD 2008-02-11 #newlistlevelattrs#
491                     SwNumRule aSetRule( pCurRule->GetName(),
492                                         pCurRule->Get( 0 ).GetPositionAndSpaceMode() );
493                     // <--
494                     aSetRule.SetSvxRule( aRule, GetShell().GetDoc());
495                     aSetRule.SetAutoRule( sal_True );
496                     // --> OD 2008-03-17 #refactorlists#
497                     // no start or continuation of a list - list style is only changed
498                     GetShell().SetCurNumRule( aSetRule, false );
499                     // <--
500                 }
501             }
502         }
503         break;
504 
505 		default:
506 			ASSERT(sal_False, falscher Dispatcher);
507 			return;
508 	}
509 	SwWrtShell& rWrtSh = GetShell();
510 	SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
511 	if(pColl && pColl->IsAutoUpdateFmt())
512 	{
513 		rWrtSh.AutoUpdatePara(pColl, aSet);
514 	}
515 	else
516 		rWrtSh.SetAttrSet( aSet );
517     rReq.Done();
518 }
519 
520 #endif
521 
522 
523 
ExecParaAttrArgs(SfxRequest & rReq)524 void SwTextShell::ExecParaAttrArgs(SfxRequest &rReq)
525 {
526 	SwWrtShell &rSh = GetShell();
527 	const SfxItemSet *pArgs = rReq.GetArgs();
528 	const SfxPoolItem *pItem = 0;
529 
530 	sal_uInt16 nSlot = rReq.GetSlot();
531 	if(pArgs)
532 		pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem);
533 	switch ( nSlot )
534 	{
535         case FN_DROP_CHAR_STYLE_NAME:
536             if( pItem )
537             {
538                 String sCharStyleName = ((const SfxStringItem*)pItem)->GetValue();
539                 SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP, 0L);
540                 rSh.GetCurAttr(aSet);
541                 SwFmtDrop aDropItem((const SwFmtDrop&)aSet.Get(RES_PARATR_DROP));
542                 SwCharFmt* pFmt = 0;
543                 if(sCharStyleName.Len())
544                     pFmt = rSh.FindCharFmtByName( sCharStyleName );
545                 aDropItem.SetCharFmt( pFmt );
546                 aSet.Put(aDropItem);
547                 rSh.SetAttrSet(aSet);
548             }
549         break;
550         case FN_FORMAT_DROPCAPS:
551         {
552 			if(pItem)
553             {
554 				rSh.SetAttrItem(*pItem);
555                 rReq.Done();
556             }
557 			else
558 			{
559 				SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP,
560 										   HINT_END, HINT_END, 0);
561                 rSh.GetCurAttr(aSet);
562                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
563                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
564 
565                 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aSet,
566 					rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), DLG_SWDROPCAPS );
567                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
568 				if (pDlg->Execute() == RET_OK)
569 				{
570 					rSh.StartAction();
571 					rSh.StartUndo( UNDO_START );
572 					if ( SFX_ITEM_SET == aSet.GetItemState(HINT_END,sal_False,&pItem) )
573 					{
574 						if ( ((SfxStringItem*)pItem)->GetValue().Len() )
575 							rSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue());
576 					}
577 					rSh.SetAttrSet(*pDlg->GetOutputItemSet());
578 					rSh.StartUndo( UNDO_END );
579 					rSh.EndAction();
580                     rReq.Done(*pDlg->GetOutputItemSet());
581 				}
582 				delete pDlg;
583 			}
584 		}
585  		break;
586 		case SID_ATTR_PARA_PAGEBREAK:
587 			if(pItem)
588 			{
589 				rSh.SetAttrItem( *pItem );
590                 rReq.Done();
591 			}
592 		break;
593 		case SID_ATTR_PARA_MODEL:
594 		{
595 			if(pItem)
596 			{
597 				SfxItemSet aCoreSet( GetPool(),
598 					RES_PAGEDESC,	RES_PAGEDESC,
599 					SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL, 0);
600 				aCoreSet.Put(*pItem);
601 				SfxToSwPageDescAttr( rSh, aCoreSet);
602 				rSh.SetAttrSet(aCoreSet);
603                 rReq.Done();
604 			}
605 		}
606 		break;
607 
608         default:
609 			ASSERT(sal_False, falscher Dispatcher);
610 			return;
611 	}
612 }
613 
614 
615 
GetAttrState(SfxItemSet & rSet)616 void SwTextShell::GetAttrState(SfxItemSet &rSet)
617 {
618 	SwWrtShell &rSh = GetShell();
619 	SfxItemPool& rPool = GetPool();
620 	SfxItemSet aCoreSet(rPool, aTxtFmtCollSetRange);
621     rSh.GetCurAttr(aCoreSet); // *alle* Textattribute von der Core erfragen
622 
623 	SfxWhichIter aIter(rSet);
624 	sal_uInt16 nSlot = aIter.FirstWhich();
625     sal_Bool bFlag = sal_False;
626 	SfxBoolItem aFlagItem;
627 	const SfxPoolItem* pItem = 0;
628 	int eAdjust = -1;	// Illegaler Wert, um DONTCARE zu erkennen
629 	SfxItemState eState = aCoreSet.GetItemState(RES_PARATR_ADJUST, sal_False, &pItem);
630 
631 	if( SFX_ITEM_DEFAULT == eState )
632 		pItem = &rPool.GetDefaultItem(RES_PARATR_ADJUST);
633 	if( SFX_ITEM_DEFAULT <= eState )
634 		eAdjust = (int)(( SvxAdjustItem* ) pItem)->GetAdjust();
635 
636 	short nEsc = 0;
637 	eState =  aCoreSet.GetItemState(RES_CHRATR_ESCAPEMENT, sal_False, &pItem);
638 	if( SFX_ITEM_DEFAULT == eState )
639 		pItem = &rPool.GetDefaultItem(RES_CHRATR_ESCAPEMENT);
640 	if( eState >= SFX_ITEM_DEFAULT )
641 		nEsc = ((SvxEscapementItem* )pItem)->GetEsc();
642 
643 	sal_uInt16 nLineSpace = 0;
644 	eState =  aCoreSet.GetItemState(RES_PARATR_LINESPACING, sal_False, &pItem);
645 	if( SFX_ITEM_DEFAULT == eState )
646 		pItem = &rPool.GetDefaultItem(RES_PARATR_LINESPACING);
647 	if( SFX_ITEM_DEFAULT <= eState &&
648 			((SvxLineSpacingItem* )pItem)->GetLineSpaceRule() == SVX_LINE_SPACE_AUTO )
649 	{
650 		if(SVX_INTER_LINE_SPACE_OFF ==
651 					((SvxLineSpacingItem* )pItem)->GetInterLineSpaceRule())
652 			nLineSpace = 100;
653 		else
654 			nLineSpace = ((SvxLineSpacingItem* )pItem)->GetPropLineSpace();
655 	}
656 
657 	while (nSlot)
658 	{
659 		switch(nSlot)
660 		{
661 			case FN_SET_SUPER_SCRIPT:
662 					bFlag = 0 < nEsc;
663 				break;
664 			case FN_SET_SUB_SCRIPT:
665 					bFlag = 0 > nEsc;
666 				break;
667 			case SID_ATTR_PARA_ADJUST_LEFT:
668 				if (eAdjust == -1)
669 				{
670 					rSet.InvalidateItem( nSlot );
671 					nSlot = 0;
672 				}
673 				else
674 					bFlag = SVX_ADJUST_LEFT == eAdjust;
675 				break;
676 			case SID_ATTR_PARA_ADJUST_RIGHT:
677 				if (eAdjust == -1)
678 				{
679 					rSet.InvalidateItem( nSlot );
680 					nSlot = 0;
681 				}
682 				else
683 					bFlag = SVX_ADJUST_RIGHT == eAdjust;
684 				break;
685 			case SID_ATTR_PARA_ADJUST_CENTER:
686 				if (eAdjust == -1)
687 				{
688 					rSet.InvalidateItem( nSlot );
689 					nSlot = 0;
690 				}
691 				else
692 					bFlag = SVX_ADJUST_CENTER == eAdjust;
693 				break;
694 			case SID_ATTR_PARA_ADJUST_BLOCK:
695 			{
696 				if (eAdjust == -1)
697 				{
698 					rSet.InvalidateItem( nSlot );
699 					nSlot = 0;
700 				}
701 				else
702 				{
703 					bFlag = SVX_ADJUST_BLOCK == eAdjust;
704 					sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
705 					if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & (HTMLMODE_FULL_STYLES|HTMLMODE_FIRSTLINE) ))
706 					{
707 						rSet.DisableItem( nSlot );
708 						nSlot = 0;
709 					}
710 				}
711 			}
712 			break;
713 			case SID_ATTR_PARA_LINESPACE_10:
714 				bFlag = nLineSpace == 100;
715 			break;
716 			case SID_ATTR_PARA_LINESPACE_15:
717 				bFlag = nLineSpace == 150;
718 			break;
719 			case SID_ATTR_PARA_LINESPACE_20:
720 				bFlag = nLineSpace == 200;
721 			break;
722 			case FN_GROW_FONT_SIZE:
723 			case FN_SHRINK_FONT_SIZE:
724 			{
725 				SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT,
726 											*rSet.GetPool() );
727 				aSetItem.GetItemSet().Put( aCoreSet, sal_False );
728 				if( !aSetItem.GetItemOfScript( rSh.GetScriptType() ))
729 					rSet.DisableItem( nSlot );
730 				nSlot = 0;
731 			}
732 			break;
733 			case FN_UNDERLINE_DOUBLE:
734 			{
735 				eState = aCoreSet.GetItemState(RES_CHRATR_UNDERLINE);
736 				if( eState >= SFX_ITEM_DEFAULT )
737 				{
738 					FontUnderline eUnderline =  ((const SvxUnderlineItem&)
739 							aCoreSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle();
740 					rSet.Put(SfxBoolItem(nSlot, eUnderline == UNDERLINE_DOUBLE));
741 				}
742 				else
743 					rSet.InvalidateItem(nSlot);
744 				nSlot = 0;
745 			}
746 			break;
747 			case SID_ATTR_PARA_ADJUST:
748 				if (eAdjust == -1)
749 					rSet.InvalidateItem( nSlot );
750 				else
751 					rSet.Put(SvxAdjustItem((SvxAdjust)eAdjust, SID_ATTR_PARA_ADJUST ));
752 				nSlot = 0;
753 			break;
754 			case SID_ATTR_PARA_LRSPACE:
755 			{
756 				eState = aCoreSet.GetItemState(RES_LR_SPACE);
757 				if( eState >= SFX_ITEM_DEFAULT )
758 				{
759 					SvxLRSpaceItem aLR = ( (const SvxLRSpaceItem&) aCoreSet.Get( RES_LR_SPACE ) );
760 					aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
761 					rSet.Put(aLR);
762 				}
763 				else
764 					rSet.InvalidateItem(nSlot);
765 				nSlot = 0;
766 			}
767 
768             case SID_ATTR_PARA_LEFT_TO_RIGHT :
769             case SID_ATTR_PARA_RIGHT_TO_LEFT :
770             {
771                 if ( !SW_MOD()->GetCTLOptions().IsCTLFontEnabled() )
772 				{
773 					rSet.DisableItem( nSlot );
774 					nSlot = 0;
775 				}
776 				else
777 				{
778                     // is the item set?
779                     sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
780                     if((!(nHtmlMode & HTMLMODE_ON) || (0 != (nHtmlMode & HTMLMODE_SOME_STYLES))) &&
781                     aCoreSet.GetItemState( RES_FRAMEDIR, sal_False ) >= SFX_ITEM_DEFAULT)
782 					{
783 						SvxFrameDirection eFrmDir = (SvxFrameDirection)
784 								((const SvxFrameDirectionItem& )aCoreSet.Get(RES_FRAMEDIR)).GetValue();
785 						if (FRMDIR_ENVIRONMENT == eFrmDir)
786 						{
787 							eFrmDir = rSh.IsInRightToLeftText() ?
788 									FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP;
789 						}
790 						bFlag = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot &&
791 											FRMDIR_HORI_LEFT_TOP == eFrmDir) ||
792 								(SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot &&
793 											FRMDIR_HORI_RIGHT_TOP == eFrmDir);
794 					}
795 					else
796 					{
797 						rSet.InvalidateItem(nSlot);
798 						nSlot = 0;
799 					}
800 				}
801             }
802             break;
803 
804 			case SID_ATTR_CHAR_LANGUAGE:
805 			case SID_ATTR_CHAR_KERNING:
806 			case RES_PARATR_DROP:
807 			{
808 #if OSL_DEBUG_LEVEL > 1
809 				const SfxPoolItem& rItem = aCoreSet.Get(GetPool().GetWhich(nSlot), sal_True);
810 				rSet.Put(rItem);
811 #else
812 				rSet.Put(aCoreSet.Get( GetPool().GetWhich(nSlot), sal_True));
813 #endif
814 				nSlot = 0;
815 			}
816 			break;
817 			case SID_ATTR_PARA_MODEL:
818 			{
819 				SfxItemSet aTemp(GetPool(),
820 						RES_PAGEDESC,RES_PAGEDESC,
821 						SID_ATTR_PARA_MODEL,SID_ATTR_PARA_MODEL,
822 						0L);
823 				aTemp.Put(aCoreSet);
824 				::SwToSfxPageDescAttr(aTemp);
825 				rSet.Put(aTemp.Get(SID_ATTR_PARA_MODEL));
826 				nSlot = 0;
827 			}
828 			break;
829 			case RES_TXTATR_INETFMT:
830 			{
831 				SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
832                 rSh.GetCurAttr(aSet);
833 #if OSL_DEBUG_LEVEL > 1
834 				const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT, sal_True);
835 				rSet.Put(rItem);
836 #else
837 				rSet.Put(aSet.Get( RES_TXTATR_INETFMT, sal_True));
838 #endif
839 				nSlot = 0;
840 			}
841 			break;
842 
843 			default:
844 			// Nichts tun
845 			nSlot = 0;
846 			break;
847 
848 		}
849 		if( nSlot )
850 		{
851 			aFlagItem.SetWhich( nSlot );
852 			aFlagItem.SetValue( bFlag );
853 			rSet.Put( aFlagItem );
854 		}
855 		nSlot = aIter.NextWhich();
856 	}
857 
858 	rSet.Put(aCoreSet,sal_False);
859 }
860 
861 
862 
863