xref: /trunk/main/sd/source/ui/accessibility/AccessibleViewForwarder.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew 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 
3630acf5e8Spfg /** For the time being, the implementation of this class will not use the
37cdf0e10cSrcweir     member mrDevice.  Instead the device is retrieved from the view
38cdf0e10cSrcweir     every time 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 
AccessibleViewForwarder(SdrPaintView * pView,OutputDevice & rDevice)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 
~AccessibleViewForwarder(void)65cdf0e10cSrcweir AccessibleViewForwarder::~AccessibleViewForwarder (void)
66cdf0e10cSrcweir {
67cdf0e10cSrcweir     // empty
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 
IsValid(void) const73cdf0e10cSrcweir sal_Bool AccessibleViewForwarder::IsValid (void) const
74cdf0e10cSrcweir {
75cdf0e10cSrcweir     return sal_True;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 
GetVisibleArea(void) const81cdf0e10cSrcweir 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 
97*7950f2afSmseidel /** Transform the given point into pixel coordinates.  After the pixel
98*7950f2afSmseidel     coordinates of the window origin are added to make the point coordinates
99cdf0e10cSrcweir     absolute.
100cdf0e10cSrcweir */
LogicToPixel(const Point & rPoint) const101cdf0e10cSrcweir 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 
LogicToPixel(const Size & rSize) const118cdf0e10cSrcweir 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 */
PixelToLogic(const Point & rPoint) const137cdf0e10cSrcweir 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 
PixelToLogic(const Size & rSize) const154cdf0e10cSrcweir 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