LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/accessibility - AccessibleViewForwarder.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 45 0.0 %
Date: 2012-12-27 Functions: 0 9 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             : 
      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           0 : AccessibleViewForwarder::AccessibleViewForwarder (SdrPaintView* pView, OutputDevice& rDevice)
      36             :     : mpView (pView),
      37             :       mnWindowId (0),
      38           0 :       mrDevice (rDevice)
      39             : {
      40             :     // Search the output device to determine its id.
      41           0 :     for(sal_uInt32 a(0L); a < mpView->PaintWindowCount(); a++)
      42             :     {
      43           0 :         SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow(a);
      44           0 :         OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
      45             : 
      46           0 :         if(&rOutDev == &rDevice)
      47             :         {
      48           0 :             mnWindowId = (sal_uInt16)a;
      49           0 :             break;
      50             :         }
      51             :     }
      52           0 : }
      53             : 
      54             : 
      55             : 
      56             : 
      57           0 : AccessibleViewForwarder::~AccessibleViewForwarder (void)
      58             : {
      59             :     // empty
      60           0 : }
      61             : 
      62             : 
      63             : 
      64             : 
      65           0 : sal_Bool AccessibleViewForwarder::IsValid (void) const
      66             : {
      67           0 :     return sal_True;
      68             : }
      69             : 
      70             : 
      71             : 
      72             : 
      73           0 : Rectangle AccessibleViewForwarder::GetVisibleArea (void) const
      74             : {
      75           0 :     Rectangle aVisibleArea;
      76             : 
      77           0 :     if((sal_uInt32)mnWindowId < mpView->PaintWindowCount())
      78             :     {
      79           0 :         SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId);
      80           0 :         aVisibleArea = pPaintWindow->GetVisibleArea();
      81             :     }
      82             : 
      83           0 :     return aVisibleArea;
      84             : }
      85             : 
      86             : 
      87             : 
      88             : 
      89             : /** Tansform the given point into pixel coordiantes.  After the the pixel
      90             :     coordiantes of the window origin are added to make the point coordinates
      91             :     absolute.
      92             : */
      93           0 : Point AccessibleViewForwarder::LogicToPixel (const Point& rPoint) const
      94             : {
      95             :     OSL_ASSERT (mpView != NULL);
      96           0 :     if((sal_uInt32)mnWindowId < mpView->PaintWindowCount())
      97             :     {
      98           0 :         SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId);
      99           0 :         OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
     100           0 :         Rectangle aBBox(static_cast<Window&>(rOutDev).GetWindowExtentsRelative(0L));
     101           0 :         return rOutDev.LogicToPixel (rPoint) + aBBox.TopLeft();
     102             :     }
     103             :     else
     104           0 :         return Point();
     105             : }
     106             : 
     107             : 
     108             : 
     109             : 
     110           0 : Size AccessibleViewForwarder::LogicToPixel (const Size& rSize) 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 :         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