[Libreoffice-commits] core.git: 2 commits - sw/source

Bjoern Michaelsen (via logerrit) logerrit at kemper.freedesktop.org
Sun Mar 15 10:40:52 UTC 2020


 sw/source/core/edit/edfldexp.cxx |   40 +++++++++++++++------------------------
 sw/source/core/fields/dbfld.cxx  |   23 ++++++++++------------
 2 files changed, 27 insertions(+), 36 deletions(-)

New commits:
commit 28411a70596841a974343be5696320aaaad8dae8
Author:     Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
AuthorDate: Sun Mar 15 02:49:07 2020 +0100
Commit:     Björn Michaelsen <bjoern.michaelsen at libreoffice.org>
CommitDate: Sun Mar 15 11:40:23 2020 +0100

    SwDbField::PutValue: SwIterator no more ...
    
    Change-Id: I5919cf91f342bbd29bad994e4094a3e5490aab21
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90509
    Tested-by: Jenkins
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at libreoffice.org>

diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx
index fbc13f796109..abc9fbd375a8 100644
--- a/sw/source/core/fields/dbfld.cxx
+++ b/sw/source/core/fields/dbfld.cxx
@@ -402,20 +402,19 @@ bool SwDBField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
             nSubTyp |= nsSwExtendedSubType::SUB_INVISIBLE;
         SetSubType(nSubTyp);
         //invalidate text node
-        if(GetTyp())
+        auto pType = GetTyp();
+        if(!pType)
+            break;
+        std::vector<SwFormatField*> vFields;
+        pType->GatherFields(vFields, false);
+        for(auto pFormatField: vFields)
         {
-            SwIterator<SwFormatField,SwFieldType> aIter( *GetTyp() );
-            SwFormatField* pFormatField = aIter.First();
-            while(pFormatField)
+            SwTextField* pTextField = pFormatField->GetTextField();
+            if(pTextField && static_cast<SwDBField*>(pFormatField->GetField()) == this)
             {
-                SwTextField *pTextField = pFormatField->GetTextField();
-                if(pTextField && static_cast<SwDBField*>(pFormatField->GetField()) == this )
-                {
-                    //notify the change
-                    pTextField->NotifyContentChange(*pFormatField);
-                    break;
-                }
-                pFormatField = aIter.Next();
+                //notify the change
+                pTextField->NotifyContentChange(*pFormatField);
+                break;
             }
         }
     }
commit 7dcda8121bf70bcb95edf82d97e94f44c13255d9
Author:     Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
AuthorDate: Sun Mar 15 01:34:00 2020 +0100
Commit:     Björn Michaelsen <bjoern.michaelsen at libreoffice.org>
CommitDate: Sun Mar 15 11:40:15 2020 +0100

    edfldexp.cxx: SwIterator no more ...
    
    Change-Id: I3b7aba9c9020e253116940dbe5cd75a047b2e2e0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90508
    Tested-by: Jenkins
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at libreoffice.org>

diff --git a/sw/source/core/edit/edfldexp.cxx b/sw/source/core/edit/edfldexp.cxx
index ff2d0d1cdcc4..c0a8fef2af87 100644
--- a/sw/source/core/edit/edfldexp.cxx
+++ b/sw/source/core/edit/edfldexp.cxx
@@ -34,33 +34,25 @@ bool SwEditShell::IsFieldDataSourceAvailable(OUString& rUsedDataSource) const
     const SwFieldTypes * pFieldTypes = GetDoc()->getIDocumentFieldsAccess().GetFieldTypes();
     uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
     uno::Reference<sdb::XDatabaseContext> xDBContext = sdb::DatabaseContext::create(xContext);
-    for(const auto & pFieldType : *pFieldTypes)
+    std::vector<SwFormatField*> vFields;
+    for(const auto& pFieldType : *pFieldTypes)
     {
         if(IsUsed(*pFieldType) && pFieldType->Which() == SwFieldIds::Database)
-        {
-            SwIterator<SwFormatField,SwFieldType> aIter( *pFieldType );
-            SwFormatField* pFormatField = aIter.First();
-            while(pFormatField)
-            {
-                if(pFormatField->IsFieldInDoc())
-                {
-                    const SwDBData& rData =
-                            static_cast<SwDBFieldType*>(pFormatField->GetField()->GetTyp())->GetDBData();
-                    try
-                    {
-                        return xDBContext->getByName(rData.sDataSource).hasValue();
-                    }
-                    catch(uno::Exception const &)
-                    {
-                        rUsedDataSource = rData.sDataSource;
-                        return false;
-                    }
-                }
-                pFormatField = aIter.Next();
-            }
-        }
+            pFieldType->GatherFields(vFields);
+    }
+    if(!vFields.size())
+        return true;
+
+    const SwDBData& rData = static_cast<SwDBFieldType*>(vFields.front()->GetField()->GetTyp())->GetDBData();
+    try
+    {
+        return xDBContext->getByName(rData.sDataSource).hasValue();
+    }
+    catch(uno::Exception const &)
+    {
+        rUsedDataSource = rData.sDataSource;
+        return false;
     }
-    return true;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list