diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2010-09-28 11:13:12 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2010-09-28 11:13:12 -0400 |
commit | be2150398ce765b87d44ada8a13c09345be52e22 (patch) | |
tree | 646b2e1cc0131ebe396249ed1c0322d6e727c5cd | |
parent | f2ab6ab8380f520ede5a46bfe5cf014dad97f05a (diff) |
Port cws-koheicopyborder-sc.diff from ooo-build.
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/inc/gridwin.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/inc/tabview.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/viewdata.hxx | 12 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 114 | ||||
-rw-r--r-- | sc/source/ui/view/makefile.mk | 2 | ||||
-rw-r--r-- | sc/source/ui/view/tabview2.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/view/tabview3.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 4 |
11 files changed, 157 insertions, 2 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 60b856247d8e..4921600b140a 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -2084,6 +2084,7 @@ IMPL_LINK( ScInputHandler, ModifyHdl, void *, EMPTYARG ) BOOL ScInputHandler::DataChanging( sal_Unicode cTyped, BOOL bFromCommand ) // return TRUE = new view created { + pActiveViewSh->GetViewData()->SetPasteMode( SC_PASTE_NONE ); bInOwnChange = TRUE; // disable ModifyHdl (reset in DataChanged) if ( eMode == SC_INPUT_NONE ) @@ -2304,6 +2305,10 @@ void ScInputHandler::SetMode( ScInputMode eNewMode ) return; } + if (eNewMode != SC_INPUT_NONE) + // Disable paste mode when edit mode starts. + pActiveViewSh->GetViewData()->SetPasteMode( SC_PASTE_NONE ); + bInOwnChange = TRUE; // disable ModifyHdl (reset below) ScInputMode eOldMode = eMode; diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index a2283bf2b7de..9843878032c0 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -108,6 +108,7 @@ private: // #114409# ::sdr::overlay::OverlayObjectList* mpOOCursors; ::sdr::overlay::OverlayObjectList* mpOOSelection; + ::sdr::overlay::OverlayObjectList* mpOOSelectionBorder; ::sdr::overlay::OverlayObjectList* mpOOAutoFill; ::sdr::overlay::OverlayObjectList* mpOODragRect; ::sdr::overlay::OverlayObjectList* mpOOHeader; @@ -399,6 +400,8 @@ public: void CursorChanged(); void DrawLayerCreated(); + void DeleteCopySourceOverlay(); + void UpdateCopySourceOverlay(); void DeleteCursorOverlay(); void UpdateCursorOverlay(); void DeleteSelectionOverlay(); diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index 80fb979d539c..5f16bbe009fa 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -435,6 +435,7 @@ public: void CreateAnchorHandles(SdrHdlList& rHdl, const ScAddress& rAddress); + void UpdateCopySourceOverlay(); void UpdateSelectionOverlay(); void UpdateShrinkOverlay(); void UpdateAllOverlays(); diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index 5d1a60a214c6..ebd2ea85d457 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -86,6 +86,13 @@ enum ScMarkType #endif }; +enum ScPasteFlags +{ + SC_PASTE_NONE = 0, // No flags specified + SC_PASTE_MODE = 1, // Enable paste-mode + SC_PASTE_BORDER = 2, // Show a border around the source cells +}; + class ScDocShell; class ScDocument; class ScDBFunc; @@ -209,6 +216,8 @@ private: SCCOL nTabStartCol; // fuer Enter nach Tab ScRange aDelRange; // fuer AutoFill-Loeschen + ScPasteFlags nPasteFlags; + ScSplitPos eEditActivePart; // the part that was active when edit mode was started BOOL bEditActive[4]; // aktiv? BOOL bActive; // aktives Fenster ? @@ -295,6 +304,8 @@ public: SCCOL GetFixPosX() const { return pThisTab->nFixPosX; } SCROW GetFixPosY() const { return pThisTab->nFixPosY; } BOOL IsPagebreakMode() const { return bPagebreak; } + bool IsPasteMode() const { return nPasteFlags & SC_PASTE_MODE; } + bool ShowPasteSource() const { return nPasteFlags & SC_PASTE_BORDER; } void SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX ); void SetPosY( ScVSplitPos eWhich, SCROW nNewPosY ); @@ -309,6 +320,7 @@ public: void SetFixPosX( SCCOL nPos ) { pThisTab->nFixPosX = nPos; } void SetFixPosY( SCROW nPos ) { pThisTab->nFixPosY = nPos; } void SetPagebreakMode( BOOL bSet ); + void SetPasteMode ( ScPasteFlags nFlags ) { nPasteFlags = nFlags; } void SetZoomType( SvxZoomType eNew, BOOL bAll ); void SetZoomType( SvxZoomType eNew, std::vector< SCTAB >& tabs ); diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 84b09b348d0c..0a2aaaa9618d 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -1162,11 +1162,16 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) // Clipboard // + 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(); + pViewData->SetPasteMode( (ScPasteFlags) (SC_PASTE_MODE | SC_PASTE_BORDER) ); + pTabViewShell->ShowCursor(); + pTabViewShell->UpdateCopySourceOverlay(); } break; @@ -1175,6 +1180,8 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) WaitObject aWait( GetViewData()->GetDialogParent() ); pTabViewShell->CutToClip( NULL, TRUE ); rReq.Done(); + GetViewData()->SetPasteMode( SC_PASTE_MODE ); + pTabViewShell->UpdateCopySourceOverlay(); } break; diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index e3ab2f453db1..6c4f557a4453 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -121,6 +121,9 @@ #include "tabprotection.hxx" #include "postit.hxx" #include "dpcontrol.hxx" +#include "clipparam.hxx" +#include "cellsh.hxx" +#include "overlayobject.hxx" #include "cellsuno.hxx" #include "drawview.hxx" @@ -405,6 +408,7 @@ ScGridWindow::ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhic DragSourceHelper( this ), mpOOCursors( NULL ), mpOOSelection( NULL ), + mpOOSelectionBorder( NULL ), mpOOAutoFill( NULL ), mpOODragRect( NULL ), mpOOHeader( NULL ), @@ -3062,12 +3066,30 @@ void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, } } +static void ClearSingleSelection( ScViewData* pViewData ) +{ + SCCOL nX; + SCROW nY; + ScTransferObj* pTransObj = ScTransferObj::GetOwnClipboard( + pViewData->GetActiveWin() ); + if (!pTransObj) + return; + + ScDocument* pClipDoc = pTransObj->GetDocument(); + pClipDoc->GetClipArea( nX, nY, TRUE ); + if (nX == 0 && nY == 0) + { + ScTabView* pView = pViewData->GetView(); + pView->Unmark(); + } +} + void __EXPORT ScGridWindow::KeyInput(const KeyEvent& rKEvt) { // #96965# Cursor control for ref input dialog + const KeyCode& rKeyCode = rKEvt.GetKeyCode(); if( SC_MOD()->IsRefDialogOpen() ) { - const KeyCode& rKeyCode = rKEvt.GetKeyCode(); if( !rKeyCode.GetModifier() && (rKeyCode.GetCode() == KEY_F2) ) { SC_MOD()->EndReference(); @@ -3082,9 +3104,35 @@ void __EXPORT ScGridWindow::KeyInput(const KeyEvent& rKEvt) return; } } + else if( rKeyCode.GetCode() == KEY_RETURN && pViewData->IsPasteMode() ) + { + ScTabViewShell* pTabViewShell = pViewData->GetViewShell(); + + ScCellShell::PasteFromClipboard( pViewData, pTabViewShell, FALSE ); + ClearSingleSelection( pViewData ); + + uno::Reference<datatransfer::clipboard::XClipboard> xSystemClipboard = + TransferableHelper::GetSystemClipboard(); + if (xSystemClipboard.is()) + { + xSystemClipboard->setContents( + uno::Reference<datatransfer::XTransferable>(), + uno::Reference<datatransfer::clipboard::XClipboardOwner>()); + } + + // hide the border around the copy source + pViewData->SetPasteMode( SC_PASTE_NONE ); + UpdateCopySourceOverlay(); + return; + } // wenn semi-Modeless-SfxChildWindow-Dialog oben, keine KeyInputs: else if( !pViewData->IsAnyFillMode() ) { + if (rKeyCode.GetCode() == KEY_ESCAPE) + { + pViewData->SetPasteMode( SC_PASTE_NONE ); + UpdateCopySourceOverlay(); + } // query for existing note marker before calling ViewShell's keyboard handling // which may remove the marker BOOL bHadKeyMarker = ( pNoteMarker && pNoteMarker->IsByKeyboard() ); @@ -5162,6 +5210,7 @@ void ScGridWindow::CursorChanged() void ScGridWindow::ImpCreateOverlayObjects() { UpdateCursorOverlay(); + UpdateCopySourceOverlay(); UpdateSelectionOverlay(); UpdateAutoFillOverlay(); UpdateDragRectOverlay(); @@ -5173,6 +5222,7 @@ void ScGridWindow::ImpCreateOverlayObjects() void ScGridWindow::ImpDestroyOverlayObjects() { DeleteCursorOverlay(); + DeleteCopySourceOverlay(); DeleteSelectionOverlay(); DeleteAutoFillOverlay(); DeleteDragRectOverlay(); @@ -5193,6 +5243,68 @@ void ScGridWindow::DeleteCursorOverlay() DELETEZ( mpOOCursors ); } +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(); + if (!pOverlayManager) + return; + ScTransferObj* pTransObj = ScTransferObj::GetOwnClipboard( pViewData->GetActiveWin() ); + if (!pTransObj) + return; + ScDocument* pClipDoc = pTransObj->GetDocument(); + if (!pClipDoc) + return; + + SCTAB nCurTab = pViewData->GetCurPos().Tab(); + + ScClipParam& rClipParam = pClipDoc->GetClipParam(); + mpOOSelectionBorder = new ::sdr::overlay::OverlayObjectList; + for (ScRange* p = rClipParam.maRanges.First(); p; p = rClipParam.maRanges.Next()) + { + if (p->aStart.Tab() != nCurTab) + continue; + + SCCOL nClipStartX = p->aStart.Col(); + SCROW nClipStartY = p->aStart.Row(); + SCCOL nClipEndX = p->aEnd.Col(); + SCROW nClipEndY = p->aEnd.Row(); + + 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(); + + Rectangle aRect( aClipStartScrPos, Size(nSizeXPix, nSizeYPix) ); + + + Color aHighlight = GetSettings().GetStyleSettings().GetHighlightColor(); + + 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() { MapMode aDrawMode = GetDrawMapMode(); diff --git a/sc/source/ui/view/makefile.mk b/sc/source/ui/view/makefile.mk index 521c5bda91fc..f7be2b3cbaf3 100644 --- a/sc/source/ui/view/makefile.mk +++ b/sc/source/ui/view/makefile.mk @@ -94,6 +94,7 @@ SLOFILES = \ $(SLO)$/output.obj \ $(SLO)$/output2.obj \ $(SLO)$/output3.obj \ + $(SLO)$/overlayobject.obj \ $(SLO)$/gridmerg.obj \ $(SLO)$/invmerge.obj \ $(SLO)$/cellmergeoption.obj \ @@ -148,6 +149,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 a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index 3801139462fb..ce068e0ef6b2 100644 --- a/sc/source/ui/view/tabview2.cxx +++ b/sc/source/ui/view/tabview2.cxx @@ -704,6 +704,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 a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 33587027c659..93bf0f8e8f5c 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -1770,6 +1770,7 @@ void ScTabView::MakeEditView( ScEditEngineDefaulter* pEngine, SCCOL nCol, SCROW pGridWin[i]->DeleteCursorOverlay(); pGridWin[i]->DeleteAutoFillOverlay(); + pGridWin[i]->DeleteCopySourceOverlay(); // flush OverlayManager before changing MapMode to text edit pGridWin[i]->flushOverlayManager(); diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 408995258384..c28af8d05d37 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -319,6 +319,7 @@ ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh ) eRefType ( SC_REFTYPE_NONE ), nTabNo ( 0 ), nRefTabNo ( 0 ), + nPasteFlags ( SC_PASTE_NONE ), eEditActivePart( SC_SPLIT_BOTTOMLEFT ), bActive ( TRUE ), //! wie initialisieren? bIsRefMode ( FALSE ), diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index ed812540f9c7..58ea8ef7e925 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -1907,6 +1907,10 @@ void ScViewFunc::DeleteMulti( BOOL bRows, BOOL bRecord ) void ScViewFunc::DeleteContents( USHORT nFlags, BOOL bRecord ) { + 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 ); |