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 
73 ScViewForwarder::ScViewForwarder(ScTabViewShell* pViewShell, ScSplitPos eSplitPos, const ScAddress& rCell)
74 	:
75 	mpViewShell(pViewShell),
76 	maCellPos(rCell),
77 	meSplitPos(eSplitPos)
78 {
79 }
80 
81 ScViewForwarder::~ScViewForwarder()
82 {
83 }
84 
85 sal_Bool ScViewForwarder::IsValid() const
86 {
87 	return mpViewShell != NULL;
88 }
89 
90 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 
118 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 
133 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 
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#
178 ScEditObjectViewForwarder::ScEditObjectViewForwarder( Window* pWindow,
179                                                       const EditView* _pEditView )
180 	:
181     mpWindow(pWindow),
182     mpEditView( _pEditView )
183 {
184 }
185 // <--
186 
187 ScEditObjectViewForwarder::~ScEditObjectViewForwarder()
188 {
189 }
190 
191 sal_Bool ScEditObjectViewForwarder::IsValid() const
192 {
193 	return (mpWindow != NULL);
194 }
195 
196 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 
214 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 
236 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 
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 
287 ScPreviewViewForwarder::ScPreviewViewForwarder(ScPreviewShell* pViewShell)
288 	:
289 	mpViewShell(pViewShell),
290 	mpTableInfo(NULL)
291 {
292 }
293 
294 ScPreviewViewForwarder::~ScPreviewViewForwarder()
295 {
296 	delete mpTableInfo;
297 }
298 
299 sal_Bool ScPreviewViewForwarder::IsValid() const
300 {
301 	return mpViewShell != NULL;
302 }
303 
304 Rectangle ScPreviewViewForwarder::GetVisArea() const
305 {
306 	Rectangle aVisArea;
307 	DBG_ERROR("should be implemented in an abrevated class");
308 	return aVisArea;
309 }
310 
311 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 
330 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 
353 void ScPreviewViewForwarder::SetInvalid()
354 {
355     mpViewShell = NULL;
356 }
357 
358 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 
373 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 
410 ScPreviewHeaderFooterViewForwarder::ScPreviewHeaderFooterViewForwarder(ScPreviewShell* pViewShell, sal_Bool bHeader)
411 	:
412 	ScPreviewViewForwarder(pViewShell),
413     mbHeader(bHeader)
414 {
415 }
416 
417 ScPreviewHeaderFooterViewForwarder::~ScPreviewHeaderFooterViewForwarder()
418 {
419 }
420 
421 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 
454 ScPreviewCellViewForwarder::ScPreviewCellViewForwarder(ScPreviewShell* pViewShell,
455                                                        ScAddress aCellPos)
456 	:
457 	ScPreviewViewForwarder(pViewShell),
458     maCellPos(aCellPos)
459 {
460 }
461 
462 ScPreviewCellViewForwarder::~ScPreviewCellViewForwarder()
463 {
464 }
465 
466 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 
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 
510 ScPreviewHeaderCellViewForwarder::~ScPreviewHeaderCellViewForwarder()
511 {
512 }
513 
514 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 
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 
556 ScPreviewNoteViewForwarder::~ScPreviewNoteViewForwarder()
557 {
558 }
559 
560 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 
602 ScEditViewForwarder::ScEditViewForwarder(EditView* pEditView, Window* pWin)
603 	: mpEditView(pEditView),
604     mpWindow(pWin)
605 {
606 	GrabFocus();
607 }
608 
609 ScEditViewForwarder::~ScEditViewForwarder()
610 {
611 }
612 
613 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 
623 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 
639 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 
650 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 
661 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 
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 
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 
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 
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 
736 void ScEditViewForwarder::GrabFocus()
737 {
738 }
739 
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 
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 
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 
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 
789 ScAccessibleTextData* ScAccessibleCellTextData::Clone() const
790 {
791     return new ScAccessibleCellTextData( mpViewShell, aCellPos, meSplitPos, mpAccessibleCell );
792 }
793 
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 
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 
1013 SvxViewForwarder* ScAccessibleCellTextData::GetViewForwarder()
1014 {
1015 	if (!mpViewForwarder)
1016 		mpViewForwarder = new ScViewForwarder(mpViewShell, meSplitPos, aCellPos);
1017 	return mpViewForwarder;
1018 }
1019 
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 
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 
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 // ============================================================================
1061 //ScAccessibleEditObjectTextData::ScAccessibleEditObjectTextData(EditView* pEditView, Window* pWin)
1062 ScAccessibleEditObjectTextData::ScAccessibleEditObjectTextData(EditView* pEditView, Window* pWin, sal_Bool isClone)
1063 	:
1064 	mpViewForwarder(NULL),
1065 	mpEditViewForwarder(NULL),
1066     mpEditView(pEditView),
1067     mpEditEngine(pEditView ? pEditView->GetEditEngine() : 0),
1068     mpForwarder(NULL),
1069     mpWindow(pWin)
1070 {
1071 	// Solution: If the object is cloned, do NOT add notify hdl.
1072 	mbIsCloned = isClone;
1073     //if (mpEditEngine)
1074     if (mpEditEngine && !mbIsCloned)
1075         mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData, NotifyHdl) );
1076 }
1077 
1078 ScAccessibleEditObjectTextData::~ScAccessibleEditObjectTextData()
1079 {
1080 	// Solution: If the object is cloned, do NOT set notify hdl.
1081     //if (mpEditEngine)
1082     if (mpEditEngine && !mbIsCloned)
1083         mpEditEngine->SetNotifyHdl(Link());
1084 	if (mpViewForwarder)
1085 		delete mpViewForwarder;
1086 	if (mpEditViewForwarder)
1087 		delete mpEditViewForwarder;
1088     if (mpForwarder)
1089         delete mpForwarder;
1090 }
1091 
1092 void ScAccessibleEditObjectTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1093 {
1094 	if ( rHint.ISA( SfxSimpleHint ) )
1095 	{
1096 		sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1097 		if ( nId == SFX_HINT_DYING )
1098 		{
1099             mpWindow = NULL;
1100             mpEditView = NULL;
1101             mpEditEngine = NULL;
1102             DELETEZ(mpForwarder);
1103         	if (mpViewForwarder)
1104             	mpViewForwarder->SetInvalid();
1105 	        if (mpEditViewForwarder)
1106             	mpEditViewForwarder->SetInvalid();
1107 		}
1108 	}
1109 	ScAccessibleTextData::Notify(rBC, rHint);
1110 }
1111 
1112 ScAccessibleTextData* ScAccessibleEditObjectTextData::Clone() const
1113 {
1114 	// Solution: Add para to indicate the object is cloned
1115 	//return new ScAccessibleEditObjectTextData(mpEditView, mpWindow);
1116 	return new ScAccessibleEditObjectTextData(mpEditView, mpWindow,sal_True);
1117 }
1118 
1119 SvxTextForwarder* ScAccessibleEditObjectTextData::GetTextForwarder()
1120 {
1121 	if ((!mpForwarder && mpEditView) || (mpEditEngine && !mpEditEngine->GetNotifyHdl().IsSet()))
1122 	{
1123         if (!mpEditEngine)
1124             mpEditEngine = mpEditView->GetEditEngine();
1125 			// Solution: If the object is cloned, do NOT add notify hdl.
1126         //if (mpEditEngine && !mpEditEngine->GetNotifyHdl().IsSet())
1127 	if (mpEditEngine && !mpEditEngine->GetNotifyHdl().IsSet()&&!mbIsCloned)
1128             mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData, NotifyHdl) );
1129         if(!mpForwarder)
1130             mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
1131 	}
1132 	return mpForwarder;
1133 }
1134 
1135 SvxViewForwarder* ScAccessibleEditObjectTextData::GetViewForwarder()
1136 {
1137 	if (!mpViewForwarder)
1138     {
1139         // --> OD 2005-12-21 #i49561#
1140         mpViewForwarder = new ScEditObjectViewForwarder( mpWindow, mpEditView );
1141         // <--
1142     }
1143 	return mpViewForwarder;
1144 }
1145 
1146 SvxEditViewForwarder* ScAccessibleEditObjectTextData::GetEditViewForwarder( sal_Bool bCreate )
1147 {
1148     if (!mpEditViewForwarder && mpEditView)
1149 		mpEditViewForwarder = new ScEditViewForwarder(mpEditView, mpWindow);
1150 	if (bCreate)
1151 	{
1152         if (!mpEditView && mpEditViewForwarder)
1153         {
1154             DELETEZ(mpEditViewForwarder);
1155         }
1156 		else if (mpEditViewForwarder)
1157 			mpEditViewForwarder->GrabFocus();
1158 	}
1159 	return mpEditViewForwarder;
1160 }
1161 
1162 IMPL_LINK(ScAccessibleEditObjectTextData, NotifyHdl, EENotify*, aNotify)
1163 {
1164     if( aNotify )
1165     {
1166         ::std::auto_ptr< SfxHint > aHint = SvxEditSourceHelper::EENotification2Hint( aNotify );
1167 
1168         if( aHint.get() )
1169             GetBroadcaster().Broadcast( *aHint.get() );
1170     }
1171 
1172     return 0;
1173 }
1174 
1175 
1176 // ============================================================================
1177 
1178 ScAccessibleEditLineTextData::ScAccessibleEditLineTextData(EditView* pEditView, Window* pWin)
1179     :
1180     ScAccessibleEditObjectTextData(pEditView, pWin),
1181     mbEditEngineCreated(sal_False)
1182 {
1183     ScTextWnd* pTxtWnd = (ScTextWnd*)pWin;
1184 
1185     if (pTxtWnd)
1186         pTxtWnd->InsertAccessibleTextData( *this );
1187 }
1188 
1189 ScAccessibleEditLineTextData::~ScAccessibleEditLineTextData()
1190 {
1191     ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
1192 
1193     if (pTxtWnd)
1194         pTxtWnd->RemoveAccessibleTextData( *this );
1195 
1196     if (mbEditEngineCreated && mpEditEngine)
1197     {
1198         delete mpEditEngine;
1199         mpEditEngine = NULL;    // #103346# don't access in ScAccessibleEditObjectTextData dtor!
1200     }
1201     else if (pTxtWnd && pTxtWnd->GetEditView() && pTxtWnd->GetEditView()->GetEditEngine())
1202     {
1203         //  #103346# the NotifyHdl also has to be removed from the ScTextWnd's EditEngine
1204         //  (it's set in ScAccessibleEditLineTextData::GetTextForwarder, and mpEditEngine
1205         //  is reset there)
1206         pTxtWnd->GetEditView()->GetEditEngine()->SetNotifyHdl(Link());
1207     }
1208 }
1209 
1210 void ScAccessibleEditLineTextData::Dispose()
1211 {
1212     ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
1213 
1214     if (pTxtWnd)
1215         pTxtWnd->RemoveAccessibleTextData( *this );
1216 
1217     ResetEditMode();
1218     mpWindow = NULL;
1219 }
1220 
1221 ScAccessibleTextData* ScAccessibleEditLineTextData::Clone() const
1222 {
1223     return new ScAccessibleEditLineTextData(mpEditView, mpWindow);
1224 }
1225 
1226 SvxTextForwarder* ScAccessibleEditLineTextData::GetTextForwarder()
1227 {
1228     ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
1229 
1230     if (pTxtWnd)
1231     {
1232         mpEditView = pTxtWnd->GetEditView();
1233         if (mpEditView)
1234         {
1235             if (mbEditEngineCreated && mpEditEngine)
1236                 ResetEditMode();
1237             mbEditEngineCreated = sal_False;
1238 
1239             mpEditView = pTxtWnd->GetEditView();
1240             ScAccessibleEditObjectTextData::GetTextForwarder(); // fill the mpForwarder
1241             mpEditEngine = NULL;
1242         }
1243         else
1244         {
1245             if (mpEditEngine && !mbEditEngineCreated)
1246                 ResetEditMode();
1247 	        if (!mpEditEngine)
1248 	        {
1249 			    SfxItemPool* pEnginePool = EditEngine::CreatePool();
1250 			    pEnginePool->FreezeIdRanges();
1251 			    mpEditEngine = new ScFieldEditEngine( pEnginePool, NULL, sal_True );
1252                 mbEditEngineCreated = sal_True;
1253 		        //	currently, GetPortions doesn't work if UpdateMode is sal_False,
1254 		        //	this will be fixed (in EditEngine) by src600
1255         //		pEditEngine->SetUpdateMode( sal_False );
1256 		        mpEditEngine->EnableUndo( sal_False );
1257 			    mpEditEngine->SetRefMapMode( MAP_100TH_MM );
1258 		        mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
1259 
1260                 mpEditEngine->SetText(pTxtWnd->GetTextString());
1261 
1262 		        Size aSize(pTxtWnd->GetSizePixel());
1263 
1264 			    aSize = pTxtWnd->PixelToLogic(aSize, mpEditEngine->GetRefMapMode());
1265 
1266 		        mpEditEngine->SetPaperSize(aSize);
1267 
1268 		        mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData, NotifyHdl) );
1269             }
1270         }
1271     }
1272     return mpForwarder;
1273 }
1274 
1275 SvxEditViewForwarder* ScAccessibleEditLineTextData::GetEditViewForwarder( sal_Bool bCreate )
1276 {
1277     ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
1278 
1279     if (pTxtWnd)
1280     {
1281         mpEditView = pTxtWnd->GetEditView();
1282         if (!mpEditView && bCreate)
1283         {
1284 	        if ( !pTxtWnd->IsInputActive() )
1285 	        {
1286 		        pTxtWnd->StartEditEngine();
1287 		        pTxtWnd->GrabFocus();
1288 //		        pTxtWnd->SetTextString( rText );
1289 //		        pTxtWnd->GetEditView()->SetSelection( rSel );
1290 
1291                 mpEditView = pTxtWnd->GetEditView();
1292 	        }
1293         }
1294     }
1295 
1296     return ScAccessibleEditObjectTextData::GetEditViewForwarder(bCreate);
1297 }
1298 
1299 void ScAccessibleEditLineTextData::ResetEditMode()
1300 {
1301     ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
1302 
1303     if (mbEditEngineCreated && mpEditEngine)
1304         delete mpEditEngine;
1305     else if (pTxtWnd && pTxtWnd->GetEditView() && pTxtWnd->GetEditView()->GetEditEngine())
1306         pTxtWnd->GetEditView()->GetEditEngine()->SetNotifyHdl(Link());
1307     mpEditEngine = NULL;
1308 
1309     DELETEZ(mpForwarder);
1310     DELETEZ(mpEditViewForwarder);
1311     DELETEZ(mpViewForwarder);
1312     mbEditEngineCreated = sal_False;
1313 }
1314 
1315 void ScAccessibleEditLineTextData::TextChanged()
1316 {
1317     if (mbEditEngineCreated && mpEditEngine)
1318     {
1319         ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
1320 
1321         if (pTxtWnd)
1322             mpEditEngine->SetText(pTxtWnd->GetTextString());
1323     }
1324 }
1325 
1326 void ScAccessibleEditLineTextData::StartEdit()
1327 {
1328     ResetEditMode();
1329     mpEditView = NULL;
1330 
1331     // send HINT_BEGEDIT
1332     SdrHint aHint(HINT_BEGEDIT);
1333 	GetBroadcaster().Broadcast( aHint );
1334 }
1335 
1336 void ScAccessibleEditLineTextData::EndEdit()
1337 {
1338     // send HINT_ENDEDIT
1339     SdrHint aHint(HINT_ENDEDIT);
1340 	GetBroadcaster().Broadcast( aHint );
1341 
1342     ResetEditMode();
1343     mpEditView = NULL;
1344 }
1345 
1346 
1347 // ============================================================================
1348 
1349 //	ScAccessiblePreviewCellTextData: shared data between sub objects of a accessible cell text object
1350 
1351 ScAccessiblePreviewCellTextData::ScAccessiblePreviewCellTextData(ScPreviewShell* pViewShell,
1352 							const ScAddress& rP)
1353 	: ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP),
1354 	mpViewForwarder(NULL),
1355 	mpViewShell(pViewShell)
1356 {
1357 }
1358 
1359 ScAccessiblePreviewCellTextData::~ScAccessiblePreviewCellTextData()
1360 {
1361     if (pEditEngine)
1362         pEditEngine->SetNotifyHdl(Link());
1363 	if (mpViewForwarder)
1364 		delete mpViewForwarder;
1365 }
1366 
1367 void ScAccessiblePreviewCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1368 {
1369 	if ( rHint.ISA( SfxSimpleHint ) )
1370 	{
1371 		sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1372 		if ( nId == SFX_HINT_DYING )
1373 		{
1374 			mpViewShell = NULL;						// invalid now
1375             if (mpViewForwarder)
1376                 mpViewForwarder->SetInvalid();
1377 		}
1378 	}
1379 	ScAccessibleCellBaseTextData::Notify(rBC, rHint);
1380 }
1381 
1382 ScAccessibleTextData* ScAccessiblePreviewCellTextData::Clone() const
1383 {
1384 	return new ScAccessiblePreviewCellTextData(mpViewShell, aCellPos);
1385 }
1386 
1387 SvxTextForwarder* ScAccessiblePreviewCellTextData::GetTextForwarder()
1388 {
1389 	sal_Bool bEditEngineBefore(pEditEngine != NULL);
1390 
1391 	ScCellTextData::GetTextForwarder(); // creates Forwarder and EditEngine
1392 
1393 	if (!bEditEngineBefore && pEditEngine)
1394 	{
1395 		Size aSize(mpViewShell->GetLocationData().GetCellOutputRect(aCellPos).GetSize());
1396 		Window* pWin = mpViewShell->GetWindow();
1397 		if (pWin)
1398 			aSize = pWin->PixelToLogic(aSize, pEditEngine->GetRefMapMode());
1399 		pEditEngine->SetPaperSize(aSize);
1400 	}
1401 
1402 	if (pEditEngine)
1403 		pEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
1404 
1405 	return pForwarder;
1406 }
1407 
1408 SvxViewForwarder* ScAccessiblePreviewCellTextData::GetViewForwarder()
1409 {
1410 	if (!mpViewForwarder)
1411 		mpViewForwarder = new ScPreviewCellViewForwarder(mpViewShell, aCellPos);
1412 	return mpViewForwarder;
1413 }
1414 
1415 //UNUSED2008-05  IMPL_LINK(ScAccessiblePreviewCellTextData, NotifyHdl, EENotify*, aNotify)
1416 //UNUSED2008-05  {
1417 //UNUSED2008-05      if( aNotify )
1418 //UNUSED2008-05      {
1419 //UNUSED2008-05          ::std::auto_ptr< SfxHint > aHint = SvxEditSourceHelper::EENotification2Hint( aNotify);
1420 //UNUSED2008-05
1421 //UNUSED2008-05          if( aHint.get() )
1422 //UNUSED2008-05              GetBroadcaster().Broadcast( *aHint.get() );
1423 //UNUSED2008-05      }
1424 //UNUSED2008-05
1425 //UNUSED2008-05      return 0;
1426 //UNUSED2008-05  }
1427 
1428 ScDocShell* ScAccessiblePreviewCellTextData::GetDocShell(ScPreviewShell* pViewShell)
1429 {
1430 	ScDocShell* pDocSh = NULL;
1431 	if (pViewShell && pViewShell->GetDocument())
1432 		pDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
1433 	return pDocSh;
1434 }
1435 
1436 
1437 // ============================================================================
1438 
1439 //	ScAccessiblePreviewHeaderCellTextData: shared data between sub objects of a accessible cell text object
1440 
1441 ScAccessiblePreviewHeaderCellTextData::ScAccessiblePreviewHeaderCellTextData(ScPreviewShell* pViewShell,
1442 			const String& rText, const ScAddress& rP, sal_Bool bColHeader, sal_Bool bRowHeader)
1443 	: ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP),
1444 	mpViewForwarder(NULL),
1445 	mpViewShell(pViewShell),
1446 	maText(rText),
1447 	mbColHeader(bColHeader),
1448 	mbRowHeader(bRowHeader)
1449 {
1450 }
1451 
1452 ScAccessiblePreviewHeaderCellTextData::~ScAccessiblePreviewHeaderCellTextData()
1453 {
1454     if (pEditEngine)
1455         pEditEngine->SetNotifyHdl(Link());
1456 	if (mpViewForwarder)
1457 		delete mpViewForwarder;
1458 }
1459 
1460 void ScAccessiblePreviewHeaderCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1461 {
1462 	if ( rHint.ISA( SfxSimpleHint ) )
1463 	{
1464 		sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1465 		if ( nId == SFX_HINT_DYING )
1466 		{
1467 			mpViewShell = NULL;						// invalid now
1468             if (mpViewForwarder)
1469                 mpViewForwarder->SetInvalid();
1470 		}
1471 	}
1472 	ScAccessibleCellBaseTextData::Notify(rBC, rHint);
1473 }
1474 
1475 ScAccessibleTextData* ScAccessiblePreviewHeaderCellTextData::Clone() const
1476 {
1477 	return new ScAccessiblePreviewHeaderCellTextData(mpViewShell, maText, aCellPos, mbColHeader, mbRowHeader);
1478 }
1479 
1480 SvxTextForwarder* ScAccessiblePreviewHeaderCellTextData::GetTextForwarder()
1481 {
1482 	if (!pEditEngine)
1483 	{
1484 		if ( pDocShell )
1485 		{
1486 			ScDocument* pDoc = pDocShell->GetDocument();
1487 			pEditEngine = pDoc->CreateFieldEditEngine();
1488 		}
1489 		else
1490 		{
1491 			SfxItemPool* pEnginePool = EditEngine::CreatePool();
1492 			pEnginePool->FreezeIdRanges();
1493 			pEditEngine = new ScFieldEditEngine( pEnginePool, NULL, sal_True );
1494 		}
1495 		//	currently, GetPortions doesn't work if UpdateMode is sal_False,
1496 		//	this will be fixed (in EditEngine) by src600
1497 //		pEditEngine->SetUpdateMode( sal_False );
1498 		pEditEngine->EnableUndo( sal_False );
1499 		if (pDocShell)
1500 			pEditEngine->SetRefDevice(pDocShell->GetRefDevice());
1501 		else
1502 			pEditEngine->SetRefMapMode( MAP_100TH_MM );
1503 		pForwarder = new SvxEditEngineForwarder(*pEditEngine);
1504 	}
1505 
1506 	if (bDataValid)
1507 		return pForwarder;
1508 
1509 	if (maText.Len() && pEditEngine)
1510 	{
1511 
1512 		if ( mpViewShell  )
1513 		{
1514 			Size aOutputSize;
1515 			Window* pWindow = mpViewShell->GetWindow();
1516 			if ( pWindow )
1517 				aOutputSize = pWindow->GetOutputSizePixel();
1518 			Point aPoint;
1519 			Rectangle aVisRect( aPoint, aOutputSize );
1520 			Size aSize(mpViewShell->GetLocationData().GetHeaderCellOutputRect(aVisRect, aCellPos, mbColHeader).GetSize());
1521 			if (pWindow)
1522 				aSize = pWindow->PixelToLogic(aSize, pEditEngine->GetRefMapMode());
1523 			pEditEngine->SetPaperSize(aSize);
1524 		}
1525 		pEditEngine->SetText( maText );
1526 	}
1527 
1528 	bDataValid = sal_True;
1529 
1530 	if (pEditEngine)
1531 		pEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
1532 
1533 	return pForwarder;
1534 }
1535 
1536 SvxViewForwarder* ScAccessiblePreviewHeaderCellTextData::GetViewForwarder()
1537 {
1538 	if (!mpViewForwarder)
1539 		mpViewForwarder = new ScPreviewHeaderCellViewForwarder(mpViewShell, aCellPos, mbColHeader, mbRowHeader);
1540 	return mpViewForwarder;
1541 }
1542 
1543 //UNUSED2008-05  IMPL_LINK(ScAccessiblePreviewHeaderCellTextData, NotifyHdl, EENotify*, aNotify)
1544 //UNUSED2008-05  {
1545 //UNUSED2008-05      if( aNotify )
1546 //UNUSED2008-05      {
1547 //UNUSED2008-05          ::std::auto_ptr< SfxHint > aHint = SvxEditSourceHelper::EENotification2Hint( aNotify);
1548 //UNUSED2008-05
1549 //UNUSED2008-05          if( aHint.get() )
1550 //UNUSED2008-05              GetBroadcaster().Broadcast( *aHint.get() );
1551 //UNUSED2008-05      }
1552 //UNUSED2008-05
1553 //UNUSED2008-05      return 0;
1554 //UNUSED2008-05  }
1555 
1556 ScDocShell* ScAccessiblePreviewHeaderCellTextData::GetDocShell(ScPreviewShell* pViewShell)
1557 {
1558 	ScDocShell* pDocSh = NULL;
1559 	if (pViewShell && pViewShell->GetDocument())
1560 		pDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
1561 	return pDocSh;
1562 }
1563 
1564 
1565 // ============================================================================
1566 
1567 ScAccessibleHeaderTextData::ScAccessibleHeaderTextData(ScPreviewShell* pViewShell,
1568                             const EditTextObject* pEditObj, sal_Bool bHeader, SvxAdjust eAdjust)
1569     :
1570     mpViewForwarder(NULL),
1571     mpViewShell(pViewShell),
1572     mpEditEngine(NULL),
1573     mpForwarder(NULL),
1574     mpDocSh(NULL),
1575     mpEditObj(pEditObj),
1576     mbHeader(bHeader),
1577     mbDataValid(sal_False),
1578     meAdjust(eAdjust)
1579 {
1580 	if (pViewShell && pViewShell->GetDocument())
1581 		mpDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
1582 	if (mpDocSh)
1583 		mpDocSh->GetDocument()->AddUnoObject(*this);
1584 }
1585 
1586 ScAccessibleHeaderTextData::~ScAccessibleHeaderTextData()
1587 {
1588 	ScUnoGuard aGuard;		//	needed for EditEngine dtor
1589 
1590 	if (mpDocSh)
1591 		mpDocSh->GetDocument()->RemoveUnoObject(*this);
1592     if (mpEditEngine)
1593         mpEditEngine->SetNotifyHdl(Link());
1594 	delete mpEditEngine;
1595 	delete mpForwarder;
1596 }
1597 
1598 ScAccessibleTextData* ScAccessibleHeaderTextData::Clone() const
1599 {
1600     return new ScAccessibleHeaderTextData(mpViewShell, mpEditObj, mbHeader, meAdjust);
1601 }
1602 
1603 void ScAccessibleHeaderTextData::Notify( SfxBroadcaster&, const SfxHint& rHint )
1604 {
1605 	if ( rHint.ISA( SfxSimpleHint ) )
1606 	{
1607 		sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1608 		if ( nId == SFX_HINT_DYING )
1609 		{
1610 			mpViewShell = NULL;// invalid now
1611             mpDocSh = NULL;
1612             if (mpViewForwarder)
1613                 mpViewForwarder->SetInvalid();
1614 		}
1615 	}
1616 }
1617 
1618 SvxTextForwarder* ScAccessibleHeaderTextData::GetTextForwarder()
1619 {
1620 	if (!mpEditEngine)
1621 	{
1622 		SfxItemPool* pEnginePool = EditEngine::CreatePool();
1623 		pEnginePool->FreezeIdRanges();
1624 		ScHeaderEditEngine* pHdrEngine = new ScHeaderEditEngine( pEnginePool, sal_True );
1625 
1626 		pHdrEngine->EnableUndo( sal_False );
1627 		pHdrEngine->SetRefMapMode( MAP_TWIP );
1628 
1629 		//	default font must be set, independently of document
1630 		//	-> use global pool from module
1631 
1632 		SfxItemSet aDefaults( pHdrEngine->GetEmptyItemSet() );
1633 		const ScPatternAttr& rPattern = (const ScPatternAttr&)SC_MOD()->GetPool().GetDefaultItem(ATTR_PATTERN);
1634 		rPattern.FillEditItemSet( &aDefaults );
1635 		//	FillEditItemSet adjusts font height to 1/100th mm,
1636 		//	but for header/footer twips is needed, as in the PatternAttr:
1637 		aDefaults.Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
1638 		aDefaults.Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
1639 		aDefaults.Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
1640 		aDefaults.Put( SvxAdjustItem( meAdjust, EE_PARA_JUST ) );
1641 		pHdrEngine->SetDefaults( aDefaults );
1642 
1643 		ScHeaderFieldData aData;
1644         if (mpViewShell)
1645             mpViewShell->FillFieldData(aData);
1646         else
1647 		    ScHeaderFooterTextObj::FillDummyFieldData( aData );
1648 		pHdrEngine->SetData( aData );
1649 
1650 		mpEditEngine = pHdrEngine;
1651 		mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
1652 	}
1653 
1654 	if (mbDataValid)
1655 		return mpForwarder;
1656 
1657 	if ( mpViewShell  )
1658 	{
1659 		Rectangle aVisRect;
1660 		mpViewShell->GetLocationData().GetHeaderPosition(aVisRect);
1661         Size aSize(aVisRect.GetSize());
1662 		Window* pWin = mpViewShell->GetWindow();
1663 		if (pWin)
1664 			aSize = pWin->PixelToLogic(aSize, mpEditEngine->GetRefMapMode());
1665 		mpEditEngine->SetPaperSize(aSize);
1666 	}
1667 	if (mpEditObj)
1668 		mpEditEngine->SetText(*mpEditObj);
1669 
1670 	mbDataValid = sal_True;
1671     return mpForwarder;
1672 }
1673 
1674 SvxViewForwarder* ScAccessibleHeaderTextData::GetViewForwarder()
1675 {
1676 	if (!mpViewForwarder)
1677 		mpViewForwarder = new ScPreviewHeaderFooterViewForwarder(mpViewShell, mbHeader);
1678 	return mpViewForwarder;
1679 }
1680 
1681 
1682 // ============================================================================
1683 
1684 ScAccessibleNoteTextData::ScAccessibleNoteTextData(ScPreviewShell* pViewShell,
1685                             const String& sText, const ScAddress& aCellPos, sal_Bool bMarkNote)
1686     :
1687     mpViewForwarder(NULL),
1688     mpViewShell(pViewShell),
1689     mpEditEngine(NULL),
1690     mpForwarder(NULL),
1691     mpDocSh(NULL),
1692     msText(sText),
1693     maCellPos(aCellPos),
1694     mbMarkNote(bMarkNote),
1695     mbDataValid(sal_False)
1696 {
1697 	if (pViewShell && pViewShell->GetDocument())
1698 		mpDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
1699 	if (mpDocSh)
1700 		mpDocSh->GetDocument()->AddUnoObject(*this);
1701 }
1702 
1703 ScAccessibleNoteTextData::~ScAccessibleNoteTextData()
1704 {
1705 	ScUnoGuard aGuard;		//	needed for EditEngine dtor
1706 
1707 	if (mpDocSh)
1708 		mpDocSh->GetDocument()->RemoveUnoObject(*this);
1709     if (mpEditEngine)
1710         mpEditEngine->SetNotifyHdl(Link());
1711 	delete mpEditEngine;
1712 	delete mpForwarder;
1713 }
1714 
1715 ScAccessibleTextData* ScAccessibleNoteTextData::Clone() const
1716 {
1717     return new ScAccessibleNoteTextData(mpViewShell, msText, maCellPos, mbMarkNote);
1718 }
1719 
1720 void ScAccessibleNoteTextData::Notify( SfxBroadcaster&, const SfxHint& rHint )
1721 {
1722 	if ( rHint.ISA( SfxSimpleHint ) )
1723 	{
1724 		sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1725 		if ( nId == SFX_HINT_DYING )
1726 		{
1727 			mpViewShell = NULL;// invalid now
1728             mpDocSh = NULL;
1729             if (mpViewForwarder)
1730                 mpViewForwarder->SetInvalid();
1731 		}
1732 	}
1733 }
1734 
1735 SvxTextForwarder* ScAccessibleNoteTextData::GetTextForwarder()
1736 {
1737 	if (!mpEditEngine)
1738 	{
1739 		if ( mpDocSh )
1740 		{
1741 			ScDocument* pDoc = mpDocSh->GetDocument();
1742 			mpEditEngine = pDoc->CreateFieldEditEngine();
1743 		}
1744 		else
1745 		{
1746 			SfxItemPool* pEnginePool = EditEngine::CreatePool();
1747 			pEnginePool->FreezeIdRanges();
1748 			mpEditEngine = new ScFieldEditEngine( pEnginePool, NULL, sal_True );
1749 		}
1750 		//	currently, GetPortions doesn't work if UpdateMode is sal_False,
1751 		//	this will be fixed (in EditEngine) by src600
1752 //		pEditEngine->SetUpdateMode( sal_False );
1753 		mpEditEngine->EnableUndo( sal_False );
1754 		if (mpDocSh)
1755 			mpEditEngine->SetRefDevice(mpDocSh->GetRefDevice());
1756 		else
1757 			mpEditEngine->SetRefMapMode( MAP_100TH_MM );
1758 		mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
1759 	}
1760 
1761 	if (mbDataValid)
1762 		return mpForwarder;
1763 
1764 	if (msText.Len() && mpEditEngine)
1765 	{
1766 
1767 		if ( mpViewShell  )
1768 		{
1769 			Size aOutputSize;
1770 			Window* pWindow = mpViewShell->GetWindow();
1771 			if ( pWindow )
1772 				aOutputSize = pWindow->GetOutputSizePixel();
1773 			Point aPoint;
1774 			Rectangle aVisRect( aPoint, aOutputSize );
1775 			Size aSize(mpViewShell->GetLocationData().GetNoteInRangeOutputRect(aVisRect, mbMarkNote, maCellPos).GetSize());
1776 			if (pWindow)
1777 				aSize = pWindow->PixelToLogic(aSize, mpEditEngine->GetRefMapMode());
1778 			mpEditEngine->SetPaperSize(aSize);
1779 		}
1780 		mpEditEngine->SetText( msText );
1781 	}
1782 
1783 	mbDataValid = sal_True;
1784 
1785 	if (mpEditEngine)
1786 		mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
1787 
1788 	return mpForwarder;
1789 }
1790 
1791 SvxViewForwarder* ScAccessibleNoteTextData::GetViewForwarder()
1792 {
1793 	if (!mpViewForwarder)
1794 		mpViewForwarder = new ScPreviewNoteViewForwarder(mpViewShell, maCellPos, mbMarkNote);
1795 	return mpViewForwarder;
1796 }
1797 
1798 
1799 // CSV import =================================================================
1800 
1801 class ScCsvViewForwarder : public SvxViewForwarder
1802 {
1803     Rectangle                   maBoundBox;
1804     Window*                     mpWindow;
1805 
1806 public:
1807     explicit                    ScCsvViewForwarder( Window* pWindow, const Rectangle& rBoundBox );
1808 
1809     virtual sal_Bool                IsValid() const;
1810     virtual Rectangle           GetVisArea() const;
1811     virtual Point               LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const;
1812     virtual Point               PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const;
1813 
1814     void                        SetInvalid();
1815 };
1816 
1817 ScCsvViewForwarder::ScCsvViewForwarder( Window* pWindow, const Rectangle& rBoundBox ) :
1818     maBoundBox( rBoundBox ),
1819     mpWindow( pWindow )
1820 {
1821 }
1822 
1823 sal_Bool ScCsvViewForwarder::IsValid() const
1824 {
1825     return mpWindow != NULL;
1826 }
1827 
1828 Rectangle ScCsvViewForwarder::GetVisArea() const
1829 {
1830     return maBoundBox;
1831 }
1832 
1833 Point ScCsvViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
1834 {
1835     if( !mpWindow ) return Point();
1836     return mpWindow->LogicToPixel( rPoint, rMapMode );
1837 }
1838 
1839 Point ScCsvViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
1840 {
1841     if( !mpWindow ) return Point();
1842     return mpWindow->PixelToLogic( rPoint, rMapMode );
1843 }
1844 
1845 void ScCsvViewForwarder::SetInvalid()
1846 {
1847     mpWindow = NULL;
1848 }
1849 
1850 // ----------------------------------------------------------------------------
1851 
1852 ScAccessibleCsvTextData::ScAccessibleCsvTextData(
1853         Window* pWindow, EditEngine* pEditEngine,
1854         const String& rCellText, const Rectangle& rBoundBox, const Size& rCellSize ) :
1855     mpWindow( pWindow ),
1856     mpEditEngine( pEditEngine ),
1857     maCellText( rCellText ),
1858     maBoundBox( rBoundBox ),
1859     maCellSize( rCellSize )
1860 {
1861 }
1862 
1863 ScAccessibleCsvTextData::~ScAccessibleCsvTextData()
1864 {
1865 }
1866 
1867 void ScAccessibleCsvTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1868 {
1869     if ( rHint.ISA( SfxSimpleHint ) )
1870     {
1871         sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1872         if( nId == SFX_HINT_DYING )
1873         {
1874             mpWindow = NULL;
1875             mpEditEngine = NULL;
1876             if (mpViewForwarder.get())
1877                 mpViewForwarder->SetInvalid();
1878         }
1879     }
1880     ScAccessibleTextData::Notify( rBC, rHint );
1881 }
1882 
1883 ScAccessibleTextData* ScAccessibleCsvTextData::Clone() const
1884 {
1885     return new ScAccessibleCsvTextData( mpWindow, mpEditEngine, maCellText, maBoundBox, maCellSize );
1886 }
1887 
1888 SvxTextForwarder* ScAccessibleCsvTextData::GetTextForwarder()
1889 {
1890     if( mpEditEngine )
1891     {
1892         mpEditEngine->SetPaperSize( maCellSize );
1893         mpEditEngine->SetText( maCellText );
1894         if( !mpTextForwarder.get() )
1895             mpTextForwarder.reset( new SvxEditEngineForwarder( *mpEditEngine ) );
1896     }
1897     else
1898         mpTextForwarder.reset( NULL );
1899     return mpTextForwarder.get();
1900 }
1901 
1902 SvxViewForwarder* ScAccessibleCsvTextData::GetViewForwarder()
1903 {
1904     if( !mpViewForwarder.get() )
1905         mpViewForwarder.reset( new ScCsvViewForwarder( mpWindow, maBoundBox ) );
1906     return mpViewForwarder.get();
1907 }
1908 
1909 SvxEditViewForwarder* ScAccessibleCsvTextData::GetEditViewForwarder( sal_Bool /* bCreate */ )
1910 {
1911     return NULL;
1912 }
1913 
1914 
1915 // ============================================================================
1916 
1917