diff options
Diffstat (limited to 'sc/source/ui/view/cellsh1.cxx')
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 123 |
1 files changed, 52 insertions, 71 deletions
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index e5bb702402d8..f610e28b3fc5 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -104,6 +104,7 @@ #include "dpgroup.hxx" // for ScDPNumGroupInfo #include "spellparam.hxx" #include "postit.hxx" +#include "clipparam.hxx" #include "globstr.hrc" #include "scui_def.hxx" //CHINA001 @@ -1182,41 +1183,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) case SID_PASTE: { - Window* pWin = GetViewData()->GetActiveWin(); - ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin ); - ScDocument* pThisDoc = GetViewData()->GetDocument(); - ScDPObject* pDPObj = pThisDoc->GetDPAtCursor( GetViewData()->GetCurX(), - GetViewData()->GetCurY(), GetViewData()->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, TRUE ); - nClipEndX = nClipEndX + nClipStartX; - nClipEndY = nClipEndY + nClipStartY; // GetClipArea returns the difference - - ScRange aSource( nClipStartX, nClipStartY, nSourceTab, nClipEndX, nClipEndY, nSourceTab ); - BOOL bDone = pTabViewShell->DataPilotMove( aSource, GetViewData()->GetCurPos() ); - if ( !bDone ) - pTabViewShell->ErrorMessage( STR_ERR_DATAPILOT_INPUT ); - } - else - { - // normal paste - WaitObject aWait( GetViewData()->GetDialogParent() ); - pTabViewShell->PasteFromSystem(); - } + PasteFromClipboard ( GetViewData(), pTabViewShell, true ); rReq.Done(); } - pTabViewShell->CellContentChanged(); // => PasteFromSystem() ??? break; case SID_CLIPBOARD_FORMAT_ITEMS: @@ -1418,7 +1387,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) pTabViewShell->CellContentChanged(); // => PasteFromXXX ??? break; - case FID_PASTE_CONTENTS: + case SID_PASTE_SPECIAL: // Unterscheidung, ob eigene oder fremde Daten, // dadurch FID_INS_CELL_CONTENTS ueberfluessig { @@ -1516,43 +1485,6 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) pTabViewShell->CellContentChanged(); // => PasteFromSystem() ??? break; -#if 0 - // clipboard slots were used only for old basic: - - case SID_GET_CLPBRD_FORMAT_COUNT: - rReq.SetReturnValue( SfxUInt16Item( nSlot, Clipboard::GetFormatCount() ) ); - break; - - case SID_GET_CLPBRD_FORMAT_BY_IDX: - if (pReqArgs) - { - const SfxPoolItem* pItem; - if ( pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET && - pItem->ISA(SfxUInt16Item) ) - { - USHORT nCount = Clipboard::GetFormatCount(); - USHORT nPos = ((const SfxUInt16Item*)pItem)->GetValue(); // 1-based - if ( nPos && nPos <= nCount ) - rReq.SetReturnValue( SfxUInt32Item( nSlot, Clipboard::GetFormat(--nPos) ) ); - } - } - break; - - case SID_GET_CLPBRD_FORMAT_NAME: - if (pReqArgs) - { - const SfxPoolItem* pItem; - if ( pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET && - pItem->ISA(SfxUInt32Item) ) - { - String aName = Exchange::GetFormatName( - ((const SfxUInt32Item*)pItem)->GetValue() ); - rReq.SetReturnValue( SfxStringItem( nSlot, aName ) ); - } - } - break; -#endif - // // sonstiges // @@ -2226,3 +2158,52 @@ 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, TRUE ); + nClipEndX = nClipEndX + nClipStartX; + nClipEndY = nClipEndY + nClipStartY; // GetClipArea returns the difference + + ScRange aSource( nClipStartX, nClipStartY, nSourceTab, nClipEndX, nClipEndY, nSourceTab ); + 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() ??? +} |