summaryrefslogtreecommitdiff
path: root/sw/source/ui/shells/txtattr.cxx
blob: 71571fd928807dd5dc3369e9e93a80b6568b2f2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * 
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"


#include <hintids.hxx>

#include <vcl/msgbox.hxx>
#include <svl/whiter.hxx>
#include <svl/stritem.hxx>
#include <svl/itemiter.hxx>
#include <svl/ctloptions.hxx>
#include <swmodule.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/request.hxx>
#include <editeng/fhgtitem.hxx>
#include <editeng/adjitem.hxx>
#include <editeng/lspcitem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/escpitem.hxx>
#include <svx/htmlmode.hxx>
#include <editeng/scripttypeitem.hxx>
#include <editeng/frmdiritem.hxx>
#include "paratr.hxx"

#include <fmtinfmt.hxx>
#include <docsh.hxx>
#include <wrtsh.hxx>
#include <view.hxx>
#include <viewopt.hxx>
#include <uitool.hxx>
#include <textsh.hxx>
#include <num.hxx>
#include <swundo.hxx>
#include <fmtcol.hxx>

#include <cmdid.h>
#include <globals.h>
#include <shells.hrc>
#include <SwStyleNameMapper.hxx>
#include "swabstdlg.hxx"
#include "chrdlg.hrc"
const SwTwips lFontInc = 2 * 20;		   // ==> PointToTwips(2)
const SwTwips lFontMaxSz = 72 * 20; 	   // ==> PointToTwips(72)




