Kaydet (Commit) e79b7a51 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in SwPendingStack

and simplify, no need for a linked list here, a vector will do fine

Change-Id: I0aa3d518ceec305aaa0607306bdf816a52507c58
Reviewed-on: https://gerrit.libreoffice.org/61109
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 7e4631c5
......@@ -1725,15 +1725,13 @@ bool SwHTMLParser::FileDownload( const OUString& rURL,
void SwHTMLParser::InsertLink()
{
bool bFinishDownload = false;
if( m_pPendStack )
if( !m_vPendingStack.empty() )
{
OSL_ENSURE( ShouldFinishFileDownload(),
"Pending-Stack without File-Download?" );
SwPendingStack* pTmp = m_pPendStack->pNext;
delete m_pPendStack;
m_pPendStack = pTmp;
OSL_ENSURE( !m_pPendStack, "Where does the Pending-Stack come from?" );
m_vPendingStack.pop_back();
assert( m_vPendingStack.empty() && "Where does the Pending-Stack come from?" );
bFinishDownload = true;
}
......@@ -1778,7 +1776,7 @@ void SwHTMLParser::InsertLink()
// The style was load asynchronously and is only available
// on the next continue call. Therefore we must create a
// Pending stack, so that we will return to here.
m_pPendStack = new SwPendingStack( HtmlTokenId::LINK, m_pPendStack );
m_vPendingStack.emplace_back( HtmlTokenId::LINK );
}
}
else
......
......@@ -1379,7 +1379,7 @@ void SwHTMLParser::EndForm( bool bAppend )
void SwHTMLParser::InsertInput()
{
assert(m_pPendStack == nullptr);
assert(m_vPendingStack.empty());
if( !m_pFormImpl || !m_pFormImpl->GetFormComps().is() )
return;
......@@ -1851,7 +1851,7 @@ void SwHTMLParser::InsertInput()
void SwHTMLParser::NewTextArea()
{
assert(m_pPendStack == nullptr);
assert(m_vPendingStack.empty());
OSL_ENSURE( !m_bTextArea, "TextArea in TextArea?" );
OSL_ENSURE( !m_pFormImpl || !m_pFormImpl->GetFCompPropSet().is(),
......@@ -2133,7 +2133,7 @@ void SwHTMLParser::InsertTextAreaText( HtmlTokenId nToken )
void SwHTMLParser::NewSelect()
{
assert(m_pPendStack == nullptr);
assert(m_vPendingStack.empty());
OSL_ENSURE( !m_bSelect, "Select in Select?" );
OSL_ENSURE( !m_pFormImpl || !m_pFormImpl->GetFCompPropSet().is(),
......@@ -2347,7 +2347,7 @@ void SwHTMLParser::NewSelect()
void SwHTMLParser::EndSelect()
{
assert(m_pPendStack == nullptr);
assert(m_vPendingStack.empty());
OSL_ENSURE( m_bSelect, "no Select" );
OSL_ENSURE( m_pFormImpl && m_pFormImpl->GetFCompPropSet().is(),
......
......@@ -259,7 +259,6 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCursor, SvStream& rIn,
m_sBaseURL( rBaseURL ),
m_xAttrTab(new HTMLAttrTable),
m_pNumRuleInfo( new SwHTMLNumRuleInfo ),
m_pPendStack( nullptr ),
m_xDoc( pD ),
m_pActionViewShell( nullptr ),
m_pSttNdIdx( nullptr ),
......@@ -477,15 +476,9 @@ SwHTMLParser::~SwHTMLParser()
OSL_ENSURE(!m_xTable.get(), "It exists still a open table");
m_pImageMaps.reset();
OSL_ENSURE( !m_pPendStack,
OSL_ENSURE( m_vPendingStack.empty(),
"SwHTMLParser::~SwHTMLParser: Here should not be Pending-Stack anymore" );
while( m_pPendStack )
{
SwPendingStack* pTmp = m_pPendStack;
m_pPendStack = m_pPendStack->pNext;
delete pTmp->pData;
delete pTmp;
}
m_vPendingStack.clear();
m_xDoc.clear();
......@@ -634,16 +627,16 @@ void SwHTMLParser::Continue( HtmlTokenId nToken )
// of NextToken.
if( SvParserState::Error == eState )
{
OSL_ENSURE( !m_pPendStack || m_pPendStack->nToken != HtmlTokenId::NONE,
OSL_ENSURE( m_vPendingStack.empty() || m_vPendingStack.back().nToken != HtmlTokenId::NONE,
"SwHTMLParser::Continue: Pending-Stack without Token" );
if( m_pPendStack && m_pPendStack->nToken != HtmlTokenId::NONE )
NextToken( m_pPendStack->nToken );
OSL_ENSURE( !m_pPendStack,
if( !m_vPendingStack.empty() && m_vPendingStack.back().nToken != HtmlTokenId::NONE )
NextToken( m_vPendingStack.back().nToken );
OSL_ENSURE( m_vPendingStack.empty(),
"SwHTMLParser::Continue: There is again a Pending-Stack" );
}
else
{
HTMLParser::Continue( m_pPendStack ? m_pPendStack->nToken : nToken );
HTMLParser::Continue( !m_vPendingStack.empty() ? m_vPendingStack.back().nToken : nToken );
}
// disable progress bar again
......@@ -962,14 +955,14 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
// Was the import cancelled by SFX? If a pending stack
// exists, clean it.
eState = SvParserState::Error;
OSL_ENSURE( !m_pPendStack || m_pPendStack->nToken != HtmlTokenId::NONE,
OSL_ENSURE( m_vPendingStack.empty() || m_vPendingStack.back().nToken != HtmlTokenId::NONE,
"SwHTMLParser::NextToken: Pending-Stack without token" );
if( 1 == m_xDoc->getReferenceCount() || !m_pPendStack )
if( 1 == m_xDoc->getReferenceCount() || m_vPendingStack.empty() )
return ;
}
#if OSL_DEBUG_LEVEL > 0
if( m_pPendStack )
if( !m_vPendingStack.empty() )
{
switch( nToken )
{
......@@ -985,7 +978,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
case HtmlTokenId::SELECT_OFF:
break;
default:
OSL_ENSURE( !m_pPendStack, "Unknown token for Pending-Stack" );
OSL_ENSURE( m_vPendingStack.empty(), "Unknown token for Pending-Stack" );
break;
}
}
......@@ -994,7 +987,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
// The following special cases have to be treated before the
// filter detection, because Netscape doesn't reference the content
// of the title for filter detection either.
if( !m_pPendStack )
if( m_vPendingStack.empty() )
{
if( m_bInTitle )
{
......@@ -1065,7 +1058,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
// The following special cases may or have to be treated after the
// filter detection
if( !m_pPendStack )
if( m_vPendingStack.empty() )
{
if( m_bInFloatingFrame )
{
......@@ -1731,7 +1724,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
break;
case HtmlTokenId::TABLE_ON:
if( m_pPendStack )
if( !m_vPendingStack.empty() )
BuildTable( SvxAdjust::End );
else
{
......
......@@ -52,7 +52,7 @@ class SwHTMLForm_Impl;
class SwApplet_Impl;
struct SwHTMLFootEndNote_Impl;
class HTMLTableCnts;
struct SwPendingStack;
struct SwPending;
class SvxCSS1PropertyInfo;
struct ImplSVEvent;
......@@ -372,7 +372,7 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient
std::unique_ptr<SwCSS1Parser> m_pCSS1Parser; // Style-Sheet-Parser
std::unique_ptr<SwHTMLNumRuleInfo> m_pNumRuleInfo;
SwPendingStack *m_pPendStack;
std::vector<SwPending> m_vPendingStack;
rtl::Reference<SwDoc> m_xDoc;
SwPaM *m_pPam; // SwPosition should be enough, or ??
......@@ -930,19 +930,18 @@ public:
static OUString StripQueryFromPath(const OUString& rBase, const OUString& rPath);
};
struct SwPendingStackData
struct SwPendingData
{
virtual ~SwPendingStackData() {}
virtual ~SwPendingData() {}
};
struct SwPendingStack
struct SwPending
{
HtmlTokenId nToken;
SwPendingStackData* pData;
SwPendingStack* pNext;
std::unique_ptr<SwPendingData> pData;
SwPendingStack( HtmlTokenId nTkn, SwPendingStack* pNxt )
: nToken( nTkn ), pData( nullptr ), pNext( pNxt )
SwPending( HtmlTokenId nTkn )
: nToken( nTkn )
{}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment