xref: /aoo4110/main/sc/source/filter/inc/htmlexp.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_HTMLEXP_HXX
25 #define SC_HTMLEXP_HXX
26 
27 #include "global.hxx"
28 #include <rtl/textenc.h>
29 #include <tools/gen.hxx>
30 #include <tools/color.hxx>
31 
32 #include "expbase.hxx"
33 
34 
35 class ScDocument;
36 class SfxItemSet;
37 class SdrPage;
38 class Graphic;
39 class SdrObject;
40 class OutputDevice;
41 class ScDrawLayer;
42 class SvStringsSortDtor;
43 class ScEditCell;
44 class SvxBorderLine;
45 
46 struct ScHTMLStyle
47 {	// Defaults aus StyleSheet
48 	Color				aBackgroundColor;
49 	String 				aFontFamilyName;
50 	sal_uInt32				nFontHeight;		// Item-Value
51     sal_uInt16              nFontSizeNumber;    // HTML value 1-7
52     sal_uInt8                nDefaultScriptType; // Font values are valid for the default script type
53     sal_Bool                bInitialized;
54 
ScHTMLStyleScHTMLStyle55     ScHTMLStyle() : nFontHeight(0), nFontSizeNumber(2), nDefaultScriptType(0),
56         bInitialized(0) {}
57 
operator =ScHTMLStyle58 	const ScHTMLStyle& operator=( const ScHTMLStyle& r )
59 		{
60 			aBackgroundColor	= r.aBackgroundColor;
61 			aFontFamilyName		= r.aFontFamilyName;
62 			nFontHeight			= r.nFontHeight;
63             nFontSizeNumber     = r.nFontSizeNumber;
64             nDefaultScriptType  = r.nDefaultScriptType;
65             bInitialized        = r.bInitialized;
66 			return *this;
67 		}
68 };
69 
70 struct ScHTMLGraphEntry
71 {
72 	ScRange				aRange;			// ueberlagerter Zellbereich
73 	Size				aSize;			// Groesse in Pixeln
74 	Size				aSpace;			// Spacing in Pixeln
75 	SdrObject*			pObject;
76 	sal_Bool				bInCell;		// ob in Zelle ausgegeben wird
77 	sal_Bool				bWritten;
78 
ScHTMLGraphEntryScHTMLGraphEntry79 	ScHTMLGraphEntry( SdrObject* pObj, const ScRange& rRange,
80 		const Size& rSize, 	sal_Bool bIn, const Size& rSpace ) :
81         aRange( rRange ), aSize( rSize ), aSpace( rSpace ),
82         pObject( pObj ), bInCell( bIn ), bWritten( sal_False ) {}
83 };
84 
85 DECLARE_LIST( ScHTMLGraphList, ScHTMLGraphEntry* )
86 
87 #define SC_HTML_FONTSIZES 7
88 const short nIndentMax = 23;
89 
90 class ScHTMLExport : public ScExportBase
91 {
92 	// default HtmlFontSz[1-7]
93 	static const sal_uInt16	nDefaultFontSize[SC_HTML_FONTSIZES];
94 	// HtmlFontSz[1-7] in s*3.ini [user]
95 	static sal_uInt16		nFontSize[SC_HTML_FONTSIZES];
96 	static const char*	pFontSizeCss[SC_HTML_FONTSIZES];
97 	static const sal_uInt16	nCellSpacing;
98 	static const sal_Char __FAR_DATA sIndentSource[];
99 
100 	ScHTMLGraphList		aGraphList;
101 	ScHTMLStyle			aHTMLStyle;
102     String              aBaseURL;
103 	String				aStreamPath;
104 	String				aCId;			// Content-Id fuer Mail-Export
105 	OutputDevice*		pAppWin;		// fuer Pixelei
106 	SvStringsSortDtor*	pSrcArr;		// fuer CopyLocalFileToINet
107 	SvStringsSortDtor*	pDestArr;
108     String              aNonConvertibleChars;   // collect nonconvertible characters
109 	rtl_TextEncoding	eDestEnc;
110 	SCTAB				nUsedTables;
111 	short				nIndent;
112 	sal_Char			sIndent[nIndentMax+1];
113 	sal_Bool				bAll;			// ganzes Dokument
114 	sal_Bool				bTabHasGraphics;
115 	sal_Bool				bTabAlignedLeft;
116 	sal_Bool				bCalcAsShown;
117 	sal_Bool				bCopyLocalFileToINet;
118     sal_Bool                bTableDataWidth;
119     sal_Bool                bTableDataHeight;
120 
121 	const SfxItemSet&	PageDefaults( SCTAB nTab );
122 
123     void                WriteBody();
124 	void 				WriteHeader();
125 	void 				WriteOverview();
126 	void 				WriteTables();
127 	void 				WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab );
128 	void				WriteGraphEntry( ScHTMLGraphEntry* );
129     void                WriteImage( String& rLinkName,
130 									const Graphic&, const ByteString& rImgOptions,
131 									sal_uLong nXOutFlags = 0 );
132 							// nXOutFlags fuer XOutBitmap::WriteGraphic
133 
134 						// write to stream if and only if URL fields in edit cell
135 	sal_Bool				WriteFieldText( const ScEditCell* pCell );
136 
137 						// kopiere ggfs. eine lokale Datei ins Internet
138 	sal_Bool 				CopyLocalFileToINet( String& rFileNm,
139 							const String& rTargetNm, sal_Bool bFileToFile = sal_False );
HasCId()140 	sal_Bool				HasCId() { return aCId.Len() > 0; }
141 	void				MakeCIdURL( String& rURL );
142 
143 	void				PrepareGraphics( ScDrawLayer*, SCTAB nTab,
144 										SCCOL nStartCol, SCROW nStartRow,
145 										SCCOL nEndCol, SCROW nEndRow );
146 	void				FillGraphList( const SdrPage*, SCTAB nTab,
147 										SCCOL nStartCol, SCROW nStartRow,
148 										SCCOL nEndCol, SCROW nEndRow );
149 
150 	void				BorderToStyle( ByteString& rOut, const char* pBorderName,
151 									   const SvxBorderLine* pLine, bool& bInsertSemicolon );
152 
153 	sal_uInt16				GetFontSizeNumber( sal_uInt16 nHeight );
154 	const char*			GetFontSizeCss( sal_uInt16 nHeight );
155 	sal_uInt16				ToPixel( sal_uInt16 nTwips );
156 	Size				MMToPixel( const Size& r100thMMSize );
157 	void				IncIndent( short nVal );
GetIndentStr()158 	const sal_Char*			GetIndentStr() { return sIndent; }
159 
160 public:
161                         ScHTMLExport( SvStream&, const String&, ScDocument*, const ScRange&,
162 										sal_Bool bAll, const String& aStreamPath );
163 	virtual				~ScHTMLExport();
164     sal_uLong               Write();
GetNonConvertibleChars() const165     const String&       GetNonConvertibleChars() const
166                             { return aNonConvertibleChars; }
167 };
168 
169 #endif
170 
171