diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2017-11-04 12:08:32 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2017-11-05 13:20:18 +0100 |
commit | 8747abf7708e06d6f989258b1cf102c144162cfa (patch) | |
tree | 50fa74bd3cc7298db6eecd1d7b2137c0a21b85dc /svx | |
parent | 30c10ae1b38342ced95889b33d95fe39c7cf6679 (diff) |
TSCP: disable OK button if no category is present in text edit
Change-Id: I638f04e904a642e4fd6700e625732e5a9a2e44de
Reviewed-on: https://gerrit.libreoffice.org/44292
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/dialog/ClassificationDialog.cxx | 39 | ||||
-rw-r--r-- | svx/uiconfig/ui/classificationdialog.ui | 2 |
2 files changed, 41 insertions, 0 deletions
diff --git a/svx/source/dialog/ClassificationDialog.cxx b/svx/source/dialog/ClassificationDialog.cxx index 3210d1a2f761..9458ceb95b3e 100644 --- a/svx/source/dialog/ClassificationDialog.cxx +++ b/svx/source/dialog/ClassificationDialog.cxx @@ -174,6 +174,7 @@ ClassificationDialog::ClassificationDialog(vcl::Window* pParent, const bool bPer , m_bPerParagraph(bPerParagraph) , m_aParagraphSignHandler(rParagraphSignHandler) { + get(m_pOkButton, "ok"); get(m_pEditWindow, "classificationEditWindow"); get(m_pSignButton, "signButton"); get(m_pBoldButton, "boldButton"); @@ -232,6 +233,8 @@ ClassificationDialog::ClassificationDialog(vcl::Window* pParent, const bool bPer bool bExpand = officecfg::Office::Common::Classification::IntellectualPropertySectionExpanded::get(); m_pIntellectualPropertyExpander->set_expanded(bExpand); + + m_pEditWindow->SetModifyHdl(LINK(this, ClassificationDialog, EditWindowModifiedHdl)); } ClassificationDialog::~ClassificationDialog() @@ -241,6 +244,7 @@ ClassificationDialog::~ClassificationDialog() void ClassificationDialog::dispose() { + m_pOkButton.clear(); m_pEditWindow.clear(); m_pSignButton.clear(); m_pBoldButton.clear(); @@ -472,6 +476,35 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp break; } } + toggleWidgetsDependingOnCategory(); +} + +void ClassificationDialog::toggleWidgetsDependingOnCategory() +{ + const EditEngine& rEditEngine = m_pEditWindow->getEditEngine(); + + for (sal_Int32 nParagraph = 0; nParagraph < rEditEngine.GetParagraphCount(); ++nParagraph) + { + sal_uInt16 nFieldCount = rEditEngine.GetFieldCount(nParagraph); + for (sal_Int16 nField = 0; nField < nFieldCount; ++nField) + { + EFieldInfo aFieldInfo = rEditEngine.GetFieldInfo(nParagraph, nField); + if (aFieldInfo.pFieldItem) + { + const ClassificationField* pClassificationField = dynamic_cast<const ClassificationField*>(aFieldInfo.pFieldItem->GetField()); + if (pClassificationField && pClassificationField->meType == ClassificationType::CATEGORY) + { + m_pOkButton->Enable(); + return; + } + } + } + } + + // Category field in the text edit has been deleted, so reset the list boxes + m_pOkButton->Disable(); + m_pClassificationListBox->SetNoSelection(); + m_pInternationalClassificationListBox->SetNoSelection(); } std::vector<ClassificationResult> ClassificationDialog::getResult() @@ -661,6 +694,12 @@ IMPL_LINK(ClassificationDialog, ButtonClicked, Button*, pButton, void) } } +IMPL_LINK_NOARG(ClassificationDialog, EditWindowModifiedHdl, LinkParamNone*, void) +{ + toggleWidgetsDependingOnCategory(); +} + + } // end svx /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/uiconfig/ui/classificationdialog.ui b/svx/uiconfig/ui/classificationdialog.ui index 40464427568a..ab4f449726a3 100644 --- a/svx/uiconfig/ui/classificationdialog.ui +++ b/svx/uiconfig/ui/classificationdialog.ui @@ -22,6 +22,8 @@ <property name="label">gtk-ok</property> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> <property name="receives_default">True</property> <property name="use_stock">True</property> </object> |