summaryrefslogtreecommitdiff
path: root/binfilter/bf_svtools/source/filter.vcl/filter
diff options
context:
space:
mode:
Diffstat (limited to 'binfilter/bf_svtools/source/filter.vcl/filter')
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/FilterConfigCache.hxx145
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/makefile.mk68
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/sgf.ini118
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigCache.cxx618
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigItem.cxx383
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_filter.cxx2019
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_filter2.cxx1325
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_fldll.cxx84
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_gradwrap.cxx577
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_sgfbram.cxx658
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvmain.cxx1144
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvspln.cxx902
-rw-r--r--binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvtext.cxx1295
13 files changed, 9336 insertions, 0 deletions
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/FilterConfigCache.hxx b/binfilter/bf_svtools/source/filter.vcl/filter/FilterConfigCache.hxx
new file mode 100644
index 000000000000..7ba338500569
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/FilterConfigCache.hxx
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _FILTER_CONFIG_CACHE_HXX_
+#define _FILTER_CONFIG_CACHE_HXX_
+
+#include <tools/string.hxx>
+#include <rtl/ustring.hxx>
+#include "bf_svtools/svtdllapi.h"
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+#include <vector>
+
+namespace binfilter
+{
+
+class FilterConfigCache
+{
+ struct FilterConfigCacheEntry
+ {
+ ::rtl::OUString sInternalFilterName;
+ ::rtl::OUString sType;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > lExtensionList;
+ ::rtl::OUString sUIName;
+ ::rtl::OUString sDocumentService;
+ ::rtl::OUString sFilterService;
+ ::rtl::OUString sTemplateName;
+
+ ::rtl::OUString sMediaType;
+ ::rtl::OUString sFilterType;
+
+ sal_Int32 nFlags;
+ sal_Int32 nFileFormatVersion;
+
+ // user data
+ String sFilterName;
+ sal_Bool bHasDialog : 1;
+ sal_Bool bIsInternalFilter : 1;
+ sal_Bool bIsPixelFormat : 1;
+
+ sal_Bool CreateFilterName( const ::rtl::OUString& rUserDataEntry );
+ String GetShortName( );
+
+ static const char* InternalPixelFilterNameList[];
+ static const char* InternalVectorFilterNameList[];
+ static const char* ExternalPixelFilterNameList[];
+ };
+
+ typedef std::vector< FilterConfigCacheEntry > CacheVector;
+
+
+ CacheVector aImport;
+ CacheVector aExport;
+ sal_Bool bUseConfig;
+
+ static sal_Bool bInitialized;
+ static sal_Int32 nIndType;
+ static sal_Int32 nIndUIName;
+ static sal_Int32 nIndDocumentService;
+ static sal_Int32 nIndFilterService;
+ static sal_Int32 nIndFlags;
+ static sal_Int32 nIndUserData;
+ static sal_Int32 nIndFileFormatVersion;
+ static sal_Int32 nIndTemplateName;
+
+ static const char* InternalFilterListForSvxLight[];
+
+ void ImplInit();
+ void ImplInitSmart();
+
+ public :
+
+ sal_uInt16 GetImportFormatCount() const
+ { return sal::static_int_cast< sal_uInt16 >(aImport.size()); };
+ sal_uInt16 GetImportFormatNumber( const String& rFormatName );
+ sal_uInt16 GetImportFormatNumberForMediaType( const String& rMediaType );
+ sal_uInt16 GetImportFormatNumberForShortName( const String& rShortName );
+ sal_uInt16 GetImportFormatNumberForTypeName( const String& rType );
+ String GetImportFilterName( sal_uInt16 nFormat );
+ String GetImportFormatName( sal_uInt16 nFormat );
+ String GetImportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry = 0);
+ String GetImportFormatMediaType( sal_uInt16 nFormat );
+ String GetImportFormatShortName( sal_uInt16 nFormat );
+ String GetImportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry );
+ String GetImportFilterType( sal_uInt16 nFormat );
+ String GetImportFilterTypeName( sal_uInt16 nFormat );
+
+ sal_Bool IsImportInternalFilter( sal_uInt16 nFormat );
+ sal_Bool IsImportPixelFormat( sal_uInt16 nFormat );
+
+ sal_uInt16 GetExportFormatCount() const
+ { return sal::static_int_cast< sal_uInt16 >(aExport.size()); };
+ sal_uInt16 GetExportFormatNumber( const String& rFormatName );
+ sal_uInt16 GetExportFormatNumberForMediaType( const String& rMediaType );
+ sal_uInt16 GetExportFormatNumberForShortName( const String& rShortName );
+ sal_uInt16 GetExportFormatNumberForTypeName( const String& rType );
+ String GetExportFilterName( sal_uInt16 nFormat );
+ String GetExportFormatName( sal_uInt16 nFormat );
+ String GetExportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry = 0 );
+ String GetExportFormatMediaType( sal_uInt16 nFormat );
+ String GetExportFormatShortName( sal_uInt16 nFormat );
+ String GetExportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry );
+ String GetExportFilterTypeName( sal_uInt16 nFormat );
+
+ sal_Bool IsExportInternalFilter( sal_uInt16 nFormat );
+ sal_Bool IsExportPixelFormat( sal_uInt16 nFormat );
+
+ FilterConfigCache( sal_Bool bUseConfig );
+ ~FilterConfigCache();
+
+};
+
+}
+
+#endif // _FILTER_CONFIG_CACHE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/makefile.mk b/binfilter/bf_svtools/source/filter.vcl/filter/makefile.mk
new file mode 100644
index 000000000000..14f5735f8c6c
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/makefile.mk
@@ -0,0 +1,68 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..
+
+PRJNAME=binfilter
+TARGET=filter
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+INC+= -I$(PRJ)$/inc$/bf_svtools
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= $(SLO)$/svt_filter.obj \
+ $(SLO)$/svt_filter2.obj \
+ $(SLO)$/svt_sgfbram.obj \
+ $(SLO)$/svt_sgvmain.obj \
+ $(SLO)$/svt_sgvtext.obj \
+ $(SLO)$/svt_sgvspln.obj \
+ $(SLO)$/svt_FilterConfigItem.obj \
+ $(SLO)$/svt_FilterConfigCache.obj
+
+EXCEPTIONSNOOPTFILES= $(SLO)$/svt_filter.obj \
+ $(SLO)$/svt_FilterConfigItem.obj \
+ $(SLO)$/svt_FilterConfigCache.obj
+
+LIB1TARGET= $(SLB)$/$(TARGET).lib
+LIB1OBJFILES= \
+ $(SLO)$/svt_filter.obj \
+ $(SLO)$/svt_filter2.obj \
+ $(SLO)$/svt_sgfbram.obj \
+ $(SLO)$/svt_sgvmain.obj \
+ $(SLO)$/svt_sgvtext.obj \
+ $(SLO)$/svt_sgvspln.obj \
+ $(SLO)$/svt_FilterConfigItem.obj \
+ $(SLO)$/svt_FilterConfigCache.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/sgf.ini b/binfilter/bf_svtools/source/filter.vcl/filter/sgf.ini
new file mode 100644
index 000000000000..7444e40c8836
--- /dev/null
+++ b/binfilter/bf_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/binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigCache.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigCache.cxx
new file mode 100644
index 000000000000..9564fbde0cb0
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigCache.cxx
@@ -0,0 +1,618 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+
+#include "FilterConfigCache.hxx"
+#include <bf_svtools/filter.hxx>
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+#include <rtl/ustring.hxx>
+
+#include <com/sun/star/uno/Any.h>
+#include <unotools/processfactory.hxx>
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#define TOKEN_COUNT_FOR_OWN_FILTER 3
+// #define TOKEN_INDEX_FOR_IDENT 0
+#define TOKEN_INDEX_FOR_FILTER 1
+// #define TOKEN_INDEX_FOR_HASDIALOG 2
+
+using namespace ::com::sun::star::lang ; // XMultiServiceFactory
+using namespace ::com::sun::star::container ; // XNameAccess
+using namespace ::com::sun::star::uno ; // Reference
+using namespace ::com::sun::star::beans ; // PropertyValue
+using namespace ::utl ; // getProcessServiceFactory();
+using namespace ::rtl ;
+
+namespace binfilter
+{
+
+const char* FilterConfigCache::FilterConfigCacheEntry::InternalPixelFilterNameList[] =
+{
+ IMP_BMP, IMP_GIF, IMP_PNG,IMP_JPEG, IMP_XBM, IMP_XPM,
+ EXP_BMP, EXP_JPEG, EXP_PNG, NULL
+};
+
+const char* FilterConfigCache::FilterConfigCacheEntry::InternalVectorFilterNameList[] =
+{
+ IMP_SVMETAFILE, IMP_WMF, IMP_EMF, IMP_SVSGF, IMP_SVSGV,
+ EXP_SVMETAFILE, EXP_WMF, EXP_EMF, EXP_SVG, NULL
+};
+
+const char* FilterConfigCache::FilterConfigCacheEntry::ExternalPixelFilterNameList[] =
+{
+ "egi", "icd", "ipd", "ipx", "ipb", "epb", "epg",
+ "epp", "ira", "era", "itg", "iti", "eti", "exp", NULL
+};
+
+sal_Bool FilterConfigCache::bInitialized = sal_False;
+sal_Int32 FilterConfigCache::nIndType = -1;
+sal_Int32 FilterConfigCache::nIndUIName = -1;
+sal_Int32 FilterConfigCache::nIndDocumentService = -1;
+sal_Int32 FilterConfigCache::nIndFilterService = -1;
+sal_Int32 FilterConfigCache::nIndFlags = -1;
+sal_Int32 FilterConfigCache::nIndUserData = -1;
+sal_Int32 FilterConfigCache::nIndFileFormatVersion = -1;
+sal_Int32 FilterConfigCache::nIndTemplateName = -1;
+
+sal_Bool FilterConfigCache::FilterConfigCacheEntry::CreateFilterName( const OUString& rUserDataEntry )
+{
+ bIsPixelFormat = bIsInternalFilter = sal_False;
+ sFilterName = String( rUserDataEntry );
+ const char** pPtr;
+ for ( pPtr = InternalPixelFilterNameList; *pPtr && ( bIsInternalFilter == sal_False ); pPtr++ )
+ {
+ if ( sFilterName.EqualsIgnoreCaseAscii( *pPtr ) )
+ {
+ bIsInternalFilter = sal_True;
+ bIsPixelFormat = sal_True;
+ }
+ }
+ for ( pPtr = InternalVectorFilterNameList; *pPtr && ( bIsInternalFilter == sal_False ); pPtr++ )
+ {
+ if ( sFilterName.EqualsIgnoreCaseAscii( *pPtr ) )
+ bIsInternalFilter = sal_True;
+ }
+ if ( !bIsInternalFilter )
+ {
+ for ( pPtr = ExternalPixelFilterNameList; *pPtr && ( bIsPixelFormat == sal_False ); pPtr++ )
+ {
+ if ( sFilterName.EqualsIgnoreCaseAscii( *pPtr ) )
+ bIsPixelFormat = sal_True;
+ }
+ String aTemp( OUString::createFromAscii( SVLIBRARY( "?" ) ) );
+ xub_StrLen nIndex = aTemp.Search( (sal_Unicode)'?' );
+ aTemp.Replace( nIndex, 1, sFilterName );
+ sFilterName = aTemp;
+ }
+ return sFilterName.Len() != 0;
+}
+
+String FilterConfigCache::FilterConfigCacheEntry::GetShortName()
+{
+ String aShortName;
+ if ( lExtensionList.getLength() )
+ {
+ aShortName = lExtensionList[ 0 ];
+ if ( aShortName.SearchAscii( "*.", 0 ) == 0 )
+ aShortName.Erase( 0, 2 );
+ }
+ return aShortName;
+}
+
+/** helper to open the configuration root of the underlying
+ config package
+
+ @param sPackage
+ specify, which config package should be opened.
+ Must be one of the defined static values TYPEPKG or FILTERPKG.
+
+ @return A valid object if open was successfull. The access on opened
+ data will be readonly. It returns NULL in case open failed.
+
+ @throws It let pass RuntimeExceptions only.
+ */
+Reference< XInterface > openConfig(const char* sPackage)
+ throw(RuntimeException)
+{
+ static OUString TYPEPKG( RTL_CONSTASCII_USTRINGPARAM( "types" ) );
+ static OUString FILTERPKG( RTL_CONSTASCII_USTRINGPARAM( "filters" ) );
+
+ Reference< XMultiServiceFactory > xSMGR = getProcessServiceFactory();
+ Reference< XInterface > xCfg;
+ try
+ {
+ // get access to config API (not to file!)
+ Reference< XMultiServiceFactory > xConfigProvider( xSMGR->createInstance(
+ OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), UNO_QUERY);
+
+ if (xConfigProvider.is())
+ {
+ Sequence< Any > lParams(1);
+ PropertyValue aParam ;
+
+ // define cfg path for open
+ aParam.Name = OUString::createFromAscii("nodepath");
+ if (TYPEPKG.equalsIgnoreAsciiCaseAscii(sPackage))
+ aParam.Value <<= OUString::createFromAscii("/org.openoffice.TypeDetection.Types/Types");
+ if (FILTERPKG.equalsIgnoreAsciiCaseAscii(sPackage))
+ aParam.Value <<= OUString::createFromAscii("/org.openoffice.TypeDetection.GraphicFilter/Filters");
+ lParams[0] = makeAny(aParam);
+
+ // get access to file
+ xCfg = xConfigProvider->createInstanceWithArguments(
+ OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"), lParams);
+ }
+ }
+ catch(const RuntimeException&)
+ { throw; }
+ catch(const Exception&)
+ { xCfg.clear(); }
+
+ return xCfg;
+}
+
+void FilterConfigCache::ImplInit()
+{
+ static OUString STYPE ( RTL_CONSTASCII_USTRINGPARAM( "Type" ) );
+ static OUString SUINAME ( RTL_CONSTASCII_USTRINGPARAM( "UIName" ) );
+ static OUString SDOCUMENTSERVICE ( RTL_CONSTASCII_USTRINGPARAM( "DocumentService" ) );
+ static OUString SFILTERSERVICE ( RTL_CONSTASCII_USTRINGPARAM( "FilterService" ) );
+ static OUString STEMPLATENAME ( RTL_CONSTASCII_USTRINGPARAM( "TemplateName" ) );
+ static OUString SFILEFORMATVERSION ( RTL_CONSTASCII_USTRINGPARAM( "FileFormatVersion" ) );
+ static OUString SUICOMPONENT ( RTL_CONSTASCII_USTRINGPARAM( "UIComponent" ) );
+ static OUString SFLAGS ( RTL_CONSTASCII_USTRINGPARAM( "Flags" ) );
+ static OUString SUSERDATA ( RTL_CONSTASCII_USTRINGPARAM( "UserData" ) );
+ static OUString SMEDIATYPE ( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) );
+ static OUString SEXTENSIONS ( RTL_CONSTASCII_USTRINGPARAM( "Extensions" ) );
+ static OUString SFORMATNAME ( RTL_CONSTASCII_USTRINGPARAM( "FormatName" ) );
+ static OUString SREALFILTERNAME ( RTL_CONSTASCII_USTRINGPARAM( "RealFilterName" ) );
+
+ // get access to config
+ Reference< XNameAccess > xTypeAccess ( openConfig("types" ), UNO_QUERY );
+ Reference< XNameAccess > xFilterAccess( openConfig("filters"), UNO_QUERY );
+
+ if ( xTypeAccess.is() && xFilterAccess.is() )
+ {
+ Sequence< OUString > lAllFilter = xFilterAccess->getElementNames();
+ sal_Int32 nAllFilterCount = lAllFilter.getLength();
+
+ for ( sal_Int32 i = 0; i < nAllFilterCount; i++ )
+ {
+ OUString sInternalFilterName = lAllFilter[ i ];
+ Reference< XPropertySet > xFilterSet;
+ xFilterAccess->getByName( sInternalFilterName ) >>= xFilterSet;
+ if (!xFilterSet.is())
+ continue;
+
+ FilterConfigCacheEntry aEntry;
+
+ aEntry.sInternalFilterName = sInternalFilterName;
+ xFilterSet->getPropertyValue(STYPE) >>= aEntry.sType;
+ xFilterSet->getPropertyValue(SUINAME) >>= aEntry.sUIName;
+ xFilterSet->getPropertyValue(SREALFILTERNAME) >>= aEntry.sFilterType;
+ Sequence< OUString > lFlags;
+ xFilterSet->getPropertyValue(SFLAGS) >>= lFlags;
+ if (lFlags.getLength()!=1 || !lFlags[0].getLength())
+ continue;
+ if (lFlags[0].equalsIgnoreAsciiCaseAscii("import"))
+ aEntry.nFlags = 1;
+ else
+ if (lFlags[0].equalsIgnoreAsciiCaseAscii("export"))
+ aEntry.nFlags = 2;
+
+ OUString sUIComponent;
+ xFilterSet->getPropertyValue(SUICOMPONENT) >>= sUIComponent;
+ aEntry.bHasDialog = sUIComponent.getLength();
+
+ ::rtl::OUString sFormatName;
+ xFilterSet->getPropertyValue(SFORMATNAME) >>= sFormatName;
+ aEntry.CreateFilterName( sFormatName );
+
+ Reference< XPropertySet > xTypeSet;
+ xTypeAccess->getByName( aEntry.sType ) >>= xTypeSet;
+ if (!xTypeSet.is())
+ continue;
+
+ xTypeSet->getPropertyValue(SMEDIATYPE) >>= aEntry.sMediaType;
+ xTypeSet->getPropertyValue(SEXTENSIONS) >>= aEntry.lExtensionList;
+
+ // The first extension will be used
+ // to generate our internal FilterType ( BMP, WMF ... )
+ String aExtension( aEntry.GetShortName() );
+ if (aExtension.Len() != 3)
+ continue;
+
+ if ( aEntry.nFlags & 1 )
+ aImport.push_back( aEntry );
+ if ( aEntry.nFlags & 2 )
+ aExport.push_back( aEntry );
+
+ // bFilterEntryCreated!?
+ if (!( aEntry.nFlags & 3 ))
+ continue; //? Entry was already inserted ... but following code will be supressed?!
+ }
+ }
+};
+
+const char* FilterConfigCache::InternalFilterListForSvxLight[] =
+{
+ "bmp","1","SVBMP",
+ "bmp","2","SVBMP",
+ "dxf","1","idx",
+ "eps","1","ips",
+ "eps","2","eps",
+ "gif","1","SVIGIF",
+ "gif","2","egi",
+ "jpg","1","SVIJPEG",
+ "jpg","2","SVEJPEG",
+ "sgv","1","SVSGV",
+ "sgf","1","SVSGF",
+ "met","1","ime",
+ "met","2","eme",
+ "png","1","SVIPNG",
+ "png","2","SVEPNG",
+ "pct","1","ipt",
+ "pct","2","ept",
+ "pcd","1","icd",
+ "psd","1","ipd",
+ "pcx","1","ipx",
+ "pbm","1","ipb",
+ "pbm","2","epb",
+ "pgm","1","ipb",
+ "pgm","2","epg",
+ "ppm","1","ipb",
+ "ppm","2","epp",
+ "ras","1","ira",
+ "ras","2","era",
+ "svm","1","SVMETAFILE",
+ "svm","2","SVMETAFILE",
+ "tga","1","itg",
+ "tif","1","iti",
+ "tif","2","eti",
+ "emf","1","SVEMF",
+ "emf","2","SVEMF",
+ "wmf","1","SVWMF",
+ "wmf","2","SVWMF",
+ "xbm","1","SVIXBM",
+ "xpm","1","SVIXPM",
+ "xpm","2","exp",
+ "svg","2","SVESVG",
+ NULL
+};
+
+void FilterConfigCache::ImplInitSmart()
+{
+ const char** pPtr;
+ for ( pPtr = InternalFilterListForSvxLight; *pPtr; pPtr++ )
+ {
+ FilterConfigCacheEntry aEntry;
+
+ OUString sExtension( OUString::createFromAscii( *pPtr++ ) );
+
+ aEntry.lExtensionList.realloc( 1 );
+ aEntry.lExtensionList[ 0 ] = sExtension;
+
+ aEntry.sType = sExtension;
+ aEntry.sUIName = sExtension;
+
+ ByteString sFlags( *pPtr++ );
+ aEntry.nFlags = sFlags.ToInt32();
+
+ OUString sUserData( OUString::createFromAscii( *pPtr ) );
+ aEntry.CreateFilterName( sUserData );
+
+ if ( aEntry.nFlags & 1 )
+ aImport.push_back( aEntry );
+ if ( aEntry.nFlags & 2 )
+ aExport.push_back( aEntry );
+ }
+}
+
+// ------------------------------------------------------------------------
+
+FilterConfigCache::FilterConfigCache( sal_Bool bConfig ) :
+ bUseConfig ( bConfig )
+{
+ if ( bUseConfig )
+ ImplInit();
+ else
+ ImplInitSmart();
+}
+
+FilterConfigCache::~FilterConfigCache()
+{
+
+}
+
+String FilterConfigCache::GetImportFilterName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ return ( aIter < aImport.end() ) ? aIter->sFilterName : String();
+}
+
+sal_uInt16 FilterConfigCache::GetImportFormatNumber( const String& rFormatName )
+{
+ CacheVector::iterator aIter( aImport.begin() );
+ while ( aIter != aImport.end() )
+ {
+ if ( aIter->sUIName.equalsIgnoreAsciiCase( rFormatName ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
+}
+
+sal_uInt16 FilterConfigCache::GetImportFormatNumberForMediaType( const String& rMediaType )
+{
+ CacheVector::iterator aIter( aImport.begin() );
+ while ( aIter != aImport.end() )
+ {
+ if ( aIter->sMediaType.equalsIgnoreAsciiCase( rMediaType ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
+}
+
+sal_uInt16 FilterConfigCache::GetImportFormatNumberForShortName( const String& rShortName )
+{
+ CacheVector::iterator aIter( aImport.begin() );
+ while ( aIter != aImport.end() )
+ {
+ if ( aIter->GetShortName().EqualsIgnoreCaseAscii( rShortName ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
+}
+
+sal_uInt16 FilterConfigCache::GetImportFormatNumberForTypeName( const String& rType )
+{
+ CacheVector::iterator aIter( aImport.begin() );
+ while ( aIter != aImport.end() )
+ {
+ if ( aIter->sType.equalsIgnoreAsciiCase( rType ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
+}
+
+String FilterConfigCache::GetImportFormatName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ String aUIName;
+ if ( aIter < aImport.end() )
+ aUIName = aIter->sUIName;
+ return aUIName;
+}
+
+String FilterConfigCache::GetImportFormatMediaType( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ String aMediaType;
+ if ( aIter < aImport.end() )
+ aMediaType = aIter->sMediaType;
+ return aMediaType;
+}
+
+String FilterConfigCache::GetImportFormatShortName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ String aType;
+ if ( aIter < aImport.end() )
+ aType = aIter->GetShortName();
+ aType.ToUpperAscii();
+ return aType;
+}
+
+String FilterConfigCache::GetImportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ String aExtension;
+ if ( aIter < aImport.end() )
+ {
+ if ( nEntry < aIter->lExtensionList.getLength() )
+ aExtension = aIter->lExtensionList[ nEntry ];
+ }
+ return aExtension;
+}
+
+String FilterConfigCache::GetImportFilterType( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ String aType;
+ if ( aIter < aImport.end() )
+ aType = aIter->sType;
+ return aType;
+}
+
+String FilterConfigCache::GetImportFilterTypeName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ String aFilterType;
+ if ( aIter < aImport.end() )
+ aFilterType = aIter->sFilterType;
+ return aFilterType;
+}
+
+String FilterConfigCache::GetImportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry )
+{
+ String aWildcard( GetImportFormatExtension( nFormat, nEntry ) );
+ if ( aWildcard.Len() )
+ aWildcard.Insert( UniString::CreateFromAscii( "*.", 2 ), 0 );
+ return aWildcard;
+}
+
+sal_Bool FilterConfigCache::IsImportInternalFilter( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ return ( aIter < aImport.end() ) ? aIter->bIsInternalFilter != 0 : sal_False;
+}
+
+sal_Bool FilterConfigCache::IsImportPixelFormat( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aImport.begin() + nFormat );
+ return ( aIter < aImport.end() ) ? aIter->bIsPixelFormat != 0 : sal_False;
+}
+
+// ------------------------------------------------------------------------
+
+String FilterConfigCache::GetExportFilterName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ return ( aIter < aExport.end() ) ? aIter->sFilterName : String();
+}
+
+sal_uInt16 FilterConfigCache::GetExportFormatNumber( const String& rFormatName )
+{
+ CacheVector::iterator aIter( aExport.begin() );
+ while ( aIter != aExport.end() )
+ {
+ if ( aIter->sUIName.equalsIgnoreAsciiCase( rFormatName ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
+}
+
+sal_uInt16 FilterConfigCache::GetExportFormatNumberForMediaType( const String& rMediaType )
+{
+ CacheVector::iterator aIter( aExport.begin() );
+ while ( aIter != aExport.end() )
+ {
+ if ( aIter->sMediaType.equalsIgnoreAsciiCase( rMediaType ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
+}
+
+sal_uInt16 FilterConfigCache::GetExportFormatNumberForShortName( const String& rShortName )
+{
+ CacheVector::iterator aIter( aExport.begin() );
+ while ( aIter != aExport.end() )
+ {
+ if ( aIter->GetShortName().EqualsIgnoreCaseAscii( rShortName ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
+}
+
+sal_uInt16 FilterConfigCache::GetExportFormatNumberForTypeName( const String& rType )
+{
+ CacheVector::iterator aIter( aExport.begin() );
+ while ( aIter != aExport.end() )
+ {
+ if ( aIter->sType.equalsIgnoreAsciiCase( rType ) )
+ break;
+ aIter++;
+ }
+ return sal::static_int_cast< sal_uInt16 >(aIter == aExport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aExport.begin());
+}
+
+String FilterConfigCache::GetExportFormatName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ String aUIName;
+ if ( aIter < aExport.end() )
+ aUIName = aIter->sUIName;
+ return aUIName;
+}
+
+String FilterConfigCache::GetExportFormatMediaType( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ String aMediaType;
+ if ( aIter < aExport.end() )
+ aMediaType = aIter->sMediaType;
+ return aMediaType;
+}
+
+String FilterConfigCache::GetExportFormatShortName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ String aType;
+ if ( aIter < aExport.end() )
+ aType = aIter->GetShortName();
+ aType.ToUpperAscii();
+ return aType;
+}
+
+String FilterConfigCache::GetExportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ String aExtension;
+ if ( aIter < aExport.end() )
+ {
+ if ( nEntry < aIter->lExtensionList.getLength() )
+ aExtension = aIter->lExtensionList[ nEntry ];
+ }
+ return aExtension;
+}
+
+String FilterConfigCache::GetExportFilterTypeName( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ String aFilterType;
+ if ( aIter < aExport.end() )
+ aFilterType = aIter->sFilterType;
+ return aFilterType;
+}
+
+String FilterConfigCache::GetExportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry )
+{
+ String aWildcard( GetExportFormatExtension( nFormat, nEntry ) );
+ if ( aWildcard.Len() )
+ aWildcard.Insert( UniString::CreateFromAscii( "*.", 2 ), 0 );
+ return aWildcard;
+}
+
+sal_Bool FilterConfigCache::IsExportInternalFilter( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ return ( aIter < aExport.end() ) ? aIter->bIsInternalFilter != 0 : sal_False;
+}
+
+sal_Bool FilterConfigCache::IsExportPixelFormat( sal_uInt16 nFormat )
+{
+ CacheVector::iterator aIter( aExport.begin() + nFormat );
+ return ( aIter < aExport.end() ) ? aIter->bIsPixelFormat != 0 : sal_False;
+}
+
+
+// ------------------------------------------------------------------------
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigItem.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigItem.cxx
new file mode 100644
index 000000000000..1f211613ebc7
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_FilterConfigItem.cxx
@@ -0,0 +1,383 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <tools/string.hxx>
+#include <bf_svtools/FilterConfigItem.hxx>
+#include <tools/debug.hxx>
+#include <unotools/configmgr.hxx>
+#include <unotools/processfactory.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+
+using namespace ::rtl;
+using namespace ::utl ; // getProcessServiceFactory
+using namespace ::com::sun::star::lang ; // XMultiServiceFactory
+using namespace ::com::sun::star::beans ; // PropertyValue
+using namespace ::com::sun::star::uno ; // Reference
+using namespace ::com::sun::star::util ; // XChangesBatch
+using namespace ::com::sun::star::awt ; // Size
+using namespace ::com::sun::star::container ; //
+using namespace ::com::sun::star::task ; // XStatusIndicator
+
+namespace binfilter
+{
+
+static sal_Bool ImpIsTreeAvailable( Reference< XMultiServiceFactory >& rXCfgProv, const String& rTree )
+{
+ sal_Bool bAvailable = rTree.Len() != 0;
+ if ( bAvailable )
+ {
+ xub_StrLen nTokenCount = rTree.GetTokenCount( (sal_Unicode)'/' );
+ xub_StrLen i = 0;
+
+ if ( rTree.GetChar( 0 ) == (sal_Unicode)'/' )
+ i++;
+ if ( rTree.GetChar( rTree.Len() - 1 ) == (sal_Unicode)'/' )
+ nTokenCount--;
+
+ Any aAny;
+ aAny <<= (OUString)rTree.GetToken( i++, (sal_Unicode)'/' );
+
+ // creation arguments: nodepath
+ PropertyValue aPathArgument;
+ aPathArgument.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) );
+ aPathArgument.Value = aAny;
+
+ Sequence< Any > aArguments( 1 );
+ aArguments[ 0 ] <<= aPathArgument;
+
+ Reference< XInterface > xReadAccess;
+ try
+ {
+ xReadAccess = rXCfgProv->createInstanceWithArguments(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" ) ),
+ aArguments );
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ bAvailable = sal_False;
+ }
+ if ( xReadAccess.is() )
+ {
+ for ( ; bAvailable && ( i < nTokenCount ); i++ )
+ {
+ Reference< XHierarchicalNameAccess > xHierarchicalNameAccess
+ ( xReadAccess, UNO_QUERY );
+
+ if ( !xHierarchicalNameAccess.is() )
+ bAvailable = sal_False;
+ else
+ {
+ String aNode( rTree.GetToken( i, (sal_Unicode)'/' ) );
+ if ( !xHierarchicalNameAccess->hasByHierarchicalName( aNode ) )
+ bAvailable = sal_False;
+ else
+ {
+ Any a( xHierarchicalNameAccess->getByHierarchicalName( aNode ) );
+ try
+ {
+ a >>= xReadAccess;
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ bAvailable = sal_False;
+ }
+ }
+ }
+ }
+ }
+ }
+ return bAvailable;
+}
+
+void FilterConfigItem::ImpInitTree( const String& rSubTree )
+{
+ bModified = sal_False;
+
+ OUString sTree( ConfigManager::GetConfigBaseURL() );
+ sTree += rSubTree;
+ Reference< XMultiServiceFactory > xSMGR = getProcessServiceFactory(); // get global uno service manager
+
+ Reference< XMultiServiceFactory > xCfgProv(
+ xSMGR->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ) ),
+ UNO_QUERY );
+
+ if ( xCfgProv.is() )
+ {
+ if ( ImpIsTreeAvailable( xCfgProv, String( sTree ) ) )
+ {
+ Any aAny;
+ // creation arguments: nodepath
+ PropertyValue aPathArgument;
+ aAny <<= sTree;
+ aPathArgument.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) );
+ aPathArgument.Value = aAny;
+
+ // creation arguments: commit mode
+ PropertyValue aModeArgument;
+ sal_Bool bAsyncron = sal_True;
+ aAny <<= bAsyncron;
+ aModeArgument.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "lazywrite" ) );
+ aModeArgument.Value = aAny;
+
+ Sequence< Any > aArguments( 2 );
+ aArguments[ 0 ] <<= aPathArgument;
+ aArguments[ 1 ] <<= aModeArgument;
+
+ try
+ {
+ xUpdatableView = xCfgProv->createInstanceWithArguments(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ),
+ aArguments );
+ if ( xUpdatableView.is() )
+ xPropSet = Reference< XPropertySet >( xUpdatableView, UNO_QUERY );
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ DBG_ERROR( "FilterConfigItem::FilterConfigItem - Could not access configuration Key" );
+ }
+ }
+ }
+}
+
+FilterConfigItem::FilterConfigItem( const OUString& rSubTree )
+{
+ ImpInitTree( rSubTree );
+}
+
+FilterConfigItem::FilterConfigItem( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >* pFilterData )
+{
+ if ( pFilterData )
+ aFilterData = *pFilterData;
+}
+
+FilterConfigItem::~FilterConfigItem()
+{
+ if ( xUpdatableView.is() )
+ {
+ if ( xPropSet.is() && bModified )
+ {
+ Reference< XChangesBatch > xUpdateControl( xUpdatableView, UNO_QUERY );
+ if ( xUpdateControl.is() )
+ {
+ try
+ {
+ xUpdateControl->commitChanges();
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ DBG_ERROR( "FilterConfigItem::FilterConfigItem - Could not update configuration data" );
+ }
+ }
+ }
+ }
+}
+
+sal_Bool FilterConfigItem::ImplGetPropertyValue( Any& rAny, const Reference< XPropertySet >& rXPropSet, const OUString& rString, sal_Bool bTestPropertyAvailability )
+{
+ sal_Bool bRetValue = sal_True;
+
+ if ( rXPropSet.is() )
+ {
+ if ( bTestPropertyAvailability )
+ {
+ bRetValue = sal_False;
+ try
+ {
+ Reference< XPropertySetInfo >
+ aXPropSetInfo( rXPropSet->getPropertySetInfo() );
+ if ( aXPropSetInfo.is() )
+ bRetValue = aXPropSetInfo->hasPropertyByName( rString );
+ }
+ catch( ::com::sun::star::uno::Exception& )
+ {
+ //
+ }
+ }
+ if ( bRetValue )
+ {
+ try
+ {
+ rAny = rXPropSet->getPropertyValue( rString );
+ if ( !rAny.hasValue() )
+ bRetValue = sal_False;
+ }
+ catch( ::com::sun::star::uno::Exception& )
+ {
+ bRetValue = sal_False;
+ }
+ }
+ }
+ else
+ bRetValue = sal_False;
+ return bRetValue;
+}
+
+
+// if property is available it returns a pointer,
+// otherwise the result is null
+PropertyValue* FilterConfigItem::GetPropertyValue( Sequence< PropertyValue >& rPropSeq, const OUString& rName )
+{
+ PropertyValue* pPropValue = NULL;
+
+ sal_Int32 i, nCount;
+ for ( i = 0, nCount = rPropSeq.getLength(); i < nCount; i++ )
+ {
+ if ( rPropSeq[ i ].Name == rName )
+ {
+ pPropValue = &rPropSeq[ i ];
+ break;
+ }
+ }
+ return pPropValue;
+}
+
+/* if PropertySequence already includes a PropertyValue using the same name, the
+ corresponding PropertyValue is replaced, otherwise the given PropertyValue
+ will be appended */
+
+sal_Bool FilterConfigItem::WritePropertyValue( Sequence< PropertyValue >& rPropSeq, const PropertyValue& rPropValue )
+{
+ sal_Bool bRet = sal_False;
+ if ( rPropValue.Name.getLength() )
+ {
+ sal_Int32 i, nCount;
+ for ( i = 0, nCount = rPropSeq.getLength(); i < nCount; i++ )
+ {
+ if ( rPropSeq[ i ].Name == rPropValue.Name )
+ break;
+ }
+ if ( i == nCount )
+ rPropSeq.realloc( ++nCount );
+
+ rPropSeq[ i ] = rPropValue;
+
+ bRet = sal_True;
+ }
+ return bRet;
+}
+
+sal_Bool FilterConfigItem::ReadBool( const OUString& rKey, sal_Bool bDefault )
+{
+ Any aAny;
+ sal_Bool bRetValue = bDefault;
+ PropertyValue* pPropVal = GetPropertyValue( aFilterData, rKey );
+ if ( pPropVal )
+ {
+ pPropVal->Value >>= bRetValue;
+ }
+ else if ( ImplGetPropertyValue( aAny, xPropSet, rKey, sal_True ) )
+ {
+ aAny >>= bRetValue;
+ }
+ PropertyValue aBool;
+ aBool.Name = rKey;
+ aBool.Value <<= bRetValue;
+ WritePropertyValue( aFilterData, aBool );
+ return bRetValue;
+}
+
+sal_Int32 FilterConfigItem::ReadInt32( const OUString& rKey, sal_Int32 nDefault )
+{
+ Any aAny;
+ sal_Int32 nRetValue = nDefault;
+ PropertyValue* pPropVal = GetPropertyValue( aFilterData, rKey );
+ if ( pPropVal )
+ {
+ pPropVal->Value >>= nRetValue;
+ }
+ else if ( ImplGetPropertyValue( aAny, xPropSet, rKey, sal_True ) )
+ {
+ aAny >>= nRetValue;
+ }
+ PropertyValue aInt32;
+ aInt32.Name = rKey;
+ aInt32.Value <<= nRetValue;
+ WritePropertyValue( aFilterData, aInt32 );
+ return nRetValue;
+}
+
+void FilterConfigItem::WriteInt32( const OUString& rKey, sal_Int32 nNewValue )
+{
+ PropertyValue aInt32;
+ aInt32.Name = rKey;
+ aInt32.Value <<= nNewValue;
+ WritePropertyValue( aFilterData, aInt32 );
+
+ if ( xPropSet.is() )
+ {
+ Any aAny;
+
+ if ( ImplGetPropertyValue( aAny, xPropSet, rKey, sal_True ) )
+ {
+ sal_Int32 nOldValue;
+ if ( aAny >>= nOldValue )
+ {
+ if ( nOldValue != nNewValue )
+ {
+ aAny <<= nNewValue;
+ try
+ {
+ xPropSet->setPropertyValue( rKey, aAny );
+ bModified = sal_True;
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ DBG_ERROR( "FilterConfigItem::WriteInt32 - could not set PropertyValue" );
+ }
+ }
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+Reference< XStatusIndicator > FilterConfigItem::GetStatusIndicator() const
+{
+ Reference< XStatusIndicator > xStatusIndicator;
+ const rtl::OUString sStatusIndicator( RTL_CONSTASCII_USTRINGPARAM( "StatusIndicator" ) );
+
+ sal_Int32 i, nCount = aFilterData.getLength();
+ for ( i = 0; i < nCount; i++ )
+ {
+ if ( aFilterData[ i ].Name == sStatusIndicator )
+ {
+ aFilterData[ i ].Value >>= xStatusIndicator;
+ break;
+ }
+ }
+ return xStatusIndicator;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_filter.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_filter.cxx
new file mode 100644
index 000000000000..12766aa131fc
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_filter.cxx
@@ -0,0 +1,2019 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+
+#if defined UNX && defined ALPHA
+#include <fstream.hxx>
+#endif
+#include <osl/mutex.hxx>
+#include <comphelper/processfactory.hxx>
+#include <ucbhelper/content.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/salctype.hxx>
+#include <vcl/pngread.hxx>
+#include <vcl/pngwrite.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/file.hxx>
+#include <bf_svtools/filter.hxx>
+#include "FilterConfigCache.hxx"
+#include <bf_svtools/FilterConfigItem.hxx>
+#include <bf_svtools/fltcall.hxx>
+#include <bf_svtools/wmf.hxx>
+#include "gifread.hxx"
+#include "jpeg.hxx"
+#include "xbmread.hxx"
+#include "xpmread.hxx"
+#include <bf_svtools/solar.hrc>
+#include "sgffilt.hxx"
+#include "osl/module.hxx"
+
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/XWeak.hpp>
+#include <com/sun/star/uno/XAggregation.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/svg/XSVGWriter.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/ucb/CommandAbortedException.hpp>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/localfilehelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <rtl/bootstrap.hxx>
+#include <rtl/instance.hxx>
+
+#define PMGCHUNG_msOG 0x6d734f47 // Microsoft Office Animated GIF
+
+#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
+#ifdef _MSC_VER
+#pragma optimize( "", off )
+#endif
+
+// -----------
+// - statics -
+// -----------
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+namespace binfilter
+{
+
+static List* pFilterHdlList = NULL;
+
+static ::osl::Mutex& getListMutex()
+{
+ static ::osl::Mutex s_aListProtection;
+ return s_aListProtection;
+}
+
+static GraphicFilter* pGraphicFilter=0;
+
+// -------------------------
+// - 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 ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) { mrStm.Write( rData.getConstArray(), rData.getLength() ); }
+ virtual void SAL_CALL flush() throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) { mrStm.Flush(); }
+ virtual void SAL_CALL closeOutput() throw() {}
+
+public:
+
+ ImpFilterOutputStream( SvStream& rStm ) : mrStm( rStm ) {}
+ ~ImpFilterOutputStream() {}
+};
+
+BOOL ImplDirEntryHelper::Exists( const INetURLObject& rObj )
+{
+ BOOL bExists = FALSE;
+
+ try
+ {
+ ::rtl::OUString aTitle;
+ ::ucbhelper::Content aCnt( rObj.GetMainURL( INetURLObject::NO_DECODE ),
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
+
+ bExists = aCnt.isDocument();
+ }
+ catch( ::com::sun::star::ucb::CommandAbortedException& )
+ {
+ DBG_ERRORFILE( "CommandAbortedException" );
+ }
+ catch( ::com::sun::star::ucb::ContentCreationException& )
+ {
+ DBG_ERRORFILE( "ContentCreationException" );
+ }
+ catch( ... )
+ {
+// DBG_ERRORFILE( "Any other exception" );
+ }
+ return bExists;
+}
+
+// -----------------------------------------------------------------------------
+
+void ImplDirEntryHelper::Kill( const String& rMainUrl )
+{
+ try
+ {
+ ::ucbhelper::Content aCnt( rMainUrl,
+ ::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" );
+ }
+}
+
+// --------------------
+// - Helper functions -
+// --------------------
+
+//--------------------------------------------------------------------------
+
+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 ImpGetExtension( const String &rPath )
+{
+ String aExt;
+ INetURLObject aURL( rPath );
+ aExt = aURL.GetFileExtension().toAsciiUpperCase();
+ 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 );
+
+ if ( !nStreamLen )
+ {
+ SvLockBytes* pLockBytes = rStream.GetLockBytes();
+ if ( pLockBytes )
+ pLockBytes->SetSynchronMode( TRUE );
+
+ rStream.Seek( STREAM_SEEK_TO_END );
+ 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[0]==0x56 && sFirstBytes[1]==0x43 && sFirstBytes[2]==0x4C &&
+ sFirstBytes[3]==0x4D && sFirstBytes[4]==0x54 && sFirstBytes[5]==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;
+ BYTE sBuf[4];
+ sal_uInt32 nOffset; // in ms documents the pict format is used without the first 512 bytes
+ for ( nOffset = 10; ( nOffset <= 522 ) && ( ( nStreamPos + nOffset + 3 ) <= nStreamLen ); 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;
+ }
+
+ //--------------------------- SGF ------------------------------------
+ if( !bTest || ( rFormatExtension.CompareToAscii( "SGF", 3 ) == COMPARE_EQUAL ) )
+ {
+ bSomethingTested=TRUE;
+ if( sFirstBytes[ 0 ] == 'J' && sFirstBytes[ 1 ] == 'J' )
+ {
+ rFormatExtension = UniString::CreateFromAscii( "SGF", 3 );
+ return TRUE;
+ }
+ }
+
+ return bTest && !bSomethingTested;
+}
+
+//--------------------------------------------------------------------------
+
+sal_uInt16 GraphicFilter::ImpTestOrFindFormat( const String& rPath, SvStream& rStream, sal_uInt16& rFormat )
+{
+ sal_uInt16 n = pConfig->GetImportFormatCount();
+
+ // ggf. Filter bzw. Format durch anlesen ermitteln,
+ // oder durch anlesen zusichern, dass das Format stimmt:
+ if( rFormat == GRFILTER_FORMAT_DONTKNOW )
+ {
+ String aFormatExt;
+ if( ImpPeekGraphicFormat( rStream, aFormatExt, FALSE ) )
+ {
+ for( sal_uInt16 i = 0; i < n; i++ )
+ {
+ if( pConfig->GetImportFormatExtension( i ).EqualsIgnoreCaseAscii( aFormatExt ) )
+ {
+ rFormat = i;
+ return GRFILTER_OK;
+ }
+ }
+ }
+ // ggf. Filter anhand der Datei-Endung raussuchen:
+ if( rPath.Len() )
+ {
+ String aExt( ImpGetExtension( rPath ) );
+ for( sal_uInt16 i = 0; i < n; i++ )
+ {
+ if( pConfig->GetImportFormatExtension( i ).EqualsIgnoreCaseAscii( aExt ) )
+ {
+ rFormat = i;
+ return GRFILTER_OK;
+ }
+ }
+ }
+ return GRFILTER_FORMATERROR;
+ }
+ else
+ {
+ String aTmpStr( pConfig->GetImportFormatExtension( rFormat ) );
+ if( !ImpPeekGraphicFormat( rStream, aTmpStr, TRUE ) )
+ return GRFILTER_FORMATERROR;
+ if ( pConfig->GetImportFormatExtension( rFormat ).EqualsIgnoreCaseAscii( "pcd" ) )
+ {
+ sal_Int32 nBase = 2; // default Base0
+ if ( pConfig->GetImportFilterType( rFormat ).EqualsIgnoreCaseAscii( "pcd_Photo_CD_Base4" ) )
+ nBase = 1;
+ else if ( pConfig->GetImportFilterType( rFormat ).EqualsIgnoreCaseAscii( "pcd_Photo_CD_Base16" ) )
+ nBase = 0;
+ String aFilterConfigPath( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/Graphic/Import/PCD" ) );
+ FilterConfigItem aFilterConfigItem( aFilterConfigPath );
+ aFilterConfigItem.WriteInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Resolution" ) ), nBase );
+ }
+ }
+
+ return GRFILTER_OK;
+}
+
+//--------------------------------------------------------------------------
+
+static Graphic ImpGetScaledGraphic( const Graphic& rGraphic, FilterConfigItem& rConfigItem )
+{
+ Graphic aGraphic;
+
+ sal_Int32 nLogicalWidth = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "LogicalWidth" ) ), 0 );
+ sal_Int32 nLogicalHeight = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "LogicalHeight" ) ), 0 );
+
+ if ( rGraphic.GetType() != GRAPHIC_NONE )
+ {
+ sal_Int32 nMode = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "ExportMode" ) ), -1 );
+
+ if ( nMode == -1 ) // the property is not there, this is possible, if the graphic filter
+ { // is called via UnoGraphicExporter and not from a graphic export Dialog
+ nMode = 0; // then we are defaulting this mode to 0
+ if ( nLogicalWidth || nLogicalHeight )
+ nMode = 2;
+ }
+
+
+ Size aOriginalSize;
+ Size aPrefSize( rGraphic.GetPrefSize() );
+ MapMode aPrefMapMode( rGraphic.GetPrefMapMode() );
+ if ( aPrefMapMode == MAP_PIXEL )
+ aOriginalSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_100TH_MM );
+ else
+ aOriginalSize = Application::GetDefaultDevice()->LogicToLogic( aPrefSize, aPrefMapMode, MAP_100TH_MM );
+ if ( !nLogicalWidth )
+ nLogicalWidth = aOriginalSize.Width();
+ if ( !nLogicalHeight )
+ nLogicalHeight = aOriginalSize.Height();
+ if( rGraphic.GetType() == GRAPHIC_BITMAP )
+ {
+
+ // Aufloesung wird eingestellt
+ if( nMode == 1 )
+ {
+ Bitmap aBitmap( rGraphic.GetBitmap() );
+ MapMode aMap( MAP_100TH_INCH );
+
+ sal_Int32 nDPI = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Resolution" ) ), 75 );
+ Fraction aFrac( 1, Min( Max( nDPI, sal_Int32( 75 ) ), sal_Int32( 600 ) ) );
+
+ 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 )
+ {
+ BitmapEx aBitmapEx( rGraphic.GetBitmapEx() );
+ aBitmapEx.SetPrefMapMode( MapMode( MAP_100TH_MM ) );
+ aBitmapEx.SetPrefSize( Size( nLogicalWidth, nLogicalHeight ) );
+ aGraphic = Graphic( aBitmapEx );
+ }
+ else
+ aGraphic = rGraphic;
+
+ sal_Int32 nColors = rConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Color" ) ), 0 ); // #92767#
+ if ( nColors ) // graphic conversion necessary ?
+ {
+ BitmapEx aBmpEx( aGraphic.GetBitmapEx() );
+ aBmpEx.Convert( (BmpConversion)nColors ); // the entries in the xml section have the same meaning as
+ aGraphic = aBmpEx; // they have in the BmpConversion enum, so it should be
+ } // allowed to cast them
+ }
+ else
+ {
+ if( ( nMode == 1 ) || ( nMode == 2 ) )
+ {
+ GDIMetaFile aMtf( rGraphic.GetGDIMetaFile() );
+ ::com::sun::star::awt::Size aDefaultSize( 10000, 10000 );
+ Size aNewSize( OutputDevice::LogicToLogic( Size( nLogicalWidth, nLogicalHeight ), MAP_100TH_MM, aMtf.GetPrefMapMode() ) );
+
+ if( aNewSize.Width() && aNewSize.Height() )
+ {
+ const Size aPreferredSize( aMtf.GetPrefSize() );
+ aMtf.Scale( Fraction( aNewSize.Width(), aPreferredSize.Width() ),
+ Fraction( aNewSize.Height(), aPreferredSize.Height() ) );
+ }
+ aGraphic = Graphic( aMtf );
+ }
+ else
+ aGraphic = rGraphic;
+ }
+
+ }
+ else
+ aGraphic = rGraphic;
+
+ return aGraphic;
+}
+
+static String ImpCreateFullFilterPath( const String& rPath, const String& rFilterName )
+{
+ ::rtl::OUString aPathURL;
+
+ ::osl::FileBase::getFileURLFromSystemPath( rPath, aPathURL );
+ aPathURL += String( '/' );
+
+ ::rtl::OUString aSystemPath;
+ ::osl::FileBase::getSystemPathFromFileURL( aPathURL, aSystemPath );
+ aSystemPath += ::rtl::OUString( rFilterName );
+
+ return String( aSystemPath );
+}
+
+
+// --------------------------
+// - ImpFilterLibCacheEntry -
+// --------------------------
+
+class ImpFilterLibCache;
+
+struct ImpFilterLibCacheEntry
+{
+ ImpFilterLibCacheEntry* mpNext;
+ osl::Module 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.getFunctionSymbol( UniString::CreateFromAscii( EXPORT_FUNCTION_NAME ) ); }
+ PFilterDlgCall GetExportDlgFunction() { return (PFilterDlgCall) maLibrary.getFunctionSymbol( 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.getFunctionSymbol( UniString::CreateFromAscii( IMPORT_FUNCTION_NAME ) );
+
+ return mpfnImport;
+}
+
+// ------------------------------------------------------------------------
+
+PFilterDlgCall ImpFilterLibCacheEntry::GetImportDlgFunction()
+{
+ if( !mpfnImportDlg )
+ mpfnImportDlg = (PFilterDlgCall)maLibrary.getFunctionSymbol( UniString::CreateFromAscii( IMPDLG_FUNCTION_NAME ) );
+
+ return mpfnImportDlg;
+}
+
+// ---------------------
+// - ImpFilterLibCache -
+// ---------------------
+
+class ImpFilterLibCache
+{
+ ImpFilterLibCacheEntry* mpFirst;
+ ImpFilterLibCacheEntry* mpLast;
+
+public:
+ ImpFilterLibCache();
+ ~ImpFilterLibCache();
+
+ ImpFilterLibCacheEntry* GetFilter( const String& rFilterPath, const String& rFiltername );
+};
+
+// ------------------------------------------------------------------------
+
+ImpFilterLibCache::ImpFilterLibCache() :
+ mpFirst ( NULL ),
+ mpLast ( NULL )
+{
+}
+
+// ------------------------------------------------------------------------
+
+ImpFilterLibCache::~ImpFilterLibCache()
+{
+ ImpFilterLibCacheEntry* pEntry = mpFirst;
+ while( pEntry )
+ {
+ ImpFilterLibCacheEntry* pNext = pEntry->mpNext;
+ delete pEntry;
+ pEntry = pNext;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+ImpFilterLibCacheEntry* ImpFilterLibCache::GetFilter( const String& rFilterPath, const String& rFilterName )
+{
+ ImpFilterLibCacheEntry* pEntry = mpFirst;
+
+ while( pEntry )
+ {
+ if( *pEntry == rFilterName )
+ break;
+ else
+ pEntry = pEntry->mpNext;
+ }
+ if( !pEntry )
+ {
+ String aPhysicalName( ImpCreateFullFilterPath( rFilterPath, rFilterName ) );
+ pEntry = new ImpFilterLibCacheEntry( aPhysicalName, rFilterName );
+
+ if ( pEntry->maLibrary.is() )
+ {
+ if( !mpFirst )
+ mpFirst = mpLast = pEntry;
+ else
+ mpLast = mpLast->mpNext = pEntry;
+ }
+ else
+ {
+ delete pEntry;
+ pEntry = NULL;
+ }
+ }
+ return pEntry;
+};
+
+// ------------------------------------------------------------------------
+
+namespace { struct Cache : public rtl::Static<ImpFilterLibCache, Cache> {}; }
+
+// -----------------
+// - GraphicFilter -
+// -----------------
+
+GraphicFilter::GraphicFilter( sal_Bool bConfig ) :
+ bUseConfig ( bConfig )
+{
+ ImplInit();
+}
+
+// ------------------------------------------------------------------------
+
+GraphicFilter::~GraphicFilter()
+{
+ {
+ ::osl::MutexGuard aGuard( getListMutex() );
+ pFilterHdlList->Remove( (void*)this );
+ if ( !pFilterHdlList->Count() )
+ {
+ delete pFilterHdlList, pFilterHdlList = NULL;
+ delete pConfig;
+ }
+ }
+
+
+ delete pErrorEx;
+}
+
+// ------------------------------------------------------------------------
+
+void GraphicFilter::ImplInit()
+{
+ {
+ ::osl::MutexGuard aGuard( getListMutex() );
+
+ if ( !pFilterHdlList )
+ {
+ pFilterHdlList = new List;
+ pConfig = new FilterConfigCache( bUseConfig );
+ }
+ else
+ pConfig = ((GraphicFilter*)pFilterHdlList->First())->pConfig;
+
+ pFilterHdlList->Insert( (void*)this );
+ }
+
+ if( bUseConfig )
+ {
+#if defined WNT
+ rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM("BRAND_BASE_DIR"));
+#else
+ rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM("OOO_BASE_DIR"));
+#endif
+ rtl::Bootstrap::expandMacros(url); //TODO: detect failure
+ utl::LocalFileHelper::ConvertURLToPhysicalName(url, aFilterPath);
+ }
+
+ pErrorEx = new FilterErrorEx;
+ bAbort = sal_False;
+}
+
+// ------------------------------------------------------------------------
+
+ULONG GraphicFilter::ImplSetError( ULONG nError, const SvStream* pStm )
+{
+ pErrorEx->nFilterError = nError;
+ pErrorEx->nStreamError = pStm ? pStm->GetError() : ERRCODE_NONE;
+ return nError;
+}
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetImportFormatCount()
+{
+ return pConfig->GetImportFormatCount();
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetImportFormatNumber( const String& rFormatName )
+{
+ return pConfig->GetImportFormatNumber( rFormatName );
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetImportFormatNumberForMediaType( const String& rMediaType )
+{
+ return pConfig->GetImportFormatNumberForMediaType( rMediaType );
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetImportFormatNumberForShortName( const String& rShortName )
+{
+ return pConfig->GetImportFormatNumberForShortName( rShortName );
+}
+
+// ------------------------------------------------------------------------
+
+sal_uInt16 GraphicFilter::GetImportFormatNumberForTypeName( const String& rType )
+{
+ return pConfig->GetImportFormatNumberForTypeName( rType );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetImportFormatName( USHORT nFormat )
+{
+ return pConfig->GetImportFormatName( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetImportFormatTypeName( USHORT nFormat )
+{
+ return pConfig->GetImportFilterTypeName( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetImportFormatMediaType( USHORT nFormat )
+{
+ return pConfig->GetImportFormatMediaType( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetImportFormatShortName( USHORT nFormat )
+{
+ return pConfig->GetImportFormatShortName( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetImportWildcard( USHORT nFormat, sal_Int32 nEntry )
+{
+ return pConfig->GetImportWildcard( nFormat, nEntry );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GraphicFilter::IsImportPixelFormat( USHORT nFormat )
+{
+ return pConfig->IsImportPixelFormat( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetExportFormatCount()
+{
+ return pConfig->GetExportFormatCount();
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetExportFormatNumber( const String& rFormatName )
+{
+ return pConfig->GetExportFormatNumber( rFormatName );
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetExportFormatNumberForMediaType( const String& rMediaType )
+{
+ return pConfig->GetExportFormatNumberForMediaType( rMediaType );
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::GetExportFormatNumberForShortName( const String& rShortName )
+{
+ return pConfig->GetExportFormatNumberForShortName( rShortName );
+}
+
+// ------------------------------------------------------------------------
+
+sal_uInt16 GraphicFilter::GetExportFormatNumberForTypeName( const String& rType )
+{
+ return pConfig->GetExportFormatNumberForTypeName( rType );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetExportFormatName( USHORT nFormat )
+{
+ return pConfig->GetExportFormatName( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetExportFormatTypeName( USHORT nFormat )
+{
+ return pConfig->GetExportFilterTypeName( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetExportFormatMediaType( USHORT nFormat )
+{
+ return pConfig->GetExportFormatMediaType( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetExportFormatShortName( USHORT nFormat )
+{
+ return pConfig->GetExportFormatShortName( nFormat );
+}
+
+// ------------------------------------------------------------------------
+
+String GraphicFilter::GetExportWildcard( USHORT nFormat, sal_Int32 nEntry )
+{
+ return pConfig->GetExportWildcard( nFormat, nEntry );
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::CanImportGraphic( const INetURLObject& rPath,
+ USHORT nFormat, USHORT* pDeterminedFormat )
+{
+ sal_uInt16 nRetValue = GRFILTER_FORMATERROR;
+ DBG_ASSERT( rPath.GetProtocol() != INET_PROT_NOT_VALID, "GraphicFilter::CanImportGraphic() : ProtType == INET_PROT_NOT_VALID" );
+
+ String aMainUrl( rPath.GetMainURL( INetURLObject::NO_DECODE ) );
+ SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aMainUrl, STREAM_READ | STREAM_SHARE_DENYNONE );
+ if ( pStream )
+ {
+ nRetValue = CanImportGraphic( aMainUrl, *pStream, nFormat, pDeterminedFormat );
+ delete pStream;
+ }
+ return nRetValue;
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::CanImportGraphic( const String& rMainUrl, SvStream& rIStream,
+ USHORT nFormat, USHORT* pDeterminedFormat )
+{
+ ULONG nStreamPos = rIStream.Tell();
+ sal_uInt16 nRes = ImpTestOrFindFormat( rMainUrl, rIStream, nFormat );
+
+ rIStream.Seek(nStreamPos);
+
+ if( nRes==GRFILTER_OK && pDeterminedFormat!=NULL )
+ *pDeterminedFormat = nFormat;
+
+ return (USHORT) ImplSetError( nRes, &rIStream );
+}
+
+// ------------------------------------------------------------------------
+//SJ: TODO, we need to create a GraphicImporter component
+USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const INetURLObject& rPath,
+ USHORT nFormat, USHORT * pDeterminedFormat, sal_uInt32 nImportFlags )
+{
+ sal_uInt16 nRetValue = GRFILTER_FORMATERROR;
+ DBG_ASSERT( rPath.GetProtocol() != INET_PROT_NOT_VALID, "GraphicFilter::ImportGraphic() : ProtType == INET_PROT_NOT_VALID" );
+
+ String aMainUrl( rPath.GetMainURL( INetURLObject::NO_DECODE ) );
+ SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aMainUrl, STREAM_READ | STREAM_SHARE_DENYNONE );
+ if ( pStream )
+ {
+ nRetValue = ImportGraphic( rGraphic, aMainUrl, *pStream, nFormat, pDeterminedFormat, nImportFlags );
+ delete pStream;
+ }
+ return nRetValue;
+}
+
+USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvStream& rIStream,
+ USHORT nFormat, USHORT* pDeterminedFormat, sal_uInt32 nImportFlags )
+{
+ return ImportGraphic( rGraphic, rPath, rIStream, nFormat, pDeterminedFormat, nImportFlags, NULL );
+}
+
+//-------------------------------------------------------------------------
+
+USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvStream& rIStream,
+ USHORT nFormat, USHORT* pDeterminedFormat, sal_uInt32 nImportFlags,
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData )
+{
+ String aFilterName;
+ ULONG nStmBegin;
+ USHORT nStatus;
+ GraphicReader* pContext = rGraphic.GetContext();
+ GfxLinkType eLinkType = GFX_LINK_TYPE_NONE;
+ BOOL bDummyContext = ( pContext == (GraphicReader*) 1 );
+ const BOOL bLinkSet = rGraphic.IsLink();
+ FilterConfigItem* pFilterConfigItem = NULL;
+
+ Size aPreviewSizeHint( 0, 0 );
+ sal_Bool bAllowPartialStreamRead = sal_False;
+ sal_Bool bCreateNativeLink = sal_True;
+
+ ResetLastError();
+
+ if ( pFilterData )
+ {
+ sal_Int32 i;
+ for ( i = 0; i < pFilterData->getLength(); i++ )
+ {
+ if ( (*pFilterData)[ i ].Name.equalsAscii( "PreviewSizeHint" ) )
+ {
+ awt::Size aSize;
+ if ( (*pFilterData)[ i ].Value >>= aSize )
+ {
+ aPreviewSizeHint = Size( aSize.Width, aSize.Height );
+ if ( aSize.Width || aSize.Height )
+ nImportFlags |= GRFILTER_I_FLAGS_FOR_PREVIEW;
+ else
+ nImportFlags &=~GRFILTER_I_FLAGS_FOR_PREVIEW;
+ }
+ }
+ else if ( (*pFilterData)[ i ].Name.equalsAscii( "AllowPartialStreamRead" ) )
+ {
+ (*pFilterData)[ i ].Value >>= bAllowPartialStreamRead;
+ if ( bAllowPartialStreamRead )
+ nImportFlags |= GRFILTER_I_FLAGS_ALLOW_PARTIAL_STREAMREAD;
+ else
+ nImportFlags &=~GRFILTER_I_FLAGS_ALLOW_PARTIAL_STREAMREAD;
+ }
+ else if ( (*pFilterData)[ i ].Name.equalsAscii( "CreateNativeLink" ) )
+ {
+ (*pFilterData)[ i ].Value >>= bCreateNativeLink;
+ }
+ }
+ }
+
+ if( !pContext || bDummyContext )
+ {
+ if( bDummyContext )
+ {
+ rGraphic.SetContext( NULL );
+ nStmBegin = 0;
+ }
+ else
+ nStmBegin = rIStream.Tell();
+
+ bAbort = FALSE;
+ nStatus = ImpTestOrFindFormat( rPath, rIStream, 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 )
+ *pDeterminedFormat = nFormat;
+
+ aFilterName = pConfig->GetImportFilterName( nFormat );
+ }
+ else
+ {
+ if( pContext && !bDummyContext )
+ aFilterName = pContext->GetUpperFilterName();
+
+ nStmBegin = 0;
+ nStatus = GRFILTER_OK;
+ }
+
+ // read graphic
+ if ( pConfig->IsImportInternalFilter( nFormat ) )
+ {
+ if( aFilterName.EqualsIgnoreCaseAscii( IMP_GIF ) )
+ {
+ if( rGraphic.GetContext() == (GraphicReader*) 1 )
+ rGraphic.SetContext( NULL );
+
+ if( !ImportGIF( rIStream, rGraphic ) )
+ nStatus = GRFILTER_FILTERERROR;
+ else
+ eLinkType = GFX_LINK_TYPE_NATIVE_GIF;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( IMP_PNG ) )
+ {
+ if ( rGraphic.GetContext() == (GraphicReader*) 1 )
+ rGraphic.SetContext( NULL );
+
+ vcl::PNGReader aPNGReader( rIStream );
+
+ // ignore animation for previews and set preview size
+ if( aPreviewSizeHint.Width() || aPreviewSizeHint.Height() )
+ {
+ // position the stream at the end of the image if requested
+ if( !bAllowPartialStreamRead )
+ aPNGReader.GetChunks();
+ }
+ else
+ {
+ // check if this PNG contains a GIF chunk!
+ const std::vector< vcl::PNGReader::ChunkData >& rChunkData = aPNGReader.GetChunks();
+ std::vector< vcl::PNGReader::ChunkData >::const_iterator aIter( rChunkData.begin() );
+ std::vector< vcl::PNGReader::ChunkData >::const_iterator aEnd ( rChunkData.end() );
+ while( aIter != aEnd )
+ {
+ // Microsoft Office is storing Animated GIFs in following chunk
+ if ( aIter->nType == PMGCHUNG_msOG )
+ {
+ sal_uInt32 nChunkSize = aIter->aData.size();
+ if ( nChunkSize > 11 )
+ {
+ const std::vector< sal_uInt8 >& rData = aIter->aData;
+ SvMemoryStream aIStrm( (void*)&rData[ 11 ], nChunkSize - 11, STREAM_READ );
+ ImportGIF( aIStrm, rGraphic );
+ eLinkType = GFX_LINK_TYPE_NATIVE_PNG;
+ break;
+ }
+ }
+ aIter++;
+ }
+ }
+
+ if ( eLinkType == GFX_LINK_TYPE_NONE )
+ {
+ BitmapEx aBmpEx( aPNGReader.Read( aPreviewSizeHint ) );
+ if ( aBmpEx.IsEmpty() )
+ nStatus = GRFILTER_FILTERERROR;
+ else
+ {
+ rGraphic = aBmpEx;
+ eLinkType = GFX_LINK_TYPE_NATIVE_PNG;
+ }
+ }
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( IMP_JPEG ) )
+ {
+ if( rGraphic.GetContext() == (GraphicReader*) 1 )
+ rGraphic.SetContext( NULL );
+
+ // set LOGSIZE flag always, if not explicitly disabled
+ // (see #90508 and #106763)
+ if( 0 == ( nImportFlags & GRFILTER_I_FLAGS_DONT_SET_LOGSIZE_FOR_JPEG ) )
+ nImportFlags |= GRFILTER_I_FLAGS_SET_LOGSIZE_FOR_JPEG;
+
+ if( !ImportJPEG( rIStream, rGraphic, NULL, nImportFlags ) )
+ nStatus = GRFILTER_FILTERERROR;
+ else
+ eLinkType = GFX_LINK_TYPE_NATIVE_JPG;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( IMP_XBM ) )
+ {
+ if( rGraphic.GetContext() == (GraphicReader*) 1 )
+ rGraphic.SetContext( NULL );
+
+ if( !ImportXBM( rIStream, rGraphic ) )
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( IMP_XPM ) )
+ {
+ if( rGraphic.GetContext() == (GraphicReader*) 1 )
+ rGraphic.SetContext( NULL );
+
+ if( !ImportXPM( rIStream, rGraphic ) )
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( IMP_BMP ) ||
+ aFilterName.EqualsIgnoreCaseAscii( IMP_SVMETAFILE ) )
+ {
+ // SV interne Importfilter fuer Bitmaps und MetaFiles
+ rIStream >> rGraphic;
+ if( rIStream.GetError() )
+ nStatus = GRFILTER_FORMATERROR;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( IMP_WMF ) ||
+ aFilterName.EqualsIgnoreCaseAscii( IMP_EMF ) )
+ {
+ GDIMetaFile aMtf;
+ if( !ConvertWMFToGDIMetaFile( rIStream, aMtf, NULL ) )
+ nStatus = GRFILTER_FORMATERROR;
+ else
+ {
+ rGraphic = aMtf;
+ eLinkType = GFX_LINK_TYPE_NATIVE_WMF;
+ }
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( IMP_SVSGF )
+ || aFilterName.EqualsIgnoreCaseAscii( IMP_SVSGV ) )
+ {
+ USHORT nVersion;
+ unsigned char nTyp = CheckSgfTyp( rIStream, nVersion );
+
+ switch( nTyp )
+ {
+ case SGF_BITIMAGE:
+ {
+ SvMemoryStream aTempStream;
+ if( aTempStream.GetError() )
+ return GRFILTER_OPENERROR;
+
+ if( !SgfBMapFilter( rIStream, aTempStream ) )
+ nStatus = GRFILTER_FILTERERROR;
+ else
+ {
+ aTempStream.Seek( 0L );
+ aTempStream >> rGraphic;
+
+ if( aTempStream.GetError() )
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ }
+ break;
+
+ case SGF_SIMPVECT:
+ {
+ GDIMetaFile aMtf;
+ if( !SgfVectFilter( rIStream, aMtf ) )
+ nStatus = GRFILTER_FILTERERROR;
+ else
+ rGraphic = Graphic( aMtf );
+ }
+ break;
+
+ case SGF_STARDRAW:
+ {
+ if( nVersion != SGV_VERSION )
+ nStatus = GRFILTER_VERSIONERROR;
+ else
+ {
+ GDIMetaFile aMtf;
+ if( !SgfSDrwFilter( rIStream, aMtf,
+ INetURLObject(aFilterPath) ) )
+ {
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ else
+ rGraphic = Graphic( aMtf );
+ }
+ }
+ break;
+
+ default:
+ {
+ nStatus = GRFILTER_FORMATERROR;
+ }
+ break;
+ }
+ }
+ else
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ else
+ {
+ ImpFilterLibCacheEntry* pFilter = NULL;
+
+ // find first filter in filter pathes
+ xub_StrLen i, nTokenCount = aFilterPath.GetTokenCount( ';' );
+ ImpFilterLibCache &rCache = Cache::get();
+ for( i = 0; ( i < nTokenCount ) && ( pFilter == NULL ); i++ )
+ pFilter = rCache.GetFilter( aFilterPath.GetToken(i), aFilterName );
+ if( !pFilter )
+ nStatus = GRFILTER_FILTERERROR;
+ else
+ {
+ PFilterCall pFunc = pFilter->GetImportFunction();
+
+ if( !pFunc )
+ nStatus = GRFILTER_FILTERERROR;
+ else
+ {
+ String aShortName;
+ if( nFormat != GRFILTER_FORMAT_DONTKNOW )
+ {
+ aShortName = GetImportFormatShortName( nFormat ).ToUpperAscii();
+ if ( ( pFilterConfigItem == NULL ) && aShortName.EqualsAscii( "PCD" ) )
+ {
+ String aFilterConfigPath( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/Graphic/Import/PCD" ) );
+ pFilterConfigItem = new FilterConfigItem( aFilterConfigPath );
+ }
+ }
+ if( !(*pFunc)( rIStream, rGraphic, pFilterConfigItem, sal_False ) )
+ nStatus = GRFILTER_FORMATERROR;
+ else
+ {
+ // try to set link type if format matches
+ if( nFormat != GRFILTER_FORMAT_DONTKNOW )
+ {
+ 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;
+ }
+ }
+ }
+ }
+ }
+
+ if( nStatus == GRFILTER_OK && bCreateNativeLink && ( eLinkType != GFX_LINK_TYPE_NONE ) && !rGraphic.GetContext() && !bLinkSet )
+ {
+ const ULONG nStmEnd = rIStream.Tell();
+ const ULONG nBufSize = nStmEnd - nStmBegin;
+
+ if( nBufSize )
+ {
+ BYTE* pBuf=0;
+ try
+ {
+ pBuf = new BYTE[ nBufSize ];
+ }
+ catch (std::bad_alloc)
+ {
+ nStatus = GRFILTER_TOOBIG;
+ }
+
+ if( nStatus == GRFILTER_OK )
+ {
+ rIStream.Seek( nStmBegin );
+ rIStream.Read( pBuf, nBufSize );
+ rGraphic.SetLink( GfxLink( pBuf, nBufSize, eLinkType, TRUE ) );
+ }
+ }
+ }
+
+ // 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();
+ }
+
+ delete pFilterConfigItem;
+ return nStatus;
+}
+
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::ExportGraphic( const Graphic& rGraphic, const INetURLObject& rPath,
+ sal_uInt16 nFormat, const uno::Sequence< beans::PropertyValue >* pFilterData )
+{
+ sal_uInt16 nRetValue = GRFILTER_FORMATERROR;
+ DBG_ASSERT( rPath.GetProtocol() != INET_PROT_NOT_VALID, "GraphicFilter::ExportGraphic() : ProtType == INET_PROT_NOT_VALID" );
+ BOOL bAlreadyExists = ImplDirEntryHelper::Exists( rPath );
+
+ String aMainUrl( rPath.GetMainURL( INetURLObject::NO_DECODE ) );
+ SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aMainUrl, STREAM_WRITE | STREAM_TRUNC );
+ if ( pStream )
+ {
+ nRetValue = ExportGraphic( rGraphic, aMainUrl, *pStream, nFormat, pFilterData );
+ delete pStream;
+
+ if( ( GRFILTER_OK != nRetValue ) && !bAlreadyExists )
+ ImplDirEntryHelper::Kill( aMainUrl );
+ }
+ return nRetValue;
+}
+
+// ------------------------------------------------------------------------
+
+USHORT GraphicFilter::ExportGraphic( const Graphic& rGraphic, const String& rPath,
+ SvStream& rOStm, sal_uInt16 nFormat, const uno::Sequence< beans::PropertyValue >* pFilterData )
+{
+ USHORT nFormatCount = GetExportFormatCount();
+
+ ResetLastError();
+
+ if( nFormat == GRFILTER_FORMAT_DONTKNOW )
+ {
+ INetURLObject aURL( rPath );
+ String aExt( aURL.GetFileExtension().toAsciiUpperCase() );
+
+
+ for( USHORT i = 0; i < nFormatCount; i++ )
+ {
+ if ( pConfig->GetExportFormatExtension( nFormat ).EqualsIgnoreCaseAscii( aExt ) )
+ {
+ nFormat=i;
+ break;
+ }
+ }
+ }
+ if( nFormat >= nFormatCount )
+ return (USHORT) ImplSetError( GRFILTER_FORMATERROR );
+
+ FilterConfigItem aConfigItem( (uno::Sequence< beans::PropertyValue >*)pFilterData );
+ String aFilterName( pConfig->GetExportFilterName( nFormat ) );
+
+ bAbort = FALSE;
+ USHORT nStatus = GRFILTER_OK;
+ GraphicType eType;
+ Graphic aGraphic( rGraphic );
+
+ aGraphic = ImpGetScaledGraphic( rGraphic, aConfigItem );
+ eType = aGraphic.GetType();
+
+ if( pConfig->IsExportPixelFormat( nFormat ) )
+ {
+ 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));
+ }
+ }
+ if( rOStm.GetError() )
+ nStatus = GRFILTER_IOERROR;
+ if( GRFILTER_OK == nStatus )
+ {
+ if ( pConfig->IsExportInternalFilter( nFormat ) )
+ {
+ if( aFilterName.EqualsIgnoreCaseAscii( EXP_BMP ) )
+ {
+ Bitmap aBmp( aGraphic.GetBitmap() );
+ sal_Int32 nColorRes = aConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Colors" ) ), 0 );
+ if ( nColorRes && ( nColorRes <= (USHORT)BMP_CONVERSION_24BIT) )
+ {
+ if( !aBmp.Convert( (BmpConversion) nColorRes ) )
+ aBmp = aGraphic.GetBitmap();
+ }
+ sal_Bool bRleCoding = aConfigItem.ReadBool( String( RTL_CONSTASCII_USTRINGPARAM( "RLE_Coding" ) ), sal_True );
+ // Wollen wir RLE-Kodiert speichern?
+ aBmp.Write( rOStm, bRleCoding );
+
+ if( rOStm.GetError() )
+ nStatus = GRFILTER_IOERROR;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( EXP_SVMETAFILE ) )
+ {
+ sal_Int32 nVersion = aConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ), 0 ) ;
+ if ( nVersion )
+ rOStm.SetVersion( nVersion );
+ 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() );
+ }
+ rOStm << aMTF;
+ if( rOStm.GetError() )
+ nStatus = GRFILTER_IOERROR;
+ }
+ else if ( aFilterName.EqualsIgnoreCaseAscii( EXP_WMF ) )
+ {
+ if( eType == GRAPHIC_GDIMETAFILE )
+ {
+ if ( !ConvertGDIMetaFileToWMF( aGraphic.GetGDIMetaFile(), rOStm, &aConfigItem ) )
+ 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, &aConfigItem ) )
+ nStatus = GRFILTER_FORMATERROR;
+ }
+ if( rOStm.GetError() )
+ nStatus = GRFILTER_IOERROR;
+ }
+ else if ( aFilterName.EqualsIgnoreCaseAscii( EXP_EMF ) )
+ {
+ if( eType == GRAPHIC_GDIMETAFILE )
+ {
+ if ( !ConvertGDIMetaFileToEMF( aGraphic.GetGDIMetaFile(), rOStm, &aConfigItem ) )
+ 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, &aConfigItem ) )
+ nStatus = GRFILTER_FORMATERROR;
+ }
+ if( rOStm.GetError() )
+ nStatus = GRFILTER_IOERROR;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( EXP_JPEG ) )
+ {
+ if( !ExportJPEG( rOStm, aGraphic, pFilterData ) )
+ nStatus = GRFILTER_FORMATERROR;
+
+ if( rOStm.GetError() )
+ nStatus = GRFILTER_IOERROR;
+ }
+ else if ( aFilterName.EqualsIgnoreCaseAscii( EXP_PNG ) )
+ {
+ vcl::PNGWriter aPNGWriter( aGraphic.GetBitmapEx(), pFilterData );
+ if ( pFilterData )
+ {
+ sal_Int32 k, j, i = 0;
+ for ( i = 0; i < pFilterData->getLength(); i++ )
+ {
+ if ( (*pFilterData)[ i ].Name.equalsAscii( "AdditionalChunks" ) )
+ {
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aAdditionalChunkSequence;
+ if ( (*pFilterData)[ i ].Value >>= aAdditionalChunkSequence )
+ {
+ for ( j = 0; j < aAdditionalChunkSequence.getLength(); j++ )
+ {
+ if ( aAdditionalChunkSequence[ j ].Name.getLength() == 4 )
+ {
+ sal_uInt32 nChunkType = 0;
+ for ( k = 0; k < 4; k++ )
+ {
+ nChunkType <<= 8;
+ nChunkType |= (sal_uInt8)aAdditionalChunkSequence[ j ].Name[ k ];
+ }
+ com::sun::star::uno::Sequence< sal_Int8 > aByteSeq;
+ if ( aAdditionalChunkSequence[ j ].Value >>= aByteSeq )
+ {
+ std::vector< vcl::PNGWriter::ChunkData >& rChunkData = aPNGWriter.GetChunks();
+ if ( rChunkData.size() )
+ {
+ sal_uInt32 nChunkLen = aByteSeq.getLength();
+
+ vcl::PNGWriter::ChunkData aChunkData;
+ aChunkData.nType = nChunkType;
+ if ( nChunkLen )
+ {
+ aChunkData.aData.resize( nChunkLen );
+ rtl_copyMemory( &aChunkData.aData[ 0 ], aByteSeq.getConstArray(), nChunkLen );
+ }
+ std::vector< vcl::PNGWriter::ChunkData >::iterator aIter = rChunkData.end() - 1;
+ rChunkData.insert( aIter, aChunkData );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ aPNGWriter.Write( rOStm );
+
+ if( rOStm.GetError() )
+ nStatus = GRFILTER_IOERROR;
+ }
+ else if( aFilterName.EqualsIgnoreCaseAscii( EXP_SVG ) )
+ {
+ try
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr( ::comphelper::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 );
+
+ 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 );
+ }
+ }
+ }
+ }
+ catch( ::com::sun::star::uno::Exception& )
+ {
+ nStatus = GRFILTER_IOERROR;
+ }
+ }
+ else
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ else
+ {
+ xub_StrLen i, nTokenCount = aFilterPath.GetTokenCount( ';' );
+ for ( i = 0; i < nTokenCount; i++ )
+ {
+ String aPhysicalName( ImpCreateFullFilterPath( aFilterPath.GetToken( i ), aFilterName ) );
+ osl::Module aLibrary( aPhysicalName );
+
+ PFilterCall pFunc = (PFilterCall) aLibrary.getFunctionSymbol( UniString::CreateFromAscii( EXPORT_FUNCTION_NAME ) );
+ // Dialog in DLL ausfuehren
+ if( pFunc )
+ {
+ if ( !(*pFunc)( rOStm, aGraphic, &aConfigItem, sal_False ) )
+ nStatus = GRFILTER_FORMATERROR;
+ break;
+ }
+ else
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ }
+ }
+ if( nStatus != GRFILTER_OK )
+ {
+ if( bAbort )
+ nStatus = GRFILTER_ABORT;
+
+ ImplSetError( nStatus, &rOStm );
+ }
+ return nStatus;
+}
+
+// ------------------------------------------------------------------------
+
+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;
+ 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
+ {
+ // Import
+ nFormat = GetImportFormatNumberForShortName( String( aShortName.GetBuffer(), RTL_TEXTENCODING_UTF8 ) );
+ nRet = ImportGraphic( pData->maGraphic, String(), pData->mrStm ) == 0;
+ }
+ else if( aShortName.Len() )
+ {
+ // Export
+ nFormat = GetExportFormatNumberForShortName( String( aShortName.GetBuffer(), RTL_TEXTENCODING_UTF8 ) );
+ nRet = ExportGraphic( pData->maGraphic, String(), pData->mrStm, nFormat ) == 0;
+ }
+ }
+ return nRet;
+}
+
+// ------------------------------------------------------------------------
+
+GraphicFilter* GraphicFilter::GetGraphicFilter()
+{
+ if( !pGraphicFilter )
+ {
+ pGraphicFilter = new GraphicFilter;
+ pGraphicFilter->GetImportFormatCount();
+ }
+ return pGraphicFilter;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_filter2.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_filter2.cxx
new file mode 100644
index 000000000000..ef904a862442
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_filter2.cxx
@@ -0,0 +1,1325 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+#include <tools/urlobj.hxx>
+#include <string.h>
+#include <stdio.h>
+#include <tools/stream.hxx>
+#include <tools/debug.hxx>
+#include <vcl/outdev.hxx>
+#include <tools/config.hxx>
+#include <bf_svtools/filter.hxx>
+#include "FilterConfigCache.hxx"
+#include <unotools/ucbstreamhelper.hxx>
+
+#define DATA_SIZE 640
+
+namespace binfilter
+{
+
+BYTE* ImplSearchEntry( BYTE* , BYTE* , ULONG , ULONG );
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+GraphicDescriptor::GraphicDescriptor( SvStream& rInStream, const String* pPath) :
+ pFileStm ( NULL )
+{
+ ImpConstruct();
+
+ if ( pPath )
+ {
+ INetURLObject aURL( *pPath );
+ aPathExt = aURL.GetFileExtension().toAsciiLowerCase();
+ }
+ nStmPos = rInStream.Tell();
+ pBaseStm = &rInStream;
+ bBaseStm = TRUE;
+
+ if ( !pBaseStm->GetError() )
+ bDataReady = TRUE;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+GraphicDescriptor::~GraphicDescriptor()
+{
+ delete pFileStm;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::Detect( BOOL bExtendedInfo )
+{
+ BOOL bRet = FALSE;
+
+ // Link-Status ueberpruefen
+ if ( bLinked && bLinkChanged )
+ {
+ DBG_ASSERT( aReqLink.IsSet(), "Wo ist der RequestHandler???" );
+ pMemStm = (SvStream*) aReqLink.Call( this );
+ if ( pMemStm )
+ {
+ 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;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+SvStream& GraphicDescriptor::GetSearchStream() const
+{
+ DBG_ASSERT( bDataReady, "Was laeuft hier falsch???" );
+
+ if ( bLinked )
+ return *pMemStm;
+ else if ( bBaseStm )
+ return *pBaseStm;
+ else
+ return *pFileStm;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphicDescriptor::ImpConstruct()
+{
+ if ( !pFileStm )
+ pFileStm = new SvStream();
+ 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 n32;
+ UINT16 n16;
+ BOOL bRet = FALSE;
+ BYTE cByte;
+
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ rStm.Seek( nStmPos );
+
+ rStm >> n32;
+ if ( n32 == 0x38464947 )
+ {
+ rStm >> n16;
+ if ( ( n16 == 0x6137 ) || ( n16 == 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 = 0;
+ 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 = static_cast< SvMemoryStream& >(rStm).GetEndOfData()
+ - 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 )
+{
+ 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
+ {
+ bRet = aPathExt.CompareToAscii( "pcd", 3 ) == COMPARE_EQUAL;
+ if ( bRet )
+ {
+ nFormat = GFF_PCD;
+ }
+ }
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectPCX( SvStream& rStm, BOOL bExtendedInfo )
+{
+ // ! Because 0x0a can be interpreted as LF too ...
+ // we cant be shure that this special sign represent a PCX file only.
+ // Every Ascii file is possible here :-(
+ // We must detect the whole header.
+ bExtendedInfo = TRUE;
+
+ 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 );
+
+ bRet = (cByte==0 || cByte ==1);
+
+ // 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;
+
+ bRet = (nPlanes<=4);
+ }
+ }
+
+ 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 )
+ {
+ 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 bDetectOk = 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 );
+ bDetectOk = TRUE;
+ }
+ else if ( cByte1 == 0x4d )
+ {
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+ bDetectOk = TRUE;
+ }
+
+ if ( bDetectOk )
+ {
+ 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 = FALSE;
+
+ // 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 );
+ if ( !bOk )
+ {
+ break;
+ }
+ 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&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "xbm", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_XBM;
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectXPM( SvStream&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "xpm", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_XPM;
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectPBM( SvStream& rStm, BOOL )
+{
+ 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 )
+{
+ 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 )
+{
+ 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 )
+{
+ 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&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "tga", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ 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 )
+{
+ // es wird die EPS mit Vorschaubild Variante und die Extensionuebereinstimmung
+ // geprueft
+
+ sal_uInt32 nFirstLong;
+ sal_uInt8 nFirstBytes[20];
+
+ rStm.Seek( nStmPos );
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+ rStm >> nFirstLong;
+ rStm.SeekRel( -4 );
+ rStm.Read( &nFirstBytes, 20 );
+
+ if ( ( nFirstLong == 0xC5D0D3C6 ) || ( aPathExt.CompareToAscii( "eps", 3 ) == COMPARE_EQUAL ) ||
+ ( ImplSearchEntry( nFirstBytes, (sal_uInt8*)"%!PS-Adobe", 10, 10 )
+ && ImplSearchEntry( &nFirstBytes[15], (sal_uInt8*)"EPS", 3, 3 ) ) )
+ {
+ nFormat = GFF_EPS;
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectDXF( SvStream&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "dxf", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_DXF;
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectMET( SvStream&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "met", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_MET;
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectPCT( SvStream& rStm, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "pct", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ 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 )
+{
+ BOOL bRet = FALSE;
+
+ if( aPathExt.CompareToAscii( "sgf", 3 ) == COMPARE_EQUAL )
+ bRet = TRUE;
+ else
+ {
+ BYTE nFirst, nSecond;
+
+ rStm.Seek( nStmPos );
+ rStm >> nFirst >> nSecond;
+
+ if( nFirst == 'J' && nSecond == 'J' )
+ bRet = TRUE;
+ }
+
+ if( bRet )
+ nFormat = GFF_SGF;
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectSGV( SvStream&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "sgv", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_SGV;
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectSVM( SvStream& rStm, BOOL bExtendedInfo )
+{
+ UINT32 n32;
+ BOOL bRet = FALSE;
+ BYTE cByte;
+
+ rStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ rStm.Seek( nStmPos );
+
+ rStm >> n32;
+ if ( n32 == 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
+ {
+ rStm.SeekRel( -4L );
+ rStm >> n32;
+
+ if( n32 == 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&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "wmf",3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_WMF;
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL GraphicDescriptor::ImpDetectEMF( SvStream&, BOOL )
+{
+ BOOL bRet = aPathExt.CompareToAscii( "emf", 3 ) == COMPARE_EQUAL;
+ if (bRet)
+ nFormat = GFF_EMF;
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+String GraphicDescriptor::GetImportFormatShortName( sal_uInt16 nFormat )
+{
+ ByteString aKeyName;
+
+ 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;
+ }
+
+ return String( aKeyName, RTL_TEXTENCODING_ASCII_US );
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_fldll.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_fldll.cxx
new file mode 100644
index 000000000000..4d7d7f50fae7
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_fldll.cxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+
+#ifdef WIN
+
+#include <svwin.h>
+
+namespace binfilter
+{
+
+// 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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_gradwrap.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_gradwrap.cxx
new file mode 100644
index 000000000000..75c94d9f07dc
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_gradwrap.cxx
@@ -0,0 +1,577 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+
+#include <math.h>
+#include <svgrad.hxx>
+#include <svbmpacc.hxx>
+#include <gradwrap.hxx>
+
+namespace binfilter
+{
+
+// -------------------
+// - 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
+ aSetFillInBrushRecordHdl.Call(&aCol);
+
+ // 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 );
+ }
+
+ aSetFillInBrushRecordHdl.Call(&aCol);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+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
+ aSetFillInBrushRecordHdl.Call(&aCol);
+
+ // 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 );
+ aSetFillInBrushRecordHdl.Call(&aCol);
+
+ // 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;
+
+ nRed = MinMax( nRed, 0, 0xFF );
+ nGreen = MinMax( nGreen, 0, 0xFF );
+ nBlue = MinMax( nBlue, 0, 0xFF );
+ }
+
+ // Falls PolyPolygon-Ausgabe, muessen wir noch ein letztes
+ // inneres Polygon zeichnen
+ aCol = Color( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue );
+ aSetFillInBrushRecordHdl.Call(&aCol);
+
+ 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
+ aSetFillInBrushRecordHdl.Call(&aCol);
+
+ // 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 );
+ aSetFillInBrushRecordHdl.Call(&aCol);
+
+ // 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;
+
+ nRed = MinMax( nRed, 0, 0xFF );
+ nGreen = MinMax( nGreen, 0, 0xFF );
+ nBlue = MinMax( nBlue, 0, 0xFF );
+ }
+
+ aCol = Color( (BYTE) nRed, (BYTE) nGreen, (BYTE) nBlue );
+ aSetFillInBrushRecordHdl.Call(&aCol);
+
+ aPoly = aPolyPoly.GetObject( 1 );
+ if ( !aPoly.GetBoundRect().IsEmpty() )
+ {
+ aPoly.Clip( aClipRect );
+ aDrawPolyRecordHdl.Call(&aPoly);
+ }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgfbram.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgfbram.cxx
new file mode 100644
index 000000000000..40d994bb6c2f
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgfbram.cxx
@@ -0,0 +1,658 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+
+#include <string.h>
+#include <osl/endian.h>
+#include <tools/stream.hxx>
+#include <vcl/gdimtf.hxx>
+#include <tools/color.hxx>
+#include <vcl/virdev.hxx>
+#include "sgffilt.hxx"
+#include "sgfbram.hxx"
+
+namespace binfilter
+{
+
+#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 OSL_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 OSL_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 OSL_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 OSL_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 OSL_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 OSL_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 OSL_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; // Spaltenzaehler, Zeilenzaehler, Planezaehler
+ USHORT a,b; // Hilfsvariable
+ BYTE pl1 = 0,pl2= 0; // Masken fuer die Planes
+ BYTE* pBuf=NULL; // Buffer fuer 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 fuellen
+
+ 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 fuellen
+ 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); // rueckwaerts 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 fuellen
+ 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); // rueckwaerts schreiben!
+ rOut.Write((char*)pBuf,nWdtOut);
+ }
+ } else if (nColors==256) {
+ cRGB[3]=0; // der 4. Paletteneintrag fuer 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 fuellen
+ 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); // rueckwaerts 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 ///////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// Fuer 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);
+}
+
+
+/*************************************************************************
+|*
+|* CheckSgfTyp()
+|*
+|* Beschreibung Feststellen, um was fuer ein SGF/SGV es sich handelt.
+|* Ersterstellung JOE 23.06.93
+|* Letzte Aenderung JOE 23.06.93
+|*
+*************************************************************************/
+BYTE CheckSgfTyp(SvStream& rInp, USHORT& nVersion)
+{
+#if OSL_DEBUG_LEVEL > 1 // Recordgroessen 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;
+ }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvmain.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvmain.cxx
new file mode 100644
index 000000000000..596d65268bfa
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvmain.cxx
@@ -0,0 +1,1144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+#include <osl/endian.h>
+#include <vcl/graph.hxx>
+#include <tools/poly.hxx>
+#include <bf_svtools/filter.hxx>
+#include "sgffilt.hxx"
+#include "sgfbram.hxx"
+#include "sgvmain.hxx"
+#include "sgvspln.hxx"
+#include <unotools/ucbstreamhelper.hxx>
+
+namespace binfilter
+{
+
+#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); }
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Einschraenkungen:
+//
+// - Flaechenmuster werden den unter StarView verfuegbaren Mustern angenaehert.
+// - Linienenden werden unter StarView immer rund dargestellt und gehen ueber
+// den Endpunkt der Linie hinaus.
+// - Linienmuster werden den unter StarView verfuegbaren Mustern angenaehert.
+// Transparent/Opak wird zur Zeit noch nicht beruecksichtigt.
+// - Keine gedrehten Ellipsen
+//
+//
+//
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#if defined( WIN ) && defined( MSC )
+#pragma code_seg( "svtools", "AUTO_CODE" )
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Fuer Fontuebersetzung ///////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+SgfFontLst* pSgfFonts = 0;
+
+#if defined( WIN ) && defined( MSC )
+#pragma code_seg( "SVTOOLS_FILTER3", "SVTOOLS_CODE" )
+static void AntiMscBug() {}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Fuer 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 OSL_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 unveraendert!
+ ULONG nPos;
+ nPos=rInp.Tell();
+ rInp.Read((char*)&rObjk.Last,ObjkSize);
+#if defined OSL_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 OSL_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 OSL_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 OSL_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 OSL_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 OSL_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 OSL_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 OSL_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 OSL_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
+|*
+*************************************************************************/
+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;
+ }
+ 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( (sal_uInt8)r1, (sal_uInt8)g1, (sal_uInt8)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 fuer 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 = a.y - Center.y;
+ b.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 = a.y + Center.y;
+ b.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::Draw(OutputDevice& rOut)
+{
+ //ifstream aInp;
+ unsigned char nSgfTyp;
+ USHORT nVersion;
+ String aStr(
+ reinterpret_cast< char const * >(&Filename[ 1 ]),
+ (xub_StrLen)Filename[ 0 ], RTL_TEXTENCODING_UTF8 );
+ INetURLObject aFNam( aStr );
+
+ SvStream* pInp = ::utl::UcbStreamHelper::CreateStream( aFNam.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+ if ( pInp )
+ {
+ nSgfTyp=CheckSgfTyp( *pInp,nVersion);
+ switch(nSgfTyp) {
+ case SGF_BITIMAGE: {
+ GraphicFilter aFlt;
+ Graphic aGrf;
+ USHORT nRet;
+ 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;
+ SgfVectFilter(*pInp,aMtf);
+ SgfVectXofs=0;
+ SgfVectYofs=0;
+ SgfVectXmul=0;
+ SgfVectYmul=0;
+ SgfVectXdiv=0;
+ SgfVectYdiv=0;
+ SgfVectScal=FALSE;
+ aMtf.Play(&rOut);
+ } break;
+ }
+ delete pInp;
+ }
+}
+
+
+/*************************************************************************
+|*
+|* 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 )
+{
+ 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 fuer 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.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 OSL_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 OSL_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-Anhaengsel
+ if(aGrup.GetSubPtr()!=0L) nGrpCnt++;// DrawObjkList(rInp,rOut );
+ }
+ } break;
+ default: {
+ aObjk.Draw(rOut); // Objektbezeichnung auf 2. Screen
+ ObjkOverSeek(rInp,aObjk); // zum naechsten 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-Anhaengsel
+ if(aGrup.GetSubPtr()!=0L) SkipObjkList(rInp);
+ } else {
+ ObjkOverSeek(rInp,aObjk); // zum naechsten 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 )
+{
+ BOOL bRet = FALSE;
+ 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 );
+ rInp.Seek(nZchPos);
+ nZchPos=rInp.Tell();
+ rInp>>aPage;
+ }
+ if (aPage.nList!=0L) DrawObjkList(rInp,*pOutDev );
+
+ 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 )
+{
+#if OSL_DEBUG_LEVEL > 1 // Recordgroessen checken. Neuer Compiler hat vielleichte anderes Alignment!
+ 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.GetMainURL( INetURLObject::NO_DECODE ) );
+ 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 );
+ }
+ } // 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
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvspln.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvspln.cxx
new file mode 100644
index 000000000000..ac44fc8c8fea
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvspln.cxx
@@ -0,0 +1,902 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+
+#include <math.h>
+
+
+#include <tools/poly.hxx>
+
+#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
+
+namespace binfilter
+{
+
+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 ---------------------------*/
+
+#define IEEE
+
+/* 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 -----------------------*/
+
+double exp (double);
+double atan (double);
+double pow (double,double);
+double sqrt (double);
+
+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.
+ */
+
+#define MAXEXPON 1023.0 /* groesster Exponent */
+#define MINEXPON -1024.0 /* kleinster Exponent */
+
+
+#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 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 fuer 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 natuerlichen
+|* kubischen Polynomsplines mit n Stuetzstellen.
+|* 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 & ~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 Stuetzstellen.
+|* 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 muessen 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; // muss streng nonoton fallend sein!
+ if (y[n]!=y[0]) return 3; // Anfang muss 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;
+ delete[] lowrow;
+ delete[] 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;
+ delete[] lowrow;
+ delete[] ricol;
+ return 0;
+}
+
+
+
+/*************************************************************************
+|*
+|* ParaSpline()
+|*
+|* Beschreibung Berechnet die Koeffizienten eines parametrischen
+|* natuerlichen oder periodischen kubischen
+|* Polynomsplines mit n Stuetzstellen.
+|* 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 = 0,alphY = 0,
+ betX = 0,betY = 0;
+
+ if (n<2) return 1;
+ if ((MargCond & ~3) && (MargCond != 4)) return 2; // ungueltige 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
+|* natuerlichen oder periodischen kubischen
+|* Polynomsplines. Die Eckpunkte des uebergebenen
+|* Polygons werden als Stuetzstellen angenommen.
+|* n liefert die Anzahl der Teilpolynome.
+|* Ist die Berechnung fehlerfrei verlaufen, so
+|* liefert die Funktion TRUE. Nur in diesem Fall
+|* ist Speicher fuer die Koeffizientenarrays
+|* allokiert, der dann spaeter 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)
+
+ BOOL bRet = FALSE;
+ if ( ( Marg == 3 && n >= 3 ) || ( Marg == 2 && n >= 2 ) )
+ {
+ bRet = ParaSpline(n,ax,ay,Marg,Marg01,Marg01,MargN1,MargN2,FALSE,T,bx,cx,dx,by,cy,dy) == 0;
+ }
+ if ( bRet == FALSE )
+ {
+ delete[] ax;
+ delete[] ay;
+ delete[] bx;
+ delete[] by;
+ delete[] cx;
+ delete[] cy;
+ delete[] dx;
+ delete[] dy;
+ delete[] T;
+ n=0;
+ }
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|* Spline2Poly()
+|*
+|* Beschreibung Konvertiert einen parametrichen kubischen
+|* Polynomspline Spline (natuerlich oder periodisch)
+|* in ein angenaehertes Polygon.
+|* Die Funktion liefert FALSE, wenn ein Fehler bei
+|* der Koeffizientenberechnung aufgetreten ist oder
+|* das Polygon zu gross wird (>PolyMax=16380). Im 1.
+|* Fall hat das Polygon 0, im 2. Fall PolyMax Punkte.
+|* Um Koordinatenueberlaeufe 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 Ueberlaeufen
+
+ double* ax; // Koeffizienten der Polynome
+ double* ay;
+ double* bx;
+ double* by;
+ double* cx;
+ double* cy;
+ double* dx;
+ double* dy;
+ double* tv;
+
+ double Step; // Schrittweite fuer t
+ double dt1,dt2,dt3; // Delta t, y, ^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 gross
+ }
+ t=t+Step;
+ } // Ende von Teilpolynom
+ i++; // naechstes Teilpolynom
+ }
+ delete[] ax;
+ delete[] ay;
+ delete[] bx;
+ delete[] by;
+ delete[] cx;
+ delete[] cy;
+ delete[] dx;
+ delete[] dy;
+ delete[] tv;
+ return bOk;
+ } // Ende von if (bOk)
+ rPoly.SetSize(0);
+ return FALSE;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvtext.cxx b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvtext.cxx
new file mode 100644
index 000000000000..ddb15c3f8011
--- /dev/null
+++ b/binfilter/bf_svtools/source/filter.vcl/filter/svt_sgvtext.cxx
@@ -0,0 +1,1295 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+#include <tools/config.hxx>
+#include <bf_svtools/filter.hxx>
+#include "sgffilt.hxx"
+#include "sgfbram.hxx"
+#include "sgvmain.hxx"
+
+namespace binfilter {
+
+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
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Einschraenkungen: 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 /* Strichstaerke 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 fuer 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 fuer 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. Laenge von Value soll sein: 8 Char (7+Vorzeichen). Demnach max. Laenge
+// einer Escapesequenz: 11 Char.
+// Identifer:
+
+#define EscFont 'F' /* FontID, z.B. 92500 fuer CG Times */
+#define EscGrad 'G' /* Schriftgrad 1..255 fuer <<Pt-127<<Pt */
+#define EscBreit 'B' /* Breite 1..255% des Schriftgrades */
+#define EscKaptS 'K' /* Kapitaelchengroesse 1..255% des Schriftgrades */
+#define EscLFeed 'L' /* Zeilenabstand 1..32767% vom max. Schriftgrad der Zeile */
+ // oder 1..32767 fuer 1..16383<<Pt absolut (Wenn Bit 15=1)
+#define EscSlant 'S' /* Kursiv(Winkel) 1..8999 fuer 0.01deg..89.99deg */
+#define EscVPos 'V' /* Zeichen Vertikal-Position 1..255 fuer <<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' /* Farbintensitaet 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' /* Musterintensitaet 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' /* Schattenintensitaet 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' /* Kapitaelchenflag */
+#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 muss spaetestens am Anfang des Absatzes stehen
+#define EscSet '' /* Flag setzen */
+#define EscReset '' /* Flag loeschen */
+#define EscDeflt '\x11' /* Flag auf default setzen */
+#define EscToggl '' /* Flag Toggeln */
+#define EscRelat '%'
+#define EscNoFlg 0
+#define EscNoVal -2147483647 /* -MaxLongInt */
+//==============================================================================
+#define NoTrenn 0xFFFF /* Wert fuer Parameter 'Rest' von GetTextChar(), wenn auf keinen Fall getrennt werden soll */
+#define DoTrenn 0xFFFE /* Wert fuer 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 /* Zeilenhoehe ist groesser als Schriftgrad */
+ // bei Avanti-Bold 'ue' 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 /* Kapitaelchen */
+#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 42deg 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));
+}
+
+
+short hPoint2Sgf(short a)
+{
+ long b;
+ b=long(a)*127*SgfDpmm/(144*5);
+ return short(b);
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+// 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 erhoeht.
+// Der Parameter Rest muss 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, dass ueberall dort
+// getrennt wird, wo ein SoftTrenner vorkommt.
+//
+// SoftTrenner werden immer in ein Minuszeichen konvertiert.
+// GetTextCharConv() konvertiert zusaetzlich 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;
+}
+
+long ChgValue(long Def, long Min, long Max, UCHAR FlgVal, long NumVal)
+{
+ long r=0;
+
+ if (FlgVal==EscDeflt) {
+ r=Def; // zurueck 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 faengt 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 ueberspringen
+ if (c0==SoftTrennAdd) {
+ if (c>=32) c=ProcessOne(TBuf,Index,Atr0,AktAtr,ScanEsc); // und hier noch 'nen Buchstaben ueberspringen
+ }
+ }
+ }
+ 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 muessen explizit konvertiert werden ! }
+ // if AktAtr.Schnitt and TextKaptBit =TextKaptBit then c:=UpCase(c);(explizit) }
+
+ // Bei der Trennmethode SoftTrennAdd wird davon ausgegangen, dass 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()
+//
+// Benoetigter Zeilenabstand in SGF-Units. ChrVPos wird beruecksichtigt.
+// ======================================================================
+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=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 15deg */
+#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 heisst 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 == 0xe4 || c == 0xf6 || c == 0xfc ) 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 == 0xe4 ) c = 0xc4;
+ else if ( c == 0xf6 ) c = 0xd6;
+ else if ( c == 0xfc ) c = 0xdc;
+ 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 {
+ // with MaxChar == 255 c cannot be greater than MaxChar
+ // assert if MaxChar is ever changed
+ OSL_ENSURE( MaxChar == 255, "MaxChar not 255" );
+ 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 fuer 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 fuer den naechsten Character
+ }
+ return c;
+}
+
+void FormatLine(UCHAR* TBuf, USHORT& Index, ObjTextType& Atr0, ObjTextType& AktAtr,
+ USHORT UmbWdt, USHORT AdjWdt,
+ short* Line, USHORT& nChars,
+ double, double,
+ UCHAR* cLine, BOOL TextFit)
+{
+ VirtualDevice vOut;
+ UCHAR c,c0;
+ UCHAR ct;
+ BOOL First; // erster Char ?
+ BYTE Just = 0; // 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, dass 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 muss 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 linksbuendig
+ 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]=Line[i]+BoxRest;
+ } break;
+ case THJustRight: { // Rechts
+ for (i=1;i<=nChars;i++) Line[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]=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]=Line[i]+h;
+ }
+ }
+ for (i=re+1;i<=nChars;i++) Line[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]=Line[i]+MulDiv(i-li,BoxRest,re-li+1-1);
+ }
+ for (i=re+1;i<=nChars;i++) Line[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 fuer Outliner !!
+
+ ObjTextType T1,T2;
+ USHORT Index1;
+ USHORT Index2;
+ UCHAR c = TextEnd;
+ 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 = 0;
+ USHORT lc;
+ BOOL LineFit; // FitSize.x=0? oder Flags -> jede Zeile stretchen
+ BOOL TextFit;
+ short* xLine;
+ UCHAR* cLine; // Buffer fuer 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=sal::static_int_cast< USHORT >(abs(Pos2.x-Pos1.x)); FitXDiv=FitSize.x; if (FitXDiv==0) FitXDiv=1;
+ FitYMul=sal::static_int_cast< USHORT >(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=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; // Fuer die naechste 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 benoetigt, da der Pointer nun extra gefuehrt wird
+// (DEC Alpha hat naemlich 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 loeschen 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=sal::static_int_cast< USHORT >(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;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */