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>
31 #include <officecfg/Office/Common.hxx>
33 #include "ClassificationEditView.hxx"
37 IMPL_STATIC_LINK(ClassificationDialog
, KeyInput
, const KeyEvent
&, rKeyEvent
, bool)
39 bool bTextIsFreeForm
= officecfg::Office::Common::Classification::IntellectualPropertyTextInputIsFreeForm::get();
43 // Ignore key combination with modifier keys
44 if (rKeyEvent
.GetKeyCode().IsMod3()
45 || rKeyEvent
.GetKeyCode().IsMod2()
46 || rKeyEvent
.GetKeyCode().IsMod1())
51 switch (rKeyEvent
.GetKeyCode().GetCode())
60 // Anything else is ignored
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
);
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
);
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
;
116 OUString
classificationTypeToString(svx::ClassificationType
const & 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;
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
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
);
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
));
243 m_nAsyncExpandEvent
= nullptr;
245 m_xEditWindow
->SetModifyHdl(LINK(this, ClassificationDialog
, EditWindowModifiedHdl
));
248 toggleWidgetsDependingOnCategory();
251 if (m_aRecentlyUsedValuesCollection
.empty())
253 m_xRecentlyUsedListBox
->set_sensitive(false);
257 for (std::vector
<ClassificationResult
> const & rResults
: m_aRecentlyUsedValuesCollection
)
259 OUString rContentRepresentation
= svx::classification::convertClassificationResultToString(rResults
);
260 OUString rDescription
= OUString::number(nNumber
) + ": " + rContentRepresentation
;
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
))
309 SvFileStream
aFileStream(sFilePath
, StreamMode::READ
);
310 tools::XmlWalker aWalker
;
311 if (!aWalker
.open(&aFileStream
))
314 if (aWalker
.name() != "recentlyUsedClassifications")
318 while (aWalker
.isValid())
320 if (aWalker
.name() == "elementGroup")
322 std::vector
<ClassificationResult
> aResults
;
326 while (aWalker
.isValid())
328 if (aWalker
.name() == "element")
330 svx::ClassificationType eType
= svx::ClassificationType::TEXT
;
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
))
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
);
359 aResults
.emplace_back(eType
, sString
, sAbbreviatedString
, sIdentifier
);
365 m_aRecentlyUsedValuesCollection
.push_back(aResults
);
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())
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
);
426 case svx::ClassificationType::CATEGORY
:
429 if (rClassificationResult
.msName
.isEmpty())
430 sName
= maHelper
.GetBACNameForIdentifier(rClassificationResult
.msIdentifier
);
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
);
446 case svx::ClassificationType::MARKING
:
448 m_xMarkingListBox
->select_text(rClassificationResult
.msName
);
449 insertField(rClassificationResult
.meType
, rClassificationResult
.msName
, rClassificationResult
.msName
, rClassificationResult
.msIdentifier
);
453 case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART
:
455 insertField(rClassificationResult
.meType
, rClassificationResult
.msName
, rClassificationResult
.msName
, rClassificationResult
.msIdentifier
);
459 case svx::ClassificationType::PARAGRAPH
:
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
);
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);
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
)
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
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
);
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
)
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
);
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();
613 const OUString aString
= maHelper
.GetMarkings()[nSelected
];
614 insertField(ClassificationType::MARKING
, aString
, aString
);
619 IMPL_LINK(ClassificationDialog
, SelectIPPartNumbersHdl
, weld::TreeView
&, rBox
, bool)
621 sal_Int32 nSelected
= rBox
.get_selected_index();
624 OUString sString
= maHelper
.GetIntellectualPropertyPartNumbers()[nSelected
];
625 m_xIntellectualPropertyPartEdit
->replace_selection(sString
);
626 m_xIntellectualPropertyPartEdit
->grab_focus();
631 IMPL_LINK(ClassificationDialog
, SelectRecentlyUsedHdl
, weld::ComboBox
&, rBox
, void)
633 sal_Int32 nSelected
= rBox
.get_active();
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();
646 const OUString sString
= maHelper
.GetIntellectualPropertyParts()[nSelected
];
647 m_xIntellectualPropertyPartEdit
->replace_selection(sString
);
648 m_xIntellectualPropertyPartEdit
->grab_focus();
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)
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();
691 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */