1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim Jagielski
25*b1cdbd2cSJim Jagielski #include "precompiled_sw.hxx"
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielski #include <SidebarTxtControlAcc.hxx>
28*b1cdbd2cSJim Jagielski
29*b1cdbd2cSJim Jagielski #include <SidebarTxtControl.hxx>
30*b1cdbd2cSJim Jagielski
31*b1cdbd2cSJim Jagielski #include <svl/brdcst.hxx>
32*b1cdbd2cSJim Jagielski #include <toolkit/awt/vclxaccessiblecomponent.hxx>
33*b1cdbd2cSJim Jagielski #include <editeng/unoedsrc.hxx>
34*b1cdbd2cSJim Jagielski #include <editeng/unoforou.hxx>
35*b1cdbd2cSJim Jagielski #include <editeng/unoviwou.hxx>
36*b1cdbd2cSJim Jagielski #include <editeng/unoedhlp.hxx>
37*b1cdbd2cSJim Jagielski #include <svx/AccessibleTextHelper.hxx>
38*b1cdbd2cSJim Jagielski #include <editeng/outliner.hxx>
39*b1cdbd2cSJim Jagielski
40*b1cdbd2cSJim Jagielski
41*b1cdbd2cSJim Jagielski namespace css = ::com::sun::star;
42*b1cdbd2cSJim Jagielski
43*b1cdbd2cSJim Jagielski namespace sw { namespace sidebarwindows {
44*b1cdbd2cSJim Jagielski
45*b1cdbd2cSJim Jagielski // =============================================================================
46*b1cdbd2cSJim Jagielski // declaration and implementation of <SvxEditSource>
47*b1cdbd2cSJim Jagielski // for <::accessibiliy::AccessibleTextHelper> instance
48*b1cdbd2cSJim Jagielski // =============================================================================
49*b1cdbd2cSJim Jagielski class SidebarTextEditSource : public SvxEditSource,
50*b1cdbd2cSJim Jagielski public SfxBroadcaster
51*b1cdbd2cSJim Jagielski {
52*b1cdbd2cSJim Jagielski public:
53*b1cdbd2cSJim Jagielski SidebarTextEditSource( SidebarTxtControl& rSidebarTxtControl );
54*b1cdbd2cSJim Jagielski virtual ~SidebarTextEditSource();
55*b1cdbd2cSJim Jagielski
56*b1cdbd2cSJim Jagielski virtual SvxEditSource* Clone() const;
57*b1cdbd2cSJim Jagielski
58*b1cdbd2cSJim Jagielski virtual SvxTextForwarder* GetTextForwarder();
59*b1cdbd2cSJim Jagielski virtual SvxViewForwarder* GetViewForwarder();
60*b1cdbd2cSJim Jagielski virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate = sal_False );
61*b1cdbd2cSJim Jagielski
62*b1cdbd2cSJim Jagielski virtual void UpdateData();
63*b1cdbd2cSJim Jagielski
64*b1cdbd2cSJim Jagielski virtual SfxBroadcaster& GetBroadcaster() const;
65*b1cdbd2cSJim Jagielski DECL_LINK( NotifyHdl, EENotify* );
66*b1cdbd2cSJim Jagielski
67*b1cdbd2cSJim Jagielski private:
68*b1cdbd2cSJim Jagielski SidebarTxtControl& mrSidebarTxtControl;
69*b1cdbd2cSJim Jagielski SvxOutlinerForwarder mTextForwarder;
70*b1cdbd2cSJim Jagielski SvxDrawOutlinerViewForwarder mViewForwarder;
71*b1cdbd2cSJim Jagielski };
72*b1cdbd2cSJim Jagielski
SidebarTextEditSource(SidebarTxtControl & rSidebarTxtControl)73*b1cdbd2cSJim Jagielski SidebarTextEditSource::SidebarTextEditSource( SidebarTxtControl& rSidebarTxtControl )
74*b1cdbd2cSJim Jagielski : SvxEditSource()
75*b1cdbd2cSJim Jagielski , mrSidebarTxtControl( rSidebarTxtControl )
76*b1cdbd2cSJim Jagielski , mTextForwarder( *(rSidebarTxtControl.GetTextView()->GetOutliner()), sal_False )
77*b1cdbd2cSJim Jagielski , mViewForwarder( *(rSidebarTxtControl.GetTextView()) )
78*b1cdbd2cSJim Jagielski {
79*b1cdbd2cSJim Jagielski if ( mrSidebarTxtControl.GetTextView() )
80*b1cdbd2cSJim Jagielski {
81*b1cdbd2cSJim Jagielski mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( LINK(this, SidebarTextEditSource, NotifyHdl) );
82*b1cdbd2cSJim Jagielski }
83*b1cdbd2cSJim Jagielski }
84*b1cdbd2cSJim Jagielski
~SidebarTextEditSource()85*b1cdbd2cSJim Jagielski SidebarTextEditSource::~SidebarTextEditSource()
86*b1cdbd2cSJim Jagielski {
87*b1cdbd2cSJim Jagielski if ( mrSidebarTxtControl.GetTextView() )
88*b1cdbd2cSJim Jagielski {
89*b1cdbd2cSJim Jagielski mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( Link() );
90*b1cdbd2cSJim Jagielski }
91*b1cdbd2cSJim Jagielski }
92*b1cdbd2cSJim Jagielski
Clone() const93*b1cdbd2cSJim Jagielski SvxEditSource* SidebarTextEditSource::Clone() const
94*b1cdbd2cSJim Jagielski {
95*b1cdbd2cSJim Jagielski return new SidebarTextEditSource( mrSidebarTxtControl );
96*b1cdbd2cSJim Jagielski }
97*b1cdbd2cSJim Jagielski
GetTextForwarder()98*b1cdbd2cSJim Jagielski SvxTextForwarder* SidebarTextEditSource::GetTextForwarder()
99*b1cdbd2cSJim Jagielski {
100*b1cdbd2cSJim Jagielski return &mTextForwarder;
101*b1cdbd2cSJim Jagielski }
102*b1cdbd2cSJim Jagielski
GetViewForwarder()103*b1cdbd2cSJim Jagielski SvxViewForwarder* SidebarTextEditSource::GetViewForwarder()
104*b1cdbd2cSJim Jagielski {
105*b1cdbd2cSJim Jagielski return &mViewForwarder;
106*b1cdbd2cSJim Jagielski }
107*b1cdbd2cSJim Jagielski
GetEditViewForwarder(sal_Bool)108*b1cdbd2cSJim Jagielski SvxEditViewForwarder* SidebarTextEditSource::GetEditViewForwarder( sal_Bool /*bCreate*/ )
109*b1cdbd2cSJim Jagielski {
110*b1cdbd2cSJim Jagielski return &mViewForwarder;
111*b1cdbd2cSJim Jagielski }
112*b1cdbd2cSJim Jagielski
UpdateData()113*b1cdbd2cSJim Jagielski void SidebarTextEditSource::UpdateData()
114*b1cdbd2cSJim Jagielski {
115*b1cdbd2cSJim Jagielski // nothing to do
116*b1cdbd2cSJim Jagielski }
117*b1cdbd2cSJim Jagielski
GetBroadcaster() const118*b1cdbd2cSJim Jagielski SfxBroadcaster& SidebarTextEditSource::GetBroadcaster() const
119*b1cdbd2cSJim Jagielski {
120*b1cdbd2cSJim Jagielski return *( const_cast< SidebarTextEditSource* > (this) );
121*b1cdbd2cSJim Jagielski }
122*b1cdbd2cSJim Jagielski
IMPL_LINK(SidebarTextEditSource,NotifyHdl,EENotify *,pNotify)123*b1cdbd2cSJim Jagielski IMPL_LINK(SidebarTextEditSource, NotifyHdl, EENotify*, pNotify)
124*b1cdbd2cSJim Jagielski {
125*b1cdbd2cSJim Jagielski if ( pNotify )
126*b1cdbd2cSJim Jagielski {
127*b1cdbd2cSJim Jagielski ::std::auto_ptr< SfxHint > aHint( SvxEditSourceHelper::EENotification2Hint( pNotify ) );
128*b1cdbd2cSJim Jagielski
129*b1cdbd2cSJim Jagielski if( aHint.get() )
130*b1cdbd2cSJim Jagielski {
131*b1cdbd2cSJim Jagielski Broadcast( *aHint.get() );
132*b1cdbd2cSJim Jagielski }
133*b1cdbd2cSJim Jagielski }
134*b1cdbd2cSJim Jagielski
135*b1cdbd2cSJim Jagielski return 0;
136*b1cdbd2cSJim Jagielski }
137*b1cdbd2cSJim Jagielski
138*b1cdbd2cSJim Jagielski
139*b1cdbd2cSJim Jagielski // =============================================================================
140*b1cdbd2cSJim Jagielski // declaration and implementation of accessible context for <SidebarTxtControl> instance
141*b1cdbd2cSJim Jagielski // =============================================================================
142*b1cdbd2cSJim Jagielski class SidebarTxtControlAccessibleContext : public VCLXAccessibleComponent
143*b1cdbd2cSJim Jagielski {
144*b1cdbd2cSJim Jagielski public:
145*b1cdbd2cSJim Jagielski explicit SidebarTxtControlAccessibleContext( SidebarTxtControl& rSidebarTxtControl );
146*b1cdbd2cSJim Jagielski virtual ~SidebarTxtControlAccessibleContext();
147*b1cdbd2cSJim Jagielski
148*b1cdbd2cSJim Jagielski virtual sal_Int32 SAL_CALL
149*b1cdbd2cSJim Jagielski getAccessibleChildCount()
150*b1cdbd2cSJim Jagielski throw (::com::sun::star::uno::RuntimeException);
151*b1cdbd2cSJim Jagielski virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
152*b1cdbd2cSJim Jagielski getAccessibleChild( sal_Int32 i )
153*b1cdbd2cSJim Jagielski throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
154*b1cdbd2cSJim Jagielski
155*b1cdbd2cSJim Jagielski using WeakAggComponentImplHelperBase::addEventListener;
156*b1cdbd2cSJim Jagielski using WeakAggComponentImplHelperBase::removeEventListener;
157*b1cdbd2cSJim Jagielski
158*b1cdbd2cSJim Jagielski virtual void SAL_CALL
159*b1cdbd2cSJim Jagielski addEventListener (
160*b1cdbd2cSJim Jagielski const ::com::sun::star::uno::Reference<
161*b1cdbd2cSJim Jagielski ::com::sun::star::accessibility::XAccessibleEventListener >& xListener)
162*b1cdbd2cSJim Jagielski throw (::com::sun::star::uno::RuntimeException);
163*b1cdbd2cSJim Jagielski virtual void SAL_CALL
164*b1cdbd2cSJim Jagielski removeEventListener (
165*b1cdbd2cSJim Jagielski const ::com::sun::star::uno::Reference<
166*b1cdbd2cSJim Jagielski ::com::sun::star::accessibility::XAccessibleEventListener >& xListener)
167*b1cdbd2cSJim Jagielski throw (::com::sun::star::uno::RuntimeException);
168*b1cdbd2cSJim Jagielski
169*b1cdbd2cSJim Jagielski protected:
170*b1cdbd2cSJim Jagielski virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
171*b1cdbd2cSJim Jagielski
172*b1cdbd2cSJim Jagielski private:
173*b1cdbd2cSJim Jagielski SidebarTxtControl& mrSidebarTxtControl;
174*b1cdbd2cSJim Jagielski ::accessibility::AccessibleTextHelper* mpAccessibleTextHelper;
175*b1cdbd2cSJim Jagielski
176*b1cdbd2cSJim Jagielski ::vos::OMutex maMutex;
177*b1cdbd2cSJim Jagielski
178*b1cdbd2cSJim Jagielski void defunc();
179*b1cdbd2cSJim Jagielski };
180*b1cdbd2cSJim Jagielski
SidebarTxtControlAccessibleContext(SidebarTxtControl & rSidebarTxtControl)181*b1cdbd2cSJim Jagielski SidebarTxtControlAccessibleContext::SidebarTxtControlAccessibleContext( SidebarTxtControl& rSidebarTxtControl )
182*b1cdbd2cSJim Jagielski : VCLXAccessibleComponent( rSidebarTxtControl.GetWindowPeer() )
183*b1cdbd2cSJim Jagielski , mrSidebarTxtControl( rSidebarTxtControl )
184*b1cdbd2cSJim Jagielski , mpAccessibleTextHelper( 0 )
185*b1cdbd2cSJim Jagielski , maMutex()
186*b1cdbd2cSJim Jagielski {
187*b1cdbd2cSJim Jagielski ::std::auto_ptr<SvxEditSource> pEditSource(
188*b1cdbd2cSJim Jagielski new SidebarTextEditSource( mrSidebarTxtControl ) );
189*b1cdbd2cSJim Jagielski mpAccessibleTextHelper = new ::accessibility::AccessibleTextHelper( pEditSource );
190*b1cdbd2cSJim Jagielski mpAccessibleTextHelper->SetEventSource( mrSidebarTxtControl.GetWindowPeer() );
191*b1cdbd2cSJim Jagielski }
192*b1cdbd2cSJim Jagielski
~SidebarTxtControlAccessibleContext()193*b1cdbd2cSJim Jagielski SidebarTxtControlAccessibleContext::~SidebarTxtControlAccessibleContext()
194*b1cdbd2cSJim Jagielski {
195*b1cdbd2cSJim Jagielski defunc();
196*b1cdbd2cSJim Jagielski }
197*b1cdbd2cSJim Jagielski
defunc()198*b1cdbd2cSJim Jagielski void SidebarTxtControlAccessibleContext::defunc()
199*b1cdbd2cSJim Jagielski {
200*b1cdbd2cSJim Jagielski delete mpAccessibleTextHelper;
201*b1cdbd2cSJim Jagielski mpAccessibleTextHelper = 0;
202*b1cdbd2cSJim Jagielski }
203*b1cdbd2cSJim Jagielski
getAccessibleChildCount()204*b1cdbd2cSJim Jagielski sal_Int32 SAL_CALL SidebarTxtControlAccessibleContext::getAccessibleChildCount()
205*b1cdbd2cSJim Jagielski throw (::com::sun::star::uno::RuntimeException)
206*b1cdbd2cSJim Jagielski {
207*b1cdbd2cSJim Jagielski vos::OGuard aGuard( maMutex );
208*b1cdbd2cSJim Jagielski
209*b1cdbd2cSJim Jagielski sal_Int32 nChildCount( 0 );
210*b1cdbd2cSJim Jagielski
211*b1cdbd2cSJim Jagielski if ( mpAccessibleTextHelper )
212*b1cdbd2cSJim Jagielski {
213*b1cdbd2cSJim Jagielski nChildCount = mpAccessibleTextHelper->GetChildCount();
214*b1cdbd2cSJim Jagielski }
215*b1cdbd2cSJim Jagielski
216*b1cdbd2cSJim Jagielski return nChildCount;
217*b1cdbd2cSJim Jagielski }
218*b1cdbd2cSJim Jagielski
getAccessibleChild(sal_Int32 i)219*b1cdbd2cSJim Jagielski css::uno::Reference< css::accessibility::XAccessible > SAL_CALL SidebarTxtControlAccessibleContext::getAccessibleChild( sal_Int32 i )
220*b1cdbd2cSJim Jagielski throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException )
221*b1cdbd2cSJim Jagielski {
222*b1cdbd2cSJim Jagielski vos::OGuard aGuard( maMutex );
223*b1cdbd2cSJim Jagielski
224*b1cdbd2cSJim Jagielski css::uno::Reference< css::accessibility::XAccessible > xChild;
225*b1cdbd2cSJim Jagielski
226*b1cdbd2cSJim Jagielski if ( mpAccessibleTextHelper )
227*b1cdbd2cSJim Jagielski {
228*b1cdbd2cSJim Jagielski xChild = mpAccessibleTextHelper->GetChild( i );
229*b1cdbd2cSJim Jagielski }
230*b1cdbd2cSJim Jagielski
231*b1cdbd2cSJim Jagielski return xChild;
232*b1cdbd2cSJim Jagielski }
233*b1cdbd2cSJim Jagielski
addEventListener(const css::uno::Reference<css::accessibility::XAccessibleEventListener> & xListener)234*b1cdbd2cSJim Jagielski void SAL_CALL SidebarTxtControlAccessibleContext::addEventListener (
235*b1cdbd2cSJim Jagielski const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener)
236*b1cdbd2cSJim Jagielski throw (css::uno::RuntimeException)
237*b1cdbd2cSJim Jagielski {
238*b1cdbd2cSJim Jagielski vos::OGuard aGuard( maMutex );
239*b1cdbd2cSJim Jagielski
240*b1cdbd2cSJim Jagielski if ( mpAccessibleTextHelper )
241*b1cdbd2cSJim Jagielski {
242*b1cdbd2cSJim Jagielski mpAccessibleTextHelper->AddEventListener(xListener);
243*b1cdbd2cSJim Jagielski }
244*b1cdbd2cSJim Jagielski }
245*b1cdbd2cSJim Jagielski
removeEventListener(const css::uno::Reference<css::accessibility::XAccessibleEventListener> & xListener)246*b1cdbd2cSJim Jagielski void SAL_CALL SidebarTxtControlAccessibleContext::removeEventListener (
247*b1cdbd2cSJim Jagielski const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener)
248*b1cdbd2cSJim Jagielski throw (css::uno::RuntimeException)
249*b1cdbd2cSJim Jagielski {
250*b1cdbd2cSJim Jagielski vos::OGuard aGuard( maMutex );
251*b1cdbd2cSJim Jagielski
252*b1cdbd2cSJim Jagielski if ( mpAccessibleTextHelper )
253*b1cdbd2cSJim Jagielski {
254*b1cdbd2cSJim Jagielski mpAccessibleTextHelper->RemoveEventListener(xListener);
255*b1cdbd2cSJim Jagielski }
256*b1cdbd2cSJim Jagielski }
257*b1cdbd2cSJim Jagielski
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)258*b1cdbd2cSJim Jagielski void SidebarTxtControlAccessibleContext::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
259*b1cdbd2cSJim Jagielski {
260*b1cdbd2cSJim Jagielski if ( mpAccessibleTextHelper )
261*b1cdbd2cSJim Jagielski {
262*b1cdbd2cSJim Jagielski switch ( rVclWindowEvent.GetId() )
263*b1cdbd2cSJim Jagielski {
264*b1cdbd2cSJim Jagielski case VCLEVENT_OBJECT_DYING:
265*b1cdbd2cSJim Jagielski {
266*b1cdbd2cSJim Jagielski defunc();
267*b1cdbd2cSJim Jagielski }
268*b1cdbd2cSJim Jagielski break;
269*b1cdbd2cSJim Jagielski case VCLEVENT_WINDOW_GETFOCUS:
270*b1cdbd2cSJim Jagielski case VCLEVENT_CONTROL_GETFOCUS:
271*b1cdbd2cSJim Jagielski {
272*b1cdbd2cSJim Jagielski mpAccessibleTextHelper->SetFocus( sal_True );
273*b1cdbd2cSJim Jagielski }
274*b1cdbd2cSJim Jagielski break;
275*b1cdbd2cSJim Jagielski case VCLEVENT_WINDOW_LOSEFOCUS:
276*b1cdbd2cSJim Jagielski case VCLEVENT_CONTROL_LOSEFOCUS:
277*b1cdbd2cSJim Jagielski {
278*b1cdbd2cSJim Jagielski mpAccessibleTextHelper->SetFocus( sal_False );
279*b1cdbd2cSJim Jagielski }
280*b1cdbd2cSJim Jagielski break;
281*b1cdbd2cSJim Jagielski }
282*b1cdbd2cSJim Jagielski }
283*b1cdbd2cSJim Jagielski
284*b1cdbd2cSJim Jagielski VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
285*b1cdbd2cSJim Jagielski }
286*b1cdbd2cSJim Jagielski
287*b1cdbd2cSJim Jagielski // =============================================================================
288*b1cdbd2cSJim Jagielski // implementaion of accessible for <SidebarTxtControl> instance
289*b1cdbd2cSJim Jagielski // =============================================================================
SidebarTxtControlAccessible(SidebarTxtControl & rSidebarTxtControl)290*b1cdbd2cSJim Jagielski SidebarTxtControlAccessible::SidebarTxtControlAccessible( SidebarTxtControl& rSidebarTxtControl )
291*b1cdbd2cSJim Jagielski : VCLXWindow()
292*b1cdbd2cSJim Jagielski , mrSidebarTxtControl( rSidebarTxtControl )
293*b1cdbd2cSJim Jagielski {
294*b1cdbd2cSJim Jagielski SetWindow( &mrSidebarTxtControl );
295*b1cdbd2cSJim Jagielski }
296*b1cdbd2cSJim Jagielski
~SidebarTxtControlAccessible()297*b1cdbd2cSJim Jagielski SidebarTxtControlAccessible::~SidebarTxtControlAccessible()
298*b1cdbd2cSJim Jagielski {
299*b1cdbd2cSJim Jagielski }
300*b1cdbd2cSJim Jagielski
CreateAccessibleContext()301*b1cdbd2cSJim Jagielski css::uno::Reference< css::accessibility::XAccessibleContext > SidebarTxtControlAccessible::CreateAccessibleContext()
302*b1cdbd2cSJim Jagielski {
303*b1cdbd2cSJim Jagielski SidebarTxtControlAccessibleContext* pAccContext(
304*b1cdbd2cSJim Jagielski new SidebarTxtControlAccessibleContext( mrSidebarTxtControl ) );
305*b1cdbd2cSJim Jagielski css::uno::Reference< css::accessibility::XAccessibleContext > xAcc( pAccContext );
306*b1cdbd2cSJim Jagielski return xAcc;
307*b1cdbd2cSJim Jagielski }
308*b1cdbd2cSJim Jagielski
309*b1cdbd2cSJim Jagielski } } // end of namespace sw::sidebarwindows
310*b1cdbd2cSJim Jagielski
311