lok: Allow to reply to comments using postit id

Change-Id: Ic6aaa3066923d62f197bc2b0e02e8049c9d7cd2c
Reviewed-on: https://gerrit.libreoffice.org/33612
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
This commit is contained in:
Pranav Kant
2017-01-22 19:39:47 +05:30
committed by pranavk
parent 73875b39e0
commit 6e463381b4
12 changed files with 113 additions and 2 deletions

View File

@@ -1383,6 +1383,7 @@ static void doc_iniUnoCommands ()
OUString(".uno:Paste"),
OUString(".uno:SelectAll"),
OUString(".uno:InsertAnnotation"),
OUString(".uno:ReplyComment"),
OUString(".uno:InsertRowsBefore"),
OUString(".uno:InsertRowsAfter"),
OUString(".uno:InsertColumnsBefore"),

View File

@@ -19,6 +19,7 @@
#ifndef INCLUDED_SVX_POSTATTR_HXX
#define INCLUDED_SVX_POSTATTR_HXX
#include <svl/intitem.hxx>
#include <svl/stritem.hxx>
#include <svx/svxdllapi.h>
@@ -112,6 +113,31 @@ public:
}
};
// class SvxPostItIdItem -----------------------------------------------
/*
The internal id of a note
*/
class SVX_DLLPUBLIC SvxPostItIdItem: public SfxUInt32Item
{
public:
static SfxPoolItem* CreateDefault();
SvxPostItIdItem( sal_uInt16 nWhich );
SvxPostItIdItem( sal_uInt32 rId, sal_uInt16 nWhich );
virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
inline SvxPostItIdItem& operator=( const SvxPostItIdItem& rId )
{
SetValue( rId.GetValue() );
return *this;
}
};
#endif

View File

@@ -235,6 +235,7 @@
#define SID_ATTR_POSTIT_AUTHOR ( SID_SVX_START + 44 )
#define SID_ATTR_POSTIT_DATE ( SID_SVX_START + 45 )
#define SID_ATTR_POSTIT_TEXT ( SID_SVX_START + 46 )
#define SID_ATTR_POSTIT_ID ( SID_SVX_START + 47 )
// free
// CAUTION! Range <48 .. 49> used by EditEngine (!)

View File

@@ -223,6 +223,7 @@ item BYTE SvxPaperBinItem;
item String SvxPostItAuthorItem;
item String SvxPostItDateItem;
item String SvxPostItTextItem;
item INT32 SvxPostItIdItem;
item FontItalic SvxPostureItem; // enum
item BOOL SvxPrintItem;
item UINT16 SvxPropSizeItem; // derived from UInt16Item

View File

