LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/vcl/generic/app - gensys.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 93 5.4 %
Date: 2013-07-09 Functions: 4 9 44.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <generic/gensys.h>
      21             : 
      22             : #include <vcl/msgbox.hxx>
      23             : #include <vcl/button.hxx>
      24             : 
      25             : #include <svdata.hxx>
      26             : 
      27             : #include <rtl/ustrbuf.hxx>
      28             : #include <rtl/strbuf.hxx>
      29             : #include <rtl/bootstrap.hxx>
      30             : #include <osl/process.h>
      31             : #include <osl/thread.h>
      32             : #include <unotools/configmgr.hxx>
      33             : 
      34             : #include "vcl/unohelp.hxx"
      35             : #include <com/sun/star/beans/PropertyValue.hpp>
      36             : #include <com/sun/star/container/XNameAccess.hpp>
      37             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      38             : 
      39             : using namespace com::sun::star;
      40             : 
      41             : namespace {
      42             : 
      43           0 : OUString GetNativeMessageBoxButtonText( int nButtonId, bool bUseResources )
      44             : {
      45           0 :     OUString aText;
      46           0 :     if( bUseResources )
      47             :     {
      48           0 :         aText = Button::GetStandardText( nButtonId );
      49             :     }
      50           0 :     if( aText.isEmpty() )
      51             :     {
      52           0 :         switch( nButtonId )
      53             :         {
      54             :         case BUTTON_OK:
      55           0 :             aText = "OK";
      56           0 :             break;
      57             :         case BUTTON_CANCEL:
      58           0 :             aText = "Cancel";
      59           0 :             break;
      60             :         case BUTTON_ABORT:
      61           0 :             aText = "Abort";
      62           0 :             break;
      63             :         case BUTTON_RETRY:
      64           0 :             aText = "Retry";
      65           0 :             break;
      66             :         case BUTTON_IGNORE:
      67           0 :             aText = "Ignore";
      68           0 :             break;
      69             :         case BUTTON_YES:
      70           0 :             aText = "Yes";
      71           0 :             break;
      72             :         case BUTTON_NO:
      73           0 :             aText = "No";
      74           0 :             break;
      75             :         }
      76             :     }
      77           0 :     return aText;
      78             : }
      79             : 
      80             : }
      81             : 
      82          55 : SalGenericSystem::SalGenericSystem()
      83             : {
      84          55 : }
      85             : 
      86          29 : SalGenericSystem::~SalGenericSystem()
      87             : {
      88          29 : }
      89             : 
      90           0 : int SalGenericSystem::ShowNativeMessageBox( const OUString& rTitle, const OUString& rMessage,
      91             :                                             int nButtonCombination, int nDefaultButton,
      92             :                                             bool bUseResources )
      93             : {
      94           0 :     int nDefButton = 0;
      95           0 :     std::list< OUString > aButtons;
      96           0 :     int nButtonIds[5], nBut = 0;
      97             : 
      98           0 :     ImplHideSplash();
      99             : 
     100           0 :     if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK ||
     101             :         nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL )
     102             :     {
     103           0 :         aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_OK, bUseResources ) );
     104           0 :         nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK;
     105             :     }
     106           0 :     if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO_CANCEL ||
     107             :         nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO )
     108             :     {
     109           0 :         aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_YES, bUseResources ) );
     110           0 :         nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_YES;
     111           0 :         aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_NO, bUseResources ) );
     112           0 :         nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO;
     113           0 :         if( nDefaultButton == SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO )
     114           0 :             nDefButton = 1;
     115             :     }
     116           0 :     if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL ||
     117           0 :         nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO_CANCEL ||
     118             :         nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL )
     119             :     {
     120           0 :         if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL )
     121             :         {
     122           0 :             aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_RETRY, bUseResources ) );
     123           0 :             nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY;
     124             :         }
     125           0 :         aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_CANCEL, bUseResources ) );
     126           0 :         nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL;
     127           0 :         if( nDefaultButton == SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL )
     128           0 :             nDefButton = aButtons.size()-1;
     129             :     }
     130           0 :     if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_ABORT_RETRY_IGNORE )
     131             :     {
     132           0 :         aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_ABORT, bUseResources ) );
     133           0 :         nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_ABORT;
     134           0 :         aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_RETRY, bUseResources ) );
     135           0 :         nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY;
     136           0 :         aButtons.push_back( GetNativeMessageBoxButtonText( BUTTON_IGNORE, bUseResources ) );
     137           0 :         nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_IGNORE;
     138           0 :         switch( nDefaultButton )
     139             :         {
     140           0 :             case SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY: nDefButton = 1;break;
     141           0 :             case SALSYSTEM_SHOWNATIVEMSGBOX_BTN_IGNORE: nDefButton = 2;break;
     142             :         }
     143             :     }
     144             : 
     145           0 :     int nResult = ShowNativeDialog( rTitle, rMessage, aButtons, nDefButton );
     146             : 
     147           0 :     return nResult != -1 ? nButtonIds[ nResult ] : 0;
     148             : }
     149             : 
     150             : #if !defined(ANDROID) && !defined(IOS)
     151             : 
     152             : // X11-specific
     153             : 
     154           0 : const char* SalGenericSystem::getFrameResName()
     155             : {
     156             :     /*  according to ICCCM:
     157             :      *  first search command line for -name parameter
     158             :      *  then try RESOURCE_NAME environment variable
     159             :      *  then use argv[0] stripped by directories
     160             :      */
     161           0 :     static OStringBuffer aResName;
     162           0 :     if( aResName.isEmpty() )
     163             :     {
     164           0 :         int nArgs = osl_getCommandArgCount();
     165           0 :         for( int n = 0; n < nArgs-1; n++ )
     166             :         {
     167           0 :             OUString aArg;
     168           0 :             if( ! osl_getCommandArg( n, &aArg.pData ) &&
     169           0 :                 aArg.equalsIgnoreAsciiCase("-name") &&
     170           0 :                 ! osl_getCommandArg( n+1, &aArg.pData ) )
     171             :             {
     172           0 :                 aResName.append( OUStringToOString( aArg, osl_getThreadTextEncoding() ) );
     173           0 :                 break;
     174             :             }
     175           0 :         }
     176           0 :         if( aResName.isEmpty() )
     177             :         {
     178           0 :             const char* pEnv = getenv( "RESOURCE_NAME" );
     179           0 :             if( pEnv && *pEnv )
     180           0 :                 aResName.append( pEnv );
     181             :         }
     182           0 :         if( aResName.isEmpty() )
     183             :             aResName.append( OUStringToOString( utl::ConfigManager::getProductName().toAsciiLowerCase(),
     184           0 :                 osl_getThreadTextEncoding()));
     185             :     }
     186           0 :     return aResName.getStr();
     187             : }
     188             : 
     189           0 : const char* SalGenericSystem::getFrameClassName()
     190             : {
     191           0 :     static OStringBuffer aClassName;
     192           0 :     if( aClassName.isEmpty() )
     193             :     {
     194           0 :         OUString aIni, aProduct;
     195           0 :         rtl::Bootstrap::get( "BRAND_BASE_DIR", aIni );
     196           0 :         aIni += "/program/" SAL_CONFIGFILE( "bootstrap" );
     197           0 :         rtl::Bootstrap aBootstrap( aIni );
     198           0 :         aBootstrap.getFrom( "ProductKey", aProduct );
     199             : 
     200           0 :         if( !aProduct.isEmpty() )
     201           0 :             aClassName.append( OUStringToOString( aProduct, osl_getThreadTextEncoding() ) );
     202             :         else
     203           0 :             aClassName.append( OUStringToOString( utl::ConfigManager::getProductName(), osl_getThreadTextEncoding()));
     204             :     }
     205           0 :     return aClassName.getStr();
     206         465 : }
     207             : 
     208             : #endif
     209             : 
     210             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10