summaryrefslogtreecommitdiff
path: root/goodies/source
diff options
context:
space:
mode:
Diffstat (limited to 'goodies/source')
-rw-r--r--goodies/source/base3d/b3dcolor.cxx364
-rw-r--r--goodies/source/base3d/b3dcommn.cxx1415
-rw-r--r--goodies/source/base3d/b3dcommn.hxx165
-rw-r--r--goodies/source/base3d/b3dcompo.cxx1180
-rw-r--r--goodies/source/base3d/b3ddeflt.cxx1786
-rw-r--r--goodies/source/base3d/b3ddeflt.hxx233
-rw-r--r--goodies/source/base3d/b3dentty.cxx366
-rw-r--r--goodies/source/base3d/b3dgeom.cxx982
-rw-r--r--goodies/source/base3d/b3dlight.cxx870
-rw-r--r--goodies/source/base3d/b3dopngl.cxx1502
-rw-r--r--goodies/source/base3d/b3dopngl.hxx223
-rw-r--r--goodies/source/base3d/b3dtex.cxx1176
-rw-r--r--goodies/source/base3d/b3dtrans.cxx936
-rw-r--r--goodies/source/base3d/base3d.cxx1268
-rw-r--r--goodies/source/base3d/makefile.mk124
-rw-r--r--goodies/source/base3d/matril3d.cxx191
-rw-r--r--goodies/source/filter.vcl/egif/dlgegif.cxx137
-rw-r--r--goodies/source/filter.vcl/egif/dlgegif.hrc70
-rw-r--r--goodies/source/filter.vcl/egif/dlgegif.hxx101
-rw-r--r--goodies/source/filter.vcl/egif/dlgegif.src230
-rw-r--r--goodies/source/filter.vcl/egif/egif.cxx653
-rw-r--r--goodies/source/filter.vcl/egif/egifstr.src73
-rw-r--r--goodies/source/filter.vcl/egif/giflzwc.cxx287
-rw-r--r--goodies/source/filter.vcl/egif/giflzwc.hxx99
-rw-r--r--goodies/source/filter.vcl/egif/makefile.mk188
-rw-r--r--goodies/source/filter.vcl/egif/strings.hrc62
-rw-r--r--goodies/source/filter.vcl/eos2met/dlgeos2.cxx259
-rw-r--r--goodies/source/filter.vcl/eos2met/dlgeos2.hrc75
-rw-r--r--goodies/source/filter.vcl/eos2met/dlgeos2.hxx111
-rw-r--r--goodies/source/filter.vcl/eos2met/dlgeos2.src318
-rw-r--r--goodies/source/filter.vcl/eos2met/eos2met.cxx2667
-rw-r--r--goodies/source/filter.vcl/eos2met/eos2mstr.src77
-rw-r--r--goodies/source/filter.vcl/eos2met/makefile.mk180
-rw-r--r--goodies/source/filter.vcl/eos2met/strings.hrc64
-rw-r--r--goodies/source/filter.vcl/epbm/dlgepbm.cxx126
-rw-r--r--goodies/source/filter.vcl/epbm/dlgepbm.hrc68
-rw-r--r--goodies/source/filter.vcl/epbm/dlgepbm.hxx101
-rw-r--r--goodies/source/filter.vcl/epbm/dlgepbm.src198
-rw-r--r--goodies/source/filter.vcl/epbm/epbm.cxx319
-rw-r--r--goodies/source/filter.vcl/epbm/epbmstr.src69
-rw-r--r--goodies/source/filter.vcl/epbm/makefile.mk184
-rw-r--r--goodies/source/filter.vcl/epbm/strings.hrc61
-rw-r--r--goodies/source/filter.vcl/epgm/dlgepgm.cxx123
-rw-r--r--goodies/source/filter.vcl/epgm/dlgepgm.hrc68
-rw-r--r--goodies/source/filter.vcl/epgm/dlgepgm.hxx101
-rw-r--r--goodies/source/filter.vcl/epgm/dlgepgm.src198
-rw-r--r--goodies/source/filter.vcl/epgm/epgm.cxx339
-rw-r--r--goodies/source/filter.vcl/epgm/epgmstr.src69
-rw-r--r--goodies/source/filter.vcl/epgm/makefile.mk185
-rw-r--r--goodies/source/filter.vcl/epgm/strings.hrc61
-rw-r--r--goodies/source/filter.vcl/epict/dlgepct.cxx222
-rw-r--r--goodies/source/filter.vcl/epict/dlgepct.hrc75
-rw-r--r--goodies/source/filter.vcl/epict/dlgepct.hxx111
-rw-r--r--goodies/source/filter.vcl/epict/dlgepct.src317
-rw-r--r--goodies/source/filter.vcl/epict/epict.cxx2313
-rw-r--r--goodies/source/filter.vcl/epict/epictstr.src77
-rw-r--r--goodies/source/filter.vcl/epict/makefile.mk186
-rw-r--r--goodies/source/filter.vcl/epict/strings.hrc64
-rw-r--r--goodies/source/filter.vcl/eppm/dlgeppm.cxx125
-rw-r--r--goodies/source/filter.vcl/eppm/dlgeppm.hrc68
-rw-r--r--goodies/source/filter.vcl/eppm/dlgeppm.hxx101
-rw-r--r--goodies/source/filter.vcl/eppm/dlgeppm.src198
-rw-r--r--goodies/source/filter.vcl/eppm/eppm.cxx347
-rw-r--r--goodies/source/filter.vcl/eppm/eppmstr.src69
-rw-r--r--goodies/source/filter.vcl/eppm/makefile.mk183
-rw-r--r--goodies/source/filter.vcl/eppm/strings.hrc61
-rw-r--r--goodies/source/filter.vcl/eps/dlgeps.cxx221
-rw-r--r--goodies/source/filter.vcl/eps/dlgeps.hrc77
-rw-r--r--goodies/source/filter.vcl/eps/dlgeps.hxx111
-rw-r--r--goodies/source/filter.vcl/eps/dlgeps.src459
-rw-r--r--goodies/source/filter.vcl/eps/eps.cxx2411
-rw-r--r--goodies/source/filter.vcl/eps/epsstr.src188
-rw-r--r--goodies/source/filter.vcl/eps/makefile.mk181
-rw-r--r--goodies/source/filter.vcl/eps/strings.hrc66
-rw-r--r--goodies/source/filter.vcl/eras/eras.cxx345
-rw-r--r--goodies/source/filter.vcl/eras/makefile.mk169
-rw-r--r--goodies/source/filter.vcl/etiff/etiff.cxx663
-rw-r--r--goodies/source/filter.vcl/etiff/makefile.mk169
-rw-r--r--goodies/source/filter.vcl/expm/expm.cxx331
-rw-r--r--goodies/source/filter.vcl/expm/makefile.mk169
-rw-r--r--goodies/source/filter.vcl/icgm/actimpr.cxx1324
-rw-r--r--goodies/source/filter.vcl/icgm/bitmap.cxx449
-rw-r--r--goodies/source/filter.vcl/icgm/bitmap.hxx121
-rw-r--r--goodies/source/filter.vcl/icgm/bundles.cxx319
-rw-r--r--goodies/source/filter.vcl/icgm/bundles.hxx207
-rw-r--r--goodies/source/filter.vcl/icgm/cgm.cxx1065
-rw-r--r--goodies/source/filter.vcl/icgm/cgm.hxx226
-rw-r--r--goodies/source/filter.vcl/icgm/cgmres.hrc62
-rw-r--r--goodies/source/filter.vcl/icgm/cgmtypes.hxx179
-rw-r--r--goodies/source/filter.vcl/icgm/chart.cxx148
-rw-r--r--goodies/source/filter.vcl/icgm/chart.hxx250
-rw-r--r--goodies/source/filter.vcl/icgm/class0.cxx169
-rw-r--r--goodies/source/filter.vcl/icgm/class1.cxx309
-rw-r--r--goodies/source/filter.vcl/icgm/class2.cxx258
-rw-r--r--goodies/source/filter.vcl/icgm/class3.cxx179
-rw-r--r--goodies/source/filter.vcl/icgm/class4.cxx1005
-rw-r--r--goodies/source/filter.vcl/icgm/class5.cxx569
-rw-r--r--goodies/source/filter.vcl/icgm/class7.cxx269
-rw-r--r--goodies/source/filter.vcl/icgm/classx.cxx322
-rw-r--r--goodies/source/filter.vcl/icgm/elements.cxx436
-rw-r--r--goodies/source/filter.vcl/icgm/elements.hxx179
-rw-r--r--goodies/source/filter.vcl/icgm/main.hxx97
-rw-r--r--goodies/source/filter.vcl/icgm/makefile.mk266
-rw-r--r--goodies/source/filter.vcl/icgm/outact.cxx238
-rw-r--r--goodies/source/filter.vcl/icgm/outact.hxx208
-rw-r--r--goodies/source/filter.vcl/idxf/dxf2mtf.cxx804
-rw-r--r--goodies/source/filter.vcl/idxf/dxf2mtf.hxx163
-rw-r--r--goodies/source/filter.vcl/idxf/dxfblkrd.cxx167
-rw-r--r--goodies/source/filter.vcl/idxf/dxfblkrd.hxx123
-rw-r--r--goodies/source/filter.vcl/idxf/dxfentrd.cxx575
-rw-r--r--goodies/source/filter.vcl/idxf/dxfentrd.hxx498
-rw-r--r--goodies/source/filter.vcl/idxf/dxfgrprd.cxx388
-rw-r--r--goodies/source/filter.vcl/idxf/dxfgrprd.hxx200
-rw-r--r--goodies/source/filter.vcl/idxf/dxfreprd.cxx383
-rw-r--r--goodies/source/filter.vcl/idxf/dxfreprd.hxx166
-rw-r--r--goodies/source/filter.vcl/idxf/dxftblrd.cxx387
-rw-r--r--goodies/source/filter.vcl/idxf/dxftblrd.hxx223
-rw-r--r--goodies/source/filter.vcl/idxf/dxfvec.cxx258
-rw-r--r--goodies/source/filter.vcl/idxf/dxfvec.hxx261
-rw-r--r--goodies/source/filter.vcl/idxf/idxf.cxx119
-rw-r--r--goodies/source/filter.vcl/idxf/makefile.mk176
-rw-r--r--goodies/source/filter.vcl/ieps/ieps.cxx527
-rw-r--r--goodies/source/filter.vcl/ieps/makefile.mk168
-rw-r--r--goodies/source/filter.vcl/ios2met/ios2met.cxx2847
-rw-r--r--goodies/source/filter.vcl/ios2met/makefile.mk175
-rw-r--r--goodies/source/filter.vcl/ipbm/ipbm.cxx606
-rw-r--r--goodies/source/filter.vcl/ipbm/makefile.mk168
-rw-r--r--goodies/source/filter.vcl/ipcd/ipcd.cxx509
-rw-r--r--goodies/source/filter.vcl/ipcd/makefile.mk182
-rw-r--r--goodies/source/filter.vcl/ipcx/ipcx.cxx483
-rw-r--r--goodies/source/filter.vcl/ipcx/makefile.mk170
-rw-r--r--goodies/source/filter.vcl/ipict/ipict.cxx2021
-rw-r--r--goodies/source/filter.vcl/ipict/makefile.mk172
-rw-r--r--goodies/source/filter.vcl/ipsd/ipsd.cxx748
-rw-r--r--goodies/source/filter.vcl/ipsd/makefile.mk168
-rw-r--r--goodies/source/filter.vcl/iras/iras.cxx439
-rw-r--r--goodies/source/filter.vcl/iras/makefile.mk168
-rw-r--r--goodies/source/filter.vcl/itga/itga.cxx810
-rw-r--r--goodies/source/filter.vcl/itga/makefile.mk168
-rw-r--r--goodies/source/filter.vcl/itiff/ccidecom.cxx1143
-rw-r--r--goodies/source/filter.vcl/itiff/ccidecom.hxx159
-rw-r--r--goodies/source/filter.vcl/itiff/itiff.cxx1340
-rw-r--r--goodies/source/filter.vcl/itiff/lzwdecom.cxx224
-rw-r--r--goodies/source/filter.vcl/itiff/lzwdecom.hxx113
-rw-r--r--goodies/source/filter.vcl/itiff/makefile.mk171
-rw-r--r--goodies/source/graphic/grfattr.cxx148
-rw-r--r--goodies/source/graphic/grfcache.cxx876
-rw-r--r--goodies/source/graphic/grfcache.hxx133
-rw-r--r--goodies/source/graphic/grfmgr.cxx851
-rw-r--r--goodies/source/graphic/grfmgr2.cxx1492
-rw-r--r--goodies/source/graphic/makefile.mk95
-rw-r--r--goodies/source/inv/expl.cxx165
-rw-r--r--goodies/source/inv/expl.hxx110
-rw-r--r--goodies/source/inv/gegner.src194
-rw-r--r--goodies/source/inv/invader.cxx637
-rw-r--r--goodies/source/inv/invader.hrc94
-rw-r--r--goodies/source/inv/invader.hxx173
-rw-r--r--goodies/source/inv/invader1.cxx476
-rw-r--r--goodies/source/inv/makefile.mk213
-rw-r--r--goodies/source/inv/monst.cxx436
-rw-r--r--goodies/source/inv/monst.hxx172
-rw-r--r--goodies/source/inv/score.cxx198
-rw-r--r--goodies/source/inv/score.hxx94
-rw-r--r--goodies/source/inv/shapes.cxx497
-rw-r--r--goodies/source/inv/shapes.hxx229
-rw-r--r--goodies/source/inv/strings.hrc88
-rw-r--r--goodies/source/inv/strings.src167
-rw-r--r--goodies/source/inv/waves.hxx152
168 files changed, 65893 insertions, 0 deletions
diff --git a/goodies/source/base3d/b3dcolor.cxx b/goodies/source/base3d/b3dcolor.cxx
new file mode 100644
index 000000000000..8cb9b0087c94
--- /dev/null
+++ b/goodies/source/base3d/b3dcolor.cxx
@@ -0,0 +1,364 @@
+/*************************************************************************
+ *
+ * $RCSfile: b3dcolor.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma hdrstop
+
+#ifndef _B3D_B3DCOLOR_HXX
+#include "b3dcolor.hxx"
+#endif
+
+/*************************************************************************
+|*
+|* Farbwert interpolieren
+|*
+\************************************************************************/
+
+void B3dColor::CalcInBetween(Color& rOld1, Color& rOld2, double t)
+{
+ if(rOld1 != rOld2)
+ {
+ UINT16 nFac = (UINT16)(t * 256.0);
+ UINT16 nNegFac = 256 - nFac;
+ SetRed((UINT8)(((nFac * (UINT16)rOld2.GetRed())
+ + (nNegFac * (UINT16)rOld1.GetRed())) >> 8));
+ SetGreen((UINT8)(((nFac * (UINT16)rOld2.GetGreen())
+ + (nNegFac * (UINT16)rOld1.GetGreen())) >> 8));
+ SetBlue((UINT8)(((nFac * (UINT16)rOld2.GetBlue())
+ + (nNegFac * (UINT16)rOld1.GetBlue())) >> 8));
+ SetTransparency((UINT8)(((nFac * (UINT16)rOld2.GetTransparency())
+ + (nNegFac * (UINT16)rOld1.GetTransparency())) >> 8));
+ }
+ else
+ {
+ SetColor(rOld1.GetColor());
+ }
+}
+
+/*************************************************************************
+|*
+|* Farbwert Mittelwert finden mit 2 Farben
+|*
+\************************************************************************/
+
+void B3dColor::CalcMiddle(Color& rOld1, Color& rOld2)
+{
+ if(rOld1 != rOld2)
+ {
+ SetRed((UINT8)(((UINT16)rOld1.GetRed()
+ + (UINT16)rOld2.GetRed())>>1));
+ SetGreen((UINT8)(((UINT16)rOld1.GetGreen()
+ + (UINT16)rOld2.GetGreen())>>1));
+ SetBlue((UINT8)(((UINT16)rOld1.GetBlue()
+ + (UINT16)rOld2.GetBlue())>>1));
+ SetTransparency((UINT8)(((UINT16)rOld1.GetTransparency()
+ + (UINT16)rOld2.GetTransparency())>>1));
+ }
+ else
+ {
+ SetColor(rOld1.GetColor());
+ }
+}
+
+/*************************************************************************
+|*
+|* Farbwert Mittelwert finden mit 3 Farben
+|*
+\************************************************************************/
+
+void B3dColor::CalcMiddle(Color& rOld1, Color& rOld2, Color& rOld3)
+{
+ if(rOld1 != rOld2)
+ {
+ if(rOld1 != rOld3)
+ {
+ // alle 3 unterschiedlich
+ SetRed((UINT8)(((UINT16)rOld1.GetRed()
+ + (UINT16)rOld2.GetRed()
+ + (UINT16)rOld3.GetRed()) / 3L));
+ SetGreen((UINT8)(((UINT16)rOld1.GetGreen()
+ + (UINT16)rOld2.GetGreen()
+ + (UINT16)rOld3.GetGreen()) / 3L));
+ SetBlue((UINT8)(((UINT16)rOld1.GetBlue()
+ + (UINT16)rOld2.GetBlue()
+ + (UINT16)rOld3.GetBlue()) / 3L));
+ SetTransparency((UINT8)(((UINT16)rOld1.GetTransparency()
+ + (UINT16)rOld2.GetTransparency()
+ + (UINT16)rOld3.GetTransparency()) / 3L));
+ }
+ else
+ {
+ // 1 != 2, 1 == 3
+ CalcMiddle(rOld1, rOld2);
+ }
+ }
+ else
+ {
+ // 1 == 2
+ if(rOld1 != rOld3)
+ {
+ CalcMiddle(rOld1, rOld3);
+ }
+ else
+ {
+ // 1==2, 1==3 -> alle gleich
+ SetColor(rOld1.GetColor());
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Ermittle den Abstand der beiden Farben im Farbraum
+|* Dies geschieht OHNE Wurzelziehen, d.h. es wird als Metrik im RGB
+|* Farbraum hier das Quadrat der 'echten' (gewohnten) Entfernung benutzt
+|*
+\************************************************************************/
+
+ULONG B3dColor::GetDistance(Color& rOld)
+{
+ // Bei Gleichheit kein Abstand
+ if(*this == rOld)
+ return 0L;
+
+ // Abstand ermitteln
+ long nDistRed = rOld.GetRed() > GetRed() ?
+ rOld.GetRed() - GetRed() :
+ GetRed() - rOld.GetRed();
+ long nDistGreen = rOld.GetGreen() > GetGreen() ?
+ rOld.GetGreen() - GetGreen() :
+ GetGreen() - rOld.GetGreen();
+ long nDistBlue = rOld.GetBlue() > GetBlue() ?
+ rOld.GetBlue() - GetBlue() :
+ GetBlue() - rOld.GetBlue();
+ return (ULONG)(nDistRed * nDistRed
+ + nDistGreen * nDistGreen
+ + nDistBlue * nDistBlue);
+}
+
+/*************************************************************************
+|*
+|* Farbaddition mit clamping
+|*
+\************************************************************************/
+
+B3dColor& B3dColor::operator+= (const B3dColor& rCol)
+{
+ UINT16 nZwi;
+ if(rCol.GetRed())
+ {
+ nZwi = (UINT16)GetRed() + (UINT16)rCol.GetRed();
+ if(nZwi > 255)
+ nZwi = 255;
+ SetRed((UINT8)nZwi);
+ }
+ if(rCol.GetGreen())
+ {
+ nZwi = (UINT16)GetGreen() + (UINT16)rCol.GetGreen();
+ if(nZwi > 255)
+ nZwi = 255;
+ SetGreen((UINT8)nZwi);
+ }
+ if(rCol.GetBlue())
+ {
+ nZwi = (UINT16)GetBlue() + (UINT16)rCol.GetBlue();
+ if(nZwi > 255)
+ nZwi = 255;
+ SetBlue((UINT8)nZwi);
+ }
+ if(rCol.GetTransparency())
+ {
+ nZwi = (UINT16)GetTransparency() + (UINT16)rCol.GetTransparency();
+ if(nZwi > 255)
+ nZwi = 255;
+ SetTransparency((UINT8)nZwi);
+ }
+ return *this;
+}
+
+/*************************************************************************
+|*
+|* Farbsubtraktion mit clamping
+|*
+\************************************************************************/
+
+B3dColor& B3dColor::operator-= (const B3dColor& rCol)
+{
+ INT16 nZwi;
+ if(rCol.GetRed())
+ {
+ nZwi = (INT16)GetRed() - (INT16)rCol.GetRed();
+ if(nZwi < 0)
+ nZwi = 0;
+ SetRed((UINT8)nZwi);
+ }
+ if(rCol.GetGreen())
+ {
+ nZwi = (INT16)GetGreen() - (INT16)rCol.GetGreen();
+ if(nZwi < 0)
+ nZwi = 0;
+ SetGreen((UINT8)nZwi);
+ }
+ if(rCol.GetBlue())
+ {
+ nZwi = (INT16)GetBlue() - (INT16)rCol.GetBlue();
+ if(nZwi < 0)
+ nZwi = 0;
+ SetBlue((UINT8)nZwi);
+ }
+ if(rCol.GetTransparency())
+ {
+ nZwi = (INT16)GetTransparency() - (INT16)rCol.GetTransparency();
+ if(nZwi < 0)
+ nZwi = 0;
+ SetTransparency((UINT8)nZwi);
+ }
+ return *this;
+}
+
+/*************************************************************************
+|*
+|* Farbaddition mit clamping, neue Farbe erzeugen
+|*
+\************************************************************************/
+
+B3dColor B3dColor::operator+ (const B3dColor& rCol) const
+{
+ B3dColor aSum = *this;
+ aSum += rCol;
+ return aSum;
+}
+
+/*************************************************************************
+|*
+|* Farbsubtraktion mit clamping, neue Farbe erzeugen
+|*
+\************************************************************************/
+
+B3dColor B3dColor::operator- (const B3dColor& rCol) const
+{
+ B3dColor aSub = *this;
+ aSub -= rCol;
+ return aSub;
+}
+
+/*************************************************************************
+|*
+|* Farbmultiplikation, d.h. Gewichtung der Farben aneinander
+|*
+\************************************************************************/
+
+B3dColor& B3dColor::operator*= (const B3dColor& rCol)
+{
+ // urspruengliches Objekt ist die Farbe, rCol die zu berechnende
+ // Gewichtung
+ SetRed((UINT8)(((((UINT16)GetRed())+1)
+ * (UINT16)rCol.GetRed()) >> 8));
+ SetGreen((UINT8)(((((UINT16)GetGreen())+1)
+ * (UINT16)rCol.GetGreen()) >> 8));
+ SetBlue((UINT8)(((((UINT16)GetBlue())+1)
+ * (UINT16)rCol.GetBlue()) >> 8));
+ SetTransparency((UINT8)(((((UINT16)GetTransparency())+1)
+ * (UINT16)rCol.GetTransparency()) >> 8));
+ return *this;
+}
+
+/*************************************************************************
+|*
+|* Farbmultiplikation, neue Farbe erzeugen
+|*
+\************************************************************************/
+
+B3dColor B3dColor::operator* (const B3dColor& rCol) const
+{
+ B3dColor aMul = *this;
+ aMul *= rCol;
+ return aMul;
+}
+
+/*************************************************************************
+|*
+|* Farbmultiplikation mit Faktor im Bereich [0.0 .. 1.0]
+|*
+\************************************************************************/
+
+B3dColor& B3dColor::operator*= (const double fVal)
+{
+ ULONG nVal = (ULONG)(fVal * 65536.0);
+ SetRed((UINT8)(((ULONG)GetRed() * nVal) >> 16));
+ SetGreen((UINT8)(((ULONG)GetGreen() * nVal) >> 16));
+ SetBlue((UINT8)(((ULONG)GetBlue() * nVal) >> 16));
+ SetTransparency((UINT8)(((ULONG)GetTransparency() * nVal) >> 16));
+ return *this;
+}
+
+/*************************************************************************
+|*
+|* Farbmultiplikation mit Faktor, neue Farbe erzeugen
+|*
+\************************************************************************/
+
+B3dColor B3dColor::operator* (const double fVal) const
+{
+ B3dColor aMul = *this;
+ aMul *= fVal;
+ return aMul;
+}
+
diff --git a/goodies/source/base3d/b3dcommn.cxx b/goodies/source/base3d/b3dcommn.cxx
new file mode 100644
index 000000000000..759c8c2032ee
--- /dev/null
+++ b/goodies/source/base3d/b3dcommn.cxx
@@ -0,0 +1,1415 @@
+/*************************************************************************
+ *
+ * $RCSfile: b3dcommn.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma hdrstop
+
+#ifndef _B3D_B3DCOMMN_HXX
+#include "b3dcommn.hxx"
+#endif
+
+#ifndef _B3D_B3DTRANS_HXX
+#include "b3dtrans.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#ifndef _SV_OUTDEV_HXX
+#include <vcl/outdev.hxx>
+#endif
+
+/*************************************************************************
+|*
+|* Bucket fuer Index
+|*
+\************************************************************************/
+
+BASE3D_IMPL_BUCKET(UINT32, Bucket)
+
+/*************************************************************************
+|*
+|* Konstruktor Base3DCommon
+|*
+\************************************************************************/
+
+Base3DCommon::Base3DCommon(OutputDevice* pOutDev)
+: Base3D(pOutDev),
+ aBuffers(12) // 4K
+{
+}
+
+/*************************************************************************
+|*
+|* Destruktor Base3DCommon
+|*
+\************************************************************************/
+
+Base3DCommon::~Base3DCommon()
+{
+}
+
+/*************************************************************************
+|*
+|* Start der Szenenbeschreibung:
+|*
+\************************************************************************/
+
+void Base3DCommon::StartScene()
+{
+}
+
+/*************************************************************************
+|*
+|* Ende der Szenenbeschreibung:
+|*
+\************************************************************************/
+
+void Base3DCommon::EndScene()
+{
+}
+
+/*************************************************************************
+|*
+|* Neuen freien Eintrag fuer naechste geometrische Daten liefern
+|*
+\************************************************************************/
+
+B3dEntity& Base3DCommon::ImplGetFreeEntity()
+{
+ aBuffers.Append();
+ return (aBuffers[aBuffers.Count() - 1]);
+}
+
+/*************************************************************************
+|*
+|* Beleuchtung setzen/lesen
+|*
+\************************************************************************/
+
+void Base3DCommon::SetLightGroup(B3dLightGroup* pSet, BOOL bSetGlobal)
+{
+ // call parent
+ Base3D::SetLightGroup(pSet, bSetGlobal);
+
+ if(GetLightGroup())
+ {
+ Matrix4D aOldObjectTrans;
+ Matrix4D aEmptyTrans;
+ if(GetTransformationSet() && bSetGlobal)
+ {
+ aOldObjectTrans = GetTransformationSet()->GetObjectTrans();
+ GetTransformationSet()->SetObjectTrans(aEmptyTrans);
+ }
+
+ for(UINT16 i=0;i<BASE3D_MAX_NUMBER_LIGHTS;i++)
+ {
+ B3dLight& rLight = GetLightGroup()->
+ GetLightObject((Base3DLightNumber)(Base3DLight0 + i));
+ if(rLight.IsDirectionalSource())
+ {
+ Vector3D aDirection = rLight.GetPosition();
+ if(GetTransformationSet())
+ aDirection = GetTransformationSet()->InvTransObjectToEye(aDirection);
+ aDirection.Normalize();
+ rLight.SetPositionEye(aDirection);
+ }
+ else
+ {
+ Vector3D aPosition = rLight.GetPosition();
+ if(GetTransformationSet())
+ aPosition = GetTransformationSet()->ObjectToEyeCoor(aPosition);
+ rLight.SetPositionEye(aPosition);
+
+ Vector3D aDirection = rLight.GetSpotDirection();
+ if(GetTransformationSet())
+ aDirection = GetTransformationSet()->InvTransObjectToEye(aDirection);
+ aDirection.Normalize();
+ rLight.SetSpotDirectionEye(aDirection);
+ }
+ }
+
+ if(GetTransformationSet() && bSetGlobal)
+ GetTransformationSet()->SetObjectTrans(aOldObjectTrans);
+ }
+}
+
+/*************************************************************************
+|*
+|* entsprechend der impliziten Topologie auf den neuen Punkt reagieren
+|*
+\************************************************************************/
+
+void Base3DCommon::ImplPostAddVertex(B3dEntity& rEntity)
+{
+ B3dTransformationSet* pSet = GetTransformationSet();
+ if(pSet)
+ {
+ // Positionen transformieren in ClippingCoordinates
+ rEntity.Point() *= pSet->GetObjectToDevice();
+
+ // Normalen transformieren in EyeCoordinates
+ if((GetLightGroup() && GetLightGroup()->IsLightingEnabled()) && rEntity.IsNormalUsed())
+ {
+ if(GetForceFlat() || GetShadeModel() == Base3DFlat)
+ rEntity.Normal() = pSet->InvTransObjectToEye(rEntity.PlaneNormal());
+ else
+ rEntity.Normal() = pSet->InvTransObjectToEye(rEntity.Normal());
+ }
+
+ // Texturkoordinaten transformieren anhand der Texturmatrix
+ if(rEntity.IsTexCoorUsed())
+ {
+ // Multiplikation mittels Point4D, um die Translationen zu
+ // beruecksichtigen. Die Koordinaten werden bei GetVector3D()
+ // homogenisiert.
+ rEntity.TexCoor() = pSet->TransTextureCoor(rEntity.TexCoor());
+ }
+ }
+
+ // Aktuelle Farbe in diesen B3dEntity eintragen
+ rEntity.Color() = GetColor();
+
+ // Jetzt Topologie beachten und evtl. ein Primitiv ausspucken
+ UINT32 aCount = aBuffers.Count();
+ switch(GetObjectMode())
+ {
+ case Base3DPoints:
+ {
+ Create3DPoint(0);
+ aBuffers.Erase();
+ break;
+ }
+ case Base3DLines:
+ {
+ if(aCount == 2)
+ {
+ Create3DLine(0, 1);
+ aBuffers.Erase();
+ }
+ break;
+ }
+ case Base3DLineLoop:
+ case Base3DLineStrip:
+ {
+ if(aCount > 1)
+ Create3DLine(aCount - 2, aCount - 1);
+ break;
+ }
+ case Base3DTriangles:
+ {
+ if(aCount == 3)
+ {
+ Create3DTriangle(0, 1, 2);
+ aBuffers.Erase();
+ }
+ break;
+ }
+ case Base3DTriangleStrip:
+ {
+ if(aCount > 2)
+ {
+ if(aCount % 2)
+ Create3DTriangle(aCount - 3, aCount - 2, aCount - 1);
+ else
+ Create3DTriangle(aCount - 2, aCount - 3, aCount - 1);
+ }
+ break;
+ }
+ case Base3DTriangleFan:
+ {
+ if(aCount > 2)
+ Create3DTriangle(0, aCount - 2, aCount - 1);
+ break;
+ }
+ case Base3DQuads:
+ {
+ if(aCount == 4)
+ {
+ // Spezielle Behandlung, da die inneren Kanten
+ // eines Quads NICHT sichtbar sein sollen
+ B3dEntity& rEnt2 = aBuffers[2];
+ B3dEntity& rEnt0 = aBuffers[0];
+
+ BOOL bZwi = rEnt2.IsEdgeVisible();
+ rEnt2.SetEdgeVisible(FALSE);
+ Create3DTriangle(0, 1, 2);
+ rEnt2.SetEdgeVisible(bZwi);
+
+ bZwi = rEnt0.IsEdgeVisible();
+ rEnt0.SetEdgeVisible(FALSE);
+ Create3DTriangle(0, 2, 3);
+ rEnt0.SetEdgeVisible(bZwi);
+
+ aBuffers.Erase();
+ }
+ break;
+ }
+ case Base3DQuadStrip:
+ {
+ if(aCount > 2)
+ {
+ B3dEntity& rEnt = aBuffers[aCount - 2];
+ BOOL bZwi = rEnt.IsEdgeVisible();
+ rEnt.SetEdgeVisible(FALSE);
+ if(aCount % 2)
+ Create3DTriangle(aCount - 2, aCount - 1, aCount - 3);
+ else
+ Create3DTriangle(aCount - 3, aCount - 1, aCount - 2);
+ rEnt.SetEdgeVisible(bZwi);
+ }
+ break;
+ }
+ case Base3DPolygon:
+ {
+ if(aCount > 2)
+ {
+ B3dEntity& rEnt = aBuffers[aCount - 1];
+ BOOL bZwi = rEnt.IsEdgeVisible();
+ rEnt.SetEdgeVisible(FALSE);
+ Create3DTriangle(0, aCount - 2, aCount - 1);
+ rEnt.SetEdgeVisible(bZwi);
+ // Ab jetzt nie wieder eine Kante vom 1. Punkt (0)
+ // ausgehend generieren
+ if(aCount == 3)
+ aBuffers[0].SetEdgeVisible(FALSE);
+ }
+ break;
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Ein neues Primitiv, leere die jetzigen buffer
+|*
+\************************************************************************/
+
+void Base3DCommon::ImplStartPrimitive()
+{
+ // Buffer leeren
+ aBuffers.Erase();
+}
+
+/*************************************************************************
+|*
+|* Primitiv abgeschlossen
+|*
+\************************************************************************/
+
+void Base3DCommon::ImplEndPrimitive()
+{
+ // Topologie beachten und evtl. ein Primitiv ausspucken
+ UINT32 aCount = aBuffers.Count();
+ switch(GetObjectMode())
+ {
+ case Base3DLineLoop:
+ {
+ if(aCount > 2)
+ Create3DLine(aCount - 1, 0);
+ break;
+ }
+ case Base3DPolygon:
+ {
+ // Letzte schliessende Linie erzeugen, falls
+ // es um das Erzeugen von Linien ging und
+ // das letzte Primitiv auch wirklich zur Ausgabe
+ // gelangt ist
+ if(GetRenderMode() == Base3DRenderLine
+ && !WasLastPrimitiveRejected())
+ {
+ if(aCount > 2)
+ Create3DLine(aCount - 1, 0);
+ }
+ break;
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Funktion fuer Primitiv Punkt
+|* Clipping und Ausgabe, falls noch was ueber ist
+|*
+\************************************************************************/
+
+void Base3DCommon::Create3DPoint(UINT32 nInd)
+{
+ bLastPrimitiveRejected = TRUE;
+ if(GetRenderMode() != Base3DRenderNone)
+ {
+ // Sicherstellen, dass die Koordinaten in
+ // ClipCoordinates vorliegen
+ aBuffers[nInd].To3DCoor(GetTransformationSet());
+
+ // Punkt an Einheitswuerfel clippen
+ if(Clip3DPoint(nInd))
+ Create3DPointClipped(nInd);
+ }
+}
+
+void Base3DCommon::Create3DPointClipped(UINT32 nInd)
+{
+ // einige Beleuchtungsdinge koennen hier schon geklaert
+ // werden
+ if(GetLightGroup() && GetLightGroup()->IsLightingEnabled())
+ {
+ B3dEntity& rEnt = aBuffers[nInd];
+ if(rEnt.IsNormalUsed() && GetLightGroup())
+ {
+ // Beleuchtungsmodell loesen, Normale loeschen
+ SolveColorModel(rEnt.Color(), rEnt.Normal(), rEnt.Point().GetVector3D());
+ }
+ rEnt.SetNormalUsed(FALSE);
+ }
+
+ // Punkt wird dargestellt, weiterreichen
+ if(GetPointSize() != 1.0)
+ {
+ // Punkt als Kreis mit dem Durchmesser GetPointSize() ausgeben
+ // Hole den Original-Punkt
+ B3dEntity& rEnt1 = aBuffers[nInd];
+
+ // Umrechnen auf DeviceCoor
+ rEnt1.ToDeviceCoor(GetTransformationSet());
+
+ // Radius holen
+ // Logische Koordinaten nach Pixel
+ Point aPnt((long)(GetLineWidth() + 0.5), 0);
+ double fRadius = ((double)((
+ GetOutputDevice()->PixelToLogic(aPnt).X() -
+ GetOutputDevice()->PixelToLogic(Point()).X()) + 0.5)) / 2.0;
+
+ // Bereite neue Punkte vor
+ // Hole die neuen Punkte
+ UINT32 nNew1 = aBuffers.Count();
+ aBuffers.Append(rEnt1);
+ B3dEntity& rNew1 = aBuffers[nNew1];
+
+ UINT32 nNew2 = aBuffers.Count();
+ aBuffers.Append(rEnt1);
+ B3dEntity& rNew2 = aBuffers[nNew2];
+
+ UINT32 nNew3 = aBuffers.Count();
+ aBuffers.Append(rEnt1);
+ B3dEntity& rNew3 = aBuffers[nNew3];
+
+ // Schleife drehen
+ Base3DRenderMode eRenderMode = GetRenderMode();
+ SetRenderMode(Base3DRenderFill);
+ BOOL bPolyOffset = GetPolygonOffset(Base3DPolygonOffsetFill);
+ SetPolygonOffset(Base3DPolygonOffsetFill, TRUE);
+
+ for(double fWink=0.0;fWink<F_2PI-(F_2PI/24.0);fWink+=F_2PI/12.0)
+ {
+ rNew2.Point().X() = rNew1.Point().X() + (cos(fWink) * fRadius);
+ rNew2.Point().Y() = rNew1.Point().Y() + (sin(fWink) * fRadius);
+
+ rNew3.Point().X() = rNew1.Point().X() + (cos(fWink+(F_2PI/12.0)) * fRadius);
+ rNew3.Point().Y() = rNew1.Point().Y() + (sin(fWink+(F_2PI/12.0)) * fRadius);
+
+ // Dreieck Zeichnen
+ Create3DTriangle(nNew1, nNew3, nNew2);
+ }
+
+ SetRenderMode(eRenderMode);
+ SetPolygonOffset(Base3DPolygonOffsetFill, bPolyOffset);
+
+ bLastPrimitiveRejected = FALSE;
+ }
+ else
+ {
+ Clipped3DPoint(nInd);
+ bLastPrimitiveRejected = FALSE;
+ }
+}
+
+/*************************************************************************
+|*
+|* Funktion fuer Primitiv Linie
+|* Clipping und Ausgabe, falls noch was ueber ist
+|*
+\************************************************************************/
+
+void Base3DCommon::Create3DLine(UINT32 nInd1, UINT32 nInd2)
+{
+ bLastPrimitiveRejected = TRUE;
+ if(GetRenderMode() != Base3DRenderNone)
+ {
+ // Sicherstellen, dass die Koordinaten in
+ // ClipCoordinates vorliegen
+ aBuffers[nInd1].To3DCoor(GetTransformationSet());
+ aBuffers[nInd2].To3DCoor(GetTransformationSet());
+
+ if(AreEqual(nInd1, nInd2))
+ return;
+
+ // Linie an Einheitswuerfel clippen, dabei kann eine
+ // der Indexvariablen (werden als Referenz uegergeben)
+ // veraendert werden
+
+ // Alte Buffergroesse merken
+ ULONG nCount = aBuffers.Count();
+
+ if(Clip3DLine(nInd1, nInd2))
+ {
+ // EdgeFlag beachten
+ if(aBuffers[nInd1].IsEdgeVisible())
+ Create3DLineClipped(nInd1, nInd2);
+ }
+
+ // Alte Buffergroesse wiederherstellen, um fortgesetzte
+ // Primitive nicht zu zerstoeren
+ while(aBuffers.Count() > nCount)
+ aBuffers.Remove();
+ }
+}
+
+void Base3DCommon::Create3DLineClipped(UINT32 nInd1, UINT32 nInd2)
+{
+ // einige Beleuchtungsdinge koennen hier schon geklaert
+ // werden
+ if(GetLightGroup() && GetLightGroup()->IsLightingEnabled())
+ {
+ if(GetShadeModel() == Base3DFlat)
+ {
+ // Beleuchtuungsmodell fuer gemittelte Normale
+ // loesen, Normalen loeschen
+ B3dEntity& rEnt1 = aBuffers[nInd1];
+ B3dEntity& rEnt2 = aBuffers[nInd2];
+ if(rEnt1.IsNormalUsed() && rEnt2.IsNormalUsed() && GetLightGroup())
+ {
+ Vector3D aNormal = rEnt1.Normal() + rEnt2.Normal();
+ aNormal.Normalize();
+ Vector3D aPoint = (rEnt1.Point().GetVector3D() + rEnt2.Point().GetVector3D()) / 2.0;
+ SolveColorModel(rEnt1.Color(), aNormal, aPoint);
+ rEnt2.Color() = rEnt1.Color();
+ }
+ rEnt1.SetNormalUsed(FALSE);
+ rEnt2.SetNormalUsed(FALSE);
+ }
+ }
+ else
+ {
+ if(GetShadeModel() == Base3DFlat)
+ {
+ B3dEntity& rEnt1 = aBuffers[nInd1];
+ B3dEntity& rEnt2 = aBuffers[nInd2];
+ B3dColor aCol;
+ aCol.CalcMiddle(rEnt1.Color(), rEnt2.Color());
+ rEnt1.Color() = aCol;
+ rEnt2.Color() = aCol;
+ }
+ }
+
+ if(GetRenderMode() == Base3DRenderPoint)
+ {
+ // Als Punkte ausgeben
+ Create3DPointClipped(nInd1);
+ Create3DPointClipped(nInd2);
+ }
+ else
+ {
+ if(GetLineWidth() != 1.0)
+ {
+ // Linie als Polygon mit der Breite GetLineWidth() ausgeben
+ // Hole die Original-Punkte
+ B3dEntity& rEnt1 = aBuffers[nInd1];
+ B3dEntity& rEnt2 = aBuffers[nInd2];
+
+ // Umrechnen auf DeviceCoor
+ rEnt1.ToDeviceCoor(GetTransformationSet());
+ rEnt2.ToDeviceCoor(GetTransformationSet());
+
+ // Bereite neue Punkte vor
+ // Hole die neuen Punkte
+ UINT32 nNew1 = aBuffers.Count();
+ aBuffers.Append(rEnt1);
+ B3dEntity& rNew1 = aBuffers[nNew1];
+
+ UINT32 nNew2 = aBuffers.Count();
+ aBuffers.Append(rEnt1);
+ B3dEntity& rNew2 = aBuffers[nNew2];
+
+ UINT32 nNew3 = aBuffers.Count();
+ aBuffers.Append(rEnt2);
+ B3dEntity& rNew3 = aBuffers[nNew3];
+
+ UINT32 nNew4 = aBuffers.Count();
+ aBuffers.Append(rEnt2);
+ B3dEntity& rNew4 = aBuffers[nNew4];
+
+ // Berechnen
+ Vector3D aEntVector = rEnt2.Point().GetVector3D() - rEnt1.Point().GetVector3D();
+ Vector3D aTurned(-aEntVector.Y(), aEntVector.X(), 0.0);
+ aTurned.Normalize();
+
+ // Logische Koordinaten nach Pixel
+ Point aPnt((long)(GetLineWidth() + 0.5), 0);
+ double fFac = ((double)((
+ GetOutputDevice()->PixelToLogic(aPnt).X() -
+ GetOutputDevice()->PixelToLogic(Point()).X()) + 0.5)) / 2.0;
+
+ // Aufmuliplizieren
+ aTurned *= fFac;
+
+ rNew1.Point().X() += aTurned.X();
+ rNew1.Point().Y() += aTurned.Y();
+ rNew2.Point().X() -= aTurned.X();
+ rNew2.Point().Y() -= aTurned.Y();
+
+ rNew3.Point().X() += aTurned.X();
+ rNew3.Point().Y() += aTurned.Y();
+ rNew4.Point().X() -= aTurned.X();
+ rNew4.Point().Y() -= aTurned.Y();
+
+ // Ausgeben
+ Base3DRenderMode eRenderMode = GetRenderMode();
+ SetRenderMode(Base3DRenderFill);
+ BOOL bPolyOffset = GetPolygonOffset(Base3DPolygonOffsetFill);
+ SetPolygonOffset(Base3DPolygonOffsetFill, TRUE);
+
+ Create3DTriangle(nNew2, nNew1, nNew3);
+ Create3DTriangle(nNew2, nNew3, nNew4);
+
+ SetRenderMode(eRenderMode);
+ SetPolygonOffset(Base3DPolygonOffsetFill, bPolyOffset);
+
+ bLastPrimitiveRejected = FALSE;
+ }
+ else
+ {
+ // Linie ausgeben
+ Clipped3DLine(nInd1,nInd2);
+ bLastPrimitiveRejected = FALSE;
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Funktion fuer Primitiv Dreieck
+|* Clipping und Ausgabe, falls noch was ueber ist
+|*
+\************************************************************************/
+
+void Base3DCommon::Create3DTriangle(UINT32 nInd1, UINT32 nInd2, UINT32 nInd3)
+{
+ bLastPrimitiveRejected = TRUE;
+
+ // Sicherstellen, dass die Koordinaten in
+ // ClipCoordinates vorliegen
+ aBuffers[nInd1].To3DCoor(GetTransformationSet());
+ aBuffers[nInd2].To3DCoor(GetTransformationSet());
+ aBuffers[nInd3].To3DCoor(GetTransformationSet());
+
+ if(AreEqual(nInd1, nInd2)
+ || AreEqual(nInd1, nInd3)
+ || AreEqual(nInd2, nInd3))
+ return;
+
+ // Normale vorbereiten, die echte Ebenennormale der Geometrie
+ // im Device-Koordinatensystem. Verzerrungen durch perspektivische
+ // Projektion sind somit bereits beruecksichtigt.
+ const Vector3D& rPnt1 = aBuffers[nInd1].Point().GetVector3D();
+ const Vector3D& rPnt2 = aBuffers[nInd2].Point().GetVector3D();
+ const Vector3D& rPnt3 = aBuffers[nInd3].Point().GetVector3D();
+ Vector3D aNormal = (rPnt2 - rPnt3)|(rPnt2 - rPnt1);
+ aNormal.Normalize();
+
+ if(GetCullMode() != Base3DCullNone)
+ {
+ // Normale ermitteln, eventuell gar nicht zeichnen
+ if(GetCullMode() == Base3DCullFront)
+ {
+ if(aNormal.Z() > 0.0)
+ return;
+ }
+ else
+ {
+ if(aNormal.Z() < 0.0)
+ return;
+ }
+ }
+
+ // allgemeines Polygon vorbereiten
+ UINT32Bucket aEdgeIndex(8);
+ aEdgeIndex.Append(nInd1);
+ aEdgeIndex.Append(nInd2);
+ aEdgeIndex.Append(nInd3);
+
+ // Alte Buffergroesse merken
+ ULONG nCount = aBuffers.Count();
+
+ // Dreieck an Einheitswuerfel clippen
+ if(Clip3DPolygon(aEdgeIndex))
+ {
+ UINT32 nNumPoints = aEdgeIndex.Count();
+
+ // einige Beleuchtungsdinge koennen hier schon geklaert
+ // werden
+ if(GetLightGroup() && GetLightGroup()->IsLightingEnabled() && nNumPoints != 0)
+ {
+ if(GetShadeModel() == Base3DFlat)
+ {
+ B3dEntity& rEnt = aBuffers[nInd1];
+ B3dColor aColFlatMode;
+
+ // #63505#
+ aNormal.X() = -aNormal.X();
+ aNormal.Y() = -aNormal.Y();
+
+ SolveColorModel(aColFlatMode, aNormal, rEnt.Point().GetVector3D());
+
+ // Vorberechnete Farbe in Eckpunkten setzen
+ for(UINT32 i=0;i<nNumPoints;i++)
+ {
+ B3dEntity& rEnt = aBuffers[aEdgeIndex[i]];
+ rEnt.Color() = aColFlatMode;
+ rEnt.SetNormalUsed(FALSE);
+ }
+ }
+ }
+ else
+ {
+ if(GetShadeModel() == Base3DFlat && nNumPoints != 0)
+ {
+ UINT16 aRed(0), aGreen(0), aBlue(0), aAlpha(0);
+ UINT32 i;
+ for(i=0;i<nNumPoints;i++)
+ {
+ B3dEntity& rEnt = aBuffers[aEdgeIndex[i]];
+ aRed += (UINT16)rEnt.Color().GetRed();
+ aGreen += (UINT16)rEnt.Color().GetGreen();
+ aBlue += (UINT16)rEnt.Color().GetBlue();
+ aAlpha += (UINT16)rEnt.Color().GetTransparency();
+ }
+ B3dColor aCol((UINT8)(aAlpha / nNumPoints),
+ (UINT8)(aRed / nNumPoints),
+ (UINT8)(aGreen / nNumPoints),
+ (UINT8)(aBlue / nNumPoints));
+ for(i=0;i<nNumPoints;i++)
+ {
+ aBuffers[aEdgeIndex[i]].Color() = aCol;
+ }
+ }
+ }
+
+ // Ausgeben, je nach Modus
+ Base3DMaterialMode eMat = Base3DMaterialFront;
+ if(aNormal.Z() < 0.0
+ && (GetLightGroup() && GetLightGroup()->GetModelTwoSide()))
+ eMat = Base3DMaterialBack;
+ Base3DRenderMode eMode = GetRenderMode(eMat);
+
+ if(eMode == Base3DRenderPoint)
+ {
+ // Als Punktmenge ausgeben
+ for(UINT32 i=0;i<nNumPoints;i++)
+ {
+ Create3DPointClipped(aEdgeIndex[i]);
+ }
+ }
+ else if(eMode == Base3DRenderLine)
+ {
+ // Als Linien ausgeben
+ UINT32 i2, i3;
+ for(UINT32 i=0;i<nNumPoints;i++)
+ {
+ i2 = i+1;
+ if(i2 == nNumPoints)
+ i2 = 0;
+ i3 = aEdgeIndex[i];
+ i2 = aEdgeIndex[i2];
+
+ // EdgeFlag beachten
+ if(aBuffers[i3].IsEdgeVisible())
+ Create3DLineClipped(i3, i2);
+ }
+ }
+ else
+ {
+ // after clipping the triangle can be a multi-sided, but
+ // convex polygon. Render it by dividing it into triangles
+ // again. Cause' it is clipped now, no more taking care is
+ // necessary. Just give hints which flags are truly edges
+ // to allow further computations.
+ if(nNumPoints > 2)
+ {
+ for(UINT32 i=2;i < nNumPoints; i++)
+ {
+ Clipped3DTriangle(
+ aEdgeIndex[0],
+ aEdgeIndex[i-1],
+ aEdgeIndex[i]);
+ bLastPrimitiveRejected = FALSE;
+ }
+ }
+ }
+ }
+ // Alte Buffergroesse wiederherstellen, um fortgesetzte
+ // Primitive nicht zu zerstoeren
+ while(aBuffers.Count() > nCount)
+ aBuffers.Remove();
+}
+
+/*************************************************************************
+|*
+|* Punkt am canonical view volume clippen
+|*
+\************************************************************************/
+
+BOOL Base3DCommon::Clip3DPoint(UINT32 nInd)
+{
+ return (!(BOOL)GetClipFlags(nInd));
+}
+
+/*************************************************************************
+|*
+|* Vergleicht, ob die beiden Entities geometrisch gleich sind
+|*
+\************************************************************************/
+
+BOOL Base3DCommon::AreEqual(UINT32 nInd1, UINT32 nInd2)
+{
+ const Vector3D& rVec1 = aBuffers[nInd1].Point().GetVector3D();
+ const Vector3D& rVec2 = aBuffers[nInd2].Point().GetVector3D();
+
+ if(fabs(rVec1.X() - rVec2.X()) < SMALL_DVALUE)
+ if(fabs(rVec1.Y() - rVec2.Y()) < SMALL_DVALUE)
+ if(fabs(rVec1.Z() - rVec2.Z()) < SMALL_DVALUE)
+ return TRUE;
+ return FALSE;
+}
+
+/*************************************************************************
+|*
+|* Linie am canonical view volume clippen
+|*
+\************************************************************************/
+
+BOOL Base3DCommon::Clip3DLine(UINT32& nInd1,UINT32& nInd2)
+{
+ UINT16 nFlag0, nFlag1;
+ do
+ {
+ nFlag0 = GetClipFlags(nInd1);
+ nFlag1 = GetClipFlags(nInd2);
+
+ // Beide Endpunkte drin?
+ if(!(nFlag0 | nFlag1))
+ return TRUE;
+
+ // Linie komplett draussen?
+ if(nFlag0 & nFlag1)
+ return FALSE;
+
+ // Es muss geclippt werden, bereite einen neuen Punkt vor
+ UINT32 nNewIndex = aBuffers.Count();
+ aBuffers.Append();
+
+ if((nFlag0 | nFlag1) & (CLIPFLAG_FRONT | CLIPFLAG_BACK))
+ {
+ // clippen in Z
+ if(nFlag0 & (CLIPFLAG_FRONT | CLIPFLAG_BACK))
+ {
+ if(nFlag0 & CLIPFLAG_FRONT)
+ CalcNewPoint(nNewIndex, nInd2, nInd1, 2, -1.0);
+ else
+ CalcNewPoint(nNewIndex, nInd1, nInd2, 2, 1.0);
+ nInd1 = nNewIndex;
+ }
+ else
+ {
+ if(nFlag1 & CLIPFLAG_FRONT)
+ CalcNewPoint(nNewIndex, nInd1, nInd2, 2, -1.0);
+ else
+ CalcNewPoint(nNewIndex, nInd2, nInd1, 2, 1.0);
+ nInd2 = nNewIndex;
+ }
+ }
+ else if((nFlag0 | nFlag1) & (CLIPFLAG_LEFT | CLIPFLAG_RIGHT))
+ {
+ // clippen in X
+ if(nFlag0 & (CLIPFLAG_LEFT | CLIPFLAG_RIGHT))
+ {
+ if(nFlag0 & CLIPFLAG_LEFT)
+ CalcNewPoint(nNewIndex, nInd2, nInd1, 0, -1.0);
+ else
+ CalcNewPoint(nNewIndex, nInd1, nInd2, 0, 1.0);
+ nInd1 = nNewIndex;
+ }
+ else
+ {
+ if(nFlag1 & CLIPFLAG_LEFT)
+ CalcNewPoint(nNewIndex, nInd1, nInd2, 0, -1.0);
+ else
+ CalcNewPoint(nNewIndex, nInd2, nInd1, 0, 1.0);
+ nInd2 = nNewIndex;
+ }
+ }
+ else
+ {
+ // clippen in Y
+ if(nFlag0 & (CLIPFLAG_BOTTOM | CLIPFLAG_TOP))
+ {
+ if(nFlag0 & CLIPFLAG_BOTTOM)
+ CalcNewPoint(nNewIndex, nInd2, nInd1, 1, -1.0);
+ else
+ CalcNewPoint(nNewIndex, nInd1, nInd2, 1, 1.0);
+ nInd1 = nNewIndex;
+ }
+ else
+ {
+ if(nFlag1 & CLIPFLAG_BOTTOM)
+ CalcNewPoint(nNewIndex, nInd1, nInd2, 1, -1.0);
+ else
+ CalcNewPoint(nNewIndex, nInd2, nInd1, 1, 1.0);
+ nInd2 = nNewIndex;
+ }
+ }
+ } while(nFlag0 | nFlag1);
+ return TRUE;
+}
+
+/*************************************************************************
+|*
+|* ClipFlags eines Punktes ermitteln und zurueckgeben
+|*
+\************************************************************************/
+
+UINT16 Base3DCommon::GetClipFlags(UINT32 nInd)
+{
+ UINT16 nRetval(0);
+ Point4D& rPoint = aBuffers[nInd].Point();
+ rPoint.Homogenize();
+
+ if(rPoint[0] < -(1.0 + SMALL_DVALUE))
+ nRetval |= CLIPFLAG_LEFT;
+ if(rPoint[0] > 1.0 + SMALL_DVALUE)
+ nRetval |= CLIPFLAG_RIGHT;
+
+ if(rPoint[1] < -(1.0 + SMALL_DVALUE))
+ nRetval |= CLIPFLAG_BOTTOM;
+ if(rPoint[1] > 1.0 + SMALL_DVALUE)
+ nRetval |= CLIPFLAG_TOP;
+
+ if(rPoint[2] < -(1.0 + SMALL_DVALUE))
+ nRetval |= CLIPFLAG_FRONT;
+ if(rPoint[2] > 1.0 + SMALL_DVALUE)
+ nRetval |= CLIPFLAG_BACK;
+
+ return nRetval;
+}
+
+/*************************************************************************
+|*
+|* Dreieck am canonical view volume clippen
+|* Ergebnis steht indirekt ueber eine Indizierungstabelle in
+|* aEdgeIndex[nEdgeDestination][0 .. aEdgeIndexFree[nEdgeDestination]]
+|*
+\************************************************************************/
+
+BOOL Base3DCommon::Clip3DPolygon(UINT32Bucket& rEdgeIndex)
+{
+ UINT32 i;
+ UINT16 nAllFlagsOr, nAllFlagsAnd;
+
+ do
+ {
+ // ClipFlags holen
+ nAllFlagsOr = 0;
+ nAllFlagsAnd = CLIPFLAG_ALL;
+
+ for(i=0; i < rEdgeIndex.Count(); i++)
+ {
+ UINT16 nFlag = GetClipFlags(rEdgeIndex[i]);
+ nAllFlagsOr |= nFlag;
+ nAllFlagsAnd &= nFlag;
+ }
+
+ // Alle Endpunkte drin?
+ if(!nAllFlagsOr)
+ return TRUE;
+
+ // Dreieck komplett draussen?
+ if(nAllFlagsAnd)
+ return FALSE;
+
+ if(nAllFlagsOr & (CLIPFLAG_FRONT|CLIPFLAG_BACK))
+ {
+ // clippen in Z
+ if(nAllFlagsOr & CLIPFLAG_FRONT)
+ {
+ ClipPoly(rEdgeIndex, 2, TRUE);
+ }
+ else
+ {
+ ClipPoly(rEdgeIndex, 2, FALSE);
+ }
+ }
+ else if(nAllFlagsOr & (CLIPFLAG_LEFT|CLIPFLAG_RIGHT))
+ {
+ // clippen in X
+ if(nAllFlagsOr & CLIPFLAG_LEFT)
+ {
+ ClipPoly(rEdgeIndex, 0, TRUE);
+ }
+ else
+ {
+ ClipPoly(rEdgeIndex, 0, FALSE);
+ }
+ }
+ else
+ {
+ // clippen in Y
+ if(nAllFlagsOr & CLIPFLAG_BOTTOM)
+ {
+ ClipPoly(rEdgeIndex, 1, TRUE);
+ }
+ else
+ {
+ ClipPoly(rEdgeIndex, 1, FALSE);
+ }
+ }
+ } while(nAllFlagsOr);
+ return TRUE;
+}
+
+/*************************************************************************
+|*
+|* Testen, ob die Entitaet nInd innerhalb des canonical view volume liegt
+|*
+\************************************************************************/
+
+BOOL Base3DCommon::IsInside(UINT32 nInd, UINT32 nDim, BOOL bLow)
+{
+ B3dEntity& aEntity = aBuffers[nInd];
+ if(bLow)
+ {
+ if(aEntity.Point()[nDim] < -1.0)
+ return FALSE;
+ }
+ else
+ {
+ if(aEntity.Point()[nDim] > 1.0)
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/*************************************************************************
+|*
+|* Macht einen Clippingdurchgang eines Polygons in der angegebenen
+|* Dimension. Es werden eventuell neue Punkte erzeugt.
+|*
+\************************************************************************/
+
+void Base3DCommon::ClipPoly(UINT32Bucket& rEdgeIndex, UINT16 nDim, BOOL bLow)
+{
+ UINT32 nNumEdges = rEdgeIndex.Count();
+ UINT32 nCurrentInd = rEdgeIndex[0];
+ BOOL bCurrentInside = IsInside(nCurrentInd, nDim, bLow);
+ UINT32 nNextInd;
+ BOOL bNextInside;
+ UINT32Bucket aEdgeIndex(8);
+
+ for(UINT32 i=0;i<nNumEdges;i++)
+ {
+ // hole naechsten Eckpunkt
+ nNextInd = i+1;
+ if(nNextInd == nNumEdges)
+ nNextInd = 0;
+ nNextInd = rEdgeIndex[nNextInd];
+ bNextInside = IsInside(nNextInd, nDim, bLow);
+
+ // behandle die Kante nCurrentInd, nNextInd in der Dimension
+ // nDim gegen die Grenze -1.0
+ if(bCurrentInside)
+ {
+ // aktuellen Punkt hinzufuegen
+ aEdgeIndex.Append(nCurrentInd);
+ if(!bNextInside)
+ {
+ // drin -> draussen
+ // Platz fuer Schnittpunkt allokieren
+ UINT32 nNewIndex = aBuffers.Count();
+ aBuffers.Append();
+
+ // Schnittpunkt berechnen
+ if(bLow)
+ CalcNewPoint(nNewIndex, nCurrentInd, nNextInd, nDim, -1.0);
+ else
+ CalcNewPoint(nNewIndex, nNextInd, nCurrentInd, nDim, 1.0);
+
+ // EdgeFlag behandeln, beim Verlassen zuruecksetzen
+ if(aBuffers[nCurrentInd].IsEdgeVisible())
+ aBuffers[nNewIndex].SetEdgeVisible(FALSE);
+
+ // Schnittpunkt hinzufuegen
+ aEdgeIndex.Append(nNewIndex);
+ }
+ }
+ else
+ {
+ if(bNextInside)
+ {
+ // draussen -> drin
+ // Platz fuer Schnittpunkt allokieren
+ UINT32 nNewIndex = aBuffers.Count();
+ aBuffers.Append();
+
+ // Schnittpunkt berechnen
+ if(bLow)
+ CalcNewPoint(nNewIndex, nNextInd, nCurrentInd, nDim, -1.0);
+ else
+ CalcNewPoint(nNewIndex, nCurrentInd, nNextInd, nDim, 1.0);
+
+ // EdgeFlag behandeln, selber Wert wie Vorgaenger
+ aBuffers[nNewIndex].SetEdgeVisible(aBuffers[nCurrentInd].IsEdgeVisible());
+
+ // Schnittpunkt hinzufuegen
+ aEdgeIndex.Append(nNewIndex);
+ }
+ }
+
+ // bereite naechste Kante vor
+ nCurrentInd = nNextInd;
+ bCurrentInside = bNextInside;
+ }
+
+ // Indices kopieren
+ rEdgeIndex = aEdgeIndex;
+}
+
+/*************************************************************************
+|*
+|* Die Entitaet nNew muss berechnet werden in der angegebenen
+|* Dimension an der Grenze fBound.
+|*
+\************************************************************************/
+
+void Base3DCommon::CalcNewPoint(UINT32 nNew, UINT32 nHigh, UINT32 nLow,
+ UINT16 nDim, double fBound)
+{
+ B3dEntity& aNew = aBuffers[nNew];
+ B3dEntity& aHigh = aBuffers[nHigh];
+ B3dEntity& aLow = aBuffers[nLow];
+ aNew.Reset();
+
+ double fFactor = 1.0;
+ if(aLow.Point()[nDim] != aHigh.Point()[nDim])
+ fFactor = (fBound - aHigh.Point()[nDim])
+ / (aLow.Point()[nDim] - aHigh.Point()[nDim]);
+
+#ifdef DBG_UTIL
+ if(fFactor > 1.0 || fFactor < 0.0)
+ DBG_ERROR("Wrong clipping factor (out of range)!");
+ if(fFactor == 1.0 || fFactor == 0.0)
+ DBG_ERROR("Wrong clipping factor (on boundary)!");
+#endif
+
+ // Neuen Punkt berechnen, aber Reihenfolge der
+ // Punkte aufrecht erhalten um die Sichtbarkeit
+ // der Kanten zu retten
+ aLow.ForceEqualBase(GetTransformationSet(), aHigh);
+ if(fBound < 0.0)
+ aNew.CalcInBetween(aLow, aHigh, 1.0 - fFactor);
+ else
+ aNew.CalcInBetween(aHigh, aLow, fFactor);
+
+ // WICHTIG fuer die Numerik beim Clippen: Die betroffene
+ // Koordinate wirklich auf fBound setzen, nicht berechnen.
+ // Beim Berechnen koennen nur wieder Ungenauigkeiten auftreten,
+ // die bei der Bestimmung der Clipping-Grenzen zu
+ // Endlosschleifen fuehren koennen.
+ aNew.Point()[nDim] = fBound;
+}
+
+/*************************************************************************
+|*
+|* Beleuchtungsmodell (ColorModel) in einem Punkt loesen
+|* Dabei das Ergebnis in rCol ablegen, d.h. wirklich modifizieren
+|*
+\************************************************************************/
+
+void Base3DCommon::SolveColorModel(B3dColor& rCol, Vector3D& rVec,
+ const Vector3D& rPnt)
+{
+ if(GetLightGroup() && GetLightGroup()->IsLightingEnabled())
+ {
+ B3dMaterial& rMat = GetMaterialObject();
+ BOOL bDoSolve(TRUE);
+
+ // Welches Material? Zeigt der Vektor vom Betrachter
+ // weg oder auf diesen?
+ if(rVec.Z() < 0.0)
+ {
+ // Rueckseite, soll diese dargestellt werden?
+ if(GetLightGroup() && GetLightGroup()->GetModelTwoSide())
+ {
+ rMat = GetMaterialObject(Base3DMaterialBack);
+ }
+ else
+ {
+ bDoSolve = FALSE;
+ }
+ }
+ if(bDoSolve)
+ rCol = SolveColorModel(rMat, rVec, rPnt);
+ }
+}
+
+B3dColor Base3DCommon::SolveColorModel(B3dMaterial& rMat, Vector3D& rVec, const Vector3D& rPnt)
+{
+ // Material emission einbeziehen
+ B3dColor aNew = rMat.GetMaterial(Base3DMaterialEmission);
+
+ // global ambient light beachten
+ aNew += (B3dColor)rMat.GetMaterial(Base3DMaterialAmbient)
+ * (B3dColor)GetLightGroup()->GetGlobalAmbientLight();
+
+ if(GetTransformationSet())
+ {
+ // Die Punktkoordinate liegt in ClipCoordinates vor, wird
+ // aber zur Farbberechnung in EyeCoordinates benoetigt.
+ // Fuehre eine Ruecktransformation durch.
+ Vector3D aPnt(rPnt);
+ aPnt = GetTransformationSet()->DeviceToEyeCoor(aPnt);
+
+ // Falls die Normale vom Betrachter weg zeigt und das Beleuchtungs-
+ // modell doppelseitig ist, Normale umdrehen
+ Vector3D aVec(rVec);
+ if(rVec.Z() < 0.0 && GetLightGroup()->GetModelTwoSide())
+ aVec = -rVec;
+
+ // Die einzelnen Lichtquellen einbeziehen
+ for(UINT16 i=Base3DLight0; i <= Base3DLight7; i++)
+ {
+ if(GetLightGroup()->IsEnabled((Base3DLightNumber)i))
+ {
+ aNew += SolveColorModel(
+ GetLightGroup()->GetLightObject((Base3DLightNumber)i),
+ rMat, aVec, aPnt);
+ }
+ }
+
+ // Transparenz aus der Diffuse (=Objekt-) Farbe uebernehmen
+ aNew.SetTransparency(rMat.GetMaterial(Base3DMaterialDiffuse).GetTransparency());
+ }
+ return aNew;
+}
+
+/*************************************************************************
+|*
+|* Beleuchtungsmodell (ColorModel) fuer eine Lichtquelle loesen
+|*
+\************************************************************************/
+
+B3dColor Base3DCommon::SolveColorModel(B3dLight& rLight, B3dMaterial& rMat,
+ Vector3D& rVec, const Vector3D& rPnt)
+{
+ B3dColor aRetval(255, 0, 0, 0);
+ if(rLight.IsEnabled())
+ {
+ // Faktor mit Attenuation 1.0 initialisieren, falls
+ // IsDirectionalSource() == TRUE
+ double fFac = 1.0;
+ Vector3D aLightToVertex;
+ BOOL bLightToVertex(FALSE);
+
+ if(!rLight.IsDirectionalSource())
+ {
+ // positional light
+ // echten attenuation Faktor ermitteln
+ fFac = rLight.GetConstantAttenuation();
+ if(rLight.IsLinearOrQuadratic())
+ {
+ // jetzt wird die Entfernung zwischen Lichtposition
+ // und Punkt benoetigt
+ aLightToVertex = rPnt - rLight.GetPositionEye();
+ bLightToVertex = TRUE;
+ double fLen = aLightToVertex.GetLength();
+ aLightToVertex.Normalize();
+
+ fFac += rLight.GetLinearAttenuation() * fLen;
+ fFac += rLight.GetQuadraticAttenuation() * fLen * fLen;
+ }
+ // Kehrwert bilden
+ if(fFac != 1.0 && fFac != 0.0)
+ fFac = 1.0 / fFac;
+
+ if(rLight.IsSpot())
+ {
+ // Spotlight it immer ein positional light
+ // Spotlight effect, wird auf den Faktor multipliziert
+ if(!bLightToVertex)
+ {
+ aLightToVertex = rPnt - rLight.GetPositionEye();
+ aLightToVertex.Normalize();
+ bLightToVertex = TRUE;
+ }
+ double fCosAngle = aLightToVertex.Scalar(rLight.GetSpotDirection());
+ // innerhalb des konus?
+ if(fCosAngle <= rLight.GetCosSpotCutoff())
+ {
+ if(fCosAngle > 0.000001)
+ {
+ if(rLight.GetSpotExponent() != 0.0)
+ fCosAngle = pow(fCosAngle, rLight.GetSpotExponent());
+ fFac *= fCosAngle;
+ }
+ else
+ {
+ fFac = 0.0;
+ }
+ }
+ else
+ {
+ // Ausserhalb des Konus, keine Beleuchtung
+ fFac = 0.0;
+ }
+ }
+ }
+
+ // falls es etwas zu beleuchten gibt...
+ if(fFac != 0.0)
+ {
+ // Ambient term
+ if(rLight.IsAmbient())
+ {
+ aRetval += (B3dColor)rLight.GetIntensity(Base3DMaterialAmbient)
+ * (B3dColor)rMat.GetMaterial(Base3DMaterialAmbient);
+ }
+
+ if(rLight.IsDiffuse() || rLight.IsSpecular())
+ {
+ if(bLightToVertex)
+ {
+ // Falls hier schon berechnet, handelt es sich
+ // auch um ein positional light
+ aLightToVertex = -aLightToVertex;
+ }
+ else
+ {
+ if(rLight.IsDirectionalSource())
+ {
+ // Vektor direkt nehmen
+ aLightToVertex = rLight.GetPosition();
+ }
+ else
+ {
+ // Umgerechnete Lichtposition nehmen
+ aLightToVertex = rLight.GetPositionEye();
+ // Betrachtete Position abziehen -> Einheitsvektor
+ // vom Punkt zur Lichtquelle
+ aLightToVertex -= rPnt;
+ }
+ aLightToVertex.Normalize();
+ }
+ double fCosFac = aLightToVertex.Scalar(rVec);
+
+ if(fCosFac > 0.000001)
+ {
+ if(rLight.IsDiffuse())
+ {
+ // Diffuse term
+ aRetval += (B3dColor)rLight.GetIntensity(Base3DMaterialDiffuse)
+ * (B3dColor)rMat.GetMaterial(Base3DMaterialDiffuse)
+ * fCosFac;
+ }
+ if(rLight.IsSpecular())
+ {
+ // Specular term
+ if(GetLightGroup()->GetLocalViewer())
+ {
+ // use vector 0,0,1
+ aLightToVertex.Z() += 1.0;
+ }
+ else
+ {
+ // vector Vertex to Viewpoint berechnen in
+ // Augkoordinaten, ist 0 - rPnt
+ aLightToVertex -= rPnt;
+ }
+ aLightToVertex.Normalize();
+ fCosFac = aLightToVertex.Scalar(rVec);
+ if(fCosFac > 0.000001)
+ {
+ if(rMat.GetShininess())
+ fCosFac = pow(fCosFac, rMat.GetShininess());
+ aRetval += (B3dColor)rLight.GetIntensity(Base3DMaterialSpecular)
+ * (B3dColor)rMat.GetMaterial(Base3DMaterialSpecular)
+ * fCosFac;
+ }
+ }
+ }
+ }
+
+ // jetzt fFac aufrechnen
+ if(fFac != 1.0)
+ aRetval *= fFac;
+ }
+ }
+ return aRetval;
+}
+
+
diff --git a/goodies/source/base3d/b3dcommn.hxx b/goodies/source/base3d/b3dcommn.hxx
new file mode 100644
index 000000000000..300c84e6cf21
--- /dev/null
+++ b/goodies/source/base3d/b3dcommn.hxx
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * $RCSfile: b3dcommn.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _B3D_B3DCOMMN_HXX
+#define _B3D_B3DCOMMN_HXX
+
+#ifndef _B3D_BASE3D_HXX
+#include "base3d.hxx"
+#endif
+
+#ifndef _B3D_B3DGEOM_HXX
+#include "b3dgeom.hxx"
+#endif
+
+// Defines fuer clipping flags (nFlag0,1)
+#define CLIPFLAG_LEFT 0x0001
+#define CLIPFLAG_RIGHT 0x0002
+#define CLIPFLAG_BOTTOM 0x0004
+#define CLIPFLAG_TOP 0x0008
+#define CLIPFLAG_FRONT 0x0010
+#define CLIPFLAG_BACK 0x0020
+#define CLIPFLAG_ALL (CLIPFLAG_LEFT|CLIPFLAG_RIGHT| \
+ CLIPFLAG_BOTTOM|CLIPFLAG_TOP| \
+ CLIPFLAG_FRONT|CLIPFLAG_BACK)
+
+/*************************************************************************
+|*
+|* Bucket fuer Indices
+|*
+\************************************************************************/
+
+BASE3D_DECL_BUCKET(UINT32, Bucket)
+
+/*************************************************************************
+|*
+|* Die Basisklasse fuer Standard 3D Ausgaben auf StarView Basis
+|*
+\************************************************************************/
+
+#define BUFFER_OVERHEAD (20)
+
+class Base3DCommon : public Base3D
+{
+protected:
+ // Buffers fuer temporaere geometrische Daten
+ B3dEntityBucket aBuffers;
+
+ // Remember if last primitive was rejected
+ BOOL bLastPrimitiveRejected : 1;
+
+public:
+ Base3DCommon(OutputDevice* pOutDev);
+ virtual ~Base3DCommon();
+
+ // Beleuchtung setzen/lesen
+ virtual void SetLightGroup(B3dLightGroup* pSet, BOOL bSetGlobal=TRUE);
+
+ // Info if last primitive was rejected
+ BOOL WasLastPrimitiveRejected()
+ { return bLastPrimitiveRejected; }
+
+ // Szenenverwaltung
+ virtual void StartScene();
+ virtual void EndScene();
+
+protected:
+ // Geometrische Daten uebergeben
+ virtual B3dEntity& ImplGetFreeEntity();
+
+ virtual void ImplStartPrimitive();
+ virtual void ImplEndPrimitive();
+ virtual void ImplPostAddVertex(B3dEntity& rEnt);
+
+ void Create3DPoint(UINT32 nInd);
+ void Create3DPointClipped(UINT32 nInd);
+ void Create3DLine(UINT32 nInd1, UINT32 nInd2);
+ void Create3DLineClipped(UINT32 nInd1, UINT32 nInd2);
+ void Create3DTriangle(UINT32 nInd1, UINT32 nInd2, UINT32 nInd3);
+
+ virtual void Clipped3DPoint(UINT32 nInd) = 0;
+ virtual void Clipped3DLine(UINT32 nInd1,UINT32 nInd2) = 0;
+ virtual void Clipped3DTriangle(UINT32 nInd1,UINT32 nInd2, UINT32 nInd3) = 0;
+
+ // clipping functions
+ BOOL AreEqual(UINT32 nInd1, UINT32 nInd2);
+ BOOL Clip3DPoint(UINT32 nInd);
+ BOOL Clip3DLine(UINT32& nInd1,UINT32& nInd2);
+ BOOL Clip3DPolygon(UINT32Bucket& rEdgeIndex);
+ UINT16 GetClipFlags(UINT32 nInd);
+ BOOL IsInside(UINT32 nInd, UINT32 nDim, BOOL bLow);
+ void ClipPoly(UINT32Bucket& rEdgeIndex, UINT16 nDim,BOOL bLow);
+ void CalcNewPoint(UINT32 nNew,UINT32 nHigh,UINT32 nLow,
+ UINT16 nDim, double fBound);
+
+ // Beleuchtungsmodell (ColorModel) in einem Punkt loesen
+ // Punkt MUSS in ClipCoordinates vorliegen !
+ void SolveColorModel(B3dColor&, Vector3D&, const Vector3D&);
+ B3dColor SolveColorModel(B3dMaterial& rMat, Vector3D& rVec,
+ const Vector3D& rPnt);
+
+ // Beleuchtungsmodell (ColorModel) fuer eine Lichtquelle loesen
+ B3dColor SolveColorModel(B3dLight& rLight, B3dMaterial& rMat,
+ Vector3D& rVec, const Vector3D& rPnt);
+};
+
+
+#endif // _B3D_B3DCOMMN_HXX
diff --git a/goodies/source/base3d/b3dcompo.cxx b/goodies/source/base3d/b3dcompo.cxx
new file mode 100644
index 000000000000..2b8094a28581
--- /dev/null
+++ b/goodies/source/base3d/b3dcompo.cxx
@@ -0,0 +1,1180 @@
+/*************************************************************************
+ *
+ * $RCSfile: b3dcompo.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _B3D_B3DCOMPO_HXX
+#include "b3dcompo.hxx"
+#endif
+
+#ifndef _B3D_BASE3D_HXX
+#include "base3d.hxx"
+#endif
+
+#ifndef _B3D_B3DGEOM_HXX
+#include "b3dgeom.hxx"
+#endif
+
+#ifndef _INC_FLOAT
+#include <float.h>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+/*************************************************************************
+|*
+|* Vergleiche fuer doubles mit bound
+|*
+\************************************************************************/
+
+#define DOUBLE_EQUAL(a,b) (fabs(a-b) < SMALL_DVALUE)
+#define DOUBLE_NOT_EQUAL(a,b) (fabs(a-b) > SMALL_DVALUE)
+#define DOUBLE_SMALLER(a,b) ((a + (SMALL_DVALUE / 2.0)) < b)
+#define DOUBLE_BIGGER(a,b) ((a - (SMALL_DVALUE / 2.0)) > b)
+
+/*************************************************************************
+|*
+|* Bucket fuer Kantenliste, vertikaler Teil
+|*
+\************************************************************************/
+
+BASE3D_IMPL_BUCKET(B3dEdgeList, Bucket)
+
+/*************************************************************************
+|*
+|* Bucket fuer Kantenliste, horizontaler Teil
+|*
+\************************************************************************/
+
+BASE3D_IMPL_BUCKET(B3dEdgeEntry, Bucket)
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+B3dComplexPolygon::B3dComplexPolygon()
+: aEntityBuffer(14), // 16K
+ aEdgeList(12), // 4K
+ aEdgeEntry(12) // 4K
+{
+ EmptyBuffers();
+ bTestForCut = TRUE;
+ nHighestEdge = 0L;
+ pBase3D = NULL;
+ pGeometry = NULL;
+ pLastVertex = NULL;
+}
+
+/*************************************************************************
+|*
+|* Gib einen neuen freien Eintrag zurueck
+|*
+\************************************************************************/
+
+B3dEntity &B3dComplexPolygon::GetFreeEntity()
+{
+ aEntityBuffer.Append();
+ return aEntityBuffer[aEntityBuffer.Count() - 1];
+}
+
+/*************************************************************************
+|*
+|* Ein neuer Punkt ist ausgefuellt
+|*
+\************************************************************************/
+
+void B3dComplexPolygon::PostAddVertex(B3dEntity &rVertex)
+{
+ if(pLastVertex)
+ {
+ if(ArePointsEqual(*pLastVertex, rVertex))
+ {
+ aEntityBuffer.Remove();
+ return;
+ }
+ if(!nNewPolyStart)
+ {
+ if(nHighestEdge)
+ TestHighestEdge(rVertex);
+ else
+ nHighestEdge = aEntityBuffer.Count();
+ }
+ }
+
+ // Zeiger auf letzten hinzugefuegten Punkt setzen
+ pLastVertex = &rVertex;
+}
+
+/*************************************************************************
+|*
+|* Testet, ob die neue Edge in allen Freiheitsgraden groesser ist
+|* als die momentane
+|*
+\************************************************************************/
+
+void B3dComplexPolygon::TestHighestEdge(B3dEntity& rVertex)
+{
+ B3dEntity& rHighest = aEntityBuffer[nHighestEdge - 1];
+ if(rVertex.GetX() <= rHighest.GetX())
+ {
+ if(rVertex.GetX() < rHighest.GetX())
+ {
+ nHighestEdge = aEntityBuffer.Count();
+ }
+ else
+ {
+ if(rVertex.GetY() <= rHighest.GetY())
+ {
+ if(rVertex.GetY() < rHighest.GetY())
+ {
+ nHighestEdge = aEntityBuffer.Count();
+ }
+ else
+ {
+ if(rVertex.GetZ() < rHighest.GetZ())
+ {
+ nHighestEdge = aEntityBuffer.Count();
+ }
+ }
+ }
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Vergleicht zwei Punkte auf ihren INHALT
+|* und fuellt die 2D-Koordinaten aus
+|*
+\************************************************************************/
+
+BOOL B3dComplexPolygon::ArePointsEqual(B3dEntity& rFirst,
+ B3dEntity& rSecond)
+{
+ // Wenn der Punkt dem letzten gleich ist, gar nicht behandeln
+ if(rFirst.Point().GetVector3D() == rSecond.Point().GetVector3D())
+ return TRUE;
+ return FALSE;
+}
+
+/*************************************************************************
+|*
+|* Alles auf Startzustand, buffer leeren
+|*
+\************************************************************************/
+
+void B3dComplexPolygon::EmptyBuffers()
+{
+ aEntityBuffer.Erase();
+ nNewPolyStart = 0;
+ bOrientationValid = FALSE;
+ bNormalValid = FALSE;
+
+ // EdgeList und EdgeEntries leeren
+ pEdgeList = NULL;
+ aEdgeList.Erase();
+ aEdgeEntry.Erase();
+}
+
+/*************************************************************************
+|*
+|* Neues Teilpolygon beginnen
+|*
+\************************************************************************/
+
+void B3dComplexPolygon::StartPrimitive()
+{
+ // Bisherige Punkte verarbeiten
+ if(aEntityBuffer.Count() > nNewPolyStart)
+ ComputeLastPolygon();
+
+ // Zeiger auf letzten Punkt loeschen
+ pLastVertex = NULL;
+
+ // Hoechten Punkt vergesset
+ nHighestEdge = 0L;
+}
+
+/*************************************************************************
+|*
+|* Teilpolygon abschliessen
+|*
+\************************************************************************/
+
+void B3dComplexPolygon::ComputeLastPolygon(BOOL bIsLast)
+{
+ // Letzten Punkt mit erstem vergleichen, evtl
+ // wegschmeissen
+ if(pLastVertex)
+ {
+ if(ArePointsEqual(aEntityBuffer[nNewPolyStart], *pLastVertex))
+ {
+ // HighestEdge korrigieren, falls dieser geloescht werden soll
+ if(nHighestEdge && nHighestEdge == aEntityBuffer.Count())
+ nHighestEdge = nNewPolyStart + 1;
+
+ aEntityBuffer.Remove();
+ }
+ }
+
+ // Sind noch genug Punkte da?
+ if(aEntityBuffer.Count() < nNewPolyStart + 3)
+ {
+ // Geometrie ausgeben, obwohl zuwenig Punkte fuer ein Polygon
+ if(pBase3D)
+ {
+ pBase3D->StartPrimitive(Base3DPolygon);
+ for(UINT32 a=0; a < aEntityBuffer.Count(); a++)
+ {
+ pBase3D->SetEdgeFlag(aEntityBuffer[a].IsEdgeVisible());
+ pBase3D->AddVertex(aEntityBuffer[a]);
+ }
+ pBase3D->EndPrimitive();
+ }
+ else if(pGeometry)
+ {
+ pGeometry->StartComplexPrimitive();
+ for(UINT32 a=0; a < aEntityBuffer.Count(); a++)
+ pGeometry->AddComplexVertex(aEntityBuffer[a], aEntityBuffer[a].IsEdgeVisible());
+ pGeometry->EndComplexPrimitive();
+ }
+ }
+ else
+ {
+ if(!nNewPolyStart && bIsLast && IsConvexPolygon())
+ {
+ // Falls das PolyPolygon nur aus einem Polygon besteht
+ // und es Konvex ist, ist man fertig.
+ // Um die Qualitaet zu verbessern, wird fuer
+ // Polygone ab einer gewissen Punktzahl ein
+ // abschliessender Mittelpunkt generiert.
+ if(pBase3D)
+ {
+ pBase3D->StartPrimitive(Base3DPolygon);
+ if(aEntityBuffer.Count() > 4)
+ {
+ B3dEntity aNew;
+ aNew.CalcMiddle(aEntityBuffer[0], aEntityBuffer[aEntityBuffer.Count() / 2]);
+ pBase3D->SetEdgeFlag(FALSE);
+ pBase3D->AddVertex(aNew);
+ for(UINT32 a=0; a < aEntityBuffer.Count(); a++)
+ {
+ pBase3D->SetEdgeFlag(aEntityBuffer[a].IsEdgeVisible());
+ pBase3D->AddVertex(aEntityBuffer[a]);
+ }
+ pBase3D->SetEdgeFlag(FALSE);
+ pBase3D->AddVertex(aEntityBuffer[0]);
+ }
+ else
+ {
+ for(UINT32 a=0; a < aEntityBuffer.Count(); a++)
+ {
+ pBase3D->SetEdgeFlag(aEntityBuffer[a].IsEdgeVisible());
+ pBase3D->AddVertex(aEntityBuffer[a]);
+ }
+ }
+ pBase3D->EndPrimitive();
+ }
+ else if(pGeometry)
+ {
+ pGeometry->StartComplexPrimitive();
+ if(aEntityBuffer.Count() > 4)
+ {
+ B3dEntity aNew;
+ aNew.CalcMiddle(aEntityBuffer[0], aEntityBuffer[aEntityBuffer.Count() / 2]);
+ pGeometry->AddComplexVertex(aNew, FALSE);
+ for(UINT32 a=0; a < aEntityBuffer.Count(); a++)
+ pGeometry->AddComplexVertex(aEntityBuffer[a], aEntityBuffer[a].IsEdgeVisible());
+ pGeometry->AddComplexVertex(aEntityBuffer[0], FALSE);
+ }
+ else
+ {
+ for(UINT32 a=0; a < aEntityBuffer.Count(); a++)
+ pGeometry->AddComplexVertex(aEntityBuffer[a], aEntityBuffer[a].IsEdgeVisible());
+ }
+ pGeometry->EndComplexPrimitive();
+ }
+ }
+ else
+ {
+ if(!bNormalValid)
+ ChooseNormal();
+
+ // Einsortieren
+ UINT32 nUpperBound = aEntityBuffer.Count();
+
+ // Als Polygon behandeln
+ if(GetTestForCut())
+ {
+ UINT32 a;
+ for(a=nNewPolyStart + 1; a < nUpperBound; a++)
+ AddEdgeCut(&aEntityBuffer[a-1], &aEntityBuffer[a]);
+
+ // Polygon schliessen
+ AddEdgeCut(&aEntityBuffer[a-1], &aEntityBuffer[nNewPolyStart]);
+ }
+ else
+ {
+ UINT32 a;
+ for(a=nNewPolyStart + 1; a < nUpperBound; a++)
+ AddEdge(&aEntityBuffer[a-1], &aEntityBuffer[a]);
+
+ // Polygon schliessen
+ AddEdge(&aEntityBuffer[a-1], &aEntityBuffer[nNewPolyStart]);
+ }
+
+ // Hier setzen, da evtl. bereits neue Punkte
+ // durch Schnitte hinzugekommen sind
+ nNewPolyStart = aEntityBuffer.Count();
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Orientierung des ersten Polygons ermitteln
+|*
+\************************************************************************/
+
+void B3dComplexPolygon::ChooseNormal()
+{
+ if(nHighestEdge)
+ {
+ UINT32 nHigh = nHighestEdge - 1;
+ UINT32 nPrev = (nHigh != 0) ? nHigh - 1 : aEntityBuffer.Count() - 1;
+ UINT32 nNext = (nHigh + 1 != aEntityBuffer.Count()) ? nHigh + 1 : nNewPolyStart;
+
+ // Punkt, Vorgaenger und Nachfolger holen
+ const Vector3D& rHigh = aEntityBuffer[nHigh].Point().GetVector3D();
+ const Vector3D& rPrev = aEntityBuffer[nPrev].Point().GetVector3D();
+ const Vector3D& rNext = aEntityBuffer[nNext].Point().GetVector3D();
+
+ // Normale bilden
+ aNormal = (rPrev - rHigh)|(rNext - rHigh);
+ if(aNormal != Vector3D())
+ aNormal.Normalize();
+ else
+ aNormal = Vector3D(0.0, 0.0, -1.0);
+ }
+ bNormalValid = TRUE;
+}
+
+/*************************************************************************
+|*
+|* Komplexes Polygon ausgeben
+|*
+\************************************************************************/
+
+void B3dComplexPolygon::EndPrimitive(Base3D* pB3D)
+{
+ // Funktionszeiger setzen
+ pBase3D = pB3D;
+
+ // Letztes angefangenes Poly verarbeiten
+ ComputeLastPolygon(TRUE);
+
+ // Wenn es Kanten gibt
+ if(pEdgeList)
+ {
+ // Dreiecke generieren und ausgeben
+ pBase3D->StartPrimitive(Base3DTriangles);
+ while(pEdgeList)
+ ExtractTriangle();
+ pBase3D->EndPrimitive();
+ }
+
+ // Buffer leeren
+ EmptyBuffers();
+
+ // Zeiger wieder loeschen
+ pBase3D = NULL;
+}
+
+void B3dComplexPolygon::EndPrimitive(B3dGeometry *pGeom)
+{
+ // Funktionszeiger setzen
+ pGeometry = pGeom;
+
+ // Letztes angefangenes Poly verarbeiten
+ ComputeLastPolygon(TRUE);
+
+ // Dreiecke generieren und ausgeben
+ while(pEdgeList)
+ ExtractTriangle();
+
+ // Buffer leeren
+ EmptyBuffers();
+
+ // Zeiger wieder loeschen
+ pGeometry = NULL;
+}
+
+/*************************************************************************
+|*
+|* Teste aktuelles Polygon (0..aEntityBuffer.Count()) auf Konvexitaet
+|*
+\************************************************************************/
+
+BOOL B3dComplexPolygon::IsConvexPolygon()
+{
+ B3dEntity* pFirst = &aEntityBuffer[aEntityBuffer.Count() - 2];
+ B3dEntity* pSecond = &aEntityBuffer[aEntityBuffer.Count() - 1];
+ B3dEntity* pThird = &aEntityBuffer[0];
+ BOOL bDirection = IsLeft(pSecond, pFirst, pThird);
+ BOOL bOrder = CompareOrder(pSecond, pThird);
+ UINT16 nDirChanges(0);
+
+ for(UINT32 a = 1; nDirChanges <= 2 && a < aEntityBuffer.Count(); a++)
+ {
+ pFirst = pSecond;
+ pSecond = pThird;
+ pThird = &aEntityBuffer[a];
+
+ if(IsLeft(pSecond, pFirst, pThird) != bDirection)
+ return FALSE;
+
+ if(CompareOrder(pSecond, pThird) != bOrder)
+ {
+ nDirChanges++;
+ bOrder = !bOrder;
+ }
+ }
+ // Zuviele aenderungen der Ordnung, auf keinen Fall Convex
+ if(nDirChanges > 2)
+ return FALSE;
+
+ return TRUE;
+}
+
+/*************************************************************************
+|*
+|* Lexikografische Ordnung der beiden Punkte
+|*
+\************************************************************************/
+
+BOOL B3dComplexPolygon::CompareOrder(B3dEntity* pFirst, B3dEntity* pSecond)
+{
+ if(pFirst->GetX() < pSecond->GetX())
+ return FALSE;
+ if(pFirst->GetX() > pSecond->GetX())
+ return TRUE;
+ if(pFirst->GetY() < pSecond->GetY())
+ return FALSE;
+ return TRUE;
+}
+
+/*************************************************************************
+|*
+|* Teste, ob die Punkte der Kante getauscht werden muessen
+|*
+\************************************************************************/
+
+BOOL B3dComplexPolygon::DoSwap(B3dEntity* pStart, B3dEntity* pEnd)
+{
+ if(DOUBLE_EQUAL(pStart->GetY(), pEnd->GetY()))
+ {
+ if(pStart->GetX() > pEnd->GetX())
+ return TRUE;
+ }
+ else
+ {
+ if(pStart->GetY() > pEnd->GetY())
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/*************************************************************************
+|*
+|* Kante nInd1, nInd2 zu Kantenliste hinzufuegen
+|*
+\************************************************************************/
+
+B3dEdgeEntry* B3dComplexPolygon::AddEdge(B3dEntity* pStart, B3dEntity* pEnd)
+{
+ if(DoSwap(pStart, pEnd))
+ return InsertEdge(GetList(pEnd), pStart, TRUE);
+ return InsertEdge(GetList(pStart), pEnd, TRUE);
+}
+
+/*************************************************************************
+|*
+|* Einen Listeneintrag suchen oder neu anlegen
+|* Liefert immer einen Listeneintrag zurueck
+|*
+\************************************************************************/
+
+B3dEdgeList* B3dComplexPolygon::GetList(B3dEntity* pStart)
+{
+ B3dEdgeList* pList = pEdgeList;
+ B3dEdgeList* pLast = NULL;
+
+ while(pList && pList->GetStart() != pStart && DoSwap(pStart, pList->GetStart()))
+ {
+ pLast = pList;
+ pList = pList->GetDown();
+ }
+
+ if(pList)
+ {
+ if(pList->GetStart() != pStart)
+ {
+ if(DOUBLE_NOT_EQUAL(pStart->GetX(), pList->GetXPos()) || DOUBLE_NOT_EQUAL(pStart->GetY(), pList->GetYPos()))
+ {
+ // Auf jeden Fall ein neuer Eintrag
+ aEdgeList.Append();
+ B3dEdgeList* pNewList = &aEdgeList[aEdgeList.Count() - 1];
+ pNewList->Reset();
+ pNewList->SetStart(pStart);
+
+ // vor pList einhaengen
+ // pLast KANN NULL SEIN!
+ pNewList->SetDown(pList);
+ pList->SetParent(pNewList);
+ if(pLast)
+ {
+ pNewList->SetParent(pLast);
+ pLast->SetDown(pNewList);
+ }
+ else
+ {
+ pEdgeList = pNewList;
+ }
+
+ // Returnwert setzen
+ pList = pNewList;
+ }
+ else
+ {
+ // pList->GetStart() != pStart, aber
+ // die Koordinaten sind praktisch identisch!
+ // Gib diese Liste zurueck, d.h.
+ // tue gar nichts
+ }
+ }
+ }
+ else
+ {
+ // pLast->GetYPos() < pStart->GetY(),
+ // Hinten anhaengen
+ aEdgeList.Append();
+ pList = &aEdgeList[aEdgeList.Count() - 1];
+ pList->Reset();
+ pList->SetStart(pStart);
+ if(pLast)
+ {
+ pList->SetParent(pLast);
+ pLast->SetDown(pList);
+ }
+ else
+ {
+ pEdgeList = pList;
+ }
+ }
+ return pList;
+}
+
+/*************************************************************************
+|*
+|* Eine Kante in eine Kantenliste einsortieren
+|* Die Kante wird dabei neu erzeugt
+|*
+\************************************************************************/
+
+B3dEdgeEntry* B3dComplexPolygon::InsertEdge(B3dEdgeList* pList,
+ B3dEntity* pEnd, BOOL bEdgeVisible)
+{
+ B3dEdgeEntry* pEntry = pList->GetEntries();
+
+ // Immer ein neuer Eintrag
+ aEdgeEntry.Append();
+ B3dEdgeEntry* pNewEntry = &aEdgeEntry[aEdgeEntry.Count() - 1];
+ pNewEntry->Reset();
+ pNewEntry->SetEnd(pEnd);
+ pNewEntry->SetParent(pList);
+ pNewEntry->SetEdgeVisible(bEdgeVisible);
+
+ if(pEntry)
+ {
+ B3dEdgeEntry* pLast = NULL;
+ double fSlant = GetSlant(pNewEntry);
+ while(pEntry
+ && GetSlant(pEntry) < fSlant)
+ {
+ pLast = pEntry;
+ pEntry = pEntry->GetRight();
+ }
+
+ if(pEntry)
+ {
+ // GetSlant(pEntry) < fSlant
+ // GetSlant(pLast) >= fSlant
+ // Neuen Eintrag hinter pLast einfuegen
+ // pLast KANN NULL SEIN!
+ pNewEntry->SetRight(pEntry);
+ if(pLast)
+ {
+ pLast->SetRight(pNewEntry);
+ }
+ else
+ {
+ pList->SetEntries(pNewEntry);
+ }
+ }
+ else
+ {
+ // GetSlant(pEntry) >= fSlant
+ // Neuen Eintrag am Ende anhaengen
+ pLast->SetRight(pNewEntry);
+ }
+ }
+ else
+ {
+ pList->SetEntries(pNewEntry);
+ }
+ // Returnwert
+ return pNewEntry;
+}
+
+/*************************************************************************
+|*
+|* Steigung der Kante liefern
+|*
+\************************************************************************/
+
+double B3dComplexPolygon::GetSlant(B3dEdgeEntry* pEdge)
+{
+ double fDivisor = pEdge->GetYPos() - pEdge->GetParent()->GetYPos();
+ if(fabs(fDivisor) < SMALL_DVALUE)
+ return DBL_MAX;
+ return (pEdge->GetXPos() - pEdge->GetParent()->GetXPos()) / fDivisor;
+}
+
+/*************************************************************************
+|*
+|* Auf Schnitt mit einer vorhandenen Kante testen
+|*
+\************************************************************************/
+
+void B3dComplexPolygon::TestForCut(B3dEdgeEntry* pEntry)
+{
+ // pEntry: die bereits eingefuegte neue Kante, die mit allen
+ // aelteren Kanten geschnitten werden soll
+ B3dEdgeList* pList = pEdgeList;
+
+ while(pList && DOUBLE_SMALLER(pList->GetYPos(), pEntry->GetYPos()))
+ {
+ // nur in Gruppen mit anderem Startpunkt suchen
+ if(pList != pEntry->GetParent())
+ {
+ B3dEdgeEntry* pTestEntry = pList->GetEntries();
+
+ while(pTestEntry)
+ {
+ if(DOUBLE_BIGGER(pTestEntry->GetYPos(), pEntry->GetParent()->GetYPos()))
+ {
+ // es existiert eine vertikale Bereichsueberschneidung
+ // Min/Max fuer pEntry holen
+ double fXMin = pEntry->GetXPos();
+ double fXMax = pEntry->GetParent()->GetXPos();
+ if(fXMin > fXMax)
+ {
+ double fSwap = fXMin;
+ fXMin = fXMax;
+ fXMax = fSwap;
+ }
+
+ // Min/Max in X fuer Kandidat holen
+ double fTestXMin = pTestEntry->GetXPos();
+ double fTestXMax = pList->GetXPos();
+ if(fTestXMin > fTestXMax)
+ {
+ double fSwap = fTestXMin;
+ fTestXMin = fTestXMax;
+ fTestXMax = fSwap;
+ }
+
+ if(fTestXMin < fXMax && fTestXMax > fXMin)
+ {
+ // es existiert eine horizontale Bereichsueberschneidung
+ // ein Schnitt ist moeglich
+ double fCut = FindCut(pEntry, pTestEntry);
+
+ if(fCut != 0.0)
+ {
+ // Schnitt existiert! fCut ist aus dem Parameterbereich
+ // der ersten Kante, also pEntry. Neuen Punkt erzeugen.
+ B3dEntity& rNew = GetFreeEntity();
+ rNew.CalcInBetween(*pEntry->GetParent()->GetStart(), *pEntry->GetEnd(), fCut);
+
+ // Neuen Punkt und neue von diesem ausgehende Kanten erzeugen
+ B3dEdgeList* pNewPointList = GetList(&rNew);
+ B3dEdgeEntry* pEntry2 = InsertEdge(pNewPointList, pEntry->GetEnd(), pEntry->IsEdgeVisible());
+ InsertEdge(pNewPointList, pTestEntry->GetEnd(), pTestEntry->IsEdgeVisible());
+
+ // Beteiligte Entries kuerzen
+ pEntry->SetEnd(&rNew);
+ pTestEntry->SetEnd(&rNew);
+
+ // Das neue Ende von pEntry kann weitere Linien
+ // schneiden, also geht der test mit diesem weiter
+ TestForCut(pEntry2);
+
+ // Test mit gekuerztem pEntry fortsetzen
+ }
+ }
+ }
+
+ // naechster Entry
+ pTestEntry = pTestEntry->GetRight();
+ }
+ }
+
+ // naechste Liste
+ pList = pList->GetDown();
+ }
+}
+
+/*************************************************************************
+|*
+|* Berechne den Schnitt zwischen den beiden Kanten und gib den
+|* Schnittpunkt im Parameterbereich der 1. Kante zurueck
+|*
+\************************************************************************/
+
+double B3dComplexPolygon::FindCut(B3dEdgeEntry* pEdge1, B3dEdgeEntry* pEdge2)
+{
+ double fRetval = 0.0;
+ double fDeltaEdge2Y = pEdge2->GetYPos() - pEdge2->GetParent()->GetYPos();
+ double fDeltaEdge2X = pEdge2->GetXPos() - pEdge2->GetParent()->GetXPos();
+ double fDeltaEdge1X = pEdge1->GetXPos() - pEdge1->GetParent()->GetXPos();
+ double fDeltaEdge1Y = pEdge1->GetYPos() - pEdge1->GetParent()->GetYPos();
+
+ // Dynamische Grenze fuer parallelitaet berechnen
+ double fSmallValue = fabs((fDeltaEdge2Y + fDeltaEdge2X + fDeltaEdge1X + fDeltaEdge1Y) * (SMALL_DVALUE / 4.0));
+ double fZwi = (fDeltaEdge1X * fDeltaEdge2Y) - (fDeltaEdge1Y * fDeltaEdge2X);
+
+ if(fabs(fZwi) > fSmallValue)
+ {
+ fZwi = (fDeltaEdge2Y * (pEdge2->GetParent()->GetXPos() - pEdge1->GetParent()->GetXPos())
+ + fDeltaEdge2X * (pEdge1->GetParent()->GetYPos() - pEdge2->GetParent()->GetYPos())) / fZwi;
+
+ // Im Parameterbereich der ersten Kante (ohne Punkte) ?
+ if(fZwi > fSmallValue && fZwi < 1.0 - fSmallValue)
+ {
+ // Schnitt liegt im Parameterbereich der ersten
+ // Linie, aber auch in dem der zweiten?
+ if(fabs(fDeltaEdge2X) > fSmallValue && fabs(fDeltaEdge2X) > fabs(fDeltaEdge2Y))
+ {
+ fDeltaEdge2Y = (pEdge1->GetParent()->GetXPos() + fZwi
+ * fDeltaEdge1X - pEdge2->GetParent()->GetXPos()) / fDeltaEdge2X;
+
+ // Parameterbereich der zweiten schliesst Start/Ende mit ein!
+ if(fDeltaEdge2Y > -fSmallValue && fDeltaEdge2Y < 1.0 + fSmallValue)
+ {
+ // Ja. Zuweisen.
+ fRetval = fZwi;
+ }
+ }
+ else if(fabs(fDeltaEdge2Y) > fSmallValue)
+ {
+ fDeltaEdge2X = (pEdge1->GetParent()->GetYPos() + fZwi
+ * fDeltaEdge1Y - pEdge2->GetParent()->GetYPos()) / fDeltaEdge2Y;
+
+ // Parameterbereich der zweiten schliesst Start/Ende mit ein!
+ if(fDeltaEdge2X > -fSmallValue && fDeltaEdge2X < 1.0 + fSmallValue)
+ {
+ // Ja. Zuweisen.
+ fRetval = fZwi;
+ }
+ }
+ }
+ }
+ return fRetval;
+}
+
+/*************************************************************************
+|*
+|* Testet, ob die angegebene Kante schon existiert
+|* Ja: Entfernen
+|* Nein: Einfuegen
+|*
+\************************************************************************/
+
+BOOL B3dComplexPolygon::SwitchEdgeExistance(B3dEntity* pStart,
+ B3dEntity* pEnd)
+{
+ if(DoSwap(pStart, pEnd))
+ {
+ B3dEntity* pZwi = pStart;
+ pStart = pEnd;
+ pEnd = pZwi;
+ }
+
+ if(pEdgeList)
+ {
+ // Suchen
+ B3dEdgeList* pList = pEdgeList;
+ while(pList && pList->GetStart() != pStart)
+ pList = pList->GetDown();
+
+ if(pList && pList->GetStart() == pStart)
+ {
+ // Liste gefunden, Eintrag mit Endpunkt
+ // pEnd finden
+ B3dEdgeEntry* pEntry = pList->GetEntries();
+ B3dEdgeEntry* pLeft = NULL;
+
+ while(pEntry)
+ {
+ if(pEntry->GetEnd() == pEnd)
+ {
+ // Kante existiert, austragen
+ // Liste ist pList
+ // Links ist pLeft
+ if(pLeft)
+ {
+ pLeft->SetRight(pEntry->GetRight());
+ }
+ else
+ {
+ if(pEntry->GetRight())
+ pList->SetEntries(pEntry->GetRight());
+ else
+ RemoveEdgeList(pList);
+ }
+ // fertig
+ return TRUE;
+ }
+
+ // naechste Kante
+ pLeft = pEntry;
+ pEntry = pEntry->GetRight();
+ }
+
+ // Liste existiert, aber der EdgeEintrag nicht.
+ // Fuege diesen hinzu
+ InsertEdge(pList, pEnd, FALSE);
+
+ // fertig
+ return FALSE;
+ }
+ }
+ // Liste und Eintrag existieren nicht
+ // Erzeuge beides
+ InsertEdge(GetList(pStart), pEnd, FALSE);
+
+ return FALSE;
+}
+
+/*************************************************************************
+|*
+|* Entferne die Kante aus der Kantenliste. Tue alles weitere,
+|* um die Struktur weiter aufzuloesen
+|*
+\************************************************************************/
+
+void B3dComplexPolygon::RemoveFirstEdge(B3dEdgeList* pList)
+{
+ if(pList->GetEntries()->GetRight())
+ pList->SetEntries(pList->GetEntries()->GetRight());
+ else
+ RemoveEdgeList(pList);
+}
+
+/*************************************************************************
+|*
+|* Entferne die Kantenliste. Tue alles weitere,
+|* um die Struktur weiter aufzuloesen
+|*
+\************************************************************************/
+
+void B3dComplexPolygon::RemoveEdgeList(B3dEdgeList* pList)
+{
+ if(pList->GetDown())
+ pList->GetDown()->SetParent(pList->GetParent());
+ if(pList->GetParent())
+ pList->GetParent()->SetDown(pList->GetDown());
+ else
+ {
+ // Es gibt keinen parent mehr
+ pEdgeList = pList->GetDown();
+ }
+}
+
+/*************************************************************************
+|*
+|* Extrahiere das naechste Dreieck aus der Kantenliste
+|* und zeichne es
+|*
+\************************************************************************/
+
+void B3dComplexPolygon::ExtractTriangle()
+{
+ B3dEdgeEntry* pLeft = pEdgeList->GetEntries();
+ B3dEdgeEntry* pRight = pLeft->GetRight();
+
+ if(!pRight)
+ {
+// DBG_ASSERT(0, "AW: Einzelne Kante als Startpunkt!");
+ RemoveFirstEdge(pEdgeList);
+ return;
+ }
+
+ B3dEdgeList* pList = FindStartInTriangle();
+ BOOL bNotAllAligned = (fabs(GetSlant(pLeft) - GetSlant(pRight)) > SMALL_DVALUE);
+ BOOL bStartIsEdgePoint = FALSE;
+ if(pList)
+ {
+ const Vector3D& rListStart = pList->GetStart()->Point().GetVector3D();
+ if((rListStart - pEdgeList->GetStart()->Point().GetVector3D()).GetLength() < SMALL_DVALUE)
+ bStartIsEdgePoint = TRUE;
+ else if((rListStart - pLeft->GetEnd()->Point().GetVector3D()).GetLength() < SMALL_DVALUE)
+ bStartIsEdgePoint = TRUE;
+ else if((rListStart - pRight->GetEnd()->Point().GetVector3D()).GetLength() < SMALL_DVALUE)
+ bStartIsEdgePoint = TRUE;
+ }
+
+ if(pList && bNotAllAligned && !bStartIsEdgePoint)
+ {
+ // Zerlegen in 2 Teildreiecke
+ // Erstes Teildreieck
+ InsertEdge(pEdgeList, pList->GetStart(), FALSE);
+ ExtractTriangle();
+
+ // Zweites Teildreieck
+ InsertEdge(pEdgeList, pList->GetStart(), FALSE);
+ ExtractTriangle();
+ }
+ else
+ {
+ B3dEntity* pEntLeft = pLeft->GetEnd();
+ B3dEntity* pEntRight = pRight->GetEnd();
+ B3dEntity* pEntTop = pEdgeList->GetStart();
+ BOOL bLeftVisible = pLeft->IsEdgeVisible();
+ BOOL bRightVisible = pRight->IsEdgeVisible();
+
+ RemoveFirstEdge(pEdgeList);
+ RemoveFirstEdge(pEdgeList);
+
+ if(pEntLeft != pEntRight)
+ {
+ // Merken, ob die Abschlusslinie existiert hat oder nicht
+ BOOL bDidEdgeExist = SwitchEdgeExistance(pEntLeft, pEntRight);
+
+ if(DOUBLE_NOT_EQUAL(pEntLeft->GetY(), pEntTop->GetY())
+ || DOUBLE_NOT_EQUAL(pEntRight->GetY(), pEntTop->GetY()))
+ {
+ if(!bOrientationValid)
+ {
+ // Anhand des ersten Dreiecks entscheiden,
+ // in welcher Orientierung die Dreiecke
+ // auszugeben sind
+ Vector3D aTmpNormal =
+ (pEntLeft->Point().GetVector3D() - pEntTop->Point().GetVector3D())
+ |(pEntRight->Point().GetVector3D() - pEntTop->Point().GetVector3D());
+
+ bOrientation = (aNormal.Scalar(aTmpNormal) > 0.0) ? TRUE : FALSE;
+ bOrientationValid = TRUE;
+ }
+
+ // Dreieck ausgeben
+ if(pBase3D)
+ {
+ if(bOrientation)
+ {
+ // Rechtsrum
+ pBase3D->SetEdgeFlag(bRightVisible);
+ pBase3D->AddVertex(*pEntTop);
+ pBase3D->SetEdgeFlag(bDidEdgeExist);
+ pBase3D->AddVertex(*pEntRight);
+ pBase3D->SetEdgeFlag(bLeftVisible);
+ pBase3D->AddVertex(*pEntLeft);
+ }
+ else
+ {
+ // Linksrum
+ pBase3D->SetEdgeFlag(bLeftVisible);
+ pBase3D->AddVertex(*pEntTop);
+ pBase3D->SetEdgeFlag(bDidEdgeExist);
+ pBase3D->AddVertex(*pEntLeft);
+ pBase3D->SetEdgeFlag(bRightVisible);
+ pBase3D->AddVertex(*pEntRight);
+ }
+ }
+ else if(pGeometry)
+ {
+ pGeometry->StartComplexPrimitive();
+ if(bOrientation)
+ {
+ // Rechtsrum
+ pGeometry->AddComplexVertex(*pEntTop, bRightVisible);
+ pGeometry->AddComplexVertex(*pEntRight, bDidEdgeExist);
+ pGeometry->AddComplexVertex(*pEntLeft, bLeftVisible);
+ }
+ else
+ {
+ // Linksrum
+ pGeometry->AddComplexVertex(*pEntTop, bLeftVisible);
+ pGeometry->AddComplexVertex(*pEntLeft, bDidEdgeExist);
+ pGeometry->AddComplexVertex(*pEntRight, bRightVisible);
+ }
+ pGeometry->EndComplexPrimitive();
+ }
+ }
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Suche nach einem fremden Startpunkt innerhalb des zu zeichnenden
+|* naechsten Dreiecks
+|*
+\************************************************************************/
+
+B3dEdgeList* B3dComplexPolygon::FindStartInTriangle()
+{
+ B3dEdgeList* pList = pEdgeList->GetDown();
+ if(pList)
+ {
+ B3dEdgeEntry* pLeft = pEdgeList->GetEntries();
+ B3dEdgeEntry* pRight = pLeft->GetRight();
+
+ double fYMax = pLeft->GetYPos();
+ double fZwi = pRight->GetYPos();
+ if(fZwi > fYMax)
+ fYMax = fZwi;
+
+ if(pList->GetYPos() <= fYMax)
+ {
+ B3dEntity* pTop = pEdgeList->GetStart();
+ double fXMin = pLeft->GetXPos();
+ double fXMax = pRight->GetXPos();
+ if(fXMin > fXMax)
+ {
+ fZwi = fXMin;
+ fXMin = fXMax;
+ fXMax = fZwi;
+ }
+
+ double fXTop = pTop->GetX();
+ if(fXMin > fXTop)
+ fXMin = fXTop;
+ if(fXMax < fXTop)
+ fXMax = fXTop;
+
+ while(pList
+ && pList->GetYPos() <= fYMax)
+ {
+ if(pList->GetXPos() > fXMin && pList->GetXPos() < fXMax)
+ {
+ if(pList->GetStart() != pLeft->GetEnd()
+ && pList->GetStart() != pRight->GetEnd())
+ {
+ if(IsLeft(pTop, pLeft->GetEnd(), pList->GetStart()))
+ {
+ if(DOUBLE_NOT_EQUAL(pList->GetXPos(), pLeft->GetXPos())
+ || DOUBLE_NOT_EQUAL(pList->GetYPos(), pLeft->GetYPos()))
+ {
+ if(IsLeft(pRight->GetEnd(), pTop, pList->GetStart()))
+ {
+ if(DOUBLE_NOT_EQUAL(pList->GetXPos(), pRight->GetXPos())
+ || DOUBLE_NOT_EQUAL(pList->GetYPos(), pRight->GetYPos()))
+ {
+ if(IsLeft(pLeft->GetEnd(), pRight->GetEnd(),
+ pList->GetStart()))
+ {
+ return pList;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ // naechste Liste
+ pList = pList->GetDown();
+ }
+ }
+ }
+ return NULL;
+}
+
+/*************************************************************************
+|*
+|* Testen, auf welcher Seite pPoint von der Linie pTop, pDirection liegt
+|*
+\************************************************************************/
+
+BOOL B3dComplexPolygon::IsLeft(B3dEntity* pTop, B3dEntity* pDirection,
+ B3dEntity* pPoint)
+{
+ double fDirX = pDirection->GetX() - pTop->GetX();
+ double fDirY = pDirection->GetY() - pTop->GetY();
+ double fPntX = pPoint->GetX() - pTop->GetX();
+ double fPntY = pPoint->GetY() - pTop->GetY();
+
+ return ((fDirX * fPntY - fDirY * fPntX) <= 0.0);
+}
+
diff --git a/goodies/source/base3d/b3ddeflt.cxx b/goodies/source/base3d/b3ddeflt.cxx
new file mode 100644
index 000000000000..a626ad797406
--- /dev/null
+++ b/goodies/source/base3d/b3ddeflt.cxx
@@ -0,0 +1,1786 @@
+/*************************************************************************
+ *
+ * $RCSfile: b3ddeflt.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _B3D_B3DDEFLT_HXX
+#include "b3ddeflt.hxx"
+#endif
+
+#ifndef _B3D_B3DTRANS_HXX
+#include "b3dtrans.hxx"
+#endif
+
+#ifndef _SV_OUTDEV_HXX
+#include <vcl/outdev.hxx>
+#endif
+
+#ifndef _SV_BMPACC_HXX
+#include <vcl/bmpacc.hxx>
+#endif
+
+#ifndef _SV_BITMAPEX_HXX
+#include <vcl/bitmapex.hxx>
+#endif
+
+#ifndef _B3D_B3DTEX_HXX
+#include "b3dtex.hxx"
+#endif
+
+/*************************************************************************
+|*
+|* Konstruktor Base3DDefault
+|*
+\************************************************************************/
+
+Base3DDefault::Base3DDefault(OutputDevice* pOutDev)
+: Base3DCommon(pOutDev),
+ aZBuffer(),
+ aPicture(),
+ aMonoTransparence(),
+ aAlphaTransparence(),
+ aClearValue(Color(0x00ffffff)),
+ pZBufferWrite(NULL),
+ pPictureWrite(NULL),
+ pTransparenceWrite(NULL),
+ fDetail(1.0),
+ bReducedDetail(FALSE),
+ bDetailBackedup(FALSE),
+ fDetailBackup( -1.0 ),
+ nMaxPixels(500000)
+{
+}
+
+/*************************************************************************
+|*
+|* Destruktor Base3DDefault
+|*
+\************************************************************************/
+
+Base3DDefault::~Base3DDefault()
+{
+ // Alle Bitmap-Zugriffe freigeben
+ ReleaseAccess();
+}
+
+/*************************************************************************
+|*
+|* Typbestimmung
+|*
+\************************************************************************/
+
+UINT16 Base3DDefault::GetBase3DType()
+{
+ return BASE3D_TYPE_DEFAULT;
+}
+
+/*************************************************************************
+|*
+|* Darstellungsqualitaet setzen
+|*
+\************************************************************************/
+
+void Base3DDefault::SetDisplayQuality(UINT8 nNew)
+{
+ // Entsprechende PixelGrenze setzen
+ SetMaxPixels(((long)nNew * 3500) + 3500);
+
+ // call parent
+ Base3D::SetDisplayQuality(nNew);
+}
+
+/*************************************************************************
+|*
+|* Vergroeberungsstufe setzen
+|*
+\************************************************************************/
+
+void Base3DDefault::SetDetail(double fNew)
+{
+ // nach unten begrenzen
+ if(fNew > 1.0)
+ fNew = 1.0;
+
+ fDetail = fNew;
+ if(fDetail < 1.0)
+ {
+ bReducedDetail = TRUE;
+ }
+ else
+ {
+ bReducedDetail = FALSE;
+ }
+}
+
+/*************************************************************************
+|*
+|* BitmapAccess holen
+|*
+\************************************************************************/
+
+void Base3DDefault::AcquireAccess()
+{
+ // Alle accesses holen
+ pZBufferWrite = aZBuffer.AcquireWriteAccess();
+ pPictureWrite = aPicture.AcquireWriteAccess();
+ pTransparenceWrite = (GetTransparentPartsContainedHint())
+ ? aAlphaTransparence.AcquireWriteAccess()
+ : aMonoTransparence.AcquireWriteAccess();
+}
+
+/*************************************************************************
+|*
+|* BitmapAccess freigeben
+|*
+\************************************************************************/
+
+void Base3DDefault::ReleaseAccess()
+{
+ // Alle accesses wieder freigeben
+ if(pZBufferWrite)
+ {
+ delete pZBufferWrite;
+ pZBufferWrite = NULL;
+ }
+
+ if(pPictureWrite)
+ {
+ delete pPictureWrite;
+ pPictureWrite = NULL;
+ }
+
+ if(pTransparenceWrite)
+ {
+ delete pTransparenceWrite;
+ pTransparenceWrite = NULL;
+ }
+}
+
+/*************************************************************************
+|*
+|* Start der Szenenbeschreibung:
+|*
+\************************************************************************/
+
+void Base3DDefault::StartScene()
+{
+ // Zugriffe freigeben
+ ReleaseAccess();
+
+ // Groesse der Bitmaps anpassen?
+ BOOL bSizeHasChanged = (aLocalSizePixel.GetSize() != aPicture.GetSizePixel());
+
+ // Neue BitMaps fuer ZBuffer und Picture allokieren
+ if(bSizeHasChanged || !aZBuffer || !aPicture)
+ {
+ aZBuffer = Bitmap(aLocalSizePixel.GetSize(), 24);
+ aPicture = Bitmap(aLocalSizePixel.GetSize(), 24);
+ }
+
+ // ZBuffer loeschen
+ aZBuffer.Erase(aClearValue);
+
+ // Bild loeschen
+ aPicture.Erase( GetOutputDevice()->GetBackground().GetColor() );
+
+ // Neue Transparenz-Bitmap allokieren
+ if(GetTransparentPartsContainedHint())
+ {
+ // Alpha-Channel
+ if(bSizeHasChanged || !aAlphaTransparence)
+ {
+ aAlphaTransparence = AlphaMask(aLocalSizePixel.GetSize());
+ if(!!aMonoTransparence)
+ aMonoTransparence = Bitmap();
+ }
+
+ // zu Beginn alles transparent
+ aAlphaTransparence.Erase(BYTE(0xff));
+ }
+ else
+ {
+ // Mono-Channel
+ if(bSizeHasChanged || !aMonoTransparence)
+ {
+ aMonoTransparence = Bitmap(aLocalSizePixel.GetSize(), 1);
+ if(!!aAlphaTransparence)
+ aAlphaTransparence = AlphaMask();
+ }
+
+ // zu Beginn alles transparent
+ Color aEraseCol(COL_WHITE);
+ aMonoTransparence.Erase(aEraseCol);
+ }
+
+ // Zugriffe wieder holen
+ AcquireAccess();
+
+ // lokale ClipRegion anpassen
+ if(IsScissorRegionActive())
+ {
+ // Default specifics for scissoring
+ aDefaultScissorRectangle = GetScissorRegionPixel();
+ aDefaultScissorRectangle -= aSizePixel.TopLeft();
+
+ // Detailstufe beachten
+ if(bReducedDetail && fDetail != 0.0)
+ {
+ long nReducedWidth = (long)((double)(aDefaultScissorRectangle.GetWidth() - 1) * fDetail);
+ long nReducedHeight = (long)((double)(aDefaultScissorRectangle.GetHeight() - 1)* fDetail);
+ aDefaultScissorRectangle.SetSize(Size(nReducedWidth + 1, nReducedHeight + 1));
+ }
+ }
+
+ // call parent
+ Base3DCommon::StartScene();
+}
+
+/*************************************************************************
+|*
+|* Ende der Szenenbeschreibung:
+|*
+\************************************************************************/
+
+void Base3DDefault::EndScene()
+{
+ // Zugriffe freigeben
+ ReleaseAccess();
+
+ // Ausgabe der erzeugten BitMap
+ BitmapEx aBitmapEx;
+
+ if(GetTransparentPartsContainedHint())
+ {
+ // Alpha-Transparenz
+ aBitmapEx = BitmapEx(aPicture, aAlphaTransparence);
+ }
+ else
+ {
+ // Mono-Transparenz
+ aBitmapEx = BitmapEx(aPicture, aMonoTransparence);
+ }
+
+ // Dithern
+ UINT16 nBitCount = GetOutputDevice()->GetBitCount();
+ if( GetOutputDevice()->GetOutDevType() != OUTDEV_PRINTER && nBitCount <= 16 && GetDither())
+ {
+ aBitmapEx.Dither(nBitCount <= 8
+ ? BMP_DITHER_MATRIX
+ : BMP_DITHER_FLOYD_16);
+ }
+
+ if(GetOutputDevice()->GetConnectMetaFile() != NULL)
+ {
+ Rectangle aLogicRect;
+ aLogicRect = GetOutputDevice()->PixelToLogic(aSizePixel);
+ aBitmapEx.Draw(GetOutputDevice(), aLogicRect.TopLeft(), aLogicRect.GetSize());
+ }
+ else
+ {
+ BOOL bWasEnabled = GetOutputDevice()->IsMapModeEnabled();
+ GetOutputDevice()->EnableMapMode(FALSE);
+
+#ifdef DBG_UTIL // draw for testing
+ static BOOL bDoDrawBitmapForTesting(FALSE);
+ if(bDoDrawBitmapForTesting)
+ {
+ Bitmap aBmp( aBitmapEx.GetMask() );
+ aBmp.Convert( BMP_CONVERSION_4BIT_COLORS );
+ aBmp.Replace( COL_WHITE, COL_LIGHTRED );
+ GetOutputDevice()->DrawBitmap( aSizePixel.TopLeft(), aSizePixel.GetSize(), aBmp );
+ GetOutputDevice()->SetFillColor( COL_LIGHTRED );
+ GetOutputDevice()->SetLineColor( COL_LIGHTRED );
+ GetOutputDevice()->DrawRect( aSizePixel );
+ }
+#endif
+
+ aBitmapEx.Draw(GetOutputDevice(), aSizePixel.TopLeft(), aSizePixel.GetSize());
+ GetOutputDevice()->EnableMapMode(bWasEnabled);
+ }
+
+ // Zugriffe wieder holen
+ AcquireAccess();
+
+ // eventuelle temporaere Reduzierung der Aufloesung zuruecknehmen
+ if(bDetailBackedup)
+ {
+ SetDetail(fDetailBackup);
+ bDetailBackedup = FALSE;
+ }
+
+ // call parent
+ Base3DCommon::EndScene();
+}
+
+/*************************************************************************
+|*
+|* Callbacks bei Matrixaenderungen
+|*
+|* Ausgaberechteck innerhalb des OutputDevice festlegen. Die Koordinaten
+|* sind device-spezifisch, muessen also evtl. erst auf pixelkoordinaten
+|* umgerechnet werden
+|*
+\************************************************************************/
+
+void Base3DDefault::SetTransformationSet(B3dTransformationSet* pSet)
+{
+ // call parent
+ Base3DCommon::SetTransformationSet(pSet);
+
+ if(GetTransformationSet())
+ {
+ // eventuelle temporaere Reduzierung der Aufloesung zuruecknehmen
+ if(bDetailBackedup)
+ {
+ SetDetail(fDetailBackup);
+ bDetailBackedup = FALSE;
+ }
+
+ // Neue Groesse fuer die Ausgabe
+ aSizePixel = GetOutputDevice()->LogicToPixel(
+ GetTransformationSet()->GetLogicalViewportBounds());
+
+ // Eventuell durch ClipRegion eingeschraenkt? Dies
+ // muss beachtet werden
+ if(IsScissorRegionActive())
+ {
+ // draw region even smaller
+ aSizePixel.Intersection(GetScissorRegionPixel());
+ }
+
+ // Testen, ob die Bitmap zu gross wird
+ aLocalSizePixel = aSizePixel;
+ long nQuadSize = aLocalSizePixel.GetWidth() * aLocalSizePixel.GetHeight();
+
+ if(nQuadSize > GetMaxPixels())
+ {
+ // Groesse reduzieren
+ double fFactor = sqrt((double)GetMaxPixels() / (double)nQuadSize);
+
+ // Bei Druckjobs die Reduzierung einschraenken
+ if(fFactor < 0.25 && GetOutputDevice()->GetOutDevType() == OUTDEV_PRINTER)
+ fFactor = 0.25;
+
+ // Wird hier mehr reduziert als sowieso schon eingestellt ist?
+ if(fFactor < fDetail)
+ {
+ fDetailBackup = GetDetail();
+ bDetailBackedup = TRUE;
+ SetDetail(fFactor);
+ }
+ }
+
+ // Detailstufe beachten
+ if(bReducedDetail && fDetail != 0.0)
+ {
+ long nReducedWidth = (long)((double)(aLocalSizePixel.GetWidth() - 1) * fDetail);
+ long nReducedHeight = (long)((double)(aLocalSizePixel.GetHeight() - 1)* fDetail);
+ aLocalSizePixel.SetSize(Size(nReducedWidth + 1, nReducedHeight + 1));
+ }
+
+ // Falls die Groesse null ist, groesse auf 1,1 setzen
+ if(aLocalSizePixel.GetSize().Width() < 1)
+ aLocalSizePixel.SetSize(Size(1 , aLocalSizePixel.GetSize().Height()));
+ if(aLocalSizePixel.GetSize().Height() < 1)
+ aLocalSizePixel.SetSize(Size(aLocalSizePixel.GetSize().Width(), 1));
+ }
+}
+
+/*************************************************************************
+|*
+|* Pixelkoordinaten des Punktes innerhalb der Bitmap holen
+|*
+\************************************************************************/
+
+Point Base3DDefault::GetPixelCoor(B3dEntity& rEntity)
+{
+ if(bReducedDetail && fDetail != 0.0)
+ {
+ Point aRetval = GetOutputDevice()->LogicToPixel(
+ Point((long)(rEntity.Point().X()),
+ (long)(rEntity.Point().Y()))) - aSizePixel.TopLeft();
+ aRetval.X() = (long)((double)aRetval.X() * fDetail);
+ aRetval.Y() = (long)((double)aRetval.Y() * fDetail);
+ return aRetval;
+ }
+ else
+ {
+ return GetOutputDevice()->LogicToPixel(
+ Point((long)(rEntity.Point().X()),
+ (long)(rEntity.Point().Y()))) - aSizePixel.TopLeft();
+ }
+}
+
+/*************************************************************************
+|*
+|* 3DPunkt aus Pixelkoordinaten und Tiefe rekonstruieren
+|*
+\************************************************************************/
+
+Vector3D Base3DDefault::Get3DCoor(Point& rPnt, double fDepth)
+{
+ if(bReducedDetail && fDetail != 0.0)
+ {
+ Point aPnt(rPnt);
+ aPnt.X() = (long)((double)aPnt.X() / fDetail);
+ aPnt.Y() = (long)((double)aPnt.Y() / fDetail);
+ aPnt = GetOutputDevice()->PixelToLogic(aPnt + aSizePixel.TopLeft());
+ return Vector3D(aPnt.X(), aPnt.Y(), fDepth);
+ }
+ else
+ {
+ Point aPnt = GetOutputDevice()->PixelToLogic(rPnt + aSizePixel.TopLeft());
+ return Vector3D(aPnt.X(), aPnt.Y(), fDepth);
+ }
+}
+
+/*************************************************************************
+|*
+|* ZBuffer Sichtbarkeitstest
+|*
+\************************************************************************/
+
+BOOL Base3DDefault::IsVisibleAndScissor(long nX, long nY, UINT32 nDepth)
+{
+ if(!IsScissorRegionActive() || IsInScissorRegion(nX, nY))
+ {
+ const BitmapColor& rBmCol = pZBufferWrite->GetPixel(nY, nX);
+ Color aColor(rBmCol.GetRed(), rBmCol.GetGreen(), rBmCol.GetBlue());
+ return (aColor.GetColor() >= nDepth);
+ }
+ return FALSE;
+}
+
+/*************************************************************************
+|*
+|* Scissoring Sichtbarkeitstest
+|*
+\************************************************************************/
+
+BOOL Base3DDefault::IsInScissorRegion(long nX, long nY)
+{
+ if(nX < aDefaultScissorRectangle.Left())
+ return FALSE;
+ if(nY < aDefaultScissorRectangle.Top())
+ return FALSE;
+ if(nX > aDefaultScissorRectangle.Right())
+ return FALSE;
+ if(nY > aDefaultScissorRectangle.Bottom())
+ return FALSE;
+ return TRUE;
+}
+
+/*************************************************************************
+|*
+|* Pixel setzen in allen Buffern
+|*
+\************************************************************************/
+
+void Base3DDefault::WritePixel(long nX, long nY, Color aColor, UINT32 nDepth)
+{
+ // In Transparenz-Map eintragen
+ if(GetTransparentPartsContainedHint())
+ {
+ if(aColor.GetTransparency())
+ {
+ BYTE nOldTrans = pTransparenceWrite->GetPixel(nY, nX).GetIndex();
+
+ if(nOldTrans != (BYTE)0xff)
+ {
+ // Farbe mischen
+ BitmapColor aOldCol = pPictureWrite->GetPixel(nY, nX);
+ UINT16 nNegTrans = 0x0100 - (UINT16)aColor.GetTransparency();
+ aColor.SetRed((BYTE)((((UINT16)aOldCol.GetRed() * (UINT16)aColor.GetTransparency())
+ + (aColor.GetRed() * nNegTrans)) >> 8));
+ aColor.SetGreen((BYTE)((((UINT16)aOldCol.GetGreen() * (UINT16)aColor.GetTransparency())
+ + (aColor.GetGreen() * nNegTrans)) >> 8));
+ aColor.SetBlue((BYTE)((((UINT16)aOldCol.GetBlue() * (UINT16)aColor.GetTransparency())
+ + (aColor.GetBlue() * nNegTrans)) >> 8));
+ pPictureWrite->SetPixel(nY, nX, aColor);
+
+ // Transparenz mischen
+ pTransparenceWrite->SetPixel(nY, nX,
+ (BYTE)(((UINT16)(nOldTrans+1) * (UINT16)aColor.GetTransparency()) >> 8));
+ }
+ else
+ {
+ // Pixel setzen
+ pPictureWrite->SetPixel(nY, nX, aColor);
+
+ // Alpha-Wert setzen
+ pTransparenceWrite->SetPixel(nY, nX, aColor.GetTransparency());
+ }
+ }
+ else
+ {
+ // Pixel setzen
+ pPictureWrite->SetPixel(nY, nX, aColor);
+
+ // Alpha-Wert setzen
+ pTransparenceWrite->SetPixel(nY, nX, (BYTE)0x00);
+
+ // Z-Buffer setzen
+ Color aZBufCol(nDepth);
+ pZBufferWrite->SetPixel(nY, nX, aZBufCol);
+ }
+ }
+ else
+ {
+ // Dieser Punkt in der Mono-Transparenz ist nicht transparent
+ BitmapColor aColBlack(BYTE(0));
+ pTransparenceWrite->SetPixel(nY, nX, aColBlack);
+
+ // Pixel setzen
+ pPictureWrite->SetPixel(nY, nX, aColor);
+
+ // Z-Buffer setzen
+ Color aZBufCol(nDepth);
+ pZBufferWrite->SetPixel(nY, nX, aZBufCol);
+ }
+}
+
+/*************************************************************************
+|*
+|* Zeichenfunktionen; alle Objekte sind geclippt
+|* Einzelner Punkt
+|*
+\************************************************************************/
+
+#define POLYGONOFFSET_VALUE (120)
+
+void Base3DDefault::Clipped3DPoint(UINT32 nInd)
+{
+ B3dEntity& rEntity = aBuffers[nInd];
+
+ // Geometrie holen
+ rEntity.ToDeviceCoor(GetTransformationSet());
+ Point aOutPoint = GetPixelCoor(rEntity);
+ UINT32 nDepth = (UINT32)rEntity.Point().Z();
+
+ // PolygonOffset beachten
+ if(GetPolygonOffset(Base3DPolygonOffsetPoint))
+ {
+ if(nDepth >= POLYGONOFFSET_VALUE)
+ nDepth -= POLYGONOFFSET_VALUE;
+ else
+ nDepth = 0;
+ }
+
+ // Zeichnen
+ if(IsVisibleAndScissor(aOutPoint.X(), aOutPoint.Y(), nDepth))
+ WritePixel(aOutPoint.X(), aOutPoint.Y(), rEntity.Color(), nDepth);
+}
+
+/*************************************************************************
+|*
+|* Zeichenfunktionen; alle Objekte sind geclippt
+|* Linie
+|*
+\************************************************************************/
+
+void Base3DDefault::Clipped3DLine(UINT32 nInd1, UINT32 nInd2)
+{
+ B3dEntity& rEntity1 = aBuffers[nInd1];
+ B3dEntity& rEntity2 = aBuffers[nInd2];
+ bNormalsUsed = rEntity1.IsNormalUsed() && rEntity2.IsNormalUsed();
+ bTextureUsed = IsTextureActive() && rEntity1.IsTexCoorUsed() && rEntity2.IsTexCoorUsed();
+
+ // ColorModel fuer diese Punkte anwenden, falls Normale vorhanden
+ // Danach Normale als ungueltig markieren, da nur noch die berechnete
+ // Farbe bei Aufteilungen weiter interpoliert wird
+ if(bNormalsUsed)
+ {
+ // Vektoren normalisieren
+ rEntity1.Normal().Normalize();
+ rEntity2.Normal().Normalize();
+
+ if(GetShadeModel() != Base3DPhong)
+ {
+ // Farben auswerten
+ rEntity1.Color() = SolveColorModel(GetMaterialObject(),
+ rEntity1.Normal(), rEntity1.Point().GetVector3D());
+ rEntity2.Color() = SolveColorModel(GetMaterialObject(),
+ rEntity2.Normal(), rEntity2.Point().GetVector3D());
+
+ // Die Normalen NICHT ungueltig machen, da die Entities
+ // eventuell noch fuer weitere Primitive benutzt werden.
+ // Aber lokal merken, dass die Normalen bereits ausgewertet sind
+ bNormalsUsed = FALSE;
+ }
+ }
+
+ // Geometrie holen
+ rEntity1.ToDeviceCoor(GetTransformationSet());
+ rEntity2.ToDeviceCoor(GetTransformationSet());
+ Rectangle aPrimitiveArea;
+
+ aOutPointTop = GetPixelCoor(rEntity1);
+ aOutPointLeft = GetPixelCoor(rEntity2);
+
+ if(IsScissorRegionActive())
+ {
+ aPrimitiveArea.Union(Rectangle(aOutPointTop, aOutPointTop));
+ aPrimitiveArea.Union(Rectangle(aOutPointLeft, aOutPointLeft));
+ }
+
+ if(!IsScissorRegionActive()
+ || (IsScissorRegionActive()
+ && !aDefaultScissorRectangle.GetIntersection(aPrimitiveArea).IsEmpty()))
+ {
+ if(bTextureUsed)
+ {
+ fTexWidth = (double)GetActiveTexture()->GetBitmapSize().Width();
+ fTexHeight = (double)GetActiveTexture()->GetBitmapSize().Height();
+ }
+
+ // Punkt, Farbe und Z-Wert interpolieren und die Linie gererieren
+ long nDx = aOutPointLeft.X() - aOutPointTop.X();
+ long nDy = aOutPointLeft.Y() - aOutPointTop.Y();
+ long nCount;
+
+ // Werte fuer Schleife vorbereiten
+ if(abs(nDx) > abs(nDy))
+ // ueber X gehen
+ nCount = abs(nDx);
+ else
+ // ueber Y gehen
+ nCount = abs(nDy);
+
+ if(nCount)
+ {
+ // Interpolatoren vorbereiten
+ aIntXPosLeft.Load(aOutPointTop.X(), aOutPointLeft.X(), nCount);
+ aIntXPosRight.Load(aOutPointTop.Y(), aOutPointLeft.Y(), nCount);
+ UINT32 nDepth;
+
+ // PolygonOffset beachten
+ if(GetPolygonOffset())
+ {
+ double fDepthLeft = rEntity1.Point().Z();
+ double fDepthRight = rEntity2.Point().Z();
+
+ if(fDepthLeft >= double(POLYGONOFFSET_VALUE))
+ fDepthLeft -= double(POLYGONOFFSET_VALUE);
+ else
+ fDepthLeft = 0.0;
+
+ if(fDepthRight >= double(POLYGONOFFSET_VALUE))
+ fDepthRight -= double(POLYGONOFFSET_VALUE);
+ else
+ fDepthRight = 0.0;
+
+ aIntDepthLine.Load(fDepthLeft, fDepthRight, nCount);
+ }
+ else
+ {
+ aIntDepthLine.Load(rEntity1.Point().Z(), rEntity2.Point().Z(), nCount);
+ }
+
+ // Texturkoordinateninterpolation?
+ if(bTextureUsed)
+ {
+ aIntTexSLine.Load(
+ rEntity1.TexCoor().X() * fTexWidth,
+ rEntity2.TexCoor().X() * fTexWidth,
+ nCount);
+ aIntTexTLine.Load(
+ rEntity1.TexCoor().Y() * fTexHeight,
+ rEntity2.TexCoor().Y() * fTexHeight,
+ nCount);
+ }
+
+ if(bNormalsUsed && GetShadeModel() == Base3DPhong)
+ {
+ // Normalen und Geometrie interpolieren
+ if(GetTransformationSet())
+ {
+ Vector3D aInvTrans = GetTransformationSet()->GetTranslate();
+ Vector3D aInvScale = GetTransformationSet()->GetScale();
+
+ // Tiefe und Normale vorbereiten
+ aIntVectorLine.Load(rEntity1.Normal(), rEntity2.Normal(), nCount);
+
+ // Linie zeichnen
+ if(bTextureUsed)
+ {
+ while(nCount--)
+ {
+ // weiterer Punkt
+ nDx = aIntXPosLeft.GetLongValue();
+ nDy = aIntXPosRight.GetLongValue();
+ nDepth = aIntDepthLine.GetUINT32Value();
+
+ if(IsVisibleAndScissor(nDx, nDy, nDepth))
+ {
+ Point aTmpPoint(nDx, nDy);
+ Vector3D aPoint = Get3DCoor(aTmpPoint, nDepth);
+ aPoint -= aInvTrans;
+ aPoint /= aInvScale;
+ Vector3D aNormal;
+ aIntVectorLine.GetVector3DValue(aNormal);
+ aNormal.Normalize();
+ Color aCol = SolveColorModel(GetMaterialObject(), aNormal, aPoint);
+ GetActiveTexture()->ModifyColor(aCol,
+ aIntTexSLine.GetDoubleValue(),
+ aIntTexTLine.GetDoubleValue());
+ WritePixel(nDx, nDy, aCol, nDepth);
+ }
+
+ if(nCount)
+ {
+ // Weiterschalten
+ aIntXPosLeft.Increment();
+ aIntXPosRight.Increment();
+ aIntDepthLine.Increment();
+ aIntVectorLine.Increment();
+ aIntTexSLine.Increment();
+ aIntTexTLine.Increment();
+ }
+ }
+ }
+ else
+ {
+ while(nCount--)
+ {
+ // weiterer Punkt
+ nDx = aIntXPosLeft.GetLongValue();
+ nDy = aIntXPosRight.GetLongValue();
+ nDepth = aIntDepthLine.GetUINT32Value();
+
+ if(IsVisibleAndScissor(nDx, nDy, nDepth))
+ {
+ Point aTmpPoint(nDx, nDy);
+ Vector3D aPoint = Get3DCoor(aTmpPoint, nDepth);
+ aPoint -= aInvTrans;
+ aPoint /= aInvScale;
+ Vector3D aNormal;
+ aIntVectorLine.GetVector3DValue(aNormal);
+ aNormal.Normalize();
+ Color aCol = SolveColorModel(GetMaterialObject(), aNormal, aPoint);
+ WritePixel(nDx, nDy, aCol, nDepth);
+ }
+
+ if(nCount)
+ {
+ // Weiterschalten
+ aIntXPosLeft.Increment();
+ aIntXPosRight.Increment();
+ aIntDepthLine.Increment();
+ aIntVectorLine.Increment();
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ if(rEntity1.Color() != rEntity2.Color())
+ {
+ // Farbe und Geometrie interpolieren
+ // Tiefe und Farbe vorbereiten
+ aIntColorLine.Load(rEntity1.Color(), rEntity2.Color(), nCount);
+
+ // Linie zeichnen
+ if(bTextureUsed)
+ {
+ while(nCount--)
+ {
+ // weiterer Punkt
+ nDx = aIntXPosLeft.GetLongValue();
+ nDy = aIntXPosRight.GetLongValue();
+ nDepth = aIntDepthLine.GetUINT32Value();
+
+ if(IsVisibleAndScissor(nDx, nDy, nDepth))
+ {
+ Color aCol = aIntColorLine.GetColorValue();
+ GetActiveTexture()->ModifyColor(aCol,
+ aIntTexSLine.GetDoubleValue(),
+ aIntTexTLine.GetDoubleValue());
+ WritePixel(nDx, nDy, aCol, nDepth);
+ }
+
+ if(nCount)
+ {
+ // Weiterschalten
+ aIntXPosLeft.Increment();
+ aIntXPosRight.Increment();
+ aIntDepthLine.Increment();
+ aIntColorLine.Increment();
+ aIntTexSLine.Increment();
+ aIntTexTLine.Increment();
+ }
+ }
+ }
+ else
+ {
+ while(nCount--)
+ {
+ // weiterer Punkt
+ nDx = aIntXPosLeft.GetLongValue();
+ nDy = aIntXPosRight.GetLongValue();
+ nDepth = aIntDepthLine.GetUINT32Value();
+
+ if(IsVisibleAndScissor(nDx, nDy, nDepth))
+ WritePixel(nDx, nDy, aIntColorLine.GetColorValue(), nDepth);
+
+ if(nCount)
+ {
+ // Weiterschalten
+ aIntXPosLeft.Increment();
+ aIntXPosRight.Increment();
+ aIntDepthLine.Increment();
+ aIntColorLine.Increment();
+ }
+ }
+ }
+ }
+ else
+ {
+ // Nur die Geometrie interpolieren
+ // Linie zeichnen
+ if(bTextureUsed)
+ {
+ while(nCount--)
+ {
+ // weiterer Punkt
+ nDx = aIntXPosLeft.GetLongValue();
+ nDy = aIntXPosRight.GetLongValue();
+ nDepth = aIntDepthLine.GetUINT32Value();
+
+ if(IsVisibleAndScissor(nDx, nDy, nDepth))
+ {
+ Color aCol = rEntity1.Color();
+ GetActiveTexture()->ModifyColor(aCol,
+ aIntTexSLine.GetDoubleValue(),
+ aIntTexTLine.GetDoubleValue());
+ WritePixel(nDx, nDy, aCol, nDepth);
+ }
+
+ if(nCount)
+ {
+ // Weiterschalten
+ aIntXPosLeft.Increment();
+ aIntXPosRight.Increment();
+ aIntDepthLine.Increment();
+ aIntTexSLine.Increment();
+ aIntTexTLine.Increment();
+ }
+ }
+ }
+ else
+ {
+ while(nCount--)
+ {
+ // weiterer Punkt
+ nDx = aIntXPosLeft.GetLongValue();
+ nDy = aIntXPosRight.GetLongValue();
+ nDepth = aIntDepthLine.GetUINT32Value();
+
+ if(IsVisibleAndScissor(nDx, nDy, nDepth))
+ WritePixel(nDx, nDy, rEntity1.Color(), nDepth);
+
+ if(nCount)
+ {
+ // Weiterschalten
+ aIntXPosLeft.Increment();
+ aIntXPosRight.Increment();
+ aIntDepthLine.Increment();
+ aIntTexSLine.Increment();
+ aIntTexTLine.Increment();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Zeichenfunktionen; alle Objekte sind geclippt
+|* Polygon
+|*
+\************************************************************************/
+
+void Base3DDefault::Clipped3DTriangle(UINT32 nInd1, UINT32 nInd2, UINT32 nInd3)
+{
+ B3dEntity& rEntity1 = aBuffers[nInd1];
+ B3dEntity& rEntity2 = aBuffers[nInd2];
+ B3dEntity& rEntity3 = aBuffers[nInd3];
+ bNormalsUsed = rEntity1.IsNormalUsed() && rEntity2.IsNormalUsed() && rEntity3.IsNormalUsed();
+ bTextureUsed = IsTextureActive() && rEntity1.IsTexCoorUsed() && rEntity2.IsTexCoorUsed() && rEntity3.IsTexCoorUsed();
+ Base3DMaterialMode eMode = Base3DMaterialFront;
+
+ // ColorModel fuer diese Punkte anwenden, falls Normale vorhanden
+ // Danach Normale als ungueltig markieren, da nur noch die berechnete
+ // Farbe bei Aufteilungen weiter interpoliert wird
+ if(bNormalsUsed)
+ {
+ // Vektoren normalisieren
+ rEntity1.Normal().Normalize();
+ rEntity2.Normal().Normalize();
+ rEntity3.Normal().Normalize();
+
+ if(GetShadeModel() != Base3DPhong)
+ {
+ // Normale berechnen, Farben auswerten
+ if(rEntity1.PlaneNormal().Z() < 0.0 && (GetLightGroup() && GetLightGroup()->GetModelTwoSide()))
+ eMode = Base3DMaterialBack;
+
+ rEntity1.Color() = SolveColorModel(
+ GetMaterialObject(eMode),
+ rEntity1.Normal(), rEntity1.Point().GetVector3D());
+ rEntity2.Color() = SolveColorModel(
+ GetMaterialObject(eMode),
+ rEntity2.Normal(), rEntity2.Point().GetVector3D());
+ rEntity3.Color() = SolveColorModel(
+ GetMaterialObject(eMode),
+ rEntity3.Normal(), rEntity3.Point().GetVector3D());
+
+ // Die Normalen NICHT ungueltig machen, da die Entities
+ // eventuell noch fuer weitere Primitive benutzt werden.
+ // Aber lokal merken, dass die Normalen bereits ausgewertet sind
+ bNormalsUsed = FALSE;
+ }
+ }
+
+ // Geometrie holen
+ rEntity1.ToDeviceCoor(GetTransformationSet());
+ rEntity2.ToDeviceCoor(GetTransformationSet());
+ rEntity3.ToDeviceCoor(GetTransformationSet());
+
+ // Punkte ordnen. Oberster nach pEntTop
+ if(rEntity1.Point().Y() < rEntity2.Point().Y()
+ && rEntity1.Point().Y() < rEntity3.Point().Y())
+ {
+ // rEntity1 ist der oberste
+ pEntTop = &rEntity1;
+
+ // Left, Right erst mal zuweisen
+ pEntRight = &rEntity3;
+ pEntLeft = &rEntity2;
+ }
+ else
+ {
+ if(rEntity2.Point().Y() < rEntity3.Point().Y())
+ {
+ // rEntity2 ist der oberste
+ pEntTop = &rEntity2;
+
+ // Left, Right erst mal zuweisen
+ pEntRight = &rEntity1;
+ pEntLeft = &rEntity3;
+ }
+ else
+ {
+ // rEntity3 ist der oberste
+ pEntTop = &rEntity3;
+
+ // Left, Right erst mal zuweisen
+ pEntRight = &rEntity2;
+ pEntLeft = &rEntity1;
+ }
+ }
+
+ // Werte holen
+ Rectangle aPrimitiveArea;
+
+ aOutPointTop = GetPixelCoor(*pEntTop);
+ aOutPointLeft = GetPixelCoor(*pEntLeft);
+ aOutPointRight = GetPixelCoor(*pEntRight);
+
+ if(IsScissorRegionActive())
+ {
+ aPrimitiveArea.Union(Rectangle(aOutPointTop, aOutPointTop));
+ aPrimitiveArea.Union(Rectangle(aOutPointLeft, aOutPointLeft));
+ aPrimitiveArea.Union(Rectangle(aOutPointRight, aOutPointRight));
+ }
+
+ if(!IsScissorRegionActive()
+ || (IsScissorRegionActive()
+ && !aDefaultScissorRectangle.GetIntersection(aPrimitiveArea).IsEmpty()))
+ {
+ if(bTextureUsed)
+ {
+ fTexWidth = (double)GetActiveTexture()->GetBitmapSize().Width();
+ fTexHeight = (double)GetActiveTexture()->GetBitmapSize().Height();
+ }
+
+ // Links und rechts ordnen
+ long nDeltaYLeft = aOutPointLeft.Y() - aOutPointTop.Y();
+ long nDeltaYRight = aOutPointRight.Y() - aOutPointTop.Y();
+ long nYLine;
+
+ if((aOutPointLeft.X() - aOutPointTop.X()) * nDeltaYRight
+ - nDeltaYLeft * (aOutPointRight.X() - aOutPointTop.X()) > 0)
+ {
+ // Links und rechts vertauschen
+ // Punkte
+ nYLine = aOutPointLeft.X();
+ aOutPointLeft.X() = aOutPointRight.X();
+ aOutPointRight.X() = nYLine;
+ nYLine = aOutPointLeft.Y();
+ aOutPointLeft.Y() = aOutPointRight.Y();
+ aOutPointRight.Y() = nYLine;
+
+ // Deltas
+ nYLine = nDeltaYLeft; nDeltaYLeft = nDeltaYRight; nDeltaYRight = nYLine;
+
+ // Zeiger auf Entities
+ B3dEntity* pTmp = pEntLeft; pEntLeft = pEntRight; pEntRight = pTmp;
+ }
+
+ // YStart, Links und rechts laden
+ nYLine = aOutPointTop.Y();
+ aIntXPosLeft.Load(aOutPointTop.X(), aOutPointLeft.X(), nDeltaYLeft);
+ aIntDepthLeft.Load(pEntTop->Point().Z(), pEntLeft->Point().Z(), nDeltaYLeft);
+ aIntXPosRight.Load(aOutPointTop.X(), aOutPointRight.X(), nDeltaYRight);
+ aIntDepthRight.Load(pEntTop->Point().Z(), pEntRight->Point().Z(), nDeltaYRight);
+ if(bTextureUsed)
+ {
+ aIntTexSLeft.Load(
+ pEntTop->TexCoor().X() * fTexWidth,
+ pEntLeft->TexCoor().X() * fTexWidth, nDeltaYLeft);
+ aIntTexTLeft.Load(
+ pEntTop->TexCoor().Y() * fTexHeight,
+ pEntLeft->TexCoor().Y() * fTexHeight, nDeltaYLeft);
+ aIntTexSRight.Load(
+ pEntTop->TexCoor().X() * fTexWidth,
+ pEntRight->TexCoor().X() * fTexWidth, nDeltaYRight);
+ aIntTexTRight.Load(
+ pEntTop->TexCoor().Y() * fTexHeight,
+ pEntRight->TexCoor().Y() * fTexHeight, nDeltaYRight);
+ }
+
+ if(bNormalsUsed && GetShadeModel() == Base3DPhong)
+ {
+ // Normalen und Geometrie interpolieren
+ aIntVectorLeft.Load(pEntTop->Normal(), pEntLeft->Normal(), nDeltaYLeft);
+ aIntVectorRight.Load(pEntTop->Normal(), pEntRight->Normal(), nDeltaYRight);
+ B3dMaterial& rMat = GetMaterialObject(eMode);
+
+ if(bTextureUsed)
+ {
+ // Schleife
+ while(nDeltaYLeft || nDeltaYRight)
+ {
+ // Zeile ausgeben
+ DrawLinePhongTexture(nYLine, rMat);
+
+ // naechste Zeile vorbereiten rechts
+ if(!nDeltaYRight && nDeltaYLeft)
+ {
+ // Rechts ist zuende, lade neu mit Rest nach links
+ nDeltaYRight = nDeltaYLeft;
+ LoadRightTexture(nDeltaYRight);
+ aIntVectorRight.Load(pEntRight->Normal(), pEntLeft->Normal(), nDeltaYRight);
+ }
+
+ // naechste Zeile vorbereiten links
+ if(!nDeltaYLeft && nDeltaYRight)
+ {
+ // Links ist zuende, lade neu mit Rest nach rechts
+ nDeltaYLeft = nDeltaYRight;
+ LoadLeftTexture(nDeltaYLeft);
+ aIntVectorLeft.Load(pEntLeft->Normal(), pEntRight->Normal(), nDeltaYLeft);
+ }
+
+ // naechste Zeile rechts
+ if(nDeltaYRight || nDeltaYLeft)
+ {
+ nDeltaYRight--;
+ NextStepRightTexture();
+ aIntVectorRight.Increment();
+
+ nDeltaYLeft--;
+ NextStepLeftTexture();
+ aIntVectorLeft.Increment();
+
+ nYLine++;
+ }
+ }
+ }
+ else
+ {
+ // Schleife
+ while(nDeltaYLeft || nDeltaYRight)
+ {
+ // Zeile ausgeben
+ DrawLinePhong(nYLine, rMat);
+
+ // naechste Zeile vorbereiten rechts
+ if(!nDeltaYRight && nDeltaYLeft)
+ {
+ // Rechts ist zuende, lade neu mit Rest nach links
+ nDeltaYRight = nDeltaYLeft;
+ LoadRight(nDeltaYRight);
+ aIntVectorRight.Load(pEntRight->Normal(), pEntLeft->Normal(), nDeltaYRight);
+ }
+
+ // naechste Zeile vorbereiten links
+ if(!nDeltaYLeft && nDeltaYRight)
+ {
+ // Links ist zuende, lade neu mit Rest nach rechts
+ nDeltaYLeft = nDeltaYRight;
+ LoadLeft(nDeltaYLeft);
+ aIntVectorLeft.Load(pEntLeft->Normal(), pEntRight->Normal(), nDeltaYLeft);
+ }
+
+ // naechste Zeile rechts
+ if(nDeltaYRight || nDeltaYLeft)
+ {
+ nDeltaYRight--;
+ NextStepRight();
+ aIntVectorRight.Increment();
+
+ nDeltaYLeft--;
+ NextStepLeft();
+ aIntVectorLeft.Increment();
+
+ nYLine++;
+ }
+ }
+ }
+ }
+ else
+ {
+ if(!(rEntity1.Color() == rEntity2.Color() && rEntity1.Color() == rEntity3.Color()))
+ {
+ // Farbe und Geometrie interpolieren
+ aIntColorLeft.Load(pEntTop->Color(), pEntLeft->Color(), nDeltaYLeft);
+ aIntColorRight.Load(pEntTop->Color(), pEntRight->Color(), nDeltaYRight);
+
+ if(bTextureUsed)
+ {
+ // Schleife
+ while(nDeltaYLeft || nDeltaYRight)
+ {
+ // Zeile ausgeben
+ DrawLineColorTexture(nYLine);
+
+ // naechste Zeile vorbereiten rechts
+ if(!nDeltaYRight && nDeltaYLeft)
+ {
+ // Rechts ist zuende, lade neu mit Rest nach links
+ nDeltaYRight = nDeltaYLeft;
+ LoadRightTexture(nDeltaYRight);
+ aIntColorRight.Load(pEntRight->Color(), pEntLeft->Color(), nDeltaYRight);
+ }
+
+ // naechste Zeile vorbereiten links
+ if(!nDeltaYLeft && nDeltaYRight)
+ {
+ // Links ist zuende, lade neu mit Rest nach rechts
+ nDeltaYLeft = nDeltaYRight;
+ LoadLeftTexture(nDeltaYLeft);
+ aIntColorLeft.Load(pEntLeft->Color(), pEntRight->Color(), nDeltaYLeft);
+ }
+
+ // naechste Zeile rechts
+ if(nDeltaYRight || nDeltaYLeft)
+ {
+ nDeltaYRight--;
+ NextStepRightTexture();
+ aIntColorRight.Increment();
+
+ nDeltaYLeft--;
+ NextStepLeftTexture();
+ aIntColorLeft.Increment();
+
+ nYLine++;
+ }
+ }
+ }
+ else
+ {
+ // Schleife
+ while(nDeltaYLeft || nDeltaYRight)
+ {
+ // Zeile ausgeben
+ DrawLineColor(nYLine);
+
+ // naechste Zeile vorbereiten rechts
+ if(!nDeltaYRight && nDeltaYLeft)
+ {
+ // Rechts ist zuende, lade neu mit Rest nach links
+ nDeltaYRight = nDeltaYLeft;
+ LoadRight(nDeltaYRight);
+ aIntColorRight.Load(pEntRight->Color(), pEntLeft->Color(), nDeltaYRight);
+ }
+
+ // naechste Zeile vorbereiten links
+ if(!nDeltaYLeft && nDeltaYRight)
+ {
+ // Links ist zuende, lade neu mit Rest nach rechts
+ nDeltaYLeft = nDeltaYRight;
+ LoadLeft(nDeltaYLeft);
+ aIntColorLeft.Load(pEntLeft->Color(), pEntRight->Color(), nDeltaYLeft);
+ }
+
+ // naechste Zeile rechts
+ if(nDeltaYRight || nDeltaYLeft)
+ {
+ nDeltaYRight--;
+ NextStepRight();
+ aIntColorRight.Increment();
+
+ nDeltaYLeft--;
+ NextStepLeft();
+ aIntColorLeft.Increment();
+
+ nYLine++;
+ }
+ }
+ }
+ }
+ else
+ {
+ // Nur die Geometrie interpolieren
+ if(bTextureUsed)
+ {
+ // Schleife
+ while(nDeltaYLeft || nDeltaYRight)
+ {
+ // Zeile ausgeben
+ DrawLineTexture(nYLine, pEntTop->Color());
+
+ // naechste Zeile vorbereiten rechts
+ if(!nDeltaYRight && nDeltaYLeft)
+ {
+ // Rechts ist zuende, lade neu mit Rest nach links
+ nDeltaYRight = nDeltaYLeft;
+ LoadRightTexture(nDeltaYRight);
+ }
+
+ // naechste Zeile vorbereiten links
+ if(!nDeltaYLeft && nDeltaYRight)
+ {
+ // Links ist zuende, lade neu mit Rest nach rechts
+ nDeltaYLeft = nDeltaYRight;
+ LoadLeftTexture(nDeltaYLeft);
+ }
+
+ // naechste Zeile rechts
+ if(nDeltaYRight || nDeltaYLeft)
+ {
+ nDeltaYRight--;
+ NextStepRightTexture();
+
+ nDeltaYLeft--;
+ NextStepLeftTexture();
+
+ nYLine++;
+ }
+ }
+ }
+ else
+ {
+ // Schleife
+ while(nDeltaYLeft || nDeltaYRight)
+ {
+ // Zeile ausgeben
+ DrawLine(nYLine, pEntTop->Color());
+
+ // naechste Zeile vorbereiten rechts
+ if(!nDeltaYRight && nDeltaYLeft)
+ {
+ // Rechts ist zuende, lade neu mit Rest nach links
+ nDeltaYRight = nDeltaYLeft;
+ LoadRight(nDeltaYRight);
+ }
+
+ // naechste Zeile vorbereiten links
+ if(!nDeltaYLeft && nDeltaYRight)
+ {
+ // Links ist zuende, lade neu mit Rest nach rechts
+ nDeltaYLeft = nDeltaYRight;
+ LoadLeft(nDeltaYLeft);
+ }
+
+ // naechste Zeile rechts
+ if(nDeltaYRight || nDeltaYLeft)
+ {
+ nDeltaYRight--;
+ NextStepRight();
+
+ nDeltaYLeft--;
+ NextStepLeft();
+
+ nYLine++;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void Base3DDefault::DrawLinePhongTexture(long nYPos, B3dMaterial& rMat)
+{
+ // Ausserhalb des Clipping-Bereichs?
+ if(IsScissorRegionActive()
+ && (nYPos < aDefaultScissorRectangle.Top()
+ || nYPos > aDefaultScissorRectangle.Bottom()))
+ return;
+
+ // Von links bis rechts zeichnen
+ long nXLineStart = aIntXPosLeft.GetLongValue();
+ long nXLineDelta = aIntXPosRight.GetLongValue() - nXLineStart;
+
+ if(nXLineDelta > 0)
+ {
+ // Ausserhalb des Clipping-Bereichs?
+ if(IsScissorRegionActive()
+ && ( nXLineStart+nXLineDelta < aDefaultScissorRectangle.Left()
+ || nXLineStart > aDefaultScissorRectangle.Right()))
+ return;
+
+ Vector3D aVectorLeft;
+ aIntVectorLeft.GetVector3DValue(aVectorLeft);
+ Vector3D aVectorRight;
+ aIntVectorRight.GetVector3DValue(aVectorRight);
+ aIntVectorLine.Load(aVectorLeft, aVectorRight, nXLineDelta);
+ aIntDepthLine.Load(aIntDepthLeft.GetDoubleValue(), aIntDepthRight.GetDoubleValue(), nXLineDelta);
+
+ // Texturkoordinateninterpolation?
+ if(bTextureUsed)
+ {
+ aIntTexSLine.Load(aIntTexSLeft.GetDoubleValue(), aIntTexSRight.GetDoubleValue(), nXLineDelta);
+ aIntTexTLine.Load(aIntTexTLeft.GetDoubleValue(), aIntTexTRight.GetDoubleValue(), nXLineDelta);
+ }
+
+ if(GetTransformationSet())
+ {
+ Vector3D aInvTrans = GetTransformationSet()->GetTranslate();
+ Vector3D aInvScale = GetTransformationSet()->GetScale();
+
+ while(nXLineDelta--)
+ {
+ // Werte vorbereiten
+ UINT32 nDepth = aIntDepthLine.GetUINT32Value();
+
+ // Punkt ausgeben
+ if(IsVisibleAndScissor(nXLineStart, nYPos, nDepth))
+ {
+ Point aTmpPoint(nXLineStart, nYPos);
+ Vector3D aPoint = Get3DCoor(aTmpPoint, nDepth);
+ aPoint -= aInvTrans;
+ aPoint /= aInvScale;
+ Vector3D aNormal;
+ aIntVectorLine.GetVector3DValue(aNormal);
+ aNormal.Normalize();
+ Color aCol = SolveColorModel(rMat, aNormal, aPoint);
+
+ // Texturkoordinateninterpolation?
+ if(bTextureUsed)
+ {
+ GetActiveTexture()->ModifyColor(aCol,
+ aIntTexSLine.GetDoubleValue(),
+ aIntTexTLine.GetDoubleValue());
+ }
+ WritePixel(nXLineStart, nYPos, aCol, nDepth);
+ }
+
+ if(nXLineDelta)
+ {
+ // naechste Spalte
+ nXLineStart++;
+
+ // naechste Tiefe und Farbe
+ aIntDepthLine.Increment();
+ aIntVectorLine.Increment();
+
+ // Texturkoordinateninterpolation?
+ if(bTextureUsed)
+ {
+ aIntTexSLine.Increment();
+ aIntTexTLine.Increment();
+ }
+ }
+ }
+ }
+ }
+}
+
+void Base3DDefault::DrawLinePhong(long nYPos, B3dMaterial& rMat)
+{
+ // Ausserhalb des Clipping-Bereichs?
+ if(IsScissorRegionActive()
+ && (nYPos < aDefaultScissorRectangle.Top()
+ || nYPos > aDefaultScissorRectangle.Bottom()))
+ return;
+
+ // Von links bis rechts zeichnen
+ long nXLineStart = aIntXPosLeft.GetLongValue();
+ long nXLineDelta = aIntXPosRight.GetLongValue() - nXLineStart;
+
+ if(nXLineDelta > 0)
+ {
+ // Ausserhalb des Clipping-Bereichs?
+ if(IsScissorRegionActive()
+ && ( nXLineStart+nXLineDelta < aDefaultScissorRectangle.Left()
+ || nXLineStart > aDefaultScissorRectangle.Right()))
+ return;
+
+ Vector3D aVectorLeft;
+ aIntVectorLeft.GetVector3DValue(aVectorLeft);
+ Vector3D aVectorRight;
+ aIntVectorRight.GetVector3DValue(aVectorRight);
+ aIntVectorLine.Load(aVectorLeft, aVectorRight, nXLineDelta);
+ aIntDepthLine.Load(aIntDepthLeft.GetDoubleValue(), aIntDepthRight.GetDoubleValue(), nXLineDelta);
+
+ if(GetTransformationSet())
+ {
+ Vector3D aInvTrans = GetTransformationSet()->GetTranslate();
+ Vector3D aInvScale = GetTransformationSet()->GetScale();
+ while(nXLineDelta--)
+ {
+ // Werte vorbereiten
+ UINT32 nDepth = aIntDepthLine.GetUINT32Value();
+
+ // Punkt ausgeben
+ if(IsVisibleAndScissor(nXLineStart, nYPos, nDepth))
+ {
+ Point aTmpPoint(nXLineStart, nYPos);
+ Vector3D aPoint = Get3DCoor(aTmpPoint, nDepth);
+ aPoint -= aInvTrans;
+ aPoint /= aInvScale;
+ Vector3D aNormal;
+ aIntVectorLine.GetVector3DValue(aNormal);
+ aNormal.Normalize();
+ Color aCol = SolveColorModel(rMat, aNormal, aPoint);
+ WritePixel(nXLineStart, nYPos, aCol, nDepth);
+ }
+
+ if(nXLineDelta)
+ {
+ // naechste Spalte
+ nXLineStart++;
+
+ // naechste Tiefe und Farbe
+ aIntDepthLine.Increment();
+ aIntVectorLine.Increment();
+ }
+ }
+ }
+ }
+}
+
+void Base3DDefault::DrawLineColorTexture(long nYPos)
+{
+ // Ausserhalb des Clipping-Bereichs?
+ if(IsScissorRegionActive()
+ && (nYPos < aDefaultScissorRectangle.Top()
+ || nYPos > aDefaultScissorRectangle.Bottom()))
+ return;
+
+ // Von links bis rechts zeichnen
+ long nXLineStart = aIntXPosLeft.GetLongValue();
+ long nXLineDelta = aIntXPosRight.GetLongValue() - nXLineStart;
+
+ if(nXLineDelta > 0)
+ {
+ // Ausserhalb des Clipping-Bereichs?
+ if(IsScissorRegionActive()
+ && ( nXLineStart+nXLineDelta < aDefaultScissorRectangle.Left()
+ || nXLineStart > aDefaultScissorRectangle.Right()))
+ return;
+
+ aIntColorLine.Load(aIntColorLeft.GetColorValue(), aIntColorRight.GetColorValue(), nXLineDelta);
+ aIntTexSLine.Load(aIntTexSLeft.GetDoubleValue(), aIntTexSRight.GetDoubleValue(), nXLineDelta);
+ aIntTexTLine.Load(aIntTexTLeft.GetDoubleValue(), aIntTexTRight.GetDoubleValue(), nXLineDelta);
+ aIntDepthLine.Load(aIntDepthLeft.GetDoubleValue(), aIntDepthRight.GetDoubleValue(), nXLineDelta);
+
+ while(nXLineDelta--)
+ {
+ // Werte vorbereiten
+ UINT32 nDepth = aIntDepthLine.GetUINT32Value();
+
+ // Punkt ausgeben
+ if(IsVisibleAndScissor(nXLineStart, nYPos, nDepth))
+ {
+ Color aCol = aIntColorLine.GetColorValue();
+ GetActiveTexture()->ModifyColor(aCol,
+ aIntTexSLine.GetDoubleValue(),
+ aIntTexTLine.GetDoubleValue());
+ WritePixel(nXLineStart, nYPos, aCol, nDepth);
+ }
+
+ if(nXLineDelta)
+ {
+ // naechste Spalte
+ nXLineStart++;
+
+ // naechste Tiefe und Farbe
+ aIntDepthLine.Increment();
+ aIntColorLine.Increment();
+ aIntTexSLine.Increment();
+ aIntTexTLine.Increment();
+ }
+ }
+ }
+}
+
+void Base3DDefault::DrawLineColor(long nYPos)
+{
+ // Ausserhalb des Clipping-Bereichs?
+ if(IsScissorRegionActive()
+ && (nYPos < aDefaultScissorRectangle.Top()
+ || nYPos > aDefaultScissorRectangle.Bottom()))
+ return;
+
+ // Von links bis rechts zeichnen
+ long nXLineStart = aIntXPosLeft.GetLongValue();
+ long nXLineDelta = aIntXPosRight.GetLongValue() - nXLineStart;
+
+ if(nXLineDelta > 0)
+ {
+ // Ausserhalb des Clipping-Bereichs?
+ if(IsScissorRegionActive()
+ && ( nXLineStart+nXLineDelta < aDefaultScissorRectangle.Left()
+ || nXLineStart > aDefaultScissorRectangle.Right()))
+ return;
+
+ aIntColorLine.Load(aIntColorLeft.GetColorValue(), aIntColorRight.GetColorValue(), nXLineDelta);
+ aIntDepthLine.Load(aIntDepthLeft.GetDoubleValue(), aIntDepthRight.GetDoubleValue(), nXLineDelta);
+
+ while(nXLineDelta--)
+ {
+ // Werte vorbereiten
+ UINT32 nDepth = aIntDepthLine.GetUINT32Value();
+
+ // Punkt ausgeben
+ if(IsVisibleAndScissor(nXLineStart, nYPos, nDepth))
+ WritePixel(nXLineStart, nYPos, aIntColorLine.GetColorValue(), nDepth);
+
+ if(nXLineDelta)
+ {
+ // naechste Spalte
+ nXLineStart++;
+
+ // naechste Tiefe und Farbe
+ aIntDepthLine.Increment();
+ aIntColorLine.Increment();
+ }
+ }
+ }
+}
+
+void Base3DDefault::DrawLineTexture(long nYPos, Color& rCol)
+{
+ // Ausserhalb des Clipping-Bereichs?
+ if(IsScissorRegionActive()
+ && (nYPos < aDefaultScissorRectangle.Top()
+ || nYPos > aDefaultScissorRectangle.Bottom()))
+ return;
+
+ // Von links bis rechts zeichnen
+ long nXLineStart = aIntXPosLeft.GetLongValue();
+ long nXLineDelta = aIntXPosRight.GetLongValue() - nXLineStart;
+
+ if(nXLineDelta > 0)
+ {
+ // Ausserhalb des Clipping-Bereichs?
+ if(IsScissorRegionActive()
+ && ( nXLineStart+nXLineDelta < aDefaultScissorRectangle.Left()
+ || nXLineStart > aDefaultScissorRectangle.Right()))
+ return;
+
+ aIntTexSLine.Load(aIntTexSLeft.GetDoubleValue(), aIntTexSRight.GetDoubleValue(), nXLineDelta);
+ aIntTexTLine.Load(aIntTexTLeft.GetDoubleValue(), aIntTexTRight.GetDoubleValue(), nXLineDelta);
+ aIntDepthLine.Load(aIntDepthLeft.GetDoubleValue(), aIntDepthRight.GetDoubleValue(), nXLineDelta);
+
+ while(nXLineDelta--)
+ {
+ // Werte vorbereiten
+ UINT32 nDepth = aIntDepthLine.GetUINT32Value();
+
+ // Punkt ausgeben
+ if(IsVisibleAndScissor(nXLineStart, nYPos, nDepth))
+ {
+ // Texturkoordinateninterpolation?
+ Color aCol = rCol;
+ GetActiveTexture()->ModifyColor(aCol,
+ aIntTexSLine.GetDoubleValue(),
+ aIntTexTLine.GetDoubleValue());
+ WritePixel(nXLineStart, nYPos, aCol, nDepth);
+ }
+
+ if(nXLineDelta)
+ {
+ // naechste Spalte
+ nXLineStart++;
+
+ // naechste Tiefe und Farbe
+ aIntDepthLine.Increment();
+ aIntTexSLine.Increment();
+ aIntTexTLine.Increment();
+ }
+ }
+ }
+}
+
+void Base3DDefault::DrawLine(long nYPos, Color& rCol)
+{
+ // Ausserhalb des Clipping-Bereichs?
+ if(IsScissorRegionActive()
+ && (nYPos < aDefaultScissorRectangle.Top()
+ || nYPos > aDefaultScissorRectangle.Bottom()))
+ return;
+
+ // Von links bis rechts zeichnen
+ long nXLineStart = aIntXPosLeft.GetLongValue();
+ long nXLineDelta = aIntXPosRight.GetLongValue() - nXLineStart;
+
+ if(nXLineDelta > 0)
+ {
+ // Ausserhalb des Clipping-Bereichs?
+ if(IsScissorRegionActive()
+ && ( nXLineStart+nXLineDelta < aDefaultScissorRectangle.Left()
+ || nXLineStart > aDefaultScissorRectangle.Right()))
+ return;
+
+ aIntDepthLine.Load(aIntDepthLeft.GetDoubleValue(), aIntDepthRight.GetDoubleValue(), nXLineDelta);
+
+ while(nXLineDelta--)
+ {
+ // Werte vorbereiten
+ UINT32 nDepth = aIntDepthLine.GetUINT32Value();
+
+ // Punkt ausgeben
+ if(IsVisibleAndScissor(nXLineStart, nYPos, nDepth))
+ WritePixel(nXLineStart, nYPos, rCol, nDepth);
+
+ if(nXLineDelta)
+ {
+ // naechste Spalte
+ nXLineStart++;
+
+ // naechste Tiefe und Farbe
+ aIntDepthLine.Increment();
+ }
+ }
+ }
+}
+
+void Base3DDefault::LoadLeftTexture(long nSize)
+{
+ aIntXPosLeft.Load(aOutPointLeft.X(), aOutPointRight.X(), nSize);
+ aIntDepthLeft.Load(pEntLeft->Point().Z(), pEntRight->Point().Z(), nSize);
+ aIntTexSLeft.Load(
+ pEntLeft->TexCoor().X() * fTexWidth,
+ pEntRight->TexCoor().X() * fTexWidth, nSize);
+ aIntTexTLeft.Load(
+ pEntLeft->TexCoor().Y() * fTexHeight,
+ pEntRight->TexCoor().Y() * fTexHeight, nSize);
+}
+
+void Base3DDefault::LoadLeft(long nSize)
+{
+ aIntXPosLeft.Load(aOutPointLeft.X(), aOutPointRight.X(), nSize);
+ aIntDepthLeft.Load(pEntLeft->Point().Z(), pEntRight->Point().Z(), nSize);
+}
+
+void Base3DDefault::LoadRightTexture(long nSize)
+{
+ aIntXPosRight.Load(aOutPointRight.X(), aOutPointLeft.X(), nSize);
+ aIntDepthRight.Load(pEntRight->Point().Z(), pEntLeft->Point().Z(), nSize);
+ aIntTexSRight.Load(
+ pEntRight->TexCoor().X() * fTexWidth,
+ pEntLeft->TexCoor().X() * fTexWidth, nSize);
+ aIntTexTRight.Load(
+ pEntRight->TexCoor().Y() * fTexHeight,
+ pEntLeft->TexCoor().Y() * fTexHeight, nSize);
+}
+
+void Base3DDefault::LoadRight(long nSize)
+{
+ aIntXPosRight.Load(aOutPointRight.X(), aOutPointLeft.X(), nSize);
+ aIntDepthRight.Load(pEntRight->Point().Z(), pEntLeft->Point().Z(), nSize);
+}
+
+void Base3DDefault::NextStepRightTexture()
+{
+ aIntXPosRight.Increment();
+ aIntDepthRight.Increment();
+ aIntTexSRight.Increment();
+ aIntTexTRight.Increment();
+}
+
+void Base3DDefault::NextStepRight()
+{
+ aIntXPosRight.Increment();
+ aIntDepthRight.Increment();
+}
+
+void Base3DDefault::NextStepLeftTexture()
+{
+ aIntXPosLeft.Increment();
+ aIntDepthLeft.Increment();
+ aIntTexSLeft.Increment();
+ aIntTexTLeft.Increment();
+}
+
+void Base3DDefault::NextStepLeft()
+{
+ aIntXPosLeft.Increment();
+ aIntDepthLeft.Increment();
+}
+
diff --git a/goodies/source/base3d/b3ddeflt.hxx b/goodies/source/base3d/b3ddeflt.hxx
new file mode 100644
index 000000000000..be022af8b0f2
--- /dev/null
+++ b/goodies/source/base3d/b3ddeflt.hxx
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * $RCSfile: b3ddeflt.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _B3D_B3DDEFLT_HXX
+#define _B3D_B3DDEFLT_HXX
+
+#ifndef _B3D_B3DCOMMN_HXX
+#include "b3dcommn.hxx"
+#endif
+
+#ifndef _SV_BITMAP_HXX
+#include <vcl/bitmap.hxx>
+#endif
+
+#ifndef _SV_SALBTYPE_HXX
+#include <vcl/salbtype.hxx>
+#endif
+
+#ifndef _SV_ALPHA_HXX
+#include <vcl/alpha.hxx>
+#endif
+
+#ifndef _BXD_INTERPOLATOR_HXX
+#include "bxdintpo.hxx"
+#endif
+
+/*************************************************************************
+|*
+|* Die Basisklasse fuer Standard 3D Ausgaben auf StarView Basis
+|*
+\************************************************************************/
+
+class Base3DDefault : public Base3DCommon
+{
+private:
+ // ZBuffer auch als BitMap
+ Bitmap aZBuffer;
+
+ // Bitmap zum Zeichnen im Hintergrund
+ Bitmap aPicture;
+
+ // Bitmaps fuer die Transparenz
+ Bitmap aMonoTransparence;
+ AlphaMask aAlphaTransparence;
+
+ // Position der oberen linken Ecke aus ImplSetViewport
+ Rectangle aSizePixel;
+
+ // Mit faktoren umgerechnete echte Bitmap-Groesse
+ Rectangle aLocalSizePixel;
+
+ // ZBuffer loeschwert
+ BitmapColor aClearValue;
+
+ // Zugriffe auf die BitMaps
+ BitmapWriteAccess* pZBufferWrite;
+ BitmapWriteAccess* pPictureWrite;
+ BitmapWriteAccess* pTransparenceWrite;
+
+ // Vergroeberungsstufe und dazugehoerige Variablen
+ double fDetail;
+ double fDetailBackup;
+ long nMaxPixels;
+
+ // Groesse der Textur, falls benutzt
+ double fTexWidth;
+ double fTexHeight;
+
+ // Punktkoodinaten fuer Primitive
+ Point aOutPointTop;
+ Point aOutPointLeft;
+ Point aOutPointRight;
+
+ // Zeiger auf die Ursprungsdaten
+ B3dEntity* pEntTop;
+ B3dEntity* pEntLeft;
+ B3dEntity* pEntRight;
+
+ // benoetigte Interpolatoren
+ BxdInterpolator aIntXPosLeft;
+ BxdInterpolator aIntXPosRight;
+ BxdInterpolator aIntDepthLeft;
+ BxdInterpolator aIntDepthRight;
+ BxdInterpolator aIntDepthLine;
+ BxdInterpolator aIntTexSLeft;
+ BxdInterpolator aIntTexSRight;
+ BxdInterpolator aIntTexTLeft;
+ BxdInterpolator aIntTexTRight;
+ BxdInterpolator aIntTexSLine;
+ BxdInterpolator aIntTexTLine;
+ B3dVectorInterpolator aIntVectorLeft;
+ B3dVectorInterpolator aIntVectorRight;
+ B3dVectorInterpolator aIntVectorLine;
+ BxdColorInterpolator aIntColorLeft;
+ BxdColorInterpolator aIntColorRight;
+ BxdColorInterpolator aIntColorLine;
+
+ // Lokale Scissor Region (ohne TopLeft)
+ Rectangle aDefaultScissorRectangle;
+
+ // Booleans fuer Zeichenoperationen
+ unsigned bNormalsUsed : 1;
+ unsigned bTextureUsed : 1;
+
+ // Bool fuer Detailreduzierung
+ unsigned bReducedDetail : 1;
+ unsigned bDetailBackedup : 1;
+
+ // Funktionen fuer erlangen/freigeben der BitmapAccesses
+ void AcquireAccess();
+ void ReleaseAccess();
+
+ // Umrechnung auf PixelCoor der Bitmaps und zurueck
+ Point GetPixelCoor(B3dEntity& rEntity);
+ Vector3D Get3DCoor(Point& rPnt, double fDepth);
+
+ // ZBuffer funktionen
+ inline BOOL IsInScissorRegion(long nX, long nY);
+ inline BOOL IsVisibleAndScissor(long nX, long nY, UINT32 nDepth);
+ inline void WritePixel(long nX, long nY, Color aColor, UINT32 nDepth);
+
+ // Zeilenerzeuger fuer Polygon
+ /*inline*/ void DrawLinePhongTexture(long nYPos, B3dMaterial& rMat);
+ /*inline*/ void DrawLinePhong(long nYPos, B3dMaterial& rMat);
+ /*inline*/ void DrawLineColorTexture(long nYPos);
+ /*inline*/ void DrawLineColor(long nYPos);
+ /*inline*/ void DrawLineTexture(long nYPos, Color& rCol);
+ /*inline*/ void DrawLine(long nYPos, Color& rCol);
+
+ inline void LoadLeft(long nSize);
+ inline void LoadLeftTexture(long nSize);
+ inline void LoadRight(long nSize);
+ inline void LoadRightTexture(long nSize);
+
+ inline void NextStepRight();
+ inline void NextStepRightTexture();
+ inline void NextStepLeft();
+ inline void NextStepLeftTexture();
+
+public:
+ Base3DDefault(OutputDevice* pOutDev);
+ virtual ~Base3DDefault();
+
+ // Typbestimmung
+ virtual UINT16 GetBase3DType();
+
+ // Szenenverwaltung
+ virtual void StartScene();
+ virtual void EndScene();
+
+ // Nullwert des ZBuffers setzen
+ void SetClearValue(UINT32 nNew) { aClearValue = Color(nNew); }
+
+ // Detailstufe/Vergroeberung der Ausgabe setzen/lesen
+ void SetDetail(double fNew=1.0);
+ double GetDetail() { return fDetail; }
+ void SetMaxPixels(long nNew=500000) { nMaxPixels = nNew; }
+ long GetMaxPixels() { return nMaxPixels; }
+ virtual void SetDisplayQuality(UINT8 nNew);
+
+ // Callbacks bei Matrixaenderungen
+ virtual void SetTransformationSet(B3dTransformationSet* pSet);
+
+protected:
+
+ // Geometrie
+ virtual void Clipped3DPoint(UINT32 nInd);
+ virtual void Clipped3DLine(UINT32 nInd1, UINT32 nInd2);
+ virtual void Clipped3DTriangle(UINT32 nInd1, UINT32 nInd2,
+ UINT32 nInd3);
+};
+
+
+
+#endif // _B3D_B3DDEFLT_HXX
diff --git a/goodies/source/base3d/b3dentty.cxx b/goodies/source/base3d/b3dentty.cxx
new file mode 100644
index 000000000000..f3ad576cfdce
--- /dev/null
+++ b/goodies/source/base3d/b3dentty.cxx
@@ -0,0 +1,366 @@
+/*************************************************************************
+ *
+ * $RCSfile: b3dentty.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _B3D_B3DENTITY_HXX
+#include "b3dentty.hxx"
+#endif
+
+#ifndef _B3D_B3DCOMMN_HXX
+#include "b3dcommn.hxx"
+#endif
+
+#ifndef _B3D_B3DTRANS_HXX
+#include "b3dtrans.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+/*************************************************************************
+|*
+|* Kopieren eine 3DEntity
+|*
+\************************************************************************/
+
+void B3dEntity::Copy(B3dEntity& rEnt)
+{
+ aPoint = rEnt.Point();
+ bDeviceCoor = rEnt.IsDeviceCoor();
+ bValid = rEnt.IsValid();
+ bEdgeFlag = rEnt.IsEdgeVisible();
+ aPlaneNormal = rEnt.PlaneNormal();
+
+ if(bNormalUsed = rEnt.IsNormalUsed())
+ aNormal = rEnt.Normal();
+
+ if(bTexCoorUsed = rEnt.IsTexCoorUsed())
+ aTexCoor = rEnt.TexCoor();
+
+ aColor = rEnt.Color();
+}
+
+/*************************************************************************
+|*
+|* Flags auf Ausgangsposition
+|*
+\************************************************************************/
+
+void B3dEntity::Reset()
+{
+ bValid = bNormalUsed = bTexCoorUsed = bDeviceCoor = FALSE;
+ bEdgeFlag = TRUE;
+}
+
+/*************************************************************************
+|*
+|* Device Koordinaten des Punktes berechnen
+|*
+\************************************************************************/
+
+void B3dEntity::ImplToDeviceCoor(B3dTransformationSet* pSet)
+{
+ if(pSet && !bDeviceCoor)
+ {
+ const Vector3D& rScale = pSet->GetScale();
+ const Vector3D& rTrans = pSet->GetTranslate();
+
+ aPoint.Homogenize();
+ aPoint[0] = (aPoint[0] * rScale[0]) + rTrans[0];
+ aPoint[1] = (aPoint[1] * rScale[1]) + rTrans[1];
+ aPoint[2] = (aPoint[2] * rScale[2]) + rTrans[2];
+
+ bDeviceCoor = TRUE;
+ }
+}
+
+/*************************************************************************
+|*
+|* aus Device Koordinaten des Punktes 3D Koor im canonical view volume
+|* berechnen
+|*
+\************************************************************************/
+
+void B3dEntity::ImplTo3DCoor(B3dTransformationSet* pSet)
+{
+ if(pSet && bDeviceCoor)
+ {
+ const Vector3D& rScale = pSet->GetScale();
+ const Vector3D& rTrans = pSet->GetTranslate();
+
+ aPoint.Homogenize();
+ if(rScale[0] != 0.0)
+ aPoint[0] = (aPoint[0] - rTrans[0]) / rScale[0];
+ if(rScale[1] != 0.0)
+ aPoint[1] = (aPoint[1] - rTrans[1]) / rScale[1];
+ if(rScale[2] != 0.0)
+ aPoint[2] = (aPoint[2] - rTrans[2]) / rScale[2];
+
+ bDeviceCoor = FALSE;
+ }
+}
+
+/*************************************************************************
+|*
+|* Garantiere eine gemeinsame Datenbasis (ClipKoordinaten oder
+|* Devicekoordinaten)
+|*
+\************************************************************************/
+
+void B3dEntity::ForceEqualBase(B3dTransformationSet* pSet, B3dEntity& rOld)
+{
+ if(IsDeviceCoor() && rOld.IsDeviceCoor())
+ {
+ SetDeviceCoor();
+ }
+ else
+ {
+ if(IsDeviceCoor())
+ To3DCoor(pSet);
+ if(rOld.IsDeviceCoor())
+ rOld.To3DCoor(pSet);
+ }
+}
+
+/*************************************************************************
+|*
+|* Garantiere eine gemeinsame Datenbasis (ClipKoordinaten oder
+|* Devicekoordinaten)
+|*
+\************************************************************************/
+
+void B3dEntity::ForceEqualBase(B3dTransformationSet* pSet, B3dEntity& rOld1,
+ B3dEntity& rOld2)
+{
+ if(!IsDeviceCoor() && rOld1.IsDeviceCoor() && rOld2.IsDeviceCoor())
+ {
+ if(IsDeviceCoor())
+ To3DCoor(pSet);
+ if(rOld1.IsDeviceCoor())
+ rOld1.To3DCoor(pSet);
+ if(rOld2.IsDeviceCoor())
+ rOld2.To3DCoor(pSet);
+ }
+}
+
+/*************************************************************************
+|*
+|* Neuen Punkt an der stelle t des parametrisierten Vektors rOld1, rOld2
+|* berechnen und fuellen
+|*
+\************************************************************************/
+
+void B3dEntity::CalcInBetween(B3dEntity& rOld1, B3dEntity& rOld2, double t)
+{
+ // DeviceCoor der ersten Quelle benutzen, die Basis sollte
+ // vorher abgeglichen sein
+ SetDeviceCoor(rOld1.IsDeviceCoor());
+
+ // Punktkoordinaten berechnen
+ aPoint.CalcInBetween(rOld1.Point(), rOld2.Point(), t);
+ SetValid();
+
+ // PlaneNormal Koordinaten berechnen
+ rOld1.PlaneNormal().Normalize();
+ rOld2.PlaneNormal().Normalize();
+ aPlaneNormal.CalcInBetween(rOld1.PlaneNormal(), rOld2.PlaneNormal(), t);
+ aPlaneNormal.Normalize();
+
+ // Vektor berechnen
+ if(rOld1.IsNormalUsed() && rOld2.IsNormalUsed())
+ {
+ rOld1.Normal().Normalize();
+ rOld2.Normal().Normalize();
+ aNormal.CalcInBetween(rOld1.Normal(), rOld2.Normal(), t);
+ aNormal.Normalize();
+ SetNormalUsed();
+ }
+
+ // Texturkoordinaten berechnen
+ if(rOld1.IsTexCoorUsed() && rOld2.IsTexCoorUsed())
+ {
+ aTexCoor.CalcInBetween(rOld1.TexCoor(), rOld2.TexCoor(), t);
+ SetTexCoorUsed();
+ }
+
+ // EdgeVisible berechnen
+ SetEdgeVisible(rOld1.IsEdgeVisible());
+
+ // Farbe berechnen
+ aColor.CalcInBetween(rOld1.Color(), rOld2.Color(), t);
+}
+
+/*************************************************************************
+|*
+|* Neuen Punkt in der Mitte des parametrisierten Vektors rOld1, rOld2
+|* berechnen und fuellen
+|*
+\************************************************************************/
+
+void B3dEntity::CalcMiddle(B3dEntity& rOld1, B3dEntity& rOld2)
+{
+ // DeviceCoor der ersten Quelle benutzen, die Basis sollte
+ // vorher abgeglichen sein
+ SetDeviceCoor(rOld1.IsDeviceCoor());
+
+ // Punktkoordinaten berechnen
+ aPoint.CalcMiddle(rOld1.Point(), rOld2.Point());
+ SetValid();
+
+ // PlaneNormal Koordinaten berechnen
+ rOld1.PlaneNormal().Normalize();
+ rOld2.PlaneNormal().Normalize();
+ aPlaneNormal.CalcMiddle(rOld1.PlaneNormal(), rOld2.PlaneNormal());
+ aPlaneNormal.Normalize();
+
+ // Vektor berechnen
+ if(rOld1.IsNormalUsed() && rOld2.IsNormalUsed())
+ {
+ rOld1.Normal().Normalize();
+ rOld2.Normal().Normalize();
+ aNormal.CalcMiddle(rOld1.Normal(), rOld2.Normal());
+ aNormal.Normalize();
+ SetNormalUsed();
+ }
+
+ // Texturkoordinaten berechnen
+ if(rOld1.IsTexCoorUsed() && rOld2.IsTexCoorUsed())
+ {
+ aTexCoor.CalcMiddle(rOld1.TexCoor(), rOld2.TexCoor());
+ SetTexCoorUsed();
+ }
+
+ // EdgeVisible berechnen
+ SetEdgeVisible(rOld1.IsEdgeVisible());
+
+ // Farbe berechnen
+ aColor.CalcMiddle(rOld1.Color(), rOld2.Color());
+}
+
+/*************************************************************************
+|*
+|* Neuen Punkt in der Mitte des Dreiecks rOld1, rOld2, rOld3
+|* berechnen und fuellen
+|*
+\************************************************************************/
+
+void B3dEntity::CalcMiddle(B3dEntity& rOld1, B3dEntity& rOld2,
+ B3dEntity& rOld3)
+{
+ // DeviceCoor der ersten Quelle benutzen, die Basis sollte
+ // vorher abgeglichen sein
+ SetDeviceCoor(rOld1.IsDeviceCoor());
+
+ // Punktkoordinaten berechnen
+ aPoint.CalcMiddle(rOld1.Point(), rOld2.Point(), rOld3.Point());
+ SetValid();
+
+ // PlaneNormal Koordinaten berechnen
+ rOld1.PlaneNormal().Normalize();
+ rOld2.PlaneNormal().Normalize();
+ rOld3.PlaneNormal().Normalize();
+ aPlaneNormal.CalcMiddle(rOld1.PlaneNormal(), rOld2.PlaneNormal(), rOld3.PlaneNormal());
+ aPlaneNormal.Normalize();
+
+ // Vektor berechnen
+ if(rOld1.IsNormalUsed() && rOld2.IsNormalUsed() && rOld3.IsNormalUsed())
+ {
+ rOld1.Normal().Normalize();
+ rOld2.Normal().Normalize();
+ rOld3.Normal().Normalize();
+ aNormal.CalcMiddle(rOld1.Normal(), rOld2.Normal(), rOld3.Normal());
+ aNormal.Normalize();
+ SetNormalUsed();
+ }
+
+ // Texturkoordinaten berechnen
+ if(rOld1.IsTexCoorUsed() && rOld2.IsTexCoorUsed() && rOld3.IsTexCoorUsed())
+ {
+ aTexCoor.CalcMiddle(rOld1.TexCoor(), rOld2.TexCoor(), rOld3.TexCoor());
+ SetTexCoorUsed();
+ }
+
+ // Farbe berechnen
+ aColor.CalcMiddle(rOld1.Color(), rOld2.Color(), rOld3.Color());
+}
+
+/*************************************************************************
+|*
+|* Eine beliebige Transformation auf die Geometrie anwenden
+|*
+\************************************************************************/
+
+void B3dEntity::Transform(const Matrix4D& rMat)
+{
+ aPoint *= rMat;
+ if(bNormalUsed)
+ rMat.RotateAndNormalize(aNormal);
+}
+
+/*************************************************************************
+|*
+|* Bucket fuer geometrische Daten
+|*
+\************************************************************************/
+
+BASE3D_IMPL_BUCKET(B3dEntity, Bucket)
+
+
diff --git a/goodies/source/base3d/b3dgeom.cxx b/goodies/source/base3d/b3dgeom.cxx
new file mode 100644
index 000000000000..a9f4c271a506
--- /dev/null
+++ b/goodies/source/base3d/b3dgeom.cxx
@@ -0,0 +1,982 @@
+/*************************************************************************
+ *
+ * $RCSfile: b3dgeom.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _B3D_B3DGEOM_HXX
+#include "b3dgeom.hxx"
+#endif
+
+#ifndef _B3D_B3DCOMPO_HXX
+#include "b3dcompo.hxx"
+#endif
+
+#ifndef _B3D_HMATRIX_HXX
+#include "hmatrix.hxx"
+#endif
+
+#ifndef _B3D_BASE3D_HXX
+#include "base3d.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#ifndef _INC_MATH
+#include <math.h>
+#endif
+
+/*************************************************************************
+|*
+|* Bucket fuer Index
+|*
+\************************************************************************/
+
+BASE3D_IMPL_BUCKET(GeometryIndexValue, Bucket)
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+B3dGeometry::B3dGeometry()
+: pComplexPolygon(NULL),
+ aEntityBucket(14), // 16K
+ aIndexBucket(8) // 256Byte
+{
+ Reset();
+}
+
+/*************************************************************************
+|*
+|* Ausgangszustand der Variablen herstellen
+|*
+\************************************************************************/
+
+void B3dGeometry::Reset()
+{
+ bHintIsComplex = FALSE;
+ if(pComplexPolygon)
+ delete pComplexPolygon;
+ pComplexPolygon = NULL;
+}
+
+/*************************************************************************
+|*
+|* Freien Eintrag zum fuellen holen
+|*
+\************************************************************************/
+
+B3dEntity& B3dGeometry::GetFreeEntity()
+{
+ aEntityBucket.Append();
+ return aEntityBucket[aEntityBucket.Count() - 1];
+}
+
+/*************************************************************************
+|*
+|* Inhalte loeschen
+|*
+\************************************************************************/
+
+void B3dGeometry::Erase()
+{
+ aEntityBucket.Erase();
+ aIndexBucket.Erase();
+ Reset();
+}
+
+/*************************************************************************
+|*
+|* Inhalte loeschen und Speicher freigeben
+|*
+\************************************************************************/
+
+void B3dGeometry::Empty()
+{
+ aEntityBucket.Empty();
+ aIndexBucket.Empty();
+ Reset();
+}
+
+/*************************************************************************
+|*
+|* Start der Geometriebeschreibung
+|*
+\************************************************************************/
+
+void B3dGeometry::StartDescription()
+{
+ Erase();
+}
+
+/*************************************************************************
+|*
+|* Ende der Geometriebeschreibung
+|*
+\************************************************************************/
+
+void B3dGeometry::EndDescription()
+{
+ if(pComplexPolygon)
+ delete pComplexPolygon;
+ pComplexPolygon = NULL;
+}
+
+/*************************************************************************
+|*
+|* Neues Primitiv beginnen
+|*
+\************************************************************************/
+
+void B3dGeometry::StartObject(BOOL bHintComplex, BOOL bOutl)
+{
+ // Hint uebernehmen
+ bHintIsComplex = bHintComplex;
+ bOutline = bOutl;
+
+ // ComplexPolygon anlegen falls nicht vorhanden
+ if(bHintIsComplex)
+ {
+ if(!pComplexPolygon)
+ pComplexPolygon = new B3dComplexPolygon;
+ pComplexPolygon->StartPrimitive();
+ }
+ else
+ {
+ // Direkt neues Polygon beginnen
+ StartPolygon();
+ }
+}
+
+/*************************************************************************
+|*
+|* Primitiv abschliessen
+|*
+\************************************************************************/
+
+void B3dGeometry::EndObject()
+{
+ // Unteren Index holen
+ UINT32 nLow = 0L;
+ if(aIndexBucket.Count())
+ nLow = aIndexBucket[aIndexBucket.Count()-1].GetIndex();
+
+ if(bHintIsComplex)
+ {
+ pComplexPolygon->EndPrimitive(this);
+ }
+ else
+ {
+ // Polygon abschliessen
+ EndPolygon();
+ }
+
+ // EbenenNormale berechnen und setzen; bei Linien und
+ // Punkten wird PlaneNormal auf (0,0,0) gesetzt
+ UINT32 nHigh = aIndexBucket[aIndexBucket.Count()-1].GetIndex();
+ Vector3D aPlaneNormal = -CalcNormal(nLow, nHigh);
+ while(nLow < nHigh)
+ aEntityBucket[nLow++].PlaneNormal() = aPlaneNormal;
+}
+
+/*************************************************************************
+|*
+|* Geometrieuebergabe
+|*
+\************************************************************************/
+
+void B3dGeometry::AddEdge(const Vector3D& rPoint)
+{
+ if(bHintIsComplex)
+ {
+ B3dEntity& rNew = pComplexPolygon->GetFreeEntity();
+
+ rNew.Reset();
+ rNew.Point() = rPoint;
+ rNew.SetValid();
+ rNew.SetEdgeVisible(TRUE);
+
+ pComplexPolygon->PostAddVertex(rNew);
+ }
+ else
+ {
+ B3dEntity& rNew = GetFreeEntity();
+
+ rNew.Reset();
+ rNew.Point() = rPoint;
+ rNew.SetValid();
+ rNew.SetEdgeVisible(TRUE);
+ }
+}
+
+void B3dGeometry::AddEdge(
+ const Vector3D& rPoint,
+ const Vector3D& rNormal)
+{
+ if(bHintIsComplex)
+ {
+ B3dEntity& rNew = pComplexPolygon->GetFreeEntity();
+
+ rNew.Reset();
+ rNew.Point() = rPoint;
+ rNew.SetValid();
+ rNew.Normal() = rNormal;
+ rNew.SetNormalUsed();
+ rNew.SetEdgeVisible(TRUE);
+
+ pComplexPolygon->PostAddVertex(rNew);
+ }
+ else
+ {
+ B3dEntity& rNew = GetFreeEntity();
+
+ rNew.Reset();
+ rNew.Point() = rPoint;
+ rNew.SetValid();
+ rNew.Normal() = rNormal;
+ rNew.SetNormalUsed();
+ rNew.SetEdgeVisible(TRUE);
+ }
+}
+
+void B3dGeometry::AddEdge(
+ const Vector3D& rPoint,
+ const Vector3D& rNormal,
+ const Vector3D& rTexture)
+{
+ if(bHintIsComplex)
+ {
+ B3dEntity& rNew = pComplexPolygon->GetFreeEntity();
+
+ rNew.Reset();
+ rNew.Point() = rPoint;
+ rNew.SetValid();
+ rNew.Normal() = rNormal;
+ rNew.SetNormalUsed();
+ rNew.TexCoor() = rTexture;
+ rNew.SetTexCoorUsed();
+ rNew.SetEdgeVisible(TRUE);
+
+ pComplexPolygon->PostAddVertex(rNew);
+ }
+ else
+ {
+ B3dEntity& rNew = GetFreeEntity();
+
+ rNew.Reset();
+ rNew.Point() = rPoint;
+ rNew.SetValid();
+ rNew.Normal() = rNormal;
+ rNew.SetNormalUsed();
+ rNew.TexCoor() = rTexture;
+ rNew.SetTexCoorUsed();
+ rNew.SetEdgeVisible(TRUE);
+ }
+}
+
+/*************************************************************************
+|*
+|* Copy-Operator
+|*
+\************************************************************************/
+
+void B3dGeometry::operator=(const B3dGeometry& rObj)
+{
+ // Bucket kopieren
+ aEntityBucket = rObj.aEntityBucket;
+ aIndexBucket = rObj.aIndexBucket;
+
+ // ComplexPolygon nicht kopieren
+ pComplexPolygon = NULL;
+
+ // Hint auch nicht
+ bHintIsComplex = FALSE;
+}
+
+/*************************************************************************
+|*
+|* Callbacks bei komplexen Primitiven
+|*
+\************************************************************************/
+
+void B3dGeometry::StartComplexPrimitive()
+{
+ StartPolygon();
+}
+
+void B3dGeometry::EndComplexPrimitive()
+{
+ EndPolygon();
+}
+
+void B3dGeometry::AddComplexVertex(B3dEntity& rNew, BOOL bIsVisible)
+{
+ // Kopieren
+ B3dEntity& rLocal = GetFreeEntity();
+ rLocal = rNew;
+
+ // EdgeFlag anpassen
+ rLocal.SetEdgeVisible(bIsVisible);
+}
+
+/*************************************************************************
+|*
+|* PolygonStart und -Ende aufzeichnen
+|*
+\************************************************************************/
+
+void B3dGeometry::StartPolygon()
+{
+}
+
+void B3dGeometry::EndPolygon()
+{
+ GeometryIndexValue aNewIndex(aEntityBucket.Count());
+ if(bOutline)
+ aNewIndex.SetMode(B3D_INDEX_MODE_LINE);
+ aIndexBucket.Append(aNewIndex);
+}
+
+/*************************************************************************
+|*
+|* Eine beliebige Transformation auf die Geometrie anwenden
+|*
+\************************************************************************/
+
+void B3dGeometry::Transform(const Matrix4D& rMat)
+{
+ for(UINT32 a=0;a<aEntityBucket.Count();a++)
+ aEntityBucket[a].Transform(rMat);
+}
+
+/*************************************************************************
+|*
+|* Hittest auf Geometrie
+|* Liegt der angegebene Schnittpunkt innerhalb eines der Polygone?
+|*
+\************************************************************************/
+
+INT32 B3dGeometry::CheckHit(const Vector3D& rFront, const Vector3D& rBack, USHORT nTol)
+{
+ UINT32 nPolyCounter = 0;
+ UINT32 nEntityCounter = 0;
+ UINT32 nUpperBound;
+ INT32 nRetval;
+
+ while(nPolyCounter < aIndexBucket.Count())
+ {
+ // Obergrenze neues Polygon holen
+ nUpperBound = aIndexBucket[nPolyCounter++].GetIndex();
+
+ // Hittest fuer momentanes Polygon
+ nRetval = CheckSinglePolygonHit(nEntityCounter, nUpperBound, rFront, rBack);
+ if(nRetval != -1L)
+ return nRetval;
+
+ // Auf naechstes Polygon
+ nEntityCounter = nUpperBound;
+ }
+ return nRetval;
+}
+
+INT32 B3dGeometry::CheckSinglePolygonHit(UINT32 nLow, UINT32 nHigh, const Vector3D& rFront, const Vector3D& rBack)
+{
+ if(nLow + 2 < nHigh)
+ {
+ // Schnittpunkt berechnen
+ Vector3D aCut;
+ if(GetCutPoint(nLow, aCut, rFront, rBack))
+ {
+ // Schnittpunkt existiert, liegt dieser im angegebenen
+ // konvexen Polygon?
+ if(IsInside(nLow, nHigh, aCut))
+ {
+ return ((INT32)(aCut.Z() + 0.5));
+ }
+ }
+ }
+ return -1L;
+}
+
+BOOL B3dGeometry::GetCutPoint(UINT32 nLow, Vector3D& rCut, const Vector3D& rFront, const Vector3D& rBack)
+{
+ BOOL bCutValid = FALSE;
+
+ // Normale und Skalar der Ebenengleichung ermitteln
+ Vector3D aNormal = aEntityBucket[nLow].PlaneNormal();
+ double fScalar = -(aEntityBucket[nLow + 1].Point().GetVector3D().Scalar(aNormal));
+ Vector3D aLineVec = rFront - rBack;
+ double fZwi = aNormal.Scalar(aLineVec);
+
+ if(fabs(fZwi) > SMALL_DVALUE)
+ {
+ fZwi = (-fScalar - (rBack.Scalar(aNormal))) / fZwi;
+// if(fZwi > SMALL_DVALUE && fZwi < 1.0 - SMALL_DVALUE)
+// {
+ rCut.X() = rBack.X() + (aLineVec.X() * fZwi);
+ rCut.Y() = rBack.Y() + (aLineVec.Y() * fZwi);
+ rCut.Z() = rBack.Z() + (aLineVec.Z() * fZwi);
+
+ bCutValid = TRUE;
+// }
+ }
+ return bCutValid;
+}
+
+BOOL B3dGeometry::IsInside(UINT32 nLow, UINT32 nHigh, const Vector3D& rPnt)
+{
+ BOOL bInside(FALSE);
+ B3dVolume aVolume;
+
+ // Volume von genau dieser Flaeche feststellen
+ for(UINT32 a=nLow;a<nHigh;a++)
+ aVolume.Union(aEntityBucket[a].Point().GetVector3D());
+
+ // Hier eigentlich ein aVolume.IsInside(rPnt), doch da hier ein
+ // Vergleich mit Epsilon-Umgebung gebraucht wird, vergleiche selbst
+ BOOL bIsInside =
+ (rPnt.X() + SMALL_DVALUE >= aVolume.MinVec().X() && rPnt.X() - SMALL_DVALUE <= aVolume.MaxVec().X()
+ && rPnt.Y() + SMALL_DVALUE >= aVolume.MinVec().Y() && rPnt.Y() - SMALL_DVALUE <= aVolume.MaxVec().Y()
+ && rPnt.Z() + SMALL_DVALUE >= aVolume.MinVec().Z() && rPnt.Z() - SMALL_DVALUE <= aVolume.MaxVec().Z());
+
+ if(bIsInside)
+ {
+ BOOL bInsideXY(FALSE);
+ BOOL bInsideXZ(FALSE);
+ BOOL bInsideYZ(FALSE);
+ const Vector3D* pPrev = &(aEntityBucket[nHigh - 1].Point().GetVector3D());
+ const Vector3D* pActual;
+ Vector3D aDiffPrev, aDiffActual;
+
+ while(nLow < nHigh)
+ {
+ // Neuen Punkt holen
+ pActual = &(aEntityBucket[nLow++].Point().GetVector3D());
+
+ // Diffs bilden
+ aDiffPrev = *pPrev - rPnt;
+ aDiffActual = *pActual - rPnt;
+
+ // Ueberschneidung in Y moeglich?
+ if((aDiffPrev.Y() > 0.0 && aDiffActual.Y() <= 0.0) || (aDiffActual.Y() > 0.0 && aDiffPrev.Y() <= 0.0))
+ {
+ // in welchem Bereich liegt X?
+ if(aDiffPrev.X() >= 0.0 && aDiffActual.X() >= 0.0)
+ {
+ // Ueberschneidung
+ bInsideXY = !bInsideXY;
+ }
+ else if((aDiffPrev.X() > 0.0 && aDiffActual.X() <= 0.0) || (aDiffActual.X() > 0.0 && aDiffPrev.X() <= 0.0))
+ {
+ // eventuell Ueberschneidung
+ // wo liegt die X-Koordinate des Schnitts mit der X-Achse?
+ if(aDiffActual.Y() != aDiffPrev.Y())
+ if(aDiffPrev.X() - ((aDiffPrev.Y() * (aDiffActual.X() - aDiffPrev.X())) / (aDiffActual.Y() - aDiffPrev.Y())) >= 0.0)
+ // Ueberschneidung
+ bInsideXY = !bInsideXY;
+ }
+
+ // in welchem Bereich liegt Z?
+ if(aDiffPrev.Z() >= 0.0 && aDiffActual.Z() >= 0.0)
+ {
+ // Ueberschneidung
+ bInsideYZ = !bInsideYZ;
+ }
+ else if((aDiffPrev.Z() > 0.0 && aDiffActual.Z() <= 0.0) || (aDiffActual.Z() > 0.0 && aDiffPrev.Z() <= 0.0))
+ {
+ // eventuell Ueberschneidung
+ // wo liegt die X-Koordinate des Schnitts mit der X-Achse?
+ if(aDiffActual.Y() != aDiffPrev.Y())
+ if(aDiffPrev.Z() - ((aDiffPrev.Y() * (aDiffActual.Z() - aDiffPrev.Z())) / (aDiffActual.Y() - aDiffPrev.Y())) >= 0.0)
+ // Ueberschneidung
+ bInsideYZ = !bInsideYZ;
+ }
+ }
+
+ // Ueberschneidung in X moeglich?
+ if((aDiffPrev.X() > 0.0 && aDiffActual.X() <= 0.0) || (aDiffActual.X() > 0.0 && aDiffPrev.X() <= 0.0))
+ {
+ // in welchem Bereich liegt Z?
+ if(aDiffPrev.Z() >= 0.0 && aDiffActual.Z() >= 0.0)
+ {
+ // Ueberschneidung
+ bInsideXZ = !bInsideXZ;
+ }
+ else if((aDiffPrev.Z() > 0.0 && aDiffActual.Z() <= 0.0) || (aDiffActual.Z() > 0.0 && aDiffPrev.Z() <= 0.0))
+ {
+ // eventuell Ueberschneidung
+ // wo liegt die X-Koordinate des Schnitts mit der X-Achse?
+ if(aDiffActual.X() != aDiffPrev.X())
+ if(aDiffPrev.Z() - ((aDiffPrev.X() * (aDiffActual.Z() - aDiffPrev.Z())) / (aDiffActual.X() - aDiffPrev.X())) >= 0.0)
+ // Ueberschneidung
+ bInsideXZ = !bInsideXZ;
+ }
+ }
+
+ // Punkt als Vorgaenger merken
+ pPrev = pActual;
+ }
+ // Wahrheitswert bilden
+ bInside = bInsideXY || bInsideXZ || bInsideYZ;
+ }
+ return bInside;
+}
+
+/*************************************************************************
+|*
+|* BoundVolume liefern
+|*
+\************************************************************************/
+
+B3dVolume B3dGeometry::GetBoundVolume()
+{
+ B3dVolume aRetval;
+
+ for(UINT32 a=0;a<aEntityBucket.Count();a++)
+ aRetval.Union(aEntityBucket[a].Point().GetVector3D());
+
+ return aRetval;
+}
+
+/*************************************************************************
+|*
+|* Mittelpunkt liefern
+|*
+\************************************************************************/
+
+Vector3D B3dGeometry::GetCenter()
+{
+ B3dVolume aVolume = GetBoundVolume();
+ return (aVolume.MaxVec() + aVolume.MinVec()) / 2.0;
+}
+
+/*************************************************************************
+|*
+|* Standard - Normalen generieren
+|*
+\************************************************************************/
+
+void B3dGeometry::CreateDefaultNormalsSphere()
+{
+ // Alle Normalen ausgehend vom Zentrum der Geometrie bilden
+ Vector3D aCenter = GetCenter();
+
+ for(UINT32 a=0;a<aEntityBucket.Count();a++)
+ {
+ const Vector3D& aPoint = aEntityBucket[a].Point().GetVector3D();
+ Vector3D aNewNormal = aPoint - aCenter;
+ aNewNormal.Normalize();
+ aEntityBucket[a].Normal() = aNewNormal;
+ aEntityBucket[a].SetNormalUsed(TRUE);
+ }
+}
+
+/*************************************************************************
+|*
+|* Normale ermitteln fuer einzelnes Polygon
+|*
+\************************************************************************/
+
+Vector3D B3dGeometry::CalcNormal(UINT32 nLow, UINT32 nHigh)
+{
+ const Vector3D* pVec1 = NULL;
+ const Vector3D* pVec2 = NULL;
+ const Vector3D* pVec3 = NULL;
+ Vector3D aNormal;
+
+ while(nLow < nHigh && !(pVec1 && pVec2 && pVec3))
+ {
+ if(!pVec1)
+ {
+ pVec1 = &(aEntityBucket[nLow++].Point().GetVector3D());
+ }
+ else if(!pVec2)
+ {
+ pVec2 = &(aEntityBucket[nLow++].Point().GetVector3D());
+ if(*pVec2 == *pVec1)
+ pVec2 = NULL;
+ }
+ else if(!pVec3)
+ {
+ pVec3 = &(aEntityBucket[nLow++].Point().GetVector3D());
+ if(*pVec3 == *pVec2 || pVec3 == pVec1)
+ pVec3 = NULL;
+ }
+ }
+ if(pVec1 && pVec2 && pVec3)
+ {
+ aNormal = (*pVec2 - *pVec1)|(*pVec2 - *pVec3);
+ aNormal.Normalize();
+ }
+ return aNormal;
+}
+
+/*************************************************************************
+|*
+|* Normaleninformationen ungueltig machen
+|*
+\************************************************************************/
+
+void B3dGeometry::RemoveNormals()
+{
+ for(UINT32 a=0;a<aEntityBucket.Count();a++)
+ aEntityBucket[a].SetNormalUsed(FALSE);
+}
+
+/*************************************************************************
+|*
+|* Standard - Texturkoordinaten generieren
+|*
+\************************************************************************/
+
+void B3dGeometry::CreateDefaultTexture(UINT16 nCreateWhat, BOOL bUseSphere)
+{
+ if(nCreateWhat)
+ {
+ if(bUseSphere)
+ {
+ // Texturkoordinaten mittels Kugelprojektion ermitteln,
+ // dazu das Zentrum der Geometrie benutzen
+ // Alle Normalen ausgehend vom Zentrum der Geometrie bilden
+ Vector3D aCenter = GetCenter();
+ UINT32 nPointCounter = 0;
+
+ for(UINT32 a=0;a<aIndexBucket.Count();a++)
+ {
+ // Lokales Zentrum der zu behandelnden Flaeche bilden,
+ // um zu wissen von welcher Seite sich diese Flaeche
+ // dem Winkel F_PI bzw. -F_PI naehert
+ Vector3D aLocalCenter;
+ for(UINT32 b=nPointCounter;b<aIndexBucket[a].GetIndex();b++)
+ aLocalCenter += aEntityBucket[b].Point().GetVector3D();
+ aLocalCenter /= aIndexBucket[a].GetIndex() - nPointCounter;
+
+ // Vektor vom Mittelpunkt zum lokalen Zentrum bilden
+ aLocalCenter = aLocalCenter - aCenter;
+ if(fabs(aLocalCenter.X()) < SMALL_DVALUE)
+ aLocalCenter.X() = 0.0;
+ if(fabs(aLocalCenter.Y()) < SMALL_DVALUE)
+ aLocalCenter.Y() = 0.0;
+ if(fabs(aLocalCenter.Z()) < SMALL_DVALUE)
+ aLocalCenter.Z() = 0.0;
+
+ // X,Y fuer das lokale Zentrum bilden
+ double fXCenter = atan2(aLocalCenter.Z(), aLocalCenter.X());
+ double fYCenter = atan2(aLocalCenter.Y(), aLocalCenter.GetXZLength());
+ fXCenter = 1.0 - ((fXCenter + F_PI) / F_2PI);
+ fYCenter = 1.0 - ((fYCenter + F_PI2) / F_PI);
+
+ // Einzelne Punkte behandeln
+ UINT32 nRememberPointCounter = nPointCounter;
+ while(nPointCounter < aIndexBucket[a].GetIndex())
+ {
+ // Vektor vom Mittelpunkt zum Punkt bilden
+ const Vector3D& aPoint = aEntityBucket[nPointCounter].Point().GetVector3D();
+ Vector3D aDirection = aPoint - aCenter;
+ if(fabs(aDirection.X()) < SMALL_DVALUE)
+ aDirection.X() = 0.0;
+ if(fabs(aDirection.Y()) < SMALL_DVALUE)
+ aDirection.Y() = 0.0;
+ if(fabs(aDirection.Z()) < SMALL_DVALUE)
+ aDirection.Z() = 0.0;
+
+ // X,Y fuer Punkt bilden
+ double fXPoint = atan2(aDirection.Z(), aDirection.X());
+ double fYPoint = atan2(aDirection.Y(), aDirection.GetXZLength());
+ fXPoint = 1.0 - ((fXPoint + F_PI) / F_2PI);
+ fYPoint = 1.0 - ((fYPoint + F_PI2) / F_PI);
+
+ // X,Y des Punktes korrigieren
+ if(fXPoint > fXCenter + 0.5)
+ fXPoint -= 1.0;
+ if(fXPoint < fXCenter - 0.5)
+ fXPoint += 1.0;
+
+ // Polarkoordinaten als Texturkoordinaten zuweisen
+ if(nCreateWhat & B3D_CREATE_DEFAULT_X)
+ aEntityBucket[nPointCounter].TexCoor().X() = fXPoint;
+ if(nCreateWhat & B3D_CREATE_DEFAULT_Y)
+ aEntityBucket[nPointCounter].TexCoor().Y() = fYPoint;
+ if(nCreateWhat & B3D_CREATE_DEFAULT_Z)
+ aEntityBucket[nPointCounter].TexCoor().Z() = 0.0;
+
+ aEntityBucket[nPointCounter++].SetTexCoorUsed(TRUE);
+ }
+
+ // Punkte korrigieren, die direkt in den Polarregionen liegen. Deren
+ // X-Koordinate kann nicht korrekt sein. Die korrekte X-Koordinate
+ // ist diejenige des Punktes, der in den Pol hinein oder aus diesem heraus
+ // fuehrt, auf der Kugel also direkt darauf zu.
+ if(nCreateWhat & B3D_CREATE_DEFAULT_X)
+ {
+ nPointCounter = nRememberPointCounter;
+ while(nPointCounter < aIndexBucket[a].GetIndex())
+ {
+ Vector3D& aCoor = aEntityBucket[nPointCounter].TexCoor();
+ if(fabs(aCoor.Y()) < SMALL_DVALUE || fabs(aCoor.Y() - 1.0) < SMALL_DVALUE)
+ {
+ // Nachfolger finden
+ UINT32 nNextIndex = (nPointCounter + 1 < aIndexBucket[a].GetIndex())
+ ? nPointCounter + 1 : nRememberPointCounter;
+ Vector3D& aNextCoor = aEntityBucket[nNextIndex].TexCoor();
+
+ // Vorgaenger finden
+ UINT32 nPrevIndex = (nPointCounter && nPointCounter - 1 >= nRememberPointCounter)
+ ? nPointCounter - 1 : aIndexBucket[a].GetIndex() - 1;
+ Vector3D& aPrevCoor = aEntityBucket[nPrevIndex].TexCoor();
+
+ // Nachfolger testen: Liegt dieser ausserhalb des Pols?
+ if(fabs(aNextCoor.Y()) > SMALL_DVALUE && fabs(aNextCoor.Y() - 1.0) > SMALL_DVALUE)
+ {
+ // falls ja: X-Koordinate uebernehmen
+ aCoor.X() = aNextCoor.X();
+ }
+ // Vorgaenger testen: Liegt dieser ausserhalb des Pols?
+ else if(fabs(aPrevCoor.Y()) > SMALL_DVALUE && fabs(aPrevCoor.Y() - 1.0) > SMALL_DVALUE)
+ {
+ // falls ja, X-Koordinate uebernehmen
+ aCoor.X() = aPrevCoor.X();
+ }
+ else
+ {
+ // Weder Vorgaenger noch Nachfolger liegen ausserhalb des Pols.
+ // Uebernimm daher wenigstens den bereits korrigierten X-Wert
+ // des Vorgaengers
+ aCoor.X() = aPrevCoor.X();
+ }
+ }
+ // naechster Punkt
+ nPointCounter++;
+ }
+ }
+ }
+ }
+ else
+ {
+ // Texturkoordinaten als Parallelprojektion auf X,Y,Z - Koordinaten
+ // im Bereich 1.0 bis 0.0 der Geometrie abstellen
+ // Gesamtabmessungen holen
+ B3dVolume aVolume = GetBoundVolume();
+
+ for(UINT32 a=0;a<aEntityBucket.Count();a++)
+ {
+ const Vector3D& aPoint = aEntityBucket[a].Point().GetVector3D();
+
+ if(nCreateWhat & B3D_CREATE_DEFAULT_X)
+ {
+ if(aVolume.GetWidth())
+ aEntityBucket[a].TexCoor().X() = (aPoint.X() - aVolume.MinVec().X()) / aVolume.GetWidth();
+ else
+ aEntityBucket[a].TexCoor().X() = 0.0;
+ }
+
+ if(nCreateWhat & B3D_CREATE_DEFAULT_Y)
+ {
+ if(aVolume.GetHeight())
+ aEntityBucket[a].TexCoor().Y() = 1.0 - ((aPoint.Y() - aVolume.MinVec().Y()) / aVolume.GetHeight());
+ else
+ aEntityBucket[a].TexCoor().Y() = 1.0;
+ }
+
+ if(nCreateWhat & B3D_CREATE_DEFAULT_Z)
+ aEntityBucket[a].TexCoor().Z() = 0.0;
+
+ aEntityBucket[a].SetTexCoorUsed(TRUE);
+ }
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Texturinformationen ungueltig machen
+|*
+\************************************************************************/
+
+void B3dGeometry::RemoveTexture()
+{
+ for(UINT32 a=0;a<aEntityBucket.Count();a++)
+ aEntityBucket[a].SetTexCoorUsed(FALSE);
+}
+
+/*************************************************************************
+|*
+|* Default-Geometrien erstellen
+|*
+\************************************************************************/
+
+void B3dGeometry::CreateCube(const B3dVolume& rVolume)
+{
+ Erase();
+ StartDescription();
+ Vector3D A(rVolume.MinVec().X(), rVolume.MaxVec().Y(), rVolume.MinVec().Z());
+ Vector3D B(rVolume.MaxVec().X(), rVolume.MaxVec().Y(), rVolume.MinVec().Z());
+ Vector3D C(rVolume.MaxVec().X(), rVolume.MinVec().Y(), rVolume.MinVec().Z());
+ Vector3D D(rVolume.MinVec().X(), rVolume.MinVec().Y(), rVolume.MinVec().Z());
+ Vector3D E(rVolume.MinVec().X(), rVolume.MaxVec().Y(), rVolume.MaxVec().Z());
+ Vector3D F(rVolume.MaxVec().X(), rVolume.MaxVec().Y(), rVolume.MaxVec().Z());
+ Vector3D G(rVolume.MaxVec().X(), rVolume.MinVec().Y(), rVolume.MaxVec().Z());
+ Vector3D H(rVolume.MinVec().X(), rVolume.MinVec().Y(), rVolume.MaxVec().Z());
+ StartObject(FALSE);
+ AddEdge(A);
+ AddEdge(B);
+ AddEdge(C);
+ AddEdge(D);
+ EndObject();
+ StartObject(FALSE);
+ AddEdge(A);
+ AddEdge(E);
+ AddEdge(F);
+ AddEdge(B);
+ EndObject();
+ StartObject(FALSE);
+ AddEdge(B);
+ AddEdge(F);
+ AddEdge(G);
+ AddEdge(C);
+ EndObject();
+ StartObject(FALSE);
+ AddEdge(C);
+ AddEdge(G);
+ AddEdge(H);
+ AddEdge(D);
+ EndObject();
+ StartObject(FALSE);
+ AddEdge(D);
+ AddEdge(H);
+ AddEdge(E);
+ AddEdge(A);
+ EndObject();
+ StartObject(FALSE);
+ AddEdge(E);
+ AddEdge(H);
+ AddEdge(G);
+ AddEdge(F);
+ EndObject();
+ EndDescription();
+ CreateDefaultNormalsSphere();
+ CreateDefaultTexture(B3D_CREATE_DEFAULT_ALL, FALSE);
+}
+
+void B3dGeometry::CreateSphere(const B3dVolume& rVolume, double fX, double fY)
+{
+ Erase();
+ StartDescription();
+ Vector3D A,B,C,D;
+ double fXInc, fYInc;
+ if(fX == 0.0)
+ fX = 4.0;
+ fXInc = F_2PI / fX;
+ if(fY == 0.0)
+ fY = 4.0;
+ fYInc = F_PI / fY;
+ UINT16 nX = (UINT16)fX;
+ UINT16 nY = (UINT16)fY;
+ fX = 0.0;
+ for(UINT16 a=0;a<nX;a++,fX+=fXInc)
+ {
+ fY = -F_PI2;
+ for(UINT16 b=0;b<nY;b++,fY+=fYInc)
+ {
+ A.Y() = B.Y() = sin(fY+fYInc);
+ D.Y() = C.Y() = sin(fY);
+ A.X() = cos(fX) * cos(fY+fYInc);
+ D.X() = cos(fX) * cos(fY);
+ B.X() = cos(fX+fXInc) * cos(fY+fYInc);
+ C.X() = cos(fX+fXInc) * cos(fY);
+ A.Z() = sin(fX) * cos(fY+fYInc);
+ D.Z() = sin(fX) * cos(fY);
+ B.Z() = sin(fX+fXInc) * cos(fY+fYInc);
+ C.Z() = sin(fX+fXInc) * cos(fY);
+ StartObject(FALSE);
+ AddEdge(A);
+ AddEdge(B);
+ AddEdge(C);
+ AddEdge(D);
+ EndObject();
+ }
+ }
+ EndDescription();
+ CreateDefaultNormalsSphere();
+ CreateDefaultTexture(B3D_CREATE_DEFAULT_ALL, TRUE);
+ Matrix4D aTransform;
+ aTransform.Translate(Vector3D(1.0, 1.0, 1.0));
+ aTransform.Scale(
+ (rVolume.MaxVec().X() - rVolume.MinVec().X())/2.0,
+ (rVolume.MaxVec().Y() - rVolume.MinVec().Y())/2.0,
+ (rVolume.MaxVec().Z() - rVolume.MinVec().Z())/2.0);
+ aTransform.Translate(rVolume.MinVec());
+ Transform(aTransform);
+}
+
+/*************************************************************************
+|*
+|* Normalen invertieren
+|*
+\************************************************************************/
+
+void B3dGeometry::InvertNormals()
+{
+ for(UINT32 a=0;a<aEntityBucket.Count();a++)
+ aEntityBucket[a].Normal() = -aEntityBucket[a].Normal();
+}
+
diff --git a/goodies/source/base3d/b3dlight.cxx b/goodies/source/base3d/b3dlight.cxx
new file mode 100644
index 000000000000..fdb5bc37192f
--- /dev/null
+++ b/goodies/source/base3d/b3dlight.cxx
@@ -0,0 +1,870 @@
+/*************************************************************************
+ *
+ * $RCSfile: b3dlight.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _B3D_B3DLIGHT_HXX
+#include "b3dlight.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+/*************************************************************************
+|*
+|* Konstruktor B3dLight
+|*
+\************************************************************************/
+
+B3dLight::B3dLight()
+{
+}
+
+/*************************************************************************
+|*
+|* Intensitaet einer bestimmten Lichtkomponente setzen
+|*
+\************************************************************************/
+
+void B3dLight::SetIntensity(const Color rNew, Base3DMaterialValue eVal)
+{
+ switch(eVal)
+ {
+ case Base3DMaterialAmbient:
+ {
+ aAmbient = rNew;
+ if(rNew.GetRed() || rNew.GetGreen() || rNew.GetBlue())
+ bIsAmbient = TRUE;
+ else
+ bIsAmbient = FALSE;
+ break;
+ }
+ case Base3DMaterialDiffuse:
+ {
+ aDiffuse = rNew;
+ if(rNew.GetRed() || rNew.GetGreen() || rNew.GetBlue())
+ bIsDiffuse = TRUE;
+ else
+ bIsDiffuse = FALSE;
+ break;
+ }
+ default:
+ {
+ aSpecular = rNew;
+ if(rNew.GetRed() || rNew.GetGreen() || rNew.GetBlue())
+ bIsSpecular = TRUE;
+ else
+ bIsSpecular = FALSE;
+ break;
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Intensitaet einer bestimmten Lichtkomponente lesen
+|*
+\************************************************************************/
+
+const Color B3dLight::GetIntensity(Base3DMaterialValue eVal)
+{
+ switch(eVal)
+ {
+ case Base3DMaterialAmbient:
+ {
+ return aAmbient;
+ break;
+ }
+ case Base3DMaterialDiffuse:
+ {
+ return aDiffuse;
+ break;
+ }
+ default:
+ {
+ return aSpecular;
+ break;
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Lichtquelle initialisieren (selbe defaults wie OpenGL)
+|*
+\************************************************************************/
+
+void B3dLight::Init()
+{
+ aAmbient = Color(255, 0, 0, 0);
+ if(IsFirst())
+ {
+ aDiffuse = Color(255, 204, 204, 204);
+ aSpecular = Color(255, 255, 255, 255);
+ aPosition = Vector3D(1.0, 1.0, 1.0);
+ aPosition.Normalize();
+ bIsDiffuse = TRUE;
+ bIsSpecular = TRUE;
+ bIsEnabled = TRUE;
+ }
+ else
+ {
+ aDiffuse = Color(0, 0, 0, 0);
+ aSpecular = Color(0, 0, 0, 0);
+ aPosition = Vector3D(0.0, 0.0, 1.0);
+ bIsDiffuse = FALSE;
+ bIsSpecular = FALSE;
+ bIsEnabled = FALSE;
+ }
+ aPositionEye = Vector3D(0.0, 0.0, 0.0);
+ aSpotDirection = Vector3D(0.0, 0.0, -1.0);
+ aSpotDirectionEye = Vector3D(0.0, 0.0, 0.0);
+ nSpotExponent = 0;
+ fSpotCutoff = 180.0;
+ fConstantAttenuation = 1.0;
+ fLinearAttenuation = 0.0;
+ fQuadraticAttenuation = 0.0;
+ bLinearOrQuadratic = FALSE;
+ bIsDirectionalSource = TRUE;
+ bIsSpot = FALSE;
+ bIsAmbient = FALSE;
+}
+
+/*************************************************************************
+|*
+|* Richtung der Lichtquelle setzen
+|*
+\************************************************************************/
+
+void B3dLight::SetSpotDirection(const Vector3D& rNew)
+{
+ aSpotDirection=rNew;
+ aSpotDirection.Normalize();
+}
+
+/*************************************************************************
+|*
+|* Richtung der Lichtquelle in Augkoordinaten setzen
+|*
+\************************************************************************/
+
+void B3dLight::SetSpotDirectionEye(const Vector3D& rNew)
+{
+ aSpotDirectionEye=rNew;
+ aSpotDirectionEye.Normalize();
+}
+
+/*************************************************************************
+|*
+|* Kegel der Lichtquelle setzen
+|*
+\************************************************************************/
+
+void B3dLight::SetSpotCutoff(double fNew)
+{
+ fSpotCutoff = fNew;
+ bIsSpot = (fNew == 180.0) ? FALSE : TRUE;
+ fCosSpotCutoff = cos(fNew * F_PI180);
+}
+
+/*************************************************************************
+|*
+|* Lineare Attenuation setzen
+|*
+\************************************************************************/
+
+void B3dLight::SetLinearAttenuation(double fNew)
+{
+ fLinearAttenuation = fNew;
+ bLinearOrQuadratic =
+ (fNew + fQuadraticAttenuation == 0.0) ? FALSE : TRUE;
+}
+
+/*************************************************************************
+|*
+|* Quadratische Attenuation setzen
+|*
+\************************************************************************/
+
+void B3dLight::SetQuadraticAttenuation(double fNew)
+{
+ fQuadraticAttenuation = fNew;
+ bLinearOrQuadratic =
+ (fNew + fLinearAttenuation == 0.0) ? FALSE : TRUE;
+}
+
+void B3dLight::WriteData(SvStream& rOut) const
+{
+ rOut << aAmbient;
+ rOut << aDiffuse;
+ rOut << aSpecular;
+
+ rOut << aPosition;
+ rOut << aPositionEye;
+ rOut << aSpotDirection;
+ rOut << aSpotDirectionEye;
+ rOut << nSpotExponent;
+
+ rOut << fSpotCutoff;
+ rOut << fCosSpotCutoff;
+ rOut << fConstantAttenuation;
+ rOut << fLinearAttenuation;
+ rOut << fQuadraticAttenuation;
+
+ rOut << (BOOL)bIsFirstLight;
+ rOut << (BOOL)bIsEnabled;
+ rOut << (BOOL)bIsDirectionalSource;
+ rOut << (BOOL)bIsSpot;
+ rOut << (BOOL)bIsAmbient;
+ rOut << (BOOL)bIsDiffuse;
+ rOut << (BOOL)bIsSpecular;
+ rOut << (BOOL)bLinearOrQuadratic;
+}
+
+void B3dLight::ReadData(SvStream& rIn)
+{
+ BOOL bTmp;
+
+ rIn >> aAmbient;
+ rIn >> aDiffuse;
+ rIn >> aSpecular;
+
+ rIn >> aPosition;
+ rIn >> aPositionEye;
+ rIn >> aSpotDirection;
+ rIn >> aSpotDirectionEye;
+ rIn >> nSpotExponent;
+
+ rIn >> fSpotCutoff;
+ rIn >> fCosSpotCutoff;
+ rIn >> fConstantAttenuation;
+ rIn >> fLinearAttenuation;
+ rIn >> fQuadraticAttenuation;
+
+ rIn >> bTmp; bIsFirstLight = bTmp;
+ rIn >> bTmp; bIsEnabled = bTmp;
+ rIn >> bTmp; bIsDirectionalSource = bTmp;
+ rIn >> bTmp; bIsSpot = bTmp;
+ rIn >> bTmp; bIsAmbient = bTmp;
+ rIn >> bTmp; bIsDiffuse = bTmp;
+ rIn >> bTmp; bIsSpecular = bTmp;
+ rIn >> bTmp; bLinearOrQuadratic = bTmp;
+}
+
+/*************************************************************************
+|*
+|* Gruppe von Lichtquellen, Konstruktor
+|*
+\************************************************************************/
+
+B3dLightGroup::B3dLightGroup()
+: aGlobalAmbientLight(255, 102, 102, 102),
+ bLocalViewer(TRUE),
+ bModelTwoSide(FALSE),
+ bLightingEnabled(TRUE)
+{
+ // Lichtquellen initialisieren
+ for(UINT16 i=0; i < BASE3D_MAX_NUMBER_LIGHTS;i++)
+ {
+ aLight[i].SetFirst(i==0);
+ aLight[i].Init();
+ }
+}
+
+/*************************************************************************
+|*
+|* globales Umgebungslicht setzen
+|*
+\************************************************************************/
+
+void B3dLightGroup::SetGlobalAmbientLight(const Color rNew)
+{
+ if(aGlobalAmbientLight != rNew)
+ {
+ aGlobalAmbientLight = rNew;
+ }
+}
+
+/*************************************************************************
+|*
+|* globales Umgebungslicht lesen
+|*
+\************************************************************************/
+
+const Color B3dLightGroup::GetGlobalAmbientLight()
+{
+ return aGlobalAmbientLight;
+}
+
+/*************************************************************************
+|*
+|* Modus globaler Viewer bei Berechnung specular reflection setzen
+|*
+\************************************************************************/
+
+void B3dLightGroup::SetLocalViewer(BOOL bNew)
+{
+ if(bLocalViewer != bNew)
+ {
+ bLocalViewer = bNew;
+ }
+}
+
+/*************************************************************************
+|*
+|* Modus globaler Viewer bei Berechnung specular reflection lesen
+|*
+\************************************************************************/
+
+BOOL B3dLightGroup::GetLocalViewer()
+{
+ return bLocalViewer;
+}
+
+/*************************************************************************
+|*
+|* Modus Beleuchtungsmodell beidseitig anwenden setzen
+|*
+\************************************************************************/
+
+void B3dLightGroup::SetModelTwoSide(BOOL bNew)
+{
+ if(bModelTwoSide != bNew)
+ {
+ bModelTwoSide = bNew;
+ }
+}
+
+/*************************************************************************
+|*
+|* Modus Beleuchtungsmodell beidseitig anwenden lesen
+|*
+\************************************************************************/
+
+BOOL B3dLightGroup::GetModelTwoSide()
+{
+ return bModelTwoSide;
+}
+
+/*************************************************************************
+|*
+|* Beleuchtungsmodell aktivieren/deaktivieren
+|*
+\************************************************************************/
+
+void B3dLightGroup::EnableLighting(BOOL bNew)
+{
+ if(bLightingEnabled != bNew)
+ {
+ bLightingEnabled = bNew;
+ }
+}
+
+/*************************************************************************
+|*
+|* Abfrage, ob das Beleuchtungsmodell aktiviert/deaktiviert ist
+|*
+\************************************************************************/
+
+BOOL B3dLightGroup::IsLightingEnabled()
+{
+ return bLightingEnabled;
+}
+
+/*************************************************************************
+|*
+|* Die Intensitaet eines bestimmten Aspekts einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void B3dLightGroup::SetIntensity(const Color rNew,
+ Base3DMaterialValue eMat, Base3DLightNumber eNum)
+{
+ if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
+ {
+ aLight[eNum].SetIntensity(rNew, eMat);
+ }
+#ifdef DBG_UTIL
+ else
+ DBG_ERROR("Access to Light out of range");
+#endif
+}
+
+/*************************************************************************
+|*
+|* Die Intensitaet eines bestimmten Aspekts einer Lichtquelle lesen
+|*
+\************************************************************************/
+
+const Color B3dLightGroup::GetIntensity(Base3DMaterialValue eMat,
+ Base3DLightNumber eNum)
+{
+ if(eNum < Base3DLight0 || eNum > Base3DLight7)
+ {
+ eNum = Base3DLight0;
+#ifdef DBG_UTIL
+ DBG_ERROR("Access to Light out of range");
+#endif
+ }
+ return aLight[eNum].GetIntensity(eMat);
+}
+
+/*************************************************************************
+|*
+|* Die Position einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void B3dLightGroup::SetPosition(const Vector3D& rNew, Base3DLightNumber eNum)
+{
+ if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
+ {
+ aLight[eNum].SetPosition(rNew);
+ aLight[eNum].SetDirectionalSource(FALSE);
+ }
+#ifdef DBG_UTIL
+ else
+ DBG_ERROR("Access to Light out of range");
+#endif
+}
+
+/*************************************************************************
+|*
+|* Die Position einer Lichtquelle lesen
+|*
+\************************************************************************/
+
+const Vector3D& B3dLightGroup::GetPosition(Base3DLightNumber eNum)
+{
+ if(eNum < Base3DLight0 || eNum > Base3DLight7)
+ {
+ eNum = Base3DLight0;
+#ifdef DBG_UTIL
+ DBG_ERROR("Access to Light out of range");
+#endif
+ }
+#ifdef DBG_UTIL
+ if(IsDirectionalSource())
+ DBG_ERROR("Zugriff auf die Position einer gerichteten Lichtquelle!");
+#endif
+ return aLight[eNum].GetPosition();
+}
+
+/*************************************************************************
+|*
+|* Die Richtung einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void B3dLightGroup::SetDirection(const Vector3D& rNew, Base3DLightNumber eNum)
+{
+ if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
+ {
+ aLight[eNum].SetPosition(rNew);
+ aLight[eNum].SetDirectionalSource(TRUE);
+ }
+#ifdef DBG_UTIL
+ else
+ DBG_ERROR("Access to Light out of range");
+#endif
+}
+
+/*************************************************************************
+|*
+|* Die Richtung einer Lichtquelle lesen
+|*
+\************************************************************************/
+
+const Vector3D& B3dLightGroup::GetDirection(Base3DLightNumber eNum)
+{
+ if(eNum < Base3DLight0 || eNum > Base3DLight7)
+ {
+ eNum = Base3DLight0;
+#ifdef DBG_UTIL
+ DBG_ERROR("Access to Light out of range");
+#endif
+ }
+#ifdef DBG_UTIL
+ if(!IsDirectionalSource())
+ DBG_ERROR("Zugriff auf die Richtung einer ungerichteten Lichtquelle!");
+#endif
+ return aLight[eNum].GetPosition();
+}
+
+/*************************************************************************
+|*
+|* Die Richtung einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void B3dLightGroup::SetSpotDirection(const Vector3D& rNew, Base3DLightNumber eNum)
+{
+ if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
+ {
+ aLight[eNum].SetSpotDirection(rNew);
+ }
+#ifdef DBG_UTIL
+ else
+ DBG_ERROR("Access to Light out of range");
+#endif
+}
+
+/*************************************************************************
+|*
+|* Die Richtung einer Lichtquelle lesen
+|*
+\************************************************************************/
+
+const Vector3D& B3dLightGroup::GetSpotDirection(Base3DLightNumber eNum)
+{
+ if(eNum < Base3DLight0 || eNum > Base3DLight7)
+ {
+ eNum = Base3DLight0;
+#ifdef DBG_UTIL
+ DBG_ERROR("Access to Light out of range");
+#endif
+ }
+ return aLight[eNum].GetSpotDirection();
+}
+
+/*************************************************************************
+|*
+|* Den SpotExponent einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void B3dLightGroup::SetSpotExponent(UINT16 nNew, Base3DLightNumber eNum)
+{
+ if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
+ {
+ aLight[eNum].SetSpotExponent(nNew);
+ }
+#ifdef DBG_UTIL
+ else
+ DBG_ERROR("Access to Light out of range");
+#endif
+}
+
+/*************************************************************************
+|*
+|* Den SpotExponent einer Lichtquelle lesen
+|*
+\************************************************************************/
+
+UINT16 B3dLightGroup::GetSpotExponent(Base3DLightNumber eNum)
+{
+ if(eNum < Base3DLight0 || eNum > Base3DLight7)
+ {
+ eNum = Base3DLight0;
+#ifdef DBG_UTIL
+ DBG_ERROR("Access to Light out of range");
+#endif
+ }
+ return aLight[eNum].GetSpotExponent();
+}
+
+/*************************************************************************
+|*
+|* Die Einengung des Lichtkegels einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void B3dLightGroup::SetSpotCutoff(double fNew, Base3DLightNumber eNum)
+{
+ if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
+ {
+ aLight[eNum].SetSpotCutoff(fNew);
+ }
+#ifdef DBG_UTIL
+ else
+ DBG_ERROR("Access to Light out of range");
+#endif
+}
+
+/*************************************************************************
+|*
+|* Die Einengung des Lichtkegels einer Lichtquelle lesen
+|*
+\************************************************************************/
+
+double B3dLightGroup::GetSpotCutoff(Base3DLightNumber eNum)
+{
+ if(eNum < Base3DLight0 || eNum > Base3DLight7)
+ {
+ eNum = Base3DLight0;
+#ifdef DBG_UTIL
+ DBG_ERROR("Access to Light out of range");
+#endif
+ }
+ return aLight[eNum].GetSpotCutoff();
+}
+
+/*************************************************************************
+|*
+|* Den konstanten AttenuationFactor einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void B3dLightGroup::SetConstantAttenuation(double fNew, Base3DLightNumber eNum)
+{
+ if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
+ {
+ aLight[eNum].SetConstantAttenuation(fNew);
+ }
+#ifdef DBG_UTIL
+ else
+ DBG_ERROR("Access to Light out of range");
+#endif
+}
+
+/*************************************************************************
+|*
+|* Den konstanten AttenuationFactor einer Lichtquelle lesen
+|*
+\************************************************************************/
+
+double B3dLightGroup::GetConstantAttenuation(Base3DLightNumber eNum)
+{
+ if(eNum < Base3DLight0 || eNum > Base3DLight7)
+ {
+ eNum = Base3DLight0;
+#ifdef DBG_UTIL
+ DBG_ERROR("Access to Light out of range");
+#endif
+ }
+ return aLight[eNum].GetConstantAttenuation();
+}
+
+/*************************************************************************
+|*
+|* Den linearen AttenuationFactor einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void B3dLightGroup::SetLinearAttenuation(double fNew, Base3DLightNumber eNum)
+{
+ if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
+ {
+ aLight[eNum].SetLinearAttenuation(fNew);
+ }
+#ifdef DBG_UTIL
+ else
+ DBG_ERROR("Access to Light out of range");
+#endif
+}
+
+/*************************************************************************
+|*
+|* Den linearen AttenuationFactor einer Lichtquelle lesen
+|*
+\************************************************************************/
+
+double B3dLightGroup::GetLinearAttenuation(Base3DLightNumber eNum)
+{
+ if(eNum < Base3DLight0 || eNum > Base3DLight7)
+ {
+ eNum = Base3DLight0;
+#ifdef DBG_UTIL
+ DBG_ERROR("Access to Light out of range");
+#endif
+ }
+ return aLight[eNum].GetLinearAttenuation();
+}
+
+/*************************************************************************
+|*
+|* Den quadratischen AttenuationFactor einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void B3dLightGroup::SetQuadraticAttenuation(double fNew, Base3DLightNumber eNum)
+{
+ if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
+ {
+ aLight[eNum].SetQuadraticAttenuation(fNew);
+ }
+#ifdef DBG_UTIL
+ else
+ DBG_ERROR("Access to Light out of range");
+#endif
+}
+
+/*************************************************************************
+|*
+|* Den quadratischen AttenuationFactor einer Lichtquelle lesen
+|*
+\************************************************************************/
+
+double B3dLightGroup::GetQuadraticAttenuation(Base3DLightNumber eNum)
+{
+ if(eNum < Base3DLight0 || eNum > Base3DLight7)
+ {
+ eNum = Base3DLight0;
+#ifdef DBG_UTIL
+ DBG_ERROR("Access to Light out of range");
+#endif
+ }
+ return aLight[eNum].GetQuadraticAttenuation();
+}
+
+/*************************************************************************
+|*
+|* Eine Lichtquelle aktivieren/deaktivieren
+|*
+\************************************************************************/
+
+void B3dLightGroup::Enable(BOOL bNew, Base3DLightNumber eNum)
+{
+ if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
+ {
+ aLight[eNum].Enable(bNew);
+ }
+#ifdef DBG_UTIL
+ else
+ DBG_ERROR("Access to Light out of range");
+#endif
+}
+
+/*************************************************************************
+|*
+|* Abfrage, ob eine Lichtquelle aktiviert/deaktiviert ist
+|*
+\************************************************************************/
+
+BOOL B3dLightGroup::IsEnabled(Base3DLightNumber eNum)
+{
+ if(eNum < Base3DLight0 || eNum > Base3DLight7)
+ {
+ eNum = Base3DLight0;
+#ifdef DBG_UTIL
+ DBG_ERROR("Access to Light out of range");
+#endif
+ }
+ return aLight[eNum].IsEnabled();
+}
+
+/*************************************************************************
+|*
+|* Abfrage, ob eine Lichtquelle als directional source eingerichtet ist
+|*
+\************************************************************************/
+
+BOOL B3dLightGroup::IsDirectionalSource(Base3DLightNumber eNum)
+{
+ if(eNum < Base3DLight0 || eNum > Base3DLight7)
+ {
+ eNum = Base3DLight0;
+#ifdef DBG_UTIL
+ DBG_ERROR("Access to Light out of range");
+#endif
+ }
+ return aLight[eNum].IsDirectionalSource();
+}
+
+/*************************************************************************
+|*
+|* Direkter Zugriff auf B3dLight fuer abgeleitete Klassen
+|*
+\************************************************************************/
+
+B3dLight& B3dLightGroup::GetLightObject(Base3DLightNumber eNum)
+{
+ if(eNum < Base3DLight0 || eNum > Base3DLight7)
+ {
+ eNum = Base3DLight0;
+#ifdef DBG_UTIL
+ DBG_ERROR("Access to Light out of range");
+#endif
+ }
+ return aLight[eNum];
+}
+
+void B3dLightGroup::WriteData(SvStream& rOut) const
+{
+ for(UINT16 a=0;a<BASE3D_MAX_NUMBER_LIGHTS;a++)
+ {
+ B3dLight& rLight = ((B3dLightGroup*)(this))->GetLightObject((Base3DLightNumber)(Base3DLight0 + a));
+ rLight.WriteData(rOut);
+ }
+
+ rOut << aGlobalAmbientLight;
+
+ rOut << (BOOL)bLightingEnabled;
+ rOut << (BOOL)bLocalViewer;
+ rOut << (BOOL)bModelTwoSide;
+}
+
+void B3dLightGroup::ReadData(SvStream& rIn)
+{
+ BOOL bTmp;
+
+ for(UINT16 a=0;a<BASE3D_MAX_NUMBER_LIGHTS;a++)
+ {
+ B3dLight& rLight = GetLightObject((Base3DLightNumber)(Base3DLight0 + a));
+ rLight.ReadData(rIn);
+ }
+
+ rIn >> aGlobalAmbientLight;
+
+ rIn >> bTmp; bLightingEnabled = bTmp;
+ rIn >> bTmp; bLocalViewer = bTmp;
+ rIn >> bTmp; bModelTwoSide = bTmp;
+}
+
diff --git a/goodies/source/base3d/b3dopngl.cxx b/goodies/source/base3d/b3dopngl.cxx
new file mode 100644
index 000000000000..e5feb7f41a60
--- /dev/null
+++ b/goodies/source/base3d/b3dopngl.cxx
@@ -0,0 +1,1502 @@
+/*************************************************************************
+ *
+ * $RCSfile: b3dopngl.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _SV_OUTDEV_HXX
+#include <vcl/outdev.hxx>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#ifndef _B3D_B3DOPNGL_HXX
+#include "b3dopngl.hxx"
+#endif
+
+#ifndef _B3D_HMATRIX_HXX
+#include "hmatrix.hxx"
+#endif
+
+#ifndef _B3D_B3DTEX_HXX
+#include "b3dtex.hxx"
+#endif
+
+#ifndef _B3D_B3DTRANS_HXX
+#include "b3dtrans.hxx"
+#endif
+
+#ifndef _B3D_B3DGEOM_HXX
+#include "b3dgeom.hxx"
+#endif
+
+#ifndef _SFXINIMGR_HXX
+#include <svtools/iniman.hxx>
+#endif
+
+/*************************************************************************
+|*
+|* Konstruktor Base3DOpenGL
+|*
+\************************************************************************/
+
+Base3DOpenGL::Base3DOpenGL(OutputDevice* pOutDev)
+: Base3D(pOutDev),
+ aOpenGL(pOutDev),
+ aEmptyVector(0.0, 0.0, 0.0),
+ aLastNormal(DBL_MAX, DBL_MAX, DBL_MAX),
+ aLastTexCoor(DBL_MAX, DBL_MAX, DBL_MAX),
+ fOffFacMul100((float)(-0.2 * 100.0)),
+ fOffUniMul100((float)(-1.0 * 100.0)),
+ aPhongBuffer(12), // 4K
+ nPhongDivideSize(20),
+ bForceToSinglePrimitiveOutput(TRUE) // (#70626#)
+{
+ // create OpenGL context for pOutDev; pOutDev is NOT a printer,
+ // so don't care about printers in this place
+ if(aOpenGL.IsValid())
+ {
+ // setup default parameters
+ aOpenGL.ClearDepth( 1.0 );
+ aOpenGL.DepthFunc( GL_LEQUAL );
+ aOpenGL.Enable( GL_DEPTH_TEST );
+ aOpenGL.Enable( GL_DITHER );
+ aOpenGL.Enable( GL_NORMALIZE );
+ aOpenGL.Disable( GL_CULL_FACE );
+ aOpenGL.Disable( GL_LIGHTING );
+ aOpenGL.Disable( GL_LINE_SMOOTH );
+ aOpenGL.Disable( GL_POINT_SMOOTH );
+ aOpenGL.Disable( GL_POLYGON_SMOOTH );
+ aOpenGL.Disable( GL_POLYGON_STIPPLE );
+ aOpenGL.Disable( GL_LINE_STIPPLE );
+ aOpenGL.Disable( GL_TEXTURE_1D );
+ aOpenGL.Disable( GL_TEXTURE_2D );
+ aOpenGL.Disable( GL_BLEND );
+ aOpenGL.DepthMask( GL_TRUE );
+ aOpenGL.ShadeModel( GL_SMOOTH );
+ aOpenGL.EdgeFlag( GL_TRUE );
+ aOpenGL.Disable( GL_SCISSOR_TEST );
+ }
+ SetContextIsValid(aOpenGL.IsValid());
+ CalcInternPhongDivideSize();
+
+ // read bForceToSinglePrimitiveOutput-flag from .ini
+ String aTmp = SfxIniManager::Get()->Get(SFX_KEY_3D_OPENGL_FASTER);
+ bForceToSinglePrimitiveOutput =
+ (aTmp.Len() && aTmp.GetChar(0) == sal_Unicode('0'));
+}
+
+/*************************************************************************
+|*
+|* Typbestimmung
+|*
+\************************************************************************/
+
+UINT16 Base3DOpenGL::GetBase3DType()
+{
+ return BASE3D_TYPE_OPENGL;
+}
+
+/*************************************************************************
+|*
+|* Start der Szenenbeschreibung: Evtl. neuer HDC, Loesche Tiefenbuffer
+|*
+\************************************************************************/
+
+void Base3DOpenGL::StartScene()
+{
+ // Falls Transparenz an war, diese zuruecknehmen
+ aOpenGL.Disable( GL_BLEND );
+ aOpenGL.DepthMask( TRUE );
+
+ // OutputDevice setzen und ZBuffer loeschen
+ aOpenGL.SetConnectOutputDevice(GetOutputDevice());
+ aOpenGL.Clear( GL_DEPTH_BUFFER_BIT );
+}
+
+/*************************************************************************
+|*
+|* Scissoring Region setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetScissorRegionPixel(const Rectangle& rRect, BOOL bActivate)
+{
+ // OpenGL specifics
+ aOpenGL.Scissor( rRect.Left(), rRect.Top(),
+ rRect.GetWidth(), rRect.GetHeight());
+
+ // call parent
+ Base3D::SetScissorRegionPixel(rRect, bActivate);
+}
+
+/*************************************************************************
+|*
+|* Dithering
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetDither(BOOL bNew)
+{
+ // call parent
+ Base3D::SetDither(bNew);
+
+ // OpenGL specifics
+ if(GetDither())
+ aOpenGL.Enable( GL_DITHER );
+ else
+ aOpenGL.Disable( GL_DITHER );
+}
+
+/*************************************************************************
+|*
+|* Scissoring aktivieren/deaktivieren
+|*
+\************************************************************************/
+
+void Base3DOpenGL::ActivateScissorRegion(BOOL bNew)
+{
+ // OpenGL specifics
+ if(bNew)
+ {
+ aOpenGL.Enable(GL_SCISSOR_TEST);
+ }
+ else
+ {
+ aOpenGL.Disable(GL_SCISSOR_TEST);
+ }
+
+ // call parent
+ Base3D::ActivateScissorRegion(bNew);
+}
+
+/*************************************************************************
+|*
+|* Ende der Szenenbeschreibung: Erzwinge bisher nicht erzeugte Ausgaben
+|*
+\************************************************************************/
+
+void Base3DOpenGL::EndScene()
+{
+ aOpenGL.Flush();
+ aOpenGL.Finish();
+}
+
+/*************************************************************************
+|*
+|* Neuen freien Eintrag fuer naechste geometrische Daten liefern
+|*
+\************************************************************************/
+
+B3dEntity& Base3DOpenGL::ImplGetFreeEntity()
+{
+ return aEntity;
+}
+
+/*************************************************************************
+|*
+|* starte primitiv auch in OpenGL
+|*
+\************************************************************************/
+
+void Base3DOpenGL::ImplStartPrimitive()
+{
+ bPhongBufferedMode = (GetShadeModel() == Base3DPhong
+ && GetRenderMode() == Base3DRenderFill
+ && (GetObjectMode() == Base3DTriangles
+ || GetObjectMode() == Base3DTriangleStrip
+ || GetObjectMode() == Base3DTriangleFan
+ || GetObjectMode() == Base3DQuads
+ || GetObjectMode() == Base3DQuadStrip
+ || GetObjectMode() == Base3DPolygon ));
+
+ // Transparenz beachten
+ if(GetMaterial(Base3DMaterialDiffuse).GetTransparency())
+ {
+ aOpenGL.Enable( GL_BLEND );
+ aOpenGL.DepthMask( FALSE );
+ aOpenGL.BlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+ }
+ else
+ {
+ aOpenGL.Disable( GL_BLEND );
+ aOpenGL.DepthMask( TRUE );
+ }
+
+ if(bPhongBufferedMode)
+ {
+ // Phong-Modus: Ausgabe sammeln und in kleinere
+ // Dreiecke zerlegt bei ImplEndPrimitive() rendern
+ aPhongBuffer.Erase();
+ }
+ else
+ {
+ // OpenGL direkt benutzen
+ aOpenGL.Begin(GetObjectMode());
+ }
+}
+
+/*************************************************************************
+|*
+|* beende primitiv auch in OpenGL
+|*
+\************************************************************************/
+
+void Base3DOpenGL::ImplEndPrimitive()
+{
+ if(bPhongBufferedMode)
+ {
+ DrawPhongPrimitives();
+ }
+ else
+ {
+ aOpenGL.End();
+ }
+}
+
+/*************************************************************************
+|*
+|* Darstellungsqualitaet setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetDisplayQuality(UINT8 nNew)
+{
+ // call parent
+ Base3D::SetDisplayQuality(nNew);
+
+ // endgueltige Splittinggroesse neuberechnen
+ CalcInternPhongDivideSize();
+}
+
+/*************************************************************************
+|*
+|* PhongMode Splitting-Groesse neu setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetPhongDivideSize(long nNew)
+{
+ nPhongDivideSize = nNew;
+
+ // endgueltige Splittinggroesse neuberechnen
+ CalcInternPhongDivideSize();
+}
+
+/*************************************************************************
+|*
+|* PhongMode interne Splitting-Groesse neu setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::CalcInternPhongDivideSize()
+{
+ if(GetDisplayQuality() != 255)
+ {
+ long nNew = GetPhongDivideSize() +
+ ((255L - (INT32)GetDisplayQuality())>>2);
+ nInternPhongDivideSize = nNew * nNew;
+ }
+ else
+ nInternPhongDivideSize = GetPhongDivideSize() * GetPhongDivideSize();
+}
+
+/*************************************************************************
+|*
+|* Zeichne fuer Phong gebufferte primitive als Dreiecke
+|*
+\************************************************************************/
+
+void Base3DOpenGL::DrawPhongPrimitives()
+{
+ UINT32 aCount = aPhongBuffer.Count();
+ UINT32 aPos(0L);
+ bPhongBufferedMode = FALSE;
+ aOpenGL.Begin(Base3DTriangles);
+
+ switch(GetObjectMode())
+ {
+ case Base3DTriangles :
+ {
+ while(aPos < aCount)
+ {
+ DrawPhongTriangle(aPos, aPos+1, aPos+2);
+ aPos += 3;
+ }
+ break;
+ }
+ case Base3DTriangleStrip:
+ {
+ aPos = 1;
+ while(aPos < aCount)
+ {
+ if(aPos%2)
+ DrawPhongTriangle(aPos-1, aPos, aPos+1);
+ else
+ DrawPhongTriangle(aPos-1, aPos+1, aPos);
+ aPos++;
+ }
+ break;
+ }
+ case Base3DTriangleFan:
+ {
+ aPos = 1;
+ while(aPos < aCount)
+ {
+ DrawPhongTriangle(0, aPos, aPos+1);
+ aPos++;
+ }
+ break;
+ }
+ case Base3DQuads:
+ {
+ while(aPos < aCount)
+ {
+ DrawPhongTriangle(aPos, aPos+1, aPos+2);
+ DrawPhongTriangle(aPos+2, aPos+3, aPos);
+ aPos += 4;
+ }
+ break;
+ }
+ case Base3DQuadStrip:
+ {
+ aPos = 1;
+ while(aPos < aCount)
+ {
+ DrawPhongTriangle(aPos, aPos+1, aPos+3);
+ DrawPhongTriangle(aPos, aPos+3, aPos+2);
+ aPos+=2;
+ }
+ break;
+ }
+ case Base3DPolygon:
+ {
+ aPos = 2;
+ while(aPos < aCount)
+ {
+ DrawPhongTriangle(0, aPos-1, aPos);
+ aPos++;
+ }
+ break;
+ }
+ }
+ aOpenGL.End();
+}
+
+/*************************************************************************
+|*
+|* Zeichne fuer Phong gebufferte Dreiecke
+|*
+\************************************************************************/
+
+void Base3DOpenGL::DrawPhongTriangle(UINT32 nInd1, UINT32 nInd2, UINT32 nInd3)
+{
+ Vector3D aPos1 = GetTransformationSet()->ObjectToViewCoor(aPhongBuffer[nInd1].Point().GetVector3D());
+ double fXMin = aPos1.X();
+ double fXMax = aPos1.X();
+ double fYMin = aPos1.Y();
+ double fYMax = aPos1.Y();
+ Vector3D aPos2 = GetTransformationSet()->ObjectToViewCoor(aPhongBuffer[nInd2].Point().GetVector3D());
+ if(aPos2.X() < fXMin)
+ fXMin = aPos2.X();
+ if(aPos2.X() > fXMax)
+ fXMax = aPos2.X();
+ if(aPos2.Y() < fYMin)
+ fYMin = aPos2.Y();
+ if(aPos2.Y() > fYMax)
+ fYMax = aPos2.Y();
+ aPos2 = GetTransformationSet()->ObjectToViewCoor(aPhongBuffer[nInd3].Point().GetVector3D());
+ if(aPos2.X() < fXMin)
+ fXMin = aPos2.X();
+ if(aPos2.X() > fXMax)
+ fXMax = aPos2.X();
+ if(aPos2.Y() < fYMin)
+ fYMin = aPos2.Y();
+ if(aPos2.Y() > fYMax)
+ fYMax = aPos2.Y();
+
+ Size aPixelSize = GetOutputDevice()->LogicToPixel(
+ Size((long)(fXMax - fXMin),(long)(fYMax - fYMin)));
+ if(aPixelSize.Width() * aPixelSize.Height() > nInternPhongDivideSize)
+ {
+ UINT32 aCount = aPhongBuffer.Count();
+ aPhongBuffer.Append();
+ aPhongBuffer.Append();
+ aPhongBuffer.Append();
+
+ aPhongBuffer[aCount ].CalcMiddle(aPhongBuffer[nInd1], aPhongBuffer[nInd2]);
+ aPhongBuffer[aCount+1].CalcMiddle(aPhongBuffer[nInd2], aPhongBuffer[nInd3]);
+ aPhongBuffer[aCount+2].CalcMiddle(aPhongBuffer[nInd3], aPhongBuffer[nInd1]);
+
+ DrawPhongTriangle(nInd1, aCount, aCount+2);
+ DrawPhongTriangle(aCount, nInd2, aCount+1);
+ DrawPhongTriangle(aCount+1, nInd3, aCount+2);
+ DrawPhongTriangle(aCount, aCount+1, aCount+2);
+
+ aPhongBuffer.Remove();
+ aPhongBuffer.Remove();
+ aPhongBuffer.Remove();
+ }
+ else
+ {
+ ImplPostAddVertex(aPhongBuffer[nInd1]);
+ ImplPostAddVertex(aPhongBuffer[nInd2]);
+ ImplPostAddVertex(aPhongBuffer[nInd3]);
+ }
+}
+
+/*************************************************************************
+|*
+|* Geometrische Daten direkt an OpenGL weitergeben
+|* ACHTUNG! Es wird die aktuelle Farbe benutzt, NICHT die in Enttity3D
+|* enthaltene!
+|*
+\************************************************************************/
+
+void Base3DOpenGL::ImplPostAddVertex(B3dEntity& rEntity)
+{
+ if(bPhongBufferedMode)
+ {
+ aPhongBuffer.Append(rEntity);
+ }
+ else
+ {
+ // Normale setzen
+ if(rEntity.IsNormalUsed())
+ {
+ if(GetForceFlat() || GetShadeModel() == Base3DFlat)
+ {
+ if(rEntity.PlaneNormal() != aLastNormal)
+ {
+ aLastNormal = rEntity.PlaneNormal();
+ aOpenGL.Normal3dv(&aLastNormal.X());
+ }
+ }
+ else
+ {
+ if(rEntity.Normal() != aLastNormal)
+ {
+ aLastNormal = rEntity.Normal();
+ aOpenGL.Normal3dv(&aLastNormal.X());
+ }
+ }
+ }
+ else
+ {
+ if(aLastNormal != aEmptyVector)
+ {
+ aLastNormal = aEmptyVector;
+ aOpenGL.Normal3dv(&aLastNormal.X());
+ }
+ }
+
+ // Texturkoordinate setzen
+ if(rEntity.IsTexCoorUsed())
+ {
+ if(rEntity.TexCoor() != aLastTexCoor)
+ {
+ aLastTexCoor = rEntity.TexCoor();
+ aOpenGL.TexCoord3dv(&aLastTexCoor.X());
+ }
+ }
+ else
+ {
+ if(aLastTexCoor != aEmptyVector)
+ {
+ aLastTexCoor = aEmptyVector;
+ aOpenGL.TexCoord3dv(&aLastTexCoor.X());
+ }
+ }
+
+ // Punkt erzeugen
+ aOpenGL.Vertex3dv(&rEntity.Point().X());
+ }
+}
+
+/*************************************************************************
+|*
+|* beim setzen von color und alpha reagieren
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetColor(Color aNew)
+{
+ // call parent
+ Base3D::SetColor(aNew);
+
+ // Normale Farbausgabe
+ aOpenGL.Color4ub(GetColor().GetRed(), GetColor().GetGreen(),
+ GetColor().GetBlue(), 0xff - GetColor().GetTransparency());
+}
+
+/*************************************************************************
+|*
+|* Materialeigenschaften setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetMaterial(Color rNew, Base3DMaterialValue eVal,
+ Base3DMaterialMode eMode)
+{
+ // call parent
+ Base3D::SetMaterial(rNew, eVal, eMode);
+
+ // OpenGL Specifics
+ GLenum eFace = GL_FRONT_AND_BACK;
+ if(eMode == Base3DMaterialFront)
+ eFace = GL_FRONT;
+ if(eMode == Base3DMaterialBack)
+ eFace = GL_BACK;
+ GLenum eName = GL_SPECULAR;
+ if(eVal == Base3DMaterialAmbient)
+ eName = GL_AMBIENT;
+ if(eVal == Base3DMaterialDiffuse)
+ eName = GL_DIFFUSE;
+ if(eVal == Base3DMaterialEmission)
+ eName = GL_EMISSION;
+
+ // Array fuellen
+ float fArray[4] = {
+ ((float)GetMaterial(eVal, eMode).GetRed()) / (float)255.0,
+ ((float)GetMaterial(eVal, eMode).GetGreen()) / (float)255.0,
+ ((float)GetMaterial(eVal, eMode).GetBlue()) / (float)255.0,
+ ((float)(255 - GetMaterial(eVal, eMode).GetTransparency())) / (float)255.0
+ };
+
+ aOpenGL.Materialfv(eFace, eName, fArray);
+}
+
+/*************************************************************************
+|*
+|* Materialeigenschaften setzen, exponent der specular-Eigenschaft
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetShininess(UINT16 nExponent,
+ Base3DMaterialMode eMode)
+{
+ // call parent
+ Base3D::SetShininess(nExponent, eMode);
+
+ // OpenGL Specifics
+ GLenum eFace = GL_FRONT_AND_BACK;
+ if(eMode == Base3DMaterialFront)
+ eFace = GL_FRONT;
+ if(eMode == Base3DMaterialBack)
+ eFace = GL_BACK;
+ aOpenGL.Materialf(eFace, GL_SHININESS, (float)nExponent);
+}
+
+/*************************************************************************
+|*
+|* Aktuell zu benutzende Textur setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetActiveTexture(B3dTexture* pTex)
+{
+ // call parent
+ Base3D::SetActiveTexture(pTex);
+
+ // make current texture, cast ist unkritisch, da innerhalb von
+ // Base3DOpenGL nur Texturen von diesem Typ angelegt worden
+ // sein koennen
+ if(GetActiveTexture())
+ {
+ aOpenGL.Enable(GL_TEXTURE_2D);
+ ((B3dTextureOpenGL*)GetActiveTexture())->MakeCurrentTexture(aOpenGL);
+ }
+ else
+ {
+ aOpenGL.BindTexture(GL_TEXTURE_2D, 0);
+ aOpenGL.Disable(GL_TEXTURE_2D);
+ }
+}
+
+/*************************************************************************
+|*
+|* Ein Textur-Objekt inkarnieren
+|*
+\************************************************************************/
+
+B3dTexture* Base3DOpenGL::CreateTexture(TextureAttributes& rAtt, Bitmap& rBitmap)
+{
+ // Hier Parent NICHT rufen! Sonst wird auch noch eine normale Textur erzeugt
+ B3dTextureOpenGL* pRetval = new B3dTextureOpenGL(rAtt, rBitmap, aOpenGL);
+ DBG_ASSERT(pRetval,"AW: Kein Speicher fuer OpenGL-Textur bekommen!");
+ return pRetval;
+}
+
+/*************************************************************************
+|*
+|* OpenGL - Textur loeschen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::DestroyTexture(B3dTexture* pTex)
+{
+ // Spezielle Loeschaufgaben im Zusammenhang mit OpenGL
+ ((B3dTextureOpenGL*)pTex)->DestroyOpenGLTexture(aOpenGL);
+
+ // call parent, endgueltig loeschen
+ Base3D::DestroyTexture(pTex);
+}
+
+/*************************************************************************
+|*
+|* PolygonOffset setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetPolygonOffset(Base3DPolygonOffset eNew, BOOL bNew)
+{
+ // call parent
+ Base3D::SetPolygonOffset(eNew, bNew);
+
+ if(GetPolygonOffset())
+ aOpenGL.PolygonOffset((float)(fOffFacMul100 / 100.0), (float)(fOffUniMul100 / 100.0));
+ else
+ aOpenGL.PolygonOffset((float)0.0, (float)0.0);
+
+ // OpenGL Specifics
+ switch(eNew)
+ {
+ case Base3DPolygonOffsetFill :
+ if(bNew)
+ aOpenGL.Enable( GL_POLYGON_OFFSET_FILL );
+ else
+ aOpenGL.Disable( GL_POLYGON_OFFSET_FILL );
+ break;
+
+ case Base3DPolygonOffsetLine :
+ if(bNew)
+ aOpenGL.Enable( GL_POLYGON_OFFSET_LINE );
+ else
+ aOpenGL.Disable( GL_POLYGON_OFFSET_LINE );
+ break;
+
+ case Base3DPolygonOffsetPoint :
+ if(bNew)
+ aOpenGL.Enable( GL_POLYGON_OFFSET_POINT );
+ else
+ aOpenGL.Disable( GL_POLYGON_OFFSET_POINT );
+ break;
+ }
+}
+
+/*************************************************************************
+|*
+|* Beleuchtung setzen/lesen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetLightGroup(B3dLightGroup* pSet, BOOL bSetGlobal)
+{
+ // call parent
+ Base3D::SetLightGroup(pSet, bSetGlobal);
+
+ if(GetLightGroup())
+ {
+ // Allgemeine Parameter setzen
+ SetGlobalAmbientLight(GetLightGroup()->GetGlobalAmbientLight());
+ SetLocalViewer(GetLightGroup()->GetLocalViewer());
+ SetModelTwoSide(GetLightGroup()->GetModelTwoSide());
+ EnableLighting(GetLightGroup()->IsLightingEnabled());
+
+ // Einzelne Lampen setzen
+ if(GetTransformationSet() && bSetGlobal)
+ {
+ aOpenGL.MatrixMode(GL_MODELVIEW);
+ aOpenGL.LoadIdentity();
+ }
+
+ // Set and enable lights from the beginning of array in
+ // OpenGL
+ UINT16 nNumAlloc = 0;
+
+ UINT16 a;
+ for(a=0;a<BASE3D_MAX_NUMBER_LIGHTS;a++)
+ {
+ Base3DLightNumber eNum = (Base3DLightNumber)(Base3DLight0 + a);
+ B3dLight& rLight = GetLightGroup()->GetLightObject(eNum);
+
+ if(rLight.IsEnabled())
+ {
+ Base3DLightNumber eNumAlloc = (Base3DLightNumber)(Base3DLight0 + nNumAlloc);
+ nNumAlloc++;
+
+ Enable(TRUE, eNumAlloc);
+
+ SetIntensity(rLight.GetIntensity(Base3DMaterialAmbient),
+ Base3DMaterialAmbient, eNumAlloc);
+ SetIntensity(rLight.GetIntensity(Base3DMaterialDiffuse),
+ Base3DMaterialDiffuse, eNumAlloc);
+ SetIntensity(rLight.GetIntensity(Base3DMaterialSpecular),
+ Base3DMaterialSpecular, eNumAlloc);
+
+ if(rLight.IsDirectionalSource())
+ {
+ SetDirection(rLight.GetPosition(), eNumAlloc);
+ }
+ else
+ {
+ SetPosition(rLight.GetPosition(), eNumAlloc);
+ SetSpotDirection(rLight.GetSpotDirection(), eNumAlloc);
+ SetSpotExponent(rLight.GetSpotExponent(), eNumAlloc);
+ SetSpotCutoff(rLight.GetSpotCutoff(), eNumAlloc);
+ }
+
+ SetConstantAttenuation(rLight.GetConstantAttenuation(), eNumAlloc);
+ SetLinearAttenuation(rLight.GetLinearAttenuation(), eNumAlloc);
+ SetQuadraticAttenuation(rLight.GetQuadraticAttenuation(), eNumAlloc);
+ }
+ }
+
+ for(a=nNumAlloc;a<BASE3D_MAX_NUMBER_LIGHTS;a++)
+ {
+ Base3DLightNumber eNum = (Base3DLightNumber)(Base3DLight0 + a);
+ Enable(FALSE, eNum);
+ }
+
+ if(GetTransformationSet() && bSetGlobal)
+ PostSetObjectOrientation(GetTransformationSet());
+ }
+}
+
+/*************************************************************************
+|*
+|* globales Umgebungslicht setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetGlobalAmbientLight(const Color rNew)
+{
+ // OpenGL Specifics
+ Color aSource;
+ if(GetOutputDevice()->GetDrawMode() & DRAWMODE_GRAYFILL)
+ {
+ // Graustufen
+ UINT8 nLuminance = rNew.GetLuminance();
+ aSource.SetRed(nLuminance);
+ aSource.SetGreen(nLuminance);
+ aSource.SetBlue(nLuminance);
+ aSource.SetTransparency(rNew.GetTransparency());
+ }
+ else if(GetOutputDevice()->GetDrawMode() & DRAWMODE_WHITEFILL)
+ {
+ // Keine Ausgabe, hier Weiss als Farbe setzen
+ aSource = Color(COL_WHITE);
+ }
+ else
+ {
+ // Normale Farbausgabe
+ aSource = rNew;
+ }
+
+ // Array fuellen
+ float fArray[4] = {
+ ((float)aSource.GetRed()) / (float)255.0,
+ ((float)aSource.GetGreen()) / (float)255.0,
+ ((float)aSource.GetBlue()) / (float)255.0,
+ ((float)aSource.GetTransparency()) / (float)255.0
+ };
+ aOpenGL.LightModelfv(GL_LIGHT_MODEL_AMBIENT, fArray);
+}
+
+/*************************************************************************
+|*
+|* Modus globaler Viewer bei Berechnung specular reflection setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetLocalViewer(BOOL bNew)
+{
+ // OpenGL Specifics
+ aOpenGL.LightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER,
+ bNew ? (float)0.0 : (float)1.0);
+}
+
+/*************************************************************************
+|*
+|* Modus Beleuchtungsmodell beidseitig anwenden setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetModelTwoSide(BOOL bNew)
+{
+ // OpenGL Specifics
+ aOpenGL.LightModelf(GL_LIGHT_MODEL_TWO_SIDE,
+ bNew ? (float)1.0 : (float)0.0);
+}
+
+/*************************************************************************
+|*
+|* Beleuchtungsmodell aktivieren/deaktivieren
+|*
+\************************************************************************/
+
+void Base3DOpenGL::EnableLighting(BOOL bNew)
+{
+ // OpenGL Specifics
+ if(bNew)
+ aOpenGL.Enable( GL_LIGHTING );
+ else
+ aOpenGL.Disable( GL_LIGHTING );
+}
+
+/*************************************************************************
+|*
+|* Die Intensitaet eines bestimmten Aspekts einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetIntensity(const Color rNew,
+ Base3DMaterialValue eVal, Base3DLightNumber eNum)
+{
+ // OpenGL Specifics
+ Color aSource;
+ if(GetOutputDevice()->GetDrawMode() & DRAWMODE_GRAYFILL)
+ {
+ // Graustufen
+ UINT8 nLuminance = rNew.GetLuminance();
+ aSource.SetRed(nLuminance);
+ aSource.SetGreen(nLuminance);
+ aSource.SetBlue(nLuminance);
+ aSource.SetTransparency(rNew.GetTransparency());
+ }
+ else if(GetOutputDevice()->GetDrawMode() & DRAWMODE_WHITEFILL)
+ {
+ // Keine Ausgabe, hier Weiss als Farbe setzen
+ aSource = Color(COL_WHITE);
+ }
+ else
+ {
+ // Normale Farbausgabe
+ aSource = rNew;
+ }
+
+ // Array fuellen
+ float fArray[4] = {
+ ((float)aSource.GetRed()) / (float)255.0,
+ ((float)aSource.GetGreen()) / (float)255.0,
+ ((float)aSource.GetBlue()) / (float)255.0,
+ ((float)aSource.GetTransparency()) / (float)255.0
+ };
+
+ GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
+ GLenum eName = GL_SPECULAR;
+ if(eVal == Base3DMaterialAmbient)
+ eName = GL_AMBIENT;
+ if(eVal == Base3DMaterialDiffuse)
+ eName = GL_DIFFUSE;
+ aOpenGL.Lightfv(eLight, eName, fArray);
+}
+
+/*************************************************************************
+|*
+|* Die Position einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetPosition(const Vector3D& rNew, Base3DLightNumber eNum)
+{
+ // OpenGL Specifics
+ GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
+ float fArray[4] = {
+ (float)rNew[0], (float)rNew[1], (float)rNew[2], (float)1.0
+ };
+ aOpenGL.Lightfv(eLight, GL_POSITION, fArray);
+}
+
+/*************************************************************************
+|*
+|* Die Richtung einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetDirection(const Vector3D& rNew, Base3DLightNumber eNum)
+{
+ // OpenGL Specifics
+ GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
+ float fArray[4] = {
+ (float)rNew[0], (float)rNew[1], (float)rNew[2], (float)0.0
+ };
+ aOpenGL.Lightfv(eLight, GL_POSITION, fArray);
+}
+
+/*************************************************************************
+|*
+|* Die Richtung einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetSpotDirection(const Vector3D& rNew,
+ Base3DLightNumber eNum)
+{
+ // OpenGL Specifics
+ GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
+ float fArray[4] = {
+ (float)rNew[0], (float)rNew[1], (float)rNew[2], (float)0.0
+ };
+ aOpenGL.Lightfv(eLight, GL_SPOT_DIRECTION, fArray);
+}
+
+/*************************************************************************
+|*
+|* Den SpotExponent einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetSpotExponent(UINT16 nNew, Base3DLightNumber eNum)
+{
+ // OpenGL Specifics
+ GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
+ aOpenGL.Lightf(eLight, GL_SPOT_EXPONENT, (float)nNew);
+}
+
+/*************************************************************************
+|*
+|* Die Einengung des Lichtkegels einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetSpotCutoff(double fNew, Base3DLightNumber eNum)
+{
+ // OpenGL Specifics
+ GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
+ aOpenGL.Lightf(eLight, GL_SPOT_CUTOFF, (float)fNew);
+}
+
+/*************************************************************************
+|*
+|* Den konstanten AttenuationFactor einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetConstantAttenuation(double fNew,
+ Base3DLightNumber eNum)
+{
+ // OpenGL Specifics
+ GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
+ aOpenGL.Lightf(eLight, GL_CONSTANT_ATTENUATION, (float)fNew);
+}
+
+/*************************************************************************
+|*
+|* Den linearen AttenuationFactor einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetLinearAttenuation(double fNew,
+ Base3DLightNumber eNum)
+{
+ // OpenGL Specifics
+ GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
+ aOpenGL.Lightf(eLight, GL_LINEAR_ATTENUATION, (float)fNew);
+}
+
+/*************************************************************************
+|*
+|* Den quadratischen AttenuationFactor einer Lichtquelle setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetQuadraticAttenuation(double fNew,
+ Base3DLightNumber eNum)
+{
+ // OpenGL Specifics
+ GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
+ aOpenGL.Lightf(eLight, GL_QUADRATIC_ATTENUATION, (float)fNew);
+}
+
+/*************************************************************************
+|*
+|* Eine Lichtquelle aktivieren/deaktivieren
+|*
+\************************************************************************/
+
+void Base3DOpenGL::Enable(BOOL bNew, Base3DLightNumber eNum)
+{
+ // OpenGL Specifics
+ GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
+ if(bNew)
+ aOpenGL.Enable(eLight);
+ else
+ aOpenGL.Disable(eLight);
+}
+
+/*************************************************************************
+|*
+|* RenderMode setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetRenderMode(Base3DRenderMode eNew,
+ Base3DMaterialMode eMode)
+{
+ // call parent
+ Base3D::SetRenderMode(eNew, eMode);
+
+ // OpenGL Specifics
+ GLenum eFace = GL_FRONT_AND_BACK;
+ if(eMode == Base3DMaterialFront)
+ eFace = GL_FRONT;
+ if(eMode == Base3DMaterialBack)
+ eFace = GL_BACK;
+
+ switch(eNew)
+ {
+ case Base3DRenderNone :
+ {
+ break;
+ }
+ case Base3DRenderPoint :
+ {
+ aOpenGL.PolygonMode(eFace, GL_POINT);
+ break;
+ }
+ case Base3DRenderLine :
+ {
+ aOpenGL.PolygonMode(eFace, GL_LINE);
+ break;
+ }
+ case Base3DRenderFill :
+ {
+ aOpenGL.PolygonMode(eFace, GL_FILL);
+ break;
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* ShadeModel setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetShadeModel(Base3DShadeModel eNew)
+{
+ // call parent
+ Base3D::SetShadeModel(eNew);
+
+ switch(eNew)
+ {
+ case Base3DSmooth :
+ case Base3DPhong :
+ {
+ aOpenGL.ShadeModel(GL_SMOOTH);
+ break;
+ }
+ case Base3DFlat :
+ {
+ aOpenGL.ShadeModel(GL_FLAT);
+ break;
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* CullingMode setzen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetCullMode(Base3DCullMode eNew)
+{
+ // call parent
+ Base3D::SetCullMode(eNew);
+
+ switch(eNew)
+ {
+ case Base3DCullFront :
+ {
+ aOpenGL.CullFace(GL_FRONT);
+ aOpenGL.Enable(GL_CULL_FACE);
+ break;
+ }
+ case Base3DCullBack :
+ {
+ aOpenGL.CullFace(GL_BACK);
+ aOpenGL.Enable(GL_CULL_FACE);
+ break;
+ }
+ case Base3DCullNone :
+ {
+ aOpenGL.Disable(GL_CULL_FACE);
+ break;
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* EdgeFlag schreiben
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetEdgeFlag(BOOL bNew)
+{
+ // EdgeFlag fuer OpenGL setzen
+ if(bNew)
+ aOpenGL.EdgeFlag(GL_TRUE);
+ else
+ aOpenGL.EdgeFlag(GL_FALSE);
+
+ // call parent
+ Base3D::SetEdgeFlag(bNew);
+}
+
+/*************************************************************************
+|*
+|* PointSize schreiben
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetPointSize(double fNew)
+{
+ // PointSize fuer OpenGL setzen
+ aOpenGL.PointSize((GLfloat)fNew);
+
+ // call parent
+ Base3D::SetPointSize(fNew);
+}
+
+/*************************************************************************
+|*
+|* LineWidth schreiben
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetLineWidth(double fNew)
+{
+ // LineWidth fuer OpenGL setzen
+ aOpenGL.LineWidth((GLfloat)fNew);
+
+ // call parent
+ Base3D::SetLineWidth(fNew);
+}
+
+/*************************************************************************
+|*
+|* Callbacks bei Matrixaenderungen, Default-Implementierungen
+|*
+\************************************************************************/
+
+void Base3DOpenGL::SetTransformationSet(B3dTransformationSet* pSet)
+{
+ // call parent
+ Base3D::SetTransformationSet(pSet);
+
+ if(GetTransformationSet())
+ {
+ PostSetObjectOrientation(GetTransformationSet());
+ PostSetProjection(GetTransformationSet());
+ PostSetTexture(GetTransformationSet());
+ PostSetViewport(GetTransformationSet());
+ }
+}
+
+void Base3DOpenGL::PostSetObjectOrientation(B3dTransformationSet* pCaller)
+{
+ // OpenGL specifics
+ Matrix4D aMat = pCaller->GetObjectTrans();
+ aMat *= pCaller->GetOrientation();
+ double fBuffer[16] = {
+ aMat[0][0], aMat[1][0], aMat[2][0], aMat[3][0],
+ aMat[0][1], aMat[1][1], aMat[2][1], aMat[3][1],
+ aMat[0][2], aMat[1][2], aMat[2][2], aMat[3][2],
+ aMat[0][3], aMat[1][3], aMat[2][3], aMat[3][3]
+ };
+ aOpenGL.MatrixMode(GL_MODELVIEW);
+ aOpenGL.LoadMatrixd(fBuffer);
+}
+
+void Base3DOpenGL::PostSetProjection(B3dTransformationSet* pCaller)
+{
+ // OpenGL specifics
+ const Matrix4D& rMat = pCaller->GetProjection();
+ double fBuffer[16] = {
+ rMat[0][0], rMat[1][0], rMat[2][0], rMat[3][0],
+ rMat[0][1], rMat[1][1], rMat[2][1], rMat[3][1],
+ rMat[0][2], rMat[1][2], rMat[2][2], rMat[3][2],
+ rMat[0][3], rMat[1][3], rMat[2][3], rMat[3][3]
+ };
+ aOpenGL.MatrixMode(GL_PROJECTION);
+ aOpenGL.LoadMatrixd(fBuffer);
+}
+
+void Base3DOpenGL::PostSetTexture(B3dTransformationSet* pCaller)
+{
+ // OpenGL specifics
+ const Matrix4D& rMat = pCaller->GetTexture();
+ double fBuffer[16] = {
+ rMat[0][0], rMat[1][0], rMat[2][0], rMat[3][0],
+ rMat[0][1], rMat[1][1], rMat[2][1], rMat[3][1],
+ rMat[0][2], rMat[1][2], rMat[2][2], rMat[3][2],
+ rMat[0][3], rMat[1][3], rMat[2][3], rMat[3][3]
+ };
+ aOpenGL.MatrixMode(GL_TEXTURE);
+ aOpenGL.LoadMatrixd(fBuffer);
+}
+
+void Base3DOpenGL::PostSetViewport(B3dTransformationSet* pCaller)
+{
+ // OpenGL specifics
+ Rectangle aBoundPixel(GetOutputDevice()->
+ LogicToPixel(pCaller->GetLogicalViewportBounds()));
+ aOpenGL.Viewport( aBoundPixel.Left(), aBoundPixel.Top(),
+ aBoundPixel.GetWidth() - 1, aBoundPixel.GetHeight() - 1);
+}
+
+/*************************************************************************
+|*
+|* Ein Objekt in Form einer B3dGeometry direkt ausgeben
+|*
+\************************************************************************/
+
+void Base3DOpenGL::DrawPolygonGeometry(B3dGeometry& rGeometry, BOOL bOutline)
+{
+ // bForceToSinglePrimitiveOutput: (#70626#)
+ if(bForceToSinglePrimitiveOutput || (GetShadeModel() == Base3DPhong && GetRenderMode() == Base3DRenderFill))
+ {
+ // call parent, render with many primitives
+ Base3D::DrawPolygonGeometry(rGeometry, bOutline);
+ }
+ else
+ {
+ // Buckets der Geometrie holen
+ B3dEntityBucket& rEntityBucket = rGeometry.GetEntityBucket();
+ GeometryIndexValueBucket& rIndexBucket = rGeometry.GetIndexBucket();
+
+ if(rEntityBucket.Count() && rIndexBucket.Count())
+ {
+ // Arrays aktivieren
+ aOpenGL.EnableClientState(GL_VERTEX_ARRAY);
+
+ UINT32 nPolyCounter = 0;
+ UINT32 nEntityCounter = 0;
+ UINT32 nArrayStartIndex = 0;
+ UINT32 nUpperBound;
+
+ // Pointer setzen
+ UINT16 nArray = 0;
+ aOpenGL.VertexPointer(3, GL_DOUBLE, rEntityBucket.GetSlotSize(), &rEntityBucket[0].Point());
+
+ if(bOutline)
+ {
+ // Transparenz Linien beachten
+ if(GetColor().GetTransparency())
+ {
+ aOpenGL.Enable( GL_BLEND );
+ aOpenGL.DepthMask( FALSE );
+ aOpenGL.BlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+ }
+ else
+ {
+ aOpenGL.Disable( GL_BLEND );
+ aOpenGL.DepthMask( TRUE );
+ }
+
+ // ALLE Linien Zeichnen
+ aOpenGL.Disable(GL_CULL_FACE);
+
+ // Polygone als Outline ausgeben
+ aOpenGL.PolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ aOpenGL.PolygonOffset((float)(fOffFacMul100 / 100.0), (float)(fOffUniMul100 / 100.0));
+ aOpenGL.Enable( GL_POLYGON_OFFSET_LINE );
+ aOpenGL.EnableClientState(GL_EDGE_FLAG_ARRAY);
+ aOpenGL.EdgeFlagPointer(rEntityBucket.GetSlotSize(), &rEntityBucket[0].EdgeFlag());
+
+ while(nPolyCounter < rIndexBucket.Count())
+ {
+ // Naechstes Primitiv
+ nUpperBound = rIndexBucket[nPolyCounter].GetIndex();
+ BOOL bLineMode = (rIndexBucket[nPolyCounter++].GetMode() == B3D_INDEX_MODE_LINE);
+
+ if(nUpperBound >> rEntityBucket.GetBlockShift() != nArray)
+ {
+ // Einzelschritt, Bereichsueberschreitung im Buffer
+ // Als Polygon ausgeben
+ aOpenGL.Begin(bLineMode ? Base3DLineStrip : Base3DPolygon);
+
+ // Polygon ausgeben
+ while(nEntityCounter < nUpperBound)
+ {
+ B3dEntity& rEntity = rEntityBucket[nEntityCounter++];
+ aOpenGL.EdgeFlag(rEntity.IsEdgeVisible() ? GL_TRUE : GL_FALSE);
+ aOpenGL.Vertex3dv((const double *)(&rEntity.Point()));
+ }
+
+ // Primitiv abschliessen
+ aOpenGL.End();
+
+ // NUR auf neues Array setzen, wenn noch was da ist (#59941#)
+ if(nEntityCounter < rEntityBucket.Count())
+ {
+ // Pointer auf neues Array setzen
+ nArray = (UINT16)(nEntityCounter >> rEntityBucket.GetBlockShift());
+ nArrayStartIndex = nEntityCounter;
+ B3dEntity& rStart = rEntityBucket[nEntityCounter];
+
+ aOpenGL.VertexPointer(3, GL_DOUBLE, rEntityBucket.GetSlotSize(), &rStart);
+ aOpenGL.EdgeFlagPointer(rEntityBucket.GetSlotSize(), &(rStart.EdgeFlag()));
+ }
+ }
+ else
+ {
+ // Primitiv komplett raushauen, liegt in einem Buffer
+ aOpenGL.DrawArrays(bLineMode ? Base3DLineStrip : Base3DPolygon,
+ nEntityCounter - nArrayStartIndex,
+ nUpperBound - nEntityCounter);
+ nEntityCounter = nUpperBound;
+ }
+ }
+
+ // Arrays deaktivieren
+ aOpenGL.DisableClientState(GL_VERTEX_ARRAY);
+ aOpenGL.DisableClientState(GL_EDGE_FLAG_ARRAY);
+ }
+ else
+ {
+ // Transparenz Flaechen beachten
+ if(GetMaterial(Base3DMaterialDiffuse).GetTransparency())
+ {
+ aOpenGL.Enable( GL_BLEND );
+ aOpenGL.DepthMask( FALSE );
+ aOpenGL.BlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+ }
+ else
+ {
+ aOpenGL.Disable( GL_BLEND );
+ aOpenGL.DepthMask( TRUE );
+ }
+
+ // Polygone gefuellt ausgeben
+ aOpenGL.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ aOpenGL.EnableClientState(GL_NORMAL_ARRAY);
+ aOpenGL.EnableClientState(GL_TEXTURE_COORD_ARRAY);
+ if(GetForceFlat() || GetShadeModel() == Base3DFlat)
+ aOpenGL.NormalPointer(GL_DOUBLE, rEntityBucket.GetSlotSize(), &rEntityBucket[0].PlaneNormal());
+ else
+ aOpenGL.NormalPointer(GL_DOUBLE, rEntityBucket.GetSlotSize(), &rEntityBucket[0].Normal());
+ aOpenGL.TexCoordPointer(2, GL_DOUBLE, rEntityBucket.GetSlotSize(), &rEntityBucket[0].TexCoor());
+
+ while(nPolyCounter < rIndexBucket.Count())
+ {
+ // Naechstes Primitiv
+ nUpperBound = rIndexBucket[nPolyCounter].GetIndex();
+ BOOL bLineMode = (rIndexBucket[nPolyCounter++].GetMode() == B3D_INDEX_MODE_LINE);
+
+ if(nUpperBound >> rEntityBucket.GetBlockShift() != nArray)
+ {
+ // Einzelschritt, Bereichsueberschreitung im Buffer
+ // Als Polygon ausgeben
+ aOpenGL.Begin(bLineMode ? Base3DLineStrip : Base3DPolygon);
+
+ // Polygon ausgeben
+ while(nEntityCounter < nUpperBound)
+ {
+ B3dEntity& rEntity = rEntityBucket[nEntityCounter++];
+ if(GetForceFlat() || GetShadeModel() == Base3DFlat)
+ aOpenGL.Normal3dv((const double *)(&rEntity.PlaneNormal()));
+ else
+ aOpenGL.Normal3dv((const double *)(&rEntity.Normal()));
+ aOpenGL.TexCoord3dv((const double *)(&rEntity.TexCoor()));
+ aOpenGL.Vertex3dv((const double *)(&rEntity.Point()));
+ }
+
+ // Primitiv abschliessen
+ aOpenGL.End();
+
+ // NUR auf neues Array setzen, wenn noch was da ist (#58702#)
+ if(nEntityCounter < rEntityBucket.Count())
+ {
+ // Pointer auf neues Array setzen
+ nArray = (UINT16)(nEntityCounter >> rEntityBucket.GetBlockShift());
+ nArrayStartIndex = nEntityCounter;
+ B3dEntity& rStart = rEntityBucket[nEntityCounter];
+
+ aOpenGL.VertexPointer(3, GL_DOUBLE, rEntityBucket.GetSlotSize(), &rStart);
+ if(GetForceFlat() || GetShadeModel() == Base3DFlat)
+ aOpenGL.NormalPointer(GL_DOUBLE, rEntityBucket.GetSlotSize(), &(rStart.PlaneNormal()));
+ else
+ aOpenGL.NormalPointer(GL_DOUBLE, rEntityBucket.GetSlotSize(), &(rStart.Normal()));
+ aOpenGL.TexCoordPointer(2, GL_DOUBLE, rEntityBucket.GetSlotSize(), &(rStart.TexCoor()));
+ }
+ }
+ else
+ {
+ // Primitiv komplett raushauen, liegt in einem Buffer
+ aOpenGL.DrawArrays(bLineMode ? Base3DLineStrip : Base3DPolygon,
+ nEntityCounter - nArrayStartIndex,
+ nUpperBound - nEntityCounter);
+ nEntityCounter = nUpperBound;
+ }
+ }
+
+ // Arrays deaktivieren
+ aOpenGL.DisableClientState(GL_VERTEX_ARRAY);
+ aOpenGL.DisableClientState(GL_NORMAL_ARRAY);
+ aOpenGL.DisableClientState(GL_TEXTURE_COORD_ARRAY);
+ }
+ }
+ }
+}
+
diff --git a/goodies/source/base3d/b3dopngl.hxx b/goodies/source/base3d/b3dopngl.hxx
new file mode 100644
index 000000000000..910cb49caa0a
--- /dev/null
+++ b/goodies/source/base3d/b3dopngl.hxx
@@ -0,0 +1,223 @@
+/*************************************************************************
+ *
+ * $RCSfile: b3dopngl.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _B3D_B3DOPNGL_HXX
+#define _B3D_B3DOPNGL_HXX
+
+#ifndef _B3D_BASE3D_HXX
+#include "base3d.hxx"
+#endif
+
+#ifndef _SV_OPENGL_HXX
+#include <vcl/opengl.hxx>
+#endif
+
+/*************************************************************************
+|*
+|* Die Basisklasse fuer Standard 3D Ausgaben mittels OpenGL unter
+|* Windows (Win95 und Windows NT)
+|*
+\************************************************************************/
+
+class Base3DOpenGL : public Base3D
+{
+private:
+ // Datenuebergabe
+ B3dEntity aEntity;
+
+ // OpenGL Objekt
+ OpenGL aOpenGL;
+
+ // Letzte Normale und letzte Texturkoordinate
+ Vector3D aLastNormal;
+ Vector3D aLastTexCoor;
+ Vector3D aEmptyVector;
+
+ float fOffFacMul100;
+ float fOffUniMul100;
+
+ // Simulation Phong-Mode
+ BOOL bPhongBufferedMode;
+ B3dEntityBucket aPhongBuffer;
+ long nPhongDivideSize;
+ long nInternPhongDivideSize;
+
+ // flags (#70626#)
+ BOOL bForceToSinglePrimitiveOutput;
+
+ void DrawPhongPrimitives();
+ void DrawPhongTriangle(UINT32 nInd1, UINT32 nInd2, UINT32 nInd3);
+ void CalcInternPhongDivideSize();
+
+public:
+ Base3DOpenGL(OutputDevice* pOutDev);
+
+ // DivideSize bei Phong-Simulation
+ long GetPhongDivideSize() { return nPhongDivideSize; }
+ void SetPhongDivideSize(long nNew);
+
+ // Get/Set force to single primitive output (#70626#)
+ BOOL IsForceToSinglePrimitiveOutput() const { return bForceToSinglePrimitiveOutput; }
+ void SetForceToSinglePrimitiveOutput(BOOL bNew) { bForceToSinglePrimitiveOutput = bNew; }
+
+ // Typbestimmung
+ virtual UINT16 GetBase3DType();
+
+ virtual void StartScene();
+ virtual void EndScene();
+
+ // Scissoring
+ virtual void SetScissorRegionPixel(const Rectangle& rRect, BOOL bActivate=TRUE);
+ virtual void ActivateScissorRegion(BOOL bNew);
+
+ // Dithering
+ virtual void SetDither(BOOL bNew);
+
+ // Farbe
+ virtual void SetColor(Color aNew);
+
+ // Material
+ virtual void SetMaterial(Color rNew,
+ Base3DMaterialValue=Base3DMaterialAmbient,
+ Base3DMaterialMode=Base3DMaterialFrontAndBack);
+ virtual void SetShininess(UINT16 nExponent,
+ Base3DMaterialMode=Base3DMaterialFrontAndBack);
+
+ // Texturen
+private:
+ virtual B3dTexture* CreateTexture(TextureAttributes& rAtt, Bitmap& rBitmap);
+ virtual void DestroyTexture(B3dTexture*);
+public:
+ virtual void SetActiveTexture(B3dTexture* pTex=NULL);
+
+ // Darstellungsqualitaet
+ virtual void SetDisplayQuality(UINT8 nNew);
+
+ // PolygonOffset
+ virtual void SetPolygonOffset(
+ Base3DPolygonOffset eNew=Base3DPolygonOffsetLine, BOOL bNew=FALSE);
+
+ // Beleuchtung setzen/lesen
+ virtual void SetLightGroup(B3dLightGroup* pSet, BOOL bSetGlobal=TRUE);
+
+ virtual void SetRenderMode(Base3DRenderMode eNew,
+ Base3DMaterialMode=Base3DMaterialFrontAndBack);
+ virtual void SetShadeModel(Base3DShadeModel eNew);
+ virtual void SetCullMode(Base3DCullMode eNew);
+
+ virtual void SetEdgeFlag(BOOL bNew=TRUE);
+ virtual void SetPointSize(double fNew=1.0);
+ virtual void SetLineWidth(double fNew=1.0);
+
+ // Ein Objekt in Form einer B3dGeometry direkt ausgeben
+ virtual void DrawPolygonGeometry(B3dGeometry& rGeometry, BOOL bOutline=FALSE);
+
+ // Callbacks bei Matrixaenderungen
+ virtual void SetTransformationSet(B3dTransformationSet* pSet);
+
+protected:
+ // Geometrische Daten uebergeben
+ virtual B3dEntity& ImplGetFreeEntity();
+ virtual void ImplPostAddVertex(B3dEntity& rEnt);
+
+ virtual void ImplStartPrimitive();
+ virtual void ImplEndPrimitive();
+
+ // Callbacks bei Matrixaenderungen
+ void PostSetObjectOrientation(B3dTransformationSet* pCaller);
+ void PostSetProjection(B3dTransformationSet* pCaller);
+ void PostSetTexture(B3dTransformationSet* pCaller);
+ void PostSetViewport(B3dTransformationSet* pCaller);
+
+ // lokale Parameter des LightModels
+ void SetGlobalAmbientLight(const Color rNew);
+ void SetLocalViewer(BOOL bNew=TRUE);
+ void SetModelTwoSide(BOOL bNew=FALSE);
+
+ // Hauptschalter fuer die Beleuchtung
+ void EnableLighting(BOOL bNew=TRUE);
+
+ // Lichtquellen Interface
+ void SetIntensity(const Color rNew,
+ Base3DMaterialValue=Base3DMaterialAmbient,
+ Base3DLightNumber=Base3DLight0);
+ void SetPosition(const Vector3D& rNew,
+ Base3DLightNumber=Base3DLight0);
+ void SetDirection(const Vector3D& rNew,
+ Base3DLightNumber=Base3DLight0);
+ void SetSpotDirection(const Vector3D& rNew,
+ Base3DLightNumber=Base3DLight0);
+ void SetSpotExponent(UINT16 nNew,
+ Base3DLightNumber=Base3DLight0);
+ void SetSpotCutoff(double fNew,
+ Base3DLightNumber=Base3DLight0);
+ void SetConstantAttenuation(double fNew,
+ Base3DLightNumber=Base3DLight0);
+ void SetLinearAttenuation(double fNew,
+ Base3DLightNumber=Base3DLight0);
+ void SetQuadraticAttenuation(double fNew,
+ Base3DLightNumber=Base3DLight0);
+ void Enable(BOOL bNew=TRUE,
+ Base3DLightNumber=Base3DLight0);
+};
+
+
+#endif // _B3D_B3DOPNGL_HXX
diff --git a/goodies/source/base3d/b3dtex.cxx b/goodies/source/base3d/b3dtex.cxx
new file mode 100644
index 000000000000..39c67644b30f
--- /dev/null
+++ b/goodies/source/base3d/b3dtex.cxx
@@ -0,0 +1,1176 @@
+/*************************************************************************
+ *
+ * $RCSfile: b3dtex.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _B3D_B3DTEX_HXX
+#include "b3dtex.hxx"
+#endif
+
+#ifndef _B3D_B3DOPNGL_HXX
+#include "b3dopngl.hxx"
+#endif
+
+#ifndef _SV_BMPACC_HXX
+#include <vcl/bmpacc.hxx>
+#endif
+
+#ifndef _NEW_HXX
+#include <tools/new.hxx>
+#endif
+
+/*************************************************************************
+|*
+|* Klassen fuer TexturAttribute beim Anfordern von Texturen
+|*
+\************************************************************************/
+
+TextureAttributes::TextureAttributes()
+{
+}
+
+// Fuer Bitmaps
+
+TextureAttributesBitmap::TextureAttributesBitmap(Bitmap aBmp)
+: TextureAttributes(),
+ aBitmapAttribute(aBmp)
+{
+}
+
+BOOL TextureAttributesBitmap::operator==(const TextureAttributes& rAtt) const
+{
+ if(GetTextureAttributeType() == rAtt.GetTextureAttributeType())
+ {
+ const TextureAttributesBitmap& rAttBmp = (const TextureAttributesBitmap&)rAtt;
+
+ if(rAttBmp.aBitmapAttribute == aBitmapAttribute)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+UINT16 TextureAttributesBitmap::GetTextureAttributeType() const
+{
+ return TEXTURE_ATTRIBUTE_TYPE_BITMAP;
+}
+
+// Fuer Gradientfills
+
+TextureAttributesGradient::TextureAttributesGradient(void* pF, void *pSC)
+: TextureAttributes(),
+ pFill(pF),
+ pStepCount(pSC)
+{
+}
+
+BOOL TextureAttributesGradient::operator==(const TextureAttributes& rAtt) const
+{
+ if(GetTextureAttributeType() == rAtt.GetTextureAttributeType())
+ {
+ const TextureAttributesGradient& rAttGra = (const TextureAttributesGradient&)rAtt;
+
+ if(rAttGra.pFill == pFill
+ && rAttGra.pStepCount == pStepCount)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+UINT16 TextureAttributesGradient::GetTextureAttributeType() const
+{
+ return TEXTURE_ATTRIBUTE_TYPE_GRADIENT;
+}
+
+// Fuer Hatchfills
+
+TextureAttributesHatch::TextureAttributesHatch(void* pF)
+: TextureAttributes(),
+ pFill(pF)
+{
+}
+
+BOOL TextureAttributesHatch::operator==(const TextureAttributes& rAtt) const
+{
+ if(GetTextureAttributeType() == rAtt.GetTextureAttributeType())
+ {
+ const TextureAttributesHatch& rAttHat = (const TextureAttributesHatch&)rAtt;
+
+ if(rAttHat.pFill == pFill)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+UINT16 TextureAttributesHatch::GetTextureAttributeType() const
+{
+ return TEXTURE_ATTRIBUTE_TYPE_HATCH;
+}
+
+
+/*************************************************************************
+|*
+|* Konstruktor Textur
+|*
+\************************************************************************/
+
+B3dTexture::B3dTexture(
+ TextureAttributes& rAtt,
+ Bitmap& rBmp,
+ Base3DTextureKind eKnd,
+ Base3DTextureMode eMod,
+ Base3DTextureFilter eFlt,
+ Base3DTextureWrap eS,
+ Base3DTextureWrap eT)
+: aBitmap(rBmp),
+ pReadAccess(NULL),
+ nUsageCount(B3D_TEXTURE_LIFETIME),
+ eKind(eKnd),
+ eMode(eMod),
+ eFilter(eFlt),
+ eWrapS(eS),
+ eWrapT(eT),
+ nSwitchVal(0),
+ bTextureKindChanged(FALSE)
+{
+ // ReadAccess auf Textur anfordern
+ pReadAccess = aBitmap.AcquireReadAccess();
+ DBG_ASSERT(pReadAccess, "AW: Keinen Lesezugriff auf Textur-Bitmap bekommen");
+
+ // Attribute kopieren
+ switch(rAtt.GetTextureAttributeType())
+ {
+ case TEXTURE_ATTRIBUTE_TYPE_BITMAP :
+ pAttributes = new TextureAttributesBitmap(
+ ((TextureAttributesBitmap&)rAtt).GetBitmapAttribute());
+ break;
+
+ case TEXTURE_ATTRIBUTE_TYPE_GRADIENT :
+ pAttributes = new TextureAttributesGradient(
+ ((TextureAttributesGradient&)rAtt).GetFillAttribute(),
+ ((TextureAttributesGradient&)rAtt).GetStepCountAttribute());
+ break;
+
+ case TEXTURE_ATTRIBUTE_TYPE_HATCH :
+ pAttributes = new TextureAttributesHatch(
+ ((TextureAttributesHatch&)rAtt).GetHatchFillAttribute());
+ break;
+ }
+
+ // SwitchVal setzen
+ SetSwitchVal();
+}
+
+/*************************************************************************
+|*
+|* Destruktor Textur
+|*
+\************************************************************************/
+
+B3dTexture::~B3dTexture()
+{
+ // ReadAccess auf Textur freigeben
+ if(pReadAccess)
+ {
+ aBitmap.ReleaseAccess(pReadAccess);
+ pReadAccess = NULL;
+ }
+
+ // Attribute wegschmeissen
+ if(pAttributes)
+ delete pAttributes;
+ pAttributes = NULL;
+}
+
+// Zugriff auf die Attribute der Textur
+TextureAttributes& B3dTexture::GetAttributes()
+{
+ return *pAttributes;
+}
+
+/*************************************************************************
+|*
+|* Art des Wrappings in X setzen
+|*
+\************************************************************************/
+
+void B3dTexture::SetTextureWrapS(Base3DTextureWrap eNew)
+{
+ if(eNew != eWrapS)
+ {
+ eWrapS = eNew;
+ bTextureKindChanged = TRUE;
+ }
+}
+
+/*************************************************************************
+|*
+|* Art des Wrappings in Y setzen
+|*
+\************************************************************************/
+
+void B3dTexture::SetTextureWrapT(Base3DTextureWrap eNew)
+{
+ if(eNew != eWrapT)
+ {
+ eWrapT = eNew;
+ bTextureKindChanged = TRUE;
+ }
+}
+
+/*************************************************************************
+|*
+|* Blend-Color lesen/bestimmen
+|*
+\************************************************************************/
+
+void B3dTexture::SetBlendColor(Color rNew)
+{
+ if(rNew.GetRed() != aColBlend.GetRed()
+ || rNew.GetGreen() != aColBlend.GetGreen()
+ || rNew.GetBlue() != aColBlend.GetBlue())
+ {
+ aColBlend.SetRed(rNew.GetRed());
+ aColBlend.SetGreen(rNew.GetGreen());
+ aColBlend.SetBlue(rNew.GetBlue());
+ if(eWrapS == Base3DTextureSingle || eWrapT == Base3DTextureSingle)
+ bTextureKindChanged = TRUE;
+ }
+}
+
+Color B3dTexture::GetBlendColor()
+{
+ Color aRetval(aColBlend.GetRed(),
+ aColBlend.GetGreen(),
+ aColBlend.GetBlue());
+ return aRetval;
+}
+
+/*************************************************************************
+|*
+|* Textur-Ersatz-Color lesen/bestimmen
+|*
+\************************************************************************/
+
+void B3dTexture::SetTextureColor(Color rNew)
+{
+ if(rNew.GetRed() != aColTexture.GetRed()
+ || rNew.GetGreen() != aColTexture.GetGreen()
+ || rNew.GetBlue() != aColTexture.GetBlue())
+ {
+ aColTexture.SetRed(rNew.GetRed());
+ aColTexture.SetGreen(rNew.GetGreen());
+ aColTexture.SetBlue(rNew.GetBlue());
+ if(eWrapS == Base3DTextureSingle || eWrapT == Base3DTextureSingle)
+ bTextureKindChanged = TRUE;
+ }
+}
+
+Color B3dTexture::GetTextureColor()
+{
+ Color aRetval(aColTexture.GetRed(),
+ aColTexture.GetGreen(),
+ aColTexture.GetBlue());
+ return aRetval;
+}
+
+/*************************************************************************
+|*
+|* Internen Verteilungswert setzen
+|*
+\************************************************************************/
+
+void B3dTexture::SetSwitchVal()
+{
+ nSwitchVal = 0;
+
+ // Kind
+ if(GetTextureKind() == Base3DTextureLuminance)
+ nSwitchVal |= B3D_TXT_KIND_LUM;
+ else if(GetTextureKind() == Base3DTextureIntensity)
+ nSwitchVal |= B3D_TXT_KIND_INT;
+ else if(GetTextureKind() == Base3DTextureColor)
+ nSwitchVal |= B3D_TXT_KIND_COL;
+
+ // Mode
+ if(GetTextureMode() == Base3DTextureReplace)
+ nSwitchVal |= B3D_TXT_MODE_REP;
+ else if(GetTextureMode() == Base3DTextureModulate)
+ nSwitchVal |= B3D_TXT_MODE_MOD;
+ else if(GetTextureMode() == Base3DTextureBlend)
+ nSwitchVal |= B3D_TXT_MODE_BND;
+
+ // Filter
+ if(GetTextureFilter() == Base3DTextureNearest)
+ nSwitchVal |= B3D_TXT_FLTR_NEA;
+}
+
+/*************************************************************************
+|*
+|* Zugriffsfunktion auf die Farben der Bitmap
+|*
+\************************************************************************/
+
+const BitmapColor B3dTexture::GetBitmapColor(long nX, long nY)
+{
+ return pReadAccess->GetColor(nY, nX);
+}
+
+/*************************************************************************
+|*
+|* Art der Pixeldaten lesen/bestimmen
+|*
+\************************************************************************/
+
+void B3dTexture::SetTextureKind(Base3DTextureKind eNew)
+{
+ if(eKind != eNew)
+ {
+ eKind = eNew;
+ bTextureKindChanged = TRUE;
+ }
+ SetSwitchVal();
+}
+
+/*************************************************************************
+|*
+|* Texturmodus lesen/bestimmen
+|*
+\************************************************************************/
+
+void B3dTexture::SetTextureMode(Base3DTextureMode eNew)
+{
+ eMode = eNew;
+ SetSwitchVal();
+}
+
+/*************************************************************************
+|*
+|* Filtermodus lesen/bestimmen
+|*
+\************************************************************************/
+
+void B3dTexture::SetTextureFilter(Base3DTextureFilter eNew)
+{
+ eFilter = eNew;
+ SetSwitchVal();
+}
+
+/*************************************************************************
+|*
+|* Die Texturfunktion selbst. Die ursruengliche Farbe des Punktes
+|* innerhalb der Grenzen des Parameterbereiches S,T (in Bitmapkoordinaten)
+|* wird modifiziert.
+|*
+\************************************************************************/
+
+void B3dTexture::ModifyColor(Color& rCol, double fS, double fT)
+{
+ // Integer-Koordinaten der Texturposition bilden
+ long nX((long)fS);
+ long nY((long)fT);
+ BitmapColor aBmCol = aColTexture;
+ BOOL bOnTexture(TRUE);
+
+ // Wrapping in S-Richtung
+ if(eWrapS == Base3DTextureClamp)
+ {
+ // Clamping
+ if(nX < 0)
+ nX = 0;
+ else if(nX >= GetBitmapSize().Width())
+ nX = GetBitmapSize().Width() - 1;
+ }
+ else if(eWrapS == Base3DTextureRepeat)
+ {
+ // Repeating
+ nX %= GetBitmapSize().Width();
+ if(nX < 0)
+ nX += GetBitmapSize().Width();
+ }
+ else
+ {
+ // Single
+ if(nX < 0 || nX >= GetBitmapSize().Width())
+ bOnTexture = FALSE;
+ }
+
+ // Wrapping in T-Richtung
+ if(bOnTexture)
+ {
+ if(eWrapT == Base3DTextureClamp)
+ {
+ // Clamping
+ if(nY < 0)
+ nY = 0;
+ else if(nY >= GetBitmapSize().Height())
+ nY = GetBitmapSize().Height() - 1;
+ }
+ else if(eWrapT == Base3DTextureRepeat)
+ {
+ // Repeating
+ nY %= GetBitmapSize().Height();
+ if(nY < 0)
+ nY += GetBitmapSize().Height();
+ }
+ else
+ {
+ // Single
+ if(nY < 0 || nY >= GetBitmapSize().Height())
+ bOnTexture = FALSE;
+ }
+
+ if(bOnTexture)
+ aBmCol = pReadAccess->GetColor(nY, nX);
+ }
+
+ // Falls die Position nicht innerhalb der Textur ist, auch das Filtern
+ // unterdruecken um keine falschen BitmapAcesses zu bekommen
+ UINT8 nLocalSwitchVal(nSwitchVal);
+ if(!bOnTexture)
+ nLocalSwitchVal |= B3D_TXT_FLTR_NEA;
+
+ switch(nLocalSwitchVal)
+ {
+ case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_REP|B3D_TXT_KIND_COL) :
+ {
+ rCol.SetRed(aBmCol.GetRed());
+ rCol.SetGreen(aBmCol.GetGreen());
+ rCol.SetBlue(aBmCol.GetBlue());
+ break;
+ }
+ case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_MOD|B3D_TXT_KIND_COL) :
+ {
+ rCol.SetRed((UINT8)( ((UINT16)rCol.GetRed() * (UINT16)aBmCol.GetRed())>>8 ));
+ rCol.SetGreen((UINT8)( ((UINT16)rCol.GetGreen() * (UINT16)aBmCol.GetGreen())>>8 ));
+ rCol.SetBlue((UINT8)( ((UINT16)rCol.GetBlue() * (UINT16)aBmCol.GetBlue())>>8 ));
+ break;
+ }
+ case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_BND|B3D_TXT_KIND_COL) :
+ {
+ rCol.SetRed((UINT8)( ((UINT16)rCol.GetRed() * (0x00ff - (UINT16)aBmCol.GetRed()))
+ + ((UINT16)aColBlend.GetRed() * (UINT16)aBmCol.GetRed()) ));
+ rCol.SetGreen((UINT8)( ((UINT16)rCol.GetGreen() * (0x00ff - (UINT16)aBmCol.GetGreen()))
+ + ((UINT16)aColBlend.GetGreen() * (UINT16)aBmCol.GetGreen()) ));
+ rCol.SetBlue((UINT8)( ((UINT16)rCol.GetBlue() * (0x00ff - (UINT16)aBmCol.GetBlue()))
+ + ((UINT16)aColBlend.GetBlue() * (UINT16)aBmCol.GetBlue()) ));
+ break;
+ }
+ case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_REP|B3D_TXT_KIND_INT) :
+ case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_REP|B3D_TXT_KIND_LUM) :
+ {
+ rCol.SetRed((aBmCol.GetRed() + aBmCol.GetGreen() + aBmCol.GetBlue()) / 3);
+ rCol.SetGreen(rCol.GetRed());
+ rCol.SetBlue(rCol.GetRed());
+ break;
+ }
+ case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_MOD|B3D_TXT_KIND_INT) :
+ case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_MOD|B3D_TXT_KIND_LUM) :
+ {
+ UINT16 nMidCol = (aBmCol.GetRed() + aBmCol.GetGreen() + aBmCol.GetBlue()) / 3;
+ rCol.SetRed((UINT8)( ((UINT16)rCol.GetRed() * nMidCol)>>8 ));
+ rCol.SetGreen((UINT8)( ((UINT16)rCol.GetGreen() * nMidCol)>>8 ));
+ rCol.SetBlue((UINT8)( ((UINT16)rCol.GetBlue() * nMidCol)>>8 ));
+ break;
+ }
+ case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_BND|B3D_TXT_KIND_INT) :
+ case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_BND|B3D_TXT_KIND_LUM) :
+ {
+ UINT16 nMidCol = (aBmCol.GetRed() + aBmCol.GetGreen() + aBmCol.GetBlue()) / 3;
+ UINT16 nInvMidCol = 0x00ff - nMidCol;
+ rCol.SetRed((UINT8)( ((UINT16)rCol.GetRed() * nInvMidCol)
+ + ((UINT16)aColBlend.GetRed() * nMidCol) ));
+ rCol.SetGreen((UINT8)( ((UINT16)rCol.GetGreen() * nInvMidCol)
+ + ((UINT16)aColBlend.GetGreen() * nMidCol) ));
+ rCol.SetBlue((UINT8)( ((UINT16)rCol.GetBlue() * nInvMidCol)
+ + ((UINT16)aColBlend.GetBlue() * nMidCol) ));
+ break;
+ }
+ case (B3D_TXT_MODE_REP|B3D_TXT_KIND_COL) :
+ {
+ fS = fS - floor(fS);
+ fT = fT - floor(fT);
+ long nX2, nY2;
+
+ if(fS > 0.5) {
+ nX2 = (nX + 1) % GetBitmapSize().Width();
+ fS = 1.0 - fS;
+ } else
+ nX2 = nX ? nX - 1 : GetBitmapSize().Width() - 1;
+
+ if(fT > 0.5) {
+ nY2 = (nY + 1) % GetBitmapSize().Height();
+ fT = 1.0 - fT;
+ } else
+ nY2 = nY ? nY - 1 : GetBitmapSize().Height() - 1;
+
+ fS += 0.5;
+ fT += 0.5;
+ double fRight = 1.0 - fS;
+ double fBottom = 1.0 - fT;
+
+ BitmapColor aColTL = pReadAccess->GetColor(nY, nX);
+ BitmapColor aColTR = pReadAccess->GetColor(nY, nX2);
+ BitmapColor aColBL = pReadAccess->GetColor(nY2, nX);
+ BitmapColor aColBR = pReadAccess->GetColor(nY2, nX2);
+
+ rCol.SetRed((UINT8)(((double)aColTL.GetRed() * fS + (double)aColTR.GetRed() * fRight) * fT
+ + ((double)aColBL.GetRed() * fS + (double)aColBR.GetRed() * fRight) * fBottom));
+ rCol.SetGreen((UINT8)(((double)aColTL.GetGreen() * fS + (double)aColTR.GetGreen() * fRight) * fT
+ + ((double)aColBL.GetGreen() * fS + (double)aColBR.GetGreen() * fRight) * fBottom));
+ rCol.SetBlue((UINT8)(((double)aColTL.GetBlue() * fS + (double)aColTR.GetBlue() * fRight) * fT
+ + ((double)aColBL.GetBlue() * fS + (double)aColBR.GetBlue() * fRight) * fBottom));
+ break;
+ }
+ case (B3D_TXT_MODE_MOD|B3D_TXT_KIND_COL) :
+ {
+ fS = fS - floor(fS);
+ fT = fT - floor(fT);
+ long nX2, nY2;
+
+ if(fS > 0.5) {
+ nX2 = (nX + 1) % GetBitmapSize().Width();
+ fS = 1.0 - fS;
+ } else
+ nX2 = nX ? nX - 1 : GetBitmapSize().Width() - 1;
+
+ if(fT > 0.5) {
+ nY2 = (nY + 1) % GetBitmapSize().Height();
+ fT = 1.0 - fT;
+ } else
+ nY2 = nY ? nY - 1 : GetBitmapSize().Height() - 1;
+
+ fS += 0.5;
+ fT += 0.5;
+ double fRight = 1.0 - fS;
+ double fBottom = 1.0 - fT;
+
+ BitmapColor aColTL = pReadAccess->GetColor(nY, nX);
+ BitmapColor aColTR = pReadAccess->GetColor(nY, nX2);
+ BitmapColor aColBL = pReadAccess->GetColor(nY2, nX);
+ BitmapColor aColBR = pReadAccess->GetColor(nY2, nX2);
+
+ double fRed = ((double)aColTL.GetRed() * fS + (double)aColTR.GetRed() * fRight) * fT
+ + ((double)aColBL.GetRed() * fS + (double)aColBR.GetRed() * fRight) * fBottom;
+ double fGreen = ((double)aColTL.GetGreen() * fS + (double)aColTR.GetGreen() * fRight) * fT
+ + ((double)aColBL.GetGreen() * fS + (double)aColBR.GetGreen() * fRight) * fBottom;
+ double fBlue = ((double)aColTL.GetBlue() * fS + (double)aColTR.GetBlue() * fRight) * fT
+ + ((double)aColBL.GetBlue() * fS + (double)aColBR.GetBlue() * fRight) * fBottom;
+
+ rCol.SetRed((UINT8)(((double)rCol.GetRed() * fRed) / 255.0));
+ rCol.SetGreen((UINT8)(((double)rCol.GetGreen() * fGreen) / 255.0));
+ rCol.SetBlue((UINT8)(((double)rCol.GetBlue() * fBlue) / 255.0));
+ break;
+ }
+ case (B3D_TXT_MODE_BND|B3D_TXT_KIND_COL) :
+ {
+ fS = fS - floor(fS);
+ fT = fT - floor(fT);
+ long nX2, nY2;
+
+ if(fS > 0.5) {
+ nX2 = (nX + 1) % GetBitmapSize().Width();
+ fS = 1.0 - fS;
+ } else
+ nX2 = nX ? nX - 1 : GetBitmapSize().Width() - 1;
+
+ if(fT > 0.5) {
+ nY2 = (nY + 1) % GetBitmapSize().Height();
+ fT = 1.0 - fT;
+ } else
+ nY2 = nY ? nY - 1 : GetBitmapSize().Height() - 1;
+
+ fS += 0.5;
+ fT += 0.5;
+ double fRight = 1.0 - fS;
+ double fBottom = 1.0 - fT;
+
+ BitmapColor aColTL = pReadAccess->GetColor(nY, nX);
+ BitmapColor aColTR = pReadAccess->GetColor(nY, nX2);
+ BitmapColor aColBL = pReadAccess->GetColor(nY2, nX);
+ BitmapColor aColBR = pReadAccess->GetColor(nY2, nX2);
+
+ double fRed = ((double)aColTL.GetRed() * fS + (double)aColTR.GetRed() * fRight) * fT
+ + ((double)aColBL.GetRed() * fS + (double)aColBR.GetRed() * fRight) * fBottom;
+ double fGreen = ((double)aColTL.GetGreen() * fS + (double)aColTR.GetGreen() * fRight) * fT
+ + ((double)aColBL.GetGreen() * fS + (double)aColBR.GetGreen() * fRight) * fBottom;
+ double fBlue = ((double)aColTL.GetBlue() * fS + (double)aColTR.GetBlue() * fRight) * fT
+ + ((double)aColBL.GetBlue() * fS + (double)aColBR.GetBlue() * fRight) * fBottom;
+
+ rCol.SetRed((UINT8)((((double)rCol.GetRed() * (255.0 - fRed)) + ((double)aColBlend.GetRed() * fRed)) / 255.0));
+ rCol.SetGreen((UINT8)((((double)rCol.GetGreen() * (255.0 - fGreen)) + ((double)aColBlend.GetGreen() * fGreen)) / 255.0));
+ rCol.SetBlue((UINT8)((((double)rCol.GetBlue() * (255.0 - fBlue)) + ((double)aColBlend.GetBlue() * fBlue)) / 255.0));
+ break;
+ }
+ case (B3D_TXT_MODE_REP|B3D_TXT_KIND_INT) :
+ case (B3D_TXT_MODE_REP|B3D_TXT_KIND_LUM) :
+ {
+ fS = fS - floor(fS);
+ fT = fT - floor(fT);
+ long nX2, nY2;
+
+ if(fS > 0.5) {
+ nX2 = (nX + 1) % GetBitmapSize().Width();
+ fS = 1.0 - fS;
+ } else
+ nX2 = nX ? nX - 1 : GetBitmapSize().Width() - 1;
+
+ if(fT > 0.5) {
+ nY2 = (nY + 1) % GetBitmapSize().Height();
+ fT = 1.0 - fT;
+ } else
+ nY2 = nY ? nY - 1 : GetBitmapSize().Height() - 1;
+
+ fS += 0.5;
+ fT += 0.5;
+ double fRight = 1.0 - fS;
+ double fBottom = 1.0 - fT;
+
+ UINT8 nMidVal = (UINT8)((
+ (double)pReadAccess->GetLuminance(nY, nX) * fS +
+ (double)pReadAccess->GetLuminance(nY, nX2) * fRight) * fT + (
+ (double)pReadAccess->GetLuminance(nY2, nX) * fS +
+ (double)pReadAccess->GetLuminance(nY2, nX2) * fRight) * fBottom);
+
+ rCol.SetRed(nMidVal);
+ rCol.SetGreen(nMidVal);
+ rCol.SetBlue(nMidVal);
+ break;
+ }
+ case (B3D_TXT_MODE_MOD|B3D_TXT_KIND_INT) :
+ case (B3D_TXT_MODE_MOD|B3D_TXT_KIND_LUM) :
+ {
+ fS = fS - floor(fS);
+ fT = fT - floor(fT);
+ long nX2, nY2;
+
+ if(fS > 0.5) {
+ nX2 = (nX + 1) % GetBitmapSize().Width();
+ fS = 1.0 - fS;
+ } else
+ nX2 = nX ? nX - 1 : GetBitmapSize().Width() - 1;
+
+ if(fT > 0.5) {
+ nY2 = (nY + 1) % GetBitmapSize().Height();
+ fT = 1.0 - fT;
+ } else
+ nY2 = nY ? nY - 1 : GetBitmapSize().Height() - 1;
+
+ fS += 0.5;
+ fT += 0.5;
+ double fRight = 1.0 - fS;
+ double fBottom = 1.0 - fT;
+
+ double fMidVal = (
+ (double)pReadAccess->GetLuminance(nY, nX) * fS +
+ (double)pReadAccess->GetLuminance(nY, nX2) * fRight) * fT + (
+ (double)pReadAccess->GetLuminance(nY2, nX) * fS +
+ (double)pReadAccess->GetLuminance(nY2, nX2) * fRight) * fBottom;
+
+ rCol.SetRed((UINT8)(((double)rCol.GetRed() * fMidVal) / 255.0));
+ rCol.SetGreen((UINT8)(((double)rCol.GetGreen() * fMidVal) / 255.0));
+ rCol.SetBlue((UINT8)(((double)rCol.GetBlue() * fMidVal) / 255.0));
+ break;
+ }
+ case (B3D_TXT_MODE_BND|B3D_TXT_KIND_INT) :
+ case (B3D_TXT_MODE_BND|B3D_TXT_KIND_LUM) :
+ {
+ fS = fS - floor(fS);
+ fT = fT - floor(fT);
+ long nX2, nY2;
+
+ if(fS > 0.5) {
+ nX2 = (nX + 1) % GetBitmapSize().Width();
+ fS = 1.0 - fS;
+ } else
+ nX2 = nX ? nX - 1 : GetBitmapSize().Width() - 1;
+
+ if(fT > 0.5) {
+ nY2 = (nY + 1) % GetBitmapSize().Height();
+ fT = 1.0 - fT;
+ } else
+ nY2 = nY ? nY - 1 : GetBitmapSize().Height() - 1;
+
+ fS += 0.5;
+ fT += 0.5;
+ double fRight = 1.0 - fS;
+ double fBottom = 1.0 - fT;
+
+ double fMidVal = (
+ (double)pReadAccess->GetLuminance(nY, nX) * fS +
+ (double)pReadAccess->GetLuminance(nY, nX2) * fRight) * fT + (
+ (double)pReadAccess->GetLuminance(nY2, nX) * fS +
+ (double)pReadAccess->GetLuminance(nY2, nX2) * fRight) * fBottom;
+ double fInvMidVal(255.0 - fMidVal);
+
+ rCol.SetRed((UINT8)((((double)rCol.GetRed() * fInvMidVal) + ((double)aColBlend.GetRed() * fMidVal)) / 255.0));
+ rCol.SetGreen((UINT8)((((double)rCol.GetGreen() * fInvMidVal) + ((double)aColBlend.GetGreen() * fMidVal)) / 255.0));
+ rCol.SetBlue((UINT8)((((double)rCol.GetBlue() * fInvMidVal) + ((double)aColBlend.GetBlue() * fMidVal)) / 255.0));
+ break;
+ }
+ }
+
+// Funktionsfaehige Version komplett auf double precision und
+// kuerzesten Pfaden
+//
+// // Parameter fuer Farbe der Texturstelle bereitstellen
+// double fRed, fGreen, fBlue;
+//
+// // Eventuell glaetten?
+// if(GetTextureFilter() == Base3DTextureLinear)
+// {
+// // Filtern
+// double fLeft = fS - floor(fS);
+// double fTop = fT - floor(fT);
+// double fRight, fBottom;
+// long nX2, nY2;
+//
+// if(fLeft > 0.5)
+// {
+// nX2 = (nX + 1) % GetBitmapSize().Width();
+// fLeft = (1.0 - fLeft) + 0.5;
+// fRight = 1.0 - fLeft;
+// }
+// else
+// {
+// nX2 = nX ? nX - 1 : GetBitmapSize().Width() - 1;
+// fLeft = fLeft + 0.5;
+// fRight = 1.0 - fLeft;
+// }
+//
+//
+// if(fTop > 0.5)
+// {
+// nY2 = (nY + 1) % GetBitmapSize().Height();
+// fTop = (1.0 - fTop) + 0.5;
+// fBottom = 1.0 - fTop;
+// }
+// else
+// {
+// nY2 = nY ? nY - 1 : GetBitmapSize().Height() - 1;
+// fTop = fTop + 0.5;
+// fBottom = 1.0 - fTop;
+// }
+//
+// const BitmapColor& rColTL = GetBitmapColor(nX, nY);
+// const BitmapColor& rColTR = GetBitmapColor(nX2, nY);
+// const BitmapColor& rColBL = GetBitmapColor(nX, nY2);
+// const BitmapColor& rColBR = GetBitmapColor(nX2, nY2);
+//
+// fRed = ((double)rColTL.GetRed() * fLeft + (double)rColTR.GetRed() * fRight) * fTop
+// + ((double)rColBL.GetRed() * fLeft + (double)rColBR.GetRed() * fRight) * fBottom;
+//
+// fGreen = ((double)rColTL.GetGreen() * fLeft + (double)rColTR.GetGreen() * fRight) * fTop
+// + ((double)rColBL.GetGreen() * fLeft + (double)rColBR.GetGreen() * fRight) * fBottom;
+//
+// fBlue = ((double)rColTL.GetBlue() * fLeft + (double)rColTR.GetBlue() * fRight) * fTop
+// + ((double)rColBL.GetBlue() * fLeft + (double)rColBR.GetBlue() * fRight) * fBottom;
+// }
+// else
+// {
+// // Nearest Pixel
+// const BitmapColor& rBmCol = GetBitmapColor(nX, nY);
+// fRed = (double)rBmCol.GetRed();
+// fGreen = (double)rBmCol.GetGreen();
+// fBlue = (double)rBmCol.GetBlue();
+// }
+//
+// // Jetzt anhand der TextureKind entscheiden
+// if(eKind == Base3DTextureColor)
+// {
+// if(eMode == Base3DTextureReplace)
+// {
+// rCol.SetRed((UINT8)fRed);
+// rCol.SetGreen((UINT8)fGreen);
+// rCol.SetBlue((UINT8)fBlue);
+// }
+// else if(eMode == Base3DTextureModulate)
+// {
+// rCol.SetRed((UINT8)(((double)rCol.GetRed() * fRed) / 255.0));
+// rCol.SetGreen((UINT8)(((double)rCol.GetGreen() * fGreen) / 255.0));
+// rCol.SetBlue((UINT8)(((double)rCol.GetBlue() * fBlue) / 255.0));
+// }
+// else // Base3DTextureBlend
+// {
+// rCol.SetRed((UINT8)((((double)rCol.GetRed() * (255.0 - fRed)) + ((double)aColBlend.GetRed() * fRed)) / 255.0));
+// rCol.SetGreen((UINT8)((((double)rCol.GetGreen() * (255.0 - fGreen)) + ((double)aColBlend.GetGreen() * fGreen)) / 255.0));
+// rCol.SetBlue((UINT8)((((double)rCol.GetBlue() * (255.0 - fBlue)) + ((double)aColBlend.GetBlue() * fBlue)) / 255.0));
+// }
+// }
+// else
+// {
+// double fMidVal((fRed + fGreen + fBlue) / 3.0);
+// if(eMode == Base3DTextureReplace)
+// {
+// rCol.SetRed((UINT8)fMidVal);
+// rCol.SetGreen((UINT8)fMidVal);
+// rCol.SetBlue((UINT8)fMidVal);
+// }
+// else if(eMode == Base3DTextureModulate)
+// {
+// rCol.SetRed((UINT8)(((double)rCol.GetRed() * fMidVal) / 255.0));
+// rCol.SetGreen((UINT8)(((double)rCol.GetGreen() * fMidVal) / 255.0));
+// rCol.SetBlue((UINT8)(((double)rCol.GetBlue() * fMidVal) / 255.0));
+// }
+// else // Base3DTextureBlend
+// {
+// double fInvMidVal(255.0 - fMidVal);
+// rCol.SetRed((UINT8)((((double)rCol.GetRed() * fInvMidVal) + ((double)aColBlend.GetRed() * fRed)) / 255.0));
+// rCol.SetGreen((UINT8)((((double)rCol.GetGreen() * fInvMidVal) + ((double)aColBlend.GetGreen() * fGreen)) / 255.0));
+// rCol.SetBlue((UINT8)((((double)rCol.GetBlue() * fInvMidVal) + ((double)aColBlend.GetBlue() * fBlue)) / 255.0));
+// }
+// }
+}
+
+/*************************************************************************
+|*
+|* Konstruktor TexturOpenGL
+|*
+\************************************************************************/
+
+B3dTextureOpenGL::B3dTextureOpenGL(
+ TextureAttributes& rAtt,
+ Bitmap& rBmp,
+ OpenGL& rOGL,
+ Base3DTextureKind eKnd,
+ Base3DTextureMode eMod,
+ Base3DTextureFilter eFlt,
+ Base3DTextureWrap eS,
+ Base3DTextureWrap eT)
+: B3dTexture(rAtt, rBmp, eKnd, eMod, eFlt, eS, eT),
+ nTextureName(0)
+{
+ // TextureName anfordern
+ rOGL.GenTextures(1, &nTextureName);
+}
+
+/*************************************************************************
+|*
+|* Destruktor TexturOpenGL
+|*
+\************************************************************************/
+
+B3dTextureOpenGL::~B3dTextureOpenGL()
+{
+}
+
+/*************************************************************************
+|*
+|* In OpenGL die Textur zerstoeren
+|*
+\************************************************************************/
+
+void B3dTextureOpenGL::DestroyOpenGLTexture(OpenGL& rOpenGL)
+{
+ // OpenGL Textur wieder freigeben
+ rOpenGL.DeleteTextures(1, &nTextureName);
+}
+
+/*************************************************************************
+|*
+|* Setze diese Textur in OpenGL als aktuelle Textur
+|*
+\************************************************************************/
+
+void B3dTextureOpenGL::MakeCurrentTexture(OpenGL& rOpenGL)
+{
+ // Eventuell Textur erst erzeugen?
+ if(!rOpenGL.IsTexture(nTextureName) || bTextureKindChanged)
+ {
+ // Textur erzeugen und binden
+ CreateOpenGLTexture(rOpenGL);
+ }
+ else
+ {
+ // Jetzt Textur binden
+ rOpenGL.BindTexture(GL_TEXTURE_2D, nTextureName);
+ }
+
+ // Nun die Parameter an der Textur setzen
+ switch(GetTextureWrapS())
+ {
+ case Base3DTextureSingle :
+ case Base3DTextureClamp :
+ rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ break;
+ case Base3DTextureRepeat :
+ rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ break;
+ }
+ switch(GetTextureWrapT())
+ {
+ case Base3DTextureSingle :
+ case Base3DTextureClamp :
+ rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ break;
+ case Base3DTextureRepeat :
+ rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ break;
+ }
+ switch(GetTextureFilter())
+ {
+ case Base3DTextureNearest :
+ rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ break;
+ case Base3DTextureLinear :
+ rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ break;
+ }
+ switch(GetTextureMode())
+ {
+ case Base3DTextureReplace :
+ rOpenGL.TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ break;
+ case Base3DTextureModulate :
+ rOpenGL.TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ break;
+ case Base3DTextureBlend :
+ {
+ rOpenGL.TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
+ float fArray[4] = {
+ ((float)GetBlendColor().GetRed()) / (float)255.0,
+ ((float)GetBlendColor().GetGreen()) / (float)255.0,
+ ((float)GetBlendColor().GetBlue()) / (float)255.0,
+ ((float)GetBlendColor().GetTransparency()) / (float)255.0
+ };
+ rOpenGL.TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, fArray);
+ break;
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Erzeuge diese Textur als OpenGL-Textur
+|*
+\************************************************************************/
+
+void B3dTextureOpenGL::CreateOpenGLTexture(OpenGL& rOpenGL)
+{
+ Size aSize(0,0);
+
+ // Groesse entscheiden (auf 1024 begrenzen)
+ for(UINT16 a=1;a<0x0400 && (!aSize.Width() || !aSize.Height());a<<=1)
+ {
+ if(!aSize.Width() && (a>=GetBitmapSize().Width()))
+ aSize.Width() = a;
+ if(!aSize.Height() && (a>=GetBitmapSize().Height()))
+ aSize.Height() = a;
+ }
+
+ // begrenzen falls groesser als 1024
+ if(!aSize.Width())
+ aSize.Width() = 0x0400;
+ if(!aSize.Height())
+ aSize.Height() = 0x0400;
+
+ // Minimalgroesse garantieren, auch an 4Byte-Alignment denken
+ // falls hier mal geaendert wird... (siehe OpenGL Bitmap Befehle)
+ if(aSize.Width() < 8)
+ aSize.Width() = 8;
+ if(aSize.Height() < 8)
+ aSize.Height() = 8;
+
+ // Skalierte Bitmap anlegen
+ Bitmap aBitmap(GetBitmap());
+ if(aSize != GetBitmapSize())
+ aBitmap.Scale((double)aSize.Width() / (double)GetBitmapSize().Width(),
+ (double)aSize.Height() / (double)GetBitmapSize().Height());
+
+ // Falls es sich um eine nur einmal zu wiederholende Bitmap
+ // handelt, lege nun eine mit einem definierten Rand an
+ if(GetTextureWrapS() == Base3DTextureSingle
+ || GetTextureWrapT() == Base3DTextureSingle)
+ {
+ Bitmap aHelpBitmap(aBitmap);
+ Size aNewSize(aSize);
+ Point aNewPos(0, 0);
+
+ if(GetTextureWrapS() == Base3DTextureSingle)
+ {
+ aNewSize.Width() -= 4;
+ aNewPos.X() = 2;
+ }
+ if(GetTextureWrapT() == Base3DTextureSingle)
+ {
+ aNewSize.Height() -= 4;
+ aNewPos.Y() = 2;
+ }
+
+ aHelpBitmap.Scale((double)aNewSize.Width() / (double)aSize.Width(),
+ (double)aNewSize.Height() / (double)aSize.Height());
+ Color aEraseCol = GetTextureColor();
+ aBitmap.Erase(aEraseCol);
+ Point aPoint;
+ Rectangle aCopySrc(aPoint, aNewSize);
+ Rectangle aCopyDest(aNewPos, aNewSize);
+ aBitmap.CopyPixel(aCopyDest, aCopySrc, &aHelpBitmap);
+ }
+
+ // Lesezugriff auf neue Bitmap holen
+ BitmapReadAccess* pReadAccess = aBitmap.AcquireReadAccess();
+ if(pReadAccess)
+ {
+ // Buffer holen
+ long nSize = aSize.Width() * aSize.Height();
+ if(GetTextureKind() == Base3DTextureColor)
+ nSize *= 3;
+ GL_UINT8 pBuffer = (GL_UINT8)SvMemAlloc(nSize);
+
+ if(pBuffer)
+ {
+ // Daten kopieren
+ GL_UINT8 pRunner = pBuffer;
+ if(GetTextureKind() == Base3DTextureColor)
+ {
+ if(pReadAccess->HasPalette())
+ {
+ for(long a=0;a<aSize.Height();a++)
+ {
+ for(long b=0;b<aSize.Width();b++)
+ {
+ const BitmapColor& rCol = pReadAccess->GetPaletteColor(
+ pReadAccess->GetPixel(a, b));
+ *pRunner++ = rCol.GetRed();
+ *pRunner++ = rCol.GetGreen();
+ *pRunner++ = rCol.GetBlue();
+ }
+ }
+ }
+ else
+ {
+ for(long a=0;a<aSize.Height();a++)
+ {
+ for(long b=0;b<aSize.Width();b++)
+ {
+ const BitmapColor& rCol = pReadAccess->GetPixel(a, b);
+ *pRunner++ = rCol.GetRed();
+ *pRunner++ = rCol.GetGreen();
+ *pRunner++ = rCol.GetBlue();
+ }
+ }
+ }
+ }
+ else
+ {
+ if(pReadAccess->HasPalette())
+ {
+ for(long a=0;a<aSize.Height();a++)
+ {
+ for(long b=0;b<aSize.Width();b++)
+ {
+ const BitmapColor& rCol = pReadAccess->GetPaletteColor(
+ pReadAccess->GetPixel(a, b));
+ *pRunner++ = (rCol.GetRed() + rCol.GetGreen() + rCol.GetBlue()) / 3;
+ }
+ }
+ }
+ else
+ {
+ for(long a=0;a<aSize.Height();a++)
+ {
+ for(long b=0;b<aSize.Width();b++)
+ {
+ const BitmapColor& rCol = pReadAccess->GetPixel(a, b);
+ *pRunner++ = (rCol.GetRed() + rCol.GetGreen() + rCol.GetBlue()) / 3;
+ }
+ }
+ }
+ }
+
+ // Textur das erste mal binden und damit initialisieren
+ rOpenGL.BindTexture(GL_TEXTURE_2D, nTextureName);
+
+ // Jetzt ein glTexImage2D() ausfuehren
+ GLint nInternalFormat;
+ GLint nFormat;
+
+ switch(GetTextureKind())
+ {
+ case Base3DTextureLuminance:
+ nInternalFormat = GL_LUMINANCE;
+ nFormat = GL_LUMINANCE;
+ break;
+ case Base3DTextureIntensity:
+ nInternalFormat = GL_INTENSITY;
+ nFormat = GL_LUMINANCE;
+ break;
+ case Base3DTextureColor:
+ nInternalFormat = GL_RGB;
+ nFormat = GL_RGB;
+ break;
+ }
+
+ rOpenGL.TexImage2D(GL_TEXTURE_2D, 0, nInternalFormat,
+ (GLsizei)aSize.Width(),
+ (GLsizei)aSize.Height(),
+ 0, nFormat, GL_UNSIGNED_BYTE, pBuffer);
+
+ SvMemFree(pBuffer);
+ }
+
+ // Lesezugriff freigeben
+ aBitmap.ReleaseAccess(pReadAccess);
+ }
+
+ // Hinweis auf Veraenderung der Texturart auf jeden Fall elliminieren
+ bTextureKindChanged = FALSE;
+}
+
diff --git a/goodies/source/base3d/b3dtrans.cxx b/goodies/source/base3d/b3dtrans.cxx
new file mode 100644
index 000000000000..0765e2adc001
--- /dev/null
+++ b/goodies/source/base3d/b3dtrans.cxx
@@ -0,0 +1,936 @@
+/*************************************************************************
+ *
+ * $RCSfile: b3dtrans.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _B3D_B3DTRANS_HXX
+#include "b3dtrans.hxx"
+#endif
+
+#ifndef _B3D_BASE3D_HXX
+#include "base3d.hxx"
+#endif
+
+#ifndef _B3D_VOLUM_HXX
+#include "b3dvolum.hxx"
+#endif
+
+/*************************************************************************
+|*
+|* Transformationen fuer alle 3D Ausgaben
+|*
+\************************************************************************/
+
+B3dTransformationSet::B3dTransformationSet()
+{
+ Reset();
+}
+
+/*************************************************************************
+|*
+|* Reset der Werte
+|*
+\************************************************************************/
+
+void B3dTransformationSet::Reset()
+{
+ // Matritzen auf Einheitsmatritzen
+ aObjectTrans.Identity();
+ PostSetObjectTrans();
+
+ aOrientation.Orientation();
+ PostSetOrientation();
+
+ aTexture.Identity();
+
+ fLeftBound = fBottomBound = -1.0;
+ fRightBound = fTopBound = 1.0;
+ fNearBound = 0.001;
+ fFarBound = 1.001;
+
+ eRatio = Base3DRatioGrow;
+ fRatio = 0.0;
+
+ aViewportRectangle = Rectangle(-1, -1, 2, 2);
+ aVisibleRectangle = aViewportRectangle;
+
+ bPerspective = TRUE;
+
+ bProjectionValid = FALSE;
+ bObjectToDeviceValid = FALSE;
+ bWorldToViewValid = FALSE;
+
+ CalcViewport();
+}
+
+/*************************************************************************
+|*
+|* Objekttransformation
+|*
+\************************************************************************/
+
+void B3dTransformationSet::SetObjectTrans(Matrix4D& rObj)
+{
+ aObjectTrans = rObj;
+
+ bObjectToDeviceValid = FALSE;
+ bInvTransObjectToEyeValid = FALSE;
+
+ PostSetObjectTrans();
+}
+
+void B3dTransformationSet::PostSetObjectTrans()
+{
+ // Zuweisen und Inverse bestimmen
+ aInvObjectTrans = aObjectTrans;
+ aInvObjectTrans.Invert();
+}
+
+/*************************************************************************
+|*
+|* Orientierungstransformation
+|*
+\************************************************************************/
+
+#ifndef ICC
+void B3dTransformationSet::SetOrientation( Vector3D& aVRP, Vector3D& aVPN, Vector3D& aVUP)
+#else
+void B3dTransformationSet::SetOrientation( Vector3D aVRP, Vector3D aVPN, Vector3D aVUP)
+#endif
+{
+ aOrientation.Identity();
+ aOrientation.Orientation(Point4D(aVRP), aVPN, aVUP);
+
+ bInvTransObjectToEyeValid = FALSE;
+ bObjectToDeviceValid = FALSE;
+ bWorldToViewValid = FALSE;
+
+ PostSetOrientation();
+}
+
+void B3dTransformationSet::SetOrientation(Matrix4D& mOrient)
+{
+ aOrientation = mOrient;
+
+ bInvTransObjectToEyeValid = FALSE;
+ bObjectToDeviceValid = FALSE;
+ bWorldToViewValid = FALSE;
+
+ PostSetOrientation();
+}
+
+void B3dTransformationSet::PostSetOrientation()
+{
+ // Zuweisen und Inverse bestimmen
+ aInvOrientation = aOrientation;
+ aInvOrientation.Invert();
+}
+
+/*************************************************************************
+|*
+|* Projektionstransformation
+|*
+\************************************************************************/
+
+void B3dTransformationSet::SetProjection(Matrix4D& mProject)
+{
+ aProjection = mProject;
+ PostSetProjection();
+}
+
+const Matrix4D& B3dTransformationSet::GetProjection()
+{
+ if(!bProjectionValid)
+ CalcViewport();
+ return aProjection;
+}
+
+const Matrix4D& B3dTransformationSet::GetInvProjection()
+{
+ if(!bProjectionValid)
+ CalcViewport();
+ return aInvProjection;
+}
+
+void B3dTransformationSet::PostSetProjection()
+{
+ // Zuweisen und Inverse bestimmen
+ aInvProjection = GetProjection();
+ aInvProjection.Invert();
+
+ // Abhaengige Matritzen invalidieren
+ bObjectToDeviceValid = FALSE;
+ bWorldToViewValid = FALSE;
+}
+
+/*************************************************************************
+|*
+|* Texturtransformation
+|*
+\************************************************************************/
+
+void B3dTransformationSet::SetTexture(Matrix4D& rTxt)
+{
+ aTexture = rTxt;
+ PostSetTexture();
+}
+
+void B3dTransformationSet::PostSetTexture()
+{
+}
+
+/*************************************************************************
+|*
+|* Viewport-Transformation
+|*
+\************************************************************************/
+
+void B3dTransformationSet::CalcViewport()
+{
+ // Faktoren fuer die Projektion
+ double fLeft = fLeftBound;
+ double fRight = fRightBound;
+ double fBottom = fBottomBound;
+ double fTop = fTopBound;
+
+ // Soll das Seitenverhaeltnis Beachtung finden?
+ // Falls ja, Bereich der Projektion an Seitenverhaeltnis anpassen
+ if(GetRatio() != 0.0)
+ {
+ // Berechne aktuelles Seitenverhaeltnis der Bounds
+ double fBoundWidth = (double)(aViewportRectangle.GetWidth() + 1);
+ double fBoundHeight = (double)(aViewportRectangle.GetHeight() + 1);
+ double fActRatio;
+ double fFactor;
+
+ if(fBoundWidth != 0.0)
+ fActRatio = fBoundHeight / fBoundWidth;
+
+ switch(eRatio)
+ {
+ case Base3DRatioShrink :
+ {
+ // Kleineren Teil vergroessern
+ if(fActRatio > fRatio)
+ {
+ // X vergroessern
+ fFactor = 1.0 / fActRatio;
+ fRight *= fFactor;
+ fLeft *= fFactor;
+ }
+ else
+ {
+ // Y vergroessern
+ fFactor = fActRatio;
+ fTop *= fFactor;
+ fBottom *= fFactor;
+ }
+ break;
+ }
+ case Base3DRatioGrow :
+ {
+ // GroesserenTeil verkleinern
+ if(fActRatio > fRatio)
+ {
+ // Y verkleinern
+ fFactor = fActRatio;
+ fTop *= fFactor;
+ fBottom *= fFactor;
+ }
+ else
+ {
+ // X verkleinern
+ fFactor = 1.0 / fActRatio;
+ fRight *= fFactor;
+ fLeft *= fFactor;
+ }
+ break;
+ }
+ case Base3DRatioMiddle :
+ {
+ // Mitteln
+ fFactor = ((1.0 / fActRatio) + 1.0) / 2.0;
+ fRight *= fFactor;
+ fLeft *= fFactor;
+ fFactor = (fActRatio + 1.0) / 2.0;
+ fTop *= fFactor;
+ fBottom *= fFactor;
+ break;
+ }
+ }
+ }
+
+ // Ueberschneiden sich Darstellungsflaeche und Objektflaeche?
+ aSetBound = aViewportRectangle;
+
+ // Mit den neuen Werten Projektion und ViewPort setzen
+ Matrix4D aNewProjection;
+ double fDistPart = (fFarBound - fNearBound) * SMALL_DVALUE;
+
+ // Near, Far etwas grosszuegiger setzen, um falsches,
+ // zu kritisches clippen zu verhindern
+ if(bPerspective)
+ aNewProjection.Frustum(fLeft, fRight, fBottom, fTop,
+ fNearBound - fDistPart, fFarBound + fDistPart);
+ else
+ aNewProjection.Ortho(fLeft, fRight, fBottom, fTop,
+ fNearBound - fDistPart, fFarBound + fDistPart);
+
+ // jetzt schon auf gueltig setzen um Endlosschleife zu vermeiden
+ bProjectionValid = TRUE;
+
+ // Neue Projektion setzen
+ SetProjection(aNewProjection);
+
+ // fill parameters for ViewportTransformation
+ // Translation
+ aTranslate[0] = (double)aSetBound.Left() + ((aSetBound.GetWidth() - 1L) / 2.0);
+ aTranslate[1] = (double)aSetBound.Top() + ((aSetBound.GetHeight() - 1L) / 2.0);
+ aTranslate[2] = ZBUFFER_DEPTH_RANGE / 2.0;
+
+ // Skalierung
+ aScale[0] = (aSetBound.GetWidth() - 1L) / 2.0;
+ aScale[1] = (aSetBound.GetHeight() - 1L) / -2.0;
+ aScale[2] = ZBUFFER_DEPTH_RANGE / 2.0;
+
+ // Auf Veraenderung des ViewPorts reagieren
+ PostSetViewport();
+}
+
+void B3dTransformationSet::SetRatio(double fNew)
+{
+ if(fRatio != fNew)
+ {
+ fRatio = fNew;
+ bProjectionValid = FALSE;
+ bObjectToDeviceValid = FALSE;
+ bWorldToViewValid = FALSE;
+ }
+}
+
+void B3dTransformationSet::SetRatioMode(Base3DRatio eNew)
+{
+ if(eRatio != eNew)
+ {
+ eRatio = eNew;
+ bProjectionValid = FALSE;
+ bObjectToDeviceValid = FALSE;
+ bWorldToViewValid = FALSE;
+ }
+}
+
+void B3dTransformationSet::SetDeviceRectangle(double fL, double fR, double fB, double fT,
+ BOOL bBroadCastChange)
+{
+ if(fL != fLeftBound || fR != fRightBound || fB != fBottomBound || fT != fTopBound)
+ {
+ fLeftBound = fL;
+ fRightBound = fR;
+ fBottomBound = fB;
+ fTopBound = fT;
+
+ bProjectionValid = FALSE;
+ bObjectToDeviceValid = FALSE;
+ bWorldToViewValid = FALSE;
+
+ // Aenderung bekanntmachen
+ if(bBroadCastChange)
+ DeviceRectangleChange();
+ }
+}
+
+void B3dTransformationSet::SetDeviceVolume(const B3dVolume& rVol, BOOL bBroadCastChange)
+{
+ SetDeviceRectangle(rVol.MinVec().X(), rVol.MaxVec().X(),
+ rVol.MinVec().Y(), rVol.MaxVec().Y(), bBroadCastChange);
+ SetFrontClippingPlane(rVol.MinVec().Z());
+ SetBackClippingPlane(rVol.MaxVec().Z());
+}
+
+void B3dTransformationSet::DeviceRectangleChange()
+{
+}
+
+void B3dTransformationSet::GetDeviceRectangle(double &fL, double &fR, double& fB, double& fT)
+{
+ fL = fLeftBound;
+ fR = fRightBound;
+ fB = fBottomBound;
+ fT = fTopBound;
+
+ bProjectionValid = FALSE;
+ bObjectToDeviceValid = FALSE;
+ bWorldToViewValid = FALSE;
+}
+
+B3dVolume B3dTransformationSet::GetDeviceVolume()
+{
+ B3dVolume aRet;
+ aRet.MinVec() = Vector3D(fLeftBound, fBottomBound, fNearBound);
+ aRet.MaxVec() = Vector3D(fRightBound, fTopBound, fFarBound);
+ return aRet;
+}
+
+void B3dTransformationSet::SetFrontClippingPlane(double fF)
+{
+ if(fNearBound != fF)
+ {
+ fNearBound = fF;
+ bProjectionValid = FALSE;
+ bObjectToDeviceValid = FALSE;
+ bWorldToViewValid = FALSE;
+ }
+}
+
+void B3dTransformationSet::SetBackClippingPlane(double fB)
+{
+ if(fFarBound != fB)
+ {
+ fFarBound = fB;
+ bProjectionValid = FALSE;
+ bObjectToDeviceValid = FALSE;
+ bWorldToViewValid = FALSE;
+ }
+}
+
+void B3dTransformationSet::SetPerspective(BOOL bNew)
+{
+ if(bPerspective != bNew)
+ {
+ bPerspective = bNew;
+ bProjectionValid = FALSE;
+ bObjectToDeviceValid = FALSE;
+ bWorldToViewValid = FALSE;
+ }
+}
+
+void B3dTransformationSet::SetViewportRectangle(Rectangle& rRect, Rectangle& rVisible)
+{
+ if(rRect != aViewportRectangle || rVisible != aVisibleRectangle)
+ {
+ aViewportRectangle = rRect;
+ aVisibleRectangle = rVisible;
+
+ bProjectionValid = FALSE;
+ bObjectToDeviceValid = FALSE;
+ bWorldToViewValid = FALSE;
+ }
+}
+
+void B3dTransformationSet::PostSetViewport()
+{
+}
+
+const Rectangle& B3dTransformationSet::GetLogicalViewportBounds()
+{
+ if(!bProjectionValid)
+ CalcViewport();
+ return aSetBound;
+}
+
+const Vector3D& B3dTransformationSet::GetScale()
+{
+ if(!bProjectionValid)
+ CalcViewport();
+ return aScale;
+}
+
+const Vector3D& B3dTransformationSet::GetTranslate()
+{
+ if(!bProjectionValid)
+ CalcViewport();
+ return aTranslate;
+}
+
+/*************************************************************************
+|*
+|* Hilfsmatrixberechnungsroutinen
+|*
+\************************************************************************/
+
+void B3dTransformationSet::CalcMatObjectToDevice()
+{
+ // ObjectToDevice berechnen (Orientation * Projection * Object)
+ aObjectToDevice = aObjectTrans;
+ aObjectToDevice *= aOrientation;
+ aObjectToDevice *= GetProjection();
+
+ // auf gueltig setzen
+ bObjectToDeviceValid = TRUE;
+}
+
+const Matrix4D& B3dTransformationSet::GetObjectToDevice()
+{
+ if(!bObjectToDeviceValid)
+ CalcMatObjectToDevice();
+ return aObjectToDevice;
+}
+
+void B3dTransformationSet::CalcMatInvTransObjectToEye()
+{
+ aInvTransObjectToEye = aObjectTrans;
+ aInvTransObjectToEye *= aOrientation;
+ aInvTransObjectToEye.Invert();
+ aInvTransObjectToEye.Transpose();
+
+ // eventuelle Translationen rausschmeissen, da diese
+ // Matrix nur zur Transformation von Vektoren gedacht ist
+ aInvTransObjectToEye[3] = Point4D(0.0, 0.0, 0.0, 1.0);
+
+ // auf gueltig setzen
+ bInvTransObjectToEyeValid = TRUE;
+}
+
+const Matrix4D& B3dTransformationSet::GetInvTransObjectToEye()
+{
+ if(!bInvTransObjectToEyeValid)
+ CalcMatInvTransObjectToEye();
+ return aInvTransObjectToEye;
+}
+
+Matrix4D B3dTransformationSet::GetMatFromObjectToView()
+{
+ Matrix4D aFromObjectToView = GetObjectToDevice();
+
+ aFromObjectToView.Scale(GetScale());
+ aFromObjectToView.Translate(GetTranslate());
+
+ return aFromObjectToView;
+}
+
+void B3dTransformationSet::CalcMatFromWorldToView()
+{
+ aMatFromWorldToView = aOrientation;
+ aMatFromWorldToView *= GetProjection();
+ aMatFromWorldToView.Scale(GetScale());
+ aMatFromWorldToView.Translate(GetTranslate());
+ aInvMatFromWorldToView = aMatFromWorldToView;
+ aInvMatFromWorldToView.Invert();
+
+ // gueltig setzen
+ bWorldToViewValid = TRUE;
+}
+
+const Matrix4D& B3dTransformationSet::GetMatFromWorldToView()
+{
+ if(!bWorldToViewValid)
+ CalcMatFromWorldToView();
+ return aMatFromWorldToView;
+}
+
+const Matrix4D& B3dTransformationSet::GetInvMatFromWorldToView()
+{
+ if(!bWorldToViewValid)
+ CalcMatFromWorldToView();
+ return aInvMatFromWorldToView;
+}
+
+/*************************************************************************
+|*
+|* Direkter Zugriff auf verschiedene Transformationen
+|*
+\************************************************************************/
+
+const Vector3D B3dTransformationSet::WorldToEyeCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetOrientation();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::EyeToWorldCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetInvOrientation();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::EyeToViewCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetProjection();
+ aVec *= GetScale();
+ aVec += GetTranslate();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::ViewToEyeCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec -= GetTranslate();
+ aVec = aVec / GetScale();
+ aVec *= GetInvProjection();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::WorldToViewCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetMatFromWorldToView();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::ViewToWorldCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetInvMatFromWorldToView();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::DeviceToViewCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetScale();
+ aVec += GetTranslate();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::ViewToDeviceCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec -= GetTranslate();
+ aVec = aVec / GetScale();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::ObjectToWorldCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetObjectTrans();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::WorldToObjectCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetInvObjectTrans();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::ObjectToViewCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetObjectTrans();
+ aVec *= GetMatFromWorldToView();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::ViewToObjectCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetInvMatFromWorldToView();
+ aVec *= GetInvObjectTrans();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::ObjectToEyeCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetObjectTrans();
+ aVec *= GetOrientation();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::EyeToObjectCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetInvOrientation();
+ aVec *= GetInvObjectTrans();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::DeviceToEyeCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetInvProjection();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::EyeToDeviceCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetProjection();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::InvTransObjectToEye(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetInvTransObjectToEye();
+ return aVec;
+}
+
+const Vector3D B3dTransformationSet::TransTextureCoor(const Vector3D& rVec)
+{
+ Vector3D aVec(rVec);
+ aVec *= GetTexture();
+ return aVec;
+}
+
+/*************************************************************************
+|*
+|* Konstruktor B3dViewport
+|*
+\************************************************************************/
+
+B3dViewport::B3dViewport()
+: B3dTransformationSet(),
+ aVRP(0, 0, 0),
+ aVPN(0, 0, 1),
+ aVUV(0, 1, 0)
+{
+ CalcOrientation();
+}
+
+void B3dViewport::SetVRP(const Vector3D& rNewVRP)
+{
+ aVRP = rNewVRP;
+ CalcOrientation();
+}
+
+void B3dViewport::SetVPN(const Vector3D& rNewVPN)
+{
+ aVPN = rNewVPN;
+ CalcOrientation();
+}
+
+void B3dViewport::SetVUV(const Vector3D& rNewVUV)
+{
+ aVUV = rNewVUV;
+ CalcOrientation();
+}
+
+void B3dViewport::SetViewportValues(
+ const Vector3D& rNewVRP,
+ const Vector3D& rNewVPN,
+ const Vector3D& rNewVUV)
+{
+ aVRP = rNewVRP;
+ aVPN = rNewVPN;
+ aVUV = rNewVUV;
+ CalcOrientation();
+}
+
+void B3dViewport::CalcOrientation()
+{
+ SetOrientation(aVRP, aVPN, aVUV);
+}
+
+/*************************************************************************
+|*
+|* Konstruktor B3dViewport
+|*
+\************************************************************************/
+
+B3dCamera::B3dCamera(const Vector3D& rPos, const Vector3D& rLkAt,
+ double fFocLen, double fBnkAng, BOOL bUseFocLen)
+: B3dViewport(),
+ aPosition(rPos),
+ aCorrectedPosition(rPos),
+ aLookAt(rLkAt),
+ fFocalLength(fFocLen),
+ fBankAngle(fBnkAng),
+ bUseFocalLength(bUseFocLen)
+{
+ CalcNewViewportValues();
+}
+
+void B3dCamera::SetPosition(const Vector3D& rNewPos)
+{
+ if(rNewPos != aPosition)
+ {
+ // Zuweisen
+ aCorrectedPosition = aPosition = rNewPos;
+
+ // Neuberechnung
+ CalcNewViewportValues();
+ }
+}
+
+void B3dCamera::SetLookAt(const Vector3D& rNewLookAt)
+{
+ if(rNewLookAt != aLookAt)
+ {
+ // Zuweisen
+ aLookAt = rNewLookAt;
+
+ // Neuberechnung
+ CalcNewViewportValues();
+ }
+}
+
+void B3dCamera::SetPositionAndLookAt(const Vector3D& rNewPos, const Vector3D& rNewLookAt)
+{
+ if(rNewPos != aPosition || rNewLookAt != aLookAt)
+ {
+ // Zuweisen
+ aPosition = rNewPos;
+ aLookAt = rNewLookAt;
+
+ // Neuberechnung
+ CalcNewViewportValues();
+ }
+}
+
+void B3dCamera::SetFocalLength(double fLen)
+{
+ if(fLen != fFocalLength)
+ {
+ // Zuweisen
+ if(fLen < 5.0)
+ fLen = 5.0;
+ fFocalLength = fLen;
+
+ // Neuberechnung
+ CalcNewViewportValues();
+ }
+}
+
+void B3dCamera::SetBankAngle(double fAngle)
+{
+ if(fAngle != fBankAngle)
+ {
+ // Zuweisen
+ fBankAngle = fAngle;
+
+ // Neuberechnung
+ CalcNewViewportValues();
+ }
+}
+
+void B3dCamera::SetUseFocalLength(BOOL bNew)
+{
+ if(bNew != (BOOL)bUseFocalLength)
+ {
+ // Zuweisen
+ bUseFocalLength = bNew;
+
+ // Neuberechnung
+ CalcNewViewportValues();
+ }
+}
+
+void B3dCamera::DeviceRectangleChange()
+{
+ // call parent
+ B3dViewport::DeviceRectangleChange();
+
+ // Auf Aenderung reagieren
+ CalcNewViewportValues();
+}
+
+void B3dCamera::CalcNewViewportValues()
+{
+ Vector3D aViewVector = aPosition - aLookAt;
+ Vector3D aNewVPN = aViewVector;
+
+ Vector3D aNewVUV(0.0, 1.0, 0.0);
+ if(aNewVPN.GetLength() < aNewVPN.Y())
+ aNewVUV.X() = 0.5;
+
+ aNewVUV.Normalize();
+ aNewVPN.Normalize();
+
+ Vector3D aNewToTheRight = aNewVPN;
+ aNewToTheRight |= aNewVUV;
+ aNewToTheRight.Normalize();
+ aNewVUV = aNewToTheRight | aNewVPN;
+ aNewVUV.Normalize();
+
+ SetViewportValues(aPosition, aNewVPN, aNewVUV);
+ if(CalcFocalLength())
+ SetViewportValues(aCorrectedPosition, aNewVPN, aNewVUV);
+
+ if(fBankAngle != 0.0)
+ {
+ Matrix4D aRotMat;
+ aRotMat.RotateZ(fBankAngle);
+ Vector3D aUp(0.0, 1.0, 0.0);
+ aUp *= aRotMat;
+ aUp = EyeToWorldCoor(aUp);
+ aUp.Normalize();
+ SetVUV(aUp);
+ }
+}
+
+BOOL B3dCamera::CalcFocalLength()
+{
+ double fWidth = GetDeviceRectangleWidth();
+ BOOL bRetval = FALSE;
+
+ if(bUseFocalLength)
+ {
+ // Position aufgrund der FocalLength korrigieren
+ aCorrectedPosition = Vector3D(0.0, 0.0, fFocalLength * fWidth / 35.0);
+ aCorrectedPosition = EyeToWorldCoor(aCorrectedPosition);
+ bRetval = TRUE;
+ }
+ else
+ {
+ // FocalLength anhand der Position anpassen
+ Vector3D aOldPosition;
+ aOldPosition = WorldToEyeCoor(aOldPosition);
+ if(fWidth != 0.0)
+ fFocalLength = aOldPosition.Z() / fWidth * 35.0;
+ if(fFocalLength < 5.0)
+ fFocalLength = 5.0;
+ }
+ return bRetval;
+}
+
diff --git a/goodies/source/base3d/base3d.cxx b/goodies/source/base3d/base3d.cxx
new file mode 100644
index 000000000000..6a45cb2fb01d
--- /dev/null
+++ b/goodies/source/base3d/base3d.cxx
@@ -0,0 +1,1268 @@
+/*************************************************************************
+ *
+ * $RCSfile: base3d.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _B3D_BASE3D_HXX
+#include "base3d.hxx"
+#endif
+
+#ifndef _B3D_B3DENTITY_HXX
+#include "b3dentty.hxx"
+#endif
+
+#ifndef _B3D_B3DTEX_HXX
+#include "b3dtex.hxx"
+#endif
+
+#ifndef _B3D_B3DOPNGL_HXX
+#include "b3dopngl.hxx"
+#endif
+
+#ifndef _B3D_B3DDEFLT_HXX
+#include "b3ddeflt.hxx"
+#endif
+
+#ifndef _B3D_B3DPRINT_HXX
+#include "b3dprint.hxx"
+#endif
+
+#ifndef _B3D_B3DGEOM_HXX
+#include "b3dgeom.hxx"
+#endif
+
+#ifndef _B3D_B3DTRANS_HXX
+#include "b3dtrans.hxx"
+#endif
+
+#ifndef _SHL_HXX
+#include <tools/shl.hxx>
+#endif
+
+#ifndef _SV_POLY_HXX
+#include <vcl/poly.hxx>
+#endif
+
+#ifndef _SFXINIPROP_HXX
+#include <svtools/iniprop.hxx>
+#endif
+
+#ifndef _SFXINIMGR_HXX
+#include <svtools/iniman.hxx>
+#endif
+
+/*************************************************************************
+|*
+|* Konstruktor B3dGlobalData
+|*
+\************************************************************************/
+
+B3dGlobalData::B3dGlobalData()
+{
+}
+
+/*************************************************************************
+|*
+|* Destruktor B3dGlobalData
+|*
+\************************************************************************/
+
+B3dGlobalData::~B3dGlobalData()
+{
+}
+
+/*************************************************************************
+|*
+|* Konstruktor Base3D
+|*
+\************************************************************************/
+
+Base3D::Base3D(OutputDevice* pOutDev)
+: OutDev3D(),
+ pDevice(pOutDev),
+ eObjectMode(Base3DPoints),
+ aCurrentColor(Color(0xff, 0xff, 0xff)),
+ aComplexPolygon(),
+ eRenderModeFront(Base3DRenderFill),
+ eRenderModeBack(Base3DRenderFill),
+ eShadeModel(Base3DSmooth),
+ eCullMode(Base3DCullNone),
+ fPointSize(1.0),
+ fLineWidth(1.0),
+ pActiveTexture(NULL),
+ pTransformationSet(NULL),
+ pLightGroup(NULL),
+ aMaterialFront(),
+ aMaterialBack(),
+ nDisplayQuality(127),
+ bEdgeFlag(TRUE),
+ bContextIsValid(TRUE),
+ bPolyOffsetFill(FALSE),
+ bPolyOffsetLine(FALSE),
+ bPolyOffsetPoint(FALSE),
+ bScissorRegionActive(FALSE),
+ bDitherActive(TRUE)
+{
+ // Grundsaetzliche Materialeigenschaften setzen
+ ResetMaterial(Base3DMaterialFrontAndBack);
+
+ // Fuer OS/2 die FP-Exceptions abschalten
+#if defined(OS2)
+#define SC_FPEXCEPTIONS_ON() _control87( MCW_EM, 0 )
+#define SC_FPEXCEPTIONS_OFF() _control87( MCW_EM, MCW_EM )
+ SC_FPEXCEPTIONS_OFF();
+#endif
+
+ // Fuer WIN95/NT die FP-Exceptions abschalten
+#if defined(WNT) || defined(WIN)
+#define SC_FPEXCEPTIONS_ON() _control87( _MCW_EM, 0 )
+#define SC_FPEXCEPTIONS_OFF() _control87( _MCW_EM, _MCW_EM )
+ SC_FPEXCEPTIONS_OFF();
+#endif
+}
+
+/*************************************************************************
+|*
+|* Destruktor Base3D
+|*
+\************************************************************************/
+
+Base3D::~Base3D()
+{
+}
+
+/*************************************************************************
+|*
+|* Erzeuge einen Base3D Kontext in Anhaengigkeit vom uebergebenen
+|* OutputDevice und trage Ihn dort ein
+|*
+\************************************************************************/
+
+Base3D* Base3D::Create(OutputDevice* pOutDev, BOOL bForcePrinter)
+{
+ Base3D* pRetval = NULL;
+ if(pOutDev)
+ {
+ // Anforderungen feststellen
+ BOOL bOwnDevice = FALSE;
+ if(pOutDev->GetOutDevType() == OUTDEV_VIRDEV
+ || pOutDev->GetOutDevType() == OUTDEV_PRINTER
+ || pOutDev->GetConnectMetaFile() != NULL)
+ bOwnDevice = TRUE;
+
+ // Existiert schon ein 3D-Kontext, der auch an dieses
+ // OutputDevice gebunden ist?
+ if(pOutDev->Get3DContext()
+ && ((Base3D*)(pOutDev->Get3DContext()))->GetOutputDevice() == pOutDev)
+ {
+ pRetval = (Base3D*)pOutDev->Get3DContext();
+ }
+
+ // Falls Ja, ist er den Anforderungen gewachsen?
+ if(pRetval)
+ {
+ BOOL bForceNew(FALSE);
+
+ if((!bForceNew) && (bOwnDevice)&&(pRetval->GetBase3DType() == BASE3D_TYPE_OPENGL))
+ {
+ bForceNew = TRUE;
+ }
+
+ if((!bForceNew) && (bForcePrinter)&&(pRetval->GetBase3DType() != BASE3D_TYPE_PRINTER))
+ {
+ bForceNew = TRUE;
+ }
+
+ if((!bForceNew) && (!bForcePrinter)&&(pRetval->GetBase3DType() == BASE3D_TYPE_PRINTER))
+ {
+ bForceNew = TRUE;
+ }
+
+ if(!bForceNew && !bOwnDevice)
+ {
+ // Versuchen, einen OpenGL Kontext zu bekommen? Teste das
+ // globale Flag aus der .INI
+ BOOL bUseOpenGL = FALSE;
+ String aTmp = SfxIniManager::Get()->Get( SFX_KEY_3D_OPENGL );
+
+ if(aTmp.Len() && aTmp.GetChar(0) != sal_Unicode('0'))
+ bUseOpenGL = TRUE;
+
+ if((bUseOpenGL && pRetval->GetBase3DType() != BASE3D_TYPE_OPENGL)
+ || (!bUseOpenGL && pRetval->GetBase3DType() == BASE3D_TYPE_OPENGL))
+ {
+ bForceNew = TRUE;
+ bOwnDevice = !bUseOpenGL;
+ }
+ }
+
+ if(bForceNew)
+ {
+ pRetval->Destroy(pOutDev);
+ pRetval = NULL;
+ }
+ }
+
+ if(!pRetval)
+ {
+ // zerstoere altes Base3D, war nicht mehr an das
+ // OutputDevice gebunden
+ if(pOutDev->Get3DContext())
+ pOutDev->Get3DContext()->Destroy(pOutDev);
+
+ // erzeuge neues Base3D, je nach Anforderungen
+ if(bForcePrinter)
+ {
+ pRetval = new Base3DPrinter(pOutDev);
+ }
+ else if(bOwnDevice)
+ {
+ pRetval = new Base3DDefault(pOutDev);
+ }
+ else
+ {
+ // Versuche OpenGL, fallback auf default
+ // falls OpenGL nicht verfuegbar
+ pRetval = CreateScreenRenderer(pOutDev);
+ }
+
+ // 3D-Kontext eintragen als Renderer im angegebenen OutputDevice
+ if(pRetval)
+ pOutDev->Set3DContext((Base3D*)pRetval);
+ }
+ }
+ return pRetval;
+}
+
+/*************************************************************************
+|*
+|* Versuche, einen 3D Kontext zur Bildschirmdarstellung zu generieren.
+|* Diese Funktion wird nur bei WNT realisiert. Sie muss entscheiden,
+|* ob OpenGL-DLL's verfuegbar sind und entsprechend den OpenGL
+|* Renderer oder einen Default Renderer erzeugen.
+|*
+\************************************************************************/
+
+Base3D* Base3D::CreateScreenRenderer(OutputDevice* pOutDev)
+{
+ // OpenGL Kontext erzeugen
+ Base3D* pRetval = NULL;
+
+ // Versuchen, einen OpenGL Kontext zu bekommen? Teste das
+ // globale Flag aus der .INI
+ BOOL bUseOpenGL = FALSE;
+ String aTmp = SfxIniManager::Get()->Get( SFX_KEY_3D_OPENGL );
+
+ if(aTmp.Len() && aTmp.GetChar(0) != sal_Unicode('0'))
+ bUseOpenGL = TRUE;
+
+ // Versuchen, einen OpenGL Kontext zu bekommen
+ if(bUseOpenGL)
+ pRetval = new Base3DOpenGL(pOutDev);
+
+ if(!pRetval || !pRetval->IsContextValid())
+ {
+ if(pRetval)
+ {
+ delete pRetval;
+ pRetval = NULL;
+ }
+ }
+
+ // versuche alternativ, einen Default Renderer zu inkarnieren
+ if(!pRetval)
+ pRetval = new Base3DDefault(pOutDev);
+
+ return pRetval;
+}
+
+/*************************************************************************
+|*
+|* Entferne den Kontext aus dem assoziierten OutputDevice und zerstoere
+|* sich selbst
+|*
+|* Als Platzhalter fuer den Zeiger auf einen Kontext im OutputDevice
+|* wird momentan pTheCurrentBase3DIncarnation benutzt
+|*
+\************************************************************************/
+
+void Base3D::Destroy(OutputDevice *pOutDev)
+{
+ Base3D* pTmp;
+ if((pTmp = (Base3D*)GetOutputDevice()->Get3DContext()) == this)
+ {
+ GetOutputDevice()->Set3DContext(NULL);
+ delete pTmp;
+ }
+}
+
+/*************************************************************************
+|*
+|* TransformationSet setzen
+|*
+\************************************************************************/
+
+void Base3D::SetTransformationSet(B3dTransformationSet* pSet)
+{
+ // Aktuelles TransformationSet eintragen
+ pTransformationSet = pSet;
+}
+
+/*************************************************************************
+|*
+|* Beleuchtung setzen
+|*
+\************************************************************************/
+
+void Base3D::SetLightGroup(B3dLightGroup* pSet, BOOL bSetGlobal)
+{
+ // Aktuelle Beleuchtung eintragen
+ pLightGroup = pSet;
+}
+
+/*************************************************************************
+|*
+|* Scissoring Region setzen
+|*
+\************************************************************************/
+
+void Base3D::SetScissorRegionPixel(const Rectangle& rRect, BOOL bActivate)
+{
+ aScissorRectangle = rRect;
+ ActivateScissorRegion(bActivate);
+}
+
+void Base3D::SetScissorRegion(const Rectangle& rRect, BOOL bActivate)
+{
+ SetScissorRegionPixel(pDevice->LogicToPixel(rRect), bActivate);
+}
+
+/*************************************************************************
+|*
+|* Scissoring aktivieren/deaktivieren
+|*
+\************************************************************************/
+
+void Base3D::ActivateScissorRegion(BOOL bNew)
+{
+ if(bNew != bScissorRegionActive)
+ bScissorRegionActive = bNew;
+}
+
+/*************************************************************************
+|*
+|* Dithering setzen
+|*
+\************************************************************************/
+
+void Base3D::SetDither(BOOL bNew)
+{
+ bDitherActive = bNew;
+}
+
+/*************************************************************************
+|*
+|* Objektmodus holen
+|*
+\************************************************************************/
+
+Base3DObjectMode Base3D::GetObjectMode()
+{
+ return eObjectMode;
+}
+
+/*************************************************************************
+|*
+|* Ein neues Primitiv vom Typ nMode starten
+|*
+\************************************************************************/
+
+void Base3D::StartPrimitive(Base3DObjectMode eMode)
+{
+ eObjectMode = eMode;
+ if(eObjectMode > Base3DPolygon)
+ {
+ switch(eObjectMode)
+ {
+ case Base3DComplexPolygonCut :
+ {
+ // Neues Polygon beginnen
+ aComplexPolygon.SetTestForCut(TRUE);
+ aComplexPolygon.StartPrimitive();
+ break;
+ }
+ case Base3DComplexPolygon :
+ {
+ // Neues Polygon beginnen
+ aComplexPolygon.SetTestForCut(FALSE);
+ aComplexPolygon.StartPrimitive();
+ break;
+ }
+ }
+ }
+ else
+ {
+ ImplStartPrimitive();
+ }
+}
+
+/*************************************************************************
+|*
+|* Primitiv beenden
+|*
+\************************************************************************/
+
+void Base3D::EndPrimitive()
+{
+ if(eObjectMode > Base3DPolygon)
+ {
+ switch(eObjectMode)
+ {
+ case Base3DComplexPolygon :
+ case Base3DComplexPolygonCut :
+ {
+ // Selbst fuer Darstellung sorgen
+ aComplexPolygon.EndPrimitive(this);
+ break;
+ }
+ }
+ }
+ else
+ {
+ ImplEndPrimitive();
+ }
+}
+
+/*************************************************************************
+|*
+|* Ein Objekt in Form einer B3dGeometry direkt ausgeben
+|*
+\************************************************************************/
+
+void Base3D::DrawPolygonGeometry(B3dGeometry& rGeometry, BOOL bOutline)
+{
+ // Buckets der Geometrie holen
+ B3dEntityBucket& rEntityBucket = rGeometry.GetEntityBucket();
+ GeometryIndexValueBucket& rIndexBucket = rGeometry.GetIndexBucket();
+
+ UINT32 nPolyCounter = 0;
+ UINT32 nEntityCounter = 0;
+ UINT32 nUpperBound;
+
+ while(nPolyCounter < rIndexBucket.Count())
+ {
+ // Naechstes Primitiv
+ nUpperBound = rIndexBucket[nPolyCounter].GetIndex();
+
+ if(bOutline)
+ {
+ // Polygon als Outline ausgeben
+ SetRenderMode(Base3DRenderLine);
+ SetPolygonOffset(Base3DPolygonOffsetLine, TRUE);
+
+ // ALLE Linien Zeichnen
+ SetCullMode(Base3DCullNone);
+ }
+ else
+ {
+ // Polygone gefuellt ausgeben
+ SetRenderMode(Base3DRenderFill);
+ SetPolygonOffset(Base3DPolygonOffsetLine, FALSE);
+ }
+
+ if(rIndexBucket[nPolyCounter++].GetMode() == B3D_INDEX_MODE_LINE)
+ {
+ eObjectMode = Base3DLineStrip;
+ }
+ else
+ {
+ eObjectMode = Base3DPolygon;
+ }
+
+ // Neues Polygon beginnen
+ ImplStartPrimitive();
+
+ // Polygon ausgeben
+ while(nEntityCounter < nUpperBound)
+ {
+ B3dEntity& rEntity = ImplGetFreeEntity();
+ rEntity = rEntityBucket[nEntityCounter++];
+ if(bOutline)
+ {
+ rEntity.SetNormalUsed(FALSE);
+ rEntity.SetTexCoorUsed(FALSE);
+ SetEdgeFlag(rEntity.IsEdgeVisible());
+ }
+ ImplPostAddVertex(rEntity);
+ }
+
+ // Primitiv abschliessen
+ ImplEndPrimitive();
+ }
+}
+
+/*************************************************************************
+|*
+|* Direkter Zugriff auf B3dMaterial fuer abgeleitete Klassen
+|*
+\************************************************************************/
+
+B3dMaterial& Base3D::GetMaterialObject(Base3DMaterialMode eMode)
+{
+ if(eMode == Base3DMaterialFront)
+ return aMaterialFront;
+ return aMaterialBack;
+}
+
+/*************************************************************************
+|*
+|* geometrische Daten uebernehmen
+|*
+\************************************************************************/
+
+void Base3D::AddVertex(Vector3D& rVertex)
+{
+ // Platz fuer neue Daten holen
+ B3dEntity& rEntity = GetFreeEntity();
+ rEntity.Reset();
+
+ // geometrische Daten
+ rEntity.Point() = Point4D(rVertex);
+ rEntity.SetValid();
+
+ // Nachbehandlung
+ PostAddVertex(rEntity);
+}
+
+void Base3D::AddVertex(Vector3D& rVertex, Vector3D& rNormal)
+{
+ // Platz fuer neue Daten holen
+ B3dEntity& rEntity = GetFreeEntity();
+ rEntity.Reset();
+
+ // geometrische Daten
+ rEntity.Point() = Point4D(rVertex);
+ rEntity.SetValid();
+
+ // Normale
+ if(GetLightGroup() && GetLightGroup()->IsLightingEnabled())
+ {
+ rEntity.Normal() = rNormal;
+ rEntity.SetNormalUsed();
+ }
+
+ // Nachbehandlung
+ PostAddVertex(rEntity);
+}
+
+void Base3D::AddVertex(Vector3D& rVertex, Vector3D& rNormal,
+ Vector3D& rTexPos)
+{
+ // Platz fuer neue Daten holen
+ B3dEntity& rEntity = GetFreeEntity();
+ rEntity.Reset();
+
+ // geometrische Daten
+ rEntity.Point() = Point4D(rVertex);
+ rEntity.SetValid();
+
+ // Normale
+ if(GetLightGroup() && GetLightGroup()->IsLightingEnabled())
+ {
+ rEntity.Normal() = rNormal;
+ rEntity.SetNormalUsed();
+ }
+
+ // Texturdaten
+ rEntity.TexCoor() = rTexPos;
+ rEntity.SetTexCoorUsed();
+
+ // Nachbehandlung
+ PostAddVertex(rEntity);
+}
+
+void Base3D::AddVertex(B3dEntity& rEnt)
+{
+ // Platz fuer neue Daten holen
+ B3dEntity& rEntity = GetFreeEntity();
+
+ // Kopieren
+ rEntity = rEnt;
+
+ // Nachbehandlung
+ PostAddVertex(rEntity);
+}
+
+void Base3D::PostAddVertex(B3dEntity& rEntity)
+{
+ // Flag fuer die Sichtbarkeit von Kanten kopieren
+ rEntity.SetEdgeVisible(GetEdgeFlag());
+
+ // aktuelle Farbe eintragen
+ rEntity.Color().SetColor(GetColor().GetColor());
+
+ if(eObjectMode > Base3DPolygon)
+ {
+ switch(eObjectMode)
+ {
+ case Base3DComplexPolygon :
+ case Base3DComplexPolygonCut :
+ {
+ // Punkt ist nun ausgefuellt
+ aComplexPolygon.PostAddVertex(rEntity);
+ break;
+ }
+ }
+ }
+ else
+ {
+ ImplPostAddVertex(rEntity);
+ }
+}
+
+/*************************************************************************
+|*
+|* Platz fuer neuen Punkt anfordern
+|*
+\************************************************************************/
+
+B3dEntity& Base3D::GetFreeEntity()
+{
+ if(eObjectMode > Base3DPolygon)
+ {
+ switch(eObjectMode)
+ {
+ case Base3DComplexPolygon :
+ case Base3DComplexPolygonCut :
+ {
+ // Im eigenen Buffer anlegen
+ return aComplexPolygon.GetFreeEntity();
+ break;
+ }
+ }
+ }
+ return ImplGetFreeEntity();
+}
+
+/*************************************************************************
+|*
+|* Farbe setzen
+|*
+\************************************************************************/
+
+void Base3D::SetColor(Color aNew)
+{
+ // Farbe setzen
+ if(GetOutputDevice()->GetDrawMode() & DRAWMODE_GRAYFILL)
+ {
+ // Graustufen
+ UINT8 nLuminance = aNew.GetLuminance();
+ aCurrentColor = Color(nLuminance, nLuminance, nLuminance);
+ }
+ else if(GetOutputDevice()->GetDrawMode() & DRAWMODE_WHITEFILL)
+ {
+ // Keine Ausgabe, hier Schwarz als Farbe setzen, wird
+ // als Linienfarbe benutzt
+ aCurrentColor = Color(COL_BLACK);
+ }
+ else
+ {
+ // Normale Farbausgabe
+ aCurrentColor = aNew;
+ }
+}
+
+/*************************************************************************
+|*
+|* Farbe liefern
+|*
+\************************************************************************/
+
+Color Base3D::GetColor()
+{
+ return aCurrentColor;
+}
+
+/*************************************************************************
+|*
+|* Materialeigenschaften setzen
+|*
+\************************************************************************/
+
+void Base3D::SetMaterial(Color aNew,
+ Base3DMaterialValue eVal,
+ Base3DMaterialMode eMode)
+{
+ Color aSource;
+ if(GetOutputDevice()->GetDrawMode() & DRAWMODE_GRAYFILL)
+ {
+ // Graustufen
+ UINT8 nLuminance = aNew.GetLuminance();
+ aSource.SetRed(nLuminance);
+ aSource.SetGreen(nLuminance);
+ aSource.SetBlue(nLuminance);
+ aSource.SetTransparency(aNew.GetTransparency());
+ }
+ else if(GetOutputDevice()->GetDrawMode() & DRAWMODE_WHITEFILL)
+ {
+ // Keine Ausgabe, hier Weiss als Farbe setzen
+ aSource = Color(COL_WHITE);
+ }
+ else
+ {
+ // Normale Farbausgabe
+ aSource = aNew;
+ }
+
+ if(eMode == Base3DMaterialFrontAndBack
+ || eMode == Base3DMaterialFront)
+ {
+ aMaterialFront.SetMaterial(aSource, eVal);
+ }
+ if(eMode == Base3DMaterialFrontAndBack
+ || eMode == Base3DMaterialBack)
+ {
+ aMaterialBack.SetMaterial(aSource, eVal);
+ }
+}
+
+/*************************************************************************
+|*
+|* Materialeigenschaften abfragen
+|*
+\************************************************************************/
+
+Color Base3D::GetMaterial(Base3DMaterialValue eVal,
+ Base3DMaterialMode eMode)
+{
+ if(eMode == Base3DMaterialFrontAndBack
+ || eMode == Base3DMaterialFront)
+ {
+ return aMaterialFront.GetMaterial(eVal);
+ }
+ return aMaterialBack.GetMaterial(eVal);
+}
+
+/*************************************************************************
+|*
+|* Materialeigenschaften setzen, exponent der specular-Eigenschaft
+|*
+\************************************************************************/
+
+void Base3D::SetShininess(UINT16 nExponent,
+ Base3DMaterialMode eMode)
+{
+ if(eMode == Base3DMaterialFrontAndBack
+ || eMode == Base3DMaterialFront)
+ {
+ aMaterialFront.SetShininess(nExponent);
+ }
+ if(eMode == Base3DMaterialFrontAndBack
+ || eMode == Base3DMaterialBack)
+ {
+ aMaterialBack.SetShininess(nExponent);
+ }
+}
+
+/*************************************************************************
+|*
+|* Materialeigenschaften abfragen, exponent der specular-Eigenschaft
+|*
+\************************************************************************/
+
+UINT16 Base3D::GetShininess(Base3DMaterialMode eMode)
+{
+ if(eMode == Base3DMaterialFrontAndBack
+ || eMode == Base3DMaterialFront)
+ {
+ return aMaterialFront.GetShininess();
+ }
+ return aMaterialBack.GetShininess();
+}
+
+/*************************************************************************
+|*
+|* Materialeigenschaften auf Ausgangszustand
+|*
+\************************************************************************/
+
+void Base3D::ResetMaterial(Base3DMaterialMode eMode)
+{
+ Color aColor(255, 51, 51, 51);
+ SetMaterial(aColor, Base3DMaterialAmbient, eMode);
+ aColor.SetColor(TRGB_COLORDATA(255, 204, 204, 204));
+ SetMaterial(aColor, Base3DMaterialDiffuse, eMode);
+ aColor.SetColor(TRGB_COLORDATA(255, 0, 0, 0));
+ SetMaterial(aColor, Base3DMaterialSpecular, eMode);
+ aColor.SetColor(TRGB_COLORDATA(255, 0, 0, 0));
+ SetMaterial(aColor, Base3DMaterialEmission, eMode);
+ SetShininess(0, eMode);
+}
+
+/*************************************************************************
+|*
+|* GlobalData holen
+|*
+\************************************************************************/
+
+B3dGlobalData& Base3D::GetGlobalData()
+{
+ B3dGlobalData** ppGlobalData = (B3dGlobalData**)GetAppData(SHL_BASE3D);
+ if(*ppGlobalData)
+ return **ppGlobalData;
+
+ // GlobalData anlegen
+ *ppGlobalData = new B3dGlobalData;
+ return **ppGlobalData;
+}
+
+/*************************************************************************
+|*
+|* TextureStore aus GlobalData holen
+|*
+\************************************************************************/
+
+B3dTextureStore& Base3D::GetTextureStore()
+{
+ return GetGlobalData().GetTextureStore();
+}
+
+/*************************************************************************
+|*
+|* Textur mit den angegebenen Attributen als Grundlage anfordern.
+|*
+\************************************************************************/
+
+B3dTexture* Base3D::ObtainTexture(TextureAttributes& rAtt)
+{
+ B3dTexture* pRetval = NULL;
+
+ // Textur suchen und bei Treffer zurueckgeben
+ B3dTextureStore& rTextureStore = GetTextureStore();
+ for(UINT16 a=0;a<rTextureStore.Count();a++)
+ {
+ if(rTextureStore[a]->GetAttributes() == rAtt)
+ {
+ pRetval = rTextureStore[a];
+ pRetval->Touch();
+ }
+ else
+ {
+ rTextureStore[a]->DecrementUsageCount();
+
+ // Auf zu loeschende Texturen testen
+ if(!rTextureStore[a]->GetUsageCount())
+ {
+ B3dTexture *pTex = rTextureStore[a];
+ rTextureStore.Remove(a);
+ DestroyTexture(pTex);
+ a--;
+ }
+ }
+ }
+
+ // Textur zurueckgeben
+ return pRetval;
+}
+
+/*************************************************************************
+|*
+|* Textur mit den angegebenen Attributen als Grundlage anfordern. Falls
+|* eine solche Textur nicht existiert, erzeuge eine und gib diese zurueck
+|*
+\************************************************************************/
+
+B3dTexture* Base3D::ObtainTexture(TextureAttributes& rAtt, Bitmap& rBitmap)
+{
+ B3dTexture* pRetval = ObtainTexture(rAtt);
+
+ if(!pRetval)
+ {
+ // Existiert tatsaechlich nicht, generiere eine neue Textur
+ B3dTextureStore& rTextureStore = GetTextureStore();
+
+ pRetval = CreateTexture(rAtt, rBitmap);
+ rTextureStore.Insert((const B3dTexture*&)pRetval, rTextureStore.Count());
+ }
+
+ // Textur zurueckgeben
+ return pRetval;
+}
+
+/*************************************************************************
+|*
+|* Gezielt eine Textur freigeben
+|*
+\************************************************************************/
+
+void Base3D::DeleteTexture(TextureAttributes& rAtt)
+{
+ B3dTexture* pTexture = NULL;
+
+ // Textur suchen
+ B3dTextureStore& rTextureStore = GetTextureStore();
+ UINT16 a;
+ for(a=0;a<rTextureStore.Count();a++)
+ {
+ if(rTextureStore[a]->GetAttributes() == rAtt)
+ {
+ pTexture = rTextureStore[a];
+ }
+ }
+
+ if(pTexture)
+ {
+ if(pTexture == pActiveTexture)
+ pActiveTexture = NULL;
+
+ rTextureStore.Remove(a);
+ DestroyTexture(pTexture);
+ }
+}
+
+/*************************************************************************
+|*
+|* Alle Texturen freigeben
+|*
+\************************************************************************/
+
+void Base3D::DeleteAllTextures()
+{
+ pActiveTexture = NULL;
+
+ B3dTextureStore& rTextureStore = GetTextureStore();
+ while(rTextureStore.Count())
+ {
+ B3dTexture *pTex = rTextureStore[0];
+ rTextureStore.Remove(0);
+ DestroyTexture(pTex);
+ }
+}
+
+/*************************************************************************
+|*
+|* Ein Textur-Objekt inkarnieren
+|*
+\************************************************************************/
+
+B3dTexture* Base3D::CreateTexture(TextureAttributes& rAtt, Bitmap& rBitmap)
+{
+ B3dTexture* pRetval = new B3dTexture(rAtt, rBitmap);
+ DBG_ASSERT(pRetval,"AW: Kein Speicher fuer Textur bekommen!");
+ return pRetval;
+}
+
+/*************************************************************************
+|*
+|* Normale Textur loeschen
+|*
+\************************************************************************/
+
+void Base3D::DestroyTexture(B3dTexture* pTex)
+{
+ delete pTex;
+}
+
+/*************************************************************************
+|*
+|* Aktuell zu benutzende Textur setzen
+|*
+\************************************************************************/
+
+void Base3D::SetActiveTexture(B3dTexture* pTex)
+{
+ if(pTex)
+ {
+ if(GetOutputDevice()->GetDrawMode() & DRAWMODE_GRAYFILL)
+ {
+ // Graustufen
+ pTex->SetTextureKind(Base3DTextureIntensity);
+ }
+ else if(GetOutputDevice()->GetDrawMode() & DRAWMODE_WHITEFILL)
+ {
+ // Keine Ausgabe, keine Textur setzen
+ pTex = NULL;
+ }
+ }
+
+ // ... und setzen
+ pActiveTexture = pTex;
+}
+
+/*************************************************************************
+|*
+|* Darstellungsqualitaet setzen
+|*
+\************************************************************************/
+
+void Base3D::SetDisplayQuality(UINT8 nNew)
+{
+ nDisplayQuality = nNew;
+}
+
+/*************************************************************************
+|*
+|* Darstellungsqualitaet lesen
+|*
+\************************************************************************/
+
+UINT8 Base3D::GetDisplayQuality()
+{
+ return nDisplayQuality;
+}
+
+/*************************************************************************
+|*
+|* PolygonOffset setzen
+|*
+\************************************************************************/
+
+void Base3D::SetPolygonOffset(Base3DPolygonOffset eNew, BOOL bNew)
+{
+ switch(eNew)
+ {
+ case Base3DPolygonOffsetFill :
+ bPolyOffsetFill = bNew;
+ break;
+
+ case Base3DPolygonOffsetLine :
+ bPolyOffsetLine = bNew;
+ break;
+
+ case Base3DPolygonOffsetPoint :
+ bPolyOffsetPoint = bNew;
+ break;
+ }
+}
+
+/*************************************************************************
+|*
+|* PolygonOffset lesen
+|*
+\************************************************************************/
+
+BOOL Base3D::GetPolygonOffset(Base3DPolygonOffset eNew)
+{
+ if(eNew == Base3DPolygonOffsetLine)
+ return bPolyOffsetLine;
+ if(eNew == Base3DPolygonOffsetFill)
+ return bPolyOffsetFill;
+ return bPolyOffsetPoint;
+}
+
+/*************************************************************************
+|*
+|* EdgeFlag lesen
+|*
+\************************************************************************/
+
+BOOL Base3D::GetEdgeFlag()
+{
+ return bEdgeFlag;
+}
+
+/*************************************************************************
+|*
+|* EdgeFlag schreiben
+|*
+\************************************************************************/
+
+void Base3D::SetEdgeFlag(BOOL bNew)
+{
+ bEdgeFlag = bNew;
+}
+
+/*************************************************************************
+|*
+|* PointSize lesen
+|*
+\************************************************************************/
+
+double Base3D::GetPointSize()
+{
+ return fPointSize;
+}
+
+/*************************************************************************
+|*
+|* PointSize schreiben
+|*
+\************************************************************************/
+
+void Base3D::SetPointSize(double fNew)
+{
+ fPointSize = fNew;
+}
+
+/*************************************************************************
+|*
+|* LineWidth lesen
+|*
+\************************************************************************/
+
+double Base3D::GetLineWidth()
+{
+ return fLineWidth;
+}
+
+/*************************************************************************
+|*
+|* LineWidth schreiben
+|*
+\************************************************************************/
+
+void Base3D::SetLineWidth(double fNew)
+{
+ fLineWidth = fNew;
+}
+
+/*************************************************************************
+|*
+|* RenderMode setzen
+|*
+\************************************************************************/
+
+void Base3D::SetRenderMode(Base3DRenderMode eNew,
+ Base3DMaterialMode eMode)
+{
+ if(eMode == Base3DMaterialFrontAndBack
+ || eMode == Base3DMaterialFront)
+ {
+ eRenderModeFront = eNew;
+ }
+ if(eMode == Base3DMaterialFrontAndBack
+ || eMode == Base3DMaterialBack)
+ {
+ eRenderModeBack = eNew;
+ }
+}
+
+/*************************************************************************
+|*
+|* RenderMode lieferen
+|*
+\************************************************************************/
+
+Base3DRenderMode Base3D::GetRenderMode(Base3DMaterialMode eMode)
+{
+ if(eMode == Base3DMaterialFrontAndBack
+ || eMode == Base3DMaterialFront)
+ {
+ return eRenderModeFront;
+ }
+ return eRenderModeBack;
+}
+
+/*************************************************************************
+|*
+|* ShadeModel setzen
+|*
+\************************************************************************/
+
+void Base3D::SetShadeModel(Base3DShadeModel eNew)
+{
+ eShadeModel = eNew;
+}
+
+/*************************************************************************
+|*
+|* ShadeModel lieferen
+|*
+\************************************************************************/
+
+Base3DShadeModel Base3D::GetShadeModel()
+{
+ return eShadeModel;
+}
+
+/*************************************************************************
+|*
+|* CullingMode setzen
+|*
+\************************************************************************/
+
+void Base3D::SetCullMode(Base3DCullMode eNew)
+{
+ eCullMode = eNew;
+}
+
+/*************************************************************************
+|*
+|* CullingMode liefern
+|*
+\************************************************************************/
+
+Base3DCullMode Base3D::GetCullMode()
+{
+ return eCullMode;
+}
+
+/*************************************************************************
+|*
+|* Texturenverwaltung
+|*
+\************************************************************************/
+
+SV_IMPL_PTRARR(B3dTextureStore, B3dTexture*);
+
+
+#ifdef DBG_UTIL
+#include "b3dtest.cxx"
+#endif
+
diff --git a/goodies/source/base3d/makefile.mk b/goodies/source/base3d/makefile.mk
new file mode 100644
index 000000000000..925276be0378
--- /dev/null
+++ b/goodies/source/base3d/makefile.mk
@@ -0,0 +1,124 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=goodies
+TARGET=base3d
+AUTOSEG=true
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(header)" == ""
+
+CXXFILES= \
+ base3d.cxx \
+ b3dtrans.cxx \
+ b3ddeflt.cxx \
+ b3dopngl.cxx \
+ b3dprint.cxx \
+ b3dcommn.cxx \
+ vector3d.cxx \
+ point4d.cxx \
+ matril3d.cxx \
+ b3dlight.cxx \
+ b3dcolor.cxx \
+ b3dentty.cxx \
+ b3dcompo.cxx \
+ hmatrix.cxx \
+ b3dtex.cxx \
+ b3dgeom.cxx \
+ b3dvolum.cxx
+
+#SRS1NAME=
+#SRC1FILES=
+
+SLOFILES= \
+ $(SLO)$/base3d.obj \
+ $(SLO)$/b3dtrans.obj \
+ $(SLO)$/b3ddeflt.obj \
+ $(SLO)$/b3dopngl.obj \
+ $(SLO)$/b3dprint.obj \
+ $(SLO)$/b3dcommn.obj \
+ $(SLO)$/vector3d.obj \
+ $(SLO)$/point4d.obj \
+ $(SLO)$/matril3d.obj \
+ $(SLO)$/b3dcolor.obj \
+ $(SLO)$/b3dlight.obj \
+ $(SLO)$/b3dentty.obj \
+ $(SLO)$/b3dcompo.obj \
+ $(SLO)$/hmatrix.obj \
+ $(SLO)$/b3dtex.obj \
+ $(SLO)$/b3dgeom.obj \
+ $(SLO)$/b3dvolum.obj
+
+
+.ENDIF # "$(header)" == ""
+
+.INCLUDE : target.mk
+
diff --git a/goodies/source/base3d/matril3d.cxx b/goodies/source/base3d/matril3d.cxx
new file mode 100644
index 000000000000..f0af32ac38e4
--- /dev/null
+++ b/goodies/source/base3d/matril3d.cxx
@@ -0,0 +1,191 @@
+/*************************************************************************
+ *
+ * $RCSfile: matril3d.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _B3D_MATRIL3D_HXX
+#include "matril3d.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+/*************************************************************************
+|*
+|* Konstruktor B3dMaterial
+|*
+\************************************************************************/
+
+B3dMaterial::B3dMaterial()
+: aAmbient(COL_BLACK), // kein lokales Umgebungslicht
+ aDiffuse(0x00, 0xb8, 0xff), // Blau7
+ aSpecular(COL_WHITE), // Weisser Glanzpunkt
+ aEmission(COL_BLACK), // Keine Selbstleuchtfarbe
+ nExponent(15) // Glanzpunktbuendelung
+{
+}
+
+/*************************************************************************
+|*
+|* Materialeigenschaft setzen
+|*
+\************************************************************************/
+
+void B3dMaterial::SetMaterial(Color rNew, Base3DMaterialValue eVal)
+{
+ switch(eVal)
+ {
+ case Base3DMaterialAmbient:
+ aAmbient = rNew;
+ break;
+ case Base3DMaterialDiffuse:
+ aDiffuse = rNew;
+ break;
+ case Base3DMaterialSpecular:
+ aSpecular = rNew;
+ break;
+ case Base3DMaterialEmission:
+ aEmission = rNew;
+ break;
+ }
+}
+
+/*************************************************************************
+|*
+|* Materialeigenschaft abfragen
+|*
+\************************************************************************/
+
+Color B3dMaterial::GetMaterial(Base3DMaterialValue eVal) const
+{
+ if(eVal == Base3DMaterialAmbient)
+ return aAmbient;
+ if(eVal == Base3DMaterialDiffuse)
+ return aDiffuse;
+ if(eVal == Base3DMaterialEmission)
+ return aEmission;
+ return aSpecular;
+}
+
+/*************************************************************************
+|*
+|* Materialeigenschaften setzen, exponent der specular-Eigenschaft
+|*
+\************************************************************************/
+
+void B3dMaterial::SetShininess(UINT16 nNew)
+{
+ nExponent = nNew;
+}
+
+/*************************************************************************
+|*
+|* Materialeigenschaften abfragen, exponent der specular-Eigenschaft
+|*
+\************************************************************************/
+
+UINT16 B3dMaterial::GetShininess() const
+{
+ return nExponent;
+}
+
+void B3dMaterial::WriteData(SvStream& rOut) const
+{
+ rOut << aAmbient;
+ rOut << aDiffuse;
+ rOut << aSpecular;
+ rOut << aEmission;
+ rOut << nExponent;
+}
+
+void B3dMaterial::ReadData(SvStream& rIn)
+{
+ rIn >> aAmbient;
+ rIn >> aDiffuse;
+ rIn >> aSpecular;
+ rIn >> aEmission;
+ rIn >> nExponent;
+}
+
+/*************************************************************************
+|*
+|* Vergleichsoperator
+|*
+\************************************************************************/
+
+BOOL B3dMaterial::operator==(const B3dMaterial& rMat)
+{
+ if(aAmbient == rMat.aAmbient
+ && aDiffuse == rMat.aDiffuse
+ && aSpecular == rMat.aSpecular
+ && aEmission == rMat.aEmission
+ && nExponent == rMat.nExponent)
+ return TRUE;
+ return FALSE;
+}
+
+/*************************************************************************
+|*
+|* Bucket fuer geometrische Daten
+|*
+\************************************************************************/
+
+BASE3D_IMPL_BUCKET(B3dMaterial, Bucket)
+
diff --git a/goodies/source/filter.vcl/egif/dlgegif.cxx b/goodies/source/filter.vcl/egif/dlgegif.cxx
new file mode 100644
index 000000000000..db3ea2d61fd6
--- /dev/null
+++ b/goodies/source/filter.vcl/egif/dlgegif.cxx
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgegif.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma hdrstop
+#include <tools/ref.hxx>
+#include <vcl/config.hxx>
+#include <vcl/msgbox.hxx>
+#include "dlgegif.hxx"
+#include "dlgegif.hrc"
+#include "strings.hrc"
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+
+DlgExportEGIF::DlgExportEGIF( FltCallDialogParameter& rPara ) :
+ ModalDialog ( rPara.pWindow, ResId( DLG_EXPORT_GIF, rPara.pResMgr ) ),
+ aCbxInterlaced ( this, ResId( CBX_INTERLACED ) ),
+ aCbxTranslucent ( this, ResId( CBX_TRANSLUCENT ) ),
+ aGrpMode ( this, ResId( GRP_MODE ) ),
+ aGrpDraw ( this, ResId( GRP_DRAW ) ),
+ aBtnOK ( this, ResId( BTN_OK ) ),
+ aBtnCancel ( this, ResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ResId( BTN_HELP ) ),
+ pConfig ( rPara.pCfg ),
+ pMgr ( rPara.pResMgr )
+{
+ FreeResource();
+
+ String aInterlaceStr( ResId( KEY_INTER, pMgr ) );
+ String aTranslucentStr( ResId( KEY_TRANS, pMgr ) );
+ // Config-Parameter lesen
+ BOOL bInterlaced = ( pConfig->ReadKey( ByteString( aInterlaceStr, RTL_TEXTENCODING_UTF8 ) ).ToInt32() != 0 );
+ BOOL bTranslucent = ( (char) pConfig->ReadKey( ByteString( aTranslucentStr, RTL_TEXTENCODING_UTF8 ) ).ToInt32() != 0 );
+
+ aCbxInterlaced.Check( bInterlaced );
+ aCbxTranslucent.Check( bTranslucent );
+
+ aBtnOK.SetClickHdl( LINK( this, DlgExportEGIF, OK ) );
+}
+
+/*************************************************************************
+|*
+|* Speichert eingestellte Werte in ini-Datei
+|*
+\************************************************************************/
+
+IMPL_LINK( DlgExportEGIF, OK, void *, EMPTYARG )
+{
+
+ // Config-Parameter schreiben
+ String aInterlaceStr( ResId( KEY_INTER, pMgr ) );
+ String aTranslucentStr( ResId( KEY_TRANS, pMgr ) );
+
+ ByteString aStr;
+
+ if ( aCbxInterlaced.IsChecked() )
+ aStr = '1';
+ else
+ aStr = '0';
+
+ pConfig->WriteKey( ByteString( aInterlaceStr, RTL_TEXTENCODING_UTF8 ), aStr );
+
+ if ( aCbxTranslucent.IsChecked() )
+ aStr = '1';
+ else
+ aStr = '0';
+
+ pConfig->WriteKey( ByteString( aTranslucentStr, RTL_TEXTENCODING_UTF8 ), aStr );
+
+ EndDialog( RET_OK );
+
+ return 0;
+}
+
+
+
diff --git a/goodies/source/filter.vcl/egif/dlgegif.hrc b/goodies/source/filter.vcl/egif/dlgegif.hrc
new file mode 100644
index 000000000000..8ae49d512f5b
--- /dev/null
+++ b/goodies/source/filter.vcl/egif/dlgegif.hrc
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgegif.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "goodies.hrc"
+
+#define BTN_OK 1
+#define BTN_CANCEL 1
+#define BTN_HELP 1
+#define FI_DESCR 1
+#define GRP_MODE 1
+#define GRP_DRAW 2
+#define CBX_INTERLACED 1
+#define CBX_TRANSLUCENT 2
diff --git a/goodies/source/filter.vcl/egif/dlgegif.hxx b/goodies/source/filter.vcl/egif/dlgegif.hxx
new file mode 100644
index 000000000000..41a16506f48a
--- /dev/null
+++ b/goodies/source/filter.vcl/egif/dlgegif.hxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgegif.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _DLGEGIF_HXX_
+#define _DLGEGIF_HXX_
+
+#include <svtools/fltcall.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/group.hxx>
+
+/*************************************************************************
+|*
+|* Dialog zum Einstellen von Filteroptionen
+|*
+\************************************************************************/
+
+class Config;
+class ResMgr;
+
+class DlgExportEGIF : public ModalDialog
+{
+private:
+ CheckBox aCbxInterlaced;
+ CheckBox aCbxTranslucent;
+ GroupBox aGrpMode;
+ GroupBox aGrpDraw;
+ OKButton aBtnOK;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ Config* pConfig;
+ ResMgr* pMgr;
+
+ DECL_LINK( OK, void * );
+
+public:
+ DlgExportEGIF( FltCallDialogParameter& rPara );
+};
+
+#endif // _DLGEGIF_HXX_
+
diff --git a/goodies/source/filter.vcl/egif/dlgegif.src b/goodies/source/filter.vcl/egif/dlgegif.src
new file mode 100644
index 000000000000..f88c4a619d61
--- /dev/null
+++ b/goodies/source/filter.vcl/egif/dlgegif.src
@@ -0,0 +1,230 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgegif.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "dlgegif.hrc"
+ModalDialog DLG_EXPORT_GIF
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 169 , 70 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Text = "GIF Optionen" ;
+ Text [ ENGLISH ] = "GIF options" ;
+ Text [ english_us ] = "GIF Options" ;
+ Text [ italian ] = "Opzioni GIF" ;
+ Text [ spanish ] = "Opciones GIF" ;
+ Text [ french ] = "Options GIF" ;
+ Text [ dutch ] = "GIF-opties" ;
+ Text [ swedish ] = "GIF alternativ" ;
+ Text [ danish ] = "GIF indstillinger" ;
+ Text [ portuguese_brazilian ] = "GIF Optionen" ;
+ Text [ portuguese ] = "Opções GIF" ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 113 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 113 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 113 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ GroupBox GRP_MODE
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 100 , 29 ) ;
+ Text = "Modus" ;
+ Text [ ENGLISH ] = "Mode" ;
+ Text [ english_us ] = "Mode" ;
+ Text [ italian ] = "Modo" ;
+ Text [ spanish ] = "Modo" ;
+ Text [ french ] = "Mode" ;
+ Text [ dutch ] = "Modus" ;
+ Text [ swedish ] = "Läge" ;
+ Text [ danish ] = "Modus" ;
+ Text [ portuguese_brazilian ] = "Modus" ;
+ Text [ portuguese ] = "Modo" ;
+ Text[ chinese_simplified ] = "ģʽ";
+ Text[ russian ] = "Ðåæèì";
+ Text[ polish ] = "Tryb";
+ Text[ japanese ] = "Ó°ÄÞ";
+ Text[ chinese_traditional ] = "¼Ò¦¡";
+ Text[ arabic ] = "æÖÚ";
+ Text[ dutch ] = "Modus";
+ Text[ chinese_simplified ] = "ģʽ";
+ Text[ greek ] = "ÊáôÜóôáóç";
+ Text[ korean ] = "¸ðµå";
+ Text[ turkish ] = "Kip";
+ Text[ language_user1 ] = " ";
+ };
+ CheckBox CBX_INTERLACED
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 86 , 12 ) ;
+ TabStop = TRUE ;
+ Text = "~Interlaced" ;
+ Text [ ENGLISH ] = "~Interlaced" ;
+ Text [ english_us ] = "~Interlaced" ;
+ Text [ portuguese_brazilian ] = "~Interlaced" ;
+ Text [ swedish ] = "~Interlaced" ;
+ Text [ danish ] = "~Interlaced" ;
+ Text [ italian ] = "Interlaced" ;
+ Text [ spanish ] = "~Entrelazado" ;
+ Text [ french ] = "~Entrelacé" ;
+ Text [ dutch ] = "~Interlaced" ;
+ Text [ portuguese ] = "~Interlaced" ;
+ Text[ chinese_simplified ] = "½»´í(~I)";
+ Text[ russian ] = "~Ñ ÷åðåäîâàíèåì";
+ Text[ polish ] = "Interlaced";
+ Text[ japanese ] = "²ÝÀ°Ú°½‚µ‚½(~I)";
+ Text[ chinese_traditional ] = "¥æ¿ù(~I)";
+ Text[ arabic ] = "ãÊÔÇÈß";
+ Text[ dutch ] = "~Interlaced";
+ Text[ chinese_simplified ] = "½»´í(~I)";
+ Text[ greek ] = "ÐåðëåãìÝíç";
+ Text[ korean ] = "ÀÎÅÍ·¹À̽º(~I)";
+ Text[ turkish ] = "~Interlaced";
+ Text[ language_user1 ] = " ";
+ };
+ GroupBox GRP_DRAW
+ {
+ Pos = MAP_APPFONT ( 6 , 35 ) ;
+ Size = MAP_APPFONT ( 100 , 29 ) ;
+ Text = "Zeichenobjekte" ;
+ Text [ ENGLISH ] = "Drawing objects" ;
+ Text [ english_us ] = "Drawing objects" ;
+ Text [ portuguese_brazilian ] = "Zeichenobjekte" ;
+ Text [ swedish ] = "Ritobjekt" ;
+ Text [ danish ] = "Tegneobjekter" ;
+ Text [ italian ] = "Oggetti di disegno" ;
+ Text [ spanish ] = "Objetos de dibujo" ;
+ Text [ french ] = "Objets de dessin" ;
+ Text [ dutch ] = "Tekenobjecten" ;
+ Text [ portuguese ] = "Objectos de desenho" ;
+ Text[ chinese_simplified ] = "»æͼ¶ÔÏó";
+ Text[ russian ] = "Ãðàôè÷åñêèå îáúåêòû";
+ Text[ polish ] = "Obiekty graficzne";
+ Text[ japanese ] = "}Œ`•`‰æµÌÞ¼Þª¸Ä";
+ Text[ russian ] = "Ãðàôè÷åñêèå îáúåêòû";
+ Text[ polish ] = "Obiekty graficzne";
+ Text[ japanese ] = "}Œ`•`‰æµÌÞ¼Þª¸Ä";
+ Text[ chinese_simplified ] = "»æͼ¶ÔÏó";
+ Text[ chinese_traditional ] = "¦r«¬ª«¥ó";
+ Text[ arabic ] = "ßÇÆäÇÊ ÑÓæãíÉ";
+ Text[ dutch ] = "Tekenobjecten";
+ Text[ chinese_simplified ] = "»æͼ¶ÔÏó";
+ Text[ greek ] = "Áíôéêåßìåíá ó÷åäßáóçò";
+ Text[ korean ] = "±×¸®±â °³Ã¼";
+ Text[ turkish ] = "Çizimler";
+ Text[ language_user1 ] = " ";
+ };
+ CheckBox CBX_TRANSLUCENT
+ {
+ Pos = MAP_APPFONT ( 12 , 46 ) ;
+ Size = MAP_APPFONT ( 86 , 12 ) ;
+ TabStop = TRUE ;
+ Text = "~Transparent speichern" ;
+ Text [ ENGLISH ] = "Save ~transparent" ;
+ Text [ english_us ] = "Save ~transparency" ;
+ Text [ portuguese_brazilian ] = "~Transparent speichern" ;
+ Text [ swedish ] = "Spara ~transparent" ;
+ Text [ danish ] = "Gem ~transparent" ;
+ Text [ italian ] = "Salva in modo trasparente" ;
+ Text [ spanish ] = "Guardar en modo ~transparente" ;
+ Text [ french ] = "Enregistrer en t~ransparence" ;
+ Text [ dutch ] = "~Transparant opslaan" ;
+ Text [ portuguese ] = "~Guardar em modo transparente" ;
+ Text[ chinese_simplified ] = "´æÅÌ͸Ã÷(~T)";
+ Text[ russian ] = "Ñîõðàíèòü â ïðîçðà÷íîì ðåæèìå";
+ Text[ polish ] = "Zapisz w trybie przezroczystym";
+ Text[ japanese ] = "“§‰ß«‚Ì‚Ü‚Ü•Û‘¶(~T)";
+ Text[ chinese_traditional ] = "Àx¦s³z©ú(~T)";
+ Text[ arabic ] = "ÍÝÙ ÔÝÇÝ";
+ Text[ dutch ] = "~Transparant opslaan";
+ Text[ chinese_simplified ] = "´æÅÌ͸Ã÷(~T)";
+ Text[ greek ] = "Äéá~öáíÝò áðïèÞêåõóç";
+ Text[ korean ] = "Åõ¸í ¸ðµå ÀúÀå(~T)";
+ Text[ turkish ] = "Saydam biçimde kaydet";
+ Text[ language_user1 ] = " ";
+ };
+ Text[ chinese_simplified ] = "GIF Ñ¡Ïî";
+ Text[ russian ] = "Ïàðàìåòðû GIF";
+ Text[ polish ] = "Opcje GIF";
+ Text[ japanese ] = "GIF µÌß¼®Ý";
+ Text[ chinese_traditional ] = "GIF¿ï¶µ";
+ Text[ arabic ] = "GIF ÎíÇÑÇÊ";
+ Text[ dutch ] = "GIF-opties";
+ Text[ chinese_simplified ] = "GIF Ñ¡Ïî";
+ Text[ greek ] = "ÅðéëïãÝò GIF";
+ Text[ korean ] = "GIF ¿É¼Ç";
+ Text[ turkish ] = "GIF seçenekleri";
+ Text[ language_user1 ] = " ";
+};
diff --git a/goodies/source/filter.vcl/egif/egif.cxx b/goodies/source/filter.vcl/egif/egif.cxx
new file mode 100644
index 000000000000..545e158e41b2
--- /dev/null
+++ b/goodies/source/filter.vcl/egif/egif.cxx
@@ -0,0 +1,653 @@
+/*************************************************************************
+ *
+ * $RCSfile: egif.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <vcl/graph.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/config.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/window.hxx>
+#include <svtools/solar.hrc>
+#include <svtools/fltcall.hxx>
+#include "giflzwc.hxx"
+#include "strings.hrc"
+#include "dlgegif.hrc"
+#include "dlgegif.hxx"
+
+// -------------
+// - GIFWriter -
+// -------------
+
+class GIFWriter
+{
+ Bitmap aAccBmp;
+ PFilterCallback pCallback;
+ void* pCallerData;
+ BitmapReadAccess* pAcc;
+ SvStream* pGIF;
+ ULONG nMinPercent;
+ ULONG nMaxPercent;
+ ULONG nLastPercent;
+ long nActX;
+ long nActY;
+ sal_Int32 nInterlaced;
+ BOOL bStatus;
+ BOOL bTransparent;
+
+ void MayCallback( ULONG nPercent );
+ void WriteSignature( BOOL bGIF89a );
+ void WriteGlobalHeader( const Size& rSize );
+ void WriteLoopExtension( const Animation& rAnimation );
+ void WriteLogSizeExtension( const Size& rSize100 );
+ void WriteImageExtension( long nTimer, Disposal eDisposal );
+ void WriteLocalHeader();
+ void WritePalette();
+ void WriteAccess();
+ void WriteTerminator();
+
+ BOOL CreateAccess( const BitmapEx& rBmpEx );
+ void DestroyAccess();
+
+ void WriteAnimation( const Animation& rAnimation );
+ void WriteBitmapEx( const BitmapEx& rBmpEx, const Point& rPoint, BOOL bExtended,
+ long nTimer = 0, Disposal eDisposal = DISPOSE_NOT );
+
+public:
+
+ GIFWriter() {}
+ ~GIFWriter() {}
+
+ BOOL WriteGIF( const Graphic& rGraphic, SvStream& rGIF,
+ PFilterCallback pcallback, void* pcallerdata,
+ Config* pOptionsConfig );
+};
+
+// ------------------------------------------------------------------------
+
+BOOL GIFWriter::WriteGIF( const Graphic& rGraphic, SvStream& rGIF,
+ PFilterCallback pcallback, void* pcallerdata,
+ Config* pOptionsConfig )
+{
+ Size aSize100;
+ const MapMode aMap( rGraphic.GetPrefMapMode() );
+ BOOL bLogSize = ( aMap.GetMapUnit() != MAP_PIXEL );
+
+ if( bLogSize )
+ aSize100 = Application::GetDefaultDevice()->LogicToLogic( rGraphic.GetPrefSize(), aMap, MAP_100TH_MM );
+
+ pGIF = &rGIF;
+ bStatus = TRUE;
+ nLastPercent = 0;
+ nInterlaced = 0;
+ pAcc = NULL;
+ pCallback = pcallback;
+ pCallerData = pcallerdata;
+
+ if ( pOptionsConfig )
+ nInterlaced = pOptionsConfig->ReadKey( "GIF-EXPORT-INTERLACED", "0" ).ToInt32();
+
+ pGIF->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+
+ if( rGraphic.IsAnimated() )
+ {
+ const Animation& rAnimation = rGraphic.GetAnimation();
+
+ WriteSignature( TRUE );
+
+ if ( bStatus )
+ {
+ WriteGlobalHeader( rAnimation.GetDisplaySizePixel() );
+
+ if( bStatus )
+ {
+ WriteLoopExtension( rAnimation );
+
+ if( bStatus )
+ WriteAnimation( rAnimation );
+ }
+ }
+ }
+ else
+ {
+ const BOOL bGrafTrans = rGraphic.IsTransparent();
+
+ BitmapEx aBmpEx;
+
+ if( bGrafTrans )
+ aBmpEx = rGraphic.GetBitmapEx();
+ else
+ aBmpEx = BitmapEx( rGraphic.GetBitmap() );
+
+ nMinPercent = 0;
+ nMaxPercent = 100;
+
+ WriteSignature( bGrafTrans || bLogSize );
+
+ if( bStatus )
+ {
+ WriteGlobalHeader( aBmpEx.GetSizePixel() );
+
+ if( bStatus )
+ WriteBitmapEx( aBmpEx, Point(), bGrafTrans );
+ }
+ }
+
+ if( bStatus )
+ {
+ if( bLogSize )
+ WriteLogSizeExtension( aSize100 );
+
+ WriteTerminator();
+ }
+
+ return bStatus;
+}
+
+// ------------------------------------------------------------------------
+
+void GIFWriter::WriteBitmapEx( const BitmapEx& rBmpEx, const Point& rPoint,
+ BOOL bExtended, long nTimer, Disposal eDisposal )
+{
+ if( CreateAccess( rBmpEx ) )
+ {
+ nActX = rPoint.X();
+ nActY = rPoint.Y();
+
+ if( bExtended )
+ WriteImageExtension( nTimer, eDisposal );
+
+ if( bStatus )
+ {
+ WriteLocalHeader();
+
+ if( bStatus )
+ {
+ WritePalette();
+
+ if( bStatus )
+ WriteAccess();
+ }
+ }
+
+ DestroyAccess();
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GIFWriter::WriteAnimation( const Animation& rAnimation )
+{
+ const USHORT nCount = rAnimation.Count();
+
+ if( nCount )
+ {
+ const double fStep = 100. / nCount;
+
+ nMinPercent = 0L;
+ nMaxPercent = (ULONG) fStep;
+
+ for( USHORT i = 0; i < nCount; i++ )
+ {
+ const AnimationBitmap& rAnimBmp = rAnimation.Get( i );
+
+ WriteBitmapEx( rAnimBmp.aBmpEx, rAnimBmp.aPosPix, TRUE,
+ rAnimBmp.nWait, rAnimBmp.eDisposal );
+ nMinPercent = nMaxPercent;
+ nMaxPercent = (ULONG) ( nMaxPercent + fStep );
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GIFWriter::MayCallback( ULONG nPercent )
+{
+ if( nPercent >= nLastPercent + 3 )
+ {
+ nLastPercent = nPercent;
+
+ if( pCallback && ( nPercent <= 100 ) && bStatus )
+ if ( ( (*pCallback)( pCallerData, (USHORT) nPercent ) ) )
+ bStatus = FALSE;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GIFWriter::CreateAccess( const BitmapEx& rBmpEx )
+{
+ if( bStatus )
+ {
+ Bitmap aMask( rBmpEx.GetMask() );
+
+ aAccBmp = rBmpEx.GetBitmap();
+ bTransparent = FALSE;
+
+ if( !!aMask )
+ {
+ if( aAccBmp.Convert( BMP_CONVERSION_8BIT_TRANS ) )
+ {
+ aMask.Convert( BMP_CONVERSION_1BIT_THRESHOLD );
+ aAccBmp.Replace( aMask, BMP_COL_TRANS );
+ bTransparent = TRUE;
+ }
+ else
+ aAccBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
+ }
+ else
+ aAccBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
+
+ pAcc = aAccBmp.AcquireReadAccess();
+
+ if( !pAcc )
+ bStatus = FALSE;
+ }
+
+ return bStatus;
+}
+
+// ------------------------------------------------------------------------
+
+void GIFWriter::DestroyAccess()
+{
+ aAccBmp.ReleaseAccess( pAcc );
+ pAcc = NULL;
+}
+
+// ------------------------------------------------------------------------
+
+void GIFWriter::WriteSignature( BOOL bGIF89a )
+{
+ if( bStatus )
+ {
+ pGIF->Write( bGIF89a ? "GIF89a" : "GIF87a" , 6 );
+
+ if( pGIF->GetError() )
+ bStatus = FALSE;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GIFWriter::WriteGlobalHeader( const Size& rSize )
+{
+ if( bStatus )
+ {
+ // 256 Farben
+ const UINT16 nWidth = (UINT16) rSize.Width();
+ const UINT16 nHeight = (UINT16) rSize.Height();
+ const UINT16 nDummy = 0;
+ const BYTE cFlags = 128 | ( 7 << 4 );
+
+ // Werte rausschreiben
+ *pGIF << nWidth;
+ *pGIF << nHeight;
+ *pGIF << cFlags;
+ *pGIF << (BYTE) 0x00;
+ *pGIF << (BYTE) 0x00;
+
+ // Dummy-Palette mit zwei Eintraegen (Schwarz/Weiss) schreiben;
+ // dieses nur wegen Photoshop-Bug, da die keine Bilder ohne
+ // globale Farbpalette lesen koennen
+ *pGIF << (UINT16) 0;
+ *pGIF << (UINT16) 255;
+ *pGIF << (UINT16) 65535;
+
+ if( pGIF->GetError() )
+ bStatus = FALSE;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GIFWriter::WriteLoopExtension( const Animation& rAnimation )
+{
+ DBG_ASSERT( rAnimation.Count() > 0, "Animation has no bitmaps!" );
+
+ USHORT nLoopCount = (USHORT) rAnimation.GetLoopCount();
+
+ // falls nur ein Durchlauf stattfinden soll,
+ // wird keine LoopExtension geschrieben;
+ // Default ist dann immer ein Durchlauf
+ if( nLoopCount != 1 )
+ {
+ // Netscape interpretiert den LoopCount
+ // als reine Anzahl der _Wiederholungen_
+ if( nLoopCount )
+ nLoopCount--;
+
+ const BYTE cLoByte = (const BYTE) nLoopCount;
+ const BYTE cHiByte = (const BYTE) ( nLoopCount >> 8 );
+
+ *pGIF << (BYTE) 0x21;
+ *pGIF << (BYTE) 0xff;
+ *pGIF << (BYTE) 0x0b;
+ pGIF->Write( "NETSCAPE2.0", 11 );
+ *pGIF << (BYTE) 0x03;
+ *pGIF << (BYTE) 0x01;
+ *pGIF << cLoByte;
+ *pGIF << cHiByte;
+ *pGIF << (BYTE) 0x00;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GIFWriter::WriteLogSizeExtension( const Size& rSize100 )
+{
+ // PrefSize in 100th-mm als ApplicationExtension schreiben
+ if( rSize100.Width() && rSize100.Height() )
+ {
+ *pGIF << (BYTE) 0x21;
+ *pGIF << (BYTE) 0xff;
+ *pGIF << (BYTE) 0x0b;
+ pGIF->Write( "STARDIV 5.0", 11 );
+ *pGIF << (BYTE) 0x09;
+ *pGIF << (BYTE) 0x01;
+ *pGIF << (UINT32) rSize100.Width();
+ *pGIF << (UINT32) rSize100.Height();
+ *pGIF << (BYTE) 0x00;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GIFWriter::WriteImageExtension( long nTimer, Disposal eDisposal )
+{
+ if( bStatus )
+ {
+ const UINT16 nDelay = (UINT16) nTimer;
+ BYTE cFlags = 0;
+
+ // Transparent-Flag setzen
+ if( bTransparent )
+ cFlags |= 1;
+
+ // Disposal-Wert setzen
+ if( eDisposal == DISPOSE_BACK )
+ cFlags |= ( 2 << 2 );
+ else if( eDisposal == DISPOSE_PREVIOUS )
+ cFlags |= ( 3 << 2 );
+
+ *pGIF << (BYTE) 0x21;
+ *pGIF << (BYTE) 0xf9;
+ *pGIF << (BYTE) 0x04;
+ *pGIF << cFlags;
+ *pGIF << nDelay;
+ *pGIF << (BYTE) pAcc->GetBestPaletteIndex( BMP_COL_TRANS );
+ *pGIF << (BYTE) 0x00;
+
+ if( pGIF->GetError() )
+ bStatus = FALSE;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GIFWriter::WriteLocalHeader()
+{
+ if( bStatus )
+ {
+ const UINT16 nPosX = (UINT16) nActX;
+ const UINT16 nPosY = (UINT16) nActY;
+ const UINT16 nWidth = (UINT16) pAcc->Width();
+ const UINT16 nHeight = (UINT16) pAcc->Height();
+ BYTE cFlags = (BYTE) ( pAcc->GetBitCount() - 1 );
+
+ // Interlaced-Flag setzen
+ if( nInterlaced )
+ cFlags |= 0x40;
+
+ // Flag fuer lokale Farbpalette setzen
+ cFlags |= 0x80;
+
+ // alles rausschreiben
+ *pGIF << (BYTE) 0x2c;
+ *pGIF << nPosX;
+ *pGIF << nPosY;
+ *pGIF << nWidth;
+ *pGIF << nHeight;
+ *pGIF << cFlags;
+
+ if( pGIF->GetError() )
+ bStatus = FALSE;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GIFWriter::WritePalette()
+{
+ if( bStatus && pAcc->HasPalette() )
+ {
+ const USHORT nCount = pAcc->GetPaletteEntryCount();
+ const USHORT nMaxCount = ( 1 << pAcc->GetBitCount() );
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ const BitmapColor& rColor = pAcc->GetPaletteColor( i );
+
+ *pGIF << rColor.GetRed();
+ *pGIF << rColor.GetGreen();
+ *pGIF << rColor.GetBlue();
+ }
+
+ // Rest mit 0 auffuellen
+ if( nCount < nMaxCount )
+ pGIF->SeekRel( ( nMaxCount - nCount ) * 3 );
+
+ if( pGIF->GetError() )
+ bStatus = FALSE;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GIFWriter::WriteAccess()
+{
+ GIFLZWCompressor aCompressor;
+ const long nWidth = pAcc->Width();
+ const long nHeight = pAcc->Height();
+ BYTE* pBuffer = NULL;
+ const ULONG nFormat = pAcc->GetScanlineFormat();
+ long nY;
+ long nT;
+ long i;
+ BOOL bNative = ( BMP_FORMAT_8BIT_PAL == nFormat );
+
+ if( !bNative )
+ pBuffer = new BYTE[ nWidth ];
+
+ if( bStatus && ( 8 == pAcc->GetBitCount() ) && pAcc->HasPalette() )
+ {
+ aCompressor.StartCompression( *pGIF, pAcc->GetBitCount() );
+
+ for( i = 0; i < nHeight; i++ )
+ {
+ if( nInterlaced )
+ {
+ nY = i << 3;
+
+ if( nY >= nHeight )
+ {
+ nT = i - ( ( nHeight + 7 ) >> 3 );
+ nY= ( nT << 3 ) + 4;
+
+ if( nY >= nHeight )
+ {
+ nT -= ( nHeight + 3 ) >> 3;
+ nY = ( nT << 2 ) + 2;
+
+ if ( nY >= nHeight )
+ {
+ nT -= ( ( nHeight + 1 ) >> 2 );
+ nY = ( nT << 1 ) + 1;
+ }
+ }
+ }
+ }
+ else
+ nY = i;
+
+ if( bNative )
+ aCompressor.Compress( pAcc->GetScanline( nY ), nWidth );
+ else
+ {
+ for( long nX = 0L; nX < nWidth; nX++ )
+ pBuffer[ nX ] = (BYTE) pAcc->GetPixel( nY, nX );
+
+ aCompressor.Compress( pBuffer, nWidth );
+ }
+
+ if ( pGIF->GetError() )
+ bStatus = FALSE;
+
+ MayCallback( nMinPercent + ( nMaxPercent - nMinPercent ) * i / nHeight );
+
+ if( !bStatus )
+ break;
+ }
+
+ aCompressor.EndCompression();
+
+ if ( pGIF->GetError() )
+ bStatus = FALSE;
+ }
+
+ delete[] pBuffer;
+}
+
+// ------------------------------------------------------------------------
+
+void GIFWriter::WriteTerminator()
+{
+ if( bStatus )
+ {
+ *pGIF << (BYTE) 0x3b;
+
+ if( pGIF->GetError() )
+ bStatus = FALSE;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+extern "C" BOOL __LOADONCALLAPI GraphicExport( SvStream& rStream, Graphic& rGraphic,
+ PFilterCallback pCallback, void* pCallerData,
+ Config* pOptionsConfig, BOOL )
+{
+ return GIFWriter().WriteGIF( rGraphic, rStream, pCallback, pCallerData, pOptionsConfig );
+}
+
+// ------------------------------------------------------------------------
+
+extern "C" BOOL __LOADONCALLAPI DoExportDialog( FltCallDialogParameter& rPara )
+{
+ BOOL bRet = FALSE;
+
+ if ( rPara.pWindow && rPara.pCfg )
+ {
+ ByteString aResMgrName( "egi" );
+ ResMgr* pResMgr;
+
+ aResMgrName.Append( ByteString::CreateFromInt32( SOLARUPD ) );
+ pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetAppInternational().GetLanguage() );
+
+ if( pResMgr )
+ {
+ rPara.pResMgr = pResMgr;
+ bRet = ( DlgExportEGIF( rPara ).Execute() == RET_OK );
+ delete pResMgr;
+ }
+ else
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0;
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
diff --git a/goodies/source/filter.vcl/egif/egifstr.src b/goodies/source/filter.vcl/egif/egifstr.src
new file mode 100644
index 000000000000..e3fc4e4fa59b
--- /dev/null
+++ b/goodies/source/filter.vcl/egif/egifstr.src
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: egifstr.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include "strings.hrc"
+
+// Key fuer den Dialog
+String KEY_INTER
+{
+ Text = "GIF-EXPORT-INTERLACED";
+};
+String KEY_TRANS
+{
+ Text = "GIF-EXPORT-TRANSLUCENT";
+};
diff --git a/goodies/source/filter.vcl/egif/giflzwc.cxx b/goodies/source/filter.vcl/egif/giflzwc.cxx
new file mode 100644
index 000000000000..29c3a7735d27
--- /dev/null
+++ b/goodies/source/filter.vcl/egif/giflzwc.cxx
@@ -0,0 +1,287 @@
+/*************************************************************************
+ *
+ * $RCSfile: giflzwc.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <tools/stream.hxx>
+#include "giflzwc.hxx"
+
+// ----------------------------
+// - GIFImageDataOutputStream -
+// ----------------------------
+
+class GIFImageDataOutputStream
+{
+private:
+
+ void FlushBlockBuf();
+ inline void FlushBitsBufsFullBytes();
+
+ SvStream& rStream;
+ BYTE* pBlockBuf;
+ BYTE nBlockBufSize;
+ ULONG nBitsBuf;
+ USHORT nBitsBufSize;
+
+public:
+
+ GIFImageDataOutputStream( SvStream & rGIF, BYTE nLZWDataSize );
+ ~GIFImageDataOutputStream();
+
+ inline void WriteBits( USHORT nCode, USHORT nCodeLen );
+};
+
+// ------------------------------------------------------------------------
+
+inline void GIFImageDataOutputStream::FlushBitsBufsFullBytes()
+{
+ while (nBitsBufSize>=8)
+ {
+ if( nBlockBufSize==255 )
+ FlushBlockBuf();
+
+ pBlockBuf[nBlockBufSize++] = (BYTE) nBitsBuf;
+ nBitsBuf >>= 8;
+ nBitsBufSize -= 8;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+inline void GIFImageDataOutputStream::WriteBits( USHORT nCode, USHORT nCodeLen )
+{
+ if( nBitsBufSize+nCodeLen>32 )
+ FlushBitsBufsFullBytes();
+
+ nBitsBuf |= (ULONG) nCode << nBitsBufSize;
+ nBitsBufSize += nCodeLen;
+}
+
+// ------------------------------------------------------------------------
+
+GIFImageDataOutputStream::GIFImageDataOutputStream( SvStream & rGIF, BYTE nLZWDataSize ) :
+ rStream(rGIF)
+{
+ pBlockBuf = new BYTE[ 255 ];
+ nBlockBufSize = 0;
+ nBitsBufSize = 0;
+ nBitsBuf = 0;
+ rStream << nLZWDataSize;
+}
+
+// ------------------------------------------------------------------------
+
+
+GIFImageDataOutputStream::~GIFImageDataOutputStream()
+{
+ WriteBits(0,7);
+ FlushBitsBufsFullBytes();
+ FlushBlockBuf();
+ rStream << (BYTE)0;
+ delete[] pBlockBuf;
+}
+
+// ------------------------------------------------------------------------
+
+void GIFImageDataOutputStream::FlushBlockBuf()
+{
+ if( nBlockBufSize )
+ {
+ rStream << (BYTE) nBlockBufSize;
+ rStream.Write( pBlockBuf,nBlockBufSize );
+ nBlockBufSize = 0;
+ }
+}
+
+// -------------------
+// - GIFLZWCTreeNode -
+// -------------------
+
+struct GIFLZWCTreeNode
+{
+
+ GIFLZWCTreeNode* pBrother; // naechster Knoten, der den selben Vater hat
+ GIFLZWCTreeNode* pFirstChild; // erster Sohn
+ USHORT nCode; // Der Code fuer den String von Pixelwerten, der sich ergibt, wenn
+ USHORT nValue; // Der Pixelwert
+};
+
+// --------------------
+// - GIFLZWCompressor -
+// --------------------
+
+GIFLZWCompressor::GIFLZWCompressor()
+{
+ pIDOS=NULL;
+}
+
+// ------------------------------------------------------------------------
+
+GIFLZWCompressor::~GIFLZWCompressor()
+{
+ if (pIDOS!=NULL) EndCompression();
+}
+
+// ------------------------------------------------------------------------
+
+void GIFLZWCompressor::StartCompression( SvStream& rGIF, USHORT nPixelSize )
+{
+ if( !pIDOS )
+ {
+ USHORT i;
+
+ nDataSize = nPixelSize;
+
+ if( nDataSize < 2 )
+ nDataSize=2;
+
+ nClearCode=1<<nDataSize;
+ nEOICode=nClearCode+1;
+ nTableSize=nEOICode+1;
+ nCodeSize=nDataSize+1;
+
+ pIDOS=new GIFImageDataOutputStream(rGIF,(BYTE)nDataSize);
+ pTable=new GIFLZWCTreeNode[4096];
+
+ for (i=0; i<4096; i++)
+ {
+ pTable[i].pBrother = pTable[i].pFirstChild = NULL;
+ pTable[i].nValue = (BYTE) ( pTable[i].nCode = i );
+ }
+
+ pPrefix = NULL;
+ pIDOS->WriteBits( nClearCode,nCodeSize );
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GIFLZWCompressor::Compress( HPBYTE pSrc, ULONG nSize )
+{
+ if( pIDOS )
+ {
+ GIFLZWCTreeNode* p;
+ USHORT i;
+ BYTE nV;
+
+ if( !pPrefix && nSize )
+ {
+ pPrefix=pTable+(*pSrc++);
+ nSize--;
+ }
+
+ while( nSize )
+ {
+ nSize--;
+ nV=*pSrc++;
+ for( p=pPrefix->pFirstChild; p!=NULL; p=p->pBrother )
+ {
+ if (p->nValue==nV)
+ break;
+ }
+
+ if( p)
+ pPrefix=p;
+ else
+ {
+ pIDOS->WriteBits(pPrefix->nCode,nCodeSize);
+
+ if (nTableSize==4096)
+ {
+ pIDOS->WriteBits(nClearCode,nCodeSize);
+
+ for (i=0; i<nClearCode; i++)
+ pTable[i].pFirstChild=NULL;
+
+ nCodeSize=nDataSize+1;
+ nTableSize=nEOICode+1;
+ }
+ else
+ {
+ if(nTableSize==(USHORT)(1<<nCodeSize))
+ nCodeSize++;
+
+ p=pTable+(nTableSize++);
+ p->pBrother=pPrefix->pFirstChild;
+ pPrefix->pFirstChild=p;
+ p->nValue=nV;
+ p->pFirstChild=NULL;
+ }
+
+ pPrefix=pTable+nV;
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GIFLZWCompressor::EndCompression()
+{
+ if( pIDOS )
+ {
+ if( pPrefix )
+ pIDOS->WriteBits(pPrefix->nCode,nCodeSize);
+
+ pIDOS->WriteBits( nEOICode,nCodeSize );
+ delete[] pTable;
+ delete pIDOS;
+ pIDOS=NULL;
+ }
+}
diff --git a/goodies/source/filter.vcl/egif/giflzwc.hxx b/goodies/source/filter.vcl/egif/giflzwc.hxx
new file mode 100644
index 000000000000..9f92644265e9
--- /dev/null
+++ b/goodies/source/filter.vcl/egif/giflzwc.hxx
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * $RCSfile: giflzwc.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _GIFLZWC_HXX
+#define _GIFLZWC_HXX
+
+#ifndef _BMPACC_HXX
+#include <vcl/bmpacc.hxx>
+#endif
+
+// --------------------
+// - GIFLZWCompressor -
+// --------------------
+
+class GIFImageDataOutputStream;
+struct GIFLZWCTreeNode;
+
+class GIFLZWCompressor
+{
+private:
+
+ GIFImageDataOutputStream* pIDOS;
+ GIFLZWCTreeNode* pTable;
+ GIFLZWCTreeNode* pPrefix;
+ USHORT nDataSize;
+ USHORT nClearCode;
+ USHORT nEOICode;
+ USHORT nTableSize;
+ USHORT nCodeSize;
+
+public:
+
+ GIFLZWCompressor();
+ ~GIFLZWCompressor();
+
+ void StartCompression( SvStream& rGIF, USHORT nPixelSize );
+ void Compress( HPBYTE pSrc, ULONG nSize );
+ void EndCompression();
+};
+
+#endif // _GIFLZWC_HXX
diff --git a/goodies/source/filter.vcl/egif/makefile.mk b/goodies/source/filter.vcl/egif/makefile.mk
new file mode 100644
index 000000000000..7bb41384300a
--- /dev/null
+++ b/goodies/source/filter.vcl/egif/makefile.mk
@@ -0,0 +1,188 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=VCL
+TARGET=egif
+TARGET2=egi
+DEPTARGET=vegif
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+# --- Settings -----------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+
+# --- Files --------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SRCFILES = dlgegif.src \
+ egifstr.src
+
+SLOFILES= $(SLO)$/egif.obj \
+ $(SLO)$/dlgegif.obj \
+ $(SLO)$/giflzwc.obj
+
+
+# ==========================================================================
+
+RESLIB1NAME=$(TARGET2)
+RESLIB1SRSFILES=\
+ $(SRS)$/$(TARGET).srs
+
+SHL1TARGET= egi$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= egif
+SHL1STDLIBS= \
+ $(TOOLSLIB) \
+ $(SVLIB) \
+ $(CPPULIB) \
+ $(SVTOOLLIB)
+
+SHL1DEPN= $(LB)$/egif.lib
+SHL1LIBS= $(SLB)$/egif.lib # $(LB)$/rtftoken.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/egif.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicExport >>$@
+ @echo DoExportDialog >>$@
+.ELSE
+ @echo _GraphicExport >>$@
+ @echo _DoExportDialog >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET) >>$@
+ @echo GraphicExport_ >>temp.def
+ @echo DoExportDialog_ >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicExport >>$@
+ @echo DoExportDialog >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/egif/strings.hrc b/goodies/source/filter.vcl/egif/strings.hrc
new file mode 100644
index 000000000000..d09d02ec9582
--- /dev/null
+++ b/goodies/source/filter.vcl/egif/strings.hrc
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * $RCSfile: strings.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#define KEY_INTER 256
+#define KEY_TRANS 257
diff --git a/goodies/source/filter.vcl/eos2met/dlgeos2.cxx b/goodies/source/filter.vcl/eos2met/dlgeos2.cxx
new file mode 100644
index 000000000000..7c5726c761ab
--- /dev/null
+++ b/goodies/source/filter.vcl/eos2met/dlgeos2.cxx
@@ -0,0 +1,259 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgeos2.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma hdrstop
+
+#include <vcl/msgbox.hxx>
+#include <vcl/config.hxx>
+#include "dlgeos2.hxx"
+#include "dlgeos2.hrc"
+#include "strings.hrc"
+
+#include <segmentc.hxx>
+
+SEG_EOFGLOBALS()
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+
+DlgExportEMET::DlgExportEMET( FltCallDialogParameter& rPara ) :
+ ModalDialog ( rPara.pWindow, ResId( DLG_EXPORT_EMET, rPara.pResMgr ) ),
+ aBtnOK ( this, ResId( BTN_OK ) ),
+ aBtnCancel ( this, ResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ResId( BTN_HELP ) ),
+ aRbOriginal ( this, ResId( RB_ORIGINAL ) ),
+ aRbSize ( this, ResId( RB_SIZE ) ),
+ aGrpMode ( this, ResId( GRP_MODE ) ),
+ aFtSizeX ( this, ResId( FT_SIZEX ) ),
+ aMtfSizeX ( this, ResId( MTF_SIZEX ) ),
+ aFtSizeY ( this, ResId( FT_SIZEY ) ),
+ aMtfSizeY ( this, ResId( MTF_SIZEY ) ),
+ aGrpSize ( this, ResId( GRP_SIZE ) ),
+ pConfig ( rPara.pCfg ),
+ pMgr ( rPara.pResMgr )
+
+{
+ FreeResource();
+
+ aBtnOK.SetClickHdl( LINK( this, DlgExportEMET, OK ) );
+ aRbOriginal.SetClickHdl( LINK( this, DlgExportEMET, ClickRbOriginal ) );
+ aRbSize.SetClickHdl( LINK( this, DlgExportEMET, ClickRbSize ) );
+
+ // Config-Parameter lesen
+ String aModeStr( ResId( KEY_MODE, pMgr ) );
+ String aSizeXStr( ResId( KEY_SIZEX, pMgr ) );
+ String aSizeYStr( ResId( KEY_SIZEY, pMgr ) );
+ ByteString aStrMode( pConfig->ReadKey( ByteString( aModeStr, RTL_TEXTENCODING_UTF8 ) ) );
+ ByteString aStrSizeX( pConfig->ReadKey( ByteString( aSizeXStr, RTL_TEXTENCODING_UTF8 ) ) );
+ ByteString aStrSizeY( pConfig->ReadKey( ByteString( aSizeYStr, RTL_TEXTENCODING_UTF8 ) ) );
+
+ aMtfSizeX.SetDefaultUnit( FUNIT_MM );
+ aMtfSizeY.SetDefaultUnit( FUNIT_MM );
+
+ if ( !aStrSizeX.Len() )
+ aMtfSizeX.SetValue( 10000 );
+ else
+ aMtfSizeX.SetValue( aStrSizeX.ToInt32() );
+
+ if ( !aStrSizeY.Len() )
+ aMtfSizeY.SetValue( 10000 );
+ else
+ aMtfSizeY.SetValue( aStrSizeY.ToInt32() );
+
+ switch ( rPara.eFieldUnit )
+ {
+// case FUNIT_NONE :
+// case FUNIT_KM :
+// case FUNIT_PERCENT :
+// case FUNIT_CUSTOM :
+// case FUNIT_MILE :
+// case FUNIT_FOOT :
+// case FUNIT_M :
+ case FUNIT_MM :
+ case FUNIT_CM :
+ case FUNIT_TWIP :
+ case FUNIT_POINT :
+ case FUNIT_PICA :
+ case FUNIT_INCH :
+ case FUNIT_100TH_MM :
+ {
+ aMtfSizeX.SetUnit( rPara.eFieldUnit );
+ aMtfSizeY.SetUnit( rPara.eFieldUnit );
+ }
+ break;
+ }
+
+ if ( aStrMode.Len() && ( aStrMode.GetChar( 0 ) == '1' ) )
+ {
+ aRbSize.Check( TRUE );
+ ClickRbSize( NULL );
+ }
+ else
+ {
+ aRbOriginal.Check( TRUE );
+ ClickRbOriginal( NULL );
+ }
+}
+
+/*************************************************************************
+|*
+|* Speichert eingestellte Werte in ini-Datei
+|*
+\************************************************************************/
+
+IMPL_LINK( DlgExportEMET, OK, void *, EMPTYARG )
+{
+ // Config-Parameter schreiben
+ sal_Int32 nSizeX = (sal_Int32)MetricField::ConvertDoubleValue( aMtfSizeX.GetValue(), 2, aMtfSizeX.GetUnit(), MAP_100TH_MM );
+ sal_Int32 nSizeY = (sal_Int32)MetricField::ConvertDoubleValue( aMtfSizeY.GetValue(), 2, aMtfSizeY.GetUnit(), MAP_100TH_MM );
+ sal_Int32 nStrMode = ( aRbSize.IsChecked() ) ? 1 : 0;
+
+ String aModeStr( ResId( KEY_MODE, pMgr ) );
+ String aSizeXStr( ResId( KEY_SIZEX, pMgr ) );
+ String aSizeYStr( ResId( KEY_SIZEY, pMgr ) );
+ pConfig->WriteKey( ByteString( aModeStr, RTL_TEXTENCODING_UTF8 ), ByteString::CreateFromInt32( nStrMode ) );
+ pConfig->WriteKey( ByteString( aSizeXStr, RTL_TEXTENCODING_UTF8 ), ByteString::CreateFromInt32( nSizeX ) );
+ pConfig->WriteKey( ByteString( aSizeYStr, RTL_TEXTENCODING_UTF8 ), ByteString::CreateFromInt32( nSizeY ) );
+
+ EndDialog( RET_OK );
+
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* Enabled/Disabled Controls
+|*
+\************************************************************************/
+
+IMPL_LINK( DlgExportEMET, ClickRbOriginal, void*, EMPTYARG )
+{
+ aGrpSize.Disable();
+ aFtSizeX.Disable();
+ aMtfSizeX.Disable();
+ aFtSizeY.Disable();
+ aMtfSizeY.Disable();
+
+ return 0;
+}
+
+
+/*************************************************************************
+|*
+|* Enabled/Disabled Controls
+|*
+\************************************************************************/
+#pragma SEG_FUNCDEF(dlgeos2_09)
+
+IMPL_LINK( DlgExportEMET, ClickRbSize, void*, EMPTYARG )
+{
+ aGrpSize.Enable();
+ aFtSizeX.Enable();
+ aMtfSizeX.Enable();
+ aFtSizeY.Enable();
+ aMtfSizeY.Enable();
+
+ return 0;
+}
+
+
+/*************************************************************************
+
+ Source Code Control System - History
+
+ $Log: not supported by cvs2svn $
+ Revision 1.6 2000/09/15 15:27:06 willem.vandorp
+ OpenOffice header added.
+
+ Revision 1.5 2000/07/26 17:24:45 willem.vandorp
+ Headers/footers replaced
+
+ Revision 1.4 2000/04/16 11:17:23 sj
+ #75046# displaying different metrics
+
+ Revision 1.3 2000/04/07 11:31:47 sj
+ unicode changes
+
+ Revision 1.2 1998/01/17 11:56:14 KA
+ Includes
+
+
+ Rev 1.1 17 Jan 1998 12:56:14 KA
+ Includes
+
+ Rev 1.0 26 Aug 1997 11:36:48 KA
+ Initial revision.
+
+ Rev 1.2 06 Feb 1996 12:38:06 KA
+ #25026#: Defaultgroesse fuer Export auf 10*10 cm angehoben
+
+ Rev 1.1 22 Jan 1996 15:25:10 KA
+ Dialoge umgestellt / erweitert
+
+ Rev 1.0 19 Jan 1996 20:09:16 KA
+ Dialoganbindung
+
+*************************************************************************/
+
+#pragma SEG_EOFMODULE
diff --git a/goodies/source/filter.vcl/eos2met/dlgeos2.hrc b/goodies/source/filter.vcl/eos2met/dlgeos2.hrc
new file mode 100644
index 000000000000..6e8ab913e32f
--- /dev/null
+++ b/goodies/source/filter.vcl/eos2met/dlgeos2.hrc
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgeos2.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "goodies.hrc"
+
+#define BTN_OK 1
+#define BTN_CANCEL 1
+#define BTN_HELP 1
+#define CBX_SIZE 2
+#define MTF_SIZEX 1
+#define MTF_SIZEY 2
+#define FT_SIZEX 1
+#define FT_SIZEY 2
+#define GRP_SIZE 1
+#define GRP_MODE 2
+#define RB_ORIGINAL 1
+#define RB_SIZE 2
+
diff --git a/goodies/source/filter.vcl/eos2met/dlgeos2.hxx b/goodies/source/filter.vcl/eos2met/dlgeos2.hxx
new file mode 100644
index 000000000000..c014e50cb6c7
--- /dev/null
+++ b/goodies/source/filter.vcl/eos2met/dlgeos2.hxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgeos2.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _DLGEOS2_HXX_
+#define _DLGEOS2_HXX_
+#include <svtools/fltcall.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/group.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/field.hxx>
+
+/*************************************************************************
+|*
+|* Dialog zum Einstellen von Filteroptionen bei Vektorformaten
+|*
+\************************************************************************/
+
+class Config;
+class ResMgr;
+
+class DlgExportEMET : public ModalDialog
+{
+private:
+ OKButton aBtnOK;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ RadioButton aRbOriginal;
+ RadioButton aRbSize;
+ GroupBox aGrpMode;
+
+ FixedText aFtSizeX;
+ MetricField aMtfSizeX;
+ FixedText aFtSizeY;
+ MetricField aMtfSizeY;
+ GroupBox aGrpSize;
+
+ Config* pConfig;
+ ResMgr* pMgr;
+
+ DECL_LINK( OK, void* p );
+ DECL_LINK( ClickRbOriginal,void* p );
+ DECL_LINK( ClickRbSize,void* p );
+
+public:
+ DlgExportEMET( FltCallDialogParameter& rPara );
+};
+
+
+#endif // _DLGEMET_HXX_
+
diff --git a/goodies/source/filter.vcl/eos2met/dlgeos2.src b/goodies/source/filter.vcl/eos2met/dlgeos2.src
new file mode 100644
index 000000000000..b543fefae4db
--- /dev/null
+++ b/goodies/source/filter.vcl/eos2met/dlgeos2.src
@@ -0,0 +1,318 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgeos2.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include "dlgeos2.hrc"
+
+ModalDialog DLG_EXPORT_EMET
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 178 , 98 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Text = "MET Optionen" ;
+ Text [ ENGLISH ] = "MET options" ;
+ Text [ english_us ] = "MET Options" ;
+ Text [ italian ] = "Opzioni MET" ;
+ Text [ spanish ] = "Opciones MET" ;
+ Text [ french ] = "Options MET" ;
+ Text [ dutch ] = "MET-opties" ;
+ Text [ swedish ] = "MET alternativ" ;
+ Text [ danish ] = "MET indstillinger" ;
+ Text [ portuguese_brazilian ] = "MET Optionen" ;
+ Text [ portuguese ] = "Opções MET" ;
+ MetricField MTF_SIZEX
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 59 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 100 ;
+ Maximum = 99999 ;
+ StrictFormat = TRUE ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_MM ;
+ First = 100 ;
+ Last = 99999 ;
+ SpinSize = 100 ;
+ };
+ MetricField MTF_SIZEY
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 74 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 100 ;
+ Maximum = 99999 ;
+ StrictFormat = TRUE ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_MM ;
+ First = 100 ;
+ Last = 99999 ;
+ SpinSize = 100 ;
+ };
+ GroupBox GRP_SIZE
+ {
+ Pos = MAP_APPFONT ( 6 , 48 ) ;
+ Size = MAP_APPFONT ( 110 , 44 ) ;
+ Text = "Größe" ;
+ Text [ ENGLISH ] = "Size" ;
+ Text [ english_us ] = "Size" ;
+ Text [ dutch ] = "Grootte" ;
+ Text [ italian ] = "Dimens." ;
+ Text [ spanish ] = "Tamaño" ;
+ Text [ french ] = "Taille" ;
+ Text [ swedish ] = "Storlek" ;
+ Text [ danish ] = "Størrelse" ;
+ Text [ portuguese ] = "Tamanho" ;
+ Text [ portuguese_brazilian ] = "Tamanho" ;
+ Text[ russian ] = "Ðàçìåð";
+ Text[ polish ] = "Rozmiar";
+ Text[ japanese ] = "»²½Þ";
+ Text[ chinese_simplified ] = "´óС";
+ Text[ chinese_traditional ] = "¤j¤p";
+ Text[ arabic ] = "ÇáÍÌã";
+ Text[ dutch ] = "Grootte";
+ Text[ chinese_simplified ] = "´óС";
+ Text[ greek ] = "ÌÝãåèïò";
+ Text[ korean ] = "Å©±â";
+ Text[ turkish ] = "Boyut";
+ Text[ language_user1 ] = " ";
+ };
+ FixedText FT_SIZEX
+ {
+ Pos = MAP_APPFONT ( 12 , 59 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text = "Breite" ;
+ Text [ ENGLISH ] = "Width" ;
+ Text [ dutch ] = "Breedte" ;
+ Text [ english_us ] = "Width" ;
+ Text [ italian ] = "Larghezza" ;
+ Text [ spanish ] = "Ancho" ;
+ Text [ french ] = "Largeur" ;
+ Text [ swedish ] = "Bredd" ;
+ Text [ danish ] = "Bredde" ;
+ Text [ portuguese ] = "Largura" ;
+ Text [ portuguese_brazilian ] = "Largura" ;
+ Text[ russian ] = "Øèðèíà";
+ Text[ polish ] = "Szer.";
+ Text[ japanese ] = "•";
+ Text[ chinese_simplified ] = "¿í¶È";
+ Text[ chinese_traditional ] = "¼e«×";
+ Text[ arabic ] = "ÇáÚÑÖ";
+ Text[ dutch ] = "Breedte";
+ Text[ chinese_simplified ] = "¿í¶È";
+ Text[ greek ] = "ÐëÜôïò";
+ Text[ korean ] = "³Êºñ";
+ Text[ turkish ] = "Geniþlik";
+ Text[ language_user1 ] = " ";
+ };
+ FixedText FT_SIZEY
+ {
+ Pos = MAP_APPFONT ( 12 , 74 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text = "Höhe" ;
+ Text [ ENGLISH ] = "Height" ;
+ Text [ english_us ] = "Height" ;
+ Text [ italian ] = "Altezza" ;
+ Text [ spanish ] = "Altura" ;
+ Text [ french ] = "Hauteur" ;
+ Text [ dutch ] = "Hoogte" ;
+ Text [ swedish ] = "Höjd" ;
+ Text [ danish ] = "Højde" ;
+ Text [ portuguese_brazilian ] = "Højde" ;
+ Text [ portuguese ] = "Altura" ;
+ Text[ russian ] = "Âûñîòà";
+ Text[ polish ] = "Wys.";
+ Text[ japanese ] = "‚‚³";
+ Text[ chinese_simplified ] = "¸ß¶È";
+ Text[ chinese_traditional ] = "°ª«×";
+ Text[ arabic ] = "ÇáÇÑÊÝÇÚ";
+ Text[ dutch ] = "Hoogte";
+ Text[ chinese_simplified ] = "¸ß¶È";
+ Text[ greek ] = "¾øïò";
+ Text[ korean ] = "³ôÀÌ";
+ Text[ turkish ] = "Yükseklik";
+ Text[ language_user1 ] = " ";
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 122 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 122 , 24 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 122 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ RadioButton RB_ORIGINAL
+ {
+ Pos = MAP_APPFONT ( 12 , 12 ) ;
+ Size = MAP_APPFONT ( 98 , 12 ) ;
+ TabStop = TRUE ;
+ Text = "~Original" ;
+ Text [ ENGLISH ] = "~Original" ;
+ Text [ dutch ] = "~Origineel" ;
+ Text [ english_us ] = "~Original" ;
+ Text [ italian ] = "~Originale" ;
+ Text [ spanish ] = "~Original" ;
+ Text [ french ] = "~Original" ;
+ Text [ swedish ] = "~Original" ;
+ Text [ danish ] = "~Original" ;
+ Text [ portuguese_brazilian ] = "~Original" ;
+ Text [ portuguese ] = "~Original" ;
+ Text[ russian ] = "Îðèãèíàë";
+ Text[ polish ] = "Orygina³";
+ Text[ japanese ] = "µØ¼ÞÅÙ(~O)";
+ Text[ chinese_simplified ] = "Ô­¼þ(~O)";
+ Text[ chinese_traditional ] = "­ì¥ó(~O)";
+ Text[ arabic ] = "ÇáÃÕá";
+ Text[ dutch ] = "~Origineel";
+ Text[ chinese_simplified ] = "Ô­¼þ(~O)";
+ Text[ greek ] = "Á~ñ÷éêü";
+ Text[ korean ] = "¿À¸®Áö³Î(~O)";
+ Text[ language_user1 ] = " ";
+ Text[ turkish ] = "Aslý";
+ };
+ RadioButton RB_SIZE
+ {
+ Pos = MAP_APPFONT ( 12 , 27 ) ;
+ Size = MAP_APPFONT ( 98 , 12 ) ;
+ TabStop = TRUE ;
+ Text = "~Größe" ;
+ Text [ ENGLISH ] = "~Size" ;
+ Text [ dutch ] = "~Grootte" ;
+ Text [ english_us ] = "~Size" ;
+ Text [ italian ] = "~Dimens." ;
+ Text [ spanish ] = "~Tamaño" ;
+ Text [ french ] = "~Taille" ;
+ Text [ swedish ] = "~Storlek" ;
+ Text [ danish ] = "~Størrelse" ;
+ Text [ portuguese ] = "~Tamanho" ;
+ Text [ portuguese_brazilian ] = "~Tamanho" ;
+ Text[ russian ] = "Ðàçìåð";
+ Text[ polish ] = "Rozmiar";
+ Text[ japanese ] = "»²½Þ(~S)";
+ Text[ chinese_simplified ] = "´óС(~S)";
+ Text[ chinese_traditional ] = "¤j¤p(~S)";
+ Text[ arabic ] = "ÇáÍÌã";
+ Text[ dutch ] = "~Grootte";
+ Text[ chinese_simplified ] = "´óС(~S)";
+ Text[ greek ] = "ÌÝãåèïò";
+ Text[ korean ] = "Å©±â(~S)";
+ Text[ turkish ] = "Boyut";
+ Text[ language_user1 ] = " ";
+ };
+ GroupBox GRP_MODE
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 110 , 42 ) ;
+ Text = "Modus" ;
+ Text [ ENGLISH ] = "Mode" ;
+ Text [ dutch ] = "Modus" ;
+ Text [ english_us ] = "Mode" ;
+ Text [ italian ] = "Modo" ;
+ Text [ spanish ] = "Modo" ;
+ Text [ french ] = "Mode" ;
+ Text [ swedish ] = "Läge" ;
+ Text [ danish ] = "Modus" ;
+ Text [ portuguese_brazilian ] = "Modus" ;
+ Text [ portuguese ] = "Modo" ;
+ Text[ russian ] = "Ðåæèì";
+ Text[ polish ] = "Tryb";
+ Text[ japanese ] = "Ó°ÄÞ";
+ Text[ chinese_simplified ] = "ģʽ";
+ Text[ chinese_traditional ] = "¼Ò¦¡";
+ Text[ arabic ] = "ÇáæÖÚ";
+ Text[ dutch ] = "Modus";
+ Text[ chinese_simplified ] = "ģʽ";
+ Text[ greek ] = "ÊáôÜóôáóç";
+ Text[ korean ] = "¸ðµå";
+ Text[ turkish ] = "Kip";
+ Text[ language_user1 ] = " ";
+ };
+ Text[ russian ] = "Ïàðàìåòðû MET";
+ Text[ polish ] = "Opcje MET";
+ Text[ japanese ] = "MET µÌß¼®Ý";
+ Text[ chinese_simplified ] = "MET Ñ¡Ïî";
+ Text[ chinese_traditional ] = "MET¿ï¶µ";
+ Text[ arabic ] = "MET ÎíÇÑÇÊ";
+ Text[ dutch ] = "MET-opties";
+ Text[ chinese_simplified ] = "MET Ñ¡Ïî";
+ Text[ greek ] = "ÅðéëïãÝò MET";
+ Text[ korean ] = "MET ¿É¼Ç";
+ Text[ turkish ] = "MET seçenekleri";
+ Text[ language_user1 ] = " ";
+};
diff --git a/goodies/source/filter.vcl/eos2met/eos2met.cxx b/goodies/source/filter.vcl/eos2met/eos2met.cxx
new file mode 100644
index 000000000000..829c8f50d36b
--- /dev/null
+++ b/goodies/source/filter.vcl/eos2met/eos2met.cxx
@@ -0,0 +1,2667 @@
+/*************************************************************************
+ *
+ * $RCSfile: eos2met.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#if SUPD <= 364
+#include <tools/mtf.hxx>
+#include <fltcall.hxx>
+#else
+#include <svtools/fltcall.hxx>
+#endif
+
+#include <math.h>
+#include <tools/stream.hxx>
+#include <tools/bigint.hxx>
+#include <vcl/metaact.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/poly.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/gradient.hxx>
+#include <vcl/hatch.hxx>
+#include <vcl/metric.hxx>
+#include <vcl/font.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <svtools/solar.hrc>
+#include "strings.hrc"
+#include "dlgeos2.hxx"
+
+// -----------------------------Feld-Typen-------------------------------
+
+#define BegDocumnMagic 0xA8A8 /* Begin Document */
+#define EndDocumnMagic 0xA8A9 /* End Document */
+
+#define BegResGrpMagic 0xC6A8 /* Begin Resource Group */
+#define EndResGrpMagic 0xC6A9 /* End Resource Group */
+
+#define BegColAtrMagic 0x77A8 /* Begin Color Attribute Table */
+#define EndColAtrMagic 0x77A9 /* End Color Attribute Table */
+#define BlkColAtrMagic 0x77B0 /* Color Attribute Table */
+#define MapColAtrMagic 0x77AB /* Map Color Attribute Table */
+
+#define BegImgObjMagic 0xFBA8 /* Begin Image Object */
+#define EndImgObjMagic 0xFBA9 /* End Image Object */
+#define DscImgObjMagic 0xFBA6 /* Image Data Descriptor */
+#define DatImgObjMagic 0xFBEE /* Image Picture Data */
+
+#define BegObjEnvMagic 0xC7A8 /* Begin Object Environment Group */
+#define EndObjEnvMagic 0xC7A9 /* End Object Environment Group */
+
+#define BegGrfObjMagic 0xBBA8 /* Begin Graphics Object */
+#define EndGrfObjMagic 0xBBA9 /* End Graphics Object */
+#define DscGrfObjMagic 0xBBA6 /* Graphics Data Descritor */
+#define DatGrfObjMagic 0xBBEE /* Graphics Data */
+
+#define MapCodFntMagic 0x8AAB /* Map Coded Font */
+#define MapDatResMagic 0xC3AB /* Map Data Resource */
+
+// Struktur des Metafiles
+// BegDocumn
+// BegResGrp
+// BegColAtr
+// BlkColAtr
+// EndColAtr
+// BegImgObj[0..n]
+// BegResGrp[]
+// BegColAtr[]
+// BlkColAtr
+// EndColAtr
+// EndResGrp
+// BegObjEnv[]
+// MapColAtr
+// EndObjEnv
+// DscImgObj
+// DatImgOb1
+// DatImgOb2[1..n]
+// EndImgObj
+// BegGrfObj
+// BegObjEnv[]
+// MapColAtr
+// MapCodFnt1
+// MapCodFnt2[0..n]
+// MapDatRes[0..n]
+// EndObjEnv
+// DscGrfObj
+// DatGrfObj[0..n]
+// EndGrfObj
+// EndResGrp
+// EndDocumn
+
+//============================== METWriter ===================================
+
+struct METChrSet
+{
+ struct METChrSet * pSucc;
+ BYTE nSet;
+ ByteString aName;
+ FontWeight eWeight;
+};
+
+struct METGDIStackMember
+{
+ struct METGDIStackMember * pSucc;
+ Color aLineColor;
+ Color aFillColor;
+ RasterOp eRasterOp;
+ Font aFont;
+ MapMode aMapMode;
+ Region aClipRegion;
+};
+
+class METWriter
+{
+private:
+
+ BOOL bStatus;
+ PFilterCallback pCallback;
+ void* pCallerData;
+ ULONG nLastPercent; // Mit welcher Zahl pCallback zuletzt aufgerufen wurde.
+ SvStream* pMET;
+ Rectangle aPictureRect;
+ MapMode aPictureMapMode;
+ MapMode aTargetMapMode;
+ ULONG nActualFieldStartPos; // Anfangs-Position des aktuellen 'Field'
+ ULONG nNumberOfDataFields; // Anzahl der angefangenen 'Graphcis Data Fields'
+ Color aGDILineColor;
+ Color aGDIFillColor;
+ RasterOp eGDIRasterOp;
+ Font aGDIFont;
+ MapMode aGDIMapMode; // derzeit unbenutzt!
+ Region aGDIClipRegion; // derzeit unbenutzt!
+ METGDIStackMember* pGDIStack;
+ Color aMETColor;
+ Color aMETBackgroundColor;
+ Color aMETPatternSymbol;
+ RasterOp eMETMix ;
+ long nMETStrokeLineWidth;
+ Size aMETChrCellSize;
+ short nMETChrAngle;
+ BYTE nMETChrSet;
+ METChrSet* pChrSetList; // Liste der Character-Sets
+ BYTE nNextChrSetId; // die erste unbenutzte ChrSet-Id
+ ULONG nActBitmapId; // Field-Id der naechsten Bitmap
+ ULONG nNumberOfActions; // Anzahl der Actions im GDIMetafile
+ ULONG nNumberOfBitmaps; // Anzahl der Bitmaps
+ ULONG nWrittenActions; // Anzahl der bereits verarbeiteten Actions beim Schreiben der Orders
+ ULONG nWrittenBitmaps; // Anzahl der bereits geschriebenen Bitmaps
+ ULONG nActBitmapPercent; // Wieviel Prozent die naechste Bitmap schon geschrieben ist.
+
+ void MayCallback();
+ // Berechnet anhand der obigen 5 Parameter eine Prozentzahl
+ // und macht dann ggf. einen Callback. Setzt bStatus auf FALSE wenn User abbrechen
+ // moechte.
+
+ void CountActionsAndBitmaps(const GDIMetaFile * pMTF);
+ // Zaehlt die Bitmaps und Actions (nNumberOfActions und nNumberOfBitmaps muessen
+ // zu Anfang auf 0 gesetzt werden, weil diese Methode rekursiv ist)
+
+ void WriteBigEndianShort(USHORT nWord);
+ void WriteBigEndianLong(ULONG nLong);
+
+ void WritePoint(Point aPt);
+
+ void WriteFieldIntroducer(USHORT nFieldSize, USHORT nFieldType,
+ BYTE nFlags, USHORT nSegSeqNum);
+ void UpdateFieldSize();
+
+ void WriteFieldId(ULONG nId);
+
+ void CreateChrSets(const GDIMetaFile * pMTF);
+ void CreateChrSet(const Font & rFont);
+ void WriteChrSets();
+ BYTE FindChrSet(const Font & rFont);
+
+ void WriteColorAttributeTable(ULONG nFieldId=4, BitmapPalette* pPalette=NULL,
+ BYTE nBasePartFlags=0x40, BYTE nBasePartLCTID=0);
+
+ void WriteImageObject(const Bitmap & rBitmap);
+ void WriteImageObjects(const GDIMetaFile * pMTF);
+
+ void WriteDataDescriptor(const GDIMetaFile * pMTF);
+
+ void WillWriteOrder(ULONG nNextOrderMaximumLength);
+
+ void METSetAndPushLineInfo( const LineInfo& rLineInfo );
+ void METPopLineInfo( const LineInfo& rLineInfo );
+ void METBitBlt(Point aPt, Size aSize, const Bitmap & rBitmap);
+ void METBeginArea(BOOL bBoundaryLine);
+ void METEndArea();
+ void METBeginPath(ULONG nPathId);
+ void METEndPath();
+ void METFillPath(ULONG nPathId);
+ void METOutlinePath(ULONG nPathId);
+ void METCloseFigure();
+ void METMove(Point aPt);
+ void METLine(Point aPt1, Point aPt2);
+ void METLine(const Polygon & rPolygon);
+ void METLine(const PolyPolygon & rPolyPolygon);
+ void METLineAtCurPos(Point aPt);
+ void METBox(BOOL bFill, BOOL bBoundary,
+ Rectangle aRect, ULONG nHAxis, ULONG nVAxis);
+ void METArc(Point aP0, Point aP1, Point aP2);
+ void METArcAtCurPos(Point aP1, Point aP2);
+ void METFullArc(Point aCenter, double fMultiplier);
+ void METPartialArcAtCurPos(Point aCenter, double fMultiplier,
+ double fStartAngle, double fSweepAngle);
+ void METChrStr(Point aPt, String aStr);
+ void METSetArcParams(long nP, long nQ, long nR, long nS);
+ void METSetColor(Color aColor);
+ void METSetBackgroundColor(Color aColor);
+ void METSetMix(RasterOp eROP);
+ void METSetChrCellSize(Size aSize);
+ void METSetChrAngle(short nAngle);
+ void METSetChrSet(BYTE nSet);
+
+ void WriteOrders(const GDIMetaFile * pMTF);
+
+ void WriteObjectEnvironmentGroup(const GDIMetaFile * pMTF);
+
+ void WriteGraphicsObject(const GDIMetaFile * pMTF);
+
+ void WriteResourceGroup(const GDIMetaFile * pMTF);
+
+ void WriteDocument(const GDIMetaFile * pMTF);
+
+public:
+
+ METWriter() {}
+
+ BOOL WriteMET(const GDIMetaFile & rMTF, SvStream & rTargetStream,
+ PFilterCallback pcallback, void * pcallerdata);
+};
+
+
+//========================== Methoden von METWriter ==========================
+
+void METWriter::MayCallback()
+{
+ ULONG nPercent;
+
+ // Wir gehen mal einfach so davon aus, dass 16386 Actions einer Bitmap entsprechen
+ // (in der Regel wird ein Metafile entweder nur Actions oder einige Bitmaps und fast
+ // keine Actions enthalten. Dann ist das Verhaeltnis ziemlich unwichtig)
+
+ nPercent=((nWrittenBitmaps<<14)+(nActBitmapPercent<<14)/100+nWrittenActions)
+ *100/((nNumberOfBitmaps<<14)+nNumberOfActions);
+
+ if (nPercent>=nLastPercent+3)
+ {
+ nLastPercent=nPercent;
+ if(pCallback!=NULL && nPercent<=100)
+ {
+ if (((*pCallback)(pCallerData,(USHORT)nPercent))==TRUE)
+ bStatus=FALSE;
+ }
+ }
+}
+
+void METWriter::CountActionsAndBitmaps(const GDIMetaFile * pMTF)
+{
+ const MetaAction* pMA;
+
+ for( ULONG nAction = 0, nCount=pMTF->GetActionCount(); nAction < nCount; nAction++ )
+ {
+ pMA = pMTF->GetAction(nAction);
+
+ switch (pMA->GetType())
+ {
+ case META_EPS_ACTION :
+ {
+ const GDIMetaFile aGDIMetaFile( ((const MetaEPSAction*)pMA)->GetSubstitute() );
+ INT32 nCount = aGDIMetaFile.GetActionCount();
+ INT32 i;
+ for ( i = 0; i < nCount; i++ )
+ if ( ((const MetaAction*)aGDIMetaFile.GetAction( i ))->GetType() == META_BMPSCALE_ACTION )
+ break;
+ if ( i == nCount)
+ break;
+ }
+ case META_BMP_ACTION:
+ case META_BMPSCALE_ACTION:
+ case META_BMPSCALEPART_ACTION:
+ case META_BMPEX_ACTION:
+ case META_BMPEXSCALE_ACTION:
+ case META_BMPEXSCALEPART_ACTION:
+ nNumberOfBitmaps++;
+ break;
+ }
+ nNumberOfActions++;
+ }
+}
+
+
+void METWriter::WriteBigEndianShort(USHORT nWord)
+{
+ *pMET << ((BYTE)(nWord>>8)) << ((BYTE)(nWord&0x00ff));
+}
+
+
+void METWriter::WriteBigEndianLong(ULONG nLong)
+{
+ WriteBigEndianShort((USHORT)(nLong>>16));
+ WriteBigEndianShort((USHORT)(nLong&0x0000ffff));
+}
+
+
+void METWriter::WritePoint(Point aPt)
+{
+ Point aNewPt = OutputDevice::LogicToLogic( aPt, aPictureMapMode, aTargetMapMode );
+
+ *pMET << (long) ( aNewPt.X() - aPictureRect.Left() )
+ << (long) ( aPictureRect.Bottom() - aNewPt.Y() );
+}
+
+
+void METWriter::WriteFieldIntroducer(USHORT nFieldSize, USHORT nFieldType,
+ BYTE nFlags, USHORT nSegSeqNum)
+{
+ nActualFieldStartPos=pMET->Tell();
+ WriteBigEndianShort(nFieldSize);
+ *pMET << (BYTE)0xd3 << nFieldType << nFlags << nSegSeqNum;
+}
+
+
+void METWriter::UpdateFieldSize()
+{
+ ULONG nPos;
+
+ nPos=pMET->Tell();
+ pMET->Seek(nActualFieldStartPos);
+ WriteBigEndianShort((USHORT)(nPos-nActualFieldStartPos));
+ pMET->Seek(nPos);
+}
+
+
+void METWriter::WriteFieldId(ULONG nId)
+{
+ BYTE nbyte;
+ short i;
+
+ for (i=1; i<=8; i++) {
+ nbyte= '0' + (BYTE)((nId >> (32-i*4)) & 0x0f);
+ *pMET << nbyte;
+ }
+}
+
+
+void METWriter::CreateChrSets(const GDIMetaFile * pMTF)
+{
+ ULONG nAction, nActionCount;
+ const MetaAction * pMA;
+
+ if (bStatus==FALSE)
+ return;
+
+ nActionCount=pMTF->GetActionCount();
+
+ for (nAction=0; nAction<nActionCount; nAction++)
+ {
+ pMA = pMTF->GetAction(nAction);
+
+ switch (pMA->GetType())
+ {
+ case META_FONT_ACTION:
+ {
+ const MetaFontAction* pA = (const MetaFontAction*) pMA;
+ CreateChrSet( pA->GetFont() );
+ }
+ break;
+ }
+ }
+}
+
+
+void METWriter::CreateChrSet(const Font & rFont)
+{
+ METChrSet * pCS;
+
+ if ( FindChrSet( rFont ) == 0 )
+ {
+ pCS = new METChrSet;
+ pCS->pSucc = pChrSetList; pChrSetList=pCS;
+ pCS->nSet = nNextChrSetId++;
+ pCS->aName = ByteString( rFont.GetName(), RTL_TEXTENCODING_UTF8 );
+ pCS->eWeight = rFont.GetWeight();
+ }
+}
+
+
+BYTE METWriter::FindChrSet(const Font & rFont)
+{
+ METChrSet* pCS;
+
+ for (pCS=pChrSetList; pCS!=NULL; pCS=pCS->pSucc)
+ {
+ if (pCS->aName==rFont.GetName() && pCS->eWeight==rFont.GetWeight() )
+ return pCS->nSet;
+ }
+
+ return 0;
+}
+
+
+void METWriter::WriteChrSets()
+{
+ USHORT i;
+ char c;
+ METChrSet * pCS;
+ BYTE nbyte;
+
+ for (pCS=pChrSetList; pCS!=NULL; pCS=pCS->pSucc)
+ {
+
+ WriteFieldIntroducer(0x58,MapCodFntMagic,0,0);
+
+ WriteBigEndianShort(0x0050);
+
+ *pMET << (BYTE)0x0c << (BYTE)0x02 << (BYTE)0x84 << (BYTE)0x00;
+ *pMET << (BYTE)0xa4 << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x01;
+ *pMET << (BYTE)0x01 << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x00;
+
+ *pMET << (BYTE)0x04 << (BYTE)0x24 << (BYTE)0x05 << (BYTE)pCS->nSet;
+
+ *pMET << (BYTE)0x14 << (BYTE)0x1f;
+ switch (pCS->eWeight)
+ {
+ case WEIGHT_THIN: nbyte=1; break;
+ case WEIGHT_ULTRALIGHT: nbyte=2; break;
+ case WEIGHT_LIGHT: nbyte=3; break;
+ case WEIGHT_SEMILIGHT: nbyte=4; break;
+ case WEIGHT_NORMAL: nbyte=5; break;
+ case WEIGHT_SEMIBOLD: nbyte=6; break;
+ case WEIGHT_BOLD: nbyte=7; break;
+ case WEIGHT_ULTRABOLD: nbyte=8; break;
+ case WEIGHT_BLACK: nbyte=9; break;
+ default: nbyte=5;
+ }
+ *pMET << nbyte;
+ *pMET << (BYTE)0x05;
+ *pMET << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x00;
+ *pMET << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x00;
+ *pMET << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x00;
+ *pMET << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x0c;
+
+ *pMET << (BYTE)0x06 << (BYTE)0x20 << (BYTE)0x03 << (BYTE)0xd4;
+ *pMET << (BYTE)0x03 << (BYTE)0x52;
+
+ *pMET << (BYTE)0x24 << (BYTE)0x02 << (BYTE)0x08 << (BYTE)0x00;
+ for (i=0; i<32; i++)
+ {
+ if ( i == 0 || c != 0 )
+ c = pCS->aName.GetChar( i );
+ *pMET << c;
+ }
+ }
+}
+
+
+void METWriter::WriteColorAttributeTable(ULONG nFieldId, BitmapPalette* pPalette, BYTE nBasePartFlags, BYTE nBasePartLCTID)
+{
+ USHORT nIndex,nNumI,i;
+
+ if (bStatus==FALSE) return;
+
+ //--- Das Feld 'Begin Color Attribute Table':
+ WriteFieldIntroducer(16,BegColAtrMagic,0,0);
+ WriteFieldId(nFieldId);
+
+ //--- Das Feld 'Color Attribute Table':
+ WriteFieldIntroducer(0,BlkColAtrMagic,0,0);
+ *pMET << nBasePartFlags << (BYTE)0x00 << nBasePartLCTID; // 'Base Part'
+ if (pPalette!=NULL)
+ {
+ nIndex=0;
+ while (nIndex<pPalette->GetEntryCount())
+ {
+ nNumI=pPalette->GetEntryCount()-nIndex;
+ if (nNumI>81) nNumI=81;
+ *pMET << (BYTE)(11+nNumI*3); // Laenge des Parameters
+ *pMET << (BYTE)1 << (BYTE)0 << (BYTE)1; // typ: element list, Reserved, Format: RGB
+ *pMET << (BYTE)0; WriteBigEndianShort(nIndex); // Start-Index (3 Bytes)
+ *pMET << (BYTE)8 << (BYTE)8 << (BYTE)8; // Bits je Komponente R,G,B
+ *pMET << (BYTE)3; // Anzahl Bytes je Eintrag
+ for (i=0; i<nNumI; i++)
+ {
+ const BitmapColor& rCol = (*pPalette)[ nIndex ];
+
+ *pMET << (BYTE) rCol.GetRed();
+ *pMET << (BYTE) rCol.GetGreen();
+ *pMET << (BYTE) rCol.GetBlue();
+ nIndex++;
+ }
+ }
+ }
+ else
+ {
+ // 'Trible Generating'
+ *pMET << (BYTE)0x0a << (BYTE)0x02 << (BYTE)0x00 << (BYTE)0x01 << (BYTE)0x00;
+ *pMET << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x08 << (BYTE)0x08 << (BYTE)0x08;
+ }
+ UpdateFieldSize();
+
+ //--- Das Feld 'End Color Attribute Table':
+ WriteFieldIntroducer(16,EndColAtrMagic,0,0);
+ WriteFieldId(nFieldId);
+
+ if (pMET->GetError())
+ bStatus=FALSE;
+}
+
+
+void METWriter::WriteImageObject(const Bitmap & rBitmap)
+{
+ SvMemoryStream aTemp(0x00010000,0x00010000);
+ ULONG nWidth,nHeight,nResX,nResY,nBytesPerLine,i,j,nNumColors,ny,nLines;
+ ULONG nActColMapId;
+ USHORT nBitsPerPixel;
+ BYTE nbyte, * pBuf;
+
+ if (bStatus==FALSE)
+ return;
+
+ nActColMapId=((nActBitmapId>>24)&0x000000ff) | ((nActBitmapId>> 8)&0x0000ff00) |
+ ((nActBitmapId<< 8)&0x00ff0000) | ((nActBitmapId<<24)&0xff000000);
+
+ //--- Das Feld 'Begin Image Object':
+ WriteFieldIntroducer(16,BegImgObjMagic,0,0);
+ WriteFieldId(nActBitmapId);
+
+ // Windows-BMP-Datei erzeugen:
+ aTemp << rBitmap;
+
+ // Header der Windows-BMP-Datei einlesen:
+ aTemp.SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
+ aTemp.Seek(18);
+ aTemp >> nWidth >> nHeight;
+ aTemp.SeekRel(2);
+ aTemp >> nBitsPerPixel;
+ aTemp.SeekRel(8);
+ aTemp >> nResX >> nResY;
+ aTemp.SeekRel(8);
+
+ nNumColors=1<<nBitsPerPixel;
+ nBytesPerLine=((nWidth*nBitsPerPixel+0x0000001f) & 0xffffffe0 ) >> 3;
+
+ // ggf. Farbpalette einlesen und in die MET-Datei schreiben:
+ if (nBitsPerPixel<=8)
+ {
+ BitmapPalette aPal( (USHORT) nNumColors );
+ BYTE nr,ng,nb;
+
+ for (i=0; i<nNumColors; i++)
+ {
+ aTemp >> nb >> ng >> nr; aTemp.SeekRel(1);
+ aPal[ (USHORT) i ] = BitmapColor( nr, ng, nb );
+ }
+
+ //--- Das Feld 'Begin Resource Group':
+ WriteFieldIntroducer(16,BegResGrpMagic,0,0);
+ WriteFieldId(nActColMapId);
+
+ //--- Farbtabelle schreiben:
+ WriteColorAttributeTable(nActColMapId,&aPal,0,1);
+
+ //--- Das Feld 'End Resource Group':
+ WriteFieldIntroducer(16,EndResGrpMagic,0,0);
+ WriteFieldId(nActColMapId);
+
+ //--- Das Feld 'Begin Object Environment Group':
+ WriteFieldIntroducer(16,BegObjEnvMagic,0,0);
+ WriteFieldId(nActBitmapId);
+
+ //--- Das Feld 'Map Color Attribute Table':
+ WriteFieldIntroducer(26,MapColAtrMagic,0,0);
+ WriteBigEndianShort(0x0012);
+ *pMET << (BYTE)0x0c << (BYTE)0x02 << (BYTE)0x84 << (BYTE)0x00;
+ WriteFieldId(nActColMapId);
+ *pMET << (BYTE)0x04 << (BYTE)0x24 << (BYTE)0x07 << (BYTE)0x01;
+
+ //--- Das Feld 'End Object Environment Group':
+ WriteFieldIntroducer(16,EndObjEnvMagic,0,0);
+ WriteFieldId(nActBitmapId);
+ }
+
+ //--- Das Feld 'Image Data Descriptor':
+ WriteFieldIntroducer(17,DscImgObjMagic,0,0);
+ *pMET << (BYTE)0x01; // Unit of measure: tens of centimeters
+ WriteBigEndianShort((USHORT)nResX);
+ WriteBigEndianShort((USHORT)nResY);
+ WriteBigEndianShort((USHORT)nWidth);
+ WriteBigEndianShort((USHORT)nHeight);
+
+ //--- Das erste Feld 'Image Picture Data':
+ WriteFieldIntroducer(0,DatImgObjMagic,0,0);
+
+ // Begin Segment:
+ *pMET << (BYTE)0x70 << (BYTE)0x00;
+
+ // Begin Image Content:
+ *pMET << (BYTE)0x91 << (BYTE)0x01 << (BYTE)0xff;
+
+ // Image Size:
+ *pMET << (BYTE)0x94 << (BYTE)0x09 << (BYTE)0x02;
+ *pMET << (USHORT) 0 << (USHORT) 0;
+ WriteBigEndianShort((USHORT)nHeight);
+ WriteBigEndianShort((USHORT)nWidth);
+
+ // Image Encoding:
+ *pMET << (BYTE)0x95 << (BYTE)0x02 << (BYTE)0x03 << (BYTE)0x03;
+
+ // Image IDE-Size:
+ *pMET << (BYTE)0x96 << (BYTE)0x01 << (BYTE)nBitsPerPixel;
+
+ if (nBitsPerPixel<=8) {
+ // Image LUT-ID
+ *pMET << (BYTE)0x97 << (BYTE)0x01 << (BYTE)0x01;
+ }
+ else {
+ // IDE Structure
+ *pMET << (BYTE)0x9b << (BYTE)0x08 << (BYTE)0x00 << (BYTE)0x01;
+ *pMET << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x08;
+ *pMET << (BYTE)0x08 << (BYTE)0x08;
+ }
+
+ pBuf=new BYTE[nBytesPerLine];
+ ny=0;
+ while (ny<nHeight) {
+
+ // Abschliessen des vorherigen Feldes 'Image Picture Data':
+ UpdateFieldSize();
+
+ // Und ein neues Feld 'Image Picture Data' anfangen:
+ WriteFieldIntroducer(0,DatImgObjMagic,0,0);
+
+ // Einige Scanlines lesen und schreiben:
+ nLines=nHeight-ny;
+ if (nLines*nBytesPerLine>30000) nLines=30000/nBytesPerLine;
+ if (nLines<1) nLines=1;
+ WriteBigEndianShort(0xfe92);
+ WriteBigEndianShort((USHORT)(nLines*nBytesPerLine));
+ for (i=0; i<nLines; i++) {
+ aTemp.Read(pBuf,nBytesPerLine);
+ if (nBitsPerPixel==24) {
+ for (j=2; j<nBytesPerLine; j+=3) {
+ nbyte=pBuf[j]; pBuf[j]=pBuf[j-2]; pBuf[j-2]=nbyte;
+ }
+ }
+ pMET->Write(pBuf,nBytesPerLine);
+ ny++;
+ }
+ if (aTemp.GetError() || pMET->GetError()) bStatus=FALSE;
+ nActBitmapPercent=(ny+1)*100/nHeight;
+ MayCallback();
+ if (bStatus==FALSE) { delete pBuf; return; }
+ }
+ delete pBuf;
+
+ // End Image Content:
+ *pMET << (BYTE)0x93 << (BYTE)0x00;
+
+ // End Segment:
+ *pMET << (BYTE)0x71 << (BYTE)0x00;
+
+ // Abschliessen des letzten Feldes 'Image Picture Data':
+ UpdateFieldSize();
+
+ //--- Das Feld 'End Image Object':
+ WriteFieldIntroducer(16,EndImgObjMagic,0,0);
+ WriteFieldId(nActBitmapId);
+
+ // Ids erhoehen:
+ nActBitmapId++;
+
+ // Bitmaps zaehlen:
+ nWrittenBitmaps++;
+ nActBitmapPercent=0;
+
+ if (pMET->GetError()) bStatus=FALSE;
+}
+
+
+void METWriter::WriteImageObjects(const GDIMetaFile * pMTF)
+{
+ const MetaAction* pMA;
+
+ if (bStatus==FALSE)
+ return;
+
+ for ( ULONG nAction = 0, nCount = pMTF->GetActionCount(); nAction < nCount; nAction++)
+ {
+ pMA = pMTF->GetAction(nAction);
+
+ switch (pMA->GetType())
+ {
+ case META_BMP_ACTION:
+ {
+ METSetMix( eGDIRasterOp );
+ WriteImageObject( ( (MetaBmpAction*) pMA )->GetBitmap() );
+ }
+ break;
+
+ case META_BMPSCALE_ACTION:
+ {
+ METSetMix( eGDIRasterOp );
+ WriteImageObject( ( (MetaBmpScaleAction*) pMA )->GetBitmap() );
+ }
+ break;
+
+ case META_BMPSCALEPART_ACTION:
+ {
+ METSetMix( eGDIRasterOp );
+ WriteImageObject( ( (MetaBmpScalePartAction*) pMA )->GetBitmap() );
+ }
+ break;
+
+ case META_BMPEX_ACTION:
+ {
+ METSetMix( eGDIRasterOp );
+ WriteImageObject( Graphic( ( (MetaBmpExAction*) pMA )->GetBitmapEx() ).GetBitmap() );
+ }
+ break;
+
+ case META_BMPEXSCALE_ACTION:
+ {
+ METSetMix( eGDIRasterOp );
+ WriteImageObject( Graphic( ( (MetaBmpExScaleAction*) pMA )->GetBitmapEx() ).GetBitmap() );
+ }
+ break;
+
+ case META_BMPEXSCALEPART_ACTION:
+ {
+ METSetMix( eGDIRasterOp );
+ WriteImageObject( Graphic( ( (MetaBmpExScalePartAction*) pMA )->GetBitmapEx() ).GetBitmap() );
+ }
+ break;
+
+ case META_EPS_ACTION :
+ {
+ const MetaEPSAction* pA = (const MetaEPSAction*)pMA;
+ const GDIMetaFile aGDIMetaFile( pA->GetSubstitute() );
+
+ INT32 nCount = aGDIMetaFile.GetActionCount();
+ for ( INT32 i = 0; i < nCount; i++ )
+ {
+ const MetaAction* pMetaAct = aGDIMetaFile.GetAction( i );
+ if ( pMetaAct->GetType() == META_BMPSCALE_ACTION )
+ {
+ const MetaBmpScaleAction* pBmpScaleAction = (const MetaBmpScaleAction*)pMetaAct;
+ METSetMix( eGDIRasterOp );
+ WriteImageObject( pBmpScaleAction->GetBitmap() );
+ break;
+ }
+ }
+ }
+ break;
+ }
+
+ if (bStatus==FALSE)
+ break;
+ }
+
+ if (pMET->GetError())
+ bStatus=FALSE;
+}
+
+void METWriter::WriteDataDescriptor(const GDIMetaFile *)
+{
+ if (bStatus==FALSE)
+ return;
+
+ WriteFieldIntroducer(0,DscGrfObjMagic,0,0);
+
+ //------------------------------------------------------------------------------
+ // Im Folgenden die OS2-Orginal-Dokumentation und die Implementation dazu (uff)
+ //------------------------------------------------------------------------------
+
+ // Parameters (all required and in this order)
+
+ // 0 0xF7 Specify GVM Subset
+ // 1 Length of following data 0x07
+ // 2 0xB0 drawing order subset
+ // 3-4 0x0000
+ // 5 0x23 Level 3.2
+ // 6 0x01 Version 1
+ // 7 Length of following field 0x01
+ // 8 Coordinate types in data
+ // 0x04Intel16
+ // 0x05Intel32
+ *pMET << (BYTE)0xf7 << (BYTE)0x07 << (BYTE)0xb0 << (BYTE)0x00
+ << (BYTE)0x00 << (BYTE)0x23 << (BYTE)0x01 << (BYTE)0x01
+ << (BYTE)0x05;
+
+ // 0 0xF6 Set Picture Descriptor
+ // 1 Length of following data
+ // 2 Flags
+ // 0 B'0' Picture in 2D
+ // 1 Picture Dimensions
+ // B'0' Not absolute (PU_ARBITRARY PS)
+ // B'1' Absolute (example: PU_TWIPS PS)
+ // 2 Picture Elements
+ // B'0' Not pels
+ // B'1' Pels (PU_PELS PS)
+ // (Bit 1 must also be set)
+ // 3-7 B'00000'
+ // 3 0x00 Reserved
+ // 4 Picture frame size coordinate type
+ // 0x04 Intel16
+ // 0x05 Intel32
+ // 5 UnitsOfMeasure
+ // 0x00 Ten inches
+ // 0x01 Decimeter
+ // 6-11 or 6-17(2 or 4 bytes) Resolution.
+ // GPS Units / UOM on x axis
+ // GPS Units / UOM on y axis
+ // GPS Units / UOM on z axis
+ // 12-23 or 18-41(2 or 4 bytes) Window Size.
+ // GPS X left, X right
+ // GPS Y bottom, Y top
+ // GPS Z near, Z far
+ Size aUnitsPerDecimeter=OutputDevice::LogicToLogic(Size(10,10),MapMode(MAP_CM),aPictureMapMode);
+ *pMET << (BYTE)0xf6 << (BYTE)0x28 << (BYTE)0x40 << (BYTE)0x00
+ << (BYTE)0x05 << (BYTE)0x01
+ << (ULONG)(aUnitsPerDecimeter.Width())
+ << (ULONG)(aUnitsPerDecimeter.Height())
+ << (ULONG)0
+ << (ULONG)0 << (ULONG)aPictureRect.GetWidth()
+ << (ULONG)0 << (ULONG)aPictureRect.GetHeight()
+ << (ULONG)0 << (ULONG)0;
+
+ // 0 0x21 Set Current Defaults
+ // 1 Length of following data
+ // 2 Set Default Parameter Format 0x08
+ // 3-4 Mask 0xE000
+ // 5 Names 0x8F
+ // 6 Coordinates
+ // 0x00 Picture in 2D
+ // 7 Transforms
+ // 0x04 Intel16
+ // 0x05 Intel32
+ // 8 Geometrics
+ // 0x04 Intel16
+ // 0x05 Intel32
+ *pMET << (BYTE)0x21 << (BYTE)0x07 << (BYTE)0x08 << (BYTE)0xe0
+ << (BYTE)0x00 << (BYTE)0x8f << (BYTE)0x00 << (BYTE)0x05
+ << (BYTE)0x05;
+
+ // 0 0x21 Set Current Defaults
+ // 1 Length of following data
+ // 2 Set default viewing transform 0x07
+ // 3-4 Mask 0xCC0C
+ // 5 Names 0x8F
+ // 6-n M11, M12, M21, M22, M41, M42 Matrix elements
+ *pMET << (BYTE)0x21 << (BYTE)0x1c << (BYTE)0x07 << (BYTE)0xcc
+ << (BYTE)0x0c << (BYTE)0x8f
+ << (ULONG)0x00010000 << (ULONG)0x00000000 << (ULONG)0x00000000
+ << (ULONG)0x00010000 << (ULONG)0x00000000 << (ULONG)0x00000000;
+
+ // 0 0x21 Set Current Defaults
+ // 1 Length of following data
+ // 2 Set default line attributes 0x01
+ // 3-4 Mask - OR of as many of the following bits as are required:
+ // 0x8000 Line type
+ // 0x4000 Line width
+ // 0x2000 Line end
+ // 0x1000 Line join
+ // 0x0800 Stroke width
+ // 0x0008 Line color
+ // 0x0002 Line mix
+ // 5 Flags
+ //
+ // 0x0F Set indicated default attributes to initial values. (Data field is not present in this
+ // instance).
+ // 0x8F Set indicated default attributes to specified values.
+ // 6-n Data - data values as required, in the following order if present.
+ // No space is reserved for attributes for which the corresponding mask flag was not
+ // set.
+ //
+ // (1 byte) - Line type
+ // (1 byte) - Line width
+ // (1 byte) - Line end
+ // (1 byte) - Line join
+ // (G bytes) - Stroke width
+ // (4 bytes) - Line color
+ // (1 byte) - Line mix (G=2 or 4 depending on the Geometrics parameter of Set Default
+ // Parameter Format)
+ // Nanu! witziger-weise fehlt obiger Abschnitt in den Metadateien. Also lassen wir ihn auch weg
+
+ // 0 0x21 Set Current Defaults
+ // 1 Length of following data
+ // 2 Set Default Character Attributes 0x02
+ // 3-4 Mask - OR of as many of the following bits as are required:
+ //
+ // 0x8000 Character angle
+ // 0x4000 Character box
+ // 0x2000 Character direction
+ // 0x1000 Character precision
+ // 0x0800 Character set
+ // 0x0400 Character shear
+ // 0x0040 Character break extra
+ // 0x0020 Character extra
+ // 0x0008 Character color
+ // 0x0004 Character background color
+ // 0x0002 Character mix
+ // 0x0001 Character background mix
+ // 5 Flags
+ // 0x0FSet indicated default attributes to initial values. (Data field is not present in this
+ // case).
+ // 0x8FSet indicated default attributes to specified values.
+ // 6-n Data - data values as required, in the following order if present.
+ // No space is reserved for attributes for which the corresponding Mask flag was not
+ // set.
+ // (2*G bytes) - Character angle
+ // (2*G + 4 bytes)- Character box
+ // (1 byte) - Character direction
+ // (1 byte) - Character precision
+ // (1 byte) - Character set
+ // (2*G bytes) - Character shear
+ // (4 bytes) - Character break extra
+ // (4 bytes) - Character extra
+ // (4 bytes) - Character color
+ // (4 bytes) - Character background color
+ // (1 byte) - Character mix
+ // (1 byte) - Character background mix (G=2 or 4 depending on the Geometrics
+ // parameter of Set Default Parameter Format)
+ *pMET << (BYTE)0x21 << (BYTE)0x10 << (BYTE)0x02 << (BYTE)0x40
+ << (BYTE)0x00 << (BYTE)0x8f
+ << (BYTE)0xaa << (BYTE)0x02 << (BYTE)0x00 << (BYTE)0x00
+ << (BYTE)0x44 << (BYTE)0x04 << (BYTE)0x00 << (BYTE)0x00
+ << (BYTE)0xa8 << (BYTE)0xaa << (BYTE)0x40 << (BYTE)0x44;
+
+ // 0 0x21 Set Current Defaults
+ // 1 Length of following data
+ // 2 Set Default Marker Attributes 0x03
+ // 3-4 Mask - OR of as many of the following bits as are required:
+ // 0x4000 Marker box
+ // 0x1000 Marker precision
+ // 0x0800 Marker set
+ // 0x0100 Marker symbol
+ // 0x0008 Marker color
+ // 0x0004 Marker background color
+ // 0x0002 Marker mix
+ // 0x0001 Marker background mix
+ // 5 Flags
+ // 0x0F Set indicated default attributes to initial values.
+ // (Data field is not present in this instance)
+ // 0x8F Set indicated default attributes to specified values.
+ // 6-n Data - data values as required, in this order if present.
+ // No space is reserved for attributes for which the corresponding Mask flag was not
+ // set.
+ // (2*G bytes) - Marker box
+ // (1 byte) - Marker precision
+ // (1 byte) - Marker set
+ // (1 byte) - Marker symbol
+ // (4 bytes) - Marker color
+ // (4 bytes) - Marker background color
+ // (1 byte) - Marker mix
+ // (1 byte) - Marker background mix (G=2 or 4 depending on the Geometrics
+ // parameter of Set Default Parameter Format)
+ *pMET << (BYTE)0x21 << (BYTE)0x0c << (BYTE)0x03 << (BYTE)0x40
+ << (BYTE)0x00 << (BYTE)0x8f
+ << (BYTE)0x66 << (BYTE)0x02 << (BYTE)0x00 << (BYTE)0x00
+ << (BYTE)0x66 << (BYTE)0x02 << (BYTE)0x00 << (BYTE)0x00;
+
+ // 0 0x21 Set Current Defaults
+ // 1 Length of following data
+ // 2 Set Default Pattern Attributes 0x04
+ // 3-4 Mask - OR of as many of the following bits as are required:
+ // 0x0800 Pattern set
+ // 0x0100 Pattern symbol
+ // 0x0080 Pattern reference point
+ // 0x0008 Pattern color
+ // 0x0004 Pattern background color
+ // 0x0002 Pattern mix
+ // 0x0001 Pattern background mix
+ // 5 Flags
+ //
+ // 0x0F Set indicated default attributes to initial values.
+ // (Data field is not present in this instance)
+ // 0x8F Set indicated default attributes to specified values.
+ // 6-n Data - data values as required, in this order if present.
+ // No space is reserved for attributes for which the corresponding Mask flag was
+ // not set.
+ //
+ // (1 byte) - Pattern set
+ // (1 byte) - Pattern symbol
+ // (2*G bytes) - Pattern reference point
+ // (4 bytes) - Pattern color
+ // (4 bytes) - Pattern background color
+ // (1 byte) - Pattern mix
+ // (1 byte) - Pattern background mix (G=2 or 4 depending on the Geometrics
+ // parameter of Set Default Parameter Format)
+ // 0 0x21 Set Current Defaults
+ // 1 Length of following data
+ // 2 Set Default Image Attributes 0x06
+ // 3-4 Mask - OR of as many of these bits as are required:
+ // 0x0008 Image color
+ // 0x0004 Image background color
+ // 0x0002 Image mix
+ // 0x0001 Image background mix
+ // 5 Flags
+ // 0x0F Set indicated default attributes to initial values. (Data field is not present in
+ // this instance)
+ // 0x8F Set indicated default attributes to specified values.
+ // 6-n Data - data values as required, in this order if present.
+ // No space is reserved for attributes for which the corresponding Mask flag was
+ // not set.
+ // (4 bytes) - Image color
+ // (4 bytes) - Image background color
+ // (1 byte) - Image mix
+ // (1 byte) - Image background mix
+ // 0 0x21 Set Current Defaults
+ // 1 Length of following data
+ // 2 Set Default Viewing Window 0x05
+ // 3-4 Mask - OR of as many of the following bits as are required:
+ // 0x8000 x left limit
+ // 0x4000 x right limit
+ // 0x2000 y bottom limit
+ // 0x1000 y top limit
+ // 5 Flags
+ // 0x0F Set indicated default attributes to initial values.
+ // (Data field is not present in this case).
+ // 0x8F Set indicated default attributes to specified values.
+ // 6-n Data - data values as required, in the following order if present.
+ // No space is reserved for attributes for which the corresponding Mask flag was
+ // not set.
+ // (2*G bytes) - x left limit
+ // (2*G bytes) - x right limit
+ // (2*G bytes) - y bottom limit
+ // (2*G bytes) - y top limit (G=2 or 4 depending on the Geometrics parameter of Set
+ // Default Parameter Format)
+ // 0 0x21 Set Current Defaults
+ // 1 Length of following data
+ // 2 Set Default Arc Parameters 0x0B
+ // 3-4 Mask - OR of as many of the following bits as are required:
+ // 0x8000 P value
+ // 0x4000 Q value
+ // 0x2000 R value
+ // 0x1000 S value
+ // 5 Flags
+ // 0x0F Set indicated default attributes to initial values.
+ // (Data field is not present in this case).
+ // 0x8F Set indicated default attributes to specified values.
+ // 6-n Data - data values as required, in the following order if present.
+ // No space is reserved for attributes for which the corresponding Mask flag was
+ // not set.
+ // (G bytes) - P value
+ // (G bytes) - Q value
+ // (G bytes) - R value
+ // (G bytes) - S value (G=2 or 4 depending on the Geometrics parameter of Set
+ // Default Parameter Format)
+ // 0 0x21 Set Current Defaults
+ // 1 Length of following data
+ // 2 Set Default Pick Identifier 0x0C
+ // 3-4 Mask - OR of as many of the following bits as are required:
+ // 0x8000 Pick identifier
+ // 5 Flags
+ // 0x0F Set indicated default attributes to initial values.
+ // (Data field is not present in this case).
+ // 0x8F Set indicated default attributes to specified values.
+ // 6-n Data - data values as required, in the following order if present.
+ // No space is reserved for attributes for which the corresponding Mask flag was
+ // not set.
+ // (4 bytes) - Pick identifier
+
+ // 0 0xE7 Set Bit-map Identifier
+ // 1 Length of following data 0x07
+ // 2-3 Usage Flags 0x8000
+ // 4-7 Bit-map handle
+ // 8 Lcid
+ if (nNumberOfBitmaps>0) {
+ *pMET << (BYTE)0xe7 << (BYTE)0x07 << (BYTE)0x80 << (BYTE)0x00;
+ WriteBigEndianLong(nActBitmapId);
+ *pMET << (BYTE)0xfe;
+ }
+
+ UpdateFieldSize();
+
+ if (pMET->GetError()) bStatus=FALSE;
+}
+
+
+void METWriter::WillWriteOrder(ULONG nNextOrderMaximumLength)
+{
+ // Die Parameter eines 'Graphics Data Fields' duerfen (laut OS2-Doku)
+ // hoechstens 32759 Bytes umfassen. Gemeint ist die Laenge des Feldes minus
+ // dem 'Structured Field Introducer' (groesse: 8). Also darf die Groesse
+ // des ganzen Fields hoechstens 8+32759=32767=0x7fff sein.
+ // Zur Sicherheit nehmen wir lieber 30000 als Grenze.
+
+ if (pMET->Tell()-nActualFieldStartPos+nNextOrderMaximumLength>30000)
+ {
+ UpdateFieldSize();
+ WriteFieldIntroducer(0,DatGrfObjMagic,0,0);
+ nNumberOfDataFields++;
+ }
+}
+
+
+
+void METWriter::METBitBlt(Point aPt, Size aSize, const Bitmap & rBitmap)
+{
+ WillWriteOrder(46);
+ *pMET << (BYTE)0xd6 << (BYTE)44 << (USHORT)0 << (USHORT) 0x00cc;
+ WriteBigEndianLong(nActBitmapId++);
+ *pMET << (BYTE)0x02 << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x00;
+ WritePoint(Point(aPt.X(),aPt.Y()+aSize.Height()));
+ WritePoint(Point(aPt.X()+aSize.Width(),aPt.Y()));
+ *pMET << (ULONG)0 << (ULONG)0
+ << (ULONG)(rBitmap.GetSizePixel().Width())
+ << (ULONG)(rBitmap.GetSizePixel().Height());
+}
+
+void METWriter::METSetAndPushLineInfo( const LineInfo& rLineInfo )
+{
+ INT32 nWidth = OutputDevice::LogicToLogic( Size( rLineInfo.GetWidth(),0 ), aPictureMapMode, aTargetMapMode ).Width();
+
+ WillWriteOrder( 8 ); // set stroke linewidth
+ *pMET << (BYTE)0x15
+ << (BYTE)6
+ << (BYTE)0 // Flags
+ << (BYTE)0
+ << nWidth;
+
+ if ( rLineInfo.GetStyle() != LINE_SOLID )
+ {
+ BYTE nStyle = 0; // LineDefault;
+
+ switch ( rLineInfo.GetStyle() )
+ {
+ case LINE_NONE :
+ nStyle = 8;
+ break;
+
+ case LINE_DASH :
+ {
+ if ( rLineInfo.GetDotCount() )
+ {
+ if ( !rLineInfo.GetDashCount() )
+ nStyle = 1; // LINE_DOT
+ else
+ nStyle = 3; // LINE_DASH_DOT
+ }
+ else
+ nStyle = 2; // LINE_DASH
+ }
+ break;
+ }
+ WillWriteOrder( 2 );
+ *pMET << (BYTE)0x18 << nStyle; // set LineType
+ }
+}
+
+void METWriter::METPopLineInfo( const LineInfo& rLineInfo )
+{
+ WillWriteOrder( 8 ); // set stroke linewidth
+ *pMET << (BYTE)0x15
+ << (BYTE)6
+ << (BYTE)0 // Flags
+ << (BYTE)0
+ << (UINT32)1;
+
+ if ( rLineInfo.GetStyle() != LINE_SOLID )
+ {
+ WillWriteOrder( 2 );
+ *pMET << (BYTE)0x18 << (BYTE)0; // set LineType
+ }
+}
+
+void METWriter::METBeginArea(BOOL bBoundaryLine)
+{
+ WillWriteOrder(2);
+ *pMET << (BYTE)0x68;
+ if (bBoundaryLine) *pMET << (BYTE)0xc0;
+ else *pMET << (BYTE)0x80;
+}
+
+
+void METWriter::METEndArea()
+{
+ WillWriteOrder(2);
+ *pMET << (BYTE)0x60 << (BYTE)0;
+}
+
+
+void METWriter::METBeginPath(ULONG nPathId)
+{
+ WillWriteOrder(8);
+ *pMET << (BYTE)0xd0 << (BYTE)6 << (USHORT) 0 << nPathId;
+}
+
+
+void METWriter::METEndPath()
+{
+ WillWriteOrder(2);
+ *pMET << (BYTE)0x7f << (BYTE)0;
+}
+
+
+void METWriter::METFillPath(ULONG nPathId)
+{
+ WillWriteOrder(8);
+ *pMET << (BYTE)0xd7 << (BYTE)6
+ << (BYTE)0x00 << (BYTE)0 << nPathId;
+}
+
+
+void METWriter::METOutlinePath(ULONG nPathId)
+{
+ WillWriteOrder(8);
+ *pMET << (BYTE)0xd4 << (BYTE)6
+ << (BYTE)0 << (BYTE)0 << nPathId;
+}
+
+
+void METWriter::METCloseFigure()
+{
+ WillWriteOrder(2);
+ *pMET << (BYTE)0x7d << (BYTE)0;
+}
+
+
+void METWriter::METMove(Point aPt)
+{
+ WillWriteOrder(10);
+ *pMET << (BYTE)0x21 << (BYTE)8;
+ WritePoint(aPt);
+}
+
+
+void METWriter::METLine(Point aPt1, Point aPt2)
+{
+ WillWriteOrder(18);
+ *pMET << (BYTE)0xc1 << (BYTE)16;
+ WritePoint(aPt1); WritePoint(aPt2);
+}
+
+
+void METWriter::METLine(const Polygon & rPolygon)
+{
+ USHORT nNumPoints,i,j,nOrderPoints;
+ BOOL bFirstOrder;
+
+ bFirstOrder=TRUE;
+ i=0; nNumPoints=rPolygon.GetSize();
+ while (i<nNumPoints) {
+ nOrderPoints=nNumPoints-i;
+ if (nOrderPoints>30) nOrderPoints=30;
+ WillWriteOrder(nOrderPoints*8+2);
+ if (bFirstOrder==TRUE) {
+ *pMET << (BYTE)0xc1; // Line at given pos
+ bFirstOrder=FALSE;
+ }
+ else {
+ *pMET << (BYTE)0x81; // Line at current pos
+ }
+ *pMET << (BYTE)(nOrderPoints*8);
+ for (j=0; j<nOrderPoints; j++) WritePoint(rPolygon.GetPoint(i++));
+ }
+}
+
+
+void METWriter::METLine(const PolyPolygon & rPolyPolygon)
+{
+ USHORT i,nCount;
+ nCount=rPolyPolygon.Count();
+ for (i=0; i<nCount; i++) {
+ METLine(rPolyPolygon.GetObject(i));
+ METCloseFigure();
+ }
+}
+
+
+void METWriter::METLineAtCurPos(Point aPt)
+{
+ WillWriteOrder(10);
+ *pMET << (BYTE)0x81 << (BYTE)8;
+ WritePoint(aPt);
+}
+
+
+void METWriter::METBox(BOOL bFill, BOOL bBoundary,
+ Rectangle aRect, ULONG nHAxis, ULONG nVAxis)
+{
+ BYTE nFlags=0;
+ if (bFill) nFlags|=0x40;
+ if (bBoundary) nFlags|=0x20;
+
+ WillWriteOrder(28);
+ *pMET << (BYTE)0xc0 << (BYTE)26 << nFlags << (BYTE)0;
+ WritePoint(aRect.BottomLeft());
+ WritePoint(aRect.TopRight());
+ *pMET << nHAxis << nVAxis;
+}
+
+
+void METWriter::METArc(Point aP0, Point aP1, Point aP2)
+{
+ WillWriteOrder(26);
+ *pMET << (BYTE)0xc6 << (BYTE)24;
+ WritePoint(aP0);
+ WritePoint(aP1);
+ WritePoint(aP2);
+}
+
+
+void METWriter::METArcAtCurPos(Point aP1, Point aP2)
+{
+ WillWriteOrder(18);
+ *pMET << (BYTE)0x86 << (BYTE)16;
+ WritePoint(aP1);
+ WritePoint(aP2);
+}
+
+
+void METWriter::METFullArc(Point aCenter, double fMultiplier)
+{
+ WillWriteOrder(14);
+ *pMET << (BYTE)0xc7 << (BYTE)12;
+ WritePoint(aCenter);
+ *pMET << (long)(fMultiplier*65536.0+0.5);
+}
+
+
+void METWriter::METPartialArcAtCurPos(Point aCenter, double fMultiplier,
+ double fStartAngle, double fSweepAngle)
+{
+ fStartAngle*=180.0/3.14159265359;
+ while (fStartAngle>360.0) fStartAngle-=360.0;
+ while (fStartAngle<0.0) fStartAngle+=360.0;
+ fSweepAngle*=180.0/3.14159265359;
+ while (fSweepAngle>360.0) fSweepAngle-=360.0;
+ while (fSweepAngle<.00) fSweepAngle+=360.0;
+ WillWriteOrder(22);
+ *pMET << (BYTE)0xa3 << (BYTE)20;
+ WritePoint(aCenter);
+ *pMET << (long)(fMultiplier*65536.0+0.5);
+ *pMET << (long)(fStartAngle*65536.0+0.5);
+ *pMET << (long)(fSweepAngle*65536.0+0.5);
+}
+
+
+void METWriter::METChrStr( Point aPt, String aUniStr )
+{
+ USHORT nLen,i;
+ ByteString aStr( aUniStr, RTL_TEXTENCODING_UTF8 );
+ nLen = aStr.Len();
+ WillWriteOrder( 11 + nLen );
+ *pMET << (BYTE)0xc3 << (BYTE)( 9 + nLen );
+ WritePoint(aPt);
+ for ( i = 0; i < nLen; i++ )
+ *pMET << aStr.GetChar( i );
+ *pMET << (BYTE)0;
+}
+
+
+void METWriter::METSetArcParams(long nP, long nQ, long nR, long nS)
+{
+ WillWriteOrder(18);
+ *pMET << (BYTE)0x22 << (BYTE)16 << nP << nQ << nR << nS;
+}
+
+
+void METWriter::METSetColor(Color aColor)
+{
+ if (aColor==aMETColor) return;
+ aMETColor=aColor;
+
+ WillWriteOrder(6);
+ *pMET << (BYTE)0xa6 << (BYTE)4 << (BYTE)0
+ << (BYTE)(aColor.GetBlue())
+ << (BYTE)(aColor.GetGreen())
+ << (BYTE)(aColor.GetRed());
+}
+
+
+void METWriter::METSetBackgroundColor(Color aColor)
+{
+ if (aColor==aMETBackgroundColor) return;
+ aMETBackgroundColor=aColor;
+
+ WillWriteOrder(6);
+ *pMET << (BYTE)0xa7 << (BYTE)4 << (BYTE)0
+ << (BYTE)(aColor.GetBlue())
+ << (BYTE)(aColor.GetGreen())
+ << (BYTE)(aColor.GetRed());
+}
+
+void METWriter::METSetMix(RasterOp eROP)
+{
+ BYTE nMix;
+
+ if (eMETMix==eROP)
+ return;
+
+ eMETMix=eROP;
+
+ switch (eROP)
+ {
+ case ROP_INVERT: nMix=0x0c; break;
+ case ROP_XOR: nMix=0x04; break;
+ default: nMix=0x02;
+ }
+
+ WillWriteOrder(2);
+ *pMET << (BYTE)0x0c << nMix;
+}
+
+
+void METWriter::METSetChrCellSize(Size aSize)
+{
+ if (aMETChrCellSize==aSize)
+ return;
+
+ aMETChrCellSize=aSize;
+ WillWriteOrder(10);
+ if (aSize.Width()==0) aSize.Width()=aSize.Height();
+ *pMET << (BYTE)0x33 << (BYTE)8 << (long)aSize.Width() << (long)aSize.Height();
+}
+
+
+void METWriter::METSetChrAngle(short nAngle)
+{
+ double fa;
+ long nax,nay;
+
+ if (nMETChrAngle==nAngle) return;
+ nMETChrAngle=nAngle;
+
+ if (nAngle==0)
+ {
+ nax=256;
+ nay=0;
+ }
+ else
+ {
+ fa=((double)nAngle)/1800.0*3.14159265359;
+ nax=(long)(256.0*cos(fa)+0.5);
+ nay=(long)(256.0*sin(fa)+0.5);
+ }
+
+ WillWriteOrder(10);
+ *pMET << (BYTE)0x34 << (BYTE)8 << nax << nay;
+}
+
+
+void METWriter::METSetChrSet(BYTE nSet)
+{
+ if (nMETChrSet==nSet)
+ return;
+
+ nMETChrSet=nSet;
+ WillWriteOrder(2);
+ *pMET << (BYTE)0x38 << nSet;
+}
+
+
+void METWriter::WriteOrders( const GDIMetaFile* pMTF )
+{
+ if(bStatus==FALSE)
+ return;
+
+ for( ULONG nA = 0, nACount = pMTF->GetActionCount(); nA < nACount; nA++ )
+ {
+ const MetaAction* pMA = pMTF->GetAction( nA );
+
+ switch (pMA->GetType())
+ {
+ case META_PIXEL_ACTION:
+ {
+ const MetaPixelAction* pA = (const MetaPixelAction*) pMA;
+ METSetMix( eGDIRasterOp );
+ METSetColor( pA->GetColor() );
+ METLine( pA->GetPoint(),pA->GetPoint() );
+ }
+ break;
+
+ case META_POINT_ACTION:
+ {
+ const MetaPointAction* pA = (const MetaPointAction*) pMA;
+
+ METSetArcParams(1,1,0,0);
+ METSetMix(eGDIRasterOp);
+ METSetColor(aGDILineColor);
+ METBeginArea(FALSE);
+ METFullArc(pA->GetPoint(),0.5);
+ METEndArea();
+ }
+ break;
+
+ case META_LINE_ACTION:
+ {
+ const MetaLineAction* pA = (const MetaLineAction*) pMA;
+
+ if( aGDILineColor != Color( COL_TRANSPARENT ) )
+ {
+ LineInfo aLineInfo( pA->GetLineInfo() );
+ if ( ! ( aLineInfo.IsDefault() ) )
+ METSetAndPushLineInfo( aLineInfo );
+
+ METSetMix( eGDIRasterOp );
+ METSetColor(aGDILineColor);
+ METBeginPath( 1 );
+ METLine( pA->GetStartPoint(), pA->GetEndPoint() );
+ METEndPath();
+ METOutlinePath( 1 );
+
+ if ( ! ( aLineInfo.IsDefault() ) )
+ METPopLineInfo( aLineInfo );
+ }
+ }
+ break;
+
+ case META_RECT_ACTION:
+ {
+ const MetaRectAction* pA = (const MetaRectAction*) pMA;
+
+ if( aGDIFillColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix( eGDIRasterOp );
+ METSetColor( aGDIFillColor );
+ METSetBackgroundColor( aGDIFillColor );
+ METBox( TRUE, FALSE, pA->GetRect(), 0, 0 );
+ }
+
+ if( aGDILineColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix( eGDIRasterOp );
+ METSetColor( aGDILineColor );
+ METBox( FALSE, TRUE, pA->GetRect(), 0, 0 );
+ }
+ }
+ break;
+
+ case META_ROUNDRECT_ACTION:
+ {
+ const MetaRoundRectAction* pA = (const MetaRoundRectAction*) pMA;
+
+ if( aGDIFillColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix( eGDIRasterOp );
+ METSetColor( aGDIFillColor );
+ METSetBackgroundColor( aGDIFillColor );
+ METBox( TRUE, FALSE, pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound() );
+ }
+
+ if( aGDILineColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix( eGDIRasterOp );
+ METSetColor( aGDILineColor );
+ METBox( FALSE, TRUE, pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound() );
+ }
+ }
+ break;
+
+ case META_ELLIPSE_ACTION:
+ {
+ const MetaEllipseAction* pA = (const MetaEllipseAction*) pMA;
+ Point aCenter;
+
+ aCenter.X()=(pA->GetRect().Left()+pA->GetRect().Right())/2;
+ aCenter.Y()=(pA->GetRect().Top()+pA->GetRect().Bottom())/2;
+
+ METSetArcParams(pA->GetRect().GetWidth(), pA->GetRect().GetHeight(),0,0);
+
+ if( aGDIFillColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix( eGDIRasterOp );
+ METSetColor( aGDIFillColor );
+ METSetBackgroundColor( aGDIFillColor );
+ METBeginArea(FALSE);
+ METFullArc(aCenter,0.5);
+ METEndArea();
+ }
+
+ if( aGDILineColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix( eGDIRasterOp );
+ METSetColor( aGDILineColor );
+ METFullArc( aCenter,0.5 );
+ }
+ }
+ break;
+
+ case META_ARC_ACTION:
+ {
+ const MetaArcAction* pA = (const MetaArcAction*) pMA;
+ Point aStartPos,aCenter;
+ double fdx,fdy,fa1,fa2;
+
+ aCenter.X()=(pA->GetRect().Left()+pA->GetRect().Right())/2;
+ aCenter.Y()=(pA->GetRect().Top()+pA->GetRect().Bottom())/2;
+ fdx=(double)(pA->GetStartPoint().X()-aCenter.X());
+ fdy=(double)(pA->GetStartPoint().Y()-aCenter.Y());
+ fdx*=(double)pA->GetRect().GetHeight();
+ fdy*=(double)pA->GetRect().GetWidth();
+ if (fdx==0.0 && fdy==0.0) fdx=1.0;
+ fa1=atan2(-fdy,fdx);
+ fdx=(double)(pA->GetEndPoint().X()-aCenter.X());
+ fdy=(double)(pA->GetEndPoint().Y()-aCenter.Y());
+ fdx*=(double)pA->GetRect().GetHeight();
+ fdy*=(double)pA->GetRect().GetWidth();
+ if (fdx==0.0 && fdy==0.0) fdx=1.0;
+ fa2=atan2(-fdy,fdx);
+ aStartPos.X()=aCenter.X()+(long)(((double)pA->GetRect().GetWidth())*cos(fa1)/2.0+0.5);
+ aStartPos.Y()=aCenter.Y()-(long)(((double)pA->GetRect().GetHeight())*sin(fa1)/2.0+0.5);
+
+ if( aGDILineColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix( eGDIRasterOp );
+ METSetColor( aGDILineColor );
+ METSetArcParams(pA->GetRect().GetWidth(), pA->GetRect().GetHeight(),0,0);
+ METBeginPath(1);
+ METMove(aStartPos);
+ METPartialArcAtCurPos(aCenter,0.5,fa1,fa2-fa1);
+ METEndPath();
+ METOutlinePath(1);
+ }
+ }
+ break;
+
+ case META_PIE_ACTION:
+ {
+ const MetaPieAction* pA = (const MetaPieAction*) pMA;
+ Point aCenter;
+ double fdx,fdy,fa1,fa2;
+
+ aCenter.X()=(pA->GetRect().Left()+pA->GetRect().Right())/2;
+ aCenter.Y()=(pA->GetRect().Top()+pA->GetRect().Bottom())/2;
+ fdx=(double)(pA->GetStartPoint().X()-aCenter.X());
+ fdy=(double)(pA->GetStartPoint().Y()-aCenter.Y());
+ fdx*=(double)pA->GetRect().GetHeight();
+ fdy*=(double)pA->GetRect().GetWidth();
+ if (fdx==0.0 && fdy==0.0) fdx=1.0;
+ fa1=atan2(-fdy,fdx);
+ fdx=(double)(pA->GetEndPoint().X()-aCenter.X());
+ fdy=(double)(pA->GetEndPoint().Y()-aCenter.Y());
+ fdx*=(double)pA->GetRect().GetHeight();
+ fdy*=(double)pA->GetRect().GetWidth();
+ if (fdx==0.0 && fdy==0.0) fdx=1.0;
+ fa2=atan2(-fdy,fdx);
+
+ METSetArcParams(pA->GetRect().GetWidth(), pA->GetRect().GetHeight(),0,0);
+
+ if( aGDIFillColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix( eGDIRasterOp );
+ METSetColor( aGDIFillColor );
+ METSetBackgroundColor( aGDIFillColor );
+ METBeginPath(1);
+ METMove(aCenter);
+ METPartialArcAtCurPos(aCenter,0.5,fa1,fa2-fa1);
+ METLineAtCurPos(aCenter);
+ METEndPath();
+ METFillPath(1);
+ }
+
+ if( aGDILineColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix( eGDIRasterOp );
+ METSetColor( aGDILineColor );
+ METBeginPath(1);
+ METMove(aCenter);
+ METPartialArcAtCurPos(aCenter,0.5,fa1,fa2-fa1);
+ METLineAtCurPos(aCenter);
+ METEndPath();
+ METOutlinePath(1);
+ }
+ }
+ break;
+
+ case META_CHORD_ACTION:
+ {
+ const MetaChordAction* pA = (const MetaChordAction*) pMA;
+ Point aStartPos,aCenter;
+ double fdx,fdy,fa1,fa2;
+
+ aCenter.X()=(pA->GetRect().Left()+pA->GetRect().Right())/2;
+ aCenter.Y()=(pA->GetRect().Top()+pA->GetRect().Bottom())/2;
+ fdx=(double)(pA->GetStartPoint().X()-aCenter.X());
+ fdy=(double)(pA->GetStartPoint().Y()-aCenter.Y());
+ fdx*=(double)pA->GetRect().GetHeight();
+ fdy*=(double)pA->GetRect().GetWidth();
+ if (fdx==0.0 && fdy==0.0) fdx=1.0;
+ fa1=atan2(-fdy,fdx);
+ fdx=(double)(pA->GetEndPoint().X()-aCenter.X());
+ fdy=(double)(pA->GetEndPoint().Y()-aCenter.Y());
+ fdx*=(double)pA->GetRect().GetHeight();
+ fdy*=(double)pA->GetRect().GetWidth();
+ if (fdx==0.0 && fdy==0.0) fdx=1.0;
+ fa2=atan2(-fdy,fdx);
+ aStartPos.X()=aCenter.X()+(long)(((double)pA->GetRect().GetWidth())*cos(fa1)/2.0+0.5);
+ aStartPos.Y()=aCenter.Y()-(long)(((double)pA->GetRect().GetHeight())*sin(fa1)/2.0+0.5);
+
+ if( aGDIFillColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix( eGDIRasterOp );
+ METSetColor( aGDIFillColor );
+ METSetBackgroundColor( aGDIFillColor );
+ METBeginPath(1);
+ METMove(aStartPos);
+ METPartialArcAtCurPos(aCenter,0.5,fa1,fa2-fa1);
+ METLineAtCurPos(aStartPos);
+ METEndPath();
+ METFillPath(1);
+ }
+
+ if( aGDILineColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix( eGDIRasterOp );
+ METSetColor( aGDILineColor );
+ METBeginPath(1);
+ METMove(aStartPos);
+ METPartialArcAtCurPos(aCenter,0.5,fa1,fa2-fa1);
+ METLineAtCurPos(aStartPos);
+ METEndPath();
+ METOutlinePath(1);
+ }
+ }
+ break;
+
+ case META_POLYLINE_ACTION:
+ {
+ const MetaPolyLineAction* pA = (const MetaPolyLineAction*) pMA;
+
+ if( aGDILineColor != Color( COL_TRANSPARENT ) )
+ {
+ LineInfo aLineInfo( pA->GetLineInfo() );
+ if ( ! ( aLineInfo.IsDefault() ) )
+ METSetAndPushLineInfo( aLineInfo );
+
+ METSetMix(eGDIRasterOp);
+ METSetColor(aGDILineColor);
+ METBeginPath(1);
+ METLine(pA->GetPolygon());
+ METEndPath();
+ METOutlinePath(1);
+
+ if ( ! ( aLineInfo.IsDefault() ) )
+ METPopLineInfo( aLineInfo );
+ }
+ }
+ break;
+
+ case META_POLYGON_ACTION:
+ {
+ const MetaPolygonAction* pA = (const MetaPolygonAction*) pMA;
+
+ if( aGDIFillColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix(eGDIRasterOp);
+ METSetColor(aGDIFillColor );
+ METSetBackgroundColor(aGDIFillColor );
+ METBeginPath(1);
+ METLine(pA->GetPolygon());
+ METEndPath();
+ METFillPath(1);
+ }
+
+ if( aGDILineColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix(eGDIRasterOp);
+ METSetColor(aGDILineColor );
+ METBeginPath(1);
+ METLine(pA->GetPolygon());
+ METEndPath();
+ METOutlinePath(1);
+ }
+ }
+ break;
+
+ case META_POLYPOLYGON_ACTION:
+ {
+ const MetaPolyPolygonAction* pA = (const MetaPolyPolygonAction*) pMA;
+
+ if( aGDIFillColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix(eGDIRasterOp);
+ METSetColor(aGDIFillColor);
+ METSetBackgroundColor(aGDIFillColor);
+ METBeginPath(1);
+ METLine(pA->GetPolyPolygon());
+ METEndPath();
+ METFillPath(1);
+ }
+
+ if( aGDILineColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix(eGDIRasterOp);
+ METSetColor(aGDILineColor);
+ METBeginPath(1);
+ METLine(pA->GetPolyPolygon());
+ METEndPath();
+ METOutlinePath(1);
+ }
+ }
+ break;
+
+ case META_TEXT_ACTION:
+ {
+ const MetaTextAction* pA = (const MetaTextAction*) pMA;
+ Point aPt( pA->GetPoint() );
+
+ if( aGDIFont.GetAlign() != ALIGN_BASELINE)
+ {
+ VirtualDevice aVDev;
+
+ if( aGDIFont.GetAlign()==ALIGN_TOP )
+ aPt.Y()+=(long)aVDev.GetFontMetric( aGDIFont ).GetAscent();
+ else
+ aPt.Y()-=(long)aVDev.GetFontMetric( aGDIFont ).GetDescent();
+ }
+
+ METSetMix(eGDIRasterOp);
+ METSetColor(aGDIFont.GetColor());
+ METSetBackgroundColor(aGDIFont.GetFillColor());
+ METSetChrCellSize(aGDIFont.GetSize());
+ METSetChrAngle(aGDIFont.GetOrientation());
+ METSetChrSet(FindChrSet(aGDIFont));
+ METChrStr(aPt, String(pA->GetText(),pA->GetIndex(),pA->GetLen()));
+ }
+ break;
+
+ case META_TEXTARRAY_ACTION:
+ {
+ const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pMA;
+ USHORT i;
+ String aStr;
+ Polygon aPolyDummy(1);
+ short nOrientation;
+ Point aPt( pA->GetPoint() );
+
+ if( aGDIFont.GetAlign() != ALIGN_BASELINE )
+ {
+ VirtualDevice aVDev;
+ if( aGDIFont.GetAlign() == ALIGN_TOP )
+ aPt.Y()+=(long)aVDev.GetFontMetric(aGDIFont).GetAscent();
+ else
+ aPt.Y()-=(long)aVDev.GetFontMetric(aGDIFont).GetDescent();
+ }
+
+ METSetMix(eGDIRasterOp);
+ METSetColor(aGDIFont.GetColor());
+ METSetBackgroundColor(aGDIFont.GetFillColor());
+ METSetChrCellSize(aGDIFont.GetSize());
+ METSetChrAngle( nOrientation = aGDIFont.GetOrientation() );
+ METSetChrSet(FindChrSet(aGDIFont));
+ aStr=String(pA->GetText(),pA->GetIndex(),pA->GetLen());
+
+ if( pA->GetDXArray()!=NULL )
+ {
+ Point aPt2;
+
+ for( i=0; i < aStr.Len(); i++ )
+ {
+ aPt2 = aPt;
+ if ( i > 0 )
+ {
+ aPt2.X() += pA->GetDXArray()[i-1];
+ if ( nOrientation )
+ {
+ aPolyDummy.SetPoint( aPt2, 0 );
+ aPolyDummy.Rotate( aPt, nOrientation );
+ aPt2 = aPolyDummy.GetPoint( 0 );
+ }
+ }
+ METChrStr( aPt2, String( aStr.GetChar( i ) ) );
+ }
+ }
+ else
+ METChrStr( aPt, aStr );
+ }
+ break;
+
+ case META_STRETCHTEXT_ACTION:
+ {
+ const MetaStretchTextAction* pA = (const MetaStretchTextAction*) pMA;
+ VirtualDevice aVDev;
+ USHORT i;
+ long* pDXAry;
+ sal_Int32 nNormSize;
+ String aStr;
+ Polygon aPolyDummy(1);
+ short nOrientation;
+ Point aPt( pA->GetPoint() );
+ Point aPt2;
+
+ aVDev.SetFont( aGDIFont );
+
+ if( aGDIFont.GetAlign() != ALIGN_BASELINE)
+ {
+ if( aGDIFont.GetAlign() == ALIGN_TOP )
+ aPt.Y()+=(long)aVDev.GetFontMetric().GetAscent();
+ else
+ aPt.Y()-=(long)aVDev.GetFontMetric().GetDescent();
+ }
+
+ METSetMix(eGDIRasterOp);
+ METSetColor(aGDIFont.GetColor());
+ METSetBackgroundColor(aGDIFont.GetFillColor());
+ METSetChrCellSize(aGDIFont.GetSize());
+ METSetChrAngle( nOrientation = aGDIFont.GetOrientation() );
+ METSetChrSet(FindChrSet(aGDIFont));
+ aStr=String(pA->GetText(),pA->GetIndex(),pA->GetLen());
+ pDXAry=new long[aStr.Len()];
+ nNormSize = aVDev.GetTextArray( aStr, pDXAry );
+
+ for ( i = 0; i < aStr.Len(); i++ )
+ {
+ aPt2 = aPt;
+ if ( i > 0 )
+ {
+ aPt2.X() += pDXAry[i-1]*((long)pA->GetWidth())/ nNormSize;
+ if ( nOrientation )
+ {
+ aPolyDummy.SetPoint( aPt2, 0 );
+ aPolyDummy.Rotate( aPt, nOrientation );
+ aPt2 = aPolyDummy.GetPoint( 0 );
+ }
+ }
+ METChrStr( aPt2, String( aStr.GetChar( i ) ) );
+ }
+
+ delete[] pDXAry;
+ }
+ break;
+
+ case META_TEXTRECT_ACTION:
+ {
+// DBG_ERROR( "Unsupported MET-Action: META_TEXTRECT_ACTION!" );
+ }
+ break;
+
+ case META_BMP_ACTION:
+ {
+ const MetaBmpAction* pA = (const MetaBmpAction*) pMA;
+
+ METSetMix(eGDIRasterOp);
+ METBitBlt( pA->GetPoint(), pA->GetBitmap().GetSizePixel(), pA->GetBitmap() );
+ }
+ break;
+
+ case META_BMPSCALE_ACTION:
+ {
+ const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pMA;
+
+ METSetMix(eGDIRasterOp);
+ METBitBlt( pA->GetPoint(), pA->GetSize(), pA->GetBitmap() );
+ }
+ break;
+
+ case META_BMPSCALEPART_ACTION:
+ {
+ const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*) pMA;
+ Bitmap aTmp( pA->GetBitmap() );
+
+ aTmp.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
+ METSetMix( eGDIRasterOp );
+ METBitBlt( pA->GetDestPoint(), pA->GetDestSize(), aTmp );
+ }
+ break;
+
+ case META_BMPEX_ACTION:
+ {
+ const MetaBmpExAction* pA = (const MetaBmpExAction*) pMA;
+ Bitmap aTmp( Graphic( pA->GetBitmapEx() ).GetBitmap() );
+
+ METSetMix(eGDIRasterOp);
+ METBitBlt( pA->GetPoint(), aTmp.GetSizePixel(), aTmp );
+ }
+ break;
+
+ case META_BMPEXSCALE_ACTION:
+ {
+ const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pMA;
+ Bitmap aTmp( Graphic( pA->GetBitmapEx() ).GetBitmap() );
+
+ METSetMix(eGDIRasterOp);
+ METBitBlt( pA->GetPoint(), pA->GetSize(), aTmp );
+ }
+ break;
+
+ case META_BMPEXSCALEPART_ACTION:
+ {
+ const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*) pMA;
+ Bitmap aTmp( Graphic( pA->GetBitmapEx() ).GetBitmap() );
+
+ aTmp.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
+ METSetMix(eGDIRasterOp);
+ METBitBlt( pA->GetDestPoint(), pA->GetDestSize(), aTmp );
+ }
+ break;
+
+ case META_EPS_ACTION :
+ {
+ const MetaEPSAction* pA = (const MetaEPSAction*)pMA;
+ const GDIMetaFile aGDIMetaFile( pA->GetSubstitute() );
+
+ INT32 nCount = aGDIMetaFile.GetActionCount();
+ for ( INT32 i = 0; i < nCount; i++ )
+ {
+ const MetaAction* pMetaAct = aGDIMetaFile.GetAction( i );
+ if ( pMetaAct->GetType() == META_BMPSCALE_ACTION )
+ {
+ const MetaBmpScaleAction* pBmpScaleAction = (const MetaBmpScaleAction*)pMetaAct;
+ METSetMix(eGDIRasterOp);
+ METBitBlt( pA->GetPoint(), pA->GetSize(), pBmpScaleAction->GetBitmap() );
+ break;
+ }
+ }
+ }
+ break;
+
+ case META_MASK_ACTION:
+ {
+// DBG_ERROR( "Unsupported MET-Action: META_MASK_ACTION!" );
+ }
+ break;
+
+ case META_MASKSCALE_ACTION:
+ {
+// DBG_ERROR( "Unsupported MET-Action: META_MASKSCALE_ACTION!" );
+ }
+ break;
+
+ case META_MASKSCALEPART_ACTION:
+ {
+// DBG_ERROR( "Unsupported MET-Action: META_MASKSCALEPART_ACTION!" );
+ }
+ break;
+
+ case META_GRADIENT_ACTION:
+ {
+ VirtualDevice aVDev;
+ GDIMetaFile aTmpMtf;
+ const MetaGradientAction* pA = (const MetaGradientAction*) pMA;
+
+ aVDev.SetMapMode( aTargetMapMode );
+ aVDev.AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf );
+ WriteOrders( &aTmpMtf );
+ }
+ break;
+
+ case META_HATCH_ACTION:
+ {
+ VirtualDevice aVDev;
+ GDIMetaFile aTmpMtf;
+ const MetaHatchAction* pA = (const MetaHatchAction*) pMA;
+
+ aVDev.SetMapMode( aTargetMapMode );
+ aVDev.AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf );
+ WriteOrders( &aTmpMtf );
+ }
+ break;
+
+ case META_WALLPAPER_ACTION:
+ {
+// DBG_ERROR( "Unsupported MET-Action: META_WALLPAPER_ACTION!" );
+ }
+ break;
+
+ case META_CLIPREGION_ACTION:
+ {
+// DBG_ERROR( "Unsupported MET-Action: META_CLIPREGION_ACTION!" );
+ }
+ break;
+
+ case META_ISECTRECTCLIPREGION_ACTION:
+ {
+// DBG_ERROR( "Unsupported MET-Action: META_ISECTRECTCLIPREGION_ACTION!" );
+ }
+ break;
+
+ case META_ISECTREGIONCLIPREGION_ACTION:
+ {
+// DBG_ERROR( "Unsupported MET-Action: META_ISECTREGIONCLIPREGION_ACTION!" );
+ }
+ break;
+
+ case META_MOVECLIPREGION_ACTION:
+ {
+// DBG_ERROR( "Unsupported MET-Action: META_MOVECLIPREGION_ACTION!" );
+ }
+ break;
+
+ case META_LINECOLOR_ACTION:
+ {
+ const MetaLineColorAction* pA = (const MetaLineColorAction*) pMA;
+
+ if( pA->IsSetting() )
+ aGDILineColor = pA->GetColor();
+ else
+ aGDILineColor = Color( COL_TRANSPARENT );
+ }
+ break;
+
+ case META_FILLCOLOR_ACTION:
+ {
+ const MetaFillColorAction* pA = (const MetaFillColorAction*) pMA;
+
+ if( pA->IsSetting() )
+ aGDIFillColor = pA->GetColor();
+ else
+ aGDIFillColor = Color( COL_TRANSPARENT );
+ }
+ break;
+
+ case META_TEXTCOLOR_ACTION:
+ {
+ const MetaTextColorAction* pA = (const MetaTextColorAction*) pMA;
+ aGDIFont.SetColor( pA->GetColor() );
+ }
+ break;
+
+ case META_TEXTFILLCOLOR_ACTION:
+ {
+ const MetaTextFillColorAction* pA = (const MetaTextFillColorAction*) pMA;
+
+ if( pA->IsSetting() )
+ aGDIFont.SetFillColor( pA->GetColor() );
+ else
+ aGDIFont.SetFillColor( Color( COL_TRANSPARENT ) );
+ }
+ break;
+
+ case META_TEXTALIGN_ACTION:
+ {
+// DBG_ERROR( "Unsupported MET-Action: META_TEXTALIGN_ACTION!" );
+ }
+ break;
+
+ case META_MAPMODE_ACTION:
+ {
+ const MetaMapModeAction* pA = (const MetaMapModeAction*) pMA;
+
+ if( aPictureMapMode != pA->GetMapMode() )
+ {
+ if ( pA->GetMapMode().GetMapUnit() == MAP_RELATIVE )
+ {
+ MapMode aMM = pA->GetMapMode();
+ Fraction aScaleX = aMM.GetScaleX();
+ Fraction aScaleY = aMM.GetScaleY();
+
+ Point aOrigin = aPictureMapMode.GetOrigin();
+ BigInt aX( aOrigin.X() );
+ aX *= BigInt( aScaleX.GetDenominator() );
+
+ if( aOrigin.X() >= 0 )
+ {
+ if( aScaleX.GetNumerator() >= 0 )
+ aX += BigInt( aScaleX.GetNumerator()/2 );
+ else
+ aX -= BigInt( (aScaleX.GetNumerator()+1)/2 );
+ }
+ else
+ {
+ if( aScaleX.GetNumerator() >= 0 )
+ aX -= BigInt( (aScaleX.GetNumerator()-1)/2 );
+ else
+ aX += BigInt( aScaleX.GetNumerator()/2 );
+ }
+
+ aX /= BigInt( aScaleX.GetNumerator() );
+ aOrigin.X() = (long) aX + aMM.GetOrigin().X();
+
+ BigInt aY( aOrigin.Y() );
+ aY *= BigInt( aScaleY.GetDenominator() );
+
+ if( aOrigin.Y() >= 0 )
+ {
+ if( aScaleY.GetNumerator() >= 0 )
+ aY += BigInt( aScaleY.GetNumerator()/2 );
+ else
+ aY -= BigInt( (aScaleY.GetNumerator()+1)/2 );
+ }
+ else
+ {
+ if( aScaleY.GetNumerator() >= 0 )
+ aY -= BigInt( (aScaleY.GetNumerator()-1)/2 );
+ else
+ aY += BigInt( aScaleY.GetNumerator()/2 );
+ }
+
+ aY /= BigInt( aScaleY.GetNumerator() );
+ aOrigin.Y() = (long)aY + aMM.GetOrigin().Y();
+ aPictureMapMode.SetOrigin( aOrigin );
+
+ aScaleX *= aPictureMapMode.GetScaleX();
+ aScaleY *= aPictureMapMode.GetScaleY();
+ aPictureMapMode.SetScaleX( aScaleX );
+ aPictureMapMode.SetScaleY( aScaleY );
+ }
+ else
+ aPictureMapMode=pA->GetMapMode();
+ }
+ }
+ break;
+
+ case META_FONT_ACTION:
+ {
+ aGDIFont = ( (const MetaFontAction*) pMA )->GetFont();
+ }
+ break;
+
+ case META_PUSH_ACTION:
+ {
+ METGDIStackMember* pGS = new METGDIStackMember;
+
+ pGS->pSucc=pGDIStack; pGDIStack=pGS;
+ pGS->aLineColor=aGDILineColor;
+ pGS->aFillColor=aGDIFillColor;
+ pGS->eRasterOp=eGDIRasterOp;
+ pGS->aFont=aGDIFont;
+ pGS->aMapMode=aPictureMapMode;
+ pGS->aClipRegion=aGDIClipRegion;
+ }
+ break;
+
+ case META_POP_ACTION:
+ {
+ METGDIStackMember* pGS;
+
+ if( pGDIStack )
+ {
+ pGS=pGDIStack; pGDIStack=pGS->pSucc;
+ aGDILineColor=pGS->aLineColor;
+ aGDIFillColor=pGS->aFillColor;
+ eGDIRasterOp=pGS->eRasterOp;
+ aGDIFont=pGS->aFont;
+ aGDIClipRegion=pGS->aClipRegion;
+ aPictureMapMode=pGS->aMapMode;
+ delete pGS;
+ }
+ }
+ break;
+
+ case META_RASTEROP_ACTION:
+ {
+ eGDIRasterOp = ( (const MetaRasterOpAction*) pMA )->GetRasterOp();
+ }
+ break;
+
+ case META_TRANSPARENT_ACTION:
+ {
+ if( aGDIFillColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix(eGDIRasterOp);
+ METSetColor(aGDIFillColor);
+ METSetBackgroundColor(aGDIFillColor);
+ METBeginPath(1);
+ METLine(( (const MetaTransparentAction*) pMA )->GetPolyPolygon());
+ METEndPath();
+ METFillPath(1);
+ }
+
+ if( aGDILineColor != Color( COL_TRANSPARENT ) )
+ {
+ METSetMix(eGDIRasterOp);
+ METSetColor(aGDILineColor);
+ METBeginPath(1);
+ METLine(( (const MetaTransparentAction*) pMA )->GetPolyPolygon());
+ METEndPath();
+ METOutlinePath(1);
+ }
+ }
+ break;
+
+ case META_FLOATTRANSPARENT_ACTION:
+ {
+ const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pMA;
+
+ GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() );
+ Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() );
+ const Size aSrcSize( aTmpMtf.GetPrefSize() );
+ const Point aDestPt( pA->GetPoint() );
+ const Size aDestSize( pA->GetSize() );
+ const double fScaleX = aSrcSize.Width() ? (double) aDestSize.Width() / aSrcSize.Width() : 1.0;
+ const double fScaleY = aSrcSize.Height() ? (double) aDestSize.Height() / aSrcSize.Height() : 1.0;
+ long nMoveX, nMoveY;
+
+ if( fScaleX != 1.0 || fScaleY != 1.0 )
+ {
+ aTmpMtf.Scale( fScaleX, fScaleY );
+ aSrcPt.X() = FRound( aSrcPt.X() * fScaleX ), aSrcPt.Y() = FRound( aSrcPt.Y() * fScaleY );
+ }
+
+ nMoveX = aDestPt.X() - aSrcPt.X(), nMoveY = aDestPt.Y() - aSrcPt.Y();
+
+ if( nMoveX || nMoveY )
+ aTmpMtf.Move( nMoveX, nMoveY );
+
+ WriteOrders( &aTmpMtf );
+ }
+ break;
+ }
+
+ nWrittenActions++;
+ MayCallback();
+
+ if( pMET->GetError() )
+ bStatus=FALSE;
+
+ if( bStatus == FALSE )
+ break;
+ }
+}
+
+void METWriter::WriteObjectEnvironmentGroup(const GDIMetaFile * pMTF)
+{
+ ULONG i, nId;
+
+ //--- Das Feld 'Begin Object Environment Group':
+ WriteFieldIntroducer(16,BegObjEnvMagic,0,0);
+ WriteFieldId(7);
+
+ //--- Das Feld 'Map Color Attribute Table':
+ WriteFieldIntroducer(22,MapColAtrMagic,0,0);
+ WriteBigEndianShort(0x000e);
+ *pMET << (BYTE)0x0c << (BYTE)0x02 << (BYTE)0x84 << (BYTE)0x00;
+ WriteFieldId(4);
+
+ //--- Das erste Feld 'Map Coded Font':
+ WriteFieldIntroducer(32,MapCodFntMagic,0,0);
+ WriteBigEndianShort(0x0018);
+ *pMET << (BYTE)0x0c << (BYTE)0x02 << (BYTE)0x84 << (BYTE)0x00;
+ *pMET << (BYTE)0xff << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x00;
+ *pMET << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x00 << (BYTE)0x00;
+ *pMET << (BYTE)0x04 << (BYTE)0x24 << (BYTE)0x05 << (BYTE)0x00;
+ *pMET << (BYTE)0x06 << (BYTE)0x20;
+ *pMET << (BYTE)0x03 << (BYTE)0x97 << (BYTE)0x01 << (BYTE)0xb5;
+
+ //--- Die weiteren Felder 'Map Coded Font':
+ CreateChrSets(pMTF);
+ WriteChrSets();
+
+ //--- Die Felder 'Map Data Resource':
+ nId=nActBitmapId;
+ for (i=0; i<nNumberOfBitmaps; i++)
+ {
+ WriteFieldIntroducer(29,MapDatResMagic,0,0);
+ WriteBigEndianShort(0x0015);
+ *pMET << (BYTE)0x0c << (BYTE)0x02 << (BYTE)0x84 << (BYTE)0x00;
+ WriteFieldId(nId);
+ *pMET << (BYTE)0x07 << (BYTE)0x22 << (BYTE)0x10;
+ *pMET << (ULONG)nId;
+ nId++;
+ }
+
+ //--- Das Feld 'End Object Environment Group':
+ WriteFieldIntroducer(16,EndObjEnvMagic,0,0);
+ WriteFieldId(7);
+}
+
+
+void METWriter::WriteGraphicsObject(const GDIMetaFile * pMTF)
+{
+ ULONG nSegmentSize,nPos,nDataFieldsStartPos;
+
+ if( bStatus==FALSE )
+ return;
+
+ //--- Das Feld 'Begin Graphics Object':
+ WriteFieldIntroducer(16,BegGrfObjMagic,0,0);
+ WriteFieldId(7);
+
+ // Map Color Attribute Table, Fonts und anderes:
+ WriteObjectEnvironmentGroup(pMTF);
+
+ //--- Das Feld 'Graphics Data Descriptor':
+ WriteDataDescriptor(pMTF);
+
+ // Zaehler fuer Data Fields initialisieren:
+ nNumberOfDataFields=0;
+
+ // Und Position des ersten Data Fields merken:
+ nDataFieldsStartPos=pMET->Tell();
+
+ //--- Anfang des ersten Feldes 'Graphics Data'
+ WriteFieldIntroducer(0,DatGrfObjMagic,0,0);
+ nNumberOfDataFields++;
+
+ // Nun schreiben wir zunaechst den Kopf des Segments:
+ *pMET << (BYTE)0x70 << (BYTE)0x0e << (ULONG)0;
+ *pMET << (BYTE)0x70 << (BYTE)0x10; // Flags
+ *pMET << (USHORT)0; // Lo-Wort der Laenge der Segementdaten (Big Endian)
+ *pMET << (ULONG)0; // Reserved
+ *pMET << (USHORT)0; // Hi-Wort der Laenge der Segementdaten (Big Endian) (Ohh Ohh OS2)
+ // Anmerkung: die richtige Daten-Laenge schreiben wir weiter unten nochmal
+
+ // Jetzt werden alle Orders rausgeschrieben:
+ // (wobei die Sache ggf. in mehrere 'Graphics Data Fields' aufgeteilt
+ // wird, per Methode WillWriteOrder(..))
+ WriteOrders(pMTF);
+
+ //--- Das letzte Feld 'Graphic Data' beenden:
+ UpdateFieldSize();
+
+ //--- Und schliesslich die Segmentgroesse richtigstellen:
+ nPos=pMET->Tell();
+ nSegmentSize=nPos-nDataFieldsStartPos;
+ nSegmentSize-=nNumberOfDataFields*8; // Structured Field Introducers zaehlen nicht mit
+ pMET->Seek(nDataFieldsStartPos+16); // Zum Lo-Wort der Segmentgroesse seeken
+ WriteBigEndianShort((USHORT)(nSegmentSize&0x0000ffff)); // Und schreiben
+ pMET->Seek(nDataFieldsStartPos+22); // Zum Hi-Wort der Segmentgroesse seeken
+ WriteBigEndianShort((USHORT)(nSegmentSize>>16)); // Und schreiben
+ pMET->Seek(nPos); // Zurueck zur Tagesordnung
+
+ //--- Das Feld 'End Graphic Objects':
+ WriteFieldIntroducer(16,EndGrfObjMagic,0,0);
+ WriteFieldId(7);
+
+ if( pMET->GetError() )
+ bStatus=FALSE;
+}
+
+
+void METWriter::WriteResourceGroup(const GDIMetaFile * pMTF)
+{
+ if( bStatus==FALSE )
+ return;
+
+ //--- Das Feld 'Begin Resource Group':
+ WriteFieldIntroducer(16,BegResGrpMagic,0,0);
+ WriteFieldId(2);
+
+ //--- Der Inhalt:
+ WriteColorAttributeTable();
+ nActBitmapId=0x77777700;
+ WriteImageObjects(pMTF);
+ nActBitmapId=0x77777700;
+ WriteGraphicsObject(pMTF);
+
+ //--- Das Feld 'End Resource Group':
+ WriteFieldIntroducer(16,EndResGrpMagic,0,0);
+ WriteFieldId(2);
+
+ if( pMET->GetError() )
+ bStatus=FALSE;
+}
+
+
+void METWriter::WriteDocument(const GDIMetaFile * pMTF)
+{
+ if( bStatus==FALSE )
+ return;
+
+ //--- Das Feld 'Begin Document':
+ WriteFieldIntroducer(0,BegDocumnMagic,0,0);
+ WriteFieldId(1);
+ *pMET << (BYTE)0x00 << (BYTE)0x00;
+ *pMET << (BYTE)0x05 << (BYTE)0x18 << (BYTE)0x03 << (BYTE)0x0c << (BYTE)0x00;
+ *pMET << (BYTE)0x06 << (BYTE)0x01 << (BYTE)0x03 << (BYTE)0xd4 << (BYTE)0x03 << (BYTE)0x52;
+ *pMET << (BYTE)0x03 << (BYTE)0x65 << (BYTE)0x00;
+ UpdateFieldSize();
+
+ //--- Der Inhalt:
+ WriteResourceGroup(pMTF);
+
+ //--- Das Feld 'End Document':
+ WriteFieldIntroducer(16,EndDocumnMagic,0,0);
+ WriteFieldId(1);
+
+ if( pMET->GetError() )
+ bStatus=FALSE;
+}
+
+
+BOOL METWriter::WriteMET( const GDIMetaFile& rMTF, SvStream& rTargetStream,
+ PFilterCallback pcallback, void* pcallerdata )
+{
+ METChrSet* pCS;
+ METGDIStackMember* pGS;
+
+ bStatus=TRUE;
+
+ pCallback=pcallback;
+ pCallerData=pcallerdata;
+ nLastPercent=0;
+
+ pMET=&rTargetStream;
+ pMET->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
+
+ aPictureRect = Rectangle( Point(), rMTF.GetPrefSize() );
+ aTargetMapMode = aPictureMapMode = rMTF.GetPrefMapMode();
+
+ aGDILineColor=Color( COL_BLACK );
+ aGDIFillColor=Color( COL_WHITE );
+ eGDIRasterOp=ROP_OVERPAINT;
+ aGDIFont=Font();
+ aGDIMapMode=MapMode();
+ aGDIClipRegion=Region();
+ pGDIStack=NULL;
+ aMETColor=Color(COL_BLACK);
+ aMETBackgroundColor=Color(COL_WHITE);
+ eMETMix=ROP_OVERPAINT;
+ nMETStrokeLineWidth=1;
+ aMETChrCellSize=Size(0,0);
+ nMETChrAngle=0;
+ nMETChrSet=0x00;
+ pChrSetList=NULL;
+ nNextChrSetId=1;
+ nNumberOfActions=0;
+ nNumberOfBitmaps=0;
+ nWrittenActions=0;
+ nWrittenBitmaps=0;
+ nActBitmapPercent=0;
+
+ CountActionsAndBitmaps(&rMTF);
+
+ WriteDocument(&rMTF);
+
+ while( pChrSetList )
+ {
+ pCS=pChrSetList;
+ pChrSetList=pCS->pSucc;
+ delete pCS;
+ }
+
+ while( pGDIStack )
+ {
+ pGS=pGDIStack;
+ pGDIStack=pGS->pSucc;
+ delete pGS;
+ }
+
+ return bStatus;
+}
+
+//================== GraphicExport - die exportierte Funktion ================
+
+#ifdef WNT
+extern "C" BOOL _cdecl GraphicExport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#else
+extern "C" BOOL GraphicExport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#endif
+{
+ METWriter aMETWriter;
+
+ if (rGraphic.GetType()==GRAPHIC_GDIMETAFILE) {
+ return aMETWriter.WriteMET(rGraphic.GetGDIMetaFile(),rStream,pCallback,pCallerData);
+ }
+ else {
+ Bitmap aBmp=rGraphic.GetBitmap();
+ GDIMetaFile aMTF;
+ VirtualDevice aVirDev;
+
+ aMTF.Record(&aVirDev);
+ aVirDev.DrawBitmap(Point(),aBmp);
+ aMTF.Stop();
+ aMTF.SetPrefSize(aBmp.GetSizePixel());
+ return aMETWriter.WriteMET(aMTF,rStream,pCallback,pCallerData);
+ }
+}
+
+//================== GraphicDialog - die exportierte Funktion ================
+
+extern "C" BOOL SAL_CALL DoExportDialog( FltCallDialogParameter& rPara )
+{
+ BOOL bRet = FALSE;
+
+ if ( rPara.pWindow && rPara.pCfg )
+ {
+ ByteString aResMgrName( "eme" );
+ ResMgr* pResMgr;
+
+ aResMgrName.Append( ByteString::CreateFromInt32( SOLARUPD ) );
+ pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetAppInternational().GetLanguage() );
+
+ if( pResMgr )
+ {
+ rPara.pResMgr = pResMgr;
+ bRet = ( DlgExportEMET( rPara ).Execute() == RET_OK );
+ delete pResMgr;
+ }
+ else
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+//================== ein bischen Muell fuer Windows ==========================
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
diff --git a/goodies/source/filter.vcl/eos2met/eos2mstr.src b/goodies/source/filter.vcl/eos2met/eos2mstr.src
new file mode 100644
index 000000000000..004c94690514
--- /dev/null
+++ b/goodies/source/filter.vcl/eos2met/eos2mstr.src
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * $RCSfile: eos2mstr.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "strings.hrc"
+
+String KEY_MODE
+{
+ Text = "MET-EXPORT-MODE";
+};
+
+String KEY_SIZEX
+{
+ Text = "MET-EXPORT-SIZEX";
+};
+
+String KEY_SIZEY
+{
+ Text = "MET-EXPORT-SIZEY";
+};
diff --git a/goodies/source/filter.vcl/eos2met/makefile.mk b/goodies/source/filter.vcl/eos2met/makefile.mk
new file mode 100644
index 000000000000..b4255701e68f
--- /dev/null
+++ b/goodies/source/filter.vcl/eos2met/makefile.mk
@@ -0,0 +1,180 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=eos2met
+TARGET2=eme
+DEPTARGET=veos2met
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SRCFILES= dlgeos2.src \
+ eos2mstr.src
+
+SLOFILES = $(SLO)$/eos2met.obj \
+ $(SLO)$/dlgeos2.obj
+
+# ==========================================================================
+
+RESLIB1NAME=$(TARGET2)
+RESLIB1SRSFILES=\
+ $(SRS)$/$(TARGET).srs
+
+SHL1TARGET= eme$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= eos2met
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(SVTOOLLIB) $(CPPULIB)
+
+SHL1DEPN= $(LB)$/eos2met.lib
+SHL1LIBS= $(SLB)$/eos2met.lib # $(LB)$/rtftoken.lib
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/eos2met.obj
+.ENDIF
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicExport >>$@
+ @echo DoExportDialog >>$@
+.ELSE
+ @echo _GraphicExport >>$@
+ @echo _DoExportDialog >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET) >>$@
+ @echo GraphicExport_ >>temp.def
+ @echo DoExportDialog_ >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicExport >>$@
+ @echo DoExportDialog >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/eos2met/strings.hrc b/goodies/source/filter.vcl/eos2met/strings.hrc
new file mode 100644
index 000000000000..831e6b7e7ca6
--- /dev/null
+++ b/goodies/source/filter.vcl/eos2met/strings.hrc
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * $RCSfile: strings.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#define KEY_MODE 260
+#define KEY_SIZEX 264
+#define KEY_SIZEY 266
+
diff --git a/goodies/source/filter.vcl/epbm/dlgepbm.cxx b/goodies/source/filter.vcl/epbm/dlgepbm.cxx
new file mode 100644
index 000000000000..438f657ebde6
--- /dev/null
+++ b/goodies/source/filter.vcl/epbm/dlgepbm.cxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgepbm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma hdrstop
+#include <tools/ref.hxx>
+#include <vcl/config.hxx>
+#include <vcl/msgbox.hxx>
+#include "dlgepbm.hxx"
+#include "dlgepbm.hrc"
+#include "strings.hrc"
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+
+DlgExportEPBM::DlgExportEPBM( FltCallDialogParameter& rPara ) :
+ ModalDialog ( rPara.pWindow, ResId( DLG_EXPORT_EPBM, rPara.pResMgr ) ),
+ aGrpFormat ( this, ResId( GRP_FORMAT ) ),
+ aRBRaw ( this, ResId( RB_RAW ) ),
+ aRBASCII ( this, ResId( RB_ASCII ) ),
+ aBtnOK ( this, ResId( BTN_OK ) ),
+ aBtnCancel ( this, ResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ResId( BTN_HELP ) ),
+ pConfig ( rPara.pCfg ),
+ pMgr ( rPara.pResMgr )
+{
+ FreeResource();
+
+ // Config-Parameter lesen
+
+ String aFormatStr( ResId( KEY_FORMAT, pMgr ) );
+ sal_Int32 nFormat = pConfig->ReadKey( ByteString( aFormatStr, RTL_TEXTENCODING_UTF8 ) ).ToInt32();
+
+ BOOL bCheck = FALSE;
+ if ( !nFormat )
+ bCheck ^= TRUE;
+
+ aRBRaw.Check( bCheck );
+ bCheck ^= TRUE;
+ aRBASCII.Check( bCheck );
+
+ aBtnOK.SetClickHdl( LINK( this, DlgExportEPBM, OK ) );
+}
+
+/*************************************************************************
+|*
+|* Speichert eingestellte Werte in ini-Datei
+|*
+\************************************************************************/
+
+IMPL_LINK( DlgExportEPBM, OK, void *, EMPTYARG )
+{
+
+ // Config-Parameter schreiben
+ String aStr;
+
+ sal_Int32 nCheck = 0;
+ if ( aRBASCII.IsChecked() )
+ nCheck++;
+ String aFormatStr( ResId( KEY_FORMAT, pMgr ) );
+ pConfig->WriteKey( ByteString( aFormatStr, RTL_TEXTENCODING_UTF8 ), ByteString::CreateFromInt32( nCheck ) );
+
+ EndDialog( RET_OK );
+
+ return 0;
+}
diff --git a/goodies/source/filter.vcl/epbm/dlgepbm.hrc b/goodies/source/filter.vcl/epbm/dlgepbm.hrc
new file mode 100644
index 000000000000..05db15d1099d
--- /dev/null
+++ b/goodies/source/filter.vcl/epbm/dlgepbm.hrc
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgepbm.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "goodies.hrc"
+
+#define BTN_OK 1
+#define BTN_CANCEL 1
+#define BTN_HELP 1
+#define GRP_FORMAT 1
+#define RB_RAW 1
+#define RB_ASCII 2
diff --git a/goodies/source/filter.vcl/epbm/dlgepbm.hxx b/goodies/source/filter.vcl/epbm/dlgepbm.hxx
new file mode 100644
index 000000000000..d44d23448d1b
--- /dev/null
+++ b/goodies/source/filter.vcl/epbm/dlgepbm.hxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgepbm.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _DLGEPBM_HXX_
+#define _DLGEPBM_HXX_
+#include <svtools/fltcall.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/group.hxx>
+#include <vcl/field.hxx>
+#include <svtools/stdctrl.hxx>
+
+
+/*************************************************************************
+|*
+|* Dialog zum Einstellen von Filteroptionen
+|*
+\************************************************************************/
+
+class Config;
+class ResMgr;
+
+class DlgExportEPBM : public ModalDialog
+{
+private:
+ GroupBox aGrpFormat;
+ RadioButton aRBRaw;
+ RadioButton aRBASCII;
+ OKButton aBtnOK;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ Config* pConfig;
+ ResMgr* pMgr;
+
+ DECL_LINK( OK, void * );
+
+public:
+ DlgExportEPBM( FltCallDialogParameter& rPara );
+};
+
+#endif // _DLGEPBM_HXX_
diff --git a/goodies/source/filter.vcl/epbm/dlgepbm.src b/goodies/source/filter.vcl/epbm/dlgepbm.src
new file mode 100644
index 000000000000..e6884904c923
--- /dev/null
+++ b/goodies/source/filter.vcl/epbm/dlgepbm.src
@@ -0,0 +1,198 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgepbm.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "dlgepbm.hrc"
+ModalDialog DLG_EXPORT_EPBM
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 133 , 67 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Text = "PBM Optionen" ;
+ Text [ ENGLISH ] = "PBM options" ;
+ Text [ english_us ] = "PBM Options" ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 73 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 73 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 73 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ GroupBox GRP_FORMAT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 60 , 54 ) ;
+ Text = "Datei Format" ;
+ Text [ ENGLISH ] = "file format" ;
+ Text[ italian ] = "Formato file";
+ Text[ portuguese_brazilian ] = "Datei Format";
+ Text[ portuguese ] = "Formato do ficheiro";
+ Text[ danish ] = "Filformat";
+ Text[ french ] = "Format de fichier";
+ Text[ swedish ] = "Filformat";
+ Text[ dutch ] = "Bestandsformaat";
+ Text[ spanish ] = "Formato de archivo";
+ Text[ english_us ] = "File format";
+ Text[ chinese_simplified ] = "Îļþ¸ñʽ";
+ Text[ russian ] = "Ôîðìàò ôàéëà";
+ Text[ polish ] = "Format pliku";
+ Text[ japanese ] = "̧²Ù‚Ì‘Ž®";
+ Text[ chinese_traditional ] = "Àɮ׮榡";
+ Text[ arabic ] = "ÊäÓíÞ ÇáãáÝ";
+ Text[ dutch ] = "Bestandsformaat";
+ Text[ chinese_simplified ] = "Îļþ¸ñʽ";
+ Text[ greek ] = "ÌïñöÞ áñ÷åßïõ";
+ Text[ korean ] = "ÆÄÀÏ ¼­½Ä";
+ Text[ turkish ] = "Dosya formatý";
+ Text[ language_user1 ] = " ";
+ };
+ RadioButton RB_RAW
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text = "~Binär" ;
+ Text [ ENGLISH ] = "~raw" ;
+ TabStop = TRUE ;
+ Text[ italian ] = "~Binario";
+ Text[ portuguese_brazilian ] = "~Binär";
+ Text[ portuguese ] = "~Binário";
+ Text[ danish ] = "~Binær";
+ Text[ french ] = "~Binaire";
+ Text[ swedish ] = "~Binär";
+ Text[ dutch ] = "~Binair";
+ Text[ spanish ] = "~Binario";
+ Text[ english_us ] = "~Binary";
+ Text[ chinese_simplified ] = "¶þÔª(~B)";
+ Text[ russian ] = "Áèíàðíûé";
+ Text[ polish ] = "Binarny";
+ Text[ japanese ] = "ÊÞ²ÅØ(~B)";
+ Text[ language_user1 ] = " ";
+ Text[ chinese_traditional ] = "¤G¦ì¤¸(~B)";
+ Text[ arabic ] = "ËäÇÆí";
+ Text[ dutch ] = "~Binair";
+ Text[ chinese_simplified ] = "¶þÔª(~B)";
+ Text[ greek ] = "Äõáäéêü";
+ Text[ korean ] = "¹ÙÀ̳ʸ®(~B)";
+ Text[ turkish ] = "Ýkili";
+ };
+ RadioButton RB_ASCII
+ {
+ Pos = MAP_APPFONT ( 12 , 27 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text = "~Text" ;
+ Text [ ENGLISH ] = "~text" ;
+ TabStop = TRUE ;
+ Text[ italian ] = "~Testo";
+ Text[ portuguese_brazilian ] = "~Text";
+ Text[ portuguese ] = "~Texto";
+ Text[ danish ] = "~Tekst";
+ Text[ french ] = "~Texte";
+ Text[ swedish ] = "~Text";
+ Text[ dutch ] = "~Tekst";
+ Text[ spanish ] = "~Texto";
+ Text[ english_us ] = "~Text";
+ Text[ chinese_simplified ] = "ÎÄ×Ö(~T)";
+ Text[ russian ] = "Òåêñò";
+ Text[ polish ] = "Tekst";
+ Text[ japanese ] = "÷½Ä(~T)";
+ Text[ chinese_traditional ] = "¤å¦r(~T)";
+ Text[ arabic ] = "ÇáäÕ";
+ Text[ dutch ] = "~Tekst";
+ Text[ chinese_simplified ] = "ÎÄ×Ö(~T)";
+ Text[ greek ] = "Êåßìåíï";
+ Text[ korean ] = "ÅؽºÆ®(~T)";
+ Text[ turkish ] = "Metin";
+ Text[ language_user1 ] = " ";
+ };
+ Text[ italian ] = "Opzioni PBM";
+ Text[ portuguese_brazilian ] = "PBM Optionen";
+ Text[ portuguese ] = "Opções PBM";
+ Text[ danish ] = "PBM indstillinger";
+ Text[ french ] = "Options PBM";
+ Text[ swedish ] = "PBM alternativ";
+ Text[ dutch ] = "PBM-opties";
+ Text[ spanish ] = "Opciones PBM ";
+ Text[ chinese_simplified ] = "PBM Ñ¡Ïî";
+ Text[ russian ] = "Ïàðàìåòðû PBM";
+ Text[ polish ] = "Opcje PBM ";
+ Text[ japanese ] = "PBM µÌß¼®Ý";
+ Text[ chinese_traditional ] = "PBM¿ï¶µ";
+ Text[ arabic ] = "PBM ÎíÇÑÇÊ";
+ Text[ dutch ] = "PBM-opties";
+ Text[ chinese_simplified ] = "PBM Ñ¡Ïî";
+ Text[ greek ] = "ÅðéëïãÝò PBM";
+ Text[ korean ] = "PBM ¿É¼Ç";
+ Text[ turkish ] = "PBM seçenekleri";
+ Text[ language_user1 ] = " ";
+};
diff --git a/goodies/source/filter.vcl/epbm/epbm.cxx b/goodies/source/filter.vcl/epbm/epbm.cxx
new file mode 100644
index 000000000000..f6dc198be5bd
--- /dev/null
+++ b/goodies/source/filter.vcl/epbm/epbm.cxx
@@ -0,0 +1,319 @@
+/*************************************************************************
+ *
+ * $RCSfile: epbm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <vcl/svapp.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/config.hxx>
+#include <vcl/msgbox.hxx>
+#include <svtools/solar.hrc>
+#include <svtools/fltcall.hxx>
+#include "strings.hrc"
+#include "dlgepbm.hrc"
+#include "dlgepbm.hxx"
+
+//============================ PBMWriter ==================================
+
+class PBMWriter {
+
+private:
+
+ PFilterCallback mpCallback;
+ void * mpCallerData;
+
+ SvStream* mpOStm; // Die auszugebende PBM-Datei
+ USHORT mpOStmOldModus;
+
+ BOOL mbStatus;
+ UINT32 mnMode; // 0 -> raw, 1-> ascii
+ BitmapReadAccess* mpAcc;
+ ULONG mnWidth, mnHeight; // Bildausmass in Pixeln
+
+ BOOL ImplCallback( USHORT nPercent );
+ BOOL ImplWriteHeader();
+ void ImplWriteBody();
+ void ImplWriteNumber( sal_Int32 );
+
+public:
+ PBMWriter();
+ ~PBMWriter();
+
+ BOOL WritePBM( const Graphic& rGraphic, SvStream& rPBM,
+ PFilterCallback pCallback, void* pCallerdata,
+ Config* pOptionsConfig );
+};
+
+//=================== Methoden von PBMWriter ==============================
+
+PBMWriter::PBMWriter() :
+ mpAcc ( NULL ),
+ mbStatus ( TRUE )
+{
+}
+
+// ------------------------------------------------------------------------
+
+PBMWriter::~PBMWriter()
+{
+}
+
+// ------------------------------------------------------------------------
+
+BOOL PBMWriter::ImplCallback( USHORT nPercent )
+{
+ if ( mpCallback != NULL )
+ {
+ if ( ( (*mpCallback)( mpCallerData, nPercent ) ) == TRUE )
+ {
+ mpOStm->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL PBMWriter::WritePBM( const Graphic& rGraphic, SvStream& rPBM,
+ PFilterCallback pCallback, void* pCallerdata,
+ Config* pOptionsConfig )
+{
+
+ mpOStm = &rPBM;
+ mpCallback = pCallback;
+ mpCallerData = pCallerdata;
+
+ if ( pOptionsConfig )
+ {
+ mnMode = pOptionsConfig->ReadKey( "PBM-EXPORT-FORMAT", "0" ).ToInt32();
+ }
+
+ BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+ Bitmap aBmp = aBmpEx.GetBitmap();
+ aBmp.Convert( BMP_CONVERSION_1BIT_THRESHOLD );
+
+ mpOStmOldModus = mpOStm->GetNumberFormatInt();
+ mpOStm->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+
+ mpAcc = aBmp.AcquireReadAccess();
+ if( mpAcc )
+ {
+ if ( ImplWriteHeader() )
+ ImplWriteBody();
+
+ aBmp.ReleaseAccess( mpAcc );
+ }
+ else
+ mbStatus = FALSE;
+
+ mpOStm->SetNumberFormatInt( mpOStmOldModus );
+
+ return mbStatus;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL PBMWriter::ImplWriteHeader()
+{
+ mnWidth = mpAcc->Width();
+ mnHeight = mpAcc->Height();
+ if ( mnWidth && mnHeight )
+ {
+ if ( mnMode == 0 )
+ *mpOStm << "P4\x0a";
+ else
+ *mpOStm << "P1\x0a";
+
+ ImplWriteNumber( mnWidth );
+ *mpOStm << (BYTE)32;
+ ImplWriteNumber( mnHeight );
+ *mpOStm << (BYTE)10;
+ }
+ else mbStatus = FALSE;
+ return mbStatus;
+}
+
+// ------------------------------------------------------------------------
+
+void PBMWriter::ImplWriteBody()
+{
+ if ( mnMode == 0 )
+ {
+ BYTE nBYTE;
+ for ( ULONG y = 0; y < mnHeight; y++ )
+ {
+ ULONG x;
+ for ( x = 0; x < mnWidth; x++ )
+ {
+ nBYTE <<= 1;
+ if (!(mpAcc->GetPixel( y, x ) & 1 ) )
+ nBYTE++;
+ if ( ( x & 7 ) == 7 )
+ *mpOStm << nBYTE;
+ }
+ if ( ( x & 7 ) != 0 )
+ *mpOStm << (BYTE)( nBYTE << ( ( x ^ 7 ) + 1 ) );
+ }
+ }
+ else
+ {
+ int nxCount;
+ for ( ULONG y = 0; y < mnHeight; y++ )
+ {
+ nxCount = 70;
+ for ( ULONG x = 0; x < mnWidth; x++ )
+ {
+ if (!( --nxCount ) )
+ {
+ nxCount = 69;
+ *mpOStm << (BYTE)10;
+ }
+ *mpOStm << (BYTE)( ( mpAcc->GetPixel( y, x ) ^ 1 ) + '0' ) ;
+ }
+ *mpOStm << (BYTE)10;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+// eine Dezimalzahl im ASCII format wird in den Stream geschrieben
+
+void PBMWriter::ImplWriteNumber( sal_Int32 nNumber )
+{
+ const ByteString aNum( ByteString::CreateFromInt32( nNumber ) );
+
+ for( sal_Int32 n = 0, nLen = aNum.Len(); n < nLen; n++ )
+ *mpOStm << aNum.GetChar( n );
+
+}
+
+// ------------------------------------------------------------------------
+
+// ---------------------
+// - exported function -
+// ---------------------
+
+extern "C" BOOL __LOADONCALLAPI GraphicExport( SvStream& rStream, Graphic& rGraphic,
+ PFilterCallback pCallback, void* pCallerData,
+ Config* pOptionsConfig, BOOL )
+{
+ PBMWriter aPBMWriter;
+
+ return aPBMWriter.WritePBM( rGraphic, rStream, pCallback, pCallerData, pOptionsConfig );
+}
+
+// ------------------------------------------------------------------------
+
+extern "C" BOOL __LOADONCALLAPI DoExportDialog( FltCallDialogParameter& rPara )
+{
+ BOOL bRet = FALSE;
+
+ if ( rPara.pWindow && rPara.pCfg )
+ {
+ ByteString aResMgrName( "epb" );
+ ResMgr* pResMgr;
+
+ aResMgrName.Append( ByteString::CreateFromInt32( SOLARUPD ) );
+ pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetAppInternational().GetLanguage() );
+
+ if( pResMgr )
+ {
+ rPara.pResMgr = pResMgr;
+ bRet = ( DlgExportEPBM( rPara ).Execute() == RET_OK );
+ delete pResMgr;
+ }
+ else
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+#pragma hdrstop
+
+// ---------------
+// - Win16 trash -
+// ---------------
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0;
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+ if ( nHeap )
+ UnlockData( 0 );
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
diff --git a/goodies/source/filter.vcl/epbm/epbmstr.src b/goodies/source/filter.vcl/epbm/epbmstr.src
new file mode 100644
index 000000000000..e40d72c97529
--- /dev/null
+++ b/goodies/source/filter.vcl/epbm/epbmstr.src
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * $RCSfile: epbmstr.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include "strings.hrc"
+
+// Key fuer den Dialog
+String KEY_FORMAT
+{
+ Text = "PBM-EXPORT-FORMAT";
+};
diff --git a/goodies/source/filter.vcl/epbm/makefile.mk b/goodies/source/filter.vcl/epbm/makefile.mk
new file mode 100644
index 000000000000..ad67f60e1d66
--- /dev/null
+++ b/goodies/source/filter.vcl/epbm/makefile.mk
@@ -0,0 +1,184 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=epbm
+TARGET2=epb
+DEPTARGET=vepbm
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SRCFILES= dlgepbm.src \
+ epbmstr.src
+
+SLOFILES = $(SLO)$/epbm.obj \
+ $(SLO)$/dlgepbm.obj
+
+# ==========================================================================
+
+RESLIB1NAME=$(TARGET2)
+RESLIB1SRSFILES=$(SRS)$/$(TARGET).srs
+
+SHL1TARGET= epb$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= epbm
+SHL1STDLIBS= $(TOOLSLIB) \
+ $(SVLIB) \
+ $(CPPULIB) \
+ $(SVTOOLLIB)
+
+SHL1DEPN= $(LB)$/epbm.lib
+SHL1LIBS= $(SLB)$/epbm.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/epbm.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicExport >>$@
+ @echo DoExportDialog >>$@
+.ELSE
+ @echo _GraphicExport >>$@
+ @echo _DoExportDialog >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET).DLL >>$@
+ @ldump -E1 -A $(SLB)$/epbm.lib >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicExport >>$@
+ @echo DoExportDialog >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/epbm/strings.hrc b/goodies/source/filter.vcl/epbm/strings.hrc
new file mode 100644
index 000000000000..5a1e869a47dc
--- /dev/null
+++ b/goodies/source/filter.vcl/epbm/strings.hrc
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * $RCSfile: strings.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#define KEY_FORMAT 256
diff --git a/goodies/source/filter.vcl/epgm/dlgepgm.cxx b/goodies/source/filter.vcl/epgm/dlgepgm.cxx
new file mode 100644
index 000000000000..19a500dbf95e
--- /dev/null
+++ b/goodies/source/filter.vcl/epgm/dlgepgm.cxx
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgepgm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma hdrstop
+#include <tools/ref.hxx>
+#include <vcl/config.hxx>
+#include <vcl/msgbox.hxx>
+#include "dlgepgm.hxx"
+#include "dlgepgm.hrc"
+#include "strings.hrc"
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+
+DlgExportEPGM::DlgExportEPGM( FltCallDialogParameter& rPara ) :
+ ModalDialog ( rPara.pWindow, ResId( DLG_EXPORT_EPGM, rPara.pResMgr ) ),
+ aGrpFormat ( this, ResId( GRP_FORMAT ) ),
+ aRBRaw ( this, ResId( RB_RAW ) ),
+ aRBASCII ( this, ResId( RB_ASCII ) ),
+ aBtnOK ( this, ResId( BTN_OK ) ),
+ aBtnCancel ( this, ResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ResId( BTN_HELP ) ),
+ pConfig ( rPara.pCfg ),
+ pMgr ( rPara.pResMgr )
+{
+ FreeResource();
+
+ // Config-Parameter lesen
+
+ String aFormatStr( ResId( KEY_FORMAT, pMgr ) );
+ sal_Int32 nFormat = pConfig->ReadKey( ByteString( aFormatStr, RTL_TEXTENCODING_UTF8 ) ).ToInt32();
+
+ BOOL bCheck = FALSE;
+ if ( !nFormat )
+ bCheck ^= TRUE;
+ aRBRaw.Check( bCheck );
+ bCheck ^= TRUE;
+ aRBASCII.Check( bCheck );
+
+ aBtnOK.SetClickHdl( LINK( this, DlgExportEPGM, OK ) );
+}
+
+/*************************************************************************
+|*
+|* Speichert eingestellte Werte in ini-Datei
+|*
+\************************************************************************/
+
+IMPL_LINK( DlgExportEPGM, OK, void *, EMPTYARG )
+{
+
+ // Config-Parameter schreiben
+ sal_Int32 nCheck = 0;
+ if ( aRBASCII.IsChecked() )
+ nCheck++;
+ String aFormatStr( ResId( KEY_FORMAT, pMgr ) );
+ pConfig->WriteKey( ByteString( aFormatStr, RTL_TEXTENCODING_UTF8 ), ByteString::CreateFromInt32( nCheck ) );
+
+ EndDialog( RET_OK );
+
+ return 0;
+}
diff --git a/goodies/source/filter.vcl/epgm/dlgepgm.hrc b/goodies/source/filter.vcl/epgm/dlgepgm.hrc
new file mode 100644
index 000000000000..c582fdd8b2db
--- /dev/null
+++ b/goodies/source/filter.vcl/epgm/dlgepgm.hrc
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgepgm.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "goodies.hrc"
+
+#define BTN_OK 1
+#define BTN_CANCEL 1
+#define BTN_HELP 1
+#define GRP_FORMAT 1
+#define RB_RAW 1
+#define RB_ASCII 2
diff --git a/goodies/source/filter.vcl/epgm/dlgepgm.hxx b/goodies/source/filter.vcl/epgm/dlgepgm.hxx
new file mode 100644
index 000000000000..4cfd937f33da
--- /dev/null
+++ b/goodies/source/filter.vcl/epgm/dlgepgm.hxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgepgm.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _DLGEPGM_HXX_
+#define _DLGEPGM_HXX_
+#include <svtools/fltcall.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/group.hxx>
+#include <vcl/field.hxx>
+#include <svtools/stdctrl.hxx>
+
+
+/*************************************************************************
+|*
+|* Dialog zum Einstellen von Filteroptionen
+|*
+\************************************************************************/
+
+class Config;
+class ResMgr;
+
+class DlgExportEPGM : public ModalDialog
+{
+private:
+ GroupBox aGrpFormat;
+ RadioButton aRBRaw;
+ RadioButton aRBASCII;
+ OKButton aBtnOK;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ Config* pConfig;
+ ResMgr* pMgr;
+
+ DECL_LINK( OK, void * );
+
+public:
+ DlgExportEPGM( FltCallDialogParameter& rPara );
+};
+
+#endif // _DLGEPGM_HXX_
diff --git a/goodies/source/filter.vcl/epgm/dlgepgm.src b/goodies/source/filter.vcl/epgm/dlgepgm.src
new file mode 100644
index 000000000000..c5d5bd63797b
--- /dev/null
+++ b/goodies/source/filter.vcl/epgm/dlgepgm.src
@@ -0,0 +1,198 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgepgm.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "dlgepgm.hrc"
+ModalDialog DLG_EXPORT_EPGM
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 133 , 67 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Text = "PGM Optionen" ;
+ Text [ ENGLISH ] = "PGM options" ;
+ Text [ english_us ] = "PGM Options" ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 73 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 73 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 73 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ GroupBox GRP_FORMAT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 60 , 54 ) ;
+ Text = "Datei Format" ;
+ Text [ ENGLISH ] = "file format" ;
+ Text[ italian ] = "Formato file";
+ Text[ portuguese_brazilian ] = "Datei Format";
+ Text[ portuguese ] = "Formato do ficheiro";
+ Text[ danish ] = "Filformat";
+ Text[ french ] = "Format de fichier";
+ Text[ swedish ] = "Filformat";
+ Text[ dutch ] = "Bestandsformaat";
+ Text[ spanish ] = "Formato de archivo";
+ Text[ english_us ] = "File format";
+ Text[ chinese_simplified ] = "Îļþ¸ñʽ";
+ Text[ russian ] = "Ôîðìàò ôàéëà";
+ Text[ polish ] = "Format pliku";
+ Text[ japanese ] = "̧²Ù‚Ì‘Ž®";
+ Text[ chinese_traditional ] = "Àɮ׮榡";
+ Text[ arabic ] = "ÊäÓíÞ ÇáãáÝ";
+ Text[ dutch ] = "Bestandsformaat";
+ Text[ chinese_simplified ] = "Îļþ¸ñʽ";
+ Text[ greek ] = "ÌïñöÞ áñ÷åßïõ";
+ Text[ korean ] = "ÆÄÀÏ ¼­½Ä";
+ Text[ turkish ] = "Dosya formatý";
+ Text[ language_user1 ] = " ";
+ };
+ RadioButton RB_RAW
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text = "~Binär" ;
+ Text [ ENGLISH ] = "~raw" ;
+ TabStop = TRUE ;
+ Text[ italian ] = "~Binario";
+ Text[ portuguese_brazilian ] = "~Binär";
+ Text[ portuguese ] = "~Binário";
+ Text[ danish ] = "~Binær";
+ Text[ french ] = "~Binaire";
+ Text[ swedish ] = "~Binär";
+ Text[ dutch ] = "~Binair";
+ Text[ spanish ] = "~Binario";
+ Text[ english_us ] = "~Binary";
+ Text[ chinese_simplified ] = "¶þÔª(~B)";
+ Text[ russian ] = "Áèíàðíûé";
+ Text[ polish ] = "Binarny";
+ Text[ japanese ] = "ÊÞ²ÅØ(~B)";
+ Text[ language_user1 ] = " ";
+ Text[ chinese_traditional ] = "¤G¦ì¤¸(~B)";
+ Text[ arabic ] = "ËäÇÆí";
+ Text[ dutch ] = "~Binair";
+ Text[ chinese_simplified ] = "¶þÔª(~B)";
+ Text[ greek ] = "Äõáäéêü";
+ Text[ korean ] = "¹ÙÀ̳ʸ®(~B)";
+ Text[ turkish ] = "Ýkili";
+ };
+ RadioButton RB_ASCII
+ {
+ Pos = MAP_APPFONT ( 12 , 27 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text = "~Text" ;
+ Text [ ENGLISH ] = "~text" ;
+ TabStop = TRUE ;
+ Text[ italian ] = "~Testo";
+ Text[ portuguese_brazilian ] = "~Text";
+ Text[ portuguese ] = "~Texto";
+ Text[ danish ] = "~Tekst";
+ Text[ french ] = "~Texte";
+ Text[ swedish ] = "~Text";
+ Text[ dutch ] = "~Tekst";
+ Text[ spanish ] = "~Texto";
+ Text[ english_us ] = "~Text";
+ Text[ chinese_simplified ] = "ÎÄ×Ö(~T)";
+ Text[ russian ] = "Òåêñò";
+ Text[ polish ] = "Tekst";
+ Text[ japanese ] = "÷½Ä(~T)";
+ Text[ chinese_traditional ] = "¤å¦r(~T)";
+ Text[ arabic ] = "ÇáäÕ";
+ Text[ dutch ] = "~Tekst";
+ Text[ chinese_simplified ] = "ÎÄ×Ö(~T)";
+ Text[ greek ] = "Êåßìåíï";
+ Text[ korean ] = "ÅؽºÆ®(~T)";
+ Text[ turkish ] = "Metin";
+ Text[ language_user1 ] = " ";
+ };
+ Text[ italian ] = "Opzioni PGM";
+ Text[ portuguese_brazilian ] = "PGM Optionen";
+ Text[ portuguese ] = "Opções PGM";
+ Text[ danish ] = "PGM indstillinger";
+ Text[ french ] = "Options PGM";
+ Text[ swedish ] = "PGM alternativ";
+ Text[ dutch ] = "PGM-opties";
+ Text[ spanish ] = "Opciones PGM";
+ Text[ chinese_simplified ] = "PGM Ñ¡Ïî";
+ Text[ russian ] = "Ïàðàìåòðû PGM";
+ Text[ polish ] = "Opcje PGM";
+ Text[ japanese ] = "PGM µÌß¼®Ý";
+ Text[ chinese_traditional ] = "PGM¿ï¶µ";
+ Text[ arabic ] = "PGM ÎíÇÑÇÊ";
+ Text[ dutch ] = "PGM-opties";
+ Text[ chinese_simplified ] = "PGM Ñ¡Ïî";
+ Text[ greek ] = "ÅðéëïãÝò PGM";
+ Text[ korean ] = "PGM ¿É¼Ç";
+ Text[ turkish ] = "PGM seçenekleri";
+ Text[ language_user1 ] = " ";
+};
diff --git a/goodies/source/filter.vcl/epgm/epgm.cxx b/goodies/source/filter.vcl/epgm/epgm.cxx
new file mode 100644
index 000000000000..44cd6b6b9b2c
--- /dev/null
+++ b/goodies/source/filter.vcl/epgm/epgm.cxx
@@ -0,0 +1,339 @@
+/*************************************************************************
+ *
+ * $RCSfile: epgm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <vcl/svapp.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/config.hxx>
+#include <vcl/msgbox.hxx>
+#include <svtools/solar.hrc>
+#include <svtools/fltcall.hxx>
+#include "strings.hrc"
+#include "dlgepgm.hrc"
+#include "dlgepgm.hxx"
+
+//============================ PGMWriter ==================================
+
+class PGMWriter {
+
+private:
+
+ PFilterCallback mpCallback;
+ void * mpCallerData;
+
+ SvStream* mpOStm; // Die auszugebende PGM-Datei
+ USHORT mpOStmOldModus;
+
+ BOOL mbStatus;
+ UINT32 mnMode;
+ BitmapReadAccess* mpAcc;
+ ULONG mnWidth, mnHeight; // Bildausmass in Pixeln
+
+ BOOL ImplCallback( USHORT nPercent );
+ BOOL ImplWriteHeader();
+ void ImplWriteBody();
+ void ImplWriteNumber( sal_Int32 );
+
+public:
+ PGMWriter();
+ ~PGMWriter();
+
+ BOOL WritePGM( const Graphic& rGraphic, SvStream& rPGM,
+ PFilterCallback pCallback, void* pCallerdata,
+ Config* pOptionsConfig );
+};
+
+//=================== Methoden von PGMWriter ==============================
+
+PGMWriter::PGMWriter() :
+ mpAcc ( NULL ),
+ mbStatus ( TRUE )
+{
+}
+
+// ------------------------------------------------------------------------
+
+PGMWriter::~PGMWriter()
+{
+}
+
+// ------------------------------------------------------------------------
+
+BOOL PGMWriter::ImplCallback( USHORT nPercent )
+{
+ if ( mpCallback != NULL )
+ {
+ if ( ( (*mpCallback)( mpCallerData, nPercent ) ) == TRUE )
+ {
+ mpOStm->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL PGMWriter::WritePGM( const Graphic& rGraphic, SvStream& rPGM,
+ PFilterCallback pCallback, void* pCallerdata,
+ Config* pOptionsConfig )
+{
+
+ mpOStm = &rPGM;
+ mpCallback = pCallback;
+ mpCallerData = pCallerdata;
+
+ if ( pOptionsConfig )
+ {
+ mnMode = pOptionsConfig->ReadKey( "PGM-EXPORT-FORMAT", "0" ).ToInt32();
+ }
+
+ BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+ Bitmap aBmp = aBmpEx.GetBitmap();
+ aBmp.Convert( BMP_CONVERSION_8BIT_GREYS );
+
+ mpOStmOldModus = mpOStm->GetNumberFormatInt();
+ mpOStm->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+
+ mpAcc = aBmp.AcquireReadAccess();
+ if( mpAcc )
+ {
+ if ( ImplWriteHeader() )
+ {
+ ImplWriteBody();
+ }
+ aBmp.ReleaseAccess( mpAcc );
+ }
+ else
+ mbStatus = FALSE;
+
+ mpOStm->SetNumberFormatInt( mpOStmOldModus );
+
+ return mbStatus;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL PGMWriter::ImplWriteHeader()
+{
+ mnWidth = mpAcc->Width();
+ mnHeight = mpAcc->Height();
+ if ( mnWidth && mnHeight )
+ {
+ if ( mnMode == 0 )
+ *mpOStm << "P5\x0a";
+ else
+ *mpOStm << "P2\x0a";
+
+ ImplWriteNumber( mnWidth );
+ *mpOStm << (BYTE)32;
+ ImplWriteNumber( mnHeight );
+ *mpOStm << (BYTE)32;
+ ImplWriteNumber( 255 ); // max. gray value
+ *mpOStm << (BYTE)10;
+ }
+ else
+ mbStatus = FALSE;
+
+ return mbStatus;
+}
+
+// ------------------------------------------------------------------------
+
+void PGMWriter::ImplWriteBody()
+{
+ if ( mnMode == 0 )
+ {
+ for ( ULONG y = 0; y < mnHeight; y++ )
+ {
+ for ( ULONG x = 0; x < mnWidth; x++ )
+ {
+ *mpOStm << (BYTE)( mpAcc->GetPixel( y, x ) );
+ }
+ }
+ }
+ else
+ {
+ for ( ULONG y = 0; y < mnHeight; y++ )
+ {
+ int nCount = 70;
+ for ( ULONG x = 0; x < mnWidth; x++ )
+ {
+ BYTE nDat, nNumb;
+ if ( nCount < 0 )
+ {
+ nCount = 69;
+ *mpOStm << (BYTE)10;
+ }
+ nDat = (BYTE)mpAcc->GetPixel( y, x );
+ if ( ( nNumb = nDat / 100 ) )
+ {
+ *mpOStm << (BYTE)( nNumb + '0' );
+ nDat -= ( nNumb * 100 );
+ nNumb = nDat / 10;
+ *mpOStm << (BYTE)( nNumb + '0' );
+ nDat -= ( nNumb * 10 );
+ *mpOStm << (BYTE)( nDat + '0' );
+ nCount -= 4;
+ }
+ else if ( ( nNumb = nDat / 10 ) )
+ {
+ *mpOStm << (BYTE)( nNumb + '0' );
+ nDat -= ( nNumb * 10 );
+ *mpOStm << (BYTE)( nDat + '0' );
+ nCount -= 3;
+ }
+ else
+ {
+ *mpOStm << (BYTE)( nDat + '0' );
+ nCount -= 2;
+ }
+ *mpOStm << (BYTE)' ';
+ }
+ *mpOStm << (BYTE)10;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+// eine Dezimalzahl im ASCII format wird in den Stream geschrieben
+
+void PGMWriter::ImplWriteNumber( sal_Int32 nNumber )
+{
+ const ByteString aNum( ByteString::CreateFromInt32( nNumber ) );
+
+ for( sal_Int32 n = 0UL, nLen = aNum.Len(); n < nLen; n++ )
+ *mpOStm << aNum.GetChar( n );
+
+}
+
+// ------------------------------------------------------------------------
+
+// ---------------------
+// - exported function -
+// ---------------------
+
+extern "C" BOOL __LOADONCALLAPI GraphicExport( SvStream& rStream, Graphic& rGraphic,
+ PFilterCallback pCallback, void* pCallerData,
+ Config* pOptionsConfig, BOOL )
+{
+ PGMWriter aPGMWriter;
+
+ return aPGMWriter.WritePGM( rGraphic, rStream, pCallback, pCallerData, pOptionsConfig );
+}
+
+// ------------------------------------------------------------------------
+
+extern "C" BOOL __LOADONCALLAPI DoExportDialog( FltCallDialogParameter& rPara )
+{
+ BOOL bRet = FALSE;
+
+ if ( rPara.pWindow && rPara.pCfg )
+ {
+ ByteString aResMgrName( "epg" );
+ ResMgr* pResMgr;
+
+ aResMgrName.Append( ByteString::CreateFromInt32( SOLARUPD ) );
+ pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetAppInternational().GetLanguage() );
+
+ if( pResMgr )
+ {
+ rPara.pResMgr = pResMgr;
+ bRet = ( DlgExportEPGM( rPara ).Execute() == RET_OK );
+ delete pResMgr;
+ }
+ else
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+#pragma hdrstop
+
+// ---------------
+// - Win16 trash -
+// ---------------
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0;
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+ if ( nHeap )
+ UnlockData( 0 );
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
diff --git a/goodies/source/filter.vcl/epgm/epgmstr.src b/goodies/source/filter.vcl/epgm/epgmstr.src
new file mode 100644
index 000000000000..921b45734449
--- /dev/null
+++ b/goodies/source/filter.vcl/epgm/epgmstr.src
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * $RCSfile: epgmstr.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include "strings.hrc"
+
+// Key fuer den Dialog
+String KEY_FORMAT
+{
+ Text = "PGM-EXPORT-FORMAT";
+};
diff --git a/goodies/source/filter.vcl/epgm/makefile.mk b/goodies/source/filter.vcl/epgm/makefile.mk
new file mode 100644
index 000000000000..9fe3d54d5aae
--- /dev/null
+++ b/goodies/source/filter.vcl/epgm/makefile.mk
@@ -0,0 +1,185 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=epgm
+TARGET2=epg
+DEPTARGET=vepgm
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SRCFILES= dlgepgm.src \
+ epgmstr.src
+
+SLOFILES = $(SLO)$/epgm.obj \
+ $(SLO)$/dlgepgm.obj
+
+# ==========================================================================
+
+RESLIB1NAME=$(TARGET2)
+RESLIB1SRSFILES=$(SRS)$/$(TARGET).srs
+
+SHL1TARGET= epg$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= epgm
+SHL1STDLIBS= $(TOOLSLIB) \
+ $(SVLIB) \
+ $(CPPULIB) \
+ $(SVTOOLLIB)
+
+SHL1DEPN= $(LB)$/epgm.lib
+SHL1LIBS= $(SLB)$/epgm.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/epgm.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicExport >>$@
+ @echo DoExportDialog >>$@
+.ELSE
+ @echo _GraphicExport >>$@
+ @echo _DoExportDialog >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET).DLL >>$@
+ @ldump -E1 -A $(SLB)$/epgm.lib >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicExport >>$@
+ @echo DoExportDialog >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/epgm/strings.hrc b/goodies/source/filter.vcl/epgm/strings.hrc
new file mode 100644
index 000000000000..5a1e869a47dc
--- /dev/null
+++ b/goodies/source/filter.vcl/epgm/strings.hrc
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * $RCSfile: strings.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#define KEY_FORMAT 256
diff --git a/goodies/source/filter.vcl/epict/dlgepct.cxx b/goodies/source/filter.vcl/epict/dlgepct.cxx
new file mode 100644
index 000000000000..8b89d8871d3e
--- /dev/null
+++ b/goodies/source/filter.vcl/epict/dlgepct.cxx
@@ -0,0 +1,222 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgepct.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma hdrstop
+
+#include <vcl/msgbox.hxx>
+#include <vcl/config.hxx>
+#include "dlgepct.hxx"
+#include "dlgepct.hrc"
+#include "strings.hrc"
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+
+DlgExportEPCT::DlgExportEPCT( FltCallDialogParameter& rPara ) :
+ ModalDialog ( rPara.pWindow, ResId( DLG_EXPORT_EPCT, rPara.pResMgr ) ),
+ aBtnOK ( this, ResId( BTN_OK ) ),
+ aBtnCancel ( this, ResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ResId( BTN_HELP ) ),
+ aRbOriginal ( this, ResId( RB_ORIGINAL ) ),
+ aRbSize ( this, ResId( RB_SIZE ) ),
+ aGrpMode ( this, ResId( GRP_MODE ) ),
+ aFtSizeX ( this, ResId( FT_SIZEX ) ),
+ aMtfSizeX ( this, ResId( MTF_SIZEX ) ),
+ aFtSizeY ( this, ResId( FT_SIZEY ) ),
+ aMtfSizeY ( this, ResId( MTF_SIZEY ) ),
+ aGrpSize ( this, ResId( GRP_SIZE ) ),
+ pConfig ( rPara.pCfg ),
+ pMgr ( rPara.pResMgr )
+
+{
+ FreeResource();
+
+ aBtnOK.SetClickHdl( LINK( this, DlgExportEPCT, OK ) );
+ aRbOriginal.SetClickHdl( LINK( this, DlgExportEPCT, ClickRbOriginal ) );
+ aRbSize.SetClickHdl( LINK( this, DlgExportEPCT, ClickRbSize ) );
+
+ // Config-Parameter lesen
+ String aMStr( ResId( KEY_MODE, pMgr ) );
+ String aSXStr( ResId( KEY_SIZEX, pMgr ) );
+ String aSYStr( ResId( KEY_SIZEY, pMgr ) );
+
+ sal_Int32 nStrMode( pConfig->ReadKey( ByteString( aMStr, RTL_TEXTENCODING_UTF8 ) ).ToInt32() );
+ ByteString aStrSizeX( pConfig->ReadKey( ByteString( aSXStr, RTL_TEXTENCODING_UTF8 ) ) );
+ ByteString aStrSizeY( pConfig->ReadKey( ByteString( aSYStr, RTL_TEXTENCODING_UTF8 ) ) );
+
+ aMtfSizeX.SetDefaultUnit( FUNIT_MM );
+ aMtfSizeY.SetDefaultUnit( FUNIT_MM );
+
+ if ( !aStrSizeX.Len() )
+ aMtfSizeX.SetValue( 10000 );
+ else
+ aMtfSizeX.SetValue( aStrSizeX.ToInt32() );
+
+ if ( !aStrSizeY.Len() )
+ aMtfSizeY.SetValue( 10000 );
+ else
+ aMtfSizeY.SetValue( aStrSizeY.ToInt32() );
+
+ switch ( rPara.eFieldUnit )
+ {
+// case FUNIT_NONE :
+// case FUNIT_KM :
+// case FUNIT_PERCENT :
+// case FUNIT_CUSTOM :
+// case FUNIT_MILE :
+// case FUNIT_FOOT :
+// case FUNIT_M :
+ case FUNIT_MM :
+ case FUNIT_CM :
+ case FUNIT_TWIP :
+ case FUNIT_POINT :
+ case FUNIT_PICA :
+ case FUNIT_INCH :
+ case FUNIT_100TH_MM :
+ {
+ aMtfSizeX.SetUnit( rPara.eFieldUnit );
+ aMtfSizeY.SetUnit( rPara.eFieldUnit );
+ }
+ break;
+ }
+
+ if ( nStrMode == 1 )
+ {
+ aRbSize.Check( TRUE );
+ ClickRbSize( NULL );
+ }
+ else
+ {
+ aRbOriginal.Check( TRUE );
+ ClickRbOriginal( NULL );
+ }
+}
+
+/*************************************************************************
+|*
+|* Speichert eingestellte Werte in ini-Datei
+|*
+\**************************************** ********************************/
+
+IMPL_LINK( DlgExportEPCT, OK, void *, EMPTYARG )
+{
+ // Config-Parameter schreiben
+ sal_Int32 nSizeX = (sal_Int32)MetricField::ConvertDoubleValue( aMtfSizeX.GetValue(), 2, aMtfSizeX.GetUnit(), MAP_100TH_MM );
+ sal_Int32 nSizeY = (sal_Int32)MetricField::ConvertDoubleValue( aMtfSizeY.GetValue(), 2, aMtfSizeY.GetUnit(), MAP_100TH_MM );
+ sal_Int32 nStrMode;
+
+ if ( aRbSize.IsChecked() )
+ nStrMode = 1;
+ else
+ nStrMode = 0;
+
+ String aMStr( ResId( KEY_MODE, pMgr ) );
+ String aSXStr( ResId( KEY_SIZEX, pMgr ) );
+ String aSYStr( ResId( KEY_SIZEY, pMgr ) );
+ pConfig->WriteKey( ByteString( aMStr, RTL_TEXTENCODING_UTF8 ), ByteString::CreateFromInt32( nStrMode ) );
+ pConfig->WriteKey( ByteString( aSXStr, RTL_TEXTENCODING_UTF8 ), ByteString::CreateFromInt32( nSizeX ) );
+ pConfig->WriteKey( ByteString( aSYStr, RTL_TEXTENCODING_UTF8 ), ByteString::CreateFromInt32( nSizeY ) );
+
+ EndDialog( RET_OK );
+
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* Enabled/Disabled Controls
+|*
+\************************************************************************/
+
+IMPL_LINK( DlgExportEPCT, ClickRbOriginal, void*, EMPTYARG )
+{
+ aGrpSize.Disable();
+ aFtSizeX.Disable();
+ aMtfSizeX.Disable();
+ aFtSizeY.Disable();
+ aMtfSizeY.Disable();
+
+ return 0;
+}
+
+
+/*************************************************************************
+|*
+|* Enabled/Disabled Controls
+|*
+\************************************************************************/
+
+IMPL_LINK( DlgExportEPCT, ClickRbSize, void*, EMPTYARG )
+{
+ aGrpSize.Enable();
+ aFtSizeX.Enable();
+ aMtfSizeX.Enable();
+ aFtSizeY.Enable();
+ aMtfSizeY.Enable();
+
+ return 0;
+}
+
+
+
diff --git a/goodies/source/filter.vcl/epict/dlgepct.hrc b/goodies/source/filter.vcl/epict/dlgepct.hrc
new file mode 100644
index 000000000000..e424f2b56ec8
--- /dev/null
+++ b/goodies/source/filter.vcl/epict/dlgepct.hrc
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgepct.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <goodies.hrc>
+
+#define BTN_OK 1
+#define BTN_CANCEL 1
+#define BTN_HELP 1
+#define CBX_SIZE 2
+#define MTF_SIZEX 1
+#define MTF_SIZEY 2
+#define FT_SIZEX 1
+#define FT_SIZEY 2
+#define GRP_SIZE 1
+#define GRP_MODE 2
+#define RB_ORIGINAL 1
+#define RB_SIZE 2
+
diff --git a/goodies/source/filter.vcl/epict/dlgepct.hxx b/goodies/source/filter.vcl/epict/dlgepct.hxx
new file mode 100644
index 000000000000..79df32b3aab9
--- /dev/null
+++ b/goodies/source/filter.vcl/epict/dlgepct.hxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgepct.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _DLGEPCT_HXX_
+#define _DLGEPCT_HXX_
+
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/group.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/field.hxx>
+#include <svtools/fltcall.hxx>
+
+/*************************************************************************
+|*
+|* Dialog zum Einstellen von Filteroptionen bei Vektorformaten
+|*
+\************************************************************************/
+
+class Config;
+class ResMgr;
+
+class DlgExportEPCT : public ModalDialog
+{
+private:
+ OKButton aBtnOK;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ RadioButton aRbOriginal;
+ RadioButton aRbSize;
+ GroupBox aGrpMode;
+
+ FixedText aFtSizeX;
+ MetricField aMtfSizeX;
+ FixedText aFtSizeY;
+ MetricField aMtfSizeY;
+ GroupBox aGrpSize;
+
+ Config* pConfig;
+ ResMgr* pMgr;
+
+ DECL_LINK( OK, void* p );
+ DECL_LINK( ClickRbOriginal,void* p );
+ DECL_LINK( ClickRbSize,void* p );
+
+public:
+ DlgExportEPCT( FltCallDialogParameter& rPara );
+};
+
+#endif // _DLGEPCT_HXX_
+
diff --git a/goodies/source/filter.vcl/epict/dlgepct.src b/goodies/source/filter.vcl/epict/dlgepct.src
new file mode 100644
index 000000000000..6a20a7134336
--- /dev/null
+++ b/goodies/source/filter.vcl/epict/dlgepct.src
@@ -0,0 +1,317 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgepct.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "dlgepct.hrc"
+
+ModalDialog DLG_EXPORT_EPCT
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 178 , 98 ) ;
+ Text = "PICT Optionen" ;
+ Text [ ENGLISH ] = "PICT options" ;
+ Text [ english_us ] = "PICT Options" ;
+ Text [ italian ] = "Opzioni PICT" ;
+ Text [ spanish ] = "Opciones PICT" ;
+ Text [ french ] = "Options PICT" ;
+ Text [ dutch ] = "PICT-opties" ;
+ Text [ swedish ] = "PICT alternativ" ;
+ Text [ danish ] = "PICT indstillinger" ;
+ Text [ portuguese_brazilian ] = "PICT Optionen" ;
+ Text [ portuguese ] = "Opções PICT" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ MetricField MTF_SIZEX
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 59 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 100 ;
+ Maximum = 99999 ;
+ StrictFormat = TRUE ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_MM ;
+ First = 100 ;
+ Last = 99999 ;
+ SpinSize = 100 ;
+ };
+ MetricField MTF_SIZEY
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 74 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 100 ;
+ Maximum = 99999 ;
+ StrictFormat = TRUE ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_MM ;
+ First = 100 ;
+ Last = 99999 ;
+ SpinSize = 100 ;
+ };
+ GroupBox GRP_SIZE
+ {
+ Pos = MAP_APPFONT ( 6 , 48 ) ;
+ Size = MAP_APPFONT ( 110 , 44 ) ;
+ Text = "Größe" ;
+ Text [ ENGLISH ] = "Size" ;
+ Text [ english_us ] = "Size" ;
+ Text [ dutch ] = "Grootte" ;
+ Text [ italian ] = "Dimens." ;
+ Text [ spanish ] = "Tamaño" ;
+ Text [ french ] = "Taille" ;
+ Text [ swedish ] = "Storlek" ;
+ Text [ danish ] = "Størrelse" ;
+ Text [ portuguese ] = "Tamanho" ;
+ Text [ portuguese_brazilian ] = "Tamanho" ;
+ Text[ chinese_simplified ] = "´óС";
+ Text[ russian ] = "Ðàçìåð";
+ Text[ polish ] = "Rozmiar";
+ Text[ japanese ] = "»²½Þ";
+ Text[ chinese_traditional ] = "¤j¤p";
+ Text[ arabic ] = "ÇáÍÌã";
+ Text[ dutch ] = "Grootte";
+ Text[ chinese_simplified ] = "´óС";
+ Text[ greek ] = "ÌÝãåèïò";
+ Text[ korean ] = "Å©±â";
+ Text[ turkish ] = "Boyut";
+ Text[ language_user1 ] = " ";
+ };
+ FixedText FT_SIZEX
+ {
+ Pos = MAP_APPFONT ( 12 , 59 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text = "Breite" ;
+ Text [ ENGLISH ] = "Width" ;
+ Text [ dutch ] = "Breedte" ;
+ Text [ english_us ] = "Width" ;
+ Text [ italian ] = "Larghezza" ;
+ Text [ spanish ] = "Ancho" ;
+ Text [ french ] = "Largeur" ;
+ Text [ swedish ] = "Bredd" ;
+ Text [ danish ] = "Bredde" ;
+ Text [ portuguese ] = "Largura" ;
+ Text [ portuguese_brazilian ] = "Largura" ;
+ Text[ chinese_simplified ] = "¿í¶È";
+ Text[ russian ] = "Øèðèíà";
+ Text[ polish ] = "Szer.";
+ Text[ japanese ] = "•";
+ Text[ chinese_traditional ] = "¼e«×";
+ Text[ arabic ] = "ÇáÚÑÖ";
+ Text[ dutch ] = "Breedte";
+ Text[ chinese_simplified ] = "¿í¶È";
+ Text[ greek ] = "ÐëÜôïò";
+ Text[ korean ] = "³Êºñ";
+ Text[ turkish ] = "Geniþlik";
+ Text[ language_user1 ] = " ";
+ };
+ FixedText FT_SIZEY
+ {
+ Pos = MAP_APPFONT ( 12 , 74 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text = "Höhe" ;
+ Text [ ENGLISH ] = "Height" ;
+ Text [ english_us ] = "Height" ;
+ Text [ italian ] = "Altezza" ;
+ Text [ spanish ] = "Altura" ;
+ Text [ french ] = "Hauteur" ;
+ Text [ dutch ] = "Hoogte" ;
+ Text [ swedish ] = "Höjd" ;
+ Text [ danish ] = "Højde" ;
+ Text [ portuguese_brazilian ] = "Højde" ;
+ Text [ portuguese ] = "Altura" ;
+ Text[ chinese_simplified ] = "¸ß¶È";
+ Text[ russian ] = "Âûñîòà";
+ Text[ polish ] = "Wys.";
+ Text[ japanese ] = "‚‚³";
+ Text[ chinese_traditional ] = "°ª«×";
+ Text[ arabic ] = "ÇáÇÑÊÝÇÚ";
+ Text[ dutch ] = "Hoogte";
+ Text[ chinese_simplified ] = "¸ß¶È";
+ Text[ greek ] = "¾øïò";
+ Text[ korean ] = "³ôÀÌ";
+ Text[ turkish ] = "Yükseklik";
+ Text[ language_user1 ] = " ";
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 122 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 122 , 24 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 122 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ RadioButton RB_ORIGINAL
+ {
+ Pos = MAP_APPFONT ( 12 , 12 ) ;
+ Size = MAP_APPFONT ( 98 , 12 ) ;
+ TabStop = TRUE ;
+ Text = "~Original" ;
+ Text [ ENGLISH ] = "~Original" ;
+ Text [ dutch ] = "~Origineel" ;
+ Text [ english_us ] = "~Original" ;
+ Text [ italian ] = "~Originale" ;
+ Text [ spanish ] = "~Original" ;
+ Text [ french ] = "~Original" ;
+ Text [ swedish ] = "~Original" ;
+ Text [ danish ] = "~Original" ;
+ Text [ portuguese_brazilian ] = "~Original" ;
+ Text [ portuguese ] = "~Original" ;
+ Text[ chinese_simplified ] = "Ô­¼þ(~O)";
+ Text[ russian ] = "Îðèãèíàë";
+ Text[ polish ] = "Orygina³";
+ Text[ japanese ] = "µØ¼ÞÅÙ(~O)";
+ Text[ chinese_traditional ] = "­ì¥ó(~O)";
+ Text[ arabic ] = "ÇáÃÕá";
+ Text[ dutch ] = "~Origineel";
+ Text[ chinese_simplified ] = "Ô­¼þ(~O)";
+ Text[ greek ] = "Áñ÷éêü";
+ Text[ korean ] = "¿À¸®Áö³Î(~O)";
+ Text[ turkish ] = "Aslý";
+ Text[ language_user1 ] = " ";
+ };
+ RadioButton RB_SIZE
+ {
+ Pos = MAP_APPFONT ( 12 , 27 ) ;
+ Size = MAP_APPFONT ( 98 , 12 ) ;
+ TabStop = TRUE ;
+ Text = "~Größe" ;
+ Text [ ENGLISH ] = "~Size" ;
+ Text [ dutch ] = "~Grootte" ;
+ Text [ english_us ] = "~Size" ;
+ Text [ italian ] = "~Dimens." ;
+ Text [ spanish ] = "~Tamaño" ;
+ Text [ french ] = "~Taille" ;
+ Text [ swedish ] = "~Storlek" ;
+ Text [ danish ] = "~Størrelse" ;
+ Text [ portuguese ] = "~Tamanho" ;
+ Text [ portuguese_brazilian ] = "~Tamanho" ;
+ Text[ chinese_simplified ] = "´óС(~S)";
+ Text[ russian ] = "Ðàçìåð";
+ Text[ polish ] = "Rozmiar";
+ Text[ japanese ] = "»²½Þ(~S)";
+ Text[ chinese_traditional ] = "¤j¤p(~S)";
+ Text[ arabic ] = "ÇáÍÌã";
+ Text[ dutch ] = "~Grootte";
+ Text[ chinese_simplified ] = "´óС(~S)";
+ Text[ greek ] = "ÌÝãåèïò";
+ Text[ korean ] = "Å©±â(~S)";
+ Text[ turkish ] = "Boyut";
+ Text[ language_user1 ] = " ";
+ };
+ GroupBox GRP_MODE
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 110 , 42 ) ;
+ Text = "Modus" ;
+ Text [ ENGLISH ] = "Mode" ;
+ Text [ dutch ] = "Modus" ;
+ Text [ english_us ] = "Mode" ;
+ Text [ italian ] = "Modo" ;
+ Text [ spanish ] = "Modo" ;
+ Text [ french ] = "Mode" ;
+ Text [ swedish ] = "Läge" ;
+ Text [ danish ] = "Modus" ;
+ Text [ portuguese_brazilian ] = "Modus" ;
+ Text [ portuguese ] = "Modo" ;
+ Text[ chinese_simplified ] = "ģʽ";
+ Text[ russian ] = "Ðåæèì";
+ Text[ polish ] = "Tryb";
+ Text[ japanese ] = "Ó°ÄÞ";
+ Text[ chinese_traditional ] = "¼Ò¦¡";
+ Text[ arabic ] = "ÇáæÖÚ";
+ Text[ dutch ] = "Modus";
+ Text[ chinese_simplified ] = "ģʽ";
+ Text[ greek ] = "ÊáôÜóôáóç";
+ Text[ korean ] = "¸ðµå";
+ Text[ turkish ] = "Kip";
+ Text[ language_user1 ] = " ";
+ };
+ Text[ chinese_simplified ] = "PICT Ñ¡Ïî";
+ Text[ russian ] = "Ïàðàìåòðû PICT";
+ Text[ polish ] = "Opcje PICT";
+ Text[ japanese ] = "PICT µÌß¼®Ý";
+ Text[ chinese_traditional ] = "PICT¿ï¶µ";
+ Text[ arabic ] = "PICT ÎíÇÑÇÊ";
+ Text[ dutch ] = "PICT-opties";
+ Text[ chinese_simplified ] = "PICT Ñ¡Ïî";
+ Text[ greek ] = "ÅðéëïãÝò PICT";
+ Text[ korean ] = "PICT ¿É¼Ç";
+ Text[ turkish ] = "PICT seçenekleri";
+ Text[ language_user1 ] = " ";
+};
diff --git a/goodies/source/filter.vcl/epict/epict.cxx b/goodies/source/filter.vcl/epict/epict.cxx
new file mode 100644
index 000000000000..7e424939c8cd
--- /dev/null
+++ b/goodies/source/filter.vcl/epict/epict.cxx
@@ -0,0 +1,2313 @@
+/*************************************************************************
+ *
+ * $RCSfile: epict.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#if SUPD <= 364
+#include <svtfilt.hxx>
+#include <solar.hrc>
+#include <fltcall.hxx>
+#else
+#include <vcl/metaact.hxx>
+#include <svtools/filter.hxx>
+#include <svtools/solar.hrc>
+#include <svtools/fltcall.hxx>
+#endif
+
+#include <math.h>
+#include <vcl/bmpacc.hxx>
+#include <vcl/metaact.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/gradient.hxx>
+#include <vcl/hatch.hxx>
+#include <vcl/metric.hxx>
+#include <vcl/font.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <tools/bigint.hxx>
+#include "strings.hrc"
+#include "dlgepct.hrc"
+#include "dlgepct.hxx"
+
+//============================== PictWriter ===================================
+
+struct PictWriterAttrStackMember {
+ struct PictWriterAttrStackMember * pSucc;
+ Color aLineColor;
+ Color aFillColor;
+ RasterOp eRasterOp;
+ Font aFont;
+ MapMode aMapMode;
+};
+
+
+enum PictDrawingMethod {
+ PDM_FRAME, PDM_PAINT, PDM_ERASE, PDM_INVERT, PDM_FILL
+};
+
+
+struct PictPattern {
+ ULONG nLo, nHi;
+};
+
+
+class PictWriter {
+
+private:
+
+ BOOL bStatus;
+
+ PFilterCallback pCallback;
+ void * pCallerData;
+ ULONG nLastPercent; // Mit welcher Zahl pCallback zuletzt aufgerufen wurde.
+
+ SvStream * pPict;
+
+ // Aktuelle Attribute im Quell-Metafile:
+ Color aLineColor;
+ Color aFillColor;
+ RasterOp eSrcRasterOp;
+ Font aSrcFont;
+ MapMode aSrcMapMode;
+ MapMode aTargetMapMode;
+ PictWriterAttrStackMember * pAttrStack;
+
+ // Aktuelle Attribute im Ziel-Metafile, und ob sie gueltig sind
+ BOOL bDstBkPatVisible; BOOL bDstBkPatValid;
+ BYTE nDstTxFace; BOOL bDstTxFaceValid;
+ RasterOp eDstTxMode; BOOL bDstTxModeValid;
+ USHORT nDstPnSize; BOOL bDstPnSizeValid;
+ RasterOp eDstPnMode; BOOL bDstPnModeValid;
+ PictPattern aDstPnPat; BOOL bDstPnPatValid;
+ BOOL bDstFillPatVisible; BOOL bDstFillPatValid;
+ USHORT nDstTxSize; BOOL bDstTxSizeValid;
+ Color aDstFgCol; BOOL bDstFgColValid;
+ Color aDstBkCol; BOOL bDstBkColValid;
+ Point aDstPenPosition; BOOL bDstPenPositionValid;
+ Point aDstTextPosition; BOOL bDstTextPositionValid;
+ String aDstFontName; USHORT nDstFontNameId; BOOL bDstFontNameValid;
+
+ ULONG nNumberOfActions; // Anzahl der Actions im GDIMetafile
+ ULONG nNumberOfBitmaps; // Anzahl der Bitmaps
+ ULONG nWrittenActions; // Anzahl der bereits verarbeiteten Actions beim Schreiben der Opcodes
+ ULONG nWrittenBitmaps; // Anzahl der bereits geschriebenen Bitmaps
+ ULONG nActBitmapPercent; // Wieviel Prozent die naechste Bitmap schon geschrieben ist.
+
+ void MayCallback();
+ // Berechnet anhand der obigen 5 Parameter eine Prozentzahl
+ // und macht dann ggf. einen Callback. Setzt bStatus auf FALSE wenn User abbrechen
+ // moechte.
+
+ void CountActionsAndBitmaps(const GDIMetaFile & rMTF);
+ // Zaehlt die Bitmaps und Actions (nNumberOfActions und nNumberOfBitmaps muessen
+ // zu Anfang auf 0 gesetzt werden, weil diese Methode rekursiv ist)
+
+ Polygon PolyPolygonToPolygon(const PolyPolygon & rPoly);
+ // Macht aus einem PolyPolygon ein halbwegs vernuenftiges Polygon
+
+ void WritePoint(const Point & rPoint);
+ void WriteSize(const Size & rSize);
+ void WriteRGBColor(const Color & rColor);
+ void WriteString( const ByteString & rString );
+ void WriteRectangle(const Rectangle & rRect);
+ void WritePolygon(const Polygon & rPoly);
+ void WriteArcAngles(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt);
+
+ void ConvertLinePattern(PictPattern & rPat, BOOL bVisible);
+ void ConvertFillPattern(PictPattern & rPat, BOOL bVisible);
+
+ void WriteOpcode_BkPat(BOOL bVisible);
+ void WriteOpcode_TxFace(const Font & rFont);
+ void WriteOpcode_TxMode(RasterOp eMode);
+ void WriteOpcode_PnSize(USHORT nSize);
+ void WriteOpcode_PnMode(RasterOp eMode);
+ void WriteOpcode_PnLinePat(BOOL bVisible);
+ void WriteOpcode_PnFillPat(BOOL bVisible);
+ void WriteOpcode_FillPat(BOOL bVisible);
+ void WriteOpcode_OvSize(const Size & rSize);
+ void WriteOpcode_TxSize(USHORT nSize);
+ void WriteOpcode_RGBFgCol(const Color & rColor);
+ void WriteOpcode_RGBBkCol(const Color & rColor);
+ void WriteOpcode_Line(const Point & rLocPt, const Point & rNewPt);
+ void WriteOpcode_LineFrom(const Point & rNewPt);
+ void WriteOpcode_Text(const Point & rPoint, const ByteString& rString, BOOL bDelta);
+ void WriteOpcode_FontName(const Font & rFont);
+ void WriteOpcode_Rect(PictDrawingMethod eMethod, const Rectangle & rRect);
+ void WriteOpcode_SameRect(PictDrawingMethod eMethod);
+ void WriteOpcode_RRect(PictDrawingMethod eMethod, const Rectangle & rRect);
+ void WriteOpcode_SameRRect(PictDrawingMethod eMethod);
+ void WriteOpcode_Oval(PictDrawingMethod eMethod, const Rectangle & rRect);
+ void WriteOpcode_SameOval(PictDrawingMethod eMethod);
+ void WriteOpcode_Arc(PictDrawingMethod eMethod, const Rectangle & rRect,
+ const Point & rStartPt, const Point & rEndPt);
+ void WriteOpcode_SameArc(PictDrawingMethod eMethod, const Rectangle & rRect,
+ const Point & rStartPt, const Point & rEndPt);
+ void WriteOpcode_Poly(PictDrawingMethod eMethod, const Polygon & rPoly);
+ void WriteOpcode_BitsRect(const Point & rPoint, const Size & rSize, const Bitmap & rBitmap);
+ void WriteOpcode_EndOfFile();
+
+ void SetAttrForPaint();
+ void SetAttrForFrame();
+ void SetAttrForText();
+
+ void WriteTextArray(Point & rPoint, const ByteString& rString, const long * pDXAry);
+
+ void WriteOpcodes(const GDIMetaFile & rMTF);
+
+ void WriteHeader(const GDIMetaFile & rMTF);
+ void UpdateHeader();
+
+public:
+
+ BOOL WritePict(const GDIMetaFile & rMTF, SvStream & rTargetStream,
+ PFilterCallback pcallback, void * pcallerdata);
+};
+
+
+//========================== Methoden von PictWriter ==========================
+
+
+void PictWriter::MayCallback()
+{
+ ULONG nPercent;
+
+ // Wir gehen mal einfach so davon aus, dass 16386 Actions einer Bitmap entsprechen
+ // (in der Regel wird ein Metafile entweder nur Actions oder einige Bitmaps und fast
+ // keine Actions enthalten. Dann ist das Verhaeltnis ziemlich unwichtig)
+
+ nPercent=((nWrittenBitmaps<<14)+(nActBitmapPercent<<14)/100+nWrittenActions)
+ *100
+ /((nNumberOfBitmaps<<14)+nNumberOfActions);
+
+ if (nPercent>=nLastPercent+3) {
+ nLastPercent=nPercent;
+ if(pCallback!=NULL && nPercent<=100) {
+ if (((*pCallback)(pCallerData,(USHORT)nPercent))==TRUE) bStatus=FALSE;
+ }
+ }
+}
+
+
+void PictWriter::CountActionsAndBitmaps(const GDIMetaFile & rMTF)
+{
+ ULONG nAction, nActionCount;
+ const MetaAction* pMA;
+
+ nActionCount = rMTF.GetActionCount();
+
+ for (nAction=0; nAction<nActionCount; nAction++)
+ {
+ pMA = rMTF.GetAction( nAction );
+
+ switch( pMA->GetType() )
+ {
+ case META_BMP_ACTION:
+ case META_BMPSCALE_ACTION:
+ case META_BMPSCALEPART_ACTION:
+ case META_BMPEX_ACTION:
+ case META_BMPEXSCALE_ACTION:
+ case META_BMPEXSCALEPART_ACTION:
+ nNumberOfBitmaps++;
+ break;
+ }
+
+ nNumberOfActions++;
+ }
+}
+
+
+Polygon PictWriter::PolyPolygonToPolygon(const PolyPolygon & rPolyPoly)
+{
+ USHORT nCount,nSize1,nSize2,np,i1,i2,i3,nBestIdx1,nBestIdx2;
+ long nDistSqr,nBestDistSqr, nCountdownTests;
+ Point aP1,aPRel;
+ Polygon aPoly1, aPoly2, aPoly3;
+
+ nCount=rPolyPoly.Count();
+ if (nCount==0) return Polygon(0);
+
+ aPoly1=rPolyPoly.GetObject(0);
+ for (np=1; np<nCount; np++) {
+ aPoly2=rPolyPoly.GetObject(np);
+
+ //-----------------Folgendes verschmilzt aPoly1 und aPoly2 zu aPoly1-----------------
+
+ nSize1=aPoly1.GetSize();
+ nSize2=aPoly2.GetSize();
+
+ // Zunaechst werden ein Punkt in aPoly1 (referenziert durch nBestIdx1) und ein
+ // Punkt in aPoly2 (referenziert durch nBestIdx2) gesucht, die moeglichst dicht
+ // beieinander liegen. Da dies mit quadratischem Aufwand einher geht, und somit
+ // manche Bilder Ewigkeiten benoetigen, um exportiert zu werden, begrenzen wir
+ // die Anzahl der Tests auf 1000, und brechen die Suche ggf. schon vorher ab.
+ // Dadruch wird das Ergebnis nicht falsch, sondern eventuell nicht so schoen.
+ nCountdownTests=1000;
+ nBestDistSqr=0x7fffffff;
+ nBestIdx1=0;
+ nBestIdx2=0;
+ for (i1=0; i1<nSize1; i1++) {
+ aP1=aPoly1.GetPoint(i1);
+ for (i2=0; i2<nSize2; i2++) {
+ aPRel=aPoly2.GetPoint(i2); aPRel-=aP1;
+ nDistSqr=aPRel.X()*aPRel.X()+aPRel.Y()*aPRel.Y();
+ if (nDistSqr<nBestDistSqr) {
+ nBestIdx1=i1;
+ nBestIdx2=i2;
+ nBestDistSqr=nDistSqr;
+ }
+ if (nCountdownTests<=0) break;
+ nCountdownTests--;
+ }
+ if (nCountdownTests<=0) break;
+ }
+
+ // Nun werden aPoly1 und aPoly2 zu einem Polygon aPoly3 (spaeter aPoly1) zusammengefuegt.
+ // Die beiden Polygone werden verbunden durch zwei zusaetzliche Kanten zwischen den oben
+ // gefundenen Punkten.
+ aPoly3.Clear();
+ aPoly3.SetSize(nSize1+nSize2+2);
+ i3=0;
+ for (i1=nBestIdx1; i1<nSize1; i1++) aPoly3.SetPoint(aPoly1.GetPoint(i1),i3++);
+ for (i1=0; i1<=nBestIdx1; i1++) aPoly3.SetPoint(aPoly1.GetPoint(i1),i3++);
+ for (i2=nBestIdx2; i2<nSize2; i2++) aPoly3.SetPoint(aPoly2.GetPoint(i2),i3++);
+ for (i2=0; i2<=nBestIdx2; i2++) aPoly3.SetPoint(aPoly2.GetPoint(i2),i3++);
+
+ aPoly1=aPoly3;
+
+ //-----------------------------------------------------------------------------------
+
+ }
+ return aPoly1;
+}
+
+
+void PictWriter::WritePoint(const Point & rPoint)
+{
+ Point aPoint = OutputDevice::LogicToLogic( rPoint, aSrcMapMode, aTargetMapMode );
+ *pPict << ((short)aPoint.Y()) << ((short)aPoint.X());
+}
+
+
+void PictWriter::WriteSize(const Size & rSize)
+{
+ Size aSize = OutputDevice::LogicToLogic( rSize, aSrcMapMode, aTargetMapMode );
+ *pPict << ((short)rSize.Height()) << ((short)rSize.Width());
+}
+
+
+void PictWriter::WriteRGBColor(const Color & rColor)
+{
+ const UINT16 nR = ( (UINT16) rColor.GetRed() << 8 ) | (UINT16) rColor.GetRed();
+ const UINT16 nG = ( (UINT16) rColor.GetGreen() << 8 ) | (UINT16) rColor.GetGreen();
+ const UINT16 nB = ( (UINT16) rColor.GetBlue() << 8 ) | (UINT16) rColor.GetBlue();
+
+ *pPict << nR << nG << nB;
+}
+
+
+void PictWriter::WriteString( const ByteString & rString )
+{
+ USHORT i,nLen;
+
+ nLen = rString.Len();
+ if ( nLen > 255 )
+ nLen = 255;
+ *pPict << ( (BYTE)nLen );
+ for ( i = 0; i < nLen; i++ )
+ *pPict << rString.GetChar( i );
+}
+
+
+void PictWriter::WriteRectangle(const Rectangle & rRect)
+{
+ Point aPoint = OutputDevice::LogicToLogic( rRect.TopLeft(),
+ aSrcMapMode,
+ aTargetMapMode );
+ Size aSize = OutputDevice::LogicToLogic( rRect.GetSize(),
+ aSrcMapMode,
+ aTargetMapMode );
+ Rectangle aRect( aPoint, aSize );
+
+
+ short x1,y1,x2,y2,t;
+
+ x1=(short) aRect.Left();
+ y1=(short) aRect.Top();
+ x2=(short) aRect.Right();
+ y2=(short) aRect.Bottom();
+ if (x1>x2) { t=x1; x1=x2; x2=t; }
+ if (y1>y2) { t=y1; y1=y2; y2=t; }
+ x2++;
+ y2++;
+ *pPict << y1 << x1 << y2 << x2;
+}
+
+
+void PictWriter::WritePolygon(const Polygon & rPoly)
+{
+ USHORT nDataSize,i,nSize;
+ short nMinX,nMinY,nMaxX,nMaxY,nx,ny;
+ Polygon aPoly(rPoly);
+
+ nSize=aPoly.GetSize();
+
+ if (aPoly.GetPoint(0) != aPoly.GetPoint(nSize-1))
+ {
+ nSize++;
+ aPoly.SetSize(nSize);
+ aPoly.SetPoint(aPoly.GetPoint(0),nSize-1);
+ }
+
+ nDataSize=nSize*4+10;
+ for (i=0; i<nSize; i++)
+ {
+ Point aPoint = OutputDevice::LogicToLogic( aPoly.GetPoint( i ),
+ aSrcMapMode,
+ aTargetMapMode );
+
+ nx = (short) aPoint.X();
+ ny = (short) aPoint.Y();
+
+ if ( i==0 || nMinX>nx )
+ nMinX=nx;
+ if ( i==0 || nMinY>ny )
+ nMinY=ny;
+ if ( i==0 || nMaxX<nx )
+ nMaxX=nx;
+ if ( i==0 || nMaxY<ny )
+ nMaxY=ny;
+ }
+
+ *pPict << nDataSize << nMinY << nMinX << nMaxY << nMaxX;
+
+ for (i=0; i<nSize; i++)
+ WritePoint( aPoly.GetPoint(i) );
+}
+
+
+void PictWriter::WriteArcAngles(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt)
+{
+ Point aStartPt = OutputDevice::LogicToLogic( rStartPt,
+ aSrcMapMode,
+ aTargetMapMode );
+ Point aEndPt = OutputDevice::LogicToLogic( rEndPt,
+ aSrcMapMode,
+ aTargetMapMode );
+ Rectangle aRect( OutputDevice::LogicToLogic( rRect.TopLeft(),
+ aSrcMapMode,
+ aTargetMapMode ),
+ OutputDevice::LogicToLogic( rRect.GetSize(),
+ aSrcMapMode,
+ aTargetMapMode ) );
+ Point aCenter;
+ double fAngS, fAngE, fdx, fdy;
+ short nStartAngle, nArcAngle;
+
+
+ aCenter=Point( ( aRect.Left() + aRect.Right() ) >> 1,
+ ( aRect.Top() + aRect.Bottom() ) >> 1 );
+
+ fdx=(double)(aStartPt.X()-aCenter.X());
+ fdy=(double)(aStartPt.Y()-aCenter.Y());
+ if ( fdx==0.0 && fdy==0.0 )
+ fdx=1.0;
+ fAngE=atan2(fdx,-fdy);
+
+ fdx=(double)(aEndPt.X()-aCenter.X());
+ fdy=(double)(aEndPt.Y()-aCenter.Y());
+ if ( fdx==0.0 && fdy==0.0 )
+ fdx=1.0;
+ fAngS=atan2(fdx,-fdy);
+
+ nStartAngle=(short)(fAngS*180.0/3.14159265359);
+ nArcAngle=((short)(fAngE*180.0/3.14159265359))-nStartAngle;
+ if (nArcAngle<0)
+ nArcAngle += 360;
+ *pPict << nStartAngle << nArcAngle;
+}
+
+
+void PictWriter::ConvertLinePattern(PictPattern & rPat, BOOL bVisible)
+{
+ if( bVisible )
+ {
+ rPat.nHi=0xffffffff;
+ rPat.nLo=0xffffffff;
+ }
+ else
+ {
+ rPat.nHi=0x00000000;
+ rPat.nLo=0x00000000;
+ }
+}
+
+void PictWriter::ConvertFillPattern(PictPattern & rPat, BOOL bVisible)
+{
+ if( bVisible )
+ {
+ rPat.nHi=0xffffffff;
+ rPat.nLo=0xffffffff;
+ }
+ else
+ {
+ rPat.nHi=0x00000000;
+ rPat.nLo=0x00000000;
+ }
+}
+
+
+void PictWriter::WriteOpcode_BkPat(BOOL bVisible)
+{
+ if (bDstBkPatValid==FALSE || bDstBkPatVisible!=bVisible) {
+ PictPattern aPat;
+ ConvertFillPattern(aPat,bVisible);
+ *pPict << (USHORT)0x0002 << aPat.nHi << aPat.nLo;
+ bDstBkPatVisible=bVisible;
+ bDstBkPatValid=TRUE;
+ }
+}
+
+
+void PictWriter::WriteOpcode_TxFace(const Font & rFont)
+{
+ BYTE nFace;
+ FontWeight eWeight;
+
+ nFace=0;
+ eWeight=rFont.GetWeight();
+ if (eWeight==WEIGHT_BOLD ||
+ eWeight==WEIGHT_SEMIBOLD ||
+ eWeight==WEIGHT_ULTRABOLD ||
+ eWeight==WEIGHT_BLACK) nFace|=0x01;
+ if (rFont.GetItalic()!=ITALIC_NONE) nFace|=0x02;
+ if (rFont.GetUnderline()!=UNDERLINE_NONE) nFace|=0x04;
+ if (rFont.IsOutline()==TRUE) nFace|=0x08;
+ if (rFont.IsShadow()==TRUE) nFace|=0x10;
+
+ if (bDstTxFaceValid==FALSE || nDstTxFace!=nFace) {
+ *pPict << (USHORT)0x0004 << nFace << (BYTE)0;
+ nDstTxFace=nFace;
+ bDstTxFaceValid=TRUE;
+ }
+}
+
+
+void PictWriter::WriteOpcode_TxMode(RasterOp eMode)
+{
+ USHORT nVal;
+
+ if (bDstTxModeValid==FALSE || eDstTxMode!=eMode) {
+ switch (eMode) {
+ case ROP_INVERT: nVal=0x000c; break;
+ case ROP_XOR: nVal=0x000a; break;
+ default: nVal=0x0008;
+ }
+ *pPict << (USHORT)0x0005 << nVal;
+ eDstTxMode=eMode;
+ bDstTxModeValid=TRUE;
+ }
+}
+
+
+void PictWriter::WriteOpcode_PnSize(USHORT nSize)
+{
+ if (nSize==0) nSize=1;
+ if (bDstPnSizeValid==FALSE || nDstPnSize!=nSize) {
+ *pPict << (USHORT)0x0007 << nSize << nSize;
+ nDstPnSize=nSize;
+ bDstPnSizeValid=TRUE;
+ }
+}
+
+
+void PictWriter::WriteOpcode_PnMode(RasterOp eMode)
+{
+ USHORT nVal;
+
+ if (bDstPnModeValid==FALSE || eDstPnMode!=eMode) {
+ switch (eMode)
+ {
+ case ROP_INVERT: nVal=0x000c; break;
+ case ROP_XOR: nVal=0x000a; break;
+ default: nVal=0x0008;
+ }
+ *pPict << (USHORT)0x0008 << nVal;
+ eDstPnMode=eMode;
+ bDstPnModeValid=TRUE;
+ }
+}
+
+
+void PictWriter::WriteOpcode_PnLinePat(BOOL bVisible)
+{
+ PictPattern aPat;
+
+ ConvertLinePattern(aPat,bVisible);
+ if (bDstPnPatValid==FALSE || aDstPnPat.nHi!=aPat.nHi || aDstPnPat.nLo!=aPat.nLo) {
+ *pPict << (USHORT)0x0009 << aPat.nHi << aPat.nLo;
+ aDstPnPat=aPat;
+ bDstPnPatValid=TRUE;
+ }
+}
+
+
+void PictWriter::WriteOpcode_PnFillPat(BOOL bVisible)
+{
+ PictPattern aPat;
+
+ ConvertFillPattern(aPat,bVisible);
+ if (bDstPnPatValid==FALSE || aDstPnPat.nHi!=aPat.nHi || aDstPnPat.nLo!=aPat.nLo) {
+ *pPict << (USHORT)0x0009 << aPat.nHi << aPat.nLo;
+ aDstPnPat=aPat;
+ bDstPnPatValid=TRUE;
+ }
+}
+
+
+void PictWriter::WriteOpcode_FillPat(BOOL bVisible)
+{
+ if (bDstFillPatValid==FALSE || bDstFillPatVisible!=bVisible) {
+ PictPattern aPat;
+ ConvertFillPattern(aPat,bVisible);
+ *pPict << (USHORT)0x000a << aPat.nHi << aPat.nLo;
+ bDstFillPatVisible=bVisible;
+ bDstFillPatValid=TRUE;
+ }
+}
+
+
+void PictWriter::WriteOpcode_OvSize(const Size & rSize)
+{
+ *pPict << (USHORT)0x000b;
+ WriteSize(rSize);
+}
+
+
+void PictWriter::WriteOpcode_TxSize(USHORT nSize)
+{
+ if (bDstTxSizeValid==FALSE || nDstTxSize!=nSize) {
+
+ nDstTxSize = (USHORT) OutputDevice::LogicToLogic( Size( 0, nSize ),
+ aSrcMapMode, aTargetMapMode ).Height();
+
+ *pPict << (USHORT)0x000d << nDstTxSize;
+ bDstTxSizeValid=TRUE;
+ }
+}
+
+
+void PictWriter::WriteOpcode_RGBFgCol(const Color & rColor)
+{
+ if (bDstFgColValid==FALSE || aDstFgCol!=rColor) {
+ *pPict << (USHORT)0x001a;
+ WriteRGBColor(rColor);
+ aDstFgCol=rColor;
+ bDstFgColValid=TRUE;
+ }
+}
+
+
+void PictWriter::WriteOpcode_RGBBkCol(const Color & rColor)
+{
+ if (bDstBkColValid==FALSE || aDstBkCol!=rColor) {
+ *pPict << (USHORT)0x001b;
+ WriteRGBColor(rColor);
+ aDstBkCol=rColor;
+ bDstBkColValid=TRUE;
+ }
+}
+
+
+void PictWriter::WriteOpcode_Line(const Point & rLocPt, const Point & rNewPt)
+{
+ Point aLocPt = OutputDevice::LogicToLogic( rLocPt,
+ aSrcMapMode,
+ aTargetMapMode );
+ Point aNewPt = OutputDevice::LogicToLogic( rNewPt,
+ aSrcMapMode,
+ aTargetMapMode );
+ long dh,dv;
+
+ dh=aNewPt.X()-aLocPt.X();
+ dv=aNewPt.Y()-aLocPt.Y();
+ if (dh<=127 && dh>=-128 && dv<=127 && dv>=-128)
+ { // ShortLine
+ *pPict << (USHORT)0x0022;
+ WritePoint(rLocPt);
+ *pPict << (char)dh << (char)dv;
+ }
+ else
+ {
+ *pPict << (USHORT)0x0020;
+ WritePoint(rLocPt);
+ WritePoint(rNewPt);
+ }
+ aDstPenPosition=rNewPt;
+ bDstPenPositionValid=TRUE;
+}
+
+
+void PictWriter::WriteOpcode_LineFrom(const Point & rNewPt)
+{
+ Point aNewPt = OutputDevice::LogicToLogic( rNewPt,
+ aSrcMapMode,
+ aTargetMapMode );
+ long dh,dv;
+
+ dh = aNewPt.X()-aDstPenPosition.X();
+ dv = aNewPt.Y()-aDstPenPosition.Y();
+
+ if (dh<=127 && dh>=-128 && dv<=127 && dv>=-128)
+ { // ShortLine
+ *pPict << (USHORT)0x0023;
+ *pPict << (char)dh << (char)dv;
+ }
+ else
+ {
+ *pPict << (USHORT)0x0021;
+ WritePoint(rNewPt);
+ }
+ aDstPenPosition=rNewPt;
+ bDstPenPositionValid=TRUE;
+}
+
+
+void PictWriter::WriteOpcode_Text(const Point & rPoint, const ByteString& rString, BOOL bDelta)
+{
+ Point aPoint = OutputDevice::LogicToLogic( rPoint,
+ aSrcMapMode,
+ aTargetMapMode );
+ long dh,dv;
+ ULONG nPos;
+
+ nPos = pPict->Tell();
+ dh = aPoint.X()-aDstTextPosition.X();
+ dv = aPoint.Y()-aDstTextPosition.Y();
+
+ if (bDstTextPositionValid==FALSE || dh<0 || dh>255 || dv<0 || dv>0 || bDelta==FALSE)
+ {
+ *pPict << (USHORT)0x0028;
+ WritePoint(rPoint);
+ }
+ else if (dv==0)
+ {
+ *pPict << (USHORT)0x0029 << (BYTE)dh;
+ }
+ else if (dh==0)
+ {
+ *pPict << (USHORT)0x002a << (BYTE)dv;
+ }
+ else
+ {
+ *pPict << (USHORT)0x002b << (BYTE)dh << (BYTE)dv;
+ }
+
+ WriteString( rString );
+ if (((pPict->Tell()-nPos)&1)!=0)
+ *pPict << (BYTE)0;
+
+ aDstTextPosition = aPoint;
+ bDstTextPositionValid=TRUE;
+}
+
+
+void PictWriter::WriteOpcode_FontName(const Font & rFont)
+{
+ USHORT nDataLen,nFontId;
+
+ switch (rFont.GetFamily()) {
+ case FAMILY_MODERN: nFontId=22; break;
+ case FAMILY_ROMAN: nFontId=20; break;
+ case FAMILY_SWISS: nFontId=21; break;
+ default: nFontId=1;
+ }
+
+ if (bDstFontNameValid==FALSE || nDstFontNameId!=nFontId || aDstFontName!=rFont.GetName()) {
+ if (rFont.GetName().Len()>0) {
+ nDataLen=3+rFont.GetName().Len();
+ *pPict << (USHORT)0x002c << nDataLen << nFontId;
+ WriteString( ByteString( rFont.GetName(), RTL_TEXTENCODING_UTF8 ) );
+ if ( ( ( rFont.GetName().Len() ) & 1 ) == 0 )
+ *pPict << (BYTE)0;
+ }
+ *pPict << (USHORT)0x0003 << nFontId;
+ aDstFontName=rFont.GetName();
+ nDstFontNameId=nFontId;
+ bDstFontNameValid=TRUE;
+ }
+}
+
+
+void PictWriter::WriteOpcode_Rect(PictDrawingMethod eMethod, const Rectangle & rRect)
+{
+ USHORT oc;
+ switch (eMethod) {
+ case PDM_FRAME: oc=0x0030; break;
+ case PDM_PAINT: oc=0x0031; break;
+ case PDM_ERASE: oc=0x0032; break;
+ case PDM_INVERT: oc=0x0033; break;
+ case PDM_FILL: oc=0x0034; break;
+ }
+ *pPict << oc;
+ WriteRectangle(rRect);
+}
+
+
+void PictWriter::WriteOpcode_SameRect(PictDrawingMethod eMethod)
+{
+ USHORT oc;
+ switch (eMethod) {
+ case PDM_FRAME: oc=0x0038; break;
+ case PDM_PAINT: oc=0x0039; break;
+ case PDM_ERASE: oc=0x003a; break;
+ case PDM_INVERT: oc=0x003b; break;
+ case PDM_FILL: oc=0x003c; break;
+ }
+ *pPict << oc;
+}
+
+
+void PictWriter::WriteOpcode_RRect(PictDrawingMethod eMethod, const Rectangle & rRect)
+{
+ USHORT oc;
+ switch (eMethod) {
+ case PDM_FRAME: oc=0x0040; break;
+ case PDM_PAINT: oc=0x0041; break;
+ case PDM_ERASE: oc=0x0042; break;
+ case PDM_INVERT: oc=0x0043; break;
+ case PDM_FILL: oc=0x0044; break;
+ }
+ *pPict << oc;
+ WriteRectangle(rRect);
+}
+
+
+void PictWriter::WriteOpcode_SameRRect(PictDrawingMethod eMethod)
+{
+ USHORT oc;
+ switch (eMethod) {
+ case PDM_FRAME: oc=0x0048; break;
+ case PDM_PAINT: oc=0x0049; break;
+ case PDM_ERASE: oc=0x004a; break;
+ case PDM_INVERT: oc=0x004b; break;
+ case PDM_FILL: oc=0x004c; break;
+ }
+ *pPict << oc;
+}
+
+
+void PictWriter::WriteOpcode_Oval(PictDrawingMethod eMethod, const Rectangle & rRect)
+{
+ USHORT oc;
+ switch (eMethod) {
+ case PDM_FRAME: oc=0x0050; break;
+ case PDM_PAINT: oc=0x0051; break;
+ case PDM_ERASE: oc=0x0052; break;
+ case PDM_INVERT: oc=0x0053; break;
+ case PDM_FILL: oc=0x0054; break;
+ }
+ *pPict << oc;
+ WriteRectangle(rRect);
+}
+
+
+void PictWriter::WriteOpcode_SameOval(PictDrawingMethod eMethod)
+{
+ USHORT oc;
+ switch (eMethod) {
+ case PDM_FRAME: oc=0x0058; break;
+ case PDM_PAINT: oc=0x0059; break;
+ case PDM_ERASE: oc=0x005a; break;
+ case PDM_INVERT: oc=0x005b; break;
+ case PDM_FILL: oc=0x005c; break;
+ }
+ *pPict << oc;
+}
+
+
+void PictWriter::WriteOpcode_Arc(PictDrawingMethod eMethod, const Rectangle & rRect,
+ const Point & rStartPt, const Point & rEndPt)
+{
+ USHORT oc;
+ switch (eMethod) {
+ case PDM_FRAME: oc=0x0060; break;
+ case PDM_PAINT: oc=0x0061; break;
+ case PDM_ERASE: oc=0x0062; break;
+ case PDM_INVERT: oc=0x0063; break;
+ case PDM_FILL: oc=0x0064; break;
+ }
+ *pPict << oc;
+ WriteRectangle(rRect);
+ WriteArcAngles(rRect,rStartPt,rEndPt);
+}
+
+
+void PictWriter::WriteOpcode_SameArc(PictDrawingMethod eMethod, const Rectangle & rRect,
+ const Point & rStartPt, const Point & rEndPt)
+{
+ USHORT oc;
+ switch (eMethod) {
+ case PDM_FRAME: oc=0x0068; break;
+ case PDM_PAINT: oc=0x0069; break;
+ case PDM_ERASE: oc=0x006a; break;
+ case PDM_INVERT: oc=0x006b; break;
+ case PDM_FILL: oc=0x006c; break;
+ }
+ *pPict << oc;
+ WriteArcAngles(rRect,rStartPt,rEndPt);
+}
+
+
+void PictWriter::WriteOpcode_Poly(PictDrawingMethod eMethod, const Polygon & rPoly)
+{
+ USHORT oc;
+
+ if (rPoly.GetSize()<3) return;
+ switch (eMethod) {
+ case PDM_FRAME: oc=0x0070; break;
+ case PDM_PAINT: oc=0x0071; break;
+ case PDM_ERASE: oc=0x0072; break;
+ case PDM_INVERT: oc=0x0073; break;
+ case PDM_FILL: oc=0x0074; break;
+ }
+ *pPict << oc;
+ WritePolygon(rPoly);
+}
+
+
+void PictWriter::WriteOpcode_BitsRect(const Point & rPoint, const Size & rSize, const Bitmap & rBitmap)
+{
+ BitmapReadAccess* pAcc = NULL;
+ Bitmap aBitmap( rBitmap );
+
+ ULONG nWidth, nHeight, nDstRowBytes, nx, nc, ny, nCount, nColTabSize, i;
+ ULONG nDstRowPos, nSrcRowBytes, nEqu3, nPos, nDstMapPos;
+ USHORT nBitsPerPixel, nPackType;
+ BYTE *pComp[4], *pPix, *pTemp, nEquData, nFlagCounterByte, nRed, nGreen, nBlue;
+
+ SetAttrForPaint();
+
+ // temopraere Windows-BMP-Datei erzeugen:
+ nActBitmapPercent=30;
+ MayCallback();
+
+ if ( bStatus == FALSE )
+ return;
+ if ( ( pAcc = aBitmap.AcquireReadAccess() ) == NULL )
+ return;
+
+ nBitsPerPixel = aBitmap.GetBitCount();
+ nWidth = pAcc->Width();
+ nHeight = pAcc->Height();
+
+ // Wenn 24-Bit, dann den Opcode 'DirectBitsRect' erzeugen:
+ if ( nBitsPerPixel == 24 )
+ {
+
+ // Anzahl Bytes einer (ungepackten) Zeile in Quelle und Ziel berechnen:
+ nSrcRowBytes =( ( 3 * nWidth ) + 0x0003 ) & 0xfffc;
+ nDstRowBytes = nWidth * 4;
+
+ // Opcode und BaseAddr (?) schreiben:
+ *pPict << (USHORT)0x009a << (ULONG)0x000000ff;
+
+ // Normalerweise wollen wir den Packing-Type 4 (Run length encoding
+ // for 32-Bit Pixels) erzeugen. Wenn aber RowBytes<8 gilt, sind die Daten
+ // grundsaetzlich ungepackt, auch wenn der Packing-Type 4 angegeben ist,
+ // was etwas komisch erscheint. Daher wollen wir in so einem Fall lieber
+ // gleich den Packing-Type 1 (ungepackt) angeben:
+
+ if ( nDstRowBytes < 8 )
+ nPackType = 1;
+ else
+ nPackType = 4;
+
+ // PixMap-Struktur schreiben:
+ *pPict << (USHORT)(nDstRowBytes|0x8000) // Bytes pro Zeile und dass es eine 'PixMap' ist
+ << (USHORT)0x0000 // Y1-Position der Bitmap in der Quelle
+ << (USHORT)0x0000 // X1-Position der Bitmap in der Quelle
+ << (USHORT)nHeight // Y2-Position der Bitmap in der Quelle
+ << (USHORT)nWidth // X2-Position der Bitmap in der Quelle
+ << (USHORT)0x0000 // Version
+ << (USHORT)nPackType // Packing type
+ << (ULONG) 0x00000000 // Packing size (?)
+ << (ULONG) 0x00480000 // H-Res
+ << (ULONG) 0x00480000 // V-Res
+ << (USHORT)0x0010 // Pixel type (?)
+ << (USHORT)0x0020 // Pixel size: 32 bit
+ << (USHORT)0x0004 // CmpCount: 4 Komponenten
+ << (USHORT)0x0008 // CmpSize: 8 Bits
+ << (ULONG) 0x00000000 // PlaneBytes (?)
+ << (ULONG) 0x00000000 // (?)
+ << (ULONG) 0x00000000; // (?)
+
+ // Source-Rectangle schreiben:
+ *pPict << (USHORT)0x0000 // Y1-Position auf der Bitmap
+ << (USHORT)0x0000 // X1-Position auf der Bitmap
+ << (USHORT)nHeight // Y2-Position auf der Bitmap
+ << (USHORT)nWidth; // X2-Position auf der Bitmap
+
+ // Destination-Rectangle schreiben:
+ WritePoint( rPoint );
+ WritePoint( Point( rPoint.X() + rSize.Width(), rPoint.Y() + rSize.Height() ) );
+
+ // Transfer mode schreiben:
+ *pPict << (USHORT)0x0000; // (?)
+
+ // Position der Map-Daten in Ziel merken:
+ nDstMapPos=pPict->Tell();
+
+ if ( nPackType == 1 ) // bei 24 bits nWidth == 1 !!
+ { // nicht packen
+ for ( ny = 0; ny < nHeight; ny++ )
+ {
+ *pPict << (BYTE)0;
+ *pPict << (BYTE)pAcc->GetPixel( ny, 0 ).GetRed();
+ *pPict << (BYTE)pAcc->GetPixel( ny, 0 ).GetGreen();
+ *pPict << (BYTE)pAcc->GetPixel( ny, 0 ).GetBlue();
+ // Prozente zaehlen, Callback, Fehler pruefen:
+ nActBitmapPercent = ( ny * 70 / nHeight ) + 30; // (30% machten schon das Schreiben der Win-BMP-Datei aus)
+ MayCallback();
+ }
+ }
+ else // packen ( PackType == 4 )
+ {
+ // Speicher fuer Zeilen-Zwischen-Datenstruktur allozieren:
+ for ( nc = 0; nc < 4; nc++ )
+ pComp[ nc ] = new BYTE[ nWidth ];
+
+ // Schleife ueber Zeilen:
+ for ( ny = 0; ny < nHeight; ny++ )
+ {
+ // Zeil ny der Quelle in die Zwischen-Datenstrktur einlesen:
+
+ for ( nx = 0; nx < nWidth; nx++ )
+ {
+ pComp[ 1 ][ nx ] = (BYTE)pAcc->GetPixel( ny, nx ) .GetRed();
+ pComp[ 2 ][ nx ] = (BYTE)pAcc->GetPixel( ny, nx ) .GetGreen();
+ pComp[ 3 ][ nx ] = (BYTE)pAcc->GetPixel( ny, nx ) .GetBlue();
+ pComp[ 0 ][ nx ] = 0;
+ }
+
+ // Anfang der Zeile im Ziel merken:
+ nDstRowPos = pPict->Tell();
+
+ // ByteCount (das ist die Groesse der gepackten Zeile) zunaechst 0 (wird spaeter berichtigt):
+ if ( nDstRowBytes > 250 )
+ *pPict << (USHORT)0;
+ else
+ *pPict << (BYTE)0;
+
+ // Schleife ueber Componenten:
+ for ( nc = 0; nc < 4; nc++ )
+ {
+ // Schleife ueber x:
+ nx = 0;
+ while ( nx < nWidth )
+ {
+ // Die Position von 3 gleichen Bytes suchen und in nEqu3 merken.
+ // wenn nicht gefunden, dann nEqu3=nWidth setzten.
+ // Wenn doch gefunden, dann in nEquData den Wert der Bytes merken.
+ nEqu3 = nx;
+ for (;;)
+ {
+ if ( nEqu3 + 2 >= nWidth )
+ {
+ nEqu3 = nWidth;
+ break;
+ }
+ nEquData = pComp[nc][nEqu3];
+ if ( nEquData == pComp[nc][nEqu3+1] && nEquData==pComp[nc][nEqu3+2] )
+ break;
+ nEqu3++;
+ }
+
+ // Die Daten von nx bis nEqu3 unkomprimiert schreiben (ggf. in mehreren Records):
+ while ( nEqu3 > nx )
+ {
+ nCount = nEqu3 - nx;
+ if ( nCount > 128 )
+ nCount=128;
+ nFlagCounterByte = (BYTE)(nCount-1);
+ *pPict << nFlagCounterByte;
+ do
+ {
+ *pPict << pComp[nc][nx++];
+ nCount--;
+ }
+ while ( nCount > 0 );
+ }
+
+ // Jetzt einen Komprimierungs-Record erzeugen (falls oben mindestens 3
+ // gleiche Bytes gefunden):
+ if ( nx < nWidth )
+ { // Hinweis: es gilt nx==nEqu3 (hoffentlich)
+ nCount=3; // Drei Bytes sind gleich, wie weiter oben herausgefunden.
+ // Pruefen, ob es weitere gleiche Bytes gibts (dabei Max.-Record-Groesse beachten):
+ while ( nx + nCount < nWidth && nCount < 128 )
+ {
+ if ( nEquData != pComp[ nc ][ nx + nCount ] )
+ break;
+ nCount++;
+ }
+ // nCount gleiche Bytes komprimiert schreiben:
+ nFlagCounterByte = (BYTE)( 1 - (long)nCount );
+ *pPict << nFlagCounterByte << nEquData;
+ nx += nCount;
+ }
+ }
+ }
+ // ByteCount berichtigen:
+ nPos = pPict->Tell();
+ pPict->Seek( nDstRowPos );
+ if ( nDstRowBytes > 250 )
+ *pPict << ( (USHORT)( nPos - nDstRowPos - 2 ) );
+ else
+ *pPict << ( (BYTE)( nPos - nDstRowPos - 1 ) );
+ pPict->Seek( nPos );
+
+ // Prozente zaehlen, Callback, Fehler pruefen:
+ nActBitmapPercent = ( ny * 70 / nHeight ) + 30; // (30% machten schon das Schreiben der Win-BMP-Datei aus)
+ MayCallback();
+ }
+ // Aufraeumen:
+ for ( nc = 0; nc < 4; nc++ )
+ delete pComp[ nc ];
+ }
+ }
+ else
+ { // nicht 24-Bit also Opcode 'PackBitsRect' erzeugen:
+
+ // Bei 1-Bit-Bildern ignorieren manche Import-Filter die Palette und nehmen statt
+ // dessen die Vorder- und Hintergrundfarbe:
+ if ( nBitsPerPixel == 1 )
+ {
+ WriteOpcode_RGBBkCol( pAcc->GetPaletteColor( 0 ) );
+ WriteOpcode_RGBFgCol( pAcc->GetPaletteColor( 1 ) );
+ }
+ else
+ {
+ WriteOpcode_RGBBkCol( Color( COL_BLACK ) );
+ WriteOpcode_RGBFgCol( Color( COL_WHITE ) );
+ }
+
+ // Anzahl Bytes einer (ungepackten) Zeile in Ziel und Quelle berechnen:
+ nDstRowBytes = ( nWidth * nBitsPerPixel + 7 ) >> 3;
+ nSrcRowBytes = ( nDstRowBytes + 3 ) & 0xfffffffc;
+
+ // Opcode schreiben:
+ *pPict << (USHORT)0x0098;
+
+ // Normalerweise wollen wir den Packing-Type 0 (default Packing) erzeugen.
+ // Wenn aber RowBytes<8 gilt, sind die Daten grundsaetzlich ungepackt,
+ // auch wenn der Packing-Type 0 angegeben ist, was etwas komisch erscheint.
+ // Daher wollen wir in so einem Fall lieber gleich den Packing-Type 1 (ungepackt)
+ // angeben:
+ if ( nDstRowBytes < 8 )
+ nPackType = 1;
+ else
+ nPackType = 0;
+
+ // PixMap-Struktur schreiben:
+ *pPict << (USHORT)(nDstRowBytes|0x8000) // Bytes pro Zeile und dass es eine 'PixMap' ist
+ << (USHORT)0x0000 // Y1-Position der Bitmap in der Quelle
+ << (USHORT)0x0000 // X1-Position der Bitmap in der Quelle
+ << (USHORT)nHeight // Y2-Position der Bitmap in der Quelle
+ << (USHORT)nWidth // X2-Position der Bitmap in der Quelle
+ << (USHORT)0x0000 // Version
+ << (USHORT)nPackType // Packing type
+ << (ULONG) 0x00000000 // Packing size (?)
+ << (ULONG) 0x00480000 // H-Res
+ << (ULONG) 0x00480000 // V-Res
+ << (USHORT)0x0000 // Pixel type (?)
+ << (USHORT)nBitsPerPixel // Pixel size
+ << (USHORT)0x0001 // CmpCount: 1 Komponente
+ << (USHORT)nBitsPerPixel // CmpSize
+ << (ULONG) 0x00000000 // PlaneBytes (?)
+ << (ULONG) 0x00000000 // (?)
+ << (ULONG) 0x00000000; // (?)
+
+ // Palette lesen und schreiben:
+ nColTabSize = pAcc->GetPaletteEntryCount();
+ *pPict << (ULONG)0 << (USHORT)0x8000 << (USHORT)( nColTabSize - 1 );
+
+ for ( i = 0; i < nColTabSize; i++ )
+ {
+ nRed = (BYTE)pAcc->GetPaletteColor( (USHORT)i ).GetRed();
+ nGreen = (BYTE)pAcc->GetPaletteColor( (USHORT)i ).GetGreen();
+ nBlue = (BYTE)pAcc->GetPaletteColor( (USHORT)i ).GetBlue();
+ *pPict << (UINT16)0 << nRed << nRed << nGreen << nGreen << nBlue << nBlue;
+ }
+
+ // Source-Rectangle schreiben:
+ *pPict << (USHORT)0 << (USHORT)0 << (USHORT)nHeight << (USHORT)nWidth;
+
+ // Destination-Rectangle schreiben:
+ WritePoint( rPoint );
+ WritePoint( Point( rPoint.X() + rSize.Width(), rPoint.Y() + rSize.Height() ) );
+
+ // Transfer mode schreiben:
+ *pPict << (USHORT)0; // (?)
+
+ // Speicher fuer eine Zeile allozieren:
+ pPix = new BYTE[ nSrcRowBytes ];
+
+ // Position der Map-Daten in Ziel merken:
+ nDstMapPos=pPict->Tell();
+
+ // Schleife ueber Zeilen:
+ for ( ny = 0; ny < nHeight; ny++ )
+ {
+
+ // Zeile ny der Quelle in den Zwischenspeicher einlesen:
+
+ switch ( nBitsPerPixel )
+ {
+ case 1 :
+ for ( pTemp = pPix, i = 0; i < nSrcRowBytes; i++ )
+ *pTemp++ = (BYTE)0;
+ for ( i = 0; i < nWidth; i++ )
+ pPix[ ( i >> 3 ) ] |= (BYTE)( pAcc->GetPixel( ny, i ) & 1 ) << ( ( i & 7 ) ^ 7 );
+ break;
+ case 4 :
+ for ( pTemp = pPix, i = 0; i < nSrcRowBytes; i++ )
+ *pTemp++ = (BYTE)0;
+ for ( i = 0; i < nWidth; i++ )
+ pPix[ ( i >> 1 ) ] |= (BYTE)( pAcc->GetPixel( ny, i ) & 15 ) << ( ( i & 1 ) << 2 ) ;
+ break;
+ case 8 :
+ for ( i = 0; i < nWidth; i++ )
+ pPix[ i ] = (BYTE)pAcc->GetPixel( ny, i );
+ break;
+ }
+
+ if ( nPackType == 1 )
+ { // nicht packen
+ pPict->Write( pPix, nDstRowBytes );
+ }
+ else
+ { // Packen (nPackType==0)
+
+ // Anfang der Zeile im Ziel merken:
+ nDstRowPos = pPict->Tell();
+
+ // ByteCount (das ist die Groesse der gepackten Zeile) zunaechst 0 (wird spaeter berichtigt):
+ if ( nDstRowBytes > 250 )
+ *pPict << (USHORT)0;
+ else
+ *pPict << (BYTE)0;
+
+ // Schleife ueber Bytes der Zeile:
+ nx=0;
+ while ( nx < nDstRowBytes && bStatus )
+ {
+ // Die Position von 3 gleichen Bytes suchen und in nEqu3 merken.
+ // wenn nicht gefunden, dann nEqu3=nDstRowBytes setzten.
+ // Wenn doch gefunden, dann in nEquData den Wert der Bytes merken.
+ nEqu3 = nx;
+ for (;;)
+ {
+ if ( nEqu3 + 2 >= nDstRowBytes )
+ {
+ nEqu3 = nDstRowBytes;
+ break;
+ }
+ nEquData = pPix[ nEqu3 ];
+ if ( nEquData == pPix[ nEqu3 + 1 ] && nEquData == pPix[ nEqu3 + 2 ] )
+ break;
+ nEqu3++;
+ }
+
+ // Die Daten von nx bis nEqu3 unkomprimiert schreiben (ggf. in mehreren Records):
+ while ( nEqu3 > nx )
+ {
+ nCount = nEqu3 - nx;
+ if ( nCount > 128 )
+ nCount = 128;
+ nFlagCounterByte = (BYTE)( nCount - 1 );
+ *pPict << nFlagCounterByte;
+ do
+ {
+ *pPict << pPix[ nx++ ];
+ nCount--;
+ } while ( nCount > 0 );
+ }
+
+ // Jetzt einen Komprimierungs-Record erzeugen (falls oben mindestens 3
+ // gleiche Bytes gefunden):
+ if ( nx < nDstRowBytes )
+ { // Hinweis: es gilt nx==nEqu3 (hoffentlich)
+ nCount = 3; // Drei Bytes sind gleich, wie weiter oben herausgefunden.
+ // Pruefen, ob es weitere gleiche Bytes gibts (dabei Max.-Record-Groesse beachten):
+ while ( nx + nCount < nDstRowBytes && nCount < 128 )
+ {
+ if ( nEquData != pPix[ nx + nCount ] )
+ break;
+ nCount++;
+ }
+ // nCount gleiche Bytes komprimiert schreiben:
+ nFlagCounterByte = (BYTE)( 1 - (long)nCount );
+ *pPict << nFlagCounterByte << nEquData;
+ nx += nCount;
+ }
+ }
+
+ // ByteCount berichtigen:
+ nPos = pPict->Tell();
+ pPict->Seek( nDstRowPos );
+ if ( nDstRowBytes > 250 )
+ *pPict << ( (USHORT)( nPos - nDstRowPos - 2 ) );
+ else
+ *pPict << ( (BYTE)( nPos - nDstRowPos - 1 ) );
+ pPict->Seek( nPos );
+ }
+
+ // Prozente zaehlen, Callback, Fehler pruefen:
+ nActBitmapPercent =( ny * 70 / nHeight ) + 30; // (30% machten schon das Schreiben der Win-BMP-Datei aus)
+ MayCallback();
+ if ( pPict->GetError() )
+ bStatus = FALSE;
+ }
+ // Aufraeumen:
+ delete pPix;
+ }
+
+ // Map-Daten muessen gerade Anzahl von Bytes sein:
+ if ( ( ( pPict->Tell() - nDstMapPos ) & 1 ) != 0 )
+ *pPict << (BYTE)0;
+
+ // Bitmaps zaehlen:
+ nWrittenBitmaps++;
+ nActBitmapPercent = 0;
+ if ( pAcc )
+ aBitmap.ReleaseAccess( pAcc );
+}
+
+void PictWriter::WriteOpcode_EndOfFile()
+{
+ *pPict << (USHORT)0x00ff;
+}
+
+
+void PictWriter::SetAttrForPaint()
+{
+ WriteOpcode_PnMode(eSrcRasterOp);
+ WriteOpcode_RGBFgCol(aFillColor);
+ WriteOpcode_RGBBkCol(aFillColor);
+ WriteOpcode_PnFillPat(aFillColor!=Color( COL_TRANSPARENT ));
+}
+
+
+void PictWriter::SetAttrForFrame()
+{
+ WriteOpcode_PnMode(eSrcRasterOp);
+ WriteOpcode_PnSize(0);
+ WriteOpcode_RGBFgCol(aLineColor);
+ WriteOpcode_PnLinePat(aLineColor!=Color( COL_TRANSPARENT ));
+}
+
+
+void PictWriter::SetAttrForText()
+{
+ WriteOpcode_RGBFgCol(aSrcFont.GetColor());
+ WriteOpcode_RGBBkCol(aSrcFont.GetFillColor());
+ WriteOpcode_PnLinePat(TRUE);
+ WriteOpcode_FontName(aSrcFont);
+ WriteOpcode_TxSize((USHORT)(aSrcFont.GetSize().Height()));
+ WriteOpcode_TxMode(eSrcRasterOp);
+ WriteOpcode_TxFace(aSrcFont);
+}
+
+
+void PictWriter::WriteTextArray(Point & rPoint, const ByteString& rString, const long * pDXAry)
+{
+ USHORT i,nLen;
+ sal_Char c;
+ BOOL bDelta;
+ Point aPt;
+
+ if ( pDXAry == NULL )
+ WriteOpcode_Text( rPoint, rString, FALSE );
+ else
+ {
+ bDelta = FALSE;
+ nLen = rString.Len();
+ for ( i = 0; i < nLen; i++ )
+ {
+ c = rString.GetChar( i );
+ if ( (unsigned char) c > 32 )
+ {
+ aPt = rPoint;
+ if ( i > 0 )
+ aPt.X() += pDXAry[ i - 1 ];
+
+ WriteOpcode_Text( aPt, ByteString( c ), bDelta );
+ bDelta = TRUE;
+ }
+ }
+ }
+}
+
+
+void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF )
+{
+ ULONG nA, nACount;
+ const MetaAction* pMA;
+
+ if( !bStatus)
+ return;
+
+ nACount=rMTF.GetActionCount();
+
+ for (nA=0; nA<nACount; nA++)
+ {
+ pMA = rMTF.GetAction(nA);
+
+ switch (pMA->GetType())
+ {
+ case META_PIXEL_ACTION:
+ {
+ const MetaPixelAction* pA = (const MetaPixelAction*) pMA;
+ WriteOpcode_PnMode(eSrcRasterOp);
+ WriteOpcode_PnSize(1);
+ WriteOpcode_RGBFgCol(pA->GetColor());
+ WriteOpcode_PnLinePat(TRUE);
+ WriteOpcode_Line(pA->GetPoint(),pA->GetPoint());
+ }
+ break;
+
+ case META_POINT_ACTION:
+ {
+ const MetaPointAction* pA = (const MetaPointAction*) pMA;
+
+ if( aLineColor != Color( COL_TRANSPARENT ) )
+ {
+ SetAttrForFrame();
+ WriteOpcode_Line( pA->GetPoint(),pA->GetPoint() );
+ }
+ }
+ break;
+
+ case META_LINE_ACTION:
+ {
+ const MetaLineAction* pA = (const MetaLineAction*) pMA;
+
+ if( aLineColor != Color( COL_TRANSPARENT ) )
+ {
+ SetAttrForFrame();
+ WriteOpcode_Line( pA->GetStartPoint(),pA->GetEndPoint() );
+ }
+ break;
+ }
+
+ case META_RECT_ACTION:
+ {
+ const MetaRectAction* pA = (const MetaRectAction*) pMA;
+
+ if (aFillColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForPaint();
+ WriteOpcode_Rect(PDM_PAINT,pA->GetRect());
+ if (aLineColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForFrame();
+ WriteOpcode_SameRect(PDM_FRAME);
+ }
+ }
+ else if (aLineColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForFrame();
+ WriteOpcode_Rect(PDM_FRAME,pA->GetRect());
+ }
+ }
+ break;
+
+ case META_ROUNDRECT_ACTION:
+ {
+ const MetaRoundRectAction* pA = (const MetaRoundRectAction*) pMA;
+
+ WriteOpcode_OvSize( Size( pA->GetHorzRound(), pA->GetVertRound() ) );
+
+ if (aFillColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForPaint();
+ WriteOpcode_RRect(PDM_PAINT,pA->GetRect());
+ if (aLineColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForFrame();
+ WriteOpcode_SameRRect(PDM_FRAME);
+ }
+ }
+ else if (aLineColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForFrame();
+ WriteOpcode_RRect(PDM_FRAME,pA->GetRect());
+ }
+ }
+ break;
+
+ case META_ELLIPSE_ACTION:
+ {
+ const MetaEllipseAction* pA = (const MetaEllipseAction*) pMA;
+
+ if (aFillColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForPaint();
+ WriteOpcode_Oval(PDM_PAINT,pA->GetRect());
+ if (aLineColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForFrame();
+ WriteOpcode_SameOval(PDM_FRAME);
+ }
+ }
+ else if (aLineColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForFrame();
+ WriteOpcode_Oval(PDM_FRAME,pA->GetRect());
+ }
+ }
+ break;
+
+ case META_ARC_ACTION:
+ {
+ const MetaArcAction* pA = (const MetaArcAction*) pMA;
+
+ if (aLineColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForFrame();
+ WriteOpcode_Arc(PDM_FRAME,pA->GetRect(),pA->GetStartPoint(),pA->GetEndPoint());
+ }
+ }
+ break;
+
+ case META_PIE_ACTION:
+ {
+ const MetaPieAction* pA = (const MetaPieAction *) pMA;
+
+ if (aFillColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForPaint();
+ WriteOpcode_Arc(PDM_PAINT,pA->GetRect(),pA->GetStartPoint(),pA->GetEndPoint());
+
+ if (aLineColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForFrame();
+ WriteOpcode_SameArc(PDM_FRAME,pA->GetRect(),pA->GetStartPoint(),pA->GetEndPoint());
+ }
+ }
+ else if (aLineColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForFrame();
+ WriteOpcode_Arc(PDM_FRAME,pA->GetRect(),pA->GetStartPoint(),pA->GetEndPoint());
+ }
+
+ if (aLineColor!=Color( COL_TRANSPARENT ))
+ {
+ double fxc,fyc,fxr,fyr,fx1,fy1,fx2,fy2,l1,l2;
+
+ fxc=((double)(pA->GetRect().Left()+pA->GetRect().Right()))/2.0;
+ fyc=((double)(pA->GetRect().Top()+pA->GetRect().Bottom()))/2.0;
+ fxr=((double)pA->GetRect().GetWidth())/2.0;
+ fyr=((double)pA->GetRect().GetHeight())/2.0;
+ fx1=((double)pA->GetStartPoint().X())-fxc;
+ fy1=((double)pA->GetStartPoint().Y())-fyc;
+ fx2=((double)pA->GetEndPoint().X())-fxc;
+ fy2=((double)pA->GetEndPoint().Y())-fyc;
+ l1=sqrt(fx1*fx1+fy1*fy1);
+ l2=sqrt(fx2*fx2+fy2*fy2);
+
+ if (l1>0)
+ {
+ fx1=fx1/l1*fxr;
+ fy1=fy1/l1*fyr;
+ }
+
+ if (l2>0)
+ {
+ fx2=fx2/l2*fxr;
+ fy2=fy2/l2*fyr;
+ }
+ fx1+=fxc; fy1+=fyc; fx2+=fxc; fy2+=fyc;
+ WriteOpcode_Line(Point((long)(fx1+0.5),(long)(fy1+0.5)), Point((long)(fxc+0.5),(long)(fyc+0.5)));
+ WriteOpcode_LineFrom(Point((long)(fx2+0.5),(long)(fy2+0.5)));
+ }
+ }
+ break;
+
+ case META_CHORD_ACTION:
+ {
+// DBG_ERROR( "Unsupported PICT-Action: META_CHORD_ACTION!" );
+ }
+ break;
+
+ case META_POLYLINE_ACTION:
+ {
+ const MetaPolyLineAction* pA = (const MetaPolyLineAction*) pMA;
+
+ if( aLineColor!=Color( COL_TRANSPARENT ) )
+ {
+ const Polygon& rPoly = pA->GetPolygon();
+ const USHORT nSize = rPoly.GetSize();
+ Point aLast;
+
+ if ( nSize )
+ {
+ SetAttrForFrame();
+ aLast = rPoly[0];
+
+ for ( USHORT i = 1; i < nSize; i++ )
+ {
+ WriteOpcode_Line( aLast, rPoly[i] );
+ aLast = rPoly[i];
+ }
+ }
+ }
+ }
+ break;
+
+ case META_POLYGON_ACTION:
+ {
+ const MetaPolygonAction* pA = (const MetaPolygonAction*) pMA;
+
+ if (aFillColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForPaint();
+ WriteOpcode_Poly(PDM_PAINT,pA->GetPolygon());
+ }
+
+ if (aLineColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForFrame();
+ WriteOpcode_Poly(PDM_FRAME,pA->GetPolygon());
+ }
+ }
+ break;
+
+ case META_POLYPOLYGON_ACTION:
+ {
+ const MetaPolyPolygonAction* pA = (const MetaPolyPolygonAction*) pMA;
+
+ if (aFillColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForPaint();
+ WriteOpcode_Poly(PDM_PAINT,PolyPolygonToPolygon(pA->GetPolyPolygon()));
+ }
+
+ if (aLineColor!=Color( COL_TRANSPARENT ))
+ {
+ USHORT nCount,i;
+ SetAttrForFrame();
+ nCount=pA->GetPolyPolygon().Count();
+ for (i=0; i<nCount; i++)
+ WriteOpcode_Poly(PDM_FRAME,pA->GetPolyPolygon().GetObject(i));
+ }
+ }
+ break;
+
+ case META_TEXT_ACTION:
+ {
+ const MetaTextAction* pA = (const MetaTextAction*) pMA;
+ Point aPt( pA->GetPoint() );
+
+ if ( aSrcFont.GetAlign() != ALIGN_BASELINE )
+ {
+ VirtualDevice aVirDev;
+
+ if (aSrcFont.GetAlign()==ALIGN_TOP)
+ aPt.Y()+=(long)aVirDev.GetFontMetric(aSrcFont).GetAscent();
+ else
+ aPt.Y()-=(long)aVirDev.GetFontMetric(aSrcFont).GetDescent();
+ }
+
+ SetAttrForText();
+ String aStr( pA->GetText(),pA->GetIndex(),pA->GetLen() );
+ WriteOpcode_Text( aPt, ByteString( aStr, RTL_TEXTENCODING_UTF8 ) ,FALSE );
+ }
+ break;
+
+ case META_TEXTARRAY_ACTION:
+ {
+ const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pMA;
+ Point aPt( pA->GetPoint() );
+
+ if (aSrcFont.GetAlign()!=ALIGN_BASELINE)
+ {
+ VirtualDevice aVirDev;
+
+ if (aSrcFont.GetAlign()==ALIGN_TOP)
+ aPt.Y()+=(long)aVirDev.GetFontMetric(aSrcFont).GetAscent();
+ else
+ aPt.Y()-=(long)aVirDev.GetFontMetric(aSrcFont).GetDescent();
+ }
+ SetAttrForText();
+ String aStr( pA->GetText(),pA->GetIndex(),pA->GetLen() );
+ WriteTextArray( aPt, ByteString( aStr, RTL_TEXTENCODING_UTF8 ), pA->GetDXArray() );
+ break;
+ }
+
+ case META_STRETCHTEXT_ACTION:
+ {
+ const MetaStretchTextAction* pA = (const MetaStretchTextAction*) pMA;
+ Point aPt( pA->GetPoint() );
+ String aStr( pA->GetText(),pA->GetIndex(),pA->GetLen() );
+ VirtualDevice aVirDev;
+ long* pDXAry = new long[ aStr.Len() ];
+ sal_Int32 nNormSize( aVirDev.GetTextArray( aStr,pDXAry ) );
+ USHORT i;
+
+ if (aSrcFont.GetAlign()!=ALIGN_BASELINE)
+ {
+ if (aSrcFont.GetAlign()==ALIGN_TOP)
+ aPt.Y()+=(long)aVirDev.GetFontMetric(aSrcFont).GetAscent();
+ else
+ aPt.Y()-=(long)aVirDev.GetFontMetric(aSrcFont).GetDescent();
+ }
+
+ for ( i = 0; i < aStr.Len() - 1; i++ )
+ pDXAry[ i ] = pDXAry[ i ] * ( (long)pA->GetWidth() ) / nNormSize;
+
+ SetAttrForText();
+ WriteTextArray( aPt, ByteString( aStr, RTL_TEXTENCODING_UTF8 ), pDXAry );
+ delete[] pDXAry;
+ }
+ break;
+
+ case META_TEXTRECT_ACTION:
+ {
+// DBG_ERROR( "Unsupported PICT-Action: META_TEXTRECT_ACTION!" );
+ }
+ break;
+
+ case META_BMP_ACTION:
+ {
+ const MetaBmpAction* pA = (const MetaBmpAction*) pMA;
+ WriteOpcode_BitsRect( pA->GetPoint(),pA->GetBitmap().GetSizePixel(), pA->GetBitmap() );
+ }
+ break;
+
+ case META_BMPSCALE_ACTION:
+ {
+ const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pMA;
+ WriteOpcode_BitsRect( pA->GetPoint(), pA->GetSize(), pA->GetBitmap() );
+ }
+ break;
+
+ case META_BMPSCALEPART_ACTION:
+ {
+ const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*) pMA;
+ Bitmap aBmp( pA->GetBitmap() );
+
+ aBmp.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
+ WriteOpcode_BitsRect( pA->GetDestPoint(), pA->GetDestSize(), aBmp );
+ }
+ break;
+
+ case META_BMPEX_ACTION:
+ {
+ const MetaBmpExAction* pA = (const MetaBmpExAction*) pMA;
+ const Bitmap aBmp( Graphic( pA->GetBitmapEx() ).GetBitmap() );
+
+ WriteOpcode_BitsRect( pA->GetPoint(), aBmp.GetSizePixel(), aBmp );
+ }
+ break;
+
+ case META_BMPEXSCALE_ACTION:
+ {
+ const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pMA;
+ const Bitmap aBmp( Graphic( pA->GetBitmapEx() ).GetBitmap() );
+
+ WriteOpcode_BitsRect( pA->GetPoint(), pA->GetSize(), aBmp );
+ }
+ break;
+
+ case META_BMPEXSCALEPART_ACTION:
+ {
+ const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*) pMA;
+ Bitmap aBmp( Graphic( pA->GetBitmapEx() ).GetBitmap() );
+
+ aBmp.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
+ WriteOpcode_BitsRect( pA->GetDestPoint(), pA->GetDestSize(), aBmp );
+ }
+ break;
+
+ case META_EPS_ACTION :
+ {
+ const MetaEPSAction* pA = (const MetaEPSAction*)pMA;
+ const GDIMetaFile aGDIMetaFile( pA->GetSubstitute() );
+
+ INT32 nCount = aGDIMetaFile.GetActionCount();
+ for ( INT32 i = 0; i < nCount; i++ )
+ {
+ const MetaAction* pMetaAct = aGDIMetaFile.GetAction( i );
+ if ( pMetaAct->GetType() == META_BMPSCALE_ACTION )
+ {
+ const MetaBmpScaleAction* pBmpScaleAction = (const MetaBmpScaleAction*)pMetaAct;
+ WriteOpcode_BitsRect( pA->GetPoint(), pA->GetSize(), pBmpScaleAction->GetBitmap() );
+ break;
+ }
+ }
+ }
+ break;
+
+ case META_MASK_ACTION:
+ case META_MASKSCALE_ACTION:
+ case META_MASKSCALEPART_ACTION:
+ {
+// DBG_ERROR( "Unsupported PICT-Action: META_MASK..._ACTION!" );
+ }
+ break;
+
+ case META_GRADIENT_ACTION:
+ {
+ VirtualDevice aVDev;
+ GDIMetaFile aTmpMtf;
+ const MetaGradientAction* pA = (const MetaGradientAction*) pMA;
+
+ aVDev.SetMapMode( aTargetMapMode );
+ aVDev.AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf );
+ WriteOpcodes( aTmpMtf );
+ }
+ break;
+
+ case META_HATCH_ACTION:
+ {
+ VirtualDevice aVDev;
+ GDIMetaFile aTmpMtf;
+ const MetaHatchAction* pA = (const MetaHatchAction*) pMA;
+
+ aVDev.SetMapMode( aTargetMapMode );
+ aVDev.AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf );
+ WriteOpcodes( aTmpMtf );
+ }
+ break;
+
+ case META_WALLPAPER_ACTION:
+ {
+// DBG_ERROR( "Unsupported PICT-Action: META_WALLPAPER_ACTION!" );
+ }
+ break;
+
+ case META_CLIPREGION_ACTION:
+ {
+// DBG_ERROR( "Unsupported PICT-Action: META_CLIPREGION_ACTION!" );
+ }
+ break;
+
+ case META_ISECTRECTCLIPREGION_ACTION:
+ {
+// DBG_ERROR( "Unsupported PICT-Action: META_ISECTRECTCLIPREGION_ACTION!" );
+ }
+ break;
+
+ case META_ISECTREGIONCLIPREGION_ACTION:
+ {
+// DBG_ERROR( "Unsupported PICT-Action: META_ISECTREGIONCLIPREGION_ACTION!" );
+ }
+ break;
+
+ case META_MOVECLIPREGION_ACTION:
+ {
+// DBG_ERROR( "Unsupported PICT-Action: META_MOVECLIPREGION_ACTION!" );
+ }
+ break;
+
+ case META_LINECOLOR_ACTION:
+ {
+ const MetaLineColorAction* pA = (const MetaLineColorAction*) pMA;
+
+ if( pA->IsSetting() )
+ aLineColor = pA->GetColor();
+ else
+ aLineColor = Color( COL_TRANSPARENT );
+ }
+ break;
+
+ case META_FILLCOLOR_ACTION:
+ {
+ const MetaFillColorAction* pA = (const MetaFillColorAction*) pMA;
+
+ if( pA->IsSetting() )
+ aFillColor = pA->GetColor();
+ else
+ aFillColor = Color( COL_TRANSPARENT );
+ }
+ break;
+
+ case META_TEXTCOLOR_ACTION:
+ {
+ const MetaTextColorAction* pA = (const MetaTextColorAction*) pMA;
+ aSrcFont.SetColor( pA->GetColor() );
+ }
+ break;
+
+ case META_TEXTFILLCOLOR_ACTION:
+ {
+ const MetaTextFillColorAction* pA = (const MetaTextFillColorAction*) pMA;
+
+ if( pA->IsSetting() )
+ aSrcFont.SetFillColor( pA->GetColor() );
+ else
+ aSrcFont.SetFillColor( Color( COL_TRANSPARENT ) );
+ }
+ break;
+
+ case META_TEXTALIGN_ACTION:
+ {
+// DBG_ERROR( "Unsupported PICT-Action: META_TEXTALIGN_ACTION!" );
+ }
+ break;
+
+ case META_MAPMODE_ACTION:
+ {
+ const MetaMapModeAction* pA = (const MetaMapModeAction*) pMA;
+
+ if (aSrcMapMode!=pA->GetMapMode())
+ {
+ if( pA->GetMapMode().GetMapUnit() == MAP_RELATIVE )
+ {
+ MapMode aMM = pA->GetMapMode();
+ Fraction aScaleX = aMM.GetScaleX();
+ Fraction aScaleY = aMM.GetScaleY();
+
+ Point aOrigin = aSrcMapMode.GetOrigin();
+ BigInt aX( aOrigin.X() );
+ aX *= BigInt( aScaleX.GetDenominator() );
+ if( aOrigin.X() >= 0 )
+ {
+ if( aScaleX.GetNumerator() >= 0 )
+ aX += BigInt( aScaleX.GetNumerator()/2 );
+ else
+ aX -= BigInt( (aScaleX.GetNumerator()+1)/2 );
+ }
+ else
+ {
+ if( aScaleX.GetNumerator() >= 0 )
+ aX -= BigInt( (aScaleX.GetNumerator()-1)/2 );
+ else
+ aX += BigInt( aScaleX.GetNumerator()/2 );
+ }
+
+ aX /= BigInt( aScaleX.GetNumerator() );
+ aOrigin.X() = (long)aX + aMM.GetOrigin().X();
+ BigInt aY( aOrigin.Y() );
+ aY *= BigInt( aScaleY.GetDenominator() );
+
+ if( aOrigin.Y() >= 0 )
+ {
+ if( aScaleY.GetNumerator() >= 0 )
+ aY += BigInt( aScaleY.GetNumerator()/2 );
+ else
+ aY -= BigInt( (aScaleY.GetNumerator()+1)/2 );
+ }
+ else
+ {
+ if( aScaleY.GetNumerator() >= 0 )
+ aY -= BigInt( (aScaleY.GetNumerator()-1)/2 );
+ else
+ aY += BigInt( aScaleY.GetNumerator()/2 );
+ }
+
+ aY /= BigInt( aScaleY.GetNumerator() );
+ aOrigin.Y() = (long)aY + aMM.GetOrigin().Y();
+ aSrcMapMode.SetOrigin( aOrigin );
+
+ aScaleX *= aSrcMapMode.GetScaleX();
+ aScaleY *= aSrcMapMode.GetScaleY();
+ aSrcMapMode.SetScaleX( aScaleX );
+ aSrcMapMode.SetScaleY( aScaleY );
+ }
+ else
+ aSrcMapMode = pA->GetMapMode();
+ }
+ }
+ break;
+
+ case META_FONT_ACTION:
+ {
+ const MetaFontAction* pA = (const MetaFontAction*) pMA;
+ aSrcFont=pA->GetFont();
+ }
+ break;
+
+ case META_PUSH_ACTION:
+ {
+ PictWriterAttrStackMember * pAt = new PictWriterAttrStackMember;
+ pAt->aLineColor=aLineColor;
+ pAt->aFillColor=aFillColor;
+ pAt->eRasterOp=eSrcRasterOp;
+ pAt->aFont=aSrcFont;
+ pAt->aMapMode=aSrcMapMode;
+ pAt->pSucc=pAttrStack;
+ pAttrStack=pAt;
+ }
+ break;
+
+ case META_POP_ACTION:
+ {
+ PictWriterAttrStackMember* pAt=pAttrStack;
+
+ if( pAt )
+ {
+ aLineColor=pAt->aLineColor;
+ aFillColor=pAt->aFillColor;
+ eSrcRasterOp=pAt->eRasterOp;
+ aSrcFont=pAt->aFont;
+ aSrcMapMode=pAt->aMapMode;
+ pAttrStack=pAt->pSucc;
+ delete pAt;
+ }
+ }
+ break;
+
+ case META_RASTEROP_ACTION:
+ {
+ const MetaRasterOpAction* pA = (const MetaRasterOpAction*) pMA;
+ eSrcRasterOp=pA->GetRasterOp();
+ }
+ break;
+
+ case META_TRANSPARENT_ACTION:
+ {
+ const PolyPolygon& rPolyPoly = ( (const MetaTransparentAction*) pMA )->GetPolyPolygon();
+
+ if (aFillColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForPaint();
+ WriteOpcode_Poly( PDM_PAINT, PolyPolygonToPolygon( rPolyPoly ) );
+ }
+
+ if (aLineColor!=Color( COL_TRANSPARENT ))
+ {
+ SetAttrForFrame();
+ for( USHORT i = 0, nCount = rPolyPoly.Count(); i < nCount; i++ )
+ WriteOpcode_Poly( PDM_FRAME, rPolyPoly.GetObject( i ) );
+ }
+ }
+ break;
+
+ case META_FLOATTRANSPARENT_ACTION:
+ {
+ const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pMA;
+
+ GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() );
+ Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() );
+ const Size aSrcSize( aTmpMtf.GetPrefSize() );
+ const Point aDestPt( pA->GetPoint() );
+ const Size aDestSize( pA->GetSize() );
+ const double fScaleX = aSrcSize.Width() ? (double) aDestSize.Width() / aSrcSize.Width() : 1.0;
+ const double fScaleY = aSrcSize.Height() ? (double) aDestSize.Height() / aSrcSize.Height() : 1.0;
+ long nMoveX, nMoveY;
+
+ if( fScaleX != 1.0 || fScaleY != 1.0 )
+ {
+ aTmpMtf.Scale( fScaleX, fScaleY );
+ aSrcPt.X() = FRound( aSrcPt.X() * fScaleX ), aSrcPt.Y() = FRound( aSrcPt.Y() * fScaleY );
+ }
+
+ nMoveX = aDestPt.X() - aSrcPt.X(), nMoveY = aDestPt.Y() - aSrcPt.Y();
+
+ if( nMoveX || nMoveY )
+ aTmpMtf.Move( nMoveX, nMoveY );
+
+ WriteOpcodes( aTmpMtf );
+ }
+ break;
+ }
+
+ nWrittenActions++;
+ MayCallback();
+
+ if (pPict->GetError())
+ bStatus=FALSE;
+
+ if (bStatus==FALSE)
+ break;
+ }
+}
+
+
+void PictWriter::WriteHeader(const GDIMetaFile & rMTF)
+{
+ USHORT i;
+ Size aSize( OutputDevice::LogicToLogic( rMTF.GetPrefSize(),
+ rMTF.GetPrefMapMode(),
+ aTargetMapMode ) );
+ short nWidth = (short) ( aSize.Width() + 1L );
+ short nHeight = (short) ( aSize.Height() + 1L );
+
+ // 512 Bytes "Muell" am Anfang:
+ for (i=0;i<128;i++) *pPict << (ULONG)0;
+
+ // Lo-16-Bits der Groesse der Datei ohne die 512 Bytes Muell:
+ *pPict << (USHORT)0; // wird spaeter durch UpdateHeader() berichtigt
+
+ // Das Bounding-Rectangle (y1,x1,y2,x2 !):
+ *pPict << (short)0 << (short)0
+ << nHeight << nWidth;
+
+ // Version 2:
+ *pPict << (ULONG)0x001102ff;
+
+ // Extended-Version-2-Header:
+ *pPict << (USHORT)0x0c00 // Opcode
+ << (USHORT)0xfffe // Version (?)
+ << (USHORT)0x0000 // Reserved
+ << (ULONG) 0x00480000 // hRes
+ << (ULONG) 0x00480000 // vRes
+ << (USHORT)0x0000 // SrcRect-Y1
+ << (USHORT)0x0000 // SrcRect-X1
+ << nHeight // SrcRect-Y2
+ << nWidth // SrcRect-X2
+ << (ULONG)0x00000000; // Reserved
+
+ // viele Import-Filter verlangen die Angabe eines
+ // Clipping-Bereichs am Anfang
+ *pPict << (USHORT)0x0001
+ << (USHORT)0x000a
+ << (USHORT)0x0000
+ << (USHORT)0x0000
+ << nHeight
+ << nWidth;
+}
+
+
+void PictWriter::UpdateHeader()
+{
+ ULONG nPos;
+
+ // Lo-16-Bits der Groesse der Datei ohne die 512 Bytes Muell berichtigen:
+ nPos=pPict->Tell();
+ pPict->Seek(512);
+ *pPict << (USHORT)((nPos-512)&0x0000ffff);
+ pPict->Seek(nPos);
+}
+
+
+BOOL PictWriter::WritePict(const GDIMetaFile & rMTF, SvStream & rTargetStream, PFilterCallback pcallback, void * pcallerdata)
+{
+ PictWriterAttrStackMember* pAt;
+ MapMode aMap72( MAP_INCH );
+ Fraction aDPIFrac( 1, 72 );
+
+ bStatus=TRUE;
+
+ pCallback=pcallback;
+ pCallerData=pcallerdata;
+ nLastPercent=0;
+
+ pPict=&rTargetStream;
+ pPict->SetNumberFormatInt(NUMBERFORMAT_INT_BIGENDIAN);
+
+ aLineColor=Color( COL_BLACK );
+ aFillColor=Color( COL_WHITE );
+ eSrcRasterOp=ROP_OVERPAINT;
+ aSrcFont=Font();
+ aSrcMapMode = rMTF.GetPrefMapMode();
+
+ aMap72.SetScaleX( aDPIFrac );
+ aMap72.SetScaleY( aDPIFrac );
+ aTargetMapMode = aMap72;
+
+ pAttrStack=NULL;
+
+ bDstBkPatValid=FALSE;
+ bDstTxFaceValid=FALSE;
+ bDstTxModeValid=FALSE;
+ bDstPnSizeValid=FALSE;
+ bDstPnModeValid=FALSE;
+ bDstPnPatValid=FALSE;
+ bDstFillPatValid=FALSE;
+ bDstTxSizeValid=FALSE;
+ bDstFgColValid=FALSE;
+ bDstBkColValid=FALSE;
+ bDstPenPositionValid=FALSE;
+ bDstTextPositionValid=FALSE;
+ bDstFontNameValid=FALSE;
+
+ nNumberOfActions=0;
+ nNumberOfBitmaps=0;
+ nWrittenActions=0;
+ nWrittenBitmaps=0;
+ nActBitmapPercent=0;
+
+ CountActionsAndBitmaps(rMTF);
+
+ WriteHeader(rMTF);
+ WriteOpcodes(rMTF);
+ WriteOpcode_EndOfFile();
+ UpdateHeader();
+
+ while (pAttrStack!=NULL) {
+ pAt=pAttrStack;
+ pAttrStack=pAt->pSucc;
+ delete pAt;
+ }
+
+ return bStatus;
+}
+
+//================== GraphicExport - die exportierte Funktion ================
+
+#ifdef WNT
+extern "C" BOOL _cdecl GraphicExport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#else
+extern "C" BOOL GraphicExport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#endif
+{
+ PictWriter aPictWriter;
+
+ if (rGraphic.GetType()==GRAPHIC_GDIMETAFILE)
+ {
+ GDIMetaFile aScaledMtf( rGraphic.GetGDIMetaFile() );
+
+/*
+ MapMode aMap72( MAP_INCH );
+ Fraction aDPIFrac( 1, 72 );
+ Size aOldSize = aScaledMtf.GetPrefSize();
+
+ aMap72.SetScaleX( aDPIFrac );
+ aMap72.SetScaleY( aDPIFrac );
+
+ Size aNewSize = OutputDevice::LogicToLogic( aOldSize,
+ aScaledMtf.GetPrefMapMode(),
+ aMap72 );
+
+ aScaledMtf.Scale( Fraction( aNewSize.Width(), aOldSize.Width() ),
+ Fraction( aNewSize.Height(), aOldSize.Height() ) );
+ aScaledMtf.SetPrefMapMode( aMap72 );
+ aScaledMtf.SetPrefSize( aNewSize );
+*/
+
+ return aPictWriter.WritePict( aScaledMtf, rStream, pCallback, pCallerData );
+ }
+ else
+ {
+ Bitmap aBmp=rGraphic.GetBitmap();
+ GDIMetaFile aMTF;
+ VirtualDevice aVirDev;
+
+ aMTF.Record(&aVirDev);
+ aVirDev.DrawBitmap(Point(),aBmp);
+ aMTF.Stop();
+ aMTF.SetPrefSize(aBmp.GetSizePixel());
+ return aPictWriter.WritePict(aMTF,rStream,pCallback,pCallerData);
+ }
+}
+
+//================== GraphicDialog - die exportierte Funktion ================
+
+extern "C" BOOL SAL_CALL DoExportDialog( FltCallDialogParameter& rPara )
+{
+ BOOL bRet = FALSE;
+
+ if ( rPara.pWindow && rPara.pCfg )
+ {
+ ByteString aResMgrName( "ept" );
+ ResMgr* pResMgr;
+
+ aResMgrName.Append( ByteString::CreateFromInt32( SOLARUPD ) );
+ pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetAppInternational().GetLanguage() );
+
+ if( pResMgr )
+ {
+ rPara.pResMgr = pResMgr;
+ bRet = ( DlgExportEPCT( rPara ).Execute() == RET_OK );
+ delete pResMgr;
+ }
+ else
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+
+//=============================== fuer Windows ==============================
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
+
diff --git a/goodies/source/filter.vcl/epict/epictstr.src b/goodies/source/filter.vcl/epict/epictstr.src
new file mode 100644
index 000000000000..9b4181bc7366
--- /dev/null
+++ b/goodies/source/filter.vcl/epict/epictstr.src
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * $RCSfile: epictstr.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "strings.hrc"
+
+String KEY_MODE
+{
+ Text = "PCT-EXPORT-MODE";
+};
+
+String KEY_SIZEX
+{
+ Text = "PCT-EXPORT-SIZEX";
+};
+
+String KEY_SIZEY
+{
+ Text = "PCT-EXPORT-SIZEY";
+};
diff --git a/goodies/source/filter.vcl/epict/makefile.mk b/goodies/source/filter.vcl/epict/makefile.mk
new file mode 100644
index 000000000000..7afbc9e0223b
--- /dev/null
+++ b/goodies/source/filter.vcl/epict/makefile.mk
@@ -0,0 +1,186 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=epict
+TARGET2=ept
+DEPTARGET=vepict
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(COM)"=="WTC"
+CFLAGSOPT= -od -3r
+.ENDIF
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SRCFILES = dlgepct.src \
+ epictstr.src
+
+SLOFILES = $(SLO)$/epict.obj \
+ $(SLO)$/dlgepct.obj
+
+
+# ==========================================================================
+
+RESLIB1NAME=$(TARGET2)
+RESLIB1SRSFILES=\
+ $(SRS)$/$(TARGET).srs
+
+SHL1TARGET= ept$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= epict
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(SVTOOLLIB) $(CPPULIB)
+
+SHL1DEPN= $(LB)$/epict.lib
+SHL1LIBS= $(SLB)$/epict.lib # $(LB)$/rtftoken.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/epict.obj
+.ENDIF
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicExport >>$@
+ @echo DoExportDialog >>$@
+.ELSE
+ @echo _GraphicExport >>$@
+ @echo _DoExportDialog >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET) >>$@
+ @echo GraphicExport_ >>temp.def
+ @echo DoExportDialog_ >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicExport >>$@
+ @echo DoExportDialog >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/epict/strings.hrc b/goodies/source/filter.vcl/epict/strings.hrc
new file mode 100644
index 000000000000..89b93b729e0b
--- /dev/null
+++ b/goodies/source/filter.vcl/epict/strings.hrc
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * $RCSfile: strings.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:12 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#define KEY_MODE 260
+#define KEY_SIZEX 262
+#define KEY_SIZEY 264
+
diff --git a/goodies/source/filter.vcl/eppm/dlgeppm.cxx b/goodies/source/filter.vcl/eppm/dlgeppm.cxx
new file mode 100644
index 000000000000..5b22e9c4a6fd
--- /dev/null
+++ b/goodies/source/filter.vcl/eppm/dlgeppm.cxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgeppm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma hdrstop
+#include <tools/ref.hxx>
+#include <vcl/config.hxx>
+#include <vcl/msgbox.hxx>
+#include "dlgeppm.hxx"
+#include "dlgeppm.hrc"
+#include "strings.hrc"
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+
+DlgExportEPPM::DlgExportEPPM( FltCallDialogParameter& rPara ) :
+ ModalDialog ( rPara.pWindow, ResId( DLG_EXPORT_EPPM, rPara.pResMgr ) ),
+ aGrpFormat ( this, ResId( GRP_FORMAT ) ),
+ aRBRaw ( this, ResId( RB_RAW ) ),
+ aRBASCII ( this, ResId( RB_ASCII ) ),
+ aBtnOK ( this, ResId( BTN_OK ) ),
+ aBtnCancel ( this, ResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ResId( BTN_HELP ) ),
+ pConfig ( rPara.pCfg ),
+ pMgr ( rPara.pResMgr )
+{
+ FreeResource();
+
+ // Config-Parameter lesen
+
+ String aFormatStr( ResId( KEY_FORMAT, pMgr ) );
+ sal_Int32 nFormat = pConfig->ReadKey( ByteString( aFormatStr, RTL_TEXTENCODING_UTF8 ) ).ToInt32();
+
+ BOOL bCheck = FALSE;
+ if ( !nFormat )
+ bCheck ^= TRUE;
+ aRBRaw.Check( bCheck );
+ bCheck ^= TRUE;
+ aRBASCII.Check( bCheck );
+
+ aBtnOK.SetClickHdl( LINK( this, DlgExportEPPM, OK ) );
+}
+
+/*************************************************************************
+|*
+|* Speichert eingestellte Werte in ini-Datei
+|*
+\************************************************************************/
+
+IMPL_LINK( DlgExportEPPM, OK, void *, EMPTYARG )
+{
+
+ // Config-Parameter schreiben
+
+ sal_Int32 nCheck = 0;
+ if ( aRBASCII.IsChecked() )
+ nCheck++;
+
+ String aFormatStr( ResId( KEY_FORMAT, pMgr ) );
+ pConfig->WriteKey( ByteString( aFormatStr, RTL_TEXTENCODING_UTF8 ), ByteString::CreateFromInt32( nCheck ) );
+
+ EndDialog( RET_OK );
+
+ return 0;
+}
diff --git a/goodies/source/filter.vcl/eppm/dlgeppm.hrc b/goodies/source/filter.vcl/eppm/dlgeppm.hrc
new file mode 100644
index 000000000000..e9e24ba05965
--- /dev/null
+++ b/goodies/source/filter.vcl/eppm/dlgeppm.hrc
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgeppm.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "goodies.hrc"
+
+#define BTN_OK 1
+#define BTN_CANCEL 1
+#define BTN_HELP 1
+#define GRP_FORMAT 1
+#define RB_RAW 1
+#define RB_ASCII 2
diff --git a/goodies/source/filter.vcl/eppm/dlgeppm.hxx b/goodies/source/filter.vcl/eppm/dlgeppm.hxx
new file mode 100644
index 000000000000..7a9f8edeb72e
--- /dev/null
+++ b/goodies/source/filter.vcl/eppm/dlgeppm.hxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgeppm.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _DLGEPPM_HXX_
+#define _DLGEPPM_HXX_
+#include <svtools/fltcall.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/group.hxx>
+#include <vcl/field.hxx>
+#include <svtools/stdctrl.hxx>
+
+
+/*************************************************************************
+|*
+|* Dialog zum Einstellen von Filteroptionen
+|*
+\************************************************************************/
+
+class Config;
+class ResMgr;
+
+class DlgExportEPPM : public ModalDialog
+{
+private:
+ GroupBox aGrpFormat;
+ RadioButton aRBRaw;
+ RadioButton aRBASCII;
+ OKButton aBtnOK;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ Config* pConfig;
+ ResMgr* pMgr;
+
+ DECL_LINK( OK, void * );
+
+public:
+ DlgExportEPPM( FltCallDialogParameter& rPara );
+};
+
+#endif // _DLGEPPM_HXX_
diff --git a/goodies/source/filter.vcl/eppm/dlgeppm.src b/goodies/source/filter.vcl/eppm/dlgeppm.src
new file mode 100644
index 000000000000..7f249795f6a3
--- /dev/null
+++ b/goodies/source/filter.vcl/eppm/dlgeppm.src
@@ -0,0 +1,198 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgeppm.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "dlgeppm.hrc"
+ModalDialog DLG_EXPORT_EPPM
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 133 , 67 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Text = "PPM Optionen" ;
+ Text [ ENGLISH ] = "PPM options" ;
+ Text [ english_us ] = "PPM Options" ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 73 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 73 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 73 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ GroupBox GRP_FORMAT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 60 , 54 ) ;
+ Text = "Datei Format" ;
+ Text [ ENGLISH ] = "file format" ;
+ Text[ italian ] = "Formato file";
+ Text[ portuguese_brazilian ] = "Datei Format";
+ Text[ portuguese ] = "Formato do ficheiro";
+ Text[ danish ] = "Filformat";
+ Text[ french ] = "Format de fichier";
+ Text[ swedish ] = "Filformat";
+ Text[ dutch ] = "Bestandsformaat";
+ Text[ spanish ] = "Formato de archivo";
+ Text[ english_us ] = "File format";
+ Text[ chinese_simplified ] = "Îļþ¸ñʽ";
+ Text[ russian ] = "Ôîðìàò ôàéëà";
+ Text[ polish ] = "Format pliku";
+ Text[ japanese ] = "̧²ÙŒ`Ž®";
+ Text[ chinese_traditional ] = "Àɮ׮榡";
+ Text[ arabic ] = "ÊäÓíÞ ÇáãáÝ";
+ Text[ dutch ] = "Bestandsformaat";
+ Text[ chinese_simplified ] = "Îļþ¸ñʽ";
+ Text[ greek ] = "ÌïñöÞ áñ÷åßïõ";
+ Text[ korean ] = "ÆÄÀÏ ¼­½Ä";
+ Text[ turkish ] = "Dosya formatý";
+ Text[ language_user1 ] = " ";
+ };
+ RadioButton RB_RAW
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text = "~Binär" ;
+ Text [ ENGLISH ] = "~raw" ;
+ TabStop = TRUE ;
+ Text[ italian ] = "~Binario";
+ Text[ portuguese_brazilian ] = "~Binär";
+ Text[ portuguese ] = "~Binário";
+ Text[ danish ] = "~Binær";
+ Text[ french ] = "~Binaire";
+ Text[ swedish ] = "~Binär";
+ Text[ dutch ] = "~Binair";
+ Text[ spanish ] = "~Binario";
+ Text[ english_us ] = "~Binary";
+ Text[ chinese_simplified ] = "¶þÔª(~B)";
+ Text[ russian ] = "Áèíàðíûé";
+ Text[ polish ] = "Binarny";
+ Text[ japanese ] = "ÊÞ²ÅØ(~B)";
+ Text[ language_user1 ] = " ";
+ Text[ chinese_traditional ] = "¤G¦ì¤¸(~B)";
+ Text[ arabic ] = "ËäÇÆí";
+ Text[ dutch ] = "~Binair";
+ Text[ chinese_simplified ] = "¶þÔª(~B)";
+ Text[ greek ] = "Äõáäéêü";
+ Text[ korean ] = "¹ÙÀ̳ʸ®(~B)";
+ Text[ turkish ] = "Ýkili";
+ };
+ RadioButton RB_ASCII
+ {
+ Pos = MAP_APPFONT ( 12 , 27 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text = "~Text" ;
+ Text [ ENGLISH ] = "~text" ;
+ TabStop = TRUE ;
+ Text[ italian ] = "~Testo";
+ Text[ portuguese_brazilian ] = "~Text";
+ Text[ portuguese ] = "~Texto";
+ Text[ danish ] = "~Tekst";
+ Text[ french ] = "~Texte";
+ Text[ swedish ] = "~Text";
+ Text[ dutch ] = "~Tekst";
+ Text[ spanish ] = "~Texto";
+ Text[ english_us ] = "~Text";
+ Text[ chinese_simplified ] = "ÎÄ×Ö(~T)";
+ Text[ russian ] = "Òåêñò";
+ Text[ polish ] = "Tekst";
+ Text[ japanese ] = "÷½Ä(~T)";
+ Text[ chinese_traditional ] = "¤å¦r(~T)";
+ Text[ arabic ] = "ÇáäÕ";
+ Text[ dutch ] = "~Tekst";
+ Text[ chinese_simplified ] = "ÎÄ×Ö(~T)";
+ Text[ greek ] = "Êåßìåíï";
+ Text[ korean ] = "ÅؽºÆ®(~T)";
+ Text[ turkish ] = "Metin";
+ Text[ language_user1 ] = " ";
+ };
+ Text[ italian ] = "Opzioni PPM";
+ Text[ portuguese_brazilian ] = "PPM Optionen";
+ Text[ portuguese ] = "Opções PPM";
+ Text[ danish ] = "PPM indstillinger";
+ Text[ french ] = "Options PPM";
+ Text[ swedish ] = "PPM alternativ";
+ Text[ dutch ] = "PPM-opties";
+ Text[ spanish ] = "Opciones PPM ";
+ Text[ chinese_simplified ] = "PPM Ñ¡Ïî";
+ Text[ russian ] = "Ïàðàìåòðû PPM";
+ Text[ polish ] = "Opcje PPM";
+ Text[ japanese ] = "PPM µÌß¼®Ý";
+ Text[ chinese_traditional ] = "PPM¿ï¶µ";
+ Text[ arabic ] = "PPM ÎíÇÑÇÊ";
+ Text[ dutch ] = "PPM-opties";
+ Text[ chinese_simplified ] = "PPM Ñ¡Ïî";
+ Text[ greek ] = "ÅðéëïãÝò PPM";
+ Text[ korean ] = "PPM ¿É¼Ç";
+ Text[ turkish ] = "PPM seçenekleri";
+ Text[ language_user1 ] = " ";
+};
diff --git a/goodies/source/filter.vcl/eppm/eppm.cxx b/goodies/source/filter.vcl/eppm/eppm.cxx
new file mode 100644
index 000000000000..0733f05e09dc
--- /dev/null
+++ b/goodies/source/filter.vcl/eppm/eppm.cxx
@@ -0,0 +1,347 @@
+/*************************************************************************
+ *
+ * $RCSfile: eppm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <vcl/svapp.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/config.hxx>
+#include <vcl/msgbox.hxx>
+#include <svtools/solar.hrc>
+#include <svtools/fltcall.hxx>
+#include "strings.hrc"
+#include "dlgeppm.hrc"
+#include "dlgeppm.hxx"
+
+//============================ PPMWriter ==================================
+
+class PPMWriter {
+
+private:
+
+ PFilterCallback mpCallback;
+ void * mpCallerData;
+
+ SvStream* mpOStm; // Die auszugebende PPM-Datei
+ USHORT mpOStmOldModus;
+
+ BOOL mbStatus;
+ sal_Int32 mnMode;
+ BitmapReadAccess* mpAcc;
+ ULONG mnWidth, mnHeight; // Bildausmass in Pixeln
+
+ BOOL ImplCallback( USHORT nPercent );
+ BOOL ImplWriteHeader();
+ void ImplWriteBody();
+ void ImplWriteNumber( sal_Int32 );
+
+public:
+ PPMWriter();
+ ~PPMWriter();
+
+ BOOL WritePPM( const Graphic& rGraphic, SvStream& rPPM,
+ PFilterCallback pCallback, void* pCallerdata,
+ Config* pOptionsConfig );
+};
+
+//=================== Methoden von PPMWriter ==============================
+
+PPMWriter::PPMWriter() :
+ mpAcc ( NULL ),
+ mbStatus ( TRUE )
+{
+}
+
+// ------------------------------------------------------------------------
+
+PPMWriter::~PPMWriter()
+{
+}
+
+// ------------------------------------------------------------------------
+
+BOOL PPMWriter::ImplCallback( USHORT nPercent )
+{
+ if ( mpCallback != NULL )
+ {
+ if ( ( (*mpCallback)( mpCallerData, nPercent ) ) == TRUE )
+ {
+ mpOStm->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL PPMWriter::WritePPM( const Graphic& rGraphic, SvStream& rPPM,
+ PFilterCallback pCallback, void* pCallerdata,
+ Config* pOptionsConfig )
+{
+
+ mpOStm = &rPPM;
+ mpCallback = pCallback;
+ mpCallerData = pCallerdata;
+
+ if ( pOptionsConfig )
+ {
+ mnMode = pOptionsConfig->ReadKey( "PPM-EXPORT-FORMAT", "0" ).ToInt32();
+ }
+
+ BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+ Bitmap aBmp = aBmpEx.GetBitmap();
+ aBmp.Convert( BMP_CONVERSION_24BIT );
+
+ mpOStmOldModus = mpOStm->GetNumberFormatInt();
+ mpOStm->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+
+ mpAcc = aBmp.AcquireReadAccess();
+ if( mpAcc )
+ {
+ if ( ImplWriteHeader() )
+ {
+ ImplWriteBody();
+ }
+ aBmp.ReleaseAccess( mpAcc );
+ }
+ else
+ mbStatus = FALSE;
+
+ mpOStm->SetNumberFormatInt( mpOStmOldModus );
+
+ return mbStatus;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL PPMWriter::ImplWriteHeader()
+{
+ mnWidth = mpAcc->Width();
+ mnHeight = mpAcc->Height();
+ if ( mnWidth && mnHeight )
+ {
+ if ( mnMode == 0 )
+ *mpOStm << "P6\x0a";
+ else
+ *mpOStm << "P3\x0a";
+
+ ImplWriteNumber( mnWidth );
+ *mpOStm << (BYTE)32;
+ ImplWriteNumber( mnHeight );
+ *mpOStm << (BYTE)32;
+ ImplWriteNumber( 255 ); // max. col.
+ *mpOStm << (BYTE)10;
+ }
+ else
+ mbStatus = FALSE;
+
+ return mbStatus;
+}
+
+// ------------------------------------------------------------------------
+
+void PPMWriter::ImplWriteBody()
+{
+ if ( mnMode == 0 )
+ {
+ for ( ULONG y = 0; y < mnHeight; y++ )
+ {
+ for ( ULONG x = 0; x < mnWidth; x++ )
+ {
+ const BitmapColor& rColor = mpAcc->GetPixel( y, x );
+ *mpOStm << rColor.GetRed();
+ *mpOStm << rColor.GetGreen();
+ *mpOStm << rColor.GetBlue();
+ }
+ }
+ }
+ else
+ {
+ for ( ULONG y = 0; y < mnHeight; y++ )
+ {
+ int nCount = 70;
+ for ( ULONG x = 0; x < mnWidth; x++ )
+ {
+ BYTE i, nDat[3], nNumb;
+ if ( nCount < 0 )
+ {
+ nCount = 69;
+ *mpOStm << (BYTE)10;
+ }
+ nDat[0] = mpAcc->GetPixel( y, x ).GetRed();
+ nDat[1] = mpAcc->GetPixel( y, x ).GetGreen();
+ nDat[2] = mpAcc->GetPixel( y, x ).GetBlue();
+ for ( i = 0; i < 3; i++ )
+ {
+ if ( ( nNumb = nDat[ i ] / 100 ) )
+ {
+ *mpOStm << (BYTE)( nNumb + '0' );
+ nDat[ i ] -= ( nNumb * 100 );
+ nNumb = nDat[ i ] / 10;
+ *mpOStm << (BYTE)( nNumb + '0' );
+ nDat[ i ] -= ( nNumb * 10 );
+ *mpOStm << (BYTE)( nDat[ i ] + '0' );
+ nCount -= 4;
+ }
+ else if ( ( nNumb = nDat[ i ] / 10 ) )
+ {
+ *mpOStm << (BYTE)( nNumb + '0' );
+ nDat[ i ] -= ( nNumb * 10 );
+ *mpOStm << (BYTE)( nDat[ i ] + '0' );
+ nCount -= 3;
+ }
+ else
+ {
+ *mpOStm << (BYTE)( nDat[ i ] + '0' );
+ nCount -= 2;
+ }
+ *mpOStm << (BYTE)' ';
+ }
+ }
+ *mpOStm << (BYTE)10;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+// eine Dezimalzahl im ASCII format wird in den Stream geschrieben
+
+void PPMWriter::ImplWriteNumber( sal_Int32 nNumber )
+{
+ const ByteString aNum( ByteString::CreateFromInt32( nNumber ) );
+
+ for( sal_Int32 n = 0, nLen = aNum.Len(); n < nLen; n++ )
+ *mpOStm << aNum.GetChar( n );
+
+}
+
+// ------------------------------------------------------------------------
+
+// ---------------------
+// - exported function -
+// ---------------------
+
+extern "C" BOOL __LOADONCALLAPI GraphicExport( SvStream& rStream, Graphic& rGraphic,
+ PFilterCallback pCallback, void* pCallerData,
+ Config* pOptionsConfig, BOOL )
+{
+ PPMWriter aPPMWriter;
+
+ return aPPMWriter.WritePPM( rGraphic, rStream, pCallback, pCallerData, pOptionsConfig );
+}
+
+// ------------------------------------------------------------------------
+
+extern "C" BOOL __LOADONCALLAPI DoExportDialog( FltCallDialogParameter& rPara )
+{
+ BOOL bRet = FALSE;
+
+ if ( rPara.pWindow && rPara.pCfg )
+ {
+ ByteString aResMgrName( "epp" );
+ ResMgr* pResMgr;
+
+ aResMgrName.Append( ByteString::CreateFromInt32( SOLARUPD ) );
+ pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetAppInternational(). GetLanguage() );
+
+ if( pResMgr )
+ {
+ rPara.pResMgr = pResMgr;
+ bRet = ( DlgExportEPPM( rPara ).Execute() == RET_OK );
+ delete pResMgr;
+ }
+ else
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+#pragma hdrstop
+
+// ------------------------------------------------------------------------
+
+// ---------------
+// - Win16 trash -
+// ---------------
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0;
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+ if ( nHeap )
+ UnlockData( 0 );
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
diff --git a/goodies/source/filter.vcl/eppm/eppmstr.src b/goodies/source/filter.vcl/eppm/eppmstr.src
new file mode 100644
index 000000000000..aa78128a25f4
--- /dev/null
+++ b/goodies/source/filter.vcl/eppm/eppmstr.src
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * $RCSfile: eppmstr.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include "strings.hrc"
+
+// Key fuer den Dialog
+String KEY_FORMAT
+{
+ Text = "PPM-EXPORT-FORMAT";
+};
diff --git a/goodies/source/filter.vcl/eppm/makefile.mk b/goodies/source/filter.vcl/eppm/makefile.mk
new file mode 100644
index 000000000000..a3f6207e6f88
--- /dev/null
+++ b/goodies/source/filter.vcl/eppm/makefile.mk
@@ -0,0 +1,183 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=eppm
+TARGET2=epp
+DEPTARGET=veppm
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SRCFILES= dlgeppm.src \
+ eppmstr.src
+
+SLOFILES = $(SLO)$/eppm.obj \
+ $(SLO)$/dlgeppm.obj
+
+# ==========================================================================
+
+RESLIB1NAME=$(TARGET2)
+RESLIB1SRSFILES=$(SRS)$/$(TARGET).srs
+
+SHL1TARGET= epp$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= eppm
+SHL1STDLIBS= $(TOOLSLIB) \
+ $(SVLIB) \
+ $(CPPULIB) \
+ $(SVTOOLLIB)
+
+SHL1DEPN= $(LB)$/eppm.lib
+SHL1LIBS= $(SLB)$/eppm.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/eppm.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicExport >>$@
+ @echo DoExportDialog >>$@
+.ELSE
+ @echo _GraphicExport >>$@
+ @echo _DoExportDialog >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET).DLL >>$@
+ @ldump -E1 -A $(SLB)$/eppm.lib >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicExport >>$@
+ @echo DoExportDialog >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/eppm/strings.hrc b/goodies/source/filter.vcl/eppm/strings.hrc
new file mode 100644
index 000000000000..851e6b569d01
--- /dev/null
+++ b/goodies/source/filter.vcl/eppm/strings.hrc
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * $RCSfile: strings.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#define KEY_FORMAT 256
diff --git a/goodies/source/filter.vcl/eps/dlgeps.cxx b/goodies/source/filter.vcl/eps/dlgeps.cxx
new file mode 100644
index 000000000000..4e189c05b363
--- /dev/null
+++ b/goodies/source/filter.vcl/eps/dlgeps.cxx
@@ -0,0 +1,221 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgeps.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma hdrstop
+#include <tools/ref.hxx>
+#include <vcl/config.hxx>
+#include <vcl/msgbox.hxx>
+#include "dlgeps.hxx"
+#include "dlgeps.hrc"
+#include "strings.hrc"
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+
+DlgExportEPS::DlgExportEPS( FltCallDialogParameter& rPara ) :
+ ModalDialog ( rPara.pWindow, ResId( DLG_EXPORT_EPS, rPara.pResMgr ) ),
+ aGrpPreview ( this, ResId( GRP_PREVIEW ) ),
+ aCBPreviewTiff ( this, ResId( CB_PREVIEW_TIFF ) ),
+ aCBPreviewEPSI ( this, ResId( CB_PREVIEW_EPSI ) ),
+ aGrpVersion ( this, ResId( GRP_VERSION ) ),
+ aRBLevel1 ( this, ResId( RB_LEVEL1 ) ),
+ aRBLevel2 ( this, ResId( RB_LEVEL2 ) ),
+ aGrpColor ( this, ResId( GRP_COLOR ) ),
+ aRBColor ( this, ResId( RB_COLOR ) ),
+ aRBGrayscale ( this, ResId( RB_GRAYSCALE ) ),
+ aGrpCompression ( this, ResId( GRP_COMPRESSION ) ),
+ aRBCompressionLZW ( this, ResId( RB_COMPRESSION_LZW ) ),
+ aRBCompressionNone ( this, ResId( RB_COMPRESSION_NONE ) ),
+ aBtnOK ( this, ResId( BTN_OK ) ),
+ aBtnCancel ( this, ResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ResId( BTN_HELP ) ),
+ pConfig ( rPara.pCfg ),
+ pMgr ( rPara.pResMgr )
+{
+ FreeResource();
+
+ // Config-Parameter lesen
+ String aPrevStr( ResId( KEY_PREVIEW, pMgr ) );
+ String aVersionStr( ResId( KEY_VERSION, pMgr ) );
+ String aColorStr( ResId( KEY_COLOR, pMgr ) );
+ String aComprStr( ResId( KEY_COMPR, pMgr ) );
+
+ sal_Int32 nPreview = pConfig->ReadKey( ByteString( aPrevStr, RTL_TEXTENCODING_UTF8 ) ).ToInt32();
+ sal_Int32 nVersion = pConfig->ReadKey( ByteString( aVersionStr, RTL_TEXTENCODING_UTF8 ) ).ToInt32();
+ sal_Int32 nColor = pConfig->ReadKey( ByteString( aColorStr, RTL_TEXTENCODING_UTF8 ) ).ToInt32();
+ sal_Int32 nCompr = pConfig->ReadKey( ByteString( aComprStr, RTL_TEXTENCODING_UTF8 ) ).ToInt32();
+
+ BOOL bCheck = FALSE;
+ if ( nPreview & 1 )
+ bCheck = TRUE;
+ aCBPreviewTiff.Check( bCheck );
+ if ( nPreview & 2 )
+ bCheck = TRUE;
+ aCBPreviewEPSI.Check( bCheck );
+
+ bCheck = FALSE;
+ if ( nVersion == 1 )
+ bCheck ^= TRUE;
+ aRBLevel1.Check( bCheck );
+ bCheck ^= TRUE;
+ aRBLevel2.Check( bCheck );
+
+ bCheck = FALSE;
+ if ( nColor == 1 )
+ bCheck ^= TRUE;
+ aRBColor.Check( bCheck );
+ bCheck ^= TRUE;
+ aRBGrayscale.Check( bCheck );
+
+ bCheck = FALSE;
+ if ( nCompr == 1 )
+ bCheck ^= TRUE;
+ aRBCompressionLZW.Check( bCheck );
+ bCheck ^= TRUE;
+ aRBCompressionNone.Check( bCheck );
+
+ if ( aRBLevel1.IsChecked() )
+ {
+ aRBColor.Disable();
+ aRBGrayscale.Disable();
+ aRBCompressionNone.Disable();
+ aRBCompressionLZW.Disable();
+ aRBCompressionNone.Disable();
+ }
+
+ aBtnOK.SetClickHdl( LINK( this, DlgExportEPS, OK ) );
+ aRBLevel1.SetClickHdl( LINK( this, DlgExportEPS, LEVEL1 ) );
+ aRBLevel2.SetClickHdl( LINK( this, DlgExportEPS, LEVEL2 ) );
+}
+
+/*************************************************************************
+|*
+|* Speichert eingestellte Werte in ini-Datei
+|*
+\************************************************************************/
+
+IMPL_LINK( DlgExportEPS, OK, void *, EMPTYARG )
+{
+
+ // Config-Parameter schreiben
+ sal_Int32 nCheck = 0;
+ if ( aCBPreviewTiff.IsChecked() )
+ nCheck++;
+ if ( aCBPreviewEPSI.IsChecked() )
+ nCheck += 2;
+
+ String aPrevStr( ResId( KEY_PREVIEW, pMgr ) );
+ pConfig->WriteKey( ByteString( aPrevStr, RTL_TEXTENCODING_UTF8 ), ByteString::CreateFromInt32( nCheck ) );
+
+ nCheck = 1;
+ if ( aRBLevel2.IsChecked() )
+ nCheck++;
+ String aVersionStr( ResId( KEY_VERSION, pMgr ) );
+ pConfig->WriteKey( ByteString( aVersionStr, RTL_TEXTENCODING_UTF8 ), ByteString::CreateFromInt32( nCheck ) );
+
+ nCheck = 1;
+ if ( aRBGrayscale.IsChecked() )
+ nCheck++;
+ String aColorStr( ResId( KEY_COLOR, pMgr ) );
+ pConfig->WriteKey( ByteString( aColorStr, RTL_TEXTENCODING_UTF8 ), ByteString::CreateFromInt32( nCheck ) );
+
+ nCheck = 1;
+ if ( aRBCompressionNone.IsChecked() )
+ nCheck++;
+ String aComprStr( ResId( KEY_COMPR, pMgr ) );
+ pConfig->WriteKey( ByteString( aComprStr, RTL_TEXTENCODING_UTF8 ), ByteString::CreateFromInt32( nCheck ) );
+
+ EndDialog( RET_OK );
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( DlgExportEPS, LEVEL1, void*, EMPTYARG )
+{
+ if ( aRBLevel1.IsChecked() )
+ {
+ aRBColor.Disable();
+ aRBGrayscale.Disable();
+ aRBCompressionLZW.Disable();
+ aRBCompressionNone.Disable();
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( DlgExportEPS, LEVEL2, void*, EMPTYARG )
+{
+ if ( aRBLevel2.IsChecked() )
+ {
+ aRBColor.Enable();
+ aRBGrayscale.Enable();
+ aRBCompressionLZW.Enable();
+ aRBCompressionNone.Enable();
+ }
+ return 0;
+}
+
diff --git a/goodies/source/filter.vcl/eps/dlgeps.hrc b/goodies/source/filter.vcl/eps/dlgeps.hrc
new file mode 100644
index 000000000000..d7a547839311
--- /dev/null
+++ b/goodies/source/filter.vcl/eps/dlgeps.hrc
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgeps.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "goodies.hrc"
+
+#define BTN_OK 1
+#define BTN_CANCEL 1
+#define BTN_HELP 1
+#define GRP_PREVIEW 1
+#define GRP_VERSION 2
+#define GRP_COLOR 3
+#define GRP_COMPRESSION 4
+#define CB_PREVIEW_TIFF 1
+#define CB_PREVIEW_EPSI 2
+#define RB_LEVEL1 3
+#define RB_LEVEL2 4
+#define RB_COLOR 5
+#define RB_GRAYSCALE 6
+#define RB_COMPRESSION_LZW 7
+#define RB_COMPRESSION_NONE 8
diff --git a/goodies/source/filter.vcl/eps/dlgeps.hxx b/goodies/source/filter.vcl/eps/dlgeps.hxx
new file mode 100644
index 000000000000..b7f48b9903af
--- /dev/null
+++ b/goodies/source/filter.vcl/eps/dlgeps.hxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgeps.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DLGEPS_HXX_
+#define _DLGEPS_HXX_
+#include <svtools/fltcall.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/group.hxx>
+#include <vcl/field.hxx>
+#include <svtools/stdctrl.hxx>
+
+
+/*************************************************************************
+|*
+|* Dialog zum Einstellen von Filteroptionen
+|*
+\************************************************************************/
+
+class Config;
+class ResMgr;
+
+class DlgExportEPS : public ModalDialog
+{
+private:
+ GroupBox aGrpPreview;
+ CheckBox aCBPreviewTiff;
+ CheckBox aCBPreviewEPSI;
+ GroupBox aGrpVersion;
+ RadioButton aRBLevel1;
+ RadioButton aRBLevel2;
+ GroupBox aGrpColor;
+ RadioButton aRBColor;
+ RadioButton aRBGrayscale;
+ GroupBox aGrpCompression;
+ RadioButton aRBCompressionLZW;
+ RadioButton aRBCompressionNone;
+ OKButton aBtnOK;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ Config* pConfig;
+ ResMgr* pMgr;
+
+ DECL_LINK( OK, void * );
+ DECL_LINK( LEVEL1, void* );
+ DECL_LINK( LEVEL2, void* );
+
+public:
+ DlgExportEPS( FltCallDialogParameter& rPara );
+};
+
+#endif // _DLGEPS_HXX_
diff --git a/goodies/source/filter.vcl/eps/dlgeps.src b/goodies/source/filter.vcl/eps/dlgeps.src
new file mode 100644
index 000000000000..94fb44a3fa2f
--- /dev/null
+++ b/goodies/source/filter.vcl/eps/dlgeps.src
@@ -0,0 +1,459 @@
+/*************************************************************************
+ *
+ * $RCSfile: dlgeps.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "dlgeps.hrc"
+ModalDialog DLG_EXPORT_EPS
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 149 , 198 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Text = "EPS Export Optionen" ;
+ Text [ ENGLISH ] = "EPS export options" ;
+ Text[ portuguese ] = "Opções exportação EPS";
+ Text[ russian ] = "Ïàðàìåòðû ýêñïîðòà EPS";
+ Text[ dutch ] = "EPS export opties";
+ Text[ french ] = "Options d'export EPS";
+ Text[ spanish ] = "Opciones Exportación EPS";
+ Text[ italian ] = "Opzioni d'esportazione EPS";
+ Text[ danish ] = "EPS eksportindstillinger";
+ Text[ swedish ] = "EPS exportalternativ";
+ Text[ polish ] = "Opcje eksportowe EPS";
+ Text[ english_us ] = "EPS Export Options";
+ Text[ portuguese_brazilian ] = "EPS Export Optionen";
+ Text[ japanese ] = "EPS ´¸½Î߰ĵÌß¼®Ý";
+ Text[ chinese_simplified ] = "EPS Êä³öÑ¡Ïî";
+ Text[ chinese_traditional ] = "EPS ¿é¥X¿ï¶µ";
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 93 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 93 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 93 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+
+ GroupBox GRP_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 80 , 42 ) ;
+ Text = "Vorschau";
+ Text [ ENGLISH ] = "Preview";
+ Text[ italian ] = "Anteprima";
+ Text[ portuguese_brazilian ] = "Vorschau";
+ Text[ portuguese ] = "Previsualização";
+ Text[ danish ] = "Eksempel";
+ Text[ french ] = "Aperçu";
+ Text[ swedish ] = "Förhandsvisning";
+ Text[ dutch ] = "Voorbeeld";
+ Text[ spanish ] = "Previsualización";
+ Text[ english_us ] = "Preview";
+ Text[ chinese_simplified ] = "Ô¤ÊÓ";
+ Text[ russian ] = "Ïðîñìîòð";
+ Text[ polish ] = "Podgl¹d";
+ Text[ japanese ] = "ÌßÚËÞ­°";
+ Text[ chinese_traditional ] = "À˵ø";
+ Text[ arabic ] = "ãÚÇíäÉ";
+ Text[ dutch ] = "Voorbeeld";
+ Text[ chinese_simplified ] = "Ô¤ÊÓ";
+ Text[ greek ] = "Ðñïåðéóêüðçóç";
+ Text[ korean ] = "¹Ì¸® º¸±â";
+ Text[ turkish ] = "Önizleme";
+ };
+ CheckBox CB_PREVIEW_TIFF
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 71 , 10 ) ;
+ Text = "~Vorschau Bild (Tiff)" ;
+ Text [ ENGLISH ] = "~Preview picture (Tiff)" ;
+ TabStop = TRUE ;
+ Text[ italian ] = "~Anteprima immagine (Tiff)";
+ Text[ portuguese_brazilian ] = "~Vorschau Bild (Tiff)";
+ Text[ portuguese ] = "~Previzualizar imagem (Tiff)";
+ Text[ danish ] = "~Vis billede (Tiff)";
+ Text[ french ] = "~Aperçu (Tiff)";
+ Text[ swedish ] = "Förhandsvisning bild (Tiff)";
+ Text[ dutch ] = "~Voorbeeldvenster (TIFF)";
+ Text[ spanish ] = "~Previsualización (Tiff)";
+ Text[ english_us ] = "Image ~preview (TIFF)";
+ Text[ chinese_simplified ] = "ͼÏñÔ¤ÊÓ(~TIFF)";
+ Text[ russian ] = "Ïðîñìîòð êàðòèíêè (TIFF)";
+ Text[ polish ] = "Podgl¹d rysunku (Tiff)";
+ Text[ japanese ] = "}‚ÌÌßÚËÞ­° (Tiff)(~P)";
+ Text[ arabic ] = "ãÚÇíäÉ ÇáÕæÑÉ(TIFF) ";
+ Text[ dutch ] = "~Voorbeeldvenster (TIFF)";
+ Text[ chinese_simplified ] = "ͼÏñÔ¤ÊÓ(~TIFF)";
+ Text[ greek ] = "Ðñïåðéóêüðçóç åéêüíáò (TIFF)";
+ Text[ korean ] = "±×¸² ¹Ì¸® º¸±â (TIFF)(~P)";
+ Text[ chinese_traditional ] = "¹Ï¤ù¹wÄý(TIFF)(~P)";
+ Text[ turkish ] = "Resim önizleme (TIFF)";
+ };
+ CheckBox CB_PREVIEW_EPSI
+ {
+ Pos = MAP_APPFONT ( 12 , 30 ) ;
+ Size = MAP_APPFONT ( 71, 10 ) ;
+ Text = "~Interchange (EPSI)" ;
+ Text [ ENGLISH ] = "~Interchange (EPSI)" ;
+ TabStop = TRUE ;
+ Text[ english_us ] = "~Interchange (EPSI)";
+ Text[ portuguese ] = "~Interchange (EPSI)";
+ Text[ russian ] = "~Interchange (EPSI)";
+ Text[ greek ] = "~Interchange (EPSI)";
+ Text[ dutch ] = "~Interchange (EPSI)";
+ Text[ french ] = "~Interchange (EPSI)";
+ Text[ spanish ] = "~Interchange (EPSI)";
+ Text[ italian ] = "~Interchange (EPSI)";
+ Text[ danish ] = "~Interchange (EPSI)";
+ Text[ swedish ] = "Interchange (EPSI)";
+ Text[ polish ] = "~Interchange (EPSI)";
+ Text[ portuguese_brazilian ] = "~Interchange (EPSI)";
+ Text[ japanese ] = "²ÝÀ°ÁªÝ¼Þ(EPSI)(~I)";
+ Text[ korean ] = "ÀÎÅÍüÀÎÁö (EPSI)(~I)";
+ Text[ chinese_simplified ] = "»¥»»(EPS~I)";
+ Text[ chinese_traditional ] = "¤¬´«(EPS~I)";
+ Text[ arabic ] = "~Interchange (EPSI)";
+ Text[ turkish ] = "Interchange (EPSI)";
+ };
+
+ GroupBox GRP_VERSION
+ {
+ Pos = MAP_APPFONT ( 6 , 51 ) ;
+ Size = MAP_APPFONT ( 80 , 42 ) ;
+ Text = "Version";
+ Text [ ENGLISH ] = "Version";
+ Text[ italian ] = "Versione";
+ Text[ portuguese_brazilian ] = "Version";
+ Text[ portuguese ] = "Versão";
+ Text[ danish ] = "Version";
+ Text[ french ] = "Version";
+ Text[ swedish ] = "Version";
+ Text[ dutch ] = "Versie";
+ Text[ spanish ] = "Versión";
+ Text[ english_us ] = "Version";
+ Text[ chinese_simplified ] = "°æ±¾";
+ Text[ russian ] = "Âåðñèÿ";
+ Text[ polish ] = "Wersja";
+ Text[ japanese ] = "ÊÞ°¼Þ®Ý";
+ Text[ chinese_traditional ] = "ª©¥»";
+ Text[ arabic ] = "ÅÕÏÇÑ";
+ Text[ dutch ] = "Versie";
+ Text[ chinese_simplified ] = "°æ±¾";
+ Text[ greek ] = "¸êäïóç";
+ Text[ korean ] = "¹öÀü";
+ Text[ turkish ] = "Sürüm";
+ };
+ RadioButton RB_LEVEL1
+ {
+ Pos = MAP_APPFONT ( 12 , 62 ) ;
+ Size = MAP_APPFONT ( 71 , 10 ) ;
+ Text = "Level ~1" ;
+ Text [ ENGLISH ] = "Level ~1" ;
+ TabStop = TRUE ;
+ Text[ italian ] = "Livello ~1";
+ Text[ portuguese_brazilian ] = "Level ~1";
+ Text[ portuguese ] = "Nível ~1";
+ Text[ danish ] = "Niveau ~1";
+ Text[ french ] = "Niveau ~1";
+ Text[ swedish ] = "Nivå ~1";
+ Text[ dutch ] = "Level ~1";
+ Text[ spanish ] = "Nivel ~1";
+ Text[ english_us ] = "Level ~1";
+ Text[ chinese_simplified ] = "¼¶±ð ~1";
+ Text[ russian ] = "Óðîâåíü 1";
+ Text[ polish ] = "Poziom 1";
+ Text[ japanese ] = "ÚÍÞÙ 1";
+ Text[ chinese_traditional ] = "¯Å§O ~1";
+ Text[ arabic ] = "ÇáãÓÊæì 1";
+ Text[ dutch ] = "Level ~1";
+ Text[ chinese_simplified ] = "¼¶±ð ~1";
+ Text[ greek ] = "Åðßðåäï ~1";
+ Text[ korean ] = "·¹º§ ~1";
+ Text[ turkish ] = "Düzey ~1";
+ };
+ RadioButton RB_LEVEL2
+ {
+ Pos = MAP_APPFONT ( 12 , 78 ) ;
+ Size = MAP_APPFONT ( 71, 10 ) ;
+ Text = "Level ~2" ;
+ Text [ ENGLISH ] = "Level ~2" ;
+ TabStop = TRUE ;
+ Text[ italian ] = "Livello ~2";
+ Text[ portuguese_brazilian ] = "Level ~2";
+ Text[ portuguese ] = "Nível ~2";
+ Text[ danish ] = "Niveau ~2";
+ Text[ french ] = "Niveau ~2";
+ Text[ swedish ] = "Nivå ~2";
+ Text[ dutch ] = "Level ~2";
+ Text[ spanish ] = "Nivel ~2";
+ Text[ english_us ] = "Level ~2";
+ Text[ chinese_simplified ] = "¼¶±ð ~2";
+ Text[ russian ] = "Óðîâåíü 2";
+ Text[ polish ] = "Poziom 2";
+ Text[ japanese ] = "ÚÍÞÙ 2";
+ Text[ chinese_traditional ] = "¯Å§O ~2";
+ Text[ arabic ] = "ÇáãÓÊæì 2";
+ Text[ dutch ] = "Level ~2";
+ Text[ chinese_simplified ] = "¼¶±ð ~2";
+ Text[ greek ] = "Åðßðåäï ~2";
+ Text[ korean ] = "·¹º§ ~2";
+ Text[ turkish ] = "Düzey ~2";
+ };
+
+ GroupBox GRP_COLOR
+ {
+ Pos = MAP_APPFONT ( 6 , 99 ) ;
+ Size = MAP_APPFONT ( 80 , 42 ) ;
+ Text = "Farb Format";
+ Text [ ENGLISH ] = "Color Type";
+ Text[ italian ] = "Formato colore";
+ Text[ portuguese_brazilian ] = "Farb Format";
+ Text[ portuguese ] = "Formato da cor";
+ Text[ danish ] = "Farveformat";
+ Text[ french ] = "Format de couleur";
+ Text[ swedish ] = "Färgformat";
+ Text[ dutch ] = "Kleuropmaak";
+ Text[ spanish ] = "Formato del color";
+ Text[ english_us ] = "Color format";
+ Text[ chinese_simplified ] = "ÑÕÉ«¸ñʽ";
+ Text[ russian ] = "Ôîðìàò öâåòà";
+ Text[ polish ] = "Format koloru";
+ Text[ japanese ] = "F‚Ì‘Ž®";
+ Text[ chinese_traditional ] = "ÃC¦â®æ¦¡";
+ Text[ arabic ] = "ÊäÓíÞ Çááæä";
+ Text[ dutch ] = "Kleuropmaak";
+ Text[ chinese_simplified ] = "ÑÕÉ«¸ñʽ";
+ Text[ greek ] = "ÌïñöÞ ÷ñþìáôïò";
+ Text[ korean ] = "»ö ¼­½Ä";
+ Text[ turkish ] = "Renk formatý";
+ };
+ RadioButton RB_COLOR
+ {
+ Pos = MAP_APPFONT ( 12 , 110 ) ;
+ Size = MAP_APPFONT ( 71, 10 ) ;
+ Text = "~Farbe" ;
+ Text [ ENGLISH ] = "~Color" ;
+ TabStop = TRUE ;
+ Text[ italian ] = "~Colore";
+ Text[ portuguese_brazilian ] = "~Farbe";
+ Text[ portuguese ] = "~Cor";
+ Text[ danish ] = "~Farve";
+ Text[ french ] = "~Couleur";
+ Text[ swedish ] = "~Färg";
+ Text[ dutch ] = "~Kleur";
+ Text[ spanish ] = "~Color";
+ Text[ english_us ] = "~Color";
+ Text[ chinese_simplified ] = "ÑÕÉ«(~C)";
+ Text[ russian ] = "Öâåò";
+ Text[ polish ] = "Kolor";
+ Text[ japanese ] = "F(~C)";
+ Text[ chinese_traditional ] = "ÃC¦â(~C)";
+ Text[ arabic ] = "Çááæä";
+ Text[ dutch ] = "~Kleur";
+ Text[ chinese_simplified ] = "ÑÕÉ«(~C)";
+ Text[ greek ] = "×ñþìá";
+ Text[ korean ] = "»ö(~C)";
+ Text[ turkish ] = "Renk";
+ };
+ RadioButton RB_GRAYSCALE
+ {
+ Pos = MAP_APPFONT ( 12 , 126 ) ;
+ Size = MAP_APPFONT ( 71, 10 ) ;
+ Text = "~Graustufen" ;
+ Text [ ENGLISH ] = "~Grayscale" ;
+ TabStop = TRUE ;
+ Text[ italian ] = "Toni di grigio";
+ Text[ portuguese_brazilian ] = "~Graustufen";
+ Text[ portuguese ] = "~Tons de cinzento";
+ Text[ danish ] = "Gråtoner";
+ Text[ french ] = "~Niveaux de gris";
+ Text[ swedish ] = "~Gråskalor";
+ Text[ dutch ] = "~Grijswaarden";
+ Text[ spanish ] = "~Escala de grises";
+ Text[ english_us ] = "~Grayscale";
+ Text[ chinese_simplified ] = "»Ò¶È(~G)";
+ Text[ russian ] = "Îòòåíêè ñåðîãî";
+ Text[ polish ] = "Odcienie szaroœci";
+ Text[ japanese ] = "¸ÞÚ°½¹°Ù(~G)";
+ Text[ chinese_traditional ] = "¦Ç¯Å(~G)";
+ Text[ arabic ] = "ÏÑÌÇÊ ÇáÑãÇÏí";
+ Text[ dutch ] = "~Grijswaarden";
+ Text[ chinese_simplified ] = "»Ò¶È(~G)";
+ Text[ greek ] = "ÄéáâÜèìéóç ôïõ ãêñé";
+ Text[ korean ] = "ȸ»öÁ¶(~G)";
+ Text[ turkish ] = "Gri tonlarý";
+ };
+
+ GroupBox GRP_COMPRESSION
+ {
+ Pos = MAP_APPFONT ( 6 , 147 ) ;
+ Size = MAP_APPFONT ( 80 , 42 ) ;
+ Text = "Kompression";
+ Text [ ENGLISH ] = "Compression";
+ Text[ italian ] = "Compressione";
+ Text[ portuguese_brazilian ] = "Kompression";
+ Text[ portuguese ] = "Compressão";
+ Text[ danish ] = "Kompression";
+ Text[ french ] = "Compression";
+ Text[ swedish ] = "Kompression";
+ Text[ dutch ] = "Compressie";
+ Text[ spanish ] = "Compresión";
+ Text[ english_us ] = "Compression";
+ Text[ chinese_simplified ] = "ѹËõ";
+ Text[ russian ] = "Óæàòèå";
+ Text[ polish ] = "Kompresja";
+ Text[ japanese ] = "ˆ³k";
+ Text[ chinese_traditional ] = "À£ÁY";
+ Text[ arabic ] = "ÖÛØ";
+ Text[ dutch ] = "Compressie";
+ Text[ chinese_simplified ] = "ѹËõ";
+ Text[ greek ] = "Óõìðßåóç";
+ Text[ korean ] = "¾ÐÃà";
+ Text[ turkish ] = "Sýkýþtýrma";
+ };
+ RadioButton RB_COMPRESSION_LZW
+ {
+ Pos = MAP_APPFONT ( 12 , 158 );
+ Size = MAP_APPFONT ( 71, 10 ) ;
+ Text = "LZW Kodierung" ;
+ Text [ ENGLISH ] = "LZW Compression" ;
+ TabStop = TRUE ;
+ Text[ italian ] = "Codifica LZW";
+ Text[ portuguese_brazilian ] = "LZW Kodierung";
+ Text[ portuguese ] = "Codificação LZW";
+ Text[ danish ] = "LZW kodning";
+ Text[ french ] = "Encodage LZW";
+ Text[ swedish ] = "LZW-kodning";
+ Text[ dutch ] = "LZW-codering";
+ Text[ spanish ] = "Codificación LZW";
+ Text[ english_us ] = "LZW encoding";
+ Text[ chinese_simplified ] = "LZW ±àÂë";
+ Text[ russian ] = "Êîäèðîâêà LZW";
+ Text[ polish ] = "Kodowanie LZW";
+ Text[ japanese ] = "LZW•„†‰»";
+ Text[ chinese_traditional ] = "LZW ½s½X";
+ Text[ arabic ] = "LZW ÊÑãíÒ";
+ Text[ dutch ] = "LZW-codering";
+ Text[ chinese_simplified ] = "LZW ±àÂë";
+ Text[ greek ] = "Êùäéêïðïßçóç LZW";
+ Text[ korean ] = "LZW ÀÎÄÚµù";
+ Text[ turkish ] = "LZW kodlamasý";
+ };
+ RadioButton RB_COMPRESSION_NONE
+ {
+ Pos = MAP_APPFONT ( 12 , 174 ) ;
+ Size = MAP_APPFONT ( 71, 10 ) ;
+ Text = "Keine" ;
+ Text [ ENGLISH ] = "None" ;
+ TabStop = TRUE ;
+ Text[ italian ] = "Senza";
+ Text[ portuguese_brazilian ] = "Keine";
+ Text[ portuguese ] = "Sem";
+ Text[ danish ] = "Ingen";
+ Text[ french ] = "Aucun(e)";
+ Text[ swedish ] = "Inga";
+ Text[ dutch ] = "Geen";
+ Text[ spanish ] = "Ninguno";
+ Text[ english_us ] = "None";
+ Text[ chinese_simplified ] = "ÎÞ";
+ Text[ russian ] = "Áåç";
+ Text[ polish ] = "Brak";
+ Text[ japanese ] = "‚È‚µ";
+ Text[ chinese_traditional ] = "µL";
+ Text[ arabic ] = "ÈÏæä";
+ Text[ dutch ] = "Geen";
+ Text[ chinese_simplified ] = "ÎÞ";
+ Text[ greek ] = "ÊáíÝíá";
+ Text[ korean ] = "¾øÀ½";
+ Text[ turkish ] = "Yok";
+ };
+ Text[ italian ] = "Opzioni d'esportazione EPS";
+ Text[ portuguese_brazilian ] = "EPS Export Optionen";
+ Text[ portuguese ] = "Opções exportação EPS";
+ Text[ danish ] = "EPS eksportindstillinger";
+ Text[ french ] = "Options d'export EPS";
+ Text[ swedish ] = "EPS exportalternativ";
+ Text[ dutch ] = "EPS export opties";
+ Text[ spanish ] = "Opciones Exportación EPS";
+ Text[ english_us ] = "EPS Export Options";
+ Text[ chinese_simplified ] = "EPS Êä³öÑ¡Ïî";
+ Text[ russian ] = "Ïàðàìåòðû ýêñïîðòà EPS";
+ Text[ polish ] = "Opcje eksportowe EPS";
+ Text[ japanese ] = "EPS ´¸½Î߰ĵÌß¼®Ý";
+ Text[ chinese_traditional ] = "EPS ¿é¥X¿ï¶µ";
+ Text[ arabic ] = "EPS ÎíÇÑÇÊ ÊÕÏíÑ";
+ Text[ dutch ] = "EPS export opties";
+ Text[ chinese_simplified ] = "EPS Êä³öÑ¡Ïî";
+ Text[ greek ] = "ÅðéëïãÝò åîáãùãÞò EPS";
+ Text[ korean ] = "EPS ³»º¸³»±â ¿É¼Ç";
+ Text[ turkish ] = "EPS dýþa aktarma seçenekleri";
+};
diff --git a/goodies/source/filter.vcl/eps/eps.cxx b/goodies/source/filter.vcl/eps/eps.cxx
new file mode 100644
index 000000000000..a59fbbd4446e
--- /dev/null
+++ b/goodies/source/filter.vcl/eps/eps.cxx
@@ -0,0 +1,2411 @@
+/*************************************************************************
+ *
+ * $RCSfile: eps.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <math.h>
+#include <vcl/sv.h>
+#include <tools/stream.hxx>
+#include <tools/bigint.hxx>
+#include <vcl/poly.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/config.hxx>
+#include <vcl/metaact.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/region.hxx>
+#include <vcl/metric.hxx>
+#include <vcl/font.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <vcl/gradient.hxx>
+#include <svtools/solar.hrc>
+#include <svtools/fltcall.hxx>
+#include "strings.hrc"
+#include "dlgeps.hrc"
+#include "dlgeps.hxx"
+
+#define POSTSCRIPT_BOUNDINGSEARCH 0x1000 // we only try to get the BoundingBox
+ // in the first 4096 bytes
+
+#define EPS_PREVIEW_TIFF 1
+#define EPS_PREVIEW_EPSI 2
+
+#define EPS_SCALING_FAKTOR 0.1
+
+#define PS_LINESIZE 70 // maximum number of characters a line in the output
+
+#define PS_NONE 0 // formating mode: action which is inserted behind the output
+#define PS_SPACE 1
+#define PS_RET 2
+#define PS_WRAP 4
+
+// -----------------------------Feld-Typen-------------------------------
+
+struct ChrSet
+{
+ struct ChrSet * pSucc;
+ BYTE nSet;
+ String aName;
+ FontWeight eWeight;
+};
+
+struct StackMember
+{
+ struct StackMember * pSucc;
+ Color aGlobalCol;
+ BOOL bLineCol;
+ Color aLineCol;
+ BOOL bFillCol;
+ Color aFillCol;
+ Color aTextCol;
+ BOOL bTextFillCol;
+ Color aTextFillCol;
+ Color aBackgroundCol;
+ Font aFont;
+ MapMode aMapMode;
+ double nXScale;
+ double nYScale;
+ double nXOrig;
+ double nYOrig;
+ BOOL bRegionChanged;
+ Region bClipRegion;
+ TextAlign eTextAlign;
+ Region aClipReg;
+};
+
+struct PSLZWCTreeNode
+{
+
+ PSLZWCTreeNode* pBrother; // naechster Knoten, der den selben Vater hat
+ PSLZWCTreeNode* pFirstChild; // erster Sohn
+ USHORT nCode; // Der Code fuer den String von Pixelwerten, der sich ergibt, wenn
+ USHORT nValue; // Der Pixelwert
+};
+
+class PSWriter
+{
+private:
+ BOOL mbStatus;
+ ULONG mnLevelWarning; // number of embedded eps files which was not exported
+ PFilterCallback mpCallback;
+ void* mpCallerData;
+ ULONG mnLastPercent; // Mit welcher Zahl pCallback zuletzt aufgerufen wurde.
+ UINT32 mnLatestPush; // offset auf streamposition, an der zuletzt gepusht wurde
+
+ long mnLevel; // dialog options
+ BOOL mbGrayScale;
+ BOOL mbCompression;
+ sal_Int32 mnPreview;
+
+ SvStream* mpPS;
+ const GDIMetaFile* pMTF;
+ GDIMetaFile* pAMTF; // only created if Graphics is not a Metafile
+ MapMode aMapMode;
+ VirtualDevice aOutputDevice;
+
+ double nBoundingX1; // this represents the bounding box
+ double nBoundingY1;
+ double nBoundingX2;
+ double nBoundingY2;
+
+ double nXScaling; // represents the factor of the current ( MapMode to 100THmm )
+ double nYScaling;
+ double nXOrigin; // this points to the origin ( in 100THmm )
+ double nYOrigin; // ( eg. is the BoundingBox ( 100, 200 ... )
+ // nXOrigin and nYOrigin starts with -100 -200;
+ StackMember* pGDIStack;
+ ULONG mnCursorPos; // aktuelle Cursorposition im Output
+ Color aColor; // aktuelle Farbe die fuer den Output benutzt wird
+ BOOL bLineColor;
+ Color aLineColor; // aktuelle GDIMetafile Farbeinstellungen
+ BOOL bFillColor; //
+ Color aFillColor; //
+ Color aTextColor; //
+ BOOL bTextFillColor; //
+ Color aTextFillColor; //
+ Color aBackgroundColor; //
+ BOOL bRegionChanged;
+ Region aClipRegion;
+ TextAlign eTextAlign;
+
+ Font maFont;
+ Font maLastFont;
+ BYTE nChrSet;
+ ChrSet* pChrSetList; // Liste der Character-Sets
+ BYTE nNextChrSetId; // die erste unbenutzte ChrSet-Id
+
+ PSLZWCTreeNode* pTable; // LZW compression data
+ PSLZWCTreeNode* pPrefix; // the compression is as same as the TIFF compression
+ USHORT nDataSize;
+ USHORT nClearCode;
+ USHORT nEOICode;
+ USHORT nTableSize;
+ USHORT nCodeSize;
+ ULONG nOffset;
+ ULONG dwShift;
+
+ void MayCallback( ULONG nPercent );
+ void ImplWriteProlog( const Graphic* pPreviewEPSI = NULL );
+ void ImplWriteEpilog();
+ void ImplWriteActions( const GDIMetaFile& rMtf);
+
+ // this method makes LF's, space inserting and word wrapping as used in all nMode
+ // parameters
+ inline void ImplExecMode( ULONG nMode );
+
+ // writes char[] + LF to stream
+ inline void ImplWriteLine( char[], ULONG nMode = PS_RET );
+
+ // writes ( nNumb / 10^nCount ) in ASCII format to stream
+ void ImplWriteF( sal_Int32 nNumb, ULONG nCount = 3, ULONG nMode = PS_SPACE );
+
+ // writes a double in ASCII format to stream
+ void ImplWriteDouble( double, ULONG nMode = PS_SPACE );
+
+ // writes a long in ASCII format to stream
+ void ImplWriteLong( sal_Int32 nNumb, ULONG nMode = PS_SPACE );
+
+ // writes a byte in ASCII format to stream
+ void ImplWriteByte( BYTE nNumb, ULONG nMode = PS_SPACE );
+
+ // writes a byte in ASCII (hex) format to stream
+ void ImplWriteHexByte( BYTE nNumb, ULONG nMode = PS_WRAP );
+
+ // writes nNumb as number from 0.000 till 1.000 in ASCII format to stream
+ void ImplWriteB1( BYTE nNumb, ULONG nMode = PS_SPACE );
+
+ inline void ImplWritePoint( Point, ULONG nMode = PS_SPACE );
+ void ImplMoveTo( Point, ULONG nMode = PS_SPACE );
+ void ImplLineTo( Point, ULONG nMode = PS_SPACE );
+ void ImplLine( const Polygon & rPolygon );
+ void ImplLine( const PolyPolygon & rPolyPolygon );
+ void ImplWriteLineInfo( const LineInfo& rLineInfo );
+ void ImplRect( const Rectangle & rRectangle );
+ void ImplRectFill ( const Rectangle & rRectangle );
+ void ImplPoly( const Polygon & rPolygon );
+
+ void ImplSetClipRegion();
+ void ImplBmp( Bitmap*, Bitmap*, const Point &, double nWidth, double nHeight );
+ void ImplSetAttrForText( Point & rPoint );
+ void ImplWriteCharacter( sal_Char );
+ void ImplWriteString( const ByteString&, const INT32* pDXArry = NULL, BOOL bStretch = FALSE );
+ void ImplDefineFont( char*, char* );
+
+ void ImplClosePathFill( ULONG nMode = PS_RET );
+ void ImplClosePathDraw( ULONG nMode = PS_RET );
+ void ImplPathDraw( ULONG nMode = PS_RET );
+
+ inline void ImplWriteLineColor( ULONG nMode = PS_RET );
+ inline void ImplWriteFillColor( ULONG nMode = PS_RET );
+ inline void ImplWriteTextColor( ULONG nMode = PS_RET );
+ inline void ImplWriteTextFillColor( ULONG nMode = PS_RET );
+ void ImplWriteColor( ULONG nMode );
+
+ void ImplGetMapMode( const MapMode& );
+ BOOL ImplGetBoundingBox( double* nNumb, BYTE* pSource, ULONG nSize );
+ BYTE* ImplSearchEntry( BYTE* pSource, BYTE* pDest, ULONG nComp, ULONG nSize );
+ // LZW methods
+ void StartCompression();
+ void Compress( BYTE nSrc );
+ void EndCompression();
+ inline void WriteBits( USHORT nCode, USHORT nCodeLen );
+
+public:
+ BOOL WritePS( const Graphic& rGraphic, SvStream& rTargetStream,
+ PFilterCallback, void*, Config* );
+ PSWriter();
+ ~PSWriter();
+};
+
+//========================== Methoden von PSWriter ==========================
+
+void PSWriter::MayCallback( ULONG nPercent )
+{
+
+ if ( nPercent >= mnLastPercent + 3 )
+ {
+ mnLastPercent = nPercent;
+ if( mpCallback && nPercent <= 100 )
+ {
+ if ( ( (*mpCallback)( mpCallerData, (USHORT)nPercent ) ) == TRUE )
+ mbStatus = FALSE;
+ }
+ }
+}
+
+//---------------------------------------------------------------------------------
+
+PSWriter::PSWriter()
+{
+ pAMTF = NULL;
+}
+
+
+PSWriter::~PSWriter()
+{
+ delete pAMTF;
+}
+
+//---------------------------------------------------------------------------------
+
+BOOL PSWriter::WritePS( const Graphic& rGraphic, SvStream& rTargetStream,
+ PFilterCallback pcallback, void* pcallerdata, Config* pOptionsConfig )
+{
+ UINT32 nStreamPosition, nPSPosition;
+
+ mbStatus = TRUE;
+ mnPreview = 0;
+ mnLevelWarning = 0;
+ mpCallback = pcallback;
+ mpCallerData = pcallerdata;
+ mnLastPercent = 0;
+ mnLatestPush = 0xEFFFFFFE;
+
+ mpPS = &rTargetStream;
+ mpPS->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+
+ // default values for the dialog options
+ mnLevel = 2;
+ mbGrayScale = FALSE;
+ mbCompression = TRUE;
+
+ // try to get the dialog selection
+ if ( pOptionsConfig )
+ {
+ ByteString aResMgrName( "eps" );
+ ResMgr* pResMgr;
+
+ aResMgrName.Append( ByteString::CreateFromInt32( SOLARUPD ) );
+ pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetAppInternational().GetLanguage() );
+
+ if( pResMgr )
+ {
+ String aPreviewStr( ResId( KEY_PREVIEW, pResMgr ) );
+ String aVersionStr( ResId( KEY_VERSION, pResMgr ) );
+ String aColorStr( ResId( KEY_COLOR, pResMgr ) );
+ String aComprStr( ResId( KEY_COMPR, pResMgr ) );
+
+ mnPreview = pOptionsConfig->ReadKey( ByteString( aPreviewStr, RTL_TEXTENCODING_UTF8 ), "1" ).ToInt32();
+ mnLevel = pOptionsConfig->ReadKey( ByteString( aVersionStr, RTL_TEXTENCODING_UTF8 ), "2" ).ToInt32();
+ if ( mnLevel != 1 )
+ mnLevel = 2;
+ mbGrayScale = pOptionsConfig->ReadKey( ByteString( aColorStr, RTL_TEXTENCODING_UTF8 ), "1" ).ToInt32() == 2;
+ mbCompression = pOptionsConfig->ReadKey( ByteString( aComprStr, RTL_TEXTENCODING_UTF8 ), "1" ).ToInt32() == 1;
+ delete pResMgr;
+ }
+ }
+
+ // compression is not available for Level 1
+ if ( mnLevel == 1 )
+ {
+ mbGrayScale = TRUE;
+ mbCompression = FALSE;
+ }
+
+ if ( mnPreview & EPS_PREVIEW_TIFF )
+ {
+ rTargetStream << (UINT32)0xC6D3D0C5;
+ nStreamPosition = rTargetStream.Tell();
+ rTargetStream << (UINT32)0 << (UINT32)0 << (UINT32)0 << (UINT32)0
+ << nStreamPosition + 26 << (UINT32)0 << (UINT16)0xffff;
+
+ UINT32 nErrCode;
+ if ( mbGrayScale )
+ {
+ BitmapEx aTempBitmapEx( rGraphic.GetBitmapEx() );
+ aTempBitmapEx.Convert( BMP_CONVERSION_8BIT_GREYS );
+ nErrCode = GraphicConverter::Export( rTargetStream, aTempBitmapEx, CVT_TIF ) ;
+ }
+ else
+ nErrCode = GraphicConverter::Export( rTargetStream, rGraphic, CVT_TIF ) ;
+
+ if ( nErrCode == ERRCODE_NONE )
+ {
+ rTargetStream.Seek( STREAM_SEEK_TO_END );
+ nPSPosition = rTargetStream.Tell();
+ rTargetStream.Seek( nStreamPosition + 20 );
+ rTargetStream << nPSPosition - 30; // size of tiff gfx
+ rTargetStream.Seek( nPSPosition );
+ }
+ else
+ {
+ mnPreview &=~ EPS_PREVIEW_TIFF;
+ rTargetStream.Seek( nStreamPosition - 4 );
+ }
+ }
+
+ // global default value setting
+ ChrSet* pCS;
+ StackMember* pGS;
+
+ if ( rGraphic.GetType() == GRAPHIC_GDIMETAFILE )
+ pMTF = &rGraphic.GetGDIMetaFile();
+ else
+ pMTF = pAMTF = new GDIMetaFile( rGraphic.GetGDIMetaFile() );
+
+ ImplGetMapMode( pMTF->GetPrefMapMode() );
+
+ nBoundingX1 = nBoundingY1 = 0;
+ nBoundingX2 = pMTF->GetPrefSize().Width() * nXScaling;
+ nBoundingY2 = pMTF->GetPrefSize().Height() * nYScaling;
+
+ pGDIStack = NULL;
+ aColor = Color( COL_TRANSPARENT );
+ bLineColor = TRUE;
+ aLineColor = Color( COL_BLACK );
+ bFillColor = TRUE;
+ aFillColor = Color( COL_WHITE );
+ aBackgroundColor = Color( COL_WHITE );
+ bRegionChanged = FALSE;
+ aClipRegion.SetEmpty();
+
+ nChrSet = 0x00;
+ pChrSetList = NULL;
+ nNextChrSetId = 1;
+
+ if( pMTF->GetActionCount() )
+ {
+ ImplWriteProlog( ( mnPreview & EPS_PREVIEW_EPSI ) ? &rGraphic : NULL );
+ mnCursorPos = 0;
+ ImplWriteActions( *pMTF );
+ ImplWriteEpilog();
+ if ( mnPreview & EPS_PREVIEW_TIFF )
+ {
+ UINT32 nPosition = rTargetStream.Tell();
+ rTargetStream.Seek( nStreamPosition );
+ rTargetStream << nPSPosition;
+ rTargetStream << nPosition - nPSPosition;
+ rTargetStream.Seek( nPosition );
+ }
+ while( pChrSetList )
+ {
+ pCS=pChrSetList;
+ pChrSetList=pCS->pSucc;
+ delete pCS;
+ }
+ while( pGDIStack )
+ {
+ pGS=pGDIStack;
+ pGDIStack=pGS->pSucc;
+ delete pGS;
+ }
+ }
+ else
+ mbStatus = FALSE;
+
+ if ( mbStatus && mnLevelWarning && pOptionsConfig )
+ {
+ ByteString aResMgrName( "eps" );
+ ResMgr* pResMgr;
+ aResMgrName.Append( ByteString::CreateFromInt32( SOLARUPD ) );
+ pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetAppInternational().GetLanguage() );
+ if( pResMgr )
+ {
+ InfoBox aInfoBox( NULL, String( ResId( KEY_VERSION_CHECK, pResMgr ) ) );
+ aInfoBox.Execute();
+ delete pResMgr;
+ }
+ }
+ return mbStatus;
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplWriteProlog( const Graphic* pPreview )
+{
+ ImplWriteLine( "%!PS-Adobe-3.0 EPSF-3.0 " );
+ *mpPS << "%%BoundingBox: "; // BoundingBox
+ ImplWriteLong( 0 );
+ ImplWriteLong( 0 );
+ aMapMode = MapMode( pMTF->GetPrefMapMode() );
+ Size aSizePoint = Application::GetDefaultDevice()->LogicToLogic( pMTF->GetPrefSize(), aMapMode, MAP_POINT );
+ ImplWriteLong( aSizePoint.Width() );
+ ImplWriteLong( aSizePoint.Height() ,PS_RET );
+ ImplWriteLine( "%%Pages: 0" );
+ ImplWriteLine( "%%Creator: Sun Microsystems, Inc." );
+ ImplWriteLine( "%%Title: none" );
+ ImplWriteLine( "%%CreationDate: none" );
+
+// defaults
+
+ *mpPS << "%%LanguageLevel: "; // Language level
+ ImplWriteLong( mnLevel, PS_RET );
+ if ( !mbGrayScale && mnLevel == 1 )
+ ImplWriteLine( "%%Extensions: CMYK" ); // CMYK extension is to set in color mode in level 1
+ ImplWriteLine( "%%EndComments" );
+ if ( pPreview && aSizePoint.Width() && aSizePoint.Height() )
+ {
+ Size aSizeBitmap( ( aSizePoint.Width() + 7 ) & ~7, aSizePoint.Height() );
+ Bitmap aTmpBitmap( pPreview->GetBitmap() );
+ aTmpBitmap.Scale( aSizeBitmap, BMP_SCALE_INTERPOLATE );
+ aTmpBitmap.Convert( BMP_CONVERSION_1BIT_THRESHOLD );
+ BitmapReadAccess* pAcc = aTmpBitmap.AcquireReadAccess();
+ if ( pAcc )
+ {
+ *mpPS << "%%BeginPreview: "; // BoundingBox
+ ImplWriteLong( aSizeBitmap.Width() );
+ ImplWriteLong( aSizeBitmap.Height() );
+ *mpPS << "1 ";
+ INT32 nLines = aSizeBitmap.Width() / 312;
+ if ( ( nLines * 312 ) != aSizeBitmap.Width() )
+ nLines++;
+ nLines *= aSizeBitmap.Height();
+ ImplWriteLong( nLines );
+ char nVal;
+ INT32 nX, nY, nCount2, nCount = 4;
+ const BitmapColor aBlack( pAcc->GetBestMatchingColor( Color( COL_BLACK ) ) );
+ for ( nY = 0; nY < aSizeBitmap.Height(); nY++ )
+ {
+ nCount2 = 0;
+ nVal = 0;
+ for ( nX = 0; nX < aSizeBitmap.Width(); nX++ )
+ {
+ if ( !nCount2 )
+ {
+ ImplExecMode( PS_RET );
+ *mpPS << "%";
+ nCount2 = 312;
+ }
+ nVal <<= 1;
+ if ( pAcc->GetPixel( nY, nX ) == aBlack )
+ nVal |= 1;
+ if ( ! ( --nCount ) )
+ {
+ if ( nVal > 9 )
+ nVal += 'A' - 10;
+ else
+ nVal += '0';
+ *mpPS << nVal;
+ nVal = 0;
+ nCount += 4;
+ }
+ nCount2--;
+ }
+ }
+ aTmpBitmap.ReleaseAccess( pAcc );
+ ImplExecMode( PS_RET );
+ ImplWriteLine( "%%EndPreview" );
+ }
+ }
+ ImplWriteLine( "%%BeginProlog" );
+ ImplWriteLine( "%%BeginResource: SDRes" );
+
+// BEGIN EPSF
+ ImplWriteLine( "/b4_inc_state save def\n/dict_count countdictstack def\n/op_count count 1 sub def\nuserdict begin" );
+ ImplWriteLine( "0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit[] 0 setdash newpath" );
+ ImplWriteLine( "/languagelevel where {pop languagelevel 1 ne {false setstrokeadjust false setoverprint} if} if" );
+
+ ImplWriteLine( "/bdef {bind def} bind def" ); // der neue operator bdef wird erzeugt
+ if ( mbGrayScale )
+ ImplWriteLine( "/c {setgray} bdef" );
+ else
+ ImplWriteLine( "/c {setrgbcolor} bdef" );
+ ImplWriteLine( "/l {neg lineto} bdef" );
+ ImplWriteLine( "/rl {neg rlineto} bdef" );
+ ImplWriteLine( "/cl {currentlinewidth currentdash currentlinecap 2 setlinecap} bdef" );
+ ImplWriteLine( "/lc {setlinecap} bdef" );
+ ImplWriteLine( "/lw {setlinewidth} bdef" );
+ ImplWriteLine( "/ld {setdash} bdef" );
+ ImplWriteLine( "/m {neg moveto} bdef" );
+ ImplWriteLine( "/r {rotate} bdef" );
+ ImplWriteLine( "/t {translate} bdef" );
+ ImplWriteLine( "/gs {gsave} bdef" );
+ ImplWriteLine( "/gr {grestore} bdef" );
+
+ ImplWriteLine( "/f {findfont dup length dict begin" ); // Setfont
+ ImplWriteLine( "{1 index /FID ne {def} {pop pop} ifelse} forall /Encoding ISOLatin1Encoding def" );
+ ImplWriteLine( "currentdict end /NFont exch definefont pop /NFont findfont} bdef" );
+
+ ImplWriteLine( "/s {show} bdef" );
+ ImplWriteLine( "/p {closepath} bdef" );
+ ImplWriteLine( "/sf {scalefont setfont} bdef" );
+
+ ImplWriteLine( "/pf {closepath fill}bdef" ); // close path and fill
+ ImplWriteLine( "/pc {closepath stroke}bdef" ); // close path and draw
+ ImplWriteLine( "/ps {stroke}bdef" ); // draw current path
+ ImplWriteLine( "/pum {matrix currentmatrix}bdef" ); // pushes the current matrix
+ ImplWriteLine( "/pom {setmatrix}bdef" ); // pops the matrix
+ ImplWriteLine( "/bs {/aString exch def /nXOfs exch def /nWidth exch def currentpoint nXOfs 0 rmoveto pum nWidth aString stringwidth pop div 1 scale aString show pom moveto} bdef" );
+ ImplWriteLine( "%%EndResource" );
+ ImplWriteLine( "%%EndProlog" );
+ ImplWriteLine( "%%BeginSetup" );
+ ImplWriteLine( "%%EndSetup" );
+ ImplWriteLine( "%%Page: 1 1" );
+ ImplWriteLine( "%%BeginPageSetup" );
+ ImplWriteLine( "%%EndPageSetup" );
+
+ ImplWriteLine( "pum" );
+ ImplWriteDouble( (double)aSizePoint.Width() / (double)nBoundingX2 );
+ ImplWriteDouble( (double)aSizePoint.Height() / (double)nBoundingY2 );
+ ImplWriteLine( "scale" );
+ ImplWriteLong( 0 );
+ ImplWriteDouble( nBoundingY2 );
+ ImplWriteLine( "t" );
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplWriteEpilog()
+{
+ ImplWriteLong( 0 );
+ ImplWriteDouble( - nBoundingY2 );
+ ImplWriteLine( "t" );
+ ImplWriteLine( "pom" );
+ ImplWriteLine( "%%PageTrailer" );
+ ImplWriteLine( "%%Trailer" );
+ ImplWriteLine( "count op_count sub {pop} repeat countdictstack dict_count sub {end} repeat b4_inc_state restore" );
+ ImplWriteLine( "%%EOF" );
+}
+
+//---------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf )
+{
+ for( ULONG nCurAction = 0, nCount = rMtf.GetActionCount(); nCurAction < nCount; nCurAction++ )
+ {
+ MetaAction* pMA = rMtf.GetAction( nCurAction );
+
+ switch( pMA->GetType() )
+ {
+ case META_NULL_ACTION :
+ break;
+
+ case META_PIXEL_ACTION :
+ {
+ Color aOldLineColor( aLineColor );
+ aLineColor = ( (const MetaPixelAction*) pMA )->GetColor();
+ ImplWriteLineColor( PS_SPACE );
+ ImplMoveTo( ( (const MetaPixelAction*)pMA )->GetPoint() );
+ ImplLineTo( ( (const MetaPixelAction*)pMA )->GetPoint() );
+ ImplPathDraw();
+ aLineColor = aOldLineColor;
+ }
+ break;
+
+ case META_POINT_ACTION :
+ {
+ ImplWriteLineColor( PS_SPACE );
+ ImplMoveTo( ( (const MetaPointAction*)pMA )->GetPoint() );
+ ImplLineTo( ( (const MetaPointAction*)pMA )->GetPoint() );
+ ImplPathDraw();
+ }
+ break;
+
+ case META_LINE_ACTION :
+ {
+ const LineInfo& rLineInfo = ( ( const MetaLineAction*)pMA )->GetLineInfo();
+ if ( !rLineInfo.IsDefault() )
+ ImplWriteLineInfo( rLineInfo );
+
+ if ( bLineColor )
+ {
+ ImplWriteLineColor( PS_SPACE );
+ ImplMoveTo( ( (const MetaLineAction*) pMA )->GetStartPoint() );
+ ImplLineTo( ( (const MetaLineAction*) pMA )->GetEndPoint() );
+ ImplPathDraw();
+ }
+ if ( !rLineInfo.IsDefault() )
+ ImplWriteLine( "lc ld lw" ); // LineWidth, LineDash, LineCap zuruecksetzen
+ }
+ break;
+
+ case META_RECT_ACTION :
+ {
+ ImplRect( ( (const MetaRectAction*) pMA )->GetRect() );
+ }
+ break;
+
+ case META_ROUNDRECT_ACTION :
+ ImplRect( ( (const MetaRoundRectAction*) pMA )->GetRect() );
+ break;
+
+ case META_ELLIPSE_ACTION :
+ {
+ Rectangle aRect = ( ( (const MetaEllipseAction*) pMA )->GetRect() );
+ Point aCenter = aRect.Center();
+ Polygon aPoly( aCenter, aRect.GetWidth() / 2, aRect.GetHeight() / 2 );
+ ImplPoly( aPoly );
+ }
+ break;
+
+ case META_ARC_ACTION :
+ {
+ Polygon aPoly( ( (const MetaArcAction*)pMA )->GetRect(), ( (const MetaArcAction*)pMA )->GetStartPoint(),
+ ( (const MetaArcAction*)pMA )->GetEndPoint(), POLY_ARC );
+ ImplPoly( aPoly );
+ }
+ break;
+
+ case META_PIE_ACTION :
+ {
+ Polygon aPoly( ( (const MetaPieAction*)pMA )->GetRect(), ( (const MetaPieAction*)pMA )->GetStartPoint(),
+ ( (const MetaPieAction*)pMA )->GetEndPoint(), POLY_PIE );
+ ImplPoly( aPoly );
+ }
+ break;
+
+ case META_CHORD_ACTION :
+ {
+ Polygon aPoly( ( (const MetaChordAction*)pMA )->GetRect(), ( (const MetaChordAction*)pMA )->GetStartPoint(),
+ ( (const MetaChordAction*)pMA )->GetEndPoint(), POLY_CHORD );
+ ImplPoly( aPoly );
+ }
+ break;
+
+ case META_POLYLINE_ACTION :
+ {
+ if ( bLineColor )
+ {
+ const LineInfo& rLineInfo = ( ( const MetaPolyLineAction*)pMA )->GetLineInfo();
+ ImplWriteLineColor( PS_SPACE );
+ if ( !rLineInfo.IsDefault() )
+ ImplWriteLineInfo( rLineInfo );
+ ImplLine( ( (const MetaPolyLineAction*) pMA )->GetPolygon() );
+ ImplPathDraw();
+ if ( !rLineInfo.IsDefault() )
+ ImplWriteLine( "lc ld lw" ); // LineWidth, LineDash, LineCap zuruecksetzen
+ }
+ }
+ break;
+
+ case META_POLYGON_ACTION :
+ {
+ ImplPoly( ( (const MetaPolygonAction*) pMA )->GetPolygon() );
+ }
+ break;
+
+ case META_POLYPOLYGON_ACTION :
+ {
+ ImplLine( ( (const MetaPolyPolygonAction*) pMA )->GetPolyPolygon() );
+ }
+ break;
+
+ case META_TEXT_ACTION:
+ {
+ const MetaTextAction * pA = (const MetaTextAction*) pMA;
+
+ String aUniStr( pA->GetText(), pA->GetIndex(), pA->GetLen() );
+ Point aPoint( pA->GetPoint() );
+
+ ImplSetAttrForText( aPoint );
+ ByteString aStr( aUniStr, maFont.GetCharSet() );
+ ImplWriteString( aStr );
+ if ( maFont.GetOrientation() )
+ ImplWriteLine( "gr" );
+ }
+ break;
+
+ case META_TEXTRECT_ACTION:
+ {
+ DBG_ERROR( "Unsupported action: TextRect...Action!" );
+ }
+ break;
+
+ case META_STRETCHTEXT_ACTION :
+ {
+ const MetaStretchTextAction* pA = (const MetaStretchTextAction*)pMA;
+ String aUniStr( pA->GetText(), pA->GetIndex(), pA->GetLen() );
+ Point aPoint( pA->GetPoint() );
+
+ ImplSetAttrForText( aPoint );
+
+ ByteString aStr( aUniStr, maFont.GetCharSet() );
+ ImplWriteString( aStr, NULL, TRUE );
+
+ if ( maFont.GetOrientation() )
+ ImplWriteLine( "gr" );
+ }
+ break;
+
+ case META_TEXTARRAY_ACTION:
+ {
+ const MetaTextArrayAction* pA = (const MetaTextArrayAction*)pMA;
+ String aUniStr( pA->GetText(), pA->GetIndex(), pA->GetLen() );
+ Point aPoint( pA->GetPoint() );
+
+ ImplSetAttrForText( aPoint );
+
+ ByteString aStr( aUniStr, maFont.GetCharSet() );
+ ImplWriteString( aStr, pA->GetDXArray(), FALSE );
+
+ if ( maFont.GetOrientation() )
+ ImplWriteLine( "gr" );
+ }
+ break;
+
+ case META_BMP_ACTION :
+ {
+ Bitmap aBitmap = ( (const MetaBmpAction*)pMA )->GetBitmap();
+ if ( mbGrayScale )
+ aBitmap.Convert( BMP_CONVERSION_8BIT_GREYS );
+ Point aPoint = ( (const MetaBmpAction*) pMA )->GetPoint();
+ ImplBmp( &aBitmap, NULL, aPoint, nBoundingX2, nBoundingY2 );
+ }
+ break;
+
+ case META_BMPSCALE_ACTION :
+ {
+ Bitmap aBitmap = ( (const MetaBmpScaleAction*)pMA )->GetBitmap();
+ if ( mbGrayScale )
+ aBitmap.Convert( BMP_CONVERSION_8BIT_GREYS );
+ Point aPoint = ( (const MetaBmpScaleAction*) pMA )->GetPoint();
+ Size aSize = ( (const MetaBmpScaleAction*)pMA )->GetSize();
+ ImplBmp( &aBitmap, NULL, aPoint, aSize.Width(), aSize.Height() );
+ }
+ break;
+
+ case META_BMPSCALEPART_ACTION :
+ {
+ Bitmap aBitmap( ( (const MetaBmpScalePartAction*)pMA )->GetBitmap() );
+ aBitmap.Crop( Rectangle( ( (const MetaBmpScalePartAction*)pMA )->GetSrcPoint(),
+ ( (const MetaBmpScalePartAction*)pMA )->GetSrcSize() ) );
+ if ( mbGrayScale )
+ aBitmap.Convert( BMP_CONVERSION_8BIT_GREYS );
+ Point aPoint = ( (const MetaBmpScalePartAction*) pMA)->GetDestPoint();
+ Size aSize = ( (const MetaBmpScalePartAction*)pMA )->GetDestSize();
+ ImplBmp( &aBitmap, NULL, aPoint, aSize.Width(), aSize.Height() );
+ }
+ break;
+
+ case META_BMPEX_ACTION :
+ {
+ BitmapEx aBitmapEx( ( (MetaBmpExAction*)pMA)->GetBitmapEx() );
+ Bitmap aBitmap( aBitmapEx.GetBitmap() );
+ if ( mbGrayScale )
+ aBitmap.Convert( BMP_CONVERSION_8BIT_GREYS );
+ Bitmap aMask( aBitmapEx.GetMask() );
+ Point aPoint = ( (const MetaBmpExAction*) pMA)->GetPoint();
+ Size aSize = ( aBitmap.GetSizePixel() );
+ ImplBmp( &aBitmap, &aMask, aPoint, aSize.Width(), aSize.Height() );
+ }
+ break;
+
+ case META_BMPEXSCALE_ACTION :
+ {
+ BitmapEx aBitmapEx( ( (MetaBmpExScaleAction*)pMA)->GetBitmapEx() );
+ Bitmap aBitmap( aBitmapEx.GetBitmap() );
+ if ( mbGrayScale )
+ aBitmap.Convert( BMP_CONVERSION_8BIT_GREYS );
+ Bitmap aMask( aBitmapEx.GetMask() );
+ Point aPoint = ( (const MetaBmpExScaleAction*) pMA)->GetPoint();
+ Size aSize( ( (const MetaBmpExScaleAction*)pMA )->GetSize() );
+ ImplBmp( &aBitmap, &aMask, aPoint, aSize.Width(), aSize.Height() );
+ }
+ break;
+
+ case META_BMPEXSCALEPART_ACTION :
+ {
+ BitmapEx aBitmapEx( ( (const MetaBmpExScalePartAction*)pMA )->GetBitmapEx() );
+ aBitmapEx.Crop( Rectangle( ( (const MetaBmpExScalePartAction*)pMA )->GetSrcPoint(),
+ ( (const MetaBmpExScalePartAction*)pMA )->GetSrcSize() ) );
+ Bitmap aBitmap( aBitmapEx.GetBitmap() );
+ if ( mbGrayScale )
+ aBitmap.Convert( BMP_CONVERSION_8BIT_GREYS );
+ Bitmap aMask( aBitmapEx.GetMask() );
+ Point aPoint = ( (const MetaBmpExScalePartAction*) pMA)->GetDestPoint();
+ Size aSize = ( (const MetaBmpExScalePartAction*)pMA )->GetDestSize();
+ ImplBmp( &aBitmap, &aMask, aPoint, aSize.Width(), aSize.Height() );
+ }
+ break;
+
+ // Unsupported Actions
+ case META_MASK_ACTION:
+ case META_MASKSCALE_ACTION:
+ case META_MASKSCALEPART_ACTION:
+ {
+ DBG_ERROR( "Unsupported action: MetaMask...Action!" );
+ }
+ break;
+
+ case META_GRADIENT_ACTION :
+ {
+ VirtualDevice aVDev;
+ GDIMetaFile aTmpMtf;
+
+ aVDev.SetMapMode( aMapMode );
+ aVDev.AddGradientActions( ( (const MetaGradientAction*)pMA)->GetRect(), ( (const MetaGradientAction*) pMA )->GetGradient(), aTmpMtf );
+ ImplWriteActions( aTmpMtf );
+ }
+ break;
+
+ case META_HATCH_ACTION :
+ {
+ VirtualDevice aVDev;
+ GDIMetaFile aTmpMtf;
+
+ aVDev.SetMapMode( aMapMode );
+ aVDev.AddHatchActions( ( (const MetaHatchAction*)pMA)->GetPolyPolygon(),
+ ( (const MetaHatchAction*)pMA )->GetHatch(), aTmpMtf );
+ ImplWriteActions( aTmpMtf );
+ }
+ break;
+
+ case META_WALLPAPER_ACTION :
+ {
+ const MetaWallpaperAction* pA = (const MetaWallpaperAction*)pMA;
+ Rectangle aRect = pA->GetRect();
+ Wallpaper aWallpaper = pA->GetWallpaper();
+
+ if ( aWallpaper.IsBitmap() )
+ {
+ BitmapEx aBitmapEx = aWallpaper.GetBitmap();
+ Bitmap aBitmap( aBitmapEx.GetBitmap() );
+ if ( aBitmapEx.IsTransparent() )
+ {
+ if ( aWallpaper.IsGradient() )
+ {
+
+ // gradient action
+
+ }
+ Bitmap aMask( aBitmapEx.GetMask() );
+ ImplBmp( &aBitmap, &aMask, Point( aRect.Left(), aRect.Top() ), aRect.GetWidth(), aRect.GetHeight() );
+ }
+ else
+ ImplBmp( &aBitmap, NULL, Point( aRect.Left(), aRect.Top() ), aRect.GetWidth(), aRect.GetHeight() );
+
+ // wallpaper Style
+
+ }
+ else if ( aWallpaper.IsGradient() )
+ {
+
+ // gradient action
+
+ }
+ else
+ {
+ aColor = aWallpaper.GetColor();
+ ImplRectFill( aRect );
+ }
+ }
+ break;
+
+ case META_ISECTRECTCLIPREGION_ACTION:
+ {
+ const MetaISectRectClipRegionAction* pA = (const MetaISectRectClipRegionAction*) pMA;
+ if ( aClipRegion.IsEmpty() )
+ aClipRegion = pA->GetRect();
+ else
+ aClipRegion.Intersect( pA->GetRect() );
+ bRegionChanged = FALSE;
+ ImplSetClipRegion();
+ }
+ break;
+
+ case META_CLIPREGION_ACTION:
+ {
+ const MetaClipRegionAction* pA = (const MetaClipRegionAction*) pMA;
+ bRegionChanged = TRUE;
+ aClipRegion = pA->GetRegion();
+ ImplSetClipRegion();
+ }
+ break;
+
+ case META_ISECTREGIONCLIPREGION_ACTION:
+ {
+ const MetaISectRegionClipRegionAction* pA = (const MetaISectRegionClipRegionAction*) pMA;
+ if ( aClipRegion.IsEmpty() )
+ aClipRegion = pA->GetRegion();
+ else
+ aClipRegion.Intersect( pA->GetRegion() );
+ bRegionChanged = TRUE;
+ ImplSetClipRegion();
+ }
+ break;
+
+ case META_MOVECLIPREGION_ACTION:
+ {
+ if ( !aClipRegion.IsEmpty() )
+ {
+ const MetaMoveClipRegionAction* pA = (const MetaMoveClipRegionAction*) pMA;
+ aClipRegion.Move( pA->GetHorzMove(), pA->GetVertMove() );
+ ImplSetClipRegion();
+ }
+ }
+ break;
+
+ case META_LINECOLOR_ACTION :
+ {
+ if ( ( (const MetaLineColorAction*) pMA)->IsSetting() )
+ {
+ bLineColor = TRUE;
+ aLineColor = ( (const MetaLineColorAction*) pMA )->GetColor();
+ }
+ else
+ bLineColor = FALSE;
+ }
+ break;
+
+ case META_FILLCOLOR_ACTION :
+ {
+ if ( ( (const MetaFillColorAction*) pMA )->IsSetting() )
+ {
+ bFillColor = TRUE;
+ aFillColor = ( (const MetaFillColorAction*) pMA )->GetColor();
+ }
+ else
+ bFillColor = FALSE;
+ }
+ break;
+
+ case META_TEXTCOLOR_ACTION :
+ {
+ aTextColor = ( (const MetaTextColorAction*) pMA )->GetColor();
+ }
+ break;
+
+ case META_TEXTFILLCOLOR_ACTION :
+ {
+ if ( ( (const MetaTextFillColorAction*) pMA )->IsSetting() )
+ {
+ bTextFillColor = TRUE;
+ aTextFillColor = ( (const MetaTextFillColorAction*) pMA )->GetColor();
+ }
+ else
+ bTextFillColor = FALSE;
+ }
+ break;
+
+ case META_TEXTALIGN_ACTION :
+ {
+ eTextAlign = ( (const MetaTextAlignAction*) pMA )->GetTextAlign();
+ }
+ break;
+
+ case META_MAPMODE_ACTION :
+ {
+ aMapMode = ( (const MetaMapModeAction*) pMA )->GetMapMode();
+
+ if( aMapMode.GetMapUnit() == MAP_RELATIVE )
+ {
+ nXScaling *= (double)aMapMode.GetScaleX();
+ nYScaling *= (double)aMapMode.GetScaleY();
+ nXOrigin += (double)aMapMode.GetOrigin().X() * nXScaling;
+ nYOrigin += (double)aMapMode.GetOrigin().Y() * nYScaling;
+ }
+ else
+ ImplGetMapMode( aMapMode );
+ }
+ break;
+
+ case META_FONT_ACTION :
+ {
+ maFont = ( (const MetaFontAction*) pMA )->GetFont();
+ aOutputDevice.SetFont( maFont );
+ }
+ break;
+
+ case META_PUSH_ACTION :
+ {
+ StackMember* pGS = new StackMember;
+ pGS->pSucc = pGDIStack;
+ pGDIStack = pGS;
+ pGS->eTextAlign = eTextAlign;
+ pGS->aGlobalCol = aColor;
+ pGS->bLineCol = bLineColor;
+ pGS->aLineCol = aLineColor;
+ pGS->bFillCol = bFillColor;
+ pGS->aFillCol = aFillColor;
+ pGS->aTextCol = aTextColor;
+ pGS->bTextFillCol = bTextFillColor;
+ pGS->aTextFillCol = aTextFillColor;
+ pGS->aBackgroundCol = aBackgroundColor;
+ pGS->bRegionChanged = bRegionChanged;
+ pGS->aClipReg = aClipRegion;
+ pGS->aMapMode = aMapMode;
+ bRegionChanged = FALSE;
+ pGS->aFont = maFont;
+ pGS->nXScale = nXScaling;
+ pGS->nYScale = nYScaling;
+ pGS->nXOrig = nXOrigin;
+ pGS->nYOrig = nYOrigin;
+ mnLatestPush = mpPS->Tell();
+ ImplWriteLine( "gs" );
+ }
+ break;
+
+ case META_POP_ACTION :
+ {
+ StackMember* pGS;
+ if( pGDIStack )
+ {
+ pGS = pGDIStack;
+ pGDIStack = pGS->pSucc;
+ if ( aMapMode != pGS->aMapMode )
+ {
+ aMapMode = pGS->aMapMode;
+ ImplGetMapMode( aMapMode );
+ }
+ eTextAlign = pGS->eTextAlign;
+ aColor = pGS->aGlobalCol;
+ bLineColor = pGS->bLineCol;
+ aLineColor = pGS->aLineCol;
+ bFillColor = pGS->bFillCol;
+ aFillColor = pGS->aFillCol;
+ aTextColor = pGS->aTextCol;
+ bTextFillColor = pGS->bTextFillCol;
+ aTextFillColor = pGS->aTextFillCol;
+ aBackgroundColor = pGS->aBackgroundCol;
+ if ( bRegionChanged )
+ {
+ aClipRegion = pGS->aClipReg;
+ ImplSetClipRegion();
+ }
+ bRegionChanged = pGS->bRegionChanged;
+ maFont = pGS->aFont;
+ maLastFont = Font(); // set maLastFont != maFont -> so that
+ nXScaling = pGS->nXScale;
+ nYScaling = pGS->nYScale;
+ nXOrigin = pGS->nXOrig;
+ nYOrigin = pGS->nYOrig;
+ delete pGS;
+ UINT32 nCurrentPos = mpPS->Tell();
+ if ( nCurrentPos - 6 == mnLatestPush )
+ {
+ mpPS->Seek( mnLatestPush );
+ ImplWriteLine( " " );
+ mpPS->Seek( mnLatestPush );
+ }
+ else
+ ImplWriteLine( "gr" );
+ }
+ }
+ break;
+
+ case META_EPS_ACTION :
+ {
+ GfxLink aGfxLink = ( (const MetaEPSAction*) pMA )->GetLink();
+ BOOL bLevelConflict = FALSE;
+ BYTE* pSource = (BYTE*) aGfxLink.GetData();
+ ULONG nSize = aGfxLink.GetDataSize();
+ ULONG nParseThis = POSTSCRIPT_BOUNDINGSEARCH;
+ if ( nSize < 64 ) // assuming eps is larger than 64 bytes
+ pSource = NULL;
+ if ( nParseThis > nSize )
+ nParseThis = nSize;
+
+ if ( pSource && ( mnLevel == 1 ) )
+ {
+ BYTE* pFound = ImplSearchEntry( pSource, (BYTE*)"%%LanguageLevel:", nParseThis - 10, 16 );
+ if ( pFound )
+ {
+ BYTE k, i = 10;
+ pFound += 16;
+ while ( --i )
+ {
+ k = *pFound++;
+ if ( ( k > '0' ) && ( k <= '9' ) )
+ {
+ if ( k != '1' )
+ {
+ bLevelConflict = TRUE;
+ mnLevelWarning++;
+ }
+ break;
+ }
+ }
+ }
+ }
+ if ( !bLevelConflict )
+ {
+ double nBoundingBox[4];
+ if ( pSource && ImplGetBoundingBox( nBoundingBox, pSource, nParseThis ) )
+ {
+ Point aPoint = ( (const MetaEPSAction*) pMA )->GetPoint();
+ Size aSize = ( (const MetaEPSAction*) pMA )->GetSize();
+ double nXScale = (double)aSize.Width() * (double)nXScaling / ( nBoundingBox[ 2 ] - nBoundingBox[ 0 ] );
+ double nYScale = (double)aSize.Height() * (double)nYScaling / ( nBoundingBox[ 3 ] - nBoundingBox[ 1 ] );
+ ImplWriteLine( "gs\n%%BeginDocument:" );
+ ImplWriteDouble( aPoint.X() * nXScaling + nXOrigin );
+ ImplWriteDouble( - ( aPoint.Y() * nYScaling + nYOrigin + nBoundingBox[ 3 ] * nYScale ) );
+ ImplWriteLine( "t" );
+ ImplWriteDouble( nXScale );
+ ImplWriteDouble( nYScale );
+ ImplWriteLine( "scale" );
+ mpPS->Write( pSource, aGfxLink.GetDataSize() );
+ ImplWriteLine( "%%EndDocument\ngr" );
+ }
+ }
+ }
+ break;
+
+ case META_TRANSPARENT_ACTION:
+ {
+ ImplLine( ( (const MetaTransparentAction*) pMA )->GetPolyPolygon() );
+ }
+ break;
+
+ case META_FLOATTRANSPARENT_ACTION:
+ {
+ const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pMA;
+
+ GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() );
+ Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() );
+ const Size aSrcSize( aTmpMtf.GetPrefSize() );
+ const Point aDestPt( pA->GetPoint() );
+ const Size aDestSize( pA->GetSize() );
+ const double fScaleX = aSrcSize.Width() ? (double) aDestSize.Width() / aSrcSize.Width() : 1.0;
+ const double fScaleY = aSrcSize.Height() ? (double) aDestSize.Height() / aSrcSize.Height() : 1.0;
+ long nMoveX, nMoveY;
+
+ if( fScaleX != 1.0 || fScaleY != 1.0 )
+ {
+ aTmpMtf.Scale( fScaleX, fScaleY );
+ aSrcPt.X() = FRound( aSrcPt.X() * fScaleX ), aSrcPt.Y() = FRound( aSrcPt.Y() * fScaleY );
+ }
+
+ nMoveX = aDestPt.X() - aSrcPt.X(), nMoveY = aDestPt.Y() - aSrcPt.Y();
+
+ if( nMoveX || nMoveY )
+ aTmpMtf.Move( nMoveX, nMoveY );
+
+ ImplWriteActions( aTmpMtf );
+ }
+ break;
+ }
+ }
+}
+
+
+
+//---------------------------------------------------------------------------------
+
+inline void PSWriter::ImplWritePoint( Point nPoint, ULONG nMode )
+{
+ ImplWriteDouble( nPoint.X() * nXScaling + nXOrigin );
+ ImplWriteDouble( nPoint.Y() * nYScaling + nYOrigin, nMode );
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplMoveTo( Point nPoint, ULONG nMode )
+{
+ ImplWritePoint( nPoint );
+ ImplWriteByte( 'm' );
+ ImplExecMode( nMode );
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplLineTo( Point nPoint, ULONG nMode )
+{
+ ImplWritePoint( nPoint );
+ ImplWriteByte( 'l' );
+ ImplExecMode( nMode );
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplLine( const Polygon &rPolygon )
+{
+ USHORT i = 1;
+ USHORT nPointCount = rPolygon.GetSize();
+ if ( nPointCount > 1 )
+ {
+ ImplMoveTo( rPolygon.GetPoint( 0 ) );
+ while ( i < nPointCount )
+ {
+ ImplLineTo( rPolygon.GetPoint( i++ ), PS_SPACE | PS_WRAP );
+ }
+ }
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplLine( const PolyPolygon &rPolyPolygon )
+{
+ USHORT i, nCount = rPolyPolygon.Count();
+ for ( i = 0; i < nCount; i++ )
+ {
+ if ( bFillColor )
+ {
+ ImplWriteFillColor( PS_SPACE );
+ ImplLine( rPolyPolygon.GetObject( i ) );
+ ImplClosePathFill();
+ }
+ if ( bLineColor )
+ {
+ ImplWriteLineColor( PS_SPACE );
+ ImplLine( rPolyPolygon.GetObject( i ) );
+ ImplClosePathDraw();
+ }
+ }
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplRect( const Rectangle & rRect )
+{
+ if ( bFillColor )
+ ImplRectFill( rRect );
+ if ( bLineColor )
+ {
+
+ double nWidth = rRect.GetWidth() * nXScaling;
+ double nHeight = rRect.GetHeight() * nYScaling;
+
+ ImplWriteLineColor( PS_SPACE );
+ ImplMoveTo( rRect.TopLeft() );
+ ImplWriteDouble( nWidth );
+ *mpPS << "0 rl 0 ";
+ ImplWriteDouble( nHeight );
+ *mpPS << "rl ";
+ ImplWriteDouble( nWidth );
+ *mpPS << "neg 0 rl ";
+ ImplClosePathDraw();
+ }
+ *mpPS << (BYTE)10;
+ mnCursorPos = 0;
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplRectFill( const Rectangle & rRect )
+{
+ double nWidth = rRect.GetWidth() * nXScaling;
+ double nHeight = rRect.GetHeight() * nYScaling;
+
+ ImplWriteFillColor( PS_SPACE );
+ ImplMoveTo( rRect.TopLeft() );
+ ImplWriteDouble( nWidth );
+ *mpPS << "0 rl 0 ";
+ ImplWriteDouble( nHeight );
+ *mpPS << "rl ";
+ ImplWriteDouble( nWidth );
+ *mpPS << "neg 0 rl ";
+ ImplClosePathFill();
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplPoly( const Polygon & rPoly )
+{
+ if ( rPoly.GetSize() > 1 )
+ {
+ if ( bFillColor )
+ {
+ ImplWriteFillColor( PS_SPACE );
+ ImplLine( rPoly );
+ ImplClosePathFill();
+ }
+ if ( bLineColor )
+ {
+ ImplWriteLineColor( PS_SPACE );
+ ImplLine( rPoly );
+ ImplClosePathDraw();
+ }
+ }
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplSetClipRegion()
+{
+ if ( !aClipRegion.IsEmpty() )
+ {
+ Rectangle aRect;
+ RegionHandle hRegionHandle = aClipRegion.BeginEnumRects();
+
+ while ( aClipRegion.GetNextEnumRect( hRegionHandle, aRect ) )
+ {
+ double nX1 = aRect.Left() * nXScaling + nXOrigin;
+ double nY1 = aRect.Top() * nYScaling + nYOrigin;
+ double nX2 = aRect.Right() * nXScaling + nXOrigin;
+ double nY2 = aRect.Bottom() * nYScaling + nYOrigin;
+ ImplWriteDouble( nX1 );
+ ImplWriteDouble( nY1 );
+ ImplWriteByte( 'm' );
+ ImplWriteDouble( nX2 );
+ ImplWriteDouble( nY1 );
+ ImplWriteByte( 'l' );
+ ImplWriteDouble( nX2 );
+ ImplWriteDouble( nY2 );
+ ImplWriteByte( 'l' );
+ ImplWriteDouble( nX1 );
+ ImplWriteDouble( nY2 );
+ ImplWriteByte( 'l' );
+ ImplWriteDouble( nX1 );
+ ImplWriteDouble( nY1 );
+ ImplWriteByte( 'l', PS_SPACE | PS_WRAP );
+ };
+ aClipRegion.EndEnumRects( hRegionHandle );
+ ImplWriteLine( "eoclip newpath" );
+ }
+}
+
+//---------------------------------------------------------------------------------
+// possible gfx formats:
+//
+// level 1: grayscale 8 bit
+// color 24 bit
+//
+// level 2: grayscale 8 bit
+// color 1(pal), 4(pal), 8(pal), 24 Bit
+//
+
+void PSWriter::ImplBmp( Bitmap* pBitmap, Bitmap* pMaskBitmap, const Point & rPoint, double nXWidth, double nYHeightOrg )
+{
+ if ( !pBitmap )
+ return;
+
+ INT32 nHeightOrg = pBitmap->GetSizePixel().Height();
+ INT32 nHeightLeft = nHeightOrg;
+ long nWidth = pBitmap->GetSizePixel().Width();
+ Point aSourcePos( rPoint );
+
+ while ( nHeightLeft )
+ {
+ Bitmap aTileBitmap( *pBitmap );
+ long nHeight = nHeightLeft;
+ double nYHeight = nYHeightOrg;
+
+ BOOL bDoTrans = FALSE;
+
+ Rectangle aRect;
+ Region aRegion;
+
+ if ( pMaskBitmap )
+ {
+ bDoTrans = TRUE;
+ while (TRUE)
+ {
+ if ( mnLevel == 1 )
+ {
+ if ( nHeight > 10 )
+ nHeight = 8;
+ }
+ aRect = Rectangle( Point( 0, nHeightOrg - nHeightLeft ), Size( (long)nWidth, (long)nHeight ) );
+ aRegion = Region( pMaskBitmap->CreateRegion( COL_BLACK, aRect ) );
+
+ if ( ( mnLevel == 1 ) && ( aRegion.GetRectCount() * 5 > 1000 ) )
+ {
+ nHeight >>= 1;
+ if ( nHeight < 2 )
+ return;
+ continue;
+ }
+ break;
+ }
+ }
+ if ( nHeight != nHeightOrg )
+ {
+ nYHeight = nYHeightOrg * nHeight / nHeightOrg;
+ aTileBitmap.Crop( Rectangle( Point( 0, nHeightOrg - nHeightLeft ), Size( nWidth, nHeight ) ) );
+ }
+ if ( bDoTrans )
+ {
+ ImplWriteLine( "gs\npum" );
+ ImplWriteDouble( aSourcePos.X() * nXScaling + nXOrigin );
+ ImplWriteDouble( -aSourcePos.Y() * nYScaling - nYOrigin );
+ ImplWriteLine( "t" );
+ ImplWriteDouble( nXWidth * nXScaling / nWidth );
+ ImplWriteDouble( nYHeight * nYScaling / nHeight );
+ ImplWriteLine( "scale" );
+
+ if ( !aClipRegion.IsEmpty() )
+ {
+ // aRegion.Intersect( aClipRegion );
+ }
+ RegionHandle hRegionHandle = aRegion.BeginEnumRects();
+
+ while ( aRegion.GetNextEnumRect( hRegionHandle, aRect ) )
+ {
+ aRect.Move( 0, - ( nHeightOrg - nHeightLeft ) );
+ ImplWriteLong( aRect.Left() );
+ ImplWriteLong( aRect.Top() );
+ ImplWriteByte( 'm' );
+ ImplWriteLong( aRect.Right() + 1 );
+ ImplWriteLong( aRect.Top() );
+ ImplWriteByte( 'l' );
+ ImplWriteLong( aRect.Right() + 1 );
+ ImplWriteLong( aRect.Bottom() + 1 );
+ ImplWriteByte( 'l' );
+ ImplWriteLong( aRect.Left() );
+ ImplWriteLong( aRect.Bottom() + 1 );
+ ImplWriteByte( 'l' );
+ ImplWriteByte( 'p', PS_SPACE | PS_WRAP );
+ };
+ aRegion.EndEnumRects( hRegionHandle );
+ ImplWriteLine( "eoclip newpath" );
+ ImplWriteLine( "pom" );
+ }
+ BitmapReadAccess* pAcc = aTileBitmap.AcquireReadAccess();
+
+ if (!bDoTrans )
+ ImplWriteLine( "pum" );
+
+ ImplWriteDouble( aSourcePos.X() * nXScaling + nXOrigin );
+ ImplWriteDouble( -aSourcePos.Y() * nYScaling - nYOrigin - nYHeight * nYScaling );
+ ImplWriteLine( "t" );
+ ImplWriteDouble( nXWidth * nXScaling );
+ ImplWriteDouble( nYHeight * nYScaling );
+ ImplWriteLine( "scale" );
+ if ( mnLevel == 1 ) // level 1 is always grayscale !!!
+ {
+ ImplWriteLong( nWidth );
+ ImplWriteLong( nHeight );
+ *mpPS << "8 [";
+ ImplWriteLong( nWidth );
+ *mpPS << "0 0 ";
+ ImplWriteLong( -nHeight );
+ ImplWriteLong( 0 );
+ ImplWriteLong( nHeight );
+ ImplWriteLine( "]" );
+ *mpPS << "{currentfile ";
+ ImplWriteLong( nWidth );
+ ImplWriteLine( "string readhexstring pop}" );
+ ImplWriteLine( "image" );
+ for ( long y = 0; y < nHeight; y++ )
+ {
+ for ( long x = 0; x < nWidth; x++ )
+ {
+ ImplWriteHexByte( (BYTE)pAcc->GetPixel( y, x ) );
+ }
+ }
+ *mpPS << (BYTE)10;
+ }
+ else // Level 2
+ {
+ if ( mbGrayScale )
+ {
+ ImplWriteLine( "/DeviceGray setcolorspace" );
+ ImplWriteLine( "<<" );
+ ImplWriteLine( "/ImageType 1" );
+ *mpPS << "/Width ";
+ ImplWriteLong( nWidth, PS_RET );
+ *mpPS << "/Height ";
+ ImplWriteLong( nHeight, PS_RET );
+ ImplWriteLine( "/BitsPerComponent 8" );
+ ImplWriteLine( "/Decode[0 1]" );
+ *mpPS << "/ImageMatrix[";
+ ImplWriteLong( nWidth );
+ *mpPS << "0 0 ";
+ ImplWriteLong( -nHeight );
+ ImplWriteLong( 0 );
+ ImplWriteLong( nHeight, PS_NONE );
+ ImplWriteByte( ']', PS_RET );
+ ImplWriteLine( "/DataSource currentfile" );
+ ImplWriteLine( "/ASCIIHexDecode filter" );
+ if ( mbCompression )
+ ImplWriteLine( "/LZWDecode filter" );
+ ImplWriteLine( ">>" );
+ ImplWriteLine( "image" );
+ if ( mbCompression )
+ {
+ StartCompression();
+ for ( long y = 0; y < nHeight; y++ )
+ {
+ for ( long x = 0; x < nWidth; x++ )
+ {
+ Compress( (BYTE)pAcc->GetPixel( y, x ) );
+ }
+ }
+ EndCompression();
+ }
+ else
+ {
+ for ( long y = 0; y < nHeight; y++ )
+ {
+ for ( long x = 0; x < nWidth; x++ )
+ {
+ ImplWriteHexByte( (BYTE)pAcc->GetPixel( y, x ) );
+ }
+ }
+ }
+ }
+ else
+ {
+ // have we to write a palette ?
+
+ if ( pAcc->HasPalette() )
+ {
+ ImplWriteLine( "[/Indexed /DeviceRGB " );
+ ImplWriteLong( pAcc->GetPaletteEntryCount() - 1, PS_RET );
+ ImplWriteByte( '<', PS_NONE );
+ for ( USHORT i = 0; i < pAcc->GetPaletteEntryCount(); i++ )
+ {
+ BitmapColor aBitmapColor = pAcc->GetPaletteColor( i );
+ ImplWriteHexByte( aBitmapColor.GetRed(), PS_NONE );
+ ImplWriteHexByte( aBitmapColor.GetGreen(), PS_NONE );
+ ImplWriteHexByte( aBitmapColor.GetBlue(), PS_SPACE | PS_WRAP );
+ }
+ ImplWriteByte( '>', PS_RET );
+
+ ImplWriteLine( "] setcolorspace" );
+ ImplWriteLine( "<<" );
+ ImplWriteLine( "/ImageType 1" );
+ *mpPS << "/Width ";
+ ImplWriteLong( nWidth, PS_RET );
+ *mpPS << "/Height ";
+ ImplWriteLong( nHeight, PS_RET );
+ ImplWriteLine( "/BitsPerComponent 8" );
+ ImplWriteLine( "/Decode[0 255]" );
+ *mpPS << "/ImageMatrix[";
+ ImplWriteLong( nWidth );
+ *mpPS << "0 0 ";
+ ImplWriteLong( -nHeight );
+ ImplWriteLong( 0);
+ ImplWriteLong( nHeight, PS_NONE );
+ ImplWriteByte( ']', PS_RET );
+ ImplWriteLine( "/DataSource currentfile" );
+ ImplWriteLine( "/ASCIIHexDecode filter" );
+ if ( mbCompression )
+ ImplWriteLine( "/LZWDecode filter" );
+ ImplWriteLine( ">>" );
+ ImplWriteLine( "image" );
+ if ( mbCompression )
+ {
+ StartCompression();
+ for ( long y = 0; y < nHeight; y++ )
+ {
+ for ( long x = 0; x < nWidth; x++ )
+ {
+ Compress( (BYTE)pAcc->GetPixel( y, x ) );
+ }
+ }
+ EndCompression();
+ }
+ else
+ {
+ for ( long y = 0; y < nHeight; y++ )
+ {
+ for ( long x = 0; x < nWidth; x++ )
+ {
+ ImplWriteHexByte( (BYTE)pAcc->GetPixel( y, x ) );
+ }
+ }
+ }
+ }
+ else // 24 bit color
+ {
+ ImplWriteLine( "/DeviceRGB setcolorspace" );
+ ImplWriteLine( "<<" );
+ ImplWriteLine( "/ImageType 1" );
+ *mpPS << "/Width ";
+ ImplWriteLong( nWidth, PS_RET );
+ *mpPS << "/Height ";
+ ImplWriteLong( nHeight, PS_RET );
+ ImplWriteLine( "/BitsPerComponent 8" );
+ ImplWriteLine( "/Decode[0 1 0 1 0 1]" );
+ *mpPS << "/ImageMatrix[";
+ ImplWriteLong( nWidth );
+ *mpPS << "0 0 ";
+ ImplWriteLong( -nHeight );
+ ImplWriteLong( 0 );
+ ImplWriteLong( nHeight, PS_NONE );
+ ImplWriteByte( ']', PS_RET );
+ ImplWriteLine( "/DataSource currentfile" );
+ ImplWriteLine( "/ASCIIHexDecode filter" );
+ if ( mbCompression )
+ ImplWriteLine( "/LZWDecode filter" );
+ ImplWriteLine( ">>" );
+ ImplWriteLine( "image" );
+ if ( mbCompression )
+ {
+ StartCompression();
+ for ( long y = 0; y < nHeight; y++ )
+ {
+ for ( long x = 0; x < nWidth; x++ )
+ {
+ const BitmapColor aBitmapColor( pAcc->GetPixel( y, x ) );
+ Compress( aBitmapColor.GetRed() );
+ Compress( aBitmapColor.GetGreen() );
+ Compress( aBitmapColor.GetBlue() );
+ }
+ }
+ EndCompression();
+ }
+ else
+ {
+ for ( long y = 0; y < nHeight; y++ )
+ {
+ for ( long x = 0; x < nWidth; x++ )
+ {
+ const BitmapColor aBitmapColor( pAcc->GetPixel( y, x ) );
+ ImplWriteHexByte( aBitmapColor.GetRed() );
+ ImplWriteHexByte( aBitmapColor.GetGreen() );
+ ImplWriteHexByte( aBitmapColor.GetBlue() );
+ }
+ }
+ }
+ }
+ }
+ ImplWriteLine( ">" ); // in Level 2 the dictionary needs to be closed (eod)
+ }
+ if ( bDoTrans )
+ ImplWriteLine( "gr" );
+ else
+ ImplWriteLine( "pom" );
+
+ aTileBitmap.ReleaseAccess( pAcc );
+ nHeightLeft -= nHeight;
+ if ( nHeightLeft )
+ {
+ nHeightLeft++;
+ aSourcePos.Y() = (long) ( rPoint.Y() + ( nYHeightOrg * ( nHeightOrg - nHeightLeft ) ) / nHeightOrg );
+ }
+ }
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplWriteCharacter( sal_Char nChar )
+{
+ switch( nChar )
+ {
+ case '(' :
+ case ')' :
+ case '\\' :
+ ImplWriteByte( (BYTE)'\\', PS_NONE );
+ }
+ ImplWriteByte( (BYTE)nChar, PS_NONE );
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplWriteString( const ByteString& rString, const INT32* pDXArry, BOOL bStretch )
+{
+ USHORT nLen = rString.Len();
+ if ( nLen )
+ {
+ USHORT i;
+ if ( pDXArry )
+ {
+ double nx = 0;
+
+ for( i = 0; i < nLen; i++ )
+ {
+ if ( i > 0 )
+ nx = pDXArry[ i - 1 ] * nXScaling;
+ ImplWriteDouble( ( bStretch ) ? nx : aOutputDevice.GetTextWidth( rString.GetChar( i ) ) * nXScaling );
+ ImplWriteDouble( nx );
+ ImplWriteLine( "(", PS_NONE );
+ ImplWriteCharacter( rString.GetChar( i ) );
+ ImplWriteLine( ") bs" );
+ }
+ }
+ else
+ {
+ ImplWriteByte( '(', PS_NONE );
+ for ( i = 0; i < nLen; i++ )
+ ImplWriteCharacter( rString.GetChar( i ) );
+ ImplWriteLine( ") s" );
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void PSWriter::ImplSetAttrForText( Point & aPoint )
+{
+ long nRotation = maFont.GetOrientation();
+ ImplWriteTextColor();
+
+ Size aSize = maFont.GetSize();
+
+ if ( maLastFont != maFont )
+ {
+ if ( maFont.GetPitch() == PITCH_FIXED ) // a little bit font selection
+ ImplDefineFont( "Courier", "Oblique" );
+ else if ( maFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL )
+ ImplWriteLine( "/Symbol findfont" );
+ else if ( maFont.GetFamily() == FAMILY_SWISS )
+ ImplDefineFont( "Helvetica", "Oblique" );
+ else
+ ImplDefineFont( "Times", "Italic" );
+
+ maLastFont = maFont;
+ aSize = maFont.GetSize();
+ ImplWriteDouble( aSize.Height() * nYScaling ); ///???????????????????
+ *mpPS << "sf ";
+ }
+ if ( eTextAlign != ALIGN_BASELINE )
+ { // PostScript kennt kein FontAlignment
+ if ( eTextAlign == ALIGN_TOP ) // -> ich gehe daher davon aus, dass
+ aPoint.Y() += ( aSize.Height() * 4 / 5 ); // der Bereich unter der Baseline
+ else if ( eTextAlign == ALIGN_BOTTOM ) // in etwa 20% der Fontsize ausmacht
+ aPoint.Y() -= ( aSize.Height() / 5 );
+ }
+ ImplMoveTo( aPoint );
+ if ( nRotation )
+ {
+ *mpPS << "gs ";
+ ImplWriteF( nRotation, 1 );
+ *mpPS << "r ";
+ }
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplDefineFont( char* pOriginalName, char* pItalic )
+{
+ *mpPS << (BYTE)'/'; //convert the font pOriginalName using ISOLatin1Encoding
+ *mpPS << pOriginalName;
+ switch ( maFont.GetWeight() )
+ {
+ case WEIGHT_SEMIBOLD :
+ case WEIGHT_BOLD :
+ case WEIGHT_ULTRABOLD :
+ case WEIGHT_BLACK :
+ *mpPS << "-Bold";
+ if ( maFont.GetItalic() != ITALIC_NONE )
+ *mpPS << pItalic;
+ break;
+ default:
+ if ( maFont.GetItalic() != ITALIC_NONE )
+ *mpPS << pItalic;
+ break;
+ }
+ ImplWriteLine( " f" );
+}
+
+//---------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplClosePathFill( ULONG nMode )
+{
+ *mpPS << "pf";
+ mnCursorPos += 2;
+ ImplExecMode( nMode );
+}
+
+void PSWriter::ImplClosePathDraw( ULONG nMode )
+{
+ *mpPS << "pc";
+ mnCursorPos += 2;
+ ImplExecMode( nMode );
+}
+
+void PSWriter::ImplPathDraw( ULONG nMode )
+{
+ *mpPS << "ps";
+ mnCursorPos += 2;
+ ImplExecMode( nMode );
+}
+
+//---------------------------------------------------------------------------------
+
+inline void PSWriter::ImplWriteLineColor( ULONG nMode )
+{
+ if ( aColor != aLineColor )
+ {
+ aColor = aLineColor;
+ ImplWriteColor( nMode );
+ }
+}
+inline void PSWriter::ImplWriteFillColor( ULONG nMode )
+{
+ if ( aColor != aFillColor )
+ {
+ aColor = aFillColor;
+ ImplWriteColor( nMode );
+ }
+}
+inline void PSWriter::ImplWriteTextColor( ULONG nMode )
+{
+ if ( aColor != aTextColor )
+ {
+ aColor = aTextColor;
+ ImplWriteColor( nMode );
+ }
+}
+inline void PSWriter::ImplWriteTextFillColor( ULONG nMode )
+{
+ if ( aColor != aTextFillColor )
+ {
+ aColor = aTextFillColor;
+ ImplWriteColor( nMode );
+ }
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplWriteColor( ULONG nMode )
+{
+ if ( mbGrayScale )
+ {
+ // writes the Color (grayscale) as a Number from 0.000 up to 1.000
+
+ ImplWriteF( 1000 * ( (BYTE)aColor.GetRed() * 77 + (BYTE)aColor.GetGreen() * 151 +
+ (BYTE)aColor.GetBlue() * 28 + 1 ) / 65536, 3, nMode );
+ }
+ else
+ {
+ ImplWriteB1 ( (BYTE)aColor.GetRed() );
+ ImplWriteB1 ( (BYTE)aColor.GetGreen() );
+ ImplWriteB1 ( (BYTE)aColor.GetBlue() );
+ }
+ *mpPS << "c"; // ( c is defined as setrgbcolor or setgray )
+ ImplExecMode( nMode );
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplGetMapMode( const MapMode& aMapMode )
+{
+ aOutputDevice.SetMapMode( aMapMode );
+ double nMul;
+ switch ( aMapMode.GetMapUnit() )
+ {
+ case MAP_PIXEL :
+ case MAP_SYSFONT :
+ case MAP_APPFONT :
+
+ case MAP_100TH_MM :
+ nMul = 1 * EPS_SCALING_FAKTOR;
+ break;
+ case MAP_10TH_MM :
+ nMul = 10 * EPS_SCALING_FAKTOR;
+ break;
+ case MAP_MM :
+ nMul = 100 * EPS_SCALING_FAKTOR;
+ break;
+ case MAP_CM :
+ nMul = 1000 * EPS_SCALING_FAKTOR;
+ break;
+ case MAP_1000TH_INCH :
+ nMul = 2.54 * EPS_SCALING_FAKTOR;
+ break;
+ case MAP_100TH_INCH :
+ nMul = 25.4 * EPS_SCALING_FAKTOR;
+ break;
+ case MAP_10TH_INCH :
+ nMul = 254 * EPS_SCALING_FAKTOR;
+ break;
+ case MAP_INCH :
+ nMul = 2540 * EPS_SCALING_FAKTOR;
+ break;
+ case MAP_TWIP :
+ nMul = 1,76388889 * EPS_SCALING_FAKTOR;
+ break;
+ case MAP_POINT :
+ nMul = 35,27777778 * EPS_SCALING_FAKTOR;
+ break;
+ default:
+ // that does not look right
+ break;
+ }
+ nXOrigin = aMapMode.GetOrigin().X() * nMul;
+ nYOrigin = aMapMode.GetOrigin().Y() * nMul;
+ double nScale = aMapMode.GetScaleX();
+ nXScaling = nMul * nScale;
+ nScale = aMapMode.GetScaleY();
+ nYScaling = nMul * nScale;
+}
+
+//---------------------------------------------------------------------------------
+
+inline void PSWriter::ImplExecMode( ULONG nMode )
+{
+ if ( nMode & PS_WRAP )
+ {
+ if ( mnCursorPos >= PS_LINESIZE )
+ {
+ mnCursorPos = 0;
+ *mpPS << (BYTE)0xa;
+ return;
+ }
+ }
+ if ( nMode & PS_SPACE )
+ {
+ *mpPS << (BYTE)32;
+ mnCursorPos++;
+ }
+ if ( nMode & PS_RET )
+ {
+ *mpPS << (BYTE)0xa;
+ mnCursorPos = 0;
+ }
+}
+
+//---------------------------------------------------------------------------------
+
+inline void PSWriter::ImplWriteLine( char pString[], ULONG nMode )
+{
+ ULONG i = 0;
+ while ( pString[ i ] )
+ {
+ *mpPS << (BYTE)pString[ i++ ];
+ }
+ mnCursorPos += i;
+ ImplExecMode( nMode );
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplWriteLineInfo( const LineInfo& rLineInfo )
+{
+ double fLineWidth = ( ( rLineInfo.GetWidth() + 1 ) * nXScaling + ( rLineInfo.GetWidth() + 1 ) * nYScaling ) * 0.5;
+ ImplWriteLine( "cl", PS_SPACE ); // currentLineWidth & currentDash auf den Stack
+ ImplWriteDouble( fLineWidth );
+ ImplWriteLine( " lw", PS_SPACE );
+ if ( rLineInfo.GetStyle() == LINE_DASH )
+ {
+ ImplWriteLine( "[ 2 ] 1 ld" );
+ }
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplWriteLong( sal_Int32 nNumber, ULONG nMode )
+{
+ const ByteString aNumber( ByteString::CreateFromInt32( nNumber ) );
+ ULONG nLen = aNumber.Len();
+ mnCursorPos += nLen;
+ for ( USHORT n = 0; n < nLen; n++ )
+ *mpPS << aNumber.GetChar( n );
+ ImplExecMode( nMode );
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplWriteDouble( double fNumber, ULONG nMode )
+{
+ sal_Int32 n, nLen;
+
+ sal_Int32 nPTemp = (sal_Int32)fNumber;
+ sal_Int32 nATemp = abs( ( fNumber - nPTemp ) * 100000 );
+
+ if ( !nPTemp && nATemp && ( fNumber < 0.0 ) )
+ *mpPS << (sal_Char)'-';
+
+ ByteString aNumber1( ByteString::CreateFromInt32( nPTemp ) );
+ nLen = aNumber1.Len();
+ mnCursorPos += nLen;
+ for ( n = 0; n < nLen; n++ )
+ *mpPS << aNumber1.GetChar( n );
+
+ int zCount = 0;
+ if ( nATemp )
+ {
+ *mpPS << (BYTE)'.';
+ mnCursorPos++;
+ const ByteString aNumber2( ByteString::CreateFromInt32( nATemp ) );
+
+ ULONG nLen = aNumber2.Len();
+ if ( nLen < 8 )
+ {
+ mnCursorPos += 6 - nLen;
+ for ( n = 0; n < ( 5 - nLen ); n++ )
+ {
+ *mpPS << (BYTE)'0';
+ }
+ }
+ mnCursorPos += nLen;
+ for ( USHORT n = 0; n < nLen; n++ )
+ {
+ *mpPS << aNumber2.GetChar( n );
+ zCount--;
+ if ( aNumber2.GetChar( n ) != '0' )
+ zCount = 0;
+ }
+ if ( zCount )
+ mpPS->SeekRel( zCount );
+ }
+ ImplExecMode( nMode );
+}
+
+//---------------------------------------------------------------------------------
+
+// writes the number to stream: nNumber / ( 10^nCount )
+
+void PSWriter::ImplWriteF( sal_Int32 nNumber, ULONG nCount, ULONG nMode )
+{
+ if ( nNumber < 0 )
+ {
+ *mpPS << (BYTE)'-';
+ nNumber = -nNumber;
+ mnCursorPos++;
+ }
+ const ByteString aScaleFactor( ByteString::CreateFromInt32( nNumber ) );
+ ULONG nLen = aScaleFactor.Len();
+ long nStSize = ( nCount + 1 ) - nLen;
+ if ( nStSize >= 1 )
+ {
+ *mpPS << (BYTE)'0';
+ mnCursorPos++;
+ }
+ if ( nStSize >= 2 )
+ {
+ *mpPS << (BYTE)'.';
+ for ( long i = 1; i < nStSize; i++ )
+ {
+ *mpPS << (BYTE)'0';
+ mnCursorPos++;
+ }
+ }
+ mnCursorPos += nLen;
+ for( USHORT n = 0UL; n < nLen; n++ )
+ {
+ if ( n == nLen - nCount )
+ {
+ *mpPS << (BYTE)'.';
+ mnCursorPos++;
+ }
+ *mpPS << aScaleFactor.GetChar( n );
+ }
+ ImplExecMode( nMode );
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplWriteByte( BYTE nNumb, ULONG nMode )
+{
+ *mpPS << ( nNumb );
+ mnCursorPos++;
+ ImplExecMode( nMode );
+}
+
+//---------------------------------------------------------------------------------
+
+void PSWriter::ImplWriteHexByte( BYTE nNumb, ULONG nMode )
+{
+ if ( ( nNumb >> 4 ) > 9 )
+ *mpPS << (BYTE)( ( nNumb >> 4 ) + 'A' - 10 );
+ else
+ *mpPS << (BYTE)( ( nNumb >> 4 ) + '0' );
+
+ if ( ( nNumb & 0xf ) > 9 )
+ *mpPS << (BYTE)( ( nNumb & 0xf ) + 'A' - 10 );
+ else
+ *mpPS << (BYTE)( ( nNumb & 0xf ) + '0' );
+ mnCursorPos += 2;
+ ImplExecMode( nMode );
+}
+
+//---------------------------------------------------------------------------------
+
+// writes the BYTE nNumb as a Number from 0.000 up to 1.000
+
+void PSWriter::ImplWriteB1( BYTE nNumb, ULONG nMode )
+{
+ ImplWriteF( 1000 * ( nNumb + 1 ) / 256 , 3, nMode );
+}
+
+
+// ------------------------------------------------------------------------
+
+inline void PSWriter::WriteBits( USHORT nCode, USHORT nCodeLen )
+{
+ dwShift |= ( nCode << ( nOffset - nCodeLen ) );
+ nOffset -= nCodeLen;
+ while ( nOffset < 24 )
+ {
+ ImplWriteHexByte( (BYTE)( dwShift >> 24 ) );
+ dwShift <<= 8;
+ nOffset += 8;
+ }
+ if ( nCode == 257 && nOffset != 32 )
+ ImplWriteHexByte( (BYTE)( dwShift >> 24 ) );
+}
+
+// ------------------------------------------------------------------------
+
+void PSWriter::StartCompression()
+{
+ USHORT i;
+ nDataSize = 8;
+
+ nClearCode = 1 << nDataSize;
+ nEOICode = nClearCode + 1;
+ nTableSize = nEOICode + 1;
+ nCodeSize = nDataSize + 1;
+
+ nOffset = 32; // anzahl freier bits in dwShift
+ dwShift = 0;
+
+ pTable = new PSLZWCTreeNode[ 4096 ];
+
+ for ( i = 0; i < 4096; i++ )
+ {
+ pTable[ i ].pBrother = pTable[ i ].pFirstChild = NULL;
+ pTable[ i ].nValue = (BYTE)( pTable[ i ].nCode = i );
+ }
+ pPrefix = NULL;
+ WriteBits( nClearCode, nCodeSize );
+}
+
+// ------------------------------------------------------------------------
+
+void PSWriter::Compress( BYTE nCompThis )
+{
+ PSLZWCTreeNode* p;
+ USHORT i;
+ BYTE nV;
+
+ if( !pPrefix )
+ {
+ pPrefix = pTable + nCompThis;
+ }
+ else
+ {
+ nV = nCompThis;
+ for( p = pPrefix->pFirstChild; p != NULL; p = p->pBrother )
+ {
+ if ( p->nValue == nV )
+ break;
+ }
+
+ if( p )
+ pPrefix = p;
+ else
+ {
+ WriteBits( pPrefix->nCode, nCodeSize );
+
+ if ( nTableSize == 409 )
+ {
+ WriteBits( nClearCode, nCodeSize );
+
+ for ( i = 0; i < nClearCode; i++ )
+ pTable[ i ].pFirstChild = NULL;
+
+ nCodeSize = nDataSize + 1;
+ nTableSize = nEOICode + 1;
+ }
+ else
+ {
+ if( nTableSize == (USHORT)( ( 1 << nCodeSize ) - 1 ) )
+ nCodeSize++;
+
+ p = pTable + ( nTableSize++ );
+ p->pBrother = pPrefix->pFirstChild;
+ pPrefix->pFirstChild = p;
+ p->nValue = nV;
+ p->pFirstChild = NULL;
+ }
+
+ pPrefix = pTable + nV;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void PSWriter::EndCompression()
+{
+ if( pPrefix )
+ WriteBits( pPrefix->nCode, nCodeSize );
+
+ WriteBits( nEOICode, nCodeSize );
+ delete[] pTable;
+}
+
+// ------------------------------------------------------------------------
+
+BYTE* PSWriter::ImplSearchEntry( BYTE* pSource, BYTE* pDest, ULONG nComp, ULONG nSize )
+{
+ while ( nComp-- >= nSize )
+ {
+ ULONG i;
+ for ( i = 0; i < nSize; i++ )
+ {
+ if ( ( pSource[i]&~0x20 ) != ( pDest[i]&~0x20 ) )
+ break;
+ }
+ if ( i == nSize )
+ return pSource;
+ pSource++;
+ }
+ return NULL;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL PSWriter::ImplGetBoundingBox( double* nNumb, BYTE* pSource, ULONG nSize )
+{
+ BOOL bRetValue = FALSE;
+ ULONG nBytesRead;
+
+ if ( nSize < 256 ) // we assume that the file is greater than 256 bytes
+ return FALSE;
+
+ if ( nSize < POSTSCRIPT_BOUNDINGSEARCH )
+ nBytesRead = nSize;
+ else
+ nBytesRead = POSTSCRIPT_BOUNDINGSEARCH;
+
+ BYTE* pDest = ImplSearchEntry( pSource, (BYTE*)"%%BoundingBox:", nBytesRead, 14 );
+ if ( pDest )
+ {
+ int nSecurityCount = 100; // only 100 bytes following the bounding box will be checked
+ nNumb[0] = nNumb[1] = nNumb[2] = nNumb[3] = 0;
+ pDest += 14;
+ for ( int i = 0; ( i < 4 ) && nSecurityCount; i++ )
+ {
+ int nDivision = 1;
+ BOOL bDivision = FALSE;
+ BOOL bNegative = FALSE;
+ BOOL bValid = TRUE;
+
+ while ( ( --nSecurityCount ) && ( *pDest == ' ' ) || ( *pDest == 0x9 ) ) pDest++;
+ BYTE nByte = *pDest;
+ while ( nSecurityCount && ( nByte != ' ' ) && ( nByte != 0x9 ) && ( nByte != 0xd ) && ( nByte != 0xa ) )
+ {
+ switch ( nByte )
+ {
+ case '.' :
+ if ( bDivision )
+ bValid = FALSE;
+ else
+ bDivision = TRUE;
+ break;
+ case '-' :
+ bNegative = TRUE;
+ break;
+ default :
+ if ( ( nByte < '0' ) || ( nByte > '9' ) )
+ nSecurityCount = 1; // error parsing the bounding box values
+ else if ( bValid )
+ {
+ if ( bDivision )
+ nDivision*=10;
+ nNumb[i] *= 10;
+ nNumb[i] += nByte - '0';
+ }
+ break;
+ }
+ nSecurityCount--;
+ nByte = *(++pDest);
+ }
+ if ( bNegative )
+ nNumb[i] = -nNumb[i];
+ if ( bDivision && ( nDivision != 1 ) )
+ nNumb[i] /= nDivision;
+ }
+ if ( nSecurityCount)
+ bRetValue = TRUE;
+ }
+ return bRetValue;
+}
+
+//================== GraphicExport - die exportierte Funktion ================
+
+#ifdef WNT
+extern "C" BOOL _cdecl GraphicExport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config* pOptionsConfig, BOOL)
+#else
+extern "C" BOOL GraphicExport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config* pOptionsConfig, BOOL)
+#endif
+{
+ PSWriter aPSWriter;
+ return aPSWriter.WritePS( rGraphic, rStream, pCallback, pCallerData, pOptionsConfig );
+}
+
+//---------------------------------------------------------------------------------
+
+extern "C" BOOL __LOADONCALLAPI DoExportDialog( FltCallDialogParameter& rPara )
+{
+ BOOL bRet = FALSE;
+
+ if ( rPara.pWindow && rPara.pCfg )
+ {
+ ByteString aResMgrName( "eps" );
+ ResMgr* pResMgr;
+
+ aResMgrName.Append( ByteString::CreateFromInt32( SOLARUPD ) );
+ pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetAppInternational().GetLanguage() );
+
+ if( pResMgr )
+ {
+ rPara.pResMgr = pResMgr;
+ bRet = ( DlgExportEPS( rPara ).Execute() == RET_OK );
+ delete pResMgr;
+ }
+ else
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+//================== ein bischen Muell fuer Windows ==========================
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
diff --git a/goodies/source/filter.vcl/eps/epsstr.src b/goodies/source/filter.vcl/eps/epsstr.src
new file mode 100644
index 000000000000..ef340c7af28e
--- /dev/null
+++ b/goodies/source/filter.vcl/eps/epsstr.src
@@ -0,0 +1,188 @@
+/*************************************************************************
+ *
+ * $RCSfile: epsstr.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include "strings.hrc"
+
+// Key fuer den Dialog
+String KEY_PREVIEW
+{
+ Text = "EPS Vorschaubild";
+ Text[ ENGLISH ] = "EPS preview";
+ Text[ italian ] = "Anteprima immagine EPS";
+ Text[ portuguese_brazilian ] = "EPS Vorschaubild";
+ Text[ portuguese ] = "Imagem de previsualização EPS";
+ Text[ danish ] = "EPS eksempelbillede";
+ Text[ french ] = "Aperçu EPS";
+ Text[ swedish ] = "EPS förhandsvisningsbild";
+ Text[ dutch ] = "EPS Voorbeeld";
+ Text[ spanish ] = "Previsualización EPS";
+ Text[ english_us ] = "EPS preview image";
+ Text[ chinese_simplified ] = "EPS Ô¤ÊÓͼ";
+ Text[ russian ] = "Ïðîñìîòð êàðòèíêè EPS";
+ Text[ polish ] = "Podgl¹d EPS";
+ Text[ japanese ] = "EPS ÌßÚËÞ­°²Ò°¼Þ";
+ Text[ greek ] = "Åéêüíá ðñïåðéóêüðçóçò EPS";
+ Text[ korean ] = "EPS ¹Ì¸® º¸±â À̹ÌÁö";
+ Text[ chinese_traditional ] = "EPS À˵ø¹Ï";
+ Text[ arabic ] = "ÕæÑÉ ÇáãÚÇíäÉ EPS";
+ Text[ turkish ] = "EPS önizleme resmi";
+ Text[ language_user1 ] = " ";
+};
+String KEY_VERSION
+{
+ Text = "EPS Version";
+ Text[ ENGLISH ] = "EPS version";
+ Text[ italian ] = "Versione EPS";
+ Text[ portuguese_brazilian ] = "EPS Version";
+ Text[ portuguese ] = "Versão EPS";
+ Text[ danish ] = "EPS version";
+ Text[ french ] = "Version EPS";
+ Text[ swedish ] = "EPS version";
+ Text[ dutch ] = "EPS versie";
+ Text[ spanish ] = "Versión EPS";
+ Text[ english_us ] = "EPS version";
+ Text[ chinese_simplified ] = "EPS °æ±¾";
+ Text[ russian ] = "Âåðñèÿ EPS";
+ Text[ polish ] = "Wersja EPS";
+ Text[ japanese ] = "EPS ÊÞ°¼Þ®Ý";
+ Text[ greek ] = "¸êäïóç EPS";
+ Text[ korean ] = "EPS ¹öÀü";
+ Text[ chinese_traditional ] = "EPS ª©¥»";
+ Text[ arabic ] = "EPS ÅÕÏÇÑ";
+ Text[ turkish ] = "EPS sürümü";
+ Text[ language_user1 ] = " ";
+};
+String KEY_COLOR
+{
+ Text = "EPS Farb-Format";
+ Text[ ENGLISH ] = "EPS color format";
+ Text[ italian ] = "Formato colore EPS";
+ Text[ portuguese_brazilian ] = "EPS Farb-Format";
+ Text[ portuguese ] = "Formato de cor EPS";
+ Text[ danish ] = "EPS farveformat";
+ Text[ french ] = "Format de couleur EPS";
+ Text[ swedish ] = "EPS färgformat";
+ Text[ dutch ] = "EPS kleuropmaak";
+ Text[ spanish ] = "Formato de color EPS";
+ Text[ english_us ] = "EPS color format";
+ Text[ chinese_simplified ] = "EPS ÑÕÉ«¸ñʽ";
+ Text[ russian ] = "Ôîðìàò öâåòà EPS";
+ Text[ polish ] = "Format koloru EPS";
+ Text[ japanese ] = "EPS F‚Ì‘Ž®";
+ Text[ greek ] = "ÌïñöÞ ÷ñþìáôïò EPS";
+ Text[ korean ] = "EPS »ö ¼­½Ä";
+ Text[ chinese_traditional ] = "EPS ÃC¦â®æ¦¡";
+ Text[ arabic ] = "EPS ÊäÓíÞ ÇáÃáæÇä";
+ Text[ turkish ] = "EPS renk formatý";
+ Text[ language_user1 ] = " ";
+};
+String KEY_COMPR
+{
+ Text = "EPS Kompressionart";
+ Text[ ENGLISH ] = "EPS compression type";
+ Text[ italian ] = "Tipo di compressione EPS";
+ Text[ portuguese_brazilian ] = "EPS Kompressionart";
+ Text[ portuguese ] = "Modo de compressão EPS";
+ Text[ danish ] = "EPS kompressionstype";
+ Text[ french ] = "Type de compression EPS";
+ Text[ swedish ] = "EPS kompressionssätt";
+ Text[ dutch ] = "EPS compressietype";
+ Text[ spanish ] = "Tipo de compresión EPS";
+ Text[ english_us ] = "EPS compression mode";
+ Text[ chinese_simplified ] = "EPS ѹËõ·½Ê½";
+ Text[ russian ] = "Òèï óæàòèÿ EPS";
+ Text[ polish ] = "Tryb kompresji EPS";
+ Text[ japanese ] = "EPS ˆ³kÓ°ÄÞ";
+ Text[ greek ] = "Ôýðïò óõìðßåóçò EPS";
+ Text[ korean ] = "EPS ¾ÐÃà ¸ðµå";
+ Text[ chinese_traditional ] = "EPS À£ÁY¤è¦¡";
+ Text[ arabic ] = "EPS ØÑíÞÉ ÇáÖÛØ";
+ Text[ turkish ] = "EPS sýkýþtýrma türü";
+ Text[ language_user1 ] = " ";
+};
+
+String KEY_VERSION_CHECK
+{
+ Text = "Achtung: Es konnten nicht alle importierte EPS-Grafiken in Level1 abgespeichert werden,\n"
+ "da einige in einem höherem Level vorliegen !";
+ Text[ ENGLISH ] = "Attention: It was not possible to save all imported EPS graphics in level1,"
+ "because some of them already attend to a higher level !";
+ Text[ italian ] = "Attenzione: non è stato possibile salvare tutte le immagini EPS importate nel livello1\nin quanto ne esistono alcune in un livello superiore!";
+ Text[ portuguese_brazilian ] = "Achtung: Es konnten nicht alle importierte EPS-Grafiken in Level1 abgespeichert werden,\nda einige in einem höherem Level vorliegen !";
+ Text[ portuguese ] = "Atenção: foi impossível guardar todas as imagens EPS importadas no nível 1,\numa vez que algumas se encontram num nível superior!";
+ Text[ danish ] = "Advarsel: Det var ikke muligt at gemme alle importerede EPS-billeder på niveau1,\nfordi nogle foreligger på et højere niveau !";
+ Text[ french ] = "Attention : Les graphiques EPS importés n'ont pas tous pu être enregistrés au niveau1\ncar certains d'entre eux sont d'un niveau supérieur !";
+ Text[ swedish ] = "OBS: Alla importerade EPS-grafiker kunde inte sparas på Level1,\neftersom en del finns på en högre nivå !";
+ Text[ dutch ] = "Pas op: Niet alle geïmporteerde EPS-afbeeldingen konden onder Level1 worden opgeslagen,\ndaar enkele ervan op een hoger level liggen !";
+ Text[ spanish ] = "¡Atención: No han podido ser guardados en Level1 todos los gráficos EPS importados\nporque existen algunos en un nivel más alto!";
+ Text[ english_us ] = "Warning: Not all of the imported EPS graphics could be saved at level1\nas some are at a higher level!";
+ Text[ chinese_simplified ] = "×¢Òâ: ÎÞ·¨½«ËùÓеÄÊäÈëͼÐÎÒÔ¡°¼¶±ð 1¡±´æÅÌ£¬\nÒòΪһЩͼÐÎÊǸßÓÚ¡°¼¶±ð 1¡± £¡";
+ Text[ russian ] = "Âíèìàíèå! Ñîõðàíèòü âñå èìïîðòèðîâàííûå èçîáðàæåíèÿ EPS íà óðîâíå 1 íåâîçìîæíî,\nòàê êàê íåêîòîðûå èç íèõ íàõîäÿòñÿ íà áîëåå âûñîêîì óðîâíå !";
+ Text[ polish ] = "Uwaga: Nie wszystkie importowane grafiki EPS mog³y zostaæ zapisane na poziomie1, \nponiewa¿ niektóre znajduj¹ siê na wy¿szym poziomie!";
+ Text[ japanese ] = "’ˆÓ: ²ÝÎß°Ä‚³‚ꂽ EPS ¸Þ×̨¯¸‚Ì’†‚Ì‚¢‚­‚‚©‚Í\n‚‚¢ÚÍÞÙ‚É‚ ‚é‚Ì‚ÅÚÍÞÙ1‚É•Û‘¶‚Å‚«‚Ü‚¹‚ñ!";
+ Text[ greek ] = "Ðñïóï÷Þ: Äåí Þôáí äõíáôüí íá ãßíåé áðïèÞêåõóç üëùí ôùí åéóçãìÝíùí ãñáöéêþí EPS,\nåðåéäÞ ìåñéêÜ áðü áõôÜ õðÜñ÷ïõí óå ìïñöÞ õøçëüôåñïõ åðéðÝäïõ!";
+ Text[ korean ] = "ÁÖÀÇ: »óÀ§ ·¹º§¿¡ ±×·¡ÇÈÀÌ ¸î °¡Áö Àֱ⠶§¹®¿¡\n°¡Á®¿Â EPS ±×·¡ÇÈÀ» ·¹º§1¿¡ ¸ðµÎ ÀúÀåÇÏÁö´Â ¸øÇß½À´Ï´Ù.";
+ Text[ chinese_traditional ] = "ª`·N¡GµLªk±N©Ò¦³ªº¿é¤J¹Ï§Î¥H¡§level 1¡¨Àx¦s¡M\n¦]¬°¤@¨Ç¹Ï§Î¬O°ª©ó¡§level 1¡¨ ¡I";
+ Text[ arabic ] = "ÊÍÐíÑ: ÊÚÐÑ ÍÝÙ ßá ÕæÑ EPS ÇáãÓÊæÑÏÉ Ýí ÇáãÓÊæì 1¡\náÊæÇÌÏ ÈÚÖ ãäåÇ Ýí ãÓÊæì ÃÚáì!";
+ Text[ turkish ] = "Dikkat: Bazý EPS grafikleri daha üst düzeyde olduðu için, içe aktarýlan tüm grafikler düzey 1'e kaydedilemedi.";
+ Text[ language_user1 ] = " ";
+};
diff --git a/goodies/source/filter.vcl/eps/makefile.mk b/goodies/source/filter.vcl/eps/makefile.mk
new file mode 100644
index 000000000000..efdd66bf05bc
--- /dev/null
+++ b/goodies/source/filter.vcl/eps/makefile.mk
@@ -0,0 +1,181 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=eps
+DEPTARGET=veps
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+GEN_HID=TRUE
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SRCFILES = dlgeps.src \
+ epsstr.src
+
+SLOFILES = $(SLO)$/eps.obj \
+ $(SLO)$/dlgeps.obj
+
+# ==========================================================================
+RESLIB1NAME=$(TARGET)
+RESLIB1SRSFILES=\
+ $(SRS)$/$(TARGET).srs
+
+SHL1TARGET= eps$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= eps
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(SVLIB) $(SVTOOLLIB) $(CPPULIB)
+SHL1DEPN= $(LB)$/eps.lib
+SHL1LIBS= $(SLB)$/eps.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/eps.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicExport >>$@
+ @echo DoExportDialog >>$@
+.ELSE
+ @echo _GraphicExport >>$@
+ @echo _DoExportDialog >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET) >>$@
+ @echo GraphicExport_ >>temp.def
+ @echo DoExportDialog_ >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicExport >>$@
+ @echo DoExportDialog >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/eps/strings.hrc b/goodies/source/filter.vcl/eps/strings.hrc
new file mode 100644
index 000000000000..5b6f111d5dc5
--- /dev/null
+++ b/goodies/source/filter.vcl/eps/strings.hrc
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * $RCSfile: strings.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#define KEY_COMPR 256
+#define KEY_VERSION 257
+#define KEY_COLOR 258
+#define KEY_PREVIEW 259
+#define KEY_VERSION_CHECK 260
+
diff --git a/goodies/source/filter.vcl/eras/eras.cxx b/goodies/source/filter.vcl/eras/eras.cxx
new file mode 100644
index 000000000000..4b5ff0867c5c
--- /dev/null
+++ b/goodies/source/filter.vcl/eras/eras.cxx
@@ -0,0 +1,345 @@
+/*************************************************************************
+ *
+ * $RCSfile: eras.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <vcl/graph.hxx>
+#include <vcl/bmpacc.hxx>
+#include <svtools/fltcall.hxx>
+
+//============================ RASWriter ==================================
+
+class RASWriter {
+
+private:
+
+ PFilterCallback mpCallback;
+ void * mpCallerData;
+
+ SvStream* mpOStm;
+ USHORT mpOStmOldModus;
+
+ BOOL mbStatus;
+ BitmapReadAccess* mpAcc;
+
+ ULONG mnWidth, mnHeight;
+ USHORT mnColors, mnDepth;
+
+ ULONG mnRepCount;
+ BYTE mnRepVal;
+
+ BOOL ImplCallback( ULONG nCurrentYPos );
+ BOOL ImplWriteHeader();
+ void ImplWritePalette();
+ void ImplWriteBody();
+ void ImplPutByte( BYTE ); // RLE decoding
+
+public:
+ RASWriter();
+ ~RASWriter();
+
+ BOOL WriteRAS( const Graphic& rGraphic, SvStream& rRAS,
+ PFilterCallback pCallback, void* pCallerdata,
+ Config* pOptionsConfig );
+};
+
+//=================== Methoden von RASWriter ==============================
+
+RASWriter::RASWriter() :
+ mpAcc ( NULL ),
+ mbStatus ( TRUE ),
+ mnRepCount ( 0xffffffff )
+{
+}
+
+// ------------------------------------------------------------------------
+
+RASWriter::~RASWriter()
+{
+}
+
+// ------------------------------------------------------------------------
+
+BOOL RASWriter::ImplCallback( ULONG nYPos )
+{
+ if ( mpCallback != NULL )
+ {
+ if ( ( (*mpCallback)( mpCallerData, (USHORT)( ( 100 * nYPos ) / mnHeight ) ) ) == TRUE )
+ {
+ mpOStm->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL RASWriter::WriteRAS( const Graphic& rGraphic, SvStream& rRAS,
+ PFilterCallback pCallback, void* pCallerdata,
+ Config* pOptionsConfig )
+{
+ Bitmap aBmp;
+
+ mpOStm = &rRAS;
+ mpCallback = pCallback;
+ mpCallerData = pCallerdata;
+
+ BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+ aBmp = aBmpEx.GetBitmap();
+
+ if ( aBmp.GetBitCount() == 4 )
+ aBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
+
+ mnDepth = aBmp.GetBitCount();
+
+ if ( ( mpAcc = aBmp.AcquireReadAccess() ) )
+ {
+ mpOStmOldModus = mpOStm->GetNumberFormatInt();
+ mpOStm->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+
+ if ( ImplWriteHeader() )
+ {
+ if ( mnDepth <= 8 )
+ ImplWritePalette();
+ ImplWriteBody();
+ }
+ aBmp.ReleaseAccess( mpAcc );
+ }
+ else
+ mbStatus = FALSE;
+
+ mpOStm->SetNumberFormatInt( mpOStmOldModus );
+
+ return mbStatus;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL RASWriter::ImplWriteHeader()
+{
+ mnWidth = mpAcc->Width();
+ mnHeight = mpAcc->Height();
+ if ( mnDepth <= 8 )
+ {
+ if (!( mnColors = mpAcc->GetPaletteEntryCount() ) )
+ mbStatus = FALSE;
+ }
+ if ( mbStatus && mnWidth && mnHeight && mnDepth )
+ {
+ *mpOStm << (UINT32)0x59a66a95 << (UINT32)mnWidth << (UINT32)mnHeight
+ << (UINT32)mnDepth
+ << (UINT32) ( ( ( ( mnWidth * mnDepth ) + 15 ) >> 4 ) << 1 ) * mnHeight
+ << (UINT32)2;
+
+ if ( mnDepth > 8 )
+ *mpOStm << (UINT32)0 << (UINT32)0;
+ else
+ {
+
+ *mpOStm << (UINT32)1 << (UINT32)( mnColors * 3 );
+ }
+ }
+ else mbStatus = FALSE;
+
+ return mbStatus;
+}
+
+// ------------------------------------------------------------------------
+
+void RASWriter::ImplWritePalette()
+{
+ USHORT i;
+
+ for ( i = 0; i < mnColors; *mpOStm << mpAcc->GetPaletteColor( i++ ).GetRed() );
+ for ( i = 0; i < mnColors; *mpOStm << mpAcc->GetPaletteColor( i++ ).GetGreen() );
+ for ( i = 0; i < mnColors; *mpOStm << mpAcc->GetPaletteColor( i++ ).GetBlue() );
+}
+
+// ------------------------------------------------------------------------
+
+void RASWriter::ImplWriteBody()
+{
+ ULONG x, y;
+
+ if ( mnDepth == 24 )
+ {
+ for ( y = 0; y < mnHeight; y++ )
+ {
+ ImplCallback( y ); // processing output
+ for ( x = 0; x < mnWidth; x++ )
+ {
+ BitmapColor aColor( mpAcc->GetPixel( y, x ) );
+ ImplPutByte( aColor.GetBlue() ); // Format ist BGR
+ ImplPutByte( aColor.GetGreen() );
+ ImplPutByte( aColor.GetRed() );
+ }
+ if ( x & 1 ) ImplPutByte( 0 ); // WORD ALIGNMENT ???
+ }
+ }
+ else if ( mnDepth == 8 )
+ {
+ for ( y = 0; y < mnHeight; y++ )
+ {
+ ImplCallback( y ); // processing output
+ for ( x = 0; x < mnWidth; x++ )
+ {
+ ImplPutByte ( mpAcc->GetPixel( y, x ) );
+ }
+ if ( x & 1 ) ImplPutByte( 0 ); // WORD ALIGNMENT ???
+ }
+ }
+ else if ( mnDepth == 1 )
+ {
+ BYTE nDat;
+
+ for ( y = 0; y < mnHeight; y++ )
+ {
+ ImplCallback( y ); // processing output
+ for ( x = 0; x < mnWidth; x++ )
+ {
+ nDat = ( ( nDat << 1 ) | ( mpAcc->GetPixel ( y, x ) & 1 ) );
+ if ( ( x & 7 ) == 7 )
+ ImplPutByte( nDat );
+ }
+ if ( x & 7 )
+ ImplPutByte( nDat << ( ( ( x & 7 ) ^ 7 ) + 1) );// write remaining bits
+ if (!( ( x - 1 ) & 0x8 ) )
+ ImplPutByte( 0 ); // WORD ALIGNMENT ???
+ }
+ }
+ ImplPutByte( mnRepVal + 1 ); // end of RLE decoding
+}
+
+// ------------------------------------------------------------------------
+
+void RASWriter::ImplPutByte( BYTE nPutThis )
+{
+ if ( mnRepCount == 0xffffffff )
+ {
+ mnRepCount = 0;
+ mnRepVal = nPutThis;
+ }
+ else
+ {
+ if ( ( nPutThis == mnRepVal ) && ( mnRepCount != 0xff ) )
+ mnRepCount++;
+ else
+ {
+ if ( mnRepCount == 0 )
+ {
+ *mpOStm << (BYTE)mnRepVal;
+ if ( mnRepVal == 0x80 )
+ *mpOStm << (BYTE)0;
+ }
+ else
+ {
+ *mpOStm << (BYTE)0x80;
+ *mpOStm << (BYTE)mnRepCount;
+ *mpOStm << (BYTE)mnRepVal;
+ }
+ mnRepVal = nPutThis;
+ mnRepCount = 0;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+// ---------------------
+// - exported function -
+// ---------------------
+
+extern "C" BOOL __LOADONCALLAPI GraphicExport( SvStream& rStream, Graphic& rGraphic,
+ PFilterCallback pCallback, void* pCallerData,
+ Config* pOptionsConfig, BOOL )
+{
+ RASWriter aRASWriter;
+
+ return aRASWriter.WriteRAS( rGraphic, rStream, pCallback, pCallerData, pOptionsConfig );
+}
+
+#pragma hdrstop
+
+// ---------------
+// - Win16 trash -
+// ---------------
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0;
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+ if ( nHeap )
+ UnlockData( 0 );
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
diff --git a/goodies/source/filter.vcl/eras/makefile.mk b/goodies/source/filter.vcl/eras/makefile.mk
new file mode 100644
index 000000000000..8042437f5f67
--- /dev/null
+++ b/goodies/source/filter.vcl/eras/makefile.mk
@@ -0,0 +1,169 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=eras
+DEPTARGET=veras
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SLOFILES = $(SLO)$/eras.obj
+
+# ==========================================================================
+
+SHL1TARGET= era$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= eras
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(CPPULIB)
+SHL1DEPN= $(LB)$/eras.lib
+SHL1LIBS= $(SLB)$/eras.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/eras.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicExport >>$@
+.ELSE
+ @echo _GraphicExport >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET).DLL >>$@
+ @ldump -E1 -A $(SLB)$/eras.lib >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicExport >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/etiff/etiff.cxx b/goodies/source/filter.vcl/etiff/etiff.cxx
new file mode 100644
index 000000000000..3ed0ec8f272b
--- /dev/null
+++ b/goodies/source/filter.vcl/etiff/etiff.cxx
@@ -0,0 +1,663 @@
+/*************************************************************************
+ *
+ * $RCSfile: etiff.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <vcl/graph.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/config.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/bmpacc.hxx>
+#include <svtools/solar.hrc>
+#include <svtools/fltcall.hxx>
+
+#define NewSubfileType 254
+#define ImageWidth 256
+#define ImageLength 257
+#define BitsPerSample 258
+#define Compression 259
+#define PhotometricInterpretation 262
+#define StripOffsets 273
+#define SamplesPerPixel 277
+#define RowsPerStrip 278
+#define StripByteCounts 279
+#define XResolution 282
+#define YResolution 283
+#define PlanarConfiguration 284
+#define ResolutionUnit 296
+#define ColorMap 320
+#define ReferenceBlackWhite 532
+
+// -------------
+// - TIFFWriter -
+// -------------
+
+struct TIFFLZWCTreeNode
+{
+
+ TIFFLZWCTreeNode* pBrother; // naechster Knoten, der den selben Vater hat
+ TIFFLZWCTreeNode* pFirstChild; // erster Sohn
+ USHORT nCode; // Der Code fuer den String von Pixelwerten, der sich ergibt, wenn
+ USHORT nValue; // Der Pixelwert
+};
+
+class TIFFWriter
+{
+private:
+
+ PFilterCallback mpCallback;
+ void* mpCallerData;
+ SvStream* mpOStm;
+ UINT32 mnStreamOfs;
+
+ BOOL mbStatus;
+ BitmapReadAccess* mpAcc;
+
+ UINT32 mnWidth, mnHeight, mnColors;
+ UINT32 mnCurAllPictHeight;
+ UINT32 mnSumOfAllPictHeight;
+ UINT32 mnBitsPerPixel;
+ UINT32 mnLastPercent;
+
+ UINT32 mnLatestIfdPos;
+ UINT16 mnTagCount; // number of tags already written
+ UINT32 mnCurrentTagCountPos; // offset to the position where the current
+ // tag count is to insert
+
+ UINT32 mnXResPos; // if != 0 this DWORDs stores the
+ UINT32 mnYResPos; // actual streamposition of the
+ UINT32 mnPalPos; // Tag Entry
+ UINT32 mnBitmapPos;
+ UINT32 mnStripByteCountPos;
+
+ TIFFLZWCTreeNode* pTable;
+ TIFFLZWCTreeNode* pPrefix;
+ USHORT nDataSize;
+ USHORT nClearCode;
+ USHORT nEOICode;
+ USHORT nTableSize;
+ USHORT nCodeSize;
+ ULONG nOffset;
+ ULONG dwShift;
+
+ void ImplCallback( UINT32 nPercent );
+ BOOL ImplWriteHeader( BOOL bMultiPage );
+ void ImplWritePalette();
+ BOOL ImplWriteBody();
+ void ImplWriteTag( UINT16 TagID, UINT16 DataType, UINT32 NumberOfItems, UINT32 Value);
+ void ImplWriteResolution( ULONG nStreamPos, ULONG nResolutionUnit );
+ void StartCompression();
+ void Compress( BYTE nSrc );
+ void EndCompression();
+ inline void WriteBits( USHORT nCode, USHORT nCodeLen );
+
+public:
+
+ TIFFWriter();
+ ~TIFFWriter();
+
+ BOOL WriteTIFF( const Graphic& rGraphic, SvStream& rTIFF,
+ PFilterCallback pCallback, void* pCallerdata,
+ Config* pOptionsConfig );
+};
+
+// ------------------------------------------------------------------------
+
+TIFFWriter::TIFFWriter() :
+ mnLastPercent ( 0 ),
+ mnXResPos ( 0 ),
+ mnYResPos ( 0 ),
+ mnCurAllPictHeight ( 0 ),
+ mnSumOfAllPictHeight( 0 ),
+ mnStripByteCountPos ( 0 ),
+ mnBitmapPos ( 0 ),
+ mpAcc ( NULL ),
+ mbStatus ( TRUE )
+{
+}
+
+// ------------------------------------------------------------------------
+
+TIFFWriter::~TIFFWriter()
+{
+}
+
+// ------------------------------------------------------------------------
+
+BOOL TIFFWriter::WriteTIFF( const Graphic& rGraphic, SvStream& rTIFF,
+ PFilterCallback pCallback, void* pCallerdata,
+ Config* pOptionsConfig )
+{
+ ULONG* pDummy = new ULONG; delete pDummy; // damit unter OS/2
+ // das richtige (Tools-)new
+ // verwendet wird, da es sonst
+ // in dieser DLL nur Vector-news
+ // gibt;
+
+ mpOStm = &rTIFF;
+ mpCallback = pCallback;
+ mpCallerData = pCallerdata;
+
+ const UINT16 nOldFormat = mpOStm->GetNumberFormatInt();
+ mnStreamOfs = mpOStm->Tell();
+
+ // we will use the BIG Endian Mode
+ // TIFF header
+ mpOStm->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+ *mpOStm << (UINT32)0x4d4d002a; // TIFF identifier
+ mnLatestIfdPos = mpOStm->Tell();
+ *mpOStm << (UINT32)0;
+
+ Animation aAnimation;
+ Bitmap aBmp;
+
+ if( mbStatus )
+ {
+ if ( rGraphic.IsAnimated() )
+ aAnimation = rGraphic.GetAnimation();
+ else
+ {
+ AnimationBitmap aAnimationBitmap( rGraphic.GetBitmap(), Point(), Size() );
+ aAnimation.Insert( aAnimationBitmap );
+ }
+
+ USHORT i;
+ for ( i = 0; i < aAnimation.Count(); i++ )
+ mnSumOfAllPictHeight += aAnimation.Get( i ).aBmpEx.GetSizePixel().Height();
+
+ for ( i = 0; mbStatus && ( i < aAnimation.Count() ); i++ )
+ {
+ mnPalPos = 0;
+ const AnimationBitmap& rAnimationBitmap = aAnimation.Get( i );
+ aBmp = rAnimationBitmap.aBmpEx.GetBitmap();
+ mpAcc = aBmp.AcquireReadAccess();
+ if ( mpAcc )
+ {
+ mnBitsPerPixel = aBmp.GetBitCount();
+ if ( ImplWriteHeader( ( aAnimation.Count() > 0 ) ) )
+ {
+ Size aDestMapSize( 300, 300 );
+ const MapMode aMapMode( aBmp.GetPrefMapMode() );
+ if ( aMapMode.GetMapUnit() != MAP_PIXEL )
+ {
+ const Size aPrefSize( rGraphic.GetPrefSize() );
+ aDestMapSize = OutputDevice::LogicToLogic( aPrefSize, aMapMode, MAP_INCH );
+ }
+ ImplWriteResolution( mnXResPos, aDestMapSize.Width() );
+ ImplWriteResolution( mnYResPos, aDestMapSize.Height() );
+ if ( mnPalPos )
+ ImplWritePalette();
+ ImplWriteBody();
+ }
+ UINT32 nCurPos = mpOStm->Tell();
+ mpOStm->Seek( mnCurrentTagCountPos );
+ *mpOStm << mnTagCount;
+ mpOStm->Seek( nCurPos );
+
+ aBmp.ReleaseAccess( mpAcc );
+ }
+ else
+ mbStatus = FALSE;
+ }
+ }
+ mpOStm->SetNumberFormatInt( nOldFormat );
+
+ return mbStatus;
+}
+
+// ------------------------------------------------------------------------
+
+void TIFFWriter::ImplCallback( UINT32 nPercent )
+{
+ if( nPercent >= mnLastPercent + 3 )
+ {
+ mnLastPercent = nPercent;
+
+ if( mpCallback && ( nPercent <= 100 ) && mbStatus )
+ if ( ( (*mpCallback)( mpCallerData, (UINT16) nPercent ) ) )
+ mbStatus = FALSE;
+ }
+}
+
+
+// ------------------------------------------------------------------------
+
+BOOL TIFFWriter::ImplWriteHeader( BOOL bMultiPage )
+{
+ mnTagCount = 0;
+ mnWidth = mpAcc->Width();
+ mnHeight = mpAcc->Height();
+
+ if ( mnWidth && mnHeight && mnBitsPerPixel && mbStatus )
+ {
+ UINT32 nCurrentPos = mpOStm->Tell();
+ mpOStm->Seek( mnLatestIfdPos );
+ *mpOStm << (UINT32)( nCurrentPos - mnStreamOfs ); // offset to the IFD
+ mpOStm->Seek( nCurrentPos );
+
+ // (OFS8) TIFF image file directory (IFD)
+ mnCurrentTagCountPos = mpOStm->Tell();
+ *mpOStm << (UINT16)0; // the number of tagentrys is to insert later
+
+ UINT32 nSubFileFlags = 0;
+ if ( bMultiPage )
+ nSubFileFlags |= 2;
+ ImplWriteTag( NewSubfileType, 4, 1, nSubFileFlags );
+ ImplWriteTag( ImageWidth, 4, 1, mnWidth );
+ ImplWriteTag( ImageLength, 4, 1, mnHeight);
+ ImplWriteTag( BitsPerSample, 3, 1, ( mnBitsPerPixel == 24 ) ? 8 : mnBitsPerPixel );
+ ImplWriteTag( Compression, 3, 1, 5 );
+ BYTE nTemp;
+ switch ( mnBitsPerPixel )
+ {
+ case 1 :
+ nTemp = 1;
+ break;
+ case 4 :
+ case 8 :
+ nTemp = 3;
+ break;
+ case 24:
+ nTemp = 2;
+ break;
+ }
+ ImplWriteTag( PhotometricInterpretation, 3, 1, nTemp );
+ mnBitmapPos = mpOStm->Tell();
+ ImplWriteTag( StripOffsets, 4, 1, 0 );
+ ImplWriteTag( SamplesPerPixel, 3, 1, ( mnBitsPerPixel == 24 ) ? 3 : 1 );
+ ImplWriteTag( RowsPerStrip, 4, 1, mnHeight ); //0xffffffff );
+ mnStripByteCountPos = mpOStm->Tell();
+ ImplWriteTag( StripByteCounts, 4, 1, ( ( mnWidth * mnBitsPerPixel * mnHeight ) + 7 ) >> 3 );
+ mnXResPos = mpOStm->Tell();
+ ImplWriteTag( XResolution, 5, 1, 0 );
+ mnYResPos = mpOStm->Tell();
+ ImplWriteTag( YResolution, 5, 1, 0 );
+ if ( mnBitsPerPixel != 1 )
+ ImplWriteTag( PlanarConfiguration, 3, 1, 1 ); // ( RGB ORDER )
+ ImplWriteTag( ResolutionUnit, 3, 1, 2); // Resolution Unit is Inch
+ if ( ( mnBitsPerPixel == 4 ) || ( mnBitsPerPixel == 8 ) )
+ {
+ mnColors = mpAcc->GetPaletteEntryCount();
+ mnPalPos = mpOStm->Tell();
+ ImplWriteTag( ColorMap, 3, 3 * mnColors, 0 );
+ }
+
+ // and last we write zero to close the num dir entries list
+ mnLatestIfdPos = mpOStm->Tell();
+ *mpOStm << (UINT32)0; // there are no more IFD
+ }
+ else
+ mbStatus = FALSE;
+
+ return mbStatus;
+}
+
+// ------------------------------------------------------------------------
+
+void TIFFWriter::ImplWritePalette()
+{
+ USHORT i;
+ ULONG nCurrentPos = mpOStm->Tell();
+ mpOStm->Seek( mnPalPos + 8 ); // the palette tag entry needs the offset
+ *mpOStm << nCurrentPos - mnStreamOfs; // to the palette colors
+ mpOStm->Seek( nCurrentPos );
+
+ for ( i = 0; i < mnColors; i++ )
+ {
+ const BitmapColor& rColor = mpAcc->GetPaletteColor( i );
+ *mpOStm << (UINT16)( rColor.GetRed() << 8 );
+ }
+ for ( i = 0; i < mnColors; i++ )
+ {
+ const BitmapColor& rColor = mpAcc->GetPaletteColor( i );
+ *mpOStm << (UINT16)( rColor.GetGreen() << 8 );
+ }
+ for ( i = 0; i < mnColors; i++ )
+ {
+ const BitmapColor& rColor = mpAcc->GetPaletteColor( i );
+ *mpOStm << (UINT16)( rColor.GetBlue() << 8 );
+ }
+}
+
+// ------------------------------------------------------------------------
+
+BOOL TIFFWriter::ImplWriteBody()
+{
+ BYTE nTemp, nShift;
+ ULONG j, x, y;
+
+ ULONG nGfxBegin = mpOStm->Tell();
+ mpOStm->Seek( mnBitmapPos + 8 ); // the strip offset tag entry needs the offset
+ *mpOStm << nGfxBegin - mnStreamOfs; // to the bitmap data
+ mpOStm->Seek( nGfxBegin );
+
+ StartCompression();
+
+ switch( mnBitsPerPixel )
+ {
+ case 24 :
+ {
+ for ( y = 0; y < mnHeight; y++, mnCurAllPictHeight++ )
+ {
+ ImplCallback( 100 * mnCurAllPictHeight / mnSumOfAllPictHeight );
+ for ( x = 0; x < mnWidth; x++ )
+ {
+ const BitmapColor& rColor = mpAcc->GetPixel( y, x );
+ Compress( rColor.GetRed() );
+ Compress( rColor.GetGreen() );
+ Compress( rColor.GetBlue() );
+ }
+ }
+ }
+ break;
+
+ case 8 :
+ {
+ for ( y = 0; y < mnHeight; y++, mnCurAllPictHeight++ )
+ {
+ ImplCallback( 100 * mnCurAllPictHeight / mnSumOfAllPictHeight );
+ for ( x = 0; x < mnWidth; x++ )
+ {
+ Compress( mpAcc->GetPixel( y, x ) );
+ }
+ }
+ }
+ break;
+
+ case 4 :
+ {
+ for ( nShift = 0, y = 0; y < mnHeight; y++, mnCurAllPictHeight++ )
+ {
+ ImplCallback( 100 * mnCurAllPictHeight / mnSumOfAllPictHeight );
+ for ( x = 0; x < mnWidth; x++, nShift++ )
+ {
+ if (!( nShift & 1 ))
+ nTemp = ( (BYTE)mpAcc->GetPixel( y, x ) << 4 );
+ else
+ Compress( (BYTE)( nTemp | ( mpAcc->GetPixel( y, x ) & 0xf ) ) );
+ }
+ if ( nShift & 1 )
+ Compress( nTemp );
+ }
+ }
+ break;
+
+ case 1 :
+ {
+ j = 1;
+ for ( y = 0; y < mnHeight; y++, mnCurAllPictHeight++ )
+ {
+ ImplCallback( 100 * mnCurAllPictHeight / mnSumOfAllPictHeight );
+ for ( x = 0; x < mnWidth; x++)
+ {
+ j <<= 1;
+ j |= ( ( ~mpAcc->GetPixel( y, x ) ) & 1 );
+ if ( j & 0x100 )
+ {
+ Compress( (BYTE)j );
+ j = 1;
+ }
+ }
+ if ( j != 1 )
+ {
+ Compress( (BYTE)(j << ( ( ( x & 7) ^ 7 ) + 1 ) ) );
+ j = 1;
+ }
+ }
+ }
+ break;
+
+ default:
+ {
+ mbStatus = FALSE;
+ }
+ break;
+ }
+
+ EndCompression();
+
+ if ( mnStripByteCountPos && mbStatus )
+ {
+ ULONG nGfxEnd = mpOStm->Tell();
+ mpOStm->Seek( mnStripByteCountPos + 8 );
+ *mpOStm << ( nGfxEnd - nGfxBegin ); // mnStripByteCountPos needs the size of the compression data
+ mpOStm->Seek( nGfxEnd );
+ }
+ return mbStatus;
+}
+
+// ------------------------------------------------------------------------
+
+void TIFFWriter::ImplWriteResolution( ULONG nStreamPos, ULONG nResolutionUnit )
+{
+ ULONG nCurrentPos = mpOStm->Tell();
+ mpOStm->Seek( nStreamPos + 8 );
+ *mpOStm << (UINT32)nCurrentPos - mnStreamOfs;
+ mpOStm->Seek( nCurrentPos );
+ *mpOStm << (ULONG)1;
+ *mpOStm << nResolutionUnit;
+}
+
+// ------------------------------------------------------------------------
+
+void TIFFWriter::ImplWriteTag( UINT16 nTagID, UINT16 nDataType, UINT32 nNumberOfItems, UINT32 nValue)
+{
+ mnTagCount++;
+
+ *mpOStm << nTagID;
+ *mpOStm << nDataType;
+ *mpOStm << nNumberOfItems;
+ if ( nDataType == 3 )
+ nValue <<=16; // in Big Endian Mode WORDS needed to be shifted to a DWORD
+ *mpOStm << nValue;
+}
+
+// ------------------------------------------------------------------------
+
+inline void TIFFWriter::WriteBits( USHORT nCode, USHORT nCodeLen )
+{
+ dwShift |= ( nCode << ( nOffset - nCodeLen ) );
+ nOffset -= nCodeLen;
+ while ( nOffset < 24 )
+ {
+ *mpOStm << (BYTE)( dwShift >> 24 );
+ dwShift <<= 8;
+ nOffset += 8;
+ }
+ if ( nCode == 257 && nOffset != 32 )
+ {
+ *mpOStm << (BYTE)( dwShift >> 24 );
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void TIFFWriter::StartCompression()
+{
+ USHORT i;
+ nDataSize = 8;
+
+ nClearCode = 1 << nDataSize;
+ nEOICode = nClearCode + 1;
+ nTableSize = nEOICode + 1;
+ nCodeSize = nDataSize + 1;
+
+ nOffset = 32; // anzahl freier bits in dwShift
+ dwShift = 0;
+
+ pTable = new TIFFLZWCTreeNode[ 4096 ];
+
+ for ( i = 0; i < 4096; i++)
+ {
+ pTable[ i ].pBrother = pTable[ i ].pFirstChild = NULL;
+ pTable[ i ].nValue = (BYTE)( pTable[ i ].nCode = i );
+ }
+
+ pPrefix = NULL;
+ WriteBits( nClearCode, nCodeSize );
+}
+
+// ------------------------------------------------------------------------
+
+void TIFFWriter::Compress( BYTE nCompThis )
+{
+ TIFFLZWCTreeNode* p;
+ USHORT i;
+ BYTE nV;
+
+ if( !pPrefix )
+ {
+ pPrefix = pTable + nCompThis;
+ }
+ else
+ {
+ nV = nCompThis;
+ for( p = pPrefix->pFirstChild; p != NULL; p = p->pBrother )
+ {
+ if ( p->nValue == nV )
+ break;
+ }
+
+ if( p )
+ pPrefix = p;
+ else
+ {
+ WriteBits( pPrefix->nCode, nCodeSize );
+
+ if ( nTableSize == 409 )
+ {
+ WriteBits( nClearCode, nCodeSize );
+
+ for ( i = 0; i < nClearCode; i++ )
+ pTable[ i ].pFirstChild = NULL;
+
+ nCodeSize = nDataSize + 1;
+ nTableSize = nEOICode + 1;
+ }
+ else
+ {
+ if( nTableSize == (USHORT)( ( 1 << nCodeSize ) - 1 ) )
+ nCodeSize++;
+
+ p = pTable + ( nTableSize++ );
+ p->pBrother = pPrefix->pFirstChild;
+ pPrefix->pFirstChild = p;
+ p->nValue = nV;
+ p->pFirstChild = NULL;
+ }
+
+ pPrefix = pTable + nV;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void TIFFWriter::EndCompression()
+{
+ if( pPrefix )
+ WriteBits( pPrefix->nCode, nCodeSize );
+
+ WriteBits( nEOICode, nCodeSize );
+ delete[] pTable;
+}
+
+// ------------------------------------------------------------------------
+
+// ---------------------
+// - exported function -
+// ---------------------
+
+extern "C" BOOL __LOADONCALLAPI GraphicExport( SvStream& rStream, Graphic& rGraphic,
+ PFilterCallback pCallback, void* pCallerData,
+ Config* pOptionsConfig, BOOL )
+{
+ return TIFFWriter().WriteTIFF( rGraphic, rStream, pCallback, pCallerData, pOptionsConfig );
+}
+
+
+#pragma hdrstop
+
+// ---------------
+// - Win16 trash -
+// ---------------
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0;
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+ if ( nHeap )
+ UnlockData( 0 );
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
+
diff --git a/goodies/source/filter.vcl/etiff/makefile.mk b/goodies/source/filter.vcl/etiff/makefile.mk
new file mode 100644
index 000000000000..2ecca7af87bc
--- /dev/null
+++ b/goodies/source/filter.vcl/etiff/makefile.mk
@@ -0,0 +1,169 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=etiff
+DEPTARGET=vetiff
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SLOFILES = $(SLO)$/etiff.obj
+
+# ==========================================================================
+
+SHL1TARGET= eti$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= etiff
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(CPPULIB)
+SHL1DEPN= $(LB)$/etiff.lib
+SHL1LIBS= $(SLB)$/etiff.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/etiff.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicExport >>$@
+.ELSE
+ @echo _GraphicExport >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET) >>$@
+ @echo GraphicExport_ >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicExport >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/expm/expm.cxx b/goodies/source/filter.vcl/expm/expm.cxx
new file mode 100644
index 000000000000..a989f5d1d0d5
--- /dev/null
+++ b/goodies/source/filter.vcl/expm/expm.cxx
@@ -0,0 +1,331 @@
+/*************************************************************************
+ *
+ * $RCSfile: expm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <vcl/graph.hxx>
+#include <vcl/bmpacc.hxx>
+#include <svtools/fltcall.hxx>
+
+//============================ XPMWriter ==================================
+
+class XPMWriter {
+
+private:
+
+ PFilterCallback mpCallback;
+ void * mpCallerData;
+
+ SvStream* mpOStm; // Die auszugebende XPM-Datei
+ USHORT mpOStmOldModus;
+
+ BOOL mbStatus;
+ BOOL mbTrans;
+ BitmapReadAccess* mpAcc;
+ ULONG mnWidth, mnHeight; // Bildausmass in Pixeln
+ USHORT mnColors;
+
+ BOOL ImplCallback( USHORT nPercent );
+ BOOL ImplWriteHeader();
+ void ImplWritePalette();
+ void ImplWriteColor( USHORT );
+ void ImplWriteBody();
+ void ImplWriteNumber( sal_Int32 );
+ void ImplWritePixel( ULONG );
+
+public:
+ XPMWriter();
+ ~XPMWriter();
+
+ BOOL WriteXPM( const Graphic& rGraphic, SvStream& rXPM,
+ PFilterCallback pCallback, void* pCallerdata,
+ Config* pOptionsConfig );
+};
+
+//=================== Methoden von XPMWriter ==============================
+
+XPMWriter::XPMWriter() :
+ mpAcc ( NULL ),
+ mbStatus ( TRUE ),
+ mbTrans ( FALSE )
+{
+}
+
+// ------------------------------------------------------------------------
+
+XPMWriter::~XPMWriter()
+{
+}
+
+// ------------------------------------------------------------------------
+
+BOOL XPMWriter::ImplCallback( USHORT nPercent )
+{
+ if ( mpCallback != NULL )
+ {
+ if ( ( (*mpCallback)( mpCallerData, nPercent ) ) == TRUE )
+ {
+ mpOStm->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL XPMWriter::WriteXPM( const Graphic& rGraphic, SvStream& rXPM,
+ PFilterCallback pCallback, void* pCallerdata,
+ Config* pOptionsConfig )
+{
+ Bitmap aBmp;
+
+ mpOStm = &rXPM;
+ mpCallback = pCallback;
+ mpCallerData = pCallerdata;
+
+ BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+ aBmp = aBmpEx.GetBitmap();
+
+ if ( rGraphic.IsTransparent() ) // event. transparente Farbe erzeugen
+ {
+ mbTrans = TRUE;
+ if ( aBmp.GetBitCount() >= 8 ) // wenn noetig Bild auf 8 bit konvertieren
+ aBmp.Convert( BMP_CONVERSION_8BIT_TRANS );
+ else
+ aBmp.Convert( BMP_CONVERSION_4BIT_TRANS );
+ aBmp.Replace( aBmpEx.GetMask(), BMP_COL_TRANS );
+ }
+ else
+ {
+ if ( aBmp.GetBitCount() > 8 ) // wenn noetig Bild auf 8 bit konvertieren
+ aBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
+ }
+ if ( ( mpAcc = aBmp.AcquireReadAccess() ) )
+ {
+ mnColors = mpAcc->GetPaletteEntryCount();
+ mpOStmOldModus = mpOStm->GetNumberFormatInt();
+ mpOStm->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+
+ if ( ImplWriteHeader() )
+ {
+ ImplWritePalette();
+ ImplWriteBody();
+ *mpOStm << "\x22XPMENDEXT\x22\x0a};";
+ }
+ aBmp.ReleaseAccess( mpAcc );
+ }
+ else
+ mbStatus = FALSE;
+
+ mpOStm->SetNumberFormatInt( mpOStmOldModus );
+
+ return mbStatus;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL XPMWriter::ImplWriteHeader()
+{
+ mnWidth = mpAcc->Width();
+ mnHeight = mpAcc->Height();
+ if ( mnWidth && mnHeight && mnColors )
+ {
+ *mpOStm << "/* XPM */\x0astatic char * image[] = \x0a{\x0a\x22";
+ ImplWriteNumber( mnWidth );
+ *mpOStm << (BYTE)32;
+ ImplWriteNumber( mnHeight );
+ *mpOStm << (BYTE)32;
+ ImplWriteNumber( mnColors );
+ *mpOStm << (BYTE)32;
+ ImplWriteNumber( ( mnColors > 26 ) ? 2 : 1 );
+ *mpOStm << "\x22,\x0a";
+ }
+ else mbStatus = FALSE;
+ return mbStatus;
+}
+
+// ------------------------------------------------------------------------
+
+void XPMWriter::ImplWritePalette()
+{
+ USHORT nTransIndex = 0xffff;
+
+ if ( mbTrans )
+ nTransIndex = mpAcc->GetBestMatchingColor( BMP_COL_TRANS );
+ for ( USHORT i = 0; i < mnColors; i++ )
+ {
+ *mpOStm << "\x22";
+ ImplWritePixel( i );
+ *mpOStm << (BYTE)32;
+ if ( nTransIndex != i )
+ {
+ ImplWriteColor( i );
+ *mpOStm << "\x22,\x0a";
+ }
+ else
+ *mpOStm << "c none\x22,\x0a";
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void XPMWriter::ImplWriteBody()
+{
+ for ( ULONG y = 0; y < mnHeight; y++ )
+ {
+ ImplCallback( (USHORT)( ( 100 * y ) / mnHeight ) ); // processing output in percent
+ *mpOStm << (BYTE)0x22;
+ for ( ULONG x = 0; x < mnWidth; x++ )
+ {
+ ImplWritePixel( (BYTE)(mpAcc->GetPixel( y, x ) ) );
+ }
+ *mpOStm << "\x22,\x0a";
+ }
+}
+
+// ------------------------------------------------------------------------
+// eine Dezimalzahl im ASCII format wird in den Stream geschrieben
+
+void XPMWriter::ImplWriteNumber( sal_Int32 nNumber )
+{
+ const ByteString aNum( ByteString::CreateFromInt32( nNumber ) );
+
+ for( sal_Int32 n = 0UL, nLen = aNum.Len(); n < nLen; n++ )
+ *mpOStm << aNum.GetChar( n );
+
+}
+
+// ------------------------------------------------------------------------
+
+void XPMWriter::ImplWritePixel( ULONG nCol )
+{
+ if ( mnColors > 26 )
+ {
+ BYTE nDiff = (BYTE) ( nCol / 26 );
+ *mpOStm << (BYTE)( nDiff + 'A' );
+ *mpOStm << (BYTE)( nCol - ( nDiff*26 ) + 'A' );
+ }
+ else
+ *mpOStm << (BYTE)( nCol + 'A' );
+}
+
+// ------------------------------------------------------------------------
+// ein Farbwert wird im Hexadezimalzahlformat in den Stream geschrieben
+void XPMWriter::ImplWriteColor( USHORT nNumber )
+{
+ ULONG nTmp;
+ BYTE j;
+
+ *mpOStm << "c #"; // # zeigt einen folgenden Hexwert an
+ const BitmapColor& rColor = mpAcc->GetPaletteColor( nNumber );
+ nTmp = ( rColor.GetRed() << 16 ) | ( rColor.GetGreen() << 8 ) | rColor.GetBlue();
+ for ( char i = 20; i >= 0 ; i-=4 )
+ {
+ if ( ( j = (BYTE)( nTmp >> i ) & 0xf ) > 9 )
+ j += 'A' - 10;
+ else
+ j += '0';
+ *mpOStm << j;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+// ---------------------
+// - exported function -
+// ---------------------
+
+extern "C" BOOL __LOADONCALLAPI GraphicExport( SvStream& rStream, Graphic& rGraphic,
+ PFilterCallback pCallback, void* pCallerData,
+ Config* pOptionsConfig, BOOL )
+{
+ XPMWriter aXPMWriter;
+
+ return aXPMWriter.WriteXPM( rGraphic, rStream, pCallback, pCallerData, pOptionsConfig );
+}
+
+#pragma hdrstop
+
+// ---------------
+// - Win16 trash -
+// ---------------
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0;
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+ if ( nHeap )
+ UnlockData( 0 );
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
diff --git a/goodies/source/filter.vcl/expm/makefile.mk b/goodies/source/filter.vcl/expm/makefile.mk
new file mode 100644
index 000000000000..6f25cd3299ca
--- /dev/null
+++ b/goodies/source/filter.vcl/expm/makefile.mk
@@ -0,0 +1,169 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=expm
+DEPTARGET=vexpm
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SLOFILES = $(SLO)$/expm.obj
+
+# ==========================================================================
+
+SHL1TARGET= exp$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= expm
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(CPPULIB)
+SHL1DEPN= $(LB)$/expm.lib
+SHL1LIBS= $(SLB)$/expm.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/expm.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicExport >>$@
+.ELSE
+ @echo _GraphicExport >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET).DLL >>$@
+ @ldump -E1 -A $(SLB)$/expm.lib >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicExport >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/icgm/actimpr.cxx b/goodies/source/filter.vcl/icgm/actimpr.cxx
new file mode 100644
index 000000000000..d861b52114c9
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/actimpr.cxx
@@ -0,0 +1,1324 @@
+/*************************************************************************
+ *
+ * $RCSfile: actimpr.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _SV_BITMAPEX_HXX
+#include <vcl/bitmapex.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESSUPPLIER_HPP_
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_LINESTYLE_HPP_
+#include <com/sun/star/drawing/LineStyle.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_LINEDASH_HPP_
+#include <com/sun/star/drawing/LineDash.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_FILLSTYLE_HPP_
+#include <com/sun/star/drawing/FillStyle.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_HATCH_HPP_
+#include <com/sun/star/drawing/Hatch.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTWEIGHT_HPP_
+#include <com/sun/star/awt/FontWeight.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTUNDERLINE_HPP_
+#include <com/sun/star/awt/FontUnderline.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPEGROUPER_HPP_
+#include <com/sun/star/drawing/XShapeGrouper.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_CIRCLEKIND_HPP_
+#include <com/sun/star/drawing/CircleKind.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_XBITMAP_HPP_
+#include <com/sun/star/awt/XBitmap.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_POINTSEQUENCESEQUENCE_HPP_
+#include <com/sun/star/drawing/PointSequenceSequence.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_POINTSEQUENCE_HPP_
+#include <com/sun/star/drawing/PointSequence.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_POLYPOLYGONBEZIERCOORDS_HPP_
+#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_FLAGSEQUENCE_HPP_
+#include <com/sun/star/drawing/FlagSequence.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_TEXTADJUST_HPP_
+#include <com/sun/star/drawing/TextAdjust.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_
+#include <com/sun/star/text/XText.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TEXT_XTEXTRANGE_HPP_
+#include <com/sun/star/text/XTextRange.hpp>
+#endif
+#ifndef _COM_SUN_STAR_STYLE_HORIZONTALALIGNMENT_HPP_
+#include <com/sun/star/style/HorizontalAlignment.hpp>
+#endif
+
+#include <unotools/processfactory.hxx>
+
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+
+//#include <toolkit/unohlp.hxx>
+
+#include <main.hxx>
+#include <outact.hxx>
+
+using namespace ::com::sun::star;
+
+// ---------------------------------------------------------------
+// ---------------------------------------------------------------
+// ---------------------------------------------------------------
+// ---------------------------------------------------------------
+
+CGMImpressOutAct::CGMImpressOutAct( CGM& rCGM, const uno::Reference< frame::XModel > & rModel ) :
+ CGMOutAct ( rCGM ),
+ nFinalTextCount ( 0 )
+{
+ sal_Bool bStatRet = sal_False;
+
+ if ( mpCGM->mbStatus )
+ {
+ uno::Reference< drawing::XDrawPagesSupplier > aDrawPageSup( rModel, uno::UNO_QUERY );
+ if( aDrawPageSup.is() )
+ {
+ maXDrawPages = aDrawPageSup->getDrawPages();
+ if ( maXDrawPages.is() )
+ {
+ maXServiceManagerSC = utl::getProcessServiceFactory();
+ if ( maXServiceManagerSC.is() )
+ {
+
+ maXMultiServiceFactory = ::com::sun::star::uno::Reference< lang::XMultiServiceFactory >
+ ( maXServiceManagerSC, ::com::sun::star::uno::UNO_QUERY );
+ if ( maXMultiServiceFactory.is() )
+ {
+ maXDrawPage = *(uno::Reference< drawing::XDrawPage > *)maXDrawPages->getByIndex( 0 ).getValue();
+ if ( ImplInitPage() )
+ bStatRet = sal_True;
+ }
+/*
+ uno::Any aAny( rModel->queryInterface( ::getCppuType((const uno::Reference< lang::XMultiServiceFactory >*)0) ));
+ if( aAny >>= maXMultiServiceFactory )
+ {
+ maXDrawPage = *(uno::Reference< drawing::XDrawPage > *)maXDrawPages->getByIndex( 0 ).getValue();
+ if ( ImplInitPage() )
+ bStatRet = sal_True;
+ }
+*/
+ }
+ }
+ }
+ mpCGM->mbStatus = bStatRet;
+ }
+};
+
+// ---------------------------------------------------------------
+
+sal_Bool CGMImpressOutAct::ImplInitPage()
+{
+ sal_Bool bStatRet = sal_False;
+ if( maXDrawPage.is() )
+ {
+ maXShapes = uno::Reference< drawing::XShapes >( maXDrawPage, uno::UNO_QUERY );
+ if ( maXShapes.is() )
+ {
+ bStatRet = sal_True;
+ }
+ }
+ return bStatRet;
+}
+
+// ---------------------------------------------------------------
+
+sal_Bool CGMImpressOutAct::ImplCreateShape( const ::rtl::OUString& rType )
+{
+ uno::Reference< uno::XInterface > xNewShape( maXMultiServiceFactory->createInstance( rType ) );
+ maXShape = uno::Reference< drawing::XShape >( xNewShape, uno::UNO_QUERY );
+ maXPropSet = uno::Reference< beans::XPropertySet >( xNewShape, uno::UNO_QUERY );
+ if ( maXShape.is() && maXPropSet.is() )
+ {
+ maXShapes->add( maXShape );
+ return sal_True;
+ }
+ return sal_False;
+}
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::ImplSetOrientation( FloatPoint& rRefPoint, double& rOrientation )
+{
+ uno::Any aAny;
+ aAny <<= (sal_Int32)rRefPoint.X;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("RotationPointX"), aAny );
+ aAny <<= (sal_Int32)rRefPoint.Y;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("RotationPointY"), aAny );
+ aAny <<= (sal_Int32)( rOrientation * 100.0 );
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("RotateAngle"), aAny );
+}
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::ImplSetLineBundle()
+{
+ uno::Any aAny;
+ drawing::LineStyle eLS;
+
+ sal_uInt32 nLineColor;
+ LineType eLineType;
+ double fLineWidth;
+
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_LINECOLOR )
+ nLineColor = mpCGM->pElement->pLineBundle->GetColor();
+ else
+ nLineColor = mpCGM->pElement->aLineBundle.GetColor();
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_LINETYPE )
+ eLineType = mpCGM->pElement->pLineBundle->eLineType;
+ else
+ eLineType = mpCGM->pElement->aLineBundle.eLineType;
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_LINEWIDTH )
+ fLineWidth = mpCGM->pElement->pLineBundle->nLineWidth;
+ else
+ fLineWidth = mpCGM->pElement->aLineBundle.nLineWidth;
+
+ aAny <<= (sal_Int32)nLineColor;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("LineColor"), aAny );
+
+ aAny <<= (sal_Int32)fLineWidth;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("LineWidth"), aAny );
+
+ switch( eLineType )
+ {
+ case LT_NONE :
+ eLS = drawing::LineStyle_NONE;
+ break;
+ case LT_DASH :
+ case LT_DOT :
+ case LT_DASHDOT :
+ case LT_DOTDOTSPACE :
+ case LT_LONGDASH :
+ case LT_DASHDASHDOT :
+ eLS = drawing::LineStyle_DASH;
+ break;
+ case LT_SOLID :
+ default:
+ eLS = drawing::LineStyle_SOLID;
+ break;
+ }
+ aAny <<= eLS;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("LineStyle"), aAny );
+ if ( eLS == drawing::LineStyle_DASH )
+ {
+ drawing::LineDash aLineDash( drawing::DashStyle_RECTRELATIVE, 1, 50, 3, 33, 100 );
+ aAny <<= aLineDash;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("LineDash"), aAny );
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::ImplSetFillBundle()
+{
+
+ uno::Any aAny;
+ drawing::LineStyle eLS;
+ drawing::FillStyle eFS;
+
+ sal_uInt32 nEdgeColor;
+ EdgeType eEdgeType;
+ double fEdgeWidth;
+
+ sal_uInt32 nFillColor;
+ FillInteriorStyle eFillStyle;
+ long nPatternIndex;
+ sal_uInt32 nHatchIndex;
+
+ if ( mpCGM->pElement->eEdgeVisibility == EV_ON )
+ {
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_EDGETYPE )
+ eEdgeType = mpCGM->pElement->pEdgeBundle->eEdgeType;
+ else
+ eEdgeType = mpCGM->pElement->aEdgeBundle.eEdgeType;
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_EDGEWIDTH )
+ fEdgeWidth = mpCGM->pElement->pEdgeBundle->nEdgeWidth;
+ else
+ fEdgeWidth = mpCGM->pElement->aEdgeBundle.nEdgeWidth;
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_EDGECOLOR )
+ nEdgeColor = mpCGM->pElement->pEdgeBundle->GetColor();
+ else
+ nEdgeColor = mpCGM->pElement->aEdgeBundle.GetColor();
+ }
+ else
+ eEdgeType = ET_NONE;
+
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_FILLINTERIORSTYLE )
+ eFillStyle = mpCGM->pElement->pFillBundle->eFillInteriorStyle;
+ else
+ eFillStyle = mpCGM->pElement->aFillBundle.eFillInteriorStyle;
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_FILLCOLOR )
+ nFillColor = mpCGM->pElement->pFillBundle->GetColor();
+ else
+ nFillColor = mpCGM->pElement->aFillBundle.GetColor();
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_HATCHINDEX )
+ nHatchIndex = (sal_uInt32)mpCGM->pElement->pFillBundle->nFillHatchIndex;
+ else
+ nHatchIndex = (sal_uInt32)mpCGM->pElement->aFillBundle.nFillHatchIndex;
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_PATTERNINDEX )
+ nPatternIndex = mpCGM->pElement->pFillBundle->nFillPatternIndex;
+ else
+ nPatternIndex = mpCGM->pElement->aFillBundle.nFillPatternIndex;
+
+ aAny <<= (sal_Int32)nFillColor;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("FillColor"), aAny );
+
+ switch ( eFillStyle )
+ {
+ case FIS_HATCH :
+ {
+ if ( nHatchIndex == 0 )
+ eFS = drawing::FillStyle_NONE;
+ else
+ eFS = drawing::FillStyle_HATCH;
+ }
+ break;
+ case FIS_PATTERN :
+ case FIS_SOLID :
+ {
+ eFS = drawing::FillStyle_SOLID;
+ }
+ break;
+
+ case FIS_GEOPATTERN :
+ {
+ if ( mpCGM->pElement->eTransparency = T_ON )
+ nFillColor = mpCGM->pElement->nAuxiliaryColor;
+ eFS = drawing::FillStyle_NONE;
+ }
+ break;
+
+ case FIS_INTERPOLATED :
+ case FIS_GRADIENT :
+ {
+ eFS = drawing::FillStyle_GRADIENT;
+ }
+ break;
+
+ case FIS_HOLLOW :
+ case FIS_EMPTY :
+ default:
+ {
+ eFS = drawing::FillStyle_NONE;
+ }
+ }
+
+ if ( mpCGM->mnAct4PostReset & ACT4_GRADIENT_ACTION )
+ eFS = drawing::FillStyle_GRADIENT;
+
+ if ( eFS == drawing::FillStyle_GRADIENT )
+ {
+ aAny <<= *mpGradient;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("FillGradient"), aAny );
+ }
+ aAny <<= eFS;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("FillStyle"), aAny );
+
+ eLS = drawing::LineStyle_NONE;
+ if ( eFillStyle == FIS_HOLLOW )
+ {
+ eLS = drawing::LineStyle_SOLID;
+ aAny <<= (sal_Int32)nFillColor;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("LineColor"), aAny );
+ aAny <<= (sal_Int32)0;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("LineWidth"), aAny );
+ }
+ else if ( eEdgeType != ET_NONE )
+ {
+ aAny <<= (sal_Int32)nEdgeColor;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("LineColor"), aAny );
+
+ aAny <<= (sal_Int32)fEdgeWidth;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("LineWidth"), aAny );
+
+ switch( eEdgeType )
+ {
+ case ET_DASH :
+ case ET_DOT :
+ case ET_DASHDOT :
+ case ET_DASHDOTDOT :
+ case ET_DOTDOTSPACE :
+ case ET_LONGDASH :
+ case ET_DASHDASHDOT :
+// {
+// eLS = LineStyle_DASH;
+// aAny.setValue( &eLS, ::getCppuType((const drawing::LineStyle*)0) );
+// maXPropSet->setPropertyValue( L"LineStyle", aAny );
+// drawing::LineDash aLineDash( DashStyle_RECTRELATIVE, 1, 160, 1, 160, 190 );
+// aAny.setValue( &aLineDash, ::getCppuType((const drawing::LineDash*)0) );
+// maXPropSet->setPropertyValue( L"DashStyle", aAny );
+// }
+// break;
+ default: // case ET_SOLID :
+ {
+ eLS = drawing::LineStyle_SOLID;
+ }
+ break;
+ }
+ }
+
+ aAny <<= eLS;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("LineStyle"), aAny );
+
+ if ( eFS == drawing::FillStyle_HATCH )
+ {
+ drawing::Hatch aHatch;
+
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_LINECOLOR )
+ aHatch.Color = nFillColor;
+ else
+ aHatch.Color = nFillColor;
+ HatchEntry* pHatchEntry = (HatchEntry*)mpCGM->pElement->aHatchTable.Get( nHatchIndex );
+ if ( pHatchEntry )
+ {
+ switch ( pHatchEntry->HatchStyle )
+ {
+ case 0 : aHatch.Style = drawing::HatchStyle_SINGLE; break;
+ case 1 : aHatch.Style = drawing::HatchStyle_DOUBLE; break;
+ case 2 : aHatch.Style = drawing::HatchStyle_TRIPLE; break;
+ }
+ aHatch.Distance = pHatchEntry->HatchDistance;
+ aHatch.Angle = pHatchEntry->HatchAngle;
+ }
+ else
+ {
+ aHatch.Style = drawing::HatchStyle_TRIPLE;
+ aHatch.Distance = 10 * ( nHatchIndex & 0x1f ) | 100;
+ aHatch.Angle = 15 * ( ( nHatchIndex & 0x1f ) - 5 );
+ }
+ aAny <<= aHatch;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("FillHatch"), aAny );
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::ImplSetTextBundle( const uno::Reference< beans::XPropertySet > & rProperty )
+{
+ uno::Any aAny;
+ TextPrecision eTextPrecision;
+ sal_uInt32 nTextFontIndex;
+ sal_uInt32 nTextColor;
+ double fCharacterExpansion;
+ double fCharacterSpacing;
+
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_TEXTFONTINDEX )
+ nTextFontIndex = mpCGM->pElement->pTextBundle->nTextFontIndex;
+ else
+ nTextFontIndex = mpCGM->pElement->aTextBundle.nTextFontIndex;
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_TEXTPRECISION )
+ eTextPrecision = mpCGM->pElement->pTextBundle->eTextPrecision;
+ else
+ eTextPrecision = mpCGM->pElement->aTextBundle.eTextPrecision;
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_CHARACTEREXPANSION )
+ fCharacterExpansion = mpCGM->pElement->pTextBundle->nCharacterExpansion;
+ else
+ fCharacterExpansion = mpCGM->pElement->aTextBundle.nCharacterExpansion;
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_CHARACTERSPACING )
+ fCharacterSpacing = mpCGM->pElement->pTextBundle->nCharacterSpacing;
+ else
+ fCharacterSpacing = mpCGM->pElement->aTextBundle.nCharacterSpacing;
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_TEXTCOLOR )
+ nTextColor = mpCGM->pElement->pTextBundle->GetColor();
+ else
+ nTextColor = mpCGM->pElement->aTextBundle.GetColor();
+
+ aAny <<= (sal_Int32)nTextColor;
+ rProperty->setPropertyValue( rtl::OUString::createFromAscii("CharColor"), aAny );
+
+ sal_uInt32 nFontType = 0;
+ awt::FontDescriptor aFontDescriptor;
+ FontEntry* pFontEntry = mpCGM->pElement->aFontList.GetFontEntry( nTextFontIndex );
+ if ( pFontEntry )
+ {
+ nFontType = pFontEntry->nFontType;
+ aFontDescriptor.Name = String::CreateFromAscii( (char*)pFontEntry->pFontName );
+ }
+ aFontDescriptor.Height = ( sal_Int16 )( ( mpCGM->pElement->nCharacterHeight * (double)1.50 ) );
+ if ( nFontType & 1 )
+ aFontDescriptor.Slant = awt::FontSlant_ITALIC;
+ if ( nFontType & 2 )
+ aFontDescriptor.Weight = awt::FontWeight::BOLD;
+ else
+ aFontDescriptor.Weight = awt::FontWeight::NORMAL;
+
+ if ( mpCGM->pElement->eUnderlineMode != UM_OFF )
+ {
+ aFontDescriptor.Underline = awt::FontUnderline::SINGLE;
+ }
+ aAny <<= aFontDescriptor;
+ rProperty->setPropertyValue( rtl::OUString::createFromAscii("FontDescriptor"), aAny );
+};
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::InsertPage()
+{
+ if ( mnCurrentPage ) // eine seite ist immer vorhanden, deshalb wird die erste Seite ausgelassen
+ {
+ uno::Reference< drawing::XDrawPage > xPage( maXDrawPages->insertNewByIndex( 0xffff ), uno::UNO_QUERY );
+ maXDrawPage = xPage;
+ if ( ImplInitPage() == sal_False )
+ mpCGM->mbStatus = sal_False;
+ }
+ mnCurrentPage++;
+};
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::BeginGroup()
+{
+ if ( mnGroupLevel < CGM_OUTACT_MAX_GROUP_LEVEL )
+ {
+ mpGroupLevel[ mnGroupLevel ] = maXShapes->getCount();
+ }
+ mnGroupLevel++;
+ mnGroupActCount = mpCGM->mnActCount;
+};
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::EndGroup()
+{
+ if ( mnGroupLevel ) // preserve overflow
+ mnGroupLevel--;
+ if ( mnGroupLevel < CGM_OUTACT_MAX_GROUP_LEVEL )
+ {
+ sal_uInt32 mnFirstIndex = mpGroupLevel[ mnGroupLevel ];
+ if ( mnFirstIndex == 0xffffffff )
+ mnFirstIndex = 0;
+ sal_uInt32 mnCurrentCount = maXShapes->getCount();
+ if ( ( mnCurrentCount - mnFirstIndex ) > 1 )
+ {
+ uno::Reference< drawing::XShapeGrouper > aXShapeGrouper;
+ uno::Any aAny( maXDrawPage->queryInterface( ::getCppuType(((const uno::Reference< drawing::XShapeGrouper >*)0) )));
+ if( aAny >>= aXShapeGrouper )
+ {
+ uno::Reference< drawing::XShapes > aXShapes;
+// if ( maXServiceManagerSC->createInstance( L"stardiv.one.drawing.ShapeCollection" )->queryInterface( ::getCppuType((const Reference< drawing::XShapes >*)0), aXShapes ) )
+
+ uno::Reference< drawing::XShape > aXShapeCollection( maXServiceManagerSC->createInstance( rtl::OUString::createFromAscii("com.sun.star.drawing.ShapeCollection") ), uno::UNO_QUERY );
+ if ( aXShapeCollection.is() )
+ {
+ aXShapes = uno::Reference< drawing::XShapes >( aXShapeCollection, uno::UNO_QUERY );
+ if( aXShapes.is() )
+ {
+ for ( sal_uInt32 i = mnFirstIndex; i < mnCurrentCount; i++ )
+ {
+ uno::Reference< drawing::XShape > aXShape = *(uno::Reference< drawing::XShape > *)maXShapes->getByIndex( i ).getValue();
+ if (aXShape.is() )
+ {
+ aXShapes->add( aXShape );
+ }
+ }
+ }
+ }
+ uno::Reference< drawing::XShapeGroup > aXShapeGroup = aXShapeGrouper->group( aXShapes );
+ }
+ }
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::EndGrouping()
+{
+ while ( mnGroupLevel )
+ {
+ EndGroup();
+ }
+}
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::DrawRectangle( FloatRect& rFloatRect )
+{
+ if ( mnGroupActCount != ( mpCGM->mnActCount - 1 ) ) // POWERPOINT HACK !!!
+ {
+ if ( ImplCreateShape( rtl::OUString::createFromAscii("com.sun.star.drawing.RectangleShape") ) )
+ {
+ awt::Size aSize( (long)(rFloatRect.Right - rFloatRect.Left ), (long)(rFloatRect.Bottom-rFloatRect.Top ) );
+ maXShape->setSize( aSize );
+ maXShape->setPosition( awt::Point( (long)rFloatRect.Left, (long)rFloatRect.Top ) );
+ ImplSetFillBundle();
+ }
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::DrawEllipse( FloatPoint& rCenter, FloatPoint& rSize, double& rOrientation )
+{
+ if ( ImplCreateShape( rtl::OUString::createFromAscii("com.sun.star.drawing.EllipseShape") ) )
+ {
+ drawing::CircleKind eCircleKind = drawing::CircleKind_FULL;
+ uno::Any aAny( &eCircleKind, ::getCppuType((const drawing::CircleKind*)0) );
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("CircleKind"), aAny );
+
+ long nXSize = (long)( rSize.X * 2.0 ); // Merkwuerdigkes Verhalten bei einer awt::Size von 0
+ long nYSize = (long)( rSize.Y * 2.0 );
+ if ( nXSize < 1 )
+ nXSize = 1;
+ if ( nYSize < 1 )
+ nYSize = 1;
+ maXShape->setSize( awt::Size( nXSize, nYSize ) );
+ maXShape->setPosition( awt::Point( (long)( rCenter.X - rSize.X ), (long)( rCenter.Y - rSize.Y ) ) );
+
+ if ( rOrientation != 0 )
+ {
+ ImplSetOrientation( rCenter, rOrientation );
+ }
+ ImplSetFillBundle();
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::DrawEllipticalArc( FloatPoint& rCenter, FloatPoint& rSize, double& rOrientation,
+ sal_uInt32 nType, double& fStartAngle, double& fEndAngle )
+{
+ if ( ImplCreateShape( rtl::OUString::createFromAscii("com.sun.star.drawing.EllipseShape") ) )
+ {
+ uno::Any aAny;
+ drawing::CircleKind eCircleKind;
+
+
+ long nXSize = (long)( rSize.X * 2.0 ); // Merkwuerdigkes Verhalten bei einer awt::Size von 0
+ long nYSize = (long)( rSize.Y * 2.0 );
+ if ( nXSize < 1 )
+ nXSize = 1;
+ if ( nYSize < 1 )
+ nYSize = 1;
+
+ maXShape->setSize( awt::Size ( nXSize, nYSize ) );
+
+ if ( rOrientation != 0 )
+ {
+ fStartAngle += rOrientation;
+ if ( fStartAngle >= 360 )
+ fStartAngle -= 360;
+ fEndAngle += rOrientation;
+ if ( fEndAngle >= 360 )
+ fEndAngle -= 360;
+ }
+ switch( nType )
+ {
+ case 0 : eCircleKind = drawing::CircleKind_SECTION; break;
+ case 1 : eCircleKind = drawing::CircleKind_CUT; break;
+ case 2 : eCircleKind = drawing::CircleKind_ARC; break;
+ default : eCircleKind = drawing::CircleKind_FULL; break;
+ }
+ if ( (long)fStartAngle == (long)fEndAngle )
+ {
+ eCircleKind = drawing::CircleKind_FULL;
+ aAny.setValue( &eCircleKind, ::getCppuType((const drawing::CircleKind*)0) );
+ }
+ else
+ {
+ aAny.setValue( &eCircleKind, ::getCppuType((const drawing::CircleKind*)0) );
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("CircleKind"), aAny );
+ aAny <<= (sal_Int32)( (long)( fStartAngle * 100 ) );
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("CircleStartAngle"), aAny );
+ aAny <<= (sal_Int32)( (long)( fEndAngle * 100 ) );
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("CircleEndAngle"), aAny );
+ }
+ maXShape->setPosition( awt::Point( (long)( rCenter.X - rSize.X ), (long)( rCenter.Y - rSize.Y ) ) );
+ if ( rOrientation != 0 )
+ {
+ ImplSetOrientation( rCenter, rOrientation );
+ }
+ if ( eCircleKind == drawing::CircleKind_ARC )
+ {
+ ImplSetLineBundle();
+ }
+ else
+ {
+ ImplSetFillBundle();
+ if ( nType == 2 )
+ {
+ ImplSetLineBundle();
+ drawing::FillStyle eFillStyle = drawing::FillStyle_NONE;
+ aAny.setValue( &eFillStyle, ::getCppuType((const drawing::FillStyle*)0) );
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("FillStyle"), aAny );
+ }
+ }
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::DrawBitmap( CGMBitmapDescriptor* pBmpDesc )
+{
+ if ( pBmpDesc->mbStatus && pBmpDesc->mpBitmap )
+ {
+ FloatPoint aOrigin = pBmpDesc->mnOrigin;
+ double fdx = pBmpDesc->mndx;
+ double fdy = pBmpDesc->mndy;
+
+ sal_uInt32 nMirr = BMP_MIRROR_NONE;
+ if ( pBmpDesc->mbVMirror )
+ nMirr |= BMP_MIRROR_VERT;
+ if ( pBmpDesc->mbHMirror )
+ nMirr |= BMP_MIRROR_HORZ;
+ if ( nMirr != BMP_MIRROR_NONE )
+ pBmpDesc->mpBitmap->Mirror( nMirr );
+
+ mpCGM->ImplMapPoint( aOrigin );
+ mpCGM->ImplMapX( fdx );
+ mpCGM->ImplMapY( fdy );
+
+ if ( ImplCreateShape( rtl::OUString::createFromAscii("com.sun.star.drawing.GraphicObjectShape") ) )
+ {
+ maXShape->setSize( awt::Size( (long)fdx, (long)fdy ) );
+ maXShape->setPosition( awt::Point( (long)aOrigin.X, (long)aOrigin.Y ) );
+
+ if ( pBmpDesc->mnOrientation != 0 )
+ {
+ ImplSetOrientation( aOrigin, pBmpDesc->mnOrientation );
+ }
+
+ uno::Reference< awt::XBitmap > xBitmap( VCLUnoHelper::CreateBitmap( BitmapEx( *( pBmpDesc->mpBitmap ) ) ) );
+ uno::Any aAny;
+ aAny <<= xBitmap;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("GraphicObjectFillBitmap"), aAny );
+
+ }
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::DrawPolygon( Polygon& rPoly )
+{
+ sal_uInt16 nPoints = rPoly.GetSize();
+
+ if ( ( nPoints > 1 ) && ImplCreateShape( rtl::OUString::createFromAscii("com.sun.star.drawing.PolyPolygonShape") ) )
+ {
+ drawing::PointSequenceSequence aRetval;
+
+ // Polygone innerhalb vrobereiten
+ aRetval.realloc( 1 );
+
+ // Zeiger auf aeussere Arrays holen
+ drawing::PointSequence* pOuterSequence = aRetval.getArray();
+
+ // Platz in Arrays schaffen
+ pOuterSequence->realloc((sal_Int32)nPoints);
+
+ // Pointer auf arrays holen
+ awt::Point* pInnerSequence = pOuterSequence->getArray();
+
+ for( sal_uInt16 n = 0; n < nPoints; n++ )
+ *pInnerSequence++ = awt::Point( rPoly[ n ].X(), rPoly[n].Y() );
+
+ uno::Any aParam;
+ aParam <<= aRetval;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("PolyPolygon"), aParam );
+ ImplSetFillBundle();
+ }
+};
+
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::DrawPolyLine( Polygon& rPoly )
+{
+ sal_uInt16 nPoints = rPoly.GetSize();
+
+ if ( ( nPoints > 1 ) && ImplCreateShape( rtl::OUString::createFromAscii("com.sun.star.drawing.PolyLineShape") ) )
+ {
+ drawing::PointSequenceSequence aRetval;
+
+ // Polygone innerhalb vrobereiten
+ aRetval.realloc( 1 );
+
+ // Zeiger auf aeussere Arrays holen
+ drawing::PointSequence* pOuterSequence = aRetval.getArray();
+
+ // Platz in Arrays schaffen
+ pOuterSequence->realloc((sal_Int32)nPoints);
+
+ // Pointer auf arrays holen
+ awt::Point* pInnerSequence = pOuterSequence->getArray();
+
+ for( sal_uInt16 n = 0; n < nPoints; n++ )
+ *pInnerSequence++ = awt::Point( rPoly[ n ].X(), rPoly[n].Y() );
+
+ uno::Any aParam;
+ aParam <<= aRetval;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("PolyPolygon"), aParam );
+ ImplSetLineBundle();
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::DrawPolybezier( Polygon& rPolygon )
+{
+ sal_uInt32 nPoints = rPolygon.GetSize();
+ if ( ( nPoints > 1 ) && ImplCreateShape( rtl::OUString::createFromAscii("com.sun.star.drawing.OpenBezierShape") ) )
+ {
+ drawing::PolyPolygonBezierCoords aRetval;
+
+ aRetval.Coordinates.realloc( 1 );
+ aRetval.Flags.realloc( 1 );
+
+ // Zeiger auf aeussere Arrays holen
+ drawing::PointSequence* pOuterSequence = aRetval.Coordinates.getArray();
+ drawing::FlagSequence* pOuterFlags = aRetval.Flags.getArray();
+
+ // Platz in Arrays schaffen
+ pOuterSequence->realloc( nPoints );
+ pOuterFlags->realloc( nPoints );
+
+ awt::Point* pInnerSequence = pOuterSequence->getArray();
+ drawing::PolygonFlags* pInnerFlags = pOuterFlags->getArray();
+
+ for( sal_uInt32 i = 0; i < nPoints; i++ )
+ {
+ *pInnerSequence++ = awt::Point( rPolygon[ i ].X(), rPolygon[ i ].Y() );
+ *pInnerFlags++ = (drawing::PolygonFlags)rPolygon.GetFlags( i );
+ }
+ uno::Any aParam;
+ aParam <<= aRetval;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("PolyPolygonBezier"), aParam );
+ ImplSetLineBundle();
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::DrawPolyPolygon( PolyPolygon& rPolyPolygon )
+{
+ sal_uInt32 nNumPolys = rPolyPolygon.Count();
+ if ( nNumPolys && ImplCreateShape( rtl::OUString::createFromAscii("com.sun.star.drawing.ClosedBezierShape") ) )
+ {
+ drawing::PolyPolygonBezierCoords aRetval;
+
+ // Polygone innerhalb vrobereiten
+ aRetval.Coordinates.realloc((sal_Int32)nNumPolys);
+ aRetval.Flags.realloc((sal_Int32)nNumPolys);
+
+ // Zeiger auf aeussere Arrays holen
+ drawing::PointSequence* pOuterSequence = aRetval.Coordinates.getArray();
+ drawing::FlagSequence* pOuterFlags = aRetval.Flags.getArray();
+
+ for( sal_uInt16 a = 0; a < nNumPolys; a++ )
+ {
+ Polygon aPolygon( rPolyPolygon.GetObject( a ) );
+ sal_uInt32 nNumPoints = aPolygon.GetSize();
+
+ // Platz in Arrays schaffen
+ pOuterSequence->realloc((sal_Int32)nNumPoints);
+ pOuterFlags->realloc((sal_Int32)nNumPoints);
+
+ // Pointer auf arrays holen
+ awt::Point* pInnerSequence = pOuterSequence->getArray();
+ drawing::PolygonFlags* pInnerFlags = pOuterFlags->getArray();
+
+ for( sal_uInt16 b = 0; b < nNumPoints; b++ )
+ {
+ *pInnerSequence++ = awt::Point( aPolygon.GetPoint( b ).X(), aPolygon.GetPoint( b ).Y() ) ;
+ *pInnerFlags++ = (drawing::PolygonFlags)aPolygon.GetFlags( b );
+ }
+ pOuterSequence++;
+ pOuterFlags++;
+ }
+ uno::Any aParam;
+ aParam <<= aRetval;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("PolyPolygonBezier"), aParam);
+ ImplSetFillBundle();
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::DrawText( awt::Point& rTextPos, awt::Size& rTextSize, char* pString, sal_uInt32 nSize, FinalFlag eFlag )
+{
+ if ( ImplCreateShape( rtl::OUString::createFromAscii("com.sun.star.drawing.TextShape") ) )
+ {
+ uno::Any aAny;
+ long nWidth = rTextSize.Width;
+ long nHeight = rTextSize.Height;
+
+ awt::Point aTextPos( rTextPos );
+ switch ( mpCGM->pElement->eTextAlignmentV )
+ {
+ case TAV_HALF :
+ {
+ aTextPos.Y -= ( ( mpCGM->pElement->nCharacterHeight * 1.5 ) / 2 );
+ }
+ break;
+
+ case TAV_BASE :
+ case TAV_BOTTOM :
+ case TAV_NORMAL :
+ aTextPos.Y -= ( mpCGM->pElement->nCharacterHeight * 1.5 );
+ case TAV_TOP :
+ break;
+ }
+
+ if ( nWidth < 0 )
+ {
+ nWidth = -nWidth;
+ }
+ else if ( nWidth == 0 )
+ {
+ nWidth = -1;
+ }
+ if ( nHeight < 0 )
+ {
+ nHeight = -nHeight;
+ }
+ else if ( nHeight == 0 )
+ {
+ nHeight = -1;
+ }
+ maXShape->setPosition( aTextPos );
+ maXShape->setSize( awt::Size( nWidth, nHeight ) );
+ double nX = mpCGM->pElement->nCharacterOrientation[ 2 ];
+ double nY = mpCGM->pElement->nCharacterOrientation[ 3 ];
+ double nOrientation = acos( nX / sqrt( nX * nX + nY * nY ) ) * 57.29577951308;
+ if ( nY < 0 )
+ nOrientation = 360 - nOrientation;
+
+ if ( nOrientation )
+ {
+ aAny <<= (sal_Int32)( aTextPos.X );
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("RotationPointX"), aAny );
+ aAny <<= (sal_Int32)( aTextPos.Y + nHeight );
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("RotationPointY"), aAny );
+ aAny <<= (sal_Int32)( (sal_Int32)( nOrientation * 100 ) );
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("RotateAngle"), aAny );
+ }
+ if ( nWidth == -1 )
+ {
+ sal_Bool bTrue( sal_True );
+ aAny.setValue( &bTrue, ::getCppuType((const sal_Bool*)0 ));
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("TextAutoGrowWidth"), aAny );
+
+ drawing::TextAdjust eTextAdjust;
+ switch ( mpCGM->pElement->eTextAlignmentH )
+ {
+ case TAH_RIGHT :
+ eTextAdjust = drawing::TextAdjust_RIGHT;
+ break;
+ case TAH_LEFT :
+ case TAH_CONT :
+ case TAH_NORMAL :
+ eTextAdjust = drawing::TextAdjust_LEFT;
+ break;
+ case TAH_CENTER :
+ eTextAdjust = drawing::TextAdjust_CENTER;
+ break;
+ }
+ aAny <<= eTextAdjust;
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("TextHorizontalAdjust"), aAny );
+ }
+ if ( nHeight == -1 )
+ {
+ sal_Bool bTrue = sal_True;
+ aAny.setValue( &bTrue, ::getCppuType((const sal_Bool*)0) );
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("TextAutoGrowHeight"), aAny );
+ }
+ uno::Reference< text::XText > xText;
+ uno::Any aQuery( maXShape->queryInterface( ::getCppuType((const uno::Reference< text::XText >*)0) ));
+ if( aQuery >>= xText )
+ {
+ String aStr( String::CreateFromAscii( pString ) );
+
+ uno::Reference< text::XTextCursor > aXTextCursor( xText->createTextCursor() );
+ {
+ aXTextCursor->gotoEnd( sal_False );
+ uno::Reference< text::XTextRange > aCursorText;
+ uno::Any aQuery( aXTextCursor->queryInterface( ::getCppuType((const uno::Reference< text::XTextRange >*)0) ));
+ if ( aQuery >>= aCursorText )
+ {
+ uno::Reference< beans::XPropertySet > aCursorPropSet;
+
+ uno::Any aQuery( aCursorText->queryInterface( ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) ));
+ if( aQuery >>= aCursorPropSet )
+ {
+ if ( nWidth != -1 ) // paragraph adjusting in a valid textbox ?
+ {
+ switch ( mpCGM->pElement->eTextAlignmentH )
+ {
+ case TAH_RIGHT :
+ aAny <<= (sal_Int16)style::HorizontalAlignment_RIGHT;
+ break;
+ case TAH_LEFT :
+ case TAH_CONT :
+ case TAH_NORMAL :
+ aAny <<= (sal_Int16)style::HorizontalAlignment_LEFT;
+ break;
+ case TAH_CENTER :
+ aAny <<= (sal_Int16)style::HorizontalAlignment_CENTER;
+ break;
+ }
+ aCursorPropSet->setPropertyValue( rtl::OUString::createFromAscii("ParaAdjust"), aAny );
+ }
+ if ( nWidth > 0 && nHeight > 0 ) // restricted text
+ {
+ sal_Bool bTrue = sal_True;
+ aAny.setValue( &bTrue, ::getCppuType((const sal_Bool*)0));
+ maXPropSet->setPropertyValue( rtl::OUString::createFromAscii("TextFitToSize"), aAny );
+ }
+ aCursorText->setString( aStr );
+ aXTextCursor->gotoEnd( sal_True );
+ ImplSetTextBundle( aCursorPropSet );
+ }
+ }
+ }
+ }
+ if ( eFlag == FF_NOT_FINAL )
+ {
+ nFinalTextCount = maXShapes->getCount();
+ }
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::AppendText( char* pString, sal_uInt32 nSize, FinalFlag eFlag )
+{
+ if ( nFinalTextCount )
+ {
+ uno::Reference< drawing::XShape > aShape = *(uno::Reference< drawing::XShape > *)maXShapes->getByIndex( nFinalTextCount - 1 ).getValue();
+ if ( aShape.is() )
+ {
+ uno::Reference< text::XText > xText;
+ uno::Any aQuery( aShape->queryInterface( ::getCppuType((const uno::Reference< text::XText >*)0)) );
+ if( aQuery >>= xText )
+ {
+ String aStr( String::CreateFromAscii( pString ) );
+
+ uno::Reference< text::XTextCursor > aXTextCursor( xText->createTextCursor() );
+ if ( aXTextCursor.is() )
+ {
+ aXTextCursor->gotoEnd( sal_False );
+ uno::Reference< text::XTextRange > aCursorText;
+ uno::Any aQuery(aXTextCursor->queryInterface( ::getCppuType((const uno::Reference< text::XTextRange >*)0) ));
+ if ( aQuery >>= aCursorText )
+ {
+ uno::Reference< beans::XPropertySet > aPropSet;
+ uno::Any aQuery(aCursorText->queryInterface( ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) ));
+ if( aQuery >>= aPropSet )
+ {
+ aCursorText->setString( aStr );
+ aXTextCursor->gotoEnd( sal_True );
+ ImplSetTextBundle( aPropSet );
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+// ---------------------------------------------------------------
+// nCount != 0 -> Append Text
+sal_uInt32 CGMImpressOutAct::DrawText( TextEntry* pTextEntry, NodeFrameSet& rNodeFrameSet, sal_uInt32 nObjCount )
+{
+
+return 0;
+
+/*
+ uno::Reference< drawing::XShape > aShape;
+
+ if ( nObjCount )
+ {
+ aShape = (drawing::XShape*) maXShapes->getElementByIndex( nObjCount - 1 )->queryInterface( ::getCppuType((const Reference< drawing::XShape >*)0) );
+ }
+ else
+ {
+ aShape = maXShapes->insertShape( maXShapeFactory->createShape( L"ShapeText", rNodeFrameSet.nSize ), rNodeFrameSet.nTopLeft );
+ }
+ if ( aShape.is() )
+ {
+ uno::Reference< text::XText > xText = (text::XText*)aShape->queryInterface( ::getCppuType((const Reference< text::XText >*)0) );
+ if ( xText.is() )
+ {
+ uno::Reference< text::XTextCursor > aXTextCursor = (text::XTextCursor*)xText->createTextCursor()->queryInterface( ::getCppuType((const Reference< text::XTextCursor >*)0) );
+ if ( aXTextCursor.is() )
+ {
+ uno::Any aAny;
+ sal_uInt32 nTextOfs = 0;
+ TextAttribute* pTAttr = pTextEntry->pAttribute;
+ do
+ {
+ if ( pTAttr->nTextAttribSize > 0.3 ) // is text readable
+ {
+ aXTextCursor->gotoEnd( sal_False );
+ char nPushedChar = pTextEntry->pText[ nTextOfs + pTAttr->nTextAttribCount ];
+ pTextEntry->pText[ nTextOfs + pTAttr->nTextAttribCount ] = 0;
+ UString aStr( StringToOUString( pTextEntry->pText + nTextOfs, CHARSET_SYSTEM ) );
+
+ uno::Reference< text::XText > aCursorText = (text::XText*)aXTextCursor->queryInterface( ::getCppuType((const Reference< text::XText >*)0) );
+ if ( aCursorText.is() )
+ {
+ uno::Reference< beans::XPropertySet > aPropSet = (beans::XPropertySet*)aCursorText->queryInterface( ::getCppuType((const Reference< beans::XPropertySet >*)0) );
+ if ( aPropSet.is() )
+ {
+ if ( pTextEntry->nRowOrLineNum )
+ {
+ uno::Reference< XControlCharacterInsertable > aCRef = (XControlCharacterInsertable*)aXTextCursor->queryInterface( ::getCppuType((const Reference< XControlCharacterInsertable >*)0) );
+ if ( aCRef.is() )
+ {
+ aCRef->insertControlCharacter( TEXTCONTROLCHAR_PARAGRAPH_BREAK );
+ }
+ }
+ aCursorText->setText( aStr );
+ aXTextCursor->gotoEnd( sal_True );
+ double nSize = mpCGM->mnOutdx;
+ if ( mpCGM->mnOutdx < mpCGM->mnOutdy )
+ nSize = mpCGM->mnOutdy;
+ nSize = ( nSize * (double)pTAttr->nTextAttribSize * (double)1.5 ) / 100;
+
+ aAny <<= (sal_Int32)( (sal_Int32)nSize );
+ aPropSet->setPropertyValue( L"CharHeight", aAny );
+
+ sal_uInt32 nTextColor = pTAttr->nTextColorIndex;
+ if ( nTextColor == 0xff )
+ {
+ nTextColor = ( pTAttr->nTextColorBlue << 16 ) + ( pTAttr->nTextColorGreen << 8 ) + pTAttr->nTextColorRed;
+ }
+ else
+ {
+ nTextColor = mpCGM->pElement->aColorTable[ nTextColor ];
+ }
+
+ sal_uInt32 nFontType = 0;
+
+ if ( pTAttr->nTextFontType == 0xff )
+ {
+ FontEntry* pFontEntry = mpCGM->pElement->aFontList.GetFontEntry( pTAttr->nTextFontFamily );
+ if ( pFontEntry )
+ {
+ nFontType = pFontEntry->nFontType;
+ if ( mpCGM->pElement->nAspectSourceFlags & ASF_TEXTCOLOR )
+ nTextColor = mpCGM->pElement->pTextBundle->GetColor();
+ else
+ nTextColor = mpCGM->pElement->aTextBundle.GetColor();
+ }
+ FontItalic eFontItalic = ITALIC_NONE;
+ if ( nFontType & 1 )
+ eFontItalic = ITALIC_NORMAL;
+ aAny.setValue( &eFontItalic, ::getCppuType((const FontItalic*)0) );
+ aPropSet->setPropertyValue( L"CharPosture", aAny );
+ }
+ aAny <<= (sal_Int32)( (sal_Int32)nTextColor );
+ aPropSet->setPropertyValue( L"CharColor", aAny );
+
+ awt::FontWeight eFontWeight = WEIGHT_NORMAL;
+ if ( nFontType & 2 )
+ eFontWeight = WEIGHT_BOLD;
+ aAny.setValue( &eFontWeight, ::getCppuType((const awt::FontWeight*)0) );
+ aPropSet->setPropertyValue( L"CharWeight", aAny );
+
+ if ( pTAttr->nTextAttribBits & 0x4000 )
+ {
+ awt::FontUnderline eUnderline = UNDERLINE_SINGLE;
+ aAny.setValue( &eUnderline, ::getCppuType((const awt::FontUnderline*)0) );
+ aPropSet->setPropertyValue( L"CharUnderline", aAny );
+ }
+ }
+ }
+ pTextEntry->pText[ nTextOfs + pTAttr->nTextAttribCount ] = nPushedChar;
+ }
+ nTextOfs += pTAttr->nTextAttribCount;
+ }
+ while ( ( ( pTAttr = pTAttr->pNextAttribute ) != NULL ) );
+ }
+ }
+ }
+ return ( nObjCount ) ? nObjCount : maXShapes->getCount();
+*/
+}
+
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::ImplGetFrameSet( int nNodeNumber, NodeFrameSet& rFrameSet )
+{
+/*
+ DataNode* pDataNode = &mpCGM->mpChart->mDataNode[ nNodeNumber ];
+ FloatPoint aFloatPoint0, aFloatPoint1;
+
+ if ( pDataNode->nBoxX1 < pDataNode->nBoxX2 )
+ {
+ aFloatPoint0.X = (double)pDataNode->nBoxX1;
+ aFloatPoint1.X = (double)pDataNode->nBoxX2;
+ }
+ else
+ {
+ aFloatPoint0.X = (double)pDataNode->nBoxX2;
+ aFloatPoint1.X = (double)pDataNode->nBoxX1;
+ }
+
+ if ( pDataNode->nBoxY1 < pDataNode->nBoxY2 )
+ {
+ aFloatPoint0.Y = (double)( pDataNode->nBoxY1 );
+ aFloatPoint1.Y = (double)( pDataNode->nBoxY2 );
+ }
+ else
+ {
+ aFloatPoint0.Y = (double)pDataNode->nBoxY2;
+ aFloatPoint1.Y = (double)pDataNode->nBoxY1;
+ }
+ mpCGM->ImplMapPoint( aFloatPoint0 );
+ mpCGM->ImplMapPoint( aFloatPoint1 );
+ rFrameSet.nTopLeft.X() = (long)aFloatPoint0.X;
+ rFrameSet.nTopLeft.Y() = (long)aFloatPoint0.Y;
+ rFrameSet.nBottomRight.X() = (long)aFloatPoint1.X;
+ rFrameSet.nBottomRight.Y() = (long)aFloatPoint1.Y;
+ rFrameSet.nSize.Width() = ( (long)( aFloatPoint1.X - aFloatPoint0.X ) );
+ rFrameSet.nSize.Height() = ( (long)( aFloatPoint1.Y - aFloatPoint0.Y ) );
+*/
+}
+
+// ---------------------------------------------------------------
+
+void CGMImpressOutAct::DrawChart()
+{
+/*
+ NodeFrameSet aNodeFrameSet;
+ CGMChart* mpChart = mpCGM->mpChart;
+ switch ( mpChart->mnCurrentFileType )
+ {
+ case BULCHART :
+ {
+ sal_Bool bBulletBody = sal_False;
+ sal_uInt32 nObjCount = 0;
+
+ TextEntry* pTextEntry;
+ while( ( pTextEntry = mpChart->GetFirstTextEntry() ) )
+ {
+ switch( pTextEntry->nTypeOfText )
+ {
+ case IOC_CHTTITLE :
+ {
+ switch( pTextEntry->nRowOrLineNum )
+ {
+ case 0 : // MainTitle
+ {
+ ImplGetFrameSet( 2, aNodeFrameSet );
+ nObjCount = DrawText( pTextEntry, aNodeFrameSet, 0 );
+ }
+ break;
+ };
+ }
+ break;
+
+ case IOC_BULLETBODY :
+ {
+ if ( bBulletBody )
+ {
+ DrawText( pTextEntry, aNodeFrameSet, nObjCount );
+ }
+ else
+ {
+ bBulletBody = sal_True; // this is the first text entry for the bullet zone
+ ImplGetFrameSet( 3, aNodeFrameSet );
+ nObjCount = DrawText( pTextEntry, aNodeFrameSet, 0 );
+ }
+ }
+ break;
+
+ default :
+ break;
+ };
+ mpChart->DeleteTextEntry( pTextEntry );
+ }
+ }
+ break;
+
+ default :
+ {
+ TextEntry* pTextEntry;
+ while( ( pTextEntry = mpChart->GetFirstTextEntry() ) )
+ {
+ mpChart->DeleteTextEntry( pTextEntry );
+ }
+ }
+ break;
+ }
+*/
+}
+
+
diff --git a/goodies/source/filter.vcl/icgm/bitmap.cxx b/goodies/source/filter.vcl/icgm/bitmap.cxx
new file mode 100644
index 000000000000..c89cdb8c4e3c
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/bitmap.cxx
@@ -0,0 +1,449 @@
+/*************************************************************************
+ *
+ * $RCSfile: bitmap.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "main.hxx"
+
+// ---------------------------------------------------------------
+
+CGMBitmap::CGMBitmap( CGM& rCGM ) :
+ mpCGM ( &rCGM ),
+ pCGMBitmapDescriptor ( new CGMBitmapDescriptor )
+{
+ ImplGetBitmap( *pCGMBitmapDescriptor );
+};
+
+// ---------------------------------------------------------------
+
+CGMBitmap::~CGMBitmap()
+{
+ delete pCGMBitmapDescriptor;
+}
+
+// ---------------------------------------------------------------
+
+void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
+{
+ rDesc.mbStatus = sal_True;
+ long nx, ny, nxC, nxCount, nyCount;
+
+ if ( ImplGetDimensions( rDesc ) && rDesc.mpBuf )
+ {
+ if ( ( rDesc.mpBitmap = new Bitmap( Size( rDesc.mnX, rDesc.mnY ), (sal_uInt16)rDesc.mnDstBitsPerPixel ) ) != NULL )
+ {
+ if ( ( rDesc.mpAcc = rDesc.mpBitmap->AcquireWriteAccess() ) != NULL )
+ {
+
+ // the picture may either be read from left to right or right to left, from top to bottom ...
+
+ nxCount = rDesc.mnX + 1; // +1 because we are using prefix decreasing
+ nyCount = rDesc.mnY + 1;
+
+ switch ( rDesc.mnDstBitsPerPixel )
+ {
+ case 1 :
+ {
+ if ( rDesc.mnLocalColorPrecision == 1 )
+ ImplSetCurrentPalette( rDesc );
+ else
+ {
+ rDesc.mpAcc->SetPaletteEntryCount( 2 );
+ rDesc.mpAcc->SetPaletteColor( 0, BMCOL( mpCGM->pElement->nBackGroundColor ) );
+ rDesc.mpAcc->SetPaletteColor( 1,
+ ( mpCGM->pElement->nAspectSourceFlags & ASF_FILLINTERIORSTYLE )
+ ? BMCOL( mpCGM->pElement->pFillBundle->GetColor() )
+ : BMCOL( mpCGM->pElement->aFillBundle.GetColor() ) ) ;
+ }
+ for ( ny = 0; --nyCount ; ny++, rDesc.mpBuf += rDesc.mnScanSize )
+ {
+ nxC = nxCount;
+ for ( nx = 0; --nxC; nx++ )
+ { // this is not fast, but a one bit/pixel format is rarely used
+ rDesc.mpAcc->SetPixel( ny, nx, (sal_Int8)( (*( rDesc.mpBuf + ( nx >> 3 ) ) >> ( ( nx & 7 ) ^ 7 ) ) ) & 1 );
+ }
+ }
+ }
+ break;
+
+ case 2 :
+ {
+ ImplSetCurrentPalette( rDesc );
+ for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize )
+ {
+ nxC = nxCount;
+ for ( nx = 0; --nxC; nx++ )
+ { // this is not fast, but a two bits/pixel format is rarely used
+ rDesc.mpAcc->SetPixel( ny, nx, (sal_Int8)( (*( rDesc.mpBuf + ( nx >> 2 ) ) >> ( ( ( nx & 3 ) ^ 3 ) << 1 ) ) ) & 3 );
+ }
+ }
+ }
+ break;
+
+ case 4 :
+ {
+ ImplSetCurrentPalette( rDesc );
+ for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize )
+ {
+ nxC = nxCount;
+ sal_Int8 nDat;
+ sal_uInt8* pTemp = rDesc.mpBuf;
+ for ( nx = 0; --nxC; nx++ )
+ {
+ nDat = *pTemp++;
+ rDesc.mpAcc->SetPixel( ny, nx, (sal_Int8)( nDat >> 4 ) );
+ if ( --nxC )
+ {
+ nx ++;
+ rDesc.mpAcc->SetPixel( ny, nx, (sal_Int8)( nDat & 15 ) );
+ }
+ else
+ break;
+ }
+ }
+ }
+ break;
+
+ case 8 :
+ {
+ ImplSetCurrentPalette( rDesc );
+ for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize )
+ {
+ sal_uInt8* pTemp = rDesc.mpBuf;
+ nxC = nxCount;
+ for ( nx = 0; --nxC; nx++ )
+ {
+ rDesc.mpAcc->SetPixel( ny, nx, (sal_Int8)( *pTemp++ ) );
+ }
+ }
+ }
+ break;
+
+ case 24 :
+ {
+ {
+ BitmapColor aBitmapColor;
+ for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize )
+ {
+ sal_uInt8* pTemp = rDesc.mpBuf;
+ nxC = nxCount;
+ for ( nx = 0; --nxC; nx++ )
+ {
+ aBitmapColor.SetRed( (sal_Int8)*pTemp++ );
+ aBitmapColor.SetGreen( (sal_Int8)*pTemp++ );
+ aBitmapColor.SetBlue( (sal_Int8)*pTemp++ );
+ rDesc.mpAcc->SetPixel( ny, nx, aBitmapColor );
+ }
+ }
+ }
+ }
+ break;
+ };
+ double nX = rDesc.mnR.X - rDesc.mnQ.X;
+ double nY = rDesc.mnR.Y - rDesc.mnQ.Y;
+
+ rDesc.mndy = sqrt( nX * nX + nY * nY );
+
+ nX = rDesc.mnR.X - rDesc.mnP.X;
+ nY = rDesc.mnR.Y - rDesc.mnP.Y;
+
+ rDesc.mndx = sqrt( nX * nX + nY * nY );
+
+ nX = rDesc.mnR.X - rDesc.mnP.X;
+ nY = rDesc.mnR.Y - rDesc.mnP.Y;
+
+ rDesc.mnOrientation = acos( nX / sqrt( nX * nX + nY * nY ) ) * 57.29577951308;
+ if ( nY > 0 )
+ rDesc.mnOrientation = 360 - rDesc.mnOrientation;
+
+ nX = rDesc.mnQ.X - rDesc.mnR.X;
+ nY = rDesc.mnQ.Y - rDesc.mnR.Y;
+
+ double fAngle = 0.01745329251994 * ( 360 - rDesc.mnOrientation );
+ double fSin = sin(fAngle);
+ double fCos = cos(fAngle);
+ nX = fCos * nX + fSin * nY;
+ nY = -( fSin * nX - fCos * nY );
+
+ fAngle = acos( nX / sqrt( nX * nX + nY * nY ) ) * 57.29577951308;
+ if ( nY > 0 )
+ fAngle = 360 - fAngle;
+
+ if ( fAngle > 180 ) // wird das bild nach oben oder unten aufgebaut ?
+ {
+ rDesc.mnOrigin = rDesc.mnP;
+ }
+ else
+ {
+ rDesc.mbVMirror = sal_True;
+ rDesc.mnOrigin = rDesc.mnP;
+ rDesc.mnOrigin.X += rDesc.mnQ.X - rDesc.mnR.X;
+ rDesc.mnOrigin.Y += rDesc.mnQ.Y - rDesc.mnR.Y;
+ }
+ }
+ else
+ rDesc.mbStatus = sal_False;
+ }
+ else
+ rDesc.mbStatus = sal_False;
+ }
+ else
+ rDesc.mbStatus = sal_False;
+
+ if ( rDesc.mpAcc )
+ {
+ rDesc.mpBitmap->ReleaseAccess( rDesc.mpAcc );
+ rDesc.mpAcc = NULL;
+ }
+ if ( rDesc.mbStatus == sal_False )
+ {
+ if ( rDesc.mpBitmap )
+ {
+ delete rDesc.mpBitmap;
+ rDesc.mpBitmap = NULL;
+ }
+ }
+}
+
+// ---------------------------------------------------------------
+
+void CGMBitmap::ImplSetCurrentPalette( CGMBitmapDescriptor& rDesc )
+{
+ sal_uInt16 nColors = 1 << rDesc.mnDstBitsPerPixel;
+ rDesc.mpAcc->SetPaletteEntryCount( nColors );
+ for ( sal_uInt16 i = 0; i < nColors; i++ )
+ {
+ rDesc.mpAcc->SetPaletteColor( i, BMCOL( mpCGM->pElement->aLatestColorTable[ i ] ) );
+ }
+}
+
+// ---------------------------------------------------------------
+
+sal_Bool CGMBitmap::ImplGetDimensions( CGMBitmapDescriptor& rDesc )
+{
+ mpCGM->ImplGetPoint( rDesc.mnP ); // parallelogram p < - > r
+ mpCGM->ImplGetPoint( rDesc.mnQ ); // |
+ mpCGM->ImplGetPoint( rDesc.mnR ); // q
+ sal_uInt32 nPrecision = mpCGM->pElement->nIntegerPrecision;
+ rDesc.mnX = mpCGM->ImplGetUI( nPrecision );
+ rDesc.mnY = mpCGM->ImplGetUI( nPrecision );
+ rDesc.mnLocalColorPrecision = mpCGM->ImplGetI( nPrecision );
+ rDesc.mnScanSize = 0;
+ switch( rDesc.mnLocalColorPrecision )
+ {
+ case 0x80000001 : // monochrome ( bit = 0->backgroundcolor )
+ case 0 : // bit = 1->fillcolor
+ rDesc.mnDstBitsPerPixel = 1;
+ break;
+ case 1 : // 2 color indexed ( monochrome )
+ case -1 :
+ rDesc.mnDstBitsPerPixel = 1;
+ break;
+ case 2 : // 4 color indexed
+ case -2 :
+ rDesc.mnDstBitsPerPixel = 2;
+ break;
+ case 4 : // 16 color indexed
+ case -4 :
+ rDesc.mnDstBitsPerPixel = 4;
+ break;
+ case 8 : // 256 color indexed
+ case -8 :
+ rDesc.mnDstBitsPerPixel = 8;
+ rDesc.mnScanSize = rDesc.mnX;
+ break;
+ case 16 : // NS
+ case -16 :
+ rDesc.mbStatus = sal_False;
+ break;
+ case 24 : // 24 bit directColor ( 8 bits each component )
+ case -24 :
+ rDesc.mnDstBitsPerPixel = 24;
+ break;
+ case 32 : // NS
+ case -32 :
+ rDesc.mbStatus = sal_False;
+ break;
+
+ }
+ // mnCompressionMode == 0 : CCOMP_RUNLENGTH
+ // == 1 : CCOMP_PACKED ( no compression. each row starts on a 4 byte boundary )
+ if ( ( rDesc.mnCompressionMode = mpCGM->ImplGetUI16() ) != 1 )
+ rDesc.mbStatus = sal_False;
+
+ if ( ( rDesc.mnX || rDesc.mnY ) == 0 )
+ rDesc.mbStatus = sal_False;
+
+ sal_uInt32 nHeaderSize = 2 + 3 * nPrecision + 3 * mpCGM->ImplGetPointSize();
+ rDesc.mnScanSize = ( ( rDesc.mnX * rDesc.mnDstBitsPerPixel + 7 ) >> 3 );
+
+ if ( ( mpCGM->mnMode & CGM_IMPORT_IM ) && ( rDesc.mnLocalColorPrecision & 0x8000 ) )
+ { // if (sal_uInt16)precision is negative the color cell
+ rDesc.mnScanSize = ( rDesc.mnScanSize + 3 ) &~3; // array doesn't include data - instead it is just
+ rDesc.mpBuf = (sal_uInt8*)mpCGM->ImplGetUI( 4 ); // a 4 Byte pointer to the data
+ mpCGM->mnElementSize = mpCGM->mnParaSize;
+ }
+ else
+ {
+ sal_uInt32 nScanSize;
+ nScanSize = rDesc.mnScanSize;
+ if ( ( nScanSize * rDesc.mnY + nHeaderSize ) != mpCGM->mnElementSize ) // try a scansize without dw alignment
+ {
+ nScanSize = ( rDesc.mnScanSize + 1 ) & ~1;
+ if ( ( nScanSize * rDesc.mnY + nHeaderSize ) != mpCGM->mnElementSize ) // then we'll try word alignment
+ {
+ nScanSize = ( rDesc.mnScanSize + 3 ) & ~3;
+ if ( ( nScanSize * rDesc.mnY + nHeaderSize ) != mpCGM->mnElementSize ) // and last we'll try dword alignment
+ {
+ nScanSize = ( rDesc.mnScanSize + 1 ) & ~1; // and LAST BUT NOT LEAST we'll try word alignment without aligning the last line
+ if ( ( nScanSize * ( rDesc.mnY - 1 ) + rDesc.mnScanSize + nHeaderSize ) != mpCGM->mnElementSize )
+ {
+ nScanSize = ( rDesc.mnScanSize + 3 ) & ~3;
+ if ( ( nScanSize * ( rDesc.mnY - 1 ) + rDesc.mnScanSize + nHeaderSize ) != mpCGM->mnElementSize )
+ {
+ mpCGM->mnParaSize = 0; // this format is corrupt
+ rDesc.mbStatus = sal_False;
+ }
+ }
+ }
+ }
+ }
+ rDesc.mnScanSize = nScanSize;
+ if ( rDesc.mbStatus )
+ {
+ rDesc.mpBuf = mpCGM->mpSource + mpCGM->mnParaSize; // mpBuf now points to the first scanline
+ mpCGM->mnParaSize += rDesc.mnScanSize * rDesc.mnY;
+ }
+ }
+ return rDesc.mbStatus;
+}
+
+// ---------------------------------------------------------------
+
+void CGMBitmap::ImplInsert( CGMBitmapDescriptor& rSource, CGMBitmapDescriptor& rDest )
+{
+ if ( ( rSource.mnR.Y == rDest.mnQ.Y ) && ( rSource.mnR.X == rDest.mnQ.X ) )
+ { // Insert on Bottom
+ if ( mpCGM->mnVDCYmul == -1 )
+ rDest.mnOrigin = rSource.mnOrigin; // neuer origin
+ rDest.mpBitmap->Expand( 0, rSource.mnY );
+ rDest.mpBitmap->CopyPixel( Rectangle( Point( 0, rDest.mnY ), Size( rSource.mnX, rSource.mnY ) ),
+ Rectangle( Point( 0, 0 ), Size( rSource.mnX, rSource.mnY ) ), rSource.mpBitmap );
+ FloatPoint aFloatPoint;
+ aFloatPoint.X = rSource.mnQ.X - rSource.mnR.X;
+ aFloatPoint.Y = rSource.mnQ.Y - rSource.mnR.Y;
+ rDest.mnQ.X += aFloatPoint.X;
+ rDest.mnQ.Y += aFloatPoint.Y;
+ rDest.mnP = rSource.mnP;
+ rDest.mnR = rSource.mnR;
+ }
+ else
+ { // Insert on Top
+ if ( mpCGM->mnVDCYmul == 1 )
+ rDest.mnOrigin = rSource.mnOrigin; // neuer origin
+ rDest.mpBitmap->Expand( 0, rSource.mnY );
+ rDest.mpBitmap->CopyPixel( Rectangle( Point( 0, rDest.mnY ), Size( rSource.mnX, rSource.mnY ) ),
+ Rectangle( Point( 0, 0 ), Size( rSource.mnX, rSource.mnY ) ), rSource.mpBitmap );
+ rDest.mnP = rSource.mnP;
+ rDest.mnR = rSource.mnR;
+ }
+ rDest.mnY += rSource.mnY;
+ rDest.mndy += rSource.mndy;
+};
+
+// ---------------------------------------------------------------
+
+CGMBitmap* CGMBitmap::GetNext()
+{
+ if ( pCGMBitmapDescriptor->mpBitmap && pCGMBitmapDescriptor->mbStatus )
+ {
+ CGMBitmap* pCGMTempBitmap = new CGMBitmap( *mpCGM );
+ if ( pCGMTempBitmap )
+ {
+ if ( ( (long)pCGMTempBitmap->pCGMBitmapDescriptor->mnOrientation == (long)pCGMBitmapDescriptor->mnOrientation ) &&
+ ( ( ( pCGMTempBitmap->pCGMBitmapDescriptor->mnR.X == pCGMBitmapDescriptor->mnQ.X ) &&
+ ( pCGMTempBitmap->pCGMBitmapDescriptor->mnR.Y == pCGMBitmapDescriptor->mnQ.Y ) ) ||
+ ( ( pCGMTempBitmap->pCGMBitmapDescriptor->mnQ.X == pCGMBitmapDescriptor->mnR.X ) &&
+ ( pCGMTempBitmap->pCGMBitmapDescriptor->mnQ.Y == pCGMBitmapDescriptor->mnR.Y ) ) ) )
+ {
+ ImplInsert( *(pCGMTempBitmap->pCGMBitmapDescriptor), *(pCGMBitmapDescriptor) );
+ delete pCGMTempBitmap;
+ return NULL;
+ }
+ else // we'll replace the pointers and return the old one
+ {
+ CGMBitmapDescriptor* pTempBD = pCGMBitmapDescriptor;
+ pCGMBitmapDescriptor = pCGMTempBitmap->pCGMBitmapDescriptor;
+ pCGMTempBitmap->pCGMBitmapDescriptor = pTempBD;
+ return pCGMTempBitmap;
+ }
+ }
+ return NULL;
+ }
+ else
+ return NULL;
+}
+
+// ---------------------------------------------------------------
+
+CGMBitmapDescriptor* CGMBitmap::GetBitmap()
+{
+ return pCGMBitmapDescriptor;
+}
+
diff --git a/goodies/source/filter.vcl/icgm/bitmap.hxx b/goodies/source/filter.vcl/icgm/bitmap.hxx
new file mode 100644
index 000000000000..2f2287d9489d
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/bitmap.hxx
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * $RCSfile: bitmap.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:13 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CGM_BITMAP_HXX_
+#define CGM_BITMAP_HXX_
+
+#include "cgm.hxx"
+#include <vcl/bmpacc.hxx>
+
+class CGM;
+
+class CGMBitmapDescriptor
+{
+ public:
+ sal_uInt8* mpBuf;
+ Bitmap* mpBitmap;
+ BitmapWriteAccess* mpAcc;
+ sal_Bool mbStatus;
+ sal_Bool mbVMirror;
+ sal_Bool mbHMirror;
+ sal_uInt32 mnDstBitsPerPixel;
+ sal_uInt32 mnScanSize; // bytes per line
+ FloatPoint mnP, mnQ, mnR;
+
+ FloatPoint mnOrigin;
+ double mndx, mndy;
+ double mnOrientation;
+
+ sal_uInt32 mnX, mnY;
+ long mnLocalColorPrecision;
+ sal_uInt32 mnCompressionMode;
+ CGMBitmapDescriptor() :
+ mpAcc ( NULL ),
+ mbStatus ( sal_False ),
+ mbVMirror ( sal_False ),
+ mbHMirror ( sal_False ),
+ mpBitmap ( NULL ),
+ mpBuf ( NULL ) { };
+ ~CGMBitmapDescriptor()
+ {
+ if ( mpAcc )
+ mpBitmap->ReleaseAccess( mpAcc );
+ if ( mpBitmap )
+ delete mpBitmap;
+ };
+};
+
+class CGMBitmap
+{
+ CGM* mpCGM;
+ CGMBitmapDescriptor* pCGMBitmapDescriptor;
+ sal_Bool ImplGetDimensions( CGMBitmapDescriptor& );
+ void ImplSetCurrentPalette( CGMBitmapDescriptor& );
+ void ImplGetBitmap( CGMBitmapDescriptor& );
+ void ImplInsert( CGMBitmapDescriptor& rSource, CGMBitmapDescriptor& rDest );
+ public:
+ CGMBitmap( CGM& rCGM );
+ ~CGMBitmap();
+ CGMBitmapDescriptor* GetBitmap();
+ CGMBitmap* GetNext();
+};
+#endif
+
diff --git a/goodies/source/filter.vcl/icgm/bundles.cxx b/goodies/source/filter.vcl/icgm/bundles.cxx
new file mode 100644
index 000000000000..83b8d8d00cc3
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/bundles.cxx
@@ -0,0 +1,319 @@
+/*************************************************************************
+ *
+ * $RCSfile: bundles.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "bundles.hxx"
+
+#include <vcl/salbtype.hxx>
+#include <tools/stream.hxx>
+#include <tools/list.hxx>
+
+Bundle& Bundle::operator=( Bundle& rSource )
+{
+ mnColor = rSource.mnColor;
+ mnBundleIndex = rSource.mnBundleIndex;
+ return *this;
+};
+
+// ---------------------------------------------------------------
+
+void Bundle::SetColor( sal_uInt32 nColor )
+{
+ mnColor = nColor;
+}
+
+sal_uInt32 Bundle::GetColor()
+{
+ return mnColor;
+}
+
+// ---------------------------------------------------------------
+
+LineBundle& LineBundle::operator=( LineBundle& rSource )
+{
+ SetIndex( rSource.GetIndex() );
+ eLineType = rSource.eLineType;
+ nLineWidth = rSource.nLineWidth;
+ return *this;
+};
+
+MarkerBundle& MarkerBundle::operator=( MarkerBundle& rSource )
+{
+ SetIndex( rSource.GetIndex() );
+ eMarkerType = rSource.eMarkerType;
+ nMarkerSize = rSource.nMarkerSize;
+ return *this;
+};
+
+EdgeBundle& EdgeBundle::operator=( EdgeBundle& rSource )
+{
+ SetIndex( rSource.GetIndex() );
+ eEdgeType = rSource.eEdgeType;
+ nEdgeWidth = rSource.nEdgeWidth;
+ return *this;
+};
+
+TextBundle& TextBundle::operator=( TextBundle& rSource )
+{
+ SetIndex( rSource.GetIndex() );
+ nTextFontIndex = rSource.nTextFontIndex;
+ eTextPrecision = rSource.eTextPrecision;
+ nCharacterExpansion = rSource.nCharacterExpansion;
+ nCharacterSpacing = rSource.nCharacterSpacing;
+ return *this;
+};
+
+FillBundle& FillBundle::operator=( FillBundle& rSource )
+{
+ SetIndex( rSource.GetIndex() );
+ eFillInteriorStyle = rSource.eFillInteriorStyle;
+ nFillPatternIndex = rSource.nFillPatternIndex;
+ nFillHatchIndex = rSource.nFillHatchIndex;
+ return *this;
+};
+
+// ---------------------------------------------------------------
+
+FontEntry::FontEntry() :
+ pFontName ( NULL ),
+ pCharSetValue ( NULL ),
+ eCharSetType ( CST_CCOMPLETE ),
+ nFontType ( 0 )
+{
+}
+
+FontEntry::~FontEntry()
+{
+ delete pFontName;
+ delete pCharSetValue;
+}
+
+// ---------------------------------------------------------------
+
+FontList::FontList() :
+ nFontsAvailable ( 0 ),
+ nFontNameCount ( 0 ),
+ nCharSetCount ( 0 )
+{
+ aFontEntryList.Clear();
+}
+
+FontList::~FontList()
+{
+ ImplDeleteList();
+}
+
+// ---------------------------------------------------------------
+
+FontList& FontList::operator=( FontList& rSource )
+{
+ ImplDeleteList();
+ nFontsAvailable = rSource.nFontsAvailable;
+ nFontNameCount = rSource.nFontNameCount;
+ nCharSetCount = rSource.nCharSetCount;
+ FontEntry* pPtr = (FontEntry*)rSource.aFontEntryList.First();
+ while( pPtr )
+ {
+ FontEntry* pCFontEntry = new FontEntry;
+ if ( pPtr->pFontName )
+ {
+ sal_uInt32 nSize = strlen( (const char*)pPtr->pFontName ) + 1;
+ pCFontEntry->pFontName = new sal_Int8[ nSize ];
+ memcpy( pCFontEntry->pFontName, pPtr->pFontName, nSize );
+ }
+ if ( pPtr->pCharSetValue )
+ {
+ sal_uInt32 nSize = strlen( (const char*)pPtr->pCharSetValue ) + 1;
+ pCFontEntry->pCharSetValue = new sal_Int8[ nSize ];
+ memcpy( pCFontEntry->pCharSetValue, pPtr->pCharSetValue, nSize );
+ }
+ pCFontEntry->eCharSetType = pPtr->eCharSetType;
+ pCFontEntry->nFontType = pPtr->nFontType;
+ aFontEntryList.Insert( pCFontEntry, LIST_APPEND );
+ pPtr = (FontEntry*)rSource.aFontEntryList.Next();
+ }
+ return *this;
+}
+
+// ---------------------------------------------------------------
+
+FontEntry* FontList::GetFontEntry( sal_uInt32 nIndex )
+{
+ sal_uInt32 nInd = nIndex;
+ if ( nInd )
+ nInd--;
+ return (FontEntry*)aFontEntryList.GetObject( nInd );
+}
+
+// ---------------------------------------------------------------
+
+static sal_Int8* ImplSearchEntry( sal_Int8* pSource, sal_Int8* pDest, sal_uInt32 nComp, sal_uInt32 nSize )
+{
+ while ( nComp-- >= nSize )
+ {
+ sal_uInt32 i;
+ for ( i = 0; i < nSize; i++ )
+ {
+ if ( ( pSource[i]&~0x20 ) != ( pDest[i]&~0x20 ) )
+ break;
+ }
+ if ( i == nSize )
+ return pSource;
+ pSource++;
+ }
+ return NULL;
+}
+
+void FontList::InsertName( sal_uInt8* pSource, sal_uInt32 nSize )
+{
+ FontEntry* pFontEntry;
+ if ( nFontsAvailable == nFontNameCount )
+ {
+ nFontsAvailable++;
+ pFontEntry = new FontEntry;
+ aFontEntryList.Insert( pFontEntry, LIST_APPEND );
+ }
+ else
+ {
+ pFontEntry = (FontEntry*)aFontEntryList.GetObject( nFontNameCount );
+ }
+ nFontNameCount++;
+ sal_Int8* pBuf = new sal_Int8[ nSize ];
+ memcpy( pBuf, pSource, nSize );
+ sal_Int8* pFound = ImplSearchEntry( pBuf, (sal_Int8*)"ITALIC", nSize, 6 );
+ if ( pFound )
+ {
+ pFontEntry->nFontType |= 1;
+ sal_uInt32 nPrev = ( pFound - pBuf );
+ sal_uInt32 nToCopyOfs = 6;
+ if ( nPrev && ( pFound[ -1 ] == '-' || pFound[ -1 ] == ' ' ) )
+ {
+ nPrev--;
+ pFound--;
+ nToCopyOfs++;
+ }
+ sal_uInt32 nToCopy = nSize - nToCopyOfs - nPrev;
+ if ( nToCopy )
+ {
+ memcpy( pFound, pFound + nToCopyOfs, nToCopy );
+ }
+ nSize -= nToCopyOfs;
+ }
+ pFound = ImplSearchEntry( pBuf, (sal_Int8*)"BOLD", nSize, 4 );
+ if ( pFound )
+ {
+ pFontEntry->nFontType |= 2;
+
+ sal_uInt32 nPrev = ( pFound - pBuf );
+ sal_uInt32 nToCopyOfs = 4;
+ if ( nPrev && ( pFound[ -1 ] == '-' || pFound[ -1 ] == ' ' ) )
+ {
+ nPrev--;
+ pFound--;
+ nToCopyOfs++;
+ }
+ sal_uInt32 nToCopy = nSize - nToCopyOfs - nPrev;
+ if ( nToCopy )
+ {
+ memcpy( pFound, pFound + nToCopyOfs, nToCopy );
+ }
+ nSize -= nToCopyOfs;
+ }
+ pFontEntry->pFontName = new sal_Int8[ nSize + 1 ];
+ pFontEntry->pFontName[ nSize ] = 0;
+ memcpy( pFontEntry->pFontName, pBuf, nSize );
+ delete pBuf;
+}
+
+//--------------------------------------------------------------------------
+
+void FontList::InsertCharSet( CharSetType eCharSetType, sal_uInt8* pSource, sal_uInt32 nSize )
+{
+ FontEntry* pFontEntry;
+ if ( nFontsAvailable == nCharSetCount )
+ {
+ nFontsAvailable++;
+ pFontEntry = new FontEntry;
+ aFontEntryList.Insert( pFontEntry, LIST_APPEND );
+ }
+ else
+ {
+ pFontEntry = (FontEntry*)aFontEntryList.GetObject( nCharSetCount );
+ }
+ nCharSetCount++;
+ pFontEntry->eCharSetType = eCharSetType;
+ pFontEntry->pCharSetValue = new sal_Int8[ nSize + 1 ];
+ pFontEntry->pCharSetValue[ nSize ] = 0;
+ memcpy( pFontEntry->pCharSetValue, pSource , nSize );
+}
+
+// ---------------------------------------------------------------
+
+void FontList::ImplDeleteList()
+{
+ FontEntry* pFontEntry = (FontEntry*)aFontEntryList.First();
+ while( pFontEntry )
+ {
+ delete pFontEntry;
+ pFontEntry = (FontEntry*)aFontEntryList.Next();
+ }
+ aFontEntryList.Clear();
+}
+
diff --git a/goodies/source/filter.vcl/icgm/bundles.hxx b/goodies/source/filter.vcl/icgm/bundles.hxx
new file mode 100644
index 000000000000..f9423d3051c6
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/bundles.hxx
@@ -0,0 +1,207 @@
+/*************************************************************************
+ *
+ * $RCSfile: bundles.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CGM_BUNDLES_HXX_
+#define CGM_BUNDLES_HXX_
+
+#include <sal/types.h>
+#include "cgmtypes.hxx"
+#include <tools/list.hxx>
+#include <vcl/salbtype.hxx>
+
+// ---------------------------------------------------------------
+
+class CGM;
+
+class Bundle
+{
+
+ long mnBundleIndex;
+ sal_uInt32 mnColor;
+
+public:
+ void SetColor( sal_uInt32 nColor ) ;
+ sal_uInt32 GetColor() ;
+ long GetIndex() const { return mnBundleIndex; } ;
+ void SetIndex( long nBundleIndex ) { mnBundleIndex = nBundleIndex; } ;
+
+ Bundle() {};
+ virtual Bundle* Clone() { return new Bundle( *this ); };
+ virtual Bundle& operator=( Bundle& rBundle );
+
+ virtual ~Bundle() {} ;
+};
+
+// ---------------------------------------------------------------
+
+class LineBundle : public Bundle
+{
+public:
+
+ LineType eLineType;
+ double nLineWidth;
+
+ LineBundle() {};
+ virtual Bundle* Clone() { return new LineBundle( *this ); };
+ virtual LineBundle& operator=( LineBundle& rLineBundle );
+ virtual ~LineBundle() {};
+};
+
+// ---------------------------------------------------------------
+
+class MarkerBundle : public Bundle
+{
+public:
+
+ MarkerType eMarkerType;
+ double nMarkerSize;
+
+ MarkerBundle() {};
+ virtual Bundle* Clone() { return new MarkerBundle( *this ); } ;
+ virtual MarkerBundle& operator=( MarkerBundle& rMarkerBundle );
+ virtual ~MarkerBundle() {};
+};
+
+// ---------------------------------------------------------------
+
+class EdgeBundle : public Bundle
+{
+public:
+
+ EdgeType eEdgeType;
+ double nEdgeWidth;
+
+ EdgeBundle() {};
+ virtual Bundle* Clone() { return new EdgeBundle( *this ); } ;
+ virtual EdgeBundle& operator=( EdgeBundle& rEdgeBundle );
+ virtual ~EdgeBundle() {};
+};
+
+// ---------------------------------------------------------------
+
+class TextBundle : public Bundle
+{
+public:
+
+ sal_uInt32 nTextFontIndex;
+ TextPrecision eTextPrecision;
+ double nCharacterExpansion;
+ double nCharacterSpacing;
+
+ TextBundle() {};
+ virtual Bundle* Clone() { return new TextBundle( *this ); } ;
+ virtual TextBundle& operator=( TextBundle& rTextBundle );
+ virtual ~TextBundle() {};
+};
+
+// ---------------------------------------------------------------
+
+class FillBundle : public Bundle
+{
+public:
+
+ FillInteriorStyle eFillInteriorStyle;
+ long nFillPatternIndex;
+ long nFillHatchIndex;
+
+ FillBundle() {};
+ virtual Bundle* Clone() { return new FillBundle( *this ); } ;
+ virtual FillBundle& operator=( FillBundle& rFillBundle );
+ virtual ~FillBundle() {};
+};
+
+
+// ---------------------------------------------------------------
+
+class FontEntry
+{
+public:
+ sal_Int8* pFontName;
+ CharSetType eCharSetType;
+ sal_Int8* pCharSetValue;
+ sal_uInt32 nFontType; // bit 0 = 1 -> Italic,
+ // bit 1 = 1 -> Bold
+
+ FontEntry();
+ FontEntry* Clone() { return new FontEntry( *this ); } ;
+ ~FontEntry();
+};
+
+// ---------------------------------------------------------------
+
+class FontList
+{
+ sal_uInt32 nFontNameCount;
+ sal_uInt32 nCharSetCount;
+ List aFontEntryList;
+ void ImplDeleteList();
+public:
+ sal_uInt32 nFontsAvailable;
+ FontEntry* GetFontEntry( sal_uInt32 );
+ void InsertName( sal_uInt8* pSource, sal_uInt32 nSize );
+ void InsertCharSet( CharSetType, sal_uInt8* pSource, sal_uInt32 nSize );
+ FontList();
+ FontList& operator=( FontList& rFontList );
+ ~FontList();
+};
+
+
+#endif
diff --git a/goodies/source/filter.vcl/icgm/cgm.cxx b/goodies/source/filter.vcl/icgm/cgm.cxx
new file mode 100644
index 000000000000..e9ea93ff3c4c
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/cgm.cxx
@@ -0,0 +1,1065 @@
+/*************************************************************************
+ *
+ * $RCSfile: cgm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _COM_SUN_STAR_TASK_XSTATUSINDICATOR_HPP_
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#endif
+
+#define CGM_BREAK_ACTION 0xffffffff
+
+#include <vcl/virdev.hxx>
+#include <vcl/graph.hxx>
+#include <tools/stream.hxx>
+#include <chart.hxx>
+#include <main.hxx>
+#include <elements.hxx>
+#include <outact.hxx>
+
+using namespace ::com::sun::star;
+
+// ---------------------------------------------------------------
+
+void CGM::ImplCGMInit()
+{
+ mbIsFinished = mbPicture = mbMetaFile = mbPictureBody = sal_False;
+
+ mnActCount = 0;
+ mnOutdx = 28000;
+ mnOutdy = 21000;
+
+ mpBuf = NULL;
+ mpChart = NULL;
+ mpBitmapInUse = NULL;
+
+ pCopyOfE = new CGMElements( *this );
+ pElement = new CGMElements( *this );
+}
+
+// ---------------------------------------------------------------
+
+CGM::CGM( sal_uInt32 nMode ) :
+ mnMode ( nMode ),
+ mpGraphic ( NULL ), //
+ mpCommentOut ( NULL ), //
+ mbStatus ( sal_True ),
+ mpOutAct ( new CGMOutAct( *this ) )
+{
+ ImplCGMInit();
+};
+
+// ---------------------------------------------------------------
+
+#ifdef CGM_EXPORT_IMPRESS
+
+CGM::CGM( sal_uInt32 nMode, uno::Reference< frame::XModel > & rModel ) :
+ mnMode ( nMode ),
+ mpGraphic ( NULL ),
+ mpCommentOut ( NULL ),
+ mbStatus ( sal_True ),
+ mpOutAct ( new CGMImpressOutAct( *this, rModel ) )
+{
+// mpCommentOut = new SvFileStream( "d:\\out.txt", STREAM_WRITE | STREAM_TRUNC );
+ mnMode |= CGM_EXPORT_IMPRESS;
+ ImplCGMInit();
+}
+#endif
+
+// ---------------------------------------------------------------
+
+#ifdef CGM_EXPORT_META
+CGM::CGM( sal_uInt32 nMode, Graphic& rGraphic ) :
+ mnMode ( nMode ),
+ mpGraphic ( &rGraphic ),
+ mpCommentOut ( NULL ),
+ mbStatus ( sal_True ),
+ mpGDIMetaFile ( new GDIMetaFile ),
+ mpOutAct ( new CGMMetaOutAct( *this ) )
+{
+ ImplCGMInit();
+ mpVirDev = new VirtualDevice();
+ mpVirDev->EnableOutput( sal_False );
+ mpGDIMetaFile->Record( mpVirDev );
+};
+#endif
+
+// ---------------------------------------------------------------
+
+void CGM::ImplComment( sal_uInt32 Level, char* Description )
+{
+ if ( mpCommentOut )
+ {
+ if ( Level == CGM_DESCRIPTION )
+ {
+ *mpCommentOut << " " << Description << "\n";
+ }
+ else
+ {
+ sal_Int8 nFirst, nSecond, i, nCount = 0;
+ if ( mnActCount < 10000 )
+ nCount++;
+ if ( mnActCount < 1000 )
+ nCount++;
+ if ( mnActCount < 100 )
+ nCount++;
+ if ( mnActCount < 10 )
+ nCount++;
+ for ( i = 0; i <= nCount; i++ )
+ *mpCommentOut << " ";
+ mpCommentOut->WriteNumber( mnActCount );
+
+ switch( Level & 0xff )
+ {
+ case CGM_UNKNOWN_LEVEL :
+ *mpCommentOut << " L?";
+ break;
+ case CGM_UNKNOWN_COMMAND :
+ *mpCommentOut << " UNKNOWN COMMAND";
+ break;
+ case CGM_GDSF_ONLY :
+ *mpCommentOut << " LI";
+ break;
+ default:
+ *mpCommentOut << " L";
+ mpCommentOut->WriteNumber( Level & 0xff );
+ break;
+ }
+ *mpCommentOut << " C";
+ mpCommentOut->WriteNumber( mnElementClass );
+ *mpCommentOut << " ID-0x";
+ nFirst = ( mnElementID > 0x9F ) ? (sal_Int8)( mnElementID >> 4 ) + 'A' - 10: (sal_Int8)( mnElementID >> 4 ) + '0';
+ nSecond = ( ( mnElementID & 15 ) > 9 ) ? (sal_Int8)( mnElementID & 15 ) + 'A' - 10 : (sal_Int8)( mnElementID & 15 ) + '0';
+ *mpCommentOut << nFirst << nSecond;
+ *mpCommentOut << " Size";
+ nCount = 1;
+ if ( mnElementSize < 1000000 )
+ nCount++;
+ if ( mnElementSize < 100000 )
+ nCount++;
+ if ( mnElementSize < 10000 )
+ nCount++;
+ if ( mnElementSize < 1000 )
+ nCount++;
+ if ( mnElementSize < 100 )
+ nCount++;
+ if ( mnElementSize < 10 )
+ nCount++;
+ for ( i = 0; i < nCount; i++ )
+ *mpCommentOut << " ";
+ mpCommentOut->WriteNumber( mnElementSize );
+ *mpCommentOut << " " << Description << "\n";
+ }
+ }
+}
+
+// ---------------------------------------------------------------
+
+CGM::~CGM()
+{
+
+#ifdef CGM_EXPORT_META
+ if ( mpGraphic )
+ {
+ mpGDIMetaFile->Stop();
+ mpGDIMetaFile->SetPrefMapMode( MapMode() );
+ mpGDIMetaFile->SetPrefSize( Size( mnOutdx, mnOutdy ) );
+ delete mpVirDev;
+ *mpGraphic = Graphic( *mpGDIMetaFile );
+ }
+#endif
+ sal_Int8* pBuf = (sal_Int8*)maDefRepList.First();
+ while( pBuf )
+ {
+ delete pBuf;
+ pBuf = (sal_Int8*)maDefRepList.Next();
+ }
+ maDefRepList.Clear();
+ delete mpBitmapInUse;
+ delete mpCommentOut;
+ delete mpChart;
+ delete mpOutAct;
+ delete pCopyOfE;
+ delete pElement;
+ delete mpBuf;
+};
+
+// ---------------------------------------------------------------
+
+sal_uInt32 CGM::GetBackGroundColor()
+{
+ return ( pElement ) ? pElement->aColorTable[ 0 ] : 0;
+}
+
+// ---------------------------------------------------------------
+
+sal_uInt32 CGM::ImplGetUI16( sal_uInt32 nAlign )
+{
+ sal_uInt8* pSource = mpSource + mnParaSize;
+ mnParaSize += 2;
+ if ( nAlign && ( mnMode & CGM_IMPORT_IM ) )
+ {
+ nAlign--;
+ mnParaSize += nAlign;
+ mnParaSize &=~nAlign;
+ }
+ if ( mnMode & CGM_BIG_ENDIAN )
+ return ( pSource[ 0 ] << 8 ) + pSource[ 1 ];
+ else
+ return ( pSource[ 1 ] << 8 ) + pSource[ 0 ];
+};
+
+// ---------------------------------------------------------------
+
+sal_uInt8 CGM::ImplGetByte( sal_uInt32 nSource, sal_uInt32 nPrecision )
+{
+ return (sal_uInt8)( nSource >> ( ( nPrecision - 1 ) << 3 ) );
+};
+
+// ---------------------------------------------------------------
+
+long CGM::ImplGetI( sal_uInt32 nPrecision )
+{
+ sal_uInt8* pSource = mpSource + mnParaSize;
+ mnParaSize += nPrecision;
+ switch( nPrecision )
+ {
+ case 1 :
+ {
+ return (char)*pSource;
+ }
+
+ case 2 :
+ {
+ if ( mnMode & CGM_BIG_ENDIAN )
+ return (sal_Int16)( ( pSource[ 0 ] << 8 ) | pSource[ 1 ] );
+ else
+ return (sal_Int16)( ( pSource[ 1 ] << 8 ) | pSource[ 0 ] );
+ }
+
+ case 3 :
+ {
+ if ( mnMode & CGM_BIG_ENDIAN )
+ return ( ( pSource[ 0 ] << 24 ) | ( pSource[ 1 ] << 16 ) | pSource[ 2 ] << 8 ) >> 8;
+ else
+ return ( ( pSource[ 2 ] << 24 ) | ( pSource[ 1 ] << 16 ) | pSource[ 0 ] << 8 ) >> 8;
+ }
+ case 4:
+ {
+ if ( mnMode & CGM_BIG_ENDIAN )
+ return (sal_Int32)( ( pSource[ 0 ] << 24 ) | ( pSource[ 1 ] << 16 ) | ( pSource[ 2 ] << 8 ) | ( pSource[ 3 ] ) );
+ else
+ return (sal_Int32)( ( pSource[ 3 ] << 24 ) | ( pSource[ 2 ] << 16 ) | ( pSource[ 1 ] << 8 ) | ( pSource[ 0 ] ) );
+ }
+ default:
+ mbStatus = sal_False;
+ return 0;
+ }
+}
+
+// ---------------------------------------------------------------
+
+sal_uInt32 CGM::ImplGetUI( sal_uInt32 nPrecision )
+{
+ sal_uInt8* pSource = mpSource + mnParaSize;
+ mnParaSize += nPrecision;
+ switch( nPrecision )
+ {
+ case 1 :
+ return (sal_Int8)*pSource;
+ case 2 :
+ {
+ if ( mnMode & CGM_BIG_ENDIAN )
+ return (sal_uInt16)( ( pSource[ 0 ] << 8 ) | pSource[ 1 ] );
+ else
+ return (sal_uInt16)( ( pSource[ 1 ] << 8 ) | pSource[ 0 ] );
+ }
+ case 3 :
+ {
+ if ( mnMode & CGM_BIG_ENDIAN )
+ return ( pSource[ 0 ] << 16 ) | ( pSource[ 1 ] << 8 ) | pSource[ 2 ];
+ else
+ return ( pSource[ 2 ] << 16 ) | ( pSource[ 1 ] << 8 ) | pSource[ 0 ];
+ }
+ case 4:
+ {
+ if ( mnMode & CGM_BIG_ENDIAN )
+ return (sal_uInt32)( ( pSource[ 0 ] << 24 ) | ( pSource[ 1 ] << 16 ) | ( pSource[ 2 ] << 8 ) | ( pSource[ 3 ] ) );
+ else
+ return (sal_uInt32)( ( pSource[ 3 ] << 24 ) | ( pSource[ 2 ] << 16 ) | ( pSource[ 1 ] << 8 ) | ( pSource[ 0 ] ) );
+ }
+ default:
+ mbStatus = sal_False;
+ return 0;
+ }
+}
+
+// ---------------------------------------------------------------
+
+void CGM::ImplGetSwitch4( sal_uInt8* pSource, sal_uInt8* pDest )
+{
+ for ( int i = 0; i < 4; i++ )
+ {
+ pDest[ i ] = pSource[ i ^ 3 ]; // Little Endian <-> Big Endian switch
+ }
+}
+
+// ---------------------------------------------------------------
+
+void CGM::ImplGetSwitch8( sal_uInt8* pSource, sal_uInt8* pDest )
+{
+ for ( int i = 0; i < 8; i++ )
+ {
+ pDest[ i ] = pSource[ i ^ 7 ]; // Little Endian <-> Big Endian switch
+ }
+}
+
+// ---------------------------------------------------------------
+
+double CGM::ImplGetFloat( RealPrecision eRealPrecision, sal_uInt32 nRealSize )
+{
+ void* pPtr;
+ sal_uInt8 aBuf[8];
+ sal_Bool bCompatible;
+ double nRetValue;
+ double fDoubleBuf;
+ float fFloatBuf;
+
+#ifdef __BIGENDIAN
+ if ( mnMode & CGM_BIG_ENDIAN )
+ bCompatible = sal_True;
+ else
+ bCompatible = sal_False;
+#else
+ if ( mnMode & CGM_LITTLE_ENDIAN )
+ bCompatible = sal_True;
+ else
+ bCompatible = sal_False;
+#endif
+ if ( bCompatible )
+ pPtr = mpSource + mnParaSize;
+ else
+ {
+ if ( nRealSize == 4 )
+ ImplGetSwitch4( mpSource + mnParaSize, &aBuf[0] );
+ else
+ ImplGetSwitch8( mpSource + mnParaSize, &aBuf[0] );
+ pPtr = &aBuf;
+ }
+ if ( eRealPrecision == RP_FLOAT )
+ {
+ if ( nRealSize == 4 )
+ {
+ memcpy( (void*)&fFloatBuf, pPtr, 4 );
+ nRetValue = (double)fFloatBuf;
+ }
+ else
+ {
+ memcpy( (void*)&fDoubleBuf, pPtr, 8 );
+ nRetValue = fDoubleBuf;
+ }
+ }
+ else // ->RP_FIXED
+ {
+ long nVal;
+ int nSwitch = ( bCompatible ) ? 0 : 1 ;
+ if ( nRealSize == 4 )
+ {
+ sal_uInt16* pShort = (sal_uInt16*)pPtr;
+ nVal = pShort[ nSwitch ];
+ nVal <<= 16;
+ nVal |= pShort[ nSwitch ^ 1 ];
+ nRetValue = (double)nVal;
+ nRetValue /= 65536;
+ }
+ else
+ {
+ long* pLong = (long*)pPtr;
+ nRetValue = (double)abs( pLong[ nSwitch ] );
+ nRetValue *= 65536;
+ nVal = (sal_uInt32)( pLong[ nSwitch ^ 1 ] );
+ nVal >>= 16;
+ nRetValue += (double)nVal;
+ if ( pLong[ nSwitch ] < 0 )
+ {
+ nRetValue -= nRetValue;
+ }
+ nRetValue /= 65536;
+ }
+ }
+ mnParaSize += nRealSize;
+ return nRetValue;
+}
+
+// ---------------------------------------------------------------
+
+sal_uInt32 CGM::ImplGetPointSize()
+{
+ if ( pElement->eVDCType == VDC_INTEGER )
+ return pElement->nVDCIntegerPrecision << 1;
+ else
+ {
+ if ( mnMode & CGM_IMPORT_IM )
+ return pElement->nVDCRealSize * 3;
+ else
+ return pElement->nVDCRealSize << 1;
+ }
+}
+
+// ---------------------------------------------------------------
+
+inline double CGM::ImplGetIX()
+{
+ return ( ( ImplGetI( pElement->nVDCIntegerPrecision ) + mnVDCXadd ) * mnVDCXmul );
+}
+
+// ---------------------------------------------------------------
+
+inline double CGM::ImplGetFX()
+{
+ return ( ( ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize ) + mnVDCXadd ) * mnVDCXmul );
+}
+
+// ---------------------------------------------------------------
+
+inline double CGM::ImplGetIY()
+{
+ return ( ( ImplGetI( pElement->nVDCIntegerPrecision ) + mnVDCYadd ) * mnVDCYmul );
+}
+
+// ---------------------------------------------------------------
+
+inline double CGM::ImplGetFY()
+{
+ return ( ( ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize ) + mnVDCYadd ) * mnVDCYmul );
+}
+
+// ---------------------------------------------------------------
+
+void CGM::ImplGetPoint( FloatPoint& rFloatPoint, sal_Bool bMap )
+{
+ if ( pElement->eVDCType == VDC_INTEGER )
+ {
+ rFloatPoint.X = ImplGetIX();
+ rFloatPoint.Y = ImplGetIY();
+ }
+ else // ->floating points
+ {
+ rFloatPoint.X = ImplGetFX();
+ rFloatPoint.Y = ImplGetFY();
+ if ( mnMode & CGM_IMPORT_IM )
+ mnParaSize += 8;
+ }
+ if ( bMap )
+ ImplMapPoint( rFloatPoint );
+}
+
+// ---------------------------------------------------------------
+
+void CGM::ImplGetRectangle( FloatRect& rFloatRect, sal_Bool bMap )
+{
+ if ( pElement->eVDCType == VDC_INTEGER )
+ {
+ rFloatRect.Left = ImplGetIX();
+ rFloatRect.Bottom = ImplGetIY();
+ rFloatRect.Right = ImplGetIX();
+ rFloatRect.Top = ImplGetIY();
+ }
+ else // ->floating points
+ {
+ rFloatRect.Left = ImplGetFX();
+ rFloatRect.Bottom = ImplGetFY();
+ if ( mnMode & CGM_IMPORT_IM )
+ mnParaSize += 8;
+ rFloatRect.Right = ImplGetFX();
+ rFloatRect.Top = ImplGetFY();
+ if ( mnMode & CGM_IMPORT_IM )
+ mnParaSize += 8;
+ }
+ if ( bMap )
+ {
+ ImplMapX( rFloatRect.Left );
+ ImplMapX( rFloatRect.Right );
+ ImplMapY( rFloatRect.Top );
+ ImplMapY( rFloatRect.Bottom );
+ rFloatRect.Justify();
+ }
+}
+
+// ---------------------------------------------------------------
+
+void CGM::ImplGetRectangleNS( FloatRect& rFloatRect )
+{
+ if ( pElement->eVDCType == VDC_INTEGER )
+ {
+ rFloatRect.Left = ImplGetI( pElement->nVDCIntegerPrecision );
+ rFloatRect.Bottom = ImplGetI( pElement->nVDCIntegerPrecision );
+ rFloatRect.Right = ImplGetI( pElement->nVDCIntegerPrecision );
+ rFloatRect.Top = ImplGetI( pElement->nVDCIntegerPrecision );
+ }
+ else // ->floating points
+ {
+ rFloatRect.Left = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ rFloatRect.Bottom = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ if ( mnMode & CGM_IMPORT_IM )
+ mnParaSize += 8;
+ rFloatRect.Right = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ rFloatRect.Top = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ if ( mnMode & CGM_IMPORT_IM )
+ mnParaSize += 8;
+ }
+}
+
+// ---------------------------------------------------------------
+
+sal_uInt32 CGM::ImplGetBitmapColor( sal_Bool bDirect )
+{
+ // the background color is always a direct color
+
+ sal_uInt32 nTmp;
+ if ( ( pElement->eColorSelectionMode == CSM_DIRECT ) || bDirect )
+ {
+ sal_uInt32 nColor = ImplGetByte( ImplGetUI( pElement->nColorPrecision ), 1 );
+ sal_uInt32 nDiff = pElement->nColorValueExtent[ 3 ] - pElement->nColorValueExtent[ 0 ] + 1;
+
+ if ( !nDiff )
+ nDiff++;
+ nColor = ( ( nColor - pElement->nColorValueExtent[ 0 ] ) << 8 ) / nDiff;
+ nTmp = nColor << 16 & 0xff0000;
+
+ nColor = ImplGetByte( ImplGetUI( pElement->nColorPrecision ), 1 );
+ nDiff = pElement->nColorValueExtent[ 4 ] - pElement->nColorValueExtent[ 1 ] + 1;
+ if ( !nDiff )
+ nDiff++;
+ nColor = ( ( nColor - pElement->nColorValueExtent[ 1 ] ) << 8 ) / nDiff;
+ nTmp |= nColor << 8 & 0xff00;
+
+ nColor = ImplGetByte( ImplGetUI( pElement->nColorPrecision ), 1 );
+ nDiff = pElement->nColorValueExtent[ 5 ] - pElement->nColorValueExtent[ 2 ] + 1;
+ if ( !nDiff )
+ nDiff++;
+ nColor = ( ( nColor - pElement->nColorValueExtent[ 2 ] ) << 8 ) / nDiff;
+ nTmp |= (sal_Int8)nColor;
+ }
+ else
+ {
+ sal_uInt32 nIndex = ImplGetUI( pElement->nColorIndexPrecision );
+ nTmp = pElement->aColorTable[ (sal_Int8)( nIndex ) ] ;
+ }
+ return nTmp;
+}
+
+// ---------------------------------------------------------------
+
+// call this function each time after the mapmode settings has been changed
+void CGM::ImplSetMapMode()
+{
+ int nAngReverse = 1;
+ mnVDCdx = pElement->aVDCExtent.Right - pElement->aVDCExtent.Left;
+
+ mnVDCXadd = -pElement->aVDCExtent.Left;
+ mnVDCXmul = 1;
+ if ( mnVDCdx < 0 )
+ {
+ nAngReverse ^= 1;
+ mnVDCdx = -mnVDCdx;
+ mnVDCXmul = -1;
+ }
+
+ mnVDCdy = pElement->aVDCExtent.Bottom - pElement->aVDCExtent.Top;
+ mnVDCYadd = -pElement->aVDCExtent.Top;
+ mnVDCYmul = 1;
+ if ( mnVDCdy < 0 )
+ {
+ nAngReverse ^= 1;
+ mnVDCdy = -mnVDCdy;
+ mnVDCYmul = -1;
+ }
+ if ( nAngReverse )
+ mbAngReverse = sal_True;
+ else
+ mbAngReverse = sal_False;
+
+ double fQuo1 = mnVDCdx / mnVDCdy;
+ double fQuo2 = mnOutdx / mnOutdy;
+ if ( fQuo2 < fQuo1 )
+ {
+ mnXFraction = mnOutdx / mnVDCdx;
+ mnYFraction = mnOutdy * ( fQuo2 / fQuo1 ) / mnVDCdy;
+ }
+ else
+ {
+ mnXFraction = mnOutdx * ( fQuo1 / fQuo2 ) / mnVDCdx;
+ mnYFraction = mnOutdy / mnVDCdy;
+ }
+}
+
+// ---------------------------------------------------------------
+
+void CGM::ImplMapDouble( double& nNumb )
+{
+ if ( pElement->eDeviceViewPortMap == DVPM_FORCED )
+ {
+ // point is 1mm * ScalingFactor
+ switch ( pElement->eDeviceViewPortMode )
+ {
+ case DVPM_FRACTION :
+ {
+ nNumb *= ( mnXFraction + mnYFraction ) / 2;
+ }
+ break;
+
+ case DVPM_METRIC :
+ {
+// nNumb *= ( 100 * pElement->nDeviceViewPortScale );
+ nNumb *= ( mnXFraction + mnYFraction ) / 2;
+ if ( pElement->nDeviceViewPortScale < 0 )
+ nNumb = -nNumb;
+ }
+ break;
+
+ case DVPM_DEVICE :
+ {
+
+ }
+ break;
+
+ default:
+
+ break;
+ }
+ }
+ else
+ {
+
+
+ }
+}
+
+// ---------------------------------------------------------------
+
+void CGM::ImplMapX( double& nNumb )
+{
+ if ( pElement->eDeviceViewPortMap == DVPM_FORCED )
+ {
+ // point is 1mm * ScalingFactor
+ switch ( pElement->eDeviceViewPortMode )
+ {
+ case DVPM_FRACTION :
+ {
+ nNumb *= mnXFraction;
+ }
+ break;
+
+ case DVPM_METRIC :
+ {
+// nNumb *= ( 100 * pElement->nDeviceViewPortScale );
+ nNumb *= mnXFraction;
+ if ( pElement->nDeviceViewPortScale < 0 )
+ nNumb = -nNumb;
+ }
+ break;
+
+ case DVPM_DEVICE :
+ {
+
+ }
+ break;
+
+ default:
+
+ break;
+ }
+ }
+ else
+ {
+
+
+ }
+}
+
+
+// ---------------------------------------------------------------
+
+void CGM::ImplMapY( double& nNumb )
+{
+ if ( pElement->eDeviceViewPortMap == DVPM_FORCED )
+ {
+ // point is 1mm * ScalingFactor
+ switch ( pElement->eDeviceViewPortMode )
+ {
+ case DVPM_FRACTION :
+ {
+ nNumb *= mnYFraction;
+ }
+ break;
+
+ case DVPM_METRIC :
+ {
+// nNumb *= ( 100 * pElement->nDeviceViewPortScale );
+ nNumb *= mnYFraction;
+ if ( pElement->nDeviceViewPortScale < 0 )
+ nNumb = -nNumb;
+ }
+ break;
+
+ case DVPM_DEVICE :
+ {
+
+ }
+ break;
+
+ default:
+
+ break;
+ }
+ }
+ else
+ {
+
+
+ }
+}
+
+
+// ---------------------------------------------------------------
+
+// convert a point to the current VC mapmode (1/100TH mm)
+void CGM::ImplMapPoint( FloatPoint& rFloatPoint )
+{
+ if ( pElement->eDeviceViewPortMap == DVPM_FORCED )
+ {
+ // point is 1mm * ScalingFactor
+ switch ( pElement->eDeviceViewPortMode )
+ {
+ case DVPM_FRACTION :
+ {
+ rFloatPoint.X *= mnXFraction;
+ rFloatPoint.Y *= mnYFraction;
+ }
+ break;
+
+ case DVPM_METRIC :
+ {
+ rFloatPoint.X *= mnXFraction;
+ rFloatPoint.Y *= mnYFraction;
+ if ( pElement->nDeviceViewPortScale < 0 )
+ {
+ rFloatPoint.X = -rFloatPoint.X;
+ rFloatPoint.Y = -rFloatPoint.Y;
+ }
+ }
+ break;
+
+ case DVPM_DEVICE :
+ {
+
+ }
+ break;
+
+ default:
+
+ break;
+ }
+ }
+ else
+ {
+
+
+ }
+}
+
+// ---------------------------------------------------------------
+
+void CGM::ImplDoClass()
+{
+#ifdef CGM_USER_BREAKPOINT
+#ifdef WNT
+ if ( mnActCount == CGM_BREAK_ACTION )
+ _asm int 0x3;
+#endif
+#endif
+ switch ( mnElementClass )
+ {
+ case 0 : ImplDoClass0(); break;
+ case 1 : ImplDoClass1(); break;
+ case 2 : ImplDoClass2(); break;
+ case 3 : ImplDoClass3(); break;
+ case 4 :
+ {
+ ImplDoClass4();
+ mnAct4PostReset = 0;
+ }
+ break;
+ case 5 : ImplDoClass5(); break;
+ case 6 : ImplDoClass6(); break;
+ case 7 : ImplDoClass7(); break;
+ case 8 : ImplDoClass8(); break;
+ case 9 : ImplDoClass9(); break;
+ case 15 :ImplDoClass15(); break;
+ default : ComOut( CGM_UNKNOWN_COMMAND, "" ); break;
+ }
+ mnActCount++;
+};
+
+// ---------------------------------------------------------------
+
+void CGM::ImplDefaultReplacement()
+{
+ sal_uInt8* pBuf = (sal_uInt8*)maDefRepList.First();
+ if ( pBuf )
+ {
+ sal_uInt32 nElementSize = (sal_uInt32)maDefRepSizeList.First();
+ sal_uInt32 nOldEscape = mnEscape;
+ sal_uInt32 nOldElementClass = mnElementClass;
+ sal_uInt32 nOldElementID = mnElementID;
+ sal_uInt32 nOldElementSize = mnElementSize;
+ sal_uInt8* pOldBuf = mpSource;
+ while( pBuf )
+ {
+ sal_uInt32 nCount = 0;
+ while ( mbStatus && ( nCount < nElementSize ) )
+ {
+ mpSource = pBuf + nCount;
+ mnParaSize = 0;
+ mnEscape = ImplGetUI16();
+ mnElementClass = mnEscape >> 12;
+ mnElementID = ( mnEscape & 0x0fe0 ) >> 5;
+ mnElementSize = mnEscape & 0x1f;
+ if ( mnElementSize == 31 )
+ {
+ mnElementSize = ImplGetUI16();
+ }
+ nCount += mnParaSize;
+ mnParaSize = 0;
+ mpSource = pBuf + nCount;
+ if ( (!( mnMode & CGM_NO_PAD_BYTE ) ) && ( mnElementSize & 1 ) )
+ nCount++;
+ nCount += mnElementSize;
+ if ( ( mnElementClass != 1 ) || ( mnElementID != 0xc ) ) // rekursion hier nicht moeglich!!
+ ImplDoClass();
+ }
+ nElementSize = (sal_uInt32)maDefRepSizeList.Next();
+ pBuf = (sal_uInt8*)maDefRepList.Next();
+ }
+ mnEscape = nOldEscape;
+ mnElementClass = nOldElementClass;
+ mnElementID = nOldElementID;
+ mnParaSize = mnElementSize = nOldElementSize;
+ mpSource = pOldBuf;
+ }
+}
+
+// ---------------------------------------------------------------
+
+sal_Bool CGM::Write( SvStream& rIStm )
+{
+ if ( !mpBuf )
+ mpBuf = new sal_uInt8[ 0xffff ];
+
+ mnParaSize = 0;
+ mpSource = mpBuf;
+ rIStm.Read( mpSource, 2 );
+ mnEscape = ImplGetUI16();
+ mnElementClass = mnEscape >> 12;
+ mnElementID = ( mnEscape & 0x0fe0 ) >> 5;
+ mnElementSize = mnEscape & 0x1f;
+
+ if ( mnElementSize == 31 )
+ {
+ rIStm.Read( mpSource + mnParaSize, 2 );
+ mnElementSize = ImplGetUI16();
+ }
+ mnParaSize = 0;
+ if ( mnElementSize )
+ rIStm.Read( mpSource + mnParaSize, mnElementSize );
+
+ if ( (!( mnMode & CGM_NO_PAD_BYTE ) ) && ( mnElementSize & 1 ) )
+ rIStm.SeekRel( 1 );
+ ImplDoClass();
+
+
+#ifdef CGM_USER_BREAKPOINT
+#ifdef WNT
+ if ( !mbStatus || mnParaSize && ( mnElementSize != mnParaSize ) )
+ _asm int 0x3;
+#endif
+#endif
+
+ return mbStatus;
+};
+
+// ---------------------------------------------------------------
+
+sal_Bool CGM::Write( sal_uInt8* pSource )
+{
+ if ( mnMode & CGM_IMPORT_IM )
+ {
+ mnElementID = pSource[ 0 ];
+ mnElementClass = pSource[ 1 ];
+ mnElementSize = *( (long*)pSource + 1 );
+ mpSource = pSource + 16;
+ mnParaSize = 0;
+ ImplDoClass();
+ }
+ else
+ {
+ mpSource = pSource;
+ mnEscape = ImplGetUI16();
+ mnElementClass = mnEscape >> 12;
+ mnElementID = ( mnEscape & 0x0fe0 ) >> 5;
+ mnElementSize = mnEscape & 0x1f;
+ if ( mnElementSize == 31 )
+ mnElementSize = ImplGetUI16();
+ mpSource += mnParaSize;
+ mnParaSize = 0;
+ ImplDoClass();
+ }
+
+#ifdef CGM_USER_BREAKPOINT
+#ifdef WNT
+ if ( !mbStatus || mnParaSize && ( mnElementSize != mnParaSize ) )
+ _asm int 0x3;
+#endif
+#endif
+
+ return mbStatus;
+};
+
+// ---------------------------------------------------------------
+
+SvStream& operator>>( SvStream& rOStm, CGM& rCGM )
+{
+
+ return rOStm;
+};
+
+// ---------------------------------------------------------------
+
+
+
+//================== GraphicImport - die exportierte Funktion ================
+
+extern "C" sal_uInt32 __LOADONCALLAPI ImportCGM( String& rFileName, uno::Reference< frame::XModel > & rXModel, sal_uInt32 nMode, void* pProgressBar )
+{
+ sal_Bool bProgressBar = sal_False;
+
+ CGM* pCGM; // retvalue == 0 -> ERROR
+ sal_uInt32 nStatus = 0; // == 0xffrrggbb -> background color in the lower 24 bits
+
+ if( rXModel.is() )
+ {
+ pCGM = new CGM( nMode, rXModel );
+ if ( pCGM && pCGM->IsValid() )
+ {
+ if ( nMode & CGM_IMPORT_CGM )
+ {
+ SvFileStream aIn( rFileName, STREAM_READ );
+ aIn.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+ aIn.Seek( STREAM_SEEK_TO_END );
+ sal_uInt32 nInSize = aIn.Tell();
+ aIn.Seek( 0 );
+
+#if defined CGM_EXPORT_IMPRESS && TF_ONE51
+ uno::Reference< task::XStatusIndicator > aXStatInd;
+ sal_uInt32 nNext = 0;
+ sal_uInt32 nAdd = nInSize / 20;
+ if ( pProgressBar )
+ aXStatInd = *(uno::Reference< task::XStatusIndicator > *)pProgressBar;
+ bProgressBar = aXStatInd.is();
+ if ( bProgressBar )
+ aXStatInd->start( rtl::OUString::createFromAscii("CGM Import"), nInSize );
+#endif
+
+ while ( pCGM->IsValid() && ( aIn.Tell() < nInSize ) && !pCGM->IsFinished() )
+ {
+
+#if defined CGM_EXPORT_IMPRESS && defined TF_ONE51
+
+
+ if ( bProgressBar )
+ {
+ sal_uInt32 nCurrentPos = aIn.Tell();
+ if ( nCurrentPos >= nNext )
+ {
+ aXStatInd->setValue( nCurrentPos );
+ nNext = nCurrentPos + nAdd;
+ }
+ }
+#endif
+
+ if ( pCGM->Write( aIn ) == sal_False )
+ break;
+ }
+ if ( pCGM->IsValid() )
+ {
+ nStatus = pCGM->GetBackGroundColor() | 0xff000000;
+ }
+
+#if defined CGM_EXPORT_IMPRESS && defined TF_ONE51
+ if ( bProgressBar )
+ aXStatInd->end();
+#endif
+
+ }
+ }
+ delete pCGM;
+ }
+ return nStatus;
+}
diff --git a/goodies/source/filter.vcl/icgm/cgm.hxx b/goodies/source/filter.vcl/icgm/cgm.hxx
new file mode 100644
index 000000000000..1a8f959010c0
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/cgm.hxx
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * $RCSfile: cgm.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CGM_HXX_
+#define CGM_HXX_
+
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+
+// ---------------------------------------------------------------
+#undef CGM_USER_BREAKPOINT
+
+#define CGM_IMPORT_CGM 0x00000001
+#define CGM_IMPORT_IM 0x00000002
+
+#define CGM_EXPORT_IMPRESS 0x00000100
+#define CGM_EXPORT_META 0x00000200
+//#define CGM_EXPORT_COMMENT 0x00000400
+
+#define CGM_NO_PAD_BYTE 0x00010000
+#define CGM_BIG_ENDIAN 0x00020000
+#define CGM_LITTLE_ENDIAN 0x00040000
+
+// ---------------------------------------------------------------
+
+#include <tools/solar.h>
+#include <rtl/ustring>
+#include <tools/list.hxx>
+#include "cgmtypes.hxx"
+
+// ---------------------------------------------------------------
+
+class List;
+class Bundle;
+class Graphic;
+class SvStream;
+class CGMChart;
+class CGMBitmap;
+class CGMOutAct;
+class CGMElements;
+class BitmapColor;
+class GDIMetaFile;
+class VirtualDevice;
+class CGMBitmapDescriptor;
+
+class CGM
+{
+ friend class CGMChart;
+ friend class CGMBitmap;
+ friend class CGMElements;
+ friend class CGMOutAct;
+ friend class CGMMetaOutAct;
+ friend class CGMImpressOutAct;
+
+ double mnOutdx; // Ausgabe Groesse in 1/100TH mm
+ double mnOutdy; // auf das gemappt wird
+ double mnVDCXadd;
+ double mnVDCYadd;
+ double mnVDCXmul;
+ double mnVDCYmul;
+ double mnVDCdx;
+ double mnVDCdy;
+ double mnXFraction;
+ double mnYFraction;
+ sal_Bool mbAngReverse; // AngularDirection
+
+ Graphic* mpGraphic; // ifdef CGM_EXPORT_META
+ SvStream* mpCommentOut; // ifdef CGM_EXPORT_COMMENT
+
+ sal_Bool mbStatus;
+ sal_Bool mbMetaFile;
+ sal_Bool mbIsFinished;
+ sal_Bool mbPicture;
+ sal_Bool mbPictureBody;
+ sal_Bool mbFigure;
+ sal_Bool mbFirstOutPut;
+ sal_uInt32 mnAct4PostReset;
+ CGMBitmap* mpBitmapInUse;
+ CGMChart* mpChart; // if sal_True->"SHWSLIDEREC"
+ // otherwise "BEGINPIC" commands
+ // controlls page inserting
+ CGMElements* pElement;
+ CGMElements* pCopyOfE;
+ CGMOutAct* mpOutAct;
+ List maDefRepList;
+ List maDefRepSizeList;
+
+ sal_uInt8* mpSource; // source buffer that is not increased
+ // ( instead use mnParaCount to index )
+ sal_uInt32 mnParaSize; // actual parameter size which has been done so far
+ sal_uInt32 mnActCount; // increased by each action
+ sal_uInt8* mpBuf; // source stream operation -> then this is allocated for
+ // the temp input buffer
+
+ sal_uInt32 mnMode; // source description
+ sal_uInt32 mnEscape; //
+ sal_uInt32 mnElementClass; //
+ sal_uInt32 mnElementID; //
+ sal_uInt32 mnElementSize; // full parameter size for the latest action
+
+ void ImplCGMInit();
+ sal_uInt32 ImplGetUI16( sal_uInt32 nAlign = 0 );
+ sal_uInt8 ImplGetByte( sal_uInt32 nSource, sal_uInt32 nPrecision );
+ long ImplGetI( sal_uInt32 nPrecision );
+ sal_uInt32 ImplGetUI( sal_uInt32 nPrecision );
+ void ImplGetSwitch4( sal_uInt8* pSource, sal_uInt8* pDest );
+ void ImplGetSwitch8( sal_uInt8* pSource, sal_uInt8* pDest );
+ double ImplGetFloat( RealPrecision, sal_uInt32 nRealSize );
+ sal_uInt32 ImplGetBitmapColor( sal_Bool bDirectColor = sal_False );
+ void ImplSetMapMode();
+ void ImplMapDouble( double& );
+ void ImplMapX( double& );
+ void ImplMapY( double& );
+ void ImplMapPoint( FloatPoint& );
+ inline double ImplGetIY();
+ inline double ImplGetFY();
+ inline double ImplGetIX();
+ inline double ImplGetFX();
+ sal_uInt32 ImplGetPointSize();
+ void ImplGetPoint( FloatPoint& rFloatPoint, sal_Bool bMap = sal_False );
+ void ImplGetRectangle( FloatRect&, sal_Bool bMap = sal_False );
+ void ImplGetRectangleNS( FloatRect& );
+ void ImplGetVector( double* );
+ double ImplGetOrientation( FloatPoint& rCenter, FloatPoint& rPoint );
+ void ImplSwitchStartEndAngle( double& rStartAngle, double& rEndAngle );
+ sal_Bool ImplGetEllipse( FloatPoint& rCenter, FloatPoint& rRadius, double& rOrientation );
+
+ void ImplDefaultReplacement();
+ void ImplDoClass();
+ void ImplDoClass0();
+ void ImplDoClass1();
+ void ImplDoClass2();
+ void ImplDoClass3();
+ void ImplDoClass4();
+ void ImplDoClass5();
+ void ImplDoClass6();
+ void ImplDoClass7();
+ void ImplDoClass8();
+ void ImplDoClass9();
+ void ImplDoClass15();
+ void ImplDoClass16();
+
+ public:
+
+ CGM( sal_uInt32 nMode );
+ ~CGM();
+
+#ifdef CGM_EXPORT_IMPRESS
+ CGM( sal_uInt32 nMode, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & rModel );
+#endif
+#ifdef CGM_EXPORT_META
+ VirtualDevice* mpVirDev;
+ GDIMetaFile* mpGDIMetaFile;
+ CGM( sal_uInt32 nMode, Graphic& rGraphic );
+#endif
+ void ImplComment( sal_uInt32, char* );
+ sal_uInt32 GetBackGroundColor();
+ sal_Bool IsValid() { return (const) mbStatus; };
+ sal_Bool IsFinished() { return (const) mbIsFinished; };
+ sal_Bool Write( sal_uInt8* pSource );
+ sal_Bool Write( SvStream& rIStm );
+
+ friend SvStream& operator>>( SvStream& rOStm, CGM& rCGM );
+
+};
+#endif
+
diff --git a/goodies/source/filter.vcl/icgm/cgmres.hrc b/goodies/source/filter.vcl/icgm/cgmres.hrc
new file mode 100644
index 000000000000..8206a4055024
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/cgmres.hrc
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * $RCSfile: cgmres.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#define MB_CGM 1
+#define MID_TEST 1
diff --git a/goodies/source/filter.vcl/icgm/cgmtypes.hxx b/goodies/source/filter.vcl/icgm/cgmtypes.hxx
new file mode 100644
index 000000000000..a959164ad9b6
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/cgmtypes.hxx
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * $RCSfile: cgmtypes.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CGM_TYPES_HXX_
+#define CGM_TYPES_HXX_
+
+struct FloatPoint
+{
+ double X;
+ double Y;
+ FloatPoint(){};
+ FloatPoint( const double& rX, const double& rY ) { X = rX, Y = rY; };
+};
+
+struct FloatRect
+{
+ double Left;
+ double Top;
+ double Right;
+ double Bottom;
+ FloatRect(){};
+ FloatRect( const FloatPoint& rTopLeft, const FloatPoint& rBottomRight )
+ {
+ Left = rTopLeft.X;
+ Top = rTopLeft.Y;
+ Right = rBottomRight.X;
+ Bottom = rBottomRight.Y;
+ }
+ void Justify()
+ {
+ double fTemp;
+ if ( Left > Right )
+ {
+ fTemp = Left;
+ Left = Right;
+ Right = fTemp;
+ }
+ if ( Top > Bottom )
+ {
+ fTemp = Top;
+ Top = Bottom;
+ Bottom = fTemp;
+ }
+ }
+};
+
+struct HatchEntry
+{
+ int HatchStyle;
+ long HatchDistance;
+ long HatchAngle;
+};
+
+#define ASF_LINETYPE 0x00000001UL
+#define ASF_LINEWIDTH 0x00000002UL
+#define ASF_LINECOLOR 0x00000004UL
+#define ASF_MARKERTYPE 0x00000008UL
+#define ASF_MARKERSIZE 0x00000010UL
+#define ASF_MARKERCOLOR 0x00000020UL // NS
+#define ASF_FILLINTERIORSTYLE 0x00000040UL
+#define ASF_HATCHINDEX 0x00000080UL
+#define ASF_PATTERNINDEX 0x00000100UL
+#define ASF_BITMAPINDEX 0x00000200UL // NS
+#define ASF_FILLCOLOR 0x00000400UL
+#define ASF_EDGETYPE 0x00000800UL
+#define ASF_EDGEWIDTH 0x00001000UL
+#define ASF_EDGECOLOR 0x00002000UL
+#define ASF_TEXTFONTINDEX 0x00004000UL
+#define ASF_TEXTPRECISION 0x00008000UL
+#define ASF_CHARACTEREXPANSION 0x00010000UL
+#define ASF_CHARACTERSPACING 0x00020000UL
+#define ASF_TEXTCOLOR 0x00040000UL
+
+#define ACT4_GRADIENT_ACTION 0x00000001UL
+
+enum RealPrecision { RP_FLOAT = 0, RP_FIXED = 1 };
+
+enum ScalingMode { SM_ABSTRACT = 0, SM_METRIC = 1 };
+
+enum VDCType { VDC_INTEGER = 0, VDC_REAL = 1 };
+enum DeviceViewPortMode { DVPM_FRACTION = 0, DVPM_METRIC = 1, DVPM_DEVICE = 2 };
+enum DeviceViewPortMap { DVPM_NOT_FORCED = 0, DVPM_FORCED = 1 };
+enum DeviceViewPortMapH { DVPMH_LEFT = 0, DVPMH_CENTER = 1, CVPMH_RIGHT = 2 };
+enum DeviceViewPortMapV { DVPMV_BOTTOM = 0, DVPMV_CENTER = 1, DVPMV_TOP = 2 };
+
+enum ClipIndicator { CI_OFF = 0, CI_ON = 1 };
+
+enum ColorSelectionMode { CSM_INDEXED = 0, CSM_DIRECT = 1 };
+enum ColorModel { CM_RGB = 0, CM_CYMK = 1 };
+
+enum CharacterCodingA { CCA_BASIC_7 = 0, CCA_BASIC_8 = 1, CCA_EXT_7 = 2, CCA_EXT_8 = 3 };
+enum CharSetType { CST_CBYTE_94 = 0, CST_CBYTE_96 = 1, CST_MULT94 = 2, CST_MULT96 = 3, CST_CCOMPLETE = 4 };
+enum TextPrecision { TPR_STRING = 0, TPR_CHARACTER = 1, TPR_STROKE = 2, TPR_UNDEFINED = 0xffff };
+enum TextPath { TPR_RIGHT = 0, TPR_LEFT = 1, TPR_UP = 2, TPR_DOWN = 3 };
+enum TextAlignmentH { TAH_NORMAL = 0, TAH_LEFT = 1, TAH_CENTER = 2, TAH_RIGHT = 3, TAH_CONT = 4 };
+enum TextAlignmentV { TAV_NORMAL = 0, TAV_TOP = 1, TAV_CAP = 2, TAV_HALF = 3, TAV_BASE = 4, TAV_BOTTOM = 5, TAV_CONT = 6 };
+enum UnderlineMode { UM_OFF = 0, UM_LOW = 1, UM_HIGH = 2, UM_STRIKEOUT = 4, UM_OVERSCORE = 8 };
+enum FinalFlag { FF_NOT_FINAL = 0, FF_FINAL = 1 };
+
+enum LineType { LT_SOLID = 1, LT_DASH = 2, LT_DOT = 3, LT_DASHDOT = 4, LT_DASHDOTDOT = 5, // Standart
+ LT_NONE = -4, LT_DOTDOTSPACE = -3, LT_LONGDASH = -2, LT_DASHDASHDOT = -1 }; // GDSF Styles
+enum SpecMode { SM_ABSOLUTE = 0, SM_SCALED = 1 };
+enum LineCapType { LCT_BUTT = 0, LCT_ROUND = 1, LCT_SQUARE = 2, LCT_TRIANGLE = 3, LCT_ARROW = 4, LCT_NONE = -1 };
+enum LineJoinType { LJT_MITER = 0, LJT_ROUND = 1, LJT_BEVEL = 2, LJT_NONE = -1 };
+
+
+enum EdgeType { ET_SOLID = 1, ET_DASH = 2, ET_DOT = 3, ET_DASHDOT = 4, ET_DASHDOTDOT = 5, // Standart
+ ET_NONE = -4, ET_DOTDOTSPACE = -3, ET_LONGDASH = -2, ET_DASHDASHDOT = -1 }; // GDSF Styles
+enum EdgeVisibility { EV_OFF = 0, EV_ON = 1 };
+
+enum MarkerType { MT_POINT = 1, MT_PLUS = 2, MT_STAR = 3, MT_CIRCLE = 4, MT_CROSS = 5 };
+
+enum Transparency { T_OFF = 0, T_ON = 1 };
+
+enum FillInteriorStyle { FIS_HOLLOW = 0, FIS_SOLID = 1, FIS_PATTERN = 2, FIS_HATCH = 3, FIS_EMPTY = 4, FIS_GEOPATTERN = 5,
+ FIS_INTERPOLATED = 6, FIS_GRADIENT = 7 };
+
+
+
+
+#endif
diff --git a/goodies/source/filter.vcl/icgm/chart.cxx b/goodies/source/filter.vcl/icgm/chart.cxx
new file mode 100644
index 000000000000..5c5265cc43d2
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/chart.cxx
@@ -0,0 +1,148 @@
+/*************************************************************************
+ *
+ * $RCSfile: chart.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <main.hxx>
+#include <chart.hxx>
+
+// ---------------------------------------------------------------
+
+CGMChart::CGMChart( CGM& rCGM ) :
+ mpCGM ( &rCGM )
+{
+ for ( int i = 0; i < 7; i++ )
+ {
+ mDataNode[ i ].nBoxX1 = mDataNode[ i ].nBoxY1 = 0 ;
+ mDataNode[ i ].nBoxX2 = mDataNode[ i ].nBoxY2 = 0 ;
+
+ mDataNode[ i ].nZoneEnum = i;
+ }
+};
+
+// ---------------------------------------------------------------
+
+CGMChart::~CGMChart()
+{
+ // delete the whole textentry structure
+
+ TextEntry* pTextEntry;
+ while( ( pTextEntry = (TextEntry*)maTextEntryList.First() ) != NULL )
+ {
+ DeleteTextEntry( pTextEntry );
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGMChart::DeleteTextEntry( TextEntry* pTextEntry )
+{
+ if ( pTextEntry )
+ {
+ delete pTextEntry->pText;
+ for ( TextAttribute* pTAttr = pTextEntry->pAttribute; pTAttr != NULL ; )
+ {
+ TextAttribute* pTempTAttr = pTAttr;
+ pTAttr = pTAttr->pNextAttribute;
+ delete pTempTAttr;
+ }
+ delete pTextEntry;
+ maTextEntryList.Remove( pTextEntry );
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGMChart::InsertTextEntry( TextEntry* pTextEntry )
+{
+ maTextEntryList.Insert( pTextEntry );
+};
+
+// ---------------------------------------------------------------
+
+TextEntry* CGMChart::GetTextEntry( sal_uInt32 nLine, sal_uInt32 nColumn )
+{
+ TextEntry* pTextEntry = (TextEntry*)maTextEntryList.First();
+ while( pTextEntry && ( ( pTextEntry->nRowOrLineNum != nLine ) && ( pTextEntry->nColumnNum == nColumn ) ) )
+ {
+ pTextEntry = (TextEntry*)maTextEntryList.Next();
+ }
+ return (pTextEntry);
+};
+
+// ---------------------------------------------------------------
+
+TextEntry* CGMChart::GetFirstTextEntry()
+{
+ return (TextEntry*)maTextEntryList.First();
+};
+
+// ---------------------------------------------------------------
+void CGMChart::ResetAnnotation()
+{
+ mDataNode[ 0 ].nZoneEnum = 0;
+}
+
+// ---------------------------------------------------------------
+
+sal_Bool CGMChart::IsAnnotation()
+{
+ return ( mDataNode[ 0 ].nZoneEnum == 0 );
+};
+
diff --git a/goodies/source/filter.vcl/icgm/chart.hxx b/goodies/source/filter.vcl/icgm/chart.hxx
new file mode 100644
index 000000000000..2b78ab2ffc41
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/chart.hxx
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * $RCSfile: chart.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CGM_CHART_HXX_
+#define CGM_CHART_HXX_
+
+#include <tools/list.hxx>
+
+/* FILE TYPE CONSTANTS: */
+#define NOCHART 0 /* Undefined chart. */
+#define XYCHART 1 /* Standard XY chart. */
+#define PIECHART 21 /* Standard pie chart file. */
+#define ORGCHART 26 /* Standard org chart file. */
+#define TTLCHART 31 /* Title chart file. */
+#define BULCHART 32 /* Bullet chart file. */
+#define TABCHART 33 /* Table chart file. */
+#define DRWCHART 41 /* Chart with drawings only.*/
+#define MLTCHART 42 /* Multiple chart file. */
+#define LASTCHART 45 /* The largest chart type. */
+#define SHWFILE 46 /* Slide show file. */
+#define SYMFILE 47 /* Symbol file. */
+/* the following were added although SPC doesn't have a #define */
+/* for them... */
+#define AUTOTTLCHT 95 /* Autobuild TTL CHT */
+#define AUTOBULCHT 96 /* Autobuild BUL CHT */
+#define AUTOTABCHT 97 /* Autobuild TAB CHT */
+
+/* FNC 10/11/93: for the chart stream, ALLCHART was added. */
+/* It is used specifically by PPT in its Template to let */
+/* us know that the template applies to all charts, not to */
+/* one specific chart type. */
+#define ALLCHART 127 /* Applies to all chart types */
+#define ALLCHART_TPL 255 /* Applies to all chart types */
+
+#define IOC_CHTTITLE 1 /* Title for any chart. */
+#define IOC_CHTFOOTNOTE 2 /* ::com::sun::star::text::Footnote for any chart. */
+#define IOC_XYAXIS 3 /* Axis title for XY charts. */
+#define IOC_XYSERIESLEGEND 4 /* Series legend titles for XY charts. */
+#define IOC_PIETITLE 5 /* Title for pie charts. */
+#define IOC_TABLEBODY 6 /* Table chart text element. */
+#define IOC_TITLEBODY 7 /* Title chart text element. */
+#define IOC_BULLETBODY 8 /* Bullet chart text element. */
+#define IOC_XYLEGENDTITLE 9 /* Legend title for XY charts. */
+#define IOC_PIELEGENDTITLE 10 /* Legend title for pie charts. */
+#define IOC_TABLEGENDTITLE 11 /* Legend title for table charts. */
+
+typedef struct TextAttribute
+{
+ sal_uInt16 nTextAttribCount;
+ sal_Int8 nTextColorIndex;
+ sal_Int8 nTextColorRed;
+ sal_Int8 nTextColorGreen;
+ sal_Int8 nTextColorBlue;
+ sal_Int8 nShadowColorIndex;
+ sal_Int8 nShadowColorRed;
+ sal_Int8 nShadowColorGreen;
+ sal_Int8 nShadowColorBlue;
+ float nTextAttribSize;
+ sal_uInt16 nTextAttribBits;
+ sal_Int8 nTextFontType; // font identifiers
+ sal_Int8 nTextCharPage;
+ sal_uInt16 nTextFontFamily;
+ sal_Int8 nTextFontMemberID;
+ sal_Int8 nTextFontVendorID;
+ TextAttribute* pNextAttribute; // zero or pointer to next TextAttribute
+} TextAttribute;
+
+typedef struct TextEntry
+{
+ sal_uInt16 nTypeOfText;
+ sal_uInt16 nRowOrLineNum;
+ sal_uInt16 nColumnNum;
+ sal_uInt16 nZoneSize; // textzone attributes
+ sal_uInt16 nLineType;
+ sal_uInt16 nAttributes;
+ char* pText; // null terminated text
+ TextAttribute* pAttribute;
+} TextEntry;
+
+typedef struct ZoneOption
+{
+ char nOverTitle;
+ char nOverBody;
+ char nOverFoot;
+ char nFStyle_Title;
+ char nFStyle_Body;
+ char nFStyle_Foot;
+ char nFOutc_Title;
+ char nFOutc_Body;
+ char nFOutc_Foot;
+ char nFFillc_Title;
+ char nFFillc_Body;
+ char nFFillc_Foot;
+} ZoneOption;
+
+typedef struct BulletOption
+{
+ char nBType;
+ char nBSize;
+ char nBColor;
+ sal_Int16 nBStart;
+ double nTMargin;
+ double nBSpace;
+ char nCPlace;
+} BulletOption;
+
+typedef struct BulDef
+{
+ char btype;
+ char bsize;
+ char bcolor;
+ char bnumber;
+} BulDef;
+
+typedef struct BulletLines
+{
+ BulDef nBulDef[ 48 ];
+} BulletLines;
+
+typedef struct IntSettings
+{
+ sal_uInt16 nCountry;
+ sal_uInt16 nDateFormat;
+ sal_uInt16 nDateSep;
+ sal_uInt16 nTimeFormat;
+ sal_uInt16 nTimeSep;
+ sal_uInt16 nNumSeps;
+ sal_uInt16 nCurrencyFormat;
+ char nCurrencySymbol[ 5 ];
+} IntSettings;
+
+typedef struct PageOrientDim
+{
+ char nOrientation;
+ char nDimension;
+ float nPageX;
+ float nPageY;
+} PageOrientDim;
+
+typedef struct DataNode
+{
+ sal_Int16 nBoxX1;
+ sal_Int16 nBoxY1;
+ sal_Int16 nBoxX2;
+ sal_Int16 nBoxY2;
+ sal_Int8 nZoneEnum;
+} DataNode;
+
+typedef struct ChartZone
+{
+ sal_Int16 nMinX;
+ sal_Int16 nMinY;
+ sal_Int16 nMaxX;
+ sal_Int16 nMaxY;
+ char nUserDef;
+ char nPad1;
+} ChartZone;
+
+class CGM;
+class CGMImpressOutAct;
+class CGMChart
+{
+ friend class CGM;
+ friend class CGMImpressOutAct;
+
+ protected:
+ CGM* mpCGM;
+ sal_Int8 mnCurrentFileType;
+ List maTextEntryList;
+ DataNode mDataNode[ 7 ];
+ ChartZone mChartZone;
+ PageOrientDim mPageOrientDim;
+ BulletOption mBulletOption;
+ BulletLines mBulletLines;
+ ZoneOption mZoneOption;
+ IntSettings mIntSettings;
+
+ public:
+ CGMChart( CGM& rCGM );
+ ~CGMChart();
+
+ void DeleteTextEntry( TextEntry* );
+ void InsertTextEntry( TextEntry* );
+ TextEntry* GetTextEntry( sal_uInt32 nLine, sal_uInt32 nColumn );
+ TextEntry* GetFirstTextEntry();
+
+ void ResetAnnotation();
+ sal_Bool IsAnnotation();
+};
+
+#endif
+
diff --git a/goodies/source/filter.vcl/icgm/class0.cxx b/goodies/source/filter.vcl/icgm/class0.cxx
new file mode 100644
index 000000000000..803d91d6f639
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/class0.cxx
@@ -0,0 +1,169 @@
+/*************************************************************************
+ *
+ * $RCSfile: class0.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <main.hxx>
+#include <outact.hxx>
+
+// ---------------------------------------------------------------
+
+void CGM::ImplDoClass0()
+{
+ switch ( mnElementID )
+ {
+ case 0x01 : ComOut( CGM_LEVEL1, "Begin Metafile" )
+ {
+ ImplSetMapMode();
+ mbMetaFile = sal_True;
+ }
+ break;
+ case 0x02 : ComOut( CGM_LEVEL1, "End MetaFile" )
+ {
+ if ( mpBitmapInUse ) // vorhandene grafik verarbeiten,
+ {
+ CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
+ // irgendetwas mit der Bitmap anfangen
+ mpOutAct->DrawBitmap( pBmpDesc );
+ delete mpBitmapInUse;
+ mpBitmapInUse = NULL;
+ }
+ mbIsFinished = sal_True;
+ mbPictureBody = sal_False;
+ mbMetaFile = sal_False;
+ }
+ break;
+ case 0x03 : ComOut( CGM_LEVEL1, "Begin Picture" )
+ {
+ ImplDefaultReplacement();
+ ImplSetMapMode();
+ if ( mbPicture )
+ mbStatus = sal_False;
+ else
+ {
+ *pCopyOfE = *pElement;
+ mbPicture = mbFirstOutPut = sal_True;
+ mbFigure = sal_False;
+ mnAct4PostReset = 0;
+ if ( mpChart == NULL ) // normal CGM Files determines "BeginPic"
+ mpOutAct->InsertPage(); // as the next slide
+ }
+ }
+ break;
+ case 0x04 : ComOut( CGM_LEVEL1, "Begin Picture Body" )
+ mbPictureBody = sal_True;
+ break;
+ case 0x05 : ComOut( CGM_LEVEL1, " End Picture" )
+ {
+ if ( mbPicture )
+ {
+ if ( mpBitmapInUse ) // vorhandene grafik verarbeiten,
+ {
+ CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
+ // irgendetwas mit der Bitmap anfangen
+ mpOutAct->DrawBitmap( pBmpDesc );
+ delete mpBitmapInUse;
+ mpBitmapInUse = NULL;
+ }
+ mpOutAct->EndFigure(); // eventuelle figuren schliessen
+ mpOutAct->EndGrouping(); // eventuelle gruppierungen noch abschliessen
+ *pElement = *pCopyOfE;
+ mbFigure = mbFirstOutPut = mbPicture = mbPictureBody = sal_False;
+ }
+ else
+ mbStatus = sal_False;
+ }
+ break;
+ case 0x06 : ComOut( CGM_LEVEL2, "Begin Segment" )
+ pElement->bSegmentCount = sal_True;
+ break;
+ case 0x07 : ComOut( CGM_LEVEL2, "End Segment" )
+ pElement->bSegmentCount = sal_True;
+ break;
+ case 0x08 : ComOut( CGM_LEVEL2, "Begin Figure" )
+ mbFigure = sal_True;
+ mpOutAct->BeginFigure();
+ break;
+ case 0x09 : ComOut( CGM_LEVEL2, "End Figure" )
+ mpOutAct->EndFigure();
+ mbFigure = sal_False;
+ break;
+ case 0x0d : ComOut( CGM_LEVEL3, "Begin Protection Region" ) break;
+ case 0x0e : ComOut( CGM_LEVEL3, "End Protection Region" ) break;
+ case 0x0f : ComOut( CGM_LEVEL3, "Begin Compound Line" ) break;
+ case 0x10 : ComOut( CGM_LEVEL3, "End Compound Line" ) break;
+ case 0x11 : ComOut( CGM_LEVEL3, "Begin Compound Text Path" ) break;
+ case 0x12 : ComOut( CGM_LEVEL3, "End Compound Text Path" ) break;
+ case 0x13 : ComOut( CGM_LEVEL3, "Begin Tile Array" ) break; // NS
+ case 0x14 : ComOut( CGM_LEVEL3, "End Tile Array" ) break; // NS
+ case 0xff : ComOut( CGM_GDSF_ONLY, "Filter Setup" ) break;
+ case 0xfe : ComOut( CGM_GDSF_ONLY, "Begin Block Text Region" ) break;
+ case 0xfd : ComOut( CGM_GDSF_ONLY, "End Block Text Region" ) break;
+ case 0xfc : ComOut( CGM_GDSF_ONLY, "Begin Group" )
+ mpOutAct->BeginGroup();
+ break;
+ case 0xfb : ComOut( CGM_GDSF_ONLY, "End Group" )
+ mpOutAct->EndGroup();
+ break;
+ case 0xfa : ComOut( CGM_GDSF_ONLY, "Begin Patch" ) break;
+ case 0xf9 : ComOut( CGM_GDSF_ONLY, "Begin Patch" ) break;
+ default: ComOut( CGM_UNKNOWN_COMMAND, "" ) break;
+ }
+};
+
+
diff --git a/goodies/source/filter.vcl/icgm/class1.cxx b/goodies/source/filter.vcl/icgm/class1.cxx
new file mode 100644
index 000000000000..63f3d694dd94
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/class1.cxx
@@ -0,0 +1,309 @@
+/*************************************************************************
+ *
+ * $RCSfile: class1.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <main.hxx>
+
+// ---------------------------------------------------------------
+
+void CGM::ImplDoClass1()
+{
+ long nInteger, nI0, nI1;
+ sal_uInt32 nUInteger;
+
+ switch ( mnElementID )
+ {
+ case 0x01 : ComOut( CGM_LEVEL1, "Metafile Version" )
+ pElement->nMetaFileVersion = ImplGetI( pElement->nIntegerPrecision );
+ break;
+ case 0x02 : ComOut( CGM_LEVEL1, "Metafile Description" ) break;
+ case 0x03 : ComOut( CGM_LEVEL1, "VDC Type" )
+ {
+ nUInteger = ImplGetUI16();
+ switch( nUInteger )
+ {
+ case 0 : pElement->eVDCType = VDC_INTEGER; break;
+ case 1 : pElement->eVDCType = VDC_REAL; break;
+ default: mbStatus = sal_False; break;
+ }
+ }
+ break;
+ case 0x04 : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Integer Precision" )
+ {
+ if ( mnMode & CGM_IMPORT_IM )
+ {
+ nInteger = ImplGetI( 2 ); // MEGA PATCH
+ pElement->nIntegerPrecision = 4;
+ }
+ else
+ {
+ nInteger = ImplGetI( pElement->nIntegerPrecision );
+ switch ( nInteger )
+ {
+ case 32 :
+ case 24 :
+ case 16 :
+ case 8 : pElement->nIntegerPrecision = nInteger >> 3; break;
+ default : mbStatus = sal_False; break;
+ }
+ }
+ }
+ break;
+ case 0x05 : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Real Precision" )
+ {
+ nUInteger = ImplGetUI16( 4 );
+ nI0 = ImplGetI( pElement->nIntegerPrecision ); // exponent
+ nI1 = ImplGetI( pElement->nIntegerPrecision ); // mantisse
+ switch( nUInteger )
+ {
+ case 0 :
+ pElement->eRealPrecision = RP_FLOAT;
+ switch ( nI0 )
+ {
+ case 9 :
+ if ( nI1 != 23 )
+ mbStatus = sal_False;
+ pElement->nRealSize = 4;
+ break;
+ case 12 :
+ if ( nI1 != 52 )
+ mbStatus =sal_False;
+ pElement->nRealSize = 8;
+ break;
+ default:
+ mbStatus = sal_False;
+ break;
+ }
+ break;
+ case 1 :
+ pElement->eRealPrecision = RP_FIXED;
+ if ( nI0 != nI1 )
+ mbStatus = sal_False;
+ if ( nI0 = 16 )
+ pElement->nRealSize = 4;
+ else if ( nI0 = 32 )
+ pElement->nRealSize = 8;
+ else
+ mbStatus = sal_False;
+ break;
+ default :
+ mbStatus = sal_False; break;
+ }
+ }
+ break;
+ case 0x06 : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Index Precision" )
+ {
+ if ( mnMode & CGM_IMPORT_IM )
+ {
+ nInteger = ImplGetI( 2 ); // MEGA PATCH
+ pElement->nIndexPrecision = 4;
+ }
+ else
+ {
+ nInteger = ImplGetI( pElement->nIntegerPrecision );
+ switch ( nInteger )
+ {
+ case 32 :
+ case 24 :
+ case 16 :
+ case 8 : pElement->nIndexPrecision = nInteger >> 3; break;
+ default : mbStatus = sal_False; break;
+ }
+ }
+ }
+ break;
+ case 0x07 : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Color Precision" )
+ {
+ if ( mnMode & CGM_IMPORT_IM )
+ {
+ nInteger = ImplGetI( 2 ); // MEGA PATCH
+ pElement->nColorPrecision = 1;
+ }
+ else
+ {
+ nInteger = ImplGetI( pElement->nIntegerPrecision );
+ switch ( nInteger )
+ {
+ case 32 :
+ case 24 :
+ case 16 :
+ case 8 : pElement->nColorPrecision = nInteger >> 3; break;
+ default : mbStatus = sal_False; break;
+ }
+ }
+ }
+ break;
+ case 0x08 : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Color Index Precision" )
+ {
+ if ( mnMode & CGM_IMPORT_IM )
+ {
+ nInteger = ImplGetI( 2 ); // MEGA PATCH
+ pElement->nColorIndexPrecision = 4;
+ }
+ else
+ {
+ nInteger = ImplGetI( pElement->nIntegerPrecision );
+ switch ( nInteger )
+ {
+ case 32 :
+ case 24 :
+ case 16 :
+ case 8 : pElement->nColorIndexPrecision = nInteger >> 3; break;
+ default : mbStatus = sal_False; break;
+ }
+ }
+ }
+ break;
+ case 0x09 : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Maximum Colour Index" )
+ {
+ pElement->nColorMaximumIndex = ImplGetUI( pElement->nColorIndexPrecision );
+ if ( ( pElement->nColorMaximumIndex > 256 /*255*/ ) || ( pElement->nColorMaximumIndex == 0 ) )
+ mbStatus = sal_False;
+ }
+ break;
+ case 0x0a : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Color Value Extent" )
+ {
+ if ( pElement->eColorModel == CM_RGB )
+ nI1 = 6;
+ else
+ {
+ nI1 = 8;
+ mbStatus = sal_False; // CMYK is not supported
+ }
+ for ( nI0 = 0; nI0 < nI1; nI0++ )
+ {
+ pElement->nColorValueExtent[ nI0 ] = (sal_Int8)ImplGetUI( pElement->nColorPrecision );
+ }
+ }
+ break;
+ case 0x0b : ComOut( CGM_LEVEL1, "MetaFile Element List" ) break;
+ case 0x0c : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "MetaFile Default Replacement" )
+ {
+ if ( mnElementSize > 1 )
+ {
+ sal_Int8* pBuf = new sal_Int8[ mnElementSize ];
+ if ( pBuf )
+ {
+ memcpy( pBuf, mpSource, mnElementSize );
+ maDefRepList.Insert( pBuf, LIST_APPEND );
+ maDefRepSizeList.Insert( (void*)mnElementSize, LIST_APPEND );
+ }
+ }
+ mnParaSize = mnElementSize;
+ }
+ break;
+ case 0x0d : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Font List" )
+ {
+ while ( mnParaSize < mnElementSize )
+ {
+ sal_uInt32 nSize;
+ if ( mnMode & CGM_IMPORT_IM )
+ {
+ nSize = ImplGetUI( 4 );
+ }
+ else
+ nSize = ImplGetUI( 1 );
+ pElement->aFontList.InsertName( mpSource + mnParaSize, nSize );
+ mnParaSize += nSize;
+ }
+ }
+ break;
+ case 0x0e : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Character Set List" )
+ {
+ while ( mnParaSize < mnElementSize )
+ {
+ sal_uInt32 nCharSetType;
+ sal_uInt32 nSize;
+ if ( mnMode & CGM_IMPORT_IM )
+ {
+ ALIGN2( mnParaSize );
+ nCharSetType = ImplGetUI16();
+ ALIGN4( mnParaSize );
+ nSize = ImplGetUI( 4 );
+ }
+ else
+ {
+ nCharSetType = ImplGetUI16();
+ nSize = ImplGetUI( 1 );
+ }
+ pElement->aFontList.InsertCharSet( (CharSetType)nCharSetType, mpSource + mnParaSize, nSize );
+ mnParaSize += nSize;
+ }
+ }
+ break;
+ case 0x0f : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Character Coding Announcer" )
+ pElement->eCharacterCodingA = (CharacterCodingA)ImplGetUI16();
+ break;
+ case 0x10 : ComOut( CGM_LEVEL2, "Name Precision" ) break; // NS
+ case 0x11 : ComOut( CGM_LEVEL2, "Maximum VDC Extent" ) break; // NS
+ case 0x12 : ComOut( CGM_LEVEL2, "Segment Priority Extent" ) break; // NS
+ case 0x13 : ComOut( CGM_LEVEL3, "Color Model" ) break; // NS
+ case 0x14 : ComOut( CGM_LEVEL3, "Color Calibration" ) break; // NS
+ case 0x15 : ComOut( CGM_LEVEL3, "Font Properties" ) break; // NS
+ case 0x16 : ComOut( CGM_LEVEL3, "Glyph Mapping" ) break; // NS
+ case 0x17 : ComOut( CGM_LEVEL3, "Symbol Library List" ) break; // NS
+ case 0xfc : ComOut( CGM_GDSF_ONLY, "Inquire Function Support" ) break;
+ case 0xfa : ComOut( CGM_GDSF_ONLY, "End Metafile Defaults Replacement" ) break;
+ case 0xf8 : ComOut( CGM_GDSF_ONLY, "Set Color Value Desc Extent" ) break;
+ default: ComOut( CGM_UNKNOWN_COMMAND, "" ) break;
+ }
+};
+
+
diff --git a/goodies/source/filter.vcl/icgm/class2.cxx b/goodies/source/filter.vcl/icgm/class2.cxx
new file mode 100644
index 000000000000..9f2b58116057
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/class2.cxx
@@ -0,0 +1,258 @@
+/*************************************************************************
+ *
+ * $RCSfile: class2.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <main.hxx>
+
+// ---------------------------------------------------------------
+
+void CGM::ImplDoClass2()
+{
+ sal_uInt32 nUInteger;
+ switch ( mnElementID )
+ {
+ case 0x01 : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Scaling Mode" )
+ {
+ if ( mnElementSize ) // HACK (NASA.CGM)
+ {
+ switch( ImplGetUI16() )
+ {
+ case 0 : pElement->eScalingMode = SM_ABSTRACT; break;
+ case 1 : pElement->eScalingMode = SM_METRIC; break;
+ default : mbStatus = sal_False; break;
+ }
+ pElement->nScalingFactor = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ ImplSetMapMode();
+ }
+ }
+ break;
+ case 0x02 : ComOut( CGM_LEVEL1, "Color Selection Mode" )
+ {
+ nUInteger = ImplGetUI16();
+ switch( nUInteger )
+ {
+ case 0 : pElement->eColorSelectionMode = CSM_INDEXED; break;
+ case 1 : pElement->eColorSelectionMode = CSM_DIRECT; break;
+ default : mbStatus = sal_False; break;
+ }
+ }
+ break;
+ case 0x03 : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Line Width Specification Mode" )
+ {
+ nUInteger = ImplGetUI16();
+ switch( nUInteger )
+ {
+ case 0 : pElement->eLineWidthSpecMode = SM_ABSOLUTE; break;
+ case 1 : pElement->eLineWidthSpecMode = SM_SCALED; break;
+ default : mbStatus = sal_False; break;
+ }
+ }
+ break;
+ case 0x04 : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Marker Size Specification Mode" )
+ {
+ nUInteger = ImplGetUI16();
+ switch( nUInteger )
+ {
+ case 0 : pElement->eMarkerSizeSpecMode = SM_ABSOLUTE; break;
+ case 1 : pElement->eMarkerSizeSpecMode = SM_SCALED; break;
+ default : mbStatus = sal_False; break;
+ }
+ }
+ break;
+ case 0x05 : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Edge Width Specification Mode" )
+ {
+ nUInteger = ImplGetUI16();
+ switch( nUInteger )
+ {
+ case 0 : pElement->eEdgeWidthSpecMode = SM_ABSOLUTE; break;
+ case 1 : pElement->eEdgeWidthSpecMode = SM_SCALED; break;
+ default : mbStatus = sal_False; break;
+ }
+ }
+ break;
+ case 0x06 : ComOut( CGM_LEVEL1, "VDC Extent" )
+ {
+ ImplGetRectangleNS( pElement->aVDCExtent );
+ ImplSetMapMode();
+ }
+ break;
+ case 0x07 : ComOut( CGM_LEVEL1, "Background Color" )
+ pElement->nBackGroundColor = ImplGetBitmapColor( sal_True );
+ break;
+ case 0x08 : ComOut( CGM_LEVEL2, "Device Viewport" )
+ {
+ if ( pElement->eVDCType == VDC_INTEGER )
+ ImplGetRectangle( pElement->aDeviceViewPort );
+ ImplSetMapMode();
+ }
+ break;
+ case 0x09 : ComOut( CGM_LEVEL2, "Device Viewport Specification Mode" )
+ {
+ nUInteger = ImplGetUI16( 8 );
+ switch( nUInteger )
+ {
+ case 0 : pElement->eDeviceViewPortMode = DVPM_FRACTION; break;
+ case 1 : pElement->eDeviceViewPortMode = DVPM_METRIC; break;
+ case 2 : pElement->eDeviceViewPortMode = DVPM_DEVICE; break;
+ default : mbStatus = sal_False; break;
+ }
+ pElement->nDeviceViewPortScale = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ ImplSetMapMode();
+ }
+ break;
+ case 0x0a : ComOut( CGM_LEVEL2, "Device Viewport Mapping" )
+ {
+ switch( ImplGetUI16() )
+ {
+ case 0 : pElement->eDeviceViewPortMap = DVPM_NOT_FORCED; break;
+ case 1 : pElement->eDeviceViewPortMap = DVPM_FORCED; break;
+ default : mbStatus = sal_False; break;
+ }
+ switch( ImplGetUI16() )
+ {
+ case 0 : pElement->eDeviceViewPortMapH = DVPMH_LEFT; break;
+ case 1 : pElement->eDeviceViewPortMapH = DVPMH_CENTER; break;
+ case 2 : pElement->eDeviceViewPortMapH = CVPMH_RIGHT; break;
+ default : mbStatus = sal_False; break;
+ }
+ switch( ImplGetUI16() )
+ {
+ case 0 : pElement->eDeviceViewPortMapV = DVPMV_BOTTOM; break;
+ case 1 : pElement->eDeviceViewPortMapV = DVPMV_CENTER; break;
+ case 2 : pElement->eDeviceViewPortMapV = DVPMV_TOP; break;
+ default : mbStatus = sal_False; break;
+ }
+ ImplSetMapMode();
+ }
+ break;
+ case 0x0b : ComOut( CGM_LEVEL2, "Line Representation" )
+ {
+ LineBundle aTempLineBundle;
+ aTempLineBundle.SetIndex( ImplGetI( pElement->nIndexPrecision ) );
+ aTempLineBundle.eLineType = (LineType)ImplGetI( pElement->nIndexPrecision );
+ aTempLineBundle.nLineWidth = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ aTempLineBundle.SetColor( ImplGetBitmapColor() );
+ pElement->InsertBundle( pElement->aLineList, aTempLineBundle );
+ }
+ break;
+ case 0x0c : ComOut( CGM_LEVEL2, "Marker Representation" )
+ {
+ MarkerBundle aTempMarkerBundle;
+ aTempMarkerBundle.SetIndex( ImplGetI( pElement->nIndexPrecision ) );
+ aTempMarkerBundle.eMarkerType = (MarkerType)ImplGetI( pElement->nIndexPrecision );
+ aTempMarkerBundle.nMarkerSize = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ aTempMarkerBundle.SetColor( ImplGetBitmapColor() );
+ pElement->InsertBundle( pElement->aMarkerList, aTempMarkerBundle );
+ }
+ break;
+ case 0x0d : ComOut( CGM_LEVEL2, "Text Representation" )
+ {
+ TextBundle aTempTextBundle;
+ aTempTextBundle.SetIndex( ImplGetI( pElement->nIndexPrecision ) );
+ aTempTextBundle.nTextFontIndex = ImplGetI( pElement->nIndexPrecision );
+ aTempTextBundle.eTextPrecision = (TextPrecision)ImplGetI( pElement->nIndexPrecision );
+ aTempTextBundle.nCharacterSpacing = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ aTempTextBundle.nCharacterExpansion = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ aTempTextBundle.SetColor( ImplGetBitmapColor() );
+ pElement->InsertBundle( pElement->aTextList, aTempTextBundle );
+ }
+ break;
+ case 0x0e : ComOut( CGM_LEVEL2, "Fill Representation" )
+ {
+ FillBundle aTempFillBundle;
+ aTempFillBundle.SetIndex( ImplGetI( pElement->nIndexPrecision ) );
+ aTempFillBundle.eFillInteriorStyle = (FillInteriorStyle)ImplGetI( pElement->nIndexPrecision );
+ aTempFillBundle.SetColor( ImplGetBitmapColor() );
+ aTempFillBundle.nFillPatternIndex = ImplGetI( pElement->nIndexPrecision );
+ aTempFillBundle.nFillHatchIndex = ImplGetI( pElement->nIndexPrecision );
+ pElement->InsertBundle( pElement->aFillList, aTempFillBundle );
+ }
+ break;
+ case 0x0f : ComOut( CGM_LEVEL2, "Edge Representation" )
+ {
+ EdgeBundle aTempEdgeBundle;
+ aTempEdgeBundle.SetIndex( ImplGetI( pElement->nIndexPrecision ) );
+ aTempEdgeBundle.eEdgeType = (EdgeType)ImplGetI( pElement->nIndexPrecision );
+ aTempEdgeBundle.nEdgeWidth = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ aTempEdgeBundle.SetColor( ImplGetBitmapColor() );
+ pElement->InsertBundle( pElement->aEdgeList, aTempEdgeBundle );
+ }
+ break;
+ case 0x10 : ComOut( CGM_LEVEL3, "Interior Style Specification Mode" ) break; // NS
+ case 0x11 : ComOut( CGM_LEVEL3, "Line and Edge Type Definition" ) break;
+ case 0x12 : ComOut( CGM_LEVEL3, "Hatch Style Definition" ) break; // NS
+ case 0x13 : ComOut( CGM_LEVEL3, "Geometric Pattern Definition" ) break; // NS
+ case 0xff : ComOut( CGM_GDSF_ONLY, "inquire VDC EXTENT" ) break;
+ case 0xfe : ComOut( CGM_GDSF_ONLY, "inquire Background Color" ) break;
+ case 0xfd : ComOut( CGM_GDSF_ONLY, "inquire Device Viewport" ) break;
+ case 0xfc : ComOut( CGM_GDSF_ONLY, "set Font Selection Mode" ) break;
+ case 0xfb : ComOut( CGM_GDSF_ONLY, "inquire Color Selection Mode" ) break;
+ case 0xfa : ComOut( CGM_GDSF_ONLY, "inquire Font Selection Mode" ) break;
+ case 0xf9 : ComOut( CGM_GDSF_ONLY, "set Char Height Spec Mode" )
+ {
+ sal_uInt32 nType = ImplGetUI16();
+ }
+ break;
+ case 0xf8 : ComOut( CGM_GDSF_ONLY, "set Background Style" ) break;
+ default: ComOut( CGM_UNKNOWN_COMMAND, "" ) break;
+ }
+};
+
+
diff --git a/goodies/source/filter.vcl/icgm/class3.cxx b/goodies/source/filter.vcl/icgm/class3.cxx
new file mode 100644
index 000000000000..102a9acd217b
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/class3.cxx
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * $RCSfile: class3.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <main.hxx>
+#include <outact.hxx>
+
+// ---------------------------------------------------------------
+
+void CGM::ImplDoClass3()
+{
+ sal_uInt32 nUInteger;
+ long nI0, nI1;
+ switch ( mnElementID )
+ {
+ case 0x01 : ComOut( CGM_LEVEL1, "VDC Integer Precision" )
+ {
+ switch( ImplGetI( pElement->nIntegerPrecision ) )
+ {
+ case 16 : pElement->nVDCIntegerPrecision = 2; break;
+ case 32 : pElement->nVDCIntegerPrecision = 4; break;
+ default : mbStatus = sal_False; break;
+ }
+ }
+ break;
+ case 0x02 : ComOut( CGM_LEVEL1, "VDC Real Precision" )
+ {
+ nUInteger = ImplGetUI16();
+ if ( mnMode & CGM_IMPORT_IM )
+ ALIGN4( mnParaSize );
+ nI0 = ImplGetI( pElement->nIntegerPrecision ); // exponent
+ nI1 = ImplGetI( pElement->nIntegerPrecision ); // mantisse
+ switch( nUInteger )
+ {
+ case 0 :
+ pElement->eVDCRealPrecision = RP_FLOAT;
+ switch ( nI0 )
+ {
+ case 9 :
+ if ( nI1 != 23 )
+ mbStatus = sal_False;
+ pElement->nVDCRealSize = 4;
+ break;
+ case 12 :
+ if ( nI1 != 52 )
+ mbStatus =sal_False;
+ pElement->nVDCRealSize = 8;
+ break;
+ default:
+ mbStatus = sal_False;
+ break;
+ }
+ break;
+ case 1 :
+ pElement->eVDCRealPrecision = RP_FIXED;
+ if ( nI0 != nI1 )
+ mbStatus = sal_False;
+ if ( nI0 = 16 )
+ pElement->nVDCRealSize = 4;
+ else if ( nI0 = 32 )
+ pElement->nVDCRealSize = 8;
+ else
+ mbStatus = sal_False;
+ break;
+ default :
+ mbStatus = sal_False; break;
+ }
+ }
+ break;
+ case 0x03 : ComOut( CGM_LEVEL1, "Auxiliary Colour" )
+ {
+ pElement->nAuxiliaryColor = ImplGetBitmapColor();
+ if ( mnMode & CGM_IMPORT_IM ) // PATCH
+ mnParaSize = mnElementSize;
+ }
+ break;
+ case 0x04 : ComOut( CGM_LEVEL1, "Transparency" )
+ {
+ switch( ImplGetUI16() )
+ {
+ case 0 : pElement->eTransparency = T_OFF; break;
+ case 1 : pElement->eTransparency = T_ON; break;
+ default : mbStatus = sal_False; break;
+ }
+ }
+ break;
+ case 0x05 : ComOut( CGM_LEVEL1, "Clip Rectangle" )
+ ImplGetRectangle( pElement->aClipRect );
+ break;
+ case 0x06 : ComOut( CGM_LEVEL1, "Clip Indicator" )
+ {
+ switch( ImplGetUI16() )
+ {
+ case 0 : pElement->eClipIndicator = CI_OFF; break;
+ case 1 : pElement->eClipIndicator = CI_ON; break;
+ default : mbStatus = sal_False; break;
+ }
+ }
+ break;
+ case 0x07 : ComOut( CGM_LEVEL2, "Line Clipping Mode" ) break; // NS
+ case 0x08 : ComOut( CGM_LEVEL2, "Marker Clipping Mode" ) break; // NS
+ case 0x09 : ComOut( CGM_LEVEL2, "Edge Clipping Mode" ) break; // NS
+ case 0x0a : ComOut( CGM_LEVEL2, "New Region" )
+ mpOutAct->NewRegion();
+ break;
+ case 0x0b : ComOut( CGM_LEVEL2, "Save Primitive Context" ) break; // NS
+ case 0x0c : ComOut( CGM_LEVEL2, "Restore Primitive Context" ) break; // NS
+ case 0x11 : ComOut( CGM_LEVEL3, "Protection Region Indicator" ) break;
+ case 0x12 : ComOut( CGM_LEVEL3, "Generalized Text Path Mode" ) break; // NS
+ case 0x13 : ComOut( CGM_LEVEL3, "Mitre Limit" )
+ pElement->nMitreLimit = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ break; // NS
+ case 0x14 : ComOut( CGM_LEVEL3, "Transparent Cell Color" ) break; // NS
+ case 0xfc : ComOut( CGM_GDSF_ONLY, "Text Path Alignment Modes" ) break;
+ case 0xfd : ComOut( CGM_GDSF_ONLY, "Pop Transformation Stack" ) break;
+ case 0xfe : ComOut( CGM_GDSF_ONLY, "Push Transformation Stack" ) break;
+ case 0xff : ComOut( CGM_GDSF_ONLY, "Set Patch ID" ) break;
+ default: ComOut( CGM_UNKNOWN_COMMAND, "" ) break;
+ }
+};
+
+
diff --git a/goodies/source/filter.vcl/icgm/class4.cxx b/goodies/source/filter.vcl/icgm/class4.cxx
new file mode 100644
index 000000000000..6b61b1e8b5ab
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/class4.cxx
@@ -0,0 +1,1005 @@
+/*************************************************************************
+ *
+ * $RCSfile: class4.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <math.h>
+#include <main.hxx>
+#include <chart.hxx>
+#include <outact.hxx>
+
+using namespace ::com::sun::star;
+
+double CGM::ImplGetOrientation( FloatPoint& rCenter, FloatPoint& rPoint )
+{
+ double fOrientation;
+
+ double nX = rPoint.X - rCenter.X;
+ double nY = rPoint.Y - rCenter.Y;
+
+ fOrientation = acos( nX / sqrt( nX * nX + nY * nY ) ) * 57.29577951308;
+ if ( nY > 0 )
+ fOrientation = 360 - fOrientation;
+
+ return fOrientation;
+}
+
+// ---------------------------------------------------------------
+
+void CGM::ImplSwitchStartEndAngle( double& rStartAngle, double& rEndAngle )
+{
+ double nTemp;
+ nTemp = rStartAngle;
+ rStartAngle = rEndAngle;
+ rEndAngle = nTemp;
+}
+
+// ---------------------------------------------------------------
+
+void CGM::ImplGetVector( double* pVector )
+{
+ if ( pElement->eVDCType == VDC_REAL )
+ {
+ for ( sal_uInt32 i = 0; i < 4; i++ )
+ {
+ pVector[ i ] = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ }
+ }
+ else
+ {
+ for ( sal_uInt32 i = 0; i < 4; i++ )
+ {
+ pVector[ i ] = (double)ImplGetI( pElement->nVDCIntegerPrecision );
+ }
+ }
+ pVector[ 0 ] *= mnVDCXmul;
+ pVector[ 2 ] *= mnVDCXmul;
+ pVector[ 1 ] *= mnVDCYmul;
+ pVector[ 3 ] *= mnVDCYmul;
+}
+
+// ---------------------------------------------------------------
+sal_Bool CGM::ImplGetEllipse( FloatPoint& rCenter, FloatPoint& rRadius, double& rAngle )
+{
+ FloatPoint aPoint1, aPoint2;
+ double fRot1, fRot2;
+ ImplGetPoint( rCenter, sal_True );
+ ImplGetPoint( aPoint1, sal_True );
+ ImplGetPoint( aPoint2, sal_True );
+ fRot1 = ImplGetOrientation( rCenter, aPoint1 );
+ fRot2 = ImplGetOrientation( rCenter, aPoint2 );
+ rAngle = ImplGetOrientation( rCenter, aPoint1 );
+ aPoint1.X -= rCenter.X;
+ aPoint1.Y -= rCenter.Y;
+ rRadius.X = sqrt( aPoint1.X * aPoint1.X + aPoint1.Y * aPoint1.Y );
+ aPoint2.X -= rCenter.X;
+ aPoint2.Y -= rCenter.Y;
+ rRadius.Y = sqrt( aPoint2.X * aPoint2.X + aPoint2.Y * aPoint2.Y );
+
+ if ( fRot1 > fRot2 )
+ {
+ if ( ( fRot1 - fRot2 ) < 180 )
+ return sal_False;
+ }
+ else
+ {
+ if ( ( fRot2 - fRot1 ) > 180 )
+ return sal_False;
+ }
+ return sal_True;
+}
+
+void CGM::ImplDoClass4()
+{
+ if ( mbFirstOutPut )
+ mpOutAct->FirstOutPut();
+
+ if ( mpBitmapInUse && ( mnElementID != 9 ) ) // vorhandene grafik verarbeiten,
+ { // da jetzt nicht bitmap actions anstehen
+ CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
+ // irgendetwas mit der Bitmap anfangen
+ mpOutAct->DrawBitmap( pBmpDesc );
+ delete mpBitmapInUse;
+ mpBitmapInUse = NULL;
+ }
+
+ if ( ( mpChart == NULL ) || mpChart->IsAnnotation() )
+ {
+ switch ( mnElementID )
+ {
+ case 0x01 : ComOut( CGM_LEVEL1, "PolyLine" )
+ {
+ sal_uInt32 nPoints = mnElementSize / ImplGetPointSize();
+ Polygon aPolygon( (sal_uInt16)nPoints );
+ for ( sal_uInt16 i = 0; i < nPoints; i++)
+ {
+ FloatPoint aFloatPoint;
+ ImplGetPoint( aFloatPoint, sal_True );
+ aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), i );
+ }
+ if ( mbFigure )
+ mpOutAct->RegPolyLine( aPolygon );
+ else
+ mpOutAct->DrawPolyLine( aPolygon );
+ }
+ break;
+
+ case 0x02 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Disjoint PolyLine" )
+ {
+ sal_uInt32 nPoints = mnElementSize / ImplGetPointSize();
+ if ( ! ( nPoints & 1 ) )
+ {
+ nPoints >>= 1;
+ FloatPoint aFloatPoint;
+ if ( mbFigure )
+ {
+ Polygon aPolygon( nPoints );
+ for ( sal_uInt16 i = 0; i < nPoints; i++ )
+ {
+ ImplGetPoint( aFloatPoint, sal_True );
+ aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 0 );
+ }
+ mpOutAct->RegPolyLine( aPolygon );
+ }
+ else
+ {
+ mpOutAct->BeginGroup();
+ Polygon aPolygon( (sal_uInt16)2 );
+ for ( sal_uInt16 i = 0; i < nPoints; i++ )
+ {
+ ImplGetPoint( aFloatPoint, sal_True );
+ aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 0 );
+ ImplGetPoint( aFloatPoint, sal_True );
+ aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 1);
+ mpOutAct->DrawPolyLine( aPolygon );
+ }
+ mpOutAct->EndGroup();
+ }
+ }
+ }
+ break;
+
+ case 0x03 : ComOut( CGM_LEVEL1, "PolyMarker" ) break;
+ case 0x04 : ComOut( CGM_LEVEL1, "Text" )
+ {
+ FloatPoint aFloatPoint;
+ sal_uInt32 nType, nSize;
+
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+
+ ImplGetPoint ( aFloatPoint, sal_True );
+ nType = ImplGetUI16( 4 );
+ if ( mnMode & CGM_IMPORT_IM )
+ {
+ nSize = ImplGetUI( 4 );
+ }
+ else
+ nSize = ImplGetUI( 1 );
+
+ mpSource[ mnParaSize + nSize ] = 0;
+
+ ComOut( CGM_DESCRIPTION, (char*)mpSource + mnParaSize );
+
+ awt::Size aSize;
+ awt::Point aPoint( (long)aFloatPoint.X, (long)aFloatPoint.Y );
+ mpOutAct->DrawText( aPoint, aSize,
+ (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
+// mnParaSize += nSize;
+ mnParaSize = mnElementSize;
+ }
+ break;
+
+ case 0x05 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Restricted Text" )
+ {
+ double dx, dy;
+ FloatPoint aFloatPoint;
+ sal_uInt32 nType, nSize;
+
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+
+ if ( pElement->eVDCType == VDC_REAL )
+ {
+ dx = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ dy = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ }
+ else
+ {
+ dx = (double)ImplGetI( pElement->nVDCIntegerPrecision );
+ dy = (double)ImplGetI( pElement->nVDCIntegerPrecision );
+ }
+ ImplMapDouble( dx );
+ ImplMapDouble( dy );
+
+ ImplGetPoint ( aFloatPoint, sal_True );
+ nType = ImplGetUI16( 4 );
+ if ( mnMode & CGM_IMPORT_IM )
+ {
+ nSize = ImplGetUI( 4 );
+ }
+ else
+ nSize = ImplGetUI( 1 );
+
+ mpSource[ mnParaSize + nSize ] = 0;
+
+ ComOut( CGM_DESCRIPTION, (char*)mpSource + mnParaSize );
+
+ awt::Point aPoint( (long)aFloatPoint.X, (long)aFloatPoint.Y );
+ awt::Size aSize((long)dx, (long)dy);
+ mpOutAct->DrawText( aPoint, aSize ,
+ (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
+// mnParaSize += nSize;
+ mnParaSize = mnElementSize;
+ }
+ break;
+
+ case 0x06 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Append Text" )
+ {
+ sal_uInt32 nSize;
+ sal_uInt32 nType = ImplGetUI16( 4 );
+
+ if ( mnMode & CGM_IMPORT_IM )
+ {
+ nSize = ImplGetUI( 4 );
+ }
+ else
+ nSize = ImplGetUI( 1 );
+
+ mpSource[ mnParaSize + nSize ] = 0;
+
+ ComOut( CGM_DESCRIPTION, (char*)mpSource + mnParaSize );
+
+ mpOutAct->AppendText( (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
+// mnParaSize += nSize;
+ mnParaSize = mnElementSize;
+ }
+ break;
+
+ case 0x07 : ComOut( CGM_LEVEL1, "Polygon" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+
+ sal_uInt32 nPoints = mnElementSize / ImplGetPointSize();
+ Polygon aPolygon( nPoints );
+ for ( sal_uInt32 i = 0; i < nPoints; i++)
+ {
+ FloatPoint aFloatPoint;
+ ImplGetPoint( aFloatPoint, sal_True );
+ aPolygon.SetPoint( Point ( (long)( aFloatPoint.X ), (long)( aFloatPoint.Y ) ), i );
+ }
+ mpOutAct->DrawPolygon( aPolygon );
+ }
+ break;
+
+ case 0x08 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Polygon Set" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+
+ sal_uInt32 nPoints = 0;
+ Point* pPoints = new Point[ 0x4000 ];
+
+ PolyPolygon aPolyPolygon;
+ FloatPoint aFloatPoint;
+ sal_uInt32 nEdgeFlag;
+ while ( mnParaSize < mnElementSize )
+ {
+ ImplGetPoint( aFloatPoint, sal_True );
+ nEdgeFlag = ImplGetUI16();
+ pPoints[ nPoints++ ] = Point( (long)aFloatPoint.X, (long)aFloatPoint.Y );
+ if ( ( nEdgeFlag & 2 ) || ( mnParaSize == mnElementSize ) )
+ {
+ Polygon aPolygon( nPoints );
+ for ( sal_uInt32 i = 0; i < nPoints; i++ )
+ {
+ aPolygon.SetPoint( pPoints[ i ], i );
+ }
+ aPolyPolygon.Insert( aPolygon, POLYPOLY_APPEND );
+ nPoints = 0;
+ }
+ }
+ delete[] pPoints;
+ mpOutAct->DrawPolyPolygon( aPolyPolygon );
+ }
+ break;
+
+ case 0x09 : ComOut( CGM_LEVEL1, "Cell Array" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+
+ if ( mpBitmapInUse )
+ {
+ CGMBitmap* pBmpDesc = mpBitmapInUse->GetNext();
+ if ( pBmpDesc ) // eventuell bekommen wir eine bitmap zurück, die nicht
+ { // zur vorherigen paßt -> diese müssen wir dann auch löschen
+ mpOutAct->DrawBitmap( pBmpDesc->GetBitmap() );
+ delete pBmpDesc;
+ }
+ }
+ else
+ {
+ mpBitmapInUse = new CGMBitmap( *this );
+ }
+ }
+ break;
+
+ case 0x0a : ComOut( CGM_LEVEL1, "Generalized Drawing Primitive" )
+ {
+ long nIdentifier = ImplGetI( pElement->nIntegerPrecision );
+ sal_uInt32 nNumberOfPoints = ImplGetUI( pElement->nIntegerPrecision );
+ if ( mnMode & CGM_IMPORT_IM )
+ {
+ switch ( nIdentifier )
+ {
+ case -1 : ComOut( CGM_DESCRIPTION, "POLYBEZIER" )
+ {
+ sal_uInt32 i;
+ Polygon aPolygon( nNumberOfPoints );
+ for ( i = 0; i < nNumberOfPoints; i++)
+ {
+ FloatPoint aFloatPoint;
+ ImplGetPoint( aFloatPoint, sal_True );
+ aPolygon.SetPoint( Point ( (long)( aFloatPoint.X ), (long)( aFloatPoint.Y ) ), i );
+ }
+ sal_uInt32 nOrder = ImplGetI( pElement->nIntegerPrecision );
+ if ( nOrder & 4 )
+ {
+ for ( i = 0; i < nNumberOfPoints; i++ )
+ {
+ if ( ( i % 3 ) == 0 )
+ aPolygon.SetFlags( i, POLY_NORMAL );
+ else
+ aPolygon.SetFlags( i, POLY_CONTROL );
+ }
+ }
+ else
+ {
+ for ( i = 0; i < nNumberOfPoints; i++ )
+ {
+ switch ( i & 3 )
+ {
+ case 0 :
+ case 3 : aPolygon.SetFlags( i, POLY_NORMAL ); break;
+ default : aPolygon.SetFlags( i, POLY_CONTROL ); break;
+ }
+ }
+ }
+ if ( mbFigure )
+ mpOutAct->RegPolyLine( aPolygon );
+ else
+ mpOutAct->DrawPolybezier( aPolygon );
+ mnParaSize = mnElementSize;
+ }
+ break;
+ case -2 : ComOut( CGM_DESCRIPTION, "SHARP POLYBEZIER" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case -3 : ComOut( CGM_DESCRIPTION, "POLYSPLINE" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case -4 : ComOut( CGM_DESCRIPTION, "ROUNDED RECTANGLE" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case -5 : ComOut( CGM_DESCRIPTION, "BEGIN CELL ARRAY" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case -6 : ComOut( CGM_DESCRIPTION, "END CELL ARRAY" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case -7 : ComOut( CGM_DESCRIPTION, "INSERT FILE" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case -8 : ComOut( CGM_DESCRIPTION, "BLOCK TEXT" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case -9 : ComOut( CGM_DESCRIPTION, "VARIABLE WIDTH POLYLINE" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case -15: ComOut( CGM_DESCRIPTION, "HYPERLINK DEFINITION" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ default : ComOut( CGM_DESCRIPTION, "??????????????????????????????" ) break;
+ }
+ }
+ mnParaSize = mnElementSize;
+ }
+ break;
+
+ case 0x0b : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Rectangle" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+
+ FloatRect aFloatRect;
+ ImplGetRectangle( aFloatRect, sal_True );
+ mpOutAct->DrawRectangle( aFloatRect );
+ }
+ break;
+
+ case 0x0c : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circle" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+
+ double fRotation = 0;
+ FloatPoint aCenter, aRadius;
+ ImplGetPoint( aCenter, sal_True );
+ if ( pElement->eVDCType == VDC_REAL )
+ aRadius.X = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ else
+ aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
+ ImplMapDouble( aRadius.X );
+ aRadius.Y = aRadius.X;
+ mpOutAct->DrawEllipse( aCenter, aRadius, fRotation );
+ }
+ break;
+
+ case 0x0d : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circular Arc 3 Point" )
+ {
+ int nSwitch = 0;
+
+ FloatPoint aStartingPoint, aIntermediatePoint, aEndingPoint, aCenterPoint;
+ ImplGetPoint( aStartingPoint, sal_True );
+ ImplGetPoint( aIntermediatePoint, sal_True );
+ ImplGetPoint( aEndingPoint, sal_True );
+
+ double fA = aIntermediatePoint.X - aStartingPoint.X;
+ double fB = aIntermediatePoint.Y - aStartingPoint.Y;
+ double fC = aEndingPoint.X - aStartingPoint.X;
+ double fD = aEndingPoint.Y - aStartingPoint.Y;
+
+ double fE = fA * ( aStartingPoint.X + aIntermediatePoint.X ) + fB * ( aStartingPoint.Y + aIntermediatePoint.Y );
+ double fF = fC * ( aStartingPoint.X + aEndingPoint.X ) + fD * ( aStartingPoint.Y + aEndingPoint.Y );
+
+ double fG = 2.0 * ( fA * ( aEndingPoint.Y - aIntermediatePoint.Y ) - fB * ( aEndingPoint.X - aIntermediatePoint.X ) );
+
+ aCenterPoint.X = ( fD * fE - fB * fF ) / fG;
+ aCenterPoint.Y = ( fA * fF - fC * fE ) / fG;
+
+ if ( fG != 0 )
+ {
+ double fStartAngle = ImplGetOrientation( aCenterPoint, aStartingPoint );
+ double fInterAngle = ImplGetOrientation( aCenterPoint, aIntermediatePoint );
+ double fEndAngle = ImplGetOrientation( aCenterPoint, aEndingPoint );
+
+ if ( fStartAngle > fEndAngle )
+ {
+ nSwitch ^=1;
+ aIntermediatePoint = aEndingPoint;
+ aEndingPoint = aStartingPoint;
+ aStartingPoint = aIntermediatePoint;
+ fG = fStartAngle;
+ fStartAngle = fEndAngle;
+ fEndAngle = fG;
+ }
+ if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
+ {
+ nSwitch ^=1;
+ aIntermediatePoint = aEndingPoint;
+ aEndingPoint = aStartingPoint;
+ aStartingPoint = aIntermediatePoint;
+ fG = fStartAngle;
+ fStartAngle = fEndAngle;
+ fEndAngle = fG;
+ }
+ double fRadius = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ;
+
+ if ( mbFigure )
+ {
+ Rectangle aBoundingBox( Point( (long)( aCenterPoint.X - fRadius ), long( aCenterPoint.Y - fRadius ) ), Size( ( 2 * fRadius ), (long)( 2 * fRadius) ) );
+ Polygon aPolygon( aBoundingBox, Point( (long)aStartingPoint.X, (long)aStartingPoint.Y ) ,Point( (long)aEndingPoint.X, (long)aEndingPoint.Y ), POLY_ARC );
+ if ( nSwitch )
+ mpOutAct->RegPolyLine( aPolygon, sal_True );
+ else
+ mpOutAct->RegPolyLine( aPolygon );
+ }
+ else
+ {
+ fG = 0;
+ FloatPoint aRadius;
+ aRadius.X = aRadius.Y = fRadius;
+ mpOutAct->DrawEllipticalArc( aCenterPoint, aRadius, fG, 2, fStartAngle, fEndAngle );
+ }
+ }
+ }
+ break;
+
+ case 0x0e : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circular Arc 3 Point Close" )
+ {
+ int nSwitch = 0;
+
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+
+ FloatPoint aStartingPoint, aIntermediatePoint, aEndingPoint, aCenterPoint;
+ ImplGetPoint( aStartingPoint );
+ ImplGetPoint( aIntermediatePoint );
+ ImplGetPoint( aEndingPoint );
+
+ double fA = aIntermediatePoint.X - aStartingPoint.X;
+ double fB = aIntermediatePoint.Y - aStartingPoint.Y;
+ double fC = aEndingPoint.X - aStartingPoint.X;
+ double fD = aEndingPoint.Y - aStartingPoint.Y;
+
+ double fE = fA * ( aStartingPoint.X + aIntermediatePoint.X ) + fB * ( aStartingPoint.Y + aIntermediatePoint.Y );
+ double fF = fC * ( aStartingPoint.X + aEndingPoint.X ) + fD * ( aStartingPoint.Y + aEndingPoint.Y );
+
+ double fG = 2.0 * ( fA * ( aEndingPoint.Y - aIntermediatePoint.Y ) - fB * ( aEndingPoint.X - aIntermediatePoint.X ) );
+
+ aCenterPoint.X = ( fD * fE - fB * fF ) / fG;
+ aCenterPoint.Y = ( fA * fF - fC * fE ) / fG;
+
+ if ( fG != 0 )
+ {
+ double fStartAngle = ImplGetOrientation( aCenterPoint, aStartingPoint );
+ double fInterAngle = ImplGetOrientation( aCenterPoint, aIntermediatePoint );
+ double fEndAngle = ImplGetOrientation( aCenterPoint, aEndingPoint );
+
+ if ( fStartAngle > fEndAngle )
+ {
+ nSwitch ^=1;
+ aIntermediatePoint = aEndingPoint;
+ aEndingPoint = aStartingPoint;
+ aStartingPoint = aIntermediatePoint;
+ fG = fStartAngle;
+ fStartAngle = fEndAngle;
+ fEndAngle = fG;
+ }
+ if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
+ {
+ nSwitch ^=1;
+ aIntermediatePoint = aEndingPoint;
+ aEndingPoint = aStartingPoint;
+ aStartingPoint = aIntermediatePoint;
+ fG = fStartAngle;
+ fStartAngle = fEndAngle;
+ fEndAngle = fG;
+ }
+ FloatPoint fRadius;
+ fRadius.Y = fRadius.X = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ;
+
+ sal_uInt32 nType = ImplGetUI16();
+ if ( nType == 0 )
+ nType = 0; // is PIE
+ else
+ nType = 1; // is CHORD
+
+ double fOrientation = 0;
+ mpOutAct->DrawEllipticalArc( aCenterPoint, fRadius, fOrientation, nType, fStartAngle, fEndAngle );
+ }
+ }
+ break;
+
+ case 0x0f : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circular Arc Centre" )
+ {
+ double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
+ FloatPoint aCenter, aRadius;
+
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+
+ ImplGetPoint( aCenter, sal_True );
+ ImplGetVector( &vector[ 0 ] );
+
+ if ( pElement->eVDCType == VDC_REAL )
+ {
+ aRadius.X = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ }
+ else
+ {
+ aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
+ }
+
+ ImplMapDouble( aRadius.X );
+ aRadius.Y = aRadius.X;
+
+ fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
+ fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
+
+ if ( vector[ 1 ] > 0 )
+ fStartAngle = 360 - fStartAngle;
+ if ( vector[ 3 ] > 0 )
+ fEndAngle = 360 - fEndAngle;
+
+ if ( mbAngReverse )
+ ImplSwitchStartEndAngle( fStartAngle, fEndAngle );
+
+ if ( mbFigure )
+ {
+ Rectangle aBoundingBox( Point( (long)( aCenter.X - aRadius.X ), long( aCenter.Y - aRadius.X ) ), Size( ( 2 * aRadius.X ), (long)( 2 * aRadius.X ) ) );
+ Polygon aPolygon( aBoundingBox, Point( (long)vector[ 0 ], (long)vector[ 1 ] ), Point( (long)vector[ 2 ], (long)vector[ 3 ] ), POLY_ARC );
+ mpOutAct->RegPolyLine( aPolygon );
+ }
+ else
+ {
+ fOrientation = 0;
+ mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation, 2, fStartAngle, fEndAngle );
+ }
+ mnParaSize = mnElementSize;
+
+ }
+ break;
+
+ case 0x10 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circular Arc Centre Close" )
+ {
+ double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
+ FloatPoint aCenter, aRadius;
+
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+
+ ImplGetPoint( aCenter, sal_True );
+ ImplGetVector( &vector[ 0 ] );
+ if ( pElement->eVDCType == VDC_REAL )
+ {
+ aRadius.X = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ }
+ else
+ {
+ aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
+ }
+ ImplMapDouble( aRadius.X );
+ aRadius.Y = aRadius.X;
+ fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
+ fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
+
+ if ( vector[ 1 ] > 0 )
+ fStartAngle = 360 - fStartAngle;
+ if ( vector[ 3 ] > 0 )
+ fEndAngle = 360 - fEndAngle;
+
+ if ( mbAngReverse )
+ ImplSwitchStartEndAngle( fStartAngle, fEndAngle );
+
+
+ sal_uInt32 nType = ImplGetUI16();
+ if ( nType == 0 )
+ nType = 0; // is PIE
+ else
+ nType = 1; // is CHORD
+ fOrientation = 0;
+
+ mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
+ nType, fStartAngle, fEndAngle );
+ mnParaSize = mnElementSize;
+ }
+ break;
+
+ case 0x11 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Ellipse" )
+ {
+ double fOrientation;
+ FloatPoint aCenter, aRadius;
+
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+
+ ImplGetEllipse( aCenter, aRadius, fOrientation ) ;
+ mpOutAct->DrawEllipse( aCenter, aRadius, fOrientation ) ;
+ }
+ break;
+
+ case 0x12 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Elliptical Arc" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+
+ double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
+ FloatPoint aCenter, aRadius;
+
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+
+ sal_Bool bDirection = ImplGetEllipse( aCenter, aRadius, fOrientation );
+ ImplGetVector( &vector[ 0 ] );
+
+ fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
+ fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
+
+ if ( vector[ 1 ] > 0 )
+ fStartAngle = 360 - fStartAngle;
+ if ( vector[ 3 ] > 0 )
+ fEndAngle = 360 - fEndAngle;
+
+ if ( bDirection )
+ mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
+ 2, fStartAngle, fEndAngle );
+ else
+ mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
+ 2, fEndAngle, fStartAngle);
+ }
+ break;
+
+ case 0x13 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Elliptical Arc Close" )
+ {
+ double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
+ FloatPoint aCenter, aRadius;
+
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+
+ sal_Bool bDirection = ImplGetEllipse( aCenter, aRadius, fOrientation );
+ ImplGetVector( &vector[ 0 ] );
+
+ fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
+ fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
+
+ if ( vector[ 1 ] > 0 )
+ fStartAngle = 360 - fStartAngle;
+ if ( vector[ 3 ] > 0 )
+ fEndAngle = 360 - fEndAngle;
+
+ sal_uInt32 nType = ImplGetUI16();
+ if ( nType == 0 )
+ nType = 0; // is PIE
+ else
+ nType = 1; // is CHORD
+
+ if ( bDirection )
+ mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
+ nType, fStartAngle, fEndAngle );
+ else
+ mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
+ nType, fEndAngle, fStartAngle);
+ }
+ break;
+ case 0x14 : ComOut( CGM_LEVEL2, "Circular Arc Centre Reversed" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0x15 : ComOut( CGM_LEVEL2, "Connection Edge" ) // NS
+ {
+// if ( mbFigure )
+// mpOutAct->CloseRegion();
+ }
+ break;
+ case 0x16 : ComOut( CGM_LEVEL3, "Hyperbolic Arc" ) // NS
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0x17 : ComOut( CGM_LEVEL3, "Parabolic Arc" ) // NS
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0x18 : ComOut( CGM_LEVEL3, "Non Uniform B-Spline" ) // NS
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0x19 : ComOut( CGM_LEVEL3, "Non Uniform Rational B-Spline" ) // NS
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0x1a : ComOut( CGM_LEVEL3, "Polybezier" )
+ {
+ sal_uInt32 i, nOrder, nNumberOfPoints;
+
+ nOrder = ImplGetI( pElement->nIntegerPrecision );
+
+ nNumberOfPoints = ( mnElementSize - pElement->nIntegerPrecision ) / ImplGetPointSize();
+
+ Polygon aPolygon( nNumberOfPoints );
+
+ for ( i = 0; i < nNumberOfPoints; i++)
+ {
+ FloatPoint aFloatPoint;
+ ImplGetPoint( aFloatPoint, sal_True );
+ aPolygon.SetPoint( Point ( (long)( aFloatPoint.X ), (long)( aFloatPoint.Y ) ), i );
+ }
+ if ( nOrder & 4 )
+ {
+ for ( i = 0; i < nNumberOfPoints; i++ )
+ {
+ if ( ( i % 3 ) == 0 )
+ aPolygon.SetFlags( i, POLY_NORMAL );
+ else
+ aPolygon.SetFlags( i, POLY_CONTROL );
+ }
+ }
+ else
+ {
+ for ( i = 0; i < nNumberOfPoints; i++ )
+ {
+ switch ( i & 3 )
+ {
+ case 0 :
+ case 3 : aPolygon.SetFlags( i, POLY_NORMAL ); break;
+ default : aPolygon.SetFlags( i, POLY_CONTROL ); break;
+ }
+ }
+ }
+ if ( mbFigure )
+ mpOutAct->RegPolyLine( aPolygon );
+ else
+ mpOutAct->DrawPolybezier( aPolygon );
+ mnParaSize = mnElementSize;
+ }
+ break;
+
+ case 0x1b : ComOut( CGM_LEVEL3, "Polysymbol" ) // NS
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0x1c : ComOut( CGM_LEVEL3, "Bitonal Tile" ) // NS
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0x1d : ComOut( CGM_LEVEL3, "Tile" ) // NS
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0x1e : ComOut( CGM_UNKNOWN_LEVEL, "Insert Object" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0xff : ComOut( CGM_GDSF_ONLY, "Polybezier" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0xfe : ComOut( CGM_GDSF_ONLY, "Sharp Polybezier" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0xfd : ComOut( CGM_GDSF_ONLY, "Polyspline" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0xfc : ComOut( CGM_GDSF_ONLY, "Reounded Rectangle" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0xfb : ComOut( CGM_GDSF_ONLY, "Begin Cell Array" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0xfa : ComOut( CGM_GDSF_ONLY, "End Cell Array" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0xf9 : ComOut( CGM_GDSF_ONLY, "Insert File" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0xf8 : ComOut( CGM_GDSF_ONLY, "Block Text" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0xf7 : ComOut( CGM_GDSF_ONLY, "Variable Width Polyline" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0xf6 : ComOut( CGM_GDSF_ONLY, "Elliptical Arc 3 Point" )
+ {
+ if ( mbFigure )
+ mpOutAct->CloseRegion();
+ }
+ break;
+ case 0xf1 : ComOut( CGM_GDSF_ONLY, "Hyperlink Definition" ) break;
+ default: ComOut( CGM_UNKNOWN_COMMAND, "" ) break;
+ }
+ }
+ else
+ mnParaSize = mnElementSize;
+};
+
+
diff --git a/goodies/source/filter.vcl/icgm/class5.cxx b/goodies/source/filter.vcl/icgm/class5.cxx
new file mode 100644
index 000000000000..4b7596848740
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/class5.cxx
@@ -0,0 +1,569 @@
+/*************************************************************************
+ *
+ * $RCSfile: class5.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+//#define VCL_NEED_BASETSD
+
+#if defined( WNT ) || defined( WIN )
+#include <tools/prewin.h>
+#include <windows.h>
+#include <tools/postwin.h>
+#endif
+#include <main.hxx>
+#include <outact.hxx>
+
+
+// ---------------------------------------------------------------
+
+void CGM::ImplDoClass5()
+{
+ switch ( mnElementID )
+ {
+ case 0x01 : ComOut( CGM_LEVEL1, "Line Bundle Index" )
+ pElement->pLineBundle = (LineBundle*)pElement->GetBundleIndex( ImplGetI( pElement->nIndexPrecision ), pElement->aLineList, pElement->aLineBundle );
+ break;
+ case 0x02 : ComOut( CGM_LEVEL1, "Line Type" )
+ {
+ if ( pElement->nAspectSourceFlags & ASF_LINETYPE )
+ pElement->pLineBundle->eLineType = (LineType)ImplGetI( pElement->nIndexPrecision );
+ else
+ pElement->aLineBundle.eLineType = (LineType)ImplGetI( pElement->nIndexPrecision );
+ }
+ break;
+ case 0x03 : ComOut( CGM_LEVEL1, "Line Width" )
+ {
+ double nWidth;
+ if ( pElement->eLineWidthSpecMode == SM_ABSOLUTE )
+ {
+ if ( pElement->eVDCType == VDC_REAL )
+ nWidth = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ else
+ nWidth = (double)ImplGetI( pElement->nVDCIntegerPrecision );
+
+ ImplMapDouble( nWidth );
+ }
+ else
+ nWidth = (sal_uInt32)ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize ) * 25; // scaling in 1/4 mm
+
+ ( pElement->nAspectSourceFlags & ASF_LINEWIDTH )
+ ? pElement->aLineBundle.nLineWidth = nWidth
+ : pElement->aLineBundle.nLineWidth = nWidth;
+ }
+ break;
+ case 0x04 : ComOut( CGM_LEVEL1, "Line Color" )
+ {
+ if ( pElement->nAspectSourceFlags & ASF_LINECOLOR )
+ pElement->pLineBundle->SetColor( ImplGetBitmapColor() );
+ else
+ pElement->aLineBundle.SetColor( ImplGetBitmapColor() );
+ if ( mnMode & CGM_IMPORT_IM ) // PATCH
+ mnParaSize = mnElementSize;
+ }
+ break;
+ case 0x05 : ComOut( CGM_LEVEL1, "Marker Bundle Index" )
+ pElement->pMarkerBundle = (MarkerBundle*)pElement->GetBundleIndex( ImplGetI( pElement->nIndexPrecision ), pElement->aMarkerList, pElement->aMarkerBundle );
+ break;
+ case 0x06 : ComOut( CGM_LEVEL1, "Marker Type" )
+ {
+ if ( pElement->nAspectSourceFlags & ASF_MARKERTYPE )
+ pElement->pMarkerBundle->eMarkerType = (MarkerType)ImplGetI( pElement->nIndexPrecision );
+ else
+ pElement->aMarkerBundle.eMarkerType = (MarkerType)ImplGetI( pElement->nIndexPrecision );
+ }
+ break;
+ case 0x07 : ComOut( CGM_LEVEL1, "Marker Size" )
+ {
+ double nWidth;
+ if ( pElement->eMarkerSizeSpecMode == SM_ABSOLUTE )
+ {
+ if ( pElement->eVDCType == VDC_REAL )
+ nWidth = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ else
+ nWidth = (double)ImplGetI( pElement->nVDCIntegerPrecision );
+ ImplMapDouble( nWidth );
+ }
+ else
+ nWidth = (sal_uInt32)ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize ) * 25;
+ ( pElement->nAspectSourceFlags & ASF_MARKERSIZE )
+ ? pElement->aMarkerBundle.nMarkerSize = nWidth
+ : pElement->aMarkerBundle.nMarkerSize = nWidth;
+ }
+ break;
+ case 0x08 : ComOut( CGM_LEVEL1, "Marker Color" )
+ {
+ if ( pElement->nAspectSourceFlags & ASF_MARKERCOLOR )
+ pElement->pMarkerBundle->SetColor( ImplGetBitmapColor() );
+ else
+ pElement->aMarkerBundle.SetColor( ImplGetBitmapColor() );
+ if ( mnMode & CGM_IMPORT_IM ) // PATCH
+ mnParaSize = mnElementSize;
+ }
+ break;
+ case 0x09 : ComOut( CGM_LEVEL1, "Text Bundle Index" )
+ pElement->pTextBundle = (TextBundle*)pElement->GetBundleIndex( ImplGetI( pElement->nIndexPrecision ), pElement->aTextList, pElement->aTextBundle );
+ break;
+ case 0x0a : ComOut( CGM_LEVEL1, "Text Font Index" )
+ {
+ if ( pElement->nAspectSourceFlags & ASF_TEXTFONTINDEX )
+ pElement->pTextBundle->nTextFontIndex = ImplGetI( pElement->nIndexPrecision );
+ else
+ pElement->aTextBundle.nTextFontIndex = ImplGetI( pElement->nIndexPrecision );
+ }
+ break;
+ case 0x0b : ComOut( CGM_LEVEL1, "Text Precision" )
+ {
+ TextBundle* pBundle;
+ if ( pElement->nAspectSourceFlags & ASF_TEXTPRECISION )
+ pBundle = pElement->pTextBundle;
+ else
+ pBundle = &pElement->aTextBundle;
+ switch( ImplGetUI16() )
+ {
+ case 0 : pBundle->eTextPrecision = TPR_STRING; break;
+ case 1 : pBundle->eTextPrecision = TPR_CHARACTER; break;
+ case 2 : pBundle->eTextPrecision = TPR_STROKE; break;
+ default : pBundle->eTextPrecision = TPR_UNDEFINED; break;
+ }
+ }
+ break;
+ case 0x0c : ComOut( CGM_LEVEL1, "Character Expansion Factor" )
+ {
+ if ( pElement->nAspectSourceFlags & ASF_CHARACTEREXPANSION )
+ pElement->pTextBundle->nCharacterExpansion = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ else
+ pElement->aTextBundle.nCharacterExpansion = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ }
+ break;
+ case 0x0d : ComOut( CGM_LEVEL1, "Character Spacing" )
+ {
+ if ( pElement->nAspectSourceFlags & ASF_CHARACTERSPACING )
+ pElement->pTextBundle->nCharacterSpacing = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ else
+ pElement->aTextBundle.nCharacterSpacing = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ }
+ break;
+ case 0x0e : ComOut( CGM_LEVEL1, "Text Color" )
+ {
+ if ( pElement->nAspectSourceFlags & ASF_TEXTCOLOR )
+ pElement->pTextBundle->SetColor( ImplGetBitmapColor() );
+ else
+ pElement->aTextBundle.SetColor( ImplGetBitmapColor() );
+ if ( mnMode & CGM_IMPORT_IM ) // PATCH
+ mnParaSize = mnElementSize;
+ }
+ break;
+ case 0x0f : ComOut( CGM_LEVEL1, "Character Height" )
+ {
+ if ( pElement->eVDCType == VDC_INTEGER )
+ pElement->nCharacterHeight = ImplGetI( pElement->nVDCIntegerPrecision );
+ else // ->floating points
+ pElement->nCharacterHeight = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ ImplMapDouble( pElement->nCharacterHeight );
+ pElement->nCharacterHeight /= 18.0;
+ }
+ break;
+ case 0x10 : ComOut( CGM_LEVEL1, "Character Orientation" )
+ {
+ if ( pElement->eVDCType == VDC_INTEGER )
+ {
+ pElement->nCharacterOrientation[0] = ImplGetI( pElement->nVDCIntegerPrecision );
+ pElement->nCharacterOrientation[1] = ImplGetI( pElement->nVDCIntegerPrecision );
+ pElement->nCharacterOrientation[2] = ImplGetI( pElement->nVDCIntegerPrecision );
+ pElement->nCharacterOrientation[3] = ImplGetI( pElement->nVDCIntegerPrecision );
+ }
+ else // ->floating points
+ {
+ pElement->nCharacterOrientation[0] = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ pElement->nCharacterOrientation[1] = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ pElement->nCharacterOrientation[2] = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ pElement->nCharacterOrientation[3] = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ }
+ }
+ break;
+ case 0x11 : ComOut( CGM_LEVEL1, "Text Path" )
+ {
+ switch( ImplGetUI16() )
+ {
+ case 0 : pElement->eTextPath = TPR_RIGHT; break;
+ case 1 : pElement->eTextPath = TPR_LEFT; break;
+ case 2 : pElement->eTextPath = TPR_UP; break;
+ case 3 : pElement->eTextPath = TPR_DOWN; break;
+ default : mbStatus = sal_False; break;
+ }
+ }
+ break;
+ case 0x12 : ComOut( CGM_LEVEL1, "Text Alignment" )
+ {
+ pElement->eTextAlignmentH = (TextAlignmentH)ImplGetUI16();
+ pElement->eTextAlignmentV = (TextAlignmentV)ImplGetUI16( 8 );
+ pElement->nTextAlignmentHCont = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ pElement->nTextAlignmentVCont = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ }
+ break;
+ case 0x13 : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Character Set Index" )
+ pElement->nCharacterSetIndex = ImplGetI( pElement->nIndexPrecision );
+ break;
+ case 0x14 : ComOut( CGM_LEVEL1 | CGM_DRAWING_PLUS_CONTROL_SET, "Alternate Character Set Index" )
+ pElement->nAlternateCharacterSetIndex = ImplGetI( pElement->nIndexPrecision );
+ break;
+ case 0x15 : ComOut( CGM_LEVEL1, "Fill Bundle Index" )
+ pElement->pFillBundle = (FillBundle*)pElement->GetBundleIndex( ImplGetI( pElement->nIndexPrecision ), pElement->aFillList, pElement->aFillBundle );
+ break;
+ case 0x16 : ComOut( CGM_LEVEL1, "Fill Interior Style" )
+ {
+ if ( pElement->nAspectSourceFlags & ASF_FILLINTERIORSTYLE )
+ pElement->pFillBundle->eFillInteriorStyle = (FillInteriorStyle)ImplGetUI16();
+ else
+ pElement->aFillBundle.eFillInteriorStyle = (FillInteriorStyle)ImplGetUI16();
+ }
+ break;
+ case 0x17 : ComOut( CGM_LEVEL1, "Fill Color" )
+ {
+ if ( pElement->nAspectSourceFlags & ASF_FILLCOLOR )
+ pElement->pFillBundle->SetColor( ImplGetBitmapColor() );
+ else
+ pElement->aFillBundle.SetColor( ImplGetBitmapColor() );
+ if ( mnMode & CGM_IMPORT_IM ) // PATCH
+ mnParaSize = mnElementSize;
+ }
+ break;
+ case 0x18 : ComOut( CGM_LEVEL1, "Fill Hatch Index" )
+ {
+ if ( pElement->nAspectSourceFlags & ASF_HATCHINDEX )
+ pElement->pFillBundle->nFillHatchIndex = ImplGetI( pElement->nIndexPrecision );
+ else
+ pElement->aFillBundle.nFillHatchIndex = ImplGetI( pElement->nIndexPrecision );
+ }
+ break;
+ case 0x19 : ComOut( CGM_LEVEL1, "Fill Pattern Index" )
+ {
+ if ( pElement->nAspectSourceFlags & ASF_PATTERNINDEX )
+ pElement->pFillBundle->nFillPatternIndex = ImplGetI( pElement->nIndexPrecision );
+ else
+ pElement->aFillBundle.nFillPatternIndex = ImplGetI( pElement->nIndexPrecision );
+ }
+ break;
+ case 0x1a : ComOut( CGM_LEVEL1, "Edge Bundle Index" )
+ pElement->pEdgeBundle = (EdgeBundle*)pElement->GetBundleIndex( ImplGetI( pElement->nIndexPrecision ), pElement->aEdgeList, pElement->aEdgeBundle );
+ break;
+ case 0x1b : ComOut( CGM_LEVEL1, "Edge Type" )
+ {
+ if ( pElement->nAspectSourceFlags & ASF_EDGETYPE )
+ pElement->pEdgeBundle->eEdgeType = (EdgeType)ImplGetI( pElement->nIndexPrecision );
+ else
+ pElement->aEdgeBundle.eEdgeType = (EdgeType)ImplGetI( pElement->nIndexPrecision );
+ }
+ break;
+ case 0x1c : ComOut( CGM_LEVEL1, "Edge Width" )
+ {
+ double nWidth;
+ if ( pElement->eEdgeWidthSpecMode == SM_ABSOLUTE )
+ {
+ if ( pElement->eVDCType == VDC_REAL )
+ nWidth = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
+ else
+ nWidth = (double)ImplGetI( pElement->nVDCIntegerPrecision );
+
+ ImplMapDouble( nWidth );
+ }
+ else
+ nWidth = (sal_uInt32)ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize ) * 25;
+ ( pElement->nAspectSourceFlags & ASF_EDGEWIDTH )
+ ? pElement->aEdgeBundle.nEdgeWidth = nWidth
+ : pElement->aEdgeBundle.nEdgeWidth = nWidth;
+ }
+ break;
+ case 0x1d : ComOut( CGM_LEVEL1, "Edge Color" )
+ {
+ if ( pElement->nAspectSourceFlags & ASF_EDGECOLOR )
+ pElement->pEdgeBundle->SetColor( ImplGetBitmapColor() );
+ else
+ pElement->aEdgeBundle.SetColor( ImplGetBitmapColor() );
+ if ( mnMode & CGM_IMPORT_IM ) // PATCH
+ mnParaSize = mnElementSize;
+ }
+ break;
+ case 0x1e : ComOut( CGM_LEVEL1, "Edge Visibility" )
+ {
+ switch( ImplGetUI16() )
+ {
+ case 0 : pElement->eEdgeVisibility = EV_OFF; break;
+ case 1 : pElement->eEdgeVisibility = EV_ON; break;
+ default : mbStatus = sal_False;
+ }
+ }
+ break;
+ case 0x1f : ComOut( CGM_LEVEL1, "Fill Reference Point" )
+ ImplGetPoint( pElement->aFillRefPoint );
+ break;
+ case 0x20 : ComOut( CGM_LEVEL1, "Pattern Table" ) break;
+ case 0x21 : ComOut( CGM_LEVEL1, "Pattern Size" ) break;
+ case 0x22 : ComOut( CGM_LEVEL1, "Color Table" )
+ {
+ sal_uInt32 nColorStartIndex = ImplGetUI( pElement->nColorIndexPrecision );
+ if ( ( nColorStartIndex > 255 ) ||
+ ( ( ( mnElementSize - pElement->nColorIndexPrecision ) % ( pElement->nColorPrecision * 3 ) ) != 0 ) )
+ {
+ mbStatus = sal_False;
+ }
+ else
+ {
+ sal_uInt32 nColors = ( mnElementSize - pElement->nColorIndexPrecision ) / ( 3 * pElement->nColorPrecision );
+ if ( nColors )
+ {
+ sal_uInt32 nMaxColorIndex = nColorStartIndex + nColors - 1;
+ sal_uInt32 nIndex;
+ if ( nMaxColorIndex > 255 )
+ {
+ mbStatus = sal_False;
+ }
+ else
+ {
+ if ( pElement->nLatestColorMaximumIndex < nMaxColorIndex )
+ pElement->nLatestColorMaximumIndex = nMaxColorIndex;
+
+ for ( nIndex = nColorStartIndex; nIndex <= nMaxColorIndex; nIndex++ )
+ {
+ pElement->aLatestColorTable[ nIndex ] = ImplGetBitmapColor( sal_True );
+ }
+ }
+ pElement->nColorMaximumIndex = pElement->nLatestColorMaximumIndex;
+ for ( nIndex = nColorStartIndex; nIndex <= nMaxColorIndex; nIndex++ )
+ {
+ if ( !pElement->aColorTableEntryIs[ nIndex ] )
+ {
+ pElement->aColorTableEntryIs[ nIndex ] = 1;
+ pElement->aColorTable[ nIndex ] = pElement->aLatestColorTable[ nIndex ];
+ }
+ }
+ }
+ }
+ }
+ break;
+ case 0x23 : ComOut( CGM_LEVEL1, "Aspect Source Flags" )
+ {
+ int nFlags = mnElementSize >> 2;
+ while ( nFlags-- > 0 )
+ {
+ sal_uInt32 nFlag = 0;
+ switch( ImplGetUI16() )
+ {
+ case 0 : nFlag = ASF_LINETYPE; break;
+ case 1 : nFlag = ASF_LINEWIDTH; break;
+ case 2 : nFlag = ASF_LINECOLOR; break;
+ case 3 : nFlag = ASF_MARKERTYPE; break;
+ case 4 : nFlag = ASF_MARKERSIZE; break;
+ case 5 : nFlag = ASF_MARKERCOLOR; break;
+ case 6 : nFlag = ASF_FILLINTERIORSTYLE; break;
+ case 7 : nFlag = ASF_HATCHINDEX; break;
+ case 8 : nFlag = ASF_PATTERNINDEX; break;
+ case 9 : nFlag = ASF_BITMAPINDEX; break;
+ case 10 : nFlag = ASF_FILLCOLOR; break;
+ case 11 : nFlag = ASF_EDGETYPE; break;
+ case 12 : nFlag = ASF_EDGEWIDTH; break;
+ case 13 : nFlag = ASF_EDGECOLOR; break;
+ case 14 : nFlag = ASF_TEXTFONTINDEX; break;
+ case 15 : nFlag = ASF_TEXTPRECISION; break;
+ case 16 : nFlag = ASF_CHARACTEREXPANSION; break;
+ case 17 : nFlag = ASF_CHARACTERSPACING; break;
+ case 18 : nFlag = ASF_TEXTCOLOR; break;
+ default : mbStatus = sal_False; break;
+ }
+ sal_uInt32 nASF = ImplGetUI16();
+ switch ( nASF )
+ {
+ case 0 : pElement->nAspectSourceFlags &= ~nFlag; break; // INDIVIDUAL
+ case 1 : pElement->nAspectSourceFlags |= nFlag; break; // BUNDLED
+ default : mbStatus = sal_False; break;
+ }
+ }
+ }
+ break;
+ case 0x24 : ComOut( CGM_LEVEL2, "Pick Identifier" ) break;
+ case 0x25 : ComOut( CGM_LEVEL3, "Line Cap" )
+ {
+ switch( ImplGetUI16() )
+ {
+ case 0 : pElement->eLineCapType = LCT_BUTT; break;
+ case 1 : pElement->eLineCapType = LCT_ROUND; break;
+ case 2 : pElement->eLineCapType = LCT_SQUARE; break;
+ case 3 : pElement->eLineCapType = LCT_TRIANGLE; break;
+ case 4 : pElement->eLineCapType = LCT_ARROW; break;
+ default : pElement->eLineCapType = LCT_NONE; break;
+ }
+ }
+ break;
+ case 0x26 : ComOut( CGM_LEVEL3, "Line Join" )
+ {
+ switch( ImplGetUI16() )
+ {
+ case 0 : pElement->eLineJoinType = LJT_MITER; break;
+ case 1 : pElement->eLineJoinType = LJT_ROUND; break;
+ case 2 : pElement->eLineJoinType = LJT_BEVEL; break;
+ default : pElement->eLineJoinType = LJT_NONE; break;
+ }
+ }
+ break;
+ case 0x27 : ComOut( CGM_LEVEL3, "Line Type Continuation" ) break; // NS
+ case 0x28 : ComOut( CGM_LEVEL3, "Line Type Initial Offset" ) break; // NS
+ case 0x29 : ComOut( CGM_LEVEL3, "Text Score Type" ) break;
+ case 0x2a : ComOut( CGM_LEVEL3, "Restricted Text Type" ) break;
+ case 0x2b : ComOut( CGM_LEVEL3, "Interpolated interior" ) break;
+ case 0x2c : ComOut( CGM_LEVEL3, "Edge Cap" ) break; // NS
+ case 0x2d : ComOut( CGM_LEVEL3, "Edge Join" ) break;
+ case 0x2e : ComOut( CGM_LEVEL3, "Edge Type Continuation" ) break; // NS
+ case 0x2f : ComOut( CGM_LEVEL3, "Edge Type Initial Offset" ) break; // NS
+ case 0x30 : ComOut( CGM_LEVEL3, "Symbol Library Index" ) break; // NS
+ case 0x31 : ComOut( CGM_LEVEL3, "Symbol Color" ) break; // NS
+ case 0x32 : ComOut( CGM_LEVEL3, "Symbol Size" ) break; // NS
+ case 0x33 : ComOut( CGM_LEVEL3, "Symbol Orientation" ) break; // NS
+ case 0x50 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Region Margins" ) break;
+ case 0x51 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Region Expansion" ) break;
+ case 0x52 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Region Anchor" ) break;
+ case 0x53 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Paragraph Horizontal Alignment" ) break;
+ case 0x54 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Paragraph Vertical Alignment" ) break;
+ case 0x55 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Line Flow" ) break;
+ case 0x60 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Paragraph Spacing" ) break;
+ case 0x61 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Paragraph Indent" ) break;
+ case 0x62 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Paragraph Tabs" ) break;
+ case 0x63 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Paragraph Bullets" ) break;
+ case 0x64 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Paragraph Bullet Level" ) break;
+ case 0x65 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Paragraph Line Horizontal Alignment" ) break;
+ case 0x66 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Paragraph Line Vertical Alignment" ) break;
+ case 0x67 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Paragragh Line Spacing" ) break;
+ case 0x68 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Paragraph Word Wrap" ) break;
+ case 0x70 : ComOut( CGM_UNKNOWN_LEVEL, "Block Text Forward Advance Distance" ) break;
+ case 0x71 : ComOut( CGM_UNKNOWN_LEVEL, "Word Spacing" ) break;
+ case 0x72 : ComOut( CGM_UNKNOWN_LEVEL, "External Leading" ) break;
+ case 0x7a : ComOut( CGM_UNKNOWN_LEVEL, "set Gradient Offset" )
+ {
+ long nHorzOffset = ImplGetI( pElement->nIndexPrecision );
+ long nVertOffset = ImplGetI( pElement->nIndexPrecision );
+ sal_uInt32 nType = ImplGetUI16();
+ mpOutAct->SetGradientOffset( nHorzOffset, nVertOffset, nType );
+ mnAct4PostReset |= ACT4_GRADIENT_ACTION;
+ }
+ break;
+ case 0x7b : ComOut( CGM_UNKNOWN_LEVEL, "set Gradient Edge" )
+ {
+// mpOutAct->SetGradientEdge( long nEdge );
+ mnAct4PostReset |= ACT4_GRADIENT_ACTION;
+ }
+ break;
+ case 0x7c : ComOut( CGM_UNKNOWN_LEVEL, "set Gradient Angle" )
+ {
+ mpOutAct->SetGradientAngle( ImplGetI( pElement->nIndexPrecision ) );
+ mnAct4PostReset |= ACT4_GRADIENT_ACTION;
+ }
+ break;
+ case 0x7d : ComOut( CGM_UNKNOWN_LEVEL, "set Gradient Description" )
+ {
+ long nStepDesignator = ImplGetI( pElement->nIndexPrecision );
+ sal_uInt32 nNumberOfStages = ImplGetI( pElement->nIndexPrecision );
+ sal_uInt32 i, nColorFrom = 0;
+ sal_uInt32 nColorTo = 0xffffff;
+
+ for ( i = 0; i < nNumberOfStages; i++ )
+ {
+ double aFloat = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ }
+ for ( i = 0; i <= nNumberOfStages; i++ )
+ {
+ sal_uInt32 nPara = mnParaSize + 24;
+ if ( i == 0 )
+ {
+ nColorTo = ImplGetBitmapColor();
+ nColorFrom = nColorTo ^ 0xffffff;
+ }
+ else if ( i == 1 )
+ nColorFrom = ImplGetBitmapColor();
+ mnParaSize = nPara;
+ }
+ if ( nNumberOfStages > 1 )
+ mpOutAct->SetGradientStyle( 0xff, 1 );
+
+ mpOutAct->SetGradientDescriptor( nColorFrom, nColorTo );
+ mnAct4PostReset |= ACT4_GRADIENT_ACTION;
+ }
+ break;
+ case 0x7e : ComOut( CGM_UNKNOWN_LEVEL, "set Gradient Style" )
+ {
+ sal_uInt32 nStyle = ImplGetUI16( 8 );
+ double fRatio = ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize );
+ mpOutAct->SetGradientStyle( nStyle, fRatio );
+ mnAct4PostReset |= ACT4_GRADIENT_ACTION;
+ }
+ break;
+ case 0xff : ComOut( CGM_GDSF_ONLY, "inquire Font metrics" ) break;
+ case 0xfe : ComOut( CGM_GDSF_ONLY, "inquire character widths" ) break;
+ case 0xfd : ComOut( CGM_GDSF_ONLY, "set Text Font" ) break;
+ case 0xfc : ComOut( CGM_GDSF_ONLY, "set current position" ) break;
+ case 0xfb : ComOut( CGM_GDSF_ONLY, "set current position mode" ) break;
+ case 0xfa : ComOut( CGM_GDSF_ONLY, "set character height mode" ) break;
+ case 0xf9 : ComOut( CGM_GDSF_ONLY, "set Transform matrix 2D" ) break;
+ case 0xf8 : ComOut( CGM_GDSF_ONLY, "set Transform matrix 3D" ) break;
+ case 0xf7 : ComOut( CGM_GDSF_ONLY, "pop transformation state" ) break;
+ case 0xf6 : ComOut( CGM_GDSF_ONLY, "clear transformation state" ) break;
+ case 0xf5 : ComOut( CGM_GDSF_ONLY, "set character widths" ) break;
+ case 0xf4 : ComOut( CGM_GDSF_ONLY, "set color name - for Pantone support" ) break;
+ default: ComOut( CGM_UNKNOWN_COMMAND, "" ) break;
+ }
+};
+
+
diff --git a/goodies/source/filter.vcl/icgm/class7.cxx b/goodies/source/filter.vcl/icgm/class7.cxx
new file mode 100644
index 000000000000..56e5bd048f4d
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/class7.cxx
@@ -0,0 +1,269 @@
+/*************************************************************************
+ *
+ * $RCSfile: class7.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <main.hxx>
+#include <chart.hxx>
+#include <outact.hxx>
+
+// ---------------------------------------------------------------
+
+void CGM::ImplDoClass7()
+{
+ switch ( mnElementID )
+ {
+ case 0x01 : ComOut( CGM_LEVEL1, "Message" ) break;
+ case 0x02 :
+ {
+ sal_uInt8* pAppData = mpSource + 12;
+ sal_uInt16* pTemp = (sal_uInt16*)mpSource;
+ sal_uInt16 nOpcode = pTemp[ 4 ];
+ sal_uInt16 nOpcSize = pTemp[ 5 ];
+
+ if ( mpChart || ( nOpcode == 0 ) )
+ {
+ switch ( nOpcode )
+ {
+ case 0x000 : ComOut( CGM_LEVEL1, "AppData - Beginning of File Opcodes" )
+ {
+ if ( mpChart == NULL )
+ mpChart = new CGMChart( *this );
+ mpChart->mnCurrentFileType = pAppData[ 3 ];
+ }
+ break;
+ case 0x001 : ComOut( CGM_LEVEL1, "AppData - End of File Opcodes" ) break;
+ case 0x190 : ComOut( CGM_LEVEL1, "AppData - FDESC" ) break;
+ case 0x192 : ComOut( CGM_LEVEL1, "AppData - FNOTES" ) break;
+ case 0x1F4 : ComOut( CGM_LEVEL1, "AppData - BOGENFILE" ) break;
+ case 0x1F5 : ComOut( CGM_LEVEL1, "AppData - EOGENFILE" ) break;
+ case 0x1F8 : ComOut( CGM_LEVEL1, "AppData - BOCHTGROUP" ) break;
+ case 0x1F9 : ComOut( CGM_LEVEL1, "AppData - EOCHTGROUP" ) break;
+ case 0x1FC : ComOut( CGM_LEVEL1, "AppData - BOCHTDATA" ) break;
+ case 0x1FD : ComOut( CGM_LEVEL1, "AppData - EOCHTDATA" )
+ {
+ mpOutAct->DrawChart();
+ }
+ break;
+ case 0x200 : ComOut( CGM_LEVEL1, "AppData - BOSYMGROUP" ) break;
+ case 0x201 : ComOut( CGM_LEVEL1, "AppData - EOSYMGROUP" ) break;
+ case 0x204 : ComOut( CGM_LEVEL1, "AppData - BEGSYMBOL" ) break;
+ case 0x205 : ComOut( CGM_LEVEL1, "AppData - ENDSYMBOL" ) break;
+ case 0x208 : ComOut( CGM_LEVEL1, "AppData - BOSHWGROUP" ) break;
+ case 0x209 : ComOut( CGM_LEVEL1, "AppData - EOSHWGROUP" ) break;
+ case 0x260 : ComOut( CGM_LEVEL1, "AppData - BEGGROUP" ) break;
+ case 0x262 : ComOut( CGM_LEVEL1, "AppData - ENDGROUP" ) break;
+ case 0x264 : ComOut( CGM_LEVEL1, "AppData - DATANODE" )
+ {
+ mpChart->mDataNode[ 0 ] = *(DataNode*)( pAppData );
+ sal_Int8 nZoneEnum = mpChart->mDataNode[ 0 ].nZoneEnum;
+ if ( nZoneEnum && ( nZoneEnum <= 6 ) )
+ mpChart->mDataNode[ nZoneEnum ] = *(DataNode*)( pAppData );
+ }
+ break;
+ case 0x2BE : ComOut( CGM_LEVEL1, "AppData - SHWSLIDEREC" )
+ {
+ if ( mnMode & CGM_EXPORT_IMPRESS )
+ {
+ if ( pAppData[ 16 ] == 0 ) // a blank template ?
+ {
+ if ( pAppData[ 2 ] == 46 )
+ {
+ // this starts the document -> maybe we could insert a new document
+ }
+ else if ( pAppData[ 2 ] & 0x80 )
+ {
+ // this is a template
+ }
+ else
+ {
+ mpOutAct->InsertPage();
+ }
+ }
+ mpChart->ResetAnnotation();
+ }
+ }
+ break;
+ case 0x2C0 : ComOut( CGM_LEVEL1, "AppData - SHWKEYTABLE" ) break;
+ case 0x2C2 : ComOut( CGM_LEVEL1, "AppData - SHWBUTTONTAB" ) break;
+ case 0x2C4 : ComOut( CGM_LEVEL1, "AppData - SHWGLOBAL" ) break;
+ case 0x2C6 : ComOut( CGM_LEVEL1, "AppData - SHWTITLE" ) break;
+ case 0x2CA : ComOut( CGM_LEVEL1, "AppData - SHWAPP" ) break;
+ case 0x320 : ComOut( CGM_LEVEL1, "AppData - TEXT" )
+ {
+ TextEntry* pTextEntry = new TextEntry;
+ pTextEntry->nTypeOfText = *((sal_uInt16*)( pAppData ) );
+ pTextEntry->nRowOrLineNum = *((sal_uInt16*)( pAppData + 2 ) );
+ pTextEntry->nColumnNum = *((sal_uInt16*)( pAppData + 4 ) );
+ sal_uInt16 nAttributes = *( (sal_uInt16*)( pAppData + 6 ) );
+ pTextEntry->nZoneSize = nAttributes & 0xff;
+ pTextEntry->nLineType = ( nAttributes >> 8 ) & 0xf;
+ nAttributes >>= 12;
+ pTextEntry->nAttributes = nAttributes;
+ pAppData += 8;
+ sal_uInt32 nLen = strlen( (char*)( pAppData ) ) + 1;
+ pTextEntry->pText = new char[ nLen ];
+ memcpy( pTextEntry->pText, pAppData, nLen );
+ pAppData += nLen;
+
+ TextAttribute* pTextOld;
+ for ( sal_uInt16 i = 0; i < nAttributes; i++ )
+ {
+ TextAttribute* pTextAttr = new TextAttribute;
+
+ *pTextAttr = *(TextAttribute*)( pAppData );
+
+ pTextAttr->pNextAttribute = NULL;
+ if ( i == 0 )
+ pTextEntry->pAttribute = pTextAttr;
+ else
+ pTextOld->pNextAttribute = pTextAttr;
+
+ pAppData += sizeof( TextAttribute ) - 4;
+ pTextOld = pTextAttr;
+ }
+ mpChart->InsertTextEntry( pTextEntry );
+ }
+ break;
+ case 0x321 : ComOut( CGM_LEVEL1, "AppData - IOC_TABS" ) break;
+ case 0x322 : ComOut( CGM_LEVEL1, "AppData - CHARTZONE" )
+ {
+ mpChart->mChartZone = *( ChartZone* )( pAppData );
+ }
+ break;
+ case 0x324 : ComOut( CGM_LEVEL1, "AppData - TITLEZONE" ) break;
+ case 0x328 : ComOut( CGM_LEVEL1, "AppData - FOOTNOTEZONE" ) break;
+ case 0x32A : ComOut( CGM_LEVEL1, "AppData - LEGENDZONE" ) break;
+ case 0x330 : ComOut( CGM_LEVEL1, "AppData - PAGEORIENTDIM" )
+ {
+ mpChart->mPageOrientDim = *( PageOrientDim*)( pAppData );
+ }
+ break;
+ case 0x334 : ComOut( CGM_LEVEL1, "AppData - CHTZONEOPTN" )
+ {
+ mpChart->mZoneOption = *( ZoneOption*)( pAppData );
+ }
+ break;
+ case 0x336 : ComOut( CGM_LEVEL1, "AppData - CHTINTL" )
+ {
+ mpChart->mIntSettings = *( IntSettings*)( pAppData );
+ }
+ break;
+ case 0x338 : ComOut( CGM_LEVEL1, "AppData - CHTLINESPC" ) break;
+ case 0x384 : ComOut( CGM_LEVEL1, "AppData - ORGGRIDSTATE" ) break;
+ case 0x386 : ComOut( CGM_LEVEL1, "AppData - ORGSCRSTATE" ) break;
+ case 0x388 : ComOut( CGM_LEVEL1, "AppData - ORGTREESTATE" ) break;
+ case 0x38A : ComOut( CGM_LEVEL1, "AppData - ORGTEXTOPTN" ) break;
+ case 0x38E : ComOut( CGM_LEVEL1, "AppData - ORGBOXOPTN" ) break;
+ case 0x390 : ComOut( CGM_LEVEL1, "AppData - ORGBOXDIM" ) break;
+ case 0x392 : ComOut( CGM_LEVEL1, "AppData - ORGBOX" ) break;
+ case 0x3EA : ComOut( CGM_LEVEL1, "AppData - TTLTEXTOPTN" ) break;
+ case 0x3EE : ComOut( CGM_LEVEL1, "AppData - TTLAUTOBUILD" ) break;
+ case 0x44E : ComOut( CGM_LEVEL1, "AppData - BULTEXTOPTN" ) break;
+ case 0x452 : ComOut( CGM_LEVEL1, "AppData - BULLETOPTN" )
+ {
+ mpChart->mBulletOption = *( BulletOption*)( pAppData );
+ }
+ break;
+ case 0x454 : ComOut( CGM_LEVEL1, "AppData - BULLETLINES" )
+ {
+ mpChart->mBulletLines = *( BulletLines*)( pAppData );
+ }
+ break;
+ case 0x456 : ComOut( CGM_LEVEL1, "AppData - BULAUTOBUILD" ) break;
+ case 0x4B2 : ComOut( CGM_LEVEL1, "AppData - TBLTEXTOPTN" ) break;
+ case 0x4B6 : ComOut( CGM_LEVEL1, "AppData - TBLOPTN" ) break;
+ case 0x4B8 : ComOut( CGM_LEVEL1, "AppData - TBLCOLOPTN" ) break;
+ case 0x4BA : ComOut( CGM_LEVEL1, "AppData - TBLLEGENDOPTN" ) break;
+ case 0x4BC : ComOut( CGM_LEVEL1, "AppData - TBLRANGEOPTN" ) break;
+ case 0x4BE : ComOut( CGM_LEVEL1, "AppData - TBLROWOPTN" ) break;
+ case 0x4C0 : ComOut( CGM_LEVEL1, "AppData - TBLAUTOBUILD" ) break;
+ case 0x518 : ComOut( CGM_LEVEL1, "AppData - PIECHARTOPTN" ) break;
+ case 0x51A : ComOut( CGM_LEVEL1, "AppData - PIELEGENDOPTN" ) break;
+ case 0x51C : ComOut( CGM_LEVEL1, "AppData - PIETEXTOPTN" ) break;
+ case 0x51E : ComOut( CGM_LEVEL1, "AppData - PIEOPTN" ) break;
+ case 0x520 : ComOut( CGM_LEVEL1, "AppData - PIEPCTLABOPTN" ) break;
+ case 0x522 : ComOut( CGM_LEVEL1, "AppData - PIEVALLABOPTN" ) break;
+ case 0x524 : ComOut( CGM_LEVEL1, "AppData - PIESLICE" ) break;
+ case 0x57A : ComOut( CGM_LEVEL1, "AppData - XYAXISOPTN" ) break;
+ case 0x57C : ComOut( CGM_LEVEL1, "AppData - XYGRIDOPTN" ) break;
+ case 0x57D : ComOut( CGM_LEVEL1, "AppData - XYGRIDSHOWFILL" ) break;
+ case 0x57E : ComOut( CGM_LEVEL1, "AppData - XYSERIESOPTN" ) break;
+ case 0x580 : ComOut( CGM_LEVEL1, "AppData - XYSTYLEOPTN" ) break;
+ case 0x582 : ComOut( CGM_LEVEL1, "AppData - XYTABLEOPTN" ) break;
+ case 0x584 : ComOut( CGM_LEVEL1, "AppData - XYTEXTOPTN" ) break;
+ case 0x586 : ComOut( CGM_LEVEL1, "AppData - XYDATAOPTN" ) break;
+ case 0x58A : ComOut( CGM_LEVEL1, "AppData - XYLEGENDOPN" ) break;
+ case 0x58C : ComOut( CGM_LEVEL1, "AppData - XYCALCULATION" ) break;
+ case 0x58E : ComOut( CGM_LEVEL1, "AppData - XYXVALUE" ) break;
+ case 0x590 : ComOut( CGM_LEVEL1, "AppData - XYYVALUE" ) break;
+ case 0x592 : ComOut( CGM_LEVEL1, "AppData - XYXEXTVALUE" ) break;
+ case 0x618 : ComOut( CGM_LEVEL1, "AppData - IOC_CHTCOLRTAB" ) break;
+ case 0x619 : ComOut( CGM_LEVEL1, "AppData - IOC_CHTFONTTAB" ) break;
+ case 0x1fff : ComOut( CGM_LEVEL1, "AppData - 0x1fff" ) break;
+ default : ComOut( CGM_LEVEL1, "UNKNOWN Application Data" ) break;
+ }
+ }
+ mnParaSize = mnElementSize;
+ break;
+ }
+ default: ComOut( CGM_UNKNOWN_COMMAND, "" ) break;
+ }
+};
+
diff --git a/goodies/source/filter.vcl/icgm/classx.cxx b/goodies/source/filter.vcl/icgm/classx.cxx
new file mode 100644
index 000000000000..a5d7312c36c7
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/classx.cxx
@@ -0,0 +1,322 @@
+/*************************************************************************
+ *
+ * $RCSfile: classx.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <main.hxx>
+#include <outact.hxx>
+
+// ---------------------------------------------------------------
+
+#define ImplSetUnderlineMode() \
+ \
+ sal_uInt32 nMode = ImplGetUI16(); \
+ switch ( nMode ) \
+ { \
+ case 1 : pElement->eUnderlineMode = UM_LOW; break; \
+ case 2 : pElement->eUnderlineMode = UM_HIGH; break; \
+ case 4 : pElement->eUnderlineMode = UM_STRIKEOUT; break;\
+ case 8 : pElement->eUnderlineMode = UM_OVERSCORE; break;\
+ default: pElement->eUnderlineMode = UM_OFF; break; \
+ } \
+ pElement->nUnderlineColor = ImplGetBitmapColor(); \
+ if ( mnMode & CGM_IMPORT_IM ) \
+ mnParaSize = mnElementSize;
+
+// ---------------------------------------------------------------
+
+void CGM::ImplDoClass6()
+{
+ switch ( mnElementID )
+ {
+ case 0x01 : ComOut( CGM_LEVEL1, "Escape" )
+ {
+// if ( mnMode & CGM_IMPORT_IM ) // IMAGE MARK ONLY ????
+ {
+ long nIdentifier = ImplGetI( pElement->nIntegerPrecision );
+ switch ( nIdentifier )
+ {
+ case 0 : ComOut( CGM_DESCRIPTION, "inquire function support" ) break;
+ case -1 : ComOut( CGM_DESCRIPTION, "set underline mode" )
+ {
+ ImplSetUnderlineMode()
+ }
+ break;
+ case -2 : ComOut( CGM_DESCRIPTION, "set script mode" ) break;
+ case -3 : ComOut( CGM_DESCRIPTION, "set shadow mode" ) break;
+ case -6 : ComOut( CGM_DESCRIPTION, "inquire origin offset" ) break;
+ case -8 : ComOut( CGM_DESCRIPTION, "set media size" ) break;
+ case -10 : ComOut( CGM_DESCRIPTION, "set character mode" ) break;
+ case -14 : ComOut( CGM_DESCRIPTION, "resolution mode" ) break;
+ case -17 : ComOut( CGM_DESCRIPTION, "line cap" ) break;
+ case -18 : ComOut( CGM_DESCRIPTION, "line join" ) break;
+ case -19 : ComOut( CGM_DESCRIPTION, "edge join" ) break;
+ case -30 : ComOut( CGM_DESCRIPTION, "media type" ) break;
+ case -31 : ComOut( CGM_DESCRIPTION, "number of copies" ) break;
+ case -32 : ComOut( CGM_DESCRIPTION, "orientation" ) break;
+ case -33 : ComOut( CGM_DESCRIPTION, "device color representation" ) break;
+ case -34 : ComOut( CGM_DESCRIPTION, "device font list" ) break;
+ case -35 : ComOut( CGM_DESCRIPTION, "color reversal mode" ) break;
+ case -36 : ComOut( CGM_DESCRIPTION, "line cap attributes" ) break;
+ case -37 : ComOut( CGM_DESCRIPTION, "begin effect" ) break;
+ case -38 : ComOut( CGM_DESCRIPTION, "end effect" ) break;
+ case -39 : ComOut( CGM_DESCRIPTION, "begin effect definition" ) break;
+ case -40 : ComOut( CGM_DESCRIPTION, "end effect definition" ) break;
+ case -41 : ComOut( CGM_DESCRIPTION, "end style definition" ) break;
+ case -42 : ComOut( CGM_DESCRIPTION, "begin eps data" ) break;
+ case -43 : ComOut( CGM_DESCRIPTION, "eps data" ) break;
+ case -44 : ComOut( CGM_DESCRIPTION, "end eps data" ) break;
+ case -45 : ComOut( CGM_DESCRIPTION, "set background style" ) break;
+ case -46 : ComOut( CGM_DESCRIPTION, "set eps mode" ) break;
+ case -47 : ComOut( CGM_DESCRIPTION, "fill mode" ) break;
+ case -48 : ComOut( CGM_DESCRIPTION, "begin symbol" ) break;
+ case -49 : ComOut( CGM_DESCRIPTION, "end symbol" ) break;
+ case -50 : ComOut( CGM_DESCRIPTION, "begin layer" ) break;
+ case -51 : ComOut( CGM_DESCRIPTION, "end layer" ) break;
+ case -52 : ComOut( CGM_DESCRIPTION, "layer visibility" ) break;
+ case -53 : ComOut( CGM_DESCRIPTION, "inquire foreign data" ) break;
+ case -54 : ComOut( CGM_DESCRIPTION, "set text offset" ) break;
+ case -55 : ComOut( CGM_DESCRIPTION, "begin group" ) break;
+ case -56 : ComOut( CGM_DESCRIPTION, "end group" ) break;
+ case -100 : ComOut( CGM_DESCRIPTION, "begin patch" ) break;
+ case -101 : ComOut( CGM_DESCRIPTION, "end patch" ) break;
+ case -102 : ComOut( CGM_DESCRIPTION, "begin block text region" ) break;
+ case -103 : ComOut( CGM_DESCRIPTION, "end block text region" ) break;
+ case -120 : ComOut( CGM_DESCRIPTION, "region margins" ) break;
+ case -121 : ComOut( CGM_DESCRIPTION, "region expansions" ) break;
+ case -122 : ComOut( CGM_DESCRIPTION, "region anchor" ) break;
+ case -123 : ComOut( CGM_DESCRIPTION, "paragraph horizontal align" ) break;
+ case -124 : ComOut( CGM_DESCRIPTION, "paragraph vertical align" ) break;
+ case -125 : ComOut( CGM_DESCRIPTION, "region line flow" ) break;
+ case -130 : ComOut( CGM_DESCRIPTION, "paragraph spacing" ) break;
+ case -131 : ComOut( CGM_DESCRIPTION, "paragraph identation" ) break;
+ case -132 : ComOut( CGM_DESCRIPTION, "paragraph tabs" ) break;
+ case -133 : ComOut( CGM_DESCRIPTION, "paragraph bullet" ) break;
+ case -134 : ComOut( CGM_DESCRIPTION, "paragraph bulet level" ) break;
+ case -135 : ComOut( CGM_DESCRIPTION, "line horuzontal align" ) break;
+ case -136 : ComOut( CGM_DESCRIPTION, "line vertical align" ) break;
+ case -137 : ComOut( CGM_DESCRIPTION, "line spacing" ) break;
+ case -138 : ComOut( CGM_DESCRIPTION, "word wrap" ) break;
+ case -150 : ComOut( CGM_DESCRIPTION, "forward advance distance" ) break;
+ case -151 : ComOut( CGM_DESCRIPTION, "word spacing" ) break;
+ case -152 : ComOut( CGM_DESCRIPTION, "external leading" ) break;
+ case -160 : ComOut( CGM_DESCRIPTION, "set gradient offset" ) break;
+ case -161 : ComOut( CGM_DESCRIPTION, "set gradient edge" ) break;
+ case -162 : ComOut( CGM_DESCRIPTION, "set gradient angle" ) break;
+ case -163 : ComOut( CGM_DESCRIPTION, "set gradient description" ) break;
+ case -164 : ComOut( CGM_DESCRIPTION, "set gradient style" ) break;
+ case -165 : ComOut( CGM_DESCRIPTION, "set back ground style" ) break;
+ case -170 : ComOut( CGM_DESCRIPTION, "geometric pattern draw style" ) break;
+ case -190 : ComOut( CGM_DESCRIPTION, "set character width" ) break;
+ case -191 : ComOut( CGM_DESCRIPTION, "hyperlink definitions" ) break;
+ case -192 : ComOut( CGM_DESCRIPTION, "set color name for pantone" ) break;
+ case -32746 : ComOut( CGM_DESCRIPTION, "set text font" ) break;
+ case -32747 : ComOut( CGM_DESCRIPTION, "font selection mode" ) break;
+ case -32752 : ComOut( CGM_DESCRIPTION, "connecting edge" ) break;
+ case -32753 : ComOut( CGM_DESCRIPTION, "set drawing mode" ) break;
+ case -32754 : ComOut( CGM_DESCRIPTION, "inquire clip rectangle" ) break;
+ case -32755 : ComOut( CGM_DESCRIPTION, "protection region indicator" ) break;
+ case -32756 : ComOut( CGM_DESCRIPTION, "end protection region" ) break;
+ case -32757 : ComOut( CGM_DESCRIPTION, "begin protection region" ) break;
+ case -32758 : ComOut( CGM_DESCRIPTION, "geometric pattern definition" ) break;
+ case -32759 : ComOut( CGM_DESCRIPTION, "hatch style definition" ) break;
+ case -32760 : ComOut( CGM_DESCRIPTION, "close figure" ) break;
+ case -32761 : ComOut( CGM_DESCRIPTION, "end figure" )
+ {
+ mpOutAct->EndFigure();
+ mbFigure = sal_False;
+ }
+ break;
+ case -32762 : ComOut( CGM_DESCRIPTION, "begin figure" )
+ {
+ mbFigure = sal_True;
+ mpOutAct->BeginFigure();
+ }
+ break;
+ case -32763 : ComOut( CGM_DESCRIPTION, "pop transformatin" ) break;
+ case -32764 : ComOut( CGM_DESCRIPTION, "push transformation" ) break;
+ case -32765 : ComOut( CGM_DESCRIPTION, "copy segment" ) break;
+ case -32766 : ComOut( CGM_DESCRIPTION, "endseg" ) break;
+ case -32767 : ComOut( CGM_DESCRIPTION, "begin segment" ) break;
+ default : ComOut( CGM_DESCRIPTION, "????????????????????????????????" ) break;
+ }
+ mnParaSize = mnElementSize;
+
+ }
+ }
+ break;
+ case 0x02 : ComOut( CGM_LEVEL1, "Get Escape" ) break;
+ case 0x11 : ComOut( CGM_GDSF_ONLY, "Set Underline Mode" )
+ {
+ ImplSetUnderlineMode();
+ }
+ break;
+ case 0x12 : ComOut( CGM_GDSF_ONLY, "Set Script Mode" ) break;
+ case 0x13 : ComOut( CGM_GDSF_ONLY, "Set Shadow Mode" ) break;
+ case 0x18 : ComOut( CGM_GDSF_ONLY, "Set Media Size" ) break;
+ case 0x20 : ComOut( CGM_GDSF_ONLY, "Set Character Mode" ) break;
+ case 0x24 : ComOut( CGM_GDSF_ONLY, "Resolution Mode" ) break;
+ case 0x27 : ComOut( CGM_GDSF_ONLY, "Line Cap" ) break;
+ case 0x28 : ComOut( CGM_GDSF_ONLY, "Line Join" ) break;
+ case 0x29 : ComOut( CGM_GDSF_ONLY, "Edge Join" ) break;
+ case 0x40 : ComOut( CGM_GDSF_ONLY, "Media Type" ) break;
+ case 0x41 : ComOut( CGM_GDSF_ONLY, "Number of Copies" ) break;
+ case 0x42 : ComOut( CGM_GDSF_ONLY, "Origin" ) break;
+ case 0x45 : ComOut( CGM_GDSF_ONLY, "Color Reversal Mode" ) break;
+ case 0x46 : ComOut( CGM_GDSF_ONLY, "Line Cap Attributes" ) break;
+ case 0x49 : ComOut( CGM_GDSF_ONLY, "Begin Effect Definition" ) break;
+ case 0x50 : ComOut( CGM_GDSF_ONLY, "End Effect Definition" ) break;
+ case 0x51 : ComOut( CGM_GDSF_ONLY, "Line End Style Attributes" ) break;
+ case 0x52 : ComOut( CGM_GDSF_ONLY, "Begin Data" ) break;
+ case 0x53 : ComOut( CGM_GDSF_ONLY, "Data" ) break;
+ case 0x54 : ComOut( CGM_GDSF_ONLY, "End Data" ) break;
+ case 0x55 : ComOut( CGM_GDSF_ONLY, "Set Background Style" ) break;
+ case 0x56 : ComOut( CGM_GDSF_ONLY, "Set EPS Mode" ) break;
+ case 0x57 : ComOut( CGM_GDSF_ONLY, "Fill Mode" ) break;
+ case 0x58 : ComOut( CGM_GDSF_ONLY, "Begin Symbol" ) break;
+ case 0x59 : ComOut( CGM_GDSF_ONLY, "End Symbol" ) break;
+ case 0x60 : ComOut( CGM_GDSF_ONLY, "Begin Layer" ) break;
+ case 0x61 : ComOut( CGM_GDSF_ONLY, "End Layer" ) break;
+ case 0x62 : ComOut( CGM_GDSF_ONLY, "Layer Visibility" ) break;
+ case 0x64 : ComOut( CGM_GDSF_ONLY, "Set Text Offset" ) break;
+ case 0xFF : ComOut( CGM_GDSF_ONLY, "Inquire Function Support" ) break;
+ case 0xFE : ComOut( CGM_GDSF_ONLY, "Inquire Origin" ) break;
+ case 0xFD : ComOut( CGM_GDSF_ONLY, "Inquire Foreign Data Mode" ) break;
+ case 0xFC : ComOut( CGM_GDSF_ONLY, "Inquire Text Extent" ) break;
+ case 0xFB : ComOut( CGM_GDSF_ONLY, "Inquire DPI" ) break;
+ default: ComOut( CGM_UNKNOWN_COMMAND, "" ) break;
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGM::ImplDoClass8()
+{
+ switch ( mnElementID )
+ {
+ case 0x01 : ComOut( CGM_LEVEL2, "Copy Segment" ) break; // NS
+ case 0x02 : ComOut( CGM_LEVEL2, "Inheritance Filter" ) break; // NS
+ case 0x03 : ComOut( CGM_LEVEL2, "Clip Inheritance" ) break; // NS
+ case 0x04 : ComOut( CGM_LEVEL2, "Segment Transformation" ) break;
+ case 0x05 : ComOut( CGM_LEVEL2, "Segment HighLighting" ) break; // NS
+ case 0x06 : ComOut( CGM_LEVEL2, "Segment Display Priority" ) break; // NS
+ case 0x07 : ComOut( CGM_LEVEL2, "Segment Pick Priority" ) break; // NS
+ case 0xfe : ComOut( CGM_GDSF_ONLY, "INQ Current Position" ) break;
+ case 0xff : ComOut( CGM_GDSF_ONLY, "INQ Inserted Object Extent" ) break;
+ default: ComOut( CGM_UNKNOWN_COMMAND, "" ) break; // NS
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGM::ImplDoClass9()
+{
+ switch ( mnElementID )
+ {
+ case 0x01 : ComOut( CGM_UNKNOWN_LEVEL, "Pixel Array" ) break; // NS
+ case 0x02 : ComOut( CGM_UNKNOWN_LEVEL, "Create Bitmap" ) break; // NS
+ case 0x03 : ComOut( CGM_UNKNOWN_LEVEL, "Delete Bitmap" ) break; // NS
+ case 0x04 : ComOut( CGM_UNKNOWN_LEVEL, "Select Drawing Bitmap" ) break; // NS
+ case 0x05 : ComOut( CGM_UNKNOWN_LEVEL, "Display Bitmap" ) break; // NS
+ case 0x06 : ComOut( CGM_UNKNOWN_LEVEL, "Drawing Mode" ) break;
+ case 0x07 : ComOut( CGM_UNKNOWN_LEVEL, "Mapped Bitmap ForeGrnd Color" ) break; // NS
+ case 0x08 : ComOut( CGM_UNKNOWN_LEVEL, "Fill Bitmap" ) break; // NS
+ case 0x09 : ComOut( CGM_UNKNOWN_LEVEL, "Two Operand BitBlt" ) break; // NS
+ case 0x0a : ComOut( CGM_UNKNOWN_LEVEL, "Three Operand BitBlt" ) break; // NS
+ default: ComOut( CGM_UNKNOWN_COMMAND, "" ) break;
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGM::ImplDoClass15()
+{
+ switch ( mnElementID )
+ {
+ case 0x01 : ComOut( CGM_UNKNOWN_LEVEL, "Inquire Error Stack" ) break;
+ case 0x02 : ComOut( CGM_UNKNOWN_LEVEL, "Pop Error Stack" ) break;
+ case 0x03 : ComOut( CGM_UNKNOWN_LEVEL, "Empty Error Stack" ) break;
+ default: ComOut( CGM_UNKNOWN_COMMAND, "" ) break;
+ }
+};
+
+// ---------------------------------------------------------------
+
+void CGM::ImplDoClass16()
+{
+ switch ( mnElementID )
+ {
+ case 0x82 : ComOut( CGM_GDSF_ONLY, "Inquire Device Supported" ) break;
+ case 0x83 : ComOut( CGM_GDSF_ONLY, "Inquire Device Category" ) break;
+ case 0x84 : ComOut( CGM_GDSF_ONLY, "Inquire Device Type" ) break;
+ case 0x85 : ComOut( CGM_GDSF_ONLY, "Inquire Text Extent" ) break;
+ case 0x86 : ComOut( CGM_GDSF_ONLY, "Inquire Append Text Extent" ) break;
+ case 0x87 : ComOut( CGM_GDSF_ONLY, "Inquire Circle Extent" ) break;
+ case 0x88 : ComOut( CGM_GDSF_ONLY, "Inquire Circle Arc 3 Pt Extent" ) break;
+ case 0x89 : ComOut( CGM_GDSF_ONLY, "Inquire Circle Arc 3 Pt Close Extent" ) break;
+ case 0x8a : ComOut( CGM_GDSF_ONLY, "Inquire Circle Arc Centre Extent" ) break;
+ case 0x8b : ComOut( CGM_GDSF_ONLY, "Inquire Circle Arc Centre Close Extent" ) break;
+ case 0x8c : ComOut( CGM_GDSF_ONLY, "Inquire Ellipse Extent" ) break;
+ case 0x8d : ComOut( CGM_GDSF_ONLY, "Inquire Ellipse Arc Extent" ) break;
+ case 0x8e : ComOut( CGM_GDSF_ONLY, "Inquire Ellipse Arc Close Extent" ) break;
+ default: ComOut( CGM_UNKNOWN_COMMAND, "" ) break;
+ }
+};
+
+
diff --git a/goodies/source/filter.vcl/icgm/elements.cxx b/goodies/source/filter.vcl/icgm/elements.cxx
new file mode 100644
index 000000000000..05c546a971db
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/elements.cxx
@@ -0,0 +1,436 @@
+/*************************************************************************
+ *
+ * $RCSfile: elements.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "elements.hxx"
+
+// ---------------------------------------------------------------
+
+
+CGMElements::CGMElements( CGM& rCGM ) :
+ mpCGM ( &rCGM )
+{
+ Init();
+};
+
+// ---------------------------------------------------------------
+
+CGMElements::~CGMElements()
+{
+ DeleteTable( aHatchTable );
+ DeleteAllBundles( aLineList );
+ DeleteAllBundles( aMarkerList );
+ DeleteAllBundles( aEdgeList );
+ DeleteAllBundles( aTextList );
+ DeleteAllBundles( aFillList );
+}
+
+// ---------------------------------------------------------------
+
+CGMElements& CGMElements::operator=( CGMElements& rSource )
+{
+ sal_uInt32 nIndex;
+
+ nVDCIntegerPrecision = rSource.nVDCIntegerPrecision;
+ nIntegerPrecision = rSource.nIntegerPrecision;
+ eRealPrecision = rSource.eRealPrecision;
+ nRealSize = rSource.nRealSize;
+ nIndexPrecision = rSource.nIndexPrecision;
+ nColorPrecision = rSource.nColorPrecision;
+ nColorIndexPrecision = rSource.nColorIndexPrecision;
+
+ nMetaFileVersion = rSource.nMetaFileVersion;
+ eScalingMode = rSource.eScalingMode;
+ nScalingFactor = rSource.nScalingFactor;
+ eVDCType = rSource.eVDCType;
+ eVDCRealPrecision = rSource.eVDCRealPrecision;
+ nVDCRealSize = rSource.nVDCRealSize;
+ aVDCExtent = rSource.aVDCExtent;
+ aVDCExtentMaximum = rSource.aVDCExtentMaximum;
+ eDeviceViewPortMode = rSource.eDeviceViewPortMode;
+ nDeviceViewPortScale = rSource.nDeviceViewPortScale;
+ eDeviceViewPortMap = rSource.eDeviceViewPortMap;
+ eDeviceViewPortMapH = rSource.eDeviceViewPortMapH;
+ eDeviceViewPortMapV = rSource.eDeviceViewPortMapV;
+ aDeviceViewPort = rSource.aDeviceViewPort;
+ nMitreLimit = rSource.nMitreLimit;
+ eClipIndicator = rSource.eClipIndicator;
+ aClipRect = rSource.aClipRect;
+ eColorSelectionMode = rSource.eColorSelectionMode;
+ eColorModel = rSource.eColorModel;
+ nColorMaximumIndex = rSource.nColorMaximumIndex;
+ nLatestColorMaximumIndex = rSource.nLatestColorMaximumIndex;
+
+ for ( nIndex = 1; nIndex < 256; nIndex++ ) // do not overwrite the background color
+ {
+ aColorTableEntryIs[ nIndex ] = rSource.aColorTableEntryIs[ nIndex ];
+ aColorTable[ nIndex ] = rSource.aColorTable[ nIndex ];
+ aLatestColorTable[ nIndex ] = rSource.aColorTable[ nIndex ];
+ }
+
+ for ( nIndex = 0; nIndex < 8; nIndex++ )
+ {
+ nColorValueExtent[ nIndex ] = rSource.nColorValueExtent[ nIndex ];
+ }
+ nAspectSourceFlags = rSource.nAspectSourceFlags;
+
+ CopyAllBundles( rSource.aLineList, aLineList );
+ aLineBundle = rSource.aLineBundle;
+ pLineBundle = (LineBundle*)GetBundle( aLineList, rSource.pLineBundle->GetIndex() );
+ eLineWidthSpecMode = rSource.eLineWidthSpecMode;
+ eLineCapType = rSource.eLineCapType;
+ eLineJoinType = rSource.eLineJoinType;
+
+ CopyAllBundles( rSource.aMarkerList, aMarkerList );
+ aMarkerBundle = rSource.aMarkerBundle;
+ pMarkerBundle = (MarkerBundle*)GetBundle( aMarkerList, rSource.pMarkerBundle->GetIndex() );
+ eMarkerSizeSpecMode = rSource.eMarkerSizeSpecMode;
+
+ CopyAllBundles( rSource.aEdgeList, aEdgeList );
+ aEdgeBundle = rSource.aEdgeBundle;
+ pEdgeBundle = (EdgeBundle*)GetBundle( aEdgeList, rSource.pEdgeBundle->GetIndex() );
+ eEdgeVisibility = rSource.eEdgeVisibility;
+ eEdgeWidthSpecMode = rSource.eEdgeWidthSpecMode;
+
+ CopyAllBundles( rSource.aTextList, aTextList );
+ aTextBundle = rSource.aTextBundle;
+ pTextBundle = (TextBundle*)GetBundle( aTextList, rSource.pTextBundle->GetIndex() );
+ nCharacterHeight = rSource.nCharacterHeight;
+ nCharacterOrientation[ 0 ] = rSource.nCharacterOrientation[ 0 ];
+ nCharacterOrientation[ 1 ] = rSource.nCharacterOrientation[ 1 ];
+ nCharacterOrientation[ 2 ] = rSource.nCharacterOrientation[ 2 ];
+ nCharacterOrientation[ 3 ] = rSource.nCharacterOrientation[ 3 ];
+ eUnderlineMode = rSource.eUnderlineMode;
+ nUnderlineColor = rSource.nUnderlineColor;
+ eTextPath = rSource.eTextPath;
+ eTextAlignmentH = rSource.eTextAlignmentH;
+ eTextAlignmentV = rSource.eTextAlignmentV;
+ nTextAlignmentHCont = rSource.nTextAlignmentHCont;
+ nTextAlignmentVCont = rSource.nTextAlignmentVCont;
+ nCharacterSetIndex = rSource.nCharacterSetIndex;
+ nAlternateCharacterSetIndex = rSource.nAlternateCharacterSetIndex;
+ aFontList = rSource.aFontList;
+ eCharacterCodingA = rSource.eCharacterCodingA;
+
+ CopyAllBundles( rSource.aFillList, aFillList );
+ aFillBundle = rSource.aFillBundle;
+ pFillBundle = (FillBundle*)GetBundle( aFillList, rSource.pFillBundle->GetIndex() );
+ aFillRefPoint = rSource.aFillRefPoint;
+ eTransparency = rSource.eTransparency;
+ nAuxiliaryColor = rSource.nAuxiliaryColor;
+
+ DeleteTable( aHatchTable );
+ void* pSource = rSource.aHatchTable.First();
+ while ( pSource )
+ {
+ sal_uInt32 nKey = rSource.aHatchTable.GetKey( pSource );
+ void* pDest = new sal_Int8[ sizeof( HatchEntry ) ];
+ memcpy( pDest, pSource, sizeof( HatchEntry ) );
+ aHatchTable.Insert( nKey, pDest );
+ pSource = rSource.aHatchTable.Next();
+ }
+ bSegmentCount = rSource.bSegmentCount;
+ return (*this);
+}
+
+// ---------------------------------------------------------------
+
+void CGMElements::Init()
+{
+
+ if ( mpCGM->mnMode & CGM_IMPORT_IM ) // IMAGE MARK is device dependent !!!
+ {
+ nIntegerPrecision = nIndexPrecision = nColorIndexPrecision = 4;
+ nRealSize = nVDCRealSize = 8;
+ }
+ else
+ {
+ nIntegerPrecision = nIndexPrecision = 2;
+ nRealSize = nVDCRealSize = 4;
+ nColorIndexPrecision = 1;
+ }
+ nColorPrecision = 1;
+ nVDCIntegerPrecision = 2;
+ eRealPrecision = eVDCRealPrecision = RP_FIXED; //RP_FLOAT;
+
+ nMetaFileVersion = 1;
+ eScalingMode = SM_ABSTRACT;
+ eVDCType = VDC_INTEGER;
+ aVDCExtent.Left = aVDCExtent.Bottom = 0;
+// aVDCExtent.Right = aVDCExtent.Top = 32767;
+ aVDCExtent.Right = aVDCExtent.Top = 1.0;
+ aVDCExtentMaximum.Left = aVDCExtentMaximum.Bottom = 0;
+// aVDCExtentMaximum.Right = aVDCExtentMaximum.Top = 32767;
+ aVDCExtentMaximum.Right = aVDCExtentMaximum.Top = 1.0;
+
+ eDeviceViewPortMode = DVPM_FRACTION;
+ nDeviceViewPortScale = 1;
+ eDeviceViewPortMap = DVPM_FORCED;
+ eDeviceViewPortMapH = DVPMH_LEFT;
+ eDeviceViewPortMapV = DVPMV_BOTTOM;
+ aDeviceViewPort.Left = 0;
+ aDeviceViewPort.Top = 1;
+ aDeviceViewPort.Right = 0;
+ aDeviceViewPort.Bottom = 1;
+
+ nMitreLimit = 32767;
+ eClipIndicator = CI_ON;
+ aClipRect = aVDCExtent;
+
+ eColorSelectionMode = CSM_INDEXED;
+ eColorModel = CM_RGB;
+ nColorMaximumIndex = 63;
+ int i;
+ for ( i = 0; i < 256; aColorTableEntryIs[ i++ ] = 0 );
+ aColorTable[ 0 ] = 0;
+ for ( i = 1; i < 256; aColorTable[ i++ ] = 0xffffff );
+ nLatestColorMaximumIndex = 63;
+ aLatestColorTable[ 0 ] = 0;
+ for ( i = 1; i < 256; aLatestColorTable[ i++ ] = 0xffffff );
+ nColorValueExtent[ 0 ] = nColorValueExtent[ 1 ] = nColorValueExtent[ 2 ] = 0;
+ nColorValueExtent[ 3 ] = nColorValueExtent[ 4 ] = nColorValueExtent[ 5 ] = 255;
+
+ nAspectSourceFlags = 0; // all flags are individual
+
+ eLineWidthSpecMode = SM_SCALED; // line parameter
+ eLineCapType = LCT_NONE;
+ eLineJoinType = LJT_NONE;
+ pLineBundle = &aLineBundle; // line bundle parameter
+ aLineBundle.SetIndex( 1 );
+ aLineBundle.eLineType = LT_SOLID;
+ aLineBundle.nLineWidth = 1;
+ aLineBundle.SetColor( 0xffffff );
+ InsertBundle( aLineList, aLineBundle );
+
+ eMarkerSizeSpecMode = SM_SCALED; // marker parameter
+ pMarkerBundle = &aMarkerBundle; // marker bundle parameter
+ aMarkerBundle.SetIndex( 1 );
+ aMarkerBundle.eMarkerType = MT_STAR;
+ aMarkerBundle.nMarkerSize = 1;
+ aMarkerBundle.SetColor( 0xffffff );
+ InsertBundle( aMarkerList, aMarkerBundle );
+
+ eEdgeVisibility = EV_OFF; // edge parameter
+ eEdgeWidthSpecMode = SM_SCALED;
+ pEdgeBundle = &aEdgeBundle; // edge bundle parameter
+ aEdgeBundle.SetIndex( 1 );
+ aEdgeBundle.eEdgeType = ET_SOLID;
+ aEdgeBundle.nEdgeWidth = 1;
+ aEdgeBundle.SetColor( 0xffffff );
+ InsertBundle( aEdgeList, aEdgeBundle );
+
+ nCharacterHeight = 327; // text parameter
+ nCharacterOrientation[0] = 0;
+ nCharacterOrientation[1] = 1;
+ nCharacterOrientation[2] = 1;
+ nCharacterOrientation[3] = 0;
+ eUnderlineMode = UM_OFF;
+ nUnderlineColor = 0xffffff;
+ eTextPath = TPR_RIGHT;
+ eTextAlignmentH = TAH_NORMAL;
+ eTextAlignmentV = TAV_NORMAL;
+ nCharacterSetIndex = nAlternateCharacterSetIndex = 1;
+ eCharacterCodingA = CCA_BASIC_7;
+ pTextBundle = &aTextBundle; // text bundle parameter
+ aTextBundle.SetIndex( 1 );
+ aTextBundle.nTextFontIndex = 1;
+ aTextBundle.eTextPrecision = TPR_STRING;
+ aTextBundle.nCharacterExpansion = 1;
+ aTextBundle.nCharacterSpacing = 0;
+ aTextBundle.SetColor( 0xffffff );
+ InsertBundle( aTextList, aTextBundle );
+
+ pFillBundle = &aFillBundle; // fill bundle parameter
+ aFillBundle.SetIndex( 1 );
+ aFillBundle.eFillInteriorStyle = FIS_HOLLOW;
+ aFillBundle.nFillHatchIndex = 1;
+ aFillBundle.nFillPatternIndex = 1;
+ aFillBundle.SetColor( 0xffffff );
+ InsertBundle( aFillList, aFillBundle );
+
+ ImplInsertHatch( 0, 0, 0, 0 );
+ ImplInsertHatch( 1, 0, 125, 0 );
+ ImplInsertHatch( 2, 0, 125, 900 );
+ ImplInsertHatch( 3, 0, 125, 450 );
+ ImplInsertHatch( 4, 0, 125, 1350 );
+ ImplInsertHatch( 5, 1, 125, 0 );
+ ImplInsertHatch( 6, 1, 125, 450 );
+ ImplInsertHatch( -1, 0, 75, 0 );
+ ImplInsertHatch( -2, 0, 75, 900 );
+ ImplInsertHatch( -3, 0, 75, 450 );
+ ImplInsertHatch( -4, 0, 75, 1350 );
+ ImplInsertHatch( -5, 1, 75, 0 );
+ ImplInsertHatch( -6, 1, 75, 450 );
+ ImplInsertHatch( -7, 2, 125, 0 );
+ ImplInsertHatch( -8, 2, 125, 900 );
+ ImplInsertHatch( -9, 2, 125, 450 );
+ ImplInsertHatch( -10, 2, 125, 1350 );
+ ImplInsertHatch( -11, 0, 40, 0 );
+ ImplInsertHatch( -12, 0, 40, 900 );
+ ImplInsertHatch( -13, 0, 40, 450 );
+ ImplInsertHatch( -14, 0, 40, 1350 );
+ ImplInsertHatch( -15, 1, 40, 0 );
+ ImplInsertHatch( -16, 1, 40, 900 );
+ ImplInsertHatch( -21, 0, 250, 0 );
+ ImplInsertHatch( -22, 0, 250, 900 );
+ ImplInsertHatch( -23, 0, 250, 450 );
+ ImplInsertHatch( -24, 0, 250, 1350 );
+ ImplInsertHatch( -25, 1, 250, 0 );
+ ImplInsertHatch( -26, 1, 250, 450 );
+
+ eTransparency = T_ON;
+
+ nBackGroundColor = nAuxiliaryColor = 0;
+
+ bSegmentCount = sal_False;
+}
+
+// ---------------------------------------------------------------
+
+void CGMElements::ImplInsertHatch( sal_Int32 nKey, int nStyle, long nDistance, long nAngle )
+{
+ HatchEntry* pHatchEntry;
+ pHatchEntry = new HatchEntry;
+ aHatchTable.Insert( (sal_uInt32)nKey, pHatchEntry );
+ pHatchEntry->HatchStyle = nStyle;
+ pHatchEntry->HatchDistance = nDistance;
+ pHatchEntry->HatchAngle = nAngle;
+}
+
+// ---------------------------------------------------------------
+
+void CGMElements::DeleteTable( Table& rTable )
+{
+ void* pPtr = rTable.First();
+ while ( pPtr )
+ {
+ delete pPtr;
+ pPtr = rTable.Next();
+ }
+ rTable.Clear();
+}
+
+// ---------------------------------------------------------------
+
+void CGMElements::DeleteAllBundles( List& rList )
+{
+ void* pPtr = rList.First();
+ while( pPtr )
+ {
+ delete (Bundle*)pPtr;
+ pPtr = rList.Next();
+ }
+};
+
+
+// ---------------------------------------------------------------
+
+void CGMElements::CopyAllBundles( List& rSource, List& rDest )
+{
+ DeleteAllBundles( rDest );
+ rDest.Clear();
+
+ void* pPtr = rSource.First();
+ while( pPtr )
+ {
+ Bundle* pTempBundle = ( (Bundle*)pPtr)->Clone();
+ rDest.Insert( pTempBundle, LIST_APPEND );
+ pPtr = rSource.Next();
+ }
+};
+
+// ---------------------------------------------------------------
+
+Bundle* CGMElements::GetBundleIndex( sal_uInt32 nIndex, List& rList, Bundle& rBundle )
+{
+ rBundle.SetIndex( nIndex );
+ Bundle* pBundle = GetBundle( rList, nIndex );
+ if ( !pBundle )
+ pBundle = InsertBundle( rList, rBundle );
+ return pBundle;
+}
+
+// ---------------------------------------------------------------
+
+Bundle* CGMElements::GetBundle( List& rList, long nIndex )
+{
+ Bundle* pBundle = (Bundle*)rList.First();
+ while( pBundle && ( pBundle->GetIndex() != nIndex ) )
+ {
+ pBundle = (Bundle*)rList.Next();
+ }
+ return pBundle;
+}
+
+// ---------------------------------------------------------------
+
+Bundle* CGMElements::InsertBundle( List& rList, Bundle& rBundle )
+{
+ Bundle* pBundle = GetBundle( rList, rBundle.GetIndex() );
+ if ( pBundle )
+ {
+ rList.Remove( pBundle );
+ delete pBundle;
+ }
+ pBundle = rBundle.Clone();
+ rList.Insert( pBundle, LIST_APPEND );
+ return pBundle;
+};
+
diff --git a/goodies/source/filter.vcl/icgm/elements.hxx b/goodies/source/filter.vcl/icgm/elements.hxx
new file mode 100644
index 000000000000..ae9b8edfef3d
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/elements.hxx
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * $RCSfile: elements.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef CGM_ELEMENTS_HXX_
+#define CGM_ELEMENTS_HXX_
+
+#include "main.hxx"
+#include <tools/table.hxx>
+
+#define nBackGroundColor aColorTable[ 0 ]
+
+class CGMElements
+{
+ void ImplInsertHatch( sal_Int32 Key, int Style, long Distance, long Angle );
+ public:
+ CGM* mpCGM;
+ long nMetaFileVersion;
+
+ sal_uInt32 nIntegerPrecision; // maybe 1, 2, 4 Bytes
+ sal_uInt32 nIndexPrecision; // " " "
+ RealPrecision eRealPrecision;
+ sal_uInt32 nRealSize; // maybe 4 or 8 bytes
+ sal_uInt32 nColorPrecision; // " " "
+ sal_uInt32 nColorIndexPrecision;// " " "
+
+ ScalingMode eScalingMode;
+ double nScalingFactor;
+
+ VDCType eVDCType; // Integer / Real
+ sal_uInt32 nVDCIntegerPrecision;
+ RealPrecision eVDCRealPrecision;
+ sal_uInt32 nVDCRealSize;
+ FloatRect aVDCExtent;
+ FloatRect aVDCExtentMaximum;
+
+ DeviceViewPortMode eDeviceViewPortMode;
+ double nDeviceViewPortScale;
+ DeviceViewPortMap eDeviceViewPortMap;
+ DeviceViewPortMapH eDeviceViewPortMapH;
+ DeviceViewPortMapV eDeviceViewPortMapV;
+ FloatRect aDeviceViewPort;
+
+ double nMitreLimit;
+
+ ClipIndicator eClipIndicator;
+ FloatRect aClipRect;
+
+ ColorSelectionMode eColorSelectionMode;
+ ColorModel eColorModel;
+ sal_uInt32 nColorMaximumIndex; // default 63
+ sal_uInt32 nLatestColorMaximumIndex; // default 63
+ sal_Int8 aColorTableEntryIs[ 256 ];
+ sal_uInt32 aColorTable[ 256 ];
+ sal_uInt32 aLatestColorTable[ 256 ];
+ sal_uInt32 nColorValueExtent[ 8 ]; // RGB, CMYK
+
+ // ASPECT SOURCE FLAGS
+ sal_uInt32 nAspectSourceFlags; // bit = 0 -> INDIVIDUAL
+ // 1 -> BUNDLED
+
+ LineBundle* pLineBundle; // Pointer to the current LineBundleIndex
+ LineBundle aLineBundle;
+ List aLineList;
+ SpecMode eLineWidthSpecMode;
+ LineCapType eLineCapType;
+ LineJoinType eLineJoinType;
+
+ MarkerBundle* pMarkerBundle; // Pointer to the current MarkerBundleIndex
+ MarkerBundle aMarkerBundle;
+ List aMarkerList;
+ SpecMode eMarkerSizeSpecMode;
+
+ EdgeBundle* pEdgeBundle; // Pointer to the current EdgeBundleIndex
+ EdgeBundle aEdgeBundle;
+ List aEdgeList;
+ EdgeVisibility eEdgeVisibility;
+ SpecMode eEdgeWidthSpecMode;
+
+ TextBundle* pTextBundle; // Pointer to the current TextBundleIndex
+ TextBundle aTextBundle;
+ List aTextList;
+ double nCharacterHeight;
+ double nCharacterOrientation[ 4 ];
+ UnderlineMode eUnderlineMode;
+ sal_uInt32 nUnderlineColor;
+ TextPath eTextPath;
+ TextAlignmentH eTextAlignmentH;
+ TextAlignmentV eTextAlignmentV;
+ double nTextAlignmentHCont;
+ double nTextAlignmentVCont;
+ long nCharacterSetIndex;
+ long nAlternateCharacterSetIndex;
+ CharacterCodingA eCharacterCodingA;
+ FontList aFontList;
+
+ FillBundle* pFillBundle; // Pointer to the current EdgeBundleIndex
+ FillBundle aFillBundle;
+ List aFillList;
+ FloatPoint aFillRefPoint;
+ Table aHatchTable;
+
+ Transparency eTransparency;
+
+ sal_uInt32 nAuxiliaryColor;
+
+ // Delimiter Counts -> which will be increased by each 'begin' operation
+ // and decreased by each 'end' operation
+ sal_Bool bSegmentCount;
+ CGMElements( CGM& rCGM );
+ ~CGMElements();
+ CGMElements& operator=( CGMElements& );
+ void Init();
+ void DeleteTable( Table& );
+ Bundle* GetBundleIndex( sal_uInt32 nIndex, List&, Bundle& );
+ Bundle* GetBundle( List& rList, long nIndex );
+ Bundle* InsertBundle( List&, Bundle& );
+ void DeleteAllBundles( List& );
+ void CopyAllBundles( List& Source, List& Dest );
+};
+
+#endif
+
diff --git a/goodies/source/filter.vcl/icgm/main.hxx b/goodies/source/filter.vcl/icgm/main.hxx
new file mode 100644
index 000000000000..16329685ab49
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/main.hxx
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * $RCSfile: main.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CGM_MAIN_HXX
+#define CGM_MAIN_HXX
+
+#include <cgm.hxx>
+
+// ---------------------------------------------------------------
+
+#define CGM_LEVEL1 0x0001 // VERSION 1 METAFILE
+#define CGM_LEVEL2 0x0002
+#define CGM_LEVEL3 0x0003
+#define CGM_GDSF_ONLY 0x00F0
+#define CGM_UNKNOWN_LEVEL 0x00F1
+#define CGM_UNKNOWN_COMMAND 0x00F2
+#define CGM_DESCRIPTION 0x00F3
+
+#define CGM_EXTENDED_PRIMITIVES_SET 0x0100 // INDICATES PRIMITIVES WHICH ARE AVAILABLE IN
+ // LEVEL 1 BUT ARE NOT DEFINED IN ISO 7942(GKS)
+#define CGM_DRAWING_PLUS_CONTROL_SET 0x0200 // INDICATES THAT THIS IS AN ADDITIONAL LEVEL 1
+ // ELEMENT
+#define ComOut( Level, Description ) if ( mpCommentOut ) ImplComment( Level, Description );
+
+#define BMCOL( _col ) BitmapColor( (sal_Int8)(_col >> 16 ), (sal_Int8)( _col >> 8 ), (sal_Int8)_col )
+#define ALIGN2( _nElementSize ) { _nElementSize = ( _nElementSize + 1 ) & ~1; }
+#define ALIGN4( _nElementSize ) { _nElementSize = ( _nElementSize + 3 ) & ~3; }
+#define ALIGN8( _nElementSize ) { _nElementSize = ( _nElementSize + 7 ) & ~7; }
+
+#include <vcl/salbtype.hxx>
+#include <tools/stream.hxx>
+#include <tools/list.hxx>
+#include "bundles.hxx"
+#include "bitmap.hxx"
+#include "elements.hxx"
+
+
+#endif
+
diff --git a/goodies/source/filter.vcl/icgm/makefile.mk b/goodies/source/filter.vcl/icgm/makefile.mk
new file mode 100644
index 000000000000..f9e144d20b3a
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/makefile.mk
@@ -0,0 +1,266 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=goodies
+TARGET=icgm
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Uno III Header -----------------------------------------------
+
+UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb
+# Every source directory generates headers in a own output directory to
+# enable parallel building of the source directories within a project!
+UNOUCROUT=$(OUT)$/inc$/$(PRJNAME)$/$(TARGET)
+INCPRE+=$(UNOUCROUT)
+
+UNOTYPES=\
+ com.sun.star.uno.TypeClass \
+ com.sun.star.uno.XInterface \
+ com.sun.star.lang.XMultiServiceFactory\
+ com.sun.star.drawing.XMasterPageTarget\
+ com.sun.star.drawing.FillStyle\
+ com.sun.star.drawing.XMasterPageTarget\
+ com.sun.star.drawing.PointSequence\
+ com.sun.star.drawing.CircleKind\
+ com.sun.star.drawing.PointSequenceSequence\
+ com.sun.star.drawing.LineStyle\
+ com.sun.star.drawing.LineDash\
+ com.sun.star.drawing.Hatch\
+ com.sun.star.drawing.MeasureTextVertPos\
+ com.sun.star.drawing.XMasterPagesSupplier\
+ com.sun.star.drawing.XDrawPage\
+ com.sun.star.drawing.XDrawPages\
+ com.sun.star.drawing.XDrawPagesSupplier\
+ com.sun.star.drawing.XShapeGrouper\
+ com.sun.star.drawing.PolyPolygonBezierCoords\
+ com.sun.star.drawing.FlagSequence\
+ com.sun.star.drawing.TextAdjust\
+ com.sun.star.frame.XModel\
+ com.sun.star.task.XStatusIndicator\
+ com.sun.star.beans.XPropertySet\
+ com.sun.star.awt.Gradient\
+ com.sun.star.awt.FontDescriptor\
+ com.sun.star.awt.FontSlant\
+ com.sun.star.awt.FontWeight\
+ com.sun.star.awt.FontUnderline\
+ com.sun.star.awt.XBitmap\
+ com.sun.star.awt.XPointer\
+ com.sun.star.text.XText\
+ com.sun.star.style.HorizontalAlignment
+
+
+
+# --- Files --------------------------------------------------------
+
+CXXFILES= cgm.cxx \
+ chart.cxx \
+ class0.cxx \
+ class1.cxx \
+ class2.cxx \
+ class3.cxx \
+ class4.cxx \
+ class5.cxx \
+ class7.cxx \
+ classx.cxx \
+ outact.cxx \
+ actmeta.cxx \
+ actimpr.cxx \
+ bundles.cxx \
+ bitmap.cxx \
+ elements.cxx
+# svdem.cxx
+
+SLOFILES = $(SLO)$/cgm.obj \
+ $(SLO)$/chart.obj \
+ $(SLO)$/class0.obj \
+ $(SLO)$/class1.obj \
+ $(SLO)$/class2.obj \
+ $(SLO)$/class3.obj \
+ $(SLO)$/class4.obj \
+ $(SLO)$/class5.obj \
+ $(SLO)$/class7.obj \
+ $(SLO)$/classx.obj \
+ $(SLO)$/outact.obj \
+ $(SLO)$/actmeta.obj \
+ $(SLO)$/actimpr.obj \
+ $(SLO)$/bundles.obj \
+ $(SLO)$/bitmap.obj \
+ $(SLO)$/elements.obj
+# $(SLO)$/svdem.obj
+
+SHL1TARGET = icg$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB = icgm
+SHL1DEPN = $(LB)$/icgm.lib
+SHL1DEF = $(MISC)$/$(SHL1TARGET).def
+SHL1DEPN = $(LB)$/icgm.lib
+SHL1LIBS = $(SLB)$/icgm.lib
+SHL1BASE = 0x1c000000
+
+.IF "$(GUI)"=="OS2"
+SHL1OBJS = $(SLO)$/class0.obj
+.ENDIF
+
+SHL1STDLIBS = \
+ $(SVTOOLLIB) \
+ $(TKLIB) \
+ $(SVLIB) \
+ $(SOTLIB) \
+ $(UNOTOOLSLIB) \
+ $(TOOLSLIB) \
+ $(CPPULIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+# ims_ifac.lib
+
+# --- Targets --------------------------------------------------------------
+
+.INCLUDE : target.mk
+
+# -------------------------------------------------------------------------
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+# -------------------------------------------------------------------------
+
+.IF "$(GUI)"=="MAC"
+
+$(MISC)$/$(SHL1TARGET).def: $(MISC)$/$(SHL1TARGET).flt makefile.mk
+ @echo ImportCGM > $@
+.ENDIF
+
+# ------------------
+
+.IF "$(GUI)"=="WIN"
+
+$(MISC)$/$(SHL1TARGET).def: $(MISC)$/$(SHL1TARGET).flt makefile.mk
+ @echo ------------------------------
+ @echo Making: $@
+ @echo LIBRARY $(SHL1TARGET) >$@
+ @echo DESCRIPTION 'Filter DLL' >>$@
+ @echo EXETYPE WINDOWS >>$@
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL MOVEABLE DISCARDABLE >>$@
+ @echo DATA PRELOAD MOVEABLE SINGLE >>$@
+ @echo HEAPSIZE 0 >>$@
+ @echo EXPORTS >>$@
+ @echo _ImportCGM >>$@
+.ENDIF
+
+# ------------------
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'FILTER DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo ImportCGM >>$@
+.ELSE
+ @echo _ImportCGM >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET) >>$@
+ @echo ImportCGM_ >>$@
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+# ------------------
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Filter DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo ImportCGM >>$@
+.ENDIF
diff --git a/goodies/source/filter.vcl/icgm/outact.cxx b/goodies/source/filter.vcl/icgm/outact.cxx
new file mode 100644
index 000000000000..3cef24c10026
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/outact.cxx
@@ -0,0 +1,238 @@
+/*************************************************************************
+ *
+ * $RCSfile: outact.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <outact.hxx>
+#include <vcl/gradient.hxx>
+
+using namespace ::com::sun::star;
+
+// ---------------------------------------------------------------
+
+CGMOutAct::CGMOutAct( CGM& rCGM )
+{
+ mpCGM = &rCGM;
+ mnCurrentPage = mnGroupActCount = mnGroupLevel = 0;
+ mpGroupLevel = new sal_uInt32[ CGM_OUTACT_MAX_GROUP_LEVEL ];
+ mpPoints = (Point*)new sal_Int8[ 0x2000 * sizeof( Point ) ];
+ mpFlags = new BYTE[ 0x2000 ];
+
+ mnIndex = 0;
+ mpGradient = NULL;
+};
+
+// ---------------------------------------------------------------
+
+CGMOutAct::~CGMOutAct()
+{
+ delete mpPoints;
+ delete mpFlags;
+ delete mpGroupLevel;
+
+ if ( mpGradient )
+ delete mpGradient;
+};
+
+// ---------------------------------------------------------------
+
+void CGMOutAct::BeginFigure()
+{
+ if ( mnIndex )
+ EndFigure();
+
+ BeginGroup();
+ mnIndex = 0;
+}
+
+// ---------------------------------------------------------------
+
+void CGMOutAct::CloseRegion()
+{
+ if ( mnIndex > 2 )
+ {
+ NewRegion();
+ DrawPolyPolygon( maPolyPolygon );
+ maPolyPolygon.Clear();
+ }
+}
+
+// ---------------------------------------------------------------
+
+void CGMOutAct::NewRegion()
+{
+ if ( mnIndex > 2 )
+ {
+ Polygon aPolygon( mnIndex, mpPoints, mpFlags );
+ maPolyPolygon.Insert( aPolygon );
+ }
+ mnIndex = 0;
+}
+
+// ---------------------------------------------------------------
+
+void CGMOutAct::EndFigure()
+{
+ NewRegion();
+ DrawPolyPolygon( maPolyPolygon );
+ maPolyPolygon.Clear();
+ EndGroup();
+ mnIndex = 0;
+}
+
+// ---------------------------------------------------------------
+
+void CGMOutAct::RegPolyLine( Polygon& rPolygon, sal_Bool bReverse )
+{
+ sal_uInt32 nPoints = rPolygon.GetSize();
+ if ( nPoints )
+ {
+ if ( bReverse )
+ {
+ for ( sal_uInt32 i = 0; i < nPoints; i++ )
+ {
+ mpPoints[ mnIndex + i ] = rPolygon.GetPoint( nPoints - i - 1 );
+ mpFlags[ mnIndex + i ] = (sal_Int8)rPolygon.GetFlags( nPoints - i - 1 );
+ }
+ }
+ else
+ {
+ for ( sal_uInt32 i = 0; i < nPoints; i++ )
+ {
+ mpPoints[ mnIndex + i ] = rPolygon.GetPoint( i );
+ mpFlags[ mnIndex + i ] = (sal_Int8)rPolygon.GetFlags( i );
+ }
+ }
+ mnIndex += nPoints;
+ }
+}
+
+// ---------------------------------------------------------------
+
+void CGMOutAct::SetGradientOffset( long nHorzOfs, long nVertOfs, sal_uInt32 nType )
+{
+ if ( !mpGradient )
+ mpGradient = new awt::Gradient;
+ mpGradient->XOffset = ( (sal_uInt16)nHorzOfs & 0x7f );
+ mpGradient->YOffset = ( (sal_uInt16)nHorzOfs & 0x7f );
+}
+
+// ---------------------------------------------------------------
+
+void CGMOutAct::SetGradientEdge( long nEdge )
+{
+ if ( !mpGradient )
+ mpGradient = new awt::Gradient;
+}
+
+// ---------------------------------------------------------------
+
+void CGMOutAct::SetGradientAngle( long nAngle )
+{
+ if ( !mpGradient )
+ mpGradient = new awt::Gradient;
+ mpGradient->Angle = nAngle;
+}
+
+// ---------------------------------------------------------------
+
+void CGMOutAct::SetGradientDescriptor( sal_uInt32 nColorFrom, sal_uInt32 nColorTo )
+{
+ if ( !mpGradient )
+ mpGradient = new awt::Gradient;
+ mpGradient->StartColor = nColorFrom;
+ mpGradient->EndColor = nColorTo;
+}
+
+// ---------------------------------------------------------------
+
+void CGMOutAct::SetGradientStyle( sal_uInt32 nStyle, double fRatio )
+{
+ if ( !mpGradient )
+ mpGradient = new awt::Gradient;
+ switch ( nStyle )
+ {
+ case 0xff :
+ {
+ mpGradient->Style = awt::GradientStyle_AXIAL;
+ }
+ break;
+ case 4 :
+ {
+ mpGradient->Style = awt::GradientStyle_RADIAL; // CONICAL
+ }
+ break;
+ case 3 :
+ {
+ mpGradient->Style = awt::GradientStyle_RECT;
+ }
+ break;
+ case 2 :
+ {
+ mpGradient->Style = awt::GradientStyle_ELLIPTICAL;
+ }
+ break;
+ default :
+ {
+ mpGradient->Style = awt::GradientStyle_LINEAR;
+ }
+ }
+}
+
+
diff --git a/goodies/source/filter.vcl/icgm/outact.hxx b/goodies/source/filter.vcl/icgm/outact.hxx
new file mode 100644
index 000000000000..51caabf2da63
--- /dev/null
+++ b/goodies/source/filter.vcl/icgm/outact.hxx
@@ -0,0 +1,208 @@
+/*************************************************************************
+ *
+ * $RCSfile: outact.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CGM_OUTACT_HXX_
+#define CGM_OUTACT_HXX_
+
+#ifndef _COM_SUN_STAR_AWT_GRADIENT_HPP_
+#include <com/sun/star/awt/Gradient.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGES_HPP_
+#include <com/sun/star/drawing/XDrawPages.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGE_HPP_
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_
+#include <com/sun/star/drawing/XShape.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+
+
+#define CGM_OUTACT_MAX_GROUP_LEVEL 64
+
+#include "cgm.hxx"
+#include <chart.hxx>
+#include <vcl/poly.hxx>
+
+typedef struct NodeFrameSet
+{
+ Point nTopLeft;
+ Point nBottomRight;
+ ::com::sun::star::awt::Size nSize;
+} NodeFrameSet;
+
+class CGM;
+class VclGradient;
+class CGMOutAct
+{
+ protected:
+ sal_uInt16 mnCurrentPage; // defaulted to zero
+
+ sal_uInt32 mnGroupActCount; // grouping
+ sal_uInt32 mnGroupLevel;
+ sal_uInt32* mpGroupLevel;
+
+ sal_uInt32 mnIndex; // figure
+ BYTE* mpFlags;
+ Point* mpPoints;
+ PolyPolygon maPolyPolygon;
+ ::com::sun::star::awt::Gradient* mpGradient;
+
+ CGM* mpCGM;
+
+ public:
+ CGMOutAct( CGM& rCGM );
+ ~CGMOutAct();
+ virtual void FirstOutPut() { mpCGM->mbFirstOutPut = sal_False; } ;
+ virtual void InsertPage() { mnCurrentPage++; } ;
+ virtual void BeginGroup() {} ;
+ virtual void EndGroup() {};
+ virtual void EndGrouping() {} ;
+ void BeginFigure() ;
+ void CloseRegion() ;
+ void NewRegion() ;
+ void EndFigure() ;
+ void RegPolyLine( Polygon&, sal_Bool bReverse = sal_False ) ;
+ void SetGradientOffset( long nHorzOfs, long nVertOfs, sal_uInt32 nType );
+ void SetGradientEdge( long nEdge );
+ void SetGradientAngle( long nAngle );
+ void SetGradientDescriptor( sal_uInt32 nColorFrom, sal_uInt32 nColorTo );
+ void SetGradientStyle( sal_uInt32 nStyle, double fRatio );
+ virtual void DrawRectangle( FloatRect& ) {} ;
+ virtual void DrawEllipse( FloatPoint& center, FloatPoint& size, double& orientation ) {} ;
+ virtual void DrawEllipticalArc( FloatPoint& center, FloatPoint& size, double& orientation,
+ sal_uInt32 etype, double& startangle, double& endangle ) {} ;
+ virtual void DrawBitmap( CGMBitmapDescriptor* ) {} ;
+ virtual void DrawPolygon( Polygon& ) {} ;
+ virtual void DrawPolyLine( Polygon& ) {} ;
+ virtual void DrawPolybezier( Polygon& ) {} ;
+ virtual void DrawPolyPolygon( PolyPolygon& ) {} ;
+ virtual void DrawText( ::com::sun::star::awt::Point& TextRectPos, ::com::sun::star::awt::Size& TextRectSize, char* String, sal_uInt32 StringSize, FinalFlag ) {} ;
+ virtual void AppendText( char* String, sal_uInt32 StringSize, FinalFlag ) {} ;
+ virtual sal_uInt32 DrawText( TextEntry*, NodeFrameSet&, sal_uInt32 ) { return 0; } ;
+ virtual void DrawChart(){} ;
+};
+
+class CGMMetaOutAct : public CGMOutAct
+{
+ public:
+ CGMMetaOutAct( CGM& rCGM ) ;
+ ~CGMMetaOutAct() {} ;
+ virtual void DrawRectangle( FloatRect& ) ;
+ virtual void DrawBitmap( CGMBitmapDescriptor* ) ;
+ virtual void DrawPolygon( Polygon& ) ;
+ virtual void DrawPolyLine( Polygon& ) ;
+ virtual void DrawPolybezier( Polygon& ) ;
+};
+
+class CGMImpressOutAct : public CGMOutAct
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPages > maXDrawPages;
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > maXDrawPage;
+
+// ::com::sun::star::uno::Reference< XServiceRegistry > maXServiceRegistry;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > maXMultiServiceFactory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > maXServiceManagerSC;
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > maXShape;
+ sal_Bool ImplCreateShape( const ::rtl::OUString& rType );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > maXPropSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > maXShapes;
+
+ sal_uInt32 nFinalTextCount;
+
+ sal_Bool ImplInitPage();
+ void ImplSetOrientation( FloatPoint& RefPoint, double& Orientation ) ;
+ void ImplSetLineBundle() ;
+ void ImplSetFillBundle() ;
+ void ImplSetTextBundle( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & ) ;
+ void ImplGetFrameSet( int NodeNumber, NodeFrameSet& );
+public:
+ CGMImpressOutAct( CGM&, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & ) ;
+ ~CGMImpressOutAct() {} ;
+ virtual void InsertPage() ;
+ virtual void BeginGroup() ;
+ virtual void EndGroup() ;
+ virtual void EndGrouping() ;
+ virtual void DrawRectangle( FloatRect& ) ;
+ virtual void DrawEllipse( FloatPoint& center, FloatPoint&, double& Orientation ) ;
+ virtual void DrawEllipticalArc( FloatPoint& center, FloatPoint& size, double& orientation,
+ sal_uInt32 etype, double& startangle, double& endangle ) ;
+ virtual void DrawBitmap( CGMBitmapDescriptor* ) ;
+ virtual void DrawPolygon( Polygon& ) ;
+ virtual void DrawPolyLine( Polygon& ) ;
+ virtual void DrawPolybezier( Polygon& ) ;
+ virtual void DrawPolyPolygon( PolyPolygon& ) ;
+ virtual void DrawText( ::com::sun::star::awt::Point& TextRectPos, ::com::sun::star::awt::Size& TextRectSize, char* String, sal_uInt32 StringSize, FinalFlag ) ;
+ virtual void AppendText( char* String, sal_uInt32 StringSize, FinalFlag ) ;
+ virtual sal_uInt32 DrawText( TextEntry*, NodeFrameSet&, sal_uInt32 ) ;
+ virtual void DrawChart();
+};
+
+
+#endif
+
diff --git a/goodies/source/filter.vcl/idxf/dxf2mtf.cxx b/goodies/source/filter.vcl/idxf/dxf2mtf.cxx
new file mode 100644
index 000000000000..3e717a12525e
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/dxf2mtf.cxx
@@ -0,0 +1,804 @@
+/*************************************************************************
+ *
+ * $RCSfile: dxf2mtf.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <math.h>
+#include <string.h>
+#include <vcl/gdimtf.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/poly.hxx>
+#include "dxf2mtf.hxx"
+
+
+ULONG DXF2GDIMetaFile::CountEntities(const DXFEntities & rEntities)
+{
+ const DXFBasicEntity * pBE;
+ ULONG nRes;
+
+ nRes=0;
+ for (pBE=rEntities.pFirst; pBE!=NULL; pBE=pBE->pSucc) nRes++;
+ return nRes;
+}
+
+
+void DXF2GDIMetaFile::MayCallback(ULONG nMainEntitiesProcessed)
+{
+ ULONG nPercent;
+
+ if (pCallback!=NULL && nMainEntitiesCount!=0) {
+ nPercent=nMinPercent+(nMaxPercent-nMinPercent)*nMainEntitiesProcessed/nMainEntitiesCount;
+ if (nPercent>=nLastPercent+4) {
+ if (((*pCallback)(pCallerData,(USHORT)nPercent))==TRUE) bStatus=FALSE;
+ nLastPercent=nPercent;
+ }
+ }
+}
+
+#ifndef VCL
+Color DXF2GDIMetaFile::ConvertColor(BYTE nColor)
+{
+ return Color(
+ ((USHORT)pDXF->aPalette.GetRed(nColor))<<8,
+ ((USHORT)pDXF->aPalette.GetGreen(nColor))<<8,
+ ((USHORT)pDXF->aPalette.GetBlue(nColor))<<8
+ );
+}
+#else
+Color DXF2GDIMetaFile::ConvertColor(BYTE nColor)
+{
+ return Color(
+ pDXF->aPalette.GetRed( nColor ),
+ pDXF->aPalette.GetGreen( nColor ),
+ pDXF->aPalette.GetBlue( nColor ) );
+}
+#endif
+
+long DXF2GDIMetaFile::GetEntityColor(const DXFBasicEntity & rE)
+{
+ long nColor;
+ const DXFLayer * pLayer;
+
+ nColor=rE.nColor;
+ if (nColor==256) {
+ if (rE.sLayer[0]=='0' && rE.sLayer[1]==0) nColor=nParentLayerColor;
+ else {
+ pLayer=pDXF->aTables.SearchLayer(rE.sLayer);
+ if (pLayer!=NULL) nColor=pLayer->nColor;
+ else nColor=nParentLayerColor;
+ }
+ }
+ else if (nColor==0) nColor=nBlockColor;
+ return nColor;
+}
+
+
+PenStyle DXF2GDIMetaFile::LTypeToPStyle(const char * sLineType)
+{
+ const DXFLType * pLT;
+ PenStyle ePStyle;
+ pLT=pDXF->aTables.SearchLType(sLineType);
+ if (pLT==NULL) ePStyle=PEN_SOLID;
+ else if (pLT->nDashCount<=1) ePStyle=PEN_SOLID;
+ else if (pLT->nDashCount==2) {
+ if (fabs(pLT->fDash[0])*4<fabs(pLT->fPatternLength)) ePStyle=PEN_DOT;
+ else ePStyle=PEN_DASH;
+ }
+ else ePStyle=PEN_DASHDOT;
+ return ePStyle;
+}
+
+
+PenStyle DXF2GDIMetaFile::GetEntityPStyle(const DXFBasicEntity & rE)
+{
+ PenStyle ePStyle;
+ const DXFLayer * pLayer;
+
+ if (strcmp(rE.sLineType,"BYLAYER")==0) {
+ if (rE.sLayer[0]=='0' && rE.sLayer[1]==0) ePStyle=eParentLayerPStyle;
+ else {
+ pLayer=pDXF->aTables.SearchLayer(rE.sLayer);
+ if (pLayer!=NULL) ePStyle=LTypeToPStyle(pLayer->sLineType);
+ else ePStyle=eParentLayerPStyle;
+ }
+ }
+ else if (strcmp(rE.sLineType,"BYBLOCK")==0) {
+ ePStyle=eBlockPStyle;
+ }
+ else ePStyle=LTypeToPStyle(rE.sLineType);
+ return ePStyle;
+}
+
+
+BOOL DXF2GDIMetaFile::SetLineAttribute(const DXFBasicEntity & rE, ULONG nWidth)
+{
+ long nColor;
+ Color aColor;
+ PenStyle ePStyle;
+
+ nColor=GetEntityColor(rE);
+ if (nColor<0) return FALSE;
+ aColor=ConvertColor((BYTE)nColor);
+ ePStyle=GetEntityPStyle(rE);
+
+ if (aActLineColor!=aColor) {
+ pVirDev->SetLineColor( aActLineColor = aColor );
+ }
+
+ if (aActFillColor!=Color( COL_TRANSPARENT )) {
+ pVirDev->SetFillColor(aActFillColor = Color( COL_TRANSPARENT ));
+ }
+ return TRUE;
+}
+
+
+BOOL DXF2GDIMetaFile::SetAreaAttribute(const DXFBasicEntity & rE)
+{
+ long nColor;
+ Color aColor;
+
+ nColor=GetEntityColor(rE);
+ if (nColor<0) return FALSE;
+ aColor=ConvertColor((BYTE)nColor);
+
+ if (aActLineColor!=aColor) {
+ pVirDev->SetLineColor( aActLineColor = aColor );
+ }
+
+ if ( aActFillColor == Color( COL_TRANSPARENT ) || aActFillColor != aColor) {
+ pVirDev->SetFillColor( aActFillColor = aColor );
+ }
+ return TRUE;
+}
+
+
+BOOL DXF2GDIMetaFile::SetFontAttribute(const DXFBasicEntity & rE, short nAngle, USHORT nHeight, double fWidthScale)
+{
+ long nColor;
+ Color aColor;
+ Font aFont;
+
+ nAngle=-nAngle;
+ while (nAngle>3600) nAngle-=3600;
+ while (nAngle<0) nAngle+=3600;
+
+ nColor=GetEntityColor(rE);
+ if (nColor<0) return FALSE;
+ aColor=ConvertColor((BYTE)nColor);
+
+ aFont.SetColor(aColor);
+ aFont.SetTransparent(TRUE);
+ aFont.SetFamily(FAMILY_SWISS);
+ aFont.SetSize(Size(0,nHeight));
+ aFont.SetAlign(ALIGN_BASELINE);
+ aFont.SetOrientation(nAngle);
+ if (aActFont!=aFont) {
+ aActFont=aFont;
+ pVirDev->SetFont(aActFont);
+ }
+
+ return TRUE;
+}
+
+
+void DXF2GDIMetaFile::DrawLineEntity(const DXFLineEntity & rE, const DXFTransform & rTransform)
+{
+
+ if (SetLineAttribute(rE)) {
+ Point aP0,aP1;
+ rTransform.Transform(rE.aP0,aP0);
+ rTransform.Transform(rE.aP1,aP1);
+ pVirDev->DrawLine(aP0,aP1);
+ if (rE.fThickness!=0) {
+ Point aP2,aP3;
+ rTransform.Transform(rE.aP0+DXFVector(0,0,rE.fThickness),aP2);
+ rTransform.Transform(rE.aP1+DXFVector(0,0,rE.fThickness),aP3);
+ pVirDev->DrawLine(aP2,aP3);
+ pVirDev->DrawLine(aP0,aP2);
+ pVirDev->DrawLine(aP1,aP3);
+ }
+ }
+}
+
+
+void DXF2GDIMetaFile::DrawPointEntity(const DXFPointEntity & rE, const DXFTransform & rTransform)
+{
+
+ if (SetLineAttribute(rE)) {
+ Point aP0;
+ rTransform.Transform(rE.aP0,aP0);
+ if (rE.fThickness==0) pVirDev->DrawPixel(aP0);
+ else {
+ Point aP1;
+ rTransform.Transform(rE.aP0+DXFVector(0,0,rE.fThickness),aP1);
+ pVirDev->DrawLine(aP0,aP1);
+ }
+ }
+}
+
+
+void DXF2GDIMetaFile::DrawCircleEntity(const DXFCircleEntity & rE, const DXFTransform & rTransform)
+{
+ double frx,fry,fAng;
+ USHORT nPoints,i;
+ DXFVector aC;
+
+ if (SetLineAttribute(rE)==FALSE) return;
+ rTransform.Transform(rE.aP0,aC);
+ if (rE.fThickness==0 && rTransform.TransCircleToEllipse(rE.fRadius,frx,fry)==TRUE) {
+ pVirDev->DrawEllipse(
+ Rectangle((long)(aC.fx-frx+0.5),(long)(aC.fy-fry+0.5),
+ (long)(aC.fx+frx+0.5),(long)(aC.fy+fry+0.5)));
+ }
+ else {
+ nPoints=OptPointsPerCircle;
+ Polygon aPoly(nPoints);
+ for (i=0; i<nPoints; i++) {
+ fAng=2*3.14159265359/(double)(nPoints-1)*(double)i;
+ rTransform.Transform(
+ rE.aP0+DXFVector(rE.fRadius*cos(fAng),rE.fRadius*sin(fAng),0),
+ aPoly[i]
+ );
+ }
+ pVirDev->DrawPolyLine(aPoly);
+ if (rE.fThickness!=0) {
+ Polygon aPoly2(nPoints);
+ for (i=0; i<nPoints; i++) {
+ fAng=2*3.14159265359/(double)(nPoints-1)*(double)i;
+ rTransform.Transform(
+ rE.aP0+DXFVector(rE.fRadius*cos(fAng),rE.fRadius*sin(fAng),rE.fThickness),
+ aPoly2[i]
+ );
+
+ }
+ pVirDev->DrawPolyLine(aPoly2);
+ for (i=0; i<nPoints-1; i++) pVirDev->DrawLine(aPoly[i],aPoly2[i]);
+ }
+ }
+}
+
+
+void DXF2GDIMetaFile::DrawArcEntity(const DXFArcEntity & rE, const DXFTransform & rTransform)
+{
+ double frx,fry,fA1,fdA,fAng;
+ USHORT nPoints,i;
+ DXFVector aC;
+ Point aPS,aPE;
+
+ if (SetLineAttribute(rE)==FALSE) return;
+ fA1=rE.fStart;
+ fdA=rE.fEnd-fA1;
+ while (fdA>=360.0) fdA-=360.0;
+ while (fdA<=0) fdA+=360.0;
+ rTransform.Transform(rE.aP0,aC);
+ if (rE.fThickness==0 && fdA>5.0 && rTransform.TransCircleToEllipse(rE.fRadius,frx,fry)==TRUE) {
+ DXFVector aVS(cos(fA1/180.0*3.14159265359),sin(fA1/180.0*3.14159265359),0.0);
+ aVS*=rE.fRadius;
+ aVS+=rE.aP0;
+ DXFVector aVE(cos((fA1+fdA)/180.0*3.14159265359),sin((fA1+fdA)/180.0*3.14159265359),0.0);
+ aVE*=rE.fRadius;
+ aVE+=rE.aP0;
+ if (rTransform.Mirror()==TRUE) {
+ rTransform.Transform(aVS,aPS);
+ rTransform.Transform(aVE,aPE);
+ }
+ else {
+ rTransform.Transform(aVS,aPE);
+ rTransform.Transform(aVE,aPS);
+ }
+ pVirDev->DrawArc(
+ Rectangle((long)(aC.fx-frx+0.5),(long)(aC.fy-fry+0.5),
+ (long)(aC.fx+frx+0.5),(long)(aC.fy+fry+0.5)),
+ aPS,aPE
+ );
+ }
+ else {
+ nPoints=(USHORT)(fdA/360.0*(double)OptPointsPerCircle+0.5);
+ if (nPoints<2) nPoints=2;
+ Polygon aPoly(nPoints);
+ for (i=0; i<nPoints; i++) {
+ fAng=3.14159265359/180.0 * ( fA1 + fdA/(double)(nPoints-1)*(double)i );
+ rTransform.Transform(
+ rE.aP0+DXFVector(rE.fRadius*cos(fAng),rE.fRadius*sin(fAng),0),
+ aPoly[i]
+ );
+ }
+ pVirDev->DrawPolyLine(aPoly);
+ if (rE.fThickness!=0) {
+ Polygon aPoly2(nPoints);
+ for (i=0; i<nPoints; i++) {
+ fAng=3.14159265359/180.0 * ( fA1 + fdA/(double)(nPoints-1)*(double)i );
+ rTransform.Transform(
+ rE.aP0+DXFVector(rE.fRadius*cos(fAng),rE.fRadius*sin(fAng),rE.fThickness),
+ aPoly2[i]
+ );
+ }
+ pVirDev->DrawPolyLine(aPoly2);
+ for (i=0; i<nPoints; i++) pVirDev->DrawLine(aPoly[i],aPoly2[i]);
+ }
+ }
+}
+
+
+void DXF2GDIMetaFile::DrawTraceEntity(const DXFTraceEntity & rE, const DXFTransform & rTransform)
+{
+ if (SetLineAttribute(rE)) {
+ Polygon aPoly(4);
+ rTransform.Transform(rE.aP0,aPoly[0]);
+ rTransform.Transform(rE.aP1,aPoly[1]);
+ rTransform.Transform(rE.aP3,aPoly[2]);
+ rTransform.Transform(rE.aP2,aPoly[3]);
+ pVirDev->DrawPolygon(aPoly);
+ if (rE.fThickness!=0) {
+ USHORT i;
+ Polygon aPoly2(4);
+ DXFVector aVAdd(0,0,rE.fThickness);
+ rTransform.Transform(rE.aP0+aVAdd,aPoly2[0]);
+ rTransform.Transform(rE.aP1+aVAdd,aPoly2[1]);
+ rTransform.Transform(rE.aP3+aVAdd,aPoly2[2]);
+ rTransform.Transform(rE.aP2+aVAdd,aPoly2[3]);
+ pVirDev->DrawPolygon(aPoly2);
+ for (i=0; i<4; i++) pVirDev->DrawLine(aPoly[i],aPoly2[i]);
+ }
+ }
+}
+
+
+void DXF2GDIMetaFile::DrawSolidEntity(const DXFSolidEntity & rE, const DXFTransform & rTransform)
+{
+ if (SetAreaAttribute(rE)) {
+ USHORT nN;
+ if (rE.aP2==rE.aP3) nN=3; else nN=4;
+ Polygon aPoly(nN);
+ rTransform.Transform(rE.aP0,aPoly[0]);
+ rTransform.Transform(rE.aP1,aPoly[1]);
+ rTransform.Transform(rE.aP3,aPoly[2]);
+ if (nN>3) rTransform.Transform(rE.aP2,aPoly[3]);
+ pVirDev->DrawPolygon(aPoly);
+ if (rE.fThickness!=0) {
+ Polygon aPoly2(nN);
+ DXFVector aVAdd(0,0,rE.fThickness);
+ rTransform.Transform(rE.aP0+aVAdd,aPoly2[0]);
+ rTransform.Transform(rE.aP1+aVAdd,aPoly2[1]);
+ rTransform.Transform(rE.aP3+aVAdd,aPoly2[2]);
+ if (nN>3) rTransform.Transform(rE.aP2+aVAdd,aPoly2[3]);
+ pVirDev->DrawPolygon(aPoly2);
+ if (SetLineAttribute(rE)) {
+ USHORT i;
+ for (i=0; i<nN; i++) pVirDev->DrawLine(aPoly[i],aPoly2[i]);
+ }
+ }
+ }
+}
+
+
+void DXF2GDIMetaFile::DrawTextEntity(const DXFTextEntity & rE, const DXFTransform & rTransform)
+{
+ DXFVector aV;
+ Point aPt;
+ double fA;
+ USHORT nHeight;
+ short nAng;
+ ByteString aStr( rE.sText );
+ DXFTransform aT( DXFTransform(rE.fXScale,rE.fHeight,1.0,rE.fRotAngle,rE.aP0), rTransform );
+ aT.TransDir(DXFVector(0,1,0),aV);
+ nHeight=(USHORT)(aV.Abs()+0.5);
+ fA=aT.CalcRotAngle();
+ nAng=(short)(fA*10.0+0.5);
+ aT.TransDir(DXFVector(1,0,0),aV);
+ if ( SetFontAttribute( rE,nAng, nHeight, aV. Abs() ) )
+ {
+ String aUString( aStr, RTL_TEXTENCODING_IBM_437 );
+ aT.Transform( DXFVector( 0, 0, 0 ), aPt );
+ pVirDev->DrawText( aPt, aUString );
+ }
+}
+
+
+void DXF2GDIMetaFile::DrawInsertEntity(const DXFInsertEntity & rE, const DXFTransform & rTransform)
+{
+ const DXFBlock * pB;
+ pB=pDXF->aBlocks.Search(rE.sName);
+ if (pB!=NULL) {
+ DXFTransform aDXFTransform1(1.0,1.0,1.0,DXFVector(0.0,0.0,0.0)-pB->aBasePoint);
+ DXFTransform aDXFTransform2(rE.fXScale,rE.fYScale,rE.fZScale,rE.fRotAngle,rE.aP0);
+ DXFTransform aT(
+ DXFTransform( aDXFTransform1, aDXFTransform2 ),
+ rTransform
+ );
+ long nSavedBlockColor, nSavedParentLayerColor;
+ PenStyle eSavedBlockPStyle, eSavedParentLayerPStyle;
+ nSavedBlockColor=nBlockColor;
+ nSavedParentLayerColor=nParentLayerColor;
+ eSavedBlockPStyle=eBlockPStyle;
+ eSavedParentLayerPStyle=eParentLayerPStyle;
+ nBlockColor=GetEntityColor(rE);
+ eBlockPStyle=GetEntityPStyle(rE);
+ if (rE.sLayer[0]!='0' || rE.sLayer[1]!=0) {
+ DXFLayer * pLayer=pDXF->aTables.SearchLayer(rE.sLayer);
+ if (pLayer!=NULL) {
+ nParentLayerColor=pLayer->nColor;
+ eParentLayerPStyle=LTypeToPStyle(pLayer->sLineType);
+ }
+ }
+ DrawEntities(*pB,aT,FALSE);
+ eBlockPStyle=eSavedBlockPStyle;
+ eParentLayerPStyle=eSavedParentLayerPStyle;
+ nBlockColor=nSavedBlockColor;
+ nParentLayerColor=nSavedParentLayerColor;
+ }
+}
+
+
+void DXF2GDIMetaFile::DrawAttribEntity(const DXFAttribEntity & rE, const DXFTransform & rTransform)
+{
+ if ((rE.nAttrFlags&1)==0) {
+ DXFVector aV;
+ Point aPt;
+ double fA;
+ USHORT nHeight;
+ short nAng;
+ ByteString aStr( rE.sText );
+ DXFTransform aT( DXFTransform( rE.fXScale, rE.fHeight, 1.0, rE.fRotAngle, rE.aP0 ), rTransform );
+ aT.TransDir(DXFVector(0,1,0),aV);
+ nHeight=(USHORT)(aV.Abs()+0.5);
+ fA=aT.CalcRotAngle();
+ nAng=(short)(fA*10.0+0.5);
+ aT.TransDir(DXFVector(1,0,0),aV);
+ if (SetFontAttribute(rE,nAng,nHeight,aV.Abs()))
+ {
+ String aUString( aStr, RTL_TEXTENCODING_IBM_437 );
+ aT.Transform( DXFVector( 0, 0, 0 ), aPt );
+ pVirDev->DrawText( aPt, aUString );
+ }
+ }
+}
+
+
+void DXF2GDIMetaFile::DrawPolyLineEntity(const DXFPolyLineEntity & rE, const DXFTransform & rTransform)
+{
+ USHORT i,nPolySize;
+ double fW;
+ const DXFBasicEntity * pBE;
+
+ nPolySize=0;
+ pBE=rE.pSucc;
+ while (pBE!=NULL && pBE->eType==DXF_VERTEX) {
+ nPolySize++;
+ pBE=pBE->pSucc;
+ }
+ if (nPolySize<2) return;
+ Polygon aPoly(nPolySize);
+ fW=0.0;
+ pBE=rE.pSucc;
+ for (i=0; i<nPolySize; i++) {
+ rTransform.Transform(((DXFVertexEntity*)pBE)->aP0,aPoly[i]);
+ if (i+1<nPolySize || (rE.nFlags&1)!=0) {
+ if (((DXFVertexEntity*)pBE)->fSWidth>=0.0) fW+=((DXFVertexEntity*)pBE)->fSWidth;
+ else fW+=rE.fSWidth;
+ if (((DXFVertexEntity*)pBE)->fEWidth>=0.0) fW+=((DXFVertexEntity*)pBE)->fEWidth;
+ else fW+=rE.fEWidth;
+ }
+ pBE=pBE->pSucc;
+ }
+ fW/=2.0;
+ if ((rE.nFlags&1)!=0) fW/=(double)nPolySize;
+ else fW/=(double)(nPolySize-1);
+ if (SetLineAttribute(rE,rTransform.TransLineWidth(fW))) {
+ if ((rE.nFlags&1)!=0) pVirDev->DrawPolygon(aPoly);
+ else pVirDev->DrawPolyLine(aPoly);
+ if (rE.fThickness!=0) {
+ Polygon aPoly2(nPolySize);
+ pBE=rE.pSucc;
+ for (i=0; i<nPolySize; i++) {
+ rTransform.Transform(
+ (((DXFVertexEntity*)pBE)->aP0)+DXFVector(0,0,rE.fThickness),
+ aPoly2[i]
+ );
+ pBE=pBE->pSucc;
+ }
+ if ((rE.nFlags&1)!=0) pVirDev->DrawPolygon(aPoly2);
+ else pVirDev->DrawPolyLine(aPoly2);
+ for (i=0; i<nPolySize; i++) pVirDev->DrawLine(aPoly[i],aPoly2[i]);
+ }
+ }
+}
+
+
+void DXF2GDIMetaFile::Draw3DFaceEntity(const DXF3DFaceEntity & rE, const DXFTransform & rTransform)
+{
+ USHORT nN,i;
+ if (SetLineAttribute(rE)) {
+ if (rE.aP2==rE.aP3) nN=3; else nN=4;
+ Polygon aPoly(nN);
+ rTransform.Transform(rE.aP0,aPoly[0]);
+ rTransform.Transform(rE.aP1,aPoly[1]);
+ rTransform.Transform(rE.aP2,aPoly[2]);
+ if (nN>3) rTransform.Transform(rE.aP3,aPoly[3]);
+ if (rE.nIEFlags&0x0f==0) pVirDev->DrawPolygon(aPoly);
+ else {
+ for (i=0; i<nN; i++) {
+ if ( (rE.nIEFlags & (1<<i)) == 0 ) {
+ pVirDev->DrawLine(aPoly[i],aPoly[(i+1)%nN]);
+ }
+ }
+ }
+ }
+}
+
+
+void DXF2GDIMetaFile::DrawDimensionEntity(const DXFDimensionEntity & rE, const DXFTransform & rTransform)
+{
+ const DXFBlock * pB;
+ pB=pDXF->aBlocks.Search(rE.sPseudoBlock);
+ if (pB!=NULL) {
+ DXFTransform aT(
+ DXFTransform(1.0,1.0,1.0,DXFVector(0.0,0.0,0.0)-pB->aBasePoint),
+ rTransform
+ );
+ long nSavedBlockColor, nSavedParentLayerColor;
+ PenStyle eSavedBlockPStyle, eSavedParentLayerPStyle;
+ nSavedBlockColor=nBlockColor;
+ nSavedParentLayerColor=nParentLayerColor;
+ eSavedBlockPStyle=eBlockPStyle;
+ eSavedParentLayerPStyle=eParentLayerPStyle;
+ nBlockColor=GetEntityColor(rE);
+ eBlockPStyle=GetEntityPStyle(rE);
+ if (rE.sLayer[0]!='0' || rE.sLayer[1]!=0) {
+ DXFLayer * pLayer=pDXF->aTables.SearchLayer(rE.sLayer);
+ if (pLayer!=NULL) {
+ nParentLayerColor=pLayer->nColor;
+ eParentLayerPStyle=LTypeToPStyle(pLayer->sLineType);
+ }
+ }
+ DrawEntities(*pB,aT,FALSE);
+ eBlockPStyle=eSavedBlockPStyle;
+ eParentLayerPStyle=eSavedParentLayerPStyle;
+ nBlockColor=nSavedBlockColor;
+ nParentLayerColor=nSavedParentLayerColor;
+ }
+}
+
+
+void DXF2GDIMetaFile::DrawEntities(const DXFEntities & rEntities,
+ const DXFTransform & rTransform,
+ BOOL bTopEntities)
+{
+ ULONG nCount=0;
+ DXFTransform aET;
+ const DXFTransform * pT;
+
+ const DXFBasicEntity * pE=rEntities.pFirst;
+
+ while (pE!=NULL && bStatus==TRUE) {
+ if (pE->nSpace==0) {
+ if (pE->aExtrusion.fz==1.0) {
+ pT=&rTransform;
+ }
+ else {
+ aET=DXFTransform(DXFTransform(pE->aExtrusion),rTransform);
+ pT=&aET;
+ }
+ switch (pE->eType) {
+ case DXF_LINE:
+ DrawLineEntity((DXFLineEntity&)*pE,*pT);
+ break;
+ case DXF_POINT:
+ DrawPointEntity((DXFPointEntity&)*pE,*pT);
+ break;
+ case DXF_CIRCLE:
+ DrawCircleEntity((DXFCircleEntity&)*pE,*pT);
+ break;
+ case DXF_ARC:
+ DrawArcEntity((DXFArcEntity&)*pE,*pT);
+ break;
+ case DXF_TRACE:
+ DrawTraceEntity((DXFTraceEntity&)*pE,*pT);
+ break;
+ case DXF_SOLID:
+ DrawSolidEntity((DXFSolidEntity&)*pE,*pT);
+ break;
+ case DXF_TEXT:
+ DrawTextEntity((DXFTextEntity&)*pE,*pT);
+ break;
+ case DXF_INSERT:
+ DrawInsertEntity((DXFInsertEntity&)*pE,*pT);
+ break;
+ case DXF_ATTRIB:
+ DrawAttribEntity((DXFAttribEntity&)*pE,*pT);
+ break;
+ case DXF_POLYLINE:
+ DrawPolyLineEntity((DXFPolyLineEntity&)*pE,*pT);
+ break;
+ case DXF_3DFACE:
+ Draw3DFaceEntity((DXF3DFaceEntity&)*pE,*pT);
+ break;
+ case DXF_DIMENSION:
+ DrawDimensionEntity((DXFDimensionEntity&)*pE,*pT);
+ break;
+ }
+ }
+ pE=pE->pSucc;
+ nCount++;
+ if (bTopEntities) MayCallback(nCount);
+ }
+}
+
+
+DXF2GDIMetaFile::DXF2GDIMetaFile()
+{
+}
+
+
+DXF2GDIMetaFile::~DXF2GDIMetaFile()
+{
+}
+
+
+BOOL DXF2GDIMetaFile::Convert(const DXFRepresentation & rDXF, GDIMetaFile & rMTF,
+ PFilterCallback pcallback, void * pcallerdata,
+ USHORT nminpercent, USHORT nmaxpercent)
+{
+ double fWidth,fHeight,fScale;
+ DXFTransform aTransform;
+ Size aPrefSize;
+ const DXFLayer * pLayer;
+ const DXFVPort * pVPort;
+
+ pVirDev = new VirtualDevice;
+ pDXF = &rDXF;
+ bStatus = TRUE;
+
+ OptPointsPerCircle=50;
+
+ pCallback=pcallback;
+ pCallerData=pcallerdata;
+ nMinPercent=(ULONG)nminpercent;
+ nMaxPercent=(ULONG)nmaxpercent;
+ nLastPercent=nMinPercent;
+ nMainEntitiesCount=CountEntities(pDXF->aEntities);
+
+ nBlockColor=7;
+ eBlockPStyle=PEN_SOLID;
+
+ pLayer=pDXF->aTables.SearchLayer("0");
+ if (pLayer!=NULL) {
+ nParentLayerColor=pLayer->nColor & 0xff;
+ eParentLayerPStyle=LTypeToPStyle(pLayer->sLineType);
+ }
+ else {
+ nParentLayerColor=7;
+ eParentLayerPStyle=PEN_SOLID;
+ }
+
+ pVirDev->EnableOutput(FALSE);
+ rMTF.Record(pVirDev);
+
+ aActLineColor = pVirDev->GetLineColor();
+ aActFillColor = pVirDev->GetFillColor();
+ aActFont = pVirDev->GetFont();
+
+ pVPort=pDXF->aTables.SearchVPort("*ACTIVE");
+ if (pVPort!=NULL) {
+ if (pVPort->aDirection.fx==0 && pVPort->aDirection.fy==0) pVPort=NULL;
+ }
+
+ if (pVPort==NULL) {
+ if (pDXF->aBoundingBox.bEmpty==TRUE) bStatus=FALSE;
+ else {
+ fWidth=pDXF->aBoundingBox.fMaxX-pDXF->aBoundingBox.fMinX;
+ fHeight=pDXF->aBoundingBox.fMaxY-pDXF->aBoundingBox.fMinY;
+ if (fWidth<=0 || fHeight<=0) bStatus=FALSE;
+ else {
+ if (fWidth<500.0 || fHeight<500.0 || fWidth>32767.0 || fHeight>32767.0) {
+ if (fWidth>fHeight) fScale=10000.0/fWidth;
+ else fScale=10000.0/fHeight;
+ }
+ else fScale=1.0;
+ aTransform=DXFTransform(fScale,-fScale,fScale,
+ DXFVector(-pDXF->aBoundingBox.fMinX*fScale,
+ pDXF->aBoundingBox.fMaxY*fScale,
+ -pDXF->aBoundingBox.fMinZ*fScale));
+ }
+ aPrefSize.Width() =(long)(fWidth*fScale+1.5);
+ aPrefSize.Height()=(long)(fHeight*fScale+1.5);
+ }
+ }
+ else {
+ fHeight=pVPort->fHeight;
+ fWidth=fHeight*pVPort->fAspectRatio;
+ if (fWidth<500.0 || fHeight<500.0 || fWidth>32767.0 || fHeight>32767.0) {
+ if (fWidth>fHeight) fScale=10000.0/fWidth;
+ else fScale=10000.0/fHeight;
+ }
+ else fScale=1.0;
+ aTransform=DXFTransform(
+ DXFTransform(pVPort->aDirection,pVPort->aTarget),
+ DXFTransform(
+ DXFTransform(1.0,-1.0,1.0,DXFVector(fWidth/2-pVPort->fCenterX,fHeight/2+pVPort->fCenterY,0)),
+ DXFTransform(fScale,fScale,fScale,DXFVector(0,0,0))
+ )
+ );
+ aPrefSize.Width() =(long)(fWidth*fScale+1.5);
+ aPrefSize.Height()=(long)(fHeight*fScale+1.5);
+ }
+
+ if (bStatus==TRUE) DrawEntities(pDXF->aEntities,aTransform,TRUE);
+
+ rMTF.Stop();
+
+ if ( bStatus==TRUE )
+ {
+ rMTF.SetPrefSize( aPrefSize );
+
+ // MapMode einfach, falls Grafik dann nicht zu klein wird (<0,5cm),
+ // auf 1/100-mm (1/10-mm) setzen
+ if( ( aPrefSize.Width() < 500 ) && ( aPrefSize.Height() < 500 ) )
+ rMTF.SetPrefMapMode( MapMode( MAP_10TH_MM ) );
+ else
+ rMTF.SetPrefMapMode( MapMode( MAP_100TH_MM ) );
+ }
+
+ delete pVirDev;
+
+ return bStatus;
+}
+
+
+
diff --git a/goodies/source/filter.vcl/idxf/dxf2mtf.hxx b/goodies/source/filter.vcl/idxf/dxf2mtf.hxx
new file mode 100644
index 000000000000..17e5cc885419
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/dxf2mtf.hxx
@@ -0,0 +1,163 @@
+/*************************************************************************
+ *
+ * $RCSfile: dxf2mtf.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DXF2MTF_HXX
+#define _DXF2MTF_HXX
+
+#include "dxfreprd.hxx"
+#include <vcl/font.hxx>
+
+#ifndef NOOLDSV
+#include <vcl/gdiobj.hxx>
+#else // NOOLDSV
+enum PenStyle { PEN_NULL, PEN_SOLID, PEN_DOT, PEN_DASH, PEN_DASHDOT };
+enum BrushStyle { BRUSH_NULL, BRUSH_SOLID, BRUSH_HORZ, BRUSH_VERT,
+ BRUSH_CROSS, BRUSH_DIAGCROSS, BRUSH_UPDIAG, BRUSH_DOWNDIAG,
+ BRUSH_25, BRUSH_50, BRUSH_75,
+ BRUSH_BITMAP };
+#endif // NOOLDSV
+
+class DXF2GDIMetaFile {
+private:
+
+ VirtualDevice * pVirDev;
+ const DXFRepresentation * pDXF;
+ BOOL bStatus;
+
+ USHORT OptPointsPerCircle;
+
+ PFilterCallback pCallback;
+ void * pCallerData;
+ ULONG nMinPercent;
+ ULONG nMaxPercent;
+ ULONG nLastPercent;
+ ULONG nMainEntitiesCount;
+
+ long nBlockColor;
+ PenStyle eBlockPStyle;
+ long nParentLayerColor;
+ PenStyle eParentLayerPStyle;
+ Color aActLineColor;
+ Color aActFillColor;
+ Font aActFont;
+
+ ULONG CountEntities(const DXFEntities & rEntities);
+
+ void MayCallback(ULONG nMainEntitiesProcessed);
+
+ Color ConvertColor(BYTE nColor);
+
+ long GetEntityColor(const DXFBasicEntity & rE);
+
+ PenStyle LTypeToPStyle(const char * sLineType);
+
+ PenStyle GetEntityPStyle(const DXFBasicEntity & rE);
+
+ BOOL SetLineAttribute(const DXFBasicEntity & rE, ULONG nWidth=0);
+
+ BOOL SetAreaAttribute(const DXFBasicEntity & rE);
+
+ BOOL SetFontAttribute(const DXFBasicEntity & rE, short nAngle,
+ USHORT nHeight, double fWidthScale);
+
+ void DrawLineEntity(const DXFLineEntity & rE, const DXFTransform & rTransform);
+
+ void DrawPointEntity(const DXFPointEntity & rE, const DXFTransform & rTransform);
+
+ void DrawCircleEntity(const DXFCircleEntity & rE, const DXFTransform & rTransform);
+
+ void DrawArcEntity(const DXFArcEntity & rE, const DXFTransform & rTransform);
+
+ void DrawTraceEntity(const DXFTraceEntity & rE, const DXFTransform & rTransform);
+
+ void DrawSolidEntity(const DXFSolidEntity & rE, const DXFTransform & rTransform);
+
+ void DrawTextEntity(const DXFTextEntity & rE, const DXFTransform & rTransform);
+
+ void DrawInsertEntity(const DXFInsertEntity & rE, const DXFTransform & rTransform);
+
+ void DrawAttribEntity(const DXFAttribEntity & rE, const DXFTransform & rTransform);
+
+ void DrawPolyLineEntity(const DXFPolyLineEntity & rE, const DXFTransform & rTransform);
+
+ void Draw3DFaceEntity(const DXF3DFaceEntity & rE, const DXFTransform & rTransform);
+
+ void DrawDimensionEntity(const DXFDimensionEntity & rE, const DXFTransform & rTransform);
+
+ void DrawEntities(const DXFEntities & rEntities,
+ const DXFTransform & rTransform,
+ BOOL bTopEntities);
+
+public:
+
+ DXF2GDIMetaFile();
+ ~DXF2GDIMetaFile();
+
+ BOOL Convert(const DXFRepresentation & rDXF, GDIMetaFile & rMTF,
+ PFilterCallback pCallback, void * pCallerData,
+ USHORT nMinPercent, USHORT nMaxPercent);
+
+};
+
+
+#endif
+
+
diff --git a/goodies/source/filter.vcl/idxf/dxfblkrd.cxx b/goodies/source/filter.vcl/idxf/dxfblkrd.cxx
new file mode 100644
index 000000000000..00520af77ea7
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/dxfblkrd.cxx
@@ -0,0 +1,167 @@
+/*************************************************************************
+ *
+ * $RCSfile: dxfblkrd.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <string.h>
+#include <dxfblkrd.hxx>
+
+
+//----------------------------------------------------------------------------
+//---------------- DXFBlock --------------------------------------------------
+//----------------------------------------------------------------------------
+
+
+DXFBlock::DXFBlock()
+{
+ pSucc=NULL;
+}
+
+
+DXFBlock::~DXFBlock()
+{
+}
+
+
+void DXFBlock::Read(DXFGroupReader & rDGR)
+{
+ sName[0]=0;
+ sAlsoName[0]=0;
+ aBasePoint.fx=0.0;
+ aBasePoint.fy=0.0;
+ aBasePoint.fz=0.0;
+ nFlags=0;
+ sXRef[0]=0;
+
+ while (rDGR.Read()!=0) switch (rDGR.GetG()) {
+ case 2: strcpy(sName,rDGR.GetS()); break;
+ case 3: strcpy(sAlsoName,rDGR.GetS()); break;
+ case 70: nFlags=rDGR.GetI(); break;
+ case 10: aBasePoint.fx=rDGR.GetF(); break;
+ case 20: aBasePoint.fy=rDGR.GetF(); break;
+ case 30: aBasePoint.fz=rDGR.GetF(); break;
+ case 1: strcpy(sXRef,rDGR.GetS()); break;
+ }
+
+ DXFEntities::Read(rDGR);
+}
+
+
+//----------------------------------------------------------------------------
+//---------------- DXFBlocks -------------------------------------------------
+//----------------------------------------------------------------------------
+
+
+DXFBlocks::DXFBlocks()
+{
+ pFirst=NULL;
+}
+
+
+DXFBlocks::~DXFBlocks()
+{
+ Clear();
+}
+
+
+void DXFBlocks::Read(DXFGroupReader & rDGR)
+{
+ DXFBlock * pB, * * ppSucc;
+
+ ppSucc=&pFirst;
+ while (*ppSucc!=NULL) ppSucc=&((*ppSucc)->pSucc);
+
+ for (;;) {
+ while (rDGR.GetG()!=0) rDGR.Read();
+ if (strcmp(rDGR.GetS(),"ENDSEC")==0 ||
+ strcmp(rDGR.GetS(),"EOF")==0) break;
+ if (strcmp(rDGR.GetS(),"BLOCK")==0) {
+ pB=new DXFBlock;
+ pB->Read(rDGR);
+ *ppSucc=pB;
+ ppSucc=&(pB->pSucc);
+ }
+ else rDGR.Read();
+ }
+}
+
+
+DXFBlock * DXFBlocks::Search(const char * sName) const
+{
+ DXFBlock * pB;
+ for (pB=pFirst; pB!=NULL; pB=pB->pSucc) {
+ if (strcmp(sName,pB->sName)==0) break;
+ }
+ return pB;
+}
+
+
+void DXFBlocks::Clear()
+{
+ DXFBlock * ptmp;
+
+ while (pFirst!=NULL) {
+ ptmp=pFirst;
+ pFirst=ptmp->pSucc;
+ delete ptmp;
+ }
+}
+
+
+
diff --git a/goodies/source/filter.vcl/idxf/dxfblkrd.hxx b/goodies/source/filter.vcl/idxf/dxfblkrd.hxx
new file mode 100644
index 000000000000..cd37d42d5d14
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/dxfblkrd.hxx
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * $RCSfile: dxfblkrd.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DXFBLKRD_HXX
+#define _DXFBLKRD_HXX
+
+#ifndef _DXFENTRD_HXX
+#include <dxfentrd.hxx>
+#endif
+
+//----------------------------------------------------------------------------
+//---------------- Ein Block (= Menge von Entities) --------------------------
+//----------------------------------------------------------------------------
+
+class DXFBlock : public DXFEntities {
+
+public:
+
+ DXFBlock * pSucc;
+ // Zeiger auf naechsten Block in der Liste DXFBlocks::pFirst
+
+ // Eigenschaften des Blocks, durch Gruppencodes kommentiert:
+ char sName[DXF_MAX_STRING_LEN+1]; // 2
+ char sAlsoName[DXF_MAX_STRING_LEN+1]; // 3
+ long nFlags; // 70
+ DXFVector aBasePoint; // 10,20,30
+ char sXRef[DXF_MAX_STRING_LEN+1]; // 1
+
+ DXFBlock();
+ ~DXFBlock();
+
+ void Read(DXFGroupReader & rDGR);
+ // Liest den Block (einschliesslich der Entities) per rGDR
+ // aus einer DXF-Datei bis zu einem ENDBLK, ENDSEC oder EOF.
+};
+
+
+//----------------------------------------------------------------------------
+//---------------- Eine Menge von Bloecken -----------------------------------
+//----------------------------------------------------------------------------
+
+class DXFBlocks {
+
+public:
+
+ DXFBlock * pFirst;
+ // Liste der Bloecke, READ ONLY!
+
+ DXFBlocks();
+ ~DXFBlocks();
+
+ void Read(DXFGroupReader & rDGR);
+ // Liesst alle Bloecke per rDGR bis zu einem ENDSEC oder EOF.
+
+ DXFBlock * Search(const char * sName) const;
+ // Sucht einen Block mit dem Namen, liefert NULL bei Misserfolg.
+
+ void Clear();
+ // Loescht alle Bloecke;
+
+};
+
+#endif
+
+
diff --git a/goodies/source/filter.vcl/idxf/dxfentrd.cxx b/goodies/source/filter.vcl/idxf/dxfentrd.cxx
new file mode 100644
index 000000000000..64b2f35869c9
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/dxfentrd.cxx
@@ -0,0 +1,575 @@
+/*************************************************************************
+ *
+ * $RCSfile: dxfentrd.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <string.h>
+#include <dxfentrd.hxx>
+
+//--------------------------DXFBasicEntity--------------------------------------
+
+DXFBasicEntity::DXFBasicEntity(DXFEntityType eThisType)
+{
+ eType=eThisType;
+ pSucc=NULL;
+ strcpy(sLayer,"0");
+ strcpy(sLineType,"BYLAYER");
+ fElevation=0;
+ fThickness=0;
+ nColor=256;
+ nSpace=0;
+ aExtrusion.fx=0.0;
+ aExtrusion.fy=0.0;
+ aExtrusion.fz=1.0;
+}
+
+void DXFBasicEntity::Read(DXFGroupReader & rDGR)
+{
+ while (rDGR.Read()!=0) EvaluateGroup(rDGR);
+}
+
+void DXFBasicEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 8: strcpy(sLayer,rDGR.GetS()); break;
+ case 6: strcpy(sLineType,rDGR.GetS()); break;
+ case 38: fElevation=rDGR.GetF(); break;
+ case 39: fThickness=rDGR.GetF(); break;
+ case 62: nColor=rDGR.GetI(); break;
+ case 67: nSpace=rDGR.GetI(); break;
+ case 210: aExtrusion.fx=rDGR.GetF(); break;
+ case 220: aExtrusion.fy=rDGR.GetF(); break;
+ case 230: aExtrusion.fz=rDGR.GetF(); break;
+ }
+}
+
+//--------------------------DXFLineEntity---------------------------------------
+
+DXFLineEntity::DXFLineEntity() : DXFBasicEntity(DXF_LINE)
+{
+}
+
+void DXFLineEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 10: aP0.fx=rDGR.GetF(); break;
+ case 20: aP0.fy=rDGR.GetF(); break;
+ case 30: aP0.fz=rDGR.GetF(); break;
+ case 11: aP1.fx=rDGR.GetF(); break;
+ case 21: aP1.fy=rDGR.GetF(); break;
+ case 31: aP1.fz=rDGR.GetF(); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+//--------------------------DXFPointEntity--------------------------------------
+
+DXFPointEntity::DXFPointEntity() : DXFBasicEntity(DXF_POINT)
+{
+}
+
+void DXFPointEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 10: aP0.fx=rDGR.GetF(); break;
+ case 20: aP0.fy=rDGR.GetF(); break;
+ case 30: aP0.fz=rDGR.GetF(); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+//--------------------------DXFCircleEntity-------------------------------------
+
+DXFCircleEntity::DXFCircleEntity() : DXFBasicEntity(DXF_CIRCLE)
+{
+ fRadius=1.0;
+}
+
+void DXFCircleEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 10: aP0.fx=rDGR.GetF(); break;
+ case 20: aP0.fy=rDGR.GetF(); break;
+ case 30: aP0.fz=rDGR.GetF(); break;
+ case 40: fRadius=rDGR.GetF(); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+//--------------------------DXFArcEntity----------------------------------------
+
+DXFArcEntity::DXFArcEntity() : DXFBasicEntity(DXF_ARC)
+{
+ fRadius=1.0;
+ fStart=0;
+ fEnd=360.0;
+}
+
+void DXFArcEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 10: aP0.fx=rDGR.GetF(); break;
+ case 20: aP0.fy=rDGR.GetF(); break;
+ case 30: aP0.fz=rDGR.GetF(); break;
+ case 40: fRadius=rDGR.GetF(); break;
+ case 50: fStart=rDGR.GetF(); break;
+ case 51: fEnd=rDGR.GetF(); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+//--------------------------DXFTraceEntity--------------------------------------
+
+DXFTraceEntity::DXFTraceEntity() : DXFBasicEntity(DXF_TRACE)
+{
+}
+
+void DXFTraceEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 10: aP0.fx=rDGR.GetF(); break;
+ case 20: aP0.fy=rDGR.GetF(); break;
+ case 30: aP0.fz=rDGR.GetF(); break;
+ case 11: aP1.fx=rDGR.GetF(); break;
+ case 21: aP1.fy=rDGR.GetF(); break;
+ case 31: aP1.fz=rDGR.GetF(); break;
+ case 12: aP2.fx=rDGR.GetF(); break;
+ case 22: aP2.fy=rDGR.GetF(); break;
+ case 32: aP2.fz=rDGR.GetF(); break;
+ case 13: aP3.fx=rDGR.GetF(); break;
+ case 23: aP3.fy=rDGR.GetF(); break;
+ case 33: aP3.fz=rDGR.GetF(); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+//--------------------------DXFSolidEntity--------------------------------------
+
+DXFSolidEntity::DXFSolidEntity() : DXFBasicEntity(DXF_SOLID)
+{
+}
+
+void DXFSolidEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 10: aP0.fx=rDGR.GetF(); break;
+ case 20: aP0.fy=rDGR.GetF(); break;
+ case 30: aP0.fz=rDGR.GetF(); break;
+ case 11: aP1.fx=rDGR.GetF(); break;
+ case 21: aP1.fy=rDGR.GetF(); break;
+ case 31: aP1.fz=rDGR.GetF(); break;
+ case 12: aP2.fx=rDGR.GetF(); break;
+ case 22: aP2.fy=rDGR.GetF(); break;
+ case 32: aP2.fz=rDGR.GetF(); break;
+ case 13: aP3.fx=rDGR.GetF(); break;
+ case 23: aP3.fy=rDGR.GetF(); break;
+ case 33: aP3.fz=rDGR.GetF(); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+//--------------------------DXFTextEntity---------------------------------------
+
+DXFTextEntity::DXFTextEntity() : DXFBasicEntity(DXF_TEXT)
+{
+ fHeight=1.0;
+ sText[0]=0;
+ fRotAngle=0.0;
+ fXScale=1.0;
+ fOblAngle=0.0;
+ strcpy(sStyle,"STANDARD");
+ nGenFlags=0;
+ nHorzJust=0;
+ nVertJust=0;
+}
+
+void DXFTextEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 10: aP0.fx=rDGR.GetF(); break;
+ case 20: aP0.fy=rDGR.GetF(); break;
+ case 30: aP0.fz=rDGR.GetF(); break;
+ case 40: fHeight=rDGR.GetF(); break;
+ case 1: strcpy(sText,rDGR.GetS()); break;
+ case 50: fRotAngle=rDGR.GetF(); break;
+ case 41: fXScale=rDGR.GetF(); break;
+ case 42: fOblAngle=rDGR.GetF(); break;
+ case 7: strcpy(sStyle,rDGR.GetS()); break;
+ case 71: nGenFlags=rDGR.GetI(); break;
+ case 72: nHorzJust=rDGR.GetI(); break;
+ case 73: nVertJust=rDGR.GetI(); break;
+ case 11: aAlign.fx=rDGR.GetF(); break;
+ case 21: aAlign.fy=rDGR.GetF(); break;
+ case 31: aAlign.fz=rDGR.GetF(); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+//--------------------------DXFShapeEntity--------------------------------------
+
+DXFShapeEntity::DXFShapeEntity() : DXFBasicEntity(DXF_SHAPE)
+{
+ fSize=1.0;
+ sName[0]=0;
+ fRotAngle=0;
+ fXScale=1.0;
+ fOblAngle=0;
+}
+
+void DXFShapeEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 10: aP0.fx=rDGR.GetF(); break;
+ case 20: aP0.fy=rDGR.GetF(); break;
+ case 30: aP0.fz=rDGR.GetF(); break;
+ case 40: fSize=rDGR.GetF(); break;
+ case 2: strcpy(sName,rDGR.GetS()); break;
+ case 50: fRotAngle=rDGR.GetF(); break;
+ case 41: fXScale=rDGR.GetF(); break;
+ case 51: fOblAngle=rDGR.GetF(); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+//--------------------------DXFInsertEntity-------------------------------------
+
+DXFInsertEntity::DXFInsertEntity() : DXFBasicEntity(DXF_INSERT)
+{
+ nAttrFlag=0;
+ sName[0]=0;
+ fXScale=1.0;
+ fYScale=1.0;
+ fZScale=1.0;
+ fRotAngle=0.0;
+ nColCount=1;
+ nRowCount=1;
+ fColSpace=0.0;
+ fRowSpace=0.0;
+}
+
+void DXFInsertEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 66: nAttrFlag=rDGR.GetI(); break;
+ case 2: strcpy(sName,rDGR.GetS()); break;
+ case 10: aP0.fx=rDGR.GetF(); break;
+ case 20: aP0.fy=rDGR.GetF(); break;
+ case 30: aP0.fz=rDGR.GetF(); break;
+ case 41: fXScale=rDGR.GetF(); break;
+ case 42: fYScale=rDGR.GetF(); break;
+ case 43: fZScale=rDGR.GetF(); break;
+ case 50: fRotAngle=rDGR.GetF(); break;
+ case 70: nColCount=rDGR.GetI(); break;
+ case 71: nRowCount=rDGR.GetI(); break;
+ case 44: fColSpace=rDGR.GetF(); break;
+ case 45: fRowSpace=rDGR.GetF(); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+//--------------------------DXFAttDefEntity-------------------------------------
+
+DXFAttDefEntity::DXFAttDefEntity() : DXFBasicEntity(DXF_ATTDEF)
+{
+ fHeight=1.0;
+ sDefVal[0]=0;
+ sPrompt[0]=0;
+ sTagStr[0]=0;
+ nAttrFlags=0;
+ nFieldLen=0;
+ fRotAngle=0.0;
+ fXScale=1.0;
+ fOblAngle=0.0;
+ strcpy(sStyle,"STANDARD");
+ nGenFlags=0;
+ nHorzJust=0;
+ nVertJust=0;
+}
+
+void DXFAttDefEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 10: aP0.fx=rDGR.GetF(); break;
+ case 20: aP0.fy=rDGR.GetF(); break;
+ case 30: aP0.fz=rDGR.GetF(); break;
+ case 40: fHeight=rDGR.GetF(); break;
+ case 1: strcpy(sDefVal,rDGR.GetS()); break;
+ case 3: strcpy(sPrompt,rDGR.GetS()); break;
+ case 2: strcpy(sTagStr,rDGR.GetS()); break;
+ case 70: nAttrFlags=rDGR.GetI(); break;
+ case 73: nFieldLen=rDGR.GetI(); break;
+ case 50: fRotAngle=rDGR.GetF(); break;
+ case 41: fXScale=rDGR.GetF(); break;
+ case 51: fOblAngle=rDGR.GetF(); break;
+ case 7: strcpy(sStyle,rDGR.GetS()); break;
+ case 71: nGenFlags=rDGR.GetI(); break;
+ case 72: nHorzJust=rDGR.GetI(); break;
+ case 74: nVertJust=rDGR.GetI(); break;
+ case 11: aAlign.fx=rDGR.GetF(); break;
+ case 21: aAlign.fy=rDGR.GetF(); break;
+ case 31: aAlign.fz=rDGR.GetF(); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+//--------------------------DXFAttribEntity-------------------------------------
+
+DXFAttribEntity::DXFAttribEntity() : DXFBasicEntity(DXF_ATTRIB)
+{
+ fHeight=1.0;
+ sText[0]=0;
+ sTagStr[0]=0;
+ nAttrFlags=0;
+ nFieldLen=0;
+ fRotAngle=0.0;
+ fXScale=1.0;
+ fOblAngle=0.0;
+ strcpy(sStyle,"STANDARD");
+ nGenFlags=0;
+ nHorzJust=0;
+ nVertJust=0;
+}
+
+void DXFAttribEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 10: aP0.fx=rDGR.GetF(); break;
+ case 20: aP0.fy=rDGR.GetF(); break;
+ case 30: aP0.fz=rDGR.GetF(); break;
+ case 40: fHeight=rDGR.GetF(); break;
+ case 1: strcpy(sText,rDGR.GetS()); break;
+ case 2: strcpy(sTagStr,rDGR.GetS()); break;
+ case 70: nAttrFlags=rDGR.GetI(); break;
+ case 73: nFieldLen=rDGR.GetI(); break;
+ case 50: fRotAngle=rDGR.GetF(); break;
+ case 41: fXScale=rDGR.GetF(); break;
+ case 51: fOblAngle=rDGR.GetF(); break;
+ case 7: strcpy(sStyle,rDGR.GetS()); break;
+ case 71: nGenFlags=rDGR.GetI(); break;
+ case 72: nHorzJust=rDGR.GetI(); break;
+ case 74: nVertJust=rDGR.GetI(); break;
+ case 11: aAlign.fx=rDGR.GetF(); break;
+ case 21: aAlign.fy=rDGR.GetF(); break;
+ case 31: aAlign.fz=rDGR.GetF(); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+//--------------------------DXFPolyLine-----------------------------------------
+
+DXFPolyLineEntity::DXFPolyLineEntity() : DXFBasicEntity(DXF_POLYLINE)
+{
+ fElevation=0.0;
+ nFlags=0;
+ fSWidth=0.0;
+ fEWidth=0.0;
+ nMeshMCount=0;
+ nMeshNCount=0;
+ nMDensity=0;
+ nNDensity=0;
+ nCSSType=0;
+}
+
+void DXFPolyLineEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 30: fElevation=rDGR.GetF(); break;
+ case 70: nFlags=rDGR.GetI(); break;
+ case 40: fSWidth=rDGR.GetF(); break;
+ case 41: fEWidth=rDGR.GetF(); break;
+ case 71: nMeshMCount=rDGR.GetI(); break;
+ case 72: nMeshNCount=rDGR.GetI(); break;
+ case 73: nMDensity=rDGR.GetI(); break;
+ case 74: nNDensity=rDGR.GetI(); break;
+ case 75: nCSSType=rDGR.GetI(); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+//--------------------------DXFVertexEntity-------------------------------------
+
+DXFVertexEntity::DXFVertexEntity() : DXFBasicEntity(DXF_VERTEX)
+{
+ fSWidth=-1.0;
+ fEWidth=-1.0;
+ fBulge=0.0;
+ nFlags=0;
+ fCFTDir=0.0;
+
+}
+
+void DXFVertexEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 10: aP0.fx=rDGR.GetF(); break;
+ case 20: aP0.fy=rDGR.GetF(); break;
+ case 30: aP0.fz=rDGR.GetF(); break;
+ case 40: fSWidth=rDGR.GetF(); break;
+ case 41: fEWidth=rDGR.GetF(); break;
+ case 42: fBulge=rDGR.GetF(); break;
+ case 70: nFlags=rDGR.GetI(); break;
+ case 50: fCFTDir=rDGR.GetF(); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+//--------------------------DXFSeqEndEntity-------------------------------------
+
+DXFSeqEndEntity::DXFSeqEndEntity() : DXFBasicEntity(DXF_SEQEND)
+{
+}
+
+//--------------------------DXF3DFace-------------------------------------------
+
+DXF3DFaceEntity::DXF3DFaceEntity() : DXFBasicEntity(DXF_3DFACE)
+{
+ nIEFlags=0;
+}
+
+void DXF3DFaceEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 10: aP0.fx=rDGR.GetF(); break;
+ case 20: aP0.fy=rDGR.GetF(); break;
+ case 30: aP0.fz=rDGR.GetF(); break;
+ case 11: aP1.fx=rDGR.GetF(); break;
+ case 21: aP1.fy=rDGR.GetF(); break;
+ case 31: aP1.fz=rDGR.GetF(); break;
+ case 12: aP2.fx=rDGR.GetF(); break;
+ case 22: aP2.fy=rDGR.GetF(); break;
+ case 32: aP2.fz=rDGR.GetF(); break;
+ case 13: aP3.fx=rDGR.GetF(); break;
+ case 23: aP3.fy=rDGR.GetF(); break;
+ case 33: aP3.fz=rDGR.GetF(); break;
+ case 70: nIEFlags=rDGR.GetI(); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+
+//--------------------------DXFDimensionEntity----------------------------------
+
+DXFDimensionEntity::DXFDimensionEntity() : DXFBasicEntity(DXF_DIMENSION)
+{
+ sPseudoBlock[0]=0;
+}
+
+void DXFDimensionEntity::EvaluateGroup(DXFGroupReader & rDGR)
+{
+ switch (rDGR.GetG()) {
+ case 2: strcpy(sPseudoBlock,rDGR.GetS()); break;
+ default: DXFBasicEntity::EvaluateGroup(rDGR);
+ }
+}
+
+//---------------------------- DXFEntites --------------------------------------
+
+void DXFEntities::Read(DXFGroupReader & rDGR)
+{
+ DXFBasicEntity * pE, * * ppSucc;
+
+ ppSucc=&pFirst;
+ while (*ppSucc!=NULL) ppSucc=&((*ppSucc)->pSucc);
+
+ while (rDGR.GetG()!=0) rDGR.Read();
+
+ while (strcmp(rDGR.GetS(),"ENDBLK")!=0 &&
+ strcmp(rDGR.GetS(),"ENDSEC")!=0 &&
+ strcmp(rDGR.GetS(),"EOF")!=0 )
+ {
+
+ if (strcmp(rDGR.GetS(),"LINE" )==0) pE=new DXFLineEntity;
+ else if (strcmp(rDGR.GetS(),"POINT" )==0) pE=new DXFPointEntity;
+ else if (strcmp(rDGR.GetS(),"CIRCLE" )==0) pE=new DXFCircleEntity;
+ else if (strcmp(rDGR.GetS(),"ARC" )==0) pE=new DXFArcEntity;
+ else if (strcmp(rDGR.GetS(),"TRACE" )==0) pE=new DXFTraceEntity;
+ else if (strcmp(rDGR.GetS(),"SOLID" )==0) pE=new DXFSolidEntity;
+ else if (strcmp(rDGR.GetS(),"TEXT" )==0) pE=new DXFTextEntity;
+ else if (strcmp(rDGR.GetS(),"SHAPE" )==0) pE=new DXFShapeEntity;
+ else if (strcmp(rDGR.GetS(),"INSERT" )==0) pE=new DXFInsertEntity;
+ else if (strcmp(rDGR.GetS(),"ATTDEF" )==0) pE=new DXFAttDefEntity;
+ else if (strcmp(rDGR.GetS(),"ATTRIB" )==0) pE=new DXFAttribEntity;
+ else if (strcmp(rDGR.GetS(),"POLYLINE" )==0) pE=new DXFPolyLineEntity;
+ else if (strcmp(rDGR.GetS(),"VERTEX" )==0) pE=new DXFVertexEntity;
+ else if (strcmp(rDGR.GetS(),"SEQEND" )==0) pE=new DXFSeqEndEntity;
+ else if (strcmp(rDGR.GetS(),"3DFACE" )==0) pE=new DXF3DFaceEntity;
+ else if (strcmp(rDGR.GetS(),"DIMENSION")==0) pE=new DXFDimensionEntity;
+ else {
+ do {
+ rDGR.Read();
+ } while (rDGR.GetG()!=0);
+ continue;
+ }
+ *ppSucc=pE;
+ ppSucc=&(pE->pSucc);
+ pE->Read(rDGR);
+ }
+}
+
+void DXFEntities::Clear()
+{
+ DXFBasicEntity * ptmp;
+
+ while (pFirst!=NULL) {
+ ptmp=pFirst;
+ pFirst=ptmp->pSucc;
+ delete ptmp;
+ }
+}
+
diff --git a/goodies/source/filter.vcl/idxf/dxfentrd.hxx b/goodies/source/filter.vcl/idxf/dxfentrd.hxx
new file mode 100644
index 000000000000..b15786b3bef2
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/dxfentrd.hxx
@@ -0,0 +1,498 @@
+/*************************************************************************
+ *
+ * $RCSfile: dxfentrd.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DXFENTRD_HXX
+#define _DXFENTRD_HXX
+
+#ifndef _DXFGRPRD_HXX
+#include <dxfgrprd.hxx>
+#endif
+
+#ifndef _DXFVEC_HXX
+#include <dxfvec.hxx>
+#endif
+
+//------------------------------------------------------------------------------
+//------------------------- Art eines Entity -----------------------------------
+//------------------------------------------------------------------------------
+
+enum DXFEntityType {
+ DXF_LINE,
+ DXF_POINT,
+ DXF_CIRCLE,
+ DXF_ARC,
+ DXF_TRACE,
+ DXF_SOLID,
+ DXF_TEXT,
+ DXF_SHAPE,
+ DXF_INSERT,
+ DXF_ATTDEF,
+ DXF_ATTRIB,
+ DXF_POLYLINE,
+ DXF_VERTEX,
+ DXF_SEQEND,
+ DXF_3DFACE,
+ DXF_DIMENSION
+};
+
+//------------------------------------------------------------------------------
+//---------------------- Basisklasse fuer ein Entity ---------------------------
+//------------------------------------------------------------------------------
+
+class DXFBasicEntity {
+
+public:
+
+ DXFBasicEntity * pSucc;
+ // Zeiger auf naechstes Entity (in der Liste DXFEntities.pFirst)
+
+ DXFEntityType eType;
+ // Art des Entitys (Linie oder Kreis oder was)
+
+ // Eigenschaftenm, die alle Entities besitzen, jeweils
+ // durch den Gruppencode kommentiert:
+ char sLayer[DXF_MAX_STRING_LEN+1]; // 8
+ char sLineType[DXF_MAX_STRING_LEN+1]; // 6
+ double fElevation; // 38
+ double fThickness; // 39
+ long nColor; // 62
+ long nSpace; // 67
+ DXFVector aExtrusion; // 210,220,230
+
+protected:
+
+ DXFBasicEntity(DXFEntityType eThisType);
+ // Konstruktoren der Entities initialiseren immer mit Defaultwerten.
+
+public:
+
+ virtual void Read(DXFGroupReader & rDGR);
+ // Liest die Prameter ein, bis zur naechten 0-Gruppe
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+ // Diese Methode wird durch Read() fuer jeden Parameter (bzw. fuer jede
+ // Gruppe) aufgerufen.
+ // Sofern der Gruppencode dem Entity bekannt ist, wird der entsprechende
+ // Parameter geholt.
+
+};
+
+//------------------------------------------------------------------------------
+//---------------- die verschiedenen Arten von Entyties ------------------------
+//------------------------------------------------------------------------------
+
+//--------------------------Line------------------------------------------------
+
+class DXFLineEntity : public DXFBasicEntity {
+
+public:
+
+ DXFVector aP0; // 10,20,30
+ DXFVector aP1; // 11,21,31
+
+ DXFLineEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//--------------------------Point-----------------------------------------------
+
+class DXFPointEntity : public DXFBasicEntity {
+
+public:
+
+ DXFVector aP0; // 10,20,30
+
+ DXFPointEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//--------------------------Circle----------------------------------------------
+
+class DXFCircleEntity : public DXFBasicEntity {
+
+public:
+
+ DXFVector aP0; // 10,20,30
+ double fRadius; // 40
+
+ DXFCircleEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//--------------------------Arc-------------------------------------------------
+
+class DXFArcEntity : public DXFBasicEntity {
+
+public:
+
+ DXFVector aP0; // 10,20,30
+ double fRadius; // 40
+ double fStart; // 50
+ double fEnd; // 51
+
+ DXFArcEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//--------------------------Trace-----------------------------------------------
+
+class DXFTraceEntity : public DXFBasicEntity {
+
+public:
+
+ DXFVector aP0; // 10,20,30
+ DXFVector aP1; // 11,21,31
+ DXFVector aP2; // 12,22,32
+ DXFVector aP3; // 13,23,33
+
+ DXFTraceEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//--------------------------Solid-----------------------------------------------
+
+class DXFSolidEntity : public DXFBasicEntity {
+
+public:
+
+ DXFVector aP0; // 10,20,30
+ DXFVector aP1; // 11,21,31
+ DXFVector aP2; // 12,22,32
+ DXFVector aP3; // 13,23,33
+
+ DXFSolidEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//--------------------------Text------------------------------------------------
+
+class DXFTextEntity : public DXFBasicEntity {
+
+public:
+
+ DXFVector aP0; // 10,20,30
+ double fHeight; // 40
+ char sText[DXF_MAX_STRING_LEN+1]; // 1
+ double fRotAngle; // 50
+ double fXScale; // 41
+ double fOblAngle; // 42
+ char sStyle[DXF_MAX_STRING_LEN+1]; // 7
+ long nGenFlags; // 71
+ long nHorzJust; // 72
+ long nVertJust; // 73
+ DXFVector aAlign; // 11,21,31
+
+ DXFTextEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//--------------------------Shape-----------------------------------------------
+
+class DXFShapeEntity : public DXFBasicEntity {
+
+public:
+
+ DXFVector aP0; // 10,20,30
+ double fSize; // 40
+ char sName[DXF_MAX_STRING_LEN+1]; // 2
+ double fRotAngle; // 50
+ double fXScale; // 41
+ double fOblAngle; // 51
+
+ DXFShapeEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//--------------------------Insert----------------------------------------------
+
+class DXFInsertEntity : public DXFBasicEntity {
+
+public:
+
+ long nAttrFlag; // 66
+ char sName[DXF_MAX_STRING_LEN+1]; // 2
+ DXFVector aP0; // 10,20,30
+ double fXScale; // 41
+ double fYScale; // 42
+ double fZScale; // 43
+ double fRotAngle; // 50
+ long nColCount; // 70
+ long nRowCount; // 71
+ double fColSpace; // 44
+ double fRowSpace; // 45
+
+ DXFInsertEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//--------------------------AttDef----------------------------------------------
+
+class DXFAttDefEntity : public DXFBasicEntity {
+
+public:
+
+ DXFVector aP0; // 10,20,30
+ double fHeight; // 40
+ char sDefVal[DXF_MAX_STRING_LEN+1]; // 1
+ char sPrompt[DXF_MAX_STRING_LEN+1]; // 3
+ char sTagStr[DXF_MAX_STRING_LEN+1]; // 2
+ long nAttrFlags; // 70
+ long nFieldLen; // 73
+ double fRotAngle; // 50
+ double fXScale; // 41
+ double fOblAngle; // 51
+ char sStyle[DXF_MAX_STRING_LEN+1]; // 7
+ long nGenFlags; // 71
+ long nHorzJust; // 72
+ long nVertJust; // 74
+ DXFVector aAlign; // 11,21,31
+
+ DXFAttDefEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//--------------------------Attrib----------------------------------------------
+
+class DXFAttribEntity : public DXFBasicEntity {
+
+public:
+
+ DXFVector aP0; // 10,20,30
+ double fHeight; // 40
+ char sText[DXF_MAX_STRING_LEN+1]; // 1
+ char sTagStr[DXF_MAX_STRING_LEN+1]; // 2
+ long nAttrFlags; // 70
+ long nFieldLen; // 73
+ double fRotAngle; // 50
+ double fXScale; // 41
+ double fOblAngle; // 51
+ char sStyle[DXF_MAX_STRING_LEN+1]; // 7
+ long nGenFlags; // 71
+ long nHorzJust; // 72
+ long nVertJust; // 74
+ DXFVector aAlign; // 11,21,31
+
+ DXFAttribEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//--------------------------PolyLine--------------------------------------------
+
+class DXFPolyLineEntity : public DXFBasicEntity {
+
+public:
+
+ double fElevation; // 30
+ long nFlags; // 70
+ double fSWidth; // 40
+ double fEWidth; // 41
+ long nMeshMCount; // 71
+ long nMeshNCount; // 72
+ long nMDensity; // 73
+ long nNDensity; // 74
+ long nCSSType; // 75
+
+ DXFPolyLineEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//--------------------------Vertex----------------------------------------------
+
+class DXFVertexEntity : public DXFBasicEntity {
+
+public:
+
+ DXFVector aP0; // 10,20,30
+ double fSWidth; // 40 (Wenn <0.0, dann gilt DXFPolyLine::fSWidth)
+ double fEWidth; // 41 (Wenn <0.0, dann gilt DXFPolyLine::fEWidth)
+ double fBulge; // 42
+ long nFlags; // 70
+ double fCFTDir; // 50
+
+ DXFVertexEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//--------------------------SeqEnd----------------------------------------------
+
+class DXFSeqEndEntity : public DXFBasicEntity {
+
+public:
+
+ DXFSeqEndEntity();
+};
+
+//--------------------------3DFace----------------------------------------------
+
+class DXF3DFaceEntity : public DXFBasicEntity {
+
+public:
+
+ DXFVector aP0; // 10,20,30
+ DXFVector aP1; // 11,21,31
+ DXFVector aP2; // 12,22,32
+ DXFVector aP3; // 13,23,33
+ long nIEFlags; // 70
+
+ DXF3DFaceEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//--------------------------Dimension-------------------------------------------
+
+class DXFDimensionEntity : public DXFBasicEntity {
+
+public:
+
+ char sPseudoBlock[DXF_MAX_STRING_LEN+1]; // 2
+
+ DXFDimensionEntity();
+
+protected:
+
+ virtual void EvaluateGroup(DXFGroupReader & rDGR);
+};
+
+//------------------------------------------------------------------------------
+//----------- Eine Menge von Entities lesen und repraesentieren ----------------
+//------------------------------------------------------------------------------
+
+class DXFEntities {
+
+public:
+
+ DXFEntities();
+ ~DXFEntities();
+
+ DXFBasicEntity * pFirst; // Liste von Entities, READ ONLY!
+
+ void Read(DXFGroupReader & rDGR);
+ // Liest Entitis per rGDR aus einer DXF-Datei bis zu
+ // einem ENDBLK, ENDSEC oder EOF (der Gruppe 0).
+ // (Alle unbekannten Dinge werden uebersprungen)
+
+ void Clear();
+ // Loescht alle Entities
+};
+
+//------------------------------------------------------------------------------
+//--------------------------------- inlines ------------------------------------
+//------------------------------------------------------------------------------
+
+inline DXFEntities::DXFEntities()
+{
+ pFirst=NULL;
+}
+
+
+inline DXFEntities::~DXFEntities()
+{
+ Clear();
+}
+
+
+#endif
+
+
diff --git a/goodies/source/filter.vcl/idxf/dxfgrprd.cxx b/goodies/source/filter.vcl/idxf/dxfgrprd.cxx
new file mode 100644
index 000000000000..3ad434061879
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/dxfgrprd.cxx
@@ -0,0 +1,388 @@
+/*************************************************************************
+ *
+ * $RCSfile: dxfgrprd.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <string.h>
+#include <stdlib.h>
+#include <tools/stream.hxx>
+#include "dxfgrprd.hxx"
+
+// ----------------------------------------------------------------------------
+
+// we use an own ReadLine function, because Stream::ReadLine stops if
+// a 0-sign occurs; this functions converts 0-signs to blanks and reads
+// a complete line until a cr/lf is found
+
+BOOL DXFReadLine( SvStream& rIStm, ByteString& rStr )
+{
+ char buf[256 + 1];
+ BOOL bEnd = FALSE;
+ ULONG nOldFilePos = rIStm.Tell();
+ char c = 0;
+
+ rStr.Erase();
+
+ while( !bEnd && !rIStm.GetError() ) // !!! nicht auf EOF testen,
+ // !!! weil wir blockweise
+ // !!! lesen
+ {
+ USHORT nLen = (USHORT)rIStm.Read( buf, sizeof(buf)-1 );
+ if( !nLen )
+ if( rStr.Len() == 0 )
+ return FALSE;
+ else
+ break;
+
+ for( USHORT n = 0; n < nLen ; n++ )
+ {
+ c = buf[n];
+ if( c != '\n' && c != '\r' )
+ {
+ if( !c )
+ c = ' ';
+ rStr += c;
+ }
+ else
+ {
+ bEnd = TRUE;
+ break;
+ }
+ }
+ }
+
+ if( !bEnd && !rIStm.GetError() && rStr.Len() )
+ bEnd = TRUE;
+
+ nOldFilePos += rStr.Len();
+ if( rIStm.Tell() > nOldFilePos )
+ nOldFilePos++;
+ rIStm.Seek( nOldFilePos ); // seeken wg. obigem BlockRead!
+
+ if( bEnd && (c=='\r' || c=='\n')) // Sonderbehandlung DOS-Dateien
+ {
+ char cTemp;
+ rIStm.Read((char*)&cTemp , sizeof(cTemp) );
+ if( cTemp == c || (cTemp != '\n' && cTemp != '\r') )
+ rIStm.Seek( nOldFilePos );
+ }
+
+ return bEnd;
+}
+
+// ------------------
+
+DXFGroupReader::DXFGroupReader(SvStream & rIStream,
+ PFilterCallback pcallback, void * pcallerdata,
+ USHORT nminpercent, USHORT nmaxpercent) :
+ rIS(rIStream)
+{
+ USHORT i;
+
+ nIBuffPos=0;
+ nIBuffSize=0;
+ bStatus=TRUE;
+ nLastG=0;
+ nGCount=0;
+
+ pCallback=pcallback;
+ pCallerData=pcallerdata;
+ nMinPercent=(ULONG)nminpercent;
+ nMaxPercent=(ULONG)nmaxpercent;
+ nLastPercent=nMinPercent;
+
+ rIS.Seek(STREAM_SEEK_TO_END);
+ nFileSize=rIS.Tell();
+ rIS.Seek(0);
+
+ for (i=0; i<10; i++) S0_9[i][0]=0;
+ for (i=0; i<50; i++) F10_59[i]=0.0;
+ for (i=0; i<20; i++) I60_79[i]=0;
+ for (i=0; i< 8; i++) F140_147[i]=0.0;
+ for (i=0; i< 6; i++) I170_175[i]=0;
+ for (i=0; i<30; i++) F210_239[i]=0.0;
+ for (i=0; i<11; i++) S999_1009[i][0]=0;
+ for (i=0; i<50; i++) F1010_1059[i]=0.0;
+ for (i=0; i<20; i++) I1060_1079[i]=0;
+
+}
+
+
+USHORT DXFGroupReader::Read()
+{
+ USHORT nG;
+
+ if (bStatus==FALSE) goto LErr;
+
+ nGCount++;
+
+ nG=(USHORT)ReadI();
+
+ if (bStatus==FALSE) goto LErr;
+
+ if (nG< 10) ReadS(S0_9[nG]);
+ else if (nG< 60) F10_59[nG-10]=ReadF();
+ else if (nG< 80) I60_79[nG-60]=ReadI();
+ else if (nG< 140) goto LErr;
+ else if (nG< 148) F140_147[nG-140]=ReadF();
+ else if (nG< 170) goto LErr;
+ else if (nG< 176) I170_175[nG-175]=ReadI();
+ else if (nG< 180) ReadI();
+ else if (nG< 210) goto LErr;
+ else if (nG< 240) F210_239[nG-210]=ReadF();
+ else if (nG< 999) goto LErr;
+ else if (nG<1010) ReadS(S999_1009[nG-999]);
+ else if (nG<1060) F1010_1059[nG-1010]=ReadF();
+ else if (nG<1080) I1060_1079[nG-1060]=ReadI();
+ else goto LErr;
+
+ if (bStatus==FALSE) goto LErr;
+
+ nLastG=nG;
+ return nG;
+
+LErr:
+ bStatus=FALSE;
+ nLastG=0;
+ SetS(0,"EOF");
+
+ if (nGCount!=0xffffffff) {
+ // InfoBox(NULL,String("Fehler ab Gruppe Nr ")+String(nGCount)).Execute();
+ nGCount=0xffffffff;
+ }
+
+ return 0;
+}
+
+
+long DXFGroupReader::GetI(USHORT nG)
+{
+ nG-=60;
+ if (nG<20) return I60_79[nG];
+ else {
+ nG-=110;
+ if (nG<6) return I170_175[nG];
+ else {
+ nG-=890;
+ if (nG<20) return I1060_1079[nG];
+ else return 0;
+ }
+ }
+}
+
+double DXFGroupReader::GetF(USHORT nG)
+{
+ nG-=10;
+ if (nG<50) return F10_59[nG];
+ else {
+ nG-=130;
+ if (nG<8) return F140_147[nG];
+ else {
+ nG-=70;
+ if (nG<30) return F210_239[nG];
+ else {
+ nG-=800;
+ if (nG<50) return F1010_1059[nG];
+ else return 0;
+ }
+ }
+ }
+}
+
+const char * DXFGroupReader::GetS(USHORT nG)
+{
+ if (nG<10) return S0_9[nG];
+ else {
+ nG-=999;
+ if (nG<11) return S999_1009[nG];
+ else return NULL;
+ }
+}
+
+void DXFGroupReader::SetI(USHORT nG, long nI)
+{
+ nG-=60;
+ if (nG<20) I60_79[nG]=nI;
+ else {
+ nG-=110;
+ if (nG<6) I170_175[nG]=nI;
+ else {
+ nG-=890;
+ if (nG<20) I1060_1079[nG]=nI;
+ }
+ }
+}
+
+
+void DXFGroupReader::SetF(USHORT nG, double fF)
+{
+ nG-=10;
+ if (nG<50) F10_59[nG]=fF;
+ else {
+ nG-=130;
+ if (nG<8) F140_147[nG]=fF;
+ else {
+ nG-=70;
+ if (nG<30) F210_239[nG]=fF;
+ else {
+ nG-=800;
+ if (nG<50) F1010_1059[nG]=fF;
+ }
+ }
+ }
+}
+
+
+void DXFGroupReader::SetS(USHORT nG, const char * sS)
+{
+ if (nG<10) strcpy(S0_9[nG],sS);
+ else {
+ nG-=999;
+ if (nG<11) strcpy(S999_1009[nG],sS);
+ }
+}
+
+
+void DXFGroupReader::FillIBuff()
+{
+}
+
+
+void DXFGroupReader::ReadLine(char * ptgt)
+{
+ ByteString aStr;
+ ULONG nLen;
+
+ DXFReadLine( rIS, aStr );
+ memcpy( ptgt, aStr.GetBuffer(), nLen = aStr.Len() );
+ ptgt[ nLen ] = 0x00;
+
+ if ( pCallback )
+ {
+ const ULONG nPercent= nMinPercent + (nMaxPercent-nMinPercent)*rIS.Tell() / nFileSize;
+
+ if ( nPercent >= nLastPercent + 4 )
+ {
+ nLastPercent=nPercent;
+ if (((*pCallback)(pCallerData,(USHORT)nPercent))==TRUE)
+ bStatus=FALSE;
+ }
+ }
+}
+
+
+long DXFGroupReader::ReadI()
+{
+ char sl[DXF_MAX_STRING_LEN+1],*p;
+ long res,nv;
+
+ ReadLine(sl);
+
+ p=sl;
+
+ while(*p==0x20) p++;
+
+ if ((*p<'0' || *p>'9') && *p!='-') {
+ bStatus=FALSE;
+ return 0;
+ }
+
+ if (*p=='-') {
+ nv=-1;
+ p++;
+ }
+ else nv=1;
+
+ res=0;
+ do {
+ res=res*10+(long)(*p-'0');
+ p++;
+ } while (*p>='0' && *p<='9');
+
+ while (*p==0x20) p++;
+ if (*p!=0) {
+ bStatus=FALSE;
+ return 0;
+ }
+
+ return res*nv;
+}
+
+
+double DXFGroupReader::ReadF()
+{
+ char sl[DXF_MAX_STRING_LEN+1],*p;
+
+ ReadLine(sl);
+ p=sl;
+ while(*p==0x20) p++;
+ if ((*p<'0' || *p>'9') && *p!='.' && *p!='-') {
+ bStatus=FALSE;
+ return 0.0;
+ }
+ return atof(p);
+}
+
+
+void DXFGroupReader::ReadS(char * ptgt)
+{
+ ReadLine(ptgt);
+}
+
+
diff --git a/goodies/source/filter.vcl/idxf/dxfgrprd.hxx b/goodies/source/filter.vcl/idxf/dxfgrprd.hxx
new file mode 100644
index 000000000000..56b751b71dbb
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/dxfgrprd.hxx
@@ -0,0 +1,200 @@
+/*************************************************************************
+ *
+ * $RCSfile: dxfgrprd.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DXFGRPRD_HXX
+#define _DXFGRPRD_HXX
+
+#include <svtools/fltcall.hxx>
+
+#define DXF_MAX_STRING_LEN 256 // Max Stringlaenge (ohne die 0)
+
+
+class DXFGroupReader
+{
+
+public:
+
+ // Anmerkkung:
+ // sizeof(DXFGroupReader) ist gross, also nur dynamisch anlegen!
+
+ DXFGroupReader(SvStream & rIStream,
+ PFilterCallback pCallback, void * pCallerData,
+ USHORT nMinPercent, USHORT nMaxPercent);
+
+ BOOL GetStatus();
+
+ void SetError();
+
+ USHORT Read();
+ // Liesst die naechste Gruppe ein und liefert den Gruppencode zurueck.
+ // Im Falle eines Fehlers liefert GetStatus() FALSE, Gruppencode wird 0
+ // gesetzt, und es wird SetS(0,"EOF") ausgefuehrt.
+
+ USHORT GetG();
+ // Liefert den letzten Gruppencode (also was Read() zuletzt lieferte)
+
+ long GetI();
+ // Liefert den Integer-Wert zur Gruppe, die vorher mit Read() gelesen wurde.
+ // Dabei muss es sich um einen Gruppencode fuer den Datentyp Integer
+ // gehandelt haben, wenn nicht, wird 0 gelieferet.
+
+ double GetF();
+ // Liefert den Floatingpoint-Wert zur Gruppe, die vorher mit Read() gelesen wurde.
+ // Dabei muss es sich um einen Gruppencode fuer den Datentyp Floatingpoint
+ // gehandelt haben, wenn nicht, wird 0 geliefert.
+
+ const char * GetS();
+ // Liefert den String zur Gruppe, die vorher mit Read() gelesen wurde.
+ // Dabei muss es sich um einen Gruppencode fuer den Datentyp String
+ // gehandelt haben, wenn nicht, wird NULL geliefert.
+
+ // Folgende drei Methoden arbeiten wie die obigen, nur kann auch ein anderer als der
+ // aktuelle Gruppencode angegeben werden. (DXFGroupReader speichert die Parameter
+ // zu allen Gruppencodes. Dadurch ist es moeglich, dass zunaechst mit Read() einige
+ // verschiedene Gruppen eingelesen werden, bevor sie ausgewertet werden.)
+ long GetI(USHORT nG);
+ double GetF(USHORT nG);
+ const char * GetS(USHORT nG);
+
+ // Mit folgenden Methoden koennen die aktuell gespeicherten Werte zu den
+ // Gruppencodes veraendert werden. (z.B. um Defaultwerte zu setzen, bevor
+ // 'blind' eine Menge von Gruppen eingelesen wird.)
+ void SetI(USHORT nG, long nI);
+ void SetF(USHORT nG, double fF);
+ void SetS(USHORT nG, const char * sS); // (wird kopiert)
+
+private:
+
+ void FillIBuff();
+ char ReadChar();
+ void ReadLine(char * ptgt);
+ long ReadI();
+ double ReadF();
+ void ReadS(char * ptgt);
+
+ SvStream & rIS;
+ char sIBuff[1024];
+ USHORT nIBuffSize,nIBuffPos;
+ BOOL bStatus;
+ USHORT nLastG;
+ ULONG nGCount;
+
+ PFilterCallback pCallback;
+ void * pCallerData;
+ ULONG nMinPercent;
+ ULONG nMaxPercent;
+ ULONG nLastPercent;
+ ULONG nFileSize;
+
+ char S0_9 [10][DXF_MAX_STRING_LEN+1]; // Strings Gruppencodes 0..9
+ double F10_59 [50]; // Floats Gruppencodes 10..59
+ long I60_79 [20]; // Integers Gruppencodes 60..79
+ double F140_147 [ 8]; // Floats Gruppencodes 140..147
+ long I170_175 [ 6]; // Integers Gruppencodes 170..175
+ double F210_239 [30]; // Floats Gruppencodes 210..239
+ char S999_1009 [11][DXF_MAX_STRING_LEN+1]; // Strings Gruppencodes 999..1009
+ double F1010_1059[50]; // Floats Gruppencodes 1010..1059
+ long I1060_1079[20]; // Integers Gruppencodes 1060..1079
+
+};
+
+
+inline BOOL DXFGroupReader::GetStatus()
+{
+ return bStatus;
+}
+
+
+inline void DXFGroupReader::SetError()
+{
+ bStatus=FALSE;
+}
+
+inline USHORT DXFGroupReader::GetG()
+{
+ return nLastG;
+}
+
+inline long DXFGroupReader::GetI()
+{
+ return GetI(nLastG);
+}
+
+inline double DXFGroupReader::GetF()
+{
+ return GetF(nLastG);
+}
+
+inline const char * DXFGroupReader::GetS()
+{
+ return GetS(nLastG);
+}
+
+inline char DXFGroupReader::ReadChar()
+{
+ if (nIBuffPos>=nIBuffSize) FillIBuff();
+ return sIBuff[nIBuffPos++];
+}
+
+
+#endif
+
+
diff --git a/goodies/source/filter.vcl/idxf/dxfreprd.cxx b/goodies/source/filter.vcl/idxf/dxfreprd.cxx
new file mode 100644
index 000000000000..cc7823dee6b8
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/dxfreprd.cxx
@@ -0,0 +1,383 @@
+/*************************************************************************
+ *
+ * $RCSfile: dxfreprd.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <string.h>
+#include <dxfreprd.hxx>
+
+
+//------------------DXFBoundingBox--------------------------------------------
+
+
+void DXFBoundingBox::Union(const DXFVector & rVector)
+{
+ if (bEmpty==TRUE) {
+ fMinX=rVector.fx;
+ fMinY=rVector.fy;
+ fMinZ=rVector.fz;
+ fMaxX=rVector.fx;
+ fMaxY=rVector.fy;
+ fMaxZ=rVector.fz;
+ bEmpty=FALSE;
+ }
+ else {
+ if (fMinX>rVector.fx) fMinX=rVector.fx;
+ if (fMinY>rVector.fy) fMinY=rVector.fy;
+ if (fMinZ>rVector.fz) fMinZ=rVector.fz;
+ if (fMaxX<rVector.fx) fMaxX=rVector.fx;
+ if (fMaxY<rVector.fy) fMaxY=rVector.fy;
+ if (fMaxZ<rVector.fz) fMaxZ=rVector.fz;
+ }
+}
+
+
+//------------------DXFPalette------------------------------------------------
+
+
+DXFPalette::DXFPalette()
+{
+ short i,j,nHue,nNSat,nVal,nC[3],nmax,nmed,nmin;
+ BYTE nV;
+
+ pRed =new BYTE[256];
+ pGreen=new BYTE[256];
+ pBlue =new BYTE[256];
+
+ // Farben 0 - 9 (normale Farben)
+ SetColor(0, 0x00, 0x00, 0x00); // eigentlich nie benutzt
+ SetColor(1, 0xff, 0x00, 0x00);
+ SetColor(2, 0xff, 0xff, 0x00);
+ SetColor(3, 0x00, 0xff, 0x00);
+ SetColor(4, 0x00, 0xff, 0xff);
+ SetColor(5, 0x00, 0x00, 0xff);
+ SetColor(6, 0xff, 0x00, 0xff);
+ SetColor(7, 0x0f, 0x0f, 0x0f); // eigentlich weiss ???
+ SetColor(8, 0x80, 0x80, 0x80);
+ SetColor(9, 0xc0, 0xc0, 0xc0);
+
+ // Farben 10 - 249
+ // (Universal-Palette: 24 Farbtoene * 5 Helligkeiten * 2 Saettigungen )
+ i=10;
+ for (nHue=0; nHue<24; nHue++) {
+ for (nVal=5; nVal>=1; nVal--) {
+ for (nNSat=0; nNSat<2; nNSat++) {
+ nmax=((nHue+3)>>3)%3;
+ j=nHue-(nmax<<3); if (j>4) j=j-24;
+ if (j>=0) {
+ nmed=(nmax+1)%3;
+ nmin=(nmax+2)%3;
+ }
+ else {
+ nmed=(nmax+2)%3;
+ nmin=(nmax+1)%3;
+ j=-j;
+ }
+ nC[nmin]=0;
+ nC[nmed]=255*j/4;
+ nC[nmax]=255;
+ if (nNSat!=0) {
+ for (j=0; j<3; j++) nC[j]=(nC[j]>>1)+128;
+ }
+ for (j=0; j<3; j++) nC[j]=nC[j]*nVal/5;
+ SetColor((BYTE)(i++),(BYTE)nC[0],(BYTE)nC[1],(BYTE)nC[2]);
+ }
+ }
+ }
+
+ // Farben 250 - 255 (Grautoenne)
+ for (i=0; i<6; i++) {
+ nV=(BYTE)(i*38+65);
+ SetColor((BYTE)(250+i),nV,nV,nV);
+ }
+}
+
+
+DXFPalette::~DXFPalette()
+{
+ delete pBlue;
+ delete pGreen;
+ delete pRed;
+}
+
+
+void DXFPalette::SetColor(BYTE nIndex, BYTE nRed, BYTE nGreen, BYTE nBlue)
+{
+ pRed[nIndex]=nRed;
+ pGreen[nIndex]=nGreen;
+ pBlue[nIndex]=nBlue;
+}
+
+
+//------------------DXFRepresentation-----------------------------------------
+
+
+DXFRepresentation::DXFRepresentation()
+{
+}
+
+
+DXFRepresentation::~DXFRepresentation()
+{
+}
+
+
+BOOL DXFRepresentation::Read(SvStream & rIStream,
+ PFilterCallback pCallback, void * pCallerData,
+ USHORT nMinPercent, USHORT nMaxPercent)
+{
+ DXFGroupReader * pDGR;
+ BOOL bRes;
+
+ aTables.Clear();
+ aBlocks.Clear();
+ aEntities.Clear();
+
+ pDGR = new DXFGroupReader(rIStream,pCallback,pCallerData,nMinPercent,nMaxPercent);
+
+ pDGR->Read();
+ while (pDGR->GetG()!=0 || strcmp(pDGR->GetS(),"EOF")!=0) {
+ if (pDGR->GetG()==0 && strcmp(pDGR->GetS(),"SECTION")==0) {
+ if (pDGR->Read()!=2) {
+ pDGR->SetError();
+ break;
+ }
+ if (strcmp(pDGR->GetS(),"HEADER" )==0) ReadHeader(*pDGR);
+ else if (strcmp(pDGR->GetS(),"TABLES" )==0) aTables.Read(*pDGR);
+ else if (strcmp(pDGR->GetS(),"BLOCKS" )==0) aBlocks.Read(*pDGR);
+ else if (strcmp(pDGR->GetS(),"ENTITIES")==0) aEntities.Read(*pDGR);
+ else pDGR->Read();
+ }
+ else pDGR->Read();
+ }
+
+ bRes=pDGR->GetStatus();
+
+ delete pDGR;
+
+ if (bRes==TRUE && aBoundingBox.bEmpty==TRUE)
+ CalcBoundingBox(aEntities,aBoundingBox);
+
+ return bRes;
+}
+
+
+void DXFRepresentation::ReadHeader(DXFGroupReader & rDGR)
+{
+
+ while (rDGR.GetG()!=0 || (strcmp(rDGR.GetS(),"EOF")!=0 &&
+ strcmp(rDGR.GetS(),"ENDSEC")!=0) )
+ {
+ if (rDGR.GetG()==9) {
+ if (strcmp(rDGR.GetS(),"$EXTMIN")==0 ||
+ strcmp(rDGR.GetS(),"$EXTMAX")==0)
+ {
+ DXFVector aVector;
+ rDGR.SetF(10,0.0);
+ rDGR.SetF(20,0.0);
+ rDGR.SetF(30,0.0);
+ do {
+ rDGR.Read();
+ } while (rDGR.GetG()!=9 && rDGR.GetG()!=0);
+ aVector.fx=rDGR.GetF(10);
+ aVector.fy=rDGR.GetF(20);
+ aVector.fz=rDGR.GetF(30);
+ aBoundingBox.Union(aVector);
+ }
+ else rDGR.Read();
+ }
+ else rDGR.Read();
+ }
+}
+
+void DXFRepresentation::CalcBoundingBox(const DXFEntities & rEntities,
+ DXFBoundingBox & rBox)
+{
+ DXFBasicEntity * pBE=rEntities.pFirst;
+ while (pBE!=NULL) {
+ switch (pBE->eType) {
+ case DXF_LINE: {
+ const DXFLineEntity * pE = (DXFLineEntity*)pBE;
+ rBox.Union(pE->aP0);
+ rBox.Union(pE->aP1);
+ break;
+ }
+ case DXF_POINT: {
+ const DXFPointEntity * pE = (DXFPointEntity*)pBE;
+ rBox.Union(pE->aP0);
+ break;
+ }
+ case DXF_CIRCLE: {
+ const DXFCircleEntity * pE = (DXFCircleEntity*)pBE;
+ DXFVector aP;
+ aP=pE->aP0;
+ aP.fx-=pE->fRadius;
+ aP.fy-=pE->fRadius;
+ rBox.Union(aP);
+ aP=pE->aP0;
+ aP.fx+=pE->fRadius;
+ aP.fy+=pE->fRadius;
+ rBox.Union(aP);
+ break;
+ }
+ case DXF_ARC: {
+ const DXFArcEntity * pE = (DXFArcEntity*)pBE;
+ DXFVector aP;
+ aP=pE->aP0;
+ aP.fx-=pE->fRadius;
+ aP.fy-=pE->fRadius;
+ rBox.Union(aP);
+ aP=pE->aP0;
+ aP.fx+=pE->fRadius;
+ aP.fy+=pE->fRadius;
+ rBox.Union(aP);
+ break;
+ }
+ case DXF_TRACE: {
+ const DXFTraceEntity * pE = (DXFTraceEntity*)pBE;
+ rBox.Union(pE->aP0);
+ rBox.Union(pE->aP1);
+ rBox.Union(pE->aP2);
+ rBox.Union(pE->aP3);
+ break;
+ }
+ case DXF_SOLID: {
+ const DXFSolidEntity * pE = (DXFSolidEntity*)pBE;
+ rBox.Union(pE->aP0);
+ rBox.Union(pE->aP1);
+ rBox.Union(pE->aP2);
+ rBox.Union(pE->aP3);
+ break;
+ }
+ case DXF_TEXT: {
+ const DXFTextEntity * pE = (DXFTextEntity*)pBE;
+ //???
+ break;
+ }
+ case DXF_SHAPE: {
+ const DXFShapeEntity * pE = (DXFShapeEntity*)pBE;
+ //???
+ break;
+ }
+ case DXF_INSERT: {
+ const DXFInsertEntity * pE = (DXFInsertEntity*)pBE;
+ DXFBlock * pB;
+ DXFBoundingBox aBox;
+ DXFVector aP;
+ pB=aBlocks.Search(pE->sName);
+ if (pB==NULL) break;
+ CalcBoundingBox(*pB,aBox);
+ if (aBox.bEmpty==TRUE) break;
+ aP.fx=(aBox.fMinX-pB->aBasePoint.fx)*pE->fXScale+pE->aP0.fx;
+ aP.fy=(aBox.fMinY-pB->aBasePoint.fy)*pE->fYScale+pE->aP0.fy;
+ aP.fz=(aBox.fMinZ-pB->aBasePoint.fz)*pE->fZScale+pE->aP0.fz;
+ rBox.Union(aP);
+ aP.fx=(aBox.fMaxX-pB->aBasePoint.fx)*pE->fXScale+pE->aP0.fx;
+ aP.fy=(aBox.fMaxY-pB->aBasePoint.fy)*pE->fYScale+pE->aP0.fy;
+ aP.fz=(aBox.fMaxZ-pB->aBasePoint.fz)*pE->fZScale+pE->aP0.fz;
+ rBox.Union(aP);
+ break;
+ }
+ case DXF_ATTDEF: {
+ const DXFAttDefEntity * pE = (DXFAttDefEntity*)pBE;
+ //???
+ break;
+ }
+ case DXF_ATTRIB: {
+ const DXFAttribEntity * pE = (DXFAttribEntity*)pBE;
+ //???
+ break;
+ }
+ case DXF_VERTEX: {
+ const DXFVertexEntity * pE = (DXFVertexEntity*)pBE;
+ rBox.Union(pE->aP0);
+ break;
+ }
+ case DXF_3DFACE: {
+ const DXF3DFaceEntity * pE = (DXF3DFaceEntity*)pBE;
+ rBox.Union(pE->aP0);
+ rBox.Union(pE->aP1);
+ rBox.Union(pE->aP2);
+ rBox.Union(pE->aP3);
+ break;
+ }
+ case DXF_DIMENSION: {
+ const DXFDimensionEntity * pE = (DXFDimensionEntity*)pBE;
+ DXFBlock * pB;
+ DXFBoundingBox aBox;
+ DXFVector aP;
+ pB=aBlocks.Search(pE->sPseudoBlock);
+ if (pB==NULL) break;
+ CalcBoundingBox(*pB,aBox);
+ if (aBox.bEmpty==TRUE) break;
+ aP.fx=aBox.fMinX-pB->aBasePoint.fx;
+ aP.fy=aBox.fMinY-pB->aBasePoint.fy;
+ aP.fz=aBox.fMinZ-pB->aBasePoint.fz;
+ rBox.Union(aP);
+ aP.fx=aBox.fMaxX-pB->aBasePoint.fx;
+ aP.fy=aBox.fMaxY-pB->aBasePoint.fy;
+ aP.fz=aBox.fMaxZ-pB->aBasePoint.fz;
+ rBox.Union(aP);
+ break;
+ }
+ }
+ pBE=pBE->pSucc;
+ }
+}
+
diff --git a/goodies/source/filter.vcl/idxf/dxfreprd.hxx b/goodies/source/filter.vcl/idxf/dxfreprd.hxx
new file mode 100644
index 000000000000..09469198b482
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/dxfreprd.hxx
@@ -0,0 +1,166 @@
+/*************************************************************************
+ *
+ * $RCSfile: dxfreprd.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DXFREPRD_HXX
+#define _DXFREPRD_HXX
+
+#ifndef _DXFBLKRD_HXX
+#include <dxfblkrd.hxx>
+#endif
+
+#ifndef _DXFTBLRD_HXX
+#include <dxftblrd.hxx>
+#endif
+
+
+//----------------------------------------------------------------------------
+//--------------------Nebensachen---------------------------------------------
+//----------------------------------------------------------------------------
+
+//-------------------Eine 3D-Min/Max-Box--------------------------------------
+
+class DXFBoundingBox {
+public:
+ BOOL bEmpty;
+ double fMinX;
+ double fMinY;
+ double fMinZ;
+ double fMaxX;
+ double fMaxY;
+ double fMaxZ;
+
+ DXFBoundingBox() { bEmpty=TRUE; }
+ void Union(const DXFVector & rVector);
+};
+
+
+//-------------------Die (konstante) Palette fuer DXF-------------------------
+
+class DXFPalette {
+
+public:
+
+ DXFPalette();
+ ~DXFPalette();
+
+ BYTE GetRed(BYTE nIndex) const;
+ BYTE GetGreen(BYTE nIndex) const;
+ BYTE GetBlue(BYTE nIndex) const;
+
+private:
+ BYTE * pRed;
+ BYTE * pGreen;
+ BYTE * pBlue;
+ void SetColor(BYTE nIndex, BYTE nRed, BYTE nGreen, BYTE nBlue);
+};
+
+
+//----------------------------------------------------------------------------
+//-----------------DXF Datei lesen und repraesentieren------------------------
+//----------------------------------------------------------------------------
+
+class DXFRepresentation {
+
+public:
+
+ DXFPalette aPalette;
+ // Die immer gleiche DXF-Farb-Palette
+
+ DXFBoundingBox aBoundingBox;
+ // Ist gleich den AutoCAD-Variablen EXTMIN, EXTMAX sofern in DXF-Datei
+ // vorhanden, anderenfalls wird die BoundingBox berechnet (in Read()).
+
+ DXFTables aTables;
+ // Die Tabellen der DXF-Datei
+
+ DXFBlocks aBlocks;
+ // Die Bloecke der DXF-Datei
+
+ DXFEntities aEntities;
+ // Die Entities (aus der Entities-Section) der DXF-Datei
+
+ DXFRepresentation();
+ ~DXFRepresentation();
+
+ BOOL Read(SvStream & rIStream,
+ PFilterCallback pCallback, void * pCallerData,
+ USHORT nMinPercent, USHORT nMaxPercent);
+ // Liesst die komplette DXF-Datei ein.
+
+private:
+
+ void ReadHeader(DXFGroupReader & rDGR);
+ void CalcBoundingBox(const DXFEntities & rEntities,
+ DXFBoundingBox & rBox);
+};
+
+//----------------------------------------------------------------------------
+//-------------------inlines--------------------------------------------------
+//----------------------------------------------------------------------------
+
+inline BYTE DXFPalette::GetRed(BYTE nIndex) const { return pRed[nIndex]; }
+inline BYTE DXFPalette::GetGreen(BYTE nIndex) const { return pGreen[nIndex]; }
+inline BYTE DXFPalette::GetBlue(BYTE nIndex) const { return pBlue[nIndex]; }
+
+
+#endif
+
+
diff --git a/goodies/source/filter.vcl/idxf/dxftblrd.cxx b/goodies/source/filter.vcl/idxf/dxftblrd.cxx
new file mode 100644
index 000000000000..2d455aa213ce
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/dxftblrd.cxx
@@ -0,0 +1,387 @@
+/*************************************************************************
+ *
+ * $RCSfile: dxftblrd.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <string.h>
+#include <dxftblrd.hxx>
+
+//----------------------------------DXFLType-----------------------------------
+
+DXFLType::DXFLType()
+{
+ pSucc=NULL;
+ sName[0]=0;
+ nFlags=0;
+ sDescription[0]=0;
+ nDashCount=0;
+}
+
+void DXFLType::Read(DXFGroupReader & rDGR)
+{
+ long nDashIndex=-1;
+
+ while (rDGR.Read()!=0) {
+ switch (rDGR.GetG()) {
+ case 2: strcpy(sName,rDGR.GetS()); break;
+ case 70: nFlags=rDGR.GetI(); break;
+ case 3: strcpy(sDescription,rDGR.GetS()); break;
+ case 73:
+ if (nDashIndex!=-1) {
+ rDGR.SetError();
+ return;
+ }
+ nDashCount=rDGR.GetI();
+ if (nDashCount>DXF_MAX_DASH_COUNT)
+ nDashCount=DXF_MAX_DASH_COUNT;
+ nDashIndex=0;
+ break;
+ case 40: fPatternLength=rDGR.GetF(); break;
+ case 49:
+ if (nDashCount==-1) {
+ rDGR.SetError();
+ return;
+ }
+ if (nDashIndex<nDashCount)
+ fDash[nDashIndex++]=rDGR.GetF();
+ break;
+ }
+ }
+}
+
+//----------------------------------DXFLayer-----------------------------------
+
+DXFLayer::DXFLayer()
+{
+ pSucc=NULL;
+ sName[0]=0;
+ nFlags=0;
+ nColor=-1;
+ sLineType[0]=0;
+}
+
+void DXFLayer::Read(DXFGroupReader & rDGR)
+{
+ while (rDGR.Read()!=0) {
+ switch(rDGR.GetG()) {
+ case 2: strcpy(sName,rDGR.GetS()); break;
+ case 70: nFlags=rDGR.GetI(); break;
+ case 62: nColor=rDGR.GetI(); break;
+ case 6: strcpy(sLineType,rDGR.GetS()); break;
+ }
+ }
+}
+
+//----------------------------------DXFStyle-----------------------------------
+
+DXFStyle::DXFStyle()
+{
+ pSucc=NULL;
+ sName[0]=0;
+ nFlags=0;
+ fHeight=0.0;
+ fWidthFak=1.0;
+ fOblAngle=0.0;
+ nTextGenFlags=0;
+ fLastHeightUsed=0.0;
+ sPrimFontFile[0]=0;
+ sBigFontFile[0]=0;
+}
+
+void DXFStyle::Read(DXFGroupReader & rDGR)
+{
+ while (rDGR.Read()!=0) {
+ switch(rDGR.GetG()) {
+ case 2: strcpy(sName,rDGR.GetS()); break;
+ case 70: nFlags=rDGR.GetI(); break;
+ case 40: fHeight=rDGR.GetF(); break;
+ case 41: fWidthFak=rDGR.GetF(); break;
+ case 50: fOblAngle=rDGR.GetF(); break;
+ case 71: nTextGenFlags=rDGR.GetI(); break;
+ case 42: fLastHeightUsed=rDGR.GetF(); break;
+ case 3: strcpy(sPrimFontFile,rDGR.GetS()); break;
+ case 4: strcpy(sBigFontFile,rDGR.GetS()); break;
+ }
+ }
+}
+
+//----------------------------------DXFVPort-----------------------------------
+
+DXFVPort::DXFVPort()
+{
+ pSucc=NULL;
+
+ sName[0]=0;
+ nFlags=0;
+ fMinX=0;
+ fMinY=0;
+ fMaxX=0;
+ fMaxY=0;
+ fCenterX=0;
+ fCenterY=0;
+ fSnapBaseX=0;
+ fSnapBaseY=0;
+ fSnapSapcingX=0;
+ fSnapSpacingY=0;
+ fGridX=0;
+ fGridY=0;
+ aDirection=DXFVector(0,0,1);
+ aTarget=DXFVector(0,0,0);
+ fHeight=0;
+ fAspectRatio=0;
+ fLensLength=0;
+ fFrontClipPlane=0;
+ fBackClipPlane=0;
+ fTwistAngle=0;
+ nStatus=0;
+ nID=0;
+ nMode=0;
+ nCircleZoomPercent=0;
+ nFastZoom=0;
+ nUCSICON=0;
+ nSnap=0;
+ nGrid=0;
+ nSnapStyle=0;
+ nSnapIsopair=0;
+}
+
+void DXFVPort::Read(DXFGroupReader & rDGR)
+{
+ while (rDGR.Read()!=0) {
+ switch(rDGR.GetG()) {
+ case 2: strcpy(sName,rDGR.GetS()); break;
+ case 70: nFlags=rDGR.GetI(); break;
+ case 10: fMinX=rDGR.GetF(); break;
+ case 20: fMinY=rDGR.GetF(); break;
+ case 11: fMaxX=rDGR.GetF(); break;
+ case 21: fMaxY=rDGR.GetF(); break;
+ case 12: fCenterX=rDGR.GetF(); break;
+ case 22: fCenterY=rDGR.GetF(); break;
+ case 13: fSnapBaseX=rDGR.GetF(); break;
+ case 23: fSnapBaseY=rDGR.GetF(); break;
+ case 14: fSnapSapcingX=rDGR.GetF(); break;
+ case 24: fSnapSpacingY=rDGR.GetF(); break;
+ case 15: fGridX=rDGR.GetF(); break;
+ case 25: fGridY=rDGR.GetF(); break;
+ case 16: aDirection.fx=rDGR.GetF(); break;
+ case 26: aDirection.fy=rDGR.GetF(); break;
+ case 36: aDirection.fz=rDGR.GetF(); break;
+ case 17: aTarget.fx=rDGR.GetF(); break;
+ case 27: aTarget.fy=rDGR.GetF(); break;
+ case 37: aTarget.fz=rDGR.GetF(); break;
+ case 40: fHeight=rDGR.GetF(); break;
+ case 41: fAspectRatio=rDGR.GetF(); break;
+ case 42: fLensLength=rDGR.GetF(); break;
+ case 43: fFrontClipPlane=rDGR.GetF(); break;
+ case 44: fBackClipPlane=rDGR.GetF(); break;
+ case 51: fTwistAngle=rDGR.GetF(); break;
+ case 68: nStatus=rDGR.GetI(); break;
+ case 69: nID=rDGR.GetI(); break;
+ case 71: nMode=rDGR.GetI(); break;
+ case 72: nCircleZoomPercent=rDGR.GetI(); break;
+ case 73: nFastZoom=rDGR.GetI(); break;
+ case 74: nUCSICON=rDGR.GetI(); break;
+ case 75: nSnap=rDGR.GetI(); break;
+ case 76: nGrid=rDGR.GetI(); break;
+ case 77: nSnapStyle=rDGR.GetI(); break;
+ case 78: nSnapIsopair=rDGR.GetI(); break;
+ }
+ }
+}
+
+//----------------------------------DXFTables----------------------------------
+
+
+DXFTables::DXFTables()
+{
+ pLTypes=NULL;
+ pLayers=NULL;
+ pStyles=NULL;
+ pVPorts=NULL;
+}
+
+
+DXFTables::~DXFTables()
+{
+ Clear();
+}
+
+
+void DXFTables::Read(DXFGroupReader & rDGR)
+{
+ DXFLType * * ppLT, * pLT;
+ DXFLayer * * ppLa, * pLa;
+ DXFStyle * * ppSt, * pSt;
+ DXFVPort * * ppVP, * pVP;
+
+ ppLT=&pLTypes;
+ while(*ppLT!=NULL) ppLT=&((*ppLT)->pSucc);
+
+ ppLa=&pLayers;
+ while(*ppLa!=NULL) ppLa=&((*ppLa)->pSucc);
+
+ ppSt=&pStyles;
+ while(*ppSt!=NULL) ppSt=&((*ppSt)->pSucc);
+
+ ppVP=&pVPorts;
+ while(*ppVP!=NULL) ppVP=&((*ppVP)->pSucc);
+
+ for (;;) {
+ while (rDGR.GetG()!=0) rDGR.Read();
+ if (strcmp(rDGR.GetS(),"EOF")==0 ||
+ strcmp(rDGR.GetS(),"ENDSEC")==0) break;
+ else if (strcmp(rDGR.GetS(),"LTYPE")==0) {
+ pLT=new DXFLType;
+ pLT->Read(rDGR);
+ *ppLT=pLT;
+ ppLT=&(pLT->pSucc);
+ }
+ else if (strcmp(rDGR.GetS(),"LAYER")==0) {
+ pLa=new DXFLayer;
+ pLa->Read(rDGR);
+ *ppLa=pLa;
+ ppLa=&(pLa->pSucc);
+ }
+ else if (strcmp(rDGR.GetS(),"STYLE")==0) {
+ pSt=new DXFStyle;
+ pSt->Read(rDGR);
+ *ppSt=pSt;
+ ppSt=&(pSt->pSucc);
+ }
+ else if (strcmp(rDGR.GetS(),"VPORT")==0) {
+ pVP=new DXFVPort;
+ pVP->Read(rDGR);
+ *ppVP=pVP;
+ ppVP=&(pVP->pSucc);
+ }
+ else rDGR.Read();
+ }
+}
+
+
+void DXFTables::Clear()
+{
+ DXFLType * pLT;
+ DXFLayer * pLa;
+ DXFStyle * pSt;
+ DXFVPort * pVP;
+
+ while (pStyles!=NULL) {
+ pSt=pStyles;
+ pStyles=pSt->pSucc;
+ delete pSt;
+ }
+ while (pLayers!=NULL) {
+ pLa=pLayers;
+ pLayers=pLa->pSucc;
+ delete pLa;
+ }
+ while (pLTypes!=NULL) {
+ pLT=pLTypes;
+ pLTypes=pLT->pSucc;
+ delete pLT;
+ }
+ while (pVPorts!=NULL) {
+ pVP=pVPorts;
+ pVPorts=pVP->pSucc;
+ delete pVP;
+ }
+}
+
+
+DXFLType * DXFTables::SearchLType(const char * pName) const
+{
+ DXFLType * p;
+ for (p=pLTypes; p!=NULL; p=p->pSucc) {
+ if (strcmp(pName,p->sName)==0) break;
+ }
+ return p;
+}
+
+
+DXFLayer * DXFTables::SearchLayer(const char * pName) const
+{
+ DXFLayer * p;
+ for (p=pLayers; p!=NULL; p=p->pSucc) {
+ if (strcmp(pName,p->sName)==0) break;
+ }
+ return p;
+}
+
+
+DXFStyle * DXFTables::SearchStyle(const char * pName) const
+{
+ DXFStyle * p;
+ for (p=pStyles; p!=NULL; p=p->pSucc) {
+ if (strcmp(pName,p->sName)==0) break;
+ }
+ return p;
+}
+
+
+DXFVPort * DXFTables::SearchVPort(const char * pName) const
+{
+ DXFVPort * p;
+ for (p=pVPorts; p!=NULL; p=p->pSucc) {
+ if (strcmp(pName,p->sName)==0) break;
+ }
+ return p;
+}
+
+
diff --git a/goodies/source/filter.vcl/idxf/dxftblrd.hxx b/goodies/source/filter.vcl/idxf/dxftblrd.hxx
new file mode 100644
index 000000000000..1a6bcd14a623
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/dxftblrd.hxx
@@ -0,0 +1,223 @@
+/*************************************************************************
+ *
+ * $RCSfile: dxftblrd.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DXFTBLRD_HXX
+#define _DXFTBLRD_HXX
+
+#ifndef _DXFGRPRD_HXX
+#include <dxfgrprd.hxx>
+#endif
+
+#ifndef _DXFVEC_HXX
+#include <dxfvec.hxx>
+#endif
+
+
+//----------------------------------------------------------------------------
+//------------------ Linien-Typ ----------------------------------------------
+//----------------------------------------------------------------------------
+
+#define DXF_MAX_DASH_COUNT 32
+
+class DXFLType {
+
+public:
+
+ DXFLType * pSucc;
+
+ char sName[DXF_MAX_STRING_LEN+1]; // 2
+ long nFlags; // 70
+ char sDescription[DXF_MAX_STRING_LEN+1]; // 3
+ long nDashCount; // 73
+ double fPatternLength; // 40
+ double fDash[DXF_MAX_DASH_COUNT]; // 49,49,...
+
+ DXFLType();
+ void Read(DXFGroupReader & rDGR);
+};
+
+
+//----------------------------------------------------------------------------
+//------------------ Layer ---------------------------------------------------
+//----------------------------------------------------------------------------
+
+class DXFLayer {
+
+public:
+
+ DXFLayer * pSucc;
+
+ char sName[DXF_MAX_STRING_LEN+1]; // 2
+ long nFlags; // 70
+ long nColor; // 62
+ char sLineType[DXF_MAX_STRING_LEN+1]; // 6
+
+ DXFLayer();
+ void Read(DXFGroupReader & rDGR);
+};
+
+
+//----------------------------------------------------------------------------
+//------------------ Style ---------------------------------------------------
+//----------------------------------------------------------------------------
+
+class DXFStyle {
+
+public:
+
+ DXFStyle * pSucc;
+
+ char sName[DXF_MAX_STRING_LEN+1]; // 2
+ long nFlags; // 70
+ double fHeight; // 40
+ double fWidthFak; // 41
+ double fOblAngle; // 50
+ long nTextGenFlags; // 71
+ double fLastHeightUsed; // 42
+ char sPrimFontFile[DXF_MAX_STRING_LEN+1]; // 3
+ char sBigFontFile[DXF_MAX_STRING_LEN+1]; // 4
+
+ DXFStyle();
+ void Read(DXFGroupReader & rDGR);
+};
+
+
+//----------------------------------------------------------------------------
+//------------------ VPort ---------------------------------------------------
+//----------------------------------------------------------------------------
+
+class DXFVPort {
+
+public:
+
+ DXFVPort * pSucc;
+
+ char sName[DXF_MAX_STRING_LEN+1]; // 2
+ long nFlags; // 70
+ double fMinX; // 10
+ double fMinY; // 20
+ double fMaxX; // 11
+ double fMaxY; // 21
+ double fCenterX; // 12
+ double fCenterY; // 22
+ double fSnapBaseX; // 13
+ double fSnapBaseY; // 23
+ double fSnapSapcingX; // 14
+ double fSnapSpacingY; // 24
+ double fGridX; // 15
+ double fGridY; // 25
+ DXFVector aDirection; // 16,26,36
+ DXFVector aTarget; // 17,27,37
+ double fHeight; // 40
+ double fAspectRatio; // 41
+ double fLensLength; // 42
+ double fFrontClipPlane; // 43
+ double fBackClipPlane; // 44
+ double fTwistAngle; // 51
+ long nStatus; // 68
+ long nID; // 69
+ long nMode; // 71
+ long nCircleZoomPercent; // 72
+ long nFastZoom; // 73
+ long nUCSICON; // 74
+ long nSnap; // 75
+ long nGrid; // 76
+ long nSnapStyle; // 77
+ long nSnapIsopair; // 78
+
+ DXFVPort();
+ void Read(DXFGroupReader & rDGR);
+};
+
+
+//----------------------------------------------------------------------------
+//------------------ Tabellen ------------------------------------------------
+//----------------------------------------------------------------------------
+
+class DXFTables {
+
+public:
+
+ DXFLType * pLTypes; // Liste der Linientypen
+ DXFLayer * pLayers; // Liste der Layers
+ DXFStyle * pStyles; // Liste der Styles
+ DXFVPort * pVPorts; // Liste der Viewports
+
+ DXFTables();
+ ~DXFTables();
+
+ void Read(DXFGroupReader & rDGR);
+ // Liest die Tabellen ein bis zu einem ENDSEC oder EOF
+ // (unbekannte Dinge/Tabellen werden uebersprungen)
+
+ void Clear();
+
+ // Suche nach Tabelleneintraegen:
+ DXFLType * SearchLType(const char * pName) const;
+ DXFLayer * SearchLayer(const char * pName) const;
+ DXFStyle * SearchStyle(const char * pName) const;
+ DXFVPort * SearchVPort(const char * pName) const;
+
+};
+
+#endif
+
+
diff --git a/goodies/source/filter.vcl/idxf/dxfvec.cxx b/goodies/source/filter.vcl/idxf/dxfvec.cxx
new file mode 100644
index 000000000000..7972c37b83ed
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/dxfvec.cxx
@@ -0,0 +1,258 @@
+/*************************************************************************
+ *
+ * $RCSfile: dxfvec.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <math.h>
+#include <dxfvec.hxx>
+
+
+//---------------------------- DXFVector ---------------------------------------
+
+
+double DXFVector::Abs() const
+{
+ return sqrt(SProd(*this));
+}
+
+
+DXFVector DXFVector::Unit() const
+{
+ double flen;
+
+ flen=Abs();
+ if (flen!=0) return (*this)*(1.0/flen);
+ else return DXFVector(1.0,0.0,0.0);
+}
+
+
+//---------------------------- DXFTransform ------------------------------------
+
+
+DXFTransform::DXFTransform() :
+ aMX(1.0, 0.0, 0.0),
+ aMY(0.0, 1.0, 0.0),
+ aMZ(0.0, 0.0, 1.0),
+ aMP(0.0, 0.0, 0.0)
+{
+}
+
+
+DXFTransform::DXFTransform(double fScaleX, double fScaleY, double fScaleZ,
+ const DXFVector & rShift) :
+ aMX(fScaleX, 0.0, 0.0),
+ aMY(0.0, fScaleY, 0.0),
+ aMZ(0.0, 0.0, fScaleZ),
+ aMP(rShift)
+{
+}
+
+
+DXFTransform::DXFTransform(double fScaleX, double fScaleY, double fScaleZ,
+ double fRotAngle,
+ const DXFVector & rShift) :
+ aMX(0.0, 0.0, 0.0),
+ aMY(0.0, 0.0, 0.0),
+ aMZ(0.0, 0.0, fScaleZ),
+ aMP(rShift)
+{
+ aMX.fx=cos(3.14159265359/180.0*fRotAngle);
+ aMX.fy=sin(3.14159265359/180.0*fRotAngle);
+ aMY.fx=-aMX.fy;
+ aMY.fy=aMX.fx;
+ aMX*=fScaleX;
+ aMY*=fScaleY;
+}
+
+
+DXFTransform::DXFTransform(const DXFVector & rExtrusion) :
+ aMX(), aMY(), aMZ(), aMP(0.0, 0.0, 0.0)
+{
+ // 'Arbitrary Axis Algorithm' (siehe DXF-Doku von Autodesk)
+ if ( fabs(rExtrusion.fx) < 1.0/64.0 && fabs(rExtrusion.fy) < 1.0/64.0) {
+ aMX = DXFVector(0.0, 1.0, 0.0) * rExtrusion;
+ }
+ else {
+ aMX = DXFVector(0.0, 0.0, 1.0) * rExtrusion;
+ }
+ aMX=aMX.Unit();
+ aMY=(rExtrusion*aMX).Unit();
+ aMZ=rExtrusion.Unit();
+}
+
+
+DXFTransform::DXFTransform(const DXFVector & rViewDir, const DXFVector & rViewTarget) :
+ aMX(), aMY(), aMZ(), aMP()
+{
+ DXFVector aV;
+
+ aV=rViewDir.Unit();
+ aMX.fz=aV.fx;
+ aMY.fz=aV.fy;
+ aMZ.fz=aV.fz;
+
+ aMZ.fx=0;
+ if (aV.fx==0) aMY.fx=0; else aMY.fx=sqrt(1/(1+aV.fy*aV.fy/(aV.fx*aV.fx)));
+ aMX.fx=sqrt(1-aMY.fx*aMY.fx);
+ if (aV.fx*aV.fy*aMY.fx>0) aMX.fx=-aMX.fx;
+
+ aV=aV*DXFVector(aMX.fx,aMY.fx,aMZ.fx);
+ aMX.fy=aV.fx;
+ aMY.fy=aV.fy;
+ aMZ.fy=aV.fz;
+
+ if (aMZ.fy<0) {
+ aMX.fy=-aMX.fy;
+ aMY.fy=-aMY.fy;
+ aMZ.fy=-aMZ.fy;
+ aMX.fx=-aMX.fx;
+ aMY.fx=-aMY.fx;
+ }
+
+ aV=DXFVector(0,0,0)-rViewTarget;
+ aMP.fx = aV.fx * aMX.fx + aV.fy * aMY.fx + aV.fz * aMZ.fx;
+ aMP.fy = aV.fx * aMX.fy + aV.fy * aMY.fy + aV.fz * aMZ.fy;
+ aMP.fz = aV.fx * aMX.fz + aV.fy * aMY.fz + aV.fz * aMZ.fz;
+}
+
+
+DXFTransform::DXFTransform(const DXFTransform & rT1, const DXFTransform & rT2) :
+ aMX(),aMY(),aMZ(),aMP()
+{
+ rT2.TransDir(rT1.aMX,aMX);
+ rT2.TransDir(rT1.aMY,aMY);
+ rT2.TransDir(rT1.aMZ,aMZ);
+ rT2.Transform(rT1.aMP,aMP);
+}
+
+
+void DXFTransform::Transform(const DXFVector & rSrc, DXFVector & rTgt) const
+{
+ rTgt.fx = rSrc.fx * aMX.fx + rSrc.fy * aMY.fx + rSrc.fz * aMZ.fx + aMP.fx;
+ rTgt.fy = rSrc.fx * aMX.fy + rSrc.fy * aMY.fy + rSrc.fz * aMZ.fy + aMP.fy;
+ rTgt.fz = rSrc.fx * aMX.fz + rSrc.fy * aMY.fz + rSrc.fz * aMZ.fz + aMP.fz;
+}
+
+
+void DXFTransform::Transform(const DXFVector & rSrc, Point & rTgt) const
+{
+ rTgt.X()=(long)( rSrc.fx * aMX.fx + rSrc.fy * aMY.fx + rSrc.fz * aMZ.fx + aMP.fx + 0.5 );
+ rTgt.Y()=(long)( rSrc.fx * aMX.fy + rSrc.fy * aMY.fy + rSrc.fz * aMZ.fy + aMP.fy + 0.5 );
+}
+
+
+void DXFTransform::TransDir(const DXFVector & rSrc, DXFVector & rTgt) const
+{
+ rTgt.fx = rSrc.fx * aMX.fx + rSrc.fy * aMY.fx + rSrc.fz * aMZ.fx;
+ rTgt.fy = rSrc.fx * aMX.fy + rSrc.fy * aMY.fy + rSrc.fz * aMZ.fy;
+ rTgt.fz = rSrc.fx * aMX.fz + rSrc.fy * aMY.fz + rSrc.fz * aMZ.fz;
+}
+
+
+BOOL DXFTransform::TransCircleToEllipse(double fRadius, double & rEx, double & rEy) const
+{
+ double fMXAbs=aMX.Abs();
+ double fMYAbs=aMY.Abs();
+ double fNearNull=(fMXAbs+fMYAbs)*0.001;
+
+ if (fabs(aMX.fy)<=fNearNull && fabs(aMX.fz)<=fNearNull &&
+ fabs(aMY.fx)<=fNearNull && fabs(aMY.fz)<=fNearNull)
+ {
+ rEx=fabs(aMX.fx*fRadius);
+ rEy=fabs(aMY.fy*fRadius);
+ return TRUE;
+ }
+ else if (fabs(aMX.fx)<=fNearNull && fabs(aMX.fz)<=fNearNull &&
+ fabs(aMY.fy)<=fNearNull && fabs(aMY.fz)<=fNearNull)
+ {
+ rEx=fabs(aMY.fx*fRadius);
+ rEy=fabs(aMX.fy*fRadius);
+ return TRUE;
+ }
+ else if (fabs(fMXAbs-fMYAbs)<=fNearNull &&
+ fabs(aMX.fz)<=fNearNull && fabs(aMY.fz)<=fNearNull)
+ {
+ rEx=rEy=fabs(((fMXAbs+fMYAbs)/2)*fRadius);
+ return TRUE;
+ }
+ else return FALSE;
+}
+
+
+ULONG DXFTransform::TransLineWidth(double fW) const
+{
+ double fex,fey;
+
+ fex=sqrt(aMX.fx*aMX.fx + aMX.fy*aMX.fy);
+ fey=sqrt(aMY.fx*aMY.fx + aMY.fy*aMY.fy);
+ return (ULONG)(fabs(fW)*(fex+fey)/2.0+0.5);
+}
+
+
+double DXFTransform::CalcRotAngle() const
+{
+ return atan2(aMX.fy,aMX.fx)/3.14159265359*180.0;
+}
+
+BOOL DXFTransform::Mirror() const
+{
+ if (aMZ.SProd(aMX*aMY)<0) return TRUE; else return FALSE;
+}
+
+
diff --git a/goodies/source/filter.vcl/idxf/dxfvec.hxx b/goodies/source/filter.vcl/idxf/dxfvec.hxx
new file mode 100644
index 000000000000..cb4877aceb76
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/dxfvec.hxx
@@ -0,0 +1,261 @@
+/*************************************************************************
+ *
+ * $RCSfile: dxfvec.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DXFVEC_HXX
+#define _DXFVEC_HXX
+
+#include <tools/gen.hxx>
+
+
+//------------------------------------------------------------------------------
+//---------------------------- DXFVector ---------------------------------------
+//------------------------------------------------------------------------------
+// Allgemeiner 3D-Vektor mit double
+
+class DXFVector {
+
+public:
+
+ double fx,fy,fz; // public ! - Warum nicht ?
+
+ inline DXFVector(double fX=0.0, double fY=0.0, double fZ=0.0);
+ inline DXFVector(const DXFVector & rV);
+
+ // Addition/Subtraktion:
+ DXFVector & operator += (const DXFVector & rV);
+ DXFVector operator + (const DXFVector & rV) const;
+ DXFVector & operator -= (const DXFVector & rV);
+ DXFVector operator - (const DXFVector & rV) const;
+
+ // Vektorprodukt
+ DXFVector operator * (const DXFVector & rV) const;
+
+ // Skalarprodukt:
+ double SProd(const DXFVector & rV) const;
+
+ // Multiplikation mit Skalar:
+ DXFVector & operator *= (double fs);
+ DXFVector operator * (double fs) const;
+
+ // Laenge:
+ double Abs() const;
+
+ // Vektor gleicher Richtung und der Laenge 1:
+ DXFVector Unit() const;
+
+ // Aequivalenz oder nicht:
+ BOOL operator == (const DXFVector & rV) const;
+ BOOL operator != (const DXFVector & rV) const;
+};
+
+//------------------------------------------------------------------------------
+//---------------------------- DXFTransform ------------------------------------
+//------------------------------------------------------------------------------
+// Eine Transformationsmatrix, spezialisiert auf unser Problem
+
+class DXFTransform {
+
+public:
+
+ DXFTransform();
+ // Zielkoordinate = Quellkoordinate
+
+ DXFTransform(double fScaleX, double fScaleY, double fScaleZ,
+ const DXFVector & rShift);
+ // Zielkoordinate = Verschoben(Skaliert(Quellkoorinate))
+
+ DXFTransform(double fScaleX, double fScaleY, double fScaleZ,
+ double fRotAngle,
+ const DXFVector & rShift);
+ // Zielkoordinate = Verschoben(Gedreht(Skaliert(Quellkoorinate)))
+ // Drehung geshieht um die Z-Achse, fRotAngle in Grad.
+
+ DXFTransform(const DXFVector & rExtrusion);
+ // Transformation "ECS->WCS" per "Entity Extrusion Direction"
+ // und dem "Arbitrary Axis Algorithm"
+ // (Siehe DXF-Docu von AutoDesk)
+
+ DXFTransform(const DXFVector & rViewDir, const DXFVector & rViewTarget);
+ // Transformation Objektraum->Bildraum anhand von Richtung und
+ // Zielpunkt eines ViewPort.
+ // (siehe DXF-Docu von AutoDesk: VPORT)
+
+ DXFTransform(const DXFTransform & rT1, const DXFTransform & rT2);
+ // Zielkoordinate = rT2(rT1(Quellkoorinate))
+
+
+ void Transform(const DXFVector & rSrc, DXFVector & rTgt) const;
+ // Transformation DXFVector nach DXFVector
+
+ void Transform(const DXFVector & rSrc, Point & rTgt) const;
+ // Transformation DXFVector nach SvPoint
+
+ void TransDir(const DXFVector & rSrc, DXFVector & rTgt) const;
+ // Transformation eines relativen Vektors (also kein Verschiebung)
+
+ BOOL TransCircleToEllipse(double fRadius, double & rEx, double & rEy) const;
+ // Versucht, einen Kreis (in der XY-Ebene) zu transformieren, so dass eine
+ // ausgerichtete Ellipse entsteht. Wenn das nicht geht, weil Ellipse
+ // in belibieger Lage entstehen wuerde, wird FALSE geliefert.
+ // (Der Mittelpunkt wird hiermit nicht transformiert, nehme Transform(..))
+
+ ULONG TransLineWidth(double fW) const;
+ // Transformiert die Liniendicke (so gut es geht)
+
+ double CalcRotAngle() const;
+ // Ermittelt den Rotationswinkel um die Z-Achse (in Grad)
+
+ BOOL Mirror() const;
+ // Liefert TRUE, wenn die Matrix ein Linkssystem bildet
+
+private:
+ DXFVector aMX;
+ DXFVector aMY;
+ DXFVector aMZ;
+ DXFVector aMP;
+};
+
+//------------------------------------------------------------------------------
+//------------------------------- inlines --------------------------------------
+//------------------------------------------------------------------------------
+
+
+inline DXFVector::DXFVector(double fX, double fY, double fZ)
+{
+ fx=fX; fy=fY; fz=fZ;
+}
+
+
+inline DXFVector::DXFVector(const DXFVector & rV)
+{
+ fx=rV.fx; fy=rV.fy; fz=rV.fz;
+}
+
+
+inline DXFVector & DXFVector::operator += (const DXFVector & rV)
+{
+ fx+=rV.fx; fy+=rV.fy; fz+=rV.fz;
+ return *this;
+}
+
+
+inline DXFVector DXFVector::operator + (const DXFVector & rV) const
+{
+ return DXFVector(fx+rV.fx, fy+rV.fy, fz+rV.fz);
+}
+
+
+inline DXFVector & DXFVector::operator -= (const DXFVector & rV)
+{
+ fx-=rV.fx; fy-=rV.fy; fz-=rV.fz;
+ return *this;
+}
+
+
+inline DXFVector DXFVector::operator - (const DXFVector & rV) const
+{
+ return DXFVector(fx-rV.fx, fy-rV.fy, fz-rV.fz);
+}
+
+
+inline DXFVector DXFVector::operator * (const DXFVector & rV) const
+{
+ return DXFVector(
+ fy * rV.fz - fz * rV.fy,
+ fz * rV.fx - fx * rV.fz,
+ fx * rV.fy - fy * rV.fx
+ );
+}
+
+
+inline double DXFVector::SProd(const DXFVector & rV) const
+{
+ return fx*rV.fx + fy*rV.fy + fz*rV.fz;
+}
+
+
+inline DXFVector & DXFVector::operator *= (double fs)
+{
+ fx*=fs; fy*=fs; fz*=fs;
+ return *this;
+}
+
+
+inline DXFVector DXFVector::operator * (double fs) const
+{
+ return DXFVector(fx*fs,fy*fs,fz*fs);
+}
+
+
+inline BOOL DXFVector::operator == (const DXFVector & rV) const
+{
+ if (fx==rV.fx && fy==rV.fy && fz==rV.fz) return TRUE;
+ else return FALSE;
+}
+
+
+inline BOOL DXFVector::operator != (const DXFVector & rV) const
+{
+ if (fx!=rV.fx || fy!=rV.fy || fz!=rV.fz) return TRUE;
+ else return FALSE;
+}
+
+#endif
diff --git a/goodies/source/filter.vcl/idxf/idxf.cxx b/goodies/source/filter.vcl/idxf/idxf.cxx
new file mode 100644
index 000000000000..f630833b9304
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/idxf.cxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * $RCSfile: idxf.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <math.h>
+#include <string.h>
+#include <vcl/gdimtf.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/virdev.hxx>
+#include "dxf2mtf.hxx"
+
+//================== GraphicImport - die exportierte Funktion ================
+
+#ifdef WNT
+extern "C" BOOL _cdecl GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#else
+extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#endif
+{
+ DXFRepresentation aDXF;
+ DXF2GDIMetaFile aConverter;
+ GDIMetaFile aMTF;
+
+ if (aDXF.Read(rStream,pCallback,pCallerData,0,60)==FALSE) return FALSE;
+ if (aConverter.Convert(aDXF,aMTF,pCallback,pCallerData,60,100)==FALSE) return FALSE;
+ rGraphic=Graphic(aMTF);
+
+ return TRUE;
+}
+
+//============================= fuer Windows ==================================
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
+
+
diff --git a/goodies/source/filter.vcl/idxf/makefile.mk b/goodies/source/filter.vcl/idxf/makefile.mk
new file mode 100644
index 000000000000..b21d466ae1b0
--- /dev/null
+++ b/goodies/source/filter.vcl/idxf/makefile.mk
@@ -0,0 +1,176 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=idxf
+DEPTARGET=vidxf
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SLOFILES = $(SLO)$/dxfgrprd.obj \
+ $(SLO)$/dxfvec.obj \
+ $(SLO)$/dxfentrd.obj \
+ $(SLO)$/dxfblkrd.obj \
+ $(SLO)$/dxftblrd.obj \
+ $(SLO)$/dxfreprd.obj \
+ $(SLO)$/dxf2mtf.obj \
+ $(SLO)$/idxf.obj
+
+# ==========================================================================
+
+SHL1TARGET= idx$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= idxf
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(CPPULIB)
+
+SHL1DEPN= $(LB)$/idxf.lib
+SHL1LIBS= $(SLB)$/idxf.lib # $(LB)$/rtftoken.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/idxf.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicImport >>$@
+.ELSE
+ @echo _GraphicImport >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET) >>$@
+ @echo GraphicImport_ >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicImport >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/ieps/ieps.cxx b/goodies/source/filter.vcl/ieps/ieps.cxx
new file mode 100644
index 000000000000..898ba5e710c8
--- /dev/null
+++ b/goodies/source/filter.vcl/ieps/ieps.cxx
@@ -0,0 +1,527 @@
+/*************************************************************************
+ *
+ * $RCSfile: ieps.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+
+//
+#include <vcl/sv.h>
+#include <vcl/svapp.hxx>
+#include <vcl/bitmap.hxx>
+#include <vcl/bitmapex.hxx>
+#include <vcl/animate.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/graph.h>
+#include <vcl/window.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/metaact.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <vcl/bmpacc.hxx>
+#include <svtools/fltcall.hxx>
+#include <tools/urlobj.hxx>
+
+// we will parse only 4kb for graphic information
+#define PS_BUF_SIZE 0x1000
+
+/*************************************************************************
+|*
+|* ImpSearchEntry()
+|*
+|* Beschreibung Prueft ob im Speicherbereich pSource der nComp Bytes
+|* gross ist eine Zeichenkette(pDest) mit der länge nSize
+|* liegt. Geprueft wird NON-CASE-SENSITIVE und der Rueck-
+|* gabewert ist die Adresse an der die Zeichekette gefunden
+|* wurde oder NULL
+|*
+|* Ersterstellung SJ 04.03.98 ( und das an meinem Geburtstag )
+|* Letzte Aenderung SJ 04.03.98
+|*
+*************************************************************************/
+
+static BYTE* ImplSearchEntry( BYTE* pSource, BYTE* pDest, ULONG nComp, ULONG nSize )
+{
+ while ( nComp-- >= nSize )
+ {
+ ULONG i;
+ for ( i = 0; i < nSize; i++ )
+ {
+ if ( ( pSource[i]&~0x20 ) != ( pDest[i]&~0x20 ) )
+ break;
+ }
+ if ( i == nSize )
+ return pSource;
+ pSource++;
+ }
+ return NULL;
+}
+
+//--------------------------------------------------------------------------
+// SecurityCount is the buffersize of the buffer in which we will parse for a number
+static long ImplGetNumber( BYTE **pBuf, int& nSecurityCount )
+{
+ BOOL bValid = TRUE;
+ BOOL bNegative = FALSE;
+ long nRetValue = 0;
+ while ( ( --nSecurityCount ) && ( **pBuf == ' ' ) || ( **pBuf == 0x9 ) ) (*pBuf)++;
+ BYTE nByte = **pBuf;
+ while ( nSecurityCount && ( nByte != ' ' ) && ( nByte != 0x9 ) && ( nByte != 0xd ) && ( nByte != 0xa ) )
+ {
+ switch ( nByte )
+ {
+ case '.' :
+ // we'll only use the integer format
+ bValid = FALSE;
+ break;
+ case '-' :
+ bNegative = TRUE;
+ break;
+ default :
+ if ( ( nByte < '0' ) || ( nByte > '9' ) )
+ nSecurityCount = 1; // error parsing the bounding box values
+ else if ( bValid )
+ {
+ nRetValue *= 10;
+ nRetValue += nByte - '0';
+ }
+ break;
+ }
+ nSecurityCount--;
+ nByte = *(++(*pBuf));
+ }
+ if ( bNegative )
+ nRetValue = -nRetValue;
+ return nRetValue;
+}
+
+//--------------------------------------------------------------------------
+
+static int ImplGetLen( BYTE* pBuf, int nMax )
+{
+ int nLen = 0;
+ while( nLen != nMax )
+ {
+ BYTE nDat = *pBuf++;
+ if ( nDat == 0x0a || nDat == 0x25 )
+ break;
+ nLen++;
+ }
+ return nLen;
+}
+
+//================== GraphicImport - die exportierte Funktion ================
+
+#ifdef WNT
+extern "C" BOOL _cdecl GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#else
+extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#endif
+{
+ if ( rStream.GetError() )
+ return FALSE;
+
+ Graphic aGraphic;
+ BOOL bRetValue = FALSE;
+ BOOL bHasPreview = FALSE;
+ UINT32 nSignature, nPSStreamPos, nPSSize, nSize, nPos;
+ UINT32 nOrigPos = nPSStreamPos = rStream.Tell();
+ USHORT nOldFormat = rStream.GetNumberFormatInt();
+ rStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ rStream >> nSignature;
+ if ( nSignature == 0xc6d3d0c5 )
+ {
+ rStream >> nPSStreamPos >> nPSSize >> nPos >> nSize;
+
+ // first we try to get the metafile grafix
+
+ if ( nSize )
+ {
+ if ( nPos != 0 )
+ {
+ rStream.Seek( nOrigPos + nPos );
+ if ( GraphicConverter::Import( rStream, aGraphic, CVT_WMF ) == ERRCODE_NONE )
+ bHasPreview = bRetValue = TRUE;
+ }
+ }
+ else
+ {
+ rStream >> nPos >> nSize;
+
+ // else we have to get the tiff grafix
+
+ if ( ( nPos != 0 ) && ( nSize != 0 ) )
+ {
+ rStream.Seek( nOrigPos + nPos );
+ if ( GraphicConverter::Import( rStream, aGraphic, CVT_TIF ) == ERRCODE_NONE )
+ {
+ VirtualDevice aVDev;
+ GDIMetaFile aMtf;
+ Bitmap aBmp( aGraphic.GetBitmap() );
+ Size aSize = aBmp.GetPrefSize();
+
+ if( !aSize.Width() || !aSize.Height() )
+ aSize = Application::GetDefaultDevice()->PixelToLogic( aBmp.GetSizePixel(), MAP_100TH_MM );
+ else
+ aSize = Application::GetDefaultDevice()->LogicToLogic( aSize, aBmp.GetPrefMapMode(), MAP_100TH_MM );
+
+ aVDev.EnableOutput( FALSE );
+ aMtf.Record( &aVDev );
+ aVDev.DrawBitmap( Point(), aSize, aGraphic.GetBitmap() );
+ aMtf.Stop();
+ aMtf.WindStart();
+ aMtf.SetPrefMapMode( MAP_100TH_MM );
+ aMtf.SetPrefSize( aSize );
+ aGraphic = aMtf;
+ rStream.Seek( nOrigPos + nPos );
+ bHasPreview = bRetValue = TRUE;
+ }
+ }
+ }
+ }
+ else
+ {
+ nPSStreamPos = nOrigPos; // no preview available _>so we must get the size manually
+ nPSSize = rStream.Seek( STREAM_SEEK_TO_END ) - nOrigPos;
+ }
+ rStream.Seek( nPSStreamPos );
+ BYTE* pBuf = new BYTE[ PS_BUF_SIZE ];
+ if ( pBuf )
+ {
+ rStream.Read( pBuf, 22 ); // check PostScript header
+ if ( ImplSearchEntry( pBuf, (BYTE*)"%!PS-Adobe", 10, 10 ) &&
+ ImplSearchEntry( &pBuf[15], (BYTE*)"EPS", 3, 3 ) )
+ {
+ ULONG nBufStartPos = rStream.Tell();
+ ULONG nBytesRead = rStream.Read( pBuf, PS_BUF_SIZE );
+ if ( nBytesRead > 64 ) // assuming a eps file is greater than 64 bytes
+ {
+ int nSecurityCount = 32;
+ if ( !bHasPreview ) // if there is no tiff/wmf preview, we will parse for an preview in the eps prolog
+ {
+ BYTE* pDest = ImplSearchEntry( pBuf, (BYTE*)"%%BeginPreview:", nBytesRead - 32, 15 );
+ if ( pDest )
+ {
+ pDest += 15;
+ long nWidth = ImplGetNumber( &pDest, nSecurityCount );
+ long nHeight = ImplGetNumber( &pDest, nSecurityCount );
+ long nBitDepth = ImplGetNumber( &pDest, nSecurityCount );
+ long nScanLines = ImplGetNumber( &pDest, nSecurityCount );
+ pDest = ImplSearchEntry( pDest, (BYTE*)"%", 16, 1 ); // go to the first Scanline
+ if ( nSecurityCount && pDest && nWidth && nHeight && ( ( nBitDepth == 1 ) || ( nBitDepth == 8 ) ) && nScanLines )
+ {
+ rStream.Seek( nBufStartPos + ( pDest - pBuf ) );
+
+ Bitmap aBitmap( Size( nWidth, nHeight ), 1 );
+ BitmapWriteAccess* pAcc = aBitmap.AcquireWriteAccess();
+ if ( pAcc )
+ {
+ int nBitsLeft;
+ BOOL bIsValid = TRUE;
+ BYTE nDat;
+ char nByte;
+ for ( long y = 0; bIsValid && ( y < nHeight ); y++ )
+ {
+ nBitsLeft = 0;
+ for ( long x = 0; x < nWidth; x++ )
+ {
+ if ( --nBitsLeft < 0 )
+ {
+ while ( bIsValid && ( nBitsLeft != 7 ) )
+ {
+ rStream >> nByte;
+ switch ( nByte )
+ {
+ case 0x0a :
+ if ( --nScanLines < 0 )
+ bIsValid = FALSE;
+ case 0x09 :
+ case 0x0d :
+ case 0x20 :
+ case 0x25 :
+ break;
+ default:
+ {
+ if ( nByte >= '0' )
+ {
+ if ( nByte > '9' )
+ {
+ nByte &=~0x20; // case none sensitive for hexadezimal values
+ nByte -= ( 'A' - 10 );
+ if ( nByte > 15 )
+ bIsValid = FALSE;
+ }
+ else
+ nByte -= '0';
+ nBitsLeft += 4;
+ nDat <<= 4;
+ nDat |= ( nByte ^ 0xf ); // in epsi a zero bit represents white color
+ }
+ else
+ bIsValid = FALSE;
+ }
+ break;
+ }
+ }
+ }
+ if ( nBitDepth == 1 )
+ pAcc->SetPixel( y, x, ( nDat >> nBitsLeft ) & 1 );
+ else
+ {
+ pAcc->SetPixel( y, x, ( nDat ) ? 1 : 0 ); // nBitDepth == 8
+ nBitsLeft = 0;
+ }
+ }
+ }
+ if ( bIsValid )
+ {
+ VirtualDevice aVDev;
+ GDIMetaFile aMtf;
+ Size aSize;
+ aVDev.EnableOutput( FALSE );
+ aMtf.Record( &aVDev );
+ aSize = aBitmap.GetPrefSize();
+ if( !aSize.Width() || !aSize.Height() )
+ aSize = Application::GetDefaultDevice()->PixelToLogic( aBitmap.GetSizePixel(), MAP_100TH_MM );
+ else
+ aSize = Application::GetDefaultDevice()->LogicToLogic( aSize, aBitmap.GetPrefMapMode(), MAP_100TH_MM );
+ aVDev.DrawBitmap( Point(), aSize, aBitmap );
+ aMtf.Stop();
+ aMtf.WindStart();
+ aMtf.SetPrefMapMode( MAP_100TH_MM );
+ aMtf.SetPrefSize( aSize );
+ aGraphic = aMtf;
+ bHasPreview = bRetValue = TRUE;
+ }
+ aBitmap.ReleaseAccess( pAcc );
+ }
+ }
+ }
+ }
+
+ BYTE* pDest = ImplSearchEntry( pBuf, (BYTE*)"%%BoundingBox:", nBytesRead, 14 );
+ if ( pDest )
+ {
+ nSecurityCount = 100;
+ long nNumb[4];
+ nNumb[0] = nNumb[1] = nNumb[2] = nNumb[3] = 0;
+ pDest += 14;
+ for ( int i = 0; ( i < 4 ) && nSecurityCount; i++ )
+ {
+ nNumb[ i ] = ImplGetNumber( &pDest, nSecurityCount );
+ }
+ if ( nSecurityCount)
+ {
+ BYTE* pLinkBuf = new BYTE[ nPSSize ];
+ if ( pLinkBuf )
+ {
+ rStream.Seek( nPSStreamPos );
+ if ( rStream.Read( pLinkBuf, nPSSize ) == nPSSize )
+ {
+ GfxLink aGfxLink( pLinkBuf, nPSSize, GFX_LINK_TYPE_EPS_BUFFER, TRUE ) ;
+ GDIMetaFile aMtf;
+
+ long nWidth = nNumb[2] - nNumb[0] + 1;
+ long nHeight = nNumb[3] - nNumb[1] + 1;
+
+ if( !bHasPreview ) // if there is no preview -> make a red box
+ {
+ VirtualDevice aVDev;
+ GDIMetaFile aMtf2;
+ Font aFont;
+
+ aVDev.EnableOutput( FALSE );
+ aMtf2.Record( &aVDev );
+ aVDev.SetLineColor( Color( COL_RED ) );
+ aVDev.SetFillColor();
+
+ aFont.SetColor( COL_LIGHTRED );
+ aFont.SetSize( Size( 0, nHeight / 5 ) );
+
+ aVDev.Push( PUSH_FONT );
+ aVDev.SetFont( aFont );
+
+ Rectangle aRect( Point( 0, 0 ), Size( nWidth, nHeight ) );
+ aVDev.DrawRect( aRect );
+
+ String aString;
+ int nLen;
+ if ( rStream.IsA() == ID_FILESTREAM )
+ {
+ SvFileStream* pSvFileStream = (SvFileStream*)&rStream;
+ INetURLObject aURL;
+ aURL.SetSmartURL( pSvFileStream->GetFileName() );
+ aString = aURL.GetName();
+ }
+ else
+ {
+ pDest = ImplSearchEntry( pBuf, (BYTE*)"%%Title:", nBytesRead - 32, 8 );
+ if ( pDest )
+ {
+ pDest += 8;
+ if ( *pDest == ' ' )
+ pDest++;
+ nLen = ImplGetLen( pBuf, 32 );
+ pDest[ nLen ] = 0;
+ if ( strcmp( (const char*)pDest, "none" ) != 0 )
+ {
+ aString.AppendAscii( (char*)pDest );
+ }
+ }
+ }
+ pDest = ImplSearchEntry( pBuf, (BYTE*)"%%Creator:", nBytesRead - 32, 10 );
+ if ( pDest )
+ {
+ pDest += 10;
+ if ( *pDest == ' ' )
+ pDest++;
+ nLen = ImplGetLen( pDest, 32 );
+ pDest[ nLen ] = 0;
+ aString.AppendAscii( "\n" );
+ aString.AppendAscii( (char*)pDest );
+ }
+ pDest = ImplSearchEntry( pBuf, (BYTE*)"%%CreationDate:", nBytesRead - 32, 15 );
+ if ( pDest )
+ {
+ pDest += 15;
+ if ( *pDest == ' ' )
+ pDest++;
+ nLen = ImplGetLen( pDest, 32 );
+ pDest[ nLen ] = 0;
+ if ( strcmp( (const char*)pDest, "none" ) != 0 )
+ {
+ aString.AppendAscii( "\n" );
+ aString.AppendAscii( (char*)pDest );
+ }
+ }
+ pDest = ImplSearchEntry( pBuf, (BYTE*)"%%LanguageLevel:", nBytesRead - 4, 16 );
+ if ( pDest )
+ {
+ pDest += 16;
+ int nCount = 4;
+ long nNumber = ImplGetNumber( &pDest, nCount );
+ if ( nCount && ( (UINT32)nNumber < 10 ) )
+ {
+ aString.AppendAscii( "\nLevel:" );
+ aString.Append( UniString::CreateFromInt32( nNumber ) );
+ }
+ }
+ aVDev.DrawText( Rectangle( aRect ), aString, TEXT_DRAW_CLIP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
+ aVDev.Pop();
+ aMtf2.Stop();
+ aMtf2.WindStart();
+ aMtf2.SetPrefMapMode( MAP_POINT );
+ aMtf2.SetPrefSize( Size( nWidth, nHeight ) );
+ aGraphic = aMtf2;
+ }
+
+ aMtf.AddAction( (MetaAction*)( new MetaEPSAction( Point(), Size( nWidth, nHeight ),
+ aGfxLink, aGraphic.GetGDIMetaFile() ) ) );
+ aMtf.WindStart();
+ aMtf.SetPrefMapMode( MAP_POINT );
+ aMtf.SetPrefSize( Size( nWidth, nHeight ) );
+ rGraphic = aMtf;
+ bRetValue = TRUE;
+ }
+ else
+ delete pLinkBuf;
+ }
+ }
+ }
+ }
+ }
+ delete pBuf;
+ }
+ rStream.SetNumberFormatInt(nOldFormat);
+ rStream.Seek( nOrigPos );
+ return ( bRetValue );
+}
+
+//================== ein bischen Muell fuer Windows ==========================
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
+
diff --git a/goodies/source/filter.vcl/ieps/makefile.mk b/goodies/source/filter.vcl/ieps/makefile.mk
new file mode 100644
index 000000000000..6124cabae85f
--- /dev/null
+++ b/goodies/source/filter.vcl/ieps/makefile.mk
@@ -0,0 +1,168 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=ieps
+DEPTARGET=vieps
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SLOFILES = $(SLO)$/ieps.obj
+
+# ==========================================================================
+
+SHL1TARGET= ips$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= ieps
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(CPPULIB)
+SHL1DEPN= $(LB)$/ieps.lib
+SHL1LIBS= $(SLB)$/ieps.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/ieps.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicImport >>$@
+.ELSE
+ @echo _GraphicImport >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET).DLL >>$@
+ @ldump -E1 -A $(SLB)$/ieps.lib >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicImport >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/ios2met/ios2met.cxx b/goodies/source/filter.vcl/ios2met/ios2met.cxx
new file mode 100644
index 000000000000..e03dd1b4ab94
--- /dev/null
+++ b/goodies/source/filter.vcl/ios2met/ios2met.cxx
@@ -0,0 +1,2847 @@
+/*************************************************************************
+ *
+ * $RCSfile: ios2met.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include <math.h>
+#include <vcl/graph.hxx>
+#include <vcl/poly.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/lineinfo.hxx>
+#include <svtools/fltcall.hxx>
+
+#ifndef NOOLDSV
+#include <vcl/gdiobj.hxx>
+#else // NOOLDSV
+enum PenStyle { PEN_NULL, PEN_SOLID, PEN_DOT, PEN_DASH, PEN_DASHDOT };
+#endif // NOOLDSV
+
+
+//============================== defines ===================================
+
+#define OOODEBUG(str,Num) //InfoBox(NULL,String(str)+String(" ")+String(Num)).Execute();
+
+// -----------------------------Feld-Typen-------------------------------
+
+#define BegDocumnMagic 0xA8A8 /* Begin Document */
+#define EndDocumnMagic 0xA8A9 /* End Document */
+
+#define BegResGrpMagic 0xC6A8 /* Begin Resource Group */
+#define EndResGrpMagic 0xC6A9 /* End Resource Group */
+
+#define BegColAtrMagic 0x77A8 /* Begin Color Attribute Table */
+#define EndColAtrMagic 0x77A9 /* End Color Attribute Table */
+#define BlkColAtrMagic 0x77B0 /* Color Attribute Table */
+#define MapColAtrMagic 0x77AB /* Map Color Attribute Table */
+
+#define BegImgObjMagic 0xFBA8 /* Begin Image Object */
+#define EndImgObjMagic 0xFBA9 /* End Image Object */
+#define DscImgObjMagic 0xFBA6 /* Image Data Descriptor */
+#define DatImgObjMagic 0xFBEE /* Image Picture Data */
+
+#define BegObEnv1Magic 0xC7A8 /* Begin Object Environment Group */
+#define EndObEnv1Magic 0xC7A9 /* End Object Environment Group */
+
+#define BegGrfObjMagic 0xBBA8 /* Begin Graphics Object */
+#define EndGrfObjMagic 0xBBA9 /* End Graphics Object */
+#define DscGrfObjMagic 0xBBA6 /* Graphics Data Descritor */
+#define DatGrfObjMagic 0xBBEE /* Graphics Data */
+
+#define MapCodFntMagic 0x8AAB /* Map Coded Font */
+#define MapDatResMagic 0xC3AB /* Map Data Resource */
+
+// -----------------------------Order-Typen-------------------------------
+
+#define GOrdGivArc 0xC6 /* 1 Arc at given position */
+#define GOrdCurArc 0x86 /* 1 Arc at current position */
+#define GOrdGivBzr 0xE5 /* 1 Beziercurve at given position */
+#define GOrdCurBzr 0xA5 /* 1 Beziercurve at current position */
+#define GOrdGivBox 0xC0 /* 1 Box at given position */
+#define GOrdCurBox 0x80 /* 1 Box at current position */
+#define GOrdGivFil 0xC5 /* 1 Fillet at given position */
+#define GOrdCurFil 0x85 /* 1 Fillet at current position */
+#define GOrdGivCrc 0xC7 /* 1 Full arc (circle) at given position */
+#define GOrdCurCrc 0x87 /* 1 Full arc (circle) at current position */
+#define GOrdGivLin 0xC1 /* 1 Line at given position */
+#define GOrdCurLin 0x81 /* 1 Line at current position */
+#define GOrdGivMrk 0xC2 /* 1 Marker at given position */
+#define GOrdCurMrk 0x82 /* 1 Marker at current position */
+#define GOrdGivArP 0xE3 /* 1 Partial arc at given position */
+#define GOrdCurArP 0xA3 /* 1 Partial arc at current position */
+#define GOrdGivRLn 0xE1 /* 1 Relative line at given position */
+#define GOrdCurRLn 0xA1 /* 1 Relative line at current position */
+#define GOrdGivSFl 0xE4 /* 1 Sharp fillet at given position */
+#define GOrdCurSFl 0xA4 /* 1 Sharp fillet at current position */
+
+#define GOrdGivStM 0xF1 /* 1 Character string move at given position */
+#define GOrdCurStM 0xB1 /* 1 Character string move at current position */
+#define GOrdGivStr 0xC3 /* 1 Character string at given position */
+#define GOrdCurStr 0x83 /* 1 Character string at current position */
+#define GOrdGivStx 0xFEF0 /* 2 Character string extended at given position */
+#define GOrdCurStx 0xFEB0 /* 2 Character string extended at current position */
+
+#define GOrdGivImg 0xD1 /* 1 Begin Image at given position */
+#define GOrdCurImg 0x91 /* 1 Begin Image at current position */
+#define GOrdImgDat 0x92 /* 1 Image data */
+#define GOrdEndImg 0x93 /* 1 End Image */
+#define GOrdBegAra 0x68 /* 0 1 Begin area */
+#define GOrdEndAra 0x60 /* 1 End area */
+#define GOrdBegElm 0xD2 /* 1 Begin element */
+#define GOrdEndElm 0x49 /* 0 1 End element */
+
+#define GOrdBegPth 0xD0 /* 1 Begin path */
+#define GOrdEndPth 0x7F /* 0 1 End path */
+#define GOrdFilPth 0xD7 /* 1 Fill path */
+#define GOrdModPth 0xD8 /* 1 Modify path */
+#define GOrdOutPth 0xD4 /* 1 Outline path */
+#define GOrdSClPth 0xB4 /* 1 Set clip path */
+
+#define GOrdNopNop 0x00 /* 0 0 No operation */
+#define GOrdRemark 0x01 /* 1 Comment */
+#define GOrdSegLab 0xD3 /* 1 Label */
+#define GOrdBitBlt 0xD6 /* 1 Bitblt */
+#define GOrdCalSeg 0x07 /* 1 Call Segment */
+#define GOrdSSgBnd 0x32 /* 1 Set segment boundary */
+#define GOrdSegChr 0x04 /* 1 Segment characteristics */
+#define GOrdCloFig 0x7D /* 0 1 Close Figure */
+#define GOrdEndSym 0xFF /* 0 0 End of symbol definition */
+#define GOrdEndPlg 0x3E /* 0 1 End prolog */
+#define GOrdEscape 0xD5 /* 1 Escape */
+#define GOrdExtEsc 0xFED5 /* 2 Extended Escape */
+#define GOrdPolygn 0xF3 /* 2 Polygons */
+
+#define GOrdStkPop 0x3F /* 0 1 Pop */
+
+#define GOrdSIvAtr 0x14 /* 1 Set individual attribute */
+#define GOrdPIvAtr 0x54 /* 1 Push and set individual attribute */
+#define GOrdSColor 0x0A /* 0 1 Set color */
+#define GOrdPColor 0x4A /* 0 1 Push and set color */
+#define GOrdSIxCol 0xA6 /* 1 Set indexed color */
+#define GOrdPIxCol 0xE6 /* 1 Push and set indexed color */
+#define GOrdSXtCol 0x26 /* 1 Set extended color */
+#define GOrdPXtCol 0x66 /* 1 Push and set extended color */
+#define GOrdSBgCol 0x25 /* 1 Set background color */
+#define GOrdPBgCol 0x65 /* 1 Push and set background color */
+#define GOrdSBxCol 0xA7 /* 1 Set background indexed color */
+#define GOrdPBxCol 0xE7 /* 1 Push and set background indexed color */
+#define GOrdSMixMd 0x0C /* 0 1 Set mix */
+#define GOrdPMixMd 0x4C /* 0 1 Push and set mix */
+#define GOrdSBgMix 0x0D /* 0 1 Set background mix */
+#define GOrdPBgMix 0x4D /* 0 1 Push and set background mix */
+
+#define GOrdSPtSet 0x08 /* 0 1 Set pattern set */
+#define GOrdPPtSet 0x48 /* 0 1 Push and set pattern set */
+#define GOrdSPtSym 0x28 /* 0 1 Set pattern symbol */
+#define GOrdPPtSym 0x09 /* 0 1 Push and set pattern symbol */
+#define GOrdSPtRef 0xA0 /* 1 Set model pattern reference */
+#define GOrdPPtRef 0xE0 /* 1 Push and set pattern reference point */
+
+#define GOrdSLnEnd 0x1A /* 0 1 Set line end */
+#define GOrdPLnEnd 0x5A /* 0 1 Push and set line end */
+#define GOrdSLnJoi 0x1B /* 0 1 Set line join */
+#define GOrdPLnJoi 0x5B /* 0 1 Push and set line join */
+#define GOrdSLnTyp 0x18 /* 0 1 Set line type */
+#define GOrdPLnTyp 0x58 /* 0 1 Push and set line type */
+#define GOrdSLnWdt 0x19 /* 0 1 Set line width */
+#define GOrdPLnWdt 0x59 /* 0 1 Push and set line width */
+#define GOrdSFrLWd 0x11 /* 1 Set fractional line width */
+#define GOrdPFrLWd 0x51 /* 1 Push and set fractional line width */
+#define GOrdSStLWd 0x15 /* 1 Set stroke line width */
+#define GOrdPStLWd 0x55 /* 1 Push and set stroke line width */
+
+#define GOrdSChDir 0x3A /* 0 1 Set character direction */
+#define GOrdPChDir 0x7A /* 0 1 Push and set character direction */
+#define GOrdSChPrc 0x39 /* 0 1 Set character precision */
+#define GOrdPChPrc 0x79 /* 0 1 Push and set character precision */
+#define GOrdSChSet 0x38 /* 0 1 Set character set */
+#define GOrdPChSet 0x78 /* 0 1 Push and set character set */
+#define GOrdSChAng 0x34 /* 1 Set character angle */
+#define GOrdPChAng 0x74 /* 1 Push and set character angle */
+#define GOrdSChBrx 0x05 /* 1 Set character break extra */
+#define GOrdPChBrx 0x45 /* 1 Push and set character break extra */
+#define GOrdSChCel 0x33 /* 1 Set character cell */
+#define GOrdPChCel 0x03 /* 1 Push and set character cell */
+#define GOrdSChXtr 0x17 /* 1 Set character extra */
+#define GOrdPChXtr 0x57 /* 1 Push and set character extra */
+#define GOrdSChShr 0x35 /* 1 Set character shear */
+#define GOrdPChShr 0x75 /* 1 Push and set character shear */
+#define GOrdSTxAlg 0x36 /* 0 2 Set text allingment */
+#define GOrdPTxAlg 0x76 /* 0 2 Push and set text allingment */
+
+#define GOrdSMkPrc 0x3B /* 0 1 Set marker precision */
+#define GOrdPMkPrc 0x7B /* 0 1 Push and set marker precision */
+#define GOrdSMkSet 0x3C /* 0 1 Set marker set */
+#define GOrdPMkSet 0x7C /* 0 1 Push and set marker set */
+#define GOrdSMkSym 0x29 /* 0 1 Set marker symbol */
+#define GOrdPMkSym 0x69 /* 0 1 Push and set marker symbol */
+#define GOrdSMkCel 0x37 /* 1 Set marker cell */
+#define GOrdPMkCel 0x77 /* 1 Push and set marker cell */
+
+#define GOrdSArcPa 0x22 /* 1 Set arc parameters */
+#define GOrdPArcPa 0x62 /* 1 Push and set arc parameters */
+
+#define GOrdSCrPos 0x21 /* 1 Set current position */
+#define GOrdPCrPos 0x61 /* 1 Push and set current position */
+
+#define GOrdSMdTrn 0x24 /* 1 Set model transform */
+#define GOrdPMdTrn 0x64 /* 1 Push and set model transform */
+#define GOrdSPkIdn 0x43 /* 1 Set pick identifier */
+#define GOrdPPkIdn 0x23 /* 1 Push and set pick identifier */
+#define GOrdSVwTrn 0x31 /* 1 Set viewing transform */
+#define GOrdSVwWin 0x27 /* 1 Set viewing window */
+#define GOrdPVwWin 0x67 /* 1 Push and set viewing window */
+
+//============================ OS2METReader ==================================
+
+struct OSPalette {
+ OSPalette * pSucc;
+ ULONG * p0RGB; // Darf auch NULL sein!
+ USHORT nSize;
+};
+
+struct OSArea {
+ OSArea * pSucc;
+ BYTE nFlags;
+ PolyPolygon aPPoly;
+ BOOL bClosed;
+ Color aCol;
+ Color aBgCol;
+ RasterOp eMix;
+ RasterOp eBgMix;
+ BOOL bFill;
+ OSArea(){} ~OSArea(){}
+};
+
+struct OSPath
+{
+ OSPath* pSucc;
+ ULONG nID;
+ PolyPolygon aPPoly;
+ BOOL bClosed;
+ BOOL bStroke;
+
+ OSPath(){}
+ ~OSPath(){}
+};
+
+struct OSFont {
+ OSFont * pSucc;
+ ULONG nID;
+ Font aFont;
+ OSFont(){} ~OSFont(){}
+};
+
+struct OSBitmap {
+ OSBitmap * pSucc;
+ ULONG nID;
+ Bitmap aBitmap;
+
+ // Waehrend des Lesens der Bitmap benoetigt:
+ SvStream * pBMP; // Zeiger auf temporaere Windows-BMP-Datei oder NULL
+ ULONG nWidth, nHeight;
+ USHORT nBitsPerPixel;
+ ULONG nMapPos;
+ OSBitmap(){} ~OSBitmap(){}
+};
+
+struct OSAttr {
+ OSAttr * pSucc;
+ USHORT nPushOrder;
+ BYTE nIvAttrA, nIvAttrP; // Spezialvariablen fuer den Order "GOrdPIvAtr"
+
+ Color aLinCol;
+ Color aLinBgCol;
+ RasterOp eLinMix;
+ RasterOp eLinBgMix;
+ Color aChrCol;
+ Color aChrBgCol;
+ RasterOp eChrMix;
+ RasterOp eChrBgMix;
+ Color aMrkCol;
+ Color aMrkBgCol;
+ RasterOp eMrkMix;
+ RasterOp eMrkBgMix;
+ Color aPatCol;
+ Color aPatBgCol;
+ RasterOp ePatMix;
+ RasterOp ePatBgMix;
+ Color aImgCol;
+ Color aImgBgCol;
+ RasterOp eImgMix;
+ RasterOp eImgBgMix;
+ long nArcP, nArcQ, nArcR, nArcS;
+ short nChrAng;
+// long nChrBreakExtra;
+ Size aChrCellSize;
+// BYTE nChrDir;
+// long nChrExtra;
+// BYTE nChrPrec;
+ ULONG nChrSet;
+// Size aChrShear;
+ Point aCurPos;
+// long nFracLinWidth;
+// BYTE nLinEnd;
+// BYTE nLinJoin;
+ PenStyle eLinStyle;
+ USHORT nLinWidth;
+ Size aMrkCellSize;
+ BYTE nMrkPrec;
+ BYTE nMrkSet;
+ BYTE nMrkSymbol;
+// //... aModTransform;
+// Point aPatRef;
+// BYTE nPatSet;
+ BOOL bFill;
+// ULONG nPickId;
+// //... aSegBound;
+ USHORT nStrLinWidth;
+// BYTE nTxtAlignHor,nTxtAlignVer;
+// //... aViewTransform;
+// //... aViewWindow;
+ OSAttr(){} ~OSAttr(){}
+};
+
+class OS2METReader {
+
+private:
+
+ long ErrorCode;
+
+ PFilterCallback pCallback;
+ void * pCallerData;
+
+ SvStream * pOS2MET; // Die einzulesende OS2MET-Datei
+ VirtualDevice * pVirDev; // Hier werden die Drawing-Methoden aufgerufen.
+ // Dabei findet ein Recording in das GDIMetaFile
+ // statt.
+ ULONG nOrigPos; // Anfaengliche Position in pOS2MET
+ UINT16 nOrigNumberFormat; // Anfaengliches Nummern-Format von pOS2MET
+ Rectangle aBoundingRect; // Boundingrectangle wie in Datei angegeben
+ Rectangle aCalcBndRect; // selbst ermitteltes Boundingrectangle
+ MapMode aGlobMapMode; // Aufloesung des Bildes
+ BOOL bCoord32;
+
+ OSPalette * pPaletteStack;
+
+ LineInfo aLineInfo;
+
+ OSArea * pAreaStack; // Areas, die in Arbeit sind
+
+ OSPath * pPathStack; // Paths, die in Arbeit sind
+ OSPath * pPathList; // Vollendete Paths
+
+ OSFont * pFontList;
+
+ OSBitmap * pBitmapList;
+
+ OSAttr aDefAttr;
+ OSAttr aAttr;
+ OSAttr * pAttrStack;
+
+ SvStream * pOrdFile;
+
+ BOOL Callback(USHORT nPercent);
+
+ void AddPointsToPath(const Polygon & rPoly);
+ void AddPointsToArea(const Polygon & rPoly);
+ void CloseFigure();
+ void PushAttr(USHORT nPushOrder);
+ void PopAttr();
+
+ void ChangeBrush( const Color& rPatColor, const Color& rBGColor, BOOL bFill );
+ void SetPen( const Color& rColor, USHORT nStrLinWidth = 0, PenStyle ePenStyle = PEN_SOLID );
+ void SetRasterOp(RasterOp eROP);
+
+ void SetPalette0RGB(USHORT nIndex, ULONG nCol);
+ ULONG GetPalette0RGB(ULONG nIndex);
+ // Holt Farbe aus der Palette, oder, wenn nicht vorhanden,
+ // interpretiert nIndex als direkten RGB-Wert.
+ Color GetPaletteColor(ULONG nIndex);
+
+
+ BOOL IsLineInfo();
+ void DrawPolyLine( const Polygon& rPolygon );
+ void DrawPolygon( const Polygon& rPolygon );
+ void DrawPolyPolygon( const PolyPolygon& rPolygon );
+ USHORT ReadBigEndianWord();
+ ULONG ReadBigEndian3BytesLong();
+ ULONG ReadLittleEndian3BytesLong();
+ long ReadCoord(BOOL b32);
+ Point ReadPoint( const BOOL bAdjustBoundRect = TRUE );
+ RasterOp OS2MixToRasterOp(BYTE nMix);
+ void ReadLine(BOOL bGivenPos, USHORT nOrderLen);
+ void ReadRelLine(BOOL bGivenPos, USHORT nOrderLen);
+ void ReadBox(BOOL bGivenPos);
+ void ReadBitBlt();
+ void ReadChrStr(BOOL bGivenPos, BOOL bMove, BOOL bExtra, USHORT nOrderLen);
+ void ReadArc(BOOL bGivenPos);
+ void ReadFullArc(BOOL bGivenPos, USHORT nOrderSize);
+ void ReadPartialArc(BOOL bGivenPos, USHORT nOrderSize);
+ void ReadPolygons();
+ void ReadBezier(BOOL bGivenPos, USHORT nOrderLen);
+ void ReadFillet(BOOL bGivenPos, USHORT nOrderLen);
+ void ReadFilletSharp(BOOL bGivenPos, USHORT nOrderLen);
+ void ReadMarker(BOOL bGivenPos, USHORT nOrderLen);
+ void ReadOrder(USHORT nOrderID, USHORT nOrderLen);
+ void ReadDsc(USHORT nDscID, USHORT nDscLen);
+ void ReadImageData(USHORT nDataID, USHORT nDataLen);
+ void ReadFont(USHORT nFieldSize);
+ void ReadField(USHORT nFieldType, USHORT nFieldSize);
+
+public:
+
+ OS2METReader();
+ ~OS2METReader();
+
+ void ReadOS2MET( SvStream & rStreamOS2MET, GDIMetaFile & rGDIMetaFile, PFilterCallback pcallback, void * pcallerdata);
+ // Liesst aus dem Stream eine OS2MET-Datei und fuellt das GDIMetaFile
+
+};
+
+//=================== Methoden von OS2METReader ==============================
+
+BOOL OS2METReader::Callback(USHORT nPercent)
+{
+ if (pCallback!=NULL) {
+ if (((*pCallback)(pCallerData,nPercent))==TRUE) {
+ pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+OS2METReader::OS2METReader()
+{
+}
+
+OS2METReader::~OS2METReader()
+{
+}
+
+BOOL OS2METReader::IsLineInfo()
+{
+ return ( ! ( aLineInfo.IsDefault() || ( aLineInfo.GetStyle() == LINE_NONE ) || ( pVirDev->GetLineColor() == COL_TRANSPARENT ) ) );
+}
+
+void OS2METReader::DrawPolyLine( const Polygon& rPolygon )
+{
+ if ( aLineInfo.GetStyle() == LINE_DASH || ( aLineInfo.GetWidth() > 1 ) )
+ pVirDev->DrawPolyLine( rPolygon, aLineInfo );
+ else
+ pVirDev->DrawPolyLine( rPolygon );
+}
+
+void OS2METReader::DrawPolygon( const Polygon& rPolygon )
+{
+ if ( IsLineInfo() )
+ {
+ pVirDev->Push( PUSH_LINECOLOR );
+ pVirDev->SetLineColor( COL_TRANSPARENT );
+ pVirDev->DrawPolygon( rPolygon );
+ pVirDev->Pop();
+ pVirDev->DrawPolyLine( rPolygon, aLineInfo );
+ }
+ else
+ pVirDev->DrawPolygon( rPolygon );
+}
+
+void OS2METReader::DrawPolyPolygon( const PolyPolygon& rPolyPolygon )
+{
+ if ( IsLineInfo() )
+ {
+ pVirDev->Push( PUSH_LINECOLOR );
+ pVirDev->SetLineColor( COL_TRANSPARENT );
+ pVirDev->DrawPolyPolygon( rPolyPolygon );
+ pVirDev->Pop();
+ for ( USHORT i = 0; i < rPolyPolygon.Count(); i++ )
+ pVirDev->DrawPolyLine( rPolyPolygon.GetObject( i ), aLineInfo );
+ }
+ else
+ pVirDev->DrawPolyPolygon( rPolyPolygon );
+}
+
+void OS2METReader::AddPointsToArea(const Polygon & rPoly)
+{
+ USHORT nOldSize, nNewSize,i;
+
+ if (pAreaStack==NULL || rPoly.GetSize()==0) return;
+ PolyPolygon * pPP=&(pAreaStack->aPPoly);
+ if (pPP->Count()==0 || pAreaStack->bClosed==TRUE) pPP->Insert(rPoly);
+ else {
+ Polygon aLastPoly(pPP->GetObject(pPP->Count()-1));
+ nOldSize=aLastPoly.GetSize();
+ if (aLastPoly.GetPoint(nOldSize-1)==rPoly.GetPoint(0)) nOldSize--;
+ nNewSize=nOldSize+rPoly.GetSize();
+ aLastPoly.SetSize(nNewSize);
+ for (i=nOldSize; i<nNewSize; i++) {
+ aLastPoly.SetPoint(rPoly.GetPoint(i-nOldSize),i);
+ }
+ pPP->Replace(aLastPoly,pPP->Count()-1);
+ }
+ pAreaStack->bClosed=FALSE;
+}
+
+void OS2METReader::AddPointsToPath(const Polygon & rPoly)
+{
+ USHORT nOldSize, nNewSize,i;
+
+ if (pPathStack==NULL || rPoly.GetSize()==0) return;
+ PolyPolygon * pPP=&(pPathStack->aPPoly);
+ if (pPP->Count()==0 /*|| pPathStack->bClosed==TRUE*/) pPP->Insert(rPoly);
+ else {
+ Polygon aLastPoly(pPP->GetObject(pPP->Count()-1));
+ nOldSize=aLastPoly.GetSize();
+ if (aLastPoly.GetPoint(nOldSize-1)!=rPoly.GetPoint(0)) pPP->Insert(rPoly);
+ else {
+ nOldSize--;
+ nNewSize=nOldSize+rPoly.GetSize();
+ aLastPoly.SetSize(nNewSize);
+ for (i=nOldSize; i<nNewSize; i++) {
+ aLastPoly.SetPoint(rPoly.GetPoint(i-nOldSize),i);
+ }
+ pPP->Replace(aLastPoly,pPP->Count()-1);
+ }
+ }
+ pPathStack->bClosed=FALSE;
+}
+
+void OS2METReader::CloseFigure()
+{
+ if (pAreaStack!=NULL) pAreaStack->bClosed=TRUE;
+ else if (pPathStack!=NULL) pPathStack->bClosed=TRUE;
+}
+
+void OS2METReader::PushAttr(USHORT nPushOrder)
+{
+ OSAttr * p;
+ p=new OSAttr;
+ *p=aAttr;
+ p->pSucc=pAttrStack; pAttrStack=p;
+ p->nPushOrder=nPushOrder;
+}
+
+void OS2METReader::PopAttr()
+{
+ OSAttr * p=pAttrStack;
+
+ if (p==NULL) return;
+ switch (p->nPushOrder) {
+
+ case GOrdPIvAtr:
+ switch (p->nIvAttrA) {
+ case 1: switch (p->nIvAttrP) {
+ case 1: aAttr.aLinCol=p->aLinCol; break;
+ case 2: aAttr.aChrCol=p->aChrCol; break;
+ case 3: aAttr.aMrkCol=p->aMrkCol; break;
+ case 4: aAttr.aPatCol=p->aPatCol; break;
+ case 5: aAttr.aImgCol=p->aImgCol; break;
+ } break;
+ case 2: switch (p->nIvAttrP) {
+ case 1: aAttr.aLinBgCol=p->aLinBgCol; break;
+ case 2: aAttr.aChrBgCol=p->aChrBgCol; break;
+ case 3: aAttr.aMrkBgCol=p->aMrkBgCol; break;
+ case 4: aAttr.aPatBgCol=p->aPatBgCol; break;
+ case 5: aAttr.aImgBgCol=p->aImgBgCol; break;
+ } break;
+ case 3: switch (p->nIvAttrP) {
+ case 1: aAttr.eLinMix=p->eLinMix; break;
+ case 2: aAttr.eChrMix=p->eChrMix; break;
+ case 3: aAttr.eMrkMix=p->eMrkMix; break;
+ case 4: aAttr.ePatMix=p->ePatMix; break;
+ case 5: aAttr.eImgMix=p->eImgMix; break;
+ } break;
+ case 4: switch (p->nIvAttrP) {
+ case 1: aAttr.eLinBgMix=p->eLinBgMix; break;
+ case 2: aAttr.eChrBgMix=p->eChrBgMix; break;
+ case 3: aAttr.eMrkBgMix=p->eMrkBgMix; break;
+ case 4: aAttr.ePatBgMix=p->ePatBgMix; break;
+ case 5: aAttr.eImgBgMix=p->eImgBgMix; break;
+ } break;
+ }
+ break;
+
+ case GOrdPLnTyp: aAttr.eLinStyle=p->eLinStyle; break;
+
+ case GOrdPLnWdt: aAttr.nLinWidth=p->nLinWidth; break;
+
+ case GOrdPStLWd: aAttr.nStrLinWidth=p->nStrLinWidth; break;
+
+ case GOrdPChSet: aAttr.nChrSet=p->nChrSet; break;
+
+ case GOrdPChAng: aAttr.nChrAng=p->nChrAng; break;
+
+ case GOrdPMixMd:
+ aAttr.eLinMix=p->eLinMix;
+ aAttr.eChrMix=p->eChrMix;
+ aAttr.eMrkMix=p->eMrkMix;
+ aAttr.ePatMix=p->ePatMix;
+ aAttr.eImgMix=p->eImgMix;
+ break;
+
+ case GOrdPBgMix:
+ aAttr.eLinBgMix=p->eLinBgMix;
+ aAttr.eChrBgMix=p->eChrBgMix;
+ aAttr.eMrkBgMix=p->eMrkBgMix;
+ aAttr.ePatBgMix=p->ePatBgMix;
+ aAttr.eImgBgMix=p->eImgBgMix;
+ break;
+
+ case GOrdPPtSym: aAttr.bFill = p->bFill; break;
+
+ case GOrdPColor:
+ case GOrdPIxCol:
+ case GOrdPXtCol:
+ aAttr.aLinCol=p->aLinCol;
+ aAttr.aChrCol=p->aChrCol;
+ aAttr.aMrkCol=p->aMrkCol;
+ aAttr.aPatCol=p->aPatCol;
+ aAttr.aImgCol=p->aImgCol;
+ break;
+
+ case GOrdPBgCol:
+ case GOrdPBxCol:
+ aAttr.aLinBgCol=p->aLinBgCol;
+ aAttr.aChrBgCol=p->aChrBgCol;
+ aAttr.aMrkBgCol=p->aMrkBgCol;
+ aAttr.aPatBgCol=p->aPatBgCol;
+ aAttr.aImgBgCol=p->aImgBgCol;
+ break;
+
+ case GOrdPMkPrc: aAttr.nMrkPrec=aDefAttr.nMrkPrec; break;
+
+ case GOrdPMkSet: aAttr.nMrkSet=aDefAttr.nMrkSet; break;
+
+ case GOrdPMkSym: aAttr.nMrkSymbol=aDefAttr.nMrkSymbol; break;
+
+ case GOrdPMkCel: aAttr.aMrkCellSize=aDefAttr.aMrkCellSize; break;
+
+ case GOrdPArcPa:
+ aAttr.nArcP=p->nArcP; aAttr.nArcQ=p->nArcQ;
+ aAttr.nArcR=p->nArcR; aAttr.nArcS=p->nArcS;
+ break;
+
+ case GOrdPCrPos:
+ aAttr.aCurPos=p->aCurPos;
+ break;
+ }
+ pAttrStack=p->pSucc;
+ delete p;
+}
+
+void OS2METReader::ChangeBrush(const Color& rPatColor, const Color& rBGColor, BOOL bFill )
+{
+ Color aColor;
+
+ if( bFill )
+ aColor = rPatColor;
+ else
+ aColor = Color( COL_TRANSPARENT );
+
+ if( pVirDev->GetFillColor() != aColor )
+ pVirDev->SetFillColor( aColor );
+}
+
+void OS2METReader::SetPen( const Color& rColor, USHORT nLineWidth, PenStyle ePenStyle )
+{
+ LineStyle eLineStyle( LINE_SOLID );
+
+ if ( pVirDev->GetLineColor() != rColor )
+ pVirDev->SetLineColor( rColor );
+ aLineInfo.SetWidth( nLineWidth );
+
+ USHORT nDotCount = 0;
+ USHORT nDashCount = 0;
+ switch ( ePenStyle )
+ {
+ case PEN_NULL :
+ eLineStyle = LINE_NONE;
+ break;
+ case PEN_DASHDOT :
+ nDashCount++;
+ case PEN_DOT :
+ nDotCount++;
+ nDashCount--;
+ case PEN_DASH :
+ nDashCount++;
+ aLineInfo.SetDotCount( nDotCount );
+ aLineInfo.SetDashCount( nDashCount );
+ aLineInfo.SetDistance( nLineWidth );
+ aLineInfo.SetDotLen( nLineWidth );
+ aLineInfo.SetDashLen( nLineWidth << 2 );
+ eLineStyle = LINE_DASH;
+ break;
+ }
+ aLineInfo.SetStyle( eLineStyle );
+}
+
+void OS2METReader::SetRasterOp(RasterOp eROP)
+{
+ if (pVirDev->GetRasterOp()!=eROP) pVirDev->SetRasterOp(eROP);
+}
+
+
+void OS2METReader::SetPalette0RGB(USHORT nIndex, ULONG nCol)
+{
+ if (pPaletteStack==NULL) {
+ pPaletteStack=new OSPalette;
+ pPaletteStack->pSucc=NULL;
+ pPaletteStack->p0RGB=NULL;
+ pPaletteStack->nSize=0;
+ }
+ if (pPaletteStack->p0RGB==NULL || nIndex>=pPaletteStack->nSize) {
+ ULONG * pOld0RGB=pPaletteStack->p0RGB;
+ USHORT i,nOldSize=pPaletteStack->nSize;
+ if (pOld0RGB==NULL) nOldSize=0;
+ pPaletteStack->nSize=2*(nIndex+1);
+ if (pPaletteStack->nSize<256) pPaletteStack->nSize=256;
+ pPaletteStack->p0RGB = new ULONG[pPaletteStack->nSize];
+ for (i=0; i<pPaletteStack->nSize; i++) {
+ if (i<nOldSize) pPaletteStack->p0RGB[i]=pOld0RGB[i];
+ else if (i==0) pPaletteStack->p0RGB[i]=0x00ffffff;
+ else pPaletteStack->p0RGB[i]=0;
+ }
+ if (pOld0RGB!=NULL) delete pOld0RGB;
+ }
+ pPaletteStack->p0RGB[nIndex]=nCol;
+}
+
+ULONG OS2METReader::GetPalette0RGB(ULONG nIndex)
+{
+ if (pPaletteStack!=NULL && pPaletteStack->p0RGB!=NULL &&
+ pPaletteStack->nSize>nIndex) nIndex=pPaletteStack->p0RGB[nIndex];
+ return nIndex;
+}
+
+Color OS2METReader::GetPaletteColor(ULONG nIndex)
+{
+ nIndex=GetPalette0RGB(nIndex);
+ return Color((((USHORT)(nIndex>>8))&0xff00)>>8,
+ (((USHORT) nIndex)&0xff00)>>8,
+ (((USHORT)(nIndex<<8))&0xff00)>>8);
+}
+
+
+USHORT OS2METReader::ReadBigEndianWord()
+{
+ BYTE nLo,nHi;
+ *pOS2MET >> nHi >> nLo;
+ return (((USHORT)nHi)<<8)|(((USHORT)nLo)&0x00ff);
+}
+
+ULONG OS2METReader::ReadBigEndian3BytesLong()
+{
+ USHORT nLo;
+ BYTE nHi;
+ *pOS2MET >> nHi;
+ nLo=ReadBigEndianWord();
+ return ((((ULONG)nHi)<<16)&0x00ff0000)|((ULONG)nLo);
+}
+
+ULONG OS2METReader::ReadLittleEndian3BytesLong()
+{
+ BYTE nHi,nMed,nLo;
+
+ *pOS2MET >> nLo >> nMed >> nHi;
+ return ((((ULONG)nHi)&0xff)<<16)|((((ULONG)nMed)&0xff)<<8)|(((ULONG)nLo)&0xff);
+}
+
+long OS2METReader::ReadCoord(BOOL b32)
+{
+ long l;
+ short s;
+
+ if (b32) *pOS2MET >> l;
+ else { *pOS2MET >> s; l=(long)s; }
+ return l;
+}
+
+Point OS2METReader::ReadPoint( const BOOL bAdjustBoundRect )
+{
+ long x,y;
+
+ x=ReadCoord(bCoord32);
+ y=ReadCoord(bCoord32);
+ x=x-aBoundingRect.Left();
+ y=aBoundingRect.Bottom()-y;
+
+ if ( bAdjustBoundRect )
+ aCalcBndRect.Union(Rectangle(x,y,x+1,y+1));
+
+ return Point(x,y);
+}
+
+RasterOp OS2METReader::OS2MixToRasterOp(BYTE nMix)
+{
+ switch (nMix) {
+ case 0x0c: return ROP_INVERT;
+ case 0x04: return ROP_XOR;
+ case 0x0b: return ROP_XOR;
+ default: return ROP_OVERPAINT;
+ }
+}
+
+void OS2METReader::ReadLine(BOOL bGivenPos, USHORT nOrderLen)
+{
+ USHORT i,nPolySize;
+
+ if (bCoord32) nPolySize=nOrderLen/8; else nPolySize=nOrderLen/4;
+ if (!bGivenPos) nPolySize++;
+ if (nPolySize==0) return;
+ Polygon aPolygon(nPolySize);
+ for (i=0; i<nPolySize; i++) {
+ if (i==0 && !bGivenPos) aPolygon.SetPoint(aAttr.aCurPos,i);
+ else aPolygon.SetPoint(ReadPoint(),i);
+ }
+ aAttr.aCurPos=aPolygon.GetPoint(nPolySize-1);
+ if (pAreaStack!=NULL) AddPointsToArea(aPolygon);
+ else if (pPathStack!=NULL) AddPointsToPath(aPolygon);
+ else
+ {
+ SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
+ SetRasterOp(aAttr.eLinMix);
+ DrawPolyLine( aPolygon );
+ }
+}
+
+void OS2METReader::ReadRelLine(BOOL bGivenPos, USHORT nOrderLen)
+{
+ USHORT i,nPolySize;
+ Point aP0;
+
+
+ if (bGivenPos) {
+ aP0=ReadPoint();
+ if (bCoord32) nOrderLen-=8; else nOrderLen-=4;
+ }
+ else aP0=aAttr.aCurPos;
+ nPolySize=nOrderLen/2;
+ if (nPolySize==0) return;
+ Polygon aPolygon(nPolySize);
+ for (i=0; i<nPolySize; i++) {
+#if (defined SOLARIS && defined PPC) || defined IRIX
+ UINT8 nunsignedbyte;
+ *pOS2MET >> nunsignedbyte; aP0.X()+=(INT8)nunsignedbyte;
+ *pOS2MET >> nunsignedbyte; aP0.Y()+=(INT8)nunsignedbyte;
+#else
+ INT8 nsignedbyte;
+ *pOS2MET >> nsignedbyte; aP0.X()+=(long)nsignedbyte;
+ *pOS2MET >> nsignedbyte; aP0.Y()-=(long)nsignedbyte;
+#endif
+ aCalcBndRect.Union(Rectangle(aP0,Size(1,1)));
+ aPolygon.SetPoint(aP0,i);
+ }
+ aAttr.aCurPos=aPolygon.GetPoint(nPolySize-1);
+ if (pAreaStack!=NULL) AddPointsToArea(aPolygon);
+ else if (pPathStack!=NULL) AddPointsToPath(aPolygon);
+ else
+ {
+ SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
+ SetRasterOp(aAttr.eLinMix);
+ DrawPolyLine( aPolygon );
+ }
+}
+
+void OS2METReader::ReadBox(BOOL bGivenPos)
+{
+ BYTE nFlags;
+ Point P0;
+ long nHRound,nVRound;
+
+ *pOS2MET >> nFlags;
+ pOS2MET->SeekRel(1);
+
+ if ( bGivenPos )
+ P0 = ReadPoint();
+ else
+ P0 = aAttr.aCurPos;
+
+ aAttr.aCurPos=ReadPoint();
+ nHRound=ReadCoord(bCoord32);
+ nVRound=ReadCoord(bCoord32);
+
+ Rectangle aBoxRect( P0, aAttr.aCurPos );
+
+ if ( pAreaStack )
+ AddPointsToArea( Polygon( aBoxRect ) );
+ else if ( pPathStack )
+ AddPointsToPath( Polygon( aBoxRect ) );
+ else
+ {
+ if ( nFlags & 0x20 )
+ SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
+ else
+ SetPen( COL_TRANSPARENT );
+
+ if ( nFlags & 0x40 )
+ {
+ ChangeBrush(aAttr.aPatCol,aAttr.aPatBgCol,aAttr.bFill);
+ SetRasterOp(aAttr.ePatMix);
+ }
+ else
+ {
+ ChangeBrush( Color( COL_TRANSPARENT ), Color( COL_TRANSPARENT ), FALSE );
+ SetRasterOp(aAttr.eLinMix);
+ }
+
+ if ( IsLineInfo() )
+ {
+ Polygon aPolygon( aBoxRect, nHRound, nVRound );
+ if ( nFlags & 0x40 )
+ {
+ pVirDev->Push( PUSH_LINECOLOR );
+ pVirDev->SetLineColor( COL_TRANSPARENT );
+ pVirDev->DrawRect( aBoxRect, nHRound, nVRound );
+ pVirDev->Pop();
+ }
+ pVirDev->DrawPolyLine( aPolygon, aLineInfo );
+ }
+ else
+ pVirDev->DrawRect( aBoxRect, nHRound, nVRound );
+ }
+}
+
+void OS2METReader::ReadBitBlt()
+{
+ Point aP1,aP2;
+ Size aSize;
+ ULONG nID;
+ OSBitmap * pB;
+ long nt;
+
+ pOS2MET->SeekRel(4);
+ *pOS2MET >> nID;
+ pOS2MET->SeekRel(4);
+ aP1=ReadPoint(); aP2=ReadPoint();
+ if (aP1.X() > aP2.X()) { nt=aP1.X(); aP1.X()=aP2.X(); aP2.X()=nt; }
+ if (aP1.Y() > aP2.Y()) { nt=aP1.Y(); aP1.Y()=aP2.Y(); aP2.Y()=nt; }
+ aSize=Size(aP2.X()-aP1.X(),aP2.Y()-aP1.Y());
+
+ pB=pBitmapList;
+ while (pB!=NULL && pB->nID!=nID) pB=pB->pSucc;
+ if (pB!=NULL) {
+ SetRasterOp(aAttr.ePatMix);
+ pVirDev->DrawBitmap(aP1,aSize,pB->aBitmap);
+ }
+}
+
+void OS2METReader::ReadChrStr(BOOL bGivenPos, BOOL bMove, BOOL bExtra, USHORT nOrderLen)
+{
+ Point aP0;
+ USHORT i, nLen;
+ char * pChr;
+ OSFont * pF;
+ Font aFont;
+ Size aSize;
+
+ pF = pFontList;
+ while (pF!=NULL && pF->nID!=aAttr.nChrSet) pF=pF->pSucc;
+ if (pF!=NULL)
+ aFont = pF->aFont;
+ aFont.SetColor(aAttr.aChrCol);
+ aFont.SetSize(Size(0,aAttr.aChrCellSize.Height()));
+ if ( aAttr.nChrAng != 0 )
+ aFont.SetOrientation(aAttr.nChrAng);
+
+ if (bGivenPos)
+ aP0 = ReadPoint();
+ else
+ aP0 = aAttr.aCurPos;
+ if (bExtra)
+ {
+ pOS2MET->SeekRel(2);
+ ReadPoint( FALSE );
+ ReadPoint( FALSE );
+ *pOS2MET >> nLen;
+ }
+ else
+ {
+ if ( !bGivenPos )
+ nLen = nOrderLen;
+ else if ( bCoord32 )
+ nLen = nOrderLen-8;
+ else
+ nLen = nOrderLen-4;
+ }
+ pChr = new char[nLen+1];
+ for (i=0; i<nLen; i++)
+ *pOS2MET >> pChr[i];
+ pChr[nLen]=0;
+ String aStr( String::CreateFromAscii( pChr ) );
+
+ SetRasterOp(aAttr.eChrMix);
+ if (pVirDev->GetFont()!=aFont)
+ pVirDev->SetFont(aFont);
+ pVirDev->DrawText(aP0,aStr);
+
+ aSize = Size( pVirDev->GetTextWidth(aStr), pVirDev->GetTextHeight() );
+ if ( aAttr.nChrAng == 0 )
+ {
+ aCalcBndRect.Union(Rectangle( Point(aP0.X(),aP0.Y()-aSize.Height()),
+ Size(aSize.Width(),aSize.Height()*2)));
+ if (bMove)
+ aAttr.aCurPos = Point( aP0.X() + aSize.Width(), aP0.Y());
+ }
+ else
+ {
+ Polygon aDummyPoly(4);
+
+ aDummyPoly.SetPoint( Point( aP0.X(), aP0.Y() ), 0); // TOP LEFT
+ aDummyPoly.SetPoint( Point( aP0.X(), aP0.Y() - aSize.Height() ), 1); // BOTTOM LEFT
+ aDummyPoly.SetPoint( Point( aP0.X() + aSize.Width(), aP0.Y() ), 2); // TOP RIGHT
+ aDummyPoly.SetPoint( Point( aP0.X() + aSize.Width(), aP0.Y() - aSize.Height() ), 3);// BOTTOM RIGHT
+ aDummyPoly.Rotate( aP0, (short)aAttr.nChrAng );
+ if ( bMove )
+ aAttr.aCurPos = aDummyPoly.GetPoint( 0 );
+ aCalcBndRect.Union( Rectangle( aDummyPoly.GetPoint( 0 ), aDummyPoly.GetPoint( 3 ) ) );
+ aCalcBndRect.Union( Rectangle( aDummyPoly.GetPoint( 1 ), aDummyPoly.GetPoint( 2 ) ) );
+ }
+ delete pChr;
+}
+
+void OS2METReader::ReadArc(BOOL bGivenPos)
+{
+ Point aP1, aP2, aP3;
+ double x1,y1,x2,y2,x3,y3,p,q,cx,cy,ncx,ncy,r,rx,ry,w1,w3;
+ if (bGivenPos) aP1=ReadPoint(); else aP1=aAttr.aCurPos;
+ aP2=ReadPoint(); aP3=ReadPoint();
+ aAttr.aCurPos=aP3;
+ SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
+ SetRasterOp(aAttr.eLinMix);
+ // OK, gegeben sind 3 Punkte der Ellipse, und das Verhaeltnis
+ // Breite zu Hoehe (als p zu q):
+ x1=aP1.X(); y1=aP1.Y();
+ x2=aP2.X(); y2=aP2.Y();
+ x3=aP3.X(); y3=aP3.Y();
+ p=aAttr.nArcP;q=aAttr.nArcQ;
+ // Berechnet wird der Mittelpunkt cx,cy der Ellipse:
+ ncy=2*p*p*((y3-y1)*(x2-x1)-(y1-y2)*(x1-x3));
+ ncx=2*q*q*(x2-x1);
+ if ( (ncx<0.001 && ncx>-0.001) || (ncy<0.001 && ncy>-0.001) ) {
+ // Berechnung nicht moeglich, Punkte liegen auf einer Linie
+ pVirDev->DrawLine(aP1,aP2);
+ pVirDev->DrawLine(aP2,aP3);
+ return;
+ }
+ cy=( q*q*((x3*x3-x1*x1)*(x2-x1)+(x2*x2-x1*x1)*(x1-x3)) +
+ p*p*((y3*y3-y1*y1)*(x2-x1)+(y2*y2-y1*y1)*(x1-x3)) ) / ncy;
+ cx=( q*q*(x2*x2-x1*x1)+p*p*(y2*y2-y1*y1)+cy*2*p*p*(y1-y2) ) / ncx;
+ // Nun brauchen wir noch den Radius in x und y Richtung:
+ r=sqrt(q*q*(x1-cx)*(x1-cx)+p*p*(y1-cy)*(y1-cy));
+ rx=r/q; ry=r/p;
+ // Jetzt stellt sich "nur noch" die Frage, wie Start- und Endpunkt
+ // gewaehlt werden muessen, damit Punkt Nr. 2 innerhalb des
+ // gezeichneten Bogens liegt:
+ w1=fmod((atan2(x1-cx,y1-cy)-atan2(x2-cx,y2-cy)),6.28318530718); if (w1<0) w1+=6.28318530718;
+ w3=fmod((atan2(x3-cx,y3-cy)-atan2(x2-cx,y2-cy)),6.28318530718); if (w3<0) w3+=6.28318530718;
+ if (w3<w1) {
+ pVirDev->DrawArc(Rectangle((long)(cx-rx),(long)(cy-ry),
+ (long)(cx+rx),(long)(cy+ry)),aP1,aP3);
+ }
+ else {
+ pVirDev->DrawArc(Rectangle((long)(cx-rx),(long)(cy-ry),
+ (long)(cx+rx),(long)(cy+ry)),aP3,aP1);
+ }
+}
+
+void OS2METReader::ReadFullArc(BOOL bGivenPos, USHORT nOrderSize)
+{
+ Point aCenter;
+ long nP,nQ,nR,nS;
+ Rectangle aRect;
+ ULONG nMul; USHORT nMulS;
+
+ if (bGivenPos) {
+ aCenter=ReadPoint();
+ if (bCoord32) nOrderSize-=8; else nOrderSize-=4;
+ }
+ else aCenter=aAttr.aCurPos;
+
+ nP=aAttr.nArcP; nQ=aAttr.nArcQ; nR=aAttr.nArcR; nS=aAttr.nArcS;
+ if (nP<0) nP=-nP;
+ if (nQ<0) nQ=-nQ;
+ if (nR<0) nR=-nR;
+ if (nS<0) nS=-nS;
+ if (nOrderSize>=4) *pOS2MET >> nMul;
+ else { *pOS2MET >> nMulS; nMul=((ULONG)nMulS)<<8; }
+ if (nMul!=0x00010000) {
+ nP=(nP*nMul)>>16;
+ nQ=(nQ*nMul)>>16;
+ nR=(nR*nMul)>>16;
+ nS=(nS*nMul)>>16;
+ }
+
+ aRect=Rectangle(aCenter.X()-nP,aCenter.Y()-nQ,
+ aCenter.X()+nP,aCenter.Y()+nQ);
+ aCalcBndRect.Union(aRect);
+
+ if (pAreaStack!=NULL) {
+ ChangeBrush(aAttr.aPatCol,aAttr.aPatBgCol,aAttr.bFill);
+ SetRasterOp(aAttr.ePatMix);
+ if ((pAreaStack->nFlags&0x40)!=0)
+ SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
+ else
+ SetPen( COL_TRANSPARENT, 0, PEN_NULL );
+ }
+ else
+ {
+ SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
+ ChangeBrush(Color( COL_TRANSPARENT ),Color( COL_TRANSPARENT ),FALSE);
+ SetRasterOp(aAttr.eLinMix);
+ }
+ pVirDev->DrawEllipse(aRect);
+}
+
+void OS2METReader::ReadPartialArc(BOOL bGivenPos, USHORT nOrderSize)
+{
+ Point aP0, aCenter,aPStart,aPEnd;
+ long nP,nQ,nR,nS,nStart, nSweep;
+ Rectangle aRect;
+ ULONG nMul; USHORT nMulS;
+ double fStart, fEnd;
+
+ if (bGivenPos) {
+ aP0=ReadPoint();
+ if (bCoord32) nOrderSize-=8; else nOrderSize-=4;
+ }
+ else aP0=aAttr.aCurPos;
+ aCenter=ReadPoint();
+
+ nP=aAttr.nArcP; nQ=aAttr.nArcQ; nR=aAttr.nArcR; nS=aAttr.nArcS;
+ if (nP<0) nP=-nP;
+ if (nQ<0) nQ=-nQ;
+ if (nR<0) nR=-nR;
+ if (nS<0) nS=-nS;
+ if (nOrderSize>=12) *pOS2MET >> nMul;
+ else { *pOS2MET >> nMulS; nMul=((ULONG)nMulS)<<8; }
+ if (nMul!=0x00010000) {
+ nP=(nP*nMul)>>16;
+ nQ=(nQ*nMul)>>16;
+ nR=(nR*nMul)>>16;
+ nS=(nS*nMul)>>16;
+ }
+
+ *pOS2MET >> nStart >> nSweep;
+ fStart=((double)nStart)/65536.0/180.0*3.14159265359;
+ fEnd=fStart+((double)nSweep)/65536.0/180.0*3.14159265359;
+ aPStart=Point(aCenter.X()+(long)( cos(fStart)*nP),
+ aCenter.Y()+(long)(-sin(fStart)*nQ));
+ aPEnd= Point(aCenter.X()+(long)( cos(fEnd)*nP),
+ aCenter.Y()+(long)(-sin(fEnd)*nQ));
+
+ aRect=Rectangle(aCenter.X()-nP,aCenter.Y()-nQ,
+ aCenter.X()+nP,aCenter.Y()+nQ);
+ aCalcBndRect.Union(aRect);
+
+ SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
+ SetRasterOp(aAttr.eLinMix);
+
+ pVirDev->DrawLine(aP0,aPStart);
+ pVirDev->DrawArc(aRect,aPStart,aPEnd);
+ aAttr.aCurPos=aPEnd;
+}
+
+void OS2METReader::ReadPolygons()
+{
+ ULONG i,j,nNumPolys, nNumPoints;
+ PolyPolygon aPolyPoly;
+ Polygon aPoly;
+ Point aPoint;
+ BYTE nFlags;
+
+ *pOS2MET >> nFlags >> nNumPolys;
+ for (i=0; i<nNumPolys; i++) {
+ *pOS2MET >> nNumPoints;
+ if (i==0) nNumPoints++;
+ aPoly.SetSize((short)nNumPoints);
+ for (j=0; j<nNumPoints; j++) {
+ if (i==0 && j==0) aPoint=aAttr.aCurPos;
+ else aPoint=ReadPoint();
+ aPoly.SetPoint(aPoint,(short)j);
+ if (i==nNumPolys-1 && j==nNumPoints-1) aAttr.aCurPos=aPoint;
+ }
+ aPolyPoly.Insert(aPoly);
+ }
+
+ ChangeBrush(aAttr.aPatCol,aAttr.aPatBgCol,aAttr.bFill);
+ SetRasterOp(aAttr.ePatMix);
+ if ((nFlags&0x01)!=0)
+ SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
+ else
+ SetPen( COL_TRANSPARENT, 0, PEN_NULL );
+ DrawPolyPolygon( aPolyPoly );
+}
+
+void OS2METReader::ReadBezier(BOOL bGivenPos, USHORT nOrderLen)
+{
+ USHORT i, nNumPoints = nOrderLen / ( bCoord32 ? 8 : 4 );
+
+ if( !bGivenPos )
+ nNumPoints++;
+
+ if( !nNumPoints )
+ return;
+
+ Polygon aPolygon( nNumPoints );
+
+ for( i=0; i < nNumPoints; i++ )
+ {
+ if( i==0 && !bGivenPos)
+ aPolygon.SetPoint( aAttr.aCurPos, i );
+ else
+ aPolygon.SetPoint( ReadPoint(), i );
+ }
+
+ if( !( nNumPoints % 4 ) )
+ {
+ // create bezier polygon
+ const USHORT nSegPoints = 25;
+ const USHORT nSegments = aPolygon.GetSize() >> 2;
+ Polygon aBezPoly( nSegments * nSegPoints );
+
+ USHORT nSeg, nBezPos, nStartPos;
+ for( nSeg = 0, nBezPos = 0, nStartPos = 0; nSeg < nSegments; nSeg++, nStartPos += 4 )
+ {
+ const Polygon aSegPoly( aPolygon[ nStartPos ], aPolygon[ nStartPos + 1 ],
+ aPolygon[ nStartPos + 3 ], aPolygon[ nStartPos + 2 ],
+ nSegPoints );
+
+ for( USHORT nSegPos = 0; nSegPos < nSegPoints; )
+ aBezPoly[ nBezPos++ ] = aSegPoly[ nSegPos++ ];
+ }
+
+ nNumPoints = nBezPos;
+
+ if( nNumPoints != aBezPoly.GetSize() )
+ aBezPoly.SetSize( nNumPoints );
+
+ aPolygon = aBezPoly;
+ }
+
+ aAttr.aCurPos = aPolygon[ nNumPoints - 1 ];
+
+ if (pAreaStack!=NULL)
+ AddPointsToArea(aPolygon);
+ else if (pPathStack!=NULL)
+ AddPointsToPath(aPolygon);
+ else
+ {
+ SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
+ SetRasterOp(aAttr.eLinMix);
+ DrawPolyLine( aPolygon );
+ }
+}
+
+void OS2METReader::ReadFillet(BOOL bGivenPos, USHORT nOrderLen)
+{
+ USHORT i,nNumPoints;
+
+ if (bCoord32) nNumPoints=nOrderLen/8; else nNumPoints=nOrderLen/4;
+ if (!bGivenPos) nNumPoints++;
+ if (nNumPoints==0) return;
+ Polygon aPolygon(nNumPoints);
+ for (i=0; i<nNumPoints; i++) {
+ if (i==0 && !bGivenPos) aPolygon.SetPoint(aAttr.aCurPos,i);
+ else aPolygon.SetPoint(ReadPoint(),i);
+ }
+ aAttr.aCurPos=aPolygon.GetPoint(nNumPoints-1);
+ if (pAreaStack!=NULL) AddPointsToArea(aPolygon);
+ else if (pPathStack!=NULL) AddPointsToPath(aPolygon);
+ else {
+ SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
+ SetRasterOp(aAttr.eLinMix);
+ DrawPolyLine( aPolygon );
+ }
+}
+
+void OS2METReader::ReadFilletSharp(BOOL bGivenPos, USHORT nOrderLen)
+{
+ USHORT i,nNumPoints;
+
+ if (bGivenPos) {
+ aAttr.aCurPos=ReadPoint();
+ if (bCoord32) nOrderLen-=8; else nOrderLen-=4;
+ }
+ if (bCoord32) nNumPoints=1+nOrderLen/10;
+ else nNumPoints=1+nOrderLen/6;
+ Polygon aPolygon(nNumPoints);
+ aPolygon.SetPoint(aAttr.aCurPos,0);
+ for (i=1; i<nNumPoints; i++) aPolygon.SetPoint(ReadPoint(),i);
+ aAttr.aCurPos=aPolygon.GetPoint(nNumPoints-1);
+ if (pAreaStack!=NULL) AddPointsToArea(aPolygon);
+ else if (pPathStack!=NULL) AddPointsToPath(aPolygon);
+ else
+ {
+ SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
+ SetRasterOp(aAttr.eLinMix);
+ DrawPolyLine( aPolygon );
+ }
+}
+
+void OS2METReader::ReadMarker(BOOL bGivenPos, USHORT nOrderLen)
+{
+ USHORT i,nNumPoints;
+ long x,y;
+
+ SetPen( aAttr.aMrkCol );
+ SetRasterOp(aAttr.eMrkMix);
+ if (aAttr.nMrkSymbol>=5 && aAttr.nMrkSymbol<=9)
+ {
+ ChangeBrush(aAttr.aMrkCol,aAttr.aMrkCol,TRUE);
+ }
+ else
+ {
+ ChangeBrush(Color(COL_TRANSPARENT),Color(COL_TRANSPARENT),FALSE);
+ }
+ if (bCoord32) nNumPoints=nOrderLen/8; else nNumPoints=nOrderLen/4;
+ if (!bGivenPos) nNumPoints++;
+ for (i=0; i<nNumPoints; i++) {
+ if (i!=0 || bGivenPos) aAttr.aCurPos=ReadPoint();
+ x=aAttr.aCurPos.X(); y=aAttr.aCurPos.Y();
+ aCalcBndRect.Union(Rectangle(x-5,y-5,x+5,y+5));
+ switch (aAttr.nMrkSymbol) {
+ case 2: // PLUS
+ pVirDev->DrawLine(Point(x-4,y),Point(x+4,y));
+ pVirDev->DrawLine(Point(x,y-4),Point(x,y+4));
+ break;
+ case 3: // DIAMOND
+ case 7: { // SOLIDDIAMOND
+ Polygon aPoly(4);
+ aPoly.SetPoint(Point(x,y+4),0);
+ aPoly.SetPoint(Point(x+4,y),1);
+ aPoly.SetPoint(Point(x,y-4),2);
+ aPoly.SetPoint(Point(x-4,y),3);
+ pVirDev->DrawPolygon(aPoly);
+ break;
+ }
+ case 4: // SQARE
+ case 8: { // SOLIDSUARE
+ Polygon aPoly(4);
+ aPoly.SetPoint(Point(x+4,y+4),0);
+ aPoly.SetPoint(Point(x+4,y-4),1);
+ aPoly.SetPoint(Point(x-4,y-4),2);
+ aPoly.SetPoint(Point(x-4,y+4),3);
+ pVirDev->DrawPolygon(aPoly);
+ break;
+ }
+ case 5: { // SIXPOINTSTAR
+ Polygon aPoly(12);
+ aPoly.SetPoint(Point(x ,y-4),0);
+ aPoly.SetPoint(Point(x+2,y-2),1);
+ aPoly.SetPoint(Point(x+4,y-2),2);
+ aPoly.SetPoint(Point(x+2,y ),3);
+ aPoly.SetPoint(Point(x+4,y+2),4);
+ aPoly.SetPoint(Point(x+2,y+2),5);
+ aPoly.SetPoint(Point(x ,y+4),6);
+ aPoly.SetPoint(Point(x-2,y+2),7);
+ aPoly.SetPoint(Point(x-4,y+2),8);
+ aPoly.SetPoint(Point(x-2,y ),9);
+ aPoly.SetPoint(Point(x-4,y-2),10);
+ aPoly.SetPoint(Point(x-2,y-2),11);
+ pVirDev->DrawPolygon(aPoly);
+ break;
+ }
+ case 6: { // EIGHTPOINTSTAR
+ Polygon aPoly(16);
+ aPoly.SetPoint(Point(x ,y-4),0);
+ aPoly.SetPoint(Point(x+1,y-2),1);
+ aPoly.SetPoint(Point(x+3,y-3),2);
+ aPoly.SetPoint(Point(x+2,y-1),3);
+ aPoly.SetPoint(Point(x+4,y ),4);
+ aPoly.SetPoint(Point(x+2,y+1),5);
+ aPoly.SetPoint(Point(x+3,y+3),6);
+ aPoly.SetPoint(Point(x+1,y+2),7);
+ aPoly.SetPoint(Point(x ,y+4),8);
+ aPoly.SetPoint(Point(x-1,y+2),9);
+ aPoly.SetPoint(Point(x-3,y+3),10);
+ aPoly.SetPoint(Point(x-2,y+1),11);
+ aPoly.SetPoint(Point(x-4,y ),12);
+ aPoly.SetPoint(Point(x-2,y-1),13);
+ aPoly.SetPoint(Point(x-3,y-3),14);
+ aPoly.SetPoint(Point(x-1,y-2),15);
+ pVirDev->DrawPolygon(aPoly);
+ break;
+ }
+ case 9: // DOT
+ pVirDev->DrawEllipse(Rectangle(x-1,y-1,x+1,y+1));
+ break;
+ case 10: // SMALLCIRCLE
+ pVirDev->DrawEllipse(Rectangle(x-2,y-2,x+2,y+2));
+ break;
+ case 64: // BLANK
+ break;
+ default: // (=1) CROSS
+ pVirDev->DrawLine(Point(x-4,y-4),Point(x+4,y+4));
+ pVirDev->DrawLine(Point(x-4,y+4),Point(x+4,y-4));
+ break;
+ }
+ }
+}
+
+void OS2METReader::ReadOrder(USHORT nOrderID, USHORT nOrderLen)
+{
+ switch (nOrderID) {
+
+ case GOrdGivArc: ReadArc(TRUE); break;
+ case GOrdCurArc: ReadArc(FALSE); break;
+
+ case GOrdGivBzr: ReadBezier(TRUE,nOrderLen); break;
+ case GOrdCurBzr: ReadBezier(FALSE,nOrderLen); break;
+
+ case GOrdGivBox: ReadBox(TRUE); break;
+ case GOrdCurBox: ReadBox(FALSE); break;
+
+ case GOrdGivFil: ReadFillet(TRUE,nOrderLen); break;
+ case GOrdCurFil: ReadFillet(FALSE,nOrderLen); break;
+
+ case GOrdGivCrc: ReadFullArc(TRUE,nOrderLen); break;
+ case GOrdCurCrc: ReadFullArc(FALSE,nOrderLen); break;
+
+ case GOrdGivLin: ReadLine(TRUE, nOrderLen); break;
+ case GOrdCurLin: ReadLine(FALSE, nOrderLen); break;
+
+ case GOrdGivMrk: ReadMarker(TRUE, nOrderLen); break;
+ case GOrdCurMrk: ReadMarker(FALSE, nOrderLen); break;
+
+ case GOrdGivArP: ReadPartialArc(TRUE,nOrderLen); break;
+ case GOrdCurArP: ReadPartialArc(FALSE,nOrderLen); break;
+
+ case GOrdGivRLn: ReadRelLine(TRUE,nOrderLen); break;
+ case GOrdCurRLn: ReadRelLine(FALSE,nOrderLen); break;
+
+ case GOrdGivSFl: ReadFilletSharp(TRUE,nOrderLen); break;
+ case GOrdCurSFl: ReadFilletSharp(FALSE,nOrderLen); break;
+
+ case GOrdGivStM: ReadChrStr(TRUE , TRUE , FALSE, nOrderLen); break;
+ case GOrdCurStM: ReadChrStr(FALSE, TRUE , FALSE, nOrderLen); break;
+ case GOrdGivStr: ReadChrStr(TRUE , FALSE, FALSE, nOrderLen); break;
+ case GOrdCurStr: ReadChrStr(FALSE, FALSE, FALSE, nOrderLen); break;
+ case GOrdGivStx: ReadChrStr(TRUE , FALSE, TRUE , nOrderLen); break;
+ case GOrdCurStx: ReadChrStr(FALSE, FALSE, TRUE , nOrderLen); break;
+
+ case GOrdGivImg: OOODEBUG("GOrdGivImg",0);
+ break;
+ case GOrdCurImg: OOODEBUG("GOrdCurImg",0);
+ break;
+ case GOrdImgDat: OOODEBUG("GOrdImgDat",0);
+ break;
+ case GOrdEndImg: OOODEBUG("GOrdEndImg",0);
+ break;
+
+ case GOrdBegAra: {
+ OSArea * p=new OSArea;
+ p->bClosed=FALSE;
+ p->pSucc=pAreaStack; pAreaStack=p;
+ *pOS2MET >> (p->nFlags);
+ p->aCol=aAttr.aPatCol;
+ p->aBgCol=aAttr.aPatBgCol;
+ p->eMix=aAttr.ePatMix;
+ p->eBgMix=aAttr.ePatBgMix;
+ p->bFill=aAttr.bFill;
+ break;
+ }
+ case GOrdEndAra:
+ {
+ OSArea * p=pAreaStack;
+ if ( p )
+ {
+ pAreaStack = p->pSucc;
+ if ( pPathStack )
+ {
+ for ( USHORT i=0; i<p->aPPoly.Count(); i++ )
+ {
+ AddPointsToPath( p->aPPoly.GetObject( i ) );
+ CloseFigure();
+ }
+ }
+ else
+ {
+ if ( ( p->nFlags & 0x40 ) == 0 )
+ SetPen( COL_TRANSPARENT, 0, PEN_NULL );
+ else
+ SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
+
+ ChangeBrush(p->aCol,p->aBgCol,p->bFill);
+ SetRasterOp(p->eMix);
+ DrawPolyPolygon( p->aPPoly );
+ }
+ delete p;
+ }
+ }
+ break;
+
+ case GOrdBegElm:// OOODEBUG("GOrdBegElm",0);
+ break;
+ case GOrdEndElm:// OOODEBUG("GOrdEndElm",0);
+ break;
+
+ case GOrdBegPth: {
+ OSPath * p=new OSPath;
+ p->pSucc=pPathStack; pPathStack=p;
+ pOS2MET->SeekRel(2);
+ *pOS2MET >> p->nID;
+ p->bClosed=FALSE;
+ p->bStroke=FALSE;
+ break;
+ }
+ case GOrdEndPth: {
+ OSPath * p, * pprev, * psucc;
+ if (pPathStack==NULL) break;
+ p=pPathList; pprev=NULL;
+ while (p!=NULL) {
+ psucc=p->pSucc;
+ if (p->nID==pPathStack->nID) {
+ if (pprev==NULL) pPathList=psucc; else pprev->pSucc=psucc;
+ delete p;
+ }
+ else pprev=p;
+ p=psucc;
+ }
+ p=pPathStack;
+ pPathStack=p->pSucc;
+ p->pSucc=pPathList; pPathList=p;
+ break;
+ }
+ case GOrdFilPth:
+ {
+ ULONG nID;
+ UINT16 nDummy;
+ OSPath* p = pPathList;
+
+ *pOS2MET >> nDummy
+ >> nID;
+
+ if ( ! ( nDummy & 0x20 ) ) // #30933# i do not know the exact meaning of this bit,
+ { // but if set it seems to be better not to fill this path
+ while( p && p->nID != nID )
+ p = p->pSucc;
+
+ if( p )
+ {
+ if( p->bStroke )
+ {
+ SetPen( aAttr.aPatCol, aAttr.nStrLinWidth, PEN_SOLID );
+ ChangeBrush(Color(COL_TRANSPARENT),Color(COL_TRANSPARENT),FALSE);
+ SetRasterOp( aAttr.ePatMix );
+ if ( IsLineInfo() )
+ {
+ for ( USHORT i = 0; i < p->aPPoly.Count(); i++ )
+ pVirDev->DrawPolyLine( p->aPPoly.GetObject( i ), aLineInfo );
+ }
+ else
+ pVirDev->DrawPolyPolygon( p->aPPoly );
+ }
+ else
+ {
+ SetPen( COL_TRANSPARENT, 0, PEN_NULL );
+ ChangeBrush( aAttr.aPatCol, aAttr.aPatBgCol, aAttr.bFill );
+ SetRasterOp( aAttr.ePatMix );
+ pVirDev->DrawPolyPolygon( p->aPPoly );
+ }
+ }
+ }
+ }
+ break;
+
+ case GOrdModPth:
+ {
+ OSPath* p = pPathList;
+
+ while( p && p->nID != 1 )
+ p = p->pSucc;
+
+ if( p )
+ p->bStroke = TRUE;
+ }
+ break;
+
+ case GOrdOutPth:
+ {
+ ULONG nID;
+ USHORT i,nC;
+ OSPath* p=pPathList;
+ pOS2MET->SeekRel(2);
+ *pOS2MET >> nID;
+ while (p!=NULL && p->nID!=nID)
+ p=p->pSucc;
+
+ if( p!=NULL )
+ {
+ SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
+ SetRasterOp(aAttr.eLinMix);
+ ChangeBrush(Color(COL_TRANSPARENT),Color(COL_TRANSPARENT),FALSE);
+ nC=p->aPPoly.Count();
+ for (i=0; i<nC; i++)
+ {
+ if (i+1<nC || p->bClosed==TRUE)
+ DrawPolygon( p->aPPoly.GetObject( i ) );
+ else
+ DrawPolyLine( p->aPPoly.GetObject( i ) );
+ }
+ }
+ break;
+ }
+ case GOrdSClPth: { OOODEBUG("GOrdSClPth",0);
+ ULONG nID;
+ OSPath * p=pPathList;
+ pOS2MET->SeekRel(2);
+ *pOS2MET >> nID;
+ if (nID==0) p=NULL;
+ while (p!=NULL && p->nID!=nID) p=p->pSucc;
+ if (p!=NULL) pVirDev->SetClipRegion(Region(p->aPPoly));
+ else pVirDev->SetClipRegion();
+ break;
+ }
+ case GOrdNopNop:
+ break;
+ case GOrdRemark: //OOODEBUG("GOrdRemark",0);
+ break;
+ case GOrdSegLab: OOODEBUG("GOrdSegLab",0);
+ break;
+
+ case GOrdBitBlt: ReadBitBlt(); break;
+
+ case GOrdCalSeg: OOODEBUG("GOrdCalSeg",0);
+ break;
+ case GOrdSSgBnd: OOODEBUG("GOrdSSgBnd",0);
+ break;
+ case GOrdSegChr: OOODEBUG("GOrdSegChr",0);
+ break;
+ case GOrdCloFig:
+ CloseFigure();
+ break;
+ case GOrdEndSym: OOODEBUG("GOrdEndSym",0);
+ break;
+ case GOrdEndPlg: OOODEBUG("GOrdEndPlg",0);
+ break;
+ case GOrdEscape: OOODEBUG("GOrdEscape",0);
+ break;
+ case GOrdExtEsc: OOODEBUG("GOrdExtEsc",0);
+ break;
+
+ case GOrdPolygn: ReadPolygons(); break;
+
+ case GOrdStkPop: PopAttr(); break;
+
+ case GOrdPIvAtr: PushAttr(nOrderID);
+ case GOrdSIvAtr: {
+ BYTE nA, nP, nFlags, nMix;
+ ULONG nVal;
+ Color aCol;
+ RasterOp eROP;
+ *pOS2MET >> nA >> nP >> nFlags;
+ if (nOrderID==GOrdPIvAtr) {
+ pAttrStack->nIvAttrA=nA;
+ pAttrStack->nIvAttrP=nP;
+ }
+ if (nA<=2) {
+ if ((nFlags&0x80)!=0) {
+ if (nA==1) switch (nP) {
+ case 1: aAttr.aLinCol=aDefAttr.aLinCol; break;
+ case 2: aAttr.aChrCol=aDefAttr.aChrCol; break;
+ case 3: aAttr.aMrkCol=aDefAttr.aMrkCol; break;
+ case 4: aAttr.aPatCol=aDefAttr.aPatCol; break;
+ case 5: aAttr.aImgCol=aDefAttr.aImgCol; break;
+ }
+ else switch (nP) {
+ case 1: aAttr.aLinBgCol=aDefAttr.aLinBgCol; break;
+ case 2: aAttr.aChrBgCol=aDefAttr.aChrBgCol; break;
+ case 3: aAttr.aMrkBgCol=aDefAttr.aMrkBgCol; break;
+ case 4: aAttr.aPatBgCol=aDefAttr.aPatBgCol; break;
+ case 5: aAttr.aImgBgCol=aDefAttr.aImgBgCol; break;
+ }
+ }
+ else {
+ nVal=ReadLittleEndian3BytesLong();
+ if ((nFlags&0x40)!=0 && nVal==1) aCol=Color(COL_BLACK);
+ else if ((nFlags&0x40)!=0 && nVal==2) aCol=Color(COL_WHITE);
+ else if ((nFlags&0x40)!=0 && nVal==4) aCol=Color(COL_WHITE);
+ else if ((nFlags&0x40)!=0 && nVal==5) aCol=Color(COL_BLACK);
+ else aCol=GetPaletteColor(nVal);
+ if (nA==1) switch (nP) {
+ case 1: aAttr.aLinCol=aCol; break;
+ case 2: aAttr.aChrCol=aCol; break;
+ case 3: aAttr.aMrkCol=aCol; break;
+ case 4: aAttr.aPatCol=aCol; break;
+ case 5: aAttr.aImgCol=aCol; break;
+ }
+ else switch (nP) {
+ case 1: aAttr.aLinBgCol=aCol; break;
+ case 2: aAttr.aChrBgCol=aCol; break;
+ case 3: aAttr.aMrkBgCol=aCol; break;
+ case 4: aAttr.aPatBgCol=aCol; break;
+ case 5: aAttr.aImgBgCol=aCol; break;
+ }
+ }
+ }
+ else {
+ *pOS2MET >> nMix;
+ if (nMix==0) {
+ if (nA==1) switch (nP) {
+ case 1: aAttr.eLinMix=aDefAttr.eLinMix; break;
+ case 2: aAttr.eChrMix=aDefAttr.eChrMix; break;
+ case 3: aAttr.eMrkMix=aDefAttr.eMrkMix; break;
+ case 4: aAttr.ePatMix=aDefAttr.ePatMix; break;
+ case 5: aAttr.eImgMix=aDefAttr.eImgMix; break;
+ }
+ else switch (nP) {
+ case 1: aAttr.eLinBgMix=aDefAttr.eLinBgMix; break;
+ case 2: aAttr.eChrBgMix=aDefAttr.eChrBgMix; break;
+ case 3: aAttr.eMrkBgMix=aDefAttr.eMrkBgMix; break;
+ case 4: aAttr.ePatBgMix=aDefAttr.ePatBgMix; break;
+ case 5: aAttr.eImgBgMix=aDefAttr.eImgBgMix; break;
+ }
+ }
+ else {
+ eROP=OS2MixToRasterOp(nMix);
+ if (nA==1) switch (nP) {
+ case 1: aAttr.eLinMix=eROP; break;
+ case 2: aAttr.eChrMix=eROP; break;
+ case 3: aAttr.eMrkMix=eROP; break;
+ case 4: aAttr.ePatMix=eROP; break;
+ case 5: aAttr.eImgMix=eROP; break;
+ }
+ else switch (nP) {
+ case 1: aAttr.eLinBgMix=eROP; break;
+ case 2: aAttr.eChrBgMix=eROP; break;
+ case 3: aAttr.eMrkBgMix=eROP; break;
+ case 4: aAttr.ePatBgMix=eROP; break;
+ case 5: aAttr.eImgBgMix=eROP; break;
+ }
+ }
+ }
+ break;
+ }
+ case GOrdPIxCol: PushAttr(nOrderID);
+ case GOrdSIxCol: {
+ BYTE nFlags;
+ ULONG nVal;
+ Color aCol;
+ *pOS2MET >> nFlags;
+ if ((nFlags&0x80)!=0) {
+ aAttr.aLinCol=aDefAttr.aLinCol;
+ aAttr.aChrCol=aDefAttr.aChrCol;
+ aAttr.aMrkCol=aDefAttr.aMrkCol;
+ aAttr.aPatCol=aDefAttr.aPatCol;
+ aAttr.aImgCol=aDefAttr.aImgCol;
+ }
+ else {
+ nVal=ReadLittleEndian3BytesLong();
+ if ((nFlags&0x40)!=0 && nVal==1) aCol=Color(COL_BLACK);
+ else if ((nFlags&0x40)!=0 && nVal==2) aCol=Color(COL_WHITE);
+ else if ((nFlags&0x40)!=0 && nVal==4) aCol=Color(COL_WHITE);
+ else if ((nFlags&0x40)!=0 && nVal==5) aCol=Color(COL_BLACK);
+ else aCol=GetPaletteColor(nVal);
+ aAttr.aLinCol = aAttr.aChrCol = aAttr.aMrkCol = aAttr.aPatCol =
+ aAttr.aImgCol = aCol;
+ }
+ break;
+ }
+
+ case GOrdPColor:
+ case GOrdPXtCol: PushAttr(nOrderID);
+ case GOrdSColor:
+ case GOrdSXtCol: {
+ BYTE nbyte;
+ USHORT nVal;
+ Color aCol;
+ if (nOrderID==GOrdPColor || nOrderID==GOrdSColor) {
+ *pOS2MET >> nbyte; nVal=((USHORT)nbyte)|0xff00;
+ }
+ else *pOS2MET >> nVal;
+ if (nVal==0x0000 || nVal==0xff00) {
+ aAttr.aLinCol=aDefAttr.aLinCol;
+ aAttr.aChrCol=aDefAttr.aChrCol;
+ aAttr.aMrkCol=aDefAttr.aMrkCol;
+ aAttr.aPatCol=aDefAttr.aPatCol;
+ aAttr.aImgCol=aDefAttr.aImgCol;
+ }
+ else {
+ if (nVal==0x0007) aCol=Color(COL_WHITE);
+ else if (nVal==0x0008) aCol=Color(COL_BLACK);
+ else if (nVal==0xff08) aCol=GetPaletteColor(1);
+ else aCol=GetPaletteColor(((ULONG)nVal) & 0x000000ff);
+ aAttr.aLinCol = aAttr.aChrCol = aAttr.aMrkCol = aAttr.aPatCol =
+ aAttr.aImgCol = aCol;
+ }
+ break;
+ }
+
+ case GOrdPBgCol: PushAttr(nOrderID);
+ case GOrdSBgCol: {
+ USHORT nVal;
+ Color aCol;
+ *pOS2MET >> nVal;
+ if (nVal==0x0000 || nVal==0xff00) {
+ aAttr.aLinBgCol=aDefAttr.aLinBgCol;
+ aAttr.aChrBgCol=aDefAttr.aChrBgCol;
+ aAttr.aMrkBgCol=aDefAttr.aMrkBgCol;
+ aAttr.aPatBgCol=aDefAttr.aPatBgCol;
+ aAttr.aImgBgCol=aDefAttr.aImgBgCol;
+ }
+ else {
+ if (nVal==0x0007) aCol=Color(COL_WHITE);
+ else if (nVal==0x0008) aCol=Color(COL_BLACK);
+ else if (nVal==0xff08) aCol=GetPaletteColor(0);
+ else aCol=GetPaletteColor(((ULONG)nVal) & 0x000000ff);
+ aAttr.aLinBgCol = aAttr.aChrBgCol = aAttr.aMrkBgCol =
+ aAttr.aPatBgCol = aAttr.aImgBgCol = aCol;
+ }
+ break;
+ }
+ case GOrdPBxCol: PushAttr(nOrderID);
+ case GOrdSBxCol: {
+ BYTE nFlags;
+ ULONG nVal;
+ Color aCol;
+ *pOS2MET >> nFlags;
+ if ((nFlags&0x80)!=0) {
+ aAttr.aLinBgCol=aDefAttr.aLinBgCol;
+ aAttr.aChrBgCol=aDefAttr.aChrBgCol;
+ aAttr.aMrkBgCol=aDefAttr.aMrkBgCol;
+ aAttr.aPatBgCol=aDefAttr.aPatBgCol;
+ aAttr.aImgBgCol=aDefAttr.aImgBgCol;
+ }
+ else {
+ nVal=ReadLittleEndian3BytesLong();
+ if ((nFlags&0x40)!=0 && nVal==1) aCol=Color(COL_BLACK);
+ else if ((nFlags&0x40)!=0 && nVal==2) aCol=Color(COL_WHITE);
+ else if ((nFlags&0x40)!=0 && nVal==4) aCol=Color(COL_WHITE);
+ else if ((nFlags&0x40)!=0 && nVal==5) aCol=Color(COL_BLACK);
+ else aCol=GetPaletteColor(nVal);
+ aAttr.aLinBgCol = aAttr.aChrBgCol = aAttr.aMrkBgCol =
+ aAttr.aPatBgCol = aAttr.aImgBgCol = aCol;
+ }
+ break;
+ }
+
+ case GOrdPMixMd: PushAttr(nOrderID);
+ case GOrdSMixMd: {
+ BYTE nMix;
+ *pOS2MET >> nMix;
+ if (nMix==0) {
+ aAttr.eLinMix=aDefAttr.eLinMix;
+ aAttr.eChrMix=aDefAttr.eChrMix;
+ aAttr.eMrkMix=aDefAttr.eMrkMix;
+ aAttr.ePatMix=aDefAttr.ePatMix;
+ aAttr.eImgMix=aDefAttr.eImgMix;
+ }
+ else {
+ aAttr.eLinMix = aAttr.eChrMix = aAttr.eMrkMix =
+ aAttr.ePatMix = aAttr.eImgMix = OS2MixToRasterOp(nMix);
+ }
+ break;
+ }
+ case GOrdPBgMix: PushAttr(nOrderID);
+ case GOrdSBgMix: {
+ BYTE nMix;
+ *pOS2MET >> nMix;
+ if (nMix==0) {
+ aAttr.eLinBgMix=aDefAttr.eLinBgMix;
+ aAttr.eChrBgMix=aDefAttr.eChrBgMix;
+ aAttr.eMrkBgMix=aDefAttr.eMrkBgMix;
+ aAttr.ePatBgMix=aDefAttr.ePatBgMix;
+ aAttr.eImgBgMix=aDefAttr.eImgBgMix;
+ }
+ else {
+ aAttr.eLinBgMix = aAttr.eChrBgMix = aAttr.eMrkBgMix =
+ aAttr.ePatBgMix = aAttr.eImgBgMix = OS2MixToRasterOp(nMix);
+ }
+ break;
+ }
+ case GOrdPPtSet: PushAttr(nOrderID);
+ case GOrdSPtSet: OOODEBUG("GOrdSPtSet",0);
+ break;
+
+ case GOrdPPtSym: PushAttr(nOrderID);
+ case GOrdSPtSym: {
+ BYTE nPatt;
+ *pOS2MET >> nPatt;
+ aAttr.bFill = ( nPatt != 0x0f );
+ break;
+ }
+
+ case GOrdPPtRef: PushAttr(nOrderID);
+ case GOrdSPtRef: OOODEBUG("GOrdSPtRef",0);
+ break;
+
+ case GOrdPLnEnd: PushAttr(nOrderID);
+ case GOrdSLnEnd:
+ break;
+
+ case GOrdPLnJoi: PushAttr(nOrderID);
+ case GOrdSLnJoi:
+ break;
+
+ case GOrdPLnTyp: PushAttr(nOrderID);
+ case GOrdSLnTyp: {
+ BYTE nType;
+ *pOS2MET >> nType;
+ switch (nType) {
+ case 0: aAttr.eLinStyle=aDefAttr.eLinStyle; break;
+ case 1: case 4: aAttr.eLinStyle=PEN_DOT; break;
+ case 2: case 5: aAttr.eLinStyle=PEN_DASH; break;
+ case 3: case 6: aAttr.eLinStyle=PEN_DASHDOT; break;
+ case 8: aAttr.eLinStyle=PEN_NULL; break;
+ default: aAttr.eLinStyle=PEN_SOLID;
+ }
+ break;
+ }
+ case GOrdPLnWdt: PushAttr(nOrderID);
+ case GOrdSLnWdt: {
+ BYTE nbyte;
+ *pOS2MET >> nbyte;
+ if (nbyte==0) aAttr.nLinWidth=aDefAttr.nLinWidth;
+ else aAttr.nLinWidth=(USHORT)nbyte-1;
+ break;
+ }
+ case GOrdPFrLWd: PushAttr(nOrderID);
+ case GOrdSFrLWd:
+ break;
+
+ case GOrdPStLWd: PushAttr(nOrderID);
+ case GOrdSStLWd :
+ {
+ BYTE nFlags;
+ long nWd;
+
+ *pOS2MET >> nFlags;
+ if ( nFlags & 0x80 )
+ aAttr.nStrLinWidth = aDefAttr.nStrLinWidth;
+ else
+ {
+ pOS2MET->SeekRel( 1 );
+ nWd = ReadCoord( bCoord32 );
+ if ( nWd < 0 )
+ nWd = -nWd;
+ aAttr.nStrLinWidth = (USHORT)nWd;
+ }
+ break;
+ }
+ case GOrdPChDir: PushAttr(nOrderID);
+ case GOrdSChDir:
+ break;
+
+ case GOrdPChPrc: PushAttr(nOrderID);
+ case GOrdSChPrc:
+ break;
+
+ case GOrdPChSet: PushAttr(nOrderID);
+ case GOrdSChSet: {
+ BYTE nbyte; *pOS2MET >> nbyte;
+ aAttr.nChrSet=((ULONG)nbyte)&0xff;
+ break;
+ }
+ case GOrdPChAng: PushAttr(nOrderID);
+ case GOrdSChAng: {
+ long nX,nY;
+ nX=ReadCoord(bCoord32); nY=ReadCoord(bCoord32);
+ if (nX>=0 && nY==0) aAttr.nChrAng=0;
+ else {
+ aAttr.nChrAng=(short)(atan2((double)nY,(double)nX)/3.1415926539*1800.0);
+ while (aAttr.nChrAng<0) aAttr.nChrAng+=3600;
+ aAttr.nChrAng%=3600;
+ }
+ break;
+ }
+ case GOrdPChBrx: PushAttr(nOrderID);
+ case GOrdSChBrx:
+ break;
+
+ case GOrdPChCel: PushAttr(nOrderID);
+ case GOrdSChCel: {
+ BYTE nbyte;
+ USHORT nLen=nOrderLen;
+ aAttr.aChrCellSize.Width()=ReadCoord(bCoord32);
+ aAttr.aChrCellSize.Height()=ReadCoord(bCoord32);
+ if (bCoord32) nLen-=8; else nLen-=4;
+ if (nLen>=4) {
+ pOS2MET->SeekRel(4); nLen-=4;
+ }
+ if (nLen>=2) {
+ *pOS2MET >> nbyte;
+ if ((nbyte&0x80)==0 && aAttr.aChrCellSize==Size(0,0))
+ aAttr.aChrCellSize=aDefAttr.aChrCellSize;
+ }
+ break;
+ }
+ case GOrdPChXtr: PushAttr(nOrderID);
+ case GOrdSChXtr:
+ break;
+
+ case GOrdPChShr: PushAttr(nOrderID);
+ case GOrdSChShr:
+ break;
+
+ case GOrdPTxAlg: PushAttr(nOrderID);
+ case GOrdSTxAlg: OOODEBUG("GOrdSTxAlg",0);
+ break;
+
+ case GOrdPMkPrc: PushAttr(nOrderID);
+ case GOrdSMkPrc: {
+ BYTE nbyte;
+ *pOS2MET >> nbyte;
+ if (nbyte==0) aAttr.nMrkPrec=aDefAttr.nMrkPrec;
+ else aAttr.nMrkPrec=nbyte;
+ break;
+ }
+
+ case GOrdPMkSet: PushAttr(nOrderID);
+ case GOrdSMkSet: {
+ BYTE nbyte;
+ *pOS2MET >> nbyte;
+ if (nbyte==0) aAttr.nMrkSet=aDefAttr.nMrkSet;
+ else aAttr.nMrkSet=nbyte;
+ break;
+ }
+
+ case GOrdPMkSym: PushAttr(nOrderID);
+ case GOrdSMkSym: {
+ BYTE nbyte;
+ *pOS2MET >> nbyte;
+ if (nbyte==0) aAttr.nMrkSymbol=aDefAttr.nMrkSymbol;
+ else aAttr.nMrkSymbol=nbyte;
+ break;
+ }
+
+ case GOrdPMkCel: PushAttr(nOrderID);
+ case GOrdSMkCel: {
+ BYTE nbyte;
+ USHORT nLen=nOrderLen;
+ aAttr.aMrkCellSize.Width()=ReadCoord(bCoord32);
+ aAttr.aMrkCellSize.Height()=ReadCoord(bCoord32);
+ if (bCoord32) nLen-=8; else nLen-=4;
+ if (nLen>=2) {
+ *pOS2MET >> nbyte;
+ if ((nbyte&0x80)==0 && aAttr.aMrkCellSize==Size(0,0))
+ aAttr.aMrkCellSize=aDefAttr.aMrkCellSize;
+ }
+ break;
+ }
+
+ case GOrdPArcPa: PushAttr(nOrderID);
+ case GOrdSArcPa:
+ aAttr.nArcP=ReadCoord(bCoord32);
+ aAttr.nArcQ=ReadCoord(bCoord32);
+ aAttr.nArcR=ReadCoord(bCoord32);
+ aAttr.nArcS=ReadCoord(bCoord32);
+ break;
+
+ case GOrdPCrPos: PushAttr(nOrderID);
+ case GOrdSCrPos:
+ aAttr.aCurPos=ReadPoint();
+ break;
+
+ case GOrdPMdTrn: PushAttr(nOrderID);
+ case GOrdSMdTrn: OOODEBUG("GOrdSMdTrn",0);
+ break;
+
+ case GOrdPPkIdn: PushAttr(nOrderID);
+ case GOrdSPkIdn: OOODEBUG("GOrdSPkIdn",0);
+ break;
+
+ case GOrdSVwTrn: OOODEBUG("GOrdSVwTrn",0);
+ break;
+
+ case GOrdPVwWin: PushAttr(nOrderID);
+ case GOrdSVwWin: OOODEBUG("GOrdSVwWin",0);
+ break;
+ default: OOODEBUG("Order unbekannt:",nOrderID);
+ }
+}
+
+void OS2METReader::ReadDsc(USHORT nDscID, USHORT /*nDscLen*/)
+{
+ switch (nDscID) {
+ case 0x00f7: { // 'Specify GVM Subset'
+ BYTE nbyte;
+ pOS2MET->SeekRel(6);
+ *pOS2MET >> nbyte;
+ if (nbyte==0x05) bCoord32=TRUE;
+ else if (nbyte==0x04) bCoord32=FALSE;
+ else {
+ pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ ErrorCode=1;
+ }
+ break;
+ }
+ case 0x00f6:
+ {
+ // 'Set Picture Descriptor'
+ BOOL b32;
+ BYTE nbyte,nUnitType;
+ long x1,y1,x2,y2,nt,xr,yr;
+
+ pOS2MET->SeekRel(2);
+ *pOS2MET >> nbyte;
+
+ if (nbyte==0x05)
+ b32=TRUE;
+ else if(nbyte==0x04)
+ b32=FALSE;
+ else
+ {
+ pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ ErrorCode=2;
+ }
+
+ *pOS2MET >> nUnitType;
+
+ xr=ReadCoord(b32);
+ yr=ReadCoord(b32);
+
+ ReadCoord(b32);
+
+ if (nUnitType==0x00 && xr>0 && yr>0)
+ aGlobMapMode=MapMode(MAP_INCH,Point(0,0),Fraction(10,xr),Fraction(10,yr));
+ else if (nUnitType==0x01 && xr>0 && yr>0)
+ aGlobMapMode=MapMode(MAP_CM,Point(0,0),Fraction(10,xr),Fraction(10,yr));
+ else
+ aGlobMapMode=MapMode();
+
+ x1=ReadCoord(b32);
+ x2=ReadCoord(b32);
+ y1=ReadCoord(b32);
+ y2=ReadCoord(b32);
+
+ if (x1>x2)
+ {
+ nt=x1;
+ x1=x2;
+ x2=nt;
+ }
+
+ if (y1>y2)
+ {
+ nt=y1;
+ y1=y2;
+ y2=nt;
+ }
+
+ aBoundingRect.Left() = x1;
+ aBoundingRect.Right() = x2;
+ aBoundingRect.Top() = y1;
+ aBoundingRect.Bottom() = y2;
+
+ // no output beside this bounding rect
+ pVirDev->IntersectClipRegion( Rectangle( Point(), aBoundingRect.GetSize() ) );
+
+ break;
+ }
+ case 0x0021: // 'Set Current Defaults'
+ break;
+ }
+}
+
+void OS2METReader::ReadImageData(USHORT nDataID, USHORT nDataLen)
+{
+ OSBitmap * p=pBitmapList; if (p==NULL) return; // Nanu ?
+
+ switch (nDataID) {
+
+ case 0x0070: // Begin Segment
+ break;
+
+ case 0x0091: // Begin Image Content
+ break;
+
+ case 0x0094: // Image Size
+ pOS2MET->SeekRel(5);
+ p->nHeight=ReadBigEndianWord();
+ p->nWidth=ReadBigEndianWord();
+ break;
+
+ case 0x0095: // Image Encoding
+ break;
+
+ case 0x0096: { // Image IDE-Size
+ BYTE nbyte;
+ *pOS2MET >> nbyte; p->nBitsPerPixel=nbyte;
+ break;
+ }
+
+ case 0x0097: // Image LUT-ID
+ break;
+
+ case 0x009b: // IDE Structure
+ break;
+
+ case 0xfe92: { // Image Data
+ // Spaetestens jetzt brauchen wir die temporaere BMP-Datei
+ // und darin mindestens den Header + Palette.
+ if (p->pBMP==NULL) {
+ p->pBMP=new SvMemoryStream();
+ p->pBMP->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
+ if (p->nWidth==0 || p->nHeight==0 || p->nBitsPerPixel==0) {
+ pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ ErrorCode=3;
+ return;
+ }
+ // Schreibe (Windows-)BITMAPINFOHEADER:
+ *(p->pBMP) << ((ULONG)40) << p->nWidth << p->nHeight;
+ *(p->pBMP) << ((USHORT)1) << p->nBitsPerPixel;
+ *(p->pBMP) << ((ULONG)0) << ((ULONG)0) << ((ULONG)0) << ((ULONG)0);
+ *(p->pBMP) << ((ULONG)0) << ((ULONG)0);
+ // Schreibe Farbtabelle:
+ if (p->nBitsPerPixel<=8) {
+ USHORT i, nColTabSize=1<<(p->nBitsPerPixel);
+ for (i=0; i<nColTabSize; i++) *(p->pBMP) << GetPalette0RGB(i);
+ }
+ }
+ // OK, nun werden die Map-Daten ruebergeschoben. Leider haben OS2 und
+ // BMP eine unterschiedliche Reihenfolge von RGB bei 24-Bit.
+ BYTE * pBuf=new BYTE[nDataLen];
+ pOS2MET->Read(pBuf,nDataLen);
+ if (p->nBitsPerPixel==24) {
+ ULONG i, j, nAlign, nBytesPerLine;
+ BYTE nTemp;
+ nBytesPerLine=(p->nWidth*3+3)&0xfffffffc;
+ nAlign=p->nMapPos-(p->nMapPos % nBytesPerLine);
+ i=0;
+ while (nAlign+i+2<p->nMapPos+nDataLen) {
+ if (nAlign+i>=p->nMapPos) {
+ j=nAlign+i-p->nMapPos;
+ nTemp=pBuf[j]; pBuf[j]=pBuf[j+2]; pBuf[j+2]=nTemp;
+ }
+ i+=3; if (i+2>=nBytesPerLine) {
+ nAlign+=nBytesPerLine;
+ i=0;
+ }
+ }
+ }
+ p->pBMP->Write(pBuf,nDataLen);
+ p->nMapPos+=nDataLen;
+ delete pBuf;
+ break;
+ }
+ case 0x0093: // End Image Content
+ break;
+
+ case 0x0071: // End Segment
+ break;
+ }
+}
+
+void OS2METReader::ReadFont(USHORT nFieldSize)
+{
+ ULONG nPos, nMaxPos;
+ USHORT nLen,i;
+ BYTE nbyte, nTripType, nTripType2;
+ OSFont * pF=new OSFont;
+ pF->pSucc=pFontList; pFontList=pF;
+ pF->nID=0;
+ pF->aFont.SetTransparent(TRUE);
+ pF->aFont.SetAlign(ALIGN_BASELINE);
+
+ nPos=pOS2MET->Tell();
+ nMaxPos=nPos+(ULONG)nFieldSize;
+ pOS2MET->SeekRel(2); nPos+=2;
+ while (nPos<nMaxPos && pOS2MET->GetError()==0) {
+ *pOS2MET >> nbyte; nLen =((USHORT)nbyte) & 0x00ff;
+ *pOS2MET >> nTripType;
+ switch (nTripType) {
+ case 0x02:
+ *pOS2MET >> nTripType2;
+ switch (nTripType2) {
+ case 0x84: // Font name
+ break;
+ case 0x08: { // Font Typeface
+ char str[33];
+ String aStr;
+ pOS2MET->SeekRel(1);
+ for (i=0; i<32; i++) *pOS2MET >> str[i];
+ str[32]=0;
+ aStr = String::CreateFromAscii( str );
+ if ( aStr.CompareIgnoreCaseToAscii( "Helv" ) == COMPARE_EQUAL )
+ aStr = String::CreateFromAscii( "Helvetica" );
+ pF->aFont.SetName( aStr );
+ break;
+ }
+ }
+ break;
+ case 0x24: // Icid
+ *pOS2MET >> nTripType2;
+ switch (nTripType2) {
+ case 0x05: //Icid
+ *pOS2MET >> nbyte;
+ pF->nID=((ULONG)nbyte)&0xff;
+ break;
+ }
+ break;
+ case 0x20: // Font Binary GCID
+ break;
+ case 0x1f: { // Font Attributes
+ FontWeight eWeight;
+ BYTE nbyte;
+ *pOS2MET >> nbyte;
+ switch (nbyte) {
+ case 1: eWeight=WEIGHT_THIN; break;
+ case 2: eWeight=WEIGHT_ULTRALIGHT; break;
+ case 3: eWeight=WEIGHT_LIGHT; break;
+ case 4: eWeight=WEIGHT_SEMILIGHT; break;
+ case 5: eWeight=WEIGHT_NORMAL; break;
+ case 6: eWeight=WEIGHT_SEMIBOLD; break;
+ case 7: eWeight=WEIGHT_BOLD; break;
+ case 8: eWeight=WEIGHT_ULTRABOLD; break;
+ case 9: eWeight=WEIGHT_BLACK; break;
+ default: eWeight=WEIGHT_DONTKNOW;
+ }
+ pF->aFont.SetWeight(eWeight);
+ break;
+ }
+ }
+ nPos+=nLen; pOS2MET->Seek(nPos);
+ }
+}
+
+void OS2METReader::ReadField(USHORT nFieldType, USHORT nFieldSize)
+{
+ switch (nFieldType) {
+ case BegDocumnMagic:
+ break;
+ case EndDocumnMagic:
+ break;
+ case BegResGrpMagic:
+ break;
+ case EndResGrpMagic:
+ break;
+ case BegColAtrMagic:
+ break;
+ case EndColAtrMagic:
+ break;
+ case BlkColAtrMagic: {
+ ULONG nPos, nMaxPos;
+ BYTE nbyte;
+ ULONG nCol;
+ USHORT nStartIndex, nEndIndex, i, nElemLen, nBytesPerCol;
+
+ nPos=pOS2MET->Tell();
+ nMaxPos=nPos+(ULONG)nFieldSize;
+ pOS2MET->SeekRel(3); nPos+=3;
+ while (nPos<nMaxPos && pOS2MET->GetError()==0) {
+ *pOS2MET >> nbyte; nElemLen=((USHORT)nbyte) & 0x00ff;
+ if (nElemLen>11) {
+ pOS2MET->SeekRel(4);
+ nStartIndex=ReadBigEndianWord();
+ pOS2MET->SeekRel(3);
+ *pOS2MET >> nbyte; nBytesPerCol=((USHORT)nbyte) & 0x00ff;
+ nEndIndex=nStartIndex+(nElemLen-11)/nBytesPerCol;
+ for (i=nStartIndex; i<nEndIndex; i++) {
+ if (nBytesPerCol > 3) pOS2MET->SeekRel(nBytesPerCol-3);
+ nCol=ReadBigEndian3BytesLong();
+ SetPalette0RGB(i,nCol);
+ }
+ }
+ else if (nElemLen<10) {
+ pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ ErrorCode=4;
+ }
+ nPos+=(ULONG)nElemLen;
+ pOS2MET->Seek(nPos);
+ }
+ break;
+ }
+ case MapColAtrMagic:
+ break;
+ case BegImgObjMagic: {
+ // neue Bitmap schonmal herstellen: (wird spaeter gefuellt)
+ OSBitmap * pB=new OSBitmap;
+ pB->pSucc=pBitmapList; pBitmapList=pB;
+ pB->pBMP=NULL; pB->nWidth=0; pB->nHeight=0; pB->nBitsPerPixel=0;
+ pB->nMapPos=0;
+ // ID der Bitmap ermitteln:
+ BYTE i,nbyte,nbyte2;
+ pB->nID=0;
+ for (i=0; i<4; i++) {
+ *pOS2MET >> nbyte >> nbyte2;
+ nbyte=((nbyte-0x30)<<4)|(nbyte2-0x30);
+ pB->nID=(pB->nID>>8)|(((ULONG)nbyte)<<24);
+ }
+ // neue Palette auf den Paletten-Stack bringen: (wird spaeter gefuellt)
+ OSPalette * pP=new OSPalette;
+ pP->pSucc=pPaletteStack; pPaletteStack=pP;
+ pP->p0RGB=NULL; pP->nSize=0;
+ break;
+ }
+ case EndImgObjMagic: {
+ // Temporaere Windows-BMP-Datei auslesen:
+ if (pBitmapList==NULL || pBitmapList->pBMP==NULL ||
+ pBitmapList->pBMP->GetError()!=0) {
+ pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ ErrorCode=5;
+ return;
+ }
+ pBitmapList->pBMP->Seek(0);
+
+ pBitmapList->aBitmap.Read( *( pBitmapList->pBMP ), FALSE );
+
+ if (pBitmapList->pBMP->GetError()!=0) {
+ pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ ErrorCode=6;
+ }
+ delete pBitmapList->pBMP; pBitmapList->pBMP=NULL;
+ // Palette vom Stack killen:
+ OSPalette * pP=pPaletteStack;
+ if (pP!=NULL) {
+ pPaletteStack=pP->pSucc;
+ if (pP->p0RGB!=NULL) delete pP->p0RGB;
+ delete pP;
+ }
+ break;
+ }
+ case DscImgObjMagic:
+ break;
+ case DatImgObjMagic: {
+ USHORT nDataID, nDataLen;
+ BYTE nbyte;
+ ULONG nPos, nMaxPos;
+
+ nPos=pOS2MET->Tell();
+ nMaxPos=nPos+(ULONG)nFieldSize;
+ while (nPos<nMaxPos && pOS2MET->GetError()==0) {
+ *pOS2MET >> nbyte; nDataID=((USHORT)nbyte)&0x00ff;
+ if (nDataID==0x00fe) {
+ *pOS2MET >> nbyte;
+ nDataID=(nDataID<<8)|(((USHORT)nbyte)&0x00ff);
+ nDataLen=ReadBigEndianWord();
+ nPos+=4;
+ }
+ else {
+ *pOS2MET >> nbyte; nDataLen=((USHORT)nbyte)&0x00ff;
+ nPos+=2;
+ }
+ ReadImageData(nDataID, nDataLen);
+ nPos+=(ULONG)nDataLen;
+ pOS2MET->Seek(nPos);
+ }
+ break;
+ }
+
+ case BegObEnv1Magic:
+ break;
+ case EndObEnv1Magic:
+ break;
+ case BegGrfObjMagic:
+ break;
+ case EndGrfObjMagic: {
+ SvStream * pSave;
+ ULONG nPos, nMaxPos;
+ USHORT nOrderID, nOrderLen;
+ BYTE nbyte;
+
+ if (pOrdFile==NULL) break;
+
+ // in pOrdFile wurden alle "DatGrfObj"-Felder gesammelt, so
+ // dass die darin enthaltnen "Orders" zusammenhangend und nicht durch
+ // "Fields" segmentiert sind. Um sie aus dem MemoryStream auszulesen,
+ // ohne grosse Umstaende deswegen zu haben (frueher wurden die "Orders"
+ // direkt aus pOS2MET gelesen), hier ein kleiner Trick:
+ pSave=pOS2MET;
+ pOS2MET=pOrdFile; //(!)
+ nMaxPos=pOS2MET->Tell();
+ pOS2MET->Seek(0);
+
+ // "Segmentheader":
+ *pOS2MET >> nbyte;
+ if (nbyte==0x70) { // Header vorhanden
+ pOS2MET->SeekRel(15); // brauchen wir aber nicht
+ }
+ else pOS2MET->SeekRel(-1); // Kein Header, Byte zurueck
+
+ // Schleife ueber Order:
+ while (pOS2MET->Tell()<nMaxPos && pOS2MET->GetError()==0) {
+ *pOS2MET >> nbyte; nOrderID=((USHORT)nbyte) & 0x00ff;
+ if (nOrderID==0x00fe) {
+ *pOS2MET >> nbyte;
+ nOrderID=(nOrderID << 8) | (((USHORT)nbyte) & 0x00ff);
+ }
+ if (nOrderID>0x00ff || nOrderID==GOrdPolygn) {
+ // ooo: Laut OS2-Doku sollte die Orderlaenge nun als Big-Endian-Word
+ // gegeben sein (Zitat: "Highorder byte precedes loworder byte").
+ // Tatsaechlich gibt es aber Dateien, die die Laenge als
+ // Little-Endian-Word angeben (zu mindestens fuer nOrderID==GOrdPolygn).
+ // Also werfen wir eine Muenze oder was ?
+ *pOS2MET >> nbyte; nOrderLen=(USHORT)nbyte&0x00ff;
+ *pOS2MET >> nbyte; if (nbyte!=0) nOrderLen=nOrderLen<<8|(((USHORT)nbyte)&0x00ff);
+ }
+ else if (nOrderID==GOrdSTxAlg || nOrderID==GOrdPTxAlg) nOrderLen=2;
+ else if ((nOrderID&0xff88)==0x0008) nOrderLen=1;
+ else if (nOrderID==0x0000 || nOrderID==0x00ff) nOrderLen=0;
+ else { *pOS2MET >> nbyte; nOrderLen=((USHORT)nbyte) & 0x00ff; }
+ nPos=pOS2MET->Tell();
+ ReadOrder(nOrderID, nOrderLen);
+ if (nPos+nOrderLen < pOS2MET->Tell()) {
+ OOODEBUG("Order kuerzer als er denkt! OrderID:",nOrderID);
+ OOODEBUG("...und zwar bei Position (Parameteranfang):",nPos);
+ }
+ else if (nPos+nOrderLen != pOS2MET->Tell()) {
+ OOODEBUG(String(nOrderID)+String(" Order nicht alles gelesen! bei:"),nPos);
+ }
+ pOS2MET->Seek(nPos+nOrderLen);
+ }
+
+ pOS2MET=pSave;
+ if (pOrdFile->GetError()) {
+ pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ ErrorCode=10;
+ }
+ delete pOrdFile; pOrdFile=NULL;
+ break;
+ }
+ case DscGrfObjMagic: {
+ ULONG nPos, nMaxPos;
+ USHORT nDscID, nDscLen;
+ BYTE nbyte;
+
+ nMaxPos=pOS2MET->Tell()+(ULONG)nFieldSize;
+ while (pOS2MET->Tell()<nMaxPos && pOS2MET->GetError()==0) {
+ *pOS2MET >> nbyte; nDscID =((USHORT)nbyte) & 0x00ff;
+ *pOS2MET >> nbyte; nDscLen=((USHORT)nbyte) & 0x00ff;
+ nPos=pOS2MET->Tell();
+ ReadDsc(nDscID, nDscLen);
+ pOS2MET->Seek(nPos+nDscLen);
+ }
+ break;
+ }
+ case DatGrfObjMagic: {
+ if (pOrdFile==NULL) {
+ pOrdFile = new SvMemoryStream;
+ pOrdFile->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
+ }
+ BYTE * pBuf; pBuf = new BYTE[nFieldSize];
+ pOS2MET->Read(pBuf,nFieldSize);
+ pOrdFile->Write(pBuf,nFieldSize);
+ delete pBuf;
+ break;
+ }
+ case MapCodFntMagic:
+ ReadFont(nFieldSize);
+ break;
+
+ case MapDatResMagic:
+ break;
+ }
+}
+
+void OS2METReader::ReadOS2MET( SvStream & rStreamOS2MET, GDIMetaFile & rGDIMetaFile, PFilterCallback pcallback, void * pcallerdata)
+{
+ USHORT nFieldSize;
+ USHORT nFieldType;
+ ULONG nPos, nStartPos, nEndPos, nPercent, nLastPercent;
+ BYTE nMagicByte;
+
+ ErrorCode=0;
+
+ pCallback=pcallback; pCallerData=pcallerdata;
+
+ pOS2MET = &rStreamOS2MET;
+ nOrigPos = pOS2MET->Tell();
+ nOrigNumberFormat = pOS2MET->GetNumberFormatInt();
+
+ bCoord32 = TRUE;
+ pPaletteStack=NULL;
+ pAreaStack=NULL;
+ pPathStack=NULL;
+ pPathList=NULL;
+ pFontList=NULL;
+ pBitmapList=NULL;
+ pAttrStack=NULL;
+
+ aDefAttr.aLinCol =Color(COL_BLACK);
+ aDefAttr.aLinBgCol =Color(COL_WHITE);
+ aDefAttr.eLinMix =ROP_OVERPAINT;
+ aDefAttr.eLinBgMix =ROP_OVERPAINT;
+ aDefAttr.aChrCol =Color(COL_BLACK);
+ aDefAttr.aChrBgCol =Color(COL_WHITE);
+ aDefAttr.eChrMix =ROP_OVERPAINT;
+ aDefAttr.eChrBgMix =ROP_OVERPAINT;
+ aDefAttr.aMrkCol =Color(COL_BLACK);
+ aDefAttr.aMrkBgCol =Color(COL_WHITE);
+ aDefAttr.eMrkMix =ROP_OVERPAINT;
+ aDefAttr.eMrkBgMix =ROP_OVERPAINT;
+ aDefAttr.aPatCol =Color(COL_BLACK);
+ aDefAttr.aPatBgCol =Color(COL_WHITE);
+ aDefAttr.ePatMix =ROP_OVERPAINT;
+ aDefAttr.ePatBgMix =ROP_OVERPAINT;
+ aDefAttr.aImgCol =Color(COL_BLACK);
+ aDefAttr.aImgBgCol =Color(COL_WHITE);
+ aDefAttr.eImgMix =ROP_OVERPAINT;
+ aDefAttr.eImgBgMix =ROP_OVERPAINT;
+ aDefAttr.nArcP =1;
+ aDefAttr.nArcQ =1;
+ aDefAttr.nArcR =0;
+ aDefAttr.nArcS =0;
+ aDefAttr.nChrAng =0;
+ aDefAttr.aChrCellSize=Size(12,12);
+ aDefAttr.nChrSet =0;
+ aDefAttr.aCurPos =Point(0,0);
+ aDefAttr.eLinStyle =PEN_SOLID;
+ aDefAttr.nLinWidth =0;
+ aDefAttr.aMrkCellSize=Size(10,10);
+ aDefAttr.nMrkPrec =0x01;
+ aDefAttr.nMrkSet =0xff;
+ aDefAttr.nMrkSymbol =0x01;
+ aDefAttr.bFill =TRUE;
+ aDefAttr.nStrLinWidth=0;
+
+ aAttr=aDefAttr;
+
+ pOrdFile=NULL;
+
+ pVirDev = new VirtualDevice();
+ pVirDev->EnableOutput(FALSE);
+ rGDIMetaFile.Record(pVirDev);
+
+ pOS2MET->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
+
+ nStartPos=pOS2MET->Tell();
+ nEndPos=pOS2MET->Seek(STREAM_SEEK_TO_END); pOS2MET->Seek(nStartPos);
+ Callback(0); nLastPercent=0;
+
+ nPos=pOS2MET->Tell();
+ if ( nStartPos == nEndPos )
+ {
+ nEndPos = 100;
+ nStartPos = 0;
+ }
+
+ for (;;) {
+
+ nPercent=(nPos-nStartPos)*100/(nEndPos-nStartPos);
+ if (nLastPercent+4<=nPercent) {
+ if (Callback((USHORT)nPercent)==TRUE) break;
+ nLastPercent=nPercent;
+ }
+
+ nFieldSize=ReadBigEndianWord();
+
+ *pOS2MET >> nMagicByte;
+ if (nMagicByte!=0xd3) {
+ pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ ErrorCode=7;
+ break;
+ }
+ *pOS2MET >> nFieldType;
+
+ pOS2MET->SeekRel(3);
+ nPos+=8; nFieldSize-=8;
+
+ if (pOS2MET->GetError()) break;
+ if (pOS2MET->IsEof()) {
+ pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ ErrorCode=8;
+ break;
+ }
+
+ if (nFieldType==EndDocumnMagic) break;
+
+ ReadField(nFieldType, nFieldSize);
+
+ nPos+=(ULONG)nFieldSize;
+ if (pOS2MET->Tell()>nPos) {
+ pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ ErrorCode=9;
+ break;
+ }
+ pOS2MET->Seek(nPos);
+ }
+
+ rGDIMetaFile.Stop();
+ delete pVirDev;
+
+ rGDIMetaFile.SetPrefMapMode( aGlobMapMode );
+
+ if( aBoundingRect.GetWidth() && aBoundingRect.GetHeight() )
+ rGDIMetaFile.SetPrefSize( aBoundingRect.GetSize() );
+ else
+ {
+ if( aCalcBndRect.Left() || aCalcBndRect.Top() )
+ rGDIMetaFile.Move( -aCalcBndRect.Left(), -aCalcBndRect.Top() );
+
+ rGDIMetaFile.SetPrefSize( aCalcBndRect.GetSize() );
+ }
+
+ if (pOrdFile!=NULL) delete pOrdFile;
+
+ while (pAreaStack!=NULL) {
+ OSArea * p=pAreaStack;
+ pAreaStack=p->pSucc;
+ delete p;
+ }
+
+ while (pPathStack!=NULL) {
+ OSPath * p=pPathStack;
+ pPathStack=p->pSucc;
+ delete p;
+ }
+
+ while (pPathList!=NULL) {
+ OSPath * p=pPathList;
+ pPathList=p->pSucc;
+ delete p;
+ }
+
+ while (pFontList!=NULL) {
+ OSFont * p=pFontList;
+ pFontList=p->pSucc;
+ delete p;
+ }
+
+ while (pBitmapList!=NULL) {
+ OSBitmap * p=pBitmapList;
+ pBitmapList=p->pSucc;
+ if (p->pBMP!=NULL) delete p->pBMP;
+ delete p;
+ }
+
+ while (pAttrStack!=NULL) {
+ OSAttr * p=pAttrStack;
+ pAttrStack=p->pSucc;
+ delete p;
+ }
+
+ while (pPaletteStack!=NULL) {
+ OSPalette * p=pPaletteStack;
+ pPaletteStack=p->pSucc;
+ if (p->p0RGB!=NULL) delete p->p0RGB;
+ delete p;
+ }
+
+ pOS2MET->SetNumberFormatInt(nOrigNumberFormat);
+
+ if (pOS2MET->GetError()) {
+ OOODEBUG("Fehler Nr.:",ErrorCode);
+ pOS2MET->Seek(nOrigPos);
+ }
+}
+
+//================== GraphicImport - die exportierte Funktion ================
+
+#ifdef WNT
+extern "C" BOOL _cdecl GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#else
+extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#endif
+{
+ OS2METReader aOS2METReader;
+ GDIMetaFile aMTF;
+ BOOL bRet = FALSE;
+
+ if ( &rStream == NULL && pCallerData )
+ {
+ SvMemoryStream aMemStm;
+
+ aMemStm << *(GDIMetaFile*) pCallerData;
+ aMemStm.Seek( 0 );
+ pCallerData = NULL;
+
+ aOS2METReader.ReadOS2MET( aMemStm, aMTF, NULL, NULL );
+
+ if ( !aMemStm.GetError() )
+ {
+ rGraphic = Graphic(aMTF);
+ bRet = TRUE;
+ }
+ }
+ else
+ {
+ aOS2METReader.ReadOS2MET(rStream,aMTF,pCallback,pCallerData);
+
+ if ( !rStream.GetError() )
+ {
+ rGraphic=Graphic(aMTF);
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+//================== ein bischen Muell fuer Windows ==========================
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
+
diff --git a/goodies/source/filter.vcl/ios2met/makefile.mk b/goodies/source/filter.vcl/ios2met/makefile.mk
new file mode 100644
index 000000000000..fa287ba85a6f
--- /dev/null
+++ b/goodies/source/filter.vcl/ios2met/makefile.mk
@@ -0,0 +1,175 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=ios2met
+DEPTARGET=vios2met
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(COM)"=="WTC"
+CFLAGS=-c -Zp1 -W3 -Zl -I$(INCLUDE) -bt=os2 -zq -cc++ -xst -od -3r
+.ENDIF
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SLOFILES = $(SLO)$/ios2met.obj
+
+# ==========================================================================
+
+SHL1TARGET= ime$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= ios2met
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(CPPULIB)
+
+SHL1DEPN= $(LB)$/ios2met.lib
+SHL1LIBS= $(SLB)$/ios2met.lib # $(LB)$/rtftoken.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/ios2met.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicImport >>$@
+.ELSE
+ @echo _GraphicImport >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET) >>$@
+ @ldump -E1 -A $(SLB)$/ios2met.lib >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicImport >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/ipbm/ipbm.cxx b/goodies/source/filter.vcl/ipbm/ipbm.cxx
new file mode 100644
index 000000000000..d3840fa371a4
--- /dev/null
+++ b/goodies/source/filter.vcl/ipbm/ipbm.cxx
@@ -0,0 +1,606 @@
+/*************************************************************************
+ *
+ * $RCSfile: ipbm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <vcl/graph.hxx>
+#include <vcl/bmpacc.hxx>
+#include <svtools/fltcall.hxx>
+
+//============================ PBMReader ==================================
+
+class PBMReader {
+
+private:
+
+ PFilterCallback pCallback;
+ void * pCallerData;
+
+ SvStream* mpPBM; // Die einzulesende PBM-Datei
+
+ BOOL mbStatus;
+ BOOL mbRemark; // FALSE wenn sich stream in einem Kommentar befindet
+ BOOL mbRaw; // RAW/ASCII MODE
+ ULONG mnMode; // 0->PBM, 1->PGM, 2->PPM
+ Bitmap maBmp;
+ BitmapWriteAccess* mpAcc;
+ ULONG mnWidth, mnHeight; // Bildausmass in Pixeln
+ ULONG mnCol;
+ ULONG mnMaxVal; // maximaler wert in den
+ BOOL ImplCallback( USHORT nPercent );
+ BOOL ImplReadBody();
+ BOOL ImplReadHeader();
+
+public:
+ PBMReader();
+ ~PBMReader();
+ BOOL ReadPBM( SvStream & rPBM, Graphic & rGraphic, PFilterCallback pcallback, void * pcallerdata );
+};
+
+//=================== Methoden von PBMReader ==============================
+
+PBMReader::PBMReader() :
+ mpAcc ( NULL ),
+ mbStatus ( TRUE ),
+ mbRemark ( FALSE ),
+ mbRaw ( TRUE )
+{
+}
+
+PBMReader::~PBMReader()
+{
+}
+
+BOOL PBMReader::ImplCallback( USHORT nPercent )
+{
+ if ( pCallback != NULL )
+ {
+ if ( ( (*pCallback)( pCallerData, nPercent ) ) == TRUE )
+ {
+ mpPBM->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+BOOL PBMReader::ReadPBM( SvStream & rPBM, Graphic & rGraphic, PFilterCallback pcallback, void * pcallerdata)
+{
+ USHORT i;
+
+ if ( rPBM.GetError() ) return FALSE;
+
+ pCallback = pcallback;
+ pCallerData = pcallerdata;
+
+ mpPBM = &rPBM;
+ mpPBM->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+
+ // Kopf einlesen:
+
+ if ( ( mbStatus = ImplReadHeader() ) == FALSE )
+ return FALSE;
+
+ if ( mnWidth == 0 || mnHeight == 0 )
+ return FALSE;
+
+ // 0->PBM, 1->PGM, 2->PPM
+ switch ( mnMode )
+ {
+ case 0 :
+ maBmp = Bitmap( Size( mnWidth, mnHeight ), 1 );
+ if ( ( mpAcc = maBmp.AcquireWriteAccess() ) == FALSE )
+ return FALSE;
+ mpAcc->SetPaletteEntryCount( 2 );
+ mpAcc->SetPaletteColor( 0, BitmapColor( 0xff, 0xff, 0xff ) );
+ mpAcc->SetPaletteColor( 1, BitmapColor( 0x00, 0x00, 0x00 ) );
+ break;
+
+ case 1 :
+ if ( mnMaxVal <= 1 )
+ maBmp = Bitmap( Size( mnWidth, mnHeight ), 1);
+ else if ( mnMaxVal <= 15 )
+ maBmp = Bitmap( Size( mnWidth, mnHeight ), 4);
+ else
+ maBmp = Bitmap( Size( mnWidth, mnHeight ), 8);
+
+ if ( ( mpAcc = maBmp.AcquireWriteAccess() ) == FALSE )
+ return FALSE;
+ mnCol = (USHORT)mnMaxVal + 1;
+ if ( mnCol > 256 )
+ mnCol = 256;
+
+ mpAcc->SetPaletteEntryCount( 256 );
+ for ( i = 0; i < mnCol; i++ )
+ {
+ ULONG nCount = 255 * i / mnCol;
+ mpAcc->SetPaletteColor( i, BitmapColor( (BYTE)nCount, (BYTE)nCount, (BYTE)nCount ) );
+ }
+ break;
+ case 2 :
+ maBmp = Bitmap( Size( mnWidth, mnHeight ), 24 );
+ if ( ( mpAcc = maBmp.AcquireWriteAccess() ) == FALSE )
+ return FALSE;
+ break;
+ }
+
+ // Bitmap-Daten einlesen
+ mbStatus = ImplReadBody();
+
+ if ( mpAcc )
+ {
+ maBmp.ReleaseAccess( mpAcc ), mpAcc = NULL;
+ }
+ if ( mbStatus )
+ rGraphic = maBmp;
+
+ return mbStatus;
+}
+
+BOOL PBMReader::ImplReadHeader()
+{
+ BYTE nID[ 2 ];
+ BYTE nDat;
+ BYTE nMax, nCount = 0;
+ BOOL bFinished = FALSE;
+
+ *mpPBM >> nID[ 0 ] >> nID[ 1 ];
+ if ( nID[ 0 ] != 'P' )
+ return FALSE;
+ switch ( nID[ 1 ] )
+ {
+ case '1' :
+ mbRaw = FALSE;
+ case '4' :
+ mnMode = 0;
+ nMax = 2; // number of parameters in Header
+ break;
+ case '2' :
+ mbRaw = FALSE;
+ case '5' :
+ mnMode = 1;
+ nMax = 3;
+ break;
+ case '3' :
+ mbRaw = FALSE;
+ case '6' :
+ mnMode = 2;
+ nMax = 3;
+ break;
+ default:
+ return FALSE;
+ }
+
+ mnMaxVal = mnWidth = mnHeight = 0;
+
+ while ( bFinished == FALSE )
+ {
+ if ( mpPBM->GetError() )
+ return FALSE;
+
+ *mpPBM >> nDat;
+
+ if ( nDat == '#' )
+ {
+ mbRemark = TRUE;
+ continue;
+ }
+ else if ( ( nDat == 0x0d ) || ( nDat == 0x0a ) )
+ {
+ mbRemark = FALSE;
+ nDat = 0x20;
+ }
+ if ( mbRemark )
+ continue;
+
+ if ( ( nDat == 0x20 ) || ( nDat == 0x09 ) )
+ {
+ if ( ( nCount == 0 ) && mnWidth )
+ nCount++;
+ else if ( ( nCount == 1 ) && mnHeight )
+ {
+ if ( ++nCount == nMax )
+ bFinished = TRUE;
+ }
+ else if ( ( nCount == 2 ) && mnMaxVal )
+ {
+ bFinished = TRUE;
+ }
+ continue;
+ }
+ if ( ( nDat >= '0' ) && ( nDat <= '9' ) )
+ {
+ nDat -= '0';
+ if ( nCount == 0 )
+ {
+ mnWidth *= 10;
+ mnWidth += nDat;
+ }
+ else if ( nCount == 1 )
+ {
+ mnHeight *= 10;
+ mnHeight += nDat;
+ }
+ else if ( nCount == 2 )
+ {
+ mnMaxVal *= 10;
+ mnMaxVal += nDat;
+ }
+ }
+ else
+ return FALSE;
+ }
+ return mbStatus;
+}
+
+BOOL PBMReader::ImplReadBody()
+{
+ BOOL bPara, bFinished = FALSE;
+ BYTE nDat, nCount;
+ ULONG nGrey, nRGB[3];
+ ULONG nWidth = 0;
+ ULONG nHeight = 0;
+ char nShift = 0;
+
+ if ( mbRaw )
+ {
+ switch ( mnMode )
+ {
+
+ // PBM
+ case 0 :
+ while ( nHeight != mnHeight )
+ {
+ if ( mpPBM->IsEof() || mpPBM->GetError() )
+ return FALSE;
+
+ if ( --nShift < 0 )
+ {
+ *mpPBM >> nDat;
+ nShift = 7;
+ }
+ mpAcc->SetPixel( nHeight, nWidth, nDat >> nShift );
+ if ( ++nWidth == mnWidth )
+ {
+ nShift = 0;
+ nWidth = 0;
+ nHeight++;
+ ImplCallback( (USHORT)( ( 100 * nHeight ) / mnHeight ) ); // processing output in percent
+ }
+ }
+ break;
+
+ // PGM
+ case 1 :
+ while ( nHeight != mnHeight )
+ {
+ if ( mpPBM->IsEof() || mpPBM->GetError() )
+ return FALSE;
+
+ *mpPBM >> nDat;
+ mpAcc->SetPixel( nHeight, nWidth++, nDat);
+
+ if ( nWidth == mnWidth )
+ {
+ nWidth = 0;
+ nHeight++;
+ ImplCallback( (USHORT)( ( 100 * nHeight ) / mnHeight ) ); // processing output in percent
+ }
+ }
+ break;
+
+ // PPM
+ case 2 :
+ while ( nHeight != mnHeight )
+ {
+ if ( mpPBM->IsEof() || mpPBM->GetError() )
+ return FALSE;
+
+ BYTE nR, nG, nB;
+ ULONG nRed, nGreen, nBlue;
+ *mpPBM >> nR >> nG >> nB;
+ nRed = 255 * nR / mnMaxVal;
+ nGreen = 255 * nG / mnMaxVal;
+ nBlue = 255 * nB / mnMaxVal;
+ mpAcc->SetPixel( nHeight, nWidth++, BitmapColor( (BYTE)nRed, (BYTE)nGreen, (BYTE)nBlue ) );
+ if ( nWidth == mnWidth )
+ {
+ nWidth = 0;
+ nHeight++;
+ ImplCallback( (USHORT) ( ( 100 * nHeight ) / mnHeight ) ); // processing output in percent
+ }
+ }
+ break;
+ }
+ }
+ else switch ( mnMode )
+ {
+ // PBM
+ case 0 :
+ while ( bFinished == FALSE )
+ {
+ if ( mpPBM->IsEof() || mpPBM->GetError() )
+ return FALSE;
+
+ *mpPBM >> nDat;
+
+ if ( nDat == '#' )
+ {
+ mbRemark = TRUE;
+ continue;
+ }
+ else if ( ( nDat == 0x0d ) || ( nDat == 0x0a ) )
+ {
+ mbRemark = FALSE;
+ continue;
+ }
+ if ( mbRemark || nDat == 0x20 || nDat == 0x09 )
+ continue;
+
+ if ( nDat == '0' || nDat == '1' )
+ {
+ mpAcc->SetPixel( nHeight, nWidth, (BYTE)nDat-'0' );
+ nWidth++;
+ if ( nWidth == mnWidth )
+ {
+ nWidth = 0;
+ if ( ++nHeight == mnHeight )
+ bFinished = TRUE;
+ ImplCallback( (USHORT) ( ( 100 * nHeight ) / mnHeight ) ); // processing output in percent
+ }
+ }
+ else
+ return FALSE;
+ }
+ break;
+
+ // PGM
+ case 1 :
+
+ bPara = FALSE;
+ nCount = 0;
+ nGrey = 0;
+
+ while ( bFinished == FALSE )
+ {
+ if ( nCount )
+ {
+ nCount--;
+ if ( nGrey <= mnMaxVal )
+ nGrey = 255 * nGrey / mnMaxVal;
+ mpAcc->SetPixel( nHeight, nWidth++, (BYTE)nGrey );
+ nGrey = 0;
+ if ( nWidth == mnWidth )
+ {
+ nWidth = 0;
+ if ( ++nHeight == mnHeight )
+ bFinished = TRUE;
+ ImplCallback( (USHORT) ( ( 100 * nHeight ) / mnHeight ) ); // processing output in percent
+ }
+ continue;
+ }
+
+ if ( mpPBM->IsEof() || mpPBM->GetError() )
+ return FALSE;
+
+ *mpPBM >> nDat;
+
+ if ( nDat == '#' )
+ {
+ mbRemark = TRUE;
+ if ( bPara )
+ {
+ bPara = FALSE;
+ nCount++;
+ }
+ continue;
+ }
+ else if ( ( nDat == 0x0d ) || ( nDat == 0x0a ) )
+ {
+ mbRemark = FALSE;
+ if ( bPara )
+ {
+ bPara = FALSE;
+ nCount++;
+ }
+ continue;
+ }
+
+ if ( nDat == 0x20 || nDat == 0x09 )
+ {
+ if ( bPara )
+ {
+ bPara = FALSE;
+ nCount++;
+ }
+ continue;
+ }
+ if ( nDat >= '0' && nDat <= '9' )
+ {
+ bPara = TRUE;
+ nGrey *= 10;
+ nGrey += nDat-'0';
+ continue;
+ }
+ else
+ return FALSE;
+ }
+ break;
+
+
+
+ // PPM
+ case 2 :
+
+ bPara = FALSE;
+ nCount = 0;
+ nRGB[ 0 ] = nRGB[ 1 ] = nRGB[ 2 ] = 0;
+
+ while ( bFinished == FALSE )
+ {
+ if ( nCount == 3 )
+ {
+ nCount = 0;
+ mpAcc->SetPixel( nHeight, nWidth++, BitmapColor( (BYTE)nRGB[ 0 ], (BYTE)nRGB[ 1 ], (BYTE)nRGB[ 2 ] ) );
+ nCount = 0;
+ nRGB[ 0 ] = nRGB[ 1 ] = nRGB[ 2 ] = 0;
+ if ( nWidth == mnWidth )
+ {
+ nWidth = 0;
+ if ( ++nHeight == mnHeight )
+ bFinished = TRUE;
+ ImplCallback( (USHORT) ( ( 100 * nHeight ) / mnHeight ) ); // processing output in percent
+ }
+ continue;
+ }
+
+ if ( mpPBM->IsEof() || mpPBM->GetError() )
+ return FALSE;
+
+ *mpPBM >> nDat;
+
+ if ( nDat == '#' )
+ {
+ mbRemark = TRUE;
+ if ( bPara )
+ {
+ bPara = FALSE;
+ nCount++;
+ }
+ continue;
+ }
+ else if ( ( nDat == 0x0d ) || ( nDat == 0x0a ) )
+ {
+ mbRemark = FALSE;
+ if ( bPara )
+ {
+ bPara = FALSE;
+ nCount++;
+ }
+ continue;
+ }
+
+ if ( nDat == 0x20 || nDat == 0x09 )
+ {
+ if ( bPara )
+ {
+ bPara = FALSE;
+ nCount++;
+ }
+ continue;
+ }
+ if ( nDat >= '0' && nDat <= '9' )
+ {
+ bPara = TRUE;
+ nRGB[ nCount ] *= 10;
+ nRGB[ nCount ] += nDat-'0';
+ continue;
+ }
+ else
+ return FALSE;
+ }
+ break;
+ }
+ return mbStatus;
+}
+
+//================== GraphicImport - die exportierte Funktion ================
+
+#ifdef WNT
+extern "C" BOOL _cdecl GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#else
+extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#endif
+{
+ PBMReader aPBMReader;
+
+ return aPBMReader.ReadPBM( rStream, rGraphic, pCallback, pCallerData );
+}
+
+//================== ein bischen Muell fuer Windows ==========================
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
+
diff --git a/goodies/source/filter.vcl/ipbm/makefile.mk b/goodies/source/filter.vcl/ipbm/makefile.mk
new file mode 100644
index 000000000000..fee571db49fa
--- /dev/null
+++ b/goodies/source/filter.vcl/ipbm/makefile.mk
@@ -0,0 +1,168 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=ipbm
+DEPTARGET=vipbm
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SLOFILES = $(SLO)$/ipbm.obj
+
+# ==========================================================================
+
+SHL1TARGET= ipb$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= ipbm
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(CPPULIB)
+SHL1DEPN= $(LB)$/ipbm.lib
+SHL1LIBS= $(SLB)$/ipbm.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/ipbm.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicImport >>$@
+.ELSE
+ @echo _GraphicImport >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET).DLL >>$@
+ @ldump -E1 -A $(SLB)$/ipbm.lib >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicImport >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/ipcd/ipcd.cxx b/goodies/source/filter.vcl/ipcd/ipcd.cxx
new file mode 100644
index 000000000000..d6ba8ff488c3
--- /dev/null
+++ b/goodies/source/filter.vcl/ipcd/ipcd.cxx
@@ -0,0 +1,509 @@
+/*************************************************************************
+ *
+ * $RCSfile: ipcd.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <tools/new.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/config.hxx>
+#include <vcl/svapp.hxx>
+#include <svtools/fltcall.hxx>
+#include <svtools/solar.hrc>
+#include "strings.hrc"
+#include "dlgipcd.hrc"
+#include "dlgipcd.hxx"
+
+//============================ PCDReader ==================================
+
+// Diese Aufloesungen sind in einer PCD-Datei enthalten:
+enum PCDResolution {
+ PCDRES_BASE16, // 192 x 128
+ PCDRES_BASE4, // 384 x 256
+ PCDRES_BASE, // 768 x 512
+ // Die folgenden sind komprimiert und koennen
+ // von uns NICHT gelesen werden:
+ PCDRES_4BASE, // 1536 x 1024
+ PCDRES_16BASE // 3072 x 3072
+};
+
+
+// Schluesselworte in der INI-Datei:
+#define PCDINI_RES_KEY "PCD-IMPORT-RESOLUTION"
+#define PCDINI_RES_BASE16 "BASE/16"
+#define PCDINI_RES_BASE4 "BASE/4"
+#define PCDINI_RES_BASE "BASE"
+
+
+class PCDReader {
+
+private:
+
+ BOOL bStatus;
+
+ PFilterCallback pCallback;
+ void* pCallerData;
+ ULONG nLastPercent;
+
+ SvStream* pPCD;
+ BitmapWriteAccess* mpAcc;
+
+ BYTE nOrientation; // Ausrichtung des Bildes in der PCD-Datei:
+ // 0 - Turmspitze zeigt nach oben
+ // 1 - Turmspitze zeigt nach rechts
+ // 2 - Turmspitze zeigt nach unten
+ // 3 - Turmspitze zeigt nach links
+
+ PCDResolution eResolution; // Welche Aufloesung wir haben wollen
+
+ ULONG nWidth; // Breite des PCD-Bildes
+ ULONG nHeight; // Hoehe des PCD-Bildes
+ ULONG nImagePos; // Position des Bildes in der PCD-Datei
+
+ // Temporare BLue-Green-Red-Bitmap
+ ULONG nBMPWidth;
+ ULONG nBMPHeight;
+
+ void MayCallback(ULONG nPercent);
+
+ void CheckPCDImagePacFile();
+ // Prueft, ob es eine Photo-CD-Datei mit 'Image Pac' ist.
+
+ void ReadOrientation();
+ // Liest die Ausrichtung und setzt nOrientation
+
+ void ReadImage(ULONG nMinPercent, ULONG nMaxPercent);
+
+public:
+
+ PCDReader() {}
+ ~PCDReader() {}
+
+ BOOL ReadPCD(SvStream & rPCD, Graphic & rGraphic,
+ PFilterCallback pcallback, void * pcallerdata,
+ Config * pConfig);
+};
+
+//=================== Methoden von PCDReader ==============================
+
+BOOL PCDReader::ReadPCD(SvStream & rPCD, Graphic & rGraphic,
+ PFilterCallback pcallback, void * pcallerdata,
+ Config * pConfig)
+{
+ Bitmap aBmp;
+
+ bStatus = TRUE;
+ pCallback = pcallback;
+ pCallerData = pcallerdata;
+ nLastPercent = 0;
+ pPCD = &rPCD;
+
+ MayCallback( 0 );
+
+ // Ist es eine PCD-Datei mit Bild ? ( setzt bStatus == FALSE, wenn nicht ):
+ CheckPCDImagePacFile();
+
+ // Orientierung des Bildes einlesen:
+ ReadOrientation();
+
+ // Welche Aufloesung wollen wir ?:
+ if ( pConfig == NULL )
+ eResolution = PCDRES_BASE;
+ else
+ {
+ String aStr;
+
+ pConfig->Update();
+ aStr = UniString( pConfig->ReadKey( PCDINI_RES_KEY, PCDINI_RES_BASE ), RTL_TEXTENCODING_UTF8 );
+ aStr.ToUpperAscii();
+ if ( aStr.CompareToAscii( PCDINI_RES_BASE16 ) == COMPARE_EQUAL )
+ eResolution = PCDRES_BASE16;
+ else if ( aStr.CompareToAscii( PCDINI_RES_BASE4 ) == COMPARE_EQUAL )
+ eResolution = PCDRES_BASE4;
+ else
+ eResolution = PCDRES_BASE;
+ }
+
+ // Groesse und Position (Position in PCD-Datei) des Bildes bestimmen:
+ switch (eResolution)
+ {
+ case PCDRES_BASE16 :
+ nWidth = 192;
+ nHeight = 128;
+ nImagePos = 8192;
+ break;
+
+ case PCDRES_BASE4 :
+ nWidth = 384;
+ nHeight = 256;
+ nImagePos = 47104;
+ break;
+
+ case PCDRES_BASE :
+ nWidth = 768;
+ nHeight = 512;
+ nImagePos = 196608;
+ break;
+
+ default:
+ bStatus = FALSE;
+ }
+ if ( bStatus )
+ {
+ if ( ( nOrientation & 0x01 ) == 0 )
+ {
+ nBMPWidth = nWidth;
+ nBMPHeight = nHeight;
+ }
+ else
+ {
+ nBMPWidth = nHeight;
+ nBMPHeight = nWidth;
+ }
+ aBmp = Bitmap( Size( nBMPWidth, nBMPHeight ), 24 );
+ if ( ( mpAcc = aBmp.AcquireWriteAccess() ) == FALSE )
+ return FALSE;
+
+ ReadImage( 5 ,65 );
+
+ aBmp.ReleaseAccess( mpAcc ), mpAcc = NULL;
+ rGraphic = aBmp;
+ }
+ return bStatus;
+}
+
+// -------------------------------------------------------------------------------------------
+
+void PCDReader::MayCallback(ULONG nPercent)
+{
+ if ( nPercent >= nLastPercent + 3 )
+ {
+ nLastPercent=nPercent;
+ if ( pCallback != NULL && nPercent <= 100 && bStatus == TRUE )
+ {
+ if ( ( (*pCallback)( pCallerData, (USHORT)nPercent ) ) == TRUE )
+ bStatus = FALSE;
+ }
+ }
+}
+
+// -------------------------------------------------------------------------------------------
+
+void PCDReader::CheckPCDImagePacFile()
+{
+ char Buf[ 8 ];
+
+ pPCD->Seek( 2048 );
+ pPCD->Read( Buf, 7 );
+ Buf[ 7 ] = 0;
+ if ( ByteString( Buf ).CompareTo( "PCD_IPI" ) != COMPARE_EQUAL )
+ bStatus = FALSE;
+}
+
+// -------------------------------------------------------------------------------------------
+
+void PCDReader::ReadOrientation()
+{
+ if ( bStatus == FALSE )
+ return;
+ pPCD->Seek( 194635 );
+ *pPCD >> nOrientation;
+ nOrientation &= 0x03;
+}
+
+// -------------------------------------------------------------------------------------------
+
+void PCDReader::ReadImage(ULONG nMinPercent, ULONG nMaxPercent)
+{
+ ULONG nx,ny,nW2,nH2,nYPair,ndy,nXPair;
+ long nL,nCb,nCr,nRed,nGreen,nBlue;
+ BYTE * pt;
+ BYTE * pL0; // Luminanz fuer jeden Pixel der 1. Zeile des aktuellen Zeilen-Paars
+ BYTE * pL1; // Luminanz fuer jeden Pixel der 2. Zeile des aktuellen Zeilen-Paars
+ BYTE * pCb; // Blau-Chrominanz fuer je 2x2 Pixel des aktuellen Zeilen-Paars
+ BYTE * pCr; // Rot-Chrominanz fuer je 2x2 Pixel des aktuellen Zeilen-Paars
+ BYTE * pL0N, * pL1N, * pCbN, * pCrN; // wie oben, nur fuer das naechste Zeilen-Paar
+
+ if ( bStatus == FALSE )
+ return;
+
+ nW2=nWidth>>1;
+ nH2=nHeight>>1;
+
+ pL0 =(BYTE*)SvMemAlloc(nWidth,MEM_NOCALLNEWHDL);
+ pL1 =(BYTE*)SvMemAlloc(nWidth,MEM_NOCALLNEWHDL);
+ pCb =(BYTE*)SvMemAlloc(nW2+1 ,MEM_NOCALLNEWHDL);
+ pCr =(BYTE*)SvMemAlloc(nW2+1 ,MEM_NOCALLNEWHDL);
+ pL0N=(BYTE*)SvMemAlloc(nWidth,MEM_NOCALLNEWHDL);
+ pL1N=(BYTE*)SvMemAlloc(nWidth,MEM_NOCALLNEWHDL);
+ pCbN=(BYTE*)SvMemAlloc(nW2+1 ,MEM_NOCALLNEWHDL);
+ pCrN=(BYTE*)SvMemAlloc(nW2+1 ,MEM_NOCALLNEWHDL);
+
+ if ( pL0 == NULL || pL1 == NULL || pCb == NULL || pCr == NULL ||
+ pL0N == NULL || pL1N == NULL || pCbN == NULL || pCrN == NULL)
+ {
+ if (pL0 !=NULL) SvMemFree((void*)pL0 );
+ if (pL1 !=NULL) SvMemFree((void*)pL1 );
+ if (pCb !=NULL) SvMemFree((void*)pCb );
+ if (pCr !=NULL) SvMemFree((void*)pCr );
+ if (pL0N!=NULL) SvMemFree((void*)pL0N);
+ if (pL1N!=NULL) SvMemFree((void*)pL1N);
+ if (pCbN!=NULL) SvMemFree((void*)pCbN);
+ if (pCrN!=NULL) SvMemFree((void*)pCrN);
+ bStatus = FALSE;
+ return;
+ }
+
+ pPCD->Seek( nImagePos );
+
+ // naechstes Zeilen-Paar := erstes Zeile-Paar:
+ pPCD->Read( pL0N, nWidth );
+ pPCD->Read( pL1N, nWidth );
+ pPCD->Read( pCbN, nW2 );
+ pPCD->Read( pCrN, nW2 );
+ pCbN[ nW2 ] = pCbN[ nW2 - 1 ];
+ pCrN[ nW2 ] = pCrN[ nW2 - 1 ];
+
+ for ( nYPair = 0; nYPair < nH2; nYPair++ )
+ {
+ // aktuelles Zeilen-Paar := naechstes Zeilen-Paar
+ pt=pL0; pL0=pL0N; pL0N=pt;
+ pt=pL1; pL1=pL1N; pL1N=pt;
+ pt=pCb; pCb=pCbN; pCbN=pt;
+ pt=pCr; pCr=pCrN; pCrN=pt;
+
+ // naechstes Zeilen-Paar holen:
+ if ( nYPair < nH2 - 1 )
+ {
+ pPCD->Read( pL0N, nWidth );
+ pPCD->Read( pL1N, nWidth );
+ pPCD->Read( pCbN, nW2 );
+ pPCD->Read( pCrN, nW2 );
+ pCbN[nW2]=pCbN[ nW2 - 1 ];
+ pCrN[nW2]=pCrN[ nW2 - 1 ];
+ }
+ else
+ {
+ for ( nXPair = 0; nXPair < nW2; nXPair++ )
+ {
+ pCbN[ nXPair ] = pCb[ nXPair ];
+ pCrN[ nXPair ] = pCr[ nXPair ];
+ }
+ }
+
+ // Schleife uber die beiden Zeilen des Zeilen-Paars:
+ for ( ndy = 0; ndy < 2; ndy++ )
+ {
+ ny = ( nYPair << 1 ) + ndy;
+
+ // Schleife ueber X:
+ for ( nx = 0; nx < nWidth; nx++ )
+ {
+ // nL,nCb,nCr fuer den Pixel nx,ny holen/berechenen:
+ nXPair = nx >> 1;
+ if ( ndy == 0 )
+ {
+ nL = (long)pL0[ nx ];
+ if (( nx & 1 ) == 0 )
+ {
+ nCb = (long)pCb[ nXPair ];
+ nCr = (long)pCr[ nXPair ];
+ }
+ else
+ {
+ nCb = ( ( (long)pCb[ nXPair ] ) + ( (long)pCb[ nXPair + 1 ] ) ) >> 1;
+ nCr = ( ( (long)pCr[ nXPair ] ) + ( (long)pCr[ nXPair + 1 ] ) ) >> 1;
+ }
+ }
+ else {
+ nL = pL1[ nx ];
+ if ( ( nx & 1 ) == 0 )
+ {
+ nCb = ( ( (long)pCb[ nXPair ] ) + ( (long)pCbN[ nXPair ] ) ) >> 1;
+ nCr = ( ( (long)pCr[ nXPair ] ) + ( (long)pCrN[ nXPair ] ) ) >> 1;
+ }
+ else
+ {
+ nCb = ( ( (long)pCb[ nXPair ] ) + ( (long)pCb[ nXPair + 1 ] ) +
+ ( (long)pCbN[ nXPair ] ) + ( (long)pCbN[ nXPair + 1 ] ) ) >> 2;
+ nCr = ( ( (long)pCr[ nXPair ] ) + ( (long)pCr[ nXPair + 1] ) +
+ ( (long)pCrN[ nXPair ] ) + ( (long)pCrN[ nXPair + 1 ] ) ) >> 2;
+ }
+ }
+ // Umwandlung von nL,nCb,nCr in nRed,nGreen,nBlue:
+ nL *= 89024L;
+ nCb -= 156;
+ nCr -= 137;
+ nRed = ( nL + nCr * 119374L + 0x8000 ) >> 16;
+ if ( nRed < 0 )
+ nRed = 0;
+ if ( nRed > 255)
+ nRed = 255;
+ nGreen = ( nL - nCb * 28198L - nCr * 60761L + 0x8000 ) >> 16;
+ if ( nGreen < 0 )
+ nGreen = 0;
+ if ( nGreen > 255 )
+ nGreen = 255;
+ nBlue = ( nL + nCb * 145352L + 0x8000 ) >> 16;
+ if ( nBlue < 0 )
+ nBlue = 0;
+ if ( nBlue > 255 )
+ nBlue = 255;
+
+ // Farbwert in pBMPMap eintragen:
+ if ( nOrientation < 2 )
+ {
+ if ( nOrientation == 0 )
+ mpAcc->SetPixel( ny, nx, BitmapColor( (BYTE)nRed, (BYTE)nGreen, (BYTE)nBlue ) );
+ else
+ mpAcc->SetPixel( nWidth - 1 - nx, ny, BitmapColor( (BYTE)nRed, (BYTE)nGreen, (BYTE)nBlue ) );
+ }
+ else
+ {
+ if ( nOrientation == 2 )
+ mpAcc->SetPixel( nHeight - 1 - ny, ( nWidth - 1 - nx ), BitmapColor( (BYTE)nRed, (BYTE)nGreen, (BYTE)nBlue ) );
+ else
+ mpAcc->SetPixel( nx, ( nHeight - 1 - ny ), BitmapColor( (BYTE)nRed, (BYTE)nGreen, (BYTE)nBlue ) );
+ }
+ }
+ }
+
+ if ( pPCD->GetError() )
+ bStatus = FALSE;
+ MayCallback( nMinPercent + ( nMaxPercent - nMinPercent ) * nYPair / nH2 );
+ if ( bStatus == FALSE )
+ break;
+ }
+ SvMemFree((void*)pL0 );
+ SvMemFree((void*)pL1 );
+ SvMemFree((void*)pCb );
+ SvMemFree((void*)pCr );
+ SvMemFree((void*)pL0N);
+ SvMemFree((void*)pL1N);
+ SvMemFree((void*)pCbN);
+ SvMemFree((void*)pCrN);
+}
+
+//================== GraphicImport - die exportierte Funktion ================
+
+#ifdef WNT
+extern "C" BOOL _cdecl GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config * pOptionsConfig, BOOL)
+#else
+extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config * pOptionsConfig, BOOL)
+#endif
+{
+ PCDReader aPCDReader;
+ return aPCDReader.ReadPCD( rStream, rGraphic, pCallback, pCallerData, pOptionsConfig );
+}
+
+//================== GraphicDialog - die exportierte Funktion ================
+
+extern "C" BOOL SAL_CALL DoImportDialog( FltCallDialogParameter& rPara )
+{
+ BOOL bRet = FALSE;
+
+ if ( rPara.pWindow && rPara.pCfg )
+ {
+ ByteString aResMgrName( "icd" );
+ ResMgr* pResMgr;
+
+ aResMgrName.Append( ByteString::CreateFromInt32( SOLARUPD ) );
+ pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetAppInternational(). GetLanguage() );
+
+ rPara.pResMgr = pResMgr;
+ bRet = ( DlgIPCD( rPara ).Execute() == RET_OK );
+
+ delete pResMgr;
+ }
+
+ return bRet;
+}
+
+//============================= fuer Windows ==================================
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
+
+
diff --git a/goodies/source/filter.vcl/ipcd/makefile.mk b/goodies/source/filter.vcl/ipcd/makefile.mk
new file mode 100644
index 000000000000..82ff6efde9e4
--- /dev/null
+++ b/goodies/source/filter.vcl/ipcd/makefile.mk
@@ -0,0 +1,182 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=ipcd
+TARGET2=icd
+DEPTARGET=vipcd
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SRCFILES = dlgipcd.src \
+ ipcdstr.src
+
+SLOFILES = $(SLO)$/ipcd.obj \
+ $(SLO)$/dlgipcd.obj
+
+# ==========================================================================
+
+RESLIB1NAME=$(TARGET2)
+RESLIB1SRSFILES=\
+ $(SRS)$/$(TARGET).srs
+
+
+SHL1TARGET= icd$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= ipcd
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(CPPULIB)
+SHL1DEPN= $(LB)$/ipcd.lib
+SHL1LIBS= $(SLB)$/ipcd.lib # $(LB)$/rtftoken.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/ipcd.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicImport >>$@
+ @echo DoImportDialog >>$@
+.ELSE
+ @echo _GraphicImport >>$@
+ @echo _DoImportDialog >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET) >>$@
+ @echo GraphicImport_ >>temp.def
+ @echo DoImportDialog_ >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicImport >>$@
+ @echo DoImportDialog >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/ipcx/ipcx.cxx b/goodies/source/filter.vcl/ipcx/ipcx.cxx
new file mode 100644
index 000000000000..ce70ea8a8cd0
--- /dev/null
+++ b/goodies/source/filter.vcl/ipcx/ipcx.cxx
@@ -0,0 +1,483 @@
+/*************************************************************************
+ *
+ * $RCSfile: ipcx.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <vcl/graph.hxx>
+#include <vcl/bmpacc.hxx>
+#include <svtools/fltcall.hxx>
+
+//============================ PCXReader ==================================
+
+class PCXReader {
+
+private:
+
+ PFilterCallback pCallback;
+ void * pCallerData;
+
+ SvStream* pPCX; // Die einzulesende PCX-Datei
+
+ Bitmap aBmp;
+ BitmapWriteAccess* pAcc;
+ BYTE nVersion; // PCX-Version
+ BYTE nEncoding; // Art der Komprimierung
+ ULONG nBitsPerPlanePix; // Bits Pro Ebene pro Pixel
+ ULONG nPlanes; // Anzahl Ebenen
+ ULONG nBytesPerPlaneLin; // Bytes in einer Ebenen pro Zeile
+ USHORT nPaletteInfo;
+
+ ULONG nWidth, nHeight; // Bildausmass in Pixeln
+ USHORT nResX, nResY; // Aufloesung in Pixel pro Inch oder 0,0
+ USHORT nDestBitsPerPixel; // Bits pro Pixel der Zielbitmap 1,4,8 oder 24
+ BYTE* pPalette; //
+ BOOL nStatus; // status nun nicht mehr am stream abfragen ( SJ )
+
+
+ BOOL Callback( USHORT nPercent );
+ void ImplReadBody();
+ void ImplReadPalette( ULONG nCol );
+ void ImplReadHeader();
+
+public:
+ PCXReader();
+ ~PCXReader();
+ BOOL ReadPCX( SvStream & rPCX, Graphic & rGraphic, PFilterCallback pcallback, void * pcallerdata );
+ // Liesst aus dem Stream eine PCX-Datei und fuellt das GDIMetaFile
+};
+
+//=================== Methoden von PCXReader ==============================
+
+PCXReader::PCXReader() :
+ pAcc ( NULL )
+{
+ pPalette = new BYTE[ 768 ];
+}
+
+PCXReader::~PCXReader()
+{
+ delete[] pPalette;
+}
+
+BOOL PCXReader::Callback( USHORT nPercent )
+{
+ if (pCallback!=NULL) {
+ if (((*pCallback)(pCallerData,nPercent))==TRUE) {
+ nStatus = FALSE;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+BOOL PCXReader::ReadPCX( SvStream & rPCX, Graphic & rGraphic, PFilterCallback pcallback, void * pcallerdata)
+{
+ if ( rPCX.GetError() )
+ return FALSE;
+
+ ULONG* pDummy = new ULONG; delete pDummy; // damit unter OS/2
+ // das richtige (Tools-)new
+ // verwendet wird, da es sonst
+ // in dieser DLL nur Vector-news
+ // gibt;
+
+ pCallback = pcallback;
+ pCallerData = pcallerdata;
+
+ pPCX = &rPCX;
+ pPCX->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
+
+ // Kopf einlesen:
+
+ nStatus = TRUE;
+
+ ImplReadHeader();
+
+ // BMP-Header und ggf. (eventuell zunaechst ungueltige) Farbpalette schreiben:
+ if ( nStatus )
+ {
+ aBmp = Bitmap( Size( nWidth, nHeight ), nDestBitsPerPixel );
+ if ( ( pAcc = aBmp.AcquireWriteAccess() ) == FALSE )
+ return FALSE;
+
+ if ( nDestBitsPerPixel <= 8 )
+ {
+ USHORT nColors = 1 << nDestBitsPerPixel;
+ BYTE* pPal = pPalette;
+ pAcc->SetPaletteEntryCount( nColors );
+ for ( USHORT i = 0; i < nColors; i++, pPal += 3 )
+ {
+ pAcc->SetPaletteColor( i, BitmapColor ( pPal[ 0 ], pPal[ 1 ], pPal[ 2 ] ) );
+ }
+ }
+ // Bitmap-Daten einlesen
+ ImplReadBody();
+
+ // Wenn erweiterte Farbpalette am Ende von PCX, dann diese einlesen, und nochmals
+ // in Palette schreiben:
+ if ( nDestBitsPerPixel == 8 && nStatus )
+ {
+ BYTE* pPal = pPalette;
+ pPCX->SeekRel(1);
+ ImplReadPalette(256);
+ pAcc->SetPaletteEntryCount( 256 );
+ for ( USHORT i = 0; i < 256; i++, pPal += 3 )
+ {
+ pAcc->SetPaletteColor( i, BitmapColor ( pPal[ 0 ], pPal[ 1 ], pPal[ 2 ] ) );
+ }
+ }
+ /*
+ // Aufloesung einstellen:
+ if (nResX!=0 && nResY!=0) {
+ MapMode aMapMode(MAP_INCH,Point(0,0),Fraction(1,nResX),Fraction(1,nResY));
+ rBitmap.SetPrefMapMode(aMapMode);
+ rBitmap.SetPrefSize(Size(nWidth,nHeight));
+ }
+ */ if ( nStatus && pAcc )
+ {
+ aBmp.ReleaseAccess( pAcc ), pAcc = NULL;
+ rGraphic = aBmp;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void PCXReader::ImplReadHeader()
+{
+ BYTE nbyte;
+ USHORT nushort;
+ USHORT nMinX,nMinY,nMaxX,nMaxY;
+
+ *pPCX >> nbyte >> nVersion >> nEncoding;
+ if ( nbyte!=0x0a || (nVersion != 0 && nVersion != 2 && nVersion != 3 && nVersion != 5) || nEncoding > 1 )
+ {
+ nStatus = FALSE;
+ return;
+ }
+
+ *pPCX >> nbyte; nBitsPerPlanePix = (ULONG)nbyte;
+ *pPCX >> nMinX >> nMinY >> nMaxX >> nMaxY;
+ nWidth = nMaxX-nMinX+1;
+ nHeight = nMaxY-nMinY+1;
+
+ *pPCX >> nResX;
+ *pPCX >> nResY;
+ if ( nResX >= nWidth || nResY >= nHeight || ( nResX != nResY ) )
+ nResX = nResY = 0;
+
+ ImplReadPalette( 16 );
+
+ pPCX->SeekRel( 1 );
+ *pPCX >> nbyte; nPlanes = (ULONG)nbyte;
+ *pPCX >> nushort; nBytesPerPlaneLin = (ULONG)nushort;
+ *pPCX >> nPaletteInfo;
+
+ pPCX->SeekRel( 58 );
+
+ nDestBitsPerPixel = (USHORT)( nBitsPerPlanePix * nPlanes );
+ if (nDestBitsPerPixel == 2 || nDestBitsPerPixel == 3) nDestBitsPerPixel = 4;
+
+ if ( ( nDestBitsPerPixel != 1 && nDestBitsPerPixel != 4 && nDestBitsPerPixel != 8 && nDestBitsPerPixel != 24 )
+ || nPlanes > 4 || nBytesPerPlaneLin < ( ( nWidth * nBitsPerPlanePix+7 ) >> 3 ) )
+ {
+ nStatus = FALSE;
+ return;
+ }
+
+ // Wenn das Bild nur 2 Farben hat, ist die Palette zumeist ungueltig, und es handelt sich
+ // immer (?) um ein schwarz-weiss-Bild:
+ if ( nPlanes == 1 && nBitsPerPlanePix == 1 )
+ {
+ pPalette[ 0 ] = pPalette[ 1 ] = pPalette[ 2 ] = 0x00;
+ pPalette[ 3 ] = pPalette[ 4 ] = pPalette[ 5 ] = 0xff;
+ }
+}
+
+void PCXReader::ImplReadBody()
+{
+ BYTE *pPlane[ 4 ], * pDest, * pSource1, * pSource2, * pSource3, *pSource4;
+ ULONG i, nx, ny, np, nCount, nUsedLineSize, nLineSize, nPercent, nLastPercent;
+ BYTE nDat, nCol;
+
+ nUsedLineSize = (ULONG)( ( ( nWidth * (ULONG)nDestBitsPerPixel ) + 7 ) >> 3 );
+ nLineSize = ( nUsedLineSize + 3 ) & 0xfffc;
+
+ for( np = 0; np < nPlanes; np++ )
+ pPlane[ np ] = new BYTE[ nBytesPerPlaneLin ];
+
+ nCount = 0;
+ for ( ny = 0; ny < nHeight; ny++ )
+ {
+ nPercent = ny * 60 / nHeight + 10;
+ if ( ny == 0 || nLastPercent + 4 <= nPercent )
+ {
+ nLastPercent = nPercent;
+ if ( Callback( (USHORT)nPercent ) == TRUE )
+ break;
+ }
+ for ( np = 0; np < nPlanes; np++)
+ {
+ if ( nEncoding == 0)
+ pPCX->Read( (void *)pPlane[ np ], nBytesPerPlaneLin );
+ else
+ {
+ pDest = pPlane[ np ];
+ nx = nBytesPerPlaneLin;
+ while ( nCount > 0 && nx > 0)
+ {
+ *(pDest++) = nDat;
+ nx--;
+ nCount--;
+ }
+ while ( nx > 0 )
+ {
+ *pPCX >> nDat;
+ if ( ( nDat & 0xc0 ) == 0xc0 )
+ {
+ nCount =( (ULONG)nDat ) & 0x003f;
+ *pPCX >> nDat;
+ if ( nCount < nx )
+ {
+ nx -= nCount;
+ while ( nCount > 0)
+ {
+ *(pDest++) = nDat;
+ nCount--;
+ }
+ }
+ else
+ {
+ nCount -= nx;
+ do
+ {
+ *(pDest++) = nDat;
+ nx--;
+ }
+ while ( nx > 0 );
+ break;
+ }
+ }
+ else
+ {
+ *(pDest++) = nDat;
+ nx--;
+ }
+ }
+ }
+ }
+ pSource1 = pPlane[ 0 ];
+ pSource2 = pPlane[ 1 ];
+ pSource3 = pPlane[ 2 ];
+ pSource4 = pPlane[ 3 ];
+ switch ( nBitsPerPlanePix + ( nPlanes << 8 ) )
+ {
+ // 2 colors
+ case 0x101 :
+ for ( i = 0; i < nWidth; i++ )
+ {
+ ULONG nShift = ( i & 7 ) ^ 7;
+ if ( nShift == 0 )
+ pAcc->SetPixel( ny, i, ( *pSource1++ & 1 ) );
+ else
+ pAcc->SetPixel( ny, i, ( *pSource1 >> nShift ) & 1 );
+ }
+ break;
+ // 4 colors
+ case 0x102 :
+ for ( i = 0; i < nWidth; i++ )
+ {
+ switch( i & 3 )
+ {
+ case 0 :
+ nCol = *pSource1 >> 6;
+ break;
+ case 1 :
+ nCol = ( *pSource1 >> 4 ) & 0x03 ;
+ break;
+ case 2 :
+ nCol = ( *pSource1 >> 2 ) & 0x03;
+ break;
+ case 3 :
+ nCol = ( *pSource1++ ) & 0x03;
+ break;
+ }
+ pAcc->SetPixel( ny, i, nCol );
+ }
+ break;
+ // 256 colors
+ case 0x108 :
+ for ( i = 0; i < nWidth; i++ )
+ {
+ pAcc->SetPixel( ny, i, *pSource1++ );
+ }
+ break;
+ // 8 colors
+ case 0x301 :
+ for ( i = 0; i < nWidth; i++ )
+ {
+ ULONG nShift = ( i & 7 ) ^ 7;
+ if ( nShift == 0 )
+ {
+ nCol = ( *pSource1++ & 1) + ( ( *pSource2++ << 1 ) & 2 ) + ( ( *pSource3++ << 2 ) & 4 );
+ pAcc->SetPixel( ny, i, nCol );
+ }
+ else
+ {
+ nCol = ( ( *pSource1 >> nShift ) & 1) + ( ( ( *pSource2 >> nShift ) << 1 ) & 2 ) +
+ ( ( ( *pSource3 >> nShift ) << 2 ) & 4 );
+ pAcc->SetPixel( ny, i, nCol );
+ }
+ }
+ break;
+ // 16 colors
+ case 0x401 :
+ for ( i = 0; i < nWidth; i++ )
+ {
+ ULONG nShift = ( i & 7 ) ^ 7;
+ if ( nShift == 0 )
+ {
+ nCol = ( *pSource1++ & 1) + ( ( *pSource2++ << 1 ) & 2 ) + ( ( *pSource3++ << 2 ) & 4 ) +
+ ( ( *pSource4++ << 3 ) & 8 );
+ pAcc->SetPixel( ny, i, nCol );
+ }
+ else
+ {
+ nCol = ( ( *pSource1 >> nShift ) & 1) + ( ( ( *pSource2 >> nShift ) << 1 ) & 2 ) +
+ ( ( ( *pSource3 >> nShift ) << 2 ) & 4 ) + ( ( ( *pSource4 >> nShift ) << 3 ) & 8 );
+ pAcc->SetPixel( ny, i, nCol );
+ }
+ }
+ break;
+ // 16m colors
+ case 0x308 :
+ for ( i = 0; i < nWidth; i++ )
+ {
+ pAcc->SetPixel( ny, i, Color( *pSource1++, *pSource2++, *pSource3++ ) );
+
+ }
+ break;
+ default :
+ nStatus = FALSE;
+ break;
+ }
+ }
+ for ( np = 0; np < nPlanes; np++ )
+ delete[] pPlane[ np ];
+}
+
+void PCXReader::ImplReadPalette( ULONG nCol )
+{
+ BYTE r, g, b;
+ BYTE* pPtr = pPalette;
+ for ( ULONG i = 0; i < nCol; i++ )
+ {
+ *pPCX >> r >> g >> b;
+ *pPtr++ = r;
+ *pPtr++ = g;
+ *pPtr++ = b;
+ }
+}
+
+//================== GraphicImport - die exportierte Funktion ================
+
+#ifdef WNT
+extern "C" BOOL _cdecl GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#else
+extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#endif
+{
+ PCXReader aPCXReader;
+ BOOL nRetValue = aPCXReader.ReadPCX( rStream, rGraphic, pCallback, pCallerData );
+ if ( nRetValue == FALSE )
+ rStream.SetError( SVSTREAM_FILEFORMAT_ERROR );
+ return nRetValue;
+}
+
+//================== ein bischen Muell fuer Windows ==========================
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
+
diff --git a/goodies/source/filter.vcl/ipcx/makefile.mk b/goodies/source/filter.vcl/ipcx/makefile.mk
new file mode 100644
index 000000000000..4771533f804d
--- /dev/null
+++ b/goodies/source/filter.vcl/ipcx/makefile.mk
@@ -0,0 +1,170 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=ipcx
+DEPTARGET=vipcx
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SLOFILES = $(SLO)$/ipcx.obj
+
+# ==========================================================================
+
+SHL1TARGET= ipx$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= ipcx
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(CPPULIB)
+SHL1DEPN= $(LB)$/ipcx.lib
+SHL1LIBS= $(SLB)$/ipcx.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/ipcx.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicImport >>$@
+.ELSE
+ @echo _GraphicImport >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET).DLL >>$@
+ @ldump -E1 -A $(SLB)$/ipcx.lib >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicImport >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/ipict/ipict.cxx b/goodies/source/filter.vcl/ipict/ipict.cxx
new file mode 100644
index 000000000000..f9ad52648f4d
--- /dev/null
+++ b/goodies/source/filter.vcl/ipict/ipict.cxx
@@ -0,0 +1,2021 @@
+/*************************************************************************
+ *
+ * $RCSfile: ipict.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <math.h>
+#include <string.h>
+#include <vcl/bmpacc.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/poly.hxx>
+#include <vcl/virdev.hxx>
+#include <svtools/fltcall.hxx>
+
+#ifndef NOOLDSV
+#include <vcl/gdiobj.hxx>
+#else // NOOLDSV
+enum PenStyle { PEN_NULL, PEN_SOLID, PEN_DOT, PEN_DASH, PEN_DASHDOT };
+enum BrushStyle { BRUSH_NULL, BRUSH_SOLID, BRUSH_HORZ, BRUSH_VERT,
+ BRUSH_CROSS, BRUSH_DIAGCROSS, BRUSH_UPDIAG, BRUSH_DOWNDIAG,
+ BRUSH_25, BRUSH_50, BRUSH_75,
+ BRUSH_BITMAP };
+#endif // NOOLDSV
+
+//============================ PictReader ==================================
+
+enum PictDrawingMethod {
+ PDM_FRAME, PDM_PAINT, PDM_ERASE, PDM_INVERT, PDM_FILL,
+ PDM_TEXT, PDM_UNDEFINED
+};
+
+class PictReader {
+
+private:
+
+ PFilterCallback pCallback;
+ void * pCallerData;
+
+ SvStream * pPict; // Die einzulesende Pict-Datei
+ VirtualDevice * pVirDev; // Hier werden die Drawing-Methoden aufgerufen.
+ // Dabei findet ein Recording in das GDIMetaFile
+ // statt.
+ ULONG nOrigPos; // Anfaengliche Position in pPict
+ UINT16 nOrigNumberFormat; // Anfaengliches Nummern-Format von pPict
+ BOOL IsVersion2; // Ob es ein Version 2 Pictfile ist.
+ Rectangle aBoundingRect; // Min/Max-Rechteck fuer die ganze Zeichnung
+
+ Point aPenPosition;
+ Point aTextPosition;
+ Color aActForeColor;
+ Color aActBackColor;
+ PenStyle eActPenPenStyle;
+ BrushStyle eActPenBrushStyle;
+ BrushStyle eActFillStyle;
+ BrushStyle eActBackStyle;
+ USHORT nActPenSize;
+ RasterOp eActROP;
+ PictDrawingMethod eActMethod;
+ Size aActOvalSize;
+ Font aActFont;
+
+ Fraction aHRes;
+ Fraction aVRes;
+
+ BOOL Callback(USHORT nPercent);
+
+ Point ReadPoint();
+
+ Point ReadDeltaH(Point aBase);
+ Point ReadDeltaV(Point aBase);
+
+ Point ReadUnsignedDeltaH(Point aBase);
+ Point ReadUnsignedDeltaV(Point aBase);
+
+ Size ReadSize();
+
+ Color ReadColor();
+
+ Color ReadRGBColor();
+
+ void ReadRectangle(Rectangle & rRect);
+
+ ULONG ReadPolygon(Polygon & rPoly);
+
+ ULONG ReadPattern(PenStyle * pPenStyle, BrushStyle * pBrushStyle);
+
+ ULONG ReadPixPattern(PenStyle * pPenStyle, BrushStyle * pBrushStyle);
+
+ Rectangle aLastRect;
+ ULONG ReadAndDrawRect(PictDrawingMethod eMethod);
+ ULONG ReadAndDrawSameRect(PictDrawingMethod eMethod);
+
+ Rectangle aLastRoundRect;
+ ULONG ReadAndDrawRoundRect(PictDrawingMethod eMethod);
+ ULONG ReadAndDrawSameRoundRect(PictDrawingMethod eMethod);
+
+ Rectangle aLastOval;
+ ULONG ReadAndDrawOval(PictDrawingMethod eMethod);
+ ULONG ReadAndDrawSameOval(PictDrawingMethod eMethod);
+
+ Polygon aLastPolygon;
+ ULONG ReadAndDrawPolygon(PictDrawingMethod eMethod);
+ ULONG ReadAndDrawSamePolygon(PictDrawingMethod eMethod);
+
+ Rectangle aLastArcRect;
+ ULONG ReadAndDrawArc(PictDrawingMethod eMethod);
+ ULONG ReadAndDrawSameArc(PictDrawingMethod eMethod);
+
+ ULONG ReadAndDrawRgn(PictDrawingMethod eMethod);
+ ULONG ReadAndDrawSameRgn(PictDrawingMethod eMethod);
+
+ void DrawingMethod(PictDrawingMethod eMethod);
+
+ ULONG ReadAndDrawText();
+
+ ULONG ReadPixMapEtc(Bitmap & rBitmap, BOOL bBaseAddr, BOOL bColorTable,
+ Rectangle * pSrcRect, Rectangle * pDestRect,
+ BOOL bMode, BOOL bMaskRgn);
+
+ void ReadHeader();
+ // Liesst den Kopf der Pict-Datei, setzt IsVersion2 und aBoundingRect
+
+ ULONG ReadData(USHORT nOpcode);
+ // Liesst die Daten eines Opcodes ein und fuehrt die Operation aus.
+ // Auf jeden Fall wird die Anzahl der Datenbytes zu dem Opcode
+ // zurueckgeliefert.
+
+ void SetPen( const Color& rPenColor, USHORT nWidth, PenStyle eStyle );
+ void SetBrush( const Color& rColor, const Color& rBgColor, BrushStyle eStyle );
+
+public:
+
+ PictReader() {}
+
+ void ReadPict( SvStream & rStreamPict, GDIMetaFile & rGDIMetaFile, PFilterCallback pcallback, void * pcallerdata);
+ // Liesst aus dem Stream eine Pict-Datei und fuellt das GDIMetaFile
+
+};
+
+//------------------------------------------------------------------------------------------------
+
+#define SETBYTE \
+ switch ( nPixelSize ) \
+ { \
+ case 1 : \
+ pAcc->SetPixel( ny, nx++, nDat >> 7 ); \
+ if ( nx == nWidth ) break; \
+ pAcc->SetPixel( ny, nx++, nDat >> 6 ); \
+ if ( nx == nWidth ) break; \
+ pAcc->SetPixel( ny, nx++, nDat >> 5 ); \
+ if ( nx == nWidth ) break; \
+ pAcc->SetPixel( ny, nx++, nDat >> 4 ); \
+ if ( nx == nWidth ) break; \
+ pAcc->SetPixel( ny, nx++, nDat >> 3 ); \
+ if ( nx == nWidth ) break; \
+ pAcc->SetPixel( ny, nx++, nDat >> 2 ); \
+ if ( nx == nWidth ) break; \
+ pAcc->SetPixel( ny, nx++, nDat >> 1 ); \
+ if ( nx == nWidth ) break; \
+ pAcc->SetPixel( ny, nx++, nDat ); \
+ break; \
+ case 2 : \
+ pAcc->SetPixel( ny, nx++, nDat >> 6 ); \
+ if ( nx == nWidth ) break; \
+ pAcc->SetPixel( ny, nx++, nDat >> 4 & 3); \
+ if ( nx == nWidth ) break; \
+ pAcc->SetPixel( ny, nx++, nDat >> 2 & 3 ); \
+ if ( nx == nWidth ) break; \
+ pAcc->SetPixel( ny, nx++, nDat & 3); \
+ break; \
+ case 4 : \
+ pAcc->SetPixel( ny, nx++, nDat >> 4 ); \
+ if ( nx == nWidth ) break; \
+ pAcc->SetPixel( ny, nx++, nDat ); \
+ break; \
+ case 8 : \
+ pAcc->SetPixel( ny, nx++, nDat ); \
+ break; \
+ }
+
+//------------------------------------------------------------------------------------------------
+
+#define BITMAPERROR \
+{ \
+ if ( pAcc ) \
+ aBitmap.ReleaseAccess( pAcc ); \
+ if ( pReadAcc ) \
+ aBitmap.ReleaseAccess( pReadAcc ); \
+ return 0xffffffff; \
+}
+
+//=================== Methoden von PictReader ==============================
+
+void PictReader::SetPen( const Color& rPenColor, USHORT nWidth, PenStyle eStyle )
+{
+ pVirDev->SetLineColor( rPenColor );
+}
+
+void PictReader::SetBrush( const Color& rColor, const Color& rBgColor, BrushStyle eStyle )
+{
+ pVirDev->SetFillColor( rColor );
+}
+
+BOOL PictReader::Callback(USHORT nPercent)
+{
+ if (pCallback!=NULL) {
+ if (((*pCallback)(pCallerData,nPercent))==TRUE) {
+ pPict->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+inline Point PictReader::ReadPoint()
+{
+ short nx,ny;
+
+ *pPict >> ny >> nx;
+
+ return Point( (long) ( Fraction( (long) nx ) * aHRes ) - aBoundingRect.Left(),
+ (long) ( Fraction( (long) ny ) * aVRes ) - aBoundingRect.Top() );
+}
+
+inline Point PictReader::ReadDeltaH(Point aBase)
+{
+ signed char ndh;
+
+ *pPict >> ((char&)ndh);
+
+ return Point( aBase.X() + (long) ( Fraction( (long) ndh ) * aHRes ),
+ aBase.Y() );
+}
+
+inline Point PictReader::ReadDeltaV(Point aBase)
+{
+ signed char ndv;
+
+ *pPict >> ((char&)ndv);
+
+ return Point( aBase.X(), aBase.Y() + (long) ( Fraction( (long) ndv ) * aVRes ) );
+}
+
+inline Point PictReader::ReadUnsignedDeltaH(Point aBase)
+{
+ char ndh;
+
+ *pPict >> ndh;
+
+ return Point(aBase.X() + (long) ( Fraction( (long) ndh ) * aHRes ), aBase.Y() );
+}
+
+inline Point PictReader::ReadUnsignedDeltaV(Point aBase)
+{
+ char ndv;
+
+ *pPict >> ndv;
+
+ return Point( aBase.X(), aBase.Y() + (long) ( Fraction( (long) ndv ) * aVRes ) );
+}
+
+inline Size PictReader::ReadSize()
+{
+ short nx,ny;
+
+ *pPict >> ny >> nx;
+
+ return Size( (long) ( Fraction( (long) nx ) * aHRes ),
+ (long) ( Fraction( (long) ny ) * aVRes ) );
+}
+
+Color PictReader::ReadColor()
+{
+ ULONG nCol;
+ Color aCol;
+
+ *pPict >> nCol;
+ switch (nCol)
+ {
+ case 33: aCol=Color( COL_BLACK ); break;
+ case 30: aCol=Color( COL_WHITE ); break;
+ case 205: aCol=Color( COL_LIGHTRED ); break;
+ case 341: aCol=Color( COL_LIGHTGREEN ); break;
+ case 409: aCol=Color( COL_LIGHTBLUE ); break;
+ case 273: aCol=Color( COL_LIGHTCYAN ); break;
+ case 137: aCol=Color( COL_LIGHTMAGENTA ); break;
+ case 69: aCol=Color( COL_YELLOW ); break;
+ default: aCol=Color( COL_LIGHTGRAY );
+ }
+ return aCol;
+}
+
+
+Color PictReader::ReadRGBColor()
+{
+ USHORT nR, nG, nB;
+
+ *pPict >> nR >> nG >> nB;
+ return Color( (BYTE) ( nR >> 8 ), (BYTE) ( nG >> 8 ), (BYTE) ( nB >> 8 ) );
+}
+
+
+void PictReader::ReadRectangle(Rectangle & rRect)
+{
+ Point aTopLeft, aBottomRight;
+
+ aTopLeft=ReadPoint();
+ aBottomRight=ReadPoint();
+ aBottomRight.X() -= 1;
+ aBottomRight.Y() -= 1;
+ rRect=Rectangle(aTopLeft,aBottomRight);
+}
+
+
+ULONG PictReader::ReadPolygon(Polygon & rPoly)
+{
+ USHORT nSize,i;
+ ULONG nDataSize;
+
+ *pPict >> nSize;
+ pPict->SeekRel(8);
+ nDataSize=(ULONG)nSize;
+ nSize=(nSize-10)/4;
+ rPoly.SetSize(nSize);
+ for (i=0; i<nSize; i++) rPoly.SetPoint(ReadPoint(),i);
+ return nDataSize;
+}
+
+ULONG PictReader::ReadPattern(PenStyle * pPenStyle, BrushStyle * pBrushStyle)
+{
+ short nx,ny,nBitCount;
+ unsigned char nbyte[8];
+ BrushStyle eBrStyle;
+ PenStyle ePnStyle;
+ ULONG nHiBytes, nLoBytes;
+
+ // Anzahl der Bits im Pattern zaehlen, die auf 1 gesetzt sind:
+ nBitCount=0;
+ for (ny=0; ny<8; ny++) {
+ *pPict >> ((char&)nbyte[ny]);
+ for (nx=0; nx<8; nx++) {
+ if ( (nbyte[ny] & (1<<nx)) != 0 ) nBitCount++;
+ }
+ }
+
+ // Pattern in 2 Langworten unterbringen:
+ nHiBytes=(((((((ULONG)nbyte[0])<<8)|
+ (ULONG)nbyte[1])<<8)|
+ (ULONG)nbyte[2])<<8)|
+ (ULONG)nbyte[3];
+ nLoBytes=(((((((ULONG)nbyte[4])<<8)|
+ (ULONG)nbyte[5])<<8)|
+ (ULONG)nbyte[6])<<8)|
+ (ULONG)nbyte[7];
+
+ // Einen PenStyle machen:
+ if (nBitCount<=0) ePnStyle=PEN_NULL;
+ else if (nBitCount<=16) ePnStyle=PEN_DOT;
+ else if (nBitCount<=32) ePnStyle=PEN_DASHDOT;
+ else if (nBitCount<=48) ePnStyle=PEN_DASH;
+ else ePnStyle=PEN_SOLID;
+
+ // Einen BrushStyle machen:
+ if (nHiBytes==0xffffffff && nLoBytes==0xffffffff) eBrStyle=BRUSH_SOLID;
+ else if (nHiBytes==0xff000000 && nLoBytes==0x00000000) eBrStyle=BRUSH_HORZ;
+ else if (nHiBytes==0x80808080 && nLoBytes==0x80808080) eBrStyle=BRUSH_VERT;
+ else if (nHiBytes==0xff808080 && nLoBytes==0x80808080) eBrStyle=BRUSH_CROSS;
+ else if (nHiBytes==0x01824428 && nLoBytes==0x10284482) eBrStyle=BRUSH_DIAGCROSS;
+ else if (nHiBytes==0x80402010 && nLoBytes==0x08040201) eBrStyle=BRUSH_UPDIAG;
+ else if (nHiBytes==0x01020408 && nLoBytes==0x10204080) eBrStyle=BRUSH_DOWNDIAG;
+ else if (nBitCount<=24) eBrStyle=BRUSH_25;
+ else if (nBitCount<=40) eBrStyle=BRUSH_50;
+ else if (nBitCount<=56) eBrStyle=BRUSH_75;
+ else eBrStyle=BRUSH_SOLID;
+
+ if (pPenStyle!=0) *pPenStyle=ePnStyle;
+
+ if (pBrushStyle!=0) *pBrushStyle=eBrStyle;
+
+ return 8;
+}
+
+ULONG PictReader::ReadPixPattern(PenStyle * pPenStyle, BrushStyle * pBrushStyle)
+{
+ // Keine Ahnung, ob dies richtig ist, weil kein Bild gefunden, das
+ // PixPatterns enthaelt. Auch hier nur der Versuch, die Groesse der Daten zu
+ // ermitteln, und einfache StarView-Styles daraus zu machen. Gluecklicherweise
+ // enthaelt ein PixPattern immer auch ein normales Pattern.
+
+ ULONG nDataSize;
+ USHORT nPatType;
+ Bitmap aBMP;
+
+ *pPict >> nPatType;
+ if (nPatType==1) {
+ ReadPattern(pPenStyle,pBrushStyle);
+ nDataSize=ReadPixMapEtc(aBMP,FALSE,TRUE,NULL,NULL,FALSE,FALSE);
+ if (nDataSize!=0xffffffff) nDataSize+=10;
+ }
+ else if (nPatType==2) {
+ ReadPattern(pPenStyle,pBrushStyle);
+ pPict->SeekRel(6); // RGBColor
+ nDataSize=16;
+ }
+ else nDataSize=0xffffffff;
+
+ return nDataSize;
+}
+
+ULONG PictReader::ReadAndDrawRect(PictDrawingMethod eMethod)
+{
+ ReadRectangle(aLastRect);
+ DrawingMethod(eMethod);
+ pVirDev->DrawRect(aLastRect);
+ return 8;
+}
+
+ULONG PictReader::ReadAndDrawSameRect(PictDrawingMethod eMethod)
+{
+ DrawingMethod(eMethod);
+ pVirDev->DrawRect(aLastRect);
+ return 0;
+}
+
+ULONG PictReader::ReadAndDrawRoundRect(PictDrawingMethod eMethod)
+{
+ ReadRectangle(aLastRoundRect);
+ DrawingMethod(eMethod);
+ pVirDev->DrawRect(aLastRoundRect,aActOvalSize.Width(),aActOvalSize.Height());
+ return 8;
+}
+
+ULONG PictReader::ReadAndDrawSameRoundRect(PictDrawingMethod eMethod)
+{
+ DrawingMethod(eMethod);
+ pVirDev->DrawRect(aLastRoundRect,aActOvalSize.Width(),aActOvalSize.Height());
+ return 0;
+}
+
+ULONG PictReader::ReadAndDrawOval(PictDrawingMethod eMethod)
+{
+ ReadRectangle(aLastOval);
+ DrawingMethod(eMethod);
+ pVirDev->DrawEllipse(aLastOval);
+ return 8;
+}
+
+ULONG PictReader::ReadAndDrawSameOval(PictDrawingMethod eMethod)
+{
+ DrawingMethod(eMethod);
+ pVirDev->DrawEllipse(aLastOval);
+ return 0;
+}
+
+ULONG PictReader::ReadAndDrawPolygon(PictDrawingMethod eMethod)
+{
+ ULONG nDataSize;
+
+ nDataSize=ReadPolygon(aLastPolygon);
+ DrawingMethod(eMethod);
+ if (eMethod==PDM_FRAME) pVirDev->DrawPolyLine(aLastPolygon);
+ else pVirDev->DrawPolygon(aLastPolygon);
+ return nDataSize;
+}
+
+ULONG PictReader::ReadAndDrawSamePolygon(PictDrawingMethod eMethod)
+{
+ DrawingMethod(eMethod);
+ if (eMethod==PDM_FRAME) pVirDev->DrawPolyLine(aLastPolygon);
+ else pVirDev->DrawPolygon(aLastPolygon);
+ return 0;
+}
+
+
+ULONG PictReader::ReadAndDrawArc(PictDrawingMethod eMethod)
+{
+ short nstartAngle, narcAngle;
+ double fAng1, fAng2;
+ Point aStartPt, aEndPt, aCenter;
+
+ ReadRectangle(aLastArcRect);
+ *pPict >> nstartAngle >> narcAngle;
+ if (narcAngle<0) {
+ nstartAngle+=narcAngle;
+ narcAngle=-narcAngle;
+ }
+ fAng1=((double)nstartAngle)/180.0*3.14159265359;
+ fAng2=((double)(nstartAngle+narcAngle))/180.0*3.14159265359;
+ aCenter=Point((aLastArcRect.Left()+aLastArcRect.Right())/2,
+ (aLastArcRect.Top()+aLastArcRect.Bottom())/2);
+ aStartPt=Point(aCenter.X()+(long)( sin(fAng2)*256.0),
+ aCenter.Y()+(long)(-cos(fAng2)*256.0));
+ aEndPt= Point(aCenter.X()+(long)( sin(fAng1)*256.0),
+ aCenter.Y()+(long)(-cos(fAng1)*256.0));
+ DrawingMethod(eMethod);
+ if (eMethod==PDM_FRAME) pVirDev->DrawArc(aLastArcRect,aStartPt,aEndPt);
+ else pVirDev->DrawPie(aLastArcRect,aStartPt,aEndPt);
+ return 12;
+}
+
+ULONG PictReader::ReadAndDrawSameArc(PictDrawingMethod eMethod)
+{
+ short nstartAngle, narcAngle;
+ double fAng1, fAng2;
+ Point aStartPt, aEndPt, aCenter;
+
+ *pPict >> nstartAngle >> narcAngle;
+ if (narcAngle<0) {
+ nstartAngle+=narcAngle;
+ narcAngle=-narcAngle;
+ }
+ fAng1=((double)nstartAngle)/180.0*3.14159265359;
+ fAng2=((double)(nstartAngle+narcAngle))/180.0*3.14159265359;
+ aCenter=Point((aLastArcRect.Left()+aLastArcRect.Right())/2,
+ (aLastArcRect.Top()+aLastArcRect.Bottom())/2);
+ aStartPt=Point(aCenter.X()+(long)( sin(fAng2)*256.0),
+ aCenter.Y()+(long)(-cos(fAng2)*256.0));
+ aEndPt= Point(aCenter.X()+(long)( sin(fAng1)*256.0),
+ aCenter.Y()+(long)(-cos(fAng1)*256.0));
+ DrawingMethod(eMethod);
+ if (eMethod==PDM_FRAME) pVirDev->DrawArc(aLastArcRect,aStartPt,aEndPt);
+ else pVirDev->DrawPie(aLastArcRect,aStartPt,aEndPt);
+ return 4;
+}
+
+ULONG PictReader::ReadAndDrawRgn(PictDrawingMethod eMethod)
+{
+ USHORT nSize;
+
+ DrawingMethod(eMethod);
+ *pPict >> nSize;
+ // ...???...
+ return (ULONG)nSize;
+}
+
+ULONG PictReader::ReadAndDrawSameRgn(PictDrawingMethod eMethod)
+{
+ DrawingMethod(eMethod);
+ // ...???...
+ return 0;
+}
+
+void PictReader::DrawingMethod(PictDrawingMethod eMethod)
+{
+ if( eActMethod==eMethod ) return;
+ switch (eMethod) {
+ case PDM_FRAME:
+ SetPen( aActForeColor, nActPenSize, eActPenPenStyle );
+ SetBrush( Color(COL_TRANSPARENT), Color(COL_TRANSPARENT), BRUSH_NULL );
+ pVirDev->SetRasterOp(eActROP);
+ break;
+ case PDM_PAINT:
+ SetPen( Color(COL_TRANSPARENT), 0, PEN_NULL );
+ SetBrush( aActForeColor, aActBackColor, eActPenBrushStyle );
+ pVirDev->SetRasterOp(eActROP);
+ break;
+ case PDM_ERASE:
+ SetPen( Color(COL_TRANSPARENT), 0, PEN_NULL );
+ SetBrush( aActForeColor, aActBackColor, eActPenBrushStyle );
+ pVirDev->SetRasterOp(ROP_OVERPAINT);
+ break;
+ case PDM_INVERT:
+ SetPen( Color(COL_TRANSPARENT), 0, PEN_NULL );
+ SetBrush( Color( COL_BLACK ), Color( COL_BLACK ), BRUSH_SOLID );
+ pVirDev->SetRasterOp(ROP_INVERT);
+ break;
+ case PDM_FILL:
+ SetPen( Color(COL_TRANSPARENT), 0, PEN_NULL );
+ SetBrush( aActForeColor, aActBackColor, eActPenBrushStyle );
+ pVirDev->SetRasterOp(ROP_OVERPAINT);
+ break;
+ case PDM_TEXT:
+ aActFont.SetColor(aActForeColor);
+ aActFont.SetFillColor(aActBackColor);
+ aActFont.SetTransparent(TRUE);
+ pVirDev->SetFont(aActFont);
+ pVirDev->SetRasterOp(ROP_OVERPAINT);
+ break;
+ }
+ eActMethod=eMethod;
+}
+
+ULONG PictReader::ReadAndDrawText()
+{
+ char nByteLen;
+ ULONG nLen,i,nDataLen;
+ char sText[256];
+
+ DrawingMethod(PDM_TEXT);
+ *pPict >> nByteLen; nLen=((ULONG)nByteLen)&0x000000ff;
+ nDataLen=nLen+1;
+
+ for ( i = 0; i < nLen; i++ )
+ {
+ *pPict >> sText[i];
+ }
+
+ // Stoerende Steuerzeuichen wegnehmen:
+ while (nLen>0 && ((unsigned char)sText[nLen-1])<32) nLen--;
+
+ sText[nLen]=0;
+
+ pVirDev->DrawText( Point( aTextPosition.X(), aTextPosition.Y() ), String::CreateFromAscii( sText ) );
+
+ return nDataLen;
+}
+
+ULONG PictReader::ReadPixMapEtc( Bitmap &rBitmap, BOOL bBaseAddr, BOOL bColorTable, Rectangle* pSrcRect,
+ Rectangle* pDestRect, BOOL bMode, BOOL bMaskRgn )
+{
+ Bitmap aBitmap;
+ BitmapWriteAccess* pAcc = NULL;
+ BitmapReadAccess* pReadAcc = NULL;
+ USHORT ny, nx, nColTabSize;
+ USHORT nRowBytes, nBndX, nBndY, nWidth, nHeight, nVersion, nPackType, nPixelType,
+ nPixelSize, nCmpCount, nCmpSize;
+ ULONG nPackSize, nPlaneBytes, nHRes, nVRes;
+ BYTE nDat, nRed, nGreen, nBlue, nDummy;
+ ULONG i, nDataSize = 0;
+
+ // In nDataSize wird mitgerechnet, wie gross die gesammten Daten sind.
+ nDataSize = 0;
+
+ // ggf. BaseAddr ueberlesen
+ if ( bBaseAddr )
+ {
+ pPict->SeekRel( 4 );
+ nDataSize += 4;
+ }
+
+ // PixMap oder Bitmap-Struktur einlesen;
+ *pPict >> nRowBytes >> nBndY >> nBndX >> nHeight >> nWidth;
+ nHeight -= nBndY;
+ nWidth -= nBndX;
+
+ if ( ( nRowBytes & 0x8000 ) != 0 )
+ {
+ nRowBytes &= 0x3fff;
+ *pPict >> nVersion >> nPackType >> nPackSize >> nHRes >> nVRes >> nPixelType >>
+ nPixelSize >> nCmpCount >> nCmpSize >> nPlaneBytes;
+
+ pPict->SeekRel( 8 );
+ nDataSize += 46;
+ aBitmap = Bitmap( Size( nWidth, nHeight ), ( nPixelSize > 8 ) ? 24 : nPixelSize );
+
+ if ( ( pAcc = aBitmap.AcquireWriteAccess() ) == NULL )
+ BITMAPERROR;
+
+ if ( bColorTable )
+ {
+ pPict->SeekRel( 6 );
+ *pPict >> nColTabSize;
+
+ if ( ++nColTabSize > 256 )
+ BITMAPERROR;
+
+ pAcc->SetPaletteEntryCount( nColTabSize );
+
+ for ( i = 0; i < nColTabSize; i++ )
+ {
+ pPict->SeekRel(2);
+ *pPict >> nRed >> nDummy >> nGreen >> nDummy >> nBlue >> nDummy;
+ pAcc->SetPaletteColor( (USHORT) i, BitmapColor( nRed, nGreen, nBlue ) );
+ }
+ nDataSize += 8 + nColTabSize * 8;
+ }
+ }
+ else
+ {
+ nRowBytes &= 0x3fff;
+ nVersion = 0;
+ nPackType = 0;
+ nPackSize = nHRes = nVRes = nPlaneBytes = 0;
+ nPixelType = 0;
+ nPixelSize = nCmpCount = nCmpSize = 1;
+ nDataSize += 10;
+ aBitmap = Bitmap( Size( nWidth, nHeight ), 1 );
+ if ( ( pAcc = aBitmap.AcquireWriteAccess() ) == NULL )
+ BITMAPERROR;
+ pAcc->SetPaletteEntryCount( 2 );
+ pAcc->SetPaletteColor( 0, BitmapColor( 0xff, 0xff, 0xff ) );
+ pAcc->SetPaletteColor( 1, BitmapColor( 0, 0, 0 ) );
+ }
+
+ // ggf. Quell-Rechteck einlesen:
+ if ( pSrcRect != 0)
+ {
+ USHORT nTop, nLeft, nBottom, nRight;
+ *pPict >> nTop >> nLeft >> nBottom >> nRight;
+ *pSrcRect = Rectangle( (ULONG)nLeft, (ULONG)nTop, (ULONG)nRight, (ULONG)nBottom );
+ nDataSize += 8;
+ }
+
+ // ggf. Ziel-Rechteck einlesen:
+ if ( pDestRect != 0 )
+ {
+ Point aTL, aBR;
+ aTL = ReadPoint();
+ aBR = ReadPoint();
+ *pDestRect = Rectangle( aTL, aBR );
+ nDataSize += 8;
+ }
+
+ // ggf. Modus einlesen (bzw. ueberspringen):
+ if ( bMode )
+ {
+ pPict->SeekRel(2);
+ nDataSize += 2;
+ }
+
+ // ggf. Region einlesen (bzw. ueberspringen):
+ if ( bMaskRgn )
+ {
+ USHORT nSize;
+ *pPict >> nSize;
+ pPict->SeekRel( nSize - 2 );
+ nDataSize += (ULONG)nSize;
+ }
+
+// aSMem << (nHRes/1665L) << (nVRes/1665L) << ((ULONG)0) << ((ULONG)0);
+
+ // Lese und Schreibe Bitmap-Bits:
+ if ( nPixelSize == 1 || nPixelSize == 2 || nPixelSize == 4 || nPixelSize == 8 )
+ {
+ BYTE nByteCountAsByte, nFlagCounterByte;
+ USHORT nByteCount, nCount, nSrcBPL, nDestBPL;
+
+ if ( nPixelSize == 1 ) nSrcBPL = ( nWidth + 7 ) >> 3;
+ else if ( nPixelSize == 2 ) nSrcBPL = ( nWidth + 3 ) >> 2;
+ else if ( nPixelSize == 4 ) nSrcBPL = ( nWidth + 1 ) >> 1;
+ else nSrcBPL = nWidth;
+ nDestBPL = ( nSrcBPL + 3 ) & 0xfffc;
+ if ( nRowBytes < nSrcBPL || nRowBytes > nDestBPL )
+ BITMAPERROR;
+
+ for ( ny = 0; ny < nHeight; ny++ )
+ {
+ nx = 0;
+ if ( nRowBytes < 8 || nPackType == 1 )
+ {
+ for ( i = 0; i < nRowBytes; i++ )
+ SETBYTE;
+ nDataSize += nRowBytes;
+ }
+ else
+ {
+ if ( nRowBytes > 250 )
+ {
+ *pPict >> nByteCount;
+ nDataSize += 2 + (ULONG)nByteCount;
+ }
+ else
+ {
+ *pPict >> nByteCountAsByte;
+ nByteCount = ( (USHORT)nByteCountAsByte ) & 0x00ff;
+ nDataSize += 1 + (ULONG)nByteCount;
+ }
+
+ while ( nByteCount )
+ {
+ *pPict >> nFlagCounterByte;
+ if ( ( nFlagCounterByte & 0x80 ) == 0 )
+ {
+ nCount = ( (USHORT)nFlagCounterByte ) + 1;
+ for ( i = 0; i < nCount; i++ )
+ {
+ *pPict >> nDat;
+ if ( nx < nWidth )
+ SETBYTE;
+ }
+ nByteCount -= 1 + nCount;
+ }
+ else
+ {
+ nCount = ( 1 - ( ( (USHORT)nFlagCounterByte ) | 0xff00 ) ) & 0xffff;
+ *pPict >> nDat;
+ for ( i = 0; i < nCount; i++ )
+ {
+ if ( nx < nWidth )
+ SETBYTE;
+ }
+ nByteCount -= 2;
+ }
+ }
+ }
+ }
+ }
+ else if ( nPixelSize == 16 )
+ {
+ BYTE nByteCountAsByte, nFlagCounterByte;
+ USHORT nByteCount, nCount, nDestBPL,nD;
+ ULONG nSrcBitsPos;
+
+ if ( nRowBytes < 2 * nWidth )
+ BITMAPERROR;
+
+ nDestBPL = ( ( 3 * nWidth ) + 0x0003 ) & 0xfffc;
+
+ for ( ny = 0; ny < nHeight; ny++ )
+ {
+ nx = 0;
+ if ( nRowBytes < 8 || nPackType == 1 )
+ {
+ for ( i = 0; i < nWidth; i++ )
+ {
+ *pPict >> nD;
+ nRed = (BYTE)( nD >> 7 );
+ nGreen = (BYTE)( nD >> 2 );
+ nBlue = (BYTE)( nD << 3 );
+ pAcc->SetPixel( ny, nx++, BitmapColor( nRed, nGreen, nBlue ) );
+ }
+ nDataSize += ( (ULONG)nWidth ) * 2;
+ }
+ else
+ {
+ nSrcBitsPos = pPict->Tell();
+ if ( nRowBytes > 250 )
+ {
+ *pPict >> nByteCount;
+ nByteCount += 2;
+ }
+ else
+ {
+ *pPict >> nByteCountAsByte;
+ nByteCount = ( (USHORT)nByteCountAsByte ) & 0x00ff;
+ nByteCount++;
+ }
+ while ( nx != nWidth )
+ {
+ *pPict >> nFlagCounterByte;
+ if ( (nFlagCounterByte & 0x80) == 0)
+ {
+ nCount=((USHORT)nFlagCounterByte)+1;
+ if ( nCount + nx > nWidth)
+ nCount = nWidth - nx;
+ for (i=0; i<nCount; i++)
+ {
+ *pPict >> nD;
+ nRed = (BYTE)( nD >> 7 );
+ nGreen = (BYTE)( nD >> 2 );
+ nBlue = (BYTE)( nD << 3 );
+ pAcc->SetPixel( ny, nx++, BitmapColor( nRed, nGreen, nBlue ) );
+ }
+ }
+ else
+ {
+ nCount=(1-(((USHORT)nFlagCounterByte)|0xff00))&0xffff;
+ if ( nCount + nx > nWidth )
+ nCount = nWidth - nx;
+ *pPict >> nD;
+ nRed = (BYTE)( nD >> 7 );
+ nGreen = (BYTE)( nD >> 2 );
+ nBlue = (BYTE)( nD << 3 );
+ for (i=0; i<nCount; i++)
+ {
+ pAcc->SetPixel( ny, nx++, BitmapColor( nRed, nGreen, nBlue ) );
+ }
+ }
+ }
+ nDataSize+=(ULONG)nByteCount;
+ pPict->Seek(nSrcBitsPos+(ULONG)nByteCount);
+ }
+ }
+ }
+ else if (nPixelSize==32)
+ {
+ BYTE nByteCountAsByte, nFlagCounterByte;
+ USHORT nByteCount, nCount, nDestBPL,nc;
+ ULONG nSrcBitsPos;
+ BitmapColor aBitmapColor;
+ if ( ( pReadAcc = aBitmap.AcquireReadAccess() ) == NULL )
+ BITMAPERROR;
+ if ( nRowBytes != 4*nWidth )
+ BITMAPERROR;
+ nDestBPL = ( ( 3 * nWidth ) + 0x0003 ) & 0xfffc;
+
+ for ( ny = 0; ny < nHeight; ny++ )
+ {
+ nx = 0;
+ if ( nRowBytes < 8 || nPackType == 1 )
+ {
+ for ( i = 0; i < nWidth; i++ )
+ {
+ *pPict >> nDummy >> nRed >> nGreen >> nBlue;
+ pAcc->SetPixel( ny, nx++, BitmapColor( nRed, nGreen, nBlue) );
+ }
+ nDataSize += ( (ULONG)nWidth ) * 4;
+ }
+ else if ( nPackType == 2 )
+ {
+ for ( i = 0; i < nWidth; i++ )
+ {
+ *pPict >> nRed >> nGreen >> nBlue;
+ pAcc->SetPixel( ny, nx++, BitmapColor( nRed, nGreen, nBlue ) );
+ }
+ nDataSize += ( (ULONG)nWidth ) * 3;
+ }
+ else
+ {
+ nSrcBitsPos = pPict->Tell();
+ if ( nRowBytes > 250 )
+ {
+ *pPict >> nByteCount;
+ nByteCount += 2;
+ }
+ else
+ {
+ *pPict >> nByteCountAsByte;
+ nByteCount = (BYTE)nByteCountAsByte;
+ nByteCount++;
+ }
+ for ( nc = 0; nc < 4; nc++ )
+ {
+ nx = 0;
+ while ( nx != nWidth )
+ {
+ *pPict >> nFlagCounterByte;
+ if ( ( nFlagCounterByte & 0x80 ) == 0)
+ {
+ nCount = ( (USHORT)nFlagCounterByte ) + 1;
+ BOOL nSeekStream = 0;
+ if ( ( nCount + nx ) > nWidth )
+ {
+ nSeekStream = nCount - nWidth + nx;
+ nCount = nWidth - nx;
+ }
+ for ( i = 0; i < nCount; i++ )
+ {
+ *pPict >> nDat;
+ switch( nc )
+ {
+ case 0 :
+ nx++;
+ break;
+ case 1 :
+ pAcc->SetPixel( ny, nx++, BitmapColor( nDat, 0, 0 ) );
+ break;
+ case 2 :
+ aBitmapColor = pReadAcc->GetPixel( ny, nx );
+ aBitmapColor.SetGreen( nDat );
+ pAcc->SetPixel( ny, nx++, aBitmapColor );
+ break;
+ case 3 :
+ aBitmapColor = pReadAcc->GetPixel( ny, nx );
+ aBitmapColor.SetBlue( nDat );
+ pAcc->SetPixel( ny, nx++, aBitmapColor );
+ break;
+ }
+ }
+ if ( nSeekStream )
+ pPict->SeekRel( nSeekStream );
+ }
+ else
+ {
+ nCount = ( 1 - ( ( (USHORT)nFlagCounterByte ) | 0xff00 ) );
+ if ( nCount + nx > nWidth )
+ nCount = nWidth - nx;
+ *pPict >> nDat;
+ for ( i = 0; i < nCount; i++ )
+ {
+ switch( nc )
+ {
+ case 0 :
+ nx++;
+ break;
+ case 1 :
+ pAcc->SetPixel( ny, nx++, BitmapColor( nDat, 0, 0 ) );
+ break;
+ case 2 :
+ aBitmapColor = pReadAcc->GetPixel( ny, nx );
+ aBitmapColor.SetGreen( nDat );
+ pAcc->SetPixel( ny, nx++, aBitmapColor );
+ break;
+ case 3 :
+ aBitmapColor = pReadAcc->GetPixel( ny, nx );
+ aBitmapColor.SetBlue( nDat );
+ pAcc->SetPixel( ny, nx++, aBitmapColor );
+ break;
+ }
+ }
+ }
+ }
+ }
+ nDataSize += (ULONG)nByteCount;
+ pPict->Seek( nSrcBitsPos + (ULONG)nByteCount );
+ }
+ }
+ }
+ else
+ BITMAPERROR;
+ if ( pReadAcc )
+ aBitmap.ReleaseAccess( pReadAcc );
+ aBitmap.ReleaseAccess( pAcc );
+ rBitmap = aBitmap;
+ return nDataSize;
+}
+
+void PictReader::ReadHeader()
+{
+ char nC;
+ short y1,x1,y2,x2;
+
+ sal_Char sBuf[ 3 ];
+ pPict->SeekRel( 10 );
+ pPict->Read( sBuf, 3 );
+ if ( sBuf[ 0 ] == 0x00 && sBuf[ 1 ] == 0x11 && ( sBuf[ 2 ] == 0x01 || sBuf[ 2 ] == 0x02 ) )
+ pPict->SeekRel( -13 ); // this maybe a pict from a ms document
+ else
+ pPict->SeekRel( 512 - 13 ); // 512 Bytes Muell am Anfang
+
+ pPict->SeekRel(2); // Lo-16-bits von "picture size"
+ *pPict >> y1 >> x1 >> y2 >> x2; // Rahmen-Rechteck des Bildes
+ aBoundingRect=Rectangle( x1,y1, --x2, --y2 );
+
+ // Jetzt kommen x-beliebig viele Nullen
+ // (in manchen Dateien tatsaechlich mehr als eine):
+ do { *pPict >> nC; } while (nC==0 && pPict->IsEof()==FALSE);
+
+ // dann sollte der Versions-Opcode 0x11 folgen, dann die Versionsnummer:
+ if (nC==0x11)
+ {
+ *pPict >> nC;
+ if ( nC == 0x01 )
+ IsVersion2 = FALSE; // Version 1
+ else // Version 2 oder hoeher
+ {
+ short nExtVer;
+ ULONG nTempX;
+ ULONG nTempY;
+
+ // 3 Bytes ueberspringen, um auf
+ // ExtVersion2 oder Version2 zu kommen
+ pPict->SeekRel( 3 );
+ *pPict >> nExtVer;
+
+ // nachsehen, ob wir einen Extended-Version2-Header (==-2) haben
+ // oder einen einfachen Version2-Header (==-1);
+ // dementsprechend Aufloesung einlesen oder nicht
+ if ( nExtVer == -2 )
+ {
+ // Horizontale Skalierung als Bruch ( bzgl. 72 DPI )
+ *pPict >> nTempX;
+ nTempX &= 0x0000ffff;
+
+ // Vertikale Skalierung als Bruch ( bzgl. 72 DPI )
+ *pPict >> nTempY;
+ nTempY &= 0x0000ffff;
+
+ // nachfolgender Code soll nicht beeinflusst werden
+ pPict->SeekRel( -12 );
+ }
+ else
+ {
+ nTempX = nTempY = 72;
+
+ // nachfolgender Code soll nicht beeinflusst werden
+ pPict->SeekRel( -4 );
+ }
+
+ // gefundene Aufloesung setzen
+ aHRes = Fraction( 72, nTempX );
+ aVRes = Fraction( 72, nTempY );
+
+ IsVersion2=TRUE;
+ }
+ }
+ else {
+ // Eigentlich ist dies wohl kein Pict-File, aber es gibt tatsaechlich
+ // Dateien, bei denen mehr als 512 Bytes "Muell" am Anfang stehen.
+ // Somit koennte es theoretisch folgende Art von Header geben:
+ // <beliebig viele Bytes Muell> <Picture-Size (Lo-Bytes)> <BoundingRect>
+ // <beliebig viele Nullen> <0x11> ..
+ // Da aber in so einem Fall die Position von <BoundingRect> kaum auszumachen ist,
+ // gehen wir nun davon aus, dass in einer Datei immer entweder genau 512 Bytes Muell
+ // am Anfang sind (wie oben versucht), oder (wie normalerweise ueblich) genau eine 0 zwischen
+ // Bounding-Rectangle und 0x11. Des weiteren mag es hoechstens 1024 Bytes Muell geben,
+ // und das Ganze nur fuer Version 1 oder 2.
+ // Somit suchen wir nun nach der Folge 0x00,0x11,0x01 oder 0x00,0x11,0x02 innerhalb der
+ // "zweiten" 512 Bytes, und nehmen an, dass davor das Bounding-Rect steht, und hoffen
+ // dass das alles so seine Richtigkeit hat.
+ BYTE n1,n2,n3;
+ USHORT i,Found;
+ pPict->Seek(522);
+ Found=0;
+ *pPict >> n1 >> n2 >> n3;
+ for (i=0; i<512; i++) {
+ if (n1==0x00 && n2==0x11 && (n3==0x01 || n3==0x02)) { Found=1; break; }
+ n1=n2; n2=n3; *pPict >> n3;
+ }
+ if (Found!=0) {
+ pPict->SeekRel(-11);
+ *pPict >> y1 >> x1 >> y2 >> x2;
+ // Lieber nochmal nachsehen, ob das Bounding-Rectangle gut zu sein scheint:
+ if (x1+10<x2 && y1+10<y2 && y1>=-2048 && x1>=-2048 && x2<=2048 && y2<=2048) {
+ aBoundingRect=Rectangle( x1, y1, --x2, --y2 );
+ if (n3==0x01) {
+ pPict->SeekRel(3);
+ IsVersion2=FALSE;
+ }
+ else {
+ pPict->SeekRel(4);
+ IsVersion2=TRUE;
+ }
+ }
+ else pPict->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ }
+ else pPict->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ }
+}
+
+
+ULONG PictReader::ReadData(USHORT nOpcode)
+{
+ USHORT nUSHORT;
+ Point aPoint;
+ ULONG nDataSize=0;
+
+ switch(nOpcode) {
+
+ case 0x0000: // NOP
+ nDataSize=0;
+ break;
+
+ case 0x0001: { // Clip
+ Rectangle aRect;
+ *pPict >> nUSHORT;
+ nDataSize=nUSHORT;
+ ReadRectangle(aRect);
+ pVirDev->SetClipRegion( Region( aRect ) );
+ break;
+ }
+ case 0x0002: // BkPat
+ nDataSize=ReadPattern(NULL,&eActBackStyle);
+ eActMethod=PDM_UNDEFINED;
+ break;
+
+ case 0x0003: // TxFont
+ *pPict >> nUSHORT;
+ if (nUSHORT <= 1) aActFont.SetFamily(FAMILY_SWISS);
+ else if (nUSHORT <= 12) aActFont.SetFamily(FAMILY_DECORATIVE);
+ else if (nUSHORT <= 20) aActFont.SetFamily(FAMILY_ROMAN);
+ else if (nUSHORT == 21) aActFont.SetFamily(FAMILY_SWISS);
+ else if (nUSHORT == 22) aActFont.SetFamily(FAMILY_MODERN);
+ else if (nUSHORT <= 1023) aActFont.SetFamily(FAMILY_SWISS);
+ else aActFont.SetFamily(FAMILY_ROMAN);
+ if ( nUSHORT == 23 ) aActFont.SetCharSet( RTL_TEXTENCODING_SYMBOL );
+ else aActFont.SetCharSet( gsl_getSystemTextEncoding() );
+ eActMethod=PDM_UNDEFINED;
+ nDataSize=2;
+ break;
+
+ case 0x0004: { // TxFace
+ char nFace;
+ *pPict >> nFace;
+ if ( (nFace & 0x01)!=0 ) aActFont.SetWeight(WEIGHT_BOLD);
+ else aActFont.SetWeight(WEIGHT_NORMAL);
+ if ( (nFace & 0x02)!=0 ) aActFont.SetItalic(ITALIC_NORMAL);
+ else aActFont.SetItalic(ITALIC_NONE);
+ if ( (nFace & 0x04)!=0 ) aActFont.SetUnderline(UNDERLINE_SINGLE);
+ else aActFont.SetUnderline(UNDERLINE_NONE);
+ if ( (nFace & 0x08)!=0 ) aActFont.SetOutline(TRUE);
+ else aActFont.SetOutline(FALSE);
+ if ( (nFace & 0x10)!=0 ) aActFont.SetShadow(TRUE);
+ else aActFont.SetShadow(FALSE);
+ eActMethod=PDM_UNDEFINED;
+ nDataSize=1;
+ break;
+ }
+ case 0x0005: // TxMode
+ nDataSize=2;
+ break;
+
+ case 0x0006: // SpExtra
+ nDataSize=4;
+ break;
+
+ case 0x0007: { // PnSize
+ Size aSize;
+ aSize=ReadSize();
+ nActPenSize=(USHORT)((aSize.Width()+aSize.Height())/2);
+ eActMethod=PDM_UNDEFINED;
+ nDataSize=4;
+ break;
+ }
+ case 0x0008: // PnMode
+ *pPict >> nUSHORT;
+ switch (nUSHORT & 0x0007) {
+ case 0: eActROP=ROP_OVERPAINT; break; // Copy
+ case 1: eActROP=ROP_OVERPAINT; break; // Or
+ case 2: eActROP=ROP_XOR; break; // Xor
+ case 3: eActROP=ROP_OVERPAINT; break; // Bic
+ case 4: eActROP=ROP_INVERT; break; // notCopy
+ case 5: eActROP=ROP_OVERPAINT; break; // notOr
+ case 6: eActROP=ROP_XOR; break; // notXor
+ case 7: eActROP=ROP_OVERPAINT; break; // notBic
+ }
+ eActMethod=PDM_UNDEFINED;
+ nDataSize=2;
+ break;
+
+ case 0x0009: // PnPat
+ nDataSize=ReadPattern(&eActPenPenStyle,&eActPenBrushStyle);
+ eActMethod=PDM_UNDEFINED;
+ break;
+
+ case 0x000a: // FillPat
+ nDataSize=ReadPattern(NULL,&eActFillStyle);
+ eActMethod=PDM_UNDEFINED;
+ break;
+
+ case 0x000b: // OvSize
+ aActOvalSize=ReadSize();
+ nDataSize=4;
+ break;
+
+ case 0x000c: // Origin
+ nDataSize=4;
+ break;
+
+ case 0x000d: // TxSize
+ {
+ *pPict >> nUSHORT;
+
+ long nTemp = Max( (long) ( Fraction( (long) nUSHORT ) * aVRes ), 12L );
+ aActFont.SetSize( Size( 0, nTemp ) );
+
+ eActMethod=PDM_UNDEFINED;
+ nDataSize=2;
+ }
+ break;
+
+ case 0x000e: // FgColor
+ aActForeColor=ReadColor();
+ eActMethod=PDM_UNDEFINED;
+ nDataSize=4;
+ break;
+
+ case 0x000f: // BkColor
+ aActBackColor=ReadColor();
+ nDataSize=4;
+ break;
+
+ case 0x0010: // TxRatio
+ nDataSize=8;
+ break;
+
+ case 0x0011: // VersionOp
+ nDataSize=1;
+ break;
+
+ case 0x0012: // BkPixPat
+ nDataSize=ReadPixPattern(NULL,&eActBackStyle);
+ eActMethod=PDM_UNDEFINED;
+ break;
+
+ case 0x0013: // PnPixPat
+ nDataSize=ReadPixPattern(&eActPenPenStyle,&eActPenBrushStyle);
+ eActMethod=PDM_UNDEFINED;
+ break;
+
+ case 0x0014: // FillPixPat
+ nDataSize=ReadPixPattern(NULL,&eActFillStyle);
+ eActMethod=PDM_UNDEFINED;
+ break;
+
+ case 0x0015: // PnLocHFrac
+ nDataSize=2;
+ break;
+
+ case 0x0016: // ChExtra
+ nDataSize=2;
+ break;
+
+ case 0x0017: // Reserved (0 Bytes)
+ case 0x0018: // Reserved (0 Bytes)
+ case 0x0019: // Reserved (0 Bytes)
+ nDataSize=0;
+ break;
+
+ case 0x001a: // RGBFgCol
+ aActForeColor=ReadRGBColor();
+ eActMethod=PDM_UNDEFINED;
+ nDataSize=6;
+ break;
+
+ case 0x001b: // RGBBkCol
+ aActBackColor=ReadRGBColor();
+ eActMethod=PDM_UNDEFINED;
+ nDataSize=6;
+ break;
+
+ case 0x001c: // HiliteMode
+ nDataSize=0;
+ break;
+
+ case 0x001d: // HiliteColor
+ nDataSize=6;
+ break;
+
+ case 0x001e: // DefHilite
+ nDataSize=0;
+ break;
+
+ case 0x001f: // OpColor
+ nDataSize=6;
+ break;
+
+ case 0x0020: // Line
+ aPoint=ReadPoint(); aPenPosition=ReadPoint();
+ DrawingMethod(PDM_FRAME);
+ pVirDev->DrawLine(aPoint,aPenPosition);
+ nDataSize=8;
+ break;
+
+ case 0x0021: // LineFrom
+ aPoint=aPenPosition; aPenPosition=ReadPoint();
+ DrawingMethod(PDM_FRAME);
+ pVirDev->DrawLine(aPoint,aPenPosition);
+ nDataSize=4;
+ break;
+
+ case 0x0022: // ShortLine
+ aPoint=ReadPoint();
+ aPenPosition=ReadDeltaH(aPoint);
+ aPenPosition=ReadDeltaV(aPenPosition);
+ DrawingMethod(PDM_FRAME);
+ pVirDev->DrawLine(aPoint,aPenPosition);
+ nDataSize=6;
+ break;
+
+ case 0x0023: // ShortLineFrom
+ aPoint=aPenPosition;
+ aPenPosition=ReadDeltaH(aPoint);
+ aPenPosition=ReadDeltaV(aPenPosition);
+ DrawingMethod(PDM_FRAME);
+ pVirDev->DrawLine(aPoint,aPenPosition);
+ nDataSize=2;
+ break;
+
+ case 0x0024: // Reserved (n Bytes)
+ case 0x0025: // Reserved (n Bytes)
+ case 0x0026: // Reserved (n Bytes)
+ case 0x0027: // Reserved (n Bytes)
+ *pPict >> nUSHORT;
+ nDataSize=2+nUSHORT;
+ break;
+
+ case 0x0028: // LongText
+ aTextPosition=ReadPoint();
+ nDataSize=4+ReadAndDrawText();
+ break;
+
+ case 0x0029: // DHText
+ aTextPosition=ReadUnsignedDeltaH(aTextPosition);
+ nDataSize=1+ReadAndDrawText();
+ break;
+
+ case 0x002a: // DVText
+ aTextPosition=ReadUnsignedDeltaV(aTextPosition);
+ nDataSize=1+ReadAndDrawText();
+ break;
+
+ case 0x002b: // DHDVText
+ aTextPosition=ReadUnsignedDeltaH(aTextPosition);
+ aTextPosition=ReadUnsignedDeltaV(aTextPosition);
+ nDataSize=2+ReadAndDrawText();
+ break;
+
+ case 0x002c: { // fontName
+ char sFName[256], nByteLen;
+ USHORT nLen,i;
+ *pPict >> nUSHORT; nDataSize=nUSHORT+2;
+ *pPict >> nUSHORT;
+ if (nUSHORT <= 1) aActFont.SetFamily(FAMILY_SWISS);
+ else if (nUSHORT <= 12) aActFont.SetFamily(FAMILY_DECORATIVE);
+ else if (nUSHORT <= 20) aActFont.SetFamily(FAMILY_ROMAN);
+ else if (nUSHORT == 21) aActFont.SetFamily(FAMILY_SWISS);
+ else if (nUSHORT == 22) aActFont.SetFamily(FAMILY_MODERN);
+ else if (nUSHORT <= 1023) aActFont.SetFamily(FAMILY_SWISS);
+ else aActFont.SetFamily(FAMILY_ROMAN);
+ if (nUSHORT==23) aActFont.SetCharSet( RTL_TEXTENCODING_SYMBOL);
+ else aActFont.SetCharSet( gsl_getSystemTextEncoding() );
+ *pPict >> nByteLen; nLen=((USHORT)nByteLen)&0x00ff;
+ for ( i = 0; i < nLen; i++ )
+ *pPict >> sFName[i];
+ sFName[ nLen ]=0;
+ aActFont.SetName( String::CreateFromAscii( sFName ) );
+ eActMethod=PDM_UNDEFINED;
+ break;
+ }
+ case 0x002d: // lineJustify
+ nDataSize=10;
+ break;
+
+ case 0x002e: // glyphState
+ *pPict >> nUSHORT;
+ nDataSize=2+nUSHORT;
+ break;
+
+ case 0x002f: // Reserved (n Bytes)
+ *pPict >> nUSHORT;
+ nDataSize=2+nUSHORT;
+ break;
+
+ case 0x0030: // frameRect
+ nDataSize=ReadAndDrawRect(PDM_FRAME);
+ break;
+
+ case 0x0031: // paintRect
+ nDataSize=ReadAndDrawRect(PDM_PAINT);
+ break;
+
+ case 0x0032: // eraseRect
+ nDataSize=ReadAndDrawRect(PDM_ERASE);
+ break;
+
+ case 0x0033: // invertRect
+ nDataSize=ReadAndDrawRect(PDM_INVERT);
+ break;
+
+ case 0x0034: // fillRect
+ nDataSize=ReadAndDrawRect(PDM_FILL);
+ break;
+
+ case 0x0035: // Reserved (8 Bytes)
+ case 0x0036: // Reserved (8 Bytes)
+ case 0x0037: // Reserved (8 Bytes)
+ nDataSize=8;
+ break;
+
+ case 0x0038: // frameSameRect
+ nDataSize=ReadAndDrawSameRect(PDM_FRAME);
+ break;
+
+ case 0x0039: // paintSameRect
+ nDataSize=ReadAndDrawSameRect(PDM_PAINT);
+ break;
+
+ case 0x003a: // eraseSameRect
+ nDataSize=ReadAndDrawSameRect(PDM_ERASE);
+ break;
+
+ case 0x003b: // invertSameRect
+ nDataSize=ReadAndDrawSameRect(PDM_INVERT);
+ break;
+
+ case 0x003c: // fillSameRect
+ nDataSize=ReadAndDrawSameRect(PDM_FILL);
+ break;
+
+ case 0x003d: // Reserved (0 Bytes)
+ case 0x003e: // Reserved (0 Bytes)
+ case 0x003f: // Reserved (0 Bytes)
+ nDataSize=0;
+ break;
+
+ case 0x0040: // frameRRect
+ nDataSize=ReadAndDrawRoundRect(PDM_FRAME);
+ break;
+
+ case 0x0041: // paintRRect
+ nDataSize=ReadAndDrawRoundRect(PDM_PAINT);
+ break;
+
+ case 0x0042: // eraseRRect
+ nDataSize=ReadAndDrawRoundRect(PDM_ERASE);
+ break;
+
+ case 0x0043: // invertRRect
+ nDataSize=ReadAndDrawRoundRect(PDM_INVERT);
+ break;
+
+ case 0x0044: // fillRRect
+ nDataSize=ReadAndDrawRoundRect(PDM_FILL);
+ break;
+
+ case 0x0045: // Reserved (8 Bytes)
+ case 0x0046: // Reserved (8 Bytes)
+ case 0x0047: // Reserved (8 Bytes)
+ nDataSize=8;
+ break;
+
+ case 0x0048: // frameSameRRect
+ nDataSize=ReadAndDrawSameRoundRect(PDM_FRAME);
+ break;
+
+ case 0x0049: // paintSameRRect
+ nDataSize=ReadAndDrawSameRoundRect(PDM_PAINT);
+ break;
+
+ case 0x004a: // eraseSameRRect
+ nDataSize=ReadAndDrawSameRoundRect(PDM_ERASE);
+ break;
+
+ case 0x004b: // invertSameRRect
+ nDataSize=ReadAndDrawSameRoundRect(PDM_INVERT);
+ break;
+
+ case 0x004c: // fillSameRRect
+ nDataSize=ReadAndDrawSameRoundRect(PDM_FILL);
+ break;
+
+ case 0x004d: // Reserved (0 Bytes)
+ case 0x004e: // Reserved (0 Bytes)
+ case 0x004f: // Reserved (0 Bytes)
+ nDataSize=0;
+ break;
+
+ case 0x0050: // frameOval
+ nDataSize=ReadAndDrawOval(PDM_FRAME);
+ break;
+
+ case 0x0051: // paintOval
+ nDataSize=ReadAndDrawOval(PDM_PAINT);
+ break;
+
+ case 0x0052: // eraseOval
+ nDataSize=ReadAndDrawOval(PDM_ERASE);
+ break;
+
+ case 0x0053: // invertOval
+ nDataSize=ReadAndDrawOval(PDM_INVERT);
+ break;
+
+ case 0x0054: // fillOval
+ nDataSize=ReadAndDrawOval(PDM_FILL);
+ break;
+
+ case 0x0055: // Reserved (8 Bytes)
+ case 0x0056: // Reserved (8 Bytes)
+ case 0x0057: // Reserved (8 Bytes)
+ nDataSize=8;
+ break;
+
+ case 0x0058: // frameSameOval
+ nDataSize=ReadAndDrawSameOval(PDM_FRAME);
+ break;
+
+ case 0x0059: // paintSameOval
+ nDataSize=ReadAndDrawSameOval(PDM_PAINT);
+ break;
+
+ case 0x005a: // eraseSameOval
+ nDataSize=ReadAndDrawSameOval(PDM_ERASE);
+ break;
+
+ case 0x005b: // invertSameOval
+ nDataSize=ReadAndDrawSameOval(PDM_INVERT);
+ break;
+
+ case 0x005c: // fillSameOval
+ nDataSize=ReadAndDrawSameOval(PDM_FILL);
+ break;
+
+ case 0x005d: // Reserved (0 Bytes)
+ case 0x005e: // Reserved (0 Bytes)
+ case 0x005f: // Reserved (0 Bytes)
+ nDataSize=0;
+ break;
+
+ case 0x0060: // frameArc
+ nDataSize=ReadAndDrawArc(PDM_FRAME);
+ break;
+
+ case 0x0061: // paintArc
+ nDataSize=ReadAndDrawArc(PDM_PAINT);
+ break;
+
+ case 0x0062: // eraseArc
+ nDataSize=ReadAndDrawArc(PDM_ERASE);
+ break;
+
+ case 0x0063: // invertArc
+ nDataSize=ReadAndDrawArc(PDM_INVERT);
+ break;
+
+ case 0x0064: // fillArc
+ nDataSize=ReadAndDrawArc(PDM_FILL);
+ break;
+
+ case 0x0065: // Reserved (12 Bytes)
+ case 0x0066: // Reserved (12 Bytes)
+ case 0x0067: // Reserved (12 Bytes)
+ nDataSize=12;
+ break;
+
+ case 0x0068: // frameSameArc
+ nDataSize=ReadAndDrawSameArc(PDM_FRAME);
+ break;
+
+ case 0x0069: // paintSameArc
+ nDataSize=ReadAndDrawSameArc(PDM_PAINT);
+ break;
+
+ case 0x006a: // eraseSameArc
+ nDataSize=ReadAndDrawSameArc(PDM_ERASE);
+ break;
+
+ case 0x006b: // invertSameArc
+ nDataSize=ReadAndDrawSameArc(PDM_INVERT);
+ break;
+
+ case 0x006c: // fillSameArc
+ nDataSize=ReadAndDrawSameArc(PDM_FILL);
+ break;
+
+ case 0x006d: // Reserved (4 Bytes)
+ case 0x006e: // Reserved (4 Bytes)
+ case 0x006f: // Reserved (4 Bytes)
+ nDataSize=4;
+ break;
+
+ case 0x0070: // framePoly
+ nDataSize=ReadAndDrawPolygon(PDM_FRAME);
+ break;
+
+ case 0x0071: // paintPoly
+ nDataSize=ReadAndDrawPolygon(PDM_PAINT);
+ break;
+
+ case 0x0072: // erasePoly
+ nDataSize=ReadAndDrawPolygon(PDM_ERASE);
+ break;
+
+ case 0x0073: // invertPoly
+ nDataSize=ReadAndDrawPolygon(PDM_INVERT);
+ break;
+
+ case 0x0074: // fillPoly
+ nDataSize=ReadAndDrawPolygon(PDM_FILL);
+ break;
+
+ case 0x0075: // Reserved (Polygon-Size)
+ case 0x0076: // Reserved (Polygon-Size)
+ case 0x0077: // Reserved (Polygon-Size)
+ *pPict >> nUSHORT; nDataSize=nUSHORT;
+ break;
+
+ case 0x0078: // frameSamePoly
+ nDataSize=ReadAndDrawSamePolygon(PDM_FRAME);
+ break;
+
+ case 0x0079: // paintSamePoly
+ nDataSize=ReadAndDrawSamePolygon(PDM_PAINT);
+ break;
+
+ case 0x007a: // eraseSamePoly
+ nDataSize=ReadAndDrawSamePolygon(PDM_ERASE);
+ break;
+
+ case 0x007b: // invertSamePoly
+ nDataSize=ReadAndDrawSamePolygon(PDM_INVERT);
+ break;
+
+ case 0x007c: // fillSamePoly
+ nDataSize=ReadAndDrawSamePolygon(PDM_FILL);
+ break;
+
+ case 0x007d: // Reserved (0 Bytes)
+ case 0x007e: // Reserved (0 Bytes)
+ case 0x007f: // Reserved (0 Bytes)
+ nDataSize=0;
+ break;
+
+ case 0x0080: // frameRgn
+ nDataSize=ReadAndDrawRgn(PDM_FILL);
+ break;
+
+ case 0x0081: // paintRgn
+ nDataSize=ReadAndDrawRgn(PDM_PAINT);
+ break;
+
+ case 0x0082: // eraseRgn
+ nDataSize=ReadAndDrawRgn(PDM_ERASE);
+ break;
+
+ case 0x0083: // invertRgn
+ nDataSize=ReadAndDrawRgn(PDM_INVERT);
+ break;
+
+ case 0x0084: // fillRgn
+ nDataSize=ReadAndDrawRgn(PDM_FILL);
+ break;
+
+ case 0x0085: // Reserved (Region-Size)
+ case 0x0086: // Reserved (Region-Size)
+ case 0x0087: // Reserved (Region-Size)
+ *pPict >> nUSHORT; nDataSize=nUSHORT;
+ break;
+
+ case 0x0088: // frameSameRgn
+ nDataSize=ReadAndDrawSameRgn(PDM_FRAME);
+ break;
+
+ case 0x0089: // paintSameRgn
+ nDataSize=ReadAndDrawSameRgn(PDM_PAINT);
+ break;
+
+ case 0x008a: // eraseSameRgn
+ nDataSize=ReadAndDrawSameRgn(PDM_ERASE);
+ break;
+
+ case 0x008b: // invertSameRgn
+ nDataSize=ReadAndDrawSameRgn(PDM_INVERT);
+ break;
+
+ case 0x008c: // fillSameRgn
+ nDataSize=ReadAndDrawSameRgn(PDM_FILL);
+ break;
+
+ case 0x008d: // Reserved (0 Bytes)
+ case 0x008e: // Reserved (0 Bytes)
+ case 0x008f: // Reserved (0 Bytes)
+ nDataSize=0;
+ break;
+
+ case 0x0090: { // BitsRect
+ Bitmap aBmp;
+ Rectangle aSrcRect, aDestRect;
+ nDataSize=ReadPixMapEtc(aBmp, FALSE, TRUE, &aSrcRect, &aDestRect, TRUE, FALSE);
+ DrawingMethod(PDM_PAINT);
+ pVirDev->DrawBitmap(aDestRect.TopLeft(),aDestRect.GetSize(),aBmp);
+ break;
+ }
+ case 0x0091: { // BitsRgn
+ Bitmap aBmp;
+ Rectangle aSrcRect, aDestRect;
+ nDataSize=ReadPixMapEtc(aBmp, FALSE, TRUE, &aSrcRect, &aDestRect, TRUE, TRUE);
+ DrawingMethod(PDM_PAINT);
+ pVirDev->DrawBitmap(aDestRect.TopLeft(),aDestRect.GetSize(),aBmp);
+ break;
+ }
+ case 0x0092: // Reserved (n Bytes)
+ case 0x0093: // Reserved (n Bytes)
+ case 0x0094: // Reserved (n Bytes)
+ case 0x0095: // Reserved (n Bytes)
+ case 0x0096: // Reserved (n Bytes)
+ case 0x0097: // Reserved (n Bytes)
+ *pPict >> nUSHORT; nDataSize=2+nUSHORT;
+ break;
+
+ case 0x0098: { // PackBitsRect
+ Bitmap aBmp;
+ Rectangle aSrcRect, aDestRect;
+ nDataSize=ReadPixMapEtc(aBmp, FALSE, TRUE, &aSrcRect, &aDestRect, TRUE, FALSE);
+ DrawingMethod(PDM_PAINT);
+ pVirDev->DrawBitmap(aDestRect.TopLeft(),aDestRect.GetSize(),aBmp);
+ break;
+ }
+ case 0x0099: { // PackBitsRgn
+ Bitmap aBmp;
+ Rectangle aSrcRect, aDestRect;
+ nDataSize=ReadPixMapEtc(aBmp, FALSE, TRUE, &aSrcRect, &aDestRect, TRUE, TRUE);
+ DrawingMethod(PDM_PAINT);
+ pVirDev->DrawBitmap(aDestRect.TopLeft(),aDestRect.GetSize(),aBmp);
+ break;
+ }
+ case 0x009a: { // DirectBitsRect
+ Bitmap aBmp;
+ Rectangle aSrcRect, aDestRect;
+ nDataSize=ReadPixMapEtc(aBmp, TRUE, FALSE, &aSrcRect, &aDestRect, TRUE, FALSE);
+ DrawingMethod(PDM_PAINT);
+ pVirDev->DrawBitmap(aDestRect.TopLeft(),aDestRect.GetSize(),aBmp);
+ break;
+ }
+ case 0x009b: { // DirectBitsRgn
+ Bitmap aBmp;
+ Rectangle aSrcRect, aDestRect;
+ nDataSize=ReadPixMapEtc(aBmp, TRUE, FALSE, &aSrcRect, &aDestRect, TRUE, TRUE);
+ DrawingMethod(PDM_PAINT);
+ pVirDev->DrawBitmap(aDestRect.TopLeft(),aDestRect.GetSize(),aBmp);
+ break;
+ }
+ case 0x009c: // Reserved (n Bytes)
+ case 0x009d: // Reserved (n Bytes)
+ case 0x009e: // Reserved (n Bytes)
+ case 0x009f: // Reserved (n Bytes)
+ *pPict >> nUSHORT; nDataSize=2+nUSHORT;
+ break;
+
+ case 0x00a0: // ShortComment
+ nDataSize=2;
+ break;
+
+ case 0x00a1: // LongComment
+ pPict->SeekRel(2); *pPict >> nUSHORT; nDataSize=4+nUSHORT;
+ break;
+
+ default: // 0x00a2 bis 0xffff (zumeist Reserved)
+ if (nOpcode<=0x00af) { *pPict >> nUSHORT; nDataSize=2+nUSHORT; }
+ else if (nOpcode<=0x00cf) { nDataSize=0; }
+ else if (nOpcode<=0x00fe) { *pPict >> nDataSize; nDataSize+=4; }
+ else if (nOpcode==0x00ff) { nDataSize=2; } // OpEndPic
+ else if (nOpcode<=0x01ff) { nDataSize=2; }
+ else if (nOpcode<=0x0bfe) { nDataSize=4; }
+ else if (nOpcode<=0x0bff) { nDataSize=22; }
+ else if (nOpcode==0x0c00) { nDataSize=24; } // HeaderOp
+ else if (nOpcode<=0x7eff) { nDataSize=24; }
+ else if (nOpcode<=0x7fff) { nDataSize=254; }
+ else if (nOpcode<=0x80ff) { nDataSize=0; }
+ else { *pPict >> nDataSize; nDataSize+=4; }
+ }
+
+ if (nDataSize==0xffffffff) {
+ pPict->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ return 0;
+ }
+ return nDataSize;
+}
+
+void PictReader::ReadPict( SvStream & rStreamPict, GDIMetaFile & rGDIMetaFile, PFilterCallback pcallback, void * pcallerdata)
+{
+ const Fraction aFrac72( 1, 72 );
+ const MapMode aMap72( MAP_INCH, Point(), aFrac72, aFrac72 );
+ USHORT nOpcode;
+ BYTE nOneByteOpcode;
+ ULONG nSize, nPos, nStartPos, nEndPos, nPercent, nLastPercent;
+
+ pCallback=pcallback; pCallerData=pcallerdata;
+
+ pPict = &rStreamPict;
+ nOrigPos = pPict->Tell();
+ nOrigNumberFormat = pPict->GetNumberFormatInt();
+
+ aActForeColor = Color(COL_BLACK);
+ aActBackColor = Color(COL_WHITE);
+ eActPenPenStyle = PEN_SOLID;
+ eActPenBrushStyle = BRUSH_SOLID;
+ eActFillStyle = BRUSH_SOLID;
+ eActBackStyle = BRUSH_SOLID;
+ nActPenSize = 1;
+ eActROP = ROP_OVERPAINT;
+ eActMethod = PDM_UNDEFINED;
+ aActOvalSize = Size(1,1);
+
+ aActFont.SetCharSet( gsl_getSystemTextEncoding() );
+ aActFont.SetFamily(FAMILY_SWISS);
+ aActFont.SetSize(Size(0,12));
+ aActFont.SetAlign(ALIGN_BASELINE);
+
+ aHRes = aVRes = Fraction( 1, 1 );
+
+ pVirDev = new VirtualDevice();
+ pVirDev->EnableOutput(FALSE);
+ rGDIMetaFile.Record(pVirDev);
+
+ pPict->SetNumberFormatInt(NUMBERFORMAT_INT_BIGENDIAN);
+
+ nStartPos=pPict->Tell();
+ nEndPos=pPict->Seek(STREAM_SEEK_TO_END); pPict->Seek(nStartPos);
+ Callback(0); nLastPercent=0;
+
+ ReadHeader();
+
+ aPenPosition=Point(-aBoundingRect.Left(),-aBoundingRect.Top());
+ aTextPosition=aPenPosition;
+
+ nPos=pPict->Tell();
+
+ for (;;) {
+
+ nPercent=(nPos-nStartPos)*100/(nEndPos-nStartPos);
+ if (nLastPercent+4<=nPercent) {
+ if (Callback((USHORT)nPercent)==TRUE) break;
+ nLastPercent=nPercent;
+ }
+
+ if (IsVersion2 )
+ *pPict >> nOpcode;
+ else
+ {
+ *pPict >> nOneByteOpcode;
+ nOpcode=(USHORT)nOneByteOpcode;
+ }
+
+ if (pPict->GetError())
+ break;
+
+ if (pPict->IsEof())
+ {
+ pPict->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ break;
+ }
+
+ if (nOpcode==0x00ff)
+ break;
+
+ nSize=ReadData(nOpcode);
+
+ if ( IsVersion2 )
+ {
+ if ( nSize & 1 )
+ nSize++;
+
+ nPos+=2+nSize;
+ }
+ else
+ nPos+=1+nSize;
+
+ pPict->Seek(nPos);
+ }
+
+ rGDIMetaFile.Stop();
+ delete pVirDev;
+
+ rGDIMetaFile.SetPrefMapMode( aMap72 );
+ rGDIMetaFile.SetPrefSize( aBoundingRect.GetSize() );
+
+ pPict->SetNumberFormatInt(nOrigNumberFormat);
+
+ if (pPict->GetError()) pPict->Seek(nOrigPos);
+}
+
+//================== GraphicImport - die exportierte Funktion ================
+
+#ifdef WNT
+extern "C" BOOL _cdecl GraphicImport( SvStream& rIStm, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#else
+extern "C" BOOL GraphicImport( SvStream& rIStm, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#endif
+{
+ GDIMetaFile aMTF;
+ PictReader aPictReader;
+ BOOL bRet = FALSE;
+
+ aPictReader.ReadPict( rIStm, aMTF, pCallback, pCallerData );
+
+ if ( !rIStm.GetError() )
+ {
+ rGraphic = Graphic( aMTF );
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+//================== ein bischen Muell fuer Windows ==========================
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
diff --git a/goodies/source/filter.vcl/ipict/makefile.mk b/goodies/source/filter.vcl/ipict/makefile.mk
new file mode 100644
index 000000000000..59135726bce0
--- /dev/null
+++ b/goodies/source/filter.vcl/ipict/makefile.mk
@@ -0,0 +1,172 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=ipict
+DEPTARGET=vipict
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+.IF "$(COM)"=="WTC"
+CFLAGS=$(CFLAGS) -od -3r
+.ENDIF
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SLOFILES = $(SLO)$/ipict.obj
+
+# ==========================================================================
+
+SHL1TARGET= ipt$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= ipict
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(CPPULIB)
+SHL1DEPN= $(LB)$/ipict.lib
+SHL1LIBS= $(SLB)$/ipict.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/ipict.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicImport >>$@
+.ELSE
+ @echo _GraphicImport >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET) >>$@
+ @ldump -E1 -A $(SLB)$/ipict.lib >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicImport >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/ipsd/ipsd.cxx b/goodies/source/filter.vcl/ipsd/ipsd.cxx
new file mode 100644
index 000000000000..1256fb4eea8f
--- /dev/null
+++ b/goodies/source/filter.vcl/ipsd/ipsd.cxx
@@ -0,0 +1,748 @@
+/*************************************************************************
+ *
+ * $RCSfile: ipsd.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <vcl/graph.hxx>
+#include <vcl/bmpacc.hxx>
+#include <svtools/fltcall.hxx>
+
+//============================ PSDReader ==================================
+
+#define PSD_BITMAP 0
+#define PSD_GRAYSCALE 1
+#define PSD_INDEXED 2
+#define PSD_RGB 3
+#define PSD_CMYK 4
+#define PSD_MULTICHANNEL 7
+#define PSD_DUOTONE 8
+#define PSD_LAB 9
+
+typedef struct
+{
+ UINT32 nSignature;
+ UINT16 nVersion;
+ UINT32 nPad1;
+ UINT16 nPad2;
+ UINT16 nChannels;
+ UINT32 nRows;
+ UINT32 nColumns;
+ UINT16 nDepth;
+ UINT16 nMode;
+
+} PSDFileHeader;
+
+class PSDReader {
+
+private:
+
+ PFilterCallback pCallback;
+ void* pCallerData;
+
+ SvStream* mpPSD; // Die einzulesende PSD-Datei
+ PSDFileHeader* mpFileHeader;
+
+ BOOL mbStatus;
+ BOOL mbTransparent;
+ Bitmap maBmp;
+ Bitmap maMaskBmp;
+ BitmapReadAccess* mpReadAcc;
+ BitmapWriteAccess* mpWriteAcc;
+ BitmapWriteAccess* mpMaskWriteAcc;
+ USHORT mnDestBitDepth;
+ BOOL mbCompression; // RLE decoding
+ BYTE* mpPalette;
+
+ BOOL ImplCallback( USHORT nPercent );
+ BOOL ImplReadBody();
+ BOOL ImplReadHeader();
+
+public:
+ PSDReader();
+ ~PSDReader();
+ BOOL ReadPSD( SvStream & rPSD, Graphic & rGraphic, PFilterCallback pcallback, void * pcallerdata );
+};
+
+//=================== Methoden von PSDReader ==============================
+
+PSDReader::PSDReader() :
+ mpWriteAcc ( NULL ),
+ mpMaskWriteAcc ( NULL ),
+ mpReadAcc ( NULL ),
+ mpFileHeader ( NULL ),
+ mpPalette ( NULL ),
+ mbStatus ( TRUE ),
+ mbTransparent ( FALSE )
+{
+}
+
+PSDReader::~PSDReader()
+{
+ delete mpPalette;
+ delete mpFileHeader;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL PSDReader::ImplCallback( USHORT nPercent )
+{
+ if ( pCallback != NULL )
+ {
+ if ( ( (*pCallback)( pCallerData, nPercent ) ) == TRUE )
+ {
+ mpPSD->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL PSDReader::ReadPSD( SvStream & rPSD, Graphic & rGraphic, PFilterCallback pcallback, void * pcallerdata)
+{
+ if ( rPSD.GetError() )
+ return FALSE;
+
+ pCallback = pcallback;
+ pCallerData = pcallerdata;
+
+ mpPSD = &rPSD;
+ mpPSD->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+
+ // Kopf einlesen:
+
+ if ( ImplReadHeader() == FALSE )
+ return FALSE;
+
+ maBmp = Bitmap( Size( mpFileHeader->nColumns, mpFileHeader->nRows ), mnDestBitDepth );
+ if ( ( mpWriteAcc = maBmp.AcquireWriteAccess() ) == NULL )
+ mbStatus = FALSE;
+ if ( ( mpReadAcc = maBmp.AcquireReadAccess() ) == NULL )
+ mbStatus = FALSE;
+ if ( mbTransparent && mbStatus )
+ {
+ maMaskBmp = Bitmap( Size( mpFileHeader->nColumns, mpFileHeader->nRows ), 1 );
+ if ( ( mpMaskWriteAcc = maMaskBmp.AcquireWriteAccess() ) == NULL )
+ mbStatus = FALSE;
+ }
+ if ( mpPalette && mbStatus )
+ {
+ mpWriteAcc->SetPaletteEntryCount( 256 );
+ for ( USHORT i = 0; i < 256; i++ )
+ {
+ mpWriteAcc->SetPaletteColor( i, Color( mpPalette[ i ], mpPalette[ i + 256 ], mpPalette[ i + 512 ] ) );
+ }
+ }
+ // Bitmap-Daten einlesen
+ if ( mbStatus && ImplReadBody() )
+ {
+ if ( mbTransparent )
+ rGraphic = Graphic( BitmapEx( maBmp, maMaskBmp ) );
+ else
+ rGraphic = maBmp;
+ }
+ else
+ mbStatus = FALSE;
+ if ( mpWriteAcc )
+ maBmp.ReleaseAccess( mpWriteAcc );
+ if ( mpReadAcc )
+ maBmp.ReleaseAccess( mpReadAcc );
+ if ( mpMaskWriteAcc )
+ maMaskBmp.ReleaseAccess( mpMaskWriteAcc );
+ return mbStatus;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL PSDReader::ImplReadHeader()
+{
+ UINT16 nCompression;
+ UINT32 nColorLength, nResourceLength, nLayerMaskLength;
+
+ mpFileHeader = new PSDFileHeader;
+
+ if ( !mpFileHeader )
+ return FALSE;
+
+ *mpPSD >> mpFileHeader->nSignature >> mpFileHeader->nVersion >> mpFileHeader->nPad1 >>
+ mpFileHeader->nPad2 >> mpFileHeader->nChannels >> mpFileHeader->nRows >>
+ mpFileHeader->nColumns >> mpFileHeader->nDepth >> mpFileHeader->nMode;
+
+ if ( ( mpFileHeader->nSignature != 0x38425053 ) || ( mpFileHeader->nVersion != 1 ) )
+ return FALSE;
+
+ if ( mpFileHeader->nRows == 0 || mpFileHeader->nColumns == 0 )
+ return FALSE;
+
+ if ( ( mpFileHeader->nRows > 30000 ) || ( mpFileHeader->nColumns > 30000 ) )
+ return FALSE;
+
+ UINT16 nDepth = mpFileHeader->nDepth;
+ if (!( ( nDepth == 1 ) || ( nDepth == 8 ) || ( nDepth == 16 ) ) )
+ return FALSE;
+
+ mnDestBitDepth = ( nDepth == 16 ) ? 8 : nDepth;
+
+ *mpPSD >> nColorLength;
+ if ( mpFileHeader->nMode == PSD_CMYK )
+ {
+ switch ( mpFileHeader->nChannels )
+ {
+ case 5 :
+ mbTransparent = TRUE;
+ case 4 :
+ mnDestBitDepth = 24;
+ break;
+ default :
+ return FALSE;
+ }
+ }
+ else switch ( mpFileHeader->nChannels )
+ {
+ case 2 :
+ mbTransparent = TRUE;
+ case 1 :
+ break;
+ case 4 :
+ mbTransparent = TRUE;
+ case 3 :
+ mnDestBitDepth = 24;
+ break;
+ default:
+ return FALSE;
+ }
+
+ switch ( mpFileHeader->nMode )
+ {
+ case PSD_BITMAP :
+ {
+ if ( nColorLength || ( nDepth != 1 ) )
+ return FALSE;
+ }
+ break;
+
+ case PSD_INDEXED :
+ {
+ if ( nColorLength != 768 ) // we need the color map
+ return FALSE;
+ mpPalette = new BYTE[ 768 ];
+ if ( mpPalette == NULL )
+ return FALSE;
+ mpPSD->Read( mpPalette, 768 );
+ }
+ break;
+
+ case PSD_DUOTONE : // we'll handle the doutone color like a normal grayscale picture
+ mpPSD->SeekRel( nColorLength );
+ nColorLength = 0;
+ case PSD_GRAYSCALE :
+ {
+ if ( nColorLength )
+ return FALSE;
+ mpPalette = new BYTE[ 768 ];
+ if ( mpPalette == NULL )
+ return FALSE;
+ for ( USHORT i = 0; i < 256; i++ )
+ {
+ mpPalette[ i ] = mpPalette[ i + 256 ] = mpPalette[ i + 512 ] = (BYTE)i;
+ }
+ }
+ break;
+
+ case PSD_CMYK :
+ case PSD_RGB :
+ case PSD_MULTICHANNEL :
+ case PSD_LAB :
+ {
+ if ( nColorLength ) // color table is not supported by the other graphic modes
+ return FALSE;
+ }
+ break;
+
+ default:
+ {
+ return FALSE;
+ }
+ break;
+ }
+
+ *mpPSD >> nResourceLength;
+ mpPSD->SeekRel( nResourceLength );
+
+ *mpPSD >> nLayerMaskLength;
+ mpPSD->SeekRel( nLayerMaskLength );
+
+ *mpPSD >> nCompression;
+ if ( nCompression == 0 )
+ {
+ mbCompression = FALSE;
+ }
+ else if ( nCompression == 1 )
+ {
+ mpPSD->SeekRel( ( mpFileHeader->nRows * mpFileHeader->nChannels ) << 1 );
+ mbCompression = TRUE;
+ }
+ else
+ return FALSE;
+
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL PSDReader::ImplReadBody()
+{
+ ULONG nX, nY;
+ char nRunCount = 0;
+ char nBitCount = -1;
+ BYTE nDat, nDummy, nRed, nGreen, nBlue;
+ BitmapColor aBitmapColor;
+ nX = nY = 0;
+
+ switch ( mnDestBitDepth )
+ {
+ case 1 :
+ {
+ while ( nY < mpFileHeader->nRows )
+ {
+ if ( nBitCount == -1 )
+ {
+ if ( mbCompression ) // else nRunCount = 0 -> so we use only single raw packets
+ *mpPSD >> nRunCount;
+ }
+ if ( nRunCount & 0x80 ) // a run length packet
+ {
+ if ( nBitCount == -1 ) // bits left in nDat ?
+ {
+ *mpPSD >> nDat;
+ nDat ^= 0xff;
+ nBitCount = 7;
+ }
+ for ( USHORT i = 0; i < ( -nRunCount + 1 ); i++ )
+ {
+ mpWriteAcc->SetPixel( nY, nX, (BYTE)nDat >> nBitCount-- );
+ if ( ++nX == mpFileHeader->nColumns )
+ {
+ nX = 0;
+ nY++;
+ nBitCount = -1;
+ }
+ }
+ }
+ else // a raw packet
+ {
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ if ( nBitCount == -1 ) // bits left in nDat ?
+ {
+ *mpPSD >> nDat;
+ nDat ^= 0xff;
+ nBitCount = 7;
+ }
+ mpWriteAcc->SetPixel( nY, nX, (BYTE)nDat >> nBitCount-- );
+ if ( ++nX == mpFileHeader->nColumns )
+ {
+ nX = 0;
+ nY++;
+ nBitCount = -1;
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case 8 :
+ {
+ while ( nY < mpFileHeader->nRows )
+ {
+ if ( mbCompression ) // else nRunCount = 0 -> so we use only single raw packets
+ *mpPSD >> nRunCount;
+
+ if ( nRunCount & 0x80 ) // a run length packet
+ {
+ *mpPSD >> nDat;
+ if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped
+ *mpPSD >> nDummy;
+ for ( USHORT i = 0; i < ( -nRunCount + 1 ); i++ )
+ {
+ mpWriteAcc->SetPixel( nY, nX, (BYTE)nDat );
+ if ( ++nX == mpFileHeader->nColumns )
+ {
+ nX = 0;
+ nY++;
+ }
+ }
+ }
+ else // a raw packet
+ {
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ *mpPSD >> nDat;
+ if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped
+ *mpPSD >> nDummy;
+ mpWriteAcc->SetPixel( nY, nX, (BYTE)nDat );
+ if ( ++nX == mpFileHeader->nColumns )
+ {
+ nX = 0;
+ nY++;
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case 24 :
+ {
+
+ // the psd format is in plain order (RRRR GGGG BBBB) so we have to set each pixel three times
+ // maybe the format is CCCC MMMM YYYY KKKK
+
+ while ( nY < mpFileHeader->nRows )
+ {
+ if ( mbCompression ) // else nRunCount = 0 -> so we use only single raw packets
+ *mpPSD >> nRunCount;
+
+ if ( nRunCount & 0x80 ) // a run length packet
+ {
+ *mpPSD >> nRed;
+ if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped
+ *mpPSD >> nDummy;
+ for ( USHORT i = 0; i < ( -nRunCount + 1 ); i++ )
+ {
+ mpWriteAcc->SetPixel( nY, nX, BitmapColor( nRed, (BYTE)0, (BYTE)0 ) );
+ if ( ++nX == mpFileHeader->nColumns )
+ {
+ nX = 0;
+ nY++;
+ }
+ }
+ }
+ else // a raw packet
+ {
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ *mpPSD >> nRed;
+ if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped
+ *mpPSD >> nDummy;
+ mpWriteAcc->SetPixel( nY, nX, BitmapColor( nRed, (BYTE)0, (BYTE)0 ) );
+ if ( ++nX == mpFileHeader->nColumns )
+ {
+ nX = 0;
+ nY++;
+ }
+ }
+ }
+ }
+ nY = 0;
+ while ( nY < mpFileHeader->nRows )
+ {
+ if ( mbCompression )
+ *mpPSD >> nRunCount;
+ if ( nRunCount & 0x80 ) // a run length packet
+ {
+ *mpPSD >> nGreen;
+ if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped
+ *mpPSD >> nDummy;
+ for ( USHORT i = 0; i < ( -nRunCount + 1 ); i++ )
+ {
+ aBitmapColor = mpReadAcc->GetPixel( nY, nX );
+ mpWriteAcc->SetPixel( nY, nX, BitmapColor( aBitmapColor.GetRed(), nGreen, aBitmapColor.GetBlue() ) );
+ if ( ++nX == mpFileHeader->nColumns )
+ {
+ nX = 0;
+ nY++;
+ }
+ }
+ }
+ else // a raw packet
+ {
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ *mpPSD >> nGreen;
+ if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped
+ *mpPSD >> nDummy;
+ aBitmapColor = mpReadAcc->GetPixel( nY, nX );
+ mpWriteAcc->SetPixel( nY, nX, BitmapColor( aBitmapColor.GetRed(), nGreen, aBitmapColor.GetBlue() ) );
+ if ( ++nX == mpFileHeader->nColumns )
+ {
+ nX = 0;
+ nY++;
+ }
+ }
+ }
+ }
+ nY = 0;
+ while ( nY < mpFileHeader->nRows )
+ {
+ if ( mbCompression )
+ *mpPSD >> nRunCount;
+ if ( nRunCount & 0x80 ) // a run length packet
+ {
+ *mpPSD >> nBlue;
+ if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped
+ *mpPSD >> nDummy;
+ for ( USHORT i = 0; i < ( -nRunCount + 1 ); i++ )
+ {
+ aBitmapColor = mpReadAcc->GetPixel( nY, nX );
+ mpWriteAcc->SetPixel( nY, nX, BitmapColor( aBitmapColor.GetRed(), aBitmapColor.GetGreen(), nBlue ) );
+ if ( ++nX == mpFileHeader->nColumns )
+ {
+ nX = 0;
+ nY++;
+ }
+ }
+ }
+ else // a raw packet
+ {
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ *mpPSD >> nBlue;
+ if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped
+ *mpPSD >> nDummy;
+ aBitmapColor = mpReadAcc->GetPixel( nY, nX );
+ mpWriteAcc->SetPixel( nY, nX, BitmapColor( aBitmapColor.GetRed(), aBitmapColor.GetGreen(), nBlue ) );
+ if ( ++nX == mpFileHeader->nColumns )
+ {
+ nX = 0;
+ nY++;
+ }
+ }
+ }
+ }
+ if ( mpFileHeader->nMode == PSD_CMYK )
+ {
+ UINT32 nBlack, nBlackMax = 0;
+ BYTE* pBlack = new BYTE[ mpFileHeader->nRows * mpFileHeader->nColumns ];
+ nY = 0;
+ while ( nY < mpFileHeader->nRows )
+ {
+ if ( mbCompression ) // else nRunCount = 0 -> so we use only single raw packets
+ *mpPSD >> nRunCount;
+
+ if ( nRunCount & 0x80 ) // a run length packet
+ {
+ *mpPSD >> nDat;
+
+ if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped
+ *mpPSD >> nDummy;
+
+ for ( USHORT i = 0; i < ( -nRunCount + 1 ); i++ )
+ {
+ nBlack = (BYTE)mpReadAcc->GetPixel( nY, nX ).GetRed() + nDat;
+ if ( nBlack > nBlackMax )
+ nBlackMax = nBlack;
+ nBlack = (BYTE)mpReadAcc->GetPixel( nY, nX ).GetGreen() + nDat;
+ if ( nBlack > nBlackMax )
+ nBlackMax = nBlack;
+ nBlack = (BYTE)mpReadAcc->GetPixel( nY, nX ).GetBlue() + nDat;
+ if ( nBlack > nBlackMax )
+ nBlackMax = nBlack;
+ pBlack[ nX + nY * mpFileHeader->nColumns ] = nDat ^ 0xff;
+ if ( ++nX == mpFileHeader->nColumns )
+ {
+ nX = 0;
+ nY++;
+ }
+ }
+ }
+ else // a raw packet
+ {
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ *mpPSD >> nDat;
+
+ if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped
+ *mpPSD >> nDummy;
+ nBlack = (BYTE)mpReadAcc->GetPixel( nY, nX ).GetRed() + nDat;
+ if ( nBlack > nBlackMax )
+ nBlackMax = nBlack;
+ nBlack = (BYTE)mpReadAcc->GetPixel( nY, nX ).GetGreen() + nDat;
+ if ( nBlack > nBlackMax )
+ nBlackMax = nBlack;
+ nBlack = (BYTE)mpReadAcc->GetPixel( nY, nX ).GetBlue() + nDat;
+ if ( nBlack > nBlackMax )
+ nBlackMax = nBlack;
+ pBlack[ nX + nY * mpFileHeader->nColumns ] = nDat ^ 0xff;
+ if ( ++nX == mpFileHeader->nColumns )
+ {
+ nX = 0;
+ nY++;
+ }
+ }
+ }
+ }
+
+ for ( nY = 0; nY < mpFileHeader->nRows; nY++ )
+ {
+ for ( nX = 0; nX < mpFileHeader->nColumns; nX++ )
+ {
+ INT32 nDAT = pBlack[ nX + nY * mpFileHeader->nColumns ] * ( nBlackMax - 256 ) / 0x1ff;
+
+ aBitmapColor = mpReadAcc->GetPixel( nY, nX );
+ BYTE cR = (BYTE) MinMax( aBitmapColor.GetRed() - nDAT, 0L, 255L );
+ BYTE cG = (BYTE) MinMax( aBitmapColor.GetGreen() - nDAT, 0L, 255L );
+ BYTE cB = (BYTE) MinMax( aBitmapColor.GetBlue() - nDAT, 0L, 255L );
+ mpWriteAcc->SetPixel( nY, nX, BitmapColor( cR, cG, cB ) );
+ }
+ }
+ delete pBlack;
+ }
+ }
+ break;
+ }
+
+ if ( mbTransparent )
+ {
+ // the psd is 24 or 8 bit grafix + alphachannel
+
+ nY = nX = 0;
+ while ( nY < mpFileHeader->nRows )
+ {
+ if ( mbCompression ) // else nRunCount = 0 -> so we use only single raw packets
+ *mpPSD >> nRunCount;
+
+ if ( nRunCount & 0x80 ) // a run length packet
+ {
+ *mpPSD >> nDat;
+ if ( nDat )
+ nDat = 0;
+ else
+ nDat = 1;
+ if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped
+ *mpPSD >> nDummy;
+ for ( USHORT i = 0; i < ( -nRunCount + 1 ); i++ )
+ {
+ mpMaskWriteAcc->SetPixel( nY, nX, (BYTE)nDat );
+ if ( ++nX == mpFileHeader->nColumns )
+ {
+ nX = 0;
+ nY++;
+ }
+ }
+ }
+ else // a raw packet
+ {
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ *mpPSD >> nDat;
+ if ( nDat )
+ nDat = 0;
+ else
+ nDat = 1;
+ if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped
+ *mpPSD >> nDummy;
+ mpMaskWriteAcc->SetPixel( nY, nX, (BYTE)nDat );
+ if ( ++nX == mpFileHeader->nColumns )
+ {
+ nX = 0;
+ nY++;
+ }
+ }
+ }
+ }
+ }
+ return TRUE;
+}
+
+//================== GraphicImport - die exportierte Funktion ================
+
+#ifdef WNT
+extern "C" BOOL _cdecl GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#else
+extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#endif
+{
+ PSDReader aPSDReader;
+
+ return aPSDReader.ReadPSD( rStream, rGraphic, pCallback, pCallerData );
+}
+
+//================== ein bischen Muell fuer Windows ==========================
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
diff --git a/goodies/source/filter.vcl/ipsd/makefile.mk b/goodies/source/filter.vcl/ipsd/makefile.mk
new file mode 100644
index 000000000000..6b3e17c6871b
--- /dev/null
+++ b/goodies/source/filter.vcl/ipsd/makefile.mk
@@ -0,0 +1,168 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:15 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=ipsd
+DEPTARGET=vipsd
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SLOFILES = $(SLO)$/ipsd.obj
+
+# ==========================================================================
+
+SHL1TARGET= ipd$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= ipsd
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(CPPULIB)
+SHL1DEPN= $(LB)$/ipsd.lib
+SHL1LIBS= $(SLB)$/ipsd.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/ipsd.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicImport >>$@
+.ELSE
+ @echo _GraphicImport >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET).DLL >>$@
+ @ldump -E1 -A $(SLB)$/ipsd.lib >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicImport >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/iras/iras.cxx b/goodies/source/filter.vcl/iras/iras.cxx
new file mode 100644
index 000000000000..791785446012
--- /dev/null
+++ b/goodies/source/filter.vcl/iras/iras.cxx
@@ -0,0 +1,439 @@
+/*************************************************************************
+ *
+ * $RCSfile: iras.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <vcl/graph.hxx>
+#include <vcl/bmpacc.hxx>
+#include <svtools/fltcall.hxx>
+
+#define RAS_TYPE_OLD 0x00000000 // supported formats by this filter
+#define RAS_TYPE_STANDARD 0x00000001
+#define RAS_TYPE_BYTE_ENCODED 0x00000002
+#define RAS_TYPE_RGB_FORMAT 0x00000003
+
+#define RAS_COLOR_NO_MAP 0x00000000
+#define RAS_COLOR_RGB_MAP 0x00000001
+#define RAS_COLOR_RAW_MAP 0x00000002
+
+#define SUNRASTER_MAGICNUMBER 0x59a66a95
+
+//============================ RASReader ==================================
+
+class RASReader {
+
+private:
+
+ PFilterCallback pCallback;
+ void * pCallerData;
+
+ SvStream* mpRAS; // Die einzulesende RAS-Datei
+
+ BOOL mbStatus;
+ Bitmap maBmp;
+ BitmapWriteAccess* mpAcc;
+ ULONG mnWidth, mnHeight; // Bildausmass in Pixeln
+ USHORT mnDstBitsPerPix;
+ USHORT mnDstColors;
+ ULONG mnDepth, mnImageDatSize, mnType;
+ ULONG mnColorMapType, mnColorMapSize;
+ BYTE mnRepCount, mnRepVal; // RLE Decoding
+ BOOL mbPalette;
+
+ BOOL ImplCallback( USHORT nPercent );
+ BOOL ImplReadBody();
+ BOOL ImplReadHeader();
+ BYTE ImplGetByte();
+
+public:
+ RASReader();
+ ~RASReader();
+ BOOL ReadRAS( SvStream & rRAS, Graphic & rGraphic, PFilterCallback pcallback, void * pcallerdata );
+};
+
+//=================== Methoden von RASReader ==============================
+
+RASReader::RASReader() :
+ mpAcc ( NULL ),
+ mbStatus ( TRUE ),
+ mbPalette ( FALSE ),
+ mnRepCount ( 0 )
+{
+}
+
+RASReader::~RASReader()
+{
+}
+
+//----------------------------------------------------------------------------
+
+BOOL RASReader::ImplCallback( USHORT nPercent )
+{
+ if ( pCallback != NULL )
+ {
+ if ( ( (*pCallback)( pCallerData, nPercent ) ) == TRUE )
+ {
+ mpRAS->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL RASReader::ReadRAS( SvStream & rRAS, Graphic & rGraphic, PFilterCallback pcallback, void * pcallerdata)
+{
+ UINT32 nMagicNumber;
+
+ if ( rRAS.GetError() ) return FALSE;
+
+ pCallback = pcallback;
+ pCallerData = pcallerdata;
+
+ mpRAS = &rRAS;
+ mpRAS->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+ *mpRAS >> nMagicNumber;
+ if ( nMagicNumber != SUNRASTER_MAGICNUMBER )
+ return FALSE;
+
+ // Kopf einlesen:
+
+ if ( ( mbStatus = ImplReadHeader() ) == FALSE )
+ return FALSE;
+
+ maBmp = Bitmap( Size( mnWidth, mnHeight ), mnDstBitsPerPix );
+ if ( ( mpAcc = maBmp.AcquireWriteAccess() ) == FALSE )
+ return FALSE;
+
+ if ( mnDstBitsPerPix <= 8 ) // paletten bildchen
+ {
+ if ( mnColorMapType == RAS_COLOR_RAW_MAP ) // RAW Colormap wird geskipped
+ {
+ ULONG nCurPos = mpRAS->Tell();
+ mpRAS->Seek( nCurPos + mnColorMapSize );
+ }
+ else if ( mnColorMapType == RAS_COLOR_RGB_MAP ) // RGB koennen wir auslesen
+ {
+ mnDstColors = (USHORT)( mnColorMapSize / 3 );
+
+ if ( ( 1 << mnDstBitsPerPix ) < mnDstColors )
+ return FALSE;
+
+ if ( ( mnDstColors >= 2 ) && ( ( mnColorMapSize % 3 ) == 0 ) )
+ {
+ mpAcc->SetPaletteEntryCount( mnDstColors );
+ USHORT i;
+ BYTE nRed[256], nGreen[256], nBlue[256];
+ for ( i = 0; i < mnDstColors; i++ ) *mpRAS >> nRed[ i ];
+ for ( i = 0; i < mnDstColors; i++ ) *mpRAS >> nGreen[ i ];
+ for ( i = 0; i < mnDstColors; i++ ) *mpRAS >> nBlue[ i ];
+ for ( i = 0; i < mnDstColors; i++ )
+ {
+ mpAcc->SetPaletteColor( i, BitmapColor( nRed[ i ], nGreen[ i ], nBlue[ i ] ) );
+ }
+ mbPalette = TRUE;
+ }
+ else
+ return FALSE;
+
+ }
+ else if ( mnColorMapType != RAS_COLOR_NO_MAP ) // alles andere ist kein standard
+ return FALSE;
+
+ if ( !mbPalette )
+ {
+ mnDstColors = 1 << mnDstBitsPerPix;
+ mpAcc->SetPaletteEntryCount( mnDstColors );
+ for ( USHORT i = 0; i < mnDstColors; i++ )
+ {
+ ULONG nCount = 255 - ( 255 * i / ( mnDstColors - 1 ) );
+ mpAcc->SetPaletteColor( i, BitmapColor( (BYTE)nCount, (BYTE)nCount, (BYTE)nCount ) );
+ }
+ }
+ }
+ else
+ {
+ if ( mnColorMapType != RAS_COLOR_NO_MAP ) // when graphic has more then 256 colors and a color map we skip
+ { // the colormap
+ ULONG nCurPos = mpRAS->Tell();
+ mpRAS->Seek( nCurPos + mnColorMapSize );
+ }
+ }
+
+ // Bitmap-Daten einlesen
+ mbStatus = ImplReadBody();
+
+ if ( mpAcc )
+ {
+ maBmp.ReleaseAccess( mpAcc ), mpAcc = NULL;
+ }
+ if ( mbStatus )
+ rGraphic = maBmp;
+
+ return mbStatus;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL RASReader::ImplReadHeader()
+{
+ *mpRAS >> mnWidth >> mnHeight >> mnDepth >> mnImageDatSize >>
+ mnType >> mnColorMapType >> mnColorMapSize;
+
+ if ( mnWidth == 0 || mnHeight == 0 )
+ mbStatus = FALSE;
+
+ switch ( mnDepth )
+ {
+ case 24 :
+ case 8 :
+ case 1 :
+ mnDstBitsPerPix = (USHORT)mnDepth;
+ break;
+ case 32 :
+ mnDstBitsPerPix = 24;
+ break;
+
+ default :
+ mbStatus = FALSE;
+ }
+
+ switch ( mnType )
+ {
+ case RAS_TYPE_OLD :
+ case RAS_TYPE_STANDARD :
+ case RAS_TYPE_RGB_FORMAT :
+ case RAS_TYPE_BYTE_ENCODED : // this type will be supported later
+ break;
+
+ default:
+ mbStatus = FALSE;
+ }
+ return mbStatus;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL RASReader::ImplReadBody()
+{
+ ULONG x, y;
+ BYTE nDat, nRed, nGreen, nBlue;
+ switch ( mnDstBitsPerPix )
+ {
+ case 1 :
+ for ( y = 0; y < mnHeight; y++ )
+ {
+ for ( x = 0; x < mnWidth; x++ )
+ {
+ if (!(x & 7))
+ nDat = ImplGetByte();
+ mpAcc->SetPixel ( y, x, nDat >> ( ( x & 7 ) ^ 7 ) );
+ }
+ if (!( ( x - 1 ) & 0x8 ) ) ImplGetByte(); // WORD ALIGNMENT ???
+ }
+ break;
+
+ case 8 :
+ for ( y = 0; y < mnHeight; y++ )
+ {
+ for ( x = 0; x < mnWidth; x++ )
+ {
+ nDat = ImplGetByte();
+ mpAcc->SetPixel ( y, x, nDat );
+ }
+ if ( x & 1 ) ImplGetByte(); // WORD ALIGNMENT ???
+ }
+ break;
+
+ case 24 :
+ switch ( mnDepth )
+ {
+
+ case 24 :
+ for ( y = 0; y < mnHeight; y++ )
+ {
+ for ( x = 0; x < mnWidth; x++ )
+ {
+ if ( mnType == RAS_TYPE_RGB_FORMAT )
+ {
+ nRed = ImplGetByte();
+ nGreen = ImplGetByte();
+ nBlue = ImplGetByte();
+ }
+ else
+ {
+ nBlue = ImplGetByte();
+ nGreen = ImplGetByte();
+ nRed = ImplGetByte();
+ }
+ mpAcc->SetPixel ( y, x, BitmapColor( nRed, nGreen, nBlue ) );
+ }
+ if ( x & 1 ) ImplGetByte(); // WORD ALIGNMENT ???
+ }
+ break;
+
+ case 32 :
+ for ( y = 0; y < mnHeight; y++ )
+ {
+ for ( x = 0; x < mnWidth; x++ )
+ {
+ nDat = ImplGetByte(); // pad byte > nil
+ if ( mnType == RAS_TYPE_RGB_FORMAT )
+ {
+ nRed = ImplGetByte();
+ nGreen = ImplGetByte();
+ nBlue = ImplGetByte();
+ }
+ else
+ {
+ nBlue = ImplGetByte();
+ nGreen = ImplGetByte();
+ nRed = ImplGetByte();
+ }
+ mpAcc->SetPixel ( y, x, BitmapColor( nRed, nGreen, nBlue ) );
+ }
+ }
+ break;
+ }
+ break;
+
+ default:
+ mbStatus = FALSE;
+ break;
+ }
+ return mbStatus;
+}
+
+//----------------------------------------------------------------------------
+
+BYTE RASReader::ImplGetByte()
+{
+ BYTE nRetVal;
+ if ( mnType != RAS_TYPE_BYTE_ENCODED )
+ {
+ *mpRAS >> nRetVal;
+ return nRetVal;
+ }
+ else
+ {
+ if ( mnRepCount )
+ {
+ mnRepCount--;
+ return mnRepVal;
+ }
+ else
+ {
+ *mpRAS >> nRetVal;
+ if ( nRetVal != 0x80 )
+ return nRetVal;
+ *mpRAS >> nRetVal;
+ if ( nRetVal == 0 )
+ return 0x80;
+ mnRepCount = nRetVal ;
+ *mpRAS >> mnRepVal;
+ return mnRepVal;
+ }
+ }
+}
+
+//================== GraphicImport - die exportierte Funktion ================
+
+#ifdef WNT
+extern "C" BOOL _cdecl GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#else
+extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#endif
+{
+ RASReader aRASReader;
+
+ return aRASReader.ReadRAS( rStream, rGraphic, pCallback, pCallerData );
+}
+
+//================== ein bischen Muell fuer Windows ==========================
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
+
diff --git a/goodies/source/filter.vcl/iras/makefile.mk b/goodies/source/filter.vcl/iras/makefile.mk
new file mode 100644
index 000000000000..2235da6df352
--- /dev/null
+++ b/goodies/source/filter.vcl/iras/makefile.mk
@@ -0,0 +1,168 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=iras
+DEPTARGET=viras
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SLOFILES = $(SLO)$/iras.obj
+
+# ==========================================================================
+
+SHL1TARGET= ira$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= iras
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(CPPULIB)
+SHL1DEPN= $(LB)$/iras.lib
+SHL1LIBS= $(SLB)$/iras.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/iras.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicImport >>$@
+.ELSE
+ @echo _GraphicImport >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET).DLL >>$@
+ @ldump -E1 -A $(SLB)$/iras.lib >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicImport >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/itga/itga.cxx b/goodies/source/filter.vcl/itga/itga.cxx
new file mode 100644
index 000000000000..3af6fc488f2c
--- /dev/null
+++ b/goodies/source/filter.vcl/itga/itga.cxx
@@ -0,0 +1,810 @@
+/*************************************************************************
+ *
+ * $RCSfile: itga.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <vcl/graph.hxx>
+#include <vcl/bmpacc.hxx>
+#include <svtools/fltcall.hxx>
+
+//============================ TGAReader ==================================
+
+struct TGAFileHeader
+{
+ BYTE nImageIDLength;
+ BYTE nColorMapType;
+ BYTE nImageType;
+ UINT16 nColorMapFirstEntryIndex;
+ UINT16 nColorMapLength;
+ BYTE nColorMapEntrySize;
+ UINT16 nColorMapXOrigin;
+ UINT16 nColorMapYOrigin;
+ UINT16 nImageWidth;
+ UINT16 nImageHeight;
+ BYTE nPixelDepth;
+ BYTE nImageDescriptor;
+};
+
+#define SizeOfTGAFileFooter 26
+
+struct TGAFileFooter
+{
+ UINT32 nExtensionFileOffset;
+ UINT32 nDeveloperDirectoryOffset;
+ UINT32 nSignature[4];
+ BYTE nPadByte;
+ BYTE nStringTerminator;
+};
+
+#define SizeOfTGAExtension 495
+
+struct TGAExtension
+{
+ UINT16 nExtensionSize;
+ char sAuthorName[41];
+ char sAuthorComment[324];
+ char sDateTimeStamp[12];
+ char sJobNameID[41];
+ UINT16 nJobTime[3];
+ char sSoftwareID[41];
+ UINT16 nSoftwareVersionNumber;
+ BYTE nSoftwareVersionLetter;
+ UINT32 nKeyColor;
+ UINT16 nPixelAspectRatioNumerator;
+ UINT16 nPixelAspectRatioDeNumerator;
+ UINT16 nGammaValueNumerator;
+ UINT16 nGammaValueDeNumerator;
+ UINT32 nColorCorrectionOffset;
+ UINT32 nPostageStampOffset;
+ UINT32 nScanLineOffset;
+ BYTE nAttributesType;
+};
+
+class TGAReader {
+
+private:
+
+ PFilterCallback pCallback;
+ void* pCallerData;
+
+ SvStream* mpTGA;
+
+ BitmapWriteAccess* mpAcc;
+ TGAFileHeader* mpFileHeader;
+ TGAFileFooter* mpFileFooter;
+ TGAExtension* mpExtension;
+ UINT32* mpColorMap;
+
+ BOOL mbStatus;
+
+ ULONG mnTGAVersion; // Enhanced TGA is defined as Version 2.0
+ UINT16 mnDestBitDepth;
+ BOOL mbIndexing; // TRUE if source contains indexing color values
+ BOOL mbEncoding; // TRUE if source is compressed
+
+ BOOL Callback( USHORT nPercent );
+ BOOL ImplReadHeader();
+ BOOL ImplReadPalette();
+ BOOL ImplReadBody();
+
+public:
+ TGAReader();
+ ~TGAReader();
+ BOOL ReadTGA( SvStream & rTGA, Graphic & rGraphic, PFilterCallback pcallback, void * pcallerdata );
+};
+
+//=================== Methoden von TGAReader ==============================
+
+TGAReader::TGAReader() :
+ mbStatus ( TRUE ),
+ mpAcc ( NULL ),
+ mpFileHeader ( NULL ),
+ mpFileFooter ( NULL ),
+ mpExtension ( NULL ),
+ mpColorMap ( NULL ),
+ mbIndexing ( FALSE ),
+ mbEncoding ( FALSE ),
+ mnTGAVersion ( 1 )
+{
+}
+
+TGAReader::~TGAReader()
+{
+ delete mpColorMap;
+ delete mpFileHeader;
+ delete mpExtension;
+ delete mpFileFooter;
+}
+
+BOOL TGAReader::Callback( USHORT nPercent )
+{
+ if ( pCallback != NULL )
+ {
+ if ( ( (*pCallback)( pCallerData,nPercent ) ) == TRUE )
+ {
+ mpTGA->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+// -------------------------------------------------------------------------------------------
+
+BOOL TGAReader::ReadTGA( SvStream & rTGA, Graphic & rGraphic, PFilterCallback pcallback, void * pcallerdata )
+{
+ if ( rTGA.GetError() )
+ return FALSE;
+
+ pCallback = pcallback;
+ pCallerData = pcallerdata;
+
+ mpTGA = &rTGA;
+ mpTGA->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+
+ // Kopf einlesen:
+
+ if ( !mpTGA->GetError() && ( mbStatus = ImplReadHeader() ) )
+ {
+ Bitmap aBitmap;
+
+ aBitmap = Bitmap( Size( mpFileHeader->nImageWidth, mpFileHeader->nImageHeight ), mnDestBitDepth );
+ mpAcc = aBitmap.AcquireWriteAccess();
+ if ( mpAcc )
+ {
+ if ( mbIndexing )
+ mbStatus = ImplReadPalette();
+ if ( mbStatus )
+ mbStatus = ImplReadBody();
+ }
+ else
+ mbStatus = FALSE;
+
+ if ( mpAcc )
+ aBitmap.ReleaseAccess ( mpAcc), mpAcc = NULL;
+
+ if ( mbStatus )
+ rGraphic = aBitmap;
+ }
+ return mbStatus;
+}
+
+// -------------------------------------------------------------------------------------------
+
+BOOL TGAReader::ImplReadHeader()
+{
+ mpFileHeader = new TGAFileHeader;
+ if ( mpFileHeader == NULL )
+ return FALSE;
+
+ *mpTGA >> mpFileHeader->nImageIDLength >> mpFileHeader->nColorMapType >> mpFileHeader->nImageType >>
+ mpFileHeader->nColorMapFirstEntryIndex >> mpFileHeader->nColorMapLength >> mpFileHeader->nColorMapEntrySize >>
+ mpFileHeader->nColorMapXOrigin >> mpFileHeader->nColorMapYOrigin >> mpFileHeader->nImageWidth >>
+ mpFileHeader->nImageHeight >> mpFileHeader->nPixelDepth >> mpFileHeader->nImageDescriptor;
+
+ if ( mpFileHeader->nColorMapType > 1 )
+ return FALSE;
+ if ( mpFileHeader->nColorMapType == 1 )
+ mbIndexing = TRUE;
+
+ // first we want to get the version
+ mpFileFooter = new TGAFileFooter; // read the TGA-File-Footer to determine whether
+ if ( mpFileFooter ) // we got an old TGA format or the new one
+ {
+ ULONG nCurStreamPos = mpTGA->Tell();
+ mpTGA->Seek( STREAM_SEEK_TO_END );
+ ULONG nTemp = mpTGA->Tell();
+ mpTGA->Seek( nTemp - SizeOfTGAFileFooter );
+
+ *mpTGA >> mpFileFooter->nExtensionFileOffset >> mpFileFooter->nDeveloperDirectoryOffset >>
+ mpFileFooter->nSignature[0] >> mpFileFooter->nSignature[1] >> mpFileFooter->nSignature[2] >>
+ mpFileFooter->nSignature[3] >> mpFileFooter->nPadByte >> mpFileFooter->nStringTerminator;
+
+ if ( mpFileFooter->nSignature[ 0 ] == 'TRUE' && mpFileFooter->nSignature[ 1 ] == 'VISI' &&
+ mpFileFooter->nSignature[ 2 ] == 'ON-X' && mpFileFooter->nSignature[ 3 ] == 'FILE' )
+ {
+ mpExtension = new TGAExtension;
+ if ( mpExtension )
+ {
+ mpTGA->Seek( mpFileFooter->nExtensionFileOffset );
+ *mpTGA >> mpExtension->nExtensionSize;
+ if ( mpExtension->nExtensionSize >= SizeOfTGAExtension )
+ {
+ mnTGAVersion = 2;
+
+ mpTGA->Read( mpExtension->sAuthorName, 41 );
+ mpTGA->Read( mpExtension->sAuthorComment, 324 );
+ mpTGA->Read( mpExtension->sDateTimeStamp, 12 );
+ mpTGA->Read( mpExtension->sJobNameID, 12 );
+ *mpTGA >> mpExtension->sJobNameID[ 0 ] >> mpExtension->sJobNameID[ 1 ] >> mpExtension->sJobNameID[ 2 ];
+ mpTGA->Read( mpExtension->sSoftwareID, 41 );
+ *mpTGA >> mpExtension->nSoftwareVersionNumber >> mpExtension->nSoftwareVersionLetter
+ >> mpExtension->nKeyColor >> mpExtension->nPixelAspectRatioNumerator
+ >> mpExtension->nPixelAspectRatioDeNumerator >> mpExtension->nGammaValueNumerator
+ >> mpExtension->nGammaValueDeNumerator >> mpExtension->nColorCorrectionOffset
+ >> mpExtension->nPostageStampOffset >> mpExtension->nScanLineOffset
+ >> mpExtension->nAttributesType;
+
+ }
+ }
+ }
+ mpTGA->Seek( nCurStreamPos );
+ }
+
+ // using the TGA file specification this was the correct form but adobe photoshop sets nImageDescriptor
+ // equal to nPixelDepth
+ // mnDestBitDepth = mpFileHeader->nPixelDepth - ( mpFileHeader->nImageDescriptor & 0xf );
+ mnDestBitDepth = mpFileHeader->nPixelDepth;
+
+ if ( mnDestBitDepth == 8 ) // this is a patch for grayscale pictures not including a palette
+ mbIndexing = TRUE;
+
+ if ( mnDestBitDepth > 32 ) // maybe the pixeldepth is invalid
+ return FALSE;
+ else if ( mnDestBitDepth > 8 )
+ mnDestBitDepth = 24;
+ else if ( mnDestBitDepth > 4 )
+ mnDestBitDepth = 8;
+ else if ( mnDestBitDepth > 2 )
+ mnDestBitDepth = 4;
+
+ if ( !mbIndexing && ( mnDestBitDepth < 15 ) )
+ return FALSE;
+
+ switch ( mpFileHeader->nImageType )
+ {
+ case 9 : // encoding for colortype 9, 10, 11
+ case 10 :
+ case 11 :
+ mbEncoding = TRUE;
+ break;
+ };
+
+ if ( mpFileHeader->nImageIDLength ) // skip the Image ID
+ mpTGA->SeekRel( mpFileHeader->nImageIDLength );
+
+ return mbStatus;
+}
+
+// -------------------------------------------------------------------------------------------
+
+BOOL TGAReader::ImplReadBody()
+{
+
+ USHORT nXCount, nYCount, nRGB16;
+ BYTE nRed, nGreen, nBlue, nRunCount, nDummy, nDepth;
+
+ // this four variables match the image direction
+ long nY, nYAdd, nX, nXAdd, nXStart;
+
+ nX = nXStart = nY = 0;
+ nXCount = nYCount = 0;
+ nYAdd = nXAdd = 1;
+
+ if ( mpFileHeader->nImageDescriptor & 0x10 )
+ {
+ nX = nXStart = mpFileHeader->nImageWidth - 1;
+ nXAdd -= 2;
+ }
+
+ if ( !(mpFileHeader->nImageDescriptor & 0x20 ) )
+ {
+ nY = mpFileHeader->nImageHeight - 1;
+ nYAdd -=2;
+ }
+
+// nDepth = mpFileHeader->nPixelDepth - ( mpFileHeader->nImageDescriptor & 0xf );
+ nDepth = mpFileHeader->nPixelDepth;
+
+ if ( mbEncoding )
+ {
+ if ( mbIndexing )
+ {
+ switch( nDepth )
+ {
+ // 16 bit encoding + indexing
+ case 16 :
+ while ( nYCount < mpFileHeader->nImageHeight )
+ {
+ *mpTGA >> nRunCount;
+ if ( nRunCount & 0x80 ) // a run length packet
+ {
+ *mpTGA >> nRGB16;
+ if ( nRGB16 >= mpFileHeader->nColorMapLength )
+ return FALSE;
+ nRed = (BYTE)( mpColorMap[ nRGB16 ] >> 16 );
+ nGreen = (BYTE)( mpColorMap[ nRGB16 ] >> 8 );
+ nBlue = (BYTE)( mpColorMap[ nRGB16 ] );
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ mpAcc->SetPixel( nY, nX, BitmapColor( nRed, nGreen, nBlue ) );
+ nX += nXAdd;
+ nXCount++;
+ if ( nXCount == mpFileHeader->nImageWidth )
+ {
+ nX = nXStart;
+ nXCount = 0;
+ nY += nYAdd;
+ nYCount++;
+ }
+ }
+ }
+ else // a raw packet
+ {
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ *mpTGA >> nRGB16;
+ if ( nRGB16 >= mpFileHeader->nColorMapLength )
+ return FALSE;
+ nRed = (BYTE)( mpColorMap[ nRGB16 ] >> 16 );
+ nGreen = (BYTE)( mpColorMap[ nRGB16 ] >> 8 );
+ nBlue = (BYTE)( mpColorMap[ nRGB16 ] );
+ mpAcc->SetPixel( nY, nX, BitmapColor( nRed, nGreen, nBlue ) );
+ nX += nXAdd;
+ nXCount++;
+ if ( nXCount == mpFileHeader->nImageWidth )
+ {
+ nX = nXStart;
+ nXCount = 0;
+ nY += nYAdd;
+ nYCount++;
+ }
+ }
+ }
+ }
+ break;
+
+ // 8 bit encoding + indexing
+ case 8 :
+ while ( nYCount < mpFileHeader->nImageHeight )
+ {
+ *mpTGA >> nRunCount;
+ if ( nRunCount & 0x80 ) // a run length packet
+ {
+ *mpTGA >> nDummy;
+ if ( nDummy >= mpFileHeader->nColorMapLength )
+ return FALSE;
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ mpAcc->SetPixel( nY, nX, (BYTE)nDummy );
+ nX += nXAdd;
+ nXCount++;
+ if ( nXCount == mpFileHeader->nImageWidth )
+ {
+ nX = nXStart;
+ nXCount = 0;
+ nY += nYAdd;
+ nYCount++;
+ }
+ }
+ }
+ else // a raw packet
+ {
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+
+ *mpTGA >> nDummy;
+ if ( nDummy >= mpFileHeader->nColorMapLength )
+ return FALSE;
+ mpAcc->SetPixel( nY, nX, (BYTE)nDummy );
+ nX += nXAdd;
+ nXCount++;
+ if ( nXCount == mpFileHeader->nImageWidth )
+ {
+ nX = nXStart;
+ nXCount = 0;
+ nY += nYAdd;
+ nYCount++;
+ }
+ }
+ }
+ }
+ break;
+ default:
+ return FALSE;
+ }
+ }
+ else
+ {
+ switch( nDepth )
+ {
+ // 32 bit transparent true color encoding
+ case 32 :
+ {
+ while ( nYCount < mpFileHeader->nImageHeight )
+ {
+ *mpTGA >> nRunCount;
+ if ( nRunCount & 0x80 ) // a run length packet
+ {
+ *mpTGA >> nBlue >> nGreen >> nRed >> nDummy;
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ mpAcc->SetPixel( nY, nX, BitmapColor( nRed, nGreen, nBlue ) );
+ nX += nXAdd;
+ nXCount++;
+ if ( nXCount == mpFileHeader->nImageWidth )
+ {
+ nX = nXStart;
+ nXCount = 0;
+ nY += nYAdd;
+ nYCount++;
+ }
+ }
+ }
+ else // a raw packet
+ {
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ *mpTGA >> nBlue >> nGreen >> nRed >> nDummy;
+ mpAcc->SetPixel( nY, nX, BitmapColor( nRed, nGreen, nBlue ) );
+ nX += nXAdd;
+ nXCount++;
+ if ( nXCount == mpFileHeader->nImageWidth )
+ {
+ nX = nXStart;
+ nXCount = 0;
+ nY += nYAdd;
+ nYCount++;
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ // 24 bit true color encoding
+ case 24 :
+ while ( nYCount < mpFileHeader->nImageHeight )
+ {
+ *mpTGA >> nRunCount;
+ if ( nRunCount & 0x80 ) // a run length packet
+ {
+ *mpTGA >> nBlue >> nGreen >> nRed;
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ mpAcc->SetPixel( nY, nX, BitmapColor( nRed, nGreen, nBlue ) );
+ nX += nXAdd;
+ nXCount++;
+ if ( nXCount == mpFileHeader->nImageWidth )
+ {
+ nX = nXStart;
+ nXCount = 0;
+ nY += nYAdd;
+ nYCount++;
+ }
+ }
+ }
+ else // a raw packet
+ {
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ *mpTGA >> nBlue >> nGreen >> nRed;
+ mpAcc->SetPixel( nY, nX, BitmapColor( nRed, nGreen, nBlue ) );
+ nX += nXAdd;
+ nXCount++;
+ if ( nXCount == mpFileHeader->nImageWidth )
+ {
+ nX = nXStart;
+ nXCount = 0;
+ nY += nYAdd;
+ nYCount++;
+ }
+ }
+ }
+ }
+ break;
+
+ // 16 bit true color encoding
+ case 16 :
+ while ( nYCount < mpFileHeader->nImageHeight )
+ {
+ *mpTGA >> nRunCount;
+ if ( nRunCount & 0x80 ) // a run length packet
+ {
+ *mpTGA >> nRGB16;
+ nRed = (BYTE)( nRGB16 >> 7 ) & 0xf8;
+ nGreen = (BYTE)( nRGB16 >> 2 ) & 0xf8;
+ nBlue = (BYTE)( nRGB16 << 3 ) & 0xf8;
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ mpAcc->SetPixel( nY, nX, BitmapColor( nRed, nGreen, nBlue ) );
+ nX += nXAdd;
+ nXCount++;
+ if ( nXCount == mpFileHeader->nImageWidth )
+ {
+ nX = nXStart;
+ nXCount = 0;
+ nY += nYAdd;
+ nYCount++;
+ }
+ }
+ }
+ else // a raw packet
+ {
+ for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ )
+ {
+ *mpTGA >> nRGB16;
+ nRed = (BYTE)( nRGB16 >> 7 ) & 0xf8;
+ nGreen = (BYTE)( nRGB16 >> 2 ) & 0xf8;
+ nBlue = (BYTE)( nRGB16 << 3 ) & 0xf8;
+ mpAcc->SetPixel( nY, nX, BitmapColor( nRed, nGreen, nBlue ) );
+ nX += nXAdd;
+ nXCount++;
+ if ( nXCount == mpFileHeader->nImageWidth )
+ {
+ nX = nXStart;
+ nXCount = 0;
+ nY += nYAdd;
+ nYCount++;
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ return FALSE;
+ }
+ }
+ }
+ else
+ {
+ for ( USHORT nYCount = 0; nYCount < mpFileHeader->nImageHeight; nYCount++, nY += nYAdd )
+ {
+ nX = nXStart;
+ nXCount = 0;
+
+ if ( mbIndexing )
+ {
+ switch( nDepth )
+ {
+ // 16 bit indexing
+ case 16 :
+ for (;nXCount < mpFileHeader->nImageWidth; nXCount++, nX += nXAdd )
+ {
+ *mpTGA >> nRGB16;
+ if ( nRGB16 >= mpFileHeader->nColorMapLength )
+ return FALSE;
+ nRed = (BYTE)( mpColorMap[ nRGB16 ] >> 16 );
+ nGreen = (BYTE)( mpColorMap[ nRGB16 ] >> 8 );
+ nBlue = (BYTE)( mpColorMap[ nRGB16 ] );
+ mpAcc->SetPixel( nY, nX, BitmapColor( nRed, nGreen, nBlue ) );
+ }
+ break;
+
+ // 8 bit indexing
+ case 8 :
+ for (;nXCount < mpFileHeader->nImageWidth; nXCount++, nX += nXAdd )
+ {
+ *mpTGA >> nDummy;
+ if ( nDummy >= mpFileHeader->nColorMapLength )
+ return FALSE;
+ mpAcc->SetPixel( nY, nX, (BYTE)nDummy );
+ }
+ break;
+ default:
+ return FALSE;
+ }
+ }
+ else
+ {
+ switch( nDepth )
+ {
+ // 32 bit true color
+ case 32 :
+ {
+ for (;nXCount < mpFileHeader->nImageWidth; nXCount++, nX += nXAdd )
+ {
+ *mpTGA >> nBlue >> nGreen >> nRed >> nDummy;
+ mpAcc->SetPixel( nY, nX, BitmapColor( nRed, nGreen, nBlue ) );
+ }
+ }
+ break;
+
+ // 24 bit true color
+ case 24 :
+ for (;nXCount < mpFileHeader->nImageWidth; nXCount++, nX += nXAdd )
+ {
+ *mpTGA >> nBlue >> nGreen >> nRed;
+ mpAcc->SetPixel( nY, nX, BitmapColor( nRed, nGreen, nBlue ) );
+ }
+ break;
+
+ // 16 bit true color
+ case 16 :
+ for (;nXCount < mpFileHeader->nImageWidth; nXCount++, nX += nXAdd )
+ {
+ *mpTGA >> nRGB16;
+ nRed = (BYTE)( nRGB16 >> 7 ) & 0xf8;
+ nGreen = (BYTE)( nRGB16 >> 2 ) & 0xf8;
+ nBlue = (BYTE)( nRGB16 << 3 ) & 0xf8;
+ mpAcc->SetPixel( nY, nX, BitmapColor( nRed, nGreen, nBlue ) );
+ }
+ break;
+ default:
+ return FALSE;
+ }
+ }
+ }
+ }
+ return mbStatus;
+}
+
+// -------------------------------------------------------------------------------------------
+
+BOOL TGAReader::ImplReadPalette()
+{
+ if ( mbIndexing ) // read the colormap
+ {
+ USHORT nColors = mpFileHeader->nColorMapLength;
+
+ if ( !nColors ) // colors == 0 ? -> we will build a grayscale palette
+ {
+ if ( mpFileHeader->nPixelDepth != 8 )
+ return FALSE;
+ nColors = 256;
+ mpFileHeader->nColorMapLength = 256;
+ mpFileHeader->nColorMapEntrySize = 0x3f; // patch for the following switch routine
+ }
+ mpColorMap = new UINT32[ nColors ]; // we will always index dwords
+ if ( mpColorMap == FALSE )
+ return FALSE; // out of memory %&!$&/!"§$
+
+ switch( mpFileHeader->nColorMapEntrySize )
+ {
+ case 0x3f :
+ {
+ for ( ULONG i = 0; i < nColors; i++ )
+ {
+ mpColorMap[ i ] = ( i << 16 ) + ( i << 8 ) + i;
+ }
+ }
+ break;
+
+ case 32 :
+ mpTGA->Read( mpColorMap, 4 * nColors );
+ break;
+
+ case 24 :
+ {
+ for ( ULONG i = 0; i < nColors; i++ )
+ {
+ mpTGA->Read( &mpColorMap[ i ], 3 );
+ }
+ }
+ break;
+
+ case 15 :
+ case 16 :
+ {
+ for ( ULONG i = 0; i < nColors; i++ )
+ {
+ UINT16 nTemp;
+ *mpTGA >> nTemp;
+ mpColorMap[ i ] = ( ( nTemp & 0x7c00 ) << 9 ) + ( ( nTemp & 0x01e0 ) << 6 ) +
+ ( ( nTemp & 0x1f ) << 3 );
+ }
+ }
+ break;
+
+ default :
+ return FALSE;
+ }
+ if ( mnDestBitDepth <= 8 )
+ {
+ USHORT nDestColors = ( 1 << mnDestBitDepth );
+ if ( nColors > nDestColors )
+ return FALSE;
+
+ mpAcc->SetPaletteEntryCount( nColors );
+ for ( USHORT i = 0; i < nColors; i++ )
+ {
+ mpAcc->SetPaletteColor( i, Color( (BYTE)( mpColorMap[ i ] >> 16 ),
+ (BYTE)( mpColorMap[ i ] >> 8 ), (BYTE)(mpColorMap[ i ] ) ) );
+ }
+ }
+ }
+
+ return mbStatus;
+}
+
+//================== GraphicImport - die exportierte Funktion ================
+
+#ifdef WNT
+extern "C" BOOL _cdecl GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#else
+extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData,
+ Config *, BOOL)
+#endif
+{
+ TGAReader aTGAReader;
+
+ return aTGAReader.ReadTGA( rStream, rGraphic, pCallback, pCallerData );
+}
+
+//================== ein bischen Muell fuer Windows ==========================
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
+
diff --git a/goodies/source/filter.vcl/itga/makefile.mk b/goodies/source/filter.vcl/itga/makefile.mk
new file mode 100644
index 000000000000..1b00a963dbc0
--- /dev/null
+++ b/goodies/source/filter.vcl/itga/makefile.mk
@@ -0,0 +1,168 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=itga
+DEPTARGET=vitga
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SLOFILES = $(SLO)$/itga.obj
+
+# ==========================================================================
+
+SHL1TARGET= itg$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= itga
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(CPPULIB)
+SHL1DEPN= $(LB)$/itga.lib
+SHL1LIBS= $(SLB)$/itga.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/itga.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicImport >>$@
+.ELSE
+ @echo _GraphicImport >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET).DLL >>$@
+ @ldump -E1 -A $(SLB)$/itga.lib >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicImport >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/filter.vcl/itiff/ccidecom.cxx b/goodies/source/filter.vcl/itiff/ccidecom.cxx
new file mode 100644
index 000000000000..538cea411852
--- /dev/null
+++ b/goodies/source/filter.vcl/itiff/ccidecom.cxx
@@ -0,0 +1,1143 @@
+/*************************************************************************
+ *
+ * $RCSfile: ccidecom.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "ccidecom.hxx"
+
+//=============================== Huffman-Tabellen ========================
+
+//---------------------------- White-Run ------------------------------
+
+#define CCIWhiteTableSize 105
+
+const CCIHuffmanTableEntry CCIWhiteTable[CCIWhiteTableSize]={
+ { 0, 0x0035, 8 },
+ { 1, 0x0007, 6 },
+ { 2, 0x0007, 4 },
+ { 3, 0x0008, 4 },
+ { 4, 0x000b, 4 },
+ { 5, 0x000c, 4 },
+ { 6, 0x000e, 4 },
+ { 7, 0x000f, 4 },
+ { 8, 0x0013, 5 },
+ { 9, 0x0014, 5 },
+ { 10, 0x0007, 5 },
+ { 11, 0x0008, 5 },
+ { 12, 0x0008, 6 },
+ { 13, 0x0003, 6 },
+ { 14, 0x0034, 6 },
+ { 15, 0x0035, 6 },
+ { 16, 0x002a, 6 },
+ { 17, 0x002b, 6 },
+ { 18, 0x0027, 7 },
+ { 19, 0x000c, 7 },
+ { 20, 0x0008, 7 },
+ { 21, 0x0017, 7 },
+ { 22, 0x0003, 7 },
+ { 23, 0x0004, 7 },
+ { 24, 0x0028, 7 },
+ { 25, 0x002b, 7 },
+ { 26, 0x0013, 7 },
+ { 27, 0x0024, 7 },
+ { 28, 0x0018, 7 },
+ { 29, 0x0002, 8 },
+ { 30, 0x0003, 8 },
+ { 31, 0x001a, 8 },
+ { 32, 0x001b, 8 },
+ { 33, 0x0012, 8 },
+ { 34, 0x0013, 8 },
+ { 35, 0x0014, 8 },
+ { 36, 0x0015, 8 },
+ { 37, 0x0016, 8 },
+ { 38, 0x0017, 8 },
+ { 39, 0x0028, 8 },
+ { 40, 0x0029, 8 },
+ { 41, 0x002a, 8 },
+ { 42, 0x002b, 8 },
+ { 43, 0x002c, 8 },
+ { 44, 0x002d, 8 },
+ { 45, 0x0004, 8 },
+ { 46, 0x0005, 8 },
+ { 47, 0x000a, 8 },
+ { 48, 0x000b, 8 },
+ { 49, 0x0052, 8 },
+ { 50, 0x0053, 8 },
+ { 51, 0x0054, 8 },
+ { 52, 0x0055, 8 },
+ { 53, 0x0024, 8 },
+ { 54, 0x0025, 8 },
+ { 55, 0x0058, 8 },
+ { 56, 0x0059, 8 },
+ { 57, 0x005a, 8 },
+ { 58, 0x005b, 8 },
+ { 59, 0x004a, 8 },
+ { 60, 0x004b, 8 },
+ { 61, 0x0032, 8 },
+ { 62, 0x0033, 8 },
+ { 63, 0x0034, 8 },
+ { 64, 0x001b, 5 },
+ { 128, 0x0012, 5 },
+ { 192, 0x0017, 6 },
+ { 256, 0x0037, 7 },
+ { 320, 0x0036, 8 },
+ { 384, 0x0037, 8 },
+ { 448, 0x0064, 8 },
+ { 512, 0x0065, 8 },
+ { 576, 0x0068, 8 },
+ { 640, 0x0067, 8 },
+ { 704, 0x00cc, 9 },
+ { 768, 0x00cd, 9 },
+ { 832, 0x00d2, 9 },
+ { 896, 0x00d3, 9 },
+ { 960, 0x00d4, 9 },
+ { 1024, 0x00d5, 9 },
+ { 1088, 0x00d6, 9 },
+ { 1152, 0x00d7, 9 },
+ { 1216, 0x00d8, 9 },
+ { 1280, 0x00d9, 9 },
+ { 1344, 0x00da, 9 },
+ { 1408, 0x00db, 9 },
+ { 1472, 0x0098, 9 },
+ { 1536, 0x0099, 9 },
+ { 1600, 0x009a, 9 },
+ { 1664, 0x0018, 6 },
+ { 1728, 0x009b, 9 },
+ { 1792, 0x0008, 11 },
+ { 1856, 0x000c, 11 },
+ { 1920, 0x000d, 11 },
+ { 1984, 0x0012, 12 },
+ { 2048, 0x0013, 12 },
+ { 2112, 0x0014, 12 },
+ { 2176, 0x0015, 12 },
+ { 2240, 0x0016, 12 },
+ { 2304, 0x0017, 12 },
+ { 2368, 0x001c, 12 },
+ { 2432, 0x001d, 12 },
+ { 2496, 0x001e, 12 },
+ { 2560, 0x001f, 12 },
+ { 9999, 0x0001, 12 } // EOL
+};
+
+//---------------------------- Black-Run ------------------------------
+
+#define CCIBlackTableSize 105
+
+const CCIHuffmanTableEntry CCIBlackTable[CCIBlackTableSize]={
+ { 0, 0x0037, 10 },
+ { 1, 0x0002, 3 },
+ { 2, 0x0003, 2 },
+ { 3, 0x0002, 2 },
+ { 4, 0x0003, 3 },
+ { 5, 0x0003, 4 },
+ { 6, 0x0002, 4 },
+ { 7, 0x0003, 5 },
+ { 8, 0x0005, 6 },
+ { 9, 0x0004, 6 },
+ { 10, 0x0004, 7 },
+ { 11, 0x0005, 7 },
+ { 12, 0x0007, 7 },
+ { 13, 0x0004, 8 },
+ { 14, 0x0007, 8 },
+ { 15, 0x0018, 9 },
+ { 16, 0x0017, 10 },
+ { 17, 0x0018, 10 },
+ { 18, 0x0008, 10 },
+ { 19, 0x0067, 11 },
+ { 20, 0x0068, 11 },
+ { 21, 0x006c, 11 },
+ { 22, 0x0037, 11 },
+ { 23, 0x0028, 11 },
+ { 24, 0x0017, 11 },
+ { 25, 0x0018, 11 },
+ { 26, 0x00ca, 12 },
+ { 27, 0x00cb, 12 },
+ { 28, 0x00cc, 12 },
+ { 29, 0x00cd, 12 },
+ { 30, 0x0068, 12 },
+ { 31, 0x0069, 12 },
+ { 32, 0x006a, 12 },
+ { 33, 0x006b, 12 },
+ { 34, 0x00d2, 12 },
+ { 35, 0x00d3, 12 },
+ { 36, 0x00d4, 12 },
+ { 37, 0x00d5, 12 },
+ { 38, 0x00d6, 12 },
+ { 39, 0x00d7, 12 },
+ { 40, 0x006c, 12 },
+ { 41, 0x006d, 12 },
+ { 42, 0x00da, 12 },
+ { 43, 0x00db, 12 },
+ { 44, 0x0054, 12 },
+ { 45, 0x0055, 12 },
+ { 46, 0x0056, 12 },
+ { 47, 0x0057, 12 },
+ { 48, 0x0064, 12 },
+ { 49, 0x0065, 12 },
+ { 50, 0x0052, 12 },
+ { 51, 0x0053, 12 },
+ { 52, 0x0024, 12 },
+ { 53, 0x0037, 12 },
+ { 54, 0x0038, 12 },
+ { 55, 0x0027, 12 },
+ { 56, 0x0028, 12 },
+ { 57, 0x0058, 12 },
+ { 58, 0x0059, 12 },
+ { 59, 0x002b, 12 },
+ { 60, 0x002c, 12 },
+ { 61, 0x005a, 12 },
+ { 62, 0x0066, 12 },
+ { 63, 0x0067, 12 },
+ { 64, 0x000f, 10 },
+ { 128, 0x00c8, 12 },
+ { 192, 0x00c9, 12 },
+ { 256, 0x005b, 12 },
+ { 320, 0x0033, 12 },
+ { 384, 0x0034, 12 },
+ { 448, 0x0035, 12 },
+ { 512, 0x006c, 13 },
+ { 576, 0x006d, 13 },
+ { 640, 0x004a, 13 },
+ { 704, 0x004b, 13 },
+ { 768, 0x004c, 13 },
+ { 832, 0x004d, 13 },
+ { 896, 0x0072, 13 },
+ { 960, 0x0073, 13 },
+ { 1024, 0x0074, 13 },
+ { 1088, 0x0075, 13 },
+ { 1152, 0x0076, 13 },
+ { 1216, 0x0077, 13 },
+ { 1280, 0x0052, 13 },
+ { 1344, 0x0053, 13 },
+ { 1408, 0x0054, 13 },
+ { 1472, 0x0055, 13 },
+ { 1536, 0x005a, 13 },
+ { 1600, 0x005b, 13 },
+ { 1664, 0x0064, 13 },
+ { 1728, 0x0065, 13 },
+ { 1792, 0x0008, 11 },
+ { 1856, 0x000c, 11 },
+ { 1920, 0x000d, 11 },
+ { 1984, 0x0012, 12 },
+ { 2048, 0x0013, 12 },
+ { 2112, 0x0014, 12 },
+ { 2176, 0x0015, 12 },
+ { 2240, 0x0016, 12 },
+ { 2304, 0x0017, 12 },
+ { 2368, 0x001c, 12 },
+ { 2432, 0x001d, 12 },
+ { 2496, 0x001e, 12 },
+ { 2560, 0x001f, 12 },
+ { 9999, 0x0001, 12 } // EOL
+};
+
+
+//---------------------------- 2D-Mode --------------------------------
+
+#define CCI2DMODE_UNCOMP 0
+#define CCI2DMODE_PASS 1
+#define CCI2DMODE_HORZ 2
+#define CCI2DMODE_VERT_L3 3
+#define CCI2DMODE_VERT_L2 4
+#define CCI2DMODE_VERT_L1 5
+#define CCI2DMODE_VERT_0 6
+#define CCI2DMODE_VERT_R1 7
+#define CCI2DMODE_VERT_R2 8
+#define CCI2DMODE_VERT_R3 9
+
+#define CCI2DModeTableSize 10
+
+const CCIHuffmanTableEntry CCI2DModeTable[CCI2DModeTableSize]={
+ { CCI2DMODE_UNCOMP , 0x000f, 10 },
+ { CCI2DMODE_PASS , 0x0001, 4 },
+ { CCI2DMODE_HORZ , 0x0001, 3 },
+ { CCI2DMODE_VERT_L3, 0x0002, 7 },
+ { CCI2DMODE_VERT_L2, 0x0002, 6 },
+ { CCI2DMODE_VERT_L1, 0x0002, 3 },
+ { CCI2DMODE_VERT_0 , 0x0001, 1 },
+ { CCI2DMODE_VERT_R1, 0x0003, 3 },
+ { CCI2DMODE_VERT_R2, 0x0003, 6 },
+ { CCI2DMODE_VERT_R3, 0x0003, 7 }
+};
+
+
+//-------------------------- 2D-Uncompressed-Mode ----------------------
+
+#define CCIUNCOMP_0White_1Black 0
+#define CCIUNCOMP_1White_1Black 1
+#define CCIUNCOMP_2White_1Black 2
+#define CCIUNCOMP_3White_1Black 3
+#define CCIUNCOMP_4White_1Black 4
+#define CCIUNCOMP_5White 5
+#define CCIUNCOMP_0White_End 6
+#define CCIUNCOMP_1White_End 7
+#define CCIUNCOMP_2White_End 8
+#define CCIUNCOMP_3White_End 9
+#define CCIUNCOMP_4White_End 10
+
+#define CCIUncompTableSize 11
+
+const CCIHuffmanTableEntry CCIUncompTable[CCIUncompTableSize]={
+ { CCIUNCOMP_0White_1Black, 0x0001, 1 },
+ { CCIUNCOMP_1White_1Black, 0x0001, 2 },
+ { CCIUNCOMP_2White_1Black, 0x0001, 3 },
+ { CCIUNCOMP_3White_1Black, 0x0001, 4 },
+ { CCIUNCOMP_4White_1Black, 0x0001, 5 },
+ { CCIUNCOMP_5White , 0x0001, 6 },
+ { CCIUNCOMP_0White_End , 0x0001, 7 },
+ { CCIUNCOMP_1White_End , 0x0001, 8 },
+ { CCIUNCOMP_2White_End , 0x0001, 9 },
+ { CCIUNCOMP_3White_End , 0x0001, 10 },
+ { CCIUNCOMP_4White_End , 0x0001, 11 }
+};
+
+
+//================== Sicherheitskopie der Huffman-Tabellen ================
+// Um sicher zugehen, dass die Huffman-Tabellen keine Fehler enthalten,
+// wurden sie zweimal von unterschiedlichen Quellen eingegeben (Uff) und
+// verglichen.
+// Da sich aber im Laufe der Pflege des Source-Codes mal ein Fehler
+// einschleichen koennte (z.B. versehentlicher druck einer Taste im Editor)
+// werden die Tablellen hier weiterhin zweimal aufgefuehrt und zur Laufzeit
+// verglichen. (Wenn der Vergleich fehlschlaegt, liefert CCIDecompressor
+// immer einen Fehler). Das Ganze mag etwas wahnsinnig erscheinen, aber ein Fehler
+// in den Tabellen waere sonst sehr sehr schwer zu erkennen, zumal es
+// unwahrscheinlich ist, dass eine oder mehere Beispieldateien alle Codes
+// durchlaufen.
+
+const CCIHuffmanTableEntry CCIWhiteTableSave[CCIWhiteTableSize]={
+ { 0, 0x0035, 8 },
+ { 1, 0x0007, 6 },
+ { 2, 0x0007, 4 },
+ { 3, 0x0008, 4 },
+ { 4, 0x000b, 4 },
+ { 5, 0x000c, 4 },
+ { 6, 0x000e, 4 },
+ { 7, 0x000f, 4 },
+ { 8, 0x0013, 5 },
+ { 9, 0x0014, 5 },
+ { 10, 0x0007, 5 },
+ { 11, 0x0008, 5 },
+ { 12, 0x0008, 6 },
+ { 13, 0x0003, 6 },
+ { 14, 0x0034, 6 },
+ { 15, 0x0035, 6 },
+ { 16, 0x002a, 6 },
+ { 17, 0x002b, 6 },
+ { 18, 0x0027, 7 },
+ { 19, 0x000c, 7 },
+ { 20, 0x0008, 7 },
+ { 21, 0x0017, 7 },
+ { 22, 0x0003, 7 },
+ { 23, 0x0004, 7 },
+ { 24, 0x0028, 7 },
+ { 25, 0x002b, 7 },
+ { 26, 0x0013, 7 },
+ { 27, 0x0024, 7 },
+ { 28, 0x0018, 7 },
+ { 29, 0x0002, 8 },
+ { 30, 0x0003, 8 },
+ { 31, 0x001a, 8 },
+ { 32, 0x001b, 8 },
+ { 33, 0x0012, 8 },
+ { 34, 0x0013, 8 },
+ { 35, 0x0014, 8 },
+ { 36, 0x0015, 8 },
+ { 37, 0x0016, 8 },
+ { 38, 0x0017, 8 },
+ { 39, 0x0028, 8 },
+ { 40, 0x0029, 8 },
+ { 41, 0x002a, 8 },
+ { 42, 0x002b, 8 },
+ { 43, 0x002c, 8 },
+ { 44, 0x002d, 8 },
+ { 45, 0x0004, 8 },
+ { 46, 0x0005, 8 },
+ { 47, 0x000a, 8 },
+ { 48, 0x000b, 8 },
+ { 49, 0x0052, 8 },
+ { 50, 0x0053, 8 },
+ { 51, 0x0054, 8 },
+ { 52, 0x0055, 8 },
+ { 53, 0x0024, 8 },
+ { 54, 0x0025, 8 },
+ { 55, 0x0058, 8 },
+ { 56, 0x0059, 8 },
+ { 57, 0x005a, 8 },
+ { 58, 0x005b, 8 },
+ { 59, 0x004a, 8 },
+ { 60, 0x004b, 8 },
+ { 61, 0x0032, 8 },
+ { 62, 0x0033, 8 },
+ { 63, 0x0034, 8 },
+ { 64, 0x001b, 5 },
+ { 128, 0x0012, 5 },
+ { 192, 0x0017, 6 },
+ { 256, 0x0037, 7 },
+ { 320, 0x0036, 8 },
+ { 384, 0x0037, 8 },
+ { 448, 0x0064, 8 },
+ { 512, 0x0065, 8 },
+ { 576, 0x0068, 8 },
+ { 640, 0x0067, 8 },
+ { 704, 0x00cc, 9 },
+ { 768, 0x00cd, 9 },
+ { 832, 0x00d2, 9 },
+ { 896, 0x00d3, 9 },
+ { 960, 0x00d4, 9 },
+ { 1024, 0x00d5, 9 },
+ { 1088, 0x00d6, 9 },
+ { 1152, 0x00d7, 9 },
+ { 1216, 0x00d8, 9 },
+ { 1280, 0x00d9, 9 },
+ { 1344, 0x00da, 9 },
+ { 1408, 0x00db, 9 },
+ { 1472, 0x0098, 9 },
+ { 1536, 0x0099, 9 },
+ { 1600, 0x009a, 9 },
+ { 1664, 0x0018, 6 },
+ { 1728, 0x009b, 9 },
+ { 1792, 0x0008, 11 },
+ { 1856, 0x000c, 11 },
+ { 1920, 0x000d, 11 },
+ { 1984, 0x0012, 12 },
+ { 2048, 0x0013, 12 },
+ { 2112, 0x0014, 12 },
+ { 2176, 0x0015, 12 },
+ { 2240, 0x0016, 12 },
+ { 2304, 0x0017, 12 },
+ { 2368, 0x001c, 12 },
+ { 2432, 0x001d, 12 },
+ { 2496, 0x001e, 12 },
+ { 2560, 0x001f, 12 },
+ { 9999, 0x0001, 12 } // EOL
+};
+
+const CCIHuffmanTableEntry CCIBlackTableSave[CCIBlackTableSize]={
+ { 0, 0x0037, 10 },
+ { 1, 0x0002, 3 },
+ { 2, 0x0003, 2 },
+ { 3, 0x0002, 2 },
+ { 4, 0x0003, 3 },
+ { 5, 0x0003, 4 },
+ { 6, 0x0002, 4 },
+ { 7, 0x0003, 5 },
+ { 8, 0x0005, 6 },
+ { 9, 0x0004, 6 },
+ { 10, 0x0004, 7 },
+ { 11, 0x0005, 7 },
+ { 12, 0x0007, 7 },
+ { 13, 0x0004, 8 },
+ { 14, 0x0007, 8 },
+ { 15, 0x0018, 9 },
+ { 16, 0x0017, 10 },
+ { 17, 0x0018, 10 },
+ { 18, 0x0008, 10 },
+ { 19, 0x0067, 11 },
+ { 20, 0x0068, 11 },
+ { 21, 0x006c, 11 },
+ { 22, 0x0037, 11 },
+ { 23, 0x0028, 11 },
+ { 24, 0x0017, 11 },
+ { 25, 0x0018, 11 },
+ { 26, 0x00ca, 12 },
+ { 27, 0x00cb, 12 },
+ { 28, 0x00cc, 12 },
+ { 29, 0x00cd, 12 },
+ { 30, 0x0068, 12 },
+ { 31, 0x0069, 12 },
+ { 32, 0x006a, 12 },
+ { 33, 0x006b, 12 },
+ { 34, 0x00d2, 12 },
+ { 35, 0x00d3, 12 },
+ { 36, 0x00d4, 12 },
+ { 37, 0x00d5, 12 },
+ { 38, 0x00d6, 12 },
+ { 39, 0x00d7, 12 },
+ { 40, 0x006c, 12 },
+ { 41, 0x006d, 12 },
+ { 42, 0x00da, 12 },
+ { 43, 0x00db, 12 },
+ { 44, 0x0054, 12 },
+ { 45, 0x0055, 12 },
+ { 46, 0x0056, 12 },
+ { 47, 0x0057, 12 },
+ { 48, 0x0064, 12 },
+ { 49, 0x0065, 12 },
+ { 50, 0x0052, 12 },
+ { 51, 0x0053, 12 },
+ { 52, 0x0024, 12 },
+ { 53, 0x0037, 12 },
+ { 54, 0x0038, 12 },
+ { 55, 0x0027, 12 },
+ { 56, 0x0028, 12 },
+ { 57, 0x0058, 12 },
+ { 58, 0x0059, 12 },
+ { 59, 0x002b, 12 },
+ { 60, 0x002c, 12 },
+ { 61, 0x005a, 12 },
+ { 62, 0x0066, 12 },
+ { 63, 0x0067, 12 },
+ { 64, 0x000f, 10 },
+ { 128, 0x00c8, 12 },
+ { 192, 0x00c9, 12 },
+ { 256, 0x005b, 12 },
+ { 320, 0x0033, 12 },
+ { 384, 0x0034, 12 },
+ { 448, 0x0035, 12 },
+ { 512, 0x006c, 13 },
+ { 576, 0x006d, 13 },
+ { 640, 0x004a, 13 },
+ { 704, 0x004b, 13 },
+ { 768, 0x004c, 13 },
+ { 832, 0x004d, 13 },
+ { 896, 0x0072, 13 },
+ { 960, 0x0073, 13 },
+ { 1024, 0x0074, 13 },
+ { 1088, 0x0075, 13 },
+ { 1152, 0x0076, 13 },
+ { 1216, 0x0077, 13 },
+ { 1280, 0x0052, 13 },
+ { 1344, 0x0053, 13 },
+ { 1408, 0x0054, 13 },
+ { 1472, 0x0055, 13 },
+ { 1536, 0x005a, 13 },
+ { 1600, 0x005b, 13 },
+ { 1664, 0x0064, 13 },
+ { 1728, 0x0065, 13 },
+ { 1792, 0x0008, 11 },
+ { 1856, 0x000c, 11 },
+ { 1920, 0x000d, 11 },
+ { 1984, 0x0012, 12 },
+ { 2048, 0x0013, 12 },
+ { 2112, 0x0014, 12 },
+ { 2176, 0x0015, 12 },
+ { 2240, 0x0016, 12 },
+ { 2304, 0x0017, 12 },
+ { 2368, 0x001c, 12 },
+ { 2432, 0x001d, 12 },
+ { 2496, 0x001e, 12 },
+ { 2560, 0x001f, 12 },
+ { 9999, 0x0001, 12 } // EOL
+};
+
+
+const CCIHuffmanTableEntry CCI2DModeTableSave[CCI2DModeTableSize]={
+ { CCI2DMODE_UNCOMP , 0x000f, 10 },
+ { CCI2DMODE_PASS , 0x0001, 4 },
+ { CCI2DMODE_HORZ , 0x0001, 3 },
+ { CCI2DMODE_VERT_L3, 0x0002, 7 },
+ { CCI2DMODE_VERT_L2, 0x0002, 6 },
+ { CCI2DMODE_VERT_L1, 0x0002, 3 },
+ { CCI2DMODE_VERT_0 , 0x0001, 1 },
+ { CCI2DMODE_VERT_R1, 0x0003, 3 },
+ { CCI2DMODE_VERT_R2, 0x0003, 6 },
+ { CCI2DMODE_VERT_R3, 0x0003, 7 }
+};
+
+
+const CCIHuffmanTableEntry CCIUncompTableSave[CCIUncompTableSize]={
+ { CCIUNCOMP_0White_1Black, 0x0001, 1 },
+ { CCIUNCOMP_1White_1Black, 0x0001, 2 },
+ { CCIUNCOMP_2White_1Black, 0x0001, 3 },
+ { CCIUNCOMP_3White_1Black, 0x0001, 4 },
+ { CCIUNCOMP_4White_1Black, 0x0001, 5 },
+ { CCIUNCOMP_5White , 0x0001, 6 },
+ { CCIUNCOMP_0White_End , 0x0001, 7 },
+ { CCIUNCOMP_1White_End , 0x0001, 8 },
+ { CCIUNCOMP_2White_End , 0x0001, 9 },
+ { CCIUNCOMP_3White_End , 0x0001, 10 },
+ { CCIUNCOMP_4White_End , 0x0001, 11 }
+};
+
+//=========================================================================
+
+
+CCIDecompressor::CCIDecompressor( ULONG nOpts, UINT32 nImageWidth ) :
+ bTableBad ( FALSE ),
+ pLastLine ( NULL ),
+ bStatus ( FALSE ),
+ pByteSwap ( NULL ),
+ nOptions ( nOpts ),
+ nWidth ( nImageWidth )
+{
+ if ( nOpts & CCI_OPTION_INVERSEBITORDER )
+ {
+ pByteSwap = new BYTE[ 256 ];
+ for ( int i = 0; i < 256; i++ )
+ {
+ pByteSwap[ i ] = ( i << 7 ) | ( ( i & 2 ) << 5 ) | ( ( i & 4 ) << 3 ) | ( ( i & 8 ) << 1 ) |
+ ( ( i & 16 ) >> 1 ) | ( ( i & 32 ) >> 3 ) | ( ( i & 64 ) >> 5 ) | ( ( i & 128 ) >> 7 );
+ }
+ }
+
+ pWhiteLookUp =new CCILookUpTableEntry[1<<13];
+ pBlackLookUp =new CCILookUpTableEntry[1<<13];
+ p2DModeLookUp=new CCILookUpTableEntry[1<<10];
+ pUncompLookUp=new CCILookUpTableEntry[1<<11];
+
+ MakeLookUp(CCIWhiteTable,CCIWhiteTableSave,pWhiteLookUp,CCIWhiteTableSize,13);
+ MakeLookUp(CCIBlackTable,CCIBlackTableSave,pBlackLookUp,CCIBlackTableSize,13);
+ MakeLookUp(CCI2DModeTable,CCI2DModeTableSave,p2DModeLookUp,CCI2DModeTableSize,10);
+ MakeLookUp(CCIUncompTable,CCIUncompTableSave,pUncompLookUp,CCIUncompTableSize,11);
+}
+
+
+CCIDecompressor::~CCIDecompressor()
+{
+ delete pByteSwap;
+ delete pLastLine;
+ delete pWhiteLookUp;
+ delete pBlackLookUp;
+ delete p2DModeLookUp;
+ delete pUncompLookUp;
+}
+
+
+void CCIDecompressor::StartDecompression( SvStream & rIStream )
+{
+ pIStream = &rIStream;
+ nInputBitsBufSize = 0;
+ bFirstEOL = TRUE;
+ bStatus = TRUE;
+ nEOLCount = 0;
+
+ if ( bTableBad == TRUE )
+ return;
+}
+
+
+BOOL CCIDecompressor::DecompressScanline( BYTE * pTarget, ULONG nTargetBits )
+{
+ USHORT i;
+ BYTE * pSrc,* pDst;
+ BOOL b2D;
+
+ if ( nEOLCount >= 5 ) // RTC( Return To Controller )
+ return TRUE;
+
+ if ( bStatus == FALSE )
+ return FALSE;
+
+ // Wenn EOL-Codes vorhanden sind, steht der EOL-Code auch vor der ersten Zeile.
+ // (und ich dachte EOL heisst 'End Of Line'...)
+ // Daher lesen wir den EOL-Code immer vor jeder Zeile als erstes ein:
+ if ( nOptions & CCI_OPTION_EOL )
+ {
+ if ( bFirstEOL )
+ {
+ UINT32 nCurPos = pIStream->Tell();
+ UINT16 nOldInputBitsBufSize = nInputBitsBufSize;
+ UINT32 nOldInputBitsBuf = nInputBitsBuf;
+ if ( ReadEOL( 32 ) == FALSE )
+ {
+ nInputBitsBufSize = nOldInputBitsBufSize;
+ nInputBitsBuf = nOldInputBitsBuf;
+ pIStream->Seek( nCurPos );
+ nOptions &=~ CCI_OPTION_EOL; // CCITT Group 3 - Compression Type 2
+ }
+ bFirstEOL = FALSE;
+ }
+ else
+ {
+ if ( ReadEOL( nTargetBits ) == FALSE )
+ {
+ return bStatus;
+ }
+ }
+ }
+
+ if ( nEOLCount >= 5 ) // RTC( Return To Controller )
+ return TRUE;
+
+ // ggf. eine weisse vorherige Zeile herstellen fuer 2D:
+ if ( nOptions & CCI_OPTION_2D )
+ {
+ if ( pLastLine == NULL || nLastLineSize != ( ( nTargetBits + 7 ) >> 3 ) )
+ {
+ if ( pLastLine == NULL )
+ delete pLastLine;
+ nLastLineSize = ( nTargetBits + 7 ) >> 3;
+ pLastLine = new BYTE[ nLastLineSize ];
+ pDst = pLastLine;
+ for ( i = 0; i < nLastLineSize; i++ ) *( pDst++ ) = 0x00;
+ }
+ }
+ // ggf. Zeilen-Anfang auf naechste Byte-Grenze runden:
+ if ( nOptions & CCI_OPTION_BYTEALIGNROW )
+ nInputBitsBufSize &= 0xfff8;
+
+ // Ist es eine 2D-Zeile ?:
+ if ( nOptions & CCI_OPTION_2D )
+ {
+ if ( nOptions & CCI_OPTION_EOL )
+ b2D = Read2DTag();
+ else
+ b2D = TRUE;
+ }
+ else
+ b2D = FALSE;
+
+ // Zeile einlesen:
+ if ( b2D )
+ Read2DScanlineData( pTarget, (USHORT)nTargetBits );
+ else
+ Read1DScanlineData( pTarget, (USHORT)nTargetBits );
+
+ // Wenn wir im 2D-Modus sind, muessen wir uns die Zeile merken:
+ if ( nOptions & CCI_OPTION_2D && bStatus == TRUE )
+ {
+ pSrc = pTarget;
+ pDst = pLastLine;
+ for ( i = 0; i < nLastLineSize; i++ ) *(pDst++)=*(pSrc++);
+ }
+
+ if ( pIStream->GetError() )
+ bStatus = FALSE;
+
+ return bStatus;
+}
+
+
+void CCIDecompressor::MakeLookUp(const CCIHuffmanTableEntry * pHufTab,
+ const CCIHuffmanTableEntry * pHufTabSave,
+ CCILookUpTableEntry * pLookUp,
+ USHORT nHuffmanTableSize,
+ USHORT nMaxCodeBits)
+{
+ USHORT i,j,nMinCode,nMaxCode,nLookUpSize,nMask;
+
+ if (bTableBad==TRUE) return;
+
+ nLookUpSize=1<<nMaxCodeBits;
+
+ nMask=0xffff>>(16-nMaxCodeBits);
+
+ for (i=0; i<nLookUpSize; i++) pLookUp[i].nCodeBits=0;
+ for (i=0; i<nHuffmanTableSize; i++) {
+ if ( pHufTab[i].nValue!=pHufTabSave[i].nValue ||
+ pHufTab[i].nCode!=pHufTabSave[i].nCode ||
+ pHufTab[i].nCodeBits!=pHufTabSave[i].nCodeBits ||
+ pHufTab[i].nCodeBits==0 ||
+ pHufTab[i].nCodeBits>nMaxCodeBits )
+ {
+ bTableBad=TRUE;
+ return;
+ }
+ nMinCode = nMask & (pHufTab[i].nCode << (nMaxCodeBits-pHufTab[i].nCodeBits));
+ nMaxCode = nMinCode | (nMask >> pHufTab[i].nCodeBits);
+ for (j=nMinCode; j<=nMaxCode; j++) {
+ if (pLookUp[j].nCodeBits!=0) {
+ bTableBad=TRUE;
+ return;
+ }
+ pLookUp[j].nValue=pHufTab[i].nValue;
+ pLookUp[j].nCodeBits=pHufTab[i].nCodeBits;
+ }
+ }
+}
+
+
+BOOL CCIDecompressor::ReadEOL( UINT32 nMaxFillBits )
+{
+ USHORT nCode;
+ BYTE nByte;
+
+ // if (nOptions&CCI_OPTION_BYTEALIGNEOL) nMaxFillBits=7; else nMaxFillBits=0;
+ // Buuuh: Entweder wird die Option in itiff.cxx nicht richtig gesetzt (-> Fehler in Doku)
+ // oder es gibt tatsaechlich gemeine Export-Filter, die immer ein Align machen.
+ // Ausserdem wurden Dateien gefunden, in denen mehr als die maximal 7 noetigen
+ // Fuellbits vor dem EOL-Code stehen. Daher akzeptieren wir nun grundsaetzlich
+ // bis zu 32-Bloedsinn-Bits vor dem EOL-Code:
+ // und ich habe eine Datei gefunden in der bis zu ??? Bloedsinn Bits stehen, zudem ist dort die Bit Reihenfolge verdreht (SJ);
+
+ UINT32 nMaxPos = pIStream->Tell();
+ nMaxPos += nWidth >> 3;
+
+ for ( ;; )
+ {
+ while ( nInputBitsBufSize < 12 )
+ {
+ *pIStream >> nByte;
+ if ( pIStream->IsEof() )
+ return FALSE;
+ if ( pIStream->Tell() > nMaxPos )
+ return FALSE;
+
+ if ( nOptions & CCI_OPTION_INVERSEBITORDER )
+ nByte = pByteSwap[ nByte ];
+ nInputBitsBuf=(nInputBitsBuf<<8) | (ULONG)nByte;
+ nInputBitsBufSize += 8;
+ }
+ nCode = (USHORT)( ( nInputBitsBuf >> ( nInputBitsBufSize - 12 ) ) & 0x0fff );
+ if ( nCode == 0x0001 )
+ {
+ nEOLCount++;
+ nInputBitsBufSize -= 12;
+ break;
+ }
+ else
+ nInputBitsBufSize--;
+ }
+ return TRUE;
+}
+
+
+BOOL CCIDecompressor::Read2DTag()
+{
+ BYTE nByte;
+
+ // Ein Bit einlesen und TRUE liefern, wenn es 0 ist, sonst FALSE
+ if (nInputBitsBufSize==0) {
+ *pIStream >> nByte;
+ if ( nOptions & CCI_OPTION_INVERSEBITORDER )
+ nByte = pByteSwap[ nByte ];
+ nInputBitsBuf=(ULONG)nByte;
+ nInputBitsBufSize=8;
+ }
+ nInputBitsBufSize--;
+ if ( ((nInputBitsBuf>>nInputBitsBufSize)&0x0001) ) return FALSE;
+ else return TRUE;
+}
+
+
+BYTE CCIDecompressor::ReadBlackOrWhite()
+{
+ BYTE nByte;
+
+ // Ein Bit einlesen und 0x00 liefern, wenn es 0 ist, sonst 0xff
+ if (nInputBitsBufSize==0) {
+ *pIStream >> nByte;
+ if ( nOptions & CCI_OPTION_INVERSEBITORDER )
+ nByte = pByteSwap[ nByte ];
+ nInputBitsBuf=(ULONG)nByte;
+ nInputBitsBufSize=8;
+ }
+ nInputBitsBufSize--;
+ if ( ((nInputBitsBuf>>nInputBitsBufSize)&0x0001) ) return 0xff;
+ else return 0x00;
+}
+
+
+USHORT CCIDecompressor::ReadCodeAndDecode(const CCILookUpTableEntry * pLookUp,
+ USHORT nMaxCodeBits)
+{
+ USHORT nCode,nCodeBits;
+ BYTE nByte;
+
+ // Einen Huffman-Code einlesen und dekodieren:
+ while (nInputBitsBufSize<nMaxCodeBits) {
+ *pIStream >> nByte;
+ if ( nOptions & CCI_OPTION_INVERSEBITORDER )
+ nByte = pByteSwap[ nByte ];
+ nInputBitsBuf=(nInputBitsBuf<<8) | (ULONG)nByte;
+ nInputBitsBufSize+=8;
+ }
+ nCode=(USHORT)((nInputBitsBuf>>(nInputBitsBufSize-nMaxCodeBits))
+ &(0xffff>>(16-nMaxCodeBits)));
+ nCodeBits=pLookUp[nCode].nCodeBits;
+ if (nCodeBits==0) bStatus=FALSE;
+ nInputBitsBufSize-=nCodeBits;
+ return pLookUp[nCode].nValue;
+}
+
+
+void CCIDecompressor::FillBits(BYTE * pTarget, USHORT nTargetBits,
+ USHORT nBitPos, USHORT nNumBits,
+ BYTE nBlackOrWhite)
+{
+
+ if (nBitPos+nNumBits>nTargetBits) {
+ if (nBitPos>=nTargetBits) return;
+ nNumBits=nTargetBits-nBitPos;
+ }
+
+ pTarget+=nBitPos>>3;
+ nBitPos&=7;
+
+ if (nBlackOrWhite==0x00) *pTarget &= 0xff << (8-nBitPos);
+ else *pTarget |= 0xff >> nBitPos;
+ if (nNumBits>8-nBitPos) {
+ nNumBits-=8-nBitPos;
+ while (nNumBits>=8) {
+ *(++pTarget)=nBlackOrWhite;
+ nNumBits-=8;
+ }
+ if (nNumBits>0) *(++pTarget)=nBlackOrWhite;
+ }
+}
+
+
+USHORT CCIDecompressor::CountBits(const BYTE * pData, USHORT nDataSizeBits,
+ USHORT nBitPos, BYTE nBlackOrWhite)
+{
+ USHORT nPos,nLo;
+ BYTE nData;
+
+ // Hier wird die Anzahl der zusammenhaengenden Bits gezaehlt, die
+ // ab Position nBitPos in pTarget alle die Farbe nBlackOrWhite
+ // (0xff oder 0x00) haben.
+
+ nPos=nBitPos;
+ for (;;) {
+ if (nPos>=nDataSizeBits) {
+ nPos=nDataSizeBits;
+ break;
+ }
+ nData=pData[nPos>>3];
+ nLo=nPos & 7;
+ if ( nLo==0 && nData==nBlackOrWhite) nPos+=8;
+ else {
+ if ( ((nData^nBlackOrWhite) & (0x80 >> nLo))!=0) break;
+ nPos++;
+ }
+ }
+ if (nPos<=nBitPos) return 0;
+ else return nPos-nBitPos;
+}
+
+
+void CCIDecompressor::Read1DScanlineData(BYTE * pTarget, USHORT nTargetBits)
+{
+ USHORT nCode,nCodeBits,nDataBits,nTgtFreeByteBits;
+ BYTE nByte;
+ BYTE nBlackOrWhite; // ist 0xff fuer Black oder 0x00 fuer White
+ BOOL bTerminatingCode;
+
+ // Der erste Code ist immer eine "White-Code":
+ nBlackOrWhite=0x00;
+
+ // Anzahl der Bits, die im Byte *pTarget noch nicht geschrieben sind:
+ nTgtFreeByteBits=8;
+
+ // Schleife ueber Codes aus dem Eingabe-Stream:
+ do {
+
+ // die naechsten 13 Bits nach nCode holen, aber noch nicht
+ // aus dem Eingabe-Buffer loeschen:
+ while (nInputBitsBufSize<13) {
+ *pIStream >> nByte;
+ if ( nOptions & CCI_OPTION_INVERSEBITORDER )
+ nByte = pByteSwap[ nByte ];
+ nInputBitsBuf=(nInputBitsBuf<<8) | (ULONG)nByte;
+ nInputBitsBufSize+=8;
+ }
+ nCode=(USHORT)((nInputBitsBuf>>(nInputBitsBufSize-13))&0x1fff);
+
+ // Anzahl der DatenBits und Anzahl der CodeBits ermitteln:
+ if (nBlackOrWhite) {
+ nCodeBits=pBlackLookUp[nCode].nCodeBits;
+ nDataBits=pBlackLookUp[nCode].nValue;
+ }
+ else {
+ nCodeBits=pWhiteLookUp[nCode].nCodeBits;
+ nDataBits=pWhiteLookUp[nCode].nValue;
+ }
+ // Ist es ein Ungueltiger Code ?
+ if ( nDataBits == 9999 )
+ {
+ return;
+ }
+ if ( nCodeBits == 0 )
+ {
+ return; // das koennen sich jetzt um FuellBits handeln
+ }
+ nEOLCount = 0;
+ // Zuviele Daten ?
+ if (nDataBits>nTargetBits) {
+ // Ja, koennte ein Folge-Fehler durch ungueltigen Code sein,
+ // daher irdenwie weitermachen:
+ nDataBits=nTargetBits;
+ }
+
+ // Ist es ein 'Terminating-Code' ?
+ if (nDataBits<64) bTerminatingCode=TRUE; else bTerminatingCode=FALSE;
+
+ // Die gelesenen Bits aus dem Eingabe-Buffer entfernen:
+ nInputBitsBufSize-=nCodeBits;
+
+ // Die Anzahl Daten-Bits in die Scanline schreiben:
+ if (nDataBits>0) {
+ nTargetBits-=nDataBits;
+ if (nBlackOrWhite==0x00) *pTarget &= 0xff << nTgtFreeByteBits;
+ else *pTarget |= 0xff >> (8-nTgtFreeByteBits);
+ if (nDataBits<=nTgtFreeByteBits) {
+ if (nDataBits==nTgtFreeByteBits) {
+ pTarget++;
+ nTgtFreeByteBits=8;
+ }
+ else nTgtFreeByteBits-=nDataBits;
+ }
+ else {
+ nDataBits-=nTgtFreeByteBits;
+ pTarget++;
+ nTgtFreeByteBits=8;
+ while (nDataBits>=8) {
+ *(pTarget++)=nBlackOrWhite;
+ nDataBits-=8;
+ }
+ if (nDataBits>0) {
+ *pTarget=nBlackOrWhite;
+ nTgtFreeByteBits-=nDataBits;
+ }
+ }
+ }
+
+ // ggf. Umschaltung Black <-> White:
+ if (bTerminatingCode==TRUE) nBlackOrWhite=~nBlackOrWhite;
+
+ } while (nTargetBits>0 || bTerminatingCode==FALSE);
+}
+
+
+
+void CCIDecompressor::Read2DScanlineData(BYTE * pTarget, USHORT nTargetBits)
+{
+ USHORT n2DMode,nBitPos,nUncomp,nRun,nRun2,nt;
+ BYTE nBlackOrWhite;
+
+ nBlackOrWhite=0x00;
+ nBitPos=0;
+
+ while (nBitPos<nTargetBits && bStatus==TRUE) {
+
+ n2DMode=ReadCodeAndDecode(p2DModeLookUp,10);
+ if (bStatus==FALSE) return;
+
+ if (n2DMode==CCI2DMODE_UNCOMP) {
+ for (;;) {
+ nUncomp=ReadCodeAndDecode(pUncompLookUp,11);
+ if ( nUncomp <= CCIUNCOMP_4White_1Black ) {
+ nRun=nUncomp-CCIUNCOMP_0White_1Black;
+ FillBits(pTarget,nTargetBits,nBitPos,nRun,0x00);
+ nBitPos+=nRun;
+ FillBits(pTarget,nTargetBits,nBitPos,1,0xff);
+ nBitPos++;
+ }
+ else if ( nUncomp == CCIUNCOMP_5White ) {
+ FillBits(pTarget,nTargetBits,nBitPos,5,0x00);
+ nBitPos+=5;
+ }
+ else {
+ nRun=nUncomp-CCIUNCOMP_0White_End;
+ FillBits(pTarget,nTargetBits,nBitPos,nRun,0x00);
+ nBitPos+=nRun;
+ nBlackOrWhite=ReadBlackOrWhite();
+ break;
+ }
+ }
+ }
+
+ else if (n2DMode==CCI2DMODE_PASS) {
+ if (nBitPos==0 && nBlackOrWhite==0x00 && CountBits(pLastLine,nTargetBits,0,0xff)!=0) nRun=0;
+ else {
+ nRun=CountBits(pLastLine,nTargetBits,nBitPos,~nBlackOrWhite);
+ nRun+=CountBits(pLastLine,nTargetBits,nBitPos+nRun,nBlackOrWhite);
+ }
+ nRun+=CountBits(pLastLine,nTargetBits,nBitPos+nRun,~nBlackOrWhite);
+ FillBits(pTarget,nTargetBits,nBitPos,nRun,nBlackOrWhite);
+ nBitPos+=nRun;
+ }
+
+ else if (n2DMode==CCI2DMODE_HORZ) {
+ if (nBlackOrWhite==0x00) {
+ nRun=0;
+ do {
+ nt=ReadCodeAndDecode(pWhiteLookUp,13);
+ nRun+=nt;
+ } while (nt>=64);
+ nRun2=0;
+ do {
+ nt=ReadCodeAndDecode(pBlackLookUp,13);
+ nRun2+=nt;
+ } while (nt>=64);
+ }
+ else {
+ nRun=0;
+ do {
+ nt=ReadCodeAndDecode(pBlackLookUp,13);
+ nRun+=nt;
+ } while (nt>=64);
+ nRun2=0;
+ do {
+ nt=ReadCodeAndDecode(pWhiteLookUp,13);
+ nRun2+=nt;
+ } while (nt>=64);
+ }
+ FillBits(pTarget,nTargetBits,nBitPos,nRun,nBlackOrWhite);
+ nBitPos+=nRun;
+ FillBits(pTarget,nTargetBits,nBitPos,nRun2,~nBlackOrWhite);
+ nBitPos+=nRun2;
+ }
+
+ else { // Es ist einer der Modi CCI2DMODE_VERT_...
+ if (nBitPos==0 && nBlackOrWhite==0x00 && CountBits(pLastLine,nTargetBits,0,0xff)!=0) nRun=0;
+ else {
+ nRun=CountBits(pLastLine,nTargetBits,nBitPos,~nBlackOrWhite);
+ nRun+=CountBits(pLastLine,nTargetBits,nBitPos+nRun,nBlackOrWhite);
+ }
+ nRun+=n2DMode-CCI2DMODE_VERT_0;
+ FillBits(pTarget,nTargetBits,nBitPos,nRun,nBlackOrWhite);
+ nBitPos+=nRun;
+ nBlackOrWhite=~nBlackOrWhite;
+ }
+ }
+}
+
+
diff --git a/goodies/source/filter.vcl/itiff/ccidecom.hxx b/goodies/source/filter.vcl/itiff/ccidecom.hxx
new file mode 100644
index 000000000000..df23d16e2f5c
--- /dev/null
+++ b/goodies/source/filter.vcl/itiff/ccidecom.hxx
@@ -0,0 +1,159 @@
+/*************************************************************************
+ *
+ * $RCSfile: ccidecom.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CCIDECOM_HXX
+#define _CCIDECOM_HXX
+
+#include <tools/stream.hxx>
+
+
+#define CCI_OPTION_2D 1 // 2D-Komprimierung (statt 1D)
+#define CCI_OPTION_EOL 2 // EOL-Codes am Ende jeder Zeile vorhanden
+#define CCI_OPTION_BYTEALIGNEOL 4 // Fuellbits vor jedem EOL-Code, so dass
+ // Ende von EOL auf Bytes aligend
+#define CCI_OPTION_BYTEALIGNROW 8 // Rows beginnen immer auf Byte-Grenze
+#define CCI_OPTION_INVERSEBITORDER 16
+
+// Eintrag in eine Huffman-Tabelle:
+struct CCIHuffmanTableEntry {
+ USHORT nValue; // Der Daten-Wert.
+ USHORT nCode; // Der Code durch den der Daten-Wert repraesentiert wird.
+ USHORT nCodeBits; // Laenge des Codes in Bits.
+};
+
+
+// Eintrag in eine Hash-Tabelle zur schnellen Dekodierung
+struct CCILookUpTableEntry {
+ USHORT nValue;
+ USHORT nCodeBits;
+};
+
+
+class CCIDecompressor {
+
+public:
+
+ CCIDecompressor( ULONG nOptions, UINT32 nImageWidth );
+ ~CCIDecompressor();
+
+ void StartDecompression( SvStream & rIStream );
+
+ BOOL DecompressScanline(BYTE * pTarget, ULONG nTargetBits );
+
+private:
+
+ void MakeLookUp(const CCIHuffmanTableEntry * pHufTab,
+ const CCIHuffmanTableEntry * pHufTabSave,
+ CCILookUpTableEntry * pLookUp,
+ USHORT nHuffmanTableSize,
+ USHORT nMaxCodeBits);
+
+ BOOL ReadEOL( UINT32 nMaxFillBits );
+
+ BOOL Read2DTag();
+
+ BYTE ReadBlackOrWhite();
+
+ USHORT ReadCodeAndDecode(const CCILookUpTableEntry * pLookUp,
+ USHORT nMaxCodeBits);
+
+ void FillBits(BYTE * pTarget, USHORT nTargetBits,
+ USHORT nBitPos, USHORT nNumBits,
+ BYTE nBlackOrWhite);
+
+ USHORT CountBits(const BYTE * pData, USHORT nDataSizeBits,
+ USHORT nBitPos, BYTE nBlackOrWhite);
+
+ void Read1DScanlineData(BYTE * pTarget, USHORT nTargetBits);
+
+ void Read2DScanlineData(BYTE * pTarget, USHORT nTargetBits);
+
+ BOOL bTableBad;
+
+ BOOL bStatus;
+
+ BYTE* pByteSwap;
+
+ SvStream * pIStream;
+
+ UINT32 nEOLCount;
+
+ UINT32 nWidth;
+
+ ULONG nOptions;
+
+ BOOL bFirstEOL;
+
+ CCILookUpTableEntry * pWhiteLookUp;
+ CCILookUpTableEntry * pBlackLookUp;
+ CCILookUpTableEntry * p2DModeLookUp;
+ CCILookUpTableEntry * pUncompLookUp;
+
+ ULONG nInputBitsBuf;
+ USHORT nInputBitsBufSize;
+
+ BYTE * pLastLine;
+ ULONG nLastLineSize;
+};
+
+
+#endif
+
diff --git a/goodies/source/filter.vcl/itiff/itiff.cxx b/goodies/source/filter.vcl/itiff/itiff.cxx
new file mode 100644
index 000000000000..fcd7f2211f72
--- /dev/null
+++ b/goodies/source/filter.vcl/itiff/itiff.cxx
@@ -0,0 +1,1340 @@
+/*************************************************************************
+ *
+ * $RCSfile: itiff.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _NEW_HXX
+#include <tools/new.hxx>
+#endif
+#ifndef _SV_GRAPH_HXX
+#include <vcl/graph.hxx>
+#endif
+#ifndef _SV_BMPACC_HXX
+#include <vcl/bmpacc.hxx>
+#endif
+#ifndef _SV_FLTCALL_HXX
+#include <svtools/fltcall.hxx>
+#endif
+#ifndef _SV_ANIMATE_HXX
+#include <vcl/animate.hxx>
+#endif
+#include "lzwdecom.hxx"
+#include "ccidecom.hxx"
+
+#define OOODEBUG(str,Num) //(InfoBox(NULL,String(str)+String(" ")+String(Num)).Execute();
+
+#define BYTESWAP( nByte ) ( nByte << 7 ) | ( ( nByte & 2 ) << 5 ) | ( ( nByte & 4 ) << 3 ) | ( ( nByte & 8 ) << 1 ) | \
+ ( ( nByte & 16 ) >> 1 ) | ( ( nByte & 32 ) >> 3 ) | ( ( nByte & 64 ) >> 5 ) | ( ( nByte & 128 ) >> 7 )
+
+
+//============================ TIFFReader ==================================
+
+class TIFFReader
+{
+
+private:
+
+ BOOL bStatus; // Ob bisher kein Fehler auftrat
+ Animation aAnimation;
+
+ PFilterCallback pCallback;
+ void* pCallerData;
+ ULONG nLastPercent;
+
+ SvStream* pTIFF; // Die einzulesende TIFF-Datei
+ Bitmap aBitmap;
+ BitmapWriteAccess* pAcc;
+ USHORT nDstBitsPerPixel;
+
+ ULONG nOrigPos; // Anfaengliche Position in pTIFF
+ UINT16 nOrigNumberFormat; // Anfaengliches Nummern-Format von pTIFF
+
+
+ UINT16 nDataType;
+ // Daten, die aus dem TIFF-Tags entnommen werden:
+ BOOL bByteSwap; // TRUE wenn bits 0..7 -> 7..0 invertiert werden sollen ( FILLORDER = 2 );
+ BYTE nByte1; // 'I', wenn Format LittleEndian
+
+ ULONG nNewSubFile; //
+ ULONG nSubFile; //
+ ULONG nImageWidth; // Bildbreite in Pixel
+ ULONG nImageLength; // Bildhoehe in Pixel
+ ULONG nBitsPerSample; // Bits pro Pixel pro Ebene
+ ULONG nCompression; // Art der Kompriemierung
+ ULONG nPhotometricInterpretation; //
+ ULONG nThresholding; //
+ ULONG nCellWidth; //
+ ULONG nCellLength; //
+ ULONG nFillOrder; //
+ ULONG* pStripOffsets; // Feld von Offsets zu den Bitmap-Daten-"Strips"
+ ULONG nNumStripOffsets; // Groesse obigen Feldes
+ ULONG nOrientation; //
+ ULONG nSamplesPerPixel; // Anzahl der Ebenen
+ ULONG nRowsPerStrip; // Wenn nicht komprimiert: Zahl der Zeilen pro Strip
+ ULONG* pStripByteCounts; // Wenn komprimiert (bestimmte Art): Groesse der Strips
+ ULONG nNumStripByteCounts; // Anzahl der Eintraege in obiges Feld
+ ULONG nMinSampleValue; //
+ ULONG nMaxSampleValue; //
+ double fXResolution; // X-Aufloesung oder 0.0
+ double fYResolution; // Y-Aufloesung oder 0.0
+ ULONG nPlanarConfiguration; //
+ ULONG nGroup3Options; //
+ ULONG nGroup4Options; //
+ ULONG nResolutionUnit; // Einheit von fX/YResolution: 1=unbekannt, 2(default)=Zoll, 3=cm
+ ULONG nPredictor; //
+ ULONG* pColorMap; // Farb-Palette
+ ULONG nNumColors; // Anzahl Farben in der Farbpalette
+
+ ULONG nPlanes; // Anzahl der Ebenen in der Tiff-Datei
+ ULONG nStripsPerPlane; // Anzahl der Strips pro Ebene
+ ULONG nBytesPerRow; // Bytes pro Zeile pro Ebene in der Tiff-Datei ( unkomprimiert )
+ BYTE* pMap[ 4 ]; // Temporaere Scanline
+
+
+ void MayCallback( ULONG nPercent );
+
+ ULONG DataTypeSize();
+ ULONG ReadIntData();
+ double ReadDoubleData();
+
+ void ReadHeader();
+ void ReadTagData( USHORT nTagType, ULONG nDataLen );
+
+ BOOL ReadMap( ULONG nMinPercent, ULONG nMaxPercent );
+ // Liesst/dekomprimert die Bitmap-Daten, und fuellt pMap
+
+ ULONG GetBits( const BYTE * pSrc, ULONG nBitsPos, ULONG nBitsCount );
+ // Holt nBitsCount Bits aus pSrc[..] an der Bit-Position nBitsPos
+
+ void MakePalCol( void );
+ // Erzeugt die Bitmap aus der temporaeren Bitmap pMap
+ // und loescht dabei pMap teilweise
+ BOOL ConvertScanline( ULONG nY );
+ // Konvertiert eine Scanline in das Windows-BMP-Format
+
+public:
+
+ TIFFReader() {}
+ ~TIFFReader() {}
+
+ BOOL ReadTIFF( SvStream & rTIFF, Graphic & rGraphic, PFilterCallback pcallback, void * pcallerdata );
+};
+
+//=================== Methoden von TIFFReader ==============================
+
+void TIFFReader::MayCallback( ULONG nPercent )
+{
+ if ( nPercent >= nLastPercent + 3 )
+ {
+ nLastPercent=nPercent;
+ if ( pCallback != NULL && nPercent <= 100 && bStatus == TRUE )
+ {
+ if (((*pCallback)(pCallerData,(USHORT)nPercent)) == TRUE )
+ bStatus = FALSE;
+ }
+ }
+}
+
+// ---------------------------------------------------------------------------------
+
+ULONG TIFFReader::DataTypeSize()
+{
+ ULONG nSize;
+ switch ( nDataType )
+ {
+ case 1 : // BYTE
+ case 2 : // ACSII
+ case 6 : // SIGNED Byte
+ case 7 : // UNDEFINED
+ nSize = 1;
+ break;
+ case 3 : // UINT16
+ case 8 : // INT16
+ nSize = 2;
+ break;
+ case 4 : // UINT32
+ case 9 : // INT32
+ case 11 : // FLOAT
+ nSize = 4;
+ break;
+ case 5 : // RATIONAL
+ case 10 : // SIGNED RATINAL
+ case 12 : // DOUBLE
+ nSize = 8;
+ break;
+ default:
+ pTIFF->SetError(SVSTREAM_FILEFORMAT_ERROR);
+ nSize=1;
+ }
+ return nSize;
+}
+
+// ---------------------------------------------------------------------------------
+
+ULONG TIFFReader::ReadIntData()
+{
+ double nDOUBLE;
+ float nFLOAT;
+ UINT32 nUINT32a, nUINT32b;
+ INT32 nINT32;
+ UINT16 nUINT16;
+ INT16 nINT16;
+ BYTE nBYTE;
+ char nCHAR;
+
+ switch( nDataType )
+ {
+ case 0 : //??
+ case 1 :
+ case 2 :
+ case 7 :
+ *pTIFF >> nBYTE;
+ nUINT32a = (ULONG)nBYTE;
+ break;
+ case 3 :
+ *pTIFF >> nUINT16;
+ nUINT32a = (ULONG)nUINT16;
+ break;
+ case 9 :
+ case 4 :
+ *pTIFF >> nUINT32a;
+ break;
+ case 5 :
+ *pTIFF >> nUINT32a >> nUINT32b;
+ if ( nUINT32b != 0 )
+ nUINT32a /= nUINT32b;
+ break;
+ case 6 :
+ *pTIFF >> nCHAR;
+ nUINT32a = (INT32)nCHAR;
+ break;
+ case 8 :
+ *pTIFF >> nINT16;
+ nUINT32a = (INT32)nINT16;
+ break;
+ case 10 :
+ *pTIFF >> nUINT32a >> nINT32;
+ if ( nINT32 != 0 )
+ nUINT32a /= nINT32;
+ break;
+ case 11 :
+ *pTIFF >> nFLOAT;
+ nUINT32a = (INT32)nFLOAT;
+ break;
+ case 12 :
+ *pTIFF >> nDOUBLE;
+ nUINT32a = (INT32)nDOUBLE;
+ break;
+ default:
+ *pTIFF >> nUINT32a;
+ break;
+ }
+ return nUINT32a;
+}
+
+// ---------------------------------------------------------------------------------
+
+double TIFFReader::ReadDoubleData()
+{
+ ULONG nulong;
+ double nd;
+
+ if ( nDataType == 5 )
+ {
+ *pTIFF >> nulong;
+ nd = (double)nulong;
+ *pTIFF >> nulong;
+ if ( nulong != 0 )
+ nd /= (double)nulong;
+ }
+ else
+ nd = (double)ReadIntData();
+ return nd;
+}
+
+// ---------------------------------------------------------------------------------
+
+void TIFFReader::ReadTagData( USHORT nTagType, ULONG nDataLen)
+{
+ if ( bStatus == FALSE )
+ return;
+
+ switch ( nTagType )
+ {
+ case 0x00fe: // New Sub File
+ nNewSubFile = ReadIntData();
+ OOODEBUG("NewSubFile",nNewSubFile);
+ break;
+
+ case 0x00ff: // Sub File
+ nSubFile = ReadIntData();
+ OOODEBUG("SubFile",nSubFile);
+ break;
+
+ case 0x0100: // Image Width
+ nImageWidth = ReadIntData();
+ OOODEBUG("ImageWidth",nImageWidth);
+ break;
+
+ case 0x0101: // Image Length
+ nImageLength = ReadIntData();
+ OOODEBUG("ImageLength",nImageLength);
+ break;
+
+ case 0x0102: // Bits Per Sample
+ nBitsPerSample = ReadIntData();
+ OOODEBUG("BitsPerSample",nBitsPerSample);
+ break;
+
+ case 0x0103: // Compression
+ nCompression = ReadIntData();
+ OOODEBUG("Compression",nCompression);
+ break;
+
+ case 0x0106: // Photometric Interpreation
+ nPhotometricInterpretation = ReadIntData();
+ OOODEBUG("PhotometricInterpretation",nPhotometricInterpretation);
+ break;
+
+ case 0x0107: // Thresholding
+ nThresholding = ReadIntData();
+ OOODEBUG("Thresholding",nThresholding);
+ break;
+
+ case 0x0108: // Cell Width
+ nCellWidth = ReadIntData();
+ break;
+
+ case 0x0109: // Cell Length
+ nCellLength = ReadIntData();
+ break;
+
+ case 0x010a: // Fill Order
+ nFillOrder = ReadIntData();
+ OOODEBUG("FillOrder",nFillOrder);
+ break;
+
+ case 0x0111: { // Strip Offset(s)
+ ULONG nOldNumSO, i, * pOldSO;
+ pOldSO = pStripOffsets;
+ if ( pOldSO == NULL ) nNumStripOffsets = 0; // Sicherheitshalber
+ nOldNumSO = nNumStripOffsets;
+ nNumStripOffsets += nDataLen;
+ pStripOffsets = new ULONG[ nNumStripOffsets ];
+ for ( i = 0; i < nOldNumSO; i++ )
+ pStripOffsets[ i ] = pOldSO[ i ] + nOrigPos;
+ for ( i = nOldNumSO; i < nNumStripOffsets; i++ )
+ pStripOffsets[ i ] = ReadIntData() + nOrigPos;
+ if ( pOldSO != NULL )
+ delete pOldSO;
+ OOODEBUG("StripOffsets (Anzahl:)",nDataLen);
+ break;
+ }
+ case 0x0112: // Orientation
+ nOrientation = ReadIntData();
+ OOODEBUG("Orientation",nOrientation);
+ break;
+
+ case 0x0115: // Samples Per Pixel
+ nSamplesPerPixel = ReadIntData();
+ OOODEBUG("SamplesPerPixel",nSamplesPerPixel);
+ break;
+
+ case 0x0116: // Rows Per Strip
+ nRowsPerStrip = ReadIntData();
+ OOODEBUG("RowsPerStrip",nRowsPerStrip);
+ break;
+
+ case 0x0117: { // Strip Byte Counts
+ ULONG nOldNumSBC, i, * pOldSBC;
+ pOldSBC = pStripByteCounts;
+ if ( pOldSBC == NULL ) nNumStripByteCounts = 0; // Sicherheitshalber
+ nOldNumSBC = nNumStripByteCounts;
+ nNumStripByteCounts += nDataLen;
+ pStripByteCounts = new ULONG[ nNumStripByteCounts ];
+ for ( i = 0; i < nOldNumSBC; i++ )
+ pStripByteCounts[ i ] = pOldSBC[ i ];
+ for ( i = nOldNumSBC; i < nNumStripByteCounts; i++)
+ pStripByteCounts[ i ] = ReadIntData();
+ if ( pOldSBC != NULL )
+ delete pOldSBC;
+ OOODEBUG("StripByteCounts (Anzahl:)",nDataLen);
+ break;
+ }
+ case 0x0118: // Min Sample Value
+ nMinSampleValue = ReadIntData();
+ OOODEBUG("MinSampleValue",nMinSampleValue);
+ break;
+
+ case 0x0119: // Max Sample Value
+ nMaxSampleValue = ReadIntData();
+ OOODEBUG("MaxSampleValue",nMaxSampleValue);
+ break;
+
+ case 0x011a: // X Resolution
+ fXResolution = ReadDoubleData();
+ break;
+
+ case 0x011b: // Y Resolution
+ fYResolution = ReadDoubleData();
+ break;
+
+ case 0x011c: // Planar Configuration
+ nPlanarConfiguration = ReadIntData();
+ OOODEBUG("PlanarConfiguration",nPlanarConfiguration);
+ break;
+
+ case 0x0124: // Group 3 Options
+ nGroup3Options = ReadIntData();
+ OOODEBUG("Group3Options",nGroup3Options);
+ break;
+
+ case 0x0125: // Group 4 Options
+ nGroup4Options = ReadIntData();
+ OOODEBUG("Group4Options",nGroup4Options);
+ break;
+
+ case 0x0128: // Resolution Unit
+ nResolutionUnit = ReadIntData();
+ break;
+
+ case 0x013d: // Predictor
+ nPredictor = ReadIntData();
+ OOODEBUG("Predictor",nPredictor);
+ break;
+
+ case 0x0140: { // Color Map
+ USHORT nVal;
+ ULONG i;
+ nNumColors= ( 1 << nBitsPerSample );
+ if ( nDataType == 3 && nNumColors <= 256)
+ {
+ pColorMap = new ULONG[ 256 ];
+ for ( i = 0; i < nNumColors; i++ )
+ pColorMap[ i ] = 0;
+ for ( i = 0; i < nNumColors; i++ )
+ {
+ *pTIFF >> nVal;
+ pColorMap[ i ] |= ( ( (ULONG)nVal ) << 8 ) & 0x00ff0000;
+ }
+ for ( i = 0; i < nNumColors; i++ )
+ {
+ *pTIFF >> nVal;
+ pColorMap[ i ] |= ( (ULONG)nVal ) & 0x0000ff00;
+ }
+ for ( i = 0; i < nNumColors; i++ )
+ {
+ *pTIFF >> nVal;
+ pColorMap[ i ] |= ( ( (ULONG)nVal ) >> 8 ) & 0x000000ff;
+ }
+ }
+ else
+ bStatus = FALSE;
+ OOODEBUG("ColorMap (Anzahl Farben:)", nNumColors);
+ break;
+ }
+ }
+
+ if ( pTIFF->GetError() )
+ bStatus = FALSE;
+}
+
+// ---------------------------------------------------------------------------------
+
+BOOL TIFFReader::ReadMap( ULONG nMinPercent, ULONG nMaxPercent )
+{
+ if ( nCompression == 1 || nCompression == 32771 )
+ {
+ ULONG ny, np, nStrip, nStripBytesPerRow;
+
+ if ( nCompression == 1 )
+ nStripBytesPerRow = nBytesPerRow;
+ else
+ nStripBytesPerRow = ( nBytesPerRow + 1 ) & 0xfffffffe;
+ for ( ny = 0; ny < nImageLength; ny++ )
+ {
+ for ( np = 0; np < nPlanes; np++ )
+ {
+ nStrip = ny / nRowsPerStrip + np * nStripsPerPlane;
+ if ( nStrip >= nNumStripOffsets )
+ return FALSE;
+ pTIFF->Seek( pStripOffsets[ nStrip ] + ( ny % nRowsPerStrip ) * nStripBytesPerRow );
+ pTIFF->Read( pMap[ np ], nBytesPerRow );
+ if ( pTIFF->GetError() )
+ return FALSE;
+ MayCallback( nMinPercent + ( nMaxPercent - nMinPercent ) * ( np * nImageLength + ny) / ( nImageLength * nPlanes ) );
+ }
+ if ( !ConvertScanline( ny ) )
+ return FALSE;
+ }
+ }
+ else if ( nCompression == 2 || nCompression == 3 || nCompression == 4 )
+ {
+ ULONG ny, np, nStrip, nOptions;
+ if ( nCompression == 2 )
+ {
+ nOptions = CCI_OPTION_BYTEALIGNROW;
+ }
+ else if ( nCompression == 3 )
+ {
+ nOptions = CCI_OPTION_EOL;
+ if ( nGroup3Options & 0x00000001 )
+ nOptions |= CCI_OPTION_2D;
+ if ( nGroup3Options & 0x00000004 )
+ nOptions |= CCI_OPTION_BYTEALIGNEOL;
+ if ( nGroup3Options & 0xfffffffa )
+ return FALSE;
+ }
+ else
+ { // nCompression==4
+ nOptions = CCI_OPTION_2D;
+ if ( nGroup4Options & 0xffffffff )
+ return FALSE;
+ }
+ if ( nFillOrder == 2 )
+ {
+ nOptions |= CCI_OPTION_INVERSEBITORDER;
+ bByteSwap = FALSE;
+ }
+ nStrip = 0;
+ if ( nStrip >= nNumStripOffsets )
+ return FALSE;
+ pTIFF->Seek(pStripOffsets[nStrip]);
+
+ CCIDecompressor aCCIDecom( nOptions, nImageWidth );
+
+ aCCIDecom.StartDecompression( *pTIFF );
+
+ for ( ny = 0; ny < nImageLength; ny++ )
+ {
+ for ( np = 0; np < nPlanes; np++ )
+ {
+ if ( ny / nRowsPerStrip + np * nStripsPerPlane > nStrip )
+ {
+ nStrip=ny/nRowsPerStrip+np*nStripsPerPlane;
+ if ( nStrip >= nNumStripOffsets )
+ return FALSE;
+ pTIFF->Seek( pStripOffsets[ nStrip ] );
+ aCCIDecom.StartDecompression( *pTIFF );
+ }
+ if ( aCCIDecom.DecompressScanline( pMap[ np ], nImageWidth * nBitsPerSample * nSamplesPerPixel / nPlanes ) == FALSE )
+ return FALSE;
+ if ( pTIFF->GetError() )
+ return FALSE;
+ MayCallback(nMinPercent+(nMaxPercent-nMinPercent)*(np*nImageLength+ny)/(nImageLength*nPlanes));
+ }
+ if ( !ConvertScanline( ny ) )
+ return FALSE;
+ }
+ }
+ else if ( nCompression == 5 )
+ {
+ LZWDecompressor aLZWDecom;
+ ULONG ny, np, nStrip;
+ nStrip=0;
+ if ( nStrip >= nNumStripOffsets )
+ return FALSE;
+ pTIFF->Seek(pStripOffsets[nStrip]);
+ aLZWDecom.StartDecompression(*pTIFF);
+ for ( ny = 0; ny < nImageLength; ny++ )
+ {
+ for ( np = 0; np < nPlanes; np++ )
+ {
+ if ( ny / nRowsPerStrip + np * nStripsPerPlane > nStrip )
+ {
+ nStrip = ny / nRowsPerStrip + np * nStripsPerPlane;
+ if ( nStrip >= nNumStripOffsets )
+ return FALSE;
+ pTIFF->Seek(pStripOffsets[nStrip]);
+ aLZWDecom.StartDecompression(*pTIFF);
+ }
+ if ( ( aLZWDecom.Decompress( pMap[ np ], nBytesPerRow ) != nBytesPerRow ) || pTIFF->GetError() )
+ return FALSE;
+ MayCallback(nMinPercent+(nMaxPercent-nMinPercent)*(np*nImageLength+ny)/(nImageLength*nPlanes));
+ }
+ if ( !ConvertScanline( ny ) )
+ return FALSE;
+ }
+ }
+ else if ( nCompression == 32773 )
+ {
+ ULONG nStrip,nRecCount,nRowBytesLeft,ny,np,i;
+ BYTE * pdst, nRecHeader, nRecData;
+ nStrip = 0;
+ if ( nStrip >= nNumStripOffsets )
+ return FALSE;
+ pTIFF->Seek(pStripOffsets[nStrip]);
+ for ( ny = 0; ny < nImageLength; ny++ )
+ {
+ for ( np = 0; np < nPlanes; np++ )
+ {
+ if ( ny / nRowsPerStrip + np * nStripsPerPlane > nStrip )
+ {
+ nStrip=ny/nRowsPerStrip+np*nStripsPerPlane;
+ if ( nStrip >= nNumStripOffsets )
+ return FALSE;
+ pTIFF->Seek(pStripOffsets[nStrip]);
+ }
+ nRowBytesLeft = nBytesPerRow;
+ pdst=pMap[ np ];
+ do
+ {
+ *pTIFF >> nRecHeader;
+ if ((nRecHeader&0x80)==0)
+ {
+ nRecCount=0x00000001+((ULONG)nRecHeader);
+ if ( nRecCount > nRowBytesLeft )
+ return FALSE;
+ pTIFF->Read(pdst,nRecCount);
+ pdst+=nRecCount;
+ nRowBytesLeft-=nRecCount;
+ }
+ else if ( nRecHeader != 0x80 )
+ {
+ nRecCount = 0x000000101 - ( (ULONG)nRecHeader );
+ if ( nRecCount > nRowBytesLeft )
+ {
+ nRecCount = nRowBytesLeft;
+
+// bStatus = FALSE;
+// return;
+
+ }
+ *pTIFF >> nRecData;
+ for ( i = 0; i < nRecCount; i++ )
+ *(pdst++) = nRecData;
+ nRowBytesLeft -= nRecCount;
+ }
+ } while ( nRowBytesLeft != 0 );
+ if ( pTIFF->GetError() )
+ return FALSE;
+ MayCallback(nMinPercent+(nMaxPercent-nMinPercent)*(np*nImageLength+ny)/(nImageLength*nPlanes));
+ }
+ if ( !ConvertScanline( ny ) )
+ return FALSE;
+ }
+ }
+ else
+ return FALSE;
+ return TRUE;
+}
+
+ULONG TIFFReader::GetBits( const BYTE * pSrc, ULONG nBitsPos, ULONG nBitsCount )
+{
+ ULONG nRes;
+ if ( bByteSwap )
+ {
+ pSrc += ( nBitsPos >> 3 );
+ nBitsPos &= 7;
+ BYTE nDat = *pSrc;
+ nRes = (ULONG)( BYTESWAP( nDat ) & ( 0xff >> nBitsPos ) );
+
+ if ( nBitsCount <= 8 - nBitsPos )
+ {
+ nRes >>= ( 8 - nBitsPos - nBitsCount );
+ }
+ else
+ {
+ pSrc++;
+ nBitsCount -= 8 - nBitsPos;
+ while ( nBitsCount >= 8 )
+ {
+ nDat = *(pSrc++);
+ nRes = ( nRes << 8 ) | ((ULONG)BYTESWAP( nDat ) );
+ nBitsCount -= 8;
+ }
+ if ( nBitsCount > 0 )
+ {
+ nDat = *pSrc;
+ nRes = ( nRes << nBitsCount ) | (((ULONG)BYTESWAP(nDat))>>(8-nBitsCount));
+ }
+ }
+ }
+ else
+ {
+ pSrc += ( nBitsPos >> 3 );
+ nBitsPos &= 7;
+ nRes = (ULONG)((*pSrc)&(0xff>>nBitsPos));
+ if ( nBitsCount <= 8 - nBitsPos )
+ {
+ nRes >>= ( 8 - nBitsPos - nBitsCount );
+ }
+ else
+ {
+ pSrc++;
+ nBitsCount -= 8 - nBitsPos;
+ while ( nBitsCount >= 8 )
+ {
+ nRes = ( nRes << 8 ) | ((ULONG)*(pSrc++));
+ nBitsCount -= 8;
+ }
+ if ( nBitsCount > 0 )
+ nRes = ( nRes << nBitsCount ) | (((ULONG)*pSrc)>>(8-nBitsCount));
+ }
+ }
+ return nRes;
+}
+
+// ---------------------------------------------------------------------------------
+
+BOOL TIFFReader::ConvertScanline( ULONG nY )
+{
+ UINT32 nRed, nGreen, nBlue, ns, nx, nVal, nByteCount;
+ BYTE nByteVal;
+
+ if ( nDstBitsPerPixel == 24 )
+ {
+ if ( nBitsPerSample == 8 && nSamplesPerPixel >= 3 &&
+ nPlanes == 1 && nPhotometricInterpretation == 2 )
+ {
+ BYTE* pt = pMap[ 0 ];
+
+ // sind die Werte als Differenz abgelegt?
+ if ( 2 == nPredictor )
+ {
+ BYTE nLRed = 0;
+ BYTE nLGreen = 0;
+ BYTE nLBlue = 0;
+ for ( nx = 0; nx < nImageWidth; nx++, pt += nSamplesPerPixel )
+ {
+ pAcc->SetPixel( nY, nx, Color( ( nLRed+=pt[ 0 ] ), ( nLGreen += pt[ 1 ] ), ( nLBlue += pt[ 2 ] ) ) );
+ }
+ }
+ else
+ {
+ for ( nx = 0; nx < nImageWidth; nx++, pt += nSamplesPerPixel )
+ {
+ pAcc->SetPixel( nY, nx, Color( pt[0], pt[1], pt[2] ) );
+ }
+ }
+ }
+ else if ( nPhotometricInterpretation == 2 && nSamplesPerPixel >= 3 )
+ {
+ ULONG nMinMax = nMinSampleValue * 255 / ( nMaxSampleValue - nMinSampleValue );
+ for ( nx = 0; nx < nImageWidth; nx++ )
+ {
+ if ( nPlanes < 3 )
+ {
+ nRed = GetBits( pMap[ 0 ], ( nx * nSamplesPerPixel + 0 ) * nBitsPerSample, nBitsPerSample );
+ nGreen = GetBits( pMap[ 1 ], ( nx * nSamplesPerPixel + 1 ) * nBitsPerSample, nBitsPerSample );
+ nBlue = GetBits( pMap[ 2 ], ( nx * nSamplesPerPixel + 2 ) * nBitsPerSample, nBitsPerSample );
+ }
+ else
+ {
+ nRed = GetBits( pMap[ 0 ], nx * nBitsPerSample, nBitsPerSample );
+ nGreen = GetBits( pMap[ 1 ], nx * nBitsPerSample, nBitsPerSample );
+ nBlue = GetBits( pMap[ 2 ], nx * nBitsPerSample, nBitsPerSample );
+ }
+ pAcc->SetPixel( nY, nx, Color( (BYTE)( nRed - nMinMax ), (BYTE)( nGreen - nMinMax ), (BYTE)(nBlue - nMinMax) ) );
+ }
+ }
+ else if ( nPhotometricInterpretation == 5 && nSamplesPerPixel == 3 )
+ {
+ ULONG nMinMax = nMinSampleValue * 255 / ( nMaxSampleValue - nMinSampleValue );
+ for ( nx = 0; nx < nImageWidth; nx++ )
+ {
+ if ( nPlanes < 3 )
+ {
+ nRed = GetBits( pMap[ 0 ],( nx * nSamplesPerPixel + 0 ) * nBitsPerSample, nBitsPerSample );
+ nGreen = GetBits( pMap[ 0 ],( nx * nSamplesPerPixel + 1 ) * nBitsPerSample, nBitsPerSample );
+ nBlue = GetBits( pMap[ 0 ],( nx * nSamplesPerPixel + 2 ) * nBitsPerSample, nBitsPerSample );
+ }
+ else
+ {
+ nRed = GetBits( pMap[ 0 ], nx * nBitsPerSample, nBitsPerSample );
+ nGreen = GetBits( pMap[ 1 ], nx * nBitsPerSample, nBitsPerSample );
+ nBlue = GetBits( pMap[ 2 ], nx * nBitsPerSample, nBitsPerSample );
+ }
+ nRed = 255 - (BYTE)( nRed - nMinMax );
+ nGreen = 255 - (BYTE)( nGreen - nMinMax );
+ nBlue = 255 - (BYTE)( nBlue - nMinMax );
+ pAcc->SetPixel( nY, nx, Color( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue ) );
+ }
+ }
+ else if( nPhotometricInterpretation == 5 && nSamplesPerPixel == 4 )
+ {
+ BYTE nSamp[ 4 ];
+ BYTE nSampLast[ 4 ] = { 0, 0, 0, 0 };
+ long nBlack;
+
+ for( nx = 0; nx < nImageWidth; nx++ )
+ {
+ // sind die Werte als Differenz abgelegt?
+ if( 2 == nPredictor )
+ {
+ for( ns = 0; ns < 4; ns++ )
+ {
+ if( nPlanes < 3 )
+ nSamp[ ns ] = ( nSampLast[ ns ] += (BYTE) GetBits( pMap[ 0 ], ( nx * nSamplesPerPixel + ns ) * nBitsPerSample, nBitsPerSample ) );
+ else
+ nSamp[ ns ] = ( nSampLast[ ns ] += (BYTE) GetBits( pMap[ ns ], nx * nBitsPerSample, nBitsPerSample ) );
+ }
+ }
+ else
+ {
+ for( ns = 0; ns < 4; ns++ )
+ {
+ if( nPlanes < 3 )
+ nSamp[ ns ] = (BYTE) GetBits( pMap[ 0 ], ( nx * nSamplesPerPixel + ns ) * nBitsPerSample, nBitsPerSample );
+ else
+ nSamp[ ns ]= (BYTE) GetBits( pMap[ ns ], nx * nBitsPerSample, nBitsPerSample );
+ }
+ }
+ nBlack = nSamp[ 3 ];
+ nRed = (BYTE) Max( 0L, 255L - ( ( (long) nSamp[ 0 ] + nBlack - ( ( (long) nMinSampleValue ) << 1 ) ) *
+ 255L/(long)(nMaxSampleValue-nMinSampleValue) ) );
+ nGreen = (BYTE) Max( 0L, 255L - ( ( (long) nSamp[ 1 ] + nBlack - ( ( (long) nMinSampleValue ) << 1 ) ) *
+ 255L/(long)(nMaxSampleValue-nMinSampleValue) ) );
+ nBlue = (BYTE) Max( 0L, 255L - ( ( (long) nSamp[ 2 ] + nBlack - ( ( (long) nMinSampleValue ) << 1 ) ) *
+ 255L/(long)(nMaxSampleValue-nMinSampleValue) ) );
+ pAcc->SetPixel( nY, nx, Color ( (BYTE)nRed, (BYTE)nGreen, (BYTE)nBlue ) );
+
+ }
+ }
+ }
+ else if ( nSamplesPerPixel == 1 && ( nPhotometricInterpretation <= 1 || nPhotometricInterpretation == 3 ) )
+ {
+ ULONG nMinMax = ( ( 1 << nDstBitsPerPixel ) - 1 ) / ( nMaxSampleValue - nMinSampleValue );
+ BYTE* pt = pMap[ 0 ];
+ BYTE nShift;
+
+ switch ( nDstBitsPerPixel )
+ {
+ case 8 :
+ {
+ BYTE nLast;
+ if ( bByteSwap )
+ {
+ if ( nPredictor == 2 )
+ {
+ nLast = BYTESWAP( (BYTE)*pt++ );
+ for ( nx = 0; nx < nImageWidth; nx++ )
+ {
+ pAcc->SetPixel( nY, nx, nLast );
+ nLast += *pt++;
+ }
+ }
+ else
+ {
+ for ( nx = 0; nx < nImageWidth; nx++ )
+ {
+ nLast = *pt++;
+ pAcc->SetPixel( nY, nx, (BYTE)( ( (BYTESWAP((ULONG)nLast ) - nMinSampleValue ) * nMinMax ) ) );
+ }
+ }
+ }
+ else
+ {
+ if ( nPredictor == 2 )
+ {
+ nLast = *pt++;
+ for ( nx = 0; nx < nImageWidth; nx++ )
+ {
+ pAcc->SetPixel( nY, nx, nLast );
+ nLast += *pt++;
+ }
+ }
+ else
+ {
+ for ( nx = 0; nx < nImageWidth; nx++ )
+ {
+ pAcc->SetPixel( nY, nx, (BYTE)( ( (ULONG)*pt++ - nMinSampleValue ) * nMinMax ) );
+
+ }
+ }
+ }
+ }
+ break;
+
+ case 7 :
+ case 6 :
+ case 5 :
+ case 4 :
+ case 3 :
+ case 2 :
+ {
+ for ( nx = 0; nx < nImageWidth; nx++ )
+ {
+ nVal = ( GetBits( pt, nx * nBitsPerSample, nBitsPerSample ) - nMinSampleValue ) * nMinMax;
+ pAcc->SetPixel( nY, nx, (BYTE)nVal );
+ }
+ }
+ break;
+
+ case 1 :
+ {
+ if ( bByteSwap )
+ {
+ nx = 0;
+ nByteCount = ( nImageWidth >> 3 ) + 1;
+ while ( --nByteCount )
+ {
+ nByteVal = *pt++;
+ pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+ nByteVal >>= 1;
+ pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+ nByteVal >>= 1;
+ pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+ nByteVal >>= 1;
+ pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+ nByteVal >>= 1;
+ pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+ nByteVal >>= 1;
+ pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+ nByteVal >>= 1;
+ pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+ nByteVal >>= 1;
+ pAcc->SetPixel( nY, nx++, nByteVal );
+ }
+ if ( nImageWidth & 7 )
+ {
+ nByteVal = *pt++;
+ while ( nx < nImageWidth )
+ {
+ pAcc->SetPixel( nY, nx++, nByteVal & 1 );
+ nByteVal >>= 1;
+ }
+ }
+ }
+ else
+ {
+ nx = 7;
+ nByteCount = ( nImageWidth >> 3 ) + 1;
+ while ( --nByteCount )
+ {
+ nByteVal = *pt++;
+ pAcc->SetPixel( nY, nx, nByteVal & 1 );
+ nByteVal >>= 1;
+ pAcc->SetPixel( nY, --nx, nByteVal & 1 );
+ nByteVal >>= 1;
+ pAcc->SetPixel( nY, --nx, nByteVal & 1 );
+ nByteVal >>= 1;
+ pAcc->SetPixel( nY, --nx, nByteVal & 1 );
+ nByteVal >>= 1;
+ pAcc->SetPixel( nY, --nx, nByteVal & 1 );
+ nByteVal >>= 1;
+ pAcc->SetPixel( nY, --nx, nByteVal & 1 );
+ nByteVal >>= 1;
+ pAcc->SetPixel( nY, --nx, nByteVal & 1 );
+ nByteVal >>= 1;
+ pAcc->SetPixel( nY, --nx, nByteVal );
+ nx += 15;
+ }
+ if ( nImageWidth & 7 )
+ {
+ nx -= 7;
+ nByteVal = *pt++;
+ nShift = 7;
+ while ( nx < nImageWidth )
+ {
+ pAcc->SetPixel( nY, nx++, ( nByteVal >> nShift ) & 1);
+ }
+ }
+ }
+ }
+ break;
+
+ default :
+ return FALSE;
+ }
+ }
+ else if ( ( nSamplesPerPixel == 2 ) && ( nBitsPerSample == 8 ) &&
+ ( nPlanarConfiguration == 1 ) && ( pColorMap == 0 ) ) // grayscale
+ {
+ ULONG nMinMax = ( ( 1 << 8 /*nDstBitsPerPixel*/ ) - 1 ) / ( nMaxSampleValue - nMinSampleValue );
+ BYTE* pt = pMap[ 0 ];
+ if ( nByte1 == 'I' )
+ pt++;
+ for ( nx = 0; nx < nImageWidth; nx++, pt += 2 )
+ {
+ pAcc->SetPixel( nY, nx, (BYTE)( ( (ULONG)*pt - nMinSampleValue ) * nMinMax ) );
+ }
+ }
+ else
+ return FALSE;
+ return TRUE;
+}
+
+// ---------------------------------------------------------------------------------
+
+void TIFFReader::MakePalCol( void )
+{
+ if ( nDstBitsPerPixel <= 8 )
+ {
+ ULONG i, nVal, n0RGB;
+ if ( pColorMap == NULL )
+ pColorMap = new ULONG[ 256 ];
+ if ( nPhotometricInterpretation <= 1 )
+ {
+ nNumColors = 1 << nBitsPerSample;
+ if ( nNumColors > 256 )
+ nNumColors = 256;
+ pAcc->SetPaletteEntryCount( (USHORT)nNumColors );
+ for ( i = 0; i < nNumColors; i++ )
+ {
+ nVal = ( i * 255 / ( nNumColors - 1 ) ) & 0xff;
+ n0RGB = nVal | ( nVal << 8 ) | ( nVal << 16 );
+ if ( nPhotometricInterpretation == 1 )
+ pColorMap[ i ] = n0RGB;
+ else
+ pColorMap[ nNumColors - i - 1 ] = n0RGB;
+ }
+ }
+ for ( i = 0; i < nNumColors; i++ )
+ {
+ pAcc->SetPaletteColor( (USHORT)i, BitmapColor( (BYTE)( pColorMap[ i ] >> 16 ),
+ (BYTE)( pColorMap[ i ] >> 8 ), (BYTE)pColorMap[ i ] ) );
+ }
+ }
+
+ if ( fXResolution > 1.0 && fYResolution > 1.0 && ( nResolutionUnit == 2 || nResolutionUnit == 3 ) )
+ {
+ ULONG nRX,nRY;
+ if (nResolutionUnit==2)
+ {
+ nRX=(ULONG)(fXResolution+0.5);
+ nRY=(ULONG)(fYResolution+0.5);
+ }
+ else
+ {
+ nRX=(ULONG)(fXResolution*2.54+0.5);
+ nRY=(ULONG)(fYResolution*2.54+0.5);
+ }
+ MapMode aMapMode(MAP_INCH,Point(0,0),Fraction(1,nRX),Fraction(1,nRY));
+ aBitmap.SetPrefMapMode(aMapMode);
+ aBitmap.SetPrefSize(Size(nImageWidth,nImageLength));
+ }
+}
+
+// ---------------------------------------------------------------------------------
+
+void TIFFReader::ReadHeader()
+{
+ BYTE nbyte1, nbyte2;
+ USHORT nushort;
+
+ *pTIFF >> nbyte1;
+ if ( nbyte1 == 'I' )
+ pTIFF->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ else
+ pTIFF->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+
+ *pTIFF >> nbyte2 >> nushort;
+ if ( nbyte1 != nbyte2 || ( nbyte1 != 'I' && nbyte1 != 'M' ) || nushort != 0x002a )
+ bStatus = FALSE;
+}
+
+// ---------------------------------------------------------------------------------
+
+BOOL TIFFReader::ReadTIFF(SvStream & rTIFF, Graphic & rGraphic,
+ PFilterCallback pcallback, void * pcallerdata)
+{
+ USHORT i, nNumTags, nTagType;
+ ULONG nMaxPos;
+ ULONG nFirstIfd, nDataLen, nPos;
+ ULONG* pDummy = new ULONG; delete pDummy; // damit unter OS/2
+ // das richtige (Tools-)new
+ // verwendet wird, da es sonst
+ // in dieser DLL nur Vector-news
+ // gibt;
+ bStatus = TRUE;
+
+ pCallback = pcallback;
+ pCallerData = pcallerdata;
+ nLastPercent = 0;
+
+ pTIFF = &rTIFF;
+ nMaxPos = nOrigPos = pTIFF->Tell();
+ nOrigNumberFormat = pTIFF->GetNumberFormatInt();
+
+ MayCallback( 0 );
+
+ // Kopf einlesen:
+ ReadHeader();
+
+ // Ersten IFD einlesen:
+ *pTIFF >> nFirstIfd;
+
+ if( !nFirstIfd || pTIFF->GetError() )
+ bStatus = FALSE;
+
+ if ( bStatus )
+ {
+ ULONG nOffset = nFirstIfd;
+
+ // calculate length of TIFF file
+ do
+ {
+ pTIFF->Seek( nOrigPos + nOffset );
+
+ if( pTIFF->GetError() )
+ {
+ pTIFF->ResetError();
+ break;
+ };
+ nMaxPos = Max( pTIFF->Tell(), nMaxPos );
+
+ *pTIFF >> nNumTags;
+
+ // Schleife ueber Tags:
+ for( i = 0; i < nNumTags; i++ )
+ {
+ *pTIFF >> nTagType >> nDataType >> nDataLen >> nOffset;
+
+ if( DataTypeSize() * nDataLen > 4 )
+ nMaxPos = Max( nOrigPos + nOffset + DataTypeSize() * nDataLen, nMaxPos );
+ }
+ *pTIFF >> nOffset;
+
+ nMaxPos = Max( pTIFF->Tell(), nMaxPos );
+ if ( !nOffset )
+ nMaxPos = Max( pTIFF->Tell(), nMaxPos );
+ }
+ while( nOffset );
+
+ for ( UINT32 nNextIfd = nFirstIfd; nNextIfd && bStatus; )
+ {
+ pTIFF->Seek( nOrigPos + nNextIfd );
+ {
+ bByteSwap = FALSE;
+
+ nNewSubFile = 0;
+ nSubFile = 0;
+ nImageWidth = 0;
+ nImageLength = 0;
+ nBitsPerSample = 1; // Defaultwert laut Doku
+ nCompression = 1;
+ nPhotometricInterpretation = 0;
+ nThresholding = 1; // Defaultwert laut Doku
+ nCellWidth = 1;
+ nCellLength = 1;
+ nFillOrder = 1; // Defaultwert laut Doku
+ nNumStripOffsets = 0;
+ nOrientation = 1;
+ nSamplesPerPixel = 1; // Defaultwert laut Doku
+ nRowsPerStrip = 0xffffffff; // Defaultwert laut Doku
+ nNumStripByteCounts = 0;
+ nMinSampleValue = 0; // Defaultwert laut Doku
+ nMaxSampleValue = 0;
+ fXResolution = 0.0;
+ fYResolution = 0.0;
+ nPlanarConfiguration = 1;
+ nGroup3Options = 0; // Defaultwert laut Doku
+ nGroup4Options = 0; // Defaultwert laut Doku
+ nResolutionUnit = 2; // Defaultwert laut Doku
+ nPredictor = 1;
+ nNumColors = 0;
+
+ pAcc = NULL;
+ pColorMap = NULL;
+ pStripOffsets = NULL;
+ pStripByteCounts = NULL;
+ pMap[ 0 ] = pMap[ 1 ] = pMap[ 2 ] = pMap[ 3 ] = NULL;
+
+ *pTIFF >> nNumTags;
+ nPos = pTIFF->Tell();
+
+ // Schleife ueber Tags:
+ for( i = 0; i < nNumTags; i++ )
+ {
+ *pTIFF >> nTagType >> nDataType >> nDataLen;
+
+ if( DataTypeSize() * nDataLen > 4 )
+ {
+ *pTIFF >> nOffset;
+ pTIFF->Seek( nOrigPos + nOffset );
+ }
+ ReadTagData( nTagType, nDataLen );
+ nPos += 12; pTIFF->Seek( nPos );
+
+ if ( pTIFF->GetError() )
+ bStatus = FALSE;
+
+ if ( bStatus == FALSE )
+ break;
+ }
+ *pTIFF >> nNextIfd;
+ }
+ if ( bStatus )
+ {
+ if ( nMaxSampleValue == 0 )
+ nMaxSampleValue = ( 1 << nBitsPerSample ) - 1;
+
+ if ( nPhotometricInterpretation == 2 || nPhotometricInterpretation == 5 || nPhotometricInterpretation == 6 )
+ nDstBitsPerPixel = 24;
+ else if ( nBitsPerSample*nSamplesPerPixel <= 1 )
+ nDstBitsPerPixel = 1;
+ else if ( nBitsPerSample*nSamplesPerPixel <= 4 )
+ nDstBitsPerPixel = 4;
+ else
+ nDstBitsPerPixel = 8;
+
+ aBitmap = Bitmap( Size( nImageWidth, nImageLength ), nDstBitsPerPixel );
+ if ( ( pAcc = aBitmap.AcquireWriteAccess() ) )
+ {
+ if ( nPlanarConfiguration == 1 )
+ nPlanes = 1;
+ else
+ nPlanes = nSamplesPerPixel;
+
+ if ( ( nFillOrder == 2 ) && ( nCompression != 5 ) ) // im LZW Mode werden die bits schon invertiert
+ bByteSwap = TRUE;
+
+ nStripsPerPlane = ( nImageLength - 1 ) / nRowsPerStrip + 1;
+ nBytesPerRow = ( nImageWidth * nSamplesPerPixel / nPlanes * nBitsPerSample + 7 ) >> 3;
+
+ for ( ULONG i = 0; i < 4; i++ )
+ pMap[ i ] = new BYTE[ nBytesPerRow ];
+
+ if ( ReadMap( 10, 60 ) )
+ {
+ nMaxPos = Max( pTIFF->Tell(), nMaxPos );
+ MakePalCol();
+ nMaxPos = Max( pTIFF->Tell(), nMaxPos );
+ }
+ else
+ bStatus = FALSE;
+
+ if( pAcc )
+ {
+ aBitmap.ReleaseAccess( pAcc );
+ if ( bStatus )
+ {
+ AnimationBitmap aAnimationBitmap( aBitmap, Point( 0, 0 ), aBitmap.GetSizePixel(),
+ ANIMATION_TIMEOUT_ON_CLICK, DISPOSE_FULL );
+
+ aAnimation.Insert( aAnimationBitmap );
+ }
+ }
+ // Aufraeumen:
+ for ( i = 0; i < 4; i++ )
+ delete[] pMap[ i ];
+
+ delete pColorMap;
+ delete pStripOffsets;
+ delete pStripByteCounts;
+ }
+ }
+ }
+ }
+
+ // seek to end of TIFF if succeeded
+ pTIFF->SetNumberFormatInt( nOrigNumberFormat );
+ pTIFF->Seek( bStatus ? nMaxPos : nOrigPos );
+
+ if ( aAnimation.Count() )
+ {
+ if ( aAnimation.Count() == 1 )
+ rGraphic = aAnimation.GetBitmapEx();
+ else
+ rGraphic = aAnimation; //aBitmap;
+
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+
+//================== GraphicImport - die exportierte Funktion ================
+
+#ifdef WNT
+extern "C" BOOL _cdecl GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData, Config *, BOOL)
+#else
+extern "C" BOOL GraphicImport(SvStream & rStream, Graphic & rGraphic,
+ PFilterCallback pCallback, void * pCallerData, Config *, BOOL)
+#endif
+{
+ TIFFReader aTIFFReader;
+
+ if (aTIFFReader.ReadTIFF( rStream, rGraphic, pCallback, pCallerData ) == FALSE )
+ return FALSE;
+
+ return TRUE;
+}
+
+//============================= fuer Windows ==================================
+
+#pragma hdrstop
+
+#ifdef WIN
+
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
+
+
diff --git a/goodies/source/filter.vcl/itiff/lzwdecom.cxx b/goodies/source/filter.vcl/itiff/lzwdecom.cxx
new file mode 100644
index 000000000000..de59802ce4c3
--- /dev/null
+++ b/goodies/source/filter.vcl/itiff/lzwdecom.cxx
@@ -0,0 +1,224 @@
+/*************************************************************************
+ *
+ * $RCSfile: lzwdecom.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <tools/new.hxx>
+#include "lzwdecom.hxx"
+
+LZWDecompressor::LZWDecompressor()
+{
+ USHORT i;
+
+ pTable=new LZWTableEntry[4096];
+ pOutBuf=new BYTE[4096];
+ for (i=0; i<4096; i++)
+ {
+ pTable[i].nPrevCode=0;
+ pTable[i].nDataCount=1;
+ pTable[i].nData=(BYTE)i;
+ }
+ pIStream=NULL;
+ bFirst = TRUE;
+ nOldCode = 0;
+}
+
+
+LZWDecompressor::~LZWDecompressor()
+{
+ delete pOutBuf;
+ delete pTable;
+}
+
+
+void LZWDecompressor::StartDecompression(SvStream & rIStream)
+{
+ pIStream=&rIStream;
+
+ nTableSize=258;
+
+ bEOIFound=FALSE;
+
+ nOutBufDataLen=0;
+
+ *pIStream >> nInputBitsBuf;
+
+ nInputBitsBufSize=8;
+
+ if ( bFirst )
+ {
+ bInvert = nInputBitsBuf == 1;
+ bFirst = FALSE;
+ }
+
+ if ( bInvert )
+ nInputBitsBuf = ( ( nInputBitsBuf & 1 ) << 7 ) | ( ( nInputBitsBuf & 2 ) << 5 ) | ( ( nInputBitsBuf & 4 ) << 3 ) | ( ( nInputBitsBuf & 8 ) << 1 ) | ( ( nInputBitsBuf & 16 ) >> 1 ) | ( ( nInputBitsBuf & 32 ) >> 3 ) | ( ( nInputBitsBuf & 64 ) >> 5 ) | ( (nInputBitsBuf & 128 ) >> 7 );
+}
+
+
+ULONG LZWDecompressor::Decompress(BYTE * pTarget, ULONG nMaxCount)
+{
+ ULONG nCount;
+
+ if (pIStream==NULL) return 0;
+
+ nCount=0;
+ for (;;) {
+
+ if (pIStream->GetError()) break;
+
+ if (((ULONG)nOutBufDataLen)>=nMaxCount) {
+ nOutBufDataLen-=(USHORT)nMaxCount;
+ nCount+=nMaxCount;
+ while (nMaxCount>0) {
+ *(pTarget++)=*(pOutBufData++);
+ nMaxCount--;
+ }
+ break;
+ }
+
+ nMaxCount-=(ULONG)nOutBufDataLen;
+ nCount+=nOutBufDataLen;
+ while (nOutBufDataLen>0) {
+ *(pTarget++)=*(pOutBufData++);
+ nOutBufDataLen--;
+ }
+
+ if (bEOIFound==TRUE) break;
+
+ DecompressSome();
+
+ }
+
+ return nCount;
+}
+
+
+USHORT LZWDecompressor::GetNextCode()
+{
+ USHORT nBits,nCode;
+
+ if (nTableSize<511) nBits=9;
+ else if (nTableSize<1023) nBits=10;
+ else if (nTableSize<2047) nBits=11;
+ else nBits=12;
+
+ nCode=0;
+ do {
+ if (nInputBitsBufSize<=nBits)
+ {
+ nCode=(nCode<<nInputBitsBufSize) | nInputBitsBuf;
+ nBits-=nInputBitsBufSize;
+ *pIStream >> nInputBitsBuf;
+ if ( bInvert )
+ nInputBitsBuf = ( ( nInputBitsBuf & 1 ) << 7 ) | ( ( nInputBitsBuf & 2 ) << 5 ) | ( ( nInputBitsBuf & 4 ) << 3 ) | ( ( nInputBitsBuf & 8 ) << 1 ) | ( ( nInputBitsBuf & 16 ) >> 1 ) | ( ( nInputBitsBuf & 32 ) >> 3 ) | ( ( nInputBitsBuf & 64 ) >> 5 ) | ( (nInputBitsBuf & 128 ) >> 7 );
+ nInputBitsBufSize=8;
+ }
+ else
+ {
+ nCode=(nCode<<nBits) | (nInputBitsBuf>>(nInputBitsBufSize-nBits));
+ nInputBitsBufSize-=nBits;
+ nInputBitsBuf&=0x00ff>>(8-nInputBitsBufSize);
+ nBits=0;
+ }
+ } while (nBits>0);
+
+ return nCode;
+}
+
+
+void LZWDecompressor::AddToTable(USHORT nPrevCode, USHORT nCodeFirstData)
+{
+ while (pTable[nCodeFirstData].nDataCount>1)
+ nCodeFirstData=pTable[nCodeFirstData].nPrevCode;
+
+ pTable[nTableSize].nPrevCode=nPrevCode;
+ pTable[nTableSize].nDataCount=pTable[nPrevCode].nDataCount+1;
+ pTable[nTableSize].nData=pTable[nCodeFirstData].nData;
+
+ nTableSize++;
+}
+
+
+void LZWDecompressor::DecompressSome()
+{
+ USHORT i,nCode;
+
+ nCode=GetNextCode();
+ if (nCode==256) {
+ nTableSize=258;
+ nCode=GetNextCode();
+ if (nCode==257) { bEOIFound=TRUE; return; }
+ }
+ else if (nCode<nTableSize) AddToTable(nOldCode,nCode);
+ else if (nCode==nTableSize) AddToTable(nOldCode,nOldCode);
+ else { bEOIFound=TRUE; return; }
+
+ nOldCode=nCode;
+
+ nOutBufDataLen=pTable[nCode].nDataCount;
+ pOutBufData=pOutBuf+nOutBufDataLen;
+ for (i=0; i<nOutBufDataLen; i++) {
+ *(--pOutBufData)=pTable[nCode].nData;
+ nCode=pTable[nCode].nPrevCode;
+ }
+}
+
+
+
diff --git a/goodies/source/filter.vcl/itiff/lzwdecom.hxx b/goodies/source/filter.vcl/itiff/lzwdecom.hxx
new file mode 100644
index 000000000000..7e12d77f4196
--- /dev/null
+++ b/goodies/source/filter.vcl/itiff/lzwdecom.hxx
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * $RCSfile: lzwdecom.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _LZWDECOM_HXX
+#define _LZWDECOM_HXX
+
+#include <tools/stream.hxx>
+
+struct LZWTableEntry {
+ USHORT nPrevCode;
+ USHORT nDataCount;
+ BYTE nData;
+};
+
+class LZWDecompressor {
+
+public:
+
+ LZWDecompressor();
+ ~LZWDecompressor();
+
+ void StartDecompression(SvStream & rIStream);
+
+ ULONG Decompress(BYTE * pTarget, ULONG nMaxCount);
+ // Liefert die Anzahl der geschriebenen Bytes, wenn < nMaxCount,
+ // sind keine weiteren Daten zu entpacken, oder es ist ein
+ // Fehler aufgetreten.
+
+private:
+
+ USHORT GetNextCode();
+ void AddToTable(USHORT nPrevCode, USHORT nCodeFirstData);
+ void DecompressSome();
+
+ SvStream * pIStream;
+
+ LZWTableEntry * pTable;
+ USHORT nTableSize;
+
+ BOOL bEOIFound, bInvert, bFirst;
+
+ USHORT nOldCode;
+
+ BYTE * pOutBuf;
+ BYTE * pOutBufData;
+ USHORT nOutBufDataLen;
+
+ BYTE nInputBitsBuf;
+ USHORT nInputBitsBufSize;
+};
+
+
+#endif
+
+
diff --git a/goodies/source/filter.vcl/itiff/makefile.mk b/goodies/source/filter.vcl/itiff/makefile.mk
new file mode 100644
index 000000000000..44cf66cbe083
--- /dev/null
+++ b/goodies/source/filter.vcl/itiff/makefile.mk
@@ -0,0 +1,171 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=goodies
+TARGET=itiff
+DEPTARGET=vitiff
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=eeng_pch
+PROJECTPCHSOURCE=eeng_pch
+
+
+# --- Settings -----------------------------------------------------------
+
+.IF "$(VCL)" != ""
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Allgemein ----------------------------------------------------------
+
+.IF "$(editdebug)"!="" || "$(EDITDEBUG)"!=""
+CDEFS+= -DEDITDEBUG
+.ENDIF
+
+SLOFILES = $(SLO)$/itiff.obj \
+ $(SLO)$/lzwdecom.obj \
+ $(SLO)$/ccidecom.obj
+
+# ==========================================================================
+
+SHL1TARGET= iti$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= itiff
+SHL1STDLIBS= $(TOOLSLIB) $(SVLIB) $(CPPULIB)
+SHL1DEPN= $(LB)$/itiff.lib
+SHL1LIBS= $(SLB)$/itiff.lib # $(LB)$/rtftoken.lib
+
+.IF "$(GUI)" != "UNX"
+SHL1OBJS= $(SLO)$/itiff.obj
+.ENDIF
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1BASE=0x1c000000
+
+.IF "$(depend)" == ""
+
+all: ALLTAR
+
+
+.IF "$(GUI)" == "OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE TERMINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+.IF "$(COM)" == "ZTC"
+ @echo STUB 'os2STUB.EXE' >>$@
+.ENDIF
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo GraphicImport >>$@
+.ELSE
+ @echo _GraphicImport >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarView Filter DLL' >$@
+ @echo name $(BIN)$/$(SHL1TARGET) >>$@
+ @echo GraphicImport_ >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ @del temp.def
+.ENDIF
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+ @echo LIBRARY $(DLLNAME) >$@
+ @echo DESCRIPTION 'Svx RTF DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo GraphicImport >>$@
+
+.ENDIF
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP>$@
+ @echo LIBMAIN>>$@
+ @echo LibMain>>$@
+
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+.ELSE
+dummy:
+ @+echo No VCL - do nothing!
+.ENDIF #VCL
diff --git a/goodies/source/graphic/grfattr.cxx b/goodies/source/graphic/grfattr.cxx
new file mode 100644
index 000000000000..498498f78d40
--- /dev/null
+++ b/goodies/source/graphic/grfattr.cxx
@@ -0,0 +1,148 @@
+/*************************************************************************
+ *
+ * $RCSfile: grfattr.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <tools/vcompat.hxx>
+#include "grfmgr.hxx"
+
+// ---------------
+// - GraphicAttr -
+// ---------------
+
+GraphicAttr::GraphicAttr() :
+ mfGamma ( 1.0 ),
+ mnMirrFlags ( 0 ),
+ mnLeftCrop ( 0 ),
+ mnTopCrop ( 0 ),
+ mnRightCrop ( 0 ),
+ mnBottomCrop ( 0 ),
+ mnRotate10 ( 0 ),
+ mnContPercent ( 0 ),
+ mnLumPercent ( 0 ),
+ mnRPercent ( 0 ),
+ mnGPercent ( 0 ),
+ mnBPercent ( 0 ),
+ mbInvert ( FALSE ),
+ mcTransparency ( 0 ),
+ meDrawMode ( GRAPHICDRAWMODE_STANDARD )
+{
+}
+
+// ------------------------------------------------------------------------
+
+GraphicAttr::~GraphicAttr()
+{
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GraphicAttr::operator==( const GraphicAttr& rAttr ) const
+{
+ return( ( maLogSize == rAttr.maLogSize ) &&
+ ( mfGamma == rAttr.mfGamma ) &&
+ ( mnMirrFlags == rAttr.mnMirrFlags ) &&
+ ( mnLeftCrop == rAttr.mnLeftCrop ) &&
+ ( mnTopCrop == rAttr.mnTopCrop ) &&
+ ( mnRightCrop == rAttr.mnRightCrop ) &&
+ ( mnBottomCrop == rAttr.mnBottomCrop ) &&
+ ( mnRotate10 == rAttr.mnRotate10 ) &&
+ ( mnContPercent == rAttr.mnContPercent ) &&
+ ( mnLumPercent == rAttr.mnLumPercent ) &&
+ ( mnRPercent == rAttr.mnRPercent ) &&
+ ( mnGPercent == rAttr.mnGPercent ) &&
+ ( mnBPercent == rAttr.mnBPercent ) &&
+ ( mbInvert == rAttr.mbInvert ) &&
+ ( mcTransparency == rAttr.mcTransparency ) &&
+ ( meDrawMode == rAttr.meDrawMode ) );
+}
+
+// ------------------------------------------------------------------------
+
+SvStream& operator>>( SvStream& rIStm, GraphicAttr& rAttr )
+{
+ VersionCompat aCompat( rIStm, STREAM_READ );
+ UINT16 nTmp16;
+
+ rIStm >> rAttr.maLogSize >> rAttr.mfGamma >> rAttr.mnMirrFlags >> rAttr.mnRotate10;
+ rIStm >> rAttr.mnContPercent >> rAttr.mnLumPercent >> rAttr.mnRPercent >> rAttr.mnGPercent >> rAttr.mnBPercent;
+ rIStm >> rAttr.mbInvert >> rAttr.mcTransparency >> nTmp16;
+ rAttr.meDrawMode = (GraphicDrawMode) nTmp16;
+
+ if( aCompat.GetVersion() >= 2 )
+ {
+ rIStm >> rAttr.mnLeftCrop >> rAttr.mnTopCrop >> rAttr.mnRightCrop >> rAttr.mnBottomCrop;
+ }
+
+ return rIStm;
+}
+
+// ------------------------------------------------------------------------
+
+SvStream& operator<<( SvStream& rOStm, const GraphicAttr& rAttr )
+{
+ VersionCompat aCompat( rOStm, STREAM_WRITE, 2 );
+
+ rOStm << rAttr.maLogSize << rAttr.mfGamma << rAttr.mnMirrFlags << rAttr.mnRotate10;
+ rOStm << rAttr.mnContPercent << rAttr.mnLumPercent << rAttr.mnRPercent << rAttr.mnGPercent << rAttr.mnBPercent;
+ rOStm << rAttr.mbInvert << rAttr.mcTransparency << (UINT16) rAttr.meDrawMode;
+ rOStm << rAttr.mnLeftCrop << rAttr.mnTopCrop << rAttr.mnRightCrop << rAttr.mnBottomCrop;
+
+ return rOStm;
+}
diff --git a/goodies/source/graphic/grfcache.cxx b/goodies/source/graphic/grfcache.cxx
new file mode 100644
index 000000000000..0e31ff8a671b
--- /dev/null
+++ b/goodies/source/graphic/grfcache.cxx
@@ -0,0 +1,876 @@
+/*************************************************************************
+ *
+ * $RCSfile: grfcache.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <tools/debug.hxx>
+#include <vcl/outdev.hxx>
+#include "grfcache.hxx"
+
+// -----------
+// - statics -
+// -----------
+
+static const char aHexData[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+
+// -------------
+// - GraphicID -
+// -------------
+
+class GraphicID
+{
+private:
+
+ sal_uInt32 mnID1;
+ sal_uInt32 mnID2;
+ sal_uInt32 mnID3;
+ sal_uInt32 mnID4;
+
+ GraphicID();
+
+public:
+
+
+ GraphicID( const GraphicObject& rObj );
+ ~GraphicID() {}
+
+ BOOL operator==( const GraphicID& rID ) const
+ {
+ return( rID.mnID1 == mnID1 && rID.mnID2 == mnID2 &&
+ rID.mnID3 == mnID3 && rID.mnID4 == mnID4 );
+ }
+
+ ByteString GetIDString() const;
+};
+
+// -----------------------------------------------------------------------------
+
+GraphicID::GraphicID( const GraphicObject& rObj )
+{
+ const Graphic& rGraphic = rObj.GetGraphic();
+
+ mnID1 = ( (ULONG) rGraphic.GetType() ) << 28;
+
+ switch( rGraphic.GetType() )
+ {
+ case( GRAPHIC_BITMAP ):
+ {
+ if( rGraphic.IsAnimated() )
+ {
+ const Animation aAnimation( rGraphic.GetAnimation() );
+
+ mnID1 |= ( aAnimation.Count() & 0x0fffffff );
+ mnID2 = aAnimation.GetDisplaySizePixel().Width();
+ mnID3 = aAnimation.GetDisplaySizePixel().Height();
+ mnID4 = rGraphic.GetChecksum();
+ }
+ else
+ {
+ const BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+
+ mnID1 |= ( ( ( (ULONG) aBmpEx.GetTransparentType() << 8 ) | ( aBmpEx.IsAlpha() ? 1 : 0 ) ) & 0x0fffffff );
+ mnID2 = aBmpEx.GetSizePixel().Width();
+ mnID3 = aBmpEx.GetSizePixel().Height();
+ mnID4 = rGraphic.GetChecksum();
+ }
+ }
+ break;
+
+ case( GRAPHIC_GDIMETAFILE ):
+ {
+ const GDIMetaFile aMtf( rGraphic.GetGDIMetaFile() );
+
+ mnID1 |= ( aMtf.GetActionCount() & 0x0fffffff );
+ mnID2 = aMtf.GetPrefSize().Width();
+ mnID3 = aMtf.GetPrefSize().Height();
+ mnID4 = rGraphic.GetChecksum();
+ }
+ break;
+
+ default:
+ mnID2 = mnID3 = mnID4 = 0;
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+ByteString GraphicID::GetIDString() const
+{
+ ByteString aHexStr;
+ sal_Char* pStr = aHexStr.AllocBuffer( 32 );
+ sal_Int32 nShift;
+
+ for( nShift = 28; nShift >= 0; nShift -= 4 )
+ *pStr++ = aHexData[ ( mnID1 >> (sal_uInt32) nShift ) & 0xf ];
+
+ for( nShift = 28; nShift >= 0; nShift -= 4 )
+ *pStr++ = aHexData[ ( mnID2 >> (sal_uInt32) nShift ) & 0xf ];
+
+ for( nShift = 28; nShift >= 0; nShift -= 4 )
+ *pStr++ = aHexData[ ( mnID3 >> (sal_uInt32) nShift ) & 0xf ];
+
+ for( nShift = 28; nShift >= 0; nShift -= 4 )
+ *pStr++ = aHexData[ ( mnID4 >> (sal_uInt32) nShift ) & 0xf ];
+
+ return aHexStr;
+}
+
+// ---------------------
+// - GraphicCacheEntry -
+// ---------------------
+
+class GraphicCacheEntry
+{
+private:
+
+ List maGraphicObjectList;
+ GraphicID maID;
+ GfxLink maGfxLink;
+ BitmapEx* mpBmpEx;
+ GDIMetaFile* mpMtf;
+ Animation* mpAnimation;
+ BOOL mbSwappedAll : 1;
+ BOOL mbInitialized : 1;
+
+ BOOL ImplInit( const GraphicObject& rObj );
+ BOOL ImplMatches( const GraphicObject& rObj ) const { return( GraphicID( rObj ) == maID ); }
+ void ImplFillSubstitute( Graphic& rSubstitute );
+
+public:
+
+ GraphicCacheEntry( const GraphicObject& rObj );
+ ~GraphicCacheEntry();
+
+ const GraphicID& GetID() const { return maID; }
+
+ BOOL AddGraphicObjectReference( const GraphicObject& rObj, Graphic& rSubstitute );
+ BOOL ReleaseGraphicObjectReference( const GraphicObject& rObj );
+ ULONG GetGraphicObjectReferenceCount() { return maGraphicObjectList.Count(); }
+ BOOL HasGraphicObjectReference( const GraphicObject& rObj );
+
+ void GraphicObjectWasSwappedOut( const GraphicObject& rObj );
+ BOOL FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute );
+ void GraphicObjectWasSwappedIn( const GraphicObject& rObj );
+
+ BOOL IsInitialized() const { return mbInitialized; }
+};
+
+// -----------------------------------------------------------------------------
+
+GraphicCacheEntry::GraphicCacheEntry( const GraphicObject& rObj ) :
+ maID ( rObj ),
+ mpBmpEx ( NULL ),
+ mpMtf ( NULL ),
+ mpAnimation ( NULL ),
+ mbInitialized ( ImplInit( rObj ) )
+{
+ mbSwappedAll = !mbInitialized;
+ maGraphicObjectList.Insert( (void*) &rObj, LIST_APPEND );
+}
+
+// -----------------------------------------------------------------------------
+
+GraphicCacheEntry::~GraphicCacheEntry()
+{
+ DBG_ASSERT( !maGraphicObjectList.Count(), "GraphicCacheEntry::~GraphicCacheEntry(): Not all GraphicObjects are removed from this entry" );
+
+ delete mpBmpEx;
+ delete mpMtf;
+ delete mpAnimation;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicCacheEntry::ImplInit( const GraphicObject& rObj )
+{
+ BOOL bRet;
+
+ if( !rObj.IsSwappedOut() )
+ {
+ const Graphic& rGraphic = rObj.GetGraphic();
+
+ if( mpBmpEx )
+ delete mpBmpEx, mpBmpEx = NULL;
+
+ if( mpMtf )
+ delete mpMtf, mpMtf = NULL;
+
+ if( mpAnimation )
+ delete mpAnimation, mpAnimation = NULL;
+
+ switch( rGraphic.GetType() )
+ {
+ case( GRAPHIC_BITMAP ):
+ {
+ if( rGraphic.IsAnimated() )
+ mpAnimation = new Animation( rGraphic.GetAnimation() );
+ else
+ mpBmpEx = new BitmapEx( rGraphic.GetBitmapEx() );
+ }
+ break;
+
+ case( GRAPHIC_GDIMETAFILE ):
+ {
+ mpMtf = new GDIMetaFile( rGraphic.GetGDIMetaFile() );
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if( rGraphic.IsLink() )
+ maGfxLink = ( (Graphic&) rGraphic ).GetLink();
+ else
+ maGfxLink = GfxLink();
+
+ bRet = TRUE;
+ }
+ else
+ bRet = FALSE;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicCacheEntry::ImplFillSubstitute( Graphic& rSubstitute )
+{
+ // create substitute for graphic;
+ const Size aPrefSize( rSubstitute.GetPrefSize() );
+ const MapMode aPrefMapMode( rSubstitute.GetPrefMapMode() );
+ const Link aAnimationNotifyHdl( rSubstitute.GetAnimationNotifyHdl() );
+ const String aDocFileName( rSubstitute.GetDocFileName() );
+ const ULONG nDocFilePos = rSubstitute.GetDocFilePos();
+ const GraphicType eOldType = rSubstitute.GetType();
+ const BOOL bDefaultType = ( rSubstitute.GetType() == GRAPHIC_DEFAULT );
+
+ if( rSubstitute.IsLink() && ( GFX_LINK_TYPE_NONE == maGfxLink.GetType() ) )
+ maGfxLink = rSubstitute.GetLink();
+
+ if( mpBmpEx )
+ rSubstitute = *mpBmpEx;
+ else if( mpAnimation )
+ rSubstitute = *mpAnimation;
+ else if( mpMtf )
+ rSubstitute = *mpMtf;
+ else
+ rSubstitute.Clear();
+
+ if( eOldType != GRAPHIC_NONE )
+ {
+ rSubstitute.SetPrefSize( aPrefSize );
+ rSubstitute.SetPrefMapMode( aPrefMapMode );
+ rSubstitute.SetAnimationNotifyHdl( aAnimationNotifyHdl );
+ rSubstitute.SetDocFileName( aDocFileName, nDocFilePos );
+ }
+
+ if( GFX_LINK_TYPE_NONE != maGfxLink.GetType() )
+ rSubstitute.SetLink( maGfxLink );
+
+ if( bDefaultType )
+ rSubstitute.SetDefaultType();
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicCacheEntry::AddGraphicObjectReference( const GraphicObject& rObj, Graphic& rSubstitute )
+{
+ BOOL bRet;
+
+ if( !rObj.IsSwappedOut() )
+ {
+ // append object pointer to list
+ maGraphicObjectList.Insert( (void*) &rObj, LIST_APPEND );
+
+ if( mbSwappedAll )
+ {
+ ImplInit( rObj );
+ mbSwappedAll = FALSE;
+ }
+
+ ImplFillSubstitute( rSubstitute );
+ bRet = TRUE;
+ }
+ else
+ bRet = FALSE;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicCacheEntry::ReleaseGraphicObjectReference( const GraphicObject& rObj )
+{
+ BOOL bRet = FALSE;
+
+ for( void* pObj = maGraphicObjectList.First(); !bRet && pObj; pObj = maGraphicObjectList.Next() )
+ {
+ if( &rObj == (GraphicObject*) pObj )
+ {
+ maGraphicObjectList.Remove( pObj );
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicCacheEntry::HasGraphicObjectReference( const GraphicObject& rObj )
+{
+ BOOL bRet = FALSE;
+
+ for( void* pObj = maGraphicObjectList.First(); !bRet && pObj; pObj = maGraphicObjectList.Next() )
+ if( &rObj == (GraphicObject*) pObj )
+ bRet = TRUE;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicCacheEntry::GraphicObjectWasSwappedOut( const GraphicObject& rObj )
+{
+ mbSwappedAll = TRUE;
+
+ for( void* pObj = maGraphicObjectList.First(); mbSwappedAll && pObj; pObj = maGraphicObjectList.Next() )
+ if( !( (GraphicObject*) pObj )->IsSwappedOut() )
+ mbSwappedAll = FALSE;
+
+ if( mbSwappedAll )
+ {
+ delete mpBmpEx, mpBmpEx = NULL;
+ delete mpMtf, mpMtf = NULL;
+ delete mpAnimation, mpAnimation = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicCacheEntry::FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute )
+{
+ BOOL bRet;
+
+ if( !mbSwappedAll && rObj.IsSwappedOut() )
+ {
+ ImplFillSubstitute( rSubstitute );
+ bRet = TRUE;
+ }
+ else
+ bRet = FALSE;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicCacheEntry::GraphicObjectWasSwappedIn( const GraphicObject& rObj )
+{
+ if( mbSwappedAll )
+ mbSwappedAll = !ImplInit( rObj );
+}
+
+// ----------------------------
+// - GraphicDisplayCacheEntry -
+// ----------------------------
+
+class GraphicDisplayCacheEntry
+{
+private:
+
+ const GraphicCacheEntry* mpRefCacheEntry;
+ GDIMetaFile* mpMtf;
+ BitmapEx* mpBmpEx;
+ GraphicAttr maAttr;
+ Size maOutSizePix;
+ ULONG mnCacheSize;
+
+public:
+
+ static ULONG GetNeededSize( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicObject& rObj, const GraphicAttr& rAttr );
+
+public:
+
+ GraphicDisplayCacheEntry( const GraphicCacheEntry* pRefCacheEntry,
+ OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicObject& rObj, const GraphicAttr& rAttr,
+ const BitmapEx& rBmpEx ) :
+ mpRefCacheEntry( pRefCacheEntry ),
+ mpMtf( NULL ), mpBmpEx( new BitmapEx( rBmpEx ) ),
+ maAttr( rAttr ), maOutSizePix( pOut->LogicToPixel( rSz ) ),
+ mnCacheSize( GetNeededSize( pOut, rPt, rSz, rObj, rAttr ) ) {}
+
+ GraphicDisplayCacheEntry( const GraphicCacheEntry* pRefCacheEntry,
+ OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicObject& rObj, const GraphicAttr& rAttr,
+ const GDIMetaFile& rMtf ) :
+ mpRefCacheEntry( pRefCacheEntry ),
+ mpMtf( new GDIMetaFile( rMtf ) ), mpBmpEx( NULL ),
+ maAttr( rAttr ), maOutSizePix( pOut->LogicToPixel( rSz ) ),
+ mnCacheSize( GetNeededSize( pOut, rPt, rSz, rObj, rAttr ) ) {}
+
+ ~GraphicDisplayCacheEntry();
+
+ const GraphicAttr& GetAttr() const { return maAttr; }
+ const Size& GetOutputSizePixel() const { return maOutSizePix; }
+ const long GetCacheSize() const { return mnCacheSize; }
+ const GraphicCacheEntry* GetReferencedCacheEntry() const { return mpRefCacheEntry; }
+
+ BOOL Matches( OutputDevice* pOut, const Point& rPtPixel, const Size& rSzPixel,
+ const GraphicCacheEntry* pCacheEntry, const GraphicAttr& rAttr ) const
+ {
+ return( ( pCacheEntry == mpRefCacheEntry ) &&
+ ( maAttr == rAttr ) &&
+ ( ( maOutSizePix == rSzPixel ) || ( !maOutSizePix.Width() && !maOutSizePix.Height() ) ) );
+ }
+
+ void Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz ) const;
+};
+
+// -----------------------------------------------------------------------------
+
+ULONG GraphicDisplayCacheEntry::GetNeededSize( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicObject& rObj, const GraphicAttr& rAttr )
+{
+ const GraphicType eType = rObj.GetGraphic().GetType();
+ ULONG nNeededSize;
+
+ if( GRAPHIC_BITMAP == eType )
+ {
+ const Size aOutSizePix( pOut->LogicToPixel( rSz ) );
+ const long nBitCount = pOut->GetBitCount();
+
+ if( nBitCount )
+ {
+ nNeededSize = aOutSizePix.Width() * aOutSizePix.Height() * nBitCount / 8;
+
+ if( rObj.IsTransparent() || ( rAttr.GetRotation() % 3600 ) )
+ nNeededSize += nNeededSize / nBitCount;
+ }
+ else
+ {
+ DBG_ERROR( "GraphicDisplayCacheEntry::GetNeededSize(): pOut->GetBitCount() == 0" );
+ nNeededSize = 256000;
+ }
+ }
+ else if( GRAPHIC_GDIMETAFILE == eType )
+ nNeededSize = 65535;
+ else
+ nNeededSize = 0;
+
+ return nNeededSize;
+}
+
+// -----------------------------------------------------------------------------
+
+GraphicDisplayCacheEntry::~GraphicDisplayCacheEntry()
+{
+ if( mpMtf )
+ delete mpMtf;
+
+ if( mpBmpEx )
+ delete mpBmpEx;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicDisplayCacheEntry::Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz ) const
+{
+ if( mpMtf )
+ GraphicManager::ImplDraw( pOut, rPt, rSz, *mpMtf, maAttr );
+ else if( mpBmpEx )
+ GraphicManager::ImplDraw( pOut, rPt, rSz, *mpBmpEx, maAttr );
+}
+
+// -----------------------
+// - GraphicCache -
+// -----------------------
+
+GraphicCache::GraphicCache( GraphicManager& rMgr, ULONG nDisplayCacheSize, ULONG nMaxObjDisplayCacheSize ) :
+ mrMgr ( rMgr ),
+ mnMaxDisplaySize ( nDisplayCacheSize ),
+ mnMaxObjDisplaySize ( nMaxObjDisplayCacheSize ),
+ mnUsedDisplaySize ( 0UL )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+GraphicCache::~GraphicCache()
+{
+ DBG_ASSERT( !maGraphicCache.Count(), "GraphicCache::~GraphicCache(): there are some GraphicObjects in cache" );
+ DBG_ASSERT( !maDisplayCache.Count(), "GraphicCache::~GraphicCache(): there are some GraphicObjects in display cache" );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicCache::AddGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute, const ByteString* pID )
+{
+ BOOL bInserted = FALSE;
+
+ if( !rObj.IsSwappedOut() )
+ {
+ GraphicCacheEntry* pEntry = (GraphicCacheEntry*) maGraphicCache.First();
+ const GraphicID aID( rObj );
+
+ while( !bInserted && pEntry )
+ {
+ const GraphicID& rID = pEntry->GetID();
+
+ if( pID )
+ {
+ if( rID.GetIDString() == *pID )
+ bInserted = pEntry->AddGraphicObjectReference( rObj, rSubstitute );
+ }
+ else
+ {
+ if( pEntry->GetID() == aID )
+ bInserted = pEntry->AddGraphicObjectReference( rObj, rSubstitute );
+ }
+
+ pEntry = (GraphicCacheEntry*) maGraphicCache.Next();
+ }
+ }
+
+ if( !bInserted )
+ maGraphicCache.Insert( new GraphicCacheEntry( rObj ), LIST_APPEND );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicCache::ReleaseGraphicObject( const GraphicObject& rObj )
+{
+ // Release cached object
+ GraphicCacheEntry* pEntry = (GraphicCacheEntry*) maGraphicCache.First();
+ BOOL bRemoved = FALSE;
+
+ while( !bRemoved && pEntry )
+ {
+ bRemoved = pEntry->ReleaseGraphicObjectReference( rObj );
+
+ if( bRemoved )
+ {
+ if( 0 == pEntry->GetGraphicObjectReferenceCount() )
+ {
+ // if graphic cache entry has no more references,
+ // the corresponding display cache object can be removed
+ GraphicDisplayCacheEntry* pDisplayEntry = (GraphicDisplayCacheEntry*) maDisplayCache.First();
+
+ while( pDisplayEntry )
+ {
+ if( pDisplayEntry->GetReferencedCacheEntry() == pEntry )
+ {
+ mnUsedDisplaySize -= pDisplayEntry->GetCacheSize();
+ maDisplayCache.Remove( pDisplayEntry );
+ delete pDisplayEntry;
+ pDisplayEntry = (GraphicDisplayCacheEntry*) maDisplayCache.GetCurObject();
+ }
+ else
+ pDisplayEntry = (GraphicDisplayCacheEntry*) maDisplayCache.Next();
+ }
+
+ // delete graphic cache entry
+ maGraphicCache.Remove( (void*) pEntry );
+ delete pEntry;
+ }
+ }
+ else
+ pEntry = (GraphicCacheEntry*) maGraphicCache.Next();
+ }
+
+ DBG_ASSERT( bRemoved, "GraphicCache::ReleaseGraphicObject(...): GraphicObject not found in cache" );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicCache::GraphicObjectWasSwappedOut( const GraphicObject& rObj )
+{
+ ImplGetCacheEntry( rObj )->GraphicObjectWasSwappedOut( rObj );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicCache::FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute )
+{
+ return( ImplGetCacheEntry( rObj )->FillSwappedGraphicObject( rObj, rSubstitute ) );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicCache::GraphicObjectWasSwappedIn( const GraphicObject& rObj )
+{
+ GraphicCacheEntry* pEntry = ImplGetCacheEntry( rObj );
+
+ if( !pEntry->IsInitialized() )
+ {
+ ReleaseGraphicObject( rObj );
+ AddGraphicObject( rObj, (Graphic&) rObj.GetGraphic(), NULL );
+ }
+ else
+ pEntry->GraphicObjectWasSwappedIn( rObj );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicCache::SetMaxDisplayCacheSize( ULONG nNewCacheSize )
+{
+ mnMaxDisplaySize = nNewCacheSize;
+
+ if( GetMaxDisplayCacheSize() < GetUsedDisplayCacheSize() )
+ ImplFreeDisplayCacheSpace( GetUsedDisplayCacheSize() - GetMaxDisplayCacheSize() );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicCache::SetMaxObjDisplayCacheSize( ULONG nNewMaxObjSize, BOOL bDestroyGreaterCached )
+{
+ const BOOL bDestroy = ( bDestroyGreaterCached && ( nNewMaxObjSize < mnMaxObjDisplaySize ) );
+
+ mnMaxObjDisplaySize = Min( nNewMaxObjSize, mnMaxDisplaySize );
+
+ if( bDestroy )
+ {
+ GraphicDisplayCacheEntry* pCacheObj = (GraphicDisplayCacheEntry*) maDisplayCache.First();
+
+ while( pCacheObj )
+ {
+ if( pCacheObj->GetCacheSize() > mnMaxObjDisplaySize )
+ {
+ mnUsedDisplaySize -= pCacheObj->GetCacheSize();
+ maDisplayCache.Remove( pCacheObj );
+ delete pCacheObj;
+ pCacheObj = (GraphicDisplayCacheEntry*) maDisplayCache.GetCurObject();
+ }
+ else
+ pCacheObj = (GraphicDisplayCacheEntry*) maDisplayCache.Next();
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicCache::ClearDisplayCache()
+{
+ for( void* pObj = maDisplayCache.First(); pObj; pObj = maDisplayCache.Next() )
+ delete (GraphicDisplayCacheEntry*) pObj;
+
+ maDisplayCache.Clear();
+ mnUsedDisplaySize = 0UL;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicCache::IsDisplayCacheable( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicObject& rObj, const GraphicAttr& rAttr ) const
+{
+ return( GraphicDisplayCacheEntry::GetNeededSize( pOut, rPt, rSz, rObj, rAttr ) <=
+ GetMaxObjDisplayCacheSize() );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicCache::IsInDisplayCache( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicObject& rObj, const GraphicAttr& rAttr ) const
+{
+ const Point aPtPixel( pOut->LogicToPixel( rPt ) );
+ const Size aSzPixel( pOut->LogicToPixel( rSz ) );
+ const GraphicCacheEntry* pCacheEntry = ( (GraphicCache*) this )->ImplGetCacheEntry( rObj );
+ GraphicDisplayCacheEntry* pDisplayEntry = (GraphicDisplayCacheEntry*) ( (GraphicCache*) this )->maDisplayCache.First();
+ BOOL bFound = FALSE;
+
+ for( long i = 0, nCount = maDisplayCache.Count(); !bFound && ( i < nCount ); i++ )
+ if( ( (GraphicDisplayCacheEntry*) maDisplayCache.GetObject( i ) )->Matches( pOut, aPtPixel, aSzPixel, pCacheEntry, rAttr ) )
+ bFound = TRUE;
+
+ return bFound;
+}
+
+// -----------------------------------------------------------------------------
+
+ByteString GraphicCache::GetUniqueID( const GraphicObject& rObj ) const
+{
+ return( ( (GraphicCache*) this )->ImplGetCacheEntry( rObj )->GetID().GetIDString() );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicObject& rObj, const GraphicAttr& rAttr,
+ const BitmapEx& rBmpEx )
+{
+ const ULONG nNeededSize = GraphicDisplayCacheEntry::GetNeededSize( pOut, rPt, rSz, rObj, rAttr );
+ BOOL bRet = FALSE;
+
+ if( nNeededSize <= GetMaxObjDisplayCacheSize() )
+ {
+ if( nNeededSize > GetFreeDisplayCacheSize() )
+ ImplFreeDisplayCacheSpace( nNeededSize - GetFreeDisplayCacheSize() );
+
+ GraphicDisplayCacheEntry* pNewEntry = new GraphicDisplayCacheEntry( ImplGetCacheEntry( rObj ),
+ pOut, rPt, rSz, rObj, rAttr, rBmpEx );
+
+
+ maDisplayCache.Insert( pNewEntry, (ULONG) 0 );
+ mnUsedDisplaySize += pNewEntry->GetCacheSize();
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicObject& rObj, const GraphicAttr& rAttr,
+ const GDIMetaFile& rMtf )
+{
+ const ULONG nNeededSize = GraphicDisplayCacheEntry::GetNeededSize( pOut, rPt, rSz, rObj, rAttr );
+ BOOL bRet = FALSE;
+
+ if( nNeededSize <= GetMaxObjDisplayCacheSize() )
+ {
+ if( nNeededSize > GetFreeDisplayCacheSize() )
+ ImplFreeDisplayCacheSpace( nNeededSize - GetFreeDisplayCacheSize() );
+
+ GraphicDisplayCacheEntry* pNewEntry = new GraphicDisplayCacheEntry( ImplGetCacheEntry( rObj ),
+ pOut, rPt, rSz, rObj, rAttr, rMtf );
+
+
+ maDisplayCache.Insert( pNewEntry, (ULONG) 0 );
+ mnUsedDisplaySize += pNewEntry->GetCacheSize();
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicCache::DrawDisplayCacheObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicObject& rObj, const GraphicAttr& rAttr )
+{
+ const Point aPtPixel( pOut->LogicToPixel( rPt ) );
+ const Size aSzPixel( pOut->LogicToPixel( rSz ) );
+ const GraphicCacheEntry* pCacheEntry = ImplGetCacheEntry( rObj );
+ GraphicDisplayCacheEntry* pDisplayCacheEntry = (GraphicDisplayCacheEntry*) maDisplayCache.First();
+ BOOL bRet = FALSE;
+
+ while( !bRet && pDisplayCacheEntry )
+ {
+ if( pDisplayCacheEntry->Matches( pOut, aPtPixel, aSzPixel, pCacheEntry, rAttr ) )
+ {
+ // put found object at last used position
+ maDisplayCache.Insert( maDisplayCache.Remove( pDisplayCacheEntry ), LIST_APPEND );
+ bRet = TRUE;
+ }
+ else
+ pDisplayCacheEntry = (GraphicDisplayCacheEntry*) maDisplayCache.Next();
+ }
+
+ if( bRet )
+ pDisplayCacheEntry->Draw( pOut, rPt, rSz );
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicCache::ImplFreeDisplayCacheSpace( ULONG nSizeToFree )
+{
+ ULONG nFreedSize = 0UL;
+
+ if( nSizeToFree && ( nSizeToFree <= mnMaxDisplaySize ) )
+ {
+ void* pObj = maDisplayCache.First();
+
+ while( pObj )
+ {
+ GraphicDisplayCacheEntry* pCacheObj = (GraphicDisplayCacheEntry*) pObj;
+
+ nFreedSize += pCacheObj->GetCacheSize();
+ mnUsedDisplaySize -= pCacheObj->GetCacheSize();
+ maDisplayCache.Remove( pObj );
+ delete pCacheObj;
+
+ if( nFreedSize >= nSizeToFree )
+ break;
+ else
+ pObj = maDisplayCache.GetCurObject();
+ }
+ }
+
+ return( nFreedSize >= nSizeToFree );
+}
+
+// -----------------------------------------------------------------------------
+
+GraphicCacheEntry* GraphicCache::ImplGetCacheEntry( const GraphicObject& rObj )
+{
+ GraphicCacheEntry* pRet = NULL;
+
+ for( void* pObj = maGraphicCache.First(); !pRet && pObj; pObj = maGraphicCache.Next() )
+ if( ( (GraphicCacheEntry*) pObj )->HasGraphicObjectReference( rObj ) )
+ pRet = (GraphicCacheEntry*) pObj;
+
+ return pRet;
+}
diff --git a/goodies/source/graphic/grfcache.hxx b/goodies/source/graphic/grfcache.hxx
new file mode 100644
index 000000000000..508ec2e15206
--- /dev/null
+++ b/goodies/source/graphic/grfcache.hxx
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * $RCSfile: grfcache.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _GRFCACHE_HXX
+#define _GRFCACHE_HXX
+
+#include <tools/list.hxx>
+#include <vcl/graph.hxx>
+#include "grfmgr.hxx"
+
+// -----------------------
+// - GraphicManagerCache -
+// -----------------------
+
+class GraphicCacheEntry;
+
+class GraphicCache
+{
+private:
+
+ GraphicManager& mrMgr;
+ List maGraphicCache;
+ List maDisplayCache;
+ ULONG mnMaxDisplaySize;
+ ULONG mnMaxObjDisplaySize;
+ ULONG mnUsedDisplaySize;
+
+ BOOL ImplFreeDisplayCacheSpace( ULONG nSizeToFree );
+ GraphicCacheEntry* ImplGetCacheEntry( const GraphicObject& rObj );
+
+public:
+
+ GraphicCache( GraphicManager& rMgr,
+ ULONG nDisplayCacheSize = 10000000UL,
+ ULONG nMaxObjDisplayCacheSize = 2400000UL );
+ ~GraphicCache();
+
+public:
+
+ void AddGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute, const ByteString* pID );
+ void ReleaseGraphicObject( const GraphicObject& rObj );
+
+ void GraphicObjectWasSwappedOut( const GraphicObject& rObj );
+ BOOL FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute );
+ void GraphicObjectWasSwappedIn( const GraphicObject& rObj );
+
+ ByteString GetUniqueID( const GraphicObject& rObj ) const;
+
+public:
+
+ void SetMaxDisplayCacheSize( ULONG nNewCacheSize );
+ ULONG GetMaxDisplayCacheSize() const { return mnMaxDisplaySize; };
+
+ void SetMaxObjDisplayCacheSize( ULONG nNewMaxObjSize, BOOL bDestroyGreaterCached = FALSE );
+ ULONG GetMaxObjDisplayCacheSize() const { return mnMaxObjDisplaySize; }
+
+ ULONG GetUsedDisplayCacheSize() const { return mnUsedDisplaySize; }
+ ULONG GetFreeDisplayCacheSize() const { return( mnMaxDisplaySize - mnUsedDisplaySize ); }
+
+ void ClearDisplayCache();
+ BOOL IsDisplayCacheable( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicObject& rObj, const GraphicAttr& rAttr ) const;
+ BOOL IsInDisplayCache( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicObject& rObj, const GraphicAttr& rAttr ) const;
+ BOOL CreateDisplayCacheObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicObject& rObj, const GraphicAttr& rAttr,
+ const BitmapEx& rBmpEx );
+ BOOL CreateDisplayCacheObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicObject& rObj, const GraphicAttr& rAttr,
+ const GDIMetaFile& rMtf );
+ BOOL DrawDisplayCacheObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicObject& rObj, const GraphicAttr& rAttr );
+};
+
+#endif // _GRFCACHE_HXX
diff --git a/goodies/source/graphic/grfmgr.cxx b/goodies/source/graphic/grfmgr.cxx
new file mode 100644
index 000000000000..9b8d255ab946
--- /dev/null
+++ b/goodies/source/graphic/grfmgr.cxx
@@ -0,0 +1,851 @@
+/*************************************************************************
+ *
+ * $RCSfile: grfmgr.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#define ENABLE_BYTESTRING_STREAM_OPERATORS
+
+#include <tools/vcompat.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <vcl/metaact.hxx>
+#include <vcl/virdev.hxx>
+#include "grfmgr.hxx"
+
+// -----------
+// - Defines -
+// -----------
+
+#define GRFMGR_CACHESIZE_STANDARD 10000000UL
+#define GRFMGR_OBJCACHESIZE_STANDARD 2500000UL
+#define GRFMGR_CACHESIZE_APPSERVER 10000000UL
+#define GRFMGR_OBJCACHESIZE_APPSERVER 2500000UL
+#define WATERMARK_LUM_OFFSET 50
+#define WATERMARK_CON_OFFSET -70
+
+// -----------
+// - statics -
+// -----------
+
+GraphicManager* GraphicObject::mpGlobalMgr = NULL;
+
+// ---------------------
+// - GrfDirectCacheObj -
+// ---------------------
+
+struct GrfSimpleCacheObj
+{
+ Graphic maGraphic;
+ GraphicAttr maAttr;
+
+ GrfSimpleCacheObj( const Graphic& rGraphic, const GraphicAttr& rAttr ) :
+ maGraphic( rGraphic ), maAttr( rAttr ) {}
+};
+
+// -----------------
+// - GraphicObject -
+// -----------------
+
+TYPEINIT1_AUTOFACTORY( GraphicObject, SvDataCopyStream );
+
+// -----------------------------------------------------------------------------
+
+GraphicObject::GraphicObject( const GraphicManager* pMgr ) :
+ mpLink ( NULL )
+{
+ ImplConstruct();
+ ImplAssignGraphicData();
+ ImplSetGraphicManager( pMgr );
+}
+
+// -----------------------------------------------------------------------------
+
+GraphicObject::GraphicObject( const Graphic& rGraphic, const GraphicManager* pMgr ) :
+ maGraphic ( rGraphic ),
+ mpLink ( NULL )
+{
+ ImplConstruct();
+ ImplAssignGraphicData();
+ ImplSetGraphicManager( pMgr );
+}
+
+// -----------------------------------------------------------------------------
+
+GraphicObject::GraphicObject( const Graphic& rGraphic, const String& rLink, const GraphicManager* pMgr ) :
+ maGraphic ( rGraphic ),
+ mpLink ( rLink.Len() ? ( new String( rLink ) ) : NULL )
+{
+ ImplConstruct();
+ ImplAssignGraphicData();
+ ImplSetGraphicManager( pMgr );
+}
+
+// -----------------------------------------------------------------------------
+
+GraphicObject::GraphicObject( const GraphicObject& rGraphicObj, const GraphicManager* pMgr ) :
+ maGraphic ( rGraphicObj.GetGraphic() ),
+ mpLink ( rGraphicObj.mpLink ? ( new String( *rGraphicObj.mpLink ) ) : NULL ),
+ maAttr ( rGraphicObj.maAttr )
+{
+ ImplConstruct();
+ ImplAssignGraphicData();
+ ImplSetGraphicManager( pMgr );
+}
+
+// -----------------------------------------------------------------------------
+
+GraphicObject::GraphicObject( const ByteString& rUniqueID, const GraphicManager* pMgr ) :
+ mpLink ( NULL )
+{
+ ImplConstruct();
+ ImplSetGraphicManager( pMgr, &rUniqueID );
+ ImplAssignGraphicData();
+}
+
+// -----------------------------------------------------------------------------
+
+GraphicObject::~GraphicObject()
+{
+ if( mpMgr )
+ {
+ mpMgr->ImplUnregisterObj( *this );
+
+ if( ( mpMgr == mpGlobalMgr ) && !mpGlobalMgr->ImplHasObjects() )
+ delete mpGlobalMgr, mpGlobalMgr = NULL;
+ }
+
+ delete mpSwapOutTimer;
+ delete mpSwapStreamHdl;
+ delete mpLink;
+ delete mpSimpleCache;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::ImplConstruct()
+{
+ mpMgr = NULL;
+ mpSwapStreamHdl = NULL;
+ mpSwapOutTimer = NULL;
+ mpSimpleCache = NULL;
+ mbAutoSwapped = FALSE;
+ mbIsInSwapIn = FALSE;
+ mbIsInSwapOut = FALSE;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::ImplAssignGraphicData()
+{
+ maPrefSize = maGraphic.GetPrefSize();
+ maPrefMapMode = maGraphic.GetPrefMapMode();
+ mnSizeBytes = maGraphic.GetSizeBytes();
+ meType = maGraphic.GetType();
+ mbTransparent = maGraphic.IsTransparent();
+ mbAnimated = maGraphic.IsAnimated();
+
+ if( maGraphic.GetType() == GRAPHIC_GDIMETAFILE )
+ {
+ const GDIMetaFile& rMtf = GetGraphic().GetGDIMetaFile();
+ mbEPS = ( rMtf.GetActionCount() == 1 ) && ( META_EPS_ACTION == rMtf.GetAction( 0 )->GetType() );
+ }
+ else
+ mbEPS = FALSE;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::ImplSetGraphicManager( const GraphicManager* pMgr, const ByteString* pID )
+{
+ if( !mpMgr || ( pMgr != mpMgr ) )
+ {
+ if( !pMgr && mpMgr && ( mpMgr == mpGlobalMgr ) )
+ return;
+ else
+ {
+ if( mpMgr )
+ {
+ mpMgr->ImplUnregisterObj( *this );
+
+ if( ( mpMgr == mpGlobalMgr ) && !mpGlobalMgr->ImplHasObjects() )
+ delete mpGlobalMgr, mpGlobalMgr = NULL;
+ }
+
+ if( !pMgr )
+ {
+ if( !mpGlobalMgr )
+ {
+ if( Application::IsRemoteServer() )
+ mpGlobalMgr = new GraphicManager( GRFMGR_CACHESIZE_APPSERVER, GRFMGR_OBJCACHESIZE_APPSERVER );
+ else
+ mpGlobalMgr = new GraphicManager( GRFMGR_CACHESIZE_STANDARD, GRFMGR_OBJCACHESIZE_STANDARD );
+ }
+
+ mpMgr = mpGlobalMgr;
+ }
+ else
+ mpMgr = (GraphicManager*) pMgr;
+
+ mpMgr->ImplRegisterObj( *this, maGraphic, pID );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::ImplAutoSwapIn( BOOL bIgnoreSwapState )
+{
+ if( bIgnoreSwapState || IsSwappedOut() )
+ {
+ if( mpMgr && mpMgr->ImplFillSwappedGraphicObject( *this, maGraphic ) )
+ mbAutoSwapped = FALSE;
+ else
+ {
+ mbIsInSwapIn = TRUE;
+
+ SvStream* pStream = GetSwapStream();
+
+ if( GRFMGR_AUTOSWAPSTREAM_NONE != pStream )
+ {
+ if( GRFMGR_AUTOSWAPSTREAM_LINK == pStream )
+ {
+ if( HasLink() )
+ {
+ SvFileStream aIStm( GetLink(), STREAM_READ );
+ mbAutoSwapped = !maGraphic.SwapIn( &aIStm );
+ }
+ }
+ else if( GRFMGR_AUTOSWAPSTREAM_TEMP == pStream )
+ mbAutoSwapped = !maGraphic.SwapIn();
+ else if( GRFMGR_AUTOSWAPSTREAM_LOADED == pStream )
+ mbAutoSwapped = maGraphic.IsSwapOut();
+ else
+ {
+ mbAutoSwapped = !maGraphic.SwapIn( pStream );
+ delete pStream;
+ }
+ }
+
+ mbIsInSwapIn = FALSE;
+
+ if( !mbAutoSwapped && mpMgr )
+ mpMgr->ImplGraphicObjectWasSwappedIn( *this );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+GraphicObject& GraphicObject::operator=( const GraphicObject& rGraphicObj )
+{
+ if( &rGraphicObj != this )
+ {
+ mpMgr->ImplUnregisterObj( *this );
+
+ delete mpSwapStreamHdl, mpSwapStreamHdl = NULL;
+ delete mpSimpleCache, mpSimpleCache = NULL;
+ delete mpLink;
+
+ maGraphic = rGraphicObj.GetGraphic();
+ maAttr = rGraphicObj.maAttr;
+ mpLink = rGraphicObj.mpLink ? new String( *rGraphicObj.mpLink ) : NULL;
+ ImplAssignGraphicData();
+ mbAutoSwapped = FALSE;
+ mpMgr = rGraphicObj.mpMgr;
+
+ mpMgr->ImplRegisterObj( *this, maGraphic, NULL );
+ }
+
+ return *this;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicObject::operator==( const GraphicObject& rGraphicObj ) const
+{
+ return( ( rGraphicObj.maGraphic == maGraphic ) &&
+ ( rGraphicObj.maAttr == maAttr ) &&
+ ( rGraphicObj.GetLink() == GetLink() ) );
+}
+
+// ------------------------------------------------------------------------
+
+void GraphicObject::Load( SvStream& rIStm )
+{
+ rIStm >> *this;
+}
+
+// ------------------------------------------------------------------------
+
+void GraphicObject::Save( SvStream& rOStm )
+{
+ rOStm << *this;
+}
+
+// ------------------------------------------------------------------------
+
+void GraphicObject::Assign( const SvDataCopyStream& rCopyStream )
+{
+ *this = (const GraphicObject& ) rCopyStream;
+}
+
+// -----------------------------------------------------------------------------
+
+ByteString GraphicObject::GetUniqueID() const
+{
+ ByteString aRet;
+
+ if( mpMgr )
+ aRet = mpMgr->ImplGetUniqueID( *this );
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+ULONG GraphicObject::GetChecksum() const
+{
+ return( ( maGraphic.IsSupportedGraphic() && !maGraphic.IsSwapOut() ) ? maGraphic.GetChecksum() : 0 );
+}
+
+// -----------------------------------------------------------------------------
+
+SvStream* GraphicObject::GetSwapStream() const
+{
+ return( HasSwapStreamHdl() ? (SvStream*) mpSwapStreamHdl->Call( (void*) this ) : GRFMGR_AUTOSWAPSTREAM_NONE );
+}
+
+// -----------------------------------------------------------------------------
+
+// !!! to be removed
+ULONG GraphicObject::GetReleaseFromCache() const
+{
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::SetAttr( const GraphicAttr& rAttr )
+{
+ maAttr = rAttr;
+
+ if( mpSimpleCache && ( mpSimpleCache->maAttr != rAttr ) )
+ delete mpSimpleCache, mpSimpleCache = NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::SetLink()
+{
+ if( mpLink )
+ delete mpLink, mpLink = NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::SetLink( const String& rLink )
+{
+ delete mpLink, mpLink = new String( rLink );
+}
+
+// -----------------------------------------------------------------------------
+
+String GraphicObject::GetLink() const
+{
+ if( mpLink )
+ return *mpLink;
+ else
+ return String();
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::SetSwapStreamHdl()
+{
+ if( mpSwapStreamHdl )
+ {
+ delete mpSwapOutTimer, mpSwapOutTimer = NULL;
+ delete mpSwapStreamHdl, mpSwapStreamHdl = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::SetSwapStreamHdl( const Link& rHdl, const ULONG nSwapOutTimeout )
+{
+ delete mpSwapStreamHdl, mpSwapStreamHdl = new Link( rHdl );
+
+ if( nSwapOutTimeout )
+ {
+ if( !mpSwapOutTimer )
+ {
+ mpSwapOutTimer = new Timer;
+ mpSwapOutTimer->SetTimeoutHdl( LINK( this, GraphicObject, ImplAutoSwapOutHdl ) );
+ }
+
+ mpSwapOutTimer->SetTimeout( nSwapOutTimeout );
+ mpSwapOutTimer->Start();
+ }
+ else
+ delete mpSwapOutTimer, mpSwapOutTimer = NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+Link GraphicObject::GetSwapStreamHdl() const
+{
+ if( mpSwapStreamHdl )
+ return *mpSwapStreamHdl;
+ else
+ return Link();
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::FireSwapInRequest()
+{
+ ImplAutoSwapIn( TRUE );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::FireSwapOutRequest()
+{
+ ImplAutoSwapOutHdl( NULL );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::GraphicManagerDestroyed()
+{
+ // we're alive, but our manager doesn't live anymore ==> connect to default manager
+ mpMgr = NULL;
+ ImplSetGraphicManager( NULL );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::SetGraphicManager( const GraphicManager& rMgr )
+{
+ ImplSetGraphicManager( &rMgr );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicObject::IsCached( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicAttr* pAttr, ULONG nFlags ) const
+{
+ BOOL bRet;
+
+ if( nFlags & GRFMGR_DRAW_CACHED )
+ bRet = mpMgr->IsInCache( pOut, rPt, rSz, *this, ( pAttr ? *pAttr : GetAttr() ) );
+ else
+ bRet = FALSE;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::ReleaseFromCache()
+{
+
+ mpMgr->ReleaseFromCache( *this );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::SetAnimationNotifyHdl( const Link& rLink )
+{
+ maGraphic.SetAnimationNotifyHdl( rLink );
+}
+
+// -----------------------------------------------------------------------------
+
+List* GraphicObject::GetAnimationInfoList() const
+{
+ return maGraphic.GetAnimationInfoList();
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicObject::Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GraphicAttr* pAttr, ULONG nFlags )
+{
+ const GraphicAttr& rActAttr = ( pAttr ? *pAttr : GetAttr() );
+ BOOL bCached = FALSE;
+ BOOL bRet;
+
+ if( IsAnimated() || !( nFlags & GRFMGR_DRAW_CACHED ) )
+ {
+ GetGraphic();
+
+ if( maGraphic.IsSupportedGraphic() && !maGraphic.IsSwapOut() )
+ {
+ Graphic aGraphic( GetTransformedGraphic( &rActAttr ) );
+
+ if( aGraphic.IsSupportedGraphic() )
+ {
+ aGraphic.Draw( pOut, rPt, rSz );
+ bRet = TRUE;
+ }
+ else
+ bRet = FALSE;
+ }
+ else
+ bRet = FALSE;
+ }
+ else
+ bRet = mpMgr->DrawObj( pOut, rPt, rSz, *this, rActAttr, nFlags, bCached );
+
+ if( bCached )
+ {
+ if( mpSwapOutTimer )
+ mpSwapOutTimer->Start();
+ else
+ FireSwapOutRequest();
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicObject::StartAnimation( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ long nExtraData, const GraphicAttr* pAttr, ULONG nFlags,
+ OutputDevice* pFirstFrameOutDev )
+{
+ const GraphicAttr& rActAttr = ( pAttr ? *pAttr : GetAttr() );
+ BOOL bRet = FALSE;
+
+ GetGraphic();
+
+ if( !IsSwappedOut() )
+ {
+ if( mbAnimated )
+ {
+ if( !mpSimpleCache || ( mpSimpleCache->maAttr != rActAttr ) || pFirstFrameOutDev )
+ {
+ if( mpSimpleCache )
+ delete mpSimpleCache;
+
+ mpSimpleCache = new GrfSimpleCacheObj( GetTransformedGraphic( &rActAttr ), rActAttr );
+ mpSimpleCache->maGraphic.SetAnimationNotifyHdl( GetAnimationNotifyHdl() );
+ }
+
+ mpSimpleCache->maGraphic.StartAnimation( pOut, rPt, rSz, nExtraData, pFirstFrameOutDev );
+ bRet = TRUE;
+ }
+ else
+ bRet = Draw( pOut, rPt, rSz, &rActAttr, GRFMGR_DRAW_STANDARD );
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::StopAnimation( OutputDevice* pOut, long nExtraData )
+{
+ if( mpSimpleCache )
+ mpSimpleCache->maGraphic.StopAnimation( pOut, nExtraData );
+}
+
+// -----------------------------------------------------------------------------
+
+const Graphic& GraphicObject::GetGraphic() const
+{
+ if( mbAutoSwapped )
+ ( (GraphicObject*) this )->ImplAutoSwapIn( FALSE );
+
+ return maGraphic;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::SetGraphic( const Graphic& rGraphic )
+{
+ mpMgr->ImplUnregisterObj( *this );
+
+ if( mpSwapOutTimer )
+ mpSwapOutTimer->Stop();
+
+ maGraphic = rGraphic;
+ mbAutoSwapped = FALSE;
+ ImplAssignGraphicData();
+ delete mpLink, mpLink = NULL;
+ delete mpSimpleCache, mpSimpleCache = NULL;
+
+ mpMgr->ImplRegisterObj( *this, maGraphic, NULL );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::SetGraphic( const Graphic& rGraphic, const String& rLink )
+{
+ SetGraphic( rGraphic );
+ mpLink = new String( rLink );
+}
+
+// -----------------------------------------------------------------------------
+
+Graphic GraphicObject::GetTransformedGraphic( const GraphicAttr* pAttr ) const
+{
+ Graphic aGraphic;
+ GraphicAttr aActAttr;
+
+ GetGraphic();
+ aActAttr = ( pAttr ? *pAttr : GetAttr() );
+
+ if( maGraphic.IsSupportedGraphic() && !maGraphic.IsSwapOut() )
+ {
+ if( aActAttr.IsSpecialDrawMode() || aActAttr.IsAdjusted() ||
+ aActAttr.IsMirrored() || aActAttr.IsRotated() || aActAttr.IsTransparent() )
+ {
+ if( GetType() == GRAPHIC_BITMAP )
+ {
+ if( IsAnimated() )
+ {
+ Animation aAnimation( maGraphic.GetAnimation() );
+ GraphicManager::ImplAdjust( aAnimation, aActAttr, ADJUSTMENT_ALL );
+ aGraphic = aAnimation;
+ }
+ else
+ {
+ BitmapEx aBmpEx( maGraphic.GetBitmapEx() );
+ GraphicManager::ImplAdjust( aBmpEx, aActAttr, ADJUSTMENT_ALL );
+ aGraphic = aBmpEx;
+ }
+ }
+ else
+ {
+ GDIMetaFile aMtf( maGraphic.GetGDIMetaFile() );
+ GraphicManager::ImplAdjust( aMtf, aActAttr, ADJUSTMENT_ALL );
+ aGraphic = aMtf;
+ }
+ }
+ else
+ aGraphic = maGraphic;
+ }
+
+ return aGraphic;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObject::ResetAnimationLoopCount()
+{
+ if( IsAnimated() && !IsSwappedOut() )
+ {
+ maGraphic.ResetAnimationLoopCount();
+
+ if( mpSimpleCache )
+ mpSimpleCache->maGraphic.ResetAnimationLoopCount();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicObject::SwapOut()
+{
+ BOOL bRet = ( !mbAutoSwapped ? maGraphic.SwapOut() : FALSE );
+
+ if( bRet && mpMgr )
+ mpMgr->ImplGraphicObjectWasSwappedOut( *this );
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicObject::SwapOut( SvStream* pOStm )
+{
+ BOOL bRet = ( !mbAutoSwapped ? maGraphic.SwapOut( pOStm ) : FALSE );
+
+ if( bRet && mpMgr )
+ mpMgr->ImplGraphicObjectWasSwappedOut( *this );
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicObject::SwapIn()
+{
+ BOOL bRet;
+
+ if( mbAutoSwapped )
+ {
+ ImplAutoSwapIn( FALSE );
+ bRet = TRUE;
+ }
+ else if( mpMgr && mpMgr->ImplFillSwappedGraphicObject( *this, maGraphic ) )
+ bRet = TRUE;
+ else
+ {
+ bRet = maGraphic.SwapIn();
+
+ if( bRet && mpMgr )
+ mpMgr->ImplGraphicObjectWasSwappedIn( *this );
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicObject::SwapIn( SvStream* pIStm )
+{
+ BOOL bRet;
+
+ if( mbAutoSwapped )
+ {
+ ImplAutoSwapIn( FALSE );
+ bRet = TRUE;
+ }
+ else if( mpMgr && mpMgr->ImplFillSwappedGraphicObject( *this, maGraphic ) )
+ bRet = TRUE;
+ else
+ {
+ bRet = maGraphic.SwapIn( pIStm );
+
+ if( bRet && mpMgr )
+ mpMgr->ImplGraphicObjectWasSwappedIn( *this );
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( GraphicObject, ImplAutoSwapOutHdl, void*, p )
+{
+ if( !mbAutoSwapped && !IsSwappedOut() )
+ {
+ mbIsInSwapOut = TRUE;
+
+ SvStream* pStream = GetSwapStream();
+
+ if( GRFMGR_AUTOSWAPSTREAM_NONE != pStream )
+ {
+ if( GRFMGR_AUTOSWAPSTREAM_LINK == pStream )
+ mbAutoSwapped = SwapOut( NULL );
+ else
+ {
+ if( GRFMGR_AUTOSWAPSTREAM_TEMP == pStream )
+ mbAutoSwapped = SwapOut();
+ else
+ {
+ mbAutoSwapped = SwapOut( pStream );
+ delete pStream;
+ }
+ }
+ }
+
+ mbIsInSwapOut = FALSE;
+ }
+
+ if( mpSwapOutTimer )
+ mpSwapOutTimer->Start();
+
+ return 0L;
+}
+
+// ------------------------------------------------------------------------
+
+SvStream& operator>>( SvStream& rIStm, GraphicObject& rGraphicObj )
+{
+ VersionCompat aCompat( rIStm, STREAM_READ );
+ Graphic aGraphic;
+ GraphicAttr aAttr;
+ ByteString aLink;
+ BOOL bLink;
+
+ rIStm >> aGraphic >> aAttr >> bLink;
+
+ rGraphicObj.SetGraphic( aGraphic );
+ rGraphicObj.SetAttr( aAttr );
+
+ if( bLink )
+ {
+ rIStm >> aLink;
+ rGraphicObj.SetLink( UniString( aLink, RTL_TEXTENCODING_UTF8 ) );
+ }
+ else
+ rGraphicObj.SetLink();
+
+ rGraphicObj.SetSwapStreamHdl();
+
+ return rIStm;
+}
+
+// ------------------------------------------------------------------------
+
+SvStream& operator<<( SvStream& rOStm, const GraphicObject& rGraphicObj )
+{
+ VersionCompat aCompat( rOStm, STREAM_WRITE, 1 );
+ const BOOL bLink = rGraphicObj.HasLink();
+
+ rOStm << rGraphicObj.GetGraphic() << rGraphicObj.GetAttr() << bLink;
+
+ if( bLink )
+ rOStm << ByteString( rGraphicObj.GetLink(), RTL_TEXTENCODING_UTF8 );
+
+ return rOStm;
+}
diff --git a/goodies/source/graphic/grfmgr2.cxx b/goodies/source/graphic/grfmgr2.cxx
new file mode 100644
index 000000000000..8d8de217bbc0
--- /dev/null
+++ b/goodies/source/graphic/grfmgr2.cxx
@@ -0,0 +1,1492 @@
+/*************************************************************************
+ *
+ * $RCSfile: grfmgr2.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <vos/macros.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/poly.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/window.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/animate.hxx>
+#include <vcl/alpha.hxx>
+#include "grfcache.hxx"
+#include "grfmgr.hxx"
+
+// -----------
+// - defines -
+// -----------
+
+#define MAX_PRINTER_EXT 1024
+#define MAP( cVal0, cVal1, nFrac ) ((BYTE)((((long)(cVal0)<<20L)+nFrac*((long)(cVal1)-(cVal0)))>>20L))
+#define WATERMARK_LUM_OFFSET 50
+#define WATERMARK_CON_OFFSET -70
+
+// ------------------
+// - GraphicManager -
+// ------------------
+
+GraphicManager::GraphicManager( ULONG nCacheSize, ULONG nMaxObjCacheSize ) :
+ mpCache( new GraphicCache( *this, nCacheSize, nMaxObjCacheSize ) )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+GraphicManager::~GraphicManager()
+{
+ for( void* pObj = maObjList.First(); pObj; pObj = maObjList.Next() )
+ ( (GraphicObject*) pObj )->GraphicManagerDestroyed();
+
+ delete mpCache;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicManager::SetMaxCacheSize( ULONG nNewCacheSize )
+{
+ mpCache->SetMaxDisplayCacheSize( nNewCacheSize );
+}
+
+// -----------------------------------------------------------------------------
+
+ULONG GraphicManager::GetMaxCacheSize() const
+{
+ return mpCache->GetMaxDisplayCacheSize();
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicManager::SetMaxObjCacheSize( ULONG nNewMaxObjSize, BOOL bDestroyGreaterCached )
+{
+ mpCache->SetMaxObjDisplayCacheSize( nNewMaxObjSize, bDestroyGreaterCached );
+}
+
+// -----------------------------------------------------------------------------
+
+ULONG GraphicManager::GetMaxObjCacheSize() const
+{
+ return mpCache->GetMaxObjDisplayCacheSize();
+}
+
+// -----------------------------------------------------------------------------
+
+ULONG GraphicManager::GetUsedCacheSize() const
+{
+ return mpCache->GetUsedDisplayCacheSize();
+}
+
+// -----------------------------------------------------------------------------
+
+ULONG GraphicManager::GetFreeCacheSize() const
+{
+ return mpCache->GetFreeDisplayCacheSize();
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicManager::ClearCache()
+{
+ mpCache->ClearDisplayCache();
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicManager::ReleaseFromCache( const GraphicObject& rObj )
+{
+ // !!!
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicManager::IsInCache( OutputDevice* pOut, const Point& rPt,
+ const Size& rSz, const GraphicObject& rObj,
+ const GraphicAttr& rAttr ) const
+{
+ return mpCache->IsInDisplayCache( pOut, rPt, rSz, rObj, rAttr );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicManager::DrawObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ GraphicObject& rObj, const GraphicAttr& rAttr,
+ const ULONG nFlags, BOOL& rCached )
+{
+ GraphicAttr aAttr( rAttr );
+ Point aPt( rPt );
+ Size aSz( rSz );
+ BOOL bRet = FALSE;
+
+ rCached = FALSE;
+
+ if( aSz.Width() < 0L )
+ {
+ aPt.X() += aSz.Width() + 1;
+ aSz.Width() = -aSz.Width();
+ aAttr.SetMirrorFlags( aAttr.GetMirrorFlags() ^ BMP_MIRROR_HORZ );
+ }
+
+ if( aSz.Height() < 0L )
+ {
+ aPt.Y() += aSz.Height() + 1;
+ aSz.Height() = -aSz.Height();
+ aAttr.SetMirrorFlags( aAttr.GetMirrorFlags() ^ BMP_MIRROR_VERT );
+ }
+
+ if( ( rObj.GetType() == GRAPHIC_BITMAP ) || ( rObj.GetType() == GRAPHIC_GDIMETAFILE ) )
+ {
+ const Size aOutSize( pOut->GetOutputSizePixel() );
+
+ // metafile recording?
+ if( ( pOut->GetOutDevType() == OUTDEV_PRINTER ) ||
+ ( pOut->GetConnectMetaFile() && !pOut->IsOutputEnabled() &&
+ ( aOutSize.Width() == 1 ) && ( aOutSize.Height() == 1 ) ) )
+ {
+ const Graphic aGraphic( rObj.GetTransformedGraphic( &aAttr ) );
+
+ if( aGraphic.IsSupportedGraphic() )
+ aGraphic.Draw( pOut, aPt, aSz );
+
+ bRet = TRUE;
+ }
+
+ // cached/direct drawing
+ if( !bRet )
+ {
+ if( !mpCache->DrawDisplayCacheObj( pOut, aPt, aSz, rObj, aAttr ) )
+ bRet = ImplDraw( pOut, aPt, aSz, rObj, aAttr, rCached );
+ else
+ bRet = rCached = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicManager::ImplRegisterObj( const GraphicObject& rObj, Graphic& rSubstitute, const ByteString* pID )
+{
+ maObjList.Insert( (void*) &rObj, LIST_APPEND );
+ mpCache->AddGraphicObject( rObj, rSubstitute, pID );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicManager::ImplUnregisterObj( const GraphicObject& rObj )
+{
+ mpCache->ReleaseGraphicObject( rObj );
+ maObjList.Remove( (void*) &rObj );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicManager::ImplGraphicObjectWasSwappedOut( const GraphicObject& rObj )
+{
+ mpCache->GraphicObjectWasSwappedOut( rObj );
+}
+
+// -----------------------------------------------------------------------------
+
+ByteString GraphicManager::ImplGetUniqueID( const GraphicObject& rObj ) const
+{
+ return mpCache->GetUniqueID( rObj );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicManager::ImplFillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute )
+{
+ return( mpCache->FillSwappedGraphicObject( rObj, rSubstitute ) );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicManager::ImplGraphicObjectWasSwappedIn( const GraphicObject& rObj )
+{
+ mpCache->GraphicObjectWasSwappedIn( rObj );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt,
+ const Size& rSz, GraphicObject& rObj,
+ const GraphicAttr& rAttr, BOOL& rCached )
+{
+ const Graphic& rGraphic = rObj.GetGraphic();
+ BOOL bRet = FALSE;
+
+ if( rGraphic.IsSupportedGraphic() && !rGraphic.IsSwapOut() )
+ {
+ if( GRAPHIC_BITMAP == rGraphic.GetType() )
+ {
+ const BitmapEx aSrcBmpEx( rGraphic.GetBitmapEx() );
+
+ if( mpCache->IsDisplayCacheable( pOut, rPt, rSz, rObj, rAttr ) )
+ {
+ BitmapEx aDstBmpEx;
+
+ if( ImplCreateOutput( pOut, rPt, rSz, aSrcBmpEx, rAttr, &aDstBmpEx ) )
+ {
+ rCached = mpCache->CreateDisplayCacheObj( pOut, rPt, rSz, rObj, rAttr, aDstBmpEx );
+ bRet = TRUE;
+ }
+ }
+
+ if( !bRet )
+ bRet = ImplCreateOutput( pOut, rPt, rSz, aSrcBmpEx, rAttr );
+ }
+ else
+ {
+ const GDIMetaFile& rSrcMtf = rGraphic.GetGDIMetaFile();
+
+ if( mpCache->IsDisplayCacheable( pOut, rPt, rSz, rObj, rAttr ) )
+ {
+ GDIMetaFile aDstMtf;
+
+ if( ImplCreateOutput( pOut, rPt, rSz, rSrcMtf, rAttr, &aDstMtf ) )
+ {
+ rCached = mpCache->CreateDisplayCacheObj( pOut, rPt, rSz, rObj, rAttr, aDstMtf );
+ bRet = TRUE;
+ }
+ }
+
+ if( !bRet )
+ {
+ const Graphic aGraphic( rObj.GetTransformedGraphic( &rAttr ) );
+
+ if( aGraphic.IsSupportedGraphic() )
+ {
+ aGraphic.Draw( pOut, rPt, rSz );
+ bRet = TRUE;
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicManager::ImplCreateOutput( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const BitmapEx& rBmpEx, const GraphicAttr& rAttr,
+ BitmapEx* pBmpEx )
+{
+ const USHORT nRot10 = rAttr.GetRotation() % 3600;
+ const Point aOutPtPix( pOut->LogicToPixel( rPt ) );
+ const Size aOutSzPix( pOut->LogicToPixel( rSz ) );
+ const Size aUntSzPix( nRot10 ? pOut->LogicToPixel( rAttr.GetUntransformedSize() ) : aOutSzPix );
+ BOOL bRet = FALSE;
+
+ if( aUntSzPix.Width() && aUntSzPix.Height() )
+ {
+ BitmapEx aBmpEx( rBmpEx );
+ BitmapEx aOutBmpEx;
+ Point aOutPt;
+ Size aOutSz;
+ const Size& rBmpSzPix = rBmpEx.GetSizePixel();
+ const long nW = rBmpSzPix.Width();
+ const long nH = rBmpSzPix.Height();
+ const long nNewW = aUntSzPix.Width();
+ const long nNewH = aUntSzPix.Height();
+ const double fRevScaleX = ( nNewW > 1L ) ? ( (double) ( nW - 1L ) / ( nNewW - 1L ) ) : 0.0;
+ const double fRevScaleY = ( nNewH > 1L ) ? ( (double) ( nH - 1L ) / ( nNewH - 1L ) ) : 0.0;
+ double fTmp;
+ long* pMapIX = new long[ nNewW ];
+ long* pMapFX = new long[ nNewW ];
+ long* pMapIY = new long[ nNewH ];
+ long* pMapFY = new long[ nNewH ];
+ long nStartX, nStartY, nEndX, nEndY;
+ long nX, nY, nTmp, nTmpX, nTmpY;
+ BOOL bHMirr = ( rAttr.GetMirrorFlags() & BMP_MIRROR_HORZ ) != 0;
+ BOOL bVMirr = ( rAttr.GetMirrorFlags() & BMP_MIRROR_VERT ) != 0;
+
+ // create horizontal mapping table
+ for( nX = 0L, nTmpX = nW - 1L, nTmp = nW - 2L; nX < nNewW; nX++ )
+ {
+ fTmp = nX * fRevScaleX;
+
+ if( bHMirr )
+ fTmp = nTmpX - fTmp;
+
+ pMapFX[ nX ] = (long) ( ( fTmp - ( pMapIX[ nX ] = MinMax( (long) fTmp, 0, nTmp ) ) ) * 1048576. );
+ }
+
+ // create vertical mapping table
+ for( nY = 0L, nTmpY = nH - 1L, nTmp = nH - 2L; nY < nNewH; nY++ )
+ {
+ fTmp = nY * fRevScaleY;
+
+ if( bVMirr )
+ fTmp = nTmpY - fTmp;
+
+ pMapFY[ nY ] = (long) ( ( fTmp - ( pMapIY[ nY ] = MinMax( (long) fTmp, 0, nTmp ) ) ) * 1048576. );
+ }
+
+ // calculate output sizes
+ if( !pBmpEx )
+ {
+ Point aPt;
+ Rectangle aOutRect( aPt, pOut->GetOutputSizePixel() );
+ Rectangle aBmpRect( aOutPtPix, aOutSzPix );
+
+ if( pOut->GetOutDevType() == OUTDEV_WINDOW )
+ {
+ const Region aPaintRgn( ( (Window*) pOut )->GetPaintRegion() );
+ if( !aPaintRgn.IsNull() )
+ aOutRect.Intersection( pOut->LogicToPixel( aPaintRgn.GetBoundRect() ) );
+ }
+
+ aOutRect.Intersection( aBmpRect );
+
+ if( !aOutRect.IsEmpty() )
+ {
+ aOutPt = pOut->PixelToLogic( aOutRect.TopLeft() );
+ aOutSz = pOut->PixelToLogic( aOutRect.GetSize() );
+ nStartX = aOutRect.Left() - aBmpRect.Left();
+ nStartY = aOutRect.Top() - aBmpRect.Top();
+ nEndX = aOutRect.Right() - aBmpRect.Left();
+ nEndY = aOutRect.Bottom() - aBmpRect.Top();
+ }
+ else
+ nStartX = -1L; // invalid
+ }
+ else
+ {
+ aOutPt = rPt;
+ aOutSz = rSz;
+ nStartX = nStartY = 0;
+ nEndX = aOutSzPix.Width() - 1L;
+ nEndY = aOutSzPix.Height() - 1L;
+ }
+
+ // do transformation
+ if( nStartX >= 0L )
+ {
+ const BOOL bSimple = ( 1 == nW || 1 == nH );
+
+ if( nRot10 )
+ {
+ if( bSimple )
+ {
+ bRet = ( aOutBmpEx = aBmpEx ).Scale( aUntSzPix );
+
+ if( bRet )
+ aOutBmpEx.Rotate( nRot10, COL_TRANSPARENT );
+ }
+ else
+ {
+ bRet = ImplCreateRotatedScaled( aBmpEx,
+ nRot10, aOutSzPix, aUntSzPix,
+ pMapIX, pMapFX, pMapIY, pMapFY, nStartX, nEndX, nStartY, nEndY,
+ aOutBmpEx );
+ }
+ }
+ else
+ {
+ if( bSimple )
+ bRet = ( aOutBmpEx = aBmpEx ).Scale( Size( nEndX - nStartX + 1, nEndY - nStartY + 1 ) );
+ else
+ {
+ bRet = ImplCreateScaled( aBmpEx,
+ pMapIX, pMapFX, pMapIY, pMapFY,
+ nStartX, nEndX, nStartY, nEndY,
+ aOutBmpEx );
+ }
+ }
+
+ if( bRet )
+ {
+ // attribute adjustment if neccessary
+ if( rAttr.IsSpecialDrawMode() || rAttr.IsAdjusted() || rAttr.IsTransparent() )
+ ImplAdjust( aOutBmpEx, rAttr, ADJUSTMENT_DRAWMODE | ADJUSTMENT_COLORS | ADJUSTMENT_TRANSPARENCY );
+
+ // OutDev adjustment if neccessary
+ if( pOut->GetOutDevType() != OUTDEV_PRINTER && pOut->GetBitCount() <= 8 && aOutBmpEx.GetBitCount() >= 8 )
+ aOutBmpEx.Dither( BMP_DITHER_MATRIX );
+ }
+ }
+
+ // delete lookup tables
+ delete[] pMapIX;
+ delete[] pMapFX;
+ delete[] pMapIY;
+ delete[] pMapFY;
+
+ // create output
+ if( bRet )
+ {
+ if( !pBmpEx )
+ ImplDraw( pOut, aOutPt, aOutSz, aOutBmpEx, rAttr );
+ else
+ {
+ if( !rAttr.IsTransparent() && !aOutBmpEx.IsAlpha() )
+ aOutBmpEx = BitmapEx( aOutBmpEx.GetBitmap().CreateDisplayBitmap( pOut ), aOutBmpEx.GetMask() );
+
+ ImplDraw( pOut, aOutPt, aOutSz, *pBmpEx = aOutBmpEx, rAttr );
+ }
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicManager::ImplCreateOutput( OutputDevice* pOut,
+ const Point& rPt, const Size& rSz,
+ const GDIMetaFile& rMtf,
+ const GraphicAttr& rAttr,
+ GDIMetaFile* pMtf )
+{
+ if( !pMtf )
+ {
+ DBG_ERROR( "Missing..." );
+ }
+ else
+ {
+ *pMtf = rMtf;
+
+ if( rAttr.IsSpecialDrawMode() || rAttr.IsAdjusted() || rAttr.IsRotated() || rAttr.IsTransparent() )
+ ImplAdjust( *pMtf, rAttr, ADJUSTMENT_DRAWMODE | ADJUSTMENT_COLORS | ADJUSTMENT_ROTATE | ADJUSTMENT_TRANSPARENCY );
+
+ ImplDraw( pOut, rPt, rSz, *pMtf, rAttr );
+ }
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicManager::ImplCreateScaled( const BitmapEx& rBmpEx,
+ long* pMapIX, long* pMapFX, long* pMapIY, long* pMapFY,
+ long nStartX, long nEndX, long nStartY, long nEndY,
+ BitmapEx& rOutBmpEx )
+{
+ Bitmap aBmp( rBmpEx.GetBitmap() );
+ Bitmap aOutBmp;
+ BitmapReadAccess* pAcc = aBmp.AcquireReadAccess();
+ BitmapWriteAccess* pWAcc;
+ BitmapColor aCol0, aCol1, aColRes;
+ const long nDstW = nEndX - nStartX + 1L;
+ const long nDstH = nEndY - nStartY + 1L;
+ long nX, nY, nTmpX, nTmpY, nTmpFX, nTmpFY;
+ long nXDst, nYDst;
+ BYTE cR0, cG0, cB0, cR1, cG1, cB1;
+ BOOL bRet = FALSE;
+
+ if( pAcc )
+ {
+ aOutBmp = Bitmap( Size( nDstW, nDstH ), 24 );
+ pWAcc = aOutBmp.AcquireWriteAccess();
+
+ if( pWAcc )
+ {
+ if( pAcc->HasPalette() )
+ {
+ if( pAcc->GetScanlineFormat() == BMP_FORMAT_8BIT_PAL )
+ {
+ Scanline pLine0, pLine1;
+
+ for( nY = nStartY, nYDst = 0L; nY <= nEndY; nY++, nYDst++ )
+ {
+ nTmpY = pMapIY[ nY ]; nTmpFY = pMapFY[ nY ];
+ pLine0 = pAcc->GetScanline( nTmpY );
+ pLine1 = pAcc->GetScanline( ++nTmpY );
+
+ for( nX = nStartX, nXDst = 0L; nX <= nEndX; nX++ )
+ {
+ nTmpX = pMapIX[ nX ]; nTmpFX = pMapFX[ nX ];
+
+ const BitmapColor& rCol0 = pAcc->GetPaletteColor( pLine0[ nTmpX ] );
+ const BitmapColor& rCol2 = pAcc->GetPaletteColor( pLine1[ nTmpX ] );
+ const BitmapColor& rCol1 = pAcc->GetPaletteColor( pLine0[ ++nTmpX ] );
+ const BitmapColor& rCol3 = pAcc->GetPaletteColor( pLine1[ nTmpX ] );
+
+ cR0 = MAP( rCol0.GetRed(), rCol1.GetRed(), nTmpFX );
+ cG0 = MAP( rCol0.GetGreen(), rCol1.GetGreen(), nTmpFX );
+ cB0 = MAP( rCol0.GetBlue(), rCol1.GetBlue(), nTmpFX );
+
+ cR1 = MAP( rCol2.GetRed(), rCol3.GetRed(), nTmpFX );
+ cG1 = MAP( rCol2.GetGreen(), rCol3.GetGreen(), nTmpFX );
+ cB1 = MAP( rCol2.GetBlue(), rCol3.GetBlue(), nTmpFX );
+
+ aColRes.SetRed( MAP( cR0, cR1, nTmpFY ) );
+ aColRes.SetGreen( MAP( cG0, cG1, nTmpFY ) );
+ aColRes.SetBlue( MAP( cB0, cB1, nTmpFY ) );
+ pWAcc->SetPixel( nYDst, nXDst++, aColRes );
+ }
+ }
+ }
+ else
+ {
+ for( nY = nStartY, nYDst = 0L; nY <= nEndY; nY++, nYDst++ )
+ {
+ nTmpY = pMapIY[ nY ], nTmpFY = pMapFY[ nY ];
+
+ for( nX = nStartX, nXDst = 0L; nX <= nEndX; nX++ )
+ {
+ nTmpX = pMapIX[ nX ]; nTmpFX = pMapFX[ nX ];
+
+ aCol0 = pAcc->GetPaletteColor( pAcc->GetPixel( nTmpY, nTmpX ) );
+ aCol1 = pAcc->GetPaletteColor( pAcc->GetPixel( nTmpY, ++nTmpX ) );
+ cR0 = MAP( aCol0.GetRed(), aCol1.GetRed(), nTmpFX );
+ cG0 = MAP( aCol0.GetGreen(), aCol1.GetGreen(), nTmpFX );
+ cB0 = MAP( aCol0.GetBlue(), aCol1.GetBlue(), nTmpFX );
+
+ aCol1 = pAcc->GetPaletteColor( pAcc->GetPixel( ++nTmpY, nTmpX ) );
+ aCol0 = pAcc->GetPaletteColor( pAcc->GetPixel( nTmpY--, --nTmpX ) );
+ cR1 = MAP( aCol0.GetRed(), aCol1.GetRed(), nTmpFX );
+ cG1 = MAP( aCol0.GetGreen(), aCol1.GetGreen(), nTmpFX );
+ cB1 = MAP( aCol0.GetBlue(), aCol1.GetBlue(), nTmpFX );
+
+ aColRes.SetRed( MAP( cR0, cR1, nTmpFY ) );
+ aColRes.SetGreen( MAP( cG0, cG1, nTmpFY ) );
+ aColRes.SetBlue( MAP( cB0, cB1, nTmpFY ) );
+ pWAcc->SetPixel( nYDst, nXDst++, aColRes );
+ }
+ }
+ }
+ }
+ else
+ {
+ if( pAcc->GetScanlineFormat() == BMP_FORMAT_24BIT_TC_BGR )
+ {
+ Scanline pLine0, pLine1, pTmp0, pTmp1;
+ long nOff;
+
+ for( nY = nStartY, nYDst = 0L; nY <= nEndY; nY++, nYDst++ )
+ {
+ nTmpY = pMapIY[ nY ]; nTmpFY = pMapFY[ nY ];
+ pLine0 = pAcc->GetScanline( nTmpY );
+ pLine1 = pAcc->GetScanline( ++nTmpY );
+
+ for( nX = nStartX, nXDst = 0L; nX <= nEndX; nX++ )
+ {
+ nOff = 3L * ( nTmpX = pMapIX[ nX ] );
+ nTmpFX = pMapFX[ nX ];
+
+ pTmp1 = ( pTmp0 = pLine0 + nOff ) + 3L;
+ cB0 = MAP( *pTmp0, *pTmp1, nTmpFX ); pTmp0++; pTmp1++;
+ cG0 = MAP( *pTmp0, *pTmp1, nTmpFX ); pTmp0++; pTmp1++;
+ cR0 = MAP( *pTmp0, *pTmp1, nTmpFX );
+
+ pTmp1 = ( pTmp0 = pLine1 + nOff ) + 3L;
+ cB1 = MAP( *pTmp0, *pTmp1, nTmpFX ); pTmp0++; pTmp1++;
+ cG1 = MAP( *pTmp0, *pTmp1, nTmpFX ); pTmp0++; pTmp1++;
+ cR1 = MAP( *pTmp0, *pTmp1, nTmpFX );
+
+ aColRes.SetRed( MAP( cR0, cR1, nTmpFY ) );
+ aColRes.SetGreen( MAP( cG0, cG1, nTmpFY ) );
+ aColRes.SetBlue( MAP( cB0, cB1, nTmpFY ) );
+ pWAcc->SetPixel( nYDst, nXDst++, aColRes );
+ }
+ }
+ }
+ else if( pAcc->GetScanlineFormat() == BMP_FORMAT_24BIT_TC_RGB )
+ {
+ Scanline pLine0, pLine1, pTmp0, pTmp1;
+ long nOff;
+
+ for( nY = nStartY, nYDst = 0L; nY <= nEndY; nY++, nYDst++ )
+ {
+ nTmpY = pMapIY[ nY ]; nTmpFY = pMapFY[ nY ];
+ pLine0 = pAcc->GetScanline( nTmpY );
+ pLine1 = pAcc->GetScanline( ++nTmpY );
+
+ for( nX = nStartX, nXDst = 0L; nX <= nEndX; nX++ )
+ {
+ nOff = 3L * ( nTmpX = pMapIX[ nX ] );
+ nTmpFX = pMapFX[ nX ];
+
+ pTmp1 = ( pTmp0 = pLine0 + nOff ) + 3L;
+ cR0 = MAP( *pTmp0, *pTmp1, nTmpFX ); pTmp0++; pTmp1++;
+ cG0 = MAP( *pTmp0, *pTmp1, nTmpFX ); pTmp0++; pTmp1++;
+ cB0 = MAP( *pTmp0, *pTmp1, nTmpFX );
+
+ pTmp1 = ( pTmp0 = pLine1 + nOff ) + 3L;
+ cR1 = MAP( *pTmp0, *pTmp1, nTmpFX ); pTmp0++; pTmp1++;
+ cG1 = MAP( *pTmp0, *pTmp1, nTmpFX ); pTmp0++; pTmp1++;
+ cB1 = MAP( *pTmp0, *pTmp1, nTmpFX );
+
+ aColRes.SetRed( MAP( cR0, cR1, nTmpFY ) );
+ aColRes.SetGreen( MAP( cG0, cG1, nTmpFY ) );
+ aColRes.SetBlue( MAP( cB0, cB1, nTmpFY ) );
+ pWAcc->SetPixel( nYDst, nXDst++, aColRes );
+ }
+ }
+ }
+ else
+ {
+ for( nY = nStartY, nYDst = 0L; nY <= nEndY; nY++, nYDst++ )
+ {
+ nTmpY = pMapIY[ nY ]; nTmpFY = pMapFY[ nY ];
+
+ for( nX = nStartX, nXDst = 0L; nX <= nEndX; nX++ )
+ {
+ nTmpX = pMapIX[ nX ]; nTmpFX = pMapFX[ nX ];
+
+ aCol0 = pAcc->GetPixel( nTmpY, nTmpX );
+ aCol1 = pAcc->GetPixel( nTmpY, ++nTmpX );
+ cR0 = MAP( aCol0.GetRed(), aCol1.GetRed(), nTmpFX );
+ cG0 = MAP( aCol0.GetGreen(), aCol1.GetGreen(), nTmpFX );
+ cB0 = MAP( aCol0.GetBlue(), aCol1.GetBlue(), nTmpFX );
+
+ aCol1 = pAcc->GetPixel( ++nTmpY, nTmpX );
+ aCol0 = pAcc->GetPixel( nTmpY--, --nTmpX );
+ cR1 = MAP( aCol0.GetRed(), aCol1.GetRed(), nTmpFX );
+ cG1 = MAP( aCol0.GetGreen(), aCol1.GetGreen(), nTmpFX );
+ cB1 = MAP( aCol0.GetBlue(), aCol1.GetBlue(), nTmpFX );
+
+ aColRes.SetRed( MAP( cR0, cR1, nTmpFY ) );
+ aColRes.SetGreen( MAP( cG0, cG1, nTmpFY ) );
+ aColRes.SetBlue( MAP( cB0, cB1, nTmpFY ) );
+ pWAcc->SetPixel( nYDst, nXDst++, aColRes );
+ }
+ }
+ }
+ }
+
+ aOutBmp.ReleaseAccess( pWAcc );
+ bRet = TRUE;
+ }
+
+ aBmp.ReleaseAccess( pAcc );
+ }
+
+ if( bRet && rBmpEx.IsTransparent() )
+ {
+ bRet = FALSE;
+
+ if( rBmpEx.IsAlpha() )
+ {
+ AlphaMask aAlpha( rBmpEx.GetAlpha() );
+ AlphaMask aOutAlpha;
+
+ pAcc = aAlpha.AcquireReadAccess();
+
+ if( pAcc )
+ {
+ aOutAlpha = AlphaMask( Size( nDstW, nDstH ) );
+ pWAcc = aOutAlpha.AcquireWriteAccess();
+
+ if( pWAcc )
+ {
+ if( pAcc->GetScanlineFormat() == BMP_FORMAT_8BIT_PAL &&
+ pWAcc->GetScanlineFormat() == BMP_FORMAT_8BIT_PAL )
+ {
+ Scanline pLine0, pLine1, pLineW;
+
+ for( nY = nStartY, nYDst = 0L; nY <= nEndY; nY++, nYDst++ )
+ {
+ nTmpY = pMapIY[ nY ]; nTmpFY = pMapFY[ nY ];
+ pLine0 = pAcc->GetScanline( nTmpY );
+ pLine1 = pAcc->GetScanline( ++nTmpY );
+ pLineW = pWAcc->GetScanline( nYDst );
+
+ for( nX = nStartX, nXDst = 0L; nX <= nEndX; nX++, nXDst++ )
+ {
+ nTmpX = pMapIX[ nX ]; nTmpFX = pMapFX[ nX ];
+
+ const long nAlpha0 = pLine0[ nTmpX ];
+ const long nAlpha2 = pLine1[ nTmpX ];
+ const long nAlpha1 = pLine0[ ++nTmpX ];
+ const long nAlpha3 = pLine1[ nTmpX ];
+ const long n0 = MAP( nAlpha0, nAlpha1, nTmpFX );
+ const long n1 = MAP( nAlpha2, nAlpha3, nTmpFX );
+
+ *pLineW++ = MAP( n0, n1, nTmpFY );
+ }
+ }
+ }
+ else
+ {
+ BitmapColor aAlphaValue( 0 );
+
+ for( nY = nStartY, nYDst = 0L; nY <= nEndY; nY++, nYDst++ )
+ {
+ nTmpY = pMapIY[ nY ], nTmpFY = pMapFY[ nY ];
+
+ for( nX = nStartX, nXDst = 0L; nX <= nEndX; nX++ )
+ {
+ nTmpX = pMapIX[ nX ]; nTmpFX = pMapFX[ nX ];
+
+ long nAlpha0 = pAcc->GetPixel( nTmpY, nTmpX ).GetIndex();
+ long nAlpha1 = pAcc->GetPixel( nTmpY, ++nTmpX ).GetIndex();
+ const long n0 = MAP( nAlpha0, nAlpha1, nTmpFX );
+
+ nAlpha1 = pAcc->GetPixel( ++nTmpY, nTmpX ).GetIndex();
+ nAlpha0 = pAcc->GetPixel( nTmpY--, --nTmpX ).GetIndex();
+ const long n1 = MAP( nAlpha0, nAlpha1, nTmpFX );
+
+ aAlphaValue.SetIndex( MAP( n0, n1, nTmpFY ) );
+ pWAcc->SetPixel( nYDst, nXDst++, aAlphaValue );
+ }
+ }
+ }
+
+ aOutAlpha.ReleaseAccess( pWAcc );
+ bRet = TRUE;
+ }
+
+ aAlpha.ReleaseAccess( pAcc );
+
+ if( bRet )
+ rOutBmpEx = BitmapEx( aOutBmp, aOutAlpha );
+ }
+ }
+ else
+ {
+ Bitmap aMsk( rBmpEx.GetMask() );
+ Bitmap aOutMsk;
+
+ pAcc = aMsk.AcquireReadAccess();
+
+ if( pAcc )
+ {
+ aOutMsk = Bitmap( Size( nDstW, nDstH ), 1 );
+ pWAcc = aOutMsk.AcquireWriteAccess();
+
+ if( pWAcc )
+ {
+ long* pMapLX = new long[ nDstW ];
+ long* pMapLY = new long[ nDstH ];
+
+ // create new horizontal mapping table
+ for( nX = 0UL, nTmpX = nStartX; nX < nDstW; nTmpX++ )
+ pMapLX[ nX++ ] = FRound( (double) pMapIX[ nTmpX ] + pMapFX[ nTmpX ] / 1048576. );
+
+ // create new vertical mapping table
+ for( nY = 0UL, nTmpY = nStartY; nY < nDstH; nTmpY++ )
+ pMapLY[ nY++ ] = FRound( (double) pMapIY[ nTmpY ] + pMapFY[ nTmpY ] / 1048576. );
+
+ // do normal scaling
+ if( pAcc->GetScanlineFormat() == BMP_FORMAT_1BIT_MSB_PAL &&
+ pWAcc->GetScanlineFormat() == BMP_FORMAT_1BIT_MSB_PAL )
+ {
+ // optimized
+ for( nY = 0; nY < nDstH; nY++ )
+ {
+ Scanline pSrc = pAcc->GetScanline( pMapLY[ nY ] );
+ Scanline pDst = pWAcc->GetScanline( nY );
+
+ for( nX = 0L; nX < nDstW; nX++ )
+ {
+ const long nSrcX = pMapLX[ nX ];
+
+ if( pSrc[ nSrcX >> 3 ] & ( 1 << ( 7 - ( nSrcX & 7 ) ) ) )
+ pDst[ nX >> 3 ] |= 1 << ( 7 - ( nX & 7 ) );
+ else
+ pDst[ nX >> 3 ] &= ~( 1 << ( 7 - ( nX & 7 ) ) );
+ }
+ }
+ }
+ else
+ {
+ const BitmapColor aB( pAcc->GetBestMatchingColor( Color( COL_BLACK ) ) );
+ const BitmapColor aWB( pWAcc->GetBestMatchingColor( Color( COL_BLACK ) ) );
+ const BitmapColor aWW( pWAcc->GetBestMatchingColor( Color( COL_WHITE ) ) );
+
+ if( pAcc->HasPalette() )
+ {
+ for( nY = 0L; nY < nDstH; nY++ )
+ {
+ for( nX = 0L; nX < nDstW; nX++ )
+ {
+ if( pAcc->GetPaletteColor( (BYTE) pAcc->GetPixel( pMapLY[ nY ], pMapLX[ nX ] ) ) == aB )
+ pWAcc->SetPixel( nY, nX, aWB );
+ else
+ pWAcc->SetPixel( nY, nX, aWW );
+ }
+ }
+ }
+ else
+ {
+ for( nY = 0L; nY < nDstH; nY++ )
+ {
+ for( nX = 0L; nX < nDstW; nX++ )
+ {
+ if( pAcc->GetPixel( pMapLY[ nY ], pMapLX[ nX ] ) == aB )
+ pWAcc->SetPixel( nY, nX, aWB );
+ else
+ pWAcc->SetPixel( nY, nX, aWW );
+ }
+ }
+ }
+ }
+
+ delete[] pMapLX;
+ delete[] pMapLY;
+ aOutMsk.ReleaseAccess( pWAcc );
+ bRet = TRUE;
+ }
+
+ aMsk.ReleaseAccess( pAcc );
+
+ if( bRet )
+ rOutBmpEx = BitmapEx( aOutBmp, aOutMsk );
+ }
+ }
+
+ if( !bRet )
+ rOutBmpEx = aOutBmp;
+ }
+ else
+ rOutBmpEx = aOutBmp;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GraphicManager::ImplCreateRotatedScaled( const BitmapEx& rBmpEx,
+ USHORT nRot10, const Size& rOutSzPix, const Size& rUntSzPix,
+ long* pMapIX, long* pMapFX, long* pMapIY, long* pMapFY,
+ long nStartX, long nEndX, long nStartY, long nEndY,
+ BitmapEx& rOutBmpEx )
+{
+ Point aPt;
+ Bitmap aBmp( rBmpEx.GetBitmap() );
+ Bitmap aOutBmp;
+ BitmapReadAccess* pAcc = aBmp.AcquireReadAccess();
+ BitmapWriteAccess* pWAcc;
+ Polygon aPoly( Rectangle( aPt, rUntSzPix ) ); aPoly.Rotate( Point(), nRot10 );
+ Rectangle aNewBound( aPoly.GetBoundRect() );
+ const double fCosAngle = cos( nRot10 * F_PI1800 ), fSinAngle = sin( nRot10 * F_PI1800 );
+ double fTmp;
+ const long nDstW = nEndX - nStartX + 1L;
+ const long nDstH = nEndY - nStartY + 1L;
+ const long nUnRotW = rUntSzPix.Width();
+ const long nUnRotH = rUntSzPix.Height();
+ long* pCosX = new long[ nDstW ];
+ long* pSinX = new long[ nDstW ];
+ long* pCosY = new long[ nDstH ];
+ long* pSinY = new long[ nDstH ];
+ long nX, nY, nTmpX, nTmpY, nTmpFX, nTmpFY, nUnRotX, nUnRotY, nSinY, nCosY;
+ BYTE cR0, cG0, cB0, cR1, cG1, cB1;
+ BOOL bRet = FALSE;
+
+ // create horizontal mapping table
+ for( nX = 0L, nTmpX = aNewBound.Left() + nStartX; nX < nDstW; nX++ )
+ {
+ pCosX[ nX ] = FRound( fCosAngle * ( fTmp = nTmpX++ << 8 ) );
+ pSinX[ nX ] = FRound( fSinAngle * fTmp );
+ }
+
+ // create vertical mapping table
+ for( nY = 0L, nTmpY = aNewBound.Top() + nStartY; nY < nDstH; nY++ )
+ {
+ pCosY[ nY ] = FRound( fCosAngle * ( fTmp = nTmpY++ << 8 ) );
+ pSinY[ nY ] = FRound( fSinAngle * fTmp );
+ }
+
+ if( pAcc )
+ {
+ aOutBmp = Bitmap( Size( nDstW, nDstH ), 24 );
+ pWAcc = aOutBmp.AcquireWriteAccess();
+
+ if( pWAcc )
+ {
+ BitmapColor aColRes;
+
+ if( pAcc->HasPalette() )
+ {
+ for( nY = 0; nY < nDstH; nY++ )
+ {
+ nSinY = pSinY[ nY ];
+ nCosY = pCosY[ nY ];
+
+ for( nX = 0; nX < nDstW; nX++ )
+ {
+ nUnRotX = ( pCosX[ nX ] - nSinY ) >> 8;
+ nUnRotY = ( pSinX[ nX ] + nCosY ) >> 8;
+
+ if( ( nUnRotX >= 0L ) && ( nUnRotX < nUnRotW ) &&
+ ( nUnRotY >= 0L ) && ( nUnRotY < nUnRotH ) )
+ {
+ nTmpX = pMapIX[ nUnRotX ]; nTmpFX = pMapFX[ nUnRotX ];
+ nTmpY = pMapIY[ nUnRotY ], nTmpFY = pMapFY[ nUnRotY ];
+
+ const BitmapColor& rCol0 = pAcc->GetPaletteColor( pAcc->GetPixel( nTmpY, nTmpX ) );
+ const BitmapColor& rCol1 = pAcc->GetPaletteColor( pAcc->GetPixel( nTmpY, ++nTmpX ) );
+ cR0 = MAP( rCol0.GetRed(), rCol1.GetRed(), nTmpFX );
+ cG0 = MAP( rCol0.GetGreen(), rCol1.GetGreen(), nTmpFX );
+ cB0 = MAP( rCol0.GetBlue(), rCol1.GetBlue(), nTmpFX );
+
+ const BitmapColor& rCol3 = pAcc->GetPaletteColor( pAcc->GetPixel( ++nTmpY, nTmpX ) );
+ const BitmapColor& rCol2 = pAcc->GetPaletteColor( pAcc->GetPixel( nTmpY, --nTmpX ) );
+ cR1 = MAP( rCol2.GetRed(), rCol3.GetRed(), nTmpFX );
+ cG1 = MAP( rCol2.GetGreen(), rCol3.GetGreen(), nTmpFX );
+ cB1 = MAP( rCol2.GetBlue(), rCol3.GetBlue(), nTmpFX );
+
+ aColRes.SetRed( MAP( cR0, cR1, nTmpFY ) );
+ aColRes.SetGreen( MAP( cG0, cG1, nTmpFY ) );
+ aColRes.SetBlue( MAP( cB0, cB1, nTmpFY ) );
+ pWAcc->SetPixel( nY, nX, aColRes );
+ }
+ }
+ }
+ }
+ else
+ {
+ BitmapColor aCol0, aCol1;
+
+ for( nY = 0; nY < nDstH; nY++ )
+ {
+ nSinY = pSinY[ nY ];
+ nCosY = pCosY[ nY ];
+
+ for( nX = 0; nX < nDstW; nX++ )
+ {
+ nUnRotX = ( pCosX[ nX ] - nSinY ) >> 8;
+ nUnRotY = ( pSinX[ nX ] + nCosY ) >> 8;
+
+ if( ( nUnRotX >= 0L ) && ( nUnRotX < nUnRotW ) &&
+ ( nUnRotY >= 0L ) && ( nUnRotY < nUnRotH ) )
+ {
+ nTmpX = pMapIX[ nUnRotX ]; nTmpFX = pMapFX[ nUnRotX ];
+ nTmpY = pMapIY[ nUnRotY ], nTmpFY = pMapFY[ nUnRotY ];
+
+ aCol0 = pAcc->GetPixel( nTmpY, nTmpX );
+ aCol1 = pAcc->GetPixel( nTmpY, ++nTmpX );
+ cR0 = MAP( aCol0.GetRed(), aCol1.GetRed(), nTmpFX );
+ cG0 = MAP( aCol0.GetGreen(), aCol1.GetGreen(), nTmpFX );
+ cB0 = MAP( aCol0.GetBlue(), aCol1.GetBlue(), nTmpFX );
+
+ aCol1 = pAcc->GetPixel( ++nTmpY, nTmpX );
+ aCol0 = pAcc->GetPixel( nTmpY, --nTmpX );
+ cR1 = MAP( aCol0.GetRed(), aCol1.GetRed(), nTmpFX );
+ cG1 = MAP( aCol0.GetGreen(), aCol1.GetGreen(), nTmpFX );
+ cB1 = MAP( aCol0.GetBlue(), aCol1.GetBlue(), nTmpFX );
+
+ aColRes.SetRed( MAP( cR0, cR1, nTmpFY ) );
+ aColRes.SetGreen( MAP( cG0, cG1, nTmpFY ) );
+ aColRes.SetBlue( MAP( cB0, cB1, nTmpFY ) );
+ pWAcc->SetPixel( nY, nX, aColRes );
+ }
+ }
+ }
+ }
+
+ aOutBmp.ReleaseAccess( pWAcc );
+ bRet = TRUE;
+ }
+
+ aBmp.ReleaseAccess( pAcc );
+ }
+
+ // mask processing
+ if( bRet && ( rBmpEx.IsTransparent() || ( nRot10 != 900 && nRot10 != 1800 && nRot10 != 2700 ) ) )
+ {
+ bRet = FALSE;
+
+ if( rBmpEx.IsAlpha() )
+ {
+ AlphaMask aAlpha( rBmpEx.GetAlpha() );
+ AlphaMask aOutAlpha;
+
+ pAcc = aAlpha.AcquireReadAccess();
+
+ if( pAcc )
+ {
+ aOutAlpha = AlphaMask( Size( nDstW, nDstH ) );
+ pWAcc = aOutAlpha.AcquireWriteAccess();
+
+ if( pWAcc )
+ {
+ if( pAcc->GetScanlineFormat() == BMP_FORMAT_8BIT_PAL &&
+ pWAcc->GetScanlineFormat() == BMP_FORMAT_8BIT_PAL )
+ {
+ Scanline pLine0, pLine1, pLineW;
+
+ for( nY = 0; nY < nDstH; nY++ )
+ {
+ nSinY = pSinY[ nY ], nCosY = pCosY[ nY ];
+ pLineW = pWAcc->GetScanline( nY );
+
+ for( nX = 0; nX < nDstW; nX++ )
+ {
+ nUnRotX = ( pCosX[ nX ] - nSinY ) >> 8;
+ nUnRotY = ( pSinX[ nX ] + nCosY ) >> 8;
+
+ if( ( nUnRotX >= 0L ) && ( nUnRotX < nUnRotW ) &&
+ ( nUnRotY >= 0L ) && ( nUnRotY < nUnRotH ) )
+ {
+ nTmpX = pMapIX[ nUnRotX ], nTmpFX = pMapFX[ nUnRotX ];
+ nTmpY = pMapIY[ nUnRotY ], nTmpFY = pMapFY[ nUnRotY ];
+
+ pLine0 = pAcc->GetScanline( nTmpY++ );
+ pLine1 = pAcc->GetScanline( nTmpY );
+
+ const long nAlpha0 = pLine0[ nTmpX ];
+ const long nAlpha2 = pLine1[ nTmpX++ ];
+ const long nAlpha1 = pLine0[ nTmpX ];
+ const long nAlpha3 = pLine1[ nTmpX ];
+ const long n0 = MAP( nAlpha0, nAlpha1, nTmpFX );
+ const long n1 = MAP( nAlpha2, nAlpha3, nTmpFX );
+
+ *pLineW++ = MAP( n0, n1, nTmpFY );
+ }
+ else
+ *pLineW++ = 255;
+ }
+ }
+ }
+ else
+ {
+ const BitmapColor aTrans( pWAcc->GetBestMatchingColor( Color( COL_WHITE ) ) );
+ BitmapColor aAlphaVal( 0 );
+
+ for( nY = 0; nY < nDstH; nY++ )
+ {
+ nSinY = pSinY[ nY ], nCosY = pCosY[ nY ];
+
+ for( nX = 0; nX < nDstW; nX++ )
+ {
+ nUnRotX = ( pCosX[ nX ] - nSinY ) >> 8;
+ nUnRotY = ( pSinX[ nX ] + nCosY ) >> 8;
+
+ if( ( nUnRotX >= 0L ) && ( nUnRotX < nUnRotW ) &&
+ ( nUnRotY >= 0L ) && ( nUnRotY < nUnRotH ) )
+ {
+ nTmpX = pMapIX[ nUnRotX ]; nTmpFX = pMapFX[ nUnRotX ];
+ nTmpY = pMapIY[ nUnRotY ], nTmpFY = pMapFY[ nUnRotY ];
+
+ const long nAlpha0 = pAcc->GetPixel( nTmpY, nTmpX ).GetIndex();
+ const long nAlpha1 = pAcc->GetPixel( nTmpY, ++nTmpX ).GetIndex();
+ const long nAlpha3 = pAcc->GetPixel( ++nTmpY, nTmpX ).GetIndex();
+ const long nAlpha2 = pAcc->GetPixel( nTmpY, --nTmpX ).GetIndex();
+ const long n0 = MAP( nAlpha0, nAlpha1, nTmpFX );
+ const long n1 = MAP( nAlpha2, nAlpha3, nTmpFX );
+
+ aAlphaVal.SetIndex( MAP( n0, n1, nTmpFY ) );
+ pWAcc->SetPixel( nY, nX, aAlphaVal );
+ }
+ else
+ pWAcc->SetPixel( nY, nX, aTrans );
+ }
+ }
+ }
+
+ aOutAlpha.ReleaseAccess( pWAcc );
+ bRet = TRUE;
+ }
+
+ aAlpha.ReleaseAccess( pAcc );
+ }
+
+ if( bRet )
+ rOutBmpEx = BitmapEx( aOutBmp, aOutAlpha );
+ }
+ else
+ {
+ Bitmap aOutMsk( Size( nDstW, nDstH ), 1 );
+ pWAcc = aOutMsk.AcquireWriteAccess();
+
+ if( pWAcc )
+ {
+ Bitmap aMsk( rBmpEx.GetMask() );
+ const BitmapColor aB( pWAcc->GetBestMatchingColor( Color( COL_BLACK ) ) );
+ const BitmapColor aW( pWAcc->GetBestMatchingColor( Color( COL_WHITE ) ) );
+ BitmapReadAccess* pMAcc = NULL;
+
+ if( !aMsk || ( ( pMAcc = aMsk.AcquireReadAccess() ) != NULL ) )
+ {
+ long* pMapLX = new long[ nUnRotW ];
+ long* pMapLY = new long[ nUnRotH ];
+ BitmapColor aTestB;
+
+ if( pMAcc )
+ aTestB = pMAcc->GetBestMatchingColor( Color( COL_BLACK ) );
+
+ // create new horizontal mapping table
+ for( nX = 0UL; nX < nUnRotW; nX++ )
+ pMapLX[ nX ] = FRound( (double) pMapIX[ nX ] + pMapFX[ nX ] / 1048576. );
+
+ // create new vertical mapping table
+ for( nY = 0UL; nY < nUnRotH; nY++ )
+ pMapLY[ nY ] = FRound( (double) pMapIY[ nY ] + pMapFY[ nY ] / 1048576. );
+
+ // do mask rotation
+ for( nY = 0; nY < nDstH; nY++ )
+ {
+ nSinY = pSinY[ nY ];
+ nCosY = pCosY[ nY ];
+
+ for( nX = 0; nX < nDstW; nX++ )
+ {
+ nUnRotX = ( pCosX[ nX ] - nSinY ) >> 8;
+ nUnRotY = ( pSinX[ nX ] + nCosY ) >> 8;
+
+ if( ( nUnRotX >= 0L ) && ( nUnRotX < nUnRotW ) &&
+ ( nUnRotY >= 0L ) && ( nUnRotY < nUnRotH ) )
+ {
+ if( pMAcc )
+ {
+ if( pMAcc->GetPixel( pMapLY[ nUnRotY ], pMapLX[ nUnRotX ] ) == aTestB )
+ pWAcc->SetPixel( nY, nX, aB );
+ else
+ pWAcc->SetPixel( nY, nX, aW );
+ }
+ else
+ pWAcc->SetPixel( nY, nX, aB );
+ }
+ else
+ pWAcc->SetPixel( nY, nX, aW );
+ }
+ }
+
+ delete[] pMapLX;
+ delete[] pMapLY;
+
+ if( pMAcc )
+ aMsk.ReleaseAccess( pMAcc );
+
+ bRet = TRUE;
+ }
+
+ aOutMsk.ReleaseAccess( pWAcc );
+ }
+
+ if( bRet )
+ rOutBmpEx = BitmapEx( aOutBmp, aOutMsk );
+ }
+
+ if( !bRet )
+ rOutBmpEx = aOutBmp;
+ }
+ else
+ rOutBmpEx = aOutBmp;
+
+ delete[] pSinX;
+ delete[] pCosX;
+ delete[] pSinY;
+ delete[] pCosY;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicManager::ImplAdjust( BitmapEx& rBmpEx, const GraphicAttr& rAttr, ULONG nAdjustmentFlags )
+{
+ GraphicAttr aAttr( rAttr );
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_DRAWMODE ) && aAttr.IsSpecialDrawMode() )
+ {
+ switch( aAttr.GetDrawMode() )
+ {
+ case( GRAPHICDRAWMODE_MONO ):
+ rBmpEx.Convert( BMP_CONVERSION_1BIT_THRESHOLD );
+ break;
+
+ case( GRAPHICDRAWMODE_GREYS ):
+ rBmpEx.Convert( BMP_CONVERSION_8BIT_GREYS );
+ break;
+
+ case( GRAPHICDRAWMODE_WATERMARK ):
+ {
+ aAttr.SetLuminance( aAttr.GetLuminance() + WATERMARK_LUM_OFFSET );
+ aAttr.SetContrast( aAttr.GetContrast() + WATERMARK_CON_OFFSET );
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_COLORS ) && aAttr.IsAdjusted() )
+ {
+ rBmpEx.Adjust( aAttr.GetLuminance(), aAttr.GetContrast(),
+ aAttr.GetChannelR(), aAttr.GetChannelG(), aAttr.GetChannelB(),
+ aAttr.GetGamma(), aAttr.IsInvert() );
+ }
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_MIRROR ) && aAttr.IsMirrored() )
+ {
+ rBmpEx.Mirror( aAttr.GetMirrorFlags() );
+ }
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_ROTATE ) && aAttr.IsRotated() )
+ {
+ rBmpEx.Rotate( aAttr.GetRotation(), Color( COL_TRANSPARENT ) );
+ }
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_TRANSPARENCY ) && aAttr.IsTransparent() )
+ {
+ AlphaMask aAlpha;
+ BYTE cTrans = aAttr.GetTransparency();
+
+ if( !rBmpEx.IsTransparent() )
+ aAlpha = AlphaMask( rBmpEx.GetSizePixel(), &cTrans );
+ else if( !rBmpEx.IsAlpha() )
+ {
+ aAlpha = rBmpEx.GetMask();
+ aAlpha.Replace( 0, cTrans );
+ }
+ else
+ {
+ aAlpha = rBmpEx.GetAlpha();
+ BitmapWriteAccess* pA = aAlpha.AcquireWriteAccess();
+
+ if( pA )
+ {
+ ULONG nTrans = cTrans, nNewTrans;
+ const long nWidth = pA->Width(), nHeight = pA->Height();
+
+ if( pA->GetScanlineFormat() == BMP_FORMAT_8BIT_PAL )
+ {
+ for( long nY = 0; nY < nHeight; nY++ )
+ {
+ Scanline pAScan = pA->GetScanline( nY );
+
+ for( long nX = 0; nX < nWidth; nX++ )
+ {
+ nNewTrans = nTrans + *pAScan;
+ *pAScan++ = (BYTE) ( ( nNewTrans & 0xffffff00 ) ? 255 : nNewTrans );
+ }
+ }
+ }
+ else
+ {
+ BitmapColor aAlphaValue( 0 );
+
+ for( long nY = 0; nY < nHeight; nY++ )
+ {
+ for( long nX = 0; nX < nWidth; nX++ )
+ {
+ nNewTrans = nTrans + pA->GetPixel( nY, nX ).GetIndex();
+ aAlphaValue.SetIndex( (BYTE) ( ( nNewTrans & 0xffffff00 ) ? 255 : nNewTrans ) );
+ pA->SetPixel( nY, nX, aAlphaValue );
+ }
+ }
+ }
+
+ aAlpha.ReleaseAccess( pA );
+ }
+ }
+
+ rBmpEx = BitmapEx( rBmpEx.GetBitmap(), aAlpha );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicManager::ImplAdjust( GDIMetaFile& rMtf, const GraphicAttr& rAttr, ULONG nAdjustmentFlags )
+{
+ GraphicAttr aAttr( rAttr );
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_DRAWMODE ) && aAttr.IsSpecialDrawMode() )
+ {
+ switch( aAttr.GetDrawMode() )
+ {
+ case( GRAPHICDRAWMODE_MONO ):
+ rMtf.Convert( MTF_CONVERSION_1BIT_THRESHOLD );
+ break;
+
+ case( GRAPHICDRAWMODE_GREYS ):
+ rMtf.Convert( MTF_CONVERSION_8BIT_GREYS );
+ break;
+
+ case( GRAPHICDRAWMODE_WATERMARK ):
+ {
+ aAttr.SetLuminance( aAttr.GetLuminance() + WATERMARK_LUM_OFFSET );
+ aAttr.SetContrast( aAttr.GetContrast() + WATERMARK_CON_OFFSET );
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_COLORS ) && aAttr.IsAdjusted() )
+ {
+ rMtf.Adjust( aAttr.GetLuminance(), aAttr.GetContrast(),
+ aAttr.GetChannelR(), aAttr.GetChannelG(), aAttr.GetChannelB(),
+ aAttr.GetGamma(), aAttr.IsInvert() );
+ }
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_MIRROR ) && aAttr.IsMirrored() )
+ {
+ Size aPrefSize( rMtf.GetPrefSize() );
+ long nMoveX, nMoveY;
+ double fScaleX, fScaleY;
+
+ if( aAttr.GetMirrorFlags() & BMP_MIRROR_HORZ )
+ nMoveX = VOS_ABS( aPrefSize.Width() ) - 1, fScaleX = -1.0;
+ else
+ nMoveX = 0, fScaleX = 1.0;
+
+ if( aAttr.GetMirrorFlags() & BMP_MIRROR_VERT )
+ nMoveY = VOS_ABS( aPrefSize.Height() ) - 1, fScaleY = -1.0;
+ else
+ nMoveY = 0, fScaleY = 1.0;
+
+ rMtf.Scale( fScaleX, fScaleY );
+ rMtf.Move( nMoveX, nMoveY );
+ rMtf.SetPrefSize( aPrefSize );
+ }
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_ROTATE ) && aAttr.IsRotated() )
+ {
+ DBG_ERROR( "Missing implementation: Mtf-Rotation" );
+ }
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_TRANSPARENCY ) && aAttr.IsTransparent() )
+ {
+ DBG_ERROR( "Missing implementation: Mtf-Transparency" );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicManager::ImplAdjust( Animation& rAnimation, const GraphicAttr& rAttr, ULONG nAdjustmentFlags )
+{
+ GraphicAttr aAttr( rAttr );
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_DRAWMODE ) && aAttr.IsSpecialDrawMode() )
+ {
+ switch( aAttr.GetDrawMode() )
+ {
+ case( GRAPHICDRAWMODE_MONO ):
+ rAnimation.Convert( BMP_CONVERSION_1BIT_THRESHOLD );
+ break;
+
+ case( GRAPHICDRAWMODE_GREYS ):
+ rAnimation.Convert( BMP_CONVERSION_8BIT_GREYS );
+ break;
+
+ case( GRAPHICDRAWMODE_WATERMARK ):
+ {
+ aAttr.SetLuminance( aAttr.GetLuminance() + WATERMARK_LUM_OFFSET );
+ aAttr.SetContrast( aAttr.GetContrast() + WATERMARK_CON_OFFSET );
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_COLORS ) && aAttr.IsAdjusted() )
+ {
+ rAnimation.Adjust( aAttr.GetLuminance(), aAttr.GetContrast(),
+ aAttr.GetChannelR(), aAttr.GetChannelG(), aAttr.GetChannelB(),
+ aAttr.GetGamma(), aAttr.IsInvert() );
+ }
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_MIRROR ) && aAttr.IsMirrored() )
+ rAnimation.Mirror( aAttr.GetMirrorFlags() );
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_ROTATE ) && aAttr.IsRotated() )
+ {
+ DBG_ERROR( "Missing implementation: Animation-Rotation" );
+ }
+
+ if( ( nAdjustmentFlags & ADJUSTMENT_TRANSPARENCY ) && aAttr.IsTransparent() )
+ {
+ DBG_ERROR( "Missing implementation: Animation-Transparency" );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const BitmapEx& rBmpEx, const GraphicAttr& rAttr )
+{
+ pOut->DrawBitmapEx( rPt, rSz, rBmpEx );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt, const Size& rSz,
+ const GDIMetaFile& rMtf, const GraphicAttr& rAttr )
+{
+ Point aPt( rPt );
+ Size aSz( rSz );
+
+ if( rAttr.IsMirrored() )
+ {
+ if( rAttr.GetMirrorFlags() & BMP_MIRROR_HORZ )
+ {
+ aPt.X() += aSz.Width() - 1;
+ aSz.Width() = -aSz.Width();
+ }
+
+ if( rAttr.GetMirrorFlags() & BMP_MIRROR_VERT )
+ {
+ aPt.Y() += aSz.Height() - 1;
+ aSz.Height() = -aSz.Height();
+ }
+ }
+
+ pOut->Push( PUSH_CLIPREGION );
+ pOut->IntersectClipRegion( Rectangle( aPt, aSz ) );
+
+ ( (GDIMetaFile&) rMtf ).WindStart();
+ ( (GDIMetaFile&) rMtf ).Play( pOut, aPt, aSz );
+ ( (GDIMetaFile&) rMtf ).WindStart();
+
+ pOut->Pop();
+}
+
diff --git a/goodies/source/graphic/makefile.mk b/goodies/source/graphic/makefile.mk
new file mode 100644
index 000000000000..f4c64d5efa7b
--- /dev/null
+++ b/goodies/source/graphic/makefile.mk
@@ -0,0 +1,95 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:16 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=goodies
+TARGET=graphic
+VERSION=$(UPD)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+.IF "$(GUI)"=="WIN"
+LINKFLAGS=$(LINKFLAGS) /PACKC:32768
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+CXXFILES= \
+ grfattr.cxx \
+ grfmgr.cxx \
+ grfmgr2.cxx \
+ grfcache.cxx
+
+SLOFILES= \
+ $(SLO)$/grfattr.obj \
+ $(SLO)$/grfmgr.obj \
+ $(SLO)$/grfmgr2.obj \
+ $(SLO)$/grfcache.obj
+
+# --- Target -------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/goodies/source/inv/expl.cxx b/goodies/source/inv/expl.cxx
new file mode 100644
index 000000000000..b4ba1e35f1db
--- /dev/null
+++ b/goodies/source/inv/expl.cxx
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * $RCSfile: expl.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "expl.hxx"
+#include "shapes.hxx"
+#include "invader.hrc"
+
+#ifndef _SV_OUTDEV_HXX //autogen
+#include <vcl/outdev.hxx>
+#endif
+
+Explosion::Explosion(ResMgr* pRes) :
+ ExplListe(0,1),
+ pExpl1(0L),
+ pExpl2(0L),
+ pExpl3(0L)
+{
+ pExpl1 = ImplLoadImage( EXPLOS1, pRes );
+ pExpl2 = ImplLoadImage( EXPLOS2, pRes );
+ pExpl3 = ImplLoadImage( EXPLOS3, pRes );
+}
+
+Explosion::~Explosion()
+{
+ delete pExpl1;
+ delete pExpl2;
+ delete pExpl3;
+}
+
+void Explosion::Paint(OutputDevice& rDev)
+{
+ for(long i=0; i<Count(); i++)
+ {
+ switch(GetMode(i))
+ {
+ case EXPL1:
+ rDev.DrawImage(GetPoint(i),*pExpl1);
+ SetMode(i,EXPL2);
+ break;
+ case EXPL2:
+ rDev.DrawImage(GetPoint(i),*pExpl2);
+ SetMode(i,EXPL3);
+ break;
+ case EXPL3:
+ rDev.DrawImage(GetPoint(i),*pExpl3);
+ SetMode(i,EXPL4);
+ break;
+ case EXPL4:
+ rDev.DrawImage(GetPoint(i),*pExpl2);
+ SetMode(i,EXPL5);
+ break;
+ case EXPL5:
+ rDev.DrawImage(GetPoint(i),*pExpl3);
+ SetMode(i,EXPL6);
+ break;
+ case EXPL6:
+ rDev.DrawImage(GetPoint(i),*pExpl2);
+ SetMode(i,EXPL7);
+ break;
+ case EXPL7:
+ rDev.DrawImage(GetPoint(i),*pExpl1);
+ SetMode(i,EXPLNONE);
+ break;
+ case EXPLNONE:
+ SetMode(i,EXPLDEL);
+ break;
+ }
+ }
+
+// RemoveExpl();
+}
+
+BOOL Explosion::RemoveExpl()
+{
+ Expl_Impl* pWork;
+
+ for(long i=Count()-1; i >= 0; i--)
+ {
+ if(GetMode(i) == EXPLDEL)
+ {
+ pWork = GetObject(i);
+ Remove(pWork);
+ delete pWork;
+ }
+ }
+
+ if(Count())
+ return FALSE;
+ else
+ return TRUE;
+}
+
+void Explosion::ClearAll()
+{
+ for(long i=0; i<Count(); i++)
+ delete GetObject(i);
+
+ Clear();
+}
+
+void Explosion::InsertExpl(Point& rPoint)
+{
+ Expl_Impl* pWork = new Expl_Impl();
+
+ pWork->aPos = rPoint;
+ pWork->eMode = EXPL1;
+ Insert(pWork);
+}
diff --git a/goodies/source/inv/expl.hxx b/goodies/source/inv/expl.hxx
new file mode 100644
index 000000000000..d60ce10b82dd
--- /dev/null
+++ b/goodies/source/inv/expl.hxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * $RCSfile: expl.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _EXPL_HXX
+#define _EXPL_HXX
+
+
+#ifndef _SV_IMAGE_HXX //autogen
+#include <vcl/image.hxx>
+#endif
+#ifndef _SV_OUTDEV_HXX //autogen
+#include <vcl/outdev.hxx>
+#endif
+#ifndef _LIST_HXX //autogen
+#include <tools/list.hxx>
+#endif
+#ifndef _GEN_HXX //autogen
+#include <tools/gen.hxx>
+#endif
+
+enum ExplMode { EXPL1, EXPL2, EXPL3, EXPL4, EXPL5, EXPL6, EXPL7, EXPL8,
+ EXPLNONE, EXPLDEL };
+
+struct Expl_Impl
+{
+ Point aPos;
+ ExplMode eMode;
+};
+
+DECLARE_LIST(ExplListe, Expl_Impl*);
+
+class Explosion : public ExplListe
+{
+ private:
+ Image* pExpl1;
+ Image* pExpl2;
+ Image* pExpl3;
+
+ public:
+ Explosion(ResMgr* pRes);
+ ~Explosion();
+
+ void Paint(OutputDevice& rDev);
+ ExplMode GetMode(long nWert) { return GetObject(nWert)->eMode; }
+ Point& GetPoint(long nWert) { return GetObject(nWert)->aPos; }
+ void SetMode(long nWert, enum ExplMode nMode)
+ { GetObject(nWert)->eMode = nMode; }
+ BOOL RemoveExpl();
+ void ClearAll();
+ void InsertExpl(Point& rPoint);
+};
+
+#endif
diff --git a/goodies/source/inv/gegner.src b/goodies/source/inv/gegner.src
new file mode 100644
index 000000000000..4581c03a7133
--- /dev/null
+++ b/goodies/source/inv/gegner.src
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * $RCSfile: gegner.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "invader.hrc"
+
+Bitmap MONSTER1 {
+ File = "monster1.bmp";
+};
+
+Bitmap MONSTER2 {
+ File = "monster2.bmp";
+};
+
+Bitmap MONSTER3 {
+ File = "monster3.bmp";
+};
+
+Bitmap MONSTER4 {
+ File = "monster4.bmp";
+};
+
+Bitmap MONSTER1B {
+ File = "monstb1.bmp";
+};
+
+Bitmap MONSTER2B {
+ File = "monstb2.bmp";
+};
+
+Bitmap MONSTER3B {
+ File = "monstb3.bmp";
+};
+
+Bitmap MONSTER4B {
+ File = "monstb4.bmp";
+};
+
+Bitmap MONSTER5 {
+ File = "uvisibl1.bmp";
+};
+
+Bitmap MONSTER5A {
+ File = "uvisibl2.bmp";
+};
+
+Bitmap MONSTER5B {
+ File = "uvisibl3.bmp";
+};
+
+Bitmap FIGHTER1 {
+ File = "fighter1.bmp";
+};
+
+Bitmap FIGHTERR {
+ File = "fighterr.bmp";
+};
+
+Bitmap FIGHTERL {
+ File = "fighterl.bmp";
+};
+
+Bitmap MUNITION1 {
+ File = "monitio1.bmp";
+};
+
+Bitmap MUNITION2 {
+ File = "monitio2.bmp";
+};
+
+Bitmap EXPLOS1 {
+ File = "explos1.bmp";
+};
+
+Bitmap EXPLOS2 {
+ File = "explos2.bmp";
+};
+
+Bitmap EXPLOS3 {
+ File = "explos3.bmp";
+};
+
+Bitmap BOMBE {
+ File = "bombe.bmp";
+};
+
+Bitmap WALL1 {
+ File = "wall1.bmp";
+};
+
+Bitmap WALL2 {
+ File = "wall2.bmp";
+};
+
+Bitmap WALL3 {
+ File = "wall3.bmp";
+};
+
+Bitmap WALL4 {
+ File = "wall4.bmp";
+};
+
+Bitmap WALL5 {
+ File = "wall5.bmp";
+};
+
+Bitmap WALL6 {
+ File = "wall6.bmp";
+};
+
+Bitmap WALL7 {
+ File = "wall7.bmp";
+};
+
+Bitmap WALL8 {
+ File = "wall8.bmp";
+};
+
+Bitmap WALL9 {
+ File = "wall9.bmp";
+};
+
+Bitmap WALL10 {
+ File = "wall10.bmp";
+};
+
+Bitmap HEROS {
+ File = "helden.bmp";
+};
+
+Bitmap STARWARS {
+ File = "swars.bmp";
+};
+
+Bitmap WELCOME2 {
+ File = "wlcome2.bmp";
+};
+
diff --git a/goodies/source/inv/invader.cxx b/goodies/source/inv/invader.cxx
new file mode 100644
index 000000000000..9d8bb7035624
--- /dev/null
+++ b/goodies/source/inv/invader.cxx
@@ -0,0 +1,637 @@
+/*************************************************************************
+ *
+ * $RCSfile: invader.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "invader.hxx"
+#include "monst.hxx"
+#include "shapes.hxx"
+#include "expl.hxx"
+#include "invader.hrc"
+#include "strings.hrc"
+#include "score.hxx"
+
+#ifndef _SV_MSGBOX_HXX //autogen
+#include <vcl/msgbox.hxx>
+#endif
+
+#ifndef _SV_VIRDEV_HXX //autogen
+#include <vcl/virdev.hxx>
+#endif
+
+MyWindow::MyWindow(Window* pParent, ResMgr *pRes ) :
+ FloatingWindow(pParent, WB_SVLOOK | WB_CLOSEABLE | WB_MOVEABLE ),
+ pRes(pRes),
+ pGegner(0L),
+ pFighter(0L),
+ pMunition(0L),
+ pExplosion(0L),
+ pBombe(0L),
+ pWall(0L),
+ pVirtualDevice(0L),
+ pBitHeros(0L),
+ pBitStarWars(0L),
+ pBitWelcome2(0L),
+ pScoreWindow(0L),
+ pPauseWindow(0L),
+ pBox(0L),
+ ProgStatus(FALSE),
+ StartPhase(1),
+ nLevel(1),
+ nScore(0L),
+ nHighScore(0L),
+ nFighter(3),
+ nAuseCount(0),
+ bEndLevel(TRUE),
+ bFightDest(FALSE),
+ nTimeOut(TIMEHIGH),
+ bTimeHigh(TRUE),
+ bAuseModus(FALSE),
+ bPause(FALSE),
+ nDirection(0L),
+ bMouseMooving(FALSE),
+ bWaitDlg(FALSE)
+{
+ pBitWelcome2 = ImplLoadImage( WELCOME2, GetResMgr() );
+ pBitHeros = ImplLoadImage( HEROS, GetResMgr() );
+ pBitStarWars = ImplLoadImage( STARWARS, GetResMgr() );
+ pBombe = new Bombe(GetResMgr());
+ pMunition = new Munition(GetResMgr());
+ pExplosion = new Explosion(GetResMgr());
+ pWall = new Wall(GetResMgr());
+ pScoreWindow = new ScoreWindow(this,WB_BORDER, GetResMgr());
+ pPauseWindow = new Window(this, 0);
+
+ SetOutputSizePixel(Size(WINWIDTH,WINHEIGHT));
+ SetText(String(ResId(STR_APP_TITLE,GetResMgr())));
+
+ pPauseWindow->SetPosSizePixel(Point(100,190),Size(500,50));
+ pPauseWindow->SetBackground();
+
+ pScoreWindow->SetPosSizePixel(Point(0,0),Size(WINWIDTH,22));
+ Size aSize(WINWIDTH,WINHEIGHT);
+ pFighter = new Fighter(aSize,GetResMgr());
+ pGegner = new Gegner(pFighter, pBombe, GetResMgr());
+
+ pVirtualDevice = new VirtualDevice(*this);
+ pVirtualDevice->SetOutputSizePixel(Size( WINWIDTH, WINHEIGHT ));
+
+ SetBackground();
+
+ aPaintTimer = Timer();
+ aPaintTimer.SetTimeoutHdl(LINK(this, MyWindow, PaintTimer));
+ aPaintTimer.SetTimeout(nTimeOut);
+ aPaintTimer.Stop();
+
+ aWaitDlgTimer = Timer();
+ aWaitDlgTimer.SetTimeoutHdl(LINK(this, MyWindow, StartDlgTimer));
+ aWaitDlgTimer.SetTimeout(10);
+ aWaitDlgTimer.Stop();
+
+ aPointer = GetPointer();
+
+ Show();
+
+}
+
+MyWindow::~MyWindow()
+{
+ aPaintTimer.Stop();
+ delete pVirtualDevice;
+ delete pGegner;
+ delete pFighter;
+ delete pMunition;
+ delete pExplosion;
+ delete pBombe;
+ delete pWall;
+ delete pBitHeros;
+ delete pBitStarWars;
+ delete pBitWelcome2;
+ delete pScoreWindow;
+ delete pPauseWindow;
+
+ delete pRes;
+}
+
+void MyWindow::Paint(const Rectangle& rRect)
+{
+ if(bWaitDlg)
+ return;
+
+ Size aVSize = pVirtualDevice->GetOutputSizePixel();
+
+ if (!ProgStatus)
+ {
+ if (StartPhase < 3)
+ {
+ pScoreWindow->Hide();
+ bMouseMooving = FALSE;
+
+ if( StartPhase == 1 )
+ {
+ const Font aOldFont( GetFont() );
+ Font aFont( aOldFont );
+
+ SetFillColor( COL_BLACK );
+ DrawRect(Rectangle(Point(0,0),Point(640,480)));
+
+ DrawImage(Point(55,78), *pBitStarWars);
+ DrawImage(Point(53,207), *pBitHeros);
+ DrawImage(Point(470,400), *(pFighter->pFight1));
+ DrawImage(Point(460,290), *(pMunition->pMunition1));
+ DrawImage(Point(480,320), *(pMunition->pMunition1));
+ DrawImage(Point(470,250), *(pMunition->pMunition1));
+
+ aFont.SetColor(COL_WHITE);
+ aFont.SetFillColor(COL_BLACK);
+ SetFont( aFont );
+
+ DrawText(Point(175,170),String(ResId(STR_CHOOSEHERO, GetResMgr())));
+ DrawText(Point(98,208),String(ResId(STR_NAME1,GetResMgr())));
+ DrawText(Point(98,252),String(ResId(STR_NAME2, GetResMgr())));
+ DrawText(Point(98,296),String(ResId(STR_NAME3, GetResMgr())));
+ DrawText(Point(98,340),String(ResId(STR_NAME4, GetResMgr())));
+ DrawText(Point(98,384),String(ResId(STR_NAME5, GetResMgr())));
+
+ SetFont( aOldFont );
+ }
+ else if(StartPhase == 2)
+ {
+ SetFillColor( COL_WHITE );
+ DrawRect(Rectangle(Point(0,0),Point(640,480)));
+ DrawImage(Point(19,147), *pBitWelcome2 );
+ }
+ }
+ }
+ else if(!bPause)
+ {
+ aPaintTimer.Start();
+
+ Point aPoint(0,20);
+
+ pVirtualDevice->SetFillColor( COL_WHITE );
+ pVirtualDevice->SetPen(PEN_NULL);
+ pVirtualDevice->DrawRect(Rectangle(Point(0,0), Point(aVSize.Width(),aVSize.Height())));
+
+ if(!bStartLevel)
+ {
+ if ((bMouseMooving)&&(nDirection > pFighter->GetPoint().X()+32))
+ {
+ pFighter->Move(1);
+ pFighter->Move(1);
+ pGegner->SetAuseMode(FALSE);
+ nAuseCount = 0;
+ }
+ else if ((bMouseMooving)&&(nDirection < pFighter->GetPoint().X()))
+ {
+ pFighter->Move(-1);
+ pFighter->Move(-1);
+ pGegner->SetAuseMode(FALSE);
+ nAuseCount = 0;
+ }
+ nAuseCount++;
+ if(nAuseCount > AUSEMODE)
+ pGegner->SetAuseMode(TRUE);
+ pWall->Paint(*pVirtualDevice);
+ pGegner->DrawGegner(pVirtualDevice,&aPoint);
+ pFighter->Paint(*pVirtualDevice);
+ pMunition->Paint(*pVirtualDevice);
+ pBombe->Paint(*pVirtualDevice);
+ pExplosion->Paint(*pVirtualDevice);
+ }
+ else
+ {
+ bMouseMooving = FALSE;
+ Font aOldFont = pVirtualDevice->GetFont();
+ Font aFont = aOldFont;
+ switch(nStartLevel)
+ {
+ case 0:
+ aFont.SetColor(COL_RED);
+ break;
+ case 1:
+ aFont.SetColor(COL_YELLOW);
+ break;
+ case 2:
+ aFont.SetColor(COL_GREEN);
+ break;
+ }
+ pVirtualDevice->SetFont(*&aFont);
+ String aString = String(ResId(STR_LEVELSTART, GetResMgr()));
+ aString += String(" ");
+ aString += String(nLevel);
+ if(nStartLevel < 3)
+ pVirtualDevice->DrawText(Point(LEVELTEXTX,LEVELTEXTY),aString);
+ nStartLevel++;
+ if(nStartLevel > 3)
+ {
+ bStartLevel = FALSE;
+ bEndLevel = FALSE;
+ bFightDest = FALSE;
+ aPaintTimer.SetTimeout(nTimeOut);
+ }
+ pVirtualDevice->SetFont(*&aOldFont);
+
+ }
+
+ DrawOutDev( Point( 0, 22), aVSize, Point( 0, 22), aVSize, *pVirtualDevice);
+
+ if(!bStartLevel)
+ Kollision();
+ }
+ else pPauseWindow->DrawText(Point(20,20),String(ResId(STR_PAUSE, GetResMgr())));
+}
+
+void MyWindow::KeyInput( const KeyEvent& rKEvent)
+{
+ if(bEndLevel || bFightDest)
+ {
+ rKEvent.GetKeyCode().GetCode();
+ FloatingWindow::KeyInput(rKEvent);
+
+ return;
+ }
+
+ bMouseMooving = FALSE;
+ switch(rKEvent.GetKeyCode().GetCode())
+ {
+ case KEY_LEFT:
+ pFighter->Move(-1);
+ nAuseCount = 0;
+ pGegner->SetAuseMode(FALSE);
+ break;
+ case KEY_RIGHT:
+ pFighter->Move(1);
+ nAuseCount = 0;
+ pGegner->SetAuseMode(FALSE);
+ break;
+ case KEY_SPACE:
+ pMunition->Start(pFighter->GetPoint());
+ break;
+ case KEY_L:
+ if(nLevel > 1)
+ return;
+ if(bTimeHigh)
+ {
+ bTimeHigh = FALSE;
+ nTimeOut = TIMELOW;
+ }
+ else
+ {
+ bTimeHigh = TRUE;
+ nTimeOut = TIMEHIGH;
+ }
+ aPaintTimer.SetTimeout(nTimeOut);
+ break;
+ case KEY_ADD:
+ if(nLevel > 1)
+ return;
+ nTimeOut++;
+ aPaintTimer.SetTimeout(nTimeOut);
+ break;
+ case KEY_SUBTRACT:
+ if(nLevel > 1)
+ return;
+ nTimeOut--;
+ if(nTimeOut <= 0)
+ nTimeOut = 1;
+ aPaintTimer.SetTimeout(nTimeOut);
+ aPaintTimer.Start();
+ break;
+ case KEY_P:
+ if(!ProgStatus)
+ return;
+ if(bPause)
+ {
+ aPaintTimer.Start();
+ bPause = FALSE;
+ SetBackground();
+ pPauseWindow->Hide();
+ }
+ else
+ {
+ aPaintTimer.Stop();
+ bPause = TRUE;
+ SetBackground( Wallpaper( COL_WHITE ) );
+ pPauseWindow->Show();
+ pPauseWindow->DrawText(Point(20,20),String(ResId(STR_PAUSE, GetResMgr())));
+ }
+ break;
+ default:
+ FloatingWindow::KeyInput(rKEvent);
+ }
+}
+
+IMPL_LINK( MyWindow, PaintTimer, Timer*, EMPTY_ARG)
+{
+
+ Invalidate();
+
+ return 0;
+}
+
+IMPL_LINK( MyWindow, StartDlgTimer, Timer*, EMPTY_ARG )
+{
+ bWaitDlg = TRUE;
+
+ aWaitDlgTimer.Stop();
+
+ String aString;
+ if(!bFightDest)
+ {
+ aString = String(ResId(STR_GRAT1,GetResMgr()));
+ aString += String(nLevel);
+ aString += String(ResId(STR_GRAT2,GetResMgr()));
+
+ pBox = new MessBox(this,WinBits(WB_OK),String(ResId(STR_APP_TITLE,GetResMgr())),aString);
+ PlaceDialog(pBox);
+ ProgStatus=FALSE;
+ SetBackgroundBrush(Brush(COL_WHITE,BRUSH_SOLID));
+
+ pBox->Execute();
+
+ SetBackgroundBrush(BRUSH_NULL);
+ ProgStatus=TRUE;
+ delete pBox;
+ nLevel++;
+ GrabFocus();
+ }
+ else
+ {
+ nFighter--;
+ pScoreWindow->SetLives(nFighter);
+ if(nFighter > 0)
+ {
+ aString = String(ResId(STR_FIGHTDEST1,GetResMgr()));
+ aString += String(nFighter);
+ aString += String(ResId(STR_FIGHTDEST2,GetResMgr()));
+ }
+ else
+ {
+ aString = String(ResId(STR_GAMEOVER,GetResMgr()));
+ ProgStatus = FALSE;
+ nLevel = 1;
+ nFighter = 3;
+ pGegner->SetRandWert(200);
+ pGegner->SetDown(10);
+
+ if(bTimeHigh)
+ nTimeOut = TIMEHIGH;
+ else
+ nTimeOut = TIMELOW;
+ }
+
+ pBox = new MessBox(this,WinBits(WB_OK),String(ResId(STR_APP_TITLE,GetResMgr())),aString);
+ PlaceDialog(pBox);
+ BOOL aDummyStatus = ProgStatus;
+ ProgStatus=FALSE;
+ SetBackgroundBrush(Brush(COL_WHITE,BRUSH_SOLID));
+
+ pBox->Execute();
+
+ SetBackgroundBrush(BRUSH_NULL);
+ ProgStatus=aDummyStatus;
+ delete pBox;
+ GrabFocus();
+
+ if(!ProgStatus)
+ {
+ StartPhase = 1;
+ if (nScore > nHighScore)
+ {
+ String aString;
+ aString = String(ResId(STR_HIGHSCORE1,GetResMgr()));
+ aString += String(nScore);
+ aString += String(ResId(STR_HIGHSCORE2,GetResMgr()));
+ aString += String(nHighScore);
+ aString += String(ResId(STR_HIGHSCORE3,GetResMgr()));
+ nHighScore = nScore;
+ pBox = new MessBox(this,WinBits(WB_OK),String(ResId(STR_APP_TITLE,GetResMgr())),aString);
+ PlaceDialog(pBox);
+ Paint(Rectangle(Point(0,0),Point(640,480)));
+ SetBackgroundBrush(Brush(COL_WHITE,BRUSH_SOLID));
+ pBox->Execute();
+ SetBackgroundBrush(BRUSH_NULL);
+ delete pBox;
+ GrabFocus();
+ }
+ nScore = 0;
+ }
+
+ }
+
+ InitLevel();
+ Invalidate();
+
+ bWaitDlg = FALSE;
+
+ return 0;
+}
+
+void MyWindow::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ MessBox* pMessBox = 0L;
+
+ if (!ProgStatus)
+ {
+ TheHero = 0;
+
+ if (StartPhase == 1)
+ {
+ if ((rMEvt.GetPosPixel().X() >= 57) && (rMEvt.GetPosPixel().X() <=90))
+ {
+ if ((rMEvt.GetPosPixel().Y() >= 211) && (rMEvt.GetPosPixel().Y() <= 244))
+ TheHero = STR_NAME1;
+ else if ((rMEvt.GetPosPixel().Y() >= 255) && (rMEvt.GetPosPixel().Y() <= 288))
+ TheHero = STR_NAME2;
+ else if ((rMEvt.GetPosPixel().Y() >= 299) && (rMEvt.GetPosPixel().Y() <= 332))
+ TheHero = STR_NAME3;
+ else if ((rMEvt.GetPosPixel().Y() >= 343) && (rMEvt.GetPosPixel().Y() <= 376))
+ TheHero = STR_NAME4;
+ else if ((rMEvt.GetPosPixel().Y() >= 387) && (rMEvt.GetPosPixel().Y() <= 420))
+ TheHero = STR_NAME5;
+ }
+ if (TheHero)
+ {
+ SetPointer(aPointer);
+ switch (TheHero)
+ {
+ case STR_NAME1:
+ {
+ pMessBox = new MessBox(this,WinBits(WB_OK),String(ResId(STR_APP_TITLE,GetResMgr())),String(ResId(STR_HERO1, GetResMgr())));
+ }
+ break;
+ case STR_NAME2:
+ {
+ pMessBox = new MessBox(this,WinBits(WB_OK),String(ResId(STR_APP_TITLE,GetResMgr())), String(ResId(STR_HERO2, GetResMgr())));
+ }
+ break;
+ case STR_NAME3:
+ {
+ pMessBox = new MessBox(this,WinBits(WB_OK),String(ResId(STR_APP_TITLE,GetResMgr())), String(ResId(STR_HERO3, GetResMgr())));
+ }
+ break;
+ case STR_NAME4:
+ {
+ pMessBox = new MessBox(this,WinBits(WB_OK),String(ResId(STR_APP_TITLE,GetResMgr())), String(ResId(STR_HERO4,GetResMgr())));
+ }
+ break;
+ case STR_NAME5:
+ {
+ pMessBox = new MessBox(this,WinBits(WB_OK),String(ResId(STR_APP_TITLE,GetResMgr())), String(ResId(STR_HERO5,GetResMgr())));
+ }
+ break;
+ }
+ PlaceDialog(pMessBox);
+ pMessBox->Execute();
+ delete pMessBox;
+ StartPhase++;
+ pScoreWindow->SetHero(TheHero);
+ Invalidate();
+ }
+ }
+ else if (StartPhase == 2)
+ {
+ ProgStatus = TRUE;
+ StartPhase++;
+ pScoreWindow->Show();
+ InitLevel();
+ Invalidate();
+ aPaintTimer.Start();
+ }
+ }
+ else
+ {
+ if((!bStartLevel) && (!bPause))
+ pMunition->Start(pFighter->GetPoint());
+ }
+}
+
+void MyWindow::MouseMove(const MouseEvent& rMEvt)
+{
+ long TheHero;
+
+ if ((!ProgStatus) && ( StartPhase == 1 ))
+ {
+ TheHero = 0;
+ if ((rMEvt.GetPosPixel().X() >= 57) && (rMEvt.GetPosPixel().X() <=90))
+ {
+ if ((rMEvt.GetPosPixel().Y() >= 211) && (rMEvt.GetPosPixel().Y() <= 244))
+ TheHero = 1;
+ else if ((rMEvt.GetPosPixel().Y() >= 255) && (rMEvt.GetPosPixel().Y() <= 288))
+ TheHero = 2;
+ else if ((rMEvt.GetPosPixel().Y() >= 299) && (rMEvt.GetPosPixel().Y() <= 332))
+ TheHero = 3;
+ else if ((rMEvt.GetPosPixel().Y() >= 343) && (rMEvt.GetPosPixel().Y() <= 376))
+ TheHero = 4;
+ else if ((rMEvt.GetPosPixel().Y() >= 387) && (rMEvt.GetPosPixel().Y() <= 420))
+ TheHero = 5;
+ }
+ if ((TheHero) && (GetPointer() != POINTER_REFHAND)) SetPointer(POINTER_REFHAND);
+ else if ((!TheHero) && (GetPointer() != aPointer)) SetPointer(aPointer);
+ }
+ else if ( ProgStatus )
+ {
+ nDirection = rMEvt.GetPosPixel().X();
+ bMouseMooving = TRUE;
+ }
+}
+
+BOOL MyWindow::Close()
+{
+ Hide();
+ delete this;
+ return TRUE;
+}
+
+void MyWindow::PlaceDialog(MessBox* pBox)
+{
+ Point aPos = GetPosPixel();
+ Size aSize = GetSizePixel();
+ Size aBoxSize = pBox->GetOutputSizePixel();
+ aSize = Size(aSize.Width()/2 - aBoxSize.Width()/2,
+ aSize.Height()/2 - aBoxSize.Height()/2);
+
+
+ if(pBox)
+ pBox->SetPosPixel(
+ Point(aPos.X()+aSize.Width(),aPos.Y()+aSize.Height()));
+}
+
+#ifdef TEST
+void MyApp::Main(int,char*[])
+{
+ MyWindow aWindow( NULL, (ResMgr*)NULL);
+
+ Execute();
+}
+
+MyApp aMyApp;
+#else
+
+#ifdef WNT
+extern "C" void __cdecl StartInvader(Window* pParent , ResMgr* pRes)
+#else
+extern "C" void StartInvader(Window* pParent, ResMgr* pRes )
+#endif
+{
+ MyWindow *pInvaderWin = new MyWindow(pParent, pRes);
+ pInvaderWin->Show();
+}
+#endif
+
diff --git a/goodies/source/inv/invader.hrc b/goodies/source/inv/invader.hrc
new file mode 100644
index 000000000000..f91f162f9424
--- /dev/null
+++ b/goodies/source/inv/invader.hrc
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * $RCSfile: invader.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#define MONSTER1 17000
+#define MONSTER2 17001
+#define MONSTER3 17002
+#define MONSTER4 17003
+#define FIGHTERR 17004
+#define FIGHTERL 17005
+#define FIGHTER1 17006
+#define MUNITION1 17007
+#define MUNITION2 17008
+#define MONSTER1B 17009
+#define MONSTER2B 17010
+#define MONSTER3B 17011
+#define MONSTER4B 17012
+#define EXPLOS1 17013
+#define EXPLOS2 17014
+#define EXPLOS3 17015
+#define BOMBE 17016
+#define WALL1 17017
+#define WALL2 17018
+#define WALL3 17019
+#define WALL4 17020
+#define WALL5 17021
+#define WALL6 17022
+#define WALL7 17023
+#define WALL8 17024
+#define WALL9 17025
+#define WALL10 17026
+#define WELCOME 17027
+#define WELCOME2 17028
+#define MONSTER5 17029
+#define MONSTER5A 17030
+#define MONSTER5B 17031
+#define HEROS 17032
+#define STARWARS 17033
diff --git a/goodies/source/inv/invader.hxx b/goodies/source/inv/invader.hxx
new file mode 100644
index 000000000000..8cac0f306d6e
--- /dev/null
+++ b/goodies/source/inv/invader.hxx
@@ -0,0 +1,173 @@
+/*************************************************************************
+ *
+ * $RCSfile: invader.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _INVADER_HXX
+#define _INVADER_HXX
+
+#define WINWIDTH 640
+#define WINHEIGHT 480
+#define LEVELTEXTX 280
+#define LEVELTEXTY 200
+
+#define TIMEHIGH 100
+#define TIMELOW 30
+#define AUSEMODE 50
+
+#ifndef _SV_TIMER_HXX //autogen
+#include <vcl/timer.hxx>
+#endif
+#ifndef _SV_FLOATWIN_HXX //autogen
+#include <vcl/floatwin.hxx>
+#endif
+#ifndef _TOOLS_RESMGR_HXX //autogen
+#include <tools/resmgr.hxx>
+#endif
+#ifndef _SV_IMAGE_HXX //autogen
+#include <vcl/image.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+
+
+class Gegner;
+class Fighter;
+class Munition;
+class Explosion;
+class Bombe;
+class Wall;
+class ScoreWindow;
+class MessBox;
+
+class MyApp : public Application
+{
+ public:
+ virtual void Main(int,char*[]);
+};
+
+class MyWindow : public FloatingWindow
+{
+ private:
+ ResMgr* pRes;
+ BOOL ProgStatus;
+ BOOL bStartLevel;
+ BOOL bEndLevel;
+ BOOL bFightDest;
+ BOOL bTimeHigh;
+ BOOL bPause;
+ BOOL bAuseModus;
+ BOOL bGetFighter;
+ BOOL bWaitDlg;
+
+ long nStartLevel;
+ long StartPhase;
+ Pointer aPointer;
+ long nLevel;
+ long nScore;
+ long nHighScore;
+ long TheHero;
+ long nFighter;
+ long nTimeOut;
+ long nAuseCount;
+
+ Image* pBitWelcome2;
+ Image* pBitHeros;
+ Image* pBitStarWars;
+ Gegner* pGegner;
+ Fighter* pFighter;
+ Munition* pMunition;
+ Explosion* pExplosion;
+ Bombe* pBombe;
+ Wall* pWall;
+ Timer aPaintTimer;
+ Timer aWaitDlgTimer;
+ ScoreWindow* pScoreWindow;
+ VirtualDevice* pVirtualDevice;
+ Window* pPauseWindow;
+ MessBox* pBox;
+
+ void Init();
+ DECL_LINK( PaintTimer, Timer*);
+ DECL_LINK( StartDlgTimer, Timer* );
+
+ void InitLevel();
+ void RandomLevel();
+
+ long nDirection;
+ BOOL bMouseMooving;
+ void PlaceDialog(MessBox* pBox);
+
+ public:
+ MyWindow(Window* pParent, ResMgr* pRes);
+ ~MyWindow();
+
+ virtual void Paint(const Rectangle& rRect);
+ virtual void KeyInput( const KeyEvent& rKEvent);
+ virtual void MouseButtonDown(const MouseEvent& rMEvt);
+// virtual void MouseButtonUp(const MouseEvent& rMEvt);
+ virtual void MouseMove(const MouseEvent& rMEvt);
+ virtual BOOL Close();
+
+ void EndLevel();
+ void Kollision();
+ ResMgr* GetResMgr(){return pRes;}
+};
+
+#endif
diff --git a/goodies/source/inv/invader1.cxx b/goodies/source/inv/invader1.cxx
new file mode 100644
index 000000000000..d0ba80e8a97f
--- /dev/null
+++ b/goodies/source/inv/invader1.cxx
@@ -0,0 +1,476 @@
+/*************************************************************************
+ *
+ * $RCSfile: invader1.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <stdlib.h>
+
+#ifndef _SV_MSGBOX_HXX //autogen
+#include <vcl/msgbox.hxx>
+#endif
+
+#include "invader.hxx"
+#include "monst.hxx"
+#include "shapes.hxx"
+#include "expl.hxx"
+#include "waves.hxx"
+#include "score.hxx"
+#include "strings.hrc"
+
+
+void MyWindow::Kollision()
+{
+ Rectangle aRect;
+ long nStart = nScore;
+ long nRockets = pMunition->Count();
+
+ long nWert;
+
+ long i;
+ for(i=0; i<pBombe->Count(); i++)
+ {
+ //Kollision Bombe->Mauer prfen
+ aRect = pBombe->GetKoll(i);
+ if(pWall->Kollision(aRect,FALSE))
+ pBombe->SetDelete(i);
+ //Kollision Bombe->Fighter prfen
+ if(pFighter->Kollision(pBombe->GetKoll(i),pExplosion))
+ {
+ bFightDest = TRUE;
+ pBombe->SetDelete(i);
+ }
+ }
+
+ for(i=0; i<pMunition->Count(); i++)
+ {
+ //Kollision Muniton->Gegner prfen
+ aRect = pMunition->GetKoll(i);
+ nWert = pGegner->Kollision(aRect,pExplosion);
+ if(nWert != -1)
+ {
+ nScore += nWert;
+ pMunition->SetDelete(i);
+ }
+ //Kollision Muniton->Mauer prfen
+ aRect = pMunition->GetKoll(i);
+ if(pWall->Kollision(aRect,FALSE))
+ pMunition->SetDelete(i);
+
+ //Kollision Munition->Bombe prfen
+ aRect = pMunition->GetKoll(i);
+ if(pBombe->Kollision(aRect,pExplosion))
+ pMunition->SetDelete(i);
+ }
+
+ for(i=0; i<pGegner->Count();i++)
+ {
+
+ //Kollision Gegner->Mauer prfen
+ aRect = pGegner->GetKoll(i);
+ pWall->Kollision(aRect,TRUE);
+ //Kollision Gegner->Fighter prfen
+ aRect = pGegner->GetKoll(i);
+ if(pFighter->Kollision(aRect,pExplosion))
+ {
+ bFightDest = TRUE;
+ pGegner->ClearAll();
+ pBombe->ClearAll();
+ }
+
+ }
+
+ pBombe->RemoveBomben();
+ nWert = pMunition->RemoveMunition();
+ if( nWert != nRockets)
+ pScoreWindow->SetRockets(nWert);
+
+ if(nScore > nStart)
+ pScoreWindow->SetScore(nScore);
+
+ if(pGegner->RemoveGegner())
+ {
+ bEndLevel = TRUE;
+ pBombe->ClearAll();
+ pMunition->ClearAll();
+ }
+
+ if(bFightDest)
+ {
+ pBombe->ClearAll();
+ pMunition->ClearAll();
+ pGegner->ClearAll();
+ }
+
+ if(pExplosion->RemoveExpl() && (bEndLevel || bFightDest))
+ {
+ if(!bWaitDlg)
+ aWaitDlgTimer.Start();
+
+ /*String aString;
+ if(!bFightDest)
+ {
+ aString = String(ResId(STR_GRAT1,GetResMgr()));
+ aString += String(nLevel);
+ aString += String(ResId(STR_GRAT2,GetResMgr()));
+
+ if(!pBox)
+ {
+ bWaitDlg = TRUE;
+ pBox = new MessBox(GetParent(),WinBits(WB_OK),String(ResId(STR_APP_TITLE,GetResMgr())),aString);
+ ProgStatus=FALSE;
+ SetBackgroundBrush(Brush(COL_WHITE,BRUSH_SOLID));
+
+ aWaitDlgTimer.Start();
+ return;
+ }
+
+ SetBackgroundBrush(BRUSH_NULL);
+ ProgStatus=TRUE;
+ delete pBox;
+ pBox = 0L;
+ nLevel++;
+ GrabFocus();
+ }
+ else
+ {
+ nFighter--;
+ pScoreWindow->SetLives(nFighter);
+ if(nFighter > 0)
+ {
+ aString = String(ResId(STR_FIGHTDEST1,GetResMgr()));
+ aString += String(nFighter);
+ aString += String(ResId(STR_FIGHTDEST2,GetResMgr()));
+ }
+ else
+ {
+ aString = String(ResId(STR_GAMEOVER,GetResMgr()));
+ }
+
+ BOOL aDummyStatus;
+
+ if(!pBox)
+ {
+ pBox = new MessBox(this,WinBits(WB_OK),String(ResId(STR_APP_TITLE,GetResMgr())),aString);
+ aDummyStatus = ProgStatus;
+ //ProgStatus=FALSE;
+ SetBackgroundBrush(Brush(COL_WHITE,BRUSH_SOLID));
+
+ aWaitDlgTimer.Start();
+
+ return;
+ }
+
+ if(nFighter == 0)
+ {
+ ProgStatus = FALSE;
+ nLevel = 1;
+ nFighter = 3;
+ pGegner->SetRandWert(200);
+ pGegner->SetDown(10);
+
+ if(bTimeHigh)
+ nTimeOut = TIMEHIGH;
+ else
+ nTimeOut = TIMELOW;
+ }
+
+ SetBackgroundBrush(BRUSH_NULL);
+ //ProgStatus=aDummyStatus;
+ delete pBox;
+ pBox = 0L;
+ GrabFocus();
+
+ if(!ProgStatus)
+ {
+ StartPhase = 1;
+ if (nScore > nHighScore)
+ {
+ String aString;
+ aString = String(ResId(STR_HIGHSCORE1,GetResMgr()));
+ aString += String(nScore);
+ aString += String(ResId(STR_HIGHSCORE2,GetResMgr()));
+ aString += String(nHighScore);
+ aString += String(ResId(STR_HIGHSCORE3,GetResMgr()));
+ nHighScore = nScore;
+ if(!pBox)
+ {
+ pBox = new MessBox(this,WinBits(WB_OK),String(ResId(STR_APP_TITLE,GetResMgr())),aString);
+ Paint(Rectangle(Point(0,0),Point(640,480)));
+ SetBackgroundBrush(Brush(COL_WHITE,BRUSH_SOLID));
+
+ aWaitDlgTimer.Start();
+ }
+
+ SetBackgroundBrush(BRUSH_NULL);
+ delete pBox;
+ pBox = 0L;
+ GrabFocus();
+ }
+ nScore = 0;
+ }
+
+ }
+
+ InitLevel();*/
+ }
+}
+
+void MyWindow::InitLevel()
+{
+ bStartLevel = TRUE;
+ long nWert;
+
+ aPaintTimer.SetTimeout(1000);
+ nStartLevel = 0;
+ pFighter->Init();
+ pMunition->ClearAll();
+ pBombe->ClearAll();
+ pWall->ClearAll();
+ pGegner->ClearAll();
+ bAuseModus = FALSE;
+ nAuseCount = 0;
+ pGegner->SetAuseMode(FALSE);
+
+ pScoreWindow->SetRockets(5);
+ pScoreWindow->SetLives(nFighter);
+ pScoreWindow->SetScore(nScore);
+ pScoreWindow->SetLevel(nLevel);
+
+ if(nLevel > 1)
+ {
+ pGegner->SetRandWert(pGegner->GetRandWert()+10);
+ nTimeOut -= 2;
+ if(nTimeOut <= 0)
+ nTimeOut = 1;
+ }
+
+ if(nLevel == 10 || nLevel == 20 || nLevel == 30 || nLevel >= 40)
+ {
+ pGegner->SetDown(pGegner->GetDown()+2);
+ if(pGegner->GetDown() > 30)
+ pGegner->SetDown(30);
+ }
+
+ nWert = nLevel;
+ while( nWert > WAVES )
+ nWert -= WAVES;
+
+ if(!( nLevel % 10 ))
+ {
+ if(!bGetFighter)
+ {
+ nFighter++;
+ pScoreWindow->SetLives(nFighter);
+ bGetFighter = TRUE;
+ }
+ }
+ else
+ bGetFighter = FALSE;
+
+ USHORT nGegner;
+ USHORT nDummy;
+
+ if(nLevel < WAVES*2)
+ {
+ nGegner = waves[nWert-1][0];
+ nDummy = nGegner;
+ for(long i=0; i<nGegner; i++)
+ if ( nLevel > 10 ) pGegner->InsertGegner((USHORT)waves[nWert-1][i*3+1],
+ (USHORT)waves[nWert-1][i*3+2],
+ (USHORT)waves[nWert-1][i*3+3]);
+ else if ( waves[nWert-1][i*3+1] < 4 ) pGegner->InsertGegner((USHORT)waves[nWert-1][i*3+1],
+ (USHORT)waves[nWert-1][i*3+2],
+ (USHORT)waves[nWert-1][i*3+3]);
+ else nDummy--;
+
+
+ }
+ else
+ {
+ if(levelpuf[0] != nLevel)
+ RandomLevel();
+ else
+ {
+ for(long i=0; i<levelpuf[1]; i++)
+ pGegner->InsertGegner(levelpuf[i*3+2],levelpuf[i*3+3],levelpuf[i*3+4]);
+ }
+ nGegner = levelpuf[1];
+ nDummy = nGegner;
+ }
+
+ BYTE nMauer;
+ Point aPoint;
+
+ if(nLevel < WAVES*2)
+ nMauer = (BYTE)waves[nWert-1][nGegner*3+1];
+ else
+ nMauer = 0xff;
+ if(nMauer & 0x01)
+ {
+ aPoint = Point(0,340);
+ pWall->InsertWall(aPoint);
+ }
+ if(nMauer & 0x02)
+ {
+ aPoint = Point(32,340);
+ pWall->InsertWall(aPoint);
+ }
+ if(nMauer & 0x04)
+ {
+ aPoint = Point(64,340);
+ pWall->InsertWall(aPoint);
+ }
+ if(nMauer & 0x08)
+ {
+ aPoint = Point(96,340);
+ pWall->InsertWall(aPoint);
+ }
+ if(nMauer & 0x10)
+ {
+ aPoint = Point(128,340);
+ pWall->InsertWall(aPoint);
+ }
+ if(nMauer & 0x20)
+ {
+ aPoint = Point(160,340);
+ pWall->InsertWall(aPoint);
+ }
+ if(nMauer & 0x40)
+ {
+ aPoint = Point(192,340);
+ pWall->InsertWall(aPoint);
+ }
+ if(nMauer & 0x80)
+ {
+ aPoint = Point(224,340);
+ pWall->InsertWall(aPoint);
+ }
+ if(nLevel < WAVES*2)
+ nMauer = (BYTE)waves[nWert-1][nGegner*3+2];
+ else
+ nMauer = 0xff;
+ if(nMauer & 0x01)
+ pWall->InsertWall(Point(256,340));
+ if(nMauer & 0x02)
+ pWall->InsertWall(Point(288,340));
+ if(nMauer & 0x04)
+ pWall->InsertWall(Point(320,340));
+ if(nMauer & 0x08)
+ pWall->InsertWall(Point(352,340));
+ if(nMauer & 0x10)
+ pWall->InsertWall(Point(384,340));
+ if(nMauer & 0x20)
+ pWall->InsertWall(Point(416,340));
+ if(nMauer & 0x40)
+ pWall->InsertWall(Point(448,340));
+ if(nMauer & 0x80)
+ pWall->InsertWall(Point(480,340));
+ if(nLevel < WAVES*2)
+ nMauer = (BYTE)waves[nWert-1][nGegner*3+3];
+ else
+ nMauer = 0xff;
+ if(nMauer & 0x01)
+ pWall->InsertWall(Point(512,340));
+ if(nMauer & 0x02)
+ pWall->InsertWall(Point(544,340));
+ if(nMauer & 0x04)
+ pWall->InsertWall(Point(576,340));
+ if(nMauer & 0x08)
+ pWall->InsertWall(Point(608,340));
+
+ nGegner = nDummy;
+
+}
+
+void MyWindow::RandomLevel()
+{
+ Time aTime;
+
+ srand(aTime.GetTime() % 1000);
+
+ long nPos = ranpos[0];
+ while(!pGegner->Count())
+ {
+ for(long i=0; i<nPos ;i++)
+ {
+
+ int nRan = rand() / 200;
+
+ if(nRan < 3)
+ pGegner->InsertGegner(GEGNER5,ranpos[i*2+1],ranpos[i*2+2]);
+ if(nRan > 2 && nRan < 9)
+ pGegner->InsertGegner(GEGNER4,ranpos[i*2+1],ranpos[i*2+2]);
+ if(nRan > 8 && nRan < 16)
+ pGegner->InsertGegner(GEGNER3,ranpos[i*2+1],ranpos[i*2+2]);
+ if(nRan > 15 && nRan < 27)
+ pGegner->InsertGegner(GEGNER2,ranpos[i*2+1],ranpos[i*2+2]);
+ if(nRan > 26 && nRan < 41)
+ pGegner->InsertGegner(GEGNER1,ranpos[i*2+1],ranpos[i*2+2]);
+ }
+ }
+
+ levelpuf[0] = nLevel;
+ levelpuf[1] = pGegner->Count();
+ for(long i=0; i<pGegner->Count(); i++)
+ {
+ levelpuf[i*3+2] = pGegner->GegType(i);
+ levelpuf[i*3+3] = pGegner->GegnerX(i);
+ levelpuf[i*3+4] = pGegner->GegnerY(i);
+ }
+}
+
diff --git a/goodies/source/inv/makefile.mk b/goodies/source/inv/makefile.mk
new file mode 100644
index 000000000000..2e869731bbe8
--- /dev/null
+++ b/goodies/source/inv/makefile.mk
@@ -0,0 +1,213 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=goodies
+TARGET=invader
+
+AUTOSEG=true
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(TEST)" != ""
+ENVCFLAGS=-DTEST
+OBJFILES= \
+ $(OBJ)$/invader.obj \
+ $(OBJ)$/invader1.obj \
+ $(OBJ)$/shapes.obj \
+ $(OBJ)$/expl.obj \
+ $(OBJ)$/score.obj \
+ $(OBJ)$/monst.obj
+.ELSE
+
+SLOFILES= \
+ $(SLO)$/invader.obj \
+ $(SLO)$/invader1.obj \
+ $(SLO)$/shapes.obj \
+ $(SLO)$/expl.obj \
+ $(SLO)$/score.obj \
+ $(SLO)$/monst.obj
+.IF "$(GUI)"!="UNX"
+SLOFILES += $(SLO)$/dll.obj
+.ENDIF
+.ENDIF
+
+SRCFILES=gegner.src strings.src
+
+RESLIB1NAME=tfu
+RESLIB1SRSFILES=$(SRS)$/invader.srs
+
+.IF "$(TEST)"!=""
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJ)$/invader.obj
+APP1STDLIBS= $(TOOLSLIB) $(SVLIB)
+APP1LIBS=$(LIBPRE) invader.lib
+APP1STACK= 64000
+APP1DEPN= $(LB)$/invader.lib
+
+.ELSE
+
+SHL1TARGET= tfu$(UPD)$(DLLPOSTFIX)
+SHL1IMPLIB= itfu
+SHL1STDLIBS=\
+ $(SVLIB) \
+ $(TOOLSLIB)
+
+.IF "$(GUI)"=="WNT"
+SHL1STDLIBS+=\
+ comdlg32.lib \
+ advapi32.lib
+.ENDIF
+
+.IF "$(GUI)"!="WNT"
+SHL1LIBS= $(LIB1TARGET)
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+SHL1OBJS=$(SLOFILES)
+.ELSE
+.IF "$(GUI)"!="UNX"
+SHL1OBJS=$(SLO)$/dll.obj
+.ENDIF
+SHL1LIBS=$(SLB)$/$(TARGET).lib
+.ENDIF
+
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+.ENDIF
+# --- Targets -------------------------------------------------------
+
+
+.INCLUDE : target.mk
+
+.IF "$(GUI)"=="WIN"
+
+$(MISC)$/$(APP1TARGET).def : makefile.mk
+ echo NAME svdiff >$@
+ echo DESCRIPTION 'Star Invader' >>$@
+ echo EXETYPE WINDOWS >>$@
+ echo STUB 'winSTUB.EXE' >>$@
+ echo PROTMODE >>$@
+ echo CODE LOADONCALL MOVEABLE DISCARDABLE >>$@
+ echo DATA PRELOAD MOVEABLE MULTIPLE >>$@
+ echo HEAPSIZE 8192 >>$@
+ echo STACKSIZE 32000 >>$@
+
+.ENDIF
+
+# --- Def-File ---
+
+.IF "$(GUI)"=="WNT"
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk $(MISC)$/$(SHL1TARGET).flt
+ @+echo -------------------------------------------
+ @+echo DEF-File erstellen $@
+ @+echo LIBRARY $(DLLNAME) >$@
+ @+echo DESCRIPTION 'Star Cube DLL' >>$@
+ @+echo DATA READ WRITE NONSHARED >>$@
+ @+echo EXPORTS >>$@
+ @+echo StartInvader @22 >>$@
+
+.ENDIF
+
+.IF "$(GUI)"=="OS2"
+
+$(MISC)$/$(SHL1TARGET).def:\
+ makefile.mk \
+ $(MISC)$/$(SHL1TARGET).flt
+ @echo -------------------------------------------
+ @echo DEF-File erstellen
+.IF "$(COM)"!="WTC"
+ @echo LIBRARY $(DLLNAME) INITINSTANCE >$@
+ @echo DESCRIPTION 'StarView Filter DLL' >>$@
+ @echo PROTMODE >>$@
+ @echo CODE LOADONCALL >>$@
+ @echo DATA PRELOAD MULTIPLE NONSHARED >>$@
+ @echo EXPORTS >>$@
+.IF "$(COM)"=="ICC"
+ @echo StartInvader >>$@
+.ELSE
+ @echo _StartInvader >>$@
+.ENDIF
+.ELSE
+ @echo option DESCRIPTION 'StarWars Dll' >$@
+ @echo name $(BIN)$/$(SHL1TARGET).dll >>$@
+ @echo StartInvader_ @2 >>temp.def
+ @gawk -f s:\util\exp.awk temp.def >>$@
+ del temp.def
+
+.ENDIF
+.ENDIF #os2
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @+echo $(MISC)
+ @echo $(@)
+ @+echo $(@)
+ @echo Imp >$(@)
+
diff --git a/goodies/source/inv/monst.cxx b/goodies/source/inv/monst.cxx
new file mode 100644
index 000000000000..e7b4b1a30f2a
--- /dev/null
+++ b/goodies/source/inv/monst.cxx
@@ -0,0 +1,436 @@
+/*************************************************************************
+ *
+ * $RCSfile: monst.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <stdlib.h>
+#include "monst.hxx"
+#include "invader.hrc"
+#include "expl.hxx"
+#include "shapes.hxx"
+
+#ifndef _SV_OUTDEV_HXX //autogen
+#include <vcl/outdev.hxx>
+#endif
+
+#ifndef _TOOLS_TIME_HXX //autogen
+#include <tools/time.hxx>
+#endif
+
+Gegner::Gegner(Fighter* pFig, Bombe* pBom, ResMgr* pRes) :
+ pFighter(pFig),
+ GegnerListe(0,0),
+ bDown(FALSE),
+ bLeft(TRUE),
+ bAuseMode(FALSE),
+ pBombe(pBom),
+ pBitMonst1(0L),
+ pBitMonst2(0L),
+ pBitMonst3(0L),
+ pBitMonst4(0L),
+ pBitMonst1b(0L),
+ pBitMonst2b(0L),
+ pBitMonst3b(0L),
+ pBitMonst4b(0L),
+ pBitMonst5(0L),
+ pBitMonst5a(0L),
+ pBitMonst5b(0L),
+ nDown(MOVEY)
+{
+ pBitMonst1 = ImplLoadImage( MONSTER1, pRes );
+ pBitMonst2 = ImplLoadImage( MONSTER2, pRes );
+ pBitMonst3 = ImplLoadImage( MONSTER3, pRes );
+ pBitMonst4 = ImplLoadImage( MONSTER4, pRes );
+ pBitMonst1b = ImplLoadImage( MONSTER1B, pRes );
+ pBitMonst2b = ImplLoadImage( MONSTER2B, pRes );
+ pBitMonst3b = ImplLoadImage( MONSTER3B, pRes );
+ pBitMonst4b = ImplLoadImage( MONSTER4B, pRes );
+ pBitMonst5 = ImplLoadImage( MONSTER5, pRes );
+ pBitMonst5a = ImplLoadImage( MONSTER5A, pRes );
+ pBitMonst5b = ImplLoadImage( MONSTER5B, pRes );
+
+ aOutSize = pBitMonst1->GetSizePixel();
+
+ nRandWert = 200;
+}
+
+Gegner::~Gegner()
+{
+ ClearAll();
+
+ delete pBitMonst1;
+ delete pBitMonst2;
+ delete pBitMonst3;
+ delete pBitMonst4;
+ delete pBitMonst1b;
+ delete pBitMonst2b;
+ delete pBitMonst3b;
+ delete pBitMonst4b;
+ delete pBitMonst5;
+ delete pBitMonst5a;
+ delete pBitMonst5b;
+}
+
+void Gegner::InsertGegner(USHORT nType, USHORT x, USHORT y)
+{
+ Gegner_Impl* pWork = new Gegner_Impl();
+
+ pWork->aType = (enum GegnerType)nType;
+ pWork->aMode = MOVE1;
+ pWork->aXY = Point(x,y);
+ pWork->aX = x;
+ pWork->nHits = 0;
+ switch(pWork->aType)
+ {
+ case GEGNER1:
+ pWork->nPoints = 50;
+ pWork->nMaxHits = 1;
+ break;
+ case GEGNER2:
+ pWork->nPoints = 75;
+ pWork->nMaxHits = 2;
+ break;
+ case GEGNER3:
+ pWork->nPoints = 150;
+ pWork->nMaxHits = 3;
+ break;
+ case GEGNER4:
+ pWork->nPoints = 225;
+ pWork->nMaxHits = 5;
+ break;
+ case GEGNER5:
+ pWork->nPoints = 500;
+ pWork->nMaxHits = 3;
+ pWork->aMode = HIDE;
+ break;
+ }
+
+ Insert(pWork);
+}
+
+void Gegner::Move()
+{
+ BOOL bNextDown = FALSE;
+
+ for(long i=0; i<Count(); i++)
+ {
+ if(bDown)
+ {
+ SetGegnerPos(i,Point(GegnerX(i),GegnerY(i)+nDown));
+
+ }
+ else if(bLeft)
+ {
+ SetGegnerPos(i,Point(GegnerX(i)+MOVEX,GegnerY(i)));
+ if(GegnerX(i)+MOVEX+aOutSize.Width() > nMaxX)
+ bNextDown = TRUE;
+ }
+ else
+ {
+ SetGegnerPos(i,Point(GegnerX(i)-MOVEX,GegnerY(i)));
+ if(GegnerX(i)-MOVEX <= 0)
+ bNextDown = TRUE;
+ }
+
+ }
+
+ if(bDown)
+ {
+ if(bLeft)
+ bLeft = FALSE;
+ else
+ bLeft = TRUE;
+ }
+
+ bDown = FALSE;
+ if(bNextDown)
+ bDown = TRUE;
+}
+
+void Gegner::DrawGegner(OutputDevice* pDev,Point* pStart)
+{
+
+ Time aTime;
+ srand(aTime.GetTime() % 1000);
+
+ nMaxX = pDev->GetOutputSizePixel().Width()-pStart->X();
+
+ for(long i=0; i<Count();i++)
+ {
+ switch(GegType(i))
+ {
+ case GEGNER1:
+ if(GegMode(i) == MOVE1)
+ {
+ pDev->DrawImage(Point(pStart->X()+GegnerX(i),
+ pStart->Y()+GegnerY(i)),*pBitMonst1);
+ SetMode(i,MOVE2);
+ }
+ else if(GegMode(i) == MOVE2)
+ {
+ pDev->DrawImage(Point(pStart->X()+GegnerX(i),
+ pStart->Y()+GegnerY(i)),*pBitMonst1b);
+ SetMode(i,MOVE1);
+ }
+ break;
+ case GEGNER2:
+ if(GegMode(i) == MOVE1)
+ {
+ pDev->DrawImage(Point(pStart->X()+GegnerX(i),
+ pStart->Y()+GegnerY(i)),*pBitMonst2);
+ SetMode(i,MOVE2);
+ }
+ else if(GegMode(i) == MOVE2)
+ {
+ pDev->DrawImage(Point(pStart->X()+GegnerX(i),
+ pStart->Y()+GegnerY(i)),*pBitMonst2b);
+ SetMode(i,MOVE1);
+ }
+ break;
+ case GEGNER3:
+ if(GegMode(i) == MOVE1)
+ {
+ pDev->DrawImage(Point(pStart->X()+GegnerX(i),
+ pStart->Y()+GegnerY(i)),*pBitMonst3);
+ SetMode(i,MOVE2);
+ }
+ else if(GegMode(i) == MOVE2)
+ {
+ pDev->DrawImage(Point(pStart->X()+GegnerX(i),
+ pStart->Y()+GegnerY(i)),*pBitMonst3b);
+ SetMode(i,MOVE1);
+ }
+ break;
+ case GEGNER4:
+ if(GegMode(i) == MOVE1)
+ {
+ pDev->DrawImage(Point(pStart->X()+GegnerX(i),
+ pStart->Y()+GegnerY(i)),*pBitMonst4);
+ SetMode(i,MOVE2);
+ }
+ else if(GegMode(i) == MOVE2)
+ {
+ pDev->DrawImage(Point(pStart->X()+GegnerX(i),
+ pStart->Y()+GegnerY(i)),*pBitMonst4b);
+ SetMode(i,MOVE1);
+ }
+ break;
+ case GEGNER5:
+ if(GegMode(i) == MOVE1)
+ {
+ pDev->DrawImage(Point(pStart->X()+GegnerX(i),
+ pStart->Y()+GegnerY(i)),*pBitMonst5);
+ DecDelay(i);
+ if(!GetDelay(i))
+ {
+ SetDelay(i);
+ SetMode(i,MOVE2);
+ }
+ }
+ if(GegMode(i) == MOVE2)
+ {
+ pDev->DrawImage(Point(pStart->X()+GegnerX(i),
+ pStart->Y()+GegnerY(i)),*pBitMonst5a);
+ DecDelay(i);
+ if(!GetDelay(i))
+ {
+ SetDelay(i);
+ SetMode(i,MOVE3);
+ }
+ }
+ if(GegMode(i) == MOVE3)
+ {
+ pDev->DrawImage(Point(pStart->X()+GegnerX(i),
+ pStart->Y()+GegnerY(i)),*pBitMonst5b);
+ DecDelay(i);
+ if(!GetDelay(i))
+ {
+ pBombe->InsertBombe(Point(GegnerX(i)+aOutSize.Width()/2,
+ GegnerY(i)+aOutSize.Height()));
+ SetDelay(i);
+ SetMode(i,MOVE4);
+ }
+ }
+ if(GegMode(i) == MOVE4)
+ {
+ pDev->DrawImage(Point(pStart->X()+GegnerX(i),
+ pStart->Y()+GegnerY(i)),*pBitMonst5a);
+ DecDelay(i);
+ if(!GetDelay(i))
+ {
+ SetDelay(i);
+ SetMode(i,MOVE5);
+ }
+ }
+ if(GegMode(i) == MOVE5)
+ {
+ pDev->DrawImage(Point(pStart->X()+GegnerX(i),
+ pStart->Y()+GegnerY(i)),*pBitMonst5);
+ DecDelay(i);
+ if(!GetDelay(i))
+ SetMode(i,HIDE);
+ }
+ break;
+
+ }
+
+ SetKoll(i,Rectangle(Point(GegnerX(i)+KOLLXY,GegnerY(i)+KOLLXY),
+ Point(GegnerX(i)+aOutSize.Width()-KOLLXY,
+ GegnerY(i)+aOutSize.Height()-KOLLXY)));
+
+ if(bAuseMode && GegMode(i) == MOVE1)
+ {
+ if(GegnerX(i) < pFighter->GetHalf() &&
+ GegnerX(i)+aOutSize.Width() > pFighter->GetHalf())
+ pBombe->InsertBombe(Point(pFighter->GetPoint().X(),
+ GegnerY(i)+aOutSize.Height()));
+ }
+ else
+ {
+ int ran = rand();
+
+ if(ran < nRandWert)
+ {
+ if(GegType(i) != GEGNER5)
+ pBombe->InsertBombe(Point(GegnerX(i)+aOutSize.Width()/2,
+ GegnerY(i)+aOutSize.Height()));
+ else if(GegMode(i) == HIDE)
+ {
+ SetMode(i,MOVE1);
+ SetDelay(i);
+ }
+ }
+ }
+ }
+
+ Move();
+}
+
+long Gegner::Kollision(Rectangle& rRect, Explosion* pExpl)
+{
+ long nWert = -1;
+
+ Rectangle aWork;
+
+ for(long i=0; i<Count();i++)
+ {
+ aWork = GegnerKoll(i);
+ if((aWork.Left() <= rRect.Left() && aWork.Right() >= rRect.Right()) &&
+ (aWork.Top() <= rRect.Top() && aWork.Bottom() >= rRect.Bottom()) &&
+ GegMode(i) != DELETED)
+ {
+ nWert = 0;
+ if(GegnerDest(i))
+ {
+ SetMode(i,DELETED);
+ if(nWert == -1)
+ nWert = GegnerPoints(i);
+ else
+ nWert += GegnerPoints(i);
+ }
+
+ pExpl->InsertExpl(GegnerPos(i));
+
+ }
+ }
+
+ return nWert;
+}
+
+BOOL Gegner::GegnerDest(long nWert)
+{
+ GegnerHit(nWert);
+ if(GetObject(nWert)->nHits >= GetObject(nWert)->nMaxHits)
+ return TRUE;
+
+ return FALSE;
+}
+
+Rectangle Gegner::GetKoll(long nWert)
+{
+ return Rectangle(Point(GegnerX(nWert)+aOutSize.Width()/2,
+ GegnerY(nWert)+aOutSize.Height()),
+ Point(GegnerX(nWert)+aOutSize.Width()/2,
+ GegnerY(nWert)+aOutSize.Height()));
+}
+
+BOOL Gegner::RemoveGegner()
+{
+ for(long i=Count()-1; i>=0; i--)
+ {
+ Gegner_Impl* pWork = GetObject(i);
+
+ if(pWork->aMode == DELETED)
+ {
+ Remove(pWork);
+ delete pWork;
+ }
+ }
+ if(Count())
+ return FALSE;
+ else
+ return TRUE;
+}
+
+void Gegner::ClearAll()
+{
+ for(long i=0; i<Count(); i++)
+ delete GetObject(i);
+
+ Clear();
+}
diff --git a/goodies/source/inv/monst.hxx b/goodies/source/inv/monst.hxx
new file mode 100644
index 000000000000..c07c6a64ece8
--- /dev/null
+++ b/goodies/source/inv/monst.hxx
@@ -0,0 +1,172 @@
+/*************************************************************************
+ *
+ * $RCSfile: monst.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _MONST_HXX
+#define _MONST_HXX
+
+enum GegnerType { GEGNER1, GEGNER2, GEGNER3, GEGNER4, GEGNER5 };
+enum GegnerMode { MOVE1, MOVE2, MOVE3, MOVE4, MOVE5, DELETED, HIDE };
+
+#define DIFFX 20
+#define DIFFY 20
+#define MOVEX 10
+#define MOVEY 10
+#define KOLLXY 2
+
+#include <tools/list.hxx>
+#ifndef _SV_IMAGE_HXX //autogen
+#include <vcl/image.hxx>
+#endif
+#ifndef _GEN_HXX //autogen
+#include <tools/gen.hxx>
+#endif
+#ifndef _SV_OUTDEV_HXX //autogen
+#include <vcl/outdev.hxx>
+#endif
+
+struct Gegner_Impl
+{
+ Point aXY;
+ long nRow;
+ long aX;
+ long nDiffX;
+ long nPoints;
+ long nMaxHits;
+ long nHits;
+ long nDelay;
+ GegnerType aType;
+ GegnerMode aMode;
+ Rectangle aKoll;
+};
+
+DECLARE_LIST(GegnerListe,Gegner_Impl*);
+
+class Explosion;
+class Bombe;
+class Fighter;
+
+class Gegner : public GegnerListe
+{
+ private:
+ long nRows;
+ long nGegnerRow;
+ long nMaxX;
+ Size aOutSize;
+ Image* pBitMonst1;
+ Image* pBitMonst2;
+ Image* pBitMonst3;
+ Image* pBitMonst4;
+ Image* pBitMonst1b;
+ Image* pBitMonst2b;
+ Image* pBitMonst3b;
+ Image* pBitMonst4b;
+ Image* pBitMonst5;
+ Image* pBitMonst5a;
+ Image* pBitMonst5b;
+ Bombe* pBombe;
+ Fighter* pFighter;
+
+ BOOL bDown;
+ BOOL bLeft;
+ BOOL bAuseMode;
+ long nRandWert;
+ long nDown;
+
+ public:
+ Gegner(Fighter* pFighter, Bombe* pBombe, ResMgr* pRes);
+ ~Gegner();
+
+ void InsertGegner(USHORT nType, USHORT x, USHORT y);
+ void DrawGegner(OutputDevice* pDev, Point* pStart);
+ void Move();
+ void SetRandWert(long nWert) { nRandWert = nWert; }
+ long GetRandWert() { return nRandWert; }
+ long GegnerX(long nWert) { return GetObject(nWert)->aXY.X(); }
+ long GegnerXStart(long nWert) { return GetObject(nWert)->aX; }
+ long GegnerY(long nWert) { return GetObject(nWert)->aXY.Y(); }
+ GegnerType GegType(long nWert)
+ { return GetObject(nWert)->aType; }
+ GegnerMode GegMode(long nWert)
+ { return GetObject(nWert)->aMode; }
+ void SetMode(long nWert, enum GegnerMode nMode)
+ { GetObject(nWert)->aMode = nMode; }
+ void SetGegnerPos(long nWert, const Point& rPoint)
+ { GetObject(nWert)->aXY = rPoint;}
+ long GegnerDiffX(long nWert) { return GetObject(nWert)->nDiffX; }
+ Rectangle& GegnerKoll(long nWert) { return GetObject(nWert)->aKoll; }
+ Rectangle GetKoll(long nWert);
+ void SetKoll(long nWert, const Rectangle& rRect)
+ { GetObject(nWert)->aKoll = rRect; }
+ long Kollision(Rectangle& rRect, Explosion* pExplosion);
+ Point& GegnerPos(long nWert) { return GetObject(nWert)->aXY; }
+ BOOL RemoveGegner();
+ void ClearAll();
+ long GegnerPoints(long nWert) { return GetObject(nWert)->nPoints; }
+ void GegnerHit(long nWert) { GetObject(nWert)->nHits++; }
+ BOOL GegnerDest(long nWert);
+ void SetDown(long nWert) { nDown = nWert; }
+ long GetDown() { return nDown; }
+ void SetAuseMode(BOOL bFlag) { bAuseMode = bFlag; }
+ void SetDelay(long nWert) { GetObject(nWert)->nDelay = 3; }
+ long GetDelay(long nWert) { return GetObject(nWert)->nDelay; }
+ void DecDelay(long nWert) { GetObject(nWert)->nDelay--; }
+};
+
+#endif
diff --git a/goodies/source/inv/score.cxx b/goodies/source/inv/score.cxx
new file mode 100644
index 000000000000..4f78c00f565a
--- /dev/null
+++ b/goodies/source/inv/score.cxx
@@ -0,0 +1,198 @@
+/*************************************************************************
+ *
+ * $RCSfile: score.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "score.hxx"
+#include "strings.hrc"
+#include "invader.hxx"
+
+ScoreWindow::ScoreWindow(Window* Parent, WinBits wBits, ResMgr* pP) :
+ Window(Parent, wBits),
+ bPaintBack(FALSE),
+ pRes(pP),
+ nHero(-1),
+ nRockets(5),
+ nLives(3),
+ nScore(0L)
+{
+ SetBackgroundBrush( Brush( COL_GRAY, BRUSH_SOLID ));
+}
+
+ScoreWindow::~ScoreWindow()
+{
+}
+
+void ScoreWindow::Paint(const Rectangle& rRect)
+{
+ Font aFont = GetFont();
+ aFont.SetColor(COL_WHITE);
+ aFont.SetFillColor(COL_GRAY);
+ SetFont(*&aFont);
+ Brush aBrush = GetFillInBrush();
+ aBrush.SetColor(COL_GRAY);
+ SetFillInBrush(*&aBrush);
+
+ if(bPaintBack)
+ {
+ Pen aOldPen = GetPen();
+ Pen aPen = aOldPen;
+ aPen.SetStyle(PEN_NULL);
+ SetPen(aPen);
+
+ DrawRect(Rectangle(Point(0,0),GetOutputSizePixel()));
+ SetPen(aOldPen);
+ }
+
+ if(nHero)
+ DrawText(Point(0,0),String(ResId(nHero, pRes)));
+
+ DrawText(Point(180,0),String(ResId(STR_ROCKETS, pRes)));
+
+ DrawText(Point(300,0),String(ResId(STR_FIGHTER, pRes)));
+ DrawText(Point(370,0),String(nLives));
+
+ DrawText(Point(400,0),String(ResId(STR_LEVEL, pRes)));
+ DrawText(Point(460,0),String(nLevel));
+
+ DrawText(Point(500,0),String(ResId(STR_SCORE, pRes)));
+ String aString(nScore);
+ if(aString.Len() < 7)
+ {
+ String bString;
+ for(long i=0; i+aString.Len()<7;i++)
+ bString += String("0");
+
+ aString = bString + aString;
+
+ }
+ DrawText(Point(560,0),aString);
+
+ for(long i=0; i<5;i++)
+ {
+ Pen aPen = GetPen();
+ if(nRockets > i)
+ {
+ aPen.SetColor(COL_GREEN);
+ aPen.SetStyle(PEN_SOLID);
+ SetPen(*&aPen);
+ aBrush.SetColor(COL_GREEN);
+ SetFillInBrush(*&aBrush);
+ }
+ else
+ {
+ aPen.SetColor(COL_RED);
+ aPen.SetStyle(PEN_SOLID);
+ SetPen(*&aPen);
+ aBrush.SetColor(COL_RED);
+ SetFillInBrush(*&aBrush);
+ }
+
+ DrawRect(Rectangle(Point(250+i*8,5),Point(256+i*8,12)));
+ }
+ SetBackgroundBrush( Brush( COL_GRAY, BRUSH_SOLID ));
+
+ bPaintBack = FALSE;
+}
+
+void ScoreWindow::SetHero(long nName)
+{
+ nHero = nName;
+
+ SetBackgroundBrush(BRUSH_NULL);
+ Invalidate();
+}
+
+void ScoreWindow::SetRockets(USHORT nWert)
+{
+ nRockets = nWert;
+
+ SetBackgroundBrush(BRUSH_NULL);
+ Invalidate();
+}
+
+void ScoreWindow::SetLives(USHORT nWert)
+{
+ nLives = nWert;
+
+// SetBackgroundBrush(BRUSH_NULL);
+ Invalidate();
+}
+
+void ScoreWindow::SetScore(long nWert)
+{
+ nScore = nWert;
+
+ SetBackgroundBrush(BRUSH_NULL);
+ Invalidate();
+}
+
+void ScoreWindow::SetLevel(long nWert)
+{
+ nLevel = nWert;
+
+// SetBackgroundBrush(BRUSH_NULL);
+ Invalidate();
+}
+
+void ScoreWindow::Show()
+{
+ bPaintBack = TRUE;
+
+ Window::Show();
+}
diff --git a/goodies/source/inv/score.hxx b/goodies/source/inv/score.hxx
new file mode 100644
index 000000000000..7b0412b0125a
--- /dev/null
+++ b/goodies/source/inv/score.hxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * $RCSfile: score.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _SCORE_HXX
+#define _SCORE_HXX
+
+
+#ifndef _SV_WINDOW_HXX //autogen
+#include <vcl/window.hxx>
+#endif
+
+class ScoreWindow : public Window
+{
+ private:
+ long nHero;
+ USHORT nRockets;
+ USHORT nLives;
+ long nScore;
+ long nLevel;
+ ResMgr* pRes;
+
+ BOOL bPaintBack;
+
+ public:
+ ScoreWindow(Window* pParent, WinBits bits,ResMgr* pRes);
+ ~ScoreWindow();
+ virtual void Paint(const Rectangle& rRect);
+ void SetHero(long nName);
+ void SetRockets(USHORT nWert);
+ void SetLives(USHORT nWert);
+ void SetScore(long nWert);
+ void SetLevel(long nWert);
+
+ void Show();
+};
+
+#endif
diff --git a/goodies/source/inv/shapes.cxx b/goodies/source/inv/shapes.cxx
new file mode 100644
index 000000000000..67c53c082409
--- /dev/null
+++ b/goodies/source/inv/shapes.cxx
@@ -0,0 +1,497 @@
+/*************************************************************************
+ *
+ * $RCSfile: shapes.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "shapes.hxx"
+#include "invader.hrc"
+#include "expl.hxx"
+#include <vcl/outdev.hxx>
+#include <vcl/virdev.hxx>
+
+Image* ImplLoadImage( USHORT nId, ResMgr* pRes )
+{
+ return new Image( Bitmap( ResId( nId, pRes ) ), COL_WHITE );
+}
+
+// ------------------------------------------------------------------------
+
+Fighter::Fighter(Size& rOut, ResMgr* pRes) :
+ pFight1(0L),
+ pFightr(0L),
+ pFightl(0L),
+ bNoKey(FALSE),
+ eMode(FIGHT_NORM),
+ nDelay(0)
+{
+ pFight1 = ImplLoadImage( FIGHTER1, pRes );
+ pFightr = ImplLoadImage( FIGHTERR, pRes );
+ pFightl = ImplLoadImage( FIGHTERL, pRes );
+
+ aSize = pFight1->GetSizePixel();
+
+ aOut.X() = rOut.Width()/2-aSize.Width()/2;
+ aOut.Y() = rOut.Height()-aSize.Height()-10;
+
+ aStart = aOut;
+
+ nMax = rOut.Width() - aSize.Width();
+}
+
+Fighter::~Fighter()
+{
+
+ delete pFight1;
+ delete pFightr;
+ delete pFightl;
+}
+
+void Fighter::Init()
+{
+ aOut = aStart;
+ eMode = FIGHT_NORM;
+}
+
+void Fighter::Paint(OutputDevice& rDev)
+{
+ if(eMode == FIGHT_DEST)
+ return;
+
+ switch(eMode)
+ {
+ case FIGHT_NORM:
+ rDev.DrawImage(aOut,*pFight1);
+ break;
+ case FIGHT_RIGHT:
+ rDev.DrawImage(aOut,*pFightr);
+ break;
+ case FIGHT_LEFT:
+ rDev.DrawImage(aOut,*pFightl);
+ break;
+ }
+
+ if(nDelay <= 0)
+ eMode = FIGHT_NORM;
+ else
+ nDelay--;
+
+ bNoKey = FALSE;
+}
+
+void Fighter::Move(long nDirect)
+{
+ if(eMode == FIGHT_DEST)
+ return;
+
+ if(nDirect < 0)
+ {
+ aOut.X() -= KANONEX;
+ eMode = FIGHT_LEFT;
+ }
+ else
+ {
+ aOut.X() += KANONEX;
+ eMode = FIGHT_RIGHT;
+ }
+
+ nDelay = 5;
+
+ if(aOut.X() <= 0)
+ aOut.X() = 1;
+ if(aOut.X() > nMax)
+ aOut.X() = nMax;
+
+ bNoKey = TRUE;
+}
+
+BOOL Fighter::Kollision(Rectangle aRect, Explosion* pExpl)
+{
+ if((aOut.X() <= aRect.Left() && aOut.X()+aSize.Width() >= aRect.Right()) &&
+ (aOut.Y() <= aRect.Top() && aOut.Y()+aSize.Height() >= aRect.Bottom()))
+ {
+ pExpl->InsertExpl(aOut);
+ eMode = FIGHT_DEST;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+Munition::Munition(ResMgr* pRes) :
+ MunitionListe(0,1),
+ pMunition1(0L),
+ pMunition2(0L)
+{
+ pMunition1 = ImplLoadImage( MUNITION1,pRes );
+ pMunition2 = ImplLoadImage( MUNITION2,pRes );
+
+ aSize = pMunition1->GetSizePixel();
+}
+
+Munition::~Munition()
+{
+ ClearAll();
+
+ delete pMunition1;
+ delete pMunition2;
+}
+
+void Munition::Start(Point& rPoint)
+{
+ if( Count() >= MUNMAX)
+ return;
+
+
+ Munition_Impl* pWork = new Munition_Impl();
+
+ pWork->aPoint = rPoint;
+ pWork->eMode = MUNI_MODE1;
+
+ Insert(pWork);
+}
+
+void Munition::Paint(OutputDevice& rDev)
+{
+ for(long i=0; i<Count();i++)
+ {
+ switch(GetMode(i))
+ {
+ case MUNI_MODE1:
+ rDev.DrawImage(GetPoint(i),*pMunition1);
+ SetMode(i,MUNI_MODE2);
+ break;
+ case MUNI_MODE2:
+ rDev.DrawImage(GetPoint(i),*pMunition2);
+ SetMode(i,MUNI_MODE1);
+ break;
+ }
+
+ SetKoll(i,Rectangle(Point(GetPoint(i).X()+aSize.Width()/2,GetPoint(i).Y()),
+ Point(GetPoint(i).X()+aSize.Width()/2,
+ GetPoint(i).Y())));
+
+
+ SetPoint(i,Point(GetPoint(i).X(),GetPoint(i).Y() - MUNIY));
+ if(GetPoint(i).Y() <= aSize.Height()*-1)
+ {
+ SetMode(i,MUNI_DEL);
+ }
+ }
+}
+
+long Munition::RemoveMunition()
+{
+ for(long i=Count()-1; i>=0; i--)
+ {
+ if(GetMode(i) == MUNI_DEL)
+ {
+ Munition_Impl* pWork = GetObject(i);
+ Remove(pWork);
+ delete pWork;
+ }
+ }
+
+ return 5-Count();
+}
+
+void Munition::ClearAll()
+{
+ for(long i=Count()-1; i>=0; i--)
+ delete GetObject(i);
+
+ Clear();
+}
+
+Bombe::Bombe(ResMgr* pRes) :
+ BombenListe(0,1)
+{
+ pBombe = ImplLoadImage( BOMBE,pRes );
+
+ aSize = pBombe->GetSizePixel();
+ nSpeed = BOMBEY;
+}
+
+Bombe::~Bombe()
+{
+ ClearAll();
+
+ delete pBombe;
+}
+
+void Bombe::Paint(OutputDevice& rDev)
+{
+ for(long i=0; i<Count();i++)
+ {
+ rDev.DrawImage(GetPoint(i),*pBombe);
+ SetKoll(i,Rectangle(Point(GetPoint(i).X()+aSize.Width()/2,
+ GetPoint(i).Y()+aSize.Height()),
+ Point(GetPoint(i).X()+aSize.Width()/2,
+ GetPoint(i).Y()+aSize.Height())));
+
+ SetPoint(i,Point(GetPoint(i).X(),GetPoint(i).Y() + MUNIY));
+ }
+}
+
+void Bombe::InsertBombe(const Point& rPoint)
+{
+ Bombe_Impl* pWork = new Bombe_Impl;
+ pWork->aXY = rPoint;
+ pWork->bDelete = FALSE;
+ Insert(pWork);
+}
+
+void Bombe::RemoveBomben()
+{
+ for(long i=Count()-1; i>=0; i--)
+ {
+ Bombe_Impl* pWork = GetObject(i);
+ if(pWork->bDelete)
+ {
+ Remove(pWork);
+ delete pWork;
+ }
+ }
+}
+
+void Bombe::ClearAll()
+{
+ for(long i=0;i<Count();i++)
+ delete GetObject(i);
+ Clear();
+}
+
+BOOL Bombe::Kollision(Rectangle aRect, Explosion* pExpl)
+{
+ for(long i=0;i<Count();i++)
+ {
+ if((GetPoint(i).X() <= aRect.Left() && GetPoint(i).X()+aSize.Width() >= aRect.Right()) &&
+ (GetPoint(i).Y() <= aRect.Top() && GetPoint(i).Y()+aSize.Height() >= aRect.Bottom()))
+ {
+ pExpl->InsertExpl(GetPoint(i));
+ SetDelete(i);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+Wall::Wall(ResMgr* pRes) :
+ WallListe(0,1),
+ pWall1(0L),
+ pWall2(0L),
+ pWall3(0L),
+ pWall4(0L),
+ pWall5(0L),
+ pWall6(0L),
+ pWall7(0L),
+ pWall8(0L),
+ pWall9(0L),
+ pWall10(0L)
+{
+ pWall1 = ImplLoadImage( WALL1,pRes );
+ pWall2 = ImplLoadImage( WALL2,pRes );
+ pWall3 = ImplLoadImage( WALL3,pRes );
+ pWall4 = ImplLoadImage( WALL4,pRes );
+ pWall5 = ImplLoadImage( WALL5,pRes );
+ pWall6 = ImplLoadImage( WALL6,pRes );
+ pWall7 = ImplLoadImage( WALL7,pRes );
+ pWall8 = ImplLoadImage( WALL8,pRes );
+ pWall9 = ImplLoadImage( WALL9,pRes );
+ pWall10 = ImplLoadImage( WALL10,pRes );
+
+ aSize = pWall1->GetSizePixel();
+}
+
+Wall::~Wall()
+{
+ ClearAll();
+
+ delete pWall1;
+ delete pWall2;
+ delete pWall3;
+ delete pWall4;
+ delete pWall5;
+ delete pWall6;
+ delete pWall7;
+ delete pWall8;
+ delete pWall9;
+ delete pWall10;
+}
+
+void Wall::Paint(OutputDevice& rDev)
+{
+ for(long i=0; i<Count(); i++)
+ {
+ switch(GetMode(i))
+ {
+ case WALL_MOD1:
+ rDev.DrawImage(GetPoint(i),*pWall1);
+ break;
+ case WALL_MOD2:
+ rDev.DrawImage(GetPoint(i),*pWall2);
+ break;
+ case WALL_MOD3:
+ rDev.DrawImage(GetPoint(i),*pWall3);
+ break;
+ case WALL_MOD4:
+ rDev.DrawImage(GetPoint(i),*pWall4);
+ break;
+ case WALL_MOD5:
+ rDev.DrawImage(GetPoint(i),*pWall5);
+ break;
+ case WALL_MOD6:
+ rDev.DrawImage(GetPoint(i),*pWall6);
+ break;
+ case WALL_MOD7:
+ rDev.DrawImage(GetPoint(i),*pWall7);
+ break;
+ case WALL_MOD8:
+ rDev.DrawImage(GetPoint(i),*pWall8);
+ break;
+ case WALL_MOD9:
+ rDev.DrawImage(GetPoint(i),*pWall9);
+ break;
+ case WALL_MOD10:
+ rDev.DrawImage(GetPoint(i),*pWall10);
+ break;
+ }
+
+ }
+}
+
+void Wall::InsertWall(const Point& rPoint)
+{
+ Wall_Impl* pWork = new Wall_Impl();
+
+ pWork->aXY = rPoint;
+ pWork->aXY.Y() = WALLY;
+ pWork->eMode = WALL_MOD1;
+
+ Insert(pWork);
+}
+
+void Wall::ClearAll()
+{
+ for(long i=0; i<Count(); i++)
+ delete GetObject(i);
+
+ Clear();
+}
+
+BOOL Wall::Kollision(Rectangle& rRect, BOOL bDel)
+{
+ BOOL nTreffer = FALSE;
+
+ Rectangle aWork;
+
+ for(long i=0; i<Count();i++)
+ {
+
+ Point aPoint = GetPoint(i);
+ aWork = Rectangle(Point(aPoint.X(),aPoint.Y()-WALLKOLL),
+ Point(aPoint.X()+aSize.Width(),
+ aPoint.Y()+aSize.Height()-WALLKOLL));
+
+ if((aWork.Left() <= rRect.Left() && aWork.Right() >= rRect.Right()) &&
+ (aWork.Top() <= rRect.Top() && aWork.Bottom() >= rRect.Bottom()) &&
+ GetMode(i) != WALL_DEL)
+ {
+ switch(GetMode(i))
+ {
+ case WALL_MOD1:
+ SetMode(i,WALL_MOD2);
+ break;
+ case WALL_MOD2:
+ SetMode(i,WALL_MOD3);
+ break;
+ case WALL_MOD3:
+ SetMode(i,WALL_MOD4);
+ break;
+ case WALL_MOD4:
+ SetMode(i,WALL_MOD5);
+ break;
+ case WALL_MOD5:
+ SetMode(i,WALL_MOD6);
+ break;
+ case WALL_MOD6:
+ SetMode(i,WALL_MOD7);
+ break;
+ case WALL_MOD7:
+ SetMode(i,WALL_MOD8);
+ break;
+ case WALL_MOD8:
+ SetMode(i,WALL_MOD9);
+ break;
+ case WALL_MOD9:
+ SetMode(i,WALL_MOD10);
+ break;
+ case WALL_MOD10:
+ SetMode(i,WALL_DEL);
+ break;
+ }
+
+ if(bDel)
+ SetMode(i,WALL_DEL);
+
+ nTreffer = TRUE;
+ }
+ }
+
+ return nTreffer;
+}
diff --git a/goodies/source/inv/shapes.hxx b/goodies/source/inv/shapes.hxx
new file mode 100644
index 000000000000..03138d4b89cb
--- /dev/null
+++ b/goodies/source/inv/shapes.hxx
@@ -0,0 +1,229 @@
+/*************************************************************************
+ *
+ * $RCSfile: shapes.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _SHAPES_HXX
+#define _SHAPES_HXX
+
+
+#ifndef _SV_IMAGE_HXX //autogen
+#include <vcl/image.hxx>
+#endif
+#ifndef _SV_OUTDEV_HXX //autogen
+#include <vcl/outdev.hxx>
+#endif
+
+#define KANONEX 10
+#define BOMBEY 20
+#define MUNIXY 10
+#define BOMBXY 5
+#define WALLY 400
+#define WALLKOLL 8
+
+Image* ImplLoadImage( USHORT nId, ResMgr* pRes );
+
+enum FighterMode { FIGHT_NORM, FIGHT_RIGHT, FIGHT_LEFT, FIGHT_DEST};
+
+class Explosion;
+
+class Fighter
+{
+ private:
+ Image* pFightr;
+ Image* pFightl;
+ Point aOut;
+ Point aStart;
+ long nMax;
+ FighterMode eMode;
+ BOOL bNoKey;
+ Size aSize;
+ long nDelay;
+
+ public:
+
+ Image* pFight1;
+
+ Fighter(Size& rOut, ResMgr* pRes);
+ ~Fighter();
+ void Paint(OutputDevice& pDev);
+ void Move(long nDirect);
+ Point& GetPoint() { return aOut; }
+ BOOL Kollision(Rectangle, Explosion* pExpl);
+ void Init();
+ void NoFighter() { eMode = FIGHT_DEST; }
+ long GetHalf() { return aOut.X()+aSize.Width()/2; }
+};
+
+enum MuniMode { MUNI_DEL, MUNI_MODE1, MUNI_MODE2 };
+
+#define MUNIY 10
+#define MUNMAX 5
+
+struct Munition_Impl
+{
+ MuniMode eMode;
+ Point aPoint;
+ Rectangle aKoll;
+};
+
+DECLARE_LIST(MunitionListe,Munition_Impl*);
+
+class Munition : public MunitionListe
+{
+ private:
+ Image* pMunition2;
+ Size aSize;
+
+ public:
+
+ Image* pMunition1;
+
+ Munition(ResMgr* pRes);
+ ~Munition();
+ void Paint(OutputDevice& rDev);
+ void Start(Point& rPoint);
+ void SetDelete(long nWert) { GetObject(nWert)->eMode = MUNI_DEL; }
+ Rectangle GetKoll(long nWert) { return GetObject(nWert)->aKoll; }
+ void SetKoll(long nWert, Rectangle aRect)
+ { GetObject(nWert)->aKoll = aRect; }
+ MuniMode GetMode(long nWert) { return GetObject(nWert)->eMode; }
+ void SetMode(long nWert, enum MuniMode mode)
+ { GetObject(nWert)->eMode = mode; }
+ void SetPoint(long nWert, const Point& rPoint)
+ { GetObject(nWert)->aPoint = rPoint; }
+ Point GetPoint(long nWert) { return GetObject(nWert)->aPoint; }
+ long RemoveMunition();
+ void ClearAll();
+};
+
+struct Bombe_Impl
+{
+ Point aXY;
+ Rectangle aKoll;
+ BOOL bDelete;
+};
+
+DECLARE_LIST(BombenListe, Bombe_Impl*);
+
+class Bombe : public BombenListe
+{
+ private:
+ Image* pBombe;
+ Size aSize;
+ long nSpeed;
+
+ public:
+ Bombe(ResMgr* pRes);
+ ~Bombe();
+ void Paint(OutputDevice& rDev);
+ Point& GetPoint(long nWert) { return GetObject(nWert)->aXY; }
+ void SetPoint(long nWert, const Point& rPoint)
+ { GetObject(nWert)->aXY = rPoint; }
+ void InsertBombe(const Point& rPoint);
+ Rectangle GetKoll(long nWert) { return GetObject(nWert)->aKoll; }
+ void SetKoll(long nWert, Rectangle aRect)
+ { GetObject(nWert)->aKoll = aRect; }
+ void SetDelete(long nWert) { GetObject(nWert)->bDelete = TRUE; }
+ void RemoveBomben();
+ void SetSpeed(long nWert) { nSpeed = nWert; }
+ void ClearAll();
+ BOOL Kollision(Rectangle aRect, Explosion* pExpl);
+};
+
+enum WallMode { WALL_MOD1, WALL_MOD2, WALL_MOD3, WALL_MOD4, WALL_MOD5,
+ WALL_MOD6, WALL_MOD7, WALL_MOD8, WALL_MOD9, WALL_MOD10,
+ WALL_DEL };
+struct Wall_Impl
+{
+ Point aXY;
+ WallMode eMode;
+};
+
+DECLARE_LIST(WallListe, Wall_Impl*);
+
+class Wall : public WallListe
+{
+ private:
+ Image* pWall1;
+ Image* pWall2;
+ Image* pWall3;
+ Image* pWall4;
+ Image* pWall5;
+ Image* pWall6;
+ Image* pWall7;
+ Image* pWall8;
+ Image* pWall9;
+ Image* pWall10;
+ Size aSize;
+
+ public:
+ Wall(ResMgr* pRes);
+ ~Wall();
+
+ void Paint(OutputDevice& pDev);
+ WallMode GetMode(long nWert) { return GetObject(nWert)->eMode; }
+ void SetMode(long nWert, enum WallMode Mode)
+ { GetObject(nWert)->eMode = Mode; }
+ Point GetPoint(long nWert) { return GetObject(nWert)->aXY; }
+ void InsertWall(const Point& rPoint);
+ void ClearAll();
+ BOOL Kollision(Rectangle& rRect, BOOL bDel);
+};
+
+#endif
diff --git a/goodies/source/inv/strings.hrc b/goodies/source/inv/strings.hrc
new file mode 100644
index 000000000000..36562aa0eb62
--- /dev/null
+++ b/goodies/source/inv/strings.hrc
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * $RCSfile: strings.hrc,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#define STR_BASE 7000
+#define STR_APP_TITLE (STR_BASE+1)
+#define STR_HERO1 (STR_BASE+2)
+#define STR_HERO2 (STR_BASE+3)
+#define STR_HERO3 (STR_BASE+4)
+#define STR_HERO4 (STR_BASE+5)
+#define STR_HERO5 (STR_BASE+6)
+#define STR_LEVELSTART (STR_BASE+7)
+#define STR_NAME1 (STR_BASE+8)
+#define STR_NAME2 (STR_BASE+9)
+#define STR_NAME3 (STR_BASE+10)
+#define STR_NAME4 (STR_BASE+11)
+#define STR_NAME5 (STR_BASE+12)
+#define STR_ROCKETS (STR_BASE+13)
+#define STR_FIGHTER (STR_BASE+14)
+#define STR_SCORE (STR_BASE+15)
+#define STR_LEVEL (STR_BASE+16)
+#define STR_GRAT1 (STR_BASE+17)
+#define STR_GRAT2 (STR_BASE+18)
+#define STR_FIGHTDEST1 (STR_BASE+19)
+#define STR_FIGHTDEST2 (STR_BASE+20)
+#define STR_GAMEOVER (STR_BASE+21)
+#define STR_HIGHSCORE1 (STR_BASE+22)
+#define STR_HIGHSCORE2 (STR_BASE+23)
+#define STR_HIGHSCORE3 (STR_BASE+24)
+#define STR_PAUSE (STR_BASE+25)
+#define STR_CHOOSEHERO (STR_BASE+26)
+
diff --git a/goodies/source/inv/strings.src b/goodies/source/inv/strings.src
new file mode 100644
index 000000000000..72985606c24f
--- /dev/null
+++ b/goodies/source/inv/strings.src
@@ -0,0 +1,167 @@
+/*************************************************************************
+ *
+ * $RCSfile: strings.src,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include "strings.hrc"
+
+String STR_APP_TITLE {
+ Text = "StarWars Galaxy (c)96 by Updaters / TRI & NF";
+};
+
+String STR_HERO1 {
+ Text = "Eine gute Wahl!\n\nTriminatoren sind Spezialisten in\nder Bekämpfung tötlicher CXXe.";
+};
+
+String STR_HERO2 {
+ Text = "Weise entschieden!\n\nHuge Jelly Stars bekämpfen wirkungsvoll\ngefährliche Makefiles!";
+};
+
+String STR_HERO3 {
+ Text = "Zu dieser Entscheidung ist zu gratulieren!\n\nMega Hunter bekämpfen alles immer überall!";
+};
+
+String STR_HERO4 {
+ Text = "Gut gewählt!\n\nNatural Fighter vernichten gerne tötliche HXXe!";
+};
+
+String STR_HERO5 {
+ Text = "Excellen entschieden!\n\nOverkill GunFighter optimieren jeden Einsatz wirkungsvoll!";
+};
+
+String STR_LEVELSTART {
+ Text = "START LEVEL";
+};
+
+String STR_NAME1 {
+ Text = "Triminator";
+};
+
+String STR_NAME2 {
+ Text = "Huge Jelly Star";
+};
+
+String STR_NAME3 {
+ Text = "Mega Hunter";
+};
+
+String STR_NAME4 {
+ Text = "Natural Fighter";
+};
+
+String STR_NAME5 {
+ Text = "Overkill GunFighter";
+};
+
+String STR_ROCKETS {
+ Text = "Rockets";
+};
+
+String STR_FIGHTER {
+ Text = "Fighter";
+};
+
+String STR_SCORE {
+ Text = "Score";
+};
+
+String STR_LEVEL {
+ Text = "Level";
+};
+
+String STR_GRAT1 {
+ Text = "Gratuliere !!\nSie haben das ";
+};
+
+String STR_GRAT2 {
+ Text = ". Geschwader vernichtet!!\n\nSie erhalten den Orden des inkompatiblen Updates am roten Band!";
+};
+
+String STR_FIGHTDEST1 {
+ Text = "Tod und Teufel !!\n\nIhr Fighter wurde terminiert!\nVerbleibende Waffensysteme im Basislager: ";
+};
+
+String STR_FIGHTDEST2 {
+ Text = "\nViel Glück....";
+};
+
+String STR_GAMEOVER {
+ Text = "Tödlicher Fehler !!\n\nIhr Fighter wurde zerstört!\nSie kommen in den Updaterhimmel...\nBegeben Sie sich direkt dorthin,\nziehen Sie nich über Los,\nziehen Sie nicht DM 4000!\n\nGAME OVER!!!";
+};
+
+String STR_HIGHSCORE1 {
+ Text = "Sie sind ja eine ware Vernichtungsmaschine!\n\nSie haben den Highscore geknackt!\n\nNeuer Highscore: ";
+};
+
+String STR_HIGHSCORE2 {
+ Text = " Punkte\nAlter Highscore: ";
+};
+
+String STR_HIGHSCORE3 {
+ Text = " Punkte";
+};
+
+String STR_PAUSE {
+ Text = " Spiel wegen wichtiger Mussänderung unterbrochen... ";
+};
+
+String STR_CHOOSEHERO {
+ Text = "Choose Your Hero ...";
+};
diff --git a/goodies/source/inv/waves.hxx b/goodies/source/inv/waves.hxx
new file mode 100644
index 000000000000..bcc6c10fc6b7
--- /dev/null
+++ b/goodies/source/inv/waves.hxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * $RCSfile: waves.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:30:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _WAVES_HXX
+#define _WAVES_HXX
+
+#include <tools/solar.h>
+
+#define MAX_LEN 250
+#define WAVES 10
+#define RANMAX 60
+
+#ifdef WIN
+#pragma data_seg( "MY_DATA", "DATA" )
+#endif
+
+USHORT ranpos[RANMAX*2+1] =
+{ 60,
+ 10,20,50,20,90,20,130,20,170,20,210,20,250,20,290,20,330,20,370,20,
+ 30,50,70,50,110,50,150,50,190,50,230,50,270,50,310,50,350,50,390,50,
+ 10,80,50,80,90,80,130,80,170,80,210,80,250,80,290,80,330,80,370,80,
+ 30,110,70,110,110,110,150,110,190,110,230,110,270,110,310,110,350,
+ 110,390,110,
+ 10,140,50,140,90,140,130,140,170,140,210,140,250,140,290,140,330,140,
+ 370,140,
+ 30,170,70,170,110,170,150,170,190,170,230,170,270,170,310,170,350,
+ 170,390,170
+};
+
+USHORT levelpuf[RANMAX*3+2] =
+{ 0, 0, 0, 0, 0};
+
+BYTE waves[WAVES][MAX_LEN] = {
+{ 11, 0, 10, 20, 0, 50, 20, 0, 90, 20, 0, 130, 20, 0, 170, 20,
+ 0, 30, 50, 0, 70, 50, 0, 110, 50, 0, 150, 50, 0, 190, 50,
+ 4,100, 200,
+ 240, 240, 0 },
+{ 12, 1, 10, 20, 1, 50, 20, 1, 90, 20, 1, 130, 20, 1, 170, 20,
+ 1, 30, 50, 1, 70, 50, 1, 110, 50, 1, 150, 50, 1, 190, 50,
+ 4,80, 200, 4,120,200,
+ 15, 15, 15 },
+{ 13, 2, 10, 20, 2, 50, 20, 2, 90, 20, 2, 130, 20, 2, 170, 20,
+ 2, 30, 50, 2, 70, 50, 2, 110, 50, 2, 150, 50, 2, 190, 50,
+ 4,5,250, 4,100,190, 4,200,230,
+ 240, 240, 0 },
+{ 14, 3, 10, 20, 3, 50, 20, 3, 90, 20, 3, 130, 20, 3, 170, 20,
+ 3, 30, 50, 3, 70, 50, 3, 110, 50, 3, 150, 50, 3, 190, 50,
+ 4, 10,190, 4,50,240, 4,120,250, 4, 180,210,
+ 15, 15, 15 },
+{ 25, 0, 10, 50, 0, 10, 90, 0, 10, 130,
+ 1, 50, 30, 1, 50, 70, 1, 50, 110,
+ 2, 90, 10, 1, 90, 50, 2, 90, 90,
+ 3,130, 10, 3,130, 50, 3,130, 90,
+ 2,170, 10, 1,170, 50, 2,170, 90,
+ 1,210, 30, 1,210, 70, 1,210, 110,
+ 0,250, 50, 0,250, 90, 0,250, 130,
+ 4, 211, 211, 4, 215, 115, 4, 230,230, 4,198, 210,
+ 15, 6, 15 },
+{ 18, 3, 10, 10, 3, 50, 10, 3, 90, 10, 3, 130, 10, 3, 170, 10,
+ 2, 30, 50, 2, 70 , 50, 2, 110, 50, 2, 150, 50,
+ 4,10,90,1, 50, 90, 1, 90, 90, 1, 130, 90,
+ 0, 70, 130, 0, 110, 130,4,150,110,
+ 0, 90, 170, 4, 120, 200,
+ 240, 255, 0 },
+{ 15, 0, 50, 50, 0, 100, 50, 0, 150, 50, 0, 200, 50, 0, 250, 50,
+ 2, 50, 100, 2, 150, 100, 2, 250, 100,
+ 3, 100, 150, 3, 200, 150,
+ 0, 50, 200, 1, 100, 200, 0, 150, 200, 1, 200, 200, 0, 250 ,200,
+ 255, 249, 15 },
+{ 20, 1, 10, 20, 1, 50, 20, 1, 90, 20, 1, 130, 20, 1, 170, 20,
+ 1, 30, 50, 1, 70, 50, 1, 110, 50, 1, 150, 50, 1, 190, 50,
+ 2, 10, 80, 2, 50, 80, 2, 90, 80, 2, 130, 80, 2, 170, 80,
+ 2, 30, 110, 2, 70, 110, 2, 110, 110, 2, 150, 110, 2, 190, 110,
+ 240, 240, 0 },
+
+{ 40, 0, 10, 20, 0, 50, 20, 0, 90, 20, 0, 130, 20, 0, 170, 20,
+ 0, 30, 50, 0, 70, 50, 0, 110, 50, 0, 150, 50, 0, 190, 50,
+ 1, 10, 80, 1, 50, 80, 1, 90, 80, 1, 130, 80, 1, 170, 80,
+ 1, 30, 110, 1, 70, 110, 1, 110, 110, 1, 150, 110, 1, 190, 110,
+ 2, 10, 140, 2, 50, 140, 2, 90, 140, 2, 130, 140, 2, 170, 140,
+ 0, 30, 170, 0, 70, 170, 0, 110, 170, 0, 150, 170, 0, 190, 170,
+ 3, 10, 200, 3, 50, 200, 3, 90, 200, 3, 130, 200, 3, 170, 200,
+ 0, 30, 230, 0, 70, 230, 0, 110, 230, 0, 150, 230, 0, 190, 230,
+ 15, 15, 15 },
+{ 64, 0, 5, 5, 0, 40, 5, 0, 75, 5, 0, 110, 5, 0, 145, 5, 0, 180, 5, 0, 215, 5, 0, 250, 5,
+ 0, 5, 40, 0, 40, 40, 0, 75, 40, 0, 110, 40, 0, 145, 40, 0, 180, 40, 0, 215, 40, 0, 250, 40,
+ 0, 5, 75, 1, 40, 75, 2, 75, 75, 2, 110, 75, 2, 145, 75, 2, 180, 75, 1, 215, 75, 0, 250, 75,
+ 0, 5, 110, 1, 40, 110, 2, 75, 110, 0, 110, 110, 3, 145, 110, 2, 180, 110, 1, 215, 110, 0, 250, 110,
+ 0, 5, 145, 1, 40, 145, 2, 75, 145, 3, 110, 145, 0, 145, 145, 2, 180, 145, 1, 215, 145, 0, 250, 145,
+ 0, 5, 180, 1, 40, 180, 2, 75, 180, 2, 110, 180, 2, 145, 180, 2, 180, 180, 1, 215, 180, 0, 250, 180,
+ 0, 5, 215, 0, 40, 215, 0, 75, 215, 0, 110, 215, 0, 145, 215, 0, 180, 215, 0, 215, 215, 0, 250, 215,
+ 0, 5, 250, 0, 40, 250, 0, 75, 250, 0, 110, 250, 0, 145, 250, 0, 180, 250, 0, 215, 250, 0, 250, 250,
+ 255, 255, 255 },
+};
+#endif