Kaydet (Commit) acaa4d59 authored tarafından Miklos Vajna's avatar Miklos Vajna

fdo#38244 enable attaching comments to document text ranges in writer

Change-Id: I1e1ec7e91d513bc34737c7659d1178a02e80c53e
üst 2f52f37f
......@@ -59,6 +59,7 @@
#include <svl/zforlist.hxx>
#include <svl/zformat.hxx>
#include <vcl/mnemonic.hxx>
#include <xmloff/odffields.hxx>
#include <view.hxx>
#include <wrtsh.hxx> // active window
#include <doc.hxx> // active window
......@@ -849,7 +850,7 @@ sal_uInt16 SwFldMgr::GetCurTypeId() const
--------------------------------------------------------------------*/
sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData )
sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData, SwPaM *pPam )
{
SwField* pFld = 0;
sal_Bool bExp = sal_False;
......@@ -1378,6 +1379,13 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData )
// insert
pCurShell->StartAllAction();
if (pPam && *pPam->GetPoint() != *pPam->GetMark() && rData.nTypeId == TYP_POSTITFLD)
{
// If an annotation field is inserted, take care of the relevant fieldmark.
IDocumentMarkAccess* pMarksAccess = pCurShell->GetDoc()->getIDocumentMarkAccess();
pMarksAccess->makeFieldBookmark(*pPam, OUString(), ODF_COMMENTRANGE);
}
pCurShell->Insert(*pFld);
if(bExp && bEvalExp)
......
......@@ -48,6 +48,7 @@ namespace com{namespace sun{namespace star{
class SwWrtShell;
class SwField;
class SwFieldType;
class SwPaM;
class SbModule;
class SvxMacroItem;
class SvNumberFormatter;
......@@ -141,7 +142,7 @@ public:
{ pWrtShell = pShell; }
// insert field using TypeID (TYP_ ...)
sal_Bool InsertFld( const SwInsertFld_Data& rData );
sal_Bool InsertFld( const SwInsertFld_Data& rData, SwPaM* pPam = 0 );
// change the current field directly
void UpdateCurFld(sal_uLong nFormat,
......
......@@ -356,14 +356,19 @@ void SwTextShell::ExecField(SfxRequest &rReq)
if( !(sAuthor = aUserOpt.GetFullName()).Len())
if( !(sAuthor = aUserOpt.GetID()).Len() )
sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR ));
// Save the current selection, it will be required later for fieldmark insertion.
SwPaM& rCurrPam = rSh.GetCurrentShellCursor();
SwPaM aSaved(*rCurrPam.GetPoint(), *rCurrPam.GetMark());
if( rSh.HasSelection() )
{
rSh.NormalizePam(true);
rSh.NormalizePam(false);
rSh.KillPams();
rSh.ClearMark();
}
SwInsertFld_Data aData(TYP_POSTITFLD, 0, sAuthor, aEmptyStr, 0);
aFldMgr.InsertFld(aData);
aFldMgr.InsertFld(aData, &aSaved);
rSh.Push();
rSh.SwCrsrShell::Left(1, CRSR_SKIP_CHARS, sal_False);
pPostIt = (SwPostItField*)aFldMgr.GetCurFld();
......
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