LCOV - code coverage report
Current view: top level - dbaccess/source/ui/browser - dataview.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 53 75 70.7 %
Date: 2014-11-03 Functions: 13 16 81.2 %
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          22 :         ColorChanger( OutputDevice* _pDev, const ::Color& _rNewLineColor, const ::Color& _rNewFillColor )
      49          22 :             :m_pDev( _pDev )
      50             :         {
      51          22 :             m_pDev->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR );
      52          22 :             m_pDev->SetLineColor( _rNewLineColor );
      53          22 :             m_pDev->SetFillColor( _rNewFillColor );
      54          22 :         }
      55             : 
      56          22 :         ~ColorChanger()
      57             :         {
      58          22 :             m_pDev->Pop();
      59          22 :         }
      60             :     };
      61             : 
      62          18 :     ODataView::ODataView(   vcl::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          18 :         ,m_aSeparator( this )
      70             :     {
      71          18 :         m_rController.acquire();
      72          18 :         m_pAccel.reset(::svt::AcceleratorExecute::createAcceleratorHelper());
      73          18 :         m_aSeparator.Show();
      74          18 :     }
      75             : 
      76          36 :     void ODataView::Construct()
      77             :     {
      78          36 :     }
      79             : 
      80          28 :     ODataView::~ODataView()
      81             :     {
      82             : 
      83          14 :         m_rController.release();
      84          14 :     }
      85             : 
      86           0 :     void ODataView::resizeDocumentView( Rectangle& /*_rPlayground*/ )
      87             :     {
      88           0 :     }
      89             : 
      90          22 :     void ODataView::Paint( const Rectangle& _rRect )
      91             :     {
      92             :         // draw the background
      93             :         {
      94          22 :             ColorChanger aColors( this, COL_TRANSPARENT, GetSettings().GetStyleSettings().GetFaceColor() );
      95          22 :             DrawRect( _rRect );
      96             :         }
      97             : 
      98             :         // let the base class do anything it needs
      99          22 :         Window::Paint( _rRect );
     100          22 :     }
     101             : 
     102          68 :     void ODataView::resizeAll( const Rectangle& _rPlayground )
     103             :     {
     104          68 :         Rectangle aPlayground( _rPlayground );
     105             : 
     106             :         // position the separator
     107          68 :         const Size aSeparatorSize = Size( aPlayground.GetWidth(), 2 );
     108          68 :         m_aSeparator.SetPosSizePixel( aPlayground.TopLeft(), aSeparatorSize );
     109          68 :         aPlayground.Top() += aSeparatorSize.Height() + 1;
     110             : 
     111             :         // position the controls of the document's view
     112          68 :         resizeDocumentView( aPlayground );
     113          68 :     }
     114             : 
     115          68 :     void ODataView::Resize()
     116             :     {
     117          68 :         Window::Resize();
     118          68 :         resizeAll( Rectangle( Point( 0, 0), GetSizePixel() ) );
     119          68 :     }
     120         234 :     bool ODataView::PreNotify( NotifyEvent& _rNEvt )
     121             :     {
     122         234 :         bool bHandled = false;
     123         234 :         switch ( _rNEvt.GetType() )
     124             :         {
     125             :             case EVENT_KEYINPUT:
     126             :             {
     127           0 :                 const KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent();
     128           0 :                 const vcl::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         234 :         return bHandled || Window::PreNotify( _rNEvt );
     141             :     }
     142          34 :     void ODataView::StateChanged( StateChangedType nType )
     143             :     {
     144          34 :         Window::StateChanged( nType );
     145             : 
     146          34 :         if ( nType == StateChangedType::CONTROLBACKGROUND )
     147             :         {
     148             :             // Check if we need to get new images for normal/high contrast mode
     149           0 :             m_rController.notifyHiContrastChanged();
     150             :         }
     151             : 
     152          34 :         if ( nType == StateChangedType::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          16 :                 Reference< XController > xController( m_rController.getXController(), UNO_SET_THROW );
     159          32 :                 Reference< XModel > xModel( xController->getModel(), UNO_QUERY );
     160          16 :                 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          16 :                 }
     166             :             }
     167           0 :             catch( const Exception& )
     168             :             {
     169             :                 DBG_UNHANDLED_EXCEPTION();
     170             :             }
     171             :         }
     172          34 :     }
     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          30 :     void ODataView::attachFrame(const Reference< XFrame >& _xFrame)
     188             :     {
     189          30 :         m_pAccel->init(m_xContext, _xFrame);
     190          30 :     }
     191          72 : }
     192             : 
     193             : // namespace dbaui
     194             : 
     195             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10