LCOV - code coverage report
Current view: top level - chart2/source/controller/main - ChartWindow.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 53 135 39.3 %
Date: 2012-08-25 Functions: 13 26 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 20 102 19.6 %

           Branch data     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 "ChartWindow.hxx"
      21                 :            : #include "ChartController.hxx"
      22                 :            : #include "HelpIds.hrc"
      23                 :            : 
      24                 :            : #include <vcl/help.hxx>
      25                 :            : 
      26                 :            : using namespace ::com::sun::star;
      27                 :            : 
      28                 :            : namespace
      29                 :            : {
      30                 :          0 : ::Rectangle lcl_AWTRectToVCLRect( const ::com::sun::star::awt::Rectangle & rAWTRect )
      31                 :            : {
      32                 :          0 :     ::Rectangle aResult;
      33                 :          0 :     aResult.setX( rAWTRect.X );
      34                 :          0 :     aResult.setY( rAWTRect.Y );
      35                 :          0 :     aResult.setWidth( rAWTRect.Width );
      36                 :          0 :     aResult.setHeight( rAWTRect.Height );
      37                 :          0 :     return aResult;
      38                 :            : }
      39                 :            : } // anonymous namespace
      40                 :            : 
      41                 :            : 
      42                 :            : //.............................................................................
      43                 :            : namespace chart
      44                 :            : {
      45                 :            : //.............................................................................
      46                 :            : 
      47                 :         34 : ChartWindow::ChartWindow( WindowController* pWindowController, Window* pParent, WinBits nStyle )
      48                 :            :         : Window(pParent, nStyle)
      49                 :            :         , m_pWindowController( pWindowController )
      50                 :         34 :         , m_bInPaint(false)
      51                 :            : {
      52         [ +  - ]:         34 :     this->SetHelpId( HID_SCH_WIN_DOCUMENT );
      53 [ +  - ][ +  - ]:         34 :     this->SetMapMode( MapMode(MAP_100TH_MM) );
                 [ +  - ]
      54         [ +  - ]:         34 :     adjustHighContrastMode();
      55                 :            :     // chart does not depend on exact pixel painting => enable antialiased drawing
      56         [ +  - ]:         34 :     SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW | GetAntialiasing() );
      57         [ +  - ]:         34 :     EnableRTL( sal_False );
      58         [ +  - ]:         34 :     if( pParent )
      59         [ +  - ]:         34 :         pParent->EnableRTL( sal_False );// #i96215# necessary for a correct position of the context menu in rtl mode
      60                 :         34 : }
      61                 :            : 
      62                 :         34 : ChartWindow::~ChartWindow()
      63                 :            : {
      64         [ -  + ]:         68 : }
      65                 :            : 
      66                 :         34 : void ChartWindow::clear()
      67                 :            : {
      68                 :         34 :     m_pWindowController=0;
      69                 :         34 :     this->ReleaseMouse();
      70                 :         34 : }
      71                 :            : 
      72                 :       1007 : void ChartWindow::PrePaint()
      73                 :            : {
      74                 :            :     // forward VCLs PrePaint window event to DrawingLayer
      75         [ +  - ]:       1007 :     if( m_pWindowController )
      76                 :            :     {
      77                 :       1007 :         m_pWindowController->PrePaint();
      78                 :            :     }
      79                 :       1007 : }
      80                 :            : 
      81                 :        912 : void ChartWindow::Paint( const Rectangle& rRect )
      82                 :            : {
      83                 :        912 :     m_bInPaint = true;
      84         [ +  - ]:        912 :     if( m_pWindowController )
      85                 :        912 :         m_pWindowController->execute_Paint( rRect );
      86                 :            :     else
      87                 :          0 :         Window::Paint( rRect );
      88                 :        912 :     m_bInPaint = false;
      89                 :        912 : }
      90                 :            : 
      91                 :          0 : void ChartWindow::MouseButtonDown(const MouseEvent& rMEvt)
      92                 :            : {
      93         [ #  # ]:          0 :     if( m_pWindowController )
      94                 :          0 :         m_pWindowController->execute_MouseButtonDown(rMEvt);
      95                 :            :     else
      96                 :          0 :         Window::MouseButtonDown(rMEvt);
      97                 :          0 : }
      98                 :            : 
      99                 :          0 : void ChartWindow::MouseMove( const MouseEvent& rMEvt )
     100                 :            : {
     101         [ #  # ]:          0 :     if( m_pWindowController )
     102                 :          0 :         m_pWindowController->execute_MouseMove( rMEvt );
     103                 :            :     else
     104                 :          0 :         Window::MouseMove( rMEvt );
     105                 :          0 : }
     106                 :            : 
     107                 :          0 : void ChartWindow::Tracking( const TrackingEvent& rTEvt )
     108                 :            : {
     109         [ #  # ]:          0 :     if( m_pWindowController )
     110                 :          0 :         m_pWindowController->execute_Tracking( rTEvt );
     111                 :            :     else
     112                 :          0 :         Window::Tracking( rTEvt );
     113                 :          0 : }
     114                 :            : 
     115                 :          0 : void ChartWindow::MouseButtonUp( const MouseEvent& rMEvt )
     116                 :            : {
     117         [ #  # ]:          0 :     if( m_pWindowController )
     118                 :          0 :         m_pWindowController->execute_MouseButtonUp( rMEvt );
     119                 :            :     else
     120                 :          0 :         Window::MouseButtonUp( rMEvt );
     121                 :          0 : }
     122                 :            : 
     123                 :         68 : void ChartWindow::Resize()
     124                 :            : {
     125         [ +  - ]:         68 :     if( m_pWindowController )
     126                 :         68 :         m_pWindowController->execute_Resize();
     127                 :            :     else
     128                 :          0 :         Window::Resize();
     129                 :         68 : }
     130                 :            : 
     131                 :          0 : void ChartWindow::Activate()
     132                 :            : {
     133         [ #  # ]:          0 :     if( m_pWindowController )
     134                 :          0 :         m_pWindowController->execute_Activate();
     135                 :            :     else
     136                 :          0 :         Window::Activate();
     137                 :          0 : }
     138                 :          0 : void ChartWindow::Deactivate()
     139                 :            : {
     140         [ #  # ]:          0 :     if( m_pWindowController )
     141                 :          0 :         m_pWindowController->execute_Deactivate();
     142                 :            :     else
     143                 :          0 :         Window::Deactivate();
     144                 :          0 : }
     145                 :         34 : void ChartWindow::GetFocus()
     146                 :            : {
     147         [ +  - ]:         34 :     if( m_pWindowController )
     148                 :         34 :         m_pWindowController->execute_GetFocus();
     149                 :            :     else
     150                 :          0 :         Window::GetFocus();
     151                 :         34 : }
     152                 :          4 : void ChartWindow::LoseFocus()
     153                 :            : {
     154         [ +  - ]:          4 :     if( m_pWindowController )
     155                 :          4 :         m_pWindowController->execute_LoseFocus();
     156                 :            :     else
     157                 :          0 :         Window::LoseFocus();
     158                 :          4 : }
     159                 :            : 
     160                 :          0 : void ChartWindow::Command( const CommandEvent& rCEvt )
     161                 :            : {
     162         [ #  # ]:          0 :     if( m_pWindowController )
     163                 :          0 :         m_pWindowController->execute_Command( rCEvt );
     164                 :            :     else
     165                 :          0 :         Window::Command( rCEvt );
     166                 :          0 : }
     167                 :            : 
     168                 :          0 : void ChartWindow::KeyInput( const KeyEvent& rKEvt )
     169                 :            : {
     170         [ #  # ]:          0 :     if( m_pWindowController )
     171                 :            :     {
     172         [ #  # ]:          0 :         if( !m_pWindowController->execute_KeyInput(rKEvt) )
     173                 :          0 :             Window::KeyInput(rKEvt);
     174                 :            :     }
     175                 :            :     else
     176                 :          0 :         Window::KeyInput( rKEvt );
     177                 :          0 : }
     178                 :            : 
     179                 :          0 : uno::Reference< accessibility::XAccessible > ChartWindow::CreateAccessible()
     180                 :            : {
     181         [ #  # ]:          0 :     if( m_pWindowController )
     182                 :          0 :         return m_pWindowController->CreateAccessible();
     183                 :            :     else
     184                 :          0 :         return Window::CreateAccessible();
     185                 :            : }
     186                 :            : 
     187                 :          0 : void ChartWindow::DataChanged( const DataChangedEvent& rDCEvt )
     188                 :            : {
     189                 :          0 :     ::Window::DataChanged( rDCEvt );
     190                 :            : 
     191         [ #  # ]:          0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
           [ #  #  #  # ]
     192                 :          0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     193                 :            :     {
     194                 :          0 :         adjustHighContrastMode();
     195                 :            :     }
     196                 :          0 : }
     197                 :            : 
     198                 :          0 : void ChartWindow::RequestHelp( const HelpEvent& rHEvt )
     199                 :            : {
     200                 :          0 :     bool bHelpHandled = false;
     201 [ #  # ][ #  # ]:          0 :     if( ( rHEvt.GetMode() & HELPMODE_QUICK ) &&
                 [ #  # ]
     202                 :            :         m_pWindowController )
     203                 :            :     {
     204                 :            : //         Point aLogicHitPos = PixelToLogic( rHEvt.GetMousePosPixel()); // old chart: GetPointerPosPixel()
     205 [ #  # ][ #  # ]:          0 :         Point aLogicHitPos = PixelToLogic( GetPointerPosPixel());
     206                 :          0 :         ::rtl::OUString aQuickHelpText;
     207                 :          0 :         awt::Rectangle aHelpRect;
     208         [ #  # ]:          0 :         bool bIsBalloonHelp( Help::IsBalloonHelpEnabled() );
     209         [ #  # ]:          0 :         bHelpHandled = m_pWindowController->requestQuickHelp( aLogicHitPos, bIsBalloonHelp, aQuickHelpText, aHelpRect );
     210                 :            : 
     211         [ #  # ]:          0 :         if( bHelpHandled )
     212                 :            :         {
     213         [ #  # ]:          0 :             if( bIsBalloonHelp )
     214                 :            :                 Help::ShowBalloon(
     215 [ #  # ][ #  # ]:          0 :                     this, rHEvt.GetMousePosPixel(), lcl_AWTRectToVCLRect( aHelpRect ), String( aQuickHelpText ));
         [ #  # ][ #  # ]
                 [ #  # ]
     216                 :            :             else
     217                 :            :                 Help::ShowQuickHelp(
     218 [ #  # ][ #  # ]:          0 :                     this, lcl_AWTRectToVCLRect( aHelpRect ), String( aQuickHelpText ));
         [ #  # ][ #  # ]
     219                 :          0 :         }
     220                 :            :     }
     221                 :            : 
     222         [ #  # ]:          0 :     if( !bHelpHandled )
     223                 :          0 :         ::Window::RequestHelp( rHEvt );
     224                 :          0 : }
     225                 :            : 
     226                 :         34 : void ChartWindow::adjustHighContrastMode()
     227                 :            : {
     228                 :            :     static const sal_Int32 nContrastMode =
     229                 :            :         DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL |
     230                 :            :         DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT;
     231                 :            : 
     232                 :         34 :     bool bUseContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
     233         [ -  + ]:         34 :     SetDrawMode( bUseContrast ? nContrastMode : DRAWMODE_DEFAULT );
     234                 :         34 : }
     235                 :            : 
     236                 :       1588 : void ChartWindow::ForceInvalidate()
     237                 :            : {
     238                 :       1588 :     ::Window::Invalidate();
     239                 :       1588 : }
     240                 :        909 : void ChartWindow::Invalidate( sal_uInt16 nFlags )
     241                 :            : {
     242         [ +  + ]:        909 :     if( m_bInPaint ) // #i101928# superfluous paint calls while entering and editing charts"
     243                 :        909 :         return;
     244                 :        141 :     ::Window::Invalidate( nFlags );
     245                 :            : }
     246                 :       1510 : void ChartWindow::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
     247                 :            : {
     248         [ +  + ]:       1510 :     if( m_bInPaint ) // #i101928# superfluous paint calls while entering and editing charts"
     249                 :       1510 :         return;
     250                 :         30 :     ::Window::Invalidate( rRect, nFlags );
     251                 :            : }
     252                 :          0 : void ChartWindow::Invalidate( const Region& rRegion, sal_uInt16 nFlags )
     253                 :            : {
     254         [ #  # ]:          0 :     if( m_bInPaint ) // #i101928# superfluous paint calls while entering and editing charts"
     255                 :          0 :         return;
     256                 :          0 :     ::Window::Invalidate( rRegion, nFlags );
     257                 :            : }
     258                 :            : 
     259                 :            : //.............................................................................
     260                 :            : } //namespace chart
     261                 :            : //.............................................................................
     262                 :            : 
     263                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10