diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-07-16 18:42:30 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-07-17 09:55:22 +0200 |
commit | acaa4d592a0d8cc219f7ec8a65b0c17757a856aa (patch) | |
tree | f9990780fa101b7334e65521783ca3bcaf40cac0 | |
parent | 2f52f37f8363cb696bb3ead7249a87a826409908 (diff) |
fdo#38244 enable attaching comments to document text ranges in writer
Change-Id: I1e1ec7e91d513bc34737c7659d1178a02e80c53e
-rw-r--r-- | sw/source/ui/fldui/fldmgr.cxx | 10 | ||||
-rw-r--r-- | sw/source/ui/inc/fldmgr.hxx | 3 | ||||
-rw-r--r-- | sw/source/ui/shells/textfld.cxx | 9 |
3 files changed, 18 insertions, 4 deletions
diff --git a/sw/source/ui/fldui/fldmgr.cxx b/sw/source/ui/fldui/fldmgr.cxx index e33c78e2e244..e465e9fae0af 100644 --- a/sw/source/ui/fldui/fldmgr.cxx +++ b/sw/source/ui/fldui/fldmgr.cxx @@ -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) diff --git a/sw/source/ui/inc/fldmgr.hxx b/sw/source/ui/inc/fldmgr.hxx index eabe9eb63fc0..af18d94bf48b 100644 --- a/sw/source/ui/inc/fldmgr.hxx +++ b/sw/source/ui/inc/fldmgr.hxx @@ -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, diff --git a/sw/source/ui/shells/textfld.cxx b/sw/source/ui/shells/textfld.cxx index 12928188b609..c07f57a219e9 100644 --- a/sw/source/ui/shells/textfld.cxx +++ b/sw/source/ui/shells/textfld.cxx @@ -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(); |