LibreOffice Module sw (master)  1
SidebarWinAcc.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include "SidebarWinAcc.hxx"
21 #include <AnnotationWin.hxx>
22 
23 #include <viewsh.hxx>
24 #include <accmap.hxx>
26 
27 #include <com/sun/star/accessibility/AccessibleRole.hpp>
28 
29 namespace sw { namespace sidebarwindows {
30 
31 // declaration and implementation of accessible context for <SidebarWinAccessible> instance
33 {
34  public:
36  SwViewShell& rViewShell,
37  const SwFrame* pAnchorFrame )
38  : VCLXAccessibleComponent( rSidebarWin.GetWindowPeer() )
39  , mrViewShell( rViewShell )
40  , mpAnchorFrame( pAnchorFrame )
41  , maMutex()
42  {
43  rSidebarWin.SetAccessibleRole( css::accessibility::AccessibleRole::COMMENT );
44  }
45 
46  void ChangeAnchor( const SwFrame* pAnchorFrame )
47  {
48  osl::MutexGuard aGuard(maMutex);
49 
50  mpAnchorFrame = pAnchorFrame;
51  }
52 
53  virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
55  {
56  osl::MutexGuard aGuard(maMutex);
57 
58  css::uno::Reference< css::accessibility::XAccessible > xAccParent;
59 
60  if ( mpAnchorFrame &&
62  {
63  xAccParent = mrViewShell.GetAccessibleMap()->GetContext( mpAnchorFrame, false );
64  }
65 
66  return xAccParent;
67  }
68 
69  virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override
70  {
71  osl::MutexGuard aGuard(maMutex);
72 
73  sal_Int32 nIndex( -1 );
74 
75  if ( mpAnchorFrame && GetWindow() &&
77  {
79  *GetWindow() );
80  }
81 
82  return nIndex;
83  }
84 
85  private:
88 
89  ::osl::Mutex maMutex;
90 };
91 
92 // implementation of accessible for <SwAnnotationWin> instance
94  SwViewShell& rViewShell,
95  const SwSidebarItem& rSidebarItem )
96  : VCLXWindow()
97  , mrSidebarWin( rSidebarWin )
98  , mrViewShell( rViewShell )
99  , mpAnchorFrame( rSidebarItem.maLayoutInfo.mpAnchorFrame )
100  , bAccContextCreated( false )
101 {
103 }
104 
106 {
107 }
108 
110 {
111  if ( bAccContextCreated )
112  {
113  css::uno::Reference< css::accessibility::XAccessibleContext > xAcc
115  if ( xAcc.is() )
116  {
117  SidebarWinAccessibleContext* pAccContext =
118  dynamic_cast<SidebarWinAccessibleContext*>(xAcc.get());
119  if ( pAccContext )
120  {
121  pAccContext->ChangeAnchor( rSidebarItem.maLayoutInfo.mpAnchorFrame );
122  }
123  }
124  }
125 }
126 
127 css::uno::Reference< css::accessibility::XAccessibleContext > SidebarWinAccessible::CreateAccessibleContext()
128 {
129  SidebarWinAccessibleContext* pAccContext =
131  mrViewShell,
132  mpAnchorFrame );
133  css::uno::Reference< css::accessibility::XAccessibleContext > xAcc( pAccContext );
134  bAccContextCreated = true;
135  return xAcc;
136 }
137 
138 } } // end of namespace sw::sidebarwindows
139 
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class of the Writer layout elements.
Definition: frame.hxx:295
const SwFrame * mpAnchorFrame
sal_Int32 GetChildIndex(const SwFrame &rParentFrame, vcl::Window &rChild) const
Definition: accmap.cxx:2895
virtual css::uno::Reference< css::accessibility::XAccessibleContext > CreateAccessibleContext() override
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:40
void ChangeSidebarItem(const SwSidebarItem &rSidebarItem)
SwAccessibleMap * GetAccessibleMap()
Definition: viewsh.cxx:2457
void ChangeAnchor(const SwFrame *pAnchorFrame)
css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
SidebarWinAccessibleContext(sw::annotation::SwAnnotationWin &rSidebarWin, SwViewShell &rViewShell, const SwFrame *pAnchorFrame)
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
VclPtr< vcl::Window > GetWindow() const
virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override
SwLayoutInfo maLayoutInfo
sw::annotation::SwAnnotationWin & mrSidebarWin
virtual void SetWindow(const VclPtr< vcl::Window > &pWindow)
css::uno::Reference< css::accessibility::XAccessible > GetContext(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1810
void SetAccessibleRole(sal_uInt16 nRole)
SidebarWinAccessible(sw::annotation::SwAnnotationWin &rSidebarWin, SwViewShell &rViewShell, const SwSidebarItem &rSidebarItem)