desktop/source/lib/init.cxx | 268 ++++++++++++++++++-------------------------- 1 file changed, 110 insertions(+), 158 deletions(-)
New commits: commit fef1c9ba0cabe767d8c15c10903c5869dd113503 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun Apr 28 23:29:49 2019 +0300 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Thu May 2 11:50:11 2019 +0200 tdf#120703 PVS: dereference before nullptr check Use a function to consistently check if gImpl is valid before assigning last exception message. V595 The 'gImpl' pointer was utilized before it was verified against nullptr. Check lines: 2673, 2683. Change-Id: I18fc0d632c84f37b05e9d1c3c83689e6eaa6f66c Reviewed-on: https://gerrit.libreoffice.org/71488 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/71528 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Michael Meeks <michael.me...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 089f95b91996..d4a532f3f33e 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -159,6 +159,12 @@ static LibLibreOffice_Impl *gImpl = nullptr; static std::weak_ptr< LibreOfficeKitClass > gOfficeClass; static std::weak_ptr< LibreOfficeKitDocumentClass > gDocumentClass; +static void SetLastExceptionMsg(const OUString& s = OUString()) +{ + if (gImpl) + gImpl->maLastExceptionMsg = s; +} + typedef struct { const char *extn; @@ -1891,8 +1897,7 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha comphelper::ProfileZone aZone("doc_saveAs"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); @@ -1900,7 +1905,7 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha OUString aURL(getAbsoluteURL(sUrl)); if (aURL.isEmpty()) { - gImpl->maLastExceptionMsg = "Filename to save to was not provided."; + SetLastExceptionMsg("Filename to save to was not provided."); SAL_INFO("lok", "URL for save is empty"); return false; } @@ -1939,7 +1944,7 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha } else { - gImpl->maLastExceptionMsg = "input filename without a suffix"; + SetLastExceptionMsg("input filename without a suffix"); return false; } } @@ -1955,7 +1960,7 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha } if (aFilterName.isEmpty()) { - gImpl->maLastExceptionMsg = "no output filter found for provided suffix"; + SetLastExceptionMsg("no output filter found for provided suffix"); return false; } @@ -2038,7 +2043,7 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha } catch (const uno::Exception& exception) { - gImpl->maLastExceptionMsg = "exception: " + exception.Message; + SetLastExceptionMsg("exception: " + exception.Message); } return false; } @@ -2046,8 +2051,7 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha static void doc_iniUnoCommands () { SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); OUString sUnoCommands[] = { @@ -2194,8 +2198,7 @@ static int doc_getDocumentType (LibreOfficeKitDocument* pThis) comphelper::ProfileZone aZone("doc_getDocumentType"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); @@ -2221,12 +2224,12 @@ static int doc_getDocumentType (LibreOfficeKitDocument* pThis) } else { - gImpl->maLastExceptionMsg = "unknown document type"; + SetLastExceptionMsg("unknown document type"); } } catch (const uno::Exception& exception) { - gImpl->maLastExceptionMsg = "exception: " + exception.Message; + SetLastExceptionMsg("exception: " + exception.Message); } return LOK_DOCTYPE_OTHER; } @@ -2240,7 +2243,7 @@ static int doc_getParts (LibreOfficeKitDocument* pThis) ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return 0; } @@ -2252,13 +2255,12 @@ static int doc_getPart (LibreOfficeKitDocument* pThis) comphelper::ProfileZone aZone("doc_getPart"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return 0; } @@ -2270,13 +2272,12 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart) comphelper::ProfileZone aZone("doc_setPart"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } @@ -2291,7 +2292,7 @@ static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart) ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } @@ -2306,13 +2307,12 @@ static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart) static void doc_selectPart(LibreOfficeKitDocument* pThis, int nPart, int nSelect) { SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } @@ -2322,13 +2322,12 @@ static void doc_selectPart(LibreOfficeKitDocument* pThis, int nPart, int nSelect static void doc_moveSelectedParts(LibreOfficeKitDocument* pThis, int nPosition, bool bDuplicate) { SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } @@ -2340,13 +2339,12 @@ static char* doc_getPartPageRectangles(LibreOfficeKitDocument* pThis) comphelper::ProfileZone aZone("doc_getPartPageRectangles"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } @@ -2363,13 +2361,12 @@ static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart) comphelper::ProfileZone aZone("doc_getPartName"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } @@ -2386,13 +2383,12 @@ static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart) comphelper::ProfileZone aZone("doc_getPartHash"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } @@ -2410,13 +2406,12 @@ static void doc_setPartMode(LibreOfficeKitDocument* pThis, comphelper::ProfileZone aZone("doc_setPartMode"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } @@ -2453,8 +2448,7 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis, comphelper::ProfileZone aZone("doc_paintTile"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); SAL_INFO( "lok.tiledrendering", "paintTile: painting [" << nTileWidth << "x" << nTileHeight << "]@(" << nTilePosX << ", " << nTilePosY << ") to [" << @@ -2463,7 +2457,7 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis, ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } @@ -2542,8 +2536,7 @@ static void doc_paintTileToCGContext(LibreOfficeKitDocument* pThis, const int nTileWidth, const int nTileHeight) { SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); SAL_INFO( "lok.tiledrendering", "paintTileToCGContext: painting [" << nTileWidth << "x" << nTileHeight << "]@(" << nTilePosX << ", " << nTilePosY << ") to [" << @@ -2552,7 +2545,7 @@ static void doc_paintTileToCGContext(LibreOfficeKitDocument* pThis, ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } @@ -2582,8 +2575,7 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis, comphelper::ProfileZone aZone("doc_paintPartTile"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); SAL_INFO( "lok.tiledrendering", "paintPartTile: painting @ " << nPart << " [" << nTileWidth << "x" << nTileHeight << "]@(" @@ -2667,8 +2659,7 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis, static int doc_getTileMode(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/) { - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); return LOK_TILEMODE_BGRA; } @@ -2679,8 +2670,7 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis, comphelper::ProfileZone aZone("doc_getDocumentSize"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (pDoc) @@ -2691,7 +2681,7 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis, } else { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); } } @@ -2701,8 +2691,7 @@ static void doc_initializeForRendering(LibreOfficeKitDocument* pThis, comphelper::ProfileZone aZone("doc_initializeForRendering"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (pDoc) @@ -2718,8 +2707,7 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis, void* pData) { SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); @@ -2773,12 +2761,11 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis, /// Returns the JSON representation of all the comments in the document static char* getPostIts(LibreOfficeKitDocument* pThis) { - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } OUString aComments = pDoc->getPostIts(); @@ -2788,12 +2775,11 @@ static char* getPostIts(LibreOfficeKitDocument* pThis) /// Returns the JSON representation of the positions of all the comments in the document static char* getPostItsPos(LibreOfficeKitDocument* pThis) { - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } OUString aComments = pDoc->getPostItsPos(); @@ -2802,12 +2788,11 @@ static char* getPostItsPos(LibreOfficeKitDocument* pThis) static char* getRulerState(LibreOfficeKitDocument* pThis) { - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } OUString state = pDoc->getRulerState(); @@ -2819,13 +2804,12 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nChar comphelper::ProfileZone aZone("doc_postKeyEvent"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } @@ -2843,7 +2827,7 @@ static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsig ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } pWindow = pDoc->getDocWindow(); @@ -2855,7 +2839,7 @@ static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsig if (!pWindow) { - gImpl->maLastExceptionMsg = "No window found for window id: " + OUString::number(nWindowId); + SetLastExceptionMsg("No window found for window id: " + OUString::number(nWindowId)); return; } @@ -2879,13 +2863,12 @@ static void doc_postWindowKeyEvent(LibreOfficeKitDocument* /*pThis*/, unsigned n comphelper::ProfileZone aZone("doc_postWindowKeyEvent"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId); if (!pWindow) { - gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found."; + SetLastExceptionMsg("Document doesn't support dialog rendering, or window not found."); return; } @@ -2910,8 +2893,7 @@ static size_t doc_renderShapeSelection(LibreOfficeKitDocument* pThis, char** pOu comphelper::ProfileZone aZone("doc_renderShapeSelection"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); LokChartHelper aChartHelper(SfxViewShell::Current()); @@ -2960,8 +2942,7 @@ static size_t doc_renderShapeSelection(LibreOfficeKitDocument* pThis, char** pOu } catch (const uno::Exception& exception) { - if (gImpl) - gImpl->maLastExceptionMsg = exception.Message; + SetLastExceptionMsg(exception.Message); SAL_WARN("lok", "Failed to render shape selection: " << exception); } @@ -3015,8 +2996,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma comphelper::ProfileZone aZone("doc_postUnoCommand"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); SfxObjectShell* pDocSh = SfxObjectShell::Current(); OUString aCommand(pCommand, strlen(pCommand), RTL_TEXTENCODING_UTF8); @@ -3152,9 +3132,9 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma else bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector)); - if (!bResult && gImpl) + if (!bResult) { - gImpl->maLastExceptionMsg = "Failed to dispatch the .uno: command"; + SetLastExceptionMsg("Failed to dispatch the .uno: command"); } } @@ -3163,13 +3143,12 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX, comphelper::ProfileZone aZone("doc_postMouseEvent"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } @@ -3181,13 +3160,12 @@ static void doc_postWindowMouseEvent(LibreOfficeKitDocument* /*pThis*/, unsigned comphelper::ProfileZone aZone("doc_postWindowMouseEvent"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId); if (!pWindow) { - gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found."; + SetLastExceptionMsg("Document doesn't support dialog rendering, or window not found."); return; } @@ -3221,13 +3199,12 @@ static void doc_postWindowGestureEvent(LibreOfficeKitDocument* /*pThis*/, unsign comphelper::ProfileZone aZone("doc_postWindowGestureEvent"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId); if (!pWindow) { - gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found."; + SetLastExceptionMsg("Document doesn't support dialog rendering, or window not found."); return; } @@ -3260,13 +3237,12 @@ static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int n comphelper::ProfileZone aZone("doc_setTextSelection"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } @@ -3278,13 +3254,12 @@ static char* doc_getTextSelection(LibreOfficeKitDocument* pThis, const char* pMi comphelper::ProfileZone aZone("doc_getTextSelection"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } @@ -3310,13 +3285,12 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, const char* pMimeType, cons comphelper::ProfileZone aZone("doc_paste"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return false; } @@ -3326,8 +3300,7 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, const char* pMimeType, cons pDoc->setClipboard(xClipboard); if (!pDoc->isMimeTypeSupported()) { - if (gImpl) - gImpl->maLastExceptionMsg = "Document doesn't support this mime type"; + SetLastExceptionMsg("Document doesn't support this mime type"); return false; } @@ -3337,7 +3310,7 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, const char* pMimeType, cons })); if (!comphelper::dispatchCommand(".uno:Paste", aPropertyValues)) { - gImpl->maLastExceptionMsg = "Failed to dispatch the .uno: command"; + SetLastExceptionMsg("Failed to dispatch the .uno: command"); return false; } @@ -3349,13 +3322,12 @@ static void doc_setGraphicSelection(LibreOfficeKitDocument* pThis, int nType, in comphelper::ProfileZone aZone("doc_setGraphicSelection"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } @@ -3367,13 +3339,12 @@ static void doc_resetSelection(LibreOfficeKitDocument* pThis) comphelper::ProfileZone aZone("doc_resetSelection"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } @@ -3721,7 +3692,7 @@ static char* getTrackedChanges(LibreOfficeKitDocument* pThis) ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } OUString aTrackedChanges = pDoc->getTrackedChanges(); @@ -3739,7 +3710,7 @@ static char* getTrackedChangeAuthors(LibreOfficeKitDocument* pThis) ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } OUString aAuthors = pDoc->getTrackedChangeAuthors(); @@ -3751,8 +3722,7 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo comphelper::ProfileZone aZone("doc_getCommandValues"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); OString aCommand(pCommand); static const OString aViewRowColumnHeaders(".uno:ViewRowColumnHeaders"); @@ -3804,7 +3774,7 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } @@ -3862,7 +3832,7 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return nullptr; } @@ -3914,7 +3884,7 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo } else { - gImpl->maLastExceptionMsg = "Unknown command, no values returned"; + SetLastExceptionMsg("Unknown command, no values returned"); return nullptr; } } @@ -3925,13 +3895,12 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis, int nTilePixelWidth comphelper::ProfileZone aZone("doc_setClientZoom"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } @@ -3943,13 +3912,12 @@ static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int comphelper::ProfileZone aZone("doc_setClientVisibleArea"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } @@ -3962,13 +3930,12 @@ static void doc_setOutlineState(LibreOfficeKitDocument* pThis, bool bColumn, int comphelper::ProfileZone aZone("doc_setOutlineState"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + SetLastExceptionMsg("Document doesn't support tiled rendering"); return; } @@ -3981,8 +3948,7 @@ static int doc_createViewWithOptions(SAL_UNUSED_PARAMETER LibreOfficeKitDocument comphelper::ProfileZone aZone("doc_createView"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); OUString aOptions = getUString(pOptions); const OUString aLanguage = extractParameter(aOptions, "Language"); @@ -4006,8 +3972,7 @@ static void doc_destroyView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis comphelper::ProfileZone aZone("doc_destroyView"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); SfxLokHelper::destroyView(nId); } @@ -4017,8 +3982,7 @@ static void doc_setView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/, comphelper::ProfileZone aZone("doc_setView"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); SfxLokHelper::setView(nId); } @@ -4028,8 +3992,7 @@ static int doc_getView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/) comphelper::ProfileZone aZone("doc_getView"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); return SfxLokHelper::getView(); } @@ -4039,8 +4002,7 @@ static int doc_getViewsCount(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThi comphelper::ProfileZone aZone("doc_getViewsCount"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); return SfxLokHelper::getViewsCount(); } @@ -4050,8 +4012,7 @@ static bool doc_getViewIds(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis* comphelper::ProfileZone aZone("doc_getViewsIds"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); return SfxLokHelper::getViewIds(pArray, nSize); } @@ -4061,8 +4022,7 @@ static void doc_setViewLanguage(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*p comphelper::ProfileZone aZone("doc_setViewLanguage"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); SfxLokHelper::setViewLanguage(nId, OStringToOUString(language, RTL_TEXTENCODING_UTF8)); } @@ -4076,8 +4036,7 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh comphelper::ProfileZone aZone("doc_renderFont"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); OString aSearchedFontName(pFontName); OUString aText(OStringToOUString(pChar, RTL_TEXTENCODING_UTF8)); @@ -4191,13 +4150,12 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKW comphelper::ProfileZone aZone("doc_paintWindowDPI"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId); if (!pWindow) { - gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found."; + SetLastExceptionMsg("Document doesn't support dialog rendering, or window not found."); return; } @@ -4257,13 +4215,12 @@ static void doc_postWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindo comphelper::ProfileZone aZone("doc_postWindow"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId); if (!pWindow) { - gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found."; + SetLastExceptionMsg("Document doesn't support dialog rendering, or window not found."); return; } @@ -4466,13 +4423,12 @@ static void doc_resizeWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWin const int nWidth, const int nHeight) { SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId); if (!pWindow) { - gImpl->maLastExceptionMsg = "Document doesn't support dialog resizing, or window not found."; + SetLastExceptionMsg("Document doesn't support dialog resizing, or window not found."); return; } @@ -4500,8 +4456,7 @@ static void lo_freeError(char* pFree) static char* lo_getFilterTypes(LibreOfficeKit* pThis) { SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); LibLibreOffice_Impl* pImpl = static_cast<LibLibreOffice_Impl*>(pThis); @@ -4542,8 +4497,7 @@ static void lo_setOptionalFeatures(LibreOfficeKit* pThis, unsigned long long con comphelper::ProfileZone aZone("lo_setOptionalFeatures"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); LibLibreOffice_Impl *const pLib = static_cast<LibLibreOffice_Impl*>(pThis); pLib->mOptionalFeatures = features; @@ -4563,8 +4517,7 @@ static void lo_setDocumentPassword(LibreOfficeKit* pThis, comphelper::ProfileZone aZone("lo_setDocumentPassword"); SolarMutexGuard aGuard; - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); assert(pThis); assert(pURL); @@ -4575,8 +4528,7 @@ static void lo_setDocumentPassword(LibreOfficeKit* pThis, static char* lo_getVersionInfo(SAL_UNUSED_PARAMETER LibreOfficeKit* /*pThis*/) { - if (gImpl) - gImpl->maLastExceptionMsg.clear(); + SetLastExceptionMsg(); const OUString sVersionStrTemplate( "{ " "\"ProductName\": \"%PRODUCTNAME\", " @@ -4626,7 +4578,7 @@ static bool initialize_uno(const OUString& aAppProgramURL) if (!xContext.is()) { - gImpl->maLastExceptionMsg = "XComponentContext could not be created"; + SetLastExceptionMsg("XComponentContext could not be created"); SAL_INFO("lok", "XComponentContext could not be created"); return false; } @@ -4634,7 +4586,7 @@ static bool initialize_uno(const OUString& aAppProgramURL) xFactory = xContext->getServiceManager(); if (!xFactory.is()) { - gImpl->maLastExceptionMsg = "XMultiComponentFactory could not be created"; + SetLastExceptionMsg("XMultiComponentFactory could not be created"); SAL_INFO("lok", "XMultiComponentFactory could not be created"); return false; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits