[Libreoffice-commits] core.git: 5 commits - basic/source dbaccess/source include/sfx2 include/tools reportdesign/source sal/rtl sfx2/source starmath/source sw/source tools/source vcl/source xmloff/source

Stephan Bergmann sbergman at redhat.com
Wed Oct 9 12:02:56 PDT 2013


 basic/source/uno/scriptcont.cxx                      |   15 +++-
 dbaccess/source/core/dataaccess/databasedocument.cxx |    1 
 include/sfx2/sfxuno.hxx                              |    1 
 include/tools/diagnose_ex.h                          |    1 
 reportdesign/source/core/api/ReportDefinition.cxx    |    1 
 sal/rtl/strtmpl.cxx                                  |    2 
 sfx2/source/appl/linkmgr2.cxx                        |    2 
 sfx2/source/doc/DocumentMetadataAccess.cxx           |    6 +
 sfx2/source/doc/SfxDocumentMetaData.cxx              |    6 +
 sfx2/source/doc/guisaveas.cxx                        |   66 +++++++++++--------
 sfx2/source/doc/objserv.cxx                          |    7 +-
 sfx2/source/doc/sfxbasemodel.cxx                     |   43 ++++++++----
 sfx2/source/view/ipclient.cxx                        |    1 
 starmath/source/parse.cxx                            |   20 ++---
 sw/source/core/unocore/unofield.cxx                  |    4 -
 sw/source/ui/dbui/mmoutputpage.cxx                   |    1 
 tools/source/debug/debug.cxx                         |    1 
 vcl/source/control/field2.cxx                        |    4 -
 vcl/source/filter/wmf/emfwr.cxx                      |   10 ++
 vcl/source/filter/wmf/wmfwr.cxx                      |   10 ++
 xmloff/source/core/xmlexp.cxx                        |    6 +
 21 files changed, 128 insertions(+), 80 deletions(-)

New commits:
commit 57a28dc9556b4e6fff337e0eb9d0d8abc5223161
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 9 19:10:32 2013 +0200

    Fail fast at least in debug builds
    
    Change-Id: I266d5cf5b98827617f7ed65c94a772e28808f386

diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx
index 61103fe..fc618d3 100644
--- a/sal/rtl/strtmpl.cxx
+++ b/sal/rtl/strtmpl.cxx
@@ -1266,7 +1266,7 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newFromSubString )( IMPL_RTL_STRINGDATA** ppT
     }
     if ( count < 0 || beginIndex < 0 || beginIndex + count > pFrom->length )
     {
-        OSL_FAIL( "Out of bounds substring access" );
+        assert(false); // fail fast at least in debug builds
         IMPL_RTL_STRINGNAME( newFromLiteral )( ppThis, "!!br0ken!!", 10, 0 );
         return;
     }
commit 34e951bd7284d2e771c279e3adc3899d191fdad0
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 9 21:01:15 2013 +0200

    More OUString::copy out-of-bounds fixes
    
    Change-Id: I45762d167d04252e32155a7b23a3290688bccdf6

diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index 0faf853..a49d49b 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -246,7 +246,7 @@ bool LinkManager::GetDisplayNames( const SvBaseLink * pLink,
                     if( pLinkStr )
                         *pLinkStr = sRange;
                     if( pFilter )
-                        *pFilter = sLNm.copy( nPos );
+                        *pFilter = nPos == -1 ? OUString() : sLNm.copy(nPos);
 
                     if( pType )
                     {
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 2302087..5a79bbb 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -441,7 +441,7 @@ void SmParser::NextToken()
         }
         else if (aRes.TokenType & KParseType::ONE_SINGLE_CHAR)
         {
-            if (nRealStart + 2 <= nBufLen && m_aBufferString.copy(nRealStart, 2) == "%%")
+            if (nRealStart + 2 <= nBufLen && m_aBufferString.match("%%", nRealStart))
             {
                 //SkipComment
                 m_nBufferIndex = nRealStart + 2;
@@ -543,7 +543,7 @@ void SmParser::NextToken()
             {
                 case '<':
                     {
-                        if (m_aBufferString.copy(nRealStart, 2) == "<<")
+                        if (m_aBufferString.match("<<", nRealStart))
                         {
                             m_aCurToken.eType    = TLL;
                             m_aCurToken.cMathChar = MS_LL;
@@ -553,7 +553,7 @@ void SmParser::NextToken()
 
                             rnEndPos = nRealStart + 2;
                         }
-                        else if (m_aBufferString.copy(nRealStart, 2) == "<=")
+                        else if (m_aBufferString.match("<=", nRealStart))
                         {
                             m_aCurToken.eType    = TLE;
                             m_aCurToken.cMathChar = MS_LE;
@@ -563,7 +563,7 @@ void SmParser::NextToken()
 
                             rnEndPos = nRealStart + 2;
                         }
-                        else if (m_aBufferString.copy(nRealStart, 2) == "<>")
+                        else if (m_aBufferString.match("<>", nRealStart))
                         {
                             m_aCurToken.eType    = TNEQ;
                             m_aCurToken.cMathChar = MS_NEQ;
@@ -573,7 +573,7 @@ void SmParser::NextToken()
 
                             rnEndPos = nRealStart + 2;
                         }
-                        else if (m_aBufferString.copy(nRealStart, 3) == "<?>")
+                        else if (m_aBufferString.match("<?>", nRealStart))
                         {
                             m_aCurToken.eType    = TPLACE;
                             m_aCurToken.cMathChar = MS_PLACE;
@@ -595,7 +595,7 @@ void SmParser::NextToken()
                     break;
                 case '>':
                     {
-                        if (m_aBufferString.copy(nRealStart, 2) == ">=")
+                        if (m_aBufferString.match(">=", nRealStart))
                         {
                             m_aCurToken.eType    = TGE;
                             m_aCurToken.cMathChar = MS_GE;
@@ -605,7 +605,7 @@ void SmParser::NextToken()
 
                             rnEndPos = nRealStart + 2;
                         }
-                        else if (m_aBufferString.copy(nRealStart, 2) == ">>")
+                        else if (m_aBufferString.match(">>", nRealStart))
                         {
                             m_aCurToken.eType    = TGG;
                             m_aCurToken.cMathChar = MS_GG;
@@ -770,7 +770,7 @@ void SmParser::NextToken()
                     break;
                 case '#':
                     {
-                        if (m_aBufferString.copy(nRealStart, 2) == "##")
+                        if (m_aBufferString.match("##", nRealStart))
                         {
                             m_aCurToken.eType    = TDPOUND;
                             m_aCurToken.cMathChar = '\0';
@@ -828,7 +828,7 @@ void SmParser::NextToken()
                     break;
                 case '+':
                     {
-                        if (m_aBufferString.copy(nRealStart, 2) == "+-")
+                        if (m_aBufferString.match("+-", nRealStart))
                         {
                             m_aCurToken.eType    = TPLUSMINUS;
                             m_aCurToken.cMathChar = MS_PLUSMINUS;
@@ -850,7 +850,7 @@ void SmParser::NextToken()
                     break;
                 case '-':
                     {
-                        if (m_aBufferString.copy(nRealStart, 2) == "-+")
+                        if (m_aBufferString.match("-+", nRealStart))
                         {
                             m_aCurToken.eType    = TMINUSPLUS;
                             m_aCurToken.cMathChar = MS_MINUSPLUS;
diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx
index fa3fee2..162dfff 100644
--- a/vcl/source/control/field2.cxx
+++ b/vcl/source/control/field2.cxx
@@ -19,6 +19,8 @@
 
 #include "sal/config.h"
 
+#include <algorithm>
+
 #include <tools/diagnose_ex.h>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/string.hxx>
@@ -1015,7 +1017,7 @@ static sal_uInt16 ImplCutNumberFromString( OUString& rStr )
         ++i2;
     }
     sal_Int32 nValue = rStr.copy(i1, i2-i1).toInt32();
-    rStr = rStr.copy(i2+1);
+    rStr = rStr.copy(std::min(i2+1, rStr.getLength()));
     return nValue;
 }
 
diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx
index bc1fee3..b628cd8 100644
--- a/vcl/source/filter/wmf/emfwr.cxx
+++ b/vcl/source/filter/wmf/emfwr.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include "sal/config.h"
+
+#include <algorithm>
+
 #include "emfwr.hxx"
 #include <rtl/strbuf.hxx>
 #include <tools/helpers.hxx>
@@ -1353,7 +1357,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
             case META_TEXT_ACTION:
             {
                 const MetaTextAction*   pA = (const MetaTextAction*) pAction;
-                const OUString          aText = pA->GetText().copy( pA->GetIndex(), pA->GetLen() );
+                const OUString          aText = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) );
 
                 ImplCheckTextAttr();
                 ImplWriteTextRecord( pA->GetPoint(), aText, NULL, 0 );
@@ -1373,7 +1377,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
             case META_TEXTARRAY_ACTION:
             {
                 const MetaTextArrayAction*  pA = (const MetaTextArrayAction*) pAction;
-                const OUString              aText = pA->GetText().copy( pA->GetIndex(), pA->GetLen() );
+                const OUString              aText = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) );
 
                 ImplCheckTextAttr();
                 ImplWriteTextRecord( pA->GetPoint(), aText, pA->GetDXArray(), 0 );
@@ -1383,7 +1387,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
             case META_STRETCHTEXT_ACTION:
             {
                 const MetaStretchTextAction*    pA = (const MetaStretchTextAction*) pAction;
-                const OUString                  aText = pA->GetText().copy( pA->GetIndex(), pA->GetLen() );
+                const OUString                  aText = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) );
 
                 ImplCheckTextAttr();
                 ImplWriteTextRecord( pA->GetPoint(), aText, NULL, pA->GetWidth() );
diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx
index d69bd8f..3dc415b 100644
--- a/vcl/source/filter/wmf/wmfwr.cxx
+++ b/vcl/source/filter/wmf/wmfwr.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include "sal/config.h"
+
+#include <algorithm>
+
 #include "wmfwr.hxx"
 #include <unotools/fontcvt.hxx>
 #include "emfwr.hxx"
@@ -1182,7 +1186,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
                 case META_TEXT_ACTION:
                 {
                     const MetaTextAction * pA = (const MetaTextAction*) pMA;
-                    OUString aTemp = pA->GetText().copy( pA->GetIndex(), pA->GetLen() );
+                    OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) );
                     aSrcLineInfo = LineInfo();
                     SetAllAttr();
                     if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, NULL ) )
@@ -1194,7 +1198,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
                 {
                     const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pMA;
 
-                    OUString aTemp = pA->GetText().copy( pA->GetIndex(), pA->GetLen() );
+                    OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) );
                     aSrcLineInfo = LineInfo();
                     SetAllAttr();
                     if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, pA->GetDXArray() ) )
@@ -1205,7 +1209,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
                 case META_STRETCHTEXT_ACTION:
                 {
                     const MetaStretchTextAction* pA = (const MetaStretchTextAction *) pMA;
-                    OUString aTemp = pA->GetText().copy( pA->GetIndex(), pA->GetLen() );
+                    OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) );
 
                     sal_uInt16 nLen,i;
                     sal_Int32 nNormSize;
commit f58ee783eebf74108c1c1dd5f24e6abaa19c4f09
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 9 19:23:35 2013 +0200

    Improve ErrorCodeIOException messages
    
    ...and clean up some includes.
    
    Change-Id: Ia5843cd38f967722d7173a6c87fba26064e3ffd6

diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx
index 0104fd8..65e9d02 100644
--- a/basic/source/uno/scriptcont.cxx
+++ b/basic/source/uno/scriptcont.cxx
@@ -980,7 +980,11 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary
                     {
                         sal_Int32 nError = pStream ? pStream->GetError() : ERRCODE_IO_GENERAL;
                         delete pStream;
-                        throw task::ErrorCodeIOException( OUString(), uno::Reference< uno::XInterface >(), nError );
+                        throw task::ErrorCodeIOException(
+                            ("utl::UcbStreamHelper::CreateStream failed for \""
+                             + aCodeStreamName + "\": 0x"
+                             + OUString::number(nError, 16)),
+                            uno::Reference< uno::XInterface >(), nError);
                     }
 
                     /*sal_Bool bRet = */pMod->LoadBinaryData( *pStream );
@@ -1094,9 +1098,12 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary
                             {
                                 sal_Int32 nError = pStream ? pStream->GetError() : ERRCODE_IO_GENERAL;
                                 delete pStream;
-                                throw task::ErrorCodeIOException( OUString(),
-                                                                    uno::Reference< uno::XInterface >(),
-                                                                    nError );
+                                throw task::ErrorCodeIOException(
+                                    ("utl::UcbStreamHelper::CreateStream failed"
+                                     " for code.bin: 0x"
+                                     + OUString::number(nError, 16)),
+                                    uno::Reference< uno::XInterface >(),
+                                    nError);
                             }
 
                             /*sal_Bool bRet = */pMod->LoadBinaryData( *pStream );
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx
index 613ee0a..d3b4e47 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -47,7 +47,6 @@
 #include <com/sun/star/script/provider/theMasterScriptProviderFactory.hpp>
 #include <com/sun/star/sdb/DatabaseContext.hpp>
 #include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
-#include <com/sun/star/task/ErrorCodeIOException.hpp>
 #include <com/sun/star/task/XStatusIndicator.hpp>
 #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
diff --git a/include/sfx2/sfxuno.hxx b/include/sfx2/sfxuno.hxx
index 2f69e6e..70029b1 100644
--- a/include/sfx2/sfxuno.hxx
+++ b/include/sfx2/sfxuno.hxx
@@ -28,7 +28,6 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
 #include <com/sun/star/lang/XTypeProvider.hpp>
-#include <com/sun/star/task/ErrorCodeIOException.hpp>
 #include <com/sun/star/beans/NamedValue.hpp>
 
 #include <com/sun/star/uno/Type.h>
diff --git a/include/tools/diagnose_ex.h b/include/tools/diagnose_ex.h
index 50a400d..445ea7e 100644
--- a/include/tools/diagnose_ex.h
+++ b/include/tools/diagnose_ex.h
@@ -34,7 +34,6 @@
 
 #if OSL_DEBUG_LEVEL > 0
     #include <com/sun/star/configuration/CorruptedConfigurationException.hpp>
-    #include <com/sun/star/task/ErrorCodeIOException.hpp>
     #include <cppuhelper/exc_hlp.hxx>
     #include <osl/diagnose.h>
     #include <osl/thread.h>
diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx
index d266504..680172f 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -71,7 +71,6 @@
 #include <com/sun/star/table/BorderLine2.hpp>
 #include <com/sun/star/table/ShadowFormat.hpp>
 #include <com/sun/star/task/InteractionHandler.hpp>
-#include <com/sun/star/task/ErrorCodeIOException.hpp>
 #include <com/sun/star/task/XStatusIndicator.hpp>
 #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
 #include <com/sun/star/ui/UIConfigurationManager.hpp>
diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx
index 623aa84..e3d71f9 100644
--- a/sfx2/source/doc/DocumentMetadataAccess.cxx
+++ b/sfx2/source/doc/DocumentMetadataAccess.cxx
@@ -1382,8 +1382,10 @@ throw (uno::RuntimeException, lang::IllegalArgumentException,
             if ( nError == ERRCODE_NONE ) {
                 nError = ERRCODE_IO_GENERAL;
             }
-            task::ErrorCodeIOException ex( OUString(),
-                    uno::Reference< uno::XInterface >(), nError);
+            task::ErrorCodeIOException ex(
+                ("DocumentMetadataAccess::storeMetadataToMedium Commit failed: "
+                 "0x" + OUString::number(nError, 16)),
+                uno::Reference< uno::XInterface >(), nError);
             throw lang::WrappedTargetException(OUString(), *this,
                     uno::makeAny(ex));
         }
diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx
index 4e89b6a..5bdcc7e 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -2118,8 +2118,10 @@ SfxDocumentMetaData::storeToMedium(const OUString & URL,
             nError = ERRCODE_IO_GENERAL;
         }
 
-        throw css::task::ErrorCodeIOException( OUString(),
-                css::uno::Reference< css::uno::XInterface >(), nError);
+        throw css::task::ErrorCodeIOException(
+            ("SfxDocumentMetaData::storeToMedium <" + URL + "> Commit failed: "
+             "0x" + OUString::number(nError, 16)),
+            css::uno::Reference< css::uno::XInterface >(), nError);
 
     }
 }
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index f8f8805..79af8ed 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -31,6 +31,7 @@
 #include <com/sun/star/document/XExporter.hpp>
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
 #include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/task/ErrorCodeIOException.hpp>
 #include <com/sun/star/task/InteractionHandler.hpp>
 #include <com/sun/star/util/DateTime.hpp>
 #include <com/sun/star/util/URLTransformer.hpp>
