[Libreoffice-commits] core.git: include/svx svx/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Sat Nov 4 01:49:04 UTC 2017
include/svx/ClassificationDialog.hxx | 2 +
include/svx/strings.hrc | 3 +
svx/source/dialog/ClassificationDialog.cxx | 45 +++++++++++++++++++++++------
3 files changed, 41 insertions(+), 9 deletions(-)
New commits:
commit 8f1f4d5a6f4b376975e9e2f318e8c92d4bade90a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Fri Nov 3 21:04:32 2017 +0900
TSCP: Ask if it is OK to change the classification category
Change-Id: I30ccdfb9d0584d8ee9b12666b1f96eb9ba8676ee
Reviewed-on: https://gerrit.libreoffice.org/44278
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/svx/ClassificationDialog.hxx b/include/svx/ClassificationDialog.hxx
index 85a70eb95f95..59502eca4286 100644
--- a/include/svx/ClassificationDialog.hxx
+++ b/include/svx/ClassificationDialog.hxx
@@ -48,6 +48,8 @@ private:
const bool m_bPerParagraph;
const std::function<void()> m_aParagraphSignHandler;
+ sal_Int32 m_nCurrentSelectedCategory;
+
DECL_LINK(ButtonClicked, Button*, void);
DECL_LINK(SelectClassificationHdl, ListBox&, void);
DECL_LINK(SelectMarkingHdl, ListBox&, void);
diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc
index 208ba1bc7e49..bed776d4ce1a 100644
--- a/include/svx/strings.hrc
+++ b/include/svx/strings.hrc
@@ -1646,6 +1646,9 @@
#define RID_SUBSETSTR_TANGUT NC_("RID_SUBSETMAP", "Tangut")
#define RID_SUBSETSTR_TANGUT_COMPONENTS NC_("RID_SUBSETMAP", "Tangut Components")
+// TSCP Classification
+#define RID_CLASSIFICATION_CHANGE_CATEGORY NC_("RID_CLASSIFICATION_CHANGE_CATEGORY", "Do you really want to change the classification category?")
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/ClassificationDialog.cxx b/svx/source/dialog/ClassificationDialog.cxx
index 30f6c796240f..2e8b0c4ad8fc 100644
--- a/svx/source/dialog/ClassificationDialog.cxx
+++ b/svx/source/dialog/ClassificationDialog.cxx
@@ -9,13 +9,16 @@
*/
#include <svx/ClassificationDialog.hxx>
+#include <svx/strings.hrc>
+#include <svx/dialmgr.hxx>
+
#include <editeng/flditem.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/section.hxx>
#include <editeng/editobj.hxx>
#include <editeng/wghtitem.hxx>
#include <svl/itemset.hxx>
-
+#include <vcl/msgbox.hxx>
#include <osl/file.hxx>
#include <rtl/bootstrap.hxx>
#include <rtl/uri.hxx>
@@ -371,9 +374,9 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp
sal_Int32 nParagraph = -1;
for (ClassificationResult const & rClassificationResult : rInput)
{
- OUString msAbbreviatedName = rClassificationResult.msAbbreviatedName;
- if (msAbbreviatedName.isEmpty())
- msAbbreviatedName = maHelper.GetAbbreviatedBACName(rClassificationResult.msName);
+ OUString sAbbreviatedName = rClassificationResult.msAbbreviatedName;
+ if (sAbbreviatedName.isEmpty())
+ sAbbreviatedName = maHelper.GetAbbreviatedBACName(rClassificationResult.msName);
switch (rClassificationResult.meType)
{
@@ -386,21 +389,23 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp
case svx::ClassificationType::CATEGORY:
{
m_pClassificationListBox->SelectEntry(rClassificationResult.msName);
+ m_nCurrentSelectedCategory = m_pClassificationListBox->GetSelectedEntryPos();
m_pInternationalClassificationListBox->SelectEntryPos(m_pClassificationListBox->GetSelectedEntryPos());
- insertField(rClassificationResult.meType, msAbbreviatedName, rClassificationResult.msName, rClassificationResult.msIdentifier);
+
+ insertField(rClassificationResult.meType, sAbbreviatedName, rClassificationResult.msName, rClassificationResult.msIdentifier);
}
break;
case svx::ClassificationType::MARKING:
{
m_pMarkingListBox->SelectEntry(rClassificationResult.msName);
- insertField(rClassificationResult.meType, msAbbreviatedName, rClassificationResult.msName, rClassificationResult.msIdentifier);
+ insertField(rClassificationResult.meType, sAbbreviatedName, rClassificationResult.msName, rClassificationResult.msIdentifier);
}
break;
case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART:
{
- insertField(rClassificationResult.meType, msAbbreviatedName, rClassificationResult.msName, rClassificationResult.msIdentifier);
+ insertField(rClassificationResult.meType, sAbbreviatedName, rClassificationResult.msName, rClassificationResult.msIdentifier);
}
break;
@@ -485,12 +490,17 @@ std::vector<ClassificationResult> ClassificationDialog::getResult()
IMPL_LINK(ClassificationDialog, SelectClassificationHdl, ListBox&, rBox, void)
{
const sal_Int32 nSelected = rBox.GetSelectedEntryPos();
- if (nSelected >= 0)
+ if (nSelected >= 0 && m_nCurrentSelectedCategory != nSelected)
{
std::unique_ptr<EditTextObject> pEditText(m_pEditWindow->pEdEngine->CreateTextObject());
std::vector<editeng::Section> aSections;
pEditText->GetAllSections(aSections);
+ // if we are replacing an existing field
+ bool bReplaceExisting = false;
+ // selection of the existing field, which will be replaced
+ ESelection aExistingFieldSelection;
+
for (editeng::Section const & rSection : aSections)
{
const SvxFieldItem* pFieldItem = findField(rSection);
@@ -499,18 +509,35 @@ IMPL_LINK(ClassificationDialog, SelectClassificationHdl, ListBox&, rBox, void)
const ClassificationField* pClassificationField = dynamic_cast<const ClassificationField*>(pFieldItem->GetField());
if (pClassificationField && pClassificationField->meType == ClassificationType::CATEGORY)
{
- m_pEditWindow->pEdView->SetSelection(ESelection(rSection.mnParagraph, rSection.mnStart, rSection.mnParagraph, rSection.mnEnd));
+ aExistingFieldSelection = ESelection(rSection.mnParagraph, rSection.mnStart,
+ rSection.mnParagraph, rSection.mnEnd);
+ bReplaceExisting = true;
}
}
}
+ if (bReplaceExisting)
+ {
+ ScopedVclPtrInstance<QueryBox> aQueryBox(this, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, SvxResId(RID_CLASSIFICATION_CHANGE_CATEGORY));
+ if (aQueryBox->Execute() == RET_NO)
+ {
+ // Revert to previosuly selected
+ m_pInternationalClassificationListBox->SelectEntryPos(m_nCurrentSelectedCategory);
+ m_pClassificationListBox->SelectEntryPos(m_nCurrentSelectedCategory);
+ return;
+ }
+ m_pEditWindow->pEdView->SetSelection(aExistingFieldSelection);
+ }
+
const OUString aFullString = maHelper.GetBACNames()[nSelected];
const OUString aAbbreviatedString = maHelper.GetAbbreviatedBACNames()[nSelected];
const OUString aIdentifierString = maHelper.GetBACIdentifiers()[nSelected];
insertField(ClassificationType::CATEGORY, aAbbreviatedString, aFullString, aIdentifierString);
+ // Change category to the new selection
m_pInternationalClassificationListBox->SelectEntryPos(nSelected);
m_pClassificationListBox->SelectEntryPos(nSelected);
+ m_nCurrentSelectedCategory = nSelected;
}
}
More information about the Libreoffice-commits
mailing list