void SwTextShell::ExecCharAttr(SfxRequest &rReq)
{
    SwWrtShell &rSh = GetShell();
    const SfxItemSet  *pArgs   = rReq.GetArgs();
          int          eState = STATE_TOGGLE;
    USHORT nWhich = rReq.GetSlot();

    if(pArgs )
    {
        const SfxPoolItem* pItem;
        pArgs->GetItemState(nWhich, FALSE, &pItem);
        eState =  ((const SfxBoolItem &) pArgs->
                                Get( nWhich )).GetValue() ? STATE_ON : STATE_OFF;
    }


    SfxItemSet aSet( GetPool(), RES_CHRATR_BEGIN, RES_CHRATR_END-1 );
    if (STATE_TOGGLE == eState)
        rSh.GetCurAttr( aSet );

    switch ( nWhich )
    {
        case FN_SET_SUB_SCRIPT:
        case FN_SET_SUPER_SCRIPT:
        {
            SvxEscapement eEscape = SVX_ESCAPEMENT_SUBSCRIPT;
            switch (eState)
            {
            case STATE_TOGGLE:
            {
                short nTmpEsc = ((const SvxEscapementItem&)
                            aSet.Get( RES_CHRATR_ESCAPEMENT )).GetEsc();
                eEscape = nWhich == FN_SET_SUPER_SCRIPT ?
                                SVX_ESCAPEMENT_SUPERSCRIPT:
                                SVX_ESCAPEMENT_SUBSCRIPT;
                if( nWhich == FN_SET_SUB_SCRIPT && nTmpEsc < 0 ||
                            nWhich == FN_SET_SUPER_SCRIPT && nTmpEsc > 0 )
                    eEscape = SVX_ESCAPEMENT_OFF;

                SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
                if( nWhich == FN_SET_SUB_SCRIPT )
                    rBind.SetState( SfxBoolItem( FN_SET_SUPER_SCRIPT,
                                                                    FALSE ) );
                else
                    rBind.SetState( SfxBoolItem( FN_SET_SUB_SCRIPT,
                                                                    FALSE ) );

            }
            break;
            case STATE_ON:
                eEscape = nWhich == FN_SET_SUPER_SCRIPT ?
                                SVX_ESCAPEMENT_SUPERSCRIPT:
                                SVX_ESCAPEMENT_SUBSCRIPT;
                break;
            case STATE_OFF:
                eEscape = SVX_ESCAPEMENT_OFF;
                break;
            }
            SvxEscapementItem aEscape( eEscape, RES_CHRATR_ESCAPEMENT );
            if(eEscape == SVX_ESCAPEMENT_SUPERSCRIPT)
                aEscape.GetEsc() = DFLT_ESC_AUTO_SUPER;
            else if(eEscape == SVX_ESCAPEMENT_SUBSCRIPT)
                aEscape.GetEsc() = DFLT_ESC_AUTO_SUB;
            if(eState != STATE_OFF )
            {
                if(eEscape == FN_SET_SUPER_SCRIPT)
                    aEscape.GetEsc() *= -1;
            }
            rSh.SetAttr( aEscape );
            rReq.AppendItem( aEscape );
            rReq.Done();
        }
        break;

        case FN_UPDATE_STYLE_BY_EXAMPLE:
            rSh.QuickUpdateStyle();
            rReq.Done();
            break;
        case FN_UNDERLINE_DOUBLE:
        {
            FontUnderline eUnderline =  ((const SvxUnderlineItem&)
                            aSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle();
            switch( eState )
            {
                case STATE_TOGGLE:
                    eUnderline = eUnderline == UNDERLINE_DOUBLE ?
                        UNDERLINE_NONE :
                            UNDERLINE_DOUBLE;
                break;
                case STATE_ON:
                    eUnderline = UNDERLINE_DOUBLE;
                break;
                case STATE_OFF:
                    eUnderline = UNDERLINE_NONE;
                break;
            }
            SvxUnderlineItem aUnderline(eUnderline, RES_CHRATR_UNDERLINE );
            rSh.SetAttr( aUnderline );
            rReq.AppendItem( aUnderline );
            rReq.Done();
        }
        break;
        case FN_REMOVE_DIRECT_CHAR_FORMATS:
            if( !rSh.HasReadonlySel() && rSh.IsEndPara())
                rSh.DontExpandFmt();
        break;
        default:
            OSL_ENSURE(false, "wrong  dispatcher");
            return;
    }
}


void SwTextShell::ExecCharAttrArgs(SfxRequest &rReq)
{
    USHORT nSlot = rReq.GetSlot();
    const SfxItemSet* pArgs = rReq.GetArgs();
    BOOL bArgs = pArgs != 0 && pArgs->Count() > 0;
    int bGrow = FALSE;
    SwWrtShell& rWrtSh = GetShell();
    SwTxtFmtColl* pColl = 0;

    // nur gesetzt, wenn gesamter Absatz selektiert ist und AutoUpdateFmt gesetzt ist
    if( rWrtSh.HasSelection() && rWrtSh.IsSelFullPara() )
    {
        pColl = rWrtSh.GetCurTxtFmtColl();
        if(pColl && !pColl->IsAutoUpdateFmt())
            pColl = 0;
    }
    SfxItemPool& rPool = GetPool();
    USHORT nWhich = rPool.GetWhich(nSlot);
    switch ( nSlot )
    {
        case FN_TXTATR_INET:
        // Sonderbehandlung der PoolId des SwFmtInetFmt
        if(bArgs)
        {
            const SfxPoolItem& rItem = pArgs->Get(nWhich );

            SwFmtINetFmt aINetFmt((const SwFmtINetFmt&)rItem);
            if( USHRT_MAX == aINetFmt.GetVisitedFmtId() )
            {
                aINetFmt.SetVisitedFmtId(
                        SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetVisitedFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT));
            }
            if( USHRT_MAX == aINetFmt.GetINetFmtId() )
            {
                aINetFmt.SetINetFmtId(
                        SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetINetFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT));
            }

            if ( pColl )
                pColl->SetFmtAttr( aINetFmt );
            else rWrtSh.SetAttr( aINetFmt );
            rReq.Done();
        }
        break;

        case FN_GROW_FONT_SIZE:
            bGrow = TRUE;
            // kein break !!
        case FN_SHRINK_FONT_SIZE:
        {
            SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, rPool );
            rWrtSh.GetCurAttr( aSetItem.GetItemSet() );
            SfxItemSet aAttrSet( rPool, aSetItem.GetItemSet().GetRanges() );

            const SfxPoolItem* pI;
            static const USHORT aScrTypes[] = {
                SCRIPTTYPE_LATIN, SCRIPTTYPE_ASIAN, SCRIPTTYPE_COMPLEX, 0 };
            USHORT nScriptType = rWrtSh.GetScriptType();
            for( const USHORT* pScrpTyp = aScrTypes; *pScrpTyp; ++pScrpTyp )
                if( ( nScriptType & *pScrpTyp ) &&
                    0 != ( pI = aSetItem.GetItemOfScript( *pScrpTyp )))
                {
                    SvxFontHeightItem aSize( *(const SvxFontHeightItem*)pI );
                    SwTwips lSize = (SwTwips) aSize.GetHeight();

                    if (bGrow)
                    {
                        if( lSize == lFontMaxSz )
                            break;		// das wars, hoeher gehts nicht
                        if( ( lSize += lFontInc ) > lFontMaxSz )
                            lSize = lFontMaxSz;
                    }
                    else
                    {
                        if( 4 == lSize )
                            break;
                        if( ( lSize -= lFontInc ) < 4 )
                            lSize = 4;
                    }
                    aSize.SetHeight( lSize );
                    aAttrSet.Put( aSize );
                }
                if( aAttrSet.Count() )
                {
                    if( pColl )
                        pColl->SetFmtAttr( aAttrSet );
                    else
                        rWrtSh.SetAttr( aAttrSet );
                }
            rReq.Done();
        }
        break;

        default:
            OSL_ENSURE(false, "wrong  dispatcher");
            return;
    }
}



