update dev300-m58
[ooovba.git] / sw / source / ui / shells / txtattr.cxx
blobfc64a6c132c00aa3f068fee6de934a923f61a8b7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txtattr.cxx,v $
10 * $Revision: 1.28.140.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <hintids.hxx>
37 #ifndef _MSGBOX_HXX //autogen
38 #include <vcl/msgbox.hxx>
39 #endif
40 #include <svtools/whiter.hxx>
41 #include <svtools/stritem.hxx>
42 #include <svtools/itemiter.hxx>
43 #include <svtools/ctloptions.hxx>
44 #include <swmodule.hxx>
45 #include <sfx2/bindings.hxx>
46 #include <sfx2/request.hxx>
47 #include <svx/fhgtitem.hxx>
48 #include <svx/adjitem.hxx>
49 #include <svx/lspcitem.hxx>
50 #include <svx/udlnitem.hxx>
51 #include <svx/escpitem.hxx>
52 #include <svx/htmlmode.hxx>
53 #include <svx/scripttypeitem.hxx>
54 #include <svx/frmdiritem.hxx>
55 #include "paratr.hxx"
57 #include <fmtinfmt.hxx>
58 #ifndef _DOCSH_HXX
59 #include <docsh.hxx>
60 #endif
61 #include <wrtsh.hxx>
62 #ifndef _VIEW_HXX
63 #include <view.hxx>
64 #endif
65 #include <viewopt.hxx>
66 #include <uitool.hxx>
67 #ifndef _TEXTSH_HXX
68 #include <textsh.hxx>
69 #endif
70 #include <num.hxx>
71 #include <swundo.hxx>
72 #include <fmtcol.hxx>
74 #ifndef _CMDID_H
75 #include <cmdid.h>
76 #endif
77 #include <globals.h>
78 #ifndef _SHELLS_HRC
79 #include <shells.hrc>
80 #endif
81 #include <SwStyleNameMapper.hxx>
82 #include "swabstdlg.hxx"
83 #include "chrdlg.hrc"
84 const SwTwips lFontInc = 2 * 20; // ==> PointToTwips(2)
85 const SwTwips lFontMaxSz = 72 * 20; // ==> PointToTwips(72)
90 void SwTextShell::ExecCharAttr(SfxRequest &rReq)
92 SwWrtShell &rSh = GetShell();
93 const SfxItemSet *pArgs = rReq.GetArgs();
94 int eState = STATE_TOGGLE;
95 USHORT nWhich = rReq.GetSlot();
97 if(pArgs )
99 const SfxPoolItem* pItem;
100 pArgs->GetItemState(nWhich, FALSE, &pItem);
101 eState = ((const SfxBoolItem &) pArgs->
102 Get( nWhich )).GetValue() ? STATE_ON : STATE_OFF;
106 SfxItemSet aSet( GetPool(), RES_CHRATR_BEGIN, RES_CHRATR_END-1 );
107 if (STATE_TOGGLE == eState)
108 rSh.GetCurAttr( aSet );
110 switch ( nWhich )
112 case FN_SET_SUB_SCRIPT:
113 case FN_SET_SUPER_SCRIPT:
115 SvxEscapement eEscape = SVX_ESCAPEMENT_SUBSCRIPT;
116 switch (eState)
118 case STATE_TOGGLE:
120 short nTmpEsc = ((const SvxEscapementItem&)
121 aSet.Get( RES_CHRATR_ESCAPEMENT )).GetEsc();
122 eEscape = nWhich == FN_SET_SUPER_SCRIPT ?
123 SVX_ESCAPEMENT_SUPERSCRIPT:
124 SVX_ESCAPEMENT_SUBSCRIPT;
125 if( nWhich == FN_SET_SUB_SCRIPT && nTmpEsc < 0 ||
126 nWhich == FN_SET_SUPER_SCRIPT && nTmpEsc > 0 )
127 eEscape = SVX_ESCAPEMENT_OFF;
129 SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
130 if( nWhich == FN_SET_SUB_SCRIPT )
131 rBind.SetState( SfxBoolItem( FN_SET_SUPER_SCRIPT,
132 FALSE ) );
133 else
134 rBind.SetState( SfxBoolItem( FN_SET_SUB_SCRIPT,
135 FALSE ) );
138 break;
139 case STATE_ON:
140 eEscape = nWhich == FN_SET_SUPER_SCRIPT ?
141 SVX_ESCAPEMENT_SUPERSCRIPT:
142 SVX_ESCAPEMENT_SUBSCRIPT;
143 break;
144 case STATE_OFF:
145 eEscape = SVX_ESCAPEMENT_OFF;
146 break;
148 SvxEscapementItem aEscape( eEscape, RES_CHRATR_ESCAPEMENT );
149 if(eEscape == SVX_ESCAPEMENT_SUPERSCRIPT)
150 aEscape.GetEsc() = DFLT_ESC_AUTO_SUPER;
151 else if(eEscape == SVX_ESCAPEMENT_SUBSCRIPT)
152 aEscape.GetEsc() = DFLT_ESC_AUTO_SUB;
153 if(eState != STATE_OFF )
155 if(eEscape == FN_SET_SUPER_SCRIPT)
156 aEscape.GetEsc() *= -1;
158 rSh.SetAttr( aEscape );
159 rReq.AppendItem( aEscape );
160 rReq.Done();
162 break;
164 case FN_UPDATE_STYLE_BY_EXAMPLE:
165 rSh.QuickUpdateStyle();
166 rReq.Done();
167 break;
168 case FN_UNDERLINE_DOUBLE:
170 FontUnderline eUnderline = ((const SvxUnderlineItem&)
171 aSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle();
172 switch( eState )
174 case STATE_TOGGLE:
175 eUnderline = eUnderline == UNDERLINE_DOUBLE ?
176 UNDERLINE_NONE :
177 UNDERLINE_DOUBLE;
178 break;
179 case STATE_ON:
180 eUnderline = UNDERLINE_DOUBLE;
181 break;
182 case STATE_OFF:
183 eUnderline = UNDERLINE_NONE;
184 break;
186 SvxUnderlineItem aUnderline(eUnderline, RES_CHRATR_UNDERLINE );
187 rSh.SetAttr( aUnderline );
188 rReq.AppendItem( aUnderline );
189 rReq.Done();
191 break;
192 case FN_REMOVE_DIRECT_CHAR_FORMATS:
193 if( !rSh.HasReadonlySel() && rSh.IsEndPara())
194 rSh.DontExpandFmt();
195 break;
196 default:
197 ASSERT(FALSE, falscher Dispatcher);
198 return;
203 void SwTextShell::ExecCharAttrArgs(SfxRequest &rReq)
205 USHORT nSlot = rReq.GetSlot();
206 const SfxItemSet* pArgs = rReq.GetArgs();
207 BOOL bArgs = pArgs != 0 && pArgs->Count() > 0;
208 int bGrow = FALSE;
209 SwWrtShell& rWrtSh = GetShell();
210 SwTxtFmtColl* pColl = 0;
212 // nur gesetzt, wenn gesamter Absatz selektiert ist und AutoUpdateFmt gesetzt ist
213 if( rWrtSh.HasSelection() && rWrtSh.IsSelFullPara() )
215 pColl = rWrtSh.GetCurTxtFmtColl();
216 if(pColl && !pColl->IsAutoUpdateFmt())
217 pColl = 0;
219 SfxItemPool& rPool = GetPool();
220 USHORT nWhich = rPool.GetWhich(nSlot);
221 switch ( nSlot )
223 case FN_TXTATR_INET:
224 // Sonderbehandlung der PoolId des SwFmtInetFmt
225 if(bArgs)
227 const SfxPoolItem& rItem = pArgs->Get(nWhich );
229 SwFmtINetFmt aINetFmt((const SwFmtINetFmt&)rItem);
230 if( USHRT_MAX == aINetFmt.GetVisitedFmtId() )
232 aINetFmt.SetVisitedFmtId(
233 SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetVisitedFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT));
235 if( USHRT_MAX == aINetFmt.GetINetFmtId() )
237 aINetFmt.SetINetFmtId(
238 SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetINetFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT));
241 if ( pColl )
242 pColl->SetFmtAttr( aINetFmt );
243 else rWrtSh.SetAttr( aINetFmt );
244 rReq.Done();
246 break;
248 case FN_GROW_FONT_SIZE:
249 bGrow = TRUE;
250 // kein break !!
251 case FN_SHRINK_FONT_SIZE:
253 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, rPool );
254 rWrtSh.GetCurAttr( aSetItem.GetItemSet() );
255 SfxItemSet aAttrSet( rPool, aSetItem.GetItemSet().GetRanges() );
257 const SfxPoolItem* pI;
258 static const USHORT aScrTypes[] = {
259 SCRIPTTYPE_LATIN, SCRIPTTYPE_ASIAN, SCRIPTTYPE_COMPLEX, 0 };
260 USHORT nScriptType = rWrtSh.GetScriptType();
261 for( const USHORT* pScrpTyp = aScrTypes; *pScrpTyp; ++pScrpTyp )
262 if( ( nScriptType & *pScrpTyp ) &&
263 0 != ( pI = aSetItem.GetItemOfScript( *pScrpTyp )))
265 SvxFontHeightItem aSize( *(const SvxFontHeightItem*)pI );
266 SwTwips lSize = (SwTwips) aSize.GetHeight();
268 if (bGrow)
270 if( lSize == lFontMaxSz )
271 break; // das wars, hoeher gehts nicht
272 if( ( lSize += lFontInc ) > lFontMaxSz )
273 lSize = lFontMaxSz;
275 else
277 if( 4 == lSize )
278 break;
279 if( ( lSize -= lFontInc ) < 4 )
280 lSize = 4;
282 aSize.SetHeight( lSize );
283 aAttrSet.Put( aSize );
285 if( aAttrSet.Count() )
287 if( pColl )
288 pColl->SetFmtAttr( aAttrSet );
289 else
290 rWrtSh.SetAttr( aAttrSet );
292 rReq.Done();
294 break;
296 default:
297 ASSERT(FALSE, falscher Dispatcher);
298 return;
304 #ifdef CFRONT
306 void lcl_SetAdjust(SvxAdjust eAdjst, SfxItemSet& rSet)
308 rSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST ));
313 void lcl_SetLineSpace(BYTE ePropL,SfxItemSet& rSet)
315 SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING );
316 aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
317 if( 100 == ePropL )
318 aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
319 else
320 aLineSpacing.SetPropLineSpace(ePropL);
321 rSet.Put( aLineSpacing );
326 void SwTextShell::ExecParaAttr(SfxRequest &rReq)
328 // gleiche beide Attribute holen, ist nicht teuerer !!
329 SfxItemSet aSet( GetPool(), RES_PARATR_LINESPACING, RES_PARATR_ADJUST );
331 switch (rReq.GetSlot())
333 case FN_SET_LEFT_PARA: lcl_SetAdjust(ADJLEFT,aSet); break;
334 case FN_SET_RIGHT_PARA: lcl_SetAdjust(ADJRIGHT,aSet); break;
335 case FN_SET_CENTER_PARA: lcl_SetAdjust(ADJCENTER,aSet); break;
336 case SID_ATTR_PARA_ADJUST_BLOCK:lcl_SetAdjust(ADJBLOCK,aSet); break;
338 case FN_SET_LINE_SPACE_1: lcl_SetLineSpace(100,aSet); break;
339 case FN_SET_LINE_SPACE_15: lcl_SetLineSpace(150,aSet); break;
340 case FN_SET_LINE_SPACE_2: lcl_SetLineSpace(200,aSet); break;
342 default:
343 DBG_ERROR("SwTextShell::ExecParaAttr falscher Dispatcher");
344 return;
346 SwWrtShell& rWrtSh = GetShell();
347 SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
348 if(pColl && pColl->IsAutoUpdateFmt())
350 rWrtSh.AutoUpdatePara(pColl, *pSet);
352 else
354 rWrtSh.SetAttr( aSet );
355 rReq.Done( aSet );
359 #else
363 void SwTextShell::ExecParaAttr(SfxRequest &rReq)
365 SvxAdjust eAdjst;
366 BYTE ePropL;
367 const SfxItemSet* pArgs = rReq.GetArgs();
369 // gleich beide Attribute holen, ist nicht teuerer !!
370 SfxItemSet aSet( GetPool(),
371 RES_PARATR_LINESPACING, RES_PARATR_ADJUST,
372 RES_FRAMEDIR, RES_FRAMEDIR,
373 0 );
375 USHORT nSlot = rReq.GetSlot();
376 switch (nSlot)
378 case SID_ATTR_PARA_ADJUST:
380 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_PARATR_ADJUST) )
382 const SvxAdjustItem& rAdj = (const SvxAdjustItem&) pArgs->Get(RES_PARATR_ADJUST);
383 SvxAdjustItem aAdj( rAdj.GetAdjust(), RES_PARATR_ADJUST );
384 if ( rAdj.GetAdjust() == SVX_ADJUST_BLOCK )
386 aAdj.SetLastBlock( rAdj.GetLastBlock() );
387 aAdj.SetOneWord( rAdj.GetOneWord() );
390 aSet.Put(aAdj);
393 break;
394 case SID_ATTR_PARA_ADJUST_LEFT: eAdjst = SVX_ADJUST_LEFT; goto SET_ADJUST;
395 case SID_ATTR_PARA_ADJUST_RIGHT: eAdjst = SVX_ADJUST_RIGHT; goto SET_ADJUST;
396 case SID_ATTR_PARA_ADJUST_CENTER: eAdjst = SVX_ADJUST_CENTER; goto SET_ADJUST;
397 case SID_ATTR_PARA_ADJUST_BLOCK: eAdjst = SVX_ADJUST_BLOCK; goto SET_ADJUST;
398 SET_ADJUST:
400 aSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST));
401 rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), TRUE ) );
403 break;
405 case SID_ATTR_PARA_LINESPACE:
406 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( GetPool().GetWhich(nSlot) ))
408 SvxLineSpacingItem aLineSpace = (const SvxLineSpacingItem&)pArgs->Get(
409 GetPool().GetWhich(nSlot));
410 aSet.Put( aLineSpace );
412 break;
413 case SID_ATTR_PARA_LINESPACE_10: ePropL = 100; goto SET_LINESPACE;
414 case SID_ATTR_PARA_LINESPACE_15: ePropL = 150; goto SET_LINESPACE;
415 case SID_ATTR_PARA_LINESPACE_20: ePropL = 200; goto SET_LINESPACE;
417 SET_LINESPACE:
420 SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING );
421 aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
422 if( 100 == ePropL )
423 aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
424 else
425 aLineSpacing.SetPropLineSpace(ePropL);
426 aSet.Put( aLineSpacing );
428 break;
430 case SID_ATTR_PARA_LEFT_TO_RIGHT :
431 case SID_ATTR_PARA_RIGHT_TO_LEFT :
433 BOOL bSet = TRUE;
434 int eState = pArgs ? pArgs->GetItemState(nSlot) : SFX_ITEM_DISABLED;
435 if (pArgs && SFX_ITEM_SET == eState)
436 bSet = ((const SfxBoolItem&)pArgs->Get(nSlot)).GetValue();
438 // toggling of the slots not used anymore
440 if(!bSet)
441 nSlot = SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot ?
442 SID_ATTR_PARA_RIGHT_TO_LEFT :
443 SID_ATTR_PARA_LEFT_TO_RIGHT;
445 SfxItemSet aAdjustSet( GetPool(),
446 RES_PARATR_ADJUST, RES_PARATR_ADJUST );
447 GetShell().GetCurAttr(aAdjustSet);
448 BOOL bChgAdjust = FALSE;
449 SfxItemState eAdjustState = aAdjustSet.GetItemState(RES_PARATR_ADJUST, FALSE);
450 if(eAdjustState >= SFX_ITEM_DEFAULT)
452 int eAdjust = (int)(( const SvxAdjustItem& )
453 aAdjustSet.Get(RES_PARATR_ADJUST)).GetAdjust();
454 // bChgAdjust = SVX_ADJUST_CENTER != eAdjust && SVX_ADJUST_BLOCK != eAdjust;
455 bChgAdjust = (SVX_ADJUST_LEFT == eAdjust && SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot) ||
456 (SVX_ADJUST_RIGHT == eAdjust && SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot);
458 else
459 bChgAdjust = TRUE;
461 SvxFrameDirection eFrmDirection =
462 (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
463 FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
464 aSet.Put( SvxFrameDirectionItem( eFrmDirection, RES_FRAMEDIR ) );
466 if (bChgAdjust)
468 SvxAdjust eAdjust = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
469 SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT;
470 SvxAdjustItem aAdjust( eAdjust, RES_PARATR_ADJUST );
471 aSet.Put( aAdjust );
472 aAdjust.SetWhich(SID_ATTR_PARA_ADJUST);
473 GetView().GetViewFrame()->GetBindings().SetState( aAdjust );
474 // Toggle numbering alignment
475 const SwNumRule* pCurRule = GetShell().GetCurNumRule();
476 if( pCurRule )
478 SvxNumRule aRule = pCurRule->MakeSvxNumRule();
480 for(USHORT i = 0; i < aRule.GetLevelCount(); i++)
482 SvxNumberFormat aFmt(aRule.GetLevel(i));
483 if(SVX_ADJUST_LEFT == aFmt.GetNumAdjust())
484 aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
486 else if(SVX_ADJUST_RIGHT == aFmt.GetNumAdjust())
487 aFmt.SetNumAdjust( SVX_ADJUST_LEFT );
489 aRule.SetLevel(i, aFmt, aRule.Get(i) != 0);
491 // --> OD 2008-02-11 #newlistlevelattrs#
492 SwNumRule aSetRule( pCurRule->GetName(),
493 pCurRule->Get( 0 ).GetPositionAndSpaceMode() );
494 // <--
495 aSetRule.SetSvxRule( aRule, GetShell().GetDoc());
496 aSetRule.SetAutoRule( TRUE );
497 // --> OD 2008-03-17 #refactorlists#
498 // no start or continuation of a list - list style is only changed
499 GetShell().SetCurNumRule( aSetRule, false );
500 // <--
504 break;
506 default:
507 ASSERT(FALSE, falscher Dispatcher);
508 return;
510 SwWrtShell& rWrtSh = GetShell();
511 SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
512 if(pColl && pColl->IsAutoUpdateFmt())
514 rWrtSh.AutoUpdatePara(pColl, aSet);
516 else
517 rWrtSh.SetAttr( aSet );
518 rReq.Done();
521 #endif
525 void SwTextShell::ExecParaAttrArgs(SfxRequest &rReq)
527 SwWrtShell &rSh = GetShell();
528 const SfxItemSet *pArgs = rReq.GetArgs();
529 const SfxPoolItem *pItem = 0;
531 USHORT nSlot = rReq.GetSlot();
532 if(pArgs)
533 pArgs->GetItemState(GetPool().GetWhich(nSlot), FALSE, &pItem);
534 switch ( nSlot )
536 case FN_DROP_CHAR_STYLE_NAME:
537 if( pItem )
539 String sCharStyleName = ((const SfxStringItem*)pItem)->GetValue();
540 SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP, 0L);
541 rSh.GetCurAttr(aSet);
542 SwFmtDrop aDropItem((const SwFmtDrop&)aSet.Get(RES_PARATR_DROP));
543 SwCharFmt* pFmt = 0;
544 if(sCharStyleName.Len())
545 pFmt = rSh.FindCharFmtByName( sCharStyleName );
546 aDropItem.SetCharFmt( pFmt );
547 aSet.Put(aDropItem);
548 rSh.SetAttr(aSet);
550 break;
551 case FN_FORMAT_DROPCAPS:
553 if(pItem)
555 rSh.SetAttr(*pItem);
556 rReq.Done();
558 else
560 SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP,
561 HINT_END, HINT_END, 0);
562 rSh.GetCurAttr(aSet);
563 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
564 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
566 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aSet,
567 rSh.GetView().GetViewFrame()->GetFrame()->GetFrameInterface(), DLG_SWDROPCAPS );
568 DBG_ASSERT(pDlg, "Dialogdiet fail!");
569 if (pDlg->Execute() == RET_OK)
571 rSh.StartAction();
572 rSh.StartUndo( UNDO_START );
573 if ( SFX_ITEM_SET == aSet.GetItemState(HINT_END,FALSE,&pItem) )
575 if ( ((SfxStringItem*)pItem)->GetValue().Len() )
576 rSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue());
578 rSh.SetAttr(*pDlg->GetOutputItemSet());
579 rSh.StartUndo( UNDO_END );
580 rSh.EndAction();
581 rReq.Done(*pDlg->GetOutputItemSet());
583 delete pDlg;
586 break;
587 case SID_ATTR_PARA_PAGEBREAK:
588 if(pItem)
590 rSh.SetAttr( *pItem );
591 rReq.Done();
593 break;
594 case SID_ATTR_PARA_MODEL:
596 if(pItem)
598 SfxItemSet aCoreSet( GetPool(),
599 RES_PAGEDESC, RES_PAGEDESC,
600 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL, 0);
601 aCoreSet.Put(*pItem);
602 SfxToSwPageDescAttr( rSh, aCoreSet);
603 rSh.SetAttr(aCoreSet);
604 rReq.Done();
607 break;
609 default:
610 ASSERT(FALSE, falscher Dispatcher);
611 return;
617 void SwTextShell::GetAttrState(SfxItemSet &rSet)
619 SwWrtShell &rSh = GetShell();
620 SfxItemPool& rPool = GetPool();
621 SfxItemSet aCoreSet(rPool, aTxtFmtCollSetRange);
622 rSh.GetCurAttr(aCoreSet); // *alle* Textattribute von der Core erfragen
624 SfxWhichIter aIter(rSet);
625 USHORT nSlot = aIter.FirstWhich();
626 sal_Bool bFlag = sal_False;
627 SfxBoolItem aFlagItem;
628 const SfxPoolItem* pItem = 0;
629 int eAdjust = -1; // Illegaler Wert, um DONTCARE zu erkennen
630 SfxItemState eState = aCoreSet.GetItemState(RES_PARATR_ADJUST, FALSE, &pItem);
632 if( SFX_ITEM_DEFAULT == eState )
633 pItem = &rPool.GetDefaultItem(RES_PARATR_ADJUST);
634 if( SFX_ITEM_DEFAULT <= eState )
635 eAdjust = (int)(( SvxAdjustItem* ) pItem)->GetAdjust();
637 short nEsc = 0;
638 eState = aCoreSet.GetItemState(RES_CHRATR_ESCAPEMENT, FALSE, &pItem);
639 if( SFX_ITEM_DEFAULT == eState )
640 pItem = &rPool.GetDefaultItem(RES_CHRATR_ESCAPEMENT);
641 if( eState >= SFX_ITEM_DEFAULT )
642 nEsc = ((SvxEscapementItem* )pItem)->GetEsc();
644 USHORT nLineSpace = 0;
645 eState = aCoreSet.GetItemState(RES_PARATR_LINESPACING, FALSE, &pItem);
646 if( SFX_ITEM_DEFAULT == eState )
647 pItem = &rPool.GetDefaultItem(RES_PARATR_LINESPACING);
648 if( SFX_ITEM_DEFAULT <= eState &&
649 ((SvxLineSpacingItem* )pItem)->GetLineSpaceRule() == SVX_LINE_SPACE_AUTO )
651 if(SVX_INTER_LINE_SPACE_OFF ==
652 ((SvxLineSpacingItem* )pItem)->GetInterLineSpaceRule())
653 nLineSpace = 100;
654 else
655 nLineSpace = ((SvxLineSpacingItem* )pItem)->GetPropLineSpace();
658 while (nSlot)
660 switch(nSlot)
662 case FN_SET_SUPER_SCRIPT:
663 bFlag = 0 < nEsc;
664 break;
665 case FN_SET_SUB_SCRIPT:
666 bFlag = 0 > nEsc;
667 break;
668 case SID_ATTR_PARA_ADJUST_LEFT:
669 if (eAdjust == -1)
671 rSet.InvalidateItem( nSlot );
672 nSlot = 0;
674 else
675 bFlag = SVX_ADJUST_LEFT == eAdjust;
676 break;
677 case SID_ATTR_PARA_ADJUST_RIGHT:
678 if (eAdjust == -1)
680 rSet.InvalidateItem( nSlot );
681 nSlot = 0;
683 else
684 bFlag = SVX_ADJUST_RIGHT == eAdjust;
685 break;
686 case SID_ATTR_PARA_ADJUST_CENTER:
687 if (eAdjust == -1)
689 rSet.InvalidateItem( nSlot );
690 nSlot = 0;
692 else
693 bFlag = SVX_ADJUST_CENTER == eAdjust;
694 break;
695 case SID_ATTR_PARA_ADJUST_BLOCK:
697 if (eAdjust == -1)
699 rSet.InvalidateItem( nSlot );
700 nSlot = 0;
702 else
704 bFlag = SVX_ADJUST_BLOCK == eAdjust;
705 USHORT nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
706 if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & (HTMLMODE_FULL_STYLES|HTMLMODE_FIRSTLINE) ))
708 rSet.DisableItem( nSlot );
709 nSlot = 0;
713 break;
714 case SID_ATTR_PARA_LINESPACE_10:
715 bFlag = nLineSpace == 100;
716 break;
717 case SID_ATTR_PARA_LINESPACE_15:
718 bFlag = nLineSpace == 150;
719 break;
720 case SID_ATTR_PARA_LINESPACE_20:
721 bFlag = nLineSpace == 200;
722 break;
723 case FN_GROW_FONT_SIZE:
724 case FN_SHRINK_FONT_SIZE:
726 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT,
727 *rSet.GetPool() );
728 aSetItem.GetItemSet().Put( aCoreSet, FALSE );
729 if( !aSetItem.GetItemOfScript( rSh.GetScriptType() ))
730 rSet.DisableItem( nSlot );
731 nSlot = 0;
733 break;
734 case FN_UNDERLINE_DOUBLE:
736 eState = aCoreSet.GetItemState(RES_CHRATR_UNDERLINE);
737 if( eState >= SFX_ITEM_DEFAULT )
739 FontUnderline eUnderline = ((const SvxUnderlineItem&)
740 aCoreSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle();
741 rSet.Put(SfxBoolItem(nSlot, eUnderline == UNDERLINE_DOUBLE));
743 else
744 rSet.InvalidateItem(nSlot);
745 nSlot = 0;
747 break;
748 case SID_ATTR_PARA_ADJUST:
749 if (eAdjust == -1)
750 rSet.InvalidateItem( nSlot );
751 else
752 rSet.Put(SvxAdjustItem((SvxAdjust)eAdjust, SID_ATTR_PARA_ADJUST ));
753 nSlot = 0;
754 break;
756 case SID_ATTR_PARA_LEFT_TO_RIGHT :
757 case SID_ATTR_PARA_RIGHT_TO_LEFT :
759 if ( !SW_MOD()->GetCTLOptions().IsCTLFontEnabled() )
761 rSet.DisableItem( nSlot );
762 nSlot = 0;
764 else
766 // is the item set?
767 USHORT nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
768 if((!(nHtmlMode & HTMLMODE_ON) || (0 != (nHtmlMode & HTMLMODE_SOME_STYLES))) &&
769 aCoreSet.GetItemState( RES_FRAMEDIR, FALSE ) >= SFX_ITEM_DEFAULT)
771 SvxFrameDirection eFrmDir = (SvxFrameDirection)
772 ((const SvxFrameDirectionItem& )aCoreSet.Get(RES_FRAMEDIR)).GetValue();
773 if (FRMDIR_ENVIRONMENT == eFrmDir)
775 eFrmDir = rSh.IsInRightToLeftText() ?
776 FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP;
778 bFlag = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot &&
779 FRMDIR_HORI_LEFT_TOP == eFrmDir) ||
780 (SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot &&
781 FRMDIR_HORI_RIGHT_TOP == eFrmDir);
783 else
785 rSet.InvalidateItem(nSlot);
786 nSlot = 0;
790 break;
792 case SID_ATTR_CHAR_LANGUAGE:
793 case SID_ATTR_CHAR_KERNING:
794 case RES_PARATR_DROP:
796 #if OSL_DEBUG_LEVEL > 1
797 const SfxPoolItem& rItem = aCoreSet.Get(GetPool().GetWhich(nSlot), TRUE);
798 rSet.Put(rItem);
799 #else
800 rSet.Put(aCoreSet.Get( GetPool().GetWhich(nSlot), TRUE));
801 #endif
802 nSlot = 0;
804 break;
805 case SID_ATTR_PARA_MODEL:
807 SfxItemSet aTemp(GetPool(),
808 RES_PAGEDESC,RES_PAGEDESC,
809 SID_ATTR_PARA_MODEL,SID_ATTR_PARA_MODEL,
810 0L);
811 aTemp.Put(aCoreSet);
812 ::SwToSfxPageDescAttr(aTemp);
813 rSet.Put(aTemp.Get(SID_ATTR_PARA_MODEL));
814 nSlot = 0;
816 break;
817 case RES_TXTATR_INETFMT:
819 SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
820 rSh.GetCurAttr(aSet);
821 #if OSL_DEBUG_LEVEL > 1
822 const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT, TRUE);
823 rSet.Put(rItem);
824 #else
825 rSet.Put(aSet.Get( RES_TXTATR_INETFMT, TRUE));
826 #endif
827 nSlot = 0;
829 break;
831 default:
832 // Nichts tun
833 nSlot = 0;
834 break;
837 if( nSlot )
839 aFlagItem.SetWhich( nSlot );
840 aFlagItem.SetValue( bFlag );
841 rSet.Put( aFlagItem );
843 nSlot = aIter.NextWhich();
846 rSet.Put(aCoreSet,FALSE);