[Libreoffice-commits] core.git: 21 commits - basic/source connectivity/source cui/source dbaccess/source editeng/source extensions/Library_scn.mk extensions/source filter/source forms/source jvmfwk/plugins lotuswordpro/source sc/source sdext/source sd/source svl/source sw/source tools/source vcl/generic vcl/source vcl/unx

Caolán McNamara caolanm at redhat.com
Fri Nov 14 04:03:22 PST 2014


 basic/source/classes/image.cxx                        |   11 +
 connectivity/source/drivers/dbase/DTable.cxx          |    4 
 connectivity/source/drivers/firebird/Blob.cxx         |   31 +++++
 cui/source/options/optjava.cxx                        |    6 -
 dbaccess/source/core/dataaccess/databasedocument.cxx  |   11 +
 editeng/source/editeng/editobj.cxx                    |   13 +-
 extensions/Library_scn.mk                             |    1 
 extensions/source/scanner/sane.cxx                    |    7 -
 filter/source/graphicfilter/icgm/class5.cxx           |   12 +-
 forms/source/component/FormComponent.cxx              |   14 ++
 jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx      |  100 ++++++++----------
 lotuswordpro/source/filter/lwpbulletstylemgr.cxx      |    4 
 lotuswordpro/source/filter/lwpcelllayout.cxx          |    7 -
 lotuswordpro/source/filter/lwpdrawobj.cxx             |   22 +--
 lotuswordpro/source/filter/lwpfoundry.cxx             |    2 
 lotuswordpro/source/filter/lwpframelayout.cxx         |    4 
 lotuswordpro/source/filter/lwpfrib.cxx                |   12 +-
 lotuswordpro/source/filter/lwpfribbreaks.cxx          |    4 
 lotuswordpro/source/filter/lwpfribframe.cxx           |    2 
 lotuswordpro/source/filter/lwpfribmark.cxx            |    6 -
 lotuswordpro/source/filter/lwpfribsection.cxx         |    6 -
 lotuswordpro/source/filter/lwpfribtable.cxx           |    2 
 lotuswordpro/source/filter/lwpfribtext.cxx            |    4 
 lotuswordpro/source/filter/lwpgrfobj.cxx              |    4 
 lotuswordpro/source/filter/lwppagelayout.cxx          |    8 -
 lotuswordpro/source/filter/lwppara.cxx                |   18 +--
 lotuswordpro/source/filter/lwppara1.cxx               |    8 -
 lotuswordpro/source/filter/lwprowlayout.cxx           |    4 
 lotuswordpro/source/filter/lwpsilverbullet.cxx        |    2 
 lotuswordpro/source/filter/lwptablelayout.cxx         |   12 +-
 lotuswordpro/source/filter/lwptoc.cxx                 |    2 
 lotuswordpro/source/filter/xfilter/xfstylecont.cxx    |   14 +-
 lotuswordpro/source/filter/xfilter/xfstylecont.hxx    |   13 ++
 lotuswordpro/source/filter/xfilter/xfstylemanager.cxx |   59 +++++-----
 lotuswordpro/source/filter/xfilter/xfstylemanager.hxx |    2 
 sc/source/ui/optdlg/calcoptionsdlg.cxx                |   28 +----
 sd/source/ui/view/drviewse.cxx                        |    6 -
 sdext/source/pdfimport/test/pdf2xml.cxx               |    5 
 svl/source/items/macitem.cxx                          |   20 +++
 sw/source/uibase/docvw/edtwin.cxx                     |    2 
 tools/source/generic/config.cxx                       |    5 
 vcl/generic/print/glyphset.cxx                        |   10 +
 vcl/source/gdi/impfont.cxx                            |   13 +-
 vcl/unx/generic/dtrans/bmp.cxx                        |   18 ++-
 44 files changed, 331 insertions(+), 207 deletions(-)

New commits:
commit 8fe8c2e3d4d1ab44cfa53160e309255c109251d3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 11:41:20 2014 +0000

    coverity#1242630 Untrusted loop bound
    
    Change-Id: I985f47d6e5f5aa86099b86ad4666b194f4b25b83

diff --git a/svl/source/items/macitem.cxx b/svl/source/items/macitem.cxx
index 98e9a98..24c4cc7 100644
--- a/svl/source/items/macitem.cxx
+++ b/svl/source/items/macitem.cxx
@@ -100,10 +100,24 @@ SvStream& SvxMacroTableDtor::Read( SvStream& rStrm, sal_uInt16 nVersion )
 {
     if( SVX_MACROTBL_VERSION40 <= nVersion )
         rStrm.ReadUInt16( nVersion );
-    short nMacro;
-    rStrm.ReadInt16( nMacro );
 
-    for( short i = 0; i < nMacro; ++i )
+    short nMacro(0);
+    rStrm.ReadInt16(nMacro);
+
+    const size_t nMinStringSize = rStrm.GetStreamCharSet() == RTL_TEXTENCODING_UNICODE ? 4 : 2;
+    size_t nMinRecordSize = 2 + 2*nMinStringSize;
+    if( SVX_MACROTBL_VERSION40 <= nVersion )
+        nMinRecordSize+=2;
+
+    const size_t nMaxRecords = rStrm.remainingSize() / nMinRecordSize;
+    if (nMacro > 0 && static_cast<size_t>(nMacro) > nMaxRecords)
+    {
+        SAL_WARN("editeng", "Parsing error: " << nMaxRecords <<
+                 " max possible entries, but " << nMacro<< " claimed, truncating");
+        nMacro = nMaxRecords;
+    }
+
+    for (short i = 0; i < nMacro; ++i)
     {
         sal_uInt16 nCurKey, eType = STARBASIC;
         OUString aLibName, aMacName;
commit 8e6c22d74933c7157e083e97d56106b36a166559
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 11:35:00 2014 +0000

    coverity#1209889 Untrusted loop bound
    
    Change-Id: I63039ca0de1dc54b5aa9d048e5110c31bf930bdc

diff --git a/filter/source/graphicfilter/icgm/class5.cxx b/filter/source/graphicfilter/icgm/class5.cxx
index a1a9bfb..763971a 100644
--- a/filter/source/graphicfilter/icgm/class5.cxx
+++ b/filter/source/graphicfilter/icgm/class5.cxx
@@ -461,10 +461,18 @@ void CGM::ImplDoClass5()
             sal_uInt32  i, nColorFrom = 0;
             sal_uInt32  nColorTo = 0xffffff;
 
-            //FIXME,  does this loop actually do anything?
+            const size_t nRemainingSize = mpEndValidSource - (mpSource + mnParaSize);
+            const size_t nMaxPossibleRecords = nRemainingSize/pElement->nRealSize;
+
+            if (nNumberOfStages > nMaxPossibleRecords)
+            {
+                mbStatus = false;
+                break;
+            }
+
             for ( i = 0; i < nNumberOfStages; i++ )
             {
-                ImplGetFloat( pElement->eRealPrecision, pElement->nRealSize ); // -Wall is this needed
+                ImplGetFloat(pElement->eRealPrecision, pElement->nRealSize);
             }
 
             for ( i = 0; i <= nNumberOfStages; i++ )
commit 642cf9af84ab6a33b0853753499bab4d96be8f7c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 11:28:45 2014 +0000

    coverity#1209863 Untrusted loop bound
    
    Change-Id: I3de3601f489db2a4dafb4d80f5ef35d5db38ba76

diff --git a/vcl/source/gdi/impfont.cxx b/vcl/source/gdi/impfont.cxx
index 354edc1..d36005a 100644
--- a/vcl/source/gdi/impfont.cxx
+++ b/vcl/source/gdi/impfont.cxx
@@ -110,6 +110,8 @@ bool ParseCMAP( const unsigned char* pCmap, int nLength, CmapResult& rResult )
     if( (nSubTables <= 0) || (nLength < (24 + 8*nSubTables)) )
         return false;
 
+    const unsigned char* pEndValidArea = pCmap + nLength;
+
     // find the most interesting subtable in the CMAP
     rtl_TextEncoding eRecodeFrom = RTL_TEXTENCODING_UNICODE;
     int nOffset = 0;
@@ -198,8 +200,6 @@ bool ParseCMAP( const unsigned char* pCmap, int nLength, CmapResult& rResult )
                 SAL_WARN("vcl.gdi", "Format 4 char should not be 0xFFFF");
                 break;
             }
-            *(pCP++) = cMinChar;
-            *(pCP++) = cMaxChar + 1;
             if( !nRangeOffset ) {
                 // glyphid can be calculated directly
                 pStartGlyphs[i] = (cMinChar + nGlyphDelta) & 0xFFFF;
@@ -207,11 +207,20 @@ bool ParseCMAP( const unsigned char* pCmap, int nLength, CmapResult& rResult )
                 // update the glyphid-array with the glyphs in this range
                 pStartGlyphs[i] = -(int)aGlyphIdArray.size();
                 const unsigned char* pGlyphIdPtr = pOffsetBase + 2*i + nRangeOffset;
+                const size_t nRemainingSize = pEndValidArea - pGlyphIdPtr;
+                const size_t nMaxPossibleRecords = nRemainingSize/2;
+                const size_t nRequestedRecords = cMaxChar - cMinChar + 1;
+                if (nRequestedRecords > nMaxPossibleRecords) {  // no sane font should trigger this
+                    SAL_WARN("vcl.gdi", "More indexes claimed that space available in font!");
+                    break;
+                }
                 for( sal_UCS4 c = cMinChar; c <= cMaxChar; ++c, pGlyphIdPtr+=2 ) {
                     const int nGlyphIndex = Getsal_uInt16( pGlyphIdPtr ) + nGlyphDelta;
                     aGlyphIdArray.push_back( static_cast<sal_uInt16>(nGlyphIndex) );
                 }
             }
+            *(pCP++) = cMinChar;
+            *(pCP++) = cMaxChar + 1;
         }
         nRangeCount = (pCP - pCodePairs) / 2;
     }
commit 71c00f4b5797299b1e0b4f1fa23f18b2b68c89b2
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 11:14:07 2014 +0000

    coverity#982314 Logically dead code
    
    Change-Id: Iba420f0726864cb093e17fc9f4ce5bd7a33f7721

diff --git a/tools/source/generic/config.cxx b/tools/source/generic/config.cxx
index fdc7336..2454ddd 100644
--- a/tools/source/generic/config.cxx
+++ b/tools/source/generic/config.cxx
@@ -285,10 +285,7 @@ static void ImplMakeConfigList( ImplConfigData* pData,
                     pGroup->mpNext      = NULL;
                     pGroup->mpFirstKey  = NULL;
                     pGroup->mnEmptyLines = 0;
-                    if ( pPrevGroup )
-                        pPrevGroup->mpNext = pGroup;
-                    else
-                        pData->mpFirstGroup = pGroup;
+                    pData->mpFirstGroup = pGroup;
                     pPrevGroup  = pGroup;
                     pPrevKey    = NULL;
                 }
commit bbf3aa7f92c194c9cc4546c95706e6b28e0c070c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 11:06:44 2014 +0000

    coverity#705989 silence Insecure temporary file
    
    and
    
    coverity#705983 Insecure temporary file
    
    Change-Id: I2a501f8114ddf8968381e1880263abaf9d1bdc6f

diff --git a/extensions/Library_scn.mk b/extensions/Library_scn.mk
index dc9fbba..73716d1 100644
--- a/extensions/Library_scn.mk
+++ b/extensions/Library_scn.mk
@@ -24,6 +24,7 @@ $(eval $(call gb_Library_use_libraries,scn,\
 	svt \
 	vcl \
 	tl \
+	utl \
 	comphelper \
 	cppuhelper \
 	cppu \
diff --git a/extensions/source/scanner/sane.cxx b/extensions/source/scanner/sane.cxx
index fbf7c3c..84475d5 100644
--- a/extensions/source/scanner/sane.cxx
+++ b/extensions/source/scanner/sane.cxx
@@ -21,6 +21,7 @@
 #include <math.h>
 #include <osl/file.h>
 #include <tools/stream.hxx>
+#include <unotools/tempfile.hxx>
 #include <sane.hxx>
 #include <dlfcn.h>
 #include <stdio.h>
@@ -694,7 +695,9 @@ bool Sane::Start( BitmapTransporter& rBitmap )
                 if( nStatus != SANE_STATUS_GOOD )
                     bSynchronousRead = true;
             }
-            FILE* pFrame = tmpfile();
+            utl::TempFile aFrame;
+            aFrame.EnableKillingFile();
+            FILE* pFrame = fopen(OUStringToOString(aFrame.GetFileName(), osl_getThreadTextEncoding()).getStr(), "wb");
             if( ! pFrame )
             {
                 bSuccess = false;
diff --git a/vcl/generic/print/glyphset.cxx b/vcl/generic/print/glyphset.cxx
index 285ee4b..30946a3 100644
--- a/vcl/generic/print/glyphset.cxx
+++ b/vcl/generic/print/glyphset.cxx
@@ -35,6 +35,8 @@
 #include "rtl/ustring.hxx"
 #include "rtl/strbuf.hxx"
 
+#include <unotools/tempfile.hxx>
+
 #include <set>
 #include <map>
 #include <algorithm>
@@ -59,9 +61,6 @@ GlyphSet::~GlyphSet ()
     /* FIXME delete the glyphlist ??? */
 }
 
-
-
-
 bool
 GlyphSet::GetCharID (
                      sal_Unicode nChar,
@@ -742,7 +741,10 @@ GlyphSet::PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAllowType42
     sal_Int32 nSuccess = OpenTTFontFile(aTTFileName.getStr(), nFace, &pTTFont);
     if (nSuccess != SF_OK)
         return false;
-    FILE* pTmpFile = tmpfile();
+
+    utl::TempFile aTmpFile;
+    aTmpFile.EnableKillingFile();
+    FILE* pTmpFile = fopen(OUStringToOString(aTmpFile.GetFileName(), osl_getThreadTextEncoding()).getStr(), "wb");
     if (pTmpFile == NULL)
         return false;
 
commit 64cc39e0c576611297625ebcac8d48613a5bb175
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 10:40:03 2014 +0000

    coverity#1251589 silence Using invalid iterator
    
    Change-Id: I116294ee40eb61e8cbf308369998bd48a2f27812

diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx
index 14d2de5..f7a1397 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.cxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -752,11 +752,7 @@ const ScCalcConfig::OpenCLImplMatcher& ScCalcOptionsDialog::CurrentWhiteOrBlackL
 
     auto i = rSet.begin();
     int n(mpOpenCLWhiteAndBlackListBox->GetSelectEntryPos());
-    while (n && i != rSet.end())
-    {
-        ++i;
-        --n;
-    }
+    std::advance(i, n);
 
     return *i;
 }
commit a4f39904dca51f86171508c08cfd00d35b7a3989
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 10:34:40 2014 +0000

    coverity#1251587 Unchecked dynamic_cast
    
    Change-Id: Ibde77906333699046357bec4ff392e5e08b4a426

diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx
index 5e003df..14d2de5 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.cxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -763,13 +763,11 @@ const ScCalcConfig::OpenCLImplMatcher& ScCalcOptionsDialog::CurrentWhiteOrBlackL
 
 void ScCalcOptionsDialog::EditFieldValueChanged(Control *pCtrl)
 {
-    Edit* pEdit(dynamic_cast<Edit*>(pCtrl));
+    Edit& rEdit(dynamic_cast<Edit&>(*pCtrl));
 
-    assert(pEdit);
+    OUString sVal = rEdit.GetText();
 
-    OUString sVal = pEdit->GetText();
-
-    if (pEdit == mpEditField)
+    if (&rEdit == mpEditField)
     {
         // We know that the mpEditField is used for only one thing at the moment,
         // the OpenCL subset list of opcodes
@@ -783,32 +781,32 @@ void ScCalcOptionsDialog::EditFieldValueChanged(Control *pCtrl)
         const ScCalcConfig::OpenCLImplMatcher& impl(CurrentWhiteOrBlackListEntry());
         ScCalcConfig::OpenCLImplMatcher newImpl(impl);
 
-        if (pEdit == mpOS)
+        if (&rEdit == mpOS)
         {
             newImpl.maOS = sVal;
         }
-        else if (pEdit == mpOSVersion)
+        else if (&rEdit == mpOSVersion)
         {
             newImpl.maOSVersion = sVal;
         }
-        else if (pEdit == mpPlatformVendor)
+        else if (&rEdit == mpPlatformVendor)
         {
             newImpl.maPlatformVendor = sVal;
         }
-        else if (pEdit == mpDevice)
+        else if (&rEdit == mpDevice)
         {
             newImpl.maDevice = sVal;
         }
-        else if (pEdit == mpDriverVersionMin)
+        else if (&rEdit == mpDriverVersionMin)
         {
             newImpl.maDriverVersionMin = sVal;
         }
-        else if (pEdit == mpDriverVersionMax)
+        else if (&rEdit == mpDriverVersionMax)
         {
             newImpl.maDriverVersionMax = sVal;
         }
         else
-            assert(false && "pEdit does not match any of the Edit fields");
+            assert(false && "rEdit does not match any of the Edit fields");
 
         ScCalcConfig::OpenCLImplMatcherSet& rSet(CurrentWhiteOrBlackList());
 
commit e5e13192f3ce677daf6edaaebcb50bad9e24e05a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 10:26:15 2014 +0000

    coverity#1242632 Untrusted loop bound
    
    Change-Id: Ib821adfbca149091d4fbe52d05837e232c3caf55

diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 9c1da0e..b100bd4 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -1266,9 +1266,18 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream )
     rtl_TextEncoding eSrcEncoding = GetSOLoadTextEncoding( (rtl_TextEncoding)nCharSet );
 
     // The number of paragraphs ...
-    sal_uInt16 nParagraphs;
+    sal_uInt16 nParagraphs(0);
     rIStream.ReadUInt16( nParagraphs );
 
+    const size_t nMinParaRecordSize = 6 + eSrcEncoding == RTL_TEXTENCODING_UNICODE ? 4 : 2;
+    const size_t nMaxParaRecords = rIStream.remainingSize() / nMinParaRecordSize;
+    if (nParagraphs > nMaxParaRecords)
+    {
+        SAL_WARN("editeng", "Parsing error: " << nMaxParaRecords <<
+                 " max possible entries, but " << nParagraphs<< " claimed, truncating");
+        nParagraphs = nMaxParaRecords;
+    }
+
     // The individual paragraphs ...
     for ( sal_uLong nPara = 0; nPara < nParagraphs; nPara++ )
     {
@@ -1280,7 +1289,7 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream )
 
         // StyleName and Family...
         pC->GetStyle() = rIStream.ReadUniOrByteString(eSrcEncoding);
-        sal_uInt16 nStyleFamily;
+        sal_uInt16 nStyleFamily(0);
         rIStream.ReadUInt16( nStyleFamily );
         pC->GetFamily() = (SfxStyleFamily)nStyleFamily;
 
commit 41029bcdd094b516bb4f4926fca18ce60092a013
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 10:19:24 2014 +0000

    coverity#1242865 Untrusted value as argument
    
    Change-Id: Ie7a7a2e7894a204dd55833416b7cbc5b01826e64

diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx
index 1543cae..8e52b45 100644
--- a/basic/source/classes/image.cxx
+++ b/basic/source/classes/image.cxx
@@ -202,7 +202,17 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion )
             case B_LINERANGES:
                 break;
             case B_STRINGPOOL:
+            {
                 if( bBadVer ) break;
+                //assuming an empty string with just the lead 32bit len indicator
+                const size_t nMinStringSize = 4;
+                const size_t nMaxStrings = r.remainingSize() / nMinStringSize;
+                if (nCount > nMaxStrings)
+                {
+                    SAL_WARN("basic", "Parsing error: " << nMaxStrings <<
+                             " max possible entries, but " << nCount << " claimed, truncating");
+                    nCount = nMaxStrings;
+                }
                 MakeStrings( nCount );
                 short i;
                 for( i = 0; i < nStrings && SbiGood( r ); i++ )
@@ -227,6 +237,7 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion )
                     }
                 }
                 break;
