dbaccess/source/ui/browser/genericcontroller.cxx | 23 --- sw/inc/authfld.hxx | 46 +++---- sw/source/core/fields/authfld.cxx | 145 ++++++----------------- sw/source/core/tox/txmsrt.cxx | 4 sw/source/ui/index/swuiidxmrk.cxx | 9 - sw/source/uibase/fldui/fldmgr.cxx | 8 - 6 files changed, 74 insertions(+), 161 deletions(-)
New commits: commit 3b16e997f69efe2e3f6cdf64fe8fb2727b6ebaa7 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Jan 18 15:38:07 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Jan 21 07:34:09 2019 +0100 cleanup SwAuthEntry manual ref-counting And remove the "handle" nonsense and just pass plain honest pointers to a real type around Change-Id: Ic49443f5f8b20890d8335088331fff81585e8981 Reviewed-on: https://gerrit.libreoffice.org/66615 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/authfld.hxx b/sw/inc/authfld.hxx index 72837f765c65..e03cc4252f1c 100644 --- a/sw/inc/authfld.hxx +++ b/sw/inc/authfld.hxx @@ -22,27 +22,24 @@ #include "swdllapi.h" #include "fldbas.hxx" #include "toxe.hxx" +#include <rtl/ref.hxx> #include <sal/log.hxx> +#include <salhelper/simplereferenceobject.hxx> #include <memory> #include <vector> -class SwAuthEntry +class SwAuthEntry : public salhelper::SimpleReferenceObject { OUString aAuthFields[AUTH_FIELD_END]; - sal_uInt16 nRefCount; public: - SwAuthEntry() : nRefCount(0){} + SwAuthEntry() = default; SwAuthEntry( const SwAuthEntry& rCopy ); bool operator==(const SwAuthEntry& rComp); inline OUString const & GetAuthorField(ToxAuthorityField ePos) const; inline void SetAuthorField(ToxAuthorityField ePos, const OUString& rField); - - void AddRef() { ++nRefCount; } - void RemoveRef() { --nRefCount; } - sal_uInt16 GetRefCount() { return nRefCount; } }; struct SwTOXSortKey @@ -55,19 +52,19 @@ struct SwTOXSortKey }; typedef std::vector<SwTOXSortKey> SortKeyArr; -typedef std::vector<std::unique_ptr<SwAuthEntry>> SwAuthDataArr; +typedef std::vector<rtl::Reference<SwAuthEntry>> SwAuthDataArr; class SW_DLLPUBLIC SwAuthorityFieldType : public SwFieldType { SwDoc* m_pDoc; SwAuthDataArr m_DataArr; - std::vector<sal_IntPtr> m_SequArr; - std::vector<sal_IntPtr> m_SequArrRLHidden; ///< hidden redlines + std::vector<SwAuthEntry*> m_SequArr; + std::vector<SwAuthEntry*> m_SequArrRLHidden; ///< hidden redlines SortKeyArr m_SortKeyArr; sal_Unicode m_cPrefix; sal_Unicode m_cSuffix; - bool m_bIsSequence :1; - bool m_bSortByDocument :1; + bool m_bIsSequence :1; + bool m_bSortByDocument :1; LanguageType m_eLanguage; OUString m_sSortAlgorithm; @@ -83,30 +80,27 @@ public: virtual void QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const override; virtual void PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId ) override; - void SetDoc(SwDoc* pNewDoc) { m_pDoc = pNewDoc; } + void SetDoc(SwDoc* pNewDoc) { m_pDoc = pNewDoc; } SwDoc* GetDoc(){ return m_pDoc; } - void RemoveField(sal_IntPtr nHandle); - sal_IntPtr AddField(const OUString& rFieldContents); - void AddField(sal_IntPtr nHandle); + void RemoveField(const SwAuthEntry* nHandle); + SwAuthEntry* AddField(const OUString& rFieldContents); void DelSequenceArray() { m_SequArr.clear(); m_SequArrRLHidden.clear(); } - const SwAuthEntry* GetEntryByHandle(sal_IntPtr nHandle) const; - void GetAllEntryIdentifiers( std::vector<OUString>& rToFill ) const; - const SwAuthEntry* GetEntryByIdentifier(const OUString& rIdentifier) const; + SwAuthEntry* GetEntryByIdentifier(const OUString& rIdentifier) const; bool ChangeEntryContent(const SwAuthEntry* pNewEntry); // import interface sal_uInt16 AppendField(const SwAuthEntry& rInsert); - sal_IntPtr GetHandle(sal_uInt16 nPos); + SwAuthEntry* GetFieldByPos(sal_uInt16 nPos); - sal_uInt16 GetSequencePos(sal_IntPtr nHandle, SwRootFrame const* pLayout); + sal_uInt16 GetSequencePos(const SwAuthEntry* pAuthEntry, SwRootFrame const* pLayout); - bool IsSequence() const {return m_bIsSequence;} + bool IsSequence() const {return m_bIsSequence;} void SetSequence(bool bSet) { DelSequenceArray(); @@ -121,7 +115,7 @@ public: sal_Unicode GetPrefix() const { return m_cPrefix;} sal_Unicode GetSuffix() const { return m_cSuffix;} - bool IsSortByDocument() const {return m_bSortByDocument;} + bool IsSortByDocument() const {return m_bSortByDocument;} void SetSortByDocument(bool bSet) { DelSequenceArray(); @@ -154,7 +148,7 @@ public: */ class SwAuthorityField : public SwField { - sal_IntPtr m_nHandle; + rtl::Reference<SwAuthEntry> m_xAuthEntry; mutable sal_IntPtr m_nTempSequencePos; mutable sal_IntPtr m_nTempSequencePosRLHidden; ///< hidden redlines @@ -169,7 +163,7 @@ public: SW_DLLPUBLIC OUString ExpandCitation(ToxAuthorityField eField, SwRootFrame const* pLayout) const; SwAuthorityField(SwAuthorityFieldType* pType, const OUString& rFieldContents); - SwAuthorityField(SwAuthorityFieldType* pType, sal_IntPtr nHandle); + SwAuthorityField(SwAuthorityFieldType* pType, SwAuthEntry* pAuthEntry); virtual ~SwAuthorityField() override; OUString GetFieldText(ToxAuthorityField eField) const; @@ -180,7 +174,7 @@ public: virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const override; virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId ) override; - sal_IntPtr GetHandle() const { return m_nHandle; } + SwAuthEntry* GetAuthEntry() const { return m_xAuthEntry.get(); } virtual OUString GetDescription() const override; }; diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx index 1f4a64b7ac2a..705ca88136a6 100644 --- a/sw/source/core/fields/authfld.cxx +++ b/sw/source/core/fields/authfld.cxx @@ -51,7 +51,6 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; SwAuthEntry::SwAuthEntry(const SwAuthEntry& rCopy) - : nRefCount(0) { for(int i = 0; i < AUTH_FIELD_END; ++i) aAuthFields[i] = rCopy.aAuthFields[i]; @@ -85,31 +84,24 @@ SwFieldType* SwAuthorityFieldType::Copy() const return new SwAuthorityFieldType(m_pDoc); } -void SwAuthorityFieldType::RemoveField(sal_IntPtr nHandle) +void SwAuthorityFieldType::RemoveField(const SwAuthEntry* nHandle) { for(SwAuthDataArr::size_type j = 0; j < m_DataArr.size(); ++j) { - SwAuthEntry* pTemp = m_DataArr[j].get(); - sal_IntPtr nRet = reinterpret_cast<sal_IntPtr>(static_cast<void*>(pTemp)); - if(nRet == nHandle) + if(m_DataArr[j].get() == nHandle) { - pTemp->RemoveRef(); - if(!pTemp->GetRefCount()) - { - m_DataArr.erase(m_DataArr.begin() + j); - //re-generate positions of the fields - DelSequenceArray(); - } + m_DataArr.erase(m_DataArr.begin() + j); + //re-generate positions of the fields + DelSequenceArray(); return; } } OSL_FAIL("Field unknown" ); } -sal_IntPtr SwAuthorityFieldType::AddField(const OUString& rFieldContents) +SwAuthEntry* SwAuthorityFieldType::AddField(const OUString& rFieldContents) { - sal_IntPtr nRet = 0; - std::unique_ptr<SwAuthEntry> pEntry(new SwAuthEntry); + rtl::Reference<SwAuthEntry> pEntry(new SwAuthEntry); for( sal_Int32 i = 0; i < AUTH_FIELD_END; ++i ) pEntry->SetAuthorField( static_cast<ToxAuthorityField>(i), rFieldContents.getToken( i, TOX_STYLE_DELIMITER )); @@ -118,50 +110,15 @@ sal_IntPtr SwAuthorityFieldType::AddField(const OUString& rFieldContents) { if (*rpTemp == *pEntry) { - nRet = reinterpret_cast<sal_IntPtr>(static_cast<void*>(rpTemp.get())); - rpTemp->AddRef(); - return nRet; + return rpTemp.get(); } } //if it is a new Entry - insert - nRet = reinterpret_cast<sal_IntPtr>(static_cast<void*>(pEntry.get())); - // FIXME: what is this ref-counting madness on a object owned by the container? - pEntry->AddRef(); m_DataArr.push_back(std::move(pEntry)); //re-generate positions of the fields DelSequenceArray(); - return nRet; -} - -void SwAuthorityFieldType::AddField(sal_IntPtr nHandle) -{ - for (auto &rpTemp : m_DataArr) - { - sal_IntPtr nTmp = reinterpret_cast<sal_IntPtr>(static_cast<void*>(rpTemp.get())); - if( nTmp == nHandle ) - { - rpTemp->AddRef(); - //re-generate positions of the fields - DelSequenceArray(); - return; - } - } - OSL_FAIL("SwAuthorityFieldType::AddField(sal_IntPtr) failed"); -} - -const SwAuthEntry* SwAuthorityFieldType::GetEntryByHandle(sal_IntPtr nHandle) const -{ - for (auto &rpTemp : m_DataArr) - { - sal_IntPtr nTmp = reinterpret_cast<sal_IntPtr>(static_cast<void const *>(rpTemp.get())); - if( nTmp == nHandle ) - { - return rpTemp.get(); - } - } - OSL_FAIL( "invalid Handle" ); - return nullptr; + return m_DataArr.back().get(); } void SwAuthorityFieldType::GetAllEntryIdentifiers( @@ -173,7 +130,7 @@ void SwAuthorityFieldType::GetAllEntryIdentifiers( } } -const SwAuthEntry* SwAuthorityFieldType::GetEntryByIdentifier( +SwAuthEntry* SwAuthorityFieldType::GetEntryByIdentifier( const OUString& rIdentifier)const { for (const auto &rpTemp : m_DataArr) @@ -209,30 +166,21 @@ sal_uInt16 SwAuthorityFieldType::AppendField( const SwAuthEntry& rInsert ) { for( SwAuthDataArr::size_type nRet = 0; nRet < m_DataArr.size(); ++nRet ) { - SwAuthEntry* pTemp = m_DataArr[ nRet ].get(); - if( *pTemp == rInsert ) - { - //ref count unchanged + if( *m_DataArr[ nRet ] == rInsert ) return nRet; - } } //if it is a new Entry - insert - m_DataArr.push_back(o3tl::make_unique<SwAuthEntry>(rInsert)); + m_DataArr.push_back(new SwAuthEntry(rInsert)); return m_DataArr.size()-1; } -sal_IntPtr SwAuthorityFieldType::GetHandle(sal_uInt16 nPos) +SwAuthEntry* SwAuthorityFieldType::GetFieldByPos(sal_uInt16 nPos) { - if( nPos < m_DataArr.size() ) - { - SwAuthEntry* pTemp = m_DataArr[nPos].get(); - return reinterpret_cast<sal_IntPtr>(static_cast<void*>(pTemp)); - } - return 0; + return m_DataArr[nPos].get(); } -sal_uInt16 SwAuthorityFieldType::GetSequencePos(sal_IntPtr nHandle, +sal_uInt16 SwAuthorityFieldType::GetSequencePos(const SwAuthEntry* pAuthEntry, SwRootFrame const*const pLayout) { //find the field in a sorted array of handles, @@ -258,7 +206,7 @@ sal_uInt16 SwAuthorityFieldType::GetSequencePos(sal_IntPtr nHandle, if(!pTextField || !pTextField->GetpTextNode()) { #if OSL_DEBUG_LEVEL > 0 - if(nHandle == static_cast<SwAuthorityField*>(pFormatField->GetField())->GetHandle()) + if(pAuthEntry == static_cast<SwAuthorityField*>(pFormatField->GetField())->GetAuthEntry()) bCurrentFieldWithoutTextNode = true; #endif continue; @@ -326,20 +274,20 @@ sal_uInt16 SwAuthorityFieldType::GetSequencePos(sal_IntPtr nHandle, { SwFormatField& rFormatField = static_cast<SwTOXAuthority&>(*pBase).GetFieldFormat(); SwAuthorityField* pAField = static_cast<SwAuthorityField*>(rFormatField.GetField()); - m_SequArr.push_back(pAField->GetHandle()); + m_SequArr.push_back(pAField->GetAuthEntry()); } for (auto & pBase : aSortArrRLHidden) { SwFormatField& rFormatField = static_cast<SwTOXAuthority&>(*pBase).GetFieldFormat(); SwAuthorityField* pAField = static_cast<SwAuthorityField*>(rFormatField.GetField()); - m_SequArrRLHidden.push_back(pAField->GetHandle()); + m_SequArrRLHidden.push_back(pAField->GetAuthEntry()); } } //find nHandle auto const& rSequArr(pLayout && pLayout->IsHideRedlines() ? m_SequArrRLHidden : m_SequArr); for (std::vector<sal_IntPtr>::size_type i = 0; i < rSequArr.size(); ++i) { - if (rSequArr[i] == nHandle) + if (rSequArr[i] == pAuthEntry) { return i + 1; } @@ -516,22 +464,21 @@ SwAuthorityField::SwAuthorityField( SwAuthorityFieldType* pInitType, , m_nTempSequencePos( -1 ) , m_nTempSequencePosRLHidden( -1 ) { - m_nHandle = pInitType->AddField( rFieldContents ); + m_xAuthEntry = pInitType->AddField( rFieldContents ); } SwAuthorityField::SwAuthorityField( SwAuthorityFieldType* pInitType, - sal_IntPtr nSetHandle ) + SwAuthEntry* pAuthEntry ) : SwField( pInitType ) - , m_nHandle( nSetHandle ) + , m_xAuthEntry( pAuthEntry ) , m_nTempSequencePos( -1 ) , m_nTempSequencePosRLHidden( -1 ) { - pInitType->AddField( m_nHandle ); } SwAuthorityField::~SwAuthorityField() { - static_cast<SwAuthorityFieldType* >(GetTyp())->RemoveField(m_nHandle); + static_cast<SwAuthorityFieldType* >(GetTyp())->RemoveField(m_xAuthEntry.get()); } OUString SwAuthorityField::ExpandImpl(SwRootFrame const*const pLayout) const @@ -552,16 +499,15 @@ OUString SwAuthorityField::ConditionalExpandAuthIdentifier( sal_IntPtr & rnTempSequencePos(pLayout && pLayout->IsHideRedlines() ? m_nTempSequencePosRLHidden : m_nTempSequencePos); if(!pAuthType->GetDoc()->getIDocumentFieldsAccess().IsExpFieldsLocked()) - rnTempSequencePos = pAuthType->GetSequencePos(m_nHandle, pLayout); + rnTempSequencePos = pAuthType->GetSequencePos(m_xAuthEntry.get(), pLayout); if (0 <= rnTempSequencePos) sRet += OUString::number(rnTempSequencePos); } else { - const SwAuthEntry* pEntry = pAuthType->GetEntryByHandle(m_nHandle); //TODO: Expand to: identifier, number sequence, ... - if(pEntry) - sRet += pEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER); + if(m_xAuthEntry) + sRet += m_xAuthEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER); } if(pAuthType->GetSuffix()) sRet += OUStringLiteral1(pAuthType->GetSuffix()); @@ -579,16 +525,15 @@ OUString SwAuthorityField::ExpandCitation(ToxAuthorityField eField, sal_IntPtr & rnTempSequencePos(pLayout && pLayout->IsHideRedlines() ? m_nTempSequencePosRLHidden : m_nTempSequencePos); if(!pAuthType->GetDoc()->getIDocumentFieldsAccess().IsExpFieldsLocked()) - rnTempSequencePos = pAuthType->GetSequencePos(m_nHandle, pLayout); + rnTempSequencePos = pAuthType->GetSequencePos(m_xAuthEntry.get(), pLayout); if (0 <= rnTempSequencePos) sRet += OUString::number(rnTempSequencePos); } else { - const SwAuthEntry* pEntry = pAuthType->GetEntryByHandle(m_nHandle); //TODO: Expand to: identifier, number sequence, ... - if(pEntry) - sRet += pEntry->GetAuthorField(eField); + if(m_xAuthEntry) + sRet += m_xAuthEntry->GetAuthorField(eField); } return sRet; } @@ -596,21 +541,19 @@ OUString SwAuthorityField::ExpandCitation(ToxAuthorityField eField, std::unique_ptr<SwField> SwAuthorityField::Copy() const { SwAuthorityFieldType* pAuthType = static_cast<SwAuthorityFieldType*>(GetTyp()); - return o3tl::make_unique<SwAuthorityField>(pAuthType, m_nHandle); + return o3tl::make_unique<SwAuthorityField>(pAuthType, m_xAuthEntry.get()); } OUString SwAuthorityField::GetFieldText(ToxAuthorityField eField) const { - SwAuthorityFieldType* pAuthType = static_cast<SwAuthorityFieldType*>(GetTyp()); - const SwAuthEntry* pEntry = pAuthType->GetEntryByHandle( m_nHandle ); - return pEntry->GetAuthorField( eField ); + return m_xAuthEntry->GetAuthorField( eField ); } -void SwAuthorityField::SetPar1(const OUString& rStr) +void SwAuthorityField::SetPar1(const OUString& rStr) { SwAuthorityFieldType* pInitType = static_cast<SwAuthorityFieldType* >(GetTyp()); - pInitType->RemoveField(m_nHandle); - m_nHandle = pInitType->AddField(rStr); + pInitType->RemoveField(m_xAuthEntry.get()); + m_xAuthEntry = pInitType->AddField(rStr); } OUString SwAuthorityField::GetDescription() const @@ -657,15 +600,14 @@ bool SwAuthorityField::QueryValue( Any& rAny, sal_uInt16 /*nWhichId*/ ) const { if(!GetTyp()) return false; - const SwAuthEntry* pAuthEntry = static_cast<SwAuthorityFieldType*>(GetTyp())->GetEntryByHandle(m_nHandle); - if(!pAuthEntry) + if(!m_xAuthEntry) return false; Sequence <PropertyValue> aRet(AUTH_FIELD_END); PropertyValue* pValues = aRet.getArray(); for(int i = 0; i < AUTH_FIELD_END; ++i) { pValues[i].Name = OUString::createFromAscii(aFieldNames[i]); - const OUString& sField = pAuthEntry->GetAuthorField(static_cast<ToxAuthorityField>(i)); + const OUString& sField = m_xAuthEntry->GetAuthorField(static_cast<ToxAuthorityField>(i)); if(i == AUTH_FIELD_AUTHORITY_TYPE) pValues[i].Value <<= sal_Int16(sField.toInt32()); else @@ -686,7 +628,7 @@ static sal_Int32 lcl_Find(const OUString& rFieldName) bool SwAuthorityField::PutValue( const Any& rAny, sal_uInt16 /*nWhichId*/ ) { - if(!GetTyp() || !static_cast<SwAuthorityFieldType*>(GetTyp())->GetEntryByHandle(m_nHandle)) + if(!GetTyp() || !m_xAuthEntry) return false; Sequence <PropertyValue> aParam; @@ -715,8 +657,8 @@ bool SwAuthorityField::PutValue( const Any& rAny, sal_uInt16 /*nWhichId*/ ) } } - static_cast<SwAuthorityFieldType*>(GetTyp())->RemoveField(m_nHandle); - m_nHandle = static_cast<SwAuthorityFieldType*>(GetTyp())->AddField(sToSet); + static_cast<SwAuthorityFieldType*>(GetTyp())->RemoveField(m_xAuthEntry.get()); + m_xAuthEntry = static_cast<SwAuthorityFieldType*>(GetTyp())->AddField(sToSet); /* FIXME: it is weird that we always return false here */ return false; @@ -728,12 +670,9 @@ SwFieldType* SwAuthorityField::ChgTyp( SwFieldType* pFieldTyp ) * pDstTyp = static_cast<SwAuthorityFieldType*>(pFieldTyp); if( pSrcTyp != pDstTyp ) { - - const SwAuthEntry* pEntry = pSrcTyp->GetEntryByHandle( m_nHandle ); - sal_uInt16 nHdlPos = pDstTyp->AppendField( *pEntry ); - pSrcTyp->RemoveField( m_nHandle ); - m_nHandle = pDstTyp->GetHandle( nHdlPos ); - pDstTyp->AddField( m_nHandle ); + const SwAuthEntry* pSrcEntry = m_xAuthEntry.get(); + pDstTyp->AppendField( *pSrcEntry ); + pSrcTyp->RemoveField( pSrcEntry ); SwField::ChgTyp( pFieldTyp ); } return pSrcTyp; diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx index 61ec0aad10f0..78391110d16d 100644 --- a/sw/source/core/tox/txmsrt.cxx +++ b/sw/source/core/tox/txmsrt.cxx @@ -815,8 +815,8 @@ void SwTOXAuthority::FillText( SwTextNode& rNd, bool SwTOXAuthority::equivalent(const SwTOXSortTabBase& rCmp) { return nType == rCmp.nType && - static_cast<SwAuthorityField*>(m_rField.GetField())->GetHandle() == - static_cast<SwAuthorityField*>(static_cast<const SwTOXAuthority&>(rCmp).m_rField.GetField())->GetHandle(); + static_cast<SwAuthorityField*>(m_rField.GetField())->GetAuthEntry() == + static_cast<SwAuthorityField*>(static_cast<const SwTOXAuthority&>(rCmp).m_rField.GetField())->GetAuthEntry(); } bool SwTOXAuthority::sort_lt(const SwTOXSortTabBase& rBase) diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index dd0676bc0818..5929635026fb 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -1225,10 +1225,10 @@ IMPL_LINK_NOARG(SwAuthorMarkPane, InsertHdl, weld::Button&, void) { if(bDifferent) { - SwAuthEntry aNewData; + rtl::Reference<SwAuthEntry> xNewData(new SwAuthEntry); for(int i = 0; i < AUTH_FIELD_END; i++) - aNewData.SetAuthorField(static_cast<ToxAuthorityField>(i), m_sFields[i]); - pSh->ChangeAuthorityData(&aNewData); + xNewData->SetAuthorField(static_cast<ToxAuthorityField>(i), m_sFields[i]); + pSh->ChangeAuthorityData(xNewData.get()); } SwInsertField_Data aData(TYP_AUTHORITY, 0, sFields.makeStringAndClear(), OUString(), 0 ); aMgr.InsertField( aData ); @@ -1417,8 +1417,7 @@ void SwAuthorMarkPane::InitControls() if(bNewEntry || !pField || pField->GetTyp()->Which() != SwFieldIds::TableOfAuthorities) return; - const SwAuthEntry* pEntry = static_cast<SwAuthorityFieldType*>(pField->GetTyp())-> - GetEntryByHandle(static_cast<SwAuthorityField*>(pField)->GetHandle()); + const SwAuthEntry* pEntry = static_cast<SwAuthorityField*>(pField)->GetAuthEntry(); OSL_ENSURE(pEntry, "No authority entry found"); if(!pEntry) diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index b25e57b13f39..e54397e9c3f5 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -1653,17 +1653,17 @@ void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat, //#i99069# changes to a bibliography field should change the field type SwAuthorityField* pAuthorityField = static_cast<SwAuthorityField*>(pTmpField.get()); SwAuthorityFieldType* pAuthorityType = static_cast<SwAuthorityFieldType*>(pType); - SwAuthEntry aTempEntry; + rtl::Reference<SwAuthEntry> xTempEntry(new SwAuthEntry); for( sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i ) - aTempEntry.SetAuthorField( static_cast<ToxAuthorityField>(i), + xTempEntry->SetAuthorField( static_cast<ToxAuthorityField>(i), rPar1.getToken( i, TOX_STYLE_DELIMITER )); - if( pAuthorityType->ChangeEntryContent( &aTempEntry ) ) + if( pAuthorityType->ChangeEntryContent( xTempEntry.get() ) ) { pType->UpdateFields(); pSh->SetModified(); } - if( aTempEntry.GetAuthorField( AUTH_FIELD_IDENTIFIER ) == + if( xTempEntry->GetAuthorField( AUTH_FIELD_IDENTIFIER ) == pAuthorityField->GetFieldText( AUTH_FIELD_IDENTIFIER ) ) bSetPar1 = false; //otherwise it's a new or changed entry, the field needs to be updated bSetPar2 = false; commit 2af5d6006948890229d9e55feb56e0e849bf857d Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Jan 18 13:12:20 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Jan 21 07:33:57 2019 +0100 use comphelper::containerToSequence in OGenericUnoController Change-Id: If58a22a3d9536ade5f63a3708fd0b6c53f2e21c3 Reviewed-on: https://gerrit.libreoffice.org/66585 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx index f990224b11c4..e99725deb228 100644 --- a/dbaccess/source/ui/browser/genericcontroller.cxx +++ b/dbaccess/source/ui/browser/genericcontroller.cxx @@ -1204,37 +1204,18 @@ Sequence< ::sal_Int16 > SAL_CALL OGenericUnoController::getSupportedCommandGroup return comphelper::mapKeysToSequence( aCmdHashMap ); } -namespace -{ - //Current c++0x draft (apparently) has std::identity, but not operator() - template<typename T> struct SGI_identity - { - T& operator()(T& x) const { return x; } - const T& operator()(const T& x) const { return x; } - }; -} - Sequence< DispatchInformation > SAL_CALL OGenericUnoController::getConfigurableDispatchInformation( ::sal_Int16 CommandGroup ) { std::vector< DispatchInformation > aInformationVector; - DispatchInformation aDispatchInfo; for (auto const& supportedFeature : m_aSupportedFeatures) { if ( sal_Int16( supportedFeature.second.GroupId ) == CommandGroup ) { - aDispatchInfo = supportedFeature.second; - aInformationVector.push_back( aDispatchInfo ); + aInformationVector.push_back( supportedFeature.second ); } } - Sequence< DispatchInformation > aInformation( aInformationVector.size() ); - std::transform( aInformationVector.begin(), - aInformationVector.end(), - aInformation.getArray(), - SGI_identity< DispatchInformation >() - ); - - return aInformation; + return comphelper::containerToSequence( aInformationVector ); } void OGenericUnoController::fillSupportedFeatures() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits