LCOV - code coverage report
Current view: top level - desktop/source/app - app.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 404 1252 32.3 %
Date: 2012-08-25 Functions: 40 68 58.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 440 2790 15.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "sal/config.h"
      30                 :            : 
      31                 :            : #include <iostream>
      32                 :            : 
      33                 :            : #include "app.hxx"
      34                 :            : #include "desktop.hrc"
      35                 :            : #include "cmdlineargs.hxx"
      36                 :            : #include "cmdlinehelp.hxx"
      37                 :            : #include "dispatchwatcher.hxx"
      38                 :            : #include "configinit.hxx"
      39                 :            : #include "lockfile.hxx"
      40                 :            : #include "userinstall.hxx"
      41                 :            : #include "desktopcontext.hxx"
      42                 :            : #include "exithelper.hxx"
      43                 :            : #include "migration.hxx"
      44                 :            : 
      45                 :            : #include <svtools/javacontext.hxx>
      46                 :            : #include <com/sun/star/frame/XSessionManagerListener.hpp>
      47                 :            : #include <com/sun/star/frame/XSynchronousDispatch.hpp>
      48                 :            : #include <com/sun/star/document/CorruptedFilterConfigurationException.hpp>
      49                 :            : #include <com/sun/star/configuration/CorruptedConfigurationException.hpp>
      50                 :            : #include <com/sun/star/configuration/theDefaultProvider.hpp>
      51                 :            : #include <com/sun/star/util/XFlushable.hpp>
      52                 :            : #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
      53                 :            : #include <com/sun/star/frame/XDesktop.hpp>
      54                 :            : #include <com/sun/star/frame/XComponentLoader.hpp>
      55                 :            : #include <com/sun/star/view/XPrintable.hpp>
      56                 :            : #include <com/sun/star/awt/XTopWindow.hpp>
      57                 :            : #include "com/sun/star/util/URLTransformer.hpp"
      58                 :            : #include <com/sun/star/util/XURLTransformer.hpp>
      59                 :            : #include <com/sun/star/util/XCloseable.hpp>
      60                 :            : #include <com/sun/star/frame/XDispatchProvider.hpp>
      61                 :            : #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
      62                 :            : #include <com/sun/star/configuration/MissingBootstrapFileException.hpp>
      63                 :            : #include <com/sun/star/configuration/InvalidBootstrapFileException.hpp>
      64                 :            : #include <com/sun/star/configuration/InstallationIncompleteException.hpp>
      65                 :            : #include <com/sun/star/configuration/backend/BackendSetupException.hpp>
      66                 :            : #include <com/sun/star/configuration/backend/BackendAccessException.hpp>
      67                 :            : #include <com/sun/star/task/XJobExecutor.hpp>
      68                 :            : #include <com/sun/star/task/XRestartManager.hpp>
      69                 :            : #include <com/sun/star/document/XEventListener.hpp>
      70                 :            : #include <com/sun/star/ui/XUIElementFactoryRegistration.hpp>
      71                 :            : #include <com/sun/star/frame/XUIControllerRegistration.hpp>
      72                 :            : 
      73                 :            : #include <toolkit/unohlp.hxx>
      74                 :            : #include <comphelper/processfactory.hxx>
      75                 :            : #include <comphelper/componentcontext.hxx>
      76                 :            : #include <unotools/configmgr.hxx>
      77                 :            : #include <unotools/confignode.hxx>
      78                 :            : #include <unotools/moduleoptions.hxx>
      79                 :            : #include <officecfg/Office/Recovery.hxx>
      80                 :            : #include <osl/file.hxx>
      81                 :            : #include <osl/process.h>
      82                 :            : #include <rtl/uri.hxx>
      83                 :            : #include <unotools/pathoptions.hxx>
      84                 :            : #include <unotools/internaloptions.hxx>
      85                 :            : #include <svtools/miscopt.hxx>
      86                 :            : #include <svtools/menuoptions.hxx>
      87                 :            : #include <svl/folderrestriction.hxx>
      88                 :            : #include <rtl/logfile.hxx>
      89                 :            : #include <rtl/bootstrap.hxx>
      90                 :            : #include <vcl/help.hxx>
      91                 :            : #include <vcl/msgbox.hxx>
      92                 :            : #include <sfx2/sfx.hrc>
      93                 :            : #include <sfx2/app.hxx>
      94                 :            : #include <svl/itemset.hxx>
      95                 :            : #include <svl/eitem.hxx>
      96                 :            : #include <ucbhelper/contentbroker.hxx>
      97                 :            : 
      98                 :            : #include <svtools/fontsubstconfig.hxx>
      99                 :            : #include <svtools/accessibilityoptions.hxx>
     100                 :            : #include <svtools/apearcfg.hxx>
     101                 :            : #include <svtools/filter.hxx>
     102                 :            : 
     103                 :            : #include "langselect.hxx"
     104                 :            : 
     105                 :            : #ifdef ENABLE_TELEPATHY
     106                 :            : #include <tubes/manager.hxx>
     107                 :            : #endif
     108                 :            : 
     109                 :            : #if defined MACOSX
     110                 :            : #include <errno.h>
     111                 :            : #include <sys/wait.h>
     112                 :            : #endif
     113                 :            : 
     114                 :            : #ifdef WNT
     115                 :            : #ifdef _MSC_VER
     116                 :            : #pragma warning(push, 1) /* disable warnings within system headers */
     117                 :            : #endif
     118                 :            : #define WIN32_LEAN_AND_MEAN
     119                 :            : #include <windows.h>
     120                 :            : #ifdef _MSC_VER
     121                 :            : #pragma warning(pop)
     122                 :            : #endif
     123                 :            : #endif //WNT
     124                 :            : 
     125                 :            : 
     126                 :            : using rtl::OUString;
     127                 :            : using rtl::OUStringBuffer;
     128                 :            : 
     129                 :            : using namespace ::com::sun::star::uno;
     130                 :            : using namespace ::com::sun::star::util;
     131                 :            : using namespace ::com::sun::star::lang;
     132                 :            : using namespace ::com::sun::star::beans;
     133                 :            : using namespace ::com::sun::star::frame;
     134                 :            : using namespace ::com::sun::star::document;
     135                 :            : using namespace ::com::sun::star::view;
     136                 :            : using namespace ::com::sun::star::task;
     137                 :            : using namespace ::com::sun::star::system;
     138                 :            : using namespace ::com::sun::star::ui::dialogs;
     139                 :            : using namespace ::com::sun::star::container;
     140                 :            : 
     141                 :            : namespace css = ::com::sun::star;
     142                 :            : 
     143                 :            : ResMgr*                 desktop::Desktop::pResMgr = 0;
     144                 :            : 
     145                 :            : namespace desktop
     146                 :            : {
     147                 :            : 
     148                 :            : static oslSignalHandler pSignalHandler = 0;
     149                 :            : static sal_Bool _bCrashReporterEnabled = sal_True;
     150                 :            : 
     151                 :            : namespace {
     152                 :            : 
     153                 :         62 : void removeTree(OUString const & url) {
     154                 :         62 :     osl::Directory dir(url);
     155      [ -  +  - ]:         62 :     switch (dir.open()) {
                 [ +  - ]
     156                 :            :     case osl::FileBase::E_None:
     157                 :         62 :         break;
     158                 :            :     case osl::FileBase::E_NOENT:
     159                 :         62 :         return; //TODO: SAL_WARN if recursive
     160                 :            :     default:
     161                 :            :         throw css::uno::RuntimeException(
     162                 :            :             "cannot open directory " + url,
     163         [ #  # ]:          0 :             css::uno::Reference< css::uno::XInterface >());
     164                 :            :     }
     165                 :          0 :     for (;;) {
     166                 :          0 :         osl::DirectoryItem i;
     167         [ #  # ]:          0 :         osl::FileBase::RC rc = dir.getNextItem(i, SAL_MAX_UINT32);
     168         [ #  # ]:          0 :         if (rc == osl::FileBase::E_NOENT) {
     169                 :            :             break;
     170                 :            :         }
     171         [ #  # ]:          0 :         if (rc != osl::FileBase::E_None) {
     172                 :            :             throw css::uno::RuntimeException(
     173                 :            :                 ("cannot iterate directory " + url + ": "
     174                 :            :                  + OUString::valueOf(static_cast< sal_Int32 >(rc))),
     175         [ #  # ]:          0 :                 css::uno::Reference< css::uno::XInterface >());
     176                 :            :         }
     177                 :            :         osl::FileStatus stat(
     178                 :            :             osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName |
     179                 :          0 :             osl_FileStatus_Mask_FileURL);
     180         [ #  # ]:          0 :         rc = i.getFileStatus(stat);
     181         [ #  # ]:          0 :         if (rc != osl::FileBase::E_None) {
     182                 :            :             throw css::uno::RuntimeException(
     183                 :            :                 ("cannot stat in directory " + url + ": "
     184                 :            :                  + OUString::valueOf(static_cast< sal_Int32 >(rc))),
     185         [ #  # ]:          0 :                 css::uno::Reference< css::uno::XInterface >());
     186                 :            :         }
     187 [ #  # ][ #  # ]:          0 :         if (stat.getFileType() == osl::FileStatus::Directory) { //TODO: symlinks
     188 [ #  # ][ #  # ]:          0 :             removeTree(stat.getFileURL());
     189                 :            :         } else {
     190 [ #  # ][ #  # ]:          0 :             rc = osl::File::remove(stat.getFileURL());
     191         [ #  # ]:          0 :             if (rc != osl::FileBase::E_None) {
     192                 :            :                 throw css::uno::RuntimeException(
     193                 :            :                     ("cannot remove file " + stat.getFileURL() + ": "
     194                 :            :                      + OUString::valueOf(static_cast< sal_Int32 >(rc))),
     195 [ #  # ][ #  # ]:          0 :                     css::uno::Reference< css::uno::XInterface >());
     196                 :            :             }
     197                 :            :         }
     198 [ #  # ][ #  # ]:          0 :     }
     199         [ #  # ]:          0 :     osl::FileBase::RC rc = osl::Directory::remove(url);
     200                 :            :     SAL_WARN_IF(
     201                 :            :         rc != osl::FileBase::E_None, "desktop",
     202 [ +  - ][ -  + ]:         62 :         "cannot remove directory " << url << ": " << +rc);
     203                 :            :         // at least on Windows XP removing some existing directories fails with
     204                 :            :         // osl::FileBase::E_ACCESS because they are read-only; but keeping those
     205                 :            :         // directories around should be harmless once they are empty
     206                 :            : }
     207                 :            : 
     208                 :            : // Remove any existing UserInstallation's user/extensions/bundled cache
     209                 :            : // remaining from old installations.  Apparently due to the old
     210                 :            : // share/prereg/bundled mechanism (disabled since
     211                 :            : // 5c47e5f63a79a9e72ec4a100786b1bbf65137ed4 "fdo#51252 Disable copying
     212                 :            : // share/prereg/bundled to avoid startup crashes"), that cache could contain
     213                 :            : // corrupted information (like a UNO component registered twice, which got
     214                 :            : // changed from active to passive registration in one LO version, but the
     215                 :            : // version of the corresponding bundled extension only incremented in a later LO
     216                 :            : // version).  At least in theory, this function could be removed again once no
     217                 :            : // UserInstallation can be poisoned by that old share/prereg/bundled mechanism
     218                 :            : // any more.  (But then Desktop::SynchronizeExtensionRepositories might need to
     219                 :            : // be revisited, see 2d2b19dea1ab401b1b4971ff5b12b87bb11fd666 "Force
     220                 :            : // ExtensionManager resync when the implementation changes" which effectively
     221                 :            : // got reverted again now.  Now, a mismatch between a UserInstallation's
     222                 :            : // user/extensions/bundled and an installation's share/extensions will always be
     223                 :            : // detected here and lead to a removal of user/extensions/bundled, so that
     224                 :            : // Desktop::SynchronizeExtensionRepositories will then definitely resync
     225                 :            : // share/extensions.)
     226                 :            : // As a special case, if you create a UserInstallation with LO >= 3.6.1, then
     227                 :            : // run an old LO <= 3.5.x using share/prereg/bundled on the same
     228                 :            : // UserInstallation (so that it partially overwrites user/extensions/bundled,
     229                 :            : // potentially duplicating component information, but not touching
     230                 :            : // user/extensions/bundled/buildid), and then run the new LO >= 3.6.1 on the
     231                 :            : // same UserInstallation again, it can fail to start (due to the duplicated
     232                 :            : // component information).  Even though such downgrading scenarios at best work
     233                 :            : // by luck in general, the special token LIBO_NON_PREREG_BUNDLED_EXTENSIONS=TRUE
     234                 :            : // is used to detect and fix that problem:  The assumption is that if an old LO
     235                 :            : // <= 3.5.x messed with user/extensions/bundled in the meantime, then it would
     236                 :            : // have rewritten the unorc (dropping the token), and LO >= 3.6.1 can detect
     237                 :            : // that.
     238                 :        158 : void refreshBundledExtensionsDir() {
     239                 :            :     OUString buildId(
     240                 :        158 :         "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") ":buildid}");
     241                 :        158 :     rtl::Bootstrap::expandMacros(buildId); //TODO: detect failure
     242                 :        158 :     OUString dir("$BUNDLED_EXTENSIONS_USER");
     243                 :        158 :     rtl::Bootstrap::expandMacros(dir); //TODO: detect failure
     244                 :        158 :     OUString url(dir + "/buildid");
     245                 :            :     OUString nonPrereg(
     246                 :            :         "${$BUNDLED_EXTENSIONS_USER/registry/"
     247                 :            :         "com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc:"
     248                 :        158 :         "LIBO_NON_PREREG_BUNDLED_EXTENSIONS}");
     249                 :        158 :     rtl::Bootstrap::expandMacros(nonPrereg);
     250         [ +  + ]:        158 :     if (nonPrereg == "TRUE") {
     251                 :         96 :         osl::File f(url);
     252      [ +  -  - ]:         96 :         switch (f.open(osl_File_OpenFlag_Read)) {
                 [ +  - ]
     253                 :            :         case osl::FileBase::E_None:
     254                 :            :             {
     255                 :         96 :                 rtl::ByteSequence s1;
     256         [ +  - ]:         96 :                 osl::FileBase::RC rc = f.readLine(s1);
     257         [ +  - ]:         96 :                 if (f.close() != osl::FileBase::E_None) {
     258                 :            :                     SAL_WARN(
     259                 :            :                         "desktop", "cannot close " + url + " after reading");
     260                 :            :                 }
     261         [ -  + ]:         96 :                 if (rc != osl::FileBase::E_None) {
     262                 :            :                     throw css::uno::RuntimeException(
     263                 :            :                         "cannot read from " + url,
     264         [ #  # ]:          0 :                         css::uno::Reference< css::uno::XInterface >());
     265                 :            :                 }
     266                 :            :                 OUString s2(
     267                 :         96 :                     reinterpret_cast< char const * >(s1.getConstArray()),
     268         [ +  - ]:        192 :                     s1.getLength(), RTL_TEXTENCODING_ISO_8859_1);
     269                 :            :                     // using ISO 8859-1 avoids any and all conversion errors;
     270                 :            :                     // the content should only be a subset of ASCII, anyway
     271         [ +  - ]:         96 :                 if (s2 == buildId) {
     272                 :        158 :                     return;
     273                 :            :                 }
     274 [ +  - ][ +  - ]:         96 :                 break;
     275                 :            :             }
     276                 :            :         case osl::FileBase::E_NOENT:
     277                 :          0 :             break;
     278                 :            :         default:
     279                 :            :             throw css::uno::RuntimeException(
     280                 :            :                 "cannot open " + url + " for reading",
     281         [ #  # ]:          0 :                 css::uno::Reference< css::uno::XInterface >());
     282 [ +  - ][ -  + ]:         96 :         }
     283                 :            :     }
     284         [ +  - ]:         62 :     removeTree(dir);
     285 [ +  - ][ +  - ]:         62 :     switch (osl::Directory::createPath(dir)) {
     286                 :            :     case osl::FileBase::E_None:
     287                 :            :     case osl::FileBase::E_EXIST:
     288                 :         62 :         break;
     289                 :            :     default:
     290                 :            :         throw css::uno::RuntimeException(
     291                 :            :             "cannot create path " + dir,
     292         [ #  # ]:          0 :             css::uno::Reference< css::uno::XInterface >());
     293                 :            :     }
     294                 :         62 :     osl::File f(url);
     295 [ -  + ][ +  - ]:         62 :     if (f.open(osl_File_OpenFlag_Write | osl_File_OpenFlag_Create) !=
     296                 :            :         osl::FileBase::E_None)
     297                 :            :     {
     298                 :            :         throw css::uno::RuntimeException(
     299                 :            :             "cannot open " + url + " for writing",
     300         [ #  # ]:          0 :             css::uno::Reference< css::uno::XInterface >());
     301                 :            :     }
     302         [ +  - ]:         62 :     OString buf(OUStringToOString(buildId, RTL_TEXTENCODING_UTF8));
     303                 :            :         // using UTF-8 avoids almost all conversion errors (and buildid
     304                 :            :         // containing single surrogate halves should never happen, anyway); the
     305                 :            :         // content should only be a subset of ASCII, anyway
     306                 :            :     sal_uInt64 n;
     307         [ +  - ]:        124 :     if (f.write(buf.getStr(), buf.getLength(), n) != osl::FileBase::E_None
           [ +  -  -  + ]
                 [ -  + ]
     308                 :         62 :         || n != static_cast< sal_uInt32 >(buf.getLength()))
     309                 :            :     {
     310                 :            :         throw css::uno::RuntimeException(
     311                 :            :             "cannot write to " + url,
     312         [ #  # ]:          0 :             css::uno::Reference< css::uno::XInterface >());
     313                 :            :     }
     314 [ +  - ][ -  + ]:         62 :     if (f.close() != osl::FileBase::E_None) {
     315                 :            :         throw css::uno::RuntimeException(
     316                 :            :             "cannot close " + url + " after writing",
     317         [ #  # ]:          0 :             css::uno::Reference< css::uno::XInterface >());
     318 [ +  - ][ +  + ]:        158 :     }
         [ +  + ][ +  + ]
                 [ +  + ]
     319                 :            : }
     320                 :            : 
     321                 :            : }
     322                 :            : 
     323                 :            : // ----------------------------------------------------------------------------
     324                 :            : 
     325                 :          0 : ResMgr* Desktop::GetDesktopResManager()
     326                 :            : {
     327         [ #  # ]:          0 :     if ( !Desktop::pResMgr )
     328                 :            :     {
     329                 :            :         // Create desktop resource manager and bootstrap process
     330                 :            :         // was successful. Use default way to get language specific message.
     331         [ #  # ]:          0 :         if ( Application::IsInExecute() )
     332         [ #  # ]:          0 :             Desktop::pResMgr = ResMgr::CreateResMgr("dkt");
     333                 :            : 
     334         [ #  # ]:          0 :         if ( !Desktop::pResMgr )
     335                 :            :         {
     336                 :            :             // Use VCL to get the correct language specific message as we
     337                 :            :             // are in the bootstrap process and not able to get the installed
     338                 :            :             // language!!
     339         [ #  # ]:          0 :             OUString aUILocaleString = LanguageSelection::getLanguageString();
     340                 :          0 :             sal_Int32 nIndex = 0;
     341                 :          0 :             OUString aLanguage = aUILocaleString.getToken( 0, '-', nIndex);
     342                 :          0 :             OUString aCountry = aUILocaleString.getToken( 0, '-', nIndex);
     343                 :          0 :             OUString aVariant = aUILocaleString.getToken( 0, '-', nIndex);
     344                 :            : 
     345                 :          0 :             ::com::sun::star::lang::Locale aLocale( aLanguage, aCountry, aVariant );
     346                 :            : 
     347         [ #  # ]:          0 :             Desktop::pResMgr = ResMgr::SearchCreateResMgr( "dkt", aLocale);
     348 [ #  # ][ #  # ]:          0 :             AllSettings as = GetSettings();
     349         [ #  # ]:          0 :             as.SetUILocale(aLocale);
     350 [ #  # ][ #  # ]:          0 :             SetSettings(as);
     351                 :            :         }
     352                 :            :     }
     353                 :            : 
     354                 :          0 :     return Desktop::pResMgr;
     355                 :            : }
     356                 :            : 
     357                 :            : // ----------------------------------------------------------------------------
     358                 :            : // Get a message string securely. There is a fallback string if the resource
     359                 :            : // is not available.
     360                 :            : 
     361                 :          0 : OUString Desktop::GetMsgString( sal_uInt16 nId, const OUString& aFaultBackMsg )
     362                 :            : {
     363                 :          0 :     ResMgr* resMgr = GetDesktopResManager();
     364         [ #  # ]:          0 :     if ( !resMgr )
     365                 :          0 :         return aFaultBackMsg;
     366                 :            :     else
     367 [ #  # ][ #  # ]:          0 :         return OUString( String( ResId( nId, *resMgr )));
                 [ #  # ]
     368                 :            : }
     369                 :            : 
     370                 :          0 : OUString MakeStartupErrorMessage(OUString const & aErrorMessage)
     371                 :            : {
     372                 :          0 :     OUStringBuffer    aDiagnosticMessage( 100 );
     373                 :            : 
     374         [ #  # ]:          0 :     ResMgr* pResMgr = Desktop::GetDesktopResManager();
     375         [ #  # ]:          0 :     if ( pResMgr )
     376 [ #  # ][ #  # ]:          0 :         aDiagnosticMessage.append( OUString(String(ResId(STR_BOOTSTRAP_ERR_CANNOT_START, *pResMgr))) );
         [ #  # ][ #  # ]
     377                 :            :     else
     378         [ #  # ]:          0 :         aDiagnosticMessage.appendAscii( "The program cannot be started." );
     379                 :            : 
     380         [ #  # ]:          0 :     aDiagnosticMessage.appendAscii( "\n" );
     381                 :            : 
     382         [ #  # ]:          0 :     aDiagnosticMessage.append( aErrorMessage );
     383                 :            : 
     384         [ #  # ]:          0 :     return aDiagnosticMessage.makeStringAndClear();
     385                 :            : }
     386                 :            : 
     387                 :          0 : OUString MakeStartupConfigAccessErrorMessage( OUString const & aInternalErrMsg )
     388                 :            : {
     389                 :          0 :     OUStringBuffer aDiagnosticMessage( 200 );
     390                 :            : 
     391         [ #  # ]:          0 :     ResMgr* pResMgr = Desktop::GetDesktopResManager();
     392         [ #  # ]:          0 :     if ( pResMgr )
     393 [ #  # ][ #  # ]:          0 :         aDiagnosticMessage.append( OUString(String(ResId(STR_BOOTSTRAP_ERR_CFG_DATAACCESS, *pResMgr ))) );
         [ #  # ][ #  # ]
     394                 :            :     else
     395         [ #  # ]:          0 :         aDiagnosticMessage.appendAscii( "The program cannot be started." );
     396                 :            : 
     397         [ #  # ]:          0 :     if ( !aInternalErrMsg.isEmpty() )
     398                 :            :     {
     399         [ #  # ]:          0 :         aDiagnosticMessage.appendAscii( "\n\n" );
     400         [ #  # ]:          0 :         if ( pResMgr )
     401 [ #  # ][ #  # ]:          0 :             aDiagnosticMessage.append( OUString(String(ResId(STR_INTERNAL_ERRMSG, *pResMgr ))) );
         [ #  # ][ #  # ]
     402                 :            :         else
     403         [ #  # ]:          0 :             aDiagnosticMessage.appendAscii( "The following internal error has occurred:\n\n" );
     404         [ #  # ]:          0 :         aDiagnosticMessage.append( aInternalErrMsg );
     405                 :            :     }
     406                 :            : 
     407         [ #  # ]:          0 :     return aDiagnosticMessage.makeStringAndClear();
     408                 :            : }
     409                 :            : 
     410                 :            : //=============================================================================
     411                 :            : // shows a simple error box with the given message ... but exits from these process !
     412                 :            : // Fatal errors cant be solved by the process ... nor any recovery can help.
     413                 :            : // Mostly the installation was damaged and must be repaired manually .. or by calling
     414                 :            : // setup again.
     415                 :            : // On the other side we must make sure that no further actions will be possible within
     416                 :            : // the current office process ! No pipe requests, no menu/toolbar/shortuct actions
     417                 :            : // are allowed. Otherwise we will force a "crash inside a crash".
     418                 :            : // Thats why we have to use a special native message box here which does not use yield :-)
     419                 :            : //=============================================================================
     420                 :          0 : void FatalError(const ::rtl::OUString& sMessage)
     421                 :            : {
     422         [ #  # ]:          0 :     ::rtl::OUString sProductKey = ::utl::Bootstrap::getProductKey();
     423         [ #  # ]:          0 :     if ( sProductKey.isEmpty())
     424                 :            :     {
     425         [ #  # ]:          0 :         osl_getExecutableFile( &sProductKey.pData );
     426                 :            : 
     427                 :          0 :         ::sal_uInt32 nLastIndex = sProductKey.lastIndexOf('/');
     428         [ #  # ]:          0 :         if ( nLastIndex > 0 )
     429                 :          0 :             sProductKey = sProductKey.copy( nLastIndex+1 );
     430                 :            :     }
     431                 :            : 
     432                 :          0 :     ::rtl::OUStringBuffer sTitle (128);
     433         [ #  # ]:          0 :     sTitle.append      (sProductKey     );
     434         [ #  # ]:          0 :     sTitle.appendAscii (" - Fatal Error");
     435                 :            : 
     436 [ #  # ][ #  # ]:          0 :     Application::ShowNativeErrorBox (sTitle.makeStringAndClear (), sMessage);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     437                 :          0 :     _exit(ExitHelper::E_FATAL_ERROR);
     438                 :            : }
     439                 :            : 
     440                 :        158 : static bool ShouldSuppressUI(const CommandLineArgs& rCmdLine)
     441                 :            : {
     442                 :        158 :     return  rCmdLine.IsInvisible() ||
     443                 :          0 :             rCmdLine.IsHeadless() ||
     444         [ #  # ]:        158 :             rCmdLine.IsQuickstart();
           [ -  +  #  # ]
     445                 :            : }
     446                 :            : 
     447                 :            : namespace
     448                 :            : {
     449                 :            :     struct theCommandLineArgs : public rtl::Static< CommandLineArgs, theCommandLineArgs > {};
     450                 :            : }
     451                 :            : 
     452                 :       1202 : CommandLineArgs& Desktop::GetCommandLineArgs()
     453                 :            : {
     454                 :       1202 :     return theCommandLineArgs::get();
     455                 :            : }
     456                 :            : 
     457                 :            : namespace
     458                 :            : {
     459                 :            :     struct BrandName
     460                 :            :         : public rtl::Static< String, BrandName > {};
     461                 :            :     struct Version
     462                 :            :         : public rtl::Static< String, Version > {};
     463                 :            :     struct AboutBoxVersion
     464                 :            :         : public rtl::Static< String, AboutBoxVersion > {};
     465                 :            :     struct AboutBoxVersionSuffix
     466                 :            :         : public rtl::Static< String, AboutBoxVersionSuffix > {};
     467                 :            :     struct OOOVendor
     468                 :            :         : public rtl::Static< String, OOOVendor > {};
     469                 :            :     struct Extension
     470                 :            :         : public rtl::Static< String, Extension > {};
     471                 :            :     struct XMLFileFormatName
     472                 :            :         : public rtl::Static< String, XMLFileFormatName > {};
     473                 :            :     struct XMLFileFormatVersion
     474                 :            :         : public rtl::Static< String, XMLFileFormatVersion > {};
     475                 :            :     struct WriterCompatibilityVersionOOo11
     476                 :            :         : public rtl::Static< String, WriterCompatibilityVersionOOo11 > {};
     477                 :            : }
     478                 :            : 
     479                 :    1865312 : rtl::OUString ReplaceStringHookProc( const rtl::OUString& rStr )
     480                 :            : {
     481                 :    1865312 :     rtl::OUString sRet(rStr);
     482                 :            : 
     483         [ +  + ]:    1865312 :     if ( sRet.indexOf( "%PRODUCT" ) != -1 )
     484                 :            :     {
     485 [ +  - ][ +  - ]:       1384 :         rtl::OUString sBrandName = BrandName::get();
     486 [ +  - ][ +  - ]:       1384 :         rtl::OUString sVersion = Version::get();
     487 [ +  - ][ +  - ]:       1384 :         rtl::OUString sAboutBoxVersion = AboutBoxVersion::get();
     488 [ +  - ][ +  - ]:       1384 :         rtl::OUString sAboutBoxVersionSuffix = AboutBoxVersionSuffix::get();
     489 [ +  - ][ +  - ]:       1384 :         rtl::OUString sExtension = Extension::get();
     490 [ +  - ][ +  - ]:       1384 :         rtl::OUString sXMLFileFormatName = XMLFileFormatName::get();
     491 [ +  - ][ +  - ]:       1384 :         rtl::OUString sXMLFileFormatVersion = XMLFileFormatVersion::get();
     492                 :            : 
     493         [ +  - ]:       1384 :         if ( sBrandName.isEmpty() )
     494                 :            :         {
     495         [ +  - ]:       1384 :             sBrandName = utl::ConfigManager::getProductName();
     496         [ +  - ]:       1384 :             sXMLFileFormatName = utl::ConfigManager::getProductXmlFileFormat();
     497                 :            :             sXMLFileFormatVersion =
     498         [ +  - ]:       1384 :                 utl::ConfigManager::getProductXmlFileFormatVersion();
     499         [ +  - ]:       1384 :             sVersion = utl::ConfigManager::getProductVersion();
     500         [ +  - ]:       1384 :             sAboutBoxVersion = utl::ConfigManager::getAboutBoxProductVersion();
     501         [ +  - ]:       1384 :             sAboutBoxVersionSuffix = utl::ConfigManager::getAboutBoxProductVersionSuffix();
     502         [ +  - ]:       1384 :             if ( sExtension.isEmpty() )
     503                 :            :             {
     504         [ +  - ]:       1384 :                 sExtension = utl::ConfigManager::getProductExtension();
     505                 :            :             }
     506                 :            :         }
     507                 :            : 
     508                 :       1384 :         sRet = sRet.replaceAll( "%PRODUCTNAME", sBrandName );
     509                 :       1384 :         sRet = sRet.replaceAll( "%PRODUCTVERSION", sVersion );
     510                 :       1384 :         sRet = sRet.replaceAll( "%ABOUTBOXPRODUCTVERSIONSUFFIX", sAboutBoxVersionSuffix );
     511                 :       1384 :         sRet = sRet.replaceAll( "%ABOUTBOXPRODUCTVERSION", sAboutBoxVersion );
     512                 :       1384 :         sRet = sRet.replaceAll( "%PRODUCTEXTENSION", sExtension );
     513                 :       1384 :         sRet = sRet.replaceAll( "%PRODUCTXMLFILEFORMATNAME", sXMLFileFormatName );
     514                 :       1384 :         sRet = sRet.replaceAll( "%PRODUCTXMLFILEFORMATVERSION", sXMLFileFormatVersion );
     515                 :            :     }
     516                 :            : 
     517         [ -  + ]:    1865312 :     if ( sRet.indexOf( "%OOOVENDOR" ) != -1 )
     518                 :            :     {
     519 [ #  # ][ #  # ]:          0 :         rtl::OUString sOOOVendor = OOOVendor::get();
     520                 :            : 
     521         [ #  # ]:          0 :         if ( sOOOVendor.isEmpty() )
     522                 :            :         {
     523         [ #  # ]:          0 :             sOOOVendor = utl::ConfigManager::getVendor();
     524                 :            :         }
     525                 :            : 
     526                 :          0 :         sRet = sRet.replaceAll( "%OOOVENDOR", sOOOVendor );
     527                 :            :     }
     528                 :            : 
     529         [ -  + ]:    1865312 :     if ( sRet.indexOf( "%WRITERCOMPATIBILITYVERSIONOOO11" ) != -1 )
     530                 :            :     {
     531 [ #  # ][ #  # ]:          0 :         rtl::OUString sWriterCompatibilityVersionOOo11 = WriterCompatibilityVersionOOo11::get();
     532         [ #  # ]:          0 :         if ( sWriterCompatibilityVersionOOo11.isEmpty() )
     533                 :            :         {
     534                 :            :             sWriterCompatibilityVersionOOo11 =
     535         [ #  # ]:          0 :                 utl::ConfigManager::getWriterCompatibilityVersionOOo_1_1();
     536                 :            :         }
     537                 :            : 
     538                 :            :         sRet = sRet.replaceAll( "%WRITERCOMPATIBILITYVERSIONOOO11",
     539                 :          0 :                                         sWriterCompatibilityVersionOOo11 );
     540                 :            :     }
     541                 :            : 
     542                 :    1865312 :     return sRet;
     543                 :            : }
     544                 :            : 
     545                 :        158 : Desktop::Desktop()
     546                 :            : : m_bServicesRegistered( false )
     547         [ +  - ]:        158 : , m_aBootstrapError( BE_OK )
     548                 :            : {
     549                 :            :     RTL_LOGFILE_TRACE( "desktop (cd100003) ::Desktop::Desktop" );
     550                 :        158 : }
     551                 :            : 
     552 [ +  - ][ +  - ]:        158 : Desktop::~Desktop()
     553                 :            : {
     554                 :            : #ifdef ENABLE_TELEPATHY
     555                 :            :     TeleManager::finalize();
     556                 :            : #endif
     557         [ -  + ]:        158 : }
     558                 :            : 
     559                 :        158 : void Desktop::Init()
     560                 :            : {
     561                 :            :     RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::Init" );
     562                 :        158 :     SetBootstrapStatus(BS_OK);
     563                 :            : 
     564                 :        158 :     refreshBundledExtensionsDir();
     565                 :            : 
     566                 :            :     // We need to have service factory before going further, but see fdo#37195.
     567                 :            :     // Doing this will mmap common.rdb, making it not overwritable on windows,
     568                 :            :     // so this can't happen before the synchronization above. Lets rework this
     569                 :            :     // so that the above is called *from* ensureProcessServiceFactory or
     570                 :            :     // something to enforce this gotcha
     571                 :        158 :     ensureProcessServiceFactory();
     572                 :            : 
     573         [ -  + ]:        158 :     if( !::comphelper::getProcessServiceFactory().is())
     574                 :            :     {
     575                 :            :         OSL_FAIL("Service factory should have been crated in soffice_main().");
     576                 :          0 :         SetBootstrapError( BE_UNO_SERVICEMANAGER );
     577                 :            :     }
     578                 :            : 
     579         [ +  - ]:        158 :     if ( GetBootstrapError() == BE_OK )
     580                 :            :     {
     581                 :            :         // prepare language
     582         [ -  + ]:        158 :         if ( !LanguageSelection::prepareLanguage() )
     583                 :            :         {
     584         [ #  # ]:          0 :             if ( LanguageSelection::getStatus() == LanguageSelection::LS_STATUS_CANNOT_DETERMINE_LANGUAGE )
     585                 :          0 :                 SetBootstrapError( BE_LANGUAGE_MISSING );
     586                 :            :             else
     587                 :          0 :                 SetBootstrapError( BE_OFFICECONFIG_BROKEN );
     588                 :            :         }
     589                 :            :     }
     590                 :            : 
     591         [ +  - ]:        158 :     if ( GetBootstrapError() == BE_OK )
     592                 :            :     {
     593                 :        158 :         const CommandLineArgs& rCmdLineArgs = GetCommandLineArgs();
     594                 :            :         // start ipc thread only for non-remote offices
     595                 :            :         RTL_LOGFILE_CONTEXT( aLog2, "desktop (cd100003) ::OfficeIPCThread::EnableOfficeIPCThread" );
     596                 :        158 :         OfficeIPCThread::Status aStatus = OfficeIPCThread::EnableOfficeIPCThread();
     597         [ -  + ]:        158 :         if ( aStatus == OfficeIPCThread::IPC_STATUS_BOOTSTRAP_ERROR )
     598                 :            :         {
     599                 :          0 :             SetBootstrapError( BE_PATHINFO_MISSING );
     600                 :            :         }
     601         [ -  + ]:        158 :         else if ( aStatus == OfficeIPCThread::IPC_STATUS_2ND_OFFICE )
     602                 :            :         {
     603                 :            :             // 2nd office startup should terminate after sending cmdlineargs through pipe
     604                 :          0 :             SetBootstrapStatus(BS_TERMINATE);
     605                 :            :         }
     606         [ -  + ]:        158 :         else if ( rCmdLineArgs.IsHelp() )
     607                 :            :         {
     608                 :            :             // disable IPC thread in an instance that is just showing a help message
     609                 :          0 :             OfficeIPCThread::DisableOfficeIPCThread();
     610                 :            :         }
     611                 :        158 :         pSignalHandler = osl_addSignalHandler(SalMainPipeExchangeSignal_impl, NULL);
     612                 :            :     }
     613                 :        158 : }
     614                 :            : 
     615                 :       1261 : void Desktop::InitFinished()
     616                 :            : {
     617                 :            :     RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::InitFinished" );
     618                 :            : 
     619                 :       1261 :     CloseSplashScreen();
     620                 :       1261 : }
     621                 :            : 
     622                 :            : // GetCommandLineArgs() requires this code to work, otherwise it will abort, and
     623                 :            : // on Unix command line args needs to be checked before Desktop::Init()
     624                 :        158 : void Desktop::ensureProcessServiceFactory()
     625                 :            : {
     626         [ +  - ]:        158 :     if (!comphelper::getProcessServiceFactory().is())
     627                 :            :     {
     628                 :            :         try
     629                 :            :         {
     630                 :            :             comphelper::setProcessServiceFactory(
     631 [ +  - ][ +  - ]:        158 :                 CreateApplicationServiceManager());
     632                 :            :         }
     633         [ #  # ]:          0 :         catch (const css::uno::Exception& e)
     634                 :            :         {
     635                 :            :             // Application::ShowNativeErrorBox would only work after InitVCL, so
     636                 :            :             // all we can realistically do here is hope the user can see stderr:
     637   [ #  #  #  #  :          0 :             std::cerr << "UNO Exception: " << e.Message << std::endl;
                   #  # ]
     638                 :            :             // Let exceptions escape and tear down the process, it is completely
     639                 :            :             // broken anyway:
     640                 :          0 :             throw;
     641                 :            :         }
     642                 :            :     }
     643                 :        158 : }
     644                 :            : 
     645                 :        158 : void Desktop::DeInit()
     646                 :            : {
     647                 :            :     RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::DeInit" );
     648                 :            : 
     649                 :            :     try {
     650                 :            :         // instead of removing of the configManager just let it commit all the changes
     651                 :            :         RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- store config items" );
     652         [ +  - ]:        158 :         utl::ConfigManager::storeConfigItems();
     653         [ +  - ]:        158 :         FlushConfiguration();
     654                 :            :         RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- store config items" );
     655                 :            : 
     656                 :            :         // close splashscreen if it's still open
     657         [ +  - ]:        158 :         CloseSplashScreen();
     658         [ +  - ]:        158 :         Reference<XMultiServiceFactory> xXMultiServiceFactory(::comphelper::getProcessServiceFactory());
     659         [ +  - ]:        158 :         DestroyApplicationServiceManager( xXMultiServiceFactory );
     660                 :            :         // nobody should get a destroyd service factory...
     661 [ +  - ][ +  - ]:        158 :         ::comphelper::setProcessServiceFactory( NULL );
     662                 :            : 
     663                 :            :         // clear lockfile
     664                 :        158 :         m_pLockfile.reset();
     665                 :            : 
     666         [ +  - ]:        158 :         OfficeIPCThread::DisableOfficeIPCThread();
     667         [ +  - ]:        158 :         if( pSignalHandler )
     668 [ +  - ][ #  # ]:        158 :             osl_removeSignalHandler( pSignalHandler );
     669                 :          0 :     } catch (const RuntimeException&) {
     670                 :            :         // someone threw an exception during shutdown
     671                 :            :         // this will leave some garbage behind..
     672                 :            :     }
     673                 :            : 
     674                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "FINISHED WITH Destop::DeInit" );
     675                 :        158 : }
     676                 :            : 
     677                 :          0 : sal_Bool Desktop::QueryExit()
     678                 :            : {
     679                 :            :     try
     680                 :            :     {
     681                 :            :         RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- store config items" );
     682         [ #  # ]:          0 :         utl::ConfigManager::storeConfigItems();
     683                 :            :         RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- store config items" );
     684                 :            :     }
     685         [ #  # ]:          0 :     catch ( const RuntimeException& )
     686                 :            :     {
     687                 :            :     }
     688                 :            : 
     689                 :          0 :     const sal_Char SUSPEND_QUICKSTARTVETO[] = "SuspendQuickstartVeto";
     690                 :            : 
     691                 :            :     Reference< ::com::sun::star::frame::XDesktop >
     692 [ #  # ][ #  # ]:          0 :             xDesktop( ::comphelper::getProcessServiceFactory()->createInstance( OUString("com.sun.star.frame.Desktop") ),
     693 [ #  # ][ #  # ]:          0 :                 UNO_QUERY );
     694                 :            : 
     695         [ #  # ]:          0 :     Reference < ::com::sun::star::beans::XPropertySet > xPropertySet( xDesktop, UNO_QUERY );
     696         [ #  # ]:          0 :     if ( xPropertySet.is() )
     697                 :            :     {
     698                 :          0 :         Any a;
     699         [ #  # ]:          0 :         a <<= (sal_Bool)sal_True;
     700 [ #  # ][ #  # ]:          0 :         xPropertySet->setPropertyValue( OUString(SUSPEND_QUICKSTARTVETO ), a );
     701                 :            :     }
     702                 :            : 
     703 [ #  # ][ #  # ]:          0 :     sal_Bool bExit = ( !xDesktop.is() || xDesktop->terminate() );
         [ #  # ][ #  # ]
     704                 :            : 
     705                 :            : 
     706 [ #  # ][ #  # ]:          0 :     if ( !bExit && xPropertySet.is() )
                 [ #  # ]
     707                 :            :     {
     708                 :          0 :         Any a;
     709         [ #  # ]:          0 :         a <<= (sal_Bool)sal_False;
     710 [ #  # ][ #  # ]:          0 :         xPropertySet->setPropertyValue( OUString(SUSPEND_QUICKSTARTVETO ), a );
                 [ #  # ]
     711                 :            :     }
     712                 :            :     else
     713                 :            :     {
     714         [ #  # ]:          0 :         FlushConfiguration();
     715                 :            :         try
     716                 :            :         {
     717                 :            :             // it is no problem to call DisableOfficeIPCThread() more than once
     718                 :            :             // it also looks to be threadsafe
     719         [ #  # ]:          0 :             OfficeIPCThread::DisableOfficeIPCThread();
     720                 :            :         }
     721         [ #  # ]:          0 :         catch ( const RuntimeException& )
     722                 :            :         {
     723                 :            :         }
     724                 :            : 
     725                 :          0 :         m_pLockfile.reset();
     726                 :            :     }
     727                 :            : 
     728         [ #  # ]:          0 :     return bExit;
     729                 :            : }
     730                 :            : 
     731                 :          0 : void Desktop::HandleBootstrapPathErrors( ::utl::Bootstrap::Status aBootstrapStatus, const OUString& aDiagnosticMessage )
     732                 :            : {
     733         [ #  # ]:          0 :     if ( aBootstrapStatus != ::utl::Bootstrap::DATA_OK )
     734                 :            :     {
     735                 :          0 :         ::rtl::OUString        aProductKey;
     736                 :          0 :         ::rtl::OUString        aTemp;
     737                 :            : 
     738         [ #  # ]:          0 :         osl_getExecutableFile( &aProductKey.pData );
     739                 :          0 :         sal_uInt32     lastIndex = aProductKey.lastIndexOf('/');
     740         [ #  # ]:          0 :         if ( lastIndex > 0 )
     741                 :          0 :             aProductKey = aProductKey.copy( lastIndex+1 );
     742                 :            : 
     743         [ #  # ]:          0 :         aTemp = ::utl::Bootstrap::getProductKey( aProductKey );
     744         [ #  # ]:          0 :         if ( !aTemp.isEmpty() )
     745                 :          0 :             aProductKey = aTemp;
     746                 :            : 
     747                 :          0 :         OUString        aMessage;
     748                 :          0 :         OUStringBuffer    aBuffer( 100 );
     749         [ #  # ]:          0 :         aBuffer.append( aDiagnosticMessage );
     750                 :            : 
     751         [ #  # ]:          0 :         aBuffer.appendAscii( "\n" );
     752                 :            : 
     753 [ #  # ][ #  # ]:          0 :         ErrorBox aBootstrapFailedBox( NULL, WB_OK, aMessage );
                 [ #  # ]
     754 [ #  # ][ #  # ]:          0 :         aBootstrapFailedBox.SetText( aProductKey );
                 [ #  # ]
     755 [ #  # ][ #  # ]:          0 :         aBootstrapFailedBox.Execute();
     756                 :            :     }
     757                 :          0 : }
     758                 :            : 
     759                 :            : // Create a error message depending on bootstrap failure code and an optional file url
     760                 :          0 : ::rtl::OUString    Desktop::CreateErrorMsgString(
     761                 :            :     utl::Bootstrap::FailureCode nFailureCode,
     762                 :            :     const ::rtl::OUString& aFileURL )
     763                 :            : {
     764                 :          0 :     OUString        aMsg;
     765                 :          0 :     OUString        aFilePath;
     766                 :          0 :     sal_Bool        bFileInfo = sal_True;
     767                 :            : 
     768   [ #  #  #  #  :          0 :     switch ( nFailureCode )
          #  #  #  #  #  
                      # ]
     769                 :            :     {
     770                 :            :         /// the shared installation directory could not be located
     771                 :            :         case ::utl::Bootstrap::MISSING_INSTALL_DIRECTORY:
     772                 :            :         {
     773                 :            :             aMsg = GetMsgString( STR_BOOTSTRAP_ERR_PATH_INVALID,
     774         [ #  # ]:          0 :                         OUString( "The installation path is not available." ) );
     775                 :          0 :             bFileInfo = sal_False;
     776                 :            :         }
     777                 :          0 :         break;
     778                 :            : 
     779                 :            :         /// the bootstrap INI file could not be found or read
     780                 :            :         case ::utl::Bootstrap::MISSING_BOOTSTRAP_FILE:
     781                 :            :         {
     782                 :            :             aMsg = GetMsgString( STR_BOOTSTRAP_ERR_FILE_MISSING,
     783         [ #  # ]:          0 :                         OUString( "The configuration file \"$1\" is missing." ) );
     784                 :            :         }
     785                 :          0 :         break;
     786                 :            : 
     787                 :            :         /// the bootstrap INI is missing a required entry
     788                 :            :         /// the bootstrap INI contains invalid data
     789                 :            :          case ::utl::Bootstrap::MISSING_BOOTSTRAP_FILE_ENTRY:
     790                 :            :          case ::utl::Bootstrap::INVALID_BOOTSTRAP_FILE_ENTRY:
     791                 :            :         {
     792                 :            :             aMsg = GetMsgString( STR_BOOTSTRAP_ERR_FILE_CORRUPT,
     793         [ #  # ]:          0 :                         OUString( "The configuration file \"$1\" is corrupt." ) );
     794                 :            :         }
     795                 :          0 :         break;
     796                 :            : 
     797                 :            :         /// the version locator INI file could not be found or read
     798                 :            :         case ::utl::Bootstrap::MISSING_VERSION_FILE:
     799                 :            :         {
     800                 :            :             aMsg = GetMsgString( STR_BOOTSTRAP_ERR_FILE_MISSING,
     801         [ #  # ]:          0 :                         OUString( "The configuration file \"$1\" is missing." ) );
     802                 :            :         }
     803                 :          0 :         break;
     804                 :            : 
     805                 :            :         /// the version locator INI has no entry for this version
     806                 :            :          case ::utl::Bootstrap::MISSING_VERSION_FILE_ENTRY:
     807                 :            :         {
     808                 :            :             aMsg = GetMsgString( STR_BOOTSTRAP_ERR_NO_SUPPORT,
     809         [ #  # ]:          0 :                         OUString( "The main configuration file \"$1\" does not support the current version." ) );
     810                 :            :         }
     811                 :          0 :         break;
     812                 :            : 
     813                 :            :         /// the user installation directory does not exist
     814                 :            :            case ::utl::Bootstrap::MISSING_USER_DIRECTORY:
     815                 :            :         {
     816                 :            :             aMsg = GetMsgString( STR_BOOTSTRAP_ERR_DIR_MISSING,
     817         [ #  # ]:          0 :                         OUString( "The configuration directory \"$1\" is missing." ) );
     818                 :            :         }
     819                 :          0 :         break;
     820                 :            : 
     821                 :            :         /// some bootstrap data was invalid in unexpected ways
     822                 :            :         case ::utl::Bootstrap::INVALID_BOOTSTRAP_DATA:
     823                 :            :         {
     824                 :            :             aMsg = GetMsgString( STR_BOOTSTRAP_ERR_INTERNAL,
     825         [ #  # ]:          0 :                         OUString( "An internal failure occurred." ) );
     826                 :          0 :             bFileInfo = sal_False;
     827                 :            :         }
     828                 :          0 :         break;
     829                 :            : 
     830                 :            :         case ::utl::Bootstrap::INVALID_VERSION_FILE_ENTRY:
     831                 :            :         {
     832                 :            :             // This needs to be improved, see #i67575#:
     833                 :            :             aMsg = OUString(
     834                 :          0 :                 "Invalid version file entry"  );
     835                 :          0 :             bFileInfo = sal_False;
     836                 :            :         }
     837                 :          0 :         break;
     838                 :            : 
     839                 :            :         case ::utl::Bootstrap::NO_FAILURE:
     840                 :            :         {
     841                 :            :             OSL_ASSERT(false);
     842                 :            :         }
     843                 :          0 :         break;
     844                 :            :     }
     845                 :            : 
     846         [ #  # ]:          0 :     if ( bFileInfo )
     847                 :            :     {
     848         [ #  # ]:          0 :         String aMsgString( aMsg );
     849                 :            : 
     850         [ #  # ]:          0 :         osl::File::getSystemPathFromFileURL( aFileURL, aFilePath );
     851                 :            : 
     852 [ #  # ][ #  # ]:          0 :         aMsgString.SearchAndReplaceAscii( "$1", aFilePath );
                 [ #  # ]
     853 [ #  # ][ #  # ]:          0 :         aMsg = aMsgString;
     854                 :            :     }
     855                 :            : 
     856         [ #  # ]:          0 :     return MakeStartupErrorMessage( aMsg );
     857                 :            : }
     858                 :            : 
     859                 :          0 : void Desktop::HandleBootstrapErrors( BootstrapError aBootstrapError )
     860                 :            : {
     861         [ #  # ]:          0 :     if ( aBootstrapError == BE_PATHINFO_MISSING )
     862                 :            :     {
     863                 :          0 :         OUString                    aErrorMsg;
     864                 :          0 :         OUString                    aBuffer;
     865                 :            :         utl::Bootstrap::Status        aBootstrapStatus;
     866                 :            :         utl::Bootstrap::FailureCode    nFailureCode;
     867                 :            : 
     868         [ #  # ]:          0 :         aBootstrapStatus = ::utl::Bootstrap::checkBootstrapStatus( aBuffer, nFailureCode );
     869         [ #  # ]:          0 :         if ( aBootstrapStatus != ::utl::Bootstrap::DATA_OK )
     870                 :            :         {
     871   [ #  #  #  #  :          0 :             switch ( nFailureCode )
                   #  # ]
     872                 :            :             {
     873                 :            :                 case ::utl::Bootstrap::MISSING_INSTALL_DIRECTORY:
     874                 :            :                 case ::utl::Bootstrap::INVALID_BOOTSTRAP_DATA:
     875                 :            :                 {
     876         [ #  # ]:          0 :                     aErrorMsg = CreateErrorMsgString( nFailureCode, OUString() );
     877                 :            :                 }
     878                 :          0 :                 break;
     879                 :            : 
     880                 :            :                 /// the bootstrap INI file could not be found or read
     881                 :            :                 /// the bootstrap INI is missing a required entry
     882                 :            :                 /// the bootstrap INI contains invalid data
     883                 :            :                  case ::utl::Bootstrap::MISSING_BOOTSTRAP_FILE_ENTRY:
     884                 :            :                  case ::utl::Bootstrap::INVALID_BOOTSTRAP_FILE_ENTRY:
     885                 :            :                 case ::utl::Bootstrap::MISSING_BOOTSTRAP_FILE:
     886                 :            :                 {
     887                 :          0 :                     OUString aBootstrapFileURL;
     888                 :            : 
     889         [ #  # ]:          0 :                     utl::Bootstrap::locateBootstrapFile( aBootstrapFileURL );
     890         [ #  # ]:          0 :                     aErrorMsg = CreateErrorMsgString( nFailureCode, aBootstrapFileURL );
     891                 :            :                 }
     892                 :          0 :                 break;
     893                 :            : 
     894                 :            :                 /// the version locator INI file could not be found or read
     895                 :            :                 /// the version locator INI has no entry for this version
     896                 :            :                 /// the version locator INI entry is not a valid directory URL
     897                 :            :                    case ::utl::Bootstrap::INVALID_VERSION_FILE_ENTRY:
     898                 :            :                  case ::utl::Bootstrap::MISSING_VERSION_FILE_ENTRY:
     899                 :            :                  case ::utl::Bootstrap::MISSING_VERSION_FILE:
     900                 :            :                 {
     901                 :          0 :                     OUString aVersionFileURL;
     902                 :            : 
     903         [ #  # ]:          0 :                     utl::Bootstrap::locateVersionFile( aVersionFileURL );
     904         [ #  # ]:          0 :                     aErrorMsg = CreateErrorMsgString( nFailureCode, aVersionFileURL );
     905                 :            :                 }
     906                 :          0 :                 break;
     907                 :            : 
     908                 :            :                 /// the user installation directory does not exist
     909                 :            :                    case ::utl::Bootstrap::MISSING_USER_DIRECTORY:
     910                 :            :                 {
     911                 :          0 :                     OUString aUserInstallationURL;
     912                 :            : 
     913         [ #  # ]:          0 :                     utl::Bootstrap::locateUserInstallation( aUserInstallationURL );
     914         [ #  # ]:          0 :                     aErrorMsg = CreateErrorMsgString( nFailureCode, aUserInstallationURL );
     915                 :            :                 }
     916                 :          0 :                 break;
     917                 :            : 
     918                 :            :                 case ::utl::Bootstrap::NO_FAILURE:
     919                 :            :                 {
     920                 :            :                     OSL_ASSERT(false);
     921                 :            :                 }
     922                 :          0 :                 break;
     923                 :            :             }
     924                 :            : 
     925         [ #  # ]:          0 :             HandleBootstrapPathErrors( aBootstrapStatus, aErrorMsg );
     926                 :          0 :         }
     927                 :            :     }
     928 [ #  # ][ #  # ]:          0 :     else if ( aBootstrapError == BE_UNO_SERVICEMANAGER || aBootstrapError == BE_UNO_SERVICE_CONFIG_MISSING )
     929                 :            :     {
     930                 :            :         // Uno service manager is not available. VCL needs a uno service manager to display a message box!!!
     931                 :            :         // Currently we are not able to display a message box with a service manager due to this limitations inside VCL.
     932                 :            : 
     933                 :            :         // When UNO is not properly initialized, all kinds of things can fail
     934                 :            :         // and cause the process to crash (e.g., a call to GetMsgString may
     935                 :            :         // crash when somewhere deep within that call Any::operator <= is used
     936                 :            :         // with a PropertyValue, and no binary UNO type description for
     937                 :            :         // PropertyValue is available).  To give the user a hint even if
     938                 :            :         // generating and displaying a message box below crashes, print a
     939                 :            :         // hard-coded message on stderr first:
     940                 :            :         fputs(
     941                 :            :             aBootstrapError == BE_UNO_SERVICEMANAGER
     942                 :            :             ? ("The application cannot be started. " "\n"
     943                 :            :                "The component manager is not available." "\n")
     944                 :            :                 // STR_BOOTSTRAP_ERR_CANNOT_START, STR_BOOTSTRAP_ERR_NO_SERVICE
     945                 :            :             : ("The application cannot be started. " "\n"
     946                 :            :                "The configuration service is not available." "\n"),
     947                 :            :                 // STR_BOOTSTRAP_ERR_CANNOT_START,
     948                 :            :                 // STR_BOOTSTRAP_ERR_NO_CFG_SERVICE
     949 [ #  # ][ #  # ]:          0 :             stderr);
     950                 :            : 
     951                 :            :         // First sentence. We cannot bootstrap office further!
     952                 :          0 :         OUString            aMessage;
     953                 :          0 :         OUStringBuffer        aDiagnosticMessage( 100 );
     954                 :            : 
     955                 :          0 :         OUString aErrorMsg;
     956                 :            : 
     957         [ #  # ]:          0 :         if ( aBootstrapError == BE_UNO_SERVICEMANAGER )
     958                 :            :             aErrorMsg = GetMsgString( STR_BOOTSTRAP_ERR_NO_SERVICE,
     959         [ #  # ]:          0 :                             OUString( "The service manager is not available." ) );
     960                 :            :         else
     961                 :            :             aErrorMsg = GetMsgString( STR_BOOTSTRAP_ERR_NO_CFG_SERVICE,
     962         [ #  # ]:          0 :                             OUString( "The configuration service is not available." ) );
     963                 :            : 
     964         [ #  # ]:          0 :         aDiagnosticMessage.append( aErrorMsg );
     965         [ #  # ]:          0 :         aDiagnosticMessage.appendAscii( "\n" );
     966                 :            : 
     967                 :            :         // Due to the fact the we haven't a backup applicat.rdb file anymore it is not possible to
     968                 :            :         // repair the installation with the setup executable besides the office executable. Now
     969                 :            :         // we have to ask the user to start the setup on CD/installation directory manually!!
     970                 :            :         OUString aStartSetupManually( GetMsgString(
     971                 :            :             STR_ASK_START_SETUP_MANUALLY,
     972         [ #  # ]:          0 :             OUString( "Start setup application to repair the installation from CD, or the folder containing the installation packages." ) ));
     973                 :            : 
     974         [ #  # ]:          0 :         aDiagnosticMessage.append( aStartSetupManually );
     975 [ #  # ][ #  # ]:          0 :         aMessage = MakeStartupErrorMessage( aDiagnosticMessage.makeStringAndClear() );
     976                 :            : 
     977         [ #  # ]:          0 :         FatalError( aMessage);
     978                 :            :     }
     979         [ #  # ]:          0 :     else if ( aBootstrapError == BE_OFFICECONFIG_BROKEN )
     980                 :            :     {
     981                 :          0 :         OUString aMessage;
     982                 :          0 :         OUStringBuffer aDiagnosticMessage( 100 );
     983                 :          0 :         OUString aErrorMsg;
     984                 :            :         aErrorMsg = GetMsgString( STR_CONFIG_ERR_ACCESS_GENERAL,
     985         [ #  # ]:          0 :             OUString( "A general error occurred while accessing your central configuration." ) );
     986         [ #  # ]:          0 :         aDiagnosticMessage.append( aErrorMsg );
     987 [ #  # ][ #  # ]:          0 :         aMessage = MakeStartupErrorMessage( aDiagnosticMessage.makeStringAndClear() );
     988         [ #  # ]:          0 :         FatalError(aMessage);
     989                 :            :     }
     990         [ #  # ]:          0 :     else if ( aBootstrapError == BE_USERINSTALL_FAILED )
     991                 :            :     {
     992                 :          0 :         OUString aMessage;
     993                 :          0 :         OUStringBuffer aDiagnosticMessage( 100 );
     994                 :          0 :         OUString aErrorMsg;
     995                 :            :         aErrorMsg = GetMsgString( STR_BOOTSTRAP_ERR_INTERNAL,
     996         [ #  # ]:          0 :             OUString( "User installation could not be completed" ) );
     997         [ #  # ]:          0 :         aDiagnosticMessage.append( aErrorMsg );
     998 [ #  # ][ #  # ]:          0 :         aMessage = MakeStartupErrorMessage( aDiagnosticMessage.makeStringAndClear() );
     999         [ #  # ]:          0 :         FatalError(aMessage);
    1000                 :            :     }
    1001         [ #  # ]:          0 :     else if ( aBootstrapError == BE_LANGUAGE_MISSING )
    1002                 :            :     {
    1003                 :          0 :         OUString aMessage;
    1004                 :          0 :         OUStringBuffer aDiagnosticMessage( 100 );
    1005                 :          0 :         OUString aErrorMsg;
    1006                 :            :         aErrorMsg = GetMsgString(
    1007                 :            :             //@@@ FIXME: should use an own resource string => #i36213#
    1008                 :            :             STR_BOOTSTRAP_ERR_LANGUAGE_MISSING,
    1009         [ #  # ]:          0 :             OUString( "Language could not be determined." ) );
    1010         [ #  # ]:          0 :         aDiagnosticMessage.append( aErrorMsg );
    1011                 :            :         aMessage = MakeStartupErrorMessage(
    1012 [ #  # ][ #  # ]:          0 :             aDiagnosticMessage.makeStringAndClear() );
    1013         [ #  # ]:          0 :         FatalError(aMessage);
    1014                 :            :     }
    1015 [ #  # ][ #  # ]:          0 :     else if (( aBootstrapError == BE_USERINSTALL_NOTENOUGHDISKSPACE ) ||
    1016                 :            :              ( aBootstrapError == BE_USERINSTALL_NOWRITEACCESS      ))
    1017                 :            :     {
    1018                 :          0 :         OUString       aUserInstallationURL;
    1019                 :          0 :         OUString       aUserInstallationPath;
    1020                 :          0 :         OUString       aMessage;
    1021                 :          0 :         OUString       aErrorMsg;
    1022                 :          0 :         OUStringBuffer aDiagnosticMessage( 100 );
    1023                 :            : 
    1024         [ #  # ]:          0 :         utl::Bootstrap::locateUserInstallation( aUserInstallationURL );
    1025                 :            : 
    1026         [ #  # ]:          0 :         if ( aBootstrapError == BE_USERINSTALL_NOTENOUGHDISKSPACE )
    1027                 :            :             aErrorMsg = GetMsgString(
    1028                 :            :                 STR_BOOSTRAP_ERR_NOTENOUGHDISKSPACE,
    1029         [ #  # ]:          0 :                 OUString( "User installation could not be completed due to insufficient free disk space." ) );
    1030                 :            :         else
    1031                 :            :             aErrorMsg = GetMsgString(
    1032                 :            :                 STR_BOOSTRAP_ERR_NOACCESSRIGHTS,
    1033         [ #  # ]:          0 :                 OUString( "User installation could not be processed due to missing access rights." ) );
    1034                 :            : 
    1035         [ #  # ]:          0 :         osl::File::getSystemPathFromFileURL( aUserInstallationURL, aUserInstallationPath );
    1036                 :            : 
    1037         [ #  # ]:          0 :         aDiagnosticMessage.append( aErrorMsg );
    1038         [ #  # ]:          0 :         aDiagnosticMessage.append( aUserInstallationPath );
    1039                 :            :         aMessage = MakeStartupErrorMessage(
    1040 [ #  # ][ #  # ]:          0 :             aDiagnosticMessage.makeStringAndClear() );
    1041         [ #  # ]:          0 :         FatalError(aMessage);
    1042                 :            :     }
    1043                 :            : 
    1044                 :          0 :     return;
    1045                 :            : }
    1046                 :            : 
    1047                 :            : 
    1048                 :        158 : void Desktop::retrieveCrashReporterState()
    1049                 :            : {
    1050                 :            :     _bCrashReporterEnabled
    1051                 :        158 :         = officecfg::Office::Recovery::CrashReporter::Enabled::get();
    1052                 :        158 : }
    1053                 :            : 
    1054                 :          0 : sal_Bool Desktop::isUIOnSessionShutdownAllowed()
    1055                 :            : {
    1056                 :            :     return officecfg::Office::Recovery::SessionShutdown::DocumentStoreUIEnabled
    1057                 :            :         ::get();
    1058                 :            : }
    1059                 :            : 
    1060                 :            : //-----------------------------------------------
    1061                 :            : /** @short  check if crash reporter feature is enabled or
    1062                 :            :             disabled.
    1063                 :            : */
    1064                 :        158 : sal_Bool Desktop::isCrashReporterEnabled()
    1065                 :            : {
    1066                 :        158 :     return _bCrashReporterEnabled;
    1067                 :            : }
    1068                 :            : 
    1069                 :            : //-----------------------------------------------
    1070                 :            : /** @short  check if recovery must be started or not.
    1071                 :            : 
    1072                 :            :     @param  bCrashed [boolean ... out!]
    1073                 :            :             the office crashed last times.
    1074                 :            :             But may be there are no recovery data.
    1075                 :            :             Usefull to trigger the error report tool without
    1076                 :            :             showing the recovery UI.
    1077                 :            : 
    1078                 :            :     @param  bRecoveryDataExists [boolean ... out!]
    1079                 :            :             there exists some recovery data.
    1080                 :            : 
    1081                 :            :     @param  bSessionDataExists [boolean ... out!]
    1082                 :            :             there exists some session data.
    1083                 :            :             Because the user may be logged out last time from it's
    1084                 :            :             unix session...
    1085                 :            : */
    1086                 :        158 : void impl_checkRecoveryState(sal_Bool& bCrashed           ,
    1087                 :            :                              sal_Bool& bRecoveryDataExists,
    1088                 :            :                              sal_Bool& bSessionDataExists )
    1089                 :            : {
    1090                 :        158 :     bCrashed = officecfg::Office::Recovery::RecoveryInfo::Crashed::get();
    1091 [ +  - ][ +  - ]:        316 :     bool elements = officecfg::Office::Recovery::RecoveryList::get()->
    1092         [ +  - ]:        158 :         hasElements();
    1093                 :            :     bool session
    1094                 :            :         = officecfg::Office::Recovery::RecoveryInfo::SessionData::get();
    1095 [ #  # ][ -  + ]:        158 :     bRecoveryDataExists = elements && !session;
    1096 [ -  + ][ #  # ]:        158 :     bSessionDataExists = elements && session;
    1097                 :        158 : }
    1098                 :            : 
    1099                 :            : //-----------------------------------------------
    1100                 :            : /*  @short  start the recovery wizard.
    1101                 :            : 
    1102                 :            :     @param  bEmergencySave
    1103                 :            :             differs between EMERGENCY_SAVE and RECOVERY
    1104                 :            : */
    1105                 :          0 : sal_Bool impl_callRecoveryUI(sal_Bool bEmergencySave     ,
    1106                 :            :                              sal_Bool bCrashed           ,
    1107                 :            :                              sal_Bool bExistsRecoveryData)
    1108                 :            : {
    1109 [ #  # ][ #  # ]:          0 :     static ::rtl::OUString SERVICENAME_RECOVERYUI("com.sun.star.comp.svx.RecoveryUI");
    1110 [ #  # ][ #  # ]:          0 :     static ::rtl::OUString COMMAND_EMERGENCYSAVE("vnd.sun.star.autorecovery:/doEmergencySave");
    1111 [ #  # ][ #  # ]:          0 :     static ::rtl::OUString COMMAND_RECOVERY("vnd.sun.star.autorecovery:/doAutoRecovery");
    1112 [ #  # ][ #  # ]:          0 :     static ::rtl::OUString COMMAND_CRASHREPORT("vnd.sun.star.autorecovery:/doCrashReport");
    1113                 :            : 
    1114         [ #  # ]:          0 :     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
    1115                 :            : 
    1116                 :            :     Reference< css::frame::XSynchronousDispatch > xRecoveryUI(
    1117         [ #  # ]:          0 :         xSMGR->createInstance(SERVICENAME_RECOVERYUI),
    1118 [ #  # ][ #  # ]:          0 :         css::uno::UNO_QUERY_THROW);
    1119                 :            : 
    1120                 :            :     Reference< css::util::XURLTransformer > xURLParser(
    1121 [ #  # ][ #  # ]:          0 :         css::util::URLTransformer::create(::comphelper::getProcessComponentContext()) );
    1122                 :            : 
    1123                 :          0 :     css::util::URL aURL;
    1124         [ #  # ]:          0 :     if (bEmergencySave)
    1125                 :          0 :         aURL.Complete = COMMAND_EMERGENCYSAVE;
    1126         [ #  # ]:          0 :     else if (bExistsRecoveryData)
    1127                 :          0 :         aURL.Complete = COMMAND_RECOVERY;
    1128 [ #  # ][ #  # ]:          0 :     else if (bCrashed && Desktop::isCrashReporterEnabled() )
                 [ #  # ]
    1129                 :          0 :         aURL.Complete = COMMAND_CRASHREPORT;
    1130                 :            :     else
    1131                 :          0 :         return false;
    1132                 :            : 
    1133 [ #  # ][ #  # ]:          0 :     xURLParser->parseStrict(aURL);
    1134                 :            : 
    1135 [ #  # ][ #  # ]:          0 :     css::uno::Any aRet = xRecoveryUI->dispatchWithReturnValue(aURL, css::uno::Sequence< css::beans::PropertyValue >());
         [ #  # ][ #  # ]
    1136                 :          0 :     sal_Bool bRet = sal_False;
    1137                 :          0 :     aRet >>= bRet;
    1138 [ #  # ][ #  # ]:          0 :     return !bEmergencySave || bRet;
    1139                 :            : }
    1140                 :            : 
    1141                 :            : /*
    1142                 :            :  * Save all open documents so they will be reopened
    1143                 :            :  * the next time the application ist started
    1144                 :            :  *
    1145                 :            :  * returns sal_True if at least one document could be saved...
    1146                 :            :  *
    1147                 :            :  */
    1148                 :            : 
    1149                 :          0 : sal_Bool Desktop::SaveTasks()
    1150                 :            : {
    1151                 :            :     return impl_callRecoveryUI(
    1152                 :            :         sal_True , // sal_True => force emergency save
    1153                 :            :         sal_False, // 2. and 3. param not used if 1. = true!
    1154                 :          0 :         sal_False);
    1155                 :            : }
    1156                 :            : 
    1157                 :            : namespace {
    1158                 :            : 
    1159                 :         62 : void restartOnMac(bool passArguments) {
    1160                 :            : #if defined MACOSX
    1161                 :            :     OfficeIPCThread::DisableOfficeIPCThread();
    1162                 :            :     rtl::OUString execUrl;
    1163                 :            :     OSL_VERIFY(osl_getExecutableFile(&execUrl.pData) == osl_Process_E_None);
    1164                 :            :     rtl::OUString execPath;
    1165                 :            :     rtl::OString execPath8;
    1166                 :            :     if ((osl::FileBase::getSystemPathFromFileURL(execUrl, execPath)
    1167                 :            :          != osl::FileBase::E_None) ||
    1168                 :            :         !execPath.convertToString(
    1169                 :            :             &execPath8, osl_getThreadTextEncoding(),
    1170                 :            :             (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
    1171                 :            :              RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
    1172                 :            :     {
    1173                 :            :         std::abort();
    1174                 :            :     }
    1175                 :            :     std::vector< rtl::OString > args;
    1176                 :            :     args.push_back(execPath8);
    1177                 :            :     bool wait = false;
    1178                 :            :     if (passArguments) {
    1179                 :            :         sal_uInt32 n = osl_getCommandArgCount();
    1180                 :            :         for (sal_uInt32 i = 0; i < n; ++i) {
    1181                 :            :             rtl::OUString arg;
    1182                 :            :             OSL_VERIFY(osl_getCommandArg(i, &arg.pData) == osl_Process_E_None);
    1183                 :            :             if (arg.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("--accept="))) {
    1184                 :            :                 wait = true;
    1185                 :            :             }
    1186                 :            :             rtl::OString arg8;
    1187                 :            :             if (!arg.convertToString(
    1188                 :            :                     &arg8, osl_getThreadTextEncoding(),
    1189                 :            :                     (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
    1190                 :            :                      RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
    1191                 :            :             {
    1192                 :            :                 std::abort();
    1193                 :            :             }
    1194                 :            :             args.push_back(arg8);
    1195                 :            :         }
    1196                 :            :     }
    1197                 :            :     std::vector< char const * > argPtrs;
    1198                 :            :     for (std::vector< rtl::OString >::iterator i(args.begin()); i != args.end();
    1199                 :            :          ++i)
    1200                 :            :     {
    1201                 :            :         argPtrs.push_back(i->getStr());
    1202                 :            :     }
    1203                 :            :     argPtrs.push_back(0);
    1204                 :            :     execv(execPath8.getStr(), const_cast< char ** >(&argPtrs[0]));
    1205                 :            :     if (errno == ENOTSUP) { // happens when multithreaded on OS X < 10.6
    1206                 :            :         pid_t pid = fork();
    1207                 :            :         if (pid == 0) {
    1208                 :            :             execv(execPath8.getStr(), const_cast< char ** >(&argPtrs[0]));
    1209                 :            :         } else if (pid > 0) {
    1210                 :            :             // Two simultaneously running soffice processes lead to two dock
    1211                 :            :             // icons, so avoid waiting here unless it must be assumed that the
    1212                 :            :             // process invoking soffice itself wants to wait for soffice to
    1213                 :            :             // finish:
    1214                 :            :             if (!wait) {
    1215                 :            :                 return;
    1216                 :            :             }
    1217                 :            :             int stat;
    1218                 :            :             if (waitpid(pid, &stat, 0) == pid && WIFEXITED(stat)) {
    1219                 :            :                 _exit(WEXITSTATUS(stat));
    1220                 :            :             }
    1221                 :            :         }
    1222                 :            :     }
    1223                 :            :     std::abort();
    1224                 :            : #else
    1225                 :            :     (void) passArguments; // avoid warnings
    1226                 :            : #endif
    1227                 :         62 : }
    1228                 :            : 
    1229                 :            : }
    1230                 :            : 
    1231                 :          0 : sal_uInt16 Desktop::Exception(sal_uInt16 nError)
    1232                 :            : {
    1233                 :            :     // protect against recursive calls
    1234                 :            :     static sal_Bool bInException = sal_False;
    1235                 :            : 
    1236                 :          0 :     sal_uInt16 nOldMode = Application::GetSystemWindowMode();
    1237                 :          0 :     Application::SetSystemWindowMode( nOldMode & ~SYSTEMWINDOW_MODE_NOAUTOMODE );
    1238                 :          0 :     Application::SetDefDialogParent( NULL );
    1239                 :            : 
    1240         [ #  # ]:          0 :     if ( bInException )
    1241                 :            :     {
    1242         [ #  # ]:          0 :         String aDoubleExceptionString;
    1243 [ #  # ][ #  # ]:          0 :         Application::Abort( aDoubleExceptionString );
    1244                 :            :     }
    1245                 :            : 
    1246                 :          0 :     bInException = sal_True;
    1247                 :          0 :     const CommandLineArgs& rArgs = GetCommandLineArgs();
    1248                 :            : 
    1249                 :            :     // save all modified documents ... if it's allowed doing so.
    1250                 :          0 :     sal_Bool bRestart                           = sal_False;
    1251                 :            :     sal_Bool bAllowRecoveryAndSessionManagement = (
    1252                 :          0 :                                                     ( !rArgs.IsNoRestore()                    ) && // some use cases of office must work without recovery
    1253                 :          0 :                                                     ( !rArgs.IsHeadless()                     ) &&
    1254                 :            :                                                     (( nError & EXC_MAJORTYPE ) != EXC_DISPLAY ) && // recovery cant work without UI ... but UI layer seams to be the reason for this crash
    1255                 :          0 :                                                     ( Application::IsInExecute()               )    // crashes during startup and shutdown should be ignored (they indicates a corrupt installation ...)
    1256   [ #  #  #  # ]:          0 :                                                   );
           [ #  #  #  # ]
    1257         [ #  # ]:          0 :     if ( bAllowRecoveryAndSessionManagement )
    1258                 :          0 :         bRestart = SaveTasks();
    1259                 :            : 
    1260                 :          0 :     FlushConfiguration();
    1261                 :            : 
    1262      [ #  #  # ]:          0 :     switch( nError & EXC_MAJORTYPE )
    1263                 :            :     {
    1264                 :            :         case EXC_RSCNOTLOADED:
    1265                 :            :         {
    1266         [ #  # ]:          0 :             String aResExceptionString;
    1267         [ #  # ]:          0 :             Application::Abort( aResExceptionString );
    1268         [ #  # ]:          0 :             break;
    1269                 :            :         }
    1270                 :            : 
    1271                 :            :         case EXC_SYSOBJNOTCREATED:
    1272                 :            :         {
    1273         [ #  # ]:          0 :             String aSysResExceptionString;
    1274         [ #  # ]:          0 :             Application::Abort( aSysResExceptionString );
    1275         [ #  # ]:          0 :             break;
    1276                 :            :         }
    1277                 :            : 
    1278                 :            :         default:
    1279                 :            :         {
    1280                 :          0 :             m_pLockfile.reset();
    1281                 :            : 
    1282         [ #  # ]:          0 :             if( bRestart )
    1283                 :            :             {
    1284                 :          0 :                 OfficeIPCThread::DisableOfficeIPCThread();
    1285         [ #  # ]:          0 :                 if( pSignalHandler )
    1286                 :          0 :                     osl_removeSignalHandler( pSignalHandler );
    1287                 :            : 
    1288                 :          0 :                 restartOnMac(false);
    1289         [ #  # ]:          0 :                 if ( m_rSplashScreen.is() )
    1290                 :          0 :                     m_rSplashScreen->reset();
    1291                 :            : 
    1292                 :          0 :                 _exit( ExitHelper::E_CRASH_WITH_RESTART );
    1293                 :            :             }
    1294                 :            :             else
    1295                 :            :             {
    1296         [ #  # ]:          0 :                 Application::Abort( String() );
    1297                 :            :             }
    1298                 :            : 
    1299                 :          0 :             break;
    1300                 :            :         }
    1301                 :            :     }
    1302                 :            : 
    1303                 :            :     OSL_ASSERT(false); // unreachable
    1304                 :          0 :     return 0;
    1305                 :            : }
    1306                 :            : 
    1307                 :          0 : void Desktop::AppEvent( const ApplicationEvent& rAppEvent )
    1308                 :            : {
    1309                 :          0 :     HandleAppEvent( rAppEvent );
    1310                 :          0 : }
    1311                 :            : 
    1312                 :            : namespace {
    1313                 :          0 :     void SetDocumentExtendedStyle( const Reference< ::com::sun::star::awt::XWindow > &xContainerWindow )
    1314                 :            :     {
    1315                 :            :         // set the WB_EXT_DOCUMENT style. Normally, this is done by the TaskCreator service when a "_blank"
    1316                 :            :         // frame/window is created. Since we do not use the TaskCreator here, we need to mimic its behavior,
    1317                 :            :         // otherwise documents loaded into this frame will later on miss functionality depending on the style.
    1318                 :          0 :         Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
    1319                 :            :         OSL_ENSURE( pContainerWindow, "Desktop::Main: no implementation access to the frame's container window!" );
    1320         [ #  # ]:          0 :         if (!pContainerWindow) {
    1321                 :            :             fprintf (stderr, "Error: It very much looks as if you have used 'linkoo' (or bin/ooinstall -l)\n"
    1322                 :            :                      "but have then forgotten to source 'ooenv' into your shell before running !\n"
    1323                 :          0 :                      "to save a crash, we will exit now with an error - please '. ./ooenv' first.\n");
    1324                 :          0 :             exit (1);
    1325                 :            :         }
    1326                 :          0 :         pContainerWindow->SetExtendedStyle( pContainerWindow->GetExtendedStyle() | WB_EXT_DOCUMENT );
    1327                 :          0 :     }
    1328                 :            : }
    1329                 :            : 
    1330 [ +  - ][ +  - ]:        158 : struct ExecuteGlobals
    1331                 :            : {
    1332                 :            :     Reference < css::document::XEventListener > xGlobalBroadcaster;
    1333                 :            :     sal_Bool bRestartRequested;
    1334                 :            :     sal_Bool bUseSystemFileDialog;
    1335                 :            :     std::auto_ptr<SvtLanguageOptions> pLanguageOptions;
    1336                 :            :     std::auto_ptr<SvtPathOptions> pPathOptions;
    1337                 :            : 
    1338                 :        158 :     ExecuteGlobals()
    1339                 :            :     : bRestartRequested( sal_False )
    1340                 :        158 :     , bUseSystemFileDialog( sal_True )
    1341                 :        158 :     {}
    1342                 :            : };
    1343                 :            : 
    1344                 :            : static ExecuteGlobals* pExecGlobals = NULL;
    1345                 :            : 
    1346                 :        158 : int Desktop::Main()
    1347                 :            : {
    1348 [ +  - ][ +  - ]:        158 :     pExecGlobals = new ExecuteGlobals();
    1349                 :            : 
    1350                 :            :     RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::Main" );
    1351                 :            : 
    1352                 :            :     // Remember current context object
    1353                 :            :     com::sun::star::uno::ContextLayer layer(
    1354 [ +  - ][ +  - ]:        158 :         com::sun::star::uno::getCurrentContext() );
    1355                 :            : 
    1356                 :        158 :     BootstrapError eError = GetBootstrapError();
    1357         [ -  + ]:        158 :     if ( eError != BE_OK )
    1358                 :            :     {
    1359         [ #  # ]:          0 :         HandleBootstrapErrors( eError );
    1360                 :          0 :         return EXIT_FAILURE;
    1361                 :            :     }
    1362                 :            : 
    1363                 :        158 :     BootstrapStatus eStatus = GetBootstrapStatus();
    1364         [ -  + ]:        158 :     if (eStatus == BS_TERMINATE) {
    1365                 :          0 :         return EXIT_FAILURE;
    1366                 :            :     }
    1367                 :            : 
    1368                 :            :     // Detect desktop environment - need to do this as early as possible
    1369                 :            :     com::sun::star::uno::setCurrentContext(
    1370 [ +  - ][ +  - ]:        158 :         new DesktopContext( com::sun::star::uno::getCurrentContext() ) );
         [ +  - ][ +  - ]
                 [ +  - ]
    1371                 :            : 
    1372         [ +  - ]:        158 :     CommandLineArgs& rCmdLineArgs = GetCommandLineArgs();
    1373                 :            : 
    1374                 :            :     // setup configuration error handling
    1375         [ +  - ]:        158 :     ConfigurationErrorHandler aConfigErrHandler;
    1376 [ +  - ][ -  + ]:        158 :     if (!ShouldSuppressUI(rCmdLineArgs))
    1377         [ #  # ]:          0 :         aConfigErrHandler.activate();
    1378                 :            : 
    1379         [ +  - ]:        158 :     ResMgr::SetReadStringHook( ReplaceStringHookProc );
    1380                 :            : 
    1381                 :            :     // Startup screen
    1382                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109) Desktop::Main { OpenSplashScreen" );
    1383         [ +  - ]:        158 :     OpenSplashScreen();
    1384                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109) Desktop::Main } OpenSplashScreen" );
    1385                 :            : 
    1386         [ +  - ]:        158 :     SetSplashScreenProgress(10);
    1387                 :            : 
    1388         [ +  - ]:        158 :     UserInstall::UserInstallStatus inst_fin = UserInstall::finalize();
    1389 [ +  + ][ -  + ]:        158 :     if (inst_fin != UserInstall::Ok && inst_fin != UserInstall::Created)
    1390                 :            :     {
    1391                 :            :         OSL_FAIL("userinstall failed");
    1392         [ #  # ]:          0 :         if ( inst_fin == UserInstall::E_NoDiskSpace )
    1393         [ #  # ]:          0 :             HandleBootstrapErrors( BE_USERINSTALL_NOTENOUGHDISKSPACE );
    1394         [ #  # ]:          0 :         else if ( inst_fin == UserInstall::E_NoWriteAccess )
    1395         [ #  # ]:          0 :             HandleBootstrapErrors( BE_USERINSTALL_NOWRITEACCESS );
    1396                 :            :         else
    1397         [ #  # ]:          0 :             HandleBootstrapErrors( BE_USERINSTALL_FAILED );
    1398                 :          0 :         return EXIT_FAILURE;
    1399                 :            :     }
    1400                 :            :     // refresh path information
    1401         [ +  - ]:        158 :     utl::Bootstrap::reloadData();
    1402         [ +  - ]:        158 :     SetSplashScreenProgress(20);
    1403                 :            : 
    1404                 :            :     Reference< XMultiServiceFactory > xSMgr =
    1405         [ +  - ]:        158 :         ::comphelper::getProcessServiceFactory();
    1406                 :            : 
    1407                 :        158 :     Reference< XDesktop > xDesktop;
    1408                 :        158 :     Reference< ::com::sun::star::task::XRestartManager > xRestartManager;
    1409                 :            :     try
    1410                 :            :     {
    1411         [ +  - ]:        158 :         RegisterServices();
    1412                 :            : 
    1413         [ +  - ]:        158 :         SetSplashScreenProgress(25);
    1414                 :            : 
    1415                 :            : #ifndef UNX
    1416                 :            :         if ( rCmdLineArgs.IsHelp() )
    1417                 :            :         {
    1418                 :            :             displayCmdlineHelp();
    1419                 :            :             return EXIT_SUCCESS;
    1420                 :            :         }
    1421                 :            : #endif
    1422                 :            : 
    1423                 :            :         // check user installation directory for lockfile so we can be sure
    1424                 :            :         // there is no other instance using our data files from a remote host
    1425                 :            :         RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109) Desktop::Main -> Lockfile" );
    1426 [ +  - ][ +  - ]:        158 :         m_pLockfile.reset( new Lockfile );
    1427                 :            : #ifndef ANDROID
    1428 [ -  + ][ #  # ]:        158 :         if ( !rCmdLineArgs.IsHeadless() && !rCmdLineArgs.IsInvisible() &&
         [ #  # ][ #  # ]
         [ #  # ][ -  + ]
                 [ +  - ]
    1429 [ #  # ][ #  # ]:          0 :              !rCmdLineArgs.IsNoLockcheck() && !m_pLockfile->check( Lockfile_execWarning ))
    1430                 :            :         {
    1431                 :            :             // Lockfile exists, and user clicked 'no'
    1432                 :          0 :             return EXIT_FAILURE;
    1433                 :            :         }
    1434                 :            :         RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109) Desktop::Main <- Lockfile" );
    1435                 :            : 
    1436                 :            :         // check if accessibility is enabled but not working and allow to quit
    1437                 :            :         RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ GetEnableATToolSupport" );
    1438 [ +  - ][ +  - ]:        158 :         if( Application::GetSettings().GetMiscSettings().GetEnableATToolSupport() )
                 [ -  + ]
    1439                 :            :         {
    1440                 :            :             sal_Bool bQuitApp;
    1441                 :            : 
    1442 [ #  # ][ #  # ]:          0 :             if( !InitAccessBridge( true, bQuitApp ) )
    1443         [ #  # ]:          0 :                 if( bQuitApp )
    1444                 :          0 :                     return EXIT_FAILURE;
    1445                 :            :         }
    1446                 :            :         RTL_LOGFILE_CONTEXT_TRACE( aLog, "} GetEnableATToolSupport" );
    1447                 :            : #endif
    1448                 :            : 
    1449                 :            :         // terminate if requested...
    1450 [ +  - ][ -  + ]:        158 :         if( rCmdLineArgs.IsTerminateAfterInit() )
    1451                 :          0 :             return EXIT_SUCCESS;
    1452                 :            : 
    1453                 :            :         //  Read the common configuration items for optimization purpose
    1454 [ +  - ][ -  + ]:        158 :         if ( !InitializeConfiguration() )
    1455                 :          0 :             return EXIT_FAILURE;
    1456                 :            : 
    1457         [ +  - ]:        158 :         SetSplashScreenProgress(30);
    1458                 :            : 
    1459                 :            :         // set static variable to enabled/disable crash reporter
    1460         [ +  - ]:        158 :         retrieveCrashReporterState();
    1461         [ +  - ]:        158 :         if ( !isCrashReporterEnabled() )
    1462                 :            :         {
    1463         [ +  - ]:        158 :             osl_setErrorReporting( sal_False );
    1464                 :            :             // disable stack trace feature
    1465                 :            :         }
    1466                 :            : 
    1467                 :            :         // create title string
    1468                 :        158 :         ::com::sun::star::lang::Locale aLocale;
    1469         [ +  - ]:        158 :         ResMgr* pLabelResMgr = ResMgr::SearchCreateResMgr( "ofa", aLocale );
    1470 [ +  - ][ +  - ]:        158 :         String aTitle = pLabelResMgr ? String( ResId( RID_APPTITLE, *pLabelResMgr ) ) : String();
         [ #  # ][ +  - ]
                 [ #  # ]
    1471 [ +  - ][ +  - ]:        158 :         delete pLabelResMgr;
    1472                 :            : 
    1473                 :            : #ifdef DBG_UTIL
    1474                 :            :         //include version ID in non product builds
    1475                 :            :         ::rtl::OUString aDefault("development");
    1476                 :            :         aTitle += rtl::OUString(" [");
    1477                 :            :         String aVerId( utl::Bootstrap::getProductSource(aDefault));
    1478                 :            :         aTitle += aVerId;
    1479                 :            :         aTitle += ']';
    1480                 :            : #endif
    1481                 :            : 
    1482         [ +  - ]:        158 :         SetDisplayName( aTitle );
    1483         [ +  - ]:        158 :         SetSplashScreenProgress(35);
    1484                 :            :         RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create SvtPathOptions and SvtLanguageOptions" );
    1485 [ +  - ][ +  - ]:        158 :         pExecGlobals->pPathOptions.reset( new SvtPathOptions);
    1486         [ +  - ]:        158 :         SetSplashScreenProgress(40);
    1487                 :            :         RTL_LOGFILE_CONTEXT_TRACE( aLog, "} create SvtPathOptions and SvtLanguageOptions" );
    1488                 :            : 
    1489                 :            :         // Check special env variable
    1490         [ +  - ]:        158 :         std::vector< String > aUnrestrictedFolders;
    1491         [ +  - ]:        158 :         svt::getUnrestrictedFolders( aUnrestrictedFolders );
    1492                 :            : 
    1493         [ -  + ]:        158 :         if ( !aUnrestrictedFolders.empty() )
    1494                 :            :         {
    1495                 :            :             // Set different working directory. The first entry is
    1496                 :            :             // the new work path.
    1497 [ #  # ][ #  # ]:          0 :             String aWorkPath = aUnrestrictedFolders[0];
    1498 [ #  # ][ #  # ]:          0 :             SvtPathOptions().SetWorkPath( aWorkPath );
         [ #  # ][ #  # ]
    1499                 :            :         }
    1500                 :            : 
    1501         [ +  - ]:        158 :         xDesktop = Reference<XDesktop>( xSMgr->createInstance(
    1502 [ +  - ][ +  - ]:        158 :             OUString( "com.sun.star.frame.Desktop" )), UNO_QUERY );
                 [ +  - ]
    1503                 :            : 
    1504                 :            :         // create service for loadin SFX (still needed in startup)
    1505                 :            :         pExecGlobals->xGlobalBroadcaster = Reference < css::document::XEventListener >
    1506         [ +  - ]:        158 :             ( xSMgr->createInstance(
    1507 [ +  - ][ +  - ]:        158 :             rtl::OUString( "com.sun.star.frame.GlobalEventBroadcaster" ) ), UNO_QUERY );
                 [ +  - ]
    1508                 :            : 
    1509                 :            :         /* ensure existance of a default window that messages can be dispatched to
    1510                 :            :            This is for the benefit of testtool which uses PostUserEvent extensively
    1511                 :            :            and else can deadlock while creating this window from another tread while
    1512                 :            :            the main thread is not yet in the event loop.
    1513                 :            :         */
    1514         [ +  - ]:        158 :         Application::GetDefaultDevice();
    1515                 :            : 
    1516                 :            : #ifndef ANDROID
    1517                 :            :         // Check if bundled or shared extensions were added /removed
    1518                 :            :         // and process those extensions (has to be done before checking
    1519                 :            :         // the extension dependencies!
    1520         [ +  - ]:        158 :         SynchronizeExtensionRepositories();
    1521         [ +  - ]:        158 :         bool bAbort = CheckExtensionDependencies();
    1522         [ -  + ]:        158 :         if ( bAbort )
    1523                 :          0 :             return EXIT_FAILURE;
    1524                 :            : 
    1525                 :            :         {
    1526         [ +  - ]:        158 :             ::comphelper::ComponentContext aContext( xSMgr );
    1527 [ +  - ][ +  - ]:        158 :             xRestartManager.set( aContext.getSingleton( ::rtl::OUString( "com.sun.star.task.OfficeRestartManager"  ) ), UNO_QUERY );
                 [ +  - ]
    1528                 :            :         }
    1529                 :            : 
    1530                 :            :         // check whether the shutdown is caused by restart
    1531 [ +  - ][ +  - ]:        158 :         pExecGlobals->bRestartRequested = ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) );
         [ +  - ][ +  + ]
    1532                 :            : 
    1533         [ +  + ]:        158 :         if (inst_fin == UserInstall::Created)
    1534                 :            :         {
    1535         [ +  - ]:         62 :             Migration::migrateSettingsIfNecessary();
    1536                 :            :         }
    1537                 :            : #endif
    1538                 :            : 
    1539                 :            :         // keep a language options instance...
    1540 [ +  - ][ +  - ]:        158 :         pExecGlobals->pLanguageOptions.reset( new SvtLanguageOptions(sal_True));
    1541                 :            : 
    1542         [ +  - ]:        158 :         if (pExecGlobals->xGlobalBroadcaster.is())
    1543                 :            :         {
    1544         [ +  - ]:        158 :             css::document::EventObject aEvent;
    1545                 :        158 :             aEvent.EventName = ::rtl::OUString("OnStartApp");
    1546 [ +  - ][ +  - ]:        158 :             pExecGlobals->xGlobalBroadcaster->notifyEvent(aEvent);
                 [ +  - ]
    1547                 :            :         }
    1548                 :            : 
    1549         [ +  - ]:        158 :         SetSplashScreenProgress(50);
    1550                 :            : 
    1551                 :            :         // Backing Component
    1552                 :        158 :         sal_Bool bCrashed            = sal_False;
    1553                 :        158 :         sal_Bool bExistsRecoveryData = sal_False;
    1554                 :        158 :         sal_Bool bExistsSessionData  = sal_False;
    1555                 :            : 
    1556                 :            :         RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ impl_checkRecoveryState" );
    1557         [ +  - ]:        158 :         impl_checkRecoveryState(bCrashed, bExistsRecoveryData, bExistsSessionData);
    1558                 :            :         RTL_LOGFILE_CONTEXT_TRACE( aLog, "} impl_checkRecoveryState" );
    1559                 :            : 
    1560                 :            :         {
    1561         [ +  - ]:        158 :             ::comphelper::ComponentContext aContext( xSMgr );
    1562 [ +  - ][ +  - ]:        158 :             xRestartManager.set( aContext.getSingleton( ::rtl::OUString( "com.sun.star.task.OfficeRestartManager"  ) ), UNO_QUERY );
                 [ +  - ]
    1563                 :            :         }
    1564                 :            : 
    1565                 :            :         // check whether the shutdown is caused by restart
    1566 [ +  - ][ +  - ]:        158 :         pExecGlobals->bRestartRequested = ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) );
         [ +  - ][ +  + ]
    1567                 :            : 
    1568 [ +  - ][ +  - ]:        158 :         if ( rCmdLineArgs.IsHeadless() )
    1569                 :            :         {
    1570                 :            :             // Ensure that we use not the system file dialogs as
    1571                 :            :             // headless mode relies on Application::EnableHeadlessMode()
    1572                 :            :             // which does only work for VCL dialogs!!
    1573         [ +  - ]:        158 :             SvtMiscOptions aMiscOptions;
    1574         [ +  - ]:        158 :             pExecGlobals->bUseSystemFileDialog = aMiscOptions.UseSystemFileDialog();
    1575 [ +  - ][ +  - ]:        158 :             aMiscOptions.SetUseSystemFileDialog( sal_False );
    1576                 :            :         }
    1577                 :            : 
    1578         [ +  + ]:        158 :         if ( !pExecGlobals->bRestartRequested )
    1579                 :            :         {
    1580 [ +  - ][ +  - ]:        192 :             if ((!rCmdLineArgs.WantsToLoadDocument() && !rCmdLineArgs.IsInvisible() && !rCmdLineArgs.IsHeadless() && !rCmdLineArgs.IsQuickstart()) &&
         [ +  - ][ -  + ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ -  + ]
    1581 [ #  # ][ #  # ]:         96 :                 (SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SSTARTMODULE)) &&
         [ -  + ][ #  # ]
                 [ #  # ]
    1582                 :          0 :                 (!bExistsRecoveryData                                                  ) &&
    1583                 :          0 :                 (!bExistsSessionData                                                   ) &&
    1584         [ #  # ]:          0 :                 (!Application::AnyInput( VCL_INPUT_APPEVENT )                          ))
    1585                 :            :             {
    1586                 :            :                  RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create BackingComponent" );
    1587         [ #  # ]:        158 :                  ShowBackingComponent(this);
    1588                 :            :                  RTL_LOGFILE_CONTEXT_TRACE( aLog, "} create BackingComponent" );
    1589                 :            :             }
    1590 [ -  + ][ +  - ]:        158 :         }
         [ -  + ][ +  - ]
    1591                 :            :     }
    1592         [ #  # ]:          0 :     catch ( const com::sun::star::lang::WrappedTargetException& wte )
    1593                 :            :     {
    1594         [ #  # ]:          0 :         com::sun::star::uno::Exception te;
    1595         [ #  # ]:          0 :         wte.TargetException >>= te;
    1596   [ #  #  #  # ]:          0 :         FatalError( MakeStartupConfigAccessErrorMessage(wte.Message + te.Message) );
    1597         [ #  # ]:          0 :         return EXIT_FAILURE;
    1598                 :            :     }
    1599   [ #  #  #  #  :          0 :     catch ( const com::sun::star::uno::Exception& e )
                      # ]
    1600                 :            :     {
    1601   [ #  #  #  # ]:          0 :         FatalError( MakeStartupErrorMessage(e.Message) );
    1602                 :          0 :         return EXIT_FAILURE;
    1603                 :            :     }
    1604         [ +  - ]:        158 :     SetSplashScreenProgress(55);
    1605                 :            : 
    1606 [ +  - ][ +  - ]:        158 :     SvtFontSubstConfig().Apply();
                 [ +  - ]
    1607                 :            : 
    1608         [ +  - ]:        158 :     SvtTabAppearanceCfg aAppearanceCfg;
    1609                 :        158 :     aAppearanceCfg.SetInitialized();
    1610         [ +  - ]:        158 :     aAppearanceCfg.SetApplicationDefaults( this );
    1611         [ +  - ]:        158 :     SvtAccessibilityOptions aOptions;
    1612         [ +  - ]:        158 :     aOptions.SetVCLSettings();
    1613         [ +  - ]:        158 :     SetSplashScreenProgress(60);
    1614                 :            : 
    1615                 :            : #ifdef ENABLE_TELEPATHY
    1616                 :            :     bool bListen = rCmdLineArgs.IsInvisible();
    1617                 :            :     TeleManager::init( bListen );
    1618                 :            : #endif
    1619                 :            : 
    1620         [ +  + ]:        158 :     if ( !pExecGlobals->bRestartRequested )
    1621                 :            :     {
    1622 [ +  - ][ +  - ]:         96 :         Application::SetFilterHdl( LINK( this, Desktop, ImplInitFilterHdl ) );
    1623                 :         96 :         sal_Bool bTerminateRequested = sal_False;
    1624                 :            : 
    1625                 :            :         // Preload function depends on an initialized sfx application!
    1626         [ +  - ]:         96 :         SetSplashScreenProgress(75);
    1627                 :            : 
    1628                 :            :         // use system window dialogs
    1629         [ +  - ]:         96 :         Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_DIALOG );
    1630                 :            : 
    1631         [ +  - ]:         96 :         SetSplashScreenProgress(80);
    1632                 :            : 
    1633 [ +  - ][ +  - ]:         96 :         if ( !bTerminateRequested && !rCmdLineArgs.IsInvisible() &&
         [ -  + ][ #  # ]
                 [ -  + ]
    1634         [ #  # ]:          0 :              !rCmdLineArgs.IsNoQuickstart() )
    1635         [ #  # ]:          0 :             InitializeQuickstartMode( xSMgr );
    1636                 :            : 
    1637                 :            :         RTL_LOGFILE_CONTEXT( aLog2, "desktop (cd100003) createInstance com.sun.star.frame.Desktop" );
    1638                 :            :         try
    1639                 :            :         {
    1640         [ +  - ]:         96 :             if ( xDesktop.is() )
    1641 [ +  - ][ +  - ]:         96 :                 xDesktop->addTerminateListener( new OfficeIPCThreadController );
         [ +  - ][ +  - ]
                 [ +  - ]
    1642         [ +  - ]:         96 :             SetSplashScreenProgress(100);
    1643                 :            :         }
    1644   [ #  #  #  # ]:          0 :         catch ( const com::sun::star::uno::Exception& e )
    1645                 :            :         {
    1646   [ #  #  #  # ]:          0 :             FatalError( MakeStartupErrorMessage(e.Message) );
    1647                 :          0 :             return EXIT_FAILURE;
    1648                 :            :         }
    1649                 :            : 
    1650                 :            :         // Release solar mutex just before we wait for our client to connect
    1651         [ +  - ]:         96 :         int nAcquireCount = Application::ReleaseSolarMutex();
    1652                 :            : 
    1653                 :            :         // Post user event to startup first application component window
    1654                 :            :         // We have to send this OpenClients message short before execute() to
    1655                 :            :         // minimize the risk that this message overtakes type detection contruction!!
    1656 [ +  - ][ +  - ]:         96 :         Application::PostUserEvent( LINK( this, Desktop, OpenClients_Impl ) );
    1657                 :            : 
    1658                 :            :         // Post event to enable acceptors
    1659 [ +  - ][ +  - ]:         96 :         Application::PostUserEvent( LINK( this, Desktop, EnableAcceptors_Impl) );
    1660                 :            : 
    1661                 :            :         // The configuration error handler currently is only for startup
    1662         [ +  - ]:         96 :         aConfigErrHandler.deactivate();
    1663                 :            : 
    1664                 :            :        // Acquire solar mutex just before we enter our message loop
    1665         [ +  - ]:         96 :         if ( nAcquireCount )
    1666         [ +  - ]:         96 :             Application::AcquireSolarMutex( nAcquireCount );
    1667                 :            : 
    1668                 :            :         // call Application::Execute to process messages in vcl message loop
    1669         [ +  - ]:         96 :         RTL_LOGFILE_PRODUCT_TRACE( "PERFORMANCE - enter Application::Execute()" );
    1670                 :            : 
    1671                 :            :         try
    1672                 :            :         {
    1673                 :            :             // The JavaContext contains an interaction handler which is used when
    1674                 :            :             // the creation of a Java Virtual Machine fails
    1675                 :            :             com::sun::star::uno::ContextLayer layer2(
    1676 [ +  - ][ +  - ]:         96 :                 new svt::JavaContext( com::sun::star::uno::getCurrentContext() ) );
         [ +  - ][ +  - ]
                 [ +  - ]
    1677                 :            : 
    1678                 :            :             // check whether the shutdown is caused by restart just before entering the Execute
    1679 [ +  - ][ +  - ]:         96 :             pExecGlobals->bRestartRequested = pExecGlobals->bRestartRequested || ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) );
         [ +  - ][ -  + ]
                 [ +  - ]
    1680                 :            : 
    1681         [ +  - ]:         96 :             if ( !pExecGlobals->bRestartRequested )
    1682                 :            :             {
    1683                 :            :                 // if this run of the office is triggered by restart, some additional actions should be done
    1684 [ +  - ][ -  + ]:         96 :                 DoRestartActionsIfNecessary( !rCmdLineArgs.IsInvisible() && !rCmdLineArgs.IsNoQuickstart() );
         [ #  # ][ #  # ]
                 [ +  - ]
    1685                 :            : 
    1686         [ +  - ]:         96 :                 Execute();
    1687         [ +  - ]:         96 :             }
    1688                 :            :         }
    1689         [ #  # ]:          0 :         catch(const com::sun::star::document::CorruptedFilterConfigurationException& exFilterCfg)
    1690                 :            :         {
    1691         [ #  # ]:          0 :             OfficeIPCThread::SetDowning();
    1692   [ #  #  #  # ]:          0 :             FatalError( MakeStartupErrorMessage(exFilterCfg.Message) );
    1693                 :            :         }
    1694   [ #  #  #  #  :          0 :         catch(const com::sun::star::configuration::CorruptedConfigurationException& exAnyCfg)
                      # ]
    1695                 :            :         {
    1696         [ #  # ]:          0 :             OfficeIPCThread::SetDowning();
    1697   [ #  #  #  # ]:          0 :             FatalError( MakeStartupErrorMessage(exAnyCfg.Message) );
    1698                 :            :         }
    1699                 :            :     }
    1700                 :            :     else
    1701                 :            :     {
    1702         [ +  - ]:         62 :         if (xDesktop.is())
    1703 [ +  - ][ +  - ]:         62 :             xDesktop->terminate();
    1704                 :            :     }
    1705                 :            :     // CAUTION: you do not necessarily get here e.g. on the Mac.
    1706                 :            :     // please put all deinitialization code into doShutdown
    1707 [ +  - ][ +  - ]:        158 :     return doShutdown();
         [ +  - ][ +  - ]
                 [ +  - ]
    1708                 :            : }
    1709                 :            : 
    1710                 :        158 : int Desktop::doShutdown()
    1711                 :            : {
    1712         [ -  + ]:        158 :     if( ! pExecGlobals )
    1713                 :          0 :         return EXIT_SUCCESS;
    1714                 :            : 
    1715         [ +  + ]:        158 :     if ( pExecGlobals->bRestartRequested )
    1716                 :         62 :         SetRestartState();
    1717                 :            : 
    1718         [ +  - ]:        158 :     if (pExecGlobals->xGlobalBroadcaster.is())
    1719                 :            :     {
    1720         [ +  - ]:        158 :         css::document::EventObject aEvent;
    1721                 :        158 :         aEvent.EventName = ::rtl::OUString("OnCloseApp");
    1722 [ +  - ][ +  - ]:        158 :         pExecGlobals->xGlobalBroadcaster->notifyEvent(aEvent);
                 [ +  - ]
    1723                 :            :     }
    1724                 :            : 
    1725         [ -  + ]:        158 :     delete pResMgr, pResMgr = NULL;
    1726                 :            :     // Restore old value
    1727                 :        158 :     const CommandLineArgs& rCmdLineArgs = GetCommandLineArgs();
    1728         [ +  - ]:        158 :     if ( rCmdLineArgs.IsHeadless() )
    1729         [ +  - ]:        158 :         SvtMiscOptions().SetUseSystemFileDialog( pExecGlobals->bUseSystemFileDialog );
    1730                 :            : 
    1731                 :            :     // remove temp directory
    1732                 :        158 :     RemoveTemporaryDirectory();
    1733                 :        158 :     FlushConfiguration();
    1734                 :            :     // The acceptors in the AcceptorMap must be released (in DeregisterServices)
    1735                 :            :     // with the solar mutex unlocked, to avoid deadlock:
    1736                 :        158 :     sal_uLong nAcquireCount = Application::ReleaseSolarMutex();
    1737                 :        158 :     DeregisterServices();
    1738                 :        158 :     Application::AcquireSolarMutex(nAcquireCount);
    1739                 :            :     // be sure that path/language options gets destroyed before
    1740                 :            :     // UCB is deinitialized
    1741                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "-> dispose path/language options" );
    1742                 :        158 :     pExecGlobals->pLanguageOptions.reset( 0 );
    1743                 :        158 :     pExecGlobals->pPathOptions.reset( 0 );
    1744                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- dispose path/language options" );
    1745                 :            : 
    1746                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "-> deinit ucb" );
    1747                 :        158 :     ::ucbhelper::ContentBroker::deinitialize();
    1748                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- deinit ucb" );
    1749                 :            : 
    1750                 :        158 :     sal_Bool bRR = pExecGlobals->bRestartRequested;
    1751         [ +  - ]:        158 :     delete pExecGlobals, pExecGlobals = NULL;
    1752                 :            : 
    1753                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "FINISHED WITH Destop::Main" );
    1754         [ +  + ]:        158 :     if ( bRR )
    1755                 :            :     {
    1756                 :         62 :         restartOnMac(true);
    1757         [ -  + ]:         62 :         if ( m_rSplashScreen.is() )
    1758                 :          0 :             m_rSplashScreen->reset();
    1759                 :            : 
    1760                 :         62 :         return ExitHelper::E_NORMAL_RESTART;
    1761                 :            :     }
    1762                 :        158 :     return EXIT_SUCCESS;
    1763                 :            : }
    1764                 :            : 
    1765                 :         42 : IMPL_LINK( Desktop, ImplInitFilterHdl, ConvertData*, pData )
    1766                 :            : {
    1767         [ +  - ]:         42 :     return GraphicFilter::GetGraphicFilter().GetFilterCallback().Call( pData );
    1768                 :            : }
    1769                 :            : 
    1770                 :        158 : bool Desktop::InitializeConfiguration()
    1771                 :            : {
    1772                 :            :     RTL_LOGFILE_CONTEXT( aLog, "desktop (jb99855) ::InitConfiguration" );
    1773                 :            :     try
    1774                 :            :     {
    1775                 :            :         css::configuration::theDefaultProvider::get(
    1776 [ +  - ][ +  - ]:        158 :             comphelper::getProcessComponentContext() );
    1777                 :        158 :         return true;
    1778                 :            :     }
    1779                 :          0 :     catch( const ::com::sun::star::lang::ServiceNotRegisteredException& )
    1780                 :            :     {
    1781         [ #  # ]:          0 :         this->HandleBootstrapErrors( Desktop::BE_UNO_SERVICE_CONFIG_MISSING );
    1782                 :            :     }
    1783                 :          0 :     catch( const ::com::sun::star::configuration::MissingBootstrapFileException& e )
    1784                 :            :     {
    1785                 :            :         OUString aMsg( CreateErrorMsgString( utl::Bootstrap::MISSING_BOOTSTRAP_FILE,
    1786         [ #  # ]:          0 :                                                 e.BootstrapFileURL ));
    1787         [ #  # ]:          0 :         HandleBootstrapPathErrors( ::utl::Bootstrap::INVALID_USER_INSTALL, aMsg );
    1788                 :            :     }
    1789                 :          0 :     catch( const ::com::sun::star::configuration::InvalidBootstrapFileException& e )
    1790                 :            :     {
    1791                 :            :         OUString aMsg( CreateErrorMsgString( utl::Bootstrap::INVALID_BOOTSTRAP_FILE_ENTRY,
    1792         [ #  # ]:          0 :                                                 e.BootstrapFileURL ));
    1793         [ #  # ]:          0 :         HandleBootstrapPathErrors( ::utl::Bootstrap::INVALID_BASE_INSTALL, aMsg );
    1794                 :            :     }
    1795                 :          0 :     catch( const ::com::sun::star::configuration::InstallationIncompleteException& )
    1796                 :            :     {
    1797                 :          0 :         OUString aVersionFileURL;
    1798                 :          0 :         OUString aMsg;
    1799         [ #  # ]:          0 :         utl::Bootstrap::PathStatus aPathStatus = utl::Bootstrap::locateVersionFile( aVersionFileURL );
    1800         [ #  # ]:          0 :         if ( aPathStatus == utl::Bootstrap::PATH_EXISTS )
    1801         [ #  # ]:          0 :             aMsg = CreateErrorMsgString( utl::Bootstrap::MISSING_VERSION_FILE_ENTRY, aVersionFileURL );
    1802                 :            :         else
    1803         [ #  # ]:          0 :             aMsg = CreateErrorMsgString( utl::Bootstrap::MISSING_VERSION_FILE, aVersionFileURL );
    1804                 :            : 
    1805         [ #  # ]:          0 :         HandleBootstrapPathErrors( ::utl::Bootstrap::MISSING_USER_INSTALL, aMsg );
    1806                 :            :     }
    1807                 :          0 :     catch ( const com::sun::star::configuration::backend::BackendAccessException& exception)
    1808                 :            :     {
    1809                 :            :         // [cm122549] It is assumed in this case that the message
    1810                 :            :         // coming from InitConfiguration (in fact CreateApplicationConf...)
    1811                 :            :         // is suitable for display directly.
    1812   [ #  #  #  # ]:          0 :         FatalError( MakeStartupErrorMessage( exception.Message ) );
    1813                 :            :     }
    1814                 :          0 :     catch ( const com::sun::star::configuration::backend::BackendSetupException& exception)
    1815                 :            :     {
    1816                 :            :         // [cm122549] It is assumed in this case that the message
    1817                 :            :         // coming from InitConfiguration (in fact CreateApplicationConf...)
    1818                 :            :         // is suitable for display directly.
    1819   [ #  #  #  # ]:          0 :         FatalError( MakeStartupErrorMessage( exception.Message ) );
    1820                 :            :     }
    1821                 :          0 :     catch ( const ::com::sun::star::configuration::CannotLoadConfigurationException& )
    1822                 :            :     {
    1823                 :            :         OUString aMsg( CreateErrorMsgString( utl::Bootstrap::INVALID_BOOTSTRAP_DATA,
    1824         [ #  # ]:          0 :                                                 OUString() ));
    1825         [ #  # ]:          0 :         HandleBootstrapPathErrors( ::utl::Bootstrap::INVALID_BASE_INSTALL, aMsg );
    1826                 :            :     }
    1827   [ #  #  #  #  :          0 :     catch( const ::com::sun::star::uno::Exception& )
             #  #  #  #  
                      # ]
    1828                 :            :     {
    1829                 :            :         OUString aMsg( CreateErrorMsgString( utl::Bootstrap::INVALID_BOOTSTRAP_DATA,
    1830         [ #  # ]:          0 :                                                 OUString() ));
    1831         [ #  # ]:          0 :         HandleBootstrapPathErrors( ::utl::Bootstrap::INVALID_BASE_INSTALL, aMsg );
    1832                 :            :     }
    1833                 :        158 :     return false;
    1834                 :            : }
    1835                 :            : 
    1836                 :        316 : void Desktop::FlushConfiguration()
    1837                 :            : {
    1838                 :            :     css::uno::Reference< css::util::XFlushable >(
    1839                 :            :         css::configuration::theDefaultProvider::get(
    1840                 :            :             comphelper::getProcessComponentContext()),
    1841 [ +  - ][ +  - ]:        316 :         css::uno::UNO_QUERY_THROW)->flush();
         [ +  - ][ +  - ]
    1842                 :        316 : }
    1843                 :            : 
    1844                 :          0 : sal_Bool Desktop::shouldLaunchQuickstart()
    1845                 :            : {
    1846                 :          0 :     sal_Bool bQuickstart = GetCommandLineArgs().IsQuickstart();
    1847         [ #  # ]:          0 :     if (!bQuickstart)
    1848                 :            :     {
    1849                 :          0 :         const SfxPoolItem* pItem=0;
    1850 [ #  # ][ #  # ]:          0 :         SfxItemSet aQLSet(SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER);
    1851 [ #  # ][ #  # ]:          0 :         SFX_APP()->GetOptions(aQLSet);
    1852         [ #  # ]:          0 :         SfxItemState eState = aQLSet.GetItemState(SID_ATTR_QUICKLAUNCHER, sal_False, &pItem);
    1853         [ #  # ]:          0 :         if (SFX_ITEM_SET == eState)
    1854         [ #  # ]:          0 :             bQuickstart = ((SfxBoolItem*)pItem)->GetValue();
    1855                 :            :     }
    1856                 :          0 :     return bQuickstart;
    1857                 :            : }
    1858                 :            : 
    1859                 :            : 
    1860                 :          0 : sal_Bool Desktop::InitializeQuickstartMode( Reference< XMultiServiceFactory >& rSMgr )
    1861                 :            : {
    1862                 :            :     try
    1863                 :            :     {
    1864                 :            :         // the shutdown icon sits in the systray and allows the user to keep
    1865                 :            :         // the office instance running for quicker restart
    1866                 :            :         // this will only be activated if --quickstart was specified on cmdline
    1867                 :            :         RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) createInstance com.sun.star.office.Quickstart" );
    1868                 :            : 
    1869         [ #  # ]:          0 :         sal_Bool bQuickstart = shouldLaunchQuickstart();
    1870                 :            : 
    1871                 :            :         // Try to instanciate quickstart service. This service is not mandatory, so
    1872                 :            :         // do nothing if service is not available
    1873                 :            : 
    1874                 :            :         // #i105753# the following if was invented for performance
    1875                 :            :         // unfortunately this broke the QUARTZ behavior which is to always run
    1876                 :            :         // in quickstart mode since Mac applications do not usually quit
    1877                 :            :         // when the last document closes
    1878                 :            :         #ifndef QUARTZ
    1879         [ #  # ]:          0 :         if ( bQuickstart )
    1880                 :            :         #endif
    1881                 :            :         {
    1882         [ #  # ]:          0 :             Sequence< Any > aSeq( 1 );
    1883 [ #  # ][ #  # ]:          0 :             aSeq[0] <<= bQuickstart;
    1884         [ #  # ]:          0 :             Reference < XComponent > xQuickstart( rSMgr->createInstanceWithArguments(
    1885                 :          0 :                                                 rtl::OUString( "com.sun.star.office.Quickstart" ), aSeq ),
    1886 [ #  # ][ #  # ]:          0 :                                                 UNO_QUERY );
         [ #  # ][ #  # ]
    1887                 :            :         }
    1888                 :          0 :         return sal_True;
    1889                 :            :     }
    1890                 :          0 :     catch( const ::com::sun::star::uno::Exception& )
    1891                 :            :     {
    1892                 :          0 :         return sal_False;
    1893                 :            :     }
    1894                 :            : }
    1895                 :            : 
    1896                 :        316 : void Desktop::SystemSettingsChanging( AllSettings& rSettings, Window* )
    1897                 :            : {
    1898         [ +  - ]:        316 :     if ( !SvtTabAppearanceCfg::IsInitialized () )
    1899                 :        316 :         return;
    1900                 :            : 
    1901                 :            : #   define DRAGFULL_OPTION_ALL \
    1902                 :            :          ( DRAGFULL_OPTION_WINDOWMOVE | DRAGFULL_OPTION_WINDOWSIZE  \
    1903                 :            :          | DRAGFULL_OPTION_OBJECTMOVE  | DRAGFULL_OPTION_OBJECTSIZE \
    1904                 :            :          | DRAGFULL_OPTION_DOCKING     | DRAGFULL_OPTION_SPLIT      \
    1905                 :            :          | DRAGFULL_OPTION_SCROLL )
    1906                 :            : #   define DRAGFULL_OPTION_NONE ((sal_uInt32)~DRAGFULL_OPTION_ALL)
    1907                 :            : 
    1908         [ +  - ]:        316 :     StyleSettings hStyleSettings   = rSettings.GetStyleSettings();
    1909         [ +  - ]:        316 :     MouseSettings hMouseSettings = rSettings.GetMouseSettings();
    1910                 :            : 
    1911                 :        316 :     sal_uInt32 nDragFullOptions = hStyleSettings.GetDragFullOptions();
    1912                 :            : 
    1913         [ +  - ]:        316 :     SvtTabAppearanceCfg aAppearanceCfg;
    1914                 :        316 :     sal_uInt16 nGet = aAppearanceCfg.GetDragMode();
    1915      [ -  -  + ]:        316 :     switch ( nGet )
    1916                 :            :     {
    1917                 :            :     case DragFullWindow:
    1918                 :          0 :         nDragFullOptions |= DRAGFULL_OPTION_ALL;
    1919                 :          0 :         break;
    1920                 :            :     case DragFrame:
    1921                 :          0 :         nDragFullOptions &= DRAGFULL_OPTION_NONE;
    1922                 :          0 :         break;
    1923                 :            :     case DragSystemDep:
    1924                 :            :     default:
    1925                 :        316 :         break;
    1926                 :            :     }
    1927                 :            : 
    1928                 :        316 :     sal_uInt32 nFollow = hMouseSettings.GetFollow();
    1929 [ +  - ][ +  - ]:        316 :     hMouseSettings.SetFollow( aAppearanceCfg.IsMenuMouseFollow() ? (nFollow|MOUSE_FOLLOW_MENU) : (nFollow&~MOUSE_FOLLOW_MENU));
    1930         [ +  - ]:        316 :     rSettings.SetMouseSettings(hMouseSettings);
    1931                 :            : 
    1932         [ +  - ]:        316 :     SvtMenuOptions aMenuOpt;
    1933 [ +  - ][ +  - ]:        316 :     hStyleSettings.SetUseImagesInMenus(aMenuOpt.GetMenuIconsState());
    1934         [ +  - ]:        316 :     hStyleSettings.SetDragFullOptions( nDragFullOptions );
    1935 [ +  - ][ +  - ]:        316 :     rSettings.SetStyleSettings ( hStyleSettings );
         [ +  - ][ +  - ]
                 [ +  - ]
    1936                 :            : }
    1937                 :            : 
    1938                 :            : // ========================================================================
    1939                 :         52 : IMPL_LINK_NOARG(Desktop, AsyncInitFirstRun)
    1940                 :            : {
    1941                 :         52 :     DoFirstRunInitializations();
    1942                 :         52 :     return 0L;
    1943                 :            : }
    1944                 :            : 
    1945                 :            : // ========================================================================
    1946                 :            : 
    1947         [ #  # ]:          0 : class ExitTimer : public Timer
    1948                 :            : {
    1949                 :            :   public:
    1950                 :          0 :     ExitTimer()
    1951                 :          0 :     {
    1952         [ #  # ]:          0 :         SetTimeout(500);
    1953         [ #  # ]:          0 :         Start();
    1954                 :          0 :     }
    1955                 :          0 :     virtual void Timeout()
    1956                 :            :     {
    1957                 :          0 :         exit(42);
    1958                 :            :     }
    1959                 :            : };
    1960                 :            : 
    1961                 :         96 : IMPL_LINK_NOARG(Desktop, OpenClients_Impl)
    1962                 :            : {
    1963         [ +  - ]:         96 :     RTL_LOGFILE_PRODUCT_CONTEXT( aLog, "PERFORMANCE - DesktopOpenClients_Impl()" );
    1964                 :            : 
    1965                 :            :     try {
    1966         [ +  - ]:         96 :         OpenClients();
    1967                 :            : 
    1968 [ +  - ][ +  - ]:         96 :         OfficeIPCThread::SetReady();
    1969                 :            : 
    1970         [ +  - ]:         96 :         CloseSplashScreen();
    1971         [ +  - ]:         96 :         CheckFirstRun( );
    1972                 :         96 :         EnableOleAutomation();
    1973                 :            : 
    1974         [ -  + ]:         96 :         if (getenv ("OOO_EXIT_POST_STARTUP"))
    1975 [ #  # ][ #  # ]:          0 :             new ExitTimer();
    1976   [ #  #  #  # ]:          0 :     } catch (const ::com::sun::star::uno::Exception &e) {
    1977         [ #  # ]:          0 :         String a( "UNO exception during client open:\n"  );
    1978   [ #  #  #  #  :          0 :         Application::Abort( a + e.Message );
          #  #  #  #  #  
                      # ]
    1979                 :            :     }
    1980         [ +  - ]:         96 :     return 0;
    1981                 :            : }
    1982                 :            : 
    1983                 :            : // enable acceptos
    1984                 :         96 : IMPL_LINK_NOARG(Desktop, EnableAcceptors_Impl)
    1985                 :            : {
    1986                 :         96 :     enableAcceptors();
    1987                 :         96 :     return 0;
    1988                 :            : }
    1989                 :            : 
    1990                 :            : 
    1991                 :            : // Registers a COM class factory of the service manager with the windows operating system.
    1992                 :         96 : void Desktop::EnableOleAutomation()
    1993                 :            : {
    1994                 :            :       RTL_LOGFILE_CONTEXT( aLog, "desktop (jl97489) ::Desktop::EnableOleAutomation" );
    1995                 :            : #ifdef WNT
    1996                 :            :     Reference< XMultiServiceFactory > xSMgr=  comphelper::getProcessServiceFactory();
    1997                 :            :     xSMgr->createInstance(rtl::OUString("com.sun.star.bridge.OleApplicationRegistration"));
    1998                 :            :     xSMgr->createInstance(rtl::OUString("com.sun.star.comp.ole.EmbedServer"));
    1999                 :            : #endif
    2000                 :         96 : }
    2001                 :            : 
    2002                 :          0 : void Desktop::PreloadModuleData( const CommandLineArgs& rArgs )
    2003                 :            : {
    2004         [ #  # ]:          0 :     Reference< XMultiServiceFactory > rFactory = ::comphelper::getProcessServiceFactory();
    2005                 :            : 
    2006         [ #  # ]:          0 :     Sequence < com::sun::star::beans::PropertyValue > args(1);
    2007         [ #  # ]:          0 :     args[0].Name = ::rtl::OUString("Hidden");
    2008 [ #  # ][ #  # ]:          0 :     args[0].Value <<= sal_True;
    2009 [ #  # ][ #  # ]:          0 :     Reference < XComponentLoader > xLoader( ::comphelper::getProcessServiceFactory()->createInstance(
    2010 [ #  # ][ #  # ]:          0 :         ::rtl::OUString("com.sun.star.frame.Desktop") ), UNO_QUERY );
    2011                 :            : 
    2012         [ #  # ]:          0 :     if ( !xLoader.is() )
    2013                 :          0 :         return;
    2014                 :            : 
    2015 [ #  # ][ #  # ]:          0 :     if ( rArgs.IsWriter() )
    2016                 :            :     {
    2017                 :            :         try
    2018                 :            :         {
    2019         [ #  # ]:          0 :             Reference < ::com::sun::star::util::XCloseable > xDoc( xLoader->loadComponentFromURL( rtl::OUString("private:factory/swriter"),
    2020 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString("_blank"), 0, args ), UNO_QUERY_THROW );
    2021 [ #  # ][ #  # ]:          0 :             xDoc->close( sal_False );
                 [ #  # ]
    2022                 :            :         }
    2023         [ #  # ]:          0 :         catch ( const com::sun::star::uno::Exception& )
    2024                 :            :         {
    2025                 :            :         }
    2026                 :            :     }
    2027 [ #  # ][ #  # ]:          0 :     if ( rArgs.IsCalc() )
    2028                 :            :     {
    2029                 :            :         try
    2030                 :            :         {
    2031         [ #  # ]:          0 :             Reference < ::com::sun::star::util::XCloseable > xDoc( xLoader->loadComponentFromURL( rtl::OUString("private:factory/scalc"),
    2032 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString("_blank"), 0, args ), UNO_QUERY_THROW );
    2033 [ #  # ][ #  # ]:          0 :             xDoc->close( sal_False );
                 [ #  # ]
    2034                 :            :         }
    2035         [ #  # ]:          0 :         catch ( const com::sun::star::uno::Exception& )
    2036                 :            :         {
    2037                 :            :         }
    2038                 :            :     }
    2039 [ #  # ][ #  # ]:          0 :     if ( rArgs.IsDraw() )
    2040                 :            :     {
    2041                 :            :         try
    2042                 :            :         {
    2043         [ #  # ]:          0 :             Reference < ::com::sun::star::util::XCloseable > xDoc( xLoader->loadComponentFromURL( rtl::OUString("private:factory/sdraw"),
    2044 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString("_blank"), 0, args ), UNO_QUERY_THROW );
    2045 [ #  # ][ #  # ]:          0 :             xDoc->close( sal_False );
                 [ #  # ]
    2046                 :            :         }
    2047         [ #  # ]:          0 :         catch ( const com::sun::star::uno::Exception& )
    2048                 :            :         {
    2049                 :            :         }
    2050                 :            :     }
    2051 [ #  # ][ #  # ]:          0 :     if ( rArgs.IsImpress() )
    2052                 :            :     {
    2053                 :            :         try
    2054                 :            :         {
    2055         [ #  # ]:          0 :             Reference < ::com::sun::star::util::XCloseable > xDoc( xLoader->loadComponentFromURL( rtl::OUString("private:factory/simpress"),
    2056 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString("_blank"), 0, args ), UNO_QUERY_THROW );
    2057 [ #  # ][ #  # ]:          0 :             xDoc->close( sal_False );
                 [ #  # ]
    2058                 :            :         }
    2059         [ #  # ]:          0 :         catch ( const com::sun::star::uno::Exception& )
    2060                 :            :         {
    2061                 :            :         }
    2062 [ #  # ][ #  # ]:          0 :     }
         [ #  # ][ #  # ]
    2063                 :            : }
    2064                 :            : 
    2065                 :          0 : void Desktop::PreloadConfigurationData()
    2066                 :            : {
    2067         [ #  # ]:          0 :     Reference< XMultiServiceFactory > rFactory = ::comphelper::getProcessServiceFactory();
    2068         [ #  # ]:          0 :     Reference< XNameAccess > xNameAccess( rFactory->createInstance(
    2069 [ #  # ][ #  # ]:          0 :         rtl::OUString( "com.sun.star.frame.UICommandDescription" )), UNO_QUERY );
    2070                 :            : 
    2071                 :          0 :     rtl::OUString aWriterDoc( "com.sun.star.text.TextDocument" );
    2072                 :          0 :     rtl::OUString aCalcDoc( "com.sun.star.sheet.SpreadsheetDocument" );
    2073                 :          0 :     rtl::OUString aDrawDoc( "com.sun.star.drawing.DrawingDocument" );
    2074                 :          0 :     rtl::OUString aImpressDoc( "com.sun.star.presentation.PresentationDocument" );
    2075                 :            : 
    2076                 :            :     // preload commands configuration
    2077         [ #  # ]:          0 :     if ( xNameAccess.is() )
    2078                 :            :     {
    2079                 :          0 :         Any a;
    2080                 :          0 :         Reference< XNameAccess > xCmdAccess;
    2081                 :            : 
    2082                 :            :         try
    2083                 :            :         {
    2084 [ #  # ][ #  # ]:          0 :             a = xNameAccess->getByName( aWriterDoc );
    2085         [ #  # ]:          0 :             a >>= xCmdAccess;
    2086         [ #  # ]:          0 :             if ( xCmdAccess.is() )
    2087                 :            :             {
    2088 [ #  # ][ #  # ]:          0 :                 xCmdAccess->getByName( rtl::OUString( ".uno:BasicShapes" ));
    2089 [ #  # ][ #  # ]:          0 :                 xCmdAccess->getByName( rtl::OUString( ".uno:EditGlossary" ));
                 [ #  # ]
    2090                 :            :             }
    2091                 :            :         }
    2092         [ #  # ]:          0 :         catch ( const ::com::sun::star::uno::Exception& )
    2093                 :            :         {
    2094                 :            :         }
    2095                 :            : 
    2096                 :            :         try
    2097                 :            :         {
    2098 [ #  # ][ #  # ]:          0 :             a = xNameAccess->getByName( aCalcDoc );
    2099         [ #  # ]:          0 :             a >>= xCmdAccess;
    2100         [ #  # ]:          0 :             if ( xCmdAccess.is() )
    2101 [ #  # ][ #  # ]:          0 :                 xCmdAccess->getByName( rtl::OUString( ".uno:InsertObjectStarMath" ));
                 [ #  # ]
    2102                 :            :         }
    2103         [ #  # ]:          0 :         catch ( const ::com::sun::star::uno::Exception& )
    2104                 :            :         {
    2105                 :            :         }
    2106                 :            : 
    2107                 :            :         try
    2108                 :            :         {
    2109                 :            :             // draw and impress share the same configuration file (DrawImpressCommands.xcu)
    2110 [ #  # ][ #  # ]:          0 :             a = xNameAccess->getByName( aDrawDoc );
    2111         [ #  # ]:          0 :             a >>= xCmdAccess;
    2112         [ #  # ]:          0 :             if ( xCmdAccess.is() )
    2113 [ #  # ][ #  # ]:          0 :                 xCmdAccess->getByName( rtl::OUString( ".uno:Polygon" ));
                 [ #  # ]
    2114                 :            :         }
    2115         [ #  # ]:          0 :         catch ( const ::com::sun::star::uno::Exception& )
    2116                 :            :         {
    2117                 :          0 :         }
    2118                 :            :     }
    2119                 :            : 
    2120                 :            :     // preload window state configuration
    2121         [ #  # ]:          0 :     xNameAccess = Reference< XNameAccess >( rFactory->createInstance(
    2122 [ #  # ][ #  # ]:          0 :                     rtl::OUString( "com.sun.star.ui.WindowStateConfiguration" )), UNO_QUERY );
                 [ #  # ]
    2123         [ #  # ]:          0 :     if ( xNameAccess.is() )
    2124                 :            :     {
    2125                 :          0 :         Any a;
    2126                 :          0 :         Reference< XNameAccess > xWindowAccess;
    2127                 :            :         try
    2128                 :            :         {
    2129 [ #  # ][ #  # ]:          0 :             a = xNameAccess->getByName( aWriterDoc );
    2130         [ #  # ]:          0 :             a >>= xWindowAccess;
    2131         [ #  # ]:          0 :             if ( xWindowAccess.is() )
    2132 [ #  # ][ #  # ]:          0 :                 xWindowAccess->getByName( rtl::OUString( "private:resource/toolbar/standardbar" ));
                 [ #  # ]
    2133                 :            :         }
    2134         [ #  # ]:          0 :         catch ( const ::com::sun::star::uno::Exception& )
    2135                 :            :         {
    2136                 :            :         }
    2137                 :            :         try
    2138                 :            :         {
    2139 [ #  # ][ #  # ]:          0 :             a = xNameAccess->getByName( aCalcDoc );
    2140         [ #  # ]:          0 :             a >>= xWindowAccess;
    2141         [ #  # ]:          0 :             if ( xWindowAccess.is() )
    2142 [ #  # ][ #  # ]:          0 :                 xWindowAccess->getByName( rtl::OUString( "private:resource/toolbar/standardbar" ));
                 [ #  # ]
    2143                 :            :         }
    2144         [ #  # ]:          0 :         catch ( const ::com::sun::star::uno::Exception& )
    2145                 :            :         {
    2146                 :            :         }
    2147                 :            :         try
    2148                 :            :         {
    2149 [ #  # ][ #  # ]:          0 :             a = xNameAccess->getByName( aDrawDoc );
    2150         [ #  # ]:          0 :             a >>= xWindowAccess;
    2151         [ #  # ]:          0 :             if ( xWindowAccess.is() )
    2152 [ #  # ][ #  # ]:          0 :                 xWindowAccess->getByName( rtl::OUString( "private:resource/toolbar/standardbar" ));
                 [ #  # ]
    2153                 :            :         }
    2154         [ #  # ]:          0 :         catch ( const ::com::sun::star::uno::Exception& )
    2155                 :            :         {
    2156                 :            :         }
    2157                 :            :         try
    2158                 :            :         {
    2159 [ #  # ][ #  # ]:          0 :             a = xNameAccess->getByName( aImpressDoc );
    2160         [ #  # ]:          0 :             a >>= xWindowAccess;
    2161         [ #  # ]:          0 :             if ( xWindowAccess.is() )
    2162 [ #  # ][ #  # ]:          0 :                 xWindowAccess->getByName( rtl::OUString( "private:resource/toolbar/standardbar" ));
                 [ #  # ]
    2163                 :            :         }
    2164         [ #  # ]:          0 :         catch ( const ::com::sun::star::uno::Exception& )
    2165                 :            :         {
    2166                 :          0 :         }
    2167                 :            :     }
    2168                 :            : 
    2169                 :            :     // preload user interface element factories
    2170         [ #  # ]:          0 :     Sequence< Sequence< css::beans::PropertyValue > > aSeqSeqPropValue;
    2171                 :            :     Reference< ::com::sun::star::ui::XUIElementFactoryRegistration > xUIElementFactory(
    2172         [ #  # ]:          0 :         rFactory->createInstance(
    2173                 :          0 :             rtl::OUString( "com.sun.star.ui.UIElementFactoryManager" )),
    2174 [ #  # ][ #  # ]:          0 :             UNO_QUERY );
    2175         [ #  # ]:          0 :     if ( xUIElementFactory.is() )
    2176                 :            :     {
    2177                 :            :         try
    2178                 :            :         {
    2179 [ #  # ][ #  # ]:          0 :             aSeqSeqPropValue = xUIElementFactory->getRegisteredFactories();
         [ #  # ][ #  # ]
                 [ #  # ]
    2180                 :            :         }
    2181         [ #  # ]:          0 :         catch ( const ::com::sun::star::uno::Exception& )
    2182                 :            :         {
    2183                 :            :         }
    2184                 :            :     }
    2185                 :            : 
    2186                 :            :     // preload popup menu controller factories. As all controllers are in the same
    2187                 :            :     // configuration file they also get preloaded!
    2188                 :            :     Reference< ::com::sun::star::frame::XUIControllerRegistration > xPopupMenuControllerFactory(
    2189         [ #  # ]:          0 :         rFactory->createInstance(
    2190                 :          0 :             rtl::OUString( "com.sun.star.frame.PopupMenuControllerFactory" )),
    2191 [ #  # ][ #  # ]:          0 :             UNO_QUERY );
    2192         [ #  # ]:          0 :     if ( xPopupMenuControllerFactory.is() )
    2193                 :            :     {
    2194                 :            :         try
    2195                 :            :         {
    2196         [ #  # ]:          0 :             xPopupMenuControllerFactory->hasController(
    2197                 :            :                         rtl::OUString( ".uno:CharFontName" ),
    2198 [ #  # ][ #  # ]:          0 :                         OUString() );
    2199                 :            :         }
    2200         [ #  # ]:          0 :         catch ( const ::com::sun::star::uno::Exception& )
    2201                 :            :         {
    2202                 :            :         }
    2203                 :            :     }
    2204                 :            : 
    2205                 :            :     // preload filter configuration
    2206         [ #  # ]:          0 :     Sequence< OUString > aSeq;
    2207         [ #  # ]:          0 :     xNameAccess = Reference< XNameAccess >( rFactory->createInstance(
    2208 [ #  # ][ #  # ]:          0 :                     rtl::OUString( "com.sun.star.document.FilterFactory" )), UNO_QUERY );
                 [ #  # ]
    2209         [ #  # ]:          0 :     if ( xNameAccess.is() )
    2210                 :            :     {
    2211                 :            :         try
    2212                 :            :         {
    2213 [ #  # ][ #  # ]:          0 :              aSeq = xNameAccess->getElementNames();
         [ #  # ][ #  # ]
                 [ #  # ]
    2214                 :            :         }
    2215         [ #  # ]:          0 :         catch ( const ::com::sun::star::uno::Exception& )
    2216                 :            :         {
    2217                 :            :         }
    2218                 :            :     }
    2219                 :            : 
    2220                 :            :     // preload type detection configuration
    2221         [ #  # ]:          0 :     xNameAccess = Reference< XNameAccess >( rFactory->createInstance(
    2222 [ #  # ][ #  # ]:          0 :                     rtl::OUString( "com.sun.star.document.TypeDetection" )), UNO_QUERY );
                 [ #  # ]
    2223         [ #  # ]:          0 :     if ( xNameAccess.is() )
    2224                 :            :     {
    2225                 :            :         try
    2226                 :            :         {
    2227 [ #  # ][ #  # ]:          0 :              aSeq = xNameAccess->getElementNames();
         [ #  # ][ #  # ]
                 [ #  # ]
    2228                 :            :         }
    2229         [ #  # ]:          0 :         catch ( const ::com::sun::star::uno::Exception& )
    2230                 :            :         {
    2231                 :            :         }
    2232 [ #  # ][ #  # ]:          0 :     }
    2233                 :          0 : }
    2234                 :            : 
    2235                 :         96 : void Desktop::OpenClients()
    2236                 :            : {
    2237                 :            : 
    2238                 :            :     // check if a document has been recovered - if there is one of if a document was loaded by cmdline, no default document
    2239                 :            :     // should be created
    2240                 :         96 :     Reference < XComponent > xFirst;
    2241                 :         96 :     bool bRecovery = false;
    2242                 :            : 
    2243         [ +  - ]:         96 :     const CommandLineArgs& rArgs = GetCommandLineArgs();
    2244         [ +  - ]:         96 :     SvtInternalOptions  aInternalOptions;
    2245                 :            : 
    2246         [ +  - ]:         96 :     Reference<XMultiServiceFactory> rFactory = ::comphelper::getProcessServiceFactory();
    2247                 :            : 
    2248 [ +  - ][ +  - ]:         96 :     if (!rArgs.IsQuickstart())
    2249                 :            :     {
    2250                 :         96 :         sal_Bool bShowHelp = sal_False;
    2251                 :         96 :         ::rtl::OUStringBuffer aHelpURLBuffer;
    2252 [ -  + ][ +  - ]:         96 :         if (rArgs.IsHelpWriter()) {
    2253                 :          0 :             bShowHelp = sal_True;
    2254         [ #  # ]:          0 :             aHelpURLBuffer.appendAscii("vnd.sun.star.help://swriter/start");
    2255 [ +  - ][ -  + ]:         96 :         } else if (rArgs.IsHelpCalc()) {
    2256                 :          0 :             bShowHelp = sal_True;
    2257         [ #  # ]:          0 :             aHelpURLBuffer.appendAscii("vnd.sun.star.help://scalc/start");
    2258 [ +  - ][ -  + ]:         96 :         } else if (rArgs.IsHelpDraw()) {
    2259                 :          0 :             bShowHelp = sal_True;
    2260         [ #  # ]:          0 :             aHelpURLBuffer.appendAscii("vnd.sun.star.help://sdraw/start");
    2261 [ +  - ][ -  + ]:         96 :         } else if (rArgs.IsHelpImpress()) {
    2262                 :          0 :             bShowHelp = sal_True;
    2263         [ #  # ]:          0 :             aHelpURLBuffer.appendAscii("vnd.sun.star.help://simpress/start");
    2264 [ +  - ][ -  + ]:         96 :         } else if (rArgs.IsHelpBase()) {
    2265                 :          0 :             bShowHelp = sal_True;
    2266         [ #  # ]:          0 :             aHelpURLBuffer.appendAscii("vnd.sun.star.help://sdatabase/start");
    2267 [ +  - ][ -  + ]:         96 :         } else if (rArgs.IsHelpBasic()) {
    2268                 :          0 :             bShowHelp = sal_True;
    2269         [ #  # ]:          0 :             aHelpURLBuffer.appendAscii("vnd.sun.star.help://sbasic/start");
    2270 [ +  - ][ -  + ]:         96 :         } else if (rArgs.IsHelpMath()) {
    2271                 :          0 :             bShowHelp = sal_True;
    2272         [ #  # ]:          0 :             aHelpURLBuffer.appendAscii("vnd.sun.star.help://smath/start");
    2273                 :            :         }
    2274         [ -  + ]:         96 :         if (bShowHelp) {
    2275         [ #  # ]:          0 :             aHelpURLBuffer.appendAscii("?Language=");
    2276 [ #  # ][ #  # ]:          0 :             aHelpURLBuffer.append(utl::ConfigManager::getLocale());
    2277                 :            : #if defined UNX
    2278         [ #  # ]:          0 :             aHelpURLBuffer.appendAscii("&System=UNX");
    2279                 :            : #elif defined WNT
    2280                 :            :             aHelpURLBuffer.appendAscii("&System=WIN");
    2281                 :            : #endif
    2282         [ #  # ]:          0 :             Application::GetHelp()->Start(
    2283 [ #  # ][ #  # ]:         96 :                 aHelpURLBuffer.makeStringAndClear(), NULL);
         [ #  # ][ #  # ]
    2284                 :            :             return;
    2285         [ +  - ]:         96 :         }
    2286                 :            :     }
    2287                 :            :     else
    2288                 :            :     {
    2289                 :          0 :         OUString            aIniName;
    2290                 :            : 
    2291         [ #  # ]:          0 :         osl_getExecutableFile( &aIniName.pData );
    2292                 :          0 :         sal_uInt32     lastIndex = aIniName.lastIndexOf('/');
    2293         [ #  # ]:          0 :         if ( lastIndex > 0 )
    2294                 :            :         {
    2295                 :          0 :             aIniName    = aIniName.copy( 0, lastIndex+1 );
    2296                 :          0 :             aIniName    += OUString( "perftune" );
    2297                 :            : #if defined(WNT)
    2298                 :            :             aIniName    += OUString( ".ini" );
    2299                 :            : #else
    2300                 :          0 :             aIniName    += OUString( "rc" );
    2301                 :            : #endif
    2302                 :            :         }
    2303                 :            : 
    2304                 :          0 :         rtl::Bootstrap aPerfTuneIniFile( aIniName );
    2305                 :            : 
    2306                 :          0 :         OUString aDefault( "0" );
    2307                 :          0 :         OUString aPreloadData;
    2308                 :            : 
    2309                 :          0 :         aPerfTuneIniFile.getFrom( OUString( "QuickstartPreloadConfiguration" ), aPreloadData, aDefault );
    2310         [ #  # ]:          0 :         if ( aPreloadData == "1" )
    2311                 :            :         {
    2312 [ #  # ][ #  # ]:          0 :             if ( rArgs.IsWriter()  ||
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2313         [ #  # ]:          0 :                  rArgs.IsCalc()    ||
    2314         [ #  # ]:          0 :                  rArgs.IsDraw()    ||
    2315         [ #  # ]:          0 :                  rArgs.IsImpress()    )
    2316                 :            :             {
    2317         [ #  # ]:          0 :                 PreloadModuleData( rArgs );
    2318                 :            :             }
    2319                 :            : 
    2320         [ #  # ]:          0 :             PreloadConfigurationData();
    2321                 :          0 :         }
    2322                 :            :     }
    2323                 :            : 
    2324                 :            :     // Disable AutoSave feature in case "--norestore" or a similar command line switch is set on the command line.
    2325                 :            :     // The reason behind: AutoSave/EmergencySave/AutoRecovery share the same data.
    2326                 :            :     // But the require that all documents, which are saved as backup should exists inside
    2327                 :            :     // memory. May be this mechanism will be inconsistent if the configuration exists ...
    2328                 :            :     // but no document inside memory corrspond to this data.
    2329                 :            :     // Furter it's not acceptable to recover such documents without any UI. It can
    2330                 :            :     // need some time, where the user wont see any results and wait for finishing the office startup ...
    2331                 :            :     sal_Bool bAllowRecoveryAndSessionManagement = (
    2332         [ +  - ]:         96 :                                                     ( !rArgs.IsNoRestore() ) &&
    2333         [ #  # ]:          0 :                                                     ( !rArgs.IsHeadless()  )
    2334 [ -  + ][ #  # ]:         96 :                                                   );
    2335                 :            : 
    2336         [ +  - ]:         96 :     if ( ! bAllowRecoveryAndSessionManagement )
    2337                 :            :     {
    2338                 :            :         try
    2339                 :            :         {
    2340                 :            :             Reference< XDispatch > xRecovery(
    2341 [ +  - ][ +  - ]:        192 :                     ::comphelper::getProcessServiceFactory()->createInstance( OUString("com.sun.star.frame.AutoRecovery") ),
    2342 [ +  - ][ +  - ]:         96 :                     ::com::sun::star::uno::UNO_QUERY_THROW );
    2343                 :            : 
    2344 [ +  - ][ +  - ]:         96 :             Reference< css::util::XURLTransformer > xParser( css::util::URLTransformer::create(::comphelper::getProcessComponentContext()) );
    2345                 :            : 
    2346                 :         96 :             css::util::URL aCmd;
    2347                 :         96 :             aCmd.Complete = ::rtl::OUString("vnd.sun.star.autorecovery:/disableRecovery");
    2348 [ +  - ][ +  - ]:         96 :             xParser->parseStrict(aCmd);
    2349                 :            : 
    2350 [ +  - ][ +  - ]:         96 :             xRecovery->dispatch(aCmd, css::uno::Sequence< css::beans::PropertyValue >());
         [ +  - ][ +  - ]
                 [ #  # ]
    2351                 :            :         }
    2352   [ #  #  #  # ]:          0 :         catch(const css::uno::Exception& e)
    2353                 :            :         {
    2354                 :            :             OUString aMessage = OUString("Could not disable AutoRecovery.\n")
    2355                 :          0 :                 + e.Message;
    2356                 :          0 :             OSL_FAIL(OUStringToOString(aMessage, RTL_TEXTENCODING_ASCII_US).getStr());
    2357                 :            :         }
    2358                 :            :     }
    2359                 :            :     else
    2360                 :            :     {
    2361                 :          0 :         sal_Bool bCrashed            = sal_False;
    2362                 :          0 :         sal_Bool bExistsRecoveryData = sal_False;
    2363                 :          0 :         sal_Bool bExistsSessionData  = sal_False;
    2364                 :            : 
    2365         [ #  # ]:          0 :         impl_checkRecoveryState(bCrashed, bExistsRecoveryData, bExistsSessionData);
    2366                 :            : 
    2367 [ #  # ][ #  # ]:          0 :         if ( !getenv ("OOO_DISABLE_RECOVERY") &&
         [ #  # ][ #  # ]
    2368                 :            :             (
    2369                 :            :                 ( bExistsRecoveryData ) || // => crash with files    => recovery
    2370                 :            :                 ( bCrashed            )    // => crash without files => error report
    2371                 :            :             )
    2372                 :            :            )
    2373                 :            :         {
    2374                 :            :             try
    2375                 :            :             {
    2376                 :            :                 bRecovery = impl_callRecoveryUI(
    2377                 :            :                     sal_False          , // false => force recovery instead of emergency save
    2378                 :            :                     bCrashed           ,
    2379         [ #  # ]:          0 :                     bExistsRecoveryData);
    2380                 :            :             }
    2381         [ #  # ]:          0 :             catch(const css::uno::Exception& e)
    2382                 :            :             {
    2383                 :            :                 OUString aMessage = OUString("Error during recovery\n")
    2384                 :          0 :                     + e.Message;
    2385                 :          0 :                 OSL_FAIL(OUStringToOString(aMessage, RTL_TEXTENCODING_ASCII_US).getStr());
    2386                 :            :             }
    2387                 :            :         }
    2388                 :            : 
    2389                 :          0 :         Reference< XInitialization > xSessionListener;
    2390                 :            :         try
    2391                 :            :         {
    2392 [ #  # ][ #  # ]:          0 :             xSessionListener = Reference< XInitialization >(::comphelper::getProcessServiceFactory()->createInstance(
    2393 [ #  # ][ #  # ]:          0 :                         OUString("com.sun.star.frame.SessionListener")), UNO_QUERY_THROW);
                 [ #  # ]
    2394                 :            : 
    2395                 :            :             // specifies whether the UI-interaction on Session shutdown is allowed
    2396         [ #  # ]:          0 :             sal_Bool bAllowUI = isUIOnSessionShutdownAllowed();
    2397                 :            :             css::beans::NamedValue aProperty( ::rtl::OUString( "AllowUserInteractionOnQuit"  ),
    2398         [ #  # ]:          0 :                                               css::uno::makeAny( bAllowUI ) );
    2399         [ #  # ]:          0 :             css::uno::Sequence< css::uno::Any > aArgs( 1 );
    2400 [ #  # ][ #  # ]:          0 :             aArgs[0] <<= aProperty;
    2401                 :            : 
    2402 [ #  # ][ #  # ]:          0 :             xSessionListener->initialize( aArgs );
         [ #  # ][ #  # ]
    2403                 :            :         }
    2404         [ #  # ]:          0 :         catch(const com::sun::star::uno::Exception& e)
    2405                 :            :         {
    2406                 :            :             OUString aMessage = OUString("Registration of session listener failed\n")
    2407                 :          0 :                 + e.Message;
    2408                 :          0 :             OSL_FAIL(OUStringToOString(aMessage, RTL_TEXTENCODING_ASCII_US).getStr());
    2409                 :            :         }
    2410                 :            : 
    2411         [ #  # ]:          0 :         if ( !bExistsRecoveryData )
    2412                 :            :         {
    2413                 :            :             // session management
    2414                 :            :             try
    2415                 :            :             {
    2416         [ #  # ]:          0 :                 Reference< XSessionManagerListener > r(xSessionListener, UNO_QUERY_THROW);
    2417 [ #  # ][ #  # ]:          0 :                 r->doRestore();
                 [ #  # ]
    2418                 :            :             }
    2419         [ #  # ]:          0 :             catch(const com::sun::star::uno::Exception& e)
    2420                 :            :             {
    2421                 :            :                 OUString aMessage = OUString("Error in session management\n")
    2422                 :          0 :                     + e.Message;
    2423                 :          0 :                 OSL_FAIL(OUStringToOString(aMessage, RTL_TEXTENCODING_ASCII_US).getStr());
    2424                 :            :             }
    2425                 :          0 :         }
    2426                 :            :     }
    2427                 :            : 
    2428         [ +  - ]:         96 :     OfficeIPCThread::EnableRequests();
    2429                 :            : 
    2430 [ +  - ][ +  - ]:         96 :     ProcessDocumentsRequest aRequest(rArgs.getCwdUrl());
                 [ +  - ]
    2431                 :         96 :     aRequest.pcProcessed = NULL;
    2432                 :            : 
    2433         [ +  - ]:         96 :     aRequest.aOpenList = rArgs.GetOpenList();
    2434         [ +  - ]:         96 :     aRequest.aViewList = rArgs.GetViewList();
    2435         [ +  - ]:         96 :     aRequest.aStartList = rArgs.GetStartList();
    2436         [ +  - ]:         96 :     aRequest.aPrintList = rArgs.GetPrintList();
    2437         [ +  - ]:         96 :     aRequest.aPrintToList = rArgs.GetPrintToList();
    2438         [ +  - ]:         96 :     aRequest.aPrinterName = rArgs.GetPrinterName();
    2439         [ +  - ]:         96 :     aRequest.aForceOpenList = rArgs.GetForceOpenList();
    2440         [ +  - ]:         96 :     aRequest.aForceNewList = rArgs.GetForceNewList();
    2441         [ +  - ]:         96 :     aRequest.aConversionList = rArgs.GetConversionList();
    2442         [ +  - ]:         96 :     aRequest.aConversionParams = rArgs.GetConversionParams();
    2443         [ +  - ]:         96 :     aRequest.aConversionOut = rArgs.GetConversionOut();
    2444 [ +  - ][ +  - ]:         96 :     aRequest.aInFilter = rArgs.GetInFilter();
    2445                 :            : 
    2446   [ +  -  +  -  :        768 :     if ( !aRequest.aOpenList.empty() ||
          +  -  +  -  +  
          -  +  -  -  +  
             #  #  -  + ]
                 [ -  + ]
    2447                 :         96 :          !aRequest.aViewList.empty() ||
    2448                 :         96 :          !aRequest.aStartList.empty() ||
    2449                 :         96 :          !aRequest.aPrintList.empty() ||
    2450                 :         96 :          !aRequest.aForceOpenList.empty() ||
    2451                 :         96 :          !aRequest.aForceNewList.empty() ||
    2452                 :         96 :          ( !aRequest.aPrintToList.empty() && !aRequest.aPrinterName.isEmpty() ) ||
    2453                 :         96 :          !aRequest.aConversionList.empty() )
    2454                 :            :     {
    2455 [ #  # ][ #  # ]:          0 :         if ( rArgs.HasModuleParam() )
    2456                 :            :         {
    2457         [ #  # ]:          0 :             SvtModuleOptions    aOpt;
    2458                 :            : 
    2459                 :            :             // Support command line parameters to start a module (as preselection)
    2460 [ #  # ][ #  # ]:          0 :             if ( rArgs.IsWriter() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2461         [ #  # ]:          0 :                 aRequest.aModule = aOpt.GetFactoryName( SvtModuleOptions::E_WRITER );
    2462 [ #  # ][ #  # ]:          0 :             else if ( rArgs.IsCalc() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2463         [ #  # ]:          0 :                 aRequest.aModule = aOpt.GetFactoryName( SvtModuleOptions::E_CALC );
    2464 [ #  # ][ #  # ]:          0 :             else if ( rArgs.IsImpress() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2465         [ #  # ]:          0 :                 aRequest.aModule= aOpt.GetFactoryName( SvtModuleOptions::E_IMPRESS );
    2466 [ #  # ][ #  # ]:          0 :             else if ( rArgs.IsDraw() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2467 [ #  # ][ #  # ]:          0 :                 aRequest.aModule= aOpt.GetFactoryName( SvtModuleOptions::E_DRAW );
    2468                 :            :         }
    2469                 :            : 
    2470                 :            :         // check for printing disabled
    2471 [ #  # ][ #  # ]:          0 :         if( ( !(aRequest.aPrintList.empty() && aRequest.aPrintToList.empty()) )
         [ #  # ][ #  # ]
    2472 [ #  # ][ #  # ]:          0 :             && Application::GetSettings().GetMiscSettings().GetDisablePrinting() )
    2473                 :            :         {
    2474                 :          0 :             aRequest.aPrintList.clear();
    2475                 :          0 :             aRequest.aPrintToList.clear();
    2476         [ #  # ]:          0 :             ResMgr* pDtResMgr = GetDesktopResManager();
    2477         [ #  # ]:          0 :             if( pDtResMgr )
    2478                 :            :             {
    2479         [ #  # ]:          0 :                 ErrorBox aBox( NULL, ResId( EBX_ERR_PRINTDISABLED, *pDtResMgr ) );
    2480 [ #  # ][ #  # ]:          0 :                 aBox.Execute();
    2481                 :            :             }
    2482                 :            :         }
    2483                 :            : 
    2484                 :            :         // Process request
    2485 [ #  # ][ #  # ]:          0 :         if ( OfficeIPCThread::ExecuteCmdLineRequests( aRequest ) )
    2486                 :            :         {
    2487                 :            :             // Don't do anything if we have successfully called terminate at desktop:
    2488                 :            :             return;
    2489                 :            :         }
    2490                 :            :     }
    2491                 :            : 
    2492                 :            :     // no default document if a document was loaded by recovery or by command line or if soffice is used as server
    2493                 :            :     Reference< XFramesSupplier > xTasksSupplier(
    2494 [ +  - ][ +  - ]:        192 :             ::comphelper::getProcessServiceFactory()->createInstance( OUString("com.sun.star.frame.Desktop") ),
    2495 [ +  - ][ +  - ]:         96 :             ::com::sun::star::uno::UNO_QUERY_THROW );
    2496 [ +  - ][ +  - ]:         96 :     Reference< XElementAccess > xList( xTasksSupplier->getFrames(), UNO_QUERY_THROW );
                 [ +  - ]
    2497 [ +  - ][ -  + ]:         96 :     if ( xList->hasElements() )
                 [ +  - ]
    2498                 :            :         return;
    2499                 :            : 
    2500 [ +  - ][ +  - ]:         96 :     if ( rArgs.IsQuickstart() || rArgs.IsInvisible() || Application::AnyInput( VCL_INPUT_APPEVENT ) )
         [ +  - ][ -  + ]
         [ #  # ][ #  # ]
                 [ +  - ]
    2501                 :            :         // soffice was started as tray icon ...
    2502                 :            :         return;
    2503                 :            : 
    2504         [ #  # ]:          0 :     if ( bRecovery )
    2505                 :            :     {
    2506         [ #  # ]:          0 :         ShowBackingComponent(0);
    2507                 :            :     }
    2508                 :            :     else
    2509                 :            :     {
    2510         [ #  # ]:          0 :         OpenDefault();
    2511 [ +  - ][ +  - ]:         96 :     }
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
    2512                 :            : }
    2513                 :            : 
    2514                 :          0 : void Desktop::OpenDefault()
    2515                 :            : {
    2516                 :            : 
    2517                 :            :     RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::OpenDefault" );
    2518                 :            : 
    2519                 :          0 :     ::rtl::OUString        aName;
    2520         [ #  # ]:          0 :     SvtModuleOptions    aOpt;
    2521                 :            : 
    2522         [ #  # ]:          0 :     const CommandLineArgs& rArgs = GetCommandLineArgs();
    2523 [ #  # ][ #  # ]:          0 :     if ( rArgs.IsNoDefault() ) return;
    2524 [ #  # ][ #  # ]:          0 :     if ( rArgs.HasModuleParam() )
    2525                 :            :     {
    2526                 :            :         // Support new command line parameters to start a module
    2527 [ #  # ][ #  # ]:          0 :         if ( rArgs.IsWriter() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2528         [ #  # ]:          0 :             aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_WRITER );
    2529 [ #  # ][ #  # ]:          0 :         else if ( rArgs.IsCalc() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2530         [ #  # ]:          0 :             aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_CALC );
    2531 [ #  # ][ #  # ]:          0 :         else if ( rArgs.IsImpress() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2532         [ #  # ]:          0 :             aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_IMPRESS );
    2533 [ #  # ][ #  # ]:          0 :         else if ( rArgs.IsBase() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2534         [ #  # ]:          0 :             aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_DATABASE );
    2535 [ #  # ][ #  # ]:          0 :         else if ( rArgs.IsDraw() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2536         [ #  # ]:          0 :             aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_DRAW );
    2537 [ #  # ][ #  # ]:          0 :         else if ( rArgs.IsMath() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2538         [ #  # ]:          0 :             aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_MATH );
    2539 [ #  # ][ #  # ]:          0 :         else if ( rArgs.IsGlobal() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2540         [ #  # ]:          0 :             aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_WRITERGLOBAL );
    2541 [ #  # ][ #  # ]:          0 :         else if ( rArgs.IsWeb() && aOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2542         [ #  # ]:          0 :             aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_WRITERWEB );
    2543                 :            :     }
    2544                 :            : 
    2545         [ #  # ]:          0 :     if ( aName.isEmpty() )
    2546                 :            :     {
    2547                 :            :         // Old way to create a default document
    2548 [ #  # ][ #  # ]:          0 :         if ( aOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
    2549         [ #  # ]:          0 :             aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_WRITER );
    2550 [ #  # ][ #  # ]:          0 :         else if ( aOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
    2551         [ #  # ]:          0 :             aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_CALC );
    2552 [ #  # ][ #  # ]:          0 :         else if ( aOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
    2553         [ #  # ]:          0 :             aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_IMPRESS );
    2554 [ #  # ][ #  # ]:          0 :         else if ( aOpt.IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
    2555         [ #  # ]:          0 :             aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_DATABASE );
    2556 [ #  # ][ #  # ]:          0 :         else if ( aOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
    2557         [ #  # ]:          0 :             aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_DRAW );
    2558                 :            :         else
    2559                 :            :             return;
    2560                 :            :     }
    2561                 :            : 
    2562 [ #  # ][ #  # ]:          0 :     ProcessDocumentsRequest aRequest(rArgs.getCwdUrl());
                 [ #  # ]
    2563                 :          0 :     aRequest.pcProcessed = NULL;
    2564         [ #  # ]:          0 :     aRequest.aOpenList.push_back(aName);
    2565 [ #  # ][ #  # ]:          0 :     OfficeIPCThread::ExecuteCmdLineRequests( aRequest );
         [ #  # ][ #  # ]
                 [ #  # ]
    2566                 :            : }
    2567                 :            : 
    2568                 :            : 
    2569                 :          0 : String GetURL_Impl(
    2570                 :            :     const String& rName, boost::optional< rtl::OUString > const & cwdUrl )
    2571                 :            : {
    2572                 :            :     // if rName is a vnd.sun.star.script URL do not attempt to parse it
    2573                 :            :     // as INetURLObj does not handle handle there URLs
    2574 [ #  # ][ #  # ]:          0 :     if (rName.CompareToAscii("vnd.sun.star.script" , 19) == COMPARE_EQUAL)
    2575                 :            :     {
    2576         [ #  # ]:          0 :         return rName;
    2577                 :            :     }
    2578                 :            : 
    2579                 :            :     // dont touch file urls, those should already be in internal form
    2580                 :            :     // they won't get better here (#112849#)
    2581 [ #  # ][ #  # ]:          0 :     if (rName.CompareToAscii("file:" , 5) == COMPARE_EQUAL)
    2582                 :            :     {
    2583         [ #  # ]:          0 :         return rName;
    2584                 :            :     }
    2585                 :            : 
    2586 [ #  # ][ #  # ]:          0 :     if ( rName.CompareToAscii("service:" , 8) == COMPARE_EQUAL )
    2587                 :            :     {
    2588         [ #  # ]:          0 :         return rName;
    2589                 :            :     }
    2590                 :            : 
    2591                 :            :     // Add path seperator to these directory and make given URL (rName) absolute by using of current working directory
    2592                 :            :     // Attention: "setFinalSlash()" is necessary for calling "smartRel2Abs()"!!!
    2593                 :            :     // Otherwhise last part will be ignored and wrong result will be returned!!!
    2594                 :            :     // "smartRel2Abs()" interpret given URL as file not as path. So he truncate last element to get the base path ...
    2595                 :            :     // But if we add a seperator - he doesn't do it anymore.
    2596         [ #  # ]:          0 :     INetURLObject aObj;
    2597 [ #  # ][ #  # ]:          0 :     if (cwdUrl) {
    2598 [ #  # ][ #  # ]:          0 :         aObj.SetURL(*cwdUrl);
    2599         [ #  # ]:          0 :         aObj.setFinalSlash();
    2600                 :            :     }
    2601                 :            : 
    2602                 :            :     // Use the provided parameters for smartRel2Abs to support the usage of '%' in system paths.
    2603                 :            :     // Otherwise this char won't get encoded and we are not able to load such files later,
    2604                 :            :     bool bWasAbsolute;
    2605                 :            :     INetURLObject aURL     = aObj.smartRel2Abs( rName, bWasAbsolute, false, INetURLObject::WAS_ENCODED,
    2606 [ #  # ][ #  # ]:          0 :                                                 RTL_TEXTENCODING_UTF8, true );
    2607 [ #  # ][ #  # ]:          0 :     String        aFileURL = aURL.GetMainURL(INetURLObject::NO_DECODE);
    2608                 :            : 
    2609                 :          0 :     ::osl::FileStatus aStatus( osl_FileStatus_Mask_FileURL );
    2610                 :          0 :     ::osl::DirectoryItem aItem;
    2611 [ #  # ][ #  # ]:          0 :     if( ::osl::FileBase::E_None == ::osl::DirectoryItem::get( aFileURL, aItem ) &&
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    2612         [ #  # ]:          0 :         ::osl::FileBase::E_None == aItem.getFileStatus( aStatus ) )
    2613 [ #  # ][ #  # ]:          0 :             aFileURL = aStatus.getFileURL();
    2614                 :            : 
    2615 [ #  # ][ #  # ]:          0 :     return aFileURL;
         [ #  # ][ #  # ]
                 [ #  # ]
    2616                 :            : }
    2617                 :            : 
    2618                 :          0 : void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent )
    2619                 :            : {
    2620   [ #  #  #  #  :          0 :     switch ( rAppEvent.GetEvent() )
          #  #  #  #  #  
                   #  # ]
    2621                 :            :     {
    2622                 :            :     case ApplicationEvent::TYPE_ACCEPT:
    2623                 :            :         // every time an accept parameter is used we create an acceptor
    2624                 :            :         // with the corresponding accept-string
    2625                 :          0 :         createAcceptor(rAppEvent.GetData());
    2626                 :          0 :         break;
    2627                 :            :     case ApplicationEvent::TYPE_APPEAR:
    2628         [ #  # ]:          0 :         if ( !GetCommandLineArgs().IsInvisible() )
    2629                 :            :         {
    2630         [ #  # ]:          0 :             css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
    2631                 :            : 
    2632                 :            :             // find active task - the active task is always a visible task
    2633                 :            :             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFramesSupplier >
    2634         [ #  # ]:          0 :                   xDesktop( xSMGR->createInstance( OUString("com.sun.star.frame.Desktop") ),
    2635 [ #  # ][ #  # ]:          0 :                             ::com::sun::star::uno::UNO_QUERY );
    2636 [ #  # ][ #  # ]:          0 :             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xTask = xDesktop->getActiveFrame();
    2637         [ #  # ]:          0 :             if ( !xTask.is() )
    2638                 :            :             {
    2639                 :            :                 // get any task if there is no active one
    2640 [ #  # ][ #  # ]:          0 :                 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xList( xDesktop->getFrames(), ::com::sun::star::uno::UNO_QUERY );
                 [ #  # ]
    2641 [ #  # ][ #  # ]:          0 :                 if ( xList->getCount()>0 )
                 [ #  # ]
    2642 [ #  # ][ #  # ]:          0 :                     xList->getByIndex(0) >>= xTask;
                 [ #  # ]
    2643                 :            :             }
    2644                 :            : 
    2645         [ #  # ]:          0 :             if ( xTask.is() )
    2646                 :            :             {
    2647 [ #  # ][ #  # ]:          0 :                 Reference< com::sun::star::awt::XTopWindow > xTop( xTask->getContainerWindow(), UNO_QUERY );
                 [ #  # ]
    2648 [ #  # ][ #  # ]:          0 :                 xTop->toFront();
    2649                 :            :             }
    2650                 :            :             else
    2651                 :            :             {
    2652                 :            :                 // no visible task that could be activated found
    2653                 :          0 :                 Reference< XFrame > xBackingFrame;
    2654                 :          0 :                 Reference< ::com::sun::star::awt::XWindow > xContainerWindow;
    2655         [ #  # ]:          0 :                 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xDesktopFrame( xDesktop, UNO_QUERY );
    2656                 :            : 
    2657 [ #  # ][ #  # ]:          0 :                 xBackingFrame = xDesktopFrame->findFrame(OUString( "_blank" ), 0);
                 [ #  # ]
    2658         [ #  # ]:          0 :                 if (xBackingFrame.is())
    2659 [ #  # ][ #  # ]:          0 :                     xContainerWindow = xBackingFrame->getContainerWindow();
                 [ #  # ]
    2660         [ #  # ]:          0 :                 if (xContainerWindow.is())
    2661                 :            :                 {
    2662         [ #  # ]:          0 :                     Sequence< Any > lArgs(1);
    2663 [ #  # ][ #  # ]:          0 :                     lArgs[0] <<= xContainerWindow;
    2664                 :            :                     Reference< XController > xBackingComp(
    2665         [ #  # ]:          0 :                         xSMGR->createInstanceWithArguments(OUString( "com.sun.star.frame.StartModule" ), lArgs),
    2666 [ #  # ][ #  # ]:          0 :                         UNO_QUERY);
    2667         [ #  # ]:          0 :                     if (xBackingComp.is())
    2668                 :            :                     {
    2669         [ #  # ]:          0 :                         Reference< ::com::sun::star::awt::XWindow > xBackingWin(xBackingComp, UNO_QUERY);
    2670                 :            :                         // Attention: You MUST(!) call setComponent() before you call attachFrame().
    2671                 :            :                         // Because the backing component set the property "IsBackingMode" of the frame
    2672                 :            :                         // to true inside attachFrame(). But setComponent() reset this state everytimes ...
    2673 [ #  # ][ #  # ]:          0 :                         xBackingFrame->setComponent(xBackingWin, xBackingComp);
    2674 [ #  # ][ #  # ]:          0 :                         xBackingComp->attachFrame(xBackingFrame);
    2675 [ #  # ][ #  # ]:          0 :                         xContainerWindow->setVisible(sal_True);
    2676                 :            : 
    2677 [ #  # ][ #  # ]:          0 :                         Window* pCompWindow = VCLUnoHelper::GetWindow(xBackingFrame->getComponentWindow());
                 [ #  # ]
    2678         [ #  # ]:          0 :                         if (pCompWindow)
    2679         [ #  # ]:          0 :                             pCompWindow->Update();
    2680         [ #  # ]:          0 :                     }
    2681                 :          0 :                 }
    2682                 :          0 :             }
    2683                 :            :         }
    2684                 :          0 :         break;
    2685                 :            :     case ApplicationEvent::TYPE_HELP:
    2686                 :            : #ifndef UNX
    2687                 :            :         // in non unix version allow showing of cmdline help window
    2688                 :            :         displayCmdlineHelp();
    2689                 :            : #endif
    2690                 :          0 :         break;
    2691                 :            :     case ApplicationEvent::TYPE_OPEN:
    2692                 :            :         {
    2693                 :          0 :             const CommandLineArgs& rCmdLine = GetCommandLineArgs();
    2694 [ #  # ][ #  # ]:          0 :             if ( !rCmdLine.IsInvisible() && !rCmdLine.IsTerminateAfterInit() )
                 [ #  # ]
    2695                 :            :             {
    2696                 :            :                 ProcessDocumentsRequest* pDocsRequest = new ProcessDocumentsRequest(
    2697 [ #  # ][ #  # ]:          0 :                     rCmdLine.getCwdUrl());
    2698                 :          0 :                 pDocsRequest->aOpenList.push_back(rAppEvent.GetData());
    2699                 :          0 :                 pDocsRequest->pcProcessed = NULL;
    2700                 :            : 
    2701                 :          0 :                 OfficeIPCThread::ExecuteCmdLineRequests( *pDocsRequest );
    2702         [ #  # ]:          0 :                 delete pDocsRequest;
    2703                 :            :             }
    2704                 :            :         }
    2705                 :          0 :         break;
    2706                 :            :     case ApplicationEvent::TYPE_OPENHELPURL:
    2707                 :            :         // start help for a specific URL
    2708         [ #  # ]:          0 :         Application::GetHelp()->Start(rAppEvent.GetData(), NULL);
    2709                 :          0 :         break;
    2710                 :            :     case ApplicationEvent::TYPE_PRINT:
    2711                 :            :         {
    2712                 :          0 :             const CommandLineArgs& rCmdLine = GetCommandLineArgs();
    2713 [ #  # ][ #  # ]:          0 :             if ( !rCmdLine.IsInvisible() && !rCmdLine.IsTerminateAfterInit() )
                 [ #  # ]
    2714                 :            :             {
    2715                 :            :                 ProcessDocumentsRequest* pDocsRequest = new ProcessDocumentsRequest(
    2716 [ #  # ][ #  # ]:          0 :                     rCmdLine.getCwdUrl());
    2717                 :          0 :                 pDocsRequest->aPrintList.push_back(rAppEvent.GetData());
    2718                 :          0 :                 pDocsRequest->pcProcessed = NULL;
    2719                 :            : 
    2720                 :          0 :                 OfficeIPCThread::ExecuteCmdLineRequests( *pDocsRequest );
    2721         [ #  # ]:          0 :                 delete pDocsRequest;
    2722                 :            :             }
    2723                 :            :         }
    2724                 :          0 :         break;
    2725                 :            :     case ApplicationEvent::TYPE_PRIVATE_DOSHUTDOWN:
    2726                 :            :         {
    2727         [ #  # ]:          0 :             Desktop* pD = dynamic_cast<Desktop*>(GetpApp());
    2728                 :            :             OSL_ENSURE( pD, "no desktop ?!?" );
    2729         [ #  # ]:          0 :             if( pD )
    2730                 :          0 :                 pD->doShutdown();
    2731                 :            :         }
    2732                 :          0 :         break;
    2733                 :            :     case ApplicationEvent::TYPE_QUICKSTART:
    2734         [ #  # ]:          0 :         if ( !GetCommandLineArgs().IsInvisible()  )
    2735                 :            :         {
    2736                 :            :             // If the office has been started the second time its command line arguments are sent through a pipe
    2737                 :            :             // connection to the first office. We want to reuse the quickstart option for the first office.
    2738                 :            :             // NOTICE: The quickstart service must be initialized inside the "main thread", so we use the
    2739                 :            :             // application events to do this (they are executed inside main thread)!!!
    2740                 :            :             // Don't start quickstart service if the user specified "--invisible" on the command line!
    2741                 :          0 :             sal_Bool bQuickstart( sal_True );
    2742         [ #  # ]:          0 :             Sequence< Any > aSeq( 1 );
    2743 [ #  # ][ #  # ]:          0 :             aSeq[0] <<= bQuickstart;
    2744                 :            : 
    2745 [ #  # ][ #  # ]:          0 :             Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance(
    2746                 :          0 :                                                            rtl::OUString( "com.sun.star.office.Quickstart" )),
    2747 [ #  # ][ #  # ]:          0 :                                                        UNO_QUERY );
    2748         [ #  # ]:          0 :             if ( xQuickstart.is() )
    2749 [ #  # ][ #  # ]:          0 :                 xQuickstart->initialize( aSeq );
                 [ #  # ]
    2750                 :            :         }
    2751                 :          0 :         break;
    2752                 :            :     case ApplicationEvent::TYPE_SHOWDIALOG:
    2753                 :            :         // ignore all errors here. It's clicking a menu entry only ...
    2754                 :            :         // The user will try it again, in case nothing happens .-)
    2755                 :            :         try
    2756                 :            :         {
    2757         [ #  # ]:          0 :             Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
    2758                 :            : 
    2759                 :            :             Reference< css::frame::XDispatchProvider >
    2760         [ #  # ]:          0 :                 xDesktop( xSMGR->createInstance( OUString("com.sun.star.frame.Desktop") ),
    2761 [ #  # ][ #  # ]:          0 :                 ::com::sun::star::uno::UNO_QUERY );
    2762                 :            : 
    2763                 :            :             // check provider ... we know it's weak reference only
    2764         [ #  # ]:          0 :             if ( ! xDesktop.is())
    2765                 :          0 :                 return;
    2766                 :            : 
    2767 [ #  # ][ #  # ]:          0 :             Reference< css::util::XURLTransformer > xParser( css::util::URLTransformer::create(::comphelper::getProcessComponentContext()) );
    2768                 :          0 :             css::util::URL aCommand;
    2769         [ #  # ]:          0 :             if( rAppEvent.GetData() == ::rtl::OUString("PREFERENCES") )
    2770                 :          0 :                 aCommand.Complete = rtl::OUString( ".uno:OptionsTreeDialog"  );
    2771         [ #  # ]:          0 :             else if( rAppEvent.GetData() == ::rtl::OUString("ABOUT") )
    2772                 :          0 :                 aCommand.Complete = rtl::OUString( ".uno:About"  );
    2773         [ #  # ]:          0 :             if( !aCommand.Complete.isEmpty() )
    2774                 :            :             {
    2775 [ #  # ][ #  # ]:          0 :                 xParser->parseStrict(aCommand);
    2776                 :            : 
    2777 [ #  # ][ #  # ]:          0 :                 css::uno::Reference< css::frame::XDispatch > xDispatch = xDesktop->queryDispatch(aCommand, rtl::OUString(), 0);
    2778         [ #  # ]:          0 :                 if (xDispatch.is())
    2779 [ #  # ][ #  # ]:          0 :                     xDispatch->dispatch(aCommand, css::uno::Sequence< css::beans::PropertyValue >());
         [ #  # ][ #  # ]
    2780 [ #  # ][ #  # ]:          0 :             }
                 [ #  # ]
    2781                 :            :         }
    2782                 :          0 :         catch(const css::uno::Exception&)
    2783                 :            :         {}
    2784                 :          0 :         break;
    2785                 :            :     case ApplicationEvent::TYPE_UNACCEPT:
    2786                 :            :         // try to remove corresponding acceptor
    2787                 :          0 :         destroyAcceptor(rAppEvent.GetData());
    2788                 :          0 :         break;
    2789                 :            :     default:
    2790                 :            :         OSL_FAIL("this cannot happen");
    2791                 :          0 :         break;
    2792                 :            :     }
    2793                 :            : }
    2794                 :            : 
    2795                 :        158 : void Desktop::OpenSplashScreen()
    2796                 :            : {
    2797         [ +  - ]:        158 :     const CommandLineArgs &rCmdLine = GetCommandLineArgs();
    2798                 :        158 :     sal_Bool bVisible = sal_False;
    2799                 :            :     // Show intro only if this is normal start (e.g. no server, no quickstart, no printing )
    2800 [ +  - ][ -  + ]:        316 :     if ( !rCmdLine.IsInvisible() &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
             #  #  #  # ]
                 [ -  + ]
    2801         [ #  # ]:          0 :          !rCmdLine.IsHeadless() &&
    2802         [ #  # ]:          0 :          !rCmdLine.IsQuickstart() &&
    2803         [ #  # ]:          0 :          !rCmdLine.IsMinimized() &&
    2804         [ #  # ]:          0 :          !rCmdLine.IsNoLogo() &&
    2805         [ #  # ]:          0 :          !rCmdLine.IsTerminateAfterInit() &&
    2806 [ #  # ][ -  + ]:        158 :          rCmdLine.GetPrintList().empty() &&
                 [ #  # ]
    2807 [ #  # ][ -  + ]:        158 :          rCmdLine.GetPrintToList().empty() &&
                 [ #  # ]
    2808 [ #  # ][ -  + ]:        158 :          rCmdLine.GetConversionList().empty() )
                 [ #  # ]
    2809                 :            :     {
    2810                 :            :         // Determine application name from command line parameters
    2811                 :          0 :         OUString aAppName;
    2812 [ #  # ][ #  # ]:          0 :         if ( rCmdLine.IsWriter() )
    2813                 :          0 :             aAppName = rtl::OUString( "writer" );
    2814 [ #  # ][ #  # ]:          0 :         else if ( rCmdLine.IsCalc() )
    2815                 :          0 :             aAppName = rtl::OUString( "calc" );
    2816 [ #  # ][ #  # ]:          0 :         else if ( rCmdLine.IsDraw() )
    2817                 :          0 :             aAppName = rtl::OUString( "draw" );
    2818 [ #  # ][ #  # ]:          0 :         else if ( rCmdLine.IsImpress() )
    2819                 :          0 :             aAppName = rtl::OUString( "impress" );
    2820 [ #  # ][ #  # ]:          0 :         else if ( rCmdLine.IsBase() )
    2821                 :          0 :             aAppName = rtl::OUString( "base" );
    2822 [ #  # ][ #  # ]:          0 :         else if ( rCmdLine.IsGlobal() )
    2823                 :          0 :             aAppName = rtl::OUString( "global" );
    2824 [ #  # ][ #  # ]:          0 :         else if ( rCmdLine.IsMath() )
    2825                 :          0 :             aAppName = rtl::OUString( "math" );
    2826 [ #  # ][ #  # ]:          0 :         else if ( rCmdLine.IsWeb() )
    2827                 :          0 :             aAppName = rtl::OUString( "web" );
    2828                 :            : 
    2829                 :            :         // Which splash to use
    2830                 :          0 :         OUString aSplashService( "com.sun.star.office.SplashScreen" );
    2831 [ #  # ][ #  # ]:          0 :         if ( rCmdLine.HasSplashPipe() )
    2832                 :          0 :             aSplashService = OUString("com.sun.star.office.PipeSplashScreen");
    2833                 :            : 
    2834                 :          0 :         bVisible = sal_True;
    2835         [ #  # ]:          0 :         Sequence< Any > aSeq( 2 );
    2836 [ #  # ][ #  # ]:          0 :         aSeq[0] <<= bVisible;
    2837 [ #  # ][ #  # ]:          0 :         aSeq[1] <<= aAppName;
    2838                 :            :         m_rSplashScreen = Reference<XStatusIndicator>(
    2839 [ #  # ][ #  # ]:          0 :             comphelper::getProcessServiceFactory()->createInstanceWithArguments(
    2840 [ #  # ][ #  # ]:          0 :             aSplashService, aSeq), UNO_QUERY);
                 [ #  # ]
    2841                 :            : 
    2842         [ #  # ]:          0 :         if(m_rSplashScreen.is())
    2843 [ #  # ][ #  # ]:          0 :                 m_rSplashScreen->start(OUString("SplashScreen"), 100);
                 [ #  # ]
    2844                 :            :     }
    2845                 :            : 
    2846                 :        158 : }
    2847                 :            : 
    2848                 :       4190 : void Desktop::SetSplashScreenProgress(sal_Int32 iProgress)
    2849                 :            : {
    2850         [ -  + ]:       4190 :     if(m_rSplashScreen.is())
    2851                 :            :     {
    2852                 :          0 :         m_rSplashScreen->setValue(iProgress);
    2853                 :            :     }
    2854                 :       4190 : }
    2855                 :            : 
    2856                 :        902 : void Desktop::SetSplashScreenText( const ::rtl::OUString& rText )
    2857                 :            : {
    2858         [ -  + ]:        902 :     if( m_rSplashScreen.is() )
    2859                 :            :     {
    2860                 :          0 :         m_rSplashScreen->setText( rText );
    2861                 :            :     }
    2862                 :        902 : }
    2863                 :            : 
    2864                 :       1515 : void Desktop::CloseSplashScreen()
    2865                 :            : {
    2866         [ -  + ]:       1515 :     if(m_rSplashScreen.is())
    2867                 :            :     {
    2868                 :          0 :         m_rSplashScreen->end();
    2869                 :          0 :         m_rSplashScreen = NULL;
    2870                 :            :     }
    2871                 :       1515 : }
    2872                 :            : 
    2873                 :            : // ========================================================================
    2874                 :         52 : void Desktop::DoFirstRunInitializations()
    2875                 :            : {
    2876                 :            :     try
    2877                 :            :     {
    2878 [ +  - ][ +  - ]:         52 :         Reference< XJobExecutor > xExecutor( ::comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString("com.sun.star.task.JobExecutor") ), UNO_QUERY );
         [ +  - ][ +  - ]
    2879         [ +  - ]:         52 :         if( xExecutor.is() )
    2880 [ +  - ][ +  - ]:         52 :             xExecutor->trigger( ::rtl::OUString("onFirstRunInitialization") );
                 [ #  # ]
    2881                 :            :     }
    2882                 :          0 :     catch(const ::com::sun::star::uno::Exception&)
    2883                 :            :     {
    2884                 :            :         OSL_FAIL( "Desktop::DoFirstRunInitializations: caught an exception while trigger job executor ..." );
    2885                 :            :     }
    2886                 :         52 : }
    2887                 :            : 
    2888                 :          0 : void Desktop::ShowBackingComponent(Desktop * progress)
    2889                 :            : {
    2890 [ #  # ][ #  # ]:          0 :     if (GetCommandLineArgs().IsNoDefault())
                 [ #  # ]
    2891                 :            :     {
    2892                 :          0 :         return;
    2893                 :            :     }
    2894                 :            :     Reference< XMultiServiceFactory > xSMgr(
    2895 [ #  # ][ #  # ]:          0 :         comphelper::getProcessServiceFactory(), UNO_SET_THROW);
    2896                 :            :     Reference< XFrame > xDesktopFrame(
    2897 [ #  # ][ #  # ]:          0 :         xSMgr->createInstance("com.sun.star.frame.Desktop"), UNO_QUERY);
                 [ #  # ]
    2898         [ #  # ]:          0 :     if (xDesktopFrame.is())
    2899                 :            :     {
    2900         [ #  # ]:          0 :         if (progress != 0)
    2901                 :            :         {
    2902         [ #  # ]:          0 :             progress->SetSplashScreenProgress(60);
    2903                 :            :         }
    2904                 :          0 :         Reference< XFrame > xBackingFrame;
    2905                 :          0 :         Reference< ::com::sun::star::awt::XWindow > xContainerWindow;
    2906                 :            : 
    2907 [ #  # ][ #  # ]:          0 :         xBackingFrame = xDesktopFrame->findFrame(OUString( "_blank" ), 0);
                 [ #  # ]
    2908         [ #  # ]:          0 :         if (xBackingFrame.is())
    2909 [ #  # ][ #  # ]:          0 :             xContainerWindow = xBackingFrame->getContainerWindow();
                 [ #  # ]
    2910         [ #  # ]:          0 :         if (xContainerWindow.is())
    2911                 :            :         {
    2912         [ #  # ]:          0 :             SetDocumentExtendedStyle(xContainerWindow);
    2913         [ #  # ]:          0 :             if (progress != 0)
    2914                 :            :             {
    2915         [ #  # ]:          0 :                 progress->SetSplashScreenProgress(75);
    2916                 :            :             }
    2917         [ #  # ]:          0 :             Sequence< Any > lArgs(1);
    2918 [ #  # ][ #  # ]:          0 :             lArgs[0] <<= xContainerWindow;
    2919                 :            : 
    2920                 :            :             Reference< XController > xBackingComp(
    2921 [ #  # ][ #  # ]:          0 :                 xSMgr->createInstanceWithArguments(OUString( "com.sun.star.frame.StartModule" ), lArgs), UNO_QUERY);
                 [ #  # ]
    2922         [ #  # ]:          0 :             if (xBackingComp.is())
    2923                 :            :             {
    2924         [ #  # ]:          0 :                 Reference< ::com::sun::star::awt::XWindow > xBackingWin(xBackingComp, UNO_QUERY);
    2925                 :            :                 // Attention: You MUST(!) call setComponent() before you call attachFrame().
    2926                 :            :                 // Because the backing component set the property "IsBackingMode" of the frame
    2927                 :            :                 // to true inside attachFrame(). But setComponent() reset this state everytimes ...
    2928 [ #  # ][ #  # ]:          0 :                 xBackingFrame->setComponent(xBackingWin, xBackingComp);
    2929         [ #  # ]:          0 :                 if (progress != 0)
    2930                 :            :                 {
    2931         [ #  # ]:          0 :                     progress->SetSplashScreenProgress(100);
    2932                 :            :                 }
    2933 [ #  # ][ #  # ]:          0 :                 xBackingComp->attachFrame(xBackingFrame);
    2934         [ #  # ]:          0 :                 if (progress != 0)
    2935                 :            :                 {
    2936         [ #  # ]:          0 :                     progress->CloseSplashScreen();
    2937                 :            :                 }
    2938 [ #  # ][ #  # ]:          0 :                 xContainerWindow->setVisible(sal_True);
    2939         [ #  # ]:          0 :             }
    2940                 :          0 :         }
    2941                 :          0 :     }
    2942                 :            : }
    2943                 :            : 
    2944                 :            : // ========================================================================
    2945                 :         96 : void Desktop::CheckFirstRun( )
    2946                 :            : {
    2947                 :         96 :     const ::rtl::OUString sCommonMiscNodeName("/org.openoffice.Office.Common/Misc");
    2948                 :         96 :     const ::rtl::OUString sFirstRunNodeName("FirstRun");
    2949                 :            : 
    2950                 :            :     // --------------------------------------------------------------------
    2951                 :            :     // check if this is the first office start
    2952                 :            : 
    2953                 :            :     // for this, open the Common/Misc node where this info is stored
    2954                 :            :     ::utl::OConfigurationTreeRoot aCommonMisc = ::utl::OConfigurationTreeRoot::createWithServiceFactory(
    2955                 :            :         ::comphelper::getProcessServiceFactory( ),
    2956                 :            :         sCommonMiscNodeName,
    2957                 :            :         2,
    2958                 :            :         ::utl::OConfigurationTreeRoot::CM_UPDATABLE
    2959 [ +  - ][ +  - ]:         96 :     );
    2960                 :            : 
    2961                 :            :     // read the flag
    2962                 :            :     OSL_ENSURE( aCommonMisc.isValid(), "Desktop::CheckFirstRun: could not open the config node needed!" );
    2963                 :         96 :     sal_Bool bIsFirstRun = sal_False;
    2964                 :         96 :     aCommonMisc.getNodeValue( sFirstRunNodeName ) >>= bIsFirstRun;
    2965                 :            : 
    2966         [ +  + ]:         96 :     if ( !bIsFirstRun )
    2967                 :            :         // nothing to do ....
    2968                 :         96 :         return;
    2969                 :            : 
    2970                 :            :     // --------------------------------------------------------------------
    2971                 :            :     // it is the first run
    2972                 :            :     // this has once been done using a vos timer. this could lead to problems when
    2973                 :            :     // the timer would trigger when the app is already going down again, since VCL would
    2974                 :            :     // no longer be available. Since the old handler would do a postUserEvent to the main
    2975                 :            :     // thread anyway, we can use a vcl timer here to prevent the race contition (#107197#)
    2976         [ +  - ]:         62 :     m_firstRunTimer.SetTimeout(3000); // 3 sec.
    2977         [ +  - ]:         62 :     m_firstRunTimer.SetTimeoutHdl(LINK(this, Desktop, AsyncInitFirstRun));
    2978         [ +  - ]:         62 :     m_firstRunTimer.Start();
    2979                 :            : 
    2980                 :            : #ifdef WNT
    2981                 :            :     // Check if Quckstarter should be started (on Windows only)
    2982                 :            :     TCHAR szValue[8192];
    2983                 :            :     DWORD nValueSize = sizeof(szValue);
    2984                 :            :     HKEY hKey;
    2985                 :            :     if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE,  "Software\\LibreOffice", &hKey ) )
    2986                 :            :     {
    2987                 :            :         if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("RunQuickstartAtFirstStart"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) )
    2988                 :            :         {
    2989                 :            :             sal_Bool bQuickstart( sal_True );
    2990                 :            :             sal_Bool bAutostart( sal_True );
    2991                 :            :             Sequence< Any > aSeq( 2 );
    2992                 :            :             aSeq[0] <<= bQuickstart;
    2993                 :            :             aSeq[1] <<= bAutostart;
    2994                 :            : 
    2995                 :            :             Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance(
    2996                 :            :                 OUString::createFromAscii( "com.sun.star.office.Quickstart" )),UNO_QUERY );
    2997                 :            :             if ( xQuickstart.is() )
    2998                 :            :                 xQuickstart->initialize( aSeq );
    2999                 :            :             RegCloseKey( hKey );
    3000                 :            :         }
    3001                 :            :     }
    3002                 :            : #endif
    3003                 :            : 
    3004                 :            :     // --------------------------------------------------------------------
    3005                 :            :     // reset the config flag
    3006                 :            : 
    3007                 :            :     // set the value
    3008         [ +  - ]:         62 :     aCommonMisc.setNodeValue( sFirstRunNodeName, makeAny( (sal_Bool)sal_False ) );
    3009                 :            :     // commit the changes
    3010 [ +  - ][ +  + ]:         96 :     aCommonMisc.commit();
         [ +  + ][ +  + ]
    3011                 :            : }
    3012                 :            : 
    3013 [ +  - ][ +  - ]:        474 : }
    3014                 :            : 
    3015                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10