Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "AccessibleDocumentPagePreview.hxx"
31 : : #include "AccessiblePreviewTable.hxx"
32 : : #include "AccessiblePageHeader.hxx"
33 : : #include "AccessibilityHints.hxx"
34 : : #include "AccessibleText.hxx"
35 : : #include "document.hxx"
36 : : #include "prevwsh.hxx"
37 : : #include "prevloc.hxx"
38 : : #include "drwlayer.hxx"
39 : : #include "editsrc.hxx"
40 : : #include "scresid.hxx"
41 : : #include "sc.hrc"
42 : : #include "DrawModelBroadcaster.hxx"
43 : : #include "docsh.hxx"
44 : : #include "drawview.hxx"
45 : : #include "preview.hxx"
46 : : #include "postit.hxx"
47 : :
48 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
49 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
50 : : #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
51 : :
52 : : #include <unotools/accessiblestatesethelper.hxx>
53 : : #include <tools/gen.hxx>
54 : : #include <svx/svdpage.hxx>
55 : : #include <svx/svdobj.hxx>
56 : : #include <svx/AccessibleTextHelper.hxx>
57 : : #include <svx/AccessibleShape.hxx>
58 : : #include <svx/ShapeTypeHandler.hxx>
59 : : #include <toolkit/helper/convert.hxx>
60 : : #include <svx/unoshape.hxx>
61 : : #include <unotools/accessiblerelationsethelper.hxx>
62 : : #include <vcl/svapp.hxx>
63 : : #include <comphelper/servicehelper.hxx>
64 : :
65 : : #include <vector>
66 : : #include <list>
67 : : #include <algorithm>
68 : : #include <memory>
69 : :
70 : : using namespace ::com::sun::star;
71 : : using namespace ::com::sun::star::accessibility;
72 : :
73 : : //=========================================================================
74 : :
75 : : typedef std::list< uno::Reference< XAccessible > > ScXAccList;
76 : :
77 : :
78 : 84 : struct ScAccNote
79 : : {
80 : : String maNoteText;
81 : : Rectangle maRect;
82 : : ScAddress maNoteCell;
83 : : ::accessibility::AccessibleTextHelper* mpTextHelper;
84 : : sal_Int32 mnParaCount;
85 : : sal_Bool mbMarkNote;
86 : :
87 [ + - ]: 84 : ScAccNote() : mpTextHelper(NULL), mnParaCount(0) {}
88 : : };
89 : :
90 : : class ScNotesChildren
91 : : {
92 : : public:
93 : : ScNotesChildren(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview* pAccDoc);
94 : : ~ScNotesChildren();
95 : : void Init(const Rectangle& rVisRect, sal_Int32 nOffset);
96 : :
97 : : sal_Int32 GetChildrenCount() const;
98 : : uno::Reference<XAccessible> GetChild(sal_Int32 nIndex) const;
99 : : uno::Reference<XAccessible> GetAt(const awt::Point& rPoint) const;
100 : :
101 : : void DataChanged(const Rectangle& rVisRect);
102 : :
103 : : private:
104 : : ScPreviewShell* mpViewShell;
105 : : ScAccessibleDocumentPagePreview* mpAccDoc;
106 : : typedef std::vector<ScAccNote> ScAccNotes;
107 : : mutable ScAccNotes maNotes;
108 : : mutable ScAccNotes maMarks;
109 : : sal_Int32 mnParagraphs;
110 : : sal_Int32 mnOffset;
111 : :
112 : : ::accessibility::AccessibleTextHelper* CreateTextHelper(const String& rString, const Rectangle& rVisRect, const ScAddress& aCellPos, sal_Bool bMarkNote, sal_Int32 nChildOffset) const;
113 : : sal_Int32 AddNotes(const ScPreviewLocationData& rData, const Rectangle& rVisRect, sal_Bool bMark, ScAccNotes& rNotes);
114 : :
115 : : sal_Int8 CompareCell(const ScAddress& aCell1, const ScAddress& aCell2);
116 : : void CollectChildren(const ScAccNote& rNote, ScXAccList& rList);
117 : : sal_Int32 CheckChanges(const ScPreviewLocationData& rData, const Rectangle& rVisRect,
118 : : sal_Bool bMark, ScAccNotes& rOldNotes, ScAccNotes& rNewNotes,
119 : : ScXAccList& rOldParas, ScXAccList& rNewParas);
120 : :
121 : : inline ScDocument* GetDocument() const;
122 : : };
123 : :
124 : 16 : ScNotesChildren::ScNotesChildren(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview* pAccDoc)
125 : : : mpViewShell(pViewShell),
126 : : mpAccDoc(pAccDoc),
127 : : mnParagraphs(0),
128 [ + - ]: 16 : mnOffset(0)
129 : : {
130 : 16 : }
131 : :
132 : : struct DeleteAccNote
133 : : {
134 : 0 : void operator()(ScAccNote& rNote)
135 : : {
136 [ # # ]: 0 : if (rNote.mpTextHelper)
137 [ # # ]: 0 : DELETEZ( rNote.mpTextHelper);
138 : 0 : }
139 : : };
140 : :
141 : 16 : ScNotesChildren::~ScNotesChildren()
142 : : {
143 [ + - ]: 16 : std::for_each(maNotes.begin(), maNotes.end(), DeleteAccNote());
144 [ + - ]: 16 : std::for_each(maMarks.begin(), maMarks.end(), DeleteAccNote());
145 : 16 : }
146 : :
147 : 0 : ::accessibility::AccessibleTextHelper* ScNotesChildren::CreateTextHelper(const String& rString, const Rectangle& rVisRect, const ScAddress& aCellPos, sal_Bool bMarkNote, sal_Int32 nChildOffset) const
148 : : {
149 : 0 : ::accessibility::AccessibleTextHelper* pTextHelper = NULL;
150 : :
151 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
152 : : ::std::auto_ptr < ScAccessibleTextData > pAccessiblePreviewHeaderCellTextData
153 [ # # ][ # # ]: 0 : (new ScAccessibleNoteTextData(mpViewShell, rString, aCellPos, bMarkNote));
154 [ # # ][ # # ]: 0 : ::std::auto_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(pAccessiblePreviewHeaderCellTextData));
[ # # ]
155 : : SAL_WNODEPRECATED_DECLARATIONS_POP
156 : :
157 [ # # ][ # # ]: 0 : pTextHelper = new ::accessibility::AccessibleTextHelper(pEditSource);
[ # # ]
158 : :
159 [ # # ]: 0 : if (pTextHelper)
160 : : {
161 [ # # ][ # # ]: 0 : pTextHelper->SetEventSource(mpAccDoc);
[ # # ]
162 [ # # ]: 0 : pTextHelper->SetStartIndex(nChildOffset);
163 [ # # ]: 0 : pTextHelper->SetOffset(rVisRect.TopLeft());
164 : : }
165 : :
166 [ # # ][ # # ]: 0 : return pTextHelper;
167 : : }
168 : :
169 : 32 : sal_Int32 ScNotesChildren::AddNotes(const ScPreviewLocationData& rData, const Rectangle& rVisRect, sal_Bool bMark, ScAccNotes& rNotes)
170 : : {
171 : 32 : sal_Int32 nCount = rData.GetNoteCountInRange(rVisRect, bMark);
172 : :
173 : 32 : rNotes.reserve(nCount);
174 : :
175 : 32 : sal_Int32 nParagraphs(0);
176 : 32 : ScDocument* pDoc = GetDocument();
177 [ + - ]: 32 : if (pDoc)
178 : : {
179 [ + - ]: 32 : ScAccNote aNote;
180 : 32 : aNote.mbMarkNote = bMark;
181 [ + + ]: 32 : if (bMark)
182 : 16 : aNote.mnParaCount = 1;
183 [ - + ]: 32 : for (sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex)
184 : : {
185 [ # # ][ # # ]: 0 : if (rData.GetNoteInRange(rVisRect, nIndex, bMark, aNote.maNoteCell, aNote.maRect))
186 : : {
187 [ # # ]: 0 : if (bMark)
188 : : {
189 : : // Document not needed, because only the cell address, but not the tablename is needed
190 [ # # ]: 0 : aNote.maNoteCell.Format( aNote.maNoteText, SCA_VALID, NULL );
191 : : }
192 : : else
193 : : {
194 [ # # ][ # # ]: 0 : if( ScPostIt* pNote = pDoc->GetNotes( aNote.maNoteCell.Tab() )->findByAddress( aNote.maNoteCell ) )
[ # # ]
195 [ # # ][ # # ]: 0 : aNote.maNoteText = pNote->GetText();
196 [ # # ]: 0 : aNote.mpTextHelper = CreateTextHelper(aNote.maNoteText, aNote.maRect, aNote.maNoteCell, aNote.mbMarkNote, nParagraphs + mnOffset);
197 [ # # ]: 0 : if (aNote.mpTextHelper)
198 [ # # ]: 0 : aNote.mnParaCount = aNote.mpTextHelper->GetChildCount();
199 : : }
200 : 0 : nParagraphs += aNote.mnParaCount;
201 [ # # ]: 0 : rNotes.push_back(aNote);
202 : : }
203 [ + - ]: 32 : }
204 : : }
205 : 32 : return nParagraphs;
206 : : }
207 : :
208 : 16 : void ScNotesChildren::Init(const Rectangle& rVisRect, sal_Int32 nOffset)
209 : : {
210 [ + - ][ + - ]: 16 : if (mpViewShell && !mnParagraphs)
211 : : {
212 : 16 : mnOffset = nOffset;
213 : 16 : const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
214 : :
215 : 16 : mnParagraphs = AddNotes(rData, rVisRect, false, maMarks);
216 : 16 : mnParagraphs += AddNotes(rData, rVisRect, sal_True, maNotes);
217 : : }
218 : 16 : }
219 : :
220 : 0 : sal_Int32 ScNotesChildren::GetChildrenCount() const
221 : : {
222 : 0 : return mnParagraphs;
223 : : }
224 : :
225 : : struct ScParaFound
226 : : {
227 : : sal_Int32 mnIndex;
228 : 0 : ScParaFound(sal_Int32 nIndex) : mnIndex(nIndex) {}
229 : 0 : sal_Bool operator() (const ScAccNote& rNote)
230 : : {
231 : 0 : sal_Bool bResult(false);
232 [ # # ]: 0 : if (rNote.mnParaCount > mnIndex)
233 : 0 : bResult = sal_True;
234 : : else
235 : 0 : mnIndex -= rNote.mnParaCount;
236 : 0 : return bResult;
237 : : }
238 : : };
239 : :
240 : 0 : uno::Reference<XAccessible> ScNotesChildren::GetChild(sal_Int32 nIndex) const
241 : : {
242 : 0 : uno::Reference<XAccessible> xAccessible;
243 : :
244 [ # # ]: 0 : if (nIndex < mnParagraphs)
245 : : {
246 [ # # ]: 0 : if (nIndex < static_cast<sal_Int32>(maMarks.size()))
247 : : {
248 : 0 : ScAccNotes::iterator aEndItr = maMarks.end();
249 : 0 : ScParaFound aParaFound(nIndex);
250 [ # # ]: 0 : ScAccNotes::iterator aItr = std::find_if(maMarks.begin(), aEndItr, aParaFound);
251 [ # # ]: 0 : if (aItr != aEndItr)
252 : : {
253 : : OSL_ENSURE((aItr->maNoteCell == maMarks[nIndex].maNoteCell) && (aItr->mbMarkNote == maMarks[nIndex].mbMarkNote), "wrong note found");
254 : : }
255 : : else
256 : : {
257 : : OSL_FAIL("wrong note found");
258 : : }
259 [ # # ]: 0 : if (!aItr->mpTextHelper)
260 [ # # ]: 0 : 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
261 [ # # ][ # # ]: 0 : xAccessible = aItr->mpTextHelper->GetChild(aParaFound.mnIndex + aItr->mpTextHelper->GetStartIndex());
[ # # ]
262 : : }
263 : : else
264 : : {
265 : 0 : nIndex -= maMarks.size();
266 : 0 : ScAccNotes::iterator aEndItr = maNotes.end();
267 : 0 : ScParaFound aParaFound(nIndex);
268 [ # # ]: 0 : ScAccNotes::iterator aItr = std::find_if(maNotes.begin(), aEndItr, aParaFound);
269 [ # # ][ # # ]: 0 : if (aEndItr != aItr)
270 : : {
271 [ # # ]: 0 : if (!aItr->mpTextHelper)
272 [ # # ]: 0 : aItr->mpTextHelper = CreateTextHelper(aItr->maNoteText, aItr->maRect, aItr->maNoteCell, aItr->mbMarkNote, (nIndex - aParaFound.mnIndex) + mnOffset + maMarks.size());
273 [ # # ][ # # ]: 0 : xAccessible = aItr->mpTextHelper->GetChild(aParaFound.mnIndex + aItr->mpTextHelper->GetStartIndex());
[ # # ]
274 : : }
275 : : }
276 : : }
277 : :
278 : 0 : return xAccessible;
279 : : }
280 : :
281 : : struct ScPointFound
282 : : {
283 : : Rectangle maPoint;
284 : : sal_Int32 mnParagraphs;
285 [ # # ]: 0 : ScPointFound(const Point& rPoint) : maPoint(rPoint, Size(0, 0)), mnParagraphs(0) {}
286 : 0 : sal_Bool operator() (const ScAccNote& rNote)
287 : : {
288 : 0 : sal_Bool bResult(false);
289 [ # # ]: 0 : if (maPoint.IsInside(rNote.maRect))
290 : 0 : bResult = sal_True;
291 : : else
292 : 0 : mnParagraphs += rNote.mnParaCount;
293 : 0 : return bResult;
294 : : }
295 : : };
296 : :
297 : 0 : uno::Reference<XAccessible> ScNotesChildren::GetAt(const awt::Point& rPoint) const
298 : : {
299 : 0 : uno::Reference<XAccessible> xAccessible;
300 : :
301 [ # # ]: 0 : ScPointFound aPointFound(Point(rPoint.X, rPoint.Y));
302 : :
303 : 0 : ScAccNotes::iterator aEndItr = maMarks.end();
304 [ # # ]: 0 : ScAccNotes::iterator aItr = std::find_if(maMarks.begin(), aEndItr, aPointFound);
305 [ # # ][ # # ]: 0 : if (aEndItr == aItr)
306 : : {
307 : 0 : aEndItr = maNotes.end();
308 [ # # ]: 0 : aItr = std::find_if(maNotes.begin(), aEndItr, aPointFound);
309 : : }
310 [ # # ][ # # ]: 0 : if (aEndItr != aItr)
311 : : {
312 [ # # ]: 0 : if (!aItr->mpTextHelper)
313 [ # # ]: 0 : aItr->mpTextHelper = CreateTextHelper(aItr->maNoteText, aItr->maRect, aItr->maNoteCell, aItr->mbMarkNote, aPointFound.mnParagraphs + mnOffset);
314 [ # # ][ # # ]: 0 : xAccessible = aItr->mpTextHelper->GetAt(rPoint);
315 : : }
316 : :
317 : 0 : return xAccessible;
318 : : }
319 : :
320 : 0 : sal_Int8 ScNotesChildren::CompareCell(const ScAddress& aCell1, const ScAddress& aCell2)
321 : : {
322 : : OSL_ENSURE(aCell1.Tab() == aCell2.Tab(), "the notes should be on the same table");
323 : 0 : sal_Int8 nResult(0);
324 [ # # ]: 0 : if (aCell1 != aCell2)
325 : : {
326 [ # # ]: 0 : if (aCell1.Row() == aCell2.Row())
327 [ # # ]: 0 : nResult = (aCell1.Col() < aCell2.Col()) ? -1 : 1;
328 : : else
329 [ # # ]: 0 : nResult = (aCell1.Row() < aCell2.Row()) ? -1 : 1;
330 : : }
331 : 0 : return nResult;
332 : : }
333 : :
334 : 0 : void ScNotesChildren::CollectChildren(const ScAccNote& rNote, ScXAccList& rList)
335 : : {
336 [ # # ]: 0 : if (rNote.mpTextHelper)
337 [ # # ]: 0 : for (sal_Int32 i = 0; i < rNote.mnParaCount; ++i)
338 [ # # ]: 0 : rList.push_back(rNote.mpTextHelper->GetChild(i + rNote.mpTextHelper->GetStartIndex()));
339 : 0 : }
340 : :
341 : 52 : sal_Int32 ScNotesChildren::CheckChanges(const ScPreviewLocationData& rData,
342 : : const Rectangle& rVisRect, sal_Bool bMark, ScAccNotes& rOldNotes,
343 : : ScAccNotes& rNewNotes, ScXAccList& rOldParas, ScXAccList& rNewParas)
344 : : {
345 : 52 : sal_Int32 nCount = rData.GetNoteCountInRange(rVisRect, bMark);
346 : :
347 : 52 : rNewNotes.reserve(nCount);
348 : :
349 : 52 : sal_Int32 nParagraphs(0);
350 : 52 : ScDocument* pDoc = GetDocument();
351 [ + - ]: 52 : if (pDoc)
352 : : {
353 [ + - ]: 52 : ScAccNote aNote;
354 : 52 : aNote.mbMarkNote = bMark;
355 [ + + ]: 52 : if (bMark)
356 : 26 : aNote.mnParaCount = 1;
357 : 52 : ScAccNotes::iterator aItr = rOldNotes.begin();
358 : 52 : ScAccNotes::iterator aEndItr = rOldNotes.end();
359 : 52 : sal_Bool bAddNote(false);
360 [ - + ]: 52 : for (sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex)
361 : : {
362 [ # # ][ # # ]: 0 : if (rData.GetNoteInRange(rVisRect, nIndex, bMark, aNote.maNoteCell, aNote.maRect))
363 : : {
364 [ # # ]: 0 : if (bMark)
365 : : {
366 : : // Document not needed, because only the cell address, but not the tablename is needed
367 [ # # ]: 0 : aNote.maNoteCell.Format( aNote.maNoteText, SCA_VALID, NULL );
368 : : }
369 : : else
370 : : {
371 [ # # ][ # # ]: 0 : if( ScPostIt* pNote = pDoc->GetNotes( aNote.maNoteCell.Tab() )->findByAddress( aNote.maNoteCell ) )
[ # # ]
372 [ # # ][ # # ]: 0 : aNote.maNoteText = pNote->GetText();
373 : : }
374 : :
375 : 0 : sal_Int8 nCompare(-1); // if there are no more old children it is always a new one
376 [ # # ][ # # ]: 0 : if (aItr != aEndItr)
377 : 0 : nCompare = CompareCell(aNote.maNoteCell, aItr->maNoteCell);
378 [ # # ]: 0 : if (nCompare == 0)
379 : : {
380 [ # # ][ # # ]: 0 : if (aNote.maNoteText == aItr->maNoteText)
381 : : {
382 : 0 : aNote.mpTextHelper = aItr->mpTextHelper;
383 [ # # ][ # # ]: 0 : if (aNote.maRect != aItr->maRect) //neue VisArea setzen
384 : : {
385 [ # # ]: 0 : aNote.mpTextHelper->SetOffset(aNote.maRect.TopLeft());
386 [ # # ]: 0 : aNote.mpTextHelper->UpdateChildren();
387 : : //OSL_ENSURE(aItr->maRect.GetSize() == aNote.maRect.GetSize(), "size should be the same, because the text is not changed");
388 : : // could be changed, because only a part of the note is visible
389 : : }
390 : : }
391 : : else
392 : : {
393 [ # # ]: 0 : aNote.mpTextHelper = CreateTextHelper(aNote.maNoteText, aNote.maRect, aNote.maNoteCell, aNote.mbMarkNote, nParagraphs + mnOffset);
394 [ # # ]: 0 : if (aNote.mpTextHelper)
395 [ # # ]: 0 : aNote.mnParaCount = aNote.mpTextHelper->GetChildCount();
396 : : // collect removed children
397 [ # # ]: 0 : CollectChildren(*aItr, rOldParas);
398 [ # # ][ # # ]: 0 : DELETEZ(aItr->mpTextHelper);
399 : : // collect new children
400 [ # # ]: 0 : CollectChildren(aNote, rNewParas);
401 : : }
402 : 0 : bAddNote = sal_True;
403 : : // not necessary, because this branch should not be reached if it is the end
404 : : //if (aItr != aEndItr)
405 : 0 : ++aItr;
406 : : }
407 [ # # ]: 0 : else if (nCompare < 0)
408 : : {
409 [ # # ]: 0 : aNote.mpTextHelper = CreateTextHelper(aNote.maNoteText, aNote.maRect, aNote.maNoteCell, aNote.mbMarkNote, nParagraphs + mnOffset);
410 [ # # ]: 0 : if (aNote.mpTextHelper)
411 [ # # ]: 0 : aNote.mnParaCount = aNote.mpTextHelper->GetChildCount();
412 : : // collect new children
413 [ # # ]: 0 : CollectChildren(aNote, rNewParas);
414 : 0 : bAddNote = sal_True;
415 : : }
416 : : else
417 : : {
418 : : // collect removed children
419 [ # # ]: 0 : CollectChildren(*aItr, rOldParas);
420 [ # # ][ # # ]: 0 : DELETEZ(aItr->mpTextHelper);
421 : :
422 : : // no note to add
423 : : // not necessary, because this branch should not be reached if it is the end
424 : : //if (aItr != aEndItr)
425 : 0 : ++aItr;
426 : : }
427 [ # # ]: 0 : if (bAddNote)
428 : : {
429 : 0 : nParagraphs += aNote.mnParaCount;
430 [ # # ]: 0 : rNewNotes.push_back(aNote);
431 : 0 : bAddNote = false;
432 : : }
433 : : }
434 [ + - ]: 52 : }
435 : : }
436 : 52 : return nParagraphs;
437 : : }
438 : :
439 : : struct ScChildGone
440 : : {
441 : : ScAccessibleDocumentPagePreview* mpAccDoc;
442 : 26 : ScChildGone(ScAccessibleDocumentPagePreview* pAccDoc) : mpAccDoc(pAccDoc) {}
443 : 0 : void operator() (const uno::Reference<XAccessible>& xAccessible) const
444 : : {
445 [ # # ]: 0 : if (mpAccDoc)
446 : : {
447 [ # # ]: 0 : AccessibleEventObject aEvent;
448 : 0 : aEvent.EventId = AccessibleEventId::CHILD;
449 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference< XAccessibleContext >(mpAccDoc);
[ # # ]
450 [ # # ]: 0 : aEvent.OldValue <<= xAccessible;
451 : :
452 [ # # ][ # # ]: 0 : mpAccDoc->CommitChange(aEvent); // gone child - event
453 : : }
454 : 0 : }
455 : : };
456 : :
457 : : struct ScChildNew
458 : : {
459 : : ScAccessibleDocumentPagePreview* mpAccDoc;
460 : 26 : ScChildNew(ScAccessibleDocumentPagePreview* pAccDoc) : mpAccDoc(pAccDoc) {}
461 : 0 : void operator() (const uno::Reference<XAccessible>& xAccessible) const
462 : : {
463 [ # # ]: 0 : if (mpAccDoc)
464 : : {
465 [ # # ]: 0 : AccessibleEventObject aEvent;
466 : 0 : aEvent.EventId = AccessibleEventId::CHILD;
467 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference< XAccessibleContext >(mpAccDoc);
[ # # ]
468 [ # # ]: 0 : aEvent.NewValue <<= xAccessible;
469 : :
470 [ # # ][ # # ]: 0 : mpAccDoc->CommitChange(aEvent); // new child - event
471 : : }
472 : 0 : }
473 : : };
474 : :
475 : 26 : void ScNotesChildren::DataChanged(const Rectangle& rVisRect)
476 : : {
477 [ + - ][ + - ]: 26 : if (mpViewShell && mpAccDoc)
478 : : {
479 [ + - ]: 26 : ScXAccList aNewParas;
480 [ + - ]: 26 : ScXAccList aOldParas;
481 [ + - ]: 26 : ScAccNotes aNewMarks;
482 [ + - ][ + - ]: 26 : mnParagraphs = CheckChanges(mpViewShell->GetLocationData(), rVisRect, sal_True, maMarks, aNewMarks, aOldParas, aNewParas);
483 [ + - ]: 26 : maMarks = aNewMarks;
484 [ + - ]: 26 : ScAccNotes aNewNotes;
485 [ + - ][ + - ]: 26 : mnParagraphs += CheckChanges(mpViewShell->GetLocationData(), rVisRect, false, maNotes, aNewNotes, aOldParas, aNewParas);
486 [ + - ]: 26 : maNotes = aNewNotes;
487 : :
488 [ + - ]: 26 : std::for_each(aOldParas.begin(), aOldParas.end(), ScChildGone(mpAccDoc));
489 [ + - ]: 26 : std::for_each(aNewParas.begin(), aNewParas.end(), ScChildNew(mpAccDoc));
490 : : }
491 : 26 : }
492 : :
493 : : struct ScChangeOffset
494 : : {
495 : : sal_Int32 mnDiff;
496 : : ScChangeOffset(sal_Int32 nDiff) : mnDiff(nDiff) {}
497 : : void operator() (const ScAccNote& rNote)
498 : : {
499 : : if (rNote.mpTextHelper)
500 : : rNote.mpTextHelper->SetStartIndex(rNote.mpTextHelper->GetStartIndex() + mnDiff);
501 : : }
502 : : };
503 : :
504 : 84 : inline ScDocument* ScNotesChildren::GetDocument() const
505 : : {
506 : 84 : ScDocument* pDoc = NULL;
507 [ + - ]: 84 : if (mpViewShell)
508 : 84 : pDoc = mpViewShell->GetDocument();
509 : 84 : return pDoc;
510 : : }
511 : :
512 [ + - ]: 72 : class ScIAccessibleViewForwarder : public ::accessibility::IAccessibleViewForwarder
513 : : {
514 : : public:
515 : : ScIAccessibleViewForwarder();
516 : : ScIAccessibleViewForwarder(ScPreviewShell* pViewShell,
517 : : ScAccessibleDocumentPagePreview* pAccDoc,
518 : : const MapMode& aMapMode);
519 : : ~ScIAccessibleViewForwarder();
520 : :
521 : : ///===== IAccessibleViewForwarder ========================================
522 : :
523 : : virtual sal_Bool IsValid (void) const;
524 : : virtual Rectangle GetVisibleArea() const;
525 : : virtual Point LogicToPixel (const Point& rPoint) const;
526 : : virtual Size LogicToPixel (const Size& rSize) const;
527 : : virtual Point PixelToLogic (const Point& rPoint) const;
528 : : virtual Size PixelToLogic (const Size& rSize) const;
529 : :
530 : : private:
531 : : ScPreviewShell* mpViewShell;
532 : : ScAccessibleDocumentPagePreview* mpAccDoc;
533 : : MapMode maMapMode;
534 : : sal_Bool mbValid;
535 : : };
536 : :
537 : 136 : ScIAccessibleViewForwarder::ScIAccessibleViewForwarder()
538 [ + - ]: 136 : : mbValid(false)
539 : : {
540 : 136 : }
541 : :
542 : 0 : ScIAccessibleViewForwarder::ScIAccessibleViewForwarder(ScPreviewShell* pViewShell,
543 : : ScAccessibleDocumentPagePreview* pAccDoc,
544 : : const MapMode& aMapMode)
545 : : : mpViewShell(pViewShell),
546 : : mpAccDoc(pAccDoc),
547 : : maMapMode(aMapMode),
548 [ # # ]: 0 : mbValid(sal_True)
549 : : {
550 : 0 : }
551 : :
552 [ + - ]: 208 : ScIAccessibleViewForwarder::~ScIAccessibleViewForwarder()
553 : : {
554 [ - + ]: 208 : }
555 : :
556 : : ///===== IAccessibleViewForwarder ========================================
557 : :
558 : 0 : sal_Bool ScIAccessibleViewForwarder::IsValid (void) const
559 : : {
560 [ # # ]: 0 : SolarMutexGuard aGuard;
561 [ # # ]: 0 : return mbValid;
562 : : }
563 : :
564 : 0 : Rectangle ScIAccessibleViewForwarder::GetVisibleArea() const
565 : : {
566 [ # # ]: 0 : SolarMutexGuard aGuard;
567 [ # # ]: 0 : Rectangle aVisRect;
568 : 0 : Window* pWin = mpViewShell->GetWindow();
569 [ # # ]: 0 : if (pWin)
570 : : {
571 [ # # ]: 0 : aVisRect.SetSize(pWin->GetOutputSizePixel());
572 : 0 : aVisRect.SetPos(Point(0, 0));
573 : :
574 [ # # ]: 0 : aVisRect = pWin->PixelToLogic(aVisRect, maMapMode);
575 : : }
576 : :
577 [ # # ]: 0 : return aVisRect;
578 : : }
579 : :
580 : 0 : Point ScIAccessibleViewForwarder::LogicToPixel (const Point& rPoint) const
581 : : {
582 [ # # ]: 0 : SolarMutexGuard aGuard;
583 : 0 : Point aPoint;
584 : 0 : Window* pWin = mpViewShell->GetWindow();
585 [ # # ][ # # ]: 0 : if (pWin && mpAccDoc)
586 : : {
587 [ # # ]: 0 : Rectangle aRect(mpAccDoc->GetBoundingBoxOnScreen());
588 [ # # ]: 0 : aPoint = pWin->LogicToPixel(rPoint, maMapMode) + aRect.TopLeft();
589 : : }
590 : :
591 [ # # ]: 0 : return aPoint;
592 : : }
593 : :
594 : 0 : Size ScIAccessibleViewForwarder::LogicToPixel (const Size& rSize) const
595 : : {
596 [ # # ]: 0 : SolarMutexGuard aGuard;
597 : 0 : Size aSize;
598 : 0 : Window* pWin = mpViewShell->GetWindow();
599 [ # # ]: 0 : if (pWin)
600 [ # # ]: 0 : aSize = pWin->LogicToPixel(rSize, maMapMode);
601 [ # # ]: 0 : return aSize;
602 : : }
603 : :
604 : 0 : Point ScIAccessibleViewForwarder::PixelToLogic (const Point& rPoint) const
605 : : {
606 [ # # ]: 0 : SolarMutexGuard aGuard;
607 : 0 : Point aPoint;
608 : 0 : Window* pWin = mpViewShell->GetWindow();
609 [ # # ][ # # ]: 0 : if (pWin && mpAccDoc)
610 : : {
611 [ # # ]: 0 : Rectangle aRect(mpAccDoc->GetBoundingBoxOnScreen());
612 [ # # ]: 0 : aPoint = pWin->PixelToLogic(rPoint - aRect.TopLeft(), maMapMode);
613 : : }
614 [ # # ]: 0 : return aPoint;
615 : : }
616 : :
617 : 0 : Size ScIAccessibleViewForwarder::PixelToLogic (const Size& rSize) const
618 : : {
619 [ # # ]: 0 : SolarMutexGuard aGuard;
620 : 0 : Size aSize;
621 : 0 : Window* pWin = mpViewShell->GetWindow();
622 [ # # ]: 0 : if (pWin)
623 [ # # ]: 0 : aSize = pWin->PixelToLogic(rSize, maMapMode);
624 [ # # ]: 0 : return aSize;
625 : : }
626 : :
627 : 0 : struct ScShapeChild
628 : : {
629 : 0 : ScShapeChild() : mpAccShape(NULL) {}
630 : : ScShapeChild(const ScShapeChild& rOld);
631 : : ~ScShapeChild();
632 : : mutable ::accessibility::AccessibleShape* mpAccShape;
633 : : com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxShape;
634 : : sal_Int32 mnRangeId;
635 : : };
636 : :
637 : 0 : ScShapeChild::ScShapeChild(const ScShapeChild& rOld)
638 : : :
639 : : mpAccShape(rOld.mpAccShape),
640 : : mxShape(rOld.mxShape),
641 : 0 : mnRangeId(rOld.mnRangeId)
642 : : {
643 [ # # ]: 0 : if (mpAccShape)
644 : 0 : mpAccShape->acquire();
645 : 0 : }
646 : :
647 : 0 : ScShapeChild::~ScShapeChild()
648 : : {
649 [ # # ]: 0 : if (mpAccShape)
650 : : {
651 [ # # ]: 0 : mpAccShape->dispose();
652 : 0 : mpAccShape->release();
653 : : }
654 : 0 : }
655 : :
656 : : struct ScShapeChildLess
657 : : {
658 : 0 : sal_Bool operator()(const ScShapeChild& rChild1, const ScShapeChild& rChild2) const
659 : : {
660 : 0 : sal_Bool bResult(false);
661 [ # # ][ # # ]: 0 : if (rChild1.mxShape.is() && rChild2.mxShape.is())
[ # # ]
662 : 0 : bResult = (rChild1.mxShape.get() < rChild2.mxShape.get());
663 : 0 : return bResult;
664 : : }
665 : : };
666 : :
667 : : typedef std::vector<ScShapeChild> ScShapeChildVec;
668 : :
669 [ + - ][ + - ]: 416 : struct ScShapeRange
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
670 : : {
671 : : ScShapeChildVec maBackShapes;
672 : : ScShapeChildVec maForeShapes; // inclusive internal shapes
673 : : ScShapeChildVec maControls;
674 : : Rectangle maPixelRect;
675 : : MapMode maMapMode;
676 : : ScIAccessibleViewForwarder maViewForwarder;
677 : : };
678 : :
679 : : typedef std::vector<ScShapeRange> ScShapeRangeVec;
680 : :
681 : : class ScShapeChildren : public SfxListener,
682 : : public ::accessibility::IAccessibleParent
683 : : {
684 : : public:
685 : : ScShapeChildren(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview* pAccDoc);
686 : : ~ScShapeChildren();
687 : :
688 : : ///===== SfxListener =====================================================
689 : :
690 : : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
691 : :
692 : : ///===== IAccessibleParent ==============================================
693 : :
694 : : virtual sal_Bool ReplaceChild (
695 : : ::accessibility::AccessibleShape* pCurrentChild,
696 : : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
697 : : const long _nIndex,
698 : : const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo
699 : : ) throw (::com::sun::star::uno::RuntimeException);
700 : :
701 : : ///===== Internal ========================================================
702 : :
703 : : void Init();
704 : :
705 : : sal_Int32 GetBackShapeCount() const;
706 : : uno::Reference<XAccessible> GetBackShape(sal_Int32 nIndex) const;
707 : : sal_Int32 GetForeShapeCount() const;
708 : : uno::Reference<XAccessible> GetForeShape(sal_Int32 nIndex) const;
709 : : sal_Int32 GetControlCount() const;
710 : : uno::Reference<XAccessible> GetControl(sal_Int32 nIndex) const;
711 : : uno::Reference<XAccessible> GetForegroundShapeAt(const awt::Point& rPoint) const; // inclusive controls
712 : : uno::Reference<XAccessible> GetBackgroundShapeAt(const awt::Point& rPoint) const;
713 : :
714 : : void DataChanged();
715 : : void VisAreaChanged() const;
716 : :
717 : : void SetDrawBroadcaster();
718 : : private:
719 : : ScAccessibleDocumentPagePreview* mpAccDoc;
720 : : ScPreviewShell* mpViewShell;
721 : : ScShapeRangeVec maShapeRanges;
722 : :
723 : : void FindChanged(ScShapeChildVec& aOld, ScShapeChildVec& aNew) const;
724 : : void FindChanged(ScShapeRange& aOld, ScShapeRange& aNew) const;
725 : : ::accessibility::AccessibleShape* GetAccShape(const ScShapeChild& rShape) const;
726 : : ::accessibility::AccessibleShape* GetAccShape(const ScShapeChildVec& rShapes, sal_Int32 nIndex) const;
727 : : void FillShapes(const Rectangle& aPixelPaintRect, const MapMode& aMapMode, sal_uInt8 nRangeId);
728 : :
729 : : // void AddShape(const uno::Reference<drawing::XShape>& xShape, SdrLayerID aLayerID);
730 : : // void RemoveShape(const uno::Reference<drawing::XShape>& xShape, SdrLayerID aLayerID);
731 : : SdrPage* GetDrawPage() const;
732 : : };
733 : :
734 : 16 : ScShapeChildren::ScShapeChildren(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview* pAccDoc)
735 : : :
736 : : mpAccDoc(pAccDoc),
737 : : mpViewShell(pViewShell),
738 [ + - ]: 16 : maShapeRanges(SC_PREVIEW_MAXRANGES)
739 : : {
740 [ + - ]: 16 : if (pViewShell)
741 : : {
742 [ + - ][ + - ]: 16 : SfxBroadcaster* pDrawBC = pViewShell->GetDocument()->GetDrawBroadcaster();
743 [ + - ]: 16 : if (pDrawBC)
744 [ + - ]: 16 : StartListening(*pDrawBC);
745 : : }
746 : 16 : }
747 : :
748 : 16 : ScShapeChildren::~ScShapeChildren()
749 : : {
750 [ + - ]: 16 : if (mpViewShell)
751 : : {
752 [ + - ][ + - ]: 16 : SfxBroadcaster* pDrawBC = mpViewShell->GetDocument()->GetDrawBroadcaster();
753 [ + - ]: 16 : if (pDrawBC)
754 [ + - ]: 16 : EndListening(*pDrawBC);
755 : : }
756 [ - + ]: 32 : }
757 : :
758 : 0 : void ScShapeChildren::SetDrawBroadcaster()
759 : : {
760 [ # # ]: 0 : if (mpViewShell)
761 : : {
762 : 0 : SfxBroadcaster* pDrawBC = mpViewShell->GetDocument()->GetDrawBroadcaster();
763 [ # # ]: 0 : if (pDrawBC)
764 : 0 : StartListening(*pDrawBC, sal_True);
765 : : }
766 : 0 : }
767 : :
768 : 2 : void ScShapeChildren::Notify(SfxBroadcaster&, const SfxHint& rHint)
769 : : {
770 [ - + ]: 2 : if ( rHint.ISA( SdrHint ) )
771 : : {
772 [ # # ][ # # ]: 0 : const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
773 [ # # ]: 0 : if (pSdrHint)
774 : : {
775 : 0 : SdrObject* pObj = const_cast<SdrObject*>(pSdrHint->GetObject());
776 [ # # ][ # # ]: 0 : if (pObj && (pObj->GetPage() == GetDrawPage()))
[ # # ]
777 : : {
778 [ # # ]: 0 : switch (pSdrHint->GetKind())
779 : : {
780 : : case HINT_OBJCHG : // Objekt geaendert
781 : : {
782 : : }
783 : 0 : break;
784 : : default :
785 : : {
786 : : // other events are not interesting
787 : : }
788 : 0 : break;
789 : : }
790 : : }
791 : : }
792 : : }
793 : 2 : }
794 : :
795 : 216 : void ScShapeChildren::FindChanged(ScShapeChildVec& rOld, ScShapeChildVec& rNew) const
796 : : {
797 : 216 : ScShapeChildVec::iterator aOldItr = rOld.begin();
798 : 216 : ScShapeChildVec::iterator aOldEnd = rOld.end();
799 [ + - ]: 216 : ScShapeChildVec::const_iterator aNewItr = rNew.begin();
800 [ + - ]: 216 : ScShapeChildVec::const_iterator aNewEnd = rNew.begin();
801 : 216 : uno::Reference<XAccessible> xAcc;
802 [ + - ][ - + ]: 216 : while ((aNewItr != aNewEnd) && (aOldItr != aOldEnd))
[ # # ][ # # ]
[ - + ]
803 : : {
804 [ # # ][ # # ]: 0 : if (aNewItr->mxShape.get() == aOldItr->mxShape.get())
[ # # ]
805 : : {
806 : 0 : ++aOldItr;
807 : 0 : ++aNewItr;
808 : : }
809 [ # # ][ # # ]: 0 : else if (aNewItr->mxShape.get() < aOldItr->mxShape.get())
[ # # ]
810 : : {
811 [ # # ][ # # ]: 0 : xAcc = GetAccShape(*aNewItr);
[ # # ]
812 [ # # ]: 0 : AccessibleEventObject aEvent;
813 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
[ # # ]
814 : 0 : aEvent.EventId = AccessibleEventId::CHILD;
815 [ # # ]: 0 : aEvent.NewValue <<= xAcc;
816 [ # # ]: 0 : mpAccDoc->CommitChange(aEvent);
817 [ # # ]: 0 : ++aNewItr;
818 : : }
819 : : else
820 : : {
821 [ # # ][ # # ]: 0 : xAcc = GetAccShape(*aOldItr);
[ # # ]
822 [ # # ]: 0 : AccessibleEventObject aEvent;
823 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
[ # # ]
824 : 0 : aEvent.EventId = AccessibleEventId::CHILD;
825 [ # # ]: 0 : aEvent.OldValue <<= xAcc;
826 [ # # ]: 0 : mpAccDoc->CommitChange(aEvent);
827 [ # # ]: 0 : ++aOldItr;
828 : : }
829 : : }
830 [ + - ][ - + ]: 216 : while (aOldItr != aOldEnd)
831 : : {
832 [ # # ][ # # ]: 0 : xAcc = GetAccShape(*aOldItr);
[ # # ]
833 [ # # ]: 0 : AccessibleEventObject aEvent;
834 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
[ # # ]
835 : 0 : aEvent.EventId = AccessibleEventId::CHILD;
836 [ # # ]: 0 : aEvent.OldValue <<= xAcc;
837 [ # # ]: 0 : mpAccDoc->CommitChange(aEvent);
838 : 0 : ++aOldItr;
839 [ # # ]: 0 : }
840 [ + - ][ - + ]: 216 : while (aNewItr != aNewEnd)
841 : : {
842 [ # # ][ # # ]: 0 : xAcc = GetAccShape(*aNewItr);
[ # # ]
843 [ # # ]: 0 : AccessibleEventObject aEvent;
844 [ # # ][ # # ]: 0 : aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
[ # # ]
845 : 0 : aEvent.EventId = AccessibleEventId::CHILD;
846 [ # # ]: 0 : aEvent.NewValue <<= xAcc;
847 [ # # ]: 0 : mpAccDoc->CommitChange(aEvent);
848 : 0 : ++aNewItr;
849 [ # # ]: 216 : }
850 : 216 : }
851 : :
852 : 72 : void ScShapeChildren::FindChanged(ScShapeRange& rOld, ScShapeRange& rNew) const
853 : : {
854 : 72 : FindChanged(rOld.maBackShapes, rNew.maBackShapes);
855 : 72 : FindChanged(rOld.maForeShapes, rNew.maForeShapes);
856 : 72 : FindChanged(rOld.maControls, rNew.maControls);
857 : 72 : }
858 : :
859 : 18 : void ScShapeChildren::DataChanged()
860 : : {
861 [ + - ]: 18 : ScShapeRangeVec aOldShapeRanges(maShapeRanges);
862 : 18 : maShapeRanges.clear();
863 [ + - ]: 18 : maShapeRanges.resize(SC_PREVIEW_MAXRANGES);
864 [ + - ]: 18 : Init();
865 [ + + ]: 90 : for (sal_Int32 i = 0; i < SC_PREVIEW_MAXRANGES; ++i)
866 : : {
867 [ + - ]: 72 : FindChanged(aOldShapeRanges[i], maShapeRanges[i]);
868 : 18 : }
869 : 18 : }
870 : :
871 : : struct ScVisAreaChanged
872 : : {
873 : : const ScIAccessibleViewForwarder* mpViewForwarder;
874 : 32 : ScVisAreaChanged(const ScIAccessibleViewForwarder* pViewForwarder) : mpViewForwarder(pViewForwarder) {}
875 : 0 : void operator() (const ScShapeChild& rAccShapeData) const
876 : : {
877 [ # # ]: 0 : if (rAccShapeData.mpAccShape)
878 : : {
879 : 0 : rAccShapeData.mpAccShape->ViewForwarderChanged(::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA, mpViewForwarder);
880 : : }
881 : 0 : }
882 : : };
883 : :
884 : 8 : void ScShapeChildren::VisAreaChanged() const
885 : : {
886 : 8 : ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
887 : 8 : ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
888 [ + - ][ + + ]: 40 : while (aItr != aEndItr)
889 : : {
890 : 32 : ScVisAreaChanged aVisAreaChanged(&(aItr->maViewForwarder));
891 [ + - ]: 32 : std::for_each(aItr->maBackShapes.begin(), aItr->maBackShapes.end(), aVisAreaChanged);
892 [ + - ]: 32 : std::for_each(aItr->maControls.begin(), aItr->maControls.end(), aVisAreaChanged);
893 [ + - ]: 32 : std::for_each(aItr->maForeShapes.begin(), aItr->maForeShapes.end(), aVisAreaChanged);
894 : 32 : ++aItr;
895 : : }
896 : 8 : }
897 : :
898 : : ///===== IAccessibleParent ==============================================
899 : :
900 : 0 : sal_Bool ScShapeChildren::ReplaceChild (::accessibility::AccessibleShape* /* pCurrentChild */,
901 : : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& /* _rxShape */,
902 : : const long /* _nIndex */, const ::accessibility::AccessibleShapeTreeInfo& /* _rShapeTreeInfo */)
903 : : throw (uno::RuntimeException)
904 : : {
905 : : OSL_FAIL("should not be called in the page preview");
906 : 0 : return false;
907 : : }
908 : :
909 : : ///===== Internal ========================================================
910 : :
911 : 34 : void ScShapeChildren::Init()
912 : : {
913 [ + - ]: 34 : if(mpViewShell)
914 : : {
915 [ + - ]: 34 : const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
916 [ + - ]: 34 : MapMode aMapMode;
917 [ + - ]: 34 : Rectangle aPixelPaintRect;
918 : : sal_uInt8 nRangeId;
919 : 34 : sal_uInt16 nCount(rData.GetDrawRanges());
920 [ + + ]: 68 : for (sal_uInt16 i = 0; i < nCount; ++i)
921 : : {
922 [ + - ]: 34 : rData.GetDrawRange(i, aPixelPaintRect, aMapMode, nRangeId);
923 [ + - ]: 34 : FillShapes(aPixelPaintRect, aMapMode, nRangeId);
924 [ + - ]: 34 : }
925 : : }
926 : 34 : }
927 : :
928 : 166 : sal_Int32 ScShapeChildren::GetBackShapeCount() const
929 : : {
930 : 166 : sal_Int32 nCount(0);
931 : 166 : ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
932 [ + - ][ + + ]: 830 : for ( ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin(); aItr != aEndItr; ++aItr )
933 : 664 : nCount += aItr->maBackShapes.size();
934 : 166 : return nCount;
935 : : }
936 : :
937 : 0 : uno::Reference<XAccessible> ScShapeChildren::GetBackShape(sal_Int32 nIndex) const
938 : : {
939 : 0 : uno::Reference<XAccessible> xAccessible;
940 : 0 : ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
941 : 0 : ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
942 [ # # ][ # # ]: 0 : while ((aItr != aEndItr) && !xAccessible.is())
[ # # ][ # # ]
943 : : {
944 : 0 : sal_Int32 nCount(aItr->maBackShapes.size());
945 [ # # ]: 0 : if(nIndex < nCount)
946 [ # # ][ # # ]: 0 : xAccessible = GetAccShape(aItr->maBackShapes, nIndex);
[ # # ]
947 : : else
948 : 0 : ++aItr;
949 : 0 : nIndex -= nCount;
950 : : }
951 : :
952 [ # # ]: 0 : if (nIndex >= 0)
953 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
954 : :
955 : 0 : return xAccessible;
956 : : }
957 : :
958 : 166 : sal_Int32 ScShapeChildren::GetForeShapeCount() const
959 : : {
960 : 166 : sal_Int32 nCount(0);
961 : 166 : ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
962 [ + - ][ + + ]: 830 : for ( ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin(); aItr != aEndItr; ++aItr )
963 : 664 : nCount += aItr->maForeShapes.size();
964 : 166 : return nCount;
965 : : }
966 : :
967 : 0 : uno::Reference<XAccessible> ScShapeChildren::GetForeShape(sal_Int32 nIndex) const
968 : : {
969 : 0 : uno::Reference<XAccessible> xAccessible;
970 : 0 : ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
971 : 0 : ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
972 [ # # ][ # # ]: 0 : while ((aItr != aEndItr) && !xAccessible.is())
[ # # ][ # # ]
973 : : {
974 : 0 : sal_Int32 nCount(aItr->maForeShapes.size());
975 [ # # ]: 0 : if(nIndex < nCount)
976 [ # # ][ # # ]: 0 : xAccessible = GetAccShape(aItr->maForeShapes, nIndex);
[ # # ]
977 : : else
978 : 0 : ++aItr;
979 : 0 : nIndex -= nCount;
980 : : }
981 : :
982 [ # # ]: 0 : if (nIndex >= 0)
983 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
984 : :
985 : 0 : return xAccessible;
986 : : }
987 : :
988 : 166 : sal_Int32 ScShapeChildren::GetControlCount() const
989 : : {
990 : 166 : sal_Int32 nCount(0);
991 : 166 : ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
992 [ + - ][ + + ]: 830 : for ( ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin(); aItr != aEndItr; ++aItr )
993 : 664 : nCount += aItr->maControls.size();
994 : 166 : return nCount;
995 : : }
996 : :
997 : 0 : uno::Reference<XAccessible> ScShapeChildren::GetControl(sal_Int32 nIndex) const
998 : : {
999 : 0 : uno::Reference<XAccessible> xAccessible;
1000 : 0 : ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
1001 : 0 : ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
1002 [ # # ][ # # ]: 0 : while ((aItr != aEndItr) && !xAccessible.is())
[ # # ][ # # ]
1003 : : {
1004 : 0 : sal_Int32 nCount(aItr->maControls.size());
1005 [ # # ]: 0 : if(nIndex < nCount)
1006 [ # # ][ # # ]: 0 : xAccessible = GetAccShape(aItr->maControls, nIndex);
[ # # ]
1007 : : else
1008 : 0 : ++aItr;
1009 : 0 : nIndex -= nCount;
1010 : : }
1011 : :
1012 [ # # ]: 0 : if (nIndex >= 0)
1013 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
1014 : :
1015 : 0 : return xAccessible;
1016 : : }
1017 : :
1018 : : struct ScShapePointFound
1019 : : {
1020 : : Point maPoint;
1021 : 0 : ScShapePointFound(const awt::Point& rPoint) : maPoint(VCLPoint(rPoint)) {}
1022 : 0 : sal_Bool operator() (const ScShapeChild& rShape)
1023 : : {
1024 : 0 : sal_Bool bResult(false);
1025 [ # # ][ # # ]: 0 : if ((VCLRectangle(rShape.mpAccShape->getBounds())).IsInside(maPoint))
[ # # ]
1026 : 0 : bResult = sal_True;
1027 : 0 : return bResult;
1028 : : }
1029 : : };
1030 : :
1031 : 0 : uno::Reference<XAccessible> ScShapeChildren::GetForegroundShapeAt(const awt::Point& rPoint) const //inclusive Controls
1032 : : {
1033 : 0 : uno::Reference<XAccessible> xAcc;
1034 : :
1035 : 0 : ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
1036 : 0 : ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
1037 [ # # ][ # # ]: 0 : while((aItr != aEndItr) && !xAcc.is())
[ # # ][ # # ]
1038 : : {
1039 [ # # ]: 0 : ScShapeChildVec::const_iterator aFindItr = std::find_if(aItr->maForeShapes.begin(), aItr->maForeShapes.end(), ScShapePointFound(rPoint));
1040 [ # # ][ # # ]: 0 : if (aFindItr != aItr->maForeShapes.end())
1041 [ # # ][ # # ]: 0 : xAcc = GetAccShape(*aFindItr);
[ # # ]
1042 : : else
1043 : : {
1044 [ # # ]: 0 : ScShapeChildVec::const_iterator aCtrlItr = std::find_if(aItr->maControls.begin(), aItr->maControls.end(), ScShapePointFound(rPoint));
1045 [ # # ][ # # ]: 0 : if (aCtrlItr != aItr->maControls.end())
1046 [ # # ][ # # ]: 0 : xAcc = GetAccShape(*aCtrlItr);
[ # # ]
1047 : : else
1048 : 0 : ++aItr;
1049 : : }
1050 : : }
1051 : :
1052 : 0 : return xAcc;
1053 : : }
1054 : :
1055 : 0 : uno::Reference<XAccessible> ScShapeChildren::GetBackgroundShapeAt(const awt::Point& rPoint) const
1056 : : {
1057 : 0 : uno::Reference<XAccessible> xAcc;
1058 : :
1059 : 0 : ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
1060 : 0 : ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
1061 [ # # ][ # # ]: 0 : while((aItr != aEndItr) && !xAcc.is())
[ # # ][ # # ]
1062 : : {
1063 [ # # ]: 0 : ScShapeChildVec::const_iterator aFindItr = std::find_if(aItr->maBackShapes.begin(), aItr->maBackShapes.end(), ScShapePointFound(rPoint));
1064 [ # # ][ # # ]: 0 : if (aFindItr != aItr->maBackShapes.end())
1065 [ # # ][ # # ]: 0 : xAcc = GetAccShape(*aFindItr);
[ # # ]
1066 : : else
1067 : 0 : ++aItr;
1068 : : }
1069 : :
1070 : 0 : return xAcc;
1071 : : }
1072 : :
1073 : 0 : ::accessibility::AccessibleShape* ScShapeChildren::GetAccShape(const ScShapeChild& rShape) const
1074 : : {
1075 [ # # ]: 0 : if (!rShape.mpAccShape)
1076 : : {
1077 [ # # ]: 0 : ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance();
1078 [ # # ][ # # ]: 0 : ::accessibility::AccessibleShapeInfo aShapeInfo(rShape.mxShape, mpAccDoc, const_cast<ScShapeChildren*>(this));
[ # # ]
1079 : :
1080 [ # # ]: 0 : if (mpViewShell)
1081 : : {
1082 [ # # ]: 0 : ::accessibility::AccessibleShapeTreeInfo aShapeTreeInfo;
1083 [ # # ][ # # ]: 0 : aShapeTreeInfo.SetSdrView(mpViewShell->GetPreview()->GetDrawView());
1084 [ # # ][ # # ]: 0 : aShapeTreeInfo.SetController(NULL);
1085 [ # # ]: 0 : aShapeTreeInfo.SetWindow(mpViewShell->GetWindow());
1086 [ # # ]: 0 : aShapeTreeInfo.SetViewForwarder(&(maShapeRanges[rShape.mnRangeId].maViewForwarder));
1087 [ # # ]: 0 : rShape.mpAccShape = rShapeHandler.CreateAccessibleObject(aShapeInfo, aShapeTreeInfo);
1088 [ # # ]: 0 : if (rShape.mpAccShape)
1089 : : {
1090 : 0 : rShape.mpAccShape->acquire();
1091 [ # # ]: 0 : rShape.mpAccShape->Init();
1092 [ # # ]: 0 : }
1093 [ # # ]: 0 : }
1094 : : }
1095 : 0 : return rShape.mpAccShape;
1096 : : }
1097 : :
1098 : 0 : ::accessibility::AccessibleShape* ScShapeChildren::GetAccShape(const ScShapeChildVec& rShapes, sal_Int32 nIndex) const
1099 : : {
1100 : 0 : return (GetAccShape(rShapes[nIndex]));
1101 : : }
1102 : :
1103 : 34 : void ScShapeChildren::FillShapes(const Rectangle& aPixelPaintRect, const MapMode& aMapMode, sal_uInt8 nRangeId)
1104 : : {
1105 : : OSL_ENSURE(nRangeId < maShapeRanges.size(), "this is not a valid range for draw objects");
1106 : 34 : SdrPage* pPage = GetDrawPage();
1107 : 34 : Window* pWin = mpViewShell->GetWindow();
1108 [ # # ][ - + ]: 34 : if (pPage && pWin)
1109 : : {
1110 : 0 : sal_Bool bForeAdded(false);
1111 : 0 : sal_Bool bBackAdded(false);
1112 : 0 : sal_Bool bControlAdded(false);
1113 : 0 : Rectangle aClippedPixelPaintRect(aPixelPaintRect);
1114 [ # # ]: 0 : if (mpAccDoc)
1115 : : {
1116 [ # # ][ # # ]: 0 : Rectangle aRect2(Point(0,0), mpAccDoc->GetBoundingBoxOnScreen().GetSize());
[ # # ]
1117 [ # # ]: 0 : aClippedPixelPaintRect = aPixelPaintRect.GetIntersection(aRect2);
1118 : : }
1119 : 0 : maShapeRanges[nRangeId].maPixelRect = aClippedPixelPaintRect;
1120 [ # # ]: 0 : maShapeRanges[nRangeId].maMapMode = aMapMode;
1121 [ # # ]: 0 : ScIAccessibleViewForwarder aViewForwarder(mpViewShell, mpAccDoc, aMapMode);
1122 [ # # ]: 0 : maShapeRanges[nRangeId].maViewForwarder = aViewForwarder;
1123 [ # # ]: 0 : sal_uInt32 nCount(pPage->GetObjCount());
1124 [ # # ]: 0 : for (sal_uInt32 i = 0; i < nCount; ++i)
1125 : : {
1126 [ # # ]: 0 : SdrObject* pObj = pPage->GetObj(i);
1127 [ # # ]: 0 : if (pObj)
1128 : : {
1129 [ # # ][ # # ]: 0 : uno::Reference< drawing::XShape > xShape(pObj->getUnoShape(), uno::UNO_QUERY);
1130 [ # # ]: 0 : if (xShape.is())
1131 : : {
1132 [ # # ][ # # ]: 0 : Rectangle aRect(pWin->LogicToPixel(VCLPoint(xShape->getPosition()), aMapMode), pWin->LogicToPixel(VCLSize(xShape->getSize()), aMapMode));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1133 [ # # ][ # # ]: 0 : if(!aClippedPixelPaintRect.GetIntersection(aRect).IsEmpty())
[ # # ]
1134 : : {
1135 [ # # ]: 0 : ScShapeChild aShape;
1136 [ # # ]: 0 : aShape.mxShape = xShape;
1137 : 0 : aShape.mnRangeId = nRangeId;
1138 [ # # ]: 0 : switch (pObj->GetLayer())
[ # # # # ]
1139 : : {
1140 : : case SC_LAYER_INTERN:
1141 : : case SC_LAYER_FRONT:
1142 : : {
1143 [ # # ]: 0 : maShapeRanges[nRangeId].maForeShapes.push_back(aShape);
1144 : 0 : bForeAdded = sal_True;
1145 : : }
1146 : 0 : break;
1147 : : case SC_LAYER_BACK:
1148 : : {
1149 [ # # ]: 0 : maShapeRanges[nRangeId].maBackShapes.push_back(aShape);
1150 : 0 : bBackAdded = sal_True;
1151 : : }
1152 : 0 : break;
1153 : : case SC_LAYER_CONTROLS:
1154 : : {
1155 [ # # ]: 0 : maShapeRanges[nRangeId].maControls.push_back(aShape);
1156 : 0 : bControlAdded = sal_True;
1157 : : }
1158 : 0 : break;
1159 : : default:
1160 : : {
1161 : : OSL_FAIL("I don't know this layer.");
1162 : : }
1163 : 0 : break;
1164 [ # # ]: 0 : }
1165 : : }
1166 : 0 : }
1167 : : }
1168 : : }
1169 [ # # ]: 0 : if (bForeAdded)
1170 [ # # ]: 0 : std::sort(maShapeRanges[nRangeId].maForeShapes.begin(), maShapeRanges[nRangeId].maForeShapes.end(),ScShapeChildLess());
1171 [ # # ]: 0 : if (bBackAdded)
1172 [ # # ]: 0 : std::sort(maShapeRanges[nRangeId].maBackShapes.begin(), maShapeRanges[nRangeId].maBackShapes.end(),ScShapeChildLess());
1173 [ # # ]: 0 : if (bControlAdded)
1174 [ # # ][ # # ]: 0 : std::sort(maShapeRanges[nRangeId].maControls.begin(), maShapeRanges[nRangeId].maControls.end(),ScShapeChildLess());
1175 : : }
1176 : 34 : }
1177 : :
1178 : 34 : SdrPage* ScShapeChildren::GetDrawPage() const
1179 : : {
1180 : 34 : SCTAB nTab( mpViewShell->GetLocationData().GetPrintTab() );
1181 : 34 : SdrPage* pDrawPage = NULL;
1182 [ + - ]: 34 : if (mpViewShell)
1183 : : {
1184 : 34 : ScDocument* pDoc = mpViewShell->GetDocument();
1185 [ + - ][ + - ]: 34 : if (pDoc && pDoc->GetDrawLayer())
[ + - ]
1186 : : {
1187 : 34 : ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
1188 [ # # ][ - + ]: 34 : if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab))
[ - + ]
1189 : 0 : pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(static_cast<sal_Int16>(nTab)));
1190 : : }
1191 : : }
1192 : 34 : return pDrawPage;
1193 : : }
1194 : :
1195 : : struct ScPagePreviewCountData
1196 : : {
1197 : : // order is background shapes, header, table or notes, footer, foreground shapes, controls
1198 : :
1199 : : Rectangle aVisRect;
1200 : : long nBackShapes;
1201 : : long nHeaders;
1202 : : long nTables;
1203 : : long nNoteParagraphs;
1204 : : long nFooters;
1205 : : long nForeShapes;
1206 : : long nControls;
1207 : :
1208 : : ScPagePreviewCountData( const ScPreviewLocationData& rData, Window* pSizeWindow,
1209 : : ScNotesChildren* pNotesChildren, ScShapeChildren* pShapeChildren );
1210 : :
1211 : 84 : long GetTotal() const
1212 : : {
1213 : 84 : return nBackShapes + nHeaders + nTables + nNoteParagraphs + nFooters + nForeShapes + nControls;
1214 : : }
1215 : : };
1216 : :
1217 : 166 : ScPagePreviewCountData::ScPagePreviewCountData( const ScPreviewLocationData& rData,
1218 : : Window* pSizeWindow, ScNotesChildren* pNotesChildren,
1219 : : ScShapeChildren* pShapeChildren) :
1220 : : nBackShapes( 0 ),
1221 : : nHeaders( 0 ),
1222 : : nTables( 0 ),
1223 : : nNoteParagraphs( 0 ),
1224 : : nFooters( 0 ),
1225 : : nForeShapes( 0 ),
1226 : 166 : nControls( 0 )
1227 : : {
1228 : 166 : Size aOutputSize;
1229 [ + - ]: 166 : if ( pSizeWindow )
1230 : 166 : aOutputSize = pSizeWindow->GetOutputSizePixel();
1231 : 166 : Point aPoint;
1232 [ + - ]: 166 : aVisRect = Rectangle( aPoint, aOutputSize );
1233 : :
1234 [ + - ]: 166 : Rectangle aObjRect;
1235 : :
1236 [ + - ][ + - ]: 166 : if ( rData.GetHeaderPosition( aObjRect ) && aObjRect.IsOver( aVisRect ) )
[ + - ][ + - ]
[ + - ]
1237 : 166 : nHeaders = 1;
1238 : :
1239 [ + - ][ + - ]: 166 : if ( rData.GetFooterPosition( aObjRect ) && aObjRect.IsOver( aVisRect ) )
[ + - ][ + + ]
[ + + ]
1240 : 160 : nFooters = 1;
1241 : :
1242 [ + - ][ + - ]: 166 : if ( rData.HasCellsInRange( aVisRect ) )
1243 : 166 : nTables = 1;
1244 : :
1245 : : //! shapes...
1246 [ + - ]: 166 : nBackShapes = pShapeChildren->GetBackShapeCount();
1247 [ + - ]: 166 : nForeShapes = pShapeChildren->GetForeShapeCount();
1248 [ + - ]: 166 : nControls = pShapeChildren->GetControlCount();
1249 : :
1250 : : // there are only notes if there is no table
1251 [ - + ]: 166 : if (nTables == 0)
1252 : 0 : nNoteParagraphs = pNotesChildren->GetChildrenCount();
1253 : 166 : }
1254 : :
1255 : : //===== internal ========================================================
1256 : :
1257 : 16 : ScAccessibleDocumentPagePreview::ScAccessibleDocumentPagePreview(
1258 : : const uno::Reference<XAccessible>& rxParent, ScPreviewShell* pViewShell ) :
1259 : : ScAccessibleDocumentBase(rxParent),
1260 : : mpViewShell(pViewShell),
1261 : : mpNotesChildren(NULL),
1262 : : mpShapeChildren(NULL),
1263 : : mpTable(NULL),
1264 : : mpHeader(NULL),
1265 : 16 : mpFooter(NULL)
1266 : : {
1267 [ + - ]: 16 : if (pViewShell)
1268 [ + - ]: 16 : pViewShell->AddAccessibilityObject(*this);
1269 : :
1270 : 16 : }
1271 : :
1272 : 16 : ScAccessibleDocumentPagePreview::~ScAccessibleDocumentPagePreview(void)
1273 : : {
1274 [ - + ][ # # ]: 16 : if (!ScAccessibleDocumentBase::IsDefunc() && !rBHelper.bInDispose)
[ - + ]
1275 : : {
1276 : : // increment refcount to prevent double call off dtor
1277 [ # # ]: 0 : osl_incrementInterlockedCount( &m_refCount );
1278 : : // call dispose to inform object wich have a weak reference to this object
1279 [ # # ]: 0 : dispose();
1280 : : }
1281 [ - + ]: 32 : }
1282 : :
1283 : 16 : void SAL_CALL ScAccessibleDocumentPagePreview::disposing()
1284 : : {
1285 [ + - ]: 16 : SolarMutexGuard aGuard;
1286 [ + + ]: 16 : if (mpTable)
1287 : : {
1288 : 15 : mpTable->release();
1289 : 15 : mpTable = NULL;
1290 : : }
1291 [ + + ]: 16 : if (mpHeader)
1292 : : {
1293 : 15 : mpHeader->release();
1294 : 15 : mpHeader = NULL;
1295 : : }
1296 [ + + ]: 16 : if (mpFooter)
1297 : : {
1298 : 5 : mpFooter->release();
1299 : 5 : mpFooter = NULL;
1300 : : }
1301 : :
1302 [ + - ]: 16 : if (mpViewShell)
1303 : : {
1304 [ + - ]: 16 : mpViewShell->RemoveAccessibilityObject(*this);
1305 : 16 : mpViewShell = NULL;
1306 : : }
1307 : :
1308 : : // no need to Dispose the AccessibleTextHelper,
1309 : : // as long as mpNotesChildren are destructed here
1310 [ + - ]: 16 : if (mpNotesChildren)
1311 [ + - ][ + - ]: 16 : DELETEZ(mpNotesChildren);
1312 : :
1313 [ + - ]: 16 : if (mpShapeChildren)
1314 [ + - ][ + - ]: 16 : DELETEZ(mpShapeChildren);
1315 : :
1316 [ + - ][ + - ]: 16 : ScAccessibleDocumentBase::disposing();
1317 : 16 : }
1318 : :
1319 : : //===== SfxListener =====================================================
1320 : :
1321 : 58 : void ScAccessibleDocumentPagePreview::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1322 : : {
1323 [ + + ]: 58 : if (rHint.ISA( SfxSimpleHint ) )
1324 : : {
1325 : 42 : const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
1326 : : // only notify if child exist, otherwise it is not necessary
1327 [ + + ]: 42 : if ((rRef.GetId() == SC_HINT_DATACHANGED))
1328 : : {
1329 [ + + ]: 18 : if (mpTable) // if there is no table there is nothing to notify, because no one recongnizes the change
1330 : : {
1331 : : {
1332 [ + - ][ + - ]: 16 : uno::Reference<XAccessible> xAcc = mpTable;
1333 [ + - ]: 16 : AccessibleEventObject aEvent;
1334 : 16 : aEvent.EventId = AccessibleEventId::CHILD;
1335 [ + - ][ + - ]: 16 : aEvent.Source = uno::Reference< XAccessibleContext >(this);
1336 [ + - ]: 16 : aEvent.OldValue <<= xAcc;
1337 [ + - ][ + - ]: 16 : CommitChange(aEvent);
1338 : : }
1339 : :
1340 [ + - ]: 16 : mpTable->dispose();
1341 : 16 : mpTable->release();
1342 : 16 : mpTable = NULL;
1343 : : }
1344 : :
1345 : 18 : Size aOutputSize;
1346 : 18 : Window* pSizeWindow = mpViewShell->GetWindow();
1347 [ + - ]: 18 : if ( pSizeWindow )
1348 : 18 : aOutputSize = pSizeWindow->GetOutputSizePixel();
1349 : 18 : Point aPoint;
1350 [ + - ]: 18 : Rectangle aVisRect( aPoint, aOutputSize );
1351 [ + - ][ + - ]: 18 : GetNotesChildren()->DataChanged(aVisRect);
1352 : :
1353 [ + - ][ + - ]: 18 : GetShapeChildren()->DataChanged();
1354 : :
1355 [ + - ]: 18 : const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
1356 [ + - ][ + - ]: 18 : ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChildren(), GetShapeChildren() );
[ + - ]
1357 : :
1358 [ + - ]: 18 : if (aCount.nTables > 0)
1359 : : {
1360 : : //! order is background shapes, header, table or notes, footer, foreground shapes, controls
1361 : 18 : sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
1362 : :
1363 [ + - ][ + - ]: 18 : mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
1364 : 18 : mpTable->acquire();
1365 [ + - ]: 18 : mpTable->Init();
1366 : :
1367 : : {
1368 [ + - ][ + - ]: 18 : uno::Reference<XAccessible> xAcc = mpTable;
1369 [ + - ]: 18 : AccessibleEventObject aEvent;
1370 : 18 : aEvent.EventId = AccessibleEventId::CHILD;
1371 [ + - ][ + - ]: 18 : aEvent.Source = uno::Reference< XAccessibleContext >(this);
1372 [ + - ]: 18 : aEvent.NewValue <<= xAcc;
1373 [ + - ][ + - ]: 18 : CommitChange(aEvent);
1374 : : }
1375 : : }
1376 : : }
1377 [ - + ]: 24 : else if (rRef.GetId() == SC_HINT_ACC_MAKEDRAWLAYER)
1378 : : {
1379 : 0 : GetShapeChildren()->SetDrawBroadcaster();
1380 : : }
1381 [ + + ]: 24 : else if (rRef.GetId() == SC_HINT_ACC_VISAREACHANGED)
1382 : : {
1383 : 8 : Size aOutputSize;
1384 : 8 : Window* pSizeWindow = mpViewShell->GetWindow();
1385 [ + - ]: 8 : if ( pSizeWindow )
1386 : 8 : aOutputSize = pSizeWindow->GetOutputSizePixel();
1387 : 8 : Point aPoint;
1388 [ + - ]: 8 : Rectangle aVisRect( aPoint, aOutputSize );
1389 [ + - ][ + - ]: 8 : GetNotesChildren()->DataChanged(aVisRect);
1390 : :
1391 [ + - ][ + - ]: 8 : GetShapeChildren()->VisAreaChanged();
1392 : :
1393 [ + - ]: 8 : AccessibleEventObject aEvent;
1394 : 8 : aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
1395 [ + - ][ + - ]: 8 : aEvent.Source = uno::Reference< XAccessibleContext >(this);
1396 [ + - ][ + - ]: 8 : CommitChange(aEvent);
1397 : : }
1398 : : }
1399 [ + - ]: 16 : else if ( rHint.ISA(ScAccWinFocusLostHint) )
1400 : : {
1401 : 16 : CommitFocusLost();
1402 : : }
1403 [ # # ]: 0 : else if ( rHint.ISA(ScAccWinFocusGotHint) )
1404 : : {
1405 : 0 : CommitFocusGained();
1406 : : }
1407 : 58 : ScAccessibleDocumentBase::Notify(rBC, rHint);
1408 : 58 : }
1409 : :
1410 : : //===== XAccessibleComponent ============================================
1411 : :
1412 : 0 : uno::Reference< XAccessible > SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleAtPoint( const awt::Point& rPoint )
1413 : : throw (uno::RuntimeException)
1414 : : {
1415 : 0 : uno::Reference<XAccessible> xAccessible;
1416 [ # # ][ # # ]: 0 : if (containsPoint(rPoint))
1417 : : {
1418 [ # # ]: 0 : SolarMutexGuard aGuard;
1419 [ # # ]: 0 : IsObjectValid();
1420 : :
1421 [ # # ]: 0 : if ( mpViewShell )
1422 : : {
1423 [ # # ][ # # ]: 0 : xAccessible = GetShapeChildren()->GetForegroundShapeAt(rPoint);
[ # # ]
1424 [ # # ]: 0 : if (!xAccessible.is())
1425 : : {
1426 [ # # ]: 0 : const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
1427 [ # # ][ # # ]: 0 : ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChildren(), GetShapeChildren() );
[ # # ]
1428 : :
1429 [ # # ][ # # ]: 0 : if ( !mpTable && (aCount.nTables > 0) )
1430 : : {
1431 : : //! order is background shapes, header, table or notes, footer, foreground shapes, controls
1432 : 0 : sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
1433 : :
1434 [ # # ][ # # ]: 0 : mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
1435 : 0 : mpTable->acquire();
1436 [ # # ]: 0 : mpTable->Init();
1437 : : }
1438 [ # # ][ # # ]: 0 : if (mpTable && VCLRectangle(mpTable->getBounds()).IsInside(VCLPoint(rPoint)))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # # # ]
1439 [ # # ][ # # ]: 0 : xAccessible = mpTable;
1440 : : }
1441 [ # # ]: 0 : if (!xAccessible.is())
1442 [ # # ][ # # ]: 0 : xAccessible = GetNotesChildren()->GetAt(rPoint);
[ # # ]
1443 [ # # ]: 0 : if (!xAccessible.is())
1444 : : {
1445 [ # # ][ # # ]: 0 : if (!mpHeader || !mpFooter)
1446 : : {
1447 [ # # ]: 0 : const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
1448 [ # # ][ # # ]: 0 : ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChildren(), GetShapeChildren() );
[ # # ]
1449 : :
1450 [ # # ]: 0 : if (!mpHeader)
1451 : : {
1452 [ # # ][ # # ]: 0 : mpHeader = new ScAccessiblePageHeader( this, mpViewShell, sal_True, aCount.nBackShapes + aCount.nHeaders - 1);
1453 : 0 : mpHeader->acquire();
1454 : : }
1455 [ # # ]: 0 : if (!mpFooter)
1456 : : {
1457 [ # # ][ # # ]: 0 : mpFooter = new ScAccessiblePageHeader( this, mpViewShell, false, aCount.nBackShapes + aCount.nHeaders + aCount.nTables + aCount.nNoteParagraphs + aCount.nFooters - 1 );
1458 : 0 : mpFooter->acquire();
1459 : : }
1460 : : }
1461 : :
1462 : 0 : Point aPoint(VCLPoint(rPoint));
1463 : :
1464 [ # # ][ # # ]: 0 : if (VCLRectangle(mpHeader->getBounds()).IsInside(aPoint))
[ # # ][ # # ]
1465 [ # # ][ # # ]: 0 : xAccessible = mpHeader;
1466 [ # # ][ # # ]: 0 : else if (VCLRectangle(mpFooter->getBounds()).IsInside(aPoint))
[ # # ][ # # ]
1467 [ # # ][ # # ]: 0 : xAccessible = mpFooter;
1468 : : }
1469 [ # # ]: 0 : if (!xAccessible.is())
1470 [ # # ][ # # ]: 0 : xAccessible = GetShapeChildren()->GetBackgroundShapeAt(rPoint);
[ # # ]
1471 [ # # ]: 0 : }
1472 : : }
1473 : :
1474 : 0 : return xAccessible;
1475 : : }
1476 : :
1477 : 4 : void SAL_CALL ScAccessibleDocumentPagePreview::grabFocus() throw (uno::RuntimeException)
1478 : : {
1479 [ + - ]: 4 : SolarMutexGuard aGuard;
1480 [ + - ]: 4 : IsObjectValid();
1481 [ + - ][ + - ]: 4 : if (getAccessibleParent().is())
1482 : : {
1483 [ + - ][ + - ]: 4 : uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
[ + - ][ + - ]
1484 [ + - ]: 4 : if (xAccessibleComponent.is())
1485 : : {
1486 : : // just grab the focus for the window
1487 [ + - ][ + - ]: 4 : xAccessibleComponent->grabFocus();
1488 : 4 : }
1489 [ + - ]: 4 : }
1490 : 4 : }
1491 : :
1492 : : //===== XAccessibleContext ==============================================
1493 : :
1494 : 84 : sal_Int32 SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleChildCount(void) throw (uno::RuntimeException)
1495 : : {
1496 [ + - ]: 84 : SolarMutexGuard aGuard;
1497 [ + - ]: 84 : IsObjectValid();
1498 : :
1499 : 84 : long nRet = 0;
1500 [ + - ]: 84 : if ( mpViewShell )
1501 : : {
1502 [ + - ][ + - ]: 84 : ScPagePreviewCountData aCount( mpViewShell->GetLocationData(), mpViewShell->GetWindow(), GetNotesChildren(), GetShapeChildren() );
[ + - ][ + - ]
1503 : 84 : nRet = aCount.GetTotal();
1504 : : }
1505 : :
1506 [ + - ]: 84 : return nRet;
1507 : : }
1508 : :
1509 : 48 : uno::Reference<XAccessible> SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleChild(sal_Int32 nIndex)
1510 : : throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
1511 : : {
1512 [ + - ]: 48 : SolarMutexGuard aGuard;
1513 [ + - ]: 48 : IsObjectValid();
1514 : 48 : uno::Reference<XAccessible> xAccessible;
1515 : :
1516 [ + - ]: 48 : if ( mpViewShell )
1517 : : {
1518 [ + - ]: 48 : const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
1519 [ + - ][ + - ]: 48 : ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChildren(), GetShapeChildren() );
[ + - ]
1520 : :
1521 [ - + ]: 48 : if ( nIndex < aCount.nBackShapes )
1522 : : {
1523 [ # # ][ # # ]: 0 : xAccessible = GetShapeChildren()->GetBackShape(nIndex);
[ # # ]
1524 : : }
1525 [ + + ]: 48 : else if ( nIndex < aCount.nBackShapes + aCount.nHeaders )
1526 : : {
1527 [ + + ]: 24 : if ( !mpHeader )
1528 : : {
1529 [ + - ][ + - ]: 15 : mpHeader = new ScAccessiblePageHeader( this, mpViewShell, sal_True, nIndex );
1530 : 15 : mpHeader->acquire();
1531 : : }
1532 : :
1533 [ + - ][ + - ]: 24 : xAccessible = mpHeader;
1534 : : }
1535 [ + + ]: 24 : else if ( nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nTables )
1536 : : {
1537 [ + + ]: 19 : if ( !mpTable )
1538 : : {
1539 [ + - ][ + - ]: 13 : mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
1540 : 13 : mpTable->acquire();
1541 [ + - ]: 13 : mpTable->Init();
1542 : : }
1543 [ + - ][ + - ]: 19 : xAccessible = mpTable;
1544 : : }
1545 [ - + ]: 5 : else if ( nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nNoteParagraphs )
1546 : : {
1547 [ # # ][ # # ]: 0 : xAccessible = GetNotesChildren()->GetChild(nIndex - aCount.nBackShapes - aCount.nHeaders);
[ # # ]
1548 : : }
1549 [ + - ]: 5 : else if ( (nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nTables + aCount.nNoteParagraphs + aCount.nFooters) )
1550 : : {
1551 [ + - ]: 5 : if ( !mpFooter )
1552 : : {
1553 [ + - ][ + - ]: 5 : mpFooter = new ScAccessiblePageHeader( this, mpViewShell, false, nIndex );
1554 : 5 : mpFooter->acquire();
1555 : : }
1556 [ + - ][ + - ]: 5 : xAccessible = mpFooter;
1557 : : }
1558 : : else
1559 : : {
1560 : 0 : sal_Int32 nIdx(nIndex - (aCount.nBackShapes + aCount.nHeaders + aCount.nTables + aCount.nNoteParagraphs + aCount.nFooters));
1561 [ # # ]: 0 : if (nIdx < aCount.nForeShapes)
1562 [ # # ][ # # ]: 0 : xAccessible = GetShapeChildren()->GetForeShape(nIdx);
[ # # ]
1563 : : else
1564 [ # # ][ # # ]: 48 : xAccessible = GetShapeChildren()->GetControl(nIdx - aCount.nForeShapes);
[ # # ]
1565 : : }
1566 : : }
1567 : :
1568 [ - + ]: 48 : if ( !xAccessible.is() )
1569 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
1570 : :
1571 [ + - ]: 48 : return xAccessible;
1572 : : }
1573 : :
1574 : : /// Return the set of current states.
1575 : 88 : uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleStateSet(void)
1576 : : throw (uno::RuntimeException)
1577 : : {
1578 [ + - ]: 88 : SolarMutexGuard aGuard;
1579 : 88 : uno::Reference<XAccessibleStateSet> xParentStates;
1580 [ + - ][ + - ]: 88 : if (getAccessibleParent().is())
1581 : : {
1582 [ + - ][ + - ]: 88 : uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
[ + - ]
1583 [ + - ][ + - ]: 88 : xParentStates = xParentContext->getAccessibleStateSet();
[ + - ]
1584 : : }
1585 [ + - ]: 88 : utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
1586 [ + - ][ - + ]: 88 : if (IsDefunc(xParentStates))
1587 [ # # ]: 0 : pStateSet->AddState(AccessibleStateType::DEFUNC);
1588 : : else
1589 : : {
1590 : : // never editable
1591 [ + - ]: 88 : pStateSet->AddState(AccessibleStateType::ENABLED);
1592 [ + - ]: 88 : pStateSet->AddState(AccessibleStateType::OPAQUE);
1593 [ + - ][ + - ]: 88 : if (isShowing())
1594 [ + - ]: 88 : pStateSet->AddState(AccessibleStateType::SHOWING);
1595 [ + - ][ + - ]: 88 : if (isVisible())
1596 [ + - ]: 88 : pStateSet->AddState(AccessibleStateType::VISIBLE);
1597 : : }
1598 [ + - ][ + - ]: 88 : return pStateSet;
[ + - ]
1599 : : }
1600 : :
1601 : : //===== XServiceInfo ====================================================
1602 : :
1603 : 0 : ::rtl::OUString SAL_CALL ScAccessibleDocumentPagePreview::getImplementationName(void)
1604 : : throw (uno::RuntimeException)
1605 : : {
1606 : 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScAccessibleDocumentPagePreview"));
1607 : : }
1608 : :
1609 : 0 : uno::Sequence< ::rtl::OUString> SAL_CALL ScAccessibleDocumentPagePreview::getSupportedServiceNames(void)
1610 : : throw (uno::RuntimeException)
1611 : : {
1612 : 0 : uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
1613 : 0 : sal_Int32 nOldSize(aSequence.getLength());
1614 [ # # ]: 0 : aSequence.realloc(nOldSize + 1);
1615 [ # # ]: 0 : ::rtl::OUString* pNames = aSequence.getArray();
1616 : :
1617 [ # # ]: 0 : pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.AccessibleSpreadsheetPageView"));
1618 : :
1619 : 0 : return aSequence;
1620 : : }
1621 : :
1622 : : //===== XTypeProvider =======================================================
1623 : :
1624 : : namespace
1625 : : {
1626 : : class theScAccessibleDocumentPagePreviewImplementationId : public rtl::Static< UnoTunnelIdInit, theScAccessibleDocumentPagePreviewImplementationId > {};
1627 : : }
1628 : :
1629 : : uno::Sequence<sal_Int8> SAL_CALL
1630 : 0 : ScAccessibleDocumentPagePreview::getImplementationId(void)
1631 : : throw (uno::RuntimeException)
1632 : : {
1633 : 0 : return theScAccessibleDocumentPagePreviewImplementationId::get().getSeq();
1634 : : }
1635 : :
1636 : : //===== internal ========================================================
1637 : :
1638 : 60 : ::rtl::OUString SAL_CALL ScAccessibleDocumentPagePreview::createAccessibleDescription(void)
1639 : : throw (uno::RuntimeException)
1640 : : {
1641 [ + - ][ + - ]: 60 : rtl::OUString sDescription = String(ScResId(STR_ACC_PREVIEWDOC_DESCR));
[ + - ]
1642 : 60 : return sDescription;
1643 : : }
1644 : :
1645 : 16 : ::rtl::OUString SAL_CALL ScAccessibleDocumentPagePreview::createAccessibleName(void)
1646 : : throw (uno::RuntimeException)
1647 : : {
1648 [ + - ][ + - ]: 16 : rtl::OUString sName = String(ScResId(STR_ACC_PREVIEWDOC_NAME));
[ + - ]
1649 : 16 : return sName;
1650 : : }
1651 : :
1652 : 3 : Rectangle ScAccessibleDocumentPagePreview::GetBoundingBoxOnScreen() const throw (uno::RuntimeException)
1653 : : {
1654 : 3 : Rectangle aRect;
1655 [ + - ]: 3 : if (mpViewShell)
1656 : : {
1657 : 3 : Window* pWindow = mpViewShell->GetWindow();
1658 [ + - ]: 3 : if (pWindow)
1659 : 3 : aRect = pWindow->GetWindowExtentsRelative(NULL);
1660 : : }
1661 : 3 : return aRect;
1662 : : }
1663 : :
1664 : 167 : Rectangle ScAccessibleDocumentPagePreview::GetBoundingBox() const throw (uno::RuntimeException)
1665 : : {
1666 : 167 : Rectangle aRect;
1667 [ + - ]: 167 : if (mpViewShell)
1668 : : {
1669 : 167 : Window* pWindow = mpViewShell->GetWindow();
1670 [ + - ]: 167 : if (pWindow)
1671 : 167 : aRect = pWindow->GetWindowExtentsRelative(pWindow->GetAccessibleParentWindow());
1672 : : }
1673 : 167 : return aRect;
1674 : : }
1675 : :
1676 : 88 : sal_Bool ScAccessibleDocumentPagePreview::IsDefunc(
1677 : : const uno::Reference<XAccessibleStateSet>& rxParentStates)
1678 : : {
1679 [ + - ][ + - ]: 264 : return ScAccessibleContextBase::IsDefunc() || !getAccessibleParent().is() ||
[ # # ]
1680 [ + - ][ + - ]: 264 : (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
[ + - ][ - + ]
[ + - + - ]
1681 : : }
1682 : :
1683 : 192 : ScNotesChildren* ScAccessibleDocumentPagePreview::GetNotesChildren()
1684 : : {
1685 [ + + ][ + - ]: 192 : if (!mpNotesChildren && mpViewShell)
1686 : : {
1687 [ + - ][ + - ]: 16 : mpNotesChildren = new ScNotesChildren(mpViewShell, this);
1688 : :
1689 [ + - ]: 16 : const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
1690 [ + - ][ + - ]: 16 : ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChildren(), GetShapeChildren() );
[ + - ]
1691 : :
1692 : : //! order is background shapes, header, table or notes, footer, foreground shapes, controls
1693 [ + - ]: 16 : mpNotesChildren->Init(aCount.aVisRect, aCount.nBackShapes + aCount.nHeaders);
1694 : : }
1695 : 192 : return mpNotesChildren;
1696 : : }
1697 : :
1698 : 192 : ScShapeChildren* ScAccessibleDocumentPagePreview::GetShapeChildren()
1699 : : {
1700 [ + + ][ + - ]: 192 : if (!mpShapeChildren && mpViewShell)
1701 : : {
1702 [ + - ]: 16 : mpShapeChildren = new ScShapeChildren(mpViewShell, this);
1703 : 16 : mpShapeChildren->Init();
1704 : : }
1705 : :
1706 : 192 : return mpShapeChildren;
1707 : : }
1708 : :
1709 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|