xref: /aoo4110/main/sc/inc/filter.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_FILTER_HXX
25 #define SC_FILTER_HXX
26 
27 #include <tools/string.hxx>
28 #include <rtl/textenc.h>
29 
30 #define ENABLE_LOTUS123_EXPORT 0
31 
32 class SfxMedium;
33 class SvStream;
34 
35 class ScAddress;
36 class ScDocument;
37 class ScRange;
38 class SvNumberFormatter;
39 
40 // Return-Werte Im-/Exportfilter	(sal_uLong)
41 
42 typedef sal_uLong FltError;
43 //enum FltError {
44 
45 #define eERR_OK  		ERRCODE_NONE				// kein Fehler, alles OK
46 #define	eERR_OPEN		SCERR_IMPORT_OPEN			// ...
47 #define	eERR_UNBEK		SCERR_IMPORT_UNKNOWN		// unbekannter Fehler, auch historische Bedeutung
48 #define	eERR_NOMEM		SCERR_IMPORT_OUTOFMEM		// nicht mehr genuegend Speicher zur Verfuegung
49 #define	eERR_UNKN_WK	SCERR_IMPORT_UNKNOWN_WK		// unbekanntes WK?-Format (Lotus 1-2-3)
50 #define	eERR_FORMAT		SCERR_IMPORT_FORMAT			// Formatfehler beim Lesen (kein Formel-Fehler!)
51 #define	eERR_NI			SCERR_IMPORT_NI				// Nicht implementierter Filter
52 #define	eERR_UNKN_BIFF	SCERR_IMPORT_UNKNOWN_BIFF	// unbekanntes BIFF-Format (Excel)
53 #define	eERR_NI_BIFF	SCERR_IMPORT_NI_BIFF		// nicht implementiertes BIFF-Format
54 #define	eERR_FILEPASSWD	SCERR_IMPORT_FILEPASSWD		// File Passwordgeschuetzt
55 #define	eERR_INTERN		SCERR_IMPORT_INTERNAL		// interner Fehler
56 #define	eERR_RNGOVRFLW	SCWARN_IMPORT_RANGE_OVERFLOW// ueberlauf der Zellkoordinaten:
57 													//	Tabelle abgschnitten auf erlaubtem Bereich
58 // mehr Fehlercodes siehe scerrors.hxx
59 
60 //	};
61 
62 
63 // fuer Import
64 enum EXCIMPFORMAT { EIF_AUTO, EIF_BIFF5, EIF_BIFF8, EIF_BIFF_LE4 };
65 
66 // fuer Export
67 enum ExportFormatLotus { ExpWK1, ExpWK3, ExpWK4 };
68 enum ExportFormatExcel { ExpBiff2, ExpBiff3, ExpBiff4, ExpBiff4W, ExpBiff5, ExpBiff8, Exp2007Xml };
69 
70 
71 // Optionen fuer DIF-Im-/Export (Kombination ueber '|')
72 #define	SC_DIFOPT_PLAIN		0x00000000
73 #define SC_DIFOPT_DATE		0x00000001
74 #define SC_DIFOPT_TIME		0x00000002
75 #define SC_DIFOPT_CURRENCY	0x00000004
76 
77 #define SC_DIFOPT_EXCEL		(SC_DIFOPT_DATE|SC_DIFOPT_TIME|SC_DIFOPT_CURRENCY)
78 
79 // These are implemented inside the scfilt library and lazy loaded
80 
81 class ScRTFImport;
82 class ScHTMLImport;
83 
84 class ScEEAbsImport {
85   public:
~ScEEAbsImport()86     virtual ~ScEEAbsImport() {}
87     virtual sal_uLong   Read( SvStream& rStream, const String& rBaseURL ) = 0;
88     virtual ScRange GetRange() = 0;
89     virtual void    WriteToDocument(
90         sal_Bool bSizeColsRows = sal_False, double nOutputFactor = 1.0,
91         SvNumberFormatter* pFormatter = NULL, bool bConvertDate = true ) = 0;
92 };
93 
94 class ScFormatFilterPlugin {
95   public:
96     // various import filters
97     virtual FltError ScImportLotus123( SfxMedium&, ScDocument*, CharSet eSrc = RTL_TEXTENCODING_DONTKNOW ) = 0;
98     virtual FltError ScImportQuattroPro( SfxMedium &rMedium, ScDocument *pDoc ) = 0;
99     virtual FltError ScImportExcel( SfxMedium&, ScDocument*, const EXCIMPFORMAT ) = 0;
100         // eFormat == EIF_AUTO	-> passender Filter wird automatisch verwendet
101         // eFormat == EIF_BIFF5	-> nur Biff5-Stream fuehrt zum Erfolg (auch wenn in einem Excel97-Doc)
102         // eFormat == EIF_BIFF8	-> nur Biff8-Stream fuehrt zum Erfolg (nur in Excel97-Docs)
103         // eFormat == EIF_BIFF_LE4 -> nur Nicht-Storage-Dateien _koennen_ zum Erfolg fuehren
104     virtual FltError ScImportStarCalc10( SvStream&, ScDocument* ) = 0;
105     virtual FltError ScImportDif( SvStream&, ScDocument*, const ScAddress& rInsPos,
106 				 const CharSet eSrc = RTL_TEXTENCODING_DONTKNOW, sal_uInt32 nDifOption = SC_DIFOPT_EXCEL ) = 0;
107     virtual FltError ScImportRTF( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange ) = 0;
108     virtual FltError ScImportHTML( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange, double nOutputFactor = 1.0,
109                                    sal_Bool bCalcWidthHeight = sal_True, SvNumberFormatter* pFormatter = NULL, bool bConvertDate = true ) = 0;
110 
111     // various import helpers
112     virtual ScEEAbsImport *CreateRTFImport( ScDocument* pDoc, const ScRange& rRange ) = 0;
113     virtual ScEEAbsImport *CreateHTMLImport( ScDocument* pDocP, const String& rBaseURL, const ScRange& rRange, sal_Bool bCalcWidthHeight ) = 0;
114     virtual String         GetHTMLRangeNameList( ScDocument* pDoc, const String& rOrigName ) = 0;
115 
116     // various export filters
117 #if ENABLE_LOTUS123_EXPORT
118     virtual FltError ScExportLotus123( SvStream&, ScDocument*, ExportFormatLotus, CharSet eDest ) = 0;
119 #endif
120     virtual FltError ScExportExcel5( SfxMedium&, ScDocument*, ExportFormatExcel eFormat, CharSet eDest ) = 0;
121     virtual FltError ScExportDif( SvStream&, ScDocument*, const ScAddress& rOutPos, const CharSet eDest,
122                                  sal_uInt32 nDifOption = SC_DIFOPT_EXCEL ) = 0;
123     virtual FltError ScExportDif( SvStream&, ScDocument*, const ScRange& rRange, const CharSet eDest,
124 				 sal_uInt32 nDifOption = SC_DIFOPT_EXCEL ) = 0;
125     virtual FltError ScExportHTML( SvStream&, const String& rBaseURL, ScDocument*, const ScRange& rRange, const CharSet eDest, sal_Bool bAll,
126 				  const String& rStreamPath, String& rNonConvertibleChars ) = 0;
127     virtual FltError ScExportRTF( SvStream&, ScDocument*, const ScRange& rRange, const CharSet eDest ) = 0;
128 };
129 
130 // scfilt plugin symbol
131 extern "C" {
132   SAL_DLLPUBLIC_EXPORT ScFormatFilterPlugin * SAL_CALL ScFilterCreate(void);
133 }
134 
135 class ScFormatFilter {
136     public:
137 	static ScFormatFilterPlugin &Get();
138 };
139 
140 #endif
141 
142