LCOV - code coverage report
Current view: top level - editeng/source/editeng - impedit.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 254 1027 24.7 %
Date: 2012-08-25 Functions: 19 49 38.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 254 1898 13.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <vcl/wrkwin.hxx>
      30                 :            : #include <vcl/dialog.hxx>
      31                 :            : #include <vcl/msgbox.hxx>
      32                 :            : #include <vcl/svapp.hxx>
      33                 :            : #include <impedit.hxx>
      34                 :            : #include <editeng/editeng.hxx>
      35                 :            : #include <editeng/editview.hxx>
      36                 :            : #include <tools/poly.hxx>
      37                 :            : #include <editeng/unolingu.hxx>
      38                 :            : #include <com/sun/star/linguistic2/XDictionaryEntry.hpp>
      39                 :            : #include <com/sun/star/linguistic2/DictionaryType.hpp>
      40                 :            : #include <com/sun/star/linguistic2/DictionaryEvent.hpp>
      41                 :            : #include <com/sun/star/linguistic2/XDictionaryEventListener.hpp>
      42                 :            : #include <com/sun/star/linguistic2/DictionaryEventFlags.hpp>
      43                 :            : #include <com/sun/star/linguistic2/XDictionary.hpp>
      44                 :            : #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
      45                 :            : #include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
      46                 :            : #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
      47                 :            : #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
      48                 :            : #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
      49                 :            : #include <osl/mutex.hxx>
      50                 :            : #include <editeng/flditem.hxx>
      51                 :            : #include <svl/intitem.hxx>
      52                 :            : #include <svtools/transfer.hxx>
      53                 :            : #include <sot/exchange.hxx>
      54                 :            : #include <sot/formats.hxx>
      55                 :            : 
      56                 :            : 
      57                 :            : using namespace ::com::sun::star;
      58                 :            : using namespace ::com::sun::star::uno;
      59                 :            : using namespace ::com::sun::star::linguistic2;
      60                 :            : 
      61                 :            : #define SCRLRANGE   20  // Scroll 1/20 of the width/height, when in QueryDrop
      62                 :            : 
      63                 :          0 : inline void lcl_AllignToPixel( Point& rPoint, OutputDevice* pOutDev, short nDiffX, short nDiffY )
      64                 :            : {
      65                 :          0 :     rPoint = pOutDev->LogicToPixel( rPoint );
      66                 :            : 
      67         [ #  # ]:          0 :     if ( nDiffX )
      68                 :          0 :         rPoint.X() += nDiffX;
      69         [ #  # ]:          0 :     if ( nDiffY )
      70                 :          0 :         rPoint.Y() += nDiffY;
      71                 :            : 
      72                 :          0 :     rPoint = pOutDev->PixelToLogic( rPoint );
      73                 :          0 : }
      74                 :            : 
      75                 :            : // ----------------------------------------------------------------------
      76                 :            : //  class ImpEditView
      77                 :            : //  ----------------------------------------------------------------------
      78                 :        297 : ImpEditView::ImpEditView( EditView* pView, EditEngine* pEng, Window* pWindow ) :
      79 [ +  - ][ +  - ]:        297 :     aOutArea( Point(), pEng->GetPaperSize() )
                 [ +  - ]
      80                 :            : {
      81                 :        297 :     pEditView           = pView;
      82                 :        297 :     pEditEngine         = pEng;
      83                 :        297 :     pOutWin             = pWindow;
      84                 :        297 :     pPointer            = NULL;
      85                 :        297 :     pBackgroundColor    = NULL;
      86                 :        297 :     nScrollDiffX        = 0;
      87                 :        297 :     nExtraCursorFlags   = 0;
      88                 :        297 :     nCursorBidiLevel    = CURSOR_BIDILEVEL_DONTKNOW;
      89                 :        297 :     pCursor             = NULL;
      90                 :        297 :        pDragAndDropInfo = NULL;
      91                 :        297 :     bReadOnly           = sal_False;
      92                 :        297 :     bClickedInSelection = sal_False;
      93                 :        297 :     eSelectionMode      = EE_SELMODE_TXTONLY;
      94                 :        297 :     eAnchorMode         = ANCHOR_TOP_LEFT;
      95                 :        297 :     nInvMore            = 1;
      96                 :        297 :     nTravelXPos         = TRAVEL_X_DONTKNOW;
      97                 :        297 :     nControl            = EV_CNTRL_AUTOSCROLL | EV_CNTRL_ENABLEPASTE;
      98                 :        297 :     bActiveDragAndDropListener = sal_False;
      99                 :            : 
     100 [ +  - ][ +  - ]:        297 :     aEditSelection.Min() = pEng->GetEditDoc().GetStartPaM();
                 [ +  - ]
     101 [ +  - ][ +  - ]:        297 :     aEditSelection.Max() = pEng->GetEditDoc().GetEndPaM();
                 [ +  - ]
     102                 :        297 : }
     103                 :            : 
     104                 :        294 : ImpEditView::~ImpEditView()
     105                 :            : {
     106         [ +  - ]:        294 :     RemoveDragAndDropListeners();
     107                 :            : 
     108 [ +  + ][ +  - ]:        294 :     if ( pOutWin && ( pOutWin->GetCursor() == pCursor ) )
         [ +  + ][ +  + ]
     109         [ +  - ]:        239 :         pOutWin->SetCursor( NULL );
     110                 :            : 
     111 [ +  - ][ +  - ]:        294 :     delete pCursor;
     112                 :        294 :     delete pBackgroundColor;
     113                 :        294 :     delete pPointer;
     114                 :        294 :     delete pDragAndDropInfo;
     115         [ -  + ]:        588 : }
     116                 :            : 
     117                 :         18 : void ImpEditView::SetBackgroundColor( const Color& rColor )
     118                 :            : {
     119                 :         18 :     delete pBackgroundColor;
     120                 :         18 :     pBackgroundColor = new Color( rColor );
     121                 :         18 : }
     122                 :            : 
     123                 :        627 : void ImpEditView::SetEditSelection( const EditSelection& rEditSelection )
     124                 :            : {
     125                 :            :     // set state before notification
     126                 :        627 :     aEditSelection = rEditSelection;
     127                 :            : 
     128 [ +  + ][ +  - ]:        627 :     if ( pEditEngine->pImpEditEngine->GetNotifyHdl().IsSet() )
     129                 :            :     {
     130                 :        142 :         EENotify aNotify( EE_NOTIFY_TEXTVIEWSELECTIONCHANGED );
     131                 :        142 :         aNotify.pEditEngine = pEditEngine;
     132                 :        142 :         aNotify.pEditView = GetEditViewPtr();
     133         [ +  - ]:        142 :         pEditEngine->pImpEditEngine->CallNotify( aNotify );
     134                 :            :     }
     135                 :        627 : }
     136                 :            : 
     137                 :            : 
     138                 :       1115 : void ImpEditView::DrawSelection( EditSelection aTmpSel, Region* pRegion )
     139                 :            : {
     140         [ +  + ]:       1115 :     if ( GetSelectionMode() == EE_SELMODE_HIDDEN )
     141                 :            :         return;
     142                 :            : 
     143                 :            :     // It must be ensured before rendering the selection, that the contents of
     144                 :            :     // the window is completely valid! Must be here so that in any case if
     145                 :            :     // empty, then later on two-Paint Events! Must be done even before the
     146                 :            :     // query from bUpdate, if after Invalidate paints still in the queue,
     147                 :            :     // but someone switches the update mode!
     148                 :            : 
     149                 :            :     // pRegion: When not NULL, then only calculate Region.
     150                 :       1111 :     PolyPolygon* pPolyPoly = NULL;
     151         [ -  + ]:       1111 :     if ( pRegion )
     152 [ #  # ][ #  # ]:          0 :         pPolyPoly = new PolyPolygon;
     153                 :            : 
     154                 :       1111 :     sal_Bool bClipRegion = pOutWin->IsClipRegion();
     155         [ +  - ]:       1111 :     Region aOldRegion = pOutWin->GetClipRegion();
     156                 :            : 
     157         [ +  - ]:       1111 :     if ( !pRegion )
     158                 :            :     {
     159         [ +  + ]:       1111 :         if ( pEditEngine->pImpEditEngine->GetUpdateMode() == sal_False )
     160                 :            :             return;
     161         [ +  - ]:       1069 :         if ( pEditEngine->pImpEditEngine->IsInUndo() )
     162                 :            :             return;
     163                 :            : 
     164 [ +  - ][ -  + ]:       1069 :         if ( !aTmpSel.HasRange() )
     165                 :            :             return;
     166                 :            : 
     167                 :            :         // aTmpOutArea: if OutputArea > Paper width and
     168                 :            :         // Text > Paper width ( over large fields )
     169                 :          0 :         Rectangle aTmpOutArea( aOutArea );
     170 [ #  # ][ #  # ]:          0 :         if ( aTmpOutArea.GetWidth() > pEditEngine->pImpEditEngine->GetPaperSize().Width() )
     171                 :          0 :             aTmpOutArea.Right() = aTmpOutArea.Left() + pEditEngine->pImpEditEngine->GetPaperSize().Width();
     172         [ #  # ]:          0 :         pOutWin->IntersectClipRegion( aTmpOutArea );
     173                 :            : 
     174 [ #  # ][ #  # ]:          0 :         if ( pOutWin->GetCursor() )
     175 [ #  # ][ #  # ]:       1111 :             pOutWin->GetCursor()->Hide();
     176                 :            :     }
     177                 :            : 
     178                 :            :     DBG_ASSERT( !pEditEngine->IsIdleFormatterActive(), "DrawSelection: Not formatted!" );
     179 [ #  # ][ #  # ]:          0 :     aTmpSel.Adjust( pEditEngine->GetEditDoc() );
     180                 :            : 
     181         [ #  # ]:          0 :     ContentNode* pStartNode = aTmpSel.Min().GetNode();
     182         [ #  # ]:          0 :     ContentNode* pEndNode = aTmpSel.Max().GetNode();
     183 [ #  # ][ #  # ]:          0 :     sal_uInt16 nStartPara = pEditEngine->GetEditDoc().GetPos( pStartNode );
     184 [ #  # ][ #  # ]:          0 :     sal_uInt16 nEndPara = pEditEngine->GetEditDoc().GetPos( pEndNode );
     185         [ #  # ]:          0 :     for ( sal_uInt16 nPara = nStartPara; nPara <= nEndPara; nPara++ )
     186                 :            :     {
     187 [ #  # ][ #  # ]:          0 :         ParaPortion* pTmpPortion = pEditEngine->GetParaPortions().SafeGetObject( nPara );
     188                 :            :         DBG_ASSERT( pTmpPortion, "Portion in Selection not found!" );
     189                 :            :         DBG_ASSERT( !pTmpPortion->IsInvalid(), "Portion in Selection not formatted!" );
     190                 :            : 
     191 [ #  # ][ #  # ]:          0 :         if ( !pTmpPortion->IsVisible() || pTmpPortion->IsInvalid() )
                 [ #  # ]
     192                 :          0 :             continue;
     193                 :            : 
     194 [ #  # ][ #  # ]:          0 :         long nParaStart = pEditEngine->GetParaPortions().GetYOffset( pTmpPortion );
     195         [ #  # ]:          0 :         if ( ( nParaStart + pTmpPortion->GetHeight() ) < GetVisDocTop() )
     196                 :          0 :             continue;
     197 [ #  # ][ #  # ]:          0 :         if ( nParaStart > GetVisDocBottom() )
     198                 :          0 :             break;
     199                 :            : 
     200                 :          0 :         sal_uInt16 nStartLine = 0;
     201         [ #  # ]:          0 :         sal_uInt16 nEndLine = pTmpPortion->GetLines().Count() -1;
     202         [ #  # ]:          0 :         if ( nPara == nStartPara )
     203         [ #  # ]:          0 :             nStartLine = pTmpPortion->GetLines().FindLine( aTmpSel.Min().GetIndex(), sal_False );
     204         [ #  # ]:          0 :         if ( nPara == nEndPara )
     205         [ #  # ]:          0 :             nEndLine = pTmpPortion->GetLines().FindLine( aTmpSel.Max().GetIndex(), sal_True );
     206                 :            : 
     207         [ #  # ]:          0 :         for ( sal_uInt16 nLine = nStartLine; nLine <= nEndLine; nLine++ )
     208                 :            :         {
     209         [ #  # ]:          0 :             const EditLine* pLine = pTmpPortion->GetLines()[nLine];
     210                 :            :             DBG_ASSERT( pLine, "Line not found: DrawSelection()" );
     211                 :            : 
     212                 :          0 :             sal_Bool bPartOfLine = sal_False;
     213                 :          0 :             sal_uInt16 nStartIndex = pLine->GetStart();
     214                 :          0 :             sal_uInt16 nEndIndex = pLine->GetEnd();
     215 [ #  # ][ #  # ]:          0 :             if ( ( nPara == nStartPara ) && ( nLine == nStartLine ) && ( nStartIndex != aTmpSel.Min().GetIndex() ) )
         [ #  # ][ #  # ]
     216                 :            :             {
     217                 :          0 :                 nStartIndex = aTmpSel.Min().GetIndex();
     218                 :          0 :                 bPartOfLine = sal_True;
     219                 :            :             }
     220 [ #  # ][ #  # ]:          0 :             if ( ( nPara == nEndPara ) && ( nLine == nEndLine ) && ( nEndIndex != aTmpSel.Max().GetIndex() ) )
         [ #  # ][ #  # ]
     221                 :            :             {
     222                 :          0 :                 nEndIndex = aTmpSel.Max().GetIndex();
     223                 :          0 :                 bPartOfLine = sal_True;
     224                 :            :             }
     225                 :            : 
     226                 :            :             // Can happen if at the beginning of a wrapped line.
     227         [ #  # ]:          0 :             if ( nEndIndex < nStartIndex )
     228                 :          0 :                 nEndIndex = nStartIndex;
     229                 :            : 
     230         [ #  # ]:          0 :             Rectangle aTmpRec( pEditEngine->pImpEditEngine->GetEditCursor( pTmpPortion, nStartIndex ) );
     231                 :          0 :             Point aTopLeft( aTmpRec.TopLeft() );
     232         [ #  # ]:          0 :             Point aBottomRight( aTmpRec.BottomRight() );
     233                 :            : 
     234                 :          0 :             aTopLeft.Y() += nParaStart;
     235                 :          0 :             aBottomRight.Y() += nParaStart;
     236                 :            : 
     237                 :            :             // Only paint if in the visible range ...
     238 [ #  # ][ #  # ]:          0 :             if ( aTopLeft.Y() > GetVisDocBottom() )
     239                 :            :                 break;
     240                 :            : 
     241         [ #  # ]:          0 :             if ( aBottomRight.Y() < GetVisDocTop() )
     242                 :          0 :                 continue;
     243                 :            : 
     244                 :            :             // Now that we have Bidi, the first/last index doesn't have to be the 'most outside' postion
     245         [ #  # ]:          0 :             if ( !bPartOfLine )
     246                 :            :             {
     247         [ #  # ]:          0 :                 Range aLineXPosStartEnd = pEditEngine->GetLineXPosStartEnd(pTmpPortion, pLine);
     248                 :          0 :                 aTopLeft.X() = aLineXPosStartEnd.Min();
     249                 :          0 :                 aBottomRight.X() = aLineXPosStartEnd.Max();
     250         [ #  # ]:          0 :                 ImplDrawHighlightRect( pOutWin, aTopLeft, aBottomRight, pPolyPoly );
     251                 :            :             }
     252                 :            :             else
     253                 :            :             {
     254                 :          0 :                 sal_uInt16 nTmpStartIndex = nStartIndex;
     255                 :            :                 sal_uInt16 nWritingDirStart, nTmpEndIndex;
     256                 :            : 
     257         [ #  # ]:          0 :                 while ( nTmpStartIndex < nEndIndex )
     258                 :            :                 {
     259         [ #  # ]:          0 :                     pEditEngine->pImpEditEngine->GetRightToLeft( nPara, nTmpStartIndex+1, &nWritingDirStart, &nTmpEndIndex );
     260         [ #  # ]:          0 :                     if ( nTmpEndIndex > nEndIndex )
     261                 :          0 :                         nTmpEndIndex = nEndIndex;
     262                 :            : 
     263                 :            :                     DBG_ASSERT( nTmpEndIndex > nTmpStartIndex, "DrawSelection, Start >= End?" );
     264                 :            : 
     265         [ #  # ]:          0 :                     long nX1 = pEditEngine->GetXPos(pTmpPortion, pLine, nTmpStartIndex, true);
     266         [ #  # ]:          0 :                     long nX2 = pEditEngine->GetXPos(pTmpPortion, pLine, nTmpEndIndex);
     267                 :            : 
     268                 :          0 :                     Point aPt1( Min( nX1, nX2 ), aTopLeft.Y() );
     269                 :          0 :                     Point aPt2( Max( nX1, nX2 ), aBottomRight.Y() );
     270                 :            : 
     271         [ #  # ]:          0 :                     ImplDrawHighlightRect( pOutWin, aPt1, aPt2, pPolyPoly );
     272                 :            : 
     273                 :          0 :                     nTmpStartIndex = nTmpEndIndex;
     274                 :            :                 }
     275                 :            :             }
     276                 :            : 
     277                 :            :         }
     278                 :            :     }
     279                 :            : 
     280         [ #  # ]:          0 :     if ( pRegion )
     281                 :            :     {
     282 [ #  # ][ #  # ]:          0 :         *pRegion = Region( *pPolyPoly );
                 [ #  # ]
     283 [ #  # ][ #  # ]:          0 :         delete pPolyPoly;
     284                 :            :     }
     285                 :            :     else
     286                 :            :     {
     287 [ #  # ][ #  # ]:          0 :         if ( pOutWin->GetCursor() )
     288 [ #  # ][ #  # ]:          0 :             pOutWin->GetCursor()->Show();
     289                 :            : 
     290         [ #  # ]:          0 :         if ( bClipRegion )
     291         [ #  # ]:          0 :             pOutWin->SetClipRegion( aOldRegion );
     292                 :            :         else
     293         [ #  # ]:          0 :             pOutWin->SetClipRegion();
     294 [ +  - ][ -  + ]:       1115 :     }
     295                 :            : }
     296                 :            : 
     297                 :          0 : void ImpEditView::ImplDrawHighlightRect( Window* _pOutWin, const Point& rDocPosTopLeft, const Point& rDocPosBottomRight, PolyPolygon* pPolyPoly )
     298                 :            : {
     299         [ #  # ]:          0 :     if ( rDocPosTopLeft.X() != rDocPosBottomRight.X() )
     300                 :            :     {
     301 [ #  # ][ #  # ]:          0 :         sal_Bool bPixelMode = _pOutWin->GetMapMode() == MAP_PIXEL;
                 [ #  # ]
     302                 :            : 
     303                 :          0 :         Point aPnt1( GetWindowPos( rDocPosTopLeft ) );
     304                 :          0 :         Point aPnt2( GetWindowPos( rDocPosBottomRight ) );
     305                 :            : 
     306         [ #  # ]:          0 :         if ( !IsVertical() )
     307                 :            :         {
     308         [ #  # ]:          0 :             lcl_AllignToPixel( aPnt1, _pOutWin, +1, 0 );
     309 [ #  # ][ #  # ]:          0 :             lcl_AllignToPixel( aPnt2, _pOutWin, 0, ( bPixelMode ? 0 : -1 ) );
     310                 :            :         }
     311                 :            :         else
     312                 :            :         {
     313         [ #  # ]:          0 :             lcl_AllignToPixel( aPnt1, _pOutWin, 0, +1 );
     314         [ #  # ]:          0 :             lcl_AllignToPixel( aPnt2, _pOutWin, ( bPixelMode ? 0 : +1 ), 0 );
     315                 :            :         }
     316                 :            : 
     317         [ #  # ]:          0 :         Rectangle aRect( aPnt1, aPnt2 );
     318         [ #  # ]:          0 :         if ( pPolyPoly )
     319                 :            :         {
     320         [ #  # ]:          0 :             Polygon aTmpPoly( 4 );
     321         [ #  # ]:          0 :             aTmpPoly[0] = aRect.TopLeft();
     322 [ #  # ][ #  # ]:          0 :             aTmpPoly[1] = aRect.TopRight();
     323 [ #  # ][ #  # ]:          0 :             aTmpPoly[2] = aRect.BottomRight();
     324 [ #  # ][ #  # ]:          0 :             aTmpPoly[3] = aRect.BottomLeft();
     325 [ #  # ][ #  # ]:          0 :             pPolyPoly->Insert( aTmpPoly );
     326                 :            :         }
     327                 :            :         else
     328                 :            :         {
     329         [ #  # ]:          0 :             _pOutWin->Invert( aRect );
     330                 :            :         }
     331                 :            :     }
     332                 :          0 : }
     333                 :            : 
     334                 :            : 
     335                 :      10667 : sal_Bool ImpEditView::IsVertical() const
     336                 :            : {
     337                 :      10667 :     return pEditEngine->pImpEditEngine->IsVertical();
     338                 :            : }
     339                 :            : 
     340                 :       1932 : Rectangle ImpEditView::GetVisDocArea() const
     341                 :            : {
     342                 :       1932 :     return Rectangle( GetVisDocLeft(), GetVisDocTop(), GetVisDocRight(), GetVisDocBottom() );
     343                 :            : }
     344                 :            : 
     345                 :        271 : Point ImpEditView::GetDocPos( const Point& rWindowPos ) const
     346                 :            : {
     347                 :            :     // Window Position => Position Document
     348                 :        271 :     Point aPoint;
     349                 :            : 
     350         [ +  - ]:        271 :     if ( !pEditEngine->pImpEditEngine->IsVertical() )
     351                 :            :     {
     352                 :        271 :         aPoint.X() = rWindowPos.X() - aOutArea.Left() + GetVisDocLeft();
     353                 :        271 :         aPoint.Y() = rWindowPos.Y() - aOutArea.Top() + GetVisDocTop();
     354                 :            :     }
     355                 :            :     else
     356                 :            :     {
     357                 :          0 :         aPoint.X() = rWindowPos.Y() - aOutArea.Top() + GetVisDocLeft();
     358                 :          0 :         aPoint.Y() = aOutArea.Right() - rWindowPos.X() + GetVisDocTop();
     359                 :            :     }
     360                 :            : 
     361                 :        271 :     return aPoint;
     362                 :            : }
     363                 :            : 
     364                 :       1463 : Point ImpEditView::GetWindowPos( const Point& rDocPos ) const
     365                 :            : {
     366                 :            :     // Document position => window position
     367                 :       1463 :     Point aPoint;
     368                 :            : 
     369         [ +  - ]:       1463 :     if ( !pEditEngine->pImpEditEngine->IsVertical() )
     370                 :            :     {
     371                 :       1463 :         aPoint.X() = rDocPos.X() + aOutArea.Left() - GetVisDocLeft();
     372                 :       1463 :         aPoint.Y() = rDocPos.Y() + aOutArea.Top() - GetVisDocTop();
     373                 :            :     }
     374                 :            :     else
     375                 :            :     {
     376                 :          0 :         aPoint.X() = aOutArea.Right() - rDocPos.Y() + GetVisDocTop();
     377                 :          0 :         aPoint.Y() = rDocPos.X() + aOutArea.Top() - GetVisDocLeft();
     378                 :            :     }
     379                 :            : 
     380                 :       1463 :     return aPoint;
     381                 :            : }
     382                 :            : 
     383                 :       1463 : Rectangle ImpEditView::GetWindowPos( const Rectangle& rDocRect ) const
     384                 :            : {
     385                 :            :     // Document position => window position
     386                 :       1463 :     Point aPos( GetWindowPos( rDocRect.TopLeft() ) );
     387         [ +  - ]:       1463 :     Size aSz = rDocRect.GetSize();
     388         [ +  - ]:       1463 :     Rectangle aRect;
     389         [ +  - ]:       1463 :     if ( !pEditEngine->pImpEditEngine->IsVertical() )
     390                 :            :     {
     391         [ +  - ]:       1463 :         aRect = Rectangle( aPos, aSz );
     392                 :            :     }
     393                 :            :     else
     394                 :            :     {
     395                 :          0 :         Point aNewPos( aPos.X()-aSz.Height(), aPos.Y() );
     396         [ #  # ]:       1463 :         aRect = Rectangle( aNewPos, Size( aSz.Height(), aSz.Width() ) );
     397                 :            :     }
     398                 :       1463 :     return aRect;
     399                 :            : }
     400                 :            : 
     401                 :         44 : void ImpEditView::SetSelectionMode( EESelectionMode eNewMode )
     402                 :            : {
     403         [ +  + ]:         44 :     if ( eSelectionMode != eNewMode )
     404                 :            :     {
     405                 :         26 :         DrawSelection();
     406                 :         26 :         eSelectionMode = eNewMode;
     407                 :         26 :         DrawSelection();    // redraw
     408                 :            :     }
     409                 :         44 : }
     410                 :            : 
     411                 :        349 : void ImpEditView::SetOutputArea( const Rectangle& rRec )
     412                 :            : {
     413                 :            :     // should be better be aligned on pixels!
     414         [ +  - ]:        349 :     Rectangle aNewRec( pOutWin->LogicToPixel( rRec ) );
     415         [ +  - ]:        349 :     aNewRec = pOutWin->PixelToLogic( aNewRec );
     416                 :        349 :     aOutArea = aNewRec;
     417         [ +  + ]:        349 :     if ( aOutArea.Right() < aOutArea.Left() )
     418                 :         68 :         aOutArea.Right() = aOutArea.Left();
     419         [ +  + ]:        349 :     if ( aOutArea.Bottom() < aOutArea.Top() )
     420                 :         68 :         aOutArea.Bottom() = aOutArea.Top();
     421                 :            : 
     422         [ -  + ]:        349 :     if ( DoBigScroll() )
     423         [ #  # ]:          0 :         SetScrollDiffX( (sal_uInt16)aOutArea.GetWidth() * 3 / 10 );
     424                 :            :     else
     425         [ +  - ]:        349 :         SetScrollDiffX( (sal_uInt16)aOutArea.GetWidth() * 2 / 10 );
     426                 :        349 : }
     427                 :            : 
     428                 :          0 : void ImpEditView::ResetOutputArea( const Rectangle& rRec )
     429                 :            : {
     430                 :          0 :     Rectangle aCurArea( aOutArea );
     431         [ #  # ]:          0 :     SetOutputArea( rRec );
     432                 :            :     // Invalidate surrounding areas if in update mode of the engine on sal_True
     433 [ #  # ][ #  # ]:          0 :     if ( !aCurArea.IsEmpty() && pEditEngine->pImpEditEngine->GetUpdateMode() )
         [ #  # ][ #  # ]
     434                 :            :     {
     435                 :          0 :         long nMore = 0;
     436         [ #  # ]:          0 :         if ( DoInvalidateMore() )
     437         [ #  # ]:          0 :             nMore = GetWindow()->PixelToLogic( Size( nInvMore, 0 ) ).Width();
     438         [ #  # ]:          0 :         if ( aCurArea.Left() < aOutArea.Left() )
     439                 :            :         {
     440                 :            :             Rectangle aRect( aCurArea.TopLeft(),
     441 [ #  # ][ #  # ]:          0 :                 Size( aOutArea.Left()-aCurArea.Left(), aCurArea.GetHeight() ) );
     442         [ #  # ]:          0 :             if ( nMore )
     443                 :            :             {
     444                 :          0 :                 aRect.Left() -= nMore;
     445                 :          0 :                 aRect.Top() -= nMore;
     446                 :          0 :                 aRect.Bottom() += nMore;
     447                 :            :             }
     448         [ #  # ]:          0 :             GetWindow()->Invalidate( aRect );
     449                 :            :         }
     450         [ #  # ]:          0 :         if ( aCurArea.Right() > aOutArea.Right() )
     451                 :            :         {
     452                 :          0 :             long nW = aCurArea.Right() - aOutArea.Right();
     453         [ #  # ]:          0 :             Point aPos( aCurArea.TopRight() );
     454                 :          0 :             aPos.X() -= nW;
     455 [ #  # ][ #  # ]:          0 :             Rectangle aRect( aPos, Size( nW, aCurArea.GetHeight() ) );
     456         [ #  # ]:          0 :             if ( nMore )
     457                 :            :             {
     458                 :          0 :                 aRect.Right() += nMore;
     459                 :          0 :                 aRect.Top() -= nMore;
     460                 :          0 :                 aRect.Bottom() += nMore;
     461                 :            :             }
     462         [ #  # ]:          0 :             GetWindow()->Invalidate( aRect );
     463                 :            :         }
     464         [ #  # ]:          0 :         if ( aCurArea.Top() < aOutArea.Top() )
     465                 :            :         {
     466 [ #  # ][ #  # ]:          0 :             Rectangle aRect( aCurArea.TopLeft(), Size( aCurArea.GetWidth(), aOutArea.Top() - aCurArea.Top() ) );
     467         [ #  # ]:          0 :             if ( nMore )
     468                 :            :             {
     469                 :          0 :                 aRect.Top() -= nMore;
     470                 :          0 :                 aRect.Left() -= nMore;
     471                 :          0 :                 aRect.Right() += nMore;
     472                 :            :             }
     473         [ #  # ]:          0 :             GetWindow()->Invalidate( aRect );
     474                 :            :         }
     475         [ #  # ]:          0 :         if ( aCurArea.Bottom() > aOutArea.Bottom() )
     476                 :            :         {
     477                 :          0 :             long nH = aCurArea.Bottom() - aOutArea.Bottom();
     478         [ #  # ]:          0 :             Point aPos( aCurArea.BottomLeft() );
     479                 :          0 :             aPos.Y() -= nH;
     480 [ #  # ][ #  # ]:          0 :             Rectangle aRect( aPos, Size( aCurArea.GetWidth(), nH ) );
     481         [ #  # ]:          0 :             if ( nMore )
     482                 :            :             {
     483                 :          0 :                 aRect.Bottom() += nMore;
     484                 :          0 :                 aRect.Left() -= nMore;
     485                 :          0 :                 aRect.Right() += nMore;
     486                 :            :             }
     487                 :            : 
     488         [ #  # ]:          0 :             GetWindow()->Invalidate( aRect );
     489                 :            :         }
     490                 :            :     }
     491                 :          0 : }
     492                 :            : 
     493                 :          0 : void ImpEditView::RecalcOutputArea()
     494                 :            : {
     495                 :          0 :     Point aNewTopLeft( aOutArea.TopLeft() );
     496         [ #  # ]:          0 :     Size aNewSz( aOutArea.GetSize() );
     497                 :            : 
     498                 :            :     // X:
     499         [ #  # ]:          0 :     if ( DoAutoWidth() )
     500                 :            :     {
     501         [ #  # ]:          0 :         if ( pEditEngine->pImpEditEngine->GetStatus().AutoPageWidth() )
     502                 :          0 :             aNewSz.Width() = pEditEngine->pImpEditEngine->GetPaperSize().Width();
     503   [ #  #  #  # ]:          0 :         switch ( eAnchorMode )
     504                 :            :         {
     505                 :            :             case ANCHOR_TOP_LEFT:
     506                 :            :             case ANCHOR_VCENTER_LEFT:
     507                 :            :             case ANCHOR_BOTTOM_LEFT:
     508                 :            :             {
     509                 :          0 :                 aNewTopLeft.X() = aAnchorPoint.X();
     510                 :            :             }
     511                 :          0 :             break;
     512                 :            :             case ANCHOR_TOP_HCENTER:
     513                 :            :             case ANCHOR_VCENTER_HCENTER:
     514                 :            :             case ANCHOR_BOTTOM_HCENTER:
     515                 :            :             {
     516                 :          0 :                 aNewTopLeft.X() = aAnchorPoint.X() - aNewSz.Width() / 2;
     517                 :            :             }
     518                 :          0 :             break;
     519                 :            :             case ANCHOR_TOP_RIGHT:
     520                 :            :             case ANCHOR_VCENTER_RIGHT:
     521                 :            :             case ANCHOR_BOTTOM_RIGHT:
     522                 :            :             {
     523                 :          0 :                 aNewTopLeft.X() = aAnchorPoint.X() - aNewSz.Width() - 1;
     524                 :            :             }
     525                 :          0 :             break;
     526                 :            :         }
     527                 :            :     }
     528                 :            : 
     529                 :            :     // Y:
     530         [ #  # ]:          0 :     if ( DoAutoHeight() )
     531                 :            :     {
     532         [ #  # ]:          0 :         if ( pEditEngine->pImpEditEngine->GetStatus().AutoPageHeight() )
     533                 :          0 :             aNewSz.Height() = pEditEngine->pImpEditEngine->GetPaperSize().Height();
     534   [ #  #  #  # ]:          0 :         switch ( eAnchorMode )
     535                 :            :         {
     536                 :            :             case ANCHOR_TOP_LEFT:
     537                 :            :             case ANCHOR_TOP_HCENTER:
     538                 :            :             case ANCHOR_TOP_RIGHT:
     539                 :            :             {
     540                 :          0 :                 aNewTopLeft.Y() = aAnchorPoint.Y();
     541                 :            :             }
     542                 :          0 :             break;
     543                 :            :             case ANCHOR_VCENTER_LEFT:
     544                 :            :             case ANCHOR_VCENTER_HCENTER:
     545                 :            :             case ANCHOR_VCENTER_RIGHT:
     546                 :            :             {
     547                 :          0 :                 aNewTopLeft.Y() = aAnchorPoint.Y() - aNewSz.Height() / 2;
     548                 :            :             }
     549                 :          0 :             break;
     550                 :            :             case ANCHOR_BOTTOM_LEFT:
     551                 :            :             case ANCHOR_BOTTOM_HCENTER:
     552                 :            :             case ANCHOR_BOTTOM_RIGHT:
     553                 :            :             {
     554                 :          0 :                 aNewTopLeft.Y() = aAnchorPoint.Y() - aNewSz.Height() - 1;
     555                 :            :             }
     556                 :          0 :             break;
     557                 :            :         }
     558                 :            :     }
     559 [ #  # ][ #  # ]:          0 :     ResetOutputArea( Rectangle( aNewTopLeft, aNewSz ) );
     560                 :          0 : }
     561                 :            : 
     562                 :          0 : void ImpEditView::SetAnchorMode( EVAnchorMode eMode )
     563                 :            : {
     564                 :          0 :     eAnchorMode = eMode;
     565                 :          0 :     CalcAnchorPoint();
     566                 :          0 : }
     567                 :            : 
     568                 :        349 : void ImpEditView::CalcAnchorPoint()
     569                 :            : {
     570                 :            :     // GetHeight() and GetWidth() -1, because rectangle calculation not prefered.
     571                 :            : 
     572                 :            :     // X:
     573   [ +  -  -  - ]:        349 :     switch ( eAnchorMode )
     574                 :            :     {
     575                 :            :         case ANCHOR_TOP_LEFT:
     576                 :            :         case ANCHOR_VCENTER_LEFT:
     577                 :            :         case ANCHOR_BOTTOM_LEFT:
     578                 :            :         {
     579                 :        349 :             aAnchorPoint.X() = aOutArea.Left();
     580                 :            :         }
     581                 :        349 :         break;
     582                 :            :         case ANCHOR_TOP_HCENTER:
     583                 :            :         case ANCHOR_VCENTER_HCENTER:
     584                 :            :         case ANCHOR_BOTTOM_HCENTER:
     585                 :            :         {
     586                 :          0 :             aAnchorPoint.X() = aOutArea.Left() + (aOutArea.GetWidth()-1) / 2;
     587                 :            :         }
     588                 :          0 :         break;
     589                 :            :         case ANCHOR_TOP_RIGHT:
     590                 :            :         case ANCHOR_VCENTER_RIGHT:
     591                 :            :         case ANCHOR_BOTTOM_RIGHT:
     592                 :            :         {
     593                 :          0 :             aAnchorPoint.X() = aOutArea.Right();
     594                 :            :         }
     595                 :          0 :         break;
     596                 :            :     }
     597                 :            : 
     598                 :            :     // Y:
     599   [ +  -  -  - ]:        349 :     switch ( eAnchorMode )
     600                 :            :     {
     601                 :            :         case ANCHOR_TOP_LEFT:
     602                 :            :         case ANCHOR_TOP_HCENTER:
     603                 :            :         case ANCHOR_TOP_RIGHT:
     604                 :            :         {
     605                 :        349 :             aAnchorPoint.Y() = aOutArea.Top();
     606                 :            :         }
     607                 :        349 :         break;
     608                 :            :         case ANCHOR_VCENTER_LEFT:
     609                 :            :         case ANCHOR_VCENTER_HCENTER:
     610                 :            :         case ANCHOR_VCENTER_RIGHT:
     611                 :            :         {
     612                 :          0 :             aAnchorPoint.Y() = aOutArea.Top() + (aOutArea.GetHeight()-1) / 2;
     613                 :            :         }
     614                 :          0 :         break;
     615                 :            :         case ANCHOR_BOTTOM_LEFT:
     616                 :            :         case ANCHOR_BOTTOM_HCENTER:
     617                 :            :         case ANCHOR_BOTTOM_RIGHT:
     618                 :            :         {
     619                 :          0 :             aAnchorPoint.Y() = aOutArea.Bottom() - 1;
     620                 :            :         }
     621                 :          0 :         break;
     622                 :            :     }
     623                 :        349 : }
     624                 :            : 
     625                 :       1377 : void ImpEditView::ShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, sal_uInt16 nShowCursorFlags )
     626                 :            : {
     627                 :            :     // No ShowCursor in an empty View ...
     628 [ +  + ][ +  - ]:       1377 :     if ( ( aOutArea.Left() >= aOutArea.Right() ) && ( aOutArea.Top() >= aOutArea.Bottom() ) )
                 [ +  + ]
     629                 :            :         return;
     630                 :            : 
     631         [ +  - ]:       1207 :     pEditEngine->CheckIdleFormatter();
     632 [ +  - ][ +  + ]:       1207 :     if (!pEditEngine->IsFormatted())
     633         [ +  - ]:         12 :         pEditEngine->pImpEditEngine->FormatDoc();
     634                 :            : 
     635                 :            :     // For some reasons I end up here during the formatting, if the Outliner
     636                 :            :     // is initialized in Paint, because no SetPool();
     637         [ +  - ]:       1207 :     if ( pEditEngine->pImpEditEngine->IsFormatting() )
     638                 :            :         return;
     639         [ +  + ]:       1207 :     if ( pEditEngine->pImpEditEngine->GetUpdateMode() == sal_False )
     640                 :            :         return;
     641         [ +  - ]:       1040 :     if ( pEditEngine->pImpEditEngine->IsInUndo() )
     642                 :            :         return;
     643                 :            : 
     644 [ +  - ][ +  - ]:       1040 :     if ( pOutWin->GetCursor() != GetCursor() )
                 [ +  + ]
     645 [ +  - ][ +  - ]:        257 :         pOutWin->SetCursor( GetCursor() );
     646                 :            : 
     647         [ +  - ]:       1040 :     EditPaM aPaM( aEditSelection.Max() );
     648                 :            : 
     649                 :       1040 :     sal_uInt16 nTextPortionStart = 0;
     650 [ +  - ][ +  - ]:       1040 :     sal_uInt16 nPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
                 [ +  - ]
     651         [ +  - ]:       1040 :     if (nPara == USHRT_MAX) // #i94322
     652                 :            :         return;
     653                 :            : 
     654 [ +  - ][ +  - ]:       1040 :     const ParaPortion* pParaPortion = pEditEngine->GetParaPortions()[nPara];
     655                 :            : 
     656                 :       1040 :     nShowCursorFlags |= nExtraCursorFlags;
     657                 :            : 
     658                 :       1040 :     nShowCursorFlags |= GETCRSR_TXTONLY;
     659                 :            : 
     660                 :            :     // Use CursorBidiLevel 0/1 in meaning of
     661                 :            :     // 0: prefer portion end, normal mode
     662                 :            :     // 1: prefer portion start
     663                 :            : 
     664 [ -  + ][ #  # ]:       1040 :     if ( ( GetCursorBidiLevel() != CURSOR_BIDILEVEL_DONTKNOW ) && GetCursorBidiLevel() )
                 [ -  + ]
     665                 :            :     {
     666                 :          0 :         nShowCursorFlags |= GETCRSR_PREFERPORTIONSTART;
     667                 :            :     }
     668                 :            : 
     669 [ +  - ][ +  - ]:       1040 :     Rectangle aEditCursor = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, nShowCursorFlags );
     670 [ -  + ][ #  # ]:       1040 :     if ( !IsInsertMode() && !aEditSelection.HasRange() )
         [ #  # ][ -  + ]
     671                 :            :     {
     672 [ #  # ][ #  # ]:          0 :         if ( aPaM.GetNode()->Len() && ( aPaM.GetIndex() < aPaM.GetNode()->Len() ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     673                 :            :         {
     674                 :            :             // If we are behind a portion, and the next portion has other direction, we must change position...
     675 [ #  # ][ #  # ]:          0 :             aEditCursor.Left() = aEditCursor.Right() = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GETCRSR_TXTONLY|GETCRSR_PREFERPORTIONSTART ).Left();
     676                 :            : 
     677         [ #  # ]:          0 :             sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, sal_True );
     678         [ #  # ]:          0 :             const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
     679         [ #  # ]:          0 :             if ( pTextPortion->GetKind() == PORTIONKIND_TAB )
     680                 :            :             {
     681                 :          0 :                 aEditCursor.Right() += pTextPortion->GetSize().Width();
     682                 :            :             }
     683                 :            :             else
     684                 :            :             {
     685         [ #  # ]:          0 :                 EditPaM aNext = pEditEngine->CursorRight( aPaM, (sal_uInt16)i18n::CharacterIteratorMode::SKIPCELL );
     686 [ #  # ][ #  # ]:          0 :                 Rectangle aTmpRect = pEditEngine->pImpEditEngine->PaMtoEditCursor( aNext, GETCRSR_TXTONLY );
     687         [ #  # ]:          0 :                 if ( aTmpRect.Top() != aEditCursor.Top() )
     688 [ #  # ][ #  # ]:          0 :                     aTmpRect = pEditEngine->pImpEditEngine->PaMtoEditCursor( aNext, GETCRSR_TXTONLY|GETCRSR_ENDOFLINE );
     689                 :          0 :                 aEditCursor.Right() = aTmpRect.Left();
     690                 :            :             }
     691                 :            :         }
     692                 :            :     }
     693 [ +  - ][ +  - ]:       1040 :     long nMaxHeight = !IsVertical() ? aOutArea.GetHeight() : aOutArea.GetWidth();
                 [ #  # ]
     694 [ +  - ][ +  + ]:       1040 :     if ( aEditCursor.GetHeight() > nMaxHeight )
     695                 :            :     {
     696                 :        896 :         aEditCursor.Bottom() = aEditCursor.Top() + nMaxHeight - 1;
     697                 :            :     }
     698         [ +  + ]:       1040 :     if ( bGotoCursor  ) // && (!pEditEngine->pImpEditEngine->GetStatus().AutoPageSize() ) )
     699                 :            :     {
     700                 :            :         // check if scrolling is necessary...
     701                 :            :         // if scrolling, then update () and Scroll ()!
     702                 :        447 :         long nDocDiffX = 0;
     703                 :        447 :         long nDocDiffY = 0;
     704                 :            : 
     705         [ +  - ]:        447 :         Rectangle aTmpVisArea( GetVisDocArea() );
     706                 :            :         // aTmpOutArea: if OutputArea > Paper width and
     707                 :            :         // Text > Paper width ( over large fields )
     708         [ +  - ]:        447 :         long nMaxTextWidth = !IsVertical() ? pEditEngine->pImpEditEngine->GetPaperSize().Width() : pEditEngine->pImpEditEngine->GetPaperSize().Height();
     709 [ +  - ][ -  + ]:        447 :         if ( aTmpVisArea.GetWidth() > nMaxTextWidth )
     710                 :          0 :             aTmpVisArea.Right() = aTmpVisArea.Left() + nMaxTextWidth;
     711                 :            : 
     712         [ -  + ]:        447 :         if ( aEditCursor.Bottom() > aTmpVisArea.Bottom() )
     713                 :            :         {   // Scroll up, here positive
     714                 :          0 :             nDocDiffY = aEditCursor.Bottom() - aTmpVisArea.Bottom();
     715                 :            :         }
     716         [ -  + ]:        447 :         else if ( aEditCursor.Top() < aTmpVisArea.Top() )
     717                 :            :         {   // Scroll down, here negative
     718                 :          0 :             nDocDiffY = aEditCursor.Top() - aTmpVisArea.Top();
     719                 :            :         }
     720                 :            : 
     721         [ +  + ]:        447 :         if ( aEditCursor.Right() > aTmpVisArea.Right() )
     722                 :            :         {
     723                 :            :             // Scroll left, positiv
     724                 :          6 :             nDocDiffX = aEditCursor.Right() - aTmpVisArea.Right();
     725                 :            :             // Can it be a little more?
     726         [ +  - ]:          6 :             if ( aEditCursor.Right() < ( nMaxTextWidth - GetScrollDiffX() ) )
     727                 :          6 :                 nDocDiffX += GetScrollDiffX();
     728                 :            :             else
     729                 :            :             {
     730                 :          0 :                 long n = nMaxTextWidth - aEditCursor.Right();
     731                 :            :                 // If MapMode != RefMapMode then the EditCursor can go beyond
     732                 :            :                 // the paper width!
     733                 :          0 :                 nDocDiffX += ( n > 0 ? n : -n );
     734                 :            :             }
     735                 :            :         }
     736         [ -  + ]:        441 :         else if ( aEditCursor.Left() < aTmpVisArea.Left() )
     737                 :            :         {
     738                 :            :             // Scroll right, negative:
     739                 :          0 :             nDocDiffX = aEditCursor.Left() - aTmpVisArea.Left();
     740                 :            :             // Can it be a little more?
     741         [ #  # ]:          0 :             if ( aEditCursor.Left() > ( - (long)GetScrollDiffX() ) )
     742                 :          0 :                 nDocDiffX -= GetScrollDiffX();
     743                 :            :             else
     744                 :          0 :                 nDocDiffX -= aEditCursor.Left();
     745                 :            :         }
     746         [ +  + ]:        447 :         if ( aPaM.GetIndex() == 0 )     // Olli needed for the Outliner
     747                 :            :         {
     748                 :            :             // But make sure that the cursor is not leaving visible area
     749                 :            :             // because of this!
     750 [ +  - ][ +  - ]:        417 :             if ( aEditCursor.Left() < aTmpVisArea.GetWidth() )
     751                 :            :             {
     752                 :        417 :                 nDocDiffX = -aTmpVisArea.Left();
     753                 :            :             }
     754                 :            :         }
     755                 :            : 
     756         [ +  + ]:        447 :         if ( nDocDiffX | nDocDiffY )
     757                 :            :         {
     758         [ -  + ]:          6 :             long nDiffX = !IsVertical() ? nDocDiffX : -nDocDiffY;
     759         [ +  - ]:          6 :             long nDiffY = !IsVertical() ? nDocDiffY : nDocDiffX;
     760                 :            : 
     761                 :            :             // Negative: Back to the top or left edge
     762 [ +  - ][ -  + ]:          6 :             if ( ( Abs( nDiffY ) > pEditEngine->GetOnePixelInRef() ) && DoBigScroll() )
         [ #  # ][ -  + ]
     763                 :            :             {
     764         [ #  # ]:          0 :                 long nH = aOutArea.GetHeight() / 4;
     765 [ #  # ][ #  # ]:          0 :                 if ( ( nH > aEditCursor.GetHeight() ) && ( Abs( nDiffY ) < nH ) )
         [ #  # ][ #  # ]
     766                 :            :                 {
     767         [ #  # ]:          0 :                     if ( nDiffY < 0 )
     768                 :          0 :                         nDiffY -= nH;
     769                 :            :                     else
     770                 :          0 :                         nDiffY += nH;
     771                 :            :                 }
     772                 :            :             }
     773                 :            : 
     774 [ +  - ][ +  - ]:          6 :             if ( ( Abs( nDiffX ) > pEditEngine->GetOnePixelInRef() ) && DoBigScroll() )
         [ -  + ][ -  + ]
     775                 :            :             {
     776         [ #  # ]:          0 :                 long nW = aOutArea.GetWidth() / 4;
     777         [ #  # ]:          0 :                 if ( Abs( nDiffX ) < nW )
     778                 :            :                 {
     779         [ #  # ]:          0 :                     if ( nDiffY < 0 )
     780                 :          0 :                         nDiffY -= nW;
     781                 :            :                     else
     782                 :          0 :                         nDiffY += nW;
     783                 :            :                 }
     784                 :            :             }
     785                 :            : 
     786         [ +  - ]:          6 :             if ( nDiffX )
     787 [ +  - ][ +  - ]:          6 :                 pEditEngine->GetInternalEditStatus().GetStatusWord() = pEditEngine->GetInternalEditStatus().GetStatusWord() | EE_STAT_HSCROLL;
     788         [ -  + ]:          6 :             if ( nDiffY )
     789 [ #  # ][ #  # ]:          0 :                 pEditEngine->GetInternalEditStatus().GetStatusWord() = pEditEngine->GetInternalEditStatus().GetStatusWord() | EE_STAT_VSCROLL;
     790         [ +  - ]:          6 :             Scroll( -nDiffX, -nDiffY );
     791         [ +  - ]:        447 :             pEditEngine->pImpEditEngine->DelayedCallStatusHdl();
     792                 :            :         }
     793                 :            :     }
     794                 :            : 
     795                 :            :     // Cursor may trim a little ...
     796 [ +  - ][ +  - ]:       2080 :     if ( ( aEditCursor.Bottom() > GetVisDocTop() ) &&
                 [ +  - ]
     797         [ +  - ]:       1040 :          ( aEditCursor.Top() < GetVisDocBottom() ) )
     798                 :            :     {
     799 [ +  - ][ -  + ]:       1040 :         if ( aEditCursor.Bottom() > GetVisDocBottom() )
     800         [ #  # ]:          0 :             aEditCursor.Bottom() = GetVisDocBottom();
     801         [ -  + ]:       1040 :         if ( aEditCursor.Top() < GetVisDocTop() )
     802                 :          0 :             aEditCursor.Top() = GetVisDocTop();
     803                 :            :     }
     804                 :            : 
     805         [ +  - ]:       1040 :     long nOnePixel = pOutWin->PixelToLogic( Size( 1, 0 ) ).Width();
     806                 :            : 
     807   [ +  -  +  - ]:       4160 :     if ( /* pEditEngine->pImpEditEngine->GetStatus().AutoPageSize() || */
         [ +  - ][ +  - ]
                 [ +  - ]
     808                 :       1040 :          ( ( aEditCursor.Top() + nOnePixel >= GetVisDocTop() ) &&
     809         [ +  - ]:       1040 :          ( aEditCursor.Bottom() - nOnePixel <= GetVisDocBottom() ) &&
     810                 :       1040 :          ( aEditCursor.Left() + nOnePixel >= GetVisDocLeft() ) &&
     811         [ +  - ]:       1040 :          ( aEditCursor.Right() - nOnePixel <= GetVisDocRight() ) ) )
     812                 :            :     {
     813         [ +  - ]:       1040 :         Rectangle aCursorRect = GetWindowPos( aEditCursor );
     814 [ +  - ][ +  - ]:       1040 :         GetCursor()->SetPos( aCursorRect.TopLeft() );
     815         [ +  - ]:       1040 :         Size aCursorSz( aCursorRect.GetSize() );
     816                 :            :         // Rectangle is inclusive
     817                 :       1040 :         aCursorSz.Width()--;
     818                 :       1040 :         aCursorSz.Height()--;
     819 [ #  # ][ +  - ]:       1040 :         if ( !aCursorSz.Width() || !aCursorSz.Height() )
                 [ -  + ]
     820                 :            :         {
     821                 :       1040 :             long nCursorSz = pOutWin->GetSettings().GetStyleSettings().GetCursorSize();
     822         [ +  - ]:       1040 :             nCursorSz = pOutWin->PixelToLogic( Size( nCursorSz, 0 ) ).Width();
     823         [ +  - ]:       1040 :             if ( !aCursorSz.Width() )
     824                 :       1040 :                 aCursorSz.Width() = nCursorSz;
     825         [ -  + ]:       1040 :             if ( !aCursorSz.Height() )
     826                 :          0 :                 aCursorSz.Height() = nCursorSz;
     827                 :            :         }
     828                 :            :         // #111036# Let VCL do orientation for cursor, otherwise problem when cursor has direction flag
     829         [ -  + ]:       1040 :         if ( IsVertical() )
     830                 :            :         {
     831                 :          0 :             Size aOldSz( aCursorSz );
     832                 :          0 :             aCursorSz.Width() = aOldSz.Height();
     833                 :          0 :             aCursorSz.Height() = aOldSz.Width();
     834 [ #  # ][ #  # ]:          0 :             GetCursor()->SetPos( aCursorRect.TopRight() );
                 [ #  # ]
     835 [ #  # ][ #  # ]:          0 :             GetCursor()->SetOrientation( 2700 );
     836                 :            :         }
     837                 :            :         else
     838                 :            :             // #i32593# Reset correct orientation in horizontal layout
     839 [ +  - ][ +  - ]:       1040 :             GetCursor()->SetOrientation( 0 );
     840                 :            : 
     841 [ +  - ][ +  - ]:       1040 :         GetCursor()->SetSize( aCursorSz );
     842                 :            : 
     843                 :       1040 :         unsigned char nCursorDir = CURSOR_DIRECTION_NONE;
     844 [ +  - ][ +  - ]:       1040 :         if ( IsInsertMode() && !aEditSelection.HasRange() && ( pEditEngine->pImpEditEngine->HasDifferentRTLLevels( aPaM.GetNode() ) ) )
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
                 [ -  + ]
     845                 :            :         {
     846         [ #  # ]:          0 :             sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, nShowCursorFlags & GETCRSR_PREFERPORTIONSTART ? sal_True : sal_False );
     847         [ #  # ]:          0 :             const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
     848                 :          0 :             sal_uInt16 nRTLLevel = pTextPortion->GetRightToLeft();
     849         [ #  # ]:          0 :             if ( nRTLLevel%2 )
     850                 :          0 :                 nCursorDir = CURSOR_DIRECTION_RTL;
     851                 :            :             else
     852                 :          0 :                 nCursorDir = CURSOR_DIRECTION_LTR;
     853                 :            : 
     854                 :            :         }
     855 [ +  - ][ +  - ]:       1040 :         GetCursor()->SetDirection( nCursorDir );
     856                 :            : 
     857         [ +  + ]:       1040 :         if ( bForceVisCursor )
     858 [ +  - ][ +  - ]:        411 :             GetCursor()->Show();
     859                 :            :         {
     860         [ +  - ]:       1040 :             SvxFont aFont;
     861 [ +  - ][ +  - ]:       1040 :             pEditEngine->SeekCursor( aPaM.GetNode(), aPaM.GetIndex()+1, aFont );
     862                 :       1040 :             sal_uLong nContextFlags = INPUTCONTEXT_TEXT|INPUTCONTEXT_EXTTEXTINPUT;
     863 [ +  - ][ +  - ]:       1040 :             GetWindow()->SetInputContext( InputContext( aFont, nContextFlags ) );
         [ +  - ][ +  - ]
     864                 :            :         }
     865                 :            :     }
     866                 :            :     else
     867                 :            :     {
     868                 :          0 :         pEditEngine->pImpEditEngine->GetStatus().GetStatusWord() = pEditEngine->pImpEditEngine->GetStatus().GetStatusWord() | EE_STAT_CURSOROUT;
     869 [ #  # ][ #  # ]:          0 :         GetCursor()->Hide();
     870 [ #  # ][ #  # ]:          0 :         GetCursor()->SetPos( Point( -1, -1 ) );
     871 [ #  # ][ #  # ]:       1377 :         GetCursor()->SetSize( Size( 0, 0 ) );
     872                 :            :     }
     873                 :            : }
     874                 :            : 
     875                 :         79 : Pair ImpEditView::Scroll( long ndX, long ndY, sal_uInt8 nRangeCheck )
     876                 :            : {
     877                 :            :     DBG_ASSERT( pEditEngine->pImpEditEngine->IsFormatted(), "Scroll: Not formatted!" );
     878 [ +  + ][ +  - ]:         79 :     if ( !ndX && !ndY )
     879                 :         73 :         return Range( 0, 0 );
     880                 :            : 
     881                 :            : #ifdef DBG_UTIL
     882                 :            :     Rectangle aR( aOutArea );
     883                 :            :     aR = pOutWin->LogicToPixel( aR );
     884                 :            :     aR = pOutWin->PixelToLogic( aR );
     885                 :            :     DBG_ASSERTWARNING( aR == aOutArea, "OutArea before Scroll not aligned" );
     886                 :            : #endif
     887                 :            : 
     888         [ +  - ]:          6 :     Rectangle aNewVisArea( GetVisDocArea() );
     889                 :            : 
     890                 :            :     // Vertical:
     891         [ +  - ]:          6 :     if ( !IsVertical() )
     892                 :            :     {
     893                 :          6 :         aNewVisArea.Top() -= ndY;
     894                 :          6 :         aNewVisArea.Bottom() -= ndY;
     895                 :            :     }
     896                 :            :     else
     897                 :            :     {
     898                 :          0 :         aNewVisArea.Top() += ndX;
     899                 :          0 :         aNewVisArea.Bottom() += ndX;
     900                 :            :     }
     901 [ -  + ][ #  # ]:          6 :     if ( ( nRangeCheck == RGCHK_PAPERSZ1 ) && ( aNewVisArea.Bottom() > (long)pEditEngine->pImpEditEngine->GetTextHeight() ) )
         [ #  # ][ -  + ]
     902                 :            :     {
     903                 :            :         // GetTextHeight still optimizing!
     904         [ #  # ]:          0 :         long nDiff = pEditEngine->pImpEditEngine->GetTextHeight() - aNewVisArea.Bottom(); // negative
     905         [ #  # ]:          0 :         aNewVisArea.Move( 0, nDiff );   // could end up in the negative area...
     906                 :            :     }
     907 [ -  + ][ #  # ]:          6 :     if ( ( aNewVisArea.Top() < 0 ) && ( nRangeCheck != RGCHK_NONE ) )
                 [ -  + ]
     908         [ #  # ]:          0 :         aNewVisArea.Move( 0, -aNewVisArea.Top() );
     909                 :            : 
     910                 :            :     // Horizontal:
     911         [ +  - ]:          6 :     if ( !IsVertical() )
     912                 :            :     {
     913                 :          6 :         aNewVisArea.Left() -= ndX;
     914                 :          6 :         aNewVisArea.Right() -= ndX;
     915                 :            :     }
     916                 :            :     else
     917                 :            :     {
     918                 :          0 :         aNewVisArea.Left() -= ndY;
     919                 :          0 :         aNewVisArea.Right() -= ndY;
     920                 :            :     }
     921 [ -  + ][ #  # ]:          6 :     if ( ( nRangeCheck == RGCHK_PAPERSZ1 ) && ( aNewVisArea.Right() > (long)pEditEngine->pImpEditEngine->CalcTextWidth( sal_False ) ) )
         [ #  # ][ -  + ]
     922                 :            :     {
     923         [ #  # ]:          0 :         long nDiff = pEditEngine->pImpEditEngine->CalcTextWidth( sal_False ) - aNewVisArea.Right();     // negative
     924         [ #  # ]:          0 :         aNewVisArea.Move( nDiff, 0 );   // could end up in the negative area...
     925                 :            :     }
     926 [ -  + ][ #  # ]:          6 :     if ( ( aNewVisArea.Left() < 0 ) && ( nRangeCheck != RGCHK_NONE ) )
                 [ -  + ]
     927         [ #  # ]:          0 :         aNewVisArea.Move( -aNewVisArea.Left(), 0 );
     928                 :            : 
     929                 :            :     // The difference must be alignt on pixel (due to scroll!)
     930         [ +  - ]:          6 :     long nDiffX = !IsVertical() ? ( GetVisDocLeft() - aNewVisArea.Left() ) : -( GetVisDocTop() - aNewVisArea.Top() );
     931         [ +  - ]:          6 :     long nDiffY = !IsVertical() ? ( GetVisDocTop() - aNewVisArea.Top() ) : ( GetVisDocLeft() - aNewVisArea.Left() );
     932                 :            : 
     933                 :          6 :     Size aDiffs( nDiffX, nDiffY );
     934         [ +  - ]:          6 :     aDiffs = pOutWin->LogicToPixel( aDiffs );
     935         [ +  - ]:          6 :     aDiffs = pOutWin->PixelToLogic( aDiffs );
     936                 :            : 
     937                 :          6 :     long nRealDiffX = aDiffs.Width();
     938                 :          6 :     long nRealDiffY = aDiffs.Height();
     939                 :            : 
     940                 :            : 
     941 [ #  # ][ -  + ]:          6 :     if ( nRealDiffX || nRealDiffY )
     942                 :            :     {
     943         [ +  - ]:          6 :         Cursor* pCrsr = GetCursor();
     944                 :          6 :         sal_Bool bVisCursor = pCrsr->IsVisible();
     945         [ +  - ]:          6 :         pCrsr->Hide();
     946         [ +  - ]:          6 :         pOutWin->Update();
     947         [ +  - ]:          6 :         if ( !IsVertical() )
     948                 :          6 :             aVisDocStartPos.Move( -nRealDiffX, -nRealDiffY );
     949                 :            :         else
     950                 :          0 :             aVisDocStartPos.Move( -nRealDiffY, nRealDiffX );
     951                 :            :         // Das Move um den allignten Wert ergibt nicht unbedingt ein
     952                 :            :         // alligntes Rechteck...
     953                 :            :         // Aligned value of the move does not necessarily result in aligned
     954                 :            :         // rectangle ...
     955         [ +  - ]:          6 :         aVisDocStartPos = pOutWin->LogicToPixel( aVisDocStartPos );
     956         [ +  - ]:          6 :         aVisDocStartPos = pOutWin->PixelToLogic( aVisDocStartPos );
     957                 :          6 :         Rectangle aRec( aOutArea );
     958         [ +  - ]:          6 :         pOutWin->Scroll( nRealDiffX, nRealDiffY, aRec, sal_True );
     959         [ +  - ]:          6 :         pOutWin->Update();
     960         [ +  - ]:          6 :         pCrsr->SetPos( pCrsr->GetPos() + Point( nRealDiffX, nRealDiffY ) );
     961         [ -  + ]:          6 :         if ( bVisCursor )
     962                 :            :         {
     963         [ #  # ]:          0 :             Rectangle aCursorRec( pCrsr->GetPos(), pCrsr->GetSize() );
     964 [ #  # ][ #  # ]:          0 :             if ( aOutArea.IsInside( aCursorRec ) )
     965         [ #  # ]:          0 :                 pCrsr->Show();
     966                 :            :         }
     967                 :            : 
     968 [ +  - ][ -  + ]:          6 :         if ( pEditEngine->pImpEditEngine->GetNotifyHdl().IsSet() )
     969                 :            :         {
     970                 :          0 :             EENotify aNotify( EE_NOTIFY_TEXTVIEWSCROLLED );
     971                 :          0 :             aNotify.pEditEngine = pEditEngine;
     972                 :          0 :             aNotify.pEditView = GetEditViewPtr();
     973         [ #  # ]:          6 :             pEditEngine->pImpEditEngine->CallNotify( aNotify );
     974                 :            :         }
     975                 :            :     }
     976                 :            : 
     977                 :         79 :     return Pair( nRealDiffX, nRealDiffY );
     978                 :            : }
     979                 :            : 
     980                 :          0 : sal_Bool ImpEditView::PostKeyEvent( const KeyEvent& rKeyEvent, Window* pFrameWin )
     981                 :            : {
     982                 :          0 :     sal_Bool bDone = sal_False;
     983                 :            : 
     984                 :          0 :     KeyFuncType eFunc = rKeyEvent.GetKeyCode().GetFunction();
     985         [ #  # ]:          0 :     if ( eFunc != KEYFUNC_DONTKNOW )
     986                 :            :     {
     987   [ #  #  #  # ]:          0 :         switch ( eFunc )
     988                 :            :         {
     989                 :            :             case KEYFUNC_CUT:
     990                 :            :             {
     991         [ #  # ]:          0 :                 if ( !bReadOnly )
     992                 :            :                 {
     993         [ #  # ]:          0 :                     Reference<com::sun::star::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetClipboard());
     994         [ #  # ]:          0 :                     CutCopy( aClipBoard, sal_True );
     995                 :          0 :                     bDone = sal_True;
     996                 :            :                 }
     997                 :            :             }
     998                 :          0 :             break;
     999                 :            :             case KEYFUNC_COPY:
    1000                 :            :             {
    1001         [ #  # ]:          0 :                 Reference<com::sun::star::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetClipboard());
    1002         [ #  # ]:          0 :                 CutCopy( aClipBoard, sal_False );
    1003                 :          0 :                 bDone = sal_True;
    1004                 :            :             }
    1005                 :          0 :             break;
    1006                 :            :             case KEYFUNC_PASTE:
    1007                 :            :             {
    1008 [ #  # ][ #  # ]:          0 :                 if ( !bReadOnly && IsPasteEnabled() )
                 [ #  # ]
    1009                 :            :                 {
    1010         [ #  # ]:          0 :                     pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_PASTE );
    1011         [ #  # ]:          0 :                     Reference<com::sun::star::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetClipboard());
    1012         [ #  # ]:          0 :                     Paste( aClipBoard, pEditEngine->pImpEditEngine->GetStatus().AllowPasteSpecial() );
    1013         [ #  # ]:          0 :                     pEditEngine->pImpEditEngine->UndoActionEnd( EDITUNDO_PASTE );
    1014                 :          0 :                     bDone = sal_True;
    1015                 :            :                 }
    1016                 :            :             }
    1017                 :          0 :             break;
    1018                 :            :             default:
    1019                 :          0 :                 break;
    1020                 :            :         }
    1021                 :            :     }
    1022                 :            : 
    1023         [ #  # ]:          0 :     if( !bDone )
    1024                 :          0 :         bDone = pEditEngine->PostKeyEvent( rKeyEvent, GetEditViewPtr(), pFrameWin );
    1025                 :            : 
    1026                 :          0 :     return bDone;
    1027                 :            : }
    1028                 :            : 
    1029                 :          0 : sal_Bool ImpEditView::MouseButtonUp( const MouseEvent& rMouseEvent )
    1030                 :            : {
    1031         [ #  # ]:          0 :     if ( pEditEngine->GetInternalEditStatus().NotifyCursorMovements() )
    1032                 :            :     {
    1033         [ #  # ]:          0 :         if ( pEditEngine->GetInternalEditStatus().GetPrevParagraph() != pEditEngine->GetEditDoc().GetPos( GetEditSelection().Max().GetNode() ) )
    1034                 :            :         {
    1035                 :          0 :             pEditEngine->GetInternalEditStatus().GetStatusWord() = pEditEngine->GetInternalEditStatus().GetStatusWord() | EE_STAT_CRSRLEFTPARA;
    1036                 :          0 :             pEditEngine->pImpEditEngine->CallStatusHdl();
    1037                 :            :         }
    1038                 :            :     }
    1039                 :          0 :     nTravelXPos = TRAVEL_X_DONTKNOW;
    1040                 :          0 :     nCursorBidiLevel = CURSOR_BIDILEVEL_DONTKNOW;
    1041                 :          0 :     nExtraCursorFlags = 0;
    1042                 :          0 :     bClickedInSelection = sal_False;
    1043                 :            : 
    1044         [ #  # ]:          0 :     if ( rMouseEvent.IsMiddle() && !bReadOnly &&
           [ #  #  #  # ]
                 [ #  # ]
    1045                 :          0 :          ( GetWindow()->GetSettings().GetMouseSettings().GetMiddleButtonAction() == MOUSE_MIDDLE_PASTESELECTION ) )
    1046                 :            :     {
    1047         [ #  # ]:          0 :         Reference<com::sun::star::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetPrimarySelection());
    1048         [ #  # ]:          0 :         Paste( aClipBoard );
    1049                 :            :     }
    1050 [ #  # ][ #  # ]:          0 :     else if ( rMouseEvent.IsLeft() && GetEditSelection().HasRange() )
                 [ #  # ]
    1051                 :            :     {
    1052         [ #  # ]:          0 :         Reference<com::sun::star::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetPrimarySelection());
    1053         [ #  # ]:          0 :         CutCopy( aClipBoard, sal_False );
    1054                 :            :     }
    1055                 :            : 
    1056                 :          0 :     return pEditEngine->pImpEditEngine->MouseButtonUp( rMouseEvent, GetEditViewPtr() );
    1057                 :            : }
    1058                 :            : 
    1059                 :          0 : sal_Bool ImpEditView::MouseButtonDown( const MouseEvent& rMouseEvent )
    1060                 :            : {
    1061                 :          0 :     pEditEngine->CheckIdleFormatter();  // If fast typing and mouse button downs
    1062         [ #  # ]:          0 :     if ( pEditEngine->GetInternalEditStatus().NotifyCursorMovements() )
    1063                 :          0 :         pEditEngine->GetInternalEditStatus().GetPrevParagraph() = pEditEngine->GetEditDoc().GetPos( GetEditSelection().Max().GetNode() );
    1064                 :          0 :     nTravelXPos = TRAVEL_X_DONTKNOW;
    1065                 :          0 :     nExtraCursorFlags = 0;
    1066                 :          0 :     nCursorBidiLevel    = CURSOR_BIDILEVEL_DONTKNOW;
    1067                 :          0 :     bClickedInSelection = IsSelectionAtPoint( rMouseEvent.GetPosPixel() );
    1068                 :          0 :     return pEditEngine->pImpEditEngine->MouseButtonDown( rMouseEvent, GetEditViewPtr() );
    1069                 :            : }
    1070                 :            : 
    1071                 :          0 : sal_Bool ImpEditView::MouseMove( const MouseEvent& rMouseEvent )
    1072                 :            : {
    1073                 :          0 :     return pEditEngine->pImpEditEngine->MouseMove( rMouseEvent, GetEditViewPtr() );
    1074                 :            : }
    1075                 :            : 
    1076                 :          0 : void ImpEditView::Command( const CommandEvent& rCEvt )
    1077                 :            : {
    1078                 :          0 :     pEditEngine->CheckIdleFormatter();  // If fast typing and mouse button down
    1079                 :          0 :     pEditEngine->pImpEditEngine->Command( rCEvt, GetEditViewPtr() );
    1080                 :          0 : }
    1081                 :            : 
    1082                 :            : 
    1083                 :        205 : void ImpEditView::SetInsertMode( sal_Bool bInsert )
    1084                 :            : {
    1085         [ -  + ]:        205 :     if ( bInsert != IsInsertMode() )
    1086                 :            :     {
    1087                 :          0 :         SetFlags( nControl, EV_CNTRL_OVERWRITE, !bInsert );
    1088                 :          0 :         ShowCursor( DoAutoScroll(), sal_False );
    1089                 :            :     }
    1090                 :        205 : }
    1091                 :            : 
    1092                 :          0 : sal_Bool ImpEditView::IsWrongSpelledWord( const EditPaM& rPaM, sal_Bool bMarkIfWrong )
    1093                 :            : {
    1094                 :          0 :     bool bIsWrong = false;
    1095         [ #  # ]:          0 :     if ( rPaM.GetNode()->GetWrongList() )
    1096                 :            :     {
    1097 [ #  # ][ #  # ]:          0 :         EditSelection aSel = pEditEngine->SelectWord( rPaM, ::com::sun::star::i18n::WordType::DICTIONARY_WORD );
    1098 [ #  # ][ #  # ]:          0 :         bIsWrong = rPaM.GetNode()->GetWrongList()->HasWrong( aSel.Min().GetIndex(), aSel.Max().GetIndex() );
    1099 [ #  # ][ #  # ]:          0 :         if ( bIsWrong && bMarkIfWrong )
    1100                 :            :         {
    1101         [ #  # ]:          0 :             DrawSelection();
    1102         [ #  # ]:          0 :             SetEditSelection( aSel );
    1103         [ #  # ]:          0 :             DrawSelection();
    1104                 :            :         }
    1105                 :            :     }
    1106                 :          0 :     return bIsWrong;
    1107                 :            : }
    1108                 :            : 
    1109                 :          0 : String ImpEditView::SpellIgnoreOrAddWord( sal_Bool bAdd )
    1110                 :            : {
    1111                 :          0 :     String aWord;
    1112 [ #  # ][ #  # ]:          0 :     if ( pEditEngine->pImpEditEngine->GetSpeller().is() )
    1113                 :            :     {
    1114         [ #  # ]:          0 :         EditPaM aPaM = GetEditSelection().Max();
    1115 [ #  # ][ #  # ]:          0 :         if ( !HasSelection() )
    1116                 :            :         {
    1117 [ #  # ][ #  # ]:          0 :             EditSelection aSel = pEditEngine->SelectWord(aPaM);
    1118 [ #  # ][ #  # ]:          0 :             aWord = pEditEngine->pImpEditEngine->GetSelected( aSel );
                 [ #  # ]
    1119                 :            :         }
    1120                 :            :         else
    1121                 :            :         {
    1122 [ #  # ][ #  # ]:          0 :             aWord = pEditEngine->pImpEditEngine->GetSelected( GetEditSelection() );
                 [ #  # ]
    1123                 :            :             // And deselect
    1124         [ #  # ]:          0 :             DrawSelection();
    1125 [ #  # ][ #  # ]:          0 :             SetEditSelection( EditSelection( aPaM, aPaM ) );
    1126         [ #  # ]:          0 :             DrawSelection();
    1127                 :            :         }
    1128                 :            : 
    1129         [ #  # ]:          0 :         if ( aWord.Len() )
    1130                 :            :         {
    1131         [ #  # ]:          0 :             if ( bAdd )
    1132                 :            :             {
    1133                 :            :                 OSL_FAIL( "Sorry, AddWord not implemented" );
    1134                 :            :             }
    1135                 :            :             else // Ignore
    1136                 :            :             {
    1137 [ #  # ][ #  # ]:          0 :                 Reference< XDictionary >  xDic( SvxGetIgnoreAllList(), UNO_QUERY );
    1138         [ #  # ]:          0 :                 if (xDic.is())
    1139 [ #  # ][ #  # ]:          0 :                     xDic->add( aWord, sal_False, String() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1140                 :            :             }
    1141         [ #  # ]:          0 :             EditDoc& rDoc = pEditEngine->GetEditDoc();
    1142         [ #  # ]:          0 :             sal_uInt16 nNodes = rDoc.Count();
    1143         [ #  # ]:          0 :             for ( sal_uInt16 n = 0; n < nNodes; n++ )
    1144                 :            :             {
    1145         [ #  # ]:          0 :                 ContentNode* pNode = rDoc.GetObject( n );
    1146         [ #  # ]:          0 :                 pNode->GetWrongList()->MarkWrongsInvalid();
    1147                 :            :             }
    1148 [ #  # ][ #  # ]:          0 :             pEditEngine->pImpEditEngine->DoOnlineSpelling( aPaM.GetNode() );
    1149         [ #  # ]:          0 :             pEditEngine->pImpEditEngine->StartOnlineSpellTimer();
    1150                 :            :         }
    1151                 :            :     }
    1152                 :          0 :     return aWord;
    1153                 :            : }
    1154                 :            : 
    1155                 :          0 : void ImpEditView::DeleteSelected()
    1156                 :            : {
    1157         [ #  # ]:          0 :     DrawSelection();
    1158                 :            : 
    1159         [ #  # ]:          0 :     pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_DELETE );
    1160                 :            : 
    1161 [ #  # ][ #  # ]:          0 :     EditPaM aPaM = pEditEngine->pImpEditEngine->DeleteSelected( GetEditSelection() );
    1162                 :            : 
    1163         [ #  # ]:          0 :     pEditEngine->pImpEditEngine->UndoActionEnd( EDITUNDO_DELETE );
    1164                 :            : 
    1165 [ #  # ][ #  # ]:          0 :     SetEditSelection( EditSelection( aPaM, aPaM ) );
    1166         [ #  # ]:          0 :     pEditEngine->pImpEditEngine->FormatAndUpdate( GetEditViewPtr() );
    1167         [ #  # ]:          0 :     ShowCursor( DoAutoScroll(), sal_True );
    1168                 :          0 : }
    1169                 :            : 
    1170                 :          0 : const SvxFieldItem* ImpEditView::GetField( const Point& rPos, sal_uInt16* pPara, sal_uInt16* pPos ) const
    1171                 :            : {
    1172 [ #  # ][ #  # ]:          0 :     if( !GetOutputArea().IsInside( rPos ) )
    1173                 :          0 :         return 0;
    1174                 :            : 
    1175                 :          0 :     Point aDocPos( GetDocPos( rPos ) );
    1176         [ #  # ]:          0 :     EditPaM aPaM = pEditEngine->GetPaM(aDocPos, false);
    1177                 :            : 
    1178 [ #  # ][ #  # ]:          0 :     if ( aPaM.GetIndex() == aPaM.GetNode()->Len() )
                 [ #  # ]
    1179                 :            :     {
    1180                 :            :         // Otherwise, whenever the Field at the very end and mouse under the text
    1181                 :          0 :         return 0;
    1182                 :            :     }
    1183                 :            : 
    1184 [ #  # ][ #  # ]:          0 :     const CharAttribList::AttribsType& rAttrs = aPaM.GetNode()->GetCharAttribs().GetAttribs();
    1185                 :          0 :     sal_uInt16 nXPos = aPaM.GetIndex();
    1186         [ #  # ]:          0 :     for (size_t nAttr = rAttrs.size(); nAttr; )
    1187                 :            :     {
    1188         [ #  # ]:          0 :         const EditCharAttrib& rAttr = rAttrs[--nAttr];
    1189         [ #  # ]:          0 :         if (rAttr.GetStart() == nXPos)
    1190                 :            :         {
    1191         [ #  # ]:          0 :             if (rAttr.Which() == EE_FEATURE_FIELD)
    1192                 :            :             {
    1193                 :            :                 DBG_ASSERT(dynamic_cast<const SvxFieldItem*>(rAttr.GetItem()), "No FieldItem...");
    1194         [ #  # ]:          0 :                 if ( pPara )
    1195 [ #  # ][ #  # ]:          0 :                     *pPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
                 [ #  # ]
    1196         [ #  # ]:          0 :                 if ( pPos )
    1197                 :          0 :                     *pPos = rAttr.GetStart();
    1198                 :          0 :                 return static_cast<const SvxFieldItem*>(rAttr.GetItem());
    1199                 :            :             }
    1200                 :            :         }
    1201                 :            :     }
    1202                 :          0 :     return NULL;
    1203                 :            : }
    1204                 :            : 
    1205                 :          0 : sal_Bool ImpEditView::IsBulletArea( const Point& rPos, sal_uInt16* pPara )
    1206                 :            : {
    1207         [ #  # ]:          0 :     if ( pPara )
    1208                 :          0 :         *pPara = 0xFFFF;
    1209                 :            : 
    1210 [ #  # ][ #  # ]:          0 :     if( !GetOutputArea().IsInside( rPos ) )
    1211                 :          0 :         return sal_False;
    1212                 :            : 
    1213                 :          0 :     Point aDocPos( GetDocPos( rPos ) );
    1214         [ #  # ]:          0 :     EditPaM aPaM = pEditEngine->GetPaM(aDocPos, false);
    1215                 :            : 
    1216         [ #  # ]:          0 :     if ( aPaM.GetIndex() == 0 )
    1217                 :            :     {
    1218 [ #  # ][ #  # ]:          0 :         sal_uInt16 nPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
                 [ #  # ]
    1219         [ #  # ]:          0 :         Rectangle aBulletArea = pEditEngine->GetBulletArea( nPara );
    1220         [ #  # ]:          0 :         long nY = pEditEngine->GetDocPosTopLeft( nPara ).Y();
    1221 [ #  # ][ #  # ]:          0 :         const ParaPortion* pParaPortion = pEditEngine->GetParaPortions()[nPara];
    1222                 :          0 :         nY += pParaPortion->GetFirstLineOffset();
    1223 [ #  # ][ #  #  :          0 :         if ( ( aDocPos.Y() > ( nY + aBulletArea.Top() ) ) &&
          #  #  #  #  #  
                      # ]
    1224                 :          0 :              ( aDocPos.Y() < ( nY + aBulletArea.Bottom() ) ) &&
    1225                 :          0 :              ( aDocPos.X() > ( aBulletArea.Left() ) ) &&
    1226                 :          0 :              ( aDocPos.X() < ( aBulletArea.Right() ) ) )
    1227                 :            :         {
    1228         [ #  # ]:          0 :             if ( pPara )
    1229                 :          0 :                 *pPara = nPara;
    1230                 :          0 :             return sal_True;
    1231                 :            :         }
    1232                 :            :     }
    1233                 :            : 
    1234                 :          0 :     return sal_False;
    1235                 :            : }
    1236                 :            : 
    1237                 :          0 : void ImpEditView::CutCopy( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard, sal_Bool bCut )
    1238                 :            : {
    1239 [ #  # ][ #  # ]:          0 :     if ( rxClipboard.is() && GetEditSelection().HasRange() )
                 [ #  # ]
    1240                 :            :     {
    1241         [ #  # ]:          0 :         uno::Reference<datatransfer::XTransferable> xData = pEditEngine->CreateTransferable( GetEditSelection() );
    1242                 :            : 
    1243         [ #  # ]:          0 :         const sal_uInt32 nRef = Application::ReleaseSolarMutex();
    1244                 :            : 
    1245                 :            :         try
    1246                 :            :         {
    1247 [ #  # ][ #  # ]:          0 :             rxClipboard->setContents( xData, NULL );
                 [ #  # ]
    1248                 :            : 
    1249                 :            :             // #87756# FlushClipboard, but it would be better to become a TerminateListener to the Desktop and flush on demand...
    1250         [ #  # ]:          0 :             uno::Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, uno::UNO_QUERY );
    1251         [ #  # ]:          0 :             if( xFlushableClipboard.is() )
    1252 [ #  # ][ #  # ]:          0 :                 xFlushableClipboard->flushClipboard();
                 [ #  # ]
    1253                 :            :         }
    1254         [ #  # ]:          0 :         catch( const ::com::sun::star::uno::Exception& )
    1255                 :            :         {
    1256                 :            :         }
    1257                 :            : 
    1258         [ #  # ]:          0 :         Application::AcquireSolarMutex( nRef );
    1259                 :            : 
    1260         [ #  # ]:          0 :         if ( bCut )
    1261                 :            :         {
    1262         [ #  # ]:          0 :             pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_CUT );
    1263         [ #  # ]:          0 :             DeleteSelected();
    1264         [ #  # ]:          0 :             pEditEngine->pImpEditEngine->UndoActionEnd( EDITUNDO_CUT );
    1265                 :            : 
    1266                 :          0 :         }
    1267                 :            :     }
    1268                 :          0 : }
    1269                 :            : 
    1270                 :          0 : void ImpEditView::Paste( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard, sal_Bool bUseSpecial )
    1271                 :            : {
    1272         [ #  # ]:          0 :     if ( rxClipboard.is() )
    1273                 :            :     {
    1274                 :          0 :         uno::Reference< datatransfer::XTransferable > xDataObj;
    1275                 :            : 
    1276         [ #  # ]:          0 :         const sal_uInt32 nRef = Application::ReleaseSolarMutex();
    1277                 :            : 
    1278                 :            :         try
    1279                 :            :         {
    1280 [ #  # ][ #  # ]:          0 :             xDataObj = rxClipboard->getContents();
         [ #  # ][ #  # ]
    1281                 :            :         }
    1282         [ #  # ]:          0 :         catch( const ::com::sun::star::uno::Exception& )
    1283                 :            :         {
    1284                 :            :         }
    1285                 :            : 
    1286         [ #  # ]:          0 :         Application::AcquireSolarMutex( nRef );
    1287                 :            : 
    1288 [ #  # ][ #  # ]:          0 :         if ( xDataObj.is() && EditEngine::HasValidData( xDataObj ) )
         [ #  # ][ #  # ]
    1289                 :            :         {
    1290         [ #  # ]:          0 :             pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_PASTE );
    1291                 :            : 
    1292         [ #  # ]:          0 :             EditSelection aSel( GetEditSelection() );
    1293 [ #  # ][ #  # ]:          0 :             if ( aSel.HasRange() )
    1294                 :            :             {
    1295         [ #  # ]:          0 :                 DrawSelection();
    1296 [ #  # ][ #  # ]:          0 :                 aSel = pEditEngine->DeleteSelection(aSel);
    1297                 :            :             }
    1298                 :            : 
    1299                 :          0 :             PasteOrDropInfos aPasteOrDropInfos;
    1300                 :          0 :             aPasteOrDropInfos.nAction = EE_ACTION_PASTE;
    1301 [ #  # ][ #  # ]:          0 :             aPasteOrDropInfos.nStartPara = pEditEngine->GetEditDoc().GetPos( aSel.Min().GetNode() );
                 [ #  # ]
    1302         [ #  # ]:          0 :             pEditEngine->HandleBeginPasteOrDrop(aPasteOrDropInfos);
    1303                 :            : 
    1304         [ #  # ]:          0 :             if ( DoSingleLinePaste() )
    1305                 :            :             {
    1306                 :          0 :                 datatransfer::DataFlavor aFlavor;
    1307         [ #  # ]:          0 :                 SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
    1308 [ #  # ][ #  # ]:          0 :                 if ( xDataObj->isDataFlavorSupported( aFlavor ) )
                 [ #  # ]
    1309                 :            :                 {
    1310                 :            :                     try
    1311                 :            :                     {
    1312 [ #  # ][ #  # ]:          0 :                         uno::Any aData = xDataObj->getTransferData( aFlavor );
    1313                 :          0 :                         ::rtl::OUString aTmpText;
    1314                 :          0 :                         aData >>= aTmpText;
    1315 [ #  # ][ #  # ]:          0 :                         String aText(convertLineEnd(aTmpText, LINEEND_LF));
    1316         [ #  # ]:          0 :                         aText.SearchAndReplaceAll( LINE_SEP, ' ' );
    1317 [ #  # ][ #  # ]:          0 :                         aSel = pEditEngine->InsertText(aSel, aText);
                 [ #  # ]
    1318                 :            :                     }
    1319         [ #  # ]:          0 :                     catch( ... )
    1320                 :            :                     {
    1321                 :            :                         ; // #i9286# can happen, even if isDataFlavorSupported returns true...
    1322                 :            :                     }
    1323                 :          0 :                 }
    1324                 :            :             }
    1325                 :            :             else
    1326                 :            :             {
    1327                 :            :                 aSel = pEditEngine->InsertText(
    1328                 :          0 :                     xDataObj, String(), aSel.Min(),
    1329 [ #  # ][ #  # ]:          0 :                     bUseSpecial && pEditEngine->GetInternalEditStatus().AllowPasteSpecial());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1330                 :            :             }
    1331                 :            : 
    1332 [ #  # ][ #  # ]:          0 :             aPasteOrDropInfos.nEndPara = pEditEngine->GetEditDoc().GetPos( aSel.Max().GetNode() );
                 [ #  # ]
    1333         [ #  # ]:          0 :             pEditEngine->HandleEndPasteOrDrop(aPasteOrDropInfos);
    1334                 :            : 
    1335         [ #  # ]:          0 :             pEditEngine->pImpEditEngine->UndoActionEnd( EDITUNDO_PASTE );
    1336         [ #  # ]:          0 :             SetEditSelection( aSel );
    1337         [ #  # ]:          0 :             pEditEngine->pImpEditEngine->UpdateSelections();
    1338         [ #  # ]:          0 :             pEditEngine->pImpEditEngine->FormatAndUpdate( GetEditViewPtr() );
    1339         [ #  # ]:          0 :             ShowCursor( DoAutoScroll(), sal_True );
    1340                 :          0 :         }
    1341                 :            :     }
    1342                 :          0 : }
    1343                 :            : 
    1344                 :            : 
    1345                 :          0 : sal_Bool ImpEditView::IsInSelection( const EditPaM& rPaM )
    1346                 :            : {
    1347         [ #  # ]:          0 :     EditSelection aSel = GetEditSelection();
    1348 [ #  # ][ #  # ]:          0 :     if ( !aSel.HasRange() )
    1349                 :          0 :         return sal_False;
    1350                 :            : 
    1351 [ #  # ][ #  # ]:          0 :     aSel.Adjust( pEditEngine->GetEditDoc() );
    1352                 :            : 
    1353 [ #  # ][ #  # ]:          0 :     sal_uInt16 nStartNode = pEditEngine->GetEditDoc().GetPos( aSel.Min().GetNode() );
                 [ #  # ]
    1354 [ #  # ][ #  # ]:          0 :     sal_uInt16 nEndNode = pEditEngine->GetEditDoc().GetPos( aSel.Max().GetNode() );
                 [ #  # ]
    1355 [ #  # ][ #  # ]:          0 :     sal_uInt16 nCurNode = pEditEngine->GetEditDoc().GetPos( rPaM.GetNode() );
                 [ #  # ]
    1356                 :            : 
    1357 [ #  # ][ #  # ]:          0 :     if ( ( nCurNode > nStartNode ) && ( nCurNode < nEndNode ) )
    1358                 :          0 :         return sal_True;
    1359                 :            : 
    1360         [ #  # ]:          0 :     if ( nStartNode == nEndNode )
    1361                 :            :     {
    1362         [ #  # ]:          0 :         if ( nCurNode == nStartNode )
    1363 [ #  # ][ #  # ]:          0 :             if ( ( rPaM.GetIndex() >= aSel.Min().GetIndex() ) && ( rPaM.GetIndex() < aSel.Max().GetIndex() ) )
                 [ #  # ]
    1364                 :          0 :                 return sal_True;
    1365                 :            :     }
    1366 [ #  # ][ #  # ]:          0 :     else if ( ( nCurNode == nStartNode ) && ( rPaM.GetIndex() >= aSel.Min().GetIndex() ) )
                 [ #  # ]
    1367                 :          0 :         return sal_True;
    1368 [ #  # ][ #  # ]:          0 :     else if ( ( nCurNode == nEndNode ) && ( rPaM.GetIndex() < aSel.Max().GetIndex() ) )
                 [ #  # ]
    1369                 :          0 :         return sal_True;
    1370                 :            : 
    1371                 :          0 :     return sal_False;
    1372                 :            : }
    1373                 :            : 
    1374                 :          0 : void ImpEditView::CreateAnchor()
    1375                 :            : {
    1376                 :          0 :     pEditEngine->SetInSelectionMode(true);
    1377                 :          0 :     GetEditSelection().Min() = GetEditSelection().Max();
    1378                 :          0 : }
    1379                 :            : 
    1380                 :          0 : void ImpEditView::DeselectAll()
    1381                 :            : {
    1382                 :          0 :     pEditEngine->SetInSelectionMode(false);
    1383                 :          0 :     DrawSelection();
    1384                 :          0 :     GetEditSelection().Min() = GetEditSelection().Max();
    1385                 :          0 : }
    1386                 :            : 
    1387                 :          0 : sal_Bool ImpEditView::IsSelectionAtPoint( const Point& rPosPixel )
    1388                 :            : {
    1389 [ #  # ][ #  # ]:          0 :     if ( pDragAndDropInfo && pDragAndDropInfo->pField )
    1390                 :          0 :         return sal_True;
    1391                 :            : 
    1392                 :          0 :     Point aMousePos( rPosPixel );
    1393                 :            : 
    1394                 :            :     // Logical units ...
    1395         [ #  # ]:          0 :     aMousePos = GetWindow()->PixelToLogic( aMousePos );
    1396                 :            : 
    1397 [ #  # ][ #  # ]:          0 :     if ( ( !GetOutputArea().IsInside( aMousePos ) ) && !pEditEngine->pImpEditEngine->IsInSelectionMode() )
         [ #  # ][ #  # ]
    1398                 :            :     {
    1399                 :          0 :         return sal_False;
    1400                 :            :     }
    1401                 :            : 
    1402                 :          0 :     Point aDocPos( GetDocPos( aMousePos ) );
    1403         [ #  # ]:          0 :     EditPaM aPaM = pEditEngine->GetPaM(aDocPos, false);
    1404         [ #  # ]:          0 :     return IsInSelection( aPaM );
    1405                 :            : }
    1406                 :            : 
    1407                 :          0 : sal_Bool ImpEditView::SetCursorAtPoint( const Point& rPointPixel )
    1408                 :            : {
    1409         [ #  # ]:          0 :     pEditEngine->CheckIdleFormatter();
    1410                 :            : 
    1411                 :          0 :     Point aMousePos( rPointPixel );
    1412                 :            : 
    1413                 :            :     // Logical units ...
    1414         [ #  # ]:          0 :     aMousePos = GetWindow()->PixelToLogic( aMousePos );
    1415                 :            : 
    1416 [ #  # ][ #  # ]:          0 :     if ( ( !GetOutputArea().IsInside( aMousePos ) ) && !pEditEngine->pImpEditEngine->IsInSelectionMode() )
         [ #  # ][ #  # ]
    1417                 :            :     {
    1418                 :          0 :         return sal_False;
    1419                 :            :     }
    1420                 :            : 
    1421                 :          0 :     Point aDocPos( GetDocPos( aMousePos ) );
    1422                 :            : 
    1423                 :            :     // Can be optimized: first go through the lines within a paragraph for PAM,
    1424                 :            :     // then again wiht the PaM for the Rect, even though the line is already
    1425                 :            :     // known .... This must not be, though!
    1426         [ #  # ]:          0 :     EditPaM aPaM = pEditEngine->GetPaM(aDocPos);
    1427                 :          0 :     sal_Bool bGotoCursor = DoAutoScroll();
    1428                 :            : 
    1429                 :            :     // aTmpNewSel: Diff between old and new, not the new selection
    1430         [ #  # ]:          0 :     EditSelection aTmpNewSel( GetEditSelection().Max(), aPaM );
    1431                 :            : 
    1432                 :            :     // #i27299#
    1433                 :            :     // work on copy of current selection and set new selection, if it has changed.
    1434         [ #  # ]:          0 :     EditSelection aNewEditSelection( GetEditSelection() );
    1435                 :            : 
    1436         [ #  # ]:          0 :     aNewEditSelection.Max() = aPaM;
    1437 [ #  # ][ #  # ]:          0 :     if (!pEditEngine->GetSelectionEngine().HasAnchor())
                 [ #  # ]
    1438                 :            :     {
    1439 [ #  # ][ #  # ]:          0 :         if ( aNewEditSelection.Min() != aPaM )
    1440 [ #  # ][ #  # ]:          0 :             pEditEngine->CursorMoved(aNewEditSelection.Min().GetNode());
    1441         [ #  # ]:          0 :         aNewEditSelection.Min() = aPaM;
    1442                 :            :     }
    1443                 :            :     else
    1444                 :            :     {
    1445 [ #  # ][ #  # ]:          0 :         DrawSelection( aTmpNewSel );
    1446                 :            :     }
    1447                 :            : 
    1448                 :            :     // set changed text selection
    1449 [ #  # ][ #  # ]:          0 :     if ( GetEditSelection() != aNewEditSelection )
    1450                 :            :     {
    1451         [ #  # ]:          0 :         SetEditSelection( aNewEditSelection );
    1452                 :            :     }
    1453                 :            : 
    1454 [ #  # ][ #  # ]:          0 :     sal_Bool bForceCursor = ( pDragAndDropInfo ? sal_False : sal_True ) && !pEditEngine->pImpEditEngine->IsInSelectionMode();
    1455         [ #  # ]:          0 :     ShowCursor( bGotoCursor, bForceCursor );
    1456                 :          0 :     return sal_True;
    1457                 :            : }
    1458                 :            : 
    1459                 :            : 
    1460                 :          0 : void ImpEditView::HideDDCursor()
    1461                 :            : {
    1462 [ #  # ][ #  # ]:          0 :     if ( pDragAndDropInfo && pDragAndDropInfo->bVisCursor )
    1463                 :            :     {
    1464                 :          0 :         GetWindow()->DrawOutDev( pDragAndDropInfo->aCurSavedCursor.TopLeft(), pDragAndDropInfo->aCurSavedCursor.GetSize(),
    1465 [ #  # ][ #  # ]:          0 :                             Point(0,0), pDragAndDropInfo->aCurSavedCursor.GetSize(),*pDragAndDropInfo->pBackground );
    1466                 :          0 :         pDragAndDropInfo->bVisCursor = sal_False;
    1467                 :            :     }
    1468                 :          0 : }
    1469                 :            : 
    1470                 :          0 : void ImpEditView::ShowDDCursor( const Rectangle& rRect )
    1471                 :            : {
    1472 [ #  # ][ #  # ]:          0 :     if ( pDragAndDropInfo && !pDragAndDropInfo->bVisCursor )
    1473                 :            :     {
    1474 [ #  # ][ #  # ]:          0 :         if ( pOutWin->GetCursor() )
    1475 [ #  # ][ #  # ]:          0 :             pOutWin->GetCursor()->Hide();
    1476                 :            : 
    1477                 :          0 :         Color aOldFillColor = GetWindow()->GetFillColor();
    1478         [ #  # ]:          0 :         GetWindow()->SetFillColor( Color(4210752) );    // GRAY BRUSH_50, OLDSV, change to DDCursor!
    1479                 :            : 
    1480                 :            :         // Save background ...
    1481         [ #  # ]:          0 :         Rectangle aSaveRec( GetWindow()->LogicToPixel( rRect ) );
    1482                 :            :         // prefer to save some more ...
    1483                 :          0 :         aSaveRec.Right() += 1;
    1484                 :          0 :         aSaveRec.Bottom() += 1;
    1485                 :            : 
    1486                 :            : #ifdef DBG_UTIL
    1487                 :            :         Size aNewSzPx( aSaveRec.GetSize() );
    1488                 :            : #endif
    1489         [ #  # ]:          0 :         if ( !pDragAndDropInfo->pBackground )
    1490                 :            :         {
    1491 [ #  # ][ #  # ]:          0 :             pDragAndDropInfo->pBackground = new VirtualDevice( *GetWindow() );
    1492         [ #  # ]:          0 :             MapMode aMapMode( GetWindow()->GetMapMode() );
    1493         [ #  # ]:          0 :             aMapMode.SetOrigin( Point( 0, 0 ) );
    1494 [ #  # ][ #  # ]:          0 :             pDragAndDropInfo->pBackground->SetMapMode( aMapMode );
    1495                 :            : 
    1496                 :            :         }
    1497                 :            : 
    1498                 :            : #ifdef DBG_UTIL
    1499                 :            :         Size aCurSzPx( pDragAndDropInfo->pBackground->GetOutputSizePixel() );
    1500                 :            :         if ( ( aCurSzPx.Width() < aNewSzPx.Width() ) ||( aCurSzPx.Height() < aNewSzPx.Height() ) )
    1501                 :            :         {
    1502                 :            :             sal_Bool bDone = pDragAndDropInfo->pBackground->SetOutputSizePixel( aNewSzPx );
    1503                 :            :             DBG_ASSERT( bDone, "Virtual Device broken?" );
    1504                 :            :         }
    1505                 :            : #endif
    1506                 :            : 
    1507         [ #  # ]:          0 :         aSaveRec = GetWindow()->PixelToLogic( aSaveRec );
    1508                 :            : 
    1509                 :            :         pDragAndDropInfo->pBackground->DrawOutDev( Point(0,0), aSaveRec.GetSize(),
    1510 [ #  # ][ #  # ]:          0 :                                     aSaveRec.TopLeft(), aSaveRec.GetSize(), *GetWindow() );
                 [ #  # ]
    1511                 :          0 :         pDragAndDropInfo->aCurSavedCursor = aSaveRec;
    1512                 :            : 
    1513                 :            :         // Draw Cursor...
    1514         [ #  # ]:          0 :         GetWindow()->DrawRect( rRect );
    1515                 :            : 
    1516                 :          0 :         pDragAndDropInfo->bVisCursor = sal_True;
    1517                 :          0 :         pDragAndDropInfo->aCurCursor = rRect;
    1518                 :            : 
    1519         [ #  # ]:          0 :         GetWindow()->SetFillColor( aOldFillColor );
    1520                 :            :     }
    1521                 :          0 : }
    1522                 :            : 
    1523                 :          0 : void ImpEditView::dragGestureRecognized( const ::com::sun::star::datatransfer::dnd::DragGestureEvent& rDGE ) throw (::com::sun::star::uno::RuntimeException)
    1524                 :            : {
    1525                 :            :     DBG_ASSERT( !pDragAndDropInfo, "dragGestureRecognized - DragAndDropInfo exist!" );
    1526                 :            : 
    1527         [ #  # ]:          0 :     SolarMutexGuard aVclGuard;
    1528                 :            : 
    1529                 :          0 :     pDragAndDropInfo = NULL;
    1530                 :            : 
    1531                 :          0 :     Point aMousePosPixel( rDGE.DragOriginX, rDGE.DragOriginY );
    1532                 :            : 
    1533         [ #  # ]:          0 :     EditSelection aCopySel( GetEditSelection() );
    1534 [ #  # ][ #  # ]:          0 :     aCopySel.Adjust( pEditEngine->GetEditDoc() );
    1535                 :            : 
    1536 [ #  # ][ #  # ]:          0 :     if ( GetEditSelection().HasRange() && bClickedInSelection )
         [ #  # ][ #  # ]
    1537                 :            :     {
    1538 [ #  # ][ #  # ]:          0 :         pDragAndDropInfo = new DragAndDropInfo();
    1539                 :            :     }
    1540                 :            :     else
    1541                 :            :     {
    1542                 :            :         // Field?!
    1543                 :            :         sal_uInt16 nPara, nPos;
    1544         [ #  # ]:          0 :         Point aMousePos = GetWindow()->PixelToLogic( aMousePosPixel );
    1545         [ #  # ]:          0 :         const SvxFieldItem* pField = GetField( aMousePos, &nPara, &nPos );
    1546         [ #  # ]:          0 :         if ( pField )
    1547                 :            :         {
    1548 [ #  # ][ #  # ]:          0 :             pDragAndDropInfo = new DragAndDropInfo();
    1549                 :          0 :             pDragAndDropInfo->pField = pField;
    1550 [ #  # ][ #  # ]:          0 :             ContentNode* pNode = pEditEngine->GetEditDoc().GetObject( nPara );
    1551 [ #  # ][ #  # ]:          0 :             aCopySel = EditSelection( EditPaM( pNode, nPos ), EditPaM( pNode, nPos+1 ) );
         [ #  # ][ #  # ]
    1552         [ #  # ]:          0 :             GetEditSelection() = aCopySel;
    1553         [ #  # ]:          0 :             DrawSelection();
    1554                 :          0 :             sal_Bool bGotoCursor = DoAutoScroll();
    1555 [ #  # ][ #  # ]:          0 :             sal_Bool bForceCursor = ( pDragAndDropInfo ? sal_False : sal_True ) && !pEditEngine->pImpEditEngine->IsInSelectionMode();
    1556         [ #  # ]:          0 :             ShowCursor( bGotoCursor, bForceCursor );
    1557                 :            :         }
    1558 [ #  # ][ #  # ]:          0 :         else if ( IsBulletArea( aMousePos, &nPara ) )
    1559                 :            :         {
    1560 [ #  # ][ #  # ]:          0 :             pDragAndDropInfo = new DragAndDropInfo();
    1561                 :          0 :             pDragAndDropInfo->bOutlinerMode = sal_True;
    1562 [ #  # ][ #  # ]:          0 :             EditPaM aStartPaM( pEditEngine->GetEditDoc().GetObject( nPara ), 0 );
                 [ #  # ]
    1563         [ #  # ]:          0 :             EditPaM aEndPaM( aStartPaM );
    1564         [ #  # ]:          0 :             const SfxInt16Item& rLevel = (const SfxInt16Item&) pEditEngine->GetParaAttrib( nPara, EE_PARA_OUTLLEVEL );
    1565 [ #  # ][ #  # ]:          0 :             for ( sal_uInt16 n = nPara +1; n < pEditEngine->GetEditDoc().Count(); n++ )
                 [ #  # ]
    1566                 :            :             {
    1567         [ #  # ]:          0 :                 const SfxInt16Item& rL = (const SfxInt16Item&) pEditEngine->GetParaAttrib( n, EE_PARA_OUTLLEVEL );
    1568         [ #  # ]:          0 :                 if ( rL.GetValue() > rLevel.GetValue() )
    1569                 :            :                 {
    1570 [ #  # ][ #  # ]:          0 :                     aEndPaM.SetNode( pEditEngine->GetEditDoc().GetObject( n ) );
                 [ #  # ]
    1571                 :            :                 }
    1572                 :            :                 else
    1573                 :            :                 {
    1574                 :          0 :                     break;
    1575                 :            :                 }
    1576                 :            :             }
    1577 [ #  # ][ #  # ]:          0 :             aEndPaM.GetIndex() = aEndPaM.GetNode()->Len();
    1578 [ #  # ][ #  # ]:          0 :             SetEditSelection( EditSelection( aStartPaM, aEndPaM ) );
    1579                 :            :         }
    1580                 :            :     }
    1581                 :            : 
    1582         [ #  # ]:          0 :     if ( pDragAndDropInfo )
    1583                 :            :     {
    1584                 :            : 
    1585                 :          0 :         pDragAndDropInfo->bStarterOfDD = sal_True;
    1586                 :            : 
    1587                 :            :         // Sensitive area to be scrolled.
    1588                 :          0 :         Size aSz( 5, 0 );
    1589         [ #  # ]:          0 :         aSz = GetWindow()->PixelToLogic( aSz );
    1590                 :          0 :         pDragAndDropInfo->nSensibleRange = (sal_uInt16) aSz.Width();
    1591                 :          0 :         pDragAndDropInfo->nCursorWidth = (sal_uInt16) aSz.Width() / 2;
    1592         [ #  # ]:          0 :         pDragAndDropInfo->aBeginDragSel = pEditEngine->pImpEditEngine->CreateESel( aCopySel );
    1593                 :            : 
    1594         [ #  # ]:          0 :         uno::Reference<datatransfer::XTransferable> xData = pEditEngine->CreateTransferable(aCopySel);
    1595                 :            : 
    1596         [ #  # ]:          0 :         sal_Int8 nActions = bReadOnly ? datatransfer::dnd::DNDConstants::ACTION_COPY : datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE;
    1597                 :            : 
    1598 [ #  # ][ #  # ]:          0 :         rDGE.DragSource->startDrag( rDGE, nActions, 0 /*cursor*/, 0 /*image*/, xData, mxDnDListener );
    1599                 :            :         // If Drag&Move in an Engine, thenCopy&Del has to be optional!
    1600 [ #  # ][ #  # ]:          0 :         GetCursor()->Hide();
    1601                 :            : 
    1602         [ #  # ]:          0 :     }
    1603                 :          0 : }
    1604                 :            : 
    1605                 :          0 : void ImpEditView::dragDropEnd( const ::com::sun::star::datatransfer::dnd::DragSourceDropEvent& rDSDE ) throw (::com::sun::star::uno::RuntimeException)
    1606                 :            : {
    1607         [ #  # ]:          0 :     SolarMutexGuard aVclGuard;
    1608                 :            : 
    1609                 :            :     DBG_ASSERT( pDragAndDropInfo, "ImpEditView::dragDropEnd: pDragAndDropInfo is NULL!" );
    1610                 :            : 
    1611                 :            :     // #123688# Shouldn't happen, but seems to happen...
    1612         [ #  # ]:          0 :     if ( pDragAndDropInfo )
    1613                 :            :     {
    1614 [ #  # ][ #  # ]:          0 :         if ( !bReadOnly && rDSDE.DropSuccess && !pDragAndDropInfo->bOutlinerMode && ( rDSDE.DropAction & datatransfer::dnd::DNDConstants::ACTION_MOVE ) )
         [ #  # ][ #  # ]
    1615                 :            :         {
    1616 [ #  # ][ #  # ]:          0 :             if ( pDragAndDropInfo->bStarterOfDD && pDragAndDropInfo->bDroppedInMe )
    1617                 :            :             {
    1618                 :            :                 // DropPos: Where was it dropped, irrespective of length.
    1619                 :          0 :                 ESelection aDropPos( pDragAndDropInfo->aDropSel.nStartPara, pDragAndDropInfo->aDropSel.nStartPos, pDragAndDropInfo->aDropSel.nStartPara, pDragAndDropInfo->aDropSel.nStartPos );
    1620                 :          0 :                 ESelection aToBeDelSel = pDragAndDropInfo->aBeginDragSel;
    1621                 :            :                 ESelection aNewSel( pDragAndDropInfo->aDropSel.nEndPara, pDragAndDropInfo->aDropSel.nEndPos,
    1622                 :          0 :                                     pDragAndDropInfo->aDropSel.nEndPara, pDragAndDropInfo->aDropSel.nEndPos );
    1623                 :          0 :                 sal_Bool bBeforeSelection = aDropPos.IsLess( pDragAndDropInfo->aBeginDragSel );
    1624                 :          0 :                 sal_uInt16 nParaDiff = pDragAndDropInfo->aBeginDragSel.nEndPara - pDragAndDropInfo->aBeginDragSel.nStartPara;
    1625         [ #  # ]:          0 :                 if ( bBeforeSelection )
    1626                 :            :                 {
    1627                 :            :                     // Adjust aToBeDelSel.
    1628                 :            :                     DBG_ASSERT( pDragAndDropInfo->aBeginDragSel.nStartPara >= pDragAndDropInfo->aDropSel.nStartPara, "But not before? ");
    1629                 :          0 :                     aToBeDelSel.nStartPara = aToBeDelSel.nStartPara + nParaDiff;
    1630                 :          0 :                     aToBeDelSel.nEndPara = aToBeDelSel.nEndPara + nParaDiff;
    1631                 :            :                     // To correct the character?
    1632         [ #  # ]:          0 :                     if ( aToBeDelSel.nStartPara == pDragAndDropInfo->aDropSel.nEndPara )
    1633                 :            :                     {
    1634                 :            :                         sal_uInt16 nMoreChars;
    1635         [ #  # ]:          0 :                         if ( pDragAndDropInfo->aDropSel.nStartPara == pDragAndDropInfo->aDropSel.nEndPara )
    1636                 :          0 :                             nMoreChars = pDragAndDropInfo->aDropSel.nEndPos - pDragAndDropInfo->aDropSel.nStartPos;
    1637                 :            :                         else
    1638                 :          0 :                             nMoreChars = pDragAndDropInfo->aDropSel.nEndPos;
    1639                 :            :                         aToBeDelSel.nStartPos =
    1640                 :          0 :                             aToBeDelSel.nStartPos + nMoreChars;
    1641         [ #  # ]:          0 :                         if ( aToBeDelSel.nStartPara == aToBeDelSel.nEndPara )
    1642                 :            :                             aToBeDelSel.nEndPos =
    1643                 :          0 :                                 aToBeDelSel.nEndPos + nMoreChars;
    1644                 :            :                     }
    1645                 :            :                 }
    1646                 :            :                 else
    1647                 :            :                 {
    1648                 :            :                     // aToBeDelSel is ok, but the selection of the  View
    1649                 :            :                     // has to be adapted, if it was deleted before!
    1650                 :            :                     DBG_ASSERT( pDragAndDropInfo->aBeginDragSel.nStartPara <= pDragAndDropInfo->aDropSel.nStartPara, "But not before? ");
    1651                 :          0 :                     aNewSel.nStartPara = aNewSel.nStartPara - nParaDiff;
    1652                 :          0 :                     aNewSel.nEndPara = aNewSel.nEndPara - nParaDiff;
    1653                 :            :                     // To correct the character?
    1654         [ #  # ]:          0 :                     if ( pDragAndDropInfo->aBeginDragSel.nEndPara == pDragAndDropInfo->aDropSel.nStartPara )
    1655                 :            :                     {
    1656                 :            :                         sal_uInt16 nLessChars;
    1657         [ #  # ]:          0 :                         if ( pDragAndDropInfo->aBeginDragSel.nStartPara == pDragAndDropInfo->aBeginDragSel.nEndPara )
    1658                 :          0 :                             nLessChars = pDragAndDropInfo->aBeginDragSel.nEndPos - pDragAndDropInfo->aBeginDragSel.nStartPos;
    1659                 :            :                         else
    1660                 :          0 :                             nLessChars = pDragAndDropInfo->aBeginDragSel.nEndPos;
    1661                 :          0 :                         aNewSel.nStartPos = aNewSel.nStartPos - nLessChars;
    1662         [ #  # ]:          0 :                         if ( aNewSel.nStartPara == aNewSel.nEndPara )
    1663                 :          0 :                             aNewSel.nEndPos = aNewSel.nEndPos - nLessChars;
    1664                 :            :                     }
    1665                 :            :                 }
    1666                 :            : 
    1667         [ #  # ]:          0 :                 DrawSelection();
    1668         [ #  # ]:          0 :                 EditSelection aDelSel( pEditEngine->pImpEditEngine->CreateSel( aToBeDelSel ) );
    1669                 :            :                 DBG_ASSERT( !aDelSel.DbgIsBuggy( pEditEngine->GetEditDoc() ), "ToBeDel is buggy!" );
    1670         [ #  # ]:          0 :                 pEditEngine->DeleteSelection(aDelSel);
    1671         [ #  # ]:          0 :                 if ( !bBeforeSelection )
    1672                 :            :                 {
    1673                 :            :                     DBG_ASSERT( !pEditEngine->pImpEditEngine->CreateSel( aNewSel ).DbgIsBuggy(pEditEngine->GetEditDoc()), "Bad" );
    1674 [ #  # ][ #  # ]:          0 :                     SetEditSelection( pEditEngine->pImpEditEngine->CreateSel( aNewSel ) );
    1675                 :            :                 }
    1676         [ #  # ]:          0 :                 pEditEngine->pImpEditEngine->FormatAndUpdate( pEditEngine->pImpEditEngine->GetActiveView() );
    1677         [ #  # ]:          0 :                 DrawSelection();
    1678                 :            :             }
    1679                 :            :             else
    1680                 :            :             {
    1681                 :            :                 // other EditEngine ...
    1682 [ #  # ][ #  # ]:          0 :                 if (pEditEngine->HasText())   // #88630# SC ist removing the content when switching the task
    1683         [ #  # ]:          0 :                     DeleteSelected();
    1684                 :            :             }
    1685                 :            :         }
    1686                 :            : 
    1687         [ #  # ]:          0 :         if ( pDragAndDropInfo->bUndoAction )
    1688         [ #  # ]:          0 :             pEditEngine->pImpEditEngine->UndoActionEnd( EDITUNDO_DRAGANDDROP );
    1689                 :            : 
    1690         [ #  # ]:          0 :         HideDDCursor();
    1691         [ #  # ]:          0 :         ShowCursor( DoAutoScroll(), sal_True );
    1692                 :          0 :         delete pDragAndDropInfo;
    1693                 :          0 :         pDragAndDropInfo = NULL;
    1694 [ #  # ][ #  # ]:          0 :         pEditEngine->GetEndDropHdl().Call(GetEditViewPtr());
    1695         [ #  # ]:          0 :     }
    1696                 :          0 : }
    1697                 :            : 
    1698                 :          0 : void ImpEditView::drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& rDTDE ) throw (::com::sun::star::uno::RuntimeException)
    1699                 :            : {
    1700         [ #  # ]:          0 :     SolarMutexGuard aVclGuard;
    1701                 :            : 
    1702                 :            :     DBG_ASSERT( pDragAndDropInfo, "Drop - No Drag&Drop info?!" );
    1703                 :            : 
    1704 [ #  # ][ #  # ]:          0 :     if ( pDragAndDropInfo && pDragAndDropInfo->bDragAccepted )
    1705                 :            :     {
    1706 [ #  # ][ #  # ]:          0 :         pEditEngine->GetBeginDropHdl().Call(GetEditViewPtr());
    1707                 :          0 :         sal_Bool bChanges = sal_False;
    1708                 :            : 
    1709         [ #  # ]:          0 :         HideDDCursor();
    1710                 :            : 
    1711         [ #  # ]:          0 :         if ( pDragAndDropInfo->bStarterOfDD )
    1712                 :            :         {
    1713         [ #  # ]:          0 :             pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_DRAGANDDROP );
    1714                 :          0 :             pDragAndDropInfo->bUndoAction = sal_True;
    1715                 :            :         }
    1716                 :            : 
    1717         [ #  # ]:          0 :         if ( pDragAndDropInfo->bOutlinerMode )
    1718                 :            :         {
    1719                 :          0 :             bChanges = sal_True;
    1720         [ #  # ]:          0 :             GetEditViewPtr()->MoveParagraphs( Range( pDragAndDropInfo->aBeginDragSel.nStartPara, pDragAndDropInfo->aBeginDragSel.nEndPara ), pDragAndDropInfo->nOutlinerDropDest );
    1721                 :            :         }
    1722                 :            :         else
    1723                 :            :         {
    1724                 :          0 :             uno::Reference< datatransfer::XTransferable > xDataObj = rDTDE.Transferable;
    1725         [ #  # ]:          0 :             if ( xDataObj.is() )
    1726                 :            :             {
    1727                 :          0 :                 bChanges = true;
    1728                 :            :                 // remove Selection ...
    1729         [ #  # ]:          0 :                 DrawSelection();
    1730         [ #  # ]:          0 :                 EditPaM aPaM( pDragAndDropInfo->aDropDest );
    1731                 :            : 
    1732                 :          0 :                 PasteOrDropInfos aPasteOrDropInfos;
    1733                 :          0 :                 aPasteOrDropInfos.nAction = EE_ACTION_DROP;
    1734 [ #  # ][ #  # ]:          0 :                 aPasteOrDropInfos.nStartPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
                 [ #  # ]
    1735         [ #  # ]:          0 :                 pEditEngine->HandleBeginPasteOrDrop(aPasteOrDropInfos);
    1736                 :            : 
    1737                 :            :                 EditSelection aNewSel = pEditEngine->InsertText(
    1738 [ #  # ][ #  # ]:          0 :                     xDataObj, String(), aPaM, pEditEngine->GetInternalEditStatus().AllowPasteSpecial());
         [ #  # ][ #  # ]
    1739                 :            : 
    1740 [ #  # ][ #  # ]:          0 :                 aPasteOrDropInfos.nEndPara = pEditEngine->GetEditDoc().GetPos( aNewSel.Max().GetNode() );
                 [ #  # ]
    1741         [ #  # ]:          0 :                 pEditEngine->HandleEndPasteOrDrop(aPasteOrDropInfos);
    1742                 :            : 
    1743         [ #  # ]:          0 :                 SetEditSelection( aNewSel );
    1744         [ #  # ]:          0 :                 pEditEngine->pImpEditEngine->FormatAndUpdate( pEditEngine->pImpEditEngine->GetActiveView() );
    1745         [ #  # ]:          0 :                 if ( pDragAndDropInfo->bStarterOfDD )
    1746                 :            :                 {
    1747                 :            :                     // Only set if the same engine!
    1748 [ #  # ][ #  # ]:          0 :                     pDragAndDropInfo->aDropSel.nStartPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
                 [ #  # ]
    1749                 :          0 :                     pDragAndDropInfo->aDropSel.nStartPos = aPaM.GetIndex();
    1750 [ #  # ][ #  # ]:          0 :                     pDragAndDropInfo->aDropSel.nEndPara = pEditEngine->GetEditDoc().GetPos( aNewSel.Max().GetNode() );
                 [ #  # ]
    1751                 :          0 :                     pDragAndDropInfo->aDropSel.nEndPos = aNewSel.Max().GetIndex();
    1752                 :          0 :                     pDragAndDropInfo->bDroppedInMe = sal_True;
    1753                 :            :                 }
    1754                 :          0 :             }
    1755                 :            :         }
    1756                 :            : 
    1757         [ #  # ]:          0 :         if ( bChanges )
    1758                 :            :         {
    1759 [ #  # ][ #  # ]:          0 :             rDTDE.Context->acceptDrop( rDTDE.DropAction );
    1760                 :            :         }
    1761                 :            : 
    1762         [ #  # ]:          0 :         if ( !pDragAndDropInfo->bStarterOfDD )
    1763                 :            :         {
    1764                 :          0 :             delete pDragAndDropInfo;
    1765                 :          0 :             pDragAndDropInfo = NULL;
    1766                 :            :         }
    1767                 :            : 
    1768 [ #  # ][ #  # ]:          0 :         rDTDE.Context->dropComplete( bChanges );
    1769         [ #  # ]:          0 :     }
    1770                 :          0 : }
    1771                 :            : 
    1772                 :          0 : void ImpEditView::dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& rDTDEE ) throw (::com::sun::star::uno::RuntimeException)
    1773                 :            : {
    1774         [ #  # ]:          0 :     SolarMutexGuard aVclGuard;
    1775                 :            : 
    1776         [ #  # ]:          0 :     if ( !pDragAndDropInfo )
    1777 [ #  # ][ #  # ]:          0 :         pDragAndDropInfo = new DragAndDropInfo( );
    1778                 :            : 
    1779                 :          0 :     pDragAndDropInfo->bHasValidData = sal_False;
    1780                 :            : 
    1781                 :            :     // Check for supported format...
    1782                 :            :     // Only check for text, will also be there if bin or rtf
    1783                 :          0 :     datatransfer::DataFlavor aTextFlavor;
    1784         [ #  # ]:          0 :     SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aTextFlavor );
    1785                 :          0 :     const ::com::sun::star::datatransfer::DataFlavor* pFlavors = rDTDEE.SupportedDataFlavors.getConstArray();
    1786                 :          0 :     int nFlavors = rDTDEE.SupportedDataFlavors.getLength();
    1787         [ #  # ]:          0 :     for ( int n = 0; n < nFlavors; n++ )
    1788                 :            :     {
    1789 [ #  # ][ #  # ]:          0 :         if( TransferableDataHelper::IsEqual( pFlavors[n], aTextFlavor ) )
    1790                 :            :         {
    1791                 :          0 :             pDragAndDropInfo->bHasValidData = sal_True;
    1792                 :          0 :             break;
    1793                 :            :         }
    1794                 :            :     }
    1795                 :            : 
    1796 [ #  # ][ #  # ]:          0 :     dragOver( rDTDEE );
    1797                 :          0 : }
    1798                 :            : 
    1799                 :          0 : void ImpEditView::dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& ) throw (::com::sun::star::uno::RuntimeException)
    1800                 :            : {
    1801         [ #  # ]:          0 :     SolarMutexGuard aVclGuard;
    1802                 :            : 
    1803         [ #  # ]:          0 :     HideDDCursor();
    1804                 :            : 
    1805 [ #  # ][ #  # ]:          0 :     if ( pDragAndDropInfo && !pDragAndDropInfo->bStarterOfDD )
    1806                 :            :     {
    1807                 :          0 :         delete pDragAndDropInfo;
    1808                 :          0 :         pDragAndDropInfo = NULL;
    1809         [ #  # ]:          0 :     }
    1810                 :          0 : }
    1811                 :            : 
    1812                 :          0 : void ImpEditView::dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& rDTDE ) throw (::com::sun::star::uno::RuntimeException)
    1813                 :            : {
    1814         [ #  # ]:          0 :     SolarMutexGuard aVclGuard;
    1815                 :            : 
    1816                 :          0 :     Point aMousePos( rDTDE.LocationX, rDTDE.LocationY );
    1817         [ #  # ]:          0 :     aMousePos = GetWindow()->PixelToLogic( aMousePos );
    1818                 :            : 
    1819                 :          0 :     sal_Bool bAccept = sal_False;
    1820                 :            : 
    1821 [ #  # ][ #  # ]:          0 :     if ( GetOutputArea().IsInside( aMousePos ) && !bReadOnly )
         [ #  # ][ #  # ]
    1822                 :            :     {
    1823 [ #  # ][ #  # ]:          0 :         if ( pDragAndDropInfo && pDragAndDropInfo->bHasValidData )
    1824                 :            :         {
    1825                 :          0 :             bAccept = sal_True;
    1826                 :            : 
    1827                 :          0 :             sal_Bool bAllowScroll = DoAutoScroll();
    1828         [ #  # ]:          0 :             if ( bAllowScroll )
    1829                 :            :             {
    1830                 :          0 :                 long nScrollX = 0;
    1831                 :          0 :                 long nScrollY = 0;
    1832                 :            :                 // Chech if in the sensitive area
    1833 [ #  # ][ #  # ]:          0 :                 if ( ( (aMousePos.X()-pDragAndDropInfo->nSensibleRange) < GetOutputArea().Left() ) && ( ( aMousePos.X() + pDragAndDropInfo->nSensibleRange ) > GetOutputArea().Left() ) )
                 [ #  # ]
    1834         [ #  # ]:          0 :                         nScrollX = GetOutputArea().GetWidth() / SCRLRANGE;
    1835 [ #  # ][ #  # ]:          0 :                 else if ( ( (aMousePos.X()+pDragAndDropInfo->nSensibleRange) > GetOutputArea().Right() ) && ( ( aMousePos.X() - pDragAndDropInfo->nSensibleRange ) < GetOutputArea().Right() ) )
                 [ #  # ]
    1836         [ #  # ]:          0 :                         nScrollX = -( GetOutputArea().GetWidth() / SCRLRANGE );
    1837                 :            : 
    1838 [ #  # ][ #  # ]:          0 :                 if ( ( (aMousePos.Y()-pDragAndDropInfo->nSensibleRange) < GetOutputArea().Top() ) && ( ( aMousePos.Y() + pDragAndDropInfo->nSensibleRange ) > GetOutputArea().Top() ) )
                 [ #  # ]
    1839         [ #  # ]:          0 :                         nScrollY = GetOutputArea().GetHeight() / SCRLRANGE;
    1840 [ #  # ][ #  # ]:          0 :                 else if ( ( (aMousePos.Y()+pDragAndDropInfo->nSensibleRange) > GetOutputArea().Bottom() ) && ( ( aMousePos.Y() - pDragAndDropInfo->nSensibleRange ) < GetOutputArea().Bottom() ) )
                 [ #  # ]
    1841         [ #  # ]:          0 :                         nScrollY = -( GetOutputArea().GetHeight() / SCRLRANGE );
    1842                 :            : 
    1843 [ #  # ][ #  # ]:          0 :                 if ( nScrollX || nScrollY )
    1844                 :            :                 {
    1845         [ #  # ]:          0 :                     HideDDCursor();
    1846         [ #  # ]:          0 :                     Scroll( nScrollX, nScrollY, RGCHK_PAPERSZ1 );
    1847                 :            :                 }
    1848                 :            :             }
    1849                 :            : 
    1850                 :          0 :             Point aDocPos( GetDocPos( aMousePos ) );
    1851         [ #  # ]:          0 :             EditPaM aPaM = pEditEngine->GetPaM( aDocPos );
    1852         [ #  # ]:          0 :             pDragAndDropInfo->aDropDest = aPaM;
    1853         [ #  # ]:          0 :             if ( pDragAndDropInfo->bOutlinerMode )
    1854                 :            :             {
    1855 [ #  # ][ #  # ]:          0 :                 sal_uInt16 nPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
                 [ #  # ]
    1856 [ #  # ][ #  # ]:          0 :                 ParaPortion* pPPortion = pEditEngine->GetParaPortions().SafeGetObject( nPara );
    1857 [ #  # ][ #  # ]:          0 :                 long nDestParaStartY = pEditEngine->GetParaPortions().GetYOffset( pPPortion );
    1858                 :          0 :                 long nRel = aDocPos.Y() - nDestParaStartY;
    1859         [ #  # ]:          0 :                 if ( nRel < ( pPPortion->GetHeight() / 2 ) )
    1860                 :            :                 {
    1861                 :          0 :                     pDragAndDropInfo->nOutlinerDropDest = nPara;
    1862                 :            :                 }
    1863                 :            :                 else
    1864                 :            :                 {
    1865                 :          0 :                     pDragAndDropInfo->nOutlinerDropDest = nPara+1;
    1866                 :            :                 }
    1867                 :            : 
    1868 [ #  # ][ #  # ]:          0 :                 if( ( pDragAndDropInfo->nOutlinerDropDest >= pDragAndDropInfo->aBeginDragSel.nStartPara ) &&
    1869                 :            :                     ( pDragAndDropInfo->nOutlinerDropDest <= (pDragAndDropInfo->aBeginDragSel.nEndPara+1) ) )
    1870                 :            :                 {
    1871                 :          0 :                     bAccept = sal_False;
    1872                 :            :                 }
    1873                 :            :             }
    1874 [ #  # ][ #  # ]:          0 :             else if ( HasSelection() )
    1875                 :            :             {
    1876                 :            :                 // it must not be dropped into a selection
    1877         [ #  # ]:          0 :                 EPaM aP = pEditEngine->pImpEditEngine->CreateEPaM( aPaM );
    1878                 :          0 :                 ESelection aDestSel( aP.nPara, aP.nIndex, aP.nPara, aP.nIndex);
    1879         [ #  # ]:          0 :                 ESelection aCurSel = pEditEngine->pImpEditEngine->CreateESel( GetEditSelection() );
    1880                 :          0 :                 aCurSel.Adjust();
    1881 [ #  # ][ #  # ]:          0 :                 if ( !aDestSel.IsLess( aCurSel ) && !aDestSel.IsGreater( aCurSel ) )
                 [ #  # ]
    1882                 :            :                 {
    1883                 :          0 :                     bAccept = sal_False;
    1884                 :            :                 }
    1885                 :            :             }
    1886         [ #  # ]:          0 :             if ( bAccept )
    1887                 :            :             {
    1888         [ #  # ]:          0 :                 Rectangle aEditCursor;
    1889         [ #  # ]:          0 :                 if ( pDragAndDropInfo->bOutlinerMode )
    1890                 :            :                 {
    1891                 :            :                     long nDDYPos;
    1892 [ #  # ][ #  # ]:          0 :                     if ( pDragAndDropInfo->nOutlinerDropDest < pEditEngine->GetEditDoc().Count() )
                 [ #  # ]
    1893                 :            :                     {
    1894 [ #  # ][ #  # ]:          0 :                         ParaPortion* pPPortion = pEditEngine->GetParaPortions().SafeGetObject( pDragAndDropInfo->nOutlinerDropDest );
    1895 [ #  # ][ #  # ]:          0 :                         nDDYPos = pEditEngine->GetParaPortions().GetYOffset( pPPortion );
    1896                 :            :                     }
    1897                 :            :                     else
    1898                 :            :                     {
    1899         [ #  # ]:          0 :                         nDDYPos = pEditEngine->pImpEditEngine->GetTextHeight();
    1900                 :            :                     }
    1901                 :          0 :                     Point aStartPos( 0, nDDYPos );
    1902                 :          0 :                     aStartPos = GetWindowPos( aStartPos );
    1903         [ #  # ]:          0 :                     Point aEndPos( GetOutputArea().GetWidth(), nDDYPos );
    1904                 :          0 :                     aEndPos = GetWindowPos( aEndPos );
    1905 [ #  # ][ #  # ]:          0 :                     aEditCursor = GetWindow()->LogicToPixel( Rectangle( aStartPos, aEndPos ) );
    1906 [ #  # ][ #  # ]:          0 :                     if ( !pEditEngine->IsVertical() )
    1907                 :            :                     {
    1908                 :          0 :                         aEditCursor.Top()--;
    1909                 :          0 :                         aEditCursor.Bottom()++;
    1910                 :            :                     }
    1911                 :            :                     else
    1912                 :            :                     {
    1913                 :          0 :                         aEditCursor.Left()--;
    1914                 :          0 :                         aEditCursor.Right()++;
    1915                 :            :                     }
    1916         [ #  # ]:          0 :                     aEditCursor = GetWindow()->PixelToLogic( aEditCursor );
    1917                 :            :                 }
    1918                 :            :                 else
    1919                 :            :                 {
    1920 [ #  # ][ #  # ]:          0 :                     aEditCursor = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM );
    1921                 :          0 :                     Point aTopLeft( GetWindowPos( aEditCursor.TopLeft() ) );
    1922                 :          0 :                     aEditCursor.SetPos( aTopLeft );
    1923                 :          0 :                     aEditCursor.Right() = aEditCursor.Left() + pDragAndDropInfo->nCursorWidth;
    1924         [ #  # ]:          0 :                     aEditCursor = GetWindow()->LogicToPixel( aEditCursor );
    1925         [ #  # ]:          0 :                     aEditCursor = GetWindow()->PixelToLogic( aEditCursor );
    1926                 :            :                 }
    1927                 :            : 
    1928 [ #  # ][ #  # ]:          0 :                 sal_Bool bCursorChanged = !pDragAndDropInfo->bVisCursor || ( pDragAndDropInfo->aCurCursor != aEditCursor );
                 [ #  # ]
    1929         [ #  # ]:          0 :                 if ( bCursorChanged )
    1930                 :            :                 {
    1931         [ #  # ]:          0 :                     HideDDCursor();
    1932         [ #  # ]:          0 :                     ShowDDCursor(aEditCursor );
    1933                 :            :                 }
    1934                 :          0 :                 pDragAndDropInfo->bDragAccepted = sal_True;
    1935 [ #  # ][ #  # ]:          0 :                 rDTDE.Context->acceptDrag( rDTDE.DropAction );
    1936                 :            :             }
    1937                 :            :         }
    1938                 :            :     }
    1939                 :            : 
    1940         [ #  # ]:          0 :     if ( !bAccept )
    1941                 :            :     {
    1942         [ #  # ]:          0 :         HideDDCursor();
    1943         [ #  # ]:          0 :         if (pDragAndDropInfo)
    1944                 :          0 :             pDragAndDropInfo->bDragAccepted = sal_False;
    1945 [ #  # ][ #  # ]:          0 :         rDTDE.Context->rejectDrag();
    1946         [ #  # ]:          0 :     }
    1947                 :          0 : }
    1948                 :            : 
    1949                 :        297 : void ImpEditView::AddDragAndDropListeners()
    1950                 :            : {
    1951                 :        297 :     Window* pWindow = GetWindow();
    1952 [ +  - ][ +  - ]:        297 :     if ( !bActiveDragAndDropListener && pWindow && pWindow->GetDragGestureRecognizer().is() )
         [ +  - ][ +  - ]
           [ +  -  #  # ]
                 [ +  - ]
    1953                 :            :     {
    1954         [ +  - ]:        297 :         vcl::unohelper::DragAndDropWrapper* pDnDWrapper = new vcl::unohelper::DragAndDropWrapper( this );
    1955 [ +  - ][ +  - ]:        297 :         mxDnDListener = pDnDWrapper;
    1956                 :            : 
    1957         [ +  - ]:        297 :         uno::Reference< datatransfer::dnd::XDragGestureListener> xDGL( mxDnDListener, uno::UNO_QUERY );
    1958 [ +  - ][ +  - ]:        297 :         pWindow->GetDragGestureRecognizer()->addDragGestureListener( xDGL );
                 [ +  - ]
    1959         [ +  - ]:        297 :         uno::Reference< datatransfer::dnd::XDropTargetListener> xDTL( xDGL, uno::UNO_QUERY );
    1960 [ +  - ][ +  - ]:        297 :         pWindow->GetDropTarget()->addDropTargetListener( xDTL );
                 [ +  - ]
    1961 [ +  - ][ +  - ]:        297 :         pWindow->GetDropTarget()->setActive( sal_True );
                 [ +  - ]
    1962 [ +  - ][ +  - ]:        297 :         pWindow->GetDropTarget()->setDefaultActions( datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE );
                 [ +  - ]
    1963                 :            : 
    1964                 :        297 :         bActiveDragAndDropListener = sal_True;
    1965                 :            :     }
    1966                 :        297 : }
    1967                 :            : 
    1968                 :        368 : void ImpEditView::RemoveDragAndDropListeners()
    1969                 :            : {
    1970 [ +  + ][ +  + ]:        368 :     if ( bActiveDragAndDropListener && GetWindow() && GetWindow()->GetDragGestureRecognizer().is() )
         [ +  - ][ +  - ]
                 [ +  + ]
           [ +  +  #  # ]
    1971                 :            :     {
    1972         [ +  - ]:        279 :         uno::Reference< datatransfer::dnd::XDragGestureListener> xDGL( mxDnDListener, uno::UNO_QUERY );
    1973 [ +  - ][ +  - ]:        279 :         GetWindow()->GetDragGestureRecognizer()->removeDragGestureListener( xDGL );
                 [ +  - ]
    1974         [ +  - ]:        279 :         uno::Reference< datatransfer::dnd::XDropTargetListener> xDTL( xDGL, uno::UNO_QUERY );
    1975 [ +  - ][ +  - ]:        279 :         GetWindow()->GetDropTarget()->removeDropTargetListener( xDTL );
                 [ +  - ]
    1976                 :            : 
    1977         [ +  - ]:        279 :         if ( mxDnDListener.is() )
    1978                 :            :         {
    1979         [ +  - ]:        279 :             uno::Reference< lang::XEventListener> xEL( mxDnDListener, uno::UNO_QUERY );
    1980 [ +  - ][ +  - ]:        279 :             xEL->disposing( lang::EventObject() );  // #95154# Empty Source means it's the Client
         [ +  - ][ +  - ]
    1981                 :        279 :             mxDnDListener.clear();
    1982                 :            :         }
    1983                 :            : 
    1984                 :        279 :         bActiveDragAndDropListener = sal_False;
    1985                 :            :     }
    1986                 :        368 : }
    1987                 :            : 
    1988                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10