diff options
Diffstat (limited to 'svtools/source/filter.vcl')
41 files changed, 23448 insertions, 0 deletions
diff --git a/svtools/source/filter.vcl/filter/dlgejpg.cxx b/svtools/source/filter.vcl/filter/dlgejpg.cxx new file mode 100644 index 000000000000..3bd89b7f0c13 --- /dev/null +++ b/svtools/source/filter.vcl/filter/dlgejpg.cxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * $RCSfile: dlgejpg.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 "dlgejpg.hxx" +#include "dlgejpg.hrc" +#include "strings.hrc" + +#define KEY_QUALITY "JPG-EXPORT-QUALITY" +#define KEY_GRAYSCALES "JPG_EXPORT_COLORMODE" + +/************************************************************************* +|* +|* Ctor +|* +\************************************************************************/ + +DlgExportEJPG::DlgExportEJPG( FltCallDialogParameter& rPara ) : + ModalDialog ( rPara.pWindow, ResId( DLG_EXPORT_JPG, rPara.pResMgr ) ), + aFiDescr ( this, ResId( FI_DESCR ) ), + aNumFldQuality ( this, ResId( NUM_FLD_QUALITY ) ), + aGrpQuality ( this, ResId( GRP_QUALITY ) ), + aRbGray ( this, ResId( RB_GRAY ) ), + aRbRGB ( this, ResId( RB_RGB ) ), + aGrpColors ( this, ResId( GRP_COLORS ) ), + 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 + ByteString aStr( pConfig->ReadKey( KEY_QUALITY ) ); + + if ( !aStr.Len() ) + aNumFldQuality.SetValue( 75 ); + else + aNumFldQuality.SetValue( aStr.ToInt32() ); + + if ( pConfig->ReadKey( KEY_GRAYSCALES ).ToInt32() ) + aRbGray.Check( TRUE ); + else + aRbRGB.Check( TRUE ); + + aBtnOK.SetClickHdl( LINK( this, DlgExportEJPG, OK ) ); +} + + +/************************************************************************* +|* +|* Speichert eingestellte Werte in ini-Datei +|* +\************************************************************************/ + +IMPL_LINK( DlgExportEJPG, OK, void *, EMPTYARG ) +{ + // Config-Parameter schreiben + pConfig->WriteKey( KEY_QUALITY, ByteString::CreateFromInt32( (long)aNumFldQuality.GetValue() ) ); + pConfig->WriteKey( KEY_GRAYSCALES, ByteString::CreateFromInt32( (sal_Int32)aRbGray.IsChecked() ) ); + + EndDialog( RET_OK ); + + return 0; +} + + + diff --git a/svtools/source/filter.vcl/filter/dlgejpg.hrc b/svtools/source/filter.vcl/filter/dlgejpg.hrc new file mode 100644 index 000000000000..f93826427388 --- /dev/null +++ b/svtools/source/filter.vcl/filter/dlgejpg.hrc @@ -0,0 +1,73 @@ +/************************************************************************* + * + * $RCSfile: dlgejpg.hrc,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 "svtools.hrc" + +#define BTN_OK 1 +#define BTN_CANCEL 1 +#define BTN_HELP 1 +#define FI_DESCR 1 +#define NUM_FLD_QUALITY 1 +#define GRP_QUALITY 1 +#define GRP_COLORS 2 +#define RB_GRAY 1 +#define RB_RGB 2 + + diff --git a/svtools/source/filter.vcl/filter/dlgejpg.hxx b/svtools/source/filter.vcl/filter/dlgejpg.hxx new file mode 100644 index 000000000000..faddda9c262e --- /dev/null +++ b/svtools/source/filter.vcl/filter/dlgejpg.hxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * $RCSfile: dlgejpg.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 _DLGEJPG_HXX_ +#define _DLGEJPG_HXX_ + +#include <vcl/dialog.hxx> +#include <vcl/button.hxx> +#include <vcl/fixed.hxx> +#include <vcl/field.hxx> +#include <vcl/group.hxx> +#include <vcl/lstbox.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/config.hxx> +#include "stdctrl.hxx" +#include <fltcall.hxx> + +/************************************************************************* +|* +|* Dialog zum Einstellen von Filteroptionen +|* +\************************************************************************/ +class DlgExportEJPG : public ModalDialog +{ +private: + FixedInfo aFiDescr; + NumericField aNumFldQuality; + GroupBox aGrpQuality; + RadioButton aRbGray; + RadioButton aRbRGB; + GroupBox aGrpColors; + OKButton aBtnOK; + CancelButton aBtnCancel; + HelpButton aBtnHelp; + + Config* pConfig; + ResMgr* pMgr; + + DECL_LINK( OK, void * ); + +public: + DlgExportEJPG( FltCallDialogParameter& rDlgPara ); +}; + +#endif // _DLGEJPG_HXX_ + diff --git a/svtools/source/filter.vcl/filter/dlgejpg.src b/svtools/source/filter.vcl/filter/dlgejpg.src new file mode 100644 index 000000000000..11cbffb37255 --- /dev/null +++ b/svtools/source/filter.vcl/filter/dlgejpg.src @@ -0,0 +1,266 @@ +/************************************************************************* + * + * $RCSfile: dlgejpg.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 "dlgejpg.hrc" +ModalDialog DLG_EXPORT_JPG +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 159 , 111 ) ; + Text = "JPEG Optionen" ; + Text [ ENGLISH ] = "JPEG Optionen" ; + Text [ english_us ] = "JPEG Options" ; + Text [ italian ] = "Opzioni JPEG" ; + Text [ spanish ] = "Opciones JPEG" ; + Text [ french ] = "Options JPEG" ; + Text [ dutch ] = "JPEG-opties" ; + Text [ swedish ] = "JPEG-alternativ" ; + Text [ danish ] = "JPEG-indstillinger" ; + Moveable = TRUE ; + Closeable = TRUE ; + OKButton BTN_OK + { + Pos = MAP_APPFONT ( 103 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton BTN_CANCEL + { + Pos = MAP_APPFONT ( 103 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + HelpButton BTN_HELP + { + Pos = MAP_APPFONT ( 103 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + GroupBox GRP_QUALITY + { + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 90 , 55 ) ; + Text = "Qualität" ; + Text [ ENGLISH ] = "Quality" ; + Text [ english_us ] = "Quality" ; + Text [ italian ] = "Qualità" ; + Text [ spanish ] = "Calidad" ; + Text [ french ] = "Qualité" ; + Text [ dutch ] = "Kwaliteit" ; + Text [ swedish ] = "Kvalitet" ; + Text [ danish ] = "Kvalitet" ; + Text [ portuguese_brazilian ] = "Qualität" ; + Text [ portuguese ] = "Qualidade" ; + Text[ chinese_simplified ] = "ÖÊÁ¿"; + Text[ russian ] = "Êà÷åñòâî"; + Text[ polish ] = "Jakoœæ"; + Text[ japanese ] = "‰æ‘œ•iŽ¿"; + Text[ chinese_traditional ] = "½è¶q"; + Text[ arabic ] = "ÇáÌæÏÉ"; + Text[ dutch ] = "Kwaliteit"; + Text[ chinese_simplified ] = "ÖÊÁ¿"; + Text[ greek ] = "Ðïéüôçôá"; + Text[ korean ] = "ÈÁú"; + Text[ turkish ] = "Kalite"; + Text[ language_user1 ] = " "; + }; + FixedText FI_DESCR + { + Pos = MAP_APPFONT ( 12 , 15 ) ; + Size = MAP_APPFONT ( 81 , 21 ) ; + Text = "0: min. Qualität\n100: max. Qualität" ; + Text [ ENGLISH ] = "0: min. quality\n100: max. quality" ; + Text [ english_us ] = "0: min. Quality\n100: max. Quality" ; + Text [ italian ] = "Q: min. qualità\n100: max. qualità" ; + Text [ spanish ] = "0: mín. calidad\n100: máx. calidad" ; + Text [ french ] = "0: qualité min.\n100: qualité max." ; + Text [ dutch ] = "0: min. kwaliteit\n100: max. kwaliteit" ; + Text [ swedish ] = "0: min. kvalitet\n100: max. kvalitet" ; + Text [ danish ] = "0: min. kvalitet\n100: maks. kvalitet" ; + Text [ portuguese_brazilian ] = "0: min. Qualidade\n100: max. Qualidade" ; + Text [ portuguese ] = "0: min. Qualidade\n100: max. Qualidade" ; + Text[ chinese_simplified ] = "0: ×î²î \n100: ×î¼Ñ¡¡"; + Text[ russian ] = "0: íèçêîå êà÷åñòâî\n100: âûñîêîå êà÷åñòâî"; + Text[ polish ] = "0: min. jakoœæ\n100: max. jakoœæ"; + Text[ japanese ] = "0: Å’á\n100: Å‚"; + Text[ chinese_traditional ] = "0: ³Ì®t \n100: ³Ì¨Î¡@"; + Text[ arabic ] = "0: ÇáÍÏ ÇáÃÏäì ááÌæÏÉ\n100: ÇáÍÏ ÇáÃÞÕì ááÌæÏÉ"; + Text[ dutch ] = "0: min. kwaliteit\n100: max. kwaliteit"; + Text[ chinese_simplified ] = "0: ×î²î \n100: ×î¼Ñ¡¡"; + Text[ greek ] = "0: åëÜ÷éóôç ðïéüôçôá\n100: ìÝãéóôç ðïéüôçôá"; + Text[ korean ] = "0: ÃÖ¼Ò ¼º´É\n100: ÃÖ´ë ¼º´É"; + Text[ turkish ] = "0: asg. kalite\n100: azm. kalite"; + Text[ language_user1 ] = " "; + }; + NumericField NUM_FLD_QUALITY + { + Border = TRUE ; + Pos = MAP_APPFONT ( 12 , 40 ) ; + Size = MAP_APPFONT ( 50 , 12 ) ; + TabStop = TRUE ; + Spin = TRUE ; + Maximum = 100 ; + StrictFormat = TRUE ; + Last = 100 ; + Repeat = TRUE ; + }; + GroupBox GRP_COLORS + { + Pos = MAP_APPFONT ( 6 , 61 ) ; + Size = MAP_APPFONT ( 90 , 44 ) ; + Text = "Farbauflösung" ; + Text [ ENGLISH ] = "Color resolution" ; + Text [ english_us ] = "Color resolution" ; + Text [ portuguese_brazilian ] = "Farbauflösung" ; + Text [ swedish ] = "Färgupplösning" ; + Text [ danish ] = "Farveopløsning" ; + Text [ italian ] = "Profondità cromatica" ; + Text [ spanish ] = "Resolución del color" ; + Text [ french ] = "Résolution couleur" ; + Text [ dutch ] = "Kleurdichtheid" ; + Text [ portuguese ] = "Resolução de cores" ; + Text[ chinese_simplified ] = "ÑÕÉ«·Ö±æÂÊ"; + Text[ russian ] = "Öâåòîâîå ðàçðåøåíèå"; + Text[ polish ] = "Rozdzielczoœæ kolorów"; + Text[ japanese ] = "F‚̉𑜓x"; + Text[ chinese_traditional ] = "ÃC¦â¸ÑªR«×"; + Text[ arabic ] = "ÇÓÊÈÇäÉ Çááæä"; + Text[ dutch ] = "Kleurdichtheid"; + Text[ chinese_simplified ] = "ÑÕÉ«·Ö±æÂÊ"; + Text[ greek ] = "ÁíÜëõóç ÷ñùìÜôùí"; + Text[ korean ] = "Ä÷¯ ÇØ»óµµ"; + Text[ turkish ] = "Renk çözünürlüðü"; + Text[ language_user1 ] = " "; + }; + RadioButton RB_GRAY + { + Pos = MAP_APPFONT ( 12 , 72 ) ; + Size = MAP_APPFONT ( 81 , 12 ) ; + TabStop = TRUE ; + Text = "Graustufen" ; + Text [ ENGLISH ] = "Grayscales" ; + Text [ english_us ] = "Grayscale" ; + Text [ portuguese ] = "Tons de cinzento" ; + Text [ portuguese_brazilian ] = "Graustufen" ; + Text [ swedish ] = "Gråskalor" ; + Text [ danish ] = "Gråtoner" ; + Text [ italian ] = "Toni di grigio" ; + Text [ spanish ] = "Escala de grises" ; + Text [ french ] = "Niveaux de gris" ; + Text [ dutch ] = "Grijswaarden" ; + Text[ chinese_simplified ] = "»Ò¶È"; + Text[ russian ] = "Îòòåíêè ñåðîãî"; + Text[ polish ] = "Odcienie szaroœci"; + Text[ japanese ] = "¸ÞÚ°½¹°Ù"; + Text[ chinese_traditional ] = "¦Ç«×"; + Text[ arabic ] = "ÏÑÌÇÊ ÇáÑãÇÏí"; + Text[ dutch ] = "Grijswaarden"; + Text[ chinese_simplified ] = "»Ò¶È"; + Text[ greek ] = "ÄéáâÜèìéóç ôïõ ãêñé"; + Text[ korean ] = "ȸ»öÁ¶"; + Text[ turkish ] = "Gri tonlama"; + Text[ language_user1 ] = " "; + }; + RadioButton RB_RGB + { + Pos = MAP_APPFONT ( 12 , 87 ) ; + Size = MAP_APPFONT ( 81 , 12 ) ; + TabStop = TRUE ; + Text = "Echtfarben" ; + Text [ ENGLISH ] = "TrueColors" ; + Text [ english_us ] = "True Colors" ; + Text [ portuguese ] = "Cores reais" ; + Text [ portuguese_brazilian ] = "Echtfarben" ; + Text [ swedish ] = "True Colors" ; + Text [ danish ] = "Ægte farver" ; + Text [ italian ] = "Colori reali" ; + Text [ spanish ] = "Colores reales" ; + Text [ french ] = "Vraies couleurs (Truecolor)" ; + Text [ dutch ] = "Echte kleuren" ; + Text[ chinese_simplified ] = "·ÂÕæÉ«"; + Text[ russian ] = "Íàòóðàëüíûå öâåòà"; + Text[ polish ] = "Trwa³e kolory"; + Text[ japanese ] = "‘NÊF"; + Text[ chinese_traditional ] = "¥þ±m"; + Text[ arabic ] = "ÃáæÇä ÍÞíÞíÉ"; + Text[ dutch ] = "Echte kleuren"; + Text[ chinese_simplified ] = "·ÂÕæÉ«"; + Text[ greek ] = "ÖõóéêÜ ÷ñþìáôá"; + Text[ korean ] = "Æ®·ç Ä÷¯"; + Text[ turkish ] = "Gerçek renkler"; + Text[ language_user1 ] = " "; + }; + Text [ portuguese_brazilian ] = "JPEG Optionen" ; + Text [ portuguese ] = "Opções JPEG" ; + Text[ chinese_simplified ] = "JPEG Ñ¡Ïî"; + Text[ russian ] = "Ïàðàìåòðû JPEG"; + Text[ polish ] = "Opcje JPEG"; + Text[ japanese ] = "JPEG µÌß¼®Ý"; + Text[ chinese_traditional ] = "JPEG ¿ï¶µ"; + Text[ arabic ] = "ÎíÇÑÇÊJPEG "; + Text[ dutch ] = "JPEG-opties"; + Text[ chinese_simplified ] = "JPEG Ñ¡Ïî"; + Text[ greek ] = "ÅðéëïãÝò JPEG"; + Text[ korean ] = "JPEG ¿É¼Ç"; + Text[ turkish ] = "JPEG seçenekleri"; + Text[ language_user1 ] = " "; +}; diff --git a/svtools/source/filter.vcl/filter/dlgexpor.cxx b/svtools/source/filter.vcl/filter/dlgexpor.cxx new file mode 100644 index 000000000000..1f53a52914db --- /dev/null +++ b/svtools/source/filter.vcl/filter/dlgexpor.cxx @@ -0,0 +1,517 @@ +/************************************************************************* + * + * $RCSfile: dlgexpor.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 "dlgexpor.hxx" +#include "dlgexpor.hrc" +#include "strings.hrc" + +/************************************************************************* +|* +|* Ctor +|* +\************************************************************************/ + +DlgExportPix::DlgExportPix( FltCallDialogParameter& rPara ) : + ModalDialog ( rPara.pWindow, ResId( DLG_EXPORT_PIX, rPara.pResMgr ) ), + aBtnOK ( this, ResId( BTN_OK_PIX ) ), + aBtnCancel ( this, ResId( BTN_CANCEL_PIX ) ), + aBtnHelp ( this, ResId( BTN_HELP_PIX ) ), + aGrpMode ( this, ResId( GRP_MODE_PIX ) ), + aCbbRes ( this, ResId( CBB_RES_PIX ) ), + aRbOriginal ( this, ResId( RB_ORIGINAL_PIX ) ), + aRbRes ( this, ResId( RB_RES_PIX ) ), + aRbSize ( this, ResId( RB_SIZE_PIX ) ), + aFtSizeX ( this, ResId( FT_SIZEX_PIX ) ), + aMtfSizeX ( this, ResId( MTF_SIZEX_PIX ) ), + aFtSizeY ( this, ResId( FT_SIZEY_PIX ) ), + aMtfSizeY ( this, ResId( MTF_SIZEY_PIX ) ), + aGrpColors ( this, ResId( GRP_COLORS ) ), + aLbColors ( this, ResId( LB_COLORS ) ), + aCbxRLE ( this, ResId( CBX_RLE ) ), + pConfig ( rPara.pCfg ), + pMgr ( rPara.pResMgr ), + rExt ( rPara.aFilterExt ) + +{ + String aTitle( rExt ); + + FreeResource(); + + aBtnOK.SetClickHdl( LINK( this, DlgExportPix, OK ) ); + aRbOriginal.SetClickHdl( LINK( this, DlgExportPix, ClickRbOriginal ) ); + aRbRes.SetClickHdl( LINK( this, DlgExportPix, ClickRbRes ) ); + aRbSize.SetClickHdl( LINK( this, DlgExportPix, ClickRbSize ) ); + aLbColors.SetSelectHdl( LINK( this, DlgExportPix, SelectLbColors ) ); + + aTitle.ToUpperAscii(); + aTitle += String( ResId( EXPORT_DIALOG_TITLE, pMgr ) ); + SetText( aTitle ); + + + // Config-Parameter lesen + ByteString aStrColors( rExt, RTL_TEXTENCODING_UTF8 ); + aStrColors.Append( ByteString( String( ResId( KEY_COLORS, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + aStrColors = pConfig->ReadKey( aStrColors ); + ByteString aStrMode( rExt, RTL_TEXTENCODING_UTF8 ); + aStrMode.Append( ByteString( String( ResId( KEY_MODE, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + aStrMode = pConfig->ReadKey( aStrMode ); + ByteString aStrRes( rExt, RTL_TEXTENCODING_UTF8 ); + aStrRes.Append( ByteString( String( ResId( KEY_RES, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + aStrRes = pConfig->ReadKey( aStrRes ); + ByteString aStrSizeX( rExt, RTL_TEXTENCODING_UTF8 ); + aStrSizeX.Append( ByteString( String( ResId( KEY_SIZEX, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + aStrSizeX = pConfig->ReadKey( aStrSizeX ); + ByteString aStrSizeY( rExt, RTL_TEXTENCODING_UTF8 ); + aStrSizeY.Append( ByteString( String( ResId( KEY_SIZEY, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + aStrSizeY = pConfig->ReadKey( aStrSizeY ); + ByteString aStrRLE( rExt, RTL_TEXTENCODING_UTF8 ); + aStrRLE.Append( ByteString( String( ResId( KEY_RLE_CODING, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + aStrRLE = pConfig->ReadKey( aStrRLE ); + + aLbColors.SelectEntryPos( Min( (USHORT) 7, (USHORT)aStrColors.ToInt32() ) ); + aCbxRLE.Check( aStrRLE.CompareIgnoreCaseToAscii( "false", 5 ) == COMPARE_EQUAL ); + + if ( !aStrRes.Len() ) + aStrRes = 75; + + aStrRes += " DPI"; + aCbbRes.SetText( UniString( aStrRes, 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; + } + + switch ( aStrMode.ToInt32() ) + { + case 2 : + { + aRbSize.Check( TRUE ); + ClickRbSize( NULL ); + } + break; + case 1 : + { + aRbRes.Check( TRUE ); + ClickRbRes( NULL ); + } + break; + default : + { + aRbOriginal.Check( TRUE ); + ClickRbOriginal( NULL ); + } + break; + } + SelectLbColors( &aLbColors ); +} + +/************************************************************************* +|* +|* Speichert eingestellte Werte in ini-Datei +|* +\************************************************************************/ + +IMPL_LINK( DlgExportPix, OK, void *, EMPTYARG ) +{ + // Config-Parameter schreiben + + ByteString aStrMode; + ByteString aRLEStr; + + long nRes = Max( Min( aCbbRes.GetText().ToInt32(), 600L), 75L ); + long nSizeX = (long)MetricField::ConvertDoubleValue( aMtfSizeX.GetValue(), 2, aMtfSizeX.GetUnit(), MAP_100TH_MM ); + long nSizeY = (long)MetricField::ConvertDoubleValue( aMtfSizeY.GetValue(), 2, aMtfSizeY.GetUnit(), MAP_100TH_MM ); + + if ( aRbRes.IsChecked() ) + aStrMode = '1'; + else if ( aRbSize.IsChecked() ) + aStrMode = '2'; + else + aStrMode = '0'; + + if ( aCbxRLE.IsChecked() ) + aRLEStr = ByteString( "TRUE", 4 ); + else + aRLEStr = ByteString( "FALSE", 5 ); + + ByteString aExt0( rExt, RTL_TEXTENCODING_UTF8 ); + aExt0.Append( ByteString( String( ResId( KEY_MODE, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + pConfig->WriteKey( aExt0, aStrMode ); + + ByteString aExt1( rExt, RTL_TEXTENCODING_UTF8 ); + aExt1.Append( ByteString( String( ResId( KEY_RES, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + pConfig->WriteKey( aExt1, ByteString::CreateFromInt32( nRes ) ); + + ByteString aExt2( rExt, RTL_TEXTENCODING_UTF8 ); + aExt2.Append( ByteString( String( ResId( KEY_SIZEX, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + pConfig->WriteKey( aExt2, ByteString::CreateFromInt32( nSizeX ) ); + + ByteString aExt3( rExt, RTL_TEXTENCODING_UTF8 ); + aExt3.Append( ByteString( String( ResId( KEY_SIZEY, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + pConfig->WriteKey( aExt3, ByteString::CreateFromInt32( nSizeY ) ); + + ByteString aExt4( rExt, RTL_TEXTENCODING_UTF8 ); + aExt4.Append( ByteString( String( ResId( KEY_COLORS, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + pConfig->WriteKey( aExt4, ByteString::CreateFromInt32( (sal_Int32)aLbColors.GetSelectEntryPos() ) ); + + ByteString aExt5( rExt, RTL_TEXTENCODING_UTF8 ); + aExt5.Append( ByteString( String( ResId( KEY_RLE_CODING, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + pConfig->WriteKey( aExt5, ByteString::CreateFromInt32( (sal_Int32)aLbColors.GetSelectEntryPos() ) ); + + EndDialog( RET_OK ); + + return 0; +} + +/************************************************************************* +|* +|* Enabled/Disabled Controls +|* +\************************************************************************/ + +IMPL_LINK( DlgExportPix, ClickRbOriginal, void*, EMPTYARG ) +{ + aCbbRes.Disable(); + + aFtSizeX.Disable(); + aMtfSizeX.Disable(); + aFtSizeY.Disable(); + aMtfSizeY.Disable(); + + return 0; +} + + +/************************************************************************* +|* +|* Enabled/Disabled Controls +|* +\************************************************************************/ + +IMPL_LINK( DlgExportPix, ClickRbRes, void*, EMPTYARG ) +{ + aCbbRes.Enable(); + + aFtSizeX.Disable(); + aMtfSizeX.Disable(); + aFtSizeY.Disable(); + aMtfSizeY.Disable(); + + return 0; +} + + +/************************************************************************* +|* +|* Enabled/Disabled Controls +|* +\************************************************************************/ + +IMPL_LINK( DlgExportPix, ClickRbSize, void*, EMPTYARG ) +{ + aFtSizeX.Enable(); + aMtfSizeX.Enable(); + aFtSizeY.Enable(); + aMtfSizeY.Enable(); + + aCbbRes.Disable(); + + return 0; +} + + +/************************************************************************* +|* +|* Enabled/Disabled Controls +|* +\************************************************************************/ + +IMPL_LINK( DlgExportPix, SelectLbColors, void*, EMPTYARG ) +{ + const USHORT nLbPos = aLbColors.GetSelectEntryPos(); + + if ( ( nLbPos >= 3 ) && ( nLbPos <= 6 ) ) + aCbxRLE.Enable(); + else + aCbxRLE.Disable(); + + return 0L; +} + + +/******************************************************************************/ + + +/************************************************************************* +|* +|* Ctor +|* +\************************************************************************/ + +DlgExportVec::DlgExportVec( FltCallDialogParameter& rPara ) : + ModalDialog ( rPara.pWindow, ResId( DLG_EXPORT_VEC, rPara.pResMgr ) ), + aBtnOK ( this, ResId( BTN_OK_VEC ) ), + aBtnCancel ( this, ResId( BTN_CANCEL_VEC ) ), + aBtnHelp ( this, ResId( BTN_HELP_VEC ) ), + aRbOriginal ( this, ResId( RB_ORIGINAL_VEC ) ), + aRbSize ( this, ResId( RB_SIZE_VEC ) ), + aGrpMode ( this, ResId( GRP_MODE_VEC ) ), + aFtSizeX ( this, ResId( FT_SIZEX_VEC ) ), + aMtfSizeX ( this, ResId( MTF_SIZEX_VEC ) ), + aFtSizeY ( this, ResId( FT_SIZEY_VEC ) ), + aMtfSizeY ( this, ResId( MTF_SIZEY_VEC ) ), + aGrpSize ( this, ResId( GRP_SIZE_VEC ) ), + pConfig ( rPara.pCfg ), + pMgr ( rPara.pResMgr ), + rExt ( rPara.aFilterExt ) + +{ + String aTitle( rExt ); + + FreeResource(); + + aBtnOK.SetClickHdl( LINK( this, DlgExportVec, OK ) ); + aRbOriginal.SetClickHdl( LINK( this, DlgExportVec, ClickRbOriginal ) ); + aRbSize.SetClickHdl( LINK( this, DlgExportVec, ClickRbSize ) ); + + aTitle.ToUpperAscii(); + aTitle += String( ResId( EXPORT_DIALOG_TITLE, pMgr ) ); + SetText( aTitle ); + + // Config-Parameter lesen + // String aStrMode = pConfig->ReadKey( rExt + String( ResId( KEY_MODE, pMgr ) ) ); + ByteString aExt( rExt, RTL_TEXTENCODING_UTF8 ); + ByteString aStrMode( aExt ); + aStrMode.Append( ByteString( String( ResId( KEY_MODE, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + aStrMode = pConfig->ReadKey( aStrMode ); + + ByteString aStrSizeX( aExt ); + aStrSizeX.Append( ByteString( String( ResId( KEY_SIZEX, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + aStrSizeX = pConfig->ReadKey( aStrSizeX ); + + ByteString aStrSizeY( aExt ); + aStrSizeY.Append( ByteString( String( ResId( KEY_SIZEY, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + aStrSizeY = pConfig->ReadKey( aStrSizeY ); + + 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_MM : + case FUNIT_CM : + case FUNIT_M : + 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; + } + + switch ( aStrMode.ToInt32() ) + { + case 1 : + { + aRbSize.Check( TRUE ); + ClickRbSize( NULL ); + } + break; + + default : + { + aRbOriginal.Check( TRUE ); + ClickRbOriginal( NULL ); + } + break; + } +} + +/************************************************************************* +|* +|* Speichert eingestellte Werte in ini-Datei +|* +\************************************************************************/ + +IMPL_LINK( DlgExportVec, OK, void *, EMPTYARG ) +{ + // Config-Parameter schreiben + long nSizeX = (long)MetricField::ConvertDoubleValue( aMtfSizeX.GetValue(), 2, aMtfSizeX.GetUnit(), MAP_100TH_MM ); + long nSizeY = (long)MetricField::ConvertDoubleValue( aMtfSizeY.GetValue(), 2, aMtfSizeY.GetUnit(), MAP_100TH_MM ); + + ByteString aStrMode; + if ( aRbSize.IsChecked() ) + aStrMode = '1'; + else + aStrMode = '0'; + + ByteString aExt( rExt, RTL_TEXTENCODING_UTF8 ); + ByteString aDest( aExt ); + aDest.Append( ByteString( String( ResId( KEY_MODE, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + pConfig->WriteKey( aDest, aStrMode ); + + aDest = aExt; + aDest.Append( ByteString( String( ResId( KEY_SIZEX, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + pConfig->WriteKey( aDest, ByteString::CreateFromInt32( nSizeX ) ); + + aDest = aExt; + aDest.Append( ByteString( String( ResId( KEY_SIZEY, pMgr ) ), RTL_TEXTENCODING_UTF8 ) ); + pConfig->WriteKey( aDest, ByteString::CreateFromInt32( nSizeY ) ); + + EndDialog( RET_OK ); + + return 0; +} + +/************************************************************************* +|* +|* Enabled/Disabled Controls +|* +\************************************************************************/ + +IMPL_LINK( DlgExportVec, ClickRbOriginal, void*, EMPTYARG ) +{ + aGrpSize.Disable(); + aFtSizeX.Disable(); + aMtfSizeX.Disable(); + aFtSizeY.Disable(); + aMtfSizeY.Disable(); + + return 0; +} + + +/************************************************************************* +|* +|* Enabled/Disabled Controls +|* +\************************************************************************/ + +IMPL_LINK( DlgExportVec, ClickRbSize, void*, EMPTYARG ) +{ + aGrpSize.Enable(); + aFtSizeX.Enable(); + aMtfSizeX.Enable(); + aFtSizeY.Enable(); + aMtfSizeY.Enable(); + + return 0; +} + + + diff --git a/svtools/source/filter.vcl/filter/dlgexpor.hrc b/svtools/source/filter.vcl/filter/dlgexpor.hrc new file mode 100644 index 000000000000..cf35e9785666 --- /dev/null +++ b/svtools/source/filter.vcl/filter/dlgexpor.hrc @@ -0,0 +1,92 @@ +/************************************************************************* + * + * $RCSfile: dlgexpor.hrc,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 <svtools.hrc> + +#define BTN_OK_PIX 1 +#define BTN_CANCEL_PIX 1 +#define BTN_HELP_PIX 1 +#define CBX_RES_PIX 1 +#define CBX_SIZE_PIX 2 +#define CBX_RLE 3 +#define CBB_RES_PIX 1 +#define LB_COLORS 1 +#define MTF_SIZEX_PIX 1 +#define MTF_SIZEY_PIX 2 +#define FT_SIZEX_PIX 1 +#define FT_SIZEY_PIX 2 +#define GRP_MODE_PIX 1 +#define GRP_COLORS 4 +#define RB_ORIGINAL_PIX 1 +#define RB_RES_PIX 2 +#define RB_SIZE_PIX 3 + +#define BTN_OK_VEC 1 +#define BTN_CANCEL_VEC 1 +#define BTN_HELP_VEC 1 +#define CBX_SIZE_VEC 2 +#define MTF_SIZEX_VEC 1 +#define MTF_SIZEY_VEC 2 +#define FT_SIZEX_VEC 1 +#define FT_SIZEY_VEC 2 +#define GRP_SIZE_VEC 1 +#define GRP_MODE_VEC 2 +#define RB_ORIGINAL_VEC 1 +#define RB_SIZE_VEC 2 diff --git a/svtools/source/filter.vcl/filter/dlgexpor.hxx b/svtools/source/filter.vcl/filter/dlgexpor.hxx new file mode 100644 index 000000000000..2b1e59922d6b --- /dev/null +++ b/svtools/source/filter.vcl/filter/dlgexpor.hxx @@ -0,0 +1,152 @@ +/************************************************************************* + * + * $RCSfile: dlgexpor.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 _DLGEXPOR_HXX_ +#define _DLGEXPOR_HXX_ + +#include "fltcall.hxx" +#include <vcl/dialog.hxx> +#include <vcl/button.hxx> +#include <vcl/fixed.hxx> +#include <vcl/field.hxx> +#include <vcl/group.hxx> +#include <vcl/lstbox.hxx> + +/************************************************************************* +|* +|* Dialog zum Einstellen von Filteroptionen bei Pixelformaten +|* +\************************************************************************/ +class DlgExportPix : public ModalDialog +{ +private: + OKButton aBtnOK; + CancelButton aBtnCancel; + HelpButton aBtnHelp; + + ListBox aLbColors; + CheckBox aCbxRLE; + GroupBox aGrpColors; + + RadioButton aRbOriginal; + RadioButton aRbRes; + RadioButton aRbSize; + FixedText aFtSizeX; + MetricField aMtfSizeX; + FixedText aFtSizeY; + MetricField aMtfSizeY; + GroupBox aGrpMode; + ComboBox aCbbRes; + + Config* pConfig; + ResMgr* pMgr; + + const String& rExt; + + DECL_LINK( OK, void* p ); + DECL_LINK( ClickRbOriginal,void* p ); + DECL_LINK( ClickRbRes,void* p ); + DECL_LINK( ClickRbSize,void* p ); + DECL_LINK( SelectLbColors, void* p ); + +public: + DlgExportPix( FltCallDialogParameter& rPara ); +}; + + +/************************************************************************* +|* +|* Dialog zum Einstellen von Filteroptionen bei Vektorformaten +|* +\************************************************************************/ +class DlgExportVec : 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; + + const String& rExt; + + DECL_LINK( OK, void* p ); + DECL_LINK( ClickRbOriginal,void* p ); + DECL_LINK( ClickRbSize,void* p ); + +public: + DlgExportVec( FltCallDialogParameter& rPara ); +}; + +#endif // _DLGEXPOR_HXX_ + diff --git a/svtools/source/filter.vcl/filter/dlgexpor.src b/svtools/source/filter.vcl/filter/dlgexpor.src new file mode 100644 index 000000000000..d983cecc51dd --- /dev/null +++ b/svtools/source/filter.vcl/filter/dlgexpor.src @@ -0,0 +1,809 @@ +/************************************************************************* + * + * $RCSfile: dlgexpor.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 "dlgexpor.hrc" + +ModalDialog DLG_EXPORT_PIX +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 178 , 144 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + GroupBox GRP_COLORS + { + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 110 , 45 ) ; + Text = "Farbauflösung" ; + Text [ ENGLISH ] = "Color resolution" ; + Text [ english_us ] = "Color resolution" ; + Text [ portuguese ] = "Resolução de cores" ; + Text [ portuguese_brazilian ] = "Farbauflösung" ; + Text [ swedish ] = "Färgupplösning" ; + Text [ danish ] = "Farveopløsning" ; + Text [ italian ] = "Profondità cromatica" ; + Text [ spanish ] = "Resolución del color" ; + Text [ french ] = "Résolution couleur" ; + Text [ dutch ] = "Kleurdichtheid" ; + Text[ chinese_simplified ] = "ÑÕÉ«·Ö±æÂÊ"; + Text[ russian ] = "Öâåòîâîå ðàçðåøåíèå"; + Text[ polish ] = "Rozdzielczoœæ kolorów"; + Text[ japanese ] = "F‚̉𑜓x"; + Text[ chinese_traditional ] = "ÃC¦â¸ÑªR«×"; + Text[ arabic ] = "ÇÓÊÈÇäÉ Çááæä"; + Text[ greek ] = "ÁíÜëõóç ÷ñùìÜôùí"; + Text[ korean ] = "Ä÷¯ ÇØ»óµµ"; + Text[ turkish ] = "Renk çözünürlüðü"; + Text[ language_user1 ] = " "; + }; + ListBox LB_COLORS + { + Pos = MAP_APPFONT ( 12 , 14 ) ; + Size = MAP_APPFONT ( 98 , 90 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + AutoHScroll = TRUE ; + StringList = + { + < "Original" ; Default ; > ; + < "1Bit - Schwellenwert" ; Default ; > ; + < "1Bit - Gedithert" ; Default ; > ; + < "4Bit - Graustufenpalette" ; Default ; > ; + < "4Bit - Farbpalette" ; Default ; > ; + < "8Bit - Graustufenpalette" ; Default ; > ; + < "8Bit - Farbpalette" ; Default ; > ; + < "24Bit - Echtfarben" ; Default ; > ; + }; + StringList [ ENGLISH ] = + { + < "Original" ; Default ; > ; + < "1Bit - Schwellenwert" ; Default ; > ; + < "1Bit - Gedithert" ; Default ; > ; + < "4Bit - Graustufenpalette" ; Default ; > ; + < "4Bit - Farbpalette" ; Default ; > ; + < "8Bit - Graustufenpalette" ; Default ; > ; + < "8Bit - Farbpalette" ; Default ; > ; + < "24Bit - Echtfarben" ; Default ; > ; + }; + StringList [ english_us ] = + { + < "Original" ; Default ; > ; + < "1 Bit - Threshold Value" ; Default ; > ; + < "1 Bit - Dithering" ; Default ; > ; + < "4 Bit - Grayscale" ; Default ; > ; + < "4 Bit - Color Palette" ; Default ; > ; + < "8 Bit - Grayscales" ; Default ; > ; + < "8 Bit - Color Palette" ; Default ; > ; + < "24 Bit - True Colors" ; Default ; > ; + }; + stringlist [ portuguese ] = + { + < "Original" ; Default ; > ; + < "Valor limite - 1 bit" ; Default ; > ; + < "Sombreado - 1 bit" ; Default ; > ; + < "Paleta de tons cinzentos de 4 bits" ; Default ; > ; + < "Paleta de cores de 4 bits" ; Default ; > ; + < "Paleta de tons cinzentos de 8 bits" ; Default ; > ; + < "Paleta de cores de 8 bits" ; Default ; > ; + < "Cores reais de 24 bits" ; Default ; > ; + }; + stringlist [ portuguese_brazilian ] = + { + < "Original" ; Default ; > ; + < "1Bit - Schwellenwert" ; Default ; > ; + < "1Bit - Gedithert" ; Default ; > ; + < "4Bit - Graustufenpalette" ; Default ; > ; + < "4Bit - Farbpalette" ; Default ; > ; + < "8Bit - Graustufenpalette" ; Default ; > ; + < "8Bit - Farbpalette" ; Default ; > ; + < "24Bit - Echtfarben" ; Default ; > ; + }; + stringlist [ swedish ] = + { + < "Original" ; Default ; > ; + < "1bit-tröskelvärde" ; Default ; > ; + < "1bit-ditrering" ; Default ; > ; + < "4bit-gråskalepalett" ; Default ; > ; + < "4bit-färgpalett" ; Default ; > ; + < "8Bit - gråskalepalett" ; Default ; > ; + < "8Bit - färgpalett" ; Default ; > ; + < "24bit - True Colors" ; Default ; > ; + }; + stringlist [ danish ] = + { + < "Original" ; Default ; > ; + < "1bit - tærskelværdi" ; Default ; > ; + < "1bit - dithering" ; Default ; > ; + < "4bit - gråtoneskala" ; Default ; > ; + < "4bit - farvepalet" ; Default ; > ; + < "8bit - gråtoneskala" ; Default ; > ; + < "8bit - farvepalet" ; Default ; > ; + < "24bit - ægte farver" ; Default ; > ; + }; + stringlist [ italian ] = + { + < "Originale" ; Default ; > ; + < "Valore soglia 1 bit" ; Default ; > ; + < "Dithering a 1 bit" ; Default ; > ; + < "Scala di grigio 4 bit" ; Default ; > ; + < "Tavola dei colori 4 bit" ; Default ; > ; + < "Scala di grigio 8 bit" ; Default ; > ; + < "Tavola dei colori a 8 bit" ; Default ; > ; + < "Colori reali - 24 bit" ; Default ; > ; + }; + stringlist [ spanish ] = + { + < "Original" ; Default ; > ; + < "Valor umbral de 1 bit" ; Default ; > ; + < "1 bit - difusionado" ; Default ; > ; + < "Paleta de escala de grises 4 bits" ; Default ; > ; + < "Paleta de colores de 4 bits" ; Default ; > ; + < "Paleta de escala de grises 8 bits" ; Default ; > ; + < "Paleta de colores de 8 bits" ; Default ; > ; + < "Color real 24 bits" ; Default ; > ; + }; + stringlist [ french ] = + { + < "Original" ; Default ; > ; + < "Valeur de seuil 1 bit" ; Default ; > ; + < "Dithering (diffusion) 1 bit" ; Default ; > ; + < "Niveaux de gris 4 bits" ; Default ; > ; + < "Palette de couleurs 4 bits" ; Default ; > ; + < "Niveaux de gris 8 bits" ; Default ; > ; + < "Palette de couleurs 8 bits" ; Default ; > ; + < "Couleurs 24 bit (Truecolor)" ; Default ; > ; + }; + stringlist [ dutch ] = + { + < "Origineel" ; Default ; > ; + < "1Bit - grenswaarde" ; Default ; > ; + < "1Bit - geditherd" ; Default ; > ; + < "4Bit - grijswaardenpalet" ; Default ; > ; + < "4Bit - kleurenpalet" ; Default ; > ; + < "8Bit - grijswaardenpalet" ; Default ; > ; + < "8Bit - kleurenpalet" ; Default ; > ; + < "24Bit - echte kleuren" ; Default ; > ; + }; + StringList [ chinese_simplified ] = + { + < "Ô¼þ" ; Default ; > ; + < "1 λ³õʼֵ" ; Default ; > ; + < "1 붶¶¯" ; Default ; > ; + < "4 λ»Ò¶Èµ÷É«°å" ; Default ; > ; + < "4 λµ÷É«°å" ; Default ; > ; + < "8 λ»Ò¶Èµ÷É«°å" ; Default ; > ; + < "8 λµ÷É«°å" ; Default ; > ; + < "24 λ·ÂÕæÑÕÉ«" ; Default ; > ; + }; + StringList [ russian ] = + { + < "Îðèãèíàë" ; Default ; > ; + < "1-ðàçðÿäíîå ïîðîãîâîå çíà÷åíèå" ; Default ; > ; + < "1-ðàçðÿäíîå ïñåâäîïîëóòîíîâîå èçîáðàæåíèå" ; Default ; > ; + < "4-ðàçðÿäíàÿ ãàììà îòòåíêîâ ñåðîãî" ; Default ; > ; + < "4-ðàçðÿäíàÿ öâåòîâàÿ ïàëèòðà" ; Default ; > ; + < "8-ðàçÿäíàÿ ãàììà îòòåíêîâ ñåðîãî" ; Default ; > ; + < "8-ðàçðÿäíàÿ öâåòîâàÿ ïàëèòðà" ; Default ; > ; + < "24-ðàçðÿäíîå êîäèðîâàíèå öâåòà" ; Default ; > ; + }; + StringList [ polish ] = + { + < "Orygina³" ; Default ; > ; + < "Wartoœæ progowa - 1bit" ; Default ; > ; + < "Rozsiewanie - 1 bit" ; Default ; > ; + < "Paleta odcieni szaroœci - 4bity" ; Default ; > ; + < "Paleta kolorów - 4bity" ; Default ; > ; + < "Paleta odcieni szaroœci - 8bitów" ; Default ; > ; + < "Paleta kolorów - 8bitów" ; Default ; > ; + < "True Color - 24bity" ; Default ; > ; + }; + StringList [ japanese ] = + { + < "µØ¼ÞÅÙ" ; Default ; > ; + < "1Bit ‚µ‚«‚¢’l" ; Default ; > ; + < "1Bit ÃÞ¨»Þ–@" ; Default ; > ; + < "4Bit-¸ÞÚ°½¹°Ù" ; Default ; > ; + < "4Bit-¶×°ÊßÚ¯Ä" ; Default ; > ; + < "8Bit-¸ÞÚ°½¹°Ù" ; Default ; > ; + < "8Bit-¶×°ÊßÚ¯Ä" ; Default ; > ; + < "24Bit-‘NÊF" ; Default ; > ; + }; + StringList [ chinese_traditional ] = + { + < "ì¥ó" ; Default ; > ; + < "1 ¦ì¤¸ªì©lÈ" ; Default ; > ; + < "1 ¦ì¤¸§Ý°Ê" ; Default ; > ; + < "4 ¦ì¤¸¦Ç«×¦âªO" ; Default ; > ; + < "4 ¦ì¤¸¦âªO" ; Default ; > ; + < "8 ¦ì¤¸¦Ç«×¦âªO" ; Default ; > ; + < "8 ¦ì¤¸¦âªO" ; Default ; > ; + < "24 ¦ì¤¸¥þ±m" ; Default ; > ; + }; + StringList [ arabic ] = + { + < "ÇáÃÕá" ; Default ; > ; + < "ÞíãÉ ÇáÈÏÁ 1 ÈÊ" ; Default ; > ; + < "1 ÈÊ Dithering" ; Default ; > ; + < "áæÍ ÏÑÌÇÊ ÇáÑãÇÏí 4 ÈÊ" ; Default ; > ; + < "áæÍ ÃáæÇä 4 ÈÊ" ; Default ; > ; + < "áæÍ ÏÑÌÇÊ ÇáÑãÇÏí 8 ÈÊ" ; Default ; > ; + < "áæÍ ÃáæÇä 8 ÈÊ" ; Default ; > ; + < "ÃáæÇä ÍÞíÞíÉ 24 ÈÊ" ; Default ; > ; + }; + StringList [ greek ] = + { + < "Áñ÷éêü" ; Default ; > ; + < "ÔéìÞ ïñßïõ 1 bit" ; Default ; > ; + < "Áðüäïóç ÷ñùìÜôùí 1 bit" ; Default ; > ; + < "ÄéáâÜèìéóç ôïõ ãêñé: 4 bit" ; Default ; > ; + < "ÐáëÝôá ÷ñùìÜôùí 4 bit" ; Default ; > ; + < "ÄéáâÜèìéóç ôïõ ãêñé: 8 bit" ; Default ; > ; + < "ÐáëÝôá ÷ñùìÜôùí 8 bit" ; Default ; > ; + < "24 bit - ÖõóéêÜ ÷ñþìáôá" ; Default ; > ; + }; + StringList [ korean ] = + { + < "¿øº»" ; Default ; > ; + < "1 ºñÆ®- ÀÓ°è°ª" ; Default ; > ; + < "1ºñÆ® - Èçµé¸²" ; Default ; > ; + < "4 ºñÆ® - ȸ»öÁ¶" ; Default ; > ; + < "4 ºñÆ® - »ö»ó ÆÄ·¹Æ®" ; Default ; > ; + < "8 ºñÆ® - ȸ»öÁ¶" ; Default ; > ; + < "8 ºñÆ® - »ö»ó ÆÄ·¹Æ®" ; Default ; > ; + < "24 ºñÆ® - Æ®·ç Ä÷¯" ; Default ; > ; + }; + StringList [ turkish ] = + { + < "Asýl" ; Default ; > ; + < "1Bit - eþik deðer" ; Default ; > ; + < "1Bit - titrek" ; Default ; > ; + < "4Bit - gri tonlama paleti" ; Default ; > ; + < "4Bit - renk paleti" ; Default ; > ; + < "8Bit - gri tonlama paleti" ; Default ; > ; + < "8Bit - renk paleti" ; Default ; > ; + < "24Bit - gerçek renk" ; Default ; > ; + }; + StringList [ language_user1 ] = + { + < " " ; Default ; > ; + < " " ; Default ; > ; + < " " ; Default ; > ; + < " " ; Default ; > ; + < " " ; Default ; > ; + < " " ; Default ; > ; + < " " ; Default ; > ; + < " " ; Default ; > ; + }; + }; + CheckBox CBX_RLE + { + Pos = MAP_APPFONT ( 12 , 31 ) ; + Size = MAP_APPFONT ( 98 , 12 ) ; + TabStop = TRUE ; + Text = "RLE-Kodierung" ; + Text [ ENGLISH ] = "RLE-Coding" ; + Text [ english_us ] = "RLE coding" ; + Text [ portuguese_brazilian ] = "RLE-Kodierung" ; + Text [ swedish ] = "RLE-kodning" ; + Text [ danish ] = "RLE-kodning" ; + Text [ italian ] = "Codifica RLE" ; + Text [ spanish ] = "Codificación RLE" ; + Text [ french ] = "Code RLE" ; + Text [ dutch ] = "RLE-codering" ; + Text [ portuguese ] = "Codificação RLE" ; + Text[ chinese_simplified ] = "RLE - ±àÂë"; + Text[ russian ] = "Êîäèðîâêà RLE"; + Text[ polish ] = "Kodowanie RLE"; + Text[ japanese ] = "RLE º°ÃިݸÞ"; + Text[ chinese_traditional ] = "RLE ½s½X"; + Text[ arabic ] = "ÊÑãíÒ RLE"; + Text[ greek ] = "Êùäéêïðïßçóç RLE"; + Text[ korean ] = "RLE ÄÚµù"; + Text[ turkish ] = "RLE kodlama"; + Text[ language_user1 ] = " "; + }; + GroupBox GRP_MODE_PIX + { + Pos = MAP_APPFONT ( 6 , 51 ) ; + Size = MAP_APPFONT ( 110 , 87 ) ; + 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 ] = "Modo" ; + Text [ portuguese_brazilian ] = "Modus" ; + Text[ chinese_simplified ] = "ģʽ"; + Text[ russian ] = "Ðåæèì"; + Text[ polish ] = "Tryb"; + Text[ japanese ] = "Ó°ÄÞ"; + Text[ chinese_traditional ] = "¼Ò¦¡"; + Text[ arabic ] = "ÇáæÖÚ"; + Text[ greek ] = "ÊáôÜóôáóç"; + Text[ korean ] = "¸ðµå"; + Text[ turkish ] = "Kip"; + Text[ language_user1 ] = " "; + }; + RadioButton RB_ORIGINAL_PIX + { + Pos = MAP_APPFONT ( 12 , 60 ) ; + Size = MAP_APPFONT ( 98 , 12 ) ; + Text = "~Original" ; + Text [ ENGLISH ] = "~Original" ; + TabStop = TRUE ; + Text [ dutch ] = "~Origineel" ; + Text [ english_us ] = "~Original" ; + Text [ italian ] = "~Originale" ; + Text [ spanish ] = "~Original" ; + Text [ french ] = "~Original" ; + Text [ swedish ] = "~Original" ; + Text [ danish ] = "Original" ; + Text [ portuguese ] = "~Original" ; + Text [ portuguese_brazilian ] = "~Original" ; + Text[ chinese_simplified ] = "Ô¼þ(~O)"; + Text[ russian ] = "Îðèãèíàë"; + Text[ polish ] = "Orygina³"; + Text[ japanese ] = "µØ¼ÞÅÙ(~O)"; + Text[ chinese_traditional ] = "ì¥ó(~O)"; + Text[ arabic ] = "ÇáÃÕá"; + Text[ greek ] = "Áñ÷éêü"; + Text[ korean ] = "¿øº»(~O)"; + Text[ turkish ] = "~Asýl"; + Text[ language_user1 ] = " "; + }; + RadioButton RB_RES_PIX + { + Pos = MAP_APPFONT ( 12 , 75 ) ; + Size = MAP_APPFONT ( 55 , 12 ) ; + Text = "~Auflösung" ; + Text [ ENGLISH ] = "~Resolution" ; + TabStop = TRUE ; + Text [ dutch ] = "~Resolutie" ; + Text [ english_us ] = "~Resolution" ; + Text [ italian ] = "~Risoluzione" ; + Text [ spanish ] = "~Resolución" ; + Text [ french ] = "Résolution" ; + Text [ swedish ] = "~Upplösning" ; + Text [ danish ] = "Opløsning" ; + Text [ portuguese ] = "~Resolução" ; + Text [ portuguese_brazilian ] = "~Auflösung" ; + Text[ chinese_simplified ] = "·Ö±æÂÊ(~R)"; + Text[ russian ] = "Ðàçðåøåíèå"; + Text[ polish ] = "Rozdzielczoœæ"; + Text[ japanese ] = "‰ð‘œ“x(~R)"; + Text[ chinese_traditional ] = "¸ÑªR«×(~R)"; + Text[ arabic ] = "ÇáÇÓÊÈÇäÉ"; + Text[ greek ] = "ÁíÜëõóç"; + Text[ korean ] = "ÇØ»óµµ(~R)"; + Text[ turkish ] = "~Çözünürlük"; + Text[ language_user1 ] = " "; + }; + ComboBox CBB_RES_PIX + { + Pos = MAP_APPFONT ( 70 , 75 ) ; + Size = MAP_APPFONT ( 40 , 50 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + StringList = + { + "75 DPI" ; + "150 DPI" ; + "300 DPI" ; + "600 DPI" ; + }; + }; + RadioButton RB_SIZE_PIX + { + Pos = MAP_APPFONT ( 12 , 90 ) ; + Size = MAP_APPFONT ( 98 , 12 ) ; + Text = "~Größe" ; + Text [ ENGLISH ] = "~Size" ; + TabStop = TRUE ; + Text [ dutch ] = "~Grootte" ; + Text [ english_us ] = "~Size" ; + Text [ italian ] = "~Dimensione" ; + Text [ spanish ] = "~Tamaño" ; + Text [ french ] = "Taille" ; + Text [ swedish ] = "~Storlek" ; + Text [ danish ] = "Størrelse" ; + Text [ portuguese ] = "~Tamanho" ; + Text [ portuguese_brazilian ] = "~Größe" ; + Text[ chinese_simplified ] = "´óС(~S)"; + Text[ russian ] = "Ðàçìåð"; + Text[ polish ] = "Rozmiar"; + Text[ japanese ] = "»²½Þ(~S)"; + Text[ chinese_traditional ] = "¤j¤p(~S)"; + Text[ arabic ] = "ÇáÍÌã"; + Text[ greek ] = "ÌÝãåèïò"; + Text[ korean ] = "Å©±â(~S)"; + Text[ turkish ] = "~Büyüklük"; + Text[ language_user1 ] = " "; + }; + MetricField MTF_SIZEX_PIX + { + Border = TRUE ; + Pos = MAP_APPFONT ( 60 , 105 ) ; + 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_PIX + { + Border = TRUE ; + Pos = MAP_APPFONT ( 60 , 120 ) ; + 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 ; + }; + FixedText FT_SIZEX_PIX + { + Pos = MAP_APPFONT ( 18 , 106 ) ; + Size = MAP_APPFONT ( 41 , 10 ) ; + Text = "Breite" ; + Text [ ENGLISH ] = "Width" ; + Text [ english_us ] = "Width" ; + Text [ italian ] = "Larghezza" ; + Text [ spanish ] = "Ancho" ; + Text [ french ] = "Largeur" ; + Text [ dutch ] = "Breedte" ; + Text [ swedish ] = "Bredd" ; + Text [ danish ] = "Bredde" ; + Text [ portuguese_brazilian ] = "Breite" ; + Text [ portuguese ] = "Largura" ; + Text[ chinese_simplified ] = "¿í¶È"; + Text[ russian ] = "Øèðèíà"; + Text[ polish ] = "Szer."; + Text[ japanese ] = "•"; + Text[ chinese_traditional ] = "¼e«×"; + Text[ arabic ] = "ÇáÚÑÖ"; + Text[ greek ] = "ÐëÜôïò"; + Text[ korean ] = "³Êºñ"; + Text[ turkish ] = "Geniþlik"; + Text[ language_user1 ] = " "; + }; + FixedText FT_SIZEY_PIX + { + Pos = MAP_APPFONT ( 18 , 121 ) ; + Size = MAP_APPFONT ( 41 , 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 ] = "Altura" ; + Text [ portuguese_brazilian ] = "Höhe" ; + Text[ chinese_simplified ] = "¸ß¶È"; + Text[ russian ] = "Âûñîòà"; + Text[ polish ] = "Wys."; + Text[ japanese ] = "‚‚³"; + Text[ chinese_traditional ] = "°ª«×"; + Text[ arabic ] = "ÇáÇÑÊÝÇÚ"; + Text[ greek ] = "¾øïò"; + Text[ korean ] = "³ôÀÌ"; + Text[ turkish ] = "Yükseklik"; + Text[ language_user1 ] = " "; + }; + OKButton BTN_OK_PIX + { + Pos = MAP_APPFONT ( 122 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton BTN_CANCEL_PIX + { + Pos = MAP_APPFONT ( 122 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + HelpButton BTN_HELP_PIX + { + Pos = MAP_APPFONT ( 122 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; +}; +ModalDialog DLG_EXPORT_VEC +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 178 , 98 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + MetricField MTF_SIZEX_VEC + { + 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_VEC + { + 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_VEC + { + Pos = MAP_APPFONT ( 6 , 48 ) ; + Size = MAP_APPFONT ( 110 , 44 ) ; + Text = "Größe" ; + Text [ ENGLISH ] = "Size" ; + Text [ dutch ] = "Grootte" ; + Text [ english_us ] = "Size" ; + Text [ italian ] = "Dimensione" ; + Text [ spanish ] = "Tamaño" ; + Text [ french ] = "Taille" ; + Text [ swedish ] = "Storlek" ; + Text [ danish ] = "Størrelse" ; + Text [ portuguese_brazilian ] = "Größe" ; + Text [ portuguese ] = "Tamanho" ; + Text[ chinese_simplified ] = "´óС"; + Text[ russian ] = "Ðàçìåð"; + Text[ polish ] = "Rozmiar"; + Text[ japanese ] = "»²½Þ"; + Text[ chinese_traditional ] = "¤j¤p"; + Text[ arabic ] = "ÇáÍÌã"; + Text[ greek ] = "ÌÝãåèïò"; + Text[ korean ] = "Å©±â"; + Text[ turkish ] = "Büyüklük"; + Text[ language_user1 ] = " "; + }; + FixedText FT_SIZEX_VEC + { + 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 ] = "Breite" ; + Text[ chinese_simplified ] = "¿í¶È"; + Text[ russian ] = "Øèðèíà"; + Text[ polish ] = "Szer."; + Text[ japanese ] = "•"; + Text[ chinese_traditional ] = "¼e«×"; + Text[ arabic ] = "ÇáÚÑÖ"; + Text[ greek ] = "ÐëÜôïò"; + Text[ korean ] = "³Êºñ"; + Text[ turkish ] = "Geniþlik"; + Text[ language_user1 ] = " "; + }; + FixedText FT_SIZEY_VEC + { + 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öhe" ; + Text [ portuguese ] = "Altura" ; + Text[ chinese_simplified ] = "¸ß¶È"; + Text[ russian ] = "Âûñîòà"; + Text[ polish ] = "Wys."; + Text[ japanese ] = "‚‚³"; + Text[ chinese_traditional ] = "°ª«×"; + Text[ arabic ] = "ÇáÇÑÊÝÇÚ"; + Text[ greek ] = "¾øïò"; + Text[ korean ] = "³ôÀÌ"; + Text[ turkish ] = "Yükseklik"; + Text[ language_user1 ] = " "; + }; + OKButton BTN_OK_VEC + { + Pos = MAP_APPFONT ( 122 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton BTN_CANCEL_VEC + { + Pos = MAP_APPFONT ( 122 , 24 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + HelpButton BTN_HELP_VEC + { + Pos = MAP_APPFONT ( 122 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + RadioButton RB_ORIGINAL_VEC + { + Pos = MAP_APPFONT ( 12 , 12 ) ; + Size = MAP_APPFONT ( 98 , 12 ) ; + Text = "~Original" ; + Text [ ENGLISH ] = "~Original" ; + TabStop = TRUE ; + 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[ greek ] = "Áñ÷éêü"; + Text[ korean ] = "¿øº»(~O)"; + Text[ turkish ] = "~Asýl"; + Text[ language_user1 ] = " "; + }; + RadioButton RB_SIZE_VEC + { + Pos = MAP_APPFONT ( 12 , 27 ) ; + Size = MAP_APPFONT ( 98 , 12 ) ; + Text = "~Größe" ; + Text [ ENGLISH ] = "~Size" ; + TabStop = TRUE ; + Text [ dutch ] = "~Grootte" ; + Text [ english_us ] = "~Size" ; + Text [ italian ] = "~Dimensione" ; + Text [ spanish ] = "~Tamaño" ; + Text [ french ] = "Taille" ; + Text [ swedish ] = "~Storlek" ; + Text [ danish ] = "Størrelse" ; + Text [ portuguese_brazilian ] = "~Größe" ; + Text [ portuguese ] = "~Tamanho" ; + Text[ chinese_simplified ] = "´óС(~S)"; + Text[ russian ] = "Ðàçìåð"; + Text[ polish ] = "Rozmiar"; + Text[ japanese ] = "»²½Þ(~S)"; + Text[ chinese_traditional ] = "¤j¤p(~S)"; + Text[ arabic ] = "ÇáÍÌã"; + Text[ greek ] = "ÌÝãåèïò"; + Text[ korean ] = "Å©±â(~S)"; + Text[ turkish ] = "~Büyüklük"; + Text[ language_user1 ] = " "; + }; + GroupBox GRP_MODE_VEC + { + 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[ greek ] = "ÊáôÜóôáóç"; + Text[ korean ] = "¸ðµå"; + Text[ turkish ] = "Kip"; + Text[ language_user1 ] = " "; + }; +}; diff --git a/svtools/source/filter.vcl/filter/filter.cxx b/svtools/source/filter.vcl/filter/filter.cxx new file mode 100644 index 000000000000..17c0c47587d2 --- /dev/null +++ b/svtools/source/filter.vcl/filter/filter.cxx @@ -0,0 +1,2735 @@ +/************************************************************************* + * + * $RCSfile: filter.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 defined UNX && defined ALPHA +#include <fstream.hxx> +#endif +#include <unotools/processfactory.hxx> +#include <ucbhelper/content.hxx> +#include <cppuhelper/implbase1.hxx> +#include <tools/urlobj.hxx> +#include <tools/tempfile.hxx> +#include <vcl/salctype.hxx> +#include <vcl/virdev.hxx> +#include <vcl/svapp.hxx> +#include "filter.hxx" +#include "fltcall.hxx" +#include "wmf.hxx" +#include "gifread.hxx" +#include "pngread.hxx" +#include "jpeg.hxx" +#include "xbmread.hxx" +#include "xpmread.hxx" +#include "solar.hrc" +#include "strings.hrc" +#include "dlgexpor.hxx" +#include "dlgejpg.hxx" +#include "sgffilt.hxx" +#ifndef _VOS_MODULE_HXX_ +#include "vos/module.hxx" +#endif + +#ifdef MAC +#include "extattr.hxx" +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif +#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_ +#include <com/sun/star/uno/XInterface.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_XWEAK_HPP_ +#include <com/sun/star/uno/XWeak.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_XAGGREGATION_HPP_ +#include <com/sun/star/uno/XAggregation.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_XTYPEPROVIDER_HPP_ +#include <com/sun/star/lang/XTypeProvider.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_ +#include <com/sun/star/io/XActiveDataSource.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_ +#include <com/sun/star/io/XOutputStream.hpp> +#endif +#ifndef _COM_SUN_STAR_SVG_XSVGWRITER_HPP_ +#include <com/sun/star/svg/XSVGWriter.hpp> +#endif +#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_ +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> +#endif + +#define IMPEXP_FILTERPATHES "Pathes" + +#define IMP_BMP "SVBMP" +#define IMP_SVMETAFILE "SVMETAFILE" +#define IMP_WMF "SVWMF" +#define IMP_EMF "SVEMF" +#define IMP_SVSGF "SVSGF" +#define IMP_SVSGV "SVSGV" +#define IMP_GIF "SVIGIF" +#define IMP_PNG "SVIPNG" +#define IMP_JPEG "SVIJPEG" +#define IMP_XBM "SVIXBM" +#define IMP_XPM "SVIXPM" +#define EXP_BMP "SVBMP" +#define EXP_SVMETAFILE "SVMETAFILE" +#define EXP_WMF "SVWMF" +#define EXP_EMF "SVEMF" +#define EXP_JPEG "SVEJPEG" +#define EXP_SVG "SVESVG" + +#define BMP_SHORTNAME "BMP" +#define GIF_SHORTNAME "GIF" +#define JPG_SHORTNAME "JPG" +#define MET_SHORTNAME "MET" +#define PCT_SHORTNAME "PCT" +#define PNG_SHORTNAME "PNG" +#define SVM_SHORTNAME "SVM" +#define TIF_SHORTNAME "TIF" +#define WMF_SHORTNAME "WMF" +#define EMF_SHORTNAME "EMF" + +#if defined WIN || (defined OS2 && !defined ICC) + +#define IMPORT_FUNCTION_NAME "_GraphicImport" +#define EXPORT_FUNCTION_NAME "_GraphicExport" +#define IMPDLG_FUNCTION_NAME "_DoImportDialog" +#define EXPDLG_FUNCTION_NAME "_DoExportDialog" + +#else + +#define IMPORT_FUNCTION_NAME "GraphicImport" +#define EXPORT_FUNCTION_NAME "GraphicExport" +#define IMPDLG_FUNCTION_NAME "DoImportDialog" +#define EXPDLG_FUNCTION_NAME "DoExportDialog" + +#endif + +// Compilerfehler, wenn Optimierung bei WNT & MSC +#if defined WNT && defined MSC +#pragma optimize( "", off ) +#endif + +// ----------- +// - statics - +// ----------- + +ULONG GraphicFilter::nFilterCount = 0UL; +Link GraphicFilter::aLastFilterHdl = Link(); + +// ------------------------- +// - ImpFilterOutputStream - +// ------------------------- + +class ImpFilterOutputStream : public ::cppu::WeakImplHelper1< ::com::sun::star::io::XOutputStream > +{ +protected: + + SvStream& mrStm; + + virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& rData ) { mrStm.Write( rData.getConstArray(), rData.getLength() ); } + virtual void SAL_CALL flush() { mrStm.Flush(); } + virtual void SAL_CALL closeOutput() {} + +public: + + ImpFilterOutputStream( SvStream& rStm ) : mrStm( rStm ) {} + ~ImpFilterOutputStream() {} +}; + +// ------------------------- +// - ImpFilterCallbackData - +// ------------------------- + +struct ImpFilterCallbackData +{ + GraphicFilter * pFilt; + USHORT * pPercent; + Link * pUpdatePercentHdl; + BOOL * pAbort; + USHORT nFilePercentOfTotal; +}; + +// --------------------- +// - ImpFilterCallback - +// --------------------- + +BOOL ImplDirEntryHelper::Exists( const INetURLObject& rObj ) +{ + BOOL bExists = FALSE; + + try + { + ::rtl::OUString aTitle; + ::ucb::Content aCnt( rObj.GetMainURL(), + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() ); + + aCnt.getPropertyValue( ::rtl::OUString::createFromAscii( "Title" ) ) >>= aTitle; + + if( aTitle.getLength() ) + bExists = TRUE; + } + catch( ::com::sun::star::ucb::CommandAbortedException& ) + { + DBG_ERRORFILE( "CommandAbortedException" ); + } + catch( ... ) + { + DBG_ERRORFILE( "Any other exception" ); + } + + return bExists; +} + +// ----------------------------------------------------------------------------- + +void ImplDirEntryHelper::Kill( const String& rStr ) +{ + try + { + ::ucb::Content aCnt( INetURLObject( rStr, INET_PROT_FILE ).GetMainURL(), + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() ); + + aCnt.executeCommand( ::rtl::OUString::createFromAscii( "delete" ), + ::com::sun::star::uno::makeAny( sal_Bool( sal_True ) ) ); + } + catch( ::com::sun::star::ucb::CommandAbortedException& ) + { + DBG_ERRORFILE( "CommandAbortedException" ); + } + catch( ... ) + { + DBG_ERRORFILE( "Any other exception" ); + } +} + +// --------------------- +// - ImpFilterCallback - +// --------------------- + +BOOL ImpFilterCallback( void* pCallerData, USHORT nPercent ) +{ + ImpFilterCallbackData* pData= (ImpFilterCallbackData*) pCallerData; + + nPercent = nPercent * pData->nFilePercentOfTotal / 100; + + if( nPercent >= ( 3 + *pData->pPercent ) ) + { + *pData->pPercent = nPercent; + pData->pUpdatePercentHdl->Call( pData->pFilt ); + } + + return *pData->pAbort; +} + +// -------------------- +// - Helper functions - +// -------------------- + +static String ImpGetNthEntry( const String& rStr, USHORT nEntry ) +{ + const sal_Unicode* pA = rStr.GetBuffer(); + const sal_Unicode* pEnd = pA + rStr.Len(); + + sal_uInt16 i; + for( i = 0; ( i < nEntry ) && ( pA != pEnd ); i++ ) + { + while( ( *pA != ',' ) && ( pA != pEnd ) ) + pA++; + + if( *pA == ',') + pA++; + } + i = 0; + if( *pA == '"' ) + { + *pA++; + while( ( ( pA + i ) != pEnd ) && ( pA[i] != '"' ) ) + i++; + } + else + { + while( ( ( pA + i ) != pEnd ) && ( pA[i] != ',' ) ) + i++; + } + return String( pA, (xub_StrLen)i ); +} + +//-------------------------------------------------------------------------- + +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; +} + +//-------------------------------------------------------------------------- + +inline String ImpGetFormatName( const String& rStr ) +{ + return ImpGetNthEntry( rStr, 0 ); +} + +//-------------------------------------------------------------------------- + +inline String ImpGetMacType( const String& rStr ) +{ + return ImpGetNthEntry( rStr, 1 ); +} + +//-------------------------------------------------------------------------- + +inline String ImpGetFormatExtension( const String& rStr ) +{ + return ImpGetNthEntry( rStr, 2 ); +} + +//-------------------------------------------------------------------------- + +inline String ImpGetFilterName( const String& rStr ) +{ + return ImpGetNthEntry( rStr, 3 ); +} + +//-------------------------------------------------------------------------- + +inline String ImpGetFilterVendor( const String& rStr ) +{ + return ImpGetNthEntry( rStr, 4 ); +} + +//-------------------------------------------------------------------------- + +inline String ImpGetFilterPixOrVec( const String& rStr ) +{ + return ImpGetNthEntry( rStr, 5 ); +} + +//-------------------------------------------------------------------------- + +inline String ImpGetFilterDialog( const String& rStr ) +{ + return ImpGetNthEntry( rStr, 6 ); +} + +//-------------------------------------------------------------------------- + +inline String ImpGetExtension( const String &rPath ) +{ + String aExt; + INetURLObject aURL; + + aURL.SetSmartURL( rPath ); + aExt = aURL.GetFileExtension().ToUpperAscii(); + return aExt; +} + +/************************************************************************* +|* +|* ImpPeekGraphicFormat() +|* +|* Beschreibung: +|* Diese Funktion kann zweierlei: +|* 1.) Datei anlesen, Dateiformat ermitteln +|* Eingabe-prarameter: +|* rPath - Dateipfad +|* rFormatExtension - Inhalt egal +|* bTest - setze FALSE +|* Ausgabe-parameter: +|* Funkionswert - TRUE wenn Erfolg +|* rFormatExtension - Bei Erfolg: uebliche Dateiendung +|* des Formats (Grossbuchstaben) +|* 2.) Datei anlesen, Dateiformat ueberpruefen +|* Eingabe-prarameter: +|* rPath - Dateipfad +|* rFormatExtension - uebliche Dateiendung des Formats +|* (Grossbuchstaben) +|* bTest - setze TRUE +|* Ausgabe-parameter: +|* Funkionswert - FALSE, wenn die Datei bestimmt nicht +|* vom uebgebenen Format ist. +|* TRUE, wenn die Datei WAHRSCHEINLICH von +|* dem Format ist, ODER WENN DAS FORMAT +|* DIESER FUNKTION NICHT BEKANNT IST! +|* +|* Ersterstellung OH 26.05.95 +|* Letzte Aenderung OH 07.08.95 +|* +*************************************************************************/ + +static BOOL ImpPeekGraphicFormat( SvStream& rStream, String& rFormatExtension, BOOL bTest ) +{ + USHORT i; + BYTE sFirstBytes[ 256 ]; + ULONG nFirstLong,nSecondLong; + ULONG nStreamPos = rStream.Tell(); + + rStream.Seek( STREAM_SEEK_TO_END ); + ULONG nStreamLen = rStream.Tell() - nStreamPos; + rStream.Seek( nStreamPos ); + + // Die ersten 256 Bytes in einen Buffer laden: + if( nStreamLen >= 256 ) + rStream.Read( sFirstBytes, 256 ); + else + { + rStream.Read( sFirstBytes, nStreamLen ); + + for( i = (USHORT) nStreamLen; i < 256; i++ ) + sFirstBytes[ i ]=0; + } + + if( rStream.GetError() ) + return FALSE; + + // Die ersten 8 Bytes in nFirstLong, nSecondLong unterbringen, + // Big-Endian: + for( i = 0, nFirstLong = 0L, nSecondLong = 0L; i < 4; i++ ) + { + nFirstLong=(nFirstLong<<8)|(ULONG)sFirstBytes[i]; + nSecondLong=(nSecondLong<<8)|(ULONG)sFirstBytes[i+4]; + } + + // Folgende Variable ist nur bei bTest==TRUE interessant. Sie + // bleibt FALSE, wenn das Format (rFormatExtension) hier noch nicht + // einprogrammiert wurde. + BOOL bSomethingTested = FALSE; + + // Nun werden die verschieden Formate ueberprueft. Dabei ist die + // Reihenfolge nicht egal. Z.b. koennte eine MET-Datei auch durch + // den BMP-Test gehen, umgekehrt kann eine BMP-Datei kaum durch den + // MET-Test gehen. Also sollte MET vor BMP getestet werden. + // Theoretisch waere aber vielleicht auch eine BMP-Datei denkbar, + // die durch den MET-Test geht. + // Diese Probleme gibt es natuerlich nicht nur bei MET und BMP. + // Deshalb wird im Falle der Uberpruefung eines Formats (bTest==TRUE) + // nur genau dieses eine Format getestet. Alles andere koennte fatale + // Folgen haben, z.B. wenn der Benutzer sagt, es sei BMP-Datei (und es + // ist BMP-Datei), und hier wuerde die Datei durch den MET-Test gehen... + + //--------------------------- MET ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "MET", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested=TRUE; + if( sFirstBytes[2] == 0xd3 ) + { + rStream.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN ); + rStream.Seek( nStreamPos ); + USHORT nFieldSize; + BYTE nMagic; + BOOL bOK=TRUE; + rStream >> nFieldSize >> nMagic; + for (i=0; i<3; i++) { + if (nFieldSize<6) { bOK=FALSE; break; } + if (nStreamLen < rStream.Tell() + nFieldSize ) { bOK=FALSE; break; } + rStream.SeekRel(nFieldSize-3); + rStream >> nFieldSize >> nMagic; + if (nMagic!=0xd3) { bOK=FALSE; break; } + } + rStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); + if (bOK && !rStream.GetError()) { + rFormatExtension= UniString::CreateFromAscii( "MET", 3 ); + return TRUE; + } + } + } + + //--------------------------- BMP ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "BMP", 3 ) == COMPARE_EQUAL ) ) + { + BYTE nOffs; + + bSomethingTested=TRUE; + + // OS/2-Bitmaparray ('BA') koennen wir evtl. auch lesen, + // dementspr. muessen wir den Offset anpassen, + // um auf die erste Bitmap im Array zu stossen + if ( sFirstBytes[0] == 0x42 && sFirstBytes[1] == 0x41 ) + nOffs = 14; + else + nOffs = 0; + + // Jetzt testen wir zunaechst auf 'BM' + if ( sFirstBytes[0+nOffs]==0x42 && sFirstBytes[1+nOffs]==0x4d ) + { + // unter OS/2 koennen die Reserved-Flags != 0 sein + // (was sie eigentlich nicht duerften); + // in diesem Fall testen wir die Groesse des BmpInfoHeaders + if ( ( sFirstBytes[6+nOffs]==0x00 && + sFirstBytes[7+nOffs]==0x00 && + sFirstBytes[8+nOffs]==0x00 && + sFirstBytes[9+nOffs]==0x00 ) || + sFirstBytes[14+nOffs] == 0x28 || + sFirstBytes[14+nOffs] == 0x0c ) + { + rFormatExtension = UniString::CreateFromAscii( "BMP", 3 ); + return TRUE; + } + } + } + + //--------------------------- WMF/EMF ------------------------------------ + + if( !bTest || + ( rFormatExtension.CompareToAscii( "WMF", 3 ) == COMPARE_EQUAL ) || + ( rFormatExtension.CompareToAscii( "EMF", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested = TRUE; + + if ( nFirstLong==0xd7cdc69a || nFirstLong==0x01000900 ) + { + rFormatExtension = UniString::CreateFromAscii( "WMF", 3 ); + return TRUE; + } + else if( nFirstLong == 0x01000000 && sFirstBytes[ 40 ] == 0x20 && sFirstBytes[ 41 ] == 0x45 && + sFirstBytes[ 42 ] == 0x4d && sFirstBytes[ 43 ] == 0x46 ) + { + rFormatExtension = UniString::CreateFromAscii( "EMF", 3 ); + return TRUE; + } + } + + //--------------------------- PCX ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "PCX", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested=TRUE; + if (sFirstBytes[0]==0x0a) + { + BYTE nVersion=sFirstBytes[1]; + BYTE nEncoding=sFirstBytes[2]; + if( ( nVersion==0 || nVersion==2 || nVersion==3 || nVersion==5 ) && nEncoding<=1 ) + { + rFormatExtension = UniString::CreateFromAscii( "PCX", 3 ); + return TRUE; + } + } + } + + //--------------------------- TIF ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "TIF", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested=TRUE; + if ( nFirstLong==0x49492a00 || nFirstLong==0x4d4d002a ) + { + rFormatExtension=UniString::CreateFromAscii( "TIF", 3 ); + return TRUE; + } + } + + //--------------------------- GIF ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "GIF", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested=TRUE; + if ( nFirstLong==0x47494638 && (sFirstBytes[4]==0x37 || sFirstBytes[4]==0x39) && sFirstBytes[5]==0x61 ) + { + rFormatExtension = UniString::CreateFromAscii( "GIF", 3 ); + return TRUE; + } + } + + //--------------------------- PNG ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "PNG", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested=TRUE; + if (nFirstLong==0x89504e47 && nSecondLong==0x0d0a1a0a) + { + rFormatExtension = UniString::CreateFromAscii( "PNG", 3 ); + return TRUE; + } + } + + //--------------------------- JPG ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "JPG", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested=TRUE; + if ( ( nFirstLong==0xffd8ffe0 && sFirstBytes[6]==0x4a && sFirstBytes[7]==0x46 && sFirstBytes[8]==0x49 && sFirstBytes[9]==0x46 ) || + ( nFirstLong==0xffd8fffe ) || ( 0xffd8ff00 == ( nFirstLong & 0xffffff00 ) ) ) + { + rFormatExtension = UniString::CreateFromAscii( "JPG", 3 ); + return TRUE; + } + } + + //--------------------------- SVM ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "SVM", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested=TRUE; + if( nFirstLong==0x53564744 && sFirstBytes[4]==0x49 ) + { + rFormatExtension = UniString::CreateFromAscii( "SVM", 3 ); + return TRUE; + } + else if( sFirstBytes[2]==0x56 && sFirstBytes[3]==0x43 && sFirstBytes[4]==0x4C && + sFirstBytes[5]==0x4D && sFirstBytes[6]==0x54 && sFirstBytes[7]==0x46 ) + { + rFormatExtension = UniString::CreateFromAscii( "SVM", 3 ); + return TRUE; + } + } + + //--------------------------- PCD ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "PCD", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested = TRUE; + if( nStreamLen >= 2055 ) + { + char sBuf[8]; + rStream.Seek( nStreamPos + 2048 ); + rStream.Read( sBuf, 7 ); + + if( strncmp( sBuf, "PCD_IPI", 7 ) == 0 ) + { + rFormatExtension = UniString::CreateFromAscii( "PCD", 3 ); + return TRUE; + } + } + } + + //--------------------------- PSD ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "PSD", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested = TRUE; + if ( ( nFirstLong == 0x38425053 ) && ( (nSecondLong >> 16 ) == 1 ) ) + { + rFormatExtension = UniString::CreateFromAscii( "PSD", 3 ); + return TRUE; + } + } + + //--------------------------- EPS ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "EPS", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested = TRUE; + if ( ( nFirstLong == 0xC5D0D3C6 ) || ( ImplSearchEntry( sFirstBytes, (BYTE*)"%!PS-Adobe", 10, 10 ) && + ImplSearchEntry( &sFirstBytes[15], (BYTE*)"EPS", 3, 3 ) ) ) + { + rFormatExtension = UniString::CreateFromAscii( "EPS", 3 ); + return TRUE; + } + } + + //--------------------------- DXF ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "DXF", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested=TRUE; + + i=0; + while (i<256 && sFirstBytes[i]<=32) + i++; + + if (i<256) + { + if( sFirstBytes[i]=='0' ) + i++; + else + i=256; + } + while( i<256 && sFirstBytes[i]<=32 ) + i++; + + if (i+7<256) + { + if (strncmp((char*)(sFirstBytes+i),"SECTION",7)==0) + { + rFormatExtension = UniString::CreateFromAscii( "DXF", 3 ); + return TRUE; + } + } + + if( strncmp( (char*) sFirstBytes, "AutoCAD Binary DXF", 18 ) == 0 ) + { + rFormatExtension = UniString::CreateFromAscii( "DXF", 3 ); + return TRUE; + } + } + + //--------------------------- PCT ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "PCT", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested = TRUE; + if( nStreamLen >= 525 ) + { + BYTE sBuf[4]; + sal_uInt32 nOffset; // in ms documents the pict format is used without the first 512 bytes + for ( nOffset = 10; nOffset <= 512; nOffset += 512 ) + { + rStream.Seek( nStreamPos + nOffset ); + rStream.Read( sBuf,3 ); + if ( sBuf[ 0 ] == 0x00 && sBuf[ 1 ] == 0x11 && ( sBuf[ 2 ] == 0x01 || sBuf[ 2 ] == 0x02 ) ) + { + rFormatExtension = UniString::CreateFromAscii( "PCT", 3 ); + return TRUE; + } + } + } + } + + //------------------------- PBM + PGM + PPM --------------------------- + if( !bTest || + ( rFormatExtension.CompareToAscii( "PBM", 3 ) == COMPARE_EQUAL ) || + ( rFormatExtension.CompareToAscii( "PGM", 3 ) == COMPARE_EQUAL ) || + ( rFormatExtension.CompareToAscii( "PPM", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested=TRUE; + if ( sFirstBytes[ 0 ] == 'P' ) + { + switch( sFirstBytes[ 1 ] ) + { + case '1' : + case '4' : + rFormatExtension = UniString::CreateFromAscii( "PBM", 3 ); + return TRUE; + + case '2' : + case '5' : + rFormatExtension = UniString::CreateFromAscii( "PGM", 3 ); + return TRUE; + + case '3' : + case '6' : + rFormatExtension = UniString::CreateFromAscii( "PPM", 3 ); + return TRUE; + } + } + } + + //--------------------------- RAS( SUN RasterFile )------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "RAS", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested=TRUE; + if( nFirstLong == 0x59a66a95 ) + { + rFormatExtension = UniString::CreateFromAscii( "RAS", 3 ); + return TRUE; + } + } + + //--------------------------- XPM ------------------------------------ + if( !bTest ) + { + bSomethingTested = TRUE; + if( ImplSearchEntry( sFirstBytes, (BYTE*)"/* XPM */", 256, 9 ) ) + { + rFormatExtension = UniString::CreateFromAscii( "XPM", 3 ); + return TRUE; + } + } + else if( rFormatExtension.CompareToAscii( "XPM", 3 ) == COMPARE_EQUAL ) + { + bSomethingTested = TRUE; + return TRUE; + } + + //--------------------------- XBM ------------------------------------ + if( !bTest ) + { + ULONG nSize = ( nStreamLen > 2048 ) ? 2048 : nStreamLen; + BYTE* pBuf = new BYTE [ nSize ]; + + rStream.Seek( nStreamPos ); + rStream.Read( pBuf, nSize ); + BYTE* pPtr = ImplSearchEntry( pBuf, (BYTE*)"#define", nSize, 7 ); + + if( pPtr ) + { + if( ImplSearchEntry( pPtr, (BYTE*)"_width", pBuf + nSize - pPtr, 6 ) ) + { + rFormatExtension = UniString::CreateFromAscii( "XBM", 3 ); + delete pBuf; + return TRUE; + } + } + delete pBuf; + } + else if( rFormatExtension.CompareToAscii( "XBM", 3 ) == COMPARE_EQUAL ) + { + bSomethingTested = TRUE; + return TRUE; + } + + //--------------------------- TGA ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "TGA", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested = TRUE; + if( rFormatExtension.CompareToAscii( "TGA", 3 ) == COMPARE_EQUAL ) + return TRUE; + } + + //--------------------------- SGV ------------------------------------ + if( !bTest || ( rFormatExtension.CompareToAscii( "SGV", 3 ) == COMPARE_EQUAL ) ) + { + bSomethingTested = TRUE; + if( rFormatExtension.CompareToAscii( "SGV", 3 ) == COMPARE_EQUAL ) + return TRUE; + } + + return bTest && !bSomethingTested; +} + +//-------------------------------------------------------------------------- + +static USHORT ImpTestOrFindFormat( GraphicFilter& rFilter, Config& rConfig, const String& rPath, + SvStream& rStream, String* pConfigString, USHORT* pFormat ) +{ + USHORT n = rConfig.GetKeyCount(); + +#ifdef MAC + // ggf. Filter anhand der Mac-Typen raussuchen: + if( *pFormat == GRFILTER_FORMAT_DONTKNOW ) + { + String aFormType; + String aType; + SvEaMgr aFile( rPath ); + + aFile.GetFileType( aType ); + aType.Cut( 4 ); + + for( USHORT i = 0; i < n; i++ ) + { + aFormType=ImpGetMacType(rConfig.ReadKey(i)); + aFormType.Cut( 4 ); + if( aFormType == aType && aFormType != "????" ) + { + *pFormat = i; + break; + } + } + } +#endif + + // ggf. Filter bzw. Format durch anlesen ermitteln, + // oder durch anlesen zusichern, dass das Format stimmt: + if( *pFormat == GRFILTER_FORMAT_DONTKNOW ) + { + String aFormatExt; + + if( ImpPeekGraphicFormat( rStream, aFormatExt, FALSE ) ) + { + // teuer + for( USHORT i = 0; i < n; i++ ) + { + UniString aConfigString( rConfig.ReadKey( i ), RTL_TEXTENCODING_UTF8 ); + + if( ImpGetFormatExtension( aConfigString ).ToUpperAscii() == aFormatExt ) + { + *pFormat = i; + + if( pConfigString ) + *pConfigString = aConfigString; + + return GRFILTER_OK; + } + } + } + + // ggf. Filter anhand der Datei-Endung raussuchen: + if( rPath.Len() ) + { + String aExt( ImpGetExtension( rPath ) ); + + for( USHORT i = 0; i < n; i++ ) + { + String aConfigString( rConfig.ReadKey( i ), RTL_TEXTENCODING_UTF8 ); + + if( ImpGetFormatExtension( aConfigString ).ToUpperAscii() == aExt ) + { + *pFormat = i; + + if( pConfigString ) + *pConfigString = aConfigString; + + return GRFILTER_OK; + } + } + } + + return GRFILTER_FORMATERROR; + } + else + { + String aConfigString( rConfig.ReadKey( *pFormat ), RTL_TEXTENCODING_UTF8 ); + String aFormatExt( ImpGetFormatExtension( aConfigString ).ToUpperAscii() ); + + if( !ImpPeekGraphicFormat( rStream, aFormatExt, TRUE ) ) + return GRFILTER_FORMATERROR; + + if( pConfigString ) + *pConfigString = aConfigString; + } + + return GRFILTER_OK; +} + +//-------------------------------------------------------------------------- + +static void ImpCorrectFilterUpdateNumber( String & rFilter ) +{ + xub_StrLen i, nq, npq; + + String aUPD( UniString::CreateFromInt32( SOLARUPD ) ); + String aDllExt( __DLLEXTENSION, RTL_TEXTENCODING_UTF8 ); + + aDllExt.Erase( 2 ); + + const sal_Unicode* pSource = rFilter.GetBuffer(); + const sal_Unicode* pEnd = pSource + rFilter.Len(); + + // Fragezeichen suchen + for( i = 0, nq = 0; pSource != pEnd; i++ ) + { + if( *pSource++ == '?' ) + { + if( nq == 0 ) + npq = i; + nq++; + } + else if( nq == aUPD.Len() ) + break; + else + nq = 0; + } + + // Fragezeichen durch UPD-Nummer ersetzen + if( nq == aUPD.Len() ) + rFilter.Replace( npq, nq, aUPD ); + + // Sternchen suchen + pSource = rFilter.GetBuffer(); + for( i = 0, nq = 0; pSource != pEnd; i++ ) + { + if( *pSource++ == '*' ) + { + if( nq == 0 ) + npq=i; + nq++; + } + else if( nq == 2 ) + break; + else + nq=0; + } + // Sternchen durch Plattform-Kuerzel ersetzen + if( nq == 2 ) + rFilter.Replace( npq, nq, aDllExt ); +} + +//-------------------------------------------------------------------------- + +static Graphic ImpGetScaledGraphic( const Graphic& rGraphic, const String& rFilterExt, Config* pOptions ) +{ + Graphic aGraphic; + ByteString aResMgrName( "svt", 3 ); + ResMgr* pResMgr; + + aResMgrName.Append( ByteString::CreateFromInt32( SOLARUPD ) ); + pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetAppInternational().GetLanguage() ); + + if ( ( rGraphic.GetType() != GRAPHIC_NONE ) && pOptions ) + { + String aStrMode( rFilterExt ); + sal_Int32 nMode; + aStrMode += String( ResId( KEY_MODE, pResMgr ) ); + + nMode = pOptions->ReadKey( ByteString( aStrMode, RTL_TEXTENCODING_UTF8 ) ).ToInt32(); + + if( rGraphic.GetType() == GRAPHIC_BITMAP ) + { + // Auflösung wird eingestellt + if( nMode == 1 ) + { + Bitmap aBitmap( rGraphic.GetBitmap() ); + MapMode aMap( MAP_100TH_INCH ); + + String aKey( rFilterExt ); + aKey += String( ResId( KEY_RES, pResMgr ) ); + long nDPI = pOptions->ReadKey( ByteString( aKey, RTL_TEXTENCODING_UTF8 ) ).ToInt32(); + Fraction aFrac( 1, Min( Max( nDPI, 75L ), 600L ) ); + + aMap.SetScaleX( aFrac ); + aMap.SetScaleY( aFrac ); + + Size aOldSize = aBitmap.GetSizePixel(); + aBitmap.SetPrefMapMode( aMap ); + aBitmap.SetPrefSize( Size( aOldSize.Width() * 100, + aOldSize.Height() * 100 ) ); + + aGraphic = Graphic( aBitmap ); + } + // Groesse wird eingestellt + else if( nMode == 2 ) + { + Bitmap aBitmap( rGraphic.GetBitmap() ); + String aKeyDX( rFilterExt ); + aKeyDX += String( ResId( KEY_SIZEX, pResMgr ) ); + long nDX = pOptions->ReadKey( ByteString( aKeyDX, RTL_TEXTENCODING_UTF8 ) ).ToInt32(); + String aKeyDY( rFilterExt ); + aKeyDY += String( ResId( KEY_SIZEY, pResMgr ) ); + long nDY = pOptions->ReadKey( ByteString( aKeyDY, RTL_TEXTENCODING_UTF8 ) ).ToInt32(); + + aBitmap.SetPrefMapMode( MapMode( MAP_100TH_MM ) ); + aBitmap.SetPrefSize( Size( nDX, nDY ) ); + aGraphic = Graphic( aBitmap ); + } + else + aGraphic = rGraphic; + } + else + { + if( ( nMode == 1 ) || ( nMode == 2 ) ) + { + GDIMetaFile aMtf( rGraphic.GetGDIMetaFile() ); + String aKeyDX( rFilterExt ); + aKeyDX += String( ResId( KEY_SIZEX, pResMgr ) ); + long nDX = pOptions->ReadKey( ByteString( aKeyDX, RTL_TEXTENCODING_UTF8 ) ).ToInt32(); + String aKeyDY( rFilterExt ); + aKeyDY += String( ResId( KEY_SIZEY, pResMgr ) ); + long nDY = pOptions->ReadKey( ByteString( aKeyDY, RTL_TEXTENCODING_UTF8 ) ).ToInt32(); + Size aNewSize( OutputDevice::LogicToLogic( Size( nDX, nDY ), MAP_100TH_MM, aMtf.GetPrefMapMode() ) ); + + if( aNewSize.Width() && aNewSize.Height() ) + { + const Size aPrefSize( aMtf.GetPrefSize() ); + aMtf.Scale( Fraction( aNewSize.Width(), aPrefSize.Width() ), + Fraction( aNewSize.Height(), aPrefSize.Height() ) ); + } + + aGraphic = Graphic( aMtf ); + } + else + aGraphic = rGraphic; + } + } + else + aGraphic = rGraphic; + + delete pResMgr; + + return aGraphic; +} + +// -------------------------- +// - ImpFilterLibCacheEntry - +// -------------------------- + +class ImpFilterLibCache; + +struct ImpFilterLibCacheEntry +{ + ImpFilterLibCacheEntry* mpNext; + ::vos::OModule maLibrary; + String maFiltername; + PFilterCall mpfnImport; + PFilterDlgCall mpfnImportDlg; + + ImpFilterLibCacheEntry( const String& rPathname, const String& rFiltername ); + int operator==( const String& rFiltername ) const { return maFiltername == rFiltername; } + + PFilterCall GetImportFunction(); + PFilterDlgCall GetImportDlgFunction(); + PFilterCall GetExportFunction() { return (PFilterCall) maLibrary.getSymbol( UniString::CreateFromAscii( EXPORT_FUNCTION_NAME ) ); } + PFilterDlgCall GetExportDlgFunction() { return (PFilterDlgCall) maLibrary.getSymbol( UniString::CreateFromAscii( EXPDLG_FUNCTION_NAME ) ); } +}; + +// ------------------------------------------------------------------------ + +ImpFilterLibCacheEntry::ImpFilterLibCacheEntry( const String& rPathname, const String& rFiltername ) : + mpNext ( NULL ), + maLibrary ( rPathname ), + maFiltername ( rFiltername ), + mpfnImport ( NULL ), + mpfnImportDlg ( NULL ) +{ +} + +// ------------------------------------------------------------------------ + +PFilterCall ImpFilterLibCacheEntry::GetImportFunction() +{ + if( !mpfnImport ) + mpfnImport = (PFilterCall) maLibrary.getSymbol( UniString::CreateFromAscii( IMPORT_FUNCTION_NAME ) ); + + return mpfnImport; +} + +// ------------------------------------------------------------------------ + +PFilterDlgCall ImpFilterLibCacheEntry::GetImportDlgFunction() +{ + if( !mpfnImportDlg ) + mpfnImportDlg = (PFilterDlgCall)maLibrary.getSymbol( UniString::CreateFromAscii( IMPDLG_FUNCTION_NAME ) ); + + return mpfnImportDlg; +} + +// --------------------- +// - ImpFilterLibCache - +// --------------------- + +class ImpFilterLibCache +{ + ImpFilterLibCacheEntry* mpFirst; + ImpFilterLibCacheEntry* mpLast; + ImpFilterLibCacheEntry* mpLastUsed; + +public: + ImpFilterLibCache(); + ~ImpFilterLibCache(); + + ImpFilterLibCacheEntry* GetFilter( INetURLObject& rFilter, const String& rFiltername ); +}; + +// ------------------------------------------------------------------------ + +ImpFilterLibCache::ImpFilterLibCache() : + mpFirst ( NULL ), + mpLast ( NULL ), + mpLastUsed ( NULL ) +{ +} + +// ------------------------------------------------------------------------ + +ImpFilterLibCache::~ImpFilterLibCache() +{ + ImpFilterLibCacheEntry* pEntry = mpFirst; + while( pEntry ) + { + ImpFilterLibCacheEntry* pNext = pEntry->mpNext; + delete pEntry; + pEntry = pNext; + } +} + +// ------------------------------------------------------------------------ + +ImpFilterLibCacheEntry* ImpFilterLibCache::GetFilter( INetURLObject& rFilter, const String& rFiltername ) +{ + if( mpLastUsed && ( *mpLastUsed == rFiltername ) ) + return mpLastUsed; + else + { + ImpFilterLibCacheEntry* pEntry = mpFirst; + + while( pEntry ) + { + if( *pEntry == rFiltername ) + break; + else + pEntry = pEntry->mpNext; + } + + if( !pEntry ) + { + pEntry = new ImpFilterLibCacheEntry( rFilter.GetFull(), rFiltername ); + + if( !mpFirst ) + mpFirst = mpLast = pEntry; + else + mpLast = mpLast->mpNext = pEntry; + } + + mpLastUsed = pEntry; + return pEntry; + } +}; + +// ------------------------------------------------------------------------ + +static ImpFilterLibCache aCache; + +// ----------------- +// - GraphicFilter - +// ----------------- + +GraphicFilter::GraphicFilter() +{ + ImplInit( String() ); +} + +// ------------------------------------------------------------------------ + +GraphicFilter::GraphicFilter( const INetURLObject& rPath ) +{ + ImplInit( rPath.PathToFileName() ); +} + +// ------------------------------------------------------------------------ + +GraphicFilter::GraphicFilter( const String& rMultiPath ) +{ + ImplInit( rMultiPath ); +} + +// ------------------------------------------------------------------------ + +GraphicFilter::~GraphicFilter() +{ + // no graphic filter, no handler => restore old handler + if( !--nFilterCount ) + Application::SetFilterHdl( aLastFilterHdl ); + + String aCfgPath( pConfig->GetPathName() ); + + delete pErrorEx; + delete pConfig; + delete pConfigPath; + delete pFilterPath; + delete pOptionsConfigPath; + + if( pOptionsConfig ) + { + pOptionsConfig->Flush(); + delete pOptionsConfig; + } + ImplDirEntryHelper::Kill( aCfgPath ); +} + +// ------------------------------------------------------------------------ + +void GraphicFilter::ImplInit( const String& rInitPath ) +{ + pErrorEx = new FilterErrorEx; + pConfig = new Config( TempFile::CreateTempName() ); + pConfig->EnablePersistence( FALSE ); + pConfigPath = new String; + pFilterPath = new String; + pOptionsConfigPath = new String; + + ImplCreateMultiConfig( rInitPath ); + pOptionsConfig = NULL; + bOptionsEnabled = FALSE; + nPercent = 0; + bAbort = FALSE; + bCacheEnabled = TRUE; + + // first instance of GraphicFilter sets link + if( !nFilterCount++ ) + { + // save old link + aLastFilterHdl = Application::GetFilterHdl(); + Application::SetFilterHdl( LINK( this, GraphicFilter, FilterCallback ) ); + } +} + +// ------------------------------------------------------------------------ + +void GraphicFilter::ImplCreateMultiConfig( const String& rMultiPath ) +{ + *pConfigPath = rMultiPath; + + if( rMultiPath.Len() ) + { + for( long i = rMultiPath.GetTokenCount( ';' ); i; ) + { + Config aCfg( rMultiPath.GetToken( (USHORT) --i, ';' ) ); + + // clone import entries + if( aCfg.HasGroup( IMP_FILTERSECTION ) ) + { + aCfg.SetGroup( IMP_FILTERSECTION ); + pConfig->SetGroup( IMP_FILTERSECTION ); + + for( USHORT n = 0, nCount = aCfg.GetKeyCount(); n < nCount; n++ ) + pConfig->WriteKey( aCfg.GetKeyName( n ), aCfg.ReadKey( n ) ); + } + + // clone export entries + if( aCfg.HasGroup( EXP_FILTERSECTION ) ) + { + aCfg.SetGroup( EXP_FILTERSECTION ); + pConfig->SetGroup( EXP_FILTERSECTION ); + + for( USHORT n = 0, nCount = aCfg.GetKeyCount(); n < nCount; n++ ) + pConfig->WriteKey( aCfg.GetKeyName( n ), aCfg.ReadKey( n ) ); + } + } + } +} + +// ------------------------------------------------------------------------ + +ULONG GraphicFilter::ImplSetError( ULONG nError, const SvStream* pStm ) +{ + pErrorEx->nFilterError = nError; + pErrorEx->nStreamError = pStm ? pStm->GetError() : ERRCODE_NONE; + return nError; +} + +// ------------------------------------------------------------------------ + +void GraphicFilter::EnableConfigCache( BOOL bEnable ) +{ + bCacheEnabled = bEnable; +} + +// ------------------------------------------------------------------------ + +void GraphicFilter::SetConfigPath( const INetURLObject& rPath ) +{ + SetConfigPath( rPath.PathToFileName() ); +} + +// ------------------------------------------------------------------------ + +void GraphicFilter::SetConfigPath( const String& rMultiPath ) +{ + // delete old import group + if( pConfig->HasGroup( IMP_FILTERSECTION ) ) + pConfig->DeleteGroup( IMP_FILTERSECTION ); + + // delete old export group + if( pConfig->HasGroup( EXP_FILTERSECTION ) ) + pConfig->DeleteGroup( EXP_FILTERSECTION ); + + ImplCreateMultiConfig( rMultiPath ); +} + +// ------------------------------------------------------------------------ + +const String& GraphicFilter::GetConfigPath() const +{ + DBG_ASSERT( pConfigPath, "GraphicFilter::GetConfigPath(): Missing ConfigPath!" ); + return *pConfigPath; +} + +// ------------------------------------------------------------------------ + +Config& GraphicFilter::GetConfig() const +{ + DBG_ASSERT( pConfig, "GraphicFilter::GetConfig(): Missing Config!" ); + return *pConfig; +} + +// ------------------------------------------------------------------------ + +void GraphicFilter::SetFilterPath( const INetURLObject& rPath ) +{ + SetFilterPath( rPath.PathToFileName() ); +} + +// ------------------------------------------------------------------------ + +void GraphicFilter::SetFilterPath( const String& rMultiPath ) +{ + *pFilterPath = rMultiPath; + + // delete old filter path group + if( pConfig->HasGroup( IMPEXP_FILTERPATHES ) ) + pConfig->DeleteGroup( IMPEXP_FILTERPATHES ); + + pConfig->SetGroup( IMPEXP_FILTERPATHES ); + + // add new pathes to group + for( USHORT i = 0, nCount = rMultiPath.GetTokenCount( ';' ); i < nCount; i++ ) + { + INetURLObject aPath; + aPath.SetSmartURL( rMultiPath.GetToken( i, ';' ) ); + if( ImplDirEntryHelper::Exists( aPath ) ) + { + ByteString aKey( 'P' ); + aKey += ByteString::CreateFromInt32( i ); + pConfig->WriteKey( aKey, aPath.PathToFileName(), RTL_TEXTENCODING_UTF8 ); + } + } +} + +// ------------------------------------------------------------------------ + +const String& GraphicFilter::GetFilterPath() const +{ + DBG_ASSERT( pFilterPath, "GraphicFilter::GetFilterPath(): Missing FilterPath!" ); + return *pFilterPath; +} + +// ------------------------------------------------------------------------ + +void GraphicFilter::SetOptionsConfigPath( const INetURLObject& rConfigPath ) +{ + const String aNewPath( rConfigPath.PathToFileName() ); + + if( aNewPath != GetOptionsConfigPath() ) + { + *pOptionsConfigPath = aNewPath; + + if( pOptionsConfig ) + { + pOptionsConfig->Flush(); + delete pOptionsConfig; + } + + if( aNewPath.Len() ) + { + pOptionsConfig = new Config( aNewPath ); + pOptionsConfig->SetGroup( OPT_FILTERSECTION ); + bOptionsEnabled = TRUE; + } + else + { + pOptionsConfig = NULL; + bOptionsEnabled = FALSE; + } + } +} + +// ------------------------------------------------------------------------ + +const String& GraphicFilter::GetOptionsConfigPath() const +{ + DBG_ASSERT( pOptionsConfigPath, "GraphicFilter::GetOptionsConfigPath(): Missing OptionsConfigPath!" ); + return *pOptionsConfigPath; +} + +// ------------------------------------------------------------------------ + +USHORT GraphicFilter::GetImportFormatCount() +{ + DBG_ASSERT (pConfig,"GraphicFilter::GetImportFormatCount() : no Config" ); + + pConfig->SetGroup( IMP_FILTERSECTION ); + return pConfig->GetKeyCount(); +} + +// ------------------------------------------------------------------------ + +USHORT GraphicFilter::GetImportFormatNumber( const String& rFormatName ) +{ + DBG_ASSERT( pConfig,"GraphicFilter::GetImportFormatNumber() : no Config" ); + + pConfig->SetGroup( IMP_FILTERSECTION ); + + USHORT nKeys = pConfig->GetKeyCount(); + USHORT i = 0; + String aFormatStr; + String aUpperFormat( rFormatName ); + + aUpperFormat.ToUpperAscii(); + + xub_StrLen nLen = aUpperFormat.Len(); + while( i < nKeys ) + { + UniString aFormat( pConfig->ReadKey( i ), RTL_TEXTENCODING_UTF8 ); + if( ImpGetFormatName( aFormat ).CompareIgnoreCaseToAscii( aUpperFormat.GetBuffer(), nLen ) == COMPARE_EQUAL ) + break; + + i++; + } + + return( ( i == nKeys ) ? GRFILTER_FORMAT_NOTFOUND : i ); +} + +// ------------------------------------------------------------------------ + +String GraphicFilter::GetImportFormatName( USHORT nFormat ) +{ + DBG_ASSERT( pConfig,"GraphicFilter::GetImportFormatName() : no Config" ); + + pConfig->SetGroup( IMP_FILTERSECTION ); + UniString aFormat( pConfig->ReadKey( nFormat ), RTL_TEXTENCODING_UTF8 ); + return ImpGetFormatName( aFormat ); +} + +// ------------------------------------------------------------------------ + +String GraphicFilter::GetImportFormatShortName( USHORT nFormat ) +{ + DBG_ASSERT( pConfig,"GraphicFilter::GetImportFormatShortName() : no Config" ); + + pConfig->SetGroup( IMP_FILTERSECTION ); + return UniString( pConfig->GetKeyName( nFormat ), RTL_TEXTENCODING_UTF8 ); +} + +// ------------------------------------------------------------------------ + +String GraphicFilter::GetImportFormatType( USHORT nFormat ) +{ + DBG_ASSERT( pConfig,"GraphicFilter::GetImportFormatType() : no Config" ); + + pConfig->SetGroup( IMP_FILTERSECTION ); + +#ifdef MAC + + String aStr=ImpGetMacType( pConfig->ReadKey( nFormat ) ); + + if( !aStr.Len() ) + { + aStr = "????."; + aStr += ImpGetFormatExtension( pConfig->ReadKey(nFormat) ); + } + + return aStr; + +#else + + return ImpGetFormatExtension( UniString( pConfig->ReadKey( nFormat ), RTL_TEXTENCODING_UTF8 ) ); + +#endif +} + +// ------------------------------------------------------------------------ + +String GraphicFilter::GetImportOSFileType( USHORT nFormat ) +{ + String aOSFileType; + +#ifdef MAC + + DBG_ASSERT( pConfig,"GraphicFilter::GetImportOSFileType() : no Config" ); + pConfig->SetGroup( IMP_FILTERSECTION ); + aOSFileType = ImpGetMacType( pConfig->ReadKey( nFormat ) ); + +#endif + + return aOSFileType; +} + +// ------------------------------------------------------------------------ + +String GraphicFilter::GetImportWildcard( USHORT nFormat ) +{ + DBG_ASSERT( pConfig,"GraphicFilter::GetImportWildcard() : no Config" ); + + String aWildcard( UniString::CreateFromAscii( "*.", 2 ) ); + pConfig->SetGroup( IMP_FILTERSECTION ); + aWildcard.Append( ImpGetFormatExtension( UniString( pConfig->ReadKey( nFormat ), RTL_TEXTENCODING_UTF8 ) ) ); + return aWildcard; +} + +// ------------------------------------------------------------------------ + +BOOL GraphicFilter::IsImportPixelFormat( USHORT nFormat ) +{ + DBG_ASSERT( pConfig,"GraphicFilter::IsImportPixelFormat() : no Config" ); + + pConfig->SetGroup( IMP_FILTERSECTION ); + return ( ImpGetNthEntry( UniString( pConfig->ReadKey( nFormat ), RTL_TEXTENCODING_UTF8 ), 5 ) + .CompareIgnoreCaseToAscii( "PIX", 3 ) == COMPARE_EQUAL ); +} + +// ------------------------------------------------------------------------ + +USHORT GraphicFilter::GetExportFormatCount() +{ + DBG_ASSERT( pConfig,"GraphicFilter:: : no Config" ); + + pConfig->SetGroup( EXP_FILTERSECTION ); + return pConfig->GetKeyCount(); +} + +// ------------------------------------------------------------------------ + +USHORT GraphicFilter::GetExportFormatNumber( const String& rFormatName ) +{ + DBG_ASSERT( pConfig,"GraphicFilter:: : no Config" ); + + pConfig->SetGroup( EXP_FILTERSECTION ); + + USHORT nKeys = pConfig->GetKeyCount(); + USHORT i = 0; + String aUpperFormat( rFormatName ); + while( i < nKeys ) + { + UniString aTemp( pConfig->ReadKey( i ), RTL_TEXTENCODING_UTF8 ); + if( ImpGetFormatName( aTemp ).EqualsIgnoreCaseAscii( aUpperFormat ) ) + break; + i++; + } + + return( ( i == nKeys ) ? GRFILTER_FORMAT_NOTFOUND : i ); +} + +// ------------------------------------------------------------------------ + +String GraphicFilter::GetExportFormatName( USHORT nFormat ) +{ + DBG_ASSERT( pConfig,"GraphicFilter:: : no Config" ); + + pConfig->SetGroup( EXP_FILTERSECTION ); + return ImpGetFormatName( UniString( pConfig->ReadKey( nFormat ), RTL_TEXTENCODING_UTF8 ) ); +} + +// ------------------------------------------------------------------------ + +String GraphicFilter::GetExportFormatShortName( USHORT nFormat ) +{ + DBG_ASSERT( pConfig,"GraphicFilter:: : no Config" ); + + pConfig->SetGroup( EXP_FILTERSECTION ); + return UniString( pConfig->GetKeyName( nFormat ), RTL_TEXTENCODING_UTF8 ); +} + +// ------------------------------------------------------------------------ + +String GraphicFilter::GetExportFormatType( USHORT nFormat ) +{ + DBG_ASSERT( pConfig,"GraphicFilter:: : no Config" ); + + pConfig->SetGroup( EXP_FILTERSECTION ); + +#ifdef MAC + + String aStr = ImpGetMacType( pConfig->ReadKey( nFormat ) ); + + if ( !aStr.Len() ) + { + aStr = "????."; + aStr += ImpGetFormatExtension( pConfig->ReadKey(nFormat) ); + } + + return aStr; + +#else + + return ImpGetFormatExtension( UniString( pConfig->ReadKey( nFormat ), RTL_TEXTENCODING_UTF8 ) ); + +#endif +} + +// ------------------------------------------------------------------------ + +String GraphicFilter::GetExportOSFileType( USHORT nFormat ) +{ + String aOSFileType; + +#ifdef MAC + + DBG_ASSERT( pConfig,"GraphicFilter::GetExportOSFileType() : no Config" ); + + pConfig->SetGroup( EXP_FILTERSECTION ); + aOSFileType = ImpGetMacType( pConfig->ReadKey( nFormat ) ); + +#endif + + return aOSFileType; +} + +// ------------------------------------------------------------------------ + +String GraphicFilter::GetExportWildcard( USHORT nFormat ) +{ + DBG_ASSERT( pConfig,"GraphicFilter::GetExportWildcard() : no Config" ); + + String aWildcard( UniString::CreateFromAscii( "*.", 2 ) ); + pConfig->SetGroup( EXP_FILTERSECTION ); + aWildcard.Append( ImpGetFormatExtension( UniString( pConfig->ReadKey( nFormat ), RTL_TEXTENCODING_UTF8 ) ) ); + return aWildcard; +} + +// ------------------------------------------------------------------------ + +BOOL GraphicFilter::IsExportPixelFormat( USHORT nFormat ) +{ + DBG_ASSERT( pConfig,"GraphicFilter::IsExportPixelFormat() : no Config" ); + + pConfig->SetGroup( EXP_FILTERSECTION ); + return ( ImpGetNthEntry( UniString( pConfig->ReadKey( nFormat ), RTL_TEXTENCODING_UTF8 ), 5 ) + .CompareIgnoreCaseToAscii( "PIX", 3 ) == COMPARE_EQUAL ); +} + +// ------------------------------------------------------------------------ + +USHORT GraphicFilter::CanImportGraphic( const INetURLObject& rPath, + USHORT nFormat, USHORT* pDeterminedFormat ) +{ + String aPath( rPath.PathToFileName() ); + SvFileStream aIStream( aPath, STREAM_READ | STREAM_SHARE_DENYNONE ); + + return CanImportGraphic( aPath, aIStream, nFormat, pDeterminedFormat ); +} + +// ------------------------------------------------------------------------ + +USHORT GraphicFilter::CanImportGraphic( const String& rPath, SvStream& rIStream, + USHORT nFormat, USHORT* pDeterminedFormat ) +{ + DBG_ASSERT(pConfig,"GraphicFilter:: : no Config"); + + if( !bCacheEnabled || pConfig->GetGroup() != IMP_FILTERSECTION ) + pConfig->SetGroup( IMP_FILTERSECTION ); + + ULONG nStreamPos = rIStream.Tell(); + USHORT nRes = ImpTestOrFindFormat( *this, *pConfig, rPath, rIStream, NULL, &nFormat ); + + rIStream.Seek(nStreamPos); + + if( nRes==GRFILTER_OK && pDeterminedFormat!=NULL ) + *pDeterminedFormat = nFormat; + + return (USHORT) ImplSetError( nRes, &rIStream ); +} + +// ------------------------------------------------------------------------ + +USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const INetURLObject& rPath, + USHORT nFormat, USHORT * pDeterminedFormat ) +{ + const String aPath( rPath.PathToFileName() ); + SvFileStream aIStm( aPath, STREAM_READ | STREAM_SHARE_DENYNONE ); + + return ImportGraphic( rGraphic, aPath, aIStm, nFormat, pDeterminedFormat ); +} + +//------------------------------------------------------------------------- + +USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvStream& rIStream, + USHORT nFormat, USHORT* pDeterminedFormat ) +{ + ImpFilterCallbackData aCallbackData; + String aFilterName; + String aConfigString; + String aUpperName; + ULONG nStmBegin; + USHORT nStatus; + GraphicReader* pContext = rGraphic.GetContext(); + GfxLinkType eLinkType = GFX_LINK_TYPE_NONE; + BOOL bDummyContext = ( pContext == (GraphicReader*) 1 ); + const BOOL bLinkSet = rGraphic.IsLink(); + + ResetLastError(); + + if( !pContext || bDummyContext ) + { + DBG_ASSERT( pConfig,"GraphicFilter:: : no Config" ); + + if( bDummyContext ) + { + rGraphic.SetContext( NULL ); + nStmBegin = 0; + } + else + nStmBegin = rIStream.Tell(); + + if( !bCacheEnabled || pConfig->GetGroup() != IMP_FILTERSECTION ) + pConfig->SetGroup( IMP_FILTERSECTION ); + + aCallbackData.pFilt = this; + aCallbackData.pPercent = &nPercent; + aCallbackData.pUpdatePercentHdl = &aUpdatePercentHdlLink; + aCallbackData.pAbort = &bAbort; + aCallbackData.nFilePercentOfTotal = 100; + bAbort = FALSE; + nPercent = 0; + nStatus = ImpTestOrFindFormat( *this, *pConfig, rPath, rIStream, &aConfigString, &nFormat ); + + // Falls Pending, geben wir GRFILTER_OK zurueck, + // um mehr Bytes anzufordern + if( rIStream.GetError() == ERRCODE_IO_PENDING ) + { + rGraphic.SetContext( (GraphicReader*) 1 ); + rIStream.ResetError(); + rIStream.Seek( nStmBegin ); + return (USHORT) ImplSetError( GRFILTER_OK ); + } + + rIStream.Seek( nStmBegin ); + + if( ( nStatus != GRFILTER_OK ) || rIStream.GetError() ) + return (USHORT) ImplSetError( ( nStatus != GRFILTER_OK ) ? nStatus : GRFILTER_OPENERROR, &rIStream ); + + if( pDeterminedFormat != NULL ) + *pDeterminedFormat = nFormat; + + aUpperName = aFilterName = ImpGetFilterName( aConfigString ); + aUpperName.ToUpperAscii(); + } + else + { + if( pContext && !bDummyContext ) + aUpperName = pContext->GetUpperFilterName(); + + nStmBegin = 0; + nStatus = GRFILTER_OK; + } + + // read graphic + if( aUpperName.CompareToAscii( IMP_GIF ) == COMPARE_EQUAL ) + { + if( rGraphic.GetContext() == (GraphicReader*) 1 ) + rGraphic.SetContext( NULL ); + + if( !ImportGIF( rIStream, rGraphic, NULL ) ) + nStatus = GRFILTER_FILTERERROR; + else + eLinkType = GFX_LINK_TYPE_NATIVE_GIF; + } + else if( aUpperName.CompareToAscii( IMP_PNG ) == COMPARE_EQUAL ) + { + if ( rGraphic.GetContext() == (GraphicReader*) 1 ) + rGraphic.SetContext( NULL ); + if ( !ImportPNG( rIStream, rGraphic, NULL ) ) + nStatus = GRFILTER_FILTERERROR; + else + eLinkType = GFX_LINK_TYPE_NATIVE_PNG; + } + else if( aUpperName.CompareToAscii( IMP_JPEG ) == COMPARE_EQUAL ) + { + if( rGraphic.GetContext() == (GraphicReader*) 1 ) + rGraphic.SetContext( NULL ); + + if( !ImportJPEG( rIStream, rGraphic, NULL ) ) + nStatus = GRFILTER_FILTERERROR; + else + eLinkType = GFX_LINK_TYPE_NATIVE_JPG; + } + else if( aUpperName.CompareToAscii( IMP_XBM ) == COMPARE_EQUAL ) + { + if( rGraphic.GetContext() == (GraphicReader*) 1 ) + rGraphic.SetContext( NULL ); + + if( !ImportXBM( rIStream, rGraphic, NULL ) ) + nStatus = GRFILTER_FILTERERROR; + } + else if( aUpperName.CompareToAscii( IMP_XPM ) == COMPARE_EQUAL ) + { + if( rGraphic.GetContext() == (GraphicReader*) 1 ) + rGraphic.SetContext( NULL ); + + if( !ImportXPM( rIStream, rGraphic, NULL ) ) + nStatus = GRFILTER_FILTERERROR; + } + else if( ( aUpperName.CompareToAscii( IMP_BMP ) == COMPARE_EQUAL ) || + ( aUpperName.CompareToAscii( IMP_SVMETAFILE ) == COMPARE_EQUAL ) ) + { + // SV interne Importfilter fuer Bitmaps und MetaFiles + aStartFilterHdlLink.Call( this ); + nPercent = 60; + aUpdatePercentHdlLink.Call( this ); + rIStream >> rGraphic; + nPercent = 100; + aUpdatePercentHdlLink.Call( this ); + + if( rIStream.GetError() ) + nStatus = GRFILTER_FORMATERROR; + } + else if( ( aUpperName.CompareToAscii( IMP_WMF ) == COMPARE_EQUAL ) || + ( aUpperName.CompareToAscii( IMP_EMF ) == COMPARE_EQUAL ) ) + { + GDIMetaFile aMtf; + aStartFilterHdlLink.Call( this ); + nPercent = 1; + + if( !ConvertWMFToGDIMetaFile( rIStream, aMtf, &ImpFilterCallback, &aCallbackData ) ) + nStatus = GRFILTER_FORMATERROR; + else + { + rGraphic = aMtf; + eLinkType = GFX_LINK_TYPE_NATIVE_WMF; + } + } + else if( ( aUpperName.CompareToAscii( IMP_SVSGF ) == COMPARE_EQUAL ) + || ( aUpperName.CompareToAscii( IMP_SVSGV ) == COMPARE_EQUAL ) ) + { + USHORT nVersion; + unsigned char nTyp = CheckSgfTyp( rIStream, nVersion ); + + switch( nTyp ) + { + case SGF_BITIMAGE: + { + String aTempFileName( TempFile::CreateTempName() ); + SvFileStream aTempStream( aTempFileName, STREAM_READ | STREAM_WRITE | STREAM_SHARE_DENYNONE ); + + if( aTempStream.GetError() ) + return GRFILTER_OPENERROR; + + // SGF in temporaere Datei filtern + aStartFilterHdlLink.Call( this ); + nPercent = 30; + aUpdatePercentHdlLink.Call( this ); + + if( !SgfBMapFilter( rIStream, aTempStream ) ) + nStatus = GRFILTER_FILTERERROR; + else + { + nPercent = 60; + aUpdatePercentHdlLink.Call( this ); + aTempStream.Seek( 0L ); + aTempStream >> rGraphic; + + nPercent = 100; + aUpdatePercentHdlLink.Call( this ); + if( aTempStream.GetError() ) + nStatus = GRFILTER_FILTERERROR; + } + aTempStream.Close(); + ImplDirEntryHelper::Kill( aTempFileName ); + } + break; + + case SGF_SIMPVECT: + { + GDIMetaFile aMtf; + + aStartFilterHdlLink.Call( this ); + nPercent = 50; + aUpdatePercentHdlLink.Call( this ); + if( !SgfVectFilter( rIStream, aMtf ) ) + nStatus = GRFILTER_FILTERERROR; + else + { + nPercent = 100; + aUpdatePercentHdlLink.Call( this ); + rGraphic = Graphic( aMtf ); + } + } + break; + + case SGF_STARDRAW: + { + if( nVersion != SGV_VERSION ) + nStatus = GRFILTER_VERSIONERROR; + else + { + GDIMetaFile aMtf; + + aStartFilterHdlLink.Call( this ); + nPercent = 50; + aUpdatePercentHdlLink.Call( this ); + if( !SgfSDrwFilter( rIStream, aMtf, aFilterPath, aFilterPath, aConfigPath ) ) + nStatus = GRFILTER_FILTERERROR; + else + { + nPercent = 100; + aUpdatePercentHdlLink.Call( this ); + rGraphic = Graphic( aMtf ); + } + } + } + break; + + default: + { + nStatus = GRFILTER_FORMATERROR; + } + break; + } + } + else if( ImpGetFilterVendor( aConfigString ).CompareIgnoreCaseToAscii( "SD", 2 ) == COMPARE_EQUAL ) + { + ImpFilterLibCacheEntry* pFilter = NULL; + + pConfig->SetGroup( IMPEXP_FILTERPATHES ); + ImpCorrectFilterUpdateNumber( aFilterName ); + + // find first filter in filter pathes + for( USHORT i = 0, nPathCount = pConfig->GetKeyCount(); i < nPathCount; i++ ) + { + INetURLObject aFilterPath; + aFilterPath.SetSmartURL( UniString( pConfig->ReadKey( i ), RTL_TEXTENCODING_UTF8 ) ); + aFilterPath.Append( aFilterName ); + if ( pFilter = aCache.GetFilter( aFilterPath, aFilterName ) ) + { + if ( ImplDirEntryHelper::Exists( aFilterPath ) ) + break; + } + } + + if( !pFilter ) + nStatus = GRFILTER_FILTERERROR; + else + { + PFilterCall pFunc = pFilter->GetImportFunction(); + + if( !pFunc ) + nStatus = GRFILTER_FILTERERROR; + else + { + aStartFilterHdlLink.Call( this ); + aUpdatePercentHdlLink.Call( this ); + + if( !(*pFunc)( rIStream, rGraphic, &ImpFilterCallback, &aCallbackData, GetOptionsConfig(), FALSE ) ) + nStatus = GRFILTER_FORMATERROR; + else + { + nPercent = 100; + aUpdatePercentHdlLink.Call( this ); + + // try to set link type if format matches + if( nFormat != GRFILTER_FORMAT_DONTKNOW ) + { + const String aShortName( GetImportFormatShortName( nFormat ).ToUpperAscii() ); + + if( aShortName.CompareToAscii( TIF_SHORTNAME ) == COMPARE_EQUAL ) + eLinkType = GFX_LINK_TYPE_NATIVE_TIF; + else if( aShortName.CompareToAscii( MET_SHORTNAME ) == COMPARE_EQUAL ) + eLinkType = GFX_LINK_TYPE_NATIVE_MET; + else if( aShortName.CompareToAscii( PCT_SHORTNAME ) == COMPARE_EQUAL ) + eLinkType = GFX_LINK_TYPE_NATIVE_PCT; + } + } + } + } + } + else + nStatus = GRFILTER_FILTERERROR; + + // Set error code or try to set native buffer + if( nStatus != GRFILTER_OK ) + { + if( bAbort ) + nStatus = GRFILTER_ABORT; + + ImplSetError( nStatus, &rIStream ); + rIStream.Seek( nStmBegin ); + rGraphic.Clear(); + + if( nPercent ) + aErrorHdlLink.Call( this ); + } + else if( ( eLinkType != GFX_LINK_TYPE_NONE ) && !rGraphic.GetContext() && !bLinkSet ) + { + const ULONG nStmEnd = rIStream.Tell(); + const ULONG nBufSize = nStmEnd - nStmBegin; + + if( nBufSize ) + { + BYTE* pBuf = new BYTE[ nBufSize ]; + GraphicReader* pOldContext = rGraphic.GetContext(); + + rIStream.Seek( nStmBegin ); + rIStream.Read( pBuf, nBufSize ); + rGraphic.SetLink( GfxLink( pBuf, nBufSize, eLinkType, TRUE ) ); + } + } + + if( nPercent && !pContext ) + { + nPercent = 0; + aEndFilterHdlLink.Call( this ); + } + + return nStatus; +} + +// ------------------------------------------------------------------------ + +USHORT GraphicFilter::ExportGraphic( const Graphic& rGraphic, const INetURLObject& rPath, USHORT nFormat ) +{ + const BOOL bAlreadyExists = ImplDirEntryHelper::Exists( rPath ); + const String aPath( rPath.PathToFileName() ); + SvFileStream aOStm( aPath, STREAM_WRITE | STREAM_TRUNC ); + USHORT nRet = ExportGraphic( rGraphic, aPath, aOStm, nFormat ); + + aOStm.Close(); + + if( ( GRFILTER_OK != nRet ) && !bAlreadyExists ) + ImplDirEntryHelper::Kill( aPath ); + + return nRet; +} + +// ------------------------------------------------------------------------ + +USHORT GraphicFilter::ExportGraphic( const Graphic& rGraphic, const String& rPath, + SvStream& rOStm, USHORT nFormat ) +{ + DBG_ASSERT( pConfig, "GraphicFilter:: : no Config" ); + + USHORT nFormatCount = GetExportFormatCount(); + + ResetLastError(); + + if( nFormat == GRFILTER_FORMAT_DONTKNOW ) + { + INetURLObject aURL; + aURL.SetSmartURL( rPath ); + String aExt( aURL.GetFileExtension().ToUpperAscii() ); + + + for( USHORT i = 0; i < nFormatCount; i++ ) + { + if ( ImpGetFormatExtension( UniString( pConfig->ReadKey( i ), RTL_TEXTENCODING_UTF8 ) ) + .CompareIgnoreCaseToAscii( aExt ) == COMPARE_EQUAL ) + { + nFormat=i; + break; + } + } + } + + if( nFormat >= nFormatCount ) + return (USHORT) ImplSetError( GRFILTER_FORMATERROR ); + + ImpFilterCallbackData aCallbackData; + aCallbackData.pFilt=this; + aCallbackData.pPercent=&nPercent; + aCallbackData.pUpdatePercentHdl=&aUpdatePercentHdlLink; + aCallbackData.pAbort=&bAbort; + aCallbackData.nFilePercentOfTotal=100; + bAbort=FALSE; + + String aKey( pConfig->ReadKey( nFormat ), RTL_TEXTENCODING_UTF8 ); + String aFilterName( ImpGetFilterName( aKey ) ); + String aUpperName( aFilterName ); + String aFilterVendor( ImpGetFilterVendor( aKey ).ToUpperAscii() ); + String aPixOrVec( ImpGetFilterPixOrVec( aKey).ToUpperAscii() ); + + aUpperName.ToUpperAscii(); + nPercent=0; + aStartFilterHdlLink.Call(this); + aUpdatePercentHdlLink.Call(this); + + USHORT nStatus = GRFILTER_OK; + GraphicType eType; + Graphic aGraphic( ImpGetScaledGraphic( rGraphic, + UniString( pConfig->GetKeyName( nFormat ), RTL_TEXTENCODING_UTF8 ), + GetOptionsConfig() ) ); + + eType = aGraphic.GetType(); + + if( aPixOrVec.CompareToAscii( "PIX", 3 ) == COMPARE_EQUAL ) + { + if( eType != GRAPHIC_BITMAP ) + { + Size aSizePixel; + ULONG nColorCount,nBitsPerPixel,nNeededMem,nMaxMem; + VirtualDevice aVirDev; + + // Maximalen Speicherbedarf fuer das Bildes holen: + if( GetOptionsConfig() ) + nMaxMem = (UINT32)GetOptionsConfig()->ReadKey( "VEC-TO-PIX-MAX-KB", "1024" ).ToInt32(); + else + nMaxMem = 1024; + + nMaxMem *= 1024; // In Bytes + + // Berechnen, wie gross das Bild normalerweise werden wuerde: + aSizePixel=aVirDev.LogicToPixel(aGraphic.GetPrefSize(),aGraphic.GetPrefMapMode()); + + // Berechnen, wieviel Speicher das Bild benoetigen wuerde: + nColorCount=aVirDev.GetColorCount(); + if (nColorCount<=2) nBitsPerPixel=1; + else if (nColorCount<=4) nBitsPerPixel=2; + else if (nColorCount<=16) nBitsPerPixel=4; + else if (nColorCount<=256) nBitsPerPixel=8; + else if (nColorCount<=65536) nBitsPerPixel=16; + else nBitsPerPixel=24; + nNeededMem=((ULONG)aSizePixel.Width()*(ULONG)aSizePixel.Height()*nBitsPerPixel+7)/8; + + // ggf. Groesse des Bildes einschraenken: + if (nMaxMem<nNeededMem) + { + double fFak=sqrt(((double)nMaxMem)/((double)nNeededMem)); + aSizePixel.Width()=(ULONG)(((double)aSizePixel.Width())*fFak); + aSizePixel.Height()=(ULONG)(((double)aSizePixel.Height())*fFak); + } + + aVirDev.SetMapMode(MapMode(MAP_PIXEL)); + aVirDev.SetOutputSizePixel(aSizePixel); + Graphic aGraphic2=aGraphic; + aGraphic2.Draw(&aVirDev,Point(0,0),aSizePixel); // Gemein: dies aendert den MapMode + aVirDev.SetMapMode(MapMode(MAP_PIXEL)); + aGraphic=Graphic(aVirDev.GetBitmap(Point(0,0),aSizePixel)); + } + } + else if ( aPixOrVec.CompareToAscii( "VEC", 3 ) != COMPARE_EQUAL ) + nStatus=GRFILTER_FILTERERROR; + + if( GRFILTER_OK == nStatus ) + { + if( aUpperName.CompareToAscii( EXP_BMP ) == COMPARE_EQUAL ) + { + nPercent = 60; + aUpdatePercentHdlLink.Call( this ); + + if( !rOStm.GetError() ) + { + Bitmap aBmp( aGraphic.GetBitmap() ); + + if( GetOptionsConfig() ) + { + ResMgr* pResMgr = CREATERESMGR( svt ); + UniString aRLEKey( pConfig->GetKeyName( nFormat ), RTL_TEXTENCODING_UTF8 ); + + aRLEKey += UniString( ResId( KEY_RLE_CODING, pResMgr ) ); + ByteString aRLEStr( GetOptionsConfig()->ReadKey( ByteString( aRLEKey, RTL_TEXTENCODING_UTF8 ) ) ); + + // Wollen wir RLE-Kodiert speichern? + aGraphic.GetBitmap().Write( rOStm, aRLEStr.CompareIgnoreCaseToAscii( "FALSE", 5 ) != COMPARE_EQUAL ); + + delete pResMgr; + } + else + rOStm << aBmp; + } + + nPercent = 90; + aUpdatePercentHdlLink.Call( this ); + + if( rOStm.GetError() ) + nStatus = GRFILTER_IOERROR; + } + else if( aUpperName.CompareToAscii( EXP_SVMETAFILE ) == COMPARE_EQUAL ) + { + if( !rOStm.GetError() ) + { + GDIMetaFile aMTF; + + if ( eType != GRAPHIC_BITMAP ) + aMTF = aGraphic.GetGDIMetaFile(); + else + { + VirtualDevice aVirDev; + + aMTF.Record( &aVirDev ); + aGraphic.Draw( &aVirDev, Point(), aGraphic.GetPrefSize() ); + aMTF.Stop(); + aMTF.SetPrefSize( aGraphic.GetPrefSize() ); + aMTF.SetPrefMapMode( aGraphic.GetPrefMapMode() ); + } + + nPercent = 60; + aUpdatePercentHdlLink.Call( this ); + rOStm << aMTF; + nPercent = 90; + aUpdatePercentHdlLink.Call( this ); + } + + if( rOStm.GetError() ) + nStatus = GRFILTER_IOERROR; + } + else if ( aUpperName.CompareToAscii( EXP_WMF ) == COMPARE_EQUAL ) + { + if( !rOStm.GetError() ) + { + if( eType == GRAPHIC_GDIMETAFILE ) + { + if ( !ConvertGDIMetaFileToWMF( aGraphic.GetGDIMetaFile(), rOStm, &ImpFilterCallback, &aCallbackData ) ) + nStatus = GRFILTER_FORMATERROR; + } + else + { + Bitmap aBmp( aGraphic.GetBitmap() ); + GDIMetaFile aMTF; + VirtualDevice aVirDev; + + aMTF.Record( &aVirDev ); + aVirDev.DrawBitmap( Point(), aBmp ); + aMTF.Stop(); + aMTF.SetPrefSize( aBmp.GetSizePixel() ); + + if( !ConvertGDIMetaFileToWMF( aMTF, rOStm, &ImpFilterCallback, &aCallbackData) ) + nStatus = GRFILTER_FORMATERROR; + } + } + + if( rOStm.GetError() ) + nStatus = GRFILTER_IOERROR; + } + else if ( aUpperName.CompareToAscii( EXP_EMF ) == COMPARE_EQUAL ) + { + if( !rOStm.GetError() ) + { + if( eType == GRAPHIC_GDIMETAFILE ) + { + if ( !ConvertGDIMetaFileToEMF( aGraphic.GetGDIMetaFile(), rOStm, &ImpFilterCallback, &aCallbackData ) ) + nStatus = GRFILTER_FORMATERROR; + } + else + { + Bitmap aBmp( aGraphic.GetBitmap() ); + GDIMetaFile aMTF; + VirtualDevice aVirDev; + + aMTF.Record( &aVirDev ); + aVirDev.DrawBitmap( Point(), aBmp ); + aMTF.Stop(); + aMTF.SetPrefSize( aBmp.GetSizePixel() ); + + if( !ConvertGDIMetaFileToEMF( aMTF, rOStm, &ImpFilterCallback, &aCallbackData) ) + nStatus = GRFILTER_FORMATERROR; + } + } + + if( rOStm.GetError() ) + nStatus = GRFILTER_IOERROR; + } + else if( aUpperName.CompareToAscii( EXP_JPEG ) == COMPARE_EQUAL ) + { + if( !rOStm.GetError() ) + { + if( !ExportJPEG( rOStm, aGraphic, &ImpFilterCallback, &aCallbackData, GetOptionsConfig() ) ) + nStatus = GRFILTER_FORMATERROR; + } + + if( rOStm.GetError() ) + nStatus = GRFILTER_IOERROR; + } + else if( aUpperName.CompareToAscii( EXP_SVG ) == COMPARE_EQUAL ) + { + if( !rOStm.GetError() ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr( ::utl::getProcessServiceFactory() ); + + if( xMgr.is() ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > xSaxWriter( xMgr->createInstance( + ::rtl::OUString::createFromAscii( "com.sun.star.xml.sax.Writer" ) ), ::com::sun::star::uno::UNO_QUERY ); + + ::com::sun::star::uno::Reference< ::com::sun::star::svg::XSVGWriter > xSVGWriter( xMgr->createInstance( + ::rtl::OUString::createFromAscii( "com.sun.star.svg.SVGWriter" ) ), ::com::sun::star::uno::UNO_QUERY ); + + if( xSaxWriter.is() && xSVGWriter.is() ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::io::XActiveDataSource > xActiveDataSource( + xSaxWriter, ::com::sun::star::uno::UNO_QUERY ); + + if( xActiveDataSource.is() ) + { + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xStmIf( + static_cast< ::cppu::OWeakObject* >( new ImpFilterOutputStream( rOStm ) ) ); + + SvMemoryStream aMemStm( 65535, 65535 ); + + aMemStm.SetCompressMode( COMPRESSMODE_FULL ); + ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( aMemStm ); + + nPercent = 60; + aUpdatePercentHdlLink.Call( this ); + + xActiveDataSource->setOutputStream( ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >( + xStmIf, ::com::sun::star::uno::UNO_QUERY ) ); + ::com::sun::star::uno::Sequence< sal_Int8 > aMtfSeq( (sal_Int8*) aMemStm.GetData(), aMemStm.Tell() ); + xSVGWriter->write( xSaxWriter, aMtfSeq ); + nPercent = 90; + aUpdatePercentHdlLink.Call( this ); + } + } + } + } + } + else if( aFilterVendor.CompareToAscii( "SD" ) == COMPARE_EQUAL ) + { + INetURLObject aFilterFilePath; + BOOL bFound = FALSE; + + pConfig->SetGroup( IMPEXP_FILTERPATHES ); + ImpCorrectFilterUpdateNumber( aFilterName ); + + // find first filter in filter pathes + for( USHORT i = 0, nPathCount = pConfig->GetKeyCount(); i < nPathCount; i++ ) + { + aFilterFilePath.SetSmartURL( UniString( pConfig->ReadKey( i ), RTL_TEXTENCODING_UTF8 ) ); + aFilterFilePath.Append( aFilterName ); + if( ImplDirEntryHelper::Exists( aFilterFilePath ) ) + { + bFound = TRUE; + break; + } + } + + if( !bFound ) + nStatus = GRFILTER_FILTERERROR; + else + { + ::vos::OModule aLibrary( aFilterFilePath.PathToFileName() ); + PFilterCall pFunc = (PFilterCall) aLibrary.getSymbol( UniString::CreateFromAscii( EXPORT_FUNCTION_NAME ) ); + + if( pFunc ) + { + if( !rOStm.GetError() ) + { + if ( !(*pFunc)( rOStm, aGraphic, &ImpFilterCallback, &aCallbackData, GetOptionsConfig(), FALSE ) ) + nStatus = GRFILTER_FORMATERROR; + } + else + nStatus = GRFILTER_IOERROR; + } + else + nStatus = GRFILTER_FILTERERROR; + } + } + else + nStatus = GRFILTER_FILTERERROR; + } + + if( nStatus != GRFILTER_OK ) + { + if( bAbort ) + nStatus = GRFILTER_ABORT; + + ImplSetError( nStatus, &rOStm ); + aErrorHdlLink.Call( this ); + } + else + { + nPercent = 100; + aUpdatePercentHdlLink.Call( this ); + } + + aEndFilterHdlLink.Call( this ); + + return nStatus; +} + +// ------------------------------------------------------------------------ + +BOOL GraphicFilter::Setup( USHORT nFormat ) +{ + return FALSE; +} + +// ------------------------------------------------------------------------ + +BOOL GraphicFilter::HasImportDialog( USHORT nFormat ) +{ + BOOL bRet = FALSE; + + if( pConfig && GetOptionsConfig() ) + { + pConfig->SetGroup( IMP_FILTERSECTION ); + bRet = ( ImpGetFilterDialog( UniString( pConfig->ReadKey( nFormat ), RTL_TEXTENCODING_UTF8 ) ).CompareToAscii( "TRUE", 4 ) == COMPARE_EQUAL ); + } + + return bRet; +} + +// ------------------------------------------------------------------------ + +BOOL GraphicFilter::DoImportDialog( Window* pWindow, USHORT nFormat ) +{ + DBG_ASSERT( pConfig,"GraphicFilter:: : no Config" ); + DBG_ASSERT( GetOptionsConfig(),"GraphicFilter:: : no OptionsConfig" ); + + pConfig->SetGroup( IMP_FILTERSECTION ); + + String aFilterName( ImpGetFilterName( UniString( pConfig->ReadKey( nFormat ), RTL_TEXTENCODING_UTF8 ) ) ); + String aUpperName( aFilterName ); + BOOL bRet = FALSE; + + aUpperName.ToUpperAscii(); + + if( ( aUpperName.CompareToAscii( IMP_BMP ) == COMPARE_EQUAL ) || ( aUpperName.CompareToAscii( IMP_SVMETAFILE ) == COMPARE_EQUAL ) ) + { + // Bitmaps und SV-MetaFiles + } + else if( aUpperName.CompareToAscii( IMP_WMF ) == COMPARE_EQUAL ) + { + // Import-Filter fuer WMF + } + else if( ( aUpperName.CompareToAscii( IMP_SVSGF ) == COMPARE_EQUAL ) || ( aUpperName.CompareToAscii( IMP_SVSGV ) ) ) + { + // StarDraw- und StarWriter-Filter + } + else + { + // ladbare Filter + String aFilterVendor( ImpGetFilterVendor( UniString( pConfig->ReadKey( nFormat ), RTL_TEXTENCODING_UTF8 ) ) ); + + // eigene Filter + if( aFilterVendor.CompareToAscii( "SD", 2 ) == COMPARE_EQUAL ) + { + ImpFilterLibCacheEntry* pFilter = NULL; + + pConfig->SetGroup( IMPEXP_FILTERPATHES ); + ImpCorrectFilterUpdateNumber( aFilterName ); + + // find first filter in filter pathes + for( USHORT i = 0, nPathCount = pConfig->GetKeyCount(); i < nPathCount; i++ ) + { + INetURLObject aFilterPath; + aFilterPath.SetSmartURL( UniString( pConfig->ReadKey( i ), RTL_TEXTENCODING_UTF8 ) ); + if ( pFilter = aCache.GetFilter( aFilterPath, aFilterName ) ) + { + aFilterPath.Append( aFilterName ); + if ( ImplDirEntryHelper::Exists( aFilterPath ) ) + break; + } + } + + if( pFilter ) + { + PFilterDlgCall pFunc = pFilter->GetImportDlgFunction(); + + // Dialog in DLL ausfuehren + if( pFunc ) + { + FltCallDialogParameter aFltCallDlgPara( pWindow, NULL, GetOptionsConfig(), FUNIT_MM ); + bRet = (*pFunc)( aFltCallDlgPara ); + } + } + } + } + + return bRet; +} + +// ------------------------------------------------------------------------ + +BOOL GraphicFilter::HasExportDialog( USHORT nFormat ) +{ + BOOL bRet = FALSE; + + if( pConfig && GetOptionsConfig() ) + { + pConfig->SetGroup( EXP_FILTERSECTION ); + bRet = ( ImpGetFilterDialog( UniString( pConfig->ReadKey( nFormat ), RTL_TEXTENCODING_UTF8 ) ) + .CompareToAscii( "TRUE", 4 ) == COMPARE_EQUAL ); + } + + return bRet; +} + +// ------------------------------------------------------------------------ + +BOOL GraphicFilter::DoExportDialog( Window* pWindow, USHORT nFormat ) +{ + return DoExportDialog( pWindow, nFormat, FUNIT_MM ); +} + +BOOL GraphicFilter::DoExportDialog( Window* pWindow, USHORT nFormat, FieldUnit eFieldUnit ) +{ + DBG_ASSERT( pConfig,"GraphicFilter:: : no Config" ); + + pConfig->SetGroup( EXP_FILTERSECTION ); + + String aKey( pConfig->ReadKey( nFormat ), RTL_TEXTENCODING_UTF8 ); + String aFilterName( ImpGetFilterName( aKey ) ); + String aUpperName( aFilterName ); + String aFilterVendor( ImpGetFilterVendor( aKey ).ToUpperAscii() ); + BOOL bRet = FALSE; + + aUpperName.ToUpperAscii(); + + if( GetOptionsConfig() ) + GetOptionsConfig()->Update(); + + // Export-Dialog fuer Bitmap's, SVM's und WMF's + if( ( aUpperName.CompareToAscii( EXP_BMP ) == COMPARE_EQUAL ) || + ( aUpperName.CompareToAscii( EXP_SVMETAFILE ) == COMPARE_EQUAL ) || + ( aUpperName.CompareToAscii( EXP_WMF ) == COMPARE_EQUAL ) || + ( aUpperName.CompareToAscii( EXP_EMF ) == COMPARE_EQUAL ) || + ( aUpperName.CompareToAscii( EXP_JPEG ) == COMPARE_EQUAL ) ) + { + ByteString aResMgrName( "svt", 3 ); + ResMgr* pResMgr; + + aResMgrName.Append( ByteString::CreateFromInt32( SOLARUPD ) ); + pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetAppInternational().GetLanguage() ); + + FltCallDialogParameter aFltCallDlgPara( pWindow, pResMgr, GetOptionsConfig(), eFieldUnit ); + + // JPEG-Dialog + if( aUpperName.CompareToAscii( EXP_JPEG ) == COMPARE_EQUAL ) + bRet = ( DlgExportEJPG( aFltCallDlgPara ).Execute() == RET_OK ); + // Fuer Bitmaps nehmen wir den Pixel-Dialog + else if( aUpperName.CompareToAscii( EXP_BMP ) != COMPARE_EQUAL ) + { + aFltCallDlgPara.aFilterExt = UniString( pConfig->GetKeyName( nFormat ), RTL_TEXTENCODING_UTF8 ); + bRet = ( DlgExportVec( aFltCallDlgPara ).Execute() == RET_OK ); + } + // Fuer Vektorformate nehmen wir den Vektor-Dialog + else + { + aFltCallDlgPara.aFilterExt = UniString( pConfig->GetKeyName( nFormat ), RTL_TEXTENCODING_UTF8 ); + bRet = ( DlgExportPix( aFltCallDlgPara ).Execute() == RET_OK ); + } + + + delete pResMgr; + } + // ladbare Filter + else + { + // eigene Filter + if( aFilterVendor.CompareToAscii( "SD", 2 ) == COMPARE_EQUAL ) + { + INetURLObject aFilterFilePath; + BOOL bFound = FALSE; + + pConfig->SetGroup( IMPEXP_FILTERPATHES ); + ImpCorrectFilterUpdateNumber( aFilterName ); + + // find first filter in filter pathes + for( USHORT i = 0, nPathCount = pConfig->GetKeyCount(); i < nPathCount; i++ ) + { + aFilterFilePath.SetSmartURL( UniString( pConfig->ReadKey( i ), RTL_TEXTENCODING_UTF8 ) ); + aFilterFilePath.Append( aFilterName ); + + if( ImplDirEntryHelper::Exists( aFilterFilePath ) ) + { + bFound = TRUE; + break; + } + } + + if( bFound ) + { + ::vos::OModule aLibrary( aFilterFilePath.PathToFileName() ); + PFilterDlgCall pFunc = (PFilterDlgCall) aLibrary.getSymbol( UniString( EXPDLG_FUNCTION_NAME, RTL_TEXTENCODING_UTF8 ) ); + + // Dialog in DLL ausfuehren + if( pFunc ) + { + FltCallDialogParameter aFltCallDlgPara( pWindow, NULL, GetOptionsConfig(), eFieldUnit ); + bRet = (*pFunc)( aFltCallDlgPara ); + } + } + } + } + + if( bRet && GetOptionsConfig() ) + GetOptionsConfig()->Flush(); + + return bRet; +} + +// ------------------------------------------------------------------------ + +const FilterErrorEx& GraphicFilter::GetLastError() const +{ + return *pErrorEx; +} + +// ------------------------------------------------------------------------ + +void GraphicFilter::ResetLastError() +{ + pErrorEx->nFilterError = pErrorEx->nStreamError = 0UL; +} + +// ------------------------------------------------------------------------ + +IMPL_LINK( GraphicFilter, FilterCallback, ConvertData*, pData ) +{ + long nRet = 0L; + + if( pData ) + { + USHORT nFormat = GRFILTER_FORMAT_DONTKNOW; + ByteString aShortName; + const BOOL bOptions = AreOptionsEnabled(); + + EnableOptions( FALSE ); + + switch( pData->mnFormat ) + { + case( CVT_BMP ): aShortName = BMP_SHORTNAME; break; + case( CVT_GIF ): aShortName = GIF_SHORTNAME; break; + case( CVT_JPG ): aShortName = JPG_SHORTNAME; break; + case( CVT_MET ): aShortName = MET_SHORTNAME; break; + case( CVT_PCT ): aShortName = PCT_SHORTNAME; break; + case( CVT_PNG ): aShortName = PNG_SHORTNAME; break; + case( CVT_SVM ): aShortName = SVM_SHORTNAME; break; + case( CVT_TIF ): aShortName = TIF_SHORTNAME; break; + case( CVT_WMF ): aShortName = WMF_SHORTNAME; break; + case( CVT_EMF ): aShortName = EMF_SHORTNAME; break; + + default: + break; + } + + if( GRAPHIC_NONE == pData->maGraphic.GetType() || pData->maGraphic.GetContext() ) // Import + { + if( aShortName.Len() ) + { + for( USHORT i = 0, nCount = GetImportFormatCount(); i < nCount; i++ ) + { + ByteString aImpShortName( GetImportFormatShortName( i ), RTL_TEXTENCODING_UTF8 ); + aImpShortName.ToUpperAscii(); + if( aImpShortName.CompareTo( aShortName ) == COMPARE_EQUAL ) + { + nFormat = i; + break; + } + } + } + + nRet = ( ImportGraphic( pData->maGraphic, String(), pData->mrStm, nFormat ) == GRFILTER_OK ); + } + else if( aShortName.Len() ) // Export + { + for( USHORT i = 0, nCount = GetExportFormatCount(); i < nCount; i++ ) + { + ByteString aExpShortName( GetExportFormatShortName( i ), RTL_TEXTENCODING_UTF8 ); + aExpShortName.ToUpperAscii(); + if( aExpShortName.CompareTo( aShortName ) == COMPARE_EQUAL ) + { + nFormat = i; + break; + } + } + + if( nFormat ) + nRet = ( ExportGraphic( pData->maGraphic, String(), pData->mrStm, nFormat ) == GRFILTER_OK ); + } + + EnableOptions( bOptions ); + } + + return nRet; +} diff --git a/svtools/source/filter.vcl/filter/filter2.cxx b/svtools/source/filter.vcl/filter/filter2.cxx new file mode 100644 index 000000000000..01dd188534d7 --- /dev/null +++ b/svtools/source/filter.vcl/filter/filter2.cxx @@ -0,0 +1,1427 @@ +/************************************************************************* + * + * $RCSfile: filter2.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 <stdio.h> +#include <tools/stream.hxx> +#include <tools/debug.hxx> +#include <vcl/outdev.hxx> +#include <vcl/config.hxx> +#include "filter.hxx" + +#define DATA_SIZE 640 +#define IMP_FILTERSECTION "Graphics Filters - Import" + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +GraphicDescriptor::GraphicDescriptor( const String* pPath ) +{ + ImpConstruct(); + + if ( pPath ) + { + INetURLObject aURL( *pPath, INET_PROT_FILE ); + aPathExt = aURL.GetFileExtension().ToLowerAscii(); + } + + bLinked = TRUE; + bLinkChanged = FALSE; + bWideSearch = FALSE; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +GraphicDescriptor::GraphicDescriptor( const INetURLObject& rPath ) : + aFileStm( rPath.PathToFileName(), STREAM_READ ), + aPathExt( rPath.GetFileExtension().ToLowerAscii() ) +{ + ImpConstruct(); + + if ( aFileStm.IsOpen() && !aFileStm.GetError() ) + { + nStmPos = 0; + aFileStm.Seek( nStmPos ); + bDataReady = TRUE; + } +} + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +GraphicDescriptor::GraphicDescriptor( SvStream& rInStream, const String* pPath) +{ + ImpConstruct(); + + if ( pPath ) + { + INetURLObject aURL( *pPath, INET_PROT_FILE ); +// aURL.SetSmartURL( *pPath ); + aPathExt = aURL.GetFileExtension().ToLowerAscii(); + } + + nStmPos = rInStream.Tell(); + pBaseStm = &rInStream; + bBaseStm = TRUE; + + if ( !pBaseStm->GetError() ) + bDataReady = TRUE; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +GraphicDescriptor::~GraphicDescriptor() +{ +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::Detect( BOOL bExtendedInfo ) +{ + BOOL bRet = FALSE; + + // Link-Status ueberpruefen + if ( bLinked && bLinkChanged ) + { + DBG_ASSERT( aReqLink.IsSet(), "Wo ist der RequestHandler???" ); + if ( pMemStm = (SvStream*) aReqLink.Call( this ) ) + { + nStmPos = pMemStm->Tell(); + bDataReady = TRUE; + } + } + + if ( bDataReady ) + { + SvStream& rStm = GetSearchStream(); + UINT16 nOldFormat = rStm.GetNumberFormatInt(); + + if ( ImpDetectGIF( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectJPG( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectBMP( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectPNG( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectTIF( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectPCX( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectDXF( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectMET( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectSGF( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectSGV( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectSVM( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectWMF( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectEMF( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectPCT( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectXBM( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectXPM( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectPBM( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectPGM( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectPPM( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectRAS( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectTGA( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectPSD( rStm, bExtendedInfo ) ) bRet = TRUE; + else if ( ImpDetectEPS( rStm, bExtendedInfo ) ) bRet = TRUE; + + // diese Formate lassen sich nur bei WideSearch im gesamten + // Stream ermitteln + else if ( bWideSearch ) + { + if ( ImpDetectPCD( rStm, bExtendedInfo ) ) + bRet = TRUE; + } + + rStm.SetNumberFormatInt( nOldFormat ); + rStm.Seek( nStmPos ); + } + + return bRet; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::IsDataReady() const +{ + return bDataReady; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::IsWideSearch() const +{ + return bWideSearch; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +SvStream& GraphicDescriptor::GetSearchStream() const +{ + DBG_ASSERT( bDataReady, "Was laeuft hier falsch???" ); + + if ( bLinked ) + return *pMemStm; + else if ( bBaseStm ) + return *pBaseStm; + else + return (SvStream&) aFileStm; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +void GraphicDescriptor::SetRequestHdl( const Link& rRequestLink ) +{ + aReqLink = rRequestLink; + bLinkChanged = TRUE; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +ULONG GraphicDescriptor::GetRequestedByteCount() const +{ + return DATA_SIZE; +} + + +/******************************************************************************/ +/* IMP-Methoden */ +/* */ + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +void GraphicDescriptor::ImpConstruct() +{ + nFormat = GFF_NOT; + nBitsPerPixel = 0; + nPlanes = 0; + bCompressed = FALSE; + bDataReady = FALSE; + bLinked = FALSE; + bWideSearch = TRUE; + bBaseStm = FALSE; + pMemStm = NULL; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectBMP( SvStream& rStm, BOOL bExtendedInfo ) +{ + UINT16 nTemp16; + BOOL bRet = FALSE; + + rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); + rStm.Seek( nStmPos ); + + rStm >> nTemp16; + + // OS/2-BitmapArray + if ( nTemp16 == 0x4142 ) + { + rStm.SeekRel( 0x0c ); + rStm >> nTemp16; + } + + // Bitmap + if ( nTemp16 == 0x4d42 ) + { + nFormat = GFF_BMP; + bRet = TRUE; + + if ( bExtendedInfo ) + { + UINT32 nTemp32; + UINT32 nCompression; + + // bis zur ersten Information + rStm.SeekRel( 0x10 ); + + // PixelBreite auslesen + rStm >> nTemp32; + aPixSize.Width() = nTemp32; + + // PixelHoehe auslesen + rStm >> nTemp32; + aPixSize.Height() = nTemp32; + + // Planes auslesen + rStm >> nTemp16; + nPlanes = nTemp16; + + // BitCount auslesen + rStm >> nTemp16; + nBitsPerPixel = nTemp16; + + // Compression auslesen + rStm >> nTemp32; + bCompressed = ( ( nCompression = nTemp32 ) > 0 ); + + // logische Breite + rStm.SeekRel( 4 ); + rStm >> nTemp32; + if ( nTemp32 ) + aLogSize.Width() = ( aPixSize.Width() * 100000 ) / nTemp32; + + // logische Hoehe + rStm >> nTemp32; + if ( nTemp32 ) + aLogSize.Height() = ( aPixSize.Height() * 100000 ) / nTemp32; + + // Wir wollen noch etwas feiner differenzieren und + // auf sinnvolle Werte ueberpruefen ( Bug-Id #29001 ) + if ( ( nBitsPerPixel > 24 ) || ( nCompression > 3 ) ) + { + nFormat = GFF_NOT; + bRet = FALSE; + } + } + } + + return bRet; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectGIF( SvStream& rStm, BOOL bExtendedInfo ) +{ + UINT32 nTemp32; + UINT16 nTemp16; + BOOL bRet = FALSE; + BYTE cByte; + + rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); + rStm.Seek( nStmPos ); + + rStm >> nTemp32; + if ( nTemp32 == 0x38464947 ) + { + rStm >> nTemp16; + if ( ( nTemp16 == 0x6137 ) || ( nTemp16 == 0x6139 ) ) + { + nFormat = GFF_GIF; + bRet = TRUE; + + if ( bExtendedInfo ) + { + UINT16 nTemp16; + + // PixelBreite auslesen + rStm >> nTemp16; + aPixSize.Width() = nTemp16; + + // PixelHoehe auslesen + rStm >> nTemp16; + aPixSize.Height() = nTemp16; + + // Bits/Pixel auslesen + rStm >> cByte; + nBitsPerPixel = ( ( cByte & 112 ) >> 4 ) + 1; + } + } + } + + return bRet; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectJPG( SvStream& rStm, BOOL bExtendedInfo ) +{ + UINT32 nTemp32; + BOOL bRet = FALSE; + BYTE cByte; + BOOL bM_COM; + + rStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN ); + rStm.Seek( nStmPos ); + + rStm >> nTemp32; + + // compare upper 28 bits + if( 0xffd8ff00 == ( nTemp32 & 0xffffff00 ) ) + { + nFormat = GFF_JPG; + return TRUE; + } + + bM_COM = ( nTemp32 == 0xffd8fffe ); + if ( ( nTemp32 == 0xffd8ffe0 ) || bM_COM ) + { + if( !bM_COM ) + { + rStm.SeekRel( 2 ); + rStm >> nTemp32; + } + + if( bM_COM || ( nTemp32 == 0x4a464946 ) ) + { + nFormat = GFF_JPG; + bRet = TRUE; + + if( bExtendedInfo ) + { + MapMode aMap; + UINT16 nTemp16; + ULONG nCount = 9; + ULONG nMax; + ULONG nResX; + ULONG nResY; + BYTE cUnit; + + // Groesse des verbleibenden Puffers ermitteln + if ( bLinked ) + nMax = ( (SvMemoryStream&) rStm ).GetSize() - 16; + else + nMax = DATA_SIZE - 16; + + // max. 8K + nMax = Min( nMax, (ULONG) 8192 ); + + // Res-Unit ermitteln + rStm.SeekRel( 3 ); + rStm >> cUnit; + + // ResX ermitteln + rStm >> nTemp16; + nResX = nTemp16; + + // ResY ermitteln + rStm >> nTemp16; + nResY = nTemp16; + + // SOF0/1-Marker finden, aber dabei + // nicht mehr als DATA_SIZE Pixel lesen, falls + // kein WideSearch + do + { + while ( ( cByte != 0xff ) && + ( bWideSearch || ( nCount++ < nMax ) ) ) + { + rStm >> cByte; + } + + while ( ( cByte == 0xff ) && + ( bWideSearch || ( nCount++ < nMax ) ) ) + { + rStm >> cByte; + } + } + while ( ( cByte != 0xc0 ) && + ( cByte != 0xc1 ) && + ( bWideSearch || ( nCount < nMax ) ) ); + + // wir haben den SOF0/1-Marker + if ( ( cByte == 0xc0 ) || ( cByte == 0xc1 ) ) + { + // Hoehe einlesen + rStm.SeekRel( 3 ); + rStm >> nTemp16; + aPixSize.Height() = nTemp16; + + // Breite einlesen + rStm >> nTemp16; + aPixSize.Width() = nTemp16; + + // Bit/Pixel einlesen + rStm >> cByte; + nBitsPerPixel = ( cByte == 3 ? 24 : cByte == 1 ? 8 : 0 ); + + // logische Groesse setzen + if ( cUnit && nResX && nResY ) + { + aMap.SetMapUnit( cUnit == 1 ? MAP_INCH : MAP_CM ); + aMap.SetScaleX( Fraction( 1, nResX ) ); + aMap.SetScaleY( Fraction( 1, nResY ) ); + aLogSize = OutputDevice::LogicToLogic( aPixSize, aMap, + MapMode( MAP_100TH_MM ) ); + } + + // Planes immer 1 + nPlanes = 1; + } + } + } + } + + return bRet; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectPCD( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet = FALSE; + + rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); + rStm.Seek( nStmPos ); + + if ( bWideSearch ) + { + UINT32 nTemp32; + UINT16 nTemp16; + BYTE cByte; + + rStm.SeekRel( 2048 ); + rStm >> nTemp32; + rStm >> nTemp16; + rStm >> cByte; + + if ( ( nTemp32 == 0x5f444350 ) && + ( nTemp16 == 0x5049 ) && + ( cByte == 0x49 ) ) + { + nFormat = GFF_PCD; + bRet = TRUE; + } + } + else if ( bRet = ( aPathExt.CompareToAscii( "pcd", 3 ) == COMPARE_EQUAL ) ) + nFormat = GFF_PCD; + + return bRet; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectPCX( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet = FALSE; + BYTE cByte; + + rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); + rStm.Seek( nStmPos ); + + rStm >> cByte; + if ( cByte == 0x0a ) + { + nFormat = GFF_PCX; + bRet = TRUE; + + if ( bExtendedInfo ) + { + UINT16 nTemp16; + USHORT nXmin; + USHORT nXmax; + USHORT nYmin; + USHORT nYmax; + USHORT nDPIx; + USHORT nDPIy; + + + rStm.SeekRel( 1 ); + + // Kompression lesen + rStm >> cByte; + bCompressed = ( cByte > 0 ); + + // Bits/Pixel lesen + rStm >> cByte; + nBitsPerPixel = cByte; + + // Bildabmessungen + rStm >> nTemp16; + nXmin = nTemp16; + rStm >> nTemp16; + nYmin = nTemp16; + rStm >> nTemp16; + nXmax = nTemp16; + rStm >> nTemp16; + nYmax = nTemp16; + + aPixSize.Width() = nXmax - nXmin + 1; + aPixSize.Height() = nYmax - nYmin + 1; + + // Aufloesung + rStm >> nTemp16; + nDPIx = nTemp16; + rStm >> nTemp16; + nDPIy = nTemp16; + + // logische Groesse setzen + MapMode aMap( MAP_INCH, Point(), + Fraction( 1, nDPIx ), Fraction( 1, nDPIy ) ); + aLogSize = OutputDevice::LogicToLogic( aPixSize, aMap, + MapMode( MAP_100TH_MM ) ); + + + // Anzahl Farbebenen + rStm.SeekRel( 49 ); + rStm >> cByte; + nPlanes = cByte; + } + } + + return bRet; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectPNG( SvStream& rStm, BOOL bExtendedInfo ) +{ + UINT32 nTemp32; + BOOL bRet = FALSE; + + rStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN ); + rStm.Seek( nStmPos ); + + rStm >> nTemp32; + if ( nTemp32 == 0x89504e47 ) + { + rStm >> nTemp32; + if ( nTemp32 == 0x0d0a1a0a ) + { + nFormat = GFF_PNG; + bRet = TRUE; + + if ( bExtendedInfo ) + { + BYTE cByte; + + // IHDR-Chunk + rStm.SeekRel( 8 ); + + // Breite einlesen + rStm >> nTemp32; + aPixSize.Width() = nTemp32; + + // Hoehe einlesen + rStm >> nTemp32; + aPixSize.Height() = nTemp32; + + // Bits/Pixel einlesen + rStm >> cByte; + nBitsPerPixel = cByte; + + // Planes immer 1; + // Kompression immer + nPlanes = 1; + bCompressed = TRUE; + + if ( bWideSearch ) + { + BOOL bOk = FALSE; + UINT32 nLen32; + + rStm.SeekRel( 8 ); + + // so lange ueberlesen, bis wir den pHYs-Chunk haben oder + // den Anfang der Bilddaten + rStm >> nLen32; + rStm >> nTemp32; + while( ( nTemp32 != 0x70485973 ) && ( nTemp32 != 0x49444154 ) ) + { + rStm.SeekRel( 4 + nLen32 ); + rStm >> nLen32; + rStm >> nTemp32; + } + + if ( nTemp32 == 0x70485973 ) + { + ULONG nXRes; + ULONG nYRes; + + // horizontale Aufloesung + rStm >> nTemp32; + nXRes = nTemp32; + + // vertikale Aufloesung + rStm >> nTemp32; + nYRes = nTemp32; + + // Unit einlesen + rStm >> cByte; + + if ( cByte ) + { + if ( nXRes ) + aLogSize.Width() = ( aPixSize.Width() * 100000 ) / + nTemp32; + + if ( nYRes ) + aLogSize.Height() = ( aPixSize.Height() * 100000 ) / + nTemp32; + } + } + } + } + } + } + + return bRet; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectTIF( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bOk = FALSE; + BOOL bRet = FALSE; + BYTE cByte1; + BYTE cByte2; + + rStm.Seek( nStmPos ); + rStm >> cByte1; + rStm >> cByte2; + if ( cByte1 == cByte2 ) + { + if ( cByte1 == 0x49 ) + { + rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); + bOk = TRUE; + } + else if ( cByte1 == 0x4d ) + { + rStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN ); + bOk = TRUE; + } + + if ( bOk ) + { + UINT16 nTemp16; + + rStm >> nTemp16; + if ( nTemp16 == 0x2a ) + { + nFormat = GFF_TIF; + bRet = TRUE; + + if ( bExtendedInfo ) + { + ULONG nCount; + ULONG nMax = DATA_SIZE - 48; + UINT32 nTemp32; + BOOL bOk; + + // Offset des ersten IFD einlesen + rStm >> nTemp32; + rStm.SeekRel( ( nCount = ( nTemp32 + 2 ) ) - 0x08 ); + + if ( bWideSearch || ( nCount < nMax ) ) + { + // Tag's lesen, bis wir auf Tag256 ( Width ) treffen + // nicht mehr Bytes als DATA_SIZE lesen + rStm >> nTemp16; + while ( ( nTemp16 != 256 ) && ( bOk = ( bWideSearch || ( nCount < nMax ) ) ) ) + { + rStm.SeekRel( 10 ); + rStm >> nTemp16; + nCount += 12; + } + + if ( bOk ) + { + // Breite lesen + rStm >> nTemp16; + rStm.SeekRel( 4 ); + if ( nTemp16 == 3 ) + { + rStm >> nTemp16; + aPixSize.Width() = nTemp16; + rStm.SeekRel( 2 ); + } + else + { + rStm >> nTemp32; + aPixSize.Width() = nTemp32; + } + nCount += 12; + + // Hoehe lesen + rStm.SeekRel( 2 ); + rStm >> nTemp16; + rStm.SeekRel( 4 ); + if ( nTemp16 == 3 ) + { + rStm >> nTemp16; + aPixSize.Height() = nTemp16; + rStm.SeekRel( 2 ); + } + else + { + rStm >> nTemp32; + aPixSize.Height() = nTemp32; + } + nCount += 12; + + // ggf. Bits/Pixel lesen + rStm >> nTemp16; + if ( nTemp16 == 258 ) + { + rStm.SeekRel( 6 ); + rStm >> nTemp16; + nBitsPerPixel = nTemp16; + rStm.SeekRel( 2 ); + nCount += 12; + } + else + rStm.SeekRel( -2 ); + + // ggf. Compression lesen + rStm >> nTemp16; + if ( nTemp16 == 259 ) + { + rStm.SeekRel( 6 ); + rStm >> nTemp16; + bCompressed = ( nTemp16 > 1 ); + rStm.SeekRel( 2 ); + nCount += 12; + } + else + rStm.SeekRel( -2 ); + } + } + } + } + } + } + + return bRet; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectXBM( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet; + + if ( bRet = ( aPathExt.CompareToAscii( "xbm", 3 ) == COMPARE_EQUAL ) ) + nFormat = GFF_XBM; + + return bRet; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectXPM( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet; + + if ( bRet = ( aPathExt.CompareToAscii( "xpm", 3 ) == COMPARE_EQUAL ) ) + nFormat = GFF_XPM; + + return bRet; +} + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectPBM( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet = FALSE; + + // erst auf Datei Extension pruefen, da diese aussagekraeftiger ist + // als die 2 ID Bytes + + if ( aPathExt.CompareToAscii( "pbm", 3 ) == COMPARE_EQUAL ) + bRet = TRUE; + else + { + BYTE nFirst, nSecond; + rStm.Seek( nStmPos ); + rStm >> nFirst >> nSecond; + if ( nFirst == 'P' && ( ( nSecond == '1' ) || ( nSecond == '4' ) ) ) + bRet = TRUE; + } + + if ( bRet ) + nFormat = GFF_PBM; + + return bRet; +} + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectPGM( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet = FALSE; + + if ( aPathExt.CompareToAscii( "pgm", 3 ) == COMPARE_EQUAL ) + bRet = TRUE; + else + { + BYTE nFirst, nSecond; + rStm.Seek( nStmPos ); + rStm >> nFirst >> nSecond; + if ( nFirst == 'P' && ( ( nSecond == '2' ) || ( nSecond == '5' ) ) ) + bRet = TRUE; + } + + if ( bRet ) + nFormat = GFF_PGM; + + return bRet; +} + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectPPM( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet = FALSE; + + if ( aPathExt.CompareToAscii( "ppm", 3 ) == COMPARE_EQUAL ) + bRet = TRUE; + else + { + BYTE nFirst, nSecond; + rStm.Seek( nStmPos ); + rStm >> nFirst >> nSecond; + if ( nFirst == 'P' && ( ( nSecond == '3' ) || ( nSecond == '6' ) ) ) + bRet = TRUE; + } + + if ( bRet ) + nFormat = GFF_PPM; + + return bRet; +} + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectRAS( SvStream& rStm, BOOL bExtendedInfo ) +{ + UINT32 nMagicNumber; + rStm.Seek( nStmPos ); + rStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN ); + rStm >> nMagicNumber; + if ( nMagicNumber == 0x59a66a95 ) + { + nFormat = GFF_RAS; + return TRUE; + } + else + return FALSE; +} + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectTGA( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet; + + if ( bRet = ( aPathExt.CompareToAscii( "tga", 3 ) == COMPARE_EQUAL ) ) + nFormat = GFF_TGA; + + return bRet; +} + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectPSD( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet = FALSE; + + UINT32 nMagicNumber; + rStm.Seek( nStmPos ); + rStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN ); + rStm >> nMagicNumber; + if ( nMagicNumber == 0x38425053 ) + { + UINT16 nVersion; + rStm >> nVersion; + if ( nVersion == 1 ) + { + bRet = TRUE; + if ( bExtendedInfo ) + { + UINT16 nChannels; + UINT32 nRows; + UINT32 nColumns; + UINT16 nDepth; + UINT16 nMode; + rStm.SeekRel( 6 ); // Pad + rStm >> nChannels >> nRows >> nColumns >> nDepth >> nMode; + if ( ( nDepth == 1 ) || ( nDepth == 8 ) || ( nDepth == 16 ) ) + { + nBitsPerPixel = ( nDepth == 16 ) ? 8 : nDepth; + switch ( nChannels ) + { + case 4 : + case 3 : + nBitsPerPixel = 24; + case 2 : + case 1 : + aPixSize.Width() = nColumns; + aPixSize.Height() = nRows; + break; + default: + bRet = FALSE; + } + } + else + bRet = FALSE; + } + } + } + + if ( bRet ) + nFormat = GFF_PSD; + return bRet; +} + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectEPS( SvStream& rStm, BOOL bExtendedInfo ) +{ + // es wird die EPS mit Vorschaubild Variante und die Extensionübereinstimmung + // geprüft + + UINT32 nFirstLong; + rStm.Seek( nStmPos ); + rStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN ); + rStm >> nFirstLong; + if ( ( nFirstLong == 0xC5D0D3C6 ) || ( aPathExt.CompareToAscii( "eps", 3 ) == COMPARE_EQUAL ) ) + { + nFormat = GFF_EPS; + return TRUE; + } + else + return FALSE; +} + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectDXF( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet; + + if ( bRet = ( aPathExt.CompareToAscii( "dxf", 3 ) == COMPARE_EQUAL ) ) + nFormat = GFF_DXF; + + return bRet; +} + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectMET( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet; + + if ( bRet = ( aPathExt.CompareToAscii( "met", 3 ) == COMPARE_EQUAL ) ) + nFormat = GFF_MET; + + return bRet; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectPCT( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet; + + if ( bRet = ( aPathExt.CompareToAscii( "pct", 3 ) == COMPARE_EQUAL ) ) + nFormat = GFF_PCT; + else + { + BYTE sBuf[4]; + + rStm.Seek( nStmPos + 522 ); + rStm.Read( sBuf, 3 ); + + if( !rStm.GetError() ) + { + if ( ( sBuf[0] == 0x00 ) && ( sBuf[1] == 0x11 ) && + ( ( sBuf[2] == 0x01 ) || ( sBuf[2] == 0x02 ) ) ) + { + bRet = TRUE; + nFormat = GFF_PCT; + } + } + } + + return bRet; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectSGF( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet; + + if ( bRet = ( aPathExt.CompareToAscii( "sgf",3 ) == COMPARE_EQUAL ) ) + nFormat = GFF_SGF; + + return bRet; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectSGV( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet; + + if ( bRet = ( aPathExt.CompareToAscii( "sgv", 3 ) == COMPARE_EQUAL ) ) + nFormat = GFF_SGV; + + return bRet; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectSVM( SvStream& rStm, BOOL bExtendedInfo ) +{ + UINT32 nTemp32; + BOOL bRet = FALSE; + BYTE cByte; + + rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); + rStm.Seek( nStmPos ); + + rStm >> nTemp32; + if ( nTemp32 == 0x44475653 ) + { + rStm >> cByte; + if ( cByte == 0x49 ) + { + nFormat = GFF_SVM; + bRet = TRUE; + + if ( bExtendedInfo ) + { + UINT32 nTemp32; + UINT16 nTemp16; + + rStm.SeekRel( 0x04 ); + + // Breite auslesen + rStm >> nTemp32; + aLogSize.Width() = nTemp32; + + // Hoehe auslesen + rStm >> nTemp32; + aLogSize.Height() = nTemp32; + + // Map-Unit auslesen und PrefSize ermitteln + rStm >> nTemp16; + aLogSize = OutputDevice::LogicToLogic( aLogSize, + MapMode( (MapUnit) nTemp16 ), + MapMode( MAP_100TH_MM ) ); + } + } + } + else + { + // StringLen-Feld ueberlesen + rStm.SeekRel( -2L ); + rStm >> nTemp32; + + if( nTemp32 == 0x4D4C4356 ) + { + UINT16 nTmp16; + + rStm >> nTmp16; + + if( nTmp16 == 0x4654 ) + { + nFormat = GFF_SVM; + bRet = TRUE; + + if( bExtendedInfo ) + { + MapMode aMapMode; + + rStm.SeekRel( 0x06 ); + rStm >> aMapMode; + rStm >> aLogSize; + aLogSize = OutputDevice::LogicToLogic( aLogSize, aMapMode, MapMode( MAP_100TH_MM ) ); + } + } + } + } + + return bRet; +} + + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectWMF( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet; + + if ( bRet = ( aPathExt.CompareToAscii( "wmf",3 ) == COMPARE_EQUAL ) ) + nFormat = GFF_WMF; + + return bRet; +} + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +BOOL GraphicDescriptor::ImpDetectEMF( SvStream& rStm, BOOL bExtendedInfo ) +{ + BOOL bRet; + + if ( bRet = ( aPathExt.CompareToAscii( "emf", 3 ) == COMPARE_EQUAL ) ) + nFormat = GFF_EMF; + + return bRet; +} + +/************************************************************************* +|* +|* +|* +\************************************************************************/ + +USHORT GraphicDescriptor::GetImportFormatNumber( USHORT nFormat, Config& rConfig ) +{ + ByteString aKeyName; + const ByteString aOldGroup( rConfig.GetGroup() ); + USHORT nKeyNumber = GRFILTER_FORMAT_NOTFOUND; + + rConfig.SetGroup( IMP_FILTERSECTION ); + + switch( nFormat ) + { + case( GFF_BMP ) : aKeyName = "bmp"; break; + case( GFF_GIF ) : aKeyName = "gif"; break; + case( GFF_JPG ) : aKeyName = "jpg"; break; + case( GFF_PCD ) : aKeyName = "pcd"; break; + case( GFF_PCX ) : aKeyName = "pcx"; break; + case( GFF_PNG ) : aKeyName = "png"; break; + case( GFF_XBM ) : aKeyName = "xbm"; break; + case( GFF_XPM ) : aKeyName = "xpm"; break; + case( GFF_PBM ) : aKeyName = "pbm"; break; + case( GFF_PGM ) : aKeyName = "pgm"; break; + case( GFF_PPM ) : aKeyName = "ppm"; break; + case( GFF_RAS ) : aKeyName = "ras"; break; + case( GFF_TGA ) : aKeyName = "tga"; break; + case( GFF_PSD ) : aKeyName = "psd"; break; + case( GFF_EPS ) : aKeyName = "eps"; break; + case( GFF_TIF ) : aKeyName = "tif"; break; + case( GFF_DXF ) : aKeyName = "dxf"; break; + case( GFF_MET ) : aKeyName = "met"; break; + case( GFF_PCT ) : aKeyName = "pct"; break; + case( GFF_SGF ) : aKeyName = "sgf"; break; + case( GFF_SGV ) : aKeyName = "sgv"; break; + case( GFF_SVM ) : aKeyName = "svm"; break; + case( GFF_WMF ) : aKeyName = "wmf"; break; + case( GFF_EMF ) : aKeyName = "emf"; break; + } + + if( aKeyName.Len() ) + { + for( USHORT i = 0, nCount = rConfig.GetKeyCount(); i < nCount; i++ ) + { + if( rConfig.GetKeyName( i ).CompareIgnoreCaseToAscii( aKeyName ) == COMPARE_EQUAL ) + { + nKeyNumber = i; + break; + } + } + } + + rConfig.SetGroup( aOldGroup ); + + return nKeyNumber; +} diff --git a/svtools/source/filter.vcl/filter/fldll.cxx b/svtools/source/filter.vcl/filter/fldll.cxx new file mode 100644 index 000000000000..ea9b47083c31 --- /dev/null +++ b/svtools/source/filter.vcl/filter/fldll.cxx @@ -0,0 +1,110 @@ +/************************************************************************* + * + * $RCSfile: fldll.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#ifdef WIN + +#ifndef _SVWIN_H +#include <svwin.h> +#endif + +// Statische DLL-Verwaltungs-Variablen +static HINSTANCE hDLLInst = 0; // HANDLE der DLL + + +/*************************************************************************** +|* +|* LibMain() +|* +|* Beschreibung Initialisierungsfunktion der DLL +|* Ersterstellung TH 05.05.93 +|* Letzte Aenderung TH 05.05.93 +|* +***************************************************************************/ + +extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR ) +{ +#ifndef WNT + if ( nHeap ) + UnlockData( 0 ); +#endif + + hDLLInst = hDLL; + + return TRUE; +} + +/*************************************************************************** +|* +|* WEP() +|* +|* Beschreibung DLL-Deinitialisierung +|* Ersterstellung TH 05.05.93 +|* Letzte Aenderung TH 05.05.93 +|* +***************************************************************************/ + +extern "C" int CALLBACK WEP( int ) +{ + return 1; +} + +#endif + diff --git a/svtools/source/filter.vcl/filter/gradwrap.cxx b/svtools/source/filter.vcl/filter/gradwrap.cxx new file mode 100644 index 000000000000..d17c97e04074 --- /dev/null +++ b/svtools/source/filter.vcl/filter/gradwrap.cxx @@ -0,0 +1,619 @@ +/************************************************************************* + * + * $RCSfile: gradwrap.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 <svgrad.hxx> +#include <svbmpacc.hxx> +#include <gradwrap.hxx> + +// ------------------- +// - GradientWrapper - +// ------------------- + +GradientWrapper::GradientWrapper(const Link& rDrawPolyRecordHdl, + const Link& rDrawPolyPolyRecordHdl, + const Link& rSetFillInBrushRecordHdl) : + aDrawPolyRecordHdl (rDrawPolyRecordHdl), + aDrawPolyPolyRecordHdl (rDrawPolyPolyRecordHdl), + aSetFillInBrushRecordHdl(rSetFillInBrushRecordHdl) +{ +} + +// ------------------------------------------------------------------------ + +GradientWrapper::~GradientWrapper() +{ +} + +// ------------------------------------------------------------------------ + +void GradientWrapper::WriteLinearGradient(const Rectangle& rRect, + const Gradient& rGradient) +{ + USHORT nStepCount = 100; + + Rectangle aRect = rRect; + aRect.Left()--; + aRect.Top()--; + aRect.Right()++; + aRect.Bottom()++; + + // rotiertes BoundRect ausrechnen + double fAngle = (rGradient.GetAngle() % 3600) * F_PI1800; + double fWidth = aRect.GetWidth(); + double fHeight = aRect.GetHeight(); + double fDX = fWidth * fabs( cos( fAngle ) ) + + fHeight * fabs( sin( fAngle ) ); + double fDY = fHeight * fabs( cos( fAngle ) ) + + fWidth * fabs( sin( fAngle ) ); + fDX = (fDX - fWidth) * 0.5 + 0.5; + fDY = (fDY - fHeight) * 0.5 + 0.5; + aRect.Left() -= (long)fDX; + aRect.Right() += (long)fDX; + aRect.Top() -= (long)fDY; + aRect.Bottom() += (long)fDY; + + // Rand berechnen und Rechteck neu setzen + Point aCenter = rRect.Center(); + Rectangle aFullRect = aRect; + long nBorder = (long)rGradient.GetBorder() * aRect.GetHeight() / 100; + BOOL bLinear; + + // Rand berechnen und Rechteck neu setzen fuer linearen Farbverlauf + if ( rGradient.GetStyle() == GRADIENT_LINEAR ) + { + bLinear = TRUE; + aRect.Top() += nBorder; + } + // Rand berechnen und Rechteck neu setzen fuer axiale Farbverlauf + else + { + bLinear = FALSE; + nBorder >>= 1; + + aRect.Top() += nBorder; + aRect.Bottom() -= nBorder; + } + + // Top darf nicht groesser als Bottom sein + aRect.Top() = Min( aRect.Top(), (long)(aRect.Bottom() - 1) ); + + long nMinRect = aRect.GetHeight(); + + // Anzahl der Schritte berechnen, falls nichts uebergeben wurde + if ( !nStepCount ) + { + long nInc = ((nMinRect >> 9) + 1) << 3; + + if ( !nInc ) + nInc = 1; + + nStepCount = (USHORT)(nMinRect / nInc); + } + // minimal drei Schritte + long nSteps = Max( nStepCount, (USHORT)3 ); + + // Falls axialer Farbverlauf, muss die Schrittanzahl ungerade sein + if ( !bLinear && !(nSteps & 1) ) + nSteps++; + + // Berechnung ueber Double-Addition wegen Genauigkeit + double fScanLine = aRect.Top(); + double fScanInc = (double)aRect.GetHeight() / (double)nSteps; + + // Intensitaeten von Start- und Endfarbe ggf. aendern und + // Farbschrittweiten berechnen + long nFactor; + const Color& rStartCol = rGradient.GetStartColor(); + const Color& rEndCol = rGradient.GetEndColor(); + long nRed = rStartCol.GetRed(); + long nGreen = rStartCol.GetGreen(); + long nBlue = rStartCol.GetBlue(); + long nEndRed = rEndCol.GetRed(); + long nEndGreen = rEndCol.GetGreen(); + long nEndBlue = rEndCol.GetBlue(); + nFactor = rGradient.GetStartIntensity(); + nRed = (nRed * nFactor) / 100; + nGreen = (nGreen * nFactor) / 100; + nBlue = (nBlue * nFactor) / 100; + nFactor = rGradient.GetEndIntensity(); + nEndRed = (nEndRed * nFactor) / 100; + nEndGreen = (nEndGreen * nFactor) / 100; + nEndBlue = (nEndBlue * nFactor) / 100; + long nStepRed = (nEndRed - nRed) / nSteps; + long nStepGreen = (nEndGreen - nGreen) / nSteps; + long nStepBlue = (nEndBlue - nBlue) / nSteps; + long nSteps2; + + if ( bLinear ) + { + // Um 1 erhoeht, um die Border innerhalb der Schleife + // zeichnen zu koennen + nSteps2 = nSteps + 1; + } + else + { + nStepRed <<= 1; + nStepGreen <<= 1; + nStepBlue <<= 1; + nRed = nEndRed; + nGreen = nEndGreen; + nBlue = nEndBlue; + + // Um 2 erhoeht, um die Border innerhalb der Schleife + // zeichnen zu koennen + nSteps2 = nSteps + 2; + } + Color aCol( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue ); + + // GDI-Objekte sichern und setzen + Brush aBrush( aCol ); + aSetFillInBrushRecordHdl.Call(&aBrush); + + // Startpolygon erzeugen (== Borderpolygon) + Polygon aPoly( 4 ); + Polygon aTempPoly( 2 ); + aPoly[0] = aFullRect.TopLeft(); + aPoly[1] = aFullRect.TopRight(); + aPoly[2] = aRect.TopRight(); + aPoly[3] = aRect.TopLeft(); + aPoly.Rotate( aCenter, rGradient.GetAngle() ); + + // Schleife, um rotierten Verlauf zu fuellen + for ( long i = 0; i < nSteps2; i++ ) + { + Polygon aTempPoly = aPoly; + aTempPoly.Clip( rRect ); + aDrawPolyRecordHdl.Call(&aTempPoly); + aTempPoly.SetSize( 2 ); + + // neues Polygon berechnen + aRect.Top() = (long)(fScanLine += fScanInc); + + // unteren Rand komplett fuellen + if ( i == nSteps ) + { + aTempPoly[0] = aFullRect.BottomLeft(); + aTempPoly[1] = aFullRect.BottomRight(); + } + else + { + aTempPoly[0] = aRect.TopLeft(); + aTempPoly[1] = aRect.TopRight(); + } + aTempPoly.Rotate( aCenter, rGradient.GetAngle() ); + + aPoly[0] = aPoly[3]; + aPoly[1] = aPoly[2]; + aPoly[2] = aTempPoly[1]; + aPoly[3] = aTempPoly[0]; + + // Farbintensitaeten aendern... + // fuer lineare FV + if ( bLinear ) + { + nRed += nStepRed; + nGreen += nStepGreen; + nBlue += nStepBlue; + } + // fuer radiale FV + else + { + if ( i <= (nSteps >> 1) ) + { + nRed -= nStepRed; + nGreen -= nStepGreen; + nBlue -= nStepBlue; + } + // genau die Mitte und hoeher + else + { + nRed += nStepRed; + nGreen += nStepGreen; + nBlue += nStepBlue; + } + } + + nRed = MinMax( nRed, 0, 255 ); + nGreen = MinMax( nGreen, 0, 255 ); + nBlue = MinMax( nBlue, 0, 255 ); + + // fuer lineare FV ganz normale Bestimmung der Farbe + if ( bLinear || (i <= nSteps) ) + { + aCol = Color( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue ); + } + // fuer axiale FV muss die letzte Farbe der ersten + // Farbe entsprechen + else + { + aCol = Color( (BYTE) nEndRed, (BYTE) nEndGreen, (BYTE) nEndBlue ); + } + + aBrush.SetColor(aCol); + aSetFillInBrushRecordHdl.Call(&aBrush); + } +} + +// ------------------------------------------------------------------------ + +void GradientWrapper::WriteRadialGradient(const Rectangle& rRect, + const Gradient& rGradient) +{ + USHORT nStepCount = 100; + Rectangle aClipRect = rRect; + Rectangle aRect = rRect; + long nZWidth = aRect.GetWidth() * (long)rGradient.GetOfsX() / 100; + long nZHeight= aRect.GetHeight() * (long)rGradient.GetOfsY() / 100; + Size aSize = aRect.GetSize(); + Point aCenter( aRect.Left() + nZWidth, aRect.Top() + nZHeight ); + + // Radien-Berechnung fuer Kreisausgabe (Kreis schliesst Rechteck ein) + if ( rGradient.GetStyle() == GRADIENT_RADIAL ) + { + aSize.Width() = (long)(0.5 + sqrt((double)aSize.Width()*(double)aSize.Width() + + (double)aSize.Height()*(double)aSize.Height())); + aSize.Height() = aSize.Width(); + } + // Radien-Berechnung fuer Ellipse + else + { + aSize.Width() = (long)(0.5 + (double)aSize.Width() * 1.4142); + aSize.Height() = (long)(0.5 + (double)aSize.Height() * 1.4142); + } + + long nBorderX = (long)rGradient.GetBorder() * aSize.Width() / 100; + long nBorderY = (long)rGradient.GetBorder() * aSize.Height() / 100; + aSize.Width() -= nBorderX; + aSize.Height() -= nBorderY; + aRect.Left() = aCenter.X() - (aSize.Width() >> 1); + aRect.Top() = aCenter.Y() - (aSize.Height() >> 1); + aRect.SetSize( aSize ); + + long nMinRect = Min( aRect.GetWidth(), aRect.GetHeight() ); + + // Anzahl der Schritte berechnen, falls nichts uebergeben wurde + if ( !nStepCount ) + { + long nInc = ((nMinRect >> 9) + 1) << 3; + + if ( !nInc ) + nInc = 1; + + nStepCount = (USHORT)(nMinRect / nInc); + } + // minimal drei Schritte + long nSteps = Max( nStepCount, (USHORT)3 ); + + // Ausgabebegrenzungen und Schrittweite fuer jede Richtung festlegen + double fScanLeft = aRect.Left(); + double fScanTop = aRect.Top(); + double fScanRight = aRect.Right(); + double fScanBottom = aRect.Bottom(); + double fScanInc = (double)nMinRect / (double)nSteps * 0.5; + + // Intensitaeten von Start- und Endfarbe ggf. aendern und + // Farbschrittweiten berechnen + long nFactor; + const Color& rStartCol = rGradient.GetStartColor(); + const Color& rEndCol = rGradient.GetEndColor(); + long nRed = rStartCol.GetRed(); + long nGreen = rStartCol.GetGreen(); + long nBlue = rStartCol.GetBlue(); + long nEndRed = rEndCol.GetRed(); + long nEndGreen = rEndCol.GetGreen(); + long nEndBlue = rEndCol.GetBlue(); + nFactor = rGradient.GetStartIntensity(); + nRed = (nRed * nFactor) / 100; + nGreen = (nGreen * nFactor) / 100; + nBlue = (nBlue * nFactor) / 100; + nFactor = rGradient.GetEndIntensity(); + nEndRed = (nEndRed * nFactor) / 100; + nEndGreen = (nEndGreen * nFactor) / 100; + nEndBlue = (nEndBlue * nFactor) / 100; + long nStepRed = (nEndRed - nRed) / nSteps; + long nStepGreen = (nEndGreen - nGreen) / nSteps; + long nStepBlue = (nEndBlue - nBlue) / nSteps; + Color aCol( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue ); + + // GDI-Objekte sichern und setzen + Brush aBrush( aCol ); + aSetFillInBrushRecordHdl.Call(&aBrush); + + // Recteck erstmal ausgeben + PolyPolygon aPolyPoly( 2 ); + Polygon aPoly( rRect ); + + aPolyPoly.Insert( aPoly ); + aPoly = Polygon( aRect ); + aPoly.Rotate( aCenter, rGradient.GetAngle() ); + aPolyPoly.Insert( aPoly ); + + // erstes Polygon zeichnen (entspricht Rechteck) + PolyPolygon aTempPolyPoly = aPolyPoly; + aTempPolyPoly.Clip( aClipRect ); + aDrawPolyPolyRecordHdl.Call(&aTempPolyPoly); + + for ( long i = 0; i < nSteps; i++ ) + { + Color aCol( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue ); + aBrush.SetColor( aCol ); + aSetFillInBrushRecordHdl.Call(&aBrush); + + // neues Polygon berechnen + aRect.Left() = (long)(fScanLeft += fScanInc); + aRect.Top() = (long)(fScanTop += fScanInc); + aRect.Right() = (long)(fScanRight -= fScanInc); + aRect.Bottom() = (long)(fScanBottom -= fScanInc); + + if ( (aRect.GetWidth() < 2) || (aRect.GetHeight() < 2) ) + break; + + aPoly = Polygon( aRect.Center(), + aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 ); + aPoly.Rotate( aCenter, rGradient.GetAngle() ); + + aPolyPoly.Replace( aPolyPoly.GetObject( 1 ), 0 ); + aPolyPoly.Replace( aPoly, 1 ); + + PolyPolygon aTempPolyPoly = aPolyPoly; + aTempPolyPoly.Clip( aClipRect ); + aDrawPolyPolyRecordHdl.Call(&aTempPolyPoly); + + // Farbe entsprechend anpassen + nRed += nStepRed; + nGreen += nStepGreen; + nBlue += nStepBlue; + +#ifndef VCL + nRed = MinMax( nRed, 0, 0xFFFF ); + nGreen = MinMax( nGreen, 0, 0xFFFF ); + nBlue = MinMax( nBlue, 0, 0xFFFF ); +#else + nRed = MinMax( nRed, 0, 0xFF ); + nGreen = MinMax( nGreen, 0, 0xFF ); + nBlue = MinMax( nBlue, 0, 0xFF ); +#endif + } + + // Falls PolyPolygon-Ausgabe, muessen wir noch ein letztes + // inneres Polygon zeichnen + aBrush.SetColor( Color( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue ) ); + aSetFillInBrushRecordHdl.Call(&aBrush); + + aPoly = aPolyPoly.GetObject( 1 ); + if ( !aPoly.GetBoundRect().IsEmpty() ) + { + aPoly.Clip( aClipRect ); + aDrawPolyRecordHdl.Call(&aPoly); + } +} + +// ------------------------------------------------------------------------ + +void GradientWrapper::WriteRectGradient(const Rectangle& rRect, + const Gradient& rGradient) +{ + USHORT nStepCount = 100; + Rectangle aClipRect = rRect; + Rectangle aRect = rRect; + + aRect.Left()--; + aRect.Top()--; + aRect.Right()++; + aRect.Bottom()++; + + // rotiertes BoundRect ausrechnen + double fAngle = (rGradient.GetAngle() % 3600) * F_PI1800; + double fWidth = aRect.GetWidth(); + double fHeight = aRect.GetHeight(); + double fDX = fWidth * fabs( cos( fAngle ) ) + + fHeight * fabs( sin( fAngle ) ); + double fDY = fHeight * fabs( cos( fAngle ) ) + + fWidth * fabs( sin( fAngle ) ); + fDX = (fDX - fWidth) * 0.5 + 0.5; + fDY = (fDY - fHeight) * 0.5 + 0.5; + aRect.Left() -= (long)fDX; + aRect.Right() += (long)fDX; + aRect.Top() -= (long)fDY; + aRect.Bottom() += (long)fDY; + + // Quadratisch machen, wenn angefordert; + Size aSize = aRect.GetSize(); + if ( rGradient.GetStyle() == GRADIENT_SQUARE ) + { + if ( aSize.Width() > aSize.Height() ) + aSize.Height() = aSize.Width(); + else + aSize.Width() = aSize.Height(); + } + + // neue Mittelpunkte berechnen + long nZWidth = aRect.GetWidth() * (long)rGradient.GetOfsX() / 100; + long nZHeight = aRect.GetHeight() * (long)rGradient.GetOfsY() / 100; + long nBorderX = (long)rGradient.GetBorder() * aSize.Width() / 100; + long nBorderY = (long)rGradient.GetBorder() * aSize.Height() / 100; + Point aCenter( aRect.Left() + nZWidth, aRect.Top() + nZHeight ); + + // Rand beruecksichtigen + aSize.Width() -= nBorderX; + aSize.Height() -= nBorderY; + + // Ausgaberechteck neu setzen + aRect.Left() = aCenter.X() - (aSize.Width() >> 1); + aRect.Top() = aCenter.Y() - (aSize.Height() >> 1); + aRect.SetSize( aSize ); + + long nMinRect = Min( aRect.GetWidth(), aRect.GetHeight() ); + + // Anzahl der Schritte berechnen, falls nichts uebergeben wurde + if ( !nStepCount ) + { + long nInc = ((nMinRect >> 9) + 1) << 3; + + if ( !nInc ) + nInc = 1; + + nStepCount = (USHORT)(nMinRect / nInc); + } + // minimal drei Schritte + long nSteps = Max( nStepCount, (USHORT)3 ); + + // Ausgabebegrenzungen und Schrittweite fuer jede Richtung festlegen + double fScanLeft = aRect.Left(); + double fScanTop = aRect.Top(); + double fScanRight = aRect.Right(); + double fScanBottom = aRect.Bottom(); + double fScanInc = (double)nMinRect / (double)nSteps * 0.5; + + // Intensitaeten von Start- und Endfarbe ggf. aendern und + // Farbschrittweiten berechnen + long nFactor; + const Color& rStartCol = rGradient.GetStartColor(); + const Color& rEndCol = rGradient.GetEndColor(); + long nRed = rStartCol.GetRed(); + long nGreen = rStartCol.GetGreen(); + long nBlue = rStartCol.GetBlue(); + long nEndRed = rEndCol.GetRed(); + long nEndGreen = rEndCol.GetGreen(); + long nEndBlue = rEndCol.GetBlue(); + nFactor = rGradient.GetStartIntensity(); + nRed = (nRed * nFactor) / 100; + nGreen = (nGreen * nFactor) / 100; + nBlue = (nBlue * nFactor) / 100; + nFactor = rGradient.GetEndIntensity(); + nEndRed = (nEndRed * nFactor) / 100; + nEndGreen = (nEndGreen * nFactor) / 100; + nEndBlue = (nEndBlue * nFactor) / 100; + long nStepRed = (nEndRed - nRed) / nSteps; + long nStepGreen = (nEndGreen - nGreen) / nSteps; + long nStepBlue = (nEndBlue - nBlue) / nSteps; + Color aCol( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue ); + + // GDI-Objekte sichern und setzen + Brush aBrush( aCol ); + aSetFillInBrushRecordHdl.Call(&aBrush); + + // Recteck erstmal ausgeben + PolyPolygon aPolyPoly( 2 ); + Polygon aPoly( rRect ); + + aPolyPoly.Insert( aPoly ); + aPoly = Polygon( aRect ); + aPoly.Rotate( aCenter, rGradient.GetAngle() ); + aPolyPoly.Insert( aPoly ); + + PolyPolygon aTempPolyPoly = aPolyPoly; + aTempPolyPoly.Clip( aClipRect ); + aDrawPolyPolyRecordHdl.Call(&aTempPolyPoly); + + // Schleife, um nacheinander die Polygone/PolyPolygone auszugeben + for ( long i = 0; i < nSteps; i++ ) + { + Color aCol( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue ); + aBrush.SetColor( aCol ); + aSetFillInBrushRecordHdl.Call(&aBrush); + + // neues Polygon berechnen + aRect.Left() = (long)(fScanLeft += fScanInc); + aRect.Top() = (long)(fScanTop += fScanInc); + aRect.Right() = (long)(fScanRight -= fScanInc); + aRect.Bottom() = (long)(fScanBottom-= fScanInc); + + if ( (aRect.GetWidth() < 2) || (aRect.GetHeight() < 2) ) + break; + + aPoly = Polygon( aRect ); + aPoly.Rotate( aCenter, rGradient.GetAngle() ); + + aPolyPoly.Replace( aPolyPoly.GetObject( 1 ), 0 ); + aPolyPoly.Replace( aPoly, 1 ); + + PolyPolygon aTempPolyPoly = aPolyPoly; + aTempPolyPoly.Clip( aClipRect ); + aDrawPolyPolyRecordHdl.Call(&aTempPolyPoly); + + // Farben aendern + nRed += nStepRed; + nGreen += nStepGreen; + nBlue += nStepBlue; + +#ifndef VCL + nRed = MinMax( nRed, 0, 65535 ); + nGreen = MinMax( nGreen, 0, 65535 ); + nBlue = MinMax( nBlue, 0, 65535 ); +#else + nRed = MinMax( nRed, 0, 0xFF ); + nGreen = MinMax( nGreen, 0, 0xFF ); + nBlue = MinMax( nBlue, 0, 0xFF ); +#endif + } + + aBrush.SetColor( Color( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue ) ); + aSetFillInBrushRecordHdl.Call(&aBrush); + + aPoly = aPolyPoly.GetObject( 1 ); + if ( !aPoly.GetBoundRect().IsEmpty() ) + { + aPoly.Clip( aClipRect ); + aDrawPolyRecordHdl.Call(&aPoly); + } +} diff --git a/svtools/source/filter.vcl/filter/makefile.mk b/svtools/source/filter.vcl/filter/makefile.mk new file mode 100644 index 000000000000..71c638a89764 --- /dev/null +++ b/svtools/source/filter.vcl/filter/makefile.mk @@ -0,0 +1,137 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ +# +# 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=SVTOOLS +TARGET=filter +DEPTARGET=vfilter +VERSION=$(UPD) + +# --- Settings ----------------------------------------------------- + +.IF "$(VCL)" != "" + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +.IF "$(GUI)"=="WIN" +LINKFLAGS=$(LINKFLAGS) /PACKC:32768 +.ENDIF + +# --- UNOTypes ----------------------------------------------------- + +UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb +UNOUCROUT=$(OUT)$/inc$/$(PRJNAME)$/$(TARGET) +INCPRE+=$(UNOUCROUT) +UNOTYPES=\ + com.sun.star.uno.TypeClass \ + com.sun.star.uno.XInterface \ + com.sun.star.uno.XWeak \ + com.sun.star.uno.XAggregation \ + com.sun.star.lang.XTypeProvider \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.io.XActiveDataSource \ + com.sun.star.io.XOutputStream \ + com.sun.star.svg.XSVGWriter \ + com.sun.star.xml.sax.XDocumentHandler + + +# --- Files -------------------------------------------------------- + +CXXFILES= filter.cxx \ + filter2.cxx \ + dlgexpor.cxx \ + dlgejpg.cxx \ + sgfbram.cxx \ + sgvmain.cxx \ + sgvtext.cxx \ + sgvspln.cxx + +SRCFILES= strings.src \ + dlgexpor.src \ + dlgejpg.src + +SLOFILES= $(SLO)$/filter.obj \ + $(SLO)$/filter2.obj \ + $(SLO)$/dlgexpor.obj \ + $(SLO)$/dlgejpg.obj \ + $(SLO)$/sgfbram.obj \ + $(SLO)$/sgvmain.obj \ + $(SLO)$/sgvtext.obj \ + $(SLO)$/sgvspln.obj + +EXCEPTIONSNOOPTFILES= $(SLO)$/filter.obj + +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + +.ELSE + +dummy: + @+echo VCL not set. nothing to do! + +.ENDIF # VCL + diff --git a/svtools/source/filter.vcl/filter/sgf.ini b/svtools/source/filter.vcl/filter/sgf.ini new file mode 100644 index 000000000000..7444e40c8836 --- /dev/null +++ b/svtools/source/filter.vcl/filter/sgf.ini @@ -0,0 +1,118 @@ +#Family : (Roman,Swiss,Modern,Script,Decora); +#CharSet : (Ansi,IBMPC,Mac,Symbol,System); Default is System +#Attribute: (Bold,Ital,Sans,Serf,Fixd); + +[SGV Fonts fuer StarView] +#IF-ID Fontname Attribute SV-Fam ChSet Width FontName + 3848=(ITC Zapf Dingbats) Decora () + 5720=(Symbol) Serf Decora Symbol () + 5721=(Symbol) Bold Serf Decora Symbol () + 5723=(Symbol Sans) Sans Decora Symbol () + 5724=(Symbol Sans) Bold Sans Decora Symbol () + 90133=(Dom Casual) Sans Script () + 90326=(Brush) Bold Ital Serf Script () + 90349=(Park Avenue) Ital Serf Script () + 90508=(Uncial) Sans Roman () + 91118=(Antique Olive) Bold Sans Swiss () + 91119=(Antique Olive) Sans Swiss () + 91120=(Antique Olive Compact) Bold Sans Swiss () + 91335=(ITC Benguiat) Bold Serf Roman () + 91336=(ITC Benguiat) Bold Ital Serf Roman () + 91846=(Antique Olive) Ital Sans Roman () +#92500=(CG Times) Serf Roman () +#92501=(CG Times) Ital Serf Roman () +#92504=(CG Times) Bold Serf Roman () +#92505=(CG Times) Bold Ital Serf Roman () +#93950=(Courier) Serf Fixd Modern () +#93951=(Courier) Ital Serf Fixd Modern () +#93952=(Courier) Bold Serf Fixd Modern () +#93953=(Courier) Bold Ital Serf Fixd Modern () +#94021=(Univers) Sans Swiss () +#94022=(Univers) Ital Sans Swiss () +#94023=(Univers) Bold Sans Swiss () +#94024=(Univers) Bold Ital Sans Swiss () +102004=(Avanti) Bold Ital Sans Swiss () +102005=(Avanti) Ital Sans Swiss () +102007=(Booklet) Bold Sans Roman () +102008=(Booklet) Bold Ital Sans Roman () +102009=(Booklet) Ital Sans Roman () +102010=(Centuri) Sans Roman () +102011=(Centuri) Bold Sans Roman () +102012=(Centuri) Bold Ital Sans Roman () +102013=(Centuri) Ital Sans Roman () +102014=(Paltus) Bold Sans Roman () +102015=(Paltus) Sans Roman () +102016=(Paltus) Bold Ital Sans Roman () +102017=(Paltus) Ital Sans Roman () +102018=(Sans) Sans Swiss () +102019=(Sans) Bold Sans Swiss () +102020=(Sans) Bold Ital Sans Swiss () +102021=(Sans) Ital Sans Swiss () +102022=(SansCondensed) Sans Swiss () +102023=(SansCondensed) Bold Sans Swiss () +102024=(SansCondensed) Bold Ital Sans Swiss () +102025=(SansCondensed) Ital Sans Swiss () +102026=(PS-Roman) Sans Roman () +102027=(PS-Roman) Bold Sans Roman () +102028=(PS-Roman) Bold Ital Sans Roman () +102029=(PS-Roman) Ital Sans Roman () +200111=(Chalenge) Sans () +200112=(Chalenge) Bold Sans () +200113=(Chalenge) Ital Sans () +200114=(Chalenge) Bold Ital Sans () +200121=(Office) Sans () +200122=(Office) Bold Sans () +200123=(Office) Ital Sans () +200124=(Office) Bold Ital Sans () +200131=(Milano) Sans () +200132=(Milano) Bold Sans () +200133=(Milano) Ital Sans () +200134=(Milano) Bold Ital Sans () +200141=(Atlantic) Sans Roman () +200142=(Atlantic) Bold Sans Roman () +200143=(Atlantic) Ital Sans Roman () +200144=(Atlantic) Bold Ital Sans Roman () +200151=(Pentagon) Sans () +200152=(Pentagon) Bold Sans () +200153=(Pentagon) Ital Sans () +200154=(Pentagon) Bold Ital Sans () +200161=(Classico) Sans () +200162=(Classico) Bold Sans () +200163=(Classico) Ital Sans () +200164=(Classico) Bold Ital Sans () +200211=(Westcost) Sans () +200212=(Westcost) Bold Sans () +200213=(Westcost) Ital Sans () +200214=(Westcost) Bold Ital Sans () +200221=(Finish) Sans () +200222=(Finish) Bold Sans () +200223=(Finish) Ital Sans () +200224=(Finish) Bold Ital Sans () +200231=(Classic) Sans () +200232=(Classic) Bold Sans () +200233=(Classic) Ital Sans () +200234=(Classic) Bold Ital Sans () +200241=(Hilton) Sans () +200242=(Hilton) Bold Sans () +200243=(Hilton) Ital Sans () +200244=(Hilton) Bold Ital Sans () +200251=(Progress) Sans () +200252=(Progress) Bold Sans () +200253=(Progress) Ital Sans () +200254=(Progress) Bold Ital Sans () +200261=(PrestigeElite) Sans () +200262=(PrestigeElite) Bold Sans () +200263=(PrestigeElite) Ital Sans () +200271=(Ovetti) Bold Sans () +200272=(Ovetti) Sans () +200301=(Cescendo) Sans () +200302=(Funky) Sans Decora () +200303=(Speed) Sans Decora () +200304=(Skyline) Sans Decora () +200305=(Calculator) Sans Decora () +200306=(Xpress) Sans Decora () +200307=(Console) Sans Decora () +200308=(Paisley) Sans () +200309=(Nova) Sans () +200310=(New York) Sans Decora () +200311=(Shanghai) Sans Decora () diff --git a/svtools/source/filter.vcl/filter/sgfbram.cxx b/svtools/source/filter.vcl/filter/sgfbram.cxx new file mode 100644 index 000000000000..824abf8271f3 --- /dev/null +++ b/svtools/source/filter.vcl/filter/sgfbram.cxx @@ -0,0 +1,696 @@ +/************************************************************************* + * + * $RCSfile: sgfbram.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 <tools/stream.hxx> +#include <vcl/gdimtf.hxx> +#include <vcl/color.hxx> +#include <vcl/virdev.hxx> +#include "sgffilt.hxx" +#include "sgfbram.hxx" + +#if defined( WIN ) && defined( MSC ) +#pragma code_seg( "SVTOOLS_FILTER4", "SVTOOLS_CODE" ) +#endif + +/************************************************************************* +|* +|* operator>>( SvStream&, SgfHeader& ) +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +SvStream& operator>>(SvStream& rIStream, SgfHeader& rHead) +{ + rIStream.Read((char*)&rHead.Magic,SgfHeaderSize); +#if defined __BIGENDIAN + rHead.Magic =SWAPSHORT(rHead.Magic ); + rHead.Version=SWAPSHORT(rHead.Version); + rHead.Typ =SWAPSHORT(rHead.Typ ); + rHead.Xsize =SWAPSHORT(rHead.Xsize ); + rHead.Ysize =SWAPSHORT(rHead.Ysize ); + rHead.Xoffs =SWAPSHORT(rHead.Xoffs ); + rHead.Yoffs =SWAPSHORT(rHead.Yoffs ); + rHead.Planes =SWAPSHORT(rHead.Planes ); + rHead.SwGrCol=SWAPSHORT(rHead.SwGrCol); + rHead.OfsLo =SWAPSHORT(rHead.OfsLo ); + rHead.OfsHi =SWAPSHORT(rHead.OfsHi ); +#endif + return rIStream; +} + + +/************************************************************************* +|* +|* SgfHeader::ChkMagic() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +BOOL SgfHeader::ChkMagic() +{ return Magic=='J'*256+'J'; } + +UINT32 SgfHeader::GetOffset() +{ return UINT32(OfsLo)+0x00010000*UINT32(OfsHi); } + + +/************************************************************************* +|* +|* operator>>( SvStream&, SgfEntry& ) +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +SvStream& operator>>(SvStream& rIStream, SgfEntry& rEntr) +{ + rIStream.Read((char*)&rEntr.Typ,SgfEntrySize); +#if defined __BIGENDIAN + rEntr.Typ =SWAPSHORT(rEntr.Typ ); + rEntr.iFrei=SWAPSHORT(rEntr.iFrei); + rEntr.lFreiLo=SWAPSHORT (rEntr.lFreiLo); + rEntr.lFreiHi=SWAPSHORT (rEntr.lFreiHi); + rEntr.OfsLo=SWAPSHORT(rEntr.OfsLo); + rEntr.OfsHi=SWAPSHORT(rEntr.OfsHi); +#endif + return rIStream; +} + +UINT32 SgfEntry::GetOffset() +{ return UINT32(OfsLo)+0x00010000*UINT32(OfsHi); } + + +/************************************************************************* +|* +|* operator>>( SvStream&, SgfVector& ) +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +SvStream& operator>>(SvStream& rIStream, SgfVector& rVect) +{ + rIStream.Read((char*)&rVect,sizeof(rVect)); +#if defined __BIGENDIAN + rVect.Flag =SWAPSHORT(rVect.Flag ); + rVect.x =SWAPSHORT(rVect.x ); + rVect.y =SWAPSHORT(rVect.y ); + rVect.OfsLo=SWAPLONG (rVect.OfsLo); + rVect.OfsHi=SWAPLONG (rVect.OfsHi); +#endif + return rIStream; +} + + +/************************************************************************* +|* +|* operator<<( SvStream&, BmpFileHeader& ) +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +SvStream& operator<<(SvStream& rOStream, BmpFileHeader& rHead) +{ +#if defined __BIGENDIAN + rHead.Typ =SWAPSHORT(rHead.Typ ); + rHead.SizeLo =SWAPSHORT(rHead.SizeLo ); + rHead.SizeHi =SWAPSHORT(rHead.SizeHi ); + rHead.Reserve1=SWAPSHORT(rHead.Reserve1); + rHead.Reserve2=SWAPSHORT(rHead.Reserve2); + rHead.OfsLo =SWAPSHORT(rHead.OfsLo ); + rHead.OfsHi =SWAPSHORT(rHead.OfsHi ); +#endif + rOStream.Write((char*)&rHead,sizeof(rHead)); +#if defined __BIGENDIAN + rHead.Typ =SWAPSHORT(rHead.Typ ); + rHead.SizeLo =SWAPSHORT(rHead.SizeLo ); + rHead.SizeHi =SWAPSHORT(rHead.SizeHi ); + rHead.Reserve1=SWAPSHORT(rHead.Reserve1); + rHead.Reserve2=SWAPSHORT(rHead.Reserve2); + rHead.OfsLo =SWAPSHORT(rHead.OfsLo ); + rHead.OfsHi =SWAPSHORT(rHead.OfsHi ); +#endif + return rOStream; +} + +void BmpFileHeader::SetSize(UINT32 Size) +{ + SizeLo=UINT16(Size & 0x0000FFFF); + SizeHi=UINT16((Size & 0xFFFF0000)>>16); +} + +void BmpFileHeader::SetOfs(UINT32 Ofs) +{ + OfsLo=UINT16(Ofs & 0x0000FFFF); + OfsHi=UINT16((Ofs & 0xFFFF0000)>>16); +} + +UINT32 BmpFileHeader::GetOfs() +{ + return UINT32(OfsLo)+0x00010000*UINT32(OfsHi); +} + +/************************************************************************* +|* +|* operator<<( SvStream&, BmpInfoHeader& ) +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +SvStream& operator<<(SvStream& rOStream, BmpInfoHeader& rInfo) +{ +#if defined __BIGENDIAN + rInfo.Size =SWAPLONG (rInfo.Size ); + rInfo.Width =SWAPLONG (rInfo.Width ); + rInfo.Hight =SWAPLONG (rInfo.Hight ); + rInfo.Planes =SWAPSHORT(rInfo.Planes ); + rInfo.PixBits =SWAPSHORT(rInfo.PixBits ); + rInfo.Compress=SWAPLONG (rInfo.Compress); + rInfo.ImgSize =SWAPLONG (rInfo.ImgSize ); + rInfo.xDpmm =SWAPLONG (rInfo.xDpmm ); + rInfo.yDpmm =SWAPLONG (rInfo.yDpmm ); + rInfo.ColUsed =SWAPLONG (rInfo.ColUsed ); + rInfo.ColMust =SWAPLONG (rInfo.ColMust ); +#endif + rOStream.Write((char*)&rInfo,sizeof(rInfo)); +#if defined __BIGENDIAN + rInfo.Size =SWAPLONG (rInfo.Size ); + rInfo.Width =SWAPLONG (rInfo.Width ); + rInfo.Hight =SWAPLONG (rInfo.Hight ); + rInfo.Planes =SWAPSHORT(rInfo.Planes ); + rInfo.PixBits =SWAPSHORT(rInfo.PixBits ); + rInfo.Compress=SWAPLONG (rInfo.Compress); + rInfo.ImgSize =SWAPLONG (rInfo.ImgSize ); + rInfo.xDpmm =SWAPLONG (rInfo.xDpmm ); + rInfo.yDpmm =SWAPLONG (rInfo.yDpmm ); + rInfo.ColUsed =SWAPLONG (rInfo.ColUsed ); + rInfo.ColMust =SWAPLONG (rInfo.ColMust ); +#endif + return rOStream; +} + + +/************************************************************************* +|* +|* operator<<( SvStream&, RGBQuad& ) +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +SvStream& operator<<(SvStream& rOStream, const RGBQuad& rQuad) +{ + rOStream.Write((char*)&rQuad,sizeof(rQuad)); + return rOStream; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// PcxExpand /////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +class PcxExpand +{ +private: + USHORT Count; + BYTE Data; +public: + PcxExpand() { Count=0; } + BYTE GetByte(SvStream& rInp); +}; + +BYTE PcxExpand::GetByte(SvStream& rInp) +{ + if (Count>0) { + Count--; + } else { + rInp.Read((char*)&Data,1); + if ((Data & 0xC0) == 0xC0) { + Count=(Data & 0x3F) -1; + rInp.Read((char*)&Data,1); + } + } + return Data; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// SgfBMapFilter /////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////// + + +/************************************************************************* +|* +|* SgfFilterBmp() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +BOOL SgfFilterBMap(SvStream& rInp, SvStream& rOut, SgfHeader& rHead, SgfEntry&) +{ + BmpFileHeader aBmpHead; + BmpInfoHeader aBmpInfo; + USHORT nWdtInp=(rHead.Xsize+7)/8; // Breite der Input-Bitmap in Bytes + USHORT nWdtOut; // Breite der Output-Bitmap in Bytes + USHORT nColors; // Anzahl der Farben (1,16,256) + USHORT nColBits; // Anzahl der Bits/Pixel (2, 4, 8) + USHORT i,j,k; // Spaltenz„hler, Zeilenz„hler, Planez„hler + USHORT a,b; // Hilfsvariable + BYTE pl1,pl2; // Masken fr die Planes + BYTE* pBuf=NULL; // Buffer fr eine Pixelzeile + PcxExpand aPcx; + ULONG nOfs; + BYTE cRGB[4]; + + if (rHead.Planes<=1) nColBits=1; else nColBits=4; if (rHead.Typ==4) nColBits=8; + nColors=1<<nColBits; + nWdtOut=((rHead.Xsize*nColBits+31)/32)*4; + aBmpHead.Typ='B'+'M'*256; + aBmpHead.SetOfs(sizeof(aBmpHead)+sizeof(aBmpInfo)+nColors*4); + aBmpHead.SetSize(aBmpHead.GetOfs()+nWdtOut*rHead.Ysize); + aBmpHead.Reserve1=0; + aBmpHead.Reserve2=0; + aBmpInfo.Size=sizeof(aBmpInfo); + aBmpInfo.Width=rHead.Xsize; + aBmpInfo.Hight=rHead.Ysize; + aBmpInfo.Planes=1; + aBmpInfo.PixBits=nColBits; + aBmpInfo.Compress=0; + aBmpInfo.ImgSize=0; + aBmpInfo.xDpmm=0; + aBmpInfo.yDpmm=0; + aBmpInfo.ColUsed=0; + aBmpInfo.ColMust=0; + pBuf=new BYTE[nWdtOut]; + if (!pBuf) return FALSE; // Fehler: kein Speichel da + rOut<<aBmpHead<<aBmpInfo; + memset(pBuf,0,nWdtOut); // Buffer mit Nullen fllen + + if (nColors==2) + { + + rOut<<RGBQuad(0x00,0x00,0x00); // Schwarz + rOut<<RGBQuad(0xFF,0xFF,0xFF); // Weiss + nOfs=rOut.Tell(); + for (j=0;j<rHead.Ysize;j++) + rOut.Write((char*)pBuf,nWdtOut); // Datei erstmal komplett mit Nullen fllen + for (j=0;j<rHead.Ysize;j++) { + for(i=0;i<nWdtInp;i++) { + pBuf[i]=aPcx.GetByte(rInp); + } + for(i=nWdtInp;i<nWdtOut;i++) pBuf[i]=0; // noch bis zu 3 Bytes + rOut.Seek(nOfs+((ULONG)rHead.Ysize-j-1L)*(ULONG)nWdtOut); // rckw„rts schreiben! + rOut.Write((char*)pBuf,nWdtOut); + } + } else if (nColors==16) { + rOut<<RGBQuad(0x00,0x00,0x00); // Schwarz + rOut<<RGBQuad(0x24,0x24,0x24); // Grau 80% + rOut<<RGBQuad(0x49,0x49,0x49); // Grau 60% + rOut<<RGBQuad(0x92,0x92,0x92); // Grau 40% + rOut<<RGBQuad(0x6D,0x6D,0x6D); // Grau 30% + rOut<<RGBQuad(0xB6,0xB6,0xB6); // Grau 20% + rOut<<RGBQuad(0xDA,0xDA,0xDA); // Grau 10% + rOut<<RGBQuad(0xFF,0xFF,0xFF); // Weiss + rOut<<RGBQuad(0x00,0x00,0x00); // Schwarz + rOut<<RGBQuad(0xFF,0x00,0x00); // Rot + rOut<<RGBQuad(0x00,0x00,0xFF); // Blau + rOut<<RGBQuad(0xFF,0x00,0xFF); // Magenta + rOut<<RGBQuad(0x00,0xFF,0x00); // Gruen + rOut<<RGBQuad(0xFF,0xFF,0x00); // Gelb + rOut<<RGBQuad(0x00,0xFF,0xFF); // Cyan + rOut<<RGBQuad(0xFF,0xFF,0xFF); // Weiss + + nOfs=rOut.Tell(); + for (j=0;j<rHead.Ysize;j++) + rOut.Write((char*)pBuf,nWdtOut); // Datei erstmal komplett mit Nullen fllen + for (j=0;j<rHead.Ysize;j++) { + memset(pBuf,0,nWdtOut); + for(k=0;k<4;k++) { + if (k==0) { + pl1=0x10; pl2=0x01; + } else { + pl1<<=1; pl2<<=1; + } + for(i=0;i<nWdtInp;i++) { + a=i*4; + b=aPcx.GetByte(rInp); + if (b & 0x80) pBuf[a ]|=pl1; + if (b & 0x40) pBuf[a ]|=pl2; + if (b & 0x20) pBuf[a+1]|=pl1; + if (b & 0x10) pBuf[a+1]|=pl2; + if (b & 0x08) pBuf[a+2]|=pl1; + if (b & 0x04) pBuf[a+2]|=pl2; + if (b & 0x02) pBuf[a+3]|=pl1; + if (b & 0x01) pBuf[a+3]|=pl2; + } + } + for(i=nWdtInp*4;i<nWdtOut;i++) pBuf[i]=0; // noch bis zu 3 Bytes + rOut.Seek(nOfs+((ULONG)rHead.Ysize-j-1L)*(ULONG)nWdtOut); // rckw„rts schreiben! + rOut.Write((char*)pBuf,nWdtOut); + } + } else if (nColors==256) { + cRGB[3]=0; // der 4. Paletteneintrag fr BMP + for (i=0;i<256;i++) { // Palette kopieren + rInp.Read((char*)cRGB,3); + pl1=cRGB[0]; // Rot mit Blau tauschen + cRGB[0]=cRGB[2]; + cRGB[2]=pl1; + rOut.Write((char*)cRGB,4); + } + + nOfs=rOut.Tell(); + for (j=0;j<rHead.Ysize;j++) + rOut.Write((char*)pBuf,nWdtOut); // Datei erstmal komplett mit Nullen fllen + for (j=0;j<rHead.Ysize;j++) { + for(i=0;i<rHead.Xsize;i++) + pBuf[i]=aPcx.GetByte(rInp); + for(i=rHead.Xsize;i<nWdtOut;i++) pBuf[i]=0; // noch bis zu 3 Bytes + rOut.Seek(nOfs+((ULONG)rHead.Ysize-j-1L)*(ULONG)nWdtOut); // rckw„rts schreiben! + rOut.Write((char*)pBuf,nWdtOut); + } + } + delete pBuf; + return TRUE; +} + + +/************************************************************************* +|* +|* SgfBMapFilter() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +BOOL SgfBMapFilter(SvStream& rInp, SvStream& rOut) +{ + ULONG nFileStart; // Offset des SgfHeaders. Im allgemeinen 0. + SgfHeader aHead; + SgfEntry aEntr; + ULONG nNext; + BOOL bRdFlag=FALSE; // Grafikentry gelesen ? + BOOL bRet=FALSE; // Returncode + + nFileStart=rInp.Tell(); + rInp>>aHead; + if (aHead.ChkMagic() && (aHead.Typ==SgfBitImag0 || aHead.Typ==SgfBitImag1 || + aHead.Typ==SgfBitImag2 || aHead.Typ==SgfBitImgMo)) { + nNext=aHead.GetOffset(); + while (nNext && !bRdFlag && !rInp.GetError() && !rOut.GetError()) { + rInp.Seek(nFileStart+nNext); + rInp>>aEntr; + nNext=aEntr.GetOffset(); + if (aEntr.Typ==aHead.Typ) { + bRdFlag=TRUE; + switch(aEntr.Typ) { + case SgfBitImag0: + case SgfBitImag1: + case SgfBitImag2: + case SgfBitImgMo: bRet=SgfFilterBMap(rInp,rOut,aHead,aEntr); break; + } + } + } // while(nNext) + } + if (rInp.GetError()) bRet=FALSE; + return(bRet); +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// SgfVectFilter /////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +// Fr StarDraw Embedded SGF-Vector +long SgfVectXofs=0; +long SgfVectYofs=0; +long SgfVectXmul=0; +long SgfVectYmul=0; +long SgfVectXdiv=0; +long SgfVectYdiv=0; +BOOL SgfVectScal=FALSE; + +//////////////////////////////////////////////////////////// +// Hpgl2SvFarbe //////////////////////////////////////////// +//////////////////////////////////////////////////////////// + +Color Hpgl2SvFarbe( BYTE nFarb ) +{ + ULONG nColor = COL_BLACK; + + switch (nFarb & 0x07) { + case 0: nColor=COL_WHITE; break; + case 1: nColor=COL_YELLOW; break; + case 2: nColor=COL_LIGHTMAGENTA; break; + case 3: nColor=COL_LIGHTRED; break; + case 4: nColor=COL_LIGHTCYAN; break; + case 5: nColor=COL_LIGHTGREEN; break; + case 6: nColor=COL_LIGHTBLUE; break; + case 7: nColor=COL_BLACK; break; + } + Color aColor( nColor ); + return aColor; +} + +/************************************************************************* +|* +|* SgfFilterVect() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +BOOL SgfFilterVect(SvStream& rInp, SgfHeader& rHead, SgfEntry&, GDIMetaFile& rMtf) +{ + VirtualDevice aOutDev; + SgfVector aVect; + BYTE nFarb; + BYTE nFrb0=7; + BYTE nLTyp; + BYTE nOTyp; + BOOL bEoDt=FALSE; + BOOL bPDwn=FALSE; + Point aP0(0,0); + Point aP1(0,0); + String Msg; + USHORT RecNr=0; + + rMtf.Record(&aOutDev); + aOutDev.SetLineColor(Color(COL_BLACK)); + aOutDev.SetFillColor(Color(COL_BLACK)); + + while (!bEoDt && !rInp.GetError()) { + rInp>>aVect; RecNr++; + nFarb=(BYTE) (aVect.Flag & 0x000F); + nLTyp=(BYTE)((aVect.Flag & 0x00F0) >>4); + nOTyp=(BYTE)((aVect.Flag & 0x0F00) >>8); + bEoDt=(aVect.Flag & 0x4000) !=0; + bPDwn=(aVect.Flag & 0x8000) !=0; + + long x=aVect.x-rHead.Xoffs; + long y=rHead.Ysize-(aVect.y-rHead.Yoffs); + if (SgfVectScal) { + if (SgfVectXdiv==0) SgfVectXdiv=rHead.Xsize; + if (SgfVectYdiv==0) SgfVectYdiv=rHead.Ysize; + if (SgfVectXdiv==0) SgfVectXdiv=1; + if (SgfVectYdiv==0) SgfVectYdiv=1; + x=SgfVectXofs+ x *SgfVectXmul /SgfVectXdiv; + y=SgfVectYofs+ y *SgfVectXmul /SgfVectYdiv; + } + aP1=Point(x,y); + if (!bEoDt && !rInp.GetError()) { + if (bPDwn && nLTyp<=6) { + switch(nOTyp) { + case 1: if (nFarb!=nFrb0) { + switch(rHead.SwGrCol) { + case SgfVectFarb: aOutDev.SetLineColor(Hpgl2SvFarbe(nFarb)); break; + case SgfVectGray: break; + case SgfVectWdth: break; + } + } + aOutDev.DrawLine(aP0,aP1); break; // Linie + case 2: break; // Kreis + case 3: break; // Text + case 5: aOutDev.DrawRect(Rectangle(aP0,aP1)); break; // Rechteck (solid) + } + } + aP0=aP1; + nFrb0=nFarb; + } + } + rMtf.Stop(); + rMtf.WindStart(); + MapMode aMap( MAP_10TH_MM, Point(), + Fraction( 1, 4 ), Fraction( 1, 4 ) ); + rMtf.SetPrefMapMode( aMap ); + rMtf.SetPrefSize( Size( (short)rHead.Xsize, (short)rHead.Ysize ) ); + return TRUE; +} + + +/************************************************************************* +|* +|* SgfVectFilter() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +BOOL SgfVectFilter(SvStream& rInp, GDIMetaFile& rMtf) +{ + ULONG nFileStart; // Offset des SgfHeaders. Im allgemeinen 0. + SgfHeader aHead; + SgfEntry aEntr; + ULONG nNext; + BOOL bRdFlag=FALSE; // Grafikentry gelesen ? + BOOL bRet=FALSE; // Returncode + + nFileStart=rInp.Tell(); + rInp>>aHead; + if (aHead.ChkMagic() && aHead.Typ==SGF_SIMPVECT) { + nNext=aHead.GetOffset(); + while (nNext && !bRdFlag && !rInp.GetError()) { + rInp.Seek(nFileStart+nNext); + rInp>>aEntr; + nNext=aEntr.GetOffset(); + if (aEntr.Typ==aHead.Typ) { + bRet=SgfFilterVect(rInp,aHead,aEntr,rMtf); + } + } // while(nNext) + if (bRdFlag) { + if (!rInp.GetError()) bRet=TRUE; // Scheinbar Ok + } + } + return(bRet); +} + + +/************************************************************************* +|* +|* SgfFilterPScr() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +BOOL SgfFilterPScr(SvStream&, SgfHeader&, SgfEntry&) +{ + return FALSE; // PostSrcipt wird noch nicht unterstuetzt ! +} + + +/************************************************************************* +|* +|* CheckSgfTyp() +|* +|* Beschreibung Feststellen, uwas fr ein SGF/SGV es sich handelt. +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +BYTE CheckSgfTyp(SvStream& rInp, USHORT& nVersion) +{ +#ifdef DEBUG // Recordgr”áen checken. Neuer Compiler hat vielleichte anderes Allignment! + if (sizeof(SgfHeader)!=SgfHeaderSize || + sizeof(SgfEntry) !=SgfEntrySize || + sizeof(SgfVector)!=SgfVectorSize || + sizeof(BmpFileHeader)!=BmpFileHeaderSize || + sizeof(BmpInfoHeader)!=BmpInfoHeaderSize || + sizeof(RGBQuad )!=RGBQuadSize ) return SGF_DONTKNOW; +#endif + + ULONG nPos; + SgfHeader aHead; + nVersion=0; + nPos=rInp.Tell(); + rInp>>aHead; + rInp.Seek(nPos); + if (aHead.ChkMagic()) { + nVersion=aHead.Version; + switch(aHead.Typ) { + case SgfBitImag0: + case SgfBitImag1: + case SgfBitImag2: + case SgfBitImgMo: return SGF_BITIMAGE; + case SgfSimpVect: return SGF_SIMPVECT; + case SgfPostScrp: return SGF_POSTSCRP; + case SgfStarDraw: return SGF_STARDRAW; + default : return SGF_DONTKNOW; + } + } else { + return SGF_DONTKNOW; + } +} diff --git a/svtools/source/filter.vcl/filter/sgvmain.cxx b/svtools/source/filter.vcl/filter/sgvmain.cxx new file mode 100644 index 000000000000..33e59755579a --- /dev/null +++ b/svtools/source/filter.vcl/filter/sgvmain.cxx @@ -0,0 +1,1220 @@ +/************************************************************************* + * + * $RCSfile: sgvmain.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#ifdef MAC +#include <mac_start.h> +#include <math.h> +#include <mac_end.h> +#else +#include <math.h> +#endif +#include <vcl/graph.hxx> +#include <vcl/poly.hxx> +#include "filter.hxx" +#include "sgffilt.hxx" +#include "sgfbram.hxx" +#include "sgvmain.hxx" +#include "sgvspln.hxx" + +#ifdef DEBUG +//#include "Debug.c" +#endif + +#define SWAPPOINT(p) { \ + p.x=SWAPSHORT(p.x); \ + p.y=SWAPSHORT(p.y); } + +#define SWAPPAGE(p) { \ + p.Next =SWAPLONG (p.Next ); \ + p.nList =SWAPLONG (p.nList ); \ + p.ListEnd=SWAPLONG (p.ListEnd); \ + p.Paper.Size.x=SWAPSHORT(p.Paper.Size.x); \ + p.Paper.Size.y=SWAPSHORT(p.Paper.Size.y); \ + p.Paper.RandL =SWAPSHORT(p.Paper.RandL ); \ + p.Paper.RandR =SWAPSHORT(p.Paper.RandR ); \ + p.Paper.RandO =SWAPSHORT(p.Paper.RandO ); \ + p.Paper.RandU =SWAPSHORT(p.Paper.RandU ); \ + SWAPPOINT(p.U); \ + UINT16 iTemp; \ + for (iTemp=0;iTemp<20;iTemp++) { \ + rPage.HlpLnH[iTemp]=SWAPSHORT(rPage.HlpLnH[iTemp]); \ + rPage.HlpLnV[iTemp]=SWAPSHORT(rPage.HlpLnV[iTemp]); }} + +#define SWAPOBJK(o) { \ + o.Last =SWAPLONG (o.Last ); \ + o.Next =SWAPLONG (o.Next ); \ + o.MemSize =SWAPSHORT(o.MemSize ); \ + SWAPPOINT(o.ObjMin); \ + SWAPPOINT(o.ObjMax); } + +#define SWAPLINE(l) { \ + l.LMSize=SWAPSHORT(l.LMSize); \ + l.LDicke=SWAPSHORT(l.LDicke); } + +#define SWAPAREA(a) { \ + a.FDummy2=SWAPSHORT(a.FDummy2); \ + a.FMuster=SWAPSHORT(a.FMuster); } + +#define SWAPTEXT(t) { \ + SWAPLINE(t.L); \ + SWAPAREA(t.F); \ + t.FontLo =SWAPSHORT(t.FontLo ); \ + t.FontHi =SWAPSHORT(t.FontHi ); \ + t.Grad =SWAPSHORT(t.Grad ); \ + t.Breite =SWAPSHORT(t.Breite ); \ + t.Schnitt=SWAPSHORT(t.Schnitt); \ + t.LnFeed =SWAPSHORT(t.LnFeed ); \ + t.Slant =SWAPSHORT(t.Slant ); \ + SWAPLINE(t.ShdL); \ + SWAPAREA(t.ShdF); \ + SWAPPOINT(t.ShdVers); \ + SWAPAREA(t.BackF); } + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Einschränkungen: +// +// þ Flächenmuster werden den unter StarView verfügbaren Mustern angenähert. +// þ Linienenden werden unter StarView immer rund dargestellt und gehen über +// den Endpunkt der Linie hinaus. +// þ Linienmuster werden den unter StarView verfügbaren Mustern angenähert. +// Transparent/Opak wird zur Zeit noch nicht berücksichtigt. +// þ Keine gedrehten Ellipsen +// +// +// +// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +#if defined( WIN ) && defined( MSC ) +#pragma code_seg( "svtools", "AUTO_CODE" ) +#endif + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Für Fontübersetzung ///////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////// +SgfFontLst* pSgfFonts = 0; + +#if defined( WIN ) && defined( MSC ) +#pragma code_seg( "SVTOOLS_FILTER3", "SVTOOLS_CODE" ) +static void AntiMscBug() {} +#endif + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Für Kreisunterarten, Text und gedrehte Rechtecke //////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////// +void RotatePoint(PointType& P, INT16 cx, INT16 cy, double sn, double cs) +{ + INT16 dx,dy; + double x1,y1; + dx=P.x-cx; + dy=P.y-cy; + x1=dx*cs-dy*sn; + y1=dy*cs+dx*sn; + P.x=cx+INT16(x1); + P.y=cy+INT16(y1); +} + +void RotatePoint(Point& P, INT16 cx, INT16 cy, double sn, double cs) +{ + INT16 dx,dy; + double x1,y1; + dx=(INT16)(P.X()-cx); + dy=(INT16)(P.Y()-cy); + x1=dx*cs-dy*sn; + y1=dy*cs+dx*sn; + P=Point(cx+INT16(x1),cy+INT16(y1)); +} + +INT16 iMulDiv(INT16 a, INT16 Mul, INT16 Div) +{ + INT32 Temp; + Temp=INT32(a)*INT32(Mul)/INT32(Div); + return INT16(Temp); +} + +UINT16 MulDiv(UINT16 a, UINT16 Mul, UINT16 Div) +{ + UINT32 Temp; + Temp=UINT32(a)*UINT32(Mul)/UINT32(Div); + return UINT16(Temp); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// SgfFilterSDrw /////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +SvStream& operator>>(SvStream& rIStream, DtHdType& rDtHd) +{ + rIStream.Read((char*)&rDtHd.Reserved[0],DtHdSize); + return rIStream; +} + +void DtHdOverSeek(SvStream& rInp) +{ + ULONG FPos=rInp.Tell(); + FPos+=(ULONG)DtHdSize; + rInp.Seek(FPos); +// rInp.seekg(rInp.tellg()+(ULONG)DtHdSize); +} + + +SvStream& operator>>(SvStream& rIStream, PageType& rPage) +{ + rIStream.Read((char*)&rPage.Next,PageSize); +#if defined __BIGENDIAN + SWAPPAGE(rPage); +#endif + return rIStream; +} + +void ObjkOverSeek(SvStream& rInp, ObjkType& rObjk) +{ + ULONG Siz; + Siz=(ULONG)rObjk.MemSize+rObjk.Last; // ObjSize+ObjAnhSize + rInp.Seek(rInp.Tell()+Siz); +} + +SvStream& operator>>(SvStream& rInp, ObjkType& rObjk) +{ // Die Fileposition im Stream bleibt unverändert! + ULONG nPos; + nPos=rInp.Tell(); + rInp.Read((char*)&rObjk.Last,ObjkSize); +#if defined __BIGENDIAN + SWAPOBJK(rObjk); +#endif +#ifdef InArbeit + ULONG nPos1=rInp.Tell(); + if(nPos == nPos1) InfoBox( NULL, "tellg funkt nich" ).Execute(); +#endif + rInp.Seek(nPos); +#ifdef InArbeit + if (rInp.Tell() != nPos) InfoBox( NULL, "seekg funkt nich" ).Execute(); +#endif + return rInp; +} +SvStream& operator>>(SvStream& rInp, StrkType& rStrk) +{ + rInp.Read((char*)&rStrk.Last,StrkSize); +#if defined __BIGENDIAN + SWAPOBJK (rStrk); + SWAPLINE (rStrk.L); + SWAPPOINT(rStrk.Pos1); + SWAPPOINT(rStrk.Pos2); +#endif + return rInp; +} +SvStream& operator>>(SvStream& rInp, RectType& rRect) +{ + rInp.Read((char*)&rRect.Last,RectSize); +#if defined __BIGENDIAN + SWAPOBJK (rRect); + SWAPLINE (rRect.L); + SWAPAREA (rRect.F); + SWAPPOINT(rRect.Pos1); + SWAPPOINT(rRect.Pos2); + rRect.Radius =SWAPSHORT(rRect.Radius ); + rRect.DrehWink=SWAPSHORT(rRect.DrehWink); + rRect.Slant =SWAPSHORT(rRect.Slant ); +#endif + return rInp; +} +SvStream& operator>>(SvStream& rInp, PolyType& rPoly) +{ + rInp.Read((char*)&rPoly.Last,PolySize); +#if defined __BIGENDIAN + SWAPOBJK (rPoly); + SWAPLINE (rPoly.L); + SWAPAREA (rPoly.F); + // rPoly.EckP=SWAPLONG(rPoly.EckP); +#endif + return rInp; +} +SvStream& operator>>(SvStream& rInp, SplnType& rSpln) +{ + rInp.Read((char*)&rSpln.Last,SplnSize); +#if defined __BIGENDIAN + SWAPOBJK (rSpln); + SWAPLINE (rSpln.L); + SWAPAREA (rSpln.F); + // rSpln.EckP=SWAPLONG(rSpln.EckP); +#endif + return rInp; +} +SvStream& operator>>(SvStream& rInp, CircType& rCirc) +{ + rInp.Read((char*)&rCirc.Last,CircSize); +#if defined __BIGENDIAN + SWAPOBJK (rCirc); + SWAPLINE (rCirc.L); + SWAPAREA (rCirc.F); + SWAPPOINT(rCirc.Radius); + SWAPPOINT(rCirc.Center); + rCirc.DrehWink =SWAPSHORT(rCirc.DrehWink ); + rCirc.StartWink=SWAPSHORT(rCirc.StartWink); + rCirc.RelWink =SWAPSHORT(rCirc.RelWink ); +#endif + return rInp; +} +SvStream& operator>>(SvStream& rInp, TextType& rText) +{ + rInp.Read((char*)&rText.Last,TextSize); +#if defined __BIGENDIAN + SWAPOBJK (rText); + SWAPTEXT (rText.T); + SWAPPOINT(rText.Pos1); + SWAPPOINT(rText.Pos2); + rText.TopOfs =SWAPSHORT(rText.TopOfs ); + rText.DrehWink=SWAPSHORT(rText.DrehWink); + rText.BoxSlant=SWAPSHORT(rText.BoxSlant); + rText.BufSize =SWAPSHORT(rText.BufSize ); + //rText.Buf =SWAPLONG (rText.Buf ); + //rText.Ext =SWAPLONG (rText.Ext ); + SWAPPOINT(rText.FitSize); + rText.FitBreit=SWAPSHORT(rText.FitBreit); +#endif + rText.Buffer=NULL; + return rInp; +} +SvStream& operator>>(SvStream& rInp, BmapType& rBmap) +{ + rInp.Read((char*)&rBmap.Last,BmapSize); +#if defined __BIGENDIAN + SWAPOBJK (rBmap); + SWAPAREA (rBmap.F); + SWAPPOINT(rBmap.Pos1); + SWAPPOINT(rBmap.Pos2); + rBmap.DrehWink=SWAPSHORT(rBmap.DrehWink); + rBmap.Slant =SWAPSHORT(rBmap.Slant ); + SWAPPOINT(rBmap.PixSize); +#endif + return rInp; +} +SvStream& operator>>(SvStream& rInp, GrupType& rGrup) +{ + rInp.Read((char*)&rGrup.Last,GrupSize); +#if defined __BIGENDIAN + SWAPOBJK (rGrup); + rGrup.SbLo =SWAPSHORT(rGrup.SbLo ); + rGrup.SbHi =SWAPSHORT(rGrup.SbHi ); + rGrup.UpLo =SWAPSHORT(rGrup.UpLo ); + rGrup.UpHi =SWAPSHORT(rGrup.UpHi ); + rGrup.ChartSize=SWAPSHORT(rGrup.ChartSize); + rGrup.ChartPtr =SWAPLONG (rGrup.ChartPtr ); +#endif + return rInp; +} + + + +/************************************************************************* +|* +|* Sgv2SvFarbe() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +#ifndef VCL +Color Sgv2SvFarbe(BYTE nFrb1, BYTE nFrb2, BYTE nInts) +{ + UINT16 r1=0,g1=0,b1=0,r2=0,g2=0,b2=0; + BYTE nInt2=100-nInts; + switch(nFrb1 & 0x07) { + case 0: r1=0xFFFF; g1=0xFFFF; b1=0xFFFF; break; + case 1: r1=0xFFFF; g1=0xFFFF; break; + case 2: g1=0xFFFF; b1=0xFFFF; break; + case 3: g1=0xFFFF; break; + case 4: r1=0xFFFF; b1=0xFFFF; break; + case 5: r1=0xFFFF; break; + case 6: b1=0xFFFF; break; + case 7: break; + } + switch(nFrb2 & 0x07) { + case 0: r2=0xFFFF; g2=0xFFFF; b2=0xFFFF; break; + case 1: r2=0xFFFF; g2=0xFFFF; break; + case 2: g2=0xFFFF; b2=0xFFFF; break; + case 3: g2=0xFFFF; break; + case 4: r2=0xFFFF; b2=0xFFFF; break; + case 5: r2=0xFFFF; break; + case 6: b2=0xFFFF; break; + case 7: break; + } +#else +Color Sgv2SvFarbe(BYTE nFrb1, BYTE nFrb2, BYTE nInts) +{ + UINT16 r1=0,g1=0,b1=0,r2=0,g2=0,b2=0; + BYTE nInt2=100-nInts; + switch(nFrb1 & 0x07) { + case 0: r1=0xFF; g1=0xFF; b1=0xFF; break; + case 1: r1=0xFF; g1=0xFF; break; + case 2: g1=0xFF; b1=0xFF; break; + case 3: g1=0xFF; break; + case 4: r1=0xFF; b1=0xFF; break; + case 5: r1=0xFF; break; + case 6: b1=0xFF; break; + case 7: break; + } + switch(nFrb2 & 0x07) { + case 0: r2=0xFF; g2=0xFF; b2=0xFF; break; + case 1: r2=0xFF; g2=0xFF; break; + case 2: g2=0xFF; b2=0xFF; break; + case 3: g2=0xFF; break; + case 4: r2=0xFF; b2=0xFF; break; + case 5: r2=0xFF; break; + case 6: b2=0xFF; break; + case 7: break; + } +#endif + r1=(UINT16)((UINT32)r1*nInts/100+(UINT32)r2*nInt2/100); + g1=(UINT16)((UINT32)g1*nInts/100+(UINT32)g2*nInt2/100); + b1=(UINT16)((UINT32)b1*nInts/100+(UINT32)b2*nInt2/100); + Color aColor(r1,g1,b1); + return aColor; +} + +void SetLine(ObjLineType& rLine, OutputDevice& rOut) +{ +/* !!! + PenStyle aStyle=PEN_SOLID; + switch(rLine.LMuster & 0x07) { + case 0: aStyle=PEN_NULL; break; + case 1: aStyle=PEN_SOLID; break; + case 2: aStyle=PEN_DOT; break; // ù ù ù ù ù ù ù ù ù ù ù ù ù ù + case 3: aStyle=PEN_DASH; break; // ÄÄ ÄÄ ÄÄ ÄÄ ÄÄ ÄÄ ÄÄ ÄÄ ÄÄ + case 4: aStyle=PEN_DASH; break; // ÄÄÄ ÄÄÄ ÄÄÄ ÄÄÄ ÄÄÄ ÄÄÄ ÄÄÄ + case 5: aStyle=PEN_DASHDOT; break; // ÄÄ ù ÄÄ ù ÄÄ ù ÄÄ ù ÄÄ ù ÄÄ + case 6: aStyle=PEN_DASHDOT; break; // ÄÄ Ä ÄÄ Ä ÄÄ Ä ÄÄ Ä ÄÄ Ä ÄÄ + case 7: aStyle=PEN_DASHDOT; break; // ÄÄÄ Ä Ä ÄÄÄ Ä Ä ÄÄÄ Ä Ä ÄÄÄ + } + Pen aPen(Sgv2SvFarbe(rLine.LFarbe,rLine.LBFarbe,rLine.LIntens),rLine.LDicke,aStyle); + SetPen(aPen,rOut); +*/ + if( 0 == ( rLine.LMuster & 0x07 ) ) + rOut.SetLineColor(); + else + rOut.SetLineColor( Sgv2SvFarbe(rLine.LFarbe,rLine.LBFarbe,rLine.LIntens) ); +} + +void SetArea(ObjAreaType& rArea, OutputDevice& rOut) +{ +/* + BrushStyle aStyle=BRUSH_SOLID; + switch(rArea.FMuster & 0x00FF) { + case 0: aStyle=BRUSH_NULL; break; + case 1: aStyle=BRUSH_SOLID; break; + case 2: case 4: case 6: case 8: + case 10: case 12: case 14: case 16: + case 43: case 45: aStyle=BRUSH_VERT; break; + case 3: case 5: case 7: case 9: + case 11: case 13: case 15: case 17: + case 42: case 44: aStyle=BRUSH_HORZ; break; + case 18: case 20: case 22: case 24: + case 26: case 28: case 30: case 32: + case 46: case 48: aStyle=BRUSH_UPDIAG; break; + case 19: case 21: case 23: case 25: + case 27: case 29: case 31: case 33: + case 47: case 49: aStyle=BRUSH_DOWNDIAG; break; + case 34: case 35: case 36: case 37: aStyle=BRUSH_CROSS; break; + case 38: case 39: case 40: case 41: aStyle=BRUSH_DIAGCROSS; break; + default: aStyle=BRUSH_DIAGCROSS; break; + } + Brush aBrush(Sgv2SvFarbe(rArea.FFarbe,rArea.FBFarbe,rArea.FIntens),aStyle); + aBrush.SetTransparent((rArea.FMuster & 0x80) !=0L); + SetBrush(aBrush,rOut); +*/ + if( 0 == ( rArea.FMuster & 0x00FF ) ) + rOut.SetFillColor(); + else + rOut.SetFillColor( Sgv2SvFarbe( rArea.FFarbe,rArea.FBFarbe,rArea.FIntens ) ); +} + +/************************************************************************* +|* +|* ObjkType::DrawObjekt() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +void ObjkType::Draw(OutputDevice&) +{ +// ShowSDObjk(*this); +} + +void Obj0Type::Draw(OutputDevice&) {} + +/************************************************************************* +|* +|* StrkType::DrawObjekt() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +void StrkType::Draw(OutputDevice& rOut) +{ + SetLine(L,rOut); + rOut.DrawLine(Point(Pos1.x,Pos1.y),Point(Pos2.x,Pos2.y)); // !!! +} + +/************************************************************************* +|* +|* RectType::DrawObjekt() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +void SgfAreaColorIntens(UINT16 Muster, BYTE Col1, BYTE Col2, BYTE Int, OutputDevice& rOut) +{ + ObjAreaType F; + F.FMuster=Muster; + F.FFarbe=Col2; + F.FBFarbe=Col1; + F.FIntens=Int; + SetArea(F,rOut); +} + +void DrawSlideRect(INT16 x1, INT16 y1, INT16 x2, INT16 y2, ObjAreaType& F, OutputDevice& rOut) +{ + INT16 i,i0,b,b0; + INT16 Int1,Int2; + INT16 Col1,Col2; + // ClipMerk: HgdClipRec; + INT16 cx,cy; + INT16 MaxR; + INT32 dx,dy; + + rOut.SetLineColor(); + if (x1>x2) { i=x1; x1=x2; x2=i; } + if (y1>y2) { i=y1; y1=y2; y2=i; } + Col1=F.FBFarbe & 0x87; Col2=F.FFarbe & 0x87; + Int1=100-F.FIntens; Int2=F.FIntens; + if (Int1==Int2) { + SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int2,rOut); + rOut.DrawRect(Rectangle(x1,y1,x2,y2)); + } else { + b0=Int1; + switch (F.FBFarbe & 0x38) { + case 0x08: { // vertikal + i0=y1; + i=y1; + while (i<=y2) { + b=Int1+INT16((INT32)(Int2-Int1)*(INT32)(i-y1) /(INT32)(y2-y1+1)); + if (b!=b0) { + SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)b0,rOut); + rOut.DrawRect(Rectangle(x1,i0,x2,i-1)); + i0=i; b0=b; + } + i++; + } + SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int2,rOut); + rOut.DrawRect(Rectangle(x1,i0,x2,y2)); + } break; + case 0x28: { // horizontal + i0=x1; + i=x1; + while (i<=x2) { + b=Int1+INT16((INT32)(Int2-Int1)*(INT32)(i-x1) /(INT32)(x2-x1+1)); + if (b!=b0) { + SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)b0,rOut); + rOut.DrawRect(Rectangle(i0,y1,i-1,y2)); + i0=i; b0=b; + } + i++; + } + SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int2,rOut); + rOut.DrawRect(Rectangle(i0,y1,x2,y2)); + } break; + + case 0x18: case 0x38: { // Kreis + Region ClipMerk=rOut.GetClipRegion(); + double a; + + rOut.SetClipRegion(Region(Rectangle(x1,y1,x2,y2))); + cx=(x1+x2) /2; + cy=(y1+y2) /2; + dx=x2-x1+1; + dy=y2-y1+1; + a=sqrt((double)(dx*dx+dy*dy)); + MaxR=INT16(a) /2 +1; + b0=Int2; + i0=MaxR; if (MaxR<1) MaxR=1; + i=MaxR; + while (i>=0) { + b=Int1+INT16((INT32(Int2-Int1)*INT32(i)) /INT32(MaxR)); + if (b!=b0) { + SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)b0,rOut); + //if (i0>200 || (Col1 & $80)!=0 || (Col2 & $80)!=0) { + // then begin { Fallunterscheidung für etwas bessere Performance } + // s2:=i0-i+2; + // SetPenSize(s2); + // s2:=s2 div 2; + // Circle(cx,cy,i0-s2,i0-s2);{} + // else + rOut.DrawEllipse(Rectangle(cx-i0,cy-i0,cx+i0,cy+i0)); + i0=i; b0=b; + } + i--; + } + SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int1,rOut); + rOut.DrawEllipse(Rectangle(cx-i0,cy-i0,cx+i0,cy+i0)); + rOut.SetClipRegion(ClipMerk); + } break; // Kreis + } + } +} + + +void RectType::Draw(OutputDevice& rOut) +{ + if (L.LMuster!=0) L.LMuster=1; // keine Linienmuster hier, nur an oder aus + SetArea(F,rOut); + if (DrehWink==0) { + if ((F.FBFarbe & 0x38)==0 || Radius!=0) { + SetLine(L,rOut); + rOut.DrawRect(Rectangle(Pos1.x,Pos1.y,Pos2.x,Pos2.y),Radius,Radius); + } else { + DrawSlideRect(Pos1.x,Pos1.y,Pos2.x,Pos2.y,F,rOut); + if (L.LMuster!=0) { + SetLine(L,rOut); + rOut.SetFillColor(); + rOut.DrawRect(Rectangle(Pos1.x,Pos1.y,Pos2.x,Pos2.y)); + } + } + } else { + Point aPts[4]; + USHORT i; + double sn,cs; + sn=sin(double(DrehWink)*3.14159265359/18000); + cs=cos(double(DrehWink)*3.14159265359/18000); + aPts[0]=Point(Pos1.x,Pos1.y); + aPts[1]=Point(Pos2.x,Pos1.y); + aPts[2]=Point(Pos2.x,Pos2.y); + aPts[3]=Point(Pos1.x,Pos2.y); + for (i=0;i<4;i++) { + RotatePoint(aPts[i],Pos1.x,Pos1.y,sn,cs); + } + SetLine(L,rOut); + Polygon aPoly(4,aPts); + rOut.DrawPolygon(aPoly); + } +} + +/************************************************************************* +|* +|* PolyType::Draw() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +void PolyType::Draw(OutputDevice& rOut) +{ + if ((Flags & PolyClosBit) !=0) SetArea(F,rOut); + SetLine(L,rOut); + Polygon aPoly(nPoints); + USHORT i; + for(i=0;i<nPoints;i++) aPoly.SetPoint(Point(EckP[i].x,EckP[i].y),i); + if ((Flags & PolyClosBit) !=0) { + rOut.DrawPolygon(aPoly); + } else { + rOut.DrawPolyLine(aPoly); + } +} + +/************************************************************************* +|* +|* SplnType::Draw() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +void SplnType::Draw(OutputDevice& rOut) +{ + if ((Flags & PolyClosBit) !=0) SetArea(F,rOut); + SetLine(L,rOut); + Polygon aPoly(0); + Polygon aSpln(nPoints); + USHORT i; + for(i=0;i<nPoints;i++) aSpln.SetPoint(Point(EckP[i].x,EckP[i].y),i); + if ((Flags & PolyClosBit) !=0) { + Spline2Poly(aSpln,TRUE,aPoly); + if (aPoly.GetSize()>0) rOut.DrawPolygon(aPoly); + } else { + Spline2Poly(aSpln,FALSE,aPoly); + if (aPoly.GetSize()>0) rOut.DrawPolyLine(aPoly); + } +} + +/************************************************************************* +|* +|* CircType::Draw() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +void DrawSlideCirc(INT16 cx, INT16 cy, INT16 rx, INT16 ry, ObjAreaType& F, OutputDevice& rOut) +{ + INT16 x1=cx-rx; + INT16 y1=cy-ry; + INT16 x2=cx+rx; + INT16 y2=cy+ry; + + INT16 i,i0,b,b0; + INT16 Int1,Int2; + INT16 Col1,Col2; + + rOut.SetLineColor(); + Col1=F.FBFarbe & 0x87; Col2=F.FFarbe & 0x87; + Int1=100-F.FIntens; Int2=F.FIntens; + if (Int1==Int2) { + SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int2,rOut); + rOut.DrawEllipse(Rectangle(x1,y1,x2,y2)); + } else { + b0=Int1; + switch (F.FBFarbe & 0x38) { + case 0x08: { // vertikal + Region ClipMerk=rOut.GetClipRegion(); + i0=y1; + i=y1; + while (i<=y2) { + b=Int1+INT16((INT32)(Int2-Int1)*(INT32)(i-y1) /(INT32)(y2-y1+1)); + if (b!=b0) { + SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)b0,rOut); + rOut.SetClipRegion(Rectangle(x1,i0,x2,i-1)); + rOut.DrawEllipse(Rectangle(x1,y1,x2,y2)); + i0=i; b0=b; + } + i++; + } + SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int2,rOut); + rOut.SetClipRegion(Rectangle(x1,i0,x2,y2)); + rOut.DrawEllipse(Rectangle(x1,y1,x2,y2)); + rOut.SetClipRegion(ClipMerk); + } break; + case 0x28: { // horizontal + Region ClipMerk=rOut.GetClipRegion(); + i0=x1; + i=x1; + while (i<=x2) { + b=Int1+INT16((INT32)(Int2-Int1)*(INT32)(i-x1) /(INT32)(x2-x1+1)); + if (b!=b0) { + SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)b0,rOut); + rOut.SetClipRegion(Rectangle(i0,y1,i-1,y2)); + rOut.DrawEllipse(Rectangle(x1,y1,x2,y2)); + i0=i; b0=b; + } + i++; + } + SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int2,rOut); + rOut.SetClipRegion(Rectangle(i0,y1,x2,y2)); + rOut.DrawEllipse(Rectangle(x1,y1,x2,y2)); + rOut.SetClipRegion(ClipMerk); + } break; + + case 0x18: case 0x38: { // Kreis + INT16 MaxR; + + if (rx<1) rx=1; + if (ry<1) ry=1; + MaxR=rx; + b0=Int2; + i0=MaxR; if (MaxR<1) MaxR=1; + i=MaxR; + while (i>=0) { + b=Int1+INT16((INT32(Int2-Int1)*INT32(i)) /INT32(MaxR)); + if (b!=b0) { + INT32 temp=INT32(i0)*INT32(ry)/INT32(rx); + INT16 j0=INT16(temp); + SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)b0,rOut); + rOut.DrawEllipse(Rectangle(cx-i0,cy-j0,cx+i0,cy+j0)); + i0=i; b0=b; + } + i--; + } + SgfAreaColorIntens(F.FMuster,(BYTE)Col1,(BYTE)Col2,(BYTE)Int1,rOut); + rOut.DrawEllipse(Rectangle(cx-i0,cy-i0,cx+i0,cy+i0)); + } break; // Kreis + } + } +} + + +void CircType::Draw(OutputDevice& rOut) +{ + Rectangle aRect(Center.x-Radius.x,Center.y-Radius.y,Center.x+Radius.x,Center.y+Radius.y); + + if (L.LMuster!=0) L.LMuster=1; // keine Linienmuster hier, nur an oder aus + SetArea(F,rOut); + if ((Flags & 0x03)==CircFull) { + if ((F.FBFarbe & 0x38)==0) { + SetLine(L,rOut); + rOut.DrawEllipse(aRect); + } else { + DrawSlideCirc(Center.x,Center.y,Radius.x,Radius.y,F,rOut); + if (L.LMuster!=0) { + SetLine(L,rOut); + rOut.SetFillColor(); + rOut.DrawEllipse(aRect); + } + } + } else { + PointType a,b; + Point aStrt,aEnde; + double sn,cs; + + a.x=Center.x+Radius.x; a.y=Center.y; b=a; + sn=sin(double(StartWink)*3.14159265359/18000); + cs=cos(double(StartWink)*3.14159265359/18000); + RotatePoint(a,Center.x,Center.y,sn,cs); + sn=sin(double(StartWink+RelWink)*3.14159265359/18000); + cs=cos(double(StartWink+RelWink)*3.14159265359/18000); + RotatePoint(b,Center.x,Center.y,sn,cs); + if (Radius.x!=Radius.y) { + if (Radius.x<1) Radius.x=1; + if (Radius.y<1) Radius.y=1; + a.y-=Center.y; + b.y-=Center.y; + a.y=iMulDiv(a.y,Radius.y,Radius.x); + b.y=iMulDiv(b.y,Radius.y,Radius.x); + a.y+=Center.y; + b.y+=Center.y; + } + aStrt=Point(a.x,a.y); + aEnde=Point(b.x,b.y); + SetLine(L,rOut); + switch (Flags & 0x03) { + case CircArc : rOut.DrawArc(aRect,aEnde,aStrt); break; + case CircSect: + case CircAbsn: rOut.DrawPie(aRect,aEnde,aStrt); break; + } + } +} + +/************************************************************************* +|* +|* BmapType::Draw() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ + +void BmapType::SetPaths(const INetURLObject rFltPath, const INetURLObject rCfgPath) +{ + aFltPath = rFltPath; + aCfgPath = rCfgPath; +} + +void BmapType::Draw(OutputDevice& rOut) +{ + //ifstream aInp; + unsigned char nSgfTyp; + USHORT nVersion; + String aStr( Filename[ 1 ], (xub_StrLen)Filename[ 0 ], RTL_TEXTENCODING_UTF8 ); + INetURLObject aFNam; + aFNam.SetSmartURL( aStr ); + BOOL Ok = ImplDirEntryHelper::Exists( aFNam ); + if (!Ok) + { + aStr = aFNam.GetName(); // Path weg, nur nach Namen suchen + aFNam.SetSmartURL( aStr ); + Ok = ImplDirEntryHelper::Exists( aFNam ); + } + SvFileStream aInp( aFNam.PathToFileName(), STREAM_READ ); + if (Ok) + Ok=aInp.GetError() ? FALSE : TRUE; + if (Ok) { + nSgfTyp=CheckSgfTyp(aInp,nVersion); + switch(nSgfTyp) { + case SGF_BITIMAGE: { + GraphicFilter aFlt; + Graphic aGrf; + USHORT nRet; + aFlt.SetFilterPath(aFltPath); + aFlt.SetConfigPath(aCfgPath); + nRet=aFlt.ImportGraphic(aGrf,aFNam); + aGrf.Draw(&rOut,Point(Pos1.x,Pos1.y),Size(Pos2.x-Pos1.x,Pos2.y-Pos1.y)); + } break; + case SGF_SIMPVECT: { + GDIMetaFile aMtf; + SgfVectXofs=Pos1.x; + SgfVectYofs=Pos1.y; + SgfVectXmul=Pos2.x-Pos1.x; + SgfVectYmul=Pos2.y-Pos1.y; + SgfVectXdiv=0; + SgfVectYdiv=0; + SgfVectScal=TRUE; + Ok=SgfVectFilter(aInp,aMtf); + SgfVectXofs=0; + SgfVectYofs=0; + SgfVectXmul=0; + SgfVectYmul=0; + SgfVectXdiv=0; + SgfVectYdiv=0; + SgfVectScal=FALSE; + aMtf.Play(&rOut); + } break; + } + } +} + + +/************************************************************************* +|* +|* GrupType::... +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +UINT32 GrupType::GetSubPtr() +{ + return UINT32(SbLo)+0x00010000*UINT32(SbHi); +} + +/************************************************************************* +|* +|* DrawObjkList() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +void DrawObjkList(SvStream& rInp, OutputDevice& rOut, const INetURLObject& rFltPath, const INetURLObject& rCfgPath) +{ + ObjkType aObjk; + USHORT nGrpCnt=0; + BOOL bEnde=FALSE; + do { + rInp>>aObjk; + if (!rInp.GetError()) { + switch(aObjk.Art) { + case ObjStrk: { StrkType aStrk; rInp>>aStrk; if (!rInp.GetError()) aStrk.Draw(rOut); } break; + case ObjRect: { RectType aRect; rInp>>aRect; if (!rInp.GetError()) aRect.Draw(rOut); } break; + case ObjCirc: { CircType aCirc; rInp>>aCirc; if (!rInp.GetError()) aCirc.Draw(rOut); } break; + case ObjText: { + TextType aText; + rInp>>aText; + if (!rInp.GetError()) { + aText.Buffer=new UCHAR[aText.BufSize+1]; // Ein mehr für LookAhead bei CK-Trennung + rInp.Read((char* )aText.Buffer,aText.BufSize); + if (!rInp.GetError()) aText.Draw(rOut); + delete aText.Buffer; + } + } break; + case ObjBmap: { + BmapType aBmap; + rInp>>aBmap; + if (!rInp.GetError()) { + aBmap.SetPaths( rFltPath, rCfgPath ); + aBmap.Draw(rOut); + } + } break; + case ObjPoly: { + PolyType aPoly; + rInp>>aPoly; + if (!rInp.GetError()) { + aPoly.EckP=new PointType[aPoly.nPoints]; + rInp.Read((char*)aPoly.EckP,4*aPoly.nPoints); +#if defined __BIGENDIAN + for(short i=0;i<aPoly.nPoints;i++) SWAPPOINT(aPoly.EckP[i]); +#endif + if (!rInp.GetError()) aPoly.Draw(rOut); + delete aPoly.EckP; + } + } break; + case ObjSpln: { + SplnType aSpln; + rInp>>aSpln; + if (!rInp.GetError()) { + aSpln.EckP=new PointType[aSpln.nPoints]; + rInp.Read((char*)aSpln.EckP,4*aSpln.nPoints); +#if defined __BIGENDIAN + for(short i=0;i<aSpln.nPoints;i++) SWAPPOINT(aSpln.EckP[i]); +#endif + if (!rInp.GetError()) aSpln.Draw(rOut); + delete aSpln.EckP; + } + } break; + case ObjGrup: { + GrupType aGrup; + rInp>>aGrup; + if (!rInp.GetError()) { + rInp.Seek(rInp.Tell()+aGrup.Last); // Obj-Anhängsel + if(aGrup.GetSubPtr()!=0L) nGrpCnt++;// DrawObjkList(rInp,rOut,rFltPath,rCfgPath); + } + } break; + default: { + aObjk.Draw(rOut); // Objektbezeichnung auf 2. Screen + ObjkOverSeek(rInp,aObjk); // zum nächsten Objekt + } + } + } // if rInp + if (!rInp.GetError()) { + if (aObjk.Next==0L) { + if (nGrpCnt==0) bEnde=TRUE; + else nGrpCnt--; + } + } else { + bEnde=TRUE; // Lesefehler + } + } while (!bEnde); +} + +/************************************************************************* +|* +|* SkipObjkList() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +void SkipObjkList(SvStream& rInp) +{ + ObjkType aObjk; + do + { + rInp>>aObjk; + if(aObjk.Art==ObjGrup) { + GrupType aGrup; + rInp>>aGrup; + rInp.Seek(rInp.Tell()+aGrup.Last); // Obj-Anhängsel + if(aGrup.GetSubPtr()!=0L) SkipObjkList(rInp); + } else { + ObjkOverSeek(rInp,aObjk); // zum nächsten Objekt + } + } while (aObjk.Next!=0L && !rInp.GetError()); +} + +/************************************************************************* +|* +|* SgfFilterSDrw() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +BOOL SgfFilterSDrw(SvStream& rInp, SgfHeader&, SgfEntry&, GDIMetaFile& rMtf, const INetURLObject& rFltPath, const INetURLObject& rCfgPath) +{ + BOOL bRet = FALSE; + ObjkType aObjk; + PageType aPage; + VirtualDevice aOutDev; + OutputDevice* pOutDev; + ULONG nStdPos; + ULONG nZchPos; + USHORT Num; + + pOutDev=&aOutDev; + DtHdOverSeek(rInp); // DataHeader weglesen + + nStdPos=rInp.Tell(); + do { // Standardseiten weglesen + rInp>>aPage; + if (aPage.nList!=0) SkipObjkList(rInp); + } while (aPage.Next!=0L && !rInp.GetError()); + +// ShowMsg("Zeichnungseite(n)\n"); + nZchPos=rInp.Tell(); + rInp>>aPage; + + rMtf.Record(pOutDev); + Num=aPage.StdPg; + if (Num!=0) { + rInp.Seek(nStdPos); + while(Num>1 && aPage.Next!=0L && !rInp.GetError()) { // Standardseite suchen + rInp>>aPage; + if (aPage.nList!=0) SkipObjkList(rInp); + Num--; + } + rInp>>aPage; + if(Num==1 && aPage.nList!=0L) DrawObjkList(rInp,*pOutDev,rFltPath,rCfgPath); + rInp.Seek(nZchPos); + nZchPos=rInp.Tell(); + rInp>>aPage; + } + if (aPage.nList!=0L) DrawObjkList(rInp,*pOutDev,rFltPath,rCfgPath); + + rMtf.Stop(); + rMtf.WindStart(); + MapMode aMap(MAP_10TH_MM,Point(),Fraction(1,4),Fraction(1,4)); + rMtf.SetPrefMapMode(aMap); + rMtf.SetPrefSize(Size((INT16)aPage.Paper.Size.x,(INT16)aPage.Paper.Size.y)); + bRet=TRUE; + return bRet; +} + + + +/************************************************************************* +|* +|* SgfSDrwFilter() +|* +|* Beschreibung +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +BOOL SgfSDrwFilter(SvStream& rInp, GDIMetaFile& rMtf, INetURLObject aIniPath, const INetURLObject& rFltPath, const INetURLObject& rCfgPath) +{ +#ifdef DEBUG // Recordgrößen checken. Neuer Compiler hat vielleichte anderes Allignment! + if (sizeof(ObjTextType)!=ObjTextTypeSize) return FALSE; +#endif + + ULONG nFileStart; // Offset des SgfHeaders. Im allgemeinen 0. + SgfHeader aHead; + SgfEntry aEntr; + ULONG nNext; + BOOL bRdFlag=FALSE; // Grafikentry gelesen ? + BOOL bRet=FALSE; // Returncode + + aIniPath.Append( String::CreateFromAscii( "sgf.ini", 7 ) ); +// aIniPath.ToAbs(); + + pSgfFonts = new SgfFontLst; + + pSgfFonts->AssignFN( aIniPath.PathToFileName() ); + nFileStart=rInp.Tell(); + rInp>>aHead; + if (aHead.ChkMagic() && aHead.Typ==SgfStarDraw && aHead.Version==SGV_VERSION) { + nNext=aHead.GetOffset(); + while (nNext && !bRdFlag && !rInp.GetError()) { + rInp.Seek(nFileStart+nNext); + rInp>>aEntr; + nNext=aEntr.GetOffset(); + if (aEntr.Typ==aHead.Typ) { + bRet=SgfFilterSDrw(rInp,aHead,aEntr,rMtf,rFltPath,rCfgPath); + } + } // while(nNext) + if (bRdFlag) { + if (!rInp.GetError()) bRet=TRUE; // Scheinbar Ok + } + } + delete pSgfFonts; + return(bRet); +} + +/* +Bitmap Dither(BYTE Intens) +{ + Bitmap aBmp; + BmpInfoHeader Info; + + +const dmatrix: array[0..7,0..7] of byte = + (( 0, 48, 12, 60, 3, 51, 15, 63 ), + ( 32, 16, 44, 28, 35, 19, 47, 31 ), + ( 8, 56, 4, 52, 11, 59, 7, 55 ), + ( 40, 24, 36, 20, 43, 27, 39, 23 ), + ( 2, 50, 14, 62, 1, 49, 13, 61 ), + ( 34, 18, 46, 30, 33, 17, 45, 29 ), + ( 10, 58, 6, 54, 9, 57, 5, 53 ), + ( 42, 26, 38, 22, 41, 25, 37, 21 )); + + + cmatrix: array[0..7,0..7] of byte; + dmatrixn,dmatrixi: array[0..7] of byte; + + +procedure SetColorIntens(col0,col1,bal: integer); +var cmatrix0: array[0..63] of byte absolute cmatrix; + dmatrix0: array[0..63] of byte absolute dmatrix; + n,i: integer; + b,bit: byte; +begin +if col0=col1 then bal:=0; +if bal<=32 then + begin + plotcolor0:=col0 and $1F; plotcolor1:=col1 and $1F; + plotbal:=bal; + end +else + begin + plotcolor0:=col1 and $1F; plotcolor1:=col0 and $1F; + plotbal:=64-bal; + end; +for n:=0 to 63 do + if plotbal<=dmatrix0[n] then cmatrix0[n]:=col0 else cmatrix0[n]:=col1; +end; +*/ + +#if defined( WIN ) && defined( MSC ) +#pragma code_seg( "svtools", "AUTO_CODE" ) +#endif + diff --git a/svtools/source/filter.vcl/filter/sgvspln.cxx b/svtools/source/filter.vcl/filter/sgvspln.cxx new file mode 100644 index 000000000000..1934ca6091cb --- /dev/null +++ b/svtools/source/filter.vcl/filter/sgvspln.cxx @@ -0,0 +1,1115 @@ +/************************************************************************* + * + * $RCSfile: sgvspln.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#ifdef MAC +#include <mac_start.h> +#include <math.h> +#include <mac_end.h> +#else +#include <math.h> +#endif + + +#ifndef _SV_POLY_HXX //autogen +#include <vcl/poly.hxx> +#endif + +#if defined( WIN ) && defined( MSC ) +#pragma code_seg( "SVTOOLS_FILTER2", "SVTOOLS_CODE" ) +#pragma optimize( "", off ) +#endif + +#if defined( PM2 ) && defined( __BORLANDC__ ) +#pragma option -Od +#endif + +extern "C" { + +/*.pn 277 */ +/*.hlAnhang: C - Programme*/ +/*.hrKonstanten- und Macro-Definitionen*/ +/*.fe Die Include-Datei u_const.h ist in das Verzeichnis zu stellen, */ +/*.fe wo der Compiler nach Include-Dateien sucht. */ + + +/*----------------------- FILE u_const.h ---------------------------*/ + +#ifndef S390 +#define IEEE +#endif + +/* IEEE - Norm fuer die Darstellung von Gleitkommazahlen: + + 8 Byte lange Gleitkommazahlen, mit + + 53 Bit Mantisse ==> Mantissenbereich: 2 hoch 52 versch. Zahlen + mit 0.1 <= Zahl < 1.0, + 1 Vorzeichen-Bit + 11 Bit Exponent ==> Exponentenbereich: -1024...+1023 + + Die 1. Zeile ( #define IEEE ) ist zu loeschen, falls die Maschine + bzw. der Compiler keine Gleitpunktzahlen gemaess der IEEE-Norm + benutzt. Zusaetzlich muessen die Zahlen MAXEXPON, MINEXPON + (s.u.) angepasst werden. + */ + +#ifdef IEEE /*----------- Falls IEEE Norm --------------------*/ + +#define MACH_EPS 2.220446049250313e-016 /* Maschinengenauigkeit */ + /* IBM-AT: = 2 hoch -52 */ +/* MACH_EPS ist die kleinste positive, auf der Maschine darstellbare + Zahl x, die der Bedingung genuegt: 1.0 + x > 1.0 */ + +#define EPSQUAD 4.930380657631324e-032 +#define EPSROOT 1.490116119384766e-008 + +#define POSMAX 8.98846567431158e+307 /* groesste positive Zahl */ +#define POSMIN 5.56268464626800e-309 /* kleinste positive Zahl */ +#define MAXROOT 9.48075190810918e+153 + +#define BASIS 2 /* Basis der Zahlendarst. */ +#ifndef PI +#define PI 3.141592653589793e+000 +#endif +#define EXP_1 2.718281828459045e+000 + +#else /*------------------ sonst -----------------------*/ + +#ifndef S390 +double exp (double); +double atan (double); +double pow (double,double); +double sqrt (double); +#endif + +double masch() /* MACH_EPS maschinenunabhaengig bestimmen */ +{ + double eps = 1.0, x = 2.0, y = 1.0; + while ( y < x ) + { eps *= 0.5; + x = 1.0 + eps; + } + eps *= 2.0; return (eps); +} + +short basis() /* BASIS maschinenunabhaengig bestimmen */ +{ + double x = 1.0, one = 1.0, b = 1.0; + + while ( (x + one) - x == one ) x *= 2.0; + while ( (x + b) == x ) b *= 2.0; + + return ( (short) ((x + b) - x) ); +} + +#define BASIS basis() /* Basis der Zahlendarst. */ + +/* Falls die Maschine (der Compiler) keine IEEE-Darstellung fuer + Gleitkommazahlen nutzt, muessen die folgenden 2 Konstanten an- + gepasst werden. + */ + +#ifndef S390 +#define MAXEXPON 1023.0 /* groesster Exponent */ +#define MINEXPON -1024.0 /* kleinster Exponent */ +#else +#include <float.h> +#define MAXEXPON 75.0 +#define MINEXPON -79.0 +#endif + + +#define MACH_EPS masch() +#define EPSQUAD MACH_EPS * MACH_EPS +#define EPSROOT sqrt(MACH_EPS) + +#define POSMAX pow ((double) BASIS, MAXEXPON) +#define POSMIN pow ((double) BASIS, MINEXPON) +#define MAXROOT sqrt(POSMAX) + +#define PI 4.0 * atan (1.0) +#define EXP_1 exp(1.0) + +#endif /*-------------- ENDE ifdef ----------------------*/ + + +#define NEGMAX -POSMIN /* groesste negative Zahl */ +#define NEGMIN -POSMAX /* kleinste negative Zahl */ + +#define TRUE 1 +#define FALSE 0 + + +/* Definition von Funktionsmakros: + */ + +// #define min(X, Y) ((X) < (Y) ? (X) : (Y)) /* Minimum von X,Y */ +// #define max(X, Y) ((X) > (Y) ? (X) : (Y)) /* Maximum von X,Y */ +#define abs(X) ((X) >= 0 ? (X) : -(X)) /* Absolutbetrag von X */ +#define sign(X, Y) (Y < 0 ? -abs(X) : abs(X)) /* Vorzeichen von */ + /* Y mal abs(X) */ +#define sqr(X) ((X) * (X)) /* Quadrat von X */ + +/*------------------- ENDE FILE u_const.h --------------------------*/ + + + + + + + + + +/*.HL Anhang: C - Programme*/ +/*.HRGleichungssysteme fr Tridiagonalmatrizen*/ + +/*.FE P 3.7 TRIDIAGONALE GLEICHUNGSSYSTEME*/ + + +/*---------------------- MODUL TRIDIAGONAL ------------------------*/ + +USHORT TriDiagGS(BOOL rep, USHORT n, double* lower, + double* diag, double* upper, double* b) + /************************/ + /* GAUSS-Verfahren fuer */ + /* Tridiagonalmatrizen */ + /************************/ + +/*====================================================================*/ +/* */ +/* trdiag bestimmt die Loesung x des linearen Gleichungssystems */ +/* A * x = b mit tridiagonaler n x n Koeffizientenmatrix A, die in */ +/* den 3 Vektoren lower, upper und diag wie folgt abgespeichert ist: */ +/* */ +/* ( diag[0] upper[0] 0 0 . . . 0 ) */ +/* ( lower[1] diag[1] upper[1] 0 . . . ) */ +/* ( 0 lower[2] diag[2] upper[2] 0 . ) */ +/* A = ( . 0 lower[3] . . . ) */ +/* ( . . . . . 0 ) */ +/* ( . . . . . ) */ +/* ( . . . upper[n-2] ) */ +/* ( 0 . . . 0 lower[n-1] diag[n-1] ) */ +/* */ +/*====================================================================*/ +/* */ +/* Anwendung: */ +/* ========= */ +/* Vorwiegend fuer diagonaldominante Tridiagonalmatrizen, wie */ +/* sie bei der Spline-Interpolation auftreten. */ +/* Fuer diagonaldominante Matrizen existiert immer eine LU- */ +/* Zerlegung; fuer nicht diagonaldominante Tridiagonalmatrizen */ +/* sollte die Funktion band vorgezogen werden, da diese mit */ +/* Spaltenpivotsuche arbeitet und daher numerisch stabiler ist. */ +/* */ +/*====================================================================*/ +/* */ +/* Eingabeparameter: */ +/* ================ */ +/* n Dimension der Matrix ( > 1 ) USHORT n */ +/* */ +/* lower untere Nebendiagonale double lower[n] */ +/* diag Hauptdiagonale double diag[n] */ +/* upper obere Nebendiagonale double upper[n] */ +/* */ +/* bei rep != 0 enthalten lower, diag und upper die */ +/* Dreieckzerlegung der Ausgangsmatrix. */ +/* */ +/* b rechte Seite des Systems double b[n] */ +/* rep = 0 erstmaliger Aufruf BOOL rep */ +/* !=0 wiederholter Aufruf */ +/* fuer gleiche Matrix, */ +/* aber verschiedenes b. */ +/* */ +/* Ausgabeparameter: */ +/* ================ */ +/* b Loesungsvektor des Systems; double b[n] */ +/* die urspruengliche rechte Seite wird ueberspeichert */ +/* */ +/* lower ) enthalten bei rep = 0 die Zerlegung der Matrix; */ +/* diag ) die urspruenglichen Werte von lower u. diag werden */ +/* upper ) ueberschrieben */ +/* */ +/* Die Determinante der Matrix ist bei rep = 0 durch */ +/* det A = diag[0] * ... * diag[n-1] bestimmt. */ +/* */ +/* Rueckgabewert: */ +/* ============= */ +/* = 0 alles ok */ +/* = 1 n < 2 gewaehlt */ +/* = 2 Die Dreieckzerlegung der Matrix existiert nicht */ +/* */ +/*====================================================================*/ +/* */ +/* Benutzte Funktionen: */ +/* =================== */ +/* */ +/* Aus der C Bibliothek: fabs() */ +/* */ +/*====================================================================*/ + +/*.cp 5 */ +{ + USHORT i; + short j; + +// double fabs(double); + + if ( n < 2 ) return(1); /* n mindestens 2 */ + + /* Wenn rep = 0 ist, */ + /* Dreieckzerlegung der */ + if (rep == 0) /* Matrix u. det be- */ + { /* stimmen */ + for (i = 1; i < n; i++) + { if ( fabs(diag[i-1]) < MACH_EPS ) /* Wenn ein diag[i] = 0 */ + return(2); /* ist, ex. keine Zerle- */ + lower[i] /= diag[i-1]; /* gung. */ + diag[i] -= lower[i] * upper[i-1]; + } + } + + if ( fabs(diag[n-1]) < MACH_EPS ) return(2); + + for (i = 1; i < n; i++) /* Vorwaertselimination */ + b[i] -= lower[i] * b[i-1]; + + b[n-1] /= diag[n-1]; /* Rueckwaertselimination */ + for (j = n-2; j >= 0; j--) { + i=j; + b[i] = ( b[i] - upper[i] * b[i+1] ) / diag[i]; + } + return(0); +} + +/*----------------------- ENDE TRIDIAGONAL -------------------------*/ + + + + + + + + + +/*.HL Anhang: C - Programme*/ +/*.HRGleichungssysteme mit zyklisch tridiagonalen Matrizen*/ + +/*.FE P 3.8 SYSTEME MIT ZYKLISCHEN TRIDIAGONALMATRIZEN */ + + +/*---------------- MODUL ZYKLISCH TRIDIAGONAL ----------------------*/ + + +USHORT ZyklTriDiagGS(BOOL rep, USHORT n, double* lower, double* diag, + double* upper, double* lowrow, double* ricol, double* b) + /******************************/ + /* Systeme mit zyklisch tri- */ + /* diagonalen Matrizen */ + /******************************/ + +/*====================================================================*/ +/* */ +/* tzdiag bestimmt die Loesung x des linearen Gleichungssystems */ +/* A * x = b mit zyklisch tridiagonaler n x n Koeffizienten- */ +/* matrix A, die in den 5 Vektoren lower, upper, diag, lowrow und */ +/* ricol wie folgt abgespeichert ist: */ +/* */ +/* ( diag[0] upper[0] 0 0 . . 0 ricol[0] ) */ +/* ( lower[1] diag[1] upper[1] 0 . . 0 ) */ +/* ( 0 lower[2] diag[2] upper[2] 0 . ) */ +/* A = ( . 0 lower[3] . . . . ) */ +/* ( . . . . . 0 ) */ +/* ( . . . . . ) */ +/* ( 0 . . . upper[n-2] ) */ +/* ( lowrow[0] 0 . . 0 lower[n-1] diag[n-1] ) */ +/* */ +/* Speicherplatz fuer lowrow[1],..,lowrow[n-3] und ricol[1],..., */ +/* ricol[n-3] muss zusaetzlich bereitgestellt werden, da dieser */ +/* fuer die Aufnahme der Zerlegungsmatrix verfuegbar sein muss, die */ +/* auf die 5 genannten Vektoren ueberspeichert wird. */ +/* */ +/*====================================================================*/ +/* */ +/* Anwendung: */ +/* ========= */ +/* Vorwiegend fuer diagonaldominante zyklische Tridiagonalmatri- */ +/* zen wie sie bei der Spline-Interpolation auftreten. */ +/* Fuer diagonaldominante Matrizen existiert immer eine LU- */ +/* Zerlegung. */ +/* */ +/*====================================================================*/ +/* */ +/* Eingabeparameter: */ +/* ================ */ +/* n Dimension der Matrix ( > 2 ) USHORT n */ +/* lower untere Nebendiagonale double lower[n] */ +/* diag Hauptdiagonale double diag[n] */ +/* upper obere Nebendiagonale double upper[n] */ +/* b rechte Seite des Systems double b[n] */ +/* rep = 0 erstmaliger Aufruf BOOL rep */ +/* !=0 wiederholter Aufruf */ +/* fuer gleiche Matrix, */ +/* aber verschiedenes b. */ +/* */ +/* Ausgabeparameter: */ +/* ================ */ +/* b Loesungsvektor des Systems, double b[n] */ +/* die urspruengliche rechte Seite wird ueberspeichert */ +/* */ +/* lower ) enthalten bei rep = 0 die Zerlegung der Matrix; */ +/* diag ) die urspruenglichen Werte von lower u. diag werden */ +/* upper ) ueberschrieben */ +/* lowrow ) double lowrow[n-2] */ +/* ricol ) double ricol[n-2] */ +/* */ +/* Die Determinante der Matrix ist bei rep = 0 durch */ +/* det A = diag[0] * ... * diag[n-1] bestimmt. */ +/* */ +/* Rueckgabewert: */ +/* ============= */ +/* = 0 alles ok */ +/* = 1 n < 3 gewaehlt */ +/* = 2 Die Zerlegungsmatrix existiert nicht */ +/* */ +/*====================================================================*/ +/* */ +/* Benutzte Funktionen: */ +/* =================== */ +/* */ +/* Aus der C Bibliothek: fabs() */ +/* */ +/*====================================================================*/ + +/*.cp 5 */ +{ + double temp; // fabs(double); + USHORT i; + short j; + + if ( n < 3 ) return(1); + + if (rep == 0) /* Wenn rep = 0 ist, */ + { /* Zerlegung der */ + lower[0] = upper[n-1] = 0.0; /* Matrix berechnen. */ + + if ( fabs (diag[0]) < MACH_EPS ) return(2); + /* Ist ein Diagonalelement */ + temp = 1.0 / diag[0]; /* betragsmaessig kleiner */ + upper[0] *= temp; /* MACH_EPS, so ex. keine */ + ricol[0] *= temp; /* Zerlegung. */ + + for (i = 1; i < n-2; i++) + { diag[i] -= lower[i] * upper[i-1]; + if ( fabs(diag[i]) < MACH_EPS ) return(2); + temp = 1.0 / diag[i]; + upper[i] *= temp; + ricol[i] = -lower[i] * ricol[i-1] * temp; + } + + diag[n-2] -= lower[n-2] * upper[n-3]; + if ( fabs(diag[n-2]) < MACH_EPS ) return(2); + + for (i = 1; i < n-2; i++) + lowrow[i] = -lowrow[i-1] * upper[i-1]; + + lower[n-1] -= lowrow[n-3] * upper[n-3]; + upper[n-2] = ( upper[n-2] - lower[n-2] * ricol[n-3] ) / diag[n-2]; + + for (temp = 0.0, i = 0; i < n-2; i++) + temp -= lowrow[i] * ricol[i]; + diag[n-1] += temp - lower[n-1] * upper[n-2]; + + if ( fabs(diag[n-1]) < MACH_EPS ) return(2); + } /* end if ( rep == 0 ) */ + + b[0] /= diag[0]; /* Vorwaertselemination */ + for (i = 1; i < n-1; i++) + b[i] = ( b[i] - b[i-1] * lower[i] ) / diag[i]; + + for (temp = 0.0, i = 0; i < n-2; i++) + temp -= lowrow[i] * b[i]; + + b[n-1] = ( b[n-1] + temp - lower[n-1] * b[n-2] ) / diag[n-1]; + + b[n-2] -= b[n-1] * upper[n-2]; /* Rueckwaertselimination */ + for (j = n-3; j >= 0; j--) { + i=j; + b[i] -= upper[i] * b[i+1] + ricol[i] * b[n-1]; + } + return(0); +} + +/*------------------ ENDE ZYKLISCH TRIDIAGONAL ---------------------*/ + + +} // extern "C" + + +/************************************************************************* +|* +|* NaturalSpline() +|* +|* Beschreibung Berechnet die Koeffizienten eines natrlichen +|* kubischen Polynomsplines mit n Sttzstellen. +|* Ersterstellung JOE 17-08.93 +|* Letzte Aenderung JOE 17-08.93 +|* +*************************************************************************/ + +USHORT NaturalSpline(USHORT n, double* x, double* y, + double Marg0, double MargN, + BYTE MargCond, + double* b, double* c, double* d) +{ + USHORT i; + double* a; + double* h; + USHORT error; + + if (n<2) return 1; + if (MargCond<0 || MargCond>3) return 2; + a=new double[n+1]; + h=new double[n+1]; + for (i=0;i<n;i++) { + h[i]=x[i+1]-x[i]; + if (h[i]<=0.0) { delete a; delete h; return 1; } + } + for (i=0;i<n-1;i++) { + a[i]=3.0*((y[i+2]-y[i+1])/h[i+1]-(y[i+1]-y[i])/h[i]); + b[i]=h[i]; + c[i]=h[i+1]; + d[i]=2.0*(h[i]+h[i+1]); + } + switch (MargCond) { + case 0: { + if (n==2) { + a[0]=a[0]/3.0; + d[0]=d[0]*0.5; + } else { + a[0] =a[0]*h[1]/(h[0]+h[1]); + a[n-2]=a[n-2]*h[n-2]/(h[n-1]+h[n-2]); + d[0] =d[0]-h[0]; + d[n-2]=d[n-2]-h[n-1]; + c[0] =c[0]-h[0]; + b[n-2]=b[n-2]-h[n-1]; + } + } + case 1: { + a[0] =a[0]-1.5*((y[1]-y[0])/h[0]-Marg0); + a[n-2]=a[n-2]-1.5*(MargN-(y[n]-y[n-1])/h[n-1]); + d[0] =d[0]-h[0]*0.5; + d[n-2]=d[n-2]-h[n-1]*0.5; + } + case 2: { + a[0] =a[0]-h[0]*Marg0*0.5; + a[n-2]=a[n-2]-h[n-1]*MargN*0.5; + } + case 3: { + a[0] =a[0]+Marg0*h[0]*h[0]*0.5; + a[n-2]=a[n-2]-MargN*h[n-1]*h[n-1]*0.5; + d[0] =d[0]+h[0]; + d[n-2]=d[n-2]+h[n-1]; + } + } // switch MargCond + if (n==2) { + c[1]=a[0]/d[0]; + } else { + error=TriDiagGS(FALSE,n-1,b,d,c,a); + if (error!=0) { delete a; delete h; return error+2; } + for (i=0;i<n-1;i++) c[i+1]=a[i]; + } + switch (MargCond) { + case 0: { + if (n==2) { + c[2]=c[1]; + c[0]=c[1]; + } else { + c[0]=c[1]+h[0]*(c[1]-c[2])/h[1]; + c[n]=c[n-1]+h[n-1]*(c[n-1]-c[n-2])/h[n-2]; + } + } + case 1: { + c[0]=1.5*((y[1]-y[0])/h[0]-Marg0); + c[0]=(c[0]-c[1]*h[0]*0.5)/h[0]; + c[n]=1.5*((y[n]-y[n-1])/h[n-1]-MargN); + c[n]=(c[n]-c[n-1]*h[n-1]*0.5)/h[n-1]; + } + case 2: { + c[0]=Marg0*0.5; + c[n]=MargN*0.5; + } + case 3: { + c[0]=c[1]-Marg0*h[0]*0.5; + c[n]=c[n-1]+MargN*h[n-1]*0.5; + } + } // switch MargCond + for (i=0;i<n;i++) { + b[i]=(y[i+1]-y[i])/h[i]-h[i]*(c[i+1]+2.0*c[i])/3.0; + d[i]=(c[i+1]-c[i])/(3.0*h[i]); + } + delete a; + delete h; + return 0; +} + + +/************************************************************************* +|* +|* PeriodicSpline() +|* +|* Beschreibung Berechnet die Koeffizienten eines periodischen +|* kubischen Polynomsplines mit n Sttzstellen. +|* Ersterstellung JOE 17-08.93 +|* Letzte Aenderung JOE 17-08.93 +|* +*************************************************************************/ + + +USHORT PeriodicSpline(USHORT n, double* x, double* y, + double* b, double* c, double* d) +{ // Arrays mssen von [0..n] dimensioniert sein! + USHORT Error; + USHORT i,im1,nm1; //integer + double hr,hl; + double* a; + double* lowrow; + double* ricol; + + if (n<2) return 4; + nm1=n-1; + for (i=0;i<=nm1;i++) if (x[i+1]<=x[i]) return 2; // muá streng nonoton fallend sein! + if (y[n]!=y[0]) return 3; // Anfang muá gleich Ende sein! + + a =new double[n+1]; + lowrow=new double[n+1]; + ricol =new double[n+1]; + + if (n==2) { + c[1]=3.0*((y[2]-y[1])/(x[2]-x[1])); + c[1]=c[1]-3.0*((y[i]-y[0])/(x[1]-x[0])); + c[1]=c[1]/(x[2]-x[0]); + c[2]=-c[1]; + } else { + for (i=1;i<=nm1;i++) { + im1=i-1; + hl=x[i]-x[im1]; + hr=x[i+1]-x[i]; + b[im1]=hl; + d[im1]=2.0*(hl+hr); + c[im1]=hr; + a[im1]=3.0*((y[i+1]-y[i])/hr-(y[i]-y[im1])/hl); + } + hl=x[n]-x[nm1]; + hr=x[1]-x[0]; + b[nm1]=hl; + d[nm1]=2.0*(hl+hr); + lowrow[0]=hr; + ricol[0]=hr; + a[nm1]=3.0*((y[1]-y[0])/hr-(y[n]-y[nm1])/hl); + Error=ZyklTriDiagGS(FALSE,n,b,d,c,lowrow,ricol,a); + if (Error!=0) { delete a,lowrow,ricol; return(Error+4); } + for (i=0;i<=nm1;i++) c[i+1]=a[i]; + } + c[0]=c[n]; + for (i=0;i<=nm1;i++) { + hl=x[i+1]-x[i]; + b[i]=(y[i+1]-y[i])/hl; + b[i]=b[i]-hl*(c[i+1]+2.0*c[i])/3.0; + d[i]=(c[i+1]-c[i])/hl/3.0; + } + delete a,lowrow,ricol; + return 0; +} + + + +/************************************************************************* +|* +|* ParaSpline() +|* +|* Beschreibung Berechnet die Koeffizienten eines parametrischen +|* natrlichen oder periodischen kubischen +|* Polynomsplines mit n Sttzstellen. +|* Ersterstellung JOE 17-08.93 +|* Letzte Aenderung JOE 17-08.93 +|* +*************************************************************************/ + +USHORT ParaSpline(USHORT n, double* x, double* y, BYTE MargCond, + double Marg01, double Marg02, + double MargN1, double MargN2, + BOOL CondT, double* T, + double* bx, double* cx, double* dx, + double* by, double* cy, double* dy) +{ + USHORT Error,Marg; + USHORT i; + double deltX,deltY,delt, + alphX,alphY, + betX,betY; + + if (n<2) return 1; + if (MargCond<0 || MargCond>4) return 2; // ungltige Randbedingung + if (CondT==FALSE) { + T[0]=0.0; + for (i=0;i<n;i++) { + deltX=x[i+1]-x[i]; deltY=y[i+1]-y[i]; + delt =deltX*deltX+deltY*deltY; + if (delt<=0.0) return 3; // zwei identische Punkte nacheinander! + T[i+1]=T[i]+sqrt(delt); + } + } + switch (MargCond) { + case 0: Marg=0; break; + case 1: case 2: { + Marg=MargCond; + alphX=Marg01; betX=MargN1; + alphY=Marg02; betY=MargN2; + } break; + case 3: { + if (x[n]!=x[0]) return 3; + if (y[n]!=y[0]) return 4; + } break; + case 4: { + Marg=1; + if (abs(Marg01)>=MAXROOT) { + alphX=0.0; + alphY=sign(1.0,y[1]-y[0]); + } else { + alphX=sign(sqrt(1.0/(1.0+Marg01*Marg01)),x[1]-x[0]); + alphY=alphX*Marg01; + } + if (abs(MargN1)>=MAXROOT) { + betX=0.0; + betY=sign(1.0,y[n]-y[n-1]); + } else { + betX=sign(sqrt(1.0/(1.0+MargN1*MargN1)),x[n]-x[n-1]); + betY=betX*MargN1; + } + } + } // switch MargCond + if (MargCond==3) { + Error=PeriodicSpline(n,T,x,bx,cx,dx); + if (Error!=0) return(Error+4); + Error=PeriodicSpline(n,T,y,by,cy,dy); + if (Error!=0) return(Error+10); + } else { + Error=NaturalSpline(n,T,x,alphX,betX,MargCond,bx,cx,dx); + if (Error!=0) return(Error+4); + Error=NaturalSpline(n,T,y,alphY,betY,MargCond,by,cy,dy); + if (Error!=0) return(Error+9); + } + return 0; +} + + + +/************************************************************************* +|* +|* CalcSpline() +|* +|* Beschreibung Berechnet die Koeffizienten eines parametrischen +|* natrlichen oder periodischen kubischen +|* Polynomsplines. Die Eckpunkte des šbergebenen +|* Polygons werden als Sttzstellen angenommen. +|* n liefert die Anzahl der Teilpolynome. +|* Ist die Berechnung fehlerfrei verlaufen, so +|* liefert die Funktion TRUE. Nur in diesem Fall +|* ist Speicher fr die Koeffizientenarrays +|* allokiert, der dann sp„ter vom Aufrufer mittels +|* delete freizugeben ist. +|* Ersterstellung JOE 17-08.93 +|* Letzte Aenderung JOE 17-08.93 +|* +*************************************************************************/ + +BOOL CalcSpline(Polygon& rPoly, BOOL Periodic, USHORT& n, + double*& ax, double*& ay, double*& bx, double*& by, + double*& cx, double*& cy, double*& dx, double*& dy, double*& T) +{ + BYTE Marg; + double Marg01,Marg02; + double MargN1,MargN2; + USHORT i; + Point P0(-32768,-32768); + Point Pt; + + n=rPoly.GetSize(); + ax=new double[rPoly.GetSize()+2]; + ay=new double[rPoly.GetSize()+2]; + + n=0; + for (i=0;i<rPoly.GetSize();i++) { + Pt=rPoly.GetPoint(i); + if (i==0 || Pt!=P0) { + ax[n]=Pt.X(); + ay[n]=Pt.Y(); + n++; + P0=Pt; + } + } + + if (Periodic) { + Marg=3; + ax[n]=ax[0]; + ay[n]=ay[0]; + n++; + } else { + Marg=2; + } + + bx=new double[n+1]; + by=new double[n+1]; + cx=new double[n+1]; + cy=new double[n+1]; + dx=new double[n+1]; + dy=new double[n+1]; + T =new double[n+1]; + + Marg01=0.0; Marg02=0.0; + MargN1=0.0; MargN2=0.0; + if (n>0) n--; // n Korregieren (Anzahl der Teilpolynome) + + if ((Marg==3 && n>=3) || (Marg==2 && n>=2)) { + i=ParaSpline(n,ax,ay,Marg,Marg01,Marg01,MargN1,MargN2,FALSE,T,bx,cx,dx,by,cy,dy); + if (i==0) { + return TRUE; + } else { + delete ax,ay,bx,by,cx,cy,dx,dy,T; + n=0; + return FALSE; + } + } else { + delete ax,ay,bx,by,cx,cy,dx,dy,T; + n=0; + return FALSE; + } +} + + +/************************************************************************* +|* +|* Spline2Poly() +|* +|* Beschreibung Konvertiert einen parametrichen kubischen +|* Polynomspline Spline (natrlich oder periodisch) +|* in ein angen„hertes Polygon. +|* Die Funktion liefert FALSE, wenn ein Fehler bei +|* der Koeffizientenberechnung aufgetreten ist oder +|* das Polygon zu groá wird (>PolyMax=16380). Im 1. +|* Fall hat das Polygon 0, im 2. Fall PolyMax Punkte. +|* Um Koordinatenberl„ufe zu vermeiden werden diese +|* auf +/-32000 begrenzt. +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +BOOL Spline2Poly(Polygon& rSpln, BOOL Periodic, Polygon& rPoly) +{ + short MinKoord=-32000; // zur Vermeidung + short MaxKoord=32000; // von šberl„ufen + + double* ax; // ¿ + double* ay; // ³ Koeffizienten + double* bx; // ³ der Polynome + double* by; // ³ + double* cx; // ³ + double* cy; // ³ + double* dx; // ³ + double* dy; // ³ + double* tv; // Ù + + double Step; // Schrittweite fr t + double dt1,dt2,dt3; // Delta t, ý, ^3 + double t; + BOOL bEnde; // Teilpolynom zu Ende? + USHORT n; // Anzahl der zu zeichnenden Teilpolynome + USHORT i; // aktuelles Teilpolynom + BOOL bOk; // noch alles ok? + USHORT PolyMax=16380;// Maximale Anzahl von Polygonpunkten + long x,y; + + bOk=CalcSpline(rSpln,Periodic,n,ax,ay,bx,by,cx,cy,dx,dy,tv); + if (bOk) { + Step =10; + + rPoly.SetSize(1); + rPoly.SetPoint(Point(short(ax[0]),short(ay[0])),0); // erster Punkt + i=0; + while (i<n) { // n Teilpolynome malen + t=tv[i]+Step; + bEnde=FALSE; + while (!bEnde) { // ein Teilpolynom interpolieren + bEnde=t>=tv[i+1]; + if (bEnde) t=tv[i+1]; + dt1=t-tv[i]; dt2=dt1*dt1; dt3=dt2*dt1; + x=long(ax[i]+bx[i]*dt1+cx[i]*dt2+dx[i]*dt3); + y=long(ay[i]+by[i]*dt1+cy[i]*dt2+dy[i]*dt3); + if (x<MinKoord) x=MinKoord; if (x>MaxKoord) x=MaxKoord; + if (y<MinKoord) y=MinKoord; if (y>MaxKoord) y=MaxKoord; + if (rPoly.GetSize()<PolyMax) { + rPoly.SetSize(rPoly.GetSize()+1); + rPoly.SetPoint(Point(short(x),short(y)),rPoly.GetSize()-1); + } else { + bOk=FALSE; // Fehler: Polygon wird zu groá + } + t=t+Step; + } // Ende von Teilpolynom + i++; // n„chstes Teilpolynom + } + delete ax,ay,bx,by,cx,cy,dx,dy,tv; + return bOk; + } // Ende von if (bOk) + rPoly.SetSize(0); + return FALSE; +} + + + + + + + + + +/************************************************************************* +|* +|* CalcLine() +|* +|* Beschreibung Routine fr DrawSpline (s.u.). +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +/*void CalcLine(short x1, short y1, + short x2, short y2, + short hb, Polygon& rPoly) +{ + short dx,dy,dxp,dyp; + double l; + + rPoly.SetSize(4); + dx=x2-x1; + dy=y2-y1; + l=sqrt(dx*dx+dy*dy); + if (l>0) { + dxp=short((long(dy)*long(hb))/l); + dyp=short((long(dx)*long(hb))/l); + rPoly.SetPoint(Point(x1-dxp,y1+dyp),0); + rPoly.SetPoint(Point(x1+dxp,y1-dyp),1); + rPoly.SetPoint(Point(x2+dxp,y2-dyp),2); + rPoly.SetPoint(Point(x2-dxp,y2+dyp),3); + } else { + rPoly.SetPoint(Point(x1,y1+hb),0); + rPoly.SetPoint(Point(x1,y1-hb),1); + rPoly.SetPoint(Point(x2,y2-hb),2); + rPoly.SetPoint(Point(x2,y2+hb),3); + } +} */ + + +/************************************************************************* +|* +|* DrawSpline() +|* +|* Beschreibung Alte Routine. Dicke Linien werden mit Polys gemalt. +|* Ersterstellung JOE 23.06.93 +|* Letzte Aenderung JOE 23.06.93 +|* +*************************************************************************/ +/* +BOOL DrawSpline(OutputDevice& rOut, Polygon& rPoly, BOOL Periodic) +{ + short MinKoord=-12000; // StarDraw-Definitionen + short MaxKoord=32000; // zur Vermeidung von šberl„ufen + + double* ax; // ¿ + double* ay; // ³ Koeffizienten + double* bx; // ³ der Polynome + double* by; // ³ + double* cx; // ³ + double* cy; // ³ + double* dx; // ³ + double* dy; // ³ + double* tv; // Ù + + double Step; // Schrittweite fr t + double dt1,dt2,dt3; // Delta t, ý, ^3 + double t; + BOOL bEnde; // Teilpolynom zu Ende? + USHORT FHB; // Halbe Linienbreite in SGV + Point P10,P20; // letzter Punkt (Screen) fr Anschluá + Point P100,P200; // erster Punkt (Screen) zum Schlieáen des pSpline + BOOL bFirst; // erster Schrit des ersten Teilpolynoms? + BOOL bThin; // Strichst„rke 1 Pixel? + Polygon aFP(0); // fr gefllten Spline + Polygon aLP(4); // fr dicke Umrandung + BOOL bFill; // gefllter Spline? + BOOL bOutl; // umrandeter Spline? + USHORT n; // Anzahl der zu zeichnenden Teilpolynome + USHORT i; // aktuelles Teilpolynom + BOOL bOk; // noch alles ok? + USHORT StatA,StatB; + USHORT PolyMax=16384;// Maximale Anzahl von Polygonpunkten + Pen aPenMerk; + Brush aBrushMerk; + short x0,y0; + long x,y; + + bOk=CalcSpline(rPoly,Periodic,n,ax,ay,bx,by,cx,cy,dx,dy,tv); + if (bOk) { + aPenMerk=rOut.GetPen(); + aBrushMerk=rOut.GetFillInBrush(); + bFill=rOut.GetFillInBrush().GetStyle()!=BRUSH_NULL && Periodic; + bOutl=rOut.GetPen().GetStyle()!=PEN_NULL; + FHB =rOut.GetPen().GetWidth() /2; + bThin=rOut.GetPen().GetWidth()<=1; + Step =10; + + StatA=1; if (!bFill) StatA++; + StatB=2; if (!bOutl) StatB--; + + while (StatA<=StatB) { + if (StatA==1) { + rOut.SetFillInBrush(aBrushMerk); + rOut.SetPen(Pen(PEN_NULL)); + } else { + if (!bThin) { + rOut.SetFillInBrush(Brush(rOut.GetPen().GetColor())); + rOut.SetPen(Pen(PEN_NULL)); + } else { + rOut.SetPen(aPenMerk); + } + } + bFirst=TRUE; + + x0=short(ax[0]); y0=short(ay[0]); // erster Punkt + i=0; + while (i<n) { // n Teilpolynome malen + t=tv[i]+Step; + bEnde=FALSE; + while (!bEnde) { // ein Teilpolynom interpolieren + bEnde=t>=tv[i+1]; + if (bEnde) t=tv[i+1]; + dt1=t-tv[i]; dt2=dt1*dt1; dt3=dt2*dt1; + x=long(ax[i]+bx[i]*dt1+cx[i]*dt2+dx[i]*dt3); + y=long(ay[i]+by[i]*dt1+cy[i]*dt2+dy[i]*dt3); + if (x-FHB<MinKoord) x=MinKoord+FHB; if (x+FHB>MaxKoord) x=MaxKoord-FHB; + if (y-FHB<MinKoord) y=MinKoord+FHB; if (y+FHB>MaxKoord) y=MaxKoord-FHB; + if (StatA==1) { // Fl„che + if (aFP.GetSize()<PolyMax) { + aFP.SetSize(aFP.GetSize()+1); + aFP.SetPoint(Point(short(x),short(y)),aFP.GetSize()-1); + } else { + bOk=FALSE; // Fehler: Polygon wird zu groá + } + } else { // Umrandung + if (bThin) { + rOut.DrawLine(Point(x0,y0),Point(short(x),short(y))); + } else { + CalcLine(x0,y0,short(x),short(y),FHB,aLP); + rOut.DrawPolygon(aLP); + if (bFirst) { + P100=aLP.GetPoint(0); // fr pSpline merken + P200=aLP.GetPoint(1); + } else { + Polygon aMP(4); + aMP.SetPoint(P10,0); + aMP.SetPoint(P20,1); + aMP.SetPoint(aLP.GetPoint(1),2); + aMP.SetPoint(aLP.GetPoint(0),3); + rOut.DrawPolygon(aMP); + } + P10=aLP.GetPoint(3); // zum Fllen der M„useecken merken + P20=aLP.GetPoint(2); + } // Ende von Umrandung + } // Ende von if (StatA==1) + x0=short(x); y0=short(y); // die letzten Koordinaten merken + bFirst=FALSE; + t=t+Step; + } // Ende von Teilpolynom + i++; // n„chstes Teilpolynom + } + if (StatA==1) { + rOut.DrawPolygon(aFP); + } else { + if (!bThin && Periodic) { // nun die letzte M„useecke fllen + Polygon aMP(4); + aMP.SetPoint(aLP[3],1); + aMP.SetPoint(aLP[4],2); + aMP.SetPoint(P100,3); + aMP.SetPoint(P200,4); + rOut.DrawPolygon(aMP); + } + } + StatA++; + } // Ende von while (StatA<=StatB) + rOut.SetPen(aPenMerk); + rOut.SetFillInBrush(aBrushMerk); + delete ax,ay,bx,by,cx,cy,dx,dy,tv; + return TRUE; + } // Ende von if (bOk) + return FALSE; +} */ + + + + diff --git a/svtools/source/filter.vcl/filter/sgvtext.cxx b/svtools/source/filter.vcl/filter/sgvtext.cxx new file mode 100644 index 000000000000..67302778a8bc --- /dev/null +++ b/svtools/source/filter.vcl/filter/sgvtext.cxx @@ -0,0 +1,1370 @@ +/************************************************************************* + * + * $RCSfile: sgvtext.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#ifdef MAC +#include <mac_start.h> +#include <math.h> +#include <mac_end.h> +#else +#include <math.h> +#endif + +#include <vcl/config.hxx> +#include <filter.hxx> +#include "sgffilt.hxx" +#include "sgfbram.hxx" +#include "sgvmain.hxx" +// #include "Debug.c" + +extern SgfFontLst* pSgfFonts; + +#if defined( WIN ) && defined( MSC ) +#pragma code_seg( "SVTOOLS_FILTER1", "SVTOOLS_CODE" ) +#endif + +#ifndef abs +#define abs(x) ((x)<0 ? -(x) : (x)) +#endif + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Einschränkungen: Schatten nur grau, 2D und mit fixem Abstand. +// +// +// +// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +// AbsBase.Pas + +// die folgenden Werte sind in % vom maximalen Schriftgrad der Zeile */ +#define UndlSpace 5 /* Untersteichungsabstand von der Baseline */ +#define UndlWidth 6 /* Untersteichungsdicke */ +#define UndlSpac2 7 /* Zwischenraum bei doppelter Unterstreichung */ +#define StrkSpace 25 /* Abstand der Durchstreichlinie von der Baseline*/ +#define StrkWidth 5 /* Durchstreichungsliniendicke */ +#define StrkSpac2 7 /* Zwischenraum bei doppelter Durchstreichung */ +#define OutlWidth 2 /* Strichstärke ist 2% vom Schriftgrad */ + +// vvv Sonderzeichen im TextBuffer vvv +#define TextEnd 0 /* ^@ Ende der Zeichenkette */ +#define HardSpace 6 /* ^F Hartspace (wird nicht umbrochen) ,' ' */ +#define GrafText 7 /* ^G Im Text eingebundene Grafik (future) */ +#define Tabulator 9 /* ^I Tabulatorzeichen, Pfeil */ +#define LineFeed 10 /* ^J Neue Zeile */ +#define SoftTrennK 11 /* ^K Zeichen für k-c-Austausch bei Trennung, 'k' */ +#define AbsatzEnd 13 /* ^M Neuer Absatz =CR */ +#define HardTrenn 16 /* ^P Hartes Trennzeichen (wird nicht umbrochen), '-' */ +#define SoftTrennAdd 19 /* ^S Zusatz-Zeichen Trennung von z.b."Schiff-fahrt" */ +#define Paragraf 21 /* ^U Zeichen welches für Paragraf-Zeichen */ +#define Escape 27 /* ^[ Escapesequenz einleiten */ +#define SoftTrenn 31 /* ^_ Weiches Trennzeichen, '-' nur Zeilenende */ +#define MaxEscValLen 8 +#define MaxEscLen (MaxEscValLen+3) + +//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +// Escapesequenzen: [Esc]<Ident><Value>[Esc] also mind. 4 Char +// Max. Länge von Value soll sein: 8 Char (7+Vorzeichen). Demnach max. Länge +// einer Escapesequenz: 11 Char. +// Identifer: + +#define EscFont 'F' /* FontID, z.B. 92500 für CG Times */ +#define EscGrad 'G' /* Schriftgrad 1..255 für «Pt-127«Pt */ +#define EscBreit 'B' /* Breite 1..255% des Schriftgrades */ +#define EscKaptS 'K' /* Kapitälchengröße 1..255% des Schriftgrades */ +#define EscLFeed 'L' /* Zeilenabstand 1..32767% vom max. Schriftgrad der Zeile */ + // oder 1..32767 für 1..16383«Pt absolut (Wenn Bit 15=1) +#define EscSlant 'S' /* Kursiv(Winkel) 1..8999 für 0.01ø..89.99ø */ +#define EscVPos 'V' /* Zeichen Vertikal-Position 1..255 für «Pt..127«Pt */ +#define EscZAbst 'Z' /* Zeichenabstand -128..127% */ +#define EscHJust 'A' /* H-Justify Absatz: Links, Zentr, Rechts, Block, Austreibend, Gesperrt (0..5)*/ + +#define EscFarbe 'C' /* Farbe 0..7 */ +#define EscBFarb 'U' /* BackFarbe 0..7 */ +#define EscInts 'I' /* Farbintensität 0..100% */ +#define EscMustr 'M' /* Muster 0..? inkl. Transp... */ +#define EscMFarb 'O' /* Musterfarbe 0..7 */ +#define EscMBFrb 'P' /* 2. Musterfarbe 0..7 */ +#define EscMInts 'W' /* Musterintensität 0..7 */ + +#define EscSMstr 'E' /* Schattenmuster 0..? inkl. Transp... */ +#define EscSFarb 'R' /* Schattenfarbe 0..7 */ +#define EscSBFrb 'T' /* 2. Schattenfarbe 0..7 */ +#define EscSInts 'Q' /* Schattenintensität 0..7 */ + +#define EscSXDst 'X' /* Schattenversatz X 0..100% */ +#define EscSYDst 'Y' /* Schattenversatz Y 0..100% */ +#define EscSDist 'D' /* Schattenversatz X-Y 0..100% */ + +#define EscBold 'f' /* Fett // */ +#define EscLSlnt 'l' /* LKursiv // */ +#define EscRSlnt 'r' /* RKursiv // */ +#define EscUndln 'u' /* Unterstrichen // */ +#define EscDbUnd 'p' /* doppelt Unterstrichen // */ +#define EscKaptF 'k' /* Kapitälchenflag // */ +#define EscStrik 'd' /* Durchgestrichen // */ +#define EscDbStk 'e' /* doppelt Durchgestrichen // */ +#define EscSupSc 'h' /* Hochgestellt // */ +#define EscSubSc 't' /* Tiefgestellt // */ +#define Esc2DShd 's' /* 2D-Schatten // */ +#define Esc3DShd 'j' /* 3D-Schatten // */ +#define Esc4DShd 'i' /* 4D-Schatten // */ +#define EscEbShd 'b' /* Embossed // */ + +// AllEscIdent =[EscFont, EscGrad, EscBreit,EscKaptS,EscLFeed,EscSlant,EscVPos, EscZAbst,EscHJust, +// EscFarbe,EscBFarb,EscInts, EscMustr,EscMFarb,EscMBFrb,EscMInts, +// EscSMstr,EscSFarb,EscSBFrb,EscSInts,EscSXDst,EscSYDst,EscSDist, +// EscBold, EscLSlnt,EscRSlnt,EscUndln,EscDbUnd,EscKaptF,EscStrik,EscDbStk, +// EscSupSc,EscSubSc,Esc2DShd,Esc3DShd,Esc4DShd]; +// Justify muß spätestens am Anfang des Absatzes stehen +#define EscSet '' /* Flag setzen */ +#define EscReset '' /* Flag löschen */ +#define EscDeflt '' /* Flag auf default setzen */ +#define EscToggl '' /* Flag Toggeln */ +#define EscRelat '%' +#define EscNoFlg 0 +#define EscNoVal -2147483647 /* -MaxLongInt */ +//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +#define NoTrenn 0xFFFF /* Wert für Parameter 'Rest' von GetTextChar(), wenn auf keinen Fall getrennt werden soll */ +#define DoTrenn 0xFFFE /* Wert für Parameter 'Rest' von GetTextChar(), wenn getrennt werden soll */ + +#define MaxLineChars 1024 + +#define ChrXPosArrSize (MaxLineChars+1+1) /* 2k - Beginnt mit 0 im gegensatz zu StarDraw */ +#define CharLineSize (MaxLineChars+1+1) +#define EscStr (UCHAR[MaxEscLen+1]); + +#define MinChar 32 +#define MaxChar 255 + + +//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +#define DefaultCharWidth 4800 +#define GradDiv 2 +#define CharTopToBase 100 /* wegen Apostrophe und Umlaute mehr als 75% */ +#define CharTopToBtm 120 /* Zeilenhöhe ist größer als Schriftgrad */ + // bei Avanti-Bold '' eigentlich sogar 130% + +// end of AbsBase.Pas +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + + + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +// DefBase.Pas + +#define TextBoldBit 0x0001 /* Fett */ +#define TextRSlnBit 0x0002 /* Kursiv */ +#define TextUndlBit 0x0004 /* Unterstrichen */ +#define TextStrkBit 0x0008 /* Durchgesteichen */ +#define TextSupSBit 0x0010 /* Hocgestellt */ +#define TextSubSBit 0x0020 /* Tiefgestellt */ +#define TextKaptBit 0x0040 /* Kapitälchen */ +#define TextLSlnBit 0x0080 /* Linkskursiv */ +#define TextDbUnBit 0x0100 /* Doppelt unterstrichen */ +#define TextDbStBit 0x0200 /* Doppelt durchgestrichen */ +#define TextSh2DBit 0x0400 /* 2D-Schatten 2.0 */ +#define TextSh3DBit 0x0800 /* 3D-Schatten 2.0 */ +#define TextSh4DBit 0x1000 /* 4D-Schatten 2.0 */ +#define TextShEbBit 0x2000 /* Embossed-Schatten 2.0 */ +#define FontAtrBits (TextBoldBit | TextRSlnBit) + +#define THJustLeft 0x00 +#define THJustCenter 0x01 +#define THJustRight 0x02 +#define THJustBlock 0x03 +#define THJustDrvOut 0x04 /* Austreibend Formatiert */ +#define THJustLocked 0x05 /* A l s S p e r r s c h r i f t */ +#define TVJustTop 0x00 /* Future */ +#define TVJustCenter 0x10 /* Future */ +#define TVJustBottom 0x20 /* Future */ +#define TVJustBlock 0x30 /* Future */ + +#define MaxCharSlant 4200 /* Maximal 42ø kursiv ! */ + +// end of DefBase.Pas +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + + +BOOL CheckTextOutl(ObjAreaType& F, ObjLineType& L); + +BOOL CheckTextOutl(ObjAreaType& F, ObjLineType& L) +{ + return (F.FIntens!=L.LIntens) || + ((F.FFarbe!=L.LFarbe) && (F.FIntens>0)) || + ((F.FBFarbe!=L.LBFarbe) && (F.FIntens<100)); +} + + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +// Misc.Pas + +short hPoint2Sgf(short a) +{ + long b; + b=long(a)*127*SgfDpmm/(144*5); + return short(b); +} + +short Sgf2hPoint(short a) +{ + long b; + b=long(a)*5*144/(127*SgfDpmm); + return short(b); +} + +// End of Misc.Pas +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + + + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +// AbsRead.Pas + +// ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +// ³ Function GetTopToBaseLine() Function GetBaseLineToBtm() ³ +// ³ ³ +// ³ Abstand von Zeilenoberkante bis BaseLine bzw. von BaseLine bis ³ +// ³ Unterkante berechnen. Alles in SGF-Units. ³ +// ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +USHORT GetTopToBaseLine(USHORT MaxGrad) +{ + long ret; + ret=long(MaxGrad)*long(CharTopToBase) /long(100); + return USHORT(ret); +} + +// ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +// ³ Function GetTextChar() Function GetTextCharConv() ³ +// ³ ³ +// ³ Liest ein Zeichen aus dem Textbuffer, wertet dabei eventuell ³ +// ³ auftretende Escapesequenzen aus und setzt dementsprechend den ³ +// ³ Ein-/Ausgabeparameter AktAtr. Index wird entsprechend erhöht. ³ +// ³ Der Parameter Rest muß immer die Anzahl der Zeichen beinhalten, ³ +// ³ den angeforderten Zeichen in der aktuellen Zeile noch folgen. ³ +// ³ Ansonsten funktioniert die Silbentrennung nicht richtig. Gibt man ³ +// ³ stattdessen die Konstante NoTrenn an, wird in keinem Fall ³ +// ³ getrennt, die Konstante DoTrenn bewirkt dagegen, daß überall dort ³ +// ³ getrennt wird, wo ein SoftTrenner vorkommt. ³ +// ³ ³ +// ³ SoftTrenner werden immer in ein Minuszeichen konvertiert. ³ +// ³ GetTextCharConv() konvertiert zusätzlich HardSpace und AbsatzEnde ³ +// ³ in Spaces sowie HardTrenner in Minuszeichen. TextEnde wird immer ³ +// ³ als Char(0) geliefert. ³ +// ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + + +UCHAR ConvertTextChar(UCHAR c) +{ + if (c<32) { + switch (c) { + case HardSpace : c=' '; break; + case AbsatzEnd : c=' '; break; + case SoftTrenn : c='-'; break; + case HardTrenn : c='-'; break; + case SoftTrennK : c='-'; break; + case SoftTrennAdd: c='-'; + } + } + return c; +} + + + +USHORT GetSchnittBit(UCHAR c) +{ + USHORT r=0; + switch (c) { + case EscBold : r=TextBoldBit; break; + case EscRSlnt: r=TextRSlnBit; break; + case EscUndln: r=TextUndlBit; break; + case EscStrik: r=TextStrkBit; break; + case EscDbUnd: r=TextDbUnBit; break; + case EscDbStk: r=TextDbStBit; break; + case EscSupSc: r=TextSupSBit; break; + case EscSubSc: r=TextSubSBit; break; + case EscKaptF: r=TextKaptBit; break; + case EscLSlnt: r=TextLSlnBit; break; + case Esc2DShd: r=TextSh2DBit; break; + case Esc3DShd: r=TextSh3DBit; break; + case Esc4DShd: r=TextSh4DBit; break; + case EscEbShd: r=TextShEbBit; + } + return r; +} + + + +long ChgValue(long Def, long Min, long Max, UCHAR FlgVal, long NumVal) +{ + long r=0; + + if (FlgVal==EscDeflt) { + r=Def; // zurück auf Default + } else { + if (NumVal!=EscNoVal) r=NumVal; // Hart setzen + } + + if (Min!=0 || Max!=0) { + if (r>Max) r=Max; + if (r<Min) r=Min; + } + return r; +} + + + +void ChgSchnittBit(USHORT Bit, USHORT Radio1, USHORT Radio2, USHORT Radio3, + UCHAR FlgVal, USHORT Schnitt0, USHORT& Schnitt) +{ + USHORT All,Rad; + + Rad=Radio1 | Radio2 | Radio3; + All=Bit | Rad; + + switch (FlgVal) { + case EscSet : Schnitt=(Schnitt & ~All) | Bit; break; + case EscReset: Schnitt=(Schnitt & ~All); break; + case EscDeflt: Schnitt=(Schnitt & ~All) | (Schnitt0 & All); break; + case EscToggl: Schnitt=(Schnitt & ~Rad) ^ Bit; + } +} + + + +UCHAR GetNextChar(UCHAR* TBuf, USHORT Index) +{ + USHORT Cnt; + while (TBuf[Index]==Escape) { + Index++; + Cnt=0; + while (TBuf[Index]!=Escape && Cnt<=MaxEscLen) { + Index++; Cnt++; } + Index++; + } + return TBuf[Index]; +} + + + +UCHAR ProcessOne(UCHAR* TBuf, USHORT& Index, + ObjTextType& Atr0, ObjTextType& AktAtr, + BOOL ScanEsc) +{ + UCHAR c; + UCHAR Ident; + BOOL Ende; + BOOL q; + UCHAR FlgVal; + long NumVal; + long Sgn; + short i; + BOOL EoVal; + + do { + c=TBuf[Index]; Index++; + Ende=(c!=Escape); + if (Ende==FALSE) { + c=TBuf[Index]; Index++; + Ident=c; // Identifer merken + FlgVal=EscNoFlg; + NumVal=EscNoVal; + c=TBuf[Index]; Index++; // Hier fängt der Wert an + if (c==EscSet || c==EscReset || c==EscDeflt || c==EscToggl) FlgVal=c; else { + if (c=='-') Sgn=-1; else Sgn=1; + if (c=='+' || c=='-') { c=TBuf[Index]; Index++; } + i=MaxEscValLen; + NumVal=0; + do { + NumVal=10*NumVal+c-'0'; + EoVal=(TBuf[Index]<'0' || TBuf[Index]>'9'); + if (EoVal==FALSE) { c=TBuf[Index]; Index++; } + i--; + } while (i>0 && EoVal==FALSE); + NumVal=Sgn*NumVal; + } + q=!CheckTextOutl(AktAtr.F,AktAtr.L); + + switch (Ident) { + case EscFont : AktAtr.SetFont(ULONG (ChgValue(Atr0.GetFont(),0,0 ,FlgVal,NumVal)));break; + case EscGrad : AktAtr.Grad =USHORT(ChgValue(Atr0.Grad, 2,2000 ,FlgVal,NumVal)); break; + case EscBreit: AktAtr.Breite =USHORT(ChgValue(Atr0.Breite, 1,1000 ,FlgVal,NumVal)); break; + case EscKaptS: AktAtr.Kapit =(BYTE)(ChgValue(Atr0.Kapit, 1,255 ,FlgVal,NumVal)); break; + case EscLFeed: AktAtr.LnFeed =USHORT(ChgValue(Atr0.LnFeed, 1,65535 ,FlgVal,NumVal)); break; + case EscSlant: AktAtr.Slant =USHORT(ChgValue(Atr0.Slant, 1,MaxCharSlant ,FlgVal,NumVal)); break; + case EscVPos : AktAtr.ChrVPos=char (ChgValue(Atr0.ChrVPos,-128,127 ,FlgVal,NumVal)); break; + case EscZAbst: AktAtr.ZAbst =(BYTE)(ChgValue(Atr0.ZAbst, 1,255 ,FlgVal,NumVal)); break; + case EscHJust: AktAtr.Justify=(BYTE)(ChgValue(Atr0.Justify & 0x0F,0,5 ,FlgVal,NumVal)); break; + case EscFarbe: { AktAtr.L.LFarbe =(BYTE)(ChgValue(Atr0.L.LFarbe,0,7 ,FlgVal,NumVal)); if (q) AktAtr.F.FFarbe =AktAtr.L.LFarbe; } break; + case EscBFarb: { AktAtr.L.LBFarbe=(BYTE)(ChgValue(Atr0.L.LBFarbe,0,255,FlgVal,NumVal)); if (q) AktAtr.F.FBFarbe=AktAtr.L.LBFarbe; } break; + case EscInts : { AktAtr.L.LIntens=(BYTE)(ChgValue(Atr0.L.LIntens,0,100,FlgVal,NumVal)); if (q) AktAtr.F.FIntens=AktAtr.L.LIntens; } break; + + case EscMustr: { AktAtr.F.FMuster=USHORT(ChgValue(Atr0.F.FMuster,0,65535,FlgVal,NumVal)); } break; + case EscMFarb: { AktAtr.F.FFarbe =(BYTE)(ChgValue(Atr0.F.FFarbe,0,7 ,FlgVal,NumVal)); } break; + case EscMBFrb: { AktAtr.F.FBFarbe=(BYTE)(ChgValue(Atr0.F.FBFarbe,0,255,FlgVal,NumVal)); } break; + case EscMInts: { AktAtr.F.FIntens=(BYTE)(ChgValue(Atr0.F.FIntens,0,100,FlgVal,NumVal)); } break; + + case EscSMstr: { AktAtr.ShdF.FMuster=USHORT(ChgValue(Atr0.ShdF.FMuster,0,65535,FlgVal,NumVal)); } break; + case EscSFarb: { AktAtr.ShdL.LFarbe =(BYTE)(ChgValue(Atr0.ShdL.LFarbe,0,7 ,FlgVal,NumVal)); AktAtr.ShdF.FFarbe =AktAtr.ShdL.LFarbe; } break; + case EscSBFrb: { AktAtr.ShdL.LBFarbe=(BYTE)(ChgValue(Atr0.ShdL.LBFarbe,0,255,FlgVal,NumVal)); AktAtr.ShdF.FBFarbe=AktAtr.ShdL.LBFarbe; } break; + case EscSInts: { AktAtr.ShdL.LIntens=(BYTE)(ChgValue(Atr0.ShdL.LIntens,0,100,FlgVal,NumVal)); AktAtr.ShdF.FIntens=AktAtr.ShdL.LIntens; } break; + case EscSDist: { AktAtr.ShdVers.x=(short)ChgValue(Atr0.ShdVers.x,0,30000,FlgVal,NumVal); AktAtr.ShdVers.y=AktAtr.ShdVers.x; } break; + case EscSXDst: { AktAtr.ShdVers.x=(short)ChgValue(Atr0.ShdVers.x,0,30000,FlgVal,NumVal); } break; + case EscSYDst: { AktAtr.ShdVers.y=(short)ChgValue(Atr0.ShdVers.y,0,30000,FlgVal,NumVal); } break; + + case EscBold : ChgSchnittBit(TextBoldBit,0,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; + case EscRSlnt: ChgSchnittBit(TextRSlnBit,TextLSlnBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; + case EscUndln: ChgSchnittBit(TextUndlBit,TextDbUnBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; + case EscStrik: ChgSchnittBit(TextStrkBit,TextDbStBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; + case EscDbUnd: ChgSchnittBit(TextDbUnBit,TextUndlBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; + case EscDbStk: ChgSchnittBit(TextDbStBit,TextStrkBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; + case EscSupSc: ChgSchnittBit(TextSupSBit,TextSubSBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; + case EscSubSc: ChgSchnittBit(TextSubSBit,TextSupSBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; + case EscKaptF: ChgSchnittBit(TextKaptBit,0,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; + case EscLSlnt: ChgSchnittBit(TextLSlnBit,TextRSlnBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; + case Esc2DShd: ChgSchnittBit(TextSh2DBit,TextSh3DBit,TextSh4DBit,TextShEbBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; + case Esc3DShd: ChgSchnittBit(TextSh3DBit,TextSh2DBit,TextSh4DBit,TextShEbBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; + case Esc4DShd: ChgSchnittBit(TextSh4DBit,TextSh2DBit,TextSh3DBit,TextShEbBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; + case EscEbShd: ChgSchnittBit(TextShEbBit,TextSh2DBit,TextSh3DBit,TextSh4DBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; + } //endcase + if (TBuf[Index]==Escape) Index++; // zweites Esc weglesen } + } // if Ende==FALSE + } while (Ende==FALSE && ScanEsc==FALSE); + if (Ende==FALSE) c=Escape; + return c; +} // end of ProcessOne + + +UCHAR GetTextChar(UCHAR* TBuf, USHORT& Index, + ObjTextType& Atr0, ObjTextType& AktAtr, + USHORT Rest, BOOL ScanEsc) +{ + UCHAR c,c0,nc; + + c=ProcessOne(TBuf,Index,Atr0,AktAtr,ScanEsc); + if (ScanEsc==FALSE) { + if (c==SoftTrennAdd || c==SoftTrennK || c==SoftTrenn) { + nc=GetNextChar(TBuf,Index); + c0=c; + if (Rest==0 || Rest==DoTrenn || + nc==' ' || nc==AbsatzEnd || nc==TextEnd) c='-'; + else { + c=ProcessOne(TBuf,Index,Atr0,AktAtr,ScanEsc); // den Trenner überspringen + if (c0==SoftTrennAdd) { + if (c>=32) c=ProcessOne(TBuf,Index,Atr0,AktAtr,ScanEsc); // und hier noch 'nen Buchstaben überspringen + } + } + } + if ((Rest==1 || Rest==DoTrenn) && GetNextChar(TBuf,Index)==SoftTrennK) { + if (c=='c') c='k'; + else if (c=='C') c='K'; + } + } + return c; +} + + // HardSpace und HardTrenn müssen explizit konvertiert werden ! } + // if AktAtr.Schnitt and TextKaptBit =TextKaptBit then c:=UpCase(c);(explizit) } + + // Bei der Trennmethode SoftTrennAdd wird davon ausgegangen, daß der zu } + // trennende Konsonant bereits 3x mal im TextBuf vorhanden ist, z.b.: } + // "Schiff-fahrt". Wenn nicht getrennt, dann wird "-f" entfernt. } + + + +UCHAR GetTextCharConv(UCHAR* TBuf, USHORT& Index, + ObjTextType& Atr0, ObjTextType& AktAtr, + USHORT Rest, BOOL ScanEsc) +{ + UCHAR c; + + c=GetTextChar(TBuf,Index,Atr0,AktAtr,Rest,ScanEsc); + if (c<32) { + switch (c) { + case HardSpace : c=' '; break; + case AbsatzEnd : c=' '; break; + case HardTrenn : c='-'; + } + } + return c; +} + + +// ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +// ³ Function GetLineFeed() ³ +// ³ ³ +// ³ Benötigter Zeilenabstand in SGF-Units. ChrVPos wird berücksichtigt.³ +// ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ +USHORT GetLineFeed(UCHAR* TBuf, USHORT Index, ObjTextType Atr0, ObjTextType AktAtr, + USHORT nChar, USHORT& LF, USHORT& MaxGrad) +{ + UCHAR c=0; + BOOL AbsEnd=FALSE; + ULONG LF100=0; + ULONG MaxLF100=0; + BOOL LFauto=0; + BOOL First=TRUE; + USHORT Grad; + USHORT i=0; + USHORT r=1; + + MaxGrad=0; + while (!AbsEnd && nChar>0) { + nChar--; + c=GetTextChar(TBuf,Index,Atr0,AktAtr,nChar,FALSE); + i++; + AbsEnd=(c==TextEnd || c==AbsatzEnd); + if (First || (!AbsEnd && c!=' ' && c!=HardTrenn)) { + LFauto=(AktAtr.LnFeed & 0x8000)==0; + LF100=AktAtr.LnFeed & 0x7FFF; + if (LFauto) LF100=LF100*AktAtr.Grad; else LF100*=LF100; + if (AktAtr.ChrVPos>0) LF100-=AktAtr.ChrVPos*100; + if (LF100>MaxLF100) MaxLF100=LF100; + Grad=AktAtr.Grad; + if (AktAtr.ChrVPos>0) Grad-=AktAtr.ChrVPos; + if (Grad>MaxGrad) MaxGrad=Grad; + First=FALSE; + } + if (!AbsEnd && c!=' ') r=i; + } + MaxGrad=hPoint2Sgf(MaxGrad); + if (MaxLF100<=4000) { // sonst Overflowgefahr + LF=USHORT(hPoint2Sgf(short(MaxLF100)) /100); + } else { + LF=USHORT(hPoint2Sgf(short(MaxLF100) /100)); + } + + return r; +} + +// End of AbsRead.Pas +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + + + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +// iFont.Pas + +#define DefaultSlant 1500 /* Default: Italic ist 15ø */ +#define SuperSubFact 60 /* SuperScript/SubScript: 60% vom Schriftgrad */ +#define DefaultSpace 40 /* Default: Space ist 40% vom SchriftGrad */ + +USHORT SetTextContext(OutputDevice& rOut, ObjTextType& Atr, BOOL Kapt, USHORT Dreh, + USHORT FitXMul, USHORT FitXDiv, USHORT FitYMul, USHORT FitYDiv) +{ + SgfFontOne* pSgfFont; // Font aus dem IniFile + Font aFont; + Color aColor; + ULONG Grad; + ULONG Brei; + String FNam; + USHORT StdBrei=50; // Durchschnittliche Zeichenbreite in % von Schriftgrad + BOOL bFit=(FitXMul!=1 || FitXDiv!=1 || FitYMul!=1 || FitYDiv!=1); + + pSgfFont = pSgfFonts->GetFontDesc(Atr.GetFont()); + + if ( pSgfFont!=NULL ) + { + FNam =pSgfFont->SVFName; + StdBrei=pSgfFont->SVWidth; + if (pSgfFont->Fixd) aFont.SetPitch(PITCH_FIXED); else aFont.SetPitch(PITCH_VARIABLE); + aFont.SetFamily(pSgfFont->SVFamil); + aFont.SetCharSet(pSgfFont->SVChSet); + aFont.SetName(FNam); + } + else + { // Falls nich im Inifile, sind hier einige Fonts hart kodiert + aFont.SetPitch(PITCH_VARIABLE); + switch (Atr.GetFont()) { + case 92500: case 92501: case 92504: case 92505: + { +#if defined(WIN) || defined(WNT) || defined(PM2) + FNam=String::CreateFromAscii( "Times New Roman" ); // CG Times ist unter Windows und OS/2 Times New Roman +#else + FNam=String::CreateFromAscii( "Times" ); // ansonsten ist das einfach Times +#endif + StdBrei=40; + aFont.SetFamily(FAMILY_ROMAN); + } break; + case 94021: case 94022: case 94023: case 94024: { +#if defined(WIN) || defined(WNT) + FNam=String::CreateFromAscii( "Arial", 5 ); // Univers ist unter Windows Arial +#else + FNam=String::CreateFromAscii( "Helvetica" ); // und ansonsten Helvetica +#endif + aFont.SetFamily(FAMILY_SWISS); + StdBrei=47; + } break; + case 93950: case 93951: case 93952: case 93953: { +#if defined(WIN) || defined(WNT) + FNam=String::CreateFromAscii( "Courier New" ); // Der Vector-Courierfont unter Windows heißt Courier New +#else + FNam=String::CreateFromAscii( "Courier" ); // ansonsten ist und bleibt Courier immer Courier +#endif + aFont.SetFamily(FAMILY_ROMAN); + aFont.SetPitch(PITCH_FIXED); + } break; + default: FNam=String::CreateFromAscii( "Helvetica", 9 ); + } + aFont.SetName(FNam); + //aFont.SetCharSet(CHARSET_SYSTEM); + } + + Grad=ULONG(Atr.Grad); + if ((Atr.Schnitt & TextKaptBit) !=0 && Kapt) Grad=Grad*ULONG(Atr.Kapit)/100; + if ((Atr.Schnitt & TextSupSBit) !=0 || (Atr.Schnitt & TextSubSBit) !=0) Grad=Grad*SuperSubFact/100; + Brei=Grad; + if (Atr.Breite!=100 || bFit) { + if (bFit) { + Grad=Grad*ULONG(FitYMul)/ULONG(FitYDiv); + Brei=Brei*ULONG(FitXMul)/ULONG(FitXDiv); + } + Brei=Brei*ULONG(Atr.Breite)/100; + Brei=Brei*ULONG(StdBrei)/100; + aFont.SetSize(Size(hPoint2Sgf(USHORT(Brei)),hPoint2Sgf(USHORT(Grad)))); + } else { + aFont.SetSize(Size(0,hPoint2Sgf(USHORT(Grad)))); + } + + aColor=Sgv2SvFarbe(Atr.L.LFarbe,Atr.L.LBFarbe,Atr.L.LIntens); aFont.SetColor(aColor); + aColor=Sgv2SvFarbe(Atr.F.FFarbe,Atr.F.FBFarbe,Atr.F.FIntens); aFont.SetFillColor(aColor); + aFont.SetTransparent(TRUE); + aFont.SetAlign(ALIGN_BASELINE); + + Dreh/=10; Dreh=3600-Dreh; if (Dreh==3600) Dreh=0; + aFont.SetOrientation(Dreh); + + if ((Atr.Schnitt & TextBoldBit) !=0) aFont.SetWeight(WEIGHT_BOLD); + if ((Atr.Schnitt & TextRSlnBit) !=0) aFont.SetItalic(ITALIC_NORMAL); + if ((Atr.Schnitt & TextUndlBit) !=0) aFont.SetUnderline(UNDERLINE_SINGLE); + if ((Atr.Schnitt & TextDbUnBit) !=0) aFont.SetUnderline(UNDERLINE_DOUBLE); + if ((Atr.Schnitt & TextStrkBit) !=0) aFont.SetStrikeout(STRIKEOUT_SINGLE); + if ((Atr.Schnitt & TextDbStBit) !=0) aFont.SetStrikeout(STRIKEOUT_DOUBLE); + if ((Atr.Schnitt & TextSh2DBit) !=0) aFont.SetShadow(TRUE); + if ((Atr.Schnitt & TextSh3DBit) !=0) aFont.SetShadow(TRUE); + if ((Atr.Schnitt & TextSh4DBit) !=0) aFont.SetShadow(TRUE); + if ((Atr.Schnitt & TextShEbBit) !=0) aFont.SetShadow(TRUE); + if (CheckTextOutl(Atr.F,Atr.L)) aFont.SetOutline(TRUE); + + if (aFont!=rOut.GetFont()) rOut.SetFont(aFont); + + return 0; +} + +// iFont.Pas +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +// Absatz.Pas + +struct ProcChrSta { + USHORT Index; + USHORT ChrXP; + UCHAR OutCh; + BOOL Kapt; + ObjTextType Attrib; +}; + +void InitProcessCharState(ProcChrSta& State, ObjTextType& AktAtr, USHORT IndexA) +{ + State.Attrib=AktAtr; + State.OutCh=0; + State.Index=IndexA; + State.ChrXP=0; + State.Kapt=FALSE; +} + +BOOL UpcasePossible(UCHAR c) +{ + if ((c>='a' && c<='z') || c=='ä' || c=='ö' || c=='ü') return TRUE; + else return FALSE; +} + +UCHAR Upcase(UCHAR c) +{ + if ((c>=(UCHAR)'a' && c<=(UCHAR)'z')) c=(c-(UCHAR)'a')+(UCHAR)'A'; + else if (c==(UCHAR)'ä') c=(UCHAR)'Ä'; + else if (c==(UCHAR)'ö') c=(UCHAR)'Ö'; + else if (c==(UCHAR)'ü') c=(UCHAR)'Ü'; + return c; +} + +USHORT GetCharWidth(OutputDevice& rOut, UCHAR c) +{ + UCHAR c1; + USHORT ChrWidth; + + c1 = ByteString::Convert((char)c,RTL_TEXTENCODING_IBM_437, gsl_getSystemTextEncoding() ); + if (c==' ') + { + ChrWidth=(USHORT)rOut.GetTextWidth( String('A') ); + if (rOut.GetFont().GetPitch()!=PITCH_FIXED) { + ChrWidth=MulDiv(ChrWidth,DefaultSpace,100); + } + } else { + if (c>=MinChar && c<=MaxChar) { + ChrWidth=(USHORT)rOut.GetTextWidth(String((char)c1)); + } else { + ChrWidth=(USHORT)rOut.GetTextWidth(String('A')); + } + } + return ChrWidth; +} + +UCHAR ProcessChar(OutputDevice& rOut, UCHAR* TBuf, ProcChrSta& R, ObjTextType& Atr0, + USHORT& nChars, USHORT Rest, + short* Line, UCHAR* cLine) +{ + USHORT KernDist=0; // Wert für Kerning + USHORT ChrWidth; + UCHAR c; + UCHAR c1; + BOOL AbsEnd; + + c=GetTextChar(TBuf,R.Index,Atr0,R.Attrib,Rest,FALSE); // versucht evtl. zu trennen, wenn Rest entsprechenden Wert besitzt + + AbsEnd=(c==AbsatzEnd || c==TextEnd); + if (AbsEnd==FALSE) { + R.OutCh=ConvertTextChar(c); // von HardTrenn nach '-', ... + R.Kapt=(R.Attrib.Schnitt & TextKaptBit) !=0 && UpcasePossible(R.OutCh); + if (R.Kapt) R.OutCh=Upcase(R.OutCh); + SetTextContext(rOut,R.Attrib,R.Kapt,0,1,1,1,1); + + if (R.Kapt) c1=Upcase(c); else c1=c; + ChrWidth=GetCharWidth(rOut,c1); + + if (R.Attrib.ZAbst!=100) { // Spezial-Zeichenabstand ? + ULONG Temp; + Temp=ULONG(ChrWidth)*ULONG(R.Attrib.ZAbst)/100; + ChrWidth=USHORT(Temp); + } + nChars++; + if (R.ChrXP>32000) R.ChrXP=32000; + Line[nChars]=R.ChrXP-KernDist; + cLine[nChars]=c; + R.ChrXP+=ChrWidth-KernDist; // Position für den nächsten Character + } + return c; +} + +void FormatLine(UCHAR* TBuf, USHORT& Index, ObjTextType& Atr0, ObjTextType& AktAtr, + USHORT UmbWdt, USHORT AdjWdt, + short* Line, USHORT& nChars, + double rSn, double rCs, + UCHAR* cLine, BOOL TextFit) +{ + VirtualDevice vOut; + UCHAR c,c0; + UCHAR ct; + BOOL First; // erster Char ? + BYTE Just; // Absatzformatierung + BOOL Border; // Rand der Box erreicht ? + BOOL Border0; + BOOL AbsEnd; // Ende des Absatzes erreicht ? + ProcChrSta* R=new ProcChrSta; + ProcChrSta* R0=new ProcChrSta; + ProcChrSta* WErec=new ProcChrSta; + USHORT WEnChar; + ProcChrSta* WErec0=new ProcChrSta; + USHORT WEnChar0; + ProcChrSta* TRrec=new ProcChrSta; + USHORT TRnChar; + + USHORT WordEndCnt; // Justieren und Trennen + BOOL WordEnd; + BOOL Trenn; + + short BoxRest; // zum Quetschen und formatieren + USHORT i,j,k,h; + USHORT re,li; + + vOut.SetMapMode(MapMode(MAP_10TH_MM,Point(),Fraction(1,4),Fraction(1,4))); + + nChars=0; + SetTextContext(vOut,AktAtr,FALSE,0,1,1,1,1); + InitProcessCharState(*R,AktAtr,Index); + (*R0)=(*R); (*WErec)=(*R); WEnChar=0; c0=0; Border0=FALSE; + Border=FALSE; First=TRUE; + WordEndCnt=0; + + do { // mal schauen, wieviele Worte so in die Zeile passen + if (Border) c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,DoTrenn,Line,cLine); + else c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine); + AbsEnd=(c==AbsatzEnd || c==TextEnd); + //if not AbsEnd then + { + if (First) { + Just=R->Attrib.Justify & 0x0F; // Absatzformat steht wenn, dann am Anfang + } + Border=R->ChrXP>UmbWdt; + WordEnd=(AbsEnd || (c==' ')) && (c0!=' ') && (c0!=0); + Trenn=c=='-'; + if (WordEnd && !Border0) { + WordEndCnt++; + (*WErec)=(*R0); + WEnChar=nChars-1; + } + if (Trenn && !Border) { + WordEndCnt++; + (*WErec)=(*R); + WEnChar=nChars; + } + } + (*R0)=(*R); c0=c; + Border0=Border; + First=FALSE; + AbsEnd=AbsEnd || (nChars>=MaxLineChars); + } while (!(AbsEnd || (Border && ((WordEndCnt>0) || WordEnd || Trenn)))); + + if (Border) { // Trennen und Quetschen + (*WErec0)=(*WErec); WEnChar0=WEnChar; + AbsEnd=FALSE; c0=0; + (*R)=(*WErec); nChars=WEnChar; + (*TRrec)=(*R); TRnChar=nChars; + Border0=FALSE; Border=FALSE; + do { // erst mal gucken wieviele Silben noch reinpassen + ct=ProcessChar(vOut,TBuf,*TRrec,Atr0,TRnChar,DoTrenn,Line,cLine); + c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine); + AbsEnd=(ct==AbsatzEnd) || (ct==TextEnd) || (nChars>=MaxLineChars); + + Border=TRrec->ChrXP>UmbWdt; + WordEnd=AbsEnd || ((AbsEnd || (c==' ')) && (c0!=' ') && (c0!=0)); + Trenn=ct=='-'; + if (WordEnd && (!Border0 || (WordEndCnt==0))) { + WordEndCnt++; + (*WErec)=(*R0); + if (AbsEnd) WEnChar=nChars; else WEnChar=nChars-1; + (*TRrec)=(*R); TRnChar=nChars; // zum weitersuchen + } + if (Trenn && (!Border || (WordEndCnt==0))) { + WordEndCnt++; // merken, daß man hier trennen kann + (*WErec)=(*TRrec); + WEnChar=TRnChar; + (*TRrec)=(*R); TRnChar=nChars; // zum weitersuchen + } + (*R0)=(*R); c0=c; + Border0=Border; + Border=R->ChrXP>UmbWdt; + } while (!(AbsEnd || (Border && ((WordEndCnt>0) || WordEnd || Trenn)))); + + while (WErec0->Index<WErec->Index) { // damit Line[] auch garantiert stimmt } + c=ProcessChar(vOut,TBuf,*WErec0,Atr0,WEnChar0,WEnChar-WEnChar0-1,Line,cLine); + } + + (*R)=(*WErec); nChars=WEnChar; + + if (UmbWdt>=R->ChrXP) { + BoxRest=UmbWdt-R->ChrXP; + } else { // Zusammenquetschen + BoxRest=R->ChrXP-UmbWdt; // um soviel muß gequetscht werden + for (i=2;i<=nChars;i++) { // 1. CharPosition bleibt ! + Line[i]-=(i-1)*(BoxRest) /(nChars-1); + } + R->ChrXP=UmbWdt; + Line[nChars+1]=UmbWdt; + } + } + + if (!AbsEnd) { + do { // Leerzeichen weglesen + (*WErec)=(*R); + c=GetTextChar(TBuf,R->Index,Atr0,R->Attrib,NoTrenn,FALSE); + nChars++; + Line[nChars]=R->ChrXP; + cLine[nChars]=c; + } while (c==' '); + if (c!=' ' && c!=AbsatzEnd && c!=TextEnd) { + nChars--; + (*R)=(*WErec); + } + } + + if (AbsEnd && nChars<MaxLineChars) { // Ausrichten, statt Blocksatz aber linksbündig + if (Just==3) Just=0; + nChars++; Line[nChars]=R->ChrXP; // Damit AbsatzEnde auch weggelesen wird + Line[nChars+1]=R->ChrXP; // denn die Breite von CR oder #0 ist nun mal sehr klein + if (TBuf[R->Index-1]!=AbsatzEnd && TBuf[R->Index-1]!=TextEnd) { + c=GetTextChar(TBuf,R->Index,Atr0,R->Attrib,NoTrenn,FALSE); // Kleine Korrektur. Notig, wenn nur 1 Wort in + } + } + + BoxRest=AdjWdt-R->ChrXP; + if (TextFit) Just=THJustLeft; + + switch (Just) { + case THJustLeft: break; // Links + case THJustCenter: { + BoxRest=BoxRest /2; // Mitte + for (i=1;i<=nChars;i++) Line[i]+=BoxRest; + } break; + case THJustRight: { // Rechts + for (i=1;i<=nChars;i++) Line[i]+=BoxRest; + } break; + case THJustDrvOut: + case THJustBlock: { // Block und Austreibend + re=nChars; + if (Just==THJustDrvOut) re--; + while (re>=1 && (cLine[re]==' ' || cLine[re]==TextEnd || cLine[re]==AbsatzEnd)) re--; + li=1; + while (li<=re && (cLine[li]==' ' || cLine[li]==TextEnd || cLine[li]==AbsatzEnd)) li++; + if (Just==THJustDrvOut) BoxRest=AdjWdt-Line[re+1]; + + j=0; // Anzahl der Spaces ermitteln + for (i=li;i<=re;i++) { + if (cLine[i]==' ') { + j++; + } + } + + if (j==0) { // nur 1 Wort ? -> Strecken ! + for (i=li+1;i<=re;i++) { // von links nach rechts + Line[i]+=MulDiv(i-li,BoxRest,re-li+1-1); + } + } else { + k=0; h=0; + for (i=li;i<=re;i++) { // j Spaces aufbohren ! + if (cLine[i]==' ') { // Space gefunden ! + k++; + h=MulDiv(k,BoxRest,j); + } + Line[i]+=h; + } + } + for (i=re+1;i<=nChars;i++) Line[i]+=BoxRest; // und den Rest anpassen + Line[nChars+1]=AdjWdt; + } break; + case THJustLocked: { //Gesperrt + re=nChars-1; + while (re>=1 && (cLine[re]==' ' || cLine[re]==TextEnd || cLine[re]==AbsatzEnd)) re--; + li=1; + while (li<=re && (cLine[li]==' ' || cLine[li]==TextEnd || cLine[li]==AbsatzEnd)) li++; + BoxRest=AdjWdt-Line[re+1]; + for (i=li+1;i<=re;i++) { // Strecken von links nach rechts + Line[i]+=MulDiv(i-li,BoxRest,re-li+1-1); + } + for (i=re+1;i<=nChars;i++) Line[i]+=BoxRest; // und den Rest anpassen + Line[nChars+1]=AdjWdt; + } break; + } + Index=R->Index; + AktAtr=R->Attrib; + delete R; + delete R0; + delete WErec; + delete WErec0; + delete TRrec; +} + + + +// End of Absatz.Pas +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +// DrawText.Pas + +void DrawChar(OutputDevice& rOut, UCHAR c, ObjTextType T, PointType Pos, USHORT DrehWink, + USHORT FitXMul, USHORT FitXDiv, USHORT FitYMul, USHORT FitYDiv) +{ + SetTextContext(rOut,T,UpcasePossible(c),DrehWink,FitXMul,FitXDiv,FitYMul,FitYDiv); + if ((T.Schnitt & TextKaptBit)!=0 && UpcasePossible(c)) c=Upcase(c); + String s( (char)c, RTL_TEXTENCODING_IBM_437 ); + rOut.DrawText( Point( Pos.x, Pos.y ), s ); +} + +/************************************************************************* +|* +|* TextType::Draw() +|* +|* Beschreibung +|* Ersterstellung JOE 09.08.93 +|* Letzte Aenderung JOE 09.08.93 +|* +*************************************************************************/ +void TextType::Draw(OutputDevice& rOut) +{ + if ((Flags & TextOutlBit)!=0) return; // Sourcetext für Outliner !! + + ObjTextType T1,T2; + USHORT Index1; + USHORT Index2; + UCHAR c; + USHORT l; // Anzahl der Zeichen in der Zeile + USHORT i; + short yPos0; + short xPos; + short yPos; + USHORT LF; + USHORT MaxGrad; + short xSize; + short xSAdj; + short ySize; + double sn,cs; + USHORT TopToBase; + BOOL Ende; + USHORT lc; + BOOL LineFit; // FitSize.x=0? oder Flags -> jede Zeile stretchen + BOOL TextFit; + short* xLine; + UCHAR* cLine; // Buffer für FormatLine + USHORT FitXMul; + USHORT FitXDiv; + USHORT FitYMul; + USHORT FitYDiv; + BOOL Fehler; + UCHAR* Buf=Buffer; // Zeiger auf die Buchstaben + + pSgfFonts->ReadList(); + xLine=new short[ChrXPosArrSize]; + cLine=new UCHAR[CharLineSize]; + + TextFit=(Flags & TextFitBits)!=0; + LineFit=FALSE; + LineFit=((Flags & TextFitZBit)!=0); + if (TextFit && FitSize.x==0) LineFit=TRUE; + + if (DrehWink==0) { + sn=0.0; + cs=1.0; + } else { + sn=sin(double(DrehWink)*3.14159265359/18000); + cs=cos(double(DrehWink)*3.14159265359/18000); + } + + T1=T; Index1=0; yPos=0; xPos=0; + if (TextFit) { + ySize=Pos2.y-Pos1.y; + xSize=32000 /2; // Umbruch + xSAdj=Pos2.x-Pos1.x; // zum Ausrichten bei Zentriert/Blocksatz + //if (xSize<=0) { xSize=32000 /2; LineFit=TRUE; } + FitXMul=abs(Pos2.x-Pos1.x); FitXDiv=FitSize.x; if (FitXDiv==0) FitXDiv=1; + FitYMul=abs(Pos2.y-Pos1.y); FitYDiv=FitSize.y; if (FitYDiv==0) FitYDiv=1; + } else { + xSize=Pos2.x-Pos1.x; + xSAdj=xSize; + ySize=Pos2.y-Pos1.y; + FitXMul=1; FitXDiv=1; + FitYMul=1; FitYDiv=1; + } + if (xSize<0) xSize=0; + if (xSAdj<0) xSAdj=0; + + do { + T2=T1; Index2=Index1; + FormatLine(Buf,Index2,T,T2,xSize,xSAdj,xLine,l,sn,cs,cLine,LineFit); + Fehler=(Index2==Index1); + if (!Fehler) { + lc=GetLineFeed(Buf,Index1,T,T1,l,LF,MaxGrad); + if (TextFit) { + if (LineFit) FitXDiv=xLine[lc+1]; + if (FitXDiv>0) { + long Temp; + for (i=1;i<=l+1;i++) { + Temp=long(xLine[i])*long(FitXMul) /long(FitXDiv); + xLine[i]=short(Temp); + } + LF=MulDiv(LF,FitYMul,FitYDiv); + MaxGrad=MulDiv(MaxGrad,FitYMul,FitYDiv); + } else { + FitXDiv=1; // 0 gibts nicht + } + } + yPos0=yPos; + TopToBase=GetTopToBaseLine(MaxGrad); + yPos+=TopToBase; + Ende=(yPos0+short(MulDiv(MaxGrad,CharTopToBtm,100))>ySize) && !TextFit; + if (!Ende) { + T2=T1; Index2=Index1; + i=1; + while (i<=l) { + c=GetTextCharConv(Buf,Index2,T,T2,l-i,FALSE); + long xp1,yp1; // wegen Overflowgefahr + PointType Pos; + xp1=long(Pos1.x)+xPos+long(xLine[i]); + yp1=long(Pos1.y)+yPos; + if (xp1>32000) xp1=32000; if (xp1<-12000) xp1=-12000; + if (yp1>32000) yp1=32000; if (yp1<-12000) yp1=-12000; + Pos.x=short(xp1); + Pos.y=short(yp1); + + if (DrehWink!=0) RotatePoint(Pos,Pos1.x,Pos1.y,sn,cs); + DrawChar(rOut,c,T2,Pos,DrehWink,FitXMul,FitXDiv,FitYMul,FitYDiv); + i++; + } // while i<=l + yPos=yPos0+LF; + T1=T2; Index1=Index2; // Für die nächste Zeile + } // if ObjMin.y+yPos<=Obj_Max.y + } // if !Fehler + } while (c!=TextEnd && !Ende && !Fehler); + delete cLine; + delete xLine; +} + +// End of DrawText.Pas +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// + +// nicht mehr benötigt, da der Pointer nun extra geführt wird +// (DEC Alpha hat nämlich 64Bit-Pointer!) +//UCHAR* TextType::GetBufPtr() +//{ +// ULONG Temp; +// Temp=ULONG(BufLo)+0x00010000*ULONG(BufHi); +// return (UCHAR*)Temp; +//} +// +//void TextType::SetBufPtr(UCHAR* Ptr) +//{ +// ULONG Temp=(ULONG)Ptr; +// BufLo=USHORT(Temp & 0x0000FFFF); +// BufHi=USHORT((Temp & 0xFFFF0000)>>16); +//} + +UINT32 ObjTextType::GetFont() +{ + return ULONG(FontLo)+0x00010000*ULONG(FontHi); +} + +void ObjTextType::SetFont(UINT32 FontID) +{ + FontLo=USHORT(FontID & 0x0000FFFF); + FontHi=USHORT((FontID & 0xFFFF0000)>>16); +} + + +///////////////////////////////////////////////////////////////////////////////// +// SGF.Ini lesen //////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// +SgfFontOne::SgfFontOne() +{ + Next=NULL; + IFID=0; + Bold=FALSE; + Ital=FALSE; + Sans=FALSE; + Serf=FALSE; + Fixd=FALSE; + SVFamil=FAMILY_DONTKNOW; + SVChSet=RTL_TEXTENCODING_DONTKNOW; + SVWidth=40; +} + +void SgfFontOne::ReadOne( ByteString& ID, ByteString& Dsc ) +{ + USHORT i,j,n; + ByteString s; + + if ( Dsc.Len() < 4 || ( Dsc.GetChar( 0 ) != '(' ) ) + return; + i=1; // Erster Buchstabe des IF-Fontnamen. Davor ist eine '(' + while ( i < Dsc.Len() && ( Dsc.GetChar( i ) !=')' ) ) + i++; + Dsc.Erase(0,i+1); // IF-Fontname löschen inkl. () + + if ( Dsc.Len() < 2 || ( Dsc.GetChar( Dsc.Len() - 1 ) !=')' ) ) + return; + i=Dsc.Len()-2; // hier ist die ')' des SV-Fontnames + j=0; + while ( i > 0 && ( Dsc.GetChar( i ) != '(' ) ) + { + i--; + j++; + } + SVFName=String(Dsc,i+1,j); // SV-Fontname rausholen + Dsc.Erase(i,j); + + IFID = (UINT32)ID.ToInt32(); + n=Dsc.GetTokenCount(' '); + for (i=0;i<n;i++) + { + s = Dsc.GetToken( i,' ' ); + if ( s.Len() ) + { + s.ToUpperAscii(); + if ( s.CompareTo( "BOLD", 4 ) == COMPARE_EQUAL ) Bold=TRUE; + else if ( s.CompareTo( "ITAL", 4 ) == COMPARE_EQUAL ) Ital=TRUE; + else if ( s.CompareTo( "SERF", 4 ) == COMPARE_EQUAL ) Serf=TRUE; + else if ( s.CompareTo( "SANS", 4 ) == COMPARE_EQUAL ) Sans=TRUE; + else if ( s.CompareTo( "FIXD", 4 ) == COMPARE_EQUAL ) Fixd=TRUE; + else if ( s.CompareTo( "ROMAN", 5 ) == COMPARE_EQUAL ) SVFamil=FAMILY_ROMAN; + else if ( s.CompareTo( "SWISS", 5 ) == COMPARE_EQUAL ) SVFamil=FAMILY_SWISS; + else if ( s.CompareTo( "MODERN", 6 ) == COMPARE_EQUAL ) SVFamil=FAMILY_MODERN; + else if ( s.CompareTo( "SCRIPT", 6 ) == COMPARE_EQUAL ) SVFamil=FAMILY_SCRIPT; + else if ( s.CompareTo( "DECORA", 6 ) == COMPARE_EQUAL ) SVFamil=FAMILY_DECORATIVE; + else if ( s.CompareTo( "ANSI", 4 ) == COMPARE_EQUAL ) SVChSet=RTL_TEXTENCODING_MS_1252; + else if ( s.CompareTo( "IBMPC", 5 ) == COMPARE_EQUAL ) SVChSet=RTL_TEXTENCODING_IBM_850; + else if ( s.CompareTo( "MAC", 3 ) == COMPARE_EQUAL ) SVChSet=RTL_TEXTENCODING_APPLE_ROMAN; + else if ( s.CompareTo( "SYMBOL", 6 ) == COMPARE_EQUAL ) SVChSet=RTL_TEXTENCODING_SYMBOL; + else if ( s.CompareTo( "SYSTEM", 6 ) == COMPARE_EQUAL ) SVChSet = gsl_getSystemTextEncoding(); + else if ( s.IsNumericAscii() ) SVWidth=s.ToInt32(); + } + } +} + +///////////////////////////////////////////////////////////////////////////////// + +SgfFontLst::SgfFontLst() +{ + pList=NULL; + Last=NULL; + LastID=0; + LastLn=NULL; + Tried=FALSE; +} + +SgfFontLst::~SgfFontLst() +{ + RausList(); +} + +void SgfFontLst::RausList() +{ + SgfFontOne* P; + SgfFontOne* P1; + P=pList; + while (P!=NULL) { + P1=P->Next; + delete P; + P=P1; + } + pList=NULL; + Last=NULL; + Tried=FALSE; + LastID=0; + LastLn=NULL; +} + +void SgfFontLst::AssignFN(const String& rFName) +{ FNam=rFName; } + +void SgfFontLst::ReadList() +{ + if (!Tried) { + Tried=TRUE; + LastID=0; + LastLn=NULL; + SgfFontOne* P,P1; + Config aCfg(FNam); + aCfg.SetGroup("SGV Fonts fuer StarView"); + USHORT Anz=aCfg.GetKeyCount(); + USHORT i; + ByteString FID,Dsc; + + for (i=0;i<Anz;i++) + { + FID = aCfg.GetKeyName( i ); + FID = FID.EraseAllChars(); // Leerzeichen weg + Dsc = aCfg.ReadKey( i ); + if ( FID.IsNumericAscii() ) + { + P=new SgfFontOne; // neuer Eintrag + if (Last!=NULL) Last->Next=P; else pList=P; Last=P; // einklinken + P->ReadOne(FID,Dsc); // und Zeile interpretieren + } + } + } +} + +SgfFontOne* SgfFontLst::GetFontDesc(UINT32 ID) +{ + if (ID!=LastID) { + SgfFontOne* P; + P=pList; + while (P!=NULL && P->IFID!=ID) P=P->Next; + LastID=ID; + LastLn=P; + } + return LastLn; +} diff --git a/svtools/source/filter.vcl/filter/strings.hrc b/svtools/source/filter.vcl/filter/strings.hrc new file mode 100644 index 000000000000..feee7a0eb9df --- /dev/null +++ b/svtools/source/filter.vcl/filter/strings.hrc @@ -0,0 +1,61 @@ +/************************************************************************* + * + * $RCSfile: strings.hrc,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 "svtools.hrc" diff --git a/svtools/source/filter.vcl/filter/strings.src b/svtools/source/filter.vcl/filter/strings.src new file mode 100644 index 000000000000..7fd31d283077 --- /dev/null +++ b/svtools/source/filter.vcl/filter/strings.src @@ -0,0 +1,117 @@ +/************************************************************************* + * + * $RCSfile: strings.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 EXPORT_DIALOG_TITLE +{ + Text = " Optionen" ; + Text [ ENGLISH ] = " options" ; + Text [ english_us ] = " Options" ; + Text [ italian ] = " Opzioni" ; + Text [ spanish ] = " Opciones" ; + Text [ french ] = "[_]Options" ; + Text [ dutch ] = " Opties" ; + Text [ swedish ] = " Alternativ" ; + Text [ danish ] = " Alternativer" ; + Text [ portuguese_brazilian ] = " Optionen" ; + Text [ portuguese ] = " Opções" ; + Text[ chinese_simplified ] = " Ñ¡Ïî"; + Text[ russian ] = " Ïàðàìåòðû"; + Text[ polish ] = " Opcje"; + Text[ japanese ] = " µÌß¼®Ý"; + Text[ chinese_traditional ] = " ¿ï¶µ"; + Text[ arabic ] = " ÇáÎíÇÑÇÊ"; + Text[ greek ] = " ÅðéëïãÝò"; + Text[ korean ] = " ¿É¼Ç"; + Text[ turkish ] = " Seçenekler"; + Text[ language_user1 ] = " "; +}; + +String KEY_MODE +{ + Text = "-EXPORT-MODE" ; +}; + +String KEY_RES +{ + Text = "-EXPORT-RES" ; +}; + +String KEY_SIZEX +{ + Text = "-EXPORT-SIZEX" ; +}; + +String KEY_SIZEY +{ + Text = "-EXPORT-SIZEY" ; +}; + +String KEY_COLORS +{ + Text = "-COLORS" ; +}; + +String KEY_RLE_CODING +{ + Text = "-RLE_CODING" ; +}; diff --git a/svtools/source/filter.vcl/igif/decode.cxx b/svtools/source/filter.vcl/igif/decode.cxx new file mode 100644 index 000000000000..f7d9198d5bfa --- /dev/null +++ b/svtools/source/filter.vcl/igif/decode.cxx @@ -0,0 +1,245 @@ +/************************************************************************* + * + * $RCSfile: decode.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 "decode.hxx" + +// ------------------------------------------------------------------------ + +struct GIFLZWTableEntry +{ + GIFLZWTableEntry* pPrev; + GIFLZWTableEntry* pFirst; + BYTE nData; +}; + +// ------------------------------------------------------------------------ + +GIFLZWDecompressor::GIFLZWDecompressor( BYTE cDataSize ) : + nDataSize ( cDataSize ), + bEOIFound ( FALSE ), + nOutBufDataLen ( 0 ), + nInputBitsBuf ( 0 ), + nInputBitsBufSize ( 0 ) +{ + pTable = new GIFLZWTableEntry[ 4096 ]; + pOutBuf = new BYTE[ 4096 ]; + + nClearCode = 1 << nDataSize; + nEOICode = nClearCode + 1; + nTableSize = nEOICode + 1; + nCodeSize = nDataSize + 1; + nOldCode = 0xffff; + pOutBufData = pOutBuf + 4096; + + for( USHORT i = 0; i < nTableSize; i++ ) + { + pTable[i].pPrev = NULL; + pTable[i].pFirst = pTable + i; + pTable[i].nData = (BYTE) i; + } +} + +// ------------------------------------------------------------------------ + +GIFLZWDecompressor::~GIFLZWDecompressor() +{ + delete[] pOutBuf; + delete[] pTable; +} + +// ------------------------------------------------------------------------ + +HPBYTE GIFLZWDecompressor::DecompressBlock( HPBYTE pSrc, BYTE cBufSize, + ULONG& rCount, BOOL& rEOI ) +{ + ULONG nTargetSize = 4096; + ULONG nCount = 0; + HPBYTE pTarget = (HPBYTE) SvMemAlloc( nTargetSize ); + HPBYTE pTmpTarget = pTarget; + + nBlockBufSize = cBufSize; + nBlockBufPos = 0; + pBlockBuf = pSrc; + + while( ProcessOneCode() ) + { + nCount += nOutBufDataLen; + + if( nCount > nTargetSize ) + { + ULONG nNewSize = nTargetSize << 1; + ULONG nOffset = pTmpTarget - pTarget; + HPBYTE pTmp = (HPBYTE) SvMemAlloc( nNewSize ); + + HMEMCPY( pTmp, pTarget, nTargetSize ); + SvMemFree( pTarget ); + + nTargetSize = nNewSize; + pTmpTarget = ( pTarget = pTmp ) + nOffset; + } + + HMEMCPY( pTmpTarget, pOutBufData, nOutBufDataLen ); + pTmpTarget += nOutBufDataLen; + pOutBufData += nOutBufDataLen; + nOutBufDataLen = 0; + + if ( bEOIFound ) + break; + } + + rCount = nCount; + rEOI = bEOIFound; + + return pTarget; +} + +// ------------------------------------------------------------------------ + +void GIFLZWDecompressor::AddToTable( USHORT nPrevCode, USHORT nCodeFirstData ) +{ + GIFLZWTableEntry* pE; + + if( nTableSize < 4096 ) + { + pE = pTable + nTableSize; + pE->pPrev = pTable + nPrevCode; + pE->pFirst = pE->pPrev->pFirst; + pE->nData = pTable[ nCodeFirstData ].pFirst->nData; + nTableSize++; + + if ( ( nTableSize == (USHORT) (1 << nCodeSize) ) && ( nTableSize < 4096 ) ) + nCodeSize++; + } +} + +// ------------------------------------------------------------------------ + +BOOL GIFLZWDecompressor::ProcessOneCode() +{ + GIFLZWTableEntry* pE; + USHORT nCode; + BOOL bRet = FALSE; + BOOL bEndOfBlock = FALSE; + + while( nInputBitsBufSize < nCodeSize ) + { + if( nBlockBufPos >= nBlockBufSize ) + { + bEndOfBlock = TRUE; + break; + } + + nInputBitsBuf |= ( (ULONG) pBlockBuf[ nBlockBufPos++ ] ) << nInputBitsBufSize; + nInputBitsBufSize += 8; + } + + if ( !bEndOfBlock ) + { + // Einen Code aus dem Eingabe-Buffer holen: + nCode = ( (USHORT) nInputBitsBuf ) & ( ~( 0xffff << nCodeSize ) ); + nInputBitsBuf >>= nCodeSize; + nInputBitsBufSize -= nCodeSize; + + if ( nCode < nClearCode ) + { + if ( nOldCode != 0xffff ) + AddToTable( nOldCode, nCode ); + } + else if ( ( nCode > nEOICode ) && ( nCode <= nTableSize ) ) + { + if ( nCode == nTableSize ) + AddToTable( nOldCode, nOldCode ); + else + AddToTable( nOldCode, nCode ); + } + else + { + if ( nCode == nClearCode ) + { + nTableSize = nEOICode + 1; + nCodeSize = nDataSize + 1; + nOldCode = 0xffff; + nOutBufDataLen = 0; + } + else + bEOIFound = TRUE; + + return TRUE; + } + + nOldCode = nCode; + + // Zeichen(/-folge) des Codes nCode in den Ausgabe-Buffer schreiben: + pE = pTable + nCode; + do + { + nOutBufDataLen++; + *(--pOutBufData) = pE->nData; + pE = pE->pPrev; + } + while( pE ); + + bRet = TRUE; + } + + return bRet; +} diff --git a/svtools/source/filter.vcl/igif/decode.hxx b/svtools/source/filter.vcl/igif/decode.hxx new file mode 100644 index 000000000000..da5d06157533 --- /dev/null +++ b/svtools/source/filter.vcl/igif/decode.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * + * $RCSfile: decode.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 _DECODE_HXX +#define _DECODE_HXX + +#ifndef _BMPACC_HXX +#include <vcl/bmpacc.hxx> +#endif + +struct GIFLZWTableEntry; + +class GIFLZWDecompressor +{ + GIFLZWTableEntry* pTable; + HPBYTE pOutBuf; + HPBYTE pOutBufData; + HPBYTE pBlockBuf; + ULONG nInputBitsBuf; + USHORT nTableSize; + USHORT nClearCode; + USHORT nEOICode; + USHORT nCodeSize; + USHORT nOldCode; + USHORT nOutBufDataLen; + USHORT nInputBitsBufSize; + BOOL bEOIFound; + BYTE nDataSize; + BYTE nBlockBufSize; + BYTE nBlockBufPos; + + void AddToTable(USHORT nPrevCode, USHORT nCodeFirstData); + BOOL ProcessOneCode(); + + +public: + + GIFLZWDecompressor( BYTE cDataSize ); + ~GIFLZWDecompressor(); + + HPBYTE DecompressBlock( HPBYTE pSrc, BYTE cBufSize, ULONG& rCount, BOOL& rEOI ); +}; + +#endif diff --git a/svtools/source/filter.vcl/igif/gifread.cxx b/svtools/source/filter.vcl/igif/gifread.cxx new file mode 100644 index 000000000000..b605173656ea --- /dev/null +++ b/svtools/source/filter.vcl/igif/gifread.cxx @@ -0,0 +1,890 @@ +/************************************************************************* + * + * $RCSfile: gifread.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 _GIFPRIVATE + +#include <tools/new.hxx> +#include "decode.hxx" +#include "gifread.hxx" + +// ----------- +// - Defines - +// ----------- + +#define NO_PENDING( rStm ) ( ( rStm ).GetError() != ERRCODE_IO_PENDING ) + +// ------------- +// - GIFReader - +// ------------- + +GIFReader::GIFReader( SvStream& rStm, void* pCallData ) : + rIStm ( rStm ), + aGPalette ( 256 ), + aLPalette ( 256 ), + pAcc8 ( NULL ), + pAcc1 ( NULL ), + nLastPos ( rStm.Tell() ), + eActAction ( GLOBAL_HEADER_READING ), + bImGraphicReady ( FALSE ), + nLoops ( 1 ), + bGCTransparent ( FALSE ), + nLogWidth100 ( 0UL ), + nLogHeight100 ( 0UL ) +{ + maUpperName = UniString::CreateFromAscii( "SVIGIF", 6 ); + pSrcBuf = new BYTE[ 256 ]; + ClearImageExtensions(); +} + +// ------------------------------------------------------------------------ + +GIFReader::~GIFReader() +{ + aImGraphic.SetContext( NULL ); + + if( pAcc1 ) + aBmp1.ReleaseAccess( pAcc1 ); + + if( pAcc8 ) + aBmp8.ReleaseAccess( pAcc8 ); + + delete[] pSrcBuf; +} + +// ------------------------------------------------------------------------ + +void GIFReader::ClearImageExtensions() +{ + nGCDisposalMethod = 0; + bGCTransparent = FALSE; + nTimer = 0; +} + +// ------------------------------------------------------------------------ + +BOOL GIFReader::CreateBitmaps( long nWidth, long nHeight, BitmapPalette* pPal, + BOOL bWatchForBackgroundColor ) +{ + const Size aSize( nWidth, nHeight ); + + if( bGCTransparent ) + { + const Color aWhite( COL_WHITE ); + + aBmp1 = Bitmap( aSize, 1 ); + + if( !aAnimation.Count() ) + aBmp1.Erase( aWhite ); + + pAcc1 = aBmp1.AcquireWriteAccess(); + + if( pAcc1 ) + { + cTransIndex1 = (BYTE) pAcc1->GetBestPaletteIndex( aWhite ); + cNonTransIndex1 = cTransIndex1 ? 0 : 1; + } + else + bStatus = FALSE; + } + + if( bStatus ) + { + aBmp8 = Bitmap( aSize, 8, pPal ); + + if( !!aBmp8 && bWatchForBackgroundColor && aAnimation.Count() ) + aBmp8.Erase( (*pPal)[ nBackgroundColor ] ); + else + aBmp8.Erase( Color( COL_WHITE ) ); + + pAcc8 = aBmp8.AcquireWriteAccess(); + bStatus = ( pAcc8 != NULL ); + } + + return bStatus; +} + +// ------------------------------------------------------------------------ + +BOOL GIFReader::ReadGlobalHeader() +{ + char pBuf[ 7 ]; + BYTE nRF; + BYTE nAspect; + BOOL bRet = FALSE; + + rIStm.Read( pBuf, 6 ); + if( NO_PENDING( rIStm ) ) + { + pBuf[ 6 ] = 0; + if( !strcmp( pBuf, "GIF87a" ) || !strcmp( pBuf, "GIF89a" ) ) + { + rIStm.Read( pBuf, 7 ); + if( NO_PENDING( rIStm ) ) + { + SvMemoryStream aMemStm; + + aMemStm.SetBuffer( pBuf, 7, FALSE, 7 ); + aMemStm >> nGlobalWidth; + aMemStm >> nGlobalHeight; + aMemStm >> nRF; + aMemStm >> nBackgroundColor; + aMemStm >> nAspect; + + bGlobalPalette = (BOOL) ( nRF & 0x80 ); + + if( bGlobalPalette ) + ReadPaletteEntries( &aGPalette, 1 << ( ( nRF & 7 ) + 1 ) ); + else + nBackgroundColor = 0; + + if( NO_PENDING( rIStm ) ) + bRet = TRUE; + } + } + else + bStatus = FALSE; + } + + return bRet; +} + +// ------------------------------------------------------------------------ + +void GIFReader::ReadPaletteEntries( BitmapPalette* pPal, ULONG nCount ) +{ + const ULONG nLen = 3UL * nCount; + BYTE* pBuf = new BYTE[ nLen ]; + + rIStm.Read( pBuf, nLen ); + if( NO_PENDING( rIStm ) ) + { + BYTE* pTmp = pBuf; + + for( ULONG i = 0UL; i < nCount; ) + { + BitmapColor& rColor = (*pPal)[ (USHORT) i++ ]; + + rColor.SetRed( *pTmp++ ); + rColor.SetGreen( *pTmp++ ); + rColor.SetBlue( *pTmp++ ); + } + + // nach Moeglichkeit noch einige Standardfarben unterbringen + if( nCount < 256UL ) + { + (*pPal)[ 255UL ] = Color( COL_WHITE ); + + if( nCount < 255UL ) + (*pPal)[ 254UL ] = Color( COL_BLACK ); + } + } + + delete[] pBuf; +} + +// ------------------------------------------------------------------------ + +BOOL GIFReader::ReadExtension() +{ + BYTE cFunction; + BYTE cSize; + BYTE cByte; + BOOL bRet = FALSE; + BOOL bOverreadDataBlocks = FALSE; + + // Extension-Label + rIStm >> cFunction; + if( NO_PENDING( rIStm ) ) + { + // Block-Laenge + rIStm >> cSize; + + switch( cFunction ) + { + // 'Graphic Control Extension' + case( 0xf9 ) : + { + BYTE cFlags; + + rIStm >> cFlags; + rIStm >> nTimer; + rIStm >> nGCTransparentIndex; + rIStm >> cByte; + + if ( NO_PENDING( rIStm ) ) + { + nGCDisposalMethod = ( cFlags >> 2) & 7; + bGCTransparent = ( cFlags & 1 ) ? TRUE : FALSE; + bStatus = ( cSize == 4 ) && ( cByte == 0 ); + bRet = TRUE; + } + } + break; + + // Application-Extension + case ( 0xff ) : + { + if ( NO_PENDING( rIStm ) ) + { + // default diese Extension ueberlesen + bOverreadDataBlocks = TRUE; + + // Appl.-Extension hat Laenge 11 + if ( cSize == 0x0b ) + { + ByteString aAppId; + ByteString aAppCode; + + rIStm.Read( aAppId.AllocBuffer( 8 ), 8 ); + rIStm.Read( aAppCode.AllocBuffer( 3 ), 3 ); + rIStm >> cSize; + + // NetScape-Extension + if( aAppId == "NETSCAPE" && aAppCode == "2.0" && cSize == 3 ) + { + rIStm >> cByte; + + // Loop-Extension + if ( cByte == 0x01 ) + { + rIStm >> cByte; + nLoops = cByte; + rIStm >> cByte; + nLoops |= ( (USHORT) cByte << 8 ); + rIStm >> cByte; + + bStatus = ( cByte == 0 ); + bRet = NO_PENDING( rIStm ); + bOverreadDataBlocks = FALSE; + + // Netscape interpretiert den LoopCount + // als reine Anzahl der _Wiederholungen_; + // bei uns ist es die Gesamtanzahl der + // Durchlaeufe + if( nLoops ) + nLoops++; + } + else + rIStm.SeekRel( -1 ); + } + else if ( aAppId == "STARDIV " && aAppCode == "5.0" && cSize == 9 ) + { + rIStm >> cByte; + + // Loop-Extension + if ( cByte == 0x01 ) + { + rIStm >> nLogWidth100 >> nLogHeight100; + rIStm >> cByte; + bStatus = ( cByte == 0 ); + bRet = NO_PENDING( rIStm ); + bOverreadDataBlocks = FALSE; + } + else + rIStm.SeekRel( -1 ); + } + + } + } + } + break; + + // alles andere ueberlesen + default: + bOverreadDataBlocks = TRUE; + break; + } + + // Sub-Blocks ueberlesen + if ( bOverreadDataBlocks ) + { + bRet = TRUE; + while( cSize && bStatus && !rIStm.IsEof() ) + { + USHORT nCount = (USHORT) cSize + 1; + char* pBuffer = new char[ nCount ]; + + bRet = FALSE; + rIStm.Read( pBuffer, nCount ); + if( NO_PENDING( rIStm ) ) + { + cSize = (BYTE) pBuffer[ cSize ]; + bRet = TRUE; + } + else + cSize = 0; + + delete[] pBuffer; + } + } + } + + return bRet; +} + +// ------------------------------------------------------------------------ + +BOOL GIFReader::ReadLocalHeader() +{ + BYTE pBuf[ 9 ]; + BOOL bRet = FALSE; + + rIStm.Read( pBuf, 9 ); + if( NO_PENDING( rIStm ) ) + { + SvMemoryStream aMemStm; + BitmapPalette* pPal; + BYTE nFlags; + + aMemStm.SetBuffer( (char*) pBuf, 9, FALSE, 9 ); + aMemStm >> nImagePosX; + aMemStm >> nImagePosY; + aMemStm >> nImageWidth; + aMemStm >> nImageHeight; + aMemStm >> nFlags; + + // Falls Interlaced, ersten Startwert vorgeben + bInterlaced = ( ( nFlags & 0x40 ) == 0x40 ); + nLastInterCount = 7; + nLastImageY = 0; + + if( nFlags & 0x80 ) + { + pPal = &aLPalette; + ReadPaletteEntries( pPal, 1 << ( (nFlags & 7 ) + 1 ) ); + } + else + pPal = &aGPalette; + + // Falls alles soweit eingelesen werden konnte, kann + // nun das lokale Bild angelegt werden; + // es wird uebergeben, ob der BackgroundColorIndex evtl. + // beruecksichtigt werden soll ( wenn Globale Farbtab. und + // diese auch fuer dieses Bild gilt ) + if( NO_PENDING( rIStm ) ) + { + CreateBitmaps( nImageWidth, nImageHeight, pPal, bGlobalPalette && ( pPal == &aGPalette ) ); + bRet = TRUE; + } + } + + return bRet; +} + +// ------------------------------------------------------------------------ + +ULONG GIFReader::ReadNextBlock() +{ + ULONG nRet = 0UL; + ULONG nRead; + BYTE cBlockSize; + + rIStm >> cBlockSize; + + if ( rIStm.IsEof() ) + nRet = 4UL; + else if ( NO_PENDING( rIStm ) ) + { + if ( cBlockSize == 0 ) + nRet = 2UL; + else + { + rIStm.Read( pSrcBuf, cBlockSize ); + + if( NO_PENDING( rIStm ) ) + { + if( bOverreadBlock ) + nRet = 3UL; + else + { + BOOL bEOI; + HPBYTE pTarget = pDecomp->DecompressBlock( pSrcBuf, cBlockSize, nRead, bEOI ); + + nRet = ( bEOI ? 3 : 1 ); + + if( nRead && !bOverreadBlock ) + FillImages( pTarget, nRead ); + + SvMemFree( pTarget ); + } + } + } + } + + return nRet; +} + +// ------------------------------------------------------------------------ + +void GIFReader::FillImages( HPBYTE pBytes, ULONG nCount ) +{ + for( ULONG i = 0UL; i < nCount; i++ ) + { + if( nImageX >= nImageWidth ) + { + if( bInterlaced ) + { + long nT1, nT2; + + // falls Interlaced, werden die Zeilen kopiert + if( nLastInterCount ) + { + long nMinY = Min( (long) nLastImageY + 1, (long) nImageHeight - 1 ); + long nMaxY = Min( (long) nLastImageY + nLastInterCount, (long) nImageHeight - 1 ); + + // letzte gelesene Zeile kopieren, wenn Zeilen + // nicht zusanmmenfallen ( kommt vorm wenn wir am Ende des Bildes sind ) + if( ( nMinY > nLastImageY ) && ( nLastImageY < ( nImageHeight - 1 ) ) ) + { + HPBYTE pScanline8 = pAcc8->GetScanline( nYAcc ); + ULONG nSize8 = pAcc8->GetScanlineSize(); + HPBYTE pScanline1; + ULONG nSize1; + + if( bGCTransparent ) + { + pScanline1 = pAcc1->GetScanline( nYAcc ); + nSize1 = pAcc1->GetScanlineSize(); + } + + for( long j = nMinY; j <= nMaxY; j++ ) + { + HMEMCPY( pAcc8->GetScanline( j ), pScanline8, nSize8 ); + + if( bGCTransparent ) + HMEMCPY( pAcc1->GetScanline( j ), pScanline1, nSize1 ); + } + } + } + + nT1 = ( ++nImageY ) << 3; + nLastInterCount = 7; + + if( nT1 >= nImageHeight ) + { + nT2 = nImageY - ( ( nImageHeight + 7 ) >> 3 ); + nT1 = ( nT2 << 3 ) + 4; + nLastInterCount = 3; + + if( nT1 >= nImageHeight ) + { + nT2 -= ( nImageHeight + 3 ) >> 3; + nT1 = ( nT2 << 2 ) + 2; + nLastInterCount = 1; + + if( nT1 >= nImageHeight ) + { + nT2 -= ( nImageHeight + 1 ) >> 2; + nT1 = ( nT2 << 1 ) + 1; + nLastInterCount = 0; + } + } + } + + nLastImageY = (USHORT) nT1; + nYAcc = nT1; + } + else + { + nLastImageY = ++nImageY; + nYAcc = nImageY; + } + + // Zeile faengt von vorne an + nImageX = 0; + } + + if( nImageY < nImageHeight ) + { + const BYTE cTmp = pBytes[ i ]; + + if( bGCTransparent ) + { + if( cTmp == nGCTransparentIndex ) + pAcc1->SetPixel( nYAcc, nImageX++, cTransIndex1 ); + else + { + pAcc8->SetPixel( nYAcc, nImageX, cTmp ); + pAcc1->SetPixel( nYAcc, nImageX++, cNonTransIndex1 ); + } + } + else + pAcc8->SetPixel( nYAcc, nImageX++, cTmp ); + } + else + { + bOverreadBlock = TRUE; + break; + } + } +} + +// ------------------------------------------------------------------------ + +void GIFReader::CreateNewBitmaps() +{ + AnimationBitmap aAnimBmp; + + aBmp8.ReleaseAccess( pAcc8 ); + pAcc8 = NULL; + + if( bGCTransparent ) + { + aBmp1.ReleaseAccess( pAcc1 ); + pAcc1 = NULL; + aAnimBmp.aBmpEx = BitmapEx( aBmp8, aBmp1 ); + } + else + aAnimBmp.aBmpEx = BitmapEx( aBmp8 ); + + aAnimBmp.aPosPix = Point( nImagePosX, nImagePosY ); + aAnimBmp.aSizePix = Size( nImageWidth, nImageHeight ); + aAnimBmp.nWait = ( nTimer != 65535 ) ? nTimer : ANIMATION_TIMEOUT_ON_CLICK; + aAnimBmp.bUserInput = FALSE; + + if( nGCDisposalMethod == 2 ) + aAnimBmp.eDisposal = DISPOSE_BACK; + else if( nGCDisposalMethod == 3 ) + aAnimBmp.eDisposal = DISPOSE_PREVIOUS; + else + aAnimBmp.eDisposal = DISPOSE_NOT; + + aAnimation.Insert( aAnimBmp ); + + if( aAnimation.Count() == 1 ) + { + aAnimation.SetDisplaySizePixel( Size( nGlobalWidth, nGlobalHeight ) ); + aAnimation.SetLoopCount( nLoops ); + } +} + +// ------------------------------------------------------------------------ + +const Graphic& GIFReader::GetIntermediateGraphic() +{ + // Intermediate-Graphic nur erzeugen, wenn schon + // Daten vorliegen, aber die Graphic noch nicht + // vollstaendig eingelesen wurde + if ( bImGraphicReady && !aAnimation.Count() ) + { + Bitmap aBmp; + + aBmp8.ReleaseAccess( pAcc8 ); + + if ( bGCTransparent ) + { + aBmp1.ReleaseAccess( pAcc1 ); + aImGraphic = BitmapEx( aBmp8, aBmp1 ); + + pAcc1 = aBmp1.AcquireWriteAccess(); + bStatus = bStatus && ( pAcc1 != NULL ); + } + else + aImGraphic = aBmp8; + + pAcc8 = aBmp8.AcquireWriteAccess(); + bStatus = bStatus && ( pAcc8 != NULL ); + } + + return aImGraphic; +} + +// ------------------------------------------------------------------------ + +BOOL GIFReader::ProcessGIF() +{ + BOOL bRead = FALSE; + BOOL bEnd = FALSE; + + if ( !bStatus ) + eActAction = ABORT_READING; + + // Stream an die richtige Stelle bringen + rIStm.Seek( nLastPos ); + + switch( eActAction ) + { + // naechsten Marker lesen + case( MARKER_READING ): + { + BYTE cByte; + + rIStm >> cByte; + + if( rIStm.IsEof() ) + eActAction = END_READING; + else if( NO_PENDING( rIStm ) ) + { + bRead = TRUE; + + if( cByte == '!' ) + eActAction = EXTENSION_READING; + else if( cByte == ',' ) + eActAction = LOCAL_HEADER_READING; + else if( cByte == ';' ) + eActAction = END_READING; + else + eActAction = ABORT_READING; + } + } + break; + + // ScreenDescriptor lesen + case( GLOBAL_HEADER_READING ): + { + if( ( bRead = ReadGlobalHeader() ) == TRUE ) + { + ClearImageExtensions(); + eActAction = MARKER_READING; + } + } + break; + + + // Extension lesen + case( EXTENSION_READING ): + { + if( ( bRead = ReadExtension() ) == TRUE ) + eActAction = MARKER_READING; + } + break; + + + // Image-Descriptor lesen + case( LOCAL_HEADER_READING ): + { + if( ( bRead = ReadLocalHeader() ) == TRUE ) + { + nYAcc = nImageX = nImageY = 0; + eActAction = FIRST_BLOCK_READING; + } + } + break; + + + // ersten Datenblock lesen + case( FIRST_BLOCK_READING ): + { + BYTE cDataSize; + + rIStm >> cDataSize; + + if( rIStm.IsEof() ) + eActAction = ABORT_READING; + else if( cDataSize > 12 ) + bStatus = FALSE; + else if( NO_PENDING( rIStm ) ) + { + bRead = TRUE; + pDecomp = new GIFLZWDecompressor( cDataSize ); + eActAction = NEXT_BLOCK_READING; + bOverreadBlock = FALSE; + } + else + eActAction = FIRST_BLOCK_READING; + } + break; + + // naechsten Datenblock lesen + case( NEXT_BLOCK_READING ): + { + USHORT nLastImageX = nImageX; + USHORT nLastImageY = nImageY; + ULONG nRet = ReadNextBlock(); + + // Return: 0:Pending / 1:OK; / 2:OK und letzter Block: / 3:EOI / 4:HardAbort + if( nRet ) + { + bRead = TRUE; + + if ( nRet == 1UL ) + { + bImGraphicReady = TRUE; + eActAction = NEXT_BLOCK_READING; + bOverreadBlock = FALSE; + } + else + { + if( nRet == 2UL ) + { + delete pDecomp; + CreateNewBitmaps(); + eActAction = MARKER_READING; + ClearImageExtensions(); + } + else if( nRet == 3UL ) + { + eActAction = NEXT_BLOCK_READING; + bOverreadBlock = TRUE; + } + else + { + delete pDecomp; + CreateNewBitmaps(); + eActAction = ABORT_READING; + ClearImageExtensions(); + } + } + } + else + { + nImageX = nLastImageX; + nImageY = nLastImageY; + } + } + break; + + // ein Fehler trat auf + case( ABORT_READING ): + { + bEnd = TRUE; + eActAction = END_READING; + } + break; + + default: + break; + } + + // Stream an die richtige Stelle bringen, + // falls Daten gelesen werden konnten + // entweder alte Position oder aktuelle Position + if( bRead || bEnd ) + nLastPos = rIStm.Tell(); + + return bRead; +} + +// ------------------------------------------------------------------------ + +ReadState GIFReader::ReadGIF( Graphic& rGraphic ) +{ + ReadState eReadState; + + bStatus = TRUE; + + while( ProcessGIF() && ( eActAction != END_READING ) ) {} + + if( !bStatus ) + eReadState = GIFREAD_ERROR; + else if( eActAction == END_READING ) + eReadState = GIFREAD_OK; + else + { + if ( rIStm.GetError() == ERRCODE_IO_PENDING ) + rIStm.ResetError(); + + eReadState = GIFREAD_NEED_MORE; + } + + if( aAnimation.Count() == 1 ) + { + rGraphic = aAnimation.Get( 0 ).aBmpEx; + + if( nLogWidth100 && nLogHeight100 ) + { + rGraphic.SetPrefSize( Size( nLogWidth100, nLogHeight100 ) ); + rGraphic.SetPrefMapMode( MAP_100TH_MM ); + } + } + else + rGraphic = aAnimation; + + return eReadState; +} + + +// ------------- +// - ImportGIF - +// ------------- + +BOOL ImportGIF( SvStream & rStm, Graphic& rGraphic, void* pCallerData ) +{ + GIFReader* pGIFReader = (GIFReader*) rGraphic.GetContext(); + USHORT nOldFormat = rStm.GetNumberFormatInt(); + ReadState eReadState; + BOOL bRet = TRUE; + + rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); + + if( !pGIFReader ) + pGIFReader = new GIFReader( rStm, pCallerData ); + + rGraphic.SetContext( NULL ); + eReadState = pGIFReader->ReadGIF( rGraphic ); + + if( eReadState == GIFREAD_ERROR ) + { + bRet = FALSE; + delete pGIFReader; + } + else if( eReadState == GIFREAD_OK ) + delete pGIFReader; + else + { + rGraphic = pGIFReader->GetIntermediateGraphic(); + rGraphic.SetContext( pGIFReader ); + } + + rStm.SetNumberFormatInt( nOldFormat ); + + return bRet; +} diff --git a/svtools/source/filter.vcl/igif/makefile.mk b/svtools/source/filter.vcl/igif/makefile.mk new file mode 100644 index 000000000000..39cd875fd527 --- /dev/null +++ b/svtools/source/filter.vcl/igif/makefile.mk @@ -0,0 +1,96 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ +# +# 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=igif +DEPTARGET=vigif + + +# --- Settings ----------------------------------------------------- + +.IF "$(VCL)" != "" + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + + +# --- Files -------------------------------------------------------- + + +CXXFILES= gifread.cxx \ + decode.cxx + +SLOFILES= $(SLO)$/gifread.obj \ + $(SLO)$/decode.obj + + +.INCLUDE : target.mk + +.ELSE + +dummy: + @+echo VCL not set. nothing to do! + +.ENDIF #VCL diff --git a/svtools/source/filter.vcl/ixbm/makefile.mk b/svtools/source/filter.vcl/ixbm/makefile.mk new file mode 100644 index 000000000000..6d3c4bf1bfec --- /dev/null +++ b/svtools/source/filter.vcl/ixbm/makefile.mk @@ -0,0 +1,95 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ +# +# 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=ixbm +DEPTARGET=vixbm +VERSION=$(UPD) + + +# --- Settings ----------------------------------------------------- + +.IF "$(VCL)" != "" + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + + +# --- Files -------------------------------------------------------- + + +CXXFILES= xbmread.cxx + +SLOFILES= $(SLO)$/xbmread.obj + + +.INCLUDE : target.mk + +.ELSE + +dummy: + @+echo VCL not set. nothing to do! + +.ENDIF #VCL diff --git a/svtools/source/filter.vcl/ixbm/xbmread.cxx b/svtools/source/filter.vcl/ixbm/xbmread.cxx new file mode 100644 index 000000000000..4ede60dfa508 --- /dev/null +++ b/svtools/source/filter.vcl/ixbm/xbmread.cxx @@ -0,0 +1,429 @@ +/************************************************************************* + * + * $RCSfile: xbmread.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ + * + * 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 XBMMINREAD 512 + +#define _XBMPRIVATE +#include <ctype.h> +#include "xbmread.hxx" + +// ------------- +// - XBMReader - +// ------------- + +XBMReader::XBMReader( SvStream& rStm, void* pCallData ) : + rIStm ( rStm ), + nWidth ( 0 ), + nHeight ( 0 ), + nLastPos ( rStm.Tell() ), + pAcc1 ( NULL ), + bStatus ( TRUE ) +{ + pHexTable = new short[ 256 ]; + maUpperName = String::CreateFromAscii( "SVIXBM", 6 ); + InitTable(); +} + +// ------------------------------------------------------------------------ + +XBMReader::~XBMReader() +{ + delete[] pHexTable; + + if( pAcc1 ) + aBmp1.ReleaseAccess( pAcc1 ); +} + +// ------------------------------------------------------------------------ + +void XBMReader::InitTable() +{ + memset( pHexTable, 0, sizeof( short ) ); + + pHexTable['0'] = 0; + pHexTable['1'] = 1; + pHexTable['2'] = 2; + pHexTable['3'] = 3; + pHexTable['4'] = 4; + pHexTable['5'] = 5; + pHexTable['6'] = 6; + pHexTable['7'] = 7; + pHexTable['8'] = 8; + pHexTable['9'] = 9; + pHexTable['A'] = 10; + pHexTable['B'] = 11; + pHexTable['C'] = 12; + pHexTable['D'] = 13; + pHexTable['E'] = 14; + pHexTable['F'] = 15; + pHexTable['X'] = 0; + pHexTable['a'] = 10; + pHexTable['b'] = 11; + pHexTable['c'] = 12; + pHexTable['d'] = 13; + pHexTable['e'] = 14; + pHexTable['f'] = 15; + pHexTable['x'] = 0; + pHexTable[' '] = -1; + pHexTable[','] = -1; + pHexTable['}'] = -1; + pHexTable['\n'] = -1; + pHexTable['\t'] = -1; + pHexTable['\0'] = -1; +} + +// ------------------------------------------------------------------------ + +ByteString XBMReader::FindTokenLine( SvStream* pInStm, const char* pTok1, + const char* pTok2, const char* pTok3 ) +{ + ByteString aRet; + long nPos1; + long nPos2; + long nPos3; + + bStatus = FALSE; + + do + { + if( !pInStm->ReadLine( aRet ) ) + break; + + if( pTok1 ) + { + if( ( nPos1 = aRet.Search( pTok1 ) ) != STRING_NOTFOUND ) + { + bStatus = TRUE; + + if( pTok2 ) + { + bStatus = FALSE; + + if( ( ( nPos2 = aRet.Search( pTok2 ) ) != STRING_NOTFOUND ) && + ( nPos2 > nPos1 ) ) + { + bStatus = TRUE; + + if( pTok3 ) + { + bStatus = FALSE; + + if( ( ( nPos3 = aRet.Search( pTok3 ) ) != STRING_NOTFOUND ) && ( nPos3 > nPos2 ) ) + bStatus = TRUE; + } + } + } + } + } + } + while( !bStatus ); + + return aRet; +} + +// ------------------------------------------------------------------------ + +long XBMReader::ParseDefine( const sal_Char* pDefine ) +{ + long nRet = 0; + char* pTmp = (char*) pDefine; + char cTmp; + + // bis zum Ende gehen + pTmp += ( strlen( pDefine ) - 1 ); + cTmp = *pTmp--; + + // letzte Ziffer suchen + while( pHexTable[ cTmp ] == -1 ) + cTmp = *pTmp--; + + // bis vor die Zahl laufen + while( pHexTable[ cTmp ] != -1 ) + cTmp = *pTmp--; + + // auf Anfang der Zahl gehen + pTmp += 2; + + // Hex lesen + if( ( pTmp[0] == '0' ) && ( ( pTmp[1] == 'X' ) || ( pTmp[1] == 'x' ) ) ) + { + pTmp += 2; + cTmp = *pTmp++; + + while ( pHexTable[ cTmp ] != -1 ) + { + nRet = ( nRet << 4 ) + pHexTable[ cTmp ]; + cTmp = *pTmp++; + } + } + // Dezimal lesen + else + { + cTmp = *pTmp++; + while( ( cTmp >= '0' ) && ( cTmp <= '9' ) ) + { + nRet = nRet * 10 + ( cTmp - '0' ); + cTmp = *pTmp++; + } + } + + return nRet; +} + +// ------------------------------------------------------------------------ + +BOOL XBMReader::ParseData( SvStream* pInStm, const ByteString& aLastLine, XBMFormat eFormat ) +{ + ByteString aLine; + long nRow = 0; + long nCol = 0; + long nBits = ( eFormat == XBM10 ) ? 16 : 8; + long nBit; + USHORT nValue; + USHORT nDigits; + BOOL bFirstLine = TRUE; + + while( nRow < nHeight ) + { + if( bFirstLine ) + { + long nPos; + + // einfuehrende geschweifte Klammer loeschen + if( (nPos = ( aLine = aLastLine ).Search( '{' ) ) != STRING_NOTFOUND ) + aLine.Erase( 0, nPos + 1 ); + + bFirstLine = FALSE; + } + else if( !pInStm->ReadLine( aLine ) ) + break; + + if( aLine.Len() ) + { + const USHORT nCount = aLine.GetTokenCount( ',' ); + + for( USHORT i = 0; ( i < nCount ) && ( nRow < nHeight ); i++ ) + { + const ByteString aToken( aLine.GetToken( i, ',' ) ); + const ULONG nLen = aToken.Len(); + BOOL bProcessed = FALSE; + + nBit = nDigits = nValue = 0; + + for( ULONG n = 0UL; n < nLen; n++ ) + { + const unsigned char cChar = aToken.GetChar( n ); + const short nTable = pHexTable[ cChar ]; + + if( isxdigit( cChar ) || !nTable ) + { + nValue = ( nValue << 4 ) + nTable; + nDigits++; + bProcessed = TRUE; + } + else if( ( nTable < 0 ) && nDigits ) + { + bProcessed = TRUE; + break; + } + } + + if( bProcessed ) + { + while( ( nCol < nWidth ) && ( nBit < nBits ) ) + pAcc1->SetPixel( nRow, nCol++, ( nValue & ( 1 << nBit++ ) ) ? aBlack : aWhite ); + + if( nCol == nWidth ) + nCol = 0, nRow++; + } + } + } + } + + return TRUE; +} + +// ------------------------------------------------------------------------ + +ReadState XBMReader::ReadXBM( Graphic& rGraphic ) +{ + ReadState eReadState; + BYTE cDummy; + + // sehen, ob wir _alles_ lesen koennen + rIStm.Seek( STREAM_SEEK_TO_END ); + rIStm >> cDummy; + + // falls wir nicht alles lesen koennen + // kehren wir zurueck und warten auf neue Daten + if ( rIStm.GetError() != ERRCODE_IO_PENDING ) + { + ByteString aLine; + int nValue; + + rIStm.Seek( nLastPos ); + bStatus = FALSE; + aLine = FindTokenLine( &rIStm, "#define", "_width" ); + + if ( bStatus ) + { + if ( ( nValue = (int) ParseDefine( aLine.GetBuffer() ) ) > 0 ) + { + nWidth = nValue; + aLine = FindTokenLine( &rIStm, "#define", "_height" ); + + // Falls die Hoehe nicht folgt, suchen wir noch + // einmal vom Anfang der Datei an + if ( !bStatus ) + { + rIStm.Seek( nLastPos ); + aLine = FindTokenLine( &rIStm, "#define", "_height" ); + } + } + else + bStatus = FALSE; + + if ( bStatus ) + { + if ( ( nValue = (int) ParseDefine( aLine.GetBuffer() ) ) > 0 ) + { + nHeight = nValue; + aLine = FindTokenLine( &rIStm, "static", "_bits" ); + + if ( bStatus ) + { + XBMFormat eFormat; + + if ( aLine.Search( "short" ) != STRING_NOTFOUND ) + eFormat = XBM10; + else if ( aLine.Search( "char" ) != STRING_NOTFOUND ) + eFormat = XBM11; + else + bStatus = FALSE; + + if ( bStatus && nWidth && nHeight ) + { + aBmp1 = Bitmap( Size( nWidth, nHeight ), 1 ); + pAcc1 = aBmp1.AcquireWriteAccess(); + + if( pAcc1 ) + { + aWhite = pAcc1->GetBestMatchingColor( Color( COL_WHITE ) ); + aBlack = pAcc1->GetBestMatchingColor( Color( COL_BLACK ) ); + bStatus = ParseData( &rIStm, aLine, eFormat ); + } + else + bStatus = FALSE; + } + } + } + } + } + + if( bStatus ) + { + Bitmap aBlackBmp( Size( pAcc1->Width(), pAcc1->Height() ), 1 ); + + aBmp1.ReleaseAccess( pAcc1 ), pAcc1 = NULL; + aBlackBmp.Erase( Color( COL_BLACK ) ); + rGraphic = BitmapEx( aBlackBmp, aBmp1 ); + eReadState = XBMREAD_OK; + } + else + eReadState = XBMREAD_ERROR; + } + else + { + rIStm.ResetError(); + eReadState = XBMREAD_NEED_MORE; + } + + return eReadState; +} + +// ------------- +// - ImportXBM - +// ------------- + +BOOL ImportXBM( SvStream& rStm, Graphic& rGraphic, void* pCallerData ) +{ + XBMReader* pXBMReader = (XBMReader*) rGraphic.GetContext(); + ReadState eReadState; + BOOL bRet = TRUE; + + if( !pXBMReader ) + pXBMReader = new XBMReader( rStm, pCallerData ); + + rGraphic.SetContext( NULL ); + eReadState = pXBMReader->ReadXBM( rGraphic ); + + if( eReadState == XBMREAD_ERROR ) + { + bRet = FALSE; + delete pXBMReader; + } + else if( eReadState == XBMREAD_OK ) + delete pXBMReader; + else + rGraphic.SetContext( pXBMReader ); + + return bRet; +} diff --git a/svtools/source/filter.vcl/ixpm/makefile.mk b/svtools/source/filter.vcl/ixpm/makefile.mk new file mode 100644 index 000000000000..7c4ed303c09b --- /dev/null +++ b/svtools/source/filter.vcl/ixpm/makefile.mk @@ -0,0 +1,95 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:58:59 $ +# +# 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=ixpm +DEPTARGET=vixpm +VERSION=$(UPD) + + +# --- Settings ----------------------------------------------------- + +.IF "$(VCL)" != "" + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + + +# --- Files -------------------------------------------------------- + + +CXXFILES= xpmread.cxx + +SLOFILES= $(SLO)$/xpmread.obj + + +.INCLUDE : target.mk + +.ELSE + +dummy: + @+echo VCL not set. nothing to do! + +.ENDIF #VCL diff --git a/svtools/source/filter.vcl/ixpm/rgbtable.hxx b/svtools/source/filter.vcl/ixpm/rgbtable.hxx new file mode 100644 index 000000000000..d7425faa8068 --- /dev/null +++ b/svtools/source/filter.vcl/ixpm/rgbtable.hxx @@ -0,0 +1,729 @@ +/************************************************************************* + * + * $RCSfile: rgbtable.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:59:00 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +struct XPMRGBTab +{ + char* name; + BYTE red; + BYTE green; + BYTE blue; +}; + +static XPMRGBTab pRGBTable[] = { +{ "white", 255, 255, 255 }, +{ "black", 0, 0, 0 }, +{ "snow", 255, 250, 250 }, +{ "GhostWhite", 248, 248, 255 }, +{ "WhiteSmoke", 245, 245, 245 }, +{ "gainsboro", 220, 220, 220 }, +{ "FloralWhite", 255, 250, 240 }, +{ "OldLace", 253, 245, 230 }, +{ "linen", 250, 240, 230 }, +{ "AntiqueWhite", 250, 235, 215 }, +{ "PapayaWhip", 255, 239, 213 }, +{ "BlanchedAlmond", 255, 235, 205 }, +{ "bisque", 255, 228, 196 }, +{ "PeachPuff", 255, 218, 185 }, +{ "NavajoWhite", 255, 222, 173 }, +{ "moccasin", 255, 228, 181 }, +{ "cornsilk", 255, 248, 220 }, +{ "ivory", 255, 255, 240 }, +{ "LemonChiffon", 255, 250, 205 }, +{ "seashell", 255, 245, 238 }, +{ "honeydew", 240, 255, 240 }, +{ "MintCream", 245, 255, 250 }, +{ "azure", 240, 255, 255 }, +{ "AliceBlue", 240, 248, 255 }, +{ "lavender", 230, 230, 250 }, +{ "LavenderBlush", 255, 240, 245 }, +{ "MistyRose", 255, 228, 225 }, +{ "DarkSlateGray", 47, 79, 79 }, +{ "DarkSlateGrey", 47, 79, 79 }, +{ "DimGray", 105, 105, 105 }, +{ "DimGrey", 105, 105, 105 }, +{ "SlateGray", 112, 128, 144 }, +{ "SlateGrey", 112, 128, 144 }, +{ "LightSlateGray", 119, 136, 153 }, +{ "LightSlateGrey", 119, 136, 153 }, +{ "gray", 190, 190, 190 }, +{ "grey", 190, 190, 190 }, +{ "LightGrey", 211, 211, 211 }, +{ "LightGray", 211, 211, 211 }, +{ "MidnightBlue", 25, 25, 112 }, +{ "navy", 0, 0, 128 }, +{ "NavyBlue", 0, 0, 128 }, +{ "CornflowerBlue", 100, 149, 237 }, +{ "DarkSlateBlue", 72, 61, 139 }, +{ "SlateBlue", 106, 90, 205 }, +{ "MediumSlateBlue", 123, 104, 238 }, +{ "LightSlateBlue", 132, 112, 255 }, +{ "MediumBlue", 0, 0, 205 }, +{ "RoyalBlue", 65, 105, 225 }, +{ "blue", 0, 0, 255 }, +{ "DodgerBlue", 30, 144, 255 }, +{ "DeepSkyBlue", 0, 191, 255 }, +{ "SkyBlue", 135, 206, 235 }, +{ "LightSkyBlue", 135, 206, 250 }, +{ "SteelBlue", 70, 130, 180 }, +{ "LightSteelBlue", 176, 196, 222 }, +{ "LightBlue", 173, 216, 230 }, +{ "PowderBlue", 176, 224, 230 }, +{ "PaleTurquoise", 175, 238, 238 }, +{ "DarkTurquoise", 0, 206, 209 }, +{ "MediumTurquoise", 72, 209, 204 }, +{ "turquoise", 64, 224, 208 }, +{ "cyan", 0, 255, 255 }, +{ "LightCyan", 224, 255, 255 }, +{ "CadetBlue", 95, 158, 160 }, +{ "MediumAquamarine", 102, 205, 170 }, +{ "aquamarine", 127, 255, 212 }, +{ "DarkGreen", 0, 100, 0 }, +{ "DarkOliveGreen", 85, 107, 47 }, +{ "DarkSeaGreen", 143, 188, 143 }, +{ "SeaGreen", 46, 139, 87 }, +{ "MediumSeaGreen", 60, 179, 113 }, +{ "LightSeaGreen", 32, 178, 170 }, +{ "PaleGreen", 152, 251, 152 }, +{ "SpringGreen", 0, 255, 127 }, +{ "LawnGreen", 124, 252, 0 }, +{ "green", 0, 255, 0 }, +{ "chartreuse", 127, 255, 0 }, +{ "MediumSpringGreen", 0, 250, 154 }, +{ "GreenYellow", 173, 255 , 47 }, +{ "LimeGreen", 50, 205, 50 }, +{ "YellowGreen", 154, 205, 50 }, +{ "ForestGreen", 34, 139, 34 }, +{ "OliveDrab", 107, 142, 35 }, +{ "DarkKhaki", 189, 183, 107 }, +{ "khaki", 240, 230, 140 }, +{ "PaleGoldenrod", 238, 232, 170 }, +{ "LightGoldenrodYellow", 250, 250, 210 }, +{ "LightYellow", 255, 255, 224 }, +{ "yellow", 255, 255, 0 }, +{ "gold", 255, 215, 0 }, +{ "LightGoldenrod", 238, 221, 130 }, +{ "goldenrod", 218, 165, 32 }, +{ "DarkGoldenrod", 184, 134, 11 }, +{ "RosyBrown", 188, 143, 143 }, +{ "IndianRed", 205, 92, 92 }, +{ "SaddleBrown", 139, 69, 19 }, +{ "sienna", 160, 82, 45 }, +{ "peru", 205, 133, 63 }, +{ "burlywood", 222, 184, 135 }, +{ "beige", 245, 245, 220 }, +{ "wheat", 245, 222, 179 }, +{ "SandyBrown", 244, 164, 96 }, +{ "tan", 210, 180, 140 }, +{ "chocolate", 210, 105, 30 }, +{ "firebrick", 178, 34, 34 }, +{ "brown", 165, 42, 42 }, +{ "DarkSalmon", 233, 150, 122 }, +{ "salmon", 250, 128, 114 }, +{ "LightSalmon", 255, 160, 122 }, +{ "orange", 255, 165, 0 }, +{ "DarkOrange", 255, 140, 0 }, +{ "coral", 255, 127, 80 }, +{ "LightCoral", 240, 128, 128 }, +{ "tomato", 255, 99, 71 }, +{ "OrangeRed", 255, 69, 0 }, +{ "red", 255, 0, 0 }, +{ "HotPink", 255, 105, 180 }, +{ "DeepPink", 255, 20, 147 }, +{ "pink", 255, 192, 203 }, +{ "LightPink", 255, 182, 193 }, +{ "PaleVioletRed", 219, 112, 147 }, +{ "maroon", 176, 48, 96 }, +{ "MediumVioletRed", 199, 21, 133 }, +{ "VioletRed", 208, 32, 144 }, +{ "magenta", 255, 0, 255 }, +{ "violet", 238, 130, 238 }, +{ "plum", 221, 160, 221 }, +{ "orchid", 218, 112, 214 }, +{ "MediumOrchid", 186, 85, 211 }, +{ "DarkOrchid", 153, 50, 204 }, +{ "DarkViolet", 148, 0, 211 }, +{ "BlueViolet", 138, 43, 226 }, +{ "purple", 160, 32, 240 }, +{ "MediumPurple", 147, 112, 219 }, +{ "thistle", 216, 191, 216 }, +{ "snow1", 255, 250, 250 }, +{ "snow2", 238, 233, 233 }, +{ "snow3", 205, 201, 201 }, +{ "snow4", 139, 137, 137 }, +{ "seashell1", 255, 245, 238 }, +{ "seashell2", 238, 229, 222 }, +{ "seashell3", 205, 197, 191 }, +{ "seashell4", 139, 134, 130 }, +{ "AntiqueWhite1", 255, 239, 219 }, +{ "AntiqueWhite2", 238, 223, 204 }, +{ "AntiqueWhite3", 205, 192, 176 }, +{ "AntiqueWhite4", 139, 131, 120 }, +{ "bisque1", 255, 228, 196 }, +{ "bisque2", 238, 213, 183 }, +{ "bisque3", 205, 183, 158 }, +{ "bisque4", 139, 125, 107 }, +{ "PeachPuff1", 255, 218, 185 }, +{ "PeachPuff2", 238, 203, 173 }, +{ "PeachPuff3", 205, 175, 149 }, +{ "PeachPuff4", 139, 119, 101 }, +{ "NavajoWhite1", 255, 222, 173 }, +{ "NavajoWhite2", 238, 207, 161 }, +{ "NavajoWhite3", 205, 179, 139 }, +{ "NavajoWhite4", 139, 121, 94 }, +{ "LemonChiffon1", 255, 250, 205 }, +{ "LemonChiffon2", 238, 233, 191 }, +{ "LemonChiffon3", 205, 201, 165 }, +{ "LemonChiffon4", 139, 137, 112 }, +{ "cornsilk1", 255, 248, 220 }, +{ "cornsilk2", 238, 232, 205 }, +{ "cornsilk3", 205, 200, 177 }, +{ "cornsilk4", 139, 136, 120 }, +{ "ivory1", 255, 255, 240 }, +{ "ivory2", 238, 238, 224 }, +{ "ivory3", 205, 205, 193 }, +{ "ivory4", 139, 139, 131 }, +{ "honeydew1", 240, 255, 240 }, +{ "honeydew2", 224, 238, 224 }, +{ "honeydew3", 193, 205, 193 }, +{ "honeydew4", 131, 139, 131 }, +{ "LavenderBlush1", 255, 240, 245 }, +{ "LavenderBlush2", 238, 224, 229 }, +{ "LavenderBlush3", 205, 193, 197 }, +{ "LavenderBlush4", 139, 131, 134 }, +{ "MistyRose1", 255, 228, 225 }, +{ "MistyRose2", 238, 213, 210 }, +{ "MistyRose3", 205, 183, 181 }, +{ "MistyRose4", 139, 125, 123 }, +{ "azure1", 240, 255, 255 }, +{ "azure2", 224, 238, 238 }, +{ "azure3", 193, 205, 205 }, +{ "azure4", 131, 139, 139 }, +{ "SlateBlue1", 131, 111, 255 }, +{ "SlateBlue2", 122, 103, 238 }, +{ "SlateBlue3", 105, 89, 205 }, +{ "SlateBlue4", 71, 60, 139 }, +{ "RoyalBlue1", 72, 118, 255 }, +{ "RoyalBlue2", 67, 110, 238 }, +{ "RoyalBlue3", 58, 95, 205 }, +{ "RoyalBlue4", 39, 64, 139 }, +{ "blue1", 0, 0, 255 }, +{ "blue2", 0, 0, 238 }, +{ "blue3", 0, 0, 205 }, +{ "blue4", 0, 0, 139 }, +{ "DodgerBlue1", 30, 144, 255 }, +{ "DodgerBlue2", 28, 134, 238 }, +{ "DodgerBlue3", 24, 116, 205 }, +{ "DodgerBlue4", 16, 78, 139 }, +{ "SteelBlue1", 99, 184, 255 }, +{ "SteelBlue2", 92, 172, 238 }, +{ "SteelBlue3", 79, 148, 205 }, +{ "SteelBlue4", 54, 100, 139 }, +{ "DeepSkyBlue1", 0, 191, 255 }, +{ "DeepSkyBlue2", 0, 178, 238 }, +{ "DeepSkyBlue3", 0, 154, 205 }, +{ "DeepSkyBlue4", 0, 104, 139 }, +{ "SkyBlue1", 135, 206, 255 }, +{ "SkyBlue2", 126, 192, 238 }, +{ "SkyBlue3", 108, 166, 205 }, +{ "SkyBlue4", 74, 112, 139 }, +{ "LightSkyBlue1", 176, 226, 255 }, +{ "LightSkyBlue2", 164, 211, 238 }, +{ "LightSkyBlue3", 141, 182, 205 }, +{ "LightSkyBlue4", 96, 123, 139 }, +{ "SlateGray1", 198, 226, 255 }, +{ "SlateGray2", 185, 211, 238 }, +{ "SlateGray3", 159, 182, 205 }, +{ "SlateGray4", 108, 123, 139 }, +{ "LightSteelBlue1", 202, 225, 255 }, +{ "LightSteelBlue2", 188, 210, 238 }, +{ "LightSteelBlue3", 162, 181, 205 }, +{ "LightSteelBlue4", 110, 123, 139 }, +{ "LightBlue1", 191, 239, 255 }, +{ "LightBlue2", 178, 223, 238 }, +{ "LightBlue3", 154, 192, 205 }, +{ "LightBlue4", 104, 131, 139 }, +{ "LightCyan1", 224, 255, 255 }, +{ "LightCyan2", 209, 238, 238 }, +{ "LightCyan3", 180, 205, 205 }, +{ "LightCyan4", 122, 139, 139 }, +{ "PaleTurquoise1", 187, 255, 255 }, +{ "PaleTurquoise2", 174, 238, 238 }, +{ "PaleTurquoise3", 150, 205, 205 }, +{ "PaleTurquoise4", 102, 139, 139 }, +{ "CadetBlue1", 152, 245, 255 }, +{ "CadetBlue2", 142, 229, 238 }, +{ "CadetBlue3", 122, 197, 205 }, +{ "CadetBlue4", 83, 134, 139 }, +{ "turquoise1", 0, 245, 255 }, +{ "turquoise2", 0, 229, 238 }, +{ "turquoise3", 0, 197, 205 }, +{ "turquoise4", 0, 134, 139 }, +{ "cyan1", 0, 255, 255 }, +{ "cyan2", 0, 238, 238 }, +{ "cyan3", 0, 205, 205 }, +{ "cyan4", 0, 139, 139 }, +{ "DarkSlateGray1", 151, 255, 255 }, +{ "DarkSlateGray2", 141, 238, 238 }, +{ "DarkSlateGray3", 121, 205, 205 }, +{ "DarkSlateGray4", 82, 139, 139 }, +{ "aquamarine1", 127, 255, 212 }, +{ "aquamarine2", 118, 238, 198 }, +{ "aquamarine3", 102, 205, 170 }, +{ "aquamarine4", 69, 139, 116 }, +{ "DarkSeaGreen1", 193, 255, 193 }, +{ "DarkSeaGreen2", 180, 238, 180 }, +{ "DarkSeaGreen3", 155, 205, 155 }, +{ "DarkSeaGreen4", 105, 139, 105 }, +{ "SeaGreen1", 84, 255, 159 }, +{ "SeaGreen2", 78, 238, 148 }, +{ "SeaGreen3", 67, 205, 128 }, +{ "SeaGreen4", 46, 139, 87 }, +{ "PaleGreen1", 154, 255, 154 }, +{ "PaleGreen2", 144, 238, 144 }, +{ "PaleGreen3", 124, 205, 124 }, +{ "PaleGreen4", 84, 139, 84 }, +{ "SpringGreen1", 0, 255, 127 }, +{ "SpringGreen2", 0, 238, 118 }, +{ "SpringGreen3", 0, 205, 102 }, +{ "SpringGreen4", 0, 139, 69 }, +{ "green1", 0, 255, 0 }, +{ "green2", 0, 238, 0 }, +{ "green3", 0, 205, 0 }, +{ "green4", 0, 139, 0 }, +{ "chartreuse1", 127, 255, 0 }, +{ "chartreuse2", 118, 238, 0 }, +{ "chartreuse3", 102, 205, 0 }, +{ "chartreuse4", 69, 139, 0 }, +{ "OliveDrab1", 192, 255, 62 }, +{ "OliveDrab2", 179, 238, 58 }, +{ "OliveDrab3", 154, 205, 50 }, +{ "OliveDrab4", 105, 139, 34 }, +{ "DarkOliveGreen1", 202, 255, 112 }, +{ "DarkOliveGreen2", 188, 238, 104 }, +{ "DarkOliveGreen3", 162, 205, 90 }, +{ "DarkOliveGreen4", 110, 139, 61 }, +{ "khaki1", 255, 246, 143 }, +{ "khaki2", 238, 230, 133 }, +{ "khaki3", 205, 198, 115 }, +{ "khaki4", 139, 134, 78 }, +{ "LightGoldenrod1", 255, 236, 139 }, +{ "LightGoldenrod2", 238, 220, 130 }, +{ "LightGoldenrod3", 205, 190, 112 }, +{ "LightGoldenrod4", 139, 129, 76 }, +{ "LightYellow1", 255, 255, 224 }, +{ "LightYellow2", 238, 238, 209 }, +{ "LightYellow3", 205, 205, 180 }, +{ "LightYellow4", 139, 139, 122 }, +{ "yellow1", 255, 255, 0 }, +{ "yellow2", 238, 238, 0 }, +{ "yellow3", 205, 205, 0 }, +{ "yellow4", 139, 139, 0 }, +{ "gold1", 255, 215, 0 }, +{ "gold2", 238, 201, 0 }, +{ "gold3", 205, 173, 0 }, +{ "gold4", 139, 117, 0 }, +{ "goldenrod1", 255, 193, 37 }, +{ "goldenrod2", 238, 180, 34 }, +{ "goldenrod3", 205, 155, 29 }, +{ "goldenrod4", 139, 105, 20 }, +{ "DarkGoldenrod1", 255, 185, 15 }, +{ "DarkGoldenrod2", 238, 173, 14 }, +{ "DarkGoldenrod3", 205, 149, 12 }, +{ "DarkGoldenrod4", 139, 101, 8 }, +{ "RosyBrown1", 255, 193, 193 }, +{ "RosyBrown2", 238, 180, 180 }, +{ "RosyBrown3", 205, 155, 155 }, +{ "RosyBrown4", 139, 105, 105 }, +{ "IndianRed1", 255, 106, 106 }, +{ "IndianRed2", 238, 99, 99 }, +{ "IndianRed3", 205, 85, 85 }, +{ "IndianRed4", 139, 58, 58 }, +{ "sienna1", 255, 130, 71 }, +{ "sienna2", 238, 121, 66 }, +{ "sienna3", 205, 104, 57 }, +{ "sienna4", 139, 71, 38 }, +{ "burlywood1", 255, 211, 155 }, +{ "burlywood2", 238, 197, 145 }, +{ "burlywood3", 205, 170, 125 }, +{ "burlywood4", 139, 115, 85 }, +{ "wheat1", 255, 231, 186 }, +{ "wheat2", 238, 216, 174 }, +{ "wheat3", 205, 186, 150 }, +{ "wheat4", 139, 126, 102 }, +{ "tan1", 255, 165, 79 }, +{ "tan2", 238, 154, 73 }, +{ "tan3", 205, 133, 63 }, +{ "tan4", 139 , 90, 43 }, +{ "chocolate1", 255, 127, 36 }, +{ "chocolate2", 238, 118, 33 }, +{ "chocolate3", 205, 102, 29 }, +{ "chocolate4", 139, 69, 19 }, +{ "firebrick1", 255, 48, 48 }, +{ "firebrick2", 238, 44, 44 }, +{ "firebrick3", 205, 38, 38 }, +{ "firebrick4", 139, 26, 26 }, +{ "brown1", 255, 64, 64 }, +{ "brown2", 238, 59, 59 }, +{ "brown3", 205, 51, 51 }, +{ "brown4", 139, 35, 35 }, +{ "salmon1", 255, 140, 105 }, +{ "salmon2", 238, 130, 98 }, +{ "salmon3", 205, 112, 84 }, +{ "salmon4", 139, 76, 57 }, +{ "LightSalmon1", 255, 160, 122 }, +{ "LightSalmon2", 238, 149, 114 }, +{ "LightSalmon3", 205, 129, 98 }, +{ "LightSalmon4", 139, 87, 66 }, +{ "orange1", 255, 165, 0 }, +{ "orange2", 238, 154, 0 }, +{ "orange3", 205, 133, 0 }, +{ "orange4", 139 , 90, 0 }, +{ "DarkOrange1", 255, 127, 0 }, +{ "DarkOrange2", 238, 118, 0 }, +{ "DarkOrange3", 205, 102, 0 }, +{ "DarkOrange4", 139 , 69, 0 }, +{ "coral1", 255, 114, 86 }, +{ "coral2", 238, 106, 80 }, +{ "coral3", 205, 91, 69 }, +{ "coral4", 139, 62, 47 }, +{ "tomato1", 255, 99, 71 }, +{ "tomato2", 238, 92, 66 }, +{ "tomato3", 205, 79, 57 }, +{ "tomato4", 139, 54, 38 }, +{ "OrangeRed1", 255, 69, 0 }, +{ "OrangeRed2", 238, 64, 0 }, +{ "OrangeRed3", 205, 55, 0 }, +{ "OrangeRed4", 139, 37, 0 }, +{ "red1", 255, 0, 0 }, +{ "red2", 238, 0, 0 }, +{ "red3", 205, 0, 0 }, +{ "red4", 139, 0, 0 }, +{ "DeepPink1", 255, 20, 147 }, +{ "DeepPink2", 238, 18, 137 }, +{ "DeepPink3", 205, 16, 118 }, +{ "DeepPink4", 139, 10, 80 }, +{ "HotPink1", 255, 110, 180 }, +{ "HotPink2", 238, 106, 167 }, +{ "HotPink3", 205, 96, 144 }, +{ "HotPink4", 139, 58, 98 }, +{ "pink1", 255, 181, 197 }, +{ "pink2", 238, 169, 184 }, +{ "pink3", 205, 145, 158 }, +{ "pink4", 139, 99, 108 }, +{ "LightPink1", 255, 174, 185 }, +{ "LightPink2", 238, 162, 173 }, +{ "LightPink3", 205, 140, 149 }, +{ "LightPink4", 139, 95, 101 }, +{ "PaleVioletRed1", 255, 130, 171 }, +{ "PaleVioletRed2", 238, 121, 159 }, +{ "PaleVioletRed3", 205, 104, 137 }, +{ "PaleVioletRed4", 139, 71, 93 }, +{ "maroon1", 255, 52, 179 }, +{ "maroon2", 238, 48, 167 }, +{ "maroon3", 205, 41, 144 }, +{ "maroon4", 139, 28, 98 }, +{ "VioletRed1", 255, 62, 150 }, +{ "VioletRed2", 238, 58, 140 }, +{ "VioletRed3", 205, 50, 120 }, +{ "VioletRed4", 139, 34, 82 }, +{ "magenta1", 255, 0, 255 }, +{ "magenta2", 238, 0, 238 }, +{ "magenta3", 205, 0, 205 }, +{ "magenta4", 139, 0, 139 }, +{ "orchid1", 255, 131, 250 }, +{ "orchid2", 238, 122, 233 }, +{ "orchid3", 205, 105, 201 }, +{ "orchid4", 139, 71, 137 }, +{ "plum1", 255, 187, 255 }, +{ "plum2", 238, 174, 238 }, +{ "plum3", 205, 150, 205 }, +{ "plum4", 139, 102, 139 }, +{ "MediumOrchid1", 224, 102, 255 }, +{ "MediumOrchid2", 209, 95, 238 }, +{ "MediumOrchid3", 180, 82, 205 }, +{ "MediumOrchid4", 122, 55, 139 }, +{ "DarkOrchid1", 191, 62, 255 }, +{ "DarkOrchid2", 178, 58, 238 }, +{ "DarkOrchid3", 154, 50, 205 }, +{ "DarkOrchid4", 104, 34, 139 }, +{ "purple1", 155, 48, 255 }, +{ "purple2", 145, 44, 238 }, +{ "purple3", 125, 38, 205 }, +{ "purple4", 85, 26, 139 }, +{ "MediumPurple1", 171, 130, 255 }, +{ "MediumPurple2", 159, 121, 238 }, +{ "MediumPurple3", 137, 104, 205 }, +{ "MediumPurple4", 93, 71, 139 }, +{ "thistle1", 255, 225, 255 }, +{ "thistle2", 238, 210, 238 }, +{ "thistle3", 205, 181, 205 }, +{ "thistle4", 139, 123, 139 }, +{ "gray0", 0, 0, 0 }, +{ "grey0", 0, 0, 0 }, +{ "gray1", 3, 3, 3 }, +{ "grey1", 3, 3, 3 }, +{ "gray2", 5, 5, 5 }, +{ "grey2", 5, 5, 5 }, +{ "gray3", 8, 8, 8 }, +{ "grey3", 8, 8, 8 }, +{ "gray4", 10, 10, 10 }, +{ "grey4", 10, 10, 10 }, +{ "gray5", 13, 13, 13 }, +{ "grey5", 13, 13, 13 }, +{ "gray6", 15, 15, 15 }, +{ "grey6", 15, 15, 15 }, +{ "gray7", 18, 18, 18 }, +{ "grey7", 18, 18, 18 }, +{ "gray8", 20, 20, 20 }, +{ "grey8", 20, 20, 20 }, +{ "gray9", 23, 23, 23 }, +{ "grey9", 23, 23, 23 }, +{ "gray10", 26, 26, 26 }, +{ "grey10", 26, 26, 26 }, +{ "gray11", 28, 28, 28 }, +{ "grey11", 28, 28, 28 }, +{ "gray12", 31, 31, 31 }, +{ "grey12", 31, 31, 31 }, +{ "gray13", 33, 33, 33 }, +{ "grey13", 33, 33, 33 }, +{ "gray14", 36, 36, 36 }, +{ "grey14", 36, 36, 36 }, +{ "gray15", 38, 38, 38 }, +{ "grey15", 38, 38, 38 }, +{ "gray16", 41, 41, 41 }, +{ "grey16", 41, 41, 41 }, +{ "gray17", 43, 43, 43 }, +{ "grey17", 43, 43, 43 }, +{ "gray18", 46, 46, 46 }, +{ "grey18", 46, 46, 46 }, +{ "gray19", 48, 48, 48 }, +{ "grey19", 48, 48, 48 }, +{ "gray20", 51, 51, 51 }, +{ "grey20", 51, 51, 51 }, +{ "gray21", 54, 54, 54 }, +{ "grey21", 54, 54, 54 }, +{ "gray22", 56, 56, 56 }, +{ "grey22", 56, 56, 56 }, +{ "gray23", 59, 59, 59 }, +{ "grey23", 59, 59, 59 }, +{ "gray24", 61, 61, 61 }, +{ "grey24", 61, 61, 61 }, +{ "gray25", 64, 64, 64 }, +{ "grey25", 64, 64, 64 }, +{ "gray26", 66, 66, 66 }, +{ "grey26", 66, 66, 66 }, +{ "gray27", 69, 69, 69 }, +{ "grey27", 69, 69, 69 }, +{ "gray28", 71, 71, 71 }, +{ "grey28", 71, 71, 71 }, +{ "gray29", 74, 74, 74 }, +{ "grey29", 74, 74, 74 }, +{ "gray30", 77, 77, 77 }, +{ "grey30", 77, 77, 77 }, +{ "gray31", 79, 79, 79 }, +{ "grey31", 79, 79, 79 }, +{ "gray32", 82, 82, 82 }, +{ "grey32", 82, 82, 82 }, +{ "gray33", 84, 84, 84 }, +{ "grey33", 84, 84, 84 }, +{ "gray34", 87, 87, 87 }, +{ "grey34", 87, 87, 87 }, +{ "gray35", 89, 89, 89 }, +{ "grey35", 89, 89, 89 }, +{ "gray36", 92, 92, 92 }, +{ "grey36", 92, 92, 92 }, +{ "gray37", 94, 94, 94 }, +{ "grey37", 94, 94, 94 }, +{ "gray38", 97, 97, 97 }, +{ "grey38", 97, 97, 97 }, +{ "gray39", 99, 99, 99 }, +{ "grey39", 99, 99, 99 }, +{ "gray40", 102, 102, 102 }, +{ "grey40", 102, 102, 102 }, +{ "gray41", 105, 105, 105 }, +{ "grey41", 105, 105, 105 }, +{ "gray42", 107, 107, 107 }, +{ "grey42", 107, 107, 107 }, +{ "gray43", 110, 110, 110 }, +{ "grey43", 110, 110, 110 }, +{ "gray44", 112, 112, 112 }, +{ "grey44", 112, 112, 112 }, +{ "gray45", 115, 115, 115 }, +{ "grey45", 115, 115, 115 }, +{ "gray46", 117, 117, 117 }, +{ "grey46", 117, 117, 117 }, +{ "gray47", 120, 120, 120 }, +{ "grey47", 120, 120, 120 }, +{ "gray48", 122, 122, 122 }, +{ "grey48", 122, 122, 122 }, +{ "gray49", 125, 125, 125 }, +{ "grey49", 125, 125, 125 }, +{ "gray50", 127, 127, 127 }, +{ "grey50", 127, 127, 127 }, +{ "gray51", 130, 130, 130 }, +{ "grey51", 130, 130, 130 }, +{ "gray52", 133, 133, 133 }, +{ "grey52", 133, 133, 133 }, +{ "gray53", 135, 135, 135 }, +{ "grey53", 135, 135, 135 }, +{ "gray54", 138, 138, 138 }, +{ "grey54", 138, 138, 138 }, +{ "gray55", 140, 140, 140 }, +{ "grey55", 140, 140, 140 }, +{ "gray56", 143, 143, 143 }, +{ "grey56", 143, 143, 143 }, +{ "gray57", 145, 145, 145 }, +{ "grey57", 145, 145, 145 }, +{ "gray58", 148, 148, 148 }, +{ "grey58", 148, 148, 148 }, +{ "gray59", 150, 150, 150 }, +{ "grey59", 150, 150, 150 }, +{ "gray60", 153, 153, 153 }, +{ "grey60", 153, 153, 153 }, +{ "gray61", 156, 156, 156 }, +{ "grey61", 156, 156, 156 }, +{ "gray62", 158, 158, 158 }, +{ "grey62", 158, 158, 158 }, +{ "gray63", 161, 161, 161 }, +{ "grey63", 161, 161, 161 }, +{ "gray64", 163, 163, 163 }, +{ "grey64", 163, 163, 163 }, +{ "gray65", 166, 166, 166 }, +{ "grey65", 166, 166, 166 }, +{ "gray66", 168, 168, 168 }, +{ "grey66", 168, 168, 168 }, +{ "gray67", 171, 171, 171 }, +{ "grey67", 171, 171, 171 }, +{ "gray68", 173, 173, 173 }, +{ "grey68", 173, 173, 173 }, +{ "gray69", 176, 176, 176 }, +{ "grey69", 176, 176, 176 }, +{ "gray70", 179, 179, 179 }, +{ "grey70", 179, 179, 179 }, +{ "gray71", 181, 181, 181 }, +{ "grey71", 181, 181, 181 }, +{ "gray72", 184, 184, 184 }, +{ "grey72", 184, 184, 184 }, +{ "gray73", 186, 186, 186 }, +{ "grey73", 186, 186, 186 }, +{ "gray74", 189, 189, 189 }, +{ "grey74", 189, 189, 189 }, +{ "gray75", 191, 191, 191 }, +{ "grey75", 191, 191, 191 }, +{ "gray76", 194, 194, 194 }, +{ "grey76", 194, 194, 194 }, +{ "gray77", 196, 196, 196 }, +{ "grey77", 196, 196, 196 }, +{ "gray78", 199, 199, 199 }, +{ "grey78", 199, 199, 199 }, +{ "gray79", 201, 201, 201 }, +{ "grey79", 201, 201, 201 }, +{ "gray80", 204, 204, 204 }, +{ "grey80", 204, 204, 204 }, +{ "gray81", 207, 207, 207 }, +{ "grey81", 207, 207, 207 }, +{ "gray82", 209, 209, 209 }, +{ "grey82", 209, 209, 209 }, +{ "gray83", 212, 212, 212 }, +{ "grey83", 212, 212, 212 }, +{ "gray84", 214, 214, 214 }, +{ "grey84", 214, 214, 214 }, +{ "gray85", 217, 217, 217 }, +{ "grey85", 217, 217, 217 }, +{ "gray86", 219, 219, 219 }, +{ "grey86", 219, 219, 219 }, +{ "gray87", 222, 222, 222 }, +{ "grey87", 222, 222, 222 }, +{ "gray88", 224, 224, 224 }, +{ "grey88", 224, 224, 224 }, +{ "gray89", 227, 227, 227 }, +{ "grey89", 227, 227, 227 }, +{ "gray90", 229, 229, 229 }, +{ "grey90", 229, 229, 229 }, +{ "gray91", 232, 232, 232 }, +{ "grey91", 232, 232, 232 }, +{ "gray92", 235, 235, 235 }, +{ "grey92", 235, 235, 235 }, +{ "gray93", 237, 237, 237 }, +{ "grey93", 237, 237, 237 }, +{ "gray94", 240, 240, 240 }, +{ "grey94", 240, 240, 240 }, +{ "gray95", 242, 242, 242 }, +{ "grey95", 242, 242, 242 }, +{ "gray96", 245, 245, 245 }, +{ "grey96", 245, 245, 245 }, +{ "gray97", 247, 247, 247 }, +{ "grey97", 247, 247, 247 }, +{ "gray98", 250, 250, 250 }, +{ "grey98", 250, 250, 250 }, +{ "gray99", 252, 252, 252 }, +{ "grey99", 252, 252, 252 }, +{ "gray100", 255, 255, 255 }, +{ "grey100", 255, 255, 255 }, +{ "DarkGrey", 169, 169, 169 }, +{ "DarkGray", 169, 169, 169 }, +{ "DarkBlue", 0, 0, 139 }, +{ "DarkCyan", 0, 139, 139 }, +{ "DarkMagenta", 139, 0, 139 }, +{ "DarkRed", 139, 0, 0 }, +{ "LightGreen", 144, 238, 144 }, +{ NULL, 0 , 0, 0} +}; diff --git a/svtools/source/filter.vcl/ixpm/xpmread.cxx b/svtools/source/filter.vcl/ixpm/xpmread.cxx new file mode 100644 index 000000000000..af267eb0d961 --- /dev/null +++ b/svtools/source/filter.vcl/ixpm/xpmread.cxx @@ -0,0 +1,714 @@ +/************************************************************************* + * + * $RCSfile: xpmread.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:59:00 $ + * + * 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 _BMPACC_HXX +#include <vcl/bmpacc.hxx> +#endif +#ifndef _GRAPH_HXX +#include <vcl/graph.hxx> +#endif +#include "rgbtable.hxx" +#define _XPMPRIVATE +#include "xpmread.hxx" + +// ------------- +// - XPMReader - +// ------------- + +XPMReader::XPMReader( SvStream& rStm, void* pCallData ) : + mrIStm ( rStm ), + mnIdentifier ( XPMIDENTIFIER ), + mnTempAvail ( 0 ), + mnStatus ( 0 ), + mbTransparent ( FALSE ), + mnCpp ( 0 ), + mnWidth ( 0 ), + mnHeight ( 0 ), + mnColors ( 0 ), + mcThisByte ( 0 ), + mnLastPos ( rStm.Tell() ), + mpFastColorTable( NULL ), + mpColMap ( NULL ), + mpAcc ( NULL ), + mpMaskAcc ( NULL ), + mbStatus ( TRUE ) +{ + +} + +// ------------------------------------------------------------------------ + +XPMReader::~XPMReader() +{ + if( mpAcc ) + maBmp.ReleaseAccess( mpAcc ); +} + +// ------------------------------------------------------------------------ + +#ifdef WNT +#pragma optimize ("",off) +#endif + +ReadState XPMReader::ReadXPM( Graphic& rGraphic ) +{ + ReadState eReadState; + BYTE cDummy; + + // sehen, ob wir _alles_ lesen koennen + mrIStm.Seek( STREAM_SEEK_TO_END ); + mrIStm >> cDummy; + + // falls wir nicht alles lesen koennen + // kehren wir zurueck und warten auf neue Daten + if ( mrIStm.GetError() != ERRCODE_IO_PENDING ) + { + mrIStm.Seek( mnLastPos ); + mbStatus = TRUE; + + if ( mbStatus ) + { + mpStringBuf = new BYTE [ XPMSTRINGBUF ]; + mpTempBuf = new BYTE [ XPMTEMPBUFSIZE ]; + + if ( ( mbStatus = ImplGetString() ) == TRUE ) + { + mnIdentifier = XPMVALUES; // Bitmap informationen einholen + mnWidth = ImplGetULONG( 0 ); + mnHeight = ImplGetULONG( 1 ); + mnColors = ImplGetULONG( 2 ); + mnCpp = ImplGetULONG( 3 ); + } + if ( mbStatus && mnWidth && mnHeight && mnColors && mnCpp ) + { + mnIdentifier = XPMCOLORS; + + // mpColMap beinhaltet für jede vorhandene + // Farbe: ( mnCpp )Byte(s)-> ASCII Eintrag der der Farbe zugeordnet ist + // 1 Byte -> 0xff wenn Farbe transparent ist + // 3 Bytes -> RGB Wert der Farbe + mpColMap = new BYTE[ mnColors * ( 4 + mnCpp ) ]; + + for ( ULONG i = 0; i < mnColors; i++ ) + { + if ( ImplGetColor( i ) == FALSE ) + { + mbStatus = FALSE; + break; + } + } + if ( mbStatus ) + { + // bei mehr als 256 Farben wird eine 24 Bit Grafik erstellt + maBmp = Bitmap( Size( mnWidth, mnHeight ), ( mnColors > 256 ) ? 24 : 8 ); + mpAcc = maBmp.AcquireWriteAccess(); + + // mbTransparent ist TRUE wenn mindestens eine Farbe Transparent ist + if ( mbTransparent ) + { + maMaskBmp = Bitmap( Size( mnWidth, mnHeight ), 1 ); + if ( ( mpMaskAcc = maMaskBmp.AcquireWriteAccess() ) == NULL ) + mbStatus = FALSE; + } + if( mpAcc && mbStatus ) + { + ULONG i; + if ( mnColors <=256 ) // palette is only needed by using less than 257 + { // colors + + BYTE* pPtr = &mpColMap[mnCpp]; + + for ( i = 0; i < mnColors; i++ ) + { + mpAcc->SetPaletteColor( (BYTE)i, Color( pPtr[1], pPtr[2], pPtr[3] ) ); + pPtr += ( mnCpp + 4 ); + } + // using 2 charakters per pixel and less than 257 Colors we speed up + if ( mnCpp == 2 ) // by using a 64kb indexing table + { + mpFastColorTable = new BYTE[ 256 * 256 ]; + for ( pPtr = mpColMap, i = 0; i < mnColors; i++, pPtr += mnCpp + 4 ) + { + ULONG j = pPtr[ 0 ] << 8; + j += pPtr[ 1 ]; + mpFastColorTable[ j ] = (BYTE)i; + } + } + } + // now we get the bitmap data + mnIdentifier = XPMPIXELS; + for ( i = 0; i < mnHeight; i++ ) + { + if ( ImplGetScanLine( i ) == FALSE ) + { + mbStatus = FALSE; + break; + } + } + mnIdentifier = XPMEXTENSIONS; + } + } + } + + delete[] mpFastColorTable; + delete[] mpColMap; + delete[] mpStringBuf; + delete[] mpTempBuf; + + } + if( mbStatus ) + { + if ( mpMaskAcc ) + { + maMaskBmp.ReleaseAccess ( mpMaskAcc), mpMaskAcc = NULL; + maBmp.ReleaseAccess( mpAcc ), mpAcc = NULL; + rGraphic = Graphic( BitmapEx( maBmp, maMaskBmp ) ); + } + else + { + maBmp.ReleaseAccess( mpAcc ), mpAcc = NULL; + rGraphic = maBmp; + } + eReadState = XPMREAD_OK; + } + else + { + if ( mpMaskAcc ) maMaskBmp.ReleaseAccess ( mpMaskAcc), mpMaskAcc = NULL; + if ( mpAcc ) maBmp.ReleaseAccess( mpAcc ), mpAcc = NULL; + eReadState = XPMREAD_ERROR; + } + } + else + { + mrIStm.ResetError(); + eReadState = XPMREAD_NEED_MORE; + } + return eReadState; +} + +#ifdef WNT +#pragma optimize ("",on) +#endif + +// ------------------------------------------------------------------------ +// ImplGetColor ermittelt sämtliche Farbwerte, +// die Rückgabe ist TRUE wenn sämtliche Farben zugeordnet werden konnten + +BOOL XPMReader::ImplGetColor( ULONG nNumb ) +{ + BYTE* pString = mpStringBuf; + BYTE* pPtr = ( mpColMap + nNumb * ( 4 + mnCpp ) ); + BOOL bStatus = ImplGetString(); + + if ( bStatus ) + { + for ( ULONG i = 0; i < mnCpp; i++ ) + *pPtr++ = *pString++; + bStatus = ImplGetColSub ( pPtr ); + } + return bStatus; +} + +// ------------------------------------------------------------------------ +// ImpGetScanLine liest den String mpBufSize aus und schreibt die Pixel in die +// Bitmap. Der Parameter nY gibt die horizontale Position an. + +BOOL XPMReader::ImplGetScanLine( ULONG nY ) +{ + BOOL bStatus = ImplGetString(); + BYTE* pString = mpStringBuf; + BYTE* pColor; + BitmapColor aWhite; + BitmapColor aBlack; + + if ( bStatus ) + { + if ( mpMaskAcc ) + { + aWhite = mpMaskAcc->GetBestMatchingColor( Color( COL_WHITE ) ); + aBlack = mpMaskAcc->GetBestMatchingColor( Color( COL_BLACK ) ); + } + if ( mnStringSize != ( mnWidth * mnCpp )) + bStatus = FALSE; + else + { + ULONG i, j; + if ( mpFastColorTable ) + { + for ( i = 0; i < mnWidth; i++ ) + { + j = (*pString++) << 8; + j += *pString++; + BYTE k = (BYTE)mpFastColorTable[ j ]; + mpAcc->SetPixel( nY, i, BitmapColor( (BYTE)k ) ); + + if ( mpMaskAcc ) + mpMaskAcc->SetPixel( nY, i, + ( mpColMap[ k * (mnCpp + 4) + mnCpp] ) ? aWhite : aBlack ); + } + } + else for ( i = 0; i < mnWidth; i++ ) + { + pColor = mpColMap; + for ( j = 0; j < mnColors; j++ ) + { + if ( ImplCompare( pString, pColor, mnCpp, XPMCASESENSITIVE ) == TRUE ) + { + if ( mnColors > 256 ) + mpAcc->SetPixel( nY, i, Color ( pColor[3], pColor[4], pColor[5] ) ); + else + mpAcc->SetPixel( nY, i, BitmapColor( (BYTE) j ) ); + + if ( mpMaskAcc ) + mpMaskAcc->SetPixel( nY, i, ( + pColor[ mnCpp ] ) ? aWhite : aBlack ); + + break; + } + pColor += ( mnCpp + 4 ); + } + pString += mnCpp; + } + + } + } + return bStatus; +} + +// ------------------------------------------------------------------------ +// versucht aus mpStringBuf einen Farbwert zu übermitteln +// wurde eine Farbe gefunden wird an pDest[1]..pDest[2] der RGB wert geschrieben +// pDest[0] enthält 0xff wenn die Farbe transparent ist sonst 0 + +BOOL XPMReader::ImplGetColSub( BYTE* pDest ) +{ + unsigned char cTransparent[] = "None"; + + BOOL bColStatus = FALSE; + + if ( ImplGetColKey( 'c' ) || ImplGetColKey( 'm' ) || ImplGetColKey( 'g' ) ) + { + // hexentry for RGB or HSV color ? + if ( *mpPara == '#' ) + { + *pDest++ = 0; + bColStatus = TRUE; + switch ( mnParaSize ) + { + case 25 : + ImplGetRGBHex ( pDest, 6 ); + break; + case 13 : + ImplGetRGBHex ( pDest, 2 ); + break; + case 7 : + ImplGetRGBHex ( pDest, 0 ); + break; + default: + bColStatus = FALSE; + break; + } + } + // maybe pixel is transparent + else if ( ImplCompare( &cTransparent[0], mpPara, 4 )) + { + *pDest++ = 0xff; + bColStatus = TRUE; + mbTransparent = TRUE; + } + // last we will try to get the colorname + else if ( mnParaSize > 2 ) // name must enlarge the minimum size + { + ULONG i = 0; + while ( TRUE ) + { + if ( pRGBTable[ i ].name == NULL ) + break; + if ( pRGBTable[ i ].name[ mnParaSize ] == 0 ) + { + if ( ImplCompare ( (unsigned char*)pRGBTable[ i ].name, + mpPara, mnParaSize, XPMCASENONSENSITIVE ) ) + { + bColStatus = TRUE; + *pDest++ = 0; + *pDest++ = pRGBTable[ i ].red; + *pDest++ = pRGBTable[ i ].green; + *pDest++ = pRGBTable[ i ].blue; + } + } + i++; + } + } + } + return bColStatus; +} + +// ------------------------------------------------------------------------ +// ImplGetColKey durchsuch den String mpStringBuf nach einem Parameter 'nKey' +// und gibt einen BOOL zurück. ( wenn TRUE werden mpPara und mnParaSize gesetzt ) + +BOOL XPMReader::ImplGetColKey( BYTE nKey ) +{ + BYTE nTemp, nPrev = ' '; + + mpPara = mpStringBuf + mnCpp + 1; + mnParaSize = 0; + + while ( *mpPara != 0 ) + { + if ( *mpPara == nKey ) + { + nTemp = *( mpPara + 1 ); + if ( nTemp == ' ' || nTemp == 0x09 ) + { + if ( nPrev == ' ' || nPrev == 0x09 ) + break; + } + } + nPrev = *mpPara; + *mpPara++; + } + if ( *mpPara ) + { + mpPara++; + while ( (*mpPara == ' ') || (*mpPara == 0x09) ) + { + mpPara++; + } + if ( *mpPara != 0 ) + { + while ( *(mpPara+mnParaSize) != ' ' && *(mpPara+mnParaSize) != 0x09 && + *(mpPara+mnParaSize) != 0 ) + { + mnParaSize++; + } + } + } + return ( mnParaSize ) ? TRUE : FALSE; +} + +// ------------------------------------------------------------------------ +// ImplGetRGBHex übersetzt den ASCII-Hexadezimalwert der sich bei mpPara befindet +// in einen RGB wert und schreibt diesen nach pDest +// folgende Formate müssen sich bei mpPara befinden: +// wenn nAdd = 0 : '#12ab12' -> RGB = 0x12, 0xab, 0x12 +// 2 : '#1234abcd1234' " " " " +// 6 : '#12345678abcdefab12345678' " " " " + + +void XPMReader::ImplGetRGBHex( BYTE* pDest,ULONG nAdd ) +{ + BYTE* pPtr = mpPara+1; + BYTE nHex, nTemp; + + for ( ULONG i = 0; i < 3; i++ ) + { + nHex = (*pPtr++) - '0'; + if ( nHex > 9 ) + nHex = ((nHex - 'A' + '0') & 7) + 10; + + nTemp = (*pPtr++) - '0'; + if ( nTemp > 9 ) + nTemp = ((nTemp - 'A' + '0') & 7) + 10; + nHex = ( nHex << 4 ) + nTemp; + + pPtr += nAdd; + *pDest++ = (BYTE)nHex; + } +} + +// ------------------------------------------------------------------------ +// ImplGetUlong gibt den wert einer bis zu 6stelligen ASCII-Dezimalzahl zurück. + +ULONG XPMReader::ImplGetULONG( ULONG nPara ) +{ + if ( ImplGetPara ( nPara ) ) + { + ULONG nRetValue = 0; + BYTE* pPtr = mpPara; + + if ( ( mnParaSize > 6 ) || ( mnParaSize == 0 ) ) return 0; + for ( ULONG i = 0; i < mnParaSize; i++ ) + { + BYTE j = (*pPtr++) - 48; + if ( j > 9 ) return 0; // ascii is invalid + nRetValue*=10; + nRetValue+=j; + } + return nRetValue; + } + else return 0; +} + +// ------------------------------------------------------------------------ + +BOOL XPMReader::ImplCompare( BYTE* pSource, BYTE* pDest, ULONG nSize, ULONG nMode ) +{ + BOOL bRet = TRUE; + + if ( nMode == XPMCASENONSENSITIVE ) + { + for ( ULONG i = 0; i < nSize; i++ ) + { + if ( ( pSource[i]&~0x20 ) != ( pDest[i]&~0x20 ) ) + { + bRet = FALSE; + break; + } + } + } + else + { + for ( ULONG i = 0; i < nSize; i++ ) + { + if ( pSource[i] != pDest[i] ) + { + bRet = FALSE; + break; + } + } + } + return bRet; +} + +// ------------------------------------------------------------------------ +// ImplGetPara versucht den nNumb ( 0...x ) Parameter aus mpStringBuf zu ermitteln. +// Ein Parameter ist durch Spaces oder Tabs von den anderen getrennt. +// Konnte der Parameter gefunden werden ist der Rückgabewert TRUE und mpPara + mnParaSize +// werden gesetzt. + +BOOL XPMReader::ImplGetPara ( ULONG nNumb ) +{ + BYTE nByte; + ULONG pSize = 0; + BYTE* pPtr = mpStringBuf; + ULONG nCount = 0; + + if ( ( *pPtr != ' ' ) && ( *pPtr != 0x09 ) ) + { + mpPara = pPtr; + mnParaSize = 0; + nCount = 0; + } + else + { + mpPara = NULL; + nCount = 0xffffffff; + } + + while ( pSize < mnStringSize ) + { + nByte = *pPtr; + + if ( mpPara ) + { + if ( ( nByte == ' ' ) || ( nByte == 0x09 ) ) + { + if ( nCount == nNumb ) + break; + else + mpPara = NULL; + } + else + mnParaSize++; + } + else + { + if ( ( nByte != ' ' ) && ( nByte != 0x09 ) ) + { + mpPara = pPtr; + mnParaSize = 1; + nCount++; + } + } + pSize++; + pPtr++; + } + return ( ( nCount == nNumb ) && ( mpPara ) ) ? TRUE : FALSE; +} + +// ------------------------------------------------------------------------ +// Der nächste String wird ausgelesen und in mpStringBuf (mit 0 abgeschloßen) abgelegt; +// mnStringSize enthält die Größe des gelesenen Strings. +// Bemerkungen wie '//' und '/*.....*/' werden übersprungen. + +BOOL XPMReader::ImplGetString( void ) +{ + BYTE sID[] = "/* XPM */"; + BYTE* pString = mpStringBuf; + + mnStringSize = 0; + mpStringBuf[0] = 0; + + while( mbStatus && ( mnStatus != XPMFINISHED ) ) + { + if ( mnTempAvail == 0 ) + { + mnTempAvail = mrIStm.Read( mpTempBuf, XPMTEMPBUFSIZE ); + if ( mnTempAvail == 0 ) + break; + + mpTempPtr = mpTempBuf; + + if ( mnIdentifier == XPMIDENTIFIER ) + { + if ( mnTempAvail <= 50 ) + { + mbStatus = FALSE; // file is too short to be a correct XPM format + break; + } + for ( int i = 0; i < 9; i++ ) // searching for "/* XPM */" + if ( *mpTempPtr++ != sID[i] ) + { + mbStatus = FALSE; + break; + } + mnTempAvail-=9; + mnIdentifier++; + } + } + mcLastByte = mcThisByte; + mcThisByte = *mpTempPtr++; + mnTempAvail--; + + if ( mnStatus & XPMDOUBLE ) + { + if ( mcThisByte == 0x0a ) + mnStatus &=~XPMDOUBLE; + continue; + } + if ( mnStatus & XPMREMARK ) + { + if ( ( mcThisByte == '/' ) && ( mcLastByte == '*' ) ) + mnStatus &=~XPMREMARK; + continue; + } + if ( mnStatus & XPMSTRING ) // characters in string + { + if ( mcThisByte == '"' ) + { + mnStatus &=~XPMSTRING; // end of parameter by eol + break; + } + if ( mnStringSize >= XPMSTRINGBUF ) + { + mbStatus = FALSE; + break; + } + *pString++ = mcThisByte; + pString[0] = 0; + mnStringSize++; + continue; + } + else + { // characters beside string + switch ( mcThisByte ) + { + case '*' : + if ( mcLastByte == '/' ) mnStatus |= XPMREMARK; + break; + case '/' : + if ( mcLastByte == '/' ) mnStatus |= XPMDOUBLE; + break; + case '"' : mnStatus |= XPMSTRING; + break; + case '{' : + if ( mnIdentifier == XPMDEFINITION ) + mnIdentifier++; + break; + case '}' : + if ( mnIdentifier == XPMENDEXT ) + mnStatus = XPMFINISHED; + break; + } + } + } + return mbStatus; +} + +// ------------- +// - ImportXPM - +// ------------- + +BOOL ImportXPM( SvStream& rStm, Graphic& rGraphic, void* pCallerData ) +{ + XPMReader* pXPMReader = (XPMReader*) rGraphic.GetContext(); + ReadState eReadState; + BOOL bRet = TRUE; + + if( !pXPMReader ) + pXPMReader = new XPMReader( rStm, pCallerData ); + + rGraphic.SetContext( NULL ); + eReadState = pXPMReader->ReadXPM( rGraphic ); + + if( eReadState == XPMREAD_ERROR ) + { + bRet = FALSE; + delete pXPMReader; + } + else if( eReadState == XPMREAD_OK ) + delete pXPMReader; + else + rGraphic.SetContext( pXPMReader ); + + return bRet; +} diff --git a/svtools/source/filter.vcl/jpeg/jpeg.cxx b/svtools/source/filter.vcl/jpeg/jpeg.cxx new file mode 100644 index 000000000000..36865f13210f --- /dev/null +++ b/svtools/source/filter.vcl/jpeg/jpeg.cxx @@ -0,0 +1,565 @@ +/************************************************************************* + * + * $RCSfile: jpeg.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:59:00 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +extern "C" +{ + #include "jpeg/jpeg.h" +} + +#define _JPEGPRIVATE + +#include <vcl/config.hxx> +#include <tools/new.hxx> +#include <vcl/bmpacc.hxx> +#include "jpeg.hxx" + +// ----------- +// - Defines - +// ----------- + +#define JPEGMINREAD 512 + +// ------------- +// - (C-Calls) - +// ------------- + +extern "C" void* JPEGMalloc( size_t nSize ) +{ + return (void*) new BYTE[ nSize ]; +} + +// ------------------------------------------------------------------------ + +extern "C" void JPEGFree( void* pBuf ) +{ + delete[] (BYTE*) pBuf; +} + +// ------------------------------------------------------------------------ + +extern "C" long StreamRead( void* pIStm, void* pBuffer, long nBufferSize ) +{ + SvStream* pSvStm = (SvStream*) pIStm; + long nRead; + + if( pSvStm->GetError() != ERRCODE_IO_PENDING ) + { + long nActPos = pSvStm->Tell(); + + nRead = (long) pSvStm->Read( pBuffer, nBufferSize ); + + if( pSvStm->GetError() == ERRCODE_IO_PENDING ) + { + nRead = 0; + + // Damit wir wieder an die alte Position + // seeken koennen, setzen wir den Error temp.zurueck + pSvStm->ResetError(); + pSvStm->Seek( nActPos ); + pSvStm->SetError( ERRCODE_IO_PENDING ); + } + } + else + nRead = 0; + + return nRead; +} + +// ------------------------------------------------------------------------ + +extern "C" long StreamWrite( void* pOStm, void* pBuffer, long nBufferSize ) +{ + return (long) ( (SvStream*) pOStm )->Write( pBuffer, nBufferSize ); +} + +// ------------------------------------------------------------------------ + +extern "C" void* CreateBitmap( void* pJPEGReader, long nWidth, long nHeight, long bGray, + long* pAlignedWidth, long* pTopDown ) + +{ + return ( (JPEGReader*) pJPEGReader )->CreateBitmap( Size( nWidth, nHeight ), (BOOL) bGray, + *pAlignedWidth, *pTopDown ); +} + +// ------------------------------------------------------------------------ + +extern "C" void* GetScanline( void* pJPEGWriter, long nY ) +{ + return ( (JPEGWriter*) pJPEGWriter )->GetScanline( nY ); +} + +// ------------------------------------------------------------------------ + +extern "C" long JPEGCallback( void* pCallbackData, long nPercent ) +{ +/* + MyCallbackHandler* pH = (MyCallbackHandler*) pCallbackData; + + if ( pH->pCallback ) + { + return (short) (pH->pCallback) ( pH->pCallerData, + (USHORT) (pH->nMinPercent+(pH->nMaxPercent-pH->nMinPercent) * nPercent / 100 ) ); + } +*/ + + return 0L; +} + +// -------------- +// - JPEGReader - +// -------------- + +JPEGReader::JPEGReader( SvStream& rStm, void* pCallData ) : + rIStm ( rStm ), + pAcc ( NULL ), + pAcc1 ( NULL ), + pBuffer ( NULL ), + nLastPos ( rStm.Tell() ), + nLastLines ( 0 ) +{ + maUpperName = String::CreateFromAscii( "SVIJPEG", 7 ); + nFormerPos = nLastPos; +} + +// ------------------------------------------------------------------------ + +JPEGReader::~JPEGReader() +{ + if( pBuffer ) + SvMemFree( pBuffer ); + + if( pAcc ) + aBmp.ReleaseAccess( pAcc ); + + if( pAcc1 ) + aBmp1.ReleaseAccess( pAcc1 ); +} + +// ------------------------------------------------------------------------ + +void* JPEGReader::CreateBitmap( const Size& rSize, BOOL bGray, + long& rAlignedWidth, long& rTopDown ) +{ + void* pBmpBuf = NULL; + + if( pAcc ) + aBmp.ReleaseAccess( pAcc ); + + if( bGray ) + { + BitmapPalette aGrayPal( 256 ); + + for( USHORT n = 0; n < 256; n++ ) + { + const BYTE cGray = (BYTE) n; + aGrayPal[ n ] = BitmapColor( cGray, cGray, cGray ); + } + + aBmp = Bitmap( rSize, 8, &aGrayPal ); + } + else + aBmp = Bitmap( rSize, 24 ); + + pAcc = aBmp.AcquireWriteAccess(); + + if( pAcc ) + { + const ULONG nFormat = pAcc->GetScanlineFormat(); + + if( ( bGray && ( BMP_FORMAT_8BIT_PAL == nFormat ) ) || + ( !bGray && ( BMP_FORMAT_24BIT_TC_BGR == nFormat ) ) ) + { + pBmpBuf = pAcc->GetBuffer(); + rAlignedWidth = pAcc->GetScanlineSize(); + rTopDown = pAcc->IsTopDown(); + } + else + { + rAlignedWidth = AlignedWidth4Bytes( rSize.Width() * ( bGray ? 8 : 24 ) ); + rTopDown = TRUE; + pBmpBuf = pBuffer = SvMemAlloc( rAlignedWidth * rSize.Height() ); + } + } + + return pBmpBuf; +} + +// ------------------------------------------------------------------------ + +void JPEGReader::FillBitmap() +{ + if( pBuffer && pAcc ) + { + HPBYTE pTmp; + BitmapColor aColor; + long nAlignedWidth; + long nWidth = pAcc->Width(); + long nHeight = pAcc->Height(); + + if( pAcc->GetBitCount() == 8 ) + { + BitmapColor* pCols = new BitmapColor[ 256 ]; + + for( USHORT n = 0; n < 256; n++ ) + { + const BYTE cGray = (BYTE) n; + pCols[ n ] = pAcc->GetBestMatchingColor( BitmapColor( cGray, cGray, cGray ) ); + } + + nAlignedWidth = AlignedWidth4Bytes( pAcc->Width() * 8L ); + + for( long nY = 0L; nY < nHeight; nY++ ) + { + pTmp = (BYTE*) pBuffer + nY * nAlignedWidth; + + for( long nX = 0L; nX < nWidth; nX++ ) + pAcc->SetPixel( nY, nX, pCols[ *pTmp++ ] ); + } + + delete[] pCols; + } + else + { + nAlignedWidth = AlignedWidth4Bytes( pAcc->Width() * 24L ); + + for( long nY = 0L; nY < nHeight; nY++ ) + { + pTmp = (BYTE*) pBuffer + nY * nAlignedWidth; + + for( long nX = 0L; nX < nWidth; nX++ ) + { + aColor.SetBlue( *pTmp++ ); + aColor.SetGreen( *pTmp++ ); + aColor.SetRed( *pTmp++ ); + pAcc->SetPixel( nY, nX, aColor ); + } + } + } + } +} + +// ------------------------------------------------------------------------ + +Graphic JPEGReader::CreateIntermediateGraphic( const Bitmap& rBitmap, long nLines ) +{ + Graphic aGraphic; + const Size aSizePix( rBitmap.GetSizePixel() ); + + if( !nLastLines ) + { + if( pAcc1 ) + aBmp1.ReleaseAccess( pAcc1 ); + + aBmp1 = Bitmap( rBitmap.GetSizePixel(), 1 ); + aBmp1.Erase( Color( COL_WHITE ) ); + pAcc1 = aBmp1.AcquireWriteAccess(); + } + + if( nLines && ( nLines < aSizePix.Height() ) ) + { + if( pAcc1 ) + { + const long nNewLines = nLines - nLastLines; + + if( nNewLines ) + { + pAcc1->SetFillColor( Color( COL_BLACK ) ); + pAcc1->FillRect( Rectangle( Point( 0, nLastLines ), + Size( pAcc1->Width(), nNewLines ) ) ); + } + + aBmp1.ReleaseAccess( pAcc1 ); + aGraphic = BitmapEx( rBitmap, aBmp1 ); + pAcc1 = aBmp1.AcquireWriteAccess(); + } + else + aGraphic = rBitmap; + } + else + aGraphic = rBitmap; + + nLastLines = nLines; + + return aGraphic; +} + +// ------------------------------------------------------------------------ + +ReadState JPEGReader::Read( Graphic& rGraphic ) +{ + long nEndPos; + long nLines; + ReadState eReadState; + BOOL bRet = FALSE; + BYTE cDummy; + + // sehen, ob wir _alles_ lesen koennen + rIStm.Seek( STREAM_SEEK_TO_END ); + rIStm >> cDummy; + nEndPos = rIStm.Tell(); + + // falls wir nicht alles lesen koennen, gucken wir, + // ob min. JPEGMINREAD Bytes gelesen werden koennen + if( rIStm.GetError() == ERRCODE_IO_PENDING ) + { + rIStm.ResetError(); + if( ( nEndPos - nFormerPos ) < JPEGMINREAD ) + { + rIStm.Seek( nLastPos ); + return JPEGREAD_NEED_MORE; + } + } + + // an Anfang springen + rIStm.Seek( nLastPos ); + + // (Teil-) Bild einlesen + ReadJPEG( this, &rIStm, &nLines ); + + if( pAcc ) + { + if( pBuffer ) + { + FillBitmap(); + SvMemFree( pBuffer ); + pBuffer = NULL; + } + + aBmp.ReleaseAccess( pAcc ); + pAcc = NULL; + + if( rIStm.GetError() == ERRCODE_IO_PENDING ) + rGraphic = CreateIntermediateGraphic( aBmp, nLines ); + else + rGraphic = aBmp; + + bRet = TRUE; + } + else if( rIStm.GetError() == ERRCODE_IO_PENDING ) + bRet = TRUE; + + // Status setzen ( Pending hat immer Vorrang ) + if( rIStm.GetError() == ERRCODE_IO_PENDING ) + { + eReadState = JPEGREAD_NEED_MORE; + rIStm.ResetError(); + nFormerPos = rIStm.Tell(); + } + else + { + if( bRet ) + eReadState = JPEGREAD_OK; + else + eReadState = JPEGREAD_ERROR; + } + + return eReadState; +} + + +// -------------- +// - JPEGWriter - +// -------------- + +JPEGWriter::JPEGWriter( SvStream& rStm, PFilterCallback pClb, void* pData, Config* pCfg ) : + rOStm ( rStm ), + pAcc ( NULL ), + pBuffer ( NULL ), + pCallback ( pClb ), + pCallerData ( pData ), + pConfig ( pCfg ) +{ +} + +// ------------------------------------------------------------------------ + +void* JPEGWriter::GetScanline( long nY ) +{ + void* pScanline = NULL; + + if( pAcc ) + { + if( bNative ) + pScanline = pAcc->GetScanline( nY ); + else if( pBuffer ) + { + BitmapColor aColor; + long nWidth = pAcc->Width(); + BYTE* pTmp = pBuffer; + + if( pAcc->HasPalette() ) + { + for( long nX = 0L; nX < nWidth; nX++ ) + { + aColor = pAcc->GetPaletteColor( (BYTE) pAcc->GetPixel( nY, nX ) ); + *pTmp++ = aColor.GetBlue(); + *pTmp++ = aColor.GetGreen(); + *pTmp++ = aColor.GetRed(); + } + } + else + { + for( long nX = 0L; nX < nWidth; nX++ ) + { + aColor = pAcc->GetPixel( nY, nX ); + *pTmp++ = aColor.GetBlue(); + *pTmp++ = aColor.GetGreen(); + *pTmp++ = aColor.GetRed(); + } + } + + pScanline = pBuffer; + } + } + + return pScanline; +} + +// ------------------------------------------------------------------------ + +BOOL JPEGWriter::Write( const Graphic& rGraphic ) +{ + BOOL bRet; + + aBmp = rGraphic.GetBitmap(); + pAcc = aBmp.AcquireReadAccess(); + + if( pAcc ) + { +// MyCallbackHandler aCbH; + +// aCbH.pCallback = pCallback; +// aCbH.pCallerData = pCallerData; +// aCbH.nMinPercent = 0; +// aCbH.nMaxPercent = 99; + + long nQuality = 75; + + if( pConfig ) + nQuality = Min( pConfig->ReadKey( "JPG-EXPORT-QUALITY", ByteString::CreateFromInt32(nQuality) ).ToInt32(), (INT32)100 ); + + bNative = ( pAcc->GetScanlineFormat() == BMP_FORMAT_24BIT_TC_BGR ); + + if( !bNative ) + pBuffer = new BYTE[ AlignedWidth4Bytes( pAcc->Width() * 24L ) ]; + + bRet = (BOOL) WriteJPEG( this, &rOStm, pAcc->Width(), pAcc->Height(), nQuality, NULL ); +// bRet = (BOOL) WriteJPEG( this, &rOStm, pAcc->Width(), pAcc->Height(), nQuality, &aCbH ); + + delete[] pBuffer; + pBuffer = NULL; + + aBmp.ReleaseAccess( pAcc ); + pAcc = NULL; + } + else + bRet = FALSE; + + return bRet; +} + +// -------------- +// - ImportJPEG - +// -------------- + +BOOL ImportJPEG( SvStream& rStm, Graphic& rGraphic, void* pCallerData ) +{ + JPEGReader* pJPEGReader = (JPEGReader*) rGraphic.GetContext(); + ReadState eReadState; + BOOL bRet = TRUE; + + if( !pJPEGReader ) + pJPEGReader = new JPEGReader( rStm, pCallerData ); + + rGraphic.SetContext( NULL ); + eReadState = pJPEGReader->Read( rGraphic ); + + if( eReadState == JPEGREAD_ERROR ) + { + bRet = FALSE; + delete pJPEGReader; + } + else if( eReadState == JPEGREAD_OK ) + delete pJPEGReader; + else + rGraphic.SetContext( pJPEGReader ); + + const GraphicType eType = rGraphic.GetType(); + + if( eType != GRAPHIC_BITMAP ) + { + ; + } + + return bRet; +} + +// -------------- +// - ExportJPEG - +// -------------- + +BOOL ExportJPEG( SvStream& rOStm, const Graphic& rGraphic, + PFilterCallback pCallback, void* pCallerData, Config* pOptionsConfig ) +{ + JPEGWriter aJPEGWriter( rOStm, pCallback, pCallerData, pOptionsConfig ); + return aJPEGWriter.Write( rGraphic ); +} diff --git a/svtools/source/filter.vcl/jpeg/makefile.mk b/svtools/source/filter.vcl/jpeg/makefile.mk new file mode 100644 index 000000000000..5a714ad0fb73 --- /dev/null +++ b/svtools/source/filter.vcl/jpeg/makefile.mk @@ -0,0 +1,96 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:59:00 $ +# +# 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=SVTOOLS +TARGET=jpeg +DEPTARGET=vjpeg +TARGET2=jpg + + +# --- Settings ----------------------------------------------------------- + +.IF "$(VCL)" != "" + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + + +.IF "$(GUI)$(CPU)"=="WNTP" +CFLAGS=$(CFLAGS) -Od +.ENDIF + +# --- Files -------------------------------------------------------- + + +SLOFILES= $(SLO)$/jpeg.obj + +.INCLUDE : target.mk + +.ELSE + +dummy: + @+echo VCL not set. nothing to do! + +.ENDIF #VCL diff --git a/svtools/source/filter.vcl/wmf/emfwr.cxx b/svtools/source/filter.vcl/wmf/emfwr.cxx new file mode 100644 index 000000000000..3e504f830b0e --- /dev/null +++ b/svtools/source/filter.vcl/wmf/emfwr.cxx @@ -0,0 +1,1207 @@ +/************************************************************************* + * + * $RCSfile: emfwr.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:59:00 $ + * + * 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 "emfwr.hxx" +#include <vcl/salbtype.hxx> + +// ----------- +// - Defines - +// ----------- + +#define WIN_EMR_HEADER 1 +#define WIN_EMR_POLYBEZIER 2 +#define WIN_EMR_POLYGON 3 +#define WIN_EMR_POLYLINE 4 +#define WIN_EMR_POLYBEZIERTO 5 +#define WIN_EMR_POLYLINETO 6 +#define WIN_EMR_POLYPOLYLINE 7 +#define WIN_EMR_POLYPOLYGON 8 +#define WIN_EMR_SETWINDOWEXTEX 9 +#define WIN_EMR_SETWINDOWORGEX 10 +#define WIN_EMR_SETVIEWPORTEXTEX 11 +#define WIN_EMR_SETVIEWPORTORGEX 12 +#define WIN_EMR_SETBRUSHORGEX 13 +#define WIN_EMR_EOF 14 +#define WIN_EMR_SETPIXELV 15 +#define WIN_EMR_SETMAPPERFLAGS 16 +#define WIN_EMR_SETMAPMODE 17 +#define WIN_EMR_SETBKMODE 18 +#define WIN_EMR_SETPOLYFILLMODE 19 +#define WIN_EMR_SETROP2 20 +#define WIN_EMR_SETSTRETCHBLTMODE 21 +#define WIN_EMR_SETTEXTALIGN 22 +#define WIN_EMR_SETCOLORADJUSTMENT 23 +#define WIN_EMR_SETTEXTCOLOR 24 +#define WIN_EMR_SETBKCOLOR 25 +#define WIN_EMR_OFFSETCLIPRGN 26 +#define WIN_EMR_MOVETOEX 27 +#define WIN_EMR_SETMETARGN 28 +#define WIN_EMR_EXCLUDECLIPRECT 29 +#define WIN_EMR_INTERSECTCLIPRECT 30 +#define WIN_EMR_SCALEVIEWPORTEXTEX 31 +#define WIN_EMR_SCALEWINDOWEXTEX 32 +#define WIN_EMR_SAVEDC 33 +#define WIN_EMR_RESTOREDC 34 +#define WIN_EMR_SETWORLDTRANSFORM 35 +#define WIN_EMR_MODIFYWORLDTRANSFORM 36 +#define WIN_EMR_SELECTOBJECT 37 +#define WIN_EMR_CREATEPEN 38 +#define WIN_EMR_CREATEBRUSHINDIRECT 39 +#define WIN_EMR_DELETEOBJECT 40 +#define WIN_EMR_ANGLEARC 41 +#define WIN_EMR_ELLIPSE 42 +#define WIN_EMR_RECTANGLE 43 +#define WIN_EMR_ROUNDRECT 44 +#define WIN_EMR_ARC 45 +#define WIN_EMR_CHORD 46 +#define WIN_EMR_PIE 47 +#define WIN_EMR_SELECTPALETTE 48 +#define WIN_EMR_CREATEPALETTE 49 +#define WIN_EMR_SETPALETTEENTRIES 50 +#define WIN_EMR_RESIZEPALETTE 51 +#define WIN_EMR_REALIZEPALETTE 52 +#define WIN_EMR_EXTFLOODFILL 53 +#define WIN_EMR_LINETO 54 +#define WIN_EMR_ARCTO 55 +#define WIN_EMR_POLYDRAW 56 +#define WIN_EMR_SETARCDIRECTION 57 +#define WIN_EMR_SETMITERLIMIT 58 +#define WIN_EMR_BEGINPATH 59 +#define WIN_EMR_ENDPATH 60 +#define WIN_EMR_CLOSEFIGURE 61 +#define WIN_EMR_FILLPATH 62 +#define WIN_EMR_STROKEANDFILLPATH 63 +#define WIN_EMR_STROKEPATH 64 +#define WIN_EMR_FLATTENPATH 65 +#define WIN_EMR_WIDENPATH 66 +#define WIN_EMR_SELECTCLIPPATH 67 +#define WIN_EMR_ABORTPATH 68 + +#define WIN_EMR_GDICOMMENT 70 +#define WIN_EMR_FILLRGN 71 +#define WIN_EMR_FRAMERGN 72 +#define WIN_EMR_INVERTRGN 73 +#define WIN_EMR_PAINTRGN 74 +#define WIN_EMR_EXTSELECTCLIPRGN 75 +#define WIN_EMR_BITBLT 76 +#define WIN_EMR_STRETCHBLT 77 +#define WIN_EMR_MASKBLT 78 +#define WIN_EMR_PLGBLT 79 +#define WIN_EMR_SETDIBITSTODEVICE 80 +#define WIN_EMR_STRETCHDIBITS 81 +#define WIN_EMR_EXTCREATEFONTINDIRECTW 82 +#define WIN_EMR_EXTTEXTOUTA 83 +#define WIN_EMR_EXTTEXTOUTW 84 +#define WIN_EMR_POLYBEZIER16 85 +#define WIN_EMR_POLYGON16 86 +#define WIN_EMR_POLYLINE16 87 +#define WIN_EMR_POLYBEZIERTO16 88 +#define WIN_EMR_POLYLINETO16 89 +#define WIN_EMR_POLYPOLYLINE16 90 +#define WIN_EMR_POLYPOLYGON16 91 +#define WIN_EMR_POLYDRAW16 92 +#define WIN_EMR_CREATEMONOBRUSH 93 +#define WIN_EMR_CREATEDIBPATTERNBRUSHPT 94 +#define WIN_EMR_EXTCREATEPEN 95 +#define WIN_EMR_POLYTEXTOUTA 96 +#define WIN_EMR_POLYTEXTOUTW 97 + +#define WIN_SRCCOPY 0x00CC0020L +#define WIN_SRCPAINT 0x00EE0086L +#define WIN_SRCAND 0x008800C6L +#define WIN_SRCINVERT 0x00660046L + +#define HANDLE_INVALID 0xffffffff +#define MAXHANDLES 65000 + +#define LINE_SELECT 0x00000001 +#define FILL_SELECT 0x00000002 +#define TEXT_SELECT 0x00000004 + +// ------------- +// - EMFWriter - +// ------------- + +BOOL EMFWriter::WriteEMF( const GDIMetaFile& rMtf, SvStream& rOStm, + PFilterCallback pCallback, void* pCallerData ) +{ + const ULONG nHeaderPos = rOStm.Tell(); + + mpHandlesUsed = new BOOL[ MAXHANDLES ]; + HMEMSET( mpHandlesUsed, 0, MAXHANDLES * sizeof( BOOL ) ); + mnHandleCount = mnLastPercent = mnRecordPos = mnRecordCount = 0; + mnLineHandle = mnFillHandle = mnTextHandle = HANDLE_INVALID; + mbRecordOpen = FALSE; + + mpStm = &rOStm; + mpCallback = pCallback; + mpCallerData = pCallerData; + maVDev.EnableOutput( FALSE ); + maVDev.SetMapMode( rMtf.GetPrefMapMode() ); + + const Size aMtfSizePix( maVDev.LogicToPixel( rMtf.GetPrefSize(), rMtf.GetPrefMapMode() ) ); + const Size aMtfSizeLog( maVDev.LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_100TH_MM ) ); + + // seek over header + rOStm.SeekRel( 100 ); + + // write initial values + ImplBeginRecord( WIN_EMR_SETWINDOWORGEX ); + (*mpStm) << (INT32) 0 << (INT32) 0; + ImplEndRecord(); + + ImplBeginRecord( WIN_EMR_SETWINDOWEXTEX ); + (*mpStm) << (INT32) aMtfSizePix.Width() << (INT32) aMtfSizePix.Height(); + ImplEndRecord(); + + ImplWriteRasterOp( ROP_OVERPAINT ); + + ImplBeginRecord( WIN_EMR_SETBKMODE ); + (*mpStm) << (UINT32) 1; // TRANSPARENT + ImplEndRecord(); + + // write emf data + ImplWrite( rMtf ); + + // write header + const ULONG nEndPos = mpStm->Tell(); mpStm->Seek( nHeaderPos ); + + (*mpStm) << (UINT32) 0x00000001 << (UINT32) 100; + (*mpStm) << (INT32) 0 << (INT32) 0 << (INT32) ( aMtfSizePix.Width() - 1 ) << (INT32) ( aMtfSizePix.Height() - 1 ); + (*mpStm) << (INT32) 0 << (INT32) 0 << (INT32) ( aMtfSizeLog.Width() - 1 ) << (INT32) ( aMtfSizeLog.Height() - 1 ); + (*mpStm) << (UINT32) 0x464d4520 << (UINT32) 0x10000 << (UINT32) ( nEndPos - nHeaderPos ); + (*mpStm) << (UINT32) mnRecordCount << (UINT16) ( mnHandleCount + 1 ) << (UINT16) 0 << (UINT32) 0 << (UINT32) 0 << (UINT32) 0; + (*mpStm) << (INT32) aMtfSizePix.Width() << (INT32) aMtfSizePix.Height(); + (*mpStm) << (INT32) ( aMtfSizeLog.Width() / 100 ) << (INT32) ( aMtfSizeLog.Height() / 100 ); + (*mpStm) << (UINT32) 0 << (UINT32) 0 << (UINT32) 0; + + mpStm->Seek( nEndPos ); + delete[] mpHandlesUsed; + + return( mpStm->GetError() == ERRCODE_NONE ); +} + +// ----------------------------------------------------------------------------- + +ULONG EMFWriter::ImplAcquireHandle() +{ + ULONG nHandle = HANDLE_INVALID; + + for( ULONG i = 0; i < MAXHANDLES && ( HANDLE_INVALID == nHandle ); i++ ) + { + if( !mpHandlesUsed[ i ] ) + { + mpHandlesUsed[ i ] = TRUE; + + if( ( nHandle = i ) == mnHandleCount ) + mnHandleCount++; + } + } + + DBG_ASSERT( nHandle != HANDLE_INVALID, "No more handles available" ); + return( nHandle != HANDLE_INVALID ? nHandle + 1 : HANDLE_INVALID ); +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplReleaseHandle( ULONG nHandle ) +{ + DBG_ASSERT( nHandle && ( nHandle < MAXHANDLES ), "Handle out of range" ); + mpHandlesUsed[ nHandle - 1 ] = FALSE; +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplBeginRecord( ULONG nType ) +{ + DBG_ASSERT( !mbRecordOpen, "Another record is already opened!" ); + + if( !mbRecordOpen ) + { + mbRecordOpen = TRUE; + mnRecordPos = mpStm->Tell(); + + (*mpStm) << nType; + mpStm->SeekRel( 4 ); + } +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplEndRecord() +{ + DBG_ASSERT( mbRecordOpen, "Record was not opened!" ); + + if( mbRecordOpen ) + { + const ULONG nActPos = mpStm->Tell(); + + mpStm->Seek( mnRecordPos + 4 ); + ( *mpStm ) << ( nActPos - mnRecordPos ); + mpStm->Seek( nActPos ); + + mnRecordCount++; + mbRecordOpen = FALSE; + } +} + +// ----------------------------------------------------------------------------- + +BOOL EMFWriter::ImplPrepareHandleSelect( ULONG& rHandle, ULONG nSelectType ) +{ + if( rHandle != HANDLE_INVALID ) + { + UINT32 nStockObject = 0x80000000; + + if( LINE_SELECT == nSelectType ) + nStockObject |= 0x00000007; + else if( FILL_SELECT == nSelectType ) + nStockObject |= 0x00000001; + else if( TEXT_SELECT == nSelectType ) + nStockObject |= 0x0000000a; + + // select stock object first + ImplBeginRecord( WIN_EMR_SELECTOBJECT ); + ( *mpStm ) << nStockObject; + ImplEndRecord(); + + // destroy handle of created object + ImplBeginRecord( WIN_EMR_DELETEOBJECT ); + ( *mpStm ) << rHandle; + ImplEndRecord(); + + // mark handle as free + ImplReleaseHandle( rHandle ); + } + + rHandle = ImplAcquireHandle(); + + return( HANDLE_INVALID != rHandle ); +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplCheckLineAttr() +{ + if( mbLineChanged && ImplPrepareHandleSelect( mnLineHandle, LINE_SELECT ) ) + { + ULONG nStyle = maVDev.IsLineColor() ? 0 : 5; + ULONG nWidth = 0, nHeight = 0; + + ImplBeginRecord( WIN_EMR_CREATEPEN ); + (*mpStm) << mnLineHandle << nStyle << nWidth << nHeight; + ImplWriteColor( maVDev.GetLineColor() ); + ImplEndRecord(); + + ImplBeginRecord( WIN_EMR_SELECTOBJECT ); + (*mpStm) << mnLineHandle; + ImplEndRecord(); + } +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplCheckFillAttr() +{ + if( mbFillChanged && ImplPrepareHandleSelect( mnFillHandle, FILL_SELECT ) ) + { + ULONG nStyle = maVDev.IsFillColor() ? 0 : 1; + ULONG nPatternStyle = 0; + + ImplBeginRecord( WIN_EMR_CREATEBRUSHINDIRECT ); + (*mpStm) << mnFillHandle << nStyle; + ImplWriteColor( maVDev.GetFillColor() ); + (*mpStm) << nPatternStyle; + ImplEndRecord(); + + ImplBeginRecord( WIN_EMR_SELECTOBJECT ); + (*mpStm) << mnFillHandle; + ImplEndRecord(); + } +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplCheckTextAttr() +{ + if( mbTextChanged && ImplPrepareHandleSelect( mnTextHandle, TEXT_SELECT ) ) + { + const Font& rFont = maVDev.GetFont(); + String aFontName( rFont.GetName() ); + INT32 i, nWeight; + BYTE nPitchAndFamily; + + ImplBeginRecord( WIN_EMR_EXTCREATEFONTINDIRECTW ); + (*mpStm) << mnTextHandle; + ImplWriteExtent( rFont.GetSize().Height() ); + ImplWriteExtent( rFont.GetSize().Width() ); + (*mpStm) << (INT32) rFont.GetOrientation() << (INT32) rFont.GetOrientation(); + + switch( rFont.GetWeight() ) + { + case WEIGHT_THIN: nWeight = 100; break; + case WEIGHT_ULTRALIGHT: nWeight = 200; break; + case WEIGHT_LIGHT: nWeight = 300; break; + case WEIGHT_SEMILIGHT: nWeight = 300; break; + case WEIGHT_NORMAL: nWeight = 400; break; + case WEIGHT_MEDIUM: nWeight = 500; break; + case WEIGHT_SEMIBOLD: nWeight = 600; break; + case WEIGHT_BOLD: nWeight = 700; break; + case WEIGHT_ULTRABOLD: nWeight = 800; break; + case WEIGHT_BLACK: nWeight = 900; break; + default: nWeight = 0; break; + } + + (*mpStm) << nWeight; + (*mpStm) << (BYTE) ( ( ITALIC_NONE == rFont.GetItalic() ) ? 0 : 1 ); + (*mpStm) << (BYTE) ( ( UNDERLINE_NONE == rFont.GetUnderline() ) ? 0 : 1 ); + (*mpStm) << (BYTE) ( ( STRIKEOUT_NONE == rFont.GetStrikeout() ) ? 0 : 1 ); + (*mpStm) << (BYTE) ( ( RTL_TEXTENCODING_SYMBOL == rFont.GetCharSet() ) ? 2 : 0 ); + (*mpStm) << (BYTE) 0 << (BYTE) 0 << (BYTE) 0; + + switch( rFont.GetPitch() ) + { + case PITCH_FIXED: nPitchAndFamily = 0x01; break; + case PITCH_VARIABLE: nPitchAndFamily = 0x02; break; + default: nPitchAndFamily = 0x00; break; + } + + switch( rFont.GetFamily() ) + { + case FAMILY_DECORATIVE: nPitchAndFamily |= 0x50; break; + case FAMILY_MODERN: nPitchAndFamily |= 0x30; break; + case FAMILY_ROMAN: nPitchAndFamily |= 0x10; break; + case FAMILY_SCRIPT: nPitchAndFamily |= 0x40; break; + case FAMILY_SWISS: nPitchAndFamily |= 0x20; break; + default: break; + } + + (*mpStm) << nPitchAndFamily; + + for( i = 0; i < 32; i++ ) + (*mpStm) << (sal_Unicode) ( ( i < aFontName.Len() ) ? aFontName.GetChar( i ) : 0 ); + + // dummy elfFullName + for( i = 0; i < 64; i++ ) + (*mpStm) << (sal_Unicode) 0; + + // dummy elfStyle + for( i = 0; i < 32; i++ ) + (*mpStm) << (sal_Unicode) 0; + + // dummy elfVersion, elfStyleSize, elfMatch, elfReserved + (*mpStm) << (UINT32) 0 << (UINT32) 0 << (UINT32) 0 << (UINT32) 0 ; + + // dummy elfVendorId + (*mpStm) << (UINT32) 0; + + // dummy elfCulture + (*mpStm) << (UINT32) 0; + + // dummy elfPanose + (*mpStm) << (BYTE) 0 << (BYTE) 0 << (BYTE) 0 << (BYTE) 0 << (BYTE) 0 << (BYTE) 0 << (BYTE) 0 << (BYTE) 0 << (BYTE) 0 << (BYTE) 0; + + // fill record to get a record size divideable by 4 + (*mpStm) << (UINT16) 0; + + ImplEndRecord(); + + // TextAlign + UINT32 nTextAlign; + + switch( rFont.GetAlign() ) + { + case ALIGN_TOP: nTextAlign = 0; break; + case ALIGN_BOTTOM: nTextAlign = 8; break; + default: nTextAlign = 24; break; + } + + ImplBeginRecord( WIN_EMR_SETTEXTALIGN ); + (*mpStm) << nTextAlign; + ImplEndRecord(); + + // Text color + ImplBeginRecord( WIN_EMR_SETTEXTCOLOR ); + ImplWriteColor( rFont.GetColor() ); + ImplEndRecord(); + + ImplBeginRecord( WIN_EMR_SELECTOBJECT ); + (*mpStm) << mnTextHandle; + ImplEndRecord(); + } +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplWriteColor( const Color& rColor ) +{ + UINT32 nCol = rColor.GetRed(); + + nCol |= ( (UINT32) rColor.GetGreen() ) << 8; + nCol |= ( (UINT32) rColor.GetBlue() ) << 16; + + (*mpStm) << nCol; +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplWriteRasterOp( RasterOp eRop ) +{ + UINT32 nROP2; + + switch( eRop ) + { + case ROP_INVERT: nROP2 = 6; break; + case ROP_XOR: nROP2 = 7; break; + default: nROP2 = 13;break; + } + + ImplBeginRecord( WIN_EMR_SETROP2 ); + (*mpStm) << nROP2; + ImplEndRecord(); +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplWriteExtent( long nExtent ) +{ + const Size aSize( maVDev.LogicToPixel( Size( nExtent, nExtent ) ) ); + (*mpStm) << (INT32) aSize.Width(); +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplWritePoint( const Point& rPoint ) +{ + const Point aPoint( maVDev.LogicToPixel( rPoint ) ); + + (*mpStm) << (INT32) aPoint.X() << (INT32) aPoint.Y(); +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplWriteSize( const Size& rSize) +{ + const Size aSize( maVDev.LogicToPixel( rSize ) ); + + (*mpStm) << (INT32) aSize.Width() << (INT32) aSize.Height(); +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplWriteRect( const Rectangle& rRect ) +{ + const Rectangle aRect( maVDev.LogicToPixel( rRect ) ); + + (*mpStm) << aRect.Left() << aRect.Top() << aRect.Right() << aRect.Bottom(); +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplWritePolygonRecord( const Polygon& rPoly, BOOL bClose ) +{ + if( rPoly.GetSize() ) + { + if( bClose ) + ImplCheckFillAttr(); + + ImplCheckLineAttr(); + + ImplBeginRecord( bClose ? WIN_EMR_POLYGON : WIN_EMR_POLYLINE ); + ImplWriteRect( rPoly.GetBoundRect() ); + (*mpStm) << (UINT32) rPoly.GetSize(); + + for( USHORT i = 0; i < rPoly.GetSize(); i++ ) + ImplWritePoint( rPoly[ i ] ); + + ImplEndRecord(); + } +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplWritePolyPolygonRecord( const PolyPolygon& rPolyPoly ) +{ + const UINT32 nPolyCount = rPolyPoly.Count(); + + if( nPolyCount ) + { + if( 1 == nPolyCount ) + ImplWritePolygonRecord( rPolyPoly[ 0 ], TRUE ); + else + { + UINT32 nTotalPoints = 0, i; + + for( i = 0; i < nPolyCount; i++ ) + nTotalPoints += rPolyPoly[ i ].GetSize(); + + if( nTotalPoints ) + { + ImplCheckFillAttr(); + ImplCheckLineAttr(); + + ImplBeginRecord( WIN_EMR_POLYPOLYGON ); + ImplWriteRect( rPolyPoly.GetBoundRect() ); + (*mpStm) << nPolyCount << nTotalPoints; + + for( i = 0; i < nPolyCount; i++ ) + (*mpStm) << (UINT32) rPolyPoly[ i ].GetSize(); + + for( i = 0; i < nPolyCount; i++ ) + { + const Polygon& rPoly = rPolyPoly[ i ]; + + for( USHORT n = 0; n < rPoly.GetSize(); n++ ) + ImplWritePoint( rPoly[ n ] ); + } + + ImplEndRecord(); + } + } + } +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt, + const Size& rSz, UINT32 nROP ) +{ + if( !!rBmp ) + { + SvMemoryStream aMemStm( 65535, 65535 ); + const Size aBmpSizePixel( rBmp.GetSizePixel() ); + + ImplBeginRecord( WIN_EMR_STRETCHDIBITS ); + ImplWriteRect( Rectangle( rPt, rSz ) ); + ImplWritePoint( rPt ); + (*mpStm) << (INT32) 0 << (INT32) 0 << (INT32) aBmpSizePixel.Width() << (INT32) aBmpSizePixel.Height(); + + // write offset positions and sizes later + const ULONG nOffPos = mpStm->Tell(); + mpStm->SeekRel( 16 ); + + (*mpStm) << (UINT32) 0 << ( ( ROP_XOR == maVDev.GetRasterOp() && WIN_SRCCOPY == nROP ) ? WIN_SRCINVERT : nROP ); + ImplWriteSize( rSz ); + + rBmp.Write( aMemStm, TRUE, FALSE ); + + UINT32 nDIBSize = aMemStm.Tell(), nHeaderSize, nCompression, nColsUsed, nPalCount, nImageSize; + UINT16 nBitCount; + + // get DIB parameters + aMemStm.Seek( 0 ); + aMemStm >> nHeaderSize; + aMemStm.SeekRel( 10 ); + aMemStm >> nBitCount >> nCompression >> nImageSize; + aMemStm.SeekRel( 8 ); + aMemStm >> nColsUsed; + + nPalCount = ( nBitCount <= 8 ) ? ( nColsUsed ? nColsUsed : ( 1 << (UINT32) nBitCount ) ) : + ( ( 3 == nCompression ) ? 12 : 0 ); + + mpStm->Write( aMemStm.GetData(), nDIBSize ); + + const ULONG nEndPos = mpStm->Tell(); + mpStm->Seek( nOffPos ); + (*mpStm) << (UINT32) 80 << (UINT32)( nHeaderSize + ( nPalCount << 2 ) ); + (*mpStm) << (UINT32)( 80 + ( nHeaderSize + ( nPalCount << 2 ) ) ) << nImageSize; + mpStm->Seek( nEndPos ); + + ImplEndRecord(); + } +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplWriteTextRecord( const Point& rPos, const String rText, const long* pDXArray, UINT32 nWidth ) +{ + UINT32 nLen = rText.Len(), i; + + if( nLen ) + { + sal_Int32 nNormWidth; + long* pOwnArray; + long* pDX; + + // get text sizes + if( pDXArray ) + { + pOwnArray = NULL; + nNormWidth = maVDev.GetTextWidth( rText ); + pDX = (long*) pDXArray; + } + else + { + pOwnArray = new long[ nLen ]; + nNormWidth = maVDev.GetTextArray( rText, pOwnArray ); + pDX = pOwnArray; + } + + if( nLen > 1 ) + { + nNormWidth = pDX[ nLen - 2 ] + maVDev.GetTextWidth( rText.GetChar( nLen - 1 ) ); + + if( nWidth && nNormWidth && ( nWidth != nNormWidth ) ) + { + const double fFactor = (double) nWidth / nNormWidth; + + for( i = 0; i < ( nLen - 1 ); i++ ) + pDX[ i ] = FRound( pDX[ i ] * fFactor ); + } + } + + // write text record + ImplBeginRecord( WIN_EMR_EXTTEXTOUTW ); + + ImplWriteRect( Rectangle( rPos, Size( nNormWidth, maVDev.GetTextHeight() ) ) ); + (*mpStm) << (UINT32) 2; // GM_ADVANCED + (*mpStm) << (INT32) 0 << (INT32) 0; + ImplWritePoint( rPos ); + (*mpStm) << (UINT32) nLen << (UINT32) 76 << (UINT32) 2; + (*mpStm) << (INT32) 0 << (INT32) 0 << (INT32) 0 << (INT32) 0; + (*mpStm) << (UINT32) ( 76 + ( nLen << 1 ) + ( (nLen & 1 ) ? 2 : 0 ) ); + + // write text + for( i = 0; i < nLen; i++ ) + (*mpStm) << (sal_Unicode)rText.GetChar( i ); + + // padding word + if( nLen & 1 ) + (*mpStm) << (UINT16) 0; + + // write DX array + ImplWriteExtent( pDX[ 0 ] ); + + if( nLen > 1 ) + { + for( i = 1; i < ( nLen - 1 ); i++ ) + ImplWriteExtent( pDX[ i ] - pDX[ i - 1 ] ); + + ImplWriteExtent( pDX[ nLen - 2 ] / ( nLen - 1 ) ); + } + + ImplEndRecord(); + delete[] pOwnArray; + } +} + +// ----------------------------------------------------------------------------- + +void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) +{ + for( ULONG i = 0, nCount = rMtf.GetActionCount(); i < nCount; i++ ) + { + const MetaAction* pAction = rMtf.GetAction( i ); + const USHORT nType = pAction->GetType(); + + switch( nType ) + { + case( META_PIXEL_ACTION ): + { + const MetaPixelAction* pA = (const MetaPixelAction*) pAction; + + ImplCheckLineAttr(); + ImplBeginRecord( WIN_EMR_SETPIXELV ); + ImplWritePoint( pA->GetPoint() ); + ImplWriteColor( pA->GetColor() ); + ImplEndRecord(); + } + break; + + case( META_POINT_ACTION ): + { + if( maVDev.IsLineColor() ) + { + const MetaPointAction* pA = (const MetaPointAction*) pAction; + + ImplCheckLineAttr(); + ImplBeginRecord( WIN_EMR_SETPIXELV ); + ImplWritePoint( pA->GetPoint() ); + ImplWriteColor( maVDev.GetLineColor() ); + ImplEndRecord(); + } + } + break; + + case( META_LINE_ACTION ): + { + if( maVDev.IsLineColor() ) + { + const MetaLineAction* pA = (const MetaLineAction*) pAction; + + ImplCheckLineAttr(); + + ImplBeginRecord( WIN_EMR_MOVETOEX ); + ImplWritePoint( pA->GetStartPoint() ); + ImplEndRecord(); + + ImplBeginRecord( WIN_EMR_LINETO ); + ImplWritePoint( pA->GetEndPoint() ); + ImplEndRecord(); + + ImplBeginRecord( WIN_EMR_SETPIXELV ); + ImplWritePoint( pA->GetEndPoint() ); + ImplWriteColor( maVDev.GetLineColor() ); + ImplEndRecord(); + } + } + break; + + case( META_RECT_ACTION ): + { + if( maVDev.IsLineColor() || maVDev.IsFillColor() ) + { + const MetaRectAction* pA = (const MetaRectAction*) pAction; + + ImplCheckFillAttr(); + ImplCheckLineAttr(); + + ImplBeginRecord( WIN_EMR_RECTANGLE ); + ImplWriteRect( pA->GetRect() ); + ImplEndRecord(); + } + } + break; + + case( META_ROUNDRECT_ACTION ): + { + if( maVDev.IsLineColor() || maVDev.IsFillColor() ) + { + const MetaRoundRectAction* pA = (const MetaRoundRectAction*) pAction; + + ImplCheckFillAttr(); + ImplCheckLineAttr(); + + ImplBeginRecord( WIN_EMR_ROUNDRECT ); + ImplWriteRect( pA->GetRect() ); + ImplWriteSize( Size( pA->GetHorzRound(), pA->GetVertRound() ) ); + ImplEndRecord(); + } + } + break; + + case( META_ELLIPSE_ACTION ): + { + if( maVDev.IsLineColor() || maVDev.IsFillColor() ) + { + const MetaEllipseAction* pA = (const MetaEllipseAction*) pAction; + + ImplCheckFillAttr(); + ImplCheckLineAttr(); + + ImplBeginRecord( WIN_EMR_ELLIPSE ); + ImplWriteRect( pA->GetRect() ); + ImplEndRecord(); + } + } + break; + + case( META_ARC_ACTION ): + case( META_PIE_ACTION ): + case( META_CHORD_ACTION ): + case( META_POLYGON_ACTION ): + { + if( maVDev.IsLineColor() || maVDev.IsFillColor() ) + { + Polygon aPoly; + + switch( nType ) + { + case( META_ARC_ACTION ): + { + const MetaArcAction* pA = (const MetaArcAction*) pAction; + aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_ARC ); + } + break; + + case( META_PIE_ACTION ): + { + const MetaPieAction* pA = (const MetaPieAction*) pAction; + aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_PIE ); + } + break; + + case( META_CHORD_ACTION ): + { + const MetaChordAction* pA = (const MetaChordAction*) pAction; + aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_CHORD ); + } + break; + + case( META_POLYGON_ACTION ): + aPoly = ( (const MetaPolygonAction*) pAction )->GetPolygon(); + break; + } + + ImplWritePolygonRecord( aPoly, nType != META_ARC_ACTION ); + } + } + break; + + case( META_POLYLINE_ACTION ): + { + if( maVDev.IsLineColor() ) + ImplWritePolygonRecord( ( (const MetaPolyLineAction*) pAction )->GetPolygon(), FALSE ); + } + break; + + case( META_POLYPOLYGON_ACTION ): + { + if( maVDev.IsLineColor() || maVDev.IsFillColor() ) + ImplWritePolyPolygonRecord( ( (const MetaPolyPolygonAction*) pAction )->GetPolyPolygon() ); + } + break; + + case( META_GRADIENT_ACTION ): + { + const MetaGradientAction* pA = (const MetaGradientAction*) pAction; + GDIMetaFile aTmpMtf; + + maVDev.AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf ); + ImplWrite( aTmpMtf ); + } + break; + + case META_HATCH_ACTION: + { + const MetaHatchAction* pA = (const MetaHatchAction*) pAction; + GDIMetaFile aTmpMtf; + + maVDev.AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf ); + ImplWrite( aTmpMtf ); + } + break; + + case META_TRANSPARENT_ACTION: + { + ImplCheckFillAttr(); + ImplCheckLineAttr(); + ImplWritePolyPolygonRecord( ( (MetaTransparentAction*) pAction )->GetPolyPolygon() ); + } + break; + + case META_FLOATTRANSPARENT_ACTION: + { + const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pAction; + + 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 ); + + ImplCheckFillAttr(); + ImplCheckLineAttr(); + ImplCheckTextAttr(); + ImplWrite( aTmpMtf ); + } + break; + + case( META_EPS_ACTION ): + { + const MetaEPSAction* pA = (const MetaEPSAction*) pAction; + const GDIMetaFile aGDIMetaFile( pA->GetSubstitute() ); + sal_Bool bFound = sal_False; + + for( ULONG i = 0, nCount = aGDIMetaFile.GetActionCount(); ( i < nCount ) && !bFound; i++ ) + { + const MetaAction* pSubstAct = aGDIMetaFile.GetAction( i ); + + if( pSubstAct->GetType() == META_BMPSCALE_ACTION ) + { + bFound = sal_True; + const MetaBmpScaleAction* pBmpScaleAction = (const MetaBmpScaleAction*) pAction; + ImplWriteBmpRecord( pBmpScaleAction->GetBitmap(), pBmpScaleAction->GetPoint(), + pBmpScaleAction->GetSize(), WIN_SRCCOPY ); + } + } + } + break; + + case META_BMP_ACTION: + { + const MetaBmpAction* pA = (const MetaBmpAction *) pAction; + ImplWriteBmpRecord( pA->GetBitmap(), pA->GetPoint(), pA->GetBitmap().GetSizePixel(), WIN_SRCCOPY ); + } + break; + + case META_BMPSCALE_ACTION: + { + const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pAction; + ImplWriteBmpRecord( pA->GetBitmap(), pA->GetPoint(), pA->GetSize(), WIN_SRCCOPY ); + } + break; + + case META_BMPSCALEPART_ACTION: + { + const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*) pAction; + Bitmap aTmp( pA->GetBitmap() ); + + if( aTmp.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ) ) + ImplWriteBmpRecord( aTmp, pA->GetDestPoint(), pA->GetDestSize(), WIN_SRCCOPY ); + } + break; + + case META_BMPEX_ACTION: + { + const MetaBmpExAction* pA = (const MetaBmpExAction *) pAction; + Bitmap aBmp( pA->GetBitmapEx().GetBitmap() ); + Bitmap aMsk( pA->GetBitmapEx().GetMask() ); + + if( !!aMsk ) + { + aBmp.Replace( aMsk, COL_WHITE ); + aMsk.Invert(); + ImplWriteBmpRecord( aMsk, pA->GetPoint(), aMsk.GetSizePixel(), WIN_SRCPAINT ); + ImplWriteBmpRecord( aBmp, pA->GetPoint(), aBmp.GetSizePixel(), WIN_SRCAND ); + } + else + ImplWriteBmpRecord( aBmp, pA->GetPoint(), aBmp.GetSizePixel(), WIN_SRCCOPY ); + } + break; + + case META_BMPEXSCALE_ACTION: + { + const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pAction; + Bitmap aBmp( pA->GetBitmapEx().GetBitmap() ); + Bitmap aMsk( pA->GetBitmapEx().GetMask() ); + + if( !!aMsk ) + { + aBmp.Replace( aMsk, COL_WHITE ); + aMsk.Invert(); + ImplWriteBmpRecord( aMsk, pA->GetPoint(), pA->GetSize(), WIN_SRCPAINT ); + ImplWriteBmpRecord( aBmp, pA->GetPoint(), pA->GetSize(), WIN_SRCAND ); + } + else + ImplWriteBmpRecord( aBmp, pA->GetPoint(), pA->GetSize(), WIN_SRCCOPY ); + } + break; + + case META_BMPEXSCALEPART_ACTION: + { + const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*) pAction; + BitmapEx aBmpEx( pA->GetBitmapEx() ); + aBmpEx.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ); + Bitmap aBmp( aBmpEx.GetBitmap() ); + Bitmap aMsk( aBmpEx.GetMask() ); + + if( !!aMsk ) + { + aBmp.Replace( aMsk, COL_WHITE ); + aMsk.Invert(); + ImplWriteBmpRecord( aMsk, pA->GetDestPoint(), pA->GetDestSize(), WIN_SRCPAINT ); + ImplWriteBmpRecord( aBmp, pA->GetDestPoint(), pA->GetDestSize(), WIN_SRCAND ); + } + else + ImplWriteBmpRecord( aBmp, pA->GetDestPoint(), pA->GetDestSize(), WIN_SRCCOPY ); + } + break; + + case META_TEXT_ACTION: + { + const MetaTextAction* pA = (const MetaTextAction*) pAction; + const String aText( pA->GetText(), pA->GetIndex(), pA->GetLen() ); + + ImplCheckTextAttr(); + ImplWriteTextRecord( pA->GetPoint(), aText, NULL, 0 ); + } + break; + + case META_TEXTRECT_ACTION: + { + const MetaTextRectAction* pA = (const MetaTextRectAction*) pAction; + const String aText( pA->GetText() ); + + ImplCheckTextAttr(); + ImplWriteTextRecord( pA->GetRect().TopLeft(), aText, NULL, 0 ); + } + break; + + case META_TEXTARRAY_ACTION: + { + const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pAction; + const String aText( pA->GetText(), pA->GetIndex(), pA->GetLen() ); + + ImplCheckTextAttr(); + ImplWriteTextRecord( pA->GetPoint(), aText, pA->GetDXArray(), 0 ); + } + break; + + case META_STRETCHTEXT_ACTION: + { + const MetaStretchTextAction* pA = (const MetaStretchTextAction*) pAction; + const String aText( pA->GetText(), pA->GetIndex(), pA->GetLen() ); + + ImplCheckTextAttr(); + ImplWriteTextRecord( pA->GetPoint(), aText, NULL, pA->GetWidth() ); + } + break; + + case( META_LINECOLOR_ACTION ): + { + ( (MetaAction*) pAction )->Execute( &maVDev ); + mbLineChanged = TRUE; + } + break; + + case( META_FILLCOLOR_ACTION ): + { + ( (MetaAction*) pAction )->Execute( &maVDev ); + mbFillChanged = TRUE; + } + break; + + case( META_TEXTCOLOR_ACTION ): + case( META_TEXTLINECOLOR_ACTION ): + case( META_TEXTFILLCOLOR_ACTION ): + case( META_TEXTALIGN_ACTION ): + case( META_FONT_ACTION ): + { + ( (MetaAction*) pAction )->Execute( &maVDev ); + mbTextChanged = TRUE; + } + break; + + case( META_ISECTRECTCLIPREGION_ACTION ): + { + ( (MetaAction*) pAction )->Execute( &maVDev ); + + ImplBeginRecord( WIN_EMR_INTERSECTCLIPRECT ); + ImplWriteRect( ( (MetaISectRectClipRegionAction*) pAction )->GetRect() ); + ImplEndRecord(); + } + break; + + case( META_CLIPREGION_ACTION ): + case( META_ISECTREGIONCLIPREGION_ACTION ): + case( META_MOVECLIPREGION_ACTION ): + { + ( (MetaAction*) pAction )->Execute( &maVDev ); + } + break; + + case( META_REFPOINT_ACTION ): + case( META_MAPMODE_ACTION ): + ( (MetaAction*) pAction )->Execute( &maVDev ); + break; + + case( META_PUSH_ACTION ): + { + ( (MetaAction*) pAction )->Execute( &maVDev ); + + ImplBeginRecord( WIN_EMR_SAVEDC ); + ImplEndRecord(); + } + break; + + case( META_POP_ACTION ): + { + ( (MetaAction*) pAction )->Execute( &maVDev ); + + ImplBeginRecord( WIN_EMR_RESTOREDC ); + (*mpStm) << (INT32) -1; + ImplEndRecord(); + + ImplWriteRasterOp( maVDev.GetRasterOp() ); + mbLineChanged = mbFillChanged = mbTextChanged = TRUE; + } + break; + + case( META_RASTEROP_ACTION ): + { + ( (MetaAction*) pAction )->Execute( &maVDev ); + ImplWriteRasterOp( ( (MetaRasterOpAction*) pAction )->GetRasterOp() ); + } + break; + + case( META_MASK_ACTION ): + case( META_MASKSCALE_ACTION ): + case( META_MASKSCALEPART_ACTION ): + case( META_WALLPAPER_ACTION ): + case( META_TEXTLINE_ACTION ): + case( META_COMMENT_ACTION ): + case( META_GRADIENTEX_ACTION ): + { + // !!! >>> we don't want to support these actions + } + break; + + default: + DBG_ERROR( ( ByteString( "SVGActionWriter::ImplWriteActions: unsupported MetaAction #" ) += ByteString( nType ) ).GetBuffer() ); + break; + } + } +} diff --git a/svtools/source/filter.vcl/wmf/emfwr.hxx b/svtools/source/filter.vcl/wmf/emfwr.hxx new file mode 100644 index 000000000000..f88edaeb92a6 --- /dev/null +++ b/svtools/source/filter.vcl/wmf/emfwr.hxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * $RCSfile: emfwr.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:59:00 $ + * + * 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 _EMFWR_HXX +#define _EMFWR_HXX + +#include <tools/debug.hxx> +#include <vcl/metaact.hxx> +#include <vcl/graph.hxx> +#include <vcl/gdimtf.hxx> +#include <vcl/virdev.hxx> +#include "fltcall.hxx" + +// ------------- +// - EMFWriter - +// ------------- + +class EMFWriter +{ +private: + + VirtualDevice maVDev; + PFilterCallback mpCallback; + void* mpCallerData; + SvStream* mpStm; + BOOL* mpHandlesUsed; + ULONG mnHandleCount; + ULONG mnLastPercent; + ULONG mnRecordCount; + ULONG mnRecordPos; + BOOL mbRecordOpen; + BOOL mbLineChanged; + ULONG mnLineHandle; + BOOL mbFillChanged; + ULONG mnFillHandle; + BOOL mbTextChanged; + ULONG mnTextHandle; + + void ImplBeginRecord( ULONG nType ); + void ImplEndRecord(); + + ULONG ImplAcquireHandle(); + void ImplReleaseHandle( ULONG nHandle ); + + BOOL ImplPrepareHandleSelect( ULONG& rHandle, ULONG nSelectType ); + void ImplCheckLineAttr(); + void ImplCheckFillAttr(); + void ImplCheckTextAttr(); + + void ImplWriteColor( const Color& rColor ); + void ImplWriteRasterOp( RasterOp eRop ); + void ImplWriteExtent( long nExtent ); + void ImplWritePoint( const Point& rPoint ); + void ImplWriteSize( const Size& rSize); + void ImplWriteRect( const Rectangle& rRect ); + void ImplWritePolygonRecord( const Polygon& rPoly, BOOL bClose ); + void ImplWritePolyPolygonRecord( const PolyPolygon& rPolyPoly ); + void ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt, const Size& rSz, UINT32 nROP ); + void ImplWriteTextRecord( const Point& rPos, const String rText, const long* pDXArray, UINT32 nWidth ); + + void ImplWrite( const GDIMetaFile& rMtf ); + +public: + + EMFWriter() {} + + BOOL WriteEMF( const GDIMetaFile& rMtf, SvStream& rOStm, + PFilterCallback pCallback, void* pCallerData ); +}; + +#endif // _EMFWR_HXX diff --git a/svtools/source/filter.vcl/wmf/enhwmf.cxx b/svtools/source/filter.vcl/wmf/enhwmf.cxx new file mode 100644 index 000000000000..ed2c10be2dd7 --- /dev/null +++ b/svtools/source/filter.vcl/wmf/enhwmf.cxx @@ -0,0 +1,1077 @@ +/************************************************************************* + * + * $RCSfile: enhwmf.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:59:00 $ + * + * 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 "winmtf.hxx" + +//=========================== GDI-Array =================================== + +#define EMR_HEADER 1 +#define EMR_POLYBEZIER 2 +#define EMR_POLYGON 3 +#define EMR_POLYLINE 4 +#define EMR_POLYBEZIERTO 5 +#define EMR_POLYLINETO 6 +#define EMR_POLYPOLYLINE 7 +#define EMR_POLYPOLYGON 8 +#define EMR_SETWINDOWEXTEX 9 +#define EMR_SETWINDOWORGEX 10 +#define EMR_SETVIEWPORTEXTEX 11 +#define EMR_SETVIEWPORTORGEX 12 +#define EMR_SETBRUSHORGEX 13 +#define EMR_EOF 14 +#define EMR_SETPIXELV 15 +#define EMR_SETMAPPERFLAGS 16 +#define EMR_SETMAPMODE 17 +#define EMR_SETBKMODE 18 +#define EMR_SETPOLYFILLMODE 19 +#define EMR_SETROP2 20 +#define EMR_SETSTRETCHBLTMODE 21 +#define EMR_SETTEXTALIGN 22 +#define EMR_SETCOLORADJUSTMENT 23 +#define EMR_SETTEXTCOLOR 24 +#define EMR_SETBKCOLOR 25 +#define EMR_OFFSETCLIPRGN 26 +#define EMR_MOVETOEX 27 +#define EMR_SETMETARGN 28 +#define EMR_EXCLUDECLIPRECT 29 +#define EMR_INTERSECTCLIPRECT 30 +#define EMR_SCALEVIEWPORTEXTEX 31 +#define EMR_SCALEWINDOWEXTEX 32 +#define EMR_SAVEDC 33 +#define EMR_RESTOREDC 34 +#define EMR_SETWORLDTRANSFORM 35 +#define EMR_MODIFYWORLDTRANSFORM 36 +#define EMR_SELECTOBJECT 37 +#define EMR_CREATEPEN 38 +#define EMR_CREATEBRUSHINDIRECT 39 +#define EMR_DELETEOBJECT 40 +#define EMR_ANGLEARC 41 +#define EMR_ELLIPSE 42 +#define EMR_RECTANGLE 43 +#define EMR_ROUNDRECT 44 +#define EMR_ARC 45 +#define EMR_CHORD 46 +#define EMR_PIE 47 +#define EMR_SELECTPALETTE 48 +#define EMR_CREATEPALETTE 49 +#define EMR_SETPALETTEENTRIES 50 +#define EMR_RESIZEPALETTE 51 +#define EMR_REALIZEPALETTE 52 +#define EMR_EXTFLOODFILL 53 +#define EMR_LINETO 54 +#define EMR_ARCTO 55 +#define EMR_POLYDRAW 56 +#define EMR_SETARCDIRECTION 57 +#define EMR_SETMITERLIMIT 58 +#define EMR_BEGINPATH 59 +#define EMR_ENDPATH 60 +#define EMR_CLOSEFIGURE 61 +#define EMR_FILLPATH 62 +#define EMR_STROKEANDFILLPATH 63 +#define EMR_STROKEPATH 64 +#define EMR_FLATTENPATH 65 +#define EMR_WIDENPATH 66 +#define EMR_SELECTCLIPPATH 67 +#define EMR_ABORTPATH 68 + +#define EMR_GDICOMMENT 70 +#define EMR_FILLRGN 71 +#define EMR_FRAMERGN 72 +#define EMR_INVERTRGN 73 +#define EMR_PAINTRGN 74 +#define EMR_EXTSELECTCLIPRGN 75 +#define EMR_BITBLT 76 +#define EMR_STRETCHBLT 77 +#define EMR_MASKBLT 78 +#define EMR_PLGBLT 79 +#define EMR_SETDIBITSTODEVICE 80 +#define EMR_STRETCHDIBITS 81 +#define EMR_EXTCREATEFONTINDIRECTW 82 +#define EMR_EXTTEXTOUTA 83 +#define EMR_EXTTEXTOUTW 84 +#define EMR_POLYBEZIER16 85 +#define EMR_POLYGON16 86 +#define EMR_POLYLINE16 87 +#define EMR_POLYBEZIERTO16 88 +#define EMR_POLYLINETO16 89 +#define EMR_POLYPOLYLINE16 90 +#define EMR_POLYPOLYGON16 91 +#define EMR_POLYDRAW16 92 +#define EMR_CREATEMONOBRUSH 93 +#define EMR_CREATEDIBPATTERNBRUSHPT 94 +#define EMR_EXTCREATEPEN 95 +#define EMR_POLYTEXTOUTA 96 +#define EMR_POLYTEXTOUTW 97 +#define EMR_SETICMMODE 98 +#define EMR_CREATECOLORSPACE 99 +#define EMR_SETCOLORSPACE 100 +#define EMR_DELETECOLORSPACE 101 +#define EMR_GLSRECORD 102 +#define EMR_GLSBOUNDEDRECORD 103 +#define EMR_PIXELFORMAT 104 + +//----------------------------------------------------------------------------------- + +BOOL EnhWMFReader::ReadEnhWMF() // SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, PFilterCallback pcallback, void * pcallerdata) +{ + UINT32 nStretchBltMode = 0; + UINT32 nRecType, nRecSize, nNextPos; + UINT32 nWidth, nHeight, nPoints, nColor, nIndex; + UINT32 nDat32, nNom1, nDen1, nNom2, nDen2; + INT32 nX32, nY32, nx32, ny32; + INT16 nX16, nY16; + + BOOL bFlag, bStatus = ReadHeader(); + + while( bStatus && nRecordCount-- ) + { + *pWMF >> nRecType >> nRecSize; + + if ( ( nRecSize < 8 ) || ( nRecSize & 3 ) ) // Parameter sind immer durch 4 teilbar + { + bStatus = FALSE; + break; + } + nNextPos = pWMF->Tell() + ( nRecSize - 8 ); + + if( aBmpSaveList.Count() && ( nRecType != EMR_STRETCHBLT ) && ( nRecType != EMR_STRETCHDIBITS ) ) + pOut->ResolveBitmapActions( aBmpSaveList ); + + bFlag = FALSE; + + switch( nRecType ) + { + case EMR_HEADER : // wir haben schon laengst einen header eingelesen + break; + + case EMR_POLYBEZIER : + break; + + case EMR_POLYGON : + { + pWMF->SeekRel( 16 ); + *pWMF >> nPoints; + Polygon aPoly( (UINT16)nPoints ); + for( UINT16 k = 0; k < (UINT16)nPoints; k++ ) + { + *pWMF >> nX32 >> nY32; + aPoly[ k ] = Point( nX32, nY32 ); + } + pOut->DrawPolygon( aPoly ); + } + break; + + case EMR_POLYBEZIERTO : + break; + + case EMR_POLYLINETO : + bFlag = TRUE; + case EMR_POLYLINE : + { + pWMF->SeekRel( 0x10 ); + *pWMF >> nPoints; + UINT16 i = 0; + if ( bFlag ) + { + i++; + nPoints++; + } + Polygon aPolygon( (UINT16)nPoints ); + for ( ; i < (UINT16)nPoints; i++ ) + { + *pWMF >> nX32 >> nY32; + aPolygon[ i ] = Point( nX32, nY32 ); + } + pOut->DrawPolyLine( aPolygon, bFlag ); + } + break; + + case EMR_POLYPOLYLINE : + { + UINT16* pnPoints; + + INT32 i, nPoly; + pWMF->SeekRel( 0x10 ); + + // Anzahl der Polygone: + *pWMF >> nPoly >> i; + + // Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln: + pnPoints = new UINT16[ nPoly ]; + + for ( i = 0; i < nPoly; i++ ) + { + *pWMF >> nPoints; + pnPoints[ i ] = (UINT16)nPoints; + } + + // Polygonpunkte holen: + + for ( i = 0; i < nPoly; i++ ) + { + Polygon aPoly( pnPoints[ i ] ); + for( UINT16 k = 0; k < pnPoints[ i ]; k++ ) + { + *pWMF >> nX32 >> nY32; + aPoly[ k ] = Point( nX32, nY32 ); + } + pOut->DrawPolyLine( aPoly, FALSE ); + } + delete pnPoints; + } + break; + + case EMR_POLYPOLYGON : + { + UINT16* pnPoints; + Point* pPtAry; + + INT32 i, nPoly, nGesPoints; + pWMF->SeekRel( 0x10 ); + + // Anzahl der Polygone: + *pWMF >> nPoly >> nGesPoints; + + // Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln: + pnPoints = new UINT16[ nPoly ]; + + for ( i = 0; i < nPoly; i++ ) + { + *pWMF >> nPoints; + pnPoints[ i ] = (UINT16)nPoints; + } + // Polygonpunkte holen: + pPtAry = (Point*) new char[ nGesPoints * sizeof(Point) ]; + + for ( i = 0; i < nGesPoints; i++ ) + { + *pWMF >> nX32 >> nY32; + pPtAry[ i ] = Point( nX32, nY32 ); + } + // PolyPolygon Actions erzeugen + PolyPolygon aPolyPoly( (UINT16)nPoly, pnPoints, pPtAry ); + + pOut->DrawPolyPolygon( aPolyPoly ); + delete (char*) pPtAry; + delete pnPoints; + } + break; + + case EMR_SETWINDOWEXTEX : + { // #75383# + *pWMF >> nWidth >> nHeight; + if( nWidth > 1 && nHeight > 1 ) + pOut->SetWinExt( Size( nWidth, nHeight ) ); + } + break; + + case EMR_SETWINDOWORGEX : + { + *pWMF >> nX32 >> nY32; + pOut->SetWinOrg( Point( nX32, nY32 ) ); + } + break; + + case EMR_SETVIEWPORTEXTEX : + case EMR_SETVIEWPORTORGEX : + break; + + case EMR_SCALEVIEWPORTEXTEX : + { + *pWMF >> nNom1 >> nDen1 >> nNom2 >> nDen2; + pOut->ScaleDevExt( (double)nNom1 / nDen1, (double)nNom2 / nDen2 ); + } + break; + + case EMR_SCALEWINDOWEXTEX : + { + *pWMF >> nNom1 >> nDen1 >> nNom2 >> nDen2; + pOut->ScaleWinExt( (double)nNom1 / nDen1, (double)nNom2 / nDen2 ); + } + break; + + case EMR_SETBRUSHORGEX : + break; + case EMR_EOF : + nRecordCount = 0; // #76846# + break; + + case EMR_SETPIXELV : + { + *pWMF >> nX32 >> nY32; + pOut->DrawPixel( Point( nX32, nY32 ), ReadColor() ); + } + break; + + case EMR_SETMAPPERFLAGS : + break; + + case EMR_SETMAPMODE : + { + UINT32 nMapMode; + *pWMF >> nMapMode; + if ( nMapMode ) + break; + } + break; + + case EMR_SETBKMODE : + { + *pWMF >> nDat32; + pOut->SetBkMode( nDat32 ); + } + break; + + case EMR_SETPOLYFILLMODE : + break; + + case EMR_SETROP2 : + { + *pWMF >> nDat32; + pOut->SetRasterOp( nDat32 ); + } + break; + + case EMR_SETSTRETCHBLTMODE : + { + *pWMF >> nStretchBltMode; + } + break; + + case EMR_SETTEXTALIGN : + { + *pWMF >> nDat32; + pOut->SetTextAlign( nDat32 ); + } + break; + + case EMR_SETCOLORADJUSTMENT : + break; + + case EMR_SETTEXTCOLOR : + { + pOut->SetTextColor( ReadColor() ); + } + break; + + case EMR_SETBKCOLOR : + { + pOut->SetBkColor( ReadColor() ); + } + break; + + case EMR_OFFSETCLIPRGN : + { + *pWMF >> nX32 >> nY32; + pOut->MoveClipRegion( Size( nX32, nY32 ) ); + } + break; + + case EMR_MOVETOEX : + { + *pWMF >> nX32 >> nY32; + pOut->MoveTo( Point( nX32, nY32 ) ); + } + break; + + case EMR_SETMETARGN : + case EMR_EXCLUDECLIPRECT : + break; + + case EMR_INTERSECTCLIPRECT : + { + *pWMF >> nX32 >> nY32 >> nx32 >> ny32; + pOut->IntersectClipRect( ReadRectangle( nX32, nY32, nx32, ny32 ) ); + } + break; + + case EMR_SAVEDC : + { + pOut->Push(); + } + break; + + case EMR_RESTOREDC : + { + pOut->Pop(); + } + break; + + case EMR_SETWORLDTRANSFORM : + { + XForm aTempXForm; + *pWMF >> aTempXForm.eM11 >> aTempXForm.eM12 >> aTempXForm.eM21 >> aTempXForm.eM22 >> aTempXForm.eDx >> aTempXForm.eDy; + pOut->SetWorldTransform( aTempXForm ); + } + break; + + case EMR_MODIFYWORLDTRANSFORM : + { + UINT32 nMode; + XForm aTempXForm; + *pWMF >> aTempXForm.eM11 >> aTempXForm.eM12 >> aTempXForm.eM21 >> aTempXForm.eM22 >> aTempXForm.eDx >> aTempXForm.eDy >> nMode; + pOut->ModifyWorldTransform( aTempXForm, nMode ); + } + break; + + case EMR_SELECTOBJECT : + { + *pWMF >> nIndex; + pOut->SelectObject( nIndex ); + } + break; + + case EMR_CREATEPEN : + { + *pWMF >> nIndex; + if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) + { + + LineInfo aLineInfo; + UINT32 nStyle; + Size aSize; + + *pWMF >> nStyle >> aSize.Width() >> aSize.Height(); + + if ( aSize.Width() ) + aLineInfo.SetWidth( aSize.Width() ); + + BOOL bTransparent = FALSE; + UINT16 nDashCount = 0; + UINT16 nDotCount = 0; + switch( nStyle ) + { + case PS_DASHDOTDOT : + nDotCount++; + case PS_DASHDOT : + nDashCount++; + case PS_DOT : + nDotCount++; + break; + case PS_DASH : + nDashCount++; + break; + case PS_NULL : + bTransparent = TRUE; + aLineInfo.SetStyle( LINE_NONE ); + break; + default : + case PS_INSIDEFRAME : + case PS_SOLID : + aLineInfo.SetStyle( LINE_SOLID ); + } + if ( nDashCount | nDotCount ) + { + aLineInfo.SetStyle( LINE_DASH ); + aLineInfo.SetDashCount( nDashCount ); + aLineInfo.SetDotCount( nDotCount ); + } + pOut->CreateObject( nIndex, GDI_PEN, new WinMtfLineStyle( ReadColor(), aLineInfo, bTransparent ) ); + } + } + break; + case EMR_CREATEBRUSHINDIRECT : + { + UINT32 nStyle; + *pWMF >> nIndex; + if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) + { + *pWMF >> nStyle; + pOut->CreateObject( nIndex, GDI_BRUSH, new WinMtfFillStyle( ReadColor(), ( nStyle == BS_HOLLOW ) ? TRUE : FALSE ) ); + } + } + break; + case EMR_DELETEOBJECT : + { + *pWMF >> nIndex; + if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) + pOut->DeleteObject( nIndex ); + } + break; + + case EMR_ANGLEARC : + break; + + case EMR_ELLIPSE : + { + *pWMF >> nX32 >> nY32 >> nx32 >> ny32; + pOut->DrawEllipse( ReadRectangle( nX32, nY32, nx32, ny32 ) ); + } + break; + + case EMR_RECTANGLE : + { + *pWMF >> nX32 >> nY32 >> nx32 >> ny32; + pOut->DrawRect( ReadRectangle( nX32, nY32, nx32, ny32 ) ); + } + break; + + case EMR_ROUNDRECT : + { + *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nWidth >> nHeight; + Size aSize( Size( nWidth, nHeight ) ); + pOut->DrawRoundRect( ReadRectangle( nX32, nY32, nx32, ny32 ), aSize ); + } + break; + + case EMR_ARC : + { + UINT32 nStartX, nStartY, nEndX, nEndY; + *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY; + pOut->DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) ); + } + break; + + case EMR_CHORD : + { + UINT32 nStartX, nStartY, nEndX, nEndY; + *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY; + pOut->DrawChord( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) ); + } + break; + + case EMR_PIE : + { + UINT32 nStartX, nStartY, nEndX, nEndY; + *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY; + pOut->DrawPie( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) ); + } + break; + + case EMR_SELECTPALETTE : + case EMR_CREATEPALETTE : + case EMR_SETPALETTEENTRIES : + case EMR_RESIZEPALETTE : + case EMR_REALIZEPALETTE : + case EMR_EXTFLOODFILL : + break; + + case EMR_LINETO : + { + *pWMF >> nX32 >> nY32; + pOut->LineTo( Point( nX32, nY32 ) ); + } + break; + + case EMR_ARCTO : + { + UINT32 nStartX, nStartY, nEndX, nEndY; + *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY; + pOut->DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ), TRUE ); + } + break; + case EMR_POLYDRAW : + case EMR_SETARCDIRECTION : + case EMR_SETMITERLIMIT : + case EMR_BEGINPATH : + case EMR_ENDPATH : + case EMR_CLOSEFIGURE : + case EMR_FILLPATH : + case EMR_STROKEANDFILLPATH : + case EMR_STROKEPATH : + case EMR_FLATTENPATH : + case EMR_WIDENPATH : + case EMR_SELECTCLIPPATH : + case EMR_ABORTPATH : + + case EMR_GDICOMMENT : + case EMR_FILLRGN : + case EMR_FRAMERGN : + case EMR_INVERTRGN : + case EMR_PAINTRGN : + case EMR_EXTSELECTCLIPRGN : + break; + case EMR_BITBLT : + { + UINT32 nRasterOp; + Size aDestExt; + Point aDestOrg; + Bitmap aBmp; + + pWMF->SeekRel( 0x10 ); + *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nRasterOp; + aDestOrg = Point( nX32, nY32 ); + aDestExt = Size( nx32, ny32 ); + *pWMF >> nX32 >> nY32 >> nColor; + + UINT32 nNewRop = R2_BLACK; + switch( nRasterOp ) + { + case DSTINVERT : + nNewRop = R2_NOT; + break; + case 0x00990066 : + case SRCINVERT: + nNewRop = R2_XORPEN; + break; + case BLACKNESS : + nColor = 0; + break; + case WHITENESS : + nColor = 0xffffff; + break; + } + pOut->Push(); + UINT32 nOldRop = pOut->SetRasterOp( nNewRop ); + pOut->DrawRect( Rectangle( aDestOrg, aDestExt ) ); + pOut->SetRasterOp( nOldRop ); + pOut->Pop(); + } + break; + + case EMR_STRETCHBLT : + { + INT32 xDest, yDest, cxDest, cyDest, xSrc, ySrc, cxSrc, cySrc; + UINT32 dwRop, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc; + XForm xformSrc; + + UINT32 nStartPos = pWMF->Tell() - 8; + + pWMF->SeekRel( 0x10 ); + *pWMF >> xDest >> yDest >> cxDest >> cyDest >> dwRop >> xSrc >> ySrc >> xformSrc.eM11 >> xformSrc.eM12 >> + xformSrc.eM21 >> xformSrc.eM22 >> xformSrc.eDx >> xformSrc.eDy >> nColor >> iUsageSrc >> offBmiSrc >> + cbBmiSrc >> offBitsSrc >> cbBitsSrc >> cxSrc >> cySrc; + + if ( offBmiSrc ) + { + Bitmap aBitmap; + Rectangle aRect( Point( xDest, yDest ), Size( cxDest+1, cyDest+1 ) ); + + UINT32 nSize = cbBmiSrc + cbBitsSrc + 14; + char* pBuf = new char[ nSize ]; + SvMemoryStream aTmp( pBuf, nSize, STREAM_READ | STREAM_WRITE ); + aTmp.ObjectOwnsMemory( TRUE ); + aTmp << (BYTE)'B' + << (BYTE)'M' + << (UINT32)cbBitsSrc + << (UINT16)0 + << (UINT16)0 + << (UINT32)cbBmiSrc + 14; + pWMF->Seek( nStartPos + offBmiSrc ); + pWMF->Read( pBuf + 14, cbBmiSrc ); + pWMF->Seek( nStartPos + offBitsSrc ); + pWMF->Read( pBuf + 14 + cbBmiSrc, cbBitsSrc ); + aTmp.Seek( 0 ); + aBitmap.Read( aTmp, TRUE ); + aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop ), LIST_APPEND ); + } + else + { + if( aBmpSaveList.Count() ) + pOut->ResolveBitmapActions( aBmpSaveList ); + + Point aDestOrg = Point( xDest, yDest ); + Size aDestExt = Size( cxDest, cyDest ); + + UINT32 nNewRop = R2_BLACK; + switch( dwRop ) + { + case DSTINVERT : + nNewRop = R2_NOT; + break; + case 0x00990066 : + case SRCINVERT: + nNewRop = R2_XORPEN; + break; + case BLACKNESS : + nColor = 0; + break; + case WHITENESS : + nColor = 0xffffff; + break; + } + pOut->Push(); + UINT32 nOldRop = pOut->SetRasterOp( nNewRop ); + pOut->DrawRect( Rectangle( aDestOrg, aDestExt ), FALSE ); + pOut->SetRasterOp( nOldRop ); + pOut->Pop(); + } + } + break; + + case EMR_STRETCHDIBITS : + { + INT32 xDest, yDest, xSrc, ySrc, cxSrc, cySrc, cxDest, cyDest; + UINT32 offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, iUsageSrc, dwRop; + UINT32 nStartPos = pWMF->Tell() - 8; + + pWMF->SeekRel( 0x10 ); + *pWMF >> xDest >> yDest >> xSrc >> ySrc >> cxSrc >> cySrc >> offBmiSrc >> cbBmiSrc >> offBitsSrc + >> cbBitsSrc >> iUsageSrc >> dwRop >> cxDest >> cyDest; + + Bitmap aBitmap; + Rectangle aRect( Point( xDest, yDest ), Size( cxDest+1, cyDest+1 ) ); + + UINT32 nSize = cbBmiSrc + cbBitsSrc + 14; + char* pBuf = new char[ nSize ]; + SvMemoryStream aTmp( pBuf, nSize, STREAM_READ | STREAM_WRITE ); + aTmp.ObjectOwnsMemory( TRUE ); + aTmp << (BYTE)'B' + << (BYTE)'M' + << (UINT32)cbBitsSrc + << (UINT16)0 + << (UINT16)0 + << (UINT32)cbBmiSrc + 14; + pWMF->Seek( nStartPos + offBmiSrc ); + pWMF->Read( pBuf + 14, cbBmiSrc ); + pWMF->Seek( nStartPos + offBitsSrc ); + pWMF->Read( pBuf + 14 + cbBmiSrc, cbBitsSrc ); + aTmp.Seek( 0 ); + aBitmap.Read( aTmp, TRUE ); + aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop ), LIST_APPEND ); + } + break; + + case EMR_MASKBLT : + case EMR_PLGBLT : + case EMR_SETDIBITSTODEVICE : + break; + + case EMR_EXTCREATEFONTINDIRECTW : + { + *pWMF >> nIndex; + if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) + { + LOGFONTW aLogFont; + *pWMF >> aLogFont.lfHeight >> aLogFont.lfWidth >> aLogFont.lfEscapement >> aLogFont.lfOrientation >> aLogFont.lfWeight >> aLogFont.lfItalic + >> aLogFont.lfUnderline >> aLogFont.lfStrikeOut >> aLogFont.lfCharSet >> aLogFont.lfOutPrecision >> aLogFont.lfClipPrecision + >> aLogFont.lfQuality >> aLogFont.lfPitchAndFamily; + + for ( int i = 0; i < LF_FACESIZE; i++ ) + { + UINT16 nChar; + *pWMF >> nChar; + aLogFont.lfFaceName[ i ] = (BYTE)nChar; + } + pOut->CreateObject( nIndex, GDI_FONT, new WinMtfFontStyle( aLogFont ) ); + } + } + break; + case EMR_EXTTEXTOUTA : + bFlag = TRUE; + case EMR_EXTTEXTOUTW : + { + INT32 nLeft, nTop, nRight, nBottom, ptlReferenceX, ptlReferenceY, nGfxMode, nXScale, nYScale; + UINT32 nCurPos, nLen, nOffString, nOptions, offDx; + + nCurPos = pWMF->Tell() - 8; + + *pWMF >> nLeft >> nTop >> nRight >> nBottom >> nGfxMode >> nXScale >> nYScale + >> ptlReferenceX >> ptlReferenceY >> nLen >> nOffString >> nOptions; + + pWMF->SeekRel( 0x10 ); + *pWMF >> offDx; + + Point aPos; + + if ( nGfxMode != GM_COMPATIBLE ) + aPos = Point( nLeft, nTop ); + else + aPos = Point( ptlReferenceX, ptlReferenceY ); + + UINT32 nSize = nLen; + + if ( nLen ) + { + if ( !bFlag ) + nSize <<= 1; + + BYTE* pBuf = new BYTE[ nSize + 1 ]; + + pWMF->Seek( nCurPos + nOffString ); + pWMF->Read( pBuf, nSize ); + + String aText; + if( bFlag ) + aText = String( (char*)pBuf, (USHORT)nLen, pOut->GetCharSet() ); + else + { + #ifdef __BIGENDIAN + pBuf += nSize; + BYTE nTemp; + for( UINT32 i = 0; i < nLen; i++ ) + { + pBuf -= 2; + pBuf[ 2 ] = *pBuf; + } + pBuf++; + #endif + aText = String( (sal_Unicode*)pBuf, (xub_StrLen)nLen ); + } + #ifdef __BIGENDIAN + pBuf--; + #endif + delete[] pBuf; + pOut->DrawText( aPos, aText ); + } + } + break; + + case EMR_POLYBEZIERTO16 : + bFlag = TRUE; + case EMR_POLYBEZIER16 : + { + pWMF->SeekRel( 16 ); + *pWMF >> nPoints; + UINT16 i = 0; + if ( bFlag ) + { + i++; + nPoints++; + } + Polygon aPoly( (UINT16)nPoints ); + for( ; i < (UINT16)nPoints; i++ ) + { + *pWMF >> nX16 >> nY16; + aPoly[ i ] = Point( nX16, nY16 ); + } + pOut->DrawPolyBezier( aPoly, bFlag ); // Line( aPoly, bFlag ); + } + break; + case EMR_POLYGON16 : + { + pWMF->SeekRel( 16 ); + *pWMF >> nPoints; + Polygon aPoly( (UINT16)nPoints ); + for( UINT16 k = 0; k < (UINT16)nPoints; k++ ) + { + *pWMF >> nX16 >> nY16; + aPoly[ k ] = Point( nX16, nY16 ); + } + pOut->DrawPolygon( aPoly ); + } + break; + case EMR_POLYLINETO16 : + bFlag = TRUE; + case EMR_POLYLINE16 : + { + pWMF->SeekRel( 16 ); + *pWMF >> nPoints; + UINT16 i = 0; + if ( bFlag ) + { + i++; + nPoints++; + } + + Polygon aPoly( (UINT16)nPoints ); + for( ; i < (UINT16)nPoints; i++ ) + { + *pWMF >> nX16 >> nY16; + aPoly[ i ] = Point( nX16, nY16 ); + } + pOut->DrawPolyLine( aPoly, bFlag ); + } + break; + + case EMR_POLYPOLYLINE16 : + { + UINT16* pnPoints; + + INT32 i, nPoly, nGesPoints; + pWMF->SeekRel( 0x10 ); + // Anzahl der Polygone: + *pWMF >> nPoly >> nGesPoints; + // Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln: + pnPoints = new UINT16[ nPoly ]; + for ( i = 0; i < nPoly; i++ ) + { + *pWMF >> nPoints; + pnPoints[ i ] = (UINT16)nPoints; + } + // Polygonpunkte holen: + for ( i = 0; i < nPoly; i++ ) + { + Polygon aPolygon( pnPoints[ i ] ); + for ( UINT16 k = 0; k < pnPoints[ i ]; k++ ) + { + *pWMF >> nX16 >> nY16; + aPolygon[ k ] = Point( nX16, nY16 ); + } + pOut->DrawPolyLine( aPolygon ); + } + delete pnPoints; + } + break; + + case EMR_POLYPOLYGON16 : + { + UINT16* pnPoints; + Point* pPtAry; + + INT32 i, nPoly, nGesPoints; + pWMF->SeekRel( 0x10 ); + // Anzahl der Polygone: + *pWMF >> nPoly >> nGesPoints; + // Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln: + pnPoints = new UINT16[ nPoly ]; + for ( i = 0; i < nPoly; i++ ) + { + *pWMF >> nPoints; + pnPoints[ i ] = (UINT16)nPoints; + } + // Polygonpunkte holen: + pPtAry = (Point*) new char[ nGesPoints * sizeof(Point) ]; + for ( i = 0; i < nGesPoints; i++ ) + { + *pWMF >> nX16 >> nY16; + pPtAry[ i ] = Point( nX16, nY16 ); + } + + // PolyPolygon Actions erzeugen + PolyPolygon aPolyPoly( (UINT16)nPoly, pnPoints, pPtAry ); + pOut->DrawPolyPolygon( aPolyPoly ); + delete (char*) pPtAry; + delete pnPoints; + }; + break; + case EMR_POLYDRAW16 : + break; + case EMR_CREATEMONOBRUSH : + case EMR_CREATEDIBPATTERNBRUSHPT : + case EMR_EXTCREATEPEN : + case EMR_POLYTEXTOUTA : + case EMR_POLYTEXTOUTW : + case EMR_SETICMMODE : + break; + case EMR_CREATECOLORSPACE : + case EMR_SETCOLORSPACE : + case EMR_DELETECOLORSPACE : + break; + case EMR_GLSRECORD : + case EMR_GLSBOUNDEDRECORD : + case EMR_PIXELFORMAT : + break; + + default : +// bStatus = FALSE; + break; + } + pWMF->Seek( nNextPos ); + } + if( aBmpSaveList.Count() ) + pOut->ResolveBitmapActions( aBmpSaveList ); + + if ( bStatus ) + pWMF->Seek(nEndPos); + + return bStatus; +}; + +//----------------------------------------------------------------------------------- + +BOOL EnhWMFReader::ReadHeader() +{ + Rectangle aPlaceableBound; + UINT32 nUINT32, nHeaderSize, nPalEntries; + INT32 nLeft, nTop, nRight, nBottom; + INT32 nPixX, nPixY, nMillX, nMillY; + + // METAFILEHEADER SPARE ICH MIR HIER + // Einlesen des METAHEADER + *pWMF >> nUINT32 >> nHeaderSize; + if ( nUINT32 != 1 ) // Typ + return FALSE; + + // bound size + pWMF->SeekRel( 16 ); + + // picture frame size + *pWMF >> nLeft >> nTop >> nRight >> nBottom; + aPlaceableBound.Left() = nLeft; + aPlaceableBound.Top() = nTop; + aPlaceableBound.Right() = nRight; + aPlaceableBound.Bottom() = nBottom; + + *pWMF >> nUINT32; // signature + + if ( nUINT32 != 0x464d4520 ) + return FALSE; + + *pWMF >> nUINT32; // nVersion + *pWMF >> nEndPos; // size of metafile + nEndPos += nStartPos; + *pWMF >> nRecordCount; + + if ( !nRecordCount ) + return FALSE; + + pWMF->SeekRel( 0xc ); + *pWMF >> nPalEntries >> nPixX >> nPixY >> nMillX >> nMillY; + + pOut->SetDevExt( aPlaceableBound.GetSize() ); + pOut->SetWinOrg( Point( FRound( ( (double) aPlaceableBound.Left() * nPixX ) / ( nMillX * 100.0 ) ), + FRound( ( (double) aPlaceableBound.Top() * nPixY ) / ( nMillY * 100.0 ) ) ) ); + pOut->SetWinExt( Size( FRound( ( (double) aPlaceableBound.GetWidth() * nPixX ) / ( nMillX * 100.0 ) ), + FRound( ( (double) aPlaceableBound.GetHeight() * nPixY ) / ( nMillY * 100.0 ) ) ) ); + pWMF->Seek( nStartPos + nHeaderSize ); + return TRUE; +} + +//----------------------------------------------------------------------------------- + +Rectangle EnhWMFReader::ReadRectangle( INT32 x1, INT32 y1, INT32 x2, INT32 y2 ) +{ + Point aTL ( Point( x1, y1 ) ); + Point aBR( Point( --x2, --y2 ) ); + return Rectangle( aTL, aBR ); +} + diff --git a/svtools/source/filter.vcl/wmf/makefile.mk b/svtools/source/filter.vcl/wmf/makefile.mk new file mode 100644 index 000000000000..090588e12bdf --- /dev/null +++ b/svtools/source/filter.vcl/wmf/makefile.mk @@ -0,0 +1,97 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:59:00 $ +# +# 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=SVTOOLS +TARGET=wmf +VERSION=$(UPD) + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +.IF "$(GUI)"=="WIN" +LINKFLAGS=$(LINKFLAGS) /PACKC:32768 +.ENDIF + +# --- Files -------------------------------------------------------- + +CXXFILES= wmf.cxx \ + winmtf.cxx \ + winwmf.cxx \ + enhwmf.cxx \ + emfwr.cxx \ + wmfwr.cxx + +SLOFILES= $(SLO)$/wmf.obj \ + $(SLO)$/winmtf.obj \ + $(SLO)$/winwmf.obj \ + $(SLO)$/enhwmf.obj \ + $(SLO)$/emfwr.obj \ + $(SLO)$/wmfwr.obj + +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk diff --git a/svtools/source/filter.vcl/wmf/winmtf.cxx b/svtools/source/filter.vcl/wmf/winmtf.cxx new file mode 100644 index 000000000000..e00ff00c7c78 --- /dev/null +++ b/svtools/source/filter.vcl/wmf/winmtf.cxx @@ -0,0 +1,1262 @@ +/************************************************************************* + * + * $RCSfile: winmtf.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:59:00 $ + * + * 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 "winmtf.hxx" +#include <vcl/metaact.hxx> + +// ------------------------------------------------------------------------ + +WinMtfFontStyle::WinMtfFontStyle( LOGFONTW& rFont ) +{ + Size aFontSize( Size( 0, rFont.lfHeight ) ); + + aFont.SetName( UniString( (char*)rFont.lfFaceName, RTL_TEXTENCODING_UTF8 ) ); + aFont.SetSize( aFontSize ); + + CharSet eCharSet; + switch ( rFont.lfCharSet ) + { + case ANSI_CHARSET: + eCharSet = RTL_TEXTENCODING_MS_1252; + break; + + case SYMBOL_CHARSET: + eCharSet = RTL_TEXTENCODING_SYMBOL; + break; + + case OEM_CHARSET: + case DEFAULT_CHARSET: + case SHIFTJIS_CHARSET: + case HANGEUL_CHARSET: + case CHINESEBIG5_CHARSET: + default: + eCharSet = gsl_getSystemTextEncoding(); + break; + } + aFont.SetCharSet( eCharSet ); + + FontFamily eFamily; + switch ( rFont.lfPitchAndFamily & 0xf0 ) + { + case FF_ROMAN: + eFamily = FAMILY_ROMAN; + break; + + case FF_SWISS: + eFamily = FAMILY_SWISS; + break; + + case FF_MODERN: + eFamily = FAMILY_MODERN; + break; + + case FF_SCRIPT: + eFamily = FAMILY_SCRIPT; + break; + + case FF_DECORATIVE: + eFamily = FAMILY_DECORATIVE; + break; + + default: + eFamily = FAMILY_DONTKNOW; + break; + } + aFont.SetFamily( eFamily ); + + FontPitch ePitch; + switch ( rFont.lfPitchAndFamily & 0x0f ) + { + case FIXED_PITCH: + ePitch = PITCH_FIXED; + break; + + case DEFAULT_PITCH: + case VARIABLE_PITCH: + default: + ePitch = PITCH_VARIABLE; + break; + } + aFont.SetPitch( ePitch ); + + FontWeight eWeight; + if( rFont.lfWeight <= FW_THIN ) + eWeight = WEIGHT_THIN; + else if( rFont.lfWeight <= FW_ULTRALIGHT ) + eWeight = WEIGHT_ULTRALIGHT; + else if( rFont.lfWeight <= FW_LIGHT ) + eWeight = WEIGHT_LIGHT; + else if( rFont.lfWeight < FW_MEDIUM ) + eWeight = WEIGHT_NORMAL; + else if( rFont.lfWeight == FW_MEDIUM ) + eWeight = WEIGHT_MEDIUM; + else if( rFont.lfWeight <= FW_SEMIBOLD ) + eWeight = WEIGHT_SEMIBOLD; + else if( rFont.lfWeight <= FW_BOLD ) + eWeight = WEIGHT_BOLD; + else if( rFont.lfWeight <= FW_ULTRABOLD ) + eWeight = WEIGHT_ULTRABOLD; + else + eWeight = WEIGHT_BLACK; + aFont.SetWeight( eWeight ); + + if( rFont.lfItalic ) + aFont.SetItalic( ITALIC_NORMAL ); + + if( rFont.lfUnderline ) + aFont.SetUnderline( UNDERLINE_SINGLE ); + + if( rFont.lfStrikeOut ) + aFont.SetStrikeout( STRIKEOUT_SINGLE ); + + if ( rFont.lfOrientation ) + aFont.SetOrientation( (short)rFont.lfOrientation ); + else + aFont.SetOrientation( (short)rFont.lfEscapement ); +}; + +// ------------------------------------------------------------------------ + +WinMtf::WinMtf( WinMtfOutput* pWinMtfOutput, SvStream& rStreamWMF, PFilterCallback pcallback, void * pcallerdata ) : + pOut ( pWinMtfOutput ), + pCallback ( pcallback ), + pCallerData ( pcallerdata ), + pWMF ( &rStreamWMF ) +{ + SvLockBytes *pLB = pWMF->GetLockBytes(); + if ( pLB ) + pLB->SetSynchronMode( TRUE ); + + nStartPos = pWMF->Tell(); + + pOut->SetDevOrg( Point() ); +} + +// ------------------------------------------------------------------------ + +WinMtf::~WinMtf() +{ + delete pOut; +} + +// ------------------------------------------------------------------------ + +BOOL WinMtf::Callback( USHORT nPercent ) +{ + if ( pCallback != NULL ) + { + if( (*pCallback)( pCallerData, nPercent ) ) + { + pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + return TRUE; + } + } + return FALSE; +} + +// ------------------------------------------------------------------------ + +Color WinMtf::ReadColor() +{ + UINT32 nColor; + *pWMF >> nColor; + return Color( (BYTE)nColor, (BYTE)( nColor >> 8 ), (BYTE)( nColor >> 16 ) ); +}; + +//----------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------- + +WinMtfOutput::WinMtfOutput() : + mnActTextAlign ( TA_LEFT | TA_TOP | TA_NOUPDATECP ), + mnBkMode ( OPAQUE ), + maBkColor ( COL_WHITE ), + mbNopMode ( FALSE ), + mbFontChanged ( FALSE ), + maActPos ( Point() ), + meRasterOp ( ROP_OVERPAINT ), + mnEntrys ( 16 ) +{ + maFont.SetCharSet( gsl_getSystemTextEncoding() ); + mpGDIObj = new GDIObj*[ mnEntrys ]; + for ( UINT32 i = 0; i < mnEntrys; i++ ) + { + mpGDIObj[ i ] = NULL; + } +}; + +//----------------------------------------------------------------------------------- + +WinMtfOutput::~WinMtfOutput() +{ + while( maSaveStack.Count() ) + delete maSaveStack.Pop(); + + for ( UINT32 i = 0; i < mnEntrys; i++ ) + { + delete mpGDIObj[ i ]; + } + delete mpGDIObj; +}; + +//----------------------------------------------------------------------------------- + +Point WinMtfOutput::ImplMap( const Point& rPt ) +{ + if( mnWinExtX && mnWinExtY ) + { + return Point( FRound( ( ( (double) rPt.X() - mnWinOrgX ) * mnDevWidth / mnWinExtX + mnDevOrgX ) * maXForm.eM11 ), + FRound( ( ( (double) rPt.Y() - mnWinOrgY ) * mnDevHeight / mnWinExtY + mnDevOrgY ) * maXForm.eM12 ) ); + } + else + return Point(); +}; + +// ------------------------------------------------------------------------ + +Size WinMtfOutput::ImplMap( const Size& rSz ) +{ + if( mnWinExtX && mnWinExtY ) + { + return Size( FRound( ( (double) rSz.Width() * mnDevWidth / mnWinExtX ) * maXForm.eM11 ), + FRound( ( (double) rSz.Height() * mnDevHeight / mnWinExtY ) * maXForm.eM12 ) ); + } + else + return Size(); +} + +//----------------------------------------------------------------------------------- + +Rectangle WinMtfOutput::ImplMap( const Rectangle& rRect ) +{ + return Rectangle( ImplMap( rRect.TopLeft() ), ImplMap( rRect.GetSize() ) ); +} + +//----------------------------------------------------------------------------------- + +void WinMtfOutput::ImplMap( Font& rFont ) +{ + // !!! HACK: Wir setzen die Breite jetzt immer auf Null, + // da OS die Breite unterschiedlich interpretieren; + // muss spaeter in SV portabel gemacht werden ( KA 08.02.96 ) + Size aFontSize = ImplMap ( rFont.GetSize() ); + + if( aFontSize.Height() < 0 ) + aFontSize.Height() *= -1; + + rFont.SetSize( Size( 0, aFontSize.Height() ) ); + + if( ( mnWinExtX * mnWinExtY ) < 0 ) + rFont.SetOrientation( 3600 - rFont.GetOrientation() ); +} + +//----------------------------------------------------------------------------------- + +Polygon& WinMtfOutput::ImplMap( Polygon& rPolygon ) +{ + UINT16 nPoints = rPolygon.GetSize(); + for ( UINT16 i = 0; i < nPoints; i++ ) + { + rPolygon[ i ] = ImplMap( rPolygon[ i ] ); + } + return rPolygon; +} + +//----------------------------------------------------------------------------------- + +PolyPolygon& WinMtfOutput::ImplMap( PolyPolygon& rPolyPolygon ) +{ + UINT16 nPolys = rPolyPolygon.Count(); + for ( UINT16 i = 0; i < nPolys; ImplMap( rPolyPolygon[ i++ ] ) ); + return rPolyPolygon; +} + +//----------------------------------------------------------------------------------- + +void WinMtfOutput::SelectObject( INT32 nIndex ) +{ + GDIObj* pGDIObj = NULL; + + if ( nIndex & ENHMETA_STOCK_OBJECT ) + pGDIObj = new GDIObj(); + else + { + nIndex &= 0xffff; // zur Sicherheit: mehr als 65535 nicht zulassen + + if ( (UINT32)nIndex < mnEntrys ) + pGDIObj = mpGDIObj[ nIndex ]; + } + + if( pGDIObj == NULL ) + return; + + if ( nIndex & ENHMETA_STOCK_OBJECT ) + { + UINT16 nStockId = (BYTE)nIndex; + switch( nStockId ) + { + case WHITE_BRUSH : + { + pGDIObj->Set( GDI_BRUSH, new WinMtfFillStyle( Color( COL_WHITE ) ) ); + } + break; + case LTGRAY_BRUSH : + { + pGDIObj->Set( GDI_BRUSH, new WinMtfFillStyle( Color( COL_LIGHTGRAY ) ) ); + } + break; + case GRAY_BRUSH : + case DKGRAY_BRUSH : + { + pGDIObj->Set( GDI_BRUSH, new WinMtfFillStyle( Color( COL_GRAY ) ) ); + } + break; + case BLACK_BRUSH : + { + pGDIObj->Set( GDI_BRUSH, new WinMtfFillStyle( Color( COL_BLACK ) ) ); + } + break; + case NULL_BRUSH : + { + pGDIObj->Set( GDI_BRUSH, new WinMtfFillStyle( Color( COL_TRANSPARENT ), TRUE ) ); + } + break; + case WHITE_PEN : + { + pGDIObj->Set( GDI_PEN, new WinMtfLineStyle( Color( COL_WHITE ) ) ); + } + break; + case BLACK_PEN : + { + pGDIObj->Set( GDI_PEN, new WinMtfLineStyle( Color( COL_BLACK ) ) ); + } + break; + case NULL_PEN : + { + pGDIObj->Set( GDI_PEN, new WinMtfLineStyle( Color( COL_TRANSPARENT ), TRUE ) ); + } + break; + default: + break; + } + } + if ( pGDIObj->pStyle ) + { + switch( pGDIObj->eType ) + { + case GDI_PEN : + maLineStyle = (WinMtfLineStyle*)pGDIObj->pStyle; + break; + case GDI_BRUSH : + maFillStyle = (WinMtfFillStyle*)pGDIObj->pStyle; + break; + case GDI_FONT : + { + maFont = ((WinMtfFontStyle*)pGDIObj->pStyle)->aFont; + if ( ( mnActTextAlign & TA_BASELINE) == TA_BASELINE ) + maFont.SetAlign( ALIGN_BASELINE ); + else if( ( mnActTextAlign & TA_BOTTOM) == TA_BOTTOM ) + maFont.SetAlign( ALIGN_BOTTOM ); + else + maFont.SetAlign( ALIGN_TOP ); + + if( mnBkMode == TRANSPARENT ) + maFont.SetTransparent( TRUE ); + else + { + maFont.SetFillColor( maBkColor ); + maFont.SetTransparent( FALSE ); + } + maFont.SetColor( maTextColor ); + mbFontChanged = TRUE; + } + break; + } + } + if ( nIndex & ENHMETA_STOCK_OBJECT ) + delete pGDIObj; +} + +//----------------------------------------------------------------------------------- + +void WinMtfOutput::Push( BOOL bWinExtSet ) +{ + SaveStruct* pSave = new SaveStruct; + + pSave->aActPos = maActPos; + pSave->nActTextAlign = mnActTextAlign; + pSave->nBkMode = mnBkMode; + pSave->aBkColor = maBkColor; + pSave->bWinExtSet = bWinExtSet; + pSave->aLineStyle = maLineStyle; + pSave->aFillStyle = maFillStyle; + pSave->aTextColor = maTextColor; + pSave->aFont = maFont; + pSave->bFontChanged = mbFontChanged; + + if ( bWinExtSet ) + { + pSave->nWinOrgX = mnWinOrgX; + pSave->nWinOrgY = mnWinOrgY; + pSave->nWinExtX = mnWinExtX; + pSave->nWinExtY = mnWinExtY; + pSave->nDevOrgX = mnDevOrgX; + pSave->nDevOrgY = mnDevOrgY; + pSave->nDevWidth = mnDevWidth; + pSave->nDevHeight = mnDevHeight; + } + maSaveStack.Push( pSave ); +} + +//----------------------------------------------------------------------------------- + +void WinMtfOutput::Pop() +{ + // Die aktuellen Daten vom Stack holen + if( maSaveStack.Count() ) + { + // Die aktuelle Daten auf dem Stack sichern + SaveStruct* pSave = maSaveStack.Pop(); + + mnBkMode = pSave->nBkMode; + maBkColor = pSave->aBkColor; + maActPos = pSave->aActPos; + mnActTextAlign = pSave->nActTextAlign; + maLineStyle = pSave->aLineStyle; + maFillStyle = pSave->aFillStyle; + maTextColor = pSave->aTextColor; + maFont = pSave->aFont; + mbFontChanged = pSave->bFontChanged; + + if ( pSave->bWinExtSet ) + { + mnWinOrgX = pSave->nWinOrgX; + mnWinOrgY = pSave->nWinOrgY; + mnWinExtX = pSave->nWinExtX; + mnWinExtY = pSave->nWinExtY; + mnDevOrgX = pSave->nDevOrgX; + mnDevOrgY = pSave->nDevOrgY; + mnDevWidth = pSave->nDevWidth; + mnDevHeight = pSave->nDevHeight; + } + delete pSave; + } +} + +//----------------------------------------------------------------------------------- + +void WinMtfOutput::SetBkMode( UINT32 nMode ) +{ + maFont.SetTransparent( ( mnBkMode = nMode ) == TRANSPARENT ); + mbFontChanged = TRUE; +} + +//----------------------------------------------------------------------------------- + +void WinMtfOutput::SetBkColor( const Color& rColor ) +{ + maBkColor = rColor; + maFont.SetFillColor( rColor ); + maFont.SetTransparent( mnBkMode == TRANSPARENT ); + mbFontChanged = TRUE; +} + + +//----------------------------------------------------------------------------------- + +void WinMtfOutput::SetTextColor( const Color& rColor ) +{ + maTextColor = rColor; + maFont.SetColor( rColor ); + mbFontChanged = TRUE; +} + +//----------------------------------------------------------------------------------- + +void WinMtfOutput::SetTextAlign( UINT32 nAlign ) +{ + mnActTextAlign = nAlign; + + if ( ( mnActTextAlign & TA_BASELINE ) == TA_BASELINE ) + maFont.SetAlign( ALIGN_BASELINE ); + else if( ( mnActTextAlign & TA_BOTTOM ) == TA_BOTTOM ) + maFont.SetAlign( ALIGN_BOTTOM ); + else + maFont.SetAlign( ALIGN_TOP ); + + mbFontChanged = TRUE; +} + +//----------------------------------------------------------------------------------- + +UINT32 WinMtfOutput::SetRasterOp( UINT32 nROP2 ) +{ + UINT32 nRetROP = mnRop; + if ( nROP2 != mnRop ) + { + mnRop = nROP2; + static WinMtfFillStyle aNopFillStyle; + static WinMtfLineStyle aNopLineStyle; + + if ( mbNopMode && ( nROP2 != R2_NOP ) ) + { // beim uebergang von R2_NOP auf anderen Modus + // gesetzten Pen und Brush aktivieren + maFillStyle = aNopFillStyle; + maLineStyle = aNopLineStyle; + mbNopMode = FALSE; + } + switch( nROP2 ) + { + case R2_NOT: + meRasterOp = ROP_INVERT; + break; + + case R2_XORPEN: + meRasterOp = ROP_XOR; + break; + + case R2_NOP: + { + meRasterOp = ROP_OVERPAINT; + if( mbNopMode = FALSE ) + { + aNopFillStyle = maFillStyle; + aNopLineStyle = maLineStyle; + maFillStyle = WinMtfFillStyle( Color( COL_TRANSPARENT ), TRUE ); + maLineStyle = WinMtfLineStyle( Color( COL_TRANSPARENT ), TRUE ); + mbNopMode = TRUE; + } + } + break; + + default: + meRasterOp = ROP_OVERPAINT; + break; + } + } + return nRetROP; +} + +//----------------------------------------------------------------------------------- + +void WinMtfOutput::ImplResizeObjectArry( UINT32 nNewEntrys ) +{ + GDIObj** pGDIObj = new GDIObj*[ mnEntrys << 1 ]; + UINT32 nIndex; + for ( nIndex = 0; nIndex < mnEntrys; nIndex++ ) + pGDIObj[ nIndex ] = mpGDIObj[ nIndex ]; + for ( mnEntrys = nNewEntrys; nIndex < mnEntrys; pGDIObj[ nIndex++ ] = NULL ); + delete mpGDIObj, mpGDIObj = pGDIObj; +} + +//----------------------------------------------------------------------------------- + +void WinMtfOutput::CreateObject( GDIObjectType eType, void* pStyle ) +{ + if ( pStyle ) + { + if ( eType == GDI_FONT ) + ImplMap( ((WinMtfFontStyle*)pStyle)->aFont ); + else if ( eType == GDI_PEN ) + { + Size aSize( ((WinMtfLineStyle*)pStyle)->aLineInfo.GetWidth(), 0 ); + ((WinMtfLineStyle*)pStyle)->aLineInfo.SetWidth( ImplMap( aSize ).Width() ); + if ( ((WinMtfLineStyle*)pStyle)->aLineInfo.GetStyle() == LINE_DASH ) + { + aSize.Width() += 1; + long nDotLen = ImplMap( aSize ).Width(); + ((WinMtfLineStyle*)pStyle)->aLineInfo.SetDistance( nDotLen ); + ((WinMtfLineStyle*)pStyle)->aLineInfo.SetDotLen( nDotLen ); + ((WinMtfLineStyle*)pStyle)->aLineInfo.SetDashLen( nDotLen * 4 ); + } + } + } + UINT32 nIndex; + for ( nIndex = 0; nIndex < mnEntrys; nIndex++ ) + { + if ( mpGDIObj[ nIndex ] == NULL ) + break; + } + if ( nIndex == mnEntrys ) + ImplResizeObjectArry( mnEntrys << 1 ); + + mpGDIObj[ nIndex ] = new GDIObj( eType, pStyle ); +} + +//----------------------------------------------------------------------------------- + +void WinMtfOutput::CreateObject( INT32 nIndex, GDIObjectType eType, void* pStyle ) +{ + if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) + { + nIndex &= 0xffff; // zur Sicherheit: mehr als 65535 nicht zulassen + if ( pStyle ) + { + if ( eType == GDI_FONT ) + ImplMap( ((WinMtfFontStyle*)pStyle)->aFont ); + else if ( eType == GDI_PEN ) + { + Size aSize( ((WinMtfLineStyle*)pStyle)->aLineInfo.GetWidth(), 0 ); + ((WinMtfLineStyle*)pStyle)->aLineInfo.SetWidth( ImplMap( aSize ).Width() ); + if ( ((WinMtfLineStyle*)pStyle)->aLineInfo.GetStyle() == LINE_DASH ) + { + aSize.Width() += 1; + long nDotLen = ImplMap( aSize ).Width(); + ((WinMtfLineStyle*)pStyle)->aLineInfo.SetDistance( nDotLen ); + ((WinMtfLineStyle*)pStyle)->aLineInfo.SetDotLen( nDotLen ); + ((WinMtfLineStyle*)pStyle)->aLineInfo.SetDashLen( nDotLen * 4 ); + } + } + } + if ( (UINT32)nIndex >= mnEntrys ) + ImplResizeObjectArry( nIndex + 16 ); + + if ( mpGDIObj[ nIndex ] != NULL ) + delete mpGDIObj[ nIndex ]; + + mpGDIObj[ nIndex ] = new GDIObj( eType, pStyle ); + } + else + delete pStyle; +} + +//----------------------------------------------------------------------------------- + +void WinMtfOutput::DeleteObject( INT32 nIndex ) +{ + if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) + { + nIndex &= 0xffff; // zur Sicherheit: mehr als 65535 nicht zulassen + delete mpGDIObj[ nIndex ], mpGDIObj[ nIndex ] = NULL; + } +} + +//----------------------------------------------------------------------------------- + +void WinMtfOutput::DrawText( Point& rPosition, String& rText, INT32* pDXArry ) +{ + rPosition = ImplMap( rPosition ); + + if ( pDXArry ) + { + INT32 i, nSum, nLen = rText.Len(); + + for( i = 0, nSum = 0; i < nLen; i++ ) + { + INT32 nTemp = ImplMap( Size( pDXArry[ i ], 0 ) ).Width(); + nSum += nTemp; + pDXArry[ i ] = nSum; + } + } +} + +//----------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------- + +WinMtfMetaOutput::WinMtfMetaOutput( GDIMetaFile& rGDIMetaFile ) : WinMtfOutput() +{ + maLatestLineStyle.aLineColor = Color( 0x12, 0x34, 0x56 ); + maLatestFillStyle.aFillColor = Color( 0x12, 0x34, 0x56 ); + mpGDIMetaFile = &rGDIMetaFile; + mnPushPopCount = 0; + + mnRop = R2_BLACK + 1; + SetRasterOp( R2_BLACK ); +}; + +//----------------------------------------------------------------------------------- + +WinMtfMetaOutput::~WinMtfMetaOutput() +{ + while( mnPushPopCount > 0 ) + { + mpGDIMetaFile->AddAction( new MetaPopAction() ); + mnPushPopCount--; + } + mpGDIMetaFile->SetPrefMapMode( MAP_100TH_MM ); + mpGDIMetaFile->SetPrefSize( Size( mnDevWidth, mnDevHeight ) ); +}; + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::UpdateLineStyle() +{ + if (!( maLatestLineStyle == maLineStyle ) ) + { + maLatestLineStyle = maLineStyle; + mpGDIMetaFile->AddAction( new MetaLineColorAction( maLineStyle.aLineColor, !maLineStyle.bTransparent ) ); + } +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::UpdateFillStyle() +{ + if (!( maLatestFillStyle == maFillStyle ) ) + { + maLatestFillStyle = maFillStyle; + mpGDIMetaFile->AddAction( new MetaFillColorAction( maFillStyle.aFillColor, !maFillStyle.bTransparent ) ); + } +} + +//----------------------------------------------------------------------------------- + +UINT32 WinMtfMetaOutput::SetRasterOp( UINT32 nRasterOp ) +{ + UINT32 nRetROP = WinMtfOutput::SetRasterOp( nRasterOp ); + if ( nRetROP != nRasterOp ) + mpGDIMetaFile->AddAction( new MetaRasterOpAction( meRasterOp ) ); + return nRetROP; +}; + + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::DrawPixel( const Point& rSource, const Color& rColor ) +{ + mpGDIMetaFile->AddAction( new MetaPixelAction( ImplMap( rSource), rColor ) ); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::LineTo( const Point& rPoint ) +{ + Point aDest( ImplMap( rPoint ) ); + UpdateLineStyle(); + mpGDIMetaFile->AddAction( new MetaLineAction( maActPos, aDest, maLineStyle.aLineInfo ) ); + maActPos = aDest; +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::DrawLine( const Point& rSource, const Point& rDest ) +{ + UpdateLineStyle(); + mpGDIMetaFile->AddAction( new MetaLineAction( ImplMap( rSource), ImplMap( rDest ), maLineStyle.aLineInfo ) ); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::DrawRect( const Rectangle& rRect, BOOL bEdge ) +{ + UpdateFillStyle(); + if ( bEdge ) + { + if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LINE_DASH ) ) + { + mpGDIMetaFile->AddAction( new MetaPushAction( PUSH_LINECOLOR ) ); + mpGDIMetaFile->AddAction( new MetaLineColorAction( maLineStyle.aLineColor, FALSE ) ); + mpGDIMetaFile->AddAction( new MetaRectAction( ImplMap( rRect ) ) ); + mpGDIMetaFile->AddAction( new MetaLineColorAction( maLineStyle.aLineColor, !maLineStyle.bTransparent ) ); + mpGDIMetaFile->AddAction( new MetaPolyLineAction( Polygon( ImplMap( rRect ) ),maLineStyle.aLineInfo ) ); + mpGDIMetaFile->AddAction( new MetaPopAction() ); + } + else + { + UpdateLineStyle(); + mpGDIMetaFile->AddAction( new MetaRectAction( ImplMap( rRect ) ) ); + } + } + else + { + mpGDIMetaFile->AddAction( new MetaPushAction( PUSH_LINECOLOR ) ); + mpGDIMetaFile->AddAction( new MetaLineColorAction( Color(), FALSE ) ); + mpGDIMetaFile->AddAction( new MetaRectAction( ImplMap( rRect ) ) ); + mpGDIMetaFile->AddAction( new MetaPopAction() ); + } +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::DrawRoundRect( const Rectangle& rRect, const Size& rSize ) +{ + UpdateLineStyle(); + UpdateFillStyle(); + mpGDIMetaFile->AddAction( new MetaRoundRectAction( ImplMap( rRect ), labs( ImplMap( rSize ).Width() ), labs( ImplMap( rSize ).Height() ) ) ); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::DrawEllipse( const Rectangle& rRect ) +{ + UpdateFillStyle(); + + if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LINE_DASH ) ) + { + Point aCenter( ImplMap( rRect.Center() ) ); + Size aRad( ImplMap( Size( rRect.GetWidth() / 2, rRect.GetHeight() / 2 ) ) ); + + mpGDIMetaFile->AddAction( new MetaPushAction( PUSH_LINECOLOR ) ); + mpGDIMetaFile->AddAction( new MetaLineColorAction( maLineStyle.aLineColor, FALSE ) ); + mpGDIMetaFile->AddAction( new MetaEllipseAction( ImplMap( rRect ) ) ); + mpGDIMetaFile->AddAction( new MetaLineColorAction( maLineStyle.aLineColor, !maLineStyle.bTransparent ) ); + mpGDIMetaFile->AddAction( new MetaPolyLineAction( Polygon( aCenter, aRad.Width(), aRad.Height() ), maLineStyle.aLineInfo ) ); + mpGDIMetaFile->AddAction( new MetaPopAction() ); + } + else + { + UpdateLineStyle(); + mpGDIMetaFile->AddAction( new MetaEllipseAction( ImplMap( rRect ) ) ); + } +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::DrawArc( const Rectangle& rRect, const Point& rStart, const Point& rEnd, BOOL bTo ) +{ + UpdateLineStyle(); + UpdateFillStyle(); + + Rectangle aRect( ImplMap( rRect ) ); + Point aStart( ImplMap( rStart ) ); + Point aEnd( ImplMap( rEnd ) ); + + if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LINE_DASH ) ) + mpGDIMetaFile->AddAction( new MetaPolyLineAction( Polygon( aRect, aStart, aEnd, POLY_ARC ), maLineStyle.aLineInfo ) ); + else + mpGDIMetaFile->AddAction( new MetaArcAction( aRect, aStart, aEnd ) ); + + if ( bTo ) + maActPos = aEnd; +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::DrawPie( const Rectangle& rRect, const Point& rStart, const Point& rEnd ) +{ + UpdateFillStyle(); + + Rectangle aRect( ImplMap( rRect ) ); + Point aStart( ImplMap( rStart ) ); + Point aEnd( ImplMap( rEnd ) ); + + if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LINE_DASH ) ) + { + mpGDIMetaFile->AddAction( new MetaPushAction( PUSH_LINECOLOR ) ); + mpGDIMetaFile->AddAction( new MetaLineColorAction( maLineStyle.aLineColor, FALSE ) ); + mpGDIMetaFile->AddAction( new MetaPieAction( aRect, aStart, aEnd ) ); + mpGDIMetaFile->AddAction( new MetaLineColorAction( maLineStyle.aLineColor, !maLineStyle.bTransparent ) ); + mpGDIMetaFile->AddAction( new MetaPolyLineAction( Polygon( aRect, aStart, aEnd, POLY_PIE ), maLineStyle.aLineInfo ) ); + mpGDIMetaFile->AddAction( new MetaPopAction() ); + } + else + { + UpdateLineStyle(); + mpGDIMetaFile->AddAction( new MetaPieAction( aRect, aStart, aEnd ) ); + } +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::DrawChord( const Rectangle& rRect, const Point& rStart, const Point& rEnd ) +{ + UpdateFillStyle(); + + Rectangle aRect( ImplMap( rRect ) ); + Point aStart( ImplMap( rStart ) ); + Point aEnd( ImplMap( rEnd ) ); + + if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LINE_DASH ) ) + { + mpGDIMetaFile->AddAction( new MetaPushAction( PUSH_LINECOLOR ) ); + mpGDIMetaFile->AddAction( new MetaLineColorAction( maLineStyle.aLineColor, FALSE ) ); + mpGDIMetaFile->AddAction( new MetaChordAction( aRect, aStart, aEnd ) ); + mpGDIMetaFile->AddAction( new MetaLineColorAction( maLineStyle.aLineColor, !maLineStyle.bTransparent ) ); + mpGDIMetaFile->AddAction( new MetaPolyLineAction( Polygon( aRect, aStart, aEnd, POLY_CHORD ), maLineStyle.aLineInfo ) ); + mpGDIMetaFile->AddAction( new MetaPopAction() ); + } + else + { + UpdateLineStyle(); + mpGDIMetaFile->AddAction( new MetaChordAction( aRect, aStart, aEnd ) ); + } +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::DrawPolygon( Polygon& rPolygon ) +{ + UpdateFillStyle(); + + if ( maLineStyle.aLineInfo.GetWidth() || ( maLineStyle.aLineInfo.GetStyle() == LINE_DASH ) ) + { + USHORT nCount = rPolygon.GetSize(); + if ( nCount ) + { + if ( rPolygon[ nCount - 1 ] != rPolygon[ 0 ] ) + { + Point aPoint( rPolygon[ 0 ] ); + rPolygon.Insert( nCount, aPoint ); + } + } + mpGDIMetaFile->AddAction( new MetaPushAction( PUSH_LINECOLOR ) ); + mpGDIMetaFile->AddAction( new MetaLineColorAction( maLineStyle.aLineColor, FALSE ) ); + mpGDIMetaFile->AddAction( new MetaPolygonAction( ImplMap( rPolygon ) ) ); + mpGDIMetaFile->AddAction( new MetaLineColorAction( maLineStyle.aLineColor, !maLineStyle.bTransparent ) ); + mpGDIMetaFile->AddAction( new MetaPolyLineAction( rPolygon, maLineStyle.aLineInfo ) ); + mpGDIMetaFile->AddAction( new MetaPopAction() ); + } + else + { + UpdateLineStyle(); + mpGDIMetaFile->AddAction( new MetaPolygonAction( ImplMap( rPolygon ) ) ); + } +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::DrawPolyPolygon( PolyPolygon& rPolyPolygon ) +{ + UpdateLineStyle(); + UpdateFillStyle(); + mpGDIMetaFile->AddAction( new MetaPolyPolygonAction( ImplMap( rPolyPolygon ) ) ); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::DrawPolyLine( Polygon& rPolygon, BOOL bTo ) +{ + UpdateLineStyle(); + ImplMap( rPolygon ); + if ( bTo ) + { + rPolygon[ 0 ] = maActPos; + maActPos = rPolygon[ rPolygon.GetSize() - 1 ]; + } + mpGDIMetaFile->AddAction( new MetaPolyLineAction( rPolygon, maLineStyle.aLineInfo ) ); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::DrawPolyBezier( Polygon& rPolygon, BOOL bTo ) +{ + UpdateLineStyle(); + UINT16 nPoints = rPolygon.GetSize(); + if ( ( nPoints >= 4 ) && ( ( ( nPoints - 4 ) % 3 ) == 0 ) ) + { + ImplMap( rPolygon ); + if ( bTo ) + { + rPolygon[ 0 ] = maActPos; + maActPos = rPolygon[ nPoints - 1 ]; + } + // create bezier polygon + const USHORT nSegPoints = 25; + const USHORT nSegments = ( ( nPoints - 4 ) / 3 ) + 1; + Polygon aBezPoly( nSegments * nSegPoints ); + + USHORT nSeg, nBezPos, nStartPos; + for( nSeg = 0, nBezPos = 0, nStartPos = 0; nSeg < nSegments; nSeg++, nStartPos += 3 ) + { + const Polygon aSegPoly( rPolygon[ nStartPos ], rPolygon[ nStartPos + 1 ], + rPolygon[ nStartPos + 3 ], rPolygon[ nStartPos + 2 ], + nSegPoints ); + for( USHORT nSegPos = 0; nSegPos < nSegPoints; ) + aBezPoly[ nBezPos++ ] = aSegPoly[ nSegPos++ ]; + } + + if( nBezPos != aBezPoly.GetSize() ) + aBezPoly.SetSize( nBezPos ); + mpGDIMetaFile->AddAction( new MetaPolyLineAction( aBezPoly, maLineStyle.aLineInfo ) ); + } +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::DrawText( Point& rPosition, String& rText, INT32* pDXArry ) +{ + WinMtfOutput::DrawText( rPosition, rText, pDXArry ); + + if( mbFontChanged ) + { + mpGDIMetaFile->AddAction( new MetaFontAction( maFont ) ); + mpGDIMetaFile->AddAction( new MetaTextAlignAction( maFont.GetAlign() ) ); + mpGDIMetaFile->AddAction( new MetaTextColorAction( maFont.GetColor() ) ); + mpGDIMetaFile->AddAction( new MetaTextFillColorAction( maFont.GetFillColor(), !maFont.IsTransparent() ) ); + mbFontChanged = FALSE; + } + + if( mnActTextAlign & ( TA_UPDATECP | TA_RIGHT_CENTER ) ) + { + VirtualDevice aVDev; + sal_Int32 nTextWidth; + + aVDev.SetMapMode( MapMode( MAP_100TH_MM ) ); + aVDev.SetFont( maFont ); + + if( pDXArry ) + { + UINT32 nLen = rText.Len(); + nTextWidth = aVDev.GetTextWidth( rText.GetChar( nLen - 1 ) ); + if( nLen > 1 ) + nTextWidth += pDXArry[ nLen - 2 ]; + } + else + nTextWidth = aVDev.GetTextWidth( rText ); + + if( mnActTextAlign & TA_UPDATECP ) + rPosition = maActPos; + + if( mnActTextAlign & TA_RIGHT_CENTER ) + rPosition.X() -= ( ( mnActTextAlign & TA_RIGHT_CENTER ) == TA_RIGHT ) ? nTextWidth : ( nTextWidth >> 1 ); + + if( mnActTextAlign & TA_UPDATECP ) + maActPos.X() = rPosition.X() + nTextWidth; + } + + if( pDXArry ) + mpGDIMetaFile->AddAction( new MetaTextArrayAction( rPosition, rText, pDXArry, 0, STRING_LEN ) ); + else + mpGDIMetaFile->AddAction( new MetaTextAction( rPosition, rText, 0, STRING_LEN ) ); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::ResolveBitmapActions( List& rSaveList ) +{ + for( ULONG i = 0, nCount = rSaveList.Count(); i < nCount; i++ ) + { + BSaveStruct* pSave1 = (BSaveStruct*) rSaveList.GetObject( i ); + BOOL bDrawn = FALSE; + + UpdateFillStyle(); + + if( i < ( nCount - 1 ) ) + { + BSaveStruct* pSave2 = (BSaveStruct*) rSaveList.GetObject( i + 1 ); + + if( ( pSave1->aOutRect == pSave2->aOutRect ) && + ( pSave1->nWinRop == SRCPAINT) && ( pSave2->nWinRop == SRCAND ) ) + { + Bitmap aMask( pSave1->aBmp ); aMask.Invert(); + BitmapEx aBmpEx( pSave2->aBmp, aMask ); + mpGDIMetaFile->AddAction( new MetaBmpExScaleAction( ImplMap( pSave1->aOutRect.TopLeft() ), ImplMap( pSave1->aOutRect.GetSize() ), aBmpEx ) ); + bDrawn = TRUE; + i++; + delete pSave2; + } + } + if( !bDrawn ) + { + UINT32 nNewROP, nOldROP; + switch( pSave1->nWinRop ) + { + case DSTINVERT: nNewROP = R2_NOT; break; + case SRCINVERT: nNewROP = R2_XORPEN; break; + default: nNewROP = R2_BLACK; break; + } + nOldROP = SetRasterOp( nNewROP ); + mpGDIMetaFile->AddAction( new MetaBmpScaleAction( ImplMap( pSave1->aOutRect.TopLeft() ), ImplMap( pSave1->aOutRect.GetSize() ), pSave1->aBmp ) ); + SetRasterOp( nOldROP ); + } + delete pSave1; + } + rSaveList.Clear(); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::IntersectClipRect( const Rectangle& rRect ) +{ + mpGDIMetaFile->AddAction( new MetaISectRectClipRegionAction( ImplMap( rRect ) ) ); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::MoveClipRegion( const Size& rSize ) +{ + Size aSize( ImplMap( rSize ) ); + mpGDIMetaFile->AddAction( new MetaMoveClipRegionAction( aSize.Width(), aSize.Height() ) ); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::SetDevOrg( const Point& rPoint ) +{ + mnDevOrgX = rPoint.X(); + mnDevOrgY = rPoint.Y(); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::SetDevOrgOffset( INT32 nXAdd, INT32 nYAdd ) +{ + mnDevOrgX += nXAdd; + mnDevOrgY += nYAdd; +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::SetDevExt( const Size& rSize ) +{ + mnDevWidth = rSize.Width(); + mnDevHeight = rSize.Height(); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::ScaleDevExt( double fX, double fY ) +{ + mnDevWidth = FRound( mnDevWidth * fX ); + mnDevHeight = FRound( mnDevHeight * fY ); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::SetWinOrg( const Point& rPoint ) +{ + mnWinOrgX = rPoint.X(); + mnWinOrgY = rPoint.Y(); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::SetWinOrgOffset( INT32 nXAdd, INT32 nYAdd ) +{ + mnWinOrgX += nXAdd; + mnWinOrgY += nYAdd; +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::SetWinExt( const Size& rSize ) +{ + mnWinExtX = rSize.Width(); + mnWinExtY = rSize.Height(); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::ScaleWinExt( double fX, double fY ) +{ + mnWinExtX = FRound( mnWinExtX * fX ); + mnWinExtY = FRound( mnWinExtY * fY ); +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::SetWorldTransform( const XForm& rXForm ) +{ + maXForm.eM11 = rXForm.eM11; + maXForm.eM12 = rXForm.eM12; + maXForm.eM21 = rXForm.eM21; + maXForm.eM22 = rXForm.eM22; + maXForm.eDx = rXForm.eDx; + maXForm.eDy = rXForm.eDy; +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::ModifyWorldTransform( const XForm& rXForm, UINT32 nMode ) +{ + switch( nMode ) + { + case MWT_IDENTITY : + { + maXForm.eM11 = maXForm.eM12 = maXForm.eM21 = maXForm.eM22 = 1.0f; + maXForm.eDx = maXForm.eDx = 0.0f; + } + break; + + case MWT_LEFTMULTIPLY : + case MWT_RIGHTMULTIPLY : + break; + } + } + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::Push( BOOL bExtSet ) +{ + WinMtfOutput::Push( bExtSet ); + // bei SaveDC muessen wir die verzoegerte Selektion + // von Objekten umgehen, damit beim RestoreDC wieder + // die richtigen Objekte selektiert werden + UpdateLineStyle(); + UpdateFillStyle(); + if( mbFontChanged ) + { + mpGDIMetaFile->AddAction( new MetaFontAction( maFont ) ); + mpGDIMetaFile->AddAction( new MetaTextAlignAction( maFont.GetAlign() ) ); + mpGDIMetaFile->AddAction( new MetaTextColorAction( maFont.GetColor() ) ); + mpGDIMetaFile->AddAction( new MetaTextFillColorAction( maFont.GetFillColor(), !maFont.IsTransparent() ) ); + mbFontChanged = FALSE; + } + mpGDIMetaFile->AddAction( new MetaPushAction( PUSH_ALL ) ); + mnPushPopCount++; +} + +//----------------------------------------------------------------------------------- + +void WinMtfMetaOutput::Pop() +{ + WinMtfOutput::Pop(); + maLatestLineStyle = maLineStyle; + maLatestFillStyle = maFillStyle; + if( mnPushPopCount > 0 ) + { + mpGDIMetaFile->AddAction( new MetaPopAction() ); + mnPushPopCount--; + } +} + diff --git a/svtools/source/filter.vcl/wmf/winmtf.hxx b/svtools/source/filter.vcl/wmf/winmtf.hxx new file mode 100644 index 000000000000..2d129a55ab6b --- /dev/null +++ b/svtools/source/filter.vcl/wmf/winmtf.hxx @@ -0,0 +1,687 @@ +/************************************************************************* + * + * $RCSfile: winmtf.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:59:00 $ + * + * 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 _WINMTF_HXX +#define _WINMTF_HXX + +#include <math.h> +#include <stdlib.h> +#include <sot/object.hxx> +#ifndef _TOOL_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _STACK_HXX +#include <tools/stack.hxx> +#endif +#ifndef _TOOLS_TABLE_HXX +#include <tools/table.hxx> +#endif +#ifndef _DYNARY_HXX +#include <tools/dynary.hxx> +#endif +#ifndef _SV_GRAPH_HXX +#include <vcl/graph.hxx> +#endif +#ifndef _SV_VIRDEV_HXX +#include <vcl/virdev.hxx> +#endif +#ifndef _SV_POLY_HXX +#include <vcl/poly.hxx> +#endif +#ifndef _SV_FONT_HXX +#include <vcl/font.hxx> +#endif +#ifndef _SV_BMPACC_HXX +#include <vcl/bmpacc.hxx> +#endif +#ifndef _SV_LINEINFO_HXX +#include <vcl/lineinfo.hxx> +#endif +#ifndef _FLTCALL_HXX +#include <fltcall.hxx> +#endif + + +#define TRANSPARENT 1 +#define OPAQUE 2 +#define BKMODE_LAST 2 + +/* xform stuff */ +#define MWT_IDENTITY 1 +#define MWT_LEFTMULTIPLY 2 +#define MWT_RIGHTMULTIPLY 3 + +#define ENHMETA_STOCK_OBJECT 0x80000000 + +/* Stock Logical Objects */ +#define WHITE_BRUSH 0 +#define LTGRAY_BRUSH 1 +#define GRAY_BRUSH 2 +#define DKGRAY_BRUSH 3 +#define BLACK_BRUSH 4 +#define NULL_BRUSH 5 +#define HOLLOW_BRUSH NULL_BRUSH +#define WHITE_PEN 6 +#define BLACK_PEN 7 +#define NULL_PEN 8 +#define OEM_FIXED_FONT 10 +#define ANSI_FIXED_FONT 11 +#define ANSI_VAR_FONT 12 +#define SYSTEM_FONT 13 +#define DEVICE_DEFAULT_FONT 14 +#define DEFAULT_PALETTE 15 +#define SYSTEM_FIXED_FONT 16 + + +#define R2_BLACK 1 +#define R2_NOTMERGEPEN 2 +#define R2_MASKNOTPEN 3 +#define R2_NOTCOPYPEN 4 +#define R2_MASKPENNOT 5 +#define R2_NOT 6 +#define R2_XORPEN 7 +#define R2_NOTMASKPEN 8 +#define R2_MASKPEN 9 +#define R2_NOTXORPEN 10 +#define R2_NOP 11 +#define R2_MERGENOTPEN 12 +#define R2_COPYPEN 13 +#define R2_MERGEPENNOT 14 +#define R2_MERGEPEN 15 +#define R2_WHITE 16 + +/* Mapping Modes */ +#define MM_TEXT 1 +#define MM_LOMETRIC 2 +#define MM_HIMETRIC 3 +#define MM_LOENGLISH 4 +#define MM_HIENGLISH 5 +#define MM_TWIPS 6 +#define MM_ISOTROPIC 7 +#define MM_ANISOTROPIC 8 + + +/* Graphics Modes */ +#define GM_COMPATIBLE 1 +#define GM_ADVANCED 2 +#define GM_LAST 2 + +/* StretchBlt() Modes */ +#define BLACKONWHITE 1 +#define WHITEONBLACK 2 +#define COLORONCOLOR 3 +#define HALFTONE 4 +#define MAXSTRETCHBLTMODE 4 +#define STRETCH_ANDSCANS BLACKONWHITE +#define STRETCH_ORSCANS WHITEONBLACK +#define STRETCH_DELETESCANS COLORONCOLOR +#define STRETCH_HALFTONE HALFTONE + +#define LF_FACESIZE 32 + +struct LOGFONTW +{ + INT32 lfHeight; + INT32 lfWidth; + INT32 lfEscapement; + INT32 lfOrientation; + INT32 lfWeight; + BYTE lfItalic; + BYTE lfUnderline; + BYTE lfStrikeOut; + BYTE lfCharSet; + BYTE lfOutPrecision; + BYTE lfClipPrecision; + BYTE lfQuality; + BYTE lfPitchAndFamily; + BYTE lfFaceName[ LF_FACESIZE ]; +}; + +#define TA_NOUPDATECP 0x0000 +#define TA_UPDATECP 0x0001 +#define TA_LEFT 0x0000 +#define TA_RIGHT 0x0002 +#define TA_CENTER 0x0006 +#define TA_RIGHT_CENTER (TA_RIGHT | TA_CENTER) +#define TA_TOP 0x0000 +#define TA_BOTTOM 0x0008 +#define TA_BASELINE 0x0018 + +#define SRCCOPY 0x00CC0020L +#define SRCPAINT 0x00EE0086L +#define SRCAND 0x008800C6L +#define SRCINVERT 0x00660046L +#define SRCERASE 0x00440328L +#define NOTSRCCOPY 0x00330008L +#define NOTSRCERASE 0x001100A6L +#define MERGECOPY 0x00C000CAL +#define MERGEPAINT 0x00BB0226L +#define PATCOPY 0x00F00021L +#define PATPAINT 0x00FB0A09L +#define PATINVERT 0x005A0049L +#define DSTINVERT 0x00550009L +#define BLACKNESS 0x00000042L +#define WHITENESS 0x00FF0062L + +#define PS_SOLID 0 +#define PS_DASH 1 +#define PS_DOT 2 +#define PS_DASHDOT 3 +#define PS_DASHDOTDOT 4 +#define PS_NULL 5 +#define PS_INSIDEFRAME 6 + +#define ANSI_CHARSET 0 +#define DEFAULT_CHARSET 1 +#define SYMBOL_CHARSET 2 +#define SHIFTJIS_CHARSET 128 +#define HANGEUL_CHARSET 129 +#define CHINESEBIG5_CHARSET 136 +#define OEM_CHARSET 255 + +#define DEFAULT_PITCH 0x00 +#define FIXED_PITCH 0x01 +#define VARIABLE_PITCH 0x02 + +/* Font Families */ +#define FF_DONTCARE 0x00 +#define FF_ROMAN 0x10 +#define FF_SWISS 0x20 +#define FF_MODERN 0x30 +#define FF_SCRIPT 0x40 +#define FF_DECORATIVE 0x50 + +#define FW_DONTCARE 0 +#define FW_THIN 100 +#define FW_EXTRALIGHT 200 +#define FW_LIGHT 300 +#define FW_NORMAL 400 +#define FW_MEDIUM 500 +#define FW_SEMIBOLD 600 +#define FW_BOLD 700 +#define FW_EXTRABOLD 800 +#define FW_HEAVY 900 +#define FW_ULTRALIGHT 200 +#define FW_REGULAR 400 +#define FW_DEMIBOLD 600 +#define FW_ULTRABOLD 800 +#define FW_BLACK 900 + +#define BS_SOLID 0 +#define BS_NULL 1 +#define BS_HOLLOW 1 +#define BS_HATCHED 2 +#define BS_PATTERN 3 +#define BS_INDEXED 4 +#define BS_DIBPATTERN 5 +#define BS_DIBPATTERNPT 6 +#define BS_PATTERN8X8 7 +#define BS_DIBPATTERN8X8 8 +#define BS_MONOPATTERN 9 + +#define W_HS_HORIZONTAL 0 +#define W_HS_VERTICAL 1 +#define W_HS_FDIAGONAL 2 +#define W_HS_BDIAGONAL 3 +#define W_HS_CROSS 4 +#define W_HS_DIAGCROSS 5 + +//============================ WMFReader ================================== + +// ----------------------------------------------------------------------------- + +struct WinMtfFontStyle +{ + Font aFont; + + WinMtfFontStyle( LOGFONTW& rLogFont ); +}; + +// ----------------------------------------------------------------------------- + +struct WinMtfFillStyle +{ + Color aFillColor; + BOOL bTransparent; + + WinMtfFillStyle() : + aFillColor ( Color( COL_BLACK ) ), + bTransparent( FALSE ) + { + }; + + WinMtfFillStyle( const Color& rColor, BOOL bTrans = FALSE ) : + aFillColor ( rColor ), + bTransparent( bTrans ) + { + }; + + BOOL operator==( const WinMtfFillStyle& rStyle ) + { return ( ( aFillColor == rStyle.aFillColor ) && ( bTransparent == rStyle.bTransparent ) ); }; + BOOL operator==( WinMtfFillStyle* pStyle ) + { return ( ( aFillColor == pStyle->aFillColor ) && ( bTransparent == pStyle->bTransparent ) ); }; + void operator=( const WinMtfFillStyle& rStyle ) { aFillColor = rStyle.aFillColor; bTransparent = rStyle.bTransparent; }; + void operator=( WinMtfFillStyle* pStyle ) { aFillColor = pStyle->aFillColor; bTransparent = pStyle->bTransparent; }; +}; + +// ----------------------------------------------------------------------------- + +struct WinMtfLineStyle +{ + Color aLineColor; + LineInfo aLineInfo; + BOOL bTransparent; + + WinMtfLineStyle() : + aLineColor ( COL_BLACK ), + bTransparent( FALSE ) {}; + + WinMtfLineStyle( const Color& rColor, BOOL bTrans = FALSE ) : + aLineColor ( rColor ), + bTransparent( bTrans ) {}; + + WinMtfLineStyle( const Color& rColor, const LineInfo rStyle, BOOL bTrans = FALSE ) : + aLineColor ( rColor ), + aLineInfo ( rStyle ), + bTransparent( bTrans ) {}; + + BOOL operator==( const WinMtfLineStyle& rStyle ) { return ( ( aLineColor == rStyle.aLineColor ) && ( bTransparent == rStyle.bTransparent ) && ( aLineInfo == rStyle.aLineInfo ) ); }; + BOOL operator==( WinMtfLineStyle* pStyle ) { return ( ( aLineColor == pStyle->aLineColor ) && ( bTransparent == pStyle->bTransparent ) && ( aLineInfo == pStyle->aLineInfo ) ); }; + void operator=( const WinMtfLineStyle& rStyle ) + { + aLineColor = rStyle.aLineColor; + bTransparent = rStyle.bTransparent; + aLineInfo = rStyle.aLineInfo; + }; + + void operator=( WinMtfLineStyle* pStyle ) + { + aLineColor = pStyle->aLineColor; + bTransparent = pStyle->bTransparent; + aLineInfo = pStyle->aLineInfo; + }; +}; + +// ----------------------------------------------------------------------------- + +struct SaveStruct +{ + UINT32 nBkMode; + BOOL bWinExtSet; + long nWinOrgX, nWinOrgY, nWinExtX, nWinExtY; + long nDevOrgX, nDevOrgY, nDevWidth, nDevHeight; + WinMtfLineStyle aLineStyle; + WinMtfFillStyle aFillStyle; + Color aBkColor; + Color aTextColor; + Point aActPos; + BOOL bFontChanged; + Font aFont; + UINT32 nActTextAlign; +}; + +DECLARE_STACK( SaveStack, SaveStruct* ); + +// ----------------------------------------------------------------------------- + +struct BSaveStruct +{ + Bitmap aBmp; + Rectangle aOutRect; + UINT32 nWinRop; + + BSaveStruct( const Bitmap& rBmp, const Rectangle& rOutRect, UINT32 nRop ) : + aBmp( rBmp ), aOutRect( rOutRect ), nWinRop( nRop ){}; +}; + +// ----------------------------------------------------------------------------- + +enum GDIObjectType { GDI_DUMMY = 0, GDI_PEN = 1, GDI_BRUSH = 2, GDI_FONT = 3, GDI_PALETTE = 4, GDI_BITMAP = 5, GDI_REGION = 6 }; + +struct GDIObj +{ + void* pStyle; + GDIObjectType eType; + + GDIObj() : + pStyle ( NULL ), + eType ( GDI_DUMMY ) + { + }; + + GDIObj( GDIObjectType eT, void* pS ) { pStyle = pS; eType = eT; }; + void Set( GDIObjectType eT, void* pS ) { pStyle = pS; eType = eT; }; + void Delete() + { + if ( pStyle ) + { + switch ( eType ) + { + case GDI_PEN : + delete (WinMtfLineStyle*)pStyle; + break; + case GDI_BRUSH : + delete (WinMtfFillStyle*)pStyle; + break; + case GDI_FONT : + delete (WinMtfFontStyle*)pStyle; + break; + + default: + delete pStyle; + } + pStyle = NULL; + } + }; + + ~GDIObj() + { + Delete(); + } +}; + +// ----------------------------------------------------------------------------- + +struct XForm +{ + float eM11; + float eM12; + float eM21; + float eM22; + float eDx; + float eDy; + XForm() + { + eM11 = eM12 = eM21 = eM22 = 1.0f; + eDx = eDx = 0.0f; + }; +}; + +// ----------------------------------------------------------------------------- + +class WinMtfOutput +{ + protected: + + GDIObj** mpGDIObj; + UINT32 mnEntrys; + UINT32 mnActTextAlign; // Aktuelle Textausrichtung (im MS-Windows-Format) + UINT32 mnBkMode; // Aktueller Modus, wie der Hintergrund uebermalt + Point maActPos; // wird. (ist gleich TRANSPARENT oder nicht) + + + BOOL mbFontChanged; + Font maFont; + WinMtfLineStyle maLineStyle; + WinMtfFillStyle maFillStyle; + + Color maTextColor; + Color maBkColor; + + UINT32 mnRop; + RasterOp meRasterOp; + BOOL mbNopMode; + + SaveStack maSaveStack; // Stapel fuer aktuelle Zustaende bzw. DCs (Drawing-Contexts) + + XForm maXForm; + long mnDevOrgX, mnDevOrgY; + long mnDevWidth, mnDevHeight; + long mnWinOrgX, mnWinOrgY; // aktuelles Window-Origin + long mnWinExtX, mnWinExtY; // aktuelles Window-Extent + + Point ImplMap( const Point& rPt ); + Size ImplMap( const Size& rSz ); + Rectangle ImplMap( const Rectangle& rRectangle ); + void ImplMap( Font& rFont ); + Polygon& ImplMap( Polygon& rPolygon ); + PolyPolygon& ImplMap( PolyPolygon& rPolyPolygon ); + void ImplResizeObjectArry( UINT32 nNewEntry ); + + public: + + virtual void SetDevOrg( const Point& rPoint ) {}; + virtual void SetDevOrgOffset( INT32 nXAdd, INT32 nYAdd ){}; + virtual void SetDevExt( const Size& rSize ){}; + virtual void ScaleDevExt( double fX, double fY ){}; + + virtual void SetWinOrg( const Point& rPoint ){}; + virtual void SetWinOrgOffset( INT32 nX, INT32 nY ){}; + virtual void SetWinExt( const Size& rSize ){}; + virtual void ScaleWinExt( double fX, double fY ){}; + + virtual void SetWorldTransform( const XForm& rXForm ){}; + virtual void ModifyWorldTransform( const XForm& rXForm, UINT32 nMode ){}; + + virtual void Push( BOOL bWinExtSet = TRUE ); + virtual void Pop(); + + void SetBkMode( UINT32 nMode ); + void SetBkColor( const Color& rColor ); + void SetTextColor( const Color& rColor ); + void SetTextAlign( UINT32 nAlign ); + virtual UINT32 SetRasterOp( UINT32 nRasterOp ); + void CreateObject( GDIObjectType, void* pStyle = NULL ); + void CreateObject( INT32 nIndex, GDIObjectType, void* pStyle = NULL ); + void DeleteObject( INT32 nIndex ); + void SelectObject( INT32 nIndex ); + CharSet GetCharSet(){ return maFont.GetCharSet(); }; + + virtual void DrawPixel( const Point& rSource, const Color& rColor ){}; + void MoveTo( const Point& rPoint ) { maActPos = ImplMap( rPoint ); }; + virtual void LineTo( const Point& rPoint ){}; + virtual void DrawLine( const Point& rSource, const Point& rDest ){}; + virtual void DrawRect( const Rectangle& rRect, BOOL bEdge = TRUE ){}; + virtual void DrawRoundRect( const Rectangle& rRect, const Size& rSize ){}; + virtual void DrawEllipse( const Rectangle& rRect ){}; + virtual void DrawArc( const Rectangle& rRect, const Point& rStartAngle, const Point& rEndAngle, BOOL bDrawTo = FALSE ){}; + virtual void DrawPie( const Rectangle& rRect, const Point& rStartAngle, const Point& rEndAngle ){}; + virtual void DrawChord( const Rectangle& rRect, const Point& rStartAngle, const Point& rEndAngle ){}; + virtual void DrawPolygon( Polygon& rPolygon ){}; + virtual void DrawPolyPolygon( PolyPolygon& rPolyPolygon ){}; + virtual void DrawPolyLine( Polygon& rPolygon, BOOL bDrawTo = FALSE ){}; + virtual void DrawPolyBezier( Polygon& rPolygin, BOOL bDrawTo = FALSE ){}; + virtual void DrawText( Point& rPosition, String& rString, INT32* pDXArry = NULL ); + virtual void ResolveBitmapActions( List& rSaveList ){}; + virtual void IntersectClipRect( const Rectangle& rRectangle ){}; + virtual void MoveClipRegion( const Size& rSize ){}; + + WinMtfOutput(); + virtual ~WinMtfOutput(); +}; + +// ----------------------------------------------------------------------------- + +class WinMtfMetaOutput : public WinMtfOutput +{ + UINT32 mnPushPopCount; // hoehe des Stapels + GDIMetaFile* mpGDIMetaFile; + WinMtfLineStyle maLatestLineStyle; + WinMtfFillStyle maLatestFillStyle; + + void UpdateLineStyle(); + void UpdateFillStyle(); + + public: + + virtual void SetDevOrg( const Point& rPoint ); + virtual void SetDevOrgOffset( INT32 nXAdd, INT32 nYAdd ); + virtual void SetDevExt( const Size& rSize ); + virtual void ScaleDevExt( double fX, double fY ); + + virtual void SetWinOrg( const Point& rPoint ); + virtual void SetWinOrgOffset( INT32 nX, INT32 nY ); + virtual void SetWinExt( const Size& rSize ); + virtual void ScaleWinExt( double fX, double fY ); + + virtual void SetWorldTransform( const XForm& rXForm ); + virtual void ModifyWorldTransform( const XForm& rXForm, UINT32 nMode ); + + virtual void Push( BOOL bWinExtSet = TRUE ); + virtual void Pop(); + + virtual UINT32 SetRasterOp( UINT32 nRasterOp ); + + virtual void LineTo( const Point& rPoint ); + virtual void DrawPixel( const Point& rSource, const Color& rColor ); + virtual void DrawLine( const Point& rSource, const Point& rDest ); + virtual void DrawRect( const Rectangle& rRect, BOOL bEdge = TRUE ); + virtual void DrawRoundRect( const Rectangle& rRect, const Size& rSize ); + virtual void DrawEllipse( const Rectangle& rRect ); + virtual void DrawArc( const Rectangle& rRect, const Point& rStartAngle, const Point& rEndAngle, BOOL bDrawTo = FALSE ); + virtual void DrawPie( const Rectangle& rRect, const Point& rStartAngle, const Point& rEndAngle ); + virtual void DrawChord( const Rectangle& rRect, const Point& rStartAngle, const Point& rEndAngle ); + virtual void DrawPolygon( Polygon& rPolygon ); + virtual void DrawPolyPolygon( PolyPolygon& rPolyPolygon ); + virtual void DrawPolyLine( Polygon& rPolygon, BOOL bDrawTo = FALSE ); + virtual void DrawPolyBezier( Polygon& rPolygin, BOOL bDrawTo = FALSE ); + virtual void DrawText( Point& rPosition, String& rString, INT32* pDXArry = NULL ); + virtual void ResolveBitmapActions( List& rSaveList ); + virtual void IntersectClipRect( const Rectangle& rRectangle ); + virtual void MoveClipRegion( const Size& rSize ); + + + WinMtfMetaOutput( GDIMetaFile& rGDIMetaFile ); + virtual ~WinMtfMetaOutput(); +}; + +// ----------------------------------------------------------------------------- + +class WinMtf +{ + protected: + + WinMtfOutput* pOut; // + SvStream* pWMF; // Die einzulesende WMF/EMF-Datei + + UINT32 nStartPos, nEndPos; + List aBmpSaveList; + + PFilterCallback pCallback; + void* pCallerData; + + // Sorgt dafuer, das aSampledBrush der aktuelle Brush des GDIMetaFiles ist. + + Color ReadColor(); + BOOL Callback( USHORT nPercent ); + + WinMtf( WinMtfOutput* pOut, SvStream& rStreamWMF, PFilterCallback pcallback, void * pcallerdata ); + ~WinMtf(); + + public: + +}; + +//============================ EMFReader ================================== + +class EnhWMFReader : public WinMtf +{ + +private: + + INT32 nRecordCount; + + BOOL ReadHeader(); + Rectangle ReadRectangle( INT32, INT32, INT32, INT32 ); // Liesst und konvertiert ein Rechteck + void ImplExtTextOut( BOOL bWideCharakter ); + +public: + EnhWMFReader( SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile, + PFilterCallback pcallback, void * pcallerdata ) : WinMtf( new WinMtfMetaOutput( rGDIMetaFile ), rStreamWMF, + pcallback, pcallerdata ) {}; + + BOOL ReadEnhWMF(); +}; + +//============================ WMFReader ================================== + +class WMFReader : public WinMtf +{ +private: + + BOOL bWinExtSet; + UINT16 nUnitsPerInch; + + // Liesst den Kopf der WMF-Datei + BOOL ReadHeader(); + + // Liesst die Parameter des Rocords mit der Funktionsnummer nFunction. + void ReadRecordParams( USHORT nFunction ); + + Point ReadPoint(); // Liesst und konvertiert einen Punkt (erst X dann Y) + Point ReadYX(); // Liesst und konvertiert einen Punkt (erst Y dann X) + Rectangle ReadRectangle(); // Liesst und konvertiert ein Rechteck + Size ReadYXExt(); + void ImplSetWMFSize( const Size& rSize ); + +public: + + WMFReader( SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile, + PFilterCallback pcallback, void * pcallerdata ) : WinMtf( new WinMtfMetaOutput( rGDIMetaFile ), rStreamWMF, + pcallback, pcallerdata ) {}; + + // Liesst aus dem Stream eine WMF-Datei und fuellt das GDIMetaFile + void ReadWMF(); +}; + +#endif + + diff --git a/svtools/source/filter.vcl/wmf/winwmf.cxx b/svtools/source/filter.vcl/wmf/winwmf.cxx new file mode 100644 index 000000000000..6e352ae8ecfd --- /dev/null +++ b/svtools/source/filter.vcl/wmf/winwmf.cxx @@ -0,0 +1,886 @@ +/************************************************************************* + * + * $RCSfile: winwmf.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:59:00 $ + * + * 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 "winmtf.hxx" + +//====================== MS-Windows-defines =============================== + +#define W_META_SETBKCOLOR 0x0201 +#define W_META_SETBKMODE 0x0102 +#define W_META_SETMAPMODE 0x0103 +#define W_META_SETROP2 0x0104 +#define W_META_SETRELABS 0x0105 +#define W_META_SETPOLYFILLMODE 0x0106 +#define W_META_SETSTRETCHBLTMODE 0x0107 +#define W_META_SETTEXTCHAREXTRA 0x0108 +#define W_META_SETTEXTCOLOR 0x0209 +#define W_META_SETTEXTJUSTIFICATION 0x020A +#define W_META_SETWINDOWORG 0x020B +#define W_META_SETWINDOWEXT 0x020C +#define W_META_SETVIEWPORTORG 0x020D +#define W_META_SETVIEWPORTEXT 0x020E +#define W_META_OFFSETWINDOWORG 0x020F +#define W_META_SCALEWINDOWEXT 0x0410 +#define W_META_OFFSETVIEWPORTORG 0x0211 +#define W_META_SCALEVIEWPORTEXT 0x0412 +#define W_META_LINETO 0x0213 +#define W_META_MOVETO 0x0214 +#define W_META_EXCLUDECLIPRECT 0x0415 +#define W_META_INTERSECTCLIPRECT 0x0416 +#define W_META_ARC 0x0817 +#define W_META_ELLIPSE 0x0418 +#define W_META_FLOODFILL 0x0419 +#define W_META_PIE 0x081A +#define W_META_RECTANGLE 0x041B +#define W_META_ROUNDRECT 0x061C +#define W_META_PATBLT 0x061D +#define W_META_SAVEDC 0x001E +#define W_META_SETPIXEL 0x041F +#define W_META_OFFSETCLIPRGN 0x0220 +#define W_META_TEXTOUT 0x0521 +#define W_META_BITBLT 0x0922 +#define W_META_STRETCHBLT 0x0B23 +#define W_META_POLYGON 0x0324 +#define W_META_POLYLINE 0x0325 +#define W_META_ESCAPE 0x0626 +#define W_META_RESTOREDC 0x0127 +#define W_META_FILLREGION 0x0228 +#define W_META_FRAMEREGION 0x0429 +#define W_META_INVERTREGION 0x012A +#define W_META_PAINTREGION 0x012B +#define W_META_SELECTCLIPREGION 0x012C +#define W_META_SELECTOBJECT 0x012D +#define W_META_SETTEXTALIGN 0x012E +#define W_META_DRAWTEXT 0x062F +#define W_META_CHORD 0x0830 +#define W_META_SETMAPPERFLAGS 0x0231 +#define W_META_EXTTEXTOUT 0x0a32 +#define W_META_SETDIBTODEV 0x0d33 +#define W_META_SELECTPALETTE 0x0234 +#define W_META_REALIZEPALETTE 0x0035 +#define W_META_ANIMATEPALETTE 0x0436 +#define W_META_SETPALENTRIES 0x0037 +#define W_META_POLYPOLYGON 0x0538 +#define W_META_RESIZEPALETTE 0x0139 +#define W_META_DIBBITBLT 0x0940 +#define W_META_DIBSTRETCHBLT 0x0b41 +#define W_META_DIBCREATEPATTERNBRUSH 0x0142 +#define W_META_STRETCHDIB 0x0f43 +#define W_META_EXTFLOODFILL 0x0548 +#define W_META_RESETDC 0x014C +#define W_META_STARTDOC 0x014D +#define W_META_STARTPAGE 0x004F +#define W_META_ENDPAGE 0x0050 +#define W_META_ABORTDOC 0x0052 +#define W_META_ENDDOC 0x005E +#define W_META_DELETEOBJECT 0x01f0 +#define W_META_CREATEPALETTE 0x00f7 +#define W_META_CREATEBRUSH 0x00F8 +#define W_META_CREATEPATTERNBRUSH 0x01F9 +#define W_META_CREATEPENINDIRECT 0x02FA +#define W_META_CREATEFONTINDIRECT 0x02FB +#define W_META_CREATEBRUSHINDIRECT 0x02FC +#define W_META_CREATEBITMAPINDIRECT 0x02FD +#define W_META_CREATEBITMAP 0x06FE +#define W_META_CREATEREGION 0x06FF + +//=================== Methoden von WMFReader ============================== + +inline Point WMFReader::ReadPoint() +{ + short nX, nY; + *pWMF >> nX >> nY; + return Point( nX, nY ); +} + +// ------------------------------------------------------------------------ + +inline Point WMFReader::ReadYX() +{ + short nX, nY; + *pWMF >> nY >> nX; + return Point( nX, nY ); +} + +// ------------------------------------------------------------------------ + +Rectangle WMFReader::ReadRectangle() +{ + Point aBR, aTL; + aBR = ReadYX(); + aTL = ReadYX(); + aBR.X()--; + aBR.Y()--; + return Rectangle( aTL, aBR ); +} + +// ------------------------------------------------------------------------ + +Size WMFReader::ReadYXExt() +{ + short nW, nH; + *pWMF >> nH >> nW; + return Size( nW, nH ); +} + +// ------------------------------------------------------------------------ + +void WMFReader::ReadRecordParams( USHORT nFunction ) +{ + switch( nFunction ) + { + case W_META_SETBKCOLOR: + { + pOut->SetBkColor( ReadColor() ); + } + break; + + case W_META_SETBKMODE: + { + USHORT nDat; + *pWMF >> nDat; + pOut->SetBkMode( nDat ); + } + break; + + // !!! + case W_META_SETMAPMODE: + { + short nMapMode; + *pWMF >> nMapMode; +#ifdef DBG_ASSERT + if ( nMapMode != 8 ) // nur MM_ANISOTROPHIC == 8 wird unterstuetzt + { + DBG_ASSERT(0,"WMF-Import: MapMode ignored"); + } +#endif + } + break; + + case W_META_SETROP2: + { + UINT16 nROP2; + *pWMF >> nROP2; + pOut->SetRasterOp( nROP2 ); + } + break; + + case W_META_SETTEXTCOLOR: + { + pOut->SetTextColor( ReadColor() ); + } + break; + + case W_META_SETWINDOWORG: + { + pOut->SetWinOrg( ReadYX() ); + } + break; + + case W_META_SETWINDOWEXT: + { + short nWidth, nHeight; + *pWMF >> nHeight >> nWidth; + ImplSetWMFSize( Size( nWidth, nHeight ) ); + } + break; + + case W_META_OFFSETWINDOWORG: + { + short nXAdd, nYAdd; + *pWMF >> nYAdd >> nXAdd; + pOut->SetWinOrgOffset( nXAdd, nYAdd ); + } + break; + + case W_META_SCALEWINDOWEXT: + { + short nXNum, nXDenom, nYNum, nYDenom; + *pWMF >> nYDenom >> nYNum >> nXDenom >> nXNum; + pOut->ScaleWinExt( (double)nXNum / nXDenom, (double)nYNum / nYDenom ); + } + break; + + case W_META_SETVIEWPORTORG: + case W_META_SETVIEWPORTEXT: + break; + + case W_META_OFFSETVIEWPORTORG: + { + short nXAdd, nYAdd; + *pWMF >> nYAdd >> nXAdd; + pOut->SetDevOrgOffset( nXAdd, nYAdd ); + } + break; + + case W_META_SCALEVIEWPORTEXT: + { + short nXNum, nXDenom, nYNum, nYDenom; + *pWMF >> nYDenom >> nYNum >> nXDenom >> nXNum; + pOut->ScaleDevExt( (double)nXNum / nXDenom, (double)nYNum / nYDenom ); + } + break; + + case W_META_LINETO: + { + pOut->LineTo( ReadYX() ); + } + break; + + case W_META_MOVETO: + { + pOut->MoveTo( ReadYX() ); + } + break; + + case W_META_INTERSECTCLIPRECT: + { + pOut->IntersectClipRect( ReadRectangle() ); + } + break; + + case W_META_RECTANGLE: + { + pOut->DrawRect( ReadRectangle() ); + } + break; + + case W_META_ROUNDRECT: + { + Size aSize( ReadYXExt() ); + pOut->DrawRoundRect( ReadRectangle(), aSize ); + } + break; + + case W_META_ELLIPSE: + { + pOut->DrawEllipse( ReadRectangle() ); + } + break; + + case W_META_ARC: + { + Point aEnd( ReadYX() ); + Point aStart( ReadYX() ); + pOut->DrawArc( ReadRectangle(), aStart, aEnd ); + } + break; + + case W_META_PIE: + { + Point aEnd( ReadYX() ); + Point aStart( ReadYX() ); + pOut->DrawPie( ReadRectangle(), aStart, aEnd ); + } + break; + + case W_META_CHORD: + { + Point aEnd( ReadYX() ); + Point aStart( ReadYX() ); + pOut->DrawChord( ReadRectangle(), aStart, aEnd ); + } + break; + + case W_META_POLYGON: + { + USHORT i,nPoints; + *pWMF >> nPoints; + Polygon aPoly( nPoints ); + for( i = 0; i < nPoints; i++ ) + aPoly[ i ] = ReadPoint(); + pOut->DrawPolygon( aPoly ); + } + break; + + case W_META_POLYPOLYGON: + { + USHORT i, nPoly, nPoints; + USHORT* pnPoints; + Point* pPtAry; + // Anzahl der Polygone: + *pWMF >> nPoly; + // Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln: + pnPoints = new USHORT[ nPoly ]; + nPoints = 0; + for( i = 0; i < nPoly; i++ ) + { + *pWMF >> pnPoints[i]; + nPoints += pnPoints[i]; + } + // Polygonpunkte holen: + pPtAry = (Point*) new char[ nPoints * sizeof(Point) ]; + for ( i = 0; i < nPoints; i++ ) + pPtAry[ i ] = ReadPoint(); + // PolyPolygon Actions erzeugen + PolyPolygon aPolyPoly( nPoly, pnPoints, pPtAry ); + pOut->DrawPolyPolygon( aPolyPoly ); + delete (char*) pPtAry; + delete pnPoints; + } + break; + + case W_META_POLYLINE: + { + USHORT i,nPoints; + *pWMF >> nPoints; + Polygon aPoly( nPoints ); + for( i = 0; i < nPoints; i++ ) + aPoly[ i ] = ReadPoint(); + pOut->DrawPolyLine( aPoly ); + } + break; + + case W_META_SAVEDC: + { + pOut->Push( bWinExtSet ); + } + break; + + case W_META_RESTOREDC: + { + pOut->Pop(); + } + break; + + case W_META_SETPIXEL: + { + const Color aColor = ReadColor(); + pOut->DrawPixel( ReadYX(), aColor ); + } + break; + + case W_META_OFFSETCLIPRGN: + { + pOut->MoveClipRegion( ReadYXExt() ); + } + break; + + case W_META_TEXTOUT: + { + USHORT nLength; + *pWMF >> nLength; + if ( nLength ) + { + char* pChar = new char[ ( nLength + 1 ) &~ 1 ]; + pWMF->Read( pChar, ( nLength + 1 ) &~ 1 ); + String aText( pChar, nLength, pOut->GetCharSet() ); + delete pChar; + Point aPosition( ReadYX() ); + pOut->DrawText( aPosition, aText ); + } + } + break; + + case W_META_EXTTEXTOUT: + { + USHORT i,nLen,nOptions,nData; + long nRecordSize,nRecSizeLeft, *pDXAry; + Point aPosition; + Rectangle aRect; + + pWMF->SeekRel(-6); + *pWMF >> nRecordSize; + pWMF->SeekRel(2); + aPosition = ReadYX(); + *pWMF >> nLen >> nOptions; + // Nur wenn der Text auch Zeichen enthaelt, macht die Ausgabe Sinn + if( nLen ) + { + if( nOptions ) + { + const Point aPt1( ReadPoint() ); + const Point aPt2( ReadPoint() ); + aRect = Rectangle( aPt1, aPt2 ); + } + char* pChar = new char[ ( nLen + 1 ) &~ 1 ]; + pWMF->Read( pChar, ( nLen + 1 ) &~ 1 ); + String aText( pChar, nLen, pOut->GetCharSet() ); + delete pChar; + + nRecSizeLeft=(nRecordSize-7-(((long)nLen+1)>>1))<<1; + + if( nOptions ) + nRecSizeLeft-=8; + + if( nRecSizeLeft >= (long) nLen ) + { + pDXAry = new long[ nLen ]; + + for( i = 0; i < nLen; i++ ) + { + *pWMF >> nData; + pDXAry[ i ] = nData; + } + pOut->DrawText( aPosition, aText, pDXAry ); + delete[] pDXAry; + } + else + pOut->DrawText( aPosition, aText ); + } + } + break; + + case W_META_SELECTOBJECT: + { + INT16 nObjIndex; + *pWMF >> nObjIndex; + pOut->SelectObject( nObjIndex ); + } + break; + + case W_META_SETTEXTALIGN: + { + UINT16 nAlign; + *pWMF >> nAlign; + pOut->SetTextAlign( nAlign ); + } + break; + + case W_META_BITBLT: + case W_META_STRETCHBLT: + case W_META_DIBBITBLT: + case W_META_DIBSTRETCHBLT: + case W_META_STRETCHDIB: + { + long nWinROP; + short nSx, nSy, nSxe, nSye, nUsage; + Bitmap aBmp; + + *pWMF >> nWinROP; + + if( nFunction == W_META_STRETCHDIB ) + *pWMF >> nUsage; + + if( nFunction==W_META_STRETCHDIB || nFunction==W_META_STRETCHBLT || nFunction==W_META_DIBSTRETCHBLT ) + *pWMF >> nSye >> nSxe; + + *pWMF >> nSy >> nSx; + + if( nFunction == W_META_STRETCHDIB || nFunction == W_META_DIBBITBLT || nFunction == W_META_DIBSTRETCHBLT ) + { + switch( nWinROP ) + { + case PATCOPY : + { + *pWMF >> nUsage; // i don't know anything of this parameter, so its called nUsage + Size aDestSize( ReadYXExt() ); + pOut->DrawRect( Rectangle( ReadYX(), aDestSize ), FALSE ); + } + break; + default : + { + Size aDestSize( ReadYXExt() ); + Rectangle aDestRect( ReadYX(), aDestSize ); + aBmp.Read( *pWMF, FALSE ); + aBmpSaveList.Insert( new BSaveStruct( aBmp, aDestRect, nWinROP ), LIST_APPEND ); + } + break; + } + } + else + { + if( aBmpSaveList.Count() ) + pOut->ResolveBitmapActions( aBmpSaveList ); + } + } + break; + + case W_META_DIBCREATEPATTERNBRUSH: + { + Bitmap aBmp; + BitmapReadAccess* pBmp; + UINT32 nRed = 0, nGreen = 0, nBlue = 0, nCount = 1; + UINT16 nFunction; + + *pWMF >> nFunction >> nFunction; + + aBmp.Read( *pWMF, FALSE ); + pBmp = aBmp.AcquireReadAccess(); + if ( pBmp ) + { + for ( INT32 y = 0; y < pBmp->Height(); y++ ) + { + for ( INT32 x = 0; x < pBmp->Width(); x++ ) + { + const BitmapColor aColor( pBmp->GetColor( y, x ) ); + + nRed += aColor.GetRed(); + nGreen += aColor.GetGreen(); + nBlue += aColor.GetBlue(); + } + } + nCount = pBmp->Height() * pBmp->Width(); + if ( !nCount ) + nCount++; + aBmp.ReleaseAccess( pBmp ); + } + Color aColor( (BYTE)( nRed / nCount ), (BYTE)( nGreen / nCount ), (BYTE)( nBlue / nCount ) ); + pOut->CreateObject( GDI_BRUSH, new WinMtfFillStyle( aColor, FALSE ) ); + } + break; + + case W_META_DELETEOBJECT: + { + INT16 nIndex; + *pWMF >> nIndex; + pOut->DeleteObject( nIndex ); + } + break; + + case W_META_CREATEPALETTE: + { + pOut->CreateObject( GDI_DUMMY ); + } + break; + + case W_META_CREATEBRUSH: + { + pOut->CreateObject( GDI_BRUSH, new WinMtfFillStyle( Color( COL_WHITE ), FALSE ) ); + } + break; + + case W_META_CREATEPATTERNBRUSH: + { + pOut->CreateObject( GDI_BRUSH, new WinMtfFillStyle( Color( COL_WHITE ), FALSE ) ); + } + break; + + case W_META_CREATEPENINDIRECT: + { + LineInfo aLineInfo; + USHORT nStyle, nWidth, nHeight; + + *pWMF >> nStyle >> nWidth >> nHeight; + + if ( nWidth ) + aLineInfo.SetWidth( nWidth ); + + BOOL bTransparent = FALSE; + UINT16 nDashCount = 0; + UINT16 nDotCount = 0; + switch( nStyle ) + { + case PS_DASHDOTDOT : + nDotCount++; + case PS_DASHDOT : + nDashCount++; + case PS_DOT : + nDotCount++; + break; + case PS_DASH : + nDashCount++; + break; + case PS_NULL : + bTransparent = TRUE; + aLineInfo.SetStyle( LINE_NONE ); + break; + default : + case PS_INSIDEFRAME : + case PS_SOLID : + aLineInfo.SetStyle( LINE_SOLID ); + } + if ( nDashCount | nDotCount ) + { + aLineInfo.SetStyle( LINE_DASH ); + aLineInfo.SetDashCount( nDashCount ); + aLineInfo.SetDotCount( nDotCount ); + } + pOut->CreateObject( GDI_PEN, new WinMtfLineStyle( ReadColor(), aLineInfo, bTransparent ) ); + } + break; + + case W_META_CREATEBRUSHINDIRECT: + { + USHORT nStyle; + *pWMF >> nStyle; + pOut->CreateObject( GDI_BRUSH, new WinMtfFillStyle( ReadColor(), ( nStyle == BS_HOLLOW ) ? TRUE : FALSE ) ); + } + break; + + case W_META_CREATEFONTINDIRECT: + { + Size aFontSize; + INT16 lfEscapement, lfOrientation, lfWeight; // ( ehemals USHORT ) + + LOGFONTW aLogFont; + aFontSize = ReadYXExt(); + *pWMF >> lfEscapement >> lfOrientation >> lfWeight + >> aLogFont.lfItalic >> aLogFont.lfUnderline >> aLogFont.lfStrikeOut >> aLogFont.lfCharSet >> aLogFont.lfOutPrecision + >> aLogFont.lfClipPrecision >> aLogFont.lfQuality >> aLogFont.lfPitchAndFamily; + pWMF->Read( aLogFont.lfFaceName, LF_FACESIZE ); + aLogFont.lfWidth = aFontSize.Width(); + aLogFont.lfHeight = aFontSize.Height(); + aLogFont.lfEscapement = lfEscapement; + aLogFont.lfOrientation = lfOrientation; + aLogFont.lfWeight = lfWeight; + pOut->CreateObject( GDI_FONT, new WinMtfFontStyle( aLogFont ) ); + } + break; + + case W_META_CREATEBITMAPINDIRECT: + { + pOut->CreateObject( GDI_DUMMY ); + } + break; + + case W_META_CREATEBITMAP: + { + pOut->CreateObject( GDI_DUMMY ); + } + break; + + case W_META_CREATEREGION: + { + pOut->CreateObject( GDI_DUMMY ); + } + break; + + case W_META_SETRELABS: + case W_META_SETPOLYFILLMODE: + case W_META_SETSTRETCHBLTMODE: + case W_META_SETTEXTCHAREXTRA: + case W_META_SETTEXTJUSTIFICATION: + case W_META_EXCLUDECLIPRECT: + case W_META_FLOODFILL: + break; + case W_META_PATBLT: + { + UINT32 nROP, nOldROP; + *pWMF >> nROP; + Size aSize = ReadYXExt(); + nOldROP = pOut->SetRasterOp( nROP ); + pOut->DrawRect( Rectangle( ReadYX(), aSize ), FALSE ); + pOut->SetRasterOp( nOldROP ); + } + break; + case W_META_ESCAPE: + case W_META_FILLREGION: + case W_META_FRAMEREGION: + case W_META_INVERTREGION: + case W_META_PAINTREGION: + case W_META_SELECTCLIPREGION: + case W_META_DRAWTEXT: + case W_META_SETMAPPERFLAGS: + case W_META_SETDIBTODEV: + case W_META_SELECTPALETTE: + case W_META_REALIZEPALETTE: + case W_META_ANIMATEPALETTE: + case W_META_SETPALENTRIES: + case W_META_RESIZEPALETTE: + case W_META_EXTFLOODFILL: + case W_META_RESETDC: + case W_META_STARTDOC: + case W_META_STARTPAGE: + case W_META_ENDPAGE: + case W_META_ABORTDOC: + case W_META_ENDDOC: + break; + } +} + +// ------------------------------------------------------------------------ + +BOOL WMFReader::ReadHeader() +{ + Rectangle aPlaceableBound; + ULONG nl; + + // Einlesen des METAFILEHEADER, falls vorhanden + *pWMF >> nl; + + if ( nl == 0x9ac6cdd7L ) + { + INT16 nVal; + + // hmf (Unused) ueberlesen wir + pWMF->SeekRel(2); + + // BoundRect + *pWMF >> nVal; aPlaceableBound.Left() = nVal; + *pWMF >> nVal; aPlaceableBound.Top() = nVal; + *pWMF >> nVal; aPlaceableBound.Right() = nVal; + *pWMF >> nVal; aPlaceableBound.Bottom() = nVal; + + // inch + *pWMF >> nUnitsPerInch; + + // reserved + pWMF->SeekRel( 4 ); + + // checksum pruefen wir lieber nicht + pWMF->SeekRel( 2 ); + } + else + { + // Unit wird bei den alten MTF's als MM_TEXT angenommen + nUnitsPerInch = 96; + pWMF->SeekRel( -4 ); // zurueck zum Anfang + } + + // Einlesen des METAHEADER + *pWMF >> nl; // Typ und Headergroesse + + if( nl != 0x00090001 ) + { + pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + return FALSE; + } + + pWMF->SeekRel( 2 ); // Version (von Windows) + pWMF->SeekRel( 4 ); // Size (der Datei in Words) + pWMF->SeekRel( 2 ); // NoObjects (Maximale Anzahl der gleichzeitigen Objekte) + pWMF->SeekRel( 4 ); // MaxRecord (Groesse des groessten Records in Words) + pWMF->SeekRel( 2 ); // NoParameters (Unused + + pOut->SetWinOrg( aPlaceableBound.TopLeft() ); + + ImplSetWMFSize( aPlaceableBound.GetSize() ); + + return TRUE; +} + +// ------------------------------------------------------------------------ + +void WMFReader::ImplSetWMFSize( const Size& rSize ) +{ + pOut->SetWinExt( rSize ); + + // try to calculate size of WMF + if( !bWinExtSet && rSize.Width() > 1 && rSize.Height() > 1 ) + { + const Fraction aFrac( 1, nUnitsPerInch ); + MapMode aWMFMap( MAP_INCH, Point(), aFrac, aFrac ); + Size aSize100( OutputDevice::LogicToLogic( rSize, aWMFMap, MAP_100TH_MM ) ); + pOut->SetDevExt( Size( labs( aSize100.Width() ), labs( aSize100.Height() ) ) ); + bWinExtSet = TRUE; + } +} + +// ------------------------------------------------------------------------ + +void WMFReader::ReadWMF() // SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, PFilterCallback pcallback, void * pcallerdata) +{ + USHORT nFunction; + ULONG nRecSize; + ULONG nPos, nPercent, nLastPercent; + + pOut->SetWinOrg( Point() ); + pOut->SetWinExt( Size( 1, 1 ) ); + pOut->SetDevExt( Size( 10000, 10000 ) ); + bWinExtSet = FALSE; + + nEndPos=pWMF->Seek( STREAM_SEEK_TO_END ); + pWMF->Seek( nStartPos ); + Callback( (USHORT) ( nLastPercent = 0 ) ); + + if ( ReadHeader() ) + { + + nPos = pWMF->Tell(); + + if( nEndPos - nStartPos ) + { + while( TRUE ) + { + nPercent = ( nPos - nStartPos ) * 100 / ( nEndPos - nStartPos ); + + if( nLastPercent + 4 <= nPercent ) + { + if( Callback( (USHORT) nPercent ) ) + break; + + nLastPercent = nPercent; + } + + *pWMF >> nRecSize >> nFunction; + + if( pWMF->GetError() || ( nRecSize < 3 ) || ( nRecSize==3 && nFunction==0 ) || pWMF->IsEof() ) + { + + if( pWMF->IsEof() ) + pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + + break; + } + + if( aBmpSaveList.Count() && + ( nFunction != W_META_STRETCHDIB ) && + ( nFunction != W_META_DIBBITBLT ) && + ( nFunction != W_META_DIBSTRETCHBLT ) ) + { + pOut->ResolveBitmapActions( aBmpSaveList ); + } + + ReadRecordParams( nFunction ); + pWMF->Seek( nPos += nRecSize * 2 ); + } + } + else + pWMF->SetError( SVSTREAM_GENERALERROR ); + + if( !pWMF->GetError() && aBmpSaveList.Count() ) + pOut->ResolveBitmapActions( aBmpSaveList ); + } + if ( pWMF->GetError() ) + pWMF->Seek( nStartPos ); +} + diff --git a/svtools/source/filter.vcl/wmf/wmf.cxx b/svtools/source/filter.vcl/wmf/wmf.cxx new file mode 100644 index 000000000000..d085bfc45e21 --- /dev/null +++ b/svtools/source/filter.vcl/wmf/wmf.cxx @@ -0,0 +1,147 @@ +/************************************************************************* + * + * $RCSfile: wmf.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:59:00 $ + * + * 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 "winmtf.hxx" +#include "emfwr.hxx" +#include "wmfwr.hxx" +#include "wmf.hxx" + +// ----------------------------------------------------------------------------- + +BOOL ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, + PFilterCallback pCallback, void * pCallerData) +{ + UINT32 nMetaType; + UINT32 nOrgPos = rStreamWMF.Tell(); + UINT16 nOrigNumberFormat = rStreamWMF.GetNumberFormatInt(); + rStreamWMF.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); + rStreamWMF.Seek( 0x28 ); + rStreamWMF >> nMetaType; + rStreamWMF.Seek( nOrgPos ); + if ( nMetaType == 0x464d4520 ) + { + if ( EnhWMFReader( rStreamWMF, rGDIMetaFile, pCallback, pCallerData ).ReadEnhWMF() == FALSE ) + rStreamWMF.SetError( SVSTREAM_FILEFORMAT_ERROR ); + } + else + { + WMFReader( rStreamWMF, rGDIMetaFile, pCallback, pCallerData ).ReadWMF(); + } + rStreamWMF.SetNumberFormatInt( nOrigNumberFormat ); + return !rStreamWMF.GetError(); +} + +// ----------------------------------------------------------------------------- + +BOOL ReadWindowMetafile( SvStream& rStream, GDIMetaFile& rMTF ) +{ + UINT32 nMetaType; + UINT32 nOrgPos = rStream.Tell(); + UINT16 nOrigNumberFormat = rStream.GetNumberFormatInt(); + rStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); + rStream.Seek( 0x28 ); + rStream >> nMetaType; + rStream.Seek( nOrgPos ); + if ( nMetaType == 0x464d4520 ) + { + if ( EnhWMFReader( rStream, rMTF, NULL, NULL ).ReadEnhWMF() == FALSE ) + rStream.SetError( SVSTREAM_FILEFORMAT_ERROR ); + } + else + { + WMFReader( rStream, rMTF, NULL, NULL ).ReadWMF(); + } + rStream.SetNumberFormatInt( nOrigNumberFormat ); + return !rStream.GetError(); +} + +// ----------------------------------------------------------------------------- + +BOOL ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream, + PFilterCallback pCallback, void * pCallerData, + BOOL bPlaceable) +{ + WMFWriter aWMFWriter; + return aWMFWriter.WriteWMF(rMTF,rTargetStream,pCallback,pCallerData,bPlaceable); +} + +// ----------------------------------------------------------------------------- + +BOOL ConvertGDIMetaFileToEMF( const GDIMetaFile & rMTF, SvStream & rTargetStream, + PFilterCallback pCallback, void * pCallerData ) +{ + EMFWriter aEMFWriter; + return aEMFWriter.WriteEMF( rMTF, rTargetStream, pCallback, pCallerData ); +} + +// ----------------------------------------------------------------------------- + +BOOL WriteWindowMetafile( SvStream& rStream, const GDIMetaFile& rMTF ) +{ + return WMFWriter().WriteWMF( rMTF, rStream, NULL, NULL ); +} + +// ----------------------------------------------------------------------------- + +BOOL WriteWindowMetafileBits( SvStream& rStream, const GDIMetaFile& rMTF ) +{ + return WMFWriter().WriteWMF( rMTF, rStream, NULL, NULL, FALSE ); +} diff --git a/svtools/source/filter.vcl/wmf/wmfwr.cxx b/svtools/source/filter.vcl/wmf/wmfwr.cxx new file mode 100644 index 000000000000..ad860a457d7d --- /dev/null +++ b/svtools/source/filter.vcl/wmf/wmfwr.cxx @@ -0,0 +1,1787 @@ +/************************************************************************* + * + * $RCSfile: wmfwr.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:59:00 $ + * + * 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/salbtype.hxx> +#include "wmfwr.hxx" + +//====================== MS-Windows-defines =============================== + +#define W_META_SETBKCOLOR 0x0201 +#define W_META_SETBKMODE 0x0102 +#define W_META_SETMAPMODE 0x0103 +#define W_META_SETROP2 0x0104 +#define W_META_SETRELABS 0x0105 +#define W_META_SETPOLYFILLMODE 0x0106 +#define W_META_SETSTRETCHBLTMODE 0x0107 +#define W_META_SETTEXTCHAREXTRA 0x0108 +#define W_META_SETTEXTCOLOR 0x0209 +#define W_META_SETTEXTJUSTIFICATION 0x020A +#define W_META_SETWINDOWORG 0x020B +#define W_META_SETWINDOWEXT 0x020C +#define W_META_SETVIEWPORTORG 0x020D +#define W_META_SETVIEWPORTEXT 0x020E +#define W_META_OFFSETWINDOWORG 0x020F +#define W_META_SCALEWINDOWEXT 0x0410 +#define W_META_OFFSETVIEWPORTORG 0x0211 +#define W_META_SCALEVIEWPORTEXT 0x0412 +#define W_META_LINETO 0x0213 +#define W_META_MOVETO 0x0214 +#define W_META_EXCLUDECLIPRECT 0x0415 +#define W_META_INTERSECTCLIPRECT 0x0416 +#define W_META_ARC 0x0817 +#define W_META_ELLIPSE 0x0418 +#define W_META_FLOODFILL 0x0419 +#define W_META_PIE 0x081A +#define W_META_RECTANGLE 0x041B +#define W_META_ROUNDRECT 0x061C +#define W_META_PATBLT 0x061D +#define W_META_SAVEDC 0x001E +#define W_META_SETPIXEL 0x041F +#define W_META_OFFSETCLIPRGN 0x0220 +#define W_META_TEXTOUT 0x0521 +#define W_META_BITBLT 0x0922 +#define W_META_STRETCHBLT 0x0B23 +#define W_META_POLYGON 0x0324 +#define W_META_POLYLINE 0x0325 +#define W_META_ESCAPE 0x0626 +#define W_META_RESTOREDC 0x0127 +#define W_META_FILLREGION 0x0228 +#define W_META_FRAMEREGION 0x0429 +#define W_META_INVERTREGION 0x012A +#define W_META_PAINTREGION 0x012B +#define W_META_SELECTCLIPREGION 0x012C +#define W_META_SELECTOBJECT 0x012D +#define W_META_SETTEXTALIGN 0x012E +#define W_META_DRAWTEXT 0x062F +#define W_META_CHORD 0x0830 +#define W_META_SETMAPPERFLAGS 0x0231 +#define W_META_EXTTEXTOUT 0x0a32 +#define W_META_SETDIBTODEV 0x0d33 +#define W_META_SELECTPALETTE 0x0234 +#define W_META_REALIZEPALETTE 0x0035 +#define W_META_ANIMATEPALETTE 0x0436 +#define W_META_SETPALENTRIES 0x0037 +#define W_META_POLYPOLYGON 0x0538 +#define W_META_RESIZEPALETTE 0x0139 +#define W_META_DIBBITBLT 0x0940 +#define W_META_DIBSTRETCHBLT 0x0b41 +#define W_META_DIBCREATEPATTERNBRUSH 0x0142 +#define W_META_STRETCHDIB 0x0f43 +#define W_META_EXTFLOODFILL 0x0548 +#define W_META_RESETDC 0x014C +#define W_META_STARTDOC 0x014D +#define W_META_STARTPAGE 0x004F +#define W_META_ENDPAGE 0x0050 +#define W_META_ABORTDOC 0x0052 +#define W_META_ENDDOC 0x005E +#define W_META_DELETEOBJECT 0x01f0 +#define W_META_CREATEPALETTE 0x00f7 +#define W_META_CREATEBRUSH 0x00F8 +#define W_META_CREATEPATTERNBRUSH 0x01F9 +#define W_META_CREATEPENINDIRECT 0x02FA +#define W_META_CREATEFONTINDIRECT 0x02FB +#define W_META_CREATEBRUSHINDIRECT 0x02FC +#define W_META_CREATEBITMAPINDIRECT 0x02FD +#define W_META_CREATEBITMAP 0x06FE +#define W_META_CREATEREGION 0x06FF + +#define W_TRANSPARENT 1 +#define W_OPAQUE 2 + +#define W_R2_BLACK 1 +#define W_R2_NOTMERGEPEN 2 +#define W_R2_MASKNOTPEN 3 +#define W_R2_NOTCOPYPEN 4 +#define W_R2_MASKPENNOT 5 +#define W_R2_NOT 6 +#define W_R2_XORPEN 7 +#define W_R2_NOTMASKPEN 8 +#define W_R2_MASKPEN 9 +#define W_R2_NOTXORPEN 10 +#define W_R2_NOP 11 +#define W_R2_MERGENOTPEN 12 +#define W_R2_COPYPEN 13 +#define W_R2_MERGEPENNOT 14 +#define W_R2_MERGEPEN 15 +#define W_R2_WHITE 16 + +#define W_TA_NOUPDATECP 0x0000 +#define W_TA_UPDATECP 0x0001 +#define W_TA_LEFT 0x0000 +#define W_TA_RIGHT 0x0002 +#define W_TA_CENTER 0x0006 +#define W_TA_TOP 0x0000 +#define W_TA_BOTTOM 0x0008 +#define W_TA_BASELINE 0x0018 + +#define W_SRCCOPY 0x00CC0020L +#define W_SRCPAINT 0x00EE0086L +#define W_SRCAND 0x008800C6L +#define W_SRCINVERT 0x00660046L +#define W_SRCERASE 0x00440328L +#define W_NOTSRCCOPY 0x00330008L +#define W_NOTSRCERASE 0x001100A6L +#define W_MERGECOPY 0x00C000CAL +#define W_MERGEPAINT 0x00BB0226L +#define W_PATCOPY 0x00F00021L +#define W_PATPAINT 0x00FB0A09L +#define W_PATINVERT 0x005A0049L +#define W_DSTINVERT 0x00550009L +#define W_BLACKNESS 0x00000042L +#define W_WHITENESS 0x00FF0062L + +#define W_PS_SOLID 0 +#define W_PS_DASH 1 +#define W_PS_DOT 2 +#define W_PS_DASHDOT 3 +#define W_PS_DASHDOTDOT 4 +#define W_PS_NULL 5 +#define W_PS_INSIDEFRAME 6 + +#define W_LF_FACESIZE 32 + +#define W_ANSI_CHARSET 0 +#define W_DEFAULT_CHARSET 1 +#define W_SYMBOL_CHARSET 2 +#define W_SHIFTJIS_CHARSET 128 +#define W_HANGEUL_CHARSET 129 +#define W_CHINESEBIG5_CHARSET 136 +#define W_OEM_CHARSET 255 + +#define W_DEFAULT_PITCH 0x00 +#define W_FIXED_PITCH 0x01 +#define W_VARIABLE_PITCH 0x02 + +#define W_FF_DONTCARE 0x00 +#define W_FF_ROMAN 0x10 +#define W_FF_SWISS 0x20 +#define W_FF_MODERN 0x30 +#define W_FF_SCRIPT 0x40 +#define W_FF_DECORATIVE 0x50 + +#define W_FW_DONTCARE 0 +#define W_FW_THIN 100 +#define W_FW_EXTRALIGHT 200 +#define W_FW_LIGHT 300 +#define W_FW_NORMAL 400 +#define W_FW_MEDIUM 500 +#define W_FW_SEMIBOLD 600 +#define W_FW_BOLD 700 +#define W_FW_EXTRABOLD 800 +#define W_FW_HEAVY 900 +#define W_FW_ULTRALIGHT 200 +#define W_FW_REGULAR 400 +#define W_FW_DEMIBOLD 600 +#define W_FW_ULTRABOLD 800 +#define W_FW_BLACK 900 + +#define W_BS_SOLID 0 +#define W_BS_HOLLOW 1 +#define W_BS_HATCHED 2 +#define W_BS_PATTERN 3 +#define W_BS_INDEXED 4 +#define W_BS_DIBPATTERN 5 + +#define W_HS_HORIZONTAL 0 +#define W_HS_VERTICAL 1 +#define W_HS_FDIAGONAL 2 +#define W_HS_BDIAGONAL 3 +#define W_HS_CROSS 4 +#define W_HS_DIAGCROSS 5 + +//========================== Methoden von WMFWriter ========================== + +void WMFWriter::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 WMFWriter::CountActionsAndBitmaps( const GDIMetaFile & rMTF ) +{ + ULONG nAction, nActionCount; + + nActionCount = rMTF.GetActionCount(); + + for ( nAction=0; nAction<nActionCount; nAction++ ) + { + MetaAction* 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++; + } +} + + +void WMFWriter::WritePointXY(const Point & rPoint) +{ + Point aPt( pVirDev->LogicToLogic(rPoint,aSrcMapMode,aTargetMapMode) ); + *pWMF << ((short)aPt.X()) << ((short)aPt.Y()); +} + + +void WMFWriter::WritePointYX(const Point & rPoint) +{ + Point aPt( pVirDev->LogicToLogic(rPoint,aSrcMapMode,aTargetMapMode) ); + *pWMF << ((short)aPt.Y()) << ((short)aPt.X()); +} + + +void WMFWriter::WriteDX(long nDX) +{ + Size aSz( pVirDev->LogicToLogic(Size(nDX,0),aSrcMapMode,aTargetMapMode) ); + *pWMF << ((short)aSz.Width()); +} + + +void WMFWriter::WriteSize(const Size & rSize) +{ + Size aSz( pVirDev->LogicToLogic(rSize,aSrcMapMode,aTargetMapMode) ); + *pWMF << ((short)aSz.Width()) << ((short)aSz.Height()); +} + + +void WMFWriter::WriteHeightWidth(const Size & rSize) +{ + Size aSz( pVirDev->LogicToLogic(rSize,aSrcMapMode,aTargetMapMode) ); + *pWMF << ((short)aSz.Height()) << ((short)aSz.Width()); +} + + +void WMFWriter::WriteRectangle(const Rectangle & rRect) +{ + WritePointYX(Point(rRect.Right()+1,rRect.Bottom()+1)); + WritePointYX(rRect.TopLeft()); +} + + +void WMFWriter::WriteColor(const Color & rColor) +{ + *pWMF << (BYTE) rColor.GetRed() << (BYTE) rColor.GetGreen() << (BYTE) rColor.GetBlue() << (BYTE) 0; +} + + +void WMFWriter::WriteRecordHeader(ULONG nSizeWords, USHORT nType) +{ + nActRecordPos=pWMF->Tell(); + if (nSizeWords>nMaxRecordSize) nMaxRecordSize=nSizeWords; + *pWMF << nSizeWords << nType; +} + + +void WMFWriter::UpdateRecordHeader() +{ + ULONG nPos,nSize; + + nPos=pWMF->Tell(); nSize=nPos-nActRecordPos; + if ((nSize & 1)!=0) { + *pWMF << (BYTE)0; + nPos++; nSize++; + } + nSize/=2; + if (nSize>nMaxRecordSize) nMaxRecordSize=nSize; + pWMF->Seek(nActRecordPos); + *pWMF << nSize; + pWMF->Seek(nPos); +} + + +void WMFWriter::WMFRecord_Arc(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt) +{ + WriteRecordHeader(0x0000000b,W_META_ARC); + WritePointYX(rEndPt); + WritePointYX(rStartPt); + WriteRectangle(rRect); +} + +void WMFWriter::WMFRecord_Chord(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt) +{ + WriteRecordHeader(0x0000000b,W_META_CHORD); + WritePointYX(rEndPt); + WritePointYX(rStartPt); + WriteRectangle(rRect); +} + + +void WMFWriter::WMFRecord_CreateBrushIndirect(const Color& rColor) +{ + WriteRecordHeader(0x00000007,W_META_CREATEBRUSHINDIRECT); + + if( rColor==Color(COL_TRANSPARENT) ) + *pWMF << (UINT16) W_BS_HOLLOW; + else + *pWMF << (UINT16) W_BS_SOLID; + + WriteColor( rColor ); + *pWMF << (UINT16) 0; +} + + +void WMFWriter::WMFRecord_CreateFontIndirect(const Font & rFont) +{ + USHORT nWeight,i; + BYTE nCharSet,nPitchFamily; + + WriteRecordHeader(0x00000000,W_META_CREATEFONTINDIRECT); + + WriteHeightWidth(Size(rFont.GetSize().Width(),-rFont.GetSize().Height())); + + *pWMF << (short)rFont.GetOrientation() << (short)rFont.GetOrientation(); + + switch (rFont.GetWeight()) { + case WEIGHT_THIN: nWeight=W_FW_THIN; break; + case WEIGHT_ULTRALIGHT: nWeight=W_FW_ULTRALIGHT; break; + case WEIGHT_LIGHT: nWeight=W_FW_LIGHT; break; + case WEIGHT_SEMILIGHT: nWeight=W_FW_LIGHT; break; + case WEIGHT_NORMAL: nWeight=W_FW_NORMAL; break; + case WEIGHT_MEDIUM: nWeight=W_FW_MEDIUM; break; + case WEIGHT_SEMIBOLD: nWeight=W_FW_SEMIBOLD; break; + case WEIGHT_BOLD: nWeight=W_FW_BOLD; break; + case WEIGHT_ULTRABOLD: nWeight=W_FW_ULTRABOLD; break; + case WEIGHT_BLACK: nWeight=W_FW_BLACK; break; + default: nWeight=W_FW_DONTCARE; + } + *pWMF << nWeight; + + if (rFont.GetItalic()==ITALIC_NONE) *pWMF << (BYTE)0; else *pWMF << (BYTE)1; + if (rFont.GetUnderline()==UNDERLINE_NONE) *pWMF << (BYTE)0; else *pWMF << (BYTE)1; + if (rFont.GetStrikeout()==STRIKEOUT_NONE) *pWMF << (BYTE)0; else *pWMF << (BYTE)1; + + switch (rFont.GetCharSet()) + { + case RTL_TEXTENCODING_SYMBOL : nCharSet = W_SYMBOL_CHARSET; break; + default: nCharSet = W_ANSI_CHARSET; + } + *pWMF << nCharSet; + + *pWMF << (BYTE)0 << (BYTE)0 << (BYTE)0; + + switch (rFont.GetPitch()) { + case PITCH_FIXED: nPitchFamily=W_FIXED_PITCH; break; + case PITCH_VARIABLE: nPitchFamily=W_VARIABLE_PITCH; break; + default: nPitchFamily=W_DEFAULT_PITCH; + } + switch (rFont.GetFamily()) { + case FAMILY_DECORATIVE: nPitchFamily|=W_FF_DECORATIVE; break; + case FAMILY_MODERN: nPitchFamily|=W_FF_MODERN; break; + case FAMILY_ROMAN: nPitchFamily|=W_FF_ROMAN; break; + case FAMILY_SCRIPT: nPitchFamily|=W_FF_SCRIPT; break; + case FAMILY_SWISS: nPitchFamily|=W_FF_SWISS; break; + default: nPitchFamily|=W_FF_DONTCARE; + } + *pWMF << nPitchFamily; + + ByteString aFontName( rFont.GetName(), RTL_TEXTENCODING_UTF8 ); + for ( i = 0; i < W_LF_FACESIZE; i++ ) + { + if ( i < aFontName.Len() ) + *pWMF << (BYTE)aFontName.GetChar( i ); + else + *pWMF << (BYTE)0; + } + + UpdateRecordHeader(); +} + + +void WMFWriter::WMFRecord_CreatePenIndirect(const Color& rColor) +{ + WriteRecordHeader(0x00000008,W_META_CREATEPENINDIRECT); + + if( rColor == Color( COL_TRANSPARENT ) ) + *pWMF << (UINT16) W_PS_NULL; + else + *pWMF << (UINT16) W_PS_SOLID; + + WriteSize( Size() ); + WriteColor(rColor); +} + +void WMFWriter::WMFRecord_CreatePenIndirect(const Color& rColor, const LineInfo& rLineInfo ) +{ + WriteRecordHeader(0x00000008,W_META_CREATEPENINDIRECT); + + USHORT nStyle = W_PS_SOLID; + switch( rLineInfo.GetStyle() ) + { + case LINE_DASH : + { + if ( rLineInfo.GetDotCount() ) + { + if ( !rLineInfo.GetDashCount() ) + nStyle = W_PS_DOT; + else + { + if ( !rLineInfo.GetDotCount() == 1 ) + nStyle = W_PS_DASHDOT; + else + nStyle = W_PS_DASHDOTDOT; + } + } + else + nStyle = W_PS_DASH; + } + break; + case LINE_NONE : + nStyle = W_PS_NULL; + break; + } + *pWMF << nStyle; + + WriteSize( Size( rLineInfo.GetWidth(), 0 ) ); + WriteColor( rColor ); +} + +void WMFWriter::WMFRecord_DeleteObject(USHORT nObjectHandle) +{ + WriteRecordHeader(0x00000004,W_META_DELETEOBJECT); + *pWMF << nObjectHandle; +} + + +void WMFWriter::WMFRecord_Ellipse(const Rectangle & rRect) +{ + WriteRecordHeader(0x00000007,W_META_ELLIPSE); + WriteRectangle(rRect); +} + + +void WMFWriter::WMFRecord_ExtTextOut(const Point & rPoint, const ByteString & rString, const long * pDXAry) +{ + USHORT nLen,i; + + nLen=rString.Len(); + if (nLen<=1 || pDXAry==NULL) + { + WMFRecord_TextOut(rPoint,rString); + return; + } + + WriteRecordHeader(0,W_META_EXTTEXTOUT); + WritePointYX(rPoint); + *pWMF << nLen << (USHORT)0; + + for ( i = 0; i < nLen; i++ ) + *pWMF << (BYTE)rString.GetChar( i ); + if ((nLen&1)!=0) *pWMF << (BYTE)0; + WriteDX(pDXAry[0]); + for (i=1; i<(nLen-1); i++) WriteDX(pDXAry[i]-pDXAry[i-1]); + WriteDX(pDXAry[nLen-2]/(nLen-1)); + UpdateRecordHeader(); +} + + +void WMFWriter::WMFRecord_ExtTextOut(const Point & rPoint, const ByteString & rString, ULONG nWidth) +{ + USHORT nLen,i; + long * pDXAry; + sal_Int32 nNormSize; + + pVirDev->SetFont(aSrcFont); + nLen=rString.Len(); + pDXAry=new long[nLen]; + nNormSize = pVirDev->GetTextArray( UniString( rString, RTL_TEXTENCODING_UTF8 ),pDXAry ); + if (nLen<=1 || nNormSize ==(long)nWidth ) + { + WMFRecord_TextOut(rPoint,rString); + delete pDXAry; + return; + } + for (i=0; i<(nLen-1); i++) pDXAry[i]=pDXAry[i]*((long)nWidth)/nNormSize; + WMFRecord_ExtTextOut(rPoint,rString,pDXAry); + delete pDXAry; +} + + +void WMFWriter::WMFRecord_LineTo(const Point & rPoint) +{ + WriteRecordHeader(0x00000005,W_META_LINETO); + WritePointYX(rPoint); +} + + +void WMFWriter::WMFRecord_MoveTo(const Point & rPoint) +{ + WriteRecordHeader(0x00000005,W_META_MOVETO); + WritePointYX(rPoint); +} + + +void WMFWriter::WMFRecord_Pie(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt) +{ + WriteRecordHeader(0x0000000b,W_META_PIE); + WritePointYX(rEndPt); + WritePointYX(rStartPt); + WriteRectangle(rRect); +} + + +void WMFWriter::WMFRecord_Polygon(const Polygon & rPoly) +{ + USHORT nSize,i; + nSize=rPoly.GetSize(); + + WriteRecordHeader(((ULONG)nSize)*2+4,W_META_POLYGON); + *pWMF << nSize; + for (i=0; i<nSize; i++) WritePointXY(rPoly.GetPoint(i)); +} + + +void WMFWriter::WMFRecord_PolyLine(const Polygon & rPoly) +{ + USHORT nSize,i; + nSize=rPoly.GetSize(); + + WriteRecordHeader(((ULONG)nSize)*2+4,W_META_POLYLINE); + *pWMF << nSize; + for (i=0; i<nSize; i++) WritePointXY(rPoly.GetPoint(i)); +} + + +void WMFWriter::WMFRecord_PolyPolygon(const PolyPolygon & rPolyPoly) +{ + const Polygon * pPoly; + USHORT nCount,nSize,i,j; + + WriteRecordHeader(0,W_META_POLYPOLYGON); + nCount=rPolyPoly.Count(); + *pWMF << nCount; + for (i=0; i<nCount; i++) *pWMF << ((USHORT)(rPolyPoly.GetObject(i).GetSize())); + for (i=0; i<nCount; i++) { + pPoly=&(rPolyPoly.GetObject(i)); + nSize=pPoly->GetSize(); + for (j=0; j<nSize; j++) WritePointXY(pPoly->GetPoint(j)); + } + UpdateRecordHeader(); +} + + +void WMFWriter::WMFRecord_Rectangle(const Rectangle & rRect) +{ + WriteRecordHeader( 0x00000007,W_META_RECTANGLE ); + WriteRectangle( rRect ); +} + + +void WMFWriter::WMFRecord_RestoreDC() +{ + WriteRecordHeader(0x00000004,W_META_RESTOREDC); + *pWMF << (short)-1; +} + + +void WMFWriter::WMFRecord_RoundRect(const Rectangle & rRect, long nHorzRound, long nVertRound) +{ + WriteRecordHeader(0x00000009,W_META_ROUNDRECT); + WriteHeightWidth(Size(nHorzRound,nVertRound)); + WriteRectangle(rRect); +} + + +void WMFWriter::WMFRecord_SaveDC() +{ + WriteRecordHeader(0x00000003,W_META_SAVEDC); +} + + +void WMFWriter::WMFRecord_SelectObject(USHORT nObjectHandle) +{ + WriteRecordHeader(0x00000004,W_META_SELECTOBJECT); + *pWMF << nObjectHandle; +} + + +void WMFWriter::WMFRecord_SetBkColor(const Color & rColor) +{ + WriteRecordHeader(0x00000005,W_META_SETBKCOLOR); + WriteColor(rColor); +} + + +void WMFWriter::WMFRecord_SetBkMode(BOOL bTransparent) +{ + WriteRecordHeader(0x00000004,W_META_SETBKMODE); + if (bTransparent==TRUE) *pWMF << (USHORT)W_TRANSPARENT; + else *pWMF << (USHORT)W_OPAQUE; +} + +void WMFWriter::WMFRecord_SetStretchBltMode() +{ + WriteRecordHeader( 0x00000004, W_META_SETSTRETCHBLTMODE ); + *pWMF << (USHORT) 3; // STRETCH_DELETESCANS +} + +void WMFWriter::WMFRecord_SetPixel(const Point & rPoint, const Color & rColor) +{ + WriteRecordHeader(0x00000007,W_META_SETPIXEL); + WriteColor(rColor); + WritePointYX(rPoint); +} + + +void WMFWriter::WMFRecord_SetROP2(RasterOp eROP) +{ + USHORT nROP2; + + switch (eROP) { + case ROP_INVERT: nROP2=W_R2_NOT; break; + case ROP_XOR: nROP2=W_R2_XORPEN; break; + default: nROP2=W_R2_COPYPEN; + } + WriteRecordHeader(0x00000004,W_META_SETROP2); + *pWMF << nROP2; +} + + +void WMFWriter::WMFRecord_SetTextAlign(FontAlign eFontAlign) +{ + USHORT nAlign; + + switch (eFontAlign) { + case ALIGN_TOP: nAlign=W_TA_TOP; break; + case ALIGN_BOTTOM: nAlign=W_TA_BOTTOM; break; + default: nAlign=W_TA_BASELINE; + } + nAlign|=W_TA_LEFT; + nAlign|=W_TA_NOUPDATECP; + + WriteRecordHeader(0x00000004,W_META_SETTEXTALIGN); + *pWMF << nAlign; +} + + +void WMFWriter::WMFRecord_SetTextColor(const Color & rColor) +{ + WriteRecordHeader(0x00000005,W_META_SETTEXTCOLOR); + WriteColor(rColor); +} + + +void WMFWriter::WMFRecord_SetWindowExt(const Size & rSize) +{ + WriteRecordHeader(0x00000005,W_META_SETWINDOWEXT); + WriteHeightWidth(rSize); +} + + +void WMFWriter::WMFRecord_SetWindowOrg(const Point & rPoint) +{ + WriteRecordHeader(0x00000005,W_META_SETWINDOWORG); + WritePointYX(rPoint); +} + + +void WMFWriter::WMFRecord_StretchDIB( const Point & rPoint, const Size & rSize, + const Bitmap & rBitmap, ULONG nROP ) +{ + ULONG nPosAnf,nPosEnd; + + nActBitmapPercent=50; + MayCallback(); + + WriteRecordHeader(0x00000000,W_META_STRETCHDIB); + + // Die Reihenfolge im Metafile soll jetzt sein: + // einige Parameter (laenge 22), dann die Bitmap ohne FILEHEADER. + // Da aber *pWMF << rBitmap einen FILEHEADER der Laenge 14 + // erzeugt, schreiben wir zuerst die Bitmap an die richtige Position + // Und ueberschreiben hinterher den FILEHEADER mit den Parametern. + nPosAnf=pWMF->Tell(); // Position merken, wo Parameter hin sollen + *pWMF << (long)0 << (long)0; // 8 bytes auffuellen (diese 8 bytes + + // 14 bytes ueberfluessigen FILEHEADER + // = 22 bytes Parameter) + *pWMF << rBitmap; // Bitmap schreiben + + // Parameter schreiben: + nPosEnd=pWMF->Tell(); + pWMF->Seek(nPosAnf); + + // Raster-Op bestimmen, falls nichts uebergeben wurde + if( !nROP ) + { + switch( eSrcRasterOp ) + { + case ROP_INVERT: nROP = W_DSTINVERT; break; + case ROP_XOR: nROP = W_SRCINVERT; break; + default: nROP = W_SRCCOPY; + } + } + + *pWMF << nROP << + (short) 0 << + (short) rBitmap.GetSizePixel().Height() << + (short) rBitmap.GetSizePixel().Width() << + (short) 0 << + (short) 0; + + WriteHeightWidth(rSize); + WritePointYX(rPoint); + pWMF->Seek(nPosEnd); + + UpdateRecordHeader(); + + nWrittenBitmaps++; + nActBitmapPercent=0; +} + + +void WMFWriter::WMFRecord_TextOut(const Point & rPoint, const ByteString & rString) +{ + USHORT nLen,i; + + WriteRecordHeader(0,W_META_TEXTOUT); + nLen=rString.Len(); + *pWMF << nLen; + for ( i = 0; i < nLen; i++ ) + *pWMF << (BYTE)rString.GetChar( i ); + if ((nLen&1)!=0) *pWMF << (BYTE)0; + WritePointYX(rPoint); + UpdateRecordHeader(); +} + + +void WMFWriter::WMFRecord_EndOfFile() +{ + WriteRecordHeader(0x00000003,0x0000); +} + + +void WMFWriter::WMFRecord_IntersectClipRect( const Rectangle& rRect ) +{ + WriteRecordHeader( 0x00000007, W_META_INTERSECTCLIPRECT ); + WriteRectangle(rRect); +} + + +USHORT WMFWriter::AllocHandle() +{ + USHORT i; + + for (i=0; i<MAXOBJECTHANDLES; i++) { + if (bHandleAllocated[i]==FALSE) { + bHandleAllocated[i]=TRUE; + return i; + } + } + bStatus=FALSE; + return 0xffff; +} + + +void WMFWriter::FreeHandle(USHORT nObjectHandle) +{ + if (nObjectHandle<MAXOBJECTHANDLES) bHandleAllocated[nObjectHandle]=FALSE; +} + + +void WMFWriter::CreateSelectDeletePen(const Color& rColor) +{ + USHORT nOldHandle; + + nOldHandle=nDstPenHandle; + nDstPenHandle=AllocHandle(); + WMFRecord_CreatePenIndirect(rColor); + WMFRecord_SelectObject(nDstPenHandle); + if (nOldHandle<MAXOBJECTHANDLES) { + WMFRecord_DeleteObject(nOldHandle); + FreeHandle(nOldHandle); + } +} + + +void WMFWriter::CreateSelectDeleteFont(const Font & rFont) +{ + USHORT nOldHandle; + + nOldHandle=nDstFontHandle; + nDstFontHandle=AllocHandle(); + WMFRecord_CreateFontIndirect(rFont); + WMFRecord_SelectObject(nDstFontHandle); + if (nOldHandle<MAXOBJECTHANDLES) { + WMFRecord_DeleteObject(nOldHandle); + FreeHandle(nOldHandle); + } +} + + +void WMFWriter::CreateSelectDeleteBrush(const Color& rColor) +{ + USHORT nOldHandle; + + nOldHandle=nDstBrushHandle; + nDstBrushHandle=AllocHandle(); + WMFRecord_CreateBrushIndirect(rColor); + WMFRecord_SelectObject(nDstBrushHandle); + if (nOldHandle<MAXOBJECTHANDLES) { + WMFRecord_DeleteObject(nOldHandle); + FreeHandle(nOldHandle); + } +} + + +void WMFWriter::SetAttrForLines() +{ + + if (bAttrReadyForLines==TRUE) return; + + if (bDstGraphicsInvalid || eDstROP2!=eSrcRasterOp) { + eDstROP2=eSrcRasterOp; + WMFRecord_SetROP2(eDstROP2); + } + if (bDstGraphicsInvalid || aDstLineColor!=aSrcLineColor) { + aDstLineColor=aSrcLineColor; + CreateSelectDeletePen(aDstLineColor); + } + if (bDstGraphicsInvalid || aDstFillColor!=aSrcFillColor) { + aDstFillColor=aSrcFillColor; + CreateSelectDeleteBrush(aDstFillColor); + } + if (bDstGraphicsInvalid || bDstIsClipping!=bSrcIsClipping || + (bSrcIsClipping==TRUE && aDstClipRegion!=aSrcClipRegion)) { + bDstIsClipping=bSrcIsClipping; + aDstClipRegion=aSrcClipRegion; + if (bDstGraphicsInvalid==FALSE || bSrcIsClipping==TRUE) { + //...???... + } + } + + bAttrReadyForLines=TRUE; + bAttrReadyForAreas=FALSE; + bAttrReadyForText=FALSE; + bDstGraphicsInvalid=FALSE; +} + + +void WMFWriter::SetAttrForAreas() +{ + if( aSrcFillColor == Color( COL_TRANSPARENT ) ) + { + SetAttrForLines(); + return; + } + + if (bAttrReadyForAreas==TRUE) return; + + if (bDstGraphicsInvalid || eDstROP2!=eSrcRasterOp) { + eDstROP2=eSrcRasterOp; + WMFRecord_SetROP2(eDstROP2); + } + if (bDstGraphicsInvalid || aDstLineColor!=aSrcLineColor) { + aDstLineColor=aSrcLineColor; + CreateSelectDeletePen(aDstLineColor); + } + if (bDstGraphicsInvalid || aDstFillColor!=aSrcFillColor) { + aDstFillColor=aSrcFillColor; + CreateSelectDeleteBrush(aDstFillColor); + } + if (bDstGraphicsInvalid || bDstIsClipping!=bSrcIsClipping || + (bSrcIsClipping==TRUE && aDstClipRegion!=aSrcClipRegion)) { + bDstIsClipping=bSrcIsClipping; + aDstClipRegion=aSrcClipRegion; + if (bDstGraphicsInvalid==FALSE || bSrcIsClipping==TRUE) { + //...???... + } + } + + bAttrReadyForAreas=TRUE; + bAttrReadyForLines=FALSE; + bAttrReadyForText=FALSE; + bDstGraphicsInvalid=FALSE; +} + + +void WMFWriter::SetAttrForText() +{ + if (bAttrReadyForText==TRUE) return; + + if (bDstGraphicsInvalid==FALSE) SetAttrForLines(); + + if (bDstTextInvalid || aDstTextColor!=aSrcFont.GetColor()) { + aDstTextColor=aSrcFont.GetColor(); + WMFRecord_SetTextColor(aDstTextColor); + } + if (bDstTextInvalid || eDstTextAlign!=aSrcFont.GetAlign()) { + eDstTextAlign=aSrcFont.GetAlign(); + WMFRecord_SetTextAlign(eDstTextAlign); + } + if (bDstTextInvalid || aDstFont!=aSrcFont) { + aDstFont=aSrcFont; + CreateSelectDeleteFont(aDstFont); + } + + bAttrReadyForText=TRUE; + bAttrReadyForLines=FALSE; + bAttrReadyForAreas=FALSE; + bDstTextInvalid=FALSE; +} + + +void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) +{ + ULONG nA, nACount; + MetaAction* pMA; + + if( bStatus ) + { + nACount = rMTF.GetActionCount(); + + WMFRecord_SetStretchBltMode(); + + for( nA=0; nA<nACount; nA++ ) + { + pMA = rMTF.GetAction( nA ); + + switch( pMA->GetType() ) + { + case META_PIXEL_ACTION: + { + const MetaPixelAction* pA = (const MetaPixelAction *) pMA; + SetAttrForLines(); + WMFRecord_SetPixel( pA->GetPoint(), pA->GetColor() ); + } + break; + + case META_POINT_ACTION: + { + const MetaPointAction* pA = (const MetaPointAction*) pMA; + const Point& rPt = pA->GetPoint(); + SetAttrForLines(); + WMFRecord_MoveTo( rPt); + WMFRecord_LineTo( rPt ); + } + break; + + case META_LINE_ACTION: + { + const MetaLineAction* pA = (const MetaLineAction *) pMA; + const LineInfo& rLineInfo = pA->GetLineInfo(); + SetAttrForLines(); + if ( rLineInfo.IsDefault() ) + { + WMFRecord_MoveTo( pA->GetStartPoint() ); + WMFRecord_LineTo( pA->GetEndPoint() ); + } + else + { + USHORT nCurrentHandle = AllocHandle(); + WMFRecord_CreatePenIndirect( aSrcLineColor, rLineInfo ); + WMFRecord_SelectObject(nCurrentHandle); + WMFRecord_MoveTo( pA->GetStartPoint() ); + WMFRecord_LineTo( pA->GetEndPoint() ); + WMFRecord_DeleteObject(nCurrentHandle); + FreeHandle(nCurrentHandle); + WMFRecord_SelectObject(nDstPenHandle); + } + } + break; + + case META_RECT_ACTION: + { + const MetaRectAction* pA = (const MetaRectAction*) pMA; + SetAttrForAreas(); + WMFRecord_Rectangle( pA->GetRect() ); + } + break; + + case META_ROUNDRECT_ACTION: + { + const MetaRoundRectAction* pA = (const MetaRoundRectAction*) pMA; + SetAttrForAreas(); + WMFRecord_RoundRect( pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound() ); + } + break; + + case META_ELLIPSE_ACTION: + { + const MetaEllipseAction* pA = (const MetaEllipseAction*) pMA; + SetAttrForAreas(); + WMFRecord_Ellipse( pA->GetRect() ); + } + break; + + case META_ARC_ACTION: + { + const MetaArcAction* pA = (const MetaArcAction*) pMA; + SetAttrForLines(); + WMFRecord_Arc( pA->GetRect(),pA->GetStartPoint(),pA->GetEndPoint() ); + } + break; + + case META_PIE_ACTION: + { + const MetaPieAction* pA = (const MetaPieAction*) pMA; + SetAttrForAreas(); + WMFRecord_Pie( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() ); + } + break; + + + case META_CHORD_ACTION: + { + const MetaChordAction* pA = (const MetaChordAction*) pMA; + SetAttrForAreas(); + WMFRecord_Chord( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() ); + } + break; + + case META_POLYLINE_ACTION: + { + const MetaPolyLineAction* pA = (const MetaPolyLineAction*) pMA; + const LineInfo& rLineInfo = pA->GetLineInfo(); + SetAttrForLines(); + + if ( rLineInfo.IsDefault() ) + WMFRecord_PolyLine( pA->GetPolygon() ); + else + { + USHORT nCurrentHandle = AllocHandle(); + WMFRecord_CreatePenIndirect( aSrcLineColor, rLineInfo ); + WMFRecord_SelectObject(nCurrentHandle); + WMFRecord_PolyLine( pA->GetPolygon() ); + WMFRecord_DeleteObject(nCurrentHandle); + FreeHandle(nCurrentHandle); + WMFRecord_SelectObject(nDstPenHandle); + } + } + break; + + case META_POLYGON_ACTION: + { + const MetaPolygonAction* pA = (const MetaPolygonAction*) pMA; + SetAttrForAreas(); + WMFRecord_Polygon( pA->GetPolygon() ); + } + break; + + case META_POLYPOLYGON_ACTION: + { + const MetaPolyPolygonAction* pA = (const MetaPolyPolygonAction*) pMA; + SetAttrForAreas(); + WMFRecord_PolyPolygon( pA->GetPolyPolygon() ); + } + break; + + case META_TEXT_ACTION: + case META_TEXTRECT_ACTION: + { + const MetaTextAction * pA = (const MetaTextAction*) pMA; + String aTemp( pA->GetText(), pA->GetIndex(), pA->GetLen() ); + rtl_TextEncoding eChrSet = aSrcFont.GetCharSet(); + rtl_TextEncoding eTargetChrSet = RTL_TEXTENCODING_MS_1252; + if ( eChrSet == RTL_TEXTENCODING_DONTKNOW ) + eChrSet = gsl_getSystemTextEncoding(); + if ( eChrSet != RTL_TEXTENCODING_SYMBOL ) + eTargetChrSet = RTL_TEXTENCODING_SYMBOL; + ByteString aStr( aTemp, eChrSet, eTargetChrSet ); + SetAttrForText(); + WMFRecord_TextOut( pA->GetPoint(), aStr ); + } + break; + + case META_TEXTARRAY_ACTION: + { + const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pMA; + + String aTemp( pA->GetText(), pA->GetIndex(), pA->GetLen() ); + rtl_TextEncoding eChrSet = aSrcFont.GetCharSet(); + rtl_TextEncoding eTargetChrSet = RTL_TEXTENCODING_MS_1252; + if ( eChrSet == RTL_TEXTENCODING_DONTKNOW ) + eChrSet = gsl_getSystemTextEncoding(); + if ( eChrSet != RTL_TEXTENCODING_SYMBOL ) + eTargetChrSet = RTL_TEXTENCODING_SYMBOL; + ByteString aStr( aTemp, eChrSet, eTargetChrSet ); + SetAttrForText(); + WMFRecord_ExtTextOut( pA->GetPoint(), aStr,pA->GetDXArray() ); + } + break; + + case META_STRETCHTEXT_ACTION: + { + const MetaStretchTextAction* pA = (const MetaStretchTextAction *) pMA; + String aTemp( pA->GetText(), pA->GetIndex(), pA->GetLen() ); + rtl_TextEncoding eChrSet = aSrcFont.GetCharSet(); + rtl_TextEncoding eTargetChrSet = RTL_TEXTENCODING_MS_1252; + if ( eChrSet == RTL_TEXTENCODING_DONTKNOW ) + eChrSet = gsl_getSystemTextEncoding(); + if ( eChrSet != RTL_TEXTENCODING_SYMBOL ) + eTargetChrSet = RTL_TEXTENCODING_SYMBOL; + ByteString aStr( aTemp, eChrSet, eTargetChrSet ); + SetAttrForText(); + WMFRecord_ExtTextOut( pA->GetPoint(),aStr,pA->GetWidth() ); + } + break; + + case META_BMP_ACTION: + { + const MetaBmpAction* pA = (const MetaBmpAction *) pMA; + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetBitmap().GetSizePixel(), pA->GetBitmap() ); + } + break; + + case META_BMPSCALE_ACTION: + { + const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pMA; + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pA->GetBitmap() ); + } + break; + + case META_BMPSCALEPART_ACTION: + { + const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*) pMA; + Bitmap aTmp( pA->GetBitmap() ); + + if( aTmp.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ) ) + WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aTmp ); + } + + case META_BMPEX_ACTION: + { + const MetaBmpExAction* pA = (const MetaBmpExAction *) pMA; + Bitmap aBmp( pA->GetBitmapEx().GetBitmap() ); + Bitmap aMsk( pA->GetBitmapEx().GetMask() ); + + if( !!aMsk ) + { + aBmp.Replace( aMsk, COL_WHITE ); + aMsk.Invert(); + WMFRecord_StretchDIB( pA->GetPoint(), aMsk.GetSizePixel(), aBmp, W_SRCPAINT ); + WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp, W_SRCAND ); + } + else + WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp ); + } + break; + + case META_BMPEXSCALE_ACTION: + { + const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pMA; + Bitmap aBmp( pA->GetBitmapEx().GetBitmap() ); + Bitmap aMsk( pA->GetBitmapEx().GetMask() ); + + if( !!aMsk ) + { + aBmp.Replace( aMsk, COL_WHITE ); + aMsk.Invert(); + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aMsk, W_SRCPAINT ); + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp, W_SRCAND ); + } + else + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp ); + } + break; + + case META_BMPEXSCALEPART_ACTION: + { + const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*) pMA; + BitmapEx aBmpEx( pA->GetBitmapEx() ); + aBmpEx.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ); + Bitmap aBmp( aBmpEx.GetBitmap() ); + Bitmap aMsk( aBmpEx.GetMask() ); + + if( !!aMsk ) + { + aBmp.Replace( aMsk, COL_WHITE ); + aMsk.Invert(); + WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aMsk, W_SRCPAINT ); + WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp, W_SRCAND ); + } + else + WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp ); + } + + case META_GRADIENT_ACTION: + { + const MetaGradientAction* pA = (const MetaGradientAction*) pMA; + GDIMetaFile aTmpMtf; + + pVirDev->AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf ); + WriteRecords( aTmpMtf ); + } + break; + + case META_HATCH_ACTION: + { + const MetaHatchAction* pA = (const MetaHatchAction*) pMA; + GDIMetaFile aTmpMtf; + + pVirDev->AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf ); + WriteRecords( aTmpMtf ); + } + break; + + case META_WALLPAPER_ACTION: + { + const MetaWallpaperAction* pA = (const MetaWallpaperAction*) pMA; + const Color& rColor = pA->GetWallpaper().GetColor(); + const Color aOldLineColor( aSrcLineColor ); + const Color aOldFillColor( aSrcFillColor ); + + aSrcLineColor = rColor; + aSrcFillColor = rColor; + bAttrReadyForLines=FALSE; + bAttrReadyForAreas=FALSE; + SetAttrForAreas(); + WMFRecord_Rectangle( pA->GetRect() ); + aSrcLineColor = aOldLineColor; + aSrcFillColor = aOldFillColor; + bAttrReadyForLines=FALSE; + bAttrReadyForAreas=FALSE; + } + break; + + case META_ISECTRECTCLIPREGION_ACTION: + { + const MetaISectRectClipRegionAction* pA = (const MetaISectRectClipRegionAction*) pMA; + WMFRecord_IntersectClipRect( pA->GetRect() ); + } + break; + + case META_LINECOLOR_ACTION: + { + const MetaLineColorAction* pA = (const MetaLineColorAction*) pMA; + + if( pA->IsSetting() ) + aSrcLineColor = pA->GetColor(); + else + aSrcLineColor = Color( COL_TRANSPARENT ); + + bAttrReadyForLines=FALSE; + bAttrReadyForAreas=FALSE; + } + break; + + case META_FILLCOLOR_ACTION: + { + const MetaFillColorAction* pA = (const MetaFillColorAction*) pMA; + + if( pA->IsSetting() ) + aSrcFillColor = pA->GetColor(); + else + aSrcFillColor = Color( COL_TRANSPARENT ); + + bAttrReadyForLines=FALSE; + bAttrReadyForAreas=FALSE; + } + break; + + case META_TEXTCOLOR_ACTION: + { + const MetaTextColorAction* pA = (const MetaTextColorAction*) pMA; + aSrcFont.SetColor( pA->GetColor() ); + bAttrReadyForText = FALSE; + } + break; + + case META_TEXTFILLCOLOR_ACTION: + { + const MetaTextFillColorAction* pA = (const MetaTextFillColorAction*) pMA; + + if( pA->IsSetting() ) + aSrcFont.SetFillColor( pA->GetColor() ); + else + aSrcFont.SetFillColor( Color( COL_TRANSPARENT ) ); + + bAttrReadyForText = FALSE; + } + break; + + case META_TEXTALIGN_ACTION: + { + const MetaTextAlignAction* pA = (const MetaTextAlignAction*) pMA; + WMFRecord_SetTextAlign( pA->GetTextAlign() ); + } + 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(); + + bAttrReadyForLines=FALSE; + bAttrReadyForAreas=FALSE; + bAttrReadyForText=FALSE; + bDstGraphicsInvalid=TRUE; + bDstTextInvalid=TRUE; + } + } + break; + + case META_FONT_ACTION: + { + const MetaFontAction* pA = (const MetaFontAction*) pMA; + aSrcFont=pA->GetFont(); + bAttrReadyForText=FALSE; + } + break; + + case META_PUSH_ACTION: + { + WMFWriterAttrStackMember* pAt = new WMFWriterAttrStackMember; + + pAt->aLineColor=aSrcLineColor; + pAt->aFillColor=aSrcFillColor; + pAt->eRasterOp=eSrcRasterOp; + pAt->aFont=aSrcFont; + pAt->aMapMode=aSrcMapMode; + pAt->aClipRegion=aSrcClipRegion; + pAt->pSucc=pAttrStack; + pAttrStack=pAt; + + // Fuer das SaveDC muessen wir ggf. alle Objekte + // sofort selektieren, damit beim RestoreDC im ::Pop + // alles wieder richtig restauriert wird + SetAttrForLines(); + SetAttrForAreas(); + SetAttrForText(); + + // Das machen wir nur, um die ClipRegion nach einem evtl. + // IntersectClipRect wieder zuruecksetzen zu koennen + WMFRecord_SaveDC(); + } + break; + + case META_POP_ACTION: + { + WMFWriterAttrStackMember * pAt=pAttrStack; + + if( pAt ) + { + aSrcLineColor=pAt->aLineColor; + aSrcFillColor=pAt->aFillColor; + eSrcRasterOp=pAt->eRasterOp; + aSrcFont=pAt->aFont; + aSrcMapMode=pAt->aMapMode; + aSrcClipRegion=pAt->aClipRegion; + pAttrStack=pAt->pSucc; + delete pAt; + + WMFRecord_RestoreDC(); + + bAttrReadyForLines=FALSE; + bAttrReadyForAreas=FALSE; + bAttrReadyForText=FALSE; + bDstGraphicsInvalid=TRUE; + } + } + 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; + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pBmpScaleAction->GetBitmap() ); + break; + } + } + } + break; + + case META_RASTEROP_ACTION: + { + const MetaRasterOpAction* pA = (const MetaRasterOpAction*) pMA; + eSrcRasterOp=pA->GetRasterOp(); + bAttrReadyForLines=FALSE; + bAttrReadyForAreas=FALSE; + bAttrReadyForText=FALSE; + } + break; + + case META_TRANSPARENT_ACTION: + { + SetAttrForAreas(); + WMFRecord_PolyPolygon( ( (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; + + SetAttrForLines(); + SetAttrForAreas(); + SetAttrForText(); + + 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 ); + + WriteRecords( aTmpMtf ); + } + break; + + // Unsupported Actions + case META_MASK_ACTION: + case META_MASKSCALE_ACTION: + case META_MASKSCALEPART_ACTION: + { + DBG_ERROR( "Unsupported action: MetaMask...Action!" ); + } + break; + + case META_CLIPREGION_ACTION: + break; + + case META_ISECTREGIONCLIPREGION_ACTION: + { + DBG_ERROR( "Unsupported action: MetaISectRegionClipRegionAction!" ); + } + break; + + case META_MOVECLIPREGION_ACTION: + { + DBG_ERROR( "Unsupported action: MetaMoveClipRegionAction!" ); + } + break; + } + + nWrittenActions++; + MayCallback(); + + if (pWMF->GetError()) + bStatus=FALSE; + + if(bStatus==FALSE) + break; + } + } +} + +// ------------------------------------------------------------------------ + +void WMFWriter::WriteHeader( const GDIMetaFile & rMTF, BOOL bPlaceable ) +{ + if( bPlaceable ) + { + USHORT nCheckSum, nValue; + Size aSize( pVirDev->LogicToLogic(Size(1,1),MapMode(MAP_INCH), aTargetMapMode) ); + USHORT nUnitsPerInch = (USHORT) ( ( aSize.Width() + aSize.Height() ) >> 1 ); + + nCheckSum=0; + nValue=0xcdd7; nCheckSum^=nValue; *pWMF << nValue; + nValue=0x9ac6; nCheckSum^=nValue; *pWMF << nValue; + nValue=0x0000; nCheckSum^=nValue; *pWMF << nValue; + nValue=0x0000; nCheckSum^=nValue; *pWMF << nValue; + nValue=0x0000; nCheckSum^=nValue; *pWMF << nValue; + nValue=(USHORT) aTargetSize.Width(); nCheckSum^=nValue; *pWMF << nValue; + nValue=(USHORT) aTargetSize.Height(); nCheckSum^=nValue; *pWMF << nValue; + nValue=nUnitsPerInch; nCheckSum^=nValue; *pWMF << nValue; + nValue=0x0000; nCheckSum^=nValue; *pWMF << nValue; + nValue=0x0000; nCheckSum^=nValue; *pWMF << nValue; + *pWMF << nCheckSum; + } + + nMetafileHeaderPos=pWMF->Tell(); + *pWMF << (USHORT)0x0001 // Typ: Datei + << (USHORT)0x0009 // Headerlaenge in Worten + << (USHORT)0x0300 // Version als BCD-Zahl + << (ULONG) 0x00000000 // Dateilaenge (ohne 1. Header), wird spaeter durch UpdateHeader() berichtigt + << (USHORT)MAXOBJECTHANDLES // Maximalezahl der gleichzeitigen Objekte + << (ULONG) 0x00000000 // Maximale Record-laenge, wird spaeter durch UpdateHeader() berichtigt + << (USHORT)0x0000; // Reserved +} + +// ------------------------------------------------------------------------ + +void WMFWriter::UpdateHeader() +{ + ULONG nPos,nFileSize; + + nPos=pWMF->Tell(); // Endposition = Gesammtgroesse der Datei + nFileSize=nPos-nMetafileHeaderPos; // Groesse des 1. Headers abziehen + if ((nFileSize&1)!=0) { // ggf. auf ganze Worte aufrunden + *pWMF << (BYTE)0; + nPos++; + nFileSize++; + } + nFileSize>>=1; // In Anzahl Worte umrechnen + pWMF->Seek(nMetafileHeaderPos+6); // Zum Dateigroessen-Eintrag im zweiten Header + *pWMF << nFileSize; // Dateigroesse berichtigen + pWMF->SeekRel(2); // Zum Max-Record-Laenge-Eintrag im zweiten Header + *pWMF << nMaxRecordSize; // und berichtigen + pWMF->Seek(nPos); +} + +// ------------------------------------------------------------------------ + +BOOL WMFWriter::WriteWMF(const GDIMetaFile& rMTF, SvStream& rTargetStream, + PFilterCallback pcallback, void* pcallerdata, + BOOL bPlaceable) +{ + WMFWriterAttrStackMember * pAt; + + bStatus=TRUE; + pVirDev = new VirtualDevice; + pCallback=pcallback; + pCallerData=pcallerdata; + nLastPercent=0; + + pWMF=&rTargetStream; + pWMF->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN); + + nMaxRecordSize=0; + + aSrcMapMode=rMTF.GetPrefMapMode(); + + if( bPlaceable ) + { + aTargetMapMode = aSrcMapMode; + aTargetSize = rMTF.GetPrefSize(); + nTargetDivisor = CalcSaveTargetMapMode(aTargetMapMode, aTargetSize); + aTargetSize.Width() /= nTargetDivisor; + aTargetSize.Height() /= nTargetDivisor; + } + else + { + aTargetMapMode = MapMode( MAP_INCH ); + + const long nUnit = pVirDev->LogicToPixel( Size( 1, 1 ), aTargetMapMode ).Width(); + const Fraction aFrac( 1, nUnit ); + + aTargetMapMode.SetScaleX( aFrac ); + aTargetMapMode.SetScaleY( aFrac ); + aTargetSize = pVirDev->LogicToLogic( rMTF.GetPrefSize(), aSrcMapMode, aTargetMapMode ); + } + + pVirDev->SetMapMode( aTargetMapMode ); + + aSrcLineColor = Color( COL_BLACK ); + aSrcFillColor = Color( COL_WHITE ); + eSrcRasterOp=ROP_OVERPAINT; + aSrcFont=Font(); + bSrcIsClipping=FALSE; + aSrcClipRegion=Region(); + pAttrStack=NULL; + + aDstLineColor = Color( COL_BLACK ); + aDstFillColor = Color( COL_WHITE ); + eDstROP2=ROP_OVERPAINT; + aDstTextColor=Color(COL_BLACK); + eDstTextAlign=ALIGN_BASELINE; + aDstFont=Font(); + bDstIsClipping=FALSE; + aDstClipRegion=Region(); + + for (USHORT i=0; i<MAXOBJECTHANDLES; i++) + bHandleAllocated[i]=FALSE; + + nDstPenHandle=0xffff; + nDstFontHandle=0xffff; + nDstBrushHandle=0xffff; + + bDstTextInvalid=TRUE; + bDstGraphicsInvalid=TRUE; + + bAttrReadyForLines=FALSE; + bAttrReadyForAreas=FALSE; + bAttrReadyForText=FALSE; + + nNumberOfActions=0; + nNumberOfBitmaps=0; + nWrittenActions=0; + nWrittenBitmaps=0; + nActBitmapPercent=0; + + CountActionsAndBitmaps(rMTF); + + WriteHeader(rMTF,bPlaceable); + WMFRecord_SetWindowOrg(Point(0,0)); + WMFRecord_SetWindowExt(rMTF.GetPrefSize()); + WMFRecord_SetBkMode( TRUE ); + + // Write records + WriteRecords(rMTF); + + WMFRecord_EndOfFile(); + UpdateHeader(); + + while(pAttrStack) + { + pAt=pAttrStack; + pAttrStack=pAt->pSucc; + delete pAt; + } + + delete pVirDev; + + return bStatus; +} + +// ------------------------------------------------------------------------ + +USHORT WMFWriter::CalcSaveTargetMapMode(MapMode& rMapMode, + const Size& rPrefSize) +{ + Fraction aDivFrac(2, 1); + USHORT nDivisor = 1; + + Size aSize = pVirDev->LogicToLogic( rPrefSize, aSrcMapMode, rMapMode ); + + while( nDivisor <= 64 && (aSize.Width() > 32767 || aSize.Height() > 32767) ) + { + Fraction aFrac = rMapMode.GetScaleX(); + + aFrac *= aDivFrac; + rMapMode.SetScaleX(aFrac); + aFrac = rMapMode.GetScaleY(); + aFrac *= aDivFrac; + rMapMode.SetScaleY(aFrac); + nDivisor <<= 1; + aSize = pVirDev->LogicToLogic( rPrefSize, aSrcMapMode, rMapMode ); + } + + return nDivisor; +} diff --git a/svtools/source/filter.vcl/wmf/wmfwr.hxx b/svtools/source/filter.vcl/wmf/wmfwr.hxx new file mode 100644 index 000000000000..1ac7603c1ba9 --- /dev/null +++ b/svtools/source/filter.vcl/wmf/wmfwr.hxx @@ -0,0 +1,245 @@ +/************************************************************************* + * + * $RCSfile: wmfwr.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:59:00 $ + * + * 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 _WMFWR_HXX +#define _WMFWR_HXX + +#include <tools/bigint.hxx> +#include <tools/debug.hxx> +#include <vcl/metaact.hxx> +#include <vcl/graph.hxx> +#include <vcl/gdimtf.hxx> +#include <vcl/virdev.hxx> +#include "fltcall.hxx" + +// ----------------------------------------------------------------------------- + +#define MAXOBJECTHANDLES 16 + +// ----------------------------------------------------------------------------- + +struct WMFWriterAttrStackMember +{ + struct WMFWriterAttrStackMember * pSucc; + Color aLineColor; + Color aFillColor; + RasterOp eRasterOp; + Font aFont; + MapMode aMapMode; + Region aClipRegion; +}; + +// ------------- +// - WMFWriter - +// ------------- + +class WMFWriter +{ +private: + + BOOL bStatus; + + PFilterCallback pCallback; + void* pCallerData; + ULONG nLastPercent; // Mit welcher Zahl pCallback zuletzt aufgerufen wurde. + + SvStream* pWMF; + VirtualDevice* pVirDev; + MapMode aTargetMapMode; + Size aTargetSize; + USHORT nTargetDivisor; + + ULONG nMetafileHeaderPos; + ULONG nMaxRecordSize; // in Worten + ULONG nActRecordPos; + + // Aktuelle Attribute im Quell-Metafile: + Color aSrcLineColor; + Color aSrcFillColor; + RasterOp eSrcRasterOp; + Font aSrcFont; + MapMode aSrcMapMode; + BOOL bSrcIsClipping; + Region aSrcClipRegion; + WMFWriterAttrStackMember * pAttrStack; + + // Aktuelle Attribute im Ziel-Metafile: + RasterOp eDstROP2; + Color aDstTextColor; + FontAlign eDstTextAlign; + Color aDstLineColor; + Color aDstFillColor; + Font aDstFont; + BOOL bDstIsClipping; // ???: derzeit unberuecksichtigt + Region aDstClipRegion; // ???: derzeit unberuecksichtigt + BOOL bHandleAllocated[MAXOBJECTHANDLES]; // Welche Handles vergeben sind + USHORT nDstPenHandle,nDstFontHandle,nDstBrushHandle; // Welche Handles die jeweiligen + // Selected-Objects besitzen + // 0xffff = keines: + BOOL bDstTextInvalid; // ist TRUE, wenn die Variablen aDstTextColor, eDstTextAlign + // und aDstFont nicht mit den Attributen im Ziel-Metafile + // uebereinstimmen (Das ist am Anfang der Fall) + BOOL bDstGraphicsInvalid; // dito fuer alle anderen Attribute + + // Damit nicht bei jeder Operation alle Attribute verglichen werden muessen: + BOOL bAttrReadyForLines; // Ist TRUE, wenn die Attribute im Ziel-Metafile so + // gesetzt sind, dass Linien ausgegeben werden koennen. + BOOL bAttrReadyForAreas; // Ist TRUE, wenn die Attribute im Ziel-Metafile so + // gesetzt sind, dass gefuellte Polygone, Rechtecke etc. + // (einschliesslich Umrahmung) ausgegeben werden koennen. + BOOL bAttrReadyForText; // Ist TRUE, wenn die Attribute im Ziel-Metafile so + // gesetzt sind, dass Text ausgegeben werden kann. + + 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 & rMTF); + // Zaehlt die Bitmaps und Actions (nNumberOfActions und nNumberOfBitmaps muessen + // zu Anfang auf 0 gesetzt werden, weil diese Methode rekursiv ist) + + void WritePointXY(const Point & rPoint); + void WritePointYX(const Point & rPoint); + void WriteDX(long nDX); + void WriteSize(const Size & rSize); + void WriteHeightWidth(const Size & rSize); + void WriteRectangle(const Rectangle & rRect); + void WriteColor(const Color & rColor); + + void WriteRecordHeader(ULONG nSizeWords, USHORT nType); + // nSizeWords ist die Groesse des gesammten Records in Anzahl Worte. + // Wenn nSizeWords unbekannt ist, dann 0 einsetzen (siehe UpdateRecordHeader()). + + void UpdateRecordHeader(); + // berichtig die Groesse des Records nach dem Schreiben der Parameter, wenn + // nSizeWords bei Aufruf von WriteRecordHeader(..) unbekannt war. + // fuegt ggf. noch ein BYTE 0 ein damit Anzahl Bytes immer gerade. + + void WMFRecord_Arc(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt); + void WMFRecord_Chord(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt); + void WMFRecord_CreateBrushIndirect(const Color& rColor); + void WMFRecord_CreateFontIndirect(const Font & rFont); + void WMFRecord_CreatePenIndirect(const Color& rColor); + void WMFRecord_CreatePenIndirect(const Color& rColor, const LineInfo& rLineInfo ); + void WMFRecord_DeleteObject(USHORT nObjectHandle); + void WMFRecord_Ellipse(const Rectangle & rRect); + void WMFRecord_ExtTextOut(const Point & rPoint, const ByteString & rString, const long * pDXAry); + void WMFRecord_ExtTextOut(const Point & rPoint, const ByteString & rString, ULONG nWidth); + void WMFRecord_LineTo(const Point & rPoint); + void WMFRecord_MoveTo(const Point & rPoint); + void WMFRecord_Pie(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt); + void WMFRecord_Polygon(const Polygon & rPoly); + void WMFRecord_PolyLine(const Polygon & rPoly); + void WMFRecord_PolyPolygon(const PolyPolygon & rPolyPoly); + void WMFRecord_Rectangle(const Rectangle & rRect); + void WMFRecord_RestoreDC(); + void WMFRecord_RoundRect(const Rectangle & rRect, long nHorzRound, long nVertRound); + void WMFRecord_SaveDC(); + void WMFRecord_SelectObject(USHORT nObjectHandle); + void WMFRecord_SetBkColor(const Color & rColor); + void WMFRecord_SetBkMode(BOOL bTransparent); + void WMFRecord_SetStretchBltMode(); + void WMFRecord_SetPixel(const Point & rPoint, const Color & rColor); + void WMFRecord_SetROP2(RasterOp eROP); + void WMFRecord_SetTextAlign(FontAlign eFontAlign); + void WMFRecord_SetTextColor(const Color & rColor); + void WMFRecord_SetWindowExt(const Size & rSize); + void WMFRecord_SetWindowOrg(const Point & rPoint); + void WMFRecord_StretchDIB(const Point & rPoint, const Size & rSize, const Bitmap & rBitmap, ULONG nROP = 0UL ); + void WMFRecord_TextOut(const Point & rPoint, const ByteString & rString); + void WMFRecord_EndOfFile(); + void WMFRecord_IntersectClipRect( const Rectangle& rRect); + + USHORT AllocHandle(); + void FreeHandle(USHORT nObjectHandle); + void CreateSelectDeletePen(const Color& rColor); + void CreateSelectDeleteFont(const Font & rFont); + void CreateSelectDeleteBrush(const Color& rColor); + + void SetAttrForLines(); // Setzt die Dst-Attribute fuer Linien + void SetAttrForAreas(); // Setzt die Dst-Attribute fuer gefuellte Dinge. + // Macht automatisch SetAttrForLines, wenn BrushStyle NULL + void SetAttrForText(); // Setzt die Dst-Attribute fuer Text-Ausgabe + + void WriteRecords(const GDIMetaFile & rMTF); + + void WriteHeader(const GDIMetaFile & rMTF, BOOL bPlaceable); + void UpdateHeader(); + + USHORT CalcSaveTargetMapMode(MapMode& rMapMode, const Size& rPrefSize); + +public: + + WMFWriter() {} + + BOOL WriteWMF(const GDIMetaFile & rMTF, SvStream & rTargetStream, + PFilterCallback pcallback, void * pcallerdata, + BOOL bPlaceable=TRUE); +}; + +#endif |