1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viscrs.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #define _SVSTDARR_USHORTS
37 #include <svtools/svstdarr.hxx>
40 #include <vcl/dialog.hxx>
41 #include <vcl/msgbox.hxx>
42 #include <vcl/wrkwin.hxx>
43 #include <viewopt.hxx>
44 #include <frmtool.hxx>
48 #include <swtable.hxx>
49 #include <viewimp.hxx>
51 #include <rootfrm.hxx>
52 #include <txtfrm.hxx> // SwTxtFrm
54 #include <extinput.hxx>
56 #include <scriptinfo.hxx>
57 #include <mdiexp.hxx> // GetSearchDialog
59 #include <comcore.hrc> // ResId fuer Abfrage wenn zu Search & Replaces
62 #include <svx/sdr/overlay/overlaymanager.hxx>
63 #include <svx/sdrpaintwindow.hxx>
64 #include <vcl/svapp.hxx>
65 #include <svx/sdr/overlay/overlayselection.hxx>
67 extern void SwCalcPixStatics( OutputDevice
*pOut
);
69 //Damit beim ShowCrsr nicht immer wieder die gleiche Size teuer ermittelt
70 //werden muss, hier statische Member, die beim Wechsel des MapModes
73 long SwSelPaintRects::nPixPtX
= 0;
74 long SwSelPaintRects::nPixPtY
= 0;
75 MapMode
* SwSelPaintRects::pMapMode
= 0;
79 // #include <IMark.hxx>
81 // class SwBookmarkRects : public SwSelPaintRects
83 // virtual void Paint( const Rectangle& rRect );
84 // virtual void FillRects();
87 // SwBookmarkRects( const SwCrsrShell& rSh ) : SwSelPaintRects( rSh ) {}
90 // void SwBookmarkRects::Paint( const Rectangle& rRect )
92 // Window* pWin = GetShell()->GetWin();
94 // RasterOp eOld( pWin->GetRasterOp() );
95 // BOOL bLCol = pWin->IsLineColor();
96 // Color aLCol( pWin->GetLineColor() );
97 // BOOL bFCol = pWin->IsFillColor();
98 // Color aFCol( pWin->GetFillColor() );
100 // pWin->SetRasterOp( ROP_XOR );
101 // Color aCol( RGB_COLORDATA( 0xF0, 0xC8, 0xF0 ) ^ COL_WHITE );
102 // pWin->SetFillColor( aCol );
103 // pWin->SetLineColor( aCol );
105 // pWin->DrawRect( rRect );
107 // if( bLCol ) pWin->SetLineColor( aLCol ); else pWin->SetLineColor();
108 // if( bFCol ) pWin->SetFillColor( aFCol ); else pWin->SetFillColor();
109 // pWin->SetRasterOp( eOld );
112 // void SwBookmarkRects::FillRects()
114 // SwRegionRects aReg( GetShell()->VisArea() );
116 // const SwBookmarks& rBkmkTbl = GetShell()->getIDocumentMarkAccess()->getBookmarks();
117 // SwShellCrsr* pCrsr = 0;
118 // for( USHORT n = 0; n < rBkmkTbl.Count(); ++n )
120 // const SwBookmark& rBkmk = *rBkmkTbl[ n ];
121 // if( rBkmk.IsBookMark() && rBkmk.GetOtherPos() )
125 // pCrsr = new SwShellCrsr( *GetShell(), rBkmk.GetPos() );
129 // *pCrsr->GetPoint() = rBkmk.GetPos();
130 // *pCrsr->GetMark() = *rBkmk.GetOtherPos();
131 // pCrsr->FillRects();
132 // for( USHORT i = 0; i < pCrsr->Count(); ++i )
133 // aReg -= (*pCrsr)[ i ];
135 // pCrsr->Remove( 0, i );
138 // if( pCrsr ) delete pCrsr;
141 // SwRects::Insert( &aReg, 0 );
144 // SwBookmarkRects* pBookMarkRects = 0;
146 // void ShowBookmarks( const SwCrsrShell* pSh, int nAction, const SwRect* pRect = 0 )
148 // if( !pBookMarkRects && pSh->getIDocumentMarkAccess()->getBookmarks().Count() )
149 // pBookMarkRects = new SwBookmarkRects( *pSh );
151 // if( pBookMarkRects )
155 // case 1: pBookMarkRects->Show(); break;
156 // case 2: pBookMarkRects->Hide(); break;
157 // case 3: pBookMarkRects->Invalidate( *pRect ); break;
160 // if( !pBookMarkRects->Count() )
161 // delete pBookMarkRects, pBookMarkRects = 0;
165 // #define SHOWBOOKMARKS1( nAct ) ShowBookmarks( GetShell(),nAct );
166 // #define SHOWBOOKMARKS2( nAct, pRect ) ShowBookmarks( GetShell(),nAct, pRect );
170 #define SHOWBOOKMARKS1( nAct )
171 #define SHOWBOOKMARKS2( nAct, pRect )
176 #include <redline.hxx>
178 class SwRedlineRects
: public SwSelPaintRects
183 virtual void Paint( const Rectangle
& rRect
);
184 virtual void FillRects();
187 SwRedlineRects( const SwCrsrShell
& rSh
, USHORT nName
, USHORT n
)
188 : SwSelPaintRects( rSh
), nMode( n
), nNm( nName
)
192 void SwRedlineRects::Paint( const Rectangle
& rRect
)
194 Window
* pWin
= GetShell()->GetWin();
196 RasterOp
eOld( pWin
->GetRasterOp() );
197 BOOL bLCol
= pWin
->IsLineColor();
198 Color
aLCol( pWin
->GetLineColor() );
199 BOOL bFCol
= pWin
->IsFillColor();
200 Color
aFCol( pWin
->GetFillColor() );
202 pWin
->SetRasterOp( ROP_XOR
);
205 UINT8 nVal
= 0xc8 - ( (nMode
/ 4) * 16 );
208 case 0: aCol
= RGB_COLORDATA( nVal
, nVal
, 0xFF ); break;
209 case 1: aCol
= RGB_COLORDATA( 0xFF, 0xc8, nVal
); break;
210 case 2: aCol
= RGB_COLORDATA( nVal
, 0xFF, nVal
); break;
211 case 3: aCol
= RGB_COLORDATA( 0xFF, nVal
, nVal
); break;
213 aCol
= aCol
.GetColor() ^ COL_WHITE
;
215 pWin
->SetFillColor( aCol
);
216 pWin
->SetLineColor( aCol
);
218 pWin
->DrawRect( rRect
);
220 if( bLCol
) pWin
->SetLineColor( aLCol
); else pWin
->SetLineColor();
221 if( bFCol
) pWin
->SetFillColor( aFCol
); else pWin
->SetFillColor();
222 pWin
->SetRasterOp( eOld
);
225 void SwRedlineRects::FillRects()
227 SwRegionRects
aReg( GetShell()->VisArea() );
229 const SwRedlineTbl
& rTbl
= GetShell()->GetDoc()->GetRedlineTbl();
230 SwShellCrsr
* pCrsr
= 0;
231 for( USHORT n
= 0; n
< rTbl
.Count(); ++n
)
233 const SwRedline
& rRed
= *rTbl
[ n
];
234 if( rRed
.HasMark() && (nMode
% 4 ) == rRed
.GetType() &&
235 nNm
== rRed
.GetAuthor() )
239 pCrsr
= new SwShellCrsr( *GetShell(), *rRed
.GetPoint() );
243 *pCrsr
->GetPoint() = *rRed
.GetPoint();
244 *pCrsr
->GetMark() = *rRed
.GetMark();
246 for( USHORT i
= 0; i
< pCrsr
->Count(); ++i
)
247 aReg
-= (*pCrsr
)[ i
];
249 pCrsr
->Remove( 0, i
);
252 if( pCrsr
) delete pCrsr
;
255 SwRects::Insert( &aReg
, 0 );
258 SwRedlineRects
* aRedlines
[ 10 * 4 ];
259 static int bFirstCall
= TRUE
;
261 void ShowRedlines( const SwCrsrShell
* pSh
, int nAction
, const SwRect
* pRect
= 0 )
265 memset( aRedlines
, 0, sizeof(aRedlines
));
269 const SwRedlineTbl
& rTbl
= pSh
->GetDoc()->GetRedlineTbl();
270 const SwRedlineAuthorTbl
& rAuthorTbl
= pSh
->GetDoc()->GetRedlineAuthorTbl();
272 for( USHORT n
= 0; n
< rAuthorTbl
.Count(); ++n
)
274 for( int i
= 0; i
< 4; ++i
)
276 SwRedlineRects
** ppRedRect
= &aRedlines
[ n
* 4 + i
];
277 if( rTbl
.Count() && !*ppRedRect
)
278 *ppRedRect
= new SwRedlineRects( *pSh
, n
, n
* 4 + i
);
284 case 1: (*ppRedRect
)->Show(); break;
285 case 2: (*ppRedRect
)->Hide(); break;
286 case 3: (*ppRedRect
)->Invalidate( *pRect
); break;
289 if( !(*ppRedRect
)->Count() )
290 delete *ppRedRect
, *ppRedRect
= 0;
296 #define SHOWREDLINES1( nAct ) ShowRedlines( GetShell(),nAct );
297 #define SHOWREDLINES2( nAct, pRect ) ShowRedlines( GetShell(),nAct, pRect );
301 #define SHOWREDLINES1( nAct )
302 #define SHOWREDLINES2( nAct, pRect )
307 if( GetDoc()->GetRedlineTbl().Count() )
309 SwRedlineTbl
& rRedlineTbl
= (SwRedlineTbl
&)GetDoc()->GetRedlineTbl();
310 for( USHORT i
= 0; i
< rRedlineTbl
.Count(); ++i
)
311 rRedlineTbl
[ i
]->HideRects( *GetShell() );
315 // -------- Ab hier Klassen / Methoden fuer den nicht Text-Cursor ------
317 SwVisCrsr::SwVisCrsr( const SwCrsrShell
* pCShell
)
318 : pCrsrShell( pCShell
)
320 pCShell
->GetWin()->SetCursor( &aTxtCrsr
);
321 bIsVisible
= aTxtCrsr
.IsVisible();
323 aTxtCrsr
.SetWidth( 0 );
327 SetTimeout( 50 ); // 50msec Verzoegerung
333 SwVisCrsr::~SwVisCrsr()
337 Stop(); // Timer stoppen
340 if( bIsVisible
&& aTxtCrsr
.IsVisible() )
343 pCrsrShell
->GetWin()->SetCursor( 0 );
349 void SwVisCrsr::Show()
355 // muss ueberhaupt angezeigt werden ?
356 if( pCrsrShell
->VisArea().IsOver( pCrsrShell
->aCharRect
) )
360 Start(); // Timer aufsetzen
364 Stop(); // Timer Stoppen
377 void SwVisCrsr::Hide()
385 Stop(); // Timer Stoppen
388 if( aTxtCrsr
.IsVisible() ) // sollten die Flags nicht gueltig sein?
395 void __EXPORT
SwVisCrsr::Timeout()
397 ASSERT( !bIsDragCrsr
, "Timer vorher abschalten" );
400 if ( !pCrsrShell
->GetWin() ) //SwFrmFmt::GetGraphic setzt das Win temp aus!
407 BOOL
SwCrsrShell::ChgCrsrTimerFlag( BOOL bTimerOn
)
409 return pVisCrsr
->ChgTimerFlag( bTimerOn
);
413 BOOL
SwVisCrsr::ChgTimerFlag( BOOL bFlag
)
416 if( !bFlag
&& bIsVisible
&& IsActive() )
418 Stop(); // Timer Stoppen
428 void SwVisCrsr::_SetPosAndShow()
431 long nTmpY
= pCrsrShell
->aCrsrHeight
.Y();
435 aTxtCrsr
.SetOrientation( 900 );
436 aRect
= SwRect( pCrsrShell
->aCharRect
.Pos(),
437 Size( pCrsrShell
->aCharRect
.Height(), nTmpY
) );
438 aRect
.Pos().X() += pCrsrShell
->aCrsrHeight
.X();
439 if( pCrsrShell
->IsOverwriteCrsr() )
440 aRect
.Pos().Y() += aRect
.Width();
444 aTxtCrsr
.SetOrientation( 0 );
445 aRect
= SwRect( pCrsrShell
->aCharRect
.Pos(),
446 Size( pCrsrShell
->aCharRect
.Width(), nTmpY
) );
447 aRect
.Pos().Y() += pCrsrShell
->aCrsrHeight
.X();
450 // check if cursor should show the current cursor bidi level
451 aTxtCrsr
.SetDirection( CURSOR_DIRECTION_NONE
);
452 const SwCursor
* pTmpCrsr
= pCrsrShell
->_GetCrsr();
454 if ( pTmpCrsr
&& !pCrsrShell
->IsOverwriteCrsr() )
456 SwNode
& rNode
= pTmpCrsr
->GetPoint()->nNode
.GetNode();
457 if( rNode
.IsTxtNode() )
459 const SwTxtNode
& rTNd
= *rNode
.GetTxtNode();
460 const SwFrm
* pFrm
= rTNd
.GetFrm( 0, 0, FALSE
);
463 const SwScriptInfo
* pSI
= ((SwTxtFrm
*)pFrm
)->GetScriptInfo();
464 // cursor level has to be shown
465 if ( pSI
&& pSI
->CountDirChg() > 1 )
467 aTxtCrsr
.SetDirection(
468 ( pTmpCrsr
->GetCrsrBidiLevel() % 2 ) ?
469 CURSOR_DIRECTION_RTL
:
470 CURSOR_DIRECTION_LTR
);
473 if ( pFrm
->IsRightToLeft() )
475 const OutputDevice
*pOut
= pCrsrShell
->GetOut();
478 long nSize
= pOut
->GetSettings().GetStyleSettings().GetCursorSize();
479 Size
aSize( nSize
, nSize
);
480 aSize
= pOut
->PixelToLogic( aSize
);
481 aRect
.Left( aRect
.Left() - aSize
.Width() );
490 ::SwCalcPixStatics( pCrsrShell
->GetOut() );
491 ::SwAlignRect( aRect
, (ViewShell
*)pCrsrShell
);
493 if( !pCrsrShell
->IsOverwriteCrsr() || bIsDragCrsr
||
494 pCrsrShell
->IsSelection() )
497 aTxtCrsr
.SetSize( aRect
.SSize() );
499 aTxtCrsr
.SetPos( aRect
.Pos() );
500 if ( !pCrsrShell
->IsCrsrReadonly() || pCrsrShell
->GetViewOptions()->IsSelectionInReadonly() )
502 if ( pCrsrShell
->GetDrawView() )
503 ((SwDrawView
*)pCrsrShell
->GetDrawView())->SetAnimationEnabled(
504 !pCrsrShell
->IsSelection() );
506 USHORT nStyle
= bIsDragCrsr
? CURSOR_SHADOW
: 0;
507 if( nStyle
!= aTxtCrsr
.GetStyle() )
509 aTxtCrsr
.SetStyle( nStyle
);
510 aTxtCrsr
.SetWindow( bIsDragCrsr
? pCrsrShell
->GetWin() : 0 );
517 //////////////////////////////////////////////////////////////////////////////
519 SwSelPaintRects::SwSelPaintRects( const SwCrsrShell
& rCSh
)
526 SwSelPaintRects::~SwSelPaintRects()
531 void SwSelPaintRects::swapContent(SwSelPaintRects
& rSwap
)
534 aTempRects
.Insert(this, 0);
539 rSwap
.Remove(0, rSwap
.Count());
540 rSwap
.Insert(&aTempRects
, 0);
542 // #i75172# also swap mpCursorOverlay
543 sdr::overlay::OverlayObject
* pTempOverlay
= getCursorOverlay();
544 setCursorOverlay(rSwap
.getCursorOverlay());
545 rSwap
.setCursorOverlay(pTempOverlay
);
548 void SwSelPaintRects::Hide()
552 delete mpCursorOverlay
;
556 SwRects::Remove( 0, Count() );
559 void SwSelPaintRects::Show()
561 SdrView
* pView
= (SdrView
*)pCShell
->GetDrawView();
563 if(pView
&& pView
->PaintWindowCount())
566 SwRects::Remove( 0, SwRects::Count() );
570 std::vector
< basegfx::B2DRange
> aNewRanges
;
572 for(sal_uInt16
a(0); a
< Count(); a
++)
574 const SwRect
aNextRect((*this)[a
]);
575 const Rectangle
aPntRect(aNextRect
.SVRect());
577 aNewRanges
.push_back(basegfx::B2DRange(
578 aPntRect
.Left(), aPntRect
.Top(),
579 aPntRect
.Right() + 1, aPntRect
.Bottom() + 1));
584 if(aNewRanges
.size())
586 static_cast< sdr::overlay::OverlaySelection
* >(mpCursorOverlay
)->setRanges(aNewRanges
);
590 delete mpCursorOverlay
;
596 SdrPaintWindow
* pCandidate
= pView
->GetPaintWindow(0);
597 sdr::overlay::OverlayManager
* pTargetOverlay
= pCandidate
->GetOverlayManager();
601 // #i97672# get the system's hilight color and limit it to the maximum
602 // allowed luminance. This is needed to react on too bright hilight colors
603 // which would otherwise vive a bad visualisation
604 const OutputDevice
*pOut
= Application::GetDefaultDevice();
605 Color
aHighlight(pOut
->GetSettings().GetStyleSettings().GetHighlightColor());
606 const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer
;
607 const basegfx::BColor
aSelection(aHighlight
.getBColor());
608 const double fLuminance(aSelection
.luminance());
609 const double fMaxLum(aSvtOptionsDrawinglayer
.GetSelectionMaximumLuminancePercent() / 100.0);
611 if(fLuminance
> fMaxLum
)
613 const double fFactor(fMaxLum
/ fLuminance
);
614 const basegfx::BColor
aNewSelection(
615 aSelection
.getRed() * fFactor
,
616 aSelection
.getGreen() * fFactor
,
617 aSelection
.getBlue() * fFactor
);
619 aHighlight
= Color(aNewSelection
);
622 // create correct selection
623 mpCursorOverlay
= new sdr::overlay::OverlaySelection(
624 sdr::overlay::OVERLAY_TRANSPARENT
,
629 pTargetOverlay
->add(*mpCursorOverlay
);
635 void SwSelPaintRects::Invalidate( const SwRect
& rRect
)
637 USHORT nSz
= Count();
641 SwRegionRects
aReg( GetShell()->VisArea() );
642 aReg
.Remove( 0, aReg
.Count() );
643 aReg
.Insert( this, 0 );
645 SwRects::Remove( 0, nSz
);
646 SwRects::Insert( &aReg
, 0 );
648 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
649 // Liegt die Selection rechts oder unten ausserhalb des sichtbaren
650 // Bereiches, so ist diese nie auf eine Pixel rechts/unten aligned.
651 // Das muss hier erkannt und ggf. das Rechteckt erweitert werden.
652 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
653 if( GetShell()->bVisPortChgd
&& 0 != ( nSz
= Count()) )
655 SwSelPaintRects::Get1PixelInLogic( *GetShell() );
656 SwRect
* pRect
= (SwRect
*)GetData();
657 for( ; nSz
--; ++pRect
)
659 if( pRect
->Right() == GetShell()->aOldRBPos
.X() )
660 pRect
->Right( pRect
->Right() + nPixPtX
);
661 if( pRect
->Bottom() == GetShell()->aOldRBPos
.Y() )
662 pRect
->Bottom( pRect
->Bottom() + nPixPtY
);
667 void SwSelPaintRects::Paint( const Rectangle
& /*rRect*/ )
669 // nothing to do with overlays
673 * Rectangle ist in Dokument-Koordianten !!
674 * pWin != 0 -> auch wirklich malen
675 * == 0 -> nur testen, ob es gemalt werden kann
678 void SwSelPaintRects::Paint( const SwRect
& /*rRect*/ )
680 // nothing to do with overlays
683 // check current MapMode of the shell and set possibly the static members.
684 // Optional set the parameters pX, pY
685 void SwSelPaintRects::Get1PixelInLogic( const ViewShell
& rSh
,
688 const OutputDevice
* pOut
= rSh
.GetWin();
692 const MapMode
& rMM
= pOut
->GetMapMode();
693 if( pMapMode
->GetMapUnit() != rMM
.GetMapUnit() ||
694 pMapMode
->GetScaleX() != rMM
.GetScaleX() ||
695 pMapMode
->GetScaleY() != rMM
.GetScaleY() )
699 aTmp
= pOut
->PixelToLogic( aTmp
);
700 nPixPtX
= aTmp
.Width();
701 nPixPtY
= aTmp
.Height();
712 SwShellCrsr::SwShellCrsr( const SwCrsrShell
& rCShell
, const SwPosition
&rPos
)
713 : SwCursor(rPos
,0,false), SwSelPaintRects(rCShell
), pPt(SwPaM::GetPoint())
717 SwShellCrsr::SwShellCrsr( const SwCrsrShell
& rCShell
, const SwPosition
&rPos
,
718 const Point
& rPtPos
, SwPaM
* pRing
)
719 : SwCursor(rPos
, pRing
, false), SwSelPaintRects(rCShell
), aMkPt(rPtPos
),
720 aPtPt(rPtPos
), pPt(SwPaM::GetPoint())
724 SwShellCrsr::SwShellCrsr( SwShellCrsr
& rICrsr
)
725 : SwCursor(rICrsr
), SwSelPaintRects(*rICrsr
.GetShell()),
726 aMkPt(rICrsr
.GetMkPos()), aPtPt(rICrsr
.GetPtPos()), pPt(SwPaM::GetPoint())
729 SwShellCrsr::~SwShellCrsr() {}
732 bool SwShellCrsr::IsReadOnlyAvailable() const
734 return GetShell()->IsReadOnlyAvailable();
737 void SwShellCrsr::SetMark()
739 if( SwPaM::GetPoint() == pPt
)
746 void SwShellCrsr::FillRects()
748 // die neuen Rechtecke berechnen
750 GetPoint()->nNode
.GetNode().IsCntntNode() &&
751 GetPoint()->nNode
.GetNode().GetCntntNode()->GetFrm() &&
752 (GetMark()->nNode
== GetPoint()->nNode
||
753 (GetMark()->nNode
.GetNode().IsCntntNode() &&
754 GetMark()->nNode
.GetNode().GetCntntNode()->GetFrm() ) ))
755 GetDoc()->GetRootFrm()->CalcFrmRects( *this, GetShell()->IsTableMode() );
759 void SwShellCrsr::Show()
761 SwShellCrsr
* pTmp
= this;
763 pTmp
->SwSelPaintRects::Show();
764 } while( this != ( pTmp
= dynamic_cast<SwShellCrsr
*>(pTmp
->GetNext()) ) );
771 // Dieses Rechteck wird neu gepaintet, also ist die SSelection in
772 // dem Bereich ungueltig
773 void SwShellCrsr::Invalidate( const SwRect
& rRect
)
775 SwShellCrsr
* pTmp
= this;
779 pTmp
->SwSelPaintRects::Invalidate( rRect
);
781 // --> FME 2005-08-18 #125102#
782 // skip any non SwShellCrsr objects in the ring
783 // (see:SwAutoFormat::DeleteSel()
785 Ring
* pTmpRing
= pTmp
;
789 pTmpRing
= pTmpRing
->GetNext();
790 pTmp
= dynamic_cast<SwShellCrsr
*>(pTmpRing
);
794 while( this != pTmp
);
796 SHOWBOOKMARKS2( 3, &rRect
)
797 SHOWREDLINES2( 3, &rRect
)
801 void SwShellCrsr::Hide()
803 SwShellCrsr
* pTmp
= this;
805 pTmp
->SwSelPaintRects::Hide();
806 } while( this != ( pTmp
= dynamic_cast<SwShellCrsr
*>(pTmp
->GetNext()) ) );
812 SwCursor
* SwShellCrsr::Create( SwPaM
* pRing
) const
814 return new SwShellCrsr( *GetShell(), *GetPoint(), GetPtPos(), pRing
);
818 short SwShellCrsr::MaxReplaceArived()
820 short nRet
= RET_YES
;
821 Window
* pDlg
= LAYOUT_THIS_WINDOW (::GetSearchDialog());
824 // alte Actions beenden; die Tabellen-Frames werden angelegt und
825 // eine SSelection kann erzeugt werden
828 ViewShell
*pShell
= GetDoc()->GetRootFrm()->GetCurrShell(),
831 for( nActCnt
= 0; pSh
->ActionPend(); ++nActCnt
)
833 aArr
.Insert( nActCnt
, aArr
.Count() );
834 } while( pShell
!= ( pSh
= (ViewShell
*)pSh
->GetNext() ) );
837 nRet
= QueryBox( pDlg
, SW_RES( MSG_COMCORE_ASKSEARCH
)).Execute();
840 for( USHORT n
= 0; n
< aArr
.Count(); ++n
)
842 for( nActCnt
= aArr
[n
]; nActCnt
--; )
844 pSh
= (ViewShell
*)pSh
->GetNext();
848 // ansonsten aus dem Basic, und dann auf RET_YES schalten
854 void SwShellCrsr::SaveTblBoxCntnt( const SwPosition
* pPos
)
856 ((SwCrsrShell
*)GetShell())->SaveTblBoxCntnt( pPos
);
859 BOOL
SwShellCrsr::UpDown( BOOL bUp
, USHORT nCnt
)
861 return SwCursor::UpDown( bUp
, nCnt
,
862 &GetPtPos(), GetShell()->GetUpDownX() );
867 // JP 05.03.98: zum Testen des UNO-Crsr Verhaltens hier die Implementierung
868 // am sichtbaren Cursor
870 BOOL
SwShellCrsr::IsSelOvr( int eFlags
)
872 return SwCursor::IsSelOvr( eFlags
);
877 // TRUE: an die Position kann der Cursor gesetzt werden
878 BOOL
SwShellCrsr::IsAtValidPos( BOOL bPoint
) const
880 if( GetShell() && ( GetShell()->IsAllProtect() ||
881 GetShell()->GetViewOptions()->IsReadonly() ||
882 ( GetShell()->Imp()->GetDrawView() &&
883 GetShell()->Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() )))
886 return SwCursor::IsAtValidPos( bPoint
);
891 SwShellTableCrsr::SwShellTableCrsr( const SwCrsrShell
& rCrsrSh
,
892 const SwPosition
& rPos
)
893 : SwCursor(rPos
,0,false), SwShellCrsr(rCrsrSh
, rPos
), SwTableCursor(rPos
)
897 SwShellTableCrsr::SwShellTableCrsr( const SwCrsrShell
& rCrsrSh
,
898 const SwPosition
& rMkPos
, const Point
& rMkPt
,
899 const SwPosition
& rPtPos
, const Point
& rPtPt
)
900 : SwCursor(rPtPos
,0,false), SwShellCrsr(rCrsrSh
, rPtPos
), SwTableCursor(rPtPos
)
908 SwShellTableCrsr::~SwShellTableCrsr() {}
910 void SwShellTableCrsr::SetMark() { SwShellCrsr::SetMark(); }
912 SwCursor
* SwShellTableCrsr::Create( SwPaM
* pRing
) const
914 return SwShellCrsr::Create( pRing
);
916 short SwShellTableCrsr::MaxReplaceArived()
918 return SwShellCrsr::MaxReplaceArived();
920 void SwShellTableCrsr::SaveTblBoxCntnt( const SwPosition
* pPos
)
922 SwShellCrsr::SaveTblBoxCntnt( pPos
);
926 void SwShellTableCrsr::FillRects()
928 // die neuen Rechtecke berechnen
929 // JP 16.01.98: wenn der Cursor noch "geparkt" ist nichts machen!!
930 if( !aSelBoxes
.Count() || bParked
||
931 !GetPoint()->nNode
.GetIndex() )
934 SwRegionRects
aReg( GetShell()->VisArea() );
935 SwNodes
& rNds
= GetDoc()->GetNodes();
936 for( USHORT n
= 0; n
< aSelBoxes
.Count(); ++n
)
938 const SwStartNode
* pSttNd
= (*(aSelBoxes
.GetData() + n
))->GetSttNd();
939 const SwTableNode
* pSelTblNd
= pSttNd
->FindTableNode();
941 SwNodeIndex
aIdx( *pSttNd
);
942 SwCntntNode
* pCNd
= rNds
.GoNextSection( &aIdx
, TRUE
, FALSE
);
945 // (see also lcl_FindTopLevelTable in unoobj2.cxx for a different
946 // version to do this)
947 const SwTableNode
* pCurTblNd
= pCNd
->FindTableNode();
948 while ( pSelTblNd
!= pCurTblNd
&& pCurTblNd
)
950 aIdx
= pCurTblNd
->EndOfSectionIndex();
951 pCNd
= rNds
.GoNextSection( &aIdx
, TRUE
, FALSE
);
952 pCurTblNd
= pCNd
->FindTableNode();
958 SwFrm
* pFrm
= pCNd
->GetFrm( &GetSttPos() );
959 while( pFrm
&& !pFrm
->IsCellFrm() )
960 pFrm
= pFrm
->GetUpper();
962 ASSERT( pFrm
, "Node nicht in einer Tabelle" );
966 if( pFrm
&& aReg
.GetOrigin().IsOver( pFrm
->Frm() ) )
969 pFrm
= pFrm
->GetNextCellLeaf( MAKEPAGE_NONE
);
977 // Pruefe, ob sich der SPoint innerhalb der Tabellen-SSelection befindet
978 BOOL
SwShellTableCrsr::IsInside( const Point
& rPt
) const
980 // die neuen Rechtecke berechnen
981 // JP 16.01.98: wenn der Cursor noch "geparkt" ist nichts machen!!
982 if( !aSelBoxes
.Count() || bParked
||
983 !GetPoint()->nNode
.GetIndex() )
986 SwNodes
& rNds
= GetDoc()->GetNodes();
987 for( USHORT n
= 0; n
< aSelBoxes
.Count(); ++n
)
989 SwNodeIndex
aIdx( *(*(aSelBoxes
.GetData() + n
))->GetSttNd() );
990 SwCntntNode
* pCNd
= rNds
.GoNextSection( &aIdx
, TRUE
, FALSE
);
994 SwFrm
* pFrm
= pCNd
->GetFrm( &GetPtPos() );
995 while( pFrm
&& !pFrm
->IsCellFrm() )
996 pFrm
= pFrm
->GetUpper();
997 ASSERT( pFrm
, "Node nicht in einer Tabelle" );
998 if( pFrm
&& pFrm
->Frm().IsInside( rPt
) )
1006 // JP 05.03.98: zum Testen des UNO-Crsr Verhaltens hier die Implementierung
1007 // am sichtbaren Cursor
1008 BOOL
SwShellTableCrsr::IsSelOvr( int eFlags
)
1010 return SwShellCrsr::IsSelOvr( eFlags
);
1015 BOOL
SwShellTableCrsr::IsAtValidPos( BOOL bPoint
) const
1017 return SwShellCrsr::IsAtValidPos( bPoint
);