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
10cdf0e10cSrcweir *
11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
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.
19cdf0e10cSrcweir *
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 #include "AccessibleDocumentPagePreview.hxx"
28cdf0e10cSrcweir #include "AccessiblePreviewTable.hxx"
29cdf0e10cSrcweir #include "AccessiblePageHeader.hxx"
30cdf0e10cSrcweir #include "AccessibilityHints.hxx"
31cdf0e10cSrcweir #include "AccessibleText.hxx"
32cdf0e10cSrcweir #include "document.hxx"
33cdf0e10cSrcweir #include "prevwsh.hxx"
34cdf0e10cSrcweir #include "prevloc.hxx"
35cdf0e10cSrcweir #include "unoguard.hxx"
36cdf0e10cSrcweir #include "drwlayer.hxx"
37cdf0e10cSrcweir #include "editsrc.hxx"
38cdf0e10cSrcweir #include "scresid.hxx"
39cdf0e10cSrcweir #include "sc.hrc"
40cdf0e10cSrcweir #include "DrawModelBroadcaster.hxx"
41cdf0e10cSrcweir #include "docsh.hxx"
42cdf0e10cSrcweir #include "drawview.hxx"
43cdf0e10cSrcweir #include "preview.hxx"
44cdf0e10cSrcweir #include "postit.hxx"
45cdf0e10cSrcweir
46cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
47cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
48cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
49cdf0e10cSrcweir
50cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
51cdf0e10cSrcweir #include <tools/debug.hxx>
52cdf0e10cSrcweir #include <tools/gen.hxx>
53cdf0e10cSrcweir #include <svx/svdpage.hxx>
54cdf0e10cSrcweir #include <svx/svdobj.hxx>
55cdf0e10cSrcweir #include <svx/AccessibleTextHelper.hxx>
56cdf0e10cSrcweir #include <svx/AccessibleShape.hxx>
57cdf0e10cSrcweir #include <svx/ShapeTypeHandler.hxx>
58cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
59cdf0e10cSrcweir #include <svx/unoshape.hxx>
60cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx>
61cdf0e10cSrcweir
62cdf0e10cSrcweir #include <vector>
63cdf0e10cSrcweir #include <list>
64cdf0e10cSrcweir #include <algorithm>
65cdf0e10cSrcweir #include <memory>
66cdf0e10cSrcweir
67cdf0e10cSrcweir using namespace ::com::sun::star;
68cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
69cdf0e10cSrcweir
70cdf0e10cSrcweir //=========================================================================
71cdf0e10cSrcweir
72cdf0e10cSrcweir typedef std::list< uno::Reference< XAccessible > > ScXAccList;
73cdf0e10cSrcweir
74cdf0e10cSrcweir
75cdf0e10cSrcweir struct ScAccNote
76cdf0e10cSrcweir {
77cdf0e10cSrcweir String maNoteText;
78cdf0e10cSrcweir Rectangle maRect;
79cdf0e10cSrcweir ScAddress maNoteCell;
80cdf0e10cSrcweir ::accessibility::AccessibleTextHelper* mpTextHelper;
81cdf0e10cSrcweir sal_Int32 mnParaCount;
82cdf0e10cSrcweir sal_Bool mbMarkNote;
83cdf0e10cSrcweir
ScAccNoteScAccNote84cdf0e10cSrcweir ScAccNote() : mpTextHelper(NULL), mnParaCount(0) {}
85cdf0e10cSrcweir };
86cdf0e10cSrcweir
87cdf0e10cSrcweir class ScNotesChilds
88cdf0e10cSrcweir {
89cdf0e10cSrcweir public:
90cdf0e10cSrcweir ScNotesChilds(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview* pAccDoc);
91cdf0e10cSrcweir ~ScNotesChilds();
92cdf0e10cSrcweir void Init(const Rectangle& rVisRect, sal_Int32 nOffset);
93cdf0e10cSrcweir
94cdf0e10cSrcweir sal_Int32 GetChildsCount() const;
95cdf0e10cSrcweir uno::Reference<XAccessible> GetChild(sal_Int32 nIndex) const;
96cdf0e10cSrcweir uno::Reference<XAccessible> GetAt(const awt::Point& rPoint) const;
97cdf0e10cSrcweir
98cdf0e10cSrcweir void DataChanged(const Rectangle& rVisRect);
99cdf0e10cSrcweir void SetOffset(sal_Int32 nNewOffset);
100cdf0e10cSrcweir private:
101cdf0e10cSrcweir ScPreviewShell* mpViewShell;
102cdf0e10cSrcweir ScAccessibleDocumentPagePreview* mpAccDoc;
103cdf0e10cSrcweir typedef std::vector<ScAccNote> ScAccNotes;
104cdf0e10cSrcweir mutable ScAccNotes maNotes;
105cdf0e10cSrcweir mutable ScAccNotes maMarks;
106cdf0e10cSrcweir sal_Int32 mnParagraphs;
107cdf0e10cSrcweir sal_Int32 mnOffset;
108cdf0e10cSrcweir
109cdf0e10cSrcweir ::accessibility::AccessibleTextHelper* CreateTextHelper(const String& rString, const Rectangle& rVisRect, const ScAddress& aCellPos, sal_Bool bMarkNote, sal_Int32 nChildOffset) const;
110cdf0e10cSrcweir sal_Int32 AddNotes(const ScPreviewLocationData& rData, const Rectangle& rVisRect, sal_Bool bMark, ScAccNotes& rNotes);
111cdf0e10cSrcweir
112cdf0e10cSrcweir sal_Int8 CompareCell(const ScAddress& aCell1, const ScAddress& aCell2);
113cdf0e10cSrcweir void CollectChilds(const ScAccNote& rNote, ScXAccList& rList);
114cdf0e10cSrcweir sal_Int32 CheckChanges(const ScPreviewLocationData& rData, const Rectangle& rVisRect,
115cdf0e10cSrcweir sal_Bool bMark, ScAccNotes& rOldNotes, ScAccNotes& rNewNotes,
116cdf0e10cSrcweir ScXAccList& rOldParas, ScXAccList& rNewParas);
117cdf0e10cSrcweir
118cdf0e10cSrcweir inline ScDocument* GetDocument() const;
119cdf0e10cSrcweir };
120cdf0e10cSrcweir
ScNotesChilds(ScPreviewShell * pViewShell,ScAccessibleDocumentPagePreview * pAccDoc)121cdf0e10cSrcweir ScNotesChilds::ScNotesChilds(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview* pAccDoc)
122cdf0e10cSrcweir : mpViewShell(pViewShell),
123cdf0e10cSrcweir mpAccDoc(pAccDoc),
124cdf0e10cSrcweir mnParagraphs(0),
125cdf0e10cSrcweir mnOffset(0)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir }
128cdf0e10cSrcweir
129cdf0e10cSrcweir struct DeleteAccNote
130cdf0e10cSrcweir {
operator ()DeleteAccNote131cdf0e10cSrcweir void operator()(ScAccNote& rNote)
132cdf0e10cSrcweir {
133cdf0e10cSrcweir if (rNote.mpTextHelper)
134cdf0e10cSrcweir DELETEZ( rNote.mpTextHelper);
135cdf0e10cSrcweir }
136cdf0e10cSrcweir };
137cdf0e10cSrcweir
~ScNotesChilds()138cdf0e10cSrcweir ScNotesChilds::~ScNotesChilds()
139cdf0e10cSrcweir {
140cdf0e10cSrcweir std::for_each(maNotes.begin(), maNotes.end(), DeleteAccNote());
141cdf0e10cSrcweir std::for_each(maMarks.begin(), maMarks.end(), DeleteAccNote());
142cdf0e10cSrcweir }
143cdf0e10cSrcweir
CreateTextHelper(const String & rString,const Rectangle & rVisRect,const ScAddress & aCellPos,sal_Bool bMarkNote,sal_Int32 nChildOffset) const144cdf0e10cSrcweir ::accessibility::AccessibleTextHelper* ScNotesChilds::CreateTextHelper(const String& rString, const Rectangle& rVisRect, const ScAddress& aCellPos, sal_Bool bMarkNote, sal_Int32 nChildOffset) const
145cdf0e10cSrcweir {
146cdf0e10cSrcweir ::accessibility::AccessibleTextHelper* pTextHelper = NULL;
147cdf0e10cSrcweir
148cdf0e10cSrcweir ::std::auto_ptr < ScAccessibleTextData > pAccessiblePreviewHeaderCellTextData
149cdf0e10cSrcweir (new ScAccessibleNoteTextData(mpViewShell, rString, aCellPos, bMarkNote));
150cdf0e10cSrcweir ::std::auto_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(pAccessiblePreviewHeaderCellTextData));
151cdf0e10cSrcweir
152cdf0e10cSrcweir pTextHelper = new ::accessibility::AccessibleTextHelper(pEditSource);
153cdf0e10cSrcweir
154cdf0e10cSrcweir if (pTextHelper)
155cdf0e10cSrcweir {
156cdf0e10cSrcweir pTextHelper->SetEventSource(mpAccDoc);
157cdf0e10cSrcweir pTextHelper->SetStartIndex(nChildOffset);
158cdf0e10cSrcweir pTextHelper->SetOffset(rVisRect.TopLeft());
159cdf0e10cSrcweir }
160cdf0e10cSrcweir
161cdf0e10cSrcweir return pTextHelper;
162cdf0e10cSrcweir }
163cdf0e10cSrcweir
AddNotes(const ScPreviewLocationData & rData,const Rectangle & rVisRect,sal_Bool bMark,ScAccNotes & rNotes)164cdf0e10cSrcweir sal_Int32 ScNotesChilds::AddNotes(const ScPreviewLocationData& rData, const Rectangle& rVisRect, sal_Bool bMark, ScAccNotes& rNotes)
165cdf0e10cSrcweir {
166cdf0e10cSrcweir sal_Int32 nCount = rData.GetNoteCountInRange(rVisRect, bMark);
167cdf0e10cSrcweir
168cdf0e10cSrcweir rNotes.reserve(nCount);
169cdf0e10cSrcweir
170cdf0e10cSrcweir sal_Int32 nParagraphs(0);
171cdf0e10cSrcweir ScDocument* pDoc = GetDocument();
172cdf0e10cSrcweir if (pDoc)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir ScAccNote aNote;
175cdf0e10cSrcweir aNote.mbMarkNote = bMark;
176cdf0e10cSrcweir if (bMark)
177cdf0e10cSrcweir aNote.mnParaCount = 1;
178cdf0e10cSrcweir for (sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex)
179cdf0e10cSrcweir {
180cdf0e10cSrcweir if (rData.GetNoteInRange(rVisRect, nIndex, bMark, aNote.maNoteCell, aNote.maRect))
181cdf0e10cSrcweir {
182cdf0e10cSrcweir if (bMark)
183cdf0e10cSrcweir {
184cdf0e10cSrcweir // Document not needed, because only the cell address, but not the tablename is needed
185cdf0e10cSrcweir aNote.maNoteCell.Format( aNote.maNoteText, SCA_VALID, NULL );
186cdf0e10cSrcweir }
187cdf0e10cSrcweir else
188cdf0e10cSrcweir {
189cdf0e10cSrcweir if( ScPostIt* pNote = pDoc->GetNote( aNote.maNoteCell ) )
190cdf0e10cSrcweir aNote.maNoteText = pNote->GetText();
191cdf0e10cSrcweir aNote.mpTextHelper = CreateTextHelper(aNote.maNoteText, aNote.maRect, aNote.maNoteCell, aNote.mbMarkNote, nParagraphs + mnOffset);
192cdf0e10cSrcweir if (aNote.mpTextHelper)
193cdf0e10cSrcweir aNote.mnParaCount = aNote.mpTextHelper->GetChildCount();
194cdf0e10cSrcweir }
195cdf0e10cSrcweir nParagraphs += aNote.mnParaCount;
196cdf0e10cSrcweir rNotes.push_back(aNote);
197cdf0e10cSrcweir }
198cdf0e10cSrcweir }
199cdf0e10cSrcweir }
200cdf0e10cSrcweir return nParagraphs;
201cdf0e10cSrcweir }
202cdf0e10cSrcweir
Init(const Rectangle & rVisRect,sal_Int32 nOffset)203cdf0e10cSrcweir void ScNotesChilds::Init(const Rectangle& rVisRect, sal_Int32 nOffset)
204cdf0e10cSrcweir {
205cdf0e10cSrcweir if (mpViewShell && !mnParagraphs)
206cdf0e10cSrcweir {
207cdf0e10cSrcweir mnOffset = nOffset;
208cdf0e10cSrcweir const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
209cdf0e10cSrcweir
210cdf0e10cSrcweir mnParagraphs = AddNotes(rData, rVisRect, sal_False, maMarks);
211cdf0e10cSrcweir mnParagraphs += AddNotes(rData, rVisRect, sal_True, maNotes);
212cdf0e10cSrcweir }
213cdf0e10cSrcweir }
214cdf0e10cSrcweir
GetChildsCount() const215cdf0e10cSrcweir sal_Int32 ScNotesChilds::GetChildsCount() const
216cdf0e10cSrcweir {
217cdf0e10cSrcweir return mnParagraphs;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir
220cdf0e10cSrcweir struct ScParaFound
221cdf0e10cSrcweir {
222cdf0e10cSrcweir sal_Int32 mnIndex;
ScParaFoundScParaFound223cdf0e10cSrcweir ScParaFound(sal_Int32 nIndex) : mnIndex(nIndex) {}
operator ()ScParaFound224cdf0e10cSrcweir sal_Bool operator() (const ScAccNote& rNote)
225cdf0e10cSrcweir {
226cdf0e10cSrcweir sal_Bool bResult(sal_False);
227cdf0e10cSrcweir if (rNote.mnParaCount > mnIndex)
228cdf0e10cSrcweir bResult = sal_True;
229cdf0e10cSrcweir else
230cdf0e10cSrcweir mnIndex -= rNote.mnParaCount;
231cdf0e10cSrcweir return bResult;
232cdf0e10cSrcweir }
233cdf0e10cSrcweir };
234cdf0e10cSrcweir
GetChild(sal_Int32 nIndex) const235cdf0e10cSrcweir uno::Reference<XAccessible> ScNotesChilds::GetChild(sal_Int32 nIndex) const
236cdf0e10cSrcweir {
237cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible;
238cdf0e10cSrcweir
239cdf0e10cSrcweir if (nIndex < mnParagraphs)
240cdf0e10cSrcweir {
241cdf0e10cSrcweir if (nIndex < static_cast<sal_Int32>(maMarks.size()))
242cdf0e10cSrcweir {
243cdf0e10cSrcweir ScAccNotes::iterator aEndItr = maMarks.end();
244cdf0e10cSrcweir ScParaFound aParaFound(nIndex);
245cdf0e10cSrcweir ScAccNotes::iterator aItr = std::find_if(maMarks.begin(), aEndItr, aParaFound);
246cdf0e10cSrcweir if (aItr != aEndItr)
247cdf0e10cSrcweir {
248cdf0e10cSrcweir DBG_ASSERT((aItr->maNoteCell == maMarks[nIndex].maNoteCell) && (aItr->mbMarkNote == maMarks[nIndex].mbMarkNote), "wrong note found");
249cdf0e10cSrcweir }
250cdf0e10cSrcweir else
251cdf0e10cSrcweir {
252cdf0e10cSrcweir DBG_ERRORFILE("wrong note found");
253cdf0e10cSrcweir }
254cdf0e10cSrcweir if (!aItr->mpTextHelper)
255cdf0e10cSrcweir aItr->mpTextHelper = CreateTextHelper(maMarks[nIndex].maNoteText, maMarks[nIndex].maRect, maMarks[nIndex].maNoteCell, maMarks[nIndex].mbMarkNote, nIndex + mnOffset); // the marks are the first and every mark has only one paragraph
256cdf0e10cSrcweir xAccessible = aItr->mpTextHelper->GetChild(aParaFound.mnIndex + aItr->mpTextHelper->GetStartIndex());
257cdf0e10cSrcweir }
258cdf0e10cSrcweir else
259cdf0e10cSrcweir {
260cdf0e10cSrcweir nIndex -= maMarks.size();
261cdf0e10cSrcweir ScAccNotes::iterator aEndItr = maNotes.end();
262cdf0e10cSrcweir ScParaFound aParaFound(nIndex);
263cdf0e10cSrcweir ScAccNotes::iterator aItr = std::find_if(maNotes.begin(), aEndItr, aParaFound);
264cdf0e10cSrcweir if (aEndItr != aItr)
265cdf0e10cSrcweir {
266cdf0e10cSrcweir if (!aItr->mpTextHelper)
267cdf0e10cSrcweir aItr->mpTextHelper = CreateTextHelper(aItr->maNoteText, aItr->maRect, aItr->maNoteCell, aItr->mbMarkNote, (nIndex - aParaFound.mnIndex) + mnOffset + maMarks.size());
268cdf0e10cSrcweir xAccessible = aItr->mpTextHelper->GetChild(aParaFound.mnIndex + aItr->mpTextHelper->GetStartIndex());
269cdf0e10cSrcweir }
270cdf0e10cSrcweir }
271cdf0e10cSrcweir }
272cdf0e10cSrcweir
273cdf0e10cSrcweir return xAccessible;
274cdf0e10cSrcweir }
275cdf0e10cSrcweir
276cdf0e10cSrcweir struct ScPointFound
277cdf0e10cSrcweir {
278cdf0e10cSrcweir Rectangle maPoint;
279cdf0e10cSrcweir sal_Int32 mnParagraphs;
ScPointFoundScPointFound280cdf0e10cSrcweir ScPointFound(const Point& rPoint) : maPoint(rPoint, Size(0, 0)), mnParagraphs(0) {}
operator ()ScPointFound281cdf0e10cSrcweir sal_Bool operator() (const ScAccNote& rNote)
282cdf0e10cSrcweir {
283cdf0e10cSrcweir sal_Bool bResult(sal_False);
284cdf0e10cSrcweir if (maPoint.IsInside(rNote.maRect))
285cdf0e10cSrcweir bResult = sal_True;
286cdf0e10cSrcweir else
287cdf0e10cSrcweir mnParagraphs += rNote.mnParaCount;
288cdf0e10cSrcweir return bResult;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir };
291cdf0e10cSrcweir
GetAt(const awt::Point & rPoint) const292cdf0e10cSrcweir uno::Reference<XAccessible> ScNotesChilds::GetAt(const awt::Point& rPoint) const
293cdf0e10cSrcweir {
294cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible;
295cdf0e10cSrcweir
296cdf0e10cSrcweir ScPointFound aPointFound(Point(rPoint.X, rPoint.Y));
297cdf0e10cSrcweir
298cdf0e10cSrcweir ScAccNotes::iterator aEndItr = maMarks.end();
299cdf0e10cSrcweir ScAccNotes::iterator aItr = std::find_if(maMarks.begin(), aEndItr, aPointFound);
300cdf0e10cSrcweir if (aEndItr == aItr)
301cdf0e10cSrcweir {
302cdf0e10cSrcweir aEndItr = maNotes.end();
303cdf0e10cSrcweir aItr = std::find_if(maNotes.begin(), aEndItr, aPointFound);
304cdf0e10cSrcweir }
305cdf0e10cSrcweir if (aEndItr != aItr)
306cdf0e10cSrcweir {
307cdf0e10cSrcweir if (!aItr->mpTextHelper)
308cdf0e10cSrcweir aItr->mpTextHelper = CreateTextHelper(aItr->maNoteText, aItr->maRect, aItr->maNoteCell, aItr->mbMarkNote, aPointFound.mnParagraphs + mnOffset);
309cdf0e10cSrcweir xAccessible = aItr->mpTextHelper->GetAt(rPoint);
310cdf0e10cSrcweir }
311cdf0e10cSrcweir
312cdf0e10cSrcweir return xAccessible;
313cdf0e10cSrcweir }
314cdf0e10cSrcweir
CompareCell(const ScAddress & aCell1,const ScAddress & aCell2)315cdf0e10cSrcweir sal_Int8 ScNotesChilds::CompareCell(const ScAddress& aCell1, const ScAddress& aCell2)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir DBG_ASSERT(aCell1.Tab() == aCell2.Tab(), "the notes should be on the same table");
318cdf0e10cSrcweir sal_Int8 nResult(0);
319cdf0e10cSrcweir if (aCell1 != aCell2)
320cdf0e10cSrcweir {
321cdf0e10cSrcweir if (aCell1.Row() == aCell2.Row())
322cdf0e10cSrcweir nResult = (aCell1.Col() < aCell2.Col()) ? -1 : 1;
323cdf0e10cSrcweir else
324cdf0e10cSrcweir nResult = (aCell1.Row() < aCell2.Row()) ? -1 : 1;
325cdf0e10cSrcweir }
326cdf0e10cSrcweir return nResult;
327cdf0e10cSrcweir }
328cdf0e10cSrcweir
CollectChilds(const ScAccNote & rNote,ScXAccList & rList)329cdf0e10cSrcweir void ScNotesChilds::CollectChilds(const ScAccNote& rNote, ScXAccList& rList)
330cdf0e10cSrcweir {
331cdf0e10cSrcweir if (rNote.mpTextHelper)
332cdf0e10cSrcweir for (sal_Int32 i = 0; i < rNote.mnParaCount; ++i)
333cdf0e10cSrcweir rList.push_back(rNote.mpTextHelper->GetChild(i + rNote.mpTextHelper->GetStartIndex()));
334cdf0e10cSrcweir }
335cdf0e10cSrcweir
CheckChanges(const ScPreviewLocationData & rData,const Rectangle & rVisRect,sal_Bool bMark,ScAccNotes & rOldNotes,ScAccNotes & rNewNotes,ScXAccList & rOldParas,ScXAccList & rNewParas)336cdf0e10cSrcweir sal_Int32 ScNotesChilds::CheckChanges(const ScPreviewLocationData& rData,
337cdf0e10cSrcweir const Rectangle& rVisRect, sal_Bool bMark, ScAccNotes& rOldNotes,
338cdf0e10cSrcweir ScAccNotes& rNewNotes, ScXAccList& rOldParas, ScXAccList& rNewParas)
339cdf0e10cSrcweir {
340cdf0e10cSrcweir sal_Int32 nCount = rData.GetNoteCountInRange(rVisRect, bMark);
341cdf0e10cSrcweir
342cdf0e10cSrcweir rNewNotes.reserve(nCount);
343cdf0e10cSrcweir
344cdf0e10cSrcweir sal_Int32 nParagraphs(0);
345cdf0e10cSrcweir ScDocument* pDoc = GetDocument();
346cdf0e10cSrcweir if (pDoc)
347cdf0e10cSrcweir {
348cdf0e10cSrcweir ScAccNote aNote;
349cdf0e10cSrcweir aNote.mbMarkNote = bMark;
350cdf0e10cSrcweir if (bMark)
351cdf0e10cSrcweir aNote.mnParaCount = 1;
352cdf0e10cSrcweir ScAccNotes::iterator aItr = rOldNotes.begin();
353cdf0e10cSrcweir ScAccNotes::iterator aEndItr = rOldNotes.end();
354cdf0e10cSrcweir sal_Bool bAddNote(sal_False);
355cdf0e10cSrcweir for (sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex)
356cdf0e10cSrcweir {
357cdf0e10cSrcweir if (rData.GetNoteInRange(rVisRect, nIndex, bMark, aNote.maNoteCell, aNote.maRect))
358cdf0e10cSrcweir {
359cdf0e10cSrcweir if (bMark)
360cdf0e10cSrcweir {
361cdf0e10cSrcweir // Document not needed, because only the cell address, but not the tablename is needed
362cdf0e10cSrcweir aNote.maNoteCell.Format( aNote.maNoteText, SCA_VALID, NULL );
363cdf0e10cSrcweir }
364cdf0e10cSrcweir else
365cdf0e10cSrcweir {
366cdf0e10cSrcweir if( ScPostIt* pNote = pDoc->GetNote( aNote.maNoteCell ) )
367cdf0e10cSrcweir aNote.maNoteText = pNote->GetText();
368cdf0e10cSrcweir }
369cdf0e10cSrcweir
370cdf0e10cSrcweir sal_Int8 nCompare(-1); // if there are no more old childs it is always a new one
371cdf0e10cSrcweir if (aItr != aEndItr)
372cdf0e10cSrcweir nCompare = CompareCell(aNote.maNoteCell, aItr->maNoteCell);
373cdf0e10cSrcweir if (nCompare == 0)
374cdf0e10cSrcweir {
375cdf0e10cSrcweir if (aNote.maNoteText == aItr->maNoteText)
376cdf0e10cSrcweir {
377cdf0e10cSrcweir aNote.mpTextHelper = aItr->mpTextHelper;
378cdf0e10cSrcweir if (aNote.maRect != aItr->maRect) //neue VisArea setzen
379cdf0e10cSrcweir {
380cdf0e10cSrcweir aNote.mpTextHelper->SetOffset(aNote.maRect.TopLeft());
381cdf0e10cSrcweir aNote.mpTextHelper->UpdateChildren();
382cdf0e10cSrcweir //DBG_ASSERT(aItr->maRect.GetSize() == aNote.maRect.GetSize(), "size should be the same, because the text is not changed");
383cdf0e10cSrcweir // could be changed, because only a part of the note is visible
384cdf0e10cSrcweir }
385cdf0e10cSrcweir }
386cdf0e10cSrcweir else
387cdf0e10cSrcweir {
388cdf0e10cSrcweir aNote.mpTextHelper = CreateTextHelper(aNote.maNoteText, aNote.maRect, aNote.maNoteCell, aNote.mbMarkNote, nParagraphs + mnOffset);
389cdf0e10cSrcweir if (aNote.mpTextHelper)
390cdf0e10cSrcweir aNote.mnParaCount = aNote.mpTextHelper->GetChildCount();
391cdf0e10cSrcweir // collect removed childs
392cdf0e10cSrcweir CollectChilds(*aItr, rOldParas);
393cdf0e10cSrcweir DELETEZ(aItr->mpTextHelper);
394cdf0e10cSrcweir // collect new childs
395cdf0e10cSrcweir CollectChilds(aNote, rNewParas);
396cdf0e10cSrcweir }
397cdf0e10cSrcweir bAddNote = sal_True;
398cdf0e10cSrcweir // not necessary, because this branch should not be reached if it is the end
399cdf0e10cSrcweir //if (aItr != aEndItr)
400cdf0e10cSrcweir ++aItr;
401cdf0e10cSrcweir }
402cdf0e10cSrcweir else if (nCompare < 0)
403cdf0e10cSrcweir {
404cdf0e10cSrcweir aNote.mpTextHelper = CreateTextHelper(aNote.maNoteText, aNote.maRect, aNote.maNoteCell, aNote.mbMarkNote, nParagraphs + mnOffset);
405cdf0e10cSrcweir if (aNote.mpTextHelper)
406cdf0e10cSrcweir aNote.mnParaCount = aNote.mpTextHelper->GetChildCount();
407cdf0e10cSrcweir // collect new childs
408cdf0e10cSrcweir CollectChilds(aNote, rNewParas);
409cdf0e10cSrcweir bAddNote = sal_True;
410cdf0e10cSrcweir }
411cdf0e10cSrcweir else
412cdf0e10cSrcweir {
413cdf0e10cSrcweir // collect removed childs
414cdf0e10cSrcweir CollectChilds(*aItr, rOldParas);
415cdf0e10cSrcweir DELETEZ(aItr->mpTextHelper);
416cdf0e10cSrcweir
417cdf0e10cSrcweir // no note to add
418cdf0e10cSrcweir // not necessary, because this branch should not be reached if it is the end
419cdf0e10cSrcweir //if (aItr != aEndItr)
420cdf0e10cSrcweir ++aItr;
421cdf0e10cSrcweir }
422cdf0e10cSrcweir if (bAddNote)
423cdf0e10cSrcweir {
424cdf0e10cSrcweir nParagraphs += aNote.mnParaCount;
425cdf0e10cSrcweir rNewNotes.push_back(aNote);
426cdf0e10cSrcweir bAddNote = sal_False;
427cdf0e10cSrcweir }
428cdf0e10cSrcweir }
429cdf0e10cSrcweir }
430cdf0e10cSrcweir }
431cdf0e10cSrcweir return nParagraphs;
432cdf0e10cSrcweir }
433cdf0e10cSrcweir
434cdf0e10cSrcweir struct ScChildGone
435cdf0e10cSrcweir {
436cdf0e10cSrcweir ScAccessibleDocumentPagePreview* mpAccDoc;
ScChildGoneScChildGone437cdf0e10cSrcweir ScChildGone(ScAccessibleDocumentPagePreview* pAccDoc) : mpAccDoc(pAccDoc) {}
operator ()ScChildGone438cdf0e10cSrcweir void operator() (const uno::Reference<XAccessible>& xAccessible) const
439cdf0e10cSrcweir {
440cdf0e10cSrcweir if (mpAccDoc)
441cdf0e10cSrcweir {
442cdf0e10cSrcweir AccessibleEventObject aEvent;
443cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
444cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(mpAccDoc);
445cdf0e10cSrcweir aEvent.OldValue <<= xAccessible;
446cdf0e10cSrcweir
447cdf0e10cSrcweir mpAccDoc->CommitChange(aEvent); // gone child - event
448cdf0e10cSrcweir }
449cdf0e10cSrcweir }
450cdf0e10cSrcweir };
451cdf0e10cSrcweir
452cdf0e10cSrcweir struct ScChildNew
453cdf0e10cSrcweir {
454cdf0e10cSrcweir ScAccessibleDocumentPagePreview* mpAccDoc;
ScChildNewScChildNew455cdf0e10cSrcweir ScChildNew(ScAccessibleDocumentPagePreview* pAccDoc) : mpAccDoc(pAccDoc) {}
operator ()ScChildNew456cdf0e10cSrcweir void operator() (const uno::Reference<XAccessible>& xAccessible) const
457cdf0e10cSrcweir {
458cdf0e10cSrcweir if (mpAccDoc)
459cdf0e10cSrcweir {
460cdf0e10cSrcweir AccessibleEventObject aEvent;
461cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
462cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(mpAccDoc);
463cdf0e10cSrcweir aEvent.NewValue <<= xAccessible;
464cdf0e10cSrcweir
465cdf0e10cSrcweir mpAccDoc->CommitChange(aEvent); // new child - event
466cdf0e10cSrcweir }
467cdf0e10cSrcweir }
468cdf0e10cSrcweir };
469cdf0e10cSrcweir
DataChanged(const Rectangle & rVisRect)470cdf0e10cSrcweir void ScNotesChilds::DataChanged(const Rectangle& rVisRect)
471cdf0e10cSrcweir {
472cdf0e10cSrcweir if (mpViewShell && mpAccDoc)
473cdf0e10cSrcweir {
474cdf0e10cSrcweir ScXAccList aNewParas;
475cdf0e10cSrcweir ScXAccList aOldParas;
476cdf0e10cSrcweir ScAccNotes aNewMarks;
477cdf0e10cSrcweir mnParagraphs = CheckChanges(mpViewShell->GetLocationData(), rVisRect, sal_True, maMarks, aNewMarks, aOldParas, aNewParas);
478cdf0e10cSrcweir maMarks = aNewMarks;
479cdf0e10cSrcweir ScAccNotes aNewNotes;
480cdf0e10cSrcweir mnParagraphs += CheckChanges(mpViewShell->GetLocationData(), rVisRect, sal_False, maNotes, aNewNotes, aOldParas, aNewParas);
481cdf0e10cSrcweir maNotes = aNewNotes;
482cdf0e10cSrcweir
483cdf0e10cSrcweir std::for_each(aOldParas.begin(), aOldParas.end(), ScChildGone(mpAccDoc));
484cdf0e10cSrcweir std::for_each(aNewParas.begin(), aNewParas.end(), ScChildNew(mpAccDoc));
485cdf0e10cSrcweir }
486cdf0e10cSrcweir }
487cdf0e10cSrcweir
488cdf0e10cSrcweir struct ScChangeOffset
489cdf0e10cSrcweir {
490cdf0e10cSrcweir sal_Int32 mnDiff;
ScChangeOffsetScChangeOffset491cdf0e10cSrcweir ScChangeOffset(sal_Int32 nDiff) : mnDiff(nDiff) {}
operator ()ScChangeOffset492cdf0e10cSrcweir void operator() (const ScAccNote& rNote)
493cdf0e10cSrcweir {
494cdf0e10cSrcweir if (rNote.mpTextHelper)
495cdf0e10cSrcweir rNote.mpTextHelper->SetStartIndex(rNote.mpTextHelper->GetStartIndex() + mnDiff);
496cdf0e10cSrcweir }
497cdf0e10cSrcweir };
498cdf0e10cSrcweir
SetOffset(sal_Int32 nNewOffset)499cdf0e10cSrcweir void ScNotesChilds::SetOffset(sal_Int32 nNewOffset)
500cdf0e10cSrcweir {
501cdf0e10cSrcweir sal_Int32 nDiff(nNewOffset - mnOffset);
502cdf0e10cSrcweir if (nDiff != 0)
503cdf0e10cSrcweir {
504cdf0e10cSrcweir std::for_each(maMarks.begin(), maMarks.end(), ScChangeOffset(nDiff));
505cdf0e10cSrcweir std::for_each(maNotes.begin(), maNotes.end(), ScChangeOffset(nDiff));
506cdf0e10cSrcweir mnOffset = nNewOffset;
507cdf0e10cSrcweir }
508cdf0e10cSrcweir }
509cdf0e10cSrcweir
GetDocument() const510cdf0e10cSrcweir inline ScDocument* ScNotesChilds::GetDocument() const
511cdf0e10cSrcweir {
512cdf0e10cSrcweir ScDocument* pDoc = NULL;
513cdf0e10cSrcweir if (mpViewShell)
514cdf0e10cSrcweir pDoc = mpViewShell->GetDocument();
515cdf0e10cSrcweir return pDoc;
516cdf0e10cSrcweir }
517cdf0e10cSrcweir
518cdf0e10cSrcweir class ScIAccessibleViewForwarder : public ::accessibility::IAccessibleViewForwarder
519cdf0e10cSrcweir {
520cdf0e10cSrcweir public:
521cdf0e10cSrcweir ScIAccessibleViewForwarder();
522cdf0e10cSrcweir ScIAccessibleViewForwarder(ScPreviewShell* pViewShell,
523cdf0e10cSrcweir ScAccessibleDocumentPagePreview* pAccDoc,
524cdf0e10cSrcweir const MapMode& aMapMode);
525cdf0e10cSrcweir ~ScIAccessibleViewForwarder();
526cdf0e10cSrcweir
527cdf0e10cSrcweir ///===== IAccessibleViewForwarder ========================================
528cdf0e10cSrcweir
529cdf0e10cSrcweir virtual sal_Bool IsValid (void) const;
530cdf0e10cSrcweir virtual Rectangle GetVisibleArea() const;
531cdf0e10cSrcweir virtual Point LogicToPixel (const Point& rPoint) const;
532cdf0e10cSrcweir virtual Size LogicToPixel (const Size& rSize) const;
533cdf0e10cSrcweir virtual Point PixelToLogic (const Point& rPoint) const;
534cdf0e10cSrcweir virtual Size PixelToLogic (const Size& rSize) const;
535cdf0e10cSrcweir
536cdf0e10cSrcweir private:
537cdf0e10cSrcweir ScPreviewShell* mpViewShell;
538cdf0e10cSrcweir ScAccessibleDocumentPagePreview* mpAccDoc;
539cdf0e10cSrcweir MapMode maMapMode;
540cdf0e10cSrcweir sal_Bool mbValid;
541cdf0e10cSrcweir };
542cdf0e10cSrcweir
ScIAccessibleViewForwarder()543cdf0e10cSrcweir ScIAccessibleViewForwarder::ScIAccessibleViewForwarder()
544cdf0e10cSrcweir : mbValid(sal_False)
545cdf0e10cSrcweir {
546cdf0e10cSrcweir }
547cdf0e10cSrcweir
ScIAccessibleViewForwarder(ScPreviewShell * pViewShell,ScAccessibleDocumentPagePreview * pAccDoc,const MapMode & aMapMode)548cdf0e10cSrcweir ScIAccessibleViewForwarder::ScIAccessibleViewForwarder(ScPreviewShell* pViewShell,
549cdf0e10cSrcweir ScAccessibleDocumentPagePreview* pAccDoc,
550cdf0e10cSrcweir const MapMode& aMapMode)
551cdf0e10cSrcweir : mpViewShell(pViewShell),
552cdf0e10cSrcweir mpAccDoc(pAccDoc),
553cdf0e10cSrcweir maMapMode(aMapMode),
554cdf0e10cSrcweir mbValid(sal_True)
555cdf0e10cSrcweir {
556cdf0e10cSrcweir }
557cdf0e10cSrcweir
~ScIAccessibleViewForwarder()558cdf0e10cSrcweir ScIAccessibleViewForwarder::~ScIAccessibleViewForwarder()
559cdf0e10cSrcweir {
560cdf0e10cSrcweir }
561cdf0e10cSrcweir
562cdf0e10cSrcweir ///===== IAccessibleViewForwarder ========================================
563cdf0e10cSrcweir
IsValid(void) const564cdf0e10cSrcweir sal_Bool ScIAccessibleViewForwarder::IsValid (void) const
565cdf0e10cSrcweir {
566cdf0e10cSrcweir ScUnoGuard aGuard;
567cdf0e10cSrcweir return mbValid;
568cdf0e10cSrcweir }
569cdf0e10cSrcweir
GetVisibleArea() const570cdf0e10cSrcweir Rectangle ScIAccessibleViewForwarder::GetVisibleArea() const
571cdf0e10cSrcweir {
572cdf0e10cSrcweir ScUnoGuard aGuard;
573cdf0e10cSrcweir Rectangle aVisRect;
574cdf0e10cSrcweir Window* pWin = mpViewShell->GetWindow();
575cdf0e10cSrcweir if (pWin)
576cdf0e10cSrcweir {
577cdf0e10cSrcweir aVisRect.SetSize(pWin->GetOutputSizePixel());
578cdf0e10cSrcweir aVisRect.SetPos(Point(0, 0));
579cdf0e10cSrcweir
580cdf0e10cSrcweir aVisRect = pWin->PixelToLogic(aVisRect, maMapMode);
581cdf0e10cSrcweir }
582cdf0e10cSrcweir
583cdf0e10cSrcweir return aVisRect;
584cdf0e10cSrcweir }
585cdf0e10cSrcweir
LogicToPixel(const Point & rPoint) const586cdf0e10cSrcweir Point ScIAccessibleViewForwarder::LogicToPixel (const Point& rPoint) const
587cdf0e10cSrcweir {
588cdf0e10cSrcweir ScUnoGuard aGuard;
589cdf0e10cSrcweir Point aPoint;
590cdf0e10cSrcweir Window* pWin = mpViewShell->GetWindow();
591cdf0e10cSrcweir if (pWin && mpAccDoc)
592cdf0e10cSrcweir {
593cdf0e10cSrcweir Rectangle aRect(mpAccDoc->GetBoundingBoxOnScreen());
594cdf0e10cSrcweir aPoint = pWin->LogicToPixel(rPoint, maMapMode) + aRect.TopLeft();
595cdf0e10cSrcweir }
596cdf0e10cSrcweir
597cdf0e10cSrcweir return aPoint;
598cdf0e10cSrcweir }
599cdf0e10cSrcweir
LogicToPixel(const Size & rSize) const600cdf0e10cSrcweir Size ScIAccessibleViewForwarder::LogicToPixel (const Size& rSize) const
601cdf0e10cSrcweir {
602cdf0e10cSrcweir ScUnoGuard aGuard;
603cdf0e10cSrcweir Size aSize;
604cdf0e10cSrcweir Window* pWin = mpViewShell->GetWindow();
605cdf0e10cSrcweir if (pWin)
606cdf0e10cSrcweir aSize = pWin->LogicToPixel(rSize, maMapMode);
607cdf0e10cSrcweir return aSize;
608cdf0e10cSrcweir }
609cdf0e10cSrcweir
PixelToLogic(const Point & rPoint) const610cdf0e10cSrcweir Point ScIAccessibleViewForwarder::PixelToLogic (const Point& rPoint) const
611cdf0e10cSrcweir {
612cdf0e10cSrcweir ScUnoGuard aGuard;
613cdf0e10cSrcweir Point aPoint;
614cdf0e10cSrcweir Window* pWin = mpViewShell->GetWindow();
615cdf0e10cSrcweir if (pWin && mpAccDoc)
616cdf0e10cSrcweir {
617cdf0e10cSrcweir Rectangle aRect(mpAccDoc->GetBoundingBoxOnScreen());
618cdf0e10cSrcweir aPoint = pWin->PixelToLogic(rPoint - aRect.TopLeft(), maMapMode);
619cdf0e10cSrcweir }
620cdf0e10cSrcweir return aPoint;
621cdf0e10cSrcweir }
622cdf0e10cSrcweir
PixelToLogic(const Size & rSize) const623cdf0e10cSrcweir Size ScIAccessibleViewForwarder::PixelToLogic (const Size& rSize) const
624cdf0e10cSrcweir {
625cdf0e10cSrcweir ScUnoGuard aGuard;
626cdf0e10cSrcweir Size aSize;
627cdf0e10cSrcweir Window* pWin = mpViewShell->GetWindow();
628cdf0e10cSrcweir if (pWin)
629cdf0e10cSrcweir aSize = pWin->PixelToLogic(rSize, maMapMode);
630cdf0e10cSrcweir return aSize;
631cdf0e10cSrcweir }
632cdf0e10cSrcweir
633cdf0e10cSrcweir struct ScShapeChild
634cdf0e10cSrcweir {
ScShapeChildScShapeChild635cdf0e10cSrcweir ScShapeChild() : mpAccShape(NULL) {}
636cdf0e10cSrcweir ScShapeChild(const ScShapeChild& rOld);
637cdf0e10cSrcweir ~ScShapeChild();
638cdf0e10cSrcweir mutable ::accessibility::AccessibleShape* mpAccShape;
639cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxShape;
640cdf0e10cSrcweir sal_Int32 mnRangeId;
641cdf0e10cSrcweir };
642cdf0e10cSrcweir
ScShapeChild(const ScShapeChild & rOld)643cdf0e10cSrcweir ScShapeChild::ScShapeChild(const ScShapeChild& rOld)
644cdf0e10cSrcweir :
645cdf0e10cSrcweir mpAccShape(rOld.mpAccShape),
646cdf0e10cSrcweir mxShape(rOld.mxShape),
647cdf0e10cSrcweir mnRangeId(rOld.mnRangeId)
648cdf0e10cSrcweir {
649cdf0e10cSrcweir if (mpAccShape)
650cdf0e10cSrcweir mpAccShape->acquire();
651cdf0e10cSrcweir }
652cdf0e10cSrcweir
~ScShapeChild()653cdf0e10cSrcweir ScShapeChild::~ScShapeChild()
654cdf0e10cSrcweir {
655cdf0e10cSrcweir if (mpAccShape)
656cdf0e10cSrcweir {
657cdf0e10cSrcweir mpAccShape->dispose();
658cdf0e10cSrcweir mpAccShape->release();
659cdf0e10cSrcweir }
660cdf0e10cSrcweir }
661cdf0e10cSrcweir
662cdf0e10cSrcweir struct ScShapeChildLess
663cdf0e10cSrcweir {
operator ()ScShapeChildLess664cdf0e10cSrcweir sal_Bool operator()(const ScShapeChild& rChild1, const ScShapeChild& rChild2) const
665cdf0e10cSrcweir {
666cdf0e10cSrcweir sal_Bool bResult(sal_False);
667cdf0e10cSrcweir if (rChild1.mxShape.is() && rChild2.mxShape.is())
668cdf0e10cSrcweir bResult = (rChild1.mxShape.get() < rChild2.mxShape.get());
669cdf0e10cSrcweir return bResult;
670cdf0e10cSrcweir }
671cdf0e10cSrcweir };
672cdf0e10cSrcweir
673cdf0e10cSrcweir typedef std::vector<ScShapeChild> ScShapeChildVec;
674cdf0e10cSrcweir
675cdf0e10cSrcweir struct ScShapeRange
676cdf0e10cSrcweir {
677cdf0e10cSrcweir ScShapeChildVec maBackShapes;
678cdf0e10cSrcweir ScShapeChildVec maForeShapes; // inclusive internal shapes
679cdf0e10cSrcweir ScShapeChildVec maControls;
680cdf0e10cSrcweir Rectangle maPixelRect;
681cdf0e10cSrcweir MapMode maMapMode;
682cdf0e10cSrcweir ScIAccessibleViewForwarder maViewForwarder;
683cdf0e10cSrcweir };
684cdf0e10cSrcweir
685cdf0e10cSrcweir typedef std::vector<ScShapeRange> ScShapeRangeVec;
686cdf0e10cSrcweir
687cdf0e10cSrcweir class ScShapeChilds : public SfxListener,
688cdf0e10cSrcweir public ::accessibility::IAccessibleParent
689cdf0e10cSrcweir {
690cdf0e10cSrcweir public:
691cdf0e10cSrcweir ScShapeChilds(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview* pAccDoc);
692cdf0e10cSrcweir ~ScShapeChilds();
693cdf0e10cSrcweir
694cdf0e10cSrcweir ///===== SfxListener =====================================================
695cdf0e10cSrcweir
696cdf0e10cSrcweir virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
697cdf0e10cSrcweir
698cdf0e10cSrcweir ///===== IAccessibleParent ==============================================
699cdf0e10cSrcweir
700cdf0e10cSrcweir virtual sal_Bool ReplaceChild (
701cdf0e10cSrcweir ::accessibility::AccessibleShape* pCurrentChild,
702cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
703cdf0e10cSrcweir const long _nIndex,
704cdf0e10cSrcweir const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo
705cdf0e10cSrcweir ) throw (::com::sun::star::uno::RuntimeException);
706cdf0e10cSrcweir
707cdf0e10cSrcweir ///===== Internal ========================================================
708cdf0e10cSrcweir
709cdf0e10cSrcweir void Init();
710cdf0e10cSrcweir
711cdf0e10cSrcweir sal_Int32 GetBackShapeCount() const;
712cdf0e10cSrcweir uno::Reference<XAccessible> GetBackShape(sal_Int32 nIndex) const;
713cdf0e10cSrcweir sal_Int32 GetForeShapeCount() const;
714cdf0e10cSrcweir uno::Reference<XAccessible> GetForeShape(sal_Int32 nIndex) const;
715cdf0e10cSrcweir sal_Int32 GetControlCount() const;
716cdf0e10cSrcweir uno::Reference<XAccessible> GetControl(sal_Int32 nIndex) const;
717cdf0e10cSrcweir uno::Reference<XAccessible> GetForegroundShapeAt(const awt::Point& rPoint) const; // inclusive controls
718cdf0e10cSrcweir uno::Reference<XAccessible> GetBackgroundShapeAt(const awt::Point& rPoint) const;
719cdf0e10cSrcweir
720cdf0e10cSrcweir void DataChanged();
721cdf0e10cSrcweir void VisAreaChanged() const;
722cdf0e10cSrcweir
723cdf0e10cSrcweir void SetDrawBroadcaster();
724cdf0e10cSrcweir private:
725cdf0e10cSrcweir ScAccessibleDocumentPagePreview* mpAccDoc;
726cdf0e10cSrcweir ScPreviewShell* mpViewShell;
727cdf0e10cSrcweir ScShapeRangeVec maShapeRanges;
728cdf0e10cSrcweir
729cdf0e10cSrcweir void FindChanged(ScShapeChildVec& aOld, ScShapeChildVec& aNew) const;
730cdf0e10cSrcweir void FindChanged(ScShapeRange& aOld, ScShapeRange& aNew) const;
731cdf0e10cSrcweir ::accessibility::AccessibleShape* GetAccShape(const ScShapeChild& rShape) const;
732cdf0e10cSrcweir ::accessibility::AccessibleShape* GetAccShape(const ScShapeChildVec& rShapes, sal_Int32 nIndex) const;
733cdf0e10cSrcweir void FillShapes(const Rectangle& aPixelPaintRect, const MapMode& aMapMode, sal_uInt8 nRangeId);
734cdf0e10cSrcweir //UNUSED2008-05 sal_Bool FindShape(ScShapeChildVec& rShapes, const uno::Reference <drawing::XShape>& xShape, ScShapeChildVec::iterator& rItr) const;
735cdf0e10cSrcweir
736cdf0e10cSrcweir // void AddShape(const uno::Reference<drawing::XShape>& xShape, SdrLayerID aLayerID);
737cdf0e10cSrcweir // void RemoveShape(const uno::Reference<drawing::XShape>& xShape, SdrLayerID aLayerID);
738cdf0e10cSrcweir SdrPage* GetDrawPage() const;
739cdf0e10cSrcweir };
740cdf0e10cSrcweir
ScShapeChilds(ScPreviewShell * pViewShell,ScAccessibleDocumentPagePreview * pAccDoc)741cdf0e10cSrcweir ScShapeChilds::ScShapeChilds(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview* pAccDoc)
742cdf0e10cSrcweir :
743cdf0e10cSrcweir mpAccDoc(pAccDoc),
744cdf0e10cSrcweir mpViewShell(pViewShell),
745cdf0e10cSrcweir maShapeRanges(SC_PREVIEW_MAXRANGES)
746cdf0e10cSrcweir {
747cdf0e10cSrcweir if (pViewShell)
748cdf0e10cSrcweir {
749cdf0e10cSrcweir SfxBroadcaster* pDrawBC = pViewShell->GetDocument()->GetDrawBroadcaster();
750cdf0e10cSrcweir if (pDrawBC)
751cdf0e10cSrcweir StartListening(*pDrawBC);
752cdf0e10cSrcweir }
753cdf0e10cSrcweir }
754cdf0e10cSrcweir
~ScShapeChilds()755cdf0e10cSrcweir ScShapeChilds::~ScShapeChilds()
756cdf0e10cSrcweir {
757cdf0e10cSrcweir if (mpViewShell)
758cdf0e10cSrcweir {
759cdf0e10cSrcweir SfxBroadcaster* pDrawBC = mpViewShell->GetDocument()->GetDrawBroadcaster();
760cdf0e10cSrcweir if (pDrawBC)
761cdf0e10cSrcweir EndListening(*pDrawBC);
762cdf0e10cSrcweir }
763cdf0e10cSrcweir }
764cdf0e10cSrcweir
SetDrawBroadcaster()765cdf0e10cSrcweir void ScShapeChilds::SetDrawBroadcaster()
766cdf0e10cSrcweir {
767cdf0e10cSrcweir if (mpViewShell)
768cdf0e10cSrcweir {
769cdf0e10cSrcweir SfxBroadcaster* pDrawBC = mpViewShell->GetDocument()->GetDrawBroadcaster();
770cdf0e10cSrcweir if (pDrawBC)
771cdf0e10cSrcweir StartListening(*pDrawBC, sal_True);
772cdf0e10cSrcweir }
773cdf0e10cSrcweir }
774cdf0e10cSrcweir
Notify(SfxBroadcaster &,const SfxHint & rHint)775cdf0e10cSrcweir void ScShapeChilds::Notify(SfxBroadcaster&, const SfxHint& rHint)
776cdf0e10cSrcweir {
777cdf0e10cSrcweir if ( rHint.ISA( SdrHint ) )
778cdf0e10cSrcweir {
779cdf0e10cSrcweir const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
780cdf0e10cSrcweir if (pSdrHint)
781cdf0e10cSrcweir {
782cdf0e10cSrcweir SdrObject* pObj = const_cast<SdrObject*>(pSdrHint->GetObject());
783cdf0e10cSrcweir if (pObj && (pObj->GetPage() == GetDrawPage()))
784cdf0e10cSrcweir {
785cdf0e10cSrcweir switch (pSdrHint->GetKind())
786cdf0e10cSrcweir {
787cdf0e10cSrcweir case HINT_OBJCHG : // Objekt geaendert
788cdf0e10cSrcweir {
789cdf0e10cSrcweir }
790cdf0e10cSrcweir break;
791cdf0e10cSrcweir // no longer necessary
792cdf0e10cSrcweir /* case HINT_OBJINSERTED : // Neues Zeichenobjekt eingefuegt
793cdf0e10cSrcweir {
794cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY);
795cdf0e10cSrcweir if (xShape.is())
796cdf0e10cSrcweir AddShape(xShape, pObj->GetLayer());
797cdf0e10cSrcweir }
798cdf0e10cSrcweir break;
799cdf0e10cSrcweir case HINT_OBJREMOVED : // Zeichenobjekt aus Liste entfernt
800cdf0e10cSrcweir {
801cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY);
802cdf0e10cSrcweir if (xShape.is())
803cdf0e10cSrcweir RemoveShape(xShape, pObj->GetLayer());
804cdf0e10cSrcweir }
805cdf0e10cSrcweir break;*/
806cdf0e10cSrcweir default :
807cdf0e10cSrcweir {
808cdf0e10cSrcweir // other events are not interesting
809cdf0e10cSrcweir }
810cdf0e10cSrcweir break;
811cdf0e10cSrcweir }
812cdf0e10cSrcweir }
813cdf0e10cSrcweir }
814cdf0e10cSrcweir }
815cdf0e10cSrcweir }
816cdf0e10cSrcweir
FindChanged(ScShapeChildVec & rOld,ScShapeChildVec & rNew) const817cdf0e10cSrcweir void ScShapeChilds::FindChanged(ScShapeChildVec& rOld, ScShapeChildVec& rNew) const
818cdf0e10cSrcweir {
819cdf0e10cSrcweir ScShapeChildVec::iterator aOldItr = rOld.begin();
820cdf0e10cSrcweir ScShapeChildVec::iterator aOldEnd = rOld.end();
821cdf0e10cSrcweir ScShapeChildVec::const_iterator aNewItr = rNew.begin();
822cdf0e10cSrcweir ScShapeChildVec::const_iterator aNewEnd = rNew.begin();
823cdf0e10cSrcweir uno::Reference<XAccessible> xAcc;
824cdf0e10cSrcweir while ((aNewItr != aNewEnd) && (aOldItr != aOldEnd))
825cdf0e10cSrcweir {
826cdf0e10cSrcweir if (aNewItr->mxShape.get() == aOldItr->mxShape.get())
827cdf0e10cSrcweir {
828cdf0e10cSrcweir ++aOldItr;
829cdf0e10cSrcweir ++aNewItr;
830cdf0e10cSrcweir }
831cdf0e10cSrcweir else if (aNewItr->mxShape.get() < aOldItr->mxShape.get())
832cdf0e10cSrcweir {
833cdf0e10cSrcweir xAcc = GetAccShape(*aNewItr);
834cdf0e10cSrcweir AccessibleEventObject aEvent;
835cdf0e10cSrcweir aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
836cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
837cdf0e10cSrcweir aEvent.NewValue <<= xAcc;
838cdf0e10cSrcweir mpAccDoc->CommitChange(aEvent);
839cdf0e10cSrcweir ++aNewItr;
840cdf0e10cSrcweir }
841cdf0e10cSrcweir else
842cdf0e10cSrcweir {
843cdf0e10cSrcweir xAcc = GetAccShape(*aOldItr);
844cdf0e10cSrcweir AccessibleEventObject aEvent;
845cdf0e10cSrcweir aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
846cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
847cdf0e10cSrcweir aEvent.OldValue <<= xAcc;
848cdf0e10cSrcweir mpAccDoc->CommitChange(aEvent);
849cdf0e10cSrcweir ++aOldItr;
850cdf0e10cSrcweir }
851cdf0e10cSrcweir }
852cdf0e10cSrcweir while (aOldItr != aOldEnd)
853cdf0e10cSrcweir {
854cdf0e10cSrcweir xAcc = GetAccShape(*aOldItr);
855cdf0e10cSrcweir AccessibleEventObject aEvent;
856cdf0e10cSrcweir aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
857cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
858cdf0e10cSrcweir aEvent.OldValue <<= xAcc;
859cdf0e10cSrcweir mpAccDoc->CommitChange(aEvent);
860cdf0e10cSrcweir ++aOldItr;
861cdf0e10cSrcweir }
862cdf0e10cSrcweir while (aNewItr != aNewEnd)
863cdf0e10cSrcweir {
864cdf0e10cSrcweir xAcc = GetAccShape(*aNewItr);
865cdf0e10cSrcweir AccessibleEventObject aEvent;
866cdf0e10cSrcweir aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
867cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
868cdf0e10cSrcweir aEvent.NewValue <<= xAcc;
869cdf0e10cSrcweir mpAccDoc->CommitChange(aEvent);
870cdf0e10cSrcweir ++aNewItr;
871cdf0e10cSrcweir }
872cdf0e10cSrcweir }
873cdf0e10cSrcweir
FindChanged(ScShapeRange & rOld,ScShapeRange & rNew) const874cdf0e10cSrcweir void ScShapeChilds::FindChanged(ScShapeRange& rOld, ScShapeRange& rNew) const
875cdf0e10cSrcweir {
876cdf0e10cSrcweir FindChanged(rOld.maBackShapes, rNew.maBackShapes);
877cdf0e10cSrcweir FindChanged(rOld.maForeShapes, rNew.maForeShapes);
878cdf0e10cSrcweir FindChanged(rOld.maControls, rNew.maControls);
879cdf0e10cSrcweir }
880cdf0e10cSrcweir
DataChanged()881cdf0e10cSrcweir void ScShapeChilds::DataChanged()
882cdf0e10cSrcweir {
883cdf0e10cSrcweir ScShapeRangeVec aOldShapeRanges(maShapeRanges);
884cdf0e10cSrcweir maShapeRanges.clear();
885cdf0e10cSrcweir maShapeRanges.resize(SC_PREVIEW_MAXRANGES);
886cdf0e10cSrcweir Init();
887cdf0e10cSrcweir for (sal_Int32 i = 0; i < SC_PREVIEW_MAXRANGES; ++i)
888cdf0e10cSrcweir {
889cdf0e10cSrcweir FindChanged(aOldShapeRanges[i], maShapeRanges[i]);
890cdf0e10cSrcweir }
891cdf0e10cSrcweir }
892cdf0e10cSrcweir
893cdf0e10cSrcweir struct ScVisAreaChanged
894cdf0e10cSrcweir {
895cdf0e10cSrcweir const ScIAccessibleViewForwarder* mpViewForwarder;
ScVisAreaChangedScVisAreaChanged896cdf0e10cSrcweir ScVisAreaChanged(const ScIAccessibleViewForwarder* pViewForwarder) : mpViewForwarder(pViewForwarder) {}
operator ()ScVisAreaChanged897cdf0e10cSrcweir void operator() (const ScShapeChild& rAccShapeData) const
898cdf0e10cSrcweir {
899cdf0e10cSrcweir if (rAccShapeData.mpAccShape)
900cdf0e10cSrcweir {
901cdf0e10cSrcweir rAccShapeData.mpAccShape->ViewForwarderChanged(::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA, mpViewForwarder);
902cdf0e10cSrcweir }
903cdf0e10cSrcweir }
904cdf0e10cSrcweir };
905cdf0e10cSrcweir
VisAreaChanged() const906cdf0e10cSrcweir void ScShapeChilds::VisAreaChanged() const
907cdf0e10cSrcweir {
908cdf0e10cSrcweir ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
909cdf0e10cSrcweir ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
910cdf0e10cSrcweir while (aItr != aEndItr)
911cdf0e10cSrcweir {
912cdf0e10cSrcweir ScVisAreaChanged aVisAreaChanged(&(aItr->maViewForwarder));
913cdf0e10cSrcweir std::for_each(aItr->maBackShapes.begin(), aItr->maBackShapes.end(), aVisAreaChanged);
914cdf0e10cSrcweir std::for_each(aItr->maControls.begin(), aItr->maControls.end(), aVisAreaChanged);
915cdf0e10cSrcweir std::for_each(aItr->maForeShapes.begin(), aItr->maForeShapes.end(), aVisAreaChanged);
916cdf0e10cSrcweir ++aItr;
917cdf0e10cSrcweir }
918cdf0e10cSrcweir }
919cdf0e10cSrcweir
920cdf0e10cSrcweir ///===== IAccessibleParent ==============================================
921cdf0e10cSrcweir
ReplaceChild(::accessibility::AccessibleShape *,const::com::sun::star::uno::Reference<::com::sun::star::drawing::XShape> &,const long,const::accessibility::AccessibleShapeTreeInfo &)922cdf0e10cSrcweir sal_Bool ScShapeChilds::ReplaceChild (::accessibility::AccessibleShape* /* pCurrentChild */,
923cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& /* _rxShape */,
924cdf0e10cSrcweir const long /* _nIndex */, const ::accessibility::AccessibleShapeTreeInfo& /* _rShapeTreeInfo */)
925cdf0e10cSrcweir throw (uno::RuntimeException)
926cdf0e10cSrcweir {
927cdf0e10cSrcweir DBG_ERRORFILE("should not be called in the page preview");
928cdf0e10cSrcweir return sal_False;
929cdf0e10cSrcweir }
930cdf0e10cSrcweir
931cdf0e10cSrcweir ///===== Internal ========================================================
932cdf0e10cSrcweir
Init()933cdf0e10cSrcweir void ScShapeChilds::Init()
934cdf0e10cSrcweir {
935cdf0e10cSrcweir if(mpViewShell)
936cdf0e10cSrcweir {
937cdf0e10cSrcweir const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
938cdf0e10cSrcweir MapMode aMapMode;
939cdf0e10cSrcweir Rectangle aPixelPaintRect;
940cdf0e10cSrcweir sal_uInt8 nRangeId;
941cdf0e10cSrcweir sal_uInt16 nCount(rData.GetDrawRanges());
942cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nCount; ++i)
943cdf0e10cSrcweir {
944cdf0e10cSrcweir rData.GetDrawRange(i, aPixelPaintRect, aMapMode, nRangeId);
945cdf0e10cSrcweir FillShapes(aPixelPaintRect, aMapMode, nRangeId);
946cdf0e10cSrcweir }
947cdf0e10cSrcweir }
948cdf0e10cSrcweir }
949cdf0e10cSrcweir
GetBackShapeCount() const950cdf0e10cSrcweir sal_Int32 ScShapeChilds::GetBackShapeCount() const
951cdf0e10cSrcweir {
952cdf0e10cSrcweir sal_Int32 nCount(0);
953cdf0e10cSrcweir ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
954cdf0e10cSrcweir for ( ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin(); aItr != aEndItr; ++aItr )
955cdf0e10cSrcweir nCount += aItr->maBackShapes.size();
956cdf0e10cSrcweir return nCount;
957cdf0e10cSrcweir }
958cdf0e10cSrcweir
GetBackShape(sal_Int32 nIndex) const959cdf0e10cSrcweir uno::Reference<XAccessible> ScShapeChilds::GetBackShape(sal_Int32 nIndex) const
960cdf0e10cSrcweir {
961cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible;
962cdf0e10cSrcweir ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
963cdf0e10cSrcweir ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
964cdf0e10cSrcweir while ((aItr != aEndItr) && !xAccessible.is())
965cdf0e10cSrcweir {
966cdf0e10cSrcweir sal_Int32 nCount(aItr->maBackShapes.size());
967cdf0e10cSrcweir if(nIndex < nCount)
968cdf0e10cSrcweir xAccessible = GetAccShape(aItr->maBackShapes, nIndex);
969cdf0e10cSrcweir else
970cdf0e10cSrcweir ++aItr;
971cdf0e10cSrcweir nIndex -= nCount;
972cdf0e10cSrcweir }
973cdf0e10cSrcweir
974cdf0e10cSrcweir if (nIndex >= 0)
975cdf0e10cSrcweir throw lang::IndexOutOfBoundsException();
976cdf0e10cSrcweir
977cdf0e10cSrcweir return xAccessible;
978cdf0e10cSrcweir }
979cdf0e10cSrcweir
GetForeShapeCount() const980cdf0e10cSrcweir sal_Int32 ScShapeChilds::GetForeShapeCount() const
981cdf0e10cSrcweir {
982cdf0e10cSrcweir sal_Int32 nCount(0);
983cdf0e10cSrcweir ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
984cdf0e10cSrcweir for ( ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin(); aItr != aEndItr; ++aItr )
985cdf0e10cSrcweir nCount += aItr->maForeShapes.size();
986cdf0e10cSrcweir return nCount;
987cdf0e10cSrcweir }
988cdf0e10cSrcweir
GetForeShape(sal_Int32 nIndex) const989cdf0e10cSrcweir uno::Reference<XAccessible> ScShapeChilds::GetForeShape(sal_Int32 nIndex) const
990cdf0e10cSrcweir {
991cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible;
992cdf0e10cSrcweir ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
993cdf0e10cSrcweir ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
994cdf0e10cSrcweir while ((aItr != aEndItr) && !xAccessible.is())
995cdf0e10cSrcweir {
996cdf0e10cSrcweir sal_Int32 nCount(aItr->maForeShapes.size());
997cdf0e10cSrcweir if(nIndex < nCount)
998cdf0e10cSrcweir xAccessible = GetAccShape(aItr->maForeShapes, nIndex);
999cdf0e10cSrcweir else
1000cdf0e10cSrcweir ++aItr;
1001cdf0e10cSrcweir nIndex -= nCount;
1002cdf0e10cSrcweir }
1003cdf0e10cSrcweir
1004cdf0e10cSrcweir if (nIndex >= 0)
1005cdf0e10cSrcweir throw lang::IndexOutOfBoundsException();
1006cdf0e10cSrcweir
1007cdf0e10cSrcweir return xAccessible;
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir
GetControlCount() const1010cdf0e10cSrcweir sal_Int32 ScShapeChilds::GetControlCount() const
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir sal_Int32 nCount(0);
1013cdf0e10cSrcweir ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
1014cdf0e10cSrcweir for ( ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin(); aItr != aEndItr; ++aItr )
1015cdf0e10cSrcweir nCount += aItr->maControls.size();
1016cdf0e10cSrcweir return nCount;
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir
GetControl(sal_Int32 nIndex) const1019cdf0e10cSrcweir uno::Reference<XAccessible> ScShapeChilds::GetControl(sal_Int32 nIndex) const
1020cdf0e10cSrcweir {
1021cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible;
1022cdf0e10cSrcweir ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
1023cdf0e10cSrcweir ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
1024cdf0e10cSrcweir while ((aItr != aEndItr) && !xAccessible.is())
1025cdf0e10cSrcweir {
1026cdf0e10cSrcweir sal_Int32 nCount(aItr->maControls.size());
1027cdf0e10cSrcweir if(nIndex < nCount)
1028cdf0e10cSrcweir xAccessible = GetAccShape(aItr->maControls, nIndex);
1029cdf0e10cSrcweir else
1030cdf0e10cSrcweir ++aItr;
1031cdf0e10cSrcweir nIndex -= nCount;
1032cdf0e10cSrcweir }
1033cdf0e10cSrcweir
1034cdf0e10cSrcweir if (nIndex >= 0)
1035cdf0e10cSrcweir throw lang::IndexOutOfBoundsException();
1036cdf0e10cSrcweir
1037cdf0e10cSrcweir return xAccessible;
1038cdf0e10cSrcweir }
1039cdf0e10cSrcweir
1040cdf0e10cSrcweir struct ScShapePointFound
1041cdf0e10cSrcweir {
1042cdf0e10cSrcweir Point maPoint;
ScShapePointFoundScShapePointFound1043cdf0e10cSrcweir ScShapePointFound(const awt::Point& rPoint) : maPoint(VCLPoint(rPoint)) {}
operator ()ScShapePointFound1044cdf0e10cSrcweir sal_Bool operator() (const ScShapeChild& rShape)
1045cdf0e10cSrcweir {
1046cdf0e10cSrcweir sal_Bool bResult(sal_False);
1047cdf0e10cSrcweir if ((VCLRectangle(rShape.mpAccShape->getBounds())).IsInside(maPoint))
1048cdf0e10cSrcweir bResult = sal_True;
1049cdf0e10cSrcweir return bResult;
1050cdf0e10cSrcweir }
1051cdf0e10cSrcweir };
1052cdf0e10cSrcweir
GetForegroundShapeAt(const awt::Point & rPoint) const1053cdf0e10cSrcweir uno::Reference<XAccessible> ScShapeChilds::GetForegroundShapeAt(const awt::Point& rPoint) const //inclusive Controls
1054cdf0e10cSrcweir {
1055cdf0e10cSrcweir uno::Reference<XAccessible> xAcc;
1056cdf0e10cSrcweir
1057cdf0e10cSrcweir ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
1058cdf0e10cSrcweir ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
1059cdf0e10cSrcweir while((aItr != aEndItr) && !xAcc.is())
1060cdf0e10cSrcweir {
1061cdf0e10cSrcweir ScShapeChildVec::const_iterator aFindItr = std::find_if(aItr->maForeShapes.begin(), aItr->maForeShapes.end(), ScShapePointFound(rPoint));
1062cdf0e10cSrcweir if (aFindItr != aItr->maForeShapes.end())
1063cdf0e10cSrcweir xAcc = GetAccShape(*aFindItr);
1064cdf0e10cSrcweir else
1065cdf0e10cSrcweir {
1066cdf0e10cSrcweir ScShapeChildVec::const_iterator aCtrlItr = std::find_if(aItr->maControls.begin(), aItr->maControls.end(), ScShapePointFound(rPoint));
1067cdf0e10cSrcweir if (aCtrlItr != aItr->maControls.end())
1068cdf0e10cSrcweir xAcc = GetAccShape(*aCtrlItr);
1069cdf0e10cSrcweir else
1070cdf0e10cSrcweir ++aItr;
1071cdf0e10cSrcweir }
1072cdf0e10cSrcweir }
1073cdf0e10cSrcweir
1074cdf0e10cSrcweir return xAcc;
1075cdf0e10cSrcweir }
1076cdf0e10cSrcweir
GetBackgroundShapeAt(const awt::Point & rPoint) const1077cdf0e10cSrcweir uno::Reference<XAccessible> ScShapeChilds::GetBackgroundShapeAt(const awt::Point& rPoint) const
1078cdf0e10cSrcweir {
1079cdf0e10cSrcweir uno::Reference<XAccessible> xAcc;
1080cdf0e10cSrcweir
1081cdf0e10cSrcweir ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
1082cdf0e10cSrcweir ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
1083cdf0e10cSrcweir while((aItr != aEndItr) && !xAcc.is())
1084cdf0e10cSrcweir {
1085cdf0e10cSrcweir ScShapeChildVec::const_iterator aFindItr = std::find_if(aItr->maBackShapes.begin(), aItr->maBackShapes.end(), ScShapePointFound(rPoint));
1086cdf0e10cSrcweir if (aFindItr != aItr->maBackShapes.end())
1087cdf0e10cSrcweir xAcc = GetAccShape(*aFindItr);
1088cdf0e10cSrcweir else
1089cdf0e10cSrcweir ++aItr;
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir
1092cdf0e10cSrcweir return xAcc;
1093cdf0e10cSrcweir }
1094cdf0e10cSrcweir
GetAccShape(const ScShapeChild & rShape) const1095cdf0e10cSrcweir ::accessibility::AccessibleShape* ScShapeChilds::GetAccShape(const ScShapeChild& rShape) const
1096cdf0e10cSrcweir {
1097cdf0e10cSrcweir if (!rShape.mpAccShape)
1098cdf0e10cSrcweir {
1099cdf0e10cSrcweir ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance();
1100cdf0e10cSrcweir ::accessibility::AccessibleShapeInfo aShapeInfo(rShape.mxShape, mpAccDoc, const_cast<ScShapeChilds*>(this));
1101cdf0e10cSrcweir
1102cdf0e10cSrcweir if (mpViewShell)
1103cdf0e10cSrcweir {
1104cdf0e10cSrcweir ::accessibility::AccessibleShapeTreeInfo aShapeTreeInfo;
1105cdf0e10cSrcweir aShapeTreeInfo.SetSdrView(mpViewShell->GetPreview()->GetDrawView());
1106cdf0e10cSrcweir aShapeTreeInfo.SetController(NULL);
1107cdf0e10cSrcweir aShapeTreeInfo.SetWindow(mpViewShell->GetWindow());
1108cdf0e10cSrcweir aShapeTreeInfo.SetViewForwarder(&(maShapeRanges[rShape.mnRangeId].maViewForwarder));
1109cdf0e10cSrcweir rShape.mpAccShape = rShapeHandler.CreateAccessibleObject(aShapeInfo, aShapeTreeInfo);
1110cdf0e10cSrcweir if (rShape.mpAccShape)
1111cdf0e10cSrcweir {
1112cdf0e10cSrcweir rShape.mpAccShape->acquire();
1113cdf0e10cSrcweir rShape.mpAccShape->Init();
1114cdf0e10cSrcweir }
1115cdf0e10cSrcweir }
1116cdf0e10cSrcweir }
1117cdf0e10cSrcweir return rShape.mpAccShape;
1118cdf0e10cSrcweir }
1119cdf0e10cSrcweir
GetAccShape(const ScShapeChildVec & rShapes,sal_Int32 nIndex) const1120cdf0e10cSrcweir ::accessibility::AccessibleShape* ScShapeChilds::GetAccShape(const ScShapeChildVec& rShapes, sal_Int32 nIndex) const
1121cdf0e10cSrcweir {
1122cdf0e10cSrcweir return (GetAccShape(rShapes[nIndex]));
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir
FillShapes(const Rectangle & aPixelPaintRect,const MapMode & aMapMode,sal_uInt8 nRangeId)1125cdf0e10cSrcweir void ScShapeChilds::FillShapes(const Rectangle& aPixelPaintRect, const MapMode& aMapMode, sal_uInt8 nRangeId)
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir DBG_ASSERT(nRangeId < maShapeRanges.size(), "this is not a valid range for draw objects");
1128cdf0e10cSrcweir SdrPage* pPage = GetDrawPage();
1129cdf0e10cSrcweir Window* pWin = mpViewShell->GetWindow();
1130cdf0e10cSrcweir if (pPage && pWin)
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir sal_Bool bForeAdded(sal_False);
1133cdf0e10cSrcweir sal_Bool bBackAdded(sal_False);
1134cdf0e10cSrcweir sal_Bool bControlAdded(sal_False);
1135cdf0e10cSrcweir Rectangle aClippedPixelPaintRect(aPixelPaintRect);
1136cdf0e10cSrcweir if (mpAccDoc)
1137cdf0e10cSrcweir {
1138cdf0e10cSrcweir Rectangle aRect2(Point(0,0), mpAccDoc->GetBoundingBoxOnScreen().GetSize());
1139cdf0e10cSrcweir aClippedPixelPaintRect = aPixelPaintRect.GetIntersection(aRect2);
1140cdf0e10cSrcweir }
1141cdf0e10cSrcweir maShapeRanges[nRangeId].maPixelRect = aClippedPixelPaintRect;
1142cdf0e10cSrcweir maShapeRanges[nRangeId].maMapMode = aMapMode;
1143cdf0e10cSrcweir ScIAccessibleViewForwarder aViewForwarder(mpViewShell, mpAccDoc, aMapMode);
1144cdf0e10cSrcweir maShapeRanges[nRangeId].maViewForwarder = aViewForwarder;
1145cdf0e10cSrcweir sal_uInt32 nCount(pPage->GetObjCount());
1146cdf0e10cSrcweir for (sal_uInt32 i = 0; i < nCount; ++i)
1147cdf0e10cSrcweir {
1148cdf0e10cSrcweir SdrObject* pObj = pPage->GetObj(i);
1149cdf0e10cSrcweir if (pObj)
1150cdf0e10cSrcweir {
1151cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape(pObj->getUnoShape(), uno::UNO_QUERY);
1152cdf0e10cSrcweir if (xShape.is())
1153cdf0e10cSrcweir {
1154cdf0e10cSrcweir Rectangle aRect(pWin->LogicToPixel(VCLPoint(xShape->getPosition()), aMapMode), pWin->LogicToPixel(VCLSize(xShape->getSize()), aMapMode));
1155cdf0e10cSrcweir if(!aClippedPixelPaintRect.GetIntersection(aRect).IsEmpty())
1156cdf0e10cSrcweir {
1157cdf0e10cSrcweir ScShapeChild aShape;
1158cdf0e10cSrcweir aShape.mxShape = xShape;
1159cdf0e10cSrcweir aShape.mnRangeId = nRangeId;
1160cdf0e10cSrcweir switch (pObj->GetLayer())
1161cdf0e10cSrcweir {
1162cdf0e10cSrcweir case SC_LAYER_INTERN:
1163cdf0e10cSrcweir case SC_LAYER_FRONT:
1164cdf0e10cSrcweir {
1165cdf0e10cSrcweir maShapeRanges[nRangeId].maForeShapes.push_back(aShape);
1166cdf0e10cSrcweir bForeAdded = sal_True;
1167cdf0e10cSrcweir }
1168cdf0e10cSrcweir break;
1169cdf0e10cSrcweir case SC_LAYER_BACK:
1170cdf0e10cSrcweir {
1171cdf0e10cSrcweir maShapeRanges[nRangeId].maBackShapes.push_back(aShape);
1172cdf0e10cSrcweir bBackAdded = sal_True;
1173cdf0e10cSrcweir }
1174cdf0e10cSrcweir break;
1175cdf0e10cSrcweir case SC_LAYER_CONTROLS:
1176cdf0e10cSrcweir {
1177cdf0e10cSrcweir maShapeRanges[nRangeId].maControls.push_back(aShape);
1178cdf0e10cSrcweir bControlAdded = sal_True;
1179cdf0e10cSrcweir }
1180cdf0e10cSrcweir break;
1181cdf0e10cSrcweir default:
1182cdf0e10cSrcweir {
1183cdf0e10cSrcweir DBG_ERRORFILE("I don't know this layer.");
1184cdf0e10cSrcweir }
1185cdf0e10cSrcweir break;
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir }
1188cdf0e10cSrcweir }
1189cdf0e10cSrcweir }
1190cdf0e10cSrcweir }
1191cdf0e10cSrcweir if (bForeAdded)
1192cdf0e10cSrcweir std::sort(maShapeRanges[nRangeId].maForeShapes.begin(), maShapeRanges[nRangeId].maForeShapes.end(),ScShapeChildLess());
1193cdf0e10cSrcweir if (bBackAdded)
1194cdf0e10cSrcweir std::sort(maShapeRanges[nRangeId].maBackShapes.begin(), maShapeRanges[nRangeId].maBackShapes.end(),ScShapeChildLess());
1195cdf0e10cSrcweir if (bControlAdded)
1196cdf0e10cSrcweir std::sort(maShapeRanges[nRangeId].maControls.begin(), maShapeRanges[nRangeId].maControls.end(),ScShapeChildLess());
1197cdf0e10cSrcweir }
1198cdf0e10cSrcweir }
1199cdf0e10cSrcweir
1200cdf0e10cSrcweir //UNUSED2008-05 sal_Bool ScShapeChilds::FindShape(ScShapeChildVec& rShapes, const uno::Reference <drawing::XShape>& xShape, ScShapeChildVec::iterator& rItr) const
1201cdf0e10cSrcweir //UNUSED2008-05 {
1202cdf0e10cSrcweir //UNUSED2008-05 sal_Bool bResult(sal_False);
1203cdf0e10cSrcweir //UNUSED2008-05 ScShapeChild aShape;
1204cdf0e10cSrcweir //UNUSED2008-05 aShape.mxShape = xShape;
1205cdf0e10cSrcweir //UNUSED2008-05 rItr = std::lower_bound(rShapes.begin(), rShapes.end(), aShape, ScShapeChildLess());
1206cdf0e10cSrcweir //UNUSED2008-05 if (rItr->mxShape.get() == xShape.get())
1207cdf0e10cSrcweir //UNUSED2008-05 bResult = sal_True; // if the shape is found
1208cdf0e10cSrcweir //UNUSED2008-05
1209cdf0e10cSrcweir //UNUSED2008-05 /*#ifdef DBG_UTIL // test whether it finds truly the correct shape (perhaps it is not really sorted)
1210cdf0e10cSrcweir //UNUSED2008-05 ScShapeChildVec::iterator aDebugItr = std::find(rShapes.begin(), rShapes.end(), aShape);
1211cdf0e10cSrcweir //UNUSED2008-05 DBG_ASSERT(rItr == aDebugItr, "wrong Shape found");
1212cdf0e10cSrcweir //UNUSED2008-05 #endif*/
1213cdf0e10cSrcweir //UNUSED2008-05 return bResult;
1214cdf0e10cSrcweir //UNUSED2008-05 }
1215cdf0e10cSrcweir
1216cdf0e10cSrcweir /*void ScShapeChilds::AddShape(const uno::Reference<drawing::XShape>& xShape, SdrLayerID aLayerID)
1217cdf0e10cSrcweir {
1218cdf0e10cSrcweir uno::Reference < XAccessible > xNew;
1219cdf0e10cSrcweir Window* pWin = mpViewShell->GetWindow();
1220cdf0e10cSrcweir if (pWin)
1221cdf0e10cSrcweir {
1222cdf0e10cSrcweir ScShapeRangeVec::iterator aEndItr = maShapeRanges.end();
1223cdf0e10cSrcweir ScShapeRangeVec::iterator aItr = maShapeRanges.begin();
1224cdf0e10cSrcweir sal_Bool bNotify(sal_False);
1225cdf0e10cSrcweir uno::Reference <XAccessible> xAcc;
1226cdf0e10cSrcweir while (aItr != aEndItr)
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir Rectangle aLogicPaintRect(pWin->PixelToLogic(aItr->maPixelRect, aItr->maMapMode));
1229cdf0e10cSrcweir Rectangle aRect(VCLPoint(xShape->getPosition()), VCLSize(xShape->getSize()));
1230cdf0e10cSrcweir if(!aRect.GetIntersection(aLogicPaintRect).IsEmpty())
1231cdf0e10cSrcweir {
1232cdf0e10cSrcweir ScShapeChild aShape;
1233cdf0e10cSrcweir aShape.mxShape = xShape;
1234cdf0e10cSrcweir switch (aLayerID)
1235cdf0e10cSrcweir {
1236cdf0e10cSrcweir case SC_LAYER_INTERN:
1237cdf0e10cSrcweir case SC_LAYER_FRONT:
1238cdf0e10cSrcweir {
1239cdf0e10cSrcweir SetAnchor(aShape);
1240cdf0e10cSrcweir aItr->maForeShapes.push_back(aShape);
1241cdf0e10cSrcweir std::sort(aItr->maForeShapes.begin(), aItr->maForeShapes.end(),ScShapeChildLess());
1242cdf0e10cSrcweir
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir break;
1245cdf0e10cSrcweir case SC_LAYER_BACK:
1246cdf0e10cSrcweir {
1247cdf0e10cSrcweir aItr->maBackShapes.push_back(aShape);
1248cdf0e10cSrcweir std::sort(aItr->maBackShapes.begin(), aItr->maBackShapes.end(),ScShapeChildLess());
1249cdf0e10cSrcweir }
1250cdf0e10cSrcweir break;
1251cdf0e10cSrcweir case SC_LAYER_CONTROLS:
1252cdf0e10cSrcweir {
1253cdf0e10cSrcweir SetAnchor(aShape);
1254cdf0e10cSrcweir aItr->maControls.push_back(aShape);
1255cdf0e10cSrcweir std::sort(aItr->maControls.begin(), aItr->maControls.end(),ScShapeChildLess());
1256cdf0e10cSrcweir }
1257cdf0e10cSrcweir break;
1258cdf0e10cSrcweir default:
1259cdf0e10cSrcweir {
1260cdf0e10cSrcweir DBG_ERRORFILE("I don't know this layer.");
1261cdf0e10cSrcweir }
1262cdf0e10cSrcweir break;
1263cdf0e10cSrcweir }
1264cdf0e10cSrcweir if (bNotify)
1265cdf0e10cSrcweir {
1266cdf0e10cSrcweir xAcc = GetAccShape(aShape);
1267cdf0e10cSrcweir AccessibleEventObject aEvent;
1268cdf0e10cSrcweir aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
1269cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
1270cdf0e10cSrcweir aEvent.NewValue <<= xAcc;
1271cdf0e10cSrcweir mpAccDoc->CommitChange(aEvent);
1272cdf0e10cSrcweir bNotify = sal_False;
1273cdf0e10cSrcweir }
1274cdf0e10cSrcweir xAcc = NULL;
1275cdf0e10cSrcweir }
1276cdf0e10cSrcweir ++aItr;
1277cdf0e10cSrcweir }
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir }*/
1280cdf0e10cSrcweir
1281cdf0e10cSrcweir /*sal_Bool HaveToNotify(uno::Reference<XAccessible>& xAcc, ScShapeChildVec::iterator aItr)
1282cdf0e10cSrcweir {
1283cdf0e10cSrcweir sal_Bool bResult(sal_False);
1284cdf0e10cSrcweir if (aItr->mpAccShape)
1285cdf0e10cSrcweir {
1286cdf0e10cSrcweir bResult = sal_True;
1287cdf0e10cSrcweir xAcc = aItr->mpAccShape;
1288cdf0e10cSrcweir }
1289cdf0e10cSrcweir else
1290cdf0e10cSrcweir DBG_ERRORFILE("No Accessible object found. Don't know how to notify.");
1291cdf0e10cSrcweir return bResult;
1292cdf0e10cSrcweir }*/
1293cdf0e10cSrcweir
1294cdf0e10cSrcweir /*void ScShapeChilds::RemoveShape(const uno::Reference<drawing::XShape>& xShape, SdrLayerID aLayerID)
1295cdf0e10cSrcweir {
1296cdf0e10cSrcweir ScShapeRangeVec::iterator aEndItr = maShapeRanges.end();
1297cdf0e10cSrcweir ScShapeRangeVec::iterator aItr = maShapeRanges.begin();
1298cdf0e10cSrcweir ScShapeChildVec::iterator aEraseItr;
1299cdf0e10cSrcweir sal_Bool bNotify(sal_False);
1300cdf0e10cSrcweir uno::Reference <XAccessible> xAcc;
1301cdf0e10cSrcweir while (aItr != aEndItr)
1302cdf0e10cSrcweir {
1303cdf0e10cSrcweir switch (aLayerID)
1304cdf0e10cSrcweir {
1305cdf0e10cSrcweir case SC_LAYER_INTERN:
1306cdf0e10cSrcweir case SC_LAYER_FRONT:
1307cdf0e10cSrcweir {
1308cdf0e10cSrcweir if (FindShape(aItr->maForeShapes, xShape, aEraseItr))
1309cdf0e10cSrcweir {
1310cdf0e10cSrcweir bNotify = HaveToNotify(xAcc, aEraseItr);
1311cdf0e10cSrcweir aItr->maForeShapes.erase(aEraseItr);
1312cdf0e10cSrcweir }
1313cdf0e10cSrcweir }
1314cdf0e10cSrcweir break;
1315cdf0e10cSrcweir case SC_LAYER_BACK:
1316cdf0e10cSrcweir {
1317cdf0e10cSrcweir if (FindShape(aItr->maBackShapes, xShape, aEraseItr))
1318cdf0e10cSrcweir {
1319cdf0e10cSrcweir bNotify = HaveToNotify(xAcc, aEraseItr);
1320cdf0e10cSrcweir aItr->maBackShapes.erase(aEraseItr);
1321cdf0e10cSrcweir }
1322cdf0e10cSrcweir }
1323cdf0e10cSrcweir break;
1324cdf0e10cSrcweir case SC_LAYER_CONTROLS:
1325cdf0e10cSrcweir {
1326cdf0e10cSrcweir if (FindShape(aItr->maControls, xShape, aEraseItr))
1327cdf0e10cSrcweir {
1328cdf0e10cSrcweir bNotify = HaveToNotify(xAcc, aEraseItr);
1329cdf0e10cSrcweir aItr->maControls.erase(aEraseItr);
1330cdf0e10cSrcweir }
1331cdf0e10cSrcweir }
1332cdf0e10cSrcweir break;
1333cdf0e10cSrcweir default:
1334cdf0e10cSrcweir {
1335cdf0e10cSrcweir DBG_ERRORFILE("I don't know this layer.");
1336cdf0e10cSrcweir }
1337cdf0e10cSrcweir break;
1338cdf0e10cSrcweir }
1339cdf0e10cSrcweir if (bNotify)
1340cdf0e10cSrcweir {
1341cdf0e10cSrcweir AccessibleEventObject aEvent;
1342cdf0e10cSrcweir aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
1343cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
1344cdf0e10cSrcweir aEvent.OldValue <<= xAcc;
1345cdf0e10cSrcweir mpAccDoc->CommitChange(aEvent);
1346cdf0e10cSrcweir bNotify = sal_False;
1347cdf0e10cSrcweir }
1348cdf0e10cSrcweir xAcc = NULL;
1349cdf0e10cSrcweir ++aItr;
1350cdf0e10cSrcweir }
1351cdf0e10cSrcweir }*/
1352cdf0e10cSrcweir
GetDrawPage() const1353cdf0e10cSrcweir SdrPage* ScShapeChilds::GetDrawPage() const
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir SCTAB nTab( mpViewShell->GetLocationData().GetPrintTab() );
1356cdf0e10cSrcweir SdrPage* pDrawPage = NULL;
1357cdf0e10cSrcweir if (mpViewShell)
1358cdf0e10cSrcweir {
1359cdf0e10cSrcweir ScDocument* pDoc = mpViewShell->GetDocument();
1360cdf0e10cSrcweir if (pDoc && pDoc->GetDrawLayer())
1361cdf0e10cSrcweir {
1362cdf0e10cSrcweir ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
1363cdf0e10cSrcweir if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab))
1364cdf0e10cSrcweir pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(static_cast<sal_Int16>(nTab)));
1365cdf0e10cSrcweir }
1366cdf0e10cSrcweir }
1367cdf0e10cSrcweir return pDrawPage;
1368cdf0e10cSrcweir }
1369cdf0e10cSrcweir
1370cdf0e10cSrcweir struct ScPagePreviewCountData
1371cdf0e10cSrcweir {
1372cdf0e10cSrcweir // order is background shapes, header, table or notes, footer, foreground shapes, controls
1373cdf0e10cSrcweir
1374cdf0e10cSrcweir Rectangle aVisRect;
1375cdf0e10cSrcweir long nBackShapes;
1376cdf0e10cSrcweir long nHeaders;
1377cdf0e10cSrcweir long nTables;
1378cdf0e10cSrcweir long nNoteParagraphs;
1379cdf0e10cSrcweir long nFooters;
1380cdf0e10cSrcweir long nForeShapes;
1381cdf0e10cSrcweir long nControls;
1382cdf0e10cSrcweir
1383cdf0e10cSrcweir ScPagePreviewCountData( const ScPreviewLocationData& rData, Window* pSizeWindow,
1384cdf0e10cSrcweir ScNotesChilds* pNotesChilds, ScShapeChilds* pShapeChilds );
1385cdf0e10cSrcweir
GetTotalScPagePreviewCountData1386cdf0e10cSrcweir long GetTotal() const
1387cdf0e10cSrcweir {
1388cdf0e10cSrcweir return nBackShapes + nHeaders + nTables + nNoteParagraphs + nFooters + nForeShapes + nControls;
1389cdf0e10cSrcweir }
1390cdf0e10cSrcweir };
1391cdf0e10cSrcweir
ScPagePreviewCountData(const ScPreviewLocationData & rData,Window * pSizeWindow,ScNotesChilds * pNotesChilds,ScShapeChilds * pShapeChilds)1392cdf0e10cSrcweir ScPagePreviewCountData::ScPagePreviewCountData( const ScPreviewLocationData& rData,
1393cdf0e10cSrcweir Window* pSizeWindow, ScNotesChilds* pNotesChilds,
1394cdf0e10cSrcweir ScShapeChilds* pShapeChilds) :
1395cdf0e10cSrcweir nBackShapes( 0 ),
1396cdf0e10cSrcweir nHeaders( 0 ),
1397cdf0e10cSrcweir nTables( 0 ),
1398cdf0e10cSrcweir nNoteParagraphs( 0 ),
1399cdf0e10cSrcweir nFooters( 0 ),
1400cdf0e10cSrcweir nForeShapes( 0 ),
1401cdf0e10cSrcweir nControls( 0 )
1402cdf0e10cSrcweir {
1403cdf0e10cSrcweir Size aOutputSize;
1404cdf0e10cSrcweir if ( pSizeWindow )
1405cdf0e10cSrcweir aOutputSize = pSizeWindow->GetOutputSizePixel();
1406cdf0e10cSrcweir Point aPoint;
1407cdf0e10cSrcweir aVisRect = Rectangle( aPoint, aOutputSize );
1408cdf0e10cSrcweir
1409cdf0e10cSrcweir Rectangle aObjRect;
1410cdf0e10cSrcweir
1411cdf0e10cSrcweir if ( rData.GetHeaderPosition( aObjRect ) && aObjRect.IsOver( aVisRect ) )
1412cdf0e10cSrcweir nHeaders = 1;
1413cdf0e10cSrcweir
1414cdf0e10cSrcweir if ( rData.GetFooterPosition( aObjRect ) && aObjRect.IsOver( aVisRect ) )
1415cdf0e10cSrcweir nFooters = 1;
1416cdf0e10cSrcweir
1417cdf0e10cSrcweir if ( rData.HasCellsInRange( aVisRect ) )
1418cdf0e10cSrcweir nTables = 1;
1419cdf0e10cSrcweir
1420cdf0e10cSrcweir //! shapes...
1421cdf0e10cSrcweir nBackShapes = pShapeChilds->GetBackShapeCount();
1422cdf0e10cSrcweir nForeShapes = pShapeChilds->GetForeShapeCount();
1423cdf0e10cSrcweir nControls = pShapeChilds->GetControlCount();
1424cdf0e10cSrcweir
1425cdf0e10cSrcweir // there are only notes if there is no table
1426cdf0e10cSrcweir if (nTables == 0)
1427cdf0e10cSrcweir nNoteParagraphs = pNotesChilds->GetChildsCount();
1428cdf0e10cSrcweir }
1429cdf0e10cSrcweir
1430cdf0e10cSrcweir //===== internal ========================================================
1431cdf0e10cSrcweir
ScAccessibleDocumentPagePreview(const uno::Reference<XAccessible> & rxParent,ScPreviewShell * pViewShell)1432cdf0e10cSrcweir ScAccessibleDocumentPagePreview::ScAccessibleDocumentPagePreview(
1433cdf0e10cSrcweir const uno::Reference<XAccessible>& rxParent, ScPreviewShell* pViewShell ) :
1434cdf0e10cSrcweir ScAccessibleDocumentBase(rxParent),
1435cdf0e10cSrcweir mpViewShell(pViewShell),
1436cdf0e10cSrcweir mpNotesChilds(NULL),
1437cdf0e10cSrcweir mpShapeChilds(NULL),
1438cdf0e10cSrcweir mpTable(NULL),
1439cdf0e10cSrcweir mpHeader(NULL),
1440cdf0e10cSrcweir mpFooter(NULL)
1441cdf0e10cSrcweir {
1442cdf0e10cSrcweir if (pViewShell)
1443cdf0e10cSrcweir pViewShell->AddAccessibilityObject(*this);
1444cdf0e10cSrcweir
1445cdf0e10cSrcweir // GetNotesChilds(); not neccessary and reduces the creation performance
1446cdf0e10cSrcweir // GetShapeChilds();
1447cdf0e10cSrcweir }
1448cdf0e10cSrcweir
~ScAccessibleDocumentPagePreview(void)1449cdf0e10cSrcweir ScAccessibleDocumentPagePreview::~ScAccessibleDocumentPagePreview(void)
1450cdf0e10cSrcweir {
1451cdf0e10cSrcweir if (!ScAccessibleDocumentBase::IsDefunc() && !rBHelper.bInDispose)
1452cdf0e10cSrcweir {
1453cdf0e10cSrcweir // increment refcount to prevent double call off dtor
1454cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount );
1455cdf0e10cSrcweir // call dispose to inform object wich have a weak reference to this object
1456cdf0e10cSrcweir dispose();
1457cdf0e10cSrcweir }
1458cdf0e10cSrcweir }
1459cdf0e10cSrcweir
disposing()1460cdf0e10cSrcweir void SAL_CALL ScAccessibleDocumentPagePreview::disposing()
1461cdf0e10cSrcweir {
1462cdf0e10cSrcweir ScUnoGuard aGuard;
1463cdf0e10cSrcweir if (mpTable)
1464cdf0e10cSrcweir {
1465cdf0e10cSrcweir mpTable->release();
1466cdf0e10cSrcweir mpTable = NULL;
1467cdf0e10cSrcweir }
1468cdf0e10cSrcweir if (mpHeader)
1469cdf0e10cSrcweir {
1470cdf0e10cSrcweir mpHeader->release();
1471cdf0e10cSrcweir mpHeader = NULL;
1472cdf0e10cSrcweir }
1473cdf0e10cSrcweir if (mpFooter)
1474cdf0e10cSrcweir {
1475cdf0e10cSrcweir mpFooter->release();
1476cdf0e10cSrcweir mpFooter = NULL;
1477cdf0e10cSrcweir }
1478cdf0e10cSrcweir
1479cdf0e10cSrcweir if (mpViewShell)
1480cdf0e10cSrcweir {
1481cdf0e10cSrcweir mpViewShell->RemoveAccessibilityObject(*this);
1482cdf0e10cSrcweir mpViewShell = NULL;
1483cdf0e10cSrcweir }
1484cdf0e10cSrcweir
1485cdf0e10cSrcweir // #100593# no need to Dispose the AccessibleTextHelper,
1486cdf0e10cSrcweir // as long as mpNotesChilds are destructed here
1487cdf0e10cSrcweir if (mpNotesChilds)
1488cdf0e10cSrcweir DELETEZ(mpNotesChilds);
1489cdf0e10cSrcweir
1490cdf0e10cSrcweir if (mpShapeChilds)
1491cdf0e10cSrcweir DELETEZ(mpShapeChilds);
1492cdf0e10cSrcweir
1493cdf0e10cSrcweir ScAccessibleDocumentBase::disposing();
1494cdf0e10cSrcweir }
1495cdf0e10cSrcweir
1496cdf0e10cSrcweir //===== SfxListener =====================================================
1497cdf0e10cSrcweir
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)1498cdf0e10cSrcweir void ScAccessibleDocumentPagePreview::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1499cdf0e10cSrcweir {
1500cdf0e10cSrcweir if (rHint.ISA( SfxSimpleHint ) )
1501cdf0e10cSrcweir {
1502cdf0e10cSrcweir const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
1503cdf0e10cSrcweir // only notify if child exist, otherwise it is not necessary
1504cdf0e10cSrcweir if ((rRef.GetId() == SC_HINT_DATACHANGED))
1505cdf0e10cSrcweir {
1506cdf0e10cSrcweir if (mpTable) // if there is no table there is nothing to notify, because no one recongnizes the change
1507cdf0e10cSrcweir {
1508cdf0e10cSrcweir {
1509cdf0e10cSrcweir uno::Reference<XAccessible> xAcc = mpTable;
1510cdf0e10cSrcweir AccessibleEventObject aEvent;
1511cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
1512cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this);
1513cdf0e10cSrcweir aEvent.OldValue <<= xAcc;
1514cdf0e10cSrcweir CommitChange(aEvent);
1515cdf0e10cSrcweir }
1516cdf0e10cSrcweir
1517cdf0e10cSrcweir mpTable->dispose();
1518cdf0e10cSrcweir mpTable->release();
1519cdf0e10cSrcweir mpTable = NULL;
1520cdf0e10cSrcweir }
1521cdf0e10cSrcweir
1522cdf0e10cSrcweir Size aOutputSize;
1523cdf0e10cSrcweir Window* pSizeWindow = mpViewShell->GetWindow();
1524cdf0e10cSrcweir if ( pSizeWindow )
1525cdf0e10cSrcweir aOutputSize = pSizeWindow->GetOutputSizePixel();
1526cdf0e10cSrcweir Point aPoint;
1527cdf0e10cSrcweir Rectangle aVisRect( aPoint, aOutputSize );
1528cdf0e10cSrcweir GetNotesChilds()->DataChanged(aVisRect);
1529cdf0e10cSrcweir
1530cdf0e10cSrcweir GetShapeChilds()->DataChanged();
1531cdf0e10cSrcweir
1532cdf0e10cSrcweir const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
1533cdf0e10cSrcweir ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChilds(), GetShapeChilds() );
1534cdf0e10cSrcweir
1535cdf0e10cSrcweir if (aCount.nTables > 0)
1536cdf0e10cSrcweir {
1537cdf0e10cSrcweir //! order is background shapes, header, table or notes, footer, foreground shapes, controls
1538cdf0e10cSrcweir sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
1539cdf0e10cSrcweir
1540cdf0e10cSrcweir mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
1541cdf0e10cSrcweir mpTable->acquire();
1542cdf0e10cSrcweir mpTable->Init();
1543cdf0e10cSrcweir
1544cdf0e10cSrcweir {
1545cdf0e10cSrcweir uno::Reference<XAccessible> xAcc = mpTable;
1546cdf0e10cSrcweir AccessibleEventObject aEvent;
1547cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD;
1548cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this);
1549cdf0e10cSrcweir aEvent.NewValue <<= xAcc;
1550cdf0e10cSrcweir CommitChange(aEvent);
1551cdf0e10cSrcweir }
1552cdf0e10cSrcweir }
1553cdf0e10cSrcweir }
1554cdf0e10cSrcweir else if (rRef.GetId() == SC_HINT_ACC_MAKEDRAWLAYER)
1555cdf0e10cSrcweir {
1556cdf0e10cSrcweir GetShapeChilds()->SetDrawBroadcaster();
1557cdf0e10cSrcweir }
1558cdf0e10cSrcweir else if (rRef.GetId() == SC_HINT_ACC_VISAREACHANGED)
1559cdf0e10cSrcweir {
1560cdf0e10cSrcweir Size aOutputSize;
1561cdf0e10cSrcweir Window* pSizeWindow = mpViewShell->GetWindow();
1562cdf0e10cSrcweir if ( pSizeWindow )
1563cdf0e10cSrcweir aOutputSize = pSizeWindow->GetOutputSizePixel();
1564cdf0e10cSrcweir Point aPoint;
1565cdf0e10cSrcweir Rectangle aVisRect( aPoint, aOutputSize );
1566cdf0e10cSrcweir GetNotesChilds()->DataChanged(aVisRect);
1567cdf0e10cSrcweir
1568cdf0e10cSrcweir GetShapeChilds()->VisAreaChanged();
1569cdf0e10cSrcweir
1570cdf0e10cSrcweir AccessibleEventObject aEvent;
1571cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
1572cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this);
1573cdf0e10cSrcweir CommitChange(aEvent);
1574cdf0e10cSrcweir }
1575cdf0e10cSrcweir }
1576cdf0e10cSrcweir else if ( rHint.ISA(ScAccWinFocusLostHint) )
1577cdf0e10cSrcweir {
1578cdf0e10cSrcweir CommitFocusLost();
1579cdf0e10cSrcweir }
1580cdf0e10cSrcweir else if ( rHint.ISA(ScAccWinFocusGotHint) )
1581cdf0e10cSrcweir {
1582cdf0e10cSrcweir CommitFocusGained();
1583cdf0e10cSrcweir }
1584cdf0e10cSrcweir ScAccessibleDocumentBase::Notify(rBC, rHint);
1585cdf0e10cSrcweir }
1586cdf0e10cSrcweir
1587cdf0e10cSrcweir //===== XAccessibleComponent ============================================
1588cdf0e10cSrcweir
getAccessibleAtPoint(const awt::Point & rPoint)1589cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleAtPoint( const awt::Point& rPoint )
1590cdf0e10cSrcweir throw (uno::RuntimeException)
1591cdf0e10cSrcweir {
1592cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible;
1593cdf0e10cSrcweir if (containsPoint(rPoint))
1594cdf0e10cSrcweir {
1595cdf0e10cSrcweir ScUnoGuard aGuard;
1596cdf0e10cSrcweir IsObjectValid();
1597cdf0e10cSrcweir
1598cdf0e10cSrcweir if ( mpViewShell )
1599cdf0e10cSrcweir {
1600cdf0e10cSrcweir xAccessible = GetShapeChilds()->GetForegroundShapeAt(rPoint);
1601cdf0e10cSrcweir if (!xAccessible.is())
1602cdf0e10cSrcweir {
1603cdf0e10cSrcweir const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
1604cdf0e10cSrcweir ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChilds(), GetShapeChilds() );
1605cdf0e10cSrcweir
1606cdf0e10cSrcweir /* if ( rData.HasCellsInRange( Rectangle( rPoint, rPoint ) ) )
1607cdf0e10cSrcweir {
1608cdf0e10cSrcweir if ( !mpTable && (aCount.nTables > 0) )
1609cdf0e10cSrcweir {
1610cdf0e10cSrcweir //! order is background shapes, header, table or notes, footer, foreground shapes, controls
1611cdf0e10cSrcweir sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
1612cdf0e10cSrcweir
1613cdf0e10cSrcweir mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
1614cdf0e10cSrcweir mpTable->acquire();
1615cdf0e10cSrcweir mpTable->Init();
1616cdf0e10cSrcweir }
1617cdf0e10cSrcweir xAccessible = mpTable;
1618cdf0e10cSrcweir }*/
1619cdf0e10cSrcweir if ( !mpTable && (aCount.nTables > 0) )
1620cdf0e10cSrcweir {
1621cdf0e10cSrcweir //! order is background shapes, header, table or notes, footer, foreground shapes, controls
1622cdf0e10cSrcweir sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
1623cdf0e10cSrcweir
1624cdf0e10cSrcweir mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
1625cdf0e10cSrcweir mpTable->acquire();
1626cdf0e10cSrcweir mpTable->Init();
1627cdf0e10cSrcweir }
1628cdf0e10cSrcweir if (mpTable && VCLRectangle(mpTable->getBounds()).IsInside(VCLPoint(rPoint)))
1629cdf0e10cSrcweir xAccessible = mpTable;
1630cdf0e10cSrcweir }
1631cdf0e10cSrcweir if (!xAccessible.is())
1632cdf0e10cSrcweir xAccessible = GetNotesChilds()->GetAt(rPoint);
1633cdf0e10cSrcweir if (!xAccessible.is())
1634cdf0e10cSrcweir {
1635cdf0e10cSrcweir if (!mpHeader || !mpFooter)
1636cdf0e10cSrcweir {
1637cdf0e10cSrcweir const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
1638cdf0e10cSrcweir ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChilds(), GetShapeChilds() );
1639cdf0e10cSrcweir
1640cdf0e10cSrcweir if (!mpHeader)
1641cdf0e10cSrcweir {
1642cdf0e10cSrcweir mpHeader = new ScAccessiblePageHeader( this, mpViewShell, sal_True, aCount.nBackShapes + aCount.nHeaders - 1);
1643cdf0e10cSrcweir mpHeader->acquire();
1644cdf0e10cSrcweir }
1645cdf0e10cSrcweir if (!mpFooter)
1646cdf0e10cSrcweir {
1647cdf0e10cSrcweir mpFooter = new ScAccessiblePageHeader( this, mpViewShell, sal_False, aCount.nBackShapes + aCount.nHeaders + aCount.nTables + aCount.nNoteParagraphs + aCount.nFooters - 1 );
1648cdf0e10cSrcweir mpFooter->acquire();
1649cdf0e10cSrcweir }
1650cdf0e10cSrcweir }
1651cdf0e10cSrcweir
1652cdf0e10cSrcweir Point aPoint(VCLPoint(rPoint));
1653cdf0e10cSrcweir
1654cdf0e10cSrcweir if (VCLRectangle(mpHeader->getBounds()).IsInside(aPoint))
1655cdf0e10cSrcweir xAccessible = mpHeader;
1656cdf0e10cSrcweir else if (VCLRectangle(mpFooter->getBounds()).IsInside(aPoint))
1657cdf0e10cSrcweir xAccessible = mpFooter;
1658cdf0e10cSrcweir }
1659cdf0e10cSrcweir if (!xAccessible.is())
1660cdf0e10cSrcweir xAccessible = GetShapeChilds()->GetBackgroundShapeAt(rPoint);
1661cdf0e10cSrcweir }
1662cdf0e10cSrcweir }
1663cdf0e10cSrcweir
1664cdf0e10cSrcweir return xAccessible;
1665cdf0e10cSrcweir }
1666cdf0e10cSrcweir
grabFocus()1667cdf0e10cSrcweir void SAL_CALL ScAccessibleDocumentPagePreview::grabFocus() throw (uno::RuntimeException)
1668cdf0e10cSrcweir {
1669cdf0e10cSrcweir ScUnoGuard aGuard;
1670cdf0e10cSrcweir IsObjectValid();
1671cdf0e10cSrcweir if (getAccessibleParent().is())
1672cdf0e10cSrcweir {
1673cdf0e10cSrcweir uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
1674cdf0e10cSrcweir if (xAccessibleComponent.is())
1675cdf0e10cSrcweir {
1676cdf0e10cSrcweir // just grab the focus for the window
1677cdf0e10cSrcweir xAccessibleComponent->grabFocus();
1678cdf0e10cSrcweir }
1679cdf0e10cSrcweir }
1680cdf0e10cSrcweir }
1681cdf0e10cSrcweir
1682cdf0e10cSrcweir //===== XAccessibleContext ==============================================
1683cdf0e10cSrcweir
getAccessibleChildCount(void)1684cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleChildCount(void) throw (uno::RuntimeException)
1685cdf0e10cSrcweir {
1686cdf0e10cSrcweir ScUnoGuard aGuard;
1687cdf0e10cSrcweir IsObjectValid();
1688cdf0e10cSrcweir
1689cdf0e10cSrcweir long nRet = 0;
1690cdf0e10cSrcweir if ( mpViewShell )
1691cdf0e10cSrcweir {
1692cdf0e10cSrcweir ScPagePreviewCountData aCount( mpViewShell->GetLocationData(), mpViewShell->GetWindow(), GetNotesChilds(), GetShapeChilds() );
1693cdf0e10cSrcweir nRet = aCount.GetTotal();
1694cdf0e10cSrcweir }
1695cdf0e10cSrcweir
1696cdf0e10cSrcweir return nRet;
1697cdf0e10cSrcweir }
1698cdf0e10cSrcweir
getAccessibleChild(sal_Int32 nIndex)1699cdf0e10cSrcweir uno::Reference<XAccessible> SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleChild(sal_Int32 nIndex)
1700cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
1701cdf0e10cSrcweir {
1702cdf0e10cSrcweir ScUnoGuard aGuard;
1703cdf0e10cSrcweir IsObjectValid();
1704cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible;
1705cdf0e10cSrcweir
1706cdf0e10cSrcweir if ( mpViewShell )
1707cdf0e10cSrcweir {
1708cdf0e10cSrcweir const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
1709cdf0e10cSrcweir ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChilds(), GetShapeChilds() );
1710cdf0e10cSrcweir
1711cdf0e10cSrcweir if ( nIndex < aCount.nBackShapes )
1712cdf0e10cSrcweir {
1713cdf0e10cSrcweir xAccessible = GetShapeChilds()->GetBackShape(nIndex);
1714cdf0e10cSrcweir }
1715cdf0e10cSrcweir else if ( nIndex < aCount.nBackShapes + aCount.nHeaders )
1716cdf0e10cSrcweir {
1717cdf0e10cSrcweir if ( !mpHeader )
1718cdf0e10cSrcweir {
1719cdf0e10cSrcweir mpHeader = new ScAccessiblePageHeader( this, mpViewShell, sal_True, nIndex );
1720cdf0e10cSrcweir mpHeader->acquire();
1721cdf0e10cSrcweir }
1722cdf0e10cSrcweir
1723cdf0e10cSrcweir xAccessible = mpHeader;
1724cdf0e10cSrcweir }
1725cdf0e10cSrcweir else if ( nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nTables )
1726cdf0e10cSrcweir {
1727cdf0e10cSrcweir if ( !mpTable )
1728cdf0e10cSrcweir {
1729cdf0e10cSrcweir mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
1730cdf0e10cSrcweir mpTable->acquire();
1731cdf0e10cSrcweir mpTable->Init();
1732cdf0e10cSrcweir }
1733cdf0e10cSrcweir xAccessible = mpTable;
1734cdf0e10cSrcweir }
1735cdf0e10cSrcweir else if ( nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nNoteParagraphs )
1736cdf0e10cSrcweir {
1737cdf0e10cSrcweir xAccessible = GetNotesChilds()->GetChild(nIndex - aCount.nBackShapes - aCount.nHeaders);
1738cdf0e10cSrcweir }
1739cdf0e10cSrcweir else if ( (nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nTables + aCount.nNoteParagraphs + aCount.nFooters) )
1740cdf0e10cSrcweir {
1741cdf0e10cSrcweir if ( !mpFooter )
1742cdf0e10cSrcweir {
1743cdf0e10cSrcweir mpFooter = new ScAccessiblePageHeader( this, mpViewShell, sal_False, nIndex );
1744cdf0e10cSrcweir mpFooter->acquire();
1745cdf0e10cSrcweir }
1746cdf0e10cSrcweir xAccessible = mpFooter;
1747cdf0e10cSrcweir }
1748cdf0e10cSrcweir else
1749cdf0e10cSrcweir {
1750cdf0e10cSrcweir sal_Int32 nIdx(nIndex - (aCount.nBackShapes + aCount.nHeaders + aCount.nTables + aCount.nNoteParagraphs + aCount.nFooters));
1751cdf0e10cSrcweir if (nIdx < aCount.nForeShapes)
1752cdf0e10cSrcweir xAccessible = GetShapeChilds()->GetForeShape(nIdx);
1753cdf0e10cSrcweir else
1754cdf0e10cSrcweir xAccessible = GetShapeChilds()->GetControl(nIdx - aCount.nForeShapes);
1755cdf0e10cSrcweir }
1756cdf0e10cSrcweir }
1757cdf0e10cSrcweir
1758cdf0e10cSrcweir if ( !xAccessible.is() )
1759cdf0e10cSrcweir throw lang::IndexOutOfBoundsException();
1760cdf0e10cSrcweir
1761cdf0e10cSrcweir return xAccessible;
1762cdf0e10cSrcweir }
1763cdf0e10cSrcweir
1764cdf0e10cSrcweir /// Return the set of current states.
getAccessibleStateSet(void)1765cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleStateSet(void)
1766cdf0e10cSrcweir throw (uno::RuntimeException)
1767cdf0e10cSrcweir {
1768cdf0e10cSrcweir ScUnoGuard aGuard;
1769cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> xParentStates;
1770cdf0e10cSrcweir if (getAccessibleParent().is())
1771cdf0e10cSrcweir {
1772cdf0e10cSrcweir uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
1773cdf0e10cSrcweir xParentStates = xParentContext->getAccessibleStateSet();
1774cdf0e10cSrcweir }
1775cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
1776cdf0e10cSrcweir if (IsDefunc(xParentStates))
1777cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::DEFUNC);
1778cdf0e10cSrcweir else
1779cdf0e10cSrcweir {
1780cdf0e10cSrcweir // never editable
1781cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::ENABLED);
1782cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::OPAQUE);
1783cdf0e10cSrcweir if (isShowing())
1784cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SHOWING);
1785cdf0e10cSrcweir if (isVisible())
1786cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::VISIBLE);
1787cdf0e10cSrcweir }
1788cdf0e10cSrcweir return pStateSet;
1789cdf0e10cSrcweir }
1790cdf0e10cSrcweir
1791cdf0e10cSrcweir //===== XServiceInfo ====================================================
1792cdf0e10cSrcweir
getImplementationName(void)1793cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDocumentPagePreview::getImplementationName(void)
1794cdf0e10cSrcweir throw (uno::RuntimeException)
1795cdf0e10cSrcweir {
1796cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScAccessibleDocumentPagePreview"));
1797cdf0e10cSrcweir }
1798cdf0e10cSrcweir
getSupportedServiceNames(void)1799cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> SAL_CALL ScAccessibleDocumentPagePreview::getSupportedServiceNames(void)
1800cdf0e10cSrcweir throw (uno::RuntimeException)
1801cdf0e10cSrcweir {
1802cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
1803cdf0e10cSrcweir sal_Int32 nOldSize(aSequence.getLength());
1804cdf0e10cSrcweir aSequence.realloc(nOldSize + 1);
1805cdf0e10cSrcweir ::rtl::OUString* pNames = aSequence.getArray();
1806cdf0e10cSrcweir
1807cdf0e10cSrcweir pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.AccessibleSpreadsheetPageView"));
1808cdf0e10cSrcweir
1809cdf0e10cSrcweir return aSequence;
1810cdf0e10cSrcweir }
1811cdf0e10cSrcweir
1812cdf0e10cSrcweir //===== XTypeProvider =======================================================
1813cdf0e10cSrcweir
1814cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL
getImplementationId(void)1815cdf0e10cSrcweir ScAccessibleDocumentPagePreview::getImplementationId(void)
1816cdf0e10cSrcweir throw (uno::RuntimeException)
1817cdf0e10cSrcweir {
1818cdf0e10cSrcweir ScUnoGuard aGuard;
1819cdf0e10cSrcweir IsObjectValid();
1820cdf0e10cSrcweir static uno::Sequence<sal_Int8> aId;
1821cdf0e10cSrcweir if (aId.getLength() == 0)
1822cdf0e10cSrcweir {
1823cdf0e10cSrcweir aId.realloc (16);
1824cdf0e10cSrcweir rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
1825cdf0e10cSrcweir }
1826cdf0e10cSrcweir return aId;
1827cdf0e10cSrcweir }
1828cdf0e10cSrcweir
1829cdf0e10cSrcweir //===== internal ========================================================
1830cdf0e10cSrcweir
createAccessibleDescription(void)1831cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDocumentPagePreview::createAccessibleDescription(void)
1832cdf0e10cSrcweir throw (uno::RuntimeException)
1833cdf0e10cSrcweir {
1834cdf0e10cSrcweir rtl::OUString sDescription = String(ScResId(STR_ACC_PREVIEWDOC_DESCR));
1835cdf0e10cSrcweir return sDescription;
1836cdf0e10cSrcweir }
1837cdf0e10cSrcweir
createAccessibleName(void)1838cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDocumentPagePreview::createAccessibleName(void)
1839cdf0e10cSrcweir throw (uno::RuntimeException)
1840cdf0e10cSrcweir {
1841cdf0e10cSrcweir rtl::OUString sName = String(ScResId(STR_ACC_PREVIEWDOC_NAME));
1842cdf0e10cSrcweir return sName;
1843cdf0e10cSrcweir }
1844cdf0e10cSrcweir
GetBoundingBoxOnScreen() const1845cdf0e10cSrcweir Rectangle ScAccessibleDocumentPagePreview::GetBoundingBoxOnScreen() const throw (uno::RuntimeException)
1846cdf0e10cSrcweir {
1847cdf0e10cSrcweir Rectangle aRect;
1848cdf0e10cSrcweir if (mpViewShell)
1849cdf0e10cSrcweir {
1850cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindow();
1851cdf0e10cSrcweir if (pWindow)
1852cdf0e10cSrcweir aRect = pWindow->GetWindowExtentsRelative(NULL);
1853cdf0e10cSrcweir }
1854cdf0e10cSrcweir return aRect;
1855cdf0e10cSrcweir }
1856cdf0e10cSrcweir
GetBoundingBox() const1857cdf0e10cSrcweir Rectangle ScAccessibleDocumentPagePreview::GetBoundingBox() const throw (uno::RuntimeException)
1858cdf0e10cSrcweir {
1859cdf0e10cSrcweir Rectangle aRect;
1860cdf0e10cSrcweir if (mpViewShell)
1861cdf0e10cSrcweir {
1862cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindow();
1863cdf0e10cSrcweir if (pWindow)
1864cdf0e10cSrcweir aRect = pWindow->GetWindowExtentsRelative(pWindow->GetAccessibleParentWindow());
1865cdf0e10cSrcweir }
1866cdf0e10cSrcweir return aRect;
1867cdf0e10cSrcweir }
1868cdf0e10cSrcweir
IsDefunc(const uno::Reference<XAccessibleStateSet> & rxParentStates)1869cdf0e10cSrcweir sal_Bool ScAccessibleDocumentPagePreview::IsDefunc(
1870cdf0e10cSrcweir const uno::Reference<XAccessibleStateSet>& rxParentStates)
1871cdf0e10cSrcweir {
1872cdf0e10cSrcweir return ScAccessibleContextBase::IsDefunc() || !getAccessibleParent().is() ||
1873cdf0e10cSrcweir (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
1874cdf0e10cSrcweir }
1875cdf0e10cSrcweir
GetNotesChilds()1876cdf0e10cSrcweir ScNotesChilds* ScAccessibleDocumentPagePreview::GetNotesChilds()
1877cdf0e10cSrcweir {
1878cdf0e10cSrcweir if (!mpNotesChilds && mpViewShell)
1879cdf0e10cSrcweir {
1880cdf0e10cSrcweir mpNotesChilds = new ScNotesChilds(mpViewShell, this);
1881cdf0e10cSrcweir
1882cdf0e10cSrcweir const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
1883cdf0e10cSrcweir ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChilds(), GetShapeChilds() );
1884cdf0e10cSrcweir
1885cdf0e10cSrcweir //! order is background shapes, header, table or notes, footer, foreground shapes, controls
1886cdf0e10cSrcweir mpNotesChilds->Init(aCount.aVisRect, aCount.nBackShapes + aCount.nHeaders);
1887cdf0e10cSrcweir }
1888cdf0e10cSrcweir return mpNotesChilds;
1889cdf0e10cSrcweir }
1890cdf0e10cSrcweir
GetShapeChilds()1891cdf0e10cSrcweir ScShapeChilds* ScAccessibleDocumentPagePreview::GetShapeChilds()
1892cdf0e10cSrcweir {
1893cdf0e10cSrcweir if (!mpShapeChilds && mpViewShell)
1894cdf0e10cSrcweir {
1895cdf0e10cSrcweir mpShapeChilds = new ScShapeChilds(mpViewShell, this);
1896cdf0e10cSrcweir mpShapeChilds->Init();
1897cdf0e10cSrcweir }
1898cdf0e10cSrcweir
1899cdf0e10cSrcweir return mpShapeChilds;
1900cdf0e10cSrcweir }
1901cdf0e10cSrcweir
getAccessibleName(void)1902*0deba7fbSSteve Yin ::rtl::OUString ScAccessibleDocumentPagePreview::getAccessibleName(void)
1903*0deba7fbSSteve Yin throw (::com::sun::star::uno::RuntimeException)
1904*0deba7fbSSteve Yin {
1905*0deba7fbSSteve Yin rtl::OUString sName = String(ScResId(STR_ACC_DOC_SPREADSHEET));
1906*0deba7fbSSteve Yin ScDocument* pScDoc = mpViewShell->GetDocument();
1907*0deba7fbSSteve Yin if ( pScDoc )
1908*0deba7fbSSteve Yin {
1909*0deba7fbSSteve Yin rtl::OUString sFileName = pScDoc->getDocAccTitle();
1910*0deba7fbSSteve Yin if ( !sFileName.getLength() )
1911*0deba7fbSSteve Yin {
1912*0deba7fbSSteve Yin SfxObjectShell* pObjSh = pScDoc->GetDocumentShell();
1913*0deba7fbSSteve Yin if ( pObjSh )
1914*0deba7fbSSteve Yin {
1915*0deba7fbSSteve Yin sFileName = pObjSh->GetTitle( SFX_TITLE_APINAME );
1916*0deba7fbSSteve Yin }
1917*0deba7fbSSteve Yin }
1918*0deba7fbSSteve Yin if ( sFileName.getLength() )
1919*0deba7fbSSteve Yin {
1920*0deba7fbSSteve Yin sName = sFileName + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" - ")) + sName;
1921*0deba7fbSSteve Yin sName += String(ScResId(STR_ACC_DOC_PREVIEW_SUFFIX));
1922*0deba7fbSSteve Yin
1923*0deba7fbSSteve Yin }
1924*0deba7fbSSteve Yin }
1925*0deba7fbSSteve Yin
1926*0deba7fbSSteve Yin return sName;
1927*0deba7fbSSteve Yin }
1928*0deba7fbSSteve Yin
1929cdf0e10cSrcweir //UNUSED2009-05 uno::Reference < XAccessible > ScAccessibleDocumentPagePreview::GetCurrentAccessibleTable()
1930cdf0e10cSrcweir //UNUSED2009-05 {
1931cdf0e10cSrcweir //UNUSED2009-05 if (!mpTable)
1932cdf0e10cSrcweir //UNUSED2009-05 {
1933cdf0e10cSrcweir //UNUSED2009-05 if ( mpViewShell )
1934cdf0e10cSrcweir //UNUSED2009-05 {
1935cdf0e10cSrcweir //UNUSED2009-05 const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
1936cdf0e10cSrcweir //UNUSED2009-05 ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChilds(), GetShapeChilds() );
1937cdf0e10cSrcweir //UNUSED2009-05 //! order is background shapes, header, table or notes, footer, foreground shapes, controls
1938cdf0e10cSrcweir //UNUSED2009-05 sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
1939cdf0e10cSrcweir //UNUSED2009-05
1940cdf0e10cSrcweir //UNUSED2009-05 mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
1941cdf0e10cSrcweir //UNUSED2009-05 mpTable->acquire();
1942cdf0e10cSrcweir //UNUSED2009-05 mpTable->Init();
1943cdf0e10cSrcweir //UNUSED2009-05 }
1944cdf0e10cSrcweir //UNUSED2009-05 }
1945cdf0e10cSrcweir //UNUSED2009-05 return mpTable;
1946cdf0e10cSrcweir //UNUSED2009-05 }
1947cdf0e10cSrcweir
1948cdf0e10cSrcweir //UNUSED2009-05 void ScAccessibleDocumentPagePreview::ChildCountChanged()
1949cdf0e10cSrcweir //UNUSED2009-05 {
1950cdf0e10cSrcweir //UNUSED2009-05 if (mpViewShell)
1951cdf0e10cSrcweir //UNUSED2009-05 {
1952cdf0e10cSrcweir //UNUSED2009-05 const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
1953cdf0e10cSrcweir //UNUSED2009-05 ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChilds(), GetShapeChilds() );
1954cdf0e10cSrcweir //UNUSED2009-05 //! order is background shapes, header, table or notes, footer, foreground shapes, controls
1955cdf0e10cSrcweir //UNUSED2009-05 if(mpHeader)
1956cdf0e10cSrcweir //UNUSED2009-05 mpHeader->SetCurrentIndexInParent(aCount.nBackShapes);
1957cdf0e10cSrcweir //UNUSED2009-05 if (mpTable)
1958cdf0e10cSrcweir //UNUSED2009-05 mpTable->SetCurrentIndexInParent(aCount.nBackShapes + aCount.nHeaders);
1959cdf0e10cSrcweir //UNUSED2009-05 if (mpFooter)
1960cdf0e10cSrcweir //UNUSED2009-05 mpFooter->SetCurrentIndexInParent(aCount.nBackShapes + aCount.nHeaders + aCount.nTables + aCount.nNoteParagraphs);
1961cdf0e10cSrcweir //UNUSED2009-05
1962cdf0e10cSrcweir //UNUSED2009-05 if (mpNotesChilds)
1963cdf0e10cSrcweir //UNUSED2009-05 mpNotesChilds->SetOffset(aCount.nBackShapes + aCount.nHeaders);
1964cdf0e10cSrcweir //UNUSED2009-05 }
1965cdf0e10cSrcweir //UNUSED2009-05 }
1966