LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/ui/browser - dataview.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 74 0.0 %
Date: 2012-12-27 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             : 
      21             : #include "dataview.hxx"
      22             : #include <toolkit/unohlp.hxx>
      23             : #include <comphelper/types.hxx>
      24             : #include <comphelper/namedvaluecollection.hxx>
      25             : #include <sfx2/app.hxx>
      26             : #include <sfx2/imgmgr.hxx>
      27             : #include "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           0 :         ColorChanger( OutputDevice* _pDev, const Color& _rNewLineColor, const Color& _rNewFillColor )
      53           0 :             :m_pDev( _pDev )
      54             :         {
      55           0 :             m_pDev->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
      56           0 :             m_pDev->SetLineColor( _rNewLineColor );
      57           0 :             m_pDev->SetFillColor( _rNewFillColor );
      58           0 :         }
      59             : 
      60           0 :         ~ColorChanger()
      61             :         {
      62           0 :             m_pDev->Pop();
      63           0 :         }
      64             :     };
      65             : 
      66             :     DBG_NAME(ODataView)
      67             :     // -------------------------------------------------------------------------
      68           0 :     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           0 :         ,m_aSeparator( this )
      76             :     {
      77             :         DBG_CTOR(ODataView,NULL);
      78           0 :         m_rController.acquire();
      79           0 :         m_pAccel.reset(::svt::AcceleratorExecute::createAcceleratorHelper());
      80           0 :         m_aSeparator.Show();
      81           0 :     }
      82             : 
      83             :     // -------------------------------------------------------------------------
      84           0 :     void ODataView::Construct()
      85             :     {
      86           0 :     }
      87             : 
      88             :     // -------------------------------------------------------------------------
      89           0 :     ODataView::~ODataView()
      90             :     {
      91             :         DBG_DTOR(ODataView,NULL);
      92             : 
      93           0 :         m_rController.release();
      94           0 :     }
      95             : 
      96             :     // -------------------------------------------------------------------------
      97           0 :     void ODataView::resizeDocumentView( Rectangle& /*_rPlayground*/ )
      98             :     {
      99           0 :     }
     100             : 
     101             :     // -------------------------------------------------------------------------
     102           0 :     void ODataView::Paint( const Rectangle& _rRect )
     103             :     {
     104             :         //.................................................................
     105             :         // draw the background
     106             :         {
     107           0 :             ColorChanger aColors( this, COL_TRANSPARENT, GetSettings().GetStyleSettings().GetFaceColor() );
     108           0 :             DrawRect( _rRect );
     109             :         }
     110             : 
     111             :         // let the base class do anything it needs
     112           0 :         Window::Paint( _rRect );
     113           0 :     }
     114             : 
     115             :     // -------------------------------------------------------------------------
     116           0 :     void ODataView::resizeAll( const Rectangle& _rPlayground )
     117             :     {
     118           0 :         Rectangle aPlayground( _rPlayground );
     119             : 
     120             :         // position the separator
     121           0 :         const Size aSeparatorSize = Size( aPlayground.GetWidth(), 2 );
     122           0 :         m_aSeparator.SetPosSizePixel( aPlayground.TopLeft(), aSeparatorSize );
     123           0 :         aPlayground.Top() += aSeparatorSize.Height() + 1;
     124             : 
     125             :         // position the controls of the document's view
     126           0 :         resizeDocumentView( aPlayground );
     127           0 :     }
     128             : 
     129             :     // -------------------------------------------------------------------------
     130           0 :     void ODataView::Resize()
     131             :     {
     132           0 :         Window::Resize();
     133           0 :         resizeAll( Rectangle( Point( 0, 0), GetSizePixel() ) );
     134           0 :     }
     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           0 :     void ODataView::StateChanged( StateChangedType nType )
     160             :     {
     161           0 :         Window::StateChanged( nType );
     162             : 
     163           0 :         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           0 :         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           0 :                 Reference< XController > xController( m_rController.getXController(), UNO_SET_THROW );
     176           0 :                 Reference< XModel > xModel( xController->getModel(), UNO_QUERY );
     177           0 :                 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           0 :                 }
     183             :             }
     184           0 :             catch( const Exception& )
     185             :             {
     186             :                 DBG_UNHANDLED_EXCEPTION();
     187             :             }
     188             :         }
     189           0 :     }
     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           0 :     void ODataView::attachFrame(const Reference< XFrame >& _xFrame)
     207             :     {
     208           0 :         m_pAccel->init(m_xContext, _xFrame);
     209           0 :     }
     210             : //.........................................................................
     211             : }
     212             : // namespace dbaui
     213             : //.........................................................................
     214             : 
     215             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10