#ifdef CFRONT

void lcl_SetAdjust(SvxAdjust eAdjst, SfxItemSet& rSet)
{
    rSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST ));
}



void lcl_SetLineSpace(BYTE ePropL,SfxItemSet& rSet)
{
    SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING );
    aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
    if( 100 == ePropL )
        aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
    else
        aLineSpacing.SetPropLineSpace(ePropL);
    rSet.Put( aLineSpacing );
}



void SwTextShell::ExecParaAttr(SfxRequest &rReq)
{
    // gleiche beide Attribute holen, ist nicht teuerer !!
    SfxItemSet aSet( GetPool(), RES_PARATR_LINESPACING, RES_PARATR_ADJUST );

    switch (rReq.GetSlot())
    {
    case FN_SET_LEFT_PARA:			lcl_SetAdjust(ADJLEFT,aSet); 	break;
    case FN_SET_RIGHT_PARA:			lcl_SetAdjust(ADJRIGHT,aSet); 	break;
    case FN_SET_CENTER_PARA:        lcl_SetAdjust(ADJCENTER,aSet); 	break;
    case SID_ATTR_PARA_ADJUST_BLOCK:lcl_SetAdjust(ADJBLOCK,aSet); 	break;

    case FN_SET_LINE_SPACE_1:	lcl_SetLineSpace(100,aSet); 	break;
    case FN_SET_LINE_SPACE_15:  lcl_SetLineSpace(150,aSet); 	break;
    case FN_SET_LINE_SPACE_2:	lcl_SetLineSpace(200,aSet); 	break;

    default:
        OSL_ENSURE(false, "SwTextShell::ExecParaAttr wrong Dispatcher");
        return;
    }
    SwWrtShell& rWrtSh = GetShell();
    SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
    if(pColl && pColl->IsAutoUpdateFmt())
    {
        rWrtSh.AutoUpdatePara(pColl, *pSet);
    }
    else
    {
        rWrtSh.SetAttr( aSet );
        rReq.Done( aSet );
    }
}

#else



void SwTextShell::ExecParaAttr(SfxRequest &rReq)
{
    SvxAdjust eAdjst;
    BYTE ePropL;
    const SfxItemSet* pArgs = rReq.GetArgs();

    // gleich beide Attribute holen, ist nicht teuerer !!
    SfxItemSet aSet( GetPool(),
        RES_PARATR_LINESPACING, RES_PARATR_ADJUST,
        RES_FRAMEDIR, RES_FRAMEDIR,
        0 );

    USHORT nSlot = rReq.GetSlot();
    switch (nSlot)
    {
        case SID_ATTR_PARA_ADJUST:
        {
            if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_PARATR_ADJUST) )
            {
                const SvxAdjustItem& rAdj = (const SvxAdjustItem&) pArgs->Get(RES_PARATR_ADJUST);
                SvxAdjustItem aAdj( rAdj.GetAdjust(), RES_PARATR_ADJUST );
                if ( rAdj.GetAdjust() == SVX_ADJUST_BLOCK )
                {
                    aAdj.SetLastBlock( rAdj.GetLastBlock() );
                    aAdj.SetOneWord( rAdj.GetOneWord() );
                }

                aSet.Put(aAdj);
            }
        }
        break;
        case SID_ATTR_PARA_ADJUST_LEFT:		eAdjst =  SVX_ADJUST_LEFT;		goto SET_ADJUST;
        case SID_ATTR_PARA_ADJUST_RIGHT:	eAdjst =  SVX_ADJUST_RIGHT;		goto SET_ADJUST;
        case SID_ATTR_PARA_ADJUST_CENTER:   eAdjst =  SVX_ADJUST_CENTER;	goto SET_ADJUST;
        case SID_ATTR_PARA_ADJUST_BLOCK:	eAdjst =  SVX_ADJUST_BLOCK;		goto SET_ADJUST;
