xref: /AOO41X/main/sc/inc/filter.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_FILTER_HXX
29 #define SC_FILTER_HXX
30 
31 #include <tools/string.hxx>
32 #include <rtl/textenc.h>
33 
34 #define ENABLE_LOTUS123_EXPORT 0
35 
36 class SfxMedium;
37 class SvStream;
38 
39 class ScAddress;
40 class ScDocument;
41 class ScRange;
42 class SvNumberFormatter;
43 
44 // Return-Werte Im-/Exportfilter	(sal_uLong)
45 
46 typedef sal_uLong FltError;
47 //enum FltError {
48 
49 #define eERR_OK  		ERRCODE_NONE				// kein Fehler, alles OK
50 #define	eERR_OPEN		SCERR_IMPORT_OPEN			// ...
51 #define	eERR_UNBEK		SCERR_IMPORT_UNKNOWN		// unbekannter Fehler, auch historische Bedeutung
52 #define	eERR_NOMEM		SCERR_IMPORT_OUTOFMEM		// nicht mehr genuegend Speicher zur Verfuegung
53 #define	eERR_UNKN_WK	SCERR_IMPORT_UNKNOWN_WK		// unbekanntes WK?-Format (Lotus 1-2-3)
54 #define	eERR_FORMAT		SCERR_IMPORT_FORMAT			// Formatfehler beim Lesen (kein Formel-Fehler!)
55 #define	eERR_NI			SCERR_IMPORT_NI				// Nicht implementierter Filter
56 #define	eERR_UNKN_BIFF	SCERR_IMPORT_UNKNOWN_BIFF	// unbekanntes BIFF-Format (Excel)
57 #define	eERR_NI_BIFF	SCERR_IMPORT_NI_BIFF		// nicht implementiertes BIFF-Format
58 #define	eERR_FILEPASSWD	SCERR_IMPORT_FILEPASSWD		// File Passwordgeschuetzt
59 #define	eERR_INTERN		SCERR_IMPORT_INTERNAL		// interner Fehler
60 #define	eERR_RNGOVRFLW	SCWARN_IMPORT_RANGE_OVERFLOW// ueberlauf der Zellkoordinaten:
61 													//	Tabelle abgschnitten auf erlaubtem Bereich
62 // mehr Fehlercodes siehe scerrors.hxx
63 
64 //	};
65 
66 
67 // fuer Import
68 enum EXCIMPFORMAT { EIF_AUTO, EIF_BIFF5, EIF_BIFF8, EIF_BIFF_LE4 };
69 
70 // fuer Export
71 enum ExportFormatLotus { ExpWK1, ExpWK3, ExpWK4 };
72 enum ExportFormatExcel { ExpBiff2, ExpBiff3, ExpBiff4, ExpBiff4W, ExpBiff5, ExpBiff8, Exp2007Xml };
73 
74 
75 // Optionen fuer DIF-Im-/Export (Kombination ueber '|')
76 #define	SC_DIFOPT_PLAIN		0x00000000
77 #define SC_DIFOPT_DATE		0x00000001
78 #define SC_DIFOPT_TIME		0x00000002
79 #define SC_DIFOPT_CURRENCY	0x00000004
80 
81 #define SC_DIFOPT_EXCEL		(SC_DIFOPT_DATE|SC_DIFOPT_TIME|SC_DIFOPT_CURRENCY)
82 
83 // These are implemented inside the scfilt library and lazy loaded
84 
85 class ScRTFImport;
86 class ScHTMLImport;
87 
88 class ScEEAbsImport {
89   public:
90     virtual ~ScEEAbsImport() {}
91     virtual sal_uLong   Read( SvStream& rStream, const String& rBaseURL ) = 0;
92     virtual ScRange GetRange() = 0;
93     virtual void    WriteToDocument(
94         sal_Bool bSizeColsRows = sal_False, double nOutputFactor = 1.0,
95         SvNumberFormatter* pFormatter = NULL, bool bConvertDate = true ) = 0;
96 };
97 
98 class ScFormatFilterPlugin {
99   public:
100     // various import filters
101     virtual FltError ScImportLotus123( SfxMedium&, ScDocument*, CharSet eSrc = RTL_TEXTENCODING_DONTKNOW ) = 0;
102     virtual FltError ScImportQuattroPro( SfxMedium &rMedium, ScDocument *pDoc ) = 0;
103     virtual FltError ScImportExcel( SfxMedium&, ScDocument*, const EXCIMPFORMAT ) = 0;
104         // eFormat == EIF_AUTO	-> passender Filter wird automatisch verwendet
105         // eFormat == EIF_BIFF5	-> nur Biff5-Stream fuehrt zum Erfolg (auch wenn in einem Excel97-Doc)
106         // eFormat == EIF_BIFF8	-> nur Biff8-Stream fuehrt zum Erfolg (nur in Excel97-Docs)
107         // eFormat == EIF_BIFF_LE4 -> nur Nicht-Storage-Dateien _koennen_ zum Erfolg fuehren
108     virtual FltError ScImportStarCalc10( SvStream&, ScDocument* ) = 0;
109     virtual FltError ScImportDif( SvStream&, ScDocument*, const ScAddress& rInsPos,
110 				 const CharSet eSrc = RTL_TEXTENCODING_DONTKNOW, sal_uInt32 nDifOption = SC_DIFOPT_EXCEL ) = 0;
111     virtual FltError ScImportRTF( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange ) = 0;
112     virtual FltError ScImportHTML( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange, double nOutputFactor = 1.0,
113                                    sal_Bool bCalcWidthHeight = sal_True, SvNumberFormatter* pFormatter = NULL, bool bConvertDate = true ) = 0;
114 
115     // various import helpers
116     virtual ScEEAbsImport *CreateRTFImport( ScDocument* pDoc, const ScRange& rRange ) = 0;
117     virtual ScEEAbsImport *CreateHTMLImport( ScDocument* pDocP, const String& rBaseURL, const ScRange& rRange, sal_Bool bCalcWidthHeight ) = 0;
118     virtual String         GetHTMLRangeNameList( ScDocument* pDoc, const String& rOrigName ) = 0;
119 
120     // various export filters
121 #if ENABLE_LOTUS123_EXPORT
122     virtual FltError ScExportLotus123( SvStream&, ScDocument*, ExportFormatLotus, CharSet eDest ) = 0;
123 #endif
124     virtual FltError ScExportExcel5( SfxMedium&, ScDocument*, ExportFormatExcel eFormat, CharSet eDest ) = 0;
125     virtual FltError ScExportDif( SvStream&, ScDocument*, const ScAddress& rOutPos, const CharSet eDest,
126                                  sal_uInt32 nDifOption = SC_DIFOPT_EXCEL ) = 0;
127     virtual FltError ScExportDif( SvStream&, ScDocument*, const ScRange& rRange, const CharSet eDest,
128 				 sal_uInt32 nDifOption = SC_DIFOPT_EXCEL ) = 0;
129     virtual FltError ScExportHTML( SvStream&, const String& rBaseURL, ScDocument*, const ScRange& rRange, const CharSet eDest, sal_Bool bAll,
130 				  const String& rStreamPath, String& rNonConvertibleChars ) = 0;
131     virtual FltError ScExportRTF( SvStream&, ScDocument*, const ScRange& rRange, const CharSet eDest ) = 0;
132 };
133 
134 // scfilt plugin symbol
135 extern "C" {
136   ScFormatFilterPlugin * SAL_CALL ScFilterCreate(void);
137 }
138 
139 class ScFormatFilter {
140     public:
141 	static ScFormatFilterPlugin &Get();
142 };
143 
144 #endif
145 
146