diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-03-27 16:08:37 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-03-27 16:35:45 +0100 |
commit | 5ddcaa86003c6a28c4a9b307cdf3b37deabaa5a4 (patch) | |
tree | f738855a29b60ecd6ae069443a87afbf3d4e8e35 /sw | |
parent | fdo#39445 writing out tools/fsys.hxx (forms) (diff) | |
download | core-5ddcaa86003c6a28c4a9b307cdf3b37deabaa5a4.tar.gz core-5ddcaa86003c6a28c4a9b307cdf3b37deabaa5a4.zip |
SwPostItField::GetByName: make this available for the layout as well
Change-Id: Ic2a2d759d855cecadb8429541d0a7665a6deaa4b
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/docufld.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/fields/docufld.cxx | 22 | ||||
-rw-r--r-- | sw/source/core/unocore/unoportenum.cxx | 24 |
3 files changed, 27 insertions, 23 deletions
diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx index 0779b256dd69..35ea4c156154 100644 --- a/sw/inc/docufld.hxx +++ b/sw/inc/docufld.hxx @@ -34,6 +34,7 @@ class SwTxtFld; class SwFrm; class OutlinerParaObject; class SwTextAPIObject; +class SwFmtFld; enum SwAuthorFormat { @@ -530,6 +531,9 @@ public: const String& rAuthor, const String& rTxt, const String& rInitials, const String& rName, const DateTime& rDate); ~SwPostItField(); + /// Looks up a field identified by its unique name (used to get the postit field of a comment fieldmark) + static const SwFmtFld* GetByName(SwDoc* pDoc, const OUString& rName); + virtual String Expand() const; virtual SwField* Copy() const; diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index 5a2e88a3e3f0..98bb00f9f77d 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -92,6 +92,7 @@ #include <editeng/outliner.hxx> #include <editeng/outlobj.hxx> #include <switerator.hxx> +#include <docary.hxx> #define URL_DECODE INetURLObject::DECODE_UNAMBIGUOUS @@ -1753,6 +1754,27 @@ SwPostItField::~SwPostItField() } } +const SwFmtFld* SwPostItField::GetByName(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()) + { + // Ignore the field if it's not an annotation or it doesn't have an anchor. + if (pCurFldFmt->GetFld()->GetTyp()->Which() != RES_POSTITFLD || !pCurFldFmt->GetTxtFld()) + continue; + + const SwPostItField* pField = dynamic_cast<const SwPostItField*>(pCurFldFmt->GetFld()); + if (pField->GetName() == rName) + return pCurFldFmt; + } + } + return 0; +} String SwPostItField::Expand() const { diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index dcc7563bd671..3d64484670d0 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -322,28 +322,6 @@ 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()) - { - // Ignore the field if it's not an annotation or it doesn't have an anchor. - if (pCurFldFmt->GetFld()->GetTyp()->Which() != RES_POSTITFLD || !pCurFldFmt->GetTxtFld()) - 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, @@ -380,7 +358,7 @@ lcl_ExportFieldMark( { pPortion->SetBookmark( SwXFieldmark::CreateXFieldmark( *pDoc, *pFieldmark ) ); Reference<XTextField> xField; - const SwFmtFld* pField = lcl_getFieldByName(pDoc, pFieldmark->GetName()); + const SwFmtFld* pField = SwPostItField::GetByName(pDoc, pFieldmark->GetName()); if (pField) xField = SwXTextField::CreateSwXTextField(*pDoc, *pField); pPortion->SetTextField(xField); |