1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 
31 #include "AccessibleViewForwarder.hxx"
32 #include "AccessibleChartView.hxx"
33 
34 #include <vcl/window.hxx>
35 
36 using namespace ::com::sun::star;
37 
38 
39 namespace chart
40 {
41 
42 AccessibleViewForwarder::AccessibleViewForwarder( AccessibleChartView* pAccChartView, Window* pWindow )
43     :m_pAccChartView( pAccChartView )
44     ,m_pWindow( pWindow )
45     ,m_aMapMode( MAP_100TH_MM )
46 {
47 }
48 
49 AccessibleViewForwarder::~AccessibleViewForwarder()
50 {
51 }
52 
53 // ________ IAccessibleViewforwarder ________
54 
55 sal_Bool AccessibleViewForwarder::IsValid() const
56 {
57     return sal_True;
58 }
59 
60 Rectangle AccessibleViewForwarder::GetVisibleArea() const
61 {
62     Rectangle aVisibleArea;
63     if ( m_pWindow )
64     {
65         aVisibleArea.SetPos( Point( 0, 0 ) );
66         aVisibleArea.SetSize( m_pWindow->GetOutputSizePixel() );
67         aVisibleArea = m_pWindow->PixelToLogic( aVisibleArea, m_aMapMode );
68     }
69     return aVisibleArea;
70 }
71 
72 Point AccessibleViewForwarder::LogicToPixel( const Point& rPoint ) const
73 {
74     Point aPoint;
75     if ( m_pAccChartView && m_pWindow )
76     {
77         awt::Point aLocation = m_pAccChartView->getLocationOnScreen();
78         Point aTopLeft( aLocation.X, aLocation.Y );
79         aPoint = m_pWindow->LogicToPixel( rPoint, m_aMapMode ) + aTopLeft;
80     }
81     return aPoint;
82 }
83 
84 Size AccessibleViewForwarder::LogicToPixel( const Size& rSize ) const
85 {
86     Size aSize;
87     if ( m_pWindow )
88     {
89         aSize = m_pWindow->LogicToPixel( rSize, m_aMapMode );
90     }
91     return aSize;
92 }
93 
94 Point AccessibleViewForwarder::PixelToLogic( const Point& rPoint ) const
95 {
96     Point aPoint;
97     if ( m_pAccChartView && m_pWindow )
98     {
99         awt::Point aLocation = m_pAccChartView->getLocationOnScreen();
100         Point aTopLeft( aLocation.X, aLocation.Y );
101         aPoint = m_pWindow->PixelToLogic( rPoint - aTopLeft, m_aMapMode );
102     }
103     return aPoint;
104 }
105 
106 Size AccessibleViewForwarder::PixelToLogic( const Size& rSize ) const
107 {
108     Size aSize;
109     if ( m_pWindow )
110     {
111         aSize = m_pWindow->PixelToLogic( rSize, m_aMapMode );
112     }
113     return aSize;
114 }
115 
116 } // namespace chart
117