SET_ADJUST:
        {
            aSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST));
            rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), TRUE ) );
        }
        break;

        case SID_ATTR_PARA_LINESPACE:
            if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( GetPool().GetWhich(nSlot) ))
            {
                SvxLineSpacingItem aLineSpace = (const SvxLineSpacingItem&)pArgs->Get(
                                                            GetPool().GetWhich(nSlot));
                aSet.Put( aLineSpace );
            }
        break;
        case SID_ATTR_PARA_LINESPACE_10:	ePropL = 100;	goto SET_LINESPACE;
        case SID_ATTR_PARA_LINESPACE_15:	ePropL = 150;	goto SET_LINESPACE;
        case SID_ATTR_PARA_LINESPACE_20:	ePropL = 200;	goto SET_LINESPACE;

SET_LINESPACE:
        {

            SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING );
            aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
            if( 100 == ePropL )
                aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
            else
                aLineSpacing.SetPropLineSpace(ePropL);
            aSet.Put( aLineSpacing );
        }
        break;

        case SID_ATTR_PARA_LEFT_TO_RIGHT :
        case SID_ATTR_PARA_RIGHT_TO_LEFT :
        {
            BOOL bSet = TRUE;
            int eState = pArgs ? pArgs->GetItemState(nSlot) : SFX_ITEM_DISABLED;
            if (pArgs && SFX_ITEM_SET == eState)
                bSet = ((const SfxBoolItem&)pArgs->Get(nSlot)).GetValue();
/*
// toggling of the slots not used anymore

           if(!bSet)
                nSlot = SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot ?
                    SID_ATTR_PARA_RIGHT_TO_LEFT :
                    SID_ATTR_PARA_LEFT_TO_RIGHT;
*/
            SfxItemSet aAdjustSet( GetPool(),
                    RES_PARATR_ADJUST, RES_PARATR_ADJUST );
            GetShell().GetCurAttr(aAdjustSet);
            BOOL bChgAdjust = FALSE;
            SfxItemState eAdjustState = aAdjustSet.GetItemState(RES_PARATR_ADJUST, FALSE);
            if(eAdjustState  >= SFX_ITEM_DEFAULT)
            {
                int eAdjust = (int)(( const SvxAdjustItem& )
                        aAdjustSet.Get(RES_PARATR_ADJUST)).GetAdjust();
//                bChgAdjust = SVX_ADJUST_CENTER  != eAdjust  &&  SVX_ADJUST_BLOCK != eAdjust;
                bChgAdjust = (SVX_ADJUST_LEFT  == eAdjust  &&  SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot) ||
                             (SVX_ADJUST_RIGHT == eAdjust  &&  SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot);
            }
            else
                bChgAdjust = TRUE;

            SvxFrameDirection eFrmDirection =
                    (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
                        FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
            aSet.Put( SvxFrameDirectionItem( eFrmDirection, RES_FRAMEDIR ) );

            if (bChgAdjust)
            {
                SvxAdjust eAdjust = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
                        SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT;
                SvxAdjustItem aAdjust( eAdjust, RES_PARATR_ADJUST );
                aSet.Put( aAdjust );
                aAdjust.SetWhich(SID_ATTR_PARA_ADJUST);
                GetView().GetViewFrame()->GetBindings().SetState( aAdjust );
                // Toggle numbering alignment
                const SwNumRule* pCurRule = GetShell().GetCurNumRule();
                if( pCurRule )
                {
                    SvxNumRule aRule = pCurRule->MakeSvxNumRule();

                    for(USHORT i = 0; i < aRule.GetLevelCount(); i++)
                    {
                        SvxNumberFormat aFmt(aRule.GetLevel(i));
                        if(SVX_ADJUST_LEFT == aFmt.GetNumAdjust())
                            aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );

                        else if(SVX_ADJUST_RIGHT == aFmt.GetNumAdjust())
                            aFmt.SetNumAdjust( SVX_ADJUST_LEFT );

                        aRule.SetLevel(i, aFmt, aRule.Get(i) != 0);
                    }
                    // --> OD 2008-02-11 #newlistlevelattrs#
                    SwNumRule aSetRule( pCurRule->GetName(),
                                        pCurRule->Get( 0 ).GetPositionAndSpaceMode() );
                    // <--
                    aSetRule.SetSvxRule( aRule, GetShell().GetDoc());
                    aSetRule.SetAutoRule( TRUE );
                    // --> OD 2008-03-17 #refactorlists#
                    // no start or continuation of a list - list style is only changed
                    GetShell().SetCurNumRule( aSetRule, false );
                    // <--
                }
            }
        }
        break;

        default:
            OSL_ENSURE(false, "wrong  dispatcher");
            return;
    }
    SwWrtShell& rWrtSh = GetShell();
    SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
    if(pColl && pColl->IsAutoUpdateFmt())
    {
        rWrtSh.AutoUpdatePara(pColl, aSet);
    }
    else
        rWrtSh.SetAttr( aSet );
    rReq.Done();
}

