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