@@ -26,6 +26,7 @@
SfxPoolItem* SvxPostItAuthorItem::CreateDefault() { return new SvxPostItAuthorItem(0); }
SfxPoolItem* SvxPostItDateItem::CreateDefault() { return new SvxPostItDateItem(0); }
SfxPoolItem* SvxPostItTextItem::CreateDefault() { return new SvxPostItTextItem(0); }
SfxPoolItem* SvxPostItIdItem::CreateDefault() { return new SvxPostItIdItem(0); }
SvxPostItAuthorItem::SvxPostItAuthorItem( sal_uInt16 _nWhich )
{
@@ -144,4 +145,20 @@ SfxPoolItem* SvxPostItTextItem::Clone( SfxItemPool * ) const
return new SvxPostItTextItem( *this );
}
SvxPostItIdItem::SvxPostItIdItem( sal_uInt16 _nWhich )
{
SetWhich( _nWhich );
}
SvxPostItIdItem::SvxPostItIdItem( sal_uInt32 rId, sal_uInt16 _nWhich ) :
SfxUInt32Item( _nWhich, rId )
{
}
SfxPoolItem* SvxPostItIdItem::Clone( SfxItemPool * ) const
{
return new SvxPostItIdItem( *this );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -156,6 +156,7 @@ class SwPostItMgr: public SfxListener
bool mbDeleteNote;
FieldShadowState mShadowState;
OutlinerParaObject* mpAnswer;
OUString maAnswerText;
bool mbIsShowAnchor;
// data structure to collect the <SwSidebarWin> instances for certain <SwFrame> instances.
@@ -237,6 +238,7 @@ class SwPostItMgr: public SfxListener
Color GetArrowColor(sal_uInt16 aDirection,unsigned long aPage) const;
sw::annotation::SwAnnotationWin* GetAnnotationWin(const SwPostItField* pField) const;
sw::annotation::SwAnnotationWin* GetAnnotationWin(const sal_uInt32 nPostItId) const;
sw::sidebarwindows::SwSidebarWin* GetNextPostIt( sal_uInt16 aDirection,
sw::sidebarwindows::SwSidebarWin* aPostIt);
@@ -265,6 +267,8 @@ class SwPostItMgr: public SfxListener
void RegisterAnswer(OutlinerParaObject* pAnswer) { mpAnswer = pAnswer;}
OutlinerParaObject* IsAnswer() {return mpAnswer;}
void RegisterAnswerText(const OUString& aAnswerText) { maAnswerText = aAnswerText; }
const OUString& GetAnswerText() { return maAnswerText; }
void CheckMetaText();
sal_uInt16 Replace(SvxSearchItem* pItem);

View File

@@ -919,6 +919,11 @@ interface BaseText
ExecMethod = ExecField ;
StateMethod = StateField;
]
FN_REPLY
[
ExecMethod = ExecField;
StateMethod = StateField;
]
FN_DELETE_COMMENT
[
ExecMethod = ExecField ;

View File

@@ -7063,7 +7063,7 @@ SfxBoolItem SelectionModeDefault FN_SELECTION_MODE_DEFAULT
]
SfxVoidItem ReplyComment FN_REPLY
()
(SvxPostItIdItem Id SID_ATTR_POSTIT_ID,SvxPostItTextItem Text SID_ATTR_POSTIT_TEXT)
[
AutoUpdate = FALSE,
FastCall = FALSE,

View File

@@ -41,6 +41,7 @@
#include <editeng/editeng.hxx>
#include <editeng/editobj.hxx>
#include <comphelper/lok.hxx>
#include <docufld.hxx>
#include <txtfld.hxx>
#include <ndtxt.hxx>
@@ -240,6 +241,10 @@ VclPtr<MenuButton> SwAnnotationWin::CreateMenuButton()
void SwAnnotationWin::InitAnswer(OutlinerParaObject* pText)
{
// If tiled annotations is off in lok case, skip adding additional reply text.
if (comphelper::LibreOfficeKit::isActive() && !comphelper::LibreOfficeKit::isTiledAnnotations())
return;
//collect our old meta data
SwSidebarWin* pWin = Mgr().GetNextPostIt(KEY_PAGEUP, this);
const SvtSysLocale aSysLocale;

View File

@@ -1624,6 +1624,16 @@ sw::annotation::SwAnnotationWin* SwPostItMgr::GetAnnotationWin(const SwPostItFie
return nullptr;
}
sw::annotation::SwAnnotationWin* SwPostItMgr::GetAnnotationWin(const sal_uInt32 nPostItId) const
{
for(const_iterator i = mvPostItFields.begin(); i != mvPostItFields.end() ; ++i)
{
if ( static_cast<const SwPostItField*>((*i)->GetFormatField().GetField())->GetPostItId() == nPostItId )
return dynamic_cast<sw::annotation::SwAnnotationWin*>((*i)->pPostIt.get());
}
return nullptr;
}
SwSidebarWin* SwPostItMgr::GetNextPostIt( sal_uInt16 aDirection,
SwSidebarWin* aPostIt )
{

View File

@@ -56,6 +56,7 @@
#include <editeng/contouritem.hxx>
#include <editeng/postitem.hxx>
#include <editeng/frmdiritem.hxx>
#include <svx/postattr.hxx>
#include <svx/svdoutl.hxx>
#include <svl/whiter.hxx>
#include <svl/cjkoptions.hxx>

View File

@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <AnnotationWin.hxx>
#include <comphelper/lok.hxx>
#include <chrdlgmodes.hxx>
#include <hintids.hxx>
@@ -369,6 +370,37 @@ void SwTextShell::ExecField(SfxRequest &rReq)
GetView().GetPostItMgr()->Hide( pNoteItem->GetValue() );
}
break;
case FN_REPLY:
{
const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID);
if (pIdItem && pIdItem->GetValue())
{
SwFieldType* pType = rSh.GetDoc()->getIDocumentFieldsAccess().GetFieldType(RES_POSTITFLD, OUString(), false);
SwIterator<SwFormatField,SwFieldType> aIter( *pType );
SwFormatField* pSwFormatField = aIter.First();
while( pSwFormatField )
{
if ( static_cast<SwPostItField*>(pSwFormatField->GetField())->GetPostItId() == pIdItem->GetValue())
{
sw::annotation::SwAnnotationWin* pWin = GetView().GetPostItMgr()->GetAnnotationWin(pIdItem->GetValue());
if (pWin)
{
const SvxPostItTextItem* pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT);
OUString sText;
if ( pTextItem )
sText = pTextItem->GetValue();
GetView().GetPostItMgr()->RegisterAnswerText(sText);
pWin->ExecuteCommand(nSlot);
}
break;
}
pSwFormatField = aIter.Next();
}
}
}
break;
case FN_POSTIT:
{
SwPostItField* pPostIt = dynamic_cast<SwPostItField*>(aFieldMgr.GetCurField());
@@ -390,6 +422,13 @@ void SwTextShell::ExecField(SfxRequest &rReq)
if ( pTextItem )
sText = pTextItem->GetValue();
// If we have a text already registered for answer, use that
if (GetView().GetPostItMgr()->IsAnswer() && !GetView().GetPostItMgr()->GetAnswerText().isEmpty())
{
sText = GetView().GetPostItMgr()->GetAnswerText();
GetView().GetPostItMgr()->RegisterAnswerText(OUString());
}
if ( rSh.HasSelection() && !rSh.IsTableMode() )
{
rSh.KillPams();
@@ -753,12 +792,13 @@ void SwTextShell::StateField( SfxItemSet &rSet )
rSet.DisableItem(nWhich);
break;
case FN_REPLY:
case FN_POSTIT :
case FN_JAVAEDIT :
{
bool bCurField = false;
pField = rSh.GetCurField();
if(nWhich == FN_POSTIT)
if(nWhich == FN_POSTIT || nWhich == FN_REPLY)
bCurField = pField && pField->GetTyp()->Which() == RES_POSTITFLD;
else
bCurField = pField && pField->GetTyp()->Which() == RES_SCRIPTFLD;