#endif



void SwTextShell::ExecParaAttrArgs(SfxRequest &rReq)
{
    SwWrtShell &rSh = GetShell();
    const SfxItemSet *pArgs = rReq.GetArgs();
    const SfxPoolItem *pItem = 0;

    USHORT nSlot = rReq.GetSlot();
    if(pArgs)
        pArgs->GetItemState(GetPool().GetWhich(nSlot), FALSE, &pItem);
    switch ( nSlot )
    {
        case FN_DROP_CHAR_STYLE_NAME:
            if( pItem )
            {
                String sCharStyleName = ((const SfxStringItem*)pItem)->GetValue();
                SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP, 0L);
                rSh.GetCurAttr(aSet);
                SwFmtDrop aDropItem((const SwFmtDrop&)aSet.Get(RES_PARATR_DROP));
                SwCharFmt* pFmt = 0;
                if(sCharStyleName.Len())
                    pFmt = rSh.FindCharFmtByName( sCharStyleName );
                aDropItem.SetCharFmt( pFmt );
                aSet.Put(aDropItem);
                rSh.SetAttr(aSet);
            }
        break;
        case FN_FORMAT_DROPCAPS:
        {
            if(pItem)
            {
                rSh.SetAttr(*pItem);
                rReq.Done();
            }
            else
            {
                SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP,
                                           HINT_END, HINT_END, 0);
                rSh.GetCurAttr(aSet);
                SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
                OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");

                SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aSet, 
                    rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), DLG_SWDROPCAPS );
                OSL_ENSURE(pDlg, "Dialogdiet fail!");
                if (pDlg->Execute() == RET_OK)
                {
                    rSh.StartAction();
                    rSh.StartUndo( UNDO_START );
                    if ( SFX_ITEM_SET == aSet.GetItemState(HINT_END,FALSE,&pItem) )
                    {
                        if ( ((SfxStringItem*)pItem)->GetValue().Len() )
                            rSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue());
                    }
                    rSh.SetAttr(*pDlg->GetOutputItemSet());
                    rSh.StartUndo( UNDO_END );
                    rSh.EndAction();
                    rReq.Done(*pDlg->GetOutputItemSet());
                }
                delete pDlg;
            }
        }
         break;
        case SID_ATTR_PARA_PAGEBREAK:
            if(pItem)
            {
                rSh.SetAttr( *pItem );
                rReq.Done();
            }
        break;
        case SID_ATTR_PARA_MODEL:
        {
            if(pItem)
            {
                SfxItemSet aCoreSet( GetPool(),
                    RES_PAGEDESC,	RES_PAGEDESC,
                    SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL, 0);
                aCoreSet.Put(*pItem);
                SfxToSwPageDescAttr( rSh, aCoreSet);
                rSh.SetAttr(aCoreSet);
                rReq.Done();
            }
        }
        break;

        default:
            OSL_ENSURE(false, "wrong  dispatcher");
            return;
    }
}



