tdf#164393 Change themes UI as per UX feedback
[LibreOffice.git] / svx / source / dialog / ClassificationDialog.cxx
blob757eba26280717b7f6c2e4460a8d5229962868b8
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/ClassificationDialog.hxx>
12 #include <svx/ClassificationCommon.hxx>
14 #include <editeng/flditem.hxx>
15 #include <editeng/eeitem.hxx>
16 #include <editeng/section.hxx>
17 #include <editeng/editobj.hxx>
18 #include <editeng/wghtitem.hxx>
19 #include <svl/itemset.hxx>
20 #include <osl/file.hxx>
21 #include <rtl/bootstrap.hxx>
22 #include <config_folders.h>
23 #include <tools/stream.hxx>
24 #include <tools/XmlWriter.hxx>
25 #include <tools/XmlWalker.hxx>
26 #include <utility>
27 #include <vcl/customweld.hxx>
28 #include <vcl/event.hxx>
29 #include <vcl/svapp.hxx>
31 #include <officecfg/Office/Common.hxx>
33 #include "ClassificationEditView.hxx"
35 namespace svx {
37 IMPL_STATIC_LINK(ClassificationDialog, KeyInput, const KeyEvent&, rKeyEvent, bool)
39 bool bTextIsFreeForm = officecfg::Office::Common::Classification::IntellectualPropertyTextInputIsFreeForm::get();
41 if (!bTextIsFreeForm)
43 // Ignore key combination with modifier keys
44 if (rKeyEvent.GetKeyCode().IsMod3()
45 || rKeyEvent.GetKeyCode().IsMod2()
46 || rKeyEvent.GetKeyCode().IsMod1())
48 return true;
51 switch (rKeyEvent.GetKeyCode().GetCode())
53 // Allowed characters
54 case KEY_BACKSPACE:
55 case KEY_DELETE:
56 case KEY_DIVIDE:
57 case KEY_SEMICOLON:
58 case KEY_SPACE:
59 return false;
60 // Anything else is ignored
61 default:
62 return true;
66 return false;
69 namespace {
71 constexpr size_t RECENTLY_USED_LIMIT = 5;
73 constexpr OUString constRecentlyUsedFileName(u"recentlyUsed.xml"_ustr);
75 OUString lcl_getClassificationUserPath()
77 OUString sPath(u"${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/user/classification/"_ustr);
78 rtl::Bootstrap::expandMacros(sPath);
79 return sPath;
82 const SvxFieldItem* findField(editeng::Section const & rSection)
84 for (SfxPoolItem const * pPool : rSection.maAttributes)
86 if (pPool->Which() == EE_FEATURE_FIELD)
87 return static_cast<const SvxFieldItem*>(pPool);
89 return nullptr;
92 bool fileExists(OUString const & sFilename)
94 osl::File aFile(sFilename);
95 osl::FileBase::RC eRC = aFile.open(osl_File_OpenFlag_Read);
96 return osl::FileBase::E_None == eRC;
99 bool stringToClassificationType(std::string_view rsType, svx::ClassificationType & reType)
101 if (rsType == "CATEGORY")
102 reType = svx::ClassificationType::CATEGORY;
103 else if (rsType == "INTELLECTUAL_PROPERTY_PART")
104 reType = svx::ClassificationType::INTELLECTUAL_PROPERTY_PART;
105 else if (rsType == "MARKING")
106 reType = svx::ClassificationType::MARKING;
107 else if (rsType == "PARAGRAPH")
108 reType = svx::ClassificationType::PARAGRAPH;
109 else if (rsType == "TEXT")
110 reType = svx::ClassificationType::TEXT;
111 else
112 return false;
113 return true;
116 OUString classificationTypeToString(svx::ClassificationType const & reType)
118 switch(reType)
120 case svx::ClassificationType::CATEGORY:
121 return u"CATEGORY"_ustr; break;
122 case svx::ClassificationType::MARKING:
123 return u"MARKING"_ustr; break;
124 case svx::ClassificationType::TEXT:
125 return u"TEXT"_ustr; break;
126 case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART:
127 return u"INTELLECTUAL_PROPERTY_PART"_ustr; break;
128 case svx::ClassificationType::PARAGRAPH:
129 return u"PARAGRAPH"_ustr; break;
131 return OUString();
134 void writeResultToXml(tools::XmlWriter & rXmlWriter,
135 std::vector<ClassificationResult> const & rResultCollection)
137 for (ClassificationResult const & rResult : rResultCollection)
139 rXmlWriter.startElement("element");
140 OUString sType = classificationTypeToString(rResult.meType);
141 rXmlWriter.attribute("type", sType);
142 rXmlWriter.startElement("string");
143 rXmlWriter.content(rResult.msName);
144 rXmlWriter.endElement();
145 rXmlWriter.startElement("abbreviatedString");
146 rXmlWriter.content(rResult.msAbbreviatedName);
147 rXmlWriter.endElement();
148 rXmlWriter.startElement("identifier");
149 rXmlWriter.content(rResult.msIdentifier);
150 rXmlWriter.endElement();
151 rXmlWriter.endElement();
155 } // end anonymous namespace
157 ClassificationDialog::ClassificationDialog(weld::Window* pParent, const css::uno::Reference<css::document::XDocumentProperties>& rDocProps,
158 const bool bPerParagraph, std::function<void()> aParagraphSignHandler)
159 : GenericDialogController(pParent, u"svx/ui/classificationdialog.ui"_ustr, u"AdvancedDocumentClassificationDialog"_ustr)
160 , maHelper(rDocProps)
161 , maInternationalHelper(rDocProps, /*bUseLocalizedPolicy*/ false)
162 , m_bPerParagraph(bPerParagraph)
163 , m_aParagraphSignHandler(std::move(aParagraphSignHandler))
164 , m_nCurrentSelectedCategory(-1)
165 , m_xOkButton(m_xBuilder->weld_button(u"ok"_ustr))
166 , m_xSignButton(m_xBuilder->weld_button(u"signButton"_ustr))
167 , m_xToolBox(m_xBuilder->weld_toggle_button(u"toolbox"_ustr))
168 , m_xRecentlyUsedListBox(m_xBuilder->weld_combo_box(u"recentlyUsedCB"_ustr))
169 , m_xClassificationListBox(m_xBuilder->weld_combo_box(u"classificationCB"_ustr))
170 , m_xInternationalClassificationListBox(m_xBuilder->weld_combo_box(u"internationalClassificationCB"_ustr))
171 , m_xMarkingLabel(m_xBuilder->weld_label(u"markingLabel"_ustr))
172 , m_xMarkingListBox(m_xBuilder->weld_tree_view(u"markingLB"_ustr))
173 , m_xIntellectualPropertyPartListBox(m_xBuilder->weld_tree_view(u"intellectualPropertyPartLB"_ustr))
174 , m_xIntellectualPropertyPartNumberListBox(m_xBuilder->weld_tree_view(u"intellectualPropertyPartNumberLB"_ustr))
175 , m_xIntellectualPropertyPartAddButton(m_xBuilder->weld_button(u"intellectualPropertyPartAddButton"_ustr))
176 , m_xIntellectualPropertyPartEdit(m_xBuilder->weld_entry(u"intellectualPropertyPartEntry"_ustr))
177 , m_xIntellectualPropertyExpander(m_xBuilder->weld_expander(u"intellectualPropertyExpander"_ustr))
178 , m_xEditWindow(new ClassificationEditView)
179 , m_xEditWindowWeld(new weld::CustomWeld(*m_xBuilder, u"classificationEditWindow"_ustr, *m_xEditWindow))
181 m_xOkButton->connect_clicked(LINK(this, ClassificationDialog, OkHdl));
182 m_xSignButton->connect_clicked(LINK(this, ClassificationDialog, ButtonClicked));
183 m_xSignButton->set_visible(m_bPerParagraph);
185 m_xIntellectualPropertyPartEdit->connect_key_press(LINK(this, ClassificationDialog, KeyInput));
187 // no need for BOLD if we do paragraph classification
188 if (m_bPerParagraph)
190 m_xToolBox->hide();
192 else
194 m_xToolBox->connect_toggled(LINK(this, ClassificationDialog, SelectToolboxHdl));
197 m_xIntellectualPropertyPartAddButton->connect_clicked(LINK(this, ClassificationDialog, ButtonClicked));
199 m_xClassificationListBox->set_size_request(m_xClassificationListBox->get_approximate_digit_width() * 20, -1);
200 m_xClassificationListBox->connect_changed(LINK(this, ClassificationDialog, SelectClassificationHdl));
201 for (const OUString& rName : maHelper.GetBACNames())
202 m_xClassificationListBox->append_text(rName);
204 m_xInternationalClassificationListBox->set_size_request(m_xInternationalClassificationListBox->get_approximate_digit_width() * 20, -1);
205 m_xInternationalClassificationListBox->connect_changed(LINK(this, ClassificationDialog, SelectClassificationHdl));
206 for (const OUString& rName : maInternationalHelper.GetBACNames())
207 m_xInternationalClassificationListBox->append_text(rName);
209 if (!maHelper.GetMarkings().empty())
211 m_xMarkingListBox->set_size_request(m_xMarkingListBox->get_approximate_digit_width() * 10,
212 m_xMarkingListBox->get_height_rows(4));
213 m_xMarkingListBox->connect_row_activated(LINK(this, ClassificationDialog, SelectMarkingHdl));
215 for (const OUString& rName : maHelper.GetMarkings())
216 m_xMarkingListBox->append_text(rName);
218 else
220 m_xMarkingListBox->hide();
221 m_xMarkingLabel->hide();
224 m_xIntellectualPropertyPartNumberListBox->set_size_request(m_xIntellectualPropertyPartNumberListBox->get_approximate_digit_width() * 10,
225 m_xIntellectualPropertyPartNumberListBox->get_height_rows(5));
226 m_xIntellectualPropertyPartNumberListBox->connect_row_activated(LINK(this, ClassificationDialog, SelectIPPartNumbersHdl));
227 for (const OUString& rName : maHelper.GetIntellectualPropertyPartNumbers())
228 m_xIntellectualPropertyPartNumberListBox->append_text(rName);
230 m_xIntellectualPropertyPartNumberListBox->set_size_request(m_xIntellectualPropertyPartNumberListBox->get_approximate_digit_width() * 20,
231 m_xIntellectualPropertyPartListBox->get_height_rows(5));
232 m_xIntellectualPropertyPartListBox->connect_row_activated(LINK(this, ClassificationDialog, SelectIPPartHdl));
233 for (const OUString& rName : maHelper.GetIntellectualPropertyParts())
234 m_xIntellectualPropertyPartListBox->append_text(rName);
236 m_xRecentlyUsedListBox->set_size_request(m_xRecentlyUsedListBox->get_approximate_digit_width() * 5, -1);
237 m_xRecentlyUsedListBox->connect_changed(LINK(this, ClassificationDialog, SelectRecentlyUsedHdl));
239 m_xIntellectualPropertyExpander->connect_expanded(LINK(this, ClassificationDialog, ExpandedHdl));
240 if (officecfg::Office::Common::Classification::IntellectualPropertySectionExpanded::get())
241 m_nAsyncExpandEvent = Application::PostUserEvent(LINK(this, ClassificationDialog, OnAsyncExpandHdl));
242 else
243 m_nAsyncExpandEvent = nullptr;
245 m_xEditWindow->SetModifyHdl(LINK(this, ClassificationDialog, EditWindowModifiedHdl));
247 readRecentlyUsed();
248 toggleWidgetsDependingOnCategory();
250 int nNumber = 1;
251 if (m_aRecentlyUsedValuesCollection.empty())
253 m_xRecentlyUsedListBox->set_sensitive(false);
255 else
257 for (std::vector<ClassificationResult> const & rResults : m_aRecentlyUsedValuesCollection)
259 OUString rContentRepresentation = svx::classification::convertClassificationResultToString(rResults);
260 OUString rDescription = OUString::number(nNumber) + ": " + rContentRepresentation;
261 nNumber++;
263 m_xRecentlyUsedListBox->append_text(rDescription);
268 //do it async so gtk has a chance to shrink it to best size, otherwise its larger than min
269 IMPL_LINK_NOARG(ClassificationDialog, OnAsyncExpandHdl, void*, void)
271 m_nAsyncExpandEvent = nullptr;
272 m_xIntellectualPropertyExpander->set_expanded(true);
275 ClassificationDialog::~ClassificationDialog()
277 if (m_nAsyncExpandEvent)
278 Application::RemoveUserEvent(m_nAsyncExpandEvent);
281 void ClassificationDialog::insertCategoryField(sal_Int32 nID)
283 const OUString aFullString = maHelper.GetBACNames()[nID];
284 const OUString aAbbreviatedString = maHelper.GetAbbreviatedBACNames()[nID];
285 const OUString aIdentifierString = maHelper.GetBACIdentifiers()[nID];
286 insertField(ClassificationType::CATEGORY, aAbbreviatedString, aFullString, aIdentifierString);
289 void ClassificationDialog::insertField(ClassificationType eType, OUString const & rString, OUString const & rFullString, OUString const & rIdentifier)
291 ClassificationField aField(eType, rString, rFullString, rIdentifier);
292 m_xEditWindow->InsertField(SvxFieldItem(aField, EE_FEATURE_FIELD));
295 void ClassificationDialog::setupValues(std::vector<ClassificationResult> && rInput)
297 m_aInitialValues = std::move(rInput);
298 readIn(m_aInitialValues);
301 void ClassificationDialog::readRecentlyUsed()
303 OUString sPath = lcl_getClassificationUserPath();
304 OUString sFilePath(sPath + constRecentlyUsedFileName);
306 if (!fileExists(sFilePath))
307 return;
309 SvFileStream aFileStream(sFilePath, StreamMode::READ);
310 tools::XmlWalker aWalker;
311 if (!aWalker.open(&aFileStream))
312 return;
314 if (aWalker.name() != "recentlyUsedClassifications")
315 return;
317 aWalker.children();
318 while (aWalker.isValid())
320 if (aWalker.name() == "elementGroup")
322 std::vector<ClassificationResult> aResults;
324 aWalker.children();
326 while (aWalker.isValid())
328 if (aWalker.name() == "element")
330 svx::ClassificationType eType = svx::ClassificationType::TEXT;
331 OUString sString;
332 OUString sAbbreviatedString;
333 OUString sIdentifier;
335 // Convert string to classification type, but continue only if
336 // conversion was successful.
337 if (stringToClassificationType(aWalker.attribute("type"_ostr), eType))
339 aWalker.children();
341 while (aWalker.isValid())
343 if (aWalker.name() == "string")
345 sString = OStringToOUString(aWalker.content(), RTL_TEXTENCODING_UTF8);
347 else if (aWalker.name() == "abbreviatedString")
349 sAbbreviatedString = OStringToOUString(aWalker.content(), RTL_TEXTENCODING_UTF8);
351 else if (aWalker.name() == "identifier")
353 sIdentifier = OStringToOUString(aWalker.content(), RTL_TEXTENCODING_UTF8);
355 aWalker.next();
357 aWalker.parent();
359 aResults.emplace_back(eType, sString, sAbbreviatedString, sIdentifier);
362 aWalker.next();
364 aWalker.parent();
365 m_aRecentlyUsedValuesCollection.push_back(aResults);
367 aWalker.next();
369 aWalker.parent();
372 void ClassificationDialog::writeRecentlyUsed()
374 OUString sPath = lcl_getClassificationUserPath();
375 osl::Directory::createPath(sPath);
376 OUString sFilePath(sPath + constRecentlyUsedFileName);
378 std::unique_ptr<SvStream> pStream;
379 pStream.reset(new SvFileStream(sFilePath, StreamMode::STD_READWRITE | StreamMode::TRUNC));
381 tools::XmlWriter aXmlWriter(pStream.get());
383 if (!aXmlWriter.startDocument())
384 return;
386 aXmlWriter.startElement("recentlyUsedClassifications");
388 aXmlWriter.startElement("elementGroup");
390 writeResultToXml(aXmlWriter, getResult());
392 aXmlWriter.endElement();
394 if (m_aRecentlyUsedValuesCollection.size() >= RECENTLY_USED_LIMIT)
395 m_aRecentlyUsedValuesCollection.pop_back();
397 for (std::vector<ClassificationResult> const & rResultCollection : m_aRecentlyUsedValuesCollection)
399 aXmlWriter.startElement("elementGroup");
401 writeResultToXml(aXmlWriter, rResultCollection);
403 aXmlWriter.endElement();
406 aXmlWriter.endElement();
408 aXmlWriter.endDocument();
411 void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInput)
413 sal_Int32 nParagraph = -1;
415 for (ClassificationResult const & rClassificationResult : rInput)
418 switch (rClassificationResult.meType)
420 case svx::ClassificationType::TEXT:
422 m_xEditWindow->getEditView().InsertText(rClassificationResult.msName);
424 break;
426 case svx::ClassificationType::CATEGORY:
428 OUString sName;
429 if (rClassificationResult.msName.isEmpty())
430 sName = maHelper.GetBACNameForIdentifier(rClassificationResult.msIdentifier);
431 else
432 sName = rClassificationResult.msName;
434 OUString sAbbreviatedName = rClassificationResult.msAbbreviatedName;
435 if (sAbbreviatedName.isEmpty())
436 sAbbreviatedName = maHelper.GetAbbreviatedBACName(sName);
438 m_xClassificationListBox->set_active_text(sName);
439 m_nCurrentSelectedCategory = m_xClassificationListBox->get_active();
440 m_xInternationalClassificationListBox->set_active(m_xClassificationListBox->get_active());
442 insertField(rClassificationResult.meType, sAbbreviatedName, sName, rClassificationResult.msIdentifier);
444 break;
446 case svx::ClassificationType::MARKING:
448 m_xMarkingListBox->select_text(rClassificationResult.msName);
449 insertField(rClassificationResult.meType, rClassificationResult.msName, rClassificationResult.msName, rClassificationResult.msIdentifier);
451 break;
453 case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART:
455 insertField(rClassificationResult.meType, rClassificationResult.msName, rClassificationResult.msName, rClassificationResult.msIdentifier);
457 break;
459 case svx::ClassificationType::PARAGRAPH:
461 nParagraph++;
463 if (nParagraph != 0)
464 m_xEditWindow->getEditView().InsertParaBreak();
466 // Set paragraph font weight
467 FontWeight eWeight = (rClassificationResult.msName == "BOLD") ? WEIGHT_BOLD : WEIGHT_NORMAL;
469 ClassificationEditEngine& rEdEngine = m_xEditWindow->getEditEngine();
470 SfxItemSet aSet(rEdEngine.GetParaAttribs(nParagraph));
471 aSet.Put(SvxWeightItem(eWeight, EE_CHAR_WEIGHT));
472 rEdEngine.SetParaAttribs(nParagraph, aSet);
474 break;
476 default:
477 break;
480 toggleWidgetsDependingOnCategory();
483 void ClassificationDialog::toggleWidgetsDependingOnCategory()
485 const EditEngine& rEditEngine = m_xEditWindow->getEditEngine();
487 for (sal_Int32 nParagraph = 0; nParagraph < rEditEngine.GetParagraphCount(); ++nParagraph)
489 for (const EFieldInfo& rFieldInfo : rEditEngine.GetFieldInfo(nParagraph))
491 if (rFieldInfo.pFieldItem)
493 const ClassificationField* pClassificationField = dynamic_cast<const ClassificationField*>(rFieldInfo.pFieldItem->GetField());
494 if (pClassificationField && pClassificationField->meType == ClassificationType::CATEGORY)
496 m_xOkButton->set_sensitive(true);
497 return;
503 // Category field in the text edit has been deleted, so reset the list boxes
504 m_xOkButton->set_sensitive(false);
505 m_xClassificationListBox->set_active(-1);
506 m_xInternationalClassificationListBox->set_active(-1);
509 std::vector<ClassificationResult> ClassificationDialog::getResult()
511 std::vector<ClassificationResult> aClassificationResults;
513 ClassificationEditEngine& rEdEngine = m_xEditWindow->getEditEngine();
514 std::unique_ptr<EditTextObject> pEditText(rEdEngine.CreateTextObject());
516 sal_Int32 nCurrentParagraph = -1;
518 std::vector<editeng::Section> aSections;
519 pEditText->GetAllSections(aSections);
520 for (editeng::Section const & rSection : aSections)
522 while (nCurrentParagraph < rSection.mnParagraph)
524 nCurrentParagraph++;
526 // Get Weight of current paragraph
527 FontWeight eFontWeight = WEIGHT_NORMAL;
528 SfxItemSet aItemSet(rEdEngine.GetParaAttribs(nCurrentParagraph));
529 if (const SfxPoolItem* pItem = aItemSet.GetItem(EE_CHAR_WEIGHT, false))
531 const SvxWeightItem* pWeightItem = dynamic_cast<const SvxWeightItem*>(pItem);
532 if (pWeightItem && pWeightItem->GetWeight() == WEIGHT_BOLD)
533 eFontWeight = WEIGHT_BOLD;
535 // Font weight to string
536 OUString sWeightProperty = u"NORMAL"_ustr;
537 if (eFontWeight == WEIGHT_BOLD)
538 sWeightProperty = "BOLD";
539 // Insert into collection
540 OUString sBlank;
541 aClassificationResults.emplace_back(ClassificationType::PARAGRAPH, sWeightProperty, sBlank, sBlank);
544 const SvxFieldItem* pFieldItem = findField(rSection);
546 ESelection aSelection(rSection.mnParagraph, rSection.mnStart, rSection.mnParagraph, rSection.mnEnd);
547 const OUString sDisplayString = rEdEngine.GetText(aSelection);
548 if (!sDisplayString.isEmpty())
550 const ClassificationField* pClassificationField = pFieldItem ? dynamic_cast<const ClassificationField*>(pFieldItem->GetField()) : nullptr;
552 if (pClassificationField)
554 aClassificationResults.emplace_back(pClassificationField->meType, pClassificationField->msFullClassName,
555 pClassificationField->msDescription, pClassificationField->msIdentifier);
557 else
559 aClassificationResults.emplace_back(ClassificationType::TEXT, sDisplayString, sDisplayString, OUString());
564 return aClassificationResults;
567 IMPL_LINK(ClassificationDialog, SelectClassificationHdl, weld::ComboBox&, rBox, void)
569 const sal_Int32 nSelected = rBox.get_active();
570 if (nSelected < 0 || m_nCurrentSelectedCategory == nSelected)
571 return;
573 std::unique_ptr<EditTextObject> pEditText(m_xEditWindow->getEditEngine().CreateTextObject());
574 std::vector<editeng::Section> aSections;
575 pEditText->GetAllSections(aSections);
577 // if we are replacing an existing field
578 bool bReplaceExisting = false;
579 // selection of the existing field, which will be replaced
580 ESelection aExistingFieldSelection;
582 for (editeng::Section const & rSection : aSections)
584 const SvxFieldItem* pFieldItem = findField(rSection);
585 if (pFieldItem)
587 const ClassificationField* pClassificationField = dynamic_cast<const ClassificationField*>(pFieldItem->GetField());
588 if (pClassificationField && pClassificationField->meType == ClassificationType::CATEGORY)
590 aExistingFieldSelection = ESelection(rSection.mnParagraph, rSection.mnStart,
591 rSection.mnParagraph, rSection.mnEnd);
592 bReplaceExisting = true;
597 if (bReplaceExisting)
598 m_xEditWindow->getEditView().SetSelection(aExistingFieldSelection);
600 insertCategoryField(nSelected);
602 // Change category to the new selection
603 m_xInternationalClassificationListBox->set_active(nSelected);
604 m_xClassificationListBox->set_active(nSelected);
605 m_nCurrentSelectedCategory = nSelected;
608 IMPL_LINK(ClassificationDialog, SelectMarkingHdl, weld::TreeView&, rBox, bool)
610 sal_Int32 nSelected = rBox.get_selected_index();
611 if (nSelected >= 0)
613 const OUString aString = maHelper.GetMarkings()[nSelected];
614 insertField(ClassificationType::MARKING, aString, aString);
616 return true;
619 IMPL_LINK(ClassificationDialog, SelectIPPartNumbersHdl, weld::TreeView&, rBox, bool)
621 sal_Int32 nSelected = rBox.get_selected_index();
622 if (nSelected >= 0)
624 OUString sString = maHelper.GetIntellectualPropertyPartNumbers()[nSelected];
625 m_xIntellectualPropertyPartEdit->replace_selection(sString);
626 m_xIntellectualPropertyPartEdit->grab_focus();
628 return true;
631 IMPL_LINK(ClassificationDialog, SelectRecentlyUsedHdl, weld::ComboBox&, rBox, void)
633 sal_Int32 nSelected = rBox.get_active();
634 if (nSelected >= 0)
636 m_xEditWindow->getEditEngine().Clear();
637 readIn(m_aRecentlyUsedValuesCollection[nSelected]);
641 IMPL_LINK(ClassificationDialog, SelectIPPartHdl, weld::TreeView&, rBox, bool)
643 const sal_Int32 nSelected = rBox.get_selected_index();
644 if (nSelected >= 0)
646 const OUString sString = maHelper.GetIntellectualPropertyParts()[nSelected];
647 m_xIntellectualPropertyPartEdit->replace_selection(sString);
648 m_xIntellectualPropertyPartEdit->grab_focus();
650 return true;
653 IMPL_LINK(ClassificationDialog, ButtonClicked, weld::Button&, rButton, void)
655 if (&rButton == m_xSignButton.get())
657 m_aParagraphSignHandler();
659 else if (&rButton == m_xIntellectualPropertyPartAddButton.get())
661 const OUString sString = m_xIntellectualPropertyPartEdit->get_text();
662 insertField(ClassificationType::INTELLECTUAL_PROPERTY_PART, sString, sString);
666 IMPL_LINK_NOARG(ClassificationDialog, OkHdl, weld::Button&, void)
668 writeRecentlyUsed();
669 m_xDialog->response(RET_OK);
672 IMPL_LINK_NOARG(ClassificationDialog, SelectToolboxHdl, weld::Toggleable&, void)
674 m_xEditWindow->InvertSelectionWeight();
677 IMPL_LINK_NOARG(ClassificationDialog, EditWindowModifiedHdl, LinkParamNone*, void)
679 toggleWidgetsDependingOnCategory();
682 IMPL_STATIC_LINK(ClassificationDialog, ExpandedHdl, weld::Expander&, rExpander, void)
684 std::shared_ptr<comphelper::ConfigurationChanges> aConfigurationChanges(comphelper::ConfigurationChanges::create());
685 officecfg::Office::Common::Classification::IntellectualPropertySectionExpanded::set(rExpander.get_expanded(), aConfigurationChanges);
686 aConfigurationChanges->commit();
689 } // end svx
691 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */