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 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132
|
/* -*- 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 <sot/object.hxx>
#include <editeng/eeitem.hxx>
#include <vcl/waitobj.hxx>
#include <editeng/flditem.hxx>
#include <svx/svdogrp.hxx>
#include <tools/urlobj.hxx>
#include <vcl/help.hxx>
#include <svx/bmpmask.hxx>
#include <svx/svdotext.hxx>
#include <sfx2/app.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/bindings.hxx>
#include <svx/svdpagv.hxx>
#include <svtools/imapobj.hxx>
#include <svx/svxids.hrc>
#include <svx/obj3d.hxx>
#include <svx/polysc3d.hxx>
#include <svx/svdpagv.hxx>
#include <sfx2/viewfrm.hxx>
#include "anminfo.hxx"
#include "anmdef.hxx"
#include "imapinfo.hxx"
#include "app.hrc"
#include "glob.hrc"
#include "strings.hrc"
#include "res_bmp.hrc"
#include "app.hxx"
#include "GraphicDocShell.hxx"
#include "fudraw.hxx"
#include "ViewShell.hxx"
#include "FrameView.hxx"
#include "View.hxx"
#include "Window.hxx"
#include "drawdoc.hxx"
#include "DrawDocShell.hxx"
#include "Client.hxx"
#include "sdresid.hxx"
#include "drawview.hxx"
#include "fusel.hxx"
#include <svl/aeitem.hxx>
#include <vcl/msgbox.hxx>
#include "slideshow.hxx"
#include <svx/sdrhittesthelper.hxx>
using namespace ::com::sun::star;
namespace sd {
TYPEINIT1( FuDraw, FuPoor );
/*************************************************************************
|*
|* Base-class for all drawmodul-specific functions
|*
\************************************************************************/
FuDraw::FuDraw(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
SdDrawDocument* pDoc, SfxRequest& rReq) :
FuPoor(pViewSh, pWin, pView, pDoc, rReq),
bMBDown(sal_False),
bDragHelpLine(sal_False),
bPermanent(sal_False)
{
}
/*************************************************************************
|*
|* Destruktor
|*
\************************************************************************/
FuDraw::~FuDraw()
{
mpView->BrkAction();
}
/*************************************************************************
|*
|* MouseButtonDown-event
|*
\************************************************************************/
sal_Bool FuDraw::MouseButtonDown(const MouseEvent& rMEvt)
{
// remember button state for creation of own MouseEvents
SetMouseButtonCode(rMEvt.GetButtons());
sal_Bool bReturn = sal_False;
bDragHelpLine = sal_False;
aMDPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
if ( rMEvt.IsLeft() )
{
FrameView* pFrameView = mpViewShell->GetFrameView();
bool bOrtho = sal_False;
sal_Bool bRestricted = sal_True;
if (mpView->IsDragObj())
{
// object is dragged (move, resize,...)
const SdrHdl* pHdl = mpView->GetDragStat().GetHdl();
if (!pHdl || (!pHdl->IsCornerHdl() && !pHdl->IsVertexHdl()))
{
// Move
bRestricted = sal_False;
}
}
// #i33136#
if(bRestricted && doConstructOrthogonal())
{
// Restrict movement:
// rectangle->quadrat, ellipse->circle etc.
bOrtho = !rMEvt.IsShift();
}
else
{
bOrtho = rMEvt.IsShift() != pFrameView->IsOrtho();
}
if (!mpView->IsSnapEnabled())
mpView->SetSnapEnabled(sal_True);
sal_Bool bSnapModPressed = rMEvt.IsMod1();
sal_Bool bGridSnap = pFrameView->IsGridSnap();
bGridSnap = (bSnapModPressed != bGridSnap);
if (mpView->IsGridSnap() != bGridSnap)
mpView->SetGridSnap(bGridSnap);
sal_Bool bBordSnap = pFrameView->IsBordSnap();
bBordSnap = (bSnapModPressed != bBordSnap);
if (mpView->IsBordSnap() != bBordSnap)
mpView->SetBordSnap(bBordSnap);
sal_Bool bHlplSnap = pFrameView->IsHlplSnap();
bHlplSnap = (bSnapModPressed != bHlplSnap);
if (mpView->IsHlplSnap() != bHlplSnap)
mpView->SetHlplSnap(bHlplSnap);
sal_Bool bOFrmSnap = pFrameView->IsOFrmSnap();
bOFrmSnap = (bSnapModPressed != bOFrmSnap);
if (mpView->IsOFrmSnap() != bOFrmSnap)
mpView->SetOFrmSnap(bOFrmSnap);
sal_Bool bOPntSnap = pFrameView->IsOPntSnap();
bOPntSnap = (bSnapModPressed != bOPntSnap);
if (mpView->IsOPntSnap() != bOPntSnap)
mpView->SetOPntSnap(bOPntSnap);
sal_Bool bOConSnap = pFrameView->IsOConSnap();
bOConSnap = (bSnapModPressed != bOConSnap);
if (mpView->IsOConSnap() != bOConSnap)
mpView->SetOConSnap(bOConSnap);
sal_Bool bAngleSnap = rMEvt.IsShift() == !pFrameView->IsAngleSnapEnabled();
if (mpView->IsAngleSnapEnabled() != bAngleSnap)
mpView->SetAngleSnapEnabled(bAngleSnap);
if (mpView->IsOrtho() != bOrtho)
mpView->SetOrtho(bOrtho);
sal_Bool bCenter = rMEvt.IsMod2();
if ( mpView->IsCreate1stPointAsCenter() != bCenter ||
mpView->IsResizeAtCenter() != bCenter )
{
mpView->SetCreate1stPointAsCenter(bCenter);
mpView->SetResizeAtCenter(bCenter);
}
SdrPageView* pPV = 0;
sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
// look only for HelpLines when they are visible (!)
sal_Bool bHelpLine(sal_False);
if(mpView->IsHlplVisible())
bHelpLine = mpView->PickHelpLine(aMDPos, nHitLog, *mpWindow, nHelpLine, pPV);
sal_Bool bHitHdl = (mpView->PickHandle(aMDPos) != NULL);
if ( bHelpLine
&& !mpView->IsCreateObj()
&& ((mpView->GetEditMode() == SDREDITMODE_EDIT && !bHitHdl) || (rMEvt.IsShift() && bSnapModPressed)) )
{
mpWindow->CaptureMouse();
mpView->BegDragHelpLine(nHelpLine, pPV);
bDragHelpLine = mpView->IsDragHelpLine();
bReturn = sal_True;
}
}
ForcePointer(&rMEvt);
return bReturn;
}
/*************************************************************************
|*
|* MouseMove-event
|*
\************************************************************************/
sal_Bool FuDraw::MouseMove(const MouseEvent& rMEvt)
{
FrameView* pFrameView = mpViewShell->GetFrameView();
Point aPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
bool bOrtho = sal_False;
sal_Bool bRestricted = sal_True;
if (mpView->IsDragObj())
{
// object is dragged (move, resize, ...)
const SdrHdl* pHdl = mpView->GetDragStat().GetHdl();
if (!pHdl || (!pHdl->IsCornerHdl() && !pHdl->IsVertexHdl()))
{
// Move
bRestricted = sal_False;
}
}
if (mpView->IsAction())
{
// #i33136#
if(bRestricted && doConstructOrthogonal())
{
// Restrict movement:
// rectangle->quadrat, ellipse->circle etc.
bOrtho = !rMEvt.IsShift();
}
else
{
bOrtho = rMEvt.IsShift() != pFrameView->IsOrtho();
}
sal_Bool bSnapModPressed = rMEvt.IsMod2();
mpView->SetDragWithCopy(rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
sal_Bool bGridSnap = pFrameView->IsGridSnap();
bGridSnap = (bSnapModPressed != bGridSnap);
if (mpView->IsGridSnap() != bGridSnap)
mpView->SetGridSnap(bGridSnap);
sal_Bool bBordSnap = pFrameView->IsBordSnap();
bBordSnap = (bSnapModPressed != bBordSnap);
if (mpView->IsBordSnap() != bBordSnap)
mpView->SetBordSnap(bBordSnap);
sal_Bool bHlplSnap = pFrameView->IsHlplSnap();
bHlplSnap = (bSnapModPressed != bHlplSnap);
if (mpView->IsHlplSnap() != bHlplSnap)
mpView->SetHlplSnap(bHlplSnap);
sal_Bool bOFrmSnap = pFrameView->IsOFrmSnap();
bOFrmSnap = (bSnapModPressed != bOFrmSnap);
if (mpView->IsOFrmSnap() != bOFrmSnap)
mpView->SetOFrmSnap(bOFrmSnap);
sal_Bool bOPntSnap = pFrameView->IsOPntSnap();
bOPntSnap = (bSnapModPressed != bOPntSnap);
if (mpView->IsOPntSnap() != bOPntSnap)
mpView->SetOPntSnap(bOPntSnap);
sal_Bool bOConSnap = pFrameView->IsOConSnap();
bOConSnap = (bSnapModPressed != bOConSnap);
if (mpView->IsOConSnap() != bOConSnap)
mpView->SetOConSnap(bOConSnap);
sal_Bool bAngleSnap = rMEvt.IsShift() == !pFrameView->IsAngleSnapEnabled();
if (mpView->IsAngleSnapEnabled() != bAngleSnap)
mpView->SetAngleSnapEnabled(bAngleSnap);
if (mpView->IsOrtho() != bOrtho)
mpView->SetOrtho(bOrtho);
sal_Bool bCenter = rMEvt.IsMod2();
if ( mpView->IsCreate1stPointAsCenter() != bCenter ||
mpView->IsResizeAtCenter() != bCenter )
{
mpView->SetCreate1stPointAsCenter(bCenter);
mpView->SetResizeAtCenter(bCenter);
}
if ( mpView->IsDragHelpLine() )
mpView->MovDragHelpLine(aPos);
}
sal_Bool bReturn = mpView->MouseMove(rMEvt, mpWindow);
if (mpView->IsAction())
{
// Because the flag set back if necessary in MouseMove
if (mpView->IsOrtho() != bOrtho)
mpView->SetOrtho(bOrtho);
}
ForcePointer(&rMEvt);
return bReturn;
}
/*************************************************************************
|*
|* MouseButtonUp-event
|*
\************************************************************************/
sal_Bool FuDraw::MouseButtonUp(const MouseEvent& rMEvt)
{
if ( mpView->IsDragHelpLine() )
mpView->EndDragHelpLine();
if ( bDragHelpLine )
{
Rectangle aOutputArea(Point(0,0), mpWindow->GetOutputSizePixel());
if ( !aOutputArea.IsInside(rMEvt.GetPosPixel()) )
mpView->GetSdrPageView()->DeleteHelpLine(nHelpLine);
mpWindow->ReleaseMouse();
}
FrameView* pFrameView = mpViewShell->GetFrameView();
mpView->SetOrtho( pFrameView->IsOrtho() );
mpView->SetAngleSnapEnabled( pFrameView->IsAngleSnapEnabled() );
mpView->SetSnapEnabled(sal_True);
mpView->SetCreate1stPointAsCenter(sal_False);
mpView->SetResizeAtCenter(sal_False);
mpView->SetDragWithCopy(pFrameView->IsDragWithCopy());
mpView->SetGridSnap(pFrameView->IsGridSnap());
mpView->SetBordSnap(pFrameView->IsBordSnap());
mpView->SetHlplSnap(pFrameView->IsHlplSnap());
mpView->SetOFrmSnap(pFrameView->IsOFrmSnap());
mpView->SetOPntSnap(pFrameView->IsOPntSnap());
mpView->SetOConSnap(pFrameView->IsOConSnap());
bIsInDragMode = sal_False;
ForcePointer(&rMEvt);
FuPoor::MouseButtonUp(rMEvt);
return sal_False;
}
/*************************************************************************
|*
|* Process keyboard-events
|*
|* When processing a KeyEvent the returnvalue is sal_True, otherwise sal_False.
|*
\************************************************************************/
sal_Bool FuDraw::KeyInput(const KeyEvent& rKEvt)
{
sal_Bool bReturn = sal_False;
switch ( rKEvt.GetKeyCode().GetCode() )
{
case KEY_ESCAPE:
{
bReturn = FuDraw::cancel();
}
break;
case KEY_DELETE:
case KEY_BACKSPACE:
{
if (!mpDocSh->IsReadOnly())
{
if ( mpView && mpView->IsPresObjSelected(sal_False, sal_True, sal_False, sal_True) )
{
InfoBox(mpWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
}
else
{
// Falls IP-Client aktiv, werden die Pointer
// auf das OLE- und das alte Graphic-Object
// am SdClient zurueckgesetzt, damit bei
// ::SelectionHasChanged nach dem Loeschen
// nicht mehr versucht wird, ein Grafik-Objekt
// zu restaurieren, das gar nicht mehr existiert.
// Alle anderen OLE-Objekte sind davon nicht
// betroffen
OSL_ASSERT (mpViewShell->GetViewShell()!=NULL);
Client* pIPClient = static_cast<Client*>(
mpViewShell->GetViewShell()->GetIPClient());
if (pIPClient && pIPClient->IsObjectInPlaceActive())
pIPClient->SetSdrGrafObj(NULL);
// wait-mousepointer while deleting object
WaitObject aWait( (Window*)mpViewShell->GetActiveWindow() );
// delete object
mpView->DeleteMarked();
}
}
bReturn = sal_True;
}
break;
case KEY_TAB:
{
KeyCode aCode = rKEvt.GetKeyCode();
if ( !aCode.IsMod1() && !aCode.IsMod2() )
{
// Moved next line which was a bugfix itself into
// the scope which really does the object selection travel
// and thus is allowed to call SelectionHasChanged().
// Switch to FuSelect.
mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
SID_OBJECT_SELECT,
SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
// changeover to the next object
if(!mpView->MarkNextObj( !aCode.IsShift() ))
{
// No next object: go over open end and
// get first from the other side
mpView->UnmarkAllObj();
mpView->MarkNextObj(!aCode.IsShift());
}
if(mpView->AreObjectsMarked())
mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
bReturn = sal_True;
}
}
break;
case KEY_END:
{
KeyCode aCode = rKEvt.GetKeyCode();
if ( aCode.IsMod1() )
{
// mark last object
mpView->UnmarkAllObj();
mpView->MarkNextObj(sal_False);
if(mpView->AreObjectsMarked())
mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
bReturn = sal_True;
}
}
break;
case KEY_HOME:
{
KeyCode aCode = rKEvt.GetKeyCode();
if ( aCode.IsMod1() )
{
// mark first object
mpView->UnmarkAllObj();
mpView->MarkNextObj(sal_True);
if(mpView->AreObjectsMarked())
mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
bReturn = sal_True;
}
}
break;
default:
break;
}
if (!bReturn)
{
bReturn = FuPoor::KeyInput(rKEvt);
}
else
{
mpWindow->ReleaseMouse();
}
return (bReturn);
}
/*************************************************************************
|*
|* Fade out the selection-presentation before scrolling
|*
\************************************************************************/
void FuDraw::ScrollStart()
{
}
/*************************************************************************
|*
|* After scrolling show the selection-presentation again
|*
\************************************************************************/
void FuDraw::ScrollEnd()
{
}
/*************************************************************************
|*
|* Aktivate function
|*
\************************************************************************/
void FuDraw::Activate()
{
FuPoor::Activate();
ForcePointer();
}
/*************************************************************************
|*
|* Deaktivate function
|*
\************************************************************************/
void FuDraw::Deactivate()
{
FuPoor::Deactivate();
}
/*************************************************************************
|*
|* Toggle mouse-pointer
|*
\************************************************************************/
void FuDraw::ForcePointer(const MouseEvent* pMEvt)
{
Point aPnt;
sal_uInt16 nModifier = 0;
sal_Bool bLeftDown = sal_False;
sal_Bool bDefPointer = sal_True;
if (pMEvt)
{
aPnt = mpWindow->PixelToLogic(pMEvt->GetPosPixel());
nModifier = pMEvt->GetModifier();
bLeftDown = pMEvt->IsLeft();
}
else
{
aPnt = mpWindow->PixelToLogic(mpWindow->GetPointerPosPixel());
}
if (mpView->IsDragObj())
{
if (SD_MOD()->GetWaterCan() && !mpView->PickHandle(aPnt))
{
/******************************************************************
* Giesskannenmodus
******************************************************************/
bDefPointer = sal_False;
mpWindow->SetPointer(Pointer(POINTER_FILL));
}
}
else
{
SdrHdl* pHdl = mpView->PickHandle(aPnt);
if (SD_MOD()->GetWaterCan() && !pHdl)
{
/******************************************************************
* Giesskannenmodus
******************************************************************/
bDefPointer = sal_False;
mpWindow->SetPointer(Pointer(POINTER_FILL));
}
else if (!pHdl &&
mpViewShell->GetViewFrame()->HasChildWindow(SvxBmpMaskChildWindow::GetChildWindowId()))
{
/******************************************************************
* Pipettenmodus
******************************************************************/
SvxBmpMask* pMask = (SvxBmpMask*) mpViewShell->GetViewFrame()->GetChildWindow(SvxBmpMaskChildWindow::GetChildWindowId())->GetWindow();
if (pMask && pMask->IsEyedropping())
{
bDefPointer = sal_False;
mpWindow->SetPointer(Pointer(POINTER_REFHAND));
}
}
else if (!mpView->IsAction())
{
SdrObject* pObj = NULL;
SdrPageView* pPV = NULL;
SdrViewEvent aVEvt;
SdrHitKind eHit = SDRHIT_NONE;
SdrDragMode eDragMode = mpView->GetDragMode();
if (pMEvt)
{
eHit = mpView->PickAnything(*pMEvt, SDRMOUSEMOVE, aVEvt);
}
if ((eDragMode == SDRDRAG_ROTATE) && (eHit == SDRHIT_MARKEDOBJECT))
{
// The goal of this request is show always the rotation-arrow for 3D-objects at rotation-modus
// Independent of the settings at Extras->Optionen->Grafik "Objekte immer verschieben"
// 2D-objects acquit in an other way. Otherwise, the rotation of 3d-objects around any axises
// wouldn't be possible per default.
const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
SdrObject* pObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
if ((pObject->ISA(E3dObject)) && (rMarkList.GetMarkCount() == 1))
{
mpWindow->SetPointer(Pointer(POINTER_ROTATE));
bDefPointer = sal_False; // Otherwise it'll be calles Joes routine and the mousepointer will reconfigurate again
}
}
if (eHit == SDRHIT_NONE)
{
// found nothing -> look after at the masterpage
mpView->PickObj(aPnt, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER);
}
else if (eHit == SDRHIT_UNMARKEDOBJECT)
{
pObj = aVEvt.pObj;
}
else if (eHit == SDRHIT_TEXTEDITOBJ && this->ISA(FuSelection))
{
sal_uInt16 nSdrObjKind = aVEvt.pObj->GetObjIdentifier();
if ( nSdrObjKind != OBJ_TEXT &&
nSdrObjKind != OBJ_TITLETEXT &&
nSdrObjKind != OBJ_OUTLINETEXT &&
aVEvt.pObj->IsEmptyPresObj() )
{
pObj = NULL;
bDefPointer = sal_False;
mpWindow->SetPointer(Pointer(POINTER_ARROW));
}
}
if (pObj && pMEvt && !pMEvt->IsMod2() && this->ISA(FuSelection))
{
// Auf Animation oder ImageMap pruefen
bDefPointer = !SetPointer(pObj, aPnt);
if (bDefPointer && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dPolyScene)))
{
// In die Gruppe hineinschauen
if (mpView->PickObj(aPnt, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_DEEP))
bDefPointer = !SetPointer(pObj, aPnt);
}
}
}
}
if (bDefPointer)
{
mpWindow->SetPointer(mpView->GetPreferedPointer(
aPnt, mpWindow, nModifier, bLeftDown));
}
}
/*************************************************************************
|*
|* Set cursor for animaton or imagemap
|*
\************************************************************************/
sal_Bool FuDraw::SetPointer(SdrObject* pObj, const Point& rPos)
{
sal_Bool bSet = sal_False;
sal_Bool bAnimationInfo = (!mpDocSh->ISA(GraphicDocShell) &&
mpDoc->GetAnimationInfo(pObj)) ? sal_True:sal_False;
sal_Bool bImageMapInfo = sal_False;
if (!bAnimationInfo)
bImageMapInfo = mpDoc->GetIMapInfo(pObj) ? sal_True:sal_False;
if (bAnimationInfo || bImageMapInfo)
{
const SetOfByte* pVisiLayer = &mpView->GetSdrPageView()->GetVisibleLayers();
sal_uInt16 nHitLog(sal_uInt16 (mpWindow->PixelToLogic(Size(HITPIX,0)).Width()));
long n2HitLog(nHitLog * 2);
Point aHitPosR(rPos);
Point aHitPosL(rPos);
Point aHitPosT(rPos);
Point aHitPosB(rPos);
aHitPosR.X() += n2HitLog;
aHitPosL.X() -= n2HitLog;
aHitPosT.Y() += n2HitLog;
aHitPosB.Y() -= n2HitLog;
if ( !pObj->IsClosedObj() ||
( SdrObjectPrimitiveHit(*pObj, aHitPosR, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
SdrObjectPrimitiveHit(*pObj, aHitPosL, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
SdrObjectPrimitiveHit(*pObj, aHitPosT, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
SdrObjectPrimitiveHit(*pObj, aHitPosB, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false)))
{
/**********************************************************
* hit inside the object (without margin) or open object
********************************************************/
if (bAnimationInfo)
{
/******************************************************
* Click-Action
******************************************************/
SdAnimationInfo* pInfo = mpDoc->GetAnimationInfo(pObj);
if ((mpView->ISA(DrawView) &&
(pInfo->meClickAction == presentation::ClickAction_BOOKMARK ||
pInfo->meClickAction == presentation::ClickAction_DOCUMENT ||
pInfo->meClickAction == presentation::ClickAction_PREVPAGE ||
pInfo->meClickAction == presentation::ClickAction_NEXTPAGE ||
pInfo->meClickAction == presentation::ClickAction_FIRSTPAGE ||
pInfo->meClickAction == presentation::ClickAction_LASTPAGE ||
pInfo->meClickAction == presentation::ClickAction_VERB ||
pInfo->meClickAction == presentation::ClickAction_PROGRAM ||
pInfo->meClickAction == presentation::ClickAction_MACRO ||
pInfo->meClickAction == presentation::ClickAction_SOUND))
||
(mpView->ISA(DrawView) &&
SlideShow::IsRunning( mpViewShell->GetViewShellBase() ) &&
(pInfo->meClickAction == presentation::ClickAction_VANISH ||
pInfo->meClickAction == presentation::ClickAction_INVISIBLE ||
pInfo->meClickAction == presentation::ClickAction_STOPPRESENTATION ||
(pInfo->mbActive &&
( pInfo->meEffect != presentation::AnimationEffect_NONE ||
pInfo->meTextEffect != presentation::AnimationEffect_NONE )))))
{
// Animations-Objekt
bSet = sal_True;
mpWindow->SetPointer(Pointer(POINTER_REFHAND));
}
}
else if (bImageMapInfo &&
mpDoc->GetHitIMapObject(pObj, rPos, *mpWindow))
{
/******************************************************
* ImageMap
******************************************************/
bSet = sal_True;
mpWindow->SetPointer(Pointer(POINTER_REFHAND));
}
}
}
return bSet;
}
/*************************************************************************
|*
|* Response of doubleclick
|*
\************************************************************************/
void FuDraw::DoubleClick(const MouseEvent& rMEvt)
{
sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
if ( mpView->AreObjectsMarked() )
{
const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
if (rMarkList.GetMarkCount() == 1)
{
SdrMark* pMark = rMarkList.GetMark(0);
SdrObject* pObj = pMark->GetMarkedSdrObj();
sal_uInt32 nInv = pObj->GetObjInventor();
sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
{
DrawDocShell* pDocSh = mpDoc->GetDocSh();
if ( !pDocSh->IsUIActive() )
{
/**********************************************************
* activate OLE-object
**********************************************************/
mpViewShell->ActivateObject( (SdrOle2Obj*) pObj, 0);
}
}
else if (nInv == SdrInventor && nSdrObjKind == OBJ_GRAF && pObj->IsEmptyPresObj() )
{
mpViewShell->GetViewFrame()->
GetDispatcher()->Execute( SID_INSERT_GRAPHIC,
SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
}
else if ( ( pObj->ISA(SdrTextObj) || pObj->ISA(SdrObjGroup) ) &&
!SD_MOD()->GetWaterCan() &&
mpViewShell->GetFrameView()->IsDoubleClickTextEdit() &&
!mpDocSh->IsReadOnly())
{
SfxUInt16Item aItem(SID_TEXTEDIT, 2);
mpViewShell->GetViewFrame()->GetDispatcher()->
Execute(SID_TEXTEDIT, SFX_CALLMODE_ASYNCHRON |
SFX_CALLMODE_RECORD, &aItem, 0L);
}
else if (nInv == SdrInventor && nSdrObjKind == OBJ_GRUP)
{
// hit group -> select subobject
mpView->UnMarkAll();
mpView->MarkObj(aMDPos, nHitLog, rMEvt.IsShift(), sal_True);
}
}
}
else
mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
}
/*************************************************************************
|*
|* Help-event
|*
\************************************************************************/
sal_Bool FuDraw::RequestHelp(const HelpEvent& rHEvt)
{
sal_Bool bReturn = sal_False;
if (Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled())
{
SdrViewEvent aVEvt;
MouseEvent aMEvt(mpWindow->GetPointerPosPixel(), 1, 0, MOUSE_LEFT);
SdrHitKind eHit = mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
SdrObject* pObj = aVEvt.pObj;
if (eHit != SDRHIT_NONE && pObj != NULL)
{
Point aPosPixel = rHEvt.GetMousePosPixel();
bReturn = SetHelpText(pObj, aPosPixel, aVEvt);
if (!bReturn && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dPolyScene)))
{
// In die Gruppe hineinschauen
SdrPageView* pPV = NULL;
Point aPos(mpWindow->PixelToLogic(mpWindow->ScreenToOutputPixel(aPosPixel)));
if (mpView->PickObj(aPos, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_DEEP))
bReturn = SetHelpText(pObj, aPosPixel, aVEvt);
}
}
}
if (!bReturn)
{
bReturn = FuPoor::RequestHelp(rHEvt);
}
return(bReturn);
}
/*************************************************************************
|*
|* Command-event
|*
\************************************************************************/
sal_Bool FuDraw::SetHelpText(SdrObject* pObj, const Point& rPosPixel, const SdrViewEvent& rVEvt)
{
sal_Bool bSet = sal_False;
String aHelpText;
Point aPos(mpWindow->PixelToLogic(mpWindow->ScreenToOutputPixel(rPosPixel)));
// URL fuer IMapObject unter Pointer ist Hilfetext
if ( mpDoc->GetIMapInfo(pObj) )
{
IMapObject* pIMapObj = mpDoc->GetHitIMapObject(pObj, aPos, *mpWindow );
if ( pIMapObj )
{
// show name
aHelpText = pIMapObj->GetAltText();
if (aHelpText.Len() == 0)
{
// show url if no name is available
aHelpText = INetURLObject::decode( pIMapObj->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET );
}
}
}
else if (!mpDocSh->ISA(GraphicDocShell) && mpDoc->GetAnimationInfo(pObj))
{
SdAnimationInfo* pInfo = mpDoc->GetAnimationInfo(pObj);
switch (pInfo->meClickAction)
{
case presentation::ClickAction_PREVPAGE:
{
// jump to the prior page
aHelpText = String(SdResId(STR_CLICK_ACTION_PREVPAGE));
}
break;
case presentation::ClickAction_NEXTPAGE:
{
// jump to the next page
aHelpText = String(SdResId(STR_CLICK_ACTION_NEXTPAGE));
}
break;
case presentation::ClickAction_FIRSTPAGE:
{
// jump to the first page
aHelpText = String(SdResId(STR_CLICK_ACTION_FIRSTPAGE));
}
break;
case presentation::ClickAction_LASTPAGE:
{
// jump to the last page
aHelpText = String(SdResId(STR_CLICK_ACTION_LASTPAGE));
}
break;
case presentation::ClickAction_BOOKMARK:
{
// jump to object/page
aHelpText = String(SdResId(STR_CLICK_ACTION_BOOKMARK));
aHelpText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
aHelpText.Append( String(INetURLObject::decode( pInfo->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET ) ));
}
break;
case presentation::ClickAction_DOCUMENT:
{
// jump to document (object/page)
aHelpText = String(SdResId(STR_CLICK_ACTION_DOCUMENT));
aHelpText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
aHelpText.Append( String(INetURLObject::decode( pInfo->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET ) ));
}
break;
case presentation::ClickAction_PROGRAM:
{
// execute program
aHelpText = String(SdResId(STR_CLICK_ACTION_PROGRAM));
aHelpText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
aHelpText.Append( String(INetURLObject::decode( pInfo->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET ) ));
}
break;
case presentation::ClickAction_MACRO:
{
// execute program
aHelpText = String(SdResId(STR_CLICK_ACTION_MACRO));
aHelpText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
if ( SfxApplication::IsXScriptURL( pInfo->GetBookmark() ) )
{
aHelpText.Append( pInfo->GetBookmark() );
}
else
{
String sBookmark( pInfo->GetBookmark() );
sal_Unicode cToken = '.';
aHelpText.Append( sBookmark.GetToken( 2, cToken ) );
aHelpText.Append( cToken );
aHelpText.Append( sBookmark.GetToken( 1, cToken ) );
aHelpText.Append( cToken );
aHelpText.Append( sBookmark.GetToken( 0, cToken ) );
}
}
break;
case presentation::ClickAction_SOUND:
{
// play-back sound
aHelpText = String(SdResId(STR_CLICK_ACTION_SOUND));
}
break;
case presentation::ClickAction_VERB:
{
// execute OLE-verb
aHelpText = String(SdResId(STR_CLICK_ACTION_VERB));
}
break;
case presentation::ClickAction_STOPPRESENTATION:
{
// quit presentation
aHelpText = String(SdResId(STR_CLICK_ACTION_STOPPRESENTATION));
}
break;
default:
break;
}
}
else if (rVEvt.pURLField)
{
/**************************************************************
* URL-Field
**************************************************************/
aHelpText = INetURLObject::decode( rVEvt.pURLField->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET );
}
if (aHelpText.Len())
{
bSet = sal_True;
Rectangle aLogicPix = mpWindow->LogicToPixel(pObj->GetLogicRect());
Rectangle aScreenRect(mpWindow->OutputToScreenPixel(aLogicPix.TopLeft()),
mpWindow->OutputToScreenPixel(aLogicPix.BottomRight()));
if (Help::IsBalloonHelpEnabled())
Help::ShowBalloon( (Window*)mpWindow, rPosPixel, aScreenRect, aHelpText);
else if (Help::IsQuickHelpEnabled())
Help::ShowQuickHelp( (Window*)mpWindow, aScreenRect, aHelpText);
}
return bSet;
}
/** is called when the currenct function should be aborted. <p>
This is used when a function gets a KEY_ESCAPE but can also
be called directly.
@returns true if a active function was aborted
*/
bool FuDraw::cancel()
{
bool bReturn = false;
if ( mpView->IsAction() )
{
mpView->BrkAction();
bReturn = true;
}
else if ( mpView->IsTextEdit() )
{
mpView->SdrEndTextEdit();
bReturn = true;
SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
rBindings.Invalidate( SID_PARASPACE_INCREASE );
rBindings.Invalidate( SID_PARASPACE_DECREASE );
}
else if ( mpView->AreObjectsMarked() )
{
const SdrHdlList& rHdlList = mpView->GetHdlList();
SdrHdl* pHdl = rHdlList.GetFocusHdl();
if(pHdl)
{
((SdrHdlList&)rHdlList).ResetFocusHdl();
}
else
{
mpView->UnmarkAll();
}
// Switch to FuSelect.
mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
SID_OBJECT_SELECT,
SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
bReturn = true;
}
return bReturn;
}
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|