LCOV - code coverage report
Current view: top level - sd/source/ui/accessibility - AccessibleOutlineEditSource.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 82 1.2 %
Date: 2015-06-13 12:38:46 Functions: 2 18 11.1 %
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 <editeng/unoedhlp.hxx>
      21             : #include <svx/svdoutl.hxx>
      22             : 
      23             : #include <AccessibleOutlineEditSource.hxx>
      24             : #include "OutlineView.hxx"
      25             : #include <svx/sdrpaintwindow.hxx>
      26             : 
      27             : namespace accessibility
      28             : {
      29             : 
      30           0 :     AccessibleOutlineEditSource::AccessibleOutlineEditSource(
      31             :         SdrOutliner&    rOutliner,
      32             :         SdrView&        rView,
      33             :         OutlinerView& rOutlView,
      34             :         const vcl::Window& rViewWindow )
      35             :         : mrView( rView ),
      36             :           mrWindow( rViewWindow ),
      37             :           mpOutliner( &rOutliner ),
      38             :           mpOutlinerView( &rOutlView ),
      39             :           mTextForwarder( rOutliner, false ),
      40           0 :           mViewForwarder( rOutlView )
      41             :     {
      42             :         // register as listener - need to broadcast state change messages
      43             :         // Moved to ::GetTextForwarder()
      44             :         //rOutliner.SetNotifyHdl( LINK(this, AccessibleOutlineEditSource, NotifyHdl) );
      45           0 :         StartListening(rOutliner);
      46           0 :     }
      47             : 
      48           0 :     AccessibleOutlineEditSource::~AccessibleOutlineEditSource()
      49             :     {
      50           0 :         if( mpOutliner )
      51           0 :             mpOutliner->SetNotifyHdl( Link<>() );
      52           0 :         Broadcast( TextHint( SFX_HINT_DYING ) );
      53           0 :     }
      54             : 
      55           0 :     SvxEditSource* AccessibleOutlineEditSource::Clone() const
      56             :     {
      57           0 :         return new AccessibleOutlineEditSource(*mpOutliner, mrView, *mpOutlinerView, mrWindow);
      58             :     }
      59             : 
      60           0 :     SvxTextForwarder* AccessibleOutlineEditSource::GetTextForwarder()
      61             :     {
      62             :         // TODO: maybe suboptimal
      63           0 :         if( IsValid() )
      64             :         {
      65             :             // Moved here to make sure that
      66             :             // the NotifyHandler was set on the current object.
      67           0 :             mpOutliner->SetNotifyHdl( LINK(this, AccessibleOutlineEditSource, NotifyHdl) );
      68           0 :             return &mTextForwarder;
      69             :         }
      70             :         else
      71           0 :             return NULL;
      72             :     }
      73             : 
      74           0 :     SvxViewForwarder* AccessibleOutlineEditSource::GetViewForwarder()
      75             :     {
      76             :         // TODO: maybe suboptimal
      77           0 :         if( IsValid() )
      78           0 :             return this;
      79             :         else
      80           0 :             return NULL;
      81             :     }
      82             : 
      83           0 :     SvxEditViewForwarder* AccessibleOutlineEditSource::GetEditViewForwarder( bool )
      84             :     {
      85             :         // TODO: maybe suboptimal
      86           0 :         if( IsValid() )
      87             :         {
      88             :             // ignore parameter, we're always in edit mode here
      89           0 :             return &mViewForwarder;
      90             :         }
      91             :         else
      92           0 :             return NULL;
      93             :     }
      94             : 
      95           0 :     void AccessibleOutlineEditSource::UpdateData()
      96             :     {
      97             :         // NOOP, since we're always working on the 'real' outliner,
      98             :         // i.e. changes are immediately reflected on the screen
      99           0 :     }
     100             : 
     101           0 :     SfxBroadcaster& AccessibleOutlineEditSource::GetBroadcaster() const
     102             :     {
     103           0 :         return *( const_cast< AccessibleOutlineEditSource* > (this) );
     104             :     }
     105             : 
     106           0 :     bool AccessibleOutlineEditSource::IsValid() const
     107             :     {
     108           0 :         if( mpOutliner && mpOutlinerView )
     109             :         {
     110             :             // Our view still on outliner?
     111             :             sal_uLong nCurrView, nViews;
     112             : 
     113           0 :             for( nCurrView=0, nViews=mpOutliner->GetViewCount(); nCurrView<nViews; ++nCurrView )
     114             :             {
     115           0 :                 if( mpOutliner->GetView(nCurrView) == mpOutlinerView )
     116           0 :                     return true;
     117             :             }
     118             :         }
     119             : 
     120           0 :         return false;
     121             :     }
     122             : 
     123           0 :     Rectangle AccessibleOutlineEditSource::GetVisArea() const
     124             :     {
     125           0 :         if( IsValid() )
     126             :         {
     127           0 :             SdrPaintWindow* pPaintWindow = mrView.FindPaintWindow(mrWindow);
     128           0 :             Rectangle aVisArea;
     129             : 
     130           0 :             if(pPaintWindow)
     131             :             {
     132           0 :                 aVisArea = pPaintWindow->GetVisibleArea();
     133             :             }
     134             : 
     135           0 :             MapMode aMapMode(mrWindow.GetMapMode());
     136           0 :             aMapMode.SetOrigin(Point());
     137           0 :             return mrWindow.LogicToPixel( aVisArea, aMapMode );
     138             :         }
     139             : 
     140           0 :         return Rectangle();
     141             :     }
     142             : 
     143           0 :     Point AccessibleOutlineEditSource::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
     144             :     {
     145           0 :         if( IsValid() && mrView.GetModel() )
     146             :         {
     147             :             Point aPoint( OutputDevice::LogicToLogic( rPoint, rMapMode,
     148           0 :                                                       MapMode(mrView.GetModel()->GetScaleUnit()) ) );
     149           0 :             MapMode aMapMode(mrWindow.GetMapMode());
     150           0 :             aMapMode.SetOrigin(Point());
     151           0 :             return mrWindow.LogicToPixel( aPoint, aMapMode );
     152             :         }
     153             : 
     154           0 :         return Point();
     155             :     }
     156             : 
     157           0 :     Point AccessibleOutlineEditSource::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
     158             :     {
     159           0 :         if( IsValid() && mrView.GetModel() )
     160             :         {
     161           0 :             MapMode aMapMode(mrWindow.GetMapMode());
     162           0 :             aMapMode.SetOrigin(Point());
     163           0 :             Point aPoint( mrWindow.PixelToLogic( rPoint, aMapMode ) );
     164             :             return OutputDevice::LogicToLogic( aPoint,
     165             :                                                MapMode(mrView.GetModel()->GetScaleUnit()),
     166           0 :                                                rMapMode );
     167             :         }
     168             : 
     169           0 :         return Point();
     170             :     }
     171             : 
     172           0 :     void AccessibleOutlineEditSource::Notify( SfxBroadcaster& rBroadcaster, const SfxHint& rHint )
     173             :     {
     174           0 :         bool bDispose = false;
     175             : 
     176           0 :         if( &rBroadcaster == mpOutliner )
     177             :         {
     178           0 :             const SfxSimpleHint* pHint = dynamic_cast< const SfxSimpleHint * >( &rHint );
     179           0 :             if( pHint && (pHint->GetId() == SFX_HINT_DYING) )
     180             :             {
     181           0 :                 bDispose = true;
     182           0 :                 mpOutliner = NULL;
     183             :             }
     184             :         }
     185             :         else
     186             :         {
     187           0 :             const SdrHint* pSdrHint = dynamic_cast< const SdrHint* >( &rHint );
     188             : 
     189           0 :             if( pSdrHint && ( pSdrHint->GetKind() == HINT_MODELCLEARED ) )
     190             :             {
     191             :                 // model is dying under us, going defunc
     192           0 :                 bDispose = true;
     193             :             }
     194             :         }
     195             : 
     196           0 :         if( bDispose )
     197             :         {
     198           0 :             if( mpOutliner )
     199           0 :                 mpOutliner->SetNotifyHdl( Link<>() );
     200           0 :             mpOutliner = NULL;
     201           0 :             mpOutlinerView = NULL;
     202           0 :             Broadcast( TextHint( SFX_HINT_DYING ) );
     203             :         }
     204           0 :     }
     205             : 
     206           0 :     IMPL_LINK(AccessibleOutlineEditSource, NotifyHdl, EENotify*, aNotify)
     207             :     {
     208           0 :         if( aNotify )
     209             :         {
     210           0 :             ::std::unique_ptr< SfxHint > aHint( SvxEditSourceHelper::EENotification2Hint( aNotify) );
     211             : 
     212           0 :             if( aHint.get() )
     213           0 :                 Broadcast( *aHint.get() );
     214             :         }
     215             : 
     216           0 :         return 0;
     217             :     }
     218             : 
     219          66 : } // end of namespace accessibility
     220             : 
     221             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11