diff options
-rw-r--r-- | sw/inc/crsrsh.hxx | 9 | ||||
-rw-r--r-- | sw/source/core/crsr/crsrsh.cxx | 28 | ||||
-rw-r--r-- | sw/source/core/crsr/viscrs.cxx | 156 |
3 files changed, 34 insertions, 159 deletions
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index 8e1e0cd37a..692184be2d 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -150,9 +150,6 @@ const int CRSR_POSOLD = 0x01, // Cursor bleibt an alter Doc-Position String *ReplaceBackReferences( const com::sun::star::util::SearchOptions& rSearchOpt, SwPaM* pPam ); -// #i75172# -enum SwOverlayType { SW_OVERLAY_INVERT, SW_OVERLAY_TRANSPARENT }; - // die Cursor - Shell class SW_DLLPUBLIC SwCrsrShell : public ViewShell, public SwModify { @@ -252,9 +249,6 @@ private: // OD 11.02.2003 #100556# - flag to allow/avoid execution of marcos (default: true) bool mbMacroExecAllowed : 1; - // #i88893# the overlay type to use for cursor - SwOverlayType maSwOverlayType; - SW_DLLPRIVATE void UpdateCrsr( USHORT eFlags =SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE, BOOL bIdleEnd = FALSE ); @@ -352,9 +346,6 @@ public: // only for usage in special cases allowed! void ExtendedSelectAll(); - // #i88893# the overlay type to use for cursor - SwOverlayType getSwOverlayType() const { return maSwOverlayType; } - SwPaM* GetCrsr( BOOL bMakeTblCrsr = TRUE ) const; inline SwCursor* GetSwCrsr( BOOL bMakeTblCrsr = TRUE ) const; // nur den akt. Cursor returnen diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index f828bd3542..5c6fc9a21c 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -2569,22 +2569,6 @@ void SwCrsrShell::ParkCrsr( const SwNodeIndex &rIdx ) * Alle Ansichten eines Dokumentes stehen im Ring der Shells. */ -SwOverlayType impGetOverlayType(OutputDevice* pOut) -{ - if(!pOut) - { - pOut = Application::GetDefaultDevice(); - } - - if(pOut->GetSettings().GetStyleSettings().GetHighContrastMode() - || !pOut->supportsOperation( OutDevSupport_TransparentRect )) - { - return SW_OVERLAY_INVERT; - } - - return SW_OVERLAY_TRANSPARENT; -} - SwCrsrShell::SwCrsrShell( SwCrsrShell& rShell, Window *pInitWin ) : ViewShell( rShell, pInitWin ), SwModify( 0 ), pCrsrStk( 0 ), pBlockCrsr( 0 ), pTblCrsr( 0 ), @@ -2592,9 +2576,8 @@ SwCrsrShell::SwCrsrShell( SwCrsrShell& rShell, Window *pInitWin ) eMvState( MV_NONE ), // --> OD 2008-04-02 #refactorlists# sMarkedListId(), - nMarkedListLevel( 0 ), + nMarkedListLevel( 0 ) // <-- - maSwOverlayType(SW_OVERLAY_INVERT) { SET_CURR_SHELL( this ); // Nur die Position vom aktuellen Cursor aus der Copy-Shell uebernehmen @@ -2610,9 +2593,6 @@ SwCrsrShell::SwCrsrShell( SwCrsrShell& rShell, Window *pInitWin ) // UpdateCrsr( 0 ); // OD 11.02.2003 #100556# mbMacroExecAllowed = rShell.IsMacroExecAllowed(); - - // #i88893# init cursor selection type - maSwOverlayType = impGetOverlayType(pInitWin); } @@ -2628,9 +2608,8 @@ SwCrsrShell::SwCrsrShell( SwDoc& rDoc, Window *pInitWin, eMvState( MV_NONE ), // state for crsr-travelling - GetCrsrOfst // --> OD 2008-04-02 #refactorlists# sMarkedListId(), - nMarkedListLevel( 0 ), + nMarkedListLevel( 0 ) // <-- - maSwOverlayType(SW_OVERLAY_INVERT) { SET_CURR_SHELL( this ); /* @@ -2658,9 +2637,6 @@ SwCrsrShell::SwCrsrShell( SwDoc& rDoc, Window *pInitWin, // UpdateCrsr( 0 ); // OD 11.02.2003 #100556# mbMacroExecAllowed = true; - - // #i88893# init cursor selection type - maSwOverlayType = impGetOverlayType(pInitWin); } diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index 5b5277c6cd..8f31456292 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -59,19 +59,10 @@ #include <comcore.hrc> // ResId fuer Abfrage wenn zu Search & Replaces #endif -// #i75172# #include <svx/sdr/overlay/overlaymanager.hxx> #include <svx/sdrpaintwindow.hxx> -#include <basegfx/polygon/b2dpolygontools.hxx> -#include <basegfx/polygon/b2dpolygon.hxx> -#include <basegfx/polygon/b2dpolypolygontools.hxx> -#include <basegfx/matrix/b2dhommatrix.hxx> -#include <vcl/hatch.hxx> - -#include <drawinglayer/primitive2d/invertprimitive2d.hxx> -#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> -#include <drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx> -#include <basegfx/polygon/b2dpolygontools.hxx> +#include <vcl/svapp.hxx> +#include <svx/sdr/overlay/overlayselection.hxx> extern void SwCalcPixStatics( OutputDevice *pOut ); @@ -524,106 +515,6 @@ void SwVisCrsr::_SetPosAndShow() } ////////////////////////////////////////////////////////////////////////////// -// #i75172# - -namespace sdr -{ - namespace overlay - { - class OverlaySwSelPaintRects : public OverlayObject - { - // geometry - std::vector< basegfx::B2DRange > maRanges; - SwOverlayType mePaintType; - - // geometry creation for OverlayObject - virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence(); - - public: - OverlaySwSelPaintRects(Color aBaseColor, const std::vector< basegfx::B2DRange >& rRanges, SwOverlayType eType); - virtual ~OverlaySwSelPaintRects(); - - // data access - const std::vector< basegfx::B2DRange >& getB2DRanges() const { return maRanges; } - void setB2DRanges(const std::vector< basegfx::B2DRange >& rNew); - }; - - drawinglayer::primitive2d::Primitive2DSequence OverlaySwSelPaintRects::createOverlayObjectPrimitive2DSequence() - { - drawinglayer::primitive2d::Primitive2DSequence aRetval; - const sal_uInt32 nCount(maRanges.size()); - - if(nCount) - { - const basegfx::BColor aRGBColor(getBaseColor().getBColor()); - aRetval.realloc(nCount); - - // create primitives for all ranges - for(sal_uInt32 a(0); a < nCount; a++) - { - const basegfx::B2DRange& rRange(maRanges[a]); - const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(rRange)); - - aRetval[a] = drawinglayer::primitive2d::Primitive2DReference( - new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( - basegfx::B2DPolyPolygon(aPolygon), - aRGBColor)); - } - - - if( mePaintType == SW_OVERLAY_TRANSPARENT) - { - // embed in 50% transparent paint - const drawinglayer::primitive2d::Primitive2DReference aUnifiedAlpha( - new drawinglayer::primitive2d::UnifiedAlphaPrimitive2D( - aRetval, - 0.5)); - - aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedAlpha, 1); - } - else // SW_OVERLAY_INVERT - { - // embed in invert primitive - const drawinglayer::primitive2d::Primitive2DReference aInvert( - new drawinglayer::primitive2d::InvertPrimitive2D( - aRetval)); - - aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aInvert, 1); - } - } - - return aRetval; - } - - OverlaySwSelPaintRects::OverlaySwSelPaintRects(Color aBaseColor, const std::vector< basegfx::B2DRange >& rRanges, SwOverlayType eType) - : OverlayObject(aBaseColor), - maRanges(rRanges), - mePaintType(eType) - { - // no AA for selection overlays - allowAntiAliase(false); - } - - OverlaySwSelPaintRects::~OverlaySwSelPaintRects() - { - if(getOverlayManager()) - { - getOverlayManager()->remove(*this); - } - } - - void OverlaySwSelPaintRects::setB2DRanges(const std::vector< basegfx::B2DRange >& rNew) - { - if(rNew != maRanges) - { - maRanges = rNew; - objectChange(); - } - } - } // end of namespace overlay -} // end of namespace sdr - -////////////////////////////////////////////////////////////////////////////// SwSelPaintRects::SwSelPaintRects( const SwCrsrShell& rCSh ) : SwRects( 0 ), @@ -671,8 +562,11 @@ void SwSelPaintRects::Show() if(pView && pView->PaintWindowCount()) { + // reset rects SwRects::Remove( 0, SwRects::Count() ); FillRects(); + + // get new rects std::vector< basegfx::B2DRange > aNewRanges; for(sal_uInt16 a(0); a < Count(); a++) @@ -689,7 +583,7 @@ void SwSelPaintRects::Show() { if(aNewRanges.size()) { - static_cast< sdr::overlay::OverlaySwSelPaintRects* >(mpCursorOverlay)->setB2DRanges(aNewRanges); + static_cast< sdr::overlay::OverlaySelection* >(mpCursorOverlay)->setRanges(aNewRanges); } else { @@ -704,20 +598,34 @@ void SwSelPaintRects::Show() if(pTargetOverlay) { - Color aHighlight(COL_BLACK); - const OutputDevice *pOut = GetShell()->GetOut(); - - if(pOut) - { - aHighlight = pOut->GetSettings().GetStyleSettings().GetHighlightColor(); + // #i97672# get the system's hilight color and limit it to the maximum + // allowed luminance. This is needed to react on too bright hilight colors + // which would otherwise vive a bad visualisation + const OutputDevice *pOut = Application::GetDefaultDevice(); + Color aHighlight(pOut->GetSettings().GetStyleSettings().GetHighlightColor()); + const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; + const basegfx::BColor aSelection(aHighlight.getBColor()); + const double fLuminance(aSelection.luminance()); + const double fMaxLum(aSvtOptionsDrawinglayer.GetSelectionMaximumLuminancePercent() / 100.0); + + if(fLuminance > fMaxLum) + { + const double fFactor(fMaxLum / fLuminance); + const basegfx::BColor aNewSelection( + aSelection.getRed() * fFactor, + aSelection.getGreen() * fFactor, + aSelection.getBlue() * fFactor); + + aHighlight = Color(aNewSelection); } - SwOverlayType aType(GetShell()->getSwOverlayType()); -#ifdef DBG_UTIL - static bool bChange(false); - if(bChange) aType = (SW_OVERLAY_INVERT == aType) ? SW_OVERLAY_TRANSPARENT : SW_OVERLAY_INVERT; -#endif - mpCursorOverlay = new sdr::overlay::OverlaySwSelPaintRects(aHighlight, aNewRanges, aType); + // create correct selection + mpCursorOverlay = new sdr::overlay::OverlaySelection( + sdr::overlay::OVERLAY_TRANSPARENT, + aHighlight, + aNewRanges, + true); + pTargetOverlay->add(*mpCursorOverlay); } } |