Kaydet (Commit) abccf9b8 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Moved PasteFromClipboard() from ScCellShell to ScClipUtil (new class).

üst ea280cef
...@@ -472,6 +472,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ ...@@ -472,6 +472,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/view/cellsh3 \ sc/source/ui/view/cellsh3 \
sc/source/ui/view/cellsh4 \ sc/source/ui/view/cellsh4 \
sc/source/ui/view/colrowba \ sc/source/ui/view/colrowba \
sc/source/ui/view/cliputil \
sc/source/ui/view/dbfunc \ sc/source/ui/view/dbfunc \
sc/source/ui/view/dbfunc2 \ sc/source/ui/view/dbfunc2 \
sc/source/ui/view/dbfunc3 \ sc/source/ui/view/dbfunc3 \
......
...@@ -108,8 +108,6 @@ public: ...@@ -108,8 +108,6 @@ public:
void ExecutePageSel( SfxRequest& rReq ); void ExecutePageSel( SfxRequest& rReq );
void ExecuteMove( SfxRequest& rReq ); void ExecuteMove( SfxRequest& rReq );
void GetStateCursor( SfxItemSet& rSet ); void GetStateCursor( SfxItemSet& rSet );
static void PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog );
}; };
#endif #endif
......
/*
* 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
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
#include "dpshttab.hxx" // ScSheetSourceDesc #include "dpshttab.hxx" // ScSheetSourceDesc
#include "dbdata.hxx" #include "dbdata.hxx"
#include "docsh.hxx" #include "docsh.hxx"
#include "cliputil.hxx"
#include "globstr.hrc" #include "globstr.hrc"
#include "scui_def.hxx" #include "scui_def.hxx"
...@@ -1169,7 +1170,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) ...@@ -1169,7 +1170,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
case SID_PASTE: case SID_PASTE:
{ {
PasteFromClipboard ( GetViewData(), pTabViewShell, true ); ScClipUtil::PasteFromClipboard ( GetViewData(), pTabViewShell, true );
rReq.Done(); rReq.Done();
} }
break; break;
...@@ -2433,54 +2434,4 @@ IMPL_LINK( ScCellShell, DialogClosed, AbstractScLinkedAreaDlg*, EMPTYARG ) ...@@ -2433,54 +2434,4 @@ IMPL_LINK( ScCellShell, DialogClosed, AbstractScLinkedAreaDlg*, EMPTYARG )
return 0; 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/*
* 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() ???
}
...@@ -130,6 +130,7 @@ ...@@ -130,6 +130,7 @@
#include "cellsuno.hxx" #include "cellsuno.hxx"
#include "drawview.hxx" #include "drawview.hxx"
#include "dragdata.hxx" #include "dragdata.hxx"
#include "cliputil.hxx"
#include <svx/sdrpagewindow.hxx> #include <svx/sdrpagewindow.hxx>
#include <svx/sdr/overlay/overlaymanager.hxx> #include <svx/sdr/overlay/overlaymanager.hxx>
...@@ -3044,7 +3045,7 @@ void ScGridWindow::KeyInput(const KeyEvent& rKEvt) ...@@ -3044,7 +3045,7 @@ void ScGridWindow::KeyInput(const KeyEvent& rKEvt)
else if( rKeyCode.GetCode() == KEY_RETURN && pViewData->IsPasteMode() ) else if( rKeyCode.GetCode() == KEY_RETURN && pViewData->IsPasteMode() )
{ {
ScTabViewShell* pTabViewShell = pViewData->GetViewShell(); ScTabViewShell* pTabViewShell = pViewData->GetViewShell();
ScCellShell::PasteFromClipboard( pViewData, pTabViewShell, false ); ScClipUtil::PasteFromClipboard( pViewData, pTabViewShell, false );
// Clear clipboard content. // Clear clipboard content.
uno::Reference<datatransfer::clipboard::XClipboard> xSystemClipboard = uno::Reference<datatransfer::clipboard::XClipboard> xSystemClipboard =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment