summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Francis <dennisfrancis.in@gmail.com>2015-11-28 22:47:02 +0530
committerEike Rathke <erack@redhat.com>2015-12-12 21:09:51 +0000
commitd4c22dbb1c9d71bb83c218d339df83e8727e469c (patch)
treeaae43d117ba27a9c12a6c1f17f5aff563375a251
parent8d57f2fb953f031c48892366ce52f6d4fcb9c025 (diff)
tdf#73006 : Put results in correct cells after Text to Columns
Change-Id: I7a1653424edd93b2de0597ce8a94aa5f4fa85622 Reviewed-on: https://gerrit.libreoffice.org/20258 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/source/ui/view/cellsh2.cxx31
1 files changed, 24 insertions, 7 deletions
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index c2c19baa525e..354ae1f02c11 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -70,7 +70,7 @@
using namespace com::sun::star;
-static bool lcl_GetTextToColumnsRange( const ScViewData* pData, ScRange& rRange )
+static bool lcl_GetTextToColumnsRange( const ScViewData* pData, ScRange& rRange, bool bDoEmptyCheckOnly )
{
OSL_ENSURE( pData, "lcl_GetTextToColumnsRange: pData is null!" );
@@ -100,11 +100,28 @@ static bool lcl_GetTextToColumnsRange( const ScViewData* pData, ScRange& rRange
const ScDocument* pDoc = pData->GetDocument();
OSL_ENSURE( pDoc, "lcl_GetTextToColumnsRange: pDoc is null!" );
- if ( bRet && pDoc->IsBlockEmpty( rRange.aStart.Tab(), rRange.aStart.Col(),
- rRange.aStart.Row(), rRange.aEnd.Col(),
- rRange.aEnd.Row() ) )
+ if ( bDoEmptyCheckOnly )
{
- bRet = false;
+ if ( bRet && pDoc->IsBlockEmpty( rRange.aStart.Tab(), rRange.aStart.Col(),
+ rRange.aStart.Row(), rRange.aEnd.Col(),
+ rRange.aEnd.Row() ) )
+ {
+ bRet = false;
+ }
+ }
+ else if ( bRet )
+ {
+ rRange.PutInOrder();
+ SCCOL nStartCol = rRange.aStart.Col(), nEndCol = rRange.aEnd.Col();
+ SCROW nStartRow = rRange.aStart.Row(), nEndRow = rRange.aEnd.Row();
+ bool bShrunk = false;
+ pDoc->ShrinkToUsedDataArea( bShrunk, rRange.aStart.Tab(), nStartCol, nStartRow,
+ nEndCol, nEndRow, false, false, true );
+ if ( bShrunk )
+ {
+ rRange.aStart.SetRow( nStartRow );
+ rRange.aEnd.SetRow( nEndRow );
+ }
}
return bRet;
@@ -957,7 +974,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
OSL_ENSURE( pData, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pData is null!" );
ScRange aRange;
- if ( lcl_GetTextToColumnsRange( pData, aRange ) )
+ if ( lcl_GetTextToColumnsRange( pData, aRange, false ) )
{
ScDocument* pDoc = pData->GetDocument();
OSL_ENSURE( pDoc, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDoc is null!" );
@@ -1195,7 +1212,7 @@ void ScCellShell::GetDBState( SfxItemSet& rSet )
case SID_TEXT_TO_COLUMNS:
{
ScRange aRange;
- if ( !lcl_GetTextToColumnsRange( pData, aRange ) )
+ if ( !lcl_GetTextToColumnsRange( pData, aRange, true ) )
{
rSet.DisableItem( nWhich );
}