+            }
             case B_MODEND:
                 goto done;
             default:
commit 480475b28864d9df245e4190c94939060a8c2cc1
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 10:14:09 2014 +0000

    coverity#1209861 untaint image data
    
    Change-Id: Ib35d4a007c276aba45925ac281fff160bf07f9fe

diff --git a/vcl/unx/generic/dtrans/bmp.cxx b/vcl/unx/generic/dtrans/bmp.cxx
index 130c7f2..e57fb93 100644
--- a/vcl/unx/generic/dtrans/bmp.cxx
+++ b/vcl/unx/generic/dtrans/bmp.cxx
@@ -453,9 +453,21 @@ void PixmapHolder::setBitmapDataPalette( const sal_uInt8* pData, XImage* pImage
     {
         if( m_aInfo.c_class != TrueColor )
         {
-            aPalette[i].red     = ((unsigned short)pData[42 + i*4]) << 8 | ((unsigned short)pData[42 + i*4]);
-            aPalette[i].green   = ((unsigned short)pData[41 + i*4]) << 8 | ((unsigned short)pData[41 + i*4]);
-            aPalette[i].blue    = ((unsigned short)pData[40 + i*4]) << 8 | ((unsigned short)pData[40 + i*4]);
+            //This is untainted data which comes from a controlled source
+            //so, using a byte-swapping pattern which coverity doesn't
+            //detect as such
+            //http://security.coverity.com/blog/2014/Apr/on-detecting-heartbleed-with-static-analysis.html
+            aPalette[i].red = ((unsigned short)pData[42 + i*4]);
+            aPalette[i].red <<= 8;
+            aPalette[i].red |= ((unsigned short)pData[42 + i*4]);
+
+            aPalette[i].green = ((unsigned short)pData[41 + i*4]);
+            aPalette[i].green <<= 8;
+            aPalette[i].green |= ((unsigned short)pData[41 + i*4]);
+
+            aPalette[i].blue = ((unsigned short)pData[40 + i*4]);
+            aPalette[i].blue <<= 8;
+            aPalette[i].blue |= ((unsigned short)pData[40 + i*4]);
             XAllocColor( m_pDisplay, m_aColormap, aPalette+i );
         }
         else
commit d6d53e5bc75606b2dbb330b727f6f6595cc49e9f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 10:06:17 2014 +0000

    coverity#706404 Uncaught exception
    
    Change-Id: I331c96a09be7a4971c3cc3c577f8f9d91333d175

diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx
index e497c5c..657f0cd 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -703,13 +703,14 @@ void SAL_CALL ODatabaseDocument::storeToRecoveryFile( const OUString& i_TargetLo
 
 void SAL_CALL ODatabaseDocument::recoverFromFile( const OUString& i_SourceLocation, const OUString& i_SalvagedFile, const Sequence< PropertyValue >& i_MediaDescriptor ) throw ( RuntimeException, IOException, WrappedTargetException, std::exception )
 {
-    DocumentGuard aGuard( *this, DocumentGuard::InitMethod );
-
-    if ( i_SourceLocation.isEmpty() )
-        throw IllegalArgumentException( OUString(), *this, 1 );
-
     try
     {
+        DocumentGuard aGuard( *this, DocumentGuard::InitMethod );
+
+        if ( i_SourceLocation.isEmpty() )
+            throw IllegalArgumentException( OUString(), *this, 1 );
+
+
         // load the document itself, by simply delegating to our "load" method
 
         // our load implementation expects the SalvagedFile and URL to be in the media descriptor
commit 275eb9c78e90c484dfb985303a75969659270ed7
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 10:04:38 2014 +0000

    coverity#706540 Uncaught exception
    
    Change-Id: I9dabd74824ec7cffe5371ed8be202ad27fecc80d

diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx
index b7a3a9e..c6e4a8c 100644
--- a/forms/source/component/FormComponent.cxx
+++ b/forms/source/component/FormComponent.cxx
@@ -643,7 +643,19 @@ void SAL_CALL OControlModel::setParent(const Reference< XInterface >& _rxParent)
 OUString SAL_CALL OControlModel::getName() throw(RuntimeException, std::exception)
 {
     OUString aReturn;
-    OPropertySetHelper::getFastPropertyValue(PROPERTY_ID_NAME) >>= aReturn;
+    try
+    {
+        OPropertySetHelper::getFastPropertyValue(PROPERTY_ID_NAME) >>= aReturn;
+    }
+    catch (const css::beans::UnknownPropertyException&)
+    {
+        css::uno::Any a(cppu::getCaughtException());
+        throw WrappedTargetRuntimeException(
+            "OControlModel::getName",
+            *const_cast< OControlModel* >( this ),
+            a
+        );
+    }
     return aReturn;
 }
 
commit 99bada2f4cd3cf738d384a0bcef4dc4db3880cc2
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 10:03:42 2014 +0000

    coverity#1019392 Uncaught exception
    
    Change-Id: Iab953700c9aa95fc3acd5f25233a942a31b7f5ad

diff --git a/sdext/source/pdfimport/test/pdf2xml.cxx b/sdext/source/pdfimport/test/pdf2xml.cxx
index f081097..974822d 100644
--- a/sdext/source/pdfimport/test/pdf2xml.cxx
+++ b/sdext/source/pdfimport/test/pdf2xml.cxx
@@ -81,6 +81,11 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
         SAL_WARN("vcl.app", "Fatal exception: " << e.Message);
         return 1;
     }
+    catch (const std::exception& e)
+    {
+        SAL_WARN("vcl.app", "Fatal exception: " << e.what());
+        return 1;
+    }
 
     return 0;
 }
commit 584d4f5dcd68f94df42cd78d06c55fd773eb3ca7
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 10:02:52 2014 +0000

    coverity#1158396 Uncaught exception
    
    Change-Id: I6752a534bca8f81627cdd616ac0f2268824299e0

diff --git a/connectivity/source/drivers/firebird/Blob.cxx b/connectivity/source/drivers/firebird/Blob.cxx
index a531dfc..18f684a 100644
--- a/connectivity/source/drivers/firebird/Blob.cxx
+++ b/connectivity/source/drivers/firebird/Blob.cxx
@@ -191,8 +191,35 @@ sal_Int32 SAL_CALL Blob::readBytes(uno::Sequence< sal_Int8 >& rDataOut,
     throw (NotConnectedException, BufferSizeExceededException, IOException, RuntimeException, std::exception)
 {
     MutexGuard aGuard(m_aMutex);
-    checkDisposed(Blob_BASE::rBHelper.bDisposed);
-    ensureBlobIsOpened();
+
+    try
+    {
+        checkDisposed(Blob_BASE::rBHelper.bDisposed);
+        ensureBlobIsOpened();
+    }
+    catch (const NotConnectedException&)
+    {
+        throw;
+    }
+    catch (const BufferSizeExceededException&)
+    {
+        throw;
+    }
+    catch (const IOException&)
+    {
+        throw;
+    }
+    catch (const RuntimeException&)
+    {
+        throw;
+    }
+    catch (const Exception& e)
+    {
+        css::uno::Any a(cppu::getCaughtException());
+        throw css::lang::WrappedTargetRuntimeException(
+            "wrapped Exception " + e.Message,
+            css::uno::Reference<css::uno::XInterface>(), a);
+    }
 
     // Ensure we have enough space for the amount of data we can actually read.
     const sal_Int64 nBytesAvailable = m_nBlobLength - m_nBlobPosition;
commit 6abcd7fe9bf7fd3b4a1d68b1480f61e6d3651fd0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 10:01:02 2014 +0000

    coverity#1247641 Uncaught exception
    
    Change-Id: I35e1eed91a23d2b993398fb39e47e21ca9c0a055

diff --git a/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx b/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx
index bec224e..806fcf9 100644
--- a/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx
+++ b/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx
@@ -44,69 +44,67 @@ static bool findAndSelect(JavaInfo**);
 
 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
 {
-    if( hasOption("--help",argc, argv) || hasOption("-h", argc, argv))
-    {
-        fprintf(stdout, HELP_TEXT);// default
-        return 0;
-    }
-    javaFrameworkError errcode = JFW_E_NONE;
-    sal_Bool bEnabled = sal_False;
-    errcode = jfw_getEnabled( & bEnabled);
-    if (errcode == JFW_E_NONE && bEnabled == sal_False)
-    {
-            //Do not do any preparation because that may only slow startup time.
-        return 0;
-    }
-    else if (errcode != JFW_E_NONE && errcode != JFW_E_DIRECT_MODE)
-    {
-        fprintf(stderr,"javaldx failed!\n");
-        return -1;
-    }
-
-
-    JavaInfo * pInfo = NULL;
-
     try
     {
-        errcode = jfw_getSelectedJRE( & pInfo);
-    }
-    catch (const std::exception&)
-    {
-        fprintf(stderr,"javaldx failed!\n");
-        return -1;
-    }
+        if( hasOption("--help",argc, argv) || hasOption("-h", argc, argv))
+        {
+            fprintf(stdout, HELP_TEXT);// default
+            return 0;
+        }
+        javaFrameworkError errcode = JFW_E_NONE;
+        sal_Bool bEnabled = sal_False;
+        errcode = jfw_getEnabled( & bEnabled);
+        if (errcode == JFW_E_NONE && bEnabled == sal_False)
+        {
+                //Do not do any preparation because that may only slow startup time.
+            return 0;
+        }
+        else if (errcode != JFW_E_NONE && errcode != JFW_E_DIRECT_MODE)
+        {
+            fprintf(stderr,"javaldx failed!\n");
+            return -1;
+        }
 
-    if (errcode != JFW_E_NONE && errcode != JFW_E_INVALID_SETTINGS)
-    {
-        fprintf(stderr,"javaldx failed!\n");
-        return -1;
-    }
+        JavaInfo * pInfo = NULL;
+        errcode = jfw_getSelectedJRE( & pInfo);
 
-    if (pInfo == NULL)
-    {
-        if (false == findAndSelect(&pInfo))
+        if (errcode != JFW_E_NONE && errcode != JFW_E_INVALID_SETTINGS)
+        {
+            fprintf(stderr,"javaldx failed!\n");
             return -1;
-    }
-    else
-    {
-        //check if the JRE was not uninstalled
-        sal_Bool bExist = sal_False;
-        errcode = jfw_existJRE(pInfo, &bExist);
-        if (errcode == JFW_E_NONE)
+        }
+
+        if (pInfo == NULL)
         {
-            if (!bExist && !findAndSelect(&pInfo))
+            if (false == findAndSelect(&pInfo))
                 return -1;
         }
         else
         {
-            fprintf(stderr, "javaldx: Could not determine if JRE still exist\n");
-            return -1;
+            //check if the JRE was not uninstalled
+            sal_Bool bExist = sal_False;
+            errcode = jfw_existJRE(pInfo, &bExist);
+            if (errcode == JFW_E_NONE)
+            {
+                if (!bExist && !findAndSelect(&pInfo))
+                    return -1;
+            }
+            else
+            {
+                fprintf(stderr, "javaldx: Could not determine if JRE still exist\n");
+                return -1;
+            }
         }
-    }
 
-    OString sPaths = getLD_LIBRARY_PATH(pInfo->arVendorData);
-    fprintf(stdout, "%s\n", sPaths.getStr());
-    jfw_freeJavaInfo(pInfo);
+        OString sPaths = getLD_LIBRARY_PATH(pInfo->arVendorData);
+        fprintf(stdout, "%s\n", sPaths.getStr());
+        jfw_freeJavaInfo(pInfo);
+    }
+    catch (const std::exception&)
+    {
+        fprintf(stderr,"javaldx failed!\n");
+        return -1;
+    }
 
     return 0;
 }
commit 70d810faa876245a3d76c22c0cbc12ad62376e6d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 09:58:49 2014 +0000

    coverity#982483 Dereference after null check
    
    Change-Id: I0e6db75e0c1dc5b26f2c251bdb4e37b5df8b3778

diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index e12fce2..329944b 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -3999,7 +3999,7 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
                 if ( m_bIsInMove || IsMinMove( m_aStartPos, aPixPt ) )
                 {
                     // event processing for resizing
-                    if( pSdrView->AreObjectsMarked() )
+                    if (pSdrView && pSdrView->AreObjectsMarked())
                     {
                         const SwFrmFmt* pFlyFmt;
                         const SvxMacro* pMacro;
commit 0332e3a8e968f9f85b40405391120d2f5949fbd2
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 09:56:50 2014 +0000

    coverity#738972 Use after free
    
    Change-Id: Iba60fc4ff3b10179ebc700467a3d73e7bc7b64c9

diff --git a/lotuswordpro/source/filter/lwpbulletstylemgr.cxx b/lotuswordpro/source/filter/lwpbulletstylemgr.cxx
index 992a16d..c71cf15 100644
--- a/lotuswordpro/source/filter/lwpbulletstylemgr.cxx
+++ b/lotuswordpro/source/filter/lwpbulletstylemgr.cxx
@@ -186,7 +186,7 @@ OUString LwpBulletStyleMgr::RegisterBulletStyle(LwpPara* pPara, LwpBulletOverrid
             }
         }
 
-        aStyleName = pXFStyleMgr->AddStyle(pListStyle)->GetStyleName();
+        aStyleName = (pXFStyleMgr->AddStyle(pListStyle)).m_pStyle->GetStyleName();
     }
     else
     {
@@ -242,7 +242,7 @@ OUString LwpBulletStyleMgr::RegisterBulletStyle(LwpPara* pPara, LwpBulletOverrid
 
                 pListStyle->SetListPosition(nPos, 0.0, 0.635, 0.0);
             }
-            aStyleName = pXFStyleMgr->AddStyle(pListStyle)->GetStyleName();
+            aStyleName = (pXFStyleMgr->AddStyle(pListStyle)).m_pStyle->GetStyleName();
         }
         else
             delete pListStyle;
diff --git a/lotuswordpro/source/filter/lwpcelllayout.cxx b/lotuswordpro/source/filter/lwpcelllayout.cxx
index 6510ccb..39717cd 100644
--- a/lotuswordpro/source/filter/lwpcelllayout.cxx
+++ b/lotuswordpro/source/filter/lwpcelllayout.cxx
@@ -283,7 +283,7 @@ void LwpCellLayout::ApplyFmtStyle(XFCellStyle *pCellStyle)
         if (pStyle)
         {
             XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-            m_NumfmtName = pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+            m_NumfmtName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
             pCellStyle->SetDataStyle(m_NumfmtName);
         }
     }
@@ -559,7 +559,7 @@ void LwpCellLayout::RegisterDefaultCell()
             }
             pCellStyle->SetBorders(pBorders);
         }
-        m_CellStyleNames[eLoop] = pXFStyleManager->AddStyle(pCellStyle)->GetStyleName();
+        m_CellStyleNames[eLoop] = (pXFStyleManager->AddStyle(pCellStyle)).m_pStyle->GetStyleName();
     }
 }
 /**
@@ -583,7 +583,6 @@ void LwpCellLayout::RegisterStyle()
     XFCellStyle *pCellStyle = new XFCellStyle();
 
     ApplyPadding(pCellStyle);
-//  ApplyBackColor(pCellStyle);
     ApplyBackGround(pCellStyle);
     ApplyWatermark(pCellStyle);
     ApplyFmtStyle(pCellStyle);
@@ -592,7 +591,7 @@ void LwpCellLayout::RegisterStyle()
     pCellStyle->SetAlignType(enumXFAlignNone, GetVerticalAlignmentType());
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(pCellStyle)->GetStyleName();
+    m_StyleName = (pXFStyleManager->AddStyle(pCellStyle)).m_pStyle->GetStyleName();
 
     // content object register styles
     rtl::Reference<LwpObject> pObj = m_Content.obj();
diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx b/lotuswordpro/source/filter/lwpdrawobj.cxx
index 2ca16ad..1563f3d 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.cxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.cxx
@@ -446,7 +446,7 @@ OUString LwpDrawLine::RegisterStyle()
     this->SetArrowHead(pStyle, m_aLineRec.nLineEnd, m_aLineRec.nLineWidth);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+    return (pXFStyleManager->AddStyle(pStyle)).m_pStyle->GetStyleName();
 
 }
 
@@ -529,7 +529,7 @@ OUString LwpDrawPolyLine::RegisterStyle()
     this->SetArrowHead(pStyle, m_aPolyLineRec.nLineEnd, m_aPolyLineRec.nLineWidth);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawPolyLine::CreateDrawObj(const OUString& rStyleName )
@@ -615,7 +615,7 @@ OUString LwpDrawPolygon::RegisterStyle()
     this->SetFillStyle(pStyle);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawPolygon::CreateDrawObj(const OUString& rStyleName)
@@ -695,7 +695,7 @@ OUString LwpDrawRectangle::RegisterStyle()
     this->SetFillStyle(pStyle);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawRectangle::CreateDrawObj(const OUString& rStyleName)
@@ -854,7 +854,7 @@ OUString LwpDrawEllipse::RegisterStyle()
     this->SetFillStyle(pStyle);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawEllipse::CreateDrawObj(const OUString& rStyleName )
@@ -933,7 +933,7 @@ OUString LwpDrawArc::RegisterStyle()
     this->SetArrowHead(pStyle, m_aArcRec.nLineEnd, m_aArcRec.nLineWidth);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawArc::CreateDrawObj(const OUString& rStyleName )
@@ -1083,7 +1083,7 @@ OUString LwpDrawTextBox::RegisterStyle()
     pStyle->SetFont(pFont);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawTextBox::CreateDrawObj(const OUString& rStyleName )
@@ -1112,7 +1112,7 @@ XFFrame* LwpDrawTextBox::CreateDrawObj(const OUString& rStyleName )
     XFTextBoxStyle* pBoxStyle = new XFTextBoxStyle();
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    OUString sName = pXFStyleManager->AddStyle(pBoxStyle)->GetStyleName();
+    OUString sName = pXFStyleManager->AddStyle(pBoxStyle).m_pStyle->GetStyleName();
     pTextBox->SetStyleName(sName);
 
     //todo: add the interface for rotating textbox
@@ -1288,7 +1288,7 @@ OUString LwpDrawTextArt::RegisterStyle()
     pStyle->SetFont(pFont);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawTextArt::CreateDrawObj(const OUString& rStyleName)
@@ -1320,7 +1320,7 @@ XFFrame* LwpDrawTextArt::CreateDrawObj(const OUString& rStyleName)
     pRetObj->Add(pXFPara);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    pRetObj->SetStyleName(pXFStyleManager->AddStyle(pStyle)->GetStyleName());
+    pRetObj->SetStyleName(pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName());
 
     return pRetObj;
 }
@@ -1486,7 +1486,7 @@ OUString LwpDrawBitmap::RegisterStyle()
     pBmpStyle->SetXPosType(enumXFFrameXPosFromLeft, enumXFFrameXRelFrame);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pBmpStyle)->GetStyleName();
+    return pXFStyleManager->AddStyle(pBmpStyle).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawBitmap::CreateDrawObj(const OUString& rStyleName)
diff --git a/lotuswordpro/source/filter/lwpfoundry.cxx b/lotuswordpro/source/filter/lwpfoundry.cxx
index 8e19cf0..04fa6f3 100644
--- a/lotuswordpro/source/filter/lwpfoundry.cxx
+++ b/lotuswordpro/source/filter/lwpfoundry.cxx
@@ -530,7 +530,7 @@ IXFStyle* LwpStyleManager::AddStyle(LwpObjectID styleObjID, IXFStyle* pStyle)
     assert(pStyle);
     //pStyle may change if same style is found in XFStyleManager
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    pStyle = pXFStyleManager->AddStyle(pStyle);
+    pStyle = pXFStyleManager->AddStyle(pStyle).m_pStyle;
     m_StyleList.insert(LwpStyleMap::value_type(styleObjID, pStyle));
     return pStyle;
 }
diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx
index 5edc34d..61325da 100644
--- a/lotuswordpro/source/filter/lwpframelayout.cxx
+++ b/lotuswordpro/source/filter/lwpframelayout.cxx
@@ -103,7 +103,7 @@ void  LwpFrame::RegisterStyle(XFFrameStyle* pFrameStyle)
 
     pFrameStyle->SetStyleName(m_pLayout->GetName().str());
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(pFrameStyle)->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(pFrameStyle).m_pStyle->GetStyleName();
     m_pLayout->SetStyleName(m_StyleName);
 }
 /**
@@ -1270,7 +1270,7 @@ void LwpRubyLayout::RegisterStyle()
     pRubyStyle->SetPosition(eType);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    OUString rubyStyle = pXFStyleManager->AddStyle(pRubyStyle)->GetStyleName();
+    OUString rubyStyle = pXFStyleManager->AddStyle(pRubyStyle).m_pStyle->GetStyleName();
     pMarker->SetRubyStyleName(rubyStyle);
 
     LwpStory* pStory = GetContentStory();
diff --git a/lotuswordpro/source/filter/lwpfrib.cxx b/lotuswordpro/source/filter/lwpfrib.cxx
index 61d5324..ea90d08 100644
--- a/lotuswordpro/source/filter/lwpfrib.cxx
+++ b/lotuswordpro/source/filter/lwpfrib.cxx
@@ -259,9 +259,10 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry)
             pStyle->SetStyleName("");
             pFont = pFoundry->GetFontManger().CreateOverrideFont(pCharStyle->GetFinalFontID(),m_pModifiers->FontID);
             pStyle->SetFont(pFont);
-            IXFStyle *pNewStyle = pXFStyleManager->AddStyle(pStyle);
+            IXFStyleRet aNewStyle = pXFStyleManager->AddStyle(pStyle);
+            IXFStyle *pNewStyle = aNewStyle.m_pStyle;
             m_StyleName = pNewStyle->GetStyleName();
-            if (pNewStyle != pStyle)
+            if (aNewStyle.m_bOrigDeleted)
                 pStyle = NULL;
         }
         else
@@ -274,9 +275,10 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry)
             pStyle = new XFTextStyle();
             pFont = pFoundry->GetFontManger().CreateFont(m_pModifiers->FontID);
             pStyle->SetFont(pFont);
-            IXFStyle *pNewStyle = pXFStyleManager->AddStyle(pStyle);
+            IXFStyleRet aNewStyle = pXFStyleManager->AddStyle(pStyle);
+            IXFStyle *pNewStyle = aNewStyle.m_pStyle;
             m_StyleName = pNewStyle->GetStyleName();
-            if (pNewStyle != pStyle)
+            if (aNewStyle.m_bOrigDeleted)
                 pStyle = NULL;
         }
     }
@@ -302,7 +304,7 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry)
                 pFont->SetBackColor(aColor);
                 pStyle->SetFont(pFont);
             }
-            m_StyleName = pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+            m_StyleName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
         }
     }
 }
diff --git a/lotuswordpro/source/filter/lwpfribbreaks.cxx b/lotuswordpro/source/filter/lwpfribbreaks.cxx
index 43fc585..eaaf919 100644
--- a/lotuswordpro/source/filter/lwpfribbreaks.cxx
+++ b/lotuswordpro/source/filter/lwpfribbreaks.cxx
@@ -102,7 +102,7 @@ void LwpFribColumnBreak::RegisterBreakStyle(LwpPara * pPara)
             pOverStyle->SetBreaks(enumXFBreakBefColumn);
     }
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
 }
 
 LwpFribPageBreak::LwpFribPageBreak( LwpPara* pPara )
@@ -153,7 +153,7 @@ void LwpFribPageBreak::RegisterBreakStyle(LwpPara* pPara)
         pOverStyle->SetBreaks(enumXFBreakBefPage);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
 }
 
 void LwpFribPageBreak::ParseLayout()
diff --git a/lotuswordpro/source/filter/lwpfribframe.cxx b/lotuswordpro/source/filter/lwpfribframe.cxx
index 8eed873..fc16cfd 100644
--- a/lotuswordpro/source/filter/lwpfribframe.cxx
+++ b/lotuswordpro/source/filter/lwpfribframe.cxx
@@ -123,7 +123,7 @@ void LwpFribFrame::RegisterStyle(LwpFoundry* pFoundry)
                 XFParaStyle* pParaStyle = new XFParaStyle;
                 *pParaStyle = *(pOldStyle);
                 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-                m_StyleName = pXFStyleManager->AddStyle(pParaStyle)->GetStyleName();
+                m_StyleName = pXFStyleManager->AddStyle(pParaStyle).m_pStyle->GetStyleName();
             }
         }
         //remember the current paragraph font size which will be used in parsing frame
diff --git a/lotuswordpro/source/filter/lwpfribmark.cxx b/lotuswordpro/source/filter/lwpfribmark.cxx
index b9d4658..430d7e5 100644
--- a/lotuswordpro/source/filter/lwpfribmark.cxx
+++ b/lotuswordpro/source/filter/lwpfribmark.cxx
@@ -408,7 +408,7 @@ void LwpFribField::RegisterTotalTimeStyle()
     pTimeStyle->SetTruncate(false);
     pTimeStyle->AddMinute();
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle)->GetStyleName();
+    m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle).m_pStyle->GetStyleName();
 }
 
 void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
@@ -1179,9 +1179,9 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
     }
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     if (pDateStyle)
-        m_TimeStyle = pXFStyleManager->AddStyle(pDateStyle)->GetStyleName();
+        m_TimeStyle = pXFStyleManager->AddStyle(pDateStyle).m_pStyle->GetStyleName();
     if (pTimeStyle)
-        m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle)->GetStyleName();
+        m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle).m_pStyle->GetStyleName();
 }
 
 void LwpFribField::CheckFieldType(LwpFieldMark* pFieldMark)
diff --git a/lotuswordpro/source/filter/lwpfribsection.cxx b/lotuswordpro/source/filter/lwpfribsection.cxx
index 388f930..f66b00f 100644
--- a/lotuswordpro/source/filter/lwpfribsection.cxx
+++ b/lotuswordpro/source/filter/lwpfribsection.cxx
@@ -310,7 +310,7 @@ bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib)
     m_pPara->RegisterTabStyle(pOverStyle);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
     //register section style here
     if(m_bNewSection)
     {
@@ -335,7 +335,7 @@ bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib)
                 pSectStyle->SetColumns(pColumns);
             }
         //}
-        m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle)->GetStyleName();
+        m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle).m_pStyle->GetStyleName();
     }
     return false;
 }
@@ -447,7 +447,7 @@ void LwpMasterPage::RegisterFillerPageStyle()
             pPagebreakStyle->SetStyleName("");
             pPagebreakStyle->SetBreaks(enumXFBreakAftPage);
             XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-            m_FillerPageStyleName= pXFStyleManager->AddStyle(pPagebreakStyle)->GetStyleName();
+            m_FillerPageStyleName= pXFStyleManager->AddStyle(pPagebreakStyle).m_pStyle->GetStyleName();
         }
     }
 }
diff --git a/lotuswordpro/source/filter/lwpfribtable.cxx b/lotuswordpro/source/filter/lwpfribtable.cxx
index 500e44e..edd73da 100644
--- a/lotuswordpro/source/filter/lwpfribtable.cxx
+++ b/lotuswordpro/source/filter/lwpfribtable.cxx
@@ -89,7 +89,7 @@ void LwpFribTable::RegisterNewStyle()
             XFParaStyle* pParaStyle = new XFParaStyle;
             *pParaStyle = *(pOldStyle);
             XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-            m_StyleName = pXFStyleManager->AddStyle(pParaStyle)->GetStyleName();
+            m_StyleName = pXFStyleManager->AddStyle(pParaStyle).m_pStyle->GetStyleName();
         }
     }
 }
diff --git a/lotuswordpro/source/filter/lwpfribtext.cxx b/lotuswordpro/source/filter/lwpfribtext.cxx
index 31579ac..42da9cd 100644
--- a/lotuswordpro/source/filter/lwpfribtext.cxx
+++ b/lotuswordpro/source/filter/lwpfribtext.cxx
@@ -205,7 +205,7 @@ void LwpFribDocVar::RegisterDefaultTimeStyle()
     pDateStyle->AddSecond(true,0);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_TimeStyle = pXFStyleManager->AddStyle(pDateStyle)->GetStyleName();
+    m_TimeStyle = pXFStyleManager->AddStyle(pDateStyle).m_pStyle->GetStyleName();
 }
 void LwpFribDocVar::RegisterTotalTimeStyle()
 {
@@ -213,7 +213,7 @@ void LwpFribDocVar::RegisterTotalTimeStyle()
     pTimeStyle->SetTruncate(false);
     pTimeStyle->AddMinute();
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle)->GetStyleName();
+    m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle).m_pStyle->GetStyleName();
 }
 
 /**
diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx
index a4db19a..4c9f3ce 100644
--- a/lotuswordpro/source/filter/lwpgrfobj.cxx
+++ b/lotuswordpro/source/filter/lwpgrfobj.cxx
@@ -284,7 +284,7 @@ void LwpGraphicObject::RegisterStyle()
             pXFFrameStyle->SetXPosType(enumXFFrameXPosFromLeft, enumXFFrameXRelFrame);
             pXFFrameStyle->SetYPosType(enumXFFrameYPosFromTop, enumXFFrameYRelPara);
             XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-            m_strStyleName = pXFStyleManager->AddStyle(pXFFrameStyle)->GetStyleName();
+            m_strStyleName = pXFStyleManager->AddStyle(pXFFrameStyle).m_pStyle->GetStyleName();
         }
     }
 
@@ -647,7 +647,7 @@ void LwpGraphicObject::CreateGrafObject()
 
     // set style for the image
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    pImage->SetStyleName(pXFStyleManager->AddStyle(pImageStyle)->GetStyleName());
+    pImage->SetStyleName(pXFStyleManager->AddStyle(pImageStyle).m_pStyle->GetStyleName());
 
     // set archor to frame
     pImage->SetAnchorType(enumXFAnchorFrame);
diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx
index 865e4d4..ad75b88 100644
--- a/lotuswordpro/source/filter/lwppagelayout.cxx
+++ b/lotuswordpro/source/filter/lwppagelayout.cxx
@@ -338,14 +338,14 @@ void LwpPageLayout::RegisterStyle()
 
     //Add the page master to stylemanager
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_pXFPageMaster = pm1 = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(pm1));
+    m_pXFPageMaster = pm1 = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(pm1).m_pStyle);
     OUString pmname = pm1->GetStyleName();
 
     //Add master page
     XFMasterPage* mp1 = new XFMasterPage();
     mp1->SetStyleName(GetName().str());
     mp1->SetPageMaster(pmname);
-    mp1 = static_cast<XFMasterPage*>(pXFStyleManager->AddStyle(mp1));
+    mp1 = static_cast<XFMasterPage*>(pXFStyleManager->AddStyle(mp1).m_pStyle);
     m_StyleName = mp1->GetStyleName();
 
     //Set footer style
@@ -397,7 +397,7 @@ OUString LwpPageLayout::RegisterEndnoteStyle()
 
     //Add the page master to stylemanager
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_pXFPageMaster = pm1 = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(pm1));
+    m_pXFPageMaster = pm1 = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(pm1).m_pStyle);
     OUString pmname = pm1->GetStyleName();
 
     //Add master page
@@ -423,7 +423,7 @@ OUString LwpPageLayout::RegisterEndnoteStyle()
         pLayoutHeader->RegisterStyle(mp1);
     }
 
-    return pXFStyleManager->AddStyle(mp1)->GetStyleName();
+    return pXFStyleManager->AddStyle(mp1).m_pStyle->GetStyleName();
 }
 /**
 * @descr:   Whether current page layout has columns
diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx
index 8ac7c8c..0f6f8bc 100644
--- a/lotuswordpro/source/filter/lwppara.cxx
+++ b/lotuswordpro/source/filter/lwppara.cxx
@@ -338,7 +338,7 @@ bool LwpPara::RegisterMasterPage(XFParaStyle* pBaseStyle)
         if (!m_ParentStyleName.isEmpty())
                     pOverStyle->SetParentStyleName(m_ParentStyleName);
         XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-        m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
+        m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
     }
     return bSuccess;
 }
@@ -514,7 +514,7 @@ void LwpPara::RegisterStyle()
         }
         if (!m_ParentStyleName.isEmpty())
             pOverStyle->SetParentStyleName(m_ParentStyleName);
-        m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
+        m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
 
     }
     else //use named style
@@ -528,7 +528,7 @@ void LwpPara::RegisterStyle()
                     OverrideIndent(NULL,m_pIndentOverride,pOverStyle);
                     if (!m_ParentStyleName.isEmpty())
                         pOverStyle->SetParentStyleName(m_ParentStyleName);
-                    m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
+                    m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
                 }
             }
     }
@@ -543,7 +543,7 @@ void LwpPara::RegisterStyle()
             pOverStyle->SetAlignType(enumXFAlignStart);
             if (!m_ParentStyleName.isEmpty())
                 pOverStyle->SetParentStyleName(m_ParentStyleName);
-            m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
+            m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
         }
     }
 
@@ -720,7 +720,7 @@ void LwpPara::RegisterStyle()
                             if (pOldStyle)
                             {
                                 XFListStyle* pNewStyle = new XFListStyle(*pOldStyle);
-                                m_aBulletStyleName = pXFStyleManager->AddStyle(pNewStyle)->GetStyleName();
+                                m_aBulletStyleName = pXFStyleManager->AddStyle(pNewStyle).m_pStyle->GetStyleName();
                             }
                         }
                     }
@@ -756,7 +756,7 @@ void LwpPara::RegisterStyle()
             pMargin->SetTop(pMargin->GetTop()+pPrePara->GetBelowSpacing());
             if (!m_ParentStyleName.isEmpty())
                     pOverStyle->SetParentStyleName(m_ParentStyleName);
-            m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
+            m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
         }
     }
 
@@ -769,7 +769,7 @@ void LwpPara::RegisterStyle()
         this->RegisterTabStyle(pParaStyle);
         if (!m_ParentStyleName.isEmpty())
                     pParaStyle->SetParentStyleName(m_ParentStyleName);
-        m_StyleName = pXFStyleManager->AddStyle(pParaStyle)->GetStyleName();
+        m_StyleName = pXFStyleManager->AddStyle(pParaStyle).m_pStyle->GetStyleName();
     }
 
     //register master page;
@@ -787,7 +787,7 @@ void LwpPara::RegisterStyle()
         pStyle->SetDropCap(m_nChars-1,m_nLines);
         if (!m_ParentStyleName.isEmpty())
                     pStyle->SetParentStyleName(m_ParentStyleName);
-        m_StyleName = pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+        m_StyleName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
     }
     // maybe useful for futer version
     // deleted because Leader of Table is not supported in this version
@@ -806,7 +806,7 @@ void LwpPara::RegisterNewSectionStyle(LwpPageLayout *pLayout)
         pSectStyle->SetColumns(pColumns);
     }
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle)->GetStyleName();
+    m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle).m_pStyle->GetStyleName();
 }
 
 XFSection* LwpPara::CreateXFSection()
diff --git a/lotuswordpro/source/filter/lwppara1.cxx b/lotuswordpro/source/filter/lwppara1.cxx
index c9a83d9..bba1506 100644
--- a/lotuswordpro/source/filter/lwppara1.cxx
+++ b/lotuswordpro/source/filter/lwppara1.cxx
@@ -414,25 +414,25 @@ void LwpPara::OverrideParaBreaks(LwpParaProperty* pProps, XFParaStyle* pOverStyl
     {
         XFParaStyle* pStyle = new XFParaStyle();
         pStyle->SetBreaks(enumXFBreakAftPage);
-        m_BefPageBreakName = pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+        m_BefPageBreakName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
     }
     if (m_pBreaks->IsPageBreakAfter())
     {
         XFParaStyle* pStyle = new XFParaStyle();
         pStyle->SetBreaks(enumXFBreakAftPage);
-        m_AftPageBreakName = pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+        m_AftPageBreakName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
     }
     if (m_pBreaks->IsColumnBreakBefore())
     {
         XFParaStyle* pStyle = new XFParaStyle();
         pStyle->SetBreaks(enumXFBreakAftColumn);//tmp after, should change when layout read
-        m_BefColumnBreakName = pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+        m_BefColumnBreakName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
     }
     if (m_pBreaks->IsColumnBreakAfter())
     {
         XFParaStyle* pStyle = new XFParaStyle();
         pStyle->SetBreaks(enumXFBreakAftColumn);
-        m_AftColumnBreakName = pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+        m_AftColumnBreakName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
     }
 
 //  pParaStyle->ApplyBreaks(pOverStyle, &aFinalBreaks);
diff --git a/lotuswordpro/source/filter/lwprowlayout.cxx b/lotuswordpro/source/filter/lwprowlayout.cxx
index b09f1ad..32f052e 100644
--- a/lotuswordpro/source/filter/lwprowlayout.cxx
+++ b/lotuswordpro/source/filter/lwprowlayout.cxx
@@ -127,7 +127,7 @@ void LwpRowLayout::RegisterStyle()
         pRowStyle->SetRowHeight((float)LwpTools::ConvertFromUnitsToMetric(cheight));
     }
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(pRowStyle)->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(pRowStyle).m_pStyle->GetStyleName();
 
     LwpTableLayout* pTableLayout = GetParentTableLayout();
     if (pTableLayout)
@@ -293,7 +293,7 @@ void LwpRowLayout::RegisterCurRowStyle(XFRow* pXFRow,sal_uInt16 nRowMark)
         pNewStyle->SetRowHeight((float)fHeight);
     }
 
-    pXFRow->SetStyleName(pXFStyleManager->AddStyle(pNewStyle)->GetStyleName());
+    pXFRow->SetStyleName(pXFStyleManager->AddStyle(pNewStyle).m_pStyle->GetStyleName());
 }
 
 /**
diff --git a/lotuswordpro/source/filter/lwpsilverbullet.cxx b/lotuswordpro/source/filter/lwpsilverbullet.cxx
index 43a3657..c0c39e9 100644
--- a/lotuswordpro/source/filter/lwpsilverbullet.cxx
+++ b/lotuswordpro/source/filter/lwpsilverbullet.cxx
@@ -182,7 +182,7 @@ void LwpSilverBullet::RegisterStyle()
     }
 
     //add style-list to style manager.
-    m_strStyleName = pXFStyleManager->AddStyle(pListStyle)->GetStyleName();
+    m_strStyleName = pXFStyleManager->AddStyle(pListStyle).m_pStyle->GetStyleName();
 }
 
 /**
diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx
index d3e037a..6734edb 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -618,7 +618,7 @@ void LwpTableLayout::RegisterColumns()
     pColStyle->SetWidth(static_cast<float>(dDefaultColumn));
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_DefaultColumnStyleName =  pXFStyleManager->AddStyle(pColStyle)->GetStyleName();
+    m_DefaultColumnStyleName =  pXFStyleManager->AddStyle(pColStyle).m_pStyle->GetStyleName();
 
     // register existed column style
     sal_uInt16 i=0;
@@ -665,7 +665,7 @@ void LwpTableLayout::RegisterRows()
         pRowStyle->SetRowHeight((float)pTable->GetHeight());
     }
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_DefaultRowStyleName =  pXFStyleManager->AddStyle(pRowStyle)->GetStyleName();
+    m_DefaultRowStyleName =  pXFStyleManager->AddStyle(pRowStyle).m_pStyle->GetStyleName();
 
     // register style of rows
     LwpObjectID& rRowID = GetChildHead();
@@ -736,7 +736,7 @@ void LwpTableLayout::RegisterStyle()
         pTableStyle->SetWidth(pSuper->GetTableWidth());
     }
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(pTableStyle)->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(pTableStyle).m_pStyle->GetStyleName();
 
     //convert to OO table now and register row stle
     // traverse
@@ -915,7 +915,7 @@ void LwpTableLayout::SplitRowToCells(XFTable* pTmpTable,XFTable* pXFTable,
     {
         pRowStyle->SetRowHeight((float)fHeight);
     }
-    pXFRow->SetStyleName(pXFStyleManager->AddStyle(pRowStyle)->GetStyleName());
+    pXFRow->SetStyleName(pXFStyleManager->AddStyle(pRowStyle).m_pStyle->GetStyleName());
 
     //construct headong row
     XFCell* pXFCell1 = new XFCell;
@@ -1224,7 +1224,7 @@ void LwpTableLayout::PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_
                 }
 
                 pOverStyle->SetStyleName("");
-                OUString StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
+                OUString StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
 
                 pXFPara->SetStyleName(StyleName);
             }
@@ -1432,7 +1432,7 @@ void LwpColumnLayout::RegisterStyle(double dCalculatedWidth)
     XFColStyle * pColStyle = new XFColStyle();
     pColStyle->SetWidth(static_cast<float>(dCalculatedWidth));
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(pColStyle)->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(pColStyle).m_pStyle->GetStyleName();
 }
 
 LwpTableHeadingLayout::LwpTableHeadingLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
diff --git a/lotuswordpro/source/filter/lwptoc.cxx b/lotuswordpro/source/filter/lwptoc.cxx
index d36a965..2020e93 100644
--- a/lotuswordpro/source/filter/lwptoc.cxx
+++ b/lotuswordpro/source/filter/lwptoc.cxx
@@ -134,7 +134,7 @@ void LwpTocSuperLayout::RegisterStyle()
     XFTextStyle*pTextStyle = new XFTextStyle;
     pTextStyle->SetFont(pBaseStyle->GetFont()); // who delete this font?????
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_TabStyleName = pXFStyleManager->AddStyle(pTextStyle)->GetStyleName();
+    m_TabStyleName = pXFStyleManager->AddStyle(pTextStyle).m_pStyle->GetStyleName();
 
 }
 /**
diff --git a/lotuswordpro/source/filter/xfilter/xfstylecont.cxx b/lotuswordpro/source/filter/xfilter/xfstylecont.cxx
index 517d15b..b5f4434 100644
--- a/lotuswordpro/source/filter/xfilter/xfstylecont.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfstylecont.cxx
@@ -106,13 +106,15 @@ void    XFStyleContainer::Reset()
     m_aStyles.clear();
 }
 
-IXFStyle*   XFStyleContainer::AddStyle(IXFStyle *pStyle)
+IXFStyleRet XFStyleContainer::AddStyle(IXFStyle *pStyle)
 {
+    IXFStyleRet aRet;
+
     IXFStyle    *pConStyle = NULL;
     OUString   name;
 
     if( !pStyle )
-        return NULL;
+        return aRet;
     //no matter we want to delete the style or not,XFFont object should be saved first.
     ManageStyleFont(pStyle);
 
@@ -122,7 +124,9 @@ IXFStyle*   XFStyleContainer::AddStyle(IXFStyle *pStyle)
     if( pConStyle )//such a style has exist:
     {
         delete pStyle;
-        return pConStyle;
+        aRet.m_pStyle = pConStyle;
+        aRet.m_bOrigDeleted = true;
+        return aRet;;
     }
     else
     {
@@ -144,8 +148,8 @@ IXFStyle*   XFStyleContainer::AddStyle(IXFStyle *pStyle)
 
         m_aStyles.push_back(pStyle);
         //transform the font object to XFFontFactory
-
-        return pStyle;
+        aRet.m_pStyle = pStyle;
+        return aRet;
     }
 }
 
diff --git a/lotuswordpro/source/filter/xfilter/xfstylecont.hxx b/lotuswordpro/source/filter/xfilter/xfstylecont.hxx
index 50dae18..59af93e4 100644
--- a/lotuswordpro/source/filter/xfilter/xfstylecont.hxx
+++ b/lotuswordpro/source/filter/xfilter/xfstylecont.hxx
@@ -65,6 +65,17 @@
 
 class IXFStyle;
 
+struct IXFStyleRet
+{
+    IXFStyle* m_pStyle;
+    bool m_bOrigDeleted;
+    IXFStyleRet()
+        : m_pStyle(NULL)
+        , m_bOrigDeleted(false)
+    {
+    }
+};
+
 /**
  * @descr   container object for styles.
  *          All styles can be placed into an style container.
@@ -87,7 +98,7 @@ public:
      * @descr   Add style to container.
      *          If the same style has exist, then pStyle will be deleted, and the same style will be return.
      */
