LCOV - code coverage report
Current view: top level - libreoffice/vcl/unx/x11 - x11sys.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 74 0.0 %
Date: 2012-12-27 Functions: 0 10 0.0 %
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 <unx/salunx.h>
      21             : #include <unx/saldata.hxx>
      22             : #include <unx/salinst.h>
      23             : #include <unx/saldisp.hxx>
      24             : #include <unx/x11/x11sys.hxx>
      25             : 
      26             : #include <vcl/msgbox.hxx>
      27             : #include <vcl/button.hxx>
      28             : 
      29             : #include <svdata.hxx>
      30             : 
      31             : #include <rtl/ustrbuf.hxx>
      32             : #include <osl/thread.h>
      33             : 
      34             : 
      35           0 : SalSystem* X11SalInstance::CreateSalSystem()
      36             : {
      37           0 :     return new X11SalSystem();
      38             : }
      39             : 
      40             : // -----------------------------------------------------------------------
      41             : 
      42           0 : X11SalSystem::~X11SalSystem()
      43             : {
      44           0 : }
      45             : 
      46             : // for the moment only handle xinerama case
      47           0 : unsigned int X11SalSystem::GetDisplayScreenCount()
      48             : {
      49           0 :     SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
      50           0 :     return pSalDisp->IsXinerama() ? pSalDisp->GetXineramaScreens().size() :
      51           0 :            pSalDisp->GetXScreenCount();
      52             : }
      53             : 
      54           0 : bool X11SalSystem::IsUnifiedDisplay()
      55             : {
      56           0 :     SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
      57           0 :     unsigned int nScreenCount = pSalDisp->GetXScreenCount();
      58           0 :     return pSalDisp->IsXinerama() ? true : (nScreenCount == 1);
      59             : }
      60             : 
      61           0 : unsigned int X11SalSystem::GetDisplayBuiltInScreen()
      62             : {
      63           0 :     SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
      64           0 :     return pSalDisp->GetDefaultXScreen().getXScreen();
      65             : }
      66             : 
      67           0 : Rectangle X11SalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen )
      68             : {
      69           0 :     Rectangle aRet;
      70           0 :     SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
      71           0 :     if( pSalDisp->IsXinerama() )
      72             :     {
      73           0 :         const std::vector< Rectangle >& rScreens = pSalDisp->GetXineramaScreens();
      74           0 :         if( nScreen < rScreens.size() )
      75           0 :             aRet = rScreens[nScreen];
      76             :     }
      77             :     else
      78             :     {
      79             :         const SalDisplay::ScreenData& rScreen =
      80           0 :             pSalDisp->getDataForScreen( SalX11Screen( nScreen ) );
      81           0 :         aRet = Rectangle( Point( 0, 0 ), rScreen.m_aSize );
      82             :     }
      83             : 
      84           0 :     return aRet;
      85             : }
      86             : 
      87           0 : Rectangle X11SalSystem::GetDisplayScreenWorkAreaPosSizePixel( unsigned int nScreen )
      88             : {
      89             :     // FIXME: workareas
      90           0 :     return GetDisplayScreenPosSizePixel( nScreen );
      91             : }
      92             : 
      93           0 : rtl::OUString X11SalSystem::GetDisplayScreenName( unsigned int nScreen )
      94             : {
      95           0 :     rtl::OUString aScreenName;
      96           0 :     SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
      97           0 :     if( pSalDisp->IsXinerama() )
      98             :     {
      99           0 :         const std::vector< Rectangle >& rScreens = pSalDisp->GetXineramaScreens();
     100           0 :         if( nScreen >= rScreens.size() )
     101           0 :             nScreen = 0;
     102           0 :         rtl::OUStringBuffer aBuf( 256 );
     103           0 :         aBuf.append( rtl::OStringToOUString( rtl::OString( DisplayString( pSalDisp->GetDisplay() ) ), osl_getThreadTextEncoding() ) );
     104           0 :         aBuf.appendAscii( " [" );
     105           0 :         aBuf.append( static_cast<sal_Int32>(nScreen) );
     106           0 :         aBuf.append( sal_Unicode(']') );
     107           0 :         aScreenName = aBuf.makeStringAndClear();
     108             :     }
     109             :     else
     110             :     {
     111           0 :         if( nScreen >= static_cast<unsigned int>(pSalDisp->GetXScreenCount()) )
     112           0 :             nScreen = 0;
     113           0 :         rtl::OUStringBuffer aBuf( 256 );
     114           0 :         aBuf.append( rtl::OStringToOUString( rtl::OString( DisplayString( pSalDisp->GetDisplay() ) ), osl_getThreadTextEncoding() ) );
     115             :         // search backwards for ':'
     116           0 :         int nPos = aBuf.getLength();
     117           0 :         if( nPos > 0 )
     118           0 :             nPos--;
     119           0 :         while( nPos > 0 && aBuf[nPos] != ':' )
     120           0 :             nPos--;
     121             :         // search forward to '.'
     122           0 :         while( nPos < aBuf.getLength() && aBuf[nPos] != '.' )
     123           0 :             nPos++;
     124           0 :         if( nPos < aBuf.getLength() )
     125           0 :             aBuf.setLength( nPos+1 );
     126             :         else
     127           0 :             aBuf.append( sal_Unicode('.') );
     128           0 :         aBuf.append( static_cast<sal_Int32>(nScreen) );
     129           0 :         aScreenName = aBuf.makeStringAndClear();
     130             :     }
     131           0 :     return aScreenName;
     132             : }
     133             : 
     134           0 : int X11SalSystem::ShowNativeDialog( const rtl::OUString& rTitle, const rtl::OUString& rMessage, const std::list< rtl::OUString >& rButtons, int nDefButton )
     135             : {
     136           0 :     int nRet = -1;
     137             : 
     138           0 :     ImplSVData* pSVData = ImplGetSVData();
     139           0 :     if( pSVData->mpIntroWindow )
     140           0 :         pSVData->mpIntroWindow->Hide();
     141             : 
     142           0 :     WarningBox aWarn( NULL, WB_STDWORK, rMessage );
     143           0 :     aWarn.SetText( rTitle );
     144           0 :     aWarn.Clear();
     145             : 
     146           0 :     sal_uInt16 nButton = 0;
     147           0 :     for( std::list< rtl::OUString >::const_iterator it = rButtons.begin(); it != rButtons.end(); ++it )
     148             :     {
     149           0 :             aWarn.AddButton( *it, nButton+1, nButton == (sal_uInt16)nDefButton ? BUTTONDIALOG_DEFBUTTON : 0 );
     150           0 :             nButton++;
     151             :     }
     152           0 :     aWarn.SetFocusButton( (sal_uInt16)nDefButton+1 );
     153             : 
     154           0 :     nRet = ((int)aWarn.Execute()) - 1;
     155             : 
     156             :     // normalize behaviour, actually this should never happen
     157           0 :     if( nRet < -1 || nRet >= int(rButtons.size()) )
     158           0 :         nRet = -1;
     159             : 
     160           0 :     return nRet;
     161             : }
     162             : 
     163             : 
     164             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10