2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 10:05:04 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
#include <hintids.hxx>
|
|
|
|
#include <sfx2/bindings.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/eitem.hxx>
|
|
|
|
#include <svl/macitem.hxx>
|
2000-10-25 14:39:12 +00:00
|
|
|
#include <unotools/charclass.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/scripttypeitem.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <cmdid.h>
|
|
|
|
#include <view.hxx>
|
|
|
|
#include <basesh.hxx>
|
|
|
|
#include <wrtsh.hxx>
|
|
|
|
#include <frmatr.hxx>
|
|
|
|
#include <initui.hxx>
|
|
|
|
#include <mdiexp.hxx>
|
|
|
|
#include <fmtcol.hxx>
|
|
|
|
#include <frmfmt.hxx>
|
2013-03-17 23:16:05 +01:00
|
|
|
#include <swundo.hxx> // for Undo-Ids
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <swevent.hxx>
|
2001-09-11 13:57:42 +00:00
|
|
|
#include <swdtflvr.hxx>
|
2002-02-01 11:51:13 +00:00
|
|
|
#include <crsskip.hxx>
|
2011-11-02 16:03:13 +00:00
|
|
|
#include <wordcountdialog.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
|
2001-03-12 07:18:49 +00:00
|
|
|
namespace com { namespace sun { namespace star { namespace util {
|
|
|
|
struct SearchOptions;
|
|
|
|
} } } }
|
|
|
|
|
2007-09-27 11:53:01 +00:00
|
|
|
using namespace ::com::sun::star::util;
|
2001-03-12 07:18:49 +00:00
|
|
|
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
static long nStartDragX = 0, nStartDragY = 0;
|
2013-03-01 15:42:53 +09:00
|
|
|
static bool bStartDrag = false;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2009-09-18 10:15:03 +00:00
|
|
|
void SwWrtShell::Invalidate()
|
|
|
|
{
|
|
|
|
// to avoid making the slot volatile, invalidate it everytime if something could have been changed
|
|
|
|
// this is still much cheaper than asking for the state every 200 ms (and avoid background processing)
|
|
|
|
GetView().GetViewFrame()->GetBindings().Invalidate( FN_STAT_SELMODE );
|
2011-11-02 16:03:13 +00:00
|
|
|
SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
|
|
|
|
if (pWrdCnt)
|
|
|
|
pWrdCnt->UpdateCounts();
|
2009-09-18 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwWrtShell::SelNearestWrd()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-09-02 16:05:21 +04:00
|
|
|
SwMvContext aMvContext(this);
|
2000-09-18 16:15:01 +00:00
|
|
|
if( !IsInWrd() && !IsEndWrd() && !IsSttWrd() )
|
|
|
|
PrvWrd();
|
|
|
|
if( IsEndWrd() )
|
2011-01-17 15:06:54 +01:00
|
|
|
Left(CRSR_SKIP_CELLS, sal_False, 1, sal_False );
|
2000-09-18 16:15:01 +00:00
|
|
|
return SelWrd();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwWrtShell::SelWrd(const Point *pPt, sal_Bool )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bRet;
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-09-02 16:05:21 +04:00
|
|
|
SwMvContext aMvContext(this);
|
2000-09-18 16:15:01 +00:00
|
|
|
SttSelect();
|
|
|
|
bRet = SwCrsrShell::SelectWord( pPt );
|
|
|
|
}
|
|
|
|
EndSelect();
|
|
|
|
if( bRet )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
bSelWrd = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
if(pPt)
|
|
|
|
aStart = *pPt;
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwWrtShell::SelSentence(const Point *pPt, sal_Bool )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
{
|
2012-09-02 16:05:21 +04:00
|
|
|
SwMvContext aMvContext(this);
|
2000-09-18 16:15:01 +00:00
|
|
|
ClearMark();
|
2004-09-09 08:15:18 +00:00
|
|
|
SwCrsrShell::GoStartSentence();
|
2000-09-18 16:15:01 +00:00
|
|
|
SttSelect();
|
2004-09-09 08:15:18 +00:00
|
|
|
SwCrsrShell::GoEndSentence();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
EndSelect();
|
2004-09-09 08:15:18 +00:00
|
|
|
if(pPt)
|
|
|
|
aStart = *pPt;
|
2011-01-17 15:06:54 +01:00
|
|
|
bSelLn = sal_True;
|
2013-03-17 23:16:05 +01:00
|
|
|
bSelWrd = sal_False; // disable SelWord, otherwise no SelLine goes on
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwWrtShell::SelPara(const Point *pPt, sal_Bool )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
{
|
2012-09-02 16:05:21 +04:00
|
|
|
SwMvContext aMvContext(this);
|
2000-09-18 16:15:01 +00:00
|
|
|
ClearMark();
|
2004-09-09 08:15:18 +00:00
|
|
|
SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
|
2000-09-18 16:15:01 +00:00
|
|
|
SttSelect();
|
2004-09-09 08:15:18 +00:00
|
|
|
SwCrsrShell::MovePara( fnParaCurr, fnParaEnd );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
EndSelect();
|
|
|
|
if(pPt)
|
|
|
|
aStart = *pPt;
|
2011-01-17 15:06:54 +01:00
|
|
|
bSelLn = sal_False;
|
2013-03-17 23:16:05 +01:00
|
|
|
bSelWrd = sal_False; // disable SelWord, otherwise no SelLine goes on
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long SwWrtShell::SelAll()
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_Bool bLockedView = IsViewLocked();
|
|
|
|
LockView( sal_True );
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2009-08-27 15:54:55 +00:00
|
|
|
if(bBlockMode)
|
|
|
|
LeaveBlockMode();
|
2012-09-02 16:05:21 +04:00
|
|
|
SwMvContext aMvContext(this);
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bMoveTable = sal_False;
|
2009-02-13 11:19:56 +00:00
|
|
|
SwPosition *pStartPos = 0;
|
|
|
|
SwPosition *pEndPos = 0;
|
|
|
|
SwShellCrsr* pTmpCrsr = 0;
|
2000-09-18 16:15:01 +00:00
|
|
|
if( !HasWholeTabSelection() )
|
|
|
|
{
|
|
|
|
if ( IsSelection() && IsCrsrPtAtEnd() )
|
|
|
|
SwapPam();
|
2009-02-13 11:19:56 +00:00
|
|
|
pTmpCrsr = getShellCrsr( false );
|
|
|
|
if( pTmpCrsr )
|
|
|
|
{
|
|
|
|
pStartPos = new SwPosition( *pTmpCrsr->GetPoint() );
|
|
|
|
pEndPos = new SwPosition( *pTmpCrsr->GetMark() );
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
Push();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bIsFullSel = !MoveSection( fnSectionCurr, fnSectionStart);
|
2000-09-18 16:15:01 +00:00
|
|
|
SwapPam();
|
|
|
|
bIsFullSel &= !MoveSection( fnSectionCurr, fnSectionEnd);
|
2011-01-17 15:06:54 +01:00
|
|
|
Pop(sal_False);
|
|
|
|
GoStart(sal_True, &bMoveTable, sal_False, !bIsFullSel);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EnterStdMode();
|
2011-01-17 15:06:54 +01:00
|
|
|
SttEndDoc(sal_True);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
SttSelect();
|
2011-01-17 15:06:54 +01:00
|
|
|
GoEnd(sal_True, &bMoveTable);
|
2013-09-16 12:12:42 +02:00
|
|
|
|
|
|
|
if (StartsWithTable())
|
|
|
|
ExtendedSelectAll();
|
|
|
|
|
2009-02-13 11:19:56 +00:00
|
|
|
if( pStartPos )
|
|
|
|
{
|
|
|
|
pTmpCrsr = getShellCrsr( false );
|
|
|
|
if( pTmpCrsr )
|
|
|
|
{
|
|
|
|
// Some special handling for sections (e.g. TOC) at the beginning of the document body
|
|
|
|
// to avoid the selection of the first section
|
|
|
|
// if the last selection was behind the first section or
|
|
|
|
// if the last selection was already the first section
|
|
|
|
// In this both cases we select to the end of document
|
|
|
|
if( *pTmpCrsr->GetPoint() < *pEndPos ||
|
|
|
|
( *pStartPos == *pTmpCrsr->GetMark() &&
|
|
|
|
*pEndPos == *pTmpCrsr->GetPoint() ) )
|
2011-01-17 15:06:54 +01:00
|
|
|
SwCrsrShell::SttEndDoc(sal_False);
|
2009-02-13 11:19:56 +00:00
|
|
|
}
|
|
|
|
delete pStartPos;
|
|
|
|
delete pEndPos;
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
EndSelect();
|
2003-03-27 14:45:43 +00:00
|
|
|
LockView( bLockedView );
|
2000-09-18 16:15:01 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Desciption: Text search
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong SwWrtShell::SearchPattern( const SearchOptions& rSearchOpt, sal_Bool bSearchInNotes,
|
2000-09-18 16:15:01 +00:00
|
|
|
SwDocPositions eStt, SwDocPositions eEnd,
|
|
|
|
FindRanges eFlags, int bReplace )
|
|
|
|
{
|
2013-03-17 23:16:05 +01:00
|
|
|
// no enhancement of existing selections
|
2000-09-18 16:15:01 +00:00
|
|
|
if(!(eFlags & FND_IN_SEL))
|
|
|
|
ClearMark();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bCancel = sal_False;
|
|
|
|
sal_uLong nRet = Find( rSearchOpt, bSearchInNotes, eStt, eEnd, bCancel, eFlags, bReplace );
|
2002-09-13 12:19:33 +00:00
|
|
|
if(bCancel)
|
|
|
|
{
|
2010-12-15 09:14:11 +01:00
|
|
|
Undo(1);
|
2002-09-13 12:19:33 +00:00
|
|
|
nRet = ULONG_MAX;
|
|
|
|
}
|
|
|
|
return nRet;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Description: search for templates
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong SwWrtShell::SearchTempl( const String &rTempl,
|
2000-09-18 16:15:01 +00:00
|
|
|
SwDocPositions eStt, SwDocPositions eEnd,
|
|
|
|
FindRanges eFlags, const String* pReplTempl )
|
|
|
|
{
|
2013-03-17 23:16:05 +01:00
|
|
|
// no enhancement of existing selections
|
2000-09-18 16:15:01 +00:00
|
|
|
if(!(eFlags & FND_IN_SEL))
|
|
|
|
ClearMark();
|
|
|
|
SwTxtFmtColl *pColl = GetParaStyle(rTempl, SwWrtShell::GETSTYLE_CREATESOME);
|
|
|
|
SwTxtFmtColl *pReplaceColl = 0;
|
|
|
|
if( pReplTempl )
|
|
|
|
pReplaceColl = GetParaStyle(*pReplTempl, SwWrtShell::GETSTYLE_CREATESOME );
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bCancel = sal_False;
|
|
|
|
sal_uLong nRet = Find(pColl? *pColl: GetDfltTxtFmtColl(),
|
2002-09-13 12:19:33 +00:00
|
|
|
eStt,eEnd, bCancel, eFlags, pReplaceColl);
|
|
|
|
if(bCancel)
|
|
|
|
{
|
2010-12-15 09:14:11 +01:00
|
|
|
Undo(1);
|
2002-09-13 12:19:33 +00:00
|
|
|
nRet = ULONG_MAX;
|
|
|
|
}
|
|
|
|
return nRet;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// search for attributes
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong SwWrtShell::SearchAttr( const SfxItemSet& rFindSet, sal_Bool bNoColls,
|
2000-09-18 16:15:01 +00:00
|
|
|
SwDocPositions eStart, SwDocPositions eEnde,
|
2001-03-12 07:18:49 +00:00
|
|
|
FindRanges eFlags, const SearchOptions* pSearchOpt,
|
2000-09-18 16:15:01 +00:00
|
|
|
const SfxItemSet* pReplaceSet )
|
|
|
|
{
|
2013-03-17 23:16:05 +01:00
|
|
|
// no enhancement of existing selections
|
2000-09-18 16:15:01 +00:00
|
|
|
if (!(eFlags & FND_IN_SEL))
|
|
|
|
ClearMark();
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Searching
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bCancel = sal_False;
|
|
|
|
sal_uLong nRet = Find( rFindSet, bNoColls, eStart, eEnde, bCancel, eFlags, pSearchOpt, pReplaceSet);
|
2002-09-13 12:19:33 +00:00
|
|
|
|
|
|
|
if(bCancel)
|
|
|
|
{
|
2010-12-15 09:14:11 +01:00
|
|
|
Undo(1);
|
2002-09-13 12:19:33 +00:00
|
|
|
nRet = ULONG_MAX;
|
|
|
|
}
|
|
|
|
return nRet;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Selection modes
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
void SwWrtShell::PushMode()
|
|
|
|
{
|
2007-11-22 14:42:50 +00:00
|
|
|
pModeStack = new ModeStack( pModeStack, bIns, bExtMode, bAddMode, bBlockMode );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwWrtShell::PopMode()
|
|
|
|
{
|
|
|
|
if ( 0 == pModeStack )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( bExtMode && !pModeStack->bExt )
|
|
|
|
LeaveExtMode();
|
|
|
|
if ( bAddMode && !pModeStack->bAdd )
|
|
|
|
LeaveAddMode();
|
2007-11-22 14:42:50 +00:00
|
|
|
if ( bBlockMode && !pModeStack->bBlock )
|
|
|
|
LeaveBlockMode();
|
2000-09-18 16:15:01 +00:00
|
|
|
bIns = pModeStack->bIns;
|
|
|
|
|
|
|
|
ModeStack *pTmp = pModeStack->pNext;
|
|
|
|
delete pModeStack;
|
|
|
|
pModeStack = pTmp;
|
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Two methodes for setting cursors: the first maps at the
|
|
|
|
// eponymous methodes in the CursorShell, the second removes
|
|
|
|
// all selections at first.
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
long SwWrtShell::SetCrsr(const Point *pPt, sal_Bool bTextOnly)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-03-17 23:16:05 +01:00
|
|
|
// Remove a possibly present selection at the position
|
|
|
|
// of the mouseclick
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
if(!IsInSelect() && ChgCurrPam(*pPt)) {
|
|
|
|
ClearMark();
|
|
|
|
}
|
2006-07-26 11:19:57 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
return SwCrsrShell::SetCrsr(*pPt, bTextOnly);
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
long SwWrtShell::SetCrsrKillSel(const Point *pPt, sal_Bool bTextOnly )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-09-02 16:05:21 +04:00
|
|
|
SwActContext aActContext(this);
|
2011-01-17 15:06:54 +01:00
|
|
|
ResetSelect(pPt,sal_False);
|
2000-09-18 16:15:01 +00:00
|
|
|
return SwCrsrShell::SetCrsr(*pPt, bTextOnly);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwWrtShell::UnSelectFrm()
|
|
|
|
{
|
2013-03-17 23:16:05 +01:00
|
|
|
// Remove Frame selection with guaranteed invalid position
|
2000-09-18 16:15:01 +00:00
|
|
|
Point aPt(LONG_MIN, LONG_MIN);
|
2002-04-23 13:10:22 +00:00
|
|
|
SelectObj(aPt, 0);
|
2001-09-11 13:57:42 +00:00
|
|
|
SwTransferable::ClearSelection( *this );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Remove of all selections
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
long SwWrtShell::ResetSelect(const Point *,sal_Bool)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
if(IsSelFrmMode())
|
|
|
|
{
|
|
|
|
UnSelectFrm();
|
|
|
|
LeaveSelFrmMode();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-17 23:16:05 +01:00
|
|
|
// SwActContext opens an Action -
|
|
|
|
// to avoid problems in the basic process with the
|
|
|
|
// shell switching, GetChgLnk().Call() may be called
|
|
|
|
// after EndAction().
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-09-02 16:05:21 +04:00
|
|
|
SwActContext aActContext(this);
|
2011-01-17 15:06:54 +01:00
|
|
|
bSelWrd = bSelLn = sal_False;
|
2000-09-18 16:15:01 +00:00
|
|
|
KillPams();
|
|
|
|
ClearMark();
|
|
|
|
fnKillSel = &SwWrtShell::Ignore;
|
|
|
|
fnSetCrsr = &SwWrtShell::SetCrsr;
|
|
|
|
}
|
2013-03-17 23:16:05 +01:00
|
|
|
|
|
|
|
// After canceling of all selections an update of Attr-Controls
|
|
|
|
// could be necessary.
|
2000-09-18 16:15:01 +00:00
|
|
|
GetChgLnk().Call(this);
|
|
|
|
}
|
2009-09-18 10:15:03 +00:00
|
|
|
Invalidate();
|
2001-09-11 13:57:42 +00:00
|
|
|
SwTransferable::ClearSelection( *this );
|
2000-09-18 16:15:01 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Do nothing
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
long SwWrtShell::Ignore(const Point *, sal_Bool ) {
|
2000-09-18 16:15:01 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Begin of a selection process.
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
void SwWrtShell::SttSelect()
|
|
|
|
{
|
|
|
|
if(bInSelect)
|
|
|
|
return;
|
|
|
|
if(!HasMark())
|
|
|
|
SetMark();
|
2007-11-22 14:42:50 +00:00
|
|
|
if( bBlockMode )
|
|
|
|
{
|
|
|
|
SwShellCrsr* pTmp = getShellCrsr( true );
|
|
|
|
if( !pTmp->HasMark() )
|
|
|
|
pTmp->SetMark();
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
fnKillSel = &SwWrtShell::Ignore;
|
|
|
|
fnSetCrsr = &SwWrtShell::SetCrsr;
|
2011-01-17 15:06:54 +01:00
|
|
|
bInSelect = sal_True;
|
2009-09-18 10:15:03 +00:00
|
|
|
Invalidate();
|
2001-09-11 13:57:42 +00:00
|
|
|
SwTransferable::CreateSelection( *this );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// End of a selection process.
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
void SwWrtShell::EndSelect()
|
|
|
|
{
|
2011-11-02 16:03:13 +00:00
|
|
|
if(bInSelect && !bExtMode)
|
|
|
|
{
|
|
|
|
bInSelect = sal_False;
|
2011-11-27 15:55:22 +09:00
|
|
|
if (bAddMode)
|
2011-11-02 16:03:13 +00:00
|
|
|
{
|
2011-11-27 15:55:22 +09:00
|
|
|
AddLeaveSelect(0, sal_False);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SttLeaveSelect(0, sal_False);
|
2011-11-02 16:03:13 +00:00
|
|
|
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
|
|
|
|
fnKillSel = &SwWrtShell::ResetSelect;
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2011-11-02 16:03:13 +00:00
|
|
|
SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
|
|
|
|
if (pWrdCnt)
|
|
|
|
pWrdCnt->UpdateCounts();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2013-03-17 23:16:05 +01:00
|
|
|
|
|
|
|
// Methode to enhance a selecton word by word or line by line.
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-03-01 15:42:53 +09:00
|
|
|
inline bool operator<(const Point &rP1,const Point &rP2)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
return rP1.Y() < rP2.Y() || (rP1.Y() == rP2.Y() && rP1.X() < rP2.X());
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
long SwWrtShell::ExtSelWrd(const Point *pPt, sal_Bool )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-09-02 16:05:21 +04:00
|
|
|
SwMvContext aMvContext(this);
|
2000-09-18 16:15:01 +00:00
|
|
|
if( IsTableMode() )
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
// Bug 66823: actual crsr has in additional mode no selection?
|
|
|
|
// Then destroy the actual an go to prev, this will be expand
|
|
|
|
if( !HasMark() && GoPrevCrsr() )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bHasMark = HasMark(); // thats wrong!
|
2000-09-18 16:15:01 +00:00
|
|
|
GoNextCrsr();
|
|
|
|
if( bHasMark )
|
|
|
|
{
|
|
|
|
DestroyCrsr();
|
|
|
|
GoPrevCrsr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check the direction of the selection with the new point
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bRet = sal_False, bMoveCrsr = sal_True, bToTop = sal_False;
|
2000-09-18 16:15:01 +00:00
|
|
|
SwCrsrShell::SelectWord( &aStart ); // select the startword
|
|
|
|
SwCrsrShell::Push(); // save the cursor
|
|
|
|
SwCrsrShell::SetCrsr( *pPt ); // and check the direction
|
|
|
|
|
|
|
|
switch( SwCrsrShell::CompareCursor( StackMkCurrPt ))
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
case -1: bToTop = sal_False; break;
|
|
|
|
case 1: bToTop = sal_True; break;
|
|
|
|
default: bMoveCrsr = sal_False; break;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
SwCrsrShell::Pop( sal_False ); // retore the saved cursor
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if( bMoveCrsr )
|
|
|
|
{
|
|
|
|
// select to Top but cursor select to Bottom? or
|
|
|
|
// select to Bottom but cursor select to Top? --> swap the cursor
|
|
|
|
if( bToTop )
|
|
|
|
SwapPam();
|
|
|
|
|
|
|
|
SwCrsrShell::Push(); // save cur cursor
|
|
|
|
if( SwCrsrShell::SelectWord( pPt )) // select the current word
|
|
|
|
{
|
|
|
|
if( bToTop )
|
|
|
|
SwapPam();
|
|
|
|
Combine();
|
2011-01-17 15:06:54 +01:00
|
|
|
bRet = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
SwCrsrShell::Pop( sal_False );
|
2000-09-18 16:15:01 +00:00
|
|
|
if( bToTop )
|
|
|
|
SwapPam();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-01-17 15:06:54 +01:00
|
|
|
bRet = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
long SwWrtShell::ExtSelLn(const Point *pPt, sal_Bool )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-09-02 16:05:21 +04:00
|
|
|
SwMvContext aMvContext(this);
|
2000-09-18 16:15:01 +00:00
|
|
|
SwCrsrShell::SetCrsr(*pPt);
|
|
|
|
if( IsTableMode() )
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
// Bug 66823: actual crsr has in additional mode no selection?
|
|
|
|
// Then destroy the actual an go to prev, this will be expand
|
|
|
|
if( !HasMark() && GoPrevCrsr() )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bHasMark = HasMark(); // thats wrong!
|
2000-09-18 16:15:01 +00:00
|
|
|
GoNextCrsr();
|
|
|
|
if( bHasMark )
|
|
|
|
{
|
|
|
|
DestroyCrsr();
|
|
|
|
GoPrevCrsr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// if applicable fit the selection to the "Mark"
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bToTop = !IsCrsrPtAtEnd();
|
2000-09-18 16:15:01 +00:00
|
|
|
SwapPam();
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// The "Mark" has to be at the end or the beginning of the line.
|
2004-09-09 08:15:18 +00:00
|
|
|
if( bToTop ? !IsEndSentence() : !IsStartSentence() )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
if( bToTop )
|
|
|
|
{
|
|
|
|
if( !IsEndPara() )
|
2002-02-01 11:51:13 +00:00
|
|
|
SwCrsrShell::Right(1,CRSR_SKIP_CHARS);
|
2004-09-09 08:15:18 +00:00
|
|
|
SwCrsrShell::GoEndSentence();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
else
|
2004-09-09 08:15:18 +00:00
|
|
|
SwCrsrShell::GoStartSentence();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
SwapPam();
|
|
|
|
|
2004-09-09 08:15:18 +00:00
|
|
|
return bToTop ? SwCrsrShell::GoStartSentence() : SwCrsrShell::GoEndSentence();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Back into the standard mode: no mode, no selections.
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
void SwWrtShell::EnterStdMode()
|
|
|
|
{
|
|
|
|
if(bAddMode)
|
|
|
|
LeaveAddMode();
|
2007-11-22 14:42:50 +00:00
|
|
|
if(bBlockMode)
|
|
|
|
LeaveBlockMode();
|
2011-01-17 15:06:54 +01:00
|
|
|
bBlockMode = sal_False;
|
|
|
|
bExtMode = sal_False;
|
|
|
|
bInSelect = sal_False;
|
2002-10-24 10:05:45 +00:00
|
|
|
if(IsSelFrmMode())
|
|
|
|
{
|
|
|
|
UnSelectFrm();
|
|
|
|
LeaveSelFrmMode();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-17 23:16:05 +01:00
|
|
|
// SwActContext opens and action which has to be
|
|
|
|
// closed prior to the call of
|
|
|
|
// GetChgLnk().Call()
|
2002-10-24 10:05:45 +00:00
|
|
|
{
|
2012-09-02 16:05:21 +04:00
|
|
|
SwActContext aActContext(this);
|
2011-01-17 15:06:54 +01:00
|
|
|
bSelWrd = bSelLn = sal_False;
|
2007-11-22 14:42:50 +00:00
|
|
|
if( !IsRetainSelection() )
|
|
|
|
KillPams();
|
2002-10-24 10:05:45 +00:00
|
|
|
ClearMark();
|
|
|
|
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
|
|
|
|
fnKillSel = &SwWrtShell::ResetSelect;
|
|
|
|
}
|
|
|
|
}
|
2009-09-18 10:15:03 +00:00
|
|
|
Invalidate();
|
2002-10-24 10:05:45 +00:00
|
|
|
SwTransferable::ClearSelection( *this );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Extended Mode
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
void SwWrtShell::EnterExtMode()
|
|
|
|
{
|
2007-11-22 14:42:50 +00:00
|
|
|
if(bBlockMode)
|
|
|
|
{
|
|
|
|
LeaveBlockMode();
|
|
|
|
KillPams();
|
|
|
|
ClearMark();
|
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
bExtMode = sal_True;
|
|
|
|
bAddMode = sal_False;
|
|
|
|
bBlockMode = sal_False;
|
2000-09-18 16:15:01 +00:00
|
|
|
SttSelect();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwWrtShell::LeaveExtMode()
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
bExtMode = sal_False;
|
2000-09-18 16:15:01 +00:00
|
|
|
EndSelect();
|
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// End of a selection; if the selection is empty,
|
|
|
|
// ClearMark().
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
long SwWrtShell::SttLeaveSelect(const Point *, sal_Bool )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
if(SwCrsrShell::HasSelection() && !IsSelTblCells() && bClearMark) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
ClearMark();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Leaving of the selection mode in additional mode
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
long SwWrtShell::AddLeaveSelect(const Point *, sal_Bool )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
if(IsTableMode()) LeaveAddMode();
|
|
|
|
else if(SwCrsrShell::HasSelection())
|
|
|
|
CreateCrsr();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Additional Mode
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
void SwWrtShell::EnterAddMode()
|
|
|
|
{
|
|
|
|
if(IsTableMode()) return;
|
2007-11-22 14:42:50 +00:00
|
|
|
if(bBlockMode)
|
|
|
|
LeaveBlockMode();
|
2000-09-18 16:15:01 +00:00
|
|
|
fnKillSel = &SwWrtShell::Ignore;
|
|
|
|
fnSetCrsr = &SwWrtShell::SetCrsr;
|
2011-01-17 15:06:54 +01:00
|
|
|
bAddMode = sal_True;
|
|
|
|
bBlockMode = sal_False;
|
|
|
|
bExtMode = sal_False;
|
2000-09-18 16:15:01 +00:00
|
|
|
if(SwCrsrShell::HasSelection())
|
|
|
|
CreateCrsr();
|
2009-09-18 10:15:03 +00:00
|
|
|
Invalidate();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwWrtShell::LeaveAddMode()
|
|
|
|
{
|
|
|
|
fnKillSel = &SwWrtShell::ResetSelect;
|
|
|
|
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
|
2011-01-17 15:06:54 +01:00
|
|
|
bAddMode = sal_False;
|
2009-09-18 10:15:03 +00:00
|
|
|
Invalidate();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Block Mode
|
2007-11-22 14:42:50 +00:00
|
|
|
|
|
|
|
void SwWrtShell::EnterBlockMode()
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
bBlockMode = sal_False;
|
2007-11-22 14:42:50 +00:00
|
|
|
EnterStdMode();
|
2011-01-17 15:06:54 +01:00
|
|
|
bBlockMode = sal_True;
|
2007-11-22 14:42:50 +00:00
|
|
|
CrsrToBlockCrsr();
|
2009-09-18 10:15:03 +00:00
|
|
|
Invalidate();
|
2007-11-22 14:42:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwWrtShell::LeaveBlockMode()
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
bBlockMode = sal_False;
|
2007-11-22 14:42:50 +00:00
|
|
|
BlockCrsrToCrsr();
|
|
|
|
EndSelect();
|
2009-09-18 10:15:03 +00:00
|
|
|
Invalidate();
|
2007-11-22 14:42:50 +00:00
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Insert mode
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwWrtShell::SetInsMode( sal_Bool bOn )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
bIns = bOn;
|
2000-11-28 17:49:16 +00:00
|
|
|
SwCrsrShell::SetOverwriteCrsr( !bIns );
|
2000-09-18 16:15:01 +00:00
|
|
|
const SfxBoolItem aTmp( SID_ATTR_INSERT, bIns );
|
|
|
|
GetView().GetViewFrame()->GetBindings().SetState( aTmp );
|
2000-11-28 17:49:16 +00:00
|
|
|
StartAction();
|
|
|
|
EndAction();
|
2009-09-18 10:15:03 +00:00
|
|
|
Invalidate();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2009-08-06 12:44:16 +00:00
|
|
|
//Overwrite mode is incompatible with red-lining
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwWrtShell::SetRedlineModeAndCheckInsMode( sal_uInt16 eMode )
|
2009-08-06 12:44:16 +00:00
|
|
|
{
|
|
|
|
SetRedlineMode( eMode );
|
|
|
|
if (IsRedlineOn())
|
|
|
|
SetInsMode( true );
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Edit frame
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
long SwWrtShell::BeginFrmDrag(const Point *pPt, sal_Bool)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
fnDrag = &SwFEShell::Drag;
|
|
|
|
if(bStartDrag)
|
|
|
|
{
|
|
|
|
Point aTmp( nStartDragX, nStartDragY );
|
2011-01-17 15:06:54 +01:00
|
|
|
SwFEShell::BeginDrag( &aTmp, sal_False );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
else
|
2011-01-17 15:06:54 +01:00
|
|
|
SwFEShell::BeginDrag( pPt, sal_False );
|
2000-09-18 16:15:01 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwWrtShell::EnterSelFrmMode(const Point *pPos)
|
|
|
|
{
|
|
|
|
if(pPos)
|
|
|
|
{
|
|
|
|
nStartDragX = pPos->X();
|
|
|
|
nStartDragY = pPos->Y();
|
2013-03-01 15:42:53 +09:00
|
|
|
bStartDrag = true;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2013-02-06 22:43:27 +09:00
|
|
|
bLayoutMode = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
HideCrsr();
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// equal call of BeginDrag in the SwFEShell
|
2000-09-18 16:15:01 +00:00
|
|
|
fnDrag = &SwWrtShell::BeginFrmDrag;
|
|
|
|
fnEndDrag = &SwWrtShell::UpdateLayoutFrm;
|
|
|
|
SwBaseShell::SetFrmMode( FLY_DRAG_START, this );
|
2009-09-18 10:15:03 +00:00
|
|
|
Invalidate();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwWrtShell::LeaveSelFrmMode()
|
|
|
|
{
|
|
|
|
fnDrag = &SwWrtShell::BeginDrag;
|
|
|
|
fnEndDrag = &SwWrtShell::EndDrag;
|
2011-01-17 15:06:54 +01:00
|
|
|
bLayoutMode = sal_False;
|
2013-03-01 15:42:53 +09:00
|
|
|
bStartDrag = false;
|
2000-09-18 16:15:01 +00:00
|
|
|
Edit();
|
|
|
|
SwBaseShell::SetFrmMode( FLY_DRAG_END, this );
|
2009-09-18 10:15:03 +00:00
|
|
|
Invalidate();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Description: execute framebound macro
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
IMPL_LINK( SwWrtShell, ExecFlyMac, void *, pFlyFmt )
|
|
|
|
{
|
|
|
|
const SwFrmFmt *pFmt = pFlyFmt ? (SwFrmFmt*)pFlyFmt : GetFlyFrmFmt();
|
2010-10-24 23:48:32 +02:00
|
|
|
OSL_ENSURE(pFmt, "no frame format");
|
2000-09-18 16:15:01 +00:00
|
|
|
const SvxMacroItem &rFmtMac = pFmt->GetMacro();
|
|
|
|
|
|
|
|
if(rFmtMac.HasMacro(SW_EVENT_OBJECT_SELECT))
|
|
|
|
{
|
|
|
|
const SvxMacro &rMac = rFmtMac.GetMacro(SW_EVENT_OBJECT_SELECT);
|
|
|
|
if( IsFrmSelected() )
|
2011-01-17 15:06:54 +01:00
|
|
|
bLayoutMode = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
CallChgLnk();
|
|
|
|
ExecMacro( rMac );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
long SwWrtShell::UpdateLayoutFrm(const Point *pPt, sal_Bool )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-03-17 23:16:05 +01:00
|
|
|
// still a dummy
|
2011-01-17 15:06:54 +01:00
|
|
|
SwFEShell::EndDrag( pPt, sal_False );
|
2000-09-18 16:15:01 +00:00
|
|
|
fnDrag = &SwWrtShell::BeginFrmDrag;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Handler for toggling the modes. Returns back the old mode.
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
long SwWrtShell::ToggleAddMode()
|
|
|
|
{
|
|
|
|
bAddMode ? LeaveAddMode(): EnterAddMode();
|
2009-09-18 10:15:03 +00:00
|
|
|
Invalidate();
|
2000-09-18 16:15:01 +00:00
|
|
|
return !bAddMode;
|
|
|
|
}
|
|
|
|
|
2007-11-22 14:42:50 +00:00
|
|
|
long SwWrtShell::ToggleBlockMode()
|
|
|
|
{
|
|
|
|
bBlockMode ? LeaveBlockMode(): EnterBlockMode();
|
2009-09-18 10:15:03 +00:00
|
|
|
Invalidate();
|
2007-11-22 14:42:50 +00:00
|
|
|
return !bBlockMode;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
long SwWrtShell::ToggleExtMode()
|
|
|
|
{
|
|
|
|
bExtMode ? LeaveExtMode() : EnterExtMode();
|
2009-09-18 10:15:03 +00:00
|
|
|
Invalidate();
|
2000-09-18 16:15:01 +00:00
|
|
|
return !bExtMode;
|
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Dragging in standard mode (Selecting of content)
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
long SwWrtShell::BeginDrag(const Point * /*pPt*/, sal_Bool )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
if(bSelWrd)
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
bInSelect = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
if( !IsCrsrPtAtEnd() )
|
|
|
|
SwapPam();
|
|
|
|
|
|
|
|
fnDrag = &SwWrtShell::ExtSelWrd;
|
|
|
|
fnSetCrsr = &SwWrtShell::Ignore;
|
|
|
|
}
|
|
|
|
else if(bSelLn)
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
bInSelect = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
fnDrag = &SwWrtShell::ExtSelLn;
|
|
|
|
fnSetCrsr = &SwWrtShell::Ignore;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fnDrag = &SwWrtShell::Drag;
|
|
|
|
SttSelect();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
long SwWrtShell::Drag(const Point *, sal_Bool )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
if( IsSelTblCells() )
|
|
|
|
aSelTblLink.Call(this);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
long SwWrtShell::EndDrag(const Point * /*pPt*/, sal_Bool )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
fnDrag = &SwWrtShell::BeginDrag;
|
|
|
|
if( IsExtSel() )
|
|
|
|
LeaveExtSel();
|
|
|
|
|
|
|
|
if( IsSelTblCells() )
|
|
|
|
aSelTblLink.Call(this);
|
|
|
|
EndSelect();
|
|
|
|
return 1;
|
|
|
|
}
|
2004-09-09 08:15:18 +00:00
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i32329# Enhanced table selection
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwWrtShell::SelectTableRowCol( const Point& rPt, const Point* pEnd, bool bRowDrag )
|
2004-09-09 08:15:18 +00:00
|
|
|
{
|
2012-09-02 16:05:21 +04:00
|
|
|
SwMvContext aMvContext(this);
|
2005-01-05 15:11:13 +00:00
|
|
|
SttSelect();
|
2008-03-07 14:10:07 +00:00
|
|
|
if(SelTblRowCol( rPt, pEnd, bRowDrag ))
|
2006-01-05 13:52:00 +00:00
|
|
|
{
|
|
|
|
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
|
|
|
|
fnKillSel = &SwWrtShell::ResetSelect;
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_True;
|
2006-01-05 13:52:00 +00:00
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2004-09-09 08:15:18 +00:00
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Description: Selection of a table line or column
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwWrtShell::SelectTableRow()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
if ( SelTblRow() )
|
|
|
|
{
|
|
|
|
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
|
|
|
|
fnKillSel = &SwWrtShell::ResetSelect;
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwWrtShell::SelectTableCol()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
if ( SelTblCol() )
|
|
|
|
{
|
|
|
|
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
|
|
|
|
fnKillSel = &SwWrtShell::ResetSelect;
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwWrtShell::SelectTableCell()
|
2004-08-02 12:13:09 +00:00
|
|
|
{
|
|
|
|
if ( SelTblBox() )
|
|
|
|
{
|
|
|
|
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
|
|
|
|
fnKillSel = &SwWrtShell::ResetSelect;
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_True;
|
2004-08-02 12:13:09 +00:00
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2004-08-02 12:13:09 +00:00
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Description: Check if a word selection is present.
|
|
|
|
// According to the rules for intelligent cut / paste
|
|
|
|
// surrounding spaces are cut out.
|
|
|
|
// Return: Delivers the type of the word selection.
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
int SwWrtShell::IntelligentCut(int nSelection, sal_Bool bCut)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-03-17 23:16:05 +01:00
|
|
|
// On multiple selection no intelligent drag and drop
|
|
|
|
// there are multiple cursors, since a second was placed
|
2013-03-26 17:36:45 +02:00
|
|
|
// already at the target postion.
|
2007-09-27 11:53:01 +00:00
|
|
|
if( IsAddMode() || !(nSelection & nsSelectionType::SEL_TXT) )
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2000-10-25 14:39:12 +00:00
|
|
|
String sTxt;
|
|
|
|
CharClass& rCC = GetAppCharClass();
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// If the first character is no word character,
|
|
|
|
// no word selected.
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Unicode cPrev = GetChar(sal_False);
|
|
|
|
sal_Unicode cNext = GetChar(sal_True, -1);
|
2003-04-17 15:12:13 +00:00
|
|
|
if( !cPrev || !cNext ||
|
2001-05-16 17:08:06 +00:00
|
|
|
!rCC.isLetterNumeric( ( sTxt = cPrev), 0 ) ||
|
2000-11-21 07:49:57 +00:00
|
|
|
!rCC.isLetterNumeric( ( sTxt = cNext), 0 ) )
|
2000-09-18 16:15:01 +00:00
|
|
|
return NO_WORD;
|
2000-10-25 14:39:12 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
cPrev = GetChar(sal_False, -1);
|
|
|
|
cNext = GetChar(sal_True);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
int cWord = NO_WORD;
|
2013-03-17 23:16:05 +01:00
|
|
|
// is a word seleced?
|
2000-09-18 16:15:01 +00:00
|
|
|
if(!cWord && cPrev && cNext &&
|
|
|
|
CH_TXTATR_BREAKWORD != cPrev && CH_TXTATR_INWORD != cPrev &&
|
|
|
|
CH_TXTATR_BREAKWORD != cNext && CH_TXTATR_INWORD != cNext &&
|
2000-10-25 14:39:12 +00:00
|
|
|
!rCC.isLetterNumeric( ( sTxt = cPrev), 0 ) &&
|
|
|
|
!rCC.isLetterNumeric( ( sTxt = cNext), 0 ) )
|
2000-09-18 16:15:01 +00:00
|
|
|
cWord = WORD_NO_SPACE;
|
2000-10-25 14:39:12 +00:00
|
|
|
|
|
|
|
if(cWord == WORD_NO_SPACE && ' ' == cPrev )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
cWord = WORD_SPACE_BEFORE;
|
2013-03-17 23:16:05 +01:00
|
|
|
// delete the space before
|
2000-09-18 16:15:01 +00:00
|
|
|
if(bCut)
|
|
|
|
{
|
|
|
|
Push();
|
|
|
|
if(IsCrsrPtAtEnd())
|
|
|
|
SwapPam();
|
|
|
|
ClearMark();
|
|
|
|
SetMark();
|
2002-02-01 11:51:13 +00:00
|
|
|
SwCrsrShell::Left(1,CRSR_SKIP_CHARS);
|
2000-09-18 16:15:01 +00:00
|
|
|
SwFEShell::Delete();
|
2011-01-17 15:06:54 +01:00
|
|
|
Pop( sal_False );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(cWord == WORD_NO_SPACE && cNext == ' ')
|
|
|
|
{
|
|
|
|
cWord = WORD_SPACE_AFTER;
|
2013-03-17 23:16:05 +01:00
|
|
|
// delete the space behind
|
2000-09-18 16:15:01 +00:00
|
|
|
if(bCut) {
|
|
|
|
Push();
|
|
|
|
if(!IsCrsrPtAtEnd()) SwapPam();
|
|
|
|
ClearMark();
|
|
|
|
SetMark();
|
2002-02-01 11:51:13 +00:00
|
|
|
SwCrsrShell::Right(1,CRSR_SKIP_CHARS);
|
2000-09-18 16:15:01 +00:00
|
|
|
SwFEShell::Delete();
|
2011-01-17 15:06:54 +01:00
|
|
|
Pop( sal_False );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return cWord;
|
|
|
|
}
|
2002-02-08 14:06:36 +00:00
|
|
|
|
|
|
|
// jump to the next / previous hyperlink - inside text and also
|
|
|
|
// on graphics
|
2013-02-05 23:42:42 +09:00
|
|
|
bool SwWrtShell::SelectNextPrevHyperlink( bool bNext )
|
2002-02-08 14:06:36 +00:00
|
|
|
{
|
|
|
|
StartAction();
|
2013-02-05 23:42:42 +09:00
|
|
|
bool bRet = SwCrsrShell::SelectNxtPrvHyperlink( bNext );
|
2002-02-08 14:06:36 +00:00
|
|
|
if( !bRet )
|
|
|
|
{
|
|
|
|
// will we have this feature?
|
|
|
|
EnterStdMode();
|
|
|
|
if( bNext )
|
2011-01-17 15:06:54 +01:00
|
|
|
SttEndDoc(sal_True);
|
2002-02-08 14:06:36 +00:00
|
|
|
else
|
2011-01-17 15:06:54 +01:00
|
|
|
SttEndDoc(sal_False);
|
2002-02-08 14:06:36 +00:00
|
|
|
bRet = SwCrsrShell::SelectNxtPrvHyperlink( bNext );
|
|
|
|
}
|
|
|
|
EndAction();
|
|
|
|
|
2013-02-05 23:42:42 +09:00
|
|
|
bool bCreateXSelection = false;
|
|
|
|
const bool bFrmSelected = IsFrmSelected() || IsObjSelected();
|
2002-02-08 14:06:36 +00:00
|
|
|
if( IsSelection() )
|
|
|
|
{
|
|
|
|
if ( bFrmSelected )
|
|
|
|
UnSelectFrm();
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// Set the function pointer for the canceling of the selection
|
|
|
|
// set at cursor
|
2002-02-08 14:06:36 +00:00
|
|
|
fnKillSel = &SwWrtShell::ResetSelect;
|
|
|
|
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
|
2013-02-05 23:42:42 +09:00
|
|
|
bCreateXSelection = true;
|
2002-02-08 14:06:36 +00:00
|
|
|
}
|
|
|
|
else if( bFrmSelected )
|
|
|
|
{
|
|
|
|
EnterSelFrmMode();
|
2013-02-05 23:42:42 +09:00
|
|
|
bCreateXSelection = true;
|
2002-02-08 14:06:36 +00:00
|
|
|
}
|
|
|
|
else if( (CNT_GRF | CNT_OLE ) & GetCntType() )
|
|
|
|
{
|
|
|
|
SelectObj( GetCharRect().Pos() );
|
|
|
|
EnterSelFrmMode();
|
2013-02-05 23:42:42 +09:00
|
|
|
bCreateXSelection = true;
|
2002-02-08 14:06:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( bCreateXSelection )
|
|
|
|
SwTransferable::CreateSelection( *this );
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2013-03-17 23:16:05 +01:00
|
|
|
// For the preservation of the selection the cursor will be moved left
|
|
|
|
// after SetMark(), so that the cursor is not moved by inserting text.
|
|
|
|
// Because a present selection at the CORE page is cleared at the
|
|
|
|
// current cursor position, the cursor will be pushed on the stack.
|
|
|
|
// After moving, they will again resummarized.
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|