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

Generated by: LCOV version 1.10