fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / querydesign / ConnectionLineAccess.cxx
blob9b584be0715b6b93757b9a526ba17e9963dff33d
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 "ConnectionLineAccess.hxx"
21 #include "JoinTableView.hxx"
22 #include <com/sun/star/accessibility/AccessibleRole.hpp>
23 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
24 #include <toolkit/awt/vclxwindow.hxx>
25 #include "TableConnection.hxx"
26 #include "TableWindow.hxx"
27 #include <comphelper/uno3.hxx>
28 #include "JoinDesignView.hxx"
29 #include "JoinController.hxx"
30 #include <comphelper/sequence.hxx>
32 namespace dbaui
34 using namespace ::com::sun::star::accessibility;
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::beans;
37 using namespace ::com::sun::star::lang;
38 using namespace ::com::sun::star;
40 OConnectionLineAccess::OConnectionLineAccess(OTableConnection* _pLine)
41 : VCLXAccessibleComponent(_pLine->GetComponentInterface().is() ? _pLine->GetWindowPeer() : NULL)
42 ,m_pLine(_pLine)
45 void SAL_CALL OConnectionLineAccess::disposing()
47 m_pLine = NULL;
48 VCLXAccessibleComponent::disposing();
50 Any SAL_CALL OConnectionLineAccess::queryInterface( const Type& aType ) throw (RuntimeException, std::exception)
52 Any aRet(VCLXAccessibleComponent::queryInterface( aType ));
53 return aRet.hasValue() ? aRet : OConnectionLineAccess_BASE::queryInterface( aType );
55 Sequence< Type > SAL_CALL OConnectionLineAccess::getTypes( ) throw (RuntimeException, std::exception)
57 return ::comphelper::concatSequences(VCLXAccessibleComponent::getTypes(),OConnectionLineAccess_BASE::getTypes());
59 OUString SAL_CALL OConnectionLineAccess::getImplementationName() throw(RuntimeException, std::exception)
61 return getImplementationName_Static();
63 // XServiceInfo - static methods
64 OUString OConnectionLineAccess::getImplementationName_Static() throw( RuntimeException )
66 return OUString("org.openoffice.comp.dbu.ConnectionLineAccessibility");
68 // XAccessibleContext
69 sal_Int32 SAL_CALL OConnectionLineAccess::getAccessibleChildCount( ) throw (RuntimeException, std::exception)
71 return 0;
73 Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleChild( sal_Int32 /*i*/ ) throw (RuntimeException, std::exception)
75 return Reference< XAccessible >();
77 sal_Int32 SAL_CALL OConnectionLineAccess::getAccessibleIndexInParent( ) throw (RuntimeException, std::exception)
79 ::osl::MutexGuard aGuard( m_aMutex );
80 sal_Int32 nIndex = -1;
81 if( m_pLine )
83 // search the position of our table window in the table window map
84 nIndex = m_pLine->GetParent()->GetTabWinMap().size();
85 const auto& rVec = m_pLine->GetParent()->getTableConnections();
86 auto aIter = rVec.begin();
87 auto aEnd = rVec.end();
88 for (; aIter != aEnd && (*aIter).get() != m_pLine; ++nIndex,++aIter)
90 nIndex = ( aIter != aEnd ) ? nIndex : -1;
92 return nIndex;
94 sal_Int16 SAL_CALL OConnectionLineAccess::getAccessibleRole( ) throw (RuntimeException, std::exception)
96 return AccessibleRole::UNKNOWN; // ? or may be an AccessibleRole::WINDOW
98 OUString SAL_CALL OConnectionLineAccess::getAccessibleDescription( ) throw (RuntimeException, std::exception)
100 return OUString("Relation");
102 Reference< XAccessibleRelationSet > SAL_CALL OConnectionLineAccess::getAccessibleRelationSet( ) throw (RuntimeException, std::exception)
104 ::osl::MutexGuard aGuard( m_aMutex );
105 return this;
107 // XAccessibleComponent
108 Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleAtPoint( const awt::Point& /*_aPoint*/ ) throw (RuntimeException, std::exception)
110 return Reference< XAccessible >();
112 awt::Rectangle SAL_CALL OConnectionLineAccess::getBounds( ) throw (RuntimeException, std::exception)
114 ::osl::MutexGuard aGuard( m_aMutex );
115 Rectangle aRect(m_pLine ? m_pLine->GetBoundingRect() : Rectangle());
116 return awt::Rectangle(aRect.getX(),aRect.getY(),aRect.getWidth(),aRect.getHeight());
118 awt::Point SAL_CALL OConnectionLineAccess::getLocation( ) throw (RuntimeException, std::exception)
120 ::osl::MutexGuard aGuard( m_aMutex );
121 Point aPoint(m_pLine ? m_pLine->GetBoundingRect().TopLeft() : Point());
122 return awt::Point(aPoint.X(),aPoint.Y());
124 awt::Point SAL_CALL OConnectionLineAccess::getLocationOnScreen( ) throw (RuntimeException, std::exception)
126 ::osl::MutexGuard aGuard( m_aMutex );
127 Point aPoint(m_pLine ? m_pLine->GetParent()->ScreenToOutputPixel(m_pLine->GetBoundingRect().TopLeft()) : Point());
128 return awt::Point(aPoint.X(),aPoint.Y());
130 awt::Size SAL_CALL OConnectionLineAccess::getSize( ) throw (RuntimeException, std::exception)
132 ::osl::MutexGuard aGuard( m_aMutex );
133 Size aSize(m_pLine ? m_pLine->GetBoundingRect().GetSize() : Size());
134 return awt::Size(aSize.Width(),aSize.Height());
136 // XAccessibleRelationSet
137 sal_Int32 SAL_CALL OConnectionLineAccess::getRelationCount( ) throw (RuntimeException, std::exception)
139 return 1;
141 AccessibleRelation SAL_CALL OConnectionLineAccess::getRelation( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
143 ::osl::MutexGuard aGuard( m_aMutex );
144 if( nIndex < 0 || nIndex >= getRelationCount() )
145 throw IndexOutOfBoundsException();
147 Sequence< Reference<XInterface> > aSeq(m_pLine ? 2 : 0);
148 if( m_pLine )
150 aSeq[0] = m_pLine->GetSourceWin()->GetAccessible();
151 aSeq[1] = m_pLine->GetDestWin()->GetAccessible();
154 return AccessibleRelation(AccessibleRelationType::CONTROLLED_BY,aSeq);
156 sal_Bool SAL_CALL OConnectionLineAccess::containsRelation( sal_Int16 aRelationType ) throw (RuntimeException, std::exception)
158 return AccessibleRelationType::CONTROLLED_BY == aRelationType;
160 AccessibleRelation SAL_CALL OConnectionLineAccess::getRelationByType( sal_Int16 aRelationType ) throw (RuntimeException, std::exception)
162 if( AccessibleRelationType::CONTROLLED_BY == aRelationType )
163 return getRelation(0);
164 return AccessibleRelation();
166 Reference< XAccessible > OTableConnection::CreateAccessible()
168 return new OConnectionLineAccess(this);
170 OTableConnection::~OTableConnection()
172 disposeOnce();
174 void OTableConnection::dispose()
176 // clear vector
177 clearLineData();
178 m_pParent.clear();
179 vcl::Window::dispose();
181 Reference< XAccessibleContext > SAL_CALL OConnectionLineAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
183 return this;
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */