diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-01-05 12:06:09 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-01-05 19:11:02 +0100 |
commit | c75c3b2fdab5614664215e52d85657472ec86f05 (patch) | |
tree | b0e8f592430a90cf501b089e1bb9bfd9ac15bf3f /sw/source | |
parent | 3a9877b74e1730424a41319a03f5b56a6102a76b (diff) |
ofz#4971 Bad-cast
Change-Id: Icf66aa82e72a2b9f24f590b84bb0441ebf09463f
Reviewed-on: https://gerrit.libreoffice.org/47466
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/filter/html/htmlftn.cxx | 31 | ||||
-rw-r--r-- | sw/source/filter/html/htmltab.cxx | 32 | ||||
-rw-r--r-- | sw/source/filter/html/swhtml.hxx | 23 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.hxx | 4 |
4 files changed, 64 insertions, 26 deletions
diff --git a/sw/source/filter/html/htmlftn.cxx b/sw/source/filter/html/htmlftn.cxx index ef384761f2b3..749b01dcf142 100644 --- a/sw/source/filter/html/htmlftn.cxx +++ b/sw/source/filter/html/htmlftn.cxx @@ -31,17 +31,6 @@ #include "swhtml.hxx" #include "wrthtml.hxx" -struct SwHTMLFootEndNote_Impl -{ - SwHTMLTextFootnotes aTextFootnotes; - std::vector<OUString> aNames; - - OUString sName; - OUString sContent; // information for the last footnote - bool bEndNote; - bool bFixed; -}; - sal_Int32 lcl_html_getNextPart( OUString& rPart, const OUString& rContent, sal_Int32 nPos ) { @@ -209,11 +198,8 @@ void SwHTMLParser::FinishFootEndNote() m_pPam->GetNode().GetTextNode()->GetTextAttrForCharAt( m_pPam->GetPoint()->nContent.GetIndex() - 1, RES_TXTATR_FTN ) ); // In header and footer no footnotes can be inserted. - if( pTextFootnote ) - { - m_pFootEndNoteImpl->aTextFootnotes.push_back( pTextFootnote ); - m_pFootEndNoteImpl->aNames.push_back(m_pFootEndNoteImpl->sName); - } + if (pTextFootnote) + m_pFootEndNoteImpl->aTextFootnotes.push_back(SwHTMLTextFootnote(m_pFootEndNoteImpl->sName,pTextFootnote)); m_pFootEndNoteImpl->sName = aEmptyOUStr; m_pFootEndNoteImpl->sContent = aEmptyOUStr; m_pFootEndNoteImpl->bFixed = false; @@ -235,19 +221,18 @@ SwNodeIndex *SwHTMLParser::GetFootEndNoteSection( const OUString& rName ) { SwNodeIndex *pStartNodeIdx = nullptr; - if( m_pFootEndNoteImpl ) + if (m_pFootEndNoteImpl) { OUString aName(rName.toAsciiUpperCase()); - size_t nCount = m_pFootEndNoteImpl->aNames.size(); + size_t nCount = m_pFootEndNoteImpl->aTextFootnotes.size(); for(size_t i = 0; i < nCount; ++i) { - if(m_pFootEndNoteImpl->aNames[i] == aName) + if (m_pFootEndNoteImpl->aTextFootnotes[i].sName == aName) { - pStartNodeIdx = m_pFootEndNoteImpl->aTextFootnotes[i]->GetStartNode(); - m_pFootEndNoteImpl->aNames.erase(m_pFootEndNoteImpl->aNames.begin() + i); + pStartNodeIdx = m_pFootEndNoteImpl->aTextFootnotes[i].pTextFootnote->GetStartNode(); m_pFootEndNoteImpl->aTextFootnotes.erase( m_pFootEndNoteImpl->aTextFootnotes.begin() + i ); - if(m_pFootEndNoteImpl->aNames.empty()) + if (m_pFootEndNoteImpl->aTextFootnotes.empty()) { delete m_pFootEndNoteImpl; m_pFootEndNoteImpl = nullptr; @@ -288,7 +273,7 @@ Writer& OutHTML_SwFormatFootnote( Writer& rWrt, const SfxPoolItem& rHt ) } if( !rHTMLWrt.m_pFootEndNotes ) - rHTMLWrt.m_pFootEndNotes = new SwHTMLTextFootnotes; + rHTMLWrt.m_pFootEndNotes = new std::vector<SwTextFootnote*>; rHTMLWrt.m_pFootEndNotes->insert( rHTMLWrt.m_pFootEndNotes->begin() + nPos, pTextFootnote ); OStringBuffer sOut; diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index 92ec9aa5c928..59cc59c64e5f 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -58,6 +58,7 @@ #include "swhtml.hxx" #include "swcss1.hxx" #include <numrule.hxx> +#include <txtftn.hxx> #define NETSCAPE_DFLT_BORDER 1 #define NETSCAPE_DFLT_CELLSPACING 2 @@ -5021,6 +5022,24 @@ namespace m_pObjectFormat->Remove(this); } }; + + class IndexInRange + { + private: + SwNodeIndex maStart; + SwNodeIndex maEnd; + public: + explicit IndexInRange(const SwNodeIndex& rStart, const SwNodeIndex& rEnd) + : maStart(rStart) + , maEnd(rEnd) + { + } + bool operator()(const SwHTMLTextFootnote& rTextFootnote) const + { + const SwNodeIndex aTextIdx(rTextFootnote.pTextFootnote->GetTextNode()); + return aTextIdx >= maStart && aTextIdx <= maEnd; + } + }; } std::shared_ptr<HTMLTable> SwHTMLParser::BuildTable(SvxAdjust eParentAdjust, @@ -5294,6 +5313,19 @@ std::shared_ptr<HTMLTable> SwHTMLParser::BuildTable(SvxAdjust eParentAdjust, SwFrameFormat* pObjectFormat = m_pMarquee ? ::FindFrameFormat(m_pMarquee) : nullptr; FrameDeleteWatch aWatch(pObjectFormat); + //similarly for footnotes + if (m_pFootEndNoteImpl) + { + SwNodeIndex aSttIdx(*pSttNd), aEndIdx(*pSttNd->EndOfSectionNode()); + m_pFootEndNoteImpl->aTextFootnotes.erase(std::remove_if(m_pFootEndNoteImpl->aTextFootnotes.begin(), + m_pFootEndNoteImpl->aTextFootnotes.end(), IndexInRange(aSttIdx, aEndIdx)), m_pFootEndNoteImpl->aTextFootnotes.end()); + if (m_pFootEndNoteImpl->aTextFootnotes.empty()) + { + delete m_pFootEndNoteImpl; + m_pFootEndNoteImpl = nullptr; + } + } + m_xDoc->getIDocumentContentOperations().DeleteSection(pSttNd); xCurTable->SetCaption( nullptr, false ); diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx index 45b5effe1857..92d090bcddc9 100644 --- a/sw/source/filter/html/swhtml.hxx +++ b/sw/source/filter/html/swhtml.hxx @@ -1002,6 +1002,29 @@ inline bool SwHTMLParser::HasStyleOptions( const OUString &rStyle, (pLang && !pLang->isEmpty()) || (pDir && !pDir->isEmpty()); } +class SwTextFootnote; + +struct SwHTMLTextFootnote +{ + OUString sName; + SwTextFootnote* pTextFootnote; + SwHTMLTextFootnote(const OUString &rName, SwTextFootnote* pInTextFootnote) + : sName(rName) + , pTextFootnote(pInTextFootnote) + { + } +}; + +struct SwHTMLFootEndNote_Impl +{ + std::vector<SwHTMLTextFootnote> aTextFootnotes; + + OUString sName; + OUString sContent; // information for the last footnote + bool bEndNote; + bool bFixed; +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx index 60171e6dfea4..96a6f1906ca2 100644 --- a/sw/source/filter/html/wrthtml.hxx +++ b/sw/source/filter/html/wrthtml.hxx @@ -59,8 +59,6 @@ class SwHTMLPosFlyFrames; class SwTextFootnote; enum class HtmlPosition; -typedef std::vector<SwTextFootnote*> SwHTMLTextFootnotes; - extern SwAttrFnTab aHTMLAttrFnTab; #define HTML_PARSPACE (MM50) @@ -286,7 +284,7 @@ public: SwHTMLFormatInfos m_CharFormatInfos; SwHTMLFormatInfos m_TextCollInfos; std::vector<SwFormatINetFormat*> m_aINetFormats; // the "open" INet attributes - SwHTMLTextFootnotes *m_pFootEndNotes; + std::vector<SwTextFootnote*> *m_pFootEndNotes; OUString m_aCSS1Selector; // style selector OUString m_aNonConvertableCharacters; |