tdf#116757 sw ChangesInMargin: add "Show Insertions in Margin"

layout mode to allow to show the original text inline,
i.e. only deletions, while insertions are showed in margin
(opposite of the Show Deletions in Margin mode).

Add a menu to the Show Changes icon on the
Changes toolbar with menu items for the 3 layout modes
"All Changes Inline", "Deletions in Margin" and
"Insertions in Margin" with the following behavior:

– Selecting a menu item turns on also the Show Changes mode
  to show the result immediately;

– Disabling Show Changes mode always show the final text, i.e.
  only insertions. Enabling Show Changes mode again shows the
  changes according to the last Show Changes mode selected in
  the menu.

– The new "Insertions in Margin" mode is intended to be only a
  run-time option, i.e. it's not possible to set it as a default
  Show Changes mode in Options, unlike "Deletions in Margin".

Change-Id: Ie4dc9fe3b4b201fa9976ef04877af649e242ab46
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109649
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
László Németh 2021-01-19 15:55:21 +01:00
parent ea610df368
commit 6aeeef8807
24 changed files with 306 additions and 14 deletions

View file

@ -509,6 +509,20 @@
<value>3dobjectsbar</value>
</prop>
</node>
<node oor:name="c41" oor:op="replace">
<prop oor:name="Command">
<value>.uno:ShowTrackedChangesMenu</value>
</prop>
<prop oor:name="Module">
<value/>
</prop>
<prop oor:name="Controller">
<value>com.sun.star.comp.framework.ResourceMenuController</value>
</prop>
<prop oor:name="Value">
<value>showtrackedchanges</value>
</prop>
</node>
<node oor:name="WindowListMenu" oor:op="replace">
<prop oor:name="Command">
<value>.uno:WindowList</value>
@ -709,6 +723,20 @@
<value>3dobjectsbar;.uno:Cube</value>
</prop>
</node>
<node oor:name="ShowTrackedChangesController" oor:op="replace">
<prop oor:name="Command">
<value>.uno:ShowTrackedChanges</value>
</prop>
<prop oor:name="Module">
<value/>
</prop>
<prop oor:name="Controller">
<value>com.sun.star.comp.framework.GenericPopupToolbarController</value>
</prop>
<prop oor:name="Value">
<value>.uno:ShowTrackedChangesMenu</value>
</prop>
</node>
<node oor:name="ConnectorToolBox" oor:op="replace">
<prop oor:name="Command">
<value>.uno:ConnectorToolbox</value>

View file

@ -6843,6 +6843,17 @@ bit 3 (0x8): #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8
<value>1</value>
</prop>
</node>
<node oor:name=".uno:ShowTrackedChangesMenu" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Change View</value>
</prop>
<prop oor:name="ContextLabel" oor:type="xs:string">
<value xml:lang="en-US">View</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
</prop>
</node>
<node oor:name=".uno:AVMediaPlayer" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Me~dia Player</value>

View file

@ -706,6 +706,30 @@
<value xml:lang="en-US">To ~Paragraph</value>
</prop>
</node>
<node oor:name=".uno:SetTrackedChangesInText" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Show All Changes Inline</value>
</prop>
<prop oor:name="ContextLabel" oor:type="xs:string">
<value xml:lang="en-US">All ~Changes Inline</value>
</prop>
</node>
<node oor:name=".uno:SetTrackedDeletionsInMargin" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Show Deletions In Margin</value>
</prop>
<prop oor:name="ContextLabel" oor:type="xs:string">
<value xml:lang="en-US">~Deletions In Margin</value>
</prop>
</node>
<node oor:name=".uno:SetTrackedInsertionsInMargin" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Show Insertions In Margin</value>
</prop>
<prop oor:name="ContextLabel" oor:type="xs:string">
<value xml:lang="en-US">~Insertions In Margin</value>
</prop>
</node>
<node oor:name=".uno:ToggleObjectLayer" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Change Position</value>

View file

