officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu | 19 ++ officecfg/registry/data/org/openoffice/Office/UI/WriterFormWindowState.xcu | 17 ++ officecfg/registry/data/org/openoffice/Office/UI/WriterGlobalWindowState.xcu | 11 + officecfg/registry/data/org/openoffice/Office/UI/WriterReportWindowState.xcu | 17 ++ officecfg/registry/data/org/openoffice/Office/UI/WriterWebWindowState.xcu | 11 + officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu | 11 + sw/UIConfig_swriter.mk | 1 sw/inc/docary.hxx | 10 + sw/inc/editsh.hxx | 2 sw/source/core/doc/docredln.cxx | 65 ++++------ sw/source/core/edit/edredln.cxx | 18 ++ sw/source/ui/uiview/view2.cxx | 31 +++- sw/source/ui/uiview/viewstat.cxx | 37 +++++ sw/uiconfig/swriter/toolbar/changes.xml | 33 +++++ 14 files changed, 233 insertions(+), 50 deletions(-)
New commits: commit 7d6c40d7a7df2051cbc831b8c118a2313d37cc17 Author: LuboÅ¡ LuÅák <[email protected]> Date: Mon Apr 28 18:03:49 2014 +0200 allow accepting/rejecting changes in a selection (bnc#874790) More convenient than handling them one by one. diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index 6b9636e..dc04113 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -38,6 +38,7 @@ class SwUnoCrsr; class SwOLENode; class SwTxtFmtColl; class SwGrfFmtColl; +class SwPosition; namespace com { namespace sun { namespace star { namespace i18n { struct ForbiddenCharacters; ///< comes from the I18N UNO interface @@ -172,6 +173,15 @@ public: sal_uInt16 FindPrevSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos, sal_uInt16 nLookahead = 20 ) const; + /** + Find the redline at the given position. + + @param tableIndex position in SwRedlineTbl to start searching at, will be updated with the index of the returned + redline (or the next redline after the given position if not found) + @param next true: redline starts at position and ends after, false: redline starts before position and ends at or after + */ + const SwRedline* FindAtPosition( const SwPosition& startPosition, sal_uInt16& tableIndex, bool next = true ) const; + using _SwRedlineTbl::size; using _SwRedlineTbl::operator[]; using _SwRedlineTbl::empty; diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index 6e49721..904124f 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -900,6 +900,8 @@ public: const SwRedline& GetRedline( sal_uInt16 nPos ) const; sal_Bool AcceptRedline( sal_uInt16 nPos ); sal_Bool RejectRedline( sal_uInt16 nPos ); + bool AcceptRedlinesInSelection(); + bool RejectRedlinesInSelection(); /** Search Redline for this Data and @return position in array. diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 9a2ea57..58beba3 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -1919,36 +1919,6 @@ static sal_Bool lcl_RejectRedline( SwRedlineTbl& rArr, sal_uInt16& rPos, return bRet; } - -static const SwRedline* lcl_FindCurrRedline( const SwPosition& rSttPos, - sal_uInt16& rPos, - bool bNext = true ) -{ - const SwRedline* pFnd = 0; - const SwRedlineTbl& rArr = rSttPos.nNode.GetNode().GetDoc()->GetRedlineTbl(); - for( ; rPos < rArr.size() ; ++rPos ) - { - const SwRedline* pTmp = rArr[ rPos ]; - if( pTmp->HasMark() && pTmp->IsVisible() ) - { - const SwPosition* pRStt = pTmp->Start(), - * pREnd = pRStt == pTmp->GetPoint() ? pTmp->GetMark() - : pTmp->GetPoint(); - if( bNext ? *pRStt <= rSttPos : *pRStt < rSttPos ) - { - if( bNext ? *pREnd > rSttPos : *pREnd >= rSttPos ) - { - pFnd = pTmp; - break; - } - } - else - break; - } - } - return pFnd; -} - static int lcl_AcceptRejectRedl( Fn_AcceptReject fn_AcceptReject, SwRedlineTbl& rArr, sal_Bool bCallDelete, const SwPaM& rPam) @@ -1959,7 +1929,7 @@ static int lcl_AcceptRejectRedl( Fn_AcceptReject fn_AcceptReject, const SwPosition* pStt = rPam.Start(), * pEnd = pStt == rPam.GetPoint() ? rPam.GetMark() : rPam.GetPoint(); - const SwRedline* pFnd = lcl_FindCurrRedline( *pStt, n, true ); + const SwRedline* pFnd = rArr.FindAtPosition( *pStt, n, true ); if( pFnd && // Is new a part of it? ( *pFnd->Start() != *pStt || *pFnd->End() > *pEnd )) { @@ -2264,7 +2234,7 @@ const SwRedline* SwDoc::SelNextRedline( SwPaM& rPam ) const // If the starting positon points to the last valid ContentNode, // we take the next Redline in any case. sal_uInt16 n = 0; - const SwRedline* pFnd = lcl_FindCurrRedline( rSttPos, n, true ); + const SwRedline* pFnd = GetRedlineTbl().FindAtPosition( rSttPos, n, true ); if( pFnd ) { const SwPosition* pEnd = pFnd->End(); @@ -2381,7 +2351,7 @@ const SwRedline* SwDoc::SelPrevRedline( SwPaM& rPam ) const // If the starting positon points to the last valid ContentNode, // we take the previous Redline in any case. sal_uInt16 n = 0; - const SwRedline* pFnd = lcl_FindCurrRedline( rSttPos, n, false ); + const SwRedline* pFnd = GetRedlineTbl().FindAtPosition( rSttPos, n, false ); if( pFnd ) { const SwPosition* pStt = pFnd->Start(); @@ -2496,7 +2466,7 @@ bool SwDoc::SetRedlineComment( const SwPaM& rPaM, const String& rS ) * pEnd = pStt == rPaM.GetPoint() ? rPaM.GetMark() : rPaM.GetPoint(); sal_uInt16 n = 0; - if( lcl_FindCurrRedline( *pStt, n, true ) ) + if( GetRedlineTbl().FindAtPosition( *pStt, n, true ) ) { for( ; n < mpRedlineTbl->size(); ++n ) { @@ -2833,6 +2803,33 @@ sal_uInt16 SwRedlineTbl::FindPrevSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos, return nRet; } +const SwRedline* SwRedlineTbl::FindAtPosition( const SwPosition& rSttPos, + sal_uInt16& rPos, + bool bNext ) const +{ + const SwRedline* pFnd = 0; + for( ; rPos < size() ; ++rPos ) + { + const SwRedline* pTmp = (*this)[ rPos ]; + if( pTmp->HasMark() && pTmp->IsVisible() ) + { + const SwPosition* pRStt = pTmp->Start(), + * pREnd = pRStt == pTmp->GetPoint() ? pTmp->GetMark() + : pTmp->GetPoint(); + if( bNext ? *pRStt <= rSttPos : *pRStt < rSttPos ) + { + if( bNext ? *pREnd > rSttPos : *pREnd >= rSttPos ) + { + pFnd = pTmp; + break; + } + } + else + break; + } + } + return pFnd; +} SwRedlineExtraData::~SwRedlineExtraData() { diff --git a/sw/source/core/edit/edredln.cxx b/sw/source/core/edit/edredln.cxx index dbefb53..f532ecc 100644 --- a/sw/source/core/edit/edredln.cxx +++ b/sw/source/core/edit/edredln.cxx @@ -92,6 +92,24 @@ sal_Bool SwEditShell::RejectRedline( sal_uInt16 nPos ) return bRet; } +bool SwEditShell::AcceptRedlinesInSelection() +{ + SET_CURR_SHELL( this ); + StartAllAction(); + sal_Bool bRet = GetDoc()->AcceptRedline( *GetCrsr(), true ); + EndAllAction(); + return bRet; +} + +bool SwEditShell::RejectRedlinesInSelection() +{ + SET_CURR_SHELL( this ); + StartAllAction(); + sal_Bool bRet = GetDoc()->RejectRedline( *GetCrsr(), true ); + EndAllAction(); + return bRet; +} + // Set the comment at the Redline sal_Bool SwEditShell::SetRedlineComment( const String& rS ) { diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index 744428c..f4af436 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -639,22 +639,31 @@ void SwView::Execute(SfxRequest &rReq) case FN_REDLINE_ACCEPT_DIRECT: case FN_REDLINE_REJECT_DIRECT: { - // We check for a redline at the start of the selection/cursor, not the point. - // This ensures we work properly with FN_REDLINE_NEXT_CHANGE, which leaves the - // point at the *end* of the redline and the mark at the start (so GetRedline - // would return NULL if called on the point) SwDoc *pDoc = m_pWrtShell->GetDoc(); SwPaM *pCursor = m_pWrtShell->GetCrsr(); - - sal_uInt16 nRedline = 0; - const SwRedline *pRedline = pDoc->GetRedline(*pCursor->Start(), &nRedline); - assert(pRedline != 0); - if (pRedline) + if( pCursor->HasMark()) { if (FN_REDLINE_ACCEPT_DIRECT == nSlot) - m_pWrtShell->AcceptRedline(nRedline); + m_pWrtShell->AcceptRedlinesInSelection(); else - m_pWrtShell->RejectRedline(nRedline); + m_pWrtShell->RejectRedlinesInSelection(); + } + else + { + // We check for a redline at the start of the selection/cursor, not the point. + // This ensures we work properly with FN_REDLINE_NEXT_CHANGE, which leaves the + // point at the *end* of the redline and the mark at the start (so GetRedline + // would return NULL if called on the point) + sal_uInt16 nRedline = 0; + const SwRedline *pRedline = pDoc->GetRedline(*pCursor->Start(), &nRedline); + assert(pRedline != 0); + if (pRedline) + { + if (FN_REDLINE_ACCEPT_DIRECT == nSlot) + m_pWrtShell->AcceptRedline(nRedline); + else + m_pWrtShell->RejectRedline(nRedline); + } } } break; diff --git a/sw/source/ui/uiview/viewstat.cxx b/sw/source/ui/uiview/viewstat.cxx index 21aa946..fc25af1 100644 --- a/sw/source/ui/uiview/viewstat.cxx +++ b/sw/source/ui/uiview/viewstat.cxx @@ -52,6 +52,8 @@ #include <svl/stritem.hxx> #include <unotools/moduleoptions.hxx> #include <svl/visitem.hxx> +#include <redline.hxx> +#include <docary.hxx> #include <cmdid.h> @@ -266,12 +268,41 @@ void SwView::GetState(SfxItemSet &rSet) case FN_REDLINE_ACCEPT_DIRECT: case FN_REDLINE_REJECT_DIRECT: { - // If the selection/cursor start position isn't on a redline, disable - // accepting/rejecting changes. SwDoc *pDoc = m_pWrtShell->GetDoc(); SwPaM *pCursor = m_pWrtShell->GetCrsr(); - if (0 == pDoc->GetRedline(*pCursor->Start(), 0)) + if (GetDocShell()->HasChangeRecordProtection()) rSet.DisableItem(nWhich); + else if (pCursor->HasMark()) + { // If the selection does not contain redlines, disable accepting/rejecting changes. + sal_uInt16 index = 0; + const SwRedlineTbl& table = pDoc->GetRedlineTbl(); + const SwRedline* redline = table.FindAtPosition( *pCursor->Start(), index ); + if( redline != NULL && *redline->Start() == *pCursor->End()) + redline = NULL; + if( redline == NULL ) + { + for(; index < table.size(); ++index ) + { + const SwRedline* tmp = table[ index ]; + if( *tmp->Start() >= *pCursor->End()) + break; + if( tmp->HasMark() && tmp->IsVisible()) + { + redline = tmp; + break; + } + } + } + if( redline == NULL ) + rSet.DisableItem(nWhich); + } + else + { + // If the cursor position isn't on a redline, disable + // accepting/rejecting changes. + if (0 == pDoc->GetRedline(*pCursor->Start(), 0)) + rSet.DisableItem(nWhich); + } } break; commit 3fdf7e0032d0674d4b691068da53ee712d70750d Author: Joel Madero <[email protected]> Date: Wed Oct 23 16:37:47 2013 -0700 fdo#47677 - Track Changes Toolbar Added new toolbar ("Changes") which contains accept, reject, comment, protect, accept or reject, record and show within Writer. Change-Id: Ic541f95f09b3897cdabd23a6e1070809f361cc16 (cherry picked from commit 686ab95e97e3a432fcccc88ae30b8ad6eed1b2b4) Signed-off-by: LuboÅ¡ LuÅák <[email protected]> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu index a4f5bcc..7ddd4ec1 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu @@ -160,16 +160,25 @@ <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~Protect Records...</value> </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> </node> <node oor:name=".uno:RejectTracedChange" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">Reject Change</value> </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> </node> <node oor:name=".uno:AcceptTracedChange" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">Accept Change</value> </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> </node> <node oor:name=".uno:NextTrackedChange" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> @@ -191,7 +200,7 @@ <value xml:lang="en-US">~Record</value> </prop> <prop oor:name="Properties" oor:type="xs:int"> - <value>8</value> + <value>1</value> </prop> </node> <node oor:name=".uno:ShowTrackedChanges" oor:op="replace"> @@ -199,7 +208,7 @@ <value xml:lang="en-US">~Show</value> </prop> <prop oor:name="Properties" oor:type="xs:int"> - <value>8</value> + <value>1</value> </prop> </node> <node oor:name=".uno:GotoPage" oor:op="replace"> @@ -211,6 +220,9 @@ <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~Comment...</value> </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> </node> <node oor:name=".uno:UpdateAll" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> @@ -226,6 +238,9 @@ <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~Accept or Reject...</value> </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> </node> <node oor:name=".uno:EditCurIndex" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterFormWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterFormWindowState.xcu index 7514f1d..1b9ae09 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterFormWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterFormWindowState.xcu @@ -697,6 +697,23 @@ <value>true</value> </prop> </node> + <node oor:name="private:resource/toolbar/changes" oor:op="replace"> + <prop oor:name="UIName" oor:type="xs:string"> + <value xml:lang="en-US">Changes</value> + </prop> + <prop oor:name="Docked" oor:type="xs:boolean"> + <value>true</value> + </prop> + <prop oor:name="DockingArea" oor:type="xs:int"> + <value>2</value> + </prop> + <prop oor:name="DockPos" oor:type="xs:string"> + <value>0,0</value> + </prop> + <prop oor:name="Visible" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> </node> </node> </oor:component-data> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterGlobalWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterGlobalWindowState.xcu index 665d500..65d62b4 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterGlobalWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterGlobalWindowState.xcu @@ -714,6 +714,17 @@ <value>true</value> </prop> </node> + <node oor:name="private:resource/toolbar/changes" oor:op="replace"> + <prop oor:name="UIName" oor:type="xs:string"> + <value xml:lang="en-US">Changes</value> + </prop> + <prop oor:name="Docked" oor:type="xs:boolean"> + <value>false</value> + </prop> + <prop oor:name="Visible" oor:type="xs:boolean"> + <value>false</value> + </prop> + </node> </node> </node> </oor:component-data> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterReportWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterReportWindowState.xcu index 5f347a4..876a406 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterReportWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterReportWindowState.xcu @@ -694,6 +694,23 @@ <value>true</value> </prop> </node> + <node oor:name="private:resource/toolbar/changes" oor:op="replace"> + <prop oor:name="UIName" oor:type="xs:string"> + <value xml:lang="en-US">Changes</value> + </prop> + <prop oor:name="Docked" oor:type="xs:boolean"> + <value>true</value> + </prop> + <prop oor:name="DockingArea" oor:type="xs:int"> + <value>2</value> + </prop> + <prop oor:name="DockPos" oor:type="xs:string"> + <value>0,0</value> + </prop> + <prop oor:name="Visible" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> </node> </node> </oor:component-data> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterWebWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterWebWindowState.xcu index f86384d..65c0e9f 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterWebWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterWebWindowState.xcu @@ -620,6 +620,17 @@ <value>true</value> </prop> </node> + <node oor:name="private:resource/toolbar/changes" oor:op="replace"> + <prop oor:name="UIName" oor:type="xs:string"> + <value xml:lang="en-US">Changes</value> + </prop> + <prop oor:name="Docked" oor:type="xs:boolean"> + <value>false</value> + </prop> + <prop oor:name="Visible" oor:type="xs:boolean"> + <value>false</value> + </prop> + </node> </node> </node> </oor:component-data> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu index 2c3d9c3..4dcc178 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu @@ -734,6 +734,17 @@ <value>false</value> </prop> </node> + <node oor:name="private:resource/toolbar/changes" oor:op="replace"> + <prop oor:name="UIName" oor:type="xs:string"> + <value xml:lang="en-US">Changes</value> + </prop> + <prop oor:name="Docked" oor:type="xs:boolean"> + <value>false</value> + </prop> + <prop oor:name="Visible" oor:type="xs:boolean"> + <value>false</value> + </prop> + </node> </node> </node> </oor:component-data> diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index a01d738..7141041 100644 --- a/sw/UIConfig_swriter.mk +++ b/sw/UIConfig_swriter.mk @@ -23,6 +23,7 @@ $(eval $(call gb_UIConfig_add_toolbarfiles,modules/swriter,\ sw/uiconfig/swriter/toolbar/basicshapes \ sw/uiconfig/swriter/toolbar/bezierobjectbar \ sw/uiconfig/swriter/toolbar/calloutshapes \ + sw/uiconfig/swriter/toolbar/changes \ sw/uiconfig/swriter/toolbar/colorbar \ sw/uiconfig/swriter/toolbar/drawbar \ sw/uiconfig/swriter/toolbar/drawingobjectbar \ diff --git a/sw/uiconfig/swriter/toolbar/changes.xml b/sw/uiconfig/swriter/toolbar/changes.xml new file mode 100644 index 0000000..29a7984 --- /dev/null +++ b/sw/uiconfig/swriter/toolbar/changes.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd"> +<!-- + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> +<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink"> + <toolbar:toolbaritem xlink:href=".uno:ShowTrackedChanges" toolbar:helpid="10624"/> + <toolbar:toolbarseparator/> + <toolbar:toolbaritem xlink:href=".uno:TrackChanges" toolbar:helpid="10725"/> + <toolbar:toolbaritem xlink:href=".uno:AcceptTrackedChanges" toolbar:helpid="10622"/> + <toolbar:toolbarseparator/> + <toolbar:toolbaritem xlink:href=".uno:ProtectTraceChangeMode" toolbar:helpid="10625"/> + <toolbar:toolbaritem xlink:href=".uno:AcceptTracedChange" toolbar:helpid="10625"/> + <toolbar:toolbarseparator/> + <toolbar:toolbaritem xlink:href=".uno:RejectTracedChange" toolbar:helpid="10626"/> + <toolbar:toolbaritem xlink:href=".uno:CommentChangeTracking" toolbar:helpid="10625"/> + <toolbar:toolbarseparator/> + <toolbar:toolbaritem xlink:href=".uno:InsertAnnotation" toolbar:helpid="10625"/> +</toolbar:toolbar>
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
