[Libreoffice-commits] core.git: 3 commits - linguistic/source sw/qa unoxml/qa

Stephan Bergmann sbergman at redhat.com
Thu Jan 22 03:53:54 PST 2015


 linguistic/source/gciterator.cxx     |  110 +++++++++++++++++++----------------
 sw/qa/extras/ww8import/ww8import.cxx |    2 
 unoxml/qa/unit/domtest.cxx           |   12 +--
 3 files changed, 67 insertions(+), 57 deletions(-)

New commits:
commit b1dbc511eeaf88e3b4b5a8a2dce129d251d2dcb6
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Jan 22 12:47:29 2015 +0100

    rhbz#1184582: At least catch and log UNO exceptions in grammar checking thread
    
    Change-Id: I87744f86d1413973709a46a58ebc03a39bce842c

diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx
index bc31490..1694d74 100644
--- a/linguistic/source/gciterator.cxx
+++ b/linguistic/source/gciterator.cxx
@@ -544,70 +544,80 @@ void GrammarCheckingIterator::DequeueAndCheck()
 
             if (xFlatPara.is() && xFPIterator.is())
             {
-                OUString aCurTxt( xFlatPara->getText() );
-                lang::Locale aCurLocale = lcl_GetPrimaryLanguageOfSentence( xFlatPara, aFPEntryItem.m_nStartIndex );
-
-                const bool bModified = xFlatPara->isModified();
-                if (!bModified)
+                try
                 {
-                    // ---- THREAD SAFE START ----
-                    ::osl::ClearableGuard< ::osl::Mutex > aGuard( MyMutex::get() );
+                    OUString aCurTxt( xFlatPara->getText() );
+                    lang::Locale aCurLocale = lcl_GetPrimaryLanguageOfSentence( xFlatPara, aFPEntryItem.m_nStartIndex );
 
-                    sal_Int32 nStartPos = aFPEntryItem.m_nStartIndex;
-                    sal_Int32 nSuggestedEnd = GetSuggestedEndOfSentence( aCurTxt, nStartPos, aCurLocale );
-                    DBG_ASSERT( (nSuggestedEnd == 0 && aCurTxt.isEmpty()) || nSuggestedEnd > nStartPos,
-                            "nSuggestedEndOfSentencePos calculation failed?" );
+                    const bool bModified = xFlatPara->isModified();
+                    if (!bModified)
+                    {
+                        // ---- THREAD SAFE START ----
+                        ::osl::ClearableGuard< ::osl::Mutex > aGuard( MyMutex::get() );
 
-                    linguistic2::ProofreadingResult aRes;
+                        sal_Int32 nStartPos = aFPEntryItem.m_nStartIndex;
+                        sal_Int32 nSuggestedEnd = GetSuggestedEndOfSentence( aCurTxt, nStartPos, aCurLocale );
+                        DBG_ASSERT( (nSuggestedEnd == 0 && aCurTxt.isEmpty()) || nSuggestedEnd > nStartPos,
+                                    "nSuggestedEndOfSentencePos calculation failed?" );
 
-                    uno::Reference< linguistic2::XProofreader > xGC( GetGrammarChecker( aCurLocale ), uno::UNO_QUERY );
-                    if (xGC.is())
-                    {
-                        aGuard.clear();
-                        uno::Sequence<beans::PropertyValue> const aProps(
+                        linguistic2::ProofreadingResult aRes;
+
+                        uno::Reference< linguistic2::XProofreader > xGC( GetGrammarChecker( aCurLocale ), uno::UNO_QUERY );
+                        if (xGC.is())
+                        {
+                            aGuard.clear();
+                            uno::Sequence<beans::PropertyValue> const aProps(
                                 lcl_makeProperties(xFlatPara));
-                        aRes = xGC->doProofreading( aCurDocId, aCurTxt,
-                                aCurLocale, nStartPos, nSuggestedEnd, aProps );
-
-                        //!! work-around to prevent looping if the grammar checker
-                        //!! failed to properly identify the sentence end
-                        if (
-                            aRes.nBehindEndOfSentencePosition <= nStartPos &&
-                            aRes.nBehindEndOfSentencePosition != nSuggestedEnd
-                           )
+                            aRes = xGC->doProofreading( aCurDocId, aCurTxt,
+                                                        aCurLocale, nStartPos, nSuggestedEnd, aProps );
+
+                            //!! work-around to prevent looping if the grammar checker
+                            //!! failed to properly identify the sentence end
+                            if (
+                                aRes.nBehindEndOfSentencePosition <= nStartPos &&
+                                aRes.nBehindEndOfSentencePosition != nSuggestedEnd
+                            )
+                            {
+                                DBG_ASSERT( false, "!! Grammarchecker failed to provide end of sentence !!" );
+                                aRes.nBehindEndOfSentencePosition = nSuggestedEnd;
+                            }
+
+                            aRes.xFlatParagraph      = xFlatPara;
+                            aRes.nStartOfSentencePosition = nStartPos;
+                        }
+                        else
                         {
-                            DBG_ASSERT( false, "!! Grammarchecker failed to provide end of sentence !!" );
-                            aRes.nBehindEndOfSentencePosition = nSuggestedEnd;
+                            // no grammar checker -> no error
+                            // but we need to provide the data below in order to continue with the next sentence
+                            aRes.aDocumentIdentifier = aCurDocId;
+                            aRes.xFlatParagraph      = xFlatPara;
+                            aRes.aText               = aCurTxt;
+                            aRes.aLocale             = aCurLocale;
+                            aRes.nStartOfSentencePosition       = nStartPos;
+                            aRes.nBehindEndOfSentencePosition   = nSuggestedEnd;
                         }
+                        aRes.nStartOfNextSentencePosition = lcl_SkipWhiteSpaces( aCurTxt, aRes.nBehindEndOfSentencePosition );
+                        aRes.nBehindEndOfSentencePosition = lcl_BacktraceWhiteSpaces( aCurTxt, aRes.nStartOfNextSentencePosition );
 
-                        aRes.xFlatParagraph      = xFlatPara;
-                        aRes.nStartOfSentencePosition = nStartPos;
+                        //guard has to be cleared as ProcessResult calls out of this class
+                        aGuard.clear();
+                        ProcessResult( aRes, xFPIterator, aFPEntryItem.m_bAutomatic );
+                        // ---- THREAD SAFE END ----
                     }
                     else
                     {
-                        // no grammar checker -> no error
-                        // but we need to provide the data below in order to continue with the next sentence
-                        aRes.aDocumentIdentifier = aCurDocId;
-                        aRes.xFlatParagraph      = xFlatPara;
-                        aRes.aText               = aCurTxt;
-                        aRes.aLocale             = aCurLocale;
-                        aRes.nStartOfSentencePosition       = nStartPos;
-                        aRes.nBehindEndOfSentencePosition   = nSuggestedEnd;
+                        // the paragraph changed meanwhile... (and maybe is still edited)
+                        // thus we simply continue to ask for the next to be checked.
+                        uno::Reference< text::XFlatParagraph > xFlatParaNext( xFPIterator->getNextPara() );
+                        AddEntry( xFPIterator, xFlatParaNext, aCurDocId, 0, aFPEntryItem.m_bAutomatic );
                     }
-                    aRes.nStartOfNextSentencePosition = lcl_SkipWhiteSpaces( aCurTxt, aRes.nBehindEndOfSentencePosition );
-                    aRes.nBehindEndOfSentencePosition = lcl_BacktraceWhiteSpaces( aCurTxt, aRes.nStartOfNextSentencePosition );
-
-                    //guard has to be cleared as ProcessResult calls out of this class
-                    aGuard.clear();
-                    ProcessResult( aRes, xFPIterator, aFPEntryItem.m_bAutomatic );
-                    // ---- THREAD SAFE END ----
                 }
-                else
+                catch (css::uno::Exception & e)
                 {
-                    // the paragraph changed meanwhile... (and maybe is still edited)
-                    // thus we simply continue to ask for the next to be checked.
-                    uno::Reference< text::XFlatParagraph > xFlatParaNext( xFPIterator->getNextPara() );
-                    AddEntry( xFPIterator, xFlatParaNext, aCurDocId, 0, aFPEntryItem.m_bAutomatic );
+                    SAL_WARN(
+                        "linguistic",
+                        "GrammarCheckingIterator::DequeueAndCheck ignoring UNO"
+                            " exception " << e.Message);
                 }
             }
 
commit e25b4bd9f83753211e868882547d96a4040d572f
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Jan 22 12:46:20 2015 +0100

    loplugin:cstylecast
    
    Change-Id: I126e06a0c7b442dfc4fcad7c05ff6caf07896a8f

diff --git a/unoxml/qa/unit/domtest.cxx b/unoxml/qa/unit/domtest.cxx
index 34558c5..d793e20 100644
--- a/unoxml/qa/unit/domtest.cxx
+++ b/unoxml/qa/unit/domtest.cxx
@@ -171,7 +171,7 @@ struct TokenHandler
 {
     virtual ::sal_Int32 SAL_CALL getTokenFromUTF8( const uno::Sequence< ::sal_Int8 >& Identifier ) throw (uno::RuntimeException) SAL_OVERRIDE
     {
-        OSL_TRACE("getTokenFromUTF8() %s", (const char*)Identifier.getConstArray());
+        OSL_TRACE("getTokenFromUTF8() %s", reinterpret_cast<const char*>(Identifier.getConstArray()));
         return Identifier.getLength() ? Identifier[0] : 0;
     }
 
@@ -199,10 +199,10 @@ struct BasicTest : public test::BootstrapFixture
         mxErrHandler.set( new ErrorHandler() );
         uno::Reference<XDocumentBuilder> xDB( getMultiServiceFactory()->createInstance(OUString("com.sun.star.xml.dom.DocumentBuilder")), uno::UNO_QUERY_THROW );
         mxDomBuilder.set( xDB );
-        mxValidInStream.set( new SequenceInputStream(css::uno::Sequence<sal_Int8>((sal_Int8*)validTestFile, SAL_N_ELEMENTS(validTestFile))) );
-        mxWarningInStream.set( new SequenceInputStream(css::uno::Sequence<sal_Int8>((sal_Int8*)warningTestFile, SAL_N_ELEMENTS(warningTestFile))) );
-        mxErrorInStream.set( new SequenceInputStream(css::uno::Sequence<sal_Int8>((sal_Int8*)errorTestFile, SAL_N_ELEMENTS(errorTestFile))) );
-        mxFatalInStream.set( new SequenceInputStream(css::uno::Sequence<sal_Int8>((sal_Int8*)fatalTestFile, SAL_N_ELEMENTS(fatalTestFile))) );
+        mxValidInStream.set( new SequenceInputStream(css::uno::Sequence<sal_Int8>(reinterpret_cast<sal_Int8 const *>(validTestFile), SAL_N_ELEMENTS(validTestFile))) );
+        mxWarningInStream.set( new SequenceInputStream(css::uno::Sequence<sal_Int8>(reinterpret_cast<sal_Int8 const *>(warningTestFile), SAL_N_ELEMENTS(warningTestFile))) );
+        mxErrorInStream.set( new SequenceInputStream(css::uno::Sequence<sal_Int8>(reinterpret_cast<sal_Int8 const *>(errorTestFile), SAL_N_ELEMENTS(errorTestFile))) );
+        mxFatalInStream.set( new SequenceInputStream(css::uno::Sequence<sal_Int8>(reinterpret_cast<sal_Int8 const *>(fatalTestFile), SAL_N_ELEMENTS(fatalTestFile))) );
         mxDomBuilder->setErrorHandler(mxErrHandler.get());
     }
 
@@ -273,7 +273,7 @@ struct SerializerTest : public test::BootstrapFixture
         mxErrHandler.set( new ErrorHandler() );
         uno::Reference<XDocumentBuilder> xDB( getMultiServiceFactory()->createInstance(OUString("com.sun.star.xml.dom.DocumentBuilder")), uno::UNO_QUERY_THROW );
         mxDomBuilder.set( xDB );
-        mxInStream.set( new SequenceInputStream(css::uno::Sequence<sal_Int8>((sal_Int8*)validTestFile, SAL_N_ELEMENTS(validTestFile))) );
+        mxInStream.set( new SequenceInputStream(css::uno::Sequence<sal_Int8>(reinterpret_cast<sal_Int8 const *>(validTestFile), SAL_N_ELEMENTS(validTestFile))) );
         mxDomBuilder->setErrorHandler(mxErrHandler.get());
         mxHandler.set( new DocumentHandler() );
         mxTokHandler.set( new TokenHandler() );
commit 7319961687e84d56f30a245c115e7b67b1b69ed3
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Jan 22 12:45:57 2015 +0100

    loplugin:stringconstant
    
    Change-Id: Ia23865a38eff10304a1c1748b2b4f17af7b4d3ae

diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 97e3d4b..8ba9466 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -519,7 +519,7 @@ DECLARE_WW8IMPORT_TEST(testLayoutHanging, "fdo68967.doc")
 DECLARE_WW8IMPORT_TEST(testfdo68963, "fdo68963.doc")
 {
     // The problem was that the text was not displayed.
-    CPPUNIT_ASSERT ( OUString("") != parseDump("/root/page/body/tab/row[2]/cell[1]/txt/Special", "rText") );
+    CPPUNIT_ASSERT ( !parseDump("/root/page/body/tab/row[2]/cell[1]/txt/Special", "rText").isEmpty() );
     CPPUNIT_ASSERT_EQUAL( OUString("Topic 1"), parseDump("/root/page/body/tab/row[2]/cell[1]/txt/Special", "rText") );
 }
 


More information about the Libreoffice-commits mailing list