diff --git sc/source/ui/inc/gridwin.hxx sc/source/ui/inc/gridwin.hxx index 2b62bc5..3ab93fd 100644 --- sc/source/ui/inc/gridwin.hxx +++ sc/source/ui/inc/gridwin.hxx @@ -356,7 +356,6 @@ private: sdr::overlay::OverlayObjectCell::RangeVector* pRanges, const MapMode& rDrawMode, const RectangleConverter *pConverter = NULL); - void UpdateCopySourceOverlay(const MapMode& rDrawMode); protected: using Window::Resize; @@ -458,6 +457,8 @@ public: void CursorChanged(); void DrawLayerCreated(); + void DeleteCopySourceOverlay(); + void UpdateCopySourceOverlay(); void DeleteCursorOverlay(); void UpdateCursorOverlay(); void DeleteSelectionOverlay(); diff --git sc/source/ui/inc/overlayobject.hxx sc/source/ui/inc/overlayobject.hxx new file mode 100644 index 0000000..5c3e774 --- /dev/null +++ sc/source/ui/inc/overlayobject.hxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gridwin.hxx,v $ + * $Revision: 1.30 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __SC_OVERLAYOBJECT_HXX__ +#define __SC_OVERLAYOBJECT_HXX__ + +#include "svx/sdr/overlay/overlayobject.hxx" + +class OutputDevice; +class Window; + +class ScOverlayDashedBorder : public ::sdr::overlay::OverlayObject +{ +public: + ScOverlayDashedBorder(const ::basegfx::B2DRange& rRange, const Color& rColor, Window* pWin); + virtual ~ScOverlayDashedBorder(); + + virtual void Trigger(sal_uInt32 nTime); + virtual void transform(const ::basegfx::B2DHomMatrix& rMatrix); + virtual void zoomHasChanged(); + +private: + virtual void drawGeometry(OutputDevice& rOutputDevice); + virtual void createBaseRange(OutputDevice& rOutputDevice); + +private: + Window* mpParent; + bool mbToggle; +}; + +#endif diff --git sc/source/ui/inc/tabview.hxx sc/source/ui/inc/tabview.hxx index 1c9d508..0288469 100644 --- sc/source/ui/inc/tabview.hxx +++ sc/source/ui/inc/tabview.hxx @@ -441,6 +441,7 @@ public: void CreateAnchorHandles(SdrHdlList& rHdl, const ScAddress& rAddress); + void UpdateCopySourceOverlay(); void UpdateSelectionOverlay(); void UpdateShrinkOverlay(); void UpdateAllOverlays(); diff --git sc/source/ui/view/cellsh1.cxx sc/source/ui/view/cellsh1.cxx index 8950395..eee4c62 100644 --- sc/source/ui/view/cellsh1.cxx +++ sc/source/ui/view/cellsh1.cxx @@ -1167,11 +1167,13 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) case SID_COPY: // fuer Grafiken in DrawShell { - WaitObject aWait( GetViewData()->GetDialogParent() ); + ScViewData* pViewData = GetViewData(); + WaitObject aWait( pViewData->GetDialogParent() ); pTabViewShell->CopyToClip( NULL, FALSE, FALSE, TRUE ); rReq.Done(); - GetViewData()->SetPasteMode( (ScPasteFlags) (SC_PASTE_MODE | SC_PASTE_BORDER) ); + pViewData->SetPasteMode( (ScPasteFlags) (SC_PASTE_MODE | SC_PASTE_BORDER) ); pTabViewShell->ShowCursor(); + pTabViewShell->UpdateCopySourceOverlay(); } break; @@ -1181,6 +1183,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) pTabViewShell->CutToClip( NULL, TRUE ); rReq.Done(); GetViewData()->SetPasteMode( SC_PASTE_MODE ); + pTabViewShell->UpdateCopySourceOverlay(); } break; diff --git sc/source/ui/view/gridwin.cxx sc/source/ui/view/gridwin.cxx index 8713b06..93a674e 100644 --- sc/source/ui/view/gridwin.cxx +++ sc/source/ui/view/gridwin.cxx @@ -122,6 +122,8 @@ #include "tabprotection.hxx" #include "clipparam.hxx" #include "dpcontrol.hxx" +#include "overlayobject.hxx" +#include "basegfx/range/b2drange.hxx" // #114409# #include // FRound @@ -3060,7 +3062,7 @@ void __EXPORT ScGridWindow::KeyInput(const KeyEvent& rKEvt) // hide the border around the copy source pViewData->SetPasteMode( SC_PASTE_NONE ); - UpdateCursorOverlay(); + UpdateCopySourceOverlay(); return; } // wenn semi-Modeless-SfxChildWindow-Dialog oben, keine KeyInputs: @@ -3069,7 +3071,7 @@ void __EXPORT ScGridWindow::KeyInput(const KeyEvent& rKEvt) if (rKeyCode.GetCode() == KEY_ESCAPE) { pViewData->SetPasteMode( SC_PASTE_NONE ); - UpdateCursorOverlay(); + UpdateCopySourceOverlay(); } // query for existing note marker before calling ViewShell's keyboard handling // which may remove the marker @@ -5149,6 +5151,7 @@ void ScGridWindow::CursorChanged() void ScGridWindow::ImpCreateOverlayObjects() { UpdateCursorOverlay(); + UpdateCopySourceOverlay(); UpdateSelectionOverlay(); UpdateAutoFillOverlay(); UpdateDragRectOverlay(); @@ -5160,6 +5163,7 @@ void ScGridWindow::ImpCreateOverlayObjects() void ScGridWindow::ImpDestroyOverlayObjects() { DeleteCursorOverlay(); + DeleteCopySourceOverlay(); DeleteSelectionOverlay(); DeleteAutoFillOverlay(); DeleteDragRectOverlay(); @@ -5178,7 +5182,6 @@ void ScGridWindow::UpdateAllOverlays() void ScGridWindow::DeleteCursorOverlay() { DELETEZ( mpOOCursors ); - DELETEZ( mpOOSelectionBorder ); } void ScGridWindow::ConvertPixelRectsToRangeVector( const ::std::vector< Rectangle >& rPixelRects, @@ -5202,8 +5205,20 @@ void ScGridWindow::ConvertPixelRectsToRangeVector( const ::std::vector< Rectangl } } -void ScGridWindow::UpdateCopySourceOverlay( const MapMode& rDrawMode ) +void ScGridWindow::DeleteCopySourceOverlay() +{ + DELETEZ( mpOOSelectionBorder ); +} + +void ScGridWindow::UpdateCopySourceOverlay() { + MapMode aDrawMode = GetDrawMapMode(); + MapMode aOldMode = GetMapMode(); + if ( aOldMode != aDrawMode ) + SetMapMode( aDrawMode ); + + DeleteCopySourceOverlay(); + if (!pViewData->ShowPasteSource()) return; ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager(); @@ -5232,33 +5247,24 @@ void ScGridWindow::UpdateCopySourceOverlay( const MapMode& rDrawMode ) Point aClipStartScrPos = pViewData->GetScrPos( nClipStartX, nClipStartY, eWhich ); Point aClipEndScrPos = pViewData->GetScrPos( nClipEndX + 1, nClipEndY + 1, eWhich ); - + aClipStartScrPos -= Point(1, 1); long nSizeXPix = aClipEndScrPos.X() - aClipStartScrPos.X(); long nSizeYPix = aClipEndScrPos.Y() - aClipStartScrPos.Y(); - aClipStartScrPos.X() -= 2; - aClipStartScrPos.Y() -= 2; + Rectangle aRect( aClipStartScrPos, Size(nSizeXPix, nSizeYPix) ); - Rectangle aRect( aClipStartScrPos, Size( nSizeXPix + 3, nSizeYPix + 3 ) ); - - std::vector aPixelRects; - - aPixelRects.push_back(Rectangle( aRect.Left(), aRect.Top(), aRect.Left()+2, aRect.Bottom() )); - aPixelRects.push_back(Rectangle( aRect.Right()-2, aRect.Top(), aRect.Right(), aRect.Bottom() )); - aPixelRects.push_back(Rectangle( aRect.Left()+3, aRect.Top(), aRect.Right()-3, aRect.Top()+2 )); - aPixelRects.push_back(Rectangle( aRect.Left()+3, aRect.Bottom()-2, aRect.Right()-3, aRect.Bottom() )); - - sdr::overlay::OverlayObjectCell::RangeVector aRanges; - ConvertPixelRectsToRangeVector( aPixelRects, &aRanges, rDrawMode ); - - ScOverlayType eType = SC_OVERLAY_BORDER_TRANSPARENT; Color aHighlight = GetSettings().GetStyleSettings().GetHighlightColor(); - sdr::overlay::OverlayObjectCell* pOverlay = new sdr::overlay::OverlayObjectCell( eType, aHighlight, aRanges ); - - pOverlayManager->add(*pOverlay); - mpOOSelectionBorder->append(*pOverlay); + + Rectangle aLogic = PixelToLogic(aRect, aDrawMode); + ::basegfx::B2DRange aRange(aLogic.Left(), aLogic.Top(), aLogic.Right(), aLogic.Bottom()); + ScOverlayDashedBorder* pDashedBorder = new ScOverlayDashedBorder(aRange, aHighlight, this); + pOverlayManager->add(*pDashedBorder); + mpOOSelectionBorder->append(*pDashedBorder); } + + if ( aOldMode != aDrawMode ) + SetMapMode( aOldMode ); } void ScGridWindow::UpdateCursorOverlay() @@ -5273,8 +5280,6 @@ void ScGridWindow::UpdateCursorOverlay() DeleteCursorOverlay(); - UpdateCopySourceOverlay( aDrawMode ); - std::vector aPixelRects; // diff --git sc/source/ui/view/makefile.mk sc/source/ui/view/makefile.mk index 312929c..9003498 100644 --- sc/source/ui/view/makefile.mk +++ sc/source/ui/view/makefile.mk @@ -98,6 +98,7 @@ SLOFILES = \ $(SLO)$/output.obj \ $(SLO)$/output2.obj \ $(SLO)$/output3.obj \ + $(SLO)$/overlayobject.obj \ $(SLO)$/gridmerg.obj \ $(SLO)$/invmerge.obj \ $(SLO)$/cellmergeoption.obj \ @@ -155,6 +156,7 @@ EXCEPTIONSFILES= \ $(SLO)$/gridwin.obj \ $(SLO)$/invmerge.obj \ $(SLO)$/output2.obj \ + $(SLO)$/overlayobject.obj \ $(SLO)$/pfuncache.obj \ $(SLO)$/spelldialog.obj \ $(SLO)$/cellsh1.obj \ diff --git sc/source/ui/view/overlayobject.cxx sc/source/ui/view/overlayobject.cxx new file mode 100644 index 0000000..5b16259 --- /dev/null +++ sc/source/ui/view/overlayobject.cxx @@ -0,0 +1,121 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gridwin.hxx,v $ + * $Revision: 1.30 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sc.hxx" + +#include "overlayobject.hxx" +#include "vcl/outdev.hxx" +#include "vcl/lineinfo.hxx" +#include "vcl/salbtype.hxx" +#include "vcl/window.hxx" +#include "tools/fract.hxx" +#include "basegfx/range/b2drange.hxx" +#include "basegfx/polygon/b2dpolygon.hxx" +#include "svx/sdr/overlay/overlaymanager.hxx" + +using ::sdr::overlay::OverlayObject; +using ::sdr::overlay::OverlayManager; + +#define DASH_UPDATE_INTERVAL 180 // in msec + +ScOverlayDashedBorder::ScOverlayDashedBorder(const ::basegfx::B2DRange& rRange, const Color& rColor, Window* pWin) : + OverlayObject(rColor), + mpParent(pWin), + mbToggle(true) +{ + mbAllowsAnimation = true; + maBaseRange = rRange; +} + +ScOverlayDashedBorder::~ScOverlayDashedBorder() +{ +} + +void ScOverlayDashedBorder::Trigger(sal_uInt32 nTime) +{ + OverlayManager* pMgr = getOverlayManager(); + if (pMgr) + { + SetTime(nTime + DASH_UPDATE_INTERVAL); + mbToggle = !mbToggle; + pMgr->InsertEvent(this); + objectChange(); + } +} + +void ScOverlayDashedBorder::transform(const ::basegfx::B2DHomMatrix& /*rMatrix*/) +{ +} + +void ScOverlayDashedBorder::zoomHasChanged() +{ +} + +void ScOverlayDashedBorder::drawGeometry(OutputDevice& rOutputDevice) +{ + using ::basegfx::B2DPoint; + using ::basegfx::B2DPolygon; + + OverlayManager* pMgr = getOverlayManager(); + if (!pMgr) + return; + + // save original AA and switch off for selection + const sal_uInt16 nOriginalAA(rOutputDevice.GetAntialiasing()); + rOutputDevice.SetAntialiasing(0); + + if (mbToggle) + { + pMgr->setStripeColorA(getBaseColor()); + pMgr->setStripeColorB(COL_WHITE); + } + else + { + pMgr->setStripeColorA(COL_WHITE); + pMgr->setStripeColorB(getBaseColor()); + } + + B2DPolygon aPoly; + aPoly.append(B2DPoint(maBaseRange.getMinX(), maBaseRange.getMinY())); + aPoly.append(B2DPoint(maBaseRange.getMaxX(), maBaseRange.getMinY())); + aPoly.append(B2DPoint(maBaseRange.getMaxX(), maBaseRange.getMaxY())); + aPoly.append(B2DPoint(maBaseRange.getMinX(), maBaseRange.getMaxY())); + aPoly.append(B2DPoint(maBaseRange.getMinX(), maBaseRange.getMinY())); + ImpDrawPolygonStriped(rOutputDevice, aPoly); + + // restore original AA + rOutputDevice.SetAntialiasing(nOriginalAA); +} + +void ScOverlayDashedBorder::createBaseRange(OutputDevice& /*rOutputDevice*/) +{ +} + diff --git sc/source/ui/view/tabview2.cxx sc/source/ui/view/tabview2.cxx index ddb584d..0cd6204 100644 --- sc/source/ui/view/tabview2.cxx +++ sc/source/ui/view/tabview2.cxx @@ -699,6 +699,13 @@ void ScTabView::ExpandBlockArea(SCsCOL nMovX, SCsROW nMovY) ExpandBlock(nAreaX, nAreaY, eMode); } +void ScTabView::UpdateCopySourceOverlay() +{ + for (sal_uInt8 i = 0; i < 4; ++i) + if (pGridWin[i] && pGridWin[i]->IsVisible()) + pGridWin[i]->UpdateCopySourceOverlay(); +} + void ScTabView::UpdateSelectionOverlay() { for (USHORT i=0; i<4; i++) diff --git sc/source/ui/view/tabview3.cxx sc/source/ui/view/tabview3.cxx index 7130fba..ff7c2cf 100644 --- sc/source/ui/view/tabview3.cxx +++ sc/source/ui/view/tabview3.cxx @@ -1810,6 +1810,7 @@ void ScTabView::MakeEditView( ScEditEngineDefaulter* pEngine, SCCOL nCol, SCROW pGridWin[i]->HideCursor(); pGridWin[i]->DeleteCursorOverlay(); + pGridWin[i]->DeleteCopySourceOverlay(); pGridWin[i]->DeleteAutoFillOverlay(); // flush OverlayManager before changing MapMode to text edit diff --git sc/source/ui/view/viewfunc.cxx sc/source/ui/view/viewfunc.cxx index 7be076a..92ed34b 100644 --- sc/source/ui/view/viewfunc.cxx +++ sc/source/ui/view/viewfunc.cxx @@ -1940,7 +1940,10 @@ void ScViewFunc::DeleteMulti( BOOL bRows, BOOL bRecord ) void ScViewFunc::DeleteContents( USHORT nFlags, BOOL bRecord ) { - GetViewData()->SetPasteMode( SC_PASTE_NONE ); + ScViewData* pViewData = GetViewData(); + pViewData->SetPasteMode( SC_PASTE_NONE ); + pViewData->GetViewShell()->UpdateCopySourceOverlay(); + // nur wegen Matrix nicht editierbar? Attribute trotzdem ok BOOL bOnlyNotBecauseOfMatrix; BOOL bEditable = SelectionEditable( &bOnlyNotBecauseOfMatrix );