1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*b3f79822SAndrew Rist * distributed with this work for additional information
6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the
17*b3f79822SAndrew Rist * specific language governing permissions and limitations
18*b3f79822SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*b3f79822SAndrew Rist *************************************************************/
21*b3f79822SAndrew Rist
22*b3f79822SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir #include "scitems.hxx"
27cdf0e10cSrcweir #include <editeng/eeitem.hxx>
28cdf0e10cSrcweir #include <tools/gen.hxx>
29cdf0e10cSrcweir #include "AccessibleText.hxx"
30cdf0e10cSrcweir #include "editsrc.hxx"
31cdf0e10cSrcweir #include <svx/AccessibleTextHelper.hxx>
32cdf0e10cSrcweir #include "AccessiblePreviewHeaderCell.hxx"
33cdf0e10cSrcweir #include "AccessibilityHints.hxx"
34cdf0e10cSrcweir #include "prevwsh.hxx"
35cdf0e10cSrcweir #include "unoguard.hxx"
36cdf0e10cSrcweir #include "miscuno.hxx"
37cdf0e10cSrcweir #include "prevloc.hxx"
38cdf0e10cSrcweir #include "scresid.hxx"
39cdf0e10cSrcweir #ifndef SC_SC_HRC
40cdf0e10cSrcweir #include "sc.hrc"
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir
43cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
44cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
45cdf0e10cSrcweir
46cdf0e10cSrcweir #include <vcl/window.hxx>
47cdf0e10cSrcweir #include <svl/smplhint.hxx>
48cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
49cdf0e10cSrcweir #include <comphelper/sequence.hxx>
50cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
51cdf0e10cSrcweir
52cdf0e10cSrcweir using namespace ::com::sun::star;
53cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
54cdf0e10cSrcweir
55cdf0e10cSrcweir //===== internal ============================================================
56cdf0e10cSrcweir
ScAccessiblePreviewHeaderCell(const::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> & rxParent,ScPreviewShell * pViewShell,const ScAddress & rCellPos,sal_Bool bIsColHdr,sal_Bool bIsRowHdr,sal_Int32 nIndex)57cdf0e10cSrcweir ScAccessiblePreviewHeaderCell::ScAccessiblePreviewHeaderCell( const ::com::sun::star::uno::Reference<
58cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& rxParent,
59cdf0e10cSrcweir ScPreviewShell* pViewShell,
60cdf0e10cSrcweir const ScAddress& rCellPos, sal_Bool bIsColHdr, sal_Bool bIsRowHdr,
61cdf0e10cSrcweir sal_Int32 nIndex ) :
62cdf0e10cSrcweir ScAccessibleContextBase( rxParent, AccessibleRole::TABLE_CELL ),
63cdf0e10cSrcweir mpViewShell( pViewShell ),
64cdf0e10cSrcweir mpTextHelper( NULL ),
65cdf0e10cSrcweir mnIndex( nIndex ),
66cdf0e10cSrcweir maCellPos( rCellPos ),
67cdf0e10cSrcweir mbColumnHeader( bIsColHdr ),
68cdf0e10cSrcweir mbRowHeader( bIsRowHdr ),
69cdf0e10cSrcweir mpTableInfo( NULL )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir if (mpViewShell)
72cdf0e10cSrcweir mpViewShell->AddAccessibilityObject(*this);
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
~ScAccessiblePreviewHeaderCell()75cdf0e10cSrcweir ScAccessiblePreviewHeaderCell::~ScAccessiblePreviewHeaderCell()
76cdf0e10cSrcweir {
77cdf0e10cSrcweir if (mpViewShell)
78cdf0e10cSrcweir mpViewShell->RemoveAccessibilityObject(*this);
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
disposing()81cdf0e10cSrcweir void SAL_CALL ScAccessiblePreviewHeaderCell::disposing()
82cdf0e10cSrcweir {
83cdf0e10cSrcweir ScUnoGuard aGuard;
84cdf0e10cSrcweir if (mpViewShell)
85cdf0e10cSrcweir {
86cdf0e10cSrcweir mpViewShell->RemoveAccessibilityObject(*this);
87cdf0e10cSrcweir mpViewShell = NULL;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir
90cdf0e10cSrcweir if (mpTableInfo)
91cdf0e10cSrcweir DELETEZ (mpTableInfo);
92cdf0e10cSrcweir
93cdf0e10cSrcweir ScAccessibleContextBase::disposing();
94cdf0e10cSrcweir }
95cdf0e10cSrcweir
96cdf0e10cSrcweir //===== SfxListener =====================================================
97cdf0e10cSrcweir
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)98cdf0e10cSrcweir void ScAccessiblePreviewHeaderCell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir if (rHint.ISA( SfxSimpleHint ))
101cdf0e10cSrcweir {
102cdf0e10cSrcweir const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
103cdf0e10cSrcweir sal_uLong nId = rRef.GetId();
104cdf0e10cSrcweir if (nId == SC_HINT_ACC_VISAREACHANGED)
105cdf0e10cSrcweir {
106cdf0e10cSrcweir if (mpTextHelper)
107cdf0e10cSrcweir mpTextHelper->UpdateChildren();
108cdf0e10cSrcweir }
109cdf0e10cSrcweir else if ( nId == SFX_HINT_DATACHANGED )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir // column / row layout may change with any document change,
112cdf0e10cSrcweir // so it must be invalidated
113cdf0e10cSrcweir DELETEZ( mpTableInfo );
114cdf0e10cSrcweir }
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
117cdf0e10cSrcweir ScAccessibleContextBase::Notify(rBC, rHint);
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir //===== XInterface =====================================================
121cdf0e10cSrcweir
queryInterface(uno::Type const & rType)122cdf0e10cSrcweir uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::queryInterface( uno::Type const & rType )
123cdf0e10cSrcweir throw (uno::RuntimeException)
124cdf0e10cSrcweir {
125cdf0e10cSrcweir uno::Any aAny (ScAccessiblePreviewHeaderCellImpl::queryInterface(rType));
126cdf0e10cSrcweir return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType);
127cdf0e10cSrcweir }
128cdf0e10cSrcweir
acquire()129cdf0e10cSrcweir void SAL_CALL ScAccessiblePreviewHeaderCell::acquire()
130cdf0e10cSrcweir throw ()
131cdf0e10cSrcweir {
132cdf0e10cSrcweir ScAccessibleContextBase::acquire();
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
release()135cdf0e10cSrcweir void SAL_CALL ScAccessiblePreviewHeaderCell::release()
136cdf0e10cSrcweir throw ()
137cdf0e10cSrcweir {
138cdf0e10cSrcweir ScAccessibleContextBase::release();
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
141cdf0e10cSrcweir //===== XAccessibleValue ================================================
142cdf0e10cSrcweir
getCurrentValue()143cdf0e10cSrcweir uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::getCurrentValue() throw (uno::RuntimeException)
144cdf0e10cSrcweir {
145cdf0e10cSrcweir ScUnoGuard aGuard;
146cdf0e10cSrcweir IsObjectValid();
147cdf0e10cSrcweir
148cdf0e10cSrcweir double fValue(0.0);
149cdf0e10cSrcweir if (mbColumnHeader)
150cdf0e10cSrcweir fValue = maCellPos.Col();
151cdf0e10cSrcweir else
152cdf0e10cSrcweir fValue = maCellPos.Row();
153cdf0e10cSrcweir
154cdf0e10cSrcweir uno::Any aAny;
155cdf0e10cSrcweir aAny <<= fValue;
156cdf0e10cSrcweir return aAny;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
setCurrentValue(const uno::Any &)159cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessiblePreviewHeaderCell::setCurrentValue( const uno::Any& /* aNumber */ )
160cdf0e10cSrcweir throw (uno::RuntimeException)
161cdf0e10cSrcweir {
162cdf0e10cSrcweir // it is not possible to set a value
163cdf0e10cSrcweir return sal_False;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir
getMaximumValue()166cdf0e10cSrcweir uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::getMaximumValue() throw (uno::RuntimeException)
167cdf0e10cSrcweir {
168cdf0e10cSrcweir ScUnoGuard aGuard;
169cdf0e10cSrcweir IsObjectValid();
170cdf0e10cSrcweir
171cdf0e10cSrcweir double fValue(0.0);
172cdf0e10cSrcweir if (mbColumnHeader)
173cdf0e10cSrcweir fValue = MAXCOL;
174cdf0e10cSrcweir else
175cdf0e10cSrcweir fValue = MAXROW;
176cdf0e10cSrcweir uno::Any aAny;
177cdf0e10cSrcweir aAny <<= fValue;
178cdf0e10cSrcweir return aAny;
179cdf0e10cSrcweir }
180cdf0e10cSrcweir
getMinimumValue()181cdf0e10cSrcweir uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::getMinimumValue() throw (uno::RuntimeException)
182cdf0e10cSrcweir {
183cdf0e10cSrcweir double fValue(0.0);
184cdf0e10cSrcweir uno::Any aAny;
185cdf0e10cSrcweir aAny <<= fValue;
186cdf0e10cSrcweir return aAny;
187cdf0e10cSrcweir }
188cdf0e10cSrcweir
189cdf0e10cSrcweir //===== XAccessibleComponent ============================================
190cdf0e10cSrcweir
getAccessibleAtPoint(const awt::Point & rPoint)191cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleAtPoint( const awt::Point& rPoint )
192cdf0e10cSrcweir throw (uno::RuntimeException)
193cdf0e10cSrcweir {
194cdf0e10cSrcweir uno::Reference<XAccessible> xRet;
195cdf0e10cSrcweir if (containsPoint(rPoint))
196cdf0e10cSrcweir {
197cdf0e10cSrcweir ScUnoGuard aGuard;
198cdf0e10cSrcweir IsObjectValid();
199cdf0e10cSrcweir
200cdf0e10cSrcweir if(!mpTextHelper)
201cdf0e10cSrcweir CreateTextHelper();
202cdf0e10cSrcweir
203cdf0e10cSrcweir xRet = mpTextHelper->GetAt(rPoint);
204cdf0e10cSrcweir }
205cdf0e10cSrcweir
206cdf0e10cSrcweir return xRet;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir
grabFocus()209cdf0e10cSrcweir void SAL_CALL ScAccessiblePreviewHeaderCell::grabFocus() throw (uno::RuntimeException)
210cdf0e10cSrcweir {
211cdf0e10cSrcweir ScUnoGuard aGuard;
212cdf0e10cSrcweir IsObjectValid();
213cdf0e10cSrcweir if (getAccessibleParent().is())
214cdf0e10cSrcweir {
215cdf0e10cSrcweir uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
216cdf0e10cSrcweir if (xAccessibleComponent.is())
217cdf0e10cSrcweir xAccessibleComponent->grabFocus();
218cdf0e10cSrcweir }
219cdf0e10cSrcweir }
220cdf0e10cSrcweir
221cdf0e10cSrcweir //===== XAccessibleContext ==============================================
222cdf0e10cSrcweir
getAccessibleChildCount()223cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleChildCount() throw(uno::RuntimeException)
224cdf0e10cSrcweir {
225cdf0e10cSrcweir ScUnoGuard aGuard;
226cdf0e10cSrcweir IsObjectValid();
227cdf0e10cSrcweir if (!mpTextHelper)
228cdf0e10cSrcweir CreateTextHelper();
229cdf0e10cSrcweir return mpTextHelper->GetChildCount();
230cdf0e10cSrcweir }
231cdf0e10cSrcweir
getAccessibleChild(sal_Int32 nIndex)232cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleChild(sal_Int32 nIndex)
233cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
234cdf0e10cSrcweir {
235cdf0e10cSrcweir ScUnoGuard aGuard;
236cdf0e10cSrcweir IsObjectValid();
237cdf0e10cSrcweir if (!mpTextHelper)
238cdf0e10cSrcweir CreateTextHelper();
239cdf0e10cSrcweir return mpTextHelper->GetChild(nIndex);
240cdf0e10cSrcweir }
241cdf0e10cSrcweir
getAccessibleIndexInParent()242cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleIndexInParent() throw (uno::RuntimeException)
243cdf0e10cSrcweir {
244cdf0e10cSrcweir return mnIndex;
245cdf0e10cSrcweir }
246cdf0e10cSrcweir
getAccessibleStateSet()247cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleStateSet()
248cdf0e10cSrcweir throw(uno::RuntimeException)
249cdf0e10cSrcweir {
250cdf0e10cSrcweir ScUnoGuard aGuard;
251cdf0e10cSrcweir
252cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> xParentStates;
253cdf0e10cSrcweir if (getAccessibleParent().is())
254cdf0e10cSrcweir {
255cdf0e10cSrcweir uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
256cdf0e10cSrcweir xParentStates = xParentContext->getAccessibleStateSet();
257cdf0e10cSrcweir }
258cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
259cdf0e10cSrcweir if (IsDefunc(xParentStates))
260cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::DEFUNC);
261cdf0e10cSrcweir else
262cdf0e10cSrcweir {
263cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::ENABLED);
264cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::MULTI_LINE);
265cdf0e10cSrcweir if (isShowing())
266cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SHOWING);
267cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::TRANSIENT);
268cdf0e10cSrcweir if (isVisible())
269cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::VISIBLE);
270cdf0e10cSrcweir }
271cdf0e10cSrcweir return pStateSet;
272cdf0e10cSrcweir }
273cdf0e10cSrcweir
274cdf0e10cSrcweir //===== XServiceInfo ====================================================
275cdf0e10cSrcweir
getImplementationName()276cdf0e10cSrcweir rtl::OUString SAL_CALL ScAccessiblePreviewHeaderCell::getImplementationName() throw(uno::RuntimeException)
277cdf0e10cSrcweir {
278cdf0e10cSrcweir return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScAccessiblePreviewHeaderCell"));
279cdf0e10cSrcweir }
280cdf0e10cSrcweir
getSupportedServiceNames()281cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL ScAccessiblePreviewHeaderCell::getSupportedServiceNames()
282cdf0e10cSrcweir throw(uno::RuntimeException)
283cdf0e10cSrcweir {
284cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
285cdf0e10cSrcweir sal_Int32 nOldSize(aSequence.getLength());
286cdf0e10cSrcweir aSequence.realloc(nOldSize + 1);
287cdf0e10cSrcweir ::rtl::OUString* pNames = aSequence.getArray();
288cdf0e10cSrcweir
289cdf0e10cSrcweir pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.AccessibleCellView"));
290cdf0e10cSrcweir
291cdf0e10cSrcweir return aSequence;
292cdf0e10cSrcweir }
293cdf0e10cSrcweir
294cdf0e10cSrcweir //===== XTypeProvider =======================================================
295cdf0e10cSrcweir
getTypes()296cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL ScAccessiblePreviewHeaderCell::getTypes()
297cdf0e10cSrcweir throw (uno::RuntimeException)
298cdf0e10cSrcweir {
299cdf0e10cSrcweir return comphelper::concatSequences(ScAccessiblePreviewHeaderCellImpl::getTypes(), ScAccessibleContextBase::getTypes());
300cdf0e10cSrcweir }
301cdf0e10cSrcweir
302cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL
getImplementationId(void)303cdf0e10cSrcweir ScAccessiblePreviewHeaderCell::getImplementationId(void)
304cdf0e10cSrcweir throw (uno::RuntimeException)
305cdf0e10cSrcweir {
306cdf0e10cSrcweir ScUnoGuard aGuard;
307cdf0e10cSrcweir IsObjectValid();
308cdf0e10cSrcweir static uno::Sequence<sal_Int8> aId;
309cdf0e10cSrcweir if (aId.getLength() == 0)
310cdf0e10cSrcweir {
311cdf0e10cSrcweir aId.realloc (16);
312cdf0e10cSrcweir rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
313cdf0e10cSrcweir }
314cdf0e10cSrcweir return aId;
315cdf0e10cSrcweir }
316cdf0e10cSrcweir
317cdf0e10cSrcweir //==== internal =========================================================
318cdf0e10cSrcweir
GetBoundingBoxOnScreen() const319cdf0e10cSrcweir Rectangle ScAccessiblePreviewHeaderCell::GetBoundingBoxOnScreen() const throw (uno::RuntimeException)
320cdf0e10cSrcweir {
321cdf0e10cSrcweir Rectangle aCellRect;
322cdf0e10cSrcweir
323cdf0e10cSrcweir FillTableInfo();
324cdf0e10cSrcweir
325cdf0e10cSrcweir if (mpTableInfo)
326cdf0e10cSrcweir {
327cdf0e10cSrcweir const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[maCellPos.Col()];
328cdf0e10cSrcweir const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[maCellPos.Row()];
329cdf0e10cSrcweir
330cdf0e10cSrcweir aCellRect = Rectangle( rColInfo.nPixelStart, rRowInfo.nPixelStart, rColInfo.nPixelEnd, rRowInfo.nPixelEnd );
331cdf0e10cSrcweir }
332cdf0e10cSrcweir
333cdf0e10cSrcweir if (mpViewShell)
334cdf0e10cSrcweir {
335cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindow();
336cdf0e10cSrcweir if (pWindow)
337cdf0e10cSrcweir {
338cdf0e10cSrcweir Rectangle aRect = pWindow->GetWindowExtentsRelative(NULL);
339cdf0e10cSrcweir aCellRect.setX(aCellRect.getX() + aRect.getX());
340cdf0e10cSrcweir aCellRect.setY(aCellRect.getY() + aRect.getY());
341cdf0e10cSrcweir }
342cdf0e10cSrcweir }
343cdf0e10cSrcweir return aCellRect;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir
GetBoundingBox() const346cdf0e10cSrcweir Rectangle ScAccessiblePreviewHeaderCell::GetBoundingBox() const throw (uno::RuntimeException)
347cdf0e10cSrcweir {
348cdf0e10cSrcweir FillTableInfo();
349cdf0e10cSrcweir
350cdf0e10cSrcweir if (mpTableInfo)
351cdf0e10cSrcweir {
352cdf0e10cSrcweir const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[maCellPos.Col()];
353cdf0e10cSrcweir const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[maCellPos.Row()];
354cdf0e10cSrcweir
355cdf0e10cSrcweir Rectangle aCellRect( rColInfo.nPixelStart, rRowInfo.nPixelStart, rColInfo.nPixelEnd, rRowInfo.nPixelEnd );
356cdf0e10cSrcweir uno::Reference<XAccessible> xAccParent = const_cast<ScAccessiblePreviewHeaderCell*>(this)->getAccessibleParent();
357cdf0e10cSrcweir if (xAccParent.is())
358cdf0e10cSrcweir {
359cdf0e10cSrcweir uno::Reference<XAccessibleContext> xAccParentContext = xAccParent->getAccessibleContext();
360cdf0e10cSrcweir uno::Reference<XAccessibleComponent> xAccParentComp (xAccParentContext, uno::UNO_QUERY);
361cdf0e10cSrcweir if (xAccParentComp.is())
362cdf0e10cSrcweir {
363cdf0e10cSrcweir Rectangle aParentRect (VCLRectangle(xAccParentComp->getBounds()));
364cdf0e10cSrcweir aCellRect.setX(aCellRect.getX() - aParentRect.getX());
365cdf0e10cSrcweir aCellRect.setY(aCellRect.getY() - aParentRect.getY());
366cdf0e10cSrcweir }
367cdf0e10cSrcweir }
368cdf0e10cSrcweir return aCellRect;
369cdf0e10cSrcweir }
370cdf0e10cSrcweir return Rectangle();
371cdf0e10cSrcweir }
372cdf0e10cSrcweir
createAccessibleDescription()373cdf0e10cSrcweir rtl::OUString SAL_CALL ScAccessiblePreviewHeaderCell::createAccessibleDescription() throw(uno::RuntimeException)
374cdf0e10cSrcweir {
375cdf0e10cSrcweir rtl::OUString sDescription = String(ScResId(STR_ACC_HEADERCELL_DESCR));
376cdf0e10cSrcweir return sDescription;
377cdf0e10cSrcweir }
378cdf0e10cSrcweir
createAccessibleName()379cdf0e10cSrcweir rtl::OUString SAL_CALL ScAccessiblePreviewHeaderCell::createAccessibleName() throw(uno::RuntimeException)
380cdf0e10cSrcweir {
381cdf0e10cSrcweir rtl::OUString sName = String(ScResId(STR_ACC_HEADERCELL_NAME));
382cdf0e10cSrcweir
383cdf0e10cSrcweir if ( mbColumnHeader )
384cdf0e10cSrcweir {
385cdf0e10cSrcweir if ( mbRowHeader )
386cdf0e10cSrcweir {
387cdf0e10cSrcweir //! name for corner cell?
388cdf0e10cSrcweir
389cdf0e10cSrcweir // sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Column/Row Header"));
390cdf0e10cSrcweir }
391cdf0e10cSrcweir else
392cdf0e10cSrcweir {
393cdf0e10cSrcweir // name of column header
394cdf0e10cSrcweir sName += ScColToAlpha( maCellPos.Col() );
395cdf0e10cSrcweir }
396cdf0e10cSrcweir }
397cdf0e10cSrcweir else
398cdf0e10cSrcweir {
399cdf0e10cSrcweir // name of row header
400cdf0e10cSrcweir sName += rtl::OUString::valueOf( (sal_Int32) ( maCellPos.Row() + 1 ) );
401cdf0e10cSrcweir }
402cdf0e10cSrcweir
403cdf0e10cSrcweir return sName;
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
IsDefunc(const uno::Reference<XAccessibleStateSet> & rxParentStates)406cdf0e10cSrcweir sal_Bool ScAccessiblePreviewHeaderCell::IsDefunc( const uno::Reference<XAccessibleStateSet>& rxParentStates )
407cdf0e10cSrcweir {
408cdf0e10cSrcweir return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() ||
409cdf0e10cSrcweir (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
410cdf0e10cSrcweir }
411cdf0e10cSrcweir
CreateTextHelper()412cdf0e10cSrcweir void ScAccessiblePreviewHeaderCell::CreateTextHelper()
413cdf0e10cSrcweir {
414cdf0e10cSrcweir if (!mpTextHelper)
415cdf0e10cSrcweir {
416cdf0e10cSrcweir ::std::auto_ptr < ScAccessibleTextData > pAccessiblePreviewHeaderCellTextData
417cdf0e10cSrcweir (new ScAccessiblePreviewHeaderCellTextData(mpViewShell, String(getAccessibleName()), maCellPos, mbColumnHeader, mbRowHeader));
418cdf0e10cSrcweir ::std::auto_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(pAccessiblePreviewHeaderCellTextData));
419cdf0e10cSrcweir
420cdf0e10cSrcweir mpTextHelper = new ::accessibility::AccessibleTextHelper(pEditSource );
421cdf0e10cSrcweir mpTextHelper->SetEventSource(this);
422cdf0e10cSrcweir }
423cdf0e10cSrcweir }
424cdf0e10cSrcweir
FillTableInfo() const425cdf0e10cSrcweir void ScAccessiblePreviewHeaderCell::FillTableInfo() const
426cdf0e10cSrcweir {
427cdf0e10cSrcweir if ( mpViewShell && !mpTableInfo )
428cdf0e10cSrcweir {
429cdf0e10cSrcweir Size aOutputSize;
430cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindow();
431cdf0e10cSrcweir if ( pWindow )
432cdf0e10cSrcweir aOutputSize = pWindow->GetOutputSizePixel();
433cdf0e10cSrcweir Point aPoint;
434cdf0e10cSrcweir Rectangle aVisRect( aPoint, aOutputSize );
435cdf0e10cSrcweir
436cdf0e10cSrcweir mpTableInfo = new ScPreviewTableInfo;
437cdf0e10cSrcweir mpViewShell->GetLocationData().GetTableInfo( aVisRect, *mpTableInfo );
438cdf0e10cSrcweir }
439cdf0e10cSrcweir }
440