@@ -152,9 +153,10 @@ static sal_uInt8 getStoreModeFromSlotName( const OUString& aSlotName )
     else if ( aSlotName == "SaveAs" )
         nResult = SAVEAS_REQUESTED;
     else
-        throw task::ErrorCodeIOException( OUString(),
-                                            uno::Reference< uno::XInterface >(),
-                                            ERRCODE_IO_INVALIDPARAMETER );
+        throw task::ErrorCodeIOException(
+            ("getStoreModeFromSlotName(\"" + aSlotName
+             + "): ERRCODE_IO_INVALIDPARAMETER"),
+            uno::Reference< uno::XInterface >(), ERRCODE_IO_INVALIDPARAMETER );
 
     return nResult;
 }
@@ -609,9 +611,11 @@ sal_Bool ModelData_Impl::ExecuteFilterDialog_Impl( const OUString& aFilterName )
                             }
                             else
                             {
-                                throw task::ErrorCodeIOException( OUString(),
-                                                                    uno::Reference< uno::XInterface >(),
-                                                                    ERRCODE_IO_ABORT );
+                                throw task::ErrorCodeIOException(
+                                    ("ModelData_Impl::ExecuteFilterDialog_Impl:"
+                                     " ERRCODE_IO_ABORT"),
+                                    uno::Reference< uno::XInterface >(),
+                                    ERRCODE_IO_ABORT);
                             }
                         }
                     }
