1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
11 #include <svx/ClassificationField.hxx>
13 #include <svl/itempool.hxx>
14 #include <svl/itemset.hxx>
15 #include <editeng/wghtitem.hxx>
16 #include <editeng/eeitem.hxx>
18 #include "ClassificationEditView.hxx"
22 ClassificationEditEngine::ClassificationEditEngine(SfxItemPool
* pItemPool
)
23 : EditEngine(pItemPool
)
26 OUString
ClassificationEditEngine::CalcFieldValue(const SvxFieldItem
& rField
, sal_Int32
/*nPara*/,
27 sal_Int32
/*nPos*/, std::optional
<Color
>& /*rTxtColor*/, std::optional
<Color
>& /*rFldColor*/, std::optional
<FontLineStyle
>& /*rFldLineStyle*/)
30 const ClassificationField
* pClassificationField
= dynamic_cast<const ClassificationField
*>(rField
.GetField());
31 if (pClassificationField
)
32 aString
= pClassificationField
->msDescription
;
38 ClassificationEditView::ClassificationEditView()
42 void ClassificationEditView::makeEditEngine()
44 m_xEditEngine
.reset(new ClassificationEditEngine(EditEngine::CreatePool().get()));
47 ClassificationEditView::~ClassificationEditView()
51 void ClassificationEditView::InsertField(const SvxFieldItem
& rFieldItem
)
53 m_xEditView
->InsertField(rFieldItem
);
54 m_xEditView
->Invalidate();
57 void ClassificationEditView::InvertSelectionWeight()
59 ESelection aSelection
= m_xEditView
->GetSelection();
61 for (sal_Int32 nParagraph
= aSelection
.start
.nPara
; nParagraph
<= aSelection
.end
.nPara
; ++nParagraph
)
63 FontWeight eFontWeight
= WEIGHT_BOLD
;
65 SfxItemSet
aSet(m_xEditEngine
->GetParaAttribs(nParagraph
));
66 if (const SfxPoolItem
* pItem
= aSet
.GetItem(EE_CHAR_WEIGHT
, false))
68 const SvxWeightItem
* pWeightItem
= dynamic_cast<const SvxWeightItem
*>(pItem
);
69 if (pWeightItem
&& pWeightItem
->GetWeight() == WEIGHT_BOLD
)
70 eFontWeight
= WEIGHT_NORMAL
;
72 SvxWeightItem
aWeight(eFontWeight
, EE_CHAR_WEIGHT
);
74 m_xEditEngine
->SetParaAttribs(nParagraph
, aSet
);
77 m_xEditView
->Invalidate();
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */