summaryrefslogtreecommitdiff
path: root/sw/source/ui/uiview/viewtab.cxx
blob: 4bb32d3667a9fcad8908de8a54553c76207530bc (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
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
/* -*- 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 <tools/list.hxx>

#include <hintids.hxx>
#include "uitool.hxx"
#include <sfx2/app.hxx>
#include <svx/rulritem.hxx>
#include <editeng/tstpitem.hxx>
#include <sfx2/request.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/ulspitem.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/frmdiritem.hxx>
#include <svl/eitem.hxx>
#include <svl/whiter.hxx>
#include <svx/ruler.hxx>
#include <editeng/protitem.hxx>
#include <svl/rectitem.hxx>
#include <sfx2/bindings.hxx>
#include <fmtfsize.hxx>
#include <fmthdft.hxx>
#include <fmtclds.hxx>
#include <fmtornt.hxx>
#include <frmatr.hxx>
#include <edtwin.hxx>
#include "view.hxx"
#include "wrtsh.hxx"
#include "basesh.hxx"
#include "cmdid.h"
#include "viewopt.hxx"
#include "tabcol.hxx"
#include "frmfmt.hxx"       // FrameFormat
#include "pagedesc.hxx"     // Aktuelles Seitenformat
#include "wview.hxx"
#include "fmtcol.hxx"
#include "section.hxx"

// -> #i23726#
#include "ndtxt.hxx"
#include "pam.hxx"
// <- #i23726#

#include <IDocumentSettingAccess.hxx>

using namespace ::com::sun::star;


/*--------------------------------------------------------------------
    Beschreibung:   Debug-Methode
 --------------------------------------------------------------------*/

/*--------------------------------------------------------------------
    Beschreibung:   Columns eintueten
 --------------------------------------------------------------------*/
void lcl_FillSvxColumn(const SwFmtCol& rCol,
                          USHORT nTotalWidth,
                          SvxColumnItem& rColItem,
                          long nDistance)
{
    const SwColumns& rCols = rCol.GetColumns();
    USHORT nWidth = 0;

    BOOL bOrtho = rCol.IsOrtho() && rCols.Count();
    long nInnerWidth = 0;
    if( bOrtho )
    {
        nInnerWidth = nTotalWidth;
        for ( USHORT i = 0; i < rCols.Count(); ++i )
        {
            SwColumn* pCol = rCols[i];
            nInnerWidth -= pCol->GetLeft() + pCol->GetRight();
        }
        if( nInnerWidth < 0 )
            nInnerWidth = 0;
        else
            nInnerWidth /= rCols.Count();
    }
    for ( USHORT i = 0; i < rCols.Count(); ++i )
    {
        SwColumn* pCol = rCols[i];
        const USHORT nStart = USHORT(pCol->GetLeft() + nWidth + nDistance);
        if( bOrtho )
            nWidth = static_cast< USHORT >(nWidth + nInnerWidth + pCol->GetLeft() + pCol->GetRight());
        else
            nWidth = static_cast< USHORT >(nWidth + rCol.CalcColWidth(i, nTotalWidth));
        const USHORT nEnd = USHORT(nWidth - pCol->GetRight() + nDistance);

        SvxColumnDescription aColDesc(nStart, nEnd, TRUE);
        rColItem.Append(aColDesc);
    }
}

/*--------------------------------------------------------------------
    Beschreibung:   ColumnItem in ColumnInfo ueberfuehren
 --------------------------------------------------------------------*/
void lcl_ConvertToCols(const SvxColumnItem& rColItem,
                          USHORT nTotalWidth,
                          SwFmtCol& rCols)
{
    OSL_ENSURE( rCols.GetNumCols() == rColItem.Count(), "Column count mismatch" );
    // #126939# ruler executes that change the columns shortly after the selection has changed
    // can result in a crash
    if(rCols.GetNumCols() != rColItem.Count())
        return;

    USHORT nLeft    = 0;
    SwTwips nSumAll= 0;  // Summiere alle Spalten und Raender auf

    SwColumns& rArr = rCols.GetColumns();

    // Tabcols der Reihe nach
    for( USHORT i=0; i < rColItem.Count()-1; ++i )
    {
        OSL_ENSURE(rColItem[i+1].nStart >= rColItem[i].nEnd,"overlapping columns" );
        USHORT nStart = static_cast< USHORT >(rColItem[i+1].nStart);
        USHORT nEnd = static_cast< USHORT >(rColItem[i].nEnd);
        if(nStart < nEnd)
            nStart = nEnd;
        const USHORT nDiff  = nStart - nEnd;
        const USHORT nRight = nDiff / 2;

        USHORT nWidth = static_cast< USHORT >(rColItem[i].nEnd - rColItem[i].nStart);
        nWidth += nLeft + nRight;

        SwColumn* pCol = rArr[i];
        pCol->SetWishWidth( USHORT(long(rCols.GetWishWidth()) * long(nWidth) /
                                                            long(nTotalWidth) ));
        pCol->SetLeft( nLeft );
        pCol->SetRight( nRight );
        nSumAll += pCol->GetWishWidth();

        nLeft = nRight;
    }
    rArr[rColItem.Count()-1]->SetLeft( nLeft );

    //Die Differenz aus der Gesamtwunschbreite und der Summe der bisher berechneten
    // Spalten und Raender sollte die Breite der letzten Spalte ergeben.
    rArr[rColItem.Count()-1]->SetWishWidth( rCols.GetWishWidth() - (USHORT)nSumAll );

    rCols.SetOrtho(FALSE, 0, 0 );
}

/*--------------------------------------------------------------------
    Beschreibung:   Tabs loeschen
 --------------------------------------------------------------------*/
void lcl_EraseDefTabs(SvxTabStopItem& rTabStops)
{
    // Def Tabs loeschen
    for ( USHORT i = 0; i < rTabStops.Count(); )
    {
        // Hier auch den DefTab auf Null rausschmeissen
        if ( SVX_TAB_ADJUST_DEFAULT == rTabStops[i].GetAdjustment() ||
            rTabStops[i].GetTabPos() == 0 )
        {
            rTabStops.Remove(i);
            continue;
        }
        ++i;
    }
}

/*--------------------------------------------------------------------
    Beschreibung:   Seitenrand umdrehen
 --------------------------------------------------------------------*/
void SwView::SwapPageMargin(const SwPageDesc& rDesc, SvxLRSpaceItem& rLRSpace)
{
    USHORT nPhyPage, nVirPage;
    GetWrtShell().GetPageNum( nPhyPage, nVirPage );

    if ( rDesc.GetUseOn() == nsUseOnPage::PD_MIRROR && (nPhyPage % 2) == 0 )
    {
        long nTmp = rLRSpace.GetRight();
        rLRSpace.SetRight( rLRSpace.GetLeft() );
        rLRSpace.SetLeft( nTmp );
    }
}

/*--------------------------------------------------------------------
    Beschreibung:   Wenn der Rahmenrand verschoben wird, sollen die
                    Spaltentrenner an der gleichen absoluten Position bleiben
 --------------------------------------------------------------------*/
void lcl_Scale(long& nVal, long nScale)
{
    nVal *= nScale;
    nVal >>= 8;
}

void ResizeFrameCols(SwFmtCol& rCol,
                    long nOldWidth,
                    long nNewWidth,
                    long nLeftDelta )
{
    SwColumns& rArr = rCol.GetColumns();
    long nWishSum = (long)rCol.GetWishWidth();
    long nWishDiff = (nWishSum * 100/nOldWidth * nNewWidth) / 100 - nWishSum;
    long nNewWishWidth = nWishSum + nWishDiff;
    if(nNewWishWidth > 0xffffl)
    {
        // wenn die Wunschbreite zu gross wird, dann muessen alle Werte passend skaliert werden
        long nScale = (0xffffl << 8)/ nNewWishWidth;
        for(USHORT i = 0; i < rArr.Count(); i++)
        {
            SwColumn* pCol = rArr.GetObject(i);
            long nVal = pCol->GetWishWidth();
            lcl_Scale(nVal, nScale);
            pCol->SetWishWidth((USHORT) nVal);
            nVal = pCol->GetLeft();
            lcl_Scale(nVal, nScale);
            pCol->SetLeft((USHORT) nVal);
            nVal = pCol->GetRight();
            lcl_Scale(nVal, nScale);
            pCol->SetRight((USHORT) nVal);
        }
        lcl_Scale(nNewWishWidth, nScale);
        lcl_Scale(nWishDiff, nScale);
    }
    rCol.SetWishWidth( (USHORT) (nNewWishWidth) );

    if( nLeftDelta >= 2 || nLeftDelta <= -2)
        rArr[0]->SetWishWidth(rArr[0]->GetWishWidth() + (USHORT)nWishDiff);
    else
        rArr[rArr.Count()-1]->SetWishWidth(rArr[rArr.Count()-1]->GetWishWidth() + (USHORT)nWishDiff);
    //reset auto width
    rCol.SetOrtho(FALSE, 0, 0 );
}

/*--------------------------------------------------------------------
    Beschreibung:   Hier werden alle Aenderungen der Tableiste
                    wieder in das Modell geschossen
 --------------------------------------------------------------------*/
void SwView::ExecTabWin( SfxRequest& rReq )
{
    SwWrtShell &rSh         = GetWrtShell();
    const USHORT nFrmType   = rSh.IsObjSelected() ?
                                    FRMTYPE_DRAWOBJ :
                                        rSh.GetFrmType(0,TRUE);
    const BOOL  bFrmSelection = rSh.IsFrmSelected();
    const BOOL bBrowse = rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE);


    const USHORT nSlot      = rReq.GetSlot();
    const USHORT nDescId    = rSh.GetCurPageDesc();
    const SwPageDesc& rDesc = rSh.GetPageDesc( nDescId );

    const BOOL bVerticalWriting = rSh.IsInVerticalText();
    const SwFmtHeader& rHeaderFmt = rDesc.GetMaster().GetHeader();
    SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();

    const SwFmtFooter& rFooterFmt = rDesc.GetMaster().GetFooter();
    SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();

    const SwFmtFrmSize &rFrmSize = rDesc.GetMaster().GetFrmSize();

    const SwRect& rPageRect = rSh.GetAnyCurRect(RECT_PAGE);
    const long nPageWidth  = bBrowse ? rPageRect.Width() : rFrmSize.GetWidth();
    const long nPageHeight = bBrowse ? rPageRect.Height() : rFrmSize.GetHeight();

    BOOL bUnlockView = FALSE;
    rSh.StartAllAction();
    BOOL bSect = 0 != (nFrmType & FRMTYPE_COLSECT);

    switch  ( nSlot )
    {
    case SID_ATTR_LONG_LRSPACE:
    {
        SvxLongLRSpaceItem aLongLR( (const SvxLongLRSpaceItem&)rReq.GetArgs()->
                                                    Get( SID_ATTR_LONG_LRSPACE ) );
        SvxLRSpaceItem aLR(RES_LR_SPACE);
        if ( !bSect && (bFrmSelection || nFrmType & FRMTYPE_FLY_ANY) )
        {
            SwFrmFmt* pFmt = ((SwFrmFmt*)rSh.GetFlyFrmFmt());
            const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED);

            BOOL bRTL;
            BOOL bVerticalFrame = (bFrmSelection && rSh.IsFrmVertical(TRUE, bRTL))|| (!bFrmSelection && bVerticalWriting);
            long nDeltaX = bVerticalFrame ?
                rRect.Right() - rPageRect.Right() + aLongLR.GetRight() :
                rPageRect.Left() + aLongLR.GetLeft() - rRect.Left();

            SfxItemSet aSet( GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
                                        RES_VERT_ORIENT, RES_HORI_ORIENT,
                                        RES_COL, RES_COL, 0 );

            if(bVerticalFrame)
            {
                SwFmtVertOrient aVertOrient(pFmt->GetVertOrient());
                aVertOrient.SetVertOrient(text::VertOrientation::NONE);
                aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaX );
                aSet.Put( aVertOrient );
            }
            else
            {
                SwFmtHoriOrient aHoriOrient( pFmt->GetHoriOrient() );
                aHoriOrient.SetHoriOrient( text::HoriOrientation::NONE );
                aHoriOrient.SetPos( aHoriOrient.GetPos() + nDeltaX );
                aSet.Put( aHoriOrient );
            }

            SwFmtFrmSize aSize( pFmt->GetFrmSize() );
            long nOldWidth = (long) aSize.GetWidth();

            if(aSize.GetWidthPercent())
            {
                SwRect aRect;
                rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
                long nPrtWidth = aRect.Width();
                aSize.SetWidthPercent(BYTE((nPageWidth - aLongLR.GetLeft() - aLongLR.GetRight()) * 100 /nPrtWidth));
            }
            else
                aSize.SetWidth( nPageWidth -
                        (aLongLR.GetLeft() + aLongLR.GetRight()));

            if( nFrmType & FRMTYPE_COLUMN )
            {
                SwFmtCol aCol(pFmt->GetCol());

                ::ResizeFrameCols(aCol, nOldWidth, (long)aSize.GetWidth(), nDeltaX );
                aSet.Put(aCol);
            }

            aSet.Put( aSize );

            rSh.StartAction();
            rSh.Push();
            rSh.SetFlyFrmAttr( aSet );
            //die Rahmenselektion wieder aufheben
            if(!bFrmSelection && rSh.IsFrmSelected())
            {
                rSh.UnSelectFrm();
                rSh.LeaveSelFrmMode();
            }
            rSh.Pop();
            rSh.EndAction();
        }
        else if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
        {
            // Seitenraender rausrechnen
            long nOld = rDesc.GetMaster().GetLRSpace().GetLeft();
            aLongLR.SetLeft( nOld > aLongLR.GetLeft() ? 0 : aLongLR.GetLeft() - nOld );

            nOld = rDesc.GetMaster().GetLRSpace().GetRight();
            aLongLR.SetRight( nOld > (USHORT)aLongLR.GetRight() ? 0 : aLongLR.GetRight() - nOld );
            aLR.SetLeft((USHORT)aLongLR.GetLeft());
            aLR.SetRight((USHORT)aLongLR.GetRight());

            if ( nFrmType & FRMTYPE_HEADER && pHeaderFmt )
                pHeaderFmt->SetFmtAttr( aLR );
            else if( nFrmType & FRMTYPE_FOOTER && pFooterFmt )
                pFooterFmt->SetFmtAttr( aLR );
        }
        else if( nFrmType == FRMTYPE_DRAWOBJ)
        {
            SwRect aRect( rSh.GetObjRect() );
            aRect.Left( aLongLR.GetLeft() + rPageRect.Left() );
            aRect.Right( rPageRect.Right() - aLongLR.GetRight());
            rSh.SetObjRect( aRect );
        }
        else if(bSect || rSh.IsDirectlyInSection())
        {
            //change the section indents and the columns if available
            //at first determine the changes
            SwRect aSectRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, 0);
            const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, 0);
            aSectRect.Pos() += aTmpRect.Pos();
            long nLeftDiff = aLongLR.GetLeft() - (long)(aSectRect.Left() - rPageRect.Left() );
            long nRightDiff = aLongLR.GetRight() - (long)( rPageRect.Right() - aSectRect.Right());
            //change the LRSpaceItem of the section accordingly
            const SwSection* pCurrSect = rSh.GetCurrSection();
            const SwSectionFmt* pSectFmt = pCurrSect->GetFmt();
            SvxLRSpaceItem aLRTmp = pSectFmt->GetLRSpace();
            aLRTmp.SetLeft(aLRTmp.GetLeft() + nLeftDiff);
            aLRTmp.SetRight(aLRTmp.GetRight() + nRightDiff);
            SfxItemSet aSet(rSh.GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE, RES_COL, RES_COL, 0L);
            aSet.Put(aLRTmp);
            //change the first/last column
            if(bSect)
            {
                SwFmtCol aCols( pSectFmt->GetCol() );
                long nDiffWidth = nLeftDiff + nRightDiff;
                ::ResizeFrameCols(aCols, aSectRect.Width(), aSectRect.Width() - nDiffWidth, nLeftDiff );
                aSet.Put( aCols );
            }
            SwSectionData aData(*pCurrSect);
            rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet);
        }
        else
        {   // Seitenraender einstellen
            aLR.SetLeft((USHORT)aLongLR.GetLeft());
            aLR.SetRight((USHORT)aLongLR.GetRight());
            SwapPageMargin( rDesc, aLR );
            SwPageDesc aDesc( rDesc );
            aDesc.GetMaster().SetFmtAttr( aLR );
            rSh.ChgPageDesc( nDescId, aDesc );
        }
    }
    break;
    case SID_ATTR_LONG_ULSPACE:
    {
        SvxLongULSpaceItem aLongULSpace( (const SvxLongULSpaceItem&)rReq.GetArgs()->
                                                        Get( SID_ATTR_LONG_ULSPACE ));

        if( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
        {
            SwFrmFmt* pFmt = ((SwFrmFmt*)rSh.GetFlyFrmFmt());
            const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED);
            const long nDeltaY = rPageRect.Top() + aLongULSpace.GetUpper() - rRect.Top();
            const long nHeight = nPageHeight - (aLongULSpace.GetUpper() + aLongULSpace.GetLower());

            SfxItemSet aSet( GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
                                        RES_VERT_ORIENT, RES_HORI_ORIENT, 0 );
            //which of the orientation attributes is to be put depends on the frame's environment
            BOOL bRTL;
            if((bFrmSelection && rSh.IsFrmVertical(TRUE, bRTL))|| (!bFrmSelection && bVerticalWriting))
            {
                SwFmtHoriOrient aHoriOrient(pFmt->GetHoriOrient());
                aHoriOrient.SetHoriOrient(text::HoriOrientation::NONE);
                aHoriOrient.SetPos(aHoriOrient.GetPos() + nDeltaY );
                aSet.Put( aHoriOrient );
            }
            else
            {
                SwFmtVertOrient aVertOrient(pFmt->GetVertOrient());
                aVertOrient.SetVertOrient(text::VertOrientation::NONE);
                aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaY );
                aSet.Put( aVertOrient );
            }
            SwFmtFrmSize aSize(pFmt->GetFrmSize());
            if(aSize.GetHeightPercent())
            {
                SwRect aRect;
                rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
                long nPrtHeight = aRect.Height();
                aSize.SetHeightPercent(BYTE(nHeight * 100 /nPrtHeight));
            }
            else
                aSize.SetHeight(nHeight );

            aSet.Put( aSize );
            rSh.SetFlyFrmAttr( aSet );
        }
        else if( nFrmType == FRMTYPE_DRAWOBJ )
        {
            SwRect aRect( rSh.GetObjRect() );
            aRect.Top( aLongULSpace.GetUpper() + rPageRect.Top() );
            aRect.Bottom( rPageRect.Bottom() - aLongULSpace.GetLower() );
            rSh.SetObjRect( aRect ) ;
        }
        else if(bVerticalWriting && (bSect || rSh.IsDirectlyInSection()))
        {
            //change the section indents and the columns if available
            //at first determine the changes
            SwRect aSectRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, 0);
            const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, 0);
            aSectRect.Pos() += aTmpRect.Pos();
            const long nLeftDiff = aLongULSpace.GetUpper() - (long)(aSectRect.Top() - rPageRect.Top());
            const long nRightDiff = aLongULSpace.GetLower() - (long)(nPageHeight - aSectRect.Bottom() + rPageRect.Top());
            //change the LRSpaceItem of the section accordingly
            const SwSection* pCurrSect = rSh.GetCurrSection();
            const SwSectionFmt* pSectFmt = pCurrSect->GetFmt();
            SvxLRSpaceItem aLR = pSectFmt->GetLRSpace();
            aLR.SetLeft(aLR.GetLeft() + nLeftDiff);
            aLR.SetRight(aLR.GetRight() + nRightDiff);
            SfxItemSet aSet(rSh.GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE, RES_COL, RES_COL, 0L);
            aSet.Put(aLR);
            //change the first/last column
            if(bSect)
            {
                SwFmtCol aCols( pSectFmt->GetCol() );
                long nDiffWidth = nLeftDiff + nRightDiff;
                ::ResizeFrameCols(aCols, aSectRect.Height(), aSectRect.Height() - nDiffWidth, nLeftDiff );
                aSet.Put( aCols );
            }
            SwSectionData aData(*pCurrSect);
            rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet);
        }
        else
        {   SwPageDesc aDesc( rDesc );

            if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
            {

                const BOOL bHead = nFrmType & FRMTYPE_HEADER ? TRUE : FALSE;
                SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
                if ( bHead )
                    aUL.SetUpper( (USHORT)aLongULSpace.GetUpper() );
                else
                    aUL.SetLower( (USHORT)aLongULSpace.GetLower() );
                aDesc.GetMaster().SetFmtAttr( aUL );

                if( (bHead && pHeaderFmt) || (!bHead && pFooterFmt ))
                {
                    SwFmtFrmSize aSz( bHead ? pHeaderFmt->GetFrmSize() :
                                              pFooterFmt->GetFrmSize() );
                    aSz.SetHeightSizeType( ATT_FIX_SIZE );
                    aSz.SetHeight(nPageHeight - aLongULSpace.GetLower() -
                                                aLongULSpace.GetUpper() );
                    if ( bHead )
                        pHeaderFmt->SetFmtAttr( aSz );
                    else
                        pFooterFmt->SetFmtAttr( aSz );
                }
            }
            else
            {
                SvxULSpaceItem aUL(RES_UL_SPACE);
                aUL.SetUpper((USHORT)aLongULSpace.GetUpper());
                aUL.SetLower((USHORT)aLongULSpace.GetLower());
                aDesc.GetMaster().SetFmtAttr(aUL);
            }

            rSh.ChgPageDesc( nDescId, aDesc );
        }
    }
    break;
    case SID_ATTR_TABSTOP_VERTICAL:
    case SID_ATTR_TABSTOP:
    {
        USHORT nWhich = GetPool().GetWhich(nSlot);
        SvxTabStopItem aTabStops( (const SvxTabStopItem&)rReq.GetArgs()->
                                                    Get( nWhich ));
        aTabStops.SetWhich(RES_PARATR_TABSTOP);
         const SvxTabStopItem& rDefTabs =
                    (const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);

        // Default-Tab an Pos 0
        SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE );
        rSh.GetCurAttr( aSet );
        const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)aSet.Get(RES_LR_SPACE);

        if ( rLR.GetTxtFirstLineOfst() < 0 )
        {
            SvxTabStop aSwTabStop( 0, SVX_TAB_ADJUST_DEFAULT );
            aTabStops.Insert( aSwTabStop );
        }

        // auffuellen mit Default-Tabs
        USHORT nDef = ::GetTabDist( rDefTabs );
        ::MakeDefTabs( nDef, aTabStops );

        SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
        if( pColl && pColl->IsAutoUpdateFmt() )
        {
            SfxItemSet aTmp(GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP);
            aTmp.Put(aTabStops);
            rSh.AutoUpdatePara( pColl, aTmp );
        }
        else
            rSh.SetAttr( aTabStops );
        break;
    }
    case SID_ATTR_PARA_LRSPACE_VERTICAL:
    case SID_ATTR_PARA_LRSPACE:
    {
        SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)rReq.
                                        GetArgs()->Get(nSlot));
        if(nFrmType & FRMTYPE_FLY_ANY)
        {
            sal_Bool bFirstColumn = sal_True;
            sal_Bool bLastColumn = sal_True;
            if(nFrmType & FRMTYPE_COLUMN)
            {
                USHORT nCurFrameCol = rSh.GetCurColNum() - 1;
                bFirstColumn = !nCurFrameCol;
                const SwFrmFmt* pFmt =  rSh.GetFlyFrmFmt();
                const SwFmtCol* pCols = &pFmt->GetCol();
                const SwColumns& rCols = pCols->GetColumns();
                USHORT nColumnCount = rCols.Count();
                bLastColumn = nColumnCount == nCurFrameCol + 1;
            }
        }
        aParaMargin.SetRight( aParaMargin.GetRight() - nRightBorderDistance );
        aParaMargin.SetTxtLeft(aParaMargin.GetTxtLeft() - nLeftBorderDistance );

        aParaMargin.SetWhich( RES_LR_SPACE );
        SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();

        // #i23726#
        if (pNumRuleNodeFromDoc)
        {
            // --> FME 2005-02-22 #i42922# Mouse move of numbering label
            // has to consider the left indent of the paragraph
            SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE );
            rSh.GetCurAttr( aSet );
            const SvxLRSpaceItem& rLR =
                    static_cast<const SvxLRSpaceItem&>(aSet.Get(RES_LR_SPACE));
            // <--

            SwPosition aPos(*pNumRuleNodeFromDoc);
            // --> OD 2008-06-09 #i90078#
            rSh.SetIndent( static_cast< short >(aParaMargin.GetTxtLeft() - rLR.GetTxtLeft()), aPos);
            // <--
            // --> OD 2005-02-18 #i42921# - invalidate state of indent in order
            // to get a ruler update.
            aParaMargin.SetWhich( nSlot );
            GetViewFrame()->GetBindings().SetState( aParaMargin );
            // <--
        }
        else if( pColl && pColl->IsAutoUpdateFmt() )
        {
            SfxItemSet aSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE);
            aSet.Put(aParaMargin);
            rSh.AutoUpdatePara( pColl, aSet);
        }
        else
            rSh.SetAttr( aParaMargin );

        if ( aParaMargin.GetTxtFirstLineOfst() < 0 )
        {
            SfxItemSet aSet( GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP );

            rSh.GetCurAttr( aSet );
            const SvxTabStopItem&  rTabStops = (const SvxTabStopItem&)aSet.Get(RES_PARATR_TABSTOP);

            // Haben wir einen Tab an Stelle Null
            USHORT i;

            for ( i = 0; i < rTabStops.Count(); ++i )
                if ( rTabStops[i].GetTabPos() == 0 )
                    break;

            if ( i >= rTabStops.Count() )
            {
                // Kein DefTab
                SvxTabStopItem aTabStops( RES_PARATR_TABSTOP );
                aTabStops = rTabStops;

                ::lcl_EraseDefTabs(aTabStops);

                SvxTabStop aSwTabStop( 0, SVX_TAB_ADJUST_DEFAULT );
                aTabStops.Insert(aSwTabStop);

                const SvxTabStopItem& rDefTabs =
                    (const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);
                USHORT nDef = ::GetTabDist(rDefTabs);
                ::MakeDefTabs( nDef, aTabStops );

                if( pColl && pColl->IsAutoUpdateFmt())
                {
                    SfxItemSet aSetTmp(GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP);
                    aSetTmp.Put(aTabStops);
                    rSh.AutoUpdatePara( pColl, aSetTmp );
                }
                else
                    rSh.SetAttr( aTabStops );
            }
        }
    }
    break;
    case SID_RULER_BORDERS_VERTICAL:
    case SID_RULER_BORDERS:
    {
        SvxColumnItem aColItem((const SvxColumnItem&)rReq.
                                            GetArgs()->Get(nSlot));

        if( bSetTabColFromDoc || (!bSect && rSh.GetTableFmt()))
        {
            OSL_ENSURE(aColItem.Count(), "ColDesc is empty!!");

            const BOOL bSingleLine = ((const SfxBoolItem&)rReq.
                            GetArgs()->Get(SID_RULER_ACT_LINE_ONLY)).GetValue();

            SwTabCols aTabCols;
            if ( bSetTabColFromDoc )
                rSh.GetMouseTabCols( aTabCols, aTabColFromDocPos );
            else
                rSh.GetTabCols(aTabCols);

            // linker Tabellenrand
            long nBorder = (long)(aColItem.GetLeft() - aTabCols.GetLeftMin());
            aTabCols.SetLeft( nBorder );

            nBorder = (bVerticalWriting ? nPageHeight : nPageWidth) - aTabCols.GetLeftMin() - aColItem.GetRight();

#ifdef DEBUG
            long nTmp1 = nPageWidth;
            long nTmp2 = aTabCols.GetLeftMin() + nBorder;
            (void)nTmp1;
            (void)nTmp2;
#endif

            if ( aColItem.GetRight() > 0 )
                aTabCols.SetRight( nBorder );

            // Tabcols der Reihe nach
            // Die letzte Col wird durch den Rand definiert
            //columns in right-to-left tables need to be mirrored
            BOOL bIsTableRTL =
                IsTabColFromDoc() ?
                      rSh.IsMouseTableRightToLeft(aTabColFromDocPos)
                    : rSh.IsTableRightToLeft();
            if(bIsTableRTL)
            {
                USHORT nColCount = aColItem.Count() - 1;
                for ( USHORT i = 0; i < nColCount; ++i )
                {
                    const SvxColumnDescription& rCol = aColItem[nColCount - i];
                    aTabCols[i] = aTabCols.GetRight() - rCol.nStart;
                    aTabCols.SetHidden( i, !rCol.bVisible );
                }
            }
            else
            {
                for ( USHORT i = 0; i < aColItem.Count()-1; ++i )
                {
                    const SvxColumnDescription& rCol = aColItem[i];
                    aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
                    aTabCols.SetHidden( i, !rCol.bVisible );
                }
            }

            if ( bSetTabColFromDoc )
            {
                if( !rSh.IsViewLocked() )
                {
                    bUnlockView = TRUE;
                    rSh.LockView( TRUE );
                }
                rSh.SetMouseTabCols( aTabCols, bSingleLine,
                                               aTabColFromDocPos );
            }
            else
                rSh.SetTabCols(aTabCols, bSingleLine);

        }
        else
        {
            if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY || bSect)
            {
                SwSectionFmt *pSectFmt = 0;
                SfxItemSet aSet( GetPool(), RES_COL, RES_COL );
                if(bSect)
                {
                    const SwSection *pSect = rSh.GetAnySection();
                    OSL_ENSURE( pSect, "Which section?");
                    pSectFmt = pSect->GetFmt();
                }
                else
                {
                    rSh.GetFlyFrmAttr( aSet );
                }
                SwFmtCol aCols(
                    bSect ?
                        pSectFmt->GetCol() :
                            (const SwFmtCol&)aSet.Get( RES_COL, FALSE ));
                SwRect aCurRect = rSh.GetAnyCurRect(bSect ? RECT_SECTION_PRT : RECT_FLY_PRT_EMBEDDED);
                const long lWidth = bVerticalWriting ? aCurRect.Height() : aCurRect.Width();
                ::lcl_ConvertToCols( aColItem, USHORT(lWidth), aCols );
                aSet.Put( aCols );
                if(bSect)
                    rSh.SetSectionAttr( aSet, pSectFmt );
                else
                {
                    rSh.StartAction();
                    rSh.Push();
                    rSh.SetFlyFrmAttr( aSet );
                    //die Rahmenselektion wieder aufheben
                    if(!bFrmSelection && rSh.IsFrmSelected())
                    {
                        rSh.UnSelectFrm();
                        rSh.LeaveSelFrmMode();
                    }
                    rSh.Pop();
                    rSh.EndAction();
                }
            }
            else
            {
                SwFmtCol aCols( rDesc.GetMaster().GetCol() );
                const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT);
                ::lcl_ConvertToCols( aColItem,
                    USHORT(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width()),
                                aCols );
                SwPageDesc aDesc( rDesc );
                aDesc.GetMaster().SetFmtAttr( aCols );
                rSh.ChgPageDesc( rSh.GetCurPageDesc(), aDesc );
            }
        }
    }
    break;

    case SID_RULER_ROWS :
    case SID_RULER_ROWS_VERTICAL:
    {
        SvxColumnItem aColItem((const SvxColumnItem&)rReq.
                                            GetArgs()->Get(nSlot));

        if( bSetTabColFromDoc || (!bSect && rSh.GetTableFmt()) )
        {
            OSL_ENSURE(aColItem.Count(), "ColDesc is empty!!");

            SwTabCols aTabCols;
            if ( bSetTabRowFromDoc )
                rSh.GetMouseTabRows( aTabCols, aTabColFromDocPos );
            else
                rSh.GetTabRows(aTabCols);

            if ( bVerticalWriting )
            {
                aTabCols.SetRight(nPageWidth - aColItem.GetRight() - aColItem.GetLeft());
                aTabCols.SetLeftMin(aColItem.GetLeft());
            }
            else
            {
                long nBorder = nPageHeight - aTabCols.GetLeftMin() - aColItem.GetRight();
                aTabCols.SetRight( nBorder );
            }

            if(bVerticalWriting)
            {
                for ( USHORT i = aColItem.Count() - 1; i; --i )
                {
                    const SvxColumnDescription& rCol = aColItem[i - 1];
                    long nColumnPos = aTabCols.GetRight() - rCol.nEnd ;
                    aTabCols[i - 1] = nColumnPos;
                    aTabCols.SetHidden( i - 1, !rCol.bVisible );
                }
            }
            else
            {
                for ( USHORT i = 0; i < aColItem.Count()-1; ++i )
                {
                    const SvxColumnDescription& rCol = aColItem[i];
                    aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
                    aTabCols.SetHidden( i, !rCol.bVisible );
                }
            }
            BOOL bSingleLine = FALSE;
            const SfxPoolItem* pSingleLine;
            if( SFX_ITEM_SET == rReq.GetArgs()->GetItemState(SID_RULER_ACT_LINE_ONLY, FALSE, &pSingleLine))
                bSingleLine = ((const SfxBoolItem*)pSingleLine)->GetValue();
            if ( bSetTabRowFromDoc )
            {
                if( !rSh.IsViewLocked() )
                {
                    bUnlockView = TRUE;
                    rSh.LockView( TRUE );
                }
                rSh.SetMouseTabRows( aTabCols, bSingleLine, aTabColFromDocPos );
            }
            else
                rSh.SetTabRows(aTabCols, bSingleLine);
        }
    }
    break;

    default:
        OSL_ENSURE( !this, "wrong SlotId");
    }
    rSh.EndAllAction();

    if( bUnlockView )
        rSh.LockView( FALSE );

    bSetTabColFromDoc = bSetTabRowFromDoc = bTabColFromDoc = bTabRowFromDoc = FALSE;
    SetNumRuleNodeFromDoc(NULL);
}

