diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-09-12 12:16:16 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-09-12 13:22:08 -0400 |
commit | e9a73d9a10d1a0c4a6e0c9280b0d19c8bb8e7c86 (patch) | |
tree | 6200c3c3a6ac8ce459537fd1aea991a3c0764dfe /sc | |
parent | Moved the code that checks destination ranges to ScClipUtil. (diff) | |
download | core-e9a73d9a10d1a0c4a6e0c9280b0d19c8bb8e7c86.tar.gz core-e9a73d9a10d1a0c4a6e0c9280b0d19c8bb8e7c86.zip |
Modified GetClipState in ScCellShell to allow multiple dest ranges.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/view/cellsh.cxx | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index b2fe2800e752..531ac702250d 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -65,6 +65,8 @@ #include "scabstdlg.hxx" #include "dociter.hxx" #include "postit.hxx" +#include "cliputil.hxx" +#include "clipparam.hxx" //------------------------------------------------------------------ @@ -444,6 +446,48 @@ IMPL_LINK( ScCellShell, ClipboardChanged, TransferableDataHelper*, pDataHelper ) return 0; } +namespace { + +bool checkDestRanges(ScViewData& rViewData) +{ + ScRange aDummy; + ScMarkType eMarkType = rViewData.GetSimpleArea( aDummy); + if (eMarkType != SC_MARK_MULTI) + { + // Single destination range. + if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED) + return false; + } + + // Multiple destination ranges. + + ScDocument* pDoc = rViewData.GetDocument(); + Window* pWin = rViewData.GetActiveWin(); + if (!pWin) + return false; + + ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(pWin); + if (!pOwnClip) + // If it's not a Calc document, we won't be picky. + return true; + + ScDocument* pClipDoc = pOwnClip->GetDocument(); + if (!pClipDoc) + return false; + + ScRange aSrcRange = pClipDoc->GetClipParam().getWholeRange(); + SCROW nRowSize = aSrcRange.aEnd.Row() - aSrcRange.aStart.Row() + 1; + SCCOL nColSize = aSrcRange.aEnd.Col() - aSrcRange.aStart.Col() + 1; + + ScMarkData aMark = rViewData.GetMarkData(); + ScRangeList aRanges; + aMark.MarkToSimple(); + aMark.FillRangeListWithMarks(&aRanges, false); + + return ScClipUtil::CheckDestRanges(pDoc, nColSize, nRowSize, aMark, aRanges); +} + +} void ScCellShell::GetClipState( SfxItemSet& rSet ) { @@ -464,7 +508,7 @@ void ScCellShell::GetClipState( SfxItemSet& rSet ) bPastePossible = lcl_IsCellPastePossible( aDataHelper ); } - sal_Bool bDisable = !bPastePossible; + bool bDisable = !bPastePossible; // Zellschutz / Multiselektion @@ -475,11 +519,10 @@ void ScCellShell::GetClipState( SfxItemSet& rSet ) SCTAB nTab = GetViewData()->GetTabNo(); ScDocument* pDoc = GetViewData()->GetDocShell()->GetDocument(); if (!pDoc->IsBlockEditable( nTab, nCol,nRow, nCol,nRow )) - bDisable = sal_True; - ScRange aDummy; - ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy); - if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED) - bDisable = sal_True; + bDisable = true; + + if (!checkDestRanges(*GetViewData())) + bDisable = true; } if (bDisable) |