1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*96de5490SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*96de5490SAndrew Rist  * distributed with this work for additional information
6*96de5490SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*96de5490SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist  * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*96de5490SAndrew Rist  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*96de5490SAndrew Rist  *
13*96de5490SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist  * software distributed under the License is distributed on an
15*96de5490SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist  * KIND, either express or implied.  See the License for the
17*96de5490SAndrew Rist  * specific language governing permissions and limitations
18*96de5490SAndrew Rist  * under the License.
19*96de5490SAndrew Rist  *
20*96de5490SAndrew Rist  *************************************************************/
21*96de5490SAndrew Rist 
22*96de5490SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir #include "HtmlReader.hxx"
27cdf0e10cSrcweir #include <connectivity/dbconversion.hxx>
28cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
29cdf0e10cSrcweir #include <tools/tenccvt.hxx>
30cdf0e10cSrcweir #include <comphelper/extract.hxx>
31cdf0e10cSrcweir #include "dbu_misc.hrc"
32cdf0e10cSrcweir #include "dbustrings.hrc"
33cdf0e10cSrcweir #include <sfx2/sfxhtml.hxx>
34cdf0e10cSrcweir #include <tools/debug.hxx>
35cdf0e10cSrcweir #include <tools/tenccvt.hxx>
36cdf0e10cSrcweir #include "moduledbu.hxx"
37cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
38cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
39cdf0e10cSrcweir #include <com/sun/star/sdbcx/XAppend.hpp>
40cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
41cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp>
42cdf0e10cSrcweir #include <com/sun/star/awt/FontDescriptor.hpp>
43cdf0e10cSrcweir #include <com/sun/star/awt/FontWeight.hpp>
44cdf0e10cSrcweir #include <com/sun/star/awt/FontStrikeout.hpp>
45cdf0e10cSrcweir #include <com/sun/star/awt/FontSlant.hpp>
46cdf0e10cSrcweir #include <com/sun/star/awt/FontUnderline.hpp>
47cdf0e10cSrcweir #include <com/sun/star/util/NumberFormat.hpp>
48cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatTypes.hpp>
49cdf0e10cSrcweir #include <svtools/htmltokn.h>
50cdf0e10cSrcweir #include <svtools/htmlkywd.hxx>
51cdf0e10cSrcweir #include <tools/color.hxx>
52cdf0e10cSrcweir #include "WCopyTable.hxx"
53cdf0e10cSrcweir #include "WExtendPages.hxx"
54cdf0e10cSrcweir #include "WNameMatch.hxx"
55cdf0e10cSrcweir #include "WColumnSelect.hxx"
56cdf0e10cSrcweir #include "QEnumTypes.hxx"
57cdf0e10cSrcweir #include "WCPage.hxx"
58cdf0e10cSrcweir #include <tools/inetmime.hxx>
59cdf0e10cSrcweir #include <svl/inettype.hxx>
60cdf0e10cSrcweir #include <rtl/tencinfo.h>
61cdf0e10cSrcweir #include "UITools.hxx"
62cdf0e10cSrcweir #include <vcl/svapp.hxx>
63cdf0e10cSrcweir #include <rtl/logfile.hxx>
64cdf0e10cSrcweir 
65cdf0e10cSrcweir using namespace dbaui;
66cdf0e10cSrcweir using namespace ::com::sun::star::uno;
67cdf0e10cSrcweir using namespace ::com::sun::star::beans;
68cdf0e10cSrcweir using namespace ::com::sun::star::container;
69cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
70cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
71cdf0e10cSrcweir using namespace ::com::sun::star::awt;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir #define DBAUI_HTML_FONTSIZES	8		// wie Export, HTML-Options
74cdf0e10cSrcweir #define HTML_META_NONE			0
75cdf0e10cSrcweir #define HTML_META_AUTHOR		1
76cdf0e10cSrcweir #define HTML_META_DESCRIPTION	2
77cdf0e10cSrcweir #define HTML_META_KEYWORDS		3
78cdf0e10cSrcweir #define HTML_META_REFRESH		4
79cdf0e10cSrcweir #define HTML_META_CLASSIFICATION 5
80cdf0e10cSrcweir #define HTML_META_CREATED		6
81cdf0e10cSrcweir #define HTML_META_CHANGEDBY		7
82cdf0e10cSrcweir #define HTML_META_CHANGED		8
83cdf0e10cSrcweir #define HTML_META_GENERATOR		9
84cdf0e10cSrcweir #define HTML_META_SDFOOTNOTE	10
85cdf0e10cSrcweir #define HTML_META_SDENDNOTE		11
86cdf0e10cSrcweir #define HTML_META_CONTENT_TYPE	12
87cdf0e10cSrcweir 
88cdf0e10cSrcweir // ==========================================================================
DBG_NAME(OHTMLReader)89cdf0e10cSrcweir DBG_NAME(OHTMLReader)
90cdf0e10cSrcweir // ==========================================================================
91cdf0e10cSrcweir // OHTMLReader
92cdf0e10cSrcweir // ==========================================================================
93cdf0e10cSrcweir OHTMLReader::OHTMLReader(SvStream& rIn,const SharedConnection& _rxConnection,
94cdf0e10cSrcweir 						const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
95cdf0e10cSrcweir 						const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
96cdf0e10cSrcweir 						const TColumnVector* pList,
97cdf0e10cSrcweir 						const OTypeInfoMap* _pInfoMap)
98cdf0e10cSrcweir 	:HTMLParser(rIn)
99cdf0e10cSrcweir 	,ODatabaseExport( _rxConnection, _rxNumberF, _rM, pList, _pInfoMap, rIn )
100cdf0e10cSrcweir 	,m_nTableCount(0)
101cdf0e10cSrcweir 	,m_nColumnWidth(87)
102cdf0e10cSrcweir 	,m_bMetaOptions(sal_False)
103cdf0e10cSrcweir 	,m_bSDNum(sal_False)
104cdf0e10cSrcweir {
105cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::OHTMLReader" );
106cdf0e10cSrcweir 	DBG_CTOR(OHTMLReader,NULL);
107cdf0e10cSrcweir 	SetSrcEncoding( GetExtendedCompatibilityTextEncoding(  RTL_TEXTENCODING_ISO_8859_1 ) );
108cdf0e10cSrcweir     // If the file starts with a BOM, switch to UCS2.
109cdf0e10cSrcweir     SetSwitchToUCS2( sal_True );
110cdf0e10cSrcweir }
111cdf0e10cSrcweir // ---------------------------------------------------------------------------
OHTMLReader(SvStream & rIn,sal_Int32 nRows,const TPositions & _rColumnPositions,const Reference<::com::sun::star::util::XNumberFormatter> & _rxNumberF,const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & _rM,const TColumnVector * pList,const OTypeInfoMap * _pInfoMap,sal_Bool _bAutoIncrementEnabled)112cdf0e10cSrcweir OHTMLReader::OHTMLReader(SvStream& rIn,
113cdf0e10cSrcweir 						 sal_Int32 nRows,
114cdf0e10cSrcweir 						 const TPositions &_rColumnPositions,
115cdf0e10cSrcweir 						 const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
116cdf0e10cSrcweir 						 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
117cdf0e10cSrcweir 						 const TColumnVector* pList,
118cdf0e10cSrcweir 						 const OTypeInfoMap* _pInfoMap,
119cdf0e10cSrcweir                          sal_Bool _bAutoIncrementEnabled)
120cdf0e10cSrcweir 	:HTMLParser(rIn)
121cdf0e10cSrcweir 	,ODatabaseExport( nRows, _rColumnPositions, _rxNumberF, _rM, pList, _pInfoMap, _bAutoIncrementEnabled, rIn )
122cdf0e10cSrcweir 	,m_nTableCount(0)
123cdf0e10cSrcweir 	,m_nColumnWidth(87)
124cdf0e10cSrcweir 	,m_bMetaOptions(sal_False)
125cdf0e10cSrcweir 	,m_bSDNum(sal_False)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::OHTMLReader" );
128cdf0e10cSrcweir 	DBG_CTOR(OHTMLReader,NULL);
129cdf0e10cSrcweir 	SetSrcEncoding( GetExtendedCompatibilityTextEncoding(  RTL_TEXTENCODING_ISO_8859_1 ) );
130cdf0e10cSrcweir     // If the file starts with a BOM, switch to UCS2.
131cdf0e10cSrcweir     SetSwitchToUCS2( sal_True );
132cdf0e10cSrcweir }
133cdf0e10cSrcweir // ---------------------------------------------------------------------------
~OHTMLReader()134cdf0e10cSrcweir OHTMLReader::~OHTMLReader()
135cdf0e10cSrcweir {
136cdf0e10cSrcweir 	DBG_DTOR(OHTMLReader,NULL);
137cdf0e10cSrcweir }
138cdf0e10cSrcweir // ---------------------------------------------------------------------------
CallParser()139cdf0e10cSrcweir SvParserState OHTMLReader::CallParser()
140cdf0e10cSrcweir {
141cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::CallParser" );
142cdf0e10cSrcweir 	DBG_CHKTHIS(OHTMLReader,NULL);
143cdf0e10cSrcweir 	rInput.Seek(STREAM_SEEK_TO_BEGIN);
144cdf0e10cSrcweir 	rInput.ResetError();
145cdf0e10cSrcweir 	SvParserState  eParseState = HTMLParser::CallParser();
146cdf0e10cSrcweir 	SetColumnTypes(m_pColumnList,m_pInfoMap);
147cdf0e10cSrcweir 	return m_bFoundTable ? eParseState : SVPAR_ERROR;
148cdf0e10cSrcweir }
149cdf0e10cSrcweir // -----------------------------------------------------------------------------
NextToken(int nToken)150cdf0e10cSrcweir void OHTMLReader::NextToken( int nToken )
151cdf0e10cSrcweir {
152cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::NextToken" );
153cdf0e10cSrcweir 	DBG_CHKTHIS(OHTMLReader,NULL);
154cdf0e10cSrcweir 	if(m_bError || !m_nRows) // falls Fehler oder keine Rows mehr zur "Uberpr"ufung dann gleich zur"uck
155cdf0e10cSrcweir 		return;
156cdf0e10cSrcweir 	if ( nToken ==  HTML_META )
157cdf0e10cSrcweir 		setTextEncoding();
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	if(m_xConnection.is())	  // gibt an welcher CTOR gerufen wurde und damit, ob eine Tabelle erstellt werden soll
160cdf0e10cSrcweir 	{
161cdf0e10cSrcweir 		switch(nToken)
162cdf0e10cSrcweir 		{
163cdf0e10cSrcweir 			case HTML_TABLE_ON:
164cdf0e10cSrcweir 				++m_nTableCount;
165cdf0e10cSrcweir 				{	// es kann auch TD oder TH sein, wenn es vorher kein TABLE gab
166cdf0e10cSrcweir                     const HTMLOptions* pHtmlOptions = GetOptions();
167cdf0e10cSrcweir                     sal_Int16 nArrLen = pHtmlOptions->Count();
168cdf0e10cSrcweir 					for ( sal_Int16 i = 0; i < nArrLen; i++ )
169cdf0e10cSrcweir 					{
170cdf0e10cSrcweir                         const HTMLOption* pOption = (*pHtmlOptions)[i];
171cdf0e10cSrcweir 						switch( pOption->GetToken() )
172cdf0e10cSrcweir 						{
173cdf0e10cSrcweir 							case HTML_O_WIDTH:
174cdf0e10cSrcweir 							{	// Prozent: von Dokumentbreite bzw. aeusserer Zelle
175cdf0e10cSrcweir 								m_nColumnWidth = GetWidthPixel( pOption );
176cdf0e10cSrcweir 							}
177cdf0e10cSrcweir 							break;
178cdf0e10cSrcweir 						}
179cdf0e10cSrcweir 					}
180cdf0e10cSrcweir 				}
181cdf0e10cSrcweir 			case HTML_THEAD_ON:
182cdf0e10cSrcweir 			case HTML_TBODY_ON:
183cdf0e10cSrcweir                 {
184cdf0e10cSrcweir                     sal_uInt32 nTell = rInput.Tell(); // ver�ndert vielleicht die Position des Streams
185cdf0e10cSrcweir 				    if ( !m_xTable.is() )
186cdf0e10cSrcweir                     {// erste Zeile als Header verwenden
187cdf0e10cSrcweir 					    m_bError = !CreateTable(nToken);
188cdf0e10cSrcweir                         if ( m_bAppendFirstLine )
189cdf0e10cSrcweir                             rInput.Seek(nTell);
190cdf0e10cSrcweir                     }
191cdf0e10cSrcweir                 }
192cdf0e10cSrcweir 				break;
193cdf0e10cSrcweir 			case HTML_TABLE_OFF:
194cdf0e10cSrcweir 				if(!--m_nTableCount)
195cdf0e10cSrcweir 				{
196cdf0e10cSrcweir 					m_xTable = NULL;
197cdf0e10cSrcweir 				}
198cdf0e10cSrcweir 				break;
199cdf0e10cSrcweir 			case HTML_TABLEROW_ON:
200cdf0e10cSrcweir 				if ( m_pUpdateHelper.get() )
201cdf0e10cSrcweir 				{
202cdf0e10cSrcweir 					try
203cdf0e10cSrcweir 					{
204cdf0e10cSrcweir 						m_pUpdateHelper->moveToInsertRow(); // sonst neue Zeile anh"angen
205cdf0e10cSrcweir 					}
206cdf0e10cSrcweir 					catch(SQLException& e)
207cdf0e10cSrcweir 					// UpdateFehlerbehandlung
208cdf0e10cSrcweir 					{
209cdf0e10cSrcweir 						showErrorDialog(e);
210cdf0e10cSrcweir 					}
211cdf0e10cSrcweir 				}
212cdf0e10cSrcweir 				else
213cdf0e10cSrcweir 					m_bError = sal_True;
214cdf0e10cSrcweir 				break;
215cdf0e10cSrcweir 			case HTML_TEXTTOKEN:
216cdf0e10cSrcweir 			case HTML_SINGLECHAR:
217cdf0e10cSrcweir 				if ( m_bInTbl ) //&& !m_bSDNum ) // wichtig, da wir sonst auch die Namen der Fonts bekommen
218cdf0e10cSrcweir 				    m_sTextToken += aToken;
219cdf0e10cSrcweir 				break;
220cdf0e10cSrcweir             case HTML_PARABREAK_OFF:
221cdf0e10cSrcweir                 m_sCurrent += m_sTextToken;
222cdf0e10cSrcweir                 break;
223cdf0e10cSrcweir             case HTML_PARABREAK_ON:
224cdf0e10cSrcweir                 m_sTextToken.Erase();
225cdf0e10cSrcweir                 break;
226cdf0e10cSrcweir 			case HTML_TABLEDATA_ON:
227cdf0e10cSrcweir                 fetchOptions();
228cdf0e10cSrcweir 				break;
229cdf0e10cSrcweir 			case HTML_TABLEDATA_OFF:
230cdf0e10cSrcweir 				{
231cdf0e10cSrcweir                     if ( m_sCurrent.Len() )
232cdf0e10cSrcweir                         m_sTextToken = m_sCurrent;
233cdf0e10cSrcweir 					try
234cdf0e10cSrcweir 					{
235cdf0e10cSrcweir 						insertValueIntoColumn();
236cdf0e10cSrcweir 					}
237cdf0e10cSrcweir 					catch(SQLException& e)
238cdf0e10cSrcweir 					// UpdateFehlerbehandlung
239cdf0e10cSrcweir 					{
240cdf0e10cSrcweir 						showErrorDialog(e);
241cdf0e10cSrcweir 					}
242cdf0e10cSrcweir                     m_sCurrent.Erase();
243cdf0e10cSrcweir 					m_nColumnPos++;
244cdf0e10cSrcweir                     eraseTokens();
245cdf0e10cSrcweir 					m_bSDNum = m_bInTbl = sal_False;
246cdf0e10cSrcweir 				}
247cdf0e10cSrcweir 				break;
248cdf0e10cSrcweir 			case HTML_TABLEROW_OFF:
249cdf0e10cSrcweir 				if ( !m_pUpdateHelper.get() )
250cdf0e10cSrcweir 				{
251cdf0e10cSrcweir 					m_bError = sal_True;
252cdf0e10cSrcweir 					break;
253cdf0e10cSrcweir 				}
254cdf0e10cSrcweir 				try
255cdf0e10cSrcweir 				{
256cdf0e10cSrcweir 					m_nRowCount++;
257cdf0e10cSrcweir 					if (m_bIsAutoIncrement) // if bSetAutoIncrement then I have to set the autoincrement
258cdf0e10cSrcweir 						m_pUpdateHelper->updateInt(1,m_nRowCount);
259cdf0e10cSrcweir 					m_pUpdateHelper->insertRow();
260cdf0e10cSrcweir 				}
261cdf0e10cSrcweir 				catch(SQLException& e)
262cdf0e10cSrcweir 				//////////////////////////////////////////////////////////////////////
263cdf0e10cSrcweir 				// UpdateFehlerbehandlung
264cdf0e10cSrcweir 				{
265cdf0e10cSrcweir 					showErrorDialog(e);
266cdf0e10cSrcweir 				}
267cdf0e10cSrcweir 				m_nColumnPos = 0;
268cdf0e10cSrcweir 				break;
269cdf0e10cSrcweir 		}
270cdf0e10cSrcweir 	}
271cdf0e10cSrcweir 	else // Zweig nur f"ur Typpr"ufung g"ultig
272cdf0e10cSrcweir 	{
273cdf0e10cSrcweir 		switch(nToken)
274cdf0e10cSrcweir 		{
275cdf0e10cSrcweir 			case HTML_THEAD_ON:
276cdf0e10cSrcweir 			case HTML_TBODY_ON:
277cdf0e10cSrcweir 				// Der Spalten Kopf z"ahlt nicht mit
278cdf0e10cSrcweir 				if(m_bHead)
279cdf0e10cSrcweir 				{
280cdf0e10cSrcweir 					do
281cdf0e10cSrcweir 					{}
282cdf0e10cSrcweir 					while(GetNextToken() != HTML_TABLEROW_OFF);
283cdf0e10cSrcweir 					m_bHead = sal_False;
284cdf0e10cSrcweir 				}
285cdf0e10cSrcweir 				break;
286cdf0e10cSrcweir 			case HTML_TABLEDATA_ON:
287cdf0e10cSrcweir 			case HTML_TABLEHEADER_ON:
288cdf0e10cSrcweir 				fetchOptions();
289cdf0e10cSrcweir 				break;
290cdf0e10cSrcweir 			case HTML_TEXTTOKEN:
291cdf0e10cSrcweir 			case HTML_SINGLECHAR:
292cdf0e10cSrcweir                 if ( m_bInTbl ) // && !m_bSDNum ) // wichtig, da wir sonst auch die Namen der Fonts bekommen
293cdf0e10cSrcweir 				    m_sTextToken += aToken;
294cdf0e10cSrcweir 				break;
295cdf0e10cSrcweir             case HTML_PARABREAK_OFF:
296cdf0e10cSrcweir                 m_sCurrent += m_sTextToken;
297cdf0e10cSrcweir                 break;
298cdf0e10cSrcweir             case HTML_PARABREAK_ON:
299cdf0e10cSrcweir                 m_sTextToken.Erase();
300cdf0e10cSrcweir                 break;
301cdf0e10cSrcweir 			case HTML_TABLEDATA_OFF:
302cdf0e10cSrcweir                 if ( m_sCurrent.Len() )
303cdf0e10cSrcweir                     m_sTextToken = m_sCurrent;
304cdf0e10cSrcweir                 adjustFormat();
305cdf0e10cSrcweir 				m_nColumnPos++;
306cdf0e10cSrcweir 				m_bSDNum = m_bInTbl = sal_False;
307cdf0e10cSrcweir                 m_sCurrent.Erase();
308cdf0e10cSrcweir 				break;
309cdf0e10cSrcweir 			case HTML_TABLEROW_OFF:
310cdf0e10cSrcweir                 if ( m_sCurrent.Len() )
311cdf0e10cSrcweir                     m_sTextToken = m_sCurrent;
312cdf0e10cSrcweir                 adjustFormat();
313cdf0e10cSrcweir 				m_nColumnPos = 0;
314cdf0e10cSrcweir 				m_nRows--;
315cdf0e10cSrcweir                 m_sCurrent.Erase();
316cdf0e10cSrcweir 				break;
317cdf0e10cSrcweir 		}
318cdf0e10cSrcweir 	}
319cdf0e10cSrcweir }
320cdf0e10cSrcweir // -----------------------------------------------------------------------------
fetchOptions()321cdf0e10cSrcweir void OHTMLReader::fetchOptions()
322cdf0e10cSrcweir {
323cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::fetchOptions" );
324cdf0e10cSrcweir 	m_bInTbl = sal_True;
325cdf0e10cSrcweir 	const HTMLOptions* options = GetOptions();
326cdf0e10cSrcweir 	sal_Int16 nArrLen = options->Count();
327cdf0e10cSrcweir 	for ( sal_Int16 i = 0; i < nArrLen; i++ )
328cdf0e10cSrcweir 	{
329cdf0e10cSrcweir 		const HTMLOption* pOption = (*options)[i];
330cdf0e10cSrcweir 		switch( pOption->GetToken() )
331cdf0e10cSrcweir 		{
332cdf0e10cSrcweir 			case HTML_O_SDVAL:
333cdf0e10cSrcweir 			{
334cdf0e10cSrcweir                 m_sValToken = pOption->GetString();
335cdf0e10cSrcweir 				//m_sTextToken = pOption->GetString();
336cdf0e10cSrcweir 				m_bSDNum = sal_True;
337cdf0e10cSrcweir 			}
338cdf0e10cSrcweir 			break;
339cdf0e10cSrcweir 			case HTML_O_SDNUM:
340cdf0e10cSrcweir                 m_sNumToken = pOption->GetString();
341cdf0e10cSrcweir 			break;
342cdf0e10cSrcweir 		}
343cdf0e10cSrcweir 	}
344cdf0e10cSrcweir }
345cdf0e10cSrcweir //---------------------------------------------------------------------------------
TableDataOn(SvxCellHorJustify & eVal,int nToken)346cdf0e10cSrcweir void OHTMLReader::TableDataOn(SvxCellHorJustify& eVal,int nToken)
347cdf0e10cSrcweir {
348cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::TableDataOn" );
349cdf0e10cSrcweir 	DBG_CHKTHIS(OHTMLReader,NULL);
350cdf0e10cSrcweir 	sal_Bool bHorJustifyCenterTH = (nToken == HTML_TABLEHEADER_ON);
351cdf0e10cSrcweir 	const HTMLOptions* pHtmlOptions = GetOptions();
352cdf0e10cSrcweir 	sal_Int16 nArrLen = pHtmlOptions->Count();
353cdf0e10cSrcweir 	for ( sal_Int16 i = 0; i < nArrLen; i++ )
354cdf0e10cSrcweir 	{
355cdf0e10cSrcweir 		const HTMLOption* pOption = (*pHtmlOptions)[i];
356cdf0e10cSrcweir 		switch( pOption->GetToken() )
357cdf0e10cSrcweir 		{
358cdf0e10cSrcweir 			case HTML_O_ALIGN:
359cdf0e10cSrcweir 			{
360cdf0e10cSrcweir 				bHorJustifyCenterTH = sal_False;
361cdf0e10cSrcweir 				const String& rOptVal = pOption->GetString();
362cdf0e10cSrcweir 				if (rOptVal.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_AL_right ))
363cdf0e10cSrcweir 					eVal = SVX_HOR_JUSTIFY_RIGHT;
364cdf0e10cSrcweir 				else if (rOptVal.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_AL_center ))
365cdf0e10cSrcweir 					eVal = SVX_HOR_JUSTIFY_CENTER;
366cdf0e10cSrcweir 				else if (rOptVal.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_AL_left ))
367cdf0e10cSrcweir 					eVal = SVX_HOR_JUSTIFY_LEFT;
368cdf0e10cSrcweir 				else
369cdf0e10cSrcweir 					eVal = SVX_HOR_JUSTIFY_STANDARD;
370cdf0e10cSrcweir 			}
371cdf0e10cSrcweir 			break;
372cdf0e10cSrcweir 			case HTML_O_WIDTH:
373cdf0e10cSrcweir 				m_nWidth = GetWidthPixel( pOption );
374cdf0e10cSrcweir 			break;
375cdf0e10cSrcweir 		}
376cdf0e10cSrcweir 	}
377cdf0e10cSrcweir }
378cdf0e10cSrcweir 
379cdf0e10cSrcweir //---------------------------------------------------------------------------------
TableFontOn(FontDescriptor & _rFont,sal_Int32 & _rTextColor)380cdf0e10cSrcweir void OHTMLReader::TableFontOn(FontDescriptor& _rFont,sal_Int32 &_rTextColor)
381cdf0e10cSrcweir {
382cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::TableFontOn" );
383cdf0e10cSrcweir 	DBG_CHKTHIS(OHTMLReader,NULL);
384cdf0e10cSrcweir 	const HTMLOptions* pHtmlOptions = GetOptions();
385cdf0e10cSrcweir 	sal_Int16 nArrLen = pHtmlOptions->Count();
386cdf0e10cSrcweir 	for ( sal_Int16 i = 0; i < nArrLen; i++ )
387cdf0e10cSrcweir 	{
388cdf0e10cSrcweir 		const HTMLOption* pOption = (*pHtmlOptions)[i];
389cdf0e10cSrcweir 		switch( pOption->GetToken() )
390cdf0e10cSrcweir 		{
391cdf0e10cSrcweir 		case HTML_O_COLOR:
392cdf0e10cSrcweir 			{
393cdf0e10cSrcweir 				Color aColor;
394cdf0e10cSrcweir 				pOption->GetColor( aColor );
395cdf0e10cSrcweir 				_rTextColor = aColor.GetRGBColor();
396cdf0e10cSrcweir 			}
397cdf0e10cSrcweir 			break;
398cdf0e10cSrcweir 		case HTML_O_FACE :
399cdf0e10cSrcweir 			{
400cdf0e10cSrcweir 				const String& rFace = pOption->GetString();
401cdf0e10cSrcweir 				String aFontName;
402cdf0e10cSrcweir 				xub_StrLen nPos = 0;
403cdf0e10cSrcweir 				while( nPos != STRING_NOTFOUND )
404cdf0e10cSrcweir 				{	// Fontliste, VCL: Semikolon als Separator, HTML: Komma
405cdf0e10cSrcweir 					String aFName = rFace.GetToken( 0, ',', nPos );
406cdf0e10cSrcweir 					aFName.EraseTrailingChars().EraseLeadingChars();
407cdf0e10cSrcweir 					if( aFontName.Len() )
408cdf0e10cSrcweir 						aFontName += ';';
409cdf0e10cSrcweir 					aFontName += aFName;
410cdf0e10cSrcweir 				}
411cdf0e10cSrcweir 				if ( aFontName.Len() )
412cdf0e10cSrcweir 					_rFont.Name = ::rtl::OUString(aFontName);
413cdf0e10cSrcweir 			}
414cdf0e10cSrcweir 			break;
415cdf0e10cSrcweir 		case HTML_O_SIZE :
416cdf0e10cSrcweir 			{
417cdf0e10cSrcweir 				sal_Int16 nSize = (sal_Int16) pOption->GetNumber();
418cdf0e10cSrcweir 				if ( nSize == 0 )
419cdf0e10cSrcweir 					nSize = 1;
420cdf0e10cSrcweir 				else if ( nSize < DBAUI_HTML_FONTSIZES )
421cdf0e10cSrcweir 					nSize = DBAUI_HTML_FONTSIZES;
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 				_rFont.Height = nSize;
424cdf0e10cSrcweir 			}
425cdf0e10cSrcweir 			break;
426cdf0e10cSrcweir 		}
427cdf0e10cSrcweir 	}
428cdf0e10cSrcweir }
429cdf0e10cSrcweir // ---------------------------------------------------------------------------
GetWidthPixel(const HTMLOption * pOption)430cdf0e10cSrcweir sal_Int16 OHTMLReader::GetWidthPixel( const HTMLOption* pOption )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::GetWidthPixel" );
433cdf0e10cSrcweir 	DBG_CHKTHIS(OHTMLReader,NULL);
434cdf0e10cSrcweir 	const String& rOptVal = pOption->GetString();
435cdf0e10cSrcweir 	if ( rOptVal.Search('%') != STRING_NOTFOUND )
436cdf0e10cSrcweir 	{	// Prozent
437cdf0e10cSrcweir 		DBG_ASSERT( m_nColumnWidth, "WIDTH Option: m_nColumnWidth==0 und Width%" );
438cdf0e10cSrcweir 		return (sal_Int16)((pOption->GetNumber() * m_nColumnWidth) / 100);
439cdf0e10cSrcweir 	}
440cdf0e10cSrcweir 	else
441cdf0e10cSrcweir 	{
442cdf0e10cSrcweir 		if ( rOptVal.Search('*') != STRING_NOTFOUND )
443cdf0e10cSrcweir 		{	// relativ zu was?!?
444cdf0e10cSrcweir //2do: ColArray aller relativen Werte sammeln und dann MakeCol
445cdf0e10cSrcweir 			return 0;
446cdf0e10cSrcweir 		}
447cdf0e10cSrcweir 		else
448cdf0e10cSrcweir 			return (sal_Int16)pOption->GetNumber();	// Pixel
449cdf0e10cSrcweir 	}
450cdf0e10cSrcweir }
451cdf0e10cSrcweir // ---------------------------------------------------------------------------
CreateTable(int nToken)452cdf0e10cSrcweir sal_Bool OHTMLReader::CreateTable(int nToken)
453cdf0e10cSrcweir {
454cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::CreateTable" );
455cdf0e10cSrcweir 	DBG_CHKTHIS(OHTMLReader,NULL);
456cdf0e10cSrcweir 	String aTempName(ModuleRes(STR_TBL_TITLE));
457cdf0e10cSrcweir 	aTempName = aTempName.GetToken(0,' ');
458cdf0e10cSrcweir 	aTempName = String(::dbtools::createUniqueName(m_xTables,::rtl::OUString(aTempName )));
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 	int nTmpToken2 = nToken;
461cdf0e10cSrcweir 	sal_Bool bCaption = sal_False;
462cdf0e10cSrcweir 	sal_Bool bTableHeader = sal_False;
463cdf0e10cSrcweir 	String aColumnName;
464cdf0e10cSrcweir 	SvxCellHorJustify eVal;
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 	String aTableName;
467cdf0e10cSrcweir 	FontDescriptor aFont = ::dbaui::CreateFontDescriptor(Application::GetSettings().GetStyleSettings().GetAppFont());
468cdf0e10cSrcweir 	sal_Int32 nTextColor = 0;
469cdf0e10cSrcweir 	do
470cdf0e10cSrcweir 	{
471cdf0e10cSrcweir 		switch(nTmpToken2)
472cdf0e10cSrcweir 		{
473cdf0e10cSrcweir 			case HTML_TEXTTOKEN:
474cdf0e10cSrcweir 			case HTML_SINGLECHAR:
475cdf0e10cSrcweir 				if(bTableHeader)
476cdf0e10cSrcweir 					aColumnName += aToken;
477cdf0e10cSrcweir 				if(bCaption)
478cdf0e10cSrcweir 					aTableName += aToken;
479cdf0e10cSrcweir 				break;
480cdf0e10cSrcweir             case HTML_PARABREAK_OFF:
481cdf0e10cSrcweir                 m_sCurrent += aColumnName;
482cdf0e10cSrcweir                 break;
483cdf0e10cSrcweir             case HTML_PARABREAK_ON:
484cdf0e10cSrcweir                 m_sTextToken.Erase();
485cdf0e10cSrcweir                 break;
486cdf0e10cSrcweir 			case HTML_TABLEDATA_ON:
487cdf0e10cSrcweir                 // m_bAppendFirstLine = true;
488cdf0e10cSrcweir                 // run through
489cdf0e10cSrcweir 			case HTML_TABLEHEADER_ON:
490cdf0e10cSrcweir 				TableDataOn(eVal,nTmpToken2);
491cdf0e10cSrcweir 				bTableHeader = sal_True;
492cdf0e10cSrcweir 				break;
493cdf0e10cSrcweir 			case HTML_TABLEDATA_OFF:
494cdf0e10cSrcweir                 // m_bAppendFirstLine = true;
495cdf0e10cSrcweir                 // run through
496cdf0e10cSrcweir 			case HTML_TABLEHEADER_OFF:
497cdf0e10cSrcweir 				{
498cdf0e10cSrcweir 					aColumnName.EraseLeadingChars();
499cdf0e10cSrcweir 					aColumnName.EraseTrailingChars();
500cdf0e10cSrcweir 					if (!aColumnName.Len() || m_bAppendFirstLine )
501cdf0e10cSrcweir 						aColumnName = String(ModuleRes(STR_COLUMN_NAME));
502cdf0e10cSrcweir                     else if ( m_sCurrent.Len() )
503cdf0e10cSrcweir                         aColumnName = m_sCurrent;
504cdf0e10cSrcweir 
505cdf0e10cSrcweir                     aColumnName.EraseLeadingChars();
506cdf0e10cSrcweir 					aColumnName.EraseTrailingChars();
507cdf0e10cSrcweir 					CreateDefaultColumn(aColumnName);
508cdf0e10cSrcweir 					aColumnName.Erase();
509cdf0e10cSrcweir                     m_sCurrent.Erase();
510cdf0e10cSrcweir 
511cdf0e10cSrcweir 					eVal = SVX_HOR_JUSTIFY_STANDARD;
512cdf0e10cSrcweir 					bTableHeader = sal_False;
513cdf0e10cSrcweir 				}
514cdf0e10cSrcweir 				break;
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 			case HTML_TITLE_ON:
517cdf0e10cSrcweir 			case HTML_CAPTION_ON:
518cdf0e10cSrcweir 				bCaption = sal_True;
519cdf0e10cSrcweir 				break;
520cdf0e10cSrcweir 			case HTML_TITLE_OFF:
521cdf0e10cSrcweir 			case HTML_CAPTION_OFF:
522cdf0e10cSrcweir 				aTableName.EraseLeadingChars();
523cdf0e10cSrcweir 				aTableName.EraseTrailingChars();
524cdf0e10cSrcweir 				if(!aTableName.Len())
525cdf0e10cSrcweir 					aTableName = String(::dbtools::createUniqueName(m_xTables,::rtl::OUString(aTableName)));
526cdf0e10cSrcweir 				else
527cdf0e10cSrcweir 					aTableName = aTempName;
528cdf0e10cSrcweir 				bCaption = sal_False;
529cdf0e10cSrcweir 				break;
530cdf0e10cSrcweir 			case HTML_FONT_ON:
531cdf0e10cSrcweir 				TableFontOn(aFont,nTextColor);
532cdf0e10cSrcweir 				break;
533cdf0e10cSrcweir 			case HTML_BOLD_ON:
534cdf0e10cSrcweir 				aFont.Weight = ::com::sun::star::awt::FontWeight::BOLD;
535cdf0e10cSrcweir 				break;
536cdf0e10cSrcweir 			case HTML_ITALIC_ON:
537cdf0e10cSrcweir 				aFont.Slant = ::com::sun::star::awt::FontSlant_ITALIC;
538cdf0e10cSrcweir 				break;
539cdf0e10cSrcweir 			case HTML_UNDERLINE_ON:
540cdf0e10cSrcweir 				aFont.Underline = ::com::sun::star::awt::FontUnderline::SINGLE;
541cdf0e10cSrcweir 				break;
542cdf0e10cSrcweir 			case HTML_STRIKE_ON:
543cdf0e10cSrcweir 				aFont.Strikeout = ::com::sun::star::awt::FontStrikeout::SINGLE;
544cdf0e10cSrcweir 				break;
545cdf0e10cSrcweir 		}
546cdf0e10cSrcweir 	}
547cdf0e10cSrcweir 	while((nTmpToken2 = GetNextToken()) != HTML_TABLEROW_OFF);
548cdf0e10cSrcweir 
549cdf0e10cSrcweir     if ( m_sCurrent.Len() )
550cdf0e10cSrcweir         aColumnName = m_sCurrent;
551cdf0e10cSrcweir     aColumnName.EraseLeadingChars();
552cdf0e10cSrcweir 	aColumnName.EraseTrailingChars();
553cdf0e10cSrcweir 	if(aColumnName.Len())
554cdf0e10cSrcweir 		CreateDefaultColumn(aColumnName);
555cdf0e10cSrcweir 
556cdf0e10cSrcweir 	if ( m_vDestVector.empty() )
557cdf0e10cSrcweir 		return sal_False;
558cdf0e10cSrcweir 
559cdf0e10cSrcweir 	if(!aTableName.Len())
560cdf0e10cSrcweir 		aTableName = aTempName;
561cdf0e10cSrcweir 
562cdf0e10cSrcweir 	m_bInTbl		= sal_False;
563cdf0e10cSrcweir 	m_bFoundTable	= sal_True;
564cdf0e10cSrcweir 
565cdf0e10cSrcweir 	if ( isCheckEnabled() )
566cdf0e10cSrcweir 		return sal_True;
567cdf0e10cSrcweir 
568cdf0e10cSrcweir 	return !executeWizard(aTableName,makeAny(nTextColor),aFont) && m_xTable.is();
569cdf0e10cSrcweir }
570cdf0e10cSrcweir // -----------------------------------------------------------------------------
setTextEncoding()571cdf0e10cSrcweir void OHTMLReader::setTextEncoding()
572cdf0e10cSrcweir {
573cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::setTextEncoding" );
574cdf0e10cSrcweir 	DBG_CHKTHIS(OHTMLReader,NULL);
575cdf0e10cSrcweir 	m_bMetaOptions = sal_True;
576cdf0e10cSrcweir     ParseMetaOptions(NULL, NULL);
577cdf0e10cSrcweir }
578cdf0e10cSrcweir 
579cdf0e10cSrcweir // -----------------------------------------------------------------------------
release()580cdf0e10cSrcweir void OHTMLReader::release()
581cdf0e10cSrcweir {
582cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::release" );
583cdf0e10cSrcweir 	DBG_CHKTHIS(OHTMLReader,NULL);
584cdf0e10cSrcweir 	ReleaseRef();
585cdf0e10cSrcweir }
586cdf0e10cSrcweir // -----------------------------------------------------------------------------
getTypeSelectionPageFactory()587cdf0e10cSrcweir TypeSelectionPageFactory OHTMLReader::getTypeSelectionPageFactory()
588cdf0e10cSrcweir {
589cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::getTypeSelectionPageFactory" );
590cdf0e10cSrcweir 	DBG_CHKTHIS(OHTMLReader,NULL);
591cdf0e10cSrcweir     return &OWizHTMLExtend::Create;
592cdf0e10cSrcweir }
593cdf0e10cSrcweir // -----------------------------------------------------------------------------
594cdf0e10cSrcweir 
595