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 @@ ...@@ -59,6 +59,7 @@
#include <svl/zforlist.hxx> #include <svl/zforlist.hxx>
#include <svl/zformat.hxx> #include <svl/zformat.hxx>
#include <vcl/mnemonic.hxx> #include <vcl/mnemonic.hxx>
#include <xmloff/odffields.hxx>
#include <view.hxx> #include <view.hxx>
#include <wrtsh.hxx> // active window #include <wrtsh.hxx> // active window
#include <doc.hxx> // active window #include <doc.hxx> // active window
...@@ -849,7 +850,7 @@ sal_uInt16 SwFldMgr::GetCurTypeId() const ...@@ -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; SwField* pFld = 0;
sal_Bool bExp = sal_False; sal_Bool bExp = sal_False;
...@@ -1378,6 +1379,13 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData ) ...@@ -1378,6 +1379,13 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData )
// insert // insert
pCurShell->StartAllAction(); 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); pCurShell->Insert(*pFld);
if(bExp && bEvalExp) if(bExp && bEvalExp)
......
...@@ -48,6 +48,7 @@ namespace com{namespace sun{namespace star{ ...@@ -48,6 +48,7 @@ namespace com{namespace sun{namespace star{
class SwWrtShell; class SwWrtShell;
class SwField; class SwField;
class SwFieldType; class SwFieldType;
class SwPaM;
class SbModule; class SbModule;
class SvxMacroItem; class SvxMacroItem;
class SvNumberFormatter; class SvNumberFormatter;
...@@ -141,7 +142,7 @@ public: ...@@ -141,7 +142,7 @@ public:
{ pWrtShell = pShell; } { pWrtShell = pShell; }
// insert field using TypeID (TYP_ ...) // 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 // change the current field directly
void UpdateCurFld(sal_uLong nFormat, void UpdateCurFld(sal_uLong nFormat,
......
...@@ -356,14 +356,19 @@ void SwTextShell::ExecField(SfxRequest &rReq) ...@@ -356,14 +356,19 @@ void SwTextShell::ExecField(SfxRequest &rReq)
if( !(sAuthor = aUserOpt.GetFullName()).Len()) if( !(sAuthor = aUserOpt.GetFullName()).Len())
if( !(sAuthor = aUserOpt.GetID()).Len() ) if( !(sAuthor = aUserOpt.GetID()).Len() )
sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR )); 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() ) if( rSh.HasSelection() )
{ {
rSh.NormalizePam(true); rSh.NormalizePam(false);
rSh.KillPams(); rSh.KillPams();
rSh.ClearMark(); rSh.ClearMark();
} }
SwInsertFld_Data aData(TYP_POSTITFLD, 0, sAuthor, aEmptyStr, 0); SwInsertFld_Data aData(TYP_POSTITFLD, 0, sAuthor, aEmptyStr, 0);
aFldMgr.InsertFld(aData); aFldMgr.InsertFld(aData, &aSaved);
rSh.Push(); rSh.Push();
rSh.SwCrsrShell::Left(1, CRSR_SKIP_CHARS, sal_False); rSh.SwCrsrShell::Left(1, CRSR_SKIP_CHARS, sal_False);
pPostIt = (SwPostItField*)aFldMgr.GetCurFld(); 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