Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 : : *
5 : : * The contents of this file are subject to the Mozilla Public License Version
6 : : * 1.1 (the "License"); you may not use this file except in compliance with
7 : : * the License or as specified alternatively below. You may obtain a copy of
8 : : * the License at http://www.mozilla.org/MPL/
9 : : *
10 : : * Software distributed under the License is distributed on an "AS IS" basis,
11 : : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : : * for the specific language governing rights and limitations under the
13 : : * License.
14 : : *
15 : : * Major Contributor(s):
16 : : * Copyright (C) 2012 Kohei Yoshida <kohei.yoshida@suse.com>
17 : : *
18 : : * All Rights Reserved.
19 : : *
20 : : * For minor contributions see the git repository.
21 : : *
22 : : * Alternatively, the contents of this file may be used under the terms of
23 : : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
24 : : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
25 : : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
26 : : * instead of those above.
27 : : */
28 : :
29 : : #include "editeng/fieldupdater.hxx"
30 : : #include "editeng/flditem.hxx"
31 : : #include "editobj2.hxx"
32 : :
33 : : #include <com/sun/star/text/textfield/Type.hpp>
34 : :
35 : : using namespace com::sun::star;
36 : :
37 : : namespace editeng {
38 : :
39 : : class FieldUpdaterImpl
40 : : {
41 : : BinTextObject& mrObj;
42 : : public:
43 : 389 : FieldUpdaterImpl(EditTextObject& rObj) : mrObj(static_cast<BinTextObject&>(rObj)) {}
44 : 0 : FieldUpdaterImpl(const FieldUpdaterImpl& r) : mrObj(r.mrObj) {}
45 : :
46 : 389 : void updateTableFields(int nTab)
47 : : {
48 : 389 : SfxItemPool* pPool = mrObj.GetPool();
49 : 389 : BinTextObject::ContentInfosType& rContents = mrObj.GetContents();
50 [ + + ]: 794 : for (size_t i = 0; i < rContents.size(); ++i)
51 : : {
52 : 405 : ContentInfo& rContent = rContents[i];
53 : 405 : ContentInfo::XEditAttributesType& rAttribs = rContent.GetAttribs();
54 [ + + ]: 7229 : for (size_t j = 0; j < rAttribs.size(); ++j)
55 : : {
56 [ + - ]: 6824 : XEditAttribute& rAttr = rAttribs[j];
57 : 6824 : const SfxPoolItem* pItem = rAttr.GetItem();
58 [ + + ]: 6824 : if (pItem->Which() != EE_FEATURE_FIELD)
59 : : // This is not a field item.
60 : 6767 : continue;
61 : :
62 : 57 : const SvxFieldItem* pFI = static_cast<const SvxFieldItem*>(pItem);
63 : 57 : const SvxFieldData* pData = pFI->GetField();
64 [ + - ][ + - ]: 57 : if (pData->GetClassId() != text::textfield::Type::TABLE)
65 : : // This is not a table field.
66 : 57 : continue;
67 : :
68 : : // Create a new table field with the new ID, and set it to the
69 : : // attribute object.
70 [ # # ][ # # ]: 0 : SvxFieldItem aNewItem(SvxTableField(nTab), EE_FEATURE_FIELD);
[ # # ]
71 [ # # ][ # # ]: 0 : rAttr.SetItem(pPool->Put(aNewItem));
72 [ # # ]: 6824 : }
73 : : }
74 : 389 : }
75 : : };
76 : :
77 : 389 : FieldUpdater::FieldUpdater(EditTextObject& rObj) : mpImpl(new FieldUpdaterImpl(rObj)) {}
78 : 0 : FieldUpdater::FieldUpdater(const FieldUpdater& r) : mpImpl(new FieldUpdaterImpl(*r.mpImpl)) {}
79 : :
80 : 389 : FieldUpdater::~FieldUpdater()
81 : : {
82 : 389 : delete mpImpl;
83 : 389 : }
84 : :
85 : 389 : void FieldUpdater::updateTableFields(int nTab)
86 : : {
87 : 389 : mpImpl->updateTableFields(nTab);
88 : 389 : }
89 : :
90 : : }
91 : :
92 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|