Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "AccessibleDocument.hxx"
30 : : #include "AccessibleSpreadsheet.hxx"
31 : : #include "tabvwsh.hxx"
32 : : #include "AccessibilityHints.hxx"
33 : : #include "document.hxx"
34 : : #include "drwlayer.hxx"
35 : : #include "shapeuno.hxx"
36 : : #include "DrawModelBroadcaster.hxx"
37 : : #include "drawview.hxx"
38 : : #include "gridwin.hxx"
39 : : #include "AccessibleEditObject.hxx"
40 : : #include "userdat.hxx"
41 : : #include "scresid.hxx"
42 : : #include "sc.hrc"
43 : : #include "markdata.hxx"
44 : :
45 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
46 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
47 : : #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
48 : : #include <com/sun/star/view/XSelectionSupplier.hpp>
49 : : #include <com/sun/star/drawing/XShape.hpp>
50 : : #include <com/sun/star/drawing/XShapes.hpp>
51 : :
52 : : #include <unotools/accessiblestatesethelper.hxx>
53 : : #include <tools/gen.hxx>
54 : : #include <svx/svdpage.hxx>
55 : : #include <svx/svdobj.hxx>
56 : : #include <svx/ShapeTypeHandler.hxx>
57 : : #include <svx/AccessibleShape.hxx>
58 : : #include <svx/AccessibleShapeTreeInfo.hxx>
59 : : #include <svx/AccessibleShapeInfo.hxx>
60 : : #include <comphelper/sequence.hxx>
61 : : #include <comphelper/servicehelper.hxx>
62 : : #include <sfx2/viewfrm.hxx>
63 : : #include <svx/unoshcol.hxx>
64 : : #include <svx/unoshape.hxx>
65 : : #include <unotools/accessiblerelationsethelper.hxx>
66 : : #include <toolkit/helper/convert.hxx>
67 : : #include <vcl/svapp.hxx>
68 : :
69 : : #include <list>
70 : : #include <algorithm>
71 : :
72 : : using namespace ::com::sun::star;
73 : : using namespace ::com::sun::star::accessibility;
74 : : using ::std::for_each;
75 : :
76 : : //===== internal ========================================================
77 : :
78 : : struct ScAccessibleShapeData
79 : : {
80 : 0 : ScAccessibleShapeData() : pAccShape(NULL), pRelationCell(NULL), bSelected(false), bSelectable(sal_True) {}
81 : : ~ScAccessibleShapeData();
82 : : mutable ::accessibility::AccessibleShape* pAccShape;
83 : : mutable ScAddress* pRelationCell; // if it is NULL this shape is anchored on the table
84 : : com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape;
85 : : mutable sal_Bool bSelected;
86 : : sal_Bool bSelectable;
87 : : };
88 : :
89 : 0 : ScAccessibleShapeData::~ScAccessibleShapeData()
90 : : {
91 [ # # ]: 0 : if (pAccShape)
92 : : {
93 [ # # ]: 0 : pAccShape->dispose();
94 : 0 : pAccShape->release();
95 : : }
96 : 0 : }
97 : :
98 : 6 : struct ScShapeDataLess
99 : : {
100 : : rtl::OUString msLayerId;
101 : : rtl::OUString msZOrder;
102 : 2 : ScShapeDataLess()
103 : : : msLayerId(RTL_CONSTASCII_USTRINGPARAM( "LayerID" )),
104 [ + - ]: 2 : msZOrder(RTL_CONSTASCII_USTRINGPARAM( "ZOrder" ))
105 : : {
106 : 2 : }
107 : 0 : void ConvertLayerId(sal_Int16& rLayerID) const // changes the number of the LayerId so it the accessibility order
108 : : {
109 [ # # # # : 0 : switch (rLayerID)
# ]
110 : : {
111 : : case SC_LAYER_FRONT:
112 : 0 : rLayerID = 1;
113 : 0 : break;
114 : : case SC_LAYER_BACK:
115 : 0 : rLayerID = 0;
116 : 0 : break;
117 : : case SC_LAYER_INTERN:
118 : 0 : rLayerID = 2;
119 : 0 : break;
120 : : case SC_LAYER_CONTROLS:
121 : 0 : rLayerID = 3;
122 : 0 : break;
123 : : }
124 : 0 : }
125 : 0 : sal_Bool LessThanSheet(const ScAccessibleShapeData* pData) const
126 : : {
127 : 0 : sal_Bool bResult(false);
128 [ # # ]: 0 : uno::Reference< beans::XPropertySet> xProps(pData->xShape, uno::UNO_QUERY);
129 [ # # ]: 0 : if (xProps.is())
130 : : {
131 [ # # ][ # # ]: 0 : uno::Any aPropAny = xProps->getPropertyValue(msLayerId);
132 : 0 : sal_Int16 nLayerID = 0;
133 [ # # ]: 0 : if( (aPropAny >>= nLayerID) )
134 : : {
135 [ # # ]: 0 : if (nLayerID == SC_LAYER_BACK)
136 : 0 : bResult = sal_True;
137 : 0 : }
138 : : }
139 : 0 : return bResult;
140 : : }
141 : 0 : sal_Bool operator()(const ScAccessibleShapeData* pData1, const ScAccessibleShapeData* pData2) const
142 : : {
143 : 0 : sal_Bool bResult(false);
144 [ # # ][ # # ]: 0 : if (pData1 && pData2)
145 : : {
146 [ # # ]: 0 : uno::Reference< beans::XPropertySet> xProps1(pData1->xShape, uno::UNO_QUERY);
147 [ # # ]: 0 : uno::Reference< beans::XPropertySet> xProps2(pData2->xShape, uno::UNO_QUERY);
148 [ # # ][ # # ]: 0 : if (xProps1.is() && xProps2.is())
[ # # ]
149 : : {
150 [ # # ][ # # ]: 0 : uno::Any aPropAny1 = xProps1->getPropertyValue(msLayerId);
151 [ # # ][ # # ]: 0 : uno::Any aPropAny2 = xProps2->getPropertyValue(msLayerId);
152 : 0 : sal_Int16 nLayerID1(0);
153 : 0 : sal_Int16 nLayerID2(0);
154 [ # # ][ # # ]: 0 : if( (aPropAny1 >>= nLayerID1) && (aPropAny2 >>= nLayerID2) )
[ # # ]
155 : : {
156 [ # # ]: 0 : if (nLayerID1 == nLayerID2)
157 : : {
158 [ # # ][ # # ]: 0 : uno::Any aAny1 = xProps1->getPropertyValue(msZOrder);
159 : 0 : sal_Int32 nZOrder1 = 0;
160 [ # # ][ # # ]: 0 : uno::Any aAny2 = xProps2->getPropertyValue(msZOrder);
161 : 0 : sal_Int32 nZOrder2 = 0;
162 [ # # ][ # # ]: 0 : if ( (aAny1 >>= nZOrder1) && (aAny2 >>= nZOrder2) )
[ # # ]
163 : 0 : bResult = (nZOrder1 < nZOrder2);
164 : : }
165 : : else
166 : : {
167 : 0 : ConvertLayerId(nLayerID1);
168 : 0 : ConvertLayerId(nLayerID2);
169 : 0 : bResult = (nLayerID1 < nLayerID2);
170 : : }
171 : 0 : }
172 : 0 : }
173 : : }
174 [ # # ][ # # ]: 0 : else if (pData1 && !pData2)
175 : 0 : bResult = LessThanSheet(pData1);
176 [ # # ][ # # ]: 0 : else if (!pData1 && pData2)
177 : 0 : bResult = !LessThanSheet(pData2);
178 : : else
179 : 0 : bResult = false;
180 : 0 : return bResult;
181 : : }
182 : : };
183 : :
184 : : struct DeselectShape
185 : : {
186 : 0 : void operator() (const ScAccessibleShapeData* pAccShapeData) const
187 : : {
188 [ # # ]: 0 : if (pAccShapeData)
189 : : {
190 : 0 : pAccShapeData->bSelected = false;
191 [ # # ]: 0 : if (pAccShapeData->pAccShape)
192 : 0 : pAccShapeData->pAccShape->ResetState(AccessibleStateType::SELECTED);
193 : : }
194 : 0 : }
195 : : };
196 : :
197 : 0 : struct SelectShape
198 : : {
199 : : uno::Reference < drawing::XShapes > xShapes;
200 : 0 : SelectShape(uno::Reference<drawing::XShapes>& xTemp) : xShapes(xTemp) {}
201 : 0 : void operator() (const ScAccessibleShapeData* pAccShapeData) const
202 : : {
203 [ # # ][ # # ]: 0 : if (pAccShapeData && pAccShapeData->bSelectable)
204 : : {
205 : 0 : pAccShapeData->bSelected = sal_True;
206 [ # # ]: 0 : if (pAccShapeData->pAccShape)
207 : 0 : pAccShapeData->pAccShape->SetState(AccessibleStateType::SELECTED);
208 [ # # ]: 0 : if (xShapes.is())
209 : 0 : xShapes->add(pAccShapeData->xShape);
210 : : }
211 : 0 : }
212 : : };
213 : :
214 : : struct Destroy
215 : : {
216 : 5 : void operator() (ScAccessibleShapeData* pData)
217 : : {
218 [ - + ]: 5 : if (pData)
219 [ # # ]: 0 : DELETEZ(pData);
220 : 5 : }
221 : : };
222 : :
223 : : class ScChildrenShapes : public SfxListener,
224 : : public ::accessibility::IAccessibleParent
225 : : {
226 : : public:
227 : : ScChildrenShapes(ScAccessibleDocument* pAccessibleDocument, ScTabViewShell* pViewShell, ScSplitPos eSplitPos);
228 : : ~ScChildrenShapes();
229 : :
230 : : ///===== SfxListener =====================================================
231 : :
232 : : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
233 : :
234 : : ///===== IAccessibleParent ===============================================
235 : :
236 : : virtual sal_Bool ReplaceChild (
237 : : ::accessibility::AccessibleShape* pCurrentChild,
238 : : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
239 : : const long _nIndex,
240 : : const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo
241 : : ) throw (::com::sun::star::uno::RuntimeException);
242 : :
243 : : ///===== Internal ========================================================
244 : : void SetDrawBroadcaster();
245 : :
246 : : sal_Int32 GetCount() const;
247 : : uno::Reference< XAccessible > Get(const ScAccessibleShapeData* pData) const;
248 : : uno::Reference< XAccessible > Get(sal_Int32 nIndex) const;
249 : : uno::Reference< XAccessible > GetAt(const awt::Point& rPoint) const;
250 : :
251 : : // gets the index of the shape starting on 0 (without the index of the table)
252 : : // returns the selected shape
253 : : sal_Bool IsSelected(sal_Int32 nIndex,
254 : : com::sun::star::uno::Reference<com::sun::star::drawing::XShape>& rShape) const;
255 : :
256 : : sal_Bool SelectionChanged();
257 : :
258 : : void Select(sal_Int32 nIndex);
259 : : void DeselectAll(); // deselect also the table
260 : : void SelectAll();
261 : : sal_Int32 GetSelectedCount() const;
262 : : uno::Reference< XAccessible > GetSelected(sal_Int32 nSelectedChildIndex, sal_Bool bTabSelected) const;
263 : : void Deselect(sal_Int32 nChildIndex);
264 : :
265 : : SdrPage* GetDrawPage() const;
266 : :
267 : : utl::AccessibleRelationSetHelper* GetRelationSet(const ScAddress* pAddress) const;
268 : :
269 : : void VisAreaChanged() const;
270 : : private:
271 : : typedef std::vector<ScAccessibleShapeData*> SortedShapes;
272 : :
273 : : mutable SortedShapes maZOrderedShapes; // a null pointer represents the sheet in the correct order
274 : :
275 : : mutable ::accessibility::AccessibleShapeTreeInfo maShapeTreeInfo;
276 : : mutable com::sun::star::uno::Reference<com::sun::star::view::XSelectionSupplier> xSelectionSupplier;
277 : : mutable sal_uInt32 mnSdrObjCount;
278 : : mutable sal_uInt32 mnShapesSelected;
279 : : ScTabViewShell* mpViewShell;
280 : : ScAccessibleDocument* mpAccessibleDocument;
281 : : ScSplitPos meSplitPos;
282 : :
283 : : void FillShapes(std::vector < uno::Reference < drawing::XShape > >& rShapes) const;
284 : : sal_Bool FindSelectedShapesChanges(const com::sun::star::uno::Reference<com::sun::star::drawing::XShapes>& xShapes, sal_Bool bCommitChange) const;
285 : : void FillSelectionSupplier() const;
286 : :
287 : : ScAddress* GetAnchor(const uno::Reference<drawing::XShape>& xShape) const;
288 : : uno::Reference<XAccessibleRelationSet> GetRelationSet(const ScAccessibleShapeData* pData) const;
289 : : void CheckWhetherAnchorChanged(const uno::Reference<drawing::XShape>& xShape) const;
290 : : void SetAnchor(const uno::Reference<drawing::XShape>& xShape, ScAccessibleShapeData* pData) const;
291 : : void AddShape(const uno::Reference<drawing::XShape>& xShape, sal_Bool bCommitChange) const;
292 : : void RemoveShape(const uno::Reference<drawing::XShape>& xShape) const;
293 : :
294 : : sal_Bool FindShape(const uno::Reference<drawing::XShape>& xShape, SortedShapes::iterator& rItr) const;
295 : :
296 : : sal_Int8 Compare(const ScAccessibleShapeData* pData1,
297 : : const ScAccessibleShapeData* pData2) const;
298 : : };
299 : :
300 : 5 : ScChildrenShapes::ScChildrenShapes(ScAccessibleDocument* pAccessibleDocument, ScTabViewShell* pViewShell, ScSplitPos eSplitPos)
301 : : :
302 : : mnShapesSelected(0),
303 : : mpViewShell(pViewShell),
304 : : mpAccessibleDocument(pAccessibleDocument),
305 [ + - ][ + - ]: 5 : meSplitPos(eSplitPos)
306 : : {
307 [ + - ]: 5 : FillSelectionSupplier();
308 [ + - ]: 5 : maZOrderedShapes.push_back(NULL); // add an element which represents the table
309 : :
310 [ + - ]: 5 : GetCount(); // fill list with filtered shapes (no internal shapes)
311 : :
312 [ - + ]: 5 : if (mnShapesSelected)
313 : : {
314 : : //set flag on every selected shape
315 [ # # ]: 0 : if (!xSelectionSupplier.is())
316 [ # # ]: 0 : throw uno::RuntimeException();
317 : :
318 [ # # ][ # # ]: 0 : uno::Reference<drawing::XShapes> xShapes(xSelectionSupplier->getSelection(), uno::UNO_QUERY);
[ # # ]
319 [ # # ]: 0 : if (xShapes.is())
320 [ # # ]: 0 : FindSelectedShapesChanges(xShapes, false);
321 : : }
322 [ + - ]: 5 : if (pViewShell)
323 : : {
324 [ + - ][ + - ]: 5 : SfxBroadcaster* pDrawBC = pViewShell->GetViewData()->GetDocument()->GetDrawBroadcaster();
325 [ + - ]: 5 : if (pDrawBC)
326 : : {
327 [ + - ]: 5 : StartListening(*pDrawBC);
328 : :
329 [ + - ][ + - ]: 5 : maShapeTreeInfo.SetModelBroadcaster( new ScDrawModelBroadcaster(pViewShell->GetViewData()->GetDocument()->GetDrawLayer()) );
[ + - ][ + - ]
[ + - ][ + - ]
330 [ + - ][ + - ]: 5 : maShapeTreeInfo.SetSdrView(pViewShell->GetViewData()->GetScDrawView());
331 [ + - ][ + - ]: 5 : maShapeTreeInfo.SetController(NULL);
332 [ + - ][ + - ]: 5 : maShapeTreeInfo.SetWindow(pViewShell->GetWindowByPos(meSplitPos));
333 [ + - ][ + - ]: 5 : maShapeTreeInfo.SetViewForwarder(mpAccessibleDocument);
334 : : }
335 : : }
336 : 5 : }
337 : :
338 [ + - ]: 5 : ScChildrenShapes::~ScChildrenShapes()
339 : : {
340 [ + - ]: 5 : std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), Destroy());
341 [ + - ]: 5 : if (mpViewShell)
342 : : {
343 [ + - ][ + - ]: 5 : SfxBroadcaster* pDrawBC = mpViewShell->GetViewData()->GetDocument()->GetDrawBroadcaster();
344 [ + - ]: 5 : if (pDrawBC)
345 [ + - ]: 5 : EndListening(*pDrawBC);
346 : : }
347 [ - + ]: 10 : }
348 : :
349 : 0 : void ScChildrenShapes::SetDrawBroadcaster()
350 : : {
351 [ # # ]: 0 : if (mpViewShell)
352 : : {
353 : 0 : SfxBroadcaster* pDrawBC = mpViewShell->GetViewData()->GetDocument()->GetDrawBroadcaster();
354 [ # # ]: 0 : if (pDrawBC)
355 : : {
356 : 0 : StartListening(*pDrawBC, sal_True);
357 : :
358 [ # # ][ # # ]: 0 : maShapeTreeInfo.SetModelBroadcaster( new ScDrawModelBroadcaster(mpViewShell->GetViewData()->GetDocument()->GetDrawLayer()) );
[ # # ]
359 : 0 : maShapeTreeInfo.SetSdrView(mpViewShell->GetViewData()->GetScDrawView());
360 [ # # ]: 0 : maShapeTreeInfo.SetController(NULL);
361 : 0 : maShapeTreeInfo.SetWindow(mpViewShell->GetWindowByPos(meSplitPos));
362 [ # # ]: 0 : maShapeTreeInfo.SetViewForwarder(mpAccessibleDocument);
363 : : }
364 : : }
365 : 0 : }
366 : :
367 : 6 : void ScChildrenShapes::Notify(SfxBroadcaster&, const SfxHint& rHint)
368 : : {
369 [ + + ]: 6 : if ( rHint.ISA( SdrHint ) )
370 : : {
371 [ + - ][ + - ]: 1 : const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
372 [ + - ]: 1 : if (pSdrHint)
373 : : {
374 : 1 : SdrObject* pObj = const_cast<SdrObject*>(pSdrHint->GetObject());
375 [ # # # # ]: 1 : if (pObj && /*(pObj->GetLayer() != SC_LAYER_INTERN) && */(pObj->GetPage() == GetDrawPage()) &&
[ - + ][ - + ]
376 : 0 : (pObj->GetPage() == pObj->GetObjList()) ) //only do something if the object lies direct on the page
377 : : {
378 [ # # # # ]: 0 : switch (pSdrHint->GetKind())
379 : : {
380 : : case HINT_OBJCHG : // Objekt geaendert
381 : : {
382 [ # # ][ # # ]: 0 : uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY);
383 [ # # ]: 0 : if (xShape.is())
384 : : {
385 [ # # ]: 0 : ScShapeDataLess aLess;
386 [ # # ]: 0 : std::sort(maZOrderedShapes.begin(), maZOrderedShapes.end(), aLess); // sort, because the z index or layer could be changed
387 [ # # ]: 0 : CheckWhetherAnchorChanged(xShape);
388 : 0 : }
389 : : }
390 : 0 : break;
391 : : case HINT_OBJINSERTED : // Neues Zeichenobjekt eingefuegt
392 : : {
393 [ # # ][ # # ]: 0 : uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY);
394 [ # # ]: 0 : if (xShape.is())
395 [ # # ]: 0 : AddShape(xShape, sal_True);
396 : : }
397 : 0 : break;
398 : : case HINT_OBJREMOVED : // Zeichenobjekt aus Liste entfernt
399 : : {
400 [ # # ][ # # ]: 0 : uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY);
401 [ # # ]: 0 : if (xShape.is())
402 [ # # ]: 0 : RemoveShape(xShape);
403 : : }
404 : 0 : break;
405 : : default :
406 : : {
407 : : // other events are not interesting
408 : : }
409 : 0 : break;
410 : : }
411 : : }
412 : : }
413 : : }
414 : 6 : }
415 : :
416 : 0 : sal_Bool ScChildrenShapes::ReplaceChild (::accessibility::AccessibleShape* pCurrentChild,
417 : : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
418 : : const long _nIndex, const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo)
419 : : throw (uno::RuntimeException)
420 : : {
421 : : // create the new child
422 [ # # ]: 0 : ::accessibility::AccessibleShape* pReplacement = ::accessibility::ShapeTypeHandler::Instance().CreateAccessibleObject (
423 : 0 : ::accessibility::AccessibleShapeInfo ( _rxShape, pCurrentChild->getAccessibleParent(), this, _nIndex ),
424 : : _rShapeTreeInfo
425 [ # # ][ # # ]: 0 : );
[ # # ][ # # ]
426 [ # # ][ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xNewChild( pReplacement ); // keep this alive (do this before calling Init!)
427 [ # # ]: 0 : if ( pReplacement )
428 [ # # ]: 0 : pReplacement->Init();
429 : :
430 : 0 : sal_Bool bResult(false);
431 [ # # ][ # # ]: 0 : if (pCurrentChild && pReplacement)
432 : : {
433 : : OSL_ENSURE(pCurrentChild->GetXShape().get() == pReplacement->GetXShape().get(), "XShape changes and should be inserted sorted");
434 : 0 : SortedShapes::iterator aItr;
435 [ # # ][ # # ]: 0 : FindShape(pCurrentChild->GetXShape(), aItr);
436 [ # # ][ # # ]: 0 : if (aItr != maZOrderedShapes.end() && (*aItr))
[ # # ]
[ # # # # ]
[ # # ]
437 : : {
438 [ # # ]: 0 : if ((*aItr)->pAccShape)
439 : : {
440 : : OSL_ENSURE((*aItr)->pAccShape == pCurrentChild, "wrong child found");
441 [ # # ]: 0 : AccessibleEventObject aEvent;
442 : 0 : aEvent.EventId = AccessibleEventId::CHILD;
443 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument);
[ # # ]
444 [ # # ][ # # ]: 0 : aEvent.OldValue <<= uno::makeAny(uno::Reference<XAccessible>(pCurrentChild));
[ # # ][ # # ]
445 : :
446 [ # # ]: 0 : mpAccessibleDocument->CommitChange(aEvent); // child is gone - event
447 : :
448 [ # # ][ # # ]: 0 : pCurrentChild->dispose();
449 : : }
450 : 0 : (*aItr)->pAccShape = pReplacement;
451 [ # # ]: 0 : AccessibleEventObject aEvent;
452 : 0 : aEvent.EventId = AccessibleEventId::CHILD;
453 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument);
[ # # ]
454 [ # # ][ # # ]: 0 : aEvent.NewValue <<= uno::makeAny(uno::Reference<XAccessible>(pReplacement));
[ # # ][ # # ]
455 : :
456 [ # # ]: 0 : mpAccessibleDocument->CommitChange(aEvent); // child is new - event
457 [ # # ]: 0 : bResult = sal_True;
458 : : }
459 : : }
460 : 0 : return bResult;
461 : : }
462 : :
463 : 29 : sal_Int32 ScChildrenShapes::GetCount() const
464 : : {
465 : 29 : SdrPage* pDrawPage = GetDrawPage();
466 [ # # ][ - + ]: 29 : if (pDrawPage && (maZOrderedShapes.size() == 1)) // the table is always in
[ - + ]
467 : : {
468 : 0 : mnSdrObjCount = pDrawPage->GetObjCount();
469 : 0 : maZOrderedShapes.reserve(mnSdrObjCount + 1); // the table is always in
470 [ # # ]: 0 : for (sal_uInt32 i = 0; i < mnSdrObjCount; ++i)
471 : : {
472 : 0 : SdrObject* pObj = pDrawPage->GetObj(i);
473 [ # # ]: 0 : if (pObj/* && (pObj->GetLayer() != SC_LAYER_INTERN)*/)
474 : : {
475 [ # # ][ # # ]: 0 : uno::Reference< drawing::XShape > xShape (pObj->getUnoShape(), uno::UNO_QUERY);
476 [ # # ]: 0 : AddShape(xShape, false); //inserts in the correct order
477 : : }
478 : : }
479 : : }
480 : 29 : return maZOrderedShapes.size();
481 : : }
482 : :
483 : 5 : uno::Reference< XAccessible > ScChildrenShapes::Get(const ScAccessibleShapeData* pData) const
484 : : {
485 [ + - ]: 5 : if (!pData)
486 : 5 : return NULL;
487 : :
488 [ # # ]: 0 : if (!pData->pAccShape)
489 : : {
490 [ # # ]: 0 : ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance();
491 [ # # ][ # # ]: 0 : ::accessibility::AccessibleShapeInfo aShapeInfo(pData->xShape, mpAccessibleDocument, const_cast<ScChildrenShapes*>(this));
[ # # ]
492 : : pData->pAccShape = rShapeHandler.CreateAccessibleObject(
493 [ # # ]: 0 : aShapeInfo, maShapeTreeInfo);
494 [ # # ]: 0 : if (pData->pAccShape)
495 : : {
496 : 0 : pData->pAccShape->acquire();
497 [ # # ]: 0 : pData->pAccShape->Init();
498 [ # # ]: 0 : if (pData->bSelected)
499 [ # # ]: 0 : pData->pAccShape->SetState(AccessibleStateType::SELECTED);
500 [ # # ]: 0 : if (!pData->bSelectable)
501 [ # # ]: 0 : pData->pAccShape->ResetState(AccessibleStateType::SELECTABLE);
502 [ # # ][ # # ]: 0 : pData->pAccShape->SetRelationSet(GetRelationSet(pData));
503 [ # # ]: 0 : }
504 : : }
505 [ # # ]: 5 : return pData->pAccShape;
506 : : }
507 : :
508 : 5 : uno::Reference< XAccessible > ScChildrenShapes::Get(sal_Int32 nIndex) const
509 : : {
510 [ + - ]: 5 : if (maZOrderedShapes.size() <= 1)
511 : 5 : GetCount(); // fill list with filtered shapes (no internal shapes)
512 : :
513 [ - + ]: 5 : if (static_cast<sal_uInt32>(nIndex) >= maZOrderedShapes.size())
514 : 0 : return NULL;
515 : :
516 : 5 : return Get(maZOrderedShapes[nIndex]);
517 : : }
518 : :
519 : 0 : uno::Reference< XAccessible > ScChildrenShapes::GetAt(const awt::Point& rPoint) const
520 : : {
521 : 0 : uno::Reference<XAccessible> xAccessible;
522 [ # # ]: 0 : if(mpViewShell)
523 : : {
524 : 0 : sal_Int32 i(maZOrderedShapes.size() - 1);
525 : 0 : sal_Bool bFound(false);
526 [ # # ][ # # ]: 0 : while (!bFound && i >= 0)
[ # # ]
527 : : {
528 : 0 : ScAccessibleShapeData* pShape = maZOrderedShapes[i];
529 [ # # ]: 0 : if (pShape)
530 : : {
531 [ # # ]: 0 : if (!pShape->pAccShape)
532 [ # # ]: 0 : Get(pShape);
533 : :
534 [ # # ]: 0 : if (pShape->pAccShape)
535 : : {
536 : 0 : Point aPoint(VCLPoint(rPoint));
537 [ # # ][ # # ]: 0 : aPoint -= VCLRectangle(pShape->pAccShape->getBounds()).TopLeft();
538 [ # # ][ # # ]: 0 : if (pShape->pAccShape->containsPoint(AWTPoint(aPoint)))
539 : : {
540 [ # # ][ # # ]: 0 : xAccessible = pShape->pAccShape;
541 : 0 : bFound = sal_True;
542 : : }
543 : : }
544 : : else
545 : : {
546 : : OSL_FAIL("I should have an accessible shape now!");
547 : : }
548 : : }
549 : : else
550 : 0 : bFound = sal_True; // this is the sheet and it lies before the rest of the shapes which are background shapes
551 : :
552 : 0 : --i;
553 : : }
554 : : }
555 : 0 : return xAccessible;
556 : : }
557 : :
558 : 0 : sal_Bool ScChildrenShapes::IsSelected(sal_Int32 nIndex,
559 : : uno::Reference<drawing::XShape>& rShape) const
560 : : {
561 : 0 : sal_Bool bResult (false);
562 [ # # ]: 0 : if (maZOrderedShapes.size() <= 1)
563 : 0 : GetCount(); // fill list with filtered shapes (no internal shapes)
564 : :
565 [ # # ]: 0 : if (!xSelectionSupplier.is())
566 [ # # ]: 0 : throw uno::RuntimeException();
567 : :
568 [ # # ]: 0 : if (!maZOrderedShapes[nIndex])
569 : 0 : return false;
570 : :
571 : 0 : bResult = maZOrderedShapes[nIndex]->bSelected;
572 : 0 : rShape = maZOrderedShapes[nIndex]->xShape;
573 : :
574 : : #if OSL_DEBUG_LEVEL > 0 // test whether it is truly selected by a slower method
575 : : uno::Reference< drawing::XShape > xReturnShape;
576 : : sal_Bool bDebugResult(false);
577 : : uno::Reference<container::XIndexAccess> xIndexAccess;
578 : : xSelectionSupplier->getSelection() >>= xIndexAccess;
579 : :
580 : : if (xIndexAccess.is())
581 : : {
582 : : sal_Int32 nCount(xIndexAccess->getCount());
583 : : if (nCount)
584 : : {
585 : : uno::Reference< drawing::XShape > xShape;
586 : : uno::Reference< drawing::XShape > xIndexShape = maZOrderedShapes[nIndex]->xShape;
587 : : sal_Int32 i(0);
588 : : while (!bDebugResult && (i < nCount))
589 : : {
590 : : xIndexAccess->getByIndex(i) >>= xShape;
591 : : if (xShape.is() && (xIndexShape.get() == xShape.get()))
592 : : {
593 : : bDebugResult = sal_True;
594 : : xReturnShape = xShape;
595 : : }
596 : : else
597 : : ++i;
598 : : }
599 : : }
600 : : }
601 : : OSL_ENSURE((bResult == bDebugResult) && ((bResult && (rShape.get() == xReturnShape.get())) || !bResult), "found the wrong shape or result");
602 : : #endif
603 : :
604 : 0 : return bResult;
605 : : }
606 : :
607 : 2 : sal_Bool ScChildrenShapes::SelectionChanged()
608 : : {
609 : 2 : sal_Bool bResult(false);
610 [ - + ]: 2 : if (!xSelectionSupplier.is())
611 [ # # ]: 0 : throw uno::RuntimeException();
612 : :
613 [ + - ][ + - ]: 2 : uno::Reference<drawing::XShapes> xShapes(xSelectionSupplier->getSelection(), uno::UNO_QUERY);
[ + - ]
614 : :
615 [ + - ]: 2 : bResult = FindSelectedShapesChanges(xShapes, sal_True);
616 : :
617 : 2 : return bResult;
618 : : }
619 : :
620 : 0 : void ScChildrenShapes::Select(sal_Int32 nIndex)
621 : : {
622 [ # # ]: 0 : if (maZOrderedShapes.size() <= 1)
623 [ # # ]: 0 : GetCount(); // fill list with filtered shapes (no internal shapes)
624 : :
625 [ # # ]: 0 : if (!xSelectionSupplier.is())
626 [ # # ]: 0 : throw uno::RuntimeException();
627 : :
628 [ # # ]: 0 : if (!maZOrderedShapes[nIndex])
629 : 0 : return;
630 : :
631 : 0 : uno::Reference<drawing::XShape> xShape;
632 [ # # ][ # # ]: 0 : if (!IsSelected(nIndex, xShape) && maZOrderedShapes[nIndex]->bSelectable)
[ # # ][ # # ]
633 : : {
634 : 0 : uno::Reference<drawing::XShapes> xShapes;
635 [ # # ][ # # ]: 0 : xSelectionSupplier->getSelection() >>= xShapes;
[ # # ]
636 : :
637 [ # # ]: 0 : if (!xShapes.is())
638 [ # # ][ # # ]: 0 : xShapes = new SvxShapeCollection();
639 : :
640 [ # # ][ # # ]: 0 : xShapes->add(maZOrderedShapes[nIndex]->xShape);
641 : :
642 : : try
643 : : {
644 [ # # ][ # # ]: 0 : xSelectionSupplier->select(uno::makeAny(xShapes));
[ # # ][ # # ]
645 : 0 : maZOrderedShapes[nIndex]->bSelected = sal_True;
646 [ # # ]: 0 : if (maZOrderedShapes[nIndex]->pAccShape)
647 [ # # ]: 0 : maZOrderedShapes[nIndex]->pAccShape->SetState(AccessibleStateType::SELECTED);
648 : : }
649 [ # # ]: 0 : catch (lang::IllegalArgumentException&)
650 : : {
651 : 0 : }
652 : 0 : }
653 : : }
654 : :
655 : 0 : void ScChildrenShapes::DeselectAll()
656 : : {
657 [ # # ]: 0 : if (!xSelectionSupplier.is())
658 [ # # ]: 0 : throw uno::RuntimeException();
659 : :
660 : 0 : sal_Bool bSomethingSelected(sal_True);
661 : : try
662 : : {
663 [ # # ][ # # ]: 0 : xSelectionSupplier->select(uno::Any()); //deselects all
[ # # ]
664 : : }
665 : 0 : catch (lang::IllegalArgumentException&)
666 : : {
667 : : OSL_FAIL("nothing selected before");
668 : 0 : bSomethingSelected = false;
669 : : }
670 : :
671 [ # # ]: 0 : if (bSomethingSelected)
672 [ # # ]: 0 : std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), DeselectShape());
673 : 0 : }
674 : :
675 : 0 : void ScChildrenShapes::SelectAll()
676 : : {
677 [ # # ]: 0 : if (!xSelectionSupplier.is())
678 [ # # ]: 0 : throw uno::RuntimeException();
679 : :
680 [ # # ]: 0 : if (maZOrderedShapes.size() <= 1)
681 : 0 : GetCount(); // fill list with filtered shapes (no internal shapes)
682 : :
683 [ # # ]: 0 : if (maZOrderedShapes.size() > 1)
684 : : {
685 : 0 : uno::Reference<drawing::XShapes> xShapes;
686 [ # # ][ # # ]: 0 : xShapes = new SvxShapeCollection();
687 : :
688 : : try
689 : : {
690 [ # # ][ # # ]: 0 : std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), SelectShape(xShapes));
[ # # ][ # # ]
691 [ # # ][ # # ]: 0 : xSelectionSupplier->select(uno::makeAny(xShapes));
[ # # ]
692 : : }
693 [ # # # # ]: 0 : catch (lang::IllegalArgumentException&)
694 : : {
695 [ # # ]: 0 : SelectionChanged(); // find all selected shapes and set the flags
696 : 0 : }
697 : : }
698 : 0 : }
699 : :
700 : 0 : void ScChildrenShapes::FillShapes(std::vector < uno::Reference < drawing::XShape > >& rShapes) const
701 : : {
702 : 0 : uno::Reference<container::XIndexAccess> xIndexAccess;
703 [ # # ][ # # ]: 0 : xSelectionSupplier->getSelection() >>= xIndexAccess;
[ # # ]
704 : :
705 [ # # ]: 0 : if (xIndexAccess.is())
706 : : {
707 [ # # ][ # # ]: 0 : sal_uInt32 nCount(xIndexAccess->getCount());
708 [ # # ]: 0 : for (sal_uInt32 i = 0; i < nCount; ++i)
709 : : {
710 : 0 : uno::Reference<drawing::XShape> xShape;
711 [ # # ][ # # ]: 0 : xIndexAccess->getByIndex(i) >>= xShape;
[ # # ]
712 [ # # ]: 0 : if (xShape.is())
713 [ # # ]: 0 : rShapes.push_back(xShape);
714 : 0 : }
715 : 0 : }
716 : 0 : }
717 : :
718 : 0 : sal_Int32 ScChildrenShapes::GetSelectedCount() const
719 : : {
720 [ # # ]: 0 : if (!xSelectionSupplier.is())
721 [ # # ]: 0 : throw uno::RuntimeException();
722 : :
723 [ # # ]: 0 : std::vector < uno::Reference < drawing::XShape > > aShapes;
724 [ # # ]: 0 : FillShapes(aShapes);
725 : :
726 : 0 : return aShapes.size();
727 : : }
728 : :
729 : 0 : uno::Reference< XAccessible > ScChildrenShapes::GetSelected(sal_Int32 nSelectedChildIndex, sal_Bool bTabSelected) const
730 : : {
731 : 0 : uno::Reference< XAccessible > xAccessible;
732 : :
733 [ # # ]: 0 : if (maZOrderedShapes.size() <= 1)
734 [ # # ]: 0 : GetCount(); // fill list with shapes
735 : :
736 [ # # ]: 0 : if (!bTabSelected)
737 : : {
738 [ # # ]: 0 : std::vector < uno::Reference < drawing::XShape > > aShapes;
739 [ # # ]: 0 : FillShapes(aShapes);
740 : :
741 : 0 : SortedShapes::iterator aItr;
742 [ # # ][ # # ]: 0 : if (FindShape(aShapes[nSelectedChildIndex], aItr))
743 [ # # ][ # # ]: 0 : xAccessible = Get(aItr - maZOrderedShapes.begin());
[ # # ]
744 : : }
745 : : else
746 : : {
747 : 0 : SortedShapes::iterator aItr = maZOrderedShapes.begin();
748 : 0 : SortedShapes::iterator aEndItr = maZOrderedShapes.end();
749 : 0 : sal_Bool bFound(false);
750 [ # # ][ # # ]: 0 : while(!bFound && aItr != aEndItr)
[ # # ][ # # ]
751 : : {
752 [ # # ]: 0 : if (*aItr)
753 : : {
754 [ # # ]: 0 : if ((*aItr)->bSelected)
755 : : {
756 [ # # ]: 0 : if (nSelectedChildIndex == 0)
757 : 0 : bFound = sal_True;
758 : : else
759 : 0 : --nSelectedChildIndex;
760 : : }
761 : : }
762 : : else
763 : : {
764 [ # # ]: 0 : if (nSelectedChildIndex == 0)
765 : 0 : bFound = sal_True;
766 : : else
767 : 0 : --nSelectedChildIndex;
768 : : }
769 [ # # ]: 0 : if (!bFound)
770 : 0 : ++aItr;
771 : : }
772 [ # # ][ # # ]: 0 : if (bFound && *aItr)
[ # # ]
773 [ # # ][ # # ]: 0 : xAccessible = (*aItr)->pAccShape;
774 : : }
775 : :
776 : 0 : return xAccessible;
777 : : }
778 : :
779 : 0 : void ScChildrenShapes::Deselect(sal_Int32 nChildIndex)
780 : : {
781 : 0 : uno::Reference<drawing::XShape> xShape;
782 [ # # ][ # # ]: 0 : if (IsSelected(nChildIndex, xShape)) // returns false if it is the sheet
783 : : {
784 [ # # ]: 0 : if (xShape.is())
785 : : {
786 : 0 : uno::Reference<drawing::XShapes> xShapes;
787 [ # # ][ # # ]: 0 : xSelectionSupplier->getSelection() >>= xShapes;
[ # # ]
788 [ # # ]: 0 : if (xShapes.is())
789 [ # # ][ # # ]: 0 : xShapes->remove(xShape);
790 : :
791 : : try
792 : : {
793 [ # # ][ # # ]: 0 : xSelectionSupplier->select(uno::makeAny(xShapes));
[ # # ][ # # ]
794 : : }
795 [ # # ]: 0 : catch (lang::IllegalArgumentException&)
796 : : {
797 : : OSL_FAIL("something not selectable");
798 : : }
799 : :
800 : 0 : maZOrderedShapes[nChildIndex]->bSelected = false;
801 [ # # ]: 0 : if (maZOrderedShapes[nChildIndex]->pAccShape)
802 [ # # ]: 0 : maZOrderedShapes[nChildIndex]->pAccShape->ResetState(AccessibleStateType::SELECTED);
803 : : }
804 : 0 : }
805 : 0 : }
806 : :
807 : :
808 : 29 : SdrPage* ScChildrenShapes::GetDrawPage() const
809 : : {
810 : 29 : SCTAB nTab(mpAccessibleDocument->getVisibleTable());
811 : 29 : SdrPage* pDrawPage = NULL;
812 [ + - ]: 29 : if (mpViewShell)
813 : : {
814 : 29 : ScDocument* pDoc = mpViewShell->GetViewData()->GetDocument();
815 [ + - ][ + - ]: 29 : if (pDoc && pDoc->GetDrawLayer())
[ + - ]
816 : : {
817 : 29 : ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
818 [ # # ][ - + ]: 29 : if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab))
[ - + ]
819 : 0 : pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(static_cast<sal_Int16>(nTab)));
820 : : }
821 : : }
822 : 29 : return pDrawPage;
823 : : }
824 : :
825 : : struct SetRelation
826 : : {
827 : : const ScChildrenShapes* mpChildrenShapes;
828 : : mutable utl::AccessibleRelationSetHelper* mpRelationSet;
829 : : const ScAddress* mpAddress;
830 : 2 : SetRelation(const ScChildrenShapes* pChildrenShapes, const ScAddress* pAddress)
831 : : :
832 : : mpChildrenShapes(pChildrenShapes),
833 : : mpRelationSet(NULL),
834 : 2 : mpAddress(pAddress)
835 : : {
836 : 2 : }
837 : 2 : void operator() (const ScAccessibleShapeData* pAccShapeData) const
838 : : {
839 [ - + ][ # # ]: 2 : if (pAccShapeData &&
[ # # ][ # # ]
[ # # # # ]
[ - + ]
840 : 0 : ((!pAccShapeData->pRelationCell && !mpAddress) ||
841 : 0 : (pAccShapeData->pRelationCell && mpAddress && (*(pAccShapeData->pRelationCell) == *mpAddress))))
842 : : {
843 [ # # ]: 0 : if (!mpRelationSet)
844 [ # # ]: 0 : mpRelationSet = new utl::AccessibleRelationSetHelper();
845 : :
846 [ # # ]: 0 : AccessibleRelation aRelation;
847 [ # # ]: 0 : aRelation.TargetSet.realloc(1);
848 [ # # ][ # # ]: 0 : aRelation.TargetSet[0] = mpChildrenShapes->Get(pAccShapeData);
[ # # ]
849 : 0 : aRelation.RelationType = AccessibleRelationType::CONTROLLER_FOR;
850 : :
851 [ # # ][ # # ]: 0 : mpRelationSet->AddRelation(aRelation);
852 : : }
853 : 2 : }
854 : : };
855 : :
856 : 2 : utl::AccessibleRelationSetHelper* ScChildrenShapes::GetRelationSet(const ScAddress* pAddress) const
857 : : {
858 : 2 : SetRelation aSetRelation(this, pAddress);
859 [ + - ]: 2 : ::std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), aSetRelation);
860 : 2 : return aSetRelation.mpRelationSet;
861 : : }
862 : :
863 : 2 : sal_Bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::XShapes>& xShapes, sal_Bool /* bCommitChange */) const
864 : : {
865 : 2 : sal_Bool bResult(false);
866 [ + - ]: 2 : SortedShapes aShapesList;
867 [ + - ]: 2 : uno::Reference<container::XIndexAccess> xIndexAcc(xShapes, uno::UNO_QUERY);
868 [ - + ]: 2 : if (xIndexAcc.is())
869 : : {
870 [ # # ][ # # ]: 0 : mnShapesSelected = xIndexAcc->getCount();
871 [ # # ]: 0 : for (sal_uInt32 i = 0; i < mnShapesSelected; ++i)
872 : : {
873 : 0 : uno::Reference< drawing::XShape > xShape;
874 [ # # ][ # # ]: 0 : xIndexAcc->getByIndex(i) >>= xShape;
[ # # ]
875 [ # # ]: 0 : if (xShape.is())
876 : : {
877 [ # # ][ # # ]: 0 : ScAccessibleShapeData* pShapeData = new ScAccessibleShapeData();
878 [ # # ]: 0 : pShapeData->xShape = xShape;
879 [ # # ]: 0 : aShapesList.push_back(pShapeData);
880 : : }
881 : 0 : }
882 : : }
883 : : else
884 : 2 : mnShapesSelected = 0;
885 [ + - ]: 2 : ScShapeDataLess aLess;
886 [ + - ]: 2 : std::sort(aShapesList.begin(), aShapesList.end(), aLess);
887 : :
888 : 2 : SortedShapes::iterator aXShapesItr(aShapesList.begin());
889 [ + - ]: 2 : SortedShapes::const_iterator aXShapesEndItr(aShapesList.end());
890 : 2 : SortedShapes::iterator aDataItr(maZOrderedShapes.begin());
891 [ + - ]: 2 : SortedShapes::const_iterator aDataEndItr(maZOrderedShapes.end());
892 : 2 : SortedShapes::const_iterator aFocusedItr = aDataEndItr;
893 [ + - ][ + + ]: 4 : while((aDataItr != aDataEndItr))
894 : : {
895 [ - + ]: 2 : if (*aDataItr) // is it realy a shape or only the sheet
896 : : {
897 : 0 : sal_Int8 nComp(0);
898 [ # # ][ # # ]: 0 : if (aXShapesItr == aXShapesEndItr)
899 : 0 : nComp = -1; // simulate that the Shape is lower, so the selction state will be removed
900 : : else
901 [ # # ]: 0 : nComp = Compare(*aDataItr, *aXShapesItr);
902 [ # # ]: 0 : if (nComp == 0)
903 : : {
904 [ # # ]: 0 : if (!(*aDataItr)->bSelected)
905 : : {
906 : 0 : (*aDataItr)->bSelected = sal_True;
907 [ # # ]: 0 : if ((*aDataItr)->pAccShape)
908 : : {
909 [ # # ]: 0 : (*aDataItr)->pAccShape->SetState(AccessibleStateType::SELECTED);
910 [ # # ]: 0 : (*aDataItr)->pAccShape->ResetState(AccessibleStateType::FOCUSED);
911 : 0 : bResult = sal_True;
912 : : }
913 [ # # ]: 0 : aFocusedItr = aDataItr;
914 : : }
915 : 0 : ++aDataItr;
916 : 0 : ++aXShapesItr;
917 : : }
918 [ # # ]: 0 : else if (nComp < 0)
919 : : {
920 [ # # ]: 0 : if ((*aDataItr)->bSelected)
921 : : {
922 : 0 : (*aDataItr)->bSelected = false;
923 [ # # ]: 0 : if ((*aDataItr)->pAccShape)
924 : : {
925 [ # # ]: 0 : (*aDataItr)->pAccShape->ResetState(AccessibleStateType::SELECTED);
926 [ # # ]: 0 : (*aDataItr)->pAccShape->ResetState(AccessibleStateType::FOCUSED);
927 : 0 : bResult = sal_True;
928 : : }
929 : : }
930 : 0 : ++aDataItr;
931 : : }
932 : : else
933 : : {
934 : : OSL_FAIL("here is a selected shape which is not in the childlist");
935 : 0 : ++aXShapesItr;
936 : 0 : --mnShapesSelected;
937 : : }
938 : : }
939 : : else
940 : 2 : ++aDataItr;
941 : : }
942 [ + - ][ - + ]: 2 : if ((aFocusedItr != aDataEndItr) && (*aFocusedItr)->pAccShape && (mnShapesSelected == 1))
[ # # ][ # # ]
[ - + ]
943 [ # # ]: 0 : (*aFocusedItr)->pAccShape->SetState(AccessibleStateType::FOCUSED);
944 : :
945 [ + - ]: 2 : std::for_each(aShapesList.begin(), aShapesList.end(), Destroy());
946 : :
947 : 2 : return bResult;
948 : : }
949 : :
950 : 5 : void ScChildrenShapes::FillSelectionSupplier() const
951 : : {
952 [ + - ][ + - ]: 5 : if (!xSelectionSupplier.is() && mpViewShell)
[ + - ]
953 : : {
954 : 5 : SfxViewFrame* pViewFrame = mpViewShell->GetViewFrame();
955 [ + - ]: 5 : if (pViewFrame)
956 : : {
957 [ + - ][ + - ]: 5 : xSelectionSupplier = uno::Reference<view::XSelectionSupplier>(pViewFrame->GetFrame().GetController(), uno::UNO_QUERY);
958 [ + - ]: 5 : if (xSelectionSupplier.is())
959 : : {
960 [ + - ]: 5 : if (mpAccessibleDocument)
961 [ + - ][ + - ]: 5 : xSelectionSupplier->addSelectionChangeListener(mpAccessibleDocument);
[ + - ][ + - ]
962 [ + - ][ + - ]: 5 : uno::Reference<drawing::XShapes> xShapes (xSelectionSupplier->getSelection(), uno::UNO_QUERY);
[ + - ]
963 [ - + ]: 5 : if (xShapes.is())
964 [ # # ][ # # ]: 5 : mnShapesSelected = xShapes->getCount();
965 : : }
966 : : }
967 : : }
968 : 5 : }
969 : :
970 : 0 : ScAddress* ScChildrenShapes::GetAnchor(const uno::Reference<drawing::XShape>& xShape) const
971 : : {
972 : 0 : ScAddress* pAddress = NULL;
973 [ # # ]: 0 : if (mpViewShell)
974 : : {
975 [ # # ]: 0 : SvxShape* pShapeImp = SvxShape::getImplementation(xShape);
976 [ # # ]: 0 : uno::Reference<beans::XPropertySet> xShapeProp(xShape, uno::UNO_QUERY);
977 [ # # ][ # # ]: 0 : if (pShapeImp && xShapeProp.is())
[ # # ]
978 : : {
979 [ # # ][ # # ]: 0 : if (SdrObject *pSdrObj = pShapeImp->GetSdrObject())
980 : : {
981 [ # # ][ # # ]: 0 : if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pSdrObj))
982 [ # # ]: 0 : return new ScAddress(pAnchor->maStart);
983 : : }
984 [ # # ]: 0 : }
985 : : }
986 : :
987 : 0 : return pAddress;
988 : : }
989 : :
990 : 0 : uno::Reference<XAccessibleRelationSet> ScChildrenShapes::GetRelationSet(const ScAccessibleShapeData* pData) const
991 : : {
992 [ # # ]: 0 : utl::AccessibleRelationSetHelper* pRelationSet = new utl::AccessibleRelationSetHelper();
993 : :
994 [ # # ][ # # ]: 0 : if(pData && pRelationSet && mpAccessibleDocument)
[ # # ]
995 : : {
996 [ # # ]: 0 : uno::Reference<XAccessible> xAccessible = mpAccessibleDocument->GetAccessibleSpreadsheet(); // should be the current table
997 [ # # ][ # # ]: 0 : if (pData->pRelationCell && xAccessible.is())
[ # # ]
998 : : {
999 [ # # ][ # # ]: 0 : uno::Reference<XAccessibleTable> xAccTable (xAccessible->getAccessibleContext(), uno::UNO_QUERY);
[ # # ]
1000 [ # # ]: 0 : if (xAccTable.is())
1001 [ # # ][ # # ]: 0 : xAccessible = xAccTable->getAccessibleCellAt(pData->pRelationCell->Row(), pData->pRelationCell->Col());
[ # # ]
1002 : : }
1003 [ # # ]: 0 : AccessibleRelation aRelation;
1004 [ # # ]: 0 : aRelation.TargetSet.realloc(1);
1005 [ # # ][ # # ]: 0 : aRelation.TargetSet[0] = xAccessible;
1006 : 0 : aRelation.RelationType = AccessibleRelationType::CONTROLLED_BY;
1007 [ # # ][ # # ]: 0 : pRelationSet->AddRelation(aRelation);
1008 : : }
1009 : :
1010 [ # # ]: 0 : return pRelationSet;
1011 : : }
1012 : :
1013 : 0 : void ScChildrenShapes::CheckWhetherAnchorChanged(const uno::Reference<drawing::XShape>& xShape) const
1014 : : {
1015 : 0 : SortedShapes::iterator aItr;
1016 [ # # ][ # # ]: 0 : if (FindShape(xShape, aItr))
1017 [ # # ]: 0 : SetAnchor(xShape, *aItr);
1018 : 0 : }
1019 : :
1020 : 0 : void ScChildrenShapes::SetAnchor(const uno::Reference<drawing::XShape>& xShape, ScAccessibleShapeData* pData) const
1021 : : {
1022 [ # # ]: 0 : if (pData)
1023 : : {
1024 : 0 : ScAddress* pAddress = GetAnchor(xShape);
1025 [ # # ][ # # ]: 0 : if ((pAddress && pData->pRelationCell && (*pAddress != *(pData->pRelationCell))) ||
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1026 : 0 : (!pAddress && pData->pRelationCell) || (pAddress && !pData->pRelationCell))
1027 : : {
1028 [ # # ]: 0 : if (pData->pRelationCell)
1029 : 0 : delete pData->pRelationCell;
1030 : 0 : pData->pRelationCell = pAddress;
1031 [ # # ]: 0 : if (pData->pAccShape)
1032 [ # # ]: 0 : pData->pAccShape->SetRelationSet(GetRelationSet(pData));
1033 : : }
1034 : : }
1035 : 0 : }
1036 : :
1037 : 0 : void ScChildrenShapes::AddShape(const uno::Reference<drawing::XShape>& xShape, sal_Bool bCommitChange) const
1038 : : {
1039 : 0 : SortedShapes::iterator aFindItr;
1040 [ # # ][ # # ]: 0 : if (!FindShape(xShape, aFindItr))
1041 : : {
1042 [ # # ][ # # ]: 0 : ScAccessibleShapeData* pShape = new ScAccessibleShapeData();
1043 [ # # ]: 0 : pShape->xShape = xShape;
1044 [ # # ]: 0 : SortedShapes::iterator aNewItr = maZOrderedShapes.insert(aFindItr, pShape);
1045 [ # # ]: 0 : SetAnchor(xShape, pShape);
1046 : :
1047 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xShapeProp(xShape, uno::UNO_QUERY);
1048 [ # # ]: 0 : if (xShapeProp.is())
1049 : : {
1050 [ # # ][ # # ]: 0 : uno::Any aPropAny = xShapeProp->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "LayerID" )));
[ # # ]
1051 : 0 : sal_Int16 nLayerID = 0;
1052 [ # # ]: 0 : if( aPropAny >>= nLayerID )
1053 : : {
1054 [ # # ][ # # ]: 0 : if( (nLayerID == SC_LAYER_INTERN) || (nLayerID == SC_LAYER_HIDDEN) )
1055 : 0 : pShape->bSelectable = false;
1056 : : else
1057 : 0 : pShape->bSelectable = sal_True;
1058 : 0 : }
1059 : : }
1060 : :
1061 : :
1062 [ # # ]: 0 : if (!xSelectionSupplier.is())
1063 [ # # ]: 0 : throw uno::RuntimeException();
1064 : :
1065 [ # # ][ # # ]: 0 : uno::Reference<container::XEnumerationAccess> xEnumAcc(xSelectionSupplier->getSelection(), uno::UNO_QUERY);
[ # # ]
1066 [ # # ]: 0 : if (xEnumAcc.is())
1067 : : {
1068 [ # # ][ # # ]: 0 : uno::Reference<container::XEnumeration> xEnum = xEnumAcc->createEnumeration();
1069 [ # # ]: 0 : if (xEnum.is())
1070 : : {
1071 : 0 : uno::Reference<drawing::XShape> xSelectedShape;
1072 : 0 : sal_Bool bFound(false);
1073 [ # # ][ # # ]: 0 : while (!bFound && xEnum->hasMoreElements())
[ # # ][ # # ]
[ # # ]
1074 : : {
1075 [ # # ][ # # ]: 0 : xEnum->nextElement() >>= xSelectedShape;
[ # # ]
1076 [ # # ][ # # ]: 0 : if (xShape.is() && (xShape.get() == xSelectedShape.get()))
[ # # ][ # # ]
[ # # ]
1077 : : {
1078 : 0 : pShape->bSelected = sal_True;
1079 : 0 : bFound = sal_True;
1080 : : }
1081 : 0 : }
1082 : 0 : }
1083 : : }
1084 [ # # ][ # # ]: 0 : if (mpAccessibleDocument && bCommitChange)
1085 : : {
1086 [ # # ]: 0 : AccessibleEventObject aEvent;
1087 : 0 : aEvent.EventId = AccessibleEventId::CHILD;
1088 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument);
[ # # ]
1089 [ # # ][ # # ]: 0 : aEvent.NewValue <<= Get(aNewItr - maZOrderedShapes.begin());
[ # # ]
1090 : :
1091 [ # # ][ # # ]: 0 : mpAccessibleDocument->CommitChange(aEvent); // new child - event
1092 : 0 : }
1093 : : }
1094 : : else
1095 : : {
1096 : : OSL_FAIL("shape is always in the list");
1097 : : }
1098 : 0 : }
1099 : :
1100 : 0 : void ScChildrenShapes::RemoveShape(const uno::Reference<drawing::XShape>& xShape) const
1101 : : {
1102 : 0 : SortedShapes::iterator aItr;
1103 [ # # ][ # # ]: 0 : if (FindShape(xShape, aItr))
1104 : : {
1105 [ # # ]: 0 : if (mpAccessibleDocument)
1106 : : {
1107 [ # # ][ # # ]: 0 : uno::Reference<XAccessible> xOldAccessible (Get(aItr - maZOrderedShapes.begin()));
1108 : :
1109 [ # # ][ # # ]: 0 : delete *aItr;
1110 [ # # ]: 0 : maZOrderedShapes.erase(aItr);
1111 : :
1112 [ # # ]: 0 : AccessibleEventObject aEvent;
1113 : 0 : aEvent.EventId = AccessibleEventId::CHILD;
1114 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument);
[ # # ]
1115 [ # # ][ # # ]: 0 : aEvent.OldValue <<= uno::makeAny(xOldAccessible);
1116 : :
1117 [ # # ][ # # ]: 0 : mpAccessibleDocument->CommitChange(aEvent); // child is gone - event
1118 : : }
1119 : : else
1120 : : {
1121 [ # # ][ # # ]: 0 : delete *aItr;
1122 [ # # ]: 0 : maZOrderedShapes.erase(aItr);
1123 : : }
1124 : : }
1125 : : else
1126 : : {
1127 : : OSL_FAIL("shape was not in internal list");
1128 : : }
1129 : 0 : }
1130 : :
1131 : 0 : sal_Bool ScChildrenShapes::FindShape(const uno::Reference<drawing::XShape>& xShape, ScChildrenShapes::SortedShapes::iterator& rItr) const
1132 : : {
1133 : 0 : sal_Bool bResult(false);
1134 [ # # ]: 0 : ScAccessibleShapeData aShape;
1135 [ # # ]: 0 : aShape.xShape = xShape;
1136 [ # # ]: 0 : ScShapeDataLess aLess;
1137 [ # # ]: 0 : rItr = std::lower_bound(maZOrderedShapes.begin(), maZOrderedShapes.end(), &aShape, aLess);
1138 [ # # ][ # # ]: 0 : if ((rItr != maZOrderedShapes.end()) && (*rItr != NULL) && ((*rItr)->xShape.get() == xShape.get()))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
[ # # ]
1139 : 0 : bResult = sal_True; // if the shape is found
1140 : :
1141 : : #if OSL_DEBUG_LEVEL > 0 // test whether it finds truly the correct shape (perhaps it is not really sorted)
1142 : : SortedShapes::iterator aDebugItr = maZOrderedShapes.begin();
1143 : : SortedShapes::iterator aEndItr = maZOrderedShapes.end();
1144 : : sal_Bool bFound(false);
1145 : : while (!bFound && aDebugItr != aEndItr)
1146 : : {
1147 : : if (*aDebugItr && ((*aDebugItr)->xShape.get() == xShape.get()))
1148 : : bFound = sal_True;
1149 : : else
1150 : : ++aDebugItr;
1151 : : }
1152 : : sal_Bool bResult2 = (aDebugItr != maZOrderedShapes.end());
1153 : : OSL_ENSURE((bResult == bResult2) && ((bResult && (rItr == aDebugItr)) || !bResult), "wrong Shape found");
1154 : : #endif
1155 [ # # ]: 0 : return bResult;
1156 : : }
1157 : :
1158 : 0 : sal_Int8 ScChildrenShapes::Compare(const ScAccessibleShapeData* pData1,
1159 : : const ScAccessibleShapeData* pData2) const
1160 : : {
1161 [ # # ]: 0 : ScShapeDataLess aLess;
1162 : :
1163 [ # # ]: 0 : sal_Bool bResult1(aLess(pData1, pData2));
1164 [ # # ]: 0 : sal_Bool bResult2(aLess(pData2, pData1));
1165 : :
1166 : 0 : sal_Int8 nResult(0);
1167 [ # # ][ # # ]: 0 : if (!bResult1 && bResult2)
1168 : 0 : nResult = 1;
1169 [ # # ][ # # ]: 0 : else if (bResult1 && !bResult2)
1170 : 0 : nResult = -1;
1171 : :
1172 : 0 : return nResult;
1173 : : }
1174 : :
1175 : : struct ScVisAreaChanged
1176 : : {
1177 : : ScAccessibleDocument* mpAccDoc;
1178 : 0 : ScVisAreaChanged(ScAccessibleDocument* pAccDoc) : mpAccDoc(pAccDoc) {}
1179 : 0 : void operator() (const ScAccessibleShapeData* pAccShapeData) const
1180 : : {
1181 [ # # ][ # # ]: 0 : if (pAccShapeData && pAccShapeData->pAccShape)
1182 : : {
1183 [ # # ]: 0 : pAccShapeData->pAccShape->ViewForwarderChanged(::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA, mpAccDoc);
1184 : : }
1185 : 0 : }
1186 : : };
1187 : :
1188 : 0 : void ScChildrenShapes::VisAreaChanged() const
1189 : : {
1190 : 0 : ScVisAreaChanged aVisAreaChanged(mpAccessibleDocument);
1191 [ # # ]: 0 : std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), aVisAreaChanged);
1192 : 0 : }
1193 : :
1194 : : // ============================================================================
1195 : :
1196 : 5 : ScAccessibleDocument::ScAccessibleDocument(
1197 : : const uno::Reference<XAccessible>& rxParent,
1198 : : ScTabViewShell* pViewShell,
1199 : : ScSplitPos eSplitPos)
1200 : : : ScAccessibleDocumentBase(rxParent),
1201 : : mpViewShell(pViewShell),
1202 : : meSplitPos(eSplitPos),
1203 : : mpAccessibleSpreadsheet(NULL),
1204 : : mpChildrenShapes(NULL),
1205 : : mpTempAccEdit(NULL),
1206 [ + - ]: 5 : mbCompleteSheetSelected(false)
1207 : : {
1208 [ + - ]: 5 : if (pViewShell)
1209 : : {
1210 [ + - ]: 5 : pViewShell->AddAccessibilityObject(*this);
1211 [ + - ]: 5 : Window *pWin = pViewShell->GetWindowByPos(eSplitPos);
1212 [ + - ]: 5 : if( pWin )
1213 : : {
1214 [ + - ][ + - ]: 5 : pWin->AddChildEventListener( LINK( this, ScAccessibleDocument, WindowChildEventListener ));
1215 [ + - ]: 5 : sal_uInt16 nCount = pWin->GetChildCount();
1216 [ - + ]: 5 : for( sal_uInt16 i=0; i < nCount; ++i )
1217 : : {
1218 [ # # ]: 0 : Window *pChildWin = pWin->GetChild( i );
1219 [ # # ][ # # ]: 0 : if( pChildWin &&
[ # # ]
1220 [ # # ]: 0 : AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
1221 [ # # ][ # # ]: 0 : AddChild( pChildWin->GetAccessible(), false );
1222 : : }
1223 : : }
1224 [ - + ]: 5 : if (pViewShell->GetViewData()->HasEditView( eSplitPos ))
1225 : : {
1226 : 0 : uno::Reference<XAccessible> xAcc = new ScAccessibleEditObject(this, pViewShell->GetViewData()->GetEditView(eSplitPos),
1227 : 0 : pViewShell->GetWindowByPos(eSplitPos), GetCurrentCellName(), GetCurrentCellDescription(),
1228 [ # # # # ]: 0 : ScAccessibleEditObject::CellInEditMode);
[ # # ][ # # ]
[ # # ][ # # ]
1229 [ # # ]: 0 : AddChild(xAcc, false);
1230 : : }
1231 : : }
1232 [ + - ]: 5 : maVisArea = GetVisibleArea_Impl();
1233 : 5 : }
1234 : :
1235 : 5 : void ScAccessibleDocument::Init()
1236 : : {
1237 [ + - ]: 5 : if(!mpChildrenShapes)
1238 [ + - ]: 5 : mpChildrenShapes = new ScChildrenShapes(this, mpViewShell, meSplitPos);
1239 : 5 : }
1240 : :
1241 : 5 : ScAccessibleDocument::~ScAccessibleDocument(void)
1242 : : {
1243 [ - + ][ # # ]: 5 : if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose)
[ - + ]
1244 : : {
1245 : : // increment refcount to prevent double call off dtor
1246 [ # # ]: 0 : osl_incrementInterlockedCount( &m_refCount );
1247 [ # # ]: 0 : dispose();
1248 : : }
1249 [ - + ]: 10 : }
1250 : :
1251 : 5 : void SAL_CALL ScAccessibleDocument::disposing()
1252 : : {
1253 [ + - ]: 5 : SolarMutexGuard aGuard;
1254 [ + - ]: 5 : FreeAccessibleSpreadsheet();
1255 [ + - ]: 5 : if (mpViewShell)
1256 : : {
1257 [ + - ]: 5 : Window *pWin = mpViewShell->GetWindowByPos(meSplitPos);
1258 [ + - ]: 5 : if( pWin )
1259 [ + - ][ + - ]: 5 : pWin->RemoveChildEventListener( LINK( this, ScAccessibleDocument, WindowChildEventListener ));
1260 : :
1261 [ + - ]: 5 : mpViewShell->RemoveAccessibilityObject(*this);
1262 : 5 : mpViewShell = NULL;
1263 : : }
1264 [ + - ]: 5 : if (mpChildrenShapes)
1265 [ + - ][ + - ]: 5 : DELETEZ(mpChildrenShapes);
1266 : :
1267 [ + - ][ + - ]: 5 : ScAccessibleDocumentBase::disposing();
1268 : 5 : }
1269 : :
1270 : 0 : void SAL_CALL ScAccessibleDocument::disposing( const lang::EventObject& /* Source */ )
1271 : : throw (uno::RuntimeException)
1272 : : {
1273 : 0 : disposing();
1274 : 0 : }
1275 : :
1276 : : //===== SfxListener =====================================================
1277 : :
1278 : 14 : IMPL_LINK( ScAccessibleDocument, WindowChildEventListener, VclSimpleEvent*, pEvent )
1279 : : {
1280 : : OSL_ENSURE( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
1281 [ + - ][ + - ]: 14 : if ( pEvent && pEvent->ISA( VclWindowEvent ) )
[ + - ]
1282 : : {
1283 : 14 : VclWindowEvent *pVclEvent = static_cast< VclWindowEvent * >( pEvent );
1284 : : OSL_ENSURE( pVclEvent->GetWindow(), "Window???" );
1285 [ - - + ]: 14 : switch ( pVclEvent->GetId() )
1286 : : {
1287 : : case VCLEVENT_WINDOW_SHOW: // send create on show for direct accessible children
1288 : : {
1289 : 0 : Window* pChildWin = static_cast < Window * >( pVclEvent->GetData() );
1290 [ # # ][ # # ]: 0 : if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
[ # # ]
1291 : : {
1292 [ # # ]: 0 : AddChild( pChildWin->GetAccessible(), sal_True );
1293 : : }
1294 : : }
1295 : 0 : break;
1296 : : case VCLEVENT_WINDOW_HIDE: // send destroy on hide for direct accessible children
1297 : : {
1298 : 0 : Window* pChildWin = static_cast < Window * >( pVclEvent->GetData() );
1299 [ # # ][ # # ]: 0 : if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
[ # # ]
1300 : : {
1301 [ # # ]: 0 : RemoveChild( pChildWin->GetAccessible(), sal_True );
1302 : : }
1303 : : }
1304 : 14 : break;
1305 : : }
1306 : : }
1307 : 14 : return 0;
1308 : : }
1309 : :
1310 : 34 : void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1311 : : {
1312 [ + + ]: 34 : if (rHint.ISA( ScAccGridWinFocusLostHint ) )
1313 : : {
1314 : 5 : const ScAccGridWinFocusLostHint& rRef = (const ScAccGridWinFocusLostHint&)rHint;
1315 [ + - ]: 5 : if (rRef.GetOldGridWin() == meSplitPos)
1316 : : {
1317 [ - + ][ # # ]: 5 : if (mxTempAcc.is() && mpTempAccEdit)
[ - + ]
1318 : 0 : mpTempAccEdit->LostFocus();
1319 [ + - ]: 5 : else if (mpAccessibleSpreadsheet)
1320 : 5 : mpAccessibleSpreadsheet->LostFocus();
1321 : : else
1322 : 0 : CommitFocusLost();
1323 : : }
1324 : : }
1325 [ - + ]: 29 : else if (rHint.ISA( ScAccGridWinFocusGotHint ) )
1326 : : {
1327 : 0 : const ScAccGridWinFocusGotHint& rRef = (const ScAccGridWinFocusGotHint&)rHint;
1328 [ # # ]: 0 : if (rRef.GetNewGridWin() == meSplitPos)
1329 : : {
1330 [ # # ][ # # ]: 0 : if (mxTempAcc.is() && mpTempAccEdit)
[ # # ]
1331 : 0 : mpTempAccEdit->GotFocus();
1332 [ # # ]: 0 : else if (mpAccessibleSpreadsheet)
1333 : 0 : mpAccessibleSpreadsheet->GotFocus();
1334 : : else
1335 : 0 : CommitFocusGained();
1336 : : }
1337 : : }
1338 [ + - ]: 29 : else if (rHint.ISA( SfxSimpleHint ))
1339 : : {
1340 : 29 : const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
1341 : : // only notify if child exist, otherwise it is not necessary
1342 [ - + ][ # # ]: 29 : if ((rRef.GetId() == SC_HINT_ACC_TABLECHANGED) &&
[ - + ]
1343 : : mpAccessibleSpreadsheet)
1344 : : {
1345 [ # # ]: 0 : FreeAccessibleSpreadsheet();
1346 [ # # ]: 0 : if (mpChildrenShapes)
1347 [ # # ][ # # ]: 0 : DELETEZ(mpChildrenShapes);
1348 : :
1349 : : // Accessibility: Shapes / form controls after reload not accessible
1350 [ # # ]: 0 : if ( !mpChildrenShapes )
1351 : : {
1352 [ # # ][ # # ]: 0 : mpChildrenShapes = new ScChildrenShapes( this, mpViewShell, meSplitPos );
1353 : : }
1354 : :
1355 [ # # ]: 0 : AccessibleEventObject aEvent;
1356 : 0 : aEvent.EventId = AccessibleEventId::INVALIDATE_ALL_CHILDREN;
1357 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference< XAccessibleContext >(this);
1358 [ # # ][ # # ]: 0 : CommitChange(aEvent); // all children changed
1359 : : }
1360 [ - + ]: 29 : else if (rRef.GetId() == SC_HINT_ACC_MAKEDRAWLAYER)
1361 : : {
1362 [ # # ]: 0 : if (mpChildrenShapes)
1363 : 0 : mpChildrenShapes->SetDrawBroadcaster();
1364 : : }
1365 [ - + ]: 29 : else if ((rRef.GetId() == SC_HINT_ACC_ENTEREDITMODE)) // this event comes only on creating edit field of a cell
1366 : : {
1367 [ # # ][ # # ]: 0 : if (mpViewShell && mpViewShell->GetViewData()->HasEditView(meSplitPos))
[ # # ]
1368 : : {
1369 : 0 : mpTempAccEdit = new ScAccessibleEditObject(this, mpViewShell->GetViewData()->GetEditView(meSplitPos),
1370 : 0 : mpViewShell->GetWindowByPos(meSplitPos), GetCurrentCellName(),
1371 [ # # # # ]: 0 : rtl::OUString(String(ScResId(STR_ACC_EDITLINE_DESCR))), ScAccessibleEditObject::CellInEditMode);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1372 [ # # ][ # # ]: 0 : uno::Reference<XAccessible> xAcc = mpTempAccEdit;
1373 : :
1374 [ # # ]: 0 : AddChild(xAcc, sal_True);
1375 : :
1376 [ # # ]: 0 : if (mpAccessibleSpreadsheet)
1377 [ # # ]: 0 : mpAccessibleSpreadsheet->LostFocus();
1378 : : else
1379 [ # # ]: 0 : CommitFocusLost();
1380 : :
1381 [ # # ]: 0 : mpTempAccEdit->GotFocus();
1382 : : }
1383 : : }
1384 [ - + ]: 29 : else if (rRef.GetId() == SC_HINT_ACC_LEAVEEDITMODE)
1385 : : {
1386 [ # # ]: 0 : if (mxTempAcc.is())
1387 : : {
1388 [ # # ]: 0 : if (mpTempAccEdit)
1389 : 0 : mpTempAccEdit->LostFocus();
1390 : :
1391 : 0 : mpTempAccEdit = NULL;
1392 : 0 : RemoveChild(mxTempAcc, sal_True);
1393 : :
1394 [ # # ]: 0 : if (mpAccessibleSpreadsheet)
1395 : 0 : mpAccessibleSpreadsheet->GotFocus();
1396 : : else
1397 : 0 : CommitFocusGained();
1398 : : }
1399 : : }
1400 [ + - ][ + + ]: 29 : else if ((rRef.GetId() == SC_HINT_ACC_VISAREACHANGED) || (rRef.GetId() == SC_HINT_ACC_WINDOWRESIZED))
[ + + ]
1401 : : {
1402 : 4 : Rectangle aOldVisArea(maVisArea);
1403 [ + - ]: 4 : maVisArea = GetVisibleArea_Impl();
1404 : :
1405 [ + - ][ - + ]: 4 : if (maVisArea != aOldVisArea)
1406 : : {
1407 [ # # ][ # # ]: 0 : if (maVisArea.GetSize() != aOldVisArea.GetSize())
[ # # ]
1408 : : {
1409 [ # # ]: 0 : AccessibleEventObject aEvent;
1410 : 0 : aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED;
1411 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference< XAccessibleContext >(this);
1412 : :
1413 [ # # ]: 0 : CommitChange(aEvent);
1414 : :
1415 [ # # ]: 0 : if (mpAccessibleSpreadsheet)
1416 [ # # ][ # # ]: 0 : mpAccessibleSpreadsheet->BoundingBoxChanged();
1417 : : }
1418 [ # # ]: 0 : else if (mpAccessibleSpreadsheet)
1419 : : {
1420 [ # # ]: 0 : mpAccessibleSpreadsheet->VisAreaChanged();
1421 : : }
1422 [ # # ]: 0 : if (mpChildrenShapes)
1423 [ # # ]: 4 : mpChildrenShapes->VisAreaChanged();
1424 : : }
1425 : : }
1426 : : }
1427 : :
1428 : 34 : ScAccessibleDocumentBase::Notify(rBC, rHint);
1429 : 34 : }
1430 : :
1431 : 2 : void SAL_CALL ScAccessibleDocument::selectionChanged( const lang::EventObject& /* aEvent */ )
1432 : : throw (uno::RuntimeException)
1433 : : {
1434 : 2 : sal_Bool bSelectionChanged(false);
1435 [ + - ]: 2 : if (mpAccessibleSpreadsheet)
1436 : : {
1437 : 2 : sal_Bool bOldSelected(mbCompleteSheetSelected);
1438 : 2 : mbCompleteSheetSelected = IsTableSelected();
1439 [ - + ]: 2 : if (bOldSelected != mbCompleteSheetSelected)
1440 : : {
1441 : 0 : mpAccessibleSpreadsheet->CompleteSelectionChanged(mbCompleteSheetSelected);
1442 : 0 : bSelectionChanged = sal_True;
1443 : : }
1444 : : }
1445 : :
1446 [ + - ][ - + ]: 2 : if (mpChildrenShapes && mpChildrenShapes->SelectionChanged())
[ - + ]
1447 : 0 : bSelectionChanged = sal_True;
1448 : :
1449 [ - + ]: 2 : if (bSelectionChanged)
1450 : : {
1451 [ # # ]: 0 : AccessibleEventObject aEvent;
1452 : 0 : aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
1453 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference< XAccessibleContext >(this);
1454 : :
1455 [ # # ][ # # ]: 0 : CommitChange(aEvent);
1456 : : }
1457 : 2 : }
1458 : :
1459 : : //===== XInterface =====================================================
1460 : :
1461 : 54 : uno::Any SAL_CALL ScAccessibleDocument::queryInterface( uno::Type const & rType )
1462 : : throw (uno::RuntimeException)
1463 : : {
1464 [ + - ]: 54 : uno::Any aAny (ScAccessibleDocumentImpl::queryInterface(rType));
1465 [ + + ][ + - ]: 54 : return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType);
1466 : : }
1467 : :
1468 : 397 : void SAL_CALL ScAccessibleDocument::acquire()
1469 : : throw ()
1470 : : {
1471 : 397 : ScAccessibleContextBase::acquire();
1472 : 397 : }
1473 : :
1474 : 397 : void SAL_CALL ScAccessibleDocument::release()
1475 : : throw ()
1476 : : {
1477 : 397 : ScAccessibleContextBase::release();
1478 : 397 : }
1479 : :
1480 : : //===== XAccessibleComponent ============================================
1481 : :
1482 : 0 : uno::Reference< XAccessible > SAL_CALL ScAccessibleDocument::getAccessibleAtPoint(
1483 : : const awt::Point& rPoint )
1484 : : throw (uno::RuntimeException)
1485 : : {
1486 : 0 : uno::Reference<XAccessible> xAccessible = NULL;
1487 [ # # ][ # # ]: 0 : if (containsPoint(rPoint))
1488 : : {
1489 [ # # ]: 0 : SolarMutexGuard aGuard;
1490 [ # # ]: 0 : IsObjectValid();
1491 [ # # ]: 0 : if (mpChildrenShapes)
1492 [ # # ][ # # ]: 0 : xAccessible = mpChildrenShapes->GetAt(rPoint);
1493 [ # # ]: 0 : if(!xAccessible.is())
1494 : : {
1495 [ # # ]: 0 : if (mxTempAcc.is())
1496 : : {
1497 [ # # ][ # # ]: 0 : uno::Reference< XAccessibleContext > xCont(mxTempAcc->getAccessibleContext());
1498 [ # # ]: 0 : uno::Reference< XAccessibleComponent > xComp(xCont, uno::UNO_QUERY);
1499 [ # # ]: 0 : if (xComp.is())
1500 : : {
1501 [ # # ][ # # ]: 0 : Rectangle aBound(VCLRectangle(xComp->getBounds()));
[ # # ]
1502 [ # # ][ # # ]: 0 : if (aBound.IsInside(VCLPoint(rPoint)))
1503 [ # # ]: 0 : xAccessible = mxTempAcc;
1504 : 0 : }
1505 : : }
1506 [ # # ]: 0 : if (!xAccessible.is())
1507 [ # # ][ # # ]: 0 : xAccessible = GetAccessibleSpreadsheet();
1508 [ # # ]: 0 : }
1509 : : }
1510 : 0 : return xAccessible;
1511 : : }
1512 : :
1513 : 2 : void SAL_CALL ScAccessibleDocument::grabFocus( )
1514 : : throw (uno::RuntimeException)
1515 : : {
1516 [ + - ]: 2 : SolarMutexGuard aGuard;
1517 [ + - ]: 2 : IsObjectValid();
1518 [ + - ][ + - ]: 2 : if (getAccessibleParent().is())
1519 : : {
1520 [ + - ][ + - ]: 2 : uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
[ + - ][ + - ]
1521 [ + - ]: 2 : if (xAccessibleComponent.is())
1522 : : {
1523 [ + - ][ + - ]: 2 : xAccessibleComponent->grabFocus();
1524 : : // grab only focus if it does not have the focus and it is not hidden
1525 [ + - ]: 4 : if (mpViewShell && mpViewShell->GetViewData() &&
[ + - - + ]
[ # # ][ - + ]
1526 : 2 : (mpViewShell->GetViewData()->GetActivePart() != meSplitPos) &&
1527 [ # # ][ # # ]: 0 : mpViewShell->GetWindowByPos(meSplitPos)->IsVisible())
1528 : : {
1529 [ # # ]: 0 : mpViewShell->ActivatePart(meSplitPos);
1530 : : }
1531 : 2 : }
1532 [ + - ]: 2 : }
1533 : 2 : }
1534 : :
1535 : : //===== XAccessibleContext ==============================================
1536 : :
1537 : : /// Return the number of currently visible children.
1538 : : sal_Int32 SAL_CALL
1539 : 14 : ScAccessibleDocument::getAccessibleChildCount(void)
1540 : : throw (uno::RuntimeException)
1541 : : {
1542 [ + - ]: 14 : SolarMutexGuard aGuard;
1543 [ + - ]: 14 : IsObjectValid();
1544 : 14 : sal_Int32 nCount(1);
1545 [ + - ]: 14 : if (mpChildrenShapes)
1546 [ + - ]: 14 : nCount = mpChildrenShapes->GetCount(); // returns the count of the shapes inclusive the table
1547 : :
1548 [ - + ]: 14 : if (mxTempAcc.is())
1549 : 0 : ++nCount;
1550 : :
1551 [ + - ]: 14 : return nCount;
1552 : : }
1553 : :
1554 : : /// Return the specified child or NULL if index is invalid.
1555 : : uno::Reference<XAccessible> SAL_CALL
1556 : 5 : ScAccessibleDocument::getAccessibleChild(sal_Int32 nIndex)
1557 : : throw (uno::RuntimeException,
1558 : : lang::IndexOutOfBoundsException)
1559 : : {
1560 [ + - ]: 5 : SolarMutexGuard aGuard;
1561 [ + - ]: 5 : IsObjectValid();
1562 : 5 : uno::Reference<XAccessible> xAccessible;
1563 [ + - ]: 5 : if (nIndex >= 0)
1564 : : {
1565 : 5 : sal_Int32 nCount(1);
1566 [ + - ]: 5 : if (mpChildrenShapes)
1567 : : {
1568 [ + - ][ + - ]: 5 : xAccessible = mpChildrenShapes->Get(nIndex); // returns NULL if it is the table or out of range
1569 [ + - ]: 5 : nCount = mpChildrenShapes->GetCount(); //there is always a table
1570 : : }
1571 [ + - ]: 5 : if (!xAccessible.is())
1572 : : {
1573 [ + - ]: 5 : if (nIndex < nCount)
1574 [ + - ][ + - ]: 5 : xAccessible = GetAccessibleSpreadsheet();
1575 [ # # ][ # # ]: 0 : else if (nIndex == nCount && mxTempAcc.is())
[ # # ]
1576 [ # # ]: 0 : xAccessible = mxTempAcc;
1577 : : }
1578 : : }
1579 : :
1580 [ - + ]: 5 : if (!xAccessible.is())
1581 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
1582 : :
1583 [ + - ]: 5 : return xAccessible;
1584 : : }
1585 : :
1586 : : /// Return the set of current states.
1587 : : uno::Reference<XAccessibleStateSet> SAL_CALL
1588 : 31 : ScAccessibleDocument::getAccessibleStateSet(void)
1589 : : throw (uno::RuntimeException)
1590 : : {
1591 [ + - ]: 31 : SolarMutexGuard aGuard;
1592 : 31 : uno::Reference<XAccessibleStateSet> xParentStates;
1593 [ + - ][ + - ]: 31 : if (getAccessibleParent().is())
1594 : : {
1595 [ + - ][ + - ]: 31 : uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
[ + - ]
1596 [ + - ][ + - ]: 31 : xParentStates = xParentContext->getAccessibleStateSet();
[ + - ]
1597 : : }
1598 [ + - ]: 31 : utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
1599 [ + - ][ - + ]: 31 : if (IsDefunc(xParentStates))
1600 [ # # ]: 0 : pStateSet->AddState(AccessibleStateType::DEFUNC);
1601 : : else
1602 : : {
1603 [ + - ]: 31 : if (IsEditable(xParentStates))
1604 [ + - ]: 31 : pStateSet->AddState(AccessibleStateType::EDITABLE);
1605 [ + - ]: 31 : pStateSet->AddState(AccessibleStateType::ENABLED);
1606 [ + - ]: 31 : pStateSet->AddState(AccessibleStateType::OPAQUE);
1607 [ + - ][ + - ]: 31 : if (isShowing())
1608 [ + - ]: 31 : pStateSet->AddState(AccessibleStateType::SHOWING);
1609 [ + - ][ + - ]: 31 : if (isVisible())
1610 [ + - ]: 31 : pStateSet->AddState(AccessibleStateType::VISIBLE);
1611 : : }
1612 [ + - ][ + - ]: 31 : return pStateSet;
[ + - ]
1613 : : }
1614 : :
1615 : : ///===== XAccessibleSelection ===========================================
1616 : :
1617 : : void SAL_CALL
1618 : 0 : ScAccessibleDocument::selectAccessibleChild( sal_Int32 nChildIndex )
1619 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1620 : : {
1621 [ # # ]: 0 : SolarMutexGuard aGuard;
1622 [ # # ]: 0 : IsObjectValid();
1623 : :
1624 [ # # ]: 0 : if (mpChildrenShapes)
1625 : : {
1626 [ # # ]: 0 : sal_Int32 nCount(mpChildrenShapes->GetCount()); //all shapes and the table
1627 [ # # ]: 0 : if (mxTempAcc.is())
1628 : 0 : ++nCount;
1629 [ # # ][ # # ]: 0 : if (nChildIndex < 0 || nChildIndex >= nCount)
1630 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
1631 : :
1632 [ # # ]: 0 : uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex);
1633 [ # # ]: 0 : if (xAccessible.is())
1634 : : {
1635 [ # # ]: 0 : sal_Bool bWasTableSelected(IsTableSelected());
1636 : :
1637 [ # # ]: 0 : if (mpChildrenShapes)
1638 [ # # ]: 0 : mpChildrenShapes->Select(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is to high
1639 : :
1640 [ # # ]: 0 : if (bWasTableSelected)
1641 [ # # ]: 0 : mpViewShell->SelectAll();
1642 : : }
1643 : : else
1644 : : {
1645 [ # # ]: 0 : if (mpViewShell)
1646 [ # # ]: 0 : mpViewShell->SelectAll();
1647 : 0 : }
1648 [ # # ]: 0 : }
1649 : 0 : }
1650 : :
1651 : : sal_Bool SAL_CALL
1652 : 0 : ScAccessibleDocument::isAccessibleChildSelected( sal_Int32 nChildIndex )
1653 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1654 : : {
1655 [ # # ]: 0 : SolarMutexGuard aGuard;
1656 [ # # ]: 0 : IsObjectValid();
1657 : 0 : sal_Bool bResult(false);
1658 : :
1659 [ # # ]: 0 : if (mpChildrenShapes)
1660 : : {
1661 [ # # ]: 0 : sal_Int32 nCount(mpChildrenShapes->GetCount()); //all shapes and the table
1662 [ # # ]: 0 : if (mxTempAcc.is())
1663 : 0 : ++nCount;
1664 [ # # ][ # # ]: 0 : if (nChildIndex < 0 || nChildIndex >= nCount)
1665 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
1666 : :
1667 [ # # ]: 0 : uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex);
1668 [ # # ]: 0 : if (xAccessible.is())
1669 : : {
1670 : 0 : uno::Reference<drawing::XShape> xShape;
1671 [ # # ]: 0 : bResult = mpChildrenShapes->IsSelected(nChildIndex, xShape); // throws no lang::IndexOutOfBoundsException if Index is to high
1672 : : }
1673 : : else
1674 : : {
1675 [ # # ][ # # ]: 0 : if (mxTempAcc.is() && nChildIndex == nCount)
[ # # ]
1676 : 0 : bResult = sal_True;
1677 : : else
1678 [ # # ]: 0 : bResult = IsTableSelected();
1679 : 0 : }
1680 : : }
1681 [ # # ]: 0 : return bResult;
1682 : : }
1683 : :
1684 : : void SAL_CALL
1685 : 0 : ScAccessibleDocument::clearAccessibleSelection( )
1686 : : throw (uno::RuntimeException)
1687 : : {
1688 [ # # ]: 0 : SolarMutexGuard aGuard;
1689 [ # # ]: 0 : IsObjectValid();
1690 : :
1691 [ # # ]: 0 : if (mpChildrenShapes)
1692 [ # # ][ # # ]: 0 : mpChildrenShapes->DeselectAll(); //deselects all (also the table)
1693 : 0 : }
1694 : :
1695 : : void SAL_CALL
1696 : 0 : ScAccessibleDocument::selectAllAccessibleChildren( )
1697 : : throw (uno::RuntimeException)
1698 : : {
1699 [ # # ]: 0 : SolarMutexGuard aGuard;
1700 [ # # ]: 0 : IsObjectValid();
1701 : :
1702 [ # # ]: 0 : if (mpChildrenShapes)
1703 [ # # ]: 0 : mpChildrenShapes->SelectAll();
1704 : :
1705 : : // select table after shapes, because while selecting shapes the table will be deselected
1706 [ # # ]: 0 : if (mpViewShell)
1707 : : {
1708 [ # # ]: 0 : mpViewShell->SelectAll();
1709 [ # # ]: 0 : }
1710 : 0 : }
1711 : :
1712 : : sal_Int32 SAL_CALL
1713 : 0 : ScAccessibleDocument::getSelectedAccessibleChildCount( )
1714 : : throw (uno::RuntimeException)
1715 : : {
1716 [ # # ]: 0 : SolarMutexGuard aGuard;
1717 [ # # ]: 0 : IsObjectValid();
1718 : 0 : sal_Int32 nCount(0);
1719 : :
1720 [ # # ]: 0 : if (mpChildrenShapes)
1721 [ # # ]: 0 : nCount = mpChildrenShapes->GetSelectedCount();
1722 : :
1723 [ # # ][ # # ]: 0 : if (IsTableSelected())
1724 : 0 : ++nCount;
1725 : :
1726 [ # # ]: 0 : if (mxTempAcc.is())
1727 : 0 : ++nCount;
1728 : :
1729 [ # # ]: 0 : return nCount;
1730 : : }
1731 : :
1732 : : uno::Reference<XAccessible > SAL_CALL
1733 : 0 : ScAccessibleDocument::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
1734 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1735 : : {
1736 [ # # ]: 0 : SolarMutexGuard aGuard;
1737 [ # # ]: 0 : IsObjectValid();
1738 : 0 : uno::Reference<XAccessible> xAccessible;
1739 [ # # ]: 0 : if (mpChildrenShapes)
1740 : : {
1741 [ # # ]: 0 : sal_Int32 nCount(getSelectedAccessibleChildCount()); //all shapes and the table
1742 [ # # ][ # # ]: 0 : if (nSelectedChildIndex < 0 || nSelectedChildIndex >= nCount)
1743 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
1744 : :
1745 [ # # ]: 0 : sal_Bool bTabMarked(IsTableSelected());
1746 : :
1747 [ # # ]: 0 : if (mpChildrenShapes)
1748 [ # # ][ # # ]: 0 : xAccessible = mpChildrenShapes->GetSelected(nSelectedChildIndex, bTabMarked); // throws no lang::IndexOutOfBoundsException if Index is to high
1749 [ # # ][ # # ]: 0 : if (mxTempAcc.is() && nSelectedChildIndex == nCount - 1)
[ # # ]
1750 [ # # ]: 0 : xAccessible = mxTempAcc;
1751 [ # # ]: 0 : else if (bTabMarked)
1752 [ # # ][ # # ]: 0 : xAccessible = GetAccessibleSpreadsheet();
1753 : : }
1754 : :
1755 : : OSL_ENSURE(xAccessible.is(), "here should always be an accessible object or a exception throwed");
1756 : :
1757 [ # # ]: 0 : return xAccessible;
1758 : : }
1759 : :
1760 : : void SAL_CALL
1761 : 0 : ScAccessibleDocument::deselectAccessibleChild( sal_Int32 nChildIndex )
1762 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1763 : : {
1764 [ # # ]: 0 : SolarMutexGuard aGuard;
1765 [ # # ]: 0 : IsObjectValid();
1766 : :
1767 [ # # ]: 0 : if (mpChildrenShapes)
1768 : : {
1769 [ # # ]: 0 : sal_Int32 nCount(mpChildrenShapes->GetCount()); //all shapes and the table
1770 [ # # ]: 0 : if (mxTempAcc.is())
1771 : 0 : ++nCount;
1772 [ # # ][ # # ]: 0 : if (nChildIndex < 0 || nChildIndex >= nCount)
1773 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
1774 : :
1775 [ # # ]: 0 : sal_Bool bTabMarked(IsTableSelected());
1776 : :
1777 [ # # ]: 0 : uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex);
1778 [ # # ]: 0 : if (xAccessible.is())
1779 : : {
1780 [ # # ]: 0 : if (mpChildrenShapes)
1781 [ # # ]: 0 : mpChildrenShapes->Deselect(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is to high
1782 : :
1783 [ # # ]: 0 : if (bTabMarked)
1784 [ # # ]: 0 : mpViewShell->SelectAll(); // select the table again
1785 : : }
1786 [ # # ]: 0 : else if (bTabMarked)
1787 [ # # ]: 0 : mpViewShell->Unmark();
1788 [ # # ]: 0 : }
1789 : 0 : }
1790 : :
1791 : : //===== XServiceInfo ====================================================
1792 : :
1793 : : ::rtl::OUString SAL_CALL
1794 : 0 : ScAccessibleDocument::getImplementationName(void)
1795 : : throw (uno::RuntimeException)
1796 : : {
1797 : 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleDocument"));
1798 : : }
1799 : :
1800 : : uno::Sequence< ::rtl::OUString> SAL_CALL
1801 : 0 : ScAccessibleDocument::getSupportedServiceNames(void)
1802 : : throw (uno::RuntimeException)
1803 : : {
1804 : 0 : uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
1805 : 0 : sal_Int32 nOldSize(aSequence.getLength());
1806 [ # # ]: 0 : aSequence.realloc(nOldSize + 1);
1807 [ # # ]: 0 : ::rtl::OUString* pNames = aSequence.getArray();
1808 : :
1809 [ # # ]: 0 : pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.AccessibleSpreadsheetDocumentView"));
1810 : :
1811 : 0 : return aSequence;
1812 : : }
1813 : :
1814 : : //===== XTypeProvider =======================================================
1815 : :
1816 : 0 : uno::Sequence< uno::Type > SAL_CALL ScAccessibleDocument::getTypes()
1817 : : throw (uno::RuntimeException)
1818 : : {
1819 [ # # ][ # # ]: 0 : return comphelper::concatSequences(ScAccessibleDocumentImpl::getTypes(), ScAccessibleContextBase::getTypes());
[ # # ]
1820 : : }
1821 : :
1822 : : namespace
1823 : : {
1824 : : class theScAccessibleDocumentImplementationId : public rtl::Static< UnoTunnelIdInit, theScAccessibleDocumentImplementationId > {};
1825 : : }
1826 : :
1827 : : uno::Sequence<sal_Int8> SAL_CALL
1828 : 0 : ScAccessibleDocument::getImplementationId(void)
1829 : : throw (uno::RuntimeException)
1830 : : {
1831 : 0 : return theScAccessibleDocumentImplementationId::get().getSeq();
1832 : : }
1833 : :
1834 : : ///===== IAccessibleViewForwarder ========================================
1835 : :
1836 : 0 : sal_Bool ScAccessibleDocument::IsValid (void) const
1837 : : {
1838 [ # # ]: 0 : SolarMutexGuard aGuard;
1839 [ # # ]: 0 : IsObjectValid();
1840 [ # # ][ # # ]: 0 : return (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose);
[ # # ]
1841 : : }
1842 : :
1843 : 9 : Rectangle ScAccessibleDocument::GetVisibleArea_Impl() const
1844 : : {
1845 [ + - ]: 9 : Rectangle aVisRect(GetBoundingBox());
1846 : :
1847 [ + - ]: 9 : Point aPoint(mpViewShell->GetViewData()->GetPixPos(meSplitPos)); // returns a negative Point
1848 : 9 : aPoint.setX(-aPoint.getX());
1849 : 9 : aPoint.setY(-aPoint.getY());
1850 : 9 : aVisRect.SetPos(aPoint);
1851 : :
1852 [ + - ]: 9 : ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
1853 [ + - ]: 9 : if (pWin)
1854 [ + - ][ + - ]: 9 : aVisRect = pWin->PixelToLogic(aVisRect, pWin->GetDrawMapMode());
[ + - ]
1855 : :
1856 : 9 : return aVisRect;
1857 : : }
1858 : :
1859 : 0 : Rectangle ScAccessibleDocument::GetVisibleArea() const
1860 : : {
1861 [ # # ]: 0 : SolarMutexGuard aGuard;
1862 [ # # ]: 0 : IsObjectValid();
1863 [ # # ]: 0 : return maVisArea;
1864 : : }
1865 : :
1866 : 0 : Point ScAccessibleDocument::LogicToPixel (const Point& rPoint) const
1867 : : {
1868 [ # # ]: 0 : SolarMutexGuard aGuard;
1869 [ # # ]: 0 : IsObjectValid();
1870 : 0 : Point aPoint;
1871 [ # # ]: 0 : ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
1872 [ # # ]: 0 : if (pWin)
1873 : : {
1874 [ # # ][ # # ]: 0 : aPoint = pWin->LogicToPixel(rPoint, pWin->GetDrawMapMode());
[ # # ]
1875 [ # # ]: 0 : aPoint += pWin->GetWindowExtentsRelative(NULL).TopLeft();
1876 : : }
1877 [ # # ]: 0 : return aPoint;
1878 : : }
1879 : :
1880 : 0 : Size ScAccessibleDocument::LogicToPixel (const Size& rSize) const
1881 : : {
1882 [ # # ]: 0 : SolarMutexGuard aGuard;
1883 [ # # ]: 0 : IsObjectValid();
1884 : 0 : Size aSize;
1885 [ # # ]: 0 : ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
1886 [ # # ]: 0 : if (pWin)
1887 [ # # ][ # # ]: 0 : aSize = pWin->LogicToPixel(rSize, pWin->GetDrawMapMode());
[ # # ]
1888 [ # # ]: 0 : return aSize;
1889 : : }
1890 : :
1891 : 0 : Point ScAccessibleDocument::PixelToLogic (const Point& rPoint) const
1892 : : {
1893 [ # # ]: 0 : SolarMutexGuard aGuard;
1894 [ # # ]: 0 : IsObjectValid();
1895 : 0 : Point aPoint;
1896 [ # # ]: 0 : ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
1897 [ # # ]: 0 : if (pWin)
1898 : : {
1899 [ # # ]: 0 : aPoint -= pWin->GetWindowExtentsRelative(NULL).TopLeft();
1900 [ # # ][ # # ]: 0 : aPoint = pWin->PixelToLogic(rPoint, pWin->GetDrawMapMode());
[ # # ]
1901 : : }
1902 [ # # ]: 0 : return aPoint;
1903 : : }
1904 : :
1905 : 0 : Size ScAccessibleDocument::PixelToLogic (const Size& rSize) const
1906 : : {
1907 [ # # ]: 0 : SolarMutexGuard aGuard;
1908 [ # # ]: 0 : IsObjectValid();
1909 : 0 : Size aSize;
1910 [ # # ]: 0 : ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
1911 [ # # ]: 0 : if (pWin)
1912 [ # # ][ # # ]: 0 : aSize = pWin->PixelToLogic(rSize, pWin->GetDrawMapMode());
[ # # ]
1913 [ # # ]: 0 : return aSize;
1914 : : }
1915 : :
1916 : : //===== internal ========================================================
1917 : :
1918 : 2 : utl::AccessibleRelationSetHelper* ScAccessibleDocument::GetRelationSet(const ScAddress* pAddress) const
1919 : : {
1920 : 2 : utl::AccessibleRelationSetHelper* pRelationSet = NULL;
1921 [ + - ]: 2 : if (mpChildrenShapes)
1922 : 2 : pRelationSet = mpChildrenShapes->GetRelationSet(pAddress);
1923 : 2 : return pRelationSet;
1924 : : }
1925 : :
1926 : : ::rtl::OUString SAL_CALL
1927 : 4 : ScAccessibleDocument::createAccessibleDescription(void)
1928 : : throw (uno::RuntimeException)
1929 : : {
1930 [ + - ][ + - ]: 4 : rtl::OUString sDescription = String(ScResId(STR_ACC_DOC_DESCR));
[ + - ]
1931 : 4 : return sDescription;
1932 : : }
1933 : :
1934 : : ::rtl::OUString SAL_CALL
1935 : 2 : ScAccessibleDocument::createAccessibleName(void)
1936 : : throw (uno::RuntimeException)
1937 : : {
1938 [ + - ]: 2 : SolarMutexGuard aGuard;
1939 [ + - ]: 2 : IsObjectValid();
1940 [ + - ][ + - ]: 2 : rtl::OUString sName = String(ScResId(STR_ACC_DOC_NAME));
[ + - ][ + - ]
1941 : 2 : sal_Int32 nNumber(sal_Int32(meSplitPos) + 1);
1942 : 2 : sName += rtl::OUString::valueOf(nNumber);
1943 [ + - ]: 2 : return sName;
1944 : : }
1945 : :
1946 : 0 : Rectangle ScAccessibleDocument::GetBoundingBoxOnScreen() const
1947 : : throw (uno::RuntimeException)
1948 : : {
1949 : 0 : Rectangle aRect;
1950 [ # # ]: 0 : if (mpViewShell)
1951 : : {
1952 : 0 : Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
1953 [ # # ]: 0 : if (pWindow)
1954 : 0 : aRect = pWindow->GetWindowExtentsRelative(NULL);
1955 : : }
1956 : 0 : return aRect;
1957 : : }
1958 : :
1959 : 66 : Rectangle ScAccessibleDocument::GetBoundingBox() const
1960 : : throw (uno::RuntimeException)
1961 : : {
1962 : 66 : Rectangle aRect;
1963 [ + - ]: 66 : if (mpViewShell)
1964 : : {
1965 : 66 : Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
1966 [ + - ]: 66 : if (pWindow)
1967 : 66 : aRect = pWindow->GetWindowExtentsRelative(pWindow->GetAccessibleParentWindow());
1968 : : }
1969 : 66 : return aRect;
1970 : : }
1971 : :
1972 : 41 : SCTAB ScAccessibleDocument::getVisibleTable() const
1973 : : {
1974 : 41 : SCTAB nVisibleTable(0);
1975 [ + - ][ + - ]: 41 : if (mpViewShell && mpViewShell->GetViewData())
[ + - ]
1976 : 41 : nVisibleTable = mpViewShell->GetViewData()->GetTabNo();
1977 : 41 : return nVisibleTable;
1978 : : }
1979 : :
1980 : : uno::Reference < XAccessible >
1981 : 5 : ScAccessibleDocument::GetAccessibleSpreadsheet()
1982 : : {
1983 [ + - ][ + - ]: 5 : if (!mpAccessibleSpreadsheet && mpViewShell)
1984 : : {
1985 [ + - ]: 5 : mpAccessibleSpreadsheet = new ScAccessibleSpreadsheet(this, mpViewShell, getVisibleTable(), meSplitPos);
1986 : 5 : mpAccessibleSpreadsheet->acquire();
1987 : 5 : mpAccessibleSpreadsheet->Init();
1988 : 5 : mbCompleteSheetSelected = IsTableSelected();
1989 : : }
1990 [ + - ]: 5 : return mpAccessibleSpreadsheet;
1991 : : }
1992 : :
1993 : 5 : void ScAccessibleDocument::FreeAccessibleSpreadsheet()
1994 : : {
1995 [ + - ]: 5 : if (mpAccessibleSpreadsheet)
1996 : : {
1997 : 5 : mpAccessibleSpreadsheet->dispose();
1998 : 5 : mpAccessibleSpreadsheet->release();
1999 : 5 : mpAccessibleSpreadsheet = NULL;
2000 : : }
2001 : 5 : }
2002 : :
2003 : 7 : sal_Bool ScAccessibleDocument::IsTableSelected() const
2004 : : {
2005 : 7 : sal_Bool bResult (false);
2006 [ + - ]: 7 : if(mpViewShell)
2007 : : {
2008 : 7 : SCTAB nTab(getVisibleTable());
2009 : : //#103800#; use a copy of MarkData
2010 [ + - ][ + - ]: 7 : ScMarkData aMarkData(mpViewShell->GetViewData()->GetMarkData());
2011 [ + - ]: 7 : aMarkData.MarkToMulti();
2012 [ + - ][ - + ]: 7 : if (aMarkData.IsAllMarked(ScRange(ScAddress(0, 0, nTab),ScAddress(MAXCOL, MAXROW, nTab))))
2013 [ + - ]: 7 : bResult = sal_True;
2014 : : }
2015 : 7 : return bResult;
2016 : : }
2017 : :
2018 : 31 : sal_Bool ScAccessibleDocument::IsDefunc(
2019 : : const uno::Reference<XAccessibleStateSet>& rxParentStates)
2020 : : {
2021 [ + - ][ + - ]: 93 : return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() ||
[ # # ]
2022 [ + - + - ]: 93 : (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
[ + - ][ + - ]
[ + - ][ - + ]
[ + - ]
2023 : : }
2024 : :
2025 : 31 : sal_Bool ScAccessibleDocument::IsEditable(
2026 : : const uno::Reference<XAccessibleStateSet>& /* rxParentStates */)
2027 : : {
2028 : : // what is with document protection or readonly documents?
2029 : 31 : return sal_True;
2030 : : }
2031 : :
2032 : 0 : void ScAccessibleDocument::AddChild(const uno::Reference<XAccessible>& xAcc, sal_Bool bFireEvent)
2033 : : {
2034 : : OSL_ENSURE(!mxTempAcc.is(), "this object should be removed before");
2035 [ # # ]: 0 : if (xAcc.is())
2036 : : {
2037 : 0 : mxTempAcc = xAcc;
2038 [ # # ]: 0 : if( bFireEvent )
2039 : : {
2040 [ # # ]: 0 : AccessibleEventObject aEvent;
2041 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference<XAccessibleContext>(this);
2042 : 0 : aEvent.EventId = AccessibleEventId::CHILD;
2043 [ # # ]: 0 : aEvent.NewValue <<= mxTempAcc;
2044 [ # # ][ # # ]: 0 : CommitChange( aEvent );
2045 : : }
2046 : : }
2047 : 0 : }
2048 : :
2049 : 0 : void ScAccessibleDocument::RemoveChild(const uno::Reference<XAccessible>& xAcc, sal_Bool bFireEvent)
2050 : : {
2051 : : OSL_ENSURE(mxTempAcc.is(), "this object should be added before");
2052 [ # # ]: 0 : if (xAcc.is())
2053 : : {
2054 : : OSL_ENSURE(xAcc.get() == mxTempAcc.get(), "only the same object should be removed");
2055 [ # # ]: 0 : if( bFireEvent )
2056 : : {
2057 [ # # ]: 0 : AccessibleEventObject aEvent;
2058 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference<XAccessibleContext>(this);
2059 : 0 : aEvent.EventId = AccessibleEventId::CHILD;
2060 [ # # ]: 0 : aEvent.OldValue <<= mxTempAcc;
2061 [ # # ][ # # ]: 0 : CommitChange( aEvent );
2062 : : }
2063 : 0 : mxTempAcc = NULL;
2064 : : }
2065 : 0 : }
2066 : :
2067 : 0 : rtl::OUString ScAccessibleDocument::GetCurrentCellName() const
2068 : : {
2069 [ # # ][ # # ]: 0 : String sName( ScResId(STR_ACC_CELL_NAME) );
2070 [ # # ]: 0 : if (mpViewShell)
2071 : : {
2072 [ # # ]: 0 : String sAddress;
2073 : : // Document not needed, because only the cell address, but not the tablename is needed
2074 [ # # ][ # # ]: 0 : mpViewShell->GetViewData()->GetCurPos().Format( sAddress, SCA_VALID, NULL );
2075 [ # # ][ # # ]: 0 : sName.SearchAndReplaceAscii("%1", sAddress);
2076 : : }
2077 [ # # ][ # # ]: 0 : return rtl::OUString(sName);
2078 : : }
2079 : :
2080 : 0 : rtl::OUString ScAccessibleDocument::GetCurrentCellDescription() const
2081 : : {
2082 : 0 : return rtl::OUString();
2083 : : }
2084 : :
2085 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|