LCOV - code coverage report
Current view: top level - sd/source/ui/accessibility - AccessibleViewForwarder.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 28 45 62.2 %
Date: 2014-04-11 Functions: 5 9 55.6 %
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 "AccessibleViewForwarder.hxx"
      22             : #include <svx/svdpntv.hxx>
      23             : #include <vcl/outdev.hxx>
      24             : #include <svx/sdrpaintwindow.hxx>
      25             : 
      26             : namespace accessibility {
      27             : 
      28             : /** For the time beeing, the implementation of this class will not use the
      29             :     member mrDevice.  Instead the device is retrieved from the view
      30             :     everytime it is used.  This is necessary because the device has to stay
      31             :     up-to-date with the current view and the class has to stay compatible.
      32             :     May change in the future.
      33             : */
      34             : 
      35           3 : AccessibleViewForwarder::AccessibleViewForwarder (SdrPaintView* pView, OutputDevice& rDevice)
      36             :     : mpView (pView),
      37             :       mnWindowId (0),
      38           3 :       mrDevice (rDevice)
      39             : {
      40             :     // Search the output device to determine its id.
      41           3 :     for(sal_uInt32 a(0L); a < mpView->PaintWindowCount(); a++)
      42             :     {
      43           3 :         SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow(a);
      44           3 :         OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
      45             : 
      46           3 :         if(&rOutDev == &rDevice)
      47             :         {
      48           3 :             mnWindowId = (sal_uInt16)a;
      49           3 :             break;
      50             :         }
      51             :     }
      52           3 : }
      53             : 
      54             : 
      55             : 
      56             : 
      57           3 : AccessibleViewForwarder::~AccessibleViewForwarder (void)
      58             : {
      59             :     // empty
      60           3 : }
      61             : 
      62             : 
      63             : 
      64             : 
      65           0 : bool AccessibleViewForwarder::IsValid (void) const
      66             : {
      67           0 :     return true;
      68             : }
      69             : 
      70             : 
      71             : 
      72             : 
      73         602 : Rectangle AccessibleViewForwarder::GetVisibleArea (void) const
      74             : {
      75         602 :     Rectangle aVisibleArea;
      76             : 
      77         602 :     if((sal_uInt32)mnWindowId < mpView->PaintWindowCount())
      78             :     {
      79         602 :         SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId);
      80         602 :         aVisibleArea = pPaintWindow->GetVisibleArea();
      81             :     }
      82             : 
      83         602 :     return aVisibleArea;
      84             : }
      85             : 
      86             : 
      87             : 
      88             : 
      89             : /** Tansform the given point into pixel coordiantes.  After the pixel
      90             :     coordiantes of the window origin are added to make the point coordinates
      91             :     absolute.
      92             : */
      93        1126 : Point AccessibleViewForwarder::LogicToPixel (const Point& rPoint) const
      94             : {
      95             :     OSL_ASSERT (mpView != NULL);
      96        1126 :     if((sal_uInt32)mnWindowId < mpView->PaintWindowCount())
      97             :     {
      98        1126 :         SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId);
      99        1126 :         OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
     100        1126 :         Rectangle aBBox(static_cast<Window&>(rOutDev).GetWindowExtentsRelative(0L));
     101        1126 :         return rOutDev.LogicToPixel (rPoint) + aBBox.TopLeft();
     102             :     }
     103             :     else
     104           0 :         return Point();
     105             : }
     106             : 
     107             : 
     108             : 
     109             : 
     110         281 : Size AccessibleViewForwarder::LogicToPixel (const Size& rSize) const
     111             : {
     112             :     OSL_ASSERT (mpView != NULL);
     113         281 :     if((sal_uInt32)mnWindowId < mpView->PaintWindowCount())
     114             :     {
     115         281 :         SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId);
     116         281 :         OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
     117         281 :         return rOutDev.LogicToPixel (rSize);
     118             :     }
     119             :     else
     120           0 :         return Size();
     121             : }
     122             : 
     123             : 
     124             : 
     125             : 
     126             : /** First subtract the window origin to make the point coordinates relative
     127             :     to the window and then transform them into internal coordinates.
     128             : */
     129           0 : Point AccessibleViewForwarder::PixelToLogic (const Point& rPoint) const
     130             : {
     131             :     OSL_ASSERT (mpView != NULL);
     132           0 :     if((sal_uInt32)mnWindowId < mpView->PaintWindowCount())
     133             :     {
     134           0 :         SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId);
     135           0 :         OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
     136           0 :         Rectangle aBBox (static_cast<Window&>(rOutDev).GetWindowExtentsRelative(0L));
     137           0 :         return rOutDev.PixelToLogic (rPoint - aBBox.TopLeft());
     138             :     }
     139             :     else
     140           0 :         return Point();
     141             : }
     142             : 
     143           0 : Size AccessibleViewForwarder::PixelToLogic (const Size& rSize) const
     144             : {
     145             :     OSL_ASSERT (mpView != NULL);
     146           0 :     if((sal_uInt32)mnWindowId < mpView->PaintWindowCount())
     147             :     {
     148           0 :         SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId);
     149           0 :         OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
     150           0 :         return rOutDev.PixelToLogic (rSize);
     151             :     }
     152             :     else
     153           0 :         return Size();
     154             : }
     155             : 
     156             : 
     157             : } // end of namespace accessibility
     158             : 
     159             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10