diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-07-19 13:28:30 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-07-20 15:20:50 +0200 |
commit | b11e923a50ca532016fc0802e1d2dfa53efa0679 (patch) | |
tree | 7fe246e47f1463b851b794928d75f985960dec02 | |
parent | 9931d736edfedb9b82a270d754f1ee8a2b134ec7 (diff) |
SwPostItField: add aName member
To handle roundtrip of office:name in ODF.
Change-Id: I35dab189f7b9b8191ca92c647332e2271d4806f9
-rw-r--r-- | offapi/com/sun/star/text/textfield/Annotation.idl | 5 | ||||
-rw-r--r-- | sw/inc/docufld.hxx | 7 | ||||
-rw-r--r-- | sw/qa/core/swdoc-test.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/fields/docufld.cxx | 24 | ||||
-rw-r--r-- | sw/source/core/unocore/unofield.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/unocore/unomap.cxx | 1 | ||||
-rw-r--r-- | sw/source/core/unocore/unoportenum.cxx | 31 | ||||
-rw-r--r-- | sw/source/filter/html/htmlfld.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/html/swhtml.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldmgr.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/wrtsh/wrtsh2.cxx | 3 |
12 files changed, 72 insertions, 14 deletions
diff --git a/offapi/com/sun/star/text/textfield/Annotation.idl b/offapi/com/sun/star/text/textfield/Annotation.idl index db9d7e230265..d21432479519 100644 --- a/offapi/com/sun/star/text/textfield/Annotation.idl +++ b/offapi/com/sun/star/text/textfield/Annotation.idl @@ -43,6 +43,11 @@ published service Annotation @since LibreOffice 3.7 */ [optional, property]string Initials; + /** contains the name of the annotation. + + @since LibreOffice 3.7 + */ + [optional, property]string Name; /** contains the annotation's content */ [property]string Content; diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx index a16aabe1c018..b62b2f68d8d7 100644 --- a/sw/inc/docufld.hxx +++ b/sw/inc/docufld.hxx @@ -520,14 +520,15 @@ class SW_DLLPUBLIC SwPostItField : public SwField { rtl::OUString sTxt; rtl::OUString sAuthor; - rtl::OUString sInitials; + rtl::OUString sInitials; ///< Initials of the author. + rtl::OUString sName; ///< Name of the comment. DateTime aDateTime; OutlinerParaObject* mpText; SwTextAPIObject* m_pTextObject; public: SwPostItField( SwPostItFieldType*, - const String& rAuthor, const String& rTxt, const String& rInitials, const DateTime& rDate); + const String& rAuthor, const String& rTxt, const String& rInitials, const String& rName, const DateTime& rDate); ~SwPostItField(); virtual String Expand() const; @@ -546,6 +547,8 @@ public: virtual void SetPar2(const rtl::OUString& rStr); const rtl::OUString& GetTxt() const { return sTxt; } const rtl::OUString& GetInitials() const; + void SetName(const rtl::OUString& rStr); + const OUString& GetName() const; const OutlinerParaObject* GetTextObject() const; void SetTextObject( OutlinerParaObject* pText ); diff --git a/sw/qa/core/swdoc-test.cxx b/sw/qa/core/swdoc-test.cxx index f76cad3d2c2f..ae4926697fed 100644 --- a/sw/qa/core/swdoc-test.cxx +++ b/sw/qa/core/swdoc-test.cxx @@ -376,7 +376,7 @@ void SwDocTest::testSwScanner() DateTime aDate(DateTime::SYSTEM); SwPostItField aPostIt( (SwPostItFieldType*)m_pDoc->GetSysFldType(RES_POSTITFLD), rtl::OUString("An Author"), - rtl::OUString("Some Text"), rtl::OUString("WhatEver"), aDate ); + rtl::OUString("Some Text"), rtl::OUString("Initials"), OUString("Name"), aDate ); m_pDoc->InsertPoolItem(aPaM, SwFmtFld(aPostIt), 0); m_pDoc->InsertString(aPaM, rtl::OUString("Apple")); diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index 7a2299058857..75e824c24aac 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -1735,8 +1735,8 @@ SwFieldType* SwPostItFieldType::Copy() const --------------------------------------------------------------------*/ SwPostItField::SwPostItField( SwPostItFieldType* pT, - const String& rAuthor, const String& rTxt, const String& rInitials, const DateTime& rDateTime ) - : SwField( pT ), sTxt( rTxt ), sAuthor( rAuthor ), sInitials( rInitials ), aDateTime( rDateTime ), mpText(0), m_pTextObject(0) + const String& rAuthor, const String& rTxt, const String& rInitials, const String& rName, const DateTime& rDateTime ) + : SwField( pT ), sTxt( rTxt ), sAuthor( rAuthor ), sInitials( rInitials ), sName( rName ), aDateTime( rDateTime ), mpText(0), m_pTextObject(0) { } @@ -1765,8 +1765,8 @@ String SwPostItField::GetDescription() const SwField* SwPostItField::Copy() const { - SwPostItField* pRet = new SwPostItField( (SwPostItFieldType*)GetTyp(), sAuthor, sInitials, - sTxt, aDateTime); + SwPostItField* pRet = new SwPostItField( (SwPostItFieldType*)GetTyp(), sAuthor, sTxt, sInitials, sName, + aDateTime); if (mpText) pRet->SetTextObject( new OutlinerParaObject(*mpText) ); return pRet; @@ -1804,6 +1804,16 @@ const rtl::OUString& SwPostItField::GetInitials() const return sInitials; } +void SwPostItField::SetName(const rtl::OUString& rName) +{ + sName = rName; +} + +const rtl::OUString& SwPostItField::GetName() const +{ + return sName; +} + const OutlinerParaObject* SwPostItField::GetTextObject() const { return mpText; @@ -1835,6 +1845,9 @@ bool SwPostItField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const case FIELD_PROP_PAR3: rAny <<= OUString(sInitials); break; + case FIELD_PROP_PAR4: + rAny <<= OUString(sName); + break; case FIELD_PROP_TEXT: { if ( !m_pTextObject ) @@ -1902,6 +1915,9 @@ bool SwPostItField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) case FIELD_PROP_PAR3: rAny >>= sInitials; break; + case FIELD_PROP_PAR4: + rAny >>= sName; + break; case FIELD_PROP_TEXT: OSL_FAIL("Not implemented!"); break; diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 7793e0921c8c..d06ec8cafa8c 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -1246,7 +1246,7 @@ void SwXTextField::attachToRange( aDateTime.SetSec(m_pProps->pDateTime->Seconds); } pFld = new SwPostItField((SwPostItFieldType*)pFldType, - m_pProps->sPar1, m_pProps->sPar2, m_pProps->sPar3, aDateTime); + m_pProps->sPar1, m_pProps->sPar2, m_pProps->sPar3, m_pProps->sPar4, aDateTime); if ( m_pTextObject ) { ((SwPostItField*)pFld)->SetTextObject( m_pTextObject->CreateText() ); @@ -1756,10 +1756,11 @@ void SwXTextField::attachToRange( if (*aPam.GetPoint() != *aPam.GetMark() && m_nServiceId == SW_SERVICE_FIELDTYPE_ANNOTATION) { IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess(); - pMarksAccess->makeFieldBookmark( + sw::mark::IFieldmark* pFieldmark = pMarksAccess->makeFieldBookmark( aPam, OUString(), ODF_COMMENTRANGE); + ((SwPostItField*)aFmt.GetFld())->SetName(pFieldmark->GetName()); // Make sure we always insert the field at the end SwPaM aEnd(*aPam.End(), *aPam.End()); diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index 25e5dd336026..35a7900d06f5 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -1863,6 +1863,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s {SW_PROP_NMID(UNO_NAME_AUTHOR), FIELD_PROP_PAR1, CPPU_E2T(CPPUTYPE_OUSTRING), PROPERTY_NONE, 0}, {SW_PROP_NMID(UNO_NAME_CONTENT), FIELD_PROP_PAR2, CPPU_E2T(CPPUTYPE_OUSTRING), PROPERTY_NONE, 0}, {SW_PROP_NMID(UNO_NAME_INITIALS), FIELD_PROP_PAR3, CPPU_E2T(CPPUTYPE_OUSTRING), PROPERTY_NONE, 0}, + {SW_PROP_NMID(UNO_NAME_NAME), FIELD_PROP_PAR4, CPPU_E2T(CPPUTYPE_OUSTRING), PROPERTY_NONE, 0}, {SW_PROP_NMID(UNO_NAME_DATE_TIME_VALUE), FIELD_PROP_DATE_TIME, CPPU_E2T(CPPUTYPE_DATETIME), PROPERTY_NONE, 0}, {SW_PROP_NMID(UNO_NAME_DATE), FIELD_PROP_DATE, CPPU_E2T(CPPUTYPE_DATE), PROPERTY_NONE, 0}, {SW_PROP_NMID(UNO_NAME_TEXT_RANGE), FIELD_PROP_TEXT, CPPU_E2T(CPPUTYPE_REFINTERFACE), PropertyAttribute::READONLY, 0}, diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index fdfe3c698b1f..ed9ef38515c7 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -54,6 +54,9 @@ #include <unoidx.hxx> #include <redline.hxx> #include <crsskip.hxx> +#include <switerator.hxx> +#include <docufld.hxx> +#include <fmtfld.hxx> #include <osl/mutex.hxx> #include <vcl/svapp.hxx> #include <comphelper/servicehelper.hxx> @@ -326,6 +329,27 @@ lcl_FillFieldMarkArray(FieldMarks_t & rFieldMarks, SwUnoCrsr const & rUnoCrsr, } } +static const SwFmtFld* lcl_getFieldByName(SwDoc* pDoc, const OUString& rName) +{ + const SwFldTypes* pFldTypes = pDoc->GetFldTypes(); + sal_uInt16 nCount = pFldTypes->size(); + for (sal_uInt16 nType = 0; nType < nCount; ++nType) + { + const SwFieldType *pCurType = (*pFldTypes)[nType]; + SwIterator<SwFmtFld, SwFieldType> aIter(*pCurType); + for (const SwFmtFld* pCurFldFmt = aIter.First(); pCurFldFmt; pCurFldFmt = aIter.Next()) + { + if (pCurFldFmt->GetFld()->GetTyp()->Which() != RES_POSTITFLD) + continue; + + const SwPostItField* pField = dynamic_cast<const SwPostItField*>(pCurFldFmt->GetFld()); + if (pField->GetName() == rName) + return pCurFldFmt; + } + } + return 0; +} + static uno::Reference<text::XTextRange> lcl_ExportFieldMark( uno::Reference< text::XText > const & i_xParentText, @@ -359,7 +383,14 @@ lcl_ExportFieldMark( pUnoCrsr, i_xParentText, PORTION_FIELD_START); xRef = pPortion; if (pPortion && pFieldmark && pDoc) + { pPortion->SetBookmark( SwXFieldmark::CreateXFieldmark( *pDoc, *pFieldmark ) ); + Reference<XTextField> xField; + const SwFmtFld* pField = lcl_getFieldByName(pDoc, pFieldmark->GetName()); + if (pField) + xField = SwXTextField::CreateSwXTextField(*pDoc, *pField); + pPortion->SetTextField(xField); + } } else if (CH_TXT_ATR_FIELDEND == Char) { diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx index 46f1bc91668f..f33b797dcbda 100644 --- a/sw/source/filter/html/htmlfld.cxx +++ b/sw/source/filter/html/htmlfld.cxx @@ -656,7 +656,7 @@ void SwHTMLParser::InsertComment( const String& rComment, const sal_Char *pTag ) SwPostItField aPostItFld( (SwPostItFieldType*)pDoc->GetSysFldType( RES_POSTITFLD ), - aEmptyStr, aComment, aEmptyStr, DateTime( DateTime::SYSTEM ) ); + aEmptyStr, aComment, aEmptyStr, aEmptyStr, DateTime( DateTime::SYSTEM ) ); InsertAttr( SwFmtFld( aPostItFld ) ); if( bMoveFwd ) diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 5f100217c76d..18850d56a637 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -5388,7 +5388,7 @@ void SwHTMLParser::ParseMoreMetaOptions() SwPostItField aPostItFld( (SwPostItFieldType*)pDoc->GetSysFldType( RES_POSTITFLD ), - aEmptyStr, sText.makeStringAndClear(), aEmptyStr, DateTime( DateTime::SYSTEM ) ); + aEmptyStr, sText.makeStringAndClear(), aEmptyStr, aEmptyStr, DateTime( DateTime::SYSTEM ) ); SwFmtFld aFmtFld( aPostItFld ); InsertAttr( aFmtFld ); } diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 6acf843cc003..54118d36b768 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1792,7 +1792,7 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes) this->pFmtOfJustInsertedApo = 0; SwPostItField aPostIt( (SwPostItFieldType*)rDoc.GetSysFldType(RES_POSTITFLD), sAuthor, - sTxt, aEmptyStr, aDate ); + sTxt, aEmptyStr, aEmptyStr, aDate ); aPostIt.SetTextObject(pOutliner); pCtrlStck->NewAttr(*pPaM->GetPoint(), SvxCharHiddenItem(false, RES_CHRATR_HIDDEN)); diff --git a/sw/source/ui/fldui/fldmgr.cxx b/sw/source/ui/fldui/fldmgr.cxx index ed483c1d6765..3312a6a7b7bb 100644 --- a/sw/source/ui/fldui/fldmgr.cxx +++ b/sw/source/ui/fldui/fldmgr.cxx @@ -870,7 +870,7 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData, SwPaM *pPam ) case TYP_POSTITFLD: { SwPostItFieldType* pType = (SwPostItFieldType*)pCurShell->GetFldType(0, RES_POSTITFLD); - pFld = new SwPostItField(pType, rData.sPar1, rData.sPar2, aEmptyStr, DateTime( DateTime::SYSTEM )); + pFld = new SwPostItField(pType, rData.sPar1, rData.sPar2, aEmptyStr, aEmptyStr, DateTime( DateTime::SYSTEM )); break; } case TYP_SCRIPTFLD: diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx index f6dda8c04003..17f2c8cc0668 100644 --- a/sw/source/ui/wrtsh/wrtsh2.cxx +++ b/sw/source/ui/wrtsh/wrtsh2.cxx @@ -90,7 +90,8 @@ void SwWrtShell::Insert(SwField &rFld, SwPaM *pCommentRange) { // If an annotation field is inserted, take care of the relevant fieldmark. IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess(); - pMarksAccess->makeFieldBookmark(*pCommentRange, OUString(), ODF_COMMENTRANGE); + sw::mark::IFieldmark* pFieldmark = pMarksAccess->makeFieldBookmark(*pCommentRange, OUString(), ODF_COMMENTRANGE); + ((SwPostItField&)rFld).SetName(pFieldmark->GetName()); } bool bDeleted = false; |