Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/dialog/ClassificationEditView.cxx
Line
Count
Source
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
11
#include <svx/ClassificationField.hxx>
12
13
#include <svl/itempool.hxx>
14
#include <svl/itemset.hxx>
15
#include <editeng/wghtitem.hxx>
16
#include <editeng/eeitem.hxx>
17
18
#include "ClassificationEditView.hxx"
19
20
namespace svx {
21
22
ClassificationEditEngine::ClassificationEditEngine(SfxItemPool* pItemPool)
23
0
    : EditEngine(pItemPool)
24
0
{}
25
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*/)
28
0
{
29
0
    OUString aString;
30
0
    const ClassificationField* pClassificationField = dynamic_cast<const ClassificationField*>(rField.GetField());
31
0
    if (pClassificationField)
32
0
        aString = pClassificationField->msDescription;
33
0
    else
34
0
        aString = "Unknown";
35
0
    return aString;
36
0
}
37
38
ClassificationEditView::ClassificationEditView()
39
0
{
40
0
}
41
42
void ClassificationEditView::makeEditEngine()
43
0
{
44
0
    m_xEditEngine.reset(new ClassificationEditEngine(EditEngine::CreatePool().get()));
45
0
}
46
47
ClassificationEditView::~ClassificationEditView()
48
0
{
49
0
}
50
51
void ClassificationEditView::InsertField(const SvxFieldItem& rFieldItem)
52
0
{
53
0
    m_xEditView->InsertField(rFieldItem);
54
0
    m_xEditView->Invalidate();
55
0
}
56
57
void ClassificationEditView::InvertSelectionWeight()
58
0
{
59
0
    ESelection aSelection = m_xEditView->GetSelection();
60
61
0
    for (sal_Int32 nParagraph = aSelection.start.nPara; nParagraph <= aSelection.end.nPara; ++nParagraph)
62
0
    {
63
0
        FontWeight eFontWeight = WEIGHT_BOLD;
64
65
0
        SfxItemSet aSet(m_xEditEngine->GetParaAttribs(nParagraph));
66
0
        if (const SfxPoolItem* pItem = aSet.GetItem(EE_CHAR_WEIGHT, false))
67
0
        {
68
0
            const SvxWeightItem* pWeightItem = dynamic_cast<const SvxWeightItem*>(pItem);
69
0
            if (pWeightItem && pWeightItem->GetWeight() == WEIGHT_BOLD)
70
0
                eFontWeight = WEIGHT_NORMAL;
71
0
        }
72
0
        SvxWeightItem aWeight(eFontWeight, EE_CHAR_WEIGHT);
73
0
        aSet.Put(aWeight);
74
0
        m_xEditEngine->SetParaAttribs(nParagraph, aSet);
75
0
    }
76
77
0
    m_xEditView->Invalidate();
78
0
}
79
80
} // end sfx2
81
82
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */