LCOV - code coverage report
Current view: top level - editeng/source/editeng - fieldupdater.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 16 29 55.2 %
Date: 2015-06-13 12:38:46 Functions: 5 7 71.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include "editeng/fieldupdater.hxx"
      11             : #include "editeng/flditem.hxx"
      12             : #include "editobj2.hxx"
      13             : 
      14             : #include <com/sun/star/text/textfield/Type.hpp>
      15             : 
      16             : using namespace com::sun::star;
      17             : 
      18             : namespace editeng {
      19             : 
      20             : class FieldUpdaterImpl
      21             : {
      22             :     EditTextObjectImpl& mrObj;
      23             : public:
      24          24 :     FieldUpdaterImpl(EditTextObject& rObj) : mrObj(*rObj.mpImpl) {}
      25           0 :     FieldUpdaterImpl(const FieldUpdaterImpl& r) : mrObj(r.mrObj) {}
      26             : 
      27          24 :     void updateTableFields(int nTab)
      28             :     {
      29          24 :         SfxItemPool* pPool = mrObj.GetPool();
      30          24 :         EditTextObjectImpl::ContentInfosType& rContents = mrObj.GetContents();
      31          48 :         for (size_t i = 0; i < rContents.size(); ++i)
      32             :         {
      33          24 :             ContentInfo& rContent = rContents[i];
      34          24 :             ContentInfo::XEditAttributesType& rAttribs = rContent.GetAttribs();
      35          24 :             for (size_t j = 0; j < rAttribs.size(); ++j)
      36             :             {
      37           0 :                 XEditAttribute& rAttr = rAttribs[j];
      38           0 :                 const SfxPoolItem* pItem = rAttr.GetItem();
      39           0 :                 if (pItem->Which() != EE_FEATURE_FIELD)
      40             :                     // This is not a field item.
      41           0 :                     continue;
      42             : 
      43           0 :                 const SvxFieldItem* pFI = static_cast<const SvxFieldItem*>(pItem);
      44           0 :                 const SvxFieldData* pData = pFI->GetField();
      45           0 :                 if (pData->GetClassId() != text::textfield::Type::TABLE)
      46             :                     // This is not a table field.
      47           0 :                     continue;
      48             : 
      49             :                 // Create a new table field with the new ID, and set it to the
      50             :                 // attribute object.
      51           0 :                 SvxFieldItem aNewItem(SvxTableField(nTab), EE_FEATURE_FIELD);
      52           0 :                 rAttr.SetItem(pPool->Put(aNewItem));
      53           0 :             }
      54             :         }
      55          24 :     }
      56             : };
      57             : 
      58          24 : FieldUpdater::FieldUpdater(EditTextObject& rObj) : mpImpl(new FieldUpdaterImpl(rObj)) {}
      59           0 : FieldUpdater::FieldUpdater(const FieldUpdater& r) : mpImpl(new FieldUpdaterImpl(*r.mpImpl)) {}
      60             : 
      61          24 : FieldUpdater::~FieldUpdater()
      62             : {
      63          24 :     delete mpImpl;
      64          24 : }
      65             : 
      66          24 : void FieldUpdater::updateTableFields(int nTab)
      67             : {
      68          24 :     mpImpl->updateTableFields(nTab);
      69          24 : }
      70             : 
      71             : }
      72             : 
      73             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11