1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include <limits.h>
#include <hintids.hxx>
#include <sfx2/bindings.hxx>
#include <svl/eitem.hxx>
#include <svl/macitem.hxx>
#include <unotools/charclass.hxx>
#include <editeng/scripttypeitem.hxx>
#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>
#include <swundo.hxx> // fuer Undo-Ids
#include <swevent.hxx>
#include <swdtflvr.hxx>
#include <crsskip.hxx>
#include <wordcountdialog.hxx>
namespace com { namespace sun { namespace star { namespace util {
struct SearchOptions;
} } } }
using namespace ::com::sun::star::util;
static long nStartDragX = 0, nStartDragY = 0;
static sal_Bool bStartDrag = sal_False;
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 );
SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
if (pWrdCnt)
pWrdCnt->UpdateCounts();
}
sal_Bool SwWrtShell::SelNearestWrd()
{
MV_KONTEXT(this);
if( !IsInWrd() && !IsEndWrd() && !IsSttWrd() )
PrvWrd();
if( IsEndWrd() )
Left(CRSR_SKIP_CELLS, sal_False, 1, sal_False );
return SelWrd();
}
sal_Bool SwWrtShell::SelWrd(const Point *pPt, sal_Bool )
{
sal_Bool bRet;
{
MV_KONTEXT(this);
SttSelect();
bRet = SwCrsrShell::SelectWord( pPt );
}
EndSelect();
if( bRet )
{
bSelWrd = sal_True;
if(pPt)
aStart = *pPt;
}
return bRet;
}
void SwWrtShell::SelSentence(const Point *pPt, sal_Bool )
{
{
MV_KONTEXT(this);
ClearMark();
SwCrsrShell::GoStartSentence();
SttSelect();
SwCrsrShell::GoEndSentence();
}
EndSelect();
if(pPt)
aStart = *pPt;
bSelLn = sal_True;
bSelWrd = sal_False; // SelWord abschalten, sonst geht kein SelLine weiter
}
void SwWrtShell::SelPara(const Point *pPt, sal_Bool )
{
{
MV_KONTEXT(this);
ClearMark();
SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
SttSelect();
SwCrsrShell::MovePara( fnParaCurr, fnParaEnd );
}
EndSelect();
if(pPt)
aStart = *pPt;
bSelLn = sal_False;
bSelWrd = sal_False; // SelWord abschalten, sonst geht kein SelLine weiter
}
long SwWrtShell::SelAll()
{
const sal_Bool bLockedView = IsViewLocked();
LockView( sal_True );
{
if(bBlockMode)
LeaveBlockMode();
MV_KONTEXT(this);
sal_Bool bMoveTable = sal_False;
SwPosition *pStartPos = 0;
SwPosition *pEndPos = 0;
SwShellCrsr* pTmpCrsr = 0;
if( !HasWholeTabSelection() )
{
if ( IsSelection() && IsCrsrPtAtEnd() )
SwapPam();
pTmpCrsr = getShellCrsr( false );
if( pTmpCrsr )
{
pStartPos = new SwPosition( *pTmpCrsr->GetPoint() );
pEndPos = new SwPosition( *pTmpCrsr->GetMark() );
}
Push();
sal_Bool bIsFullSel = !MoveSection( fnSectionCurr, fnSectionStart);
SwapPam();
bIsFullSel &= !MoveSection( fnSectionCurr, fnSectionEnd);
Pop(sal_False);
GoStart(sal_True, &bMoveTable, sal_False, !bIsFullSel);
}
else
{
EnterStdMode();
SttEndDoc(sal_True);
}
SttSelect();
GoEnd(sal_True, &bMoveTable);
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() ) )
SwCrsrShell::SttEndDoc(sal_False);
}
delete pStartPos;
delete pEndPos;
}
}
EndSelect();
LockView( bLockedView );
return 1;
}
/*------------------------------------------------------------------------
Beschreibung: Textsuche
------------------------------------------------------------------------*/
sal_uLong SwWrtShell::SearchPattern( const SearchOptions& rSearchOpt, sal_Bool bSearchInNotes,
SwDocPositions eStt, SwDocPositions eEnd,
FindRanges eFlags, int bReplace )
{
// keine Erweiterung bestehender Selektionen
if(!(eFlags & FND_IN_SEL))
ClearMark();
sal_Bool bCancel = sal_False;
sal_uLong nRet = Find( rSearchOpt, bSearchInNotes, eStt, eEnd, bCancel, eFlags, bReplace );
if(bCancel)
{
Undo(1);
nRet = ULONG_MAX;
}
return nRet;
}
/*------------------------------------------------------------------------
Beschreibung: Suche nach Vorlagen
------------------------------------------------------------------------*/
sal_uLong SwWrtShell::SearchTempl( const String &rTempl,
SwDocPositions eStt, SwDocPositions eEnd,
FindRanges eFlags, const String* pReplTempl )
{
// keine Erweiterung bestehender Selektionen
if(!(eFlags & FND_IN_SEL))
ClearMark();
SwTxtFmtColl *pColl = GetParaStyle(rTempl, SwWrtShell::GETSTYLE_CREATESOME);
SwTxtFmtColl *pReplaceColl = 0;
if( pReplTempl )
pReplaceColl = GetParaStyle(*pReplTempl, SwWrtShell::GETSTYLE_CREATESOME );
sal_Bool bCancel = sal_False;
sal_uLong nRet = Find(pColl? *pColl: GetDfltTxtFmtColl(),
eStt,eEnd, bCancel, eFlags, pReplaceColl);
if(bCancel)
{
Undo(1);
nRet = ULONG_MAX;
}
return nRet;
}
// Suche nach Attributen ----------------------------------------------------
sal_uLong SwWrtShell::SearchAttr( const SfxItemSet& rFindSet, sal_Bool bNoColls,
SwDocPositions eStart, SwDocPositions eEnde,
FindRanges eFlags, const SearchOptions* pSearchOpt,
const SfxItemSet* pReplaceSet )
{
// Keine Erweiterung bestehender Selektionen
if (!(eFlags & FND_IN_SEL))
ClearMark();
// Suchen
sal_Bool bCancel = sal_False;
sal_uLong nRet = Find( rFindSet, bNoColls, eStart, eEnde, bCancel, eFlags, pSearchOpt, pReplaceSet);
if(bCancel)
{
Undo(1);
nRet = ULONG_MAX;
}
return nRet;
}
// ---------- Selektionsmodi ----------
void SwWrtShell::PushMode()
{
pModeStack = new ModeStack( pModeStack, bIns, bExtMode, bAddMode, bBlockMode );
}
void SwWrtShell::PopMode()
{
if ( 0 == pModeStack )
return;
if ( bExtMode && !pModeStack->bExt )
LeaveExtMode();
if ( bAddMode && !pModeStack->bAdd )
LeaveAddMode();
if ( bBlockMode && !pModeStack->bBlock )
LeaveBlockMode();
bIns = pModeStack->bIns;
ModeStack *pTmp = pModeStack->pNext;
delete pModeStack;
pModeStack = pTmp;
}
/*
* Zwei Methoden fuer das Cursorsetzen; die erste mappt auf die
* gleichnamige Methoden an der CursorShell, die zweite hebt
* zuerst alle Selektionen auf.
*/
long SwWrtShell::SetCrsr(const Point *pPt, sal_Bool bTextOnly)
{
/*
* eine gfs. bestehende Selektion an der Position des
* Mausklicks aufheben
*/
if(!IsInSelect() && ChgCurrPam(*pPt)) {
ClearMark();
}
return SwCrsrShell::SetCrsr(*pPt, bTextOnly);
}
long SwWrtShell::SetCrsrKillSel(const Point *pPt, sal_Bool bTextOnly )
{
ACT_KONTEXT(this);
ResetSelect(pPt,sal_False);
return SwCrsrShell::SetCrsr(*pPt, bTextOnly);
}
void SwWrtShell::UnSelectFrm()
{
// Rahmenselektion aufheben mit garantiert ungueltiger Position
Point aPt(LONG_MIN, LONG_MIN);
SelectObj(aPt, 0);
SwTransferable::ClearSelection( *this );
}
/*
* Aufheben aller Selektionen
*/
long SwWrtShell::ResetSelect(const Point *,sal_Bool)
{
if(IsSelFrmMode())
{
UnSelectFrm();
LeaveSelFrmMode();
}
else
{
/* ACT_KONTEXT() macht eine Action auf -
um im Basicablauf keine Probleme mit der
Shellumschaltung zu bekommen, darf
GetChgLnk().Call() erst nach
EndAction() gerufen werden.
*/
{
ACT_KONTEXT(this);
bSelWrd = bSelLn = sal_False;
KillPams();
ClearMark();
fnKillSel = &SwWrtShell::Ignore;
fnSetCrsr = &SwWrtShell::SetCrsr;
}
/*
* nach dem Aufheben aller Selektionen koennte ein Update der
* Attr-Controls notwendig sein.
*/
GetChgLnk().Call(this);
}
Invalidate();
SwTransferable::ClearSelection( *this );
return 1;
}
/*
* tue nichts
*/
long SwWrtShell::Ignore(const Point *, sal_Bool ) {
return 1;
}
/*
* Start eines Selektionsvorganges.
*/
void SwWrtShell::SttSelect()
{
if(bInSelect)
return;
if(!HasMark())
SetMark();
if( bBlockMode )
{
SwShellCrsr* pTmp = getShellCrsr( true );
if( !pTmp->HasMark() )
pTmp->SetMark();
}
fnKillSel = &SwWrtShell::Ignore;
fnSetCrsr = &SwWrtShell::SetCrsr;
bInSelect = sal_True;
Invalidate();
SwTransferable::CreateSelection( *this );
}
/*
* Ende eines Selektionsvorganges.
*/
void SwWrtShell::EndSelect()
{
if(bInSelect && !bExtMode)
{
bInSelect = sal_False;
if (bAddMode)
{
AddLeaveSelect(0, sal_False);
}
else
{
SttLeaveSelect(0, sal_False);
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
fnKillSel = &SwWrtShell::ResetSelect;
}
}
SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
if (pWrdCnt)
pWrdCnt->UpdateCounts();
}
/* Methode, um eine bestehende wortweise oder zeilenweise Selektion
* zu erweitern.
*/
inline sal_Bool operator<(const Point &rP1,const Point &rP2)
{
return rP1.Y() < rP2.Y() || (rP1.Y() == rP2.Y() && rP1.X() < rP2.X());
}
long SwWrtShell::ExtSelWrd(const Point *pPt, sal_Bool )
{
MV_KONTEXT(this);
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() )
{
sal_Bool bHasMark = HasMark(); // thats wrong!
GoNextCrsr();
if( bHasMark )
{
DestroyCrsr();
GoPrevCrsr();
}
}
// check the direction of the selection with the new point
sal_Bool bRet = sal_False, bMoveCrsr = sal_True, bToTop = sal_False;
SwCrsrShell::SelectWord( &aStart ); // select the startword
SwCrsrShell::Push(); // save the cursor
SwCrsrShell::SetCrsr( *pPt ); // and check the direction
switch( SwCrsrShell::CompareCursor( StackMkCurrPt ))
{
case -1: bToTop = sal_False; break;
case 1: bToTop = sal_True; break;
default: bMoveCrsr = sal_False; break;
}
SwCrsrShell::Pop( sal_False ); // retore the saved cursor
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();
bRet = sal_True;
}
else
{
SwCrsrShell::Pop( sal_False );
if( bToTop )
SwapPam();
}
}
else
bRet = sal_True;
return bRet;
}
long SwWrtShell::ExtSelLn(const Point *pPt, sal_Bool )
{
MV_KONTEXT(this);
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() )
{
sal_Bool bHasMark = HasMark(); // thats wrong!
GoNextCrsr();
if( bHasMark )
{
DestroyCrsr();
GoPrevCrsr();
}
}
// ggfs. den Mark der Selektion anpassen
sal_Bool bToTop = !IsCrsrPtAtEnd();
SwapPam();
// der "Mark" muss am Zeilenende/-anfang stehen
if( bToTop ? !IsEndSentence() : !IsStartSentence() )
{
if( bToTop )
{
if( !IsEndPara() )
SwCrsrShell::Right(1,CRSR_SKIP_CHARS);
SwCrsrShell::GoEndSentence();
}
else
SwCrsrShell::GoStartSentence();
}
SwapPam();
return bToTop ? SwCrsrShell::GoStartSentence() : SwCrsrShell::GoEndSentence();
}
/*
* zurueck in den Standard Mode: kein Mode, keine Selektionen.
*/
void SwWrtShell::EnterStdMode()
{
if(bAddMode)
LeaveAddMode();
if(bBlockMode)
LeaveBlockMode();
bBlockMode = sal_False;
bExtMode = sal_False;
bInSelect = sal_False;
if(IsSelFrmMode())
{
UnSelectFrm();
LeaveSelFrmMode();
}
else
{
/* ACT_KONTEXT() opens and action which has to be
closed prior to the call of
GetChgLnk().Call()
*/
{
ACT_KONTEXT(this);
bSelWrd = bSelLn = sal_False;
if( !IsRetainSelection() )
KillPams();
ClearMark();
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
fnKillSel = &SwWrtShell::ResetSelect;
}
}
Invalidate();
SwTransferable::ClearSelection( *this );
}
/*
* Extended Mode
*/
void SwWrtShell::EnterExtMode()
{
if(bBlockMode)
{
LeaveBlockMode();
KillPams();
ClearMark();
}
bExtMode = sal_True;
bAddMode = sal_False;
bBlockMode = sal_False;
SttSelect();
}
void SwWrtShell::LeaveExtMode()
{
bExtMode = sal_False;
EndSelect();
}
/*
* Ende einer Selektion; falls die Selektion leer ist,
* ClearMark().
*/
long SwWrtShell::SttLeaveSelect(const Point *, sal_Bool )
{
if(SwCrsrShell::HasSelection() && !IsSelTblCells() && bClearMark) {
return 0;
}
ClearMark();
return 1;
}
/*
* Verlassen des Selektionsmodus in Additional Mode
*/
long SwWrtShell::AddLeaveSelect(const Point *, sal_Bool )
{
if(IsTableMode()) LeaveAddMode();
else if(SwCrsrShell::HasSelection())
CreateCrsr();
return 1;
}
/*
* Additional Mode
*/
void SwWrtShell::EnterAddMode()
{
if(IsTableMode()) return;
if(bBlockMode)
LeaveBlockMode();
fnKillSel = &SwWrtShell::Ignore;
fnSetCrsr = &SwWrtShell::SetCrsr;
bAddMode = sal_True;
bBlockMode = sal_False;
bExtMode = sal_False;
if(SwCrsrShell::HasSelection())
CreateCrsr();
Invalidate();
}
void SwWrtShell::LeaveAddMode()
{
fnKillSel = &SwWrtShell::ResetSelect;
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
bAddMode = sal_False;
Invalidate();
}
/*
* Block Mode
*/
void SwWrtShell::EnterBlockMode()
{
bBlockMode = sal_False;
EnterStdMode();
bBlockMode = sal_True;
CrsrToBlockCrsr();
Invalidate();
}
void SwWrtShell::LeaveBlockMode()
{
bBlockMode = sal_False;
BlockCrsrToCrsr();
EndSelect();
Invalidate();
}
// Einfuegemodus
void SwWrtShell::SetInsMode( sal_Bool bOn )
{
bIns = bOn;
SwCrsrShell::SetOverwriteCrsr( !bIns );
const SfxBoolItem aTmp( SID_ATTR_INSERT, bIns );
GetView().GetViewFrame()->GetBindings().SetState( aTmp );
StartAction();
EndAction();
Invalidate();
}
//Overwrite mode is incompatible with red-lining
void SwWrtShell::SetRedlineModeAndCheckInsMode( sal_uInt16 eMode )
{
SetRedlineMode( eMode );
if (IsRedlineOn())
SetInsMode( true );
}
/*
* Rahmen bearbeiten
*/
long SwWrtShell::BeginFrmDrag(const Point *pPt, sal_Bool)
{
fnDrag = &SwFEShell::Drag;
if(bStartDrag)
{
Point aTmp( nStartDragX, nStartDragY );
SwFEShell::BeginDrag( &aTmp, sal_False );
}
else
SwFEShell::BeginDrag( pPt, sal_False );
return 1;
}
void SwWrtShell::EnterSelFrmMode(const Point *pPos)
{
if(pPos)
{
nStartDragX = pPos->X();
nStartDragY = pPos->Y();
bStartDrag = sal_True;
}
bNoEdit = bLayoutMode = sal_True;
HideCrsr();
// gleicher Aufruf von BeginDrag an der SwFEShell
fnDrag = &SwWrtShell::BeginFrmDrag;
fnEndDrag = &SwWrtShell::UpdateLayoutFrm;
SwBaseShell::SetFrmMode( FLY_DRAG_START, this );
Invalidate();
}
void SwWrtShell::LeaveSelFrmMode()
{
fnDrag = &SwWrtShell::BeginDrag;
fnEndDrag = &SwWrtShell::EndDrag;
bLayoutMode = sal_False;
bStartDrag = sal_False;
Edit();
SwBaseShell::SetFrmMode( FLY_DRAG_END, this );
Invalidate();
}
/*------------------------------------------------------------------------
Beschreibung: Rahmengebundenes Macro ausfuehren
------------------------------------------------------------------------*/
IMPL_LINK( SwWrtShell, ExecFlyMac, void *, pFlyFmt )
{
const SwFrmFmt *pFmt = pFlyFmt ? (SwFrmFmt*)pFlyFmt : GetFlyFrmFmt();
OSL_ENSURE(pFmt, "no frame format");
const SvxMacroItem &rFmtMac = pFmt->GetMacro();
if(rFmtMac.HasMacro(SW_EVENT_OBJECT_SELECT))
{
const SvxMacro &rMac = rFmtMac.GetMacro(SW_EVENT_OBJECT_SELECT);
if( IsFrmSelected() )
bLayoutMode = sal_True;
CallChgLnk();
ExecMacro( rMac );
}
return 0;
}
long SwWrtShell::UpdateLayoutFrm(const Point *pPt, sal_Bool )
{
// voerst Dummy
SwFEShell::EndDrag( pPt, sal_False );
fnDrag = &SwWrtShell::BeginFrmDrag;
return 1;
}
/*
* Handler fuer das Togglen der Modi. Liefern alten Mode zurueck.
*/
long SwWrtShell::ToggleAddMode()
{
bAddMode ? LeaveAddMode(): EnterAddMode();
Invalidate();
return !bAddMode;
}
long SwWrtShell::ToggleBlockMode()
{
bBlockMode ? LeaveBlockMode(): EnterBlockMode();
Invalidate();
return !bBlockMode;
}
long SwWrtShell::ToggleExtMode()
{
bExtMode ? LeaveExtMode() : EnterExtMode();
Invalidate();
return !bExtMode;
}
/*
* Draggen im Standard Modus (Selektieren von Inhalt)
*/
long SwWrtShell::BeginDrag(const Point * /*pPt*/, sal_Bool )
{
if(bSelWrd)
{
bInSelect = sal_True;
if( !IsCrsrPtAtEnd() )
SwapPam();
fnDrag = &SwWrtShell::ExtSelWrd;
fnSetCrsr = &SwWrtShell::Ignore;
}
else if(bSelLn)
{
bInSelect = sal_True;
fnDrag = &SwWrtShell::ExtSelLn;
fnSetCrsr = &SwWrtShell::Ignore;
}
else
{
fnDrag = &SwWrtShell::Drag;
SttSelect();
}
return 1;
}
long SwWrtShell::Drag(const Point *, sal_Bool )
{
if( IsSelTblCells() )
aSelTblLink.Call(this);
return 1;
}
long SwWrtShell::EndDrag(const Point * /*pPt*/, sal_Bool )
{
fnDrag = &SwWrtShell::BeginDrag;
if( IsExtSel() )
LeaveExtSel();
if( IsSelTblCells() )
aSelTblLink.Call(this);
EndSelect();
return 1;
}
// #i32329# Enhanced table selection
sal_Bool SwWrtShell::SelectTableRowCol( const Point& rPt, const Point* pEnd, bool bRowDrag )
{
MV_KONTEXT(this);
SttSelect();
if(SelTblRowCol( rPt, pEnd, bRowDrag ))
{
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
fnKillSel = &SwWrtShell::ResetSelect;
return sal_True;
}
return sal_False;
}
/*------------------------------------------------------------------------
Beschreibung: Selektion einer Tabellenzeile / Spalte
------------------------------------------------------------------------*/
sal_Bool SwWrtShell::SelectTableRow()
{
if ( SelTblRow() )
{
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
fnKillSel = &SwWrtShell::ResetSelect;
return sal_True;
}
return sal_False;
}
sal_Bool SwWrtShell::SelectTableCol()
{
if ( SelTblCol() )
{
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
fnKillSel = &SwWrtShell::ResetSelect;
return sal_True;
}
return sal_False;
}
sal_Bool SwWrtShell::SelectTableCell()
{
if ( SelTblBox() )
{
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
fnKillSel = &SwWrtShell::ResetSelect;
return sal_True;
}
return sal_False;
}
/*------------------------------------------------------------------------
Beschreibung: Prueft, ob eine Wortselektion vorliegt.
Gemaess den Regeln fuer intelligentes Cut / Paste
werden umgebende Spaces rausgeschnitten.
Return: Liefert Art der Wortselektion zurueck.
------------------------------------------------------------------------*/
int SwWrtShell::IntelligentCut(int nSelection, sal_Bool bCut)
{
// kein intelligentes Drag and Drop bei Mehrfachselektion
// es existieren mehrere Cursor, da ein zweiter bereits
// an die Zielposition gesetzt wurde
if( IsAddMode() || !(nSelection & nsSelectionType::SEL_TXT) )
return sal_False;
String sTxt;
CharClass& rCC = GetAppCharClass();
// wenn das erste und das letzte Zeichen kein Wortzeichen ist,
// ist kein Wort selektiert.
sal_Unicode cPrev = GetChar(sal_False);
sal_Unicode cNext = GetChar(sal_True, -1);
if( !cPrev || !cNext ||
!rCC.isLetterNumeric( ( sTxt = cPrev), 0 ) ||
!rCC.isLetterNumeric( ( sTxt = cNext), 0 ) )
return NO_WORD;
cPrev = GetChar(sal_False, -1);
cNext = GetChar(sal_True);
int cWord = NO_WORD;
// ist ein Wort selektiert?
if(!cWord && cPrev && cNext &&
CH_TXTATR_BREAKWORD != cPrev && CH_TXTATR_INWORD != cPrev &&
CH_TXTATR_BREAKWORD != cNext && CH_TXTATR_INWORD != cNext &&
!rCC.isLetterNumeric( ( sTxt = cPrev), 0 ) &&
!rCC.isLetterNumeric( ( sTxt = cNext), 0 ) )
cWord = WORD_NO_SPACE;
if(cWord == WORD_NO_SPACE && ' ' == cPrev )
{
cWord = WORD_SPACE_BEFORE;
// Space davor loeschen
if(bCut)
{
Push();
if(IsCrsrPtAtEnd())
SwapPam();
ClearMark();
SetMark();
SwCrsrShell::Left(1,CRSR_SKIP_CHARS);
SwFEShell::Delete();
Pop( sal_False );
}
}
else if(cWord == WORD_NO_SPACE && cNext == ' ')
{
cWord = WORD_SPACE_AFTER;
// Space dahinter loeschen
if(bCut) {
Push();
if(!IsCrsrPtAtEnd()) SwapPam();
ClearMark();
SetMark();
SwCrsrShell::Right(1,CRSR_SKIP_CHARS);
SwFEShell::Delete();
Pop( sal_False );
}
}
return cWord;
}
// jump to the next / previous hyperlink - inside text and also
// on graphics
sal_Bool SwWrtShell::SelectNextPrevHyperlink( sal_Bool bNext )
{
StartAction();
sal_Bool bRet = SwCrsrShell::SelectNxtPrvHyperlink( bNext );
if( !bRet )
{
// will we have this feature?
EnterStdMode();
if( bNext )
SttEndDoc(sal_True);
else
SttEndDoc(sal_False);
bRet = SwCrsrShell::SelectNxtPrvHyperlink( bNext );
}
EndAction();
sal_Bool bCreateXSelection = sal_False;
const sal_Bool bFrmSelected = IsFrmSelected() || IsObjSelected();
if( IsSelection() )
{
if ( bFrmSelected )
UnSelectFrm();
// Funktionspointer fuer das Aufheben der Selektion setzen
// bei Cursor setzen
fnKillSel = &SwWrtShell::ResetSelect;
fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
bCreateXSelection = sal_True;
}
else if( bFrmSelected )
{
EnterSelFrmMode();
bCreateXSelection = sal_True;
}
else if( (CNT_GRF | CNT_OLE ) & GetCntType() )
{
SelectObj( GetCharRect().Pos() );
EnterSelFrmMode();
bCreateXSelection = sal_True;
}
if( bCreateXSelection )
SwTransferable::CreateSelection( *this );
return bRet;
}
/* fuer den Erhalt der Selektion wird nach SetMark() der Cursor
* nach links bewegt, damit er durch das Einfuegen von Text nicht
* verschoben wird. Da auf der CORE-Seite am aktuellen Cursor
* eine bestehende Selektion aufgehoben wird, wird der Cursor auf
* den Stack gepushed. Nach dem Verschieben werden sie wieder
* zusammengefasst. */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|