xref: /aoo41x/main/sc/source/filter/inc/htmlexp.hxx (revision 38d50f7b)
1*38d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*38d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*38d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*38d50f7bSAndrew Rist  * distributed with this work for additional information
6*38d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*38d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*38d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
9*38d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*38d50f7bSAndrew Rist  *
11*38d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*38d50f7bSAndrew Rist  *
13*38d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*38d50f7bSAndrew Rist  * software distributed under the License is distributed on an
15*38d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*38d50f7bSAndrew Rist  * specific language governing permissions and limitations
18*38d50f7bSAndrew Rist  * under the License.
19*38d50f7bSAndrew Rist  *
20*38d50f7bSAndrew Rist  *************************************************************/
21*38d50f7bSAndrew Rist 
22*38d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SC_HTMLEXP_HXX
25cdf0e10cSrcweir #define SC_HTMLEXP_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "global.hxx"
28cdf0e10cSrcweir #include <rtl/textenc.h>
29cdf0e10cSrcweir #include <tools/gen.hxx>
30cdf0e10cSrcweir #include <tools/color.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "expbase.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
35cdf0e10cSrcweir class ScDocument;
36cdf0e10cSrcweir class SfxItemSet;
37cdf0e10cSrcweir class SdrPage;
38cdf0e10cSrcweir class Graphic;
39cdf0e10cSrcweir class SdrObject;
40cdf0e10cSrcweir class OutputDevice;
41cdf0e10cSrcweir class ScDrawLayer;
42cdf0e10cSrcweir class SvStringsSortDtor;
43cdf0e10cSrcweir class ScEditCell;
44cdf0e10cSrcweir class SvxBorderLine;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir struct ScHTMLStyle
47cdf0e10cSrcweir {	// Defaults aus StyleSheet
48cdf0e10cSrcweir 	Color				aBackgroundColor;
49cdf0e10cSrcweir 	String 				aFontFamilyName;
50cdf0e10cSrcweir 	sal_uInt32				nFontHeight;		// Item-Value
51cdf0e10cSrcweir     sal_uInt16              nFontSizeNumber;    // HTML value 1-7
52cdf0e10cSrcweir     sal_uInt8                nDefaultScriptType; // Font values are valid for the default script type
53cdf0e10cSrcweir     sal_Bool                bInitialized;
54cdf0e10cSrcweir 
ScHTMLStyleScHTMLStyle55cdf0e10cSrcweir     ScHTMLStyle() : nFontHeight(0), nFontSizeNumber(2), nDefaultScriptType(0),
56cdf0e10cSrcweir         bInitialized(0) {}
57cdf0e10cSrcweir 
operator =ScHTMLStyle58cdf0e10cSrcweir 	const ScHTMLStyle& operator=( const ScHTMLStyle& r )
59cdf0e10cSrcweir 		{
60cdf0e10cSrcweir 			aBackgroundColor	= r.aBackgroundColor;
61cdf0e10cSrcweir 			aFontFamilyName		= r.aFontFamilyName;
62cdf0e10cSrcweir 			nFontHeight			= r.nFontHeight;
63cdf0e10cSrcweir             nFontSizeNumber     = r.nFontSizeNumber;
64cdf0e10cSrcweir             nDefaultScriptType  = r.nDefaultScriptType;
65cdf0e10cSrcweir             bInitialized        = r.bInitialized;
66cdf0e10cSrcweir 			return *this;
67cdf0e10cSrcweir 		}
68cdf0e10cSrcweir };
69cdf0e10cSrcweir 
70cdf0e10cSrcweir struct ScHTMLGraphEntry
71cdf0e10cSrcweir {
72cdf0e10cSrcweir 	ScRange				aRange;			// ueberlagerter Zellbereich
73cdf0e10cSrcweir 	Size				aSize;			// Groesse in Pixeln
74cdf0e10cSrcweir 	Size				aSpace;			// Spacing in Pixeln
75cdf0e10cSrcweir 	SdrObject*			pObject;
76cdf0e10cSrcweir 	sal_Bool				bInCell;		// ob in Zelle ausgegeben wird
77cdf0e10cSrcweir 	sal_Bool				bWritten;
78cdf0e10cSrcweir 
ScHTMLGraphEntryScHTMLGraphEntry79cdf0e10cSrcweir 	ScHTMLGraphEntry( SdrObject* pObj, const ScRange& rRange,
80cdf0e10cSrcweir 		const Size& rSize, 	sal_Bool bIn, const Size& rSpace ) :
81cdf0e10cSrcweir         aRange( rRange ), aSize( rSize ), aSpace( rSpace ),
82cdf0e10cSrcweir         pObject( pObj ), bInCell( bIn ), bWritten( sal_False ) {}
83cdf0e10cSrcweir };
84cdf0e10cSrcweir 
85cdf0e10cSrcweir DECLARE_LIST( ScHTMLGraphList, ScHTMLGraphEntry* )
86cdf0e10cSrcweir 
87cdf0e10cSrcweir #define SC_HTML_FONTSIZES 7
88cdf0e10cSrcweir const short nIndentMax = 23;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir class ScHTMLExport : public ScExportBase
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	// default HtmlFontSz[1-7]
93cdf0e10cSrcweir 	static const sal_uInt16	nDefaultFontSize[SC_HTML_FONTSIZES];
94cdf0e10cSrcweir 	// HtmlFontSz[1-7] in s*3.ini [user]
95cdf0e10cSrcweir 	static sal_uInt16		nFontSize[SC_HTML_FONTSIZES];
96cdf0e10cSrcweir 	static const char*	pFontSizeCss[SC_HTML_FONTSIZES];
97cdf0e10cSrcweir 	static const sal_uInt16	nCellSpacing;
98cdf0e10cSrcweir 	static const sal_Char __FAR_DATA sIndentSource[];
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	ScHTMLGraphList		aGraphList;
101cdf0e10cSrcweir 	ScHTMLStyle			aHTMLStyle;
102cdf0e10cSrcweir     String              aBaseURL;
103cdf0e10cSrcweir 	String				aStreamPath;
104cdf0e10cSrcweir 	String				aCId;			// Content-Id fuer Mail-Export
105cdf0e10cSrcweir 	OutputDevice*		pAppWin;		// fuer Pixelei
106cdf0e10cSrcweir 	SvStringsSortDtor*	pSrcArr;		// fuer CopyLocalFileToINet
107cdf0e10cSrcweir 	SvStringsSortDtor*	pDestArr;
108cdf0e10cSrcweir     String              aNonConvertibleChars;   // collect nonconvertible characters
109cdf0e10cSrcweir 	rtl_TextEncoding	eDestEnc;
110cdf0e10cSrcweir 	SCTAB				nUsedTables;
111cdf0e10cSrcweir 	short				nIndent;
112cdf0e10cSrcweir 	sal_Char			sIndent[nIndentMax+1];
113cdf0e10cSrcweir 	sal_Bool				bAll;			// ganzes Dokument
114cdf0e10cSrcweir 	sal_Bool				bTabHasGraphics;
115cdf0e10cSrcweir 	sal_Bool				bTabAlignedLeft;
116cdf0e10cSrcweir 	sal_Bool				bCalcAsShown;
117cdf0e10cSrcweir 	sal_Bool				bCopyLocalFileToINet;
118cdf0e10cSrcweir     sal_Bool                bTableDataWidth;
119cdf0e10cSrcweir     sal_Bool                bTableDataHeight;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	const SfxItemSet&	PageDefaults( SCTAB nTab );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     void                WriteBody();
124cdf0e10cSrcweir 	void 				WriteHeader();
125cdf0e10cSrcweir 	void 				WriteOverview();
126cdf0e10cSrcweir 	void 				WriteTables();
127cdf0e10cSrcweir 	void 				WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab );
128cdf0e10cSrcweir 	void				WriteGraphEntry( ScHTMLGraphEntry* );
129cdf0e10cSrcweir     void                WriteImage( String& rLinkName,
130cdf0e10cSrcweir 									const Graphic&, const ByteString& rImgOptions,
131cdf0e10cSrcweir 									sal_uLong nXOutFlags = 0 );
132cdf0e10cSrcweir 							// nXOutFlags fuer XOutBitmap::WriteGraphic
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 						// write to stream if and only if URL fields in edit cell
135cdf0e10cSrcweir 	sal_Bool				WriteFieldText( const ScEditCell* pCell );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 						// kopiere ggfs. eine lokale Datei ins Internet
138cdf0e10cSrcweir 	sal_Bool 				CopyLocalFileToINet( String& rFileNm,
139cdf0e10cSrcweir 							const String& rTargetNm, sal_Bool bFileToFile = sal_False );
HasCId()140cdf0e10cSrcweir 	sal_Bool				HasCId() { return aCId.Len() > 0; }
141cdf0e10cSrcweir 	void				MakeCIdURL( String& rURL );
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 	void				PrepareGraphics( ScDrawLayer*, SCTAB nTab,
144cdf0e10cSrcweir 										SCCOL nStartCol, SCROW nStartRow,
145cdf0e10cSrcweir 										SCCOL nEndCol, SCROW nEndRow );
146cdf0e10cSrcweir 	void				FillGraphList( const SdrPage*, SCTAB nTab,
147cdf0e10cSrcweir 										SCCOL nStartCol, SCROW nStartRow,
148cdf0e10cSrcweir 										SCCOL nEndCol, SCROW nEndRow );
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	void				BorderToStyle( ByteString& rOut, const char* pBorderName,
151cdf0e10cSrcweir 									   const SvxBorderLine* pLine, bool& bInsertSemicolon );
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 	sal_uInt16				GetFontSizeNumber( sal_uInt16 nHeight );
154cdf0e10cSrcweir 	const char*			GetFontSizeCss( sal_uInt16 nHeight );
155cdf0e10cSrcweir 	sal_uInt16				ToPixel( sal_uInt16 nTwips );
156cdf0e10cSrcweir 	Size				MMToPixel( const Size& r100thMMSize );
157cdf0e10cSrcweir 	void				IncIndent( short nVal );
GetIndentStr()158cdf0e10cSrcweir 	const sal_Char*			GetIndentStr() { return sIndent; }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir public:
161cdf0e10cSrcweir                         ScHTMLExport( SvStream&, const String&, ScDocument*, const ScRange&,
162cdf0e10cSrcweir 										sal_Bool bAll, const String& aStreamPath );
163cdf0e10cSrcweir 	virtual				~ScHTMLExport();
164cdf0e10cSrcweir     sal_uLong               Write();
GetNonConvertibleChars() const165cdf0e10cSrcweir     const String&       GetNonConvertibleChars() const
166cdf0e10cSrcweir                             { return aNonConvertibleChars; }
167cdf0e10cSrcweir };
168cdf0e10cSrcweir 
169cdf0e10cSrcweir #endif
170cdf0e10cSrcweir 
171