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