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/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>
27 #include <vcl/customweld.hxx>
28 #include <vcl/event.hxx>
29 #include <vcl/svapp.hxx>
30 #include <sfx2/objsh.hxx>
32 #include <officecfg/Office/Common.hxx>
34 #include "ClassificationEditView.hxx"
38 IMPL_STATIC_LINK(ClassificationDialog
, KeyInput
, const KeyEvent
&, rKeyEvent
, bool)
40 bool bTextIsFreeForm
= officecfg::Office::Common::Classification::IntellectualPropertyTextInputIsFreeForm::get();
44 // Ignore key combination with modifier keys
45 if (rKeyEvent
.GetKeyCode().IsMod3()
46 || rKeyEvent
.GetKeyCode().IsMod2()
47 || rKeyEvent
.GetKeyCode().IsMod1())
52 switch (rKeyEvent
.GetKeyCode().GetCode())
61 // Anything else is ignored
72 constexpr size_t RECENTLY_USED_LIMIT
= 5;
74 constexpr OUStringLiteral
constRecentlyUsedFileName(u
"recentlyUsed.xml");
76 OUString
lcl_getClassificationUserPath()
78 OUString
sPath("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER
"/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/user/classification/");
79 rtl::Bootstrap::expandMacros(sPath
);
83 const SvxFieldItem
* findField(editeng::Section
const & rSection
)
85 for (SfxPoolItem
const * pPool
: rSection
.maAttributes
)
87 if (pPool
->Which() == EE_FEATURE_FIELD
)
88 return static_cast<const SvxFieldItem
*>(pPool
);
93 bool fileExists(OUString
const & sFilename
)
95 osl::File
aFile(sFilename
);
96 osl::FileBase::RC eRC
= aFile
.open(osl_File_OpenFlag_Read
);
97 return osl::FileBase::E_None
== eRC
;
100 bool stringToClassificationType(std::string_view rsType
, svx::ClassificationType
& reType
)
102 if (rsType
== "CATEGORY")
103 reType
= svx::ClassificationType::CATEGORY
;
104 else if (rsType
== "INTELLECTUAL_PROPERTY_PART")
105 reType
= svx::ClassificationType::INTELLECTUAL_PROPERTY_PART
;
106 else if (rsType
== "MARKING")
107 reType
= svx::ClassificationType::MARKING
;
108 else if (rsType
== "PARAGRAPH")
109 reType
= svx::ClassificationType::PARAGRAPH
;
110 else if (rsType
== "TEXT")
111 reType
= svx::ClassificationType::TEXT
;
117 OUString
classificationTypeToString(svx::ClassificationType
const & reType
)
121 case svx::ClassificationType::CATEGORY
:
122 return "CATEGORY"; break;
123 case svx::ClassificationType::MARKING
:
124 return "MARKING"; break;
125 case svx::ClassificationType::TEXT
:
126 return "TEXT"; break;
127 case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART
:
128 return "INTELLECTUAL_PROPERTY_PART"; break;
129 case svx::ClassificationType::PARAGRAPH
:
130 return "PARAGRAPH"; break;
135 void writeResultToXml(tools::XmlWriter
& rXmlWriter
,
136 std::vector
<ClassificationResult
> const & rResultCollection
)
138 for (ClassificationResult
const & rResult
: rResultCollection
)
140 rXmlWriter
.startElement("element");
141 OUString sType
= classificationTypeToString(rResult
.meType
);
142 rXmlWriter
.attribute("type", sType
);
143 rXmlWriter
.startElement("string");
144 rXmlWriter
.content(rResult
.msName
);
145 rXmlWriter
.endElement();
146 rXmlWriter
.startElement("abbreviatedString");
147 rXmlWriter
.content(rResult
.msAbbreviatedName
);
148 rXmlWriter
.endElement();
149 rXmlWriter
.startElement("identifier");
150 rXmlWriter
.content(rResult
.msIdentifier
);
151 rXmlWriter
.endElement();
152 rXmlWriter
.endElement();
156 } // end anonymous namespace
158 ClassificationDialog::ClassificationDialog(weld::Window
* pParent
, const css::uno::Reference
<css::document::XDocumentProperties
>& rDocProps
,
159 const bool bPerParagraph
, std::function
<void()> aParagraphSignHandler
)
160 : GenericDialogController(pParent
, "svx/ui/classificationdialog.ui", "AdvancedDocumentClassificationDialog")
161 , maHelper(rDocProps
)
162 , maInternationalHelper(rDocProps
, /*bUseLocalizedPolicy*/ false)
163 , m_bPerParagraph(bPerParagraph
)
164 , m_aParagraphSignHandler(std::move(aParagraphSignHandler
))
165 , m_nCurrentSelectedCategory(-1)
166 , m_xOkButton(m_xBuilder
->weld_button("ok"))
167 , m_xSignButton(m_xBuilder
->weld_button("signButton"))
168 , m_xToolBox(m_xBuilder
->weld_toggle_button("toolbox"))
169 , m_xRecentlyUsedListBox(m_xBuilder
->weld_combo_box("recentlyUsedCB"))
170 , m_xClassificationListBox(m_xBuilder
->weld_combo_box("classificationCB"))
171 , m_xInternationalClassificationListBox(m_xBuilder
->weld_combo_box("internationalClassificationCB"))
172 , m_xMarkingLabel(m_xBuilder
->weld_label("markingLabel"))
173 , m_xMarkingListBox(m_xBuilder
->weld_tree_view("markingLB"))
174 , m_xIntellectualPropertyPartListBox(m_xBuilder
->weld_tree_view("intellectualPropertyPartLB"))
175 , m_xIntellectualPropertyPartNumberListBox(m_xBuilder
->weld_tree_view("intellectualPropertyPartNumberLB"))
176 , m_xIntellectualPropertyPartAddButton(m_xBuilder
->weld_button("intellectualPropertyPartAddButton"))
177 , m_xIntellectualPropertyPartEdit(m_xBuilder
->weld_entry("intellectualPropertyPartEntry"))
178 , m_xIntellectualPropertyExpander(m_xBuilder
->weld_expander("intellectualPropertyExpander"))
179 , m_xEditWindow(new ClassificationEditView
)
180 , m_xEditWindowWeld(new weld::CustomWeld(*m_xBuilder
, "classificationEditWindow", *m_xEditWindow
))
182 m_xOkButton
->connect_clicked(LINK(this, ClassificationDialog
, OkHdl
));
183 m_xSignButton
->connect_clicked(LINK(this, ClassificationDialog
, ButtonClicked
));
184 m_xSignButton
->set_visible(m_bPerParagraph
);
186 m_xIntellectualPropertyPartEdit
->connect_key_press(LINK(this, ClassificationDialog
, KeyInput
));
188 // no need for BOLD if we do paragraph classification
195 m_xToolBox
->connect_toggled(LINK(this, ClassificationDialog
, SelectToolboxHdl
));
198 m_xIntellectualPropertyPartAddButton
->connect_clicked(LINK(this, ClassificationDialog
, ButtonClicked
));
200 m_xClassificationListBox
->set_size_request(m_xClassificationListBox
->get_approximate_digit_width() * 20, -1);
201 m_xClassificationListBox
->connect_changed(LINK(this, ClassificationDialog
, SelectClassificationHdl
));
202 for (const OUString
& rName
: maHelper
.GetBACNames())
203 m_xClassificationListBox
->append_text(rName
);
205 m_xInternationalClassificationListBox
->set_size_request(m_xInternationalClassificationListBox
->get_approximate_digit_width() * 20, -1);
206 m_xInternationalClassificationListBox
->connect_changed(LINK(this, ClassificationDialog
, SelectClassificationHdl
));
207 for (const OUString
& rName
: maInternationalHelper
.GetBACNames())
208 m_xInternationalClassificationListBox
->append_text(rName
);
210 if (!maHelper
.GetMarkings().empty())
212 m_xMarkingListBox
->set_size_request(m_xMarkingListBox
->get_approximate_digit_width() * 10,
213 m_xMarkingListBox
->get_height_rows(4));
214 m_xMarkingListBox
->connect_row_activated(LINK(this, ClassificationDialog
, SelectMarkingHdl
));
216 for (const OUString
& rName
: maHelper
.GetMarkings())
217 m_xMarkingListBox
->append_text(rName
);
221 m_xMarkingListBox
->hide();
222 m_xMarkingLabel
->hide();
225 m_xIntellectualPropertyPartNumberListBox
->set_size_request(m_xIntellectualPropertyPartNumberListBox
->get_approximate_digit_width() * 10,
226 m_xIntellectualPropertyPartNumberListBox
->get_height_rows(5));
227 m_xIntellectualPropertyPartNumberListBox
->connect_row_activated(LINK(this, ClassificationDialog
, SelectIPPartNumbersHdl
));
228 for (const OUString
& rName
: maHelper
.GetIntellectualPropertyPartNumbers())
229 m_xIntellectualPropertyPartNumberListBox
->append_text(rName
);
231 m_xIntellectualPropertyPartNumberListBox
->set_size_request(m_xIntellectualPropertyPartNumberListBox
->get_approximate_digit_width() * 20,
232 m_xIntellectualPropertyPartListBox
->get_height_rows(5));
233 m_xIntellectualPropertyPartListBox
->connect_row_activated(LINK(this, ClassificationDialog
, SelectIPPartHdl
));
234 for (const OUString
& rName
: maHelper
.GetIntellectualPropertyParts())
235 m_xIntellectualPropertyPartListBox
->append_text(rName
);
237 m_xRecentlyUsedListBox
->set_size_request(m_xRecentlyUsedListBox
->get_approximate_digit_width() * 5, -1);
238 m_xRecentlyUsedListBox
->connect_changed(LINK(this, ClassificationDialog
, SelectRecentlyUsedHdl
));
240 m_xIntellectualPropertyExpander
->connect_expanded(LINK(this, ClassificationDialog
, ExpandedHdl
));
241 if (officecfg::Office::Common::Classification::IntellectualPropertySectionExpanded::get())
242 m_nAsyncExpandEvent
= Application::PostUserEvent(LINK(this, ClassificationDialog
, OnAsyncExpandHdl
));
244 m_nAsyncExpandEvent
= nullptr;
246 m_xEditWindow
->SetModifyHdl(LINK(this, ClassificationDialog
, EditWindowModifiedHdl
));
249 toggleWidgetsDependingOnCategory();
252 if (m_aRecentlyUsedValuesCollection
.empty())
254 m_xRecentlyUsedListBox
->set_sensitive(false);
258 for (std::vector
<ClassificationResult
> const & rResults
: m_aRecentlyUsedValuesCollection
)
260 OUString rContentRepresentation
= svx::classification::convertClassificationResultToString(rResults
);
261 OUString rDescription
= OUString::number(nNumber
) + ": " + rContentRepresentation
;
264 m_xRecentlyUsedListBox
->append_text(rDescription
);
269 //do it async so gtk has a chance to shrink it to best size, otherwise its larger than min
270 IMPL_LINK_NOARG(ClassificationDialog
, OnAsyncExpandHdl
, void*, void)
272 m_nAsyncExpandEvent
= nullptr;
273 m_xIntellectualPropertyExpander
->set_expanded(true);
276 ClassificationDialog::~ClassificationDialog()
278 if (m_nAsyncExpandEvent
)
279 Application::RemoveUserEvent(m_nAsyncExpandEvent
);
282 void ClassificationDialog::insertCategoryField(sal_Int32 nID
)
284 const OUString aFullString
= maHelper
.GetBACNames()[nID
];
285 const OUString aAbbreviatedString
= maHelper
.GetAbbreviatedBACNames()[nID
];
286 const OUString aIdentifierString
= maHelper
.GetBACIdentifiers()[nID
];
287 insertField(ClassificationType::CATEGORY
, aAbbreviatedString
, aFullString
, aIdentifierString
);
290 void ClassificationDialog::insertField(ClassificationType eType
, OUString
const & rString
, OUString
const & rFullString
, OUString
const & rIdentifier
)
292 ClassificationField
aField(eType
, rString
, rFullString
, rIdentifier
);
293 m_xEditWindow
->InsertField(SvxFieldItem(aField
, EE_FEATURE_FIELD
));
296 void ClassificationDialog::setupValues(std::vector
<ClassificationResult
> && rInput
)
298 m_aInitialValues
= std::move(rInput
);
299 readIn(m_aInitialValues
);
302 void ClassificationDialog::readRecentlyUsed()
304 OUString sPath
= lcl_getClassificationUserPath();
305 OUString
sFilePath(sPath
+ constRecentlyUsedFileName
);
307 if (!fileExists(sFilePath
))
310 SvFileStream
aFileStream(sFilePath
, StreamMode::READ
);
311 tools::XmlWalker aWalker
;
312 if (!aWalker
.open(&aFileStream
))
315 if (aWalker
.name() != "recentlyUsedClassifications")
319 while (aWalker
.isValid())
321 if (aWalker
.name() == "elementGroup")
323 std::vector
<ClassificationResult
> aResults
;
327 while (aWalker
.isValid())
329 if (aWalker
.name() == "element")
331 svx::ClassificationType eType
= svx::ClassificationType::TEXT
;
333 OUString sAbbreviatedString
;
334 OUString sIdentifier
;
336 // Convert string to classification type, but continue only if
337 // conversion was successful.
338 if (stringToClassificationType(aWalker
.attribute("type"), eType
))
342 while (aWalker
.isValid())
344 if (aWalker
.name() == "string")
346 sString
= OStringToOUString(aWalker
.content(), RTL_TEXTENCODING_UTF8
);
348 else if (aWalker
.name() == "abbreviatedString")
350 sAbbreviatedString
= OStringToOUString(aWalker
.content(), RTL_TEXTENCODING_UTF8
);
352 else if (aWalker
.name() == "identifier")
354 sIdentifier
= OStringToOUString(aWalker
.content(), RTL_TEXTENCODING_UTF8
);
360 aResults
.push_back({ eType
, sString
, sAbbreviatedString
, sIdentifier
});
366 m_aRecentlyUsedValuesCollection
.push_back(aResults
);
373 void ClassificationDialog::writeRecentlyUsed()
375 OUString sPath
= lcl_getClassificationUserPath();
376 osl::Directory::createPath(sPath
);
377 OUString
sFilePath(sPath
+ constRecentlyUsedFileName
);
379 std::unique_ptr
<SvStream
> pStream
;
380 pStream
.reset(new SvFileStream(sFilePath
, StreamMode::STD_READWRITE
| StreamMode::TRUNC
));
382 tools::XmlWriter
aXmlWriter(pStream
.get());
384 if (!aXmlWriter
.startDocument())
387 aXmlWriter
.startElement("recentlyUsedClassifications");
389 aXmlWriter
.startElement("elementGroup");
391 writeResultToXml(aXmlWriter
, getResult());
393 aXmlWriter
.endElement();
395 if (m_aRecentlyUsedValuesCollection
.size() >= RECENTLY_USED_LIMIT
)
396 m_aRecentlyUsedValuesCollection
.pop_back();
398 for (std::vector
<ClassificationResult
> const & rResultCollection
: m_aRecentlyUsedValuesCollection
)
400 aXmlWriter
.startElement("elementGroup");
402 writeResultToXml(aXmlWriter
, rResultCollection
);
404 aXmlWriter
.endElement();
407 aXmlWriter
.endElement();
409 aXmlWriter
.endDocument();
412 void ClassificationDialog::readIn(std::vector
<ClassificationResult
> const & rInput
)
414 sal_Int32 nParagraph
= -1;
416 for (ClassificationResult
const & rClassificationResult
: rInput
)
419 switch (rClassificationResult
.meType
)
421 case svx::ClassificationType::TEXT
:
423 m_xEditWindow
->getEditView().InsertText(rClassificationResult
.msName
);
427 case svx::ClassificationType::CATEGORY
:
430 if (rClassificationResult
.msName
.isEmpty())
431 sName
= maHelper
.GetBACNameForIdentifier(rClassificationResult
.msIdentifier
);
433 sName
= rClassificationResult
.msName
;
435 OUString sAbbreviatedName
= rClassificationResult
.msAbbreviatedName
;
436 if (sAbbreviatedName
.isEmpty())
437 sAbbreviatedName
= maHelper
.GetAbbreviatedBACName(sName
);
439 m_xClassificationListBox
->set_active_text(sName
);
440 m_nCurrentSelectedCategory
= m_xClassificationListBox
->get_active();
441 m_xInternationalClassificationListBox
->set_active(m_xClassificationListBox
->get_active());
443 insertField(rClassificationResult
.meType
, sAbbreviatedName
, sName
, rClassificationResult
.msIdentifier
);
447 case svx::ClassificationType::MARKING
:
449 m_xMarkingListBox
->select_text(rClassificationResult
.msName
);
450 insertField(rClassificationResult
.meType
, rClassificationResult
.msName
, rClassificationResult
.msName
, rClassificationResult
.msIdentifier
);
454 case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART
:
456 insertField(rClassificationResult
.meType
, rClassificationResult
.msName
, rClassificationResult
.msName
, rClassificationResult
.msIdentifier
);
460 case svx::ClassificationType::PARAGRAPH
:
465 m_xEditWindow
->getEditView().InsertParaBreak();
467 // Set paragraph font weight
468 FontWeight eWeight
= (rClassificationResult
.msName
== "BOLD") ? WEIGHT_BOLD
: WEIGHT_NORMAL
;
470 ClassificationEditEngine
& rEdEngine
= m_xEditWindow
->getEditEngine();
471 SfxItemSet
aSet(rEdEngine
.GetParaAttribs(nParagraph
));
472 aSet
.Put(SvxWeightItem(eWeight
, EE_CHAR_WEIGHT
));
473 rEdEngine
.SetParaAttribs(nParagraph
, aSet
);
481 toggleWidgetsDependingOnCategory();
484 void ClassificationDialog::toggleWidgetsDependingOnCategory()
486 const EditEngine
& rEditEngine
= m_xEditWindow
->getEditEngine();
488 for (sal_Int32 nParagraph
= 0; nParagraph
< rEditEngine
.GetParagraphCount(); ++nParagraph
)
490 sal_uInt16 nFieldCount
= rEditEngine
.GetFieldCount(nParagraph
);
491 for (sal_uInt16 nField
= 0; nField
< nFieldCount
; ++nField
)
493 EFieldInfo aFieldInfo
= rEditEngine
.GetFieldInfo(nParagraph
, nField
);
494 if (aFieldInfo
.pFieldItem
)
496 const ClassificationField
* pClassificationField
= dynamic_cast<const ClassificationField
*>(aFieldInfo
.pFieldItem
->GetField());
497 if (pClassificationField
&& pClassificationField
->meType
== ClassificationType::CATEGORY
)
499 m_xOkButton
->set_sensitive(true);
506 // Category field in the text edit has been deleted, so reset the list boxes
507 m_xOkButton
->set_sensitive(false);
508 m_xClassificationListBox
->set_active(-1);
509 m_xInternationalClassificationListBox
->set_active(-1);
512 std::vector
<ClassificationResult
> ClassificationDialog::getResult()
514 std::vector
<ClassificationResult
> aClassificationResults
;
516 ClassificationEditEngine
& rEdEngine
= m_xEditWindow
->getEditEngine();
517 std::unique_ptr
<EditTextObject
> pEditText(rEdEngine
.CreateTextObject());
519 sal_Int32 nCurrentParagraph
= -1;
521 std::vector
<editeng::Section
> aSections
;
522 pEditText
->GetAllSections(aSections
);
523 for (editeng::Section
const & rSection
: aSections
)
525 while (nCurrentParagraph
< rSection
.mnParagraph
)
529 // Get Weight of current paragraph
530 FontWeight eFontWeight
= WEIGHT_NORMAL
;
531 SfxItemSet
aItemSet(rEdEngine
.GetParaAttribs(nCurrentParagraph
));
532 if (const SfxPoolItem
* pItem
= aItemSet
.GetItem(EE_CHAR_WEIGHT
, false))
534 const SvxWeightItem
* pWeightItem
= dynamic_cast<const SvxWeightItem
*>(pItem
);
535 if (pWeightItem
&& pWeightItem
->GetWeight() == WEIGHT_BOLD
)
536 eFontWeight
= WEIGHT_BOLD
;
538 // Font weight to string
539 OUString sWeightProperty
= "NORMAL";
540 if (eFontWeight
== WEIGHT_BOLD
)
541 sWeightProperty
= "BOLD";
542 // Insert into collection
544 aClassificationResults
.push_back({ ClassificationType::PARAGRAPH
, sWeightProperty
, sBlank
, sBlank
});
547 const SvxFieldItem
* pFieldItem
= findField(rSection
);
549 ESelection
aSelection(rSection
.mnParagraph
, rSection
.mnStart
, rSection
.mnParagraph
, rSection
.mnEnd
);
550 const OUString sDisplayString
= rEdEngine
.GetText(aSelection
);
551 if (!sDisplayString
.isEmpty())
553 const ClassificationField
* pClassificationField
= pFieldItem
? dynamic_cast<const ClassificationField
*>(pFieldItem
->GetField()) : nullptr;
555 if (pClassificationField
)
557 aClassificationResults
.push_back({ pClassificationField
->meType
, pClassificationField
->msFullClassName
,
558 pClassificationField
->msDescription
, pClassificationField
->msIdentifier
});
562 aClassificationResults
.push_back({ ClassificationType::TEXT
, sDisplayString
, sDisplayString
, OUString() });
567 return aClassificationResults
;
570 IMPL_LINK(ClassificationDialog
, SelectClassificationHdl
, weld::ComboBox
&, rBox
, void)
572 const sal_Int32 nSelected
= rBox
.get_active();
573 if (nSelected
< 0 || m_nCurrentSelectedCategory
== nSelected
)
576 std::unique_ptr
<EditTextObject
> pEditText(m_xEditWindow
->getEditEngine().CreateTextObject());
577 std::vector
<editeng::Section
> aSections
;
578 pEditText
->GetAllSections(aSections
);
580 // if we are replacing an existing field
581 bool bReplaceExisting
= false;
582 // selection of the existing field, which will be replaced
583 ESelection aExistingFieldSelection
;
585 for (editeng::Section
const & rSection
: aSections
)
587 const SvxFieldItem
* pFieldItem
= findField(rSection
);
590 const ClassificationField
* pClassificationField
= dynamic_cast<const ClassificationField
*>(pFieldItem
->GetField());
591 if (pClassificationField
&& pClassificationField
->meType
== ClassificationType::CATEGORY
)
593 aExistingFieldSelection
= ESelection(rSection
.mnParagraph
, rSection
.mnStart
,
594 rSection
.mnParagraph
, rSection
.mnEnd
);
595 bReplaceExisting
= true;
600 if (bReplaceExisting
)
601 m_xEditWindow
->getEditView().SetSelection(aExistingFieldSelection
);
603 insertCategoryField(nSelected
);
605 // Change category to the new selection
606 m_xInternationalClassificationListBox
->set_active(nSelected
);
607 m_xClassificationListBox
->set_active(nSelected
);
608 m_nCurrentSelectedCategory
= nSelected
;
611 IMPL_LINK(ClassificationDialog
, SelectMarkingHdl
, weld::TreeView
&, rBox
, bool)
613 sal_Int32 nSelected
= rBox
.get_selected_index();
616 const OUString aString
= maHelper
.GetMarkings()[nSelected
];
617 insertField(ClassificationType::MARKING
, aString
, aString
);
622 IMPL_LINK(ClassificationDialog
, SelectIPPartNumbersHdl
, weld::TreeView
&, rBox
, bool)
624 sal_Int32 nSelected
= rBox
.get_selected_index();
627 OUString sString
= maHelper
.GetIntellectualPropertyPartNumbers()[nSelected
];
628 m_xIntellectualPropertyPartEdit
->replace_selection(sString
);
629 m_xIntellectualPropertyPartEdit
->grab_focus();
634 IMPL_LINK(ClassificationDialog
, SelectRecentlyUsedHdl
, weld::ComboBox
&, rBox
, void)
636 sal_Int32 nSelected
= rBox
.get_active();
639 m_xEditWindow
->getEditEngine().Clear();
640 readIn(m_aRecentlyUsedValuesCollection
[nSelected
]);
644 IMPL_LINK(ClassificationDialog
, SelectIPPartHdl
, weld::TreeView
&, rBox
, bool)
646 const sal_Int32 nSelected
= rBox
.get_selected_index();
649 const OUString sString
= maHelper
.GetIntellectualPropertyParts()[nSelected
];
650 m_xIntellectualPropertyPartEdit
->replace_selection(sString
);
651 m_xIntellectualPropertyPartEdit
->grab_focus();
656 IMPL_LINK(ClassificationDialog
, ButtonClicked
, weld::Button
&, rButton
, void)
658 if (&rButton
== m_xSignButton
.get())
660 m_aParagraphSignHandler();
662 else if (&rButton
== m_xIntellectualPropertyPartAddButton
.get())
664 const OUString sString
= m_xIntellectualPropertyPartEdit
->get_text();
665 insertField(ClassificationType::INTELLECTUAL_PROPERTY_PART
, sString
, sString
);
669 IMPL_LINK_NOARG(ClassificationDialog
, OkHdl
, weld::Button
&, void)
672 m_xDialog
->response(RET_OK
);
675 IMPL_LINK_NOARG(ClassificationDialog
, SelectToolboxHdl
, weld::Toggleable
&, void)
677 m_xEditWindow
->InvertSelectionWeight();
680 IMPL_LINK_NOARG(ClassificationDialog
, EditWindowModifiedHdl
, LinkParamNone
*, void)
682 toggleWidgetsDependingOnCategory();
685 IMPL_STATIC_LINK(ClassificationDialog
, ExpandedHdl
, weld::Expander
&, rExpander
, void)
687 std::shared_ptr
<comphelper::ConfigurationChanges
> aConfigurationChanges(comphelper::ConfigurationChanges::create());
688 officecfg::Office::Common::Classification::IntellectualPropertySectionExpanded::set(rExpander
.get_expanded(), aConfigurationChanges
);
689 aConfigurationChanges
->commit();
694 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */