LCOV - code coverage report
Current view: top level - dbaccess/source/ui/browser - dataview.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 52 74 70.3 %
Date: 2014-04-11 Functions: 11 14 78.6 %
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 <dbaccess/dataview.hxx>
      21             : #include <toolkit/helper/vclunohelper.hxx>
      22             : #include <comphelper/types.hxx>
      23             : #include <comphelper/namedvaluecollection.hxx>
      24             : #include <sfx2/app.hxx>
      25             : #include <sfx2/imgmgr.hxx>
      26             : #include <dbaccess/IController.hxx>
      27             : #include "UITools.hxx"
      28             : #include <sfx2/sfx.hrc>
      29             : #include <svtools/imgdef.hxx>
      30             : #include <tools/diagnose_ex.h>
      31             : #include <vcl/settings.hxx>
      32             : 
      33             : namespace dbaui
      34             : {
      35             :     using namespace ::com::sun::star::uno;
      36             :     using namespace ::com::sun::star::beans;
      37             :     using namespace ::com::sun::star::util;
      38             :     using namespace ::com::sun::star::lang;
      39             :     using namespace ::com::sun::star::frame;
      40             : 
      41             :     // ColorChanger
      42             :     class ColorChanger
      43             :     {
      44             :     protected:
      45             :         OutputDevice*   m_pDev;
      46             : 
      47             :     public:
      48           9 :         ColorChanger( OutputDevice* _pDev, const ::Color& _rNewLineColor, const ::Color& _rNewFillColor )
      49           9 :             :m_pDev( _pDev )
      50             :         {
      51           9 :             m_pDev->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
      52           9 :             m_pDev->SetLineColor( _rNewLineColor );
      53           9 :             m_pDev->SetFillColor( _rNewFillColor );
      54           9 :         }
      55             : 
      56           9 :         ~ColorChanger()
      57             :         {
      58           9 :             m_pDev->Pop();
      59           9 :         }
      60             :     };
      61             : 
      62           6 :     ODataView::ODataView(   Window* pParent,
      63             :                             IController& _rController,
      64             :                             const Reference< XComponentContext >& _rxContext,
      65             :                             WinBits nStyle)
      66             :         :Window(pParent,nStyle)
      67             :         ,m_xContext(_rxContext)
      68             :         ,m_rController( _rController )
      69           6 :         ,m_aSeparator( this )
      70             :     {
      71           6 :         m_rController.acquire();
      72           6 :         m_pAccel.reset(::svt::AcceleratorExecute::createAcceleratorHelper());
      73           6 :         m_aSeparator.Show();
      74           6 :     }
      75             : 
      76          12 :     void ODataView::Construct()
      77             :     {
      78          12 :     }
      79             : 
      80           4 :     ODataView::~ODataView()
      81             :     {
      82             : 
      83           2 :         m_rController.release();
      84           2 :     }
      85             : 
      86           0 :     void ODataView::resizeDocumentView( Rectangle& /*_rPlayground*/ )
      87             :     {
      88           0 :     }
      89             : 
      90           9 :     void ODataView::Paint( const Rectangle& _rRect )
      91             :     {
      92             :         // draw the background
      93             :         {
      94           9 :             ColorChanger aColors( this, COL_TRANSPARENT, GetSettings().GetStyleSettings().GetFaceColor() );
      95           9 :             DrawRect( _rRect );
      96             :         }
      97             : 
      98             :         // let the base class do anything it needs
      99           9 :         Window::Paint( _rRect );
     100           9 :     }
     101             : 
     102          26 :     void ODataView::resizeAll( const Rectangle& _rPlayground )
     103             :     {
     104          26 :         Rectangle aPlayground( _rPlayground );
     105             : 
     106             :         // position the separator
     107          26 :         const Size aSeparatorSize = Size( aPlayground.GetWidth(), 2 );
     108          26 :         m_aSeparator.SetPosSizePixel( aPlayground.TopLeft(), aSeparatorSize );
     109          26 :         aPlayground.Top() += aSeparatorSize.Height() + 1;
     110             : 
     111             :         // position the controls of the document's view
     112          26 :         resizeDocumentView( aPlayground );
     113          26 :     }
     114             : 
     115          26 :     void ODataView::Resize()
     116             :     {
     117          26 :         Window::Resize();
     118          26 :         resizeAll( Rectangle( Point( 0, 0), GetSizePixel() ) );
     119          26 :     }
     120          64 :     bool ODataView::PreNotify( NotifyEvent& _rNEvt )
     121             :     {
     122          64 :         bool bHandled = false;
     123          64 :         switch ( _rNEvt.GetType() )
     124             :         {
     125             :             case EVENT_KEYINPUT:
     126             :             {
     127           0 :                 const KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent();
     128           0 :                 const KeyCode& aKeyCode = pKeyEvent->GetKeyCode();
     129           0 :                 if ( m_pAccel.get() && m_pAccel->execute( aKeyCode ) )
     130             :                     // the accelerator consumed the event
     131           0 :                     return true;
     132             :             }
     133             :             // NO break
     134             :             case EVENT_KEYUP:
     135             :             case EVENT_MOUSEBUTTONDOWN:
     136             :             case EVENT_MOUSEBUTTONUP:
     137           0 :                 bHandled = m_rController.interceptUserInput( _rNEvt );
     138           0 :                 break;
     139             :         }
     140          64 :         return bHandled || Window::PreNotify( _rNEvt );
     141             :     }
     142          12 :     void ODataView::StateChanged( StateChangedType nType )
     143             :     {
     144          12 :         Window::StateChanged( nType );
     145             : 
     146          12 :         if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     147             :         {
     148             :             // Check if we need to get new images for normal/high contrast mode
     149           0 :             m_rController.notifyHiContrastChanged();
     150             :         }
     151             : 
     152          12 :         if ( nType == STATE_CHANGE_INITSHOW )
     153             :         {
     154             :             // now that there's a view which is finally visible, remove the "Hidden" value from the
     155             :             // model's arguments.
     156             :             try
     157             :             {
     158           6 :                 Reference< XController > xController( m_rController.getXController(), UNO_SET_THROW );
     159          12 :                 Reference< XModel > xModel( xController->getModel(), UNO_QUERY );
     160           6 :                 if ( xModel.is() )
     161             :                 {
     162           0 :                     ::comphelper::NamedValueCollection aArgs( xModel->getArgs() );
     163           0 :                     aArgs.remove( "Hidden" );
     164           0 :                     xModel->attachResource( xModel->getURL(), aArgs.getPropertyValues() );
     165           6 :                 }
     166             :             }
     167           0 :             catch( const Exception& )
     168             :             {
     169             :                 DBG_UNHANDLED_EXCEPTION();
     170             :             }
     171             :         }
     172          12 :     }
     173           0 :     void ODataView::DataChanged( const DataChangedEvent& rDCEvt )
     174             :     {
     175           0 :         Window::DataChanged( rDCEvt );
     176             : 
     177           0 :         if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
     178           0 :             (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
     179           0 :             (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
     180           0 :             ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     181           0 :             (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
     182             :         {
     183             :             // Check if we need to get new images for normal/high contrast mode
     184           0 :             m_rController.notifyHiContrastChanged();
     185             :         }
     186           0 :     }
     187           7 :     void ODataView::attachFrame(const Reference< XFrame >& _xFrame)
     188             :     {
     189           7 :         m_pAccel->init(m_xContext, _xFrame);
     190           7 :     }
     191             : }
     192             : 
     193             : // namespace dbaui
     194             : 
     195             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10