Kaydet (Commit) ebb728c9 authored tarafından Caolán McNamara's avatar Caolán McNamara

add a 'format all comments' feature

Change-Id: Ie9530f0f58b38d014beda60b9efba3ce93fe5c0e
üst 43d68d4e
......@@ -5308,6 +5308,11 @@
<value xml:lang="en-US">Delete All Comments</value>
</prop>
</node>
<node oor:name=".uno:FormatAllNotes" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Format All Comments</value>
</prop>
</node>
<node oor:name=".uno:DeleteAuthor" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Delete All Comments by This Author</value>
......
......@@ -44,6 +44,8 @@ class SfxBroadcaster;
class SfxHint;
class SwEditWin;
class Color;
class SfxItemPool;
class SfxItemSet;
class SvxSearchItem;
class SvxLanguageItem;
namespace sw { namespace annotation {
......@@ -218,6 +220,9 @@ class SwPostItMgr: public SfxListener
void Delete(const OUString& aAuthor);
void Delete();
void ExecuteFormatAllDialog(SwView& rView);
void FormatAll(const SfxItemSet &rNewAttr);
void Hide( const OUString& rAuthor );
void Hide();
void Show();
......
......@@ -783,7 +783,7 @@ included in c-context files, so c++ style stuff will cause problems.
#define FN_DELETE_COMMENT (FN_NOTES+6)
#define FN_REPLY (FN_NOTES+7)
#define FN_FORMAT_ALL_NOTES (FN_NOTES+8)
#define FN_HEADERFOOTER_EDIT (FN_HEADERFOOTER+1)
#define FN_HEADERFOOTER_DELETE (FN_HEADERFOOTER+2)
......
......@@ -116,6 +116,7 @@
#define CMD_FN_DELETE_COMMENT ".uno:DeleteComment"
#define CMD_FN_DELETE_NOTE_AUTHOR ".uno:DeleteAuthor"
#define CMD_FN_DELETE_ALL_NOTES ".uno:DeleteAllNotes"
#define CMD_FN_FORMAT_ALL_NOTES ".uno:FormatAllNotes"
#define CMD_FN_HIDE_NOTE ".uno:HideNote"
#define CMD_FN_HIDE_NOTE_AUTHOR ".uno:HideAuthor"
#define CMD_FN_HIDE_ALL_NOTES ".uno:HideAllNotes"
......
......@@ -37,6 +37,12 @@ interface _Annotation
StateMethod = GetNoteState ;
]
FN_FORMAT_ALL_NOTES
[
ExecMethod = NoteExec ;
StateMethod = GetNoteState ;
]
FN_HIDE_NOTE
[
ExecMethod = NoteExec ;
......
......@@ -940,6 +940,11 @@ interface BaseText
ExecMethod = ExecField ;
StateMethod = StateField;
]
FN_FORMAT_ALL_NOTES
[
ExecMethod = ExecField ;
StateMethod = StateField;
]
FN_HIDE_NOTE
[
ExecMethod = ExecField ;
......
......@@ -9604,6 +9604,30 @@ SfxVoidItem DeleteAllNotes FN_DELETE_ALL_NOTES
GroupId = GID_EDIT;
]
SfxVoidItem FormatAllNotes FN_FORMAT_ALL_NOTES
()
[
/* flags: */
AutoUpdate = FALSE,
Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = FALSE,
ReadOnlyDoc = FALSE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
Synchron;
/* config: */
AccelConfig = TRUE,
MenuConfig = TRUE,
StatusBarConfig = FALSE,
ToolBoxConfig = TRUE,
GroupId = GID_EDIT;
]
SfxVoidItem HideNote FN_HIDE_NOTE
()
[
......
......@@ -75,12 +75,14 @@ void AnnotationMenuButton::MouseButtonDown( const MouseEvent& rMEvt )
pButtonPopup->EnableItem( FN_DELETE_COMMENT, false );
pButtonPopup->EnableItem( FN_DELETE_NOTE_AUTHOR, false );
pButtonPopup->EnableItem( FN_DELETE_ALL_NOTES, false );
pButtonPopup->EnableItem( FN_FORMAT_ALL_NOTES, false );
}
else
{
pButtonPopup->EnableItem( FN_DELETE_COMMENT, !mrSidebarWin.IsProtected() );
pButtonPopup->EnableItem( FN_DELETE_NOTE_AUTHOR, true );
pButtonPopup->EnableItem( FN_DELETE_ALL_NOTES, true );
pButtonPopup->EnableItem( FN_FORMAT_ALL_NOTES, true );
}
if ( mrSidebarWin.IsProtected() )
......
......@@ -34,8 +34,8 @@
#include <vcl/outdev.hxx>
#include <vcl/settings.hxx>
#include <chrdlgmodes.hxx>
#include <viewopt.hxx>
#include <view.hxx>
#include <docsh.hxx>
#include <wrtsh.hxx>
......@@ -67,11 +67,14 @@
#include <svx/svdview.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/langitem.hxx>
#include <editeng/kernitem.hxx>
#include <editeng/outliner.hxx>
#include <i18nlangtag/mslangid.hxx>
#include <i18nlangtag/lang.h>
#include "annotsh.hxx"
#include "swabstdlg.hxx"
#include "swevent.hxx"
#include "switerator.hxx"
......@@ -1242,6 +1245,78 @@ void SwPostItMgr::Delete()
CalcRects();
LayoutPostIts();
}
void SwPostItMgr::ExecuteFormatAllDialog(SwView& rView)
{
if (mvPostItFlds.empty())
return;
sw::sidebarwindows::SwSidebarWin *pOrigActiveWin = GetActiveSidebarWin();
sw::sidebarwindows::SwSidebarWin *pWin = pOrigActiveWin;
if (!pWin)
{
for (SwSidebarItem_iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end(); ++i)
{
pWin = (*i)->pPostIt;
if (pWin)
break;
}
}
if (!pWin)
return;
SetActiveSidebarWin(pWin);
OutlinerView* pOLV = pWin->GetOutlinerView();
SfxItemSet aEditAttr(pOLV->GetAttribs());
SfxItemPool* pPool(SwAnnotationShell::GetAnnotationPool(rView));
SfxItemSet aDlgAttr(*pPool, EE_ITEMS_START, EE_ITEMS_END);
aDlgAttr.Put(aEditAttr);
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg(rView.GetWindow(), rView, aDlgAttr, DLG_CHAR_ANN);
sal_uInt16 nRet = pDlg->Execute();
if (RET_OK == nRet)
{
aDlgAttr.Put(*pDlg->GetOutputItemSet());
FormatAll(aDlgAttr);
}
delete pDlg;
SetActiveSidebarWin(pOrigActiveWin);
}
void SwPostItMgr::FormatAll(const SfxItemSet &rNewAttr)
{
mpWrtShell->StartAllAction();
SwRewriter aRewriter;
aRewriter.AddRule(UndoArg1, SW_RES(STR_FORMAT_ALL_NOTES) );
mpWrtShell->StartUndo( UNDO_INSATTR, &aRewriter );
for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
{
if (!(*i)->pPostIt)
continue;
OutlinerView* pOLV = (*i)->pPostIt->GetOutlinerView();
//save old selection
ESelection aOrigSel(pOLV->GetSelection());
//select all
Outliner *pOutliner = pOLV->GetOutliner();
if (pOutliner)
{
sal_Int32 nParaCount = pOutliner->GetParagraphCount();
if (nParaCount > 0)
pOLV->SelectRange(0, nParaCount);
}
//set new char properties
pOLV->SetAttribs(rNewAttr);
//restore old selection
pOLV->SetSelection(aOrigSel);
}
mpWrtShell->EndUndo();
PrepareView();
mpWrtShell->EndAllAction();
mbLayout = true;
CalcRects();
LayoutPostIts();
}
void SwPostItMgr::Hide( const OUString& rAuthor )
{
for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i != mvPostItFlds.end() ; ++i)
......
......@@ -1054,6 +1054,7 @@ void SwSidebarWin::ExecuteCommand(sal_uInt16 nSlot)
//Delete(); // do not kill the parent of our open popup menu
mnEventId = Application::PostUserEvent( LINK( this, SwSidebarWin, DeleteHdl), 0 );
break;
case FN_FORMAT_ALL_NOTES:
case FN_DELETE_ALL_NOTES:
case FN_HIDE_ALL_NOTES:
// not possible as slot as this would require that "this" is the active postit
......
......@@ -32,6 +32,7 @@
#define STR_NOAUTHOR (RC_ANNOTATION_BEGIN + 6)
#define STR_REPLY (RC_ANNOTATION_BEGIN + 7)
#define STR_FORMAT_ALL_NOTES (RC_ANNOTATION_BEGIN + 8)
#define ANNOTATION_ACT_END STR_REPLY
......
......@@ -72,6 +72,8 @@ public:
virtual ::svl::IUndoManager*
GetUndoManager() SAL_OVERRIDE;
static SfxItemPool* GetAnnotationPool(SwView& rV);
};
#endif
......
......@@ -147,11 +147,16 @@ void SwAnnotationShell::InitInterface_Impl()
TYPEINIT1(SwAnnotationShell,SfxShell)
SfxItemPool* SwAnnotationShell::GetAnnotationPool(SwView& rV)
{
SwWrtShell &rSh = rV.GetWrtShell();
return rSh.GetAttrPool().GetSecondaryPool();
}
SwAnnotationShell::SwAnnotationShell( SwView& r )
: rView(r)
: rView(r)
{
SwWrtShell &rSh = rView.GetWrtShell();
SetPool(rSh.GetAttrPool().GetSecondaryPool());
SetPool(SwAnnotationShell::GetAnnotationPool(rView));
SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Annotation));
}
......@@ -1080,9 +1085,12 @@ void SwAnnotationShell::NoteExec(SfxRequest &rReq)
pPostItMgr->GetActiveSidebarWin()->ExecuteCommand(nSlot);
break;
case FN_DELETE_ALL_NOTES:
case FN_DELETE_ALL_NOTES:
pPostItMgr->Delete();
break;
case FN_FORMAT_ALL_NOTES:
pPostItMgr->ExecuteFormatAllDialog(rView);
break;
case FN_DELETE_NOTE_AUTHOR:
{
SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, nSlot, false);
......@@ -1117,6 +1125,7 @@ void SwAnnotationShell::GetNoteState(SfxItemSet &rSet)
case FN_POSTIT:
case FN_DELETE_NOTE_AUTHOR:
case FN_DELETE_ALL_NOTES:
case FN_FORMAT_ALL_NOTES:
case FN_HIDE_NOTE:
case FN_HIDE_NOTE_AUTHOR:
case FN_HIDE_ALL_NOTES:
......
......@@ -17,9 +17,13 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <chrdlgmodes.hxx>
#include <crsskip.hxx>
#include <hintids.hxx>
#include <SidebarWin.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/kernitem.hxx>
#include <editeng/outliner.hxx>
#include <sfx2/lnkbase.hxx>
#include <fmtfld.hxx>
#include <vcl/msgbox.hxx>
......@@ -320,6 +324,13 @@ void SwTextShell::ExecField(SfxRequest &rReq)
if ( GetView().GetPostItMgr() )
GetView().GetPostItMgr()->Delete();
break;
case FN_FORMAT_ALL_NOTES:
{
SwPostItMgr* pPostItMgr = GetView().GetPostItMgr();
if (pPostItMgr)
pPostItMgr->ExecuteFormatAllDialog(GetView());
}
break;
case FN_DELETE_NOTE_AUTHOR:
{
SFX_REQUEST_ARG( rReq, pNoteItem, SfxStringItem, nSlot, false);
......@@ -623,6 +634,7 @@ void SwTextShell::StateField( SfxItemSet &rSet )
case FN_DELETE_COMMENT:
case FN_DELETE_NOTE_AUTHOR:
case FN_DELETE_ALL_NOTES:
case FN_FORMAT_ALL_NOTES:
case FN_HIDE_NOTE:
case FN_HIDE_NOTE_AUTHOR:
case FN_HIDE_ALL_NOTES:
......
......@@ -750,6 +750,12 @@
HelpId = CMD_FN_DELETE_ALL_NOTES ;\
Text [ en-US ] = "~Delete All Comments" ;\
};\
MenuItem\
{\
Identifier = FN_FORMAT_ALL_NOTES ;\
HelpId = CMD_FN_FORMAT_ALL_NOTES ;\
Text [ en-US ] = "~Format All Comments" ;\
};\
/*
MenuItem\
{\
......
......@@ -35,6 +35,11 @@ String STR_DELETE_ALL_NOTES
Text [ en-US ] = "All Comments" ;
};
String STR_FORMAT_ALL_NOTES
{
Text [ en-US ] = "All Comments" ;
};
String STR_DELETE_AUTHOR_NOTES
{
Text [ en-US ] = "Comments by " ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment