Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1903

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/03/1903/1

fdo#56098 paste special shift options incorrect/incomplete

Change-Id: Ic84ec07f4e0963ad1759036f1d7cbfa295289375
---
M sc/source/ui/view/cellsh1.cxx
1 file changed, 62 insertions(+), 20 deletions(-)



diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index c22d91d..1d92f46 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1259,29 +1259,71 @@
                             pDlg->SetOtherDoc( bOtherDoc );
                             // if ChangeTrack MoveMode disable
                             pDlg->SetChangeTrack( pDoc->GetChangeTrack() != NULL );
-                            // cut/move references may disable shift
-                            // directions if source and destination ranges intersect
-                            if ( !bOtherDoc )
+                            // fdo#56098  disable shift if source and destination ranges intersect
+                            if ( !bOtherDoc  && pOwnClip )
                             {
-                                if ( pOwnClip && pOwnClip->GetDocument()->IsCutMode() )
+                                ScViewData* pData = GetViewData();
+                                if ( pData->GetMarkData().GetTableSelect( pData->GetTabNo() ) )
                                 {
-                                    ScViewData* pData = GetViewData();
-                                    if ( pData->GetMarkData().GetTableSelect(
-                                            pData->GetTabNo() ) )
+                                    SCCOL nStartX, nEndX, nClipStartX, nClipSizeX, nRangeSizeX;
+                                    SCROW nStartY, nEndY, nClipStartY, nClipSizeY, nRangeSizeY;
+                                    SCTAB nStartTab, nEndTab;
+                                    pOwnClip->GetDocument()->GetClipStart( nClipStartX, 
nClipStartY );
+                                    pOwnClip->GetDocument()->GetClipArea( nClipSizeX, nClipSizeY, 
sal_True );
+
+                                    if ( !( pData->GetSimpleArea( nStartX, nStartY, nStartTab, 
nEndX, nEndY, nEndTab ) == SC_MARK_SIMPLE && nStartTab == nEndTab ) )
                                     {
-                                        SCCOL nPosX = pData->GetCurX();
-                                        SCROW nPosY = pData->GetCurY();
-                                        SCCOL nClipSizeX;
-                                        SCROW  nClipSizeY;
-                                        // for CutMode, filtered rows can always be included
-                                        pOwnClip->GetDocument()->GetClipArea( nClipSizeX, 
nClipSizeY, sal_True );
-                                        int nDisableShift = 0;
-                                        if ( nPosX + 2 * nClipSizeX + 1 > MAXCOL )  // fdo#56098
-                                             nDisableShift |= SC_CELL_SHIFT_DISABLE_RIGHT;
-                                        if ( nPosY + 2 * nClipSizeY + 1 > MAXROW )  // fdo#56098
-                                            nDisableShift |= SC_CELL_SHIFT_DISABLE_DOWN;
-                                        if ( nDisableShift )
-                                            pDlg->SetCellShiftDisabled( nDisableShift );
+                                        // the destination is not a simple range, so assume the 
destination as the current cell
+                                        nStartX = nEndX = pData->GetCurX();
+                                        nStartY = nEndY = pData->GetCurY();
+                                    }
+                                    // we now have clip- and range dimensions
+                                    // the size of the destination area is the larger of the two
+                                    nRangeSizeX = nClipSizeX >= nEndX - nStartX ? nClipSizeX : 
nEndX - nStartX;
+                                    nRangeSizeY = nClipSizeY >= nEndY - nStartY ? nClipSizeY : 
nEndY - nStartY;
+                                    if ( nStartX + nRangeSizeX >= nClipStartX &&
+                                         nStartX <= nClipStartX + nRangeSizeX &&
+                                         nStartY + nRangeSizeY >= nClipStartY &&
+                                         nStartY <= nClipStartY + nRangeSizeY )
+                                        pDlg->SetCellShiftDisabled( SC_CELL_SHIFT_DISABLE_DOWN | 
SC_CELL_SHIFT_DISABLE_RIGHT );
+                                    else
+                                    {
+                                        //no conflict with intersecting ranges,
+                                        //check if paste plus shift will fit on sheet
+                                        //and disable shift-option if so
+                                        int nDisableShiftX = 0;
+                                        int nDisableShiftY = 0;
+                                        //check if horizontal shift will fit
+                                        for ( SCROW nRow = nStartY;
+                                              !nDisableShiftX && nRow <= nStartY + nRangeSizeY;
+                                              nRow++ )
+                                        {
+                                            for ( SCCOL nCol = MAXCOL;
+                                                  !nDisableShiftX && nCol >= MAXCOL - nRangeSizeX;
+                                                  nCol-- )
+                                            {
+                                                ScAddress aAddress( nCol, nRow, nStartTab );
+                                                if ( pData->GetDocument()->GetCellType ( aAddress 
) != CELLTYPE_NONE )
+                                                    nDisableShiftX = SC_CELL_SHIFT_DISABLE_RIGHT;
+                                            }
+                                        }
+
+                                        //check if vertical shift will fit
+                                        for ( SCCOL nCol = nStartX;
+                                              !nDisableShiftY && nCol <= nStartX + nRangeSizeX;
+                                              nCol++ )
+                                        {
+                                            for ( SCROW nRow = MAXROW;
+                                                  !nDisableShiftY && nRow >= MAXROW - nRangeSizeY;
+                                                  nRow-- )
+                                            {
+                                                ScAddress aAddress( nCol, nRow, nStartTab );
+                                                if ( pData->GetDocument()->GetCellType ( aAddress 
) != CELLTYPE_NONE )
+                                                    nDisableShiftY = SC_CELL_SHIFT_DISABLE_DOWN;
+                                            }
+                                        }
+                                        if ( nDisableShiftX || nDisableShiftY )
+                                            pDlg->SetCellShiftDisabled( nDisableShiftX | 
nDisableShiftY );
                                     }
                                 }
                             }

-- 
To view, visit https://gerrit.libreoffice.org/1903
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic84ec07f4e0963ad1759036f1d7cbfa295289375
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Winfried Donkers <osc@dci-electronics.nl>

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.