Lines 62-67
Link Here
|
62 |
#include "waitoff.hxx" |
62 |
#include "waitoff.hxx" |
63 |
#include "globstr.hrc" |
63 |
#include "globstr.hrc" |
64 |
#include "scmod.hxx" |
64 |
#include "scmod.hxx" |
|
|
65 |
#include "tabprotection.hxx" |
65 |
|
66 |
|
66 |
#define SC_BLOCKMODE_NONE 0 |
67 |
#define SC_BLOCKMODE_NONE 0 |
67 |
#define SC_BLOCKMODE_NORMAL 1 |
68 |
#define SC_BLOCKMODE_NORMAL 1 |
Lines 178-193
void ScTabView::InitBlockMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
Link Here
|
178 |
InvertBlockMark( nBlockStartX,nBlockStartY,nBlockEndX,nBlockEndY ); |
179 |
InvertBlockMark( nBlockStartX,nBlockStartY,nBlockEndX,nBlockEndY ); |
179 |
#endif |
180 |
#endif |
180 |
UpdateSelectionOverlay(); |
181 |
UpdateSelectionOverlay(); |
181 |
|
|
|
182 |
bNewStartIfMarking = FALSE; // use only once |
183 |
} |
182 |
} |
184 |
} |
183 |
} |
185 |
|
184 |
|
186 |
void ScTabView::SetNewStartIfMarking() |
|
|
187 |
{ |
188 |
bNewStartIfMarking = TRUE; |
189 |
} |
190 |
|
191 |
void ScTabView::DoneBlockMode( BOOL bContinue ) // Default FALSE |
185 |
void ScTabView::DoneBlockMode( BOOL bContinue ) // Default FALSE |
192 |
{ |
186 |
{ |
193 |
// Wenn zwischen Tabellen- und Header SelectionEngine gewechselt wird, |
187 |
// Wenn zwischen Tabellen- und Header SelectionEngine gewechselt wird, |
Lines 414-419
void ScTabView::MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
Link Here
|
414 |
aHdrFunc.SetAnchorFlag( FALSE ); |
408 |
aHdrFunc.SetAnchorFlag( FALSE ); |
415 |
} |
409 |
} |
416 |
|
410 |
|
|
|
411 |
void ScTabView::GetPageMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, SCsCOL& rPageX, SCsROW& rPageY) |
412 |
{ |
413 |
SCCOL nCurX; |
414 |
SCROW nCurY; |
415 |
aViewData.GetMoveCursor( nCurX,nCurY ); |
416 |
|
417 |
ScSplitPos eWhich = aViewData.GetActivePart(); |
418 |
ScHSplitPos eWhichX = WhichH( eWhich ); |
419 |
ScVSplitPos eWhichY = WhichV( eWhich ); |
420 |
|
421 |
SCsCOL nPageX; |
422 |
SCsROW nPageY; |
423 |
if (nMovX >= 0) |
424 |
nPageX = ((SCsCOL) aViewData.CellsAtX( nCurX, 1, eWhichX )) * nMovX; |
425 |
else |
426 |
nPageX = ((SCsCOL) aViewData.CellsAtX( nCurX, -1, eWhichX )) * nMovX; |
427 |
|
428 |
if (nMovY >= 0) |
429 |
nPageY = ((SCsROW) aViewData.CellsAtY( nCurY, 1, eWhichY )) * nMovY; |
430 |
else |
431 |
nPageY = ((SCsROW) aViewData.CellsAtY( nCurY, -1, eWhichY )) * nMovY; |
432 |
|
433 |
if (nMovX != 0 && nPageX == 0) nPageX = (nMovX>0) ? 1 : -1; |
434 |
if (nMovY != 0 && nPageY == 0) nPageY = (nMovY>0) ? 1 : -1; |
435 |
|
436 |
rPageX = nPageX; |
437 |
rPageY = nPageY; |
438 |
} |
439 |
|
440 |
void ScTabView::GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, |
441 |
SCsCOL& rAreaX, SCsROW& rAreaY, ScFollowMode& rMode) |
442 |
{ |
443 |
SCCOL nNewX = -1; |
444 |
SCROW nNewY = -1; |
445 |
SCCOL nCurX = -1; |
446 |
SCROW nCurY = -1; |
447 |
|
448 |
if (aViewData.IsRefMode()) |
449 |
{ |
450 |
nNewX = aViewData.GetRefEndX(); |
451 |
nNewY = aViewData.GetRefEndY(); |
452 |
} |
453 |
else if (IsBlockMode()) |
454 |
{ |
455 |
nNewX = nBlockEndX; |
456 |
nNewY = nBlockEndY; |
457 |
} |
458 |
else |
459 |
{ |
460 |
nNewX = nCurX = aViewData.GetCurX(); |
461 |
nNewY = nCurY = aViewData.GetCurY(); |
462 |
} |
463 |
|
464 |
ScDocument* pDoc = aViewData.GetDocument(); |
465 |
SCTAB nTab = aViewData.GetTabNo(); |
466 |
|
467 |
// FindAreaPos kennt nur -1 oder 1 als Richtung |
468 |
|
469 |
SCsCOLROW i; |
470 |
if ( nMovX > 0 ) |
471 |
for ( i=0; i<nMovX; i++ ) |
472 |
pDoc->FindAreaPos( nNewX, nNewY, nTab, 1, 0 ); |
473 |
if ( nMovX < 0 ) |
474 |
for ( i=0; i<-nMovX; i++ ) |
475 |
pDoc->FindAreaPos( nNewX, nNewY, nTab, -1, 0 ); |
476 |
if ( nMovY > 0 ) |
477 |
for ( i=0; i<nMovY; i++ ) |
478 |
pDoc->FindAreaPos( nNewX, nNewY, nTab, 0, 1 ); |
479 |
if ( nMovY < 0 ) |
480 |
for ( i=0; i<-nMovY; i++ ) |
481 |
pDoc->FindAreaPos( nNewX, nNewY, nTab, 0, -1 ); |
482 |
|
483 |
if (eMode==SC_FOLLOW_JUMP) // unten/rechts nicht zuviel grau anzeigen |
484 |
{ |
485 |
if (nMovX != 0 && nNewX == MAXCOL) |
486 |
eMode = SC_FOLLOW_LINE; |
487 |
if (nMovY != 0 && nNewY == MAXROW) |
488 |
eMode = SC_FOLLOW_LINE; |
489 |
} |
490 |
|
491 |
if (aViewData.IsRefMode()) |
492 |
{ |
493 |
rAreaX = nNewX - aViewData.GetRefEndX(); |
494 |
rAreaY = nNewY - aViewData.GetRefEndY(); |
495 |
} |
496 |
else if (IsBlockMode()) |
497 |
{ |
498 |
rAreaX = nNewX - nBlockEndX; |
499 |
rAreaY = nNewY - nBlockEndY; |
500 |
} |
501 |
else |
502 |
{ |
503 |
rAreaX = nNewX - nCurX; |
504 |
rAreaY = nNewY - nCurY; |
505 |
} |
506 |
rMode = eMode; |
507 |
} |
508 |
|
509 |
namespace { |
510 |
|
511 |
bool lcl_isCellQualified(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, bool bSelectLocked, bool bSelectUnlocked) |
512 |
{ |
513 |
bool bCellProtected = pDoc->HasAttrib( |
514 |
nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_PROTECTED); |
515 |
|
516 |
if (bCellProtected && !bSelectLocked) |
517 |
return false; |
518 |
|
519 |
if (!bCellProtected && !bSelectUnlocked) |
520 |
return false; |
521 |
|
522 |
return true; |
523 |
} |
524 |
|
525 |
void lcl_moveCursorByProtRule( |
526 |
SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, SCTAB nTab, ScDocument* pDoc) |
527 |
{ |
528 |
bool bSelectLocked = true; |
529 |
bool bSelectUnlocked = true; |
530 |
ScTableProtection* pTabProtection = pDoc->GetTabProtection(nTab); |
531 |
if (pTabProtection && pTabProtection->isProtected()) |
532 |
{ |
533 |
bSelectLocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS); |
534 |
bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS); |
535 |
} |
536 |
|
537 |
if (nMovX > 0) |
538 |
{ |
539 |
if (rCol < MAXCOL) |
540 |
{ |
541 |
for (SCCOL i = 0; i < nMovX; ++i) |
542 |
{ |
543 |
if (!lcl_isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked)) |
544 |
break; |
545 |
++rCol; |
546 |
} |
547 |
} |
548 |
} |
549 |
else if (nMovX < 0) |
550 |
{ |
551 |
if (rCol > 0) |
552 |
{ |
553 |
nMovX = -nMovX; |
554 |
for (SCCOL i = 0; i < nMovX; ++i) |
555 |
{ |
556 |
if (!lcl_isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked)) |
557 |
break; |
558 |
--rCol; |
559 |
} |
560 |
} |
561 |
} |
562 |
|
563 |
if (nMovY > 0) |
564 |
{ |
565 |
if (rRow < MAXROW) |
566 |
{ |
567 |
for (SCROW i = 0; i < nMovY; ++i) |
568 |
{ |
569 |
if (!lcl_isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked)) |
570 |
break; |
571 |
++rRow; |
572 |
} |
573 |
} |
574 |
} |
575 |
else if (nMovY < 0) |
576 |
{ |
577 |
if (rRow > 0) |
578 |
{ |
579 |
nMovY = -nMovY; |
580 |
for (SCROW i = 0; i < nMovY; ++i) |
581 |
{ |
582 |
if (!lcl_isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked)) |
583 |
break; |
584 |
--rRow; |
585 |
} |
586 |
} |
587 |
} |
588 |
} |
589 |
|
590 |
} |
591 |
|
592 |
void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode) |
593 |
{ |
594 |
if (!nMovX && !nMovY) |
595 |
// Nothing to do. Bail out. |
596 |
return; |
597 |
|
598 |
ScTabViewShell* pViewShell = aViewData.GetViewShell(); |
599 |
bool bRefInputMode = pViewShell && pViewShell->IsRefInputMode(); |
600 |
if (bRefInputMode && !aViewData.IsRefMode()) |
601 |
// initialize formula reference mode if it hasn't already. |
602 |
InitRefMode(aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo(), SC_REFTYPE_REF); |
603 |
|
604 |
ScDocument* pDoc = aViewData.GetDocument(); |
605 |
|
606 |
if (aViewData.IsRefMode()) |
607 |
{ |
608 |
// formula reference mode |
609 |
|
610 |
SCCOL nNewX = aViewData.GetRefEndX(); |
611 |
SCROW nNewY = aViewData.GetRefEndY(); |
612 |
SCTAB nRefTab = aViewData.GetRefEndZ(); |
613 |
|
614 |
bool bSelectLocked = true; |
615 |
bool bSelectUnlocked = true; |
616 |
ScTableProtection* pTabProtection = pDoc->GetTabProtection(nRefTab); |
617 |
if (pTabProtection && pTabProtection->isProtected()) |
618 |
{ |
619 |
bSelectLocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS); |
620 |
bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS); |
621 |
} |
622 |
|
623 |
lcl_moveCursorByProtRule(nNewX, nNewY, nMovX, nMovY, nRefTab, pDoc); |
624 |
|
625 |
if (nMovX) |
626 |
{ |
627 |
SCCOL nTempX = nNewX; |
628 |
while (pDoc->IsHorOverlapped(nTempX, nNewY, nRefTab)) |
629 |
{ |
630 |
if (nMovX > 0) |
631 |
++nTempX; |
632 |
else |
633 |
--nTempX; |
634 |
} |
635 |
if (lcl_isCellQualified(pDoc, nTempX, nNewY, nRefTab, bSelectLocked, bSelectUnlocked)) |
636 |
nNewX = nTempX; |
637 |
} |
638 |
|
639 |
if (nMovY) |
640 |
{ |
641 |
SCROW nTempY = nNewY; |
642 |
while (pDoc->IsVerOverlapped(nNewX, nTempY, nRefTab)) |
643 |
{ |
644 |
if (nMovY > 0) |
645 |
++nTempY; |
646 |
else |
647 |
--nTempY; |
648 |
} |
649 |
if (lcl_isCellQualified(pDoc, nNewX, nTempY, nRefTab, bSelectLocked, bSelectUnlocked)) |
650 |
nNewY = nTempY; |
651 |
} |
652 |
|
653 |
pDoc->SkipOverlapped(nNewX, nNewY, nRefTab); |
654 |
UpdateRef(nNewX, nNewY, nRefTab); |
655 |
AlignToCursor(nNewX, nNewY, eMode); |
656 |
} |
657 |
else |
658 |
{ |
659 |
// normal selection mode |
660 |
|
661 |
SCTAB nTab = aViewData.GetTabNo(); |
662 |
|
663 |
if (!IsBlockMode()) |
664 |
InitBlockMode(aViewData.GetCurX(), aViewData.GetCurY(), nTab, true); |
665 |
|
666 |
lcl_moveCursorByProtRule(nBlockEndX, nBlockEndY, nMovX, nMovY, nTab, pDoc); |
667 |
|
668 |
if (nBlockEndX < 0) |
669 |
nBlockEndX = 0; |
670 |
else if (nBlockEndX > MAXCOL) |
671 |
nBlockEndX = MAXCOL; |
672 |
|
673 |
if (nBlockEndY < 0) |
674 |
nBlockEndY = 0; |
675 |
else if (nBlockEndY > MAXROW) |
676 |
nBlockEndY = MAXROW; |
677 |
|
678 |
pDoc->SkipOverlapped(nBlockEndX, nBlockEndY, nTab); |
679 |
MarkCursor(nBlockEndX, nBlockEndY, nTab, false, false, true); |
680 |
AlignToCursor(nBlockEndX, nBlockEndY, eMode); |
681 |
} |
682 |
} |
683 |
|
684 |
void ScTabView::ExpandBlockPage(SCsCOL nMovX, SCsROW nMovY) |
685 |
{ |
686 |
SCsCOL nPageX; |
687 |
SCsROW nPageY; |
688 |
GetPageMoveEndPosition(nMovX, nMovY, nPageX, nPageY); |
689 |
ExpandBlock(nPageX, nPageY, SC_FOLLOW_FIX); |
690 |
} |
691 |
|
692 |
void ScTabView::ExpandBlockArea(SCsCOL nMovX, SCsROW nMovY) |
693 |
{ |
694 |
SCsCOL nAreaX; |
695 |
SCsROW nAreaY; |
696 |
ScFollowMode eMode; |
697 |
GetAreaMoveEndPosition(nMovX, nMovY, SC_FOLLOW_JUMP, nAreaX, nAreaY, eMode); |
698 |
ExpandBlock(nAreaX, nAreaY, eMode); |
699 |
} |
700 |
|
417 |
void ScTabView::UpdateSelectionOverlay() |
701 |
void ScTabView::UpdateSelectionOverlay() |
418 |
{ |
702 |
{ |
419 |
for (USHORT i=0; i<4; i++) |
703 |
for (USHORT i=0; i<4; i++) |