@@ -621,12 +625,13 @@ sal_Bool ModelData_Impl::ExecuteFilterDialog_Impl( const OUString& aFilterName )
             }
         }
     }
-    catch( const container::NoSuchElementException& )
+    catch( const container::NoSuchElementException& e )
     {
         // the filter name is unknown
-        throw task::ErrorCodeIOException( OUString(),
-                                            uno::Reference< uno::XInterface >(),
-                                            ERRCODE_IO_INVALIDPARAMETER );
+        throw task::ErrorCodeIOException(
+            ("ModelData_Impl::ExecuteFilterDialog_Impl: NoSuchElementException"
+             " \"" + e.Message + "\": ERRCODE_IO_ABORT"),
+            uno::Reference< uno::XInterface >(), ERRCODE_IO_INVALIDPARAMETER);
     }
     catch( const task::ErrorCodeIOException& )
     {
@@ -870,9 +875,10 @@ sal_Bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
 
     // the file name must be specified if overwrite option is set
     if ( aOverwriteIter != GetMediaDescr().end() )
-           throw task::ErrorCodeIOException( OUString(),
-                                            uno::Reference< uno::XInterface >(),
-                                            ERRCODE_IO_INVALIDPARAMETER );
+           throw task::ErrorCodeIOException(
+               "ModelData_Impl::OutputFileDialog: ERRCODE_IO_INVALIDPARAMETER",
+               uno::Reference< uno::XInterface >(),
+               ERRCODE_IO_INVALIDPARAMETER);
 
     // no target file name is specified
     // we need to show the file dialog
@@ -1053,7 +1059,9 @@ sal_Bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
     OUString aStringTypeFN;
     if ( pFileDlg->Execute( pDialogParams, aStringTypeFN ) != ERRCODE_NONE )
     {
-        throw task::ErrorCodeIOException( OUString(), uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT );
+        throw task::ErrorCodeIOException(
+            "ModelData_Impl::OutputFileDialog: ERRCODE_IO_ABORT",
+            uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT);
     }
 
     OUString aFilterName = aStringTypeFN;
@@ -1378,7 +1386,9 @@ sal_Bool SfxStoringHelper::GUIStoreModel( uno::Reference< frame::XModel > xModel
 
         // if saving is not acceptable the warning must be shown even in case of SaveAs operation
         if ( ( nStoreMode & SAVEAS_REQUESTED ) && aModelData.CheckSaveAcceptable( STATUS_SAVEAS ) == STATUS_NO_ACTION )
-            throw task::ErrorCodeIOException( OUString(), uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT );
+            throw task::ErrorCodeIOException(
+                "SfxStoringHelper::GUIStoreModel: ERRCODE_IO_ABORT",
+                uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT);
     }
     else if ( nStoreMode & SAVE_REQUESTED )
     {
@@ -1386,7 +1396,9 @@ sal_Bool SfxStoringHelper::GUIStoreModel( uno::Reference< frame::XModel > xModel
         nStatusSave = aModelData.CheckSaveAcceptable( STATUS_SAVE );
 
         if ( nStatusSave == STATUS_NO_ACTION )
-            throw task::ErrorCodeIOException( OUString(), uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT );
+            throw task::ErrorCodeIOException(
+                "SfxStoringHelper::GUIStoreModel: ERRCODE_IO_ABORT",
+                uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT);
         else if ( nStatusSave == STATUS_SAVE )
         {
             // check whether it is possible to use save operation
@@ -1395,7 +1407,9 @@ sal_Bool SfxStoringHelper::GUIStoreModel( uno::Reference< frame::XModel > xModel
 
         if ( nStatusSave == STATUS_NO_ACTION )
         {
-            throw task::ErrorCodeIOException( OUString(), uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT );
+            throw task::ErrorCodeIOException(
+                "SfxStoringHelper::GUIStoreModel: ERRCODE_IO_ABORT",
+                uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT);
         }
         else if ( nStatusSave != STATUS_SAVE )
         {
@@ -1417,9 +1431,9 @@ sal_Bool SfxStoringHelper::GUIStoreModel( uno::Reference< frame::XModel > xModel
             if ( QueryBox( NULL, SfxResId( RID_XMLSEC_QUERY_LOSINGSIGNATURE ) ).Execute() != RET_YES )
             {
                 // the user has decided not to store the document
-                throw task::ErrorCodeIOException( OUString(),
-                                                  uno::Reference< uno::XInterface >(),
-                                                  ERRCODE_IO_ABORT );
+                throw task::ErrorCodeIOException(
+                    "SfxStoringHelper::GUIStoreModel: ERRCODE_IO_ABORT",
+                    uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT);
             }
         }
     }
@@ -1456,9 +1470,9 @@ sal_Bool SfxStoringHelper::GUIStoreModel( uno::Reference< frame::XModel > xModel
 
     DBG_ASSERT( aFilterProps.getLength(), "No filter for storing!\n" );
     if ( !aFilterProps.getLength() )
-        throw task::ErrorCodeIOException( OUString(),
-                                            uno::Reference< uno::XInterface >(),
-                                            ERRCODE_IO_INVALIDPARAMETER );
+        throw task::ErrorCodeIOException(
+            "SfxStoringHelper::GUIStoreModel: ERRCODE_IO_INVALIDPARAMETER",
+            uno::Reference< uno::XInterface >(), ERRCODE_IO_INVALIDPARAMETER);
 
     ::comphelper::SequenceAsHashMap aFilterPropsHM( aFilterProps );
     OUString aFilterName = aFilterPropsHM.getUnpackedValueOrDefault(
@@ -1607,9 +1621,9 @@ sal_Bool SfxStoringHelper::GUIStoreModel( uno::Reference< frame::XModel > xModel
     else
     {
         DBG_ASSERT( sal_False, "This code must be unreachable!\n" );
-        throw task::ErrorCodeIOException( OUString(),
-                                            uno::Reference< uno::XInterface >(),
-                                            ERRCODE_IO_INVALIDPARAMETER );
+        throw task::ErrorCodeIOException(
+            "SfxStoringHelper::GUIStoreModel: ERRCODE_IO_INVALIDPARAMETER",
+            uno::Reference< uno::XInterface >(), ERRCODE_IO_INVALIDPARAMETER);
     }
 
     ::comphelper::SequenceAsHashMap::const_iterator aIter =
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 3a2ce2e..2fe263e 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -30,6 +30,7 @@
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/document/XCmisDocument.hpp>
 #include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/task/ErrorCodeIOException.hpp>
 #include <com/sun/star/task/InteractionHandler.hpp>
 #include <com/sun/star/task/XStatusIndicator.hpp>
 #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
@@ -692,9 +693,9 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
                 else
                 {
                     // the user has decided not to store the document
-                    throw task::ErrorCodeIOException( OUString(),
-                                                      uno::Reference< uno::XInterface >(),
-                                                      ERRCODE_IO_ABORT );
+                    throw task::ErrorCodeIOException(
+                        "SfxObjectShell::ExecFile_Impl: ERRCODE_IO_ABORT",
+                        uno::Reference< uno::XInterface >(), ERRCODE_IO_ABORT);
                 }
 
                 // merge aDispatchArgs to the request
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index d777659..e7888a4 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -22,6 +22,7 @@
 #include <sfx2/sfxbasemodel.hxx>
 
 #include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/task/ErrorCodeIOException.hpp>
 #include <com/sun/star/task/ErrorCodeRequest.hpp>
 #include <com/sun/star/view/XSelectionSupplier.hpp>
 #include <com/sun/star/view/XPrintJobListener.hpp>
@@ -1660,7 +1661,9 @@ void SAL_CALL SfxBaseModel::storeSelf( const    Sequence< beans::PropertyValue >
             // write the contents of the logger to the file
             SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOCFAILED, GlobalEventConfig::GetEventName(STR_EVENT_SAVEDOCFAILED), m_pData->m_pObjectShell ) );
 
-            throw task::ErrorCodeIOException( OUString(), Reference< XInterface >(), nErrCode );
+            throw task::ErrorCodeIOException(
+                "SfxBaseModel::storeSelf: 0x" + OUString::number(nErrCode, 16),
+                Reference< XInterface >(), nErrCode);
         }
     }
 
@@ -1807,7 +1810,9 @@ void SAL_CALL SfxBaseModel::initNew()
         m_pData->m_pObjectShell->ResetError();
 
         if ( !bRes )
-            throw task::ErrorCodeIOException( OUString(), Reference< XInterface >(), nErrCode );
+            throw task::ErrorCodeIOException(
+                "SfxBaseModel::initNew: 0x" + OUString::number(nErrCode, 16),
+                Reference< XInterface >(), nErrCode);
     }
 }
 
@@ -2733,9 +2738,10 @@ void SfxBaseModel::handleLoadError( sal_uInt32 nError, SfxMedium* pMedium )
 
     if ( !bWarning )    // #i30711# don't abort loading if it's only a warning
     {
-        throw task::ErrorCodeIOException( OUString(),
-                                            Reference< XInterface >(),
-                                            nError ? nError : ERRCODE_IO_CANTREAD );
+        nError = nError ? nError : ERRCODE_IO_CANTREAD;
+        throw task::ErrorCodeIOException(
+            "SfxBaseModel::handleLoadError: 0x" + OUString::number(nError, 16),
+            Reference< XInterface >(), nError);
     }
 }
 
@@ -3158,7 +3164,10 @@ void SfxBaseModel::impl_store(  const   OUString&                   sURL
             SFX_APP()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOCFAILED : SFX_EVENT_SAVEASDOCFAILED, GlobalEventConfig::GetEventName( bSaveTo ? STR_EVENT_SAVETODOCFAILED : STR_EVENT_SAVEASDOCFAILED),
                                                     m_pData->m_pObjectShell ) );
 
-            throw task::ErrorCodeIOException( OUString(), Reference< XInterface >(), nErrCode );
+            throw task::ErrorCodeIOException(
+                ("SfxBaseModel::impl_store <" + sURL + "> failed: 0x"
+                 + OUString::number(nErrCode, 16)),
+                Reference< XInterface >(), nErrCode);
         }
     }
 }
