summaryrefslogtreecommitdiff
path: root/binfilter/bf_sch/source/core/sch_globfunc.cxx
blob: 2b35e9c9b8f15415db28d5d893022e1fd6e10417 (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
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifdef _MSC_VER
#pragma optimize("e",off)
#pragma hdrstop
#endif

#define ITEMID_FONTLIST         0
#define ITEMID_POSTURE          0
#define ITEMID_WEIGHT           0
#define ITEMID_UNDERLINE        0
#define ITEMID_CROSSEDOUT       0
#define ITEMID_SHADOWED         0
#define ITEMID_AUTOKERN         0
#define ITEMID_WORDLINEMODE     0
#define ITEMID_CONTOUR          0
#define ITEMID_PROPSIZE         0
#define ITEMID_CHARSETCOLOR     0
#define ITEMID_KERNING          0
#define ITEMID_CASEMAP          0
#define ITEMID_ESCAPEMENT       0
#define ITEMID_LANGUAGE         0
#define ITEMID_NOLINEBREAK      0
#define ITEMID_NOHYPHENHERE     0
#define ITEMID_BLINK            0

#define ITEMID_FONT        EE_CHAR_FONTINFO
#define ITEMID_COLOR       EE_CHAR_COLOR
#define ITEMID_FONTHEIGHT  EE_CHAR_FONTHEIGHT
#define ITEMID_FONTWIDTH   EE_CHAR_FONTWIDTH

#include <bf_svtools/whiter.hxx>
#include <bf_svx/eeitem.hxx>

#include "schattr.hxx"
#ifndef _SVX_CHRTITEM_HXX //autogen
#define ITEMID_DOUBLE           0
#define ITEMID_CHARTTEXTORDER   SCHATTR_TEXT_ORDER
#define ITEMID_CHARTTEXTORIENT  SCHATTR_TEXT_ORIENT
#define ITEMID_CHARTDATADESCR   SCHATTR_DATADESCR_DESCR

#include <bf_svtools/eitem.hxx>
#endif

#include <bf_svx/fhgtitem.hxx>
#include <bf_svx/svxids.hrc>
#include <globfunc.hxx>

#include "math.h"
#include "float.h"

#include <bf_svx/fontitem.hxx>
#include <bf_svx/wghtitem.hxx>
#include <bf_svx/udlnitem.hxx>
#include <bf_svx/crsditem.hxx>
#include <bf_svx/postitem.hxx>
#include <bf_svx/cntritem.hxx>
#include <bf_svx/shdditem.hxx>
#include <bf_svx/akrnitem.hxx>
#include <bf_svx/wrlmitem.hxx>

#include <algorithm>
#include <functional>

/*************************************************************************
|*
|* Objekt attributieren
|*
\************************************************************************/
namespace binfilter {
/*N*/ SdrObject *SetObjectAttr (SdrObject  *pObj,
/*N*/                         UINT16     nID,
/*N*/                         BOOL       bProtect,
/*N*/                         BOOL       bResize,
/*N*/                         SfxItemSet *pAttr)
/*N*/ {
/*N*/   pObj->InsertUserData (new SchObjectId (nID));
/*N*/   pObj->SetMoveProtect (bProtect);
/*N*/   pObj->SetResizeProtect (bResize);
/*N*/   if (pAttr)
/*N*/       pObj->SetItemSet(*pAttr);
/*N*/
/*N*/   return pObj;
/*N*/ }

/*************************************************************************
|*
|* Objektgruppe erzeugen
|*
\************************************************************************/

/*N*/ SdrObjList *CreateGroup (SdrObjList &rObjList,
/*N*/                        UINT16     nID,
/*N*/                        ULONG      nIndex)
/*N*/ {
/*N*/   SdrObjGroup *pGroup = (SdrObjGroup *) SetObjectAttr (new SchObjGroup, nID, TRUE, TRUE, 0);
/*N*/
/*N*/   rObjList.NbcInsertObject((SdrObject *) pGroup, nIndex);
/*N*/   return pGroup->GetSubList();
/*N*/ }

/*************************************************************************
|*
|* Objektgruppe erzeugen
|*
\************************************************************************/

/*N*/ SchObjGroup *CreateSimpleGroup (UINT16 nID,
/*N*/                               BOOL   bProtect,
/*N*/                               BOOL   bResize)
/*N*/ {
/*N*/   return (SchObjGroup *) SetObjectAttr (new SchObjGroup, nID, bProtect, bResize, 0);
/*N*/ }


/*************************************************************************
|*
|* Berechne kub. Spline
|*
\************************************************************************/

/*N*/ void CubicSpline (XPolygon &pKnownPoints,
/*N*/                 int      n,
/*N*/                 int      splineSize,
/*N*/                 XPolygon &pSplines)
/*N*/ {
/*N*/   double *h      = new double [n + 1];
/*N*/   double *m      = new double [n + 1];
/*N*/   double *q      = new double [n + 1];
/*N*/   double *u      = new double [n + 1];
/*N*/
/*N*/   for (int k = 1;
/*N*/            k <= n;
/*N*/            k ++)
/*N*/       h [k] = pKnownPoints [k].X () - pKnownPoints [k - 1].X ();
/*N*/
/*N*/   double p;
/*N*/   double lambda = 0.0;
/*N*/   double d      = 0.0;
/*N*/   double mue;
/*N*/
/*N*/   q [0] = -lambda / 2.0;
/*N*/   u [0] = d / 2.0;
/*N*/
/*N*/   int j;
/*N*/   for (j = 1;
/*N*/            j <= n;
/*N*/            j ++)
/*N*/   {
/*N*/       mue        = (j < n)
/*N*/                        ? h[j] / (h [j] + h [j + 1])
/*N*/                        : 0.0;
/*N*/       p          = mue * q [j - 1] + 2.0;
/*N*/       lambda     = 1.0 - mue;
/*N*/       q [j]      = -lambda / p;
/*N*/       d          = (j < n)
/*N*/                        ? 6.0 * ((pKnownPoints [j + 1].Y () - pKnownPoints [j].Y ()) / h [j + 1] -
/*N*/                                 (pKnownPoints [j].Y () - pKnownPoints [j - 1].Y ()) / h [j]) / (h [j] + h [j + 1])
/*N*/                        : 0.0;
/*N*/       u [j]      = (d - mue * u [j - 1]) / p;
/*N*/   }
/*N*/
/*N*/   m [n] = u [n];
/*N*/
/*N*/   for (j = n - 1;
/*N*/        j >= 0;
/*N*/        j --)
/*N*/       m [j] = q [j] * m [j + 1] + u [j];
/*N*/
/*N*/   for (j = 0;
/*N*/        j < n;
/*N*/        j ++)
/*N*/   {
/*N*/       double xStep = (pKnownPoints [j + 1].X () - pKnownPoints [j].X ()) / splineSize;
/*N*/       double x     = pKnownPoints [j].X ();
/*N*/
/*N*/       double alpha = pKnownPoints [j].Y ();
/*N*/       double gamma = m [j] / 2;
/*N*/       double beta  = (pKnownPoints [j + 1].Y () - pKnownPoints [j].Y ()) / h [j + 1] -
/*N*/                      ((2 * m [j] + m [j + 1]) * h [j + 1]) / 6;
/*N*/       double delta = (m [j + 1] - m [j]) / (6 * h [j + 1]);
/*N*/
/*N*/       for (int i = 0;
/*N*/                i < splineSize;
/*N*/                i ++)
/*N*/       {
/*N*/           double xdiff = (x - pKnownPoints [j].X ());
/*N*/           int    index = j * splineSize + i;
/*N*/
/*N*/           pSplines [(short) index].Y () = long(alpha + xdiff * (beta + xdiff * (gamma + xdiff * delta)));
/*N*/           pSplines [(short) index].X () = long(x);
/*N*/           x                            += xStep;
/*N*/       }
/*N*/   }
/*N*/
/*N*/   pSplines [n * splineSize].Y () = pKnownPoints [n].Y ();
/*N*/   pSplines [n * splineSize].X () = pKnownPoints [n].X ();
/*N*/
/*N*/   delete[] h;
/*N*/   delete[] m;
/*N*/   delete[] q;
/*N*/   delete[] u;
/*N*/ }

/*************************************************************************
|*
|* Bestimme Knotenvektor fuer B-Spline
|*
\************************************************************************/

/*N*/ void TVector (int    n,
/*N*/             int    k,
/*N*/             double *t)
/*N*/ {
/*N*/   for (int i = 0;
/*N*/            i <= n + k;
/*N*/            i ++)
/*N*/   {
/*N*/       if (i < k) t [i] = 0;
/*N*/       else if (i <= n) t [i] = i - k + 1;
/*N*/            else t [i] = n - k + 2;
/*N*/   }
/*N*/ }

/*************************************************************************
|*
|* Berechne linken Knotenvektor
|*
\************************************************************************/

/*N*/ double TLeft (double x,
/*N*/             int    i,
/*N*/             int    k,
/*N*/             double *t)
/*N*/ {
/*N*/   double deltaT = t [i + k - 1] - t [i];
/*N*/
/*N*/   return (deltaT == 0.0)
/*N*/              ? 0.0
/*N*/              : (x - t [i]) / deltaT;
/*N*/ }

/*************************************************************************
|*
|* Berechne rechten Knotenvektor
|*
\************************************************************************/

/*N*/ double TRight (double x,
/*N*/              int    i,
/*N*/              int    k,
/*N*/              double *t)
/*N*/ {
/*N*/   double deltaT = t [i + k] - t [i + 1];
/*N*/
/*N*/   return (deltaT == 0.0)
/*N*/              ? 0.0
/*N*/              : (t [i + k] - x) / deltaT;
/*N*/ }

/*************************************************************************
|*
|* Berechne Gewichtungsvektor
|*
\************************************************************************/

/*N*/ void BVector (double x,
/*N*/             int    n,
/*N*/             int    k,
/*N*/             double *b,
/*N*/             double *t)
/*N*/ {
/*N*/   for (int i = 0;
/*N*/            i <= n + k;
/*N*/            i ++)
/*N*/       b [i] = 0;
/*N*/
/*N*/   int i0 = (int) floor (x) + k - 1;
/*N*/   b [i0] = 1;
/*N*/
/*N*/   for (int j = 2;
/*N*/            j <= k;
/*N*/            j ++)
/*N*/       for (int i = 0;
/*N*/                i <= i0;
/*N*/                i ++)
/*N*/           b [i] = TLeft (x, i, j, t) * b [i] + TRight (x, i, j, t) * b [i + 1];
/*N*/ }

/*************************************************************************
|*
|* Berechne einzelnen Punkt
|*
\************************************************************************/

/*N*/ void BSPoint (int      n,
/*N*/             Point    &p1,
/*N*/             Point    &p2,
/*N*/             XPolygon &pKnownPoints,
/*N*/             double   *b)
/*N*/ {
/*N*/   for (int i = 0;
/*N*/            i <= n;
/*N*/            i ++)
/*N*/   {
/*N*/       p1.Y () = long(p1.Y () + b [i] * pKnownPoints [i].Y ());
/*N*/       p2.Y () = long(p2.Y () + b [n - i] * pKnownPoints [i].Y ());
/*N*/   }
/*N*/ }

/*************************************************************************
|*
|* Berechne B-Spline
|*
\************************************************************************/

/*N*/ void approxMesh (int      splineSize,
/*N*/                XPolygon &pSplines,
/*N*/                XPolygon &pKnownPoints,
/*N*/                int      n,
/*N*/                int      k)
/*N*/ {
/*N*/   int    pCount   = splineSize * n;
/*N*/   double *b       = new double [n + k + 1];
/*N*/   double *t       = new double [n + k + 2];
/*N*/   double xStep    = ((double) n - (double) k + 2.0) / (double) pCount;
/*N*/   double dStep = ((double) pKnownPoints [n].X () - (double) pKnownPoints [0].X ()) / (double) pCount;
/*N*/   double dXUp     = pKnownPoints [0].X ();
/*N*/   double dXDown   = pKnownPoints [n].X ();
/*N*/   double x        = 0.0;
/*N*/   int    nEnd     = pCount / 2 + 1;
/*N*/
/*N*/   TVector (n, k, t);
/*N*/
/*N*/   for (int j = 0;
/*N*/            j <= nEnd;
/*N*/            j ++)
/*N*/   {
/*N*/       Point aPoint1;
/*N*/       Point aPoint2;
/*N*/
/*N*/       BVector (x, n, k, b, t);
/*N*/       BSPoint (n, aPoint1, aPoint2, pKnownPoints, b);
/*N*/
/*N*/       pSplines [j].X ()          = (int)(floor(dXUp)+0.5);
/*N*/       pSplines [j].Y ()          = aPoint1.Y ();
/*N*/       pSplines [pCount - j].X () = (int)(floor(dXDown)+0.5);
/*N*/       pSplines [pCount - j].Y () = aPoint2.Y ();
/*N*/
/*N*/       x      += xStep;
/*N*/       dXUp   += dStep;
/*N*/       dXDown -= dStep;
/*N*/   }
/*N*/
/*N*/   delete[] t;
/*N*/   delete[] b;
/*N*/ }

/*************************************************************************
|*
|* Passe untere Grenze an den Wertebereich an
|*
\************************************************************************/

/*N*/ double SizeBounds (double dMinValue,
/*N*/                  double dMaxValue,
/*N*/                  BOOL   bIsMax)
/*N*/ {
/*N*/   if( (dMinValue == DBL_MIN) ||
/*N*/       (dMaxValue == DBL_MIN) ||
/*N*/       (dMinValue == dMaxValue) ||
/*N*/       (dMinValue == 0.0) )
/*?*/       return 0.0;
/*N*/
/*N*/   return bIsMax? dMaxValue : dMinValue;
/*N*/
/*N*/   // BM: I removed some very strange code here. It
/*N*/   // calculated a kind of log10 but the charts didn't
/*N*/   // really use the value calculated.
/*N*/ }

/*************************************************************************
|*
|* Erhoehe einen Wert mit Log.
|*
\************************************************************************/

/*N*/ void IncValue(double &rValue,
/*N*/             double fInc,
/*N*/             BOOL   bLogarithm)
/*N*/ {
/*N*/   if (bLogarithm)
/*?*/       rValue *= fInc;
/*N*/   else
/*N*/       rValue += fInc;
/*N*/ }

/*************************************************************************
|*
|* Vermindere einen Wert mit Log.
|*
\************************************************************************/

/*N*/ void DecValue(double &rValue,
/*N*/             double fInc,
/*N*/             BOOL   bLogarithm)
/*N*/ {
/*N*/   if (bLogarithm) rValue /= fInc;
/*N*/   else rValue -= fInc;
/*N*/ }

/*************************************************************************
|*
|* Konvertiert in echte RGB-Farben.
|*
\************************************************************************/

/*N*/ Color RGBColor(ColorData nColorName)
/*N*/ {
/*N*/   Color aColor(nColorName);
/*N*/
/*N*/   return Color(aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue());
/*N*/ }

/*************************************************************************
|*
|* "Stapelt" den angegebenen String.
|*
\************************************************************************/

/*N*/ String StackString( const String& aString )
/*N*/ {
/*N*/   String aStackStr;
/*N*/   xub_StrLen nLen = aString.Len();
/*N*/
/*N*/   if( nLen )
/*N*/   {
/*N*/       // '\n' is interpreted as newline by the outliner
/*N*/       aStackStr.Fill( nLen * 2 - 1, (sal_Unicode)('\n') );
/*N*/
/*N*/       for( xub_StrLen posSrc=0, posDest=0;
/*N*/            posSrc < nLen;
/*N*/            posSrc++, posDest += 2 )
/*N*/           aStackStr.SetChar( posDest, aString.GetChar( posSrc ));
/*N*/   }
/*N*/
/*N*/   return aStackStr;
/*N*/ }

/*************************************************************************
|*
|* Position des ungedrehten Rechtecks entsprechend der Ausrichtung anpassen
|*
\************************************************************************/

/*N*/ void AdjustRect(Rectangle          &rRect,
/*N*/               ChartAdjust        eAdjust)
/*N*/ {
/*N*/   Point aPos = rRect.TopLeft();
/*N*/   Size aSize = rRect.GetSize();
/*N*/
/*N*/   switch (eAdjust)
/*N*/   {
/*N*/       case CHADJUST_TOP_LEFT:
/*N*/
/*N*/           break;
/*N*/
/*N*/       case CHADJUST_TOP_CENTER:
/*N*/
/*N*/           aPos.X() -= aSize.Width() / 2;
/*N*/           break;
/*N*/
/*N*/       case CHADJUST_TOP_RIGHT:
/*N*/
/*N*/           aPos.X() -= aSize.Width();
/*N*/           break;
/*N*/
/*N*/       case CHADJUST_CENTER_LEFT:
/*N*/
/*N*/           aPos.Y() -= aSize.Height() / 2;
/*N*/           break;
/*N*/
/*N*/       case CHADJUST_CENTER_CENTER:
/*N*/
/*?*/           aPos.X() -= aSize.Width() / 2;
/*?*/           aPos.Y() -= aSize.Height() / 2;
/*?*/           break;
/*N*/
/*N*/       case CHADJUST_CENTER_RIGHT:
/*N*/
/*N*/           aPos.X() -= aSize.Width();
/*N*/           aPos.Y() -= aSize.Height() / 2;
/*N*/           break;
/*N*/
/*N*/       case CHADJUST_BOTTOM_LEFT:
/*N*/
/*?*/           aPos.Y() -= aSize.Height();
/*?*/           break;
/*N*/
/*N*/       case CHADJUST_BOTTOM_CENTER:
/*N*/
/*N*/           aPos.X() -= aSize.Width() / 2;
/*N*/           aPos.Y() -= aSize.Height();
/*N*/           break;
/*N*/
/*N*/       case CHADJUST_BOTTOM_RIGHT:
/*?*/           aPos.X() -= aSize.Width();
/*?*/           aPos.Y() -= aSize.Height();
/*N*/
/*N*/   }
/*N*/
/*N*/   rRect.SetPos(aPos);
/*N*/ }

/*************************************************************************
|*
|* Position des gedrehten Rechtecks entsprechend der Ausrichtung anpassen
|*
\************************************************************************/

/*N*/ Size AdjustRotatedRect(const Rectangle       &rOldRect,
/*N*/                      ChartAdjust        eAdjust,
/*N*/                      const Rectangle          &rNewRect)
/*N*/ {
/*N*/
/*N*/   Size aMovement;
/*N*/   Point aOld;
/*N*/   Point aNew;
/*N*/   Point aDifference;
/*N*/
/*N*/   switch (eAdjust)
/*N*/   {
/*?*/       case CHADJUST_TOP_LEFT:
/*?*/
/*?*/           aOld = rOldRect.TopLeft();
/*?*/           aNew = rNewRect.TopLeft();
/*?*/           break;
/*?*/
/*?*/       case CHADJUST_TOP_CENTER:
/*?*/
/*?*/           aOld = rOldRect.TopCenter();
/*?*/           aNew = rNewRect.TopCenter();
/*?*/           break;
/*?*/
/*?*/       case CHADJUST_TOP_RIGHT:
/*?*/
/*?*/           aOld = rOldRect.TopRight();
/*?*/           aNew = rNewRect.TopRight();
/*?*/           break;
/*?*/
/*?*/       case CHADJUST_CENTER_LEFT:
/*?*/
/*N*/           aOld = rOldRect.LeftCenter();
/*N*/           aNew = rNewRect.LeftCenter();
/*N*/           break;
/*?*/
/*?*/       case CHADJUST_CENTER_CENTER:
/*?*/
/*?*/           aOld = rOldRect.Center();
/*?*/           aNew = rNewRect.Center();
/*?*/           break;
/*?*/
/*?*/       case CHADJUST_CENTER_RIGHT:
/*?*/
/*?*/           aOld = rOldRect.RightCenter();
/*?*/           aNew = rNewRect.RightCenter();
/*?*/           break;
/*?*/
/*?*/       case CHADJUST_BOTTOM_LEFT:
/*?*/
/*?*/           aOld = rOldRect.BottomLeft();
/*?*/           aNew = rNewRect.BottomLeft();
/*?*/           break;
/*?*/
/*?*/       case CHADJUST_BOTTOM_CENTER:
/*?*/
/*?*/           aOld = rOldRect.BottomCenter();
/*?*/           aNew = rNewRect.BottomCenter();
/*?*/           break;
/*?*/
/*?*/       case CHADJUST_BOTTOM_RIGHT:
/*?*/
/*?*/           aOld = rOldRect.BottomRight();
/*?*/           aNew = rNewRect.BottomRight();
/*?*/           break;
/*N*/   }
/*N*/
/*N*/   aDifference = ( aOld - aNew);
/*N*/   aMovement =  Size(aDifference.X(),aDifference.Y());
/*N*/
/*N*/   return aMovement;
/*N*/ }
//Umrechnung Textgröße in Größe des BoundRects rotierter Texte
/*N*/ Size GetRotatedTextSize(const Size& rSize,const long nDegrees)
/*N*/ {
/*N*/   if(nDegrees)
/*N*/   {
/*?*/       double fDeg,fSin,fCos;
/*?*/       fDeg=CDEG2RAD(nDegrees);
/*?*/       fSin=fabs(sin(fDeg));
/*?*/       fCos=fabs(cos(fDeg));
/*?*/       Size aRetSize(
/*?*/       (long)( (double)rSize.Width()*fCos + (double)rSize.Height()*fSin ),
/*?*/       (long)( (double)rSize.Width()*fSin + (double)rSize.Height()*fCos )
/*?*/           );
/*?*/       return aRetSize;
/*N*/   }
/*N*/   Size aRetSize(rSize);
/*N*/   return aRetSize;
/*N*/ }
/*************************************************************************
|*
|* die Rotation des Textes in Grad zurueckgeben, falls kein DEGREE-item
|* vorhanden, (z.B. 4.0-Chart) so wird das Item ergaenzt
|*
\************************************************************************/
/*N*/ long GetTextRotation(SfxItemSet &rAttr) //Wrapper, falls eOrient noch nicht ermittelt
/*N*/ {
/*N*/   SvxChartTextOrient eOrient
/*N*/       = ((const SvxChartTextOrientItem&)rAttr.Get(SCHATTR_TEXT_ORIENT)).GetValue();
/*N*/   return GetTextRotation(rAttr,eOrient);
/*N*/ }

/*N*/ long GetTextRotation(SfxItemSet &rAttr,SvxChartTextOrient eOrient)
/*N*/ {
/*N*/
/*N*/   const SfxPoolItem* pPoolItem = NULL;
/*N*/   long nDegrees = 0;
/*N*/
/*N*/     // the attribute is set: use it
/*N*/   if( rAttr.GetItemState( SCHATTR_TEXT_DEGREES, TRUE, &pPoolItem ) == SFX_ITEM_SET )
/*N*/   {
/*?*/         nDegrees = ((const SfxInt32Item*)pPoolItem)->GetValue();
/*?*/         return nDegrees;
/*N*/   }
/*N*/
/*N*/     // otherwise use orientation to set default rotation
/*N*/   switch( eOrient )
/*N*/   {
/*N*/       case CHTXTORIENT_BOTTOMTOP:
/*N*/             nDegrees = 9000;    // 90 deg
/*N*/           break;
/*N*/
/*N*/       case CHTXTORIENT_TOPBOTTOM:
/*?*/             nDegrees = 27000;   // 270 deg
/*?*/           break;
/*N*/
/*N*/       case CHTXTORIENT_STANDARD:
/*N*/       case CHTXTORIENT_STACKED:
/*N*/           break;
/*N*/
/*N*/       default:
/*N*/           break;
/*N*/   }
/*N*/
/*N*/   return nDegrees;
/*N*/ }


/*************************************************************************
|*
|* Ausrichtung entsprechend der Orientierung anpassen
|*
\************************************************************************/

/*N*/ void SetAdjust(ChartAdjust        &rAdjust,
/*N*/              SvxChartTextOrient eOrient)
/*N*/ {
/*N*/   switch (eOrient)
/*N*/   {
/*N*/       case CHTXTORIENT_BOTTOMTOP:
/*N*/           switch (rAdjust)
/*N*/           {
/*N*/               case CHADJUST_TOP_LEFT:
/*N*/                   rAdjust = CHADJUST_TOP_RIGHT;
/*N*/                   break;
/*N*/
/*N*/               case CHADJUST_TOP_CENTER:
/*N*/                   rAdjust = CHADJUST_CENTER_RIGHT;
/*N*/                   break;
/*N*/
/*N*/               case CHADJUST_TOP_RIGHT:
/*N*/                   rAdjust = CHADJUST_BOTTOM_RIGHT;
/*N*/
/*N*/                   break;
/*N*/
/*N*/               case CHADJUST_CENTER_LEFT:
/*N*/                   rAdjust = CHADJUST_TOP_CENTER;
/*N*/                   break;
/*N*/
/*N*/               case CHADJUST_CENTER_RIGHT:
/*N*/                   rAdjust = CHADJUST_BOTTOM_CENTER;
/*N*/                   break;
/*N*/
/*N*/               case CHADJUST_BOTTOM_LEFT:
/*N*/                   rAdjust = CHADJUST_TOP_LEFT;
/*N*/                   break;
/*N*/
/*N*/               case CHADJUST_BOTTOM_CENTER:
/*N*/                   rAdjust = CHADJUST_CENTER_LEFT;
/*N*/                   break;
/*N*/
/*N*/               case CHADJUST_BOTTOM_RIGHT:
/*N*/                   rAdjust = CHADJUST_BOTTOM_LEFT;
/*N*/                   break;
/*N*/               default:
/*N*/                   break;
/*N*/           }
/*N*/           break;
/*N*/
/*N*/       case CHTXTORIENT_TOPBOTTOM:
/*N*/           switch (rAdjust)
/*N*/           {
/*N*/               case CHADJUST_TOP_LEFT:
/*N*/                   rAdjust = CHADJUST_BOTTOM_LEFT;
/*N*/                   break;
/*N*/
/*N*/               case CHADJUST_TOP_CENTER:
/*N*/                   rAdjust = CHADJUST_CENTER_LEFT;
/*N*/                   break;
/*N*/
/*N*/               case CHADJUST_TOP_RIGHT:
/*N*/                   rAdjust = CHADJUST_TOP_LEFT;
/*N*/                   break;
/*N*/
/*N*/               case CHADJUST_CENTER_LEFT:
/*N*/                   rAdjust = CHADJUST_BOTTOM_CENTER;
/*N*/                   break;
/*N*/
/*N*/               case CHADJUST_CENTER_RIGHT:
/*N*/                   rAdjust = CHADJUST_TOP_CENTER;
/*N*/                   break;
/*N*/
/*N*/               case CHADJUST_BOTTOM_LEFT:
/*N*/                   rAdjust = CHADJUST_BOTTOM_RIGHT;
/*N*/                   break;
/*N*/
/*N*/               case CHADJUST_BOTTOM_CENTER:
/*N*/                   rAdjust = CHADJUST_CENTER_RIGHT;
/*N*/                   break;
/*N*/
/*N*/               case CHADJUST_BOTTOM_RIGHT:
/*N*/                   rAdjust = CHADJUST_TOP_RIGHT;
/*N*/                   break;
/*N*/               default:
/*N*/                   break;
/*N*/           }
/*N*/           break;
/*N*/       default:
/*N*/           break;
/*N*/   }
/*N*/ }

/*************************************************************************
|*
|* Textobjekt positionieren
|*
\************************************************************************/
/*N*/ void SetTextPos(SdrTextObj  &rTextObj,
/*N*/               const Point &rPos,SfxItemSet* pAttr)
/*N*/ {
/*N*/   SchObjectAdjust    *pObjAdjust = GetObjectAdjust(rTextObj);
/*N*/   ChartAdjust         eAdjust    = pObjAdjust->GetAdjust();
/*N*/   double              fVal;
/*N*/   SvxChartTextOrient  eOrient    = pObjAdjust->GetOrient();
/*N*/
/*N*/   switch (eOrient)
/*N*/   {
/*N*/       case CHTXTORIENT_BOTTOMTOP:
/*N*/       case CHTXTORIENT_TOPBOTTOM:
/*N*/       {
/*N*/           long nAng = 36000 - rTextObj.GetRotateAngle();
/*N*/           fVal = nAng * nPi180;
/*N*/           rTextObj.NbcRotate(rPos, nAng, sin(fVal), cos(fVal));
/*N*/           break;
/*N*/       }
/*N*/       default:
/*N*/           break;
/*N*/   }
/*N*/
/*N*/   Rectangle aRect = rTextObj.GetLogicRect();
/*N*/   aRect.SetPos(rPos);
/*N*/   AdjustRect(aRect, eAdjust);
/*N*/   rTextObj.NbcSetLogicRect(aRect);
/*N*/
/*N*/   switch (eOrient)
/*N*/   {
/*N*/       case CHTXTORIENT_BOTTOMTOP:
/*N*/       case CHTXTORIENT_TOPBOTTOM:
/*N*/       {
/*N*/           long nDegrees = GetTextRotation(*pAttr,eOrient);
/*N*/           Rectangle aOldBoundRect=rTextObj.GetBoundRect();
/*N*/           fVal = nDegrees * nPi180;
/*N*/           rTextObj.NbcRotate(rPos, nDegrees, sin(fVal), cos(fVal));
/*N*/           Rectangle aNewBoundRect=rTextObj.GetBoundRect();
/*N*/           rTextObj.NbcMove( AdjustRotatedRect(aOldBoundRect, eAdjust, aNewBoundRect));
/*N*/       }
/*N*/       default:
/*N*/           break;
/*N*/   }
/*N*/ }

/*************************************************************************
|*
|* Textobjekt-Groesse entsprechend der Ausrichtung anpassen
|*
\************************************************************************/

/*N*/ void AdjustTextSize(SdrTextObj &rTextObj,
/*N*/                   const Size &rTextSize)
/*N*/ {
/*N*/   Rectangle aRect = rTextObj.GetLogicRect();
/*N*/
/*N*/   if (aRect.GetSize() != rTextSize)
/*N*/   {
/*N*/       SchObjectAdjust    *pObjAdjust = GetObjectAdjust(rTextObj);
/*N*/       ChartAdjust        eAdjust     = pObjAdjust->GetAdjust();
/*N*/       SvxChartTextOrient eOrient     = pObjAdjust->GetOrient();
/*N*/
/*N*/       SetAdjust(eAdjust, eOrient);
/*N*/
/*N*/       Point aOldPos = aRect.TopLeft();
/*N*/
/*N*/       switch (eAdjust)
/*N*/       {
/*N*/           case CHADJUST_TOP_CENTER:
/*N*/               aRect.Left() = aRect.Left() + aRect.GetWidth() / 2 - rTextSize.Width() / 2;
/*N*/               aRect.Right() = aRect.Left() + rTextSize.Width();
/*N*/               aRect.Bottom() = aRect.Top() + rTextSize.Height();
/*N*/               break;
/*N*/
/*N*/           case CHADJUST_TOP_RIGHT:
/*N*/               aRect.Left() = aRect.Right() - rTextSize.Width();
/*N*/               aRect.Bottom() = aRect.Top() + rTextSize.Height();
/*N*/               break;
/*N*/
/*N*/           case CHADJUST_CENTER_LEFT:
/*N*/               aRect.Right() = aRect.Left() + rTextSize.Width();
/*N*/               aRect.Top() = aRect.Top() + aRect.GetHeight() / 2 - rTextSize.Height() / 2;
/*N*/               aRect.Bottom() = aRect.Top() + rTextSize.Height();
/*N*/               break;
/*N*/
/*N*/           case CHADJUST_CENTER_CENTER:
/*N*/               aRect.Left() = aRect.Left() + aRect.GetWidth() / 2 - rTextSize.Width() / 2;
/*N*/               aRect.Right() = aRect.Left() + rTextSize.Width();
/*N*/               aRect.Top() = aRect.Top() + aRect.GetHeight() / 2 - rTextSize.Height() / 2;
/*N*/               aRect.Bottom() = aRect.Top() + rTextSize.Height();
/*N*/               break;
/*N*/
/*N*/           case CHADJUST_CENTER_RIGHT:
/*N*/               aRect.Left() = aRect.Right() - rTextSize.Width();
/*N*/               aRect.Top() = aRect.Top() + aRect.GetHeight() / 2 - rTextSize.Height() / 2;
/*N*/               aRect.Bottom() = aRect.Top() + rTextSize.Height();
/*N*/               break;
/*N*/
/*N*/           case CHADJUST_BOTTOM_LEFT:
/*N*/               aRect.Right() = aRect.Left() + rTextSize.Width();
/*N*/               aRect.Top() = aRect.Bottom() - rTextSize.Height();
/*N*/               break;
/*N*/
/*N*/           case CHADJUST_BOTTOM_CENTER:
/*N*/               aRect.Left() = aRect.Left() + aRect.GetWidth() / 2 - rTextSize.Width() / 2;
/*N*/               aRect.Right() = aRect.Left() + rTextSize.Width();
/*N*/               aRect.Top() = aRect.Bottom() - rTextSize.Height();
/*N*/               break;
/*N*/
/*N*/           case CHADJUST_BOTTOM_RIGHT:
/*N*/               aRect.Left() = aRect.Right() - rTextSize.Width();
/*N*/               aRect.Top() = aRect.Bottom() - rTextSize.Height();
/*N*/               break;
/*N*/
/*N*/           default:
/*N*/               aRect.Right() = aRect.Left() + rTextSize.Width();
/*N*/               aRect.Bottom() = aRect.Top() + rTextSize.Height();
/*N*/               break;
/*N*/       }
/*N*/
/*N*/       Point aNewPos = aRect.TopLeft();
/*N*/
/*N*/       if (aNewPos != aOldPos)
/*N*/       {
/*N*/           long nArc = rTextObj.GetRotateAngle();
/*N*/
/*N*/           if (nArc)
/*N*/           {
/*N*/               double fVal = nArc * nPi180;
/*N*/               RotatePoint(aNewPos, aOldPos, sin(fVal), cos(fVal));
/*N*/               aRect.SetPos(aNewPos);
/*N*/           }
/*N*/       }
/*N*/
/*N*/       rTextObj.SetLogicRect(aRect);
/*N*/   }
/*N*/ }

/*************************************************************************
|*
|* Ausgabegroesse ermitteln
|*
\************************************************************************/

/*N*/ Size GetOutputSize(SdrTextObj& rTextObj)
/*N*/ {
/*N*/   return (rTextObj.GetBoundRect().GetSize());
/*N*/ }

/*************************************************************************
|*
|* Erstelle eine Gruppe und die Sublist fuer ein Chart
|*
\************************************************************************/

/*N*/ void CreateChartGroup( SchObjGroup* &pGroup,
/*N*/                      SdrObjList*  &pList )
/*N*/ {
/*N*/   pGroup = new SchObjGroup;
/*N*/   pList  = pGroup->GetSubList();
/*N*/   pGroup->InsertUserData( new SchObjectId( CHOBJID_DIAGRAM ));
/*N*/ }



/*************************************************************************
|*
|* Beseitige alle Statistikattrs
|*
\************************************************************************/


/*N*/ const long nOffX = SCHATTR_AXIS_AUTO_MIN - SCHATTR_X_AXIS_AUTO_MIN;
/*N*/ const long nOffY = SCHATTR_AXIS_AUTO_MIN - SCHATTR_Y_AXIS_AUTO_MIN;
/*N*/ const long nOffZ = SCHATTR_AXIS_AUTO_MIN - SCHATTR_Z_AXIS_AUTO_MIN;

//alte in neue Achsenattr konvertieren
/*N*/ void AxisAttrOld2New(SfxItemSet &rDestSet,BOOL bClear,long nId)
/*N*/ {
/*N*/
/*N*/   double f;
/*N*/   BOOL b;
/*N*/   SfxItemSet aSet(rDestSet); //Kopie
/*N*/
/*N*/   SfxWhichIter aIter (aSet);
/*N*/   USHORT nWhich = aIter.FirstWhich ();
/*N*/
/*N*/   while (nWhich)
/*N*/   {
/*N*/       switch(nWhich)
/*N*/       {
/*N*/           case SCHATTR_X_AXIS_AUTO_MIN:
/*N*/           case SCHATTR_X_AXIS_AUTO_MAX:
/*N*/           case SCHATTR_X_AXIS_AUTO_STEP_MAIN:
/*N*/           case SCHATTR_X_AXIS_AUTO_STEP_HELP:
/*N*/           case SCHATTR_X_AXIS_LOGARITHM:
/*N*/           case SCHATTR_X_AXIS_AUTO_ORIGIN:
/*N*/
/*N*/               if(nId==CHOBJID_DIAGRAM_X_AXIS)
/*N*/               {
/*N*/                   b=((const SfxBoolItem&)rDestSet.Get(nWhich)).GetValue();
/*N*/                   rDestSet.Put(SfxBoolItem(nWhich+USHORT(nOffX),b));
/*N*/                   if(bClear)
/*N*/                       rDestSet.ClearItem(nWhich);
/*N*/               }
/*N*/               break;
/*N*/
/*N*/           case SCHATTR_X_AXIS_MIN:
/*N*/           case SCHATTR_X_AXIS_MAX:
/*N*/           case SCHATTR_X_AXIS_STEP_MAIN:
/*N*/           case SCHATTR_X_AXIS_STEP_HELP:
/*N*/           case SCHATTR_X_AXIS_ORIGIN:
/*N*/
/*N*/               if(nId==CHOBJID_DIAGRAM_X_AXIS)
/*N*/               {
/*N*/                   f=((const SvxDoubleItem&)rDestSet.Get(nWhich)).GetValue();
/*N*/                   rDestSet.Put(SvxDoubleItem(f,nWhich+USHORT(nOffX)));
/*N*/                   if(bClear)
/*N*/                       rDestSet.ClearItem(nWhich);
/*N*/               }
/*N*/               break;
/*N*/
/*N*/           case SCHATTR_Y_AXIS_AUTO_MIN:
/*N*/           case SCHATTR_Y_AXIS_AUTO_MAX:
/*N*/           case SCHATTR_Y_AXIS_AUTO_STEP_MAIN:
/*N*/           case SCHATTR_Y_AXIS_AUTO_STEP_HELP:
/*N*/           case SCHATTR_Y_AXIS_LOGARITHM:
/*N*/           case SCHATTR_Y_AXIS_AUTO_ORIGIN:
/*N*/
/*N*/               if(nId==CHOBJID_DIAGRAM_Y_AXIS)
/*N*/               {
/*N*/                   b=((const SfxBoolItem&)rDestSet.Get(nWhich)).GetValue();
/*N*/                   rDestSet.Put(SfxBoolItem(nWhich+USHORT(nOffY),b));
/*N*/                   if(bClear)
/*N*/                       rDestSet.ClearItem(nWhich);
/*N*/               }
/*N*/               break;
/*N*/
/*N*/           case SCHATTR_Y_AXIS_MIN:
/*N*/           case SCHATTR_Y_AXIS_MAX:
/*N*/           case SCHATTR_Y_AXIS_STEP_MAIN:
/*N*/           case SCHATTR_Y_AXIS_STEP_HELP:
/*N*/           case SCHATTR_Y_AXIS_ORIGIN:
/*N*/
/*N*/               if(nId==CHOBJID_DIAGRAM_Y_AXIS)
/*N*/               {
/*N*/                   f=((const SvxDoubleItem&)rDestSet.Get(nWhich)).GetValue();
/*N*/                   rDestSet.Put(SvxDoubleItem(f,nWhich+USHORT(nOffY)));
/*N*/                   if(bClear)
/*N*/                       rDestSet.ClearItem(nWhich);
/*N*/               }
/*N*/               break;
/*N*/
/*N*/           case SCHATTR_Z_AXIS_AUTO_MIN:
/*N*/           case SCHATTR_Z_AXIS_AUTO_MAX:
/*N*/           case SCHATTR_Z_AXIS_AUTO_STEP_MAIN:
/*N*/           case SCHATTR_Z_AXIS_AUTO_STEP_HELP:
/*N*/           case SCHATTR_Z_AXIS_LOGARITHM:
/*N*/           case SCHATTR_Z_AXIS_AUTO_ORIGIN:
/*N*/
/*N*/               if(nId==CHOBJID_DIAGRAM_Z_AXIS)
/*N*/               {
/*N*/                   b=((const SfxBoolItem&)rDestSet.Get(nWhich)).GetValue();
/*N*/                   rDestSet.Put(SfxBoolItem(nWhich+USHORT(nOffZ),b));
/*N*/                   if(bClear)
/*N*/                       rDestSet.ClearItem(nWhich);
/*N*/               }
/*N*/               break;
/*N*/
/*N*/           case SCHATTR_Z_AXIS_MIN:
/*N*/           case SCHATTR_Z_AXIS_MAX:
/*N*/           case SCHATTR_Z_AXIS_STEP_MAIN:
/*N*/           case SCHATTR_Z_AXIS_STEP_HELP:
/*N*/           case SCHATTR_Z_AXIS_ORIGIN:
/*N*/
/*N*/               if(nId==CHOBJID_DIAGRAM_Z_AXIS)
/*N*/               {
/*N*/                   f=((const SvxDoubleItem&)rDestSet.Get(nWhich)).GetValue();
/*N*/                   rDestSet.Put(SvxDoubleItem(f,nWhich+USHORT(nOffZ)));
/*N*/                   if(bClear)
/*N*/                       rDestSet.ClearItem(nWhich);
/*N*/               }
/*N*/               break;
/*N*/       }
/*N*/       nWhich = aIter.NextWhich();
/*N*/   }
/*N*/ }

/*************************************************************************
|*
|* Pruefe zwei ItemSets und vernichte paarweise verschiedene Items
|*
\************************************************************************/


/*N*/ void IntersectSets( const SfxItemSet &  rSource, SfxItemSet &  rDest )
/*N*/ {
/*N*/     SfxWhichIter aIter( rSource );
/*N*/     SfxItemState aSrcState;
/*N*/
/*N*/     for( USHORT nWhich = aIter.FirstWhich(); nWhich != 0; nWhich = aIter.NextWhich() )
/*N*/     {
/*N*/         aSrcState = rSource.GetItemState( nWhich );
/*N*/
/*N*/         if( // one item is (may be) set but the other one isn't
/*N*/             ( aSrcState != rDest.GetItemState( nWhich ) )
/*N*/             ||
/*N*/             // both items are set, but their content differs
/*N*/             // (if aSrcState is set it follows that also aDestState is set)
/*N*/             ( ( aSrcState == SFX_ITEM_SET )
/*N*/                 &&
/*N*/               ( rSource.Get( nWhich ) != rDest.Get( nWhich ) ) ) )
/*N*/         {
/*N*/             rDest.InvalidateItem( nWhich );
/*N*/         }
/*N*/     }
/*N*/ }

/*************************************************************************
|*
|* Setze je nach Ausrichtungsinformation den Punkt um den ausgerichtet wird
|*
|* Das wird hauptsaechlich von chtmode4 aufgerufen um zu wissen welche
|* Position des Textes man sich merken muss, um dne wird dann mit moeglicherweise
|* veraenderter Schriftgroesse ausgegeben.
|*
\************************************************************************/

/*N*/ Point SetPointOfRectangle (const Rectangle& rRect, ChartAdjust eAdjust)
/*N*/ {
/*N*/   switch (eAdjust)
/*N*/   {
/*?*/       case CHADJUST_TOP_LEFT:
/*?*/            return (rRect.TopLeft());
/*?*/       case CHADJUST_TOP_RIGHT:
/*?*/            return (rRect.TopRight());
/*N*/       case CHADJUST_TOP_CENTER:
/*N*/            return (rRect.TopCenter());
/*N*/       case CHADJUST_CENTER_LEFT:
/*N*/            return (rRect.LeftCenter());
/*?*/       case CHADJUST_CENTER_RIGHT:
/*?*/            return (rRect.RightCenter());
/*?*/       case CHADJUST_CENTER_CENTER:
/*?*/            return (rRect.Center());
/*?*/       case CHADJUST_BOTTOM_LEFT:
/*?*/            return (rRect.BottomLeft());
/*?*/       case CHADJUST_BOTTOM_CENTER:
/*N*/            return (rRect.BottomCenter());
/*?*/       case CHADJUST_BOTTOM_RIGHT:
/*?*/            return (rRect.BottomRight());
/*?*/       default:
/*?*/            ;
/*?*/   }
/*?*/   Point aPoint(-1,-1);
/*?*/   return aPoint;  // Das ist das Default für die Plazierungsinformation von Chart-Texten
/*N*/ }

//!!! Es werden NICHT ALLE Attr ausgewertet, nur Größen-relevante!
/*N*/ void ItemsToFont(const SfxItemSet& rSet,Font& rFont)
/*N*/ {
/*N*/   const SfxPoolItem* pItem = NULL;
/*N*/   if( rSet.GetItemState( EE_CHAR_FONTINFO, TRUE, &pItem ))
/*N*/   {
/*N*/       SvxFontItem* pFontItem = (SvxFontItem*)pItem;
/*N*/
/*N*/       rFont.SetStyleName(pFontItem->GetStyleName() );
/*N*/       rFont.SetName(     pFontItem->GetFamilyName());
/*N*/       rFont.SetCharSet(  pFontItem->GetCharSet());
/*N*/       rFont.SetFamily(   pFontItem->GetFamily());
/*N*/       rFont.SetPitch(    pFontItem->GetPitch());
/*N*/   }
/*N*/
/*N*/   //  Scale the font's horizontal size like the vertical size.  Assume that the original size is
/*N*/   //  7pt.  The scaling is done here because the item EE_CHAR_FONTWIDTH holds a horizontal scaling
/*N*/   //  factor.  The horizontal size can therefore not be stored there.  But as the font is scaled
/*N*/   //  uniformly, the horizontal size depends uniquely on the vertical size.
/*N*/   long nFontHeight = static_cast<const SvxFontHeightItem&>(rSet.Get(EE_CHAR_FONTHEIGHT)).GetHeight();
/*N*/   long nFontWidth = 0;    // #89001# use default font width
/*N*/   rFont.SetSize (Size (nFontWidth, nFontHeight));
/*N*/
/*N*/   rFont.SetWeight( ((const SvxWeightItem&)rSet.Get( EE_CHAR_WEIGHT )).GetWeight() );
/*N*/   rFont.SetUnderline( ((const SvxUnderlineItem&)rSet.Get( EE_CHAR_UNDERLINE )).GetUnderline() );
/*N*/   rFont.SetStrikeout( ((const SvxCrossedOutItem&)rSet.Get( EE_CHAR_STRIKEOUT )).GetStrikeout() );
/*N*/   rFont.SetItalic( ((const SvxPostureItem&)rSet.Get( EE_CHAR_ITALIC )).GetPosture() );
/*N*/   rFont.SetOutline( ((const SvxContourItem&)rSet.Get( EE_CHAR_OUTLINE )).GetValue() );
/*N*/   rFont.SetShadow( ((const SvxShadowedItem&)rSet.Get( EE_CHAR_SHADOW )).GetValue() );
/*N*/   rFont.SetKerning( ((const SvxAutoKernItem&)rSet.Get( EE_CHAR_PAIRKERNING )).GetValue() );
/*N*/   rFont.SetWordLineMode( ((const SvxWordLineModeItem&)rSet.Get( EE_CHAR_WLM )).GetValue() );
/*N*/ }


} //namespace binfilter
#ifdef DBG_UTIL

// ==================== DEBUG SfxItemSets ====================

#include <bf_svtools/itempool.hxx>
#include <bf_svtools/itemiter.hxx>

#include <cstdio>       // for snprintf
#include <cstring>      // for strncat
namespace binfilter {
/*N*/ void Dbg_DebugItems( SfxItemSet& rSet, ChartModel* pModel )
/*N*/ {
/*N*/   SfxItemPool *pItemPool=&( pModel->GetItemPool() );
/*N*/
/*N*/   char pBuf[ 512 ] = "";
/*N*/   char pSmallBuf[ 128 ] = "";
/*N*/
/*N*/   const USHORT* pRanges = rSet.GetRanges();
/*N*/   for( long n = 0; pRanges[ n ] && n<32; n+=2 )
/*N*/   {
/*N*/       snprintf( pSmallBuf, sizeof(pSmallBuf), "[%" SAL_PRIdINT32 "; %" SAL_PRIdINT32 "] ", (sal_uInt32)pRanges[ n ], (sal_uInt32)pRanges[ n+1 ] );
/*N*/       strncat( pBuf, pSmallBuf, sizeof(pBuf) - strlen(pBuf) - 1 );
/*N*/   }
/*N*/
/*N*/   OSL_TRACE( "SCH:ItemDBG - Ranges: %s", pBuf );
/*N*/
/*N*/   pBuf[ 0 ] = '\0';
/*N*/
/*N*/   long nInv = 0, nCnt = 0, nCnv = 0, nCns = 0;
/*N*/   SfxItemIter aIterator( rSet );
/*N*/
/*N*/   const SfxPoolItem* pItem;
/*N*/   USHORT nWhich, nNewWhich;
/*N*/
/*N*/   pItem = aIterator.FirstItem();
/*N*/   while( pItem )
/*N*/   {
/*N*/       if( ! IsInvalidItem( pItem ) )
/*N*/       {
/*N*/           nWhich= pItem->Which();
/*N*/
/*N*/           nCnt++;
/*N*/           if( nWhich < SCHATTR_END )
/*N*/               nCns++;
/*N*/           if( nCnt < 100 )
/*N*/           {
/*N*/               snprintf( pSmallBuf, sizeof(pSmallBuf), "%" SAL_PRIdINT32 ", ", (sal_uInt32) nWhich );
/*N*/               strncat( pBuf, pSmallBuf, sizeof(pBuf) - strlen(pBuf) - 1 );
/*N*/           }
/*N*/
/*N*/           nNewWhich = pItemPool->GetWhich( nWhich );
/*N*/           if( nWhich != nNewWhich )
/*?*/               nCnv++;
/*N*/       }
/*N*/       else
/*?*/           nInv++;
/*N*/
/*N*/       pItem = aIterator.NextItem();
/*N*/   }
/*N*/
/*N*/   OSL_TRACE( "SCH:ItemDBG - List: %s", pBuf );
/*N*/
/*N*/   long nColor = -1;
/*N*/   long nMat = -1;
/*N*/   const SfxPoolItem *pPoolItem;
/*N*/
/*N*/   if( SFX_ITEM_SET == rSet.GetItemState(XATTR_FILLCOLOR,TRUE,&pPoolItem ) )
/*N*/   {
/*N*/       Color aColor( ( ( const XFillColorItem* ) pPoolItem )->GetValue() );
/*N*/       nColor=aColor.GetRGBColor();
/*N*/   }
/*N*/   if( SFX_ITEM_SET == rSet.GetItemState( SDRATTR_3DOBJ_MAT_COLOR, TRUE, &pPoolItem ) )
/*N*/   {
/*N*/       Color aNew(  ((const SvxColorItem*) pPoolItem )->GetValue()   );
/*N*/       nMat=aNew.GetRGBColor();
/*N*/   }
/*N*/
/*N*/
/*N*/   long r=COLORDATA_RED(nColor),g=COLORDATA_GREEN(nColor),b=COLORDATA_BLUE(nColor);
/*N*/
/*N*/   OSL_TRACE( "SCH:ItemDBG - Info: this=%lx, #=%ld, WID-able=%ld, invalid=%ld", (long)pModel, nCnt, nCnv, nInv );
/*N*/   OSL_TRACE( "... Chart=%ld, RGB=(%d, %d, %d), Mat=%ld", nCns, r, g, b, nMat );
/*N*/ }
} //namespace binfilter
#endif



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