tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / sd / source / ui / accessibility / AccessibleViewForwarder.cxx
blobaf489866fd4e2ae9be1e5ef2ef115bf43b9d6933
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <AccessibleViewForwarder.hxx>
21 #include <svx/svdpntv.hxx>
22 #include <vcl/window.hxx>
23 #include <svx/sdrpaintwindow.hxx>
24 #include <osl/diagnose.h>
26 namespace accessibility
28 /** For the time being, the implementation of this class will not use the
29 member mrDevice. Instead the device is retrieved from the view
30 every time 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.
35 AccessibleViewForwarder::AccessibleViewForwarder(SdrPaintView* pView, const OutputDevice& rDevice)
36 : mpView(pView)
37 , mnWindowId(0)
39 // Search the output device to determine its id.
40 for (sal_uInt32 a(0); a < mpView->PaintWindowCount(); a++)
42 SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow(a);
43 OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
45 if (&rOutDev == &rDevice)
47 mnWindowId = static_cast<sal_uInt16>(a);
48 break;
53 AccessibleViewForwarder::~AccessibleViewForwarder()
55 // empty
58 ::tools::Rectangle AccessibleViewForwarder::GetVisibleArea() const
60 ::tools::Rectangle aVisibleArea;
62 if (static_cast<sal_uInt32>(mnWindowId) < mpView->PaintWindowCount())
64 SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow(static_cast<sal_uInt32>(mnWindowId));
65 aVisibleArea = pPaintWindow->GetVisibleArea();
68 return aVisibleArea;
71 /** Transform the given point into pixel coordinates. After the pixel
72 coordinates of the window origin are added to make the point coordinates
73 absolute.
75 Point AccessibleViewForwarder::LogicToPixel(const Point& rPoint) const
77 assert(mpView != nullptr);
78 if (static_cast<sal_uInt32>(mnWindowId) < mpView->PaintWindowCount())
80 SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow(static_cast<sal_uInt32>(mnWindowId));
81 OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
82 ::tools::Rectangle aBBox(rOutDev.GetOwnerWindow()->GetWindowExtentsAbsolute());
83 return rOutDev.LogicToPixel(rPoint) + aBBox.TopLeft();
85 else
86 return Point();
89 Size AccessibleViewForwarder::LogicToPixel(const Size& rSize) const
91 assert(mpView != nullptr);
92 if (static_cast<sal_uInt32>(mnWindowId) < mpView->PaintWindowCount())
94 SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow(static_cast<sal_uInt32>(mnWindowId));
95 OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
96 return rOutDev.LogicToPixel(rSize);
98 else
99 return Size();
102 } // end of namespace accessibility
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */