1*5b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5b190011SAndrew Rist * distributed with this work for additional information 6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance 9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5b190011SAndrew Rist * software distributed under the License is distributed on an 15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the 17*5b190011SAndrew Rist * specific language governing permissions and limitations 18*5b190011SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*5b190011SAndrew Rist *************************************************************/ 21*5b190011SAndrew Rist 22*5b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef _SVX_ACCESSIBILITY_ACCESSIBLE_VIEW_FORWARDER_HXX 28cdf0e10cSrcweir #include "AccessibleViewForwarder.hxx" 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #include <svx/svdpntv.hxx> 31cdf0e10cSrcweir #include <vcl/outdev.hxx> 32cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir namespace accessibility { 35cdf0e10cSrcweir 36cdf0e10cSrcweir /** For the time beeing, the implementation of this class will not use the 37cdf0e10cSrcweir member mrDevice. Instead the device is retrieved from the view 38cdf0e10cSrcweir everytime it is used. This is necessary because the device has to stay 39cdf0e10cSrcweir up-to-date with the current view and the class has to stay compatible. 40cdf0e10cSrcweir May change in the future. 41cdf0e10cSrcweir */ 42cdf0e10cSrcweir 43cdf0e10cSrcweir AccessibleViewForwarder::AccessibleViewForwarder (SdrPaintView* pView, OutputDevice& rDevice) 44cdf0e10cSrcweir : mpView (pView), 45cdf0e10cSrcweir mnWindowId (0), 46cdf0e10cSrcweir mrDevice (rDevice) 47cdf0e10cSrcweir { 48cdf0e10cSrcweir // Search the output device to determine its id. 49cdf0e10cSrcweir for(sal_uInt32 a(0L); a < mpView->PaintWindowCount(); a++) 50cdf0e10cSrcweir { 51cdf0e10cSrcweir SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow(a); 52cdf0e10cSrcweir OutputDevice& rOutDev = pPaintWindow->GetOutputDevice(); 53cdf0e10cSrcweir 54cdf0e10cSrcweir if(&rOutDev == &rDevice) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir mnWindowId = (sal_uInt16)a; 57cdf0e10cSrcweir break; 58cdf0e10cSrcweir } 59cdf0e10cSrcweir } 60cdf0e10cSrcweir } 61cdf0e10cSrcweir 62cdf0e10cSrcweir 63cdf0e10cSrcweir 64cdf0e10cSrcweir 65cdf0e10cSrcweir AccessibleViewForwarder::~AccessibleViewForwarder (void) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir // empty 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir 71cdf0e10cSrcweir 72cdf0e10cSrcweir 73cdf0e10cSrcweir sal_Bool AccessibleViewForwarder::IsValid (void) const 74cdf0e10cSrcweir { 75cdf0e10cSrcweir return sal_True; 76cdf0e10cSrcweir } 77cdf0e10cSrcweir 78cdf0e10cSrcweir 79cdf0e10cSrcweir 80cdf0e10cSrcweir 81cdf0e10cSrcweir Rectangle AccessibleViewForwarder::GetVisibleArea (void) const 82cdf0e10cSrcweir { 83cdf0e10cSrcweir Rectangle aVisibleArea; 84cdf0e10cSrcweir 85cdf0e10cSrcweir if((sal_uInt32)mnWindowId < mpView->PaintWindowCount()) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId); 88cdf0e10cSrcweir aVisibleArea = pPaintWindow->GetVisibleArea(); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir return aVisibleArea; 92cdf0e10cSrcweir } 93cdf0e10cSrcweir 94cdf0e10cSrcweir 95cdf0e10cSrcweir 96cdf0e10cSrcweir 97cdf0e10cSrcweir /** Tansform the given point into pixel coordiantes. After the the pixel 98cdf0e10cSrcweir coordiantes of the window origin are added to make the point coordinates 99cdf0e10cSrcweir absolute. 100cdf0e10cSrcweir */ 101cdf0e10cSrcweir Point AccessibleViewForwarder::LogicToPixel (const Point& rPoint) const 102cdf0e10cSrcweir { 103cdf0e10cSrcweir OSL_ASSERT (mpView != NULL); 104cdf0e10cSrcweir if((sal_uInt32)mnWindowId < mpView->PaintWindowCount()) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId); 107cdf0e10cSrcweir OutputDevice& rOutDev = pPaintWindow->GetOutputDevice(); 108cdf0e10cSrcweir Rectangle aBBox(static_cast<Window&>(rOutDev).GetWindowExtentsRelative(0L)); 109cdf0e10cSrcweir return rOutDev.LogicToPixel (rPoint) + aBBox.TopLeft(); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir else 112cdf0e10cSrcweir return Point(); 113cdf0e10cSrcweir } 114cdf0e10cSrcweir 115cdf0e10cSrcweir 116cdf0e10cSrcweir 117cdf0e10cSrcweir 118cdf0e10cSrcweir Size AccessibleViewForwarder::LogicToPixel (const Size& rSize) const 119cdf0e10cSrcweir { 120cdf0e10cSrcweir OSL_ASSERT (mpView != NULL); 121cdf0e10cSrcweir if((sal_uInt32)mnWindowId < mpView->PaintWindowCount()) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId); 124cdf0e10cSrcweir OutputDevice& rOutDev = pPaintWindow->GetOutputDevice(); 125cdf0e10cSrcweir return rOutDev.LogicToPixel (rSize); 126cdf0e10cSrcweir } 127cdf0e10cSrcweir else 128cdf0e10cSrcweir return Size(); 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir 132cdf0e10cSrcweir 133cdf0e10cSrcweir 134cdf0e10cSrcweir /** First subtract the window origin to make the point coordinates relative 135cdf0e10cSrcweir to the window and then transform them into internal coordinates. 136cdf0e10cSrcweir */ 137cdf0e10cSrcweir Point AccessibleViewForwarder::PixelToLogic (const Point& rPoint) const 138cdf0e10cSrcweir { 139cdf0e10cSrcweir OSL_ASSERT (mpView != NULL); 140cdf0e10cSrcweir if((sal_uInt32)mnWindowId < mpView->PaintWindowCount()) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId); 143cdf0e10cSrcweir OutputDevice& rOutDev = pPaintWindow->GetOutputDevice(); 144cdf0e10cSrcweir Rectangle aBBox (static_cast<Window&>(rOutDev).GetWindowExtentsRelative(0L)); 145cdf0e10cSrcweir return rOutDev.PixelToLogic (rPoint - aBBox.TopLeft()); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir else 148cdf0e10cSrcweir return Point(); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir 151cdf0e10cSrcweir 152cdf0e10cSrcweir 153cdf0e10cSrcweir 154cdf0e10cSrcweir Size AccessibleViewForwarder::PixelToLogic (const Size& rSize) const 155cdf0e10cSrcweir { 156cdf0e10cSrcweir OSL_ASSERT (mpView != NULL); 157cdf0e10cSrcweir if((sal_uInt32)mnWindowId < mpView->PaintWindowCount()) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow((sal_uInt32)mnWindowId); 160cdf0e10cSrcweir OutputDevice& rOutDev = pPaintWindow->GetOutputDevice(); 161cdf0e10cSrcweir return rOutDev.PixelToLogic (rSize); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir else 164cdf0e10cSrcweir return Size(); 165cdf0e10cSrcweir } 166cdf0e10cSrcweir 167cdf0e10cSrcweir 168cdf0e10cSrcweir } // end of namespace accessibility 169