@@ -3781,9 +3790,10 @@ void SAL_CALL SfxBaseModel::loadFromStorage( const Reference< embed::XStorage >&
     if ( !m_pData->m_pObjectShell->DoLoad(pMedium) )
     {
         sal_uInt32 nError = m_pData->m_pObjectShell->GetErrorCode();
-        throw task::ErrorCodeIOException( OUString(),
-                                            Reference< XInterface >(),
-                                            nError ? nError : ERRCODE_IO_CANTREAD );
+        nError = nError ? nError : ERRCODE_IO_CANTREAD;
+        throw task::ErrorCodeIOException(
+            "SfxBaseModel::loadFromStorage: 0x" + OUString::number(nError, 16),
+            Reference< XInterface >(), nError);
     }
     loadCmisProperties( );
 }
@@ -3844,9 +3854,10 @@ void SAL_CALL SfxBaseModel::storeToStorage( const Reference< embed::XStorage >&
     // the warnings are currently not transported
     if ( !bSuccess )
     {
-        throw task::ErrorCodeIOException( OUString(),
-                                            Reference< XInterface >(),
-                                            nError ? nError : ERRCODE_IO_GENERAL );
+        nError = nError ? nError : ERRCODE_IO_GENERAL;
+        throw task::ErrorCodeIOException(
+            "SfxBaseModel::storeToStorage: 0x" + OUString::number(nError, 16),
+            Reference< XInterface >(), nError);
     }
 }
 
