Blame SOURCES/0293-Keep-LibreOfficeKit.hxx-compatible-with-C-03.patch

135360
From 994720658cfc4e3e82493ca5ef1859cc0b42960c Mon Sep 17 00:00:00 2001
135360
From: Stephan Bergmann <sbergman@redhat.com>
135360
Date: Tue, 10 Nov 2015 11:08:30 +0100
135360
Subject: [PATCH 293/398] Keep LibreOfficeKit.hxx compatible with C++03
135360
135360
Change-Id: Ic2f123c9b341dbb421b766c3bba1fc56c1bfb41d
135360
(cherry picked from commit 1cd6e2e08eba3bc55fbf6dda3cd3d19a5d95f798)
135360
---
135360
 compilerplugins/clang/store/nullptr.cxx   |  9 +++++++++
135360
 include/LibreOfficeKit/LibreOfficeKit.hxx | 20 ++++++++++----------
135360
 2 files changed, 19 insertions(+), 10 deletions(-)
135360
135360
diff --git a/compilerplugins/clang/store/nullptr.cxx b/compilerplugins/clang/store/nullptr.cxx
135360
index 528bb6aac9bc..83812d0ccd49 100644
135360
--- a/compilerplugins/clang/store/nullptr.cxx
135360
+++ b/compilerplugins/clang/store/nullptr.cxx
135360
@@ -42,6 +42,8 @@ public:
135360
     bool VisitImplicitCastExpr(CastExpr const * expr);
135360
 
135360
 private:
135360
+    bool isInLokIncludeFile(SourceLocation spellingLocation) const;
135360
+
135360
     bool isFromCIncludeFile(SourceLocation spellingLocation) const;
135360
 
135360
     bool isMacroBodyExpansion(SourceLocation location) const;
135360
@@ -134,6 +136,8 @@ bool Nullptr::VisitImplicitCastExpr(CastExpr const * expr) {
135360
                 ((!compiler.getLangOpts().CPlusPlus
135360
                   || isInUnoIncludeFile(
135360
                       compiler.getSourceManager().getSpellingLoc(loc))
135360
+                  || isInLokIncludeFile(
135360
+                      compiler.getSourceManager().getSpellingLoc(loc))
135360
                   || isFromCIncludeFile(
135360
                       compiler.getSourceManager().getSpellingLoc(loc)))
135360
                  ? "NULL" : "nullptr"));
135360
@@ -143,6 +147,11 @@ bool Nullptr::VisitImplicitCastExpr(CastExpr const * expr) {
135360
     return true;
135360
 }
135360
 
135360
+bool Nullptr::isInLokIncludeFile(SourceLocation spellingLocation) const {
135360
+    return compiler.getSourceManager().getFilename(spellingLocation)
135360
+        .startswith(SRCDIR "/include/LibreOfficeKit/");
135360
+}
135360
+
135360
 bool Nullptr::isFromCIncludeFile(SourceLocation spellingLocation) const {
135360
     return !compat::isInMainFile(compiler.getSourceManager(), spellingLocation)
135360
         && (StringRef(
135360
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
135360
index dde371ddc95b..ec48d39368e3 100644
135360
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
135360
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
135360
@@ -47,7 +47,7 @@ public:
135360
      * @param pFormat the format to use while exporting, when omitted, then deducted from pURL's extension
135360
      * @param pFilterOptions options for the export filter, e.g. SkipImages.
135360
      */
135360
-    inline bool saveAs(const char* pUrl, const char* pFormat = nullptr, const char* pFilterOptions = nullptr)
135360
+    inline bool saveAs(const char* pUrl, const char* pFormat = NULL, const char* pFilterOptions = NULL)
135360
     {
135360
         return mpDoc->pClass->saveAs(mpDoc, pUrl, pFormat, pFilterOptions) != 0;
135360
     }
135360
@@ -220,7 +220,7 @@ public:
135360
      * @param pCommand uno command to be posted to the document, like ".uno:Bold"
135360
      * @param pArguments arguments of the uno command.
135360
      */
135360
-    inline void postUnoCommand(const char* pCommand, const char* pArguments = nullptr, bool bNotifyWhenFinished = false)
135360
+    inline void postUnoCommand(const char* pCommand, const char* pArguments = NULL, bool bNotifyWhenFinished = false)
135360
     {
135360
         mpDoc->pClass->postUnoCommand(mpDoc, pCommand, pArguments, bNotifyWhenFinished);
135360
     }
135360
@@ -243,7 +243,7 @@ public:
135360
      * @param pMimeType suggests the return format, for example text/plain;charset=utf-8.
135360
      * @param pUsedMimeType output parameter to inform about the determined format (suggested one or plain text).
135360
      */
135360
-    inline char* getTextSelection(const char* pMimeType, char** pUsedMimeType = nullptr)
135360
+    inline char* getTextSelection(const char* pMimeType, char** pUsedMimeType = NULL)
135360
     {
135360
         return mpDoc->pClass->getTextSelection(mpDoc, pMimeType, pUsedMimeType);
135360
     }
135360
@@ -361,17 +361,17 @@ public:
135360
      * @param pUrl the URL of the document to load
135360
      * @param pFilterOptions options for the import filter, e.g. SkipImages.
135360
      */
135360
-    inline Document* documentLoad(const char* pUrl, const char* pFilterOptions = nullptr)
135360
+    inline Document* documentLoad(const char* pUrl, const char* pFilterOptions = NULL)
135360
     {
135360
-        LibreOfficeKitDocument* pDoc = nullptr;
135360
+        LibreOfficeKitDocument* pDoc = NULL;
135360
 
135360
         if (LIBREOFFICEKIT_HAS(mpThis, documentLoadWithOptions))
135360
             pDoc = mpThis->pClass->documentLoadWithOptions(mpThis, pUrl, pFilterOptions);
135360
         else
135360
             pDoc = mpThis->pClass->documentLoad(mpThis, pUrl);
135360
 
135360
-        if (pDoc == nullptr)
135360
-            return nullptr;
135360
+        if (pDoc == NULL)
135360
+            return NULL;
135360
 
135360
         return new Document(pDoc);
135360
     }
135360
@@ -405,11 +405,11 @@ public:
135360
 };
135360
 
135360
 /// Factory method to create a lok::Office instance.
135360
-inline Office* lok_cpp_init(const char* pInstallPath, const char* pUserProfilePath = nullptr)
135360
+inline Office* lok_cpp_init(const char* pInstallPath, const char* pUserProfilePath = NULL)
135360
 {
135360
     LibreOfficeKit* pThis = lok_init_2(pInstallPath, pUserProfilePath);
135360
-    if (pThis == nullptr || pThis->pClass->nSize == 0)
135360
-        return nullptr;
135360
+    if (pThis == NULL || pThis->pClass->nSize == 0)
135360
+        return NULL;
135360
     return new ::lok::Office(pThis);
135360
 }
135360
 
135360
-- 
135360
2.12.0
135360