[Libreoffice-commits] core.git: sw/inc sw/source
Jim Raykowski (via logerrit)
logerrit at kemper.freedesktop.org
Sat Feb 1 19:25:15 UTC 2020
sw/inc/crsrsh.hxx | 4 -
sw/inc/strings.hrc | 4 -
sw/source/core/crsr/crstrvl.cxx | 7 +-
sw/source/uibase/inc/conttree.hxx | 2
sw/source/uibase/utlui/content.cxx | 113 +++++++++++++++++++++++++++----------
5 files changed, 96 insertions(+), 34 deletions(-)
New commits:
commit dfd027342e6b4107ebd3369de96ef2be3883724d
Author: Jim Raykowski <raykowj at gmail.com>
AuthorDate: Mon Jan 20 21:58:54 2020 -0900
Commit: Jim Raykowski <raykowj at gmail.com>
CommitDate: Sat Feb 1 20:24:37 2020 +0100
tdf#128814 Navigator content context menu related
Adds Select menu item to Chapter, Table, and Section content context
menus to make document selection of content. Document selection made for
collapsed chapters includes all sub chapters. Multi chapter selections
can be made from the headings content navigation view.
Reworks chapter delete to follow chapter selection behavior.
Adds accelerator keys to context menu items Delete and Chapter/Level
Promote/Demote.
Makes chapter delete undo/redo entries show as 'Delete chapter' or
'Delete chapters' depending on single or multiselected chapter delete.
Renames 'Select Chapter' and 'Delete Chapter' menu items to 'Select' and
'Delete'.
Reworks an assert so as not to assert fail when delete key is pressed on
content type entry
Change-Id: I68c725bbf5c6d561615cf10a0a75d4284b698ace
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87168
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
Reviewed-by: Jim Raykowski <raykowj at gmail.com>
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index daf784a4c86a..5c5b71b8b8b8 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -617,8 +617,8 @@ public:
SwOutlineNodes::size_type GetOutlinePos( sal_uInt8 nLevel = UCHAR_MAX );
// select the given range of OutlineNodes. Optionally including the children
// the sal_uInt16s are the positions in OutlineNodes-Array (EditShell)
- bool MakeOutlineSel( SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos,
- bool bWithChildren );
+ bool MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos,
+ bool bWithChildren, bool bKillPams = true );
bool GotoNextOutline();
bool GotoPrevOutline();
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 1193d78f9823..fbb64babe662 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -550,6 +550,8 @@
#define STR_GRAPHIC NC_("STR_GRAPHIC", "image")
#define STR_DRAWING_OBJECTS NC_("STR_DRAWING_OBJECTS", "drawing object(s)")
#define STR_TABLE_NAME NC_("STR_TABLE_NAME", "table: $1$2$3")
+#define STR_CHAPTER_NAME NC_("STR_CHAPTER_NAME", "chapter")
+#define STR_CHAPTERS_NAME NC_("STR_CHAPTERS_NAME", "chapters")
#define STR_PARAGRAPH_UNDO NC_("STR_PARAGRAPH_UNDO", "paragraph")
#define STR_PARAGRAPH_SIGN_UNDO NC_("STR_PARAGRAPH_SIGN_UNDO", "Paragraph sign")
#define STR_UNDO_FLYFRMFMT_TITLE NC_("STR_UNDO_FLYFRMFMT_TITLE", "Change object title of $1")
@@ -641,7 +643,7 @@
#define STR_OUTLINE_LEVEL NC_("STR_OUTLINE_LEVEL", "Outline Level")
#define STR_DRAGMODE NC_("STR_DRAGMODE", "Drag Mode")
#define STR_SEND_OUTLINE_TO_CLIPBOARD_ENTRY NC_("STR_SEND_OUTLINE_TO_CLIPBOARD_ENTRY", "Send Outline to Clipboard")
-#define STR_DELETE_CHAPTER NC_("STR_DELETE_CHAPTER", "Delete Chapter")
+#define STR_SELECT NC_("STR_SELECT", "Select")
#define STR_DEMOTE_CHAPTER NC_("STR_DEMOTE_CHAPTER", "Demote Chapter")
#define STR_PROMOTE_CHAPTER NC_("STR_PROMOTE_CHAPTER", "Promote Chapter")
#define STR_DEMOTE_LEVEL NC_("STR_DEMOTE_LEVEL", "Demote Level")
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index ebc9ab4306bd..fc5b606b539a 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1177,8 +1177,8 @@ SwOutlineNodes::size_type SwCursorShell::GetOutlinePos( sal_uInt8 nLevel )
return SwOutlineNodes::npos; // no more left
}
-bool SwCursorShell::MakeOutlineSel( SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos,
- bool bWithChildren )
+bool SwCursorShell::MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos,
+ bool bWithChildren , bool bKillPams)
{
const SwNodes& rNds = GetDoc()->GetNodes();
const SwOutlineNodes& rOutlNds = rNds.GetOutLineNds();
@@ -1215,7 +1215,8 @@ bool SwCursorShell::MakeOutlineSel( SwOutlineNodes::size_type nSttPos, SwOutline
if( nEndPos == rOutlNds.size() ) // no end found
pEndNd = &rNds.GetEndOfContent();
- KillPams();
+ if( bKillPams )
+ KillPams();
SwCursorSaveState aSaveState( *m_pCurrentCursor );
diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx
index 0c65e0acc407..89333bf5f228 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -171,6 +171,8 @@ class SwContentTree final
virtual VclPtr<PopupMenu> CreateContextMenu() override;
virtual void ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) override;
+ void DeleteOutlineSelections();
+
public:
SwContentTree(vcl::Window* pParent, SwNavigationPI* pDialog);
virtual ~SwContentTree() override;
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index 395ab7094672..1b9d2ee70525 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -1311,6 +1311,7 @@ VclPtr<PopupMenu> SwContentTree::CreateContextMenu()
}
else if(ContentTypeId::TABLE == nContentType)
{
+ pPop->InsertItem(805, SwResId(STR_SELECT));
pPop->InsertItem(403, m_aContextStrings[IDX_STR_EDIT_ENTRY]);
pPop->InsertItem(404, m_sUnprotTable);
bool bFull = false;
@@ -1325,16 +1326,27 @@ VclPtr<PopupMenu> SwContentTree::CreateContextMenu()
bOutline = true;
lcl_InsertExpandCollapseAllItem(this, pEntry, pPop);
pPop->InsertSeparator();
- pPop->InsertItem(501, SwResId(STR_DELETE_CHAPTER));
+ pPop->InsertItem(805, SwResId(STR_SELECT));
+ pPop->InsertItem(806, SwResId(STR_DELETE));
pPop->InsertItem(801, SwResId(STR_PROMOTE_CHAPTER));
pPop->InsertItem(802, SwResId(STR_DEMOTE_CHAPTER));
pPop->InsertItem(803, SwResId(STR_PROMOTE_LEVEL));
pPop->InsertItem(804, SwResId(STR_DEMOTE_LEVEL));
+ pPop->SetAccelKey(806, vcl::KeyCode(KEY_DELETE, false, false, false, false));
+ pPop->SetAccelKey(801, vcl::KeyCode(KEY_UP, false, true, false, false));
+ pPop->SetAccelKey(802, vcl::KeyCode(KEY_DOWN, false, true, false, false));
+ pPop->SetAccelKey(803, vcl::KeyCode(KEY_LEFT, false, true, false, false));
+ pPop->SetAccelKey(804, vcl::KeyCode(KEY_RIGHT, false, true, false, false));
}
else if(ContentTypeId::DRAWOBJECT == nContentType)
{
pPop->InsertItem(501, SwResId(STR_DELETE_ENTRY));
}
+ else if(ContentTypeId::REGION == nContentType)
+ {
+ pPop->InsertItem(805, SwResId(STR_SELECT));
+ pPop->InsertItem(403, m_aContextStrings[IDX_STR_EDIT_ENTRY]);
+ }
else
{
if(bEditable && bDeletable)
@@ -1353,6 +1365,7 @@ VclPtr<PopupMenu> SwContentTree::CreateContextMenu()
if(bRenamable)
pPop->InsertItem(502, m_sRename);
}
+ pPop->SetAccelKey(501, vcl::KeyCode(KEY_DELETE, false, false, false, false));
}
else if( pEntry )
{
@@ -3021,17 +3034,21 @@ void SwContentTree::KeyInput(const KeyEvent& rEvent)
else if(aCode.GetCode() == KEY_DELETE && 0 == aCode.GetModifier())
{
SvTreeListEntry* pEntry = FirstSelected();
- assert(!pEntry || dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
- if(pEntry &&
- lcl_IsContent(pEntry) &&
- static_cast<SwContent*>(pEntry->GetUserData())->GetParent()->IsDeletable() &&
- !m_pActiveShell->GetView().GetDocShell()->IsReadOnly())
+ if(pEntry && lcl_IsContent(pEntry))
{
- EditEntry(pEntry, EditEntryMode::DELETE);
- m_bViewHasChanged = true;
- GetParentWindow()->UpdateListBox();
- TimerUpdate(&m_aUpdTimer);
- GrabFocus();
+ assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
+ if (static_cast<SwContent*>(pEntry->GetUserData())->GetParent()->IsDeletable() &&
+ !m_pActiveShell->GetView().GetDocShell()->IsReadOnly())
+ {
+ if (static_cast<SwContentType*>(pEntry->GetUserData())->GetType() == ContentTypeId::OUTLINE)
+ DeleteOutlineSelections();
+ else
+ EditEntry(pEntry, EditEntryMode::DELETE);
+ m_bViewHasChanged = true;
+ GetParentWindow()->UpdateListBox();
+ TimerUpdate(&m_aUpdTimer);
+ GrabFocus();
+ }
}
}
//Make KEY_SPACE has same function as DoubleClick ,
@@ -3334,6 +3351,40 @@ void SwContentTree::ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry )
case 804:
ExecCommand("demote", true);
break;
+ case 805:
+ {
+ m_pActiveShell->KillPams();
+ m_pActiveShell->ClearMark();
+ m_pActiveShell->EnterAddMode();
+ SwContent* pCnt = static_cast<SwContent*>(pFirst->GetUserData());
+ const ContentTypeId eTypeId = pCnt->GetParent()->GetType();
+ if (eTypeId == ContentTypeId::OUTLINE)
+ {
+ for (SvTreeListEntry* pEntry = FirstSelected(); pEntry; pEntry = NextSelected(pEntry))
+ {
+ m_pActiveShell->SttSelect();
+ SwOutlineNodes::size_type nActPos = static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlinePos();
+ m_pActiveShell->MakeOutlineSel(nActPos, nActPos, !IsExpanded(pEntry), false); // select children if not expanded
+ m_pActiveShell->EndSelect();
+ }
+ }
+ else if (eTypeId == ContentTypeId::TABLE)
+ {
+ m_pActiveShell->GotoTable(pCnt->GetName());
+ m_pActiveShell->SelAll();
+ }
+ else if (eTypeId == ContentTypeId::REGION)
+ {
+ m_pActiveShell->GotoRegion(pCnt->GetName());
+ m_pActiveShell->Right(CRSR_SKIP_CHARS, false, 1, false );
+ m_pActiveShell->SelAll();
+ }
+ m_pActiveShell->LeaveAddMode();
+ }
+ break;
+ case 806:
+ DeleteOutlineSelections();
+ break;
//Display
default:
if(nSelectedPopupEntry > 300 && nSelectedPopupEntry < 400)
@@ -3361,6 +3412,29 @@ void SwContentTree::ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry )
GetParentWindow()->UpdateListBox();
}
+void SwContentTree::DeleteOutlineSelections()
+{
+ OUString sChapter = GetSelectionCount() > 1 ? SwResId(STR_CHAPTERS_NAME) : SwResId(STR_CHAPTER_NAME);
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, sChapter);
+ m_pActiveShell->StartAction();
+ m_pActiveShell->StartUndo(SwUndoId::DELETE, &aRewriter);
+ m_pActiveShell->EnterAddMode();
+ for (SvTreeListEntry* pEntry = FirstSelected(); pEntry; pEntry = NextSelected(pEntry))
+ {
+ m_pActiveShell->SttSelect();
+ SwOutlineNodes::size_type nActPos = static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlinePos();
+ m_pActiveShell->MakeOutlineSel(nActPos, nActPos, !IsExpanded(pEntry), false); // select children if not expanded
+ m_pActiveShell->EndSelect();
+ }
+ m_pActiveShell->LeaveAddMode();
+ m_pActiveShell->SetTextFormatColl(nullptr);
+ m_pActiveShell->Delete();
+ m_pActiveShell->ClearMark();
+ m_pActiveShell->EndUndo();
+ m_pActiveShell->EndAction();
+}
+
void SwContentTree::SetOutlineLevel(sal_uInt8 nSet)
{
m_nOutlineLevel = nSet;
@@ -3630,23 +3704,6 @@ void SwContentTree::EditEntry(SvTreeListEntry const * pEntry, EditEntryMode nMod
}
}
break;
- case ContentTypeId::OUTLINE :
- if(EditEntryMode::DELETE == nMode)
- {
- SwOutlineNodes::size_type nActPos = static_cast<SwOutlineContent*>(pCnt)->GetOutlinePos();
- SwWrtShell* pShell = m_pActiveShell;
- pShell->StartAllAction();
- pShell->StartUndo();
- pShell->Push();
- pShell->MakeOutlineSel(nActPos, nActPos, true);
- pShell->SetTextFormatColl(nullptr);
- pShell->Delete();
- pShell->ClearMark();
- pShell->Pop(SwCursorShell::PopMode::DeleteCurrent);
- pShell->EndUndo();
- pShell->EndAllAction();
- }
- break;
case ContentTypeId::DRAWOBJECT :
if(EditEntryMode::DELETE == nMode)
nSlot = SID_DELETE;
More information about the Libreoffice-commits
mailing list