[Libreoffice-commits] core.git: 3 commits - lotuswordpro/source sw/inc sw/source

Caolán McNamara caolanm at redhat.com
Mon Feb 27 13:53:30 UTC 2017


 lotuswordpro/source/filter/lwpfilter.cxx |   14 +++++++-----
 sw/inc/breakit.hxx                       |   34 ++++++++++++++----------------
 sw/source/core/bastyp/breakit.cxx        |   35 +++++++++++--------------------
 3 files changed, 38 insertions(+), 45 deletions(-)

New commits:
commit 87847bb8b87b80f338bc010d413ce2c9f912e6ec
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Feb 27 13:22:01 2017 +0000

    ofz: fix leak
    
    Change-Id: I631ea0012f8e999f14aa08b42f28d6115a73d084

diff --git a/lotuswordpro/source/filter/lwpfilter.cxx b/lotuswordpro/source/filter/lwpfilter.cxx
index 0389ee3..f2fe380 100644
--- a/lotuswordpro/source/filter/lwpfilter.cxx
+++ b/lotuswordpro/source/filter/lwpfilter.cxx
@@ -101,7 +101,7 @@ using namespace ::com::sun::star;
 #include "bento.hxx"
 using namespace OpenStormBento;
 #include "explode.hxx"
- bool Decompress(SvStream *pCompressed, SvStream * & pOutDecompressed)
+bool Decompress(SvStream *pCompressed, SvStream * & pOutDecompressed)
 {
     pCompressed->Seek(0);
     std::unique_ptr<SvStream> aDecompressed(new SvMemoryStream(4096, 4096));
@@ -110,10 +110,14 @@ using namespace OpenStormBento;
     aDecompressed->WriteBytes(buffer, 16);
 
     std::unique_ptr<LwpSvStream> aLwpStream(new LwpSvStream(pCompressed));
-    LtcBenContainer* pBentoContainer;
-    sal_uLong ulRet = BenOpenContainer(aLwpStream.get(), &pBentoContainer);
-    if (ulRet != BenErr_OK)
-        return false;
+    std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
+    {
+        OpenStormBento::LtcBenContainer* pTmp(nullptr);
+        sal_uLong ulRet = BenOpenContainer(aLwpStream.get(), &pTmp);
+        pBentoContainer.reset(pTmp);
+        if (ulRet != BenErr_OK)
+            return false;
+    }
 
     std::unique_ptr<LtcUtBenValueStream> aWordProData(pBentoContainer->FindValueStreamWithPropertyName("WordProData"));
 
commit 7f335799b34f3454649f0045bdab6f98baa84ed8
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Feb 27 10:07:03 2017 +0000

    OSL_ENSURE->assert
    
    Change-Id: I21edad9865717674217d2d10b9ec2a689d9d65f9

diff --git a/sw/source/core/bastyp/breakit.cxx b/sw/source/core/bastyp/breakit.cxx
index 69436e2..5e7a22c 100644
--- a/sw/source/core/bastyp/breakit.cxx
+++ b/sw/source/core/bastyp/breakit.cxx
@@ -56,13 +56,13 @@ SwBreakIt::SwBreakIt( const uno::Reference<uno::XComponentContext> & rxContext )
     : m_xContext(rxContext)
     , aForbiddenLang(LANGUAGE_DONTKNOW)
 {
-    OSL_ENSURE( m_xContext.is(), "SwBreakIt: no MultiServiceFactory" );
+    assert(m_xContext.is() && "SwBreakIt: no MultiServiceFactory");
 }
 
 void SwBreakIt::createBreakIterator() const
 {
-    if ( m_xContext.is() && !xBreak.is() )
-        xBreak.set( i18n::BreakIterator::create(m_xContext) );
+    if (!xBreak.is())
+        xBreak.set(i18n::BreakIterator::create(m_xContext));
 }
 
 void SwBreakIt::GetLocale_( const LanguageType aLang )
@@ -83,7 +83,7 @@ void SwBreakIt::GetLocale_( const LanguageTag& rLanguageTag )
 
 void SwBreakIt::GetForbidden_( const LanguageType aLang )
 {
-    LocaleDataWrapper aWrap( m_xContext, GetLanguageTag( aLang ) );
+    LocaleDataWrapper aWrap(m_xContext, GetLanguageTag(aLang));
 
     aForbiddenLang = aLang;
     m_xForbidden.reset(new i18n::ForbiddenCharacters(aWrap.getForbiddenCharacters()));
commit 8e89aa77056c4b233c24ad3a93c6d4a8159fcf16
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Feb 27 10:05:33 2017 +0000

    use std::unique_ptr
    
    Change-Id: I3f00cd66a0a8aa0571733caf4db4d16dfd102683

diff --git a/sw/inc/breakit.hxx b/sw/inc/breakit.hxx
index 2978f44..6b92d80 100644
--- a/sw/inc/breakit.hxx
+++ b/sw/inc/breakit.hxx
@@ -35,8 +35,8 @@ class SW_DLLPUBLIC SwBreakIt
     css::uno::Reference< css::uno::XComponentContext > m_xContext;
     mutable css::uno::Reference< css::i18n::XBreakIterator > xBreak;
 
-    LanguageTag * m_pLanguageTag;   ///< language tag of the current locale
-    css::i18n::ForbiddenCharacters * m_pForbidden;
+    std::unique_ptr<LanguageTag> m_xLanguageTag;   ///< language tag of the current locale
+    std::unique_ptr<css::i18n::ForbiddenCharacters> m_xForbidden;
 
     LanguageType aForbiddenLang; ///< language of the current forbiddenChar struct
 
@@ -50,9 +50,7 @@ class SW_DLLPUBLIC SwBreakIt
     SwBreakIt& operator=(SwBreakIt const&) = delete;
 
     // private (see @ Create_, Delete_).
-    explicit SwBreakIt(
-        const css::uno::Reference< css::uno::XComponentContext > & rxContext);
-    ~SwBreakIt();
+    explicit SwBreakIt(const css::uno::Reference<css::uno::XComponentContext> & rxContext);
 
 public:
     // private (see @ source/core/bastyp/init.cxx).
@@ -71,9 +69,9 @@ public:
 
     const css::lang::Locale& GetLocale( const LanguageType aLang )
     {
-        if( !m_pLanguageTag || m_pLanguageTag->getLanguageType() != aLang )
-            GetLocale_( aLang );
-        return m_pLanguageTag->getLocale();
+        if (!m_xLanguageTag || m_xLanguageTag->getLanguageType() != aLang)
+            GetLocale_(aLang);
+        return m_xLanguageTag->getLocale();
     }
 
     const css::lang::Locale& GetLocale( const LanguageTag& rLanguageTag )
@@ -82,16 +80,16 @@ public:
         // because here the LanguageTag is already a known LanguageType value
         // assigned, so LanguageTag does not need to convert to BCP47 for
         // comparison.
-        if( !m_pLanguageTag || m_pLanguageTag->getLanguageType() != rLanguageTag.getLanguageType() )
-            GetLocale_( rLanguageTag );
-        return m_pLanguageTag->getLocale();
+        if (!m_xLanguageTag || m_xLanguageTag->getLanguageType() != rLanguageTag.getLanguageType())
+            GetLocale_(rLanguageTag);
+        return m_xLanguageTag->getLocale();
     }
 
     const LanguageTag& GetLanguageTag( const LanguageType aLang )
     {
-        if( !m_pLanguageTag || m_pLanguageTag->getLanguageType() != aLang )
-            GetLocale_( aLang );
-        return *m_pLanguageTag;
+        if (!m_xLanguageTag || m_xLanguageTag->getLanguageType() != aLang)
+            GetLocale_(aLang);
+        return *m_xLanguageTag;
     }
 
     const LanguageTag& GetLanguageTag( const LanguageTag& rLanguageTag )
@@ -100,16 +98,16 @@ public:
         // because here the LanguageTag is already a known LanguageType value
         // assigned, so LanguageTag does not need to convert to BCP47 for
         // comparison.
-        if( !m_pLanguageTag || m_pLanguageTag->getLanguageType() != rLanguageTag.getLanguageType() )
+        if (!m_xLanguageTag || m_xLanguageTag->getLanguageType() != rLanguageTag.getLanguageType())
             GetLocale_( rLanguageTag );
-        return *m_pLanguageTag;
+        return *m_xLanguageTag;
     }
 
     const css::i18n::ForbiddenCharacters& GetForbidden( const LanguageType aLang )
     {
-        if( !m_pForbidden || aForbiddenLang != aLang )
+        if (!m_xForbidden || aForbiddenLang != aLang)
             GetForbidden_( aLang );
-        return *m_pForbidden;
+        return *m_xForbidden;
     }
 
     sal_uInt16 GetRealScriptOfText( const OUString& rText, sal_Int32 nPos ) const;