/*--------------------------------------------------------------------
    Beschreibung:   Hier wird der Status der Tableiste ermittelt
                    sprich alle relevanten Attribute an der CursorPos
                    werden der Tableiste uebermittelt
 --------------------------------------------------------------------*/
void SwView::StateTabWin(SfxItemSet& rSet)
{
    SwWrtShell &rSh         = GetWrtShell();

    const Point* pPt = IsTabColFromDoc() || IsTabRowFromDoc() ? &aTabColFromDocPos : 0;
    const USHORT nFrmType   = rSh.IsObjSelected()
                ? FRMTYPE_DRAWOBJ
                : rSh.GetFrmType( pPt, TRUE );

    const BOOL  bFrmSelection = rSh.IsFrmSelected();

    const BOOL bBrowse = rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE);
    // PageOffset/Begrenzer
    const SwRect& rPageRect = rSh.GetAnyCurRect( RECT_PAGE, pPt );
    const SwRect& rPagePrtRect = rSh.GetAnyCurRect( RECT_PAGE_PRT, pPt );
    const long nPageWidth  = rPageRect.Width();
    const long nPageHeight = rPageRect.Height();

    const SwPageDesc& rDesc = rSh.GetPageDesc(
                IsTabColFromDoc() || bTabRowFromDoc ?
                    rSh.GetMousePageDesc(aTabColFromDocPos) : rSh.GetCurPageDesc() );

    const SvxFrameDirectionItem& rFrameDir = rDesc.GetMaster().GetFrmDir();
    const BOOL bVerticalWriting = rSh.IsInVerticalText();

    //enable tab stop display on the rulers depending on the writing direction
    WinBits nRulerStyle = pHRuler->GetStyle() & ~WB_EXTRAFIELD;
    pHRuler->SetStyle(bVerticalWriting||bBrowse ? nRulerStyle : nRulerStyle|WB_EXTRAFIELD);
    nRulerStyle = pVRuler->GetStyle() & ~WB_EXTRAFIELD;
    pVRuler->SetStyle(bVerticalWriting ? nRulerStyle|WB_EXTRAFIELD : nRulerStyle);

    //#i24363# tab stops relative to indent
    bool bRelative = rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT);
    pHRuler->SetTabsRelativeToIndent( bRelative );
    pVRuler->SetTabsRelativeToIndent( bRelative );

    SvxLRSpaceItem aPageLRSpace( rDesc.GetMaster().GetLRSpace() );
    SwapPageMargin( rDesc, aPageLRSpace );

    SfxItemSet aCoreSet( GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP,
                                    RES_LR_SPACE,        RES_UL_SPACE, 0 );
    // --> OD 2008-01-17 #newlistlevelattrs#
    // get also the list level indent values merged as LR-SPACE item, if needed.
    rSh.GetCurAttr( aCoreSet, true );
    // <--
    SelectionType nSelType = rSh.GetSelectionType();

    SfxWhichIter aIter( rSet );
    USHORT nWhich = aIter.FirstWhich();
    sal_Bool bPutContentProtection = sal_False;

    while ( nWhich )
    {
        switch ( nWhich )
        {
//        case RES_LR_SPACE:
//        case SID_ATTR_LRSPACE:
        case SID_ATTR_LONG_LRSPACE:
        {
            SvxLongLRSpaceItem aLongLR( (long)aPageLRSpace.GetLeft(),
                                        (long)aPageLRSpace.GetRight(),
                                        SID_ATTR_LONG_LRSPACE);
            if(bBrowse)
            {
                aLongLR.SetLeft(rPagePrtRect.Left());
                aLongLR.SetRight(nPageWidth - rPagePrtRect.Right());
            }
            if ( ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER ) &&
                 !(nFrmType & FRMTYPE_COLSECT) )
            {
                SwFrmFmt *pFmt = (SwFrmFmt*) (nFrmType & FRMTYPE_HEADER ?
                                rDesc.GetMaster().GetHeader().GetHeaderFmt() :
                                rDesc.GetMaster().GetFooter().GetFooterFmt());
                if( pFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
                {
                    SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
                    aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
                    const SvxLRSpaceItem& aLR = pFmt->GetLRSpace();
                    aLongLR.SetLeft ( (long)aLR.GetLeft() + (long)aRect.Left() );
                    aLongLR.SetRight( (nPageWidth -
                                        (long)aRect.Right() + (long)aLR.GetRight()));
                }
            }
            else
            {
                SwRect aRect;
                if( !bFrmSelection && ((nFrmType & FRMTYPE_COLSECT) || rSh.IsDirectlyInSection()) )
                {
                    aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt);
                    const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt);
                    aRect.Pos() += aTmpRect.Pos();
                }

                else if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
                    aRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
                else if( nFrmType & FRMTYPE_DRAWOBJ)
                    aRect = rSh.GetObjRect();

                if( aRect.Width() )
                {
                    // PAGES01
                    // make relative to page position:
                    aLongLR.SetLeft ((long)( aRect.Left() - rPageRect.Left() ));
                    aLongLR.SetRight((long)( rPageRect.Right() - aRect.Right()));
                }
            }
            if( nWhich == SID_ATTR_LONG_LRSPACE )
                rSet.Put( aLongLR );
            else
            {
                SvxLRSpaceItem aLR( aLongLR.GetLeft(),
                                    aLongLR.GetRight(),
                                    0, 0,
                                    nWhich);
                rSet.Put(aLR);
            }
            break;
        }
        case SID_ATTR_LONG_ULSPACE:
