summaryrefslogtreecommitdiff
path: root/sw/source/uibase/shells/basesh.cxx
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2019-12-11 15:38:05 +0100
committerLászló Németh <nemeth@numbertext.org>2019-12-14 17:58:54 +0100
commit1e278d1d0cfb1d5375195aa764739f00633f21e8 (patch)
tree13e94f15370305dec09a0d209b71a863e60f8eba /sw/source/uibase/shells/basesh.cxx
parent9f9a0557c16a6b274ba60f5efc983978d1a88762 (diff)
tdf#37156 Writer menu: Paste as Nested table
Paste table data in Writer tables overwrites the content of the existing cells, when the cursor is there in an empty cell or at the beginning of the first paragraph of a table cell. Using the new Paste Special option "As Nested Table" of table popup (local) menu and Edit->Paste Special, (based on the new .uno:PasteNestedTable command), clipboard content (including native tables or tables copied from Calc or other spreadsheets) are inserted as nested tables in empty cells and at cell starting cursor positions. Change-Id: I32807200883651e492ae280efce7bf9806f22283 Reviewed-on: https://gerrit.libreoffice.org/85094 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source/uibase/shells/basesh.cxx')
-rw-r--r--sw/source/uibase/shells/basesh.cxx17
1 files changed, 16 insertions, 1 deletions
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index ff9598c84b37..c9e5a8ec15bf 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -258,6 +258,7 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
SwWrtShell &rSh = GetShell();
sal_uInt16 nId = rReq.GetSlot();
bool bIgnore = false;
+ bool bPasteNestedTable = false;
switch( nId )
{
case SID_CUT:
@@ -280,6 +281,9 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
}
return;
+ case FN_PASTE_NESTED_TABLE:
+ bPasteNestedTable = true;
+ [[fallthrough]];
case SID_PASTE:
{
TransferableDataHelper aDataHelper(
@@ -299,7 +303,7 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
const SfxBoolItem* pIgnoreComments = rReq.GetArg<SfxBoolItem>(FN_PARAM_2);
if (pIgnoreComments)
bIgnoreComments = pIgnoreComments->GetValue();
- SwTransferable::Paste(rSh, aDataHelper, nAnchorType, bIgnoreComments);
+ SwTransferable::Paste(rSh, aDataHelper, nAnchorType, bIgnoreComments, bPasteNestedTable);
if( rSh.IsFrameSelected() || rSh.IsObjSelected() )
rSh.EnterSelFrameMode();
@@ -466,6 +470,17 @@ void SwBaseShell::StateClpbrd(SfxItemSet &rSet)
rSet.DisableItem( nWhich );
break;
+ case FN_PASTE_NESTED_TABLE:
+ if( !rSh.IsCursorInTable()
+ || !GetView().IsPasteSpecialAllowed()
+ || rSh.CursorInsideInputField()
+ // disable if not a native Writer table and not a spreadsheet format
+ || !GetView().IsPasteSpreadsheet(rSh.GetTableCopied()) )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
case SID_PASTE:
if( !GetView().IsPasteAllowed() )
{