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
|
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: annotsh.cxx,v $
* $Revision: 1.7.82.3 $
*
* 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 <tools/shl.hxx>
#include <com/sun/star/i18n/TransliterationModules.hpp>
#include <com/sun/star/i18n/TextConversionOption.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <sfx2/objface.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/request.hxx>
#include <svx/spltitem.hxx>
#include <svx/orphitem.hxx>
#include <svx/brkitem.hxx>
#include <svx/widwitem.hxx>
#include <svx/kernitem.hxx>
#include <svx/escpitem.hxx>
#include <svx/lspcitem.hxx>
#include <svx/adjitem.hxx>
#include <svx/crsditem.hxx>
#include <svx/shdditem.hxx>
#include <svx/hyznitem.hxx>
#include <svx/udlnitem.hxx>
#include <svx/fontitem.hxx>
#include <svx/fhgtitem.hxx>
#include <svx/clipfmtitem.hxx>
#include <svtools/stritem.hxx>
#include <svtools/slstitm.hxx>
#include <svx/colritem.hxx>
#include <svx/wghtitem.hxx>
#include <svx/cntritem.hxx>
#include <svx/postitem.hxx>
#include <svx/frmdiritem.hxx>
#include <svx/svdoutl.hxx>
#include <svtools/whiter.hxx>
#include <svtools/cjkoptions.hxx>
#include <svtools/ctloptions.hxx>
#include <svtools/useroptions.hxx>
#include <vcl/msgbox.hxx>
#include <svx/flditem.hxx>
#include <svx/editstat.hxx>
#include <svx/hlnkitem.hxx>
#include <svx/htmlmode.hxx>
#include <svx/langitem.hxx>
#include <svx/unolingu.hxx>
#include <svx/scripttypeitem.hxx>
#include <svx/writingmodeitem.hxx>
#include <swundo.hxx>
#include <doc.hxx>
#include <viewopt.hxx>
#include <wrtsh.hxx>
#include <uitool.hxx>
#include <popup.hrc>
#include <pardlg.hxx>
#include <swdtflvr.hxx>
#include <drwtxtsh.hxx>
#include <swmodule.hxx>
#include <initui.hxx>
#include <edtwin.hxx>
#include <swwait.hxx>
#include <docstat.hxx>
#include <cmdid.h>
#include <globals.hrc>
#include <shells.hrc>
#include <breakit.hxx>
#include "annotsh.hxx"
#include "view.hxx"
#include "PostItMgr.hxx"
#include "postit.hxx"
#include "swtypes.hxx"
#include <svx/svxdlg.hxx>
#include <svx/dialogs.hrc>
#include <svx/svxids.hrc>
#include <svtools/itempool.hxx>
#include <svx/outliner.hxx>
#include <svx/editeng.hxx>
#include <svx/editview.hxx>
#include <svtools/languageoptions.hxx>
#include <svx/langitem.hxx>
#include <svtools/langtab.hxx>
#include <svtools/slstitm.hxx>
#include <docsh.hxx>
#include <svtools/undo.hxx>
#include "swabstdlg.hxx" //CHINA001
#include "chrdlg.hrc" //CHINA001
#include "misc.hrc"
#include <app.hrc>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/bootstrap.hxx>
#include <langhelper.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::i18n;
#define SwAnnotationShell
#include <itemdef.hxx>
#include <swslots.hxx>
SFX_IMPL_INTERFACE(SwAnnotationShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT))
{
SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX));
SFX_POPUPMENU_REGISTRATION(SW_RES(MN_ANNOTATION_POPUPMENU));
}
TYPEINIT1(SwAnnotationShell,SfxShell)
SwAnnotationShell::SwAnnotationShell( SwView& r )
: rView(r)
{
SwWrtShell &rSh = rView.GetWrtShell();
SetPool(rSh.GetAttrPool().GetSecondaryPool());
}
SwAnnotationShell::~SwAnnotationShell()
{
}
SfxUndoManager* SwAnnotationShell::GetUndoManager()
{
SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() )
{
DBG_ASSERT(pPostItMgr,"PostItMgr::Layout(): We are looping forever");
return 0;
}
return &pPostItMgr->GetActivePostIt()->Engine()->GetUndoManager();
}
void SwAnnotationShell::Exec( SfxRequest &rReq )
{
//TODO: clean this up!!!!
SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() )
return;
OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View();
SfxItemSet aEditAttr(pOLV->GetAttribs());
SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges());
sal_uInt16 nSlot = rReq.GetSlot();
sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
const SfxItemSet *pNewAttrs = rReq.GetArgs();
sal_uInt16 nEEWhich = 0;
switch (nSlot)
{
case SID_ATTR_CHAR_FONT:
case SID_ATTR_CHAR_FONTHEIGHT:
case SID_ATTR_CHAR_WEIGHT:
case SID_ATTR_CHAR_POSTURE:
{
SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool();
if( !pSecondPool )
pSecondPool = aEditAttr.GetPool();
SvxScriptSetItem aSetItem( nSlot, *pSecondPool );
aSetItem.PutItemForScriptType( pOLV->GetSelectedScriptType(), pNewAttrs->Get( nWhich ));
aNewAttr.Put( aSetItem.GetItemSet() );
rReq.Done();
break;
}
case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
case SID_ATTR_CHAR_UNDERLINE:
{
FontUnderline eFU = ((const SvxUnderlineItem&)aEditAttr.Get(EE_CHAR_UNDERLINE)).GetUnderline();
aNewAttr.Put(SvxUnderlineItem(eFU == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_UNDERLINE));
break;
}
case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW; break;
case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT; break;
case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break;
case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break;
case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break;
case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH; break;
case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break;
case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break;
case SID_ATTR_PARA_ADJUST_LEFT:
aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_LEFT, EE_PARA_JUST));
break;
case SID_ATTR_PARA_ADJUST_CENTER:
aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST));
break;
case SID_ATTR_PARA_ADJUST_RIGHT:
aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_RIGHT, EE_PARA_JUST));
break;
case SID_ATTR_PARA_ADJUST_BLOCK:
aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_BLOCK, EE_PARA_JUST));
break;
case SID_ATTR_PARA_LINESPACE_10:
{
SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_LINE, EE_PARA_SBL);
aItem.SetPropLineSpace(100);
aNewAttr.Put(aItem);
}
break;
case SID_ATTR_PARA_LINESPACE_15:
{
SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL);
aItem.SetPropLineSpace(150);
aNewAttr.Put(aItem);
}
break;
case SID_ATTR_PARA_LINESPACE_20:
{
SvxLineSpacingItem aItem(SVX_LINESPACE_TWO_LINES, EE_PARA_SBL);
aItem.SetPropLineSpace(200);
aNewAttr.Put(aItem);
}
break;
case SID_SELECTALL:
{
Outliner * pOutliner = pOLV->GetOutliner();
if(pOutliner)
{
ULONG nParaCount = pOutliner->GetParagraphCount();
if (nParaCount > 0)
pOLV->SelectRange(0L, USHORT(nParaCount) );
}
break;
}
case FN_FORMAT_RESET:
{
pPostItMgr->GetActivePostIt()->ResetAttributes();
rReq.Done();
break;
}
case FN_SET_SUPER_SCRIPT:
{
SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
else
aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
}
break;
case FN_SET_SUB_SCRIPT:
{
SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
else
aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
}
break;
case SID_HYPERLINK_SETLINK:
{
const SfxPoolItem* pItem = 0;
if(pNewAttrs)
pNewAttrs->GetItemState(nSlot, sal_False, &pItem);
if(pItem)
{
const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem;
SvxURLField aFld(rHLinkItem.GetURL(), rHLinkItem.GetName(), SVXURLFORMAT_APPDEFAULT);
aFld.SetTargetFrame(rHLinkItem.GetTargetFrame());
const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
if (pFieldItem && pFieldItem->GetField()->ISA(SvxURLField))
{
// Feld selektieren, so dass es beim Insert geloescht wird
ESelection aSel = pOLV->GetSelection();
aSel.nEndPos++;
pOLV->SetSelection(aSel);
}
if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED)
pOLV->InsertField(SvxFieldItem(aFld, EE_FEATURE_FIELD));
}
break;
}
case FN_INSERT_SOFT_HYPHEN:
case FN_INSERT_HARDHYPHEN:
case FN_INSERT_HARD_SPACE:
case SID_INSERT_RLM :
case SID_INSERT_LRM :
case SID_INSERT_ZWNBSP :
case SID_INSERT_ZWSP:
{
sal_Unicode cIns = 0;
switch(rReq.GetSlot())
{
case FN_INSERT_SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break;
case FN_INSERT_HARDHYPHEN: cIns = CHAR_HARDHYPHEN; break;
case FN_INSERT_HARD_SPACE: cIns = CHAR_HARDBLANK; break;
case SID_INSERT_RLM : cIns = CHAR_RLM ; break;
case SID_INSERT_LRM : cIns = CHAR_LRM ; break;
case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break;
case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break;
}
pOLV->InsertText( String(cIns), TRUE );
rReq.Done();
break;
}
case FN_INSERT_SYMBOL:
{
if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED)
InsertSymbol(rReq);
break;
}
case FN_INSERT_STRING:
{
const SfxPoolItem* pItem = 0;
if(pNewAttrs)
pNewAttrs->GetItemState(nSlot, FALSE, &pItem );
if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED)
pOLV->InsertText(((const SfxStringItem *)pItem)->GetValue());
break;
}
case FN_FORMAT_FOOTNOTE_DLG:
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( rView.GetWindow(), rView.GetWrtShell(), DLG_DOC_FOOTNOTE );
DBG_ASSERT(pDlg, "Dialogdiet fail!");
pDlg->Execute();
delete pDlg;
break;
}
case FN_NUMBERING_OUTLINE_DLG:
{
SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
DBG_ASSERT(pFact, "Dialogdiet fail!");
SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
rView.GetWindow(), &aTmp, rView.GetWrtShell());
DBG_ASSERT(pDlg, "Dialogdiet fail!");
pDlg->Execute();
delete pDlg;
rReq.Done();
}
break;
case SID_OPEN_XML_FILTERSETTINGS:
{
try
{
uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY);
if( xDialog.is() )
{
xDialog->execute();
}
}
catch( uno::Exception& )
{
}
rReq.Ignore ();
}
break;
case FN_WORDCOUNT_DIALOG:
{
SwWrtShell &rSh = rView.GetWrtShell();
SwDocStat aCurr;
SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
{
SwWait aWait( *rView.GetDocShell(), TRUE );
rSh.StartAction();
rSh.CountWords( aCurr );
rSh.UpdateDocStat( aDocStat );
rSh.EndAction();
}
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
DBG_ASSERT(pFact, "Dialogdiet fail!");
AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( rView.GetWindow() );
pDialog->SetValues(aCurr, aDocStat );
pDialog->Execute();
delete pDialog;
}
break;
case SID_CHAR_DLG:
{
const SfxItemSet* pArgs = rReq.GetArgs();
if( !pArgs )
{
/* mod
SwView* pView = &GetView();
FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric));
*/
SfxItemSet aDlgAttr(GetPool(), EE_ITEMS_START, EE_ITEMS_END);
// util::Language gibts an der EditEngine nicht! Daher nicht im Set.
aDlgAttr.Put( aEditAttr );
aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) );
//CHINA001 SwCharDlg* pDlg = new SwCharDlg(pView->GetWindow(), *pView, aDlgAttr, 0, sal_True);
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();//CHINA001
DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");//CHINA001
SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg( rView.GetWindow(), rView, aDlgAttr, DLG_CHAR,0, sal_True );
DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
USHORT nRet = pDlg->Execute();
if(RET_OK == nRet )
{
rReq.Done( *( pDlg->GetOutputItemSet() ) );
aNewAttr.Put(*pDlg->GetOutputItemSet());
}
delete( pDlg );
if(RET_OK != nRet)
return ;
}
else
aNewAttr.Put(*pArgs);
break;
}
case SID_PARA_DLG:
{
const SfxItemSet* pArgs = rReq.GetArgs();
if (!pArgs)
{
/* mod todo ???
SwView* pView = &GetView();
FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric));
*/
SfxItemSet aDlgAttr(GetPool(),
EE_ITEMS_START, EE_ITEMS_END,
SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE,
SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT,
SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS,
SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS,
0);
aDlgAttr.Put(aEditAttr);
aDlgAttr.Put( SvxHyphenZoneItem( sal_False, RES_PARATR_HYPHENZONE) );
aDlgAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) );
aDlgAttr.Put( SvxFmtSplitItem( sal_True, RES_PARATR_SPLIT ) );
aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) );
aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) );
//CHINA001 SwParaDlg* pDlg = new SwParaDlg(GetView().GetWindow(), GetView(), aDlgAttr, DLG_STD, 0, sal_True);
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();//CHINA001
DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");//CHINA001
SfxAbstractTabDialog* pDlg = pFact->CreateSwParaDlg( rView.GetWindow(), rView, aDlgAttr,DLG_STD, DLG_PARA, 0, sal_True );
DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
USHORT nRet = pDlg->Execute();
if(RET_OK == nRet)
{
rReq.Done( *( pDlg->GetOutputItemSet() ) );
aNewAttr.Put(*pDlg->GetOutputItemSet());
}
delete( pDlg );
if(RET_OK != nRet)
return;
}
else
aNewAttr.Put(*pArgs);
break;
}
case SID_AUTOSPELL_CHECK:
{
rView.ExecuteSlot(rReq);
break;
}
case SID_ATTR_PARA_LEFT_TO_RIGHT:
case SID_ATTR_PARA_RIGHT_TO_LEFT:
{
sal_Bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT;
const SfxPoolItem* pPoolItem;
if( pNewAttrs && SFX_ITEM_SET == pNewAttrs->GetItemState( nSlot, TRUE, &pPoolItem ) )
{
if( !( (SfxBoolItem*)pPoolItem)->GetValue() )
bLeftToRight = !bLeftToRight;
}
SfxItemSet aAttr( *aNewAttr.GetPool(),
EE_PARA_JUST, EE_PARA_JUST,
EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
0 );
USHORT nAdjust = SVX_ADJUST_LEFT;
if( SFX_ITEM_ON == aEditAttr.GetItemState(EE_PARA_JUST, TRUE, &pPoolItem ) )
nAdjust = ( (SvxAdjustItem*)pPoolItem)->GetEnumValue();
if( bLeftToRight )
{
aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) );
if( nAdjust == SVX_ADJUST_RIGHT )
aAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
}
else
{
aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
if( nAdjust == SVX_ADJUST_LEFT )
aAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
}
pOLV->SetAttribs(aAttr);
break;
}
}
if(nEEWhich && pNewAttrs)
aNewAttr.Put(pNewAttrs->Get(nWhich), nEEWhich);
Rectangle aNullRect;
Rectangle aOutRect = pOLV->GetOutputArea();
if (aNullRect != aOutRect)
pOLV->SetAttribs(aNewAttr);
rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False);
if ( pOLV->GetOutliner()->IsModified() )
rView.GetWrtShell().SetModified();
}
void SwAnnotationShell::GetState(SfxItemSet& rSet)
{
//TODO: clean this up!!!
// FN_SET_SUPER_SCRIPT
//SID_ATTR_PARA_ADJUST
//SID_ATTR_PARA_ADJUST_BLOCK
SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() )
return;
OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View();
SfxItemSet aEditAttr(pOLV->GetAttribs());
SfxWhichIter aIter(rSet);
sal_uInt16 nWhich = aIter.FirstWhich();
while(nWhich)
{
sal_uInt16 nEEWhich = 0;
USHORT nSlotId = GetPool().GetSlotId( nWhich );
switch( nSlotId )
{
case SID_ATTR_CHAR_FONT:
case SID_ATTR_CHAR_FONTHEIGHT:
case SID_ATTR_CHAR_WEIGHT:
case SID_ATTR_CHAR_POSTURE:
{
if ( pOLV )
{
USHORT nScriptType = pOLV->GetSelectedScriptType();
SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool();
if( !pSecondPool )
pSecondPool = aEditAttr.GetPool();
SvxScriptSetItem aSetItem( nSlotId, *pSecondPool );
aSetItem.GetItemSet().Put( aEditAttr, FALSE );
const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
if( pI )
rSet.Put( *pI, nWhich );
else
rSet.InvalidateItem( nWhich );
}
else
rSet.InvalidateItem( nWhich );
}
break;
case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break;
case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW;break;
case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break;
case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break;
case FN_SET_SUPER_SCRIPT:
case FN_SET_SUB_SCRIPT:
{
USHORT nEsc = 0;
const SfxPoolItem *pEscItem = 0;
if (nWhich==FN_SET_SUPER_SCRIPT)
nEsc = SVX_ESCAPEMENT_SUPERSCRIPT;
else
nEsc = SVX_ESCAPEMENT_SUBSCRIPT;
if( !pEscItem )
pEscItem = &aEditAttr.Get( EE_CHAR_ESCAPEMENT );
if( nEsc == ((const SvxEscapementItem*)pEscItem)->GetEnumValue() )
rSet.Put( SfxBoolItem( nWhich, sal_True ));
else
rSet.InvalidateItem( nWhich );
break;
}
case SID_ATTR_PARA_ADJUST_LEFT:
case SID_ATTR_PARA_ADJUST_RIGHT:
case SID_ATTR_PARA_ADJUST_CENTER:
case SID_ATTR_PARA_ADJUST_BLOCK:
{
const SfxPoolItem *pAdjust = 0;
int eAdjust = 0;
if (nWhich==SID_ATTR_PARA_ADJUST_LEFT)
eAdjust = SVX_ADJUST_LEFT;
else
if (nWhich==SID_ATTR_PARA_ADJUST_RIGHT)
eAdjust = SVX_ADJUST_RIGHT;
else
if (nWhich==SID_ATTR_PARA_ADJUST_CENTER)
eAdjust = SVX_ADJUST_CENTER;
else
if (nWhich==SID_ATTR_PARA_ADJUST_BLOCK)
eAdjust = SVX_ADJUST_BLOCK;
if( !pAdjust )
aEditAttr.GetItemState( EE_PARA_JUST, sal_False, &pAdjust);
if( !pAdjust || IsInvalidItem( pAdjust ))
rSet.InvalidateItem( nSlotId ), nSlotId = 0;
else
{
if ( eAdjust == ((const SvxAdjustItem*)pAdjust)->GetAdjust())
rSet.Put( SfxBoolItem( nWhich, sal_True ));
else
rSet.InvalidateItem( nWhich );
}
break;
}
case SID_ATTR_PARA_LINESPACE_10:
case SID_ATTR_PARA_LINESPACE_15:
case SID_ATTR_PARA_LINESPACE_20:
{
const SfxPoolItem *pLSpace = 0;
int nLSpace = 0;
if (nWhich==SID_ATTR_PARA_LINESPACE_10)
nLSpace = 100;
else
if (nWhich==SID_ATTR_PARA_LINESPACE_15)
nLSpace = 150;
else
if (nWhich==SID_ATTR_PARA_LINESPACE_20)
nLSpace = 200;
if( !pLSpace )
aEditAttr.GetItemState( EE_PARA_SBL, sal_False, &pLSpace );
if( !pLSpace || IsInvalidItem( pLSpace ))
rSet.InvalidateItem( nSlotId ), nSlotId = 0;
else
{
if( nLSpace == ((const SvxLineSpacingItem*)pLSpace)->GetPropLineSpace() )
rSet.Put( SfxBoolItem( nWhich, sal_True ));
else
rSet.InvalidateItem( nWhich );
}
break;
}
case SID_AUTOSPELL_CHECK:
{
const SfxPoolItem* pState = rView.GetSlotState(nWhich);
if (pState)
rSet.Put(SfxBoolItem(nWhich, ((const SfxBoolItem*)pState)->GetValue()));
else
rSet.DisableItem( nWhich );
break;
}
case SID_ATTR_PARA_LEFT_TO_RIGHT:
case SID_ATTR_PARA_RIGHT_TO_LEFT:
{
if ( !SvtLanguageOptions().IsCTLFontEnabled() )
rSet.DisableItem( nWhich );
else
{
if(pOLV->GetOutliner() && pOLV->GetOutliner()->IsVertical())
rSet.DisableItem( nWhich );
else
{
BOOL bFlag = FALSE;
switch( ( ( (SvxFrameDirectionItem&) aEditAttr.Get( EE_PARA_WRITINGDIR ) ) ).GetValue() )
{
case FRMDIR_HORI_LEFT_TOP:
{
bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT;
rSet.Put( SfxBoolItem( nWhich, bFlag ));
break;
}
case FRMDIR_HORI_RIGHT_TOP:
{
bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT;
rSet.Put( SfxBoolItem( nWhich, bFlag ));
break;
}
}
}
}
}
break;
case SID_INSERT_RLM :
case SID_INSERT_LRM :
case SID_INSERT_ZWNBSP :
case SID_INSERT_ZWSP:
{
SvtCTLOptions aCTLOptions;
sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled();
rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled );
if(!bEnabled)
rSet.DisableItem(nWhich);
}
break;
default:
rSet.InvalidateItem( nWhich );
break;
}
if(nEEWhich)
rSet.Put(aEditAttr.Get(nEEWhich, sal_True), nWhich);
if (pPostItMgr->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED)
rSet.DisableItem( nWhich );
nWhich = aIter.NextWhich();
}
}
void SwAnnotationShell::ExecSearch(SfxRequest& rReq, BOOL bNoMessage)
{
rView.ExecSearch(rReq,bNoMessage);
}
void SwAnnotationShell::StateSearch(SfxItemSet &rSet)
{
rView.StateSearch(rSet);
}
void SwAnnotationShell::ExecClpbrd(SfxRequest &rReq)
{
SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() )
return;
OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View();
SfxItemSet aEditAttr(pOLV->GetAttribs());
SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges());
long aOldHeight = pPostItMgr->GetActivePostIt()->GetPostItTextHeight();
sal_uInt16 nSlot = rReq.GetSlot();
switch (nSlot)
{
case SID_CUT:
pOLV->Cut();
break;
case SID_COPY:
pOLV->Copy();
break;
case SID_PASTE:
if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED)
pOLV->Paste();
break;
case FN_PASTESPECIAL:
{
if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED)
{
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( &rView.GetEditWin() );
pDlg->Insert( SOT_FORMAT_STRING, aEmptyStr );
pDlg->Insert( SOT_FORMAT_RTF, aEmptyStr );
TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView.GetEditWin() ) );
ULONG nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
if (nFormat > 0)
{
if (nFormat == SOT_FORMAT_STRING)
pOLV->Paste();
else
pOLV->PasteSpecial();
}
delete pDlg;
}
break;
}
case SID_CLIPBOARD_FORMAT_ITEMS:
{
ULONG nFormat = 0;
const SfxPoolItem* pItem;
if ( rReq.GetArgs() && rReq.GetArgs()->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET &&
pItem->ISA(SfxUInt32Item) )
{
nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
}
if ( nFormat )
{
if (SOT_FORMAT_STRING == nFormat)
pOLV->Paste();
else
pOLV->PasteSpecial();
}
break;
}
}
pPostItMgr->GetActivePostIt()->ResizeIfNeccessary(aOldHeight,pPostItMgr->GetActivePostIt()->GetPostItTextHeight());
}
void SwAnnotationShell::StateClpbrd(SfxItemSet &rSet)
{
SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() )
return;
OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View();
TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView.GetEditWin() ) );
bool bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
bPastePossible = bPastePossible && (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED);
SfxWhichIter aIter(rSet);
sal_uInt16 nWhich = aIter.FirstWhich();
while(nWhich)
{
switch(nWhich)
{
case SID_CUT:
{
if ( (pPostItMgr->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED) || !pOLV->HasSelection() )
rSet.DisableItem( nWhich );
}
case SID_COPY:
{
if( !pOLV->HasSelection() )
rSet.DisableItem( nWhich );
break;
}
case SID_PASTE:
case FN_PASTESPECIAL:
{
if( !bPastePossible )
rSet.DisableItem( nWhich );
break;
}
case SID_CLIPBOARD_FORMAT_ITEMS:
{
if ( bPastePossible )
{
SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
aFormats.AddClipbrdFormat( SOT_FORMAT_RTF );
//if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
aFormats.AddClipbrdFormat( SOT_FORMAT_STRING );
rSet.Put( aFormats );
}
else
rSet.DisableItem( nWhich );
break;
}
}
nWhich = aIter.NextWhich();
}
}
void SwAnnotationShell::StateStatusLine(SfxItemSet &rSet)
{
SfxWhichIter aIter( rSet );
USHORT nWhich = aIter.FirstWhich();
while( nWhich )
{
switch( nWhich )
{
case FN_STAT_SELMODE:
{
rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0));
rSet.DisableItem( nWhich );
break;
}
case FN_STAT_TEMPLATE:
{
rSet.DisableItem( nWhich );
break;
}
}
nWhich = aIter.NextWhich();
}
}
void SwAnnotationShell::StateInsert(SfxItemSet &rSet)
{
SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() )
return;
OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View();
SfxWhichIter aIter(rSet);
sal_uInt16 nWhich = aIter.FirstWhich();
while(nWhich)
{
switch(nWhich)
{
case SID_HYPERLINK_GETLINK:
{
SvxHyperlinkItem aHLinkItem;
aHLinkItem.SetInsertMode(HLINK_FIELD);
const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
if (pFieldItem)
{
const SvxFieldData* pField = pFieldItem->GetField();
if (pField->ISA(SvxURLField))
{
aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation());
aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL());
aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame());
}
}
else
{
String sSel(pOLV->GetSelected());
sSel.Erase(255);
sSel.EraseTrailingChars();
aHLinkItem.SetName(sSel);
}
sal_uInt16 nHtmlMode = ::GetHtmlMode(rView.GetDocShell());
aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
rSet.Put(aHLinkItem);
}
break;
}
if (pPostItMgr->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED)
rSet.DisableItem( nWhich );
nWhich = aIter.NextWhich();
}
}
void SwAnnotationShell::NoteExec(SfxRequest &rReq)
{
SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
if ( !pPostItMgr )
return;
sal_uInt16 nSlot = rReq.GetSlot();
switch (nSlot)
{
case FN_REPLY:
case FN_POSTIT:
case FN_DELETE_COMMENT:
case FN_DELETE_NOTE:
if ( pPostItMgr->GetActivePostIt() )
pPostItMgr->GetActivePostIt()->ExecuteCommand(nSlot);
break;
case FN_DELETE_ALL_NOTES:
pPostItMgr->Delete();
break;
case FN_DELETE_NOTE_AUTHOR:
{
SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, nSlot, FALSE);
if ( pItem )
pPostItMgr->Delete( pItem->GetValue() );
break;
}
case FN_HIDE_NOTE:
/*
if ( Mgr()->GetActivePostIt() == this )
{
Mgr()->SetActivePostIt(0);
// put the cursor back into the document
SwitchToFieldPos();
}
Mgr()->Hide(mpFld);
*/
break;
case FN_HIDE_ALL_NOTES:
pPostItMgr->Hide();
break;
case FN_HIDE_NOTE_AUTHOR:
{
SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, nSlot, FALSE);
if ( pItem )
pPostItMgr->Hide( pItem->GetValue() );
}
}
}
void SwAnnotationShell::GetNoteState(SfxItemSet &rSet)
{
SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
SfxWhichIter aIter(rSet);
sal_uInt16 nWhich = aIter.FirstWhich();
while(nWhich)
{
USHORT nSlotId = GetPool().GetSlotId( nWhich );
switch( nSlotId )
{
case FN_POSTIT:
case FN_DELETE_NOTE:
case FN_DELETE_NOTE_AUTHOR:
case FN_DELETE_ALL_NOTES:
case FN_HIDE_NOTE:
case FN_HIDE_NOTE_AUTHOR:
case FN_HIDE_ALL_NOTES:
{
if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() || !pPostItMgr->GetActivePostIt()->ISA(SwPostIt))
rSet.DisableItem(nWhich);
break;
}
case FN_DELETE_COMMENT:
{
if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) //|| !pPostItMgr->GetActivePostIt()->ISA(SwRedComment))
rSet.DisableItem(nWhich);
break;
}
case FN_REPLY:
{
if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() || !pPostItMgr->GetActivePostIt()->ISA(SwPostIt))
rSet.DisableItem(nWhich);
else
{
SvtUserOptions aUserOpt;
String sAuthor;
if( !(sAuthor = aUserOpt.GetFullName()).Len())
if( !(sAuthor = aUserOpt.GetID()).Len() )
sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR ));
if (sAuthor == pPostItMgr->GetActivePostIt()->GetAuthor())
rSet.DisableItem(nWhich);
}
break;
}
default:
rSet.InvalidateItem( nWhich );
break;
}
if ( (pPostItMgr->GetActivePostIt()->IsProtected()) &&
//if ( (pPostItMgr->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED) &&
( (nSlotId==FN_DELETE_NOTE) || (nSlotId==FN_REPLY) ) )
rSet.DisableItem( nWhich );
nWhich = aIter.NextWhich();
}
}
void SwAnnotationShell::ExecLingu(SfxRequest &rReq)
{
SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() )
return;
OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View();
SfxItemSet aEditAttr(pOLV->GetAttribs());
sal_uInt16 nSlot = rReq.GetSlot();
SwWrtShell &rSh = rView.GetWrtShell();
bool bRestoreSelection = false;
ESelection aOldSelection;
switch (nSlot)
{
case SID_LANGUAGE_STATUS:
{
aOldSelection = pOLV->GetSelection();
if (!pOLV->GetEditView().HasSelection())
{
bRestoreSelection = true;
pOLV->GetEditView().SelectCurrentWord();
}
bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,rView,rSh);
break;
}
case FN_THESAURUS_DLG:
{
pOLV->StartThesaurus();
break;
}
case SID_HANGUL_HANJA_CONVERSION:
pOLV->StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL,
i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True, sal_False );
break;
case SID_CHINESE_CONVERSION:
{
//open ChineseTranslationDialog
Reference< XComponentContext > xContext(
::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
if(xContext.is())
{
Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
if(xMCF.is())
{
Reference< ui::dialogs::XExecutableDialog > xDialog(
xMCF->createInstanceWithContext(
rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog")
, xContext), UNO_QUERY);
Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
if( xInit.is() )
{
// initialize dialog
Reference< awt::XWindow > xDialogParentWindow(0);
Sequence<Any> aSeq(1);
Any* pArray = aSeq.getArray();
PropertyValue aParam;
aParam.Name = rtl::OUString::createFromAscii("ParentWindow");
aParam.Value <<= makeAny(xDialogParentWindow);
pArray[0] <<= makeAny(aParam);
xInit->initialize( aSeq );
//execute dialog
sal_Int16 nDialogRet = xDialog->execute();
if( RET_OK == nDialogRet )
{
//get some parameters from the dialog
sal_Bool bToSimplified = sal_True;
sal_Bool bUseVariants = sal_True;
sal_Bool bCommonTerms = sal_True;
Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY );
if( xProp.is() )
{
try
{
xProp->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified;
xProp->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants;
xProp->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms;
}
catch( Exception& )
{
}
}
//execute translation
sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
if( !bCommonTerms )
nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
Font aTargetFont = pOLV->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT,
nTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
pOLV->StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, sal_False, sal_False );
}
}
Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
if( xComponent.is() )
xComponent->dispose();
}
}
}
break;
}
if (bRestoreSelection)
{
// restore selection
pOLV->GetEditView().SetSelection( aOldSelection );
}
}
void SwAnnotationShell::GetLinguState(SfxItemSet &rSet)
{
SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() )
return;
OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View();
SfxItemSet aEditAttr(pOLV->GetAttribs());
SfxWhichIter aIter(rSet);
sal_uInt16 nWhich = aIter.FirstWhich();
while(nWhich)
{
switch (nWhich)
{
case SID_LANGUAGE_STATUS:
{
SwLangHelper::GetLanguageStatus(pOLV,rSet);
break;
}
// disable "Thesaurus" if the language is not supported
case FN_THESAURUS_DLG:
{
const SfxPoolItem &rItem = rView.GetWrtShell().GetDoc()->GetDefault(
GetWhichOfScript( RES_CHRATR_LANGUAGE,
GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage())) );
LanguageType nLang = ((const SvxLanguageItem &)
rItem).GetLanguage();
uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() );
if (!xThes.is() || nLang == LANGUAGE_NONE ||
!xThes->hasLocale( SvxCreateLocale( nLang ) ))
rSet.DisableItem( FN_THESAURUS_DLG );
}
break;
case SID_HANGUL_HANJA_CONVERSION:
case SID_CHINESE_CONVERSION:
{
if (!SvtCJKOptions().IsAnyEnabled())
{
rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
rSet.DisableItem(nWhich);
}
else
rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
}
break;
}
if (pPostItMgr->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED)
rSet.DisableItem( nWhich );
nWhich = aIter.NextWhich();
}
}
void SwAnnotationShell::ExecTransliteration(SfxRequest &rReq)
{
SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() )
return;
OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View();
using namespace ::com::sun::star::i18n;
{
sal_uInt32 nMode = 0;
switch( rReq.GetSlot() )
{
case SID_TRANSLITERATE_UPPER:
nMode = TransliterationModules_LOWERCASE_UPPERCASE;
break;
case SID_TRANSLITERATE_LOWER:
nMode = TransliterationModules_UPPERCASE_LOWERCASE;
break;
case SID_TRANSLITERATE_HALFWIDTH:
nMode = TransliterationModules_FULLWIDTH_HALFWIDTH;
break;
case SID_TRANSLITERATE_FULLWIDTH:
nMode = TransliterationModules_HALFWIDTH_FULLWIDTH;
break;
case SID_TRANSLITERATE_HIRAGANA:
nMode = TransliterationModules_KATAKANA_HIRAGANA;
break;
case SID_TRANSLITERATE_KATAGANA:
nMode = TransliterationModules_HIRAGANA_KATAKANA;
break;
default:
ASSERT(!this, "falscher Dispatcher");
}
if( nMode )
{
pOLV->TransliterateText( nMode );
}
}
}
void SwAnnotationShell::ExecUndo(SfxRequest &rReq)
{
const SfxItemSet* pArgs = rReq.GetArgs();
SfxUndoManager* pUndoManager = GetUndoManager();
SwWrtShell &rSh = rView.GetWrtShell();
long aOldHeight = rView.GetPostItMgr()->GetActivePostIt() ? rView.GetPostItMgr()->GetActivePostIt()->GetPostItTextHeight() : 0;
USHORT nId = rReq.GetSlot();
sal_uInt16 nCnt = 1;
const SfxPoolItem* pItem=0;
if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, FALSE, &pItem ) )
nCnt = ((SfxUInt16Item*)pItem)->GetValue();
switch( nId )
{
case SID_UNDO:
{
if ( pUndoManager )
{
sal_uInt16 nCount = pUndoManager->GetUndoActionCount();
sal_uInt16 nSteps = nCnt;
if ( nCount < nCnt )
{
nCnt = nCnt - nCount;
nSteps = nCount;
}
else
nCnt = 0;
while( nSteps-- )
pUndoManager->Undo(0);
}
if ( nCnt )
rSh.Do( SwWrtShell::UNDO, nCnt );
break;
}
case SID_REDO:
{
if ( pUndoManager )
{
sal_uInt16 nCount = pUndoManager->GetRedoActionCount();
sal_uInt16 nSteps = nCnt;
if ( nCount < nCnt )
{
nCnt = nCnt - nCount;
nSteps = nCount;
}
else
nCnt = 0;
while( nSteps-- )
pUndoManager->Redo(0);
}
if ( nCnt )
rSh.Do( SwWrtShell::REDO, nCnt );
break;
}
}
if (rView.GetPostItMgr()->GetActivePostIt())
rView.GetPostItMgr()->GetActivePostIt()->ResizeIfNeccessary(aOldHeight,rView.GetPostItMgr()->GetActivePostIt()->GetPostItTextHeight());
}
void SwAnnotationShell::StateUndo(SfxItemSet &rSet)
{
SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() )
return;
SfxWhichIter aIter(rSet);
USHORT nWhich = aIter.FirstWhich();
SfxUndoManager* pUndoManager = GetUndoManager();
SfxViewFrame *pSfxViewFrame = rView.GetViewFrame();
SwWrtShell &rSh = rView.GetWrtShell();
while( nWhich )
{
switch ( nWhich )
{
case SID_UNDO:
{
sal_uInt16 nCount = pUndoManager->GetUndoActionCount();
if ( nCount )
pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet );
else if( rSh.GetUndoIds() )
rSet.Put( SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::UNDO)) );
else
rSet.DisableItem(nWhich);
break;
}
case SID_REDO:
{
sal_uInt16 nCount = pUndoManager->GetRedoActionCount();
if ( nCount )
pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet );
else if(rSh.GetRedoIds())
rSet.Put(SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::REDO)) );
else
rSet.DisableItem(nWhich);
break;
}
case SID_GETUNDOSTRINGS:
case SID_GETREDOSTRINGS:
{
if( pUndoManager )
{
UniString (SfxUndoManager:: *fnGetComment)( USHORT ) const;
sal_uInt16 nCount;
if( SID_GETUNDOSTRINGS == nWhich )
{
nCount = pUndoManager->GetUndoActionCount();
fnGetComment = &SfxUndoManager::GetUndoActionComment;
}
else
{
nCount = pUndoManager->GetRedoActionCount();
fnGetComment = &SfxUndoManager::GetRedoActionComment;
}
String sList;
if( nCount )
{
for( sal_uInt16 n = 0; n < nCount; ++n )
( sList += (pUndoManager->*fnGetComment)( n ) )
+= '\n';
}
SfxStringListItem aItem( nWhich );
if( nWhich == SID_GETUNDOSTRINGS && rSh.GetUndoIds() )
{
rSh.GetDoStrings( SwWrtShell::UNDO, aItem );
}
else if( nWhich == SID_GETREDOSTRINGS && rSh.GetRedoIds() )
{
rSh.GetDoStrings( SwWrtShell::UNDO, aItem );
}
sList += aItem.GetString();
aItem.SetString( sList );
rSet.Put( aItem );
}
else
rSet.DisableItem( nWhich );
}
break;
default:
{
pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet );
break;
}
}
if (pPostItMgr->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED)
rSet.DisableItem( nWhich );
nWhich = aIter.NextWhich();
}
}
void SwAnnotationShell::StateDisableItems( SfxItemSet &rSet )
{
SfxWhichIter aIter(rSet);
USHORT nWhich = aIter.FirstWhich();
while (nWhich)
{
rSet.DisableItem( nWhich );
nWhich = aIter.NextWhich();
}
}
void SwAnnotationShell::InsertSymbol(SfxRequest& rReq)
{
SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() )
return;
OutlinerView* pOLV = pPostItMgr->GetActivePostIt()->View();
const SfxItemSet *pArgs = rReq.GetArgs();
const SfxPoolItem* pItem = 0;
if( pArgs )
pArgs->GetItemState(GetPool().GetWhich(FN_INSERT_SYMBOL), FALSE, &pItem);
String sSym;
String sFontName;
if ( pItem )
{
sSym = ((const SfxStringItem*)pItem)->GetValue();
const SfxPoolItem* pFtItem = NULL;
pArgs->GetItemState( GetPool().GetWhich(FN_PARAM_1), FALSE, &pFtItem);
const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
if ( pFontItem )
sFontName = pFontItem->GetValue();
}
SfxItemSet aSet(pOLV->GetAttribs());
USHORT nScript = pOLV->GetSelectedScriptType();
SvxFontItem aSetDlgFont( RES_CHRATR_FONT );
{
SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
aSetItem.GetItemSet().Put( aSet, FALSE );
const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
if( pI )
aSetDlgFont = *(SvxFontItem*)pI;
else
aSetDlgFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
SID_ATTR_CHAR_FONT,
GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage() ) ));
}
Font aFont(sFontName, Size(1,1));
if(!sSym.Len())
{
//CHINA001 SvxCharacterMap* pDlg = new SvxCharacterMap( NULL, FALSE );
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
AbstractSvxCharacterMap* pDlg = pFact->CreateSvxCharacterMap( NULL, RID_SVXDLG_CHARMAP, FALSE );
DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
Font aDlgFont( pDlg->GetCharFont() );
SwViewOption aOpt(*rView.GetWrtShell().GetViewOptions());
String sSymbolFont = aOpt.GetSymbolFont();
if(sSymbolFont.Len())
aDlgFont.SetName(sSymbolFont);
else
aDlgFont.SetName( aSetDlgFont.GetFamilyName() );
// Wenn Zeichen selektiert ist kann es angezeigt werden
pDlg->SetFont( aDlgFont );
USHORT nResult = pDlg->Execute();
if( nResult == RET_OK )
{
aFont = pDlg->GetCharFont();
sSym = pDlg->GetCharacters();
aOpt.SetSymbolFont(aFont.GetName());
SW_MOD()->ApplyUsrPref(aOpt, &rView);
}
delete( pDlg );
}
if( sSym.Len() )
{
// nicht flackern
pOLV->HideCursor();
Outliner * pOutliner = pOLV->GetOutliner();
pOutliner->SetUpdateMode(FALSE);
SfxItemSet aOldSet( pOLV->GetAttribs() );
SfxItemSet aFontSet( *aOldSet.GetPool(),
EE_CHAR_FONTINFO, EE_CHAR_FONTINFO,
EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CJK,
EE_CHAR_FONTINFO_CTL, EE_CHAR_FONTINFO_CTL,
0 );
aFontSet.Set( aOldSet );
// String einfuegen
pOLV->InsertText( sSym, TRUE );
// attributieren (Font setzen)
SfxItemSet aSetFont( *aFontSet.GetPool(), aFontSet.GetRanges() );
SvxFontItem aFontItem (aFont.GetFamily(), aFont.GetName(),
aFont.GetStyleName(), aFont.GetPitch(),
aFont.GetCharSet(),
EE_CHAR_FONTINFO );
USHORT nScriptBreak = pBreakIt->GetAllScriptsOfText( sSym );
if( SCRIPTTYPE_LATIN & nScriptBreak )
aSetFont.Put( aFontItem, EE_CHAR_FONTINFO );
if( SCRIPTTYPE_ASIAN & nScriptBreak )
aSetFont.Put( aFontItem, EE_CHAR_FONTINFO_CJK );
if( SCRIPTTYPE_COMPLEX & nScriptBreak )
aSetFont.Put( aFontItem, EE_CHAR_FONTINFO_CTL );
pOLV->SetAttribs(aSetFont);
// Selektion loeschen
ESelection aSel(pOLV->GetSelection());
aSel.nStartPara = aSel.nEndPara;
aSel.nStartPos = aSel.nEndPos;
pOLV->SetSelection(aSel);
// Alten Font restaurieren
pOLV->SetAttribs( aFontSet );
// ab jetzt wieder anzeigen
pOutliner->SetUpdateMode(TRUE);
pOLV->ShowCursor();
rReq.AppendItem( SfxStringItem( GetPool().GetWhich(FN_INSERT_SYMBOL), sSym ) );
if(aFont.GetName().Len())
rReq.AppendItem( SfxStringItem( FN_PARAM_1, aFont.GetName() ) );
rReq.Done();
}
}
|