Kaydet (Commit) 8747abf7 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

TSCP: disable OK button if no category is present in text edit

Change-Id: I638f04e904a642e4fd6700e625732e5a9a2e44de
Reviewed-on: https://gerrit.libreoffice.org/44292Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 30c10ae1
......@@ -37,6 +37,7 @@ protected:
class SVX_DLLPUBLIC ClassificationDialog : public ModalDialog
{
private:
VclPtr<PushButton> m_pOkButton;
VclPtr<ClassificationEditView> m_pEditWindow;
VclPtr<PushButton> m_pSignButton;
VclPtr<PushButton> m_pBoldButton;
......@@ -65,6 +66,8 @@ private:
DECL_LINK(SelectIPPartNumbersHdl, ListBox&, void);
DECL_LINK(SelectRecentlyUsedHdl, ListBox&, void);
DECL_LINK(SelectIPPartHdl, ListBox&, void);
DECL_LINK(EditWindowModifiedHdl, LinkParamNone*, void);
void insertField(ClassificationType eType, OUString const & rString, OUString const & rFullString, OUString const & rIdentifier = OUString());
......@@ -74,6 +77,7 @@ private:
void readIn(std::vector<ClassificationResult> const & rInput);
void readRecentlyUsed();
void writeRecentlyUsed();
void toggleWidgetsDependingOnCategory();
public:
ClassificationDialog(vcl::Window* pParent, bool bPerParagraph, const std::function<void()>& rParagraphSignHandler = [](){});
......
......@@ -49,6 +49,16 @@ public:
std::unique_ptr<ClassificationEditEngine> pEdEngine;
std::unique_ptr<EditView> pEdView;
const ClassificationEditEngine& getEditEngine()
{
return *pEdEngine.get();
}
void SetModifyHdl(const Link<LinkParamNone*,void>& rLink)
{
pEdEngine->SetModifyHdl(rLink);
}
protected:
virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
virtual void MouseMove( const MouseEvent& rMEvt ) override;
......
......@@ -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: */
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment