diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-09-12 11:18:07 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-09-12 13:22:07 -0400 |
commit | abccf9b8e5f331a27f188ec5246a9e0f64f287dd (patch) | |
tree | e7d468796e5b003d1e196c547374894d75e109fa /sc | |
parent | ea280cef9c5293a1865786a2e8736bb9524f8751 (diff) |
Moved PasteFromClipboard() from ScCellShell to ScClipUtil (new class).
Diffstat (limited to 'sc')
-rw-r--r-- | sc/Library_sc.mk | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/cellsh.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/cliputil.hxx | 42 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 53 | ||||
-rw-r--r-- | sc/source/ui/view/cliputil.cxx | 87 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 3 |
6 files changed, 134 insertions, 54 deletions
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index 70cd612517a0..27b142fb079e 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -472,6 +472,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/ui/view/cellsh3 \ sc/source/ui/view/cellsh4 \ sc/source/ui/view/colrowba \ + sc/source/ui/view/cliputil \ sc/source/ui/view/dbfunc \ sc/source/ui/view/dbfunc2 \ sc/source/ui/view/dbfunc3 \ diff --git a/sc/source/ui/inc/cellsh.hxx b/sc/source/ui/inc/cellsh.hxx index b7cc54f5b7ef..26660292c58f 100644 --- a/sc/source/ui/inc/cellsh.hxx +++ b/sc/source/ui/inc/cellsh.hxx @@ -108,8 +108,6 @@ public: void ExecutePageSel( SfxRequest& rReq ); void ExecuteMove( SfxRequest& rReq ); void GetStateCursor( SfxItemSet& rSet ); - - static void PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog ); }; #endif diff --git a/sc/source/ui/inc/cliputil.hxx b/sc/source/ui/inc/cliputil.hxx new file mode 100644 index 000000000000..04a966c34242 --- /dev/null +++ b/sc/source/ui/inc/cliputil.hxx @@ -0,0 +1,42 @@ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2011 Kohei Yoshida <kohei.yoshida@suse.com> + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#ifndef __SC_CLIPUTIL_HXX__ +#define __SC_CLIPUTIL_HXX__ + +class ScViewData; +class ScTabViewShell; + +class ScClipUtil +{ + ScClipUtil(); + ~ScClipUtil(); +public: + static void PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog ); +}; + +#endif diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index a959020dea79..8a703b80f119 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -100,6 +100,7 @@ #include "dpshttab.hxx" // ScSheetSourceDesc #include "dbdata.hxx" #include "docsh.hxx" +#include "cliputil.hxx" #include "globstr.hrc" #include "scui_def.hxx" @@ -1169,7 +1170,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) case SID_PASTE: { - PasteFromClipboard ( GetViewData(), pTabViewShell, true ); + ScClipUtil::PasteFromClipboard ( GetViewData(), pTabViewShell, true ); rReq.Done(); } break; @@ -2433,54 +2434,4 @@ IMPL_LINK( ScCellShell, DialogClosed, AbstractScLinkedAreaDlg*, EMPTYARG ) return 0; } -void ScCellShell::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog ) -{ - Window* pWin = pViewData->GetActiveWin(); - ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin ); - ScDocument* pThisDoc = pViewData->GetDocument(); - ScDPObject* pDPObj = pThisDoc->GetDPAtCursor( pViewData->GetCurX(), - pViewData->GetCurY(), pViewData->GetTabNo() ); - if ( pOwnClip && pDPObj ) - { - // paste from Calc into DataPilot table: sort (similar to drag & drop) - - ScDocument* pClipDoc = pOwnClip->GetDocument(); - SCTAB nSourceTab = pOwnClip->GetVisibleTab(); - - SCCOL nClipStartX; - SCROW nClipStartY; - SCCOL nClipEndX; - SCROW nClipEndY; - pClipDoc->GetClipStart( nClipStartX, nClipStartY ); - pClipDoc->GetClipArea( nClipEndX, nClipEndY, sal_True ); - nClipEndX = nClipEndX + nClipStartX; - nClipEndY = nClipEndY + nClipStartY; // GetClipArea returns the difference - - ScRange aSource( nClipStartX, nClipStartY, nSourceTab, nClipEndX, nClipEndY, nSourceTab ); - sal_Bool bDone = pTabViewShell->DataPilotMove( aSource, pViewData->GetCurPos() ); - if ( !bDone ) - pTabViewShell->ErrorMessage( STR_ERR_DATAPILOT_INPUT ); - } - else - { - // normal paste - WaitObject aWait( pViewData->GetDialogParent() ); - if (!pOwnClip) - pTabViewShell->PasteFromSystem(); - else - { - ScDocument* pClipDoc = pOwnClip->GetDocument(); - sal_uInt16 nFlags = IDF_ALL; - if (pClipDoc->GetClipParam().isMultiRange()) - // For multi-range paste, we paste values by default. - nFlags &= ~IDF_FORMULA; - - pTabViewShell->PasteFromClip( nFlags, pClipDoc, - PASTE_NOFUNC, false, false, false, INS_NONE, IDF_NONE, - bShowDialog ); // allow warning dialog - } - } - pTabViewShell->CellContentChanged(); // => PasteFromSystem() ??? -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/cliputil.cxx b/sc/source/ui/view/cliputil.cxx new file mode 100644 index 000000000000..d7a6f882677c --- /dev/null +++ b/sc/source/ui/view/cliputil.cxx @@ -0,0 +1,87 @@ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2011 Kohei Yoshida <kohei.yoshida@suse.com> + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#include "cliputil.hxx" +#include "viewdata.hxx" +#include "tabvwsh.hxx" +#include "transobj.hxx" +#include "document.hxx" +#include "dpobject.hxx" +#include "globstr.hrc" +#include "clipparam.hxx" + +#include "vcl/waitobj.hxx" + +void ScClipUtil::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog ) +{ + Window* pWin = pViewData->GetActiveWin(); + ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin ); + ScDocument* pThisDoc = pViewData->GetDocument(); + ScDPObject* pDPObj = pThisDoc->GetDPAtCursor( pViewData->GetCurX(), + pViewData->GetCurY(), pViewData->GetTabNo() ); + if ( pOwnClip && pDPObj ) + { + // paste from Calc into DataPilot table: sort (similar to drag & drop) + + ScDocument* pClipDoc = pOwnClip->GetDocument(); + SCTAB nSourceTab = pOwnClip->GetVisibleTab(); + + SCCOL nClipStartX; + SCROW nClipStartY; + SCCOL nClipEndX; + SCROW nClipEndY; + pClipDoc->GetClipStart( nClipStartX, nClipStartY ); + pClipDoc->GetClipArea( nClipEndX, nClipEndY, sal_True ); + nClipEndX = nClipEndX + nClipStartX; + nClipEndY = nClipEndY + nClipStartY; // GetClipArea returns the difference + + ScRange aSource( nClipStartX, nClipStartY, nSourceTab, nClipEndX, nClipEndY, nSourceTab ); + sal_Bool bDone = pTabViewShell->DataPilotMove( aSource, pViewData->GetCurPos() ); + if ( !bDone ) + pTabViewShell->ErrorMessage( STR_ERR_DATAPILOT_INPUT ); + } + else + { + // normal paste + WaitObject aWait( pViewData->GetDialogParent() ); + if (!pOwnClip) + pTabViewShell->PasteFromSystem(); + else + { + ScDocument* pClipDoc = pOwnClip->GetDocument(); + sal_uInt16 nFlags = IDF_ALL; + if (pClipDoc->GetClipParam().isMultiRange()) + // For multi-range paste, we paste values by default. + nFlags &= ~IDF_FORMULA; + + pTabViewShell->PasteFromClip( nFlags, pClipDoc, + PASTE_NOFUNC, false, false, false, INS_NONE, IDF_NONE, + bShowDialog ); // allow warning dialog + } + } + pTabViewShell->CellContentChanged(); // => PasteFromSystem() ??? +} diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 305a68eda2aa..1e66a2b7f8c6 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -130,6 +130,7 @@ #include "cellsuno.hxx" #include "drawview.hxx" #include "dragdata.hxx" +#include "cliputil.hxx" #include <svx/sdrpagewindow.hxx> #include <svx/sdr/overlay/overlaymanager.hxx> @@ -3044,7 +3045,7 @@ void ScGridWindow::KeyInput(const KeyEvent& rKEvt) else if( rKeyCode.GetCode() == KEY_RETURN && pViewData->IsPasteMode() ) { ScTabViewShell* pTabViewShell = pViewData->GetViewShell(); - ScCellShell::PasteFromClipboard( pViewData, pTabViewShell, false ); + ScClipUtil::PasteFromClipboard( pViewData, pTabViewShell, false ); // Clear clipboard content. uno::Reference<datatransfer::clipboard::XClipboard> xSystemClipboard = |