-    IXFStyle*       AddStyle(IXFStyle *pStyle);
+    IXFStyleRet     AddStyle(IXFStyle *pStyle);
 
     /**
      * @descr   Find the same style.
diff --git a/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx b/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx
index 0e17576..5503805 100644
--- a/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx
@@ -104,94 +104,99 @@ void    XFStyleManager::AddFontDecl(XFFontDecl& aFontDecl)
     s_aFontDecls.push_back(aFontDecl);
 }
 
-IXFStyle*   XFStyleManager::AddStyle(IXFStyle *pStyle)
+IXFStyleRet XFStyleManager::AddStyle(IXFStyle *pStyle)
 {
+    IXFStyleRet aRet;
+
     assert(pStyle);
     OUString   name;
-    IXFStyle    *pStyleRet = NULL;
 
     if( !pStyle )
-        return NULL;
+        return aRet;
     name = pStyle->GetStyleName();
 
     if( pStyle->GetStyleFamily() == enumXFStyleText )
     {
         if( !name.isEmpty() )
         {
-            pStyleRet = s_aStdTextStyles.AddStyle(pStyle);
+            aRet = s_aStdTextStyles.AddStyle(pStyle);
         }
         else
-            pStyleRet = s_aTextStyles.AddStyle(pStyle);
+        {
+            aRet = s_aTextStyles.AddStyle(pStyle);
+        }
     }
     else if( pStyle->GetStyleFamily() == enumXFStylePara )
     {
         if( !name.isEmpty() )
         {
-            pStyleRet = s_aStdParaStyles.AddStyle(pStyle);
+            aRet = s_aStdParaStyles.AddStyle(pStyle);
         }
         else
-            pStyleRet = s_aParaStyles.AddStyle(pStyle);
+        {
+            aRet = s_aParaStyles.AddStyle(pStyle);
+        }
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleDefaultPara )
     {
-        pStyleRet = s_aStdParaStyles.AddStyle(pStyle);
+        aRet = s_aStdParaStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleList )
     {
-        pStyleRet = s_aListStyles.AddStyle(pStyle);
+        aRet = s_aListStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleSection )
     {
-        pStyleRet = s_aSectionStyles.AddStyle(pStyle);
+        aRet = s_aSectionStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStylePageMaster )
     {
-        pStyleRet = s_aPageMasters.AddStyle(pStyle);
+        aRet = s_aPageMasters.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleMasterPage )
     {
         //Master page don't need name.
-        pStyleRet = s_aMasterpages.AddStyle(pStyle);
+        aRet = s_aMasterpages.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleDate )
     {
-        pStyleRet = s_aDateStyles.AddStyle(pStyle);
+        aRet = s_aDateStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleTime )
     {
-        pStyleRet = s_aDateStyles.AddStyle(pStyle);
+        aRet = s_aDateStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleNumber )
     {
-        pStyleRet = s_aDateStyles.AddStyle(pStyle);
+        aRet = s_aDateStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStylePercent )
     {
-        pStyleRet = s_aDateStyles.AddStyle(pStyle);
+        aRet = s_aDateStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleCurrency )
     {
-        pStyleRet = s_aDateStyles.AddStyle(pStyle);
+        aRet = s_aDateStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleGraphics )
     {
-        pStyleRet = s_aGraphicsStyles.AddStyle(pStyle);
+        aRet = s_aGraphicsStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleTable )
     {
-        pStyleRet = s_aTableStyles.AddStyle(pStyle);
+        aRet = s_aTableStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleTableCell )
     {
-        pStyleRet = s_aTableCellStyles.AddStyle(pStyle);
+        aRet = s_aTableCellStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleTableRow )
     {
-        pStyleRet = s_aTableRowStyles.AddStyle(pStyle);
+        aRet = s_aTableRowStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleTableCol )
     {
-        pStyleRet = s_aTableColStyles.AddStyle(pStyle);
+        aRet = s_aTableColStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleOutline )
     {
@@ -201,22 +206,22 @@ IXFStyle*   XFStyleManager::AddStyle(IXFStyle *pStyle)
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleStrokeDash )
     {
-        pStyleRet = s_aStdStrokeDashStyles.AddStyle(pStyle);
+        aRet = s_aStdStrokeDashStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleArea )
     {
-        pStyleRet = s_aStdAreaStyles.AddStyle(pStyle);
+        aRet = s_aStdAreaStyles.AddStyle(pStyle);
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleArrow )
     {
-        pStyleRet = s_aStdArrowStyles.AddStyle(pStyle);
+        aRet = s_aStdArrowStyles.AddStyle(pStyle);
     }
     else if (pStyle->GetStyleFamily() == enumXFStyleRuby)
     {
-        pStyleRet = s_aRubyStyles.AddStyle(pStyle);
+        aRet = s_aRubyStyles.AddStyle(pStyle);
     }
 
-    return pStyleRet;
+    return aRet;
 }
 
 IXFStyle*   XFStyleManager::FindStyle(const OUString& name)
diff --git a/lotuswordpro/source/filter/xfilter/xfstylemanager.hxx b/lotuswordpro/source/filter/xfilter/xfstylemanager.hxx
index a96ad5c..c3680f5 100644
--- a/lotuswordpro/source/filter/xfilter/xfstylemanager.hxx
+++ b/lotuswordpro/source/filter/xfilter/xfstylemanager.hxx
@@ -95,7 +95,7 @@ public:
 
     void        AddFontDecl(XFFontDecl& aFontDecl);
 
-    IXFStyle*   AddStyle(IXFStyle *pStyle);
+    IXFStyleRet AddStyle(IXFStyle *pStyle);
 
     IXFStyle*   FindStyle(const OUString& name);
 
commit 792b127d5ceb397c5fb280cadd80972e1693e9ec
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 09:21:27 2014 +0000

    coverity#1242888 Unused value
    
    Change-Id: Idf2709382dc431b6e34c2993d04c41aa8a3786ab

diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 47d3472..bd376ce 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -2576,11 +2576,11 @@ void ODbaseTable::copyData(ODbaseTable* _pNewTable,sal_Int32 _nPos)
                     }
                 }
                 bOk = _pNewTable->InsertRow(*aInsertRow,true,_pNewTable->m_pColumns);
-                SAL_WARN_IF(!bOk, "connectivity.drivers", "Row could not be inserted!");
+                SAL_WARN_IF(!bOk, "connectivity.drivers", "Row could not be inserted!"); (void)bOk;
             }
             else
             {
-                SAL_WARN_IF(!bOk, "connectivity.drivers", "Row could not be fetched!");
+                SAL_WARN_IF(!bOk, "connectivity.drivers", "Row could not be fetched!"); (void)bOk;
             }
         }
         else
commit 35ef13e3eb0bb3131e4439bc7c5211eed390bae4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 09:20:46 2014 +0000

    coverity#1242860 Unused value
    
    Change-Id: Id0bb878464fa6df5ed23d4abf5748ed21cb30506

diff --git a/extensions/source/scanner/sane.cxx b/extensions/source/scanner/sane.cxx
index 4c52fbe..fbf7c3c 100644
--- a/extensions/source/scanner/sane.cxx
+++ b/extensions/source/scanner/sane.cxx
@@ -680,7 +680,7 @@ bool Sane::Start( BitmapTransporter& rBitmap )
                 bSynchronousRead = false;
                 nStatus = p_set_io_mode( maHandle, SANE_TRUE );
                 CheckConsistency( "sane_set_io_mode" );
-                SAL_WARN_IF(nStatus != SANE_STATUS_GOOD, "extensions.scanner", "driver is confused" );
+                SAL_WARN_IF(nStatus != SANE_STATUS_GOOD, "extensions.scanner", "driver is confused" ); (void)nStatus;
             }
 
             SANE_Int nLen=0;
commit d2f3c168fdce3ec6253c028491dd68c25903648c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 09:20:07 2014 +0000

    coverity#1242900 Unused value
    
    Change-Id: I4276f5dabedac97c0508aa7904473a4e20767e62

diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx
index 10ee781..e999145 100644
--- a/cui/source/options/optjava.cxx
+++ b/cui/source/options/optjava.cxx
@@ -673,7 +673,7 @@ bool SvxJavaOptionsPage::FillItemSet( SfxItemSet* /*rCoreSet*/ )
         for ( i = 0; i < nSize; ++i )
             pParamArr[i] = pList[i].pData;
         eErr = jfw_setVMParameters( pParamArrIter, nSize );
