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

Generated by: LCOV version 1.10