diff options
author | Jim Raykowski <raykowj@gmail.com> | 2020-07-27 19:42:17 -0800 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-07-30 12:04:25 +0200 |
commit | 5ab17ad2696aeb8acfc21cd2442908b785a53e86 (patch) | |
tree | b30f318d261b698b9a237cb1680bff5df3c81df8 /sw | |
parent | 835cd06a047717dfe5e0f117959f3c042e13b21b (diff) |
tdf#38093 Writer outline folding - ctrl + click toggle visibility
Patch 3/6 that breaks down https://gerrit.libreoffice.org/c/core/+/96672
Adds ctrl + mouse-click to toggle outline content visibility. Right
click includes sub levels. Outline content visibility of sub levels is
set to that of the clicked outline content toggled visibility.
Change-Id: I428b3c683bec48bec147385dcdb1708e1f28d791
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99654
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/strings.hrc | 2 | ||||
-rw-r--r-- | sw/source/uibase/docvw/edtwin.cxx | 113 |
2 files changed, 92 insertions, 23 deletions
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index 86733bf6bb3a..20d45f5cc19b 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -645,6 +645,8 @@ #define STR_OUTLINE_TRACKING_OFF NC_("STR_OUTLINE_TRACKING_OFF", "Off") #define STR_OUTLINE_CONTENT_TOGGLE_VISIBILITY NC_("STR_OUTLINE_CONTENT_TOGGLE_VISIBILITY", "Toggle Outline Content Visibility") #define STR_OUTLINE_CONTENT_TOGGLE_VISIBILITY_EXT NC_("STR_OUTLINE_CONTENT_TOGGLE_VISIBILITY_EXT", "hold Ctrl or right-click to include sub levels") +#define STR_ClICK_OUTLINE_CONTENT_TOGGLE_VISIBILITY NC_("STR_CLICK_OUTLINE_CONTENT_TOGGLE_VISIBILITY", "Click to Toggle Outline Content Visibility") +#define STR_CLICK_OUTLINE_CONTENT_TOGGLE_VISIBILITY_EXT NC_("STR_CLICK_OUTLINE_CONTENT_TOGGLE_VISIBILITY_EXT", "right-click to include sub levels") #define STR_EXPANDALL NC_("STR_EXPANDALL", "Expand All") #define STR_COLLAPSEALL NC_("STR_COLLAPSEALL", "Collapse All") diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 8f0751024e2d..b2d43874a13d 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -143,6 +143,7 @@ #include <ndtxt.hxx> #include <cntfrm.hxx> #include <txtfrm.hxx> +#include <strings.hrc> using namespace sw::mark; using namespace ::com::sun::star; @@ -332,6 +333,7 @@ static bool IsDrawObjSelectable( const SwWrtShell& rSh, const Point& rPt ) */ void SwEditWin::UpdatePointer(const Point &rLPt, sal_uInt16 nModifier ) { + SetQuickHelpText(OUString()); SwWrtShell &rSh = m_rView.GetWrtShell(); if( m_pApplyTempl ) { @@ -556,13 +558,37 @@ void SwEditWin::UpdatePointer(const Point &rLPt, sal_uInt16 nModifier ) IsAttrAtPos::ClickField | IsAttrAtPos::InetAttr | IsAttrAtPos::Ftn | - IsAttrAtPos::SmartTag ); + IsAttrAtPos::SmartTag | + IsAttrAtPos::Outline); if( rSh.GetContentAtPos( rLPt, aSwContentAtPos) ) { + if (IsAttrAtPos::Outline == aSwContentAtPos.eContentAtPos) + { + if (nModifier == KEY_MOD1 + && GetView().GetWrtShell().GetViewOptions()->IsShowOutlineContentVisibilityButton()) + { + eStyle = PointerStyle::RefHand; + // set quick help + if(aSwContentAtPos.aFnd.pNode && aSwContentAtPos.aFnd.pNode->IsTextNode()) + { + const SwNodes& rNds = GetView().GetWrtShell().GetDoc()->GetNodes(); + SwOutlineNodes::size_type nPos; + rNds.GetOutLineNds().Seek_Entry(aSwContentAtPos.aFnd.pNode->GetTextNode(), &nPos); + SwOutlineNodes::size_type nOutlineNodesCount + = rSh.getIDocumentOutlineNodesAccess()->getOutlineNodesCount(); + int nLevel = rSh.getIDocumentOutlineNodesAccess()->getOutlineLevel(nPos); + OUString sQuickHelp(SwResId(STR_ClICK_OUTLINE_CONTENT_TOGGLE_VISIBILITY)); + if (nPos + 1 < nOutlineNodesCount + && rSh.getIDocumentOutlineNodesAccess()->getOutlineLevel(nPos + 1) > nLevel) + sQuickHelp += " (" + SwResId(STR_CLICK_OUTLINE_CONTENT_TOGGLE_VISIBILITY_EXT) + ")"; + SetQuickHelpText(sQuickHelp); + } + } + } // Is edit inline input field - if (IsAttrAtPos::Field == aSwContentAtPos.eContentAtPos - && aSwContentAtPos.pFndTextAttr != nullptr - && aSwContentAtPos.pFndTextAttr->Which() == RES_TXTATR_INPUTFIELD) + else if (IsAttrAtPos::Field == aSwContentAtPos.eContentAtPos + && aSwContentAtPos.pFndTextAttr != nullptr + && aSwContentAtPos.pFndTextAttr->Which() == RES_TXTATR_INPUTFIELD) { const SwField *pCursorField = rSh.CursorInsideInputField() ? rSh.GetCurField( true ) : nullptr; if (!(pCursorField && pCursorField == aSwContentAtPos.pFndTextAttr->GetFormatField().GetField())) @@ -3490,6 +3516,20 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) case KEY_MOD1: if ( !bExecDrawTextLink ) { + if (rSh.GetViewOptions()->IsShowOutlineContentVisibilityButton()) + { + SwContentAtPos aContentAtPos(IsAttrAtPos::Outline); + if(rSh.GetContentAtPos(aDocPos, aContentAtPos)) + { + // move cursor to outline para start and toggle outline content visibility + MoveCursor(rSh, aDocPos, bOnlyText, bLockView); + SwPaM aPam(*rSh.GetCurrentShellCursor().GetPoint()); + SwOutlineNodes::size_type nPos; + if (rSh.GetNodes().GetOutLineNds().Seek_Entry( &aPam.GetPoint()->nNode.GetNode(), &nPos)) + rSh.ToggleOutlineContentVisibility(nPos); + return; + } + } if ( !m_bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) && !lcl_urlOverBackground( rSh, aDocPos ) ) { m_rView.NoRotate(); @@ -3721,28 +3761,55 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) } } } - else if ( MOUSE_RIGHT == rMEvt.GetButtons() && !rMEvt.GetModifier() - && static_cast< sal_uInt8 >(rMEvt.GetClicks() % 4) == 1 - && !rSh.TestCurrPam( aDocPos ) ) + else if (MOUSE_RIGHT == rMEvt.GetButtons()) { - SwContentAtPos aFieldAtPos(IsAttrAtPos::Field); - - // Are we clicking on a field? - if (g_bValidCursorPos - && rSh.GetContentAtPos(aDocPos, aFieldAtPos) - && aFieldAtPos.pFndTextAttr != nullptr - && aFieldAtPos.pFndTextAttr->Which() == RES_TXTATR_INPUTFIELD - && (!pCursorField || pCursorField != aFieldAtPos.pFndTextAttr->GetFormatField().GetField())) + if (rSh.GetViewOptions()->IsShowOutlineContentVisibilityButton() && rMEvt.GetModifier() == KEY_MOD1) { - // Move the cursor - MoveCursor( rSh, aDocPos, rSh.IsObjSelectable( aDocPos ), m_bWasShdwCursor ); - bCallBase = false; + SwContentAtPos aContentAtPos(IsAttrAtPos::Outline); + if(rSh.GetContentAtPos(aDocPos, aContentAtPos)) + { + // move cursor to para start toggle outline content visibility and set the same visibility for subs + MoveCursor(rSh, aDocPos, false, true); + SwPaM aPam(*rSh.GetCurrentShellCursor().GetPoint()); + SwOutlineNodes::size_type nPos; + if (rSh.GetNodes().GetOutLineNds().Seek_Entry(&aPam.GetPoint()->nNode.GetNode(), &nPos)) + { + SwOutlineNodes::size_type nOutlineNodesCount = rSh.getIDocumentOutlineNodesAccess()->getOutlineNodesCount(); + int nLevel = rSh.getIDocumentOutlineNodesAccess()->getOutlineLevel(nPos); + bool bFold = rSh.IsOutlineContentFolded(nPos); + do + { + if (rSh.IsOutlineContentFolded(nPos) == bFold) + rSh.ToggleOutlineContentVisibility(nPos); + } while (++nPos < nOutlineNodesCount + && rSh.getIDocumentOutlineNodesAccess()->getOutlineLevel(nPos) > nLevel); + return; + } + } + } + else if ( !rMEvt.GetModifier() + && static_cast< sal_uInt8 >(rMEvt.GetClicks() % 4) == 1 + && !rSh.TestCurrPam( aDocPos ) ) + { + SwContentAtPos aFieldAtPos(IsAttrAtPos::Field); + + // Are we clicking on a field? + if (g_bValidCursorPos + && rSh.GetContentAtPos(aDocPos, aFieldAtPos) + && aFieldAtPos.pFndTextAttr != nullptr + && aFieldAtPos.pFndTextAttr->Which() == RES_TXTATR_INPUTFIELD + && (!pCursorField || pCursorField != aFieldAtPos.pFndTextAttr->GetFormatField().GetField())) + { + // Move the cursor + MoveCursor( rSh, aDocPos, rSh.IsObjSelectable( aDocPos ), m_bWasShdwCursor ); + bCallBase = false; - // select content of Input Field, but exclude CH_TXT_ATR_INPUTFIELDSTART - // and CH_TXT_ATR_INPUTFIELDEND - rSh.SttSelect(); - rSh.SelectText( aFieldAtPos.pFndTextAttr->GetStart() + 1, - *(aFieldAtPos.pFndTextAttr->End()) - 1 ); + // select content of Input Field, but exclude CH_TXT_ATR_INPUTFIELDSTART + // and CH_TXT_ATR_INPUTFIELDEND + rSh.SttSelect(); + rSh.SelectText( aFieldAtPos.pFndTextAttr->GetStart() + 1, + *(aFieldAtPos.pFndTextAttr->End()) - 1 ); + } } } |