//        case SID_ATTR_ULSPACE:
//        case RES_UL_SPACE:
        {
            // Rand Seite Oben Unten
            SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
            SvxLongULSpaceItem aLongUL( (long)aUL.GetUpper(),
                                        (long)aUL.GetLower(),
                                        SID_ATTR_LONG_ULSPACE);

            if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
            {
                // Dokumentkoordinaten Frame auf Seitenkoordinaten umbrechen
                const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
                aLongUL.SetUpper((USHORT)(rRect.Top() - rPageRect.Top() ));
                aLongUL.SetLower((USHORT)(rPageRect.Bottom() - rRect.Bottom() ));
            }
            else if ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER )
            {
                SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
                aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
                aLongUL.SetUpper( (USHORT)aRect.Top() );
                aLongUL.SetLower( (USHORT)(nPageHeight - aRect.Bottom()) );
            }
            else if( nFrmType & FRMTYPE_DRAWOBJ)
            {
                const SwRect &rRect = rSh.GetObjRect();
                aLongUL.SetUpper((rRect.Top() - rPageRect.Top()));
                aLongUL.SetLower((rPageRect.Bottom() - rRect.Bottom()));
            }
            else if(bBrowse)
            {
                aLongUL.SetUpper(rPagePrtRect.Top());
                aLongUL.SetLower(nPageHeight - rPagePrtRect.Bottom());
            }
            if( nWhich == SID_ATTR_LONG_ULSPACE )
                rSet.Put( aLongUL );
            else
            {
                SvxULSpaceItem aULTmp((USHORT)aLongUL.GetUpper(),
                                      (USHORT)aLongUL.GetLower(),
                                      nWhich);
                rSet.Put(aULTmp);
            }
            break;
        }
        case SID_ATTR_TABSTOP_VERTICAL :
        case RES_PARATR_TABSTOP:
        {
            if ( ISA( SwWebView ) ||
                 IsTabColFromDoc() ||
                 IsTabRowFromDoc() ||
                 ( nSelType & nsSelectionType::SEL_GRF ) ||
                 ( nSelType & nsSelectionType::SEL_FRM ) ||
                 ( nSelType & nsSelectionType::SEL_OLE ) ||
                 ( SFX_ITEM_AVAILABLE > aCoreSet.GetItemState(RES_LR_SPACE) ) ||
                 (!bVerticalWriting && (SID_ATTR_TABSTOP_VERTICAL == nWhich) ) ||
                 ( bVerticalWriting && (RES_PARATR_TABSTOP == nWhich))
               )
                rSet.DisableItem( nWhich );
            else
            {
                SvxTabStopItem aTabStops((const SvxTabStopItem&)
                                            aCoreSet.Get( RES_PARATR_TABSTOP ));

                const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
                                            rSh.GetDefault(RES_PARATR_TABSTOP);

                OSL_ENSURE(pHRuler, "why is there no ruler?");
                long nDefTabDist = ::GetTabDist(rDefTabs);
                pHRuler->SetDefTabDist( nDefTabDist );
                pVRuler->SetDefTabDist( nDefTabDist );
                ::lcl_EraseDefTabs(aTabStops);
                rSet.Put(aTabStops, nWhich);
            }
            break;
        }
        case SID_ATTR_PARA_LRSPACE_VERTICAL:
        case SID_ATTR_PARA_LRSPACE:
        {
            if ( nSelType & nsSelectionType::SEL_GRF ||
                 nSelType & nsSelectionType::SEL_FRM ||
                 nSelType & nsSelectionType::SEL_OLE ||
                 nFrmType == FRMTYPE_DRAWOBJ ||
                 (!bVerticalWriting && (SID_ATTR_PARA_LRSPACE_VERTICAL == nWhich)) ||
                 ( bVerticalWriting && (SID_ATTR_PARA_LRSPACE == nWhich))
                )
            {
                rSet.DisableItem(nWhich);
            }
            else
            {
                SvxLRSpaceItem aLR( RES_LR_SPACE );
                if ( !IsTabColFromDoc() )
                {
                    aLR = (const SvxLRSpaceItem&)aCoreSet.Get(RES_LR_SPACE);

                    // #i23726#
                    if (pNumRuleNodeFromDoc)
                    {
                        short nOffset = static_cast< short >(aLR.GetTxtLeft() +
                                        // --> FME 2005-02-22 #i42922# Mouse move of numbering label
                                        // has to consider the left indent of the paragraph
                                        pNumRuleNodeFromDoc->GetLeftMarginWithNum( TRUE ) );
                                       // <--

                        short nFLOffset;
                        pNumRuleNodeFromDoc->GetFirstLineOfsWithNum( nFLOffset );

                        aLR.SetLeft( nOffset + nFLOffset );
                    }
                }
                aLR.SetWhich(nWhich);
                rSet.Put(aLR);
            }
        break;
        }
        case SID_RULER_BORDER_DISTANCE:
        {
            nLeftBorderDistance = 0;
            nRightBorderDistance = 0;
            if ( nSelType & nsSelectionType::SEL_GRF ||
                    nSelType & nsSelectionType::SEL_FRM ||
                    nSelType & nsSelectionType::SEL_OLE ||
                    nFrmType == FRMTYPE_DRAWOBJ )
                rSet.DisableItem(SID_RULER_BORDER_DISTANCE);
            else
            {
                SvxLRSpaceItem aDistLR(SID_RULER_BORDER_DISTANCE);
                if(nFrmType & FRMTYPE_FLY_ANY)
                {
                    if( IsTabColFromDoc() )
                    {
                        const SwRect& rFlyPrtRect = rSh.GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, pPt );
                        aDistLR.SetLeft(rFlyPrtRect.Left());
                        aDistLR.SetRight(rFlyPrtRect.Left());
                    }
                    else
                    {
                        SfxItemSet aCoreSet2( GetPool(),
                                                RES_BOX, RES_BOX,
                                                SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
                        SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
                        aCoreSet.Put( aBoxInfo );
                        rSh.GetFlyFrmAttr( aCoreSet );
                        const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet.Get(RES_BOX);
                        aDistLR.SetLeft((USHORT)rBox.GetDistance(BOX_LINE_LEFT ));
                        aDistLR.SetRight((USHORT)rBox.GetDistance(BOX_LINE_RIGHT));

                        //add the paragraph border distance
                        SfxItemSet aCoreSet1( GetPool(),
                                                RES_BOX, RES_BOX,
                                                0 );
                        rSh.GetCurAttr( aCoreSet1 );
                        const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
                        aDistLR.SetLeft(aDistLR.GetLeft() + (USHORT)rParaBox.GetDistance(BOX_LINE_LEFT ));
                        aDistLR.SetRight(aDistLR.GetRight() + (USHORT)rParaBox.GetDistance(BOX_LINE_RIGHT));
                    }
                    rSet.Put(aDistLR);
                    nLeftBorderDistance  = static_cast< USHORT >(aDistLR.GetLeft());
                    nRightBorderDistance = static_cast< USHORT >(aDistLR.GetRight());
                }
                else if ( IsTabColFromDoc() ||
                    ( rSh.GetTableFmt() && !bFrmSelection &&
                    !(nFrmType & FRMTYPE_COLSECT ) ) )
                {
                    SfxItemSet aCoreSet2( GetPool(),
                                            RES_BOX, RES_BOX,
                                            SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
                    SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
                    aBoxInfo.SetTable(FALSE);
                    aBoxInfo.SetDist((BOOL) TRUE);
                    aCoreSet2.Put(aBoxInfo);
                    rSh.GetTabBorders( aCoreSet2 );
                    const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet2.Get(RES_BOX);
                    aDistLR.SetLeft((USHORT)rBox.GetDistance(BOX_LINE_LEFT ));
                    aDistLR.SetRight((USHORT)rBox.GetDistance(BOX_LINE_RIGHT));

                    //add the border distance of the paragraph
                    SfxItemSet aCoreSet1( GetPool(),
                                            RES_BOX, RES_BOX,
                                            0 );
                    rSh.GetCurAttr( aCoreSet1 );
                    const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
                    aDistLR.SetLeft(aDistLR.GetLeft() + (USHORT)rParaBox.GetDistance(BOX_LINE_LEFT ));
                    aDistLR.SetRight(aDistLR.GetRight() + (USHORT)rParaBox.GetDistance(BOX_LINE_RIGHT));
                    rSet.Put(aDistLR);
                    nLeftBorderDistance  = static_cast< USHORT >(aDistLR.GetLeft());
                    nRightBorderDistance = static_cast< USHORT >(aDistLR.GetRight());
                }
                else if ( !rSh.IsDirectlyInSection() )
                {
                    //get the page/header/footer border distance
                    const SwFrmFmt& rMaster = rDesc.GetMaster();
                    const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetAttrSet().Get(RES_BOX);
                    aDistLR.SetLeft((USHORT)rBox.GetDistance(BOX_LINE_LEFT ));
                    aDistLR.SetRight((USHORT)rBox.GetDistance(BOX_LINE_RIGHT));

                    const SvxBoxItem* pBox = 0;
                    if(nFrmType & FRMTYPE_HEADER)
                    {
                        rMaster.GetHeader();
                        const SwFmtHeader& rHeaderFmt = rMaster.GetHeader();
                        SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();
                        if( pHeaderFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
                            pBox = & (const SvxBoxItem&)pHeaderFmt->GetBox();
                    }
                    else if(nFrmType & FRMTYPE_FOOTER )
                    {
                        const SwFmtFooter& rFooterFmt = rMaster.GetFooter();
                        SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();
                        if( pFooterFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
                            pBox = & (const SvxBoxItem&)pFooterFmt->GetBox();
                    }
                    if(pBox)
                    {
                        aDistLR.SetLeft((USHORT)pBox->GetDistance(BOX_LINE_LEFT ));
                        aDistLR.SetRight((USHORT)pBox->GetDistance(BOX_LINE_RIGHT));
                    }

                    //add the border distance of the paragraph
                    SfxItemSet aCoreSetTmp( GetPool(),
                                            RES_BOX, RES_BOX,
                                            SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
                    rSh.GetCurAttr( aCoreSetTmp );
                    const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSetTmp.Get(RES_BOX);
                    aDistLR.SetLeft(aDistLR.GetLeft() + (USHORT)rParaBox.GetDistance(BOX_LINE_LEFT ));
                    aDistLR.SetRight(aDistLR.GetRight() + (USHORT)rParaBox.GetDistance(BOX_LINE_RIGHT));
                    rSet.Put(aDistLR);
                    nLeftBorderDistance  = static_cast< USHORT >(aDistLR.GetLeft());
                    nRightBorderDistance = static_cast< USHORT >(aDistLR.GetRight());
                }
            }
        }
        break;
        case SID_RULER_TEXT_RIGHT_TO_LEFT:
        {
            if ( nSelType & nsSelectionType::SEL_GRF ||
                    nSelType & nsSelectionType::SEL_FRM ||
                    nSelType & nsSelectionType::SEL_OLE ||
                    nFrmType == FRMTYPE_DRAWOBJ)
                rSet.DisableItem(nWhich);
            else
            {
                BOOL bFlag = rSh.IsInRightToLeftText();
                rSet.Put(SfxBoolItem(nWhich, bFlag));
            }
        }
        break;
        case SID_RULER_BORDERS_VERTICAL:
        case SID_RULER_BORDERS:
        {
            BOOL bFrameRTL;
            BOOL bFrameHasVerticalColumns =  rSh.IsFrmVertical(FALSE, bFrameRTL) && bFrmSelection;
            BOOL bHasTable = ( IsTabColFromDoc() ||
                    ( rSh.GetTableFmt() && !bFrmSelection &&
                    !(nFrmType & FRMTYPE_COLSECT ) ) );

            BOOL bTableVertical = bHasTable && rSh.IsTableVertical();

            if(((SID_RULER_BORDERS_VERTICAL == nWhich) &&
                ((bHasTable && !bTableVertical) ||
                 (!bVerticalWriting && !bFrmSelection && !bHasTable ) ||
                 ( bFrmSelection && !bFrameHasVerticalColumns))) ||
               ((SID_RULER_BORDERS == nWhich) &&
                ((bHasTable && bTableVertical) ||
                 (bVerticalWriting && !bFrmSelection&& !bHasTable) || bFrameHasVerticalColumns)))
                rSet.DisableItem(nWhich);
            else if ( bHasTable )
            {
                SwTabCols aTabCols;
                USHORT    nNum;
                if ( 0 != ( bSetTabColFromDoc = IsTabColFromDoc() ) )
                {
                    rSh.GetMouseTabCols( aTabCols, aTabColFromDocPos );
                    nNum = rSh.GetCurMouseTabColNum( aTabColFromDocPos );
                }
                else
                {
                    rSh.GetTabCols( aTabCols );
                    nNum = rSh.GetCurTabColNum();
                    if(rSh.IsTableRightToLeft())
                        nNum = aTabCols.Count() - nNum;
                }

                OSL_ENSURE(nNum <= aTabCols.Count(), "TabCol not found");
                const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
                const int nRgt = (USHORT)(bTableVertical ? nPageHeight : nPageWidth) -
                                  (aTabCols.GetLeftMin() +
                                  aTabCols.GetRight());

                const USHORT nL = static_cast< USHORT >(nLft > 0 ? nLft : 0);
                const USHORT nR = static_cast< USHORT >(nRgt > 0 ? nRgt : 0);

                SvxColumnItem aColItem(nNum, nL, nR);

                USHORT nStart = 0,
                       nEnd;

                //columns in right-to-left tables need to be mirrored
                BOOL bIsTableRTL =
                    IsTabColFromDoc() ?
                          rSh.IsMouseTableRightToLeft(aTabColFromDocPos)
                        : rSh.IsTableRightToLeft();
                if(bIsTableRTL)
                {
                    for ( USHORT i = aTabCols.Count(); i ; --i )
                    {
                        const SwTabColsEntry& rEntry = aTabCols.GetEntry( i - 1 );
                        nEnd  = (USHORT)aTabCols.GetRight();
                        nEnd  = nEnd - (USHORT)rEntry.nPos;
                        SvxColumnDescription aColDesc( nStart, nEnd,
                                    (USHORT(aTabCols.GetRight() - rEntry.nMax)),
                                    (USHORT(aTabCols.GetRight() - rEntry.nMin)),
                                                    !aTabCols.IsHidden(i - 1) );
                        aColItem.Append(aColDesc);
                        nStart = nEnd;
                    }
                    SvxColumnDescription aColDesc(nStart,
                                    aTabCols.GetRight() - aTabCols.GetLeft(), TRUE);
                    aColItem.Append(aColDesc);
                }
                else
                {
                    for ( USHORT i = 0; i < aTabCols.Count(); ++i )
                    {
                        const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
                        nEnd  = static_cast< USHORT >(rEntry.nPos - aTabCols.GetLeft());
                        SvxColumnDescription aColDesc( nStart, nEnd,
                                rEntry.nMin - aTabCols.GetLeft(), rEntry.nMax - aTabCols.GetLeft(),
                                                    !aTabCols.IsHidden(i) );
                        aColItem.Append(aColDesc);
                        nStart = nEnd;
                    }
                    SvxColumnDescription aColDesc(nStart, aTabCols.GetRight() - aTabCols.GetLeft(),
                                0, 0,
                                    TRUE);
                    aColItem.Append(aColDesc);
                }
                rSet.Put(aColItem, nWhich);
            }
            else if ( bFrmSelection || nFrmType & ( FRMTYPE_COLUMN | FRMTYPE_COLSECT ) )
            {
                // Aus Rahmen oder Seite ?
                USHORT nNum = 0;
                if(bFrmSelection)
                {
                    const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt();
                    if(pFmt)
                        nNum = pFmt->GetCol().GetNumCols();
                }
                else
                    nNum = rSh.GetCurColNum();

                if(
                    //eigentlich sollte FRMTYPE_COLSECT nicht enthalten sein, wenn der Rahmen selektiert ist!
                    !bFrmSelection &&
                     nFrmType & FRMTYPE_COLSECT )
                {
                    const SwSection *pSect = rSh.GetAnySection(FALSE, pPt);
                    OSL_ENSURE( pSect, "Which section?");
                    if( pSect )
                    {
                        SwSectionFmt *pFmt = pSect->GetFmt();
                        const SwFmtCol& rCol = pFmt->GetCol();
                        if(rSh.IsInRightToLeftText())
                            nNum = rCol.GetColumns().Count() - nNum;
                        else
                            --nNum;
                        SvxColumnItem aColItem(nNum);
                        SwRect aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt);
                        const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt);

                        ::lcl_FillSvxColumn(rCol, USHORT(bVerticalWriting ? aRect.Height() : aRect.Width()), aColItem, 0);

                        if(bVerticalWriting)
                        {
                            aRect.Pos() += Point(aTmpRect.Left(), aTmpRect.Top());
                            aRect.Pos().Y() -= rPageRect.Top();
                            aColItem.SetLeft ((USHORT)(aRect.Top()));
                            aColItem.SetRight((USHORT)(nPageHeight   - aRect.Bottom() ));
                        }
                        else
                        {
                            aRect.Pos() += aTmpRect.Pos();

                            // PAGES01
                            // make relative to page position:
                            aColItem.SetLeft ((USHORT)( aRect.Left() - rPageRect.Left() ));
                            aColItem.SetRight((USHORT)( rPageRect.Right() - aRect.Right()));
                        }
                        aColItem.SetOrtho(aColItem.CalcOrtho());

                        rSet.Put(aColItem, nWhich);
                    }
                }
                else if( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
                {
                    // Spalten in Rahmen
                    if ( nNum  )
                    {
                        const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt() ;

                        const SwFmtCol& rCol = pFmt->GetCol();
                        if(rSh.IsInRightToLeftText())
                            nNum = rCol.GetColumns().Count() - nNum;
                        else
                            nNum--;
                        SvxColumnItem aColItem(nNum);
                        const SwRect &rSizeRect = rSh.GetAnyCurRect(RECT_FLY_PRT_EMBEDDED, pPt);

                        BOOL bUseVertical = bFrameHasVerticalColumns || (!bFrmSelection && bVerticalWriting);
                        const long lWidth = bUseVertical ? rSizeRect.Height() : rSizeRect.Width();
                        const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
                        long nDist2 = ((bUseVertical ? rRect.Height() : rRect.Width()) - lWidth) /2;
                        ::lcl_FillSvxColumn(rCol, USHORT(lWidth), aColItem, nDist2);

                        SfxItemSet aFrameSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE);
                        rSh.GetFlyFrmAttr( aFrameSet );

                        if(bUseVertical)
                        {
                            aColItem.SetLeft ((USHORT)(rRect.Top()- rPageRect.Top()));
                            aColItem.SetRight((USHORT)(nPageHeight + rPageRect.Top() - rRect.Bottom() ));
                        }
                        else
                        {
                            aColItem.SetLeft ((USHORT)(rRect.Left() - rPageRect.Left()   ));
                            aColItem.SetRight((USHORT)(rPageRect.Right() - rRect.Right() ));
                        }

                        aColItem.SetOrtho(aColItem.CalcOrtho());

                        rSet.Put(aColItem, nWhich);
                    }
                    else
                        rSet.DisableItem(nWhich);
                }
                else
                {   // Spalten auf der Seite
                    const SwFrmFmt& rMaster = rDesc.GetMaster();
                    SwFmtCol aCol(rMaster.GetCol());
                    if(rFrameDir.GetValue() == FRMDIR_HORI_RIGHT_TOP)
                        nNum = aCol.GetColumns().Count() - nNum;
                    else
                        nNum--;

                    SvxColumnItem aColItem(nNum);
                    const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT, pPt);
                    const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetFmtAttr(RES_BOX);
                    long nDist = rBox.GetDistance();
                    ::lcl_FillSvxColumn(aCol,
                        USHORT(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width() ),
                        aColItem, nDist);

                    if(bBrowse)
                    {
                        aColItem.SetLeft((USHORT)rPagePrtRect.Left());
                        aColItem.SetRight(USHORT(nPageWidth - rPagePrtRect.Right()));
                    }
                    else
                    {
                        aColItem.SetLeft (aPageLRSpace.GetLeft());
                        aColItem.SetRight(aPageLRSpace.GetRight());
                    }
                    aColItem.SetOrtho(aColItem.CalcOrtho());

                    rSet.Put(aColItem, nWhich);
                }
            }
            else
                rSet.DisableItem(nWhich);
            break;
        }
        case SID_RULER_ROWS :
        case SID_RULER_ROWS_VERTICAL:
        {
            BOOL bFrameRTL;
            BOOL bFrameHasVerticalColumns =  rSh.IsFrmVertical(FALSE, bFrameRTL) && bFrmSelection;

            if(((SID_RULER_ROWS == nWhich) &&
                ((!bVerticalWriting && !bFrmSelection) || (bFrmSelection && !bFrameHasVerticalColumns))) ||
               ((SID_RULER_ROWS_VERTICAL == nWhich) &&
                ((bVerticalWriting && !bFrmSelection) || bFrameHasVerticalColumns)))
                rSet.DisableItem(nWhich);
            else if ( IsTabRowFromDoc() ||
                    ( rSh.GetTableFmt() && !bFrmSelection &&
                    !(nFrmType & FRMTYPE_COLSECT ) ) )
            {
                SwTabCols aTabCols;
                //no current value necessary
                USHORT    nNum = 0;
                if ( 0 != ( bSetTabRowFromDoc = IsTabRowFromDoc() ) )
                {
                    rSh.GetMouseTabRows( aTabCols, aTabColFromDocPos );
                }
                else
                {
                    rSh.GetTabRows( aTabCols );
                }

                const int nLft = aTabCols.GetLeftMin();
                const int nRgt = (USHORT)(bVerticalWriting ? nPageWidth : nPageHeight) -
                                  (aTabCols.GetLeftMin() +
                                  aTabCols.GetRight());

                const USHORT nL = static_cast< USHORT >(nLft > 0 ? nLft : 0);
                const USHORT nR = static_cast< USHORT >(nRgt > 0 ? nRgt : 0);

                SvxColumnItem aColItem(nNum, nL, nR);

                USHORT nStart = 0,
                       nEnd;

                for ( USHORT i = 0; i < aTabCols.Count(); ++i )
                {
                    const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
                    if(bVerticalWriting)
                    {
                        nEnd  = USHORT(aTabCols.GetRight() - rEntry.nPos);
                        SvxColumnDescription aColDesc( nStart, nEnd,
                            aTabCols.GetRight() - rEntry.nMax, aTabCols.GetRight() - rEntry.nMin,
                                                    !aTabCols.IsHidden(i) );
                        aColItem.Append(aColDesc);
                    }
                    else
                    {
                        nEnd  = USHORT(rEntry.nPos - aTabCols.GetLeft());
                        SvxColumnDescription aColDesc( nStart, nEnd,
                                USHORT(rEntry.nMin - aTabCols.GetLeft()), USHORT(rEntry.nMax - aTabCols.GetLeft()),
                                                    !aTabCols.IsHidden(i) );
                        aColItem.Append(aColDesc);
                    }
                    nStart = nEnd;
                }
                if(bVerticalWriting)
                    nEnd = static_cast< USHORT >(aTabCols.GetRight());
                else
                    nEnd = static_cast< USHORT >(aTabCols.GetLeft());
                // put a position protection when the last row cannot be moved
                // due to a page break inside of a row
                if(!aTabCols.IsLastRowAllowedToChange())
                    bPutContentProtection = sal_True;

                SvxColumnDescription aColDesc( nStart, nEnd,
                    aTabCols.GetRight(), aTabCols.GetRight(),
                                            FALSE );
                aColItem.Append(aColDesc);

                rSet.Put(aColItem, nWhich);
            }
            else
                rSet.DisableItem(nWhich);
        }
        break;
        case SID_RULER_PAGE_POS:
        {
            // PAGES01
            SvxPagePosSizeItem aPagePosSize(
                    Point( rPageRect.Left(), rPageRect.Top()) , nPageWidth, nPageHeight);

            rSet.Put(aPagePosSize);
            break;
        }
        case SID_RULER_LR_MIN_MAX:
        {
            Rectangle aRectangle;
            if( ( nFrmType & FRMTYPE_COLSECT ) && !IsTabColFromDoc() &&
                ( nFrmType & ( FRMTYPE_TABLE|FRMTYPE_COLUMN ) ) )
            {
                if( nFrmType & FRMTYPE_TABLE )
                {
                    const USHORT nNum = rSh.GetCurTabColNum();
                    SwTabCols aTabCols;
                    rSh.GetTabCols( aTabCols );

                    const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
                    const int nRgt = (USHORT)nPageWidth -(aTabCols.GetLeftMin() + aTabCols.GetRight());

                    const USHORT nL = static_cast< USHORT >(nLft > 0 ? nLft : 0);
                    const USHORT nR = static_cast< USHORT >(nRgt > 0 ? nRgt : 0);

                    aRectangle.Left() = nL;
                    if(nNum > 1)
                        aRectangle.Left() += aTabCols[nNum - 2];
                    if(nNum)
                        aRectangle.Left() += MINLAY;
                    if(aTabCols.Count() <= nNum + 1 )
                        aRectangle.Right() = nR;
                    else
                        aRectangle.Right() = nPageWidth - (nL + aTabCols[nNum + 1]);

                    if(nNum < aTabCols.Count())
                        aRectangle.Right() += MINLAY;
                }
                else
                {
                    const SwFrmFmt* pFmt =  rSh.GetFlyFrmFmt();
                    const SwFmtCol* pCols = pFmt ? &pFmt->GetCol():
                                                   &rDesc.GetMaster().GetCol();
                    const SwColumns& rCols = pCols->GetColumns();
                    USHORT nNum = rSh.GetCurOutColNum();
                    USHORT nCount = Min(USHORT(nNum + 1), rCols.Count());
                    const SwRect aRect( rSh.GetAnyCurRect( pFmt
                                                    ? RECT_FLY_PRT_EMBEDDED
                                                    : RECT_PAGE_PRT, pPt ));
                    const SwRect aAbsRect( rSh.GetAnyCurRect( pFmt
                                                    ? RECT_FLY_EMBEDDED
                                                    : RECT_PAGE, pPt ));

                    //die Breite im Rahmen bzw. innerhalbe der Seitenraender
                    const USHORT nTotalWidth = (USHORT)aRect.Width();
                    //die gesamte Rahmenbreite - die Differenz ist der doppelte Abstand zum Rand
                    const USHORT nOuterWidth = (USHORT)aAbsRect.Width();
                    int nWidth = 0,
                        nStart = 0,
                        nEnd = 0;
                    aRectangle.Left() = 0;
                    for ( USHORT i = 0; i < nCount; ++i )
                    {
                        SwColumn* pCol = rCols[i];
                        nStart = pCol->GetLeft() + nWidth;
                        if(i == nNum - 2)
                            aRectangle.Left() = nStart;
                        nWidth += pCols->CalcColWidth( i, nTotalWidth );
                        nEnd = nWidth - pCol->GetRight();
                    }
                    aRectangle.Right() = rPageRect.Right() - nEnd;
                    aRectangle.Left() -= rPageRect.Left();

                    if(nNum > 1)
                    {
                        aRectangle.Left() += MINLAY;
                        aRectangle.Left() += aRect.Left();
                    }
                    if(pFmt) //Bereich in Rahmen - hier darf man bis zum Rand
                        aRectangle.Left()  = aRectangle.Right() = 0;
                    else
                    {
                        // das Rechteck an die richtige absolute Position verschieben
                        aRectangle.Left() += aAbsRect.Left();
                        aRectangle.Right() -= aAbsRect.Left();
                        // Abstand zur Umrandung mit einbeziehen
                        aRectangle.Right() -= (nOuterWidth - nTotalWidth) / 2;
                    }

                    if(nNum < rCols.Count())
                    {
                        aRectangle.Right() += MINLAY;
                    }
                    else
                        // rechts ist jetzt nur noch der Seitenrand
                        aRectangle.Right() = 0;


                }
            }
            else if ( ((nFrmType & FRMTYPE_TABLE) || IsTabColFromDoc()) &&
                 !bFrmSelection )
            {
                BOOL bColumn;
                if ( IsTabColFromDoc() )
                    bColumn = rSh.GetCurMouseColNum( aTabColFromDocPos ) != 0;
                else
                    bColumn = (nFrmType & (FRMTYPE_COLUMN|FRMTYPE_FLY_ANY|
                                            FRMTYPE_COLSECTOUTTAB)) ?
                                            TRUE : FALSE;
                if ( !bColumn )
                {
                    if( nFrmType & FRMTYPE_FLY_ANY && IsTabColFromDoc() )
                    {
                        SwRect aRect( rSh.GetAnyCurRect(
                                            RECT_FLY_PRT_EMBEDDED, pPt ) );
                        aRect.Pos() += rSh.GetAnyCurRect( RECT_FLY_EMBEDDED,
                                                                pPt ).Pos();

                        aRectangle.Left()  = aRect.Left() - rPageRect.Left();
                        aRectangle.Right() = rPageRect.Right() - aRect.Right();
                    }
                    else if( bBrowse )
                    {
                        aRectangle.Left()  = rPagePrtRect.Left();
                        aRectangle.Right() = nPageWidth - rPagePrtRect.Right();
                    }
                    else
                    {
                        aRectangle.Left()  = aPageLRSpace.GetLeft();
                        aRectangle.Right() = aPageLRSpace.GetRight();
                    }
                }
                else
                {   //hier nur fuer Tabelle in mehrspaltigen Seiten und Rahmen
                    BOOL bSectOutTbl = (nFrmType & FRMTYPE_TABLE) ? TRUE : FALSE;
                    BOOL bFrame = (nFrmType & FRMTYPE_FLY_ANY) ? TRUE : FALSE;
                    BOOL bColSct =  (nFrmType & ( bSectOutTbl
                                                    ? FRMTYPE_COLSECTOUTTAB
                                                    : FRMTYPE_COLSECT )
                                                ) ? TRUE : FALSE;
                    //Damit man auch mit der Mouse ziehen kann,
                    //ohne in der Tabelle zu stehen
                    CurRectType eRecType = RECT_PAGE_PRT;
                    USHORT nNum = IsTabColFromDoc() ?
                                rSh.GetCurMouseColNum( aTabColFromDocPos ):
                                rSh.GetCurOutColNum();
                    const SwFrmFmt* pFmt = NULL;
                    if( bColSct )
                    {
                        eRecType = bSectOutTbl ? RECT_OUTTABSECTION
                                               : RECT_SECTION;
                        const SwSection *pSect = rSh.GetAnySection( bSectOutTbl, pPt );
                        OSL_ENSURE( pSect, "Which section?");
                        pFmt = pSect->GetFmt();
                    }
                    else if( bFrame )
                    {
                        pFmt = rSh.GetFlyFrmFmt();
                        eRecType = RECT_FLY_PRT_EMBEDDED;
                    }

                    const SwFmtCol* pCols = pFmt ? &pFmt->GetCol():
                                                   &rDesc.GetMaster().GetCol();
                    const SwColumns& rCols = pCols->GetColumns();
                    const USHORT nBorder = pFmt ? pFmt->GetBox().GetDistance() :
                                                  rDesc.GetMaster().GetBox().GetDistance();

                    /* RECT_FLY_PRT_EMBEDDED returns the relative position to
                        RECT_FLY_EMBEDDED
                        the absolute position must be added here
                    */
                    SwRect aRect( rSh.GetAnyCurRect( eRecType, pPt ) );
                    if(RECT_FLY_PRT_EMBEDDED == eRecType)
                        aRect.Pos() += rSh.GetAnyCurRect( RECT_FLY_EMBEDDED,
                                                                pPt ).Pos();

                    const USHORT nTotalWidth = (USHORT)aRect.Width();
                    //nStart und nEnd initialisieren fuer nNum == 0
                    int nWidth = 0,
                        nStart = 0,
                        nEnd = nTotalWidth;

                    if( nNum > rCols.Count() )
                    {
                        OSL_ENSURE( !this, "wrong FmtCol is being edited!" );
                        nNum = rCols.Count();
                    }

                    for( USHORT i = 0; i < nNum; ++i )
                    {
                        SwColumn* pCol = rCols[i];
                        nStart = pCol->GetLeft() + nWidth;
                        nWidth += pCols->CalcColWidth( i, nTotalWidth );
                        nEnd = nWidth - pCol->GetRight();
                    }
                    if( bFrame | bColSct )
                    {
                        aRectangle.Left()  = aRect.Left() - rPageRect.Left() + nStart;
                        aRectangle.Right() = nPageWidth - aRectangle.Left() - nEnd + nStart;
                    }
                    else if(!bBrowse)
                    {
                        aRectangle.Left()  = aPageLRSpace.GetLeft() + nStart;
                        aRectangle.Right() = nPageWidth - nEnd - aPageLRSpace.GetLeft();
                    }
                    else
                    {
                        long nLeft = rPagePrtRect.Left();
                        aRectangle.Left()  = nStart + nLeft;
                        aRectangle.Right() = nPageWidth - nEnd - nLeft;
                    }
                    if(!bFrame)
                    {
                        aRectangle.Left() += nBorder;
                        aRectangle.Right() -= nBorder;
                    }
                }
            }
            else if ( nFrmType & ( FRMTYPE_HEADER  | FRMTYPE_FOOTER ))
            {
                aRectangle.Left()  = aPageLRSpace.GetLeft();
                aRectangle.Right() = aPageLRSpace.GetRight();
            }
            else
                aRectangle.Left()  = aRectangle.Right() = 0;

            SfxRectangleItem aLR( SID_RULER_LR_MIN_MAX , aRectangle);
            rSet.Put(aLR);
        }
        break;
        case SID_RULER_PROTECT:
        {
            if(bFrmSelection)
            {
                BYTE nProtect = pWrtShell->IsSelObjProtected( FLYPROTECT_SIZE|FLYPROTECT_POS|FLYPROTECT_CONTENT );

                SvxProtectItem aProt(SID_RULER_PROTECT);
                aProt.SetCntntProtect((nProtect & FLYPROTECT_CONTENT)   != 0);
                aProt.SetSizeProtect ((nProtect & FLYPROTECT_SIZE)      != 0);
                aProt.SetPosProtect  ((nProtect & FLYPROTECT_POS)       != 0);
                rSet.Put(aProt);
            }
            else
            {
                SvxProtectItem aProtect(SID_RULER_PROTECT);
                if(bBrowse && !(nFrmType & (FRMTYPE_DRAWOBJ|FRMTYPE_COLUMN)) && !rSh.GetTableFmt())
                {
                    aProtect.SetSizeProtect(TRUE);
                    aProtect.SetPosProtect(TRUE);
                }
                rSet.Put(aProtect);
            }
        }
        break;
        }
        nWhich = aIter.NextWhich();
    }
    if(bPutContentProtection)
    {
        SvxProtectItem aProtect(SID_RULER_PROTECT);
        aProtect.SetCntntProtect(TRUE);
        rSet.Put(aProtect);
    }
}

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