LCOV - code coverage report
Current view: top level - sd/source/ui/accessibility - AccessibleViewForwarder.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 28 45 62.2 %
Date: 2015-06-13 12:38:46 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             : #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           3 : AccessibleViewForwarder::AccessibleViewForwarder (SdrPaintView* pView, OutputDevice& rDevice)
      35             :     : mpView (pView),
      36             :       mnWindowId (0),
      37           3 :       mrDevice (rDevice)
      38             : {
      39             :     // Search the output device to determine its id.
      40           3 :     for(sal_uInt32 a(0L); a < mpView->PaintWindowCount(); a++)
      41             :     {
      42           3 :         SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow(a);
      43           3 :         OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
      44             : 
      45           3 :         if(&rOutDev == &rDevice)
      46             :         {
      47           3 :             mnWindowId = (sal_uInt16)a;
      48           3 :             break;
      49             :         }
      50             :     }
      51           3 : }
      52             : 
      53           3 : AccessibleViewForwarder::~AccessibleViewForwarder()
      54             : {
      55             :     // empty
      56           3 : }
      57             : 
      58           0 : bool AccessibleViewForwarder::IsValid() const
      59             : {
      60           0 :     return true;
      61             : }
      62             : 
      63         458 : Rectangle AccessibleViewForwarder::GetVisibleArea() const
      64             : {
      65         458 :     Rectangle aVisibleArea;
      66             : 
      67         458 :     if((sal_uInt32)mnWindowId < mpView->PaintWindowCount())
      68             :     {
      69         458 :         SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId);
      70         458 :         aVisibleArea = pPaintWindow->GetVisibleArea();
      71             :     }
      72             : 
      73         458 :     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         850 : Point AccessibleViewForwarder::LogicToPixel (const Point& rPoint) const
      81             : {
      82             :     OSL_ASSERT (mpView != NULL);
      83         850 :     if((sal_uInt32)mnWindowId < mpView->PaintWindowCount())
      84             :     {
      85         850 :         SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId);
      86         850 :         OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
      87         850 :         Rectangle aBBox(static_cast<vcl::Window&>(rOutDev).GetWindowExtentsRelative(0L));
      88         850 :         return rOutDev.LogicToPixel (rPoint) + aBBox.TopLeft();
      89             :     }
      90             :     else
      91           0 :         return Point();
      92             : }
      93             : 
      94         212 : Size AccessibleViewForwarder::LogicToPixel (const Size& rSize) const
      95             : {
      96             :     OSL_ASSERT (mpView != NULL);
      97         212 :     if((sal_uInt32)mnWindowId < mpView->PaintWindowCount())
      98             :     {
      99         212 :         SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId);
     100         212 :         OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
     101         212 :         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             : } // end of namespace accessibility
     138             : 
     139             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11