-        SAL_WARN_IF(JFW_E_NONE != eErr, "cui.options", "SvxJavaOptionsPage::FillItemSet(): error in jfw_setVMParameters");
+        SAL_WARN_IF(JFW_E_NONE != eErr, "cui.options", "SvxJavaOptionsPage::FillItemSet(): error in jfw_setVMParameters"); (void)eErr;
         pParamArrIter = pParamArr;
         rtl_freeMemory( pParamArr );
         bModified = true;
@@ -685,7 +685,7 @@ bool SvxJavaOptionsPage::FillItemSet( SfxItemSet* /*rCoreSet*/ )
         if ( m_pPathDlg->GetOldPath() != sPath )
         {
             eErr = jfw_setUserClassPath( sPath.pData );
-            SAL_WARN_IF(JFW_E_NONE != eErr, "cui.options", "SvxJavaOptionsPage::FillItemSet(): error in jfw_setUserClassPath");
+            SAL_WARN_IF(JFW_E_NONE != eErr, "cui.options", "SvxJavaOptionsPage::FillItemSet(): error in jfw_setUserClassPath"); (void)eErr;
             bModified = true;
         }
     }
@@ -720,7 +720,7 @@ bool SvxJavaOptionsPage::FillItemSet( SfxItemSet* /*rCoreSet*/ )
                     }
 
                     eErr = jfw_setSelectedJRE( pInfo );
