Kaydet (Commit) 0da121bc authored tarafından Laurent Balland-Poirier's avatar Laurent Balland-Poirier Kaydeden (comit) Laurent BP

tdf#30456 Enable to empty or not merged cells

Insert options during MergeCells to empty hidden cells
Three options:
- Move contents to first cell (previous Yes)
- Keep contents in covered cells (previous No, default)
- Empty covered cells (new option)

To be done: link to the help system
https://gerrit.libreoffice.org/27467/

Change-Id: I98e85296591cce8ba789d282cead1f1010e5e2ce
Reviewed-on: https://gerrit.libreoffice.org/27463Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarLaurent BP <laurent.balland-poirier@laposte.net>
üst 6e44bb1b
......@@ -473,6 +473,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/miscdlgs/crnrdlg \
sc/source/ui/miscdlgs/datastreamdlg \
sc/source/ui/miscdlgs/highred \
sc/source/ui/miscdlgs/mergecellsdialog \
sc/source/ui/miscdlgs/optsolver \
sc/source/ui/miscdlgs/protectiondlg \
sc/source/ui/miscdlgs/redcom \
......
......@@ -141,6 +141,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/notebookbar \
sc/uiconfig/scalc/ui/notebookbar_groups \
sc/uiconfig/scalc/ui/managenamesdialog \
sc/uiconfig/scalc/ui/mergecellsdialog \
sc/uiconfig/scalc/ui/movecopysheet \
sc/uiconfig/scalc/ui/movingaveragedialog \
sc/uiconfig/scalc/ui/multipleoperationsdialog \
......
......@@ -1137,6 +1137,8 @@ public:
SC_DLLPUBLIC void DoMergeContents( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow );
SC_DLLPUBLIC void DoEmptyBlock( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow );
// without checking:
SC_DLLPUBLIC void DoMerge( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow, bool bDeleteCaptions = true );
......
......@@ -2000,6 +2000,19 @@ void ScDocument::DoMergeContents( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
SetString(nStartCol,nStartRow,nTab,aTotal.makeStringAndClear());
}
void ScDocument::DoEmptyBlock( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow )
{
SCCOL nCol;
SCROW nRow;
for (nRow=nStartRow; nRow<=nEndRow; nRow++)
for (nCol=nStartCol; nCol<=nEndCol; nCol++)
{ // empty block except first cell
if (nCol != nStartCol || nRow != nStartRow)
SetString(nCol,nRow,nTab,"");
}
}
void ScDocument::DoMerge( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow, bool bDeleteCaptions )
{
......
......@@ -4673,7 +4673,7 @@ bool ScDocFunc::FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir e
return true;
}
bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, bool bContents, bool bRecord, bool bApi )
bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, bool bContents, bool bRecord, bool bApi, bool bEmptyMergedCells /*=false*/ )
{
using ::std::set;
......@@ -4721,9 +4721,12 @@ bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, bool bContents, bo
for (set<SCTAB>::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
{
SCTAB nTab = *itr;
bool bNeedContents = bContents &&
( !rDoc.IsBlockEmpty( nTab, nStartCol,nStartRow+1, nStartCol,nEndRow, true ) ||
!rDoc.IsBlockEmpty( nTab, nStartCol+1,nStartRow, nEndCol,nEndRow, true ) );
bool bIsBlockEmpty = ( nStartRow == nEndRow )
? rDoc.IsBlockEmpty( nTab, nStartCol+1,nStartRow, nEndCol,nEndRow, true )
: rDoc.IsBlockEmpty( nTab, nStartCol,nStartRow+1, nStartCol,nEndRow, true ) &&
rDoc.IsBlockEmpty( nTab, nStartCol+1,nStartRow, nEndCol,nEndRow, true );
bool bNeedContents = bContents && !bIsBlockEmpty;
bool bNeedEmpty = bEmptyMergedCells && !bIsBlockEmpty && !bNeedContents; // if DoMergeContents then cells are emptyed
if (bRecord)
{
......@@ -4747,6 +4750,8 @@ bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, bool bContents, bo
if (bNeedContents)
rDoc.DoMergeContents( nTab, nStartCol,nStartRow, nEndCol,nEndRow );
else if ( bNeedEmpty )
rDoc.DoEmptyBlock( nTab, nStartCol,nStartRow, nEndCol,nEndRow );
rDoc.DoMerge( nTab, nStartCol,nStartRow, nEndCol,nEndRow );
if (rOption.mbCenter)
......
......@@ -188,7 +188,7 @@ public:
void ResizeMatrix( const ScRange& rOldRange, const ScAddress& rNewEnd );
bool MergeCells( const ScCellMergeOption& rOption, bool bContents,
bool bRecord, bool bApi );
bool bRecord, bool bApi, bool bEmptyMergedCells = false );
bool UnmergeCells( const ScRange& rRange, bool bRecord );
bool UnmergeCells( const ScCellMergeOption& rOption, bool bRecord );
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#ifndef INCLUDED_SC_SOURCE_UI_INC_MERGECELLSDIALOG_HXX
#define INCLUDED_SC_SOURCE_UI_INC_MERGECELLSDIALOG_HXX
#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/fixed.hxx>
enum ScMergeCellsOption
{
MoveContentHiddenCells,
KeepContentHiddenCells,
EmptyContentHiddenCells
};
class ScMergeCellsDialog : public ModalDialog
{
VclPtr<RadioButton> mpRBMoveContent;
VclPtr<RadioButton> mpRBKeepContent;
VclPtr<RadioButton> mpRBEmptyContent;
public:
ScMergeCellsDialog( vcl::Window * pParent );
virtual ~ScMergeCellsDialog();
virtual void dispose() override;
ScMergeCellsOption GetMergeCellsOption();
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#include "mergecellsdialog.hxx"
ScMergeCellsDialog::ScMergeCellsDialog( vcl::Window * pParent )
: ModalDialog( pParent, "MergeCellsDialog",
"modules/scalc/ui/mergecellsdialog.ui" )
{
get(mpRBMoveContent, "move-cells-radio");
get(mpRBKeepContent, "keep-content-radio");
get(mpRBEmptyContent, "empty-cells-radio");
mpRBKeepContent->Check();
}
ScMergeCellsDialog::~ScMergeCellsDialog()
{
disposeOnce();
}
void ScMergeCellsDialog::dispose()
{
mpRBMoveContent.disposeAndClear();
mpRBKeepContent.disposeAndClear();
mpRBEmptyContent.disposeAndClear();
ModalDialog::dispose();
}
ScMergeCellsOption ScMergeCellsDialog::GetMergeCellsOption()
{
if ( mpRBMoveContent->IsChecked() )
return MoveContentHiddenCells;
if ( mpRBKeepContent->IsChecked() )
return KeepContentHiddenCells;
if ( mpRBEmptyContent->IsChecked() )
return EmptyContentHiddenCells;
assert(!"Unknown selection for merge cells.");
return KeepContentHiddenCells; // default value
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -86,6 +86,7 @@
#include <rowheightcontext.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <comphelper/lok.hxx>
#include "mergecellsdialog.hxx"
#include <vector>
#include <memory>
......@@ -1081,19 +1082,32 @@ bool ScViewFunc::MergeCells( bool bApi, bool& rDoContents, bool bCenter )
}
bool bOk = true;
bool bEmptyMergedCells = false;
if (bAskDialog)
{
if (!bApi)
{
ScopedVclPtrInstance<MessBox> aBox( GetViewData().GetDialogParent(),
WinBits(WB_YES_NO_CANCEL | WB_DEF_NO),
ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ),
ScGlobal::GetRscString( STR_MERGE_NOTEMPTY ) );
VclPtr<ScMergeCellsDialog> aBox = VclPtr<ScMergeCellsDialog>::Create( GetViewData().GetDialogParent() );
sal_uInt16 nRetVal = aBox->Execute();
if ( nRetVal == RET_YES )
rDoContents = true;
if ( nRetVal == RET_OK )
{
switch ( aBox->GetMergeCellsOption() )
{
case MoveContentHiddenCells:
rDoContents = true;
break;
case KeepContentHiddenCells:
break; // keep default values
case EmptyContentHiddenCells:
bEmptyMergedCells = true;
break;
default:
assert(!"Unknown option for merge cells.");
break;
}
}
else if ( nRetVal == RET_CANCEL )
bOk = false;
}
......@@ -1101,7 +1115,7 @@ bool ScViewFunc::MergeCells( bool bApi, bool& rDoContents, bool bCenter )
if (bOk)
{
bOk = pDocSh->GetDocFunc().MergeCells( aMergeOption, rDoContents, true/*bRecord*/, bApi );
bOk = pDocSh->GetDocFunc().MergeCells( aMergeOption, rDoContents, true/*bRecord*/, bApi, bEmptyMergedCells );
if (bOk)
{
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<object class="GtkDialog" id="MergeCellsDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes">Merge Cells</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="ok">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="cancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="help">
<property name="label">gtk-help</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="secondary">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Some cells are not empty.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="move-cells-radio">
<property name="label" translatable="yes">Move the contents of the hidden cells into the first cell</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">keep-content-radio</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="keep-content-radio">
<property name="label" translatable="yes">Keep the contents of the hidden cells</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="empty-cells-radio">
<property name="label" translatable="yes">Empty the contents of the hidden cells</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">keep-content-radio</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
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