diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-19 09:22:33 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-19 13:06:47 +0200 |
commit | 82f9573bb239b8e964723b05374d8619c3d45112 (patch) | |
tree | 81aeb5f0120f647ae9f45a357bd83b71c4bfc7f5 /sw | |
parent | 43e8797add78ba172abdc75457500d68c15473eb (diff) |
use rtl::Reference in SwHTMLWriter
instead of manual acquire/release
Change-Id: I76176841738688dff9df2e7dc3077be7d32387e9
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/html/css1atr.cxx | 16 | ||||
-rw-r--r-- | sw/source/filter/html/htmlatr.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.cxx | 43 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.hxx | 3 |
4 files changed, 31 insertions, 35 deletions
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx index 3134a1c8265a..8ea04cccf67b 100644 --- a/sw/source/filter/html/css1atr.cxx +++ b/sw/source/filter/html/css1atr.cxx @@ -513,7 +513,7 @@ void SwHTMLWriter::OutStyleSheet( const SwPageDesc& rPageDesc ) { // The document is one-sided; no matter what page, we do not create a 2-sided doc. // The attribute is exported relative to the HTML page template. - OutCSS1_SwPageDesc( *this, *pPageDesc, pStylePoolAccess, m_pTemplate, + OutCSS1_SwPageDesc( *this, *pPageDesc, pStylePoolAccess, m_xTemplate.get(), RES_POOLPAGE_HTML, true, false ); nFirstRefPoolId = pFollow->GetPoolFormatId(); } @@ -523,9 +523,9 @@ void SwHTMLWriter::OutStyleSheet( const SwPageDesc& rPageDesc ) RES_POOLPAGE_LEFT == pFollow->GetPoolFormatId()) ) { // the document is double-sided - OutCSS1_SwPageDesc( *this, *pPageDesc, pStylePoolAccess, m_pTemplate, + OutCSS1_SwPageDesc( *this, *pPageDesc, pStylePoolAccess, m_xTemplate.get(), RES_POOLPAGE_HTML, true ); - OutCSS1_SwPageDesc( *this, *pFollow, pStylePoolAccess, m_pTemplate, + OutCSS1_SwPageDesc( *this, *pFollow, pStylePoolAccess, m_xTemplate.get(), RES_POOLPAGE_HTML, true ); nFirstRefPoolId = RES_POOLPAGE_RIGHT; m_bCSS1IgnoreFirstPageDesc = false; @@ -533,7 +533,7 @@ void SwHTMLWriter::OutStyleSheet( const SwPageDesc& rPageDesc ) // other cases we miss if( pFirstPageDesc ) - OutCSS1_SwPageDesc( *this, *pFirstPageDesc, pStylePoolAccess, m_pTemplate, + OutCSS1_SwPageDesc( *this, *pFirstPageDesc, pStylePoolAccess, m_xTemplate.get(), nFirstRefPoolId, false ); } @@ -550,7 +550,7 @@ void SwHTMLWriter::OutStyleSheet( const SwPageDesc& rPageDesc ) const SwTextFormatColl* pColl = (*pDoc->GetTextFormatColls())[i]; sal_uInt16 nPoolId = pColl->GetPoolFormatId(); if( nPoolId == RES_POOLCOLL_TEXT || pDoc->IsUsed( *pColl ) ) - OutCSS1_SwFormat( *this, *pColl, &pDoc->getIDocumentStylePoolAccess(), m_pTemplate ); + OutCSS1_SwFormat( *this, *pColl, &pDoc->getIDocumentStylePoolAccess(), m_xTemplate.get() ); } // the Default-TextStyle is not also exported !! @@ -562,7 +562,7 @@ void SwHTMLWriter::OutStyleSheet( const SwPageDesc& rPageDesc ) if( nPoolId == RES_POOLCHR_INET_NORMAL || nPoolId == RES_POOLCHR_INET_VISIT || pDoc->IsUsed( *pCFormat ) ) - OutCSS1_SwFormat( *this, *pCFormat, &pDoc->getIDocumentStylePoolAccess(), m_pTemplate ); + OutCSS1_SwFormat( *this, *pCFormat, &pDoc->getIDocumentStylePoolAccess(), m_xTemplate.get() ); } bool bHasEndNotes {false}; @@ -1756,9 +1756,9 @@ static Writer& OutCSS1_SwFootnoteInfo( Writer& rWrt, const SwEndNoteInfo& rInfo, // exported, so that Netscape displays the document correctly. // Otherwise it is sufficient, to export the differences to the // footnote and endnote template. - if( !bHasNotes && rHTMLWrt.m_pTemplate ) + if( !bHasNotes && rHTMLWrt.m_xTemplate.is() ) { - SwFormat *pRefFormat = rHTMLWrt.m_pTemplate->getIDocumentStylePoolAccess().GetCharFormatFromPool( + SwFormat *pRefFormat = rHTMLWrt.m_xTemplate->getIDocumentStylePoolAccess().GetCharFormatFromPool( static_cast< sal_uInt16 >(bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE) ); if( pRefFormat ) SwHTMLWriter::SubtractItemSet( aItemSet, pRefFormat->GetAttrSet(), diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index 406a5661e0b3..a9b9eccf1554 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -499,7 +499,7 @@ void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat, } else { - pFormatInfo = new SwHTMLFormatInfo( &rFormat, rWrt.pDoc, rHWrt.m_pTemplate, + pFormatInfo = new SwHTMLFormatInfo( &rFormat, rWrt.pDoc, rHWrt.m_xTemplate.get(), rHWrt.m_bCfgOutStyles, rHWrt.m_eLang, rHWrt.m_nCSS1Script ); rHWrt.m_TextCollInfos.insert(std::unique_ptr<SwHTMLFormatInfo>(pFormatInfo)); @@ -2257,7 +2257,7 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode ) // are there any hard attributes that must be written as tags? aFullText += rStr; - HTMLEndPosLst aEndPosLst( rWrt.pDoc, rHTMLWrt.m_pTemplate, + HTMLEndPosLst aEndPosLst( rWrt.pDoc, rHTMLWrt.m_xTemplate.get(), rHTMLWrt.m_pDfltColor, rHTMLWrt.m_bCfgOutStyles, rHTMLWrt.GetHTMLMode(), aFullText, rHTMLWrt.m_aScriptTextStyles ); diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index bdc9f0ad50a7..bfa402a7d3e8 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -91,7 +91,6 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL ) , m_eCSS1Unit(FUNIT_NONE) , m_pFootEndNotes(nullptr) , mxFormComps() - , m_pTemplate(nullptr) , m_pDfltColor(nullptr) , m_pStartNdIdx(nullptr) , m_pCurrPageDesc(nullptr) @@ -262,16 +261,15 @@ sal_uLong SwHTMLWriter::WriteStream() SwTextFormatColls::size_type nOldTextFormatCollCnt = 0; SwCharFormats::size_type nOldCharFormatCnt = 0; - OSL_ENSURE( !m_pTemplate, "Wo kommt denn die HTML-Vorlage hier her?" ); - m_pTemplate = static_cast<HTMLReader*>(ReadHTML)->GetTemplateDoc(); - if( m_pTemplate ) + OSL_ENSURE( !m_xTemplate.is(), "Wo kommt denn die HTML-Vorlage hier her?" ); + m_xTemplate = static_cast<HTMLReader*>(ReadHTML)->GetTemplateDoc(); + if( m_xTemplate.is() ) { - m_pTemplate->acquire(); - bOldHTMLMode = m_pTemplate->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE); - m_pTemplate->getIDocumentSettingAccess().set(DocumentSettingId::HTML_MODE, true); + bOldHTMLMode = m_xTemplate->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE); + m_xTemplate->getIDocumentSettingAccess().set(DocumentSettingId::HTML_MODE, true); - nOldTextFormatCollCnt = m_pTemplate->GetTextFormatColls()->size(); - nOldCharFormatCnt = m_pTemplate->GetCharFormats()->size(); + nOldTextFormatCollCnt = m_xTemplate->GetTextFormatColls()->size(); + nOldCharFormatCnt = m_xTemplate->GetCharFormats()->size(); } if( bShowProgress ) @@ -298,7 +296,7 @@ sal_uLong SwHTMLWriter::WriteStream() m_nWhishLineLen = 70; m_nLastLFPos = 0; m_nDefListLvl = 0; - m_nDefListMargin = ((m_pTemplate && !m_bCfgOutStyles) ? m_pTemplate : pDoc) + m_nDefListMargin = ((m_xTemplate.is() && !m_bCfgOutStyles) ? m_xTemplate.get() : pDoc) ->getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_HTML_DD, false ) ->GetLRSpace().GetTextLeft(); m_nHeaderFooterSpace = 0; @@ -488,29 +486,26 @@ sal_uLong SwHTMLWriter::WriteStream() if( bShowProgress ) ::EndProgress( pDoc->GetDocShell() ); - if( m_pTemplate ) + if( m_xTemplate.is() ) { // Waehrend des Exports angelegte Zeichen- und Abastzvorlagen // loeschen - auto nTextFormatCollCnt = m_pTemplate->GetTextFormatColls()->size(); + auto nTextFormatCollCnt = m_xTemplate->GetTextFormatColls()->size(); while( nTextFormatCollCnt > nOldTextFormatCollCnt ) - m_pTemplate->DelTextFormatColl( --nTextFormatCollCnt ); - OSL_ENSURE( m_pTemplate->GetTextFormatColls()->size() == nOldTextFormatCollCnt, + m_xTemplate->DelTextFormatColl( --nTextFormatCollCnt ); + OSL_ENSURE( m_xTemplate->GetTextFormatColls()->size() == nOldTextFormatCollCnt, "falsche Anzahl TextFormatColls geloescht" ); - auto nCharFormatCnt = m_pTemplate->GetCharFormats()->size(); + auto nCharFormatCnt = m_xTemplate->GetCharFormats()->size(); while( nCharFormatCnt > nOldCharFormatCnt ) - m_pTemplate->DelCharFormat( --nCharFormatCnt ); - OSL_ENSURE( m_pTemplate->GetCharFormats()->size() == nOldCharFormatCnt, + m_xTemplate->DelCharFormat( --nCharFormatCnt ); + OSL_ENSURE( m_xTemplate->GetCharFormats()->size() == nOldCharFormatCnt, "falsche Anzahl CharFormats geloescht" ); // HTML-Modus wieder restaurieren - m_pTemplate->getIDocumentSettingAccess().set(DocumentSettingId::HTML_MODE, bOldHTMLMode); + m_xTemplate->getIDocumentSettingAccess().set(DocumentSettingId::HTML_MODE, bOldHTMLMode); - if( 0 == m_pTemplate->release() ) - delete m_pTemplate; - - m_pTemplate = nullptr; + m_xTemplate.clear(); } return m_nWarn; @@ -832,9 +827,9 @@ static void OutBodyColor( const sal_Char* pTag, const SwFormat *pFormat, { const SwFormat *pRefFormat = nullptr; - if( rHWrt.m_pTemplate ) + if( rHWrt.m_xTemplate.is() ) pRefFormat = SwHTMLWriter::GetTemplateFormat( pFormat->GetPoolFormatId(), - &rHWrt.m_pTemplate->getIDocumentStylePoolAccess() ); + &rHWrt.m_xTemplate->getIDocumentStylePoolAccess() ); const SvxColorItem *pColorItem = nullptr; diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx index 794027f0f05e..1f31d9769e6e 100644 --- a/sw/source/filter/html/wrthtml.hxx +++ b/sw/source/filter/html/wrthtml.hxx @@ -30,6 +30,7 @@ #include <comphelper/stl_types.hxx> #include <o3tl/sorted_vector.hxx> #include <o3tl/typed_flags_set.hxx> +#include <rtl/ref.hxx> #include "shellio.hxx" #include "wrt_fn.hxx" @@ -293,7 +294,7 @@ public: css::uno::Reference<css::container::XIndexContainer> mxFormComps; // die aktuelle Form - SwDoc *m_pTemplate; // die HTML-Vorlage + rtl::Reference<SwDoc> m_xTemplate; // die HTML-Vorlage Color *m_pDfltColor; // default Farbe SwNodeIndex *m_pStartNdIdx; // Index des ersten Absatz const SwPageDesc *m_pCurrPageDesc;// Die aktuelle Seiten-Vorlage |