@@ -3868,9 +3879,11 @@ void SAL_CALL SfxBaseModel::switchToStorage( const Reference< embed::XStorage >&
         if ( !m_pData->m_pObjectShell->SwitchPersistance( xStorage ) )
         {
             sal_uInt32 nError = m_pData->m_pObjectShell->GetErrorCode();
-            throw task::ErrorCodeIOException( OUString(),
-                                                Reference< XInterface >(),
-                                                nError ? nError : ERRCODE_IO_GENERAL );
+            nError = nError ? nError : ERRCODE_IO_GENERAL;
+            throw task::ErrorCodeIOException(
+                ("SfxBaseModel::switchToStorage: 0x"
+                 + OUString::number(nError, 16)),
+                Reference< XInterface >(), nError);
         }
         else
         {
diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx
index d3c5989..19d61a5 100644
--- a/sfx2/source/view/ipclient.cxx
+++ b/sfx2/source/view/ipclient.cxx
@@ -33,6 +33,7 @@
 #include <com/sun/star/embed/StateChangeInProgressException.hpp>
 #include <com/sun/star/embed/XLinkageSupport.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/task/ErrorCodeIOException.hpp>
 #include <com/sun/star/task/StatusIndicatorFactory.hpp>
 #include <com/sun/star/task/XStatusIndicator.hpp>
 
diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx
index 57aff12..2326071 100644
--- a/sw/source/ui/dbui/mmoutputpage.cxx
+++ b/sw/source/ui/dbui/mmoutputpage.cxx
@@ -53,6 +53,7 @@
 #include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
 #include <com/sun/star/sdb/XColumn.hpp>
+#include <com/sun/star/task/ErrorCodeIOException.hpp>
 #include <dbmgr.hxx>
 #include <swunohelper.hxx>
 #include <osl/mutex.hxx>
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index a9a713b..ceea780 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -34,6 +34,7 @@
 #include <windows.h>
 #endif
 
+#include "com/sun/star/task/ErrorCodeIOException.hpp"
 #include <tools/debug.hxx>
 #include <rtl/string.h>
 #include <sal/log.hxx>
commit 669655d146ea87db2df28125b02bcfdfe4ef61d7
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 9 19:12:14 2013 +0200

    Improve error reporting
    
    Change-Id: I43df9a5458cb87145a3492e1a0c97ceb8c8a3b90

diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index 5e91937..1c76433 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -68,6 +68,7 @@
 #include "xmloff/XMLFilterServiceNames.h"
 #include "xmloff/XMLEmbeddedObjectExportFilter.hxx"
 #include "XMLBasicExportFilter.hxx"
+#include "cppuhelper/exc_hlp.hxx"
 #include <cppuhelper/implbase1.hxx>
 #include <comphelper/extract.hxx>
 #include <comphelper/servicehelper.hxx>
@@ -842,9 +843,10 @@ sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue
     {
         // We must catch exceptions, because according to the
         // API definition export must not throw one!
-        Sequence<OUString> aSeq(0);
+        css::uno::Any ex(cppu::getCaughtException());
         SetError( XMLERROR_FLAG_ERROR | XMLERROR_FLAG_SEVERE | XMLERROR_API,
-                  aSeq, e.Message, NULL );
+                  Sequence<OUString>(),
+                  ex.getValueTypeName() + ": \"" + e.Message + "\"", NULL );
     }
 
     // return true only if no error occurred
commit 9c489f7fe0fd81fd2d293c1cb7c7d4874f434568
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 9 19:09:34 2013 +0200

    Use rtl::OUString::startsWithIgnoreAsciiCase
    
    Change-Id: I889a072bd96b6076966e3aad84e39d3491618912

diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index fff259f..20d04cf 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -94,8 +94,6 @@
 using namespace ::com::sun::star;
 using namespace nsSwDocInfoSubType;
 
-#define COM_TEXT_FLDMASTER      "com.sun.star.text.FieldMaster."
-
 // case-corrected version of the first part for the service names (see #i67811)
 #define COM_TEXT_FLDMASTER_CC   "com.sun.star.text.fieldmaster."
 
@@ -2596,7 +2594,7 @@ SwXTextFieldMasters::~SwXTextFieldMasters()
   -----------------------------------------------------------------------*/
 static sal_uInt16 lcl_GetIdByName( OUString& rName, OUString& rTypeName )
 {
-    if (rName.startsWith(COM_TEXT_FLDMASTER) || rName.startsWith(COM_TEXT_FLDMASTER_CC))
+    if (rName.startsWithIgnoreAsciiCase(COM_TEXT_FLDMASTER_CC))
         rName = rName.copy(30);
 
     sal_uInt16 nResId = USHRT_MAX;


More information about the Libreoffice-commits mailing list