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

Generated by: LCOV version 1.10