1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file
5b3f79822SAndrew Rist * distributed with this work for additional information
6b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at
10b3f79822SAndrew Rist *
11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist *
13b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist * software distributed under the License is distributed on an
15b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist * KIND, either express or implied. See the License for the
17b3f79822SAndrew Rist * specific language governing permissions and limitations
18b3f79822SAndrew Rist * under the License.
19b3f79822SAndrew Rist *
20b3f79822SAndrew Rist *************************************************************/
21b3f79822SAndrew Rist
22b3f79822SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include "AccessibleDocument.hxx"
29cdf0e10cSrcweir #include "AccessibleSpreadsheet.hxx"
30cdf0e10cSrcweir #include "tabvwsh.hxx"
31cdf0e10cSrcweir #include "AccessibilityHints.hxx"
32cdf0e10cSrcweir #include "document.hxx"
33cdf0e10cSrcweir #include "drwlayer.hxx"
34cdf0e10cSrcweir #include "unoguard.hxx"
35cdf0e10cSrcweir #include "shapeuno.hxx"
36cdf0e10cSrcweir #include "DrawModelBroadcaster.hxx"
37cdf0e10cSrcweir #include "drawview.hxx"
38cdf0e10cSrcweir #include "gridwin.hxx"
39cdf0e10cSrcweir #include "AccessibleEditObject.hxx"
40cdf0e10cSrcweir #include "scresid.hxx"
41cdf0e10cSrcweir #ifndef SC_SC_HRC
42cdf0e10cSrcweir #include "sc.hrc"
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
45cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLESTATETYPE_HPP_
46cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLERELATIONTYPE_HPP_
49cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
50cdf0e10cSrcweir #endif
51cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp>
52cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp>
53cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp>
54cdf0e10cSrcweir
55cdf0e10cSrcweir #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX
56cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir #include <tools/debug.hxx>
59cdf0e10cSrcweir #include <tools/gen.hxx>
60cdf0e10cSrcweir #include <svx/svdpage.hxx>
61cdf0e10cSrcweir #include <svx/svdobj.hxx>
62cdf0e10cSrcweir #include <svx/ShapeTypeHandler.hxx>
63cdf0e10cSrcweir #include <svx/AccessibleShape.hxx>
64cdf0e10cSrcweir #include <svx/AccessibleShapeTreeInfo.hxx>
65cdf0e10cSrcweir #include <svx/AccessibleShapeInfo.hxx>
66cdf0e10cSrcweir #include <comphelper/sequence.hxx>
67cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
68cdf0e10cSrcweir #include <svx/unoshcol.hxx>
69cdf0e10cSrcweir #include <svx/unoshape.hxx>
70cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx>
71cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
72cdf0e10cSrcweir
730deba7fbSSteve Yin #include <svx/AccessibleControlShape.hxx>
740deba7fbSSteve Yin #include <svx/AccessibleShape.hxx>
750deba7fbSSteve Yin #include <svx/ShapeTypeHandler.hxx>
760deba7fbSSteve Yin #include <svx/SvxShapeTypes.hxx>
770deba7fbSSteve Yin #include <sfx2/objsh.hxx>
780deba7fbSSteve Yin #include <editeng/editview.hxx>
790deba7fbSSteve Yin #include <editeng/editeng.hxx>
80cdf0e10cSrcweir #include <list>
81cdf0e10cSrcweir #include <algorithm>
820deba7fbSSteve Yin #include "AccessibleCell.hxx"
83cdf0e10cSrcweir
840deba7fbSSteve Yin #include "svx/unoapi.hxx"
850deba7fbSSteve Yin #include "scmod.hxx"
86cdf0e10cSrcweir using namespace ::com::sun::star;
87cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
88cdf0e10cSrcweir using ::std::for_each;
89cdf0e10cSrcweir
90cdf0e10cSrcweir //===== internal ========================================================
91cdf0e10cSrcweir
92cdf0e10cSrcweir struct ScAccessibleShapeData
93cdf0e10cSrcweir {
ScAccessibleShapeDataScAccessibleShapeData94cdf0e10cSrcweir ScAccessibleShapeData() : pAccShape(NULL), pRelationCell(NULL), bSelected(sal_False), bSelectable(sal_True) {}
95cdf0e10cSrcweir ~ScAccessibleShapeData();
96cdf0e10cSrcweir mutable ::accessibility::AccessibleShape* pAccShape;
97cdf0e10cSrcweir mutable ScAddress* pRelationCell; // if it is NULL this shape is anchored on the table
98cdf0e10cSrcweir // SdrObject* pShape;
99cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape;
100cdf0e10cSrcweir mutable sal_Bool bSelected;
101cdf0e10cSrcweir sal_Bool bSelectable;
102cdf0e10cSrcweir };
103cdf0e10cSrcweir
~ScAccessibleShapeData()104cdf0e10cSrcweir ScAccessibleShapeData::~ScAccessibleShapeData()
105cdf0e10cSrcweir {
106cdf0e10cSrcweir if (pAccShape)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir pAccShape->dispose();
109cdf0e10cSrcweir pAccShape->release();
110cdf0e10cSrcweir }
111cdf0e10cSrcweir }
112cdf0e10cSrcweir
113cdf0e10cSrcweir struct ScShapeDataLess
114cdf0e10cSrcweir {
115cdf0e10cSrcweir rtl::OUString msLayerId;
116cdf0e10cSrcweir rtl::OUString msZOrder;
ScShapeDataLessScShapeDataLess117cdf0e10cSrcweir ScShapeDataLess()
118cdf0e10cSrcweir : msLayerId(RTL_CONSTASCII_USTRINGPARAM( "LayerID" )),
119cdf0e10cSrcweir msZOrder(RTL_CONSTASCII_USTRINGPARAM( "ZOrder" ))
120cdf0e10cSrcweir {
121cdf0e10cSrcweir }
ConvertLayerIdScShapeDataLess122cdf0e10cSrcweir void ConvertLayerId(sal_Int16& rLayerID) const // changes the number of the LayerId so it the accessibility order
123cdf0e10cSrcweir {
124cdf0e10cSrcweir switch (rLayerID)
125cdf0e10cSrcweir {
126cdf0e10cSrcweir case SC_LAYER_FRONT:
127cdf0e10cSrcweir rLayerID = 1;
128cdf0e10cSrcweir break;
129cdf0e10cSrcweir case SC_LAYER_BACK:
130cdf0e10cSrcweir rLayerID = 0;
131cdf0e10cSrcweir break;
132cdf0e10cSrcweir case SC_LAYER_INTERN:
133cdf0e10cSrcweir rLayerID = 2;
134cdf0e10cSrcweir break;
135cdf0e10cSrcweir case SC_LAYER_CONTROLS:
136cdf0e10cSrcweir rLayerID = 3;
137cdf0e10cSrcweir break;
138cdf0e10cSrcweir }
139cdf0e10cSrcweir }
LessThanSheetScShapeDataLess140cdf0e10cSrcweir sal_Bool LessThanSheet(const ScAccessibleShapeData* pData) const
141cdf0e10cSrcweir {
142cdf0e10cSrcweir sal_Bool bResult(sal_False);
143cdf0e10cSrcweir uno::Reference< beans::XPropertySet> xProps(pData->xShape, uno::UNO_QUERY);
144cdf0e10cSrcweir if (xProps.is())
145cdf0e10cSrcweir {
146cdf0e10cSrcweir uno::Any aPropAny = xProps->getPropertyValue(msLayerId);
147cdf0e10cSrcweir sal_Int16 nLayerID = 0;
148cdf0e10cSrcweir if( (aPropAny >>= nLayerID) )
149cdf0e10cSrcweir {
150cdf0e10cSrcweir if (nLayerID == SC_LAYER_BACK)
151cdf0e10cSrcweir bResult = sal_True;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir }
154cdf0e10cSrcweir return bResult;
155cdf0e10cSrcweir }
operator ()ScShapeDataLess156cdf0e10cSrcweir sal_Bool operator()(const ScAccessibleShapeData* pData1, const ScAccessibleShapeData* pData2) const
157cdf0e10cSrcweir {
158cdf0e10cSrcweir sal_Bool bResult(sal_False);
159cdf0e10cSrcweir if (pData1 && pData2)
160cdf0e10cSrcweir {
161cdf0e10cSrcweir uno::Reference< beans::XPropertySet> xProps1(pData1->xShape, uno::UNO_QUERY);
162cdf0e10cSrcweir uno::Reference< beans::XPropertySet> xProps2(pData2->xShape, uno::UNO_QUERY);
163cdf0e10cSrcweir if (xProps1.is() && xProps2.is())
164cdf0e10cSrcweir {
165cdf0e10cSrcweir uno::Any aPropAny1 = xProps1->getPropertyValue(msLayerId);
166cdf0e10cSrcweir uno::Any aPropAny2 = xProps2->getPropertyValue(msLayerId);
167cdf0e10cSrcweir sal_Int16 nLayerID1(0);
168cdf0e10cSrcweir sal_Int16 nLayerID2(0);
169cdf0e10cSrcweir if( (aPropAny1 >>= nLayerID1) && (aPropAny2 >>= nLayerID2) )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir if (nLayerID1 == nLayerID2)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir uno::Any aAny1 = xProps1->getPropertyValue(msZOrder);
174cdf0e10cSrcweir sal_Int32 nZOrder1 = 0;
175cdf0e10cSrcweir uno::Any aAny2 = xProps2->getPropertyValue(msZOrder);
176cdf0e10cSrcweir sal_Int32 nZOrder2 = 0;
177cdf0e10cSrcweir if ( (aAny1 >>= nZOrder1) && (aAny2 >>= nZOrder2) )
178cdf0e10cSrcweir bResult = (nZOrder1 < nZOrder2);
179cdf0e10cSrcweir }
180cdf0e10cSrcweir else
181cdf0e10cSrcweir {
182cdf0e10cSrcweir ConvertLayerId(nLayerID1);
183cdf0e10cSrcweir ConvertLayerId(nLayerID2);
184cdf0e10cSrcweir bResult = (nLayerID1 < nLayerID2);
185cdf0e10cSrcweir }
186cdf0e10cSrcweir }
187cdf0e10cSrcweir }
188cdf0e10cSrcweir }
189cdf0e10cSrcweir else if (pData1 && !pData2)
190cdf0e10cSrcweir bResult = LessThanSheet(pData1);
191cdf0e10cSrcweir else if (!pData1 && pData2)
192cdf0e10cSrcweir bResult = !LessThanSheet(pData2);
193cdf0e10cSrcweir else
194cdf0e10cSrcweir bResult = sal_False;
195cdf0e10cSrcweir return bResult;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir };
198cdf0e10cSrcweir
199cdf0e10cSrcweir struct DeselectShape
200cdf0e10cSrcweir {
operator ()DeselectShape201cdf0e10cSrcweir void operator() (const ScAccessibleShapeData* pAccShapeData) const
202cdf0e10cSrcweir {
203cdf0e10cSrcweir if (pAccShapeData)
204cdf0e10cSrcweir {
205cdf0e10cSrcweir pAccShapeData->bSelected = sal_False;
206cdf0e10cSrcweir if (pAccShapeData->pAccShape)
207cdf0e10cSrcweir pAccShapeData->pAccShape->ResetState(AccessibleStateType::SELECTED);
208cdf0e10cSrcweir }
209cdf0e10cSrcweir }
210cdf0e10cSrcweir };
211cdf0e10cSrcweir
212cdf0e10cSrcweir struct SelectShape
213cdf0e10cSrcweir {
214cdf0e10cSrcweir uno::Reference < drawing::XShapes > xShapes;
SelectShapeSelectShape215cdf0e10cSrcweir SelectShape(uno::Reference<drawing::XShapes>& xTemp) : xShapes(xTemp) {}
operator ()SelectShape216cdf0e10cSrcweir void operator() (const ScAccessibleShapeData* pAccShapeData) const
217cdf0e10cSrcweir {
218cdf0e10cSrcweir if (pAccShapeData && pAccShapeData->bSelectable)
219cdf0e10cSrcweir {
220cdf0e10cSrcweir pAccShapeData->bSelected = sal_True;
221cdf0e10cSrcweir if (pAccShapeData->pAccShape)
222cdf0e10cSrcweir pAccShapeData->pAccShape->SetState(AccessibleStateType::SELECTED);
223cdf0e10cSrcweir if (xShapes.is())
224cdf0e10cSrcweir xShapes->add(pAccShapeData->xShape);
225cdf0e10cSrcweir }
226cdf0e10cSrcweir }
227cdf0e10cSrcweir };
228cdf0e10cSrcweir
229cdf0e10cSrcweir struct Destroy
230cdf0e10cSrcweir {
operator ()Destroy231cdf0e10cSrcweir void operator() (ScAccessibleShapeData* pData)
232cdf0e10cSrcweir {
233cdf0e10cSrcweir if (pData)
234cdf0e10cSrcweir DELETEZ(pData);
235cdf0e10cSrcweir }
236cdf0e10cSrcweir };
237cdf0e10cSrcweir
238cdf0e10cSrcweir class ScChildrenShapes : public SfxListener,
239cdf0e10cSrcweir public ::accessibility::IAccessibleParent
240cdf0e10cSrcweir {
241cdf0e10cSrcweir public:
242cdf0e10cSrcweir ScChildrenShapes(ScAccessibleDocument* pAccessibleDocument, ScTabViewShell* pViewShell, ScSplitPos eSplitPos);
243cdf0e10cSrcweir ~ScChildrenShapes();
244cdf0e10cSrcweir
245cdf0e10cSrcweir ///===== SfxListener =====================================================
246cdf0e10cSrcweir
247cdf0e10cSrcweir virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
248cdf0e10cSrcweir
249cdf0e10cSrcweir ///===== IAccessibleParent ===============================================
250cdf0e10cSrcweir
251cdf0e10cSrcweir virtual sal_Bool ReplaceChild (
252cdf0e10cSrcweir ::accessibility::AccessibleShape* pCurrentChild,
253cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
254cdf0e10cSrcweir const long _nIndex,
255cdf0e10cSrcweir const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo
256cdf0e10cSrcweir ) throw (::com::sun::star::uno::RuntimeException);
257cdf0e10cSrcweir
2580deba7fbSSteve Yin virtual ::accessibility::AccessibleControlShape* GetAccControlShapeFromModel
2590deba7fbSSteve Yin (::com::sun::star::beans::XPropertySet* pSet)
2604937ceefSSteve Yin throw (::com::sun::star::uno::RuntimeException);
2610deba7fbSSteve Yin virtual ::com::sun::star::uno::Reference<
2620deba7fbSSteve Yin ::com::sun::star::accessibility::XAccessible>
2630deba7fbSSteve Yin GetAccessibleCaption (const ::com::sun::star::uno::Reference<
2640deba7fbSSteve Yin ::com::sun::star::drawing::XShape>& xShape)
2654937ceefSSteve Yin throw (::com::sun::star::uno::RuntimeException);
266cdf0e10cSrcweir ///===== Internal ========================================================
267cdf0e10cSrcweir void SetDrawBroadcaster();
268cdf0e10cSrcweir
269cdf0e10cSrcweir sal_Int32 GetCount() const;
270cdf0e10cSrcweir uno::Reference< XAccessible > Get(const ScAccessibleShapeData* pData) const;
271cdf0e10cSrcweir uno::Reference< XAccessible > Get(sal_Int32 nIndex) const;
272cdf0e10cSrcweir uno::Reference< XAccessible > GetAt(const awt::Point& rPoint) const;
273cdf0e10cSrcweir
274cdf0e10cSrcweir // gets the index of the shape starting on 0 (without the index of the table)
275cdf0e10cSrcweir // returns the selected shape
276cdf0e10cSrcweir sal_Bool IsSelected(sal_Int32 nIndex,
277cdf0e10cSrcweir com::sun::star::uno::Reference<com::sun::star::drawing::XShape>& rShape) const;
278cdf0e10cSrcweir
279cdf0e10cSrcweir sal_Bool SelectionChanged();
280cdf0e10cSrcweir
281cdf0e10cSrcweir void Select(sal_Int32 nIndex);
282cdf0e10cSrcweir void DeselectAll(); // deselect also the table
283cdf0e10cSrcweir void SelectAll();
284cdf0e10cSrcweir sal_Int32 GetSelectedCount() const;
285cdf0e10cSrcweir uno::Reference< XAccessible > GetSelected(sal_Int32 nSelectedChildIndex, sal_Bool bTabSelected) const;
286cdf0e10cSrcweir void Deselect(sal_Int32 nChildIndex);
287cdf0e10cSrcweir
288cdf0e10cSrcweir SdrPage* GetDrawPage() const;
289cdf0e10cSrcweir
290cdf0e10cSrcweir utl::AccessibleRelationSetHelper* GetRelationSet(const ScAddress* pAddress) const;
291cdf0e10cSrcweir
292cdf0e10cSrcweir void VisAreaChanged() const;
293cdf0e10cSrcweir private:
294cdf0e10cSrcweir typedef std::vector<ScAccessibleShapeData*> SortedShapes;
295cdf0e10cSrcweir
296cdf0e10cSrcweir mutable SortedShapes maZOrderedShapes; // a null pointer represents the sheet in the correct order
297cdf0e10cSrcweir
298cdf0e10cSrcweir mutable ::accessibility::AccessibleShapeTreeInfo maShapeTreeInfo;
299cdf0e10cSrcweir mutable com::sun::star::uno::Reference<com::sun::star::view::XSelectionSupplier> xSelectionSupplier;
300cdf0e10cSrcweir mutable sal_uInt32 mnSdrObjCount;
301cdf0e10cSrcweir mutable sal_uInt32 mnShapesSelected;
302cdf0e10cSrcweir ScTabViewShell* mpViewShell;
303cdf0e10cSrcweir ScAccessibleDocument* mpAccessibleDocument;
304cdf0e10cSrcweir ScSplitPos meSplitPos;
305cdf0e10cSrcweir
306cdf0e10cSrcweir void FillShapes(std::vector < uno::Reference < drawing::XShape > >& rShapes) const;
307cdf0e10cSrcweir sal_Bool FindSelectedShapesChanges(const com::sun::star::uno::Reference<com::sun::star::drawing::XShapes>& xShapes, sal_Bool bCommitChange) const;
308cdf0e10cSrcweir void FillSelectionSupplier() const;
309cdf0e10cSrcweir
310cdf0e10cSrcweir ScAddress* GetAnchor(const uno::Reference<drawing::XShape>& xShape) const;
311cdf0e10cSrcweir uno::Reference<XAccessibleRelationSet> GetRelationSet(const ScAccessibleShapeData* pData) const;
312cdf0e10cSrcweir void CheckWhetherAnchorChanged(const uno::Reference<drawing::XShape>& xShape) const;
313cdf0e10cSrcweir void SetAnchor(const uno::Reference<drawing::XShape>& xShape, ScAccessibleShapeData* pData) const;
314cdf0e10cSrcweir void AddShape(const uno::Reference<drawing::XShape>& xShape, sal_Bool bCommitChange) const;
315cdf0e10cSrcweir void RemoveShape(const uno::Reference<drawing::XShape>& xShape) const;
316cdf0e10cSrcweir
317cdf0e10cSrcweir sal_Bool FindShape(const uno::Reference<drawing::XShape>& xShape, SortedShapes::iterator& rItr) const;
318cdf0e10cSrcweir
319cdf0e10cSrcweir sal_Int8 Compare(const ScAccessibleShapeData* pData1,
320cdf0e10cSrcweir const ScAccessibleShapeData* pData2) const;
321cdf0e10cSrcweir };
322cdf0e10cSrcweir
ScChildrenShapes(ScAccessibleDocument * pAccessibleDocument,ScTabViewShell * pViewShell,ScSplitPos eSplitPos)323cdf0e10cSrcweir ScChildrenShapes::ScChildrenShapes(ScAccessibleDocument* pAccessibleDocument, ScTabViewShell* pViewShell, ScSplitPos eSplitPos)
324cdf0e10cSrcweir :
325cdf0e10cSrcweir mnShapesSelected(0),
326cdf0e10cSrcweir mpViewShell(pViewShell),
327cdf0e10cSrcweir mpAccessibleDocument(pAccessibleDocument),
328cdf0e10cSrcweir meSplitPos(eSplitPos)
329cdf0e10cSrcweir {
330cdf0e10cSrcweir FillSelectionSupplier();
331cdf0e10cSrcweir maZOrderedShapes.push_back(NULL); // add an element which represents the table
332cdf0e10cSrcweir
333cdf0e10cSrcweir GetCount(); // fill list with filtered shapes (no internal shapes)
334cdf0e10cSrcweir
335cdf0e10cSrcweir if (mnShapesSelected)
336cdf0e10cSrcweir {
337cdf0e10cSrcweir //set flag on every selected shape
338cdf0e10cSrcweir if (!xSelectionSupplier.is())
339cdf0e10cSrcweir throw uno::RuntimeException();
340cdf0e10cSrcweir
341cdf0e10cSrcweir uno::Reference<drawing::XShapes> xShapes(xSelectionSupplier->getSelection(), uno::UNO_QUERY);
342cdf0e10cSrcweir if (xShapes.is())
343cdf0e10cSrcweir FindSelectedShapesChanges(xShapes, sal_False);
344cdf0e10cSrcweir }
345cdf0e10cSrcweir if (pViewShell)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir SfxBroadcaster* pDrawBC = pViewShell->GetViewData()->GetDocument()->GetDrawBroadcaster();
348cdf0e10cSrcweir if (pDrawBC)
349cdf0e10cSrcweir {
350cdf0e10cSrcweir StartListening(*pDrawBC);
351cdf0e10cSrcweir
352cdf0e10cSrcweir maShapeTreeInfo.SetModelBroadcaster( new ScDrawModelBroadcaster(pViewShell->GetViewData()->GetDocument()->GetDrawLayer()) );
353cdf0e10cSrcweir maShapeTreeInfo.SetSdrView(pViewShell->GetViewData()->GetScDrawView());
354cdf0e10cSrcweir maShapeTreeInfo.SetController(NULL);
355cdf0e10cSrcweir maShapeTreeInfo.SetWindow(pViewShell->GetWindowByPos(meSplitPos));
356cdf0e10cSrcweir maShapeTreeInfo.SetViewForwarder(mpAccessibleDocument);
357cdf0e10cSrcweir }
358cdf0e10cSrcweir }
359cdf0e10cSrcweir }
360cdf0e10cSrcweir
~ScChildrenShapes()361cdf0e10cSrcweir ScChildrenShapes::~ScChildrenShapes()
362cdf0e10cSrcweir {
363cdf0e10cSrcweir std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), Destroy());
364cdf0e10cSrcweir if (mpViewShell)
365cdf0e10cSrcweir {
366cdf0e10cSrcweir SfxBroadcaster* pDrawBC = mpViewShell->GetViewData()->GetDocument()->GetDrawBroadcaster();
367cdf0e10cSrcweir if (pDrawBC)
368cdf0e10cSrcweir EndListening(*pDrawBC);
369cdf0e10cSrcweir }
370cdf0e10cSrcweir }
371cdf0e10cSrcweir
SetDrawBroadcaster()372cdf0e10cSrcweir void ScChildrenShapes::SetDrawBroadcaster()
373cdf0e10cSrcweir {
374cdf0e10cSrcweir if (mpViewShell)
375cdf0e10cSrcweir {
376cdf0e10cSrcweir SfxBroadcaster* pDrawBC = mpViewShell->GetViewData()->GetDocument()->GetDrawBroadcaster();
377cdf0e10cSrcweir if (pDrawBC)
378cdf0e10cSrcweir {
379cdf0e10cSrcweir StartListening(*pDrawBC, sal_True);
380cdf0e10cSrcweir
381cdf0e10cSrcweir maShapeTreeInfo.SetModelBroadcaster( new ScDrawModelBroadcaster(mpViewShell->GetViewData()->GetDocument()->GetDrawLayer()) );
382cdf0e10cSrcweir maShapeTreeInfo.SetSdrView(mpViewShell->GetViewData()->GetScDrawView());
383cdf0e10cSrcweir maShapeTreeInfo.SetController(NULL);
384cdf0e10cSrcweir maShapeTreeInfo.SetWindow(mpViewShell->GetWindowByPos(meSplitPos));
385cdf0e10cSrcweir maShapeTreeInfo.SetViewForwarder(mpAccessibleDocument);
386cdf0e10cSrcweir }
387cdf0e10cSrcweir }
388cdf0e10cSrcweir }
389cdf0e10cSrcweir
Notify(SfxBroadcaster &,const SfxHint & rHint)390cdf0e10cSrcweir void ScChildrenShapes::Notify(SfxBroadcaster&, const SfxHint& rHint)
391cdf0e10cSrcweir {
392cdf0e10cSrcweir if ( rHint.ISA( SdrHint ) )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
395cdf0e10cSrcweir if (pSdrHint)
396cdf0e10cSrcweir {
397cdf0e10cSrcweir SdrObject* pObj = const_cast<SdrObject*>(pSdrHint->GetObject());
398cdf0e10cSrcweir if (pObj && /*(pObj->GetLayer() != SC_LAYER_INTERN) && */(pObj->GetPage() == GetDrawPage()) &&
399cdf0e10cSrcweir (pObj->GetPage() == pObj->GetObjList()) ) //#108480# only do something if the object lies direct on the page
400cdf0e10cSrcweir {
401cdf0e10cSrcweir switch (pSdrHint->GetKind())
402cdf0e10cSrcweir {
403cdf0e10cSrcweir case HINT_OBJCHG : // Objekt geaendert
404cdf0e10cSrcweir {
405cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY);
406cdf0e10cSrcweir if (xShape.is())
407cdf0e10cSrcweir {
408cdf0e10cSrcweir ScShapeDataLess aLess;
409cdf0e10cSrcweir std::sort(maZOrderedShapes.begin(), maZOrderedShapes.end(), aLess); // sort, because the z index or layer could be changed
410cdf0e10cSrcweir CheckWhetherAnchorChanged(xShape);
411cdf0e10cSrcweir }
412cdf0e10cSrcweir }
413cdf0e10cSrcweir break;
414cdf0e10cSrcweir case HINT_OBJINSERTED : // Neues Zeichenobjekt eingefuegt
415cdf0e10cSrcweir {
416cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY);
417cdf0e10cSrcweir if (xShape.is())
418cdf0e10cSrcweir AddShape(xShape, sal_True);
419cdf0e10cSrcweir }
420cdf0e10cSrcweir break;
421cdf0e10cSrcweir case HINT_OBJREMOVED : // Zeichenobjekt aus Liste entfernt
422cdf0e10cSrcweir {
423cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY);
424cdf0e10cSrcweir if (xShape.is())
425cdf0e10cSrcweir RemoveShape(xShape);
426cdf0e10cSrcweir }
427cdf0e10cSrcweir break;
428cdf0e10cSrcweir default :
429cdf0e10cSrcweir {
430cdf0e10cSrcweir // other events are not interesting
431cdf0e10cSrcweir }
432cdf0e10cSrcweir break;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir }
435cdf0e10cSrcweir }
436cdf0e10cSrcweir }
437cdf0e10cSrcweir }
438cdf0e10cSrcweir
ReplaceChild(::accessibility::AccessibleShape * pCurrentChild,const::com::sun::star::uno::Reference<::com::sun::star::drawing::XShape> & _rxShape,const long _nIndex,const::accessibility::AccessibleShapeTreeInfo & _rShapeTreeInfo)439cdf0e10cSrcweir sal_Bool ScChildrenShapes::ReplaceChild (::accessibility::AccessibleShape* pCurrentChild,
440cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
441cdf0e10cSrcweir const long _nIndex, const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo)
442cdf0e10cSrcweir throw (uno::RuntimeException)
443cdf0e10cSrcweir {
444cdf0e10cSrcweir // create the new child
445cdf0e10cSrcweir ::accessibility::AccessibleShape* pReplacement = ::accessibility::ShapeTypeHandler::Instance().CreateAccessibleObject (
446cdf0e10cSrcweir ::accessibility::AccessibleShapeInfo ( _rxShape, pCurrentChild->getAccessibleParent(), this, _nIndex ),
447cdf0e10cSrcweir _rShapeTreeInfo
448cdf0e10cSrcweir );
449cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xNewChild( pReplacement ); // keep this alive (do this before calling Init!)
450cdf0e10cSrcweir if ( pReplacement )
451cdf0e10cSrcweir pReplacement->Init();
452cdf0e10cSrcweir
453cdf0e10cSrcweir sal_Bool bResult(sal_False);
454cdf0e10cSrcweir if (pCurrentChild && pReplacement)
455cdf0e10cSrcweir {
456cdf0e10cSrcweir DBG_ASSERT(pCurrentChild->GetXShape().get() == pReplacement->GetXShape().get(), "XShape changes and should be inserted sorted");
457cdf0e10cSrcweir SortedShapes::iterator aItr;
458cdf0e10cSrcweir FindShape(pCurrentChild->GetXShape(), aItr);
459cdf0e10cSrcweir if (aItr != maZOrderedShapes.end() && (*aItr))
460cdf0e10cSrcweir {
461cdf0e10cSrcweir if ((*aItr)->pAccShape)
462cdf0e10cSrcweir {
463cdf0e10cSrcweir DBG_ASSERT((*aItr)->pAccShape == pCurrentChild, "wrong child found");
464cdf0e10cSrcweir AccessibleEventObject aEvent;
465cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
466cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument);
467cdf0e10cSrcweir aEvent.OldValue <<= uno::makeAny(uno::Reference<XAccessible>(pCurrentChild));
468cdf0e10cSrcweir
469cdf0e10cSrcweir mpAccessibleDocument->CommitChange(aEvent); // child is gone - event
470cdf0e10cSrcweir
471cdf0e10cSrcweir pCurrentChild->dispose();
472cdf0e10cSrcweir }
473cdf0e10cSrcweir (*aItr)->pAccShape = pReplacement;
474cdf0e10cSrcweir AccessibleEventObject aEvent;
475cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
476cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument);
477cdf0e10cSrcweir aEvent.NewValue <<= uno::makeAny(uno::Reference<XAccessible>(pReplacement));
478cdf0e10cSrcweir
479cdf0e10cSrcweir mpAccessibleDocument->CommitChange(aEvent); // child is new - event
480cdf0e10cSrcweir bResult = sal_True;
481cdf0e10cSrcweir }
482cdf0e10cSrcweir }
483cdf0e10cSrcweir return bResult;
484cdf0e10cSrcweir }
485cdf0e10cSrcweir
GetAccControlShapeFromModel(::com::sun::star::beans::XPropertySet * pSet)4864937ceefSSteve Yin ::accessibility::AccessibleControlShape * ScChildrenShapes::GetAccControlShapeFromModel(::com::sun::star::beans::XPropertySet* pSet) throw (::com::sun::star::uno::RuntimeException)
4870deba7fbSSteve Yin {
4880deba7fbSSteve Yin sal_Int32 count = GetCount();
4890deba7fbSSteve Yin for (sal_Int32 index=0;index<count;index++)
4900deba7fbSSteve Yin {
4910deba7fbSSteve Yin ScAccessibleShapeData* pShape = maZOrderedShapes[index];
4920deba7fbSSteve Yin if (pShape)
4930deba7fbSSteve Yin {
4940deba7fbSSteve Yin ::accessibility::AccessibleShape* pAccShape = pShape->pAccShape;
4950deba7fbSSteve Yin if (pAccShape && ::accessibility::ShapeTypeHandler::Instance().GetTypeId (pAccShape->GetXShape()) == ::accessibility::DRAWING_CONTROL)
4960deba7fbSSteve Yin {
4970deba7fbSSteve Yin ::accessibility::AccessibleControlShape *pCtlAccShape = static_cast < ::accessibility::AccessibleControlShape* >(pAccShape);
4980deba7fbSSteve Yin if (pCtlAccShape && pCtlAccShape->GetControlModel() == pSet)
4990deba7fbSSteve Yin return pCtlAccShape;
5000deba7fbSSteve Yin }
5010deba7fbSSteve Yin }
5020deba7fbSSteve Yin }
5030deba7fbSSteve Yin return NULL;
5040deba7fbSSteve Yin }
5050deba7fbSSteve Yin ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible >
GetAccessibleCaption(const::com::sun::star::uno::Reference<::com::sun::star::drawing::XShape> & xShape)5060deba7fbSSteve Yin ScChildrenShapes::GetAccessibleCaption (const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape>& xShape)
5074937ceefSSteve Yin throw (::com::sun::star::uno::RuntimeException)
5080deba7fbSSteve Yin {
5090deba7fbSSteve Yin sal_Int32 count = GetCount();
5100deba7fbSSteve Yin for (sal_Int32 index=0;index<count;index++)
5110deba7fbSSteve Yin {
5120deba7fbSSteve Yin ScAccessibleShapeData* pShape = maZOrderedShapes[index];
5130deba7fbSSteve Yin if (pShape && pShape->xShape == xShape )
5140deba7fbSSteve Yin {
5150deba7fbSSteve Yin ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xNewChild( pShape->pAccShape );
5160deba7fbSSteve Yin // uno::Reference<XAccessible> xNewChild( pShape->pAccShape , uno::UNO_QUERY );
5170deba7fbSSteve Yin if(xNewChild.get())
5180deba7fbSSteve Yin return xNewChild;
5190deba7fbSSteve Yin }
5200deba7fbSSteve Yin }
5210deba7fbSSteve Yin return NULL;
5220deba7fbSSteve Yin }
GetCount() const523cdf0e10cSrcweir sal_Int32 ScChildrenShapes::GetCount() const
524cdf0e10cSrcweir {
525cdf0e10cSrcweir SdrPage* pDrawPage = GetDrawPage();
526cdf0e10cSrcweir if (pDrawPage && (maZOrderedShapes.size() == 1)) // the table is always in
527cdf0e10cSrcweir {
528cdf0e10cSrcweir mnSdrObjCount = pDrawPage->GetObjCount();
529cdf0e10cSrcweir maZOrderedShapes.reserve(mnSdrObjCount + 1); // the table is always in
530cdf0e10cSrcweir for (sal_uInt32 i = 0; i < mnSdrObjCount; ++i)
531cdf0e10cSrcweir {
532cdf0e10cSrcweir SdrObject* pObj = pDrawPage->GetObj(i);
533cdf0e10cSrcweir if (pObj/* && (pObj->GetLayer() != SC_LAYER_INTERN)*/)
534cdf0e10cSrcweir {
535cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape (pObj->getUnoShape(), uno::UNO_QUERY);
536cdf0e10cSrcweir AddShape(xShape, sal_False); //inserts in the correct order
537cdf0e10cSrcweir }
538cdf0e10cSrcweir }
539cdf0e10cSrcweir }
540cdf0e10cSrcweir return maZOrderedShapes.size();
541cdf0e10cSrcweir }
542cdf0e10cSrcweir
Get(const ScAccessibleShapeData * pData) const543cdf0e10cSrcweir uno::Reference< XAccessible > ScChildrenShapes::Get(const ScAccessibleShapeData* pData) const
544cdf0e10cSrcweir {
545cdf0e10cSrcweir if (!pData)
546cdf0e10cSrcweir return NULL;
547cdf0e10cSrcweir
548cdf0e10cSrcweir if (!pData->pAccShape)
549cdf0e10cSrcweir {
550cdf0e10cSrcweir ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance();
551cdf0e10cSrcweir ::accessibility::AccessibleShapeInfo aShapeInfo(pData->xShape, mpAccessibleDocument, const_cast<ScChildrenShapes*>(this));
552cdf0e10cSrcweir pData->pAccShape = rShapeHandler.CreateAccessibleObject(
553cdf0e10cSrcweir aShapeInfo, maShapeTreeInfo);
554cdf0e10cSrcweir if (pData->pAccShape)
555cdf0e10cSrcweir {
556cdf0e10cSrcweir pData->pAccShape->acquire();
557cdf0e10cSrcweir pData->pAccShape->Init();
558cdf0e10cSrcweir if (pData->bSelected)
559cdf0e10cSrcweir pData->pAccShape->SetState(AccessibleStateType::SELECTED);
560cdf0e10cSrcweir if (!pData->bSelectable)
561cdf0e10cSrcweir pData->pAccShape->ResetState(AccessibleStateType::SELECTABLE);
562cdf0e10cSrcweir pData->pAccShape->SetRelationSet(GetRelationSet(pData));
563cdf0e10cSrcweir }
564cdf0e10cSrcweir }
565cdf0e10cSrcweir return pData->pAccShape;
566cdf0e10cSrcweir }
567cdf0e10cSrcweir
Get(sal_Int32 nIndex) const568cdf0e10cSrcweir uno::Reference< XAccessible > ScChildrenShapes::Get(sal_Int32 nIndex) const
569cdf0e10cSrcweir {
570cdf0e10cSrcweir if (maZOrderedShapes.size() <= 1)
571cdf0e10cSrcweir GetCount(); // fill list with filtered shapes (no internal shapes)
572cdf0e10cSrcweir
573cdf0e10cSrcweir if (static_cast<sal_uInt32>(nIndex) >= maZOrderedShapes.size())
574cdf0e10cSrcweir return NULL;
575cdf0e10cSrcweir
576cdf0e10cSrcweir return Get(maZOrderedShapes[nIndex]);
577cdf0e10cSrcweir }
578cdf0e10cSrcweir
GetAt(const awt::Point & rPoint) const579cdf0e10cSrcweir uno::Reference< XAccessible > ScChildrenShapes::GetAt(const awt::Point& rPoint) const
580cdf0e10cSrcweir {
581cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible;
582cdf0e10cSrcweir if(mpViewShell)
583cdf0e10cSrcweir {
584cdf0e10cSrcweir sal_Int32 i(maZOrderedShapes.size() - 1);
585cdf0e10cSrcweir sal_Bool bFound(sal_False);
586cdf0e10cSrcweir while (!bFound && i >= 0)
587cdf0e10cSrcweir {
588cdf0e10cSrcweir ScAccessibleShapeData* pShape = maZOrderedShapes[i];
589cdf0e10cSrcweir if (pShape)
590cdf0e10cSrcweir {
591cdf0e10cSrcweir if (!pShape->pAccShape)
592cdf0e10cSrcweir Get(pShape);
593cdf0e10cSrcweir
594cdf0e10cSrcweir if (pShape->pAccShape)
595cdf0e10cSrcweir {
596cdf0e10cSrcweir Point aPoint(VCLPoint(rPoint));
597cdf0e10cSrcweir aPoint -= VCLRectangle(pShape->pAccShape->getBounds()).TopLeft();
598cdf0e10cSrcweir if (pShape->pAccShape->containsPoint(AWTPoint(aPoint)))
599cdf0e10cSrcweir {
600cdf0e10cSrcweir xAccessible = pShape->pAccShape;
601cdf0e10cSrcweir bFound = sal_True;
602cdf0e10cSrcweir }
603cdf0e10cSrcweir }
604cdf0e10cSrcweir else
605cdf0e10cSrcweir {
606cdf0e10cSrcweir DBG_ERRORFILE("I should have an accessible shape now!");
607cdf0e10cSrcweir }
608cdf0e10cSrcweir }
609cdf0e10cSrcweir else
610cdf0e10cSrcweir bFound = sal_True; // this is the sheet and it lies before the rest of the shapes which are background shapes
611cdf0e10cSrcweir
612cdf0e10cSrcweir --i;
613cdf0e10cSrcweir }
614cdf0e10cSrcweir }
615cdf0e10cSrcweir return xAccessible;
616cdf0e10cSrcweir }
617cdf0e10cSrcweir
IsSelected(sal_Int32 nIndex,uno::Reference<drawing::XShape> & rShape) const618cdf0e10cSrcweir sal_Bool ScChildrenShapes::IsSelected(sal_Int32 nIndex,
619cdf0e10cSrcweir uno::Reference<drawing::XShape>& rShape) const
620cdf0e10cSrcweir {
621cdf0e10cSrcweir sal_Bool bResult (sal_False);
622cdf0e10cSrcweir if (maZOrderedShapes.size() <= 1)
623cdf0e10cSrcweir GetCount(); // fill list with filtered shapes (no internal shapes)
624cdf0e10cSrcweir
625cdf0e10cSrcweir if (!xSelectionSupplier.is())
626cdf0e10cSrcweir throw uno::RuntimeException();
627cdf0e10cSrcweir
628cdf0e10cSrcweir if (!maZOrderedShapes[nIndex])
629cdf0e10cSrcweir return sal_False;
630cdf0e10cSrcweir
631cdf0e10cSrcweir bResult = maZOrderedShapes[nIndex]->bSelected;
632cdf0e10cSrcweir rShape = maZOrderedShapes[nIndex]->xShape;
633cdf0e10cSrcweir
634cdf0e10cSrcweir #ifdef DBG_UTIL // test whether it is truly selected by a slower method
635cdf0e10cSrcweir uno::Reference< drawing::XShape > xReturnShape;
636cdf0e10cSrcweir sal_Bool bDebugResult(sal_False);
637cdf0e10cSrcweir uno::Reference<container::XIndexAccess> xIndexAccess;
638cdf0e10cSrcweir xSelectionSupplier->getSelection() >>= xIndexAccess;
639cdf0e10cSrcweir
640cdf0e10cSrcweir if (xIndexAccess.is())
641cdf0e10cSrcweir {
642cdf0e10cSrcweir sal_Int32 nCount(xIndexAccess->getCount());
643cdf0e10cSrcweir if (nCount)
644cdf0e10cSrcweir {
645cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape;
646cdf0e10cSrcweir uno::Reference< drawing::XShape > xIndexShape = maZOrderedShapes[nIndex]->xShape;
647cdf0e10cSrcweir sal_Int32 i(0);
648cdf0e10cSrcweir while (!bDebugResult && (i < nCount))
649cdf0e10cSrcweir {
650cdf0e10cSrcweir xIndexAccess->getByIndex(i) >>= xShape;
651cdf0e10cSrcweir if (xShape.is() && (xIndexShape.get() == xShape.get()))
652cdf0e10cSrcweir {
653cdf0e10cSrcweir bDebugResult = sal_True;
654cdf0e10cSrcweir xReturnShape = xShape;
655cdf0e10cSrcweir }
656cdf0e10cSrcweir else
657cdf0e10cSrcweir ++i;
658cdf0e10cSrcweir }
659cdf0e10cSrcweir }
660cdf0e10cSrcweir }
661cdf0e10cSrcweir DBG_ASSERT((bResult == bDebugResult) && ((bResult && (rShape.get() == xReturnShape.get())) || !bResult), "found the wrong shape or result");
662cdf0e10cSrcweir #endif
663cdf0e10cSrcweir
664cdf0e10cSrcweir return bResult;
665cdf0e10cSrcweir }
666cdf0e10cSrcweir
SelectionChanged()667cdf0e10cSrcweir sal_Bool ScChildrenShapes::SelectionChanged()
668cdf0e10cSrcweir {
669cdf0e10cSrcweir sal_Bool bResult(sal_False);
670cdf0e10cSrcweir if (!xSelectionSupplier.is())
671cdf0e10cSrcweir throw uno::RuntimeException();
672cdf0e10cSrcweir
673cdf0e10cSrcweir uno::Reference<drawing::XShapes> xShapes(xSelectionSupplier->getSelection(), uno::UNO_QUERY);
674cdf0e10cSrcweir
675cdf0e10cSrcweir bResult = FindSelectedShapesChanges(xShapes, sal_True);
676cdf0e10cSrcweir
677cdf0e10cSrcweir return bResult;
678cdf0e10cSrcweir }
679cdf0e10cSrcweir
Select(sal_Int32 nIndex)680cdf0e10cSrcweir void ScChildrenShapes::Select(sal_Int32 nIndex)
681cdf0e10cSrcweir {
682cdf0e10cSrcweir if (maZOrderedShapes.size() <= 1)
683cdf0e10cSrcweir GetCount(); // fill list with filtered shapes (no internal shapes)
684cdf0e10cSrcweir
685cdf0e10cSrcweir if (!xSelectionSupplier.is())
686cdf0e10cSrcweir throw uno::RuntimeException();
687cdf0e10cSrcweir
688cdf0e10cSrcweir if (!maZOrderedShapes[nIndex])
689cdf0e10cSrcweir return;
690cdf0e10cSrcweir
691cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape;
692cdf0e10cSrcweir if (!IsSelected(nIndex, xShape) && maZOrderedShapes[nIndex]->bSelectable)
693cdf0e10cSrcweir {
694cdf0e10cSrcweir uno::Reference<drawing::XShapes> xShapes;
695cdf0e10cSrcweir xSelectionSupplier->getSelection() >>= xShapes;
696cdf0e10cSrcweir
697cdf0e10cSrcweir if (!xShapes.is())
698cdf0e10cSrcweir xShapes = new SvxShapeCollection();
699cdf0e10cSrcweir
700cdf0e10cSrcweir xShapes->add(maZOrderedShapes[nIndex]->xShape);
701cdf0e10cSrcweir
702cdf0e10cSrcweir try
703cdf0e10cSrcweir {
704cdf0e10cSrcweir xSelectionSupplier->select(uno::makeAny(xShapes));
705cdf0e10cSrcweir maZOrderedShapes[nIndex]->bSelected = sal_True;
706cdf0e10cSrcweir if (maZOrderedShapes[nIndex]->pAccShape)
707cdf0e10cSrcweir maZOrderedShapes[nIndex]->pAccShape->SetState(AccessibleStateType::SELECTED);
708cdf0e10cSrcweir }
709cdf0e10cSrcweir catch (lang::IllegalArgumentException&)
710cdf0e10cSrcweir {
711cdf0e10cSrcweir }
712cdf0e10cSrcweir }
713cdf0e10cSrcweir }
714cdf0e10cSrcweir
DeselectAll()715cdf0e10cSrcweir void ScChildrenShapes::DeselectAll()
716cdf0e10cSrcweir {
717cdf0e10cSrcweir if (!xSelectionSupplier.is())
718cdf0e10cSrcweir throw uno::RuntimeException();
719cdf0e10cSrcweir
720cdf0e10cSrcweir sal_Bool bSomethingSelected(sal_True);
721cdf0e10cSrcweir try
722cdf0e10cSrcweir {
723cdf0e10cSrcweir xSelectionSupplier->select(uno::Any()); //deselects all
724cdf0e10cSrcweir }
725cdf0e10cSrcweir catch (lang::IllegalArgumentException&)
726cdf0e10cSrcweir {
727cdf0e10cSrcweir DBG_ERRORFILE("nothing selected before");
728cdf0e10cSrcweir bSomethingSelected = sal_False;
729cdf0e10cSrcweir }
730cdf0e10cSrcweir
731cdf0e10cSrcweir if (bSomethingSelected)
732cdf0e10cSrcweir std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), DeselectShape());
733cdf0e10cSrcweir }
734cdf0e10cSrcweir
SelectAll()735cdf0e10cSrcweir void ScChildrenShapes::SelectAll()
736cdf0e10cSrcweir {
737cdf0e10cSrcweir if (!xSelectionSupplier.is())
738cdf0e10cSrcweir throw uno::RuntimeException();
739cdf0e10cSrcweir
740cdf0e10cSrcweir if (maZOrderedShapes.size() <= 1)
741cdf0e10cSrcweir GetCount(); // fill list with filtered shapes (no internal shapes)
742cdf0e10cSrcweir
743cdf0e10cSrcweir if (maZOrderedShapes.size() > 1)
744cdf0e10cSrcweir {
745cdf0e10cSrcweir uno::Reference<drawing::XShapes> xShapes;
746cdf0e10cSrcweir xShapes = new SvxShapeCollection();
747cdf0e10cSrcweir
748cdf0e10cSrcweir try
749cdf0e10cSrcweir {
750cdf0e10cSrcweir std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), SelectShape(xShapes));
751cdf0e10cSrcweir xSelectionSupplier->select(uno::makeAny(xShapes));
752cdf0e10cSrcweir }
753cdf0e10cSrcweir catch (lang::IllegalArgumentException&)
754cdf0e10cSrcweir {
755cdf0e10cSrcweir SelectionChanged(); // find all selected shapes and set the flags
756cdf0e10cSrcweir }
757cdf0e10cSrcweir }
758cdf0e10cSrcweir }
759cdf0e10cSrcweir
FillShapes(std::vector<uno::Reference<drawing::XShape>> & rShapes) const760cdf0e10cSrcweir void ScChildrenShapes::FillShapes(std::vector < uno::Reference < drawing::XShape > >& rShapes) const
761cdf0e10cSrcweir {
762cdf0e10cSrcweir uno::Reference<container::XIndexAccess> xIndexAccess;
763cdf0e10cSrcweir xSelectionSupplier->getSelection() >>= xIndexAccess;
764cdf0e10cSrcweir
765cdf0e10cSrcweir if (xIndexAccess.is())
766cdf0e10cSrcweir {
767cdf0e10cSrcweir sal_uInt32 nCount(xIndexAccess->getCount());
768cdf0e10cSrcweir for (sal_uInt32 i = 0; i < nCount; ++i)
769cdf0e10cSrcweir {
770cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape;
771cdf0e10cSrcweir xIndexAccess->getByIndex(i) >>= xShape;
772cdf0e10cSrcweir if (xShape.is())
773cdf0e10cSrcweir rShapes.push_back(xShape);
774cdf0e10cSrcweir }
775cdf0e10cSrcweir }
776cdf0e10cSrcweir }
777cdf0e10cSrcweir
GetSelectedCount() const778cdf0e10cSrcweir sal_Int32 ScChildrenShapes::GetSelectedCount() const
779cdf0e10cSrcweir {
780cdf0e10cSrcweir if (!xSelectionSupplier.is())
781cdf0e10cSrcweir throw uno::RuntimeException();
782cdf0e10cSrcweir
783cdf0e10cSrcweir std::vector < uno::Reference < drawing::XShape > > aShapes;
784cdf0e10cSrcweir FillShapes(aShapes);
785cdf0e10cSrcweir
786cdf0e10cSrcweir return aShapes.size();
787cdf0e10cSrcweir }
788cdf0e10cSrcweir
GetSelected(sal_Int32 nSelectedChildIndex,sal_Bool bTabSelected) const789cdf0e10cSrcweir uno::Reference< XAccessible > ScChildrenShapes::GetSelected(sal_Int32 nSelectedChildIndex, sal_Bool bTabSelected) const
790cdf0e10cSrcweir {
791cdf0e10cSrcweir uno::Reference< XAccessible > xAccessible;
792cdf0e10cSrcweir
793cdf0e10cSrcweir if (maZOrderedShapes.size() <= 1)
794cdf0e10cSrcweir GetCount(); // fill list with shapes
795cdf0e10cSrcweir
796cdf0e10cSrcweir if (!bTabSelected)
797cdf0e10cSrcweir {
798cdf0e10cSrcweir std::vector < uno::Reference < drawing::XShape > > aShapes;
799cdf0e10cSrcweir FillShapes(aShapes);
800cdf0e10cSrcweir
8010deba7fbSSteve Yin if(aShapes.size()<=0) return xAccessible;
802cdf0e10cSrcweir SortedShapes::iterator aItr;
803cdf0e10cSrcweir if (FindShape(aShapes[nSelectedChildIndex], aItr))
804cdf0e10cSrcweir xAccessible = Get(aItr - maZOrderedShapes.begin());
805cdf0e10cSrcweir }
806cdf0e10cSrcweir else
807cdf0e10cSrcweir {
808cdf0e10cSrcweir SortedShapes::iterator aItr = maZOrderedShapes.begin();
809cdf0e10cSrcweir SortedShapes::iterator aEndItr = maZOrderedShapes.end();
810cdf0e10cSrcweir sal_Bool bFound(sal_False);
811cdf0e10cSrcweir while(!bFound && aItr != aEndItr)
812cdf0e10cSrcweir {
813cdf0e10cSrcweir if (*aItr)
814cdf0e10cSrcweir {
815cdf0e10cSrcweir if ((*aItr)->bSelected)
816cdf0e10cSrcweir {
817cdf0e10cSrcweir if (nSelectedChildIndex == 0)
818cdf0e10cSrcweir bFound = sal_True;
819cdf0e10cSrcweir else
820cdf0e10cSrcweir --nSelectedChildIndex;
821cdf0e10cSrcweir }
822cdf0e10cSrcweir }
823cdf0e10cSrcweir else
824cdf0e10cSrcweir {
825cdf0e10cSrcweir if (nSelectedChildIndex == 0)
826cdf0e10cSrcweir bFound = sal_True;
827cdf0e10cSrcweir else
828cdf0e10cSrcweir --nSelectedChildIndex;
829cdf0e10cSrcweir }
830cdf0e10cSrcweir if (!bFound)
831cdf0e10cSrcweir ++aItr;
832cdf0e10cSrcweir }
833cdf0e10cSrcweir if (bFound && *aItr)
834cdf0e10cSrcweir xAccessible = (*aItr)->pAccShape;
835cdf0e10cSrcweir }
836cdf0e10cSrcweir
837cdf0e10cSrcweir return xAccessible;
838cdf0e10cSrcweir }
839cdf0e10cSrcweir
Deselect(sal_Int32 nChildIndex)840cdf0e10cSrcweir void ScChildrenShapes::Deselect(sal_Int32 nChildIndex)
841cdf0e10cSrcweir {
842cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape;
843cdf0e10cSrcweir if (IsSelected(nChildIndex, xShape)) // returns false if it is the sheet
844cdf0e10cSrcweir {
845cdf0e10cSrcweir if (xShape.is())
846cdf0e10cSrcweir {
847cdf0e10cSrcweir uno::Reference<drawing::XShapes> xShapes;
848cdf0e10cSrcweir xSelectionSupplier->getSelection() >>= xShapes;
849cdf0e10cSrcweir if (xShapes.is())
850cdf0e10cSrcweir xShapes->remove(xShape);
851cdf0e10cSrcweir
852cdf0e10cSrcweir try
853cdf0e10cSrcweir {
854cdf0e10cSrcweir xSelectionSupplier->select(uno::makeAny(xShapes));
855cdf0e10cSrcweir }
856cdf0e10cSrcweir catch (lang::IllegalArgumentException&)
857cdf0e10cSrcweir {
858cdf0e10cSrcweir DBG_ERRORFILE("something not selectable");
859cdf0e10cSrcweir }
860cdf0e10cSrcweir
861cdf0e10cSrcweir maZOrderedShapes[nChildIndex]->bSelected = sal_False;
862cdf0e10cSrcweir if (maZOrderedShapes[nChildIndex]->pAccShape)
863cdf0e10cSrcweir maZOrderedShapes[nChildIndex]->pAccShape->ResetState(AccessibleStateType::SELECTED);
864cdf0e10cSrcweir }
865cdf0e10cSrcweir }
866cdf0e10cSrcweir }
867cdf0e10cSrcweir
868cdf0e10cSrcweir
GetDrawPage() const869cdf0e10cSrcweir SdrPage* ScChildrenShapes::GetDrawPage() const
870cdf0e10cSrcweir {
871cdf0e10cSrcweir SCTAB nTab(mpAccessibleDocument->getVisibleTable());
872cdf0e10cSrcweir SdrPage* pDrawPage = NULL;
873cdf0e10cSrcweir if (mpViewShell)
874cdf0e10cSrcweir {
875cdf0e10cSrcweir ScDocument* pDoc = mpViewShell->GetViewData()->GetDocument();
876cdf0e10cSrcweir if (pDoc && pDoc->GetDrawLayer())
877cdf0e10cSrcweir {
878cdf0e10cSrcweir ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
879cdf0e10cSrcweir if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab))
880cdf0e10cSrcweir pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(static_cast<sal_Int16>(nTab)));
881cdf0e10cSrcweir }
882cdf0e10cSrcweir }
883cdf0e10cSrcweir return pDrawPage;
884cdf0e10cSrcweir }
885cdf0e10cSrcweir
886cdf0e10cSrcweir struct SetRelation
887cdf0e10cSrcweir {
888cdf0e10cSrcweir const ScChildrenShapes* mpChildrenShapes;
889cdf0e10cSrcweir mutable utl::AccessibleRelationSetHelper* mpRelationSet;
890cdf0e10cSrcweir const ScAddress* mpAddress;
SetRelationSetRelation891cdf0e10cSrcweir SetRelation(const ScChildrenShapes* pChildrenShapes, const ScAddress* pAddress)
892cdf0e10cSrcweir :
893cdf0e10cSrcweir mpChildrenShapes(pChildrenShapes),
894cdf0e10cSrcweir mpRelationSet(NULL),
895cdf0e10cSrcweir mpAddress(pAddress)
896cdf0e10cSrcweir {
897cdf0e10cSrcweir }
operator ()SetRelation898cdf0e10cSrcweir void operator() (const ScAccessibleShapeData* pAccShapeData) const
899cdf0e10cSrcweir {
900cdf0e10cSrcweir if (pAccShapeData &&
901cdf0e10cSrcweir ((!pAccShapeData->pRelationCell && !mpAddress) ||
902cdf0e10cSrcweir (pAccShapeData->pRelationCell && mpAddress && (*(pAccShapeData->pRelationCell) == *mpAddress))))
903cdf0e10cSrcweir {
904cdf0e10cSrcweir if (!mpRelationSet)
905cdf0e10cSrcweir mpRelationSet = new utl::AccessibleRelationSetHelper();
906cdf0e10cSrcweir
907cdf0e10cSrcweir AccessibleRelation aRelation;
908cdf0e10cSrcweir aRelation.TargetSet.realloc(1);
909cdf0e10cSrcweir aRelation.TargetSet[0] = mpChildrenShapes->Get(pAccShapeData);
910cdf0e10cSrcweir aRelation.RelationType = AccessibleRelationType::CONTROLLER_FOR;
911cdf0e10cSrcweir
912cdf0e10cSrcweir mpRelationSet->AddRelation(aRelation);
913cdf0e10cSrcweir }
914cdf0e10cSrcweir }
915cdf0e10cSrcweir };
916cdf0e10cSrcweir
GetRelationSet(const ScAddress * pAddress) const917cdf0e10cSrcweir utl::AccessibleRelationSetHelper* ScChildrenShapes::GetRelationSet(const ScAddress* pAddress) const
918cdf0e10cSrcweir {
919cdf0e10cSrcweir SetRelation aSetRelation(this, pAddress);
920cdf0e10cSrcweir ::std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), aSetRelation);
921cdf0e10cSrcweir return aSetRelation.mpRelationSet;
922cdf0e10cSrcweir }
923cdf0e10cSrcweir
FindSelectedShapesChanges(const uno::Reference<drawing::XShapes> & xShapes,sal_Bool) const924cdf0e10cSrcweir sal_Bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::XShapes>& xShapes, sal_Bool /* bCommitChange */) const
925cdf0e10cSrcweir {
926cdf0e10cSrcweir sal_Bool bResult(sal_False);
927cdf0e10cSrcweir SortedShapes aShapesList;
928cdf0e10cSrcweir uno::Reference<container::XIndexAccess> xIndexAcc(xShapes, uno::UNO_QUERY);
929cdf0e10cSrcweir if (xIndexAcc.is())
930cdf0e10cSrcweir {
931cdf0e10cSrcweir mnShapesSelected = xIndexAcc->getCount();
932cdf0e10cSrcweir for (sal_uInt32 i = 0; i < mnShapesSelected; ++i)
933cdf0e10cSrcweir {
934cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape;
935cdf0e10cSrcweir xIndexAcc->getByIndex(i) >>= xShape;
936cdf0e10cSrcweir if (xShape.is())
937cdf0e10cSrcweir {
938cdf0e10cSrcweir ScAccessibleShapeData* pShapeData = new ScAccessibleShapeData();
939cdf0e10cSrcweir pShapeData->xShape = xShape;
940cdf0e10cSrcweir aShapesList.push_back(pShapeData);
941cdf0e10cSrcweir }
942cdf0e10cSrcweir }
943cdf0e10cSrcweir }
944cdf0e10cSrcweir else
945cdf0e10cSrcweir mnShapesSelected = 0;
9460deba7fbSSteve Yin SdrObject *pFocusedObj = NULL;
9470deba7fbSSteve Yin if( mnShapesSelected == 1 && aShapesList.size() == 1)
9480deba7fbSSteve Yin {
9490deba7fbSSteve Yin pFocusedObj = GetSdrObjectFromXShape(aShapesList[0]->xShape);
9500deba7fbSSteve Yin }
951cdf0e10cSrcweir ScShapeDataLess aLess;
952cdf0e10cSrcweir std::sort(aShapesList.begin(), aShapesList.end(), aLess);
9530deba7fbSSteve Yin SortedShapes vecSelectedShapeAdd;
9540deba7fbSSteve Yin SortedShapes vecSelectedShapeRemove;
9550deba7fbSSteve Yin sal_Bool bHasSelect=sal_False;
956cdf0e10cSrcweir SortedShapes::iterator aXShapesItr(aShapesList.begin());
957cdf0e10cSrcweir SortedShapes::const_iterator aXShapesEndItr(aShapesList.end());
958cdf0e10cSrcweir SortedShapes::iterator aDataItr(maZOrderedShapes.begin());
959cdf0e10cSrcweir SortedShapes::const_iterator aDataEndItr(maZOrderedShapes.end());
960cdf0e10cSrcweir SortedShapes::const_iterator aFocusedItr = aDataEndItr;
961cdf0e10cSrcweir while((aDataItr != aDataEndItr))
962cdf0e10cSrcweir {
963cdf0e10cSrcweir if (*aDataItr) // is it realy a shape or only the sheet
964cdf0e10cSrcweir {
965cdf0e10cSrcweir sal_Int8 nComp(0);
966cdf0e10cSrcweir if (aXShapesItr == aXShapesEndItr)
967cdf0e10cSrcweir nComp = -1; // simulate that the Shape is lower, so the selction state will be removed
968cdf0e10cSrcweir else
969cdf0e10cSrcweir nComp = Compare(*aDataItr, *aXShapesItr);
970cdf0e10cSrcweir if (nComp == 0)
971cdf0e10cSrcweir {
972cdf0e10cSrcweir if (!(*aDataItr)->bSelected)
973cdf0e10cSrcweir {
974cdf0e10cSrcweir (*aDataItr)->bSelected = sal_True;
975cdf0e10cSrcweir if ((*aDataItr)->pAccShape)
976cdf0e10cSrcweir {
977cdf0e10cSrcweir (*aDataItr)->pAccShape->SetState(AccessibleStateType::SELECTED);
978cdf0e10cSrcweir (*aDataItr)->pAccShape->ResetState(AccessibleStateType::FOCUSED);
979cdf0e10cSrcweir bResult = sal_True;
9800deba7fbSSteve Yin vecSelectedShapeAdd.push_back((*aDataItr));
981cdf0e10cSrcweir }
982cdf0e10cSrcweir aFocusedItr = aDataItr;
983cdf0e10cSrcweir }
9840deba7fbSSteve Yin else
9850deba7fbSSteve Yin {
9860deba7fbSSteve Yin bHasSelect = sal_True;
9870deba7fbSSteve Yin }
988cdf0e10cSrcweir ++aDataItr;
989cdf0e10cSrcweir ++aXShapesItr;
990cdf0e10cSrcweir }
991cdf0e10cSrcweir else if (nComp < 0)
992cdf0e10cSrcweir {
993cdf0e10cSrcweir if ((*aDataItr)->bSelected)
994cdf0e10cSrcweir {
995cdf0e10cSrcweir (*aDataItr)->bSelected = sal_False;
996cdf0e10cSrcweir if ((*aDataItr)->pAccShape)
997cdf0e10cSrcweir {
998cdf0e10cSrcweir (*aDataItr)->pAccShape->ResetState(AccessibleStateType::SELECTED);
999cdf0e10cSrcweir (*aDataItr)->pAccShape->ResetState(AccessibleStateType::FOCUSED);
1000cdf0e10cSrcweir bResult = sal_True;
10010deba7fbSSteve Yin vecSelectedShapeRemove.push_back(*aDataItr);
1002cdf0e10cSrcweir }
1003cdf0e10cSrcweir }
1004cdf0e10cSrcweir ++aDataItr;
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir else
1007cdf0e10cSrcweir {
1008cdf0e10cSrcweir DBG_ERRORFILE("here is a selected shape which is not in the childlist");
1009cdf0e10cSrcweir ++aXShapesItr;
1010cdf0e10cSrcweir --mnShapesSelected;
1011cdf0e10cSrcweir }
1012cdf0e10cSrcweir }
1013cdf0e10cSrcweir else
1014cdf0e10cSrcweir ++aDataItr;
1015cdf0e10cSrcweir }
10160deba7fbSSteve Yin bool bWinFocus=false;
10174b4244d8SSteve Yin if (mpViewShell)
10180deba7fbSSteve Yin {
10194b4244d8SSteve Yin ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
10204b4244d8SSteve Yin if (pWin)
10214b4244d8SSteve Yin {
10224b4244d8SSteve Yin bWinFocus = pWin->HasFocus();
10234b4244d8SSteve Yin }
10240deba7fbSSteve Yin }
10250deba7fbSSteve Yin const SdrMarkList* pMarkList = NULL;
10260deba7fbSSteve Yin SdrObject* pMarkedObj = NULL;
10270deba7fbSSteve Yin SdrObject* pUpObj = NULL;
10280deba7fbSSteve Yin sal_Bool bIsFocuseMarked = sal_True;
10290deba7fbSSteve Yin if( mpViewShell && mnShapesSelected == 1 && bWinFocus)
10300deba7fbSSteve Yin {
10310deba7fbSSteve Yin ScDrawView* pScDrawView = mpViewShell->GetViewData()->GetScDrawView();
10320deba7fbSSteve Yin if( pScDrawView )
10330deba7fbSSteve Yin {
10340deba7fbSSteve Yin if( pScDrawView->GetMarkedObjectList().GetMarkCount() == 1 )
10350deba7fbSSteve Yin {
10360deba7fbSSteve Yin pMarkList = &(pScDrawView->GetMarkedObjectList());
10370deba7fbSSteve Yin pMarkedObj = pMarkList->GetMark(0)->GetMarkedSdrObj();
10380deba7fbSSteve Yin uno::Reference< drawing::XShape > xMarkedXShape (pMarkedObj->getUnoShape(), uno::UNO_QUERY);
10390deba7fbSSteve Yin if( aFocusedItr != aDataEndItr &&
10400deba7fbSSteve Yin (*aFocusedItr)->xShape.is() &&
10410deba7fbSSteve Yin xMarkedXShape.is() &&
10420deba7fbSSteve Yin (*aFocusedItr)->xShape != xMarkedXShape )
10430deba7fbSSteve Yin bIsFocuseMarked = sal_False;
10440deba7fbSSteve Yin }
10450deba7fbSSteve Yin }
10460deba7fbSSteve Yin }
10470deba7fbSSteve Yin //if ((aFocusedItr != aDataEndItr) && (*aFocusedItr)->pAccShape && (mnShapesSelected == 1))
10480deba7fbSSteve Yin if ( bIsFocuseMarked && (aFocusedItr != aDataEndItr) && (*aFocusedItr)->pAccShape && (mnShapesSelected == 1) && bWinFocus)
10490deba7fbSSteve Yin {
1050cdf0e10cSrcweir (*aFocusedItr)->pAccShape->SetState(AccessibleStateType::FOCUSED);
10510deba7fbSSteve Yin }
10520deba7fbSSteve Yin else if( pFocusedObj && bWinFocus && pMarkList && pMarkList->GetMarkCount() == 1 && mnShapesSelected == 1 )
10530deba7fbSSteve Yin {
10540deba7fbSSteve Yin if( pMarkedObj )
10550deba7fbSSteve Yin {
10560deba7fbSSteve Yin uno::Reference< drawing::XShape > xMarkedXShape (pMarkedObj->getUnoShape(), uno::UNO_QUERY);
10570deba7fbSSteve Yin pUpObj = pMarkedObj->GetUpGroup();
1058cdf0e10cSrcweir
10590deba7fbSSteve Yin if( pMarkedObj == pFocusedObj )
10600deba7fbSSteve Yin {
10610deba7fbSSteve Yin if( pUpObj )
10620deba7fbSSteve Yin {
10630deba7fbSSteve Yin uno::Reference< drawing::XShape > xUpGroupXShape (pUpObj->getUnoShape(), uno::UNO_QUERY);
10640deba7fbSSteve Yin uno::Reference < XAccessible > xAccGroupShape =
10650deba7fbSSteve Yin const_cast<ScChildrenShapes*>(this)->GetAccessibleCaption( xUpGroupXShape );
10660deba7fbSSteve Yin if( xAccGroupShape.is() )
10670deba7fbSSteve Yin {
10680deba7fbSSteve Yin ::accessibility::AccessibleShape* pAccGroupShape =
10690deba7fbSSteve Yin static_cast< ::accessibility::AccessibleShape* >(xAccGroupShape.get());
10700deba7fbSSteve Yin if( pAccGroupShape )
10710deba7fbSSteve Yin {
10720deba7fbSSteve Yin sal_Int32 nCount = pAccGroupShape->getAccessibleChildCount();
10730deba7fbSSteve Yin for( sal_Int32 i = 0; i < nCount; i++ )
10740deba7fbSSteve Yin {
10750deba7fbSSteve Yin uno::Reference<XAccessible> xAccShape = pAccGroupShape->getAccessibleChild(i);
10760deba7fbSSteve Yin if (xAccShape.is())
10770deba7fbSSteve Yin {
10780deba7fbSSteve Yin ::accessibility::AccessibleShape* pChildAccShape = static_cast< ::accessibility::AccessibleShape* >(xAccShape.get());
10790deba7fbSSteve Yin uno::Reference< drawing::XShape > xChildShape = pChildAccShape->GetXShape();
10800deba7fbSSteve Yin if (xChildShape == xMarkedXShape)
10810deba7fbSSteve Yin {
10820deba7fbSSteve Yin pChildAccShape->SetState(AccessibleStateType::FOCUSED);
10830deba7fbSSteve Yin }
10840deba7fbSSteve Yin else
10850deba7fbSSteve Yin {
10860deba7fbSSteve Yin pChildAccShape->ResetState(AccessibleStateType::FOCUSED);
10870deba7fbSSteve Yin }
10880deba7fbSSteve Yin }
10890deba7fbSSteve Yin }
10900deba7fbSSteve Yin }
10910deba7fbSSteve Yin }
10920deba7fbSSteve Yin }
10930deba7fbSSteve Yin }
10940deba7fbSSteve Yin }
10950deba7fbSSteve Yin }
10960deba7fbSSteve Yin if (vecSelectedShapeAdd.size() >= 10 )
10970deba7fbSSteve Yin {
10980deba7fbSSteve Yin AccessibleEventObject aEvent;
10990deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN;
11000deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(mpAccessibleDocument);
11010deba7fbSSteve Yin mpAccessibleDocument->CommitChange(aEvent);
11020deba7fbSSteve Yin }
11030deba7fbSSteve Yin else
11040deba7fbSSteve Yin {
11050deba7fbSSteve Yin SortedShapes::iterator vi = vecSelectedShapeAdd.begin();
11060deba7fbSSteve Yin for (; vi != vecSelectedShapeAdd.end() ; ++vi )
11070deba7fbSSteve Yin {
11080deba7fbSSteve Yin AccessibleEventObject aEvent;
11090deba7fbSSteve Yin if (bHasSelect)
11100deba7fbSSteve Yin {
11110deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD;
11120deba7fbSSteve Yin }
11130deba7fbSSteve Yin else
11140deba7fbSSteve Yin {
11150deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
11160deba7fbSSteve Yin }
11170deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(mpAccessibleDocument);
11180deba7fbSSteve Yin uno::Reference< XAccessible > xChild( (*vi)->pAccShape);
11190deba7fbSSteve Yin aEvent.NewValue <<= xChild;
11200deba7fbSSteve Yin mpAccessibleDocument->CommitChange(aEvent);
11210deba7fbSSteve Yin }
11220deba7fbSSteve Yin }
11230deba7fbSSteve Yin SortedShapes::iterator vi = vecSelectedShapeRemove.begin();
11240deba7fbSSteve Yin for (; vi != vecSelectedShapeRemove.end() ; ++vi )
11250deba7fbSSteve Yin {
11260deba7fbSSteve Yin AccessibleEventObject aEvent;
11270deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE;
11280deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(mpAccessibleDocument);
11290deba7fbSSteve Yin uno::Reference< XAccessible > xChild( (*vi)->pAccShape);
11300deba7fbSSteve Yin aEvent.NewValue <<= xChild;
11310deba7fbSSteve Yin mpAccessibleDocument->CommitChange(aEvent);
11320deba7fbSSteve Yin }
1133cdf0e10cSrcweir std::for_each(aShapesList.begin(), aShapesList.end(), Destroy());
1134cdf0e10cSrcweir
1135cdf0e10cSrcweir return bResult;
1136cdf0e10cSrcweir }
1137cdf0e10cSrcweir
FillSelectionSupplier() const1138cdf0e10cSrcweir void ScChildrenShapes::FillSelectionSupplier() const
1139cdf0e10cSrcweir {
1140cdf0e10cSrcweir if (!xSelectionSupplier.is() && mpViewShell)
1141cdf0e10cSrcweir {
1142cdf0e10cSrcweir SfxViewFrame* pViewFrame = mpViewShell->GetViewFrame();
1143cdf0e10cSrcweir if (pViewFrame)
1144cdf0e10cSrcweir {
1145cdf0e10cSrcweir xSelectionSupplier = uno::Reference<view::XSelectionSupplier>(pViewFrame->GetFrame().GetController(), uno::UNO_QUERY);
1146cdf0e10cSrcweir if (xSelectionSupplier.is())
1147cdf0e10cSrcweir {
1148cdf0e10cSrcweir if (mpAccessibleDocument)
1149cdf0e10cSrcweir xSelectionSupplier->addSelectionChangeListener(mpAccessibleDocument);
1150cdf0e10cSrcweir uno::Reference<drawing::XShapes> xShapes (xSelectionSupplier->getSelection(), uno::UNO_QUERY);
1151cdf0e10cSrcweir if (xShapes.is())
1152cdf0e10cSrcweir mnShapesSelected = xShapes->getCount();
1153cdf0e10cSrcweir }
1154cdf0e10cSrcweir }
1155cdf0e10cSrcweir }
1156cdf0e10cSrcweir }
1157cdf0e10cSrcweir
GetAnchor(const uno::Reference<drawing::XShape> & xShape) const1158cdf0e10cSrcweir ScAddress* ScChildrenShapes::GetAnchor(const uno::Reference<drawing::XShape>& xShape) const
1159cdf0e10cSrcweir {
1160cdf0e10cSrcweir ScAddress* pAddress = NULL;
1161cdf0e10cSrcweir if (mpViewShell)
1162cdf0e10cSrcweir {
1163cdf0e10cSrcweir SvxShape* pShapeImp = SvxShape::getImplementation(xShape);
1164cdf0e10cSrcweir uno::Reference<beans::XPropertySet> xShapeProp(xShape, uno::UNO_QUERY);
1165cdf0e10cSrcweir if (pShapeImp && xShapeProp.is())
1166cdf0e10cSrcweir {
1167cdf0e10cSrcweir SdrObject *pSdrObj = pShapeImp->GetSdrObject();
1168cdf0e10cSrcweir if (pSdrObj)
1169cdf0e10cSrcweir {
1170cdf0e10cSrcweir if (ScDrawLayer::GetAnchor(pSdrObj) == SCA_CELL)
1171cdf0e10cSrcweir {
1172cdf0e10cSrcweir ScDocument* pDoc = mpViewShell->GetViewData()->GetDocument();
1173cdf0e10cSrcweir if (pDoc)
1174cdf0e10cSrcweir {
1175cdf0e10cSrcweir rtl::OUString sCaptionShape(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape"));
1176cdf0e10cSrcweir awt::Point aPoint(xShape->getPosition());
1177cdf0e10cSrcweir awt::Size aSize(xShape->getSize());
1178cdf0e10cSrcweir rtl::OUString sType(xShape->getShapeType());
1179cdf0e10cSrcweir Rectangle aRectangle(aPoint.X, aPoint.Y, aPoint.X + aSize.Width, aPoint.Y + aSize.Height);
1180cdf0e10cSrcweir if ( sType.equals(sCaptionShape) )
1181cdf0e10cSrcweir {
1182cdf0e10cSrcweir awt::Point aRelativeCaptionPoint;
1183cdf0e10cSrcweir rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" ));
1184cdf0e10cSrcweir xShapeProp->getPropertyValue( sCaptionPoint ) >>= aRelativeCaptionPoint;
1185cdf0e10cSrcweir Point aCoreRelativeCaptionPoint(aRelativeCaptionPoint.X, aRelativeCaptionPoint.Y);
1186cdf0e10cSrcweir Point aCoreAbsoluteCaptionPoint(aPoint.X, aPoint.Y);
1187cdf0e10cSrcweir aCoreAbsoluteCaptionPoint += aCoreRelativeCaptionPoint;
1188cdf0e10cSrcweir aRectangle.Union(Rectangle(aCoreAbsoluteCaptionPoint, aCoreAbsoluteCaptionPoint));
1189cdf0e10cSrcweir }
1190cdf0e10cSrcweir ScRange aRange = pDoc->GetRange(mpAccessibleDocument->getVisibleTable(), aRectangle);
1191cdf0e10cSrcweir pAddress = new ScAddress(aRange.aStart);
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir }
1194cdf0e10cSrcweir // else
1195cdf0e10cSrcweir // do nothing, because it is always a NULL Pointer
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir }
1198cdf0e10cSrcweir }
1199cdf0e10cSrcweir
1200cdf0e10cSrcweir return pAddress;
1201cdf0e10cSrcweir }
1202cdf0e10cSrcweir
GetRelationSet(const ScAccessibleShapeData * pData) const1203cdf0e10cSrcweir uno::Reference<XAccessibleRelationSet> ScChildrenShapes::GetRelationSet(const ScAccessibleShapeData* pData) const
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pRelationSet = new utl::AccessibleRelationSetHelper();
1206cdf0e10cSrcweir
1207cdf0e10cSrcweir if(pData && pRelationSet && mpAccessibleDocument)
1208cdf0e10cSrcweir {
1209cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible = mpAccessibleDocument->GetAccessibleSpreadsheet(); // should be the current table
1210cdf0e10cSrcweir if (pData->pRelationCell && xAccessible.is())
1211cdf0e10cSrcweir {
1212cdf0e10cSrcweir uno::Reference<XAccessibleTable> xAccTable (xAccessible->getAccessibleContext(), uno::UNO_QUERY);
1213cdf0e10cSrcweir if (xAccTable.is())
1214cdf0e10cSrcweir xAccessible = xAccTable->getAccessibleCellAt(pData->pRelationCell->Row(), pData->pRelationCell->Col());
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir AccessibleRelation aRelation;
1217cdf0e10cSrcweir aRelation.TargetSet.realloc(1);
1218cdf0e10cSrcweir aRelation.TargetSet[0] = xAccessible;
1219cdf0e10cSrcweir aRelation.RelationType = AccessibleRelationType::CONTROLLED_BY;
1220cdf0e10cSrcweir pRelationSet->AddRelation(aRelation);
1221cdf0e10cSrcweir }
1222cdf0e10cSrcweir
1223cdf0e10cSrcweir return pRelationSet;
1224cdf0e10cSrcweir }
1225cdf0e10cSrcweir
CheckWhetherAnchorChanged(const uno::Reference<drawing::XShape> & xShape) const1226cdf0e10cSrcweir void ScChildrenShapes::CheckWhetherAnchorChanged(const uno::Reference<drawing::XShape>& xShape) const
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir SortedShapes::iterator aItr;
1229cdf0e10cSrcweir if (FindShape(xShape, aItr))
1230cdf0e10cSrcweir SetAnchor(xShape, *aItr);
1231cdf0e10cSrcweir }
1232cdf0e10cSrcweir
SetAnchor(const uno::Reference<drawing::XShape> & xShape,ScAccessibleShapeData * pData) const1233cdf0e10cSrcweir void ScChildrenShapes::SetAnchor(const uno::Reference<drawing::XShape>& xShape, ScAccessibleShapeData* pData) const
1234cdf0e10cSrcweir {
1235cdf0e10cSrcweir if (pData)
1236cdf0e10cSrcweir {
1237cdf0e10cSrcweir ScAddress* pAddress = GetAnchor(xShape);
1238cdf0e10cSrcweir if ((pAddress && pData->pRelationCell && (*pAddress != *(pData->pRelationCell))) ||
1239cdf0e10cSrcweir (!pAddress && pData->pRelationCell) || (pAddress && !pData->pRelationCell))
1240cdf0e10cSrcweir {
1241cdf0e10cSrcweir if (pData->pRelationCell)
1242cdf0e10cSrcweir delete pData->pRelationCell;
1243cdf0e10cSrcweir pData->pRelationCell = pAddress;
1244cdf0e10cSrcweir if (pData->pAccShape)
1245cdf0e10cSrcweir pData->pAccShape->SetRelationSet(GetRelationSet(pData));
1246cdf0e10cSrcweir }
1247cdf0e10cSrcweir }
1248cdf0e10cSrcweir }
1249cdf0e10cSrcweir
AddShape(const uno::Reference<drawing::XShape> & xShape,sal_Bool bCommitChange) const1250cdf0e10cSrcweir void ScChildrenShapes::AddShape(const uno::Reference<drawing::XShape>& xShape, sal_Bool bCommitChange) const
1251cdf0e10cSrcweir {
1252cdf0e10cSrcweir SortedShapes::iterator aFindItr;
1253cdf0e10cSrcweir if (!FindShape(xShape, aFindItr))
1254cdf0e10cSrcweir {
1255cdf0e10cSrcweir ScAccessibleShapeData* pShape = new ScAccessibleShapeData();
1256cdf0e10cSrcweir pShape->xShape = xShape;
1257cdf0e10cSrcweir SortedShapes::iterator aNewItr = maZOrderedShapes.insert(aFindItr, pShape);
1258cdf0e10cSrcweir SetAnchor(xShape, pShape);
1259cdf0e10cSrcweir
1260cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xShapeProp(xShape, uno::UNO_QUERY);
1261cdf0e10cSrcweir if (xShapeProp.is())
1262cdf0e10cSrcweir {
1263cdf0e10cSrcweir uno::Any aPropAny = xShapeProp->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "LayerID" )));
1264cdf0e10cSrcweir sal_Int16 nLayerID = 0;
1265cdf0e10cSrcweir if( aPropAny >>= nLayerID )
1266cdf0e10cSrcweir {
1267cdf0e10cSrcweir if( (nLayerID == SC_LAYER_INTERN) || (nLayerID == SC_LAYER_HIDDEN) )
1268cdf0e10cSrcweir pShape->bSelectable = sal_False;
1269cdf0e10cSrcweir else
1270cdf0e10cSrcweir pShape->bSelectable = sal_True;
1271cdf0e10cSrcweir }
1272cdf0e10cSrcweir }
1273cdf0e10cSrcweir
1274cdf0e10cSrcweir
1275cdf0e10cSrcweir if (!xSelectionSupplier.is())
1276cdf0e10cSrcweir throw uno::RuntimeException();
1277cdf0e10cSrcweir
1278cdf0e10cSrcweir uno::Reference<container::XEnumerationAccess> xEnumAcc(xSelectionSupplier->getSelection(), uno::UNO_QUERY);
1279cdf0e10cSrcweir if (xEnumAcc.is())
1280cdf0e10cSrcweir {
1281cdf0e10cSrcweir uno::Reference<container::XEnumeration> xEnum = xEnumAcc->createEnumeration();
1282cdf0e10cSrcweir if (xEnum.is())
1283cdf0e10cSrcweir {
1284cdf0e10cSrcweir uno::Reference<drawing::XShape> xSelectedShape;
1285cdf0e10cSrcweir sal_Bool bFound(sal_False);
1286cdf0e10cSrcweir while (!bFound && xEnum->hasMoreElements())
1287cdf0e10cSrcweir {
1288cdf0e10cSrcweir xEnum->nextElement() >>= xSelectedShape;
1289cdf0e10cSrcweir if (xShape.is() && (xShape.get() == xSelectedShape.get()))
1290cdf0e10cSrcweir {
1291cdf0e10cSrcweir pShape->bSelected = sal_True;
1292cdf0e10cSrcweir bFound = sal_True;
1293cdf0e10cSrcweir }
1294cdf0e10cSrcweir }
1295cdf0e10cSrcweir }
1296cdf0e10cSrcweir }
1297cdf0e10cSrcweir if (mpAccessibleDocument && bCommitChange)
1298cdf0e10cSrcweir {
1299cdf0e10cSrcweir AccessibleEventObject aEvent;
1300cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
1301cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument);
1302cdf0e10cSrcweir aEvent.NewValue <<= Get(aNewItr - maZOrderedShapes.begin());
1303cdf0e10cSrcweir
1304cdf0e10cSrcweir mpAccessibleDocument->CommitChange(aEvent); // new child - event
1305cdf0e10cSrcweir }
1306cdf0e10cSrcweir }
1307cdf0e10cSrcweir else
1308cdf0e10cSrcweir {
1309cdf0e10cSrcweir DBG_ERRORFILE("shape is always in the list");
1310cdf0e10cSrcweir }
1311cdf0e10cSrcweir }
1312cdf0e10cSrcweir
RemoveShape(const uno::Reference<drawing::XShape> & xShape) const1313cdf0e10cSrcweir void ScChildrenShapes::RemoveShape(const uno::Reference<drawing::XShape>& xShape) const
1314cdf0e10cSrcweir {
1315cdf0e10cSrcweir SortedShapes::iterator aItr;
1316cdf0e10cSrcweir if (FindShape(xShape, aItr))
1317cdf0e10cSrcweir {
1318cdf0e10cSrcweir if (mpAccessibleDocument)
1319cdf0e10cSrcweir {
1320cdf0e10cSrcweir uno::Reference<XAccessible> xOldAccessible (Get(aItr - maZOrderedShapes.begin()));
1321cdf0e10cSrcweir
1322cdf0e10cSrcweir delete *aItr;
1323cdf0e10cSrcweir maZOrderedShapes.erase(aItr);
1324cdf0e10cSrcweir
1325cdf0e10cSrcweir AccessibleEventObject aEvent;
1326cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
1327cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument);
1328cdf0e10cSrcweir aEvent.OldValue <<= uno::makeAny(xOldAccessible);
1329cdf0e10cSrcweir
1330cdf0e10cSrcweir mpAccessibleDocument->CommitChange(aEvent); // child is gone - event
1331cdf0e10cSrcweir }
1332cdf0e10cSrcweir else
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir delete *aItr;
1335cdf0e10cSrcweir maZOrderedShapes.erase(aItr);
1336cdf0e10cSrcweir }
1337cdf0e10cSrcweir }
1338cdf0e10cSrcweir else
1339cdf0e10cSrcweir {
1340cdf0e10cSrcweir DBG_ERRORFILE("shape was not in internal list");
1341cdf0e10cSrcweir }
1342cdf0e10cSrcweir }
1343cdf0e10cSrcweir
FindShape(const uno::Reference<drawing::XShape> & xShape,ScChildrenShapes::SortedShapes::iterator & rItr) const1344cdf0e10cSrcweir sal_Bool ScChildrenShapes::FindShape(const uno::Reference<drawing::XShape>& xShape, ScChildrenShapes::SortedShapes::iterator& rItr) const
1345cdf0e10cSrcweir {
1346cdf0e10cSrcweir sal_Bool bResult(sal_False);
1347cdf0e10cSrcweir ScAccessibleShapeData aShape;
1348cdf0e10cSrcweir aShape.xShape = xShape;
1349cdf0e10cSrcweir ScShapeDataLess aLess;
1350cdf0e10cSrcweir rItr = std::lower_bound(maZOrderedShapes.begin(), maZOrderedShapes.end(), &aShape, aLess);
1351cdf0e10cSrcweir if ((rItr != maZOrderedShapes.end()) && (*rItr != NULL) && ((*rItr)->xShape.get() == xShape.get()))
1352cdf0e10cSrcweir bResult = sal_True; // if the shape is found
1353cdf0e10cSrcweir
1354cdf0e10cSrcweir #ifdef DBG_UTIL // test whether it finds truly the correct shape (perhaps it is not really sorted)
1355cdf0e10cSrcweir SortedShapes::iterator aDebugItr = maZOrderedShapes.begin();
1356cdf0e10cSrcweir SortedShapes::iterator aEndItr = maZOrderedShapes.end();
1357cdf0e10cSrcweir sal_Bool bFound(sal_False);
1358cdf0e10cSrcweir while (!bFound && aDebugItr != aEndItr)
1359cdf0e10cSrcweir {
1360cdf0e10cSrcweir if (*aDebugItr && ((*aDebugItr)->xShape.get() == xShape.get()))
1361cdf0e10cSrcweir bFound = sal_True;
1362cdf0e10cSrcweir else
1363cdf0e10cSrcweir ++aDebugItr;
1364cdf0e10cSrcweir }
1365cdf0e10cSrcweir sal_Bool bResult2 = (aDebugItr != maZOrderedShapes.end());
1366cdf0e10cSrcweir DBG_ASSERT((bResult == bResult2) && ((bResult && (rItr == aDebugItr)) || !bResult), "wrong Shape found");
1367cdf0e10cSrcweir #endif
1368cdf0e10cSrcweir return bResult;
1369cdf0e10cSrcweir }
1370cdf0e10cSrcweir
Compare(const ScAccessibleShapeData * pData1,const ScAccessibleShapeData * pData2) const1371cdf0e10cSrcweir sal_Int8 ScChildrenShapes::Compare(const ScAccessibleShapeData* pData1,
1372cdf0e10cSrcweir const ScAccessibleShapeData* pData2) const
1373cdf0e10cSrcweir {
1374cdf0e10cSrcweir ScShapeDataLess aLess;
1375cdf0e10cSrcweir
1376cdf0e10cSrcweir sal_Bool bResult1(aLess(pData1, pData2));
1377cdf0e10cSrcweir sal_Bool bResult2(aLess(pData2, pData1));
1378cdf0e10cSrcweir
1379cdf0e10cSrcweir sal_Int8 nResult(0);
1380cdf0e10cSrcweir if (!bResult1 && bResult2)
1381cdf0e10cSrcweir nResult = 1;
1382cdf0e10cSrcweir else if (bResult1 && !bResult2)
1383cdf0e10cSrcweir nResult = -1;
1384cdf0e10cSrcweir
1385cdf0e10cSrcweir return nResult;
1386cdf0e10cSrcweir }
1387cdf0e10cSrcweir
1388cdf0e10cSrcweir struct ScVisAreaChanged
1389cdf0e10cSrcweir {
1390cdf0e10cSrcweir ScAccessibleDocument* mpAccDoc;
ScVisAreaChangedScVisAreaChanged1391cdf0e10cSrcweir ScVisAreaChanged(ScAccessibleDocument* pAccDoc) : mpAccDoc(pAccDoc) {}
operator ()ScVisAreaChanged1392cdf0e10cSrcweir void operator() (const ScAccessibleShapeData* pAccShapeData) const
1393cdf0e10cSrcweir {
1394cdf0e10cSrcweir if (pAccShapeData && pAccShapeData->pAccShape)
1395cdf0e10cSrcweir {
1396cdf0e10cSrcweir pAccShapeData->pAccShape->ViewForwarderChanged(::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA, mpAccDoc);
1397cdf0e10cSrcweir }
1398cdf0e10cSrcweir }
1399cdf0e10cSrcweir };
1400cdf0e10cSrcweir
VisAreaChanged() const1401cdf0e10cSrcweir void ScChildrenShapes::VisAreaChanged() const
1402cdf0e10cSrcweir {
1403cdf0e10cSrcweir ScVisAreaChanged aVisAreaChanged(mpAccessibleDocument);
1404cdf0e10cSrcweir std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), aVisAreaChanged);
1405cdf0e10cSrcweir }
1406cdf0e10cSrcweir
1407cdf0e10cSrcweir // ============================================================================
1408cdf0e10cSrcweir
ScAccessibleDocument(const uno::Reference<XAccessible> & rxParent,ScTabViewShell * pViewShell,ScSplitPos eSplitPos)1409cdf0e10cSrcweir ScAccessibleDocument::ScAccessibleDocument(
1410cdf0e10cSrcweir const uno::Reference<XAccessible>& rxParent,
1411cdf0e10cSrcweir ScTabViewShell* pViewShell,
1412cdf0e10cSrcweir ScSplitPos eSplitPos)
1413cdf0e10cSrcweir : ScAccessibleDocumentBase(rxParent),
1414cdf0e10cSrcweir mpViewShell(pViewShell),
1415cdf0e10cSrcweir meSplitPos(eSplitPos),
1416cdf0e10cSrcweir mpAccessibleSpreadsheet(NULL),
1417cdf0e10cSrcweir mpChildrenShapes(NULL),
1418cdf0e10cSrcweir mpTempAccEdit(NULL),
1419cdf0e10cSrcweir mbCompleteSheetSelected(sal_False)
1420cdf0e10cSrcweir {
1421cdf0e10cSrcweir if (pViewShell)
1422cdf0e10cSrcweir {
1423cdf0e10cSrcweir pViewShell->AddAccessibilityObject(*this);
1424cdf0e10cSrcweir Window *pWin = pViewShell->GetWindowByPos(eSplitPos);
1425cdf0e10cSrcweir if( pWin )
1426cdf0e10cSrcweir {
1427cdf0e10cSrcweir pWin->AddChildEventListener( LINK( this, ScAccessibleDocument, WindowChildEventListener ));
1428cdf0e10cSrcweir sal_uInt16 nCount = pWin->GetChildCount();
1429cdf0e10cSrcweir for( sal_uInt16 i=0; i < nCount; ++i )
1430cdf0e10cSrcweir {
1431cdf0e10cSrcweir Window *pChildWin = pWin->GetChild( i );
1432cdf0e10cSrcweir if( pChildWin &&
1433cdf0e10cSrcweir AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
1434cdf0e10cSrcweir AddChild( pChildWin->GetAccessible(), sal_False );
1435cdf0e10cSrcweir }
1436cdf0e10cSrcweir }
1437cdf0e10cSrcweir if (pViewShell->GetViewData()->HasEditView( eSplitPos ))
1438cdf0e10cSrcweir {
1439cdf0e10cSrcweir uno::Reference<XAccessible> xAcc = new ScAccessibleEditObject(this, pViewShell->GetViewData()->GetEditView(eSplitPos),
1440cdf0e10cSrcweir pViewShell->GetWindowByPos(eSplitPos), GetCurrentCellName(), GetCurrentCellDescription(),
1441cdf0e10cSrcweir CellInEditMode);
1442cdf0e10cSrcweir AddChild(xAcc, sal_False);
1443cdf0e10cSrcweir }
1444cdf0e10cSrcweir }
1445cdf0e10cSrcweir maVisArea = GetVisibleArea_Impl();
1446cdf0e10cSrcweir }
1447cdf0e10cSrcweir
Init()1448cdf0e10cSrcweir void ScAccessibleDocument::Init()
1449cdf0e10cSrcweir {
1450cdf0e10cSrcweir if(!mpChildrenShapes)
1451cdf0e10cSrcweir mpChildrenShapes = new ScChildrenShapes(this, mpViewShell, meSplitPos);
1452cdf0e10cSrcweir }
1453cdf0e10cSrcweir
~ScAccessibleDocument(void)1454cdf0e10cSrcweir ScAccessibleDocument::~ScAccessibleDocument(void)
1455cdf0e10cSrcweir {
1456cdf0e10cSrcweir if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose)
1457cdf0e10cSrcweir {
1458cdf0e10cSrcweir // increment refcount to prevent double call off dtor
1459cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount );
1460cdf0e10cSrcweir dispose();
1461cdf0e10cSrcweir }
1462cdf0e10cSrcweir }
1463cdf0e10cSrcweir
disposing()1464cdf0e10cSrcweir void SAL_CALL ScAccessibleDocument::disposing()
1465cdf0e10cSrcweir {
1466cdf0e10cSrcweir ScUnoGuard aGuard;
1467cdf0e10cSrcweir FreeAccessibleSpreadsheet();
1468cdf0e10cSrcweir if (mpViewShell)
1469cdf0e10cSrcweir {
1470cdf0e10cSrcweir Window *pWin = mpViewShell->GetWindowByPos(meSplitPos);
1471cdf0e10cSrcweir if( pWin )
1472cdf0e10cSrcweir pWin->RemoveChildEventListener( LINK( this, ScAccessibleDocument, WindowChildEventListener ));
1473cdf0e10cSrcweir
1474cdf0e10cSrcweir mpViewShell->RemoveAccessibilityObject(*this);
1475cdf0e10cSrcweir mpViewShell = NULL;
1476cdf0e10cSrcweir }
1477cdf0e10cSrcweir if (mpChildrenShapes)
1478cdf0e10cSrcweir DELETEZ(mpChildrenShapes);
1479cdf0e10cSrcweir
1480cdf0e10cSrcweir ScAccessibleDocumentBase::disposing();
1481cdf0e10cSrcweir }
1482cdf0e10cSrcweir
disposing(const lang::EventObject &)1483cdf0e10cSrcweir void SAL_CALL ScAccessibleDocument::disposing( const lang::EventObject& /* Source */ )
1484cdf0e10cSrcweir throw (uno::RuntimeException)
1485cdf0e10cSrcweir {
1486cdf0e10cSrcweir disposing();
1487cdf0e10cSrcweir }
1488cdf0e10cSrcweir
1489cdf0e10cSrcweir //===== SfxListener =====================================================
1490cdf0e10cSrcweir
IMPL_LINK(ScAccessibleDocument,WindowChildEventListener,VclSimpleEvent *,pEvent)1491cdf0e10cSrcweir IMPL_LINK( ScAccessibleDocument, WindowChildEventListener, VclSimpleEvent*, pEvent )
1492cdf0e10cSrcweir {
1493cdf0e10cSrcweir DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
1494cdf0e10cSrcweir if ( pEvent && pEvent->ISA( VclWindowEvent ) )
1495cdf0e10cSrcweir {
1496cdf0e10cSrcweir VclWindowEvent *pVclEvent = static_cast< VclWindowEvent * >( pEvent );
1497cdf0e10cSrcweir DBG_ASSERT( pVclEvent->GetWindow(), "Window???" );
1498cdf0e10cSrcweir switch ( pVclEvent->GetId() )
1499cdf0e10cSrcweir {
1500cdf0e10cSrcweir case VCLEVENT_WINDOW_SHOW: // send create on show for direct accessible children
1501cdf0e10cSrcweir {
1502cdf0e10cSrcweir Window* pChildWin = static_cast < Window * >( pVclEvent->GetData() );
1503cdf0e10cSrcweir if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
1504cdf0e10cSrcweir {
1505cdf0e10cSrcweir AddChild( pChildWin->GetAccessible(), sal_True );
1506cdf0e10cSrcweir }
1507cdf0e10cSrcweir }
1508cdf0e10cSrcweir break;
1509cdf0e10cSrcweir case VCLEVENT_WINDOW_HIDE: // send destroy on hide for direct accessible children
1510cdf0e10cSrcweir {
1511cdf0e10cSrcweir Window* pChildWin = static_cast < Window * >( pVclEvent->GetData() );
1512cdf0e10cSrcweir if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
1513cdf0e10cSrcweir {
1514cdf0e10cSrcweir RemoveChild( pChildWin->GetAccessible(), sal_True );
1515cdf0e10cSrcweir }
1516cdf0e10cSrcweir }
1517cdf0e10cSrcweir break;
1518cdf0e10cSrcweir }
1519cdf0e10cSrcweir }
1520cdf0e10cSrcweir return 0;
1521cdf0e10cSrcweir }
1522cdf0e10cSrcweir
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)1523cdf0e10cSrcweir void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1524cdf0e10cSrcweir {
1525cdf0e10cSrcweir if (rHint.ISA( ScAccGridWinFocusLostHint ) )
1526cdf0e10cSrcweir {
1527cdf0e10cSrcweir const ScAccGridWinFocusLostHint& rRef = (const ScAccGridWinFocusLostHint&)rHint;
1528cdf0e10cSrcweir if (rRef.GetOldGridWin() == meSplitPos)
1529cdf0e10cSrcweir {
1530cdf0e10cSrcweir if (mxTempAcc.is() && mpTempAccEdit)
1531cdf0e10cSrcweir mpTempAccEdit->LostFocus();
1532cdf0e10cSrcweir else if (mpAccessibleSpreadsheet)
1533cdf0e10cSrcweir mpAccessibleSpreadsheet->LostFocus();
1534cdf0e10cSrcweir else
1535cdf0e10cSrcweir CommitFocusLost();
1536cdf0e10cSrcweir }
1537cdf0e10cSrcweir }
1538cdf0e10cSrcweir else if (rHint.ISA( ScAccGridWinFocusGotHint ) )
1539cdf0e10cSrcweir {
1540cdf0e10cSrcweir const ScAccGridWinFocusGotHint& rRef = (const ScAccGridWinFocusGotHint&)rHint;
1541cdf0e10cSrcweir if (rRef.GetNewGridWin() == meSplitPos)
1542cdf0e10cSrcweir {
15430deba7fbSSteve Yin uno::Reference<XAccessible> xAccessible;
15440deba7fbSSteve Yin if (mpChildrenShapes)
15450deba7fbSSteve Yin {
15460deba7fbSSteve Yin sal_Bool bTabMarked(IsTableSelected());
15470deba7fbSSteve Yin xAccessible = mpChildrenShapes->GetSelected(0, bTabMarked);
15480deba7fbSSteve Yin }
15490deba7fbSSteve Yin if( xAccessible.is() )
15500deba7fbSSteve Yin {
15510deba7fbSSteve Yin uno::Any aNewValue;
15520deba7fbSSteve Yin aNewValue<<=AccessibleStateType::FOCUSED;
15530deba7fbSSteve Yin static_cast< ::accessibility::AccessibleShape* >(xAccessible.get())->
15540deba7fbSSteve Yin CommitChange(AccessibleEventId::STATE_CHANGED,
15550deba7fbSSteve Yin aNewValue,
15560deba7fbSSteve Yin uno::Any() );
15570deba7fbSSteve Yin }
15580deba7fbSSteve Yin else
15590deba7fbSSteve Yin {
1560cdf0e10cSrcweir if (mxTempAcc.is() && mpTempAccEdit)
1561cdf0e10cSrcweir mpTempAccEdit->GotFocus();
1562cdf0e10cSrcweir else if (mpAccessibleSpreadsheet)
1563cdf0e10cSrcweir mpAccessibleSpreadsheet->GotFocus();
1564cdf0e10cSrcweir else
1565cdf0e10cSrcweir CommitFocusGained();
15660deba7fbSSteve Yin }
1567cdf0e10cSrcweir }
1568cdf0e10cSrcweir }
1569cdf0e10cSrcweir else if (rHint.ISA( SfxSimpleHint ))
1570cdf0e10cSrcweir {
1571cdf0e10cSrcweir const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
1572cdf0e10cSrcweir // only notify if child exist, otherwise it is not necessary
1573cdf0e10cSrcweir if ((rRef.GetId() == SC_HINT_ACC_TABLECHANGED) &&
1574cdf0e10cSrcweir mpAccessibleSpreadsheet)
1575cdf0e10cSrcweir {
1576cdf0e10cSrcweir FreeAccessibleSpreadsheet();
1577cdf0e10cSrcweir if (mpChildrenShapes)
1578cdf0e10cSrcweir DELETEZ(mpChildrenShapes);
1579cdf0e10cSrcweir
1580cdf0e10cSrcweir // #124567# Accessibility: Shapes / form controls after reload not accessible
1581cdf0e10cSrcweir if ( !mpChildrenShapes )
1582cdf0e10cSrcweir {
1583cdf0e10cSrcweir mpChildrenShapes = new ScChildrenShapes( this, mpViewShell, meSplitPos );
1584cdf0e10cSrcweir }
15850deba7fbSSteve Yin //Invoke Init() to rebuild the mpChildrenShapes variable
15860deba7fbSSteve Yin this->Init();
1587cdf0e10cSrcweir AccessibleEventObject aEvent;
1588cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::INVALIDATE_ALL_CHILDREN;
1589cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this);
1590cdf0e10cSrcweir CommitChange(aEvent); // all childs changed
15910deba7fbSSteve Yin if (mpAccessibleSpreadsheet)
15920deba7fbSSteve Yin mpAccessibleSpreadsheet->FireFirstCellFocus();
1593cdf0e10cSrcweir }
1594cdf0e10cSrcweir else if (rRef.GetId() == SC_HINT_ACC_MAKEDRAWLAYER)
1595cdf0e10cSrcweir {
1596cdf0e10cSrcweir if (mpChildrenShapes)
1597cdf0e10cSrcweir mpChildrenShapes->SetDrawBroadcaster();
1598cdf0e10cSrcweir }
1599cdf0e10cSrcweir else if ((rRef.GetId() == SC_HINT_ACC_ENTEREDITMODE)) // this event comes only on creating edit field of a cell
1600cdf0e10cSrcweir {
1601cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData()->HasEditView(meSplitPos))
1602cdf0e10cSrcweir {
16030deba7fbSSteve Yin EditEngine* pEditEng = mpViewShell->GetViewData()->GetEditView(meSplitPos)->GetEditEngine();
16040deba7fbSSteve Yin if (pEditEng && pEditEng->GetUpdateMode())
16050deba7fbSSteve Yin {
16060deba7fbSSteve Yin mpTempAccEdit = new ScAccessibleEditObject(this, mpViewShell->GetViewData()->GetEditView(meSplitPos),
16070deba7fbSSteve Yin mpViewShell->GetWindowByPos(meSplitPos), GetCurrentCellName(),
16080deba7fbSSteve Yin rtl::OUString(String(ScResId(STR_ACC_EDITLINE_DESCR))), CellInEditMode);
16090deba7fbSSteve Yin uno::Reference<XAccessible> xAcc = mpTempAccEdit;
1610cdf0e10cSrcweir
16110deba7fbSSteve Yin AddChild(xAcc, sal_True);
1612cdf0e10cSrcweir
16130deba7fbSSteve Yin if (mpAccessibleSpreadsheet)
16140deba7fbSSteve Yin mpAccessibleSpreadsheet->LostFocus();
16150deba7fbSSteve Yin else
16160deba7fbSSteve Yin CommitFocusLost();
1617cdf0e10cSrcweir
16180deba7fbSSteve Yin mpTempAccEdit->GotFocus();
16190deba7fbSSteve Yin }
1620cdf0e10cSrcweir }
1621cdf0e10cSrcweir }
1622cdf0e10cSrcweir else if (rRef.GetId() == SC_HINT_ACC_LEAVEEDITMODE)
1623cdf0e10cSrcweir {
1624cdf0e10cSrcweir if (mxTempAcc.is())
1625cdf0e10cSrcweir {
1626cdf0e10cSrcweir if (mpTempAccEdit)
1627cdf0e10cSrcweir mpTempAccEdit->LostFocus();
1628cdf0e10cSrcweir
1629cdf0e10cSrcweir mpTempAccEdit = NULL;
1630cdf0e10cSrcweir RemoveChild(mxTempAcc, sal_True);
16310deba7fbSSteve Yin if (mpAccessibleSpreadsheet && mpViewShell->IsActive())
1632cdf0e10cSrcweir mpAccessibleSpreadsheet->GotFocus();
16330deba7fbSSteve Yin else if( mpViewShell->IsActive())
1634cdf0e10cSrcweir CommitFocusGained();
1635cdf0e10cSrcweir }
1636cdf0e10cSrcweir }
1637cdf0e10cSrcweir else if ((rRef.GetId() == SC_HINT_ACC_VISAREACHANGED) || (rRef.GetId() == SC_HINT_ACC_WINDOWRESIZED))
1638cdf0e10cSrcweir {
1639cdf0e10cSrcweir Rectangle aOldVisArea(maVisArea);
1640cdf0e10cSrcweir maVisArea = GetVisibleArea_Impl();
1641cdf0e10cSrcweir
1642cdf0e10cSrcweir if (maVisArea != aOldVisArea)
1643cdf0e10cSrcweir {
1644cdf0e10cSrcweir if (maVisArea.GetSize() != aOldVisArea.GetSize())
1645cdf0e10cSrcweir {
1646cdf0e10cSrcweir AccessibleEventObject aEvent;
1647cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED;
1648cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this);
1649cdf0e10cSrcweir
1650cdf0e10cSrcweir CommitChange(aEvent);
1651cdf0e10cSrcweir
1652cdf0e10cSrcweir if (mpAccessibleSpreadsheet)
1653cdf0e10cSrcweir mpAccessibleSpreadsheet->BoundingBoxChanged();
1654cdf0e10cSrcweir }
1655cdf0e10cSrcweir else if (mpAccessibleSpreadsheet)
1656cdf0e10cSrcweir {
1657cdf0e10cSrcweir mpAccessibleSpreadsheet->VisAreaChanged();
1658cdf0e10cSrcweir }
1659cdf0e10cSrcweir if (mpChildrenShapes)
1660cdf0e10cSrcweir mpChildrenShapes->VisAreaChanged();
1661cdf0e10cSrcweir }
1662cdf0e10cSrcweir }
1663cdf0e10cSrcweir }
1664cdf0e10cSrcweir
1665cdf0e10cSrcweir ScAccessibleDocumentBase::Notify(rBC, rHint);
1666cdf0e10cSrcweir }
1667cdf0e10cSrcweir
selectionChanged(const lang::EventObject &)1668cdf0e10cSrcweir void SAL_CALL ScAccessibleDocument::selectionChanged( const lang::EventObject& /* aEvent */ )
1669cdf0e10cSrcweir throw (uno::RuntimeException)
1670cdf0e10cSrcweir {
1671cdf0e10cSrcweir sal_Bool bSelectionChanged(sal_False);
1672cdf0e10cSrcweir if (mpAccessibleSpreadsheet)
1673cdf0e10cSrcweir {
1674cdf0e10cSrcweir sal_Bool bOldSelected(mbCompleteSheetSelected);
1675cdf0e10cSrcweir mbCompleteSheetSelected = IsTableSelected();
1676cdf0e10cSrcweir if (bOldSelected != mbCompleteSheetSelected)
1677cdf0e10cSrcweir {
1678cdf0e10cSrcweir mpAccessibleSpreadsheet->CompleteSelectionChanged(mbCompleteSheetSelected);
1679cdf0e10cSrcweir bSelectionChanged = sal_True;
1680cdf0e10cSrcweir }
1681cdf0e10cSrcweir }
1682cdf0e10cSrcweir
1683cdf0e10cSrcweir if (mpChildrenShapes && mpChildrenShapes->SelectionChanged())
1684cdf0e10cSrcweir bSelectionChanged = sal_True;
1685cdf0e10cSrcweir
1686cdf0e10cSrcweir if (bSelectionChanged)
1687cdf0e10cSrcweir {
1688cdf0e10cSrcweir AccessibleEventObject aEvent;
1689cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
1690cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this);
1691cdf0e10cSrcweir
1692cdf0e10cSrcweir CommitChange(aEvent);
1693cdf0e10cSrcweir }
16940deba7fbSSteve Yin if(mpChildrenShapes )
16950deba7fbSSteve Yin {
16960deba7fbSSteve Yin mpChildrenShapes->SelectionChanged();
16970deba7fbSSteve Yin }
1698cdf0e10cSrcweir }
1699cdf0e10cSrcweir
1700cdf0e10cSrcweir //===== XInterface =====================================================
1701cdf0e10cSrcweir
queryInterface(uno::Type const & rType)1702cdf0e10cSrcweir uno::Any SAL_CALL ScAccessibleDocument::queryInterface( uno::Type const & rType )
1703cdf0e10cSrcweir throw (uno::RuntimeException)
1704cdf0e10cSrcweir {
17050deba7fbSSteve Yin uno::Any aAnyTmp;
17060deba7fbSSteve Yin if(rType == ::getCppuType((com::sun::star::uno::Reference<XAccessibleGetAccFlowTo> *)NULL) )
17070deba7fbSSteve Yin {
17080deba7fbSSteve Yin com::sun::star::uno::Reference<XAccessibleGetAccFlowTo> AccFromXShape = this;
17090deba7fbSSteve Yin aAnyTmp <<= AccFromXShape;
17100deba7fbSSteve Yin return aAnyTmp;
17110deba7fbSSteve Yin }
1712cdf0e10cSrcweir uno::Any aAny (ScAccessibleDocumentImpl::queryInterface(rType));
1713cdf0e10cSrcweir return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType);
1714cdf0e10cSrcweir }
1715cdf0e10cSrcweir
acquire()1716cdf0e10cSrcweir void SAL_CALL ScAccessibleDocument::acquire()
1717cdf0e10cSrcweir throw ()
1718cdf0e10cSrcweir {
1719cdf0e10cSrcweir ScAccessibleContextBase::acquire();
1720cdf0e10cSrcweir }
1721cdf0e10cSrcweir
release()1722cdf0e10cSrcweir void SAL_CALL ScAccessibleDocument::release()
1723cdf0e10cSrcweir throw ()
1724cdf0e10cSrcweir {
1725cdf0e10cSrcweir ScAccessibleContextBase::release();
1726cdf0e10cSrcweir }
1727cdf0e10cSrcweir
1728cdf0e10cSrcweir //===== XAccessibleComponent ============================================
1729cdf0e10cSrcweir
getAccessibleAtPoint(const awt::Point & rPoint)1730cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleDocument::getAccessibleAtPoint(
1731cdf0e10cSrcweir const awt::Point& rPoint )
1732cdf0e10cSrcweir throw (uno::RuntimeException)
1733cdf0e10cSrcweir {
1734cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible = NULL;
1735cdf0e10cSrcweir if (containsPoint(rPoint))
1736cdf0e10cSrcweir {
1737cdf0e10cSrcweir ScUnoGuard aGuard;
1738cdf0e10cSrcweir IsObjectValid();
1739cdf0e10cSrcweir if (mpChildrenShapes)
1740cdf0e10cSrcweir xAccessible = mpChildrenShapes->GetAt(rPoint);
1741cdf0e10cSrcweir if(!xAccessible.is())
1742cdf0e10cSrcweir {
1743cdf0e10cSrcweir if (mxTempAcc.is())
1744cdf0e10cSrcweir {
1745cdf0e10cSrcweir uno::Reference< XAccessibleContext > xCont(mxTempAcc->getAccessibleContext());
1746cdf0e10cSrcweir uno::Reference< XAccessibleComponent > xComp(xCont, uno::UNO_QUERY);
1747cdf0e10cSrcweir if (xComp.is())
1748cdf0e10cSrcweir {
1749cdf0e10cSrcweir Rectangle aBound(VCLRectangle(xComp->getBounds()));
1750cdf0e10cSrcweir if (aBound.IsInside(VCLPoint(rPoint)))
1751cdf0e10cSrcweir xAccessible = mxTempAcc;
1752cdf0e10cSrcweir }
1753cdf0e10cSrcweir }
1754cdf0e10cSrcweir if (!xAccessible.is())
1755cdf0e10cSrcweir xAccessible = GetAccessibleSpreadsheet();
1756cdf0e10cSrcweir }
1757cdf0e10cSrcweir }
1758cdf0e10cSrcweir return xAccessible;
1759cdf0e10cSrcweir }
1760cdf0e10cSrcweir
grabFocus()1761cdf0e10cSrcweir void SAL_CALL ScAccessibleDocument::grabFocus( )
1762cdf0e10cSrcweir throw (uno::RuntimeException)
1763cdf0e10cSrcweir {
1764cdf0e10cSrcweir ScUnoGuard aGuard;
1765cdf0e10cSrcweir IsObjectValid();
1766cdf0e10cSrcweir if (getAccessibleParent().is())
1767cdf0e10cSrcweir {
1768cdf0e10cSrcweir uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
1769cdf0e10cSrcweir if (xAccessibleComponent.is())
1770cdf0e10cSrcweir {
1771cdf0e10cSrcweir xAccessibleComponent->grabFocus();
1772cdf0e10cSrcweir // grab only focus if it does not have the focus and it is not hidden
1773cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData() &&
1774cdf0e10cSrcweir (mpViewShell->GetViewData()->GetActivePart() != meSplitPos) &&
1775cdf0e10cSrcweir mpViewShell->GetWindowByPos(meSplitPos)->IsVisible())
1776cdf0e10cSrcweir {
1777cdf0e10cSrcweir mpViewShell->ActivatePart(meSplitPos);
1778cdf0e10cSrcweir }
1779cdf0e10cSrcweir }
1780cdf0e10cSrcweir }
1781cdf0e10cSrcweir }
1782cdf0e10cSrcweir
1783cdf0e10cSrcweir //===== XAccessibleContext ==============================================
1784cdf0e10cSrcweir
1785cdf0e10cSrcweir /// Return the number of currently visible children.
1786cdf0e10cSrcweir sal_Int32 SAL_CALL
getAccessibleChildCount(void)1787cdf0e10cSrcweir ScAccessibleDocument::getAccessibleChildCount(void)
1788cdf0e10cSrcweir throw (uno::RuntimeException)
1789cdf0e10cSrcweir {
1790cdf0e10cSrcweir ScUnoGuard aGuard;
1791cdf0e10cSrcweir IsObjectValid();
1792cdf0e10cSrcweir sal_Int32 nCount(1);
1793cdf0e10cSrcweir if (mpChildrenShapes)
1794cdf0e10cSrcweir nCount = mpChildrenShapes->GetCount(); // returns the count of the shapes inclusive the table
1795cdf0e10cSrcweir
1796cdf0e10cSrcweir if (mxTempAcc.is())
1797cdf0e10cSrcweir ++nCount;
1798cdf0e10cSrcweir
1799cdf0e10cSrcweir return nCount;
1800cdf0e10cSrcweir }
1801cdf0e10cSrcweir
1802cdf0e10cSrcweir /// Return the specified child or NULL if index is invalid.
1803cdf0e10cSrcweir uno::Reference<XAccessible> SAL_CALL
getAccessibleChild(sal_Int32 nIndex)1804cdf0e10cSrcweir ScAccessibleDocument::getAccessibleChild(sal_Int32 nIndex)
1805cdf0e10cSrcweir throw (uno::RuntimeException,
1806cdf0e10cSrcweir lang::IndexOutOfBoundsException)
1807cdf0e10cSrcweir {
1808cdf0e10cSrcweir ScUnoGuard aGuard;
1809cdf0e10cSrcweir IsObjectValid();
1810cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible;
1811cdf0e10cSrcweir if (nIndex >= 0)
1812cdf0e10cSrcweir {
1813cdf0e10cSrcweir sal_Int32 nCount(1);
1814cdf0e10cSrcweir if (mpChildrenShapes)
1815cdf0e10cSrcweir {
1816cdf0e10cSrcweir xAccessible = mpChildrenShapes->Get(nIndex); // returns NULL if it is the table or out of range
1817cdf0e10cSrcweir nCount = mpChildrenShapes->GetCount(); //there is always a table
1818cdf0e10cSrcweir }
1819cdf0e10cSrcweir if (!xAccessible.is())
1820cdf0e10cSrcweir {
1821cdf0e10cSrcweir if (nIndex < nCount)
1822cdf0e10cSrcweir xAccessible = GetAccessibleSpreadsheet();
1823cdf0e10cSrcweir else if (nIndex == nCount && mxTempAcc.is())
1824cdf0e10cSrcweir xAccessible = mxTempAcc;
1825cdf0e10cSrcweir }
1826cdf0e10cSrcweir }
1827cdf0e10cSrcweir
1828cdf0e10cSrcweir if (!xAccessible.is())
1829cdf0e10cSrcweir throw lang::IndexOutOfBoundsException();
1830cdf0e10cSrcweir
1831cdf0e10cSrcweir return xAccessible;
1832cdf0e10cSrcweir }
1833cdf0e10cSrcweir
1834cdf0e10cSrcweir /// Return the set of current states.
1835cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL
getAccessibleStateSet(void)1836cdf0e10cSrcweir ScAccessibleDocument::getAccessibleStateSet(void)
1837cdf0e10cSrcweir throw (uno::RuntimeException)
1838cdf0e10cSrcweir {
1839cdf0e10cSrcweir ScUnoGuard aGuard;
1840cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> xParentStates;
1841cdf0e10cSrcweir if (getAccessibleParent().is())
1842cdf0e10cSrcweir {
1843cdf0e10cSrcweir uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
1844cdf0e10cSrcweir xParentStates = xParentContext->getAccessibleStateSet();
1845cdf0e10cSrcweir }
1846cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
1847cdf0e10cSrcweir if (IsDefunc(xParentStates))
1848cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::DEFUNC);
1849cdf0e10cSrcweir else
1850cdf0e10cSrcweir {
1851cdf0e10cSrcweir if (IsEditable(xParentStates))
1852cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::EDITABLE);
1853cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::ENABLED);
1854cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::OPAQUE);
1855cdf0e10cSrcweir if (isShowing())
1856cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SHOWING);
1857cdf0e10cSrcweir if (isVisible())
1858cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::VISIBLE);
1859cdf0e10cSrcweir }
1860cdf0e10cSrcweir return pStateSet;
1861cdf0e10cSrcweir }
1862cdf0e10cSrcweir
18630deba7fbSSteve Yin ::rtl::OUString SAL_CALL
getAccessibleName(void)18640deba7fbSSteve Yin ScAccessibleDocument::getAccessibleName(void)
18650deba7fbSSteve Yin throw (::com::sun::star::uno::RuntimeException)
18660deba7fbSSteve Yin {
18670deba7fbSSteve Yin rtl::OUString sName = String(ScResId(STR_ACC_DOC_SPREADSHEET));
18680deba7fbSSteve Yin ScDocument* pScDoc = GetDocument();
18690deba7fbSSteve Yin if ( pScDoc )
18700deba7fbSSteve Yin {
18710deba7fbSSteve Yin rtl::OUString sFileName = pScDoc->getDocAccTitle();
18720deba7fbSSteve Yin if ( !sFileName.getLength() )
18730deba7fbSSteve Yin {
18740deba7fbSSteve Yin SfxObjectShell* pObjSh = pScDoc->GetDocumentShell();
18750deba7fbSSteve Yin if ( pObjSh )
18760deba7fbSSteve Yin {
18770deba7fbSSteve Yin sFileName = pObjSh->GetTitle( SFX_TITLE_APINAME );
18780deba7fbSSteve Yin }
18790deba7fbSSteve Yin }
18800deba7fbSSteve Yin rtl::OUString sReadOnly;
18810deba7fbSSteve Yin if (pScDoc->getDocReadOnly())
18820deba7fbSSteve Yin {
18830deba7fbSSteve Yin sReadOnly = String(ScResId(STR_ACC_DOC_SPREADSHEET_READONLY));
18840deba7fbSSteve Yin }
18850deba7fbSSteve Yin if ( sFileName.getLength() )
18860deba7fbSSteve Yin {
18870deba7fbSSteve Yin sName = sFileName + sReadOnly + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" - ")) + sName;
18880deba7fbSSteve Yin }
18890deba7fbSSteve Yin }
18900deba7fbSSteve Yin return sName;
18910deba7fbSSteve Yin }
1892cdf0e10cSrcweir ///===== XAccessibleSelection ===========================================
1893cdf0e10cSrcweir
1894cdf0e10cSrcweir void SAL_CALL
selectAccessibleChild(sal_Int32 nChildIndex)1895cdf0e10cSrcweir ScAccessibleDocument::selectAccessibleChild( sal_Int32 nChildIndex )
1896cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1897cdf0e10cSrcweir {
1898cdf0e10cSrcweir ScUnoGuard aGuard;
1899cdf0e10cSrcweir IsObjectValid();
1900cdf0e10cSrcweir
1901cdf0e10cSrcweir if (mpChildrenShapes)
1902cdf0e10cSrcweir {
1903cdf0e10cSrcweir sal_Int32 nCount(mpChildrenShapes->GetCount()); //all shapes and the table
1904cdf0e10cSrcweir if (mxTempAcc.is())
1905cdf0e10cSrcweir ++nCount;
1906cdf0e10cSrcweir if (nChildIndex < 0 || nChildIndex >= nCount)
1907cdf0e10cSrcweir throw lang::IndexOutOfBoundsException();
1908cdf0e10cSrcweir
1909cdf0e10cSrcweir uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex);
1910cdf0e10cSrcweir if (xAccessible.is())
1911cdf0e10cSrcweir {
1912cdf0e10cSrcweir sal_Bool bWasTableSelected(IsTableSelected());
1913cdf0e10cSrcweir
1914cdf0e10cSrcweir if (mpChildrenShapes)
1915cdf0e10cSrcweir mpChildrenShapes->Select(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is to high
1916cdf0e10cSrcweir
1917cdf0e10cSrcweir if (bWasTableSelected)
1918cdf0e10cSrcweir mpViewShell->SelectAll();
1919cdf0e10cSrcweir }
1920cdf0e10cSrcweir else
1921cdf0e10cSrcweir {
1922cdf0e10cSrcweir if (mpViewShell)
1923cdf0e10cSrcweir mpViewShell->SelectAll();
1924cdf0e10cSrcweir }
1925cdf0e10cSrcweir }
1926cdf0e10cSrcweir }
1927cdf0e10cSrcweir
1928cdf0e10cSrcweir sal_Bool SAL_CALL
isAccessibleChildSelected(sal_Int32 nChildIndex)1929cdf0e10cSrcweir ScAccessibleDocument::isAccessibleChildSelected( sal_Int32 nChildIndex )
1930cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1931cdf0e10cSrcweir {
1932cdf0e10cSrcweir ScUnoGuard aGuard;
1933cdf0e10cSrcweir IsObjectValid();
1934cdf0e10cSrcweir sal_Bool bResult(sal_False);
1935cdf0e10cSrcweir
1936cdf0e10cSrcweir if (mpChildrenShapes)
1937cdf0e10cSrcweir {
1938cdf0e10cSrcweir sal_Int32 nCount(mpChildrenShapes->GetCount()); //all shapes and the table
1939cdf0e10cSrcweir if (mxTempAcc.is())
1940cdf0e10cSrcweir ++nCount;
1941cdf0e10cSrcweir if (nChildIndex < 0 || nChildIndex >= nCount)
1942cdf0e10cSrcweir throw lang::IndexOutOfBoundsException();
1943cdf0e10cSrcweir
1944cdf0e10cSrcweir uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex);
1945cdf0e10cSrcweir if (xAccessible.is())
1946cdf0e10cSrcweir {
1947cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape;
1948cdf0e10cSrcweir bResult = mpChildrenShapes->IsSelected(nChildIndex, xShape); // throws no lang::IndexOutOfBoundsException if Index is to high
1949cdf0e10cSrcweir }
1950cdf0e10cSrcweir else
1951cdf0e10cSrcweir {
1952cdf0e10cSrcweir if (mxTempAcc.is() && nChildIndex == nCount)
1953cdf0e10cSrcweir bResult = sal_True;
1954cdf0e10cSrcweir else
1955cdf0e10cSrcweir bResult = IsTableSelected();
1956cdf0e10cSrcweir }
1957cdf0e10cSrcweir }
1958cdf0e10cSrcweir return bResult;
1959cdf0e10cSrcweir }
1960cdf0e10cSrcweir
1961cdf0e10cSrcweir void SAL_CALL
clearAccessibleSelection()1962cdf0e10cSrcweir ScAccessibleDocument::clearAccessibleSelection( )
1963cdf0e10cSrcweir throw (uno::RuntimeException)
1964cdf0e10cSrcweir {
1965cdf0e10cSrcweir ScUnoGuard aGuard;
1966cdf0e10cSrcweir IsObjectValid();
1967cdf0e10cSrcweir
1968cdf0e10cSrcweir if (mpChildrenShapes)
1969cdf0e10cSrcweir mpChildrenShapes->DeselectAll(); //deselects all (also the table)
1970cdf0e10cSrcweir }
1971cdf0e10cSrcweir
1972cdf0e10cSrcweir void SAL_CALL
selectAllAccessibleChildren()1973cdf0e10cSrcweir ScAccessibleDocument::selectAllAccessibleChildren( )
1974cdf0e10cSrcweir throw (uno::RuntimeException)
1975cdf0e10cSrcweir {
1976cdf0e10cSrcweir ScUnoGuard aGuard;
1977cdf0e10cSrcweir IsObjectValid();
1978cdf0e10cSrcweir
1979cdf0e10cSrcweir if (mpChildrenShapes)
1980cdf0e10cSrcweir mpChildrenShapes->SelectAll();
1981cdf0e10cSrcweir
1982cdf0e10cSrcweir // select table after shapes, because while selecting shapes the table will be deselected
1983cdf0e10cSrcweir if (mpViewShell)
1984cdf0e10cSrcweir {
1985cdf0e10cSrcweir mpViewShell->SelectAll();
1986cdf0e10cSrcweir }
1987cdf0e10cSrcweir }
1988cdf0e10cSrcweir
1989cdf0e10cSrcweir sal_Int32 SAL_CALL
getSelectedAccessibleChildCount()1990cdf0e10cSrcweir ScAccessibleDocument::getSelectedAccessibleChildCount( )
1991cdf0e10cSrcweir throw (uno::RuntimeException)
1992cdf0e10cSrcweir {
1993cdf0e10cSrcweir ScUnoGuard aGuard;
1994cdf0e10cSrcweir IsObjectValid();
1995cdf0e10cSrcweir sal_Int32 nCount(0);
1996cdf0e10cSrcweir
1997cdf0e10cSrcweir if (mpChildrenShapes)
1998cdf0e10cSrcweir nCount = mpChildrenShapes->GetSelectedCount();
1999cdf0e10cSrcweir
2000cdf0e10cSrcweir if (IsTableSelected())
2001cdf0e10cSrcweir ++nCount;
2002cdf0e10cSrcweir
2003cdf0e10cSrcweir if (mxTempAcc.is())
2004cdf0e10cSrcweir ++nCount;
2005cdf0e10cSrcweir
2006cdf0e10cSrcweir return nCount;
2007cdf0e10cSrcweir }
2008cdf0e10cSrcweir
2009cdf0e10cSrcweir uno::Reference<XAccessible > SAL_CALL
getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex)2010cdf0e10cSrcweir ScAccessibleDocument::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
2011cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2012cdf0e10cSrcweir {
2013cdf0e10cSrcweir ScUnoGuard aGuard;
2014cdf0e10cSrcweir IsObjectValid();
2015cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible;
2016cdf0e10cSrcweir if (mpChildrenShapes)
2017cdf0e10cSrcweir {
2018cdf0e10cSrcweir sal_Int32 nCount(getSelectedAccessibleChildCount()); //all shapes and the table
2019cdf0e10cSrcweir if (nSelectedChildIndex < 0 || nSelectedChildIndex >= nCount)
2020cdf0e10cSrcweir throw lang::IndexOutOfBoundsException();
2021cdf0e10cSrcweir
2022cdf0e10cSrcweir sal_Bool bTabMarked(IsTableSelected());
2023cdf0e10cSrcweir
2024cdf0e10cSrcweir if (mpChildrenShapes)
2025cdf0e10cSrcweir xAccessible = mpChildrenShapes->GetSelected(nSelectedChildIndex, bTabMarked); // throws no lang::IndexOutOfBoundsException if Index is to high
2026cdf0e10cSrcweir if (mxTempAcc.is() && nSelectedChildIndex == nCount - 1)
2027cdf0e10cSrcweir xAccessible = mxTempAcc;
2028cdf0e10cSrcweir else if (bTabMarked)
2029cdf0e10cSrcweir xAccessible = GetAccessibleSpreadsheet();
2030cdf0e10cSrcweir }
2031cdf0e10cSrcweir
2032cdf0e10cSrcweir DBG_ASSERT(xAccessible.is(), "here should always be an accessible object or a exception throwed");
2033cdf0e10cSrcweir
2034cdf0e10cSrcweir return xAccessible;
2035cdf0e10cSrcweir }
2036cdf0e10cSrcweir
2037cdf0e10cSrcweir void SAL_CALL
deselectAccessibleChild(sal_Int32 nChildIndex)2038cdf0e10cSrcweir ScAccessibleDocument::deselectAccessibleChild( sal_Int32 nChildIndex )
2039cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2040cdf0e10cSrcweir {
2041cdf0e10cSrcweir ScUnoGuard aGuard;
2042cdf0e10cSrcweir IsObjectValid();
2043cdf0e10cSrcweir
2044cdf0e10cSrcweir if (mpChildrenShapes)
2045cdf0e10cSrcweir {
2046cdf0e10cSrcweir sal_Int32 nCount(mpChildrenShapes->GetCount()); //all shapes and the table
2047cdf0e10cSrcweir if (mxTempAcc.is())
2048cdf0e10cSrcweir ++nCount;
2049cdf0e10cSrcweir if (nChildIndex < 0 || nChildIndex >= nCount)
2050cdf0e10cSrcweir throw lang::IndexOutOfBoundsException();
2051cdf0e10cSrcweir
2052cdf0e10cSrcweir sal_Bool bTabMarked(IsTableSelected());
2053cdf0e10cSrcweir
2054cdf0e10cSrcweir uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex);
2055cdf0e10cSrcweir if (xAccessible.is())
2056cdf0e10cSrcweir {
2057cdf0e10cSrcweir if (mpChildrenShapes)
2058cdf0e10cSrcweir mpChildrenShapes->Deselect(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is to high
2059cdf0e10cSrcweir
2060cdf0e10cSrcweir if (bTabMarked)
2061cdf0e10cSrcweir mpViewShell->SelectAll(); // select the table again
2062cdf0e10cSrcweir }
2063cdf0e10cSrcweir else if (bTabMarked)
2064cdf0e10cSrcweir mpViewShell->Unmark();
2065cdf0e10cSrcweir }
2066cdf0e10cSrcweir }
2067cdf0e10cSrcweir
2068cdf0e10cSrcweir //===== XServiceInfo ====================================================
2069cdf0e10cSrcweir
2070cdf0e10cSrcweir ::rtl::OUString SAL_CALL
getImplementationName(void)2071cdf0e10cSrcweir ScAccessibleDocument::getImplementationName(void)
2072cdf0e10cSrcweir throw (uno::RuntimeException)
2073cdf0e10cSrcweir {
2074cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleDocument"));
2075cdf0e10cSrcweir }
2076cdf0e10cSrcweir
2077cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> SAL_CALL
getSupportedServiceNames(void)2078cdf0e10cSrcweir ScAccessibleDocument::getSupportedServiceNames(void)
2079cdf0e10cSrcweir throw (uno::RuntimeException)
2080cdf0e10cSrcweir {
2081cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
2082cdf0e10cSrcweir sal_Int32 nOldSize(aSequence.getLength());
2083cdf0e10cSrcweir aSequence.realloc(nOldSize + 1);
2084cdf0e10cSrcweir ::rtl::OUString* pNames = aSequence.getArray();
2085cdf0e10cSrcweir
2086cdf0e10cSrcweir pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.AccessibleSpreadsheetDocumentView"));
2087cdf0e10cSrcweir
2088cdf0e10cSrcweir return aSequence;
2089cdf0e10cSrcweir }
2090cdf0e10cSrcweir
2091cdf0e10cSrcweir //===== XTypeProvider =======================================================
2092cdf0e10cSrcweir
getTypes()2093cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL ScAccessibleDocument::getTypes()
2094cdf0e10cSrcweir throw (uno::RuntimeException)
2095cdf0e10cSrcweir {
2096cdf0e10cSrcweir return comphelper::concatSequences(ScAccessibleDocumentImpl::getTypes(), ScAccessibleContextBase::getTypes());
2097cdf0e10cSrcweir }
2098cdf0e10cSrcweir
2099cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL
getImplementationId(void)2100cdf0e10cSrcweir ScAccessibleDocument::getImplementationId(void)
2101cdf0e10cSrcweir throw (uno::RuntimeException)
2102cdf0e10cSrcweir {
2103cdf0e10cSrcweir ScUnoGuard aGuard;
2104cdf0e10cSrcweir IsObjectValid();
2105cdf0e10cSrcweir static uno::Sequence<sal_Int8> aId;
2106cdf0e10cSrcweir if (aId.getLength() == 0)
2107cdf0e10cSrcweir {
2108cdf0e10cSrcweir aId.realloc (16);
2109cdf0e10cSrcweir rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
2110cdf0e10cSrcweir }
2111cdf0e10cSrcweir return aId;
2112cdf0e10cSrcweir }
2113cdf0e10cSrcweir
2114cdf0e10cSrcweir ///===== IAccessibleViewForwarder ========================================
2115cdf0e10cSrcweir
IsValid(void) const2116cdf0e10cSrcweir sal_Bool ScAccessibleDocument::IsValid (void) const
2117cdf0e10cSrcweir {
2118cdf0e10cSrcweir ScUnoGuard aGuard;
2119cdf0e10cSrcweir IsObjectValid();
2120cdf0e10cSrcweir return (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose);
2121cdf0e10cSrcweir }
2122cdf0e10cSrcweir
GetVisibleArea_Impl() const2123cdf0e10cSrcweir Rectangle ScAccessibleDocument::GetVisibleArea_Impl() const
2124cdf0e10cSrcweir {
2125cdf0e10cSrcweir Rectangle aVisRect(GetBoundingBox());
2126cdf0e10cSrcweir
2127cdf0e10cSrcweir Point aPoint(mpViewShell->GetViewData()->GetPixPos(meSplitPos)); // returns a negative Point
2128cdf0e10cSrcweir aPoint.setX(-aPoint.getX());
2129cdf0e10cSrcweir aPoint.setY(-aPoint.getY());
2130cdf0e10cSrcweir aVisRect.SetPos(aPoint);
2131cdf0e10cSrcweir
2132cdf0e10cSrcweir ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
2133cdf0e10cSrcweir if (pWin)
2134cdf0e10cSrcweir aVisRect = pWin->PixelToLogic(aVisRect, pWin->GetDrawMapMode());
2135cdf0e10cSrcweir
2136cdf0e10cSrcweir return aVisRect;
2137cdf0e10cSrcweir }
2138cdf0e10cSrcweir
GetVisibleArea() const2139cdf0e10cSrcweir Rectangle ScAccessibleDocument::GetVisibleArea() const
2140cdf0e10cSrcweir {
2141cdf0e10cSrcweir ScUnoGuard aGuard;
2142cdf0e10cSrcweir IsObjectValid();
2143cdf0e10cSrcweir return maVisArea;
2144cdf0e10cSrcweir }
2145cdf0e10cSrcweir
LogicToPixel(const Point & rPoint) const2146cdf0e10cSrcweir Point ScAccessibleDocument::LogicToPixel (const Point& rPoint) const
2147cdf0e10cSrcweir {
2148cdf0e10cSrcweir ScUnoGuard aGuard;
2149cdf0e10cSrcweir IsObjectValid();
2150cdf0e10cSrcweir Point aPoint;
2151cdf0e10cSrcweir ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
2152cdf0e10cSrcweir if (pWin)
2153cdf0e10cSrcweir {
2154cdf0e10cSrcweir aPoint = pWin->LogicToPixel(rPoint, pWin->GetDrawMapMode());
2155cdf0e10cSrcweir aPoint += pWin->GetWindowExtentsRelative(NULL).TopLeft();
2156cdf0e10cSrcweir }
2157cdf0e10cSrcweir return aPoint;
2158cdf0e10cSrcweir }
2159cdf0e10cSrcweir
LogicToPixel(const Size & rSize) const2160cdf0e10cSrcweir Size ScAccessibleDocument::LogicToPixel (const Size& rSize) const
2161cdf0e10cSrcweir {
2162cdf0e10cSrcweir ScUnoGuard aGuard;
2163cdf0e10cSrcweir IsObjectValid();
2164cdf0e10cSrcweir Size aSize;
2165cdf0e10cSrcweir ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
2166cdf0e10cSrcweir if (pWin)
2167cdf0e10cSrcweir aSize = pWin->LogicToPixel(rSize, pWin->GetDrawMapMode());
2168cdf0e10cSrcweir return aSize;
2169cdf0e10cSrcweir }
2170cdf0e10cSrcweir
PixelToLogic(const Point & rPoint) const2171cdf0e10cSrcweir Point ScAccessibleDocument::PixelToLogic (const Point& rPoint) const
2172cdf0e10cSrcweir {
2173cdf0e10cSrcweir ScUnoGuard aGuard;
2174cdf0e10cSrcweir IsObjectValid();
2175cdf0e10cSrcweir Point aPoint;
2176cdf0e10cSrcweir ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
2177cdf0e10cSrcweir if (pWin)
2178cdf0e10cSrcweir {
2179cdf0e10cSrcweir aPoint -= pWin->GetWindowExtentsRelative(NULL).TopLeft();
2180cdf0e10cSrcweir aPoint = pWin->PixelToLogic(rPoint, pWin->GetDrawMapMode());
2181cdf0e10cSrcweir }
2182cdf0e10cSrcweir return aPoint;
2183cdf0e10cSrcweir }
2184cdf0e10cSrcweir
PixelToLogic(const Size & rSize) const2185cdf0e10cSrcweir Size ScAccessibleDocument::PixelToLogic (const Size& rSize) const
2186cdf0e10cSrcweir {
2187cdf0e10cSrcweir ScUnoGuard aGuard;
2188cdf0e10cSrcweir IsObjectValid();
2189cdf0e10cSrcweir Size aSize;
2190cdf0e10cSrcweir ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
2191cdf0e10cSrcweir if (pWin)
2192cdf0e10cSrcweir aSize = pWin->PixelToLogic(rSize, pWin->GetDrawMapMode());
2193cdf0e10cSrcweir return aSize;
2194cdf0e10cSrcweir }
2195cdf0e10cSrcweir
2196cdf0e10cSrcweir //===== internal ========================================================
2197cdf0e10cSrcweir
GetRelationSet(const ScAddress * pAddress) const2198cdf0e10cSrcweir utl::AccessibleRelationSetHelper* ScAccessibleDocument::GetRelationSet(const ScAddress* pAddress) const
2199cdf0e10cSrcweir {
2200cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pRelationSet = NULL;
2201cdf0e10cSrcweir if (mpChildrenShapes)
2202cdf0e10cSrcweir pRelationSet = mpChildrenShapes->GetRelationSet(pAddress);
2203cdf0e10cSrcweir return pRelationSet;
2204cdf0e10cSrcweir }
2205cdf0e10cSrcweir
2206cdf0e10cSrcweir ::rtl::OUString SAL_CALL
createAccessibleDescription(void)2207cdf0e10cSrcweir ScAccessibleDocument::createAccessibleDescription(void)
2208cdf0e10cSrcweir throw (uno::RuntimeException)
2209cdf0e10cSrcweir {
2210cdf0e10cSrcweir rtl::OUString sDescription = String(ScResId(STR_ACC_DOC_DESCR));
2211cdf0e10cSrcweir return sDescription;
2212cdf0e10cSrcweir }
2213cdf0e10cSrcweir
2214cdf0e10cSrcweir ::rtl::OUString SAL_CALL
createAccessibleName(void)2215cdf0e10cSrcweir ScAccessibleDocument::createAccessibleName(void)
2216cdf0e10cSrcweir throw (uno::RuntimeException)
2217cdf0e10cSrcweir {
2218cdf0e10cSrcweir ScUnoGuard aGuard;
2219cdf0e10cSrcweir IsObjectValid();
2220cdf0e10cSrcweir rtl::OUString sName = String(ScResId(STR_ACC_DOC_NAME));
2221cdf0e10cSrcweir sal_Int32 nNumber(sal_Int32(meSplitPos) + 1);
2222cdf0e10cSrcweir sName += rtl::OUString::valueOf(nNumber);
2223cdf0e10cSrcweir return sName;
2224cdf0e10cSrcweir }
2225cdf0e10cSrcweir
GetBoundingBoxOnScreen() const2226cdf0e10cSrcweir Rectangle ScAccessibleDocument::GetBoundingBoxOnScreen() const
2227cdf0e10cSrcweir throw (uno::RuntimeException)
2228cdf0e10cSrcweir {
2229cdf0e10cSrcweir Rectangle aRect;
2230cdf0e10cSrcweir if (mpViewShell)
2231cdf0e10cSrcweir {
2232cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
2233cdf0e10cSrcweir if (pWindow)
2234cdf0e10cSrcweir aRect = pWindow->GetWindowExtentsRelative(NULL);
2235cdf0e10cSrcweir }
2236cdf0e10cSrcweir return aRect;
2237cdf0e10cSrcweir }
2238cdf0e10cSrcweir
GetBoundingBox() const2239cdf0e10cSrcweir Rectangle ScAccessibleDocument::GetBoundingBox() const
2240cdf0e10cSrcweir throw (uno::RuntimeException)
2241cdf0e10cSrcweir {
2242cdf0e10cSrcweir Rectangle aRect;
2243cdf0e10cSrcweir if (mpViewShell)
2244cdf0e10cSrcweir {
2245cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
2246cdf0e10cSrcweir if (pWindow)
2247cdf0e10cSrcweir aRect = pWindow->GetWindowExtentsRelative(pWindow->GetAccessibleParentWindow());
2248cdf0e10cSrcweir }
2249cdf0e10cSrcweir return aRect;
2250cdf0e10cSrcweir }
2251cdf0e10cSrcweir
getVisibleTable() const2252cdf0e10cSrcweir SCTAB ScAccessibleDocument::getVisibleTable() const
2253cdf0e10cSrcweir {
2254cdf0e10cSrcweir SCTAB nVisibleTable(0);
2255cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData())
2256cdf0e10cSrcweir nVisibleTable = mpViewShell->GetViewData()->GetTabNo();
2257cdf0e10cSrcweir return nVisibleTable;
2258cdf0e10cSrcweir }
2259cdf0e10cSrcweir
2260cdf0e10cSrcweir uno::Reference < XAccessible >
GetAccessibleSpreadsheet()2261cdf0e10cSrcweir ScAccessibleDocument::GetAccessibleSpreadsheet()
2262cdf0e10cSrcweir {
2263cdf0e10cSrcweir if (!mpAccessibleSpreadsheet && mpViewShell)
2264cdf0e10cSrcweir {
2265cdf0e10cSrcweir mpAccessibleSpreadsheet = new ScAccessibleSpreadsheet(this, mpViewShell, getVisibleTable(), meSplitPos);
2266cdf0e10cSrcweir mpAccessibleSpreadsheet->acquire();
2267cdf0e10cSrcweir mpAccessibleSpreadsheet->Init();
2268cdf0e10cSrcweir mbCompleteSheetSelected = IsTableSelected();
2269*0f0923cbSSteve Yin mpAccessibleSpreadsheet->FireFirstCellFocus(); // i123622
2270cdf0e10cSrcweir }
2271cdf0e10cSrcweir return mpAccessibleSpreadsheet;
2272cdf0e10cSrcweir }
2273cdf0e10cSrcweir
FreeAccessibleSpreadsheet()2274cdf0e10cSrcweir void ScAccessibleDocument::FreeAccessibleSpreadsheet()
2275cdf0e10cSrcweir {
2276cdf0e10cSrcweir if (mpAccessibleSpreadsheet)
2277cdf0e10cSrcweir {
2278cdf0e10cSrcweir mpAccessibleSpreadsheet->dispose();
2279cdf0e10cSrcweir mpAccessibleSpreadsheet->release();
2280cdf0e10cSrcweir mpAccessibleSpreadsheet = NULL;
2281cdf0e10cSrcweir }
2282cdf0e10cSrcweir }
2283cdf0e10cSrcweir
IsTableSelected() const2284cdf0e10cSrcweir sal_Bool ScAccessibleDocument::IsTableSelected() const
2285cdf0e10cSrcweir {
2286cdf0e10cSrcweir sal_Bool bResult (sal_False);
2287cdf0e10cSrcweir if(mpViewShell)
2288cdf0e10cSrcweir {
2289cdf0e10cSrcweir SCTAB nTab(getVisibleTable());
2290cdf0e10cSrcweir //#103800#; use a copy of MarkData
2291cdf0e10cSrcweir ScMarkData aMarkData(mpViewShell->GetViewData()->GetMarkData());
2292cdf0e10cSrcweir aMarkData.MarkToMulti();
2293cdf0e10cSrcweir if (aMarkData.IsAllMarked(ScRange(ScAddress(0, 0, nTab),ScAddress(MAXCOL, MAXROW, nTab))))
2294cdf0e10cSrcweir bResult = sal_True;
2295cdf0e10cSrcweir }
2296cdf0e10cSrcweir return bResult;
2297cdf0e10cSrcweir }
2298cdf0e10cSrcweir
IsDefunc(const uno::Reference<XAccessibleStateSet> & rxParentStates)2299cdf0e10cSrcweir sal_Bool ScAccessibleDocument::IsDefunc(
2300cdf0e10cSrcweir const uno::Reference<XAccessibleStateSet>& rxParentStates)
2301cdf0e10cSrcweir {
2302cdf0e10cSrcweir return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() ||
2303cdf0e10cSrcweir (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
2304cdf0e10cSrcweir }
2305cdf0e10cSrcweir
IsEditable(const uno::Reference<XAccessibleStateSet> &)2306cdf0e10cSrcweir sal_Bool ScAccessibleDocument::IsEditable(
2307cdf0e10cSrcweir const uno::Reference<XAccessibleStateSet>& /* rxParentStates */)
2308cdf0e10cSrcweir {
2309cdf0e10cSrcweir // what is with document protection or readonly documents?
2310cdf0e10cSrcweir return sal_True;
2311cdf0e10cSrcweir }
2312cdf0e10cSrcweir
AddChild(const uno::Reference<XAccessible> & xAcc,sal_Bool bFireEvent)2313cdf0e10cSrcweir void ScAccessibleDocument::AddChild(const uno::Reference<XAccessible>& xAcc, sal_Bool bFireEvent)
2314cdf0e10cSrcweir {
2315cdf0e10cSrcweir DBG_ASSERT(!mxTempAcc.is(), "this object should be removed before");
2316cdf0e10cSrcweir if (xAcc.is())
2317cdf0e10cSrcweir {
2318cdf0e10cSrcweir mxTempAcc = xAcc;
2319cdf0e10cSrcweir if( bFireEvent )
2320cdf0e10cSrcweir {
2321cdf0e10cSrcweir AccessibleEventObject aEvent;
2322cdf0e10cSrcweir aEvent.Source = uno::Reference<XAccessibleContext>(this);
2323cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
2324cdf0e10cSrcweir aEvent.NewValue <<= mxTempAcc;
2325cdf0e10cSrcweir CommitChange( aEvent );
2326cdf0e10cSrcweir }
2327cdf0e10cSrcweir }
2328cdf0e10cSrcweir }
2329cdf0e10cSrcweir
RemoveChild(const uno::Reference<XAccessible> & xAcc,sal_Bool bFireEvent)2330cdf0e10cSrcweir void ScAccessibleDocument::RemoveChild(const uno::Reference<XAccessible>& xAcc, sal_Bool bFireEvent)
2331cdf0e10cSrcweir {
2332cdf0e10cSrcweir DBG_ASSERT(mxTempAcc.is(), "this object should be added before");
2333cdf0e10cSrcweir if (xAcc.is())
2334cdf0e10cSrcweir {
2335cdf0e10cSrcweir DBG_ASSERT(xAcc.get() == mxTempAcc.get(), "only the same object should be removed");
2336cdf0e10cSrcweir if( bFireEvent )
2337cdf0e10cSrcweir {
2338cdf0e10cSrcweir AccessibleEventObject aEvent;
2339cdf0e10cSrcweir aEvent.Source = uno::Reference<XAccessibleContext>(this);
2340cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
2341cdf0e10cSrcweir aEvent.OldValue <<= mxTempAcc;
2342cdf0e10cSrcweir CommitChange( aEvent );
2343cdf0e10cSrcweir }
2344cdf0e10cSrcweir mxTempAcc = NULL;
2345cdf0e10cSrcweir }
2346cdf0e10cSrcweir }
2347cdf0e10cSrcweir
GetCurrentCellName() const2348cdf0e10cSrcweir rtl::OUString ScAccessibleDocument::GetCurrentCellName() const
2349cdf0e10cSrcweir {
2350cdf0e10cSrcweir String sName( ScResId(STR_ACC_CELL_NAME) );
2351cdf0e10cSrcweir if (mpViewShell)
2352cdf0e10cSrcweir {
2353cdf0e10cSrcweir String sAddress;
2354cdf0e10cSrcweir // Document not needed, because only the cell address, but not the tablename is needed
2355cdf0e10cSrcweir mpViewShell->GetViewData()->GetCurPos().Format( sAddress, SCA_VALID, NULL );
2356cdf0e10cSrcweir sName.SearchAndReplaceAscii("%1", sAddress);
2357cdf0e10cSrcweir }
2358cdf0e10cSrcweir return rtl::OUString(sName);
2359cdf0e10cSrcweir }
2360cdf0e10cSrcweir
GetCurrentCellDescription() const2361cdf0e10cSrcweir rtl::OUString ScAccessibleDocument::GetCurrentCellDescription() const
2362cdf0e10cSrcweir {
2363cdf0e10cSrcweir return rtl::OUString();
2364cdf0e10cSrcweir }
GetDocument() const23650deba7fbSSteve Yin ScDocument *ScAccessibleDocument::GetDocument() const
23660deba7fbSSteve Yin {
23670deba7fbSSteve Yin return mpViewShell ? mpViewShell->GetViewData()->GetDocument() : NULL;
23680deba7fbSSteve Yin }
GetCurCellAddress() const23690deba7fbSSteve Yin ScAddress ScAccessibleDocument::GetCurCellAddress() const
23700deba7fbSSteve Yin {
23710deba7fbSSteve Yin return mpViewShell ? mpViewShell->GetViewData()->GetCurPos() :ScAddress();
23720deba7fbSSteve Yin }
getExtendedAttributes()23730deba7fbSSteve Yin uno::Any SAL_CALL ScAccessibleDocument::getExtendedAttributes()
23740deba7fbSSteve Yin throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
23750deba7fbSSteve Yin {
23760deba7fbSSteve Yin
23770deba7fbSSteve Yin uno::Any anyAtrribute;
23780deba7fbSSteve Yin
23790deba7fbSSteve Yin rtl::OUString sName;
23800deba7fbSSteve Yin rtl::OUString sValue;
23810deba7fbSSteve Yin sal_uInt16 sheetIndex;
23820deba7fbSSteve Yin String sSheetName;
23830deba7fbSSteve Yin sheetIndex = getVisibleTable();
23840deba7fbSSteve Yin if(GetDocument()==NULL)
23850deba7fbSSteve Yin return anyAtrribute;
23860deba7fbSSteve Yin GetDocument()->GetName(sheetIndex,sSheetName);
23870deba7fbSSteve Yin sName = rtl::OUString::createFromAscii("page-name:");
23880deba7fbSSteve Yin sValue = sName + sSheetName ;
23890deba7fbSSteve Yin sName = rtl::OUString::createFromAscii(";page-number:");
23900deba7fbSSteve Yin sValue += sName;
23910deba7fbSSteve Yin sValue += String::CreateFromInt32(sheetIndex+1) ;
23920deba7fbSSteve Yin sName = rtl::OUString::createFromAscii(";total-pages:");
23930deba7fbSSteve Yin sValue += sName;
23940deba7fbSSteve Yin sValue += String::CreateFromInt32(GetDocument()->GetTableCount());
23950deba7fbSSteve Yin sValue += rtl::OUString::createFromAscii(";");
23960deba7fbSSteve Yin anyAtrribute <<= sValue;
23970deba7fbSSteve Yin return anyAtrribute;
23980deba7fbSSteve Yin }
GetScAccFlowToSequence()23990deba7fbSSteve Yin com::sun::star::uno::Sequence< com::sun::star::uno::Any > ScAccessibleDocument::GetScAccFlowToSequence()
24000deba7fbSSteve Yin {
24010deba7fbSSteve Yin if ( getAccessibleChildCount() )
24020deba7fbSSteve Yin {
24030deba7fbSSteve Yin uno::Reference < XAccessible > xSCTableAcc = getAccessibleChild( 0 ); // table
24040deba7fbSSteve Yin if ( xSCTableAcc.is() )
24050deba7fbSSteve Yin {
24060deba7fbSSteve Yin uno::Reference < XAccessibleSelection > xAccSelection( xSCTableAcc, uno::UNO_QUERY );
24070deba7fbSSteve Yin sal_Int32 nSelCount = xAccSelection->getSelectedAccessibleChildCount();
24080deba7fbSSteve Yin if( nSelCount )
24090deba7fbSSteve Yin {
24100deba7fbSSteve Yin uno::Reference < XAccessible > xSel = xAccSelection->getSelectedAccessibleChild( 0 ); // selected cell
24110deba7fbSSteve Yin if ( xSel.is() )
24120deba7fbSSteve Yin {
24130deba7fbSSteve Yin uno::Reference < XAccessibleContext > xSelContext( xSel->getAccessibleContext() );
24140deba7fbSSteve Yin if ( xSelContext.is() )
24150deba7fbSSteve Yin {
24160deba7fbSSteve Yin if ( xSelContext->getAccessibleRole() == AccessibleRole::TABLE_CELL )
24170deba7fbSSteve Yin {
24180deba7fbSSteve Yin sal_Int32 nParaCount = 0;
24190deba7fbSSteve Yin uno::Sequence <uno::Any> aSequence(nSelCount);
24200deba7fbSSteve Yin for ( sal_Int32 i = 0; i < nSelCount; i++ )
24210deba7fbSSteve Yin {
24220deba7fbSSteve Yin xSel = xAccSelection->getSelectedAccessibleChild( i ) ;
24230deba7fbSSteve Yin if ( xSel.is() )
24240deba7fbSSteve Yin {
24250deba7fbSSteve Yin xSelContext = xSel->getAccessibleContext();
24260deba7fbSSteve Yin if ( xSelContext.is() )
24270deba7fbSSteve Yin {
24280deba7fbSSteve Yin if ( xSelContext->getAccessibleRole() == AccessibleRole::TABLE_CELL )
24290deba7fbSSteve Yin {
24300deba7fbSSteve Yin aSequence[nParaCount] = uno::makeAny( xSel );
24310deba7fbSSteve Yin nParaCount++;
24320deba7fbSSteve Yin }
24330deba7fbSSteve Yin }
24340deba7fbSSteve Yin }
24350deba7fbSSteve Yin }
24360deba7fbSSteve Yin return aSequence;
24370deba7fbSSteve Yin }
24380deba7fbSSteve Yin }
24390deba7fbSSteve Yin }
24400deba7fbSSteve Yin }
24410deba7fbSSteve Yin }
24420deba7fbSSteve Yin }
24430deba7fbSSteve Yin uno::Sequence <uno::Any> aEmpty;
24440deba7fbSSteve Yin return aEmpty;
24450deba7fbSSteve Yin }
24460deba7fbSSteve Yin ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
get_AccFlowTo(const::com::sun::star::uno::Any & rAny,sal_Int32 nType)24470deba7fbSSteve Yin SAL_CALL ScAccessibleDocument::get_AccFlowTo(const ::com::sun::star::uno::Any& rAny, sal_Int32 nType)
24480deba7fbSSteve Yin throw ( ::com::sun::star::uno::RuntimeException )
24490deba7fbSSteve Yin {
24500deba7fbSSteve Yin const sal_Int32 SPELLCHECKFLOWTO = 1;
24510deba7fbSSteve Yin const sal_Int32 FINDREPLACEFLOWTO = 2;
24520deba7fbSSteve Yin if ( nType == SPELLCHECKFLOWTO )
24530deba7fbSSteve Yin {
24540deba7fbSSteve Yin uno::Reference< ::com::sun::star::drawing::XShape > xShape;
24550deba7fbSSteve Yin rAny >>= xShape;
24560deba7fbSSteve Yin if ( xShape.is() )
24570deba7fbSSteve Yin {
24580deba7fbSSteve Yin uno::Reference < XAccessible > xAcc = mpChildrenShapes->GetAccessibleCaption(xShape);
24590deba7fbSSteve Yin uno::Reference < XAccessibleSelection > xAccSelection( xAcc, uno::UNO_QUERY );
24600deba7fbSSteve Yin if ( xAccSelection.is() )
24610deba7fbSSteve Yin {
24620deba7fbSSteve Yin if ( xAccSelection->getSelectedAccessibleChildCount() )
24630deba7fbSSteve Yin {
24640deba7fbSSteve Yin uno::Reference < XAccessible > xSel = xAccSelection->getSelectedAccessibleChild( 0 );
24650deba7fbSSteve Yin if ( xSel.is() )
24660deba7fbSSteve Yin {
24670deba7fbSSteve Yin uno::Reference < XAccessibleContext > xSelContext( xSel->getAccessibleContext() );
24680deba7fbSSteve Yin if ( xSelContext.is() )
24690deba7fbSSteve Yin {
24700deba7fbSSteve Yin //if in sw we find the selected paragraph here
24710deba7fbSSteve Yin if ( xSelContext->getAccessibleRole() == AccessibleRole::PARAGRAPH )
24720deba7fbSSteve Yin {
24730deba7fbSSteve Yin uno::Sequence<uno::Any> aRet( 1 );
24740deba7fbSSteve Yin aRet[0] = uno::makeAny( xSel );
24750deba7fbSSteve Yin return aRet;
24760deba7fbSSteve Yin }
24770deba7fbSSteve Yin }
24780deba7fbSSteve Yin }
24790deba7fbSSteve Yin }
24800deba7fbSSteve Yin }
24810deba7fbSSteve Yin }
24820deba7fbSSteve Yin else
24830deba7fbSSteve Yin {
24840deba7fbSSteve Yin if ( getSelectedAccessibleChildCount() )
24850deba7fbSSteve Yin {
24860deba7fbSSteve Yin uno::Reference < XAccessible > xSel = getSelectedAccessibleChild( 0 );
24870deba7fbSSteve Yin if ( xSel.is() )
24880deba7fbSSteve Yin {
24890deba7fbSSteve Yin uno::Reference < XAccessibleContext > xSelContext( xSel->getAccessibleContext() );
24900deba7fbSSteve Yin if ( xSelContext.is() )
24910deba7fbSSteve Yin {
24920deba7fbSSteve Yin uno::Reference < XAccessibleSelection > xAccChildSelection( xSel, uno::UNO_QUERY );
24930deba7fbSSteve Yin if ( xAccChildSelection.is() )
24940deba7fbSSteve Yin {
24950deba7fbSSteve Yin if ( xAccChildSelection->getSelectedAccessibleChildCount() )
24960deba7fbSSteve Yin {
24970deba7fbSSteve Yin uno::Reference < XAccessible > xChildSel = xAccChildSelection->getSelectedAccessibleChild( 0 );
24980deba7fbSSteve Yin if ( xChildSel.is() )
24990deba7fbSSteve Yin {
25000deba7fbSSteve Yin uno::Reference < ::com::sun::star::accessibility::XAccessibleContext > xChildSelContext( xChildSel->getAccessibleContext() );
25010deba7fbSSteve Yin if ( xChildSelContext.is() &&
25020deba7fbSSteve Yin xChildSelContext->getAccessibleRole() == ::com::sun::star::accessibility::AccessibleRole::PARAGRAPH )
25030deba7fbSSteve Yin {
25040deba7fbSSteve Yin uno::Sequence<uno::Any> aRet( 1 );
25050deba7fbSSteve Yin aRet[0] = uno::makeAny( xChildSel );
25060deba7fbSSteve Yin return aRet;
25070deba7fbSSteve Yin }
25080deba7fbSSteve Yin }
25090deba7fbSSteve Yin }
25100deba7fbSSteve Yin }
25110deba7fbSSteve Yin }
25120deba7fbSSteve Yin }
25130deba7fbSSteve Yin }
25140deba7fbSSteve Yin }
25150deba7fbSSteve Yin }
25160deba7fbSSteve Yin else if ( nType == FINDREPLACEFLOWTO )
25170deba7fbSSteve Yin {
25184483d2e8SPavel Janík sal_Bool bSuccess(sal_False);
25190deba7fbSSteve Yin rAny >>= bSuccess;
25200deba7fbSSteve Yin if ( bSuccess )
25210deba7fbSSteve Yin {
25220deba7fbSSteve Yin uno::Sequence< uno::Any> aSeq = GetScAccFlowToSequence();
25230deba7fbSSteve Yin if ( aSeq.getLength() )
25240deba7fbSSteve Yin {
25250deba7fbSSteve Yin return aSeq;
25260deba7fbSSteve Yin }
25270deba7fbSSteve Yin else if( mpAccessibleSpreadsheet )
25280deba7fbSSteve Yin {
25290deba7fbSSteve Yin uno::Reference < XAccessible > xFindCellAcc = mpAccessibleSpreadsheet->GetActiveCell();
25300deba7fbSSteve Yin // add xFindCellAcc to the return the Sequence
25310deba7fbSSteve Yin uno::Sequence< uno::Any> aSeq2(1);
25320deba7fbSSteve Yin aSeq2[0] = uno::makeAny( xFindCellAcc );
25330deba7fbSSteve Yin return aSeq2;
25340deba7fbSSteve Yin }
25350deba7fbSSteve Yin }
25360deba7fbSSteve Yin }
25370deba7fbSSteve Yin uno::Sequence< uno::Any> aEmpty;
25380deba7fbSSteve Yin return aEmpty;
25390deba7fbSSteve Yin }
SwitchViewFireFocus()25400deba7fbSSteve Yin void ScAccessibleDocument::SwitchViewFireFocus()
25410deba7fbSSteve Yin {
25420deba7fbSSteve Yin if (mpAccessibleSpreadsheet)
25430deba7fbSSteve Yin {
25440deba7fbSSteve Yin mpAccessibleSpreadsheet->FireFirstCellFocus();
25450deba7fbSSteve Yin }
25460deba7fbSSteve Yin }
25470deba7fbSSteve Yin
getForeground()25480deba7fbSSteve Yin sal_Int32 SAL_CALL ScAccessibleDocument::getForeground( )
25490deba7fbSSteve Yin throw (uno::RuntimeException)
25500deba7fbSSteve Yin {
25510deba7fbSSteve Yin return COL_BLACK;
25520deba7fbSSteve Yin }
25530deba7fbSSteve Yin
getBackground()25540deba7fbSSteve Yin sal_Int32 SAL_CALL ScAccessibleDocument::getBackground( )
25550deba7fbSSteve Yin throw (uno::RuntimeException)
25560deba7fbSSteve Yin {
25570deba7fbSSteve Yin ScUnoGuard aGuard;
25580deba7fbSSteve Yin IsObjectValid();
25590deba7fbSSteve Yin return SC_MOD()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor;
25600deba7fbSSteve Yin }
25610deba7fbSSteve Yin
2562