1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <comphelper/string.hxx>
23 #include <tools/config.hxx>
24 #include <vcl/graphicfilter.hxx>
25 #include "sgffilt.hxx"
26 #include "sgfbram.hxx"
27 #include "sgvmain.hxx"
29 extern SgfFontLst
* pSgfFonts
;
32 #define abs(x) ((x)<0 ? -(x) : (x))
36 ////////////////////////////////////////////////////////////////////////////////////////////////////
38 // Einschraenkungen: Schatten nur grau, 2D und mit fixem Abstand.
43 ////////////////////////////////////////////////////////////////////////////////////////////////////
45 /////////////////////////////////////////////////////////////////////////////////
46 /////////////////////////////////////////////////////////////////////////////////
47 /////////////////////////////////////////////////////////////////////////////////
50 // die folgenden Werte sind in % vom maximalen Schriftgrad der Zeile */
51 #define UndlSpace 5 /* Untersteichungsabstand von der Baseline */
52 #define UndlWidth 6 /* Untersteichungsdicke */
53 #define UndlSpac2 7 /* Zwischenraum bei doppelter Unterstreichung */
54 #define StrkSpace 25 /* Abstand der Durchstreichlinie von der Baseline*/
55 #define StrkWidth 5 /* Durchstreichungsliniendicke */
56 #define StrkSpac2 7 /* Zwischenraum bei doppelter Durchstreichung */
57 #define OutlWidth 2 /* Strichstaerke ist 2% vom Schriftgrad */
59 // vvv Sonderzeichen im TextBuffer vvv
60 #define TextEnd 0 /* ^@ Ende der Zeichenkette */
61 #define HardSpace 6 /* ^F Hartspace (wird nicht umbrochen) ,' ' */
62 #define GrafText 7 /* ^G Im Text eingebundene Grafik (future) */
63 #define Tabulator 9 /* ^I Tabulatorzeichen, Pfeil */
64 #define LineFeed 10 /* ^J Neue Zeile */
65 #define SoftTrennK 11 /* ^K Zeichen fuer k-c-Austausch bei Trennung, 'k' */
66 #define AbsatzEnd 13 /* ^M Neuer Absatz =CR */
67 #define HardTrenn 16 /* ^P Hartes Trennzeichen (wird nicht umbrochen), '-' */
68 #define SoftTrennAdd 19 /* ^S Zusatz-Zeichen Trennung von z.b."Schiff-fahrt" */
69 #define Paragraf 21 /* ^U Zeichen welches fuer Paragraf-Zeichen */
70 #define Escape 27 /* ^[ Escapesequenz einleiten */
71 #define SoftTrenn 31 /* ^_ Weiches Trennzeichen, '-' nur Zeilenende */
72 #define MaxEscValLen 8
73 #define MaxEscLen (MaxEscValLen+3)
75 //==============================================================================
76 // Escapesequenzen: [Esc]<Ident><Value>[Esc] also mind. 4 Char
77 // Max. Laenge von Value soll sein: 8 Char (7+Vorzeichen). Demnach max. Laenge
78 // einer Escapesequenz: 11 Char.
81 #define EscFont 'F' /* FontID, z.B. 92500 fuer CG Times */
82 #define EscGrad 'G' /* Schriftgrad 1..255 fuer <<Pt-127<<Pt */
83 #define EscBreit 'B' /* Breite 1..255% des Schriftgrades */
84 #define EscKaptS 'K' /* Kapitaelchengroesse 1..255% des Schriftgrades */
85 #define EscLFeed 'L' /* Zeilenabstand 1..32767% vom max. Schriftgrad der Zeile */
86 // oder 1..32767 fuer 1..16383<<Pt absolut (Wenn Bit 15=1)
87 #define EscSlant 'S' /* Kursiv(Winkel) 1..8999 fuer 0.01deg..89.99deg */
88 #define EscVPos 'V' /* Zeichen Vertikal-Position 1..255 fuer <<Pt..127<<Pt */
89 #define EscZAbst 'Z' /* Zeichenabstand -128..127% */
90 #define EscHJust 'A' /* H-Justify Absatz: Links, Zentr, Rechts, Block, Austreibend, Gesperrt (0..5)*/
92 #define EscFarbe 'C' /* Farbe 0..7 */
93 #define EscBFarb 'U' /* BackFarbe 0..7 */
94 #define EscInts 'I' /* Farbintensitaet 0..100% */
95 #define EscMustr 'M' /* Muster 0..? inkl. Transp... */
96 #define EscMFarb 'O' /* Musterfarbe 0..7 */
97 #define EscMBFrb 'P' /* 2. Musterfarbe 0..7 */
98 #define EscMInts 'W' /* Musterintensitaet 0..7 */
100 #define EscSMstr 'E' /* Schattenmuster 0..? inkl. Transp... */
101 #define EscSFarb 'R' /* Schattenfarbe 0..7 */
102 #define EscSBFrb 'T' /* 2. Schattenfarbe 0..7 */
103 #define EscSInts 'Q' /* Schattenintensitaet 0..7 */
105 #define EscSXDst 'X' /* Schattenversatz X 0..100% */
106 #define EscSYDst 'Y' /* Schattenversatz Y 0..100% */
107 #define EscSDist 'D' /* Schattenversatz X-Y 0..100% */
109 #define EscBold 'f' /* Fett */
110 #define EscLSlnt 'l' /* LKursiv */
111 #define EscRSlnt 'r' /* RKursiv */
112 #define EscUndln 'u' /* Unterstrichen */
113 #define EscDbUnd 'p' /* doppelt Unterstrichen */
114 #define EscKaptF 'k' /* Kapitaelchenflag */
115 #define EscStrik 'd' /* Durchgestrichen */
116 #define EscDbStk 'e' /* doppelt Durchgestrichen */
117 #define EscSupSc 'h' /* Hochgestellt */
118 #define EscSubSc 't' /* Tiefgestellt */
119 #define Esc2DShd 's' /* 2D-Schatten */
120 #define Esc3DShd 'j' /* 3D-Schatten */
121 #define Esc4DShd 'i' /* 4D-Schatten */
122 #define EscEbShd 'b' /* Embossed */
124 // AllEscIdent =[EscFont, EscGrad, EscBreit,EscKaptS,EscLFeed,EscSlant,EscVPos, EscZAbst,EscHJust,
125 // EscFarbe,EscBFarb,EscInts, EscMustr,EscMFarb,EscMBFrb,EscMInts,
126 // EscSMstr,EscSFarb,EscSBFrb,EscSInts,EscSXDst,EscSYDst,EscSDist,
127 // EscBold, EscLSlnt,EscRSlnt,EscUndln,EscDbUnd,EscKaptF,EscStrik,EscDbStk,
128 // EscSupSc,EscSubSc,Esc2DShd,Esc3DShd,Esc4DShd];
129 // Justify muss spaetestens am Anfang des Absatzes stehen
130 #define EscSet '\x1e' /* Flag setzen */
131 #define EscReset '\x1f' /* Flag loeschen */
132 #define EscDeflt '\x11' /* Flag auf default setzen */
133 #define EscToggl '\x1d' /* Flag Toggeln */
135 #define EscNoVal -2147483647 /* -MaxLongInt */
136 //==============================================================================
137 #define NoTrenn 0xFFFF /* Wert fuer Parameter 'Rest' von GetTextChar(), wenn auf keinen Fall getrennt werden soll */
138 #define DoTrenn 0xFFFE /* Wert fuer Parameter 'Rest' von GetTextChar(), wenn getrennt werden soll */
140 #define MaxLineChars 1024
142 #define ChrXPosArrSize (MaxLineChars+1+1) /* 2k - Beginnt mit 0 im gegensatz zu StarDraw */
143 #define CharLineSize (MaxLineChars+1+1)
149 //==============================================================================
152 #define CharTopToBase 100 /* wegen Apostrophe und Umlaute mehr als 75% */
153 #define CharTopToBtm 120 /* Zeilenhoehe ist groesser als Schriftgrad */
154 // bei Avanti-Bold 'ue' eigentlich sogar 130%
156 // end of AbsBase.Pas
157 /////////////////////////////////////////////////////////////////////////////////
158 /////////////////////////////////////////////////////////////////////////////////
159 /////////////////////////////////////////////////////////////////////////////////
163 /////////////////////////////////////////////////////////////////////////////////
164 /////////////////////////////////////////////////////////////////////////////////
165 /////////////////////////////////////////////////////////////////////////////////
168 #define TextBoldBit 0x0001 /* Fett */
169 #define TextRSlnBit 0x0002 /* Kursiv */
170 #define TextUndlBit 0x0004 /* Unterstrichen */
171 #define TextStrkBit 0x0008 /* Durchgesteichen */
172 #define TextSupSBit 0x0010 /* Hocgestellt */
173 #define TextSubSBit 0x0020 /* Tiefgestellt */
174 #define TextKaptBit 0x0040 /* Kapitaelchen */
175 #define TextLSlnBit 0x0080 /* Linkskursiv */
176 #define TextDbUnBit 0x0100 /* Doppelt unterstrichen */
177 #define TextDbStBit 0x0200 /* Doppelt durchgestrichen */
178 #define TextSh2DBit 0x0400 /* 2D-Schatten 2.0 */
179 #define TextSh3DBit 0x0800 /* 3D-Schatten 2.0 */
180 #define TextSh4DBit 0x1000 /* 4D-Schatten 2.0 */
181 #define TextShEbBit 0x2000 /* Embossed-Schatten 2.0 */
182 #define FontAtrBits (TextBoldBit | TextRSlnBit)
184 #define THJustLeft 0x00
185 #define THJustCenter 0x01
186 #define THJustRight 0x02
187 #define THJustBlock 0x03
188 #define THJustDrvOut 0x04 /* Austreibend Formatiert */
189 #define THJustLocked 0x05 /* A l s S p e r r s c h r i f t */
190 #define TVJustTop 0x00 /* Future */
191 #define TVJustCenter 0x10 /* Future */
192 #define TVJustBottom 0x20 /* Future */
193 #define TVJustBlock 0x30 /* Future */
195 #define MaxCharSlant 4200 /* Maximal 42deg kursiv ! */
197 // end of DefBase.Pas
198 /////////////////////////////////////////////////////////////////////////////////
199 /////////////////////////////////////////////////////////////////////////////////
200 /////////////////////////////////////////////////////////////////////////////////
203 sal_Bool
CheckTextOutl(ObjAreaType
& F
, ObjLineType
& L
);
205 sal_Bool
CheckTextOutl(ObjAreaType
& F
, ObjLineType
& L
)
207 return (F
.FIntens
!=L
.LIntens
) ||
208 ((F
.FFarbe
!=L
.LFarbe
) && (F
.FIntens
>0)) ||
209 ((F
.FBFarbe
!=L
.LBFarbe
) && (F
.FIntens
<100));
213 /////////////////////////////////////////////////////////////////////////////////
214 /////////////////////////////////////////////////////////////////////////////////
215 /////////////////////////////////////////////////////////////////////////////////
218 short hPoint2Sgf(short a
)
221 b
=long(a
)*127*SgfDpmm
/(144*5);
228 // ======================================================================
229 // Function GetTopToBaseLine() Function GetBaseLineToBtm()
231 // Abstand von Zeilenoberkante bis BaseLine bzw. von BaseLine bis
232 // Unterkante berechnen. Alles in SGF-Units.
233 // ======================================================================
235 sal_uInt16
GetTopToBaseLine(sal_uInt16 MaxGrad
)
238 ret
=long(MaxGrad
)*long(CharTopToBase
) /long(100);
239 return sal_uInt16(ret
);
242 // ======================================================================
243 // Function GetTextChar() Function GetTextCharConv()
245 // Liest ein Zeichen aus dem Textbuffer, wertet dabei eventuell
246 // auftretende Escapesequenzen aus und setzt dementsprechend den
247 // Ein-/Ausgabeparameter AktAtr. Index wird entsprechend erhoeht.
248 // Der Parameter Rest muss immer die Anzahl der Zeichen beinhalten,
249 // den angeforderten Zeichen in der aktuellen Zeile noch folgen.
250 // Ansonsten funktioniert die Silbentrennung nicht richtig. Gibt man
251 // stattdessen die Konstante NoTrenn an, wird in keinem Fall
252 // getrennt, die Konstante DoTrenn bewirkt dagegen, dass ueberall dort
253 // getrennt wird, wo ein SoftTrenner vorkommt.
255 // SoftTrenner werden immer in ein Minuszeichen konvertiert.
256 // GetTextCharConv() konvertiert zusaetzlich HardSpace und AbsatzEnde
257 // in Spaces sowie HardTrenner in Minuszeichen. TextEnde wird immer
258 // als Char(0) geliefert.
259 // ======================================================================
263 UCHAR
ConvertTextChar(UCHAR c
)
267 case HardSpace
: c
=' '; break;
268 case AbsatzEnd
: c
=' '; break;
269 case SoftTrenn
: c
='-'; break;
270 case HardTrenn
: c
='-'; break;
271 case SoftTrennK
: c
='-'; break;
272 case SoftTrennAdd
: c
='-';
278 long ChgValue(long Def
, long Min
, long Max
, UCHAR FlgVal
, long NumVal
)
282 if (FlgVal
==EscDeflt
) {
283 r
=Def
; // zurueck auf Default
285 if (NumVal
!=EscNoVal
) r
=NumVal
; // Hart setzen
288 if (Min
!=0 || Max
!=0) {
297 void ChgSchnittBit(sal_uInt16 Bit
, sal_uInt16 Radio1
, sal_uInt16 Radio2
, sal_uInt16 Radio3
,
298 UCHAR FlgVal
, sal_uInt16 Schnitt0
, sal_uInt16
& Schnitt
)
302 Rad
=Radio1
| Radio2
| Radio3
;
306 case EscSet
: Schnitt
=(Schnitt
& ~All
) | Bit
; break;
307 case EscReset
: Schnitt
=(Schnitt
& ~All
); break;
308 case EscDeflt
: Schnitt
=(Schnitt
& ~All
) | (Schnitt0
& All
); break;
309 case EscToggl
: Schnitt
=(Schnitt
& ~Rad
) ^ Bit
;
315 UCHAR
GetNextChar(UCHAR
* TBuf
, sal_uInt16 Index
)
318 while (TBuf
[Index
]==Escape
) {
321 while (TBuf
[Index
]!=Escape
&& Cnt
<=MaxEscLen
) {
330 UCHAR
ProcessOne(UCHAR
* TBuf
, sal_uInt16
& Index
,
331 ObjTextType
& Atr0
, ObjTextType
& AktAtr
,
345 c
=TBuf
[Index
]; Index
++;
347 if (Ende
==sal_False
) {
348 c
=TBuf
[Index
]; Index
++;
349 Ident
=c
; // Identifer merken
352 c
=TBuf
[Index
]; Index
++; // Hier faengt der Wert an
353 if (c
==EscSet
|| c
==EscReset
|| c
==EscDeflt
|| c
==EscToggl
) FlgVal
=c
; else {
354 if (c
=='-') Sgn
=-1; else Sgn
=1;
355 if (c
=='+' || c
=='-') { c
=TBuf
[Index
]; Index
++; }
359 NumVal
=10*NumVal
+c
-'0';
360 EoVal
=(TBuf
[Index
]<'0' || TBuf
[Index
]>'9');
361 if (EoVal
==sal_False
) { c
=TBuf
[Index
]; Index
++; }
363 } while (i
>0 && EoVal
==sal_False
);
366 q
=!CheckTextOutl(AktAtr
.F
,AktAtr
.L
);
369 case EscFont
: AktAtr
.SetFont(sal_uLong (ChgValue(Atr0
.GetFont(),0,0 ,FlgVal
,NumVal
)));break;
370 case EscGrad
: AktAtr
.Grad
=sal_uInt16(ChgValue(Atr0
.Grad
, 2,2000 ,FlgVal
,NumVal
)); break;
371 case EscBreit
: AktAtr
.Breite
=sal_uInt16(ChgValue(Atr0
.Breite
, 1,1000 ,FlgVal
,NumVal
)); break;
372 case EscKaptS
: AktAtr
.Kapit
=(sal_uInt8
)(ChgValue(Atr0
.Kapit
, 1,255 ,FlgVal
,NumVal
)); break;
373 case EscLFeed
: AktAtr
.LnFeed
=sal_uInt16(ChgValue(Atr0
.LnFeed
, 1,65535 ,FlgVal
,NumVal
)); break;
374 case EscSlant
: AktAtr
.Slant
=sal_uInt16(ChgValue(Atr0
.Slant
, 1,MaxCharSlant
,FlgVal
,NumVal
)); break;
375 case EscVPos
: AktAtr
.ChrVPos
=char (ChgValue(Atr0
.ChrVPos
,-128,127 ,FlgVal
,NumVal
)); break;
376 case EscZAbst
: AktAtr
.ZAbst
=(sal_uInt8
)(ChgValue(Atr0
.ZAbst
, 1,255 ,FlgVal
,NumVal
)); break;
377 case EscHJust
: AktAtr
.Justify
=(sal_uInt8
)(ChgValue(Atr0
.Justify
& 0x0F,0,5 ,FlgVal
,NumVal
)); break;
378 case EscFarbe
: { AktAtr
.L
.LFarbe
=(sal_uInt8
)(ChgValue(Atr0
.L
.LFarbe
,0,7 ,FlgVal
,NumVal
)); if (q
) AktAtr
.F
.FFarbe
=AktAtr
.L
.LFarbe
; } break;
379 case EscBFarb
: { AktAtr
.L
.LBFarbe
=(sal_uInt8
)(ChgValue(Atr0
.L
.LBFarbe
,0,255,FlgVal
,NumVal
)); if (q
) AktAtr
.F
.FBFarbe
=AktAtr
.L
.LBFarbe
; } break;
380 case EscInts
: { AktAtr
.L
.LIntens
=(sal_uInt8
)(ChgValue(Atr0
.L
.LIntens
,0,100,FlgVal
,NumVal
)); if (q
) AktAtr
.F
.FIntens
=AktAtr
.L
.LIntens
; } break;
382 case EscMustr
: { AktAtr
.F
.FMuster
=sal_uInt16(ChgValue(Atr0
.F
.FMuster
,0,65535,FlgVal
,NumVal
)); } break;
383 case EscMFarb
: { AktAtr
.F
.FFarbe
=(sal_uInt8
)(ChgValue(Atr0
.F
.FFarbe
,0,7 ,FlgVal
,NumVal
)); } break;
384 case EscMBFrb
: { AktAtr
.F
.FBFarbe
=(sal_uInt8
)(ChgValue(Atr0
.F
.FBFarbe
,0,255,FlgVal
,NumVal
)); } break;
385 case EscMInts
: { AktAtr
.F
.FIntens
=(sal_uInt8
)(ChgValue(Atr0
.F
.FIntens
,0,100,FlgVal
,NumVal
)); } break;
387 case EscSMstr
: { AktAtr
.ShdF
.FMuster
=sal_uInt16(ChgValue(Atr0
.ShdF
.FMuster
,0,65535,FlgVal
,NumVal
)); } break;
388 case EscSFarb
: { AktAtr
.ShdL
.LFarbe
=(sal_uInt8
)(ChgValue(Atr0
.ShdL
.LFarbe
,0,7 ,FlgVal
,NumVal
)); AktAtr
.ShdF
.FFarbe
=AktAtr
.ShdL
.LFarbe
; } break;
389 case EscSBFrb
: { AktAtr
.ShdL
.LBFarbe
=(sal_uInt8
)(ChgValue(Atr0
.ShdL
.LBFarbe
,0,255,FlgVal
,NumVal
)); AktAtr
.ShdF
.FBFarbe
=AktAtr
.ShdL
.LBFarbe
; } break;
390 case EscSInts
: { AktAtr
.ShdL
.LIntens
=(sal_uInt8
)(ChgValue(Atr0
.ShdL
.LIntens
,0,100,FlgVal
,NumVal
)); AktAtr
.ShdF
.FIntens
=AktAtr
.ShdL
.LIntens
; } break;
391 case EscSDist
: { AktAtr
.ShdVers
.x
=(short)ChgValue(Atr0
.ShdVers
.x
,0,30000,FlgVal
,NumVal
); AktAtr
.ShdVers
.y
=AktAtr
.ShdVers
.x
; } break;
392 case EscSXDst
: { AktAtr
.ShdVers
.x
=(short)ChgValue(Atr0
.ShdVers
.x
,0,30000,FlgVal
,NumVal
); } break;
393 case EscSYDst
: { AktAtr
.ShdVers
.y
=(short)ChgValue(Atr0
.ShdVers
.y
,0,30000,FlgVal
,NumVal
); } break;
395 case EscBold
: ChgSchnittBit(TextBoldBit
,0,0,0 ,FlgVal
,Atr0
.Schnitt
,AktAtr
.Schnitt
); break;
396 case EscRSlnt
: ChgSchnittBit(TextRSlnBit
,TextLSlnBit
,0,0 ,FlgVal
,Atr0
.Schnitt
,AktAtr
.Schnitt
); break;
397 case EscUndln
: ChgSchnittBit(TextUndlBit
,TextDbUnBit
,0,0 ,FlgVal
,Atr0
.Schnitt
,AktAtr
.Schnitt
); break;
398 case EscStrik
: ChgSchnittBit(TextStrkBit
,TextDbStBit
,0,0 ,FlgVal
,Atr0
.Schnitt
,AktAtr
.Schnitt
); break;
399 case EscDbUnd
: ChgSchnittBit(TextDbUnBit
,TextUndlBit
,0,0 ,FlgVal
,Atr0
.Schnitt
,AktAtr
.Schnitt
); break;
400 case EscDbStk
: ChgSchnittBit(TextDbStBit
,TextStrkBit
,0,0 ,FlgVal
,Atr0
.Schnitt
,AktAtr
.Schnitt
); break;
401 case EscSupSc
: ChgSchnittBit(TextSupSBit
,TextSubSBit
,0,0 ,FlgVal
,Atr0
.Schnitt
,AktAtr
.Schnitt
); break;
402 case EscSubSc
: ChgSchnittBit(TextSubSBit
,TextSupSBit
,0,0 ,FlgVal
,Atr0
.Schnitt
,AktAtr
.Schnitt
); break;
403 case EscKaptF
: ChgSchnittBit(TextKaptBit
,0,0,0 ,FlgVal
,Atr0
.Schnitt
,AktAtr
.Schnitt
); break;
404 case EscLSlnt
: ChgSchnittBit(TextLSlnBit
,TextRSlnBit
,0,0 ,FlgVal
,Atr0
.Schnitt
,AktAtr
.Schnitt
); break;
405 case Esc2DShd
: ChgSchnittBit(TextSh2DBit
,TextSh3DBit
,TextSh4DBit
,TextShEbBit
,FlgVal
,Atr0
.Schnitt
,AktAtr
.Schnitt
); break;
406 case Esc3DShd
: ChgSchnittBit(TextSh3DBit
,TextSh2DBit
,TextSh4DBit
,TextShEbBit
,FlgVal
,Atr0
.Schnitt
,AktAtr
.Schnitt
); break;
407 case Esc4DShd
: ChgSchnittBit(TextSh4DBit
,TextSh2DBit
,TextSh3DBit
,TextShEbBit
,FlgVal
,Atr0
.Schnitt
,AktAtr
.Schnitt
); break;
408 case EscEbShd
: ChgSchnittBit(TextShEbBit
,TextSh2DBit
,TextSh3DBit
,TextSh4DBit
,FlgVal
,Atr0
.Schnitt
,AktAtr
.Schnitt
); break;
410 if (TBuf
[Index
]==Escape
) Index
++; // zweites Esc weglesen }
411 } // if Ende==sal_False
412 } while (Ende
==sal_False
&& ScanEsc
==sal_False
);
413 if (Ende
==sal_False
) c
=Escape
;
415 } // end of ProcessOne
418 UCHAR
GetTextChar(UCHAR
* TBuf
, sal_uInt16
& Index
,
419 ObjTextType
& Atr0
, ObjTextType
& AktAtr
,
420 sal_uInt16 Rest
, sal_Bool ScanEsc
)
424 c
=ProcessOne(TBuf
,Index
,Atr0
,AktAtr
,ScanEsc
);
425 if (ScanEsc
==sal_False
) {
426 if (c
==SoftTrennAdd
|| c
==SoftTrennK
|| c
==SoftTrenn
) {
427 nc
=GetNextChar(TBuf
,Index
);
429 if (Rest
==0 || Rest
==DoTrenn
||
430 nc
==' ' || nc
==AbsatzEnd
|| nc
==TextEnd
) c
='-';
432 c
=ProcessOne(TBuf
,Index
,Atr0
,AktAtr
,ScanEsc
); // den Trenner ueberspringen
433 if (c0
==SoftTrennAdd
) {
434 if (c
>=32) c
=ProcessOne(TBuf
,Index
,Atr0
,AktAtr
,ScanEsc
); // und hier noch 'nen Buchstaben ueberspringen
438 if ((Rest
==1 || Rest
==DoTrenn
) && GetNextChar(TBuf
,Index
)==SoftTrennK
) {
440 else if (c
=='C') c
='K';
446 // HardSpace und HardTrenn muessen explizit konvertiert werden ! }
447 // if AktAtr.Schnitt and TextKaptBit =TextKaptBit then c:=UpCase(c);(explizit) }
449 // Bei der Trennmethode SoftTrennAdd wird davon ausgegangen, dass der zu }
450 // trennende Konsonant bereits 3x mal im TextBuf vorhanden ist, z.b.: }
451 // "Schiff-fahrt". Wenn nicht getrennt, dann wird "-f" entfernt. }
455 UCHAR
GetTextCharConv(UCHAR
* TBuf
, sal_uInt16
& Index
,
456 ObjTextType
& Atr0
, ObjTextType
& AktAtr
,
457 sal_uInt16 Rest
, sal_Bool ScanEsc
)
461 c
=GetTextChar(TBuf
,Index
,Atr0
,AktAtr
,Rest
,ScanEsc
);
464 case HardSpace
: c
=' '; break;
465 case AbsatzEnd
: c
=' '; break;
466 case HardTrenn
: c
='-';
473 // ======================================================================
474 // Function GetLineFeed()
476 // Benoetigter Zeilenabstand in SGF-Units. ChrVPos wird beruecksichtigt.
477 // ======================================================================
478 sal_uInt16
GetLineFeed(UCHAR
* TBuf
, sal_uInt16 Index
, ObjTextType Atr0
, ObjTextType AktAtr
,
479 sal_uInt16 nChar
, sal_uInt16
& LF
, sal_uInt16
& MaxGrad
)
482 sal_Bool AbsEnd
=sal_False
;
484 sal_uLong MaxLF100
=0;
486 sal_Bool First
=sal_True
;
492 while (!AbsEnd
&& nChar
>0) {
494 c
=GetTextChar(TBuf
,Index
,Atr0
,AktAtr
,nChar
,sal_False
);
496 AbsEnd
=(c
==TextEnd
|| c
==AbsatzEnd
);
497 if (First
|| (!AbsEnd
&& c
!=' ' && c
!=HardTrenn
)) {
498 LFauto
=(AktAtr
.LnFeed
& 0x8000)==0;
499 LF100
=AktAtr
.LnFeed
& 0x7FFF;
500 if (LFauto
) LF100
=LF100
*AktAtr
.Grad
; else LF100
*=LF100
;
501 if (AktAtr
.ChrVPos
>0) LF100
-=AktAtr
.ChrVPos
*100;
502 if (LF100
>MaxLF100
) MaxLF100
=LF100
;
504 if (AktAtr
.ChrVPos
>0) Grad
=Grad
-AktAtr
.ChrVPos
;
505 if (Grad
>MaxGrad
) MaxGrad
=Grad
;
508 if (!AbsEnd
&& c
!=' ') r
=i
;
510 MaxGrad
=hPoint2Sgf(MaxGrad
);
511 if (MaxLF100
<=4000) { // sonst Overflowgefahr
512 LF
=sal_uInt16(hPoint2Sgf(short(MaxLF100
)) /100);
514 LF
=sal_uInt16(hPoint2Sgf(short(MaxLF100
) /100));
520 // End of AbsRead.Pas
521 /////////////////////////////////////////////////////////////////////////////////
522 /////////////////////////////////////////////////////////////////////////////////
523 /////////////////////////////////////////////////////////////////////////////////
527 /////////////////////////////////////////////////////////////////////////////////
528 /////////////////////////////////////////////////////////////////////////////////
529 /////////////////////////////////////////////////////////////////////////////////
532 #define DefaultSlant 1500 /* Default: Italic ist 15deg */
533 #define SuperSubFact 60 /* SuperScript/SubScript: 60% vom Schriftgrad */
534 #define DefaultSpace 40 /* Default: Space ist 40% vom SchriftGrad */
536 sal_uInt16
SetTextContext(OutputDevice
& rOut
, ObjTextType
& Atr
, sal_Bool Kapt
, sal_uInt16 Dreh
,
537 sal_uInt16 FitXMul
, sal_uInt16 FitXDiv
, sal_uInt16 FitYMul
, sal_uInt16 FitYDiv
)
539 SgfFontOne
* pSgfFont
; // Font aus dem IniFile
545 sal_uInt16 StdBrei
=50; // Durchschnittliche Zeichenbreite in % von Schriftgrad
546 sal_Bool bFit
=(FitXMul
!=1 || FitXDiv
!=1 || FitYMul
!=1 || FitYDiv
!=1);
548 pSgfFont
= pSgfFonts
->GetFontDesc(Atr
.GetFont());
550 if ( pSgfFont
!=NULL
)
552 FNam
=pSgfFont
->SVFName
;
553 StdBrei
=pSgfFont
->SVWidth
;
554 if (pSgfFont
->Fixd
) aFont
.SetPitch(PITCH_FIXED
); else aFont
.SetPitch(PITCH_VARIABLE
);
555 aFont
.SetFamily(pSgfFont
->SVFamil
);
556 aFont
.SetCharSet(pSgfFont
->SVChSet
);
560 { // Falls nich im Inifile, sind hier einige Fonts hart kodiert
561 aFont
.SetPitch(PITCH_VARIABLE
);
562 switch (Atr
.GetFont()) {
563 case 92500: case 92501: case 92504: case 92505:
566 FNam
=rtl::OUString("Times New Roman"); // CG Times ist unter Windows Times New Roman
568 FNam
=rtl::OUString("Times"); // ansonsten ist das einfach Times
571 aFont
.SetFamily(FAMILY_ROMAN
);
573 case 94021: case 94022: case 94023: case 94024: {
575 FNam
=rtl::OUString("Arial"); // Univers ist unter Windows Arial
577 FNam
=rtl::OUString("Helvetica"); // und ansonsten Helvetica
579 aFont
.SetFamily(FAMILY_SWISS
);
582 case 93950: case 93951: case 93952: case 93953: {
584 FNam
=rtl::OUString("Courier New"); // Der Vector-Courierfont unter Windows heisst Courier New
586 FNam
=rtl::OUString("Courier"); // ansonsten ist und bleibt Courier immer Courier
588 aFont
.SetFamily(FAMILY_ROMAN
);
589 aFont
.SetPitch(PITCH_FIXED
);
591 default: FNam
= rtl::OUString("Helvetica");
594 //aFont.SetCharSet(CHARSET_SYSTEM);
597 Grad
=sal_uLong(Atr
.Grad
);
598 if ((Atr
.Schnitt
& TextKaptBit
) !=0 && Kapt
) Grad
=Grad
*sal_uLong(Atr
.Kapit
)/100;
599 if ((Atr
.Schnitt
& TextSupSBit
) !=0 || (Atr
.Schnitt
& TextSubSBit
) !=0) Grad
=Grad
*SuperSubFact
/100;
601 if (Atr
.Breite
!=100 || bFit
) {
603 Grad
=Grad
*sal_uLong(FitYMul
)/sal_uLong(FitYDiv
);
604 Brei
=Brei
*sal_uLong(FitXMul
)/sal_uLong(FitXDiv
);
606 Brei
=Brei
*sal_uLong(Atr
.Breite
)/100;
607 Brei
=Brei
*sal_uLong(StdBrei
)/100;
608 aFont
.SetSize(Size(hPoint2Sgf(sal_uInt16(Brei
)),hPoint2Sgf(sal_uInt16(Grad
))));
610 aFont
.SetSize(Size(0,hPoint2Sgf(sal_uInt16(Grad
))));
613 aColor
=Sgv2SvFarbe(Atr
.L
.LFarbe
,Atr
.L
.LBFarbe
,Atr
.L
.LIntens
); aFont
.SetColor(aColor
);
614 aColor
=Sgv2SvFarbe(Atr
.F
.FFarbe
,Atr
.F
.FBFarbe
,Atr
.F
.FIntens
); aFont
.SetFillColor(aColor
);
615 aFont
.SetTransparent(sal_True
);
616 aFont
.SetAlign(ALIGN_BASELINE
);
618 Dreh
/=10; Dreh
=3600-Dreh
; if (Dreh
==3600) Dreh
=0;
619 aFont
.SetOrientation(Dreh
);
621 if ((Atr
.Schnitt
& TextBoldBit
) !=0) aFont
.SetWeight(WEIGHT_BOLD
);
622 if ((Atr
.Schnitt
& TextRSlnBit
) !=0) aFont
.SetItalic(ITALIC_NORMAL
);
623 if ((Atr
.Schnitt
& TextUndlBit
) !=0) aFont
.SetUnderline(UNDERLINE_SINGLE
);
624 if ((Atr
.Schnitt
& TextDbUnBit
) !=0) aFont
.SetUnderline(UNDERLINE_DOUBLE
);
625 if ((Atr
.Schnitt
& TextStrkBit
) !=0) aFont
.SetStrikeout(STRIKEOUT_SINGLE
);
626 if ((Atr
.Schnitt
& TextDbStBit
) !=0) aFont
.SetStrikeout(STRIKEOUT_DOUBLE
);
627 if ((Atr
.Schnitt
& TextSh2DBit
) !=0) aFont
.SetShadow(sal_True
);
628 if ((Atr
.Schnitt
& TextSh3DBit
) !=0) aFont
.SetShadow(sal_True
);
629 if ((Atr
.Schnitt
& TextSh4DBit
) !=0) aFont
.SetShadow(sal_True
);
630 if ((Atr
.Schnitt
& TextShEbBit
) !=0) aFont
.SetShadow(sal_True
);
631 if (CheckTextOutl(Atr
.F
,Atr
.L
)) aFont
.SetOutline(sal_True
);
633 if (aFont
!=rOut
.GetFont()) rOut
.SetFont(aFont
);
639 /////////////////////////////////////////////////////////////////////////////////
640 /////////////////////////////////////////////////////////////////////////////////
641 /////////////////////////////////////////////////////////////////////////////////
644 /////////////////////////////////////////////////////////////////////////////////
645 /////////////////////////////////////////////////////////////////////////////////
646 /////////////////////////////////////////////////////////////////////////////////
657 void InitProcessCharState(ProcChrSta
& State
, ObjTextType
& AktAtr
, sal_uInt16 IndexA
)
663 State
.Kapt
=sal_False
;
666 sal_Bool
UpcasePossible(UCHAR c
)
668 if ((c
>='a' && c
<='z') || c
== 0xe4 || c
== 0xf6 || c
== 0xfc ) return sal_True
;
669 else return sal_False
;
672 UCHAR
Upcase(UCHAR c
)
674 if ((c
>=(UCHAR
)'a' && c
<=(UCHAR
)'z')) c
=(c
-(UCHAR
)'a')+(UCHAR
)'A';
675 else if ( c
== 0xe4 ) c
= 0xc4;
676 else if ( c
== 0xf6 ) c
= 0xd6;
677 else if ( c
== 0xfc ) c
= 0xdc;
681 sal_uInt16
GetCharWidth(OutputDevice
& rOut
, UCHAR c
)
687 ChrWidth
=(sal_uInt16
)rOut
.GetTextWidth( rtl::OUString('A') );
688 if (rOut
.GetFont().GetPitch()!=PITCH_FIXED
) {
689 ChrWidth
=MulDiv(ChrWidth
,DefaultSpace
,100);
694 // with MaxChar == 255 c cannot be greater than MaxChar
695 // assert if MaxChar is ever changed
696 OSL_ENSURE( MaxChar
== 255, "MaxChar not 255" );
697 OSL_ENSURE(sizeof(UCHAR
) == 1, "should be 1");
698 if (c
>=MinChar
/*&& c<=MaxChar*/)
700 ChrWidth
=(sal_uInt16
)rOut
.GetTextWidth(rtl::OUString(reinterpret_cast<sal_Char
*>(&c
), 1, RTL_TEXTENCODING_IBM_437
));
704 ChrWidth
=(sal_uInt16
)rOut
.GetTextWidth(rtl::OUString(static_cast<sal_Unicode
>('A')));
710 UCHAR
ProcessChar(OutputDevice
& rOut
, UCHAR
* TBuf
, ProcChrSta
& R
, ObjTextType
& Atr0
,
711 sal_uInt16
& nChars
, sal_uInt16 Rest
,
712 short* Line
, UCHAR
* cLine
)
714 sal_uInt16 KernDist
=0; // Wert fuer Kerning
720 c
=GetTextChar(TBuf
,R
.Index
,Atr0
,R
.Attrib
,Rest
,sal_False
); // versucht evtl. zu trennen, wenn Rest entsprechenden Wert besitzt
722 AbsEnd
=(c
==AbsatzEnd
|| c
==TextEnd
);
723 if (AbsEnd
==sal_False
) {
724 R
.OutCh
=ConvertTextChar(c
); // von HardTrenn nach '-', ...
725 R
.Kapt
=(R
.Attrib
.Schnitt
& TextKaptBit
) !=0 && UpcasePossible(R
.OutCh
);
726 if (R
.Kapt
) R
.OutCh
=Upcase(R
.OutCh
);
727 SetTextContext(rOut
,R
.Attrib
,R
.Kapt
,0,1,1,1,1);
729 if (R
.Kapt
) c1
=Upcase(c
); else c1
=c
;
730 ChrWidth
=GetCharWidth(rOut
,c1
);
732 if (R
.Attrib
.ZAbst
!=100) { // Spezial-Zeichenabstand ?
734 Temp
=sal_uLong(ChrWidth
)*sal_uLong(R
.Attrib
.ZAbst
)/100;
735 ChrWidth
=sal_uInt16(Temp
);
738 if (R
.ChrXP
>32000) R
.ChrXP
=32000;
739 Line
[nChars
]=R
.ChrXP
-KernDist
;
741 R
.ChrXP
+=ChrWidth
-KernDist
; // Position fuer den naechsten Character
746 void FormatLine(UCHAR
* TBuf
, sal_uInt16
& Index
, ObjTextType
& Atr0
, ObjTextType
& AktAtr
,
747 sal_uInt16 UmbWdt
, sal_uInt16 AdjWdt
,
748 short* Line
, sal_uInt16
& nChars
,
750 UCHAR
* cLine
, sal_Bool TextFit
)
755 sal_Bool First
; // erster Char ?
756 sal_uInt8 Just
= 0; // Absatzformatierung
757 sal_Bool Border
; // Rand der Box erreicht ?
759 sal_Bool AbsEnd
; // Ende des Absatzes erreicht ?
760 ProcChrSta
* R
=new ProcChrSta
;
761 ProcChrSta
* R0
=new ProcChrSta
;
762 ProcChrSta
* WErec
=new ProcChrSta
;
764 ProcChrSta
* WErec0
=new ProcChrSta
;
766 ProcChrSta
* TRrec
=new ProcChrSta
;
769 sal_uInt16 WordEndCnt
; // Justieren und Trennen
773 short BoxRest
; // zum Quetschen und formatieren
777 vOut
.SetMapMode(MapMode(MAP_10TH_MM
,Point(),Fraction(1,4),Fraction(1,4)));
780 SetTextContext(vOut
,AktAtr
,sal_False
,0,1,1,1,1);
781 InitProcessCharState(*R
,AktAtr
,Index
);
782 (*R0
)=(*R
); (*WErec
)=(*R
); WEnChar
=0; c0
=0; Border0
=sal_False
;
783 Border
=sal_False
; First
=sal_True
;
786 do { // mal schauen, wieviele Worte so in die Zeile passen
787 if (Border
) c
=ProcessChar(vOut
,TBuf
,*R
,Atr0
,nChars
,DoTrenn
,Line
,cLine
);
788 else c
=ProcessChar(vOut
,TBuf
,*R
,Atr0
,nChars
,NoTrenn
,Line
,cLine
);
789 AbsEnd
=(c
==AbsatzEnd
|| c
==TextEnd
);
793 Just
=R
->Attrib
.Justify
& 0x0F; // Absatzformat steht wenn, dann am Anfang
795 Border
=R
->ChrXP
>UmbWdt
;
796 WordEnd
=(AbsEnd
|| (c
==' ')) && (c0
!=' ') && (c0
!=0);
798 if (WordEnd
&& !Border0
) {
803 if (Trenn
&& !Border
) {
812 AbsEnd
=AbsEnd
|| (nChars
>=MaxLineChars
);
813 } while (!(AbsEnd
|| (Border
&& ((WordEndCnt
>0) || WordEnd
|| Trenn
))));
815 if (Border
) { // Trennen und Quetschen
816 (*WErec0
)=(*WErec
); WEnChar0
=WEnChar
;
817 AbsEnd
=sal_False
; c0
=0;
818 (*R
)=(*WErec
); nChars
=WEnChar
;
819 (*TRrec
)=(*R
); TRnChar
=nChars
;
820 Border0
=sal_False
; Border
=sal_False
;
821 do { // erst mal gucken wieviele Silben noch reinpassen
822 ct
=ProcessChar(vOut
,TBuf
,*TRrec
,Atr0
,TRnChar
,DoTrenn
,Line
,cLine
);
823 c
=ProcessChar(vOut
,TBuf
,*R
,Atr0
,nChars
,NoTrenn
,Line
,cLine
);
824 AbsEnd
=(ct
==AbsatzEnd
) || (ct
==TextEnd
) || (nChars
>=MaxLineChars
);
826 Border
=TRrec
->ChrXP
>UmbWdt
;
827 WordEnd
=AbsEnd
|| ((AbsEnd
|| (c
==' ')) && (c0
!=' ') && (c0
!=0));
829 if (WordEnd
&& (!Border0
|| (WordEndCnt
==0))) {
832 if (AbsEnd
) WEnChar
=nChars
; else WEnChar
=nChars
-1;
833 (*TRrec
)=(*R
); TRnChar
=nChars
; // zum weitersuchen
835 if (Trenn
&& (!Border
|| (WordEndCnt
==0))) {
836 WordEndCnt
++; // merken, dass man hier trennen kann
839 (*TRrec
)=(*R
); TRnChar
=nChars
; // zum weitersuchen
843 Border
=R
->ChrXP
>UmbWdt
;
844 } while (!(AbsEnd
|| (Border
&& ((WordEndCnt
>0) || WordEnd
|| Trenn
))));
846 while (WErec0
->Index
<WErec
->Index
) { // damit Line[] auch garantiert stimmt }
847 c
=ProcessChar(vOut
,TBuf
,*WErec0
,Atr0
,WEnChar0
,WEnChar
-WEnChar0
-1,Line
,cLine
);
850 (*R
)=(*WErec
); nChars
=WEnChar
;
852 if (UmbWdt
>=R
->ChrXP
) {
853 BoxRest
=UmbWdt
-R
->ChrXP
;
854 } else { // Zusammenquetschen
855 BoxRest
=R
->ChrXP
-UmbWdt
; // um soviel muss gequetscht werden
856 for (i
=2;i
<=nChars
;i
++) { // 1. CharPosition bleibt !
857 Line
[i
]-=(i
-1)*(BoxRest
) /(nChars
-1);
860 Line
[nChars
+1]=UmbWdt
;
865 do { // Leerzeichen weglesen
867 c
=GetTextChar(TBuf
,R
->Index
,Atr0
,R
->Attrib
,NoTrenn
,sal_False
);
869 Line
[nChars
]=R
->ChrXP
;
872 if (c
!=' ' && c
!=AbsatzEnd
&& c
!=TextEnd
) {
878 if (AbsEnd
&& nChars
<MaxLineChars
) { // Ausrichten, statt Blocksatz aber linksbuendig
880 nChars
++; Line
[nChars
]=R
->ChrXP
; // Damit AbsatzEnde auch weggelesen wird
881 Line
[nChars
+1]=R
->ChrXP
; // denn die Breite von CR oder #0 ist nun mal sehr klein
882 if (TBuf
[R
->Index
-1]!=AbsatzEnd
&& TBuf
[R
->Index
-1]!=TextEnd
) {
883 c
=GetTextChar(TBuf
,R
->Index
,Atr0
,R
->Attrib
,NoTrenn
,sal_False
); // Kleine Korrektur. Notig, wenn nur 1 Wort in
887 BoxRest
=AdjWdt
-R
->ChrXP
;
888 if (TextFit
) Just
=THJustLeft
;
891 case THJustLeft
: break; // Links
893 BoxRest
=BoxRest
/2; // Mitte
894 for (i
=1;i
<=nChars
;i
++) Line
[i
]=Line
[i
]+BoxRest
;
896 case THJustRight
: { // Rechts
897 for (i
=1;i
<=nChars
;i
++) Line
[i
]=Line
[i
]+BoxRest
;
900 case THJustBlock
: { // Block und Austreibend
902 if (Just
==THJustDrvOut
) re
--;
903 while (re
>=1 && (cLine
[re
]==' ' || cLine
[re
]==TextEnd
|| cLine
[re
]==AbsatzEnd
)) re
--;
905 while (li
<=re
&& (cLine
[li
]==' ' || cLine
[li
]==TextEnd
|| cLine
[li
]==AbsatzEnd
)) li
++;
906 if (Just
==THJustDrvOut
) BoxRest
=AdjWdt
-Line
[re
+1];
908 j
=0; // Anzahl der Spaces ermitteln
909 for (i
=li
;i
<=re
;i
++) {
915 if (j
==0) { // nur 1 Wort ? -> Strecken !
916 for (i
=li
+1;i
<=re
;i
++) { // von links nach rechts
917 Line
[i
]=Line
[i
]+MulDiv(i
-li
,BoxRest
,re
-li
+1-1);
921 for (i
=li
;i
<=re
;i
++) { // j Spaces aufbohren !
922 if (cLine
[i
]==' ') { // Space gefunden !
924 h
=MulDiv(k
,BoxRest
,j
);
929 for (i
=re
+1;i
<=nChars
;i
++) Line
[i
]=Line
[i
]+BoxRest
; // und den Rest anpassen
930 Line
[nChars
+1]=AdjWdt
;
932 case THJustLocked
: { //Gesperrt
934 while (re
>=1 && (cLine
[re
]==' ' || cLine
[re
]==TextEnd
|| cLine
[re
]==AbsatzEnd
)) re
--;
936 while (li
<=re
&& (cLine
[li
]==' ' || cLine
[li
]==TextEnd
|| cLine
[li
]==AbsatzEnd
)) li
++;
937 BoxRest
=AdjWdt
-Line
[re
+1];
938 for (i
=li
+1;i
<=re
;i
++) { // Strecken von links nach rechts
939 Line
[i
]=Line
[i
]+MulDiv(i
-li
,BoxRest
,re
-li
+1-1);
941 for (i
=re
+1;i
<=nChars
;i
++) Line
[i
]=Line
[i
]+BoxRest
; // und den Rest anpassen
942 Line
[nChars
+1]=AdjWdt
;
957 /////////////////////////////////////////////////////////////////////////////////
958 /////////////////////////////////////////////////////////////////////////////////
959 /////////////////////////////////////////////////////////////////////////////////
962 /////////////////////////////////////////////////////////////////////////////////
963 /////////////////////////////////////////////////////////////////////////////////
964 /////////////////////////////////////////////////////////////////////////////////
967 void DrawChar(OutputDevice
& rOut
, UCHAR c
, ObjTextType T
, PointType Pos
, sal_uInt16 DrehWink
,
968 sal_uInt16 FitXMul
, sal_uInt16 FitXDiv
, sal_uInt16 FitYMul
, sal_uInt16 FitYDiv
)
970 SetTextContext(rOut
,T
,UpcasePossible(c
),DrehWink
,FitXMul
,FitXDiv
,FitYMul
,FitYDiv
);
971 if ((T
.Schnitt
& TextKaptBit
)!=0 && UpcasePossible(c
)) c
=Upcase(c
);
972 rtl::OUString
s(reinterpret_cast<const sal_Char
*>(&c
), 1,
973 RTL_TEXTENCODING_IBM_437
);
974 rOut
.DrawText( Point( Pos
.x
, Pos
.y
), s
);
977 /*************************************************************************
981 *************************************************************************/
982 void TextType::Draw(OutputDevice
& rOut
)
984 if ((Flags
& TextOutlBit
)!=0) return; // Sourcetext fuer Outliner !!
990 sal_uInt16 l
; // Anzahl der Zeichen in der Zeile
1001 sal_uInt16 TopToBase
;
1004 sal_Bool LineFit
; // FitSize.x=0? oder Flags -> jede Zeile stretchen
1007 UCHAR
* cLine
; // Buffer fuer FormatLine
1013 UCHAR
* Buf
=Buffer
; // Zeiger auf die Buchstaben
1015 pSgfFonts
->ReadList();
1016 xLine
=new short[ChrXPosArrSize
];
1017 cLine
=new UCHAR
[CharLineSize
];
1019 TextFit
=(Flags
& TextFitBits
)!=0;
1021 LineFit
=((Flags
& TextFitZBit
)!=0);
1022 if (TextFit
&& FitSize
.x
==0) LineFit
=sal_True
;
1028 sn
=sin(double(DrehWink
)*3.14159265359/18000);
1029 cs
=cos(double(DrehWink
)*3.14159265359/18000);
1032 T1
=T
; Index1
=0; yPos
=0; xPos
=0;
1034 ySize
=Pos2
.y
-Pos1
.y
;
1035 xSize
=32000 /2; // Umbruch
1036 xSAdj
=Pos2
.x
-Pos1
.x
; // zum Ausrichten bei Zentriert/Blocksatz
1037 //if (xSize<=0) { xSize=32000 /2; LineFit=sal_True; }
1038 FitXMul
=sal::static_int_cast
< sal_uInt16
>(abs(Pos2
.x
-Pos1
.x
)); FitXDiv
=FitSize
.x
; if (FitXDiv
==0) FitXDiv
=1;
1039 FitYMul
=sal::static_int_cast
< sal_uInt16
>(abs(Pos2
.y
-Pos1
.y
)); FitYDiv
=FitSize
.y
; if (FitYDiv
==0) FitYDiv
=1;
1041 xSize
=Pos2
.x
-Pos1
.x
;
1043 ySize
=Pos2
.y
-Pos1
.y
;
1044 FitXMul
=1; FitXDiv
=1;
1045 FitYMul
=1; FitYDiv
=1;
1047 if (xSize
<0) xSize
=0;
1048 if (xSAdj
<0) xSAdj
=0;
1051 T2
=T1
; Index2
=Index1
;
1052 FormatLine(Buf
,Index2
,T
,T2
,xSize
,xSAdj
,xLine
,l
,sn
,cs
,cLine
,LineFit
);
1053 Fehler
=(Index2
==Index1
);
1055 lc
=GetLineFeed(Buf
,Index1
,T
,T1
,l
,LF
,MaxGrad
);
1057 if (LineFit
) FitXDiv
=xLine
[lc
+1];
1060 for (i
=1;i
<=l
+1;i
++) {
1061 Temp
=long(xLine
[i
])*long(FitXMul
) /long(FitXDiv
);
1062 xLine
[i
]=short(Temp
);
1064 LF
=MulDiv(LF
,FitYMul
,FitYDiv
);
1065 MaxGrad
=MulDiv(MaxGrad
,FitYMul
,FitYDiv
);
1067 FitXDiv
=1; // 0 gibts nicht
1071 TopToBase
=GetTopToBaseLine(MaxGrad
);
1072 yPos
=yPos
+TopToBase
;
1073 Ende
=(yPos0
+short(MulDiv(MaxGrad
,CharTopToBtm
,100))>ySize
) && !TextFit
;
1075 T2
=T1
; Index2
=Index1
;
1078 c
=GetTextCharConv(Buf
,Index2
,T
,T2
,l
-i
,sal_False
);
1079 long xp1
,yp1
; // wegen Overflowgefahr
1081 xp1
=long(Pos1
.x
)+xPos
+long(xLine
[i
]);
1082 yp1
=long(Pos1
.y
)+yPos
;
1083 if (xp1
>32000) xp1
=32000; if (xp1
<-12000) xp1
=-12000;
1084 if (yp1
>32000) yp1
=32000; if (yp1
<-12000) yp1
=-12000;
1088 if (DrehWink
!=0) RotatePoint(Pos
,Pos1
.x
,Pos1
.y
,sn
,cs
);
1089 DrawChar(rOut
,c
,T2
,Pos
,DrehWink
,FitXMul
,FitXDiv
,FitYMul
,FitYDiv
);
1093 T1
=T2
; Index1
=Index2
; // Fuer die naechste Zeile
1094 } // if ObjMin.y+yPos<=Obj_Max.y
1096 } while (c
!=TextEnd
&& !Ende
&& !Fehler
);
1101 // End of DrawText.Pas
1102 /////////////////////////////////////////////////////////////////////////////////
1103 /////////////////////////////////////////////////////////////////////////////////
1104 /////////////////////////////////////////////////////////////////////////////////
1106 // nicht mehr benoetigt, da der Pointer nun extra gefuehrt wird
1107 // (DEC Alpha hat naemlich 64Bit-Pointer!)
1108 //UCHAR* TextType::GetBufPtr()
1111 // Temp=sal_uLong(BufLo)+0x00010000*sal_uLong(BufHi);
1112 // return (UCHAR*)Temp;
1115 //void TextType::SetBufPtr(UCHAR* Ptr)
1117 // sal_uLong Temp=(sal_uLong)Ptr;
1118 // BufLo=sal_uInt16(Temp & 0x0000FFFF);
1119 // BufHi=sal_uInt16((Temp & 0xFFFF0000)>>16);
1122 sal_uInt32
ObjTextType::GetFont()
1124 return sal_uLong(FontLo
)+0x00010000*sal_uLong(FontHi
);
1127 void ObjTextType::SetFont(sal_uInt32 FontID
)
1129 FontLo
=sal_uInt16(FontID
& 0x0000FFFF);
1130 FontHi
=sal_uInt16((FontID
& 0xFFFF0000)>>16);
1134 /////////////////////////////////////////////////////////////////////////////////
1135 // SGF.Ini lesen ////////////////////////////////////////////////////////////////
1136 /////////////////////////////////////////////////////////////////////////////////
1137 SgfFontOne::SgfFontOne()
1146 SVFamil
=FAMILY_DONTKNOW
;
1147 SVChSet
=RTL_TEXTENCODING_DONTKNOW
;
1151 void SgfFontOne::ReadOne( const rtl::OString
& rID
, rtl::OString
& Dsc
)
1153 if ( Dsc
.getLength() < 4 || ( Dsc
[0] != '(' ) )
1155 sal_Int32 i
=1; // Erster Buchstabe des IF-Fontnamen. Davor ist eine '('
1156 while ( i
< Dsc
.getLength() && ( Dsc
[i
] !=')' ) )
1158 Dsc
= Dsc
.copy(i
+1); // IF-Fontname loeschen inkl. ()
1160 if ( Dsc
.getLength() < 2 || ( Dsc
[Dsc
.getLength() - 1] !=')' ) )
1162 i
=Dsc
.getLength()-2; // hier ist die ')' des SV-Fontnames
1164 while ( i
> 0 && ( Dsc
[i
] != '(' ) )
1169 SVFName
= rtl::OStringToOUString(Dsc
.copy(i
+1,j
), RTL_TEXTENCODING_IBM_437
); // SV-Fontname rausholen
1170 Dsc
= rtl::OStringBuffer(Dsc
).remove(i
,j
).makeStringAndClear();
1172 IFID
= (sal_uInt32
)rID
.toInt32();
1173 sal_Int32 nTokenCount
= comphelper::string::getTokenCount(Dsc
, ' ');
1174 for (sal_Int32 nIdx
= 0; nIdx
< nTokenCount
; ++nIdx
)
1176 rtl::OString
s(Dsc
.getToken(nIdx
, ' '));
1179 s
= s
.toAsciiUpperCase();
1180 if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("BOLD"))) Bold
=sal_True
;
1181 else if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("ITAL"))) Ital
=sal_True
;
1182 else if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("SERF"))) Serf
=sal_True
;
1183 else if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("SANS"))) Sans
=sal_True
;
1184 else if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("FIXD"))) Fixd
=sal_True
;
1185 else if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("ROMAN"))) SVFamil
=FAMILY_ROMAN
;
1186 else if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("SWISS"))) SVFamil
=FAMILY_SWISS
;
1187 else if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("MODERN"))) SVFamil
=FAMILY_MODERN
;
1188 else if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("SCRIPT"))) SVFamil
=FAMILY_SCRIPT
;
1189 else if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("DECORA"))) SVFamil
=FAMILY_DECORATIVE
;
1190 else if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("ANSI"))) SVChSet
=RTL_TEXTENCODING_MS_1252
;
1191 else if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("IBMPC"))) SVChSet
=RTL_TEXTENCODING_IBM_850
;
1192 else if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("MAC"))) SVChSet
=RTL_TEXTENCODING_APPLE_ROMAN
;
1193 else if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("SYMBOL"))) SVChSet
=RTL_TEXTENCODING_SYMBOL
;
1194 else if (s
.matchL(RTL_CONSTASCII_STRINGPARAM("SYSTEM"))) SVChSet
= osl_getThreadTextEncoding();
1195 else if (comphelper::string::isdigitAsciiString(s
) ) SVWidth
=sal::static_int_cast
< sal_uInt16
>(s
.toInt32());
1200 /////////////////////////////////////////////////////////////////////////////////
1202 SgfFontLst::SgfFontLst()
1211 SgfFontLst::~SgfFontLst()
1216 void SgfFontLst::RausList()
1233 void SgfFontLst::AssignFN(const String
& rFName
)
1236 void SgfFontLst::ReadList()
1245 aCfg
.SetGroup("SGV Fonts fuer StarView");
1246 sal_uInt16 Anz
=aCfg
.GetKeyCount();
1253 FID
= comphelper::string::remove(aCfg
.GetKeyName(i
), ' ');
1254 Dsc
= aCfg
.ReadKey( i
);
1255 if (comphelper::string::isdigitAsciiString(FID
))
1257 P
=new SgfFontOne
; // neuer Eintrag
1258 if (Last
!=NULL
) Last
->Next
=P
; else pList
=P
; Last
=P
; // einklinken
1259 P
->ReadOne(FID
,Dsc
); // und Zeile interpretieren
1265 SgfFontOne
* SgfFontLst::GetFontDesc(sal_uInt32 ID
)
1270 while (P
!=NULL
&& P
->IFID
!=ID
) P
=P
->Next
;
1277 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */