LibreOffice Module svx (master) 1
ClassificationEditView.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
12
13#include <svl/itempool.hxx>
14#include <svl/itemset.hxx>
15#include <editeng/wghtitem.hxx>
16#include <editeng/eeitem.hxx>
17
19
20namespace svx {
21
23 : EditEngine(pItemPool)
24{}
25
26OUString ClassificationEditEngine::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 /*nPara*/,
27 sal_Int32 /*nPos*/, std::optional<Color>& /*rTxtColor*/, std::optional<Color>& /*rFldColor*/, std::optional<FontLineStyle>& /*rFldLineStyle*/)
28{
29 OUString aString;
30 const ClassificationField* pClassificationField = dynamic_cast<const ClassificationField*>(rField.GetField());
31 if (pClassificationField)
32 aString = pClassificationField->msDescription;
33 else
34 aString = "Unknown";
35 return aString;
36}
37
39{
40}
41
43{
45}
46
48{
49}
50
52{
53 m_xEditView->InsertField(rFieldItem);
54 m_xEditView->Invalidate();
55}
56
58{
59 ESelection aSelection = m_xEditView->GetSelection();
60
61 for (sal_Int32 nParagraph = aSelection.nStartPara; nParagraph <= aSelection.nEndPara; ++nParagraph)
62 {
63 FontWeight eFontWeight = WEIGHT_BOLD;
64
65 SfxItemSet aSet(m_xEditEngine->GetParaAttribs(nParagraph));
66 if (const SfxPoolItem* pItem = aSet.GetItem(EE_CHAR_WEIGHT, false))
67 {
68 const SvxWeightItem* pWeightItem = dynamic_cast<const SvxWeightItem*>(pItem);
69 if (pWeightItem && pWeightItem->GetWeight() == WEIGHT_BOLD)
70 eFontWeight = WEIGHT_NORMAL;
71 }
72 SvxWeightItem aWeight(eFontWeight, EE_CHAR_WEIGHT);
73 aSet.Put(aWeight);
74 m_xEditEngine->SetParaAttribs(nParagraph, aSet);
75 }
76
77 m_xEditView->Invalidate();
78}
79
80} // end sfx2
81
82/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static rtl::Reference< SfxItemPool > CreatePool()
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SvxFieldData * GetField() const
FontWeight GetWeight() const
std::unique_ptr< EditEngine > m_xEditEngine
std::unique_ptr< EditView > m_xEditView
ClassificationEditEngine(SfxItemPool *pItemPool)
virtual OUString CalcFieldValue(const SvxFieldItem &rField, sal_Int32 nPara, sal_Int32 nPos, std::optional< Color > &rTxtColor, std::optional< Color > &rFldColor, std::optional< FontLineStyle > &rFldLineStyle) override
void InsertField(const SvxFieldItem &rField)
virtual ~ClassificationEditView() override
virtual void makeEditEngine() override
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
WEIGHT_BOLD
WEIGHT_NORMAL
FontWeight
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
sal_Int32 nStartPara
sal_Int32 nEndPara