@ -23,11 +23,13 @@ $(eval $(call gb_UIConfig_add_popupmenufiles,modules/sglobal,\
sw/uiconfig/sglobal/popupmenu/frame \
sw/uiconfig/sglobal/popupmenu/graphic \
sw/uiconfig/sglobal/popupmenu/insertfield \
sw/uiconfig/sglobal/popupmenu/showtrackedchanges \
sw/uiconfig/sglobal/popupmenu/media \
sw/uiconfig/sglobal/popupmenu/oleobject \
sw/uiconfig/sglobal/popupmenu/preview \
sw/uiconfig/sglobal/popupmenu/table \
sw/uiconfig/sglobal/popupmenu/text \
sw/uiconfig/swriter/popupmenu/showtrackedchanges \
))
$(eval $(call gb_UIConfig_add_statusbarfiles,modules/sglobal,\

View file

@ -26,6 +26,7 @@ $(eval $(call gb_UIConfig_add_popupmenufiles,modules/sweb,\
sw/uiconfig/sweb/popupmenu/source \
sw/uiconfig/sweb/popupmenu/table \
sw/uiconfig/sweb/popupmenu/text \
sw/uiconfig/swriter/popupmenu/showtrackedchanges \
))
$(eval $(call gb_UIConfig_add_statusbarfiles,modules/sweb,\

View file

@ -28,6 +28,7 @@ $(eval $(call gb_UIConfig_add_popupmenufiles,modules/swreport,\
sw/uiconfig/swreport/popupmenu/preview \
sw/uiconfig/swreport/popupmenu/table \
sw/uiconfig/swreport/popupmenu/text \
sw/uiconfig/swriter/popupmenu/showtrackedchanges \
))
$(eval $(call gb_UIConfig_add_statusbarfiles,modules/swreport,\

View file

@ -30,6 +30,7 @@ $(eval $(call gb_UIConfig_add_popupmenufiles,modules/swriter,\
sw/uiconfig/swriter/popupmenu/preview \
sw/uiconfig/swriter/popupmenu/table \
sw/uiconfig/swriter/popupmenu/text \
sw/uiconfig/swriter/popupmenu/showtrackedchanges \
))
$(eval $(call gb_UIConfig_add_statusbarfiles,modules/swriter,\

View file

@ -28,6 +28,7 @@ $(eval $(call gb_UIConfig_add_popupmenufiles,modules/swxform,\
sw/uiconfig/swxform/popupmenu/preview \
sw/uiconfig/swxform/popupmenu/table \
sw/uiconfig/swxform/popupmenu/text \
sw/uiconfig/swriter/popupmenu/showtrackedchanges \
))
$(eval $(call gb_UIConfig_add_statusbarfiles,modules/swxform,\

View file

@ -187,6 +187,10 @@
#define FN_SHOW_OUTLINECONTENTVISIBILITYBUTTON (FN_VIEW + 63) /* Show outline content visibility toggle button */
#define FN_TOGGLE_OUTLINE_CONTENT_VISIBILITY (FN_VIEW + 64)
#define FN_SHOW_CHANGES_IN_MARGIN (FN_VIEW + 65) /* Show tracked deletions in margin */
#define FN_SHOW_TRACKED_CHANGES_MENU (FN_VIEW + 66) /* Menu for the next layout modes */
#define FN_SET_TRACKED_CHANGES_IN_TEXT (FN_VIEW + 67) /* Show tracked deletions and insertions in text */
#define FN_SET_TRACKED_DELETIONS_IN_MARGIN (FN_VIEW + 68) /* Show final text (deletions in margin) */
#define FN_SET_TRACKED_INSERTIONS_IN_MARGIN (FN_VIEW + 69) /* Show original text (insertions in margin) */
// Region: Insert
#define FN_INSERT_BOOKMARK (FN_INSERT + 2 ) /* Bookmark */

View file

@ -66,10 +66,11 @@ enum class ViewOptFlags1 : sal_uInt64 {
ViewMetachars = 0x20000000,
Pageback = 0x40000000,
ShowOutlineContentVisibilityButton = 0x80000000,
ShowChangesInMargin = 0x100000000 //tracked deletions in margin
ShowChangesInMargin = 0x100000000, //tracked deletions in margin
ShowChangesInMargin2 = 0x200000000 //tracked insertions in margin
};
namespace o3tl {
template<> struct typed_flags<ViewOptFlags1> : is_typed_flags<ViewOptFlags1, 0x1ffdfcfff> {};
template<> struct typed_flags<ViewOptFlags1> : is_typed_flags<ViewOptFlags1, 0x3ffdfcfff> {};
}
enum class ViewOptCoreFlags2 {
@ -296,6 +297,12 @@ public:
void SetShowChangesInMargin( bool b )
{ SetCoreOption(b, ViewOptFlags1::ShowChangesInMargin); }
//show/hide tracked insertions in text
bool IsShowChangesInMargin2() const
{ return bool(m_nCoreOptions & ViewOptFlags1::ShowChangesInMargin2); }
void SetShowChangesInMargin2( bool b )
{ SetCoreOption(b, ViewOptFlags1::ShowChangesInMargin2); }
//show/hide interactive header/footer on top/bottom of pages
bool IsUseHeaderFooterMenu() const
{ return bool(m_nCoreOptions & ViewOptFlags1::UseHeaderFooterMenu ); }

View file

@ -477,6 +477,34 @@ interface BaseTextSelection
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
]
FN_SET_TRACKED_CHANGES_IN_TEXT
[
ExecMethod = Execute ;
StateMethod = GetState ;
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
]
FN_SET_TRACKED_DELETIONS_IN_MARGIN
[
ExecMethod = Execute ;
StateMethod = GetState ;
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
]
FN_SET_TRACKED_INSERTIONS_IN_MARGIN
[
ExecMethod = Execute ;
StateMethod = GetState ;
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
]
FN_SHOW_TRACKED_CHANGES_MENU
[
ExecMethod = Execute ;
StateMethod = GetState ;
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
]
FN_UPDATE_ALL_LINKS // status()
[
ExecMethod = Execute ;

View file

@ -7930,6 +7930,74 @@ SfxBoolItem ShowChangesInMargin FN_SHOW_CHANGES_IN_MARGIN
GroupId = SfxGroupId::View;
]
SfxVoidItem ShowTrackedChangesMenu FN_SHOW_TRACKED_CHANGES_MENU
()
[
AutoUpdate = FALSE,
FastCall = TRUE,
ReadOnlyDoc = FALSE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
AccelConfig = TRUE,
MenuConfig = TRUE,
ToolBoxConfig = TRUE,
GroupId = SfxGroupId::View;
]
SfxBoolItem SetTrackedChangesInText FN_SET_TRACKED_CHANGES_IN_TEXT
()
[
AutoUpdate = TRUE,
FastCall = TRUE,
ReadOnlyDoc = FALSE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
AccelConfig = TRUE,
MenuConfig = TRUE,
ToolBoxConfig = TRUE,
GroupId = SfxGroupId::View;
]
SfxBoolItem SetTrackedDeletionsInMargin FN_SET_TRACKED_DELETIONS_IN_MARGIN
()
[
AutoUpdate = TRUE,
FastCall = TRUE,
ReadOnlyDoc = FALSE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
AccelConfig = TRUE,
MenuConfig = TRUE,
ToolBoxConfig = TRUE,
GroupId = SfxGroupId::View;
]
SfxBoolItem SetTrackedInsertionsInMargin FN_SET_TRACKED_INSERTIONS_IN_MARGIN
()
[
AutoUpdate = TRUE,
FastCall = TRUE,
ReadOnlyDoc = FALSE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
AccelConfig = TRUE,
MenuConfig = TRUE,
ToolBoxConfig = TRUE,
GroupId = SfxGroupId::View;
]
SfxBoolItem UseHeaderFooterMenu FN_USE_HEADERFOOTERMENU
()
[

View file

@ -3295,11 +3295,18 @@ void DocumentRedlineManager::HideAll( bool bDeletion )
for (SwRedlineTable::size_type i = rTable.size(); i > 0; --i)
{
SwRangeRedline* pRedline = rTable[i-1];
if ( pRedline->GetType() == RedlineType::Delete &&
pRedline->IsVisible() )
if ( pRedline->GetType() == RedlineType::Delete )
{
pRedline->Hide(0, rTable.GetPos(pRedline), false);
pRedline->Hide(1, rTable.GetPos(pRedline), false);
if ( bDeletion && pRedline->IsVisible() )
{
pRedline->Hide(0, rTable.GetPos(pRedline), false);
pRedline->Hide(1, rTable.GetPos(pRedline), false);
}
else if ( !bDeletion && !pRedline->IsVisible() )
{
pRedline->Show(0, rTable.GetPos(pRedline), true);
pRedline->Show(1, rTable.GetPos(pRedline), true);
}
}
else if ( pRedline->GetType() == RedlineType::Insert )
{

View file

@ -200,7 +200,9 @@ void SwExtraPainter::PaintExtra( SwTwips nY, tools::Long nAsc, tools::Long nMax,
if ( pRedlineText )
{
m_pFnt->SetColor(NON_PRINTING_CHARACTER_COLOR);
m_pFnt->SetStrikeout( STRIKEOUT_SINGLE );
// don't strike out text in Insertions In Margin mode
if ( !m_pSh->GetViewOptions()->IsShowChangesInMargin2() )
m_pFnt->SetStrikeout( STRIKEOUT_SINGLE );
m_pFnt->SetSize( Size( 0, 200), m_pFnt->GetActual() );
}

View file

@ -984,15 +984,16 @@ bool SwRedlineItr::CheckLine(
case SwComparePosition::Inside:
{
bRet = true;
if (rRedlineText.isEmpty() && pRedline->GetType() == RedlineType::Delete)
// start to collect text of invisible redlines for ChangesInMargin layout
if (rRedlineText.isEmpty() && !pRedline->IsVisible())
{
rRedlineText = const_cast<SwRangeRedline*>(pRedline)->GetDescr(/*bSimplified=*/true);
pPrevRedline = pRedline;
isExtendText = true;
}
// join the text of the next short delete redlines in the same position
// join the text of the next invisible redlines in the same position
// i.e. characters deleted by pressing backspace or delete
else if (pPrevRedline && pRedline->GetType() == RedlineType::Delete &&
else if (pPrevRedline && !pRedline->IsVisible() &&
*pRedline->Start() == *pPrevRedline->Start() && *pRedline->End() == *pPrevRedline->End() )
{
OUString sExtendText(const_cast<SwRangeRedline*>(pRedline)->GetDescr(/*bSimplified=*/true));

View file

@ -2209,12 +2209,15 @@ void SwViewShell::ImplApplyViewOptions( const SwViewOption &rOpt )
{
bReformat = GetDoc()->ContainsHiddenChars();
}
if ( mpOpt->IsShowChangesInMargin() != rOpt.IsShowChangesInMargin() )
if ( mpOpt->IsShowChangesInMargin() != rOpt.IsShowChangesInMargin() ||
mpOpt->IsShowChangesInMargin2() != rOpt.IsShowChangesInMargin2() )
{
if (rOpt.IsShowChangesInMargin())
GetDoc()->GetDocumentRedlineManager().HideAll(/*bDeletion=*/true);
GetDoc()->GetDocumentRedlineManager().HideAll(
/*bDeletion=*/!rOpt.IsShowChangesInMargin2() );
else
GetDoc()->GetDocumentRedlineManager().ShowAll();
GetLayout()->SetHideRedlines( false );
}
// bReformat becomes true, if ...

View file

@ -1055,6 +1055,18 @@ void SwBaseShell::Execute(SfxRequest &rReq)
}
}
break;
case FN_SET_TRACKED_CHANGES_IN_TEXT:
case FN_SET_TRACKED_DELETIONS_IN_MARGIN:
case FN_SET_TRACKED_INSERTIONS_IN_MARGIN:
{
SwViewOption aViewOption = *rSh.GetViewOptions();
bool bAllInText = FN_SET_TRACKED_CHANGES_IN_TEXT == nSlot;
aViewOption.SetShowChangesInMargin( !bAllInText );
if ( !bAllInText )
aViewOption.SetShowChangesInMargin2( FN_SET_TRACKED_INSERTIONS_IN_MARGIN == nSlot );
rSh.ApplyViewOptions( aViewOption );
}
break;
case SID_CONTOUR_DLG:
{
sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId();

View file

@ -81,6 +81,7 @@
#include <printdata.hxx>
#include <IDocumentDeviceAccess.hxx>
#include <IDocumentRedlineAccess.hxx>
#include <DocumentRedlineManager.hxx>
#include <IDocumentUndoRedo.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentDrawModelAccess.hxx>
@ -730,9 +731,15 @@ void SwView::Execute(SfxRequest &rReq)
{
// tdf#125754 avoid recursive layout
// because all views share the layout, have to use AllAction
const bool bShow = static_cast<const SfxBoolItem*>(pItem)->GetValue();
m_pWrtShell->StartAllAction();
m_pWrtShell->GetLayout()->SetHideRedlines(
!static_cast<const SfxBoolItem*>(pItem)->GetValue());
// always show redline insertions in Hide Changes mode
if ( m_pWrtShell->GetViewOptions()->IsShowChangesInMargin() &&
m_pWrtShell->GetViewOptions()->IsShowChangesInMargin2() )
{
GetDocShell()->GetDoc()->GetDocumentRedlineManager().HideAll(/*bDeletion=*/!bShow);
}
m_pWrtShell->GetLayout()->SetHideRedlines( !bShow );
m_pWrtShell->EndAllAction();
if (m_pWrtShell->IsRedlineOn())
m_pWrtShell->SetInsMode();

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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/.
*
-->
<menu:menupopup xmlns:menu="http://openoffice.org/2001/menu">
<menu:menuitem menu:id=".uno:SetTrackedChangesInText" menu:style="radio"/>
<menu:menuitem menu:id=".uno:SetTrackedDeletionsInMargin" menu:style="radio"/>
<menu:menuitem menu:id=".uno:SetTrackedInsertionsInMargin" menu:style="radio"/>
</menu:menupopup>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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/.
*
-->
<menu:menupopup xmlns:menu="http://openoffice.org/2001/menu">
<menu:menuitem menu:id=".uno:SetTrackedChangesInText" menu:style="radio"/>
<menu:menuitem menu:id=".uno:SetTrackedDeletionsInMargin" menu:style="radio"/>
<menu:menuitem menu:id=".uno:SetTrackedInsertionsInMargin" menu:style="radio"/>
</menu:menupopup>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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/.
*
-->
<menu:menupopup xmlns:menu="http://openoffice.org/2001/menu">
<menu:menuitem menu:id=".uno:SetTrackedChangesInText" menu:style="radio"/>
<menu:menuitem menu:id=".uno:SetTrackedDeletionsInMargin" menu:style="radio"/>
<menu:menuitem menu:id=".uno:SetTrackedInsertionsInMargin" menu:style="radio"/>
</menu:menupopup>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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/.
*
-->
<menu:menupopup xmlns:menu="http://openoffice.org/2001/menu">
<menu:menuitem menu:id=".uno:SetTrackedChangesInText" menu:style="radio"/>
<menu:menuitem menu:id=".uno:SetTrackedDeletionsInMargin" menu:style="radio"/>
<menu:menuitem menu:id=".uno:SetTrackedInsertionsInMargin" menu:style="radio"/>
</menu:menupopup>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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/.
*
-->
<menu:menupopup xmlns:menu="http://openoffice.org/2001/menu">
<menu:menuitem menu:id=".uno:SetTrackedChangesInText" menu:style="radio"/>
<menu:menuitem menu:id=".uno:SetTrackedDeletionsInMargin" menu:style="radio"/>
<menu:menuitem menu:id=".uno:SetTrackedInsertionsInMargin" menu:style="radio"/>
</menu:menupopup>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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/.
*
-->
<menu:menupopup xmlns:menu="http://openoffice.org/2001/menu">
<menu:menuitem menu:id=".uno:SetTrackedChangesInText" menu:style="radio"/>
<menu:menuitem menu:id=".uno:SetTrackedDeletionsInMargin" menu:style="radio"/>
<menu:menuitem menu:id=".uno:SetTrackedInsertionsInMargin" menu:style="radio"/>
</menu:menupopup>