summaryrefslogtreecommitdiff
path: root/desktop/source
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-03-12 13:43:31 +0200
committerTor Lillqvist <tml@iki.fi>2013-03-12 13:47:33 +0200
commitecdd44e8f577e51e0208e9f421704a70041f1be8 (patch)
tree5dff0ddfe4796f698065d7346e0febff7882c778 /desktop/source
parent0950bb5e9cb85265986435fe26906af9741f2854 (diff)
Use symbolic names instead of magic literal constants
We use tons of plain C-style #defines to give symbolic names to constants all over the place already, in headers used from C++ code only. So why in this rare case where the symbolic names for some constants actually would be needed from a C source file, too, here then we define them inside a C++ class? Change-Id: I45726fe42687779724c45a1e2b118cc7a1debcf1
Diffstat (limited to 'desktop/source')
-rw-r--r--desktop/source/app/app.cxx8
-rw-r--r--desktop/source/app/sofficemain.cxx4
-rw-r--r--desktop/source/inc/exithelper.h38
-rw-r--r--desktop/source/inc/exithelper.hxx60
4 files changed, 45 insertions, 65 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 9899b1a9a69c..3e03a57a8fa4 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -30,7 +30,7 @@
#include "lockfile.hxx"
#include "userinstall.hxx"
#include "desktopcontext.hxx"
-#include "exithelper.hxx"
+#include "exithelper.h"
#include "migration.hxx"
#include <svtools/javacontext.hxx>
@@ -436,7 +436,7 @@ void FatalError(const ::rtl::OUString& sMessage)
sTitle.appendAscii (" - Fatal Error");
Application::ShowNativeErrorBox (sTitle.makeStringAndClear (), sMessage);
- _exit(ExitHelper::E_FATAL_ERROR);
+ _exit(EXITHELPER_FATAL_ERROR);
}
static bool ShouldSuppressUI(const CommandLineArgs& rCmdLine)
@@ -1306,7 +1306,7 @@ sal_uInt16 Desktop::Exception(sal_uInt16 nError)
if ( m_rSplashScreen.is() )
m_rSplashScreen->reset();
- _exit( ExitHelper::E_CRASH_WITH_RESTART );
+ _exit( EXITHELPER_CRASH_WITH_RESTART );
}
else
{
@@ -1764,7 +1764,7 @@ int Desktop::doShutdown()
if ( m_rSplashScreen.is() )
m_rSplashScreen->reset();
- return ExitHelper::E_NORMAL_RESTART;
+ return EXITHELPER_NORMAL_RESTART;
}
return EXIT_SUCCESS;
}
diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx
index 8a0f6985c47e..a8c091177171 100644
--- a/desktop/source/app/sofficemain.cxx
+++ b/desktop/source/app/sofficemain.cxx
@@ -22,6 +22,7 @@
#include "desktopdllapi.h"
#include "app.hxx"
+#include "exithelper.h"
#include "cmdlineargs.hxx"
#include "cmdlinehelp.hxx"
@@ -100,7 +101,8 @@ Java_org_libreoffice_experimental_desktop_Desktop_runMain(JNIEnv* /* env */,
do {
nRet = soffice_main();
LOGI("soffice_main returned %d", nRet );
- } while (nRet == 81 || nRet == 79); // pretend to re-start.
+ } while (nRet == EXITHELPER_NORMAL_RESTART ||
+ nRet == EXITHELPER_CRASH_WITH_RESTART); // pretend to re-start.
}
diff --git a/desktop/source/inc/exithelper.h b/desktop/source/inc/exithelper.h
new file mode 100644
index 000000000000..e670da3bcab2
--- /dev/null
+++ b/desktop/source/inc/exithelper.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _DESKTOP_EXITHELPER_H_
+#define _DESKTOP_EXITHELPER_H_
+
+enum EExitCodes {
+ /* e.g. used to force showing of the command line help */
+ EXITHELPER_NO_ERROR = 0,
+ /* pipe was detected - second office must terminate itself */
+ EXITHELPER_SECOND_OFFICE = 1,
+ /* an uno exception was catched during startup */
+ EXITHELPER_FATAL_ERROR = 333, /* Only the low 8 bits are significant 333 % 256 = 77 */
+ /* user force automatic restart after crash */
+ EXITHELPER_CRASH_WITH_RESTART = 79,
+ /* the office restarts itself */
+ EXITHELPER_NORMAL_RESTART = 81
+};
+
+#endif /* #ifndef _DESKTOP_EXITHELPER_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/inc/exithelper.hxx b/desktop/source/inc/exithelper.hxx
deleted file mode 100644
index 6343bfd6d872..000000000000
--- a/desktop/source/inc/exithelper.hxx
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _DESKTOP_EXITHELPER_HXX_
-#define _DESKTOP_EXITHELPER_HXX_
-
-namespace desktop
-{
-
-//=============================================================================
-/** @short provide helper functions to handle a abnormal exit
- and contain a list of all "well known" exit codes.
- */
-class ExitHelper
-{
- public:
-
- //---------------------------------------------------------------------
- /** @short list of all well known exit codes.
-
- @descr Its not allowed to use exit codes hard coded
- inside office. All places must use these list to
- be synchron.
- */
- enum EExitCodes
- {
- /// e.g. used to force showing of the command line help
- E_NO_ERROR = 0,
- /// pipe was detected - second office must terminate itself
- E_SECOND_OFFICE = 1,
- /// an uno exception was catched during startup
- E_FATAL_ERROR = 333, // Only the low 8 bits are significant 333 % 256 = 77
- /// user force automatic restart after crash
- E_CRASH_WITH_RESTART = 79,
- /// the office restarts itself
- E_NORMAL_RESTART = 81
- };
-};
-
-} // namespace desktop
-
-#endif // #ifndef _DESKTOP_EXITHELPER_HXX_
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */