LCOV - code coverage report
Current view: top level - svtools/source/filter - sgvtext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 21 588 3.6 %
Date: 2012-08-25 Functions: 4 30 13.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 852 0.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <rtl/math.h>
      31                 :            : #include <comphelper/string.hxx>
      32                 :            : #include <tools/config.hxx>
      33                 :            : #include <svtools/filter.hxx>
      34                 :            : #include "sgffilt.hxx"
      35                 :            : #include "sgfbram.hxx"
      36                 :            : #include "sgvmain.hxx"
      37                 :            : 
      38                 :            : extern SgfFontLst* pSgfFonts;
      39                 :            : 
      40                 :            : #ifndef abs
      41                 :            : #define abs(x) ((x)<0 ? -(x) : (x))
      42                 :            : #endif
      43                 :            : 
      44                 :            : 
      45                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
      46                 :            : //
      47                 :            : //  Einschraenkungen: Schatten nur grau, 2D und mit fixem Abstand.
      48                 :            : //
      49                 :            : //
      50                 :            : //
      51                 :            : //
      52                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
      53                 :            : 
      54                 :            : /////////////////////////////////////////////////////////////////////////////////
      55                 :            : /////////////////////////////////////////////////////////////////////////////////
      56                 :            : /////////////////////////////////////////////////////////////////////////////////
      57                 :            : // AbsBase.Pas
      58                 :            : 
      59                 :            : // die folgenden Werte sind in % vom maximalen Schriftgrad der Zeile   */
      60                 :            : #define  UndlSpace  5 /* Untersteichungsabstand von der Baseline       */
      61                 :            : #define  UndlWidth  6 /* Untersteichungsdicke                          */
      62                 :            : #define  UndlSpac2  7 /* Zwischenraum bei doppelter Unterstreichung    */
      63                 :            : #define  StrkSpace 25 /* Abstand der Durchstreichlinie von der Baseline*/
      64                 :            : #define  StrkWidth  5 /* Durchstreichungsliniendicke                   */
      65                 :            : #define  StrkSpac2  7 /* Zwischenraum bei doppelter Durchstreichung    */
      66                 :            : #define  OutlWidth  2 /* Strichstaerke ist 2% vom Schriftgrad          */
      67                 :            : 
      68                 :            : // vvv Sonderzeichen im TextBuffer vvv
      69                 :            : #define  TextEnd        0 /* ^@ Ende der Zeichenkette                           */
      70                 :            : #define  HardSpace      6 /* ^F Hartspace (wird nicht umbrochen) ,' '           */
      71                 :            : #define  GrafText       7 /* ^G Im Text eingebundene Grafik (future)            */
      72                 :            : #define  Tabulator      9 /* ^I Tabulatorzeichen, Pfeil                         */
      73                 :            : #define  LineFeed      10 /* ^J Neue Zeile                                      */
      74                 :            : #define  SoftTrennK    11 /* ^K Zeichen fuer k-c-Austausch bei Trennung, 'k'    */
      75                 :            : #define  AbsatzEnd     13 /* ^M Neuer Absatz =CR                                */
      76                 :            : #define  HardTrenn     16 /* ^P Hartes Trennzeichen (wird nicht umbrochen), '-' */
      77                 :            : #define  SoftTrennAdd  19 /* ^S Zusatz-Zeichen Trennung von z.b."Schiff-fahrt"  */
      78                 :            : #define  Paragraf      21 /* ^U Zeichen welches fuer Paragraf-Zeichen           */
      79                 :            : #define  Escape        27 /* ^[ Escapesequenz einleiten                         */
      80                 :            : #define  SoftTrenn     31 /* ^_ Weiches Trennzeichen, '-' nur Zeilenende        */
      81                 :            : #define  MaxEscValLen  8
      82                 :            : #define  MaxEscLen     (MaxEscValLen+3)
      83                 :            : 
      84                 :            : //==============================================================================
      85                 :            : // Escapesequenzen: [Esc]<Ident><Value>[Esc]  also mind. 4 Char
      86                 :            : // Max. Laenge von Value soll sein: 8 Char (7+Vorzeichen). Demnach max. Laenge
      87                 :            : // einer Escapesequenz: 11 Char.
      88                 :            : // Identifer:
      89                 :            : 
      90                 :            : #define  EscFont   'F' /* FontID, z.B. 92500 fuer CG Times                          */
      91                 :            : #define  EscGrad   'G' /* Schriftgrad 1..255 fuer <<Pt-127<<Pt                      */
      92                 :            : #define  EscBreit  'B' /* Breite 1..255% des Schriftgrades                          */
      93                 :            : #define  EscKaptS  'K' /* Kapitaelchengroesse 1..255% des Schriftgrades             */
      94                 :            : #define  EscLFeed  'L' /* Zeilenabstand 1..32767% vom max. Schriftgrad der Zeile    */
      95                 :            :                         // oder 1..32767 fuer 1..16383<<Pt absolut (Wenn Bit 15=1)
      96                 :            : #define  EscSlant  'S' /* Kursiv(Winkel) 1..8999 fuer 0.01deg..89.99deg             */
      97                 :            : #define  EscVPos   'V' /* Zeichen Vertikal-Position  1..255 fuer <<Pt..127<<Pt      */
      98                 :            : #define  EscZAbst  'Z' /* Zeichenabstand -128..127%                                 */
      99                 :            : #define  EscHJust  'A' /* H-Justify    Absatz: Links, Zentr, Rechts, Block, Austreibend, Gesperrt (0..5)*/
     100                 :            : 
     101                 :            : #define  EscFarbe  'C' /* Farbe 0..7                                                */
     102                 :            : #define  EscBFarb  'U' /* BackFarbe 0..7                                            */
     103                 :            : #define  EscInts   'I' /* Farbintensitaet 0..100%                                   */
     104                 :            : #define  EscMustr  'M' /* Muster 0..? inkl. Transp...                               */
     105                 :            : #define  EscMFarb  'O' /* Musterfarbe 0..7                                          */
     106                 :            : #define  EscMBFrb  'P' /* 2. Musterfarbe 0..7                                       */
     107                 :            : #define  EscMInts  'W' /* Musterintensitaet 0..7                                    */
     108                 :            : 
     109                 :            : #define  EscSMstr  'E' /* Schattenmuster 0..? inkl. Transp...                       */
     110                 :            : #define  EscSFarb  'R' /* Schattenfarbe 0..7                                        */
     111                 :            : #define  EscSBFrb  'T' /* 2. Schattenfarbe 0..7                                     */
     112                 :            : #define  EscSInts  'Q' /* Schattenintensitaet 0..7                                  */
     113                 :            : 
     114                 :            : #define  EscSXDst  'X' /* Schattenversatz X 0..100%                                 */
     115                 :            : #define  EscSYDst  'Y' /* Schattenversatz Y 0..100%                                 */
     116                 :            : #define  EscSDist  'D' /* Schattenversatz X-Y 0..100%                               */
     117                 :            : 
     118                 :            : #define  EscBold   'f' /* Fett                                                      */
     119                 :            : #define  EscLSlnt  'l' /* LKursiv                                                   */
     120                 :            : #define  EscRSlnt  'r' /* RKursiv                                                   */
     121                 :            : #define  EscUndln  'u' /* Unterstrichen                                             */
     122                 :            : #define  EscDbUnd  'p' /* doppelt Unterstrichen                                     */
     123                 :            : #define  EscKaptF  'k' /* Kapitaelchenflag                                          */
     124                 :            : #define  EscStrik  'd' /* Durchgestrichen                                           */
     125                 :            : #define  EscDbStk  'e' /* doppelt Durchgestrichen                                   */
     126                 :            : #define  EscSupSc  'h' /* Hochgestellt                                              */
     127                 :            : #define  EscSubSc  't' /* Tiefgestellt                                              */
     128                 :            : #define  Esc2DShd  's' /* 2D-Schatten                                               */
     129                 :            : #define  Esc3DShd  'j' /* 3D-Schatten                                               */
     130                 :            : #define  Esc4DShd  'i' /* 4D-Schatten                                               */
     131                 :            : #define  EscEbShd  'b' /* Embossed                                                  */
     132                 :            : 
     133                 :            : //  AllEscIdent =[EscFont, EscGrad, EscBreit,EscKaptS,EscLFeed,EscSlant,EscVPos, EscZAbst,EscHJust,
     134                 :            : //                EscFarbe,EscBFarb,EscInts, EscMustr,EscMFarb,EscMBFrb,EscMInts,
     135                 :            : //                EscSMstr,EscSFarb,EscSBFrb,EscSInts,EscSXDst,EscSYDst,EscSDist,
     136                 :            : //                EscBold, EscLSlnt,EscRSlnt,EscUndln,EscDbUnd,EscKaptF,EscStrik,EscDbStk,
     137                 :            : //                EscSupSc,EscSubSc,Esc2DShd,Esc3DShd,Esc4DShd];
     138                 :            : // Justify muss spaetestens am Anfang des Absatzes stehen
     139                 :            : #define  EscSet    '\x1e' /* Flag setzen                                               */
     140                 :            : #define  EscReset  '\x1f' /* Flag loeschen                                             */
     141                 :            : #define  EscDeflt  '\x11' /* Flag auf default setzen                                */
     142                 :            : #define  EscToggl  '\x1d' /* Flag Toggeln                                              */
     143                 :            : #define  EscNoFlg  0
     144                 :            : #define  EscNoVal  -2147483647 /* -MaxLongInt */
     145                 :            : //==============================================================================
     146                 :            : #define  NoTrenn 0xFFFF   /* Wert fuer Parameter 'Rest' von GetTextChar(), wenn auf keinen Fall getrennt werden soll */
     147                 :            : #define  DoTrenn 0xFFFE   /* Wert fuer Parameter 'Rest' von GetTextChar(), wenn getrennt werden soll                 */
     148                 :            : 
     149                 :            : #define  MaxLineChars 1024
     150                 :            : 
     151                 :            : #define  ChrXPosArrSize (MaxLineChars+1+1)           /* 2k - Beginnt mit 0 im gegensatz zu StarDraw */
     152                 :            : #define  CharLineSize   (MaxLineChars+1+1)
     153                 :            : 
     154                 :            : #define  MinChar 32
     155                 :            : #define  MaxChar 255
     156                 :            : 
     157                 :            : 
     158                 :            : //==============================================================================
     159                 :            : 
     160                 :            : #define  GradDiv             2
     161                 :            : #define  CharTopToBase     100 /* wegen Apostrophe und Umlaute mehr als 75% */
     162                 :            : #define  CharTopToBtm      120 /* Zeilenhoehe ist groesser als Schriftgrad  */
     163                 :            :                                // bei Avanti-Bold 'ue' eigentlich sogar 130%
     164                 :            : 
     165                 :            : // end of AbsBase.Pas
     166                 :            : /////////////////////////////////////////////////////////////////////////////////
     167                 :            : /////////////////////////////////////////////////////////////////////////////////
     168                 :            : /////////////////////////////////////////////////////////////////////////////////
     169                 :            : 
     170                 :            : 
     171                 :            : 
     172                 :            : /////////////////////////////////////////////////////////////////////////////////
     173                 :            : /////////////////////////////////////////////////////////////////////////////////
     174                 :            : /////////////////////////////////////////////////////////////////////////////////
     175                 :            : // DefBase.Pas
     176                 :            : 
     177                 :            : #define  TextBoldBit  0x0001   /* Fett                    */
     178                 :            : #define  TextRSlnBit  0x0002   /* Kursiv                  */
     179                 :            : #define  TextUndlBit  0x0004   /* Unterstrichen           */
     180                 :            : #define  TextStrkBit  0x0008   /* Durchgesteichen         */
     181                 :            : #define  TextSupSBit  0x0010   /* Hocgestellt             */
     182                 :            : #define  TextSubSBit  0x0020   /* Tiefgestellt            */
     183                 :            : #define  TextKaptBit  0x0040   /* Kapitaelchen            */
     184                 :            : #define  TextLSlnBit  0x0080   /* Linkskursiv             */
     185                 :            : #define  TextDbUnBit  0x0100   /* Doppelt unterstrichen   */
     186                 :            : #define  TextDbStBit  0x0200   /* Doppelt durchgestrichen */
     187                 :            : #define  TextSh2DBit  0x0400   /* 2D-Schatten         2.0 */
     188                 :            : #define  TextSh3DBit  0x0800   /* 3D-Schatten         2.0 */
     189                 :            : #define  TextSh4DBit  0x1000   /* 4D-Schatten         2.0 */
     190                 :            : #define  TextShEbBit  0x2000   /* Embossed-Schatten   2.0 */
     191                 :            : #define  FontAtrBits  (TextBoldBit | TextRSlnBit)
     192                 :            : 
     193                 :            : #define  THJustLeft    0x00
     194                 :            : #define  THJustCenter  0x01
     195                 :            : #define  THJustRight   0x02
     196                 :            : #define  THJustBlock   0x03
     197                 :            : #define  THJustDrvOut  0x04 /* Austreibend          Formatiert */
     198                 :            : #define  THJustLocked  0x05 /* A l s   S p e r r s c h r i f t */
     199                 :            : #define  TVJustTop     0x00 /* Future */
     200                 :            : #define  TVJustCenter  0x10 /* Future */
     201                 :            : #define  TVJustBottom  0x20 /* Future */
     202                 :            : #define  TVJustBlock   0x30 /* Future */
     203                 :            : 
     204                 :            : #define  MaxCharSlant  4200 /* Maximal 42deg kursiv ! */
     205                 :            : 
     206                 :            : // end of DefBase.Pas
     207                 :            : /////////////////////////////////////////////////////////////////////////////////
     208                 :            : /////////////////////////////////////////////////////////////////////////////////
     209                 :            : /////////////////////////////////////////////////////////////////////////////////
     210                 :            : 
     211                 :            : 
     212                 :            : sal_Bool CheckTextOutl(ObjAreaType& F, ObjLineType& L);
     213                 :            : 
     214                 :          0 : sal_Bool CheckTextOutl(ObjAreaType& F, ObjLineType& L)
     215                 :            : {
     216                 :            :     return (F.FIntens!=L.LIntens) ||
     217                 :            :            ((F.FFarbe!=L.LFarbe)   && (F.FIntens>0)) ||
     218 [ #  # ][ #  # ]:          0 :            ((F.FBFarbe!=L.LBFarbe) && (F.FIntens<100));
         [ #  # ][ #  # ]
                 [ #  # ]
     219                 :            : }
     220                 :            : 
     221                 :            : 
     222                 :            : /////////////////////////////////////////////////////////////////////////////////
     223                 :            : /////////////////////////////////////////////////////////////////////////////////
     224                 :            : /////////////////////////////////////////////////////////////////////////////////
     225                 :            : // Misc.Pas
     226                 :            : 
     227                 :          0 : short hPoint2Sgf(short a)
     228                 :            : {
     229                 :            :     long b;
     230                 :          0 :     b=long(a)*127*SgfDpmm/(144*5);
     231                 :          0 :     return short(b);
     232                 :            : }
     233                 :            : 
     234                 :            : // End of Misc.Pas
     235                 :            : // AbsRead.Pas
     236                 :            : 
     237                 :            : // ======================================================================
     238                 :            : // Function GetTopToBaseLine()  Function GetBaseLineToBtm()
     239                 :            : //
     240                 :            : // Abstand von Zeilenoberkante bis BaseLine bzw. von BaseLine bis
     241                 :            : // Unterkante berechnen. Alles in SGF-Units.
     242                 :            : // ======================================================================
     243                 :            : 
     244                 :          0 : sal_uInt16 GetTopToBaseLine(sal_uInt16 MaxGrad)
     245                 :            : {
     246                 :            :     long ret;
     247                 :          0 :     ret=long(MaxGrad)*long(CharTopToBase) /long(100);
     248                 :          0 :     return sal_uInt16(ret);
     249                 :            : }
     250                 :            : 
     251                 :            : // ======================================================================
     252                 :            : // Function GetTextChar()   Function GetTextCharConv()
     253                 :            : //
     254                 :            : // Liest ein Zeichen aus dem Textbuffer, wertet dabei eventuell
     255                 :            : // auftretende Escapesequenzen aus und setzt dementsprechend den
     256                 :            : // Ein-/Ausgabeparameter AktAtr. Index wird entsprechend erhoeht.
     257                 :            : // Der Parameter Rest muss immer die Anzahl der Zeichen beinhalten,
     258                 :            : // den angeforderten Zeichen in der aktuellen Zeile noch folgen.
     259                 :            : // Ansonsten funktioniert die Silbentrennung nicht richtig. Gibt man
     260                 :            : // stattdessen die Konstante NoTrenn an, wird in keinem Fall
     261                 :            : // getrennt, die Konstante DoTrenn bewirkt dagegen, dass ueberall dort
     262                 :            : // getrennt wird, wo ein SoftTrenner vorkommt.
     263                 :            : //
     264                 :            : // SoftTrenner werden immer in ein Minuszeichen konvertiert.
     265                 :            : // GetTextCharConv() konvertiert zusaetzlich HardSpace und AbsatzEnde
     266                 :            : // in Spaces sowie HardTrenner in Minuszeichen. TextEnde wird immer
     267                 :            : // als Char(0) geliefert.
     268                 :            : // ======================================================================
     269                 :            : 
     270                 :            : 
     271                 :            : 
     272                 :          0 : UCHAR ConvertTextChar(UCHAR c)
     273                 :            : {
     274         [ #  # ]:          0 :     if (c<32) {
     275   [ #  #  #  #  :          0 :         switch (c) {
                #  #  # ]
     276                 :          0 :             case HardSpace   : c=' '; break;
     277                 :          0 :             case AbsatzEnd   : c=' '; break;
     278                 :          0 :             case SoftTrenn   : c='-'; break;
     279                 :          0 :             case HardTrenn   : c='-'; break;
     280                 :          0 :             case SoftTrennK  : c='-'; break;
     281                 :          0 :             case SoftTrennAdd: c='-';
     282                 :            :         }
     283                 :            :     }
     284                 :          0 :     return c;
     285                 :            : }
     286                 :            : 
     287                 :          0 : long ChgValue(long Def, long Min, long Max, UCHAR FlgVal, long NumVal)
     288                 :            : {
     289                 :          0 :     long r=0;
     290                 :            : 
     291         [ #  # ]:          0 :     if (FlgVal==EscDeflt) {
     292                 :          0 :         r=Def;                          // zurueck auf Default
     293                 :            :     } else {
     294         [ #  # ]:          0 :         if (NumVal!=EscNoVal) r=NumVal; // Hart setzen
     295                 :            :     }
     296                 :            : 
     297 [ #  # ][ #  # ]:          0 :     if (Min!=0 || Max!=0) {
     298         [ #  # ]:          0 :         if (r>Max) r=Max;
     299         [ #  # ]:          0 :         if (r<Min) r=Min;
     300                 :            :     }
     301                 :          0 :     return r;
     302                 :            : }
     303                 :            : 
     304                 :            : 
     305                 :            : 
     306                 :          0 : void ChgSchnittBit(sal_uInt16 Bit, sal_uInt16 Radio1, sal_uInt16 Radio2, sal_uInt16 Radio3,
     307                 :            :                    UCHAR FlgVal, sal_uInt16 Schnitt0, sal_uInt16& Schnitt)
     308                 :            : {
     309                 :            :     sal_uInt16 All,Rad;
     310                 :            : 
     311                 :          0 :     Rad=Radio1 | Radio2 | Radio3;
     312                 :          0 :     All=Bit | Rad;
     313                 :            : 
     314   [ #  #  #  #  :          0 :     switch (FlgVal) {
                      # ]
     315                 :          0 :         case EscSet  : Schnitt=(Schnitt & ~All) | Bit;              break;
     316                 :          0 :         case EscReset: Schnitt=(Schnitt & ~All);                    break;
     317                 :          0 :         case EscDeflt: Schnitt=(Schnitt & ~All) | (Schnitt0 & All); break;
     318                 :          0 :         case EscToggl: Schnitt=(Schnitt & ~Rad) ^ Bit;
     319                 :            :     }
     320                 :          0 : }
     321                 :            : 
     322                 :            : 
     323                 :            : 
     324                 :          0 : UCHAR GetNextChar(UCHAR* TBuf, sal_uInt16 Index)
     325                 :            : {
     326                 :            :     sal_uInt16 Cnt;
     327         [ #  # ]:          0 :     while (TBuf[Index]==Escape) {
     328                 :          0 :         Index++;
     329                 :          0 :         Cnt=0;
     330 [ #  # ][ #  # ]:          0 :         while (TBuf[Index]!=Escape && Cnt<=MaxEscLen) {
                 [ #  # ]
     331                 :          0 :             Index++; Cnt++; }
     332                 :          0 :         Index++;
     333                 :            :     }
     334                 :          0 :     return TBuf[Index];
     335                 :            : }
     336                 :            : 
     337                 :            : 
     338                 :            : 
     339                 :          0 : UCHAR ProcessOne(UCHAR* TBuf, sal_uInt16& Index,
     340                 :            :                  ObjTextType& Atr0, ObjTextType& AktAtr,
     341                 :            :                  sal_Bool ScanEsc)
     342                 :            : {
     343                 :            :     UCHAR c;
     344                 :            :     UCHAR Ident;
     345                 :            :     sal_Bool  Ende;
     346                 :            :     sal_Bool  q;
     347                 :            :     UCHAR FlgVal;
     348                 :            :     long  NumVal;
     349                 :            :     long  Sgn;
     350                 :            :     short i;
     351                 :            :     sal_Bool  EoVal;
     352                 :            : 
     353 [ #  # ][ #  # ]:          0 :     do {
                 [ #  # ]
     354                 :          0 :         c=TBuf[Index]; Index++;
     355                 :          0 :         Ende=(c!=Escape);
     356         [ #  # ]:          0 :         if (Ende==sal_False) {
     357                 :          0 :             c=TBuf[Index]; Index++;
     358                 :          0 :             Ident=c;                          // Identifer merken
     359                 :          0 :             FlgVal=EscNoFlg;
     360                 :          0 :             NumVal=EscNoVal;
     361                 :          0 :             c=TBuf[Index]; Index++;            // Hier faengt der Wert an
     362 [ #  # ][ #  # ]:          0 :             if (c==EscSet || c==EscReset || c==EscDeflt || c==EscToggl) FlgVal=c; else {
         [ #  # ][ #  # ]
     363         [ #  # ]:          0 :                 if (c=='-') Sgn=-1; else Sgn=1;
     364 [ #  # ][ #  # ]:          0 :                 if (c=='+' || c=='-') { c=TBuf[Index]; Index++; }
     365                 :          0 :                 i=MaxEscValLen;
     366                 :          0 :                 NumVal=0;
     367 [ #  # ][ #  # ]:          0 :                 do {
                 [ #  # ]
     368                 :          0 :                     NumVal=10*NumVal+c-'0';
     369 [ #  # ][ #  # ]:          0 :                     EoVal=(TBuf[Index]<'0' || TBuf[Index]>'9');
     370         [ #  # ]:          0 :                     if (EoVal==sal_False) { c=TBuf[Index]; Index++; }
     371                 :          0 :                     i--;
     372                 :            :                 } while (i>0 && EoVal==sal_False);
     373                 :          0 :                 NumVal=Sgn*NumVal;
     374                 :            :             }
     375                 :          0 :             q=!CheckTextOutl(AktAtr.F,AktAtr.L);
     376                 :            : 
     377   [ #  #  #  #  :          0 :             switch (Ident) {
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
     378                 :          0 :                 case EscFont : AktAtr.SetFont(sal_uLong (ChgValue(Atr0.GetFont(),0,0          ,FlgVal,NumVal)));break;
     379                 :          0 :                 case EscGrad : AktAtr.Grad   =sal_uInt16(ChgValue(Atr0.Grad,   2,2000         ,FlgVal,NumVal)); break;
     380                 :          0 :                 case EscBreit: AktAtr.Breite =sal_uInt16(ChgValue(Atr0.Breite, 1,1000         ,FlgVal,NumVal)); break;
     381                 :          0 :                 case EscKaptS: AktAtr.Kapit  =(sal_uInt8)(ChgValue(Atr0.Kapit,  1,255          ,FlgVal,NumVal)); break;
     382                 :          0 :                 case EscLFeed: AktAtr.LnFeed =sal_uInt16(ChgValue(Atr0.LnFeed, 1,65535        ,FlgVal,NumVal)); break;
     383                 :          0 :                 case EscSlant: AktAtr.Slant  =sal_uInt16(ChgValue(Atr0.Slant,  1,MaxCharSlant ,FlgVal,NumVal)); break;
     384                 :          0 :                 case EscVPos : AktAtr.ChrVPos=char  (ChgValue(Atr0.ChrVPos,-128,127       ,FlgVal,NumVal)); break;
     385                 :          0 :                 case EscZAbst: AktAtr.ZAbst  =(sal_uInt8)(ChgValue(Atr0.ZAbst,  1,255          ,FlgVal,NumVal)); break;
     386                 :          0 :                 case EscHJust: AktAtr.Justify=(sal_uInt8)(ChgValue(Atr0.Justify & 0x0F,0,5     ,FlgVal,NumVal)); break;
     387         [ #  # ]:          0 :                 case EscFarbe: { AktAtr.L.LFarbe =(sal_uInt8)(ChgValue(Atr0.L.LFarbe,0,7   ,FlgVal,NumVal)); if (q) AktAtr.F.FFarbe =AktAtr.L.LFarbe;  } break;
     388         [ #  # ]:          0 :                 case EscBFarb: { AktAtr.L.LBFarbe=(sal_uInt8)(ChgValue(Atr0.L.LBFarbe,0,255,FlgVal,NumVal)); if (q) AktAtr.F.FBFarbe=AktAtr.L.LBFarbe; } break;
     389         [ #  # ]:          0 :                 case EscInts : { AktAtr.L.LIntens=(sal_uInt8)(ChgValue(Atr0.L.LIntens,0,100,FlgVal,NumVal)); if (q) AktAtr.F.FIntens=AktAtr.L.LIntens; } break;
     390                 :            : 
     391                 :          0 :                 case EscMustr: { AktAtr.F.FMuster=sal_uInt16(ChgValue(Atr0.F.FMuster,0,65535,FlgVal,NumVal)); } break;
     392                 :          0 :                 case EscMFarb: { AktAtr.F.FFarbe =(sal_uInt8)(ChgValue(Atr0.F.FFarbe,0,7   ,FlgVal,NumVal));   } break;
     393                 :          0 :                 case EscMBFrb: { AktAtr.F.FBFarbe=(sal_uInt8)(ChgValue(Atr0.F.FBFarbe,0,255,FlgVal,NumVal));   } break;
     394                 :          0 :                 case EscMInts: { AktAtr.F.FIntens=(sal_uInt8)(ChgValue(Atr0.F.FIntens,0,100,FlgVal,NumVal));   } break;
     395                 :            : 
     396                 :          0 :                 case EscSMstr: { AktAtr.ShdF.FMuster=sal_uInt16(ChgValue(Atr0.ShdF.FMuster,0,65535,FlgVal,NumVal)); } break;
     397                 :          0 :                 case EscSFarb: { AktAtr.ShdL.LFarbe =(sal_uInt8)(ChgValue(Atr0.ShdL.LFarbe,0,7   ,FlgVal,NumVal)); AktAtr.ShdF.FFarbe =AktAtr.ShdL.LFarbe;  } break;
     398                 :          0 :                 case EscSBFrb: { AktAtr.ShdL.LBFarbe=(sal_uInt8)(ChgValue(Atr0.ShdL.LBFarbe,0,255,FlgVal,NumVal)); AktAtr.ShdF.FBFarbe=AktAtr.ShdL.LBFarbe; } break;
     399                 :          0 :                 case EscSInts: { AktAtr.ShdL.LIntens=(sal_uInt8)(ChgValue(Atr0.ShdL.LIntens,0,100,FlgVal,NumVal)); AktAtr.ShdF.FIntens=AktAtr.ShdL.LIntens; } break;
     400                 :          0 :                 case EscSDist: { AktAtr.ShdVers.x=(short)ChgValue(Atr0.ShdVers.x,0,30000,FlgVal,NumVal); AktAtr.ShdVers.y=AktAtr.ShdVers.x; }            break;
     401                 :          0 :                 case EscSXDst: { AktAtr.ShdVers.x=(short)ChgValue(Atr0.ShdVers.x,0,30000,FlgVal,NumVal); }  break;
     402                 :          0 :                 case EscSYDst: { AktAtr.ShdVers.y=(short)ChgValue(Atr0.ShdVers.y,0,30000,FlgVal,NumVal); }  break;
     403                 :            : 
     404                 :          0 :                 case EscBold : ChgSchnittBit(TextBoldBit,0,0,0                              ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
     405                 :          0 :                 case EscRSlnt: ChgSchnittBit(TextRSlnBit,TextLSlnBit,0,0                    ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
     406                 :          0 :                 case EscUndln: ChgSchnittBit(TextUndlBit,TextDbUnBit,0,0                    ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
     407                 :          0 :                 case EscStrik: ChgSchnittBit(TextStrkBit,TextDbStBit,0,0                    ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
     408                 :          0 :                 case EscDbUnd: ChgSchnittBit(TextDbUnBit,TextUndlBit,0,0                    ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
     409                 :          0 :                 case EscDbStk: ChgSchnittBit(TextDbStBit,TextStrkBit,0,0                    ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
     410                 :          0 :                 case EscSupSc: ChgSchnittBit(TextSupSBit,TextSubSBit,0,0                    ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
     411                 :          0 :                 case EscSubSc: ChgSchnittBit(TextSubSBit,TextSupSBit,0,0                    ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
     412                 :          0 :                 case EscKaptF: ChgSchnittBit(TextKaptBit,0,0,0                              ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
     413                 :          0 :                 case EscLSlnt: ChgSchnittBit(TextLSlnBit,TextRSlnBit,0,0                    ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
     414                 :          0 :                 case Esc2DShd: ChgSchnittBit(TextSh2DBit,TextSh3DBit,TextSh4DBit,TextShEbBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
     415                 :          0 :                 case Esc3DShd: ChgSchnittBit(TextSh3DBit,TextSh2DBit,TextSh4DBit,TextShEbBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
     416                 :          0 :                 case Esc4DShd: ChgSchnittBit(TextSh4DBit,TextSh2DBit,TextSh3DBit,TextShEbBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
     417                 :          0 :                 case EscEbShd: ChgSchnittBit(TextShEbBit,TextSh2DBit,TextSh3DBit,TextSh4DBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break;
     418                 :            :             } //endcase
     419         [ #  # ]:          0 :             if (TBuf[Index]==Escape) Index++;         // zweites Esc weglesen }
     420                 :            :         } // if Ende==sal_False
     421                 :            :     } while (Ende==sal_False && ScanEsc==sal_False);
     422         [ #  # ]:          0 :     if (Ende==sal_False) c=Escape;
     423                 :          0 :     return c;
     424                 :            : } // end of ProcessOne
     425                 :            : 
     426                 :            : 
     427                 :          0 : UCHAR GetTextChar(UCHAR* TBuf, sal_uInt16& Index,
     428                 :            :                   ObjTextType& Atr0, ObjTextType& AktAtr,
     429                 :            :                   sal_uInt16 Rest, sal_Bool ScanEsc)
     430                 :            : {
     431                 :            :     UCHAR c,c0,nc;
     432                 :            : 
     433                 :          0 :     c=ProcessOne(TBuf,Index,Atr0,AktAtr,ScanEsc);
     434         [ #  # ]:          0 :     if (ScanEsc==sal_False) {
     435 [ #  # ][ #  # ]:          0 :         if (c==SoftTrennAdd || c==SoftTrennK || c==SoftTrenn) {
                 [ #  # ]
     436                 :          0 :             nc=GetNextChar(TBuf,Index);
     437                 :          0 :             c0=c;
     438 [ #  # ][ #  # ]:          0 :             if (Rest==0 || Rest==DoTrenn ||
         [ #  # ][ #  # ]
                 [ #  # ]
     439                 :          0 :                 nc==' ' || nc==AbsatzEnd || nc==TextEnd) c='-';
     440                 :            :             else {
     441                 :          0 :                 c=ProcessOne(TBuf,Index,Atr0,AktAtr,ScanEsc); // den Trenner ueberspringen
     442         [ #  # ]:          0 :                 if (c0==SoftTrennAdd) {
     443         [ #  # ]:          0 :                     if (c>=32) c=ProcessOne(TBuf,Index,Atr0,AktAtr,ScanEsc); // und hier noch 'nen Buchstaben ueberspringen
     444                 :            :                 }
     445                 :            :             }
     446                 :            :         }
     447 [ #  # ][ #  # ]:          0 :         if ((Rest==1 || Rest==DoTrenn) && GetNextChar(TBuf,Index)==SoftTrennK) {
         [ #  # ][ #  # ]
     448         [ #  # ]:          0 :             if (c=='c') c='k';
     449         [ #  # ]:          0 :             else if (c=='C') c='K';
     450                 :            :         }
     451                 :            :     }
     452                 :          0 :     return c;
     453                 :            : }
     454                 :            : 
     455                 :            :   // HardSpace und HardTrenn muessen explizit konvertiert werden ! }
     456                 :            :   // if AktAtr.Schnitt and TextKaptBit =TextKaptBit then c:=UpCase(c);(explizit) }
     457                 :            : 
     458                 :            :   // Bei der Trennmethode SoftTrennAdd wird davon ausgegangen, dass der zu }
     459                 :            :   // trennende Konsonant bereits 3x mal im TextBuf vorhanden ist, z.b.:   }
     460                 :            :   // "Schiff-fahrt". Wenn nicht getrennt, dann wird "-f" entfernt.        }
     461                 :            : 
     462                 :            : 
     463                 :            : 
     464                 :          0 : UCHAR GetTextCharConv(UCHAR* TBuf, sal_uInt16& Index,
     465                 :            :                       ObjTextType& Atr0, ObjTextType& AktAtr,
     466                 :            :                       sal_uInt16 Rest, sal_Bool ScanEsc)
     467                 :            : {
     468                 :            :     UCHAR c;
     469                 :            : 
     470                 :          0 :     c=GetTextChar(TBuf,Index,Atr0,AktAtr,Rest,ScanEsc);
     471         [ #  # ]:          0 :     if (c<32) {
     472   [ #  #  #  # ]:          0 :         switch (c) {
     473                 :          0 :             case HardSpace   : c=' '; break;
     474                 :          0 :             case AbsatzEnd   : c=' '; break;
     475                 :          0 :             case HardTrenn   : c='-';
     476                 :            :         }
     477                 :            :     }
     478                 :          0 :     return c;
     479                 :            : }
     480                 :            : 
     481                 :            : 
     482                 :            : // ======================================================================
     483                 :            : // Function GetLineFeed()
     484                 :            : //
     485                 :            : // Benoetigter Zeilenabstand in SGF-Units. ChrVPos wird beruecksichtigt.
     486                 :            : // ======================================================================
     487                 :          0 : sal_uInt16 GetLineFeed(UCHAR* TBuf, sal_uInt16 Index, ObjTextType Atr0, ObjTextType AktAtr,
     488                 :            :                    sal_uInt16 nChar, sal_uInt16& LF, sal_uInt16& MaxGrad)
     489                 :            : {
     490                 :          0 :     UCHAR  c=0;
     491                 :          0 :     sal_Bool   AbsEnd=sal_False;
     492                 :          0 :     sal_uLong  LF100=0;
     493                 :          0 :     sal_uLong  MaxLF100=0;
     494                 :          0 :     sal_Bool   LFauto=0;
     495                 :          0 :     sal_Bool   First=sal_True;
     496                 :            :     sal_uInt16 Grad;
     497                 :          0 :     sal_uInt16 i=0;
     498                 :          0 :     sal_uInt16 r=1;
     499                 :            : 
     500                 :          0 :     MaxGrad=0;
     501 [ #  # ][ #  # ]:          0 :     while (!AbsEnd && nChar>0) {
                 [ #  # ]
     502                 :          0 :         nChar--;
     503                 :          0 :         c=GetTextChar(TBuf,Index,Atr0,AktAtr,nChar,sal_False);
     504                 :          0 :         i++;
     505 [ #  # ][ #  # ]:          0 :         AbsEnd=(c==TextEnd || c==AbsatzEnd);
     506 [ #  # ][ #  # ]:          0 :         if (First || (!AbsEnd && c!=' ' && c!=HardTrenn)) {
         [ #  # ][ #  # ]
     507                 :          0 :             LFauto=(AktAtr.LnFeed & 0x8000)==0;
     508                 :          0 :             LF100=AktAtr.LnFeed & 0x7FFF;
     509         [ #  # ]:          0 :             if (LFauto) LF100=LF100*AktAtr.Grad; else LF100*=LF100;
     510         [ #  # ]:          0 :             if (AktAtr.ChrVPos>0) LF100-=AktAtr.ChrVPos*100;
     511         [ #  # ]:          0 :             if (LF100>MaxLF100) MaxLF100=LF100;
     512                 :          0 :             Grad=AktAtr.Grad;
     513         [ #  # ]:          0 :             if (AktAtr.ChrVPos>0) Grad=Grad-AktAtr.ChrVPos;
     514         [ #  # ]:          0 :             if (Grad>MaxGrad) MaxGrad=Grad;
     515                 :          0 :             First=sal_False;
     516                 :            :         }
     517 [ #  # ][ #  # ]:          0 :         if (!AbsEnd && c!=' ') r=i;
     518                 :            :     }
     519                 :          0 :     MaxGrad=hPoint2Sgf(MaxGrad);
     520         [ #  # ]:          0 :     if (MaxLF100<=4000) {  // sonst Overflowgefahr
     521                 :          0 :         LF=sal_uInt16(hPoint2Sgf(short(MaxLF100)) /100);
     522                 :            :     } else {
     523                 :          0 :         LF=sal_uInt16(hPoint2Sgf(short(MaxLF100) /100));
     524                 :            :     }
     525                 :            : 
     526                 :          0 :     return r;
     527                 :            : }
     528                 :            : 
     529                 :            : // End of AbsRead.Pas
     530                 :            : /////////////////////////////////////////////////////////////////////////////////
     531                 :            : /////////////////////////////////////////////////////////////////////////////////
     532                 :            : /////////////////////////////////////////////////////////////////////////////////
     533                 :            : 
     534                 :            : 
     535                 :            : 
     536                 :            : /////////////////////////////////////////////////////////////////////////////////
     537                 :            : /////////////////////////////////////////////////////////////////////////////////
     538                 :            : /////////////////////////////////////////////////////////////////////////////////
     539                 :            : // iFont.Pas
     540                 :            : 
     541                 :            : #define DefaultSlant 1500   /* Default: Italic ist 15deg                  */
     542                 :            : #define SuperSubFact 60     /* SuperScript/SubScript: 60% vom Schriftgrad */
     543                 :            : #define DefaultSpace 40     /* Default: Space ist 40% vom SchriftGrad     */
     544                 :            : 
     545                 :          0 : sal_uInt16 SetTextContext(OutputDevice& rOut, ObjTextType& Atr, sal_Bool Kapt, sal_uInt16 Dreh,
     546                 :            :                       sal_uInt16 FitXMul, sal_uInt16 FitXDiv, sal_uInt16 FitYMul, sal_uInt16 FitYDiv)
     547                 :            : {
     548                 :            :     SgfFontOne* pSgfFont; // Font aus dem IniFile
     549         [ #  # ]:          0 :     Font   aFont;
     550                 :          0 :     Color  aColor;
     551                 :            :     sal_uLong  Grad;
     552                 :            :     sal_uLong  Brei;
     553         [ #  # ]:          0 :     String FNam;
     554                 :          0 :     sal_uInt16 StdBrei=50;    // Durchschnittliche Zeichenbreite in % von Schriftgrad
     555 [ #  # ][ #  # ]:          0 :     sal_Bool   bFit=(FitXMul!=1 || FitXDiv!=1 || FitYMul!=1 || FitYDiv!=1);
         [ #  # ][ #  # ]
     556                 :            : 
     557                 :          0 :     pSgfFont = pSgfFonts->GetFontDesc(Atr.GetFont());
     558                 :            : 
     559         [ #  # ]:          0 :     if ( pSgfFont!=NULL )
     560                 :            :     {
     561         [ #  # ]:          0 :         FNam   =pSgfFont->SVFName;
     562                 :          0 :         StdBrei=pSgfFont->SVWidth;
     563 [ #  # ][ #  # ]:          0 :         if (pSgfFont->Fixd) aFont.SetPitch(PITCH_FIXED); else aFont.SetPitch(PITCH_VARIABLE);
                 [ #  # ]
     564         [ #  # ]:          0 :         aFont.SetFamily(pSgfFont->SVFamil);
     565         [ #  # ]:          0 :         aFont.SetCharSet(pSgfFont->SVChSet);
     566 [ #  # ][ #  # ]:          0 :         aFont.SetName(FNam);
     567                 :            :     }
     568                 :            :     else
     569                 :            :     {  // Falls nich im Inifile, sind hier einige Fonts hart kodiert
     570         [ #  # ]:          0 :         aFont.SetPitch(PITCH_VARIABLE);
     571   [ #  #  #  # ]:          0 :         switch (Atr.GetFont()) {
     572                 :            :           case 92500: case 92501: case 92504: case 92505:
     573                 :            :           {
     574                 :            : #if defined(WNT)
     575                 :            :               FNam=rtl::OUString("Times New Roman");  // CG Times ist unter Windows Times New Roman
     576                 :            : #else
     577         [ #  # ]:          0 :               FNam=rtl::OUString("Times");            // ansonsten ist das einfach Times
     578                 :            : #endif
     579                 :          0 :               StdBrei=40;
     580         [ #  # ]:          0 :               aFont.SetFamily(FAMILY_ROMAN);
     581                 :          0 :           } break;
     582                 :            :           case 94021: case 94022: case 94023: case 94024: {
     583                 :            : #if defined(WNT)
     584                 :            :               FNam=rtl::OUString("Arial");            // Univers ist unter Windows Arial
     585                 :            : #else
     586         [ #  # ]:          0 :               FNam=rtl::OUString("Helvetica");        // und ansonsten Helvetica
     587                 :            : #endif
     588         [ #  # ]:          0 :               aFont.SetFamily(FAMILY_SWISS);
     589                 :          0 :               StdBrei=47;
     590                 :          0 :           } break;
     591                 :            :           case 93950: case 93951: case 93952: case 93953: {
     592                 :            : #if defined(WNT)
     593                 :            :               FNam=rtl::OUString("Courier New");      // Der Vector-Courierfont unter Windows heisst Courier New
     594                 :            : #else
     595         [ #  # ]:          0 :               FNam=rtl::OUString("Courier");          // ansonsten ist und bleibt Courier immer Courier
     596                 :            : #endif
     597         [ #  # ]:          0 :               aFont.SetFamily(FAMILY_ROMAN);
     598         [ #  # ]:          0 :               aFont.SetPitch(PITCH_FIXED);
     599                 :          0 :           } break;
     600         [ #  # ]:          0 :           default: FNam = rtl::OUString("Helvetica");
     601                 :            :         }
     602 [ #  # ][ #  # ]:          0 :         aFont.SetName(FNam);
     603                 :            :         //aFont.SetCharSet(CHARSET_SYSTEM);
     604                 :            :     }
     605                 :            : 
     606                 :          0 :     Grad=sal_uLong(Atr.Grad);
     607 [ #  # ][ #  # ]:          0 :     if ((Atr.Schnitt & TextKaptBit) !=0 && Kapt) Grad=Grad*sal_uLong(Atr.Kapit)/100;
     608 [ #  # ][ #  # ]:          0 :     if ((Atr.Schnitt & TextSupSBit) !=0 || (Atr.Schnitt & TextSubSBit) !=0) Grad=Grad*SuperSubFact/100;
     609                 :          0 :     Brei=Grad;
     610 [ #  # ][ #  # ]:          0 :     if (Atr.Breite!=100 || bFit) {
     611         [ #  # ]:          0 :         if (bFit) {
     612                 :          0 :             Grad=Grad*sal_uLong(FitYMul)/sal_uLong(FitYDiv);
     613                 :          0 :             Brei=Brei*sal_uLong(FitXMul)/sal_uLong(FitXDiv);
     614                 :            :         }
     615                 :          0 :         Brei=Brei*sal_uLong(Atr.Breite)/100;
     616                 :          0 :         Brei=Brei*sal_uLong(StdBrei)/100;
     617         [ #  # ]:          0 :         aFont.SetSize(Size(hPoint2Sgf(sal_uInt16(Brei)),hPoint2Sgf(sal_uInt16(Grad))));
     618                 :            :     } else {
     619         [ #  # ]:          0 :         aFont.SetSize(Size(0,hPoint2Sgf(sal_uInt16(Grad))));
     620                 :            :     }
     621                 :            : 
     622 [ #  # ][ #  # ]:          0 :     aColor=Sgv2SvFarbe(Atr.L.LFarbe,Atr.L.LBFarbe,Atr.L.LIntens); aFont.SetColor(aColor);
     623 [ #  # ][ #  # ]:          0 :     aColor=Sgv2SvFarbe(Atr.F.FFarbe,Atr.F.FBFarbe,Atr.F.FIntens); aFont.SetFillColor(aColor);
     624         [ #  # ]:          0 :     aFont.SetTransparent(sal_True);
     625         [ #  # ]:          0 :     aFont.SetAlign(ALIGN_BASELINE);
     626                 :            : 
     627         [ #  # ]:          0 :     Dreh/=10; Dreh=3600-Dreh; if (Dreh==3600) Dreh=0;
     628         [ #  # ]:          0 :     aFont.SetOrientation(Dreh);
     629                 :            : 
     630 [ #  # ][ #  # ]:          0 :     if ((Atr.Schnitt & TextBoldBit) !=0) aFont.SetWeight(WEIGHT_BOLD);
     631 [ #  # ][ #  # ]:          0 :     if ((Atr.Schnitt & TextRSlnBit) !=0) aFont.SetItalic(ITALIC_NORMAL);
     632 [ #  # ][ #  # ]:          0 :     if ((Atr.Schnitt & TextUndlBit) !=0) aFont.SetUnderline(UNDERLINE_SINGLE);
     633 [ #  # ][ #  # ]:          0 :     if ((Atr.Schnitt & TextDbUnBit) !=0) aFont.SetUnderline(UNDERLINE_DOUBLE);
     634 [ #  # ][ #  # ]:          0 :     if ((Atr.Schnitt & TextStrkBit) !=0) aFont.SetStrikeout(STRIKEOUT_SINGLE);
     635 [ #  # ][ #  # ]:          0 :     if ((Atr.Schnitt & TextDbStBit) !=0) aFont.SetStrikeout(STRIKEOUT_DOUBLE);
     636 [ #  # ][ #  # ]:          0 :     if ((Atr.Schnitt & TextSh2DBit) !=0) aFont.SetShadow(sal_True);
     637 [ #  # ][ #  # ]:          0 :     if ((Atr.Schnitt & TextSh3DBit) !=0) aFont.SetShadow(sal_True);
     638 [ #  # ][ #  # ]:          0 :     if ((Atr.Schnitt & TextSh4DBit) !=0) aFont.SetShadow(sal_True);
     639 [ #  # ][ #  # ]:          0 :     if ((Atr.Schnitt & TextShEbBit) !=0) aFont.SetShadow(sal_True);
     640 [ #  # ][ #  # ]:          0 :     if (CheckTextOutl(Atr.F,Atr.L)) aFont.SetOutline(sal_True);
     641                 :            : 
     642 [ #  # ][ #  # ]:          0 :     if (aFont!=rOut.GetFont()) rOut.SetFont(aFont);
                 [ #  # ]
     643                 :            : 
     644 [ #  # ][ #  # ]:          0 :     return 0;
     645                 :            : }
     646                 :            : 
     647                 :            : // iFont.Pas
     648                 :            : /////////////////////////////////////////////////////////////////////////////////
     649                 :            : /////////////////////////////////////////////////////////////////////////////////
     650                 :            : /////////////////////////////////////////////////////////////////////////////////
     651                 :            : 
     652                 :            : 
     653                 :            : /////////////////////////////////////////////////////////////////////////////////
     654                 :            : /////////////////////////////////////////////////////////////////////////////////
     655                 :            : /////////////////////////////////////////////////////////////////////////////////
     656                 :            : // Absatz.Pas
     657                 :            : 
     658                 :            : struct ProcChrSta {
     659                 :            :     sal_uInt16 Index;
     660                 :            :     sal_uInt16 ChrXP;
     661                 :            :     UCHAR  OutCh;
     662                 :            :     sal_Bool   Kapt;
     663                 :            :     ObjTextType Attrib;
     664                 :            : };
     665                 :            : 
     666                 :          0 : void InitProcessCharState(ProcChrSta& State, ObjTextType& AktAtr, sal_uInt16 IndexA)
     667                 :            : {
     668                 :          0 :     State.Attrib=AktAtr;
     669                 :          0 :     State.OutCh=0;
     670                 :          0 :     State.Index=IndexA;
     671                 :          0 :     State.ChrXP=0;
     672                 :          0 :     State.Kapt=sal_False;
     673                 :          0 : }
     674                 :            : 
     675                 :          0 : sal_Bool UpcasePossible(UCHAR c)
     676                 :            : {
     677 [ #  # ][ #  # ]:          0 :     if ((c>='a' && c<='z') || c == 0xe4 || c == 0xf6 || c == 0xfc ) return sal_True;
         [ #  # ][ #  # ]
                 [ #  # ]
     678                 :          0 :     else return sal_False;
     679                 :            : }
     680                 :            : 
     681                 :          0 : UCHAR Upcase(UCHAR c)
     682                 :            : {
     683 [ #  # ][ #  # ]:          0 :     if ((c>=(UCHAR)'a' && c<=(UCHAR)'z')) c=(c-(UCHAR)'a')+(UCHAR)'A';
     684         [ #  # ]:          0 :     else if ( c == 0xe4 ) c = 0xc4;
     685         [ #  # ]:          0 :     else if ( c == 0xf6 ) c = 0xd6;
     686         [ #  # ]:          0 :     else if ( c == 0xfc ) c = 0xdc;
     687                 :          0 :     return c;
     688                 :            : }
     689                 :            : 
     690                 :          0 : sal_uInt16 GetCharWidth(OutputDevice& rOut, UCHAR c)
     691                 :            : {
     692                 :            :     sal_uInt16 ChrWidth;
     693                 :            : 
     694         [ #  # ]:          0 :     if (c==' ')
     695                 :            :     {
     696 [ #  # ][ #  # ]:          0 :         ChrWidth=(sal_uInt16)rOut.GetTextWidth( rtl::OUString('A') );
                 [ #  # ]
     697         [ #  # ]:          0 :         if (rOut.GetFont().GetPitch()!=PITCH_FIXED) {
     698                 :          0 :             ChrWidth=MulDiv(ChrWidth,DefaultSpace,100);
     699                 :            :         }
     700                 :            :     }
     701                 :            :     else
     702                 :            :     {
     703                 :            :          // with MaxChar == 255 c cannot be greater than MaxChar
     704                 :            :          // assert if MaxChar is ever changed
     705                 :            :         OSL_ENSURE( MaxChar == 255, "MaxChar not 255" );
     706                 :            :         OSL_ENSURE(sizeof(UCHAR) == 1, "should be 1");
     707         [ #  # ]:          0 :         if (c>=MinChar /*&& c<=MaxChar*/)
     708                 :            :         {
     709 [ #  # ][ #  # ]:          0 :             ChrWidth=(sal_uInt16)rOut.GetTextWidth(rtl::OUString(reinterpret_cast<sal_Char*>(&c), 1, RTL_TEXTENCODING_IBM_437));
                 [ #  # ]
     710                 :            :         }
     711                 :            :         else
     712                 :            :         {
     713 [ #  # ][ #  # ]:          0 :             ChrWidth=(sal_uInt16)rOut.GetTextWidth(rtl::OUString(static_cast<sal_Unicode>('A')));
                 [ #  # ]
     714                 :            :         }
     715                 :            :     }
     716                 :          0 :     return ChrWidth;
     717                 :            : }
     718                 :            : 
     719                 :          0 : UCHAR ProcessChar(OutputDevice& rOut, UCHAR* TBuf, ProcChrSta& R, ObjTextType& Atr0,
     720                 :            :                   sal_uInt16& nChars, sal_uInt16 Rest,
     721                 :            :                   short* Line, UCHAR* cLine)
     722                 :            : {
     723                 :          0 :     sal_uInt16       KernDist=0;       // Wert fuer Kerning
     724                 :            :     sal_uInt16       ChrWidth;
     725                 :            :     UCHAR        c;
     726                 :            :     UCHAR        c1;
     727                 :            :     sal_Bool         AbsEnd;
     728                 :            : 
     729                 :          0 :     c=GetTextChar(TBuf,R.Index,Atr0,R.Attrib,Rest,sal_False); // versucht evtl. zu trennen, wenn Rest entsprechenden Wert besitzt
     730                 :            : 
     731 [ #  # ][ #  # ]:          0 :     AbsEnd=(c==AbsatzEnd || c==TextEnd);
     732         [ #  # ]:          0 :     if (AbsEnd==sal_False) {
     733                 :          0 :         R.OutCh=ConvertTextChar(c); // von HardTrenn nach '-', ...
     734 [ #  # ][ #  # ]:          0 :         R.Kapt=(R.Attrib.Schnitt & TextKaptBit) !=0 && UpcasePossible(R.OutCh);
     735         [ #  # ]:          0 :         if (R.Kapt) R.OutCh=Upcase(R.OutCh);
     736                 :          0 :         SetTextContext(rOut,R.Attrib,R.Kapt,0,1,1,1,1);
     737                 :            : 
     738         [ #  # ]:          0 :         if (R.Kapt) c1=Upcase(c); else c1=c;
     739                 :          0 :         ChrWidth=GetCharWidth(rOut,c1);
     740                 :            : 
     741         [ #  # ]:          0 :         if (R.Attrib.ZAbst!=100) { // Spezial-Zeichenabstand ?
     742                 :            :             sal_uLong Temp;
     743                 :          0 :             Temp=sal_uLong(ChrWidth)*sal_uLong(R.Attrib.ZAbst)/100;
     744                 :          0 :             ChrWidth=sal_uInt16(Temp);
     745                 :            :         }
     746                 :          0 :         nChars++;
     747         [ #  # ]:          0 :         if (R.ChrXP>32000) R.ChrXP=32000;
     748                 :          0 :         Line[nChars]=R.ChrXP-KernDist;
     749                 :          0 :         cLine[nChars]=c;
     750                 :          0 :         R.ChrXP+=ChrWidth-KernDist; // Position fuer den naechsten Character
     751                 :            :     }
     752                 :          0 :     return c;
     753                 :            : }
     754                 :            : 
     755                 :          0 : void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType& AktAtr,
     756                 :            :                 sal_uInt16 UmbWdt, sal_uInt16 AdjWdt,
     757                 :            :                 short* Line, sal_uInt16& nChars,
     758                 :            :                 double, double,
     759                 :            :                 UCHAR* cLine, sal_Bool TextFit)
     760                 :            : {
     761         [ #  # ]:          0 :     VirtualDevice vOut;
     762                 :            :     UCHAR        c,c0;
     763                 :            :     UCHAR        ct;
     764                 :            :     sal_Bool         First;               // erster Char ?
     765                 :          0 :     sal_uInt8         Just = 0;                // Absatzformatierung
     766                 :            :     sal_Bool         Border;              // Rand der Box erreicht ?
     767                 :            :     sal_Bool         Border0;
     768                 :            :     sal_Bool         AbsEnd;              // Ende des Absatzes erreicht ?
     769         [ #  # ]:          0 :     ProcChrSta*  R=new ProcChrSta;
     770         [ #  # ]:          0 :     ProcChrSta*  R0=new ProcChrSta;
     771         [ #  # ]:          0 :     ProcChrSta*  WErec=new ProcChrSta;
     772                 :            :     sal_uInt16       WEnChar;
     773         [ #  # ]:          0 :     ProcChrSta*  WErec0=new ProcChrSta;
     774                 :            :     sal_uInt16       WEnChar0;
     775         [ #  # ]:          0 :     ProcChrSta*  TRrec=new ProcChrSta;
     776                 :            :     sal_uInt16       TRnChar;
     777                 :            : 
     778                 :            :     sal_uInt16       WordEndCnt;          // Justieren und Trennen
     779                 :            :     sal_Bool         WordEnd;
     780                 :            :     sal_Bool         Trenn;
     781                 :            : 
     782                 :            :     short        BoxRest;             // zum Quetschen und formatieren
     783                 :            :     sal_uInt16       i,j,k,h;
     784                 :            :     sal_uInt16       re,li;
     785                 :            : 
     786 [ #  # ][ #  # ]:          0 :     vOut.SetMapMode(MapMode(MAP_10TH_MM,Point(),Fraction(1,4),Fraction(1,4)));
         [ #  # ][ #  # ]
                 [ #  # ]
     787                 :            : 
     788                 :          0 :     nChars=0;
     789         [ #  # ]:          0 :     SetTextContext(vOut,AktAtr,sal_False,0,1,1,1,1);
     790                 :          0 :     InitProcessCharState(*R,AktAtr,Index);
     791                 :          0 :     (*R0)=(*R); (*WErec)=(*R); WEnChar=0; c0=0; Border0=sal_False;
     792                 :          0 :     Border=sal_False; First=sal_True;
     793                 :          0 :     WordEndCnt=0;
     794                 :            : 
     795         [ #  # ]:          0 :     do {               // mal schauen, wieviele Worte so in die Zeile passen
     796 [ #  # ][ #  # ]:          0 :         if (Border) c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,DoTrenn,Line,cLine);
     797         [ #  # ]:          0 :         else        c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine);
     798 [ #  # ][ #  # ]:          0 :         AbsEnd=(c==AbsatzEnd || c==TextEnd);
     799                 :            :         //if not AbsEnd then
     800                 :            :         {
     801         [ #  # ]:          0 :             if (First) {
     802                 :          0 :                 Just=R->Attrib.Justify & 0x0F; // Absatzformat steht wenn, dann am Anfang
     803                 :            :             }
     804                 :          0 :             Border=R->ChrXP>UmbWdt;
     805 [ #  # ][ #  # ]:          0 :             WordEnd=(AbsEnd || (c==' ')) && (c0!=' ') && (c0!=0);
         [ #  # ][ #  # ]
     806                 :          0 :             Trenn=c=='-';
     807 [ #  # ][ #  # ]:          0 :             if (WordEnd && !Border0) {
     808                 :          0 :                 WordEndCnt++;
     809                 :          0 :                 (*WErec)=(*R0);
     810                 :          0 :                 WEnChar=nChars-1;
     811                 :            :             }
     812 [ #  # ][ #  # ]:          0 :             if (Trenn && !Border) {
     813                 :          0 :                 WordEndCnt++;
     814                 :          0 :                 (*WErec)=(*R);
     815                 :          0 :                 WEnChar=nChars;
     816                 :            :             }
     817                 :            :         }
     818                 :          0 :         (*R0)=(*R); c0=c;
     819                 :          0 :         Border0=Border;
     820                 :          0 :         First=sal_False;
     821 [ #  # ][ #  # ]:          0 :         AbsEnd=AbsEnd || (nChars>=MaxLineChars);
     822 [ #  # ][ #  # ]:          0 :     } while (!(AbsEnd || (Border && ((WordEndCnt>0) || WordEnd || Trenn))));
         [ #  # ][ #  # ]
                 [ #  # ]
     823                 :            : 
     824         [ #  # ]:          0 :     if (Border) { // Trennen und Quetschen
     825                 :          0 :         (*WErec0)=(*WErec); WEnChar0=WEnChar;
     826                 :          0 :         AbsEnd=sal_False; c0=0;
     827                 :          0 :         (*R)=(*WErec); nChars=WEnChar;
     828                 :          0 :         (*TRrec)=(*R); TRnChar=nChars;
     829                 :          0 :         Border0=sal_False; Border=sal_False;
     830         [ #  # ]:          0 :         do {                // erst mal gucken wieviele Silben noch reinpassen
     831         [ #  # ]:          0 :             ct=ProcessChar(vOut,TBuf,*TRrec,Atr0,TRnChar,DoTrenn,Line,cLine);
     832         [ #  # ]:          0 :             c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine);
     833 [ #  # ][ #  # ]:          0 :             AbsEnd=(ct==AbsatzEnd) || (ct==TextEnd) || (nChars>=MaxLineChars);
                 [ #  # ]
     834                 :            : 
     835                 :          0 :             Border=TRrec->ChrXP>UmbWdt;
     836 [ #  # ][ #  # ]:          0 :             WordEnd=AbsEnd || ((AbsEnd || (c==' ')) && (c0!=' ') && (c0!=0));
         [ #  # ][ #  # ]
                 [ #  # ]
     837                 :          0 :             Trenn=ct=='-';
     838 [ #  # ][ #  # ]:          0 :             if (WordEnd && (!Border0 || (WordEndCnt==0))) {
                 [ #  # ]
     839                 :          0 :                 WordEndCnt++;
     840                 :          0 :                 (*WErec)=(*R0);
     841         [ #  # ]:          0 :                 if (AbsEnd) WEnChar=nChars; else WEnChar=nChars-1;
     842                 :          0 :                 (*TRrec)=(*R); TRnChar=nChars;                       // zum weitersuchen
     843                 :            :             }
     844 [ #  # ][ #  # ]:          0 :             if (Trenn && (!Border || (WordEndCnt==0))) {
                 [ #  # ]
     845                 :          0 :                 WordEndCnt++;                 // merken, dass man hier trennen kann
     846                 :          0 :                 (*WErec)=(*TRrec);
     847                 :          0 :                 WEnChar=TRnChar;
     848                 :          0 :                 (*TRrec)=(*R); TRnChar=nChars;                       // zum weitersuchen
     849                 :            :             }
     850                 :          0 :             (*R0)=(*R); c0=c;
     851                 :          0 :             Border0=Border;
     852                 :          0 :             Border=R->ChrXP>UmbWdt;
     853 [ #  # ][ #  # ]:          0 :         } while (!(AbsEnd || (Border && ((WordEndCnt>0) || WordEnd || Trenn))));
         [ #  # ][ #  # ]
                 [ #  # ]
     854                 :            : 
     855         [ #  # ]:          0 :         while (WErec0->Index<WErec->Index) { // damit Line[] auch garantiert stimmt }
     856         [ #  # ]:          0 :             c=ProcessChar(vOut,TBuf,*WErec0,Atr0,WEnChar0,WEnChar-WEnChar0-1,Line,cLine);
     857                 :            :         }
     858                 :            : 
     859                 :          0 :         (*R)=(*WErec); nChars=WEnChar;
     860                 :            : 
     861         [ #  # ]:          0 :         if (UmbWdt>=R->ChrXP) {
     862                 :          0 :             BoxRest=UmbWdt-R->ChrXP;
     863                 :            :         } else {                                       // Zusammenquetschen
     864                 :          0 :             BoxRest=R->ChrXP-UmbWdt;                     // um soviel muss gequetscht werden
     865         [ #  # ]:          0 :             for (i=2;i<=nChars;i++) {                  // 1. CharPosition bleibt !
     866                 :          0 :                 Line[i]-=(i-1)*(BoxRest) /(nChars-1);
     867                 :            :             }
     868                 :          0 :             R->ChrXP=UmbWdt;
     869                 :          0 :             Line[nChars+1]=UmbWdt;
     870                 :            :         }
     871                 :            :     }
     872                 :            : 
     873         [ #  # ]:          0 :     if (!AbsEnd) {
     874         [ #  # ]:          0 :         do {                                         // Leerzeichen weglesen
     875                 :          0 :             (*WErec)=(*R);
     876         [ #  # ]:          0 :             c=GetTextChar(TBuf,R->Index,Atr0,R->Attrib,NoTrenn,sal_False);
     877                 :          0 :             nChars++;
     878                 :          0 :             Line[nChars]=R->ChrXP;
     879                 :          0 :             cLine[nChars]=c;
     880                 :            :         } while (c==' ');
     881 [ #  # ][ #  # ]:          0 :         if (c!=' ' && c!=AbsatzEnd && c!=TextEnd) {
                 [ #  # ]
     882                 :          0 :             nChars--;
     883                 :          0 :             (*R)=(*WErec);
     884                 :            :         }
     885                 :            :     }
     886                 :            : 
     887 [ #  # ][ #  # ]:          0 :     if (AbsEnd && nChars<MaxLineChars) { // Ausrichten, statt Blocksatz aber linksbuendig
     888         [ #  # ]:          0 :         if (Just==3) Just=0;
     889                 :          0 :         nChars++; Line[nChars]=R->ChrXP; // Damit AbsatzEnde auch weggelesen wird
     890                 :          0 :         Line[nChars+1]=R->ChrXP;         // denn die Breite von CR oder #0 ist nun mal sehr klein
     891 [ #  # ][ #  # ]:          0 :         if (TBuf[R->Index-1]!=AbsatzEnd &&  TBuf[R->Index-1]!=TextEnd) {
     892         [ #  # ]:          0 :             c=GetTextChar(TBuf,R->Index,Atr0,R->Attrib,NoTrenn,sal_False); // Kleine Korrektur. Notig, wenn nur 1 Wort in
     893                 :            :         }
     894                 :            :     }
     895                 :            : 
     896                 :          0 :     BoxRest=AdjWdt-R->ChrXP;
     897         [ #  # ]:          0 :     if (TextFit) Just=THJustLeft;
     898                 :            : 
     899   [ #  #  #  #  :          0 :     switch (Just) {
                   #  # ]
     900                 :          0 :         case THJustLeft: break;                                // Links
     901                 :            :         case THJustCenter: {
     902                 :          0 :             BoxRest=BoxRest /2;                                // Mitte
     903         [ #  # ]:          0 :             for (i=1;i<=nChars;i++) Line[i]=Line[i]+BoxRest;
     904                 :          0 :         } break;
     905                 :            :         case THJustRight: {                                    // Rechts
     906         [ #  # ]:          0 :             for (i=1;i<=nChars;i++) Line[i]=Line[i]+BoxRest;
     907                 :          0 :         } break;
     908                 :            :         case THJustDrvOut:
     909                 :            :         case THJustBlock: {                                    // Block und Austreibend
     910                 :          0 :             re=nChars;
     911         [ #  # ]:          0 :             if (Just==THJustDrvOut) re--;
     912 [ #  # ][ #  # ]:          0 :             while (re>=1 && (cLine[re]==' ' || cLine[re]==TextEnd || cLine[re]==AbsatzEnd)) re--;
         [ #  # ][ #  # ]
                 [ #  # ]
     913                 :          0 :             li=1;
     914 [ #  # ][ #  # ]:          0 :             while (li<=re && (cLine[li]==' ' || cLine[li]==TextEnd || cLine[li]==AbsatzEnd)) li++;
         [ #  # ][ #  # ]
                 [ #  # ]
     915         [ #  # ]:          0 :             if (Just==THJustDrvOut) BoxRest=AdjWdt-Line[re+1];
     916                 :            : 
     917                 :          0 :             j=0;                        // Anzahl der Spaces ermitteln
     918         [ #  # ]:          0 :             for (i=li;i<=re;i++) {
     919         [ #  # ]:          0 :                 if (cLine[i]==' ') {
     920                 :          0 :                     j++;
     921                 :            :                 }
     922                 :            :             }
     923                 :            : 
     924         [ #  # ]:          0 :             if (j==0) {                        // nur 1 Wort ?  -> Strecken !
     925         [ #  # ]:          0 :                 for (i=li+1;i<=re;i++) {       // von links nach rechts
     926         [ #  # ]:          0 :                   Line[i]=Line[i]+MulDiv(i-li,BoxRest,re-li+1-1);
     927                 :            :                 }
     928                 :            :             } else {
     929                 :          0 :                 k=0; h=0;
     930         [ #  # ]:          0 :                 for (i=li;i<=re;i++) {          // j Spaces aufbohren !
     931         [ #  # ]:          0 :                     if (cLine[i]==' ') {        // Space gefunden !
     932                 :          0 :                         k++;
     933         [ #  # ]:          0 :                         h=MulDiv(k,BoxRest,j);
     934                 :            :                     }
     935                 :          0 :                     Line[i]=Line[i]+h;
     936                 :            :                 }
     937                 :            :             }
     938         [ #  # ]:          0 :             for (i=re+1;i<=nChars;i++) Line[i]=Line[i]+BoxRest; // und den Rest anpassen
     939                 :          0 :             Line[nChars+1]=AdjWdt;
     940                 :          0 :         } break;
     941                 :            :         case THJustLocked: {                                    //Gesperrt
     942                 :          0 :             re=nChars-1;
     943 [ #  # ][ #  # ]:          0 :             while (re>=1 && (cLine[re]==' ' || cLine[re]==TextEnd || cLine[re]==AbsatzEnd)) re--;
         [ #  # ][ #  # ]
                 [ #  # ]
     944                 :          0 :             li=1;
     945 [ #  # ][ #  # ]:          0 :             while (li<=re && (cLine[li]==' ' || cLine[li]==TextEnd || cLine[li]==AbsatzEnd)) li++;
         [ #  # ][ #  # ]
                 [ #  # ]
     946                 :          0 :             BoxRest=AdjWdt-Line[re+1];
     947         [ #  # ]:          0 :             for (i=li+1;i<=re;i++) {         // Strecken von links nach rechts
     948         [ #  # ]:          0 :                 Line[i]=Line[i]+MulDiv(i-li,BoxRest,re-li+1-1);
     949                 :            :             }
     950         [ #  # ]:          0 :             for (i=re+1;i<=nChars;i++) Line[i]=Line[i]+BoxRest; // und den Rest anpassen
     951                 :          0 :             Line[nChars+1]=AdjWdt;
     952                 :          0 :         } break;
     953                 :            :     }
     954                 :          0 :     Index=R->Index;
     955                 :          0 :     AktAtr=R->Attrib;
     956                 :          0 :     delete R;
     957                 :          0 :     delete R0;
     958                 :          0 :     delete WErec;
     959                 :          0 :     delete WErec0;
     960         [ #  # ]:          0 :     delete TRrec;
     961                 :          0 : }
     962                 :            : 
     963                 :            : 
     964                 :            : 
     965                 :            : // End of Absatz.Pas
     966                 :            : /////////////////////////////////////////////////////////////////////////////////
     967                 :            : /////////////////////////////////////////////////////////////////////////////////
     968                 :            : /////////////////////////////////////////////////////////////////////////////////
     969                 :            : 
     970                 :            : 
     971                 :            : /////////////////////////////////////////////////////////////////////////////////
     972                 :            : /////////////////////////////////////////////////////////////////////////////////
     973                 :            : /////////////////////////////////////////////////////////////////////////////////
     974                 :            : // DrawText.Pas
     975                 :            : 
     976                 :          0 : void DrawChar(OutputDevice& rOut, UCHAR c, ObjTextType T, PointType Pos, sal_uInt16 DrehWink,
     977                 :            :               sal_uInt16 FitXMul, sal_uInt16 FitXDiv, sal_uInt16 FitYMul, sal_uInt16 FitYDiv)
     978                 :            : {
     979         [ #  # ]:          0 :     SetTextContext(rOut,T,UpcasePossible(c),DrehWink,FitXMul,FitXDiv,FitYMul,FitYDiv);
     980 [ #  # ][ #  # ]:          0 :     if ((T.Schnitt & TextKaptBit)!=0 && UpcasePossible(c)) c=Upcase(c);
                 [ #  # ]
     981                 :            :     rtl::OUString s(reinterpret_cast<const sal_Char*>(&c), 1,
     982         [ #  # ]:          0 :         RTL_TEXTENCODING_IBM_437);
     983 [ #  # ][ #  # ]:          0 :     rOut.DrawText( Point( Pos.x, Pos.y ), s );
                 [ #  # ]
     984                 :          0 : }
     985                 :            : 
     986                 :            : /*************************************************************************
     987                 :            : |*
     988                 :            : |*    TextType::Draw()
     989                 :            : |*
     990                 :            : *************************************************************************/
     991                 :          0 : void TextType::Draw(OutputDevice& rOut)
     992                 :            : {
     993         [ #  # ]:          0 :     if ((Flags & TextOutlBit)!=0) return;   // Sourcetext fuer Outliner !!
     994                 :            : 
     995                 :            :     ObjTextType T1,T2;
     996                 :            :     sal_uInt16 Index1;
     997                 :            :     sal_uInt16 Index2;
     998                 :          0 :     UCHAR  c = TextEnd;
     999                 :            :     sal_uInt16 l;                // Anzahl der Zeichen in der Zeile
    1000                 :            :     sal_uInt16 i;
    1001                 :            :     short  yPos0;
    1002                 :            :     short  xPos;
    1003                 :            :     short  yPos;
    1004                 :            :     sal_uInt16 LF;
    1005                 :            :     sal_uInt16 MaxGrad;
    1006                 :            :     short  xSize;
    1007                 :            :     short  xSAdj;
    1008                 :            :     short  ySize;
    1009                 :            :     double sn,cs;
    1010                 :            :     sal_uInt16 TopToBase;
    1011                 :          0 :     sal_Bool   Ende = 0;
    1012                 :            :     sal_uInt16 lc;
    1013                 :            :     sal_Bool   LineFit; // FitSize.x=0? oder Flags -> jede Zeile stretchen
    1014                 :            :     sal_Bool   TextFit;
    1015                 :            :     short* xLine;
    1016                 :            :     UCHAR* cLine;   // Buffer fuer FormatLine
    1017                 :            :     sal_uInt16 FitXMul;
    1018                 :            :     sal_uInt16 FitXDiv;
    1019                 :            :     sal_uInt16 FitYMul;
    1020                 :            :     sal_uInt16 FitYDiv;
    1021                 :            :     sal_Bool   Fehler;
    1022                 :          0 :     UCHAR* Buf=Buffer; // Zeiger auf die Buchstaben
    1023                 :            : 
    1024         [ #  # ]:          0 :     pSgfFonts->ReadList();
    1025         [ #  # ]:          0 :     xLine=new short[ChrXPosArrSize];
    1026         [ #  # ]:          0 :     cLine=new UCHAR[CharLineSize];
    1027                 :            : 
    1028                 :          0 :     TextFit=(Flags & TextFitBits)!=0;
    1029                 :          0 :     LineFit=sal_False;
    1030                 :          0 :     LineFit=((Flags & TextFitZBit)!=0);
    1031 [ #  # ][ #  # ]:          0 :     if (TextFit && FitSize.x==0) LineFit=sal_True;
    1032                 :            : 
    1033         [ #  # ]:          0 :     if (DrehWink==0) {
    1034                 :          0 :         sn=0.0;
    1035                 :          0 :         cs=1.0;
    1036                 :            :     } else {
    1037                 :          0 :         sn=sin(double(DrehWink)*3.14159265359/18000);
    1038                 :          0 :         cs=cos(double(DrehWink)*3.14159265359/18000);
    1039                 :            :     }
    1040                 :            : 
    1041                 :          0 :     T1=T; Index1=0; yPos=0; xPos=0;
    1042         [ #  # ]:          0 :     if (TextFit) {
    1043                 :          0 :         ySize=Pos2.y-Pos1.y;
    1044                 :          0 :         xSize=32000 /2;      // Umbruch
    1045                 :          0 :         xSAdj=Pos2.x-Pos1.x; // zum Ausrichten bei Zentriert/Blocksatz
    1046                 :            :         //if (xSize<=0) { xSize=32000 /2; LineFit=sal_True; }
    1047         [ #  # ]:          0 :         FitXMul=sal::static_int_cast< sal_uInt16 >(abs(Pos2.x-Pos1.x)); FitXDiv=FitSize.x; if (FitXDiv==0) FitXDiv=1;
    1048         [ #  # ]:          0 :         FitYMul=sal::static_int_cast< sal_uInt16 >(abs(Pos2.y-Pos1.y)); FitYDiv=FitSize.y; if (FitYDiv==0) FitYDiv=1;
    1049                 :            :     } else {
    1050                 :          0 :         xSize=Pos2.x-Pos1.x;
    1051                 :          0 :         xSAdj=xSize;
    1052                 :          0 :         ySize=Pos2.y-Pos1.y;
    1053                 :          0 :         FitXMul=1; FitXDiv=1;
    1054                 :          0 :         FitYMul=1; FitYDiv=1;
    1055                 :            :     }
    1056         [ #  # ]:          0 :     if (xSize<0) xSize=0;
    1057         [ #  # ]:          0 :     if (xSAdj<0) xSAdj=0;
    1058                 :            : 
    1059 [ #  # ][ #  # ]:          0 :     do {
         [ #  # ][ #  # ]
    1060                 :          0 :         T2=T1; Index2=Index1;
    1061         [ #  # ]:          0 :         FormatLine(Buf,Index2,T,T2,xSize,xSAdj,xLine,l,sn,cs,cLine,LineFit);
    1062                 :          0 :         Fehler=(Index2==Index1);
    1063         [ #  # ]:          0 :         if (!Fehler) {
    1064         [ #  # ]:          0 :             lc=GetLineFeed(Buf,Index1,T,T1,l,LF,MaxGrad);
    1065         [ #  # ]:          0 :             if (TextFit) {
    1066         [ #  # ]:          0 :                 if (LineFit) FitXDiv=xLine[lc+1];
    1067         [ #  # ]:          0 :                 if (FitXDiv>0) {
    1068                 :            :                     long Temp;
    1069         [ #  # ]:          0 :                     for (i=1;i<=l+1;i++) {
    1070                 :          0 :                         Temp=long(xLine[i])*long(FitXMul) /long(FitXDiv);
    1071                 :          0 :                         xLine[i]=short(Temp);
    1072                 :            :                     }
    1073         [ #  # ]:          0 :                     LF=MulDiv(LF,FitYMul,FitYDiv);
    1074         [ #  # ]:          0 :                     MaxGrad=MulDiv(MaxGrad,FitYMul,FitYDiv);
    1075                 :            :                 } else {
    1076                 :          0 :                     FitXDiv=1; // 0 gibts nicht
    1077                 :            :                 }
    1078                 :            :             }
    1079                 :          0 :             yPos0=yPos;
    1080                 :          0 :             TopToBase=GetTopToBaseLine(MaxGrad);
    1081                 :          0 :             yPos=yPos+TopToBase;
    1082 [ #  # ][ #  # ]:          0 :             Ende=(yPos0+short(MulDiv(MaxGrad,CharTopToBtm,100))>ySize) && !TextFit;
                 [ #  # ]
    1083         [ #  # ]:          0 :             if (!Ende) {
    1084                 :          0 :                 T2=T1; Index2=Index1;
    1085                 :          0 :                 i=1;
    1086         [ #  # ]:          0 :                 while (i<=l) {
    1087         [ #  # ]:          0 :                     c=GetTextCharConv(Buf,Index2,T,T2,l-i,sal_False);
    1088                 :            :                     long xp1,yp1;       // wegen Overflowgefahr
    1089                 :            :                     PointType Pos;
    1090                 :          0 :                     xp1=long(Pos1.x)+xPos+long(xLine[i]);
    1091                 :          0 :                     yp1=long(Pos1.y)+yPos;
    1092 [ #  # ][ #  # ]:          0 :                     if (xp1>32000) xp1=32000; if (xp1<-12000) xp1=-12000;
    1093 [ #  # ][ #  # ]:          0 :                     if (yp1>32000) yp1=32000; if (yp1<-12000) yp1=-12000;
    1094                 :          0 :                     Pos.x=short(xp1);
    1095                 :          0 :                     Pos.y=short(yp1);
    1096                 :            : 
    1097 [ #  # ][ #  # ]:          0 :                     if (DrehWink!=0) RotatePoint(Pos,Pos1.x,Pos1.y,sn,cs);
    1098         [ #  # ]:          0 :                     DrawChar(rOut,c,T2,Pos,DrehWink,FitXMul,FitXDiv,FitYMul,FitYDiv);
    1099                 :          0 :                     i++;
    1100                 :            :                 } // while i<=l
    1101                 :          0 :                 yPos=yPos0+LF;
    1102                 :          0 :                 T1=T2; Index1=Index2; // Fuer die naechste Zeile
    1103                 :            :             } // if ObjMin.y+yPos<=Obj_Max.y
    1104                 :            :         } // if !Fehler
    1105                 :            :     } while (c!=TextEnd && !Ende && !Fehler);
    1106         [ #  # ]:          0 :     delete[] cLine;
    1107         [ #  # ]:          0 :     delete[] xLine;
    1108                 :            : }
    1109                 :            : 
    1110                 :            : // End of DrawText.Pas
    1111                 :            : /////////////////////////////////////////////////////////////////////////////////
    1112                 :            : /////////////////////////////////////////////////////////////////////////////////
    1113                 :            : /////////////////////////////////////////////////////////////////////////////////
    1114                 :            : 
    1115                 :            : // nicht mehr benoetigt, da der Pointer nun extra gefuehrt wird
    1116                 :            : // (DEC Alpha hat naemlich 64Bit-Pointer!)
    1117                 :            : //UCHAR* TextType::GetBufPtr()
    1118                 :            : //{
    1119                 :            : //    sal_uLong Temp;
    1120                 :            : //    Temp=sal_uLong(BufLo)+0x00010000*sal_uLong(BufHi);
    1121                 :            : //    return (UCHAR*)Temp;
    1122                 :            : //}
    1123                 :            : //
    1124                 :            : //void TextType::SetBufPtr(UCHAR* Ptr)
    1125                 :            : //{
    1126                 :            : //    sal_uLong Temp=(sal_uLong)Ptr;
    1127                 :            : //    BufLo=sal_uInt16(Temp & 0x0000FFFF);
    1128                 :            : //    BufHi=sal_uInt16((Temp & 0xFFFF0000)>>16);
    1129                 :            : //}
    1130                 :            : 
    1131                 :          0 : sal_uInt32 ObjTextType::GetFont()
    1132                 :            : {
    1133                 :          0 :     return sal_uLong(FontLo)+0x00010000*sal_uLong(FontHi);
    1134                 :            : }
    1135                 :            : 
    1136                 :          0 : void ObjTextType::SetFont(sal_uInt32 FontID)
    1137                 :            : {
    1138                 :          0 :     FontLo=sal_uInt16(FontID & 0x0000FFFF);
    1139                 :          0 :     FontHi=sal_uInt16((FontID & 0xFFFF0000)>>16);
    1140                 :          0 : }
    1141                 :            : 
    1142                 :            : 
    1143                 :            : /////////////////////////////////////////////////////////////////////////////////
    1144                 :            : // SGF.Ini lesen ////////////////////////////////////////////////////////////////
    1145                 :            : /////////////////////////////////////////////////////////////////////////////////
    1146                 :          0 : SgfFontOne::SgfFontOne()
    1147                 :            : {
    1148                 :          0 :     Next=NULL;
    1149                 :          0 :     IFID=0;
    1150                 :          0 :     Bold=sal_False;
    1151                 :          0 :     Ital=sal_False;
    1152                 :          0 :     Sans=sal_False;
    1153                 :          0 :     Serf=sal_False;
    1154                 :          0 :     Fixd=sal_False;
    1155                 :          0 :     SVFamil=FAMILY_DONTKNOW;
    1156                 :          0 :     SVChSet=RTL_TEXTENCODING_DONTKNOW;
    1157                 :          0 :     SVWidth=40;
    1158                 :          0 : }
    1159                 :            : 
    1160                 :          0 : void SgfFontOne::ReadOne( const rtl::OString& rID, rtl::OString& Dsc )
    1161                 :            : {
    1162 [ #  # ][ #  # ]:          0 :     if ( Dsc.getLength() < 4 || ( Dsc[0] != '(' ) )
                 [ #  # ]
    1163                 :          0 :         return;
    1164                 :          0 :     sal_Int32 i=1;   // Erster Buchstabe des IF-Fontnamen. Davor ist eine '('
    1165 [ #  # ][ #  # ]:          0 :     while ( i < Dsc.getLength() && ( Dsc[i] !=')' ) )
                 [ #  # ]
    1166                 :          0 :         i++;
    1167                 :          0 :     Dsc = Dsc.copy(i+1);                                // IF-Fontname loeschen inkl. ()
    1168                 :            : 
    1169 [ #  # ][ #  # ]:          0 :     if ( Dsc.getLength() < 2 || ( Dsc[Dsc.getLength() - 1] !=')' ) )
                 [ #  # ]
    1170                 :          0 :         return;
    1171                 :          0 :     i=Dsc.getLength()-2;                                // hier ist die ')' des SV-Fontnames
    1172                 :          0 :     sal_Int32 j=0;
    1173 [ #  # ][ #  # ]:          0 :     while ( i > 0 && ( Dsc[i] != '(' ) )
                 [ #  # ]
    1174                 :            :     {
    1175                 :          0 :         i--;
    1176                 :          0 :         j++;
    1177                 :            :     }
    1178 [ #  # ][ #  # ]:          0 :     SVFName = rtl::OStringToOUString(Dsc.copy(i+1,j), RTL_TEXTENCODING_IBM_437); // SV-Fontname rausholen
    1179 [ #  # ][ #  # ]:          0 :     Dsc = rtl::OStringBuffer(Dsc).remove(i,j).makeStringAndClear();
    1180                 :            : 
    1181                 :          0 :     IFID = (sal_uInt32)rID.toInt32();
    1182                 :          0 :     sal_Int32 nTokenCount = comphelper::string::getTokenCount(Dsc, ' ');
    1183         [ #  # ]:          0 :     for (sal_Int32 nIdx = 0; nIdx < nTokenCount; ++nIdx)
    1184                 :            :     {
    1185                 :          0 :         rtl::OString s(Dsc.getToken(nIdx, ' '));
    1186         [ #  # ]:          0 :         if (!s.isEmpty())
    1187                 :            :         {
    1188                 :          0 :             s = s.toAsciiUpperCase();
    1189         [ #  # ]:          0 :             if      (s.matchL(RTL_CONSTASCII_STRINGPARAM("BOLD"))) Bold=sal_True;
    1190         [ #  # ]:          0 :             else if (s.matchL(RTL_CONSTASCII_STRINGPARAM("ITAL"))) Ital=sal_True;
    1191         [ #  # ]:          0 :             else if (s.matchL(RTL_CONSTASCII_STRINGPARAM("SERF"))) Serf=sal_True;
    1192         [ #  # ]:          0 :             else if (s.matchL(RTL_CONSTASCII_STRINGPARAM("SANS"))) Sans=sal_True;
    1193         [ #  # ]:          0 :             else if (s.matchL(RTL_CONSTASCII_STRINGPARAM("FIXD"))) Fixd=sal_True;
    1194         [ #  # ]:          0 :             else if (s.matchL(RTL_CONSTASCII_STRINGPARAM("ROMAN"))) SVFamil=FAMILY_ROMAN;
    1195         [ #  # ]:          0 :             else if (s.matchL(RTL_CONSTASCII_STRINGPARAM("SWISS"))) SVFamil=FAMILY_SWISS;
    1196         [ #  # ]:          0 :             else if (s.matchL(RTL_CONSTASCII_STRINGPARAM("MODERN"))) SVFamil=FAMILY_MODERN;
    1197         [ #  # ]:          0 :             else if (s.matchL(RTL_CONSTASCII_STRINGPARAM("SCRIPT"))) SVFamil=FAMILY_SCRIPT;
    1198         [ #  # ]:          0 :             else if (s.matchL(RTL_CONSTASCII_STRINGPARAM("DECORA"))) SVFamil=FAMILY_DECORATIVE;
    1199         [ #  # ]:          0 :             else if (s.matchL(RTL_CONSTASCII_STRINGPARAM("ANSI"))) SVChSet=RTL_TEXTENCODING_MS_1252;
    1200         [ #  # ]:          0 :             else if (s.matchL(RTL_CONSTASCII_STRINGPARAM("IBMPC"))) SVChSet=RTL_TEXTENCODING_IBM_850;
    1201         [ #  # ]:          0 :             else if (s.matchL(RTL_CONSTASCII_STRINGPARAM("MAC"))) SVChSet=RTL_TEXTENCODING_APPLE_ROMAN;
    1202         [ #  # ]:          0 :             else if (s.matchL(RTL_CONSTASCII_STRINGPARAM("SYMBOL"))) SVChSet=RTL_TEXTENCODING_SYMBOL;
    1203 [ #  # ][ #  # ]:          0 :             else if (s.matchL(RTL_CONSTASCII_STRINGPARAM("SYSTEM"))) SVChSet = osl_getThreadTextEncoding();
    1204 [ #  # ][ #  # ]:          0 :             else if (comphelper::string::isdigitAsciiString(s) ) SVWidth=sal::static_int_cast< sal_uInt16 >(s.toInt32());
    1205                 :            :         }
    1206                 :          0 :     }
    1207                 :            : }
    1208                 :            : 
    1209                 :            : /////////////////////////////////////////////////////////////////////////////////
    1210                 :            : 
    1211                 :          6 : SgfFontLst::SgfFontLst()
    1212                 :            : {
    1213                 :          6 :     pList=NULL;
    1214                 :          6 :     Last=NULL;
    1215                 :          6 :     LastID=0;
    1216                 :          6 :     LastLn=NULL;
    1217                 :          6 :     Tried=sal_False;
    1218                 :          6 : }
    1219                 :            : 
    1220                 :          6 : SgfFontLst::~SgfFontLst()
    1221                 :            : {
    1222         [ +  - ]:          6 :     RausList();
    1223                 :          6 : }
    1224                 :            : 
    1225                 :          6 : void SgfFontLst::RausList()
    1226                 :            : {
    1227                 :            :     SgfFontOne* P;
    1228                 :            :     SgfFontOne* P1;
    1229                 :          6 :     P=pList;
    1230         [ -  + ]:          6 :     while (P!=NULL) {
    1231                 :          0 :         P1=P->Next;
    1232         [ #  # ]:          0 :         delete P;
    1233                 :          0 :         P=P1;
    1234                 :            :     }
    1235                 :          6 :     pList=NULL;
    1236                 :          6 :     Last=NULL;
    1237                 :          6 :     Tried=sal_False;
    1238                 :          6 :     LastID=0;
    1239                 :          6 :     LastLn=NULL;
    1240                 :          6 : }
    1241                 :            : 
    1242                 :          6 : void SgfFontLst::AssignFN(const String& rFName)
    1243                 :          6 : {   FNam=rFName;   }
    1244                 :            : 
    1245                 :          0 : void SgfFontLst::ReadList()
    1246                 :            : {
    1247         [ #  # ]:          0 :     if (!Tried)
    1248                 :            :     {
    1249                 :          0 :         Tried=sal_True;
    1250                 :          0 :         LastID=0;
    1251                 :          0 :         LastLn=NULL;
    1252         [ #  # ]:          0 :         SgfFontOne* P,P1;
    1253 [ #  # ][ #  # ]:          0 :         Config aCfg(FNam);
    1254         [ #  # ]:          0 :         aCfg.SetGroup("SGV Fonts fuer StarView");
    1255         [ #  # ]:          0 :         sal_uInt16 Anz=aCfg.GetKeyCount();
    1256                 :            :         sal_uInt16 i;
    1257                 :          0 :         rtl::OString FID;
    1258                 :          0 :         rtl::OString Dsc;
    1259                 :            : 
    1260         [ #  # ]:          0 :         for (i=0;i<Anz;i++)
    1261                 :            :         {
    1262         [ #  # ]:          0 :             FID = comphelper::string::remove(aCfg.GetKeyName(i), ' ');
    1263         [ #  # ]:          0 :             Dsc = aCfg.ReadKey( i );
    1264 [ #  # ][ #  # ]:          0 :             if (comphelper::string::isdigitAsciiString(FID))
    1265                 :            :             {
    1266 [ #  # ][ #  # ]:          0 :                 P=new SgfFontOne;                                   // neuer Eintrag
    1267         [ #  # ]:          0 :                 if (Last!=NULL) Last->Next=P; else pList=P; Last=P; // einklinken
    1268         [ #  # ]:          0 :                 P->ReadOne(FID,Dsc);                                // und Zeile interpretieren
    1269                 :            :             }
    1270 [ #  # ][ #  # ]:          0 :         }
    1271                 :            :     }
    1272                 :          0 : }
    1273                 :            : 
    1274                 :          0 : SgfFontOne* SgfFontLst::GetFontDesc(sal_uInt32 ID)
    1275                 :            : {
    1276         [ #  # ]:          0 :     if (ID!=LastID) {
    1277                 :            :         SgfFontOne* P;
    1278                 :          0 :         P=pList;
    1279 [ #  # ][ #  # ]:          0 :         while (P!=NULL && P->IFID!=ID) P=P->Next;
                 [ #  # ]
    1280                 :          0 :         LastID=ID;
    1281                 :          0 :         LastLn=P;
    1282                 :            :     }
    1283                 :          0 :     return LastLn;
    1284                 :            : }
    1285                 :            : 
    1286                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10