diff --git a/sw/source/core/bastyp/breakit.cxx b/sw/source/core/bastyp/breakit.cxx
index bf0ddb6..69436e2 100644
--- a/sw/source/core/bastyp/breakit.cxx
+++ b/sw/source/core/bastyp/breakit.cxx
@@ -53,20 +53,12 @@ SwBreakIt * SwBreakIt::Get()
 }
 
 SwBreakIt::SwBreakIt( const uno::Reference<uno::XComponentContext> & rxContext )
-    : m_xContext( rxContext ),
-      m_pLanguageTag( nullptr ),
-      m_pForbidden( nullptr ),
-      aForbiddenLang( LANGUAGE_DONTKNOW )
+    : m_xContext(rxContext)
+    , aForbiddenLang(LANGUAGE_DONTKNOW)
 {
     OSL_ENSURE( m_xContext.is(), "SwBreakIt: no MultiServiceFactory" );
 }
 
-SwBreakIt::~SwBreakIt()
-{
-    delete m_pLanguageTag;
-    delete m_pForbidden;
-}
-
 void SwBreakIt::createBreakIterator() const
 {
     if ( m_xContext.is() && !xBreak.is() )
@@ -75,18 +67,18 @@ void SwBreakIt::createBreakIterator() const
 
 void SwBreakIt::GetLocale_( const LanguageType aLang )
 {
-    if (m_pLanguageTag)
-        m_pLanguageTag->reset( aLang );
+    if (m_xLanguageTag)
+        m_xLanguageTag->reset(aLang);
     else
-        m_pLanguageTag = new LanguageTag( aLang );
+        m_xLanguageTag.reset(new LanguageTag(aLang));
 }
 
 void SwBreakIt::GetLocale_( const LanguageTag& rLanguageTag )
 {
-    if (m_pLanguageTag)
-        *m_pLanguageTag = rLanguageTag;
+    if (m_xLanguageTag)
+        *m_xLanguageTag = rLanguageTag;
     else
-        m_pLanguageTag = new LanguageTag( rLanguageTag );
+        m_xLanguageTag.reset(new LanguageTag(rLanguageTag));
 }
 
 void SwBreakIt::GetForbidden_( const LanguageType aLang )
@@ -94,8 +86,7 @@ void SwBreakIt::GetForbidden_( const LanguageType aLang )
     LocaleDataWrapper aWrap( m_xContext, GetLanguageTag( aLang ) );
 
     aForbiddenLang = aLang;
-    delete m_pForbidden;
-    m_pForbidden = new i18n::ForbiddenCharacters( aWrap.getForbiddenCharacters() );
+    m_xForbidden.reset(new i18n::ForbiddenCharacters(aWrap.getForbiddenCharacters()));
 }
 
 sal_uInt16 SwBreakIt::GetRealScriptOfText( const OUString& rText, sal_Int32 nPos ) const


More information about the Libreoffice-commits mailing list