-                    SAL_WARN_IF(JFW_E_NONE != eErr, "cui.options", "SvxJavaOptionsPage::FillItemSet(): error in jfw_setSelectedJRE");
+                    SAL_WARN_IF(JFW_E_NONE != eErr, "cui.options", "SvxJavaOptionsPage::FillItemSet(): error in jfw_setSelectedJRE"); (void)eErr;
                     bModified = true;
                 }
             }
commit cb19a99ba8a81a4d869313652c0fe3cc3d0e221e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 14 09:18:05 2014 +0000

    coverity#1251173 Dereference before null check
    
    Change-Id: I3e5a70289785f905350c895b6c869eaebe360bf8

diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index a66a091..f5b977c 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -667,17 +667,17 @@ void DrawViewShell::FuDeleteSelectedObjects()
         bConsumed = true;
     }
 
-    if (!bConsumed)
+    if (!bConsumed && mpDrawView)
     {
         ::vcl::KeyCode aKCode(KEY_DELETE);
         KeyEvent aKEvt( 0, aKCode);
 
         bConsumed = mpDrawView->getSmartTags().KeyInput( aKEvt );
 
-        if( !bConsumed && HasCurrentFunction() )
+        if (!bConsumed && HasCurrentFunction())
             bConsumed = GetCurrentFunction()->KeyInput(aKEvt);
 
-        if( !bConsumed && mpDrawView )
+        if (!bConsumed)
             mpDrawView->DeleteMarked();
     }
 }


More information about the Libreoffice-commits mailing list