void SwTextShell::GetAttrState(SfxItemSet &rSet)
{
    SwWrtShell &rSh = GetShell();
    SfxItemPool& rPool = GetPool();
    SfxItemSet aCoreSet(rPool, aTxtFmtCollSetRange);
    rSh.GetCurAttr(aCoreSet); // *alle* Textattribute von der Core erfragen

    SfxWhichIter aIter(rSet);
    USHORT nSlot = aIter.FirstWhich();
    sal_Bool bFlag = sal_False;
    SfxBoolItem aFlagItem;
    const SfxPoolItem* pItem = 0;
    int eAdjust = -1;	// Illegaler Wert, um DONTCARE zu erkennen
    SfxItemState eState = aCoreSet.GetItemState(RES_PARATR_ADJUST, FALSE, &pItem);

    if( SFX_ITEM_DEFAULT == eState )
        pItem = &rPool.GetDefaultItem(RES_PARATR_ADJUST);
    if( SFX_ITEM_DEFAULT <= eState )
        eAdjust = (int)(( SvxAdjustItem* ) pItem)->GetAdjust();

    short nEsc = 0;
    eState =  aCoreSet.GetItemState(RES_CHRATR_ESCAPEMENT, FALSE, &pItem);
    if( SFX_ITEM_DEFAULT == eState )
        pItem = &rPool.GetDefaultItem(RES_CHRATR_ESCAPEMENT);
    if( eState >= SFX_ITEM_DEFAULT )
        nEsc = ((SvxEscapementItem* )pItem)->GetEsc();

    USHORT nLineSpace = 0;
    eState =  aCoreSet.GetItemState(RES_PARATR_LINESPACING, FALSE, &pItem);
    if( SFX_ITEM_DEFAULT == eState )
        pItem = &rPool.GetDefaultItem(RES_PARATR_LINESPACING);
    if( SFX_ITEM_DEFAULT <= eState &&
            ((SvxLineSpacingItem* )pItem)->GetLineSpaceRule() == SVX_LINE_SPACE_AUTO )
    {
        if(SVX_INTER_LINE_SPACE_OFF ==
                    ((SvxLineSpacingItem* )pItem)->GetInterLineSpaceRule())
            nLineSpace = 100;
        else
            nLineSpace = ((SvxLineSpacingItem* )pItem)->GetPropLineSpace();
    }

    while (nSlot)
    {
        switch(nSlot)
        {
            case FN_SET_SUPER_SCRIPT:
                    bFlag = 0 < nEsc;
                break;
            case FN_SET_SUB_SCRIPT:
                    bFlag = 0 > nEsc;
                break;
            case SID_ATTR_PARA_ADJUST_LEFT:
                if (eAdjust == -1)
                {
                    rSet.InvalidateItem( nSlot );
                    nSlot = 0;
                }
                else
                    bFlag = SVX_ADJUST_LEFT == eAdjust;
                break;
            case SID_ATTR_PARA_ADJUST_RIGHT:
                if (eAdjust == -1)
                {
                    rSet.InvalidateItem( nSlot );
                    nSlot = 0;
                }
                else
                    bFlag = SVX_ADJUST_RIGHT == eAdjust;
                break;
            case SID_ATTR_PARA_ADJUST_CENTER:
                if (eAdjust == -1)
                {
                    rSet.InvalidateItem( nSlot );
                    nSlot = 0;
                }
                else
                    bFlag = SVX_ADJUST_CENTER == eAdjust;
                break;
            case SID_ATTR_PARA_ADJUST_BLOCK:
            {
                if (eAdjust == -1)
                {
                    rSet.InvalidateItem( nSlot );
                    nSlot = 0;
                }
                else
                {
                    bFlag = SVX_ADJUST_BLOCK == eAdjust;
                    USHORT nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
                    if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & (HTMLMODE_FULL_STYLES|HTMLMODE_FIRSTLINE) ))
                    {
                        rSet.DisableItem( nSlot );
                        nSlot = 0;
                    }
                }
            }
            break;
            case SID_ATTR_PARA_LINESPACE_10:
                bFlag = nLineSpace == 100;
            break;
            case SID_ATTR_PARA_LINESPACE_15:
                bFlag = nLineSpace == 150;
            break;
            case SID_ATTR_PARA_LINESPACE_20:
                bFlag = nLineSpace == 200;
            break;
            case FN_GROW_FONT_SIZE:
            case FN_SHRINK_FONT_SIZE:
            {
                SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT,
                                            *rSet.GetPool() );
                aSetItem.GetItemSet().Put( aCoreSet, FALSE );
                if( !aSetItem.GetItemOfScript( rSh.GetScriptType() ))
                    rSet.DisableItem( nSlot );
                nSlot = 0;
            }
            break;
            case FN_UNDERLINE_DOUBLE:
            {
                eState = aCoreSet.GetItemState(RES_CHRATR_UNDERLINE);
                if( eState >= SFX_ITEM_DEFAULT )
                {
                    FontUnderline eUnderline =  ((const SvxUnderlineItem&)
                            aCoreSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle();
                    rSet.Put(SfxBoolItem(nSlot, eUnderline == UNDERLINE_DOUBLE));
                }
                else
                    rSet.InvalidateItem(nSlot);
                nSlot = 0;
            }
            break;
            case SID_ATTR_PARA_ADJUST:
                if (eAdjust == -1)
                    rSet.InvalidateItem( nSlot );
                else
                    rSet.Put(SvxAdjustItem((SvxAdjust)eAdjust, SID_ATTR_PARA_ADJUST ));
                nSlot = 0;
            break;

            case SID_ATTR_PARA_LEFT_TO_RIGHT :
            case SID_ATTR_PARA_RIGHT_TO_LEFT :
            {
                if ( !SW_MOD()->GetCTLOptions().IsCTLFontEnabled() )
                {
                    rSet.DisableItem( nSlot );
                    nSlot = 0;
                }
                else
                {
                    // is the item set?
                    USHORT nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
                    if((!(nHtmlMode & HTMLMODE_ON) || (0 != (nHtmlMode & HTMLMODE_SOME_STYLES))) &&
                    aCoreSet.GetItemState( RES_FRAMEDIR, FALSE ) >= SFX_ITEM_DEFAULT)
                    {
                        SvxFrameDirection eFrmDir = (SvxFrameDirection)
                                ((const SvxFrameDirectionItem& )aCoreSet.Get(RES_FRAMEDIR)).GetValue();
                        if (FRMDIR_ENVIRONMENT == eFrmDir)
                        {
                            eFrmDir = rSh.IsInRightToLeftText() ?
                                    FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP;
                        }
                        bFlag = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot &&
                                            FRMDIR_HORI_LEFT_TOP == eFrmDir) ||
                                (SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot &&
                                            FRMDIR_HORI_RIGHT_TOP == eFrmDir);
                    }
                    else
                    {
                        rSet.InvalidateItem(nSlot);
                        nSlot = 0;
                    }
                }
            }
            break;

            case SID_ATTR_CHAR_LANGUAGE:
            case SID_ATTR_CHAR_KERNING:
            case RES_PARATR_DROP:
            {
#if OSL_DEBUG_LEVEL > 1
                const SfxPoolItem& rItem = aCoreSet.Get(GetPool().GetWhich(nSlot), TRUE);
                rSet.Put(rItem);
#else
                rSet.Put(aCoreSet.Get( GetPool().GetWhich(nSlot), TRUE));
#endif
                nSlot = 0;
            }
            break;
            case SID_ATTR_PARA_MODEL:
            {
                SfxItemSet aTemp(GetPool(),
                        RES_PAGEDESC,RES_PAGEDESC,
                        SID_ATTR_PARA_MODEL,SID_ATTR_PARA_MODEL,
                        0L);
                aTemp.Put(aCoreSet);
                ::SwToSfxPageDescAttr(aTemp);
                rSet.Put(aTemp.Get(SID_ATTR_PARA_MODEL));
                nSlot = 0;
            }
            break;
            case RES_TXTATR_INETFMT:
            {
                SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
                rSh.GetCurAttr(aSet);
#if OSL_DEBUG_LEVEL > 1
                const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT, TRUE);
                rSet.Put(rItem);
#else
                rSet.Put(aSet.Get( RES_TXTATR_INETFMT, TRUE));
#endif
                nSlot = 0;
            }
            break;

            default:
            // Nichts tun
            nSlot = 0;
            break;

        }
        if( nSlot )
        {
            aFlagItem.SetWhich( nSlot );
            aFlagItem.SetValue( bFlag );
            rSet.Put( aFlagItem );
        }
        nSlot = aIter.NextWhich();
    }

    rSet.Put(aCoreSet,FALSE);
}



/* vim:set shiftwidth=4 softtabstop=4 expandtab: */