LCOV - code coverage report
Current view: top level - sc/source/ui/Accessibility - AccessibleText.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 791 0.0 %
Date: 2014-04-14 Functions: 0 137 0.0 %
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           0 : ScPreviewViewForwarder::ScPreviewViewForwarder(ScPreviewShell* pViewShell)
     268             :     :
     269             :     mpViewShell(pViewShell),
     270           0 :     mpTableInfo(NULL)
     271             : {
     272           0 : }
     273             : 
     274           0 : ScPreviewViewForwarder::~ScPreviewViewForwarder()
     275             : {
     276           0 :     delete mpTableInfo;
     277           0 : }
     278             : 
     279           0 : bool ScPreviewViewForwarder::IsValid() const
     280             : {
     281           0 :     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           0 : Point ScPreviewViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
     292             : {
     293           0 :     if (mpViewShell)
     294             :     {
     295           0 :         Window* pWindow = mpViewShell->GetWindow();
     296           0 :         if (pWindow)
     297             :         {
     298           0 :             MapMode aMapMode(pWindow->GetMapMode().GetMapUnit());
     299           0 :             Point aPoint2( OutputDevice::LogicToLogic( rPoint, rMapMode, aMapMode) );
     300           0 :             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           0 : Point ScPreviewViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
     311             : {
     312           0 :     if (mpViewShell)
     313             :     {
     314           0 :         Window* pWindow = mpViewShell->GetWindow();
     315           0 :         if (pWindow)
     316             :         {
     317           0 :             MapMode aMapMode(pWindow->GetMapMode());
     318           0 :             aMapMode.SetOrigin(Point());
     319           0 :             Point aPoint1( pWindow->PixelToLogic( rPoint ) );
     320             :             Point aPoint2( OutputDevice::LogicToLogic( aPoint1,
     321             :                                                        aMapMode.GetMapUnit(),
     322           0 :                                                        rMapMode ) );
     323           0 :             return aPoint2;
     324             :         }
     325             :     }
     326             :     else
     327             :     {
     328             :         OSL_FAIL("this ViewForwarder is not valid");
     329             :     }
     330           0 :     return Point();
     331             : }
     332             : 
     333           0 : void ScPreviewViewForwarder::SetInvalid()
     334             : {
     335           0 :     mpViewShell = NULL;
     336           0 : }
     337             : 
     338           0 : Rectangle ScPreviewViewForwarder::GetVisRect() const
     339             : {
     340           0 :     if ( mpViewShell )
     341             :     {
     342           0 :         Size aOutputSize;
     343           0 :         Window* pWindow = mpViewShell->GetWindow();
     344           0 :         if ( pWindow )
     345           0 :             aOutputSize = pWindow->GetOutputSizePixel();
     346           0 :         Point aPoint;
     347           0 :         Rectangle aVisRect( aPoint, aOutputSize );
     348           0 :         return aVisRect;
     349             :     }
     350           0 :     return Rectangle();
     351             : }
     352             : 
     353           0 : Rectangle ScPreviewViewForwarder::CorrectVisArea(const Rectangle& rVisArea) const
     354             : {
     355           0 :     Rectangle aVisArea(rVisArea);
     356           0 :     Point aPos = aVisArea.TopLeft(); // get first the position to remember negative positions after clipping
     357             : 
     358           0 :     Window* pWin = mpViewShell->GetWindow();
     359           0 :     if (pWin)
     360           0 :         aVisArea = pWin->GetWindowExtentsRelative(pWin).GetIntersection(aVisArea);
     361             : 
     362           0 :     sal_Int32 nX(aPos.getX());
     363           0 :     sal_Int32 nY(aPos.getY());
     364             : 
     365           0 :     if (nX > 0)
     366           0 :         nX = 0;
     367           0 :     else if (nX < 0)
     368           0 :         nX = -nX;
     369           0 :     if (nY > 0)
     370           0 :         nY = 0;
     371           0 :     else if (nY < 0)
     372           0 :         nY = -nY;
     373           0 :     aVisArea.SetPos(Point(nX, nY));
     374             : 
     375           0 :     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           0 : ScPreviewHeaderFooterViewForwarder::ScPreviewHeaderFooterViewForwarder(ScPreviewShell* pViewShell, sal_Bool bHeader)
     389             :     :
     390             :     ScPreviewViewForwarder(pViewShell),
     391           0 :     mbHeader(bHeader)
     392             : {
     393           0 : }
     394             : 
     395           0 : ScPreviewHeaderFooterViewForwarder::~ScPreviewHeaderFooterViewForwarder()
     396             : {
     397           0 : }
     398             : 
     399           0 : Rectangle ScPreviewHeaderFooterViewForwarder::GetVisArea() const
     400             : {
     401           0 :     Rectangle aVisArea;
     402           0 :     if (mpViewShell)
     403             :     {
     404           0 :         const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
     405           0 :         if ( mbHeader )
     406           0 :             rData.GetHeaderPosition( aVisArea );
     407             :         else
     408           0 :             rData.GetFooterPosition( aVisArea );
     409             : 
     410           0 :         aVisArea = CorrectVisArea(aVisArea);
     411             :     }
     412             :     else
     413             :     {
     414             :         OSL_FAIL("this ViewForwarder is not valid");
     415             :     }
     416           0 :     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           0 : ScPreviewCellViewForwarder::ScPreviewCellViewForwarder(ScPreviewShell* pViewShell,
     431             :                                                        ScAddress aCellPos)
     432             :     :
     433             :     ScPreviewViewForwarder(pViewShell),
     434           0 :     maCellPos(aCellPos)
     435             : {
     436           0 : }
     437             : 
     438           0 : ScPreviewCellViewForwarder::~ScPreviewCellViewForwarder()
     439             : {
     440           0 : }
     441             : 
     442           0 : Rectangle ScPreviewCellViewForwarder::GetVisArea() const
     443             : {
     444           0 :     Rectangle aVisArea;
     445           0 :     if (mpViewShell)
     446             :     {
     447           0 :         const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
     448           0 :         aVisArea = rData.GetCellOutputRect(maCellPos);
     449             : 
     450           0 :         aVisArea = CorrectVisArea(aVisArea);
     451             :     }
     452             :     else
     453             :     {
     454             :         OSL_FAIL("this ViewForwarder is not valid");
     455             :     }
     456           0 :     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           0 : ScPreviewHeaderCellViewForwarder::ScPreviewHeaderCellViewForwarder(ScPreviewShell* pViewShell,
     473             :                                                                    ScAddress aCellPos,
     474             :                                                                    sal_Bool bColHeader)
     475             :     :
     476             :     ScPreviewViewForwarder(pViewShell),
     477             :     maCellPos(aCellPos),
     478           0 :     mbColHeader(bColHeader)
     479             : {
     480           0 : }
     481             : 
     482           0 : ScPreviewHeaderCellViewForwarder::~ScPreviewHeaderCellViewForwarder()
     483             : {
     484           0 : }
     485             : 
     486           0 : Rectangle ScPreviewHeaderCellViewForwarder::GetVisArea() const
     487             : {
     488           0 :     Rectangle aVisArea;
     489           0 :     if (mpViewShell)
     490             :     {
     491           0 :         const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
     492           0 :         aVisArea = rData.GetHeaderCellOutputRect(GetVisRect(), maCellPos, mbColHeader);
     493             : 
     494           0 :         aVisArea = CorrectVisArea(aVisArea);
     495             :     }
     496             :     else
     497             :     {
     498             :         OSL_FAIL("this ViewForwarder is not valid");
     499             :     }
     500           0 :     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           0 : 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           0 :     mpAccessibleCell( pAccCell )
     719             : {
     720           0 : }
     721             : 
     722           0 : ScAccessibleCellTextData::~ScAccessibleCellTextData()
     723             : {
     724           0 :     if (pEditEngine)
     725           0 :         pEditEngine->SetNotifyHdl(Link());
     726           0 :     if (mpViewForwarder)
     727           0 :         delete mpViewForwarder;
     728           0 :     if (mpEditViewForwarder)
     729           0 :         delete mpEditViewForwarder;
     730           0 : }
     731             : 
     732           0 : void ScAccessibleCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
     733             : {
     734           0 :     if ( rHint.ISA( SfxSimpleHint ) )
     735             :     {
     736           0 :         sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
     737           0 :         if ( nId == SFX_HINT_DYING )
     738             :         {
     739           0 :             mpViewShell = NULL;                     // invalid now
     740           0 :             if (mpViewForwarder)
     741           0 :                 mpViewForwarder->SetInvalid();
     742           0 :             if (mpEditViewForwarder)
     743           0 :                 mpEditViewForwarder->SetInvalid();
     744             :         }
     745             :     }
     746           0 :     ScAccessibleCellBaseTextData::Notify(rBC, rHint);
     747           0 : }
     748             : 
     749           0 : ScAccessibleTextData* ScAccessibleCellTextData::Clone() const
     750             : {
     751           0 :     return new ScAccessibleCellTextData( mpViewShell, aCellPos, meSplitPos, mpAccessibleCell );
     752             : }
     753             : 
     754           0 : void ScAccessibleCellTextData::GetCellText(const ScAddress& rCellPos, OUString& rText)
     755             : {
     756             : //  #104893#; don't use the input string
     757             : //    ScCellTextData::GetCellText(rCellPos, rText);
     758           0 :     ScDocument* pDoc = pDocShell->GetDocument();
     759           0 :     if (pDoc)
     760             :     {
     761             :         //  #104893#; use the displayed string
     762           0 :         rText = pDoc->GetString(rCellPos.Col(), rCellPos.Row(), rCellPos.Tab());
     763           0 :         if (mpViewShell)
     764             :         {
     765           0 :             const ScViewOptions& aOptions = mpViewShell->GetViewData()->GetOptions();
     766             :             CellType aCellType;
     767           0 :             pDoc->GetCellType(rCellPos.Col(), rCellPos.Row(), rCellPos.Tab(), aCellType);
     768           0 :             if (aCellType == CELLTYPE_FORMULA && aOptions.GetOption( VOPT_FORMULAS ))
     769             :             {
     770           0 :                 pDoc->GetFormula( rCellPos.Col(), rCellPos.Row(), rCellPos.Tab(), rText);
     771             :             }
     772           0 :             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           0 : }
     780             : 
     781           0 : SvxTextForwarder* ScAccessibleCellTextData::GetTextForwarder()
     782             : {
     783           0 :     ScCellTextData::GetTextForwarder(); // creates Forwarder and EditEngine
     784             : 
     785           0 :     ScDocument* pDoc = ( pDocShell ? pDocShell->GetDocument() : NULL );
     786           0 :     if ( pDoc && pEditEngine && mpViewShell )
     787             :     {
     788             :         long nSizeX, nSizeY;
     789             :         mpViewShell->GetViewData()->GetMergeSizePixel(
     790           0 :             aCellPos.Col(), aCellPos.Row(), nSizeX, nSizeY);
     791             : 
     792           0 :         Size aSize(nSizeX, nSizeY);
     793             : 
     794             :         // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
     795           0 :         long nIndent = 0;
     796             :         const SvxHorJustifyItem* pHorJustifyItem = static_cast< const SvxHorJustifyItem* >(
     797           0 :             pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_HOR_JUSTIFY ) );
     798           0 :         SvxCellHorJustify eHorJust = ( pHorJustifyItem ? static_cast< SvxCellHorJustify >( pHorJustifyItem->GetValue() ) : SVX_HOR_JUSTIFY_STANDARD );
     799           0 :         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           0 :             pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_MARGIN ) );
     811           0 :         ScViewData* pViewData = mpViewShell->GetViewData();
     812           0 :         double nPPTX = ( pViewData ? pViewData->GetPPTX() : 0 );
     813           0 :         double nPPTY = ( pViewData ? pViewData->GetPPTY() : 0 );
     814           0 :         long nLeftM = ( pMarginItem ? static_cast< long >( ( pMarginItem->GetLeftMargin() + nIndent ) * nPPTX ) : 0 );
     815           0 :         long nTopM = ( pMarginItem ? static_cast< long >( pMarginItem->GetTopMargin() * nPPTY ) : 0 );
     816           0 :         long nRightM = ( pMarginItem ? static_cast< long >( pMarginItem->GetRightMargin() * nPPTX ) : 0 );
     817           0 :         long nBottomM = ( pMarginItem ? static_cast< long >( pMarginItem->GetBottomMargin() * nPPTY ) : 0 );
     818           0 :         long nWidth = aSize.getWidth() - nLeftM - nRightM;
     819           0 :         aSize.setWidth( nWidth );
     820           0 :         aSize.setHeight( aSize.getHeight() - nTopM - nBottomM );
     821             : 
     822           0 :         Window* pWin = mpViewShell->GetWindowByPos( meSplitPos );
     823           0 :         if ( pWin )
     824             :         {
     825           0 :             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           0 :             pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_ROTATE_VALUE ) );
     840           0 :         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           0 :                 pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_LINEBREAK ) );
     851           0 :             bool bLineBreak = ( pLineBreakItem && pLineBreakItem->GetValue() );
     852           0 :             if ( !bLineBreak )
     853             :             {
     854           0 :                 long nTxtWidth = static_cast< long >( pEditEngine->CalcTextWidth() );
     855           0 :                 aSize.setWidth( ::std::max( aSize.getWidth(), nTxtWidth ) );
     856             :             }
     857             :         }
     858             : 
     859           0 :         pEditEngine->SetPaperSize( aSize );
     860             : 
     861             :         // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
     862           0 :         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           0 :         Size aTextSize;
     868           0 :         if ( pWin )
     869             :         {
     870           0 :             aTextSize = pWin->LogicToPixel( Size( pEditEngine->CalcTextWidth(), pEditEngine->GetTextHeight() ), pEditEngine->GetRefMapMode() );
     871             :         }
     872           0 :         long nTextWidth = aTextSize.Width();
     873           0 :         long nTextHeight = aTextSize.Height();
     874             : 
     875           0 :         long nOffsetX = nLeftM;
     876           0 :         long nDiffX = nTextWidth - nWidth;
     877           0 :         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           0 :         long nOffsetY = 0;
     899             :         const SvxVerJustifyItem* pVerJustifyItem = static_cast< const SvxVerJustifyItem* >(
     900           0 :             pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_VER_JUSTIFY ) );
     901           0 :         SvxCellVerJustify eVerJust = ( pVerJustifyItem ? static_cast< SvxCellVerJustify >( pVerJustifyItem->GetValue() ) : SVX_VER_JUSTIFY_STANDARD );
     902           0 :         switch ( eVerJust )
     903             :         {
     904             :             case SVX_VER_JUSTIFY_STANDARD:
     905             :             case SVX_VER_JUSTIFY_BOTTOM:
     906             :                 {
     907           0 :                     nOffsetY = nSizeY - nBottomM - nTextHeight;
     908             :                 }
     909           0 :                 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           0 :         if ( mpAccessibleCell )
     923             :         {
     924           0 :             mpAccessibleCell->SetOffset( Point( nOffsetX, nOffsetY ) );
     925             :         }
     926             : 
     927           0 :         pEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
     928             :     }
     929             : 
     930           0 :     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           0 : IMPL_LINK(ScAccessibleCellTextData, NotifyHdl, EENotify*, aNotify)
     947             : {
     948           0 :     if( aNotify )
     949             :     {
     950             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
     951           0 :         ::std::auto_ptr< SfxHint > aHint = SvxEditSourceHelper::EENotification2Hint( aNotify );
     952             :         SAL_WNODEPRECATED_DECLARATIONS_POP
     953             : 
     954           0 :         if( aHint.get() )
     955           0 :             GetBroadcaster().Broadcast( *aHint.get() );
     956             :     }
     957             : 
     958           0 :     return 0;
     959             : }
     960             : 
     961           0 : ScDocShell* ScAccessibleCellTextData::GetDocShell(ScTabViewShell* pViewShell)
     962             : {
     963           0 :     ScDocShell* pDocSh = NULL;
     964           0 :     if (pViewShell)
     965           0 :         pDocSh = pViewShell->GetViewData()->GetDocShell();
     966           0 :     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           0 : ScAccessiblePreviewCellTextData::ScAccessiblePreviewCellTextData(ScPreviewShell* pViewShell,
    1247             :                             const ScAddress& rP)
    1248             :     : ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP),
    1249             :     mpViewForwarder(NULL),
    1250           0 :     mpViewShell(pViewShell)
    1251             : {
    1252           0 : }
    1253             : 
    1254           0 : ScAccessiblePreviewCellTextData::~ScAccessiblePreviewCellTextData()
    1255             : {
    1256           0 :     if (pEditEngine)
    1257           0 :         pEditEngine->SetNotifyHdl(Link());
    1258           0 :     if (mpViewForwarder)
    1259           0 :         delete mpViewForwarder;
    1260           0 : }
    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           0 : ScAccessibleTextData* ScAccessiblePreviewCellTextData::Clone() const
    1278             : {
    1279           0 :     return new ScAccessiblePreviewCellTextData(mpViewShell, aCellPos);
    1280             : }
    1281             : 
    1282           0 : SvxTextForwarder* ScAccessiblePreviewCellTextData::GetTextForwarder()
    1283             : {
    1284           0 :     sal_Bool bEditEngineBefore(pEditEngine != NULL);
    1285             : 
    1286           0 :     ScCellTextData::GetTextForwarder(); // creates Forwarder and EditEngine
    1287             : 
    1288           0 :     if (!bEditEngineBefore && pEditEngine)
    1289             :     {
    1290           0 :         Size aSize(mpViewShell->GetLocationData().GetCellOutputRect(aCellPos).GetSize());
    1291           0 :         Window* pWin = mpViewShell->GetWindow();
    1292           0 :         if (pWin)
    1293           0 :             aSize = pWin->PixelToLogic(aSize, pEditEngine->GetRefMapMode());
    1294           0 :         pEditEngine->SetPaperSize(aSize);
    1295             :     }
    1296             : 
    1297           0 :     if (pEditEngine)
    1298           0 :         pEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
    1299             : 
    1300           0 :     return pForwarder;
    1301             : }
    1302             : 
    1303           0 : SvxViewForwarder* ScAccessiblePreviewCellTextData::GetViewForwarder()
    1304             : {
    1305           0 :     if (!mpViewForwarder)
    1306           0 :         mpViewForwarder = new ScPreviewCellViewForwarder(mpViewShell, aCellPos);
    1307           0 :     return mpViewForwarder;
    1308             : }
    1309             : 
    1310           0 : ScDocShell* ScAccessiblePreviewCellTextData::GetDocShell(ScPreviewShell* pViewShell)
    1311             : {
    1312           0 :     ScDocShell* pDocSh = NULL;
    1313           0 :     if (pViewShell && pViewShell->GetDocument())
    1314           0 :         pDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
    1315           0 :     return pDocSh;
    1316             : }
    1317             : 
    1318             : 
    1319             : //  ScAccessiblePreviewHeaderCellTextData: shared data between sub objects of a accessible cell text object
    1320             : 
    1321           0 : 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           0 :     mbRowHeader(bRowHeader)
    1329             : {
    1330           0 : }
    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           0 : void ScAccessiblePreviewHeaderCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
    1341             : {
    1342           0 :     if ( rHint.ISA( SfxSimpleHint ) )
    1343             :     {
    1344           0 :         sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
    1345           0 :         if ( nId == SFX_HINT_DYING )
    1346             :         {
    1347           0 :             mpViewShell = NULL;                     // invalid now
    1348           0 :             if (mpViewForwarder)
    1349           0 :                 mpViewForwarder->SetInvalid();
    1350             :         }
    1351             :     }
    1352           0 :     ScAccessibleCellBaseTextData::Notify(rBC, rHint);
    1353           0 : }
    1354             : 
    1355           0 : ScAccessibleTextData* ScAccessiblePreviewHeaderCellTextData::Clone() const
    1356             : {
    1357           0 :     return new ScAccessiblePreviewHeaderCellTextData(mpViewShell, maText, aCellPos, mbColHeader, mbRowHeader);
    1358             : }
    1359             : 
    1360           0 : SvxTextForwarder* ScAccessiblePreviewHeaderCellTextData::GetTextForwarder()
    1361             : {
    1362           0 :     if (!pEditEngine)
    1363             :     {
    1364           0 :         if ( pDocShell )
    1365             :         {
    1366           0 :             ScDocument* pDoc = pDocShell->GetDocument();
    1367           0 :             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           0 :         pEditEngine->EnableUndo( false );
    1376           0 :         if (pDocShell)
    1377           0 :             pEditEngine->SetRefDevice(pDocShell->GetRefDevice());
    1378             :         else
    1379           0 :             pEditEngine->SetRefMapMode( MAP_100TH_MM );
    1380           0 :         pForwarder = new SvxEditEngineForwarder(*pEditEngine);
    1381             :     }
    1382             : 
    1383           0 :     if (bDataValid)
    1384           0 :         return pForwarder;
    1385             : 
    1386           0 :     if (!maText.isEmpty())
    1387             :     {
    1388           0 :         if ( mpViewShell  )
    1389             :         {
    1390           0 :             Size aOutputSize;
    1391           0 :             Window* pWindow = mpViewShell->GetWindow();
    1392           0 :             if ( pWindow )
    1393           0 :                 aOutputSize = pWindow->GetOutputSizePixel();
    1394           0 :             Point aPoint;
    1395           0 :             Rectangle aVisRect( aPoint, aOutputSize );
    1396           0 :             Size aSize(mpViewShell->GetLocationData().GetHeaderCellOutputRect(aVisRect, aCellPos, mbColHeader).GetSize());
    1397           0 :             if (pWindow)
    1398           0 :                 aSize = pWindow->PixelToLogic(aSize, pEditEngine->GetRefMapMode());
    1399           0 :             pEditEngine->SetPaperSize(aSize);
    1400             :         }
    1401           0 :         pEditEngine->SetText( maText );
    1402             :     }
    1403             : 
    1404           0 :     bDataValid = true;
    1405             : 
    1406           0 :     pEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
    1407             : 
    1408           0 :     return pForwarder;
    1409             : }
    1410             : 
    1411           0 : SvxViewForwarder* ScAccessiblePreviewHeaderCellTextData::GetViewForwarder()
    1412             : {
    1413           0 :     if (!mpViewForwarder)
    1414           0 :         mpViewForwarder = new ScPreviewHeaderCellViewForwarder(mpViewShell, aCellPos, mbColHeader);
    1415           0 :     return mpViewForwarder;
    1416             : }
    1417             : 
    1418           0 : ScDocShell* ScAccessiblePreviewHeaderCellTextData::GetDocShell(ScPreviewShell* pViewShell)
    1419             : {
    1420           0 :     ScDocShell* pDocSh = NULL;
    1421           0 :     if (pViewShell && pViewShell->GetDocument())
    1422           0 :         pDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
    1423           0 :     return pDocSh;
    1424             : }
    1425             : 
    1426           0 : 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           0 :     meAdjust(eAdjust)
    1438             : {
    1439           0 :     if (pViewShell && pViewShell->GetDocument())
    1440           0 :         mpDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
    1441           0 :     if (mpDocSh)
    1442           0 :         mpDocSh->GetDocument()->AddUnoObject(*this);
    1443           0 : }
    1444             : 
    1445           0 : ScAccessibleHeaderTextData::~ScAccessibleHeaderTextData()
    1446             : {
    1447           0 :     SolarMutexGuard aGuard;     //  needed for EditEngine dtor
    1448             : 
    1449           0 :     if (mpDocSh)
    1450           0 :         mpDocSh->GetDocument()->RemoveUnoObject(*this);
    1451           0 :     if (mpEditEngine)
    1452           0 :         mpEditEngine->SetNotifyHdl(Link());
    1453           0 :     delete mpEditEngine;
    1454           0 :     delete mpForwarder;
    1455           0 : }
    1456             : 
    1457           0 : ScAccessibleTextData* ScAccessibleHeaderTextData::Clone() const
    1458             : {
    1459           0 :     return new ScAccessibleHeaderTextData(mpViewShell, mpEditObj, mbHeader, meAdjust);
    1460             : }
    1461             : 
    1462           0 : void ScAccessibleHeaderTextData::Notify( SfxBroadcaster&, const SfxHint& rHint )
    1463             : {
    1464           0 :     if ( rHint.ISA( SfxSimpleHint ) )
    1465             :     {
    1466           0 :         sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
    1467           0 :         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           0 : }
    1476             : 
    1477           0 : SvxTextForwarder* ScAccessibleHeaderTextData::GetTextForwarder()
    1478             : {
    1479           0 :     if (!mpEditEngine)
    1480             :     {
    1481           0 :         SfxItemPool* pEnginePool = EditEngine::CreatePool();
    1482           0 :         pEnginePool->FreezeIdRanges();
    1483           0 :         ScHeaderEditEngine* pHdrEngine = new ScHeaderEditEngine( pEnginePool, true );
    1484             : 
    1485           0 :         pHdrEngine->EnableUndo( false );
    1486           0 :         pHdrEngine->SetRefMapMode( MAP_TWIP );
    1487             : 
    1488             :         //  default font must be set, independently of document
    1489             :         //  -> use global pool from module
    1490             : 
    1491           0 :         SfxItemSet aDefaults( pHdrEngine->GetEmptyItemSet() );
    1492           0 :         const ScPatternAttr& rPattern = (const ScPatternAttr&)SC_MOD()->GetPool().GetDefaultItem(ATTR_PATTERN);
    1493           0 :         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           0 :         aDefaults.Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
    1497           0 :         aDefaults.Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
    1498           0 :         aDefaults.Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
    1499           0 :         aDefaults.Put( SvxAdjustItem( meAdjust, EE_PARA_JUST ) );
    1500           0 :         pHdrEngine->SetDefaults( aDefaults );
    1501             : 
    1502           0 :         ScHeaderFieldData aData;
    1503           0 :         if (mpViewShell)
    1504           0 :             mpViewShell->FillFieldData(aData);
    1505             :         else
    1506           0 :             ScHeaderFooterTextObj::FillDummyFieldData( aData );
    1507           0 :         pHdrEngine->SetData( aData );
    1508             : 
    1509           0 :         mpEditEngine = pHdrEngine;
    1510           0 :         mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
    1511             :     }
    1512             : 
    1513           0 :     if (mbDataValid)
    1514           0 :         return mpForwarder;
    1515             : 
    1516           0 :     if ( mpViewShell  )
    1517             :     {
    1518           0 :         Rectangle aVisRect;
    1519           0 :         mpViewShell->GetLocationData().GetHeaderPosition(aVisRect);
    1520           0 :         Size aSize(aVisRect.GetSize());
    1521           0 :         Window* pWin = mpViewShell->GetWindow();
    1522           0 :         if (pWin)
    1523           0 :             aSize = pWin->PixelToLogic(aSize, mpEditEngine->GetRefMapMode());
    1524           0 :         mpEditEngine->SetPaperSize(aSize);
    1525             :     }
    1526           0 :     if (mpEditObj)
    1527           0 :         mpEditEngine->SetText(*mpEditObj);
    1528             : 
    1529           0 :     mbDataValid = true;
    1530           0 :     return mpForwarder;
    1531             : }
    1532             : 
    1533           0 : SvxViewForwarder* ScAccessibleHeaderTextData::GetViewForwarder()
    1534             : {
    1535           0 :     if (!mpViewForwarder)
    1536           0 :         mpViewForwarder = new ScPreviewHeaderFooterViewForwarder(mpViewShell, mbHeader);
    1537           0 :     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           0 : }
    1763             : 
    1764             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10