LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/Accessibility - AccessibleText.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 793 0.1 %
Date: 2012-12-27 Functions: 2 137 1.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10