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

Generated by: LCOV version 1.10