tdf#164393 Change themes UI as per UX feedback
[LibreOffice.git] / svx / source / dialog / ClassificationEditView.cxx
blob56ac009a30f8d2b634baadaf718cffc1fcb95735
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 */
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"
20 namespace svx {
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*/)
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;
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);
73 aSet.Put(aWeight);
74 m_xEditEngine->SetParaAttribs(nParagraph, aSet);
77 m_xEditView->Invalidate();
80 } // end sfx2
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */