LCOV - code coverage report
Current view: top level - dbaccess/source/ui/browser - dataview.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 48 74 64.9 %
Date: 2012-08-25 Functions: 10 14 71.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 23 93 24.7 %

           Branch data     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                 :         10 :         ColorChanger( OutputDevice* _pDev, const Color& _rNewLineColor, const Color& _rNewFillColor )
      53                 :         10 :             :m_pDev( _pDev )
      54                 :            :         {
      55                 :         10 :             m_pDev->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
      56                 :         10 :             m_pDev->SetLineColor( _rNewLineColor );
      57                 :         10 :             m_pDev->SetFillColor( _rNewFillColor );
      58                 :         10 :         }
      59                 :            : 
      60                 :         10 :         ~ColorChanger()
      61                 :            :         {
      62                 :         10 :             m_pDev->Pop();
      63                 :         10 :         }
      64                 :            :     };
      65                 :            : 
      66                 :            :     DBG_NAME(ODataView)
      67                 :            :     // -------------------------------------------------------------------------
      68                 :          2 :     ODataView::ODataView(   Window* pParent,
      69                 :            :                             IController& _rController,
      70                 :            :                             const Reference< XMultiServiceFactory >& _rFactory,
      71                 :            :                             WinBits nStyle)
      72                 :            :         :Window(pParent,nStyle)
      73                 :            :         ,m_xServiceFactory(_rFactory)
      74                 :            :         ,m_rController( _rController )
      75         [ +  - ]:          2 :         ,m_aSeparator( this )
      76                 :            :     {
      77                 :            :         DBG_CTOR(ODataView,NULL);
      78                 :          2 :         m_rController.acquire();
      79         [ +  - ]:          2 :         m_pAccel.reset(::svt::AcceleratorExecute::createAcceleratorHelper());
      80         [ +  - ]:          2 :         m_aSeparator.Show();
      81                 :          2 :     }
      82                 :            : 
      83                 :            :     // -------------------------------------------------------------------------
      84                 :          4 :     void ODataView::Construct()
      85                 :            :     {
      86                 :          4 :     }
      87                 :            : 
      88                 :            :     // -------------------------------------------------------------------------
      89 [ +  - ][ +  - ]:          2 :     ODataView::~ODataView()
      90                 :            :     {
      91                 :            :         DBG_DTOR(ODataView,NULL);
      92                 :            : 
      93                 :          2 :         m_rController.release();
      94         [ -  + ]:          2 :     }
      95                 :            : 
      96                 :            :     // -------------------------------------------------------------------------
      97                 :          0 :     void ODataView::resizeDocumentView( Rectangle& /*_rPlayground*/ )
      98                 :            :     {
      99                 :          0 :     }
     100                 :            : 
     101                 :            :     // -------------------------------------------------------------------------
     102                 :         10 :     void ODataView::Paint( const Rectangle& _rRect )
     103                 :            :     {
     104                 :            :         //.................................................................
     105                 :            :         // draw the background
     106                 :            :         {
     107         [ +  - ]:         10 :             ColorChanger aColors( this, COL_TRANSPARENT, GetSettings().GetStyleSettings().GetFaceColor() );
     108 [ +  - ][ +  - ]:         10 :             DrawRect( _rRect );
     109                 :            :         }
     110                 :            : 
     111                 :            :         // let the base class do anything it needs
     112                 :         10 :         Window::Paint( _rRect );
     113                 :         10 :     }
     114                 :            : 
     115                 :            :     // -------------------------------------------------------------------------
     116                 :         18 :     void ODataView::resizeAll( const Rectangle& _rPlayground )
     117                 :            :     {
     118                 :         18 :         Rectangle aPlayground( _rPlayground );
     119                 :            : 
     120                 :            :         // position the separator
     121         [ +  - ]:         18 :         const Size aSeparatorSize = Size( aPlayground.GetWidth(), 2 );
     122         [ +  - ]:         18 :         m_aSeparator.SetPosSizePixel( aPlayground.TopLeft(), aSeparatorSize );
     123                 :         18 :         aPlayground.Top() += aSeparatorSize.Height() + 1;
     124                 :            : 
     125                 :            :         // position the controls of the document's view
     126         [ +  - ]:         18 :         resizeDocumentView( aPlayground );
     127                 :         18 :     }
     128                 :            : 
     129                 :            :     // -------------------------------------------------------------------------
     130                 :         18 :     void ODataView::Resize()
     131                 :            :     {
     132                 :         18 :         Window::Resize();
     133 [ +  - ][ +  - ]:         18 :         resizeAll( Rectangle( Point( 0, 0), GetSizePixel() ) );
     134                 :         18 :     }
     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                 :          4 :     void ODataView::StateChanged( StateChangedType nType )
     160                 :            :     {
     161                 :          4 :         Window::StateChanged( nType );
     162                 :            : 
     163         [ -  + ]:          4 :         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         [ +  + ]:          4 :         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 [ +  - ][ +  - ]:          2 :                 Reference< XController > xController( m_rController.getXController(), UNO_SET_THROW );
     176 [ +  - ][ +  - ]:          2 :                 Reference< XModel > xModel( xController->getModel(), UNO_QUERY );
                 [ +  - ]
     177         [ -  + ]:          2 :                 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         [ #  # ]:          2 :                 }
     183                 :            :             }
     184                 :          0 :             catch( const Exception& )
     185                 :            :             {
     186                 :            :                 DBG_UNHANDLED_EXCEPTION();
     187                 :            :             }
     188                 :            :         }
     189                 :          4 :     }
     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                 :          2 :     void ODataView::attachFrame(const Reference< XFrame >& _xFrame)
     207                 :            :     {
     208                 :          2 :         m_pAccel->init(m_xServiceFactory,_xFrame);
     209                 :          2 :     }
     210                 :            : //.........................................................................
     211                 :            : }
     212                 :            : // namespace dbaui
     213                 :            : //.........................................................................
     214                 :            : 
     215                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10