27#include <osl/diagnose.h>
28#include <core_resource.hxx>
29#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
30#include <com/sun/star/awt/FontWeight.hpp>
31#include <com/sun/star/awt/FontStrikeout.hpp>
32#include <com/sun/star/awt/FontSlant.hpp>
33#include <com/sun/star/awt/FontUnderline.hpp>
49#define DBAUI_HTML_FONTSIZES 8
54 const css::uno::Reference< css::uno::XComponentContext >& _rxContext)
62 SetSwitchToUCS2(
true );
65OHTMLReader::OHTMLReader(
SvStream& rIn,
67 TPositions&& _rColumnPositions,
69 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
70 const TColumnVector* pList,
72 bool _bAutoIncrementEnabled)
74 ,
ODatabaseExport( nRows,
std::move(_rColumnPositions), _rxNumberF, _rxContext, pList, _pInfoMap, _bAutoIncrementEnabled, rIn )
80 SetSwitchToUCS2(
true );
83OHTMLReader::~OHTMLReader()
97#pragma warning(disable: 4702)
103 if (
nToken == HtmlTokenId::META )
110 case HtmlTokenId::TABLE_ON:
114 for (
const auto & rOption : rHtmlOptions)
116 if( rOption.GetToken() == HtmlOptionId::WIDTH )
123 case HtmlTokenId::THEAD_ON:
124 case HtmlTokenId::TBODY_ON:
135 case HtmlTokenId::TABLE_OFF:
141 case HtmlTokenId::TABLEROW_ON:
145 case HtmlTokenId::TEXTTOKEN:
146 case HtmlTokenId::SINGLECHAR:
150 case HtmlTokenId::PARABREAK_OFF:
153 case HtmlTokenId::PARABREAK_ON:
156 case HtmlTokenId::TABLEDATA_ON:
159 case HtmlTokenId::TABLEDATA_OFF:
167 catch(SQLException& e)
178 case HtmlTokenId::TABLEROW_OFF:
191 catch(SQLException& e)
205 case HtmlTokenId::THEAD_ON:
206 case HtmlTokenId::TBODY_ON:
216 case HtmlTokenId::TABLEDATA_ON:
217 case HtmlTokenId::TABLEHEADER_ON:
220 case HtmlTokenId::TEXTTOKEN:
221 case HtmlTokenId::SINGLECHAR:
225 case HtmlTokenId::PARABREAK_OFF:
228 case HtmlTokenId::PARABREAK_ON:
231 case HtmlTokenId::TABLEDATA_OFF:
239 case HtmlTokenId::TABLEROW_OFF:
256 for (
const auto & rOption : options)
258 switch( rOption.GetToken() )
260 case HtmlOptionId::SDNUM:
271 for (
const auto & rOption : rHtmlOptions)
273 switch( rOption.GetToken() )
275 case HtmlOptionId::ALIGN:
277 const OUString& rOptVal = rOption.GetString();
279 eVal = SvxCellHorJustify::Right;
281 eVal = SvxCellHorJustify::Center;
283 eVal = SvxCellHorJustify::Left;
285 eVal = SvxCellHorJustify::Standard;
296 for (
const auto & rOption : rHtmlOptions)
298 switch( rOption.GetToken() )
300 case HtmlOptionId::COLOR:
303 rOption.GetColor( aColor );
307 case HtmlOptionId::FACE :
309 const OUString& rFace = rOption.GetString();
310 OUStringBuffer aFontName;
317 if( !aFontName.isEmpty() )
318 aFontName.append(
";");
319 aFontName.append(aFName);
321 if ( !aFontName.isEmpty() )
322 _rFont.Name = aFontName.makeStringAndClear();
325 case HtmlOptionId::SIZE :
327 sal_Int16 nSize =
static_cast<sal_Int16
>(rOption.GetNumber());
333 _rFont.Height = nSize;
343 const OUString& rOptVal = rOption.
GetString();
344 if ( rOptVal.indexOf(
'%') != -1 )
346 OSL_ENSURE(
m_nColumnWidth,
"WIDTH Option: m_nColumnWidth==0 and Width%" );
351 if ( rOptVal.indexOf(
'*') != -1 )
357 return static_cast<sal_Int16
>(rOption.
GetNumber());
363 OUString aTempName(
DBA_RES(STR_TBL_TITLE));
364 aTempName = aTempName.getToken(0,
' ');
365 aTempName = ::dbtools::createUniqueName(
m_xTables, aTempName);
367 bool bCaption =
false;
368 bool bTableHeader =
false;
369 OUString aColumnName;
379 case HtmlTokenId::TEXTTOKEN:
380 case HtmlTokenId::SINGLECHAR:
386 case HtmlTokenId::PARABREAK_OFF:
389 case HtmlTokenId::PARABREAK_ON:
392 case HtmlTokenId::TABLEDATA_ON:
393 case HtmlTokenId::TABLEHEADER_ON:
397 case HtmlTokenId::TABLEDATA_OFF:
398 case HtmlTokenId::TABLEHEADER_OFF:
402 aColumnName =
DBA_RES(STR_COLUMN_NAME);
411 eVal = SvxCellHorJustify::Standard;
412 bTableHeader =
false;
416 case HtmlTokenId::TITLE_ON:
417 case HtmlTokenId::CAPTION_ON:
420 case HtmlTokenId::TITLE_OFF:
421 case HtmlTokenId::CAPTION_OFF:
423 if(aTableName.isEmpty())
424 aTableName = ::dbtools::createUniqueName(
m_xTables, aTableName);
426 aTableName = aTempName;
429 case HtmlTokenId::FONT_ON:
432 case HtmlTokenId::BOLD_ON:
433 aFont.Weight = css::awt::FontWeight::BOLD;
435 case HtmlTokenId::ITALIC_ON:
436 aFont.Slant = css::awt::FontSlant_ITALIC;
438 case HtmlTokenId::UNDERLINE_ON:
439 aFont.Underline = css::awt::FontUnderline::SINGLE;
441 case HtmlTokenId::STRIKE_ON:
442 aFont.Strikeout = css::awt::FontStrikeout::SINGLE;
448 while (
nToken != HtmlTokenId::TABLEROW_OFF);
453 if(!aColumnName.isEmpty())
459 if(aTableName.isEmpty())
460 aTableName = aTempName;
#define DBAUI_HTML_FONTSIZES
static const AllSettings & GetSettings()
Color GetRGBColor() const
const OUString & GetString() const
sal_uInt32 GetNumber() const
virtual SvParserState CallParser() override
virtual bool ParseMetaOptions(const css::uno::Reference< css::document::XDocumentProperties > &, SvKeyValueIterator *)
const HTMLOptions & GetOptions(HtmlOptionId const *pNoConvertToken=nullptr)
virtual void ResetError()
sal_uInt64 Seek(sal_uInt64 nPos)
static css::awt::FontDescriptor CreateFontDescriptor(const vcl::Font &rFont)
sal_Int32 m_nRows
number of rows to be searched
bool isCheckEnabled() const
OUString m_sTextToken
cell content
void CreateDefaultColumn(const OUString &_rColumnName)
css::uno::Reference< css::container::XNameAccess > m_xTables
container
TColumnVector m_vDestVector
bool m_bError
error and termination code
std::shared_ptr< IUpdateHelper > m_pUpdateHelper
sal_Int32 m_nColumnPos
current column position
const OTypeInfoMap * m_pInfoMap
bool m_bInTbl
true, if parser is in RTF table
OUString m_sNumToken
SDNUM value.
sal_Int32 m_nRowCount
current count of rows
css::uno::Reference< css::beans::XPropertySet > m_xTable
dest table
bool executeWizard(const OUString &_sTableName, const css::uno::Any &_aTextColor, const css::awt::FontDescriptor &_rFont)
executeWizard calls a wizard to create/append data
bool m_bFoundTable
set to true when a table was found
bool m_bIsAutoIncrement
if PKey is set by user
void showErrorDialog(const css::sdbc::SQLException &e)
void SetColumnTypes(const TColumnVector *rList, const OTypeInfoMap *_pInfoMap)
void insertValueIntoColumn()
bool m_bHead
true, if the header hasn't been read yet
const TColumnVector * m_pColumnList
SharedConnection m_xConnection
dest conn
virtual TypeSelectionPageFactory getTypeSelectionPageFactory() override
sal_Int16 m_nColumnWidth
maximum column width
void TableDataOn(SvxCellHorJustify &eVal)
bool CreateTable(HtmlTokenId nToken)
sal_Int16 GetWidthPixel(const HTMLOption &rOption)
virtual SvParserState CallParser() override
void TableFontOn(css::awt::FontDescriptor &_rFont, Color &_rTextColor)
virtual void NextToken(HtmlTokenId nToken) override
static std::unique_ptr< OWizTypeSelect > Create(weld::Container *pPage, OCopyTableWizard *pWizard, SvStream &rInput)
#define OOO_STRING_SVTOOLS_HTML_AL_left
#define OOO_STRING_SVTOOLS_HTML_AL_center
#define OOO_STRING_SVTOOLS_HTML_AL_right
OString strip(const OString &rIn, char c)
std::multimap< DataTypeEnum, OExtendedTypeInfo * > OTypeInfoMap
std::unique_ptr< OWizTypeSelect >(* TypeSelectionPageFactory)(weld::Container *, OCopyTableWizard *, SvStream &)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
::std::vector< HTMLOption > HTMLOptions
#define STREAM_SEEK_TO_BEGIN
TOOLS_DLLPUBLIC rtl_TextEncoding GetExtendedCompatibilityTextEncoding(rtl_TextEncoding eEncoding)