/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifdefined _MSC_VER #pragma warning(disable: 4702) // unreachable code, bug in MSVC2015 #endif void OHTMLReader::NextToken( HtmlTokenId nToken )
{ if(m_bError || !m_nRows) // if there is an error or no more rows to check, return immediately return; if ( nToken == HtmlTokenId::META )
setTextEncoding();
if(m_xConnection.is()) // names, which CTOR was called and hence, if a table should be created
{ switch(nToken)
{ case HtmlTokenId::TABLE_ON:
++m_nTableCount;
{ // can also be TD or TH, if there was no TABLE before const HTMLOptions& rHtmlOptions = GetOptions(); for (constauto & rOption : rHtmlOptions)
{ if( rOption.GetToken() == HtmlOptionId::WIDTH )
{ // percentage: of document width respectively outer cell
m_nColumnWidth = GetWidthPixel( rOption );
}
}
}
[[fallthrough]]; case HtmlTokenId::THEAD_ON: case HtmlTokenId::TBODY_ON:
{
sal_uInt64 const nTell = rInput.Tell(); // perhaps alters position of the stream if ( !m_xTable.is() )
{// use first line as header
m_bError = !CreateTable(nToken); if ( m_bAppendFirstLine )
rInput.Seek(nTell);
}
} break; case HtmlTokenId::TABLE_OFF: if(!--m_nTableCount)
{
m_xTable = nullptr;
} break; case HtmlTokenId::TABLEROW_ON: if ( !m_pUpdateHelper )
m_bError = true; break; case HtmlTokenId::TEXTTOKEN: case HtmlTokenId::SINGLECHAR: if ( m_bInTbl ) //&& !m_bSDNum ) // important, as otherwise we also get the names of the fonts
m_sTextToken += aToken; break; case HtmlTokenId::PARABREAK_OFF:
m_sCurrent += m_sTextToken; break; case HtmlTokenId::PARABREAK_ON:
m_sTextToken.clear(); break; case HtmlTokenId::TABLEDATA_ON:
fetchOptions(); break; case HtmlTokenId::TABLEDATA_OFF:
{ if ( !m_sCurrent.isEmpty() )
m_sTextToken = m_sCurrent; try
{
insertValueIntoColumn();
} catch(SQLException& e) // handling update failure
{
showErrorDialog(e);
}
m_sCurrent.clear();
m_nColumnPos++;
eraseTokens();
m_bInTbl = false;
} break; case HtmlTokenId::TABLEROW_OFF: if ( !m_pUpdateHelper )
{
m_bError = true; break;
} try
{
m_nRowCount++; if (m_bIsAutoIncrement) // if bSetAutoIncrement then I have to set the autoincrement
m_pUpdateHelper->updateInt(1,m_nRowCount);
m_pUpdateHelper->insertRow();
} catch(SQLException& e) // handling update failure
{
showErrorDialog(e);
}
m_nColumnPos = 0; break; default: break;
}
} else// branch only valid for type checking
{ switch(nToken)
{ case HtmlTokenId::THEAD_ON: case HtmlTokenId::TBODY_ON: // The head of the column is not included if(m_bHead)
{ do
{} while(GetNextToken() != HtmlTokenId::TABLEROW_OFF);
m_bHead = false;
} break; case HtmlTokenId::TABLEDATA_ON: case HtmlTokenId::TABLEHEADER_ON:
fetchOptions(); break; case HtmlTokenId::TEXTTOKEN: case HtmlTokenId::SINGLECHAR: if ( m_bInTbl ) // && !m_bSDNum ) // important, as otherwise we also get the names of the fonts
m_sTextToken += aToken; break; case HtmlTokenId::PARABREAK_OFF:
m_sCurrent += m_sTextToken; break; case HtmlTokenId::PARABREAK_ON:
m_sTextToken.clear(); break; case HtmlTokenId::TABLEDATA_OFF: if ( !m_sCurrent.isEmpty() )
m_sTextToken = m_sCurrent;
adjustFormat();
m_nColumnPos++;
m_bInTbl = false;
m_sCurrent.clear(); break; case HtmlTokenId::TABLEROW_OFF: if ( !m_sCurrent.isEmpty() )
m_sTextToken = m_sCurrent;
adjustFormat();
m_nColumnPos = 0;
m_nRows--;
m_sCurrent.clear(); break; default: break;
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.