LibreOffice Module editeng (master)
1
editeng
source
editeng
fieldupdater.cxx
Go to the documentation of this file.
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 <memory>
11
#include <
editeng/fieldupdater.hxx
>
12
#include <
editeng/flditem.hxx
>
13
#include "
editobj2.hxx
"
14
15
#include <com/sun/star/text/textfield/Type.hpp>
16
17
using namespace
com::sun::star
;
18
19
namespace
editeng
{
20
21
class
FieldUpdaterImpl
22
{
23
EditTextObjectImpl
&
mrObj
;
24
public
:
25
explicit
FieldUpdaterImpl
(
EditTextObject
& rObj) :
mrObj
(
toImpl
(rObj)) {}
26
27
void
updateTableFields
(
int
nTab)
28
{
29
SfxItemPool
* pPool =
mrObj
.
GetPool
();
30
EditTextObjectImpl::ContentInfosType
& rContents =
mrObj
.
GetContents
();
31
for
(std::unique_ptr<ContentInfo> &
i
: rContents)
32
{
33
ContentInfo
& rContent = *
i
;
34
for
(
XEditAttribute
& rAttr : rContent.
GetCharAttribs
())
35
{
36
const
SfxPoolItem
* pItem = rAttr.GetItem();
37
if
(pItem->
Which
() !=
EE_FEATURE_FIELD
)
38
// This is not a field item.
39
continue
;
40
41
const
SvxFieldItem
* pFI =
static_cast<
const
SvxFieldItem
*
>
(pItem);
42
const
SvxFieldData
*
pData
= pFI->
GetField
();
43
if
(
pData
->GetClassId() != text::textfield::Type::TABLE)
44
// This is not a table field.
45
continue
;
46
47
// Create a new table field with the new ID, and set it to the
48
// attribute object.
49
SvxFieldItem
aNewItem(
SvxTableField
(nTab),
EE_FEATURE_FIELD
);
50
rAttr.SetItem(pPool->
Put
(aNewItem));
51
}
52
}
53
}
54
};
55
56
FieldUpdater::FieldUpdater
(
EditTextObject
& rObj) : mpImpl(new
FieldUpdaterImpl
(rObj)) {}
57
FieldUpdater::FieldUpdater
(
const
FieldUpdater
& r) : mpImpl(new
FieldUpdaterImpl
(*r.mpImpl)) {}
58
59
FieldUpdater::~FieldUpdater
()
60
{
61
}
62
63
void
FieldUpdater::updateTableFields
(
int
nTab)
64
{
65
mpImpl
->updateTableFields(nTab);
66
}
67
68
}
69
70
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ContentInfo
Definition:
editobj2.hxx:120
ContentInfo::GetCharAttribs
const std::vector< XEditAttribute > & GetCharAttribs() const
Definition:
editobj2.hxx:148
EditTextObjectImpl
Definition:
editobj2.hxx:173
EditTextObjectImpl::ContentInfosType
std::vector< std::unique_ptr< ContentInfo > > ContentInfosType
Definition:
editobj2.hxx:175
EditTextObjectImpl::GetPool
SfxItemPool * GetPool()
Definition:
editobj2.hxx:223
EditTextObjectImpl::GetContents
ContentInfosType & GetContents()
Definition:
editobj2.hxx:221
EditTextObject
Definition:
editobj.hxx:58
SfxItemPool::Put
const T & Put(std::unique_ptr< T > xItem, sal_uInt16 nWhich=0)
SfxPoolItem
SfxPoolItem::Which
sal_uInt16 Which() const
SvxFieldData
Definition:
flditem.hxx:41
SvxFieldItem
This item stores a field (SvxFieldData).
Definition:
flditem.hxx:70
SvxFieldItem::GetField
const SvxFieldData * GetField() const
Definition:
flditem.hxx:81
SvxTableField
Definition:
flditem.hxx:238
XEditAttribute
Definition:
editobj2.hxx:48
editeng::FieldUpdaterImpl
Definition:
fieldupdater.cxx:22
editeng::FieldUpdaterImpl::FieldUpdaterImpl
FieldUpdaterImpl(EditTextObject &rObj)
Definition:
fieldupdater.cxx:25
editeng::FieldUpdaterImpl::updateTableFields
void updateTableFields(int nTab)
Definition:
fieldupdater.cxx:27
editeng::FieldUpdaterImpl::mrObj
EditTextObjectImpl & mrObj
Definition:
fieldupdater.cxx:23
editeng::FieldUpdater
Wrapper for EditTextObject to handle updating of fields without exposing the internals of EditTextObj...
Definition:
fieldupdater.hxx:27
editeng::FieldUpdater::mpImpl
std::unique_ptr< FieldUpdaterImpl > mpImpl
Definition:
fieldupdater.hxx:28
editeng::FieldUpdater::FieldUpdater
FieldUpdater(EditTextObject &rObj)
Definition:
fieldupdater.cxx:56
editeng::FieldUpdater::updateTableFields
void updateTableFields(int nTab)
Set a new table ID to all table fields.
Definition:
fieldupdater.cxx:63
editeng::FieldUpdater::~FieldUpdater
~FieldUpdater()
Definition:
fieldupdater.cxx:59
editobj2.hxx
toImpl
EditTextObjectImpl & toImpl(EditTextObject &rObj)
Definition:
editobj2.hxx:273
EE_FEATURE_FIELD
constexpr TypedWhichId< SvxFieldItem > EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
fieldupdater.hxx
flditem.hxx
pData
std::unique_ptr< sal_Int32[]> pData
com::sun::star
editeng
i
int i
SfxItemPool
Generated on Sun Jul 30 2023 04:33:48 for LibreOffice Module editeng (master) by
1.9.3