Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "scitems.hxx"
21 : #include <editeng/eeitem.hxx>
22 :
23 : #include <memory>
24 : #include "AccessibleText.hxx"
25 : #include "AccessibleCell.hxx"
26 : #include "tabvwsh.hxx"
27 : #include "editutil.hxx"
28 : #include "document.hxx"
29 : #include "scmod.hxx"
30 : #include "prevwsh.hxx"
31 : #include "docsh.hxx"
32 : #include "prevloc.hxx"
33 : #include "patattr.hxx"
34 : #include "inputwin.hxx"
35 : #include <editeng/unofored.hxx>
36 : #include <editeng/editview.hxx>
37 : #include <editeng/unoedhlp.hxx>
38 : #include <vcl/virdev.hxx>
39 : #include <editeng/editobj.hxx>
40 : #include <editeng/adjustitem.hxx>
41 : #include <editeng/justifyitem.hxx>
42 : #include <svx/svdmodel.hxx>
43 : #include <svx/algitem.hxx>
44 : #include <vcl/svapp.hxx>
45 :
46 : class ScViewForwarder : public SvxViewForwarder
47 : {
48 : ScTabViewShell* mpViewShell;
49 : ScAddress maCellPos;
50 : ScSplitPos meSplitPos;
51 : public:
52 : ScViewForwarder(ScTabViewShell* pViewShell, ScSplitPos eSplitPos, const ScAddress& rCell);
53 : virtual ~ScViewForwarder();
54 :
55 : virtual bool IsValid() const SAL_OVERRIDE;
56 : virtual Rectangle GetVisArea() const SAL_OVERRIDE;
57 : virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const SAL_OVERRIDE;
58 : virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const SAL_OVERRIDE;
59 :
60 : void SetInvalid();
61 : };
62 :
63 0 : ScViewForwarder::ScViewForwarder(ScTabViewShell* pViewShell, ScSplitPos eSplitPos, const ScAddress& rCell)
64 : :
65 : mpViewShell(pViewShell),
66 : maCellPos(rCell),
67 0 : meSplitPos(eSplitPos)
68 : {
69 0 : }
70 :
71 0 : ScViewForwarder::~ScViewForwarder()
72 : {
73 0 : }
74 :
75 0 : bool ScViewForwarder::IsValid() const
76 : {
77 0 : return mpViewShell != NULL;
78 : }
79 :
80 0 : Rectangle ScViewForwarder::GetVisArea() const
81 : {
82 0 : Rectangle aVisArea;
83 0 : if (mpViewShell)
84 : {
85 0 : vcl::Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
86 0 : if (pWindow)
87 : {
88 0 : aVisArea.SetSize(pWindow->GetSizePixel());
89 :
90 0 : ScHSplitPos eWhichH = ((meSplitPos == SC_SPLIT_TOPLEFT) || (meSplitPos == SC_SPLIT_BOTTOMLEFT)) ?
91 0 : SC_SPLIT_LEFT : SC_SPLIT_RIGHT;
92 0 : ScVSplitPos eWhichV = ((meSplitPos == SC_SPLIT_TOPLEFT) || (meSplitPos == SC_SPLIT_TOPRIGHT)) ?
93 0 : SC_SPLIT_TOP : SC_SPLIT_BOTTOM;
94 :
95 0 : Point aBaseCellPos(mpViewShell->GetViewData().GetScrPos(mpViewShell->GetViewData().GetPosX(eWhichH),
96 0 : mpViewShell->GetViewData().GetPosY(eWhichV), meSplitPos, true));
97 0 : Point aCellPos(mpViewShell->GetViewData().GetScrPos(maCellPos.Col(), maCellPos.Row(), meSplitPos, true));
98 0 : aVisArea.SetPos(aCellPos - aBaseCellPos);
99 : }
100 : }
101 : else
102 : {
103 : OSL_FAIL("this ViewForwarder is not valid");
104 : }
105 0 : return aVisArea;
106 : }
107 :
108 0 : Point ScViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
109 : {
110 0 : if (mpViewShell)
111 : {
112 0 : vcl::Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
113 0 : if (pWindow)
114 0 : return pWindow->LogicToPixel( rPoint, rMapMode );
115 : }
116 : else
117 : {
118 : OSL_FAIL("this ViewForwarder is not valid");
119 : }
120 0 : return Point();
121 : }
122 :
123 0 : Point ScViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
124 : {
125 0 : if (mpViewShell)
126 : {
127 0 : vcl::Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
128 0 : if (pWindow)
129 0 : return pWindow->PixelToLogic( rPoint, rMapMode );
130 : }
131 : else
132 : {
133 : OSL_FAIL("this ViewForwarder is not valid");
134 : }
135 0 : return Point();
136 : }
137 :
138 0 : void ScViewForwarder::SetInvalid()
139 : {
140 0 : mpViewShell = NULL;
141 0 : }
142 :
143 : class ScEditObjectViewForwarder : public SvxViewForwarder
144 : {
145 : VclPtr<vcl::Window> mpWindow;
146 : // #i49561# EditView needed for access to its visible area.
147 : const EditView* mpEditView;
148 : public:
149 : ScEditObjectViewForwarder( vcl::Window* pWindow,
150 : const EditView* _pEditView);
151 : virtual ~ScEditObjectViewForwarder();
152 :
153 : virtual bool IsValid() const SAL_OVERRIDE;
154 : virtual Rectangle GetVisArea() const SAL_OVERRIDE;
155 : virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const SAL_OVERRIDE;
156 : virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const SAL_OVERRIDE;
157 :
158 : void SetInvalid();
159 : };
160 :
161 0 : ScEditObjectViewForwarder::ScEditObjectViewForwarder( vcl::Window* pWindow,
162 : const EditView* _pEditView )
163 : :
164 : mpWindow(pWindow),
165 0 : mpEditView( _pEditView )
166 : {
167 0 : }
168 :
169 0 : ScEditObjectViewForwarder::~ScEditObjectViewForwarder()
170 : {
171 0 : }
172 :
173 0 : bool ScEditObjectViewForwarder::IsValid() const
174 : {
175 0 : return (mpWindow != nullptr);
176 : }
177 :
178 0 : Rectangle ScEditObjectViewForwarder::GetVisArea() const
179 : {
180 0 : Rectangle aVisArea;
181 0 : if (mpWindow)
182 : {
183 0 : Rectangle aVisRect(mpWindow->GetWindowExtentsRelative(mpWindow->GetAccessibleParentWindow()));
184 :
185 0 : aVisRect.SetPos(Point(0, 0));
186 :
187 0 : aVisArea = aVisRect;
188 : }
189 : else
190 : {
191 : OSL_FAIL("this ViewForwarder is not valid");
192 : }
193 0 : return aVisArea;
194 : }
195 :
196 0 : Point ScEditObjectViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
197 : {
198 0 : if (mpWindow)
199 : {
200 : // #i49561# - consider offset of the visible area
201 : // of the EditView before converting point to pixel.
202 0 : Point aPoint( rPoint );
203 0 : if ( mpEditView )
204 : {
205 0 : Rectangle aEditViewVisArea( mpEditView->GetVisArea() );
206 0 : aPoint += aEditViewVisArea.TopLeft();
207 : }
208 0 : return mpWindow->LogicToPixel( aPoint, rMapMode );
209 : }
210 : else
211 : {
212 : OSL_FAIL("this ViewForwarder is not valid");
213 : }
214 0 : return Point();
215 : }
216 :
217 0 : Point ScEditObjectViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
218 : {
219 0 : if (mpWindow)
220 : {
221 : // #i49561# - consider offset of the visible area
222 : // of the EditView after converting point to logic.
223 0 : Point aPoint( mpWindow->PixelToLogic( rPoint, rMapMode ) );
224 0 : if ( mpEditView )
225 : {
226 0 : Rectangle aEditViewVisArea( mpEditView->GetVisArea() );
227 0 : aPoint -= aEditViewVisArea.TopLeft();
228 : }
229 0 : return aPoint;
230 : }
231 : else
232 : {
233 : OSL_FAIL("this ViewForwarder is not valid");
234 : }
235 0 : return Point();
236 : }
237 :
238 0 : void ScEditObjectViewForwarder::SetInvalid()
239 : {
240 0 : mpWindow = NULL;
241 0 : }
242 :
243 : class ScPreviewViewForwarder : public SvxViewForwarder
244 : {
245 : protected:
246 : ScPreviewShell* mpViewShell;
247 : mutable ScPreviewTableInfo* mpTableInfo;
248 : public:
249 : ScPreviewViewForwarder(ScPreviewShell* pViewShell);
250 : virtual ~ScPreviewViewForwarder();
251 :
252 : virtual bool IsValid() const SAL_OVERRIDE;
253 : virtual Rectangle GetVisArea() const SAL_OVERRIDE;
254 : virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const SAL_OVERRIDE;
255 : virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const SAL_OVERRIDE;
256 :
257 : void SetInvalid();
258 :
259 : Rectangle GetVisRect() const;
260 :
261 : // clips the VisArea and calculates with the negativ coordinates
262 : Rectangle CorrectVisArea(const Rectangle& rVisArea) const;
263 : };
264 :
265 25 : ScPreviewViewForwarder::ScPreviewViewForwarder(ScPreviewShell* pViewShell)
266 : :
267 : mpViewShell(pViewShell),
268 25 : mpTableInfo(NULL)
269 : {
270 25 : }
271 :
272 14 : ScPreviewViewForwarder::~ScPreviewViewForwarder()
273 : {
274 7 : delete mpTableInfo;
275 7 : }
276 :
277 139 : bool ScPreviewViewForwarder::IsValid() const
278 : {
279 139 : return mpViewShell != NULL;
280 : }
281 :
282 0 : Rectangle ScPreviewViewForwarder::GetVisArea() const
283 : {
284 0 : Rectangle aVisArea;
285 : OSL_FAIL("should be implemented in an abrevated class");
286 0 : return aVisArea;
287 : }
288 :
289 254 : Point ScPreviewViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
290 : {
291 254 : if (mpViewShell)
292 : {
293 254 : vcl::Window* pWindow = mpViewShell->GetWindow();
294 254 : if (pWindow)
295 : {
296 254 : MapMode aMapMode(pWindow->GetMapMode().GetMapUnit());
297 254 : Point aPoint2( OutputDevice::LogicToLogic( rPoint, rMapMode, aMapMode) );
298 254 : return pWindow->LogicToPixel(aPoint2);
299 : }
300 : }
301 : else
302 : {
303 : OSL_FAIL("this ViewForwarder is not valid");
304 : }
305 0 : return Point();
306 : }
307 :
308 12 : Point ScPreviewViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
309 : {
310 12 : if (mpViewShell)
311 : {
312 12 : vcl::Window* pWindow = mpViewShell->GetWindow();
313 12 : if (pWindow)
314 : {
315 12 : MapMode aMapMode(pWindow->GetMapMode());
316 12 : aMapMode.SetOrigin(Point());
317 12 : Point aPoint1( pWindow->PixelToLogic( rPoint ) );
318 : Point aPoint2( OutputDevice::LogicToLogic( aPoint1,
319 : aMapMode.GetMapUnit(),
320 12 : rMapMode ) );
321 12 : return aPoint2;
322 : }
323 : }
324 : else
325 : {
326 : OSL_FAIL("this ViewForwarder is not valid");
327 : }
328 0 : return Point();
329 : }
330 :
331 8 : void ScPreviewViewForwarder::SetInvalid()
332 : {
333 8 : mpViewShell = NULL;
334 8 : }
335 :
336 12 : Rectangle ScPreviewViewForwarder::GetVisRect() const
337 : {
338 12 : if ( mpViewShell )
339 : {
340 12 : Size aOutputSize;
341 12 : vcl::Window* pWindow = mpViewShell->GetWindow();
342 12 : if ( pWindow )
343 12 : aOutputSize = pWindow->GetOutputSizePixel();
344 12 : Point aPoint;
345 12 : Rectangle aVisRect( aPoint, aOutputSize );
346 12 : return aVisRect;
347 : }
348 0 : return Rectangle();
349 : }
350 :
351 44 : Rectangle ScPreviewViewForwarder::CorrectVisArea(const Rectangle& rVisArea) const
352 : {
353 44 : Rectangle aVisArea(rVisArea);
354 44 : Point aPos = aVisArea.TopLeft(); // get first the position to remember negative positions after clipping
355 :
356 44 : vcl::Window* pWin = mpViewShell->GetWindow();
357 44 : if (pWin)
358 44 : aVisArea = pWin->GetWindowExtentsRelative(pWin).GetIntersection(aVisArea);
359 :
360 44 : sal_Int32 nX(aPos.getX());
361 44 : sal_Int32 nY(aPos.getY());
362 :
363 44 : if (nX > 0)
364 44 : nX = 0;
365 0 : else if (nX < 0)
366 0 : nX = -nX;
367 44 : if (nY > 0)
368 44 : nY = 0;
369 0 : else if (nY < 0)
370 0 : nY = -nY;
371 44 : aVisArea.SetPos(Point(nX, nY));
372 :
373 44 : return aVisArea;
374 : }
375 :
376 : class ScPreviewHeaderFooterViewForwarder : public ScPreviewViewForwarder
377 : {
378 : bool mbHeader;
379 : public:
380 : ScPreviewHeaderFooterViewForwarder(ScPreviewShell* pViewShell, bool bHeader);
381 : virtual ~ScPreviewHeaderFooterViewForwarder();
382 :
383 : virtual Rectangle GetVisArea() const SAL_OVERRIDE;
384 : };
385 :
386 10 : ScPreviewHeaderFooterViewForwarder::ScPreviewHeaderFooterViewForwarder(ScPreviewShell* pViewShell, bool bHeader)
387 : :
388 : ScPreviewViewForwarder(pViewShell),
389 10 : mbHeader(bHeader)
390 : {
391 10 : }
392 :
393 0 : ScPreviewHeaderFooterViewForwarder::~ScPreviewHeaderFooterViewForwarder()
394 : {
395 0 : }
396 :
397 20 : Rectangle ScPreviewHeaderFooterViewForwarder::GetVisArea() const
398 : {
399 20 : Rectangle aVisArea;
400 20 : if (mpViewShell)
401 : {
402 20 : const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
403 20 : if ( mbHeader )
404 12 : rData.GetHeaderPosition( aVisArea );
405 : else
406 8 : rData.GetFooterPosition( aVisArea );
407 :
408 20 : aVisArea = CorrectVisArea(aVisArea);
409 : }
410 : else
411 : {
412 : OSL_FAIL("this ViewForwarder is not valid");
413 : }
414 20 : return aVisArea;
415 : }
416 :
417 : class ScPreviewCellViewForwarder : public ScPreviewViewForwarder
418 : {
419 : ScAddress maCellPos;
420 : public:
421 : ScPreviewCellViewForwarder(ScPreviewShell* pViewShell,
422 : ScAddress aCellPos);
423 : virtual ~ScPreviewCellViewForwarder();
424 :
425 : virtual Rectangle GetVisArea() const SAL_OVERRIDE;
426 : };
427 :
428 7 : ScPreviewCellViewForwarder::ScPreviewCellViewForwarder(ScPreviewShell* pViewShell,
429 : ScAddress aCellPos)
430 : :
431 : ScPreviewViewForwarder(pViewShell),
432 7 : maCellPos(aCellPos)
433 : {
434 7 : }
435 :
436 14 : ScPreviewCellViewForwarder::~ScPreviewCellViewForwarder()
437 : {
438 14 : }
439 :
440 12 : Rectangle ScPreviewCellViewForwarder::GetVisArea() const
441 : {
442 12 : Rectangle aVisArea;
443 12 : if (mpViewShell)
444 : {
445 12 : const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
446 12 : aVisArea = rData.GetCellOutputRect(maCellPos);
447 :
448 12 : aVisArea = CorrectVisArea(aVisArea);
449 : }
450 : else
451 : {
452 : OSL_FAIL("this ViewForwarder is not valid");
453 : }
454 12 : return aVisArea;
455 : }
456 :
457 : class ScPreviewHeaderCellViewForwarder : public ScPreviewViewForwarder
458 : {
459 : ScAddress maCellPos;
460 : bool mbColHeader;
461 : public:
462 : ScPreviewHeaderCellViewForwarder(ScPreviewShell* pViewShell,
463 : ScAddress aCellPos,
464 : bool bColHeader);
465 : virtual ~ScPreviewHeaderCellViewForwarder();
466 :
467 : virtual Rectangle GetVisArea() const SAL_OVERRIDE;
468 : };
469 :
470 8 : ScPreviewHeaderCellViewForwarder::ScPreviewHeaderCellViewForwarder(ScPreviewShell* pViewShell,
471 : ScAddress aCellPos,
472 : bool bColHeader)
473 : :
474 : ScPreviewViewForwarder(pViewShell),
475 : maCellPos(aCellPos),
476 8 : mbColHeader(bColHeader)
477 : {
478 8 : }
479 :
480 0 : ScPreviewHeaderCellViewForwarder::~ScPreviewHeaderCellViewForwarder()
481 : {
482 0 : }
483 :
484 12 : Rectangle ScPreviewHeaderCellViewForwarder::GetVisArea() const
485 : {
486 12 : Rectangle aVisArea;
487 12 : if (mpViewShell)
488 : {
489 12 : const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
490 12 : aVisArea = rData.GetHeaderCellOutputRect(GetVisRect(), maCellPos, mbColHeader);
491 :
492 12 : aVisArea = CorrectVisArea(aVisArea);
493 : }
494 : else
495 : {
496 : OSL_FAIL("this ViewForwarder is not valid");
497 : }
498 12 : return aVisArea;
499 : }
500 :
501 : class ScPreviewNoteViewForwarder : public ScPreviewViewForwarder
502 : {
503 : ScAddress maCellPos;
504 : bool mbNoteMark;
505 : public:
506 : ScPreviewNoteViewForwarder(ScPreviewShell* pViewShell,
507 : ScAddress aCellPos,
508 : bool bNoteMark);
509 : virtual ~ScPreviewNoteViewForwarder();
510 :
511 : virtual Rectangle GetVisArea() const SAL_OVERRIDE;
512 : };
513 :
514 0 : ScPreviewNoteViewForwarder::ScPreviewNoteViewForwarder(ScPreviewShell* pViewShell,
515 : ScAddress aCellPos,
516 : bool bNoteMark)
517 : :
518 : ScPreviewViewForwarder(pViewShell),
519 : maCellPos(aCellPos),
520 0 : mbNoteMark(bNoteMark)
521 : {
522 0 : }
523 :
524 0 : ScPreviewNoteViewForwarder::~ScPreviewNoteViewForwarder()
525 : {
526 0 : }
527 :
528 0 : Rectangle ScPreviewNoteViewForwarder::GetVisArea() const
529 : {
530 0 : Rectangle aVisArea;
531 0 : if (mpViewShell)
532 : {
533 0 : const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
534 0 : aVisArea = rData.GetNoteInRangeOutputRect(GetVisRect(), mbNoteMark, maCellPos);
535 :
536 0 : aVisArea = CorrectVisArea(aVisArea);
537 : }
538 : else
539 : {
540 : OSL_FAIL("this ViewForwarder is not valid");
541 : }
542 0 : return aVisArea;
543 : }
544 :
545 : class ScEditViewForwarder : public SvxEditViewForwarder
546 : {
547 : EditView* mpEditView;
548 : VclPtr<vcl::Window> mpWindow;
549 : public:
550 : ScEditViewForwarder(EditView* pEditView, vcl::Window* pWin);
551 : virtual ~ScEditViewForwarder();
552 :
553 : virtual bool IsValid() const SAL_OVERRIDE;
554 : virtual Rectangle GetVisArea() const SAL_OVERRIDE;
555 : virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const SAL_OVERRIDE;
556 : virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const SAL_OVERRIDE;
557 : virtual bool GetSelection( ESelection& rSelection ) const SAL_OVERRIDE;
558 : virtual bool SetSelection( const ESelection& rSelection ) SAL_OVERRIDE;
559 : virtual bool Copy() SAL_OVERRIDE;
560 : virtual bool Cut() SAL_OVERRIDE;
561 : virtual bool Paste() SAL_OVERRIDE;
562 :
563 : void SetInvalid();
564 : };
565 :
566 0 : ScEditViewForwarder::ScEditViewForwarder(EditView* pEditView, vcl::Window* pWin)
567 : : mpEditView(pEditView),
568 0 : mpWindow(pWin)
569 : {
570 0 : }
571 :
572 0 : ScEditViewForwarder::~ScEditViewForwarder()
573 : {
574 0 : }
575 :
576 0 : bool ScEditViewForwarder::IsValid() const
577 : {
578 0 : return mpWindow && mpEditView;
579 : }
580 :
581 0 : Rectangle ScEditViewForwarder::GetVisArea() const
582 : {
583 0 : Rectangle aVisArea;
584 0 : if (IsValid() && mpEditView->GetEditEngine())
585 : {
586 0 : MapMode aMapMode(mpEditView->GetEditEngine()->GetRefMapMode());
587 :
588 0 : aVisArea = mpWindow->LogicToPixel( mpEditView->GetVisArea(), aMapMode );
589 : }
590 : else
591 : {
592 : OSL_FAIL("this EditViewForwarder is no longer valid");
593 : }
594 0 : return aVisArea;
595 : }
596 :
597 0 : Point ScEditViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
598 : {
599 0 : if (mpWindow)
600 0 : return mpWindow->LogicToPixel( rPoint, rMapMode );
601 : else
602 : {
603 : OSL_FAIL("this ViewForwarder is not valid");
604 : }
605 0 : return Point();
606 : }
607 :
608 0 : Point ScEditViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
609 : {
610 0 : if (mpWindow)
611 0 : return mpWindow->PixelToLogic( rPoint, rMapMode );
612 : else
613 : {
614 : OSL_FAIL("this ViewForwarder is not valid");
615 : }
616 0 : return Point();
617 : }
618 :
619 0 : bool ScEditViewForwarder::GetSelection( ESelection& rSelection ) const
620 : {
621 0 : bool bResult(false);
622 0 : if (IsValid())
623 : {
624 0 : rSelection = mpEditView->GetSelection();
625 0 : bResult = true;
626 : }
627 : else
628 : {
629 : OSL_FAIL("this ViewForwarder is not valid");
630 : }
631 0 : return bResult;
632 : }
633 :
634 0 : bool ScEditViewForwarder::SetSelection( const ESelection& rSelection )
635 : {
636 0 : bool bResult(false);
637 0 : if (IsValid())
638 : {
639 0 : mpEditView->SetSelection(rSelection);
640 0 : bResult = true;
641 : }
642 : else
643 : {
644 : OSL_FAIL("this ViewForwarder is not valid");
645 : }
646 0 : return bResult;
647 : }
648 :
649 0 : bool ScEditViewForwarder::Copy()
650 : {
651 0 : bool bResult(false);
652 0 : if (IsValid())
653 : {
654 0 : mpEditView->Copy();
655 0 : bResult = true;
656 : }
657 : else
658 : {
659 : OSL_FAIL("this ViewForwarder is not valid");
660 : }
661 0 : return bResult;
662 : }
663 :
664 0 : bool ScEditViewForwarder::Cut()
665 : {
666 0 : bool bResult(false);
667 0 : if (IsValid())
668 : {
669 0 : mpEditView->Cut();
670 0 : bResult = true;
671 : }
672 : else
673 : {
674 : OSL_FAIL("this ViewForwarder is not valid");
675 : }
676 0 : return bResult;
677 : }
678 :
679 0 : bool ScEditViewForwarder::Paste()
680 : {
681 0 : bool bResult(false);
682 0 : if (IsValid())
683 : {
684 0 : mpEditView->Paste();
685 0 : bResult = true;
686 : }
687 : else
688 : {
689 : OSL_FAIL("this ViewForwarder is not valid");
690 : }
691 0 : return bResult;
692 : }
693 :
694 0 : void ScEditViewForwarder::SetInvalid()
695 : {
696 0 : mpWindow = NULL;
697 0 : mpEditView = NULL;
698 0 : }
699 :
700 : // ScAccessibleCellTextData: shared data between sub objects of a accessible cell text object
701 :
702 5 : ScAccessibleCellTextData::ScAccessibleCellTextData(ScTabViewShell* pViewShell,
703 : const ScAddress& rP, ScSplitPos eSplitPos, ScAccessibleCell* pAccCell)
704 : : ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP),
705 : mpViewForwarder(NULL),
706 : mpEditViewForwarder(NULL),
707 : mpViewShell(pViewShell),
708 : meSplitPos(eSplitPos),
709 5 : mpAccessibleCell( pAccCell )
710 : {
711 5 : }
712 :
713 15 : ScAccessibleCellTextData::~ScAccessibleCellTextData()
714 : {
715 5 : if (pEditEngine)
716 0 : pEditEngine->SetNotifyHdl(Link<>());
717 5 : if (mpViewForwarder)
718 0 : delete mpViewForwarder;
719 5 : if (mpEditViewForwarder)
720 0 : delete mpEditViewForwarder;
721 10 : }
722 :
723 23 : void ScAccessibleCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
724 : {
725 23 : const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
726 23 : if ( pSimpleHint )
727 : {
728 23 : sal_uLong nId = pSimpleHint->GetId();
729 23 : if ( nId == SFX_HINT_DYING )
730 : {
731 5 : mpViewShell = NULL; // invalid now
732 5 : if (mpViewForwarder)
733 0 : mpViewForwarder->SetInvalid();
734 5 : if (mpEditViewForwarder)
735 0 : mpEditViewForwarder->SetInvalid();
736 : }
737 : }
738 23 : ScAccessibleCellBaseTextData::Notify(rBC, rHint);
739 23 : }
740 :
741 0 : ScAccessibleTextData* ScAccessibleCellTextData::Clone() const
742 : {
743 0 : return new ScAccessibleCellTextData( mpViewShell, aCellPos, meSplitPos, mpAccessibleCell );
744 : }
745 :
746 5 : void ScAccessibleCellTextData::GetCellText(const ScAddress& rCellPos, OUString& rText)
747 : {
748 : // #104893#; don't use the input string
749 : // ScCellTextData::GetCellText(rCellPos, rText);
750 5 : ScDocument& rDoc = pDocShell->GetDocument();
751 : // #104893#; use the displayed string
752 5 : rText = rDoc.GetString(rCellPos.Col(), rCellPos.Row(), rCellPos.Tab());
753 5 : if (mpViewShell)
754 : {
755 5 : const ScViewOptions& aOptions = mpViewShell->GetViewData().GetOptions();
756 : CellType aCellType;
757 5 : rDoc.GetCellType(rCellPos.Col(), rCellPos.Row(), rCellPos.Tab(), aCellType);
758 5 : if (aCellType == CELLTYPE_FORMULA && aOptions.GetOption( VOPT_FORMULAS ))
759 : {
760 0 : rDoc.GetFormula( rCellPos.Col(), rCellPos.Row(), rCellPos.Tab(), rText);
761 : }
762 5 : else if (!aOptions.GetOption( VOPT_NULLVALS ))
763 : {
764 0 : if ((aCellType == CELLTYPE_VALUE || aCellType == CELLTYPE_FORMULA) && rDoc.GetValue(rCellPos) == 0.0)
765 0 : rText.clear();
766 : }
767 : }
768 5 : }
769 :
770 10 : SvxTextForwarder* ScAccessibleCellTextData::GetTextForwarder()
771 : {
772 10 : ScCellTextData::GetTextForwarder(); // creates Forwarder and EditEngine
773 :
774 10 : if ( pDocShell && pEditEngine && mpViewShell )
775 : {
776 10 : ScDocument& rDoc = pDocShell->GetDocument();
777 : long nSizeX, nSizeY;
778 10 : mpViewShell->GetViewData().GetMergeSizePixel(
779 20 : aCellPos.Col(), aCellPos.Row(), nSizeX, nSizeY);
780 :
781 10 : Size aSize(nSizeX, nSizeY);
782 :
783 : // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
784 10 : long nIndent = 0;
785 : const SvxHorJustifyItem* pHorJustifyItem = static_cast< const SvxHorJustifyItem* >(
786 10 : rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_HOR_JUSTIFY ) );
787 10 : SvxCellHorJustify eHorJust = ( pHorJustifyItem ? static_cast< SvxCellHorJustify >( pHorJustifyItem->GetValue() ) : SVX_HOR_JUSTIFY_STANDARD );
788 10 : if ( eHorJust == SVX_HOR_JUSTIFY_LEFT )
789 : {
790 : const SfxUInt16Item* pIndentItem = static_cast< const SfxUInt16Item* >(
791 0 : rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_INDENT ) );
792 0 : if ( pIndentItem )
793 : {
794 0 : nIndent = static_cast< long >( pIndentItem->GetValue() );
795 : }
796 : }
797 :
798 : const SvxMarginItem* pMarginItem = static_cast< const SvxMarginItem* >(
799 10 : rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_MARGIN ) );
800 10 : ScViewData& rViewData = mpViewShell->GetViewData();
801 10 : double nPPTX = rViewData.GetPPTX();
802 10 : double nPPTY = rViewData.GetPPTY();
803 10 : long nLeftM = ( pMarginItem ? static_cast< long >( ( pMarginItem->GetLeftMargin() + nIndent ) * nPPTX ) : 0 );
804 10 : long nTopM = ( pMarginItem ? static_cast< long >( pMarginItem->GetTopMargin() * nPPTY ) : 0 );
805 10 : long nRightM = ( pMarginItem ? static_cast< long >( pMarginItem->GetRightMargin() * nPPTX ) : 0 );
806 10 : long nBottomM = ( pMarginItem ? static_cast< long >( pMarginItem->GetBottomMargin() * nPPTY ) : 0 );
807 10 : long nWidth = aSize.getWidth() - nLeftM - nRightM;
808 10 : aSize.setWidth( nWidth );
809 10 : aSize.setHeight( aSize.getHeight() - nTopM - nBottomM );
810 :
811 10 : vcl::Window* pWin = mpViewShell->GetWindowByPos( meSplitPos );
812 10 : if ( pWin )
813 : {
814 10 : aSize = pWin->PixelToLogic( aSize, pEditEngine->GetRefMapMode() );
815 : }
816 :
817 : /* #i19430# Gnopernicus reads text partly if it sticks out of the cell
818 : boundaries. This leads to wrong results in cases where the cell text
819 : is rotated, because rotation is not taken into account when calcu-
820 : lating the visible part of the text. In these cases we will expand
821 : the cell size passed as paper size to the edit engine. The function
822 : accessibility::AccessibleStaticTextBase::GetParagraphBoundingBox()
823 : (see svx/source/accessibility/AccessibleStaticTextBase.cxx) will
824 : return the size of the complete text then, which is used to expand
825 : the cell bounding box in ScAccessibleCell::GetBoundingBox()
826 : (see sc/source/ui/Accessibility/AccessibleCell.cxx). */
827 : const SfxInt32Item* pItem = static_cast< const SfxInt32Item* >(
828 10 : rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_ROTATE_VALUE ) );
829 10 : if( pItem && (pItem->GetValue() != 0) )
830 : {
831 0 : pEditEngine->SetPaperSize( Size( LONG_MAX, aSize.getHeight() ) );
832 0 : long nTxtWidth = static_cast< long >( pEditEngine->CalcTextWidth() );
833 0 : aSize.setWidth( std::max( aSize.getWidth(), nTxtWidth + 2 ) );
834 : }
835 : else
836 : {
837 : // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
838 : const SfxBoolItem* pLineBreakItem = static_cast< const SfxBoolItem* >(
839 10 : rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_LINEBREAK ) );
840 10 : bool bLineBreak = ( pLineBreakItem && pLineBreakItem->GetValue() );
841 10 : if ( !bLineBreak )
842 : {
843 10 : long nTxtWidth = static_cast< long >( pEditEngine->CalcTextWidth() );
844 10 : aSize.setWidth( ::std::max( aSize.getWidth(), nTxtWidth ) );
845 : }
846 : }
847 :
848 10 : pEditEngine->SetPaperSize( aSize );
849 :
850 : // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
851 10 : if ( eHorJust == SVX_HOR_JUSTIFY_STANDARD && rDoc.HasValueData( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab() ) )
852 : {
853 0 : pEditEngine->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
854 : }
855 :
856 10 : Size aTextSize;
857 10 : if ( pWin )
858 : {
859 10 : aTextSize = pWin->LogicToPixel( Size( pEditEngine->CalcTextWidth(), pEditEngine->GetTextHeight() ), pEditEngine->GetRefMapMode() );
860 : }
861 10 : long nTextWidth = aTextSize.Width();
862 10 : long nTextHeight = aTextSize.Height();
863 :
864 10 : long nOffsetX = nLeftM;
865 10 : long nDiffX = nTextWidth - nWidth;
866 10 : if ( nDiffX > 0 )
867 : {
868 0 : switch ( eHorJust )
869 : {
870 : case SVX_HOR_JUSTIFY_RIGHT:
871 : {
872 0 : nOffsetX -= nDiffX;
873 : }
874 0 : break;
875 : case SVX_HOR_JUSTIFY_CENTER:
876 : {
877 0 : nOffsetX -= nDiffX / 2;
878 : }
879 0 : break;
880 : default:
881 : {
882 : }
883 0 : break;
884 : }
885 : }
886 :
887 10 : long nOffsetY = 0;
888 : const SvxVerJustifyItem* pVerJustifyItem = static_cast< const SvxVerJustifyItem* >(
889 10 : rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_VER_JUSTIFY ) );
890 10 : SvxCellVerJustify eVerJust = ( pVerJustifyItem ? static_cast< SvxCellVerJustify >( pVerJustifyItem->GetValue() ) : SVX_VER_JUSTIFY_STANDARD );
891 10 : switch ( eVerJust )
892 : {
893 : case SVX_VER_JUSTIFY_STANDARD:
894 : case SVX_VER_JUSTIFY_BOTTOM:
895 : {
896 10 : nOffsetY = nSizeY - nBottomM - nTextHeight;
897 : }
898 10 : break;
899 : case SVX_VER_JUSTIFY_CENTER:
900 : {
901 0 : nOffsetY = ( nSizeY - nTopM - nBottomM - nTextHeight ) / 2 + nTopM;
902 : }
903 0 : break;
904 : default:
905 : {
906 0 : nOffsetY = nTopM;
907 : }
908 0 : break;
909 : }
910 :
911 10 : if ( mpAccessibleCell )
912 : {
913 10 : mpAccessibleCell->SetOffset( Point( nOffsetX, nOffsetY ) );
914 : }
915 :
916 10 : pEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
917 : }
918 :
919 10 : return pForwarder;
920 : }
921 :
922 0 : SvxViewForwarder* ScAccessibleCellTextData::GetViewForwarder()
923 : {
924 0 : if (!mpViewForwarder)
925 0 : mpViewForwarder = new ScViewForwarder(mpViewShell, meSplitPos, aCellPos);
926 0 : return mpViewForwarder;
927 : }
928 :
929 0 : SvxEditViewForwarder* ScAccessibleCellTextData::GetEditViewForwarder( bool /* bCreate */ )
930 : {
931 : //#102219#; there should no EditViewForwarder be, because the cell is now readonly in this interface
932 0 : return NULL;
933 : }
934 :
935 24 : IMPL_LINK(ScAccessibleTextData, NotifyHdl, EENotify*, aNotify)
936 : {
937 12 : if( aNotify )
938 : {
939 12 : ::std::unique_ptr< SfxHint > aHint = SvxEditSourceHelper::EENotification2Hint( aNotify );
940 :
941 12 : if( aHint.get() )
942 12 : GetBroadcaster().Broadcast( *aHint.get() );
943 : }
944 :
945 12 : return 0;
946 : }
947 :
948 5 : ScDocShell* ScAccessibleCellTextData::GetDocShell(ScTabViewShell* pViewShell)
949 : {
950 5 : ScDocShell* pDocSh = NULL;
951 5 : if (pViewShell)
952 5 : pDocSh = pViewShell->GetViewData().GetDocShell();
953 5 : return pDocSh;
954 : }
955 :
956 0 : ScAccessibleEditObjectTextData::ScAccessibleEditObjectTextData(EditView* pEditView, vcl::Window* pWin, bool isClone)
957 : :
958 : mpViewForwarder(NULL),
959 : mpEditViewForwarder(NULL),
960 : mpEditView(pEditView),
961 : mpEditEngine(pEditView ? pEditView->GetEditEngine() : 0),
962 : mpForwarder(NULL),
963 0 : mpWindow(pWin)
964 : {
965 : // If the object is cloned, do NOT add notify hdl.
966 0 : mbIsCloned = isClone;
967 0 : if (mpEditEngine && !mbIsCloned)
968 0 : mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData, NotifyHdl) );
969 0 : }
970 :
971 0 : ScAccessibleEditObjectTextData::~ScAccessibleEditObjectTextData()
972 : {
973 : // If the object is cloned, do NOT set notify hdl.
974 0 : if (mpEditEngine && !mbIsCloned)
975 0 : mpEditEngine->SetNotifyHdl(Link<>());
976 0 : if (mpViewForwarder)
977 0 : delete mpViewForwarder;
978 0 : if (mpEditViewForwarder)
979 0 : delete mpEditViewForwarder;
980 0 : if (mpForwarder)
981 0 : delete mpForwarder;
982 0 : }
983 :
984 0 : void ScAccessibleEditObjectTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
985 : {
986 0 : const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
987 0 : if ( pSimpleHint )
988 : {
989 0 : sal_uLong nId = pSimpleHint->GetId();
990 0 : if ( nId == SFX_HINT_DYING )
991 : {
992 0 : mpWindow = NULL;
993 0 : mpEditView = NULL;
994 0 : mpEditEngine = NULL;
995 0 : DELETEZ(mpForwarder);
996 0 : if (mpViewForwarder)
997 0 : mpViewForwarder->SetInvalid();
998 0 : if (mpEditViewForwarder)
999 0 : mpEditViewForwarder->SetInvalid();
1000 : }
1001 : }
1002 0 : ScAccessibleTextData::Notify(rBC, rHint);
1003 0 : }
1004 :
1005 0 : ScAccessibleTextData* ScAccessibleEditObjectTextData::Clone() const
1006 : {
1007 : // Add para to indicate the object is cloned
1008 0 : return new ScAccessibleEditObjectTextData(mpEditView, mpWindow, true);
1009 : }
1010 :
1011 0 : SvxTextForwarder* ScAccessibleEditObjectTextData::GetTextForwarder()
1012 : {
1013 0 : if ((!mpForwarder && mpEditView) || (mpEditEngine && !mpEditEngine->GetNotifyHdl().IsSet()))
1014 : {
1015 0 : if (!mpEditEngine)
1016 0 : mpEditEngine = mpEditView->GetEditEngine();
1017 : // If the object is cloned, do NOT add notify hdl.
1018 0 : if (mpEditEngine && !mpEditEngine->GetNotifyHdl().IsSet()&&!mbIsCloned)
1019 0 : mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData, NotifyHdl) );
1020 0 : if(!mpForwarder)
1021 0 : mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
1022 : }
1023 0 : return mpForwarder;
1024 : }
1025 :
1026 0 : SvxViewForwarder* ScAccessibleEditObjectTextData::GetViewForwarder()
1027 : {
1028 0 : if (!mpViewForwarder)
1029 : {
1030 : // i#49561 Get right-aligned cell content to be read by screenreader.
1031 0 : mpViewForwarder = new ScEditObjectViewForwarder( mpWindow, mpEditView );
1032 : }
1033 0 : return mpViewForwarder;
1034 : }
1035 :
1036 0 : SvxEditViewForwarder* ScAccessibleEditObjectTextData::GetEditViewForwarder( bool bCreate )
1037 : {
1038 0 : if (!mpEditViewForwarder && mpEditView)
1039 0 : mpEditViewForwarder = new ScEditViewForwarder(mpEditView, mpWindow);
1040 0 : if (bCreate)
1041 : {
1042 0 : if (!mpEditView && mpEditViewForwarder)
1043 : {
1044 0 : DELETEZ(mpEditViewForwarder);
1045 : }
1046 : }
1047 0 : return mpEditViewForwarder;
1048 : }
1049 :
1050 0 : IMPL_LINK(ScAccessibleEditObjectTextData, NotifyHdl, EENotify*, aNotify)
1051 : {
1052 0 : if( aNotify )
1053 : {
1054 0 : ::std::unique_ptr< SfxHint > aHint = SvxEditSourceHelper::EENotification2Hint( aNotify );
1055 :
1056 0 : if( aHint.get() )
1057 0 : GetBroadcaster().Broadcast( *aHint.get() );
1058 : }
1059 :
1060 0 : return 0;
1061 : }
1062 :
1063 0 : ScAccessibleEditLineTextData::ScAccessibleEditLineTextData(EditView* pEditView, vcl::Window* pWin)
1064 : :
1065 : ScAccessibleEditObjectTextData(pEditView, pWin),
1066 0 : mbEditEngineCreated(false)
1067 : {
1068 0 : ScTextWnd* pTxtWnd = dynamic_cast<ScTextWnd*>( pWin );
1069 :
1070 0 : if (pTxtWnd)
1071 0 : pTxtWnd->InsertAccessibleTextData( *this );
1072 0 : }
1073 :
1074 0 : ScAccessibleEditLineTextData::~ScAccessibleEditLineTextData()
1075 : {
1076 0 : ScTextWnd* pTxtWnd = dynamic_cast< ScTextWnd* >(mpWindow.get());
1077 :
1078 0 : if (pTxtWnd)
1079 0 : pTxtWnd->RemoveAccessibleTextData( *this );
1080 :
1081 0 : if (mbEditEngineCreated && mpEditEngine)
1082 : {
1083 0 : delete mpEditEngine;
1084 0 : mpEditEngine = NULL; // don't access in ScAccessibleEditObjectTextData dtor!
1085 : }
1086 0 : else if (pTxtWnd && pTxtWnd->GetEditView() && pTxtWnd->GetEditView()->GetEditEngine())
1087 : {
1088 : // the NotifyHdl also has to be removed from the ScTextWnd's EditEngine
1089 : // (it's set in ScAccessibleEditLineTextData::GetTextForwarder, and mpEditEngine
1090 : // is reset there)
1091 0 : pTxtWnd->GetEditView()->GetEditEngine()->SetNotifyHdl(Link<>());
1092 : }
1093 0 : }
1094 :
1095 0 : void ScAccessibleEditLineTextData::Dispose()
1096 : {
1097 0 : ScTextWnd* pTxtWnd = dynamic_cast<ScTextWnd*>(mpWindow.get());
1098 :
1099 0 : if (pTxtWnd)
1100 0 : pTxtWnd->RemoveAccessibleTextData( *this );
1101 :
1102 0 : ResetEditMode();
1103 0 : mpWindow = NULL;
1104 0 : }
1105 :
1106 0 : ScAccessibleTextData* ScAccessibleEditLineTextData::Clone() const
1107 : {
1108 0 : return new ScAccessibleEditLineTextData(mpEditView, mpWindow);
1109 : }
1110 :
1111 0 : SvxTextForwarder* ScAccessibleEditLineTextData::GetTextForwarder()
1112 : {
1113 0 : ScTextWnd* pTxtWnd = dynamic_cast<ScTextWnd*>(mpWindow.get());
1114 :
1115 0 : if (pTxtWnd)
1116 : {
1117 0 : mpEditView = pTxtWnd->GetEditView();
1118 0 : if (mpEditView)
1119 : {
1120 0 : if (mbEditEngineCreated && mpEditEngine)
1121 0 : ResetEditMode();
1122 0 : mbEditEngineCreated = false;
1123 :
1124 0 : mpEditView = pTxtWnd->GetEditView();
1125 0 : ScAccessibleEditObjectTextData::GetTextForwarder(); // fill the mpForwarder
1126 0 : mpEditEngine = NULL;
1127 : }
1128 : else
1129 : {
1130 0 : if (mpEditEngine && !mbEditEngineCreated)
1131 0 : ResetEditMode();
1132 0 : if (!mpEditEngine)
1133 : {
1134 0 : SfxItemPool* pEnginePool = EditEngine::CreatePool();
1135 0 : pEnginePool->FreezeIdRanges();
1136 0 : mpEditEngine = new ScFieldEditEngine(NULL, pEnginePool, NULL, true);
1137 0 : mbEditEngineCreated = true;
1138 0 : mpEditEngine->EnableUndo( false );
1139 0 : mpEditEngine->SetRefMapMode( MAP_100TH_MM );
1140 0 : mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
1141 :
1142 0 : mpEditEngine->SetText(pTxtWnd->GetTextString());
1143 :
1144 0 : Size aSize(pTxtWnd->GetSizePixel());
1145 :
1146 0 : aSize = pTxtWnd->PixelToLogic(aSize, mpEditEngine->GetRefMapMode());
1147 :
1148 0 : mpEditEngine->SetPaperSize(aSize);
1149 :
1150 0 : mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData, NotifyHdl) );
1151 : }
1152 : }
1153 : }
1154 0 : return mpForwarder;
1155 : }
1156 :
1157 0 : SvxEditViewForwarder* ScAccessibleEditLineTextData::GetEditViewForwarder( bool bCreate )
1158 : {
1159 0 : ScTextWnd* pTxtWnd = dynamic_cast<ScTextWnd*>(mpWindow.get());
1160 :
1161 0 : if (pTxtWnd)
1162 : {
1163 0 : mpEditView = pTxtWnd->GetEditView();
1164 0 : if (!mpEditView && bCreate)
1165 : {
1166 0 : if ( !pTxtWnd->IsInputActive() )
1167 : {
1168 0 : pTxtWnd->StartEditEngine();
1169 0 : pTxtWnd->GrabFocus();
1170 :
1171 0 : mpEditView = pTxtWnd->GetEditView();
1172 : }
1173 : }
1174 : }
1175 :
1176 0 : return ScAccessibleEditObjectTextData::GetEditViewForwarder(bCreate);
1177 : }
1178 :
1179 0 : void ScAccessibleEditLineTextData::ResetEditMode()
1180 : {
1181 0 : ScTextWnd* pTxtWnd = dynamic_cast<ScTextWnd*>(mpWindow.get());
1182 :
1183 0 : if (mbEditEngineCreated && mpEditEngine)
1184 0 : delete mpEditEngine;
1185 0 : else if (pTxtWnd && pTxtWnd->GetEditView() && pTxtWnd->GetEditView()->GetEditEngine())
1186 0 : pTxtWnd->GetEditView()->GetEditEngine()->SetNotifyHdl(Link<>());
1187 0 : mpEditEngine = NULL;
1188 :
1189 0 : DELETEZ(mpForwarder);
1190 0 : DELETEZ(mpEditViewForwarder);
1191 0 : DELETEZ(mpViewForwarder);
1192 0 : mbEditEngineCreated = false;
1193 0 : }
1194 :
1195 0 : void ScAccessibleEditLineTextData::TextChanged()
1196 : {
1197 0 : if (mbEditEngineCreated && mpEditEngine)
1198 : {
1199 0 : ScTextWnd* pTxtWnd = dynamic_cast<ScTextWnd*>(mpWindow.get());
1200 :
1201 0 : if (pTxtWnd)
1202 0 : mpEditEngine->SetText(pTxtWnd->GetTextString());
1203 : }
1204 0 : }
1205 :
1206 0 : void ScAccessibleEditLineTextData::StartEdit()
1207 : {
1208 0 : ResetEditMode();
1209 0 : mpEditView = NULL;
1210 :
1211 : // send HINT_BEGEDIT
1212 0 : SdrHint aHint(HINT_BEGEDIT);
1213 0 : GetBroadcaster().Broadcast( aHint );
1214 0 : }
1215 :
1216 0 : void ScAccessibleEditLineTextData::EndEdit()
1217 : {
1218 : // send HINT_ENDEDIT
1219 0 : SdrHint aHint(HINT_ENDEDIT);
1220 0 : GetBroadcaster().Broadcast( aHint );
1221 :
1222 0 : ResetEditMode();
1223 0 : mpEditView = NULL;
1224 0 : }
1225 :
1226 : // ScAccessiblePreviewCellTextData: shared data between sub objects of a accessible cell text object
1227 :
1228 9 : ScAccessiblePreviewCellTextData::ScAccessiblePreviewCellTextData(ScPreviewShell* pViewShell,
1229 : const ScAddress& rP)
1230 : : ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP),
1231 : mpViewForwarder(NULL),
1232 9 : mpViewShell(pViewShell)
1233 : {
1234 9 : }
1235 :
1236 27 : ScAccessiblePreviewCellTextData::~ScAccessiblePreviewCellTextData()
1237 : {
1238 9 : if (pEditEngine)
1239 9 : pEditEngine->SetNotifyHdl(Link<>());
1240 9 : if (mpViewForwarder)
1241 7 : delete mpViewForwarder;
1242 18 : }
1243 :
1244 0 : void ScAccessiblePreviewCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1245 : {
1246 0 : const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
1247 0 : if ( pSimpleHint )
1248 : {
1249 0 : sal_uLong nId = pSimpleHint->GetId();
1250 0 : if ( nId == SFX_HINT_DYING )
1251 : {
1252 0 : mpViewShell = NULL; // invalid now
1253 0 : if (mpViewForwarder)
1254 0 : mpViewForwarder->SetInvalid();
1255 : }
1256 : }
1257 0 : ScAccessibleCellBaseTextData::Notify(rBC, rHint);
1258 0 : }
1259 :
1260 2 : ScAccessibleTextData* ScAccessiblePreviewCellTextData::Clone() const
1261 : {
1262 2 : return new ScAccessiblePreviewCellTextData(mpViewShell, aCellPos);
1263 : }
1264 :
1265 315 : SvxTextForwarder* ScAccessiblePreviewCellTextData::GetTextForwarder()
1266 : {
1267 315 : bool bEditEngineBefore(pEditEngine != NULL);
1268 :
1269 315 : ScCellTextData::GetTextForwarder(); // creates Forwarder and EditEngine
1270 :
1271 315 : if (!bEditEngineBefore && pEditEngine)
1272 : {
1273 9 : Size aSize(mpViewShell->GetLocationData().GetCellOutputRect(aCellPos).GetSize());
1274 9 : vcl::Window* pWin = mpViewShell->GetWindow();
1275 9 : if (pWin)
1276 9 : aSize = pWin->PixelToLogic(aSize, pEditEngine->GetRefMapMode());
1277 9 : pEditEngine->SetPaperSize(aSize);
1278 : }
1279 :
1280 315 : if (pEditEngine)
1281 315 : pEditEngine->SetNotifyHdl( LINK(this, ScAccessiblePreviewCellTextData, NotifyHdl) );
1282 :
1283 315 : return pForwarder;
1284 : }
1285 :
1286 77 : SvxViewForwarder* ScAccessiblePreviewCellTextData::GetViewForwarder()
1287 : {
1288 77 : if (!mpViewForwarder)
1289 7 : mpViewForwarder = new ScPreviewCellViewForwarder(mpViewShell, aCellPos);
1290 77 : return mpViewForwarder;
1291 : }
1292 :
1293 9 : ScDocShell* ScAccessiblePreviewCellTextData::GetDocShell(ScPreviewShell* pViewShell)
1294 : {
1295 9 : ScDocShell* pDocSh = NULL;
1296 9 : if (pViewShell)
1297 9 : pDocSh = static_cast<ScDocShell*>( pViewShell->GetDocument().GetDocumentShell());
1298 9 : return pDocSh;
1299 : }
1300 :
1301 : // ScAccessiblePreviewHeaderCellTextData: shared data between sub objects of a accessible cell text object
1302 :
1303 8 : ScAccessiblePreviewHeaderCellTextData::ScAccessiblePreviewHeaderCellTextData(ScPreviewShell* pViewShell,
1304 : const OUString& rText, const ScAddress& rP, bool bColHeader, bool bRowHeader)
1305 : : ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP),
1306 : mpViewForwarder(NULL),
1307 : mpViewShell(pViewShell),
1308 : maText(rText),
1309 : mbColHeader(bColHeader),
1310 8 : mbRowHeader(bRowHeader)
1311 : {
1312 8 : }
1313 :
1314 0 : ScAccessiblePreviewHeaderCellTextData::~ScAccessiblePreviewHeaderCellTextData()
1315 : {
1316 0 : if (pEditEngine)
1317 0 : pEditEngine->SetNotifyHdl(Link<>());
1318 0 : if (mpViewForwarder)
1319 0 : delete mpViewForwarder;
1320 0 : }
1321 :
1322 8 : void ScAccessiblePreviewHeaderCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1323 : {
1324 8 : const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
1325 8 : if ( pSimpleHint )
1326 : {
1327 8 : sal_uLong nId = pSimpleHint->GetId();
1328 8 : if ( nId == SFX_HINT_DYING )
1329 : {
1330 8 : mpViewShell = NULL; // invalid now
1331 8 : if (mpViewForwarder)
1332 8 : mpViewForwarder->SetInvalid();
1333 : }
1334 : }
1335 8 : ScAccessibleCellBaseTextData::Notify(rBC, rHint);
1336 8 : }
1337 :
1338 0 : ScAccessibleTextData* ScAccessiblePreviewHeaderCellTextData::Clone() const
1339 : {
1340 0 : return new ScAccessiblePreviewHeaderCellTextData(mpViewShell, maText, aCellPos, mbColHeader, mbRowHeader);
1341 : }
1342 :
1343 85 : SvxTextForwarder* ScAccessiblePreviewHeaderCellTextData::GetTextForwarder()
1344 : {
1345 85 : if (!pEditEngine)
1346 : {
1347 8 : if ( pDocShell )
1348 : {
1349 8 : ScDocument& rDoc = pDocShell->GetDocument();
1350 8 : pEditEngine = rDoc.CreateFieldEditEngine();
1351 : }
1352 : else
1353 : {
1354 0 : SfxItemPool* pEnginePool = EditEngine::CreatePool();
1355 0 : pEnginePool->FreezeIdRanges();
1356 0 : pEditEngine = new ScFieldEditEngine(NULL, pEnginePool, NULL, true);
1357 : }
1358 8 : pEditEngine->EnableUndo( false );
1359 8 : if (pDocShell)
1360 8 : pEditEngine->SetRefDevice(pDocShell->GetRefDevice());
1361 : else
1362 0 : pEditEngine->SetRefMapMode( MAP_100TH_MM );
1363 8 : pForwarder = new SvxEditEngineForwarder(*pEditEngine);
1364 : }
1365 :
1366 85 : if (bDataValid)
1367 77 : return pForwarder;
1368 :
1369 8 : if (!maText.isEmpty())
1370 : {
1371 4 : if ( mpViewShell )
1372 : {
1373 4 : Size aOutputSize;
1374 4 : vcl::Window* pWindow = mpViewShell->GetWindow();
1375 4 : if ( pWindow )
1376 4 : aOutputSize = pWindow->GetOutputSizePixel();
1377 4 : Point aPoint;
1378 4 : Rectangle aVisRect( aPoint, aOutputSize );
1379 4 : Size aSize(mpViewShell->GetLocationData().GetHeaderCellOutputRect(aVisRect, aCellPos, mbColHeader).GetSize());
1380 4 : if (pWindow)
1381 4 : aSize = pWindow->PixelToLogic(aSize, pEditEngine->GetRefMapMode());
1382 4 : pEditEngine->SetPaperSize(aSize);
1383 : }
1384 4 : pEditEngine->SetText( maText );
1385 : }
1386 :
1387 8 : bDataValid = true;
1388 :
1389 8 : pEditEngine->SetNotifyHdl( LINK(this, ScAccessiblePreviewHeaderCellTextData, NotifyHdl) );
1390 :
1391 8 : return pForwarder;
1392 : }
1393 :
1394 22 : SvxViewForwarder* ScAccessiblePreviewHeaderCellTextData::GetViewForwarder()
1395 : {
1396 22 : if (!mpViewForwarder)
1397 8 : mpViewForwarder = new ScPreviewHeaderCellViewForwarder(mpViewShell, aCellPos, mbColHeader);
1398 22 : return mpViewForwarder;
1399 : }
1400 :
1401 8 : ScDocShell* ScAccessiblePreviewHeaderCellTextData::GetDocShell(ScPreviewShell* pViewShell)
1402 : {
1403 8 : ScDocShell* pDocSh = NULL;
1404 8 : if (pViewShell)
1405 8 : pDocSh = static_cast<ScDocShell*>(pViewShell->GetDocument().GetDocumentShell());
1406 8 : return pDocSh;
1407 : }
1408 :
1409 10 : ScAccessibleHeaderTextData::ScAccessibleHeaderTextData(ScPreviewShell* pViewShell,
1410 : const EditTextObject* pEditObj, bool bHeader, SvxAdjust eAdjust)
1411 : :
1412 : mpViewForwarder(NULL),
1413 : mpViewShell(pViewShell),
1414 : mpEditEngine(NULL),
1415 : mpForwarder(NULL),
1416 : mpDocSh(NULL),
1417 : mpEditObj(pEditObj),
1418 : mbHeader(bHeader),
1419 : mbDataValid(false),
1420 10 : meAdjust(eAdjust)
1421 : {
1422 10 : if (pViewShell)
1423 10 : mpDocSh = static_cast<ScDocShell*>(pViewShell->GetDocument().GetDocumentShell());
1424 10 : if (mpDocSh)
1425 10 : mpDocSh->GetDocument().AddUnoObject(*this);
1426 10 : }
1427 :
1428 30 : ScAccessibleHeaderTextData::~ScAccessibleHeaderTextData()
1429 : {
1430 10 : SolarMutexGuard aGuard; // needed for EditEngine dtor
1431 :
1432 10 : if (mpDocSh)
1433 10 : mpDocSh->GetDocument().RemoveUnoObject(*this);
1434 10 : if (mpEditEngine)
1435 10 : mpEditEngine->SetNotifyHdl(Link<>());
1436 10 : delete mpEditEngine;
1437 10 : delete mpForwarder;
1438 20 : }
1439 :
1440 0 : ScAccessibleTextData* ScAccessibleHeaderTextData::Clone() const
1441 : {
1442 0 : return new ScAccessibleHeaderTextData(mpViewShell, mpEditObj, mbHeader, meAdjust);
1443 : }
1444 :
1445 2 : void ScAccessibleHeaderTextData::Notify( SfxBroadcaster&, const SfxHint& rHint )
1446 : {
1447 2 : const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
1448 2 : if ( pSimpleHint )
1449 : {
1450 2 : sal_uLong nId = pSimpleHint->GetId();
1451 2 : if ( nId == SFX_HINT_DYING )
1452 : {
1453 0 : mpViewShell = NULL;// invalid now
1454 0 : mpDocSh = NULL;
1455 0 : if (mpViewForwarder)
1456 0 : mpViewForwarder->SetInvalid();
1457 : }
1458 : }
1459 2 : }
1460 :
1461 109 : SvxTextForwarder* ScAccessibleHeaderTextData::GetTextForwarder()
1462 : {
1463 109 : if (!mpEditEngine)
1464 : {
1465 10 : SfxItemPool* pEnginePool = EditEngine::CreatePool();
1466 10 : pEnginePool->FreezeIdRanges();
1467 10 : ScHeaderEditEngine* pHdrEngine = new ScHeaderEditEngine( pEnginePool, true );
1468 :
1469 10 : pHdrEngine->EnableUndo( false );
1470 10 : pHdrEngine->SetRefMapMode( MAP_TWIP );
1471 :
1472 : // default font must be set, independently of document
1473 : // -> use global pool from module
1474 :
1475 10 : SfxItemSet aDefaults( pHdrEngine->GetEmptyItemSet() );
1476 10 : const ScPatternAttr& rPattern = static_cast<const ScPatternAttr&>(SC_MOD()->GetPool().GetDefaultItem(ATTR_PATTERN));
1477 10 : rPattern.FillEditItemSet( &aDefaults );
1478 : // FillEditItemSet adjusts font height to 1/100th mm,
1479 : // but for header/footer twips is needed, as in the PatternAttr:
1480 10 : aDefaults.Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
1481 10 : aDefaults.Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
1482 10 : aDefaults.Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
1483 10 : aDefaults.Put( SvxAdjustItem( meAdjust, EE_PARA_JUST ) );
1484 10 : pHdrEngine->SetDefaults( aDefaults );
1485 :
1486 20 : ScHeaderFieldData aData;
1487 10 : if (mpViewShell)
1488 10 : mpViewShell->FillFieldData(aData);
1489 : else
1490 0 : ScHeaderFooterTextObj::FillDummyFieldData( aData );
1491 10 : pHdrEngine->SetData( aData );
1492 :
1493 10 : mpEditEngine = pHdrEngine;
1494 20 : mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
1495 : }
1496 :
1497 109 : if (mbDataValid)
1498 99 : return mpForwarder;
1499 :
1500 10 : if ( mpViewShell )
1501 : {
1502 10 : Rectangle aVisRect;
1503 10 : mpViewShell->GetLocationData().GetHeaderPosition(aVisRect);
1504 10 : Size aSize(aVisRect.GetSize());
1505 10 : vcl::Window* pWin = mpViewShell->GetWindow();
1506 10 : if (pWin)
1507 10 : aSize = pWin->PixelToLogic(aSize, mpEditEngine->GetRefMapMode());
1508 10 : mpEditEngine->SetPaperSize(aSize);
1509 : }
1510 10 : if (mpEditObj)
1511 10 : mpEditEngine->SetText(*mpEditObj);
1512 :
1513 10 : mbDataValid = true;
1514 10 : return mpForwarder;
1515 : }
1516 :
1517 40 : SvxViewForwarder* ScAccessibleHeaderTextData::GetViewForwarder()
1518 : {
1519 40 : if (!mpViewForwarder)
1520 10 : mpViewForwarder = new ScPreviewHeaderFooterViewForwarder(mpViewShell, mbHeader);
1521 40 : return mpViewForwarder;
1522 : }
1523 :
1524 0 : ScAccessibleNoteTextData::ScAccessibleNoteTextData(ScPreviewShell* pViewShell,
1525 : const OUString& sText, const ScAddress& aCellPos, bool bMarkNote)
1526 : :
1527 : mpViewForwarder(NULL),
1528 : mpViewShell(pViewShell),
1529 : mpEditEngine(NULL),
1530 : mpForwarder(NULL),
1531 : mpDocSh(NULL),
1532 : msText(sText),
1533 : maCellPos(aCellPos),
1534 : mbMarkNote(bMarkNote),
1535 0 : mbDataValid(false)
1536 : {
1537 0 : if (pViewShell)
1538 0 : mpDocSh = static_cast<ScDocShell*>(pViewShell->GetDocument().GetDocumentShell());
1539 0 : if (mpDocSh)
1540 0 : mpDocSh->GetDocument().AddUnoObject(*this);
1541 0 : }
1542 :
1543 0 : ScAccessibleNoteTextData::~ScAccessibleNoteTextData()
1544 : {
1545 0 : SolarMutexGuard aGuard; // needed for EditEngine dtor
1546 :
1547 0 : if (mpDocSh)
1548 0 : mpDocSh->GetDocument().RemoveUnoObject(*this);
1549 0 : if (mpEditEngine)
1550 0 : mpEditEngine->SetNotifyHdl(Link<>());
1551 0 : delete mpEditEngine;
1552 0 : delete mpForwarder;
1553 0 : }
1554 :
1555 0 : ScAccessibleTextData* ScAccessibleNoteTextData::Clone() const
1556 : {
1557 0 : return new ScAccessibleNoteTextData(mpViewShell, msText, maCellPos, mbMarkNote);
1558 : }
1559 :
1560 0 : void ScAccessibleNoteTextData::Notify( SfxBroadcaster&, const SfxHint& rHint )
1561 : {
1562 0 : const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
1563 0 : if ( pSimpleHint )
1564 : {
1565 0 : sal_uLong nId = pSimpleHint->GetId();
1566 0 : if ( nId == SFX_HINT_DYING )
1567 : {
1568 0 : mpViewShell = NULL;// invalid now
1569 0 : mpDocSh = NULL;
1570 0 : if (mpViewForwarder)
1571 0 : mpViewForwarder->SetInvalid();
1572 : }
1573 : }
1574 0 : }
1575 :
1576 0 : SvxTextForwarder* ScAccessibleNoteTextData::GetTextForwarder()
1577 : {
1578 0 : if (!mpEditEngine)
1579 : {
1580 0 : if ( mpDocSh )
1581 : {
1582 0 : ScDocument& rDoc = mpDocSh->GetDocument();
1583 0 : mpEditEngine = rDoc.CreateFieldEditEngine();
1584 : }
1585 : else
1586 : {
1587 0 : SfxItemPool* pEnginePool = EditEngine::CreatePool();
1588 0 : pEnginePool->FreezeIdRanges();
1589 0 : mpEditEngine = new ScFieldEditEngine(NULL, pEnginePool, NULL, true);
1590 : }
1591 0 : mpEditEngine->EnableUndo( false );
1592 0 : if (mpDocSh)
1593 0 : mpEditEngine->SetRefDevice(mpDocSh->GetRefDevice());
1594 : else
1595 0 : mpEditEngine->SetRefMapMode( MAP_100TH_MM );
1596 0 : mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
1597 : }
1598 :
1599 0 : if (mbDataValid)
1600 0 : return mpForwarder;
1601 :
1602 0 : if (!msText.isEmpty())
1603 : {
1604 :
1605 0 : if ( mpViewShell )
1606 : {
1607 0 : Size aOutputSize;
1608 0 : vcl::Window* pWindow = mpViewShell->GetWindow();
1609 0 : if ( pWindow )
1610 0 : aOutputSize = pWindow->GetOutputSizePixel();
1611 0 : Point aPoint;
1612 0 : Rectangle aVisRect( aPoint, aOutputSize );
1613 0 : Size aSize(mpViewShell->GetLocationData().GetNoteInRangeOutputRect(aVisRect, mbMarkNote, maCellPos).GetSize());
1614 0 : if (pWindow)
1615 0 : aSize = pWindow->PixelToLogic(aSize, mpEditEngine->GetRefMapMode());
1616 0 : mpEditEngine->SetPaperSize(aSize);
1617 : }
1618 0 : mpEditEngine->SetText( msText );
1619 : }
1620 :
1621 0 : mbDataValid = true;
1622 :
1623 0 : mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleNoteTextData, NotifyHdl) );
1624 :
1625 0 : return mpForwarder;
1626 : }
1627 :
1628 0 : SvxViewForwarder* ScAccessibleNoteTextData::GetViewForwarder()
1629 : {
1630 0 : if (!mpViewForwarder)
1631 0 : mpViewForwarder = new ScPreviewNoteViewForwarder(mpViewShell, maCellPos, mbMarkNote);
1632 0 : return mpViewForwarder;
1633 : }
1634 :
1635 : // CSV import =================================================================
1636 :
1637 0 : class ScCsvViewForwarder : public SvxViewForwarder
1638 : {
1639 : Rectangle maBoundBox;
1640 : VclPtr<vcl::Window> mpWindow;
1641 :
1642 : public:
1643 : explicit ScCsvViewForwarder( vcl::Window* pWindow, const Rectangle& rBoundBox );
1644 :
1645 : virtual bool IsValid() const SAL_OVERRIDE;
1646 : virtual Rectangle GetVisArea() const SAL_OVERRIDE;
1647 : virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const SAL_OVERRIDE;
1648 : virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const SAL_OVERRIDE;
1649 :
1650 : void SetInvalid();
1651 : };
1652 :
1653 0 : ScCsvViewForwarder::ScCsvViewForwarder( vcl::Window* pWindow, const Rectangle& rBoundBox ) :
1654 : maBoundBox( rBoundBox ),
1655 0 : mpWindow( pWindow )
1656 : {
1657 0 : }
1658 :
1659 0 : bool ScCsvViewForwarder::IsValid() const
1660 : {
1661 0 : return mpWindow != nullptr;
1662 : }
1663 :
1664 0 : Rectangle ScCsvViewForwarder::GetVisArea() const
1665 : {
1666 0 : return maBoundBox;
1667 : }
1668 :
1669 0 : Point ScCsvViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
1670 : {
1671 0 : if( !mpWindow ) return Point();
1672 0 : return mpWindow->LogicToPixel( rPoint, rMapMode );
1673 : }
1674 :
1675 0 : Point ScCsvViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
1676 : {
1677 0 : if( !mpWindow ) return Point();
1678 0 : return mpWindow->PixelToLogic( rPoint, rMapMode );
1679 : }
1680 :
1681 0 : void ScCsvViewForwarder::SetInvalid()
1682 : {
1683 0 : mpWindow = NULL;
1684 0 : }
1685 :
1686 0 : ScAccessibleCsvTextData::ScAccessibleCsvTextData(
1687 : vcl::Window* pWindow, EditEngine* pEditEngine,
1688 : const OUString& rCellText, const Rectangle& rBoundBox, const Size& rCellSize ) :
1689 : mpWindow( pWindow ),
1690 : mpEditEngine( pEditEngine ),
1691 : maCellText( rCellText ),
1692 : maBoundBox( rBoundBox ),
1693 0 : maCellSize( rCellSize )
1694 : {
1695 0 : }
1696 :
1697 0 : ScAccessibleCsvTextData::~ScAccessibleCsvTextData()
1698 : {
1699 0 : }
1700 :
1701 0 : void ScAccessibleCsvTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1702 : {
1703 0 : const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
1704 0 : if ( pSimpleHint )
1705 : {
1706 0 : sal_uLong nId = pSimpleHint->GetId();
1707 0 : if( nId == SFX_HINT_DYING )
1708 : {
1709 0 : mpWindow = NULL;
1710 0 : mpEditEngine = NULL;
1711 0 : if (mpViewForwarder.get())
1712 0 : mpViewForwarder->SetInvalid();
1713 : }
1714 : }
1715 0 : ScAccessibleTextData::Notify( rBC, rHint );
1716 0 : }
1717 :
1718 0 : ScAccessibleTextData* ScAccessibleCsvTextData::Clone() const
1719 : {
1720 0 : return new ScAccessibleCsvTextData( mpWindow, mpEditEngine, maCellText, maBoundBox, maCellSize );
1721 : }
1722 :
1723 0 : SvxTextForwarder* ScAccessibleCsvTextData::GetTextForwarder()
1724 : {
1725 0 : if( mpEditEngine )
1726 : {
1727 0 : mpEditEngine->SetPaperSize( maCellSize );
1728 0 : mpEditEngine->SetText( maCellText );
1729 0 : if( !mpTextForwarder.get() )
1730 0 : mpTextForwarder.reset( new SvxEditEngineForwarder( *mpEditEngine ) );
1731 : }
1732 : else
1733 0 : mpTextForwarder.reset();
1734 0 : return mpTextForwarder.get();
1735 : }
1736 :
1737 0 : SvxViewForwarder* ScAccessibleCsvTextData::GetViewForwarder()
1738 : {
1739 0 : if( !mpViewForwarder.get() )
1740 0 : mpViewForwarder.reset( new ScCsvViewForwarder( mpWindow, maBoundBox ) );
1741 0 : return mpViewForwarder.get();
1742 : }
1743 :
1744 0 : SvxEditViewForwarder* ScAccessibleCsvTextData::GetEditViewForwarder( bool /* bCreate */ )
1745 : {
1746 0 : return NULL;
1747 156 : }
1748 :
1749 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|