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

Generated by: LCOV version 1.10