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

Generated by: LCOV version 1.10