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

Generated by: LCOV version 1.10