update dev300-m58
[ooovba.git] / applied_patches / 0139-sc-paste-on-enter.diff
blob295a7fdb7bb7fa81cfc31a690d02c2f048a39ff2
1 diff --git sc/source/ui/app/inputhdl.cxx sc/source/ui/app/inputhdl.cxx
2 index 98aac39..6ac26bc 100644
3 --- sc/source/ui/app/inputhdl.cxx
4 +++ sc/source/ui/app/inputhdl.cxx
5 @@ -2055,6 +2055,7 @@ IMPL_LINK( ScInputHandler, ModifyHdl, void *, EMPTYARG )
7 BOOL ScInputHandler::DataChanging( sal_Unicode cTyped, BOOL bFromCommand ) // return TRUE = new view created
9 + pActiveViewSh->GetViewData()->SetPasteMode( SC_PASTE_NONE );
10 bInOwnChange = TRUE; // disable ModifyHdl (reset in DataChanged)
12 if ( eMode == SC_INPUT_NONE )
13 diff --git sc/source/ui/inc/viewdata.hxx sc/source/ui/inc/viewdata.hxx
14 index 6f0d986..19583a8 100644
15 --- sc/source/ui/inc/viewdata.hxx
16 +++ sc/source/ui/inc/viewdata.hxx
17 @@ -89,6 +89,13 @@ enum ScMarkType
18 #endif
21 +enum ScPasteFlags
23 + SC_PASTE_NONE = 0, // No flags specified
24 + SC_PASTE_MODE = 1, // Enable paste-mode
25 + SC_PASTE_BORDER = 2, // Show a border around the source cells
26 +};
28 class ScDocShell;
29 class ScDocument;
30 class ScDBFunc;
31 @@ -210,6 +217,8 @@ private:
32 SCCOL nTabStartCol; // fuer Enter nach Tab
33 ScRange aDelRange; // fuer AutoFill-Loeschen
35 + ScPasteFlags nPasteFlags;
37 ScSplitPos eEditActivePart; // the part that was active when edit mode was started
38 BOOL bEditActive[4]; // aktiv?
39 BOOL bActive; // aktives Fenster ?
40 @@ -295,6 +304,8 @@ public:
41 SCCOL GetFixPosX() const { return pThisTab->nFixPosX; }
42 SCROW GetFixPosY() const { return pThisTab->nFixPosY; }
43 BOOL IsPagebreakMode() const { return bPagebreak; }
44 + BOOL IsPasteMode() const { return nPasteFlags & SC_PASTE_MODE; }
45 + BOOL ShowPasteSource() const { return nPasteFlags & SC_PASTE_BORDER; }
47 void SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX );
48 void SetPosY( ScVSplitPos eWhich, SCROW nNewPosY );
49 @@ -309,6 +320,7 @@ public:
50 void SetFixPosX( SCCOL nPos ) { pThisTab->nFixPosX = nPos; }
51 void SetFixPosY( SCROW nPos ) { pThisTab->nFixPosY = nPos; }
52 void SetPagebreakMode( BOOL bSet );
53 + void SetPasteMode ( ScPasteFlags nFlags ) { nPasteFlags = nFlags; }
55 void SetZoomType( SvxZoomType eNew, BOOL bAll );
56 void SetZoom( const Fraction& rNewX, const Fraction& rNewY, BOOL bAll );
57 diff --git sc/source/ui/view/cellsh1.cxx sc/source/ui/view/cellsh1.cxx
58 index ba66243..0cd4007 100644
59 --- sc/source/ui/view/cellsh1.cxx
60 +++ sc/source/ui/view/cellsh1.cxx
61 @@ -1170,6 +1170,8 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
62 WaitObject aWait( GetViewData()->GetDialogParent() );
63 pTabViewShell->CopyToClip( NULL, FALSE, FALSE, TRUE );
64 rReq.Done();
65 + GetViewData()->SetPasteMode( (ScPasteFlags) (SC_PASTE_MODE | SC_PASTE_BORDER) );
66 + pTabViewShell->ShowCursor();
68 break;
70 @@ -1178,6 +1180,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
71 WaitObject aWait( GetViewData()->GetDialogParent() );
72 pTabViewShell->CutToClip( NULL, TRUE );
73 rReq.Done();
74 + GetViewData()->SetPasteMode( SC_PASTE_MODE );
76 break;
78 diff --git sc/source/ui/view/gridwin.cxx sc/source/ui/view/gridwin.cxx
79 index 6fc33d5..6e0280a 100644
80 --- sc/source/ui/view/gridwin.cxx
81 +++ sc/source/ui/view/gridwin.cxx
82 @@ -118,6 +118,7 @@
83 #include "userdat.hxx"
84 #include "drwlayer.hxx"
85 #include "attrib.hxx"
86 +#include "cellsh.hxx"
87 #include "validat.hxx"
88 #include "tabprotection.hxx"
89 #include "postit.hxx"
90 @@ -2969,12 +2970,30 @@ void ScGridWindow::SelectForContextMenu( const Point& rPosPixel )
94 +static void ClearSingleSelection( ScViewData* pViewData )
96 + SCCOL nX;
97 + SCROW nY;
98 + ScTransferObj* pTransObj = ScTransferObj::GetOwnClipboard(
99 + pViewData->GetActiveWin() );
100 + if (!pTransObj)
101 + return;
103 + ScDocument* pClipDoc = pTransObj->GetDocument();
104 + pClipDoc->GetClipArea( nX, nY, TRUE );
105 + if (nX == 0 && nY == 0)
107 + ScTabView* pView = pViewData->GetView();
108 + pView->Unmark();
112 void __EXPORT ScGridWindow::KeyInput(const KeyEvent& rKEvt)
114 // #96965# Cursor control for ref input dialog
115 + const KeyCode& rKeyCode = rKEvt.GetKeyCode();
116 if( SC_MOD()->IsRefDialogOpen() )
118 - const KeyCode& rKeyCode = rKEvt.GetKeyCode();
119 if( !rKeyCode.GetModifier() && (rKeyCode.GetCode() == KEY_F2) )
121 SC_MOD()->EndReference();
122 @@ -2989,9 +3008,35 @@ void __EXPORT ScGridWindow::KeyInput(const KeyEvent& rKEvt)
123 return;
126 + else if( rKeyCode.GetCode() == KEY_RETURN && pViewData->IsPasteMode() )
128 + ScTabViewShell* pTabViewShell = pViewData->GetViewShell();
130 + ScCellShell::PasteFromClipboard( pViewData, pTabViewShell, FALSE );
131 + ClearSingleSelection( pViewData );
133 + uno::Reference<datatransfer::clipboard::XClipboard> xSystemClipboard =
134 + TransferableHelper::GetSystemClipboard();
135 + if (xSystemClipboard.is())
137 + xSystemClipboard->setContents(
138 + uno::Reference<datatransfer::XTransferable>(),
139 + uno::Reference<datatransfer::clipboard::XClipboardOwner>());
142 + // hide the border around the copy source
143 + pViewData->SetPasteMode( SC_PASTE_NONE );
144 + UpdateCursorOverlay();
145 + return;
147 // wenn semi-Modeless-SfxChildWindow-Dialog oben, keine KeyInputs:
148 else if( !pViewData->IsAnyFillMode() )
150 + if (rKeyCode.GetCode() == KEY_ESCAPE)
152 + pViewData->SetPasteMode( SC_PASTE_NONE );
153 + UpdateCursorOverlay();
155 // query for existing note marker before calling ViewShell's keyboard handling
156 // which may remove the marker
157 BOOL bHadKeyMarker = ( pNoteMarker && pNoteMarker->IsByKeyboard() );
158 diff --git sc/source/ui/view/viewdata.cxx sc/source/ui/view/viewdata.cxx
159 index df48982..e75b864 100644
160 --- sc/source/ui/view/viewdata.cxx
161 +++ sc/source/ui/view/viewdata.cxx
162 @@ -306,6 +306,7 @@ ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh )
163 eRefType ( SC_REFTYPE_NONE ),
164 nTabNo ( 0 ),
165 nRefTabNo ( 0 ),
166 + nPasteFlags ( SC_PASTE_NONE ),
167 eEditActivePart( SC_SPLIT_BOTTOMLEFT ),
168 bActive ( TRUE ), //! wie initialisieren?
169 bIsRefMode ( FALSE ),
170 @@ -432,6 +433,7 @@ void ScViewData::InitData( ScDocument* pDocument )
171 //UNUSED2008-05 aDefPageZoomX = pRef->aDefPageZoomX;
172 //UNUSED2008-05 aDefPageZoomY = pRef->aDefPageZoomY;
173 //UNUSED2008-05 bPagebreak = pRef->bPagebreak;
174 +//UNUSED2008-05 nPasteFlags = pRef->nPasteFlags;
175 //UNUSED2008-05 aLogicMode = pRef->aLogicMode;
176 //UNUSED2008-05
177 //UNUSED2008-05 SetGridMode ( pRef->IsGridMode() );
178 diff --git sc/source/ui/view/viewfunc.cxx sc/source/ui/view/viewfunc.cxx
179 index 8155a80..61670e7 100644
180 --- sc/source/ui/view/viewfunc.cxx
181 +++ sc/source/ui/view/viewfunc.cxx
182 @@ -1910,6 +1910,7 @@ void ScViewFunc::DeleteMulti( BOOL bRows, BOOL bRecord )
184 void ScViewFunc::DeleteContents( USHORT nFlags, BOOL bRecord )
186 + GetViewData()->SetPasteMode( SC_PASTE_NONE );
187 // nur wegen Matrix nicht editierbar? Attribute trotzdem ok
188 BOOL bOnlyNotBecauseOfMatrix;
189 BOOL bEditable = SelectionEditable( &bOnlyNotBecauseOfMatrix );