diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2017-09-11 14:48:42 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2017-09-19 15:22:47 +0200 |
commit | dcd2eb0aa5fa7b98ee7717cf616266d0278be502 (patch) | |
tree | 70d956c10a3a54013286fdfc5c24995d61c57bf5 | |
parent | TSCP: prepare toolbar for the document level classification dialog (diff) | |
download | core-dcd2eb0aa5fa7b98ee7717cf616266d0278be502.tar.gz core-dcd2eb0aa5fa7b98ee7717cf616266d0278be502.zip |
TSCP: Advanced document classification dialog
Change-Id: I4a29e3955d5fab702f14239e4435c65b10d3d234
-rw-r--r-- | include/svx/ClassificationDialog.hxx | 59 | ||||
-rw-r--r-- | svx/Library_svx.mk | 1 | ||||
-rw-r--r-- | svx/UIConfig_svx.mk | 1 | ||||
-rw-r--r-- | svx/sdi/svx.sdi | 2 | ||||
-rw-r--r-- | svx/source/dialog/ClassificationDialog.cxx | 185 | ||||
-rw-r--r-- | svx/uiconfig/ui/classificationdialog.ui | 349 | ||||
-rw-r--r-- | sw/source/uibase/app/docsh2.cxx | 14 |
7 files changed, 610 insertions, 1 deletions
diff --git a/include/svx/ClassificationDialog.hxx b/include/svx/ClassificationDialog.hxx new file mode 100644 index 000000000000..3556439407e2 --- /dev/null +++ b/include/svx/ClassificationDialog.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#ifndef INCLUDED_SVX_CLASSIFICATIONDIALOG_HXX +#define INCLUDED_SVX_CLASSIFICATIONDIALOG_HXX + +#include <sal/config.h> +#include <vcl/dialog.hxx> +#include <vcl/button.hxx> +#include <vcl/lstbox.hxx> +#include <svx/svxdllapi.h> +#include <svx/ClassificationEditView.hxx> +#include <sfx2/classificationhelper.hxx> +#include <svx/ClassificationField.hxx> + +namespace svx { + +class SVX_DLLPUBLIC ClassificationDialog : public ModalDialog +{ +private: + VclPtr<ClassificationEditView> m_pEditWindow; + VclPtr<PushButton> m_pBoldButton; + VclPtr<ListBox> m_pClassificationListBox; + VclPtr<ListBox> m_pInternationalClassificationListBox; + VclPtr<ListBox> m_pMarkingListBox; + VclPtr<ListBox> m_pIntellectualPropertyPartListBox; + VclPtr<ListBox> m_pIntellectualPropertyPartNumberListBox; + VclPtr<PushButton> m_pIntellectualPropertyPartAddButton; + + SfxClassificationHelper maHelper; + + DECL_LINK(ButtonClicked, Button*, void); + DECL_LINK(SelectClassificationHdl, ListBox&, void); + DECL_LINK(SelectMarkingHdl, ListBox&, void); + + DECL_LINK(SelectIPPartHdl, ListBox&, void); + DECL_LINK(DoubleClickIPPartHdl, ListBox&, void); + +public: + virtual short Execute() override; + ClassificationDialog(vcl::Window* pParent); + virtual ~ClassificationDialog() override; + virtual void dispose() override; + + std::vector<ClassificationResult> getResult(); +}; + +} // end svx namespace + +#endif // INCLUDED_SVX_CLASSIFICATIONDIALOG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index 1189b8c29bc0..c04dfc8e6dc4 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -117,6 +117,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\ svx/source/dialog/crashreportdlg \ svx/source/dialog/crashreportui) \ svx/source/dialog/ctredlin \ + svx/source/dialog/ClassificationDialog \ svx/source/dialog/ClassificationEditView \ svx/source/dialog/databaseregistrationui \ svx/source/dialog/dialcontrol \ diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index d836697afe8b..831e1d20a27c 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -21,6 +21,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/cellmenu \ svx/uiconfig/ui/chineseconversiondialog \ svx/uiconfig/ui/chinesedictionary \ + svx/uiconfig/ui/classificationdialog \ svx/uiconfig/ui/colorwindow \ svx/uiconfig/ui/colsmenu \ svx/uiconfig/ui/compressgraphicdialog \ diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index 4a19a0323a4a..e0f3e4d378b0 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -4388,7 +4388,7 @@ SfxVoidItem ClassificationDialog SID_CLASSIFICATION_DIALOG AccelConfig = TRUE, MenuConfig = TRUE, ToolBoxConfig = TRUE, - GroupId = GID_DOCUMENT; + GroupId = SfxGroupId::Document; ] SfxBoolItem Init3D SID_3D_INIT diff --git a/svx/source/dialog/ClassificationDialog.cxx b/svx/source/dialog/ClassificationDialog.cxx new file mode 100644 index 000000000000..d71add613182 --- /dev/null +++ b/svx/source/dialog/ClassificationDialog.cxx @@ -0,0 +1,185 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#include <svx/ClassificationDialog.hxx> +#include <editeng/flditem.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/section.hxx> +#include <editeng/editobj.hxx> +#include <svl/itemset.hxx> + +namespace svx { + +namespace { + +const SvxFieldItem* findField(editeng::Section const & rSection) +{ + for (SfxPoolItem const * pPool: rSection.maAttributes) + { + if (pPool->Which() == EE_FEATURE_FIELD) + return static_cast<const SvxFieldItem*>(pPool); + } + return nullptr; +} + +} // end anonymous namespace + +ClassificationDialog::ClassificationDialog(vcl::Window* pParent) + : ModalDialog(pParent, "AdvancedDocumentClassificationDialog", "svx/ui/classificationdialog.ui") + , maHelper(SfxObjectShell::Current()->getDocProperties()) +{ + get(m_pEditWindow, "classificationEditWindow"); + get(m_pBoldButton, "boldButton"); + get(m_pClassificationListBox, "classificationCB"); + get(m_pInternationalClassificationListBox, "internationalClassificationCB"); + get(m_pMarkingListBox, "markingCB"); + get(m_pIntellectualPropertyPartNumberListBox, "intellectualPropertyPartNumberCB"); + get(m_pIntellectualPropertyPartListBox, "intellectualPropertyPartLB"); + get(m_pIntellectualPropertyPartAddButton, "intellectualPropertyPartAddButton"); + + m_pBoldButton->SetClickHdl(LINK(this, ClassificationDialog, ButtonClicked)); + m_pIntellectualPropertyPartAddButton->SetClickHdl(LINK(this, ClassificationDialog, ButtonClicked)); + + m_pClassificationListBox->SetSelectHdl(LINK(this, ClassificationDialog, SelectClassificationHdl)); + for (const OUString& rName : maHelper.GetBACNames()) + m_pClassificationListBox->InsertEntry(rName); + m_pClassificationListBox->EnableAutoSize(true); + + m_pMarkingListBox->SetSelectHdl(LINK(this, ClassificationDialog, SelectMarkingHdl)); + for (const OUString& rName : maHelper.GetMarkings()) + m_pMarkingListBox->InsertEntry(rName); + m_pMarkingListBox->EnableAutoSize(true); + + m_pIntellectualPropertyPartListBox->SetSelectHdl(LINK(this, ClassificationDialog, SelectIPPartHdl)); + m_pIntellectualPropertyPartListBox->SetDoubleClickHdl(LINK(this, ClassificationDialog, DoubleClickIPPartHdl)); + for (const OUString& rName : maHelper.GetIntellectualPropertyParts()) + m_pIntellectualPropertyPartListBox->InsertEntry(rName); + m_pIntellectualPropertyPartListBox->EnableAutoSize(true); +} + +ClassificationDialog::~ClassificationDialog() +{ + disposeOnce(); +} + +void ClassificationDialog::dispose() +{ + ModalDialog::dispose(); +} + +short ClassificationDialog::Execute() +{ + return ModalDialog::Execute(); +} + +std::vector<ClassificationResult> ClassificationDialog::getResult() +{ + std::vector<ClassificationResult> aClassificationResults; + + std::unique_ptr<EditTextObject> pEditText(m_pEditWindow->pEdEngine->CreateTextObject()); + + std::vector<editeng::Section> aSections; + pEditText->GetAllSections(aSections); + + for (editeng::Section const & rSection : aSections) + { + const SvxFieldItem* rField = findField(rSection); + if (rField) + { + } + else + { + ESelection aSelection(rSection.mnParagraph, rSection.mnStart, rSection.mnParagraph, rSection.mnEnd); + OUString sString = m_pEditWindow->pEdEngine->GetText(aSelection); + aClassificationResults.push_back({ ClassificationType::TEXT, sString, rSection.mnParagraph }); + } + } + return aClassificationResults; +} + +IMPL_LINK(ClassificationDialog, SelectClassificationHdl, ListBox&, rBox, void) +{ + sal_Int32 nSelected = rBox.GetSelectEntryPos(); + if (nSelected >= 0) + { + std::unique_ptr<EditTextObject> pEditText(m_pEditWindow->pEdEngine->CreateTextObject()); + std::vector<editeng::Section> aSections; + pEditText->GetAllSections(aSections); + + for (editeng::Section const & rSection : aSections) + { + const SvxFieldItem* pFieldItem = findField(rSection); + if (pFieldItem) + { + const ClassificationField* pClassificationField = dynamic_cast<const ClassificationField*>(pFieldItem->GetField()); + if (pClassificationField && pClassificationField->meType == ClassificationType::CLASSIFICATION) + { + m_pEditWindow->pEdView->SetSelection(ESelection(rSection.mnParagraph, rSection.mnStart, rSection.mnParagraph, rSection.mnEnd)); + } + } + } + + OUString aString = maHelper.GetBACNames()[nSelected]; + ClassificationField aField(ClassificationType::CLASSIFICATION, aString); + m_pEditWindow->InsertField(SvxFieldItem(aField, EE_FEATURE_FIELD)); + } +} + +IMPL_LINK(ClassificationDialog, SelectMarkingHdl, ListBox&, rBox, void) +{ + sal_Int32 nSelected = rBox.GetSelectEntryPos(); + if (nSelected >= 0) + { + std::unique_ptr<EditTextObject> pEditText(m_pEditWindow->pEdEngine->CreateTextObject()); + std::vector<editeng::Section> aSections; + pEditText->GetAllSections(aSections); + + for (editeng::Section const & rSection : aSections) + { + const SvxFieldItem* pFieldItem = findField(rSection); + if (pFieldItem) + { + const ClassificationField* pClassificationField = dynamic_cast<const ClassificationField*>(pFieldItem->GetField()); + if (pClassificationField && pClassificationField->meType == ClassificationType::MARKINGS) + { + m_pEditWindow->pEdView->SetSelection(ESelection(rSection.mnParagraph, rSection.mnStart, rSection.mnParagraph, rSection.mnEnd)); + } + } + } + + OUString aString = maHelper.GetBACNames()[nSelected]; + ClassificationField aField(ClassificationType::MARKINGS, aString); + m_pEditWindow->InsertField(SvxFieldItem(aField, EE_FEATURE_FIELD)); + } +} + +IMPL_LINK(ClassificationDialog, SelectIPPartHdl, ListBox&, rBox, void) +{ +} + +IMPL_LINK(ClassificationDialog, DoubleClickIPPartHdl, ListBox&, rBox, void) +{ + printf ("DoubleClickIPPartHdl\n"); +} + +IMPL_LINK(ClassificationDialog, ButtonClicked, Button*, pButton, void) +{ + if (pButton == m_pBoldButton) + { + m_pEditWindow->InvertSelectionWeight(); + } + else if (pButton == m_pIntellectualPropertyPartAddButton) + { + } +} + +} // end sfx2 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/uiconfig/ui/classificationdialog.ui b/svx/uiconfig/ui/classificationdialog.ui new file mode 100644 index 000000000000..097e5260767f --- /dev/null +++ b/svx/uiconfig/ui/classificationdialog.ui @@ -0,0 +1,349 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.0 --> +<interface domain="sfx"> + <requires lib="gtk+" version="3.0"/> + <requires lib="LibreOffice" version="1.0"/> + <object class="GtkImage" id="bold"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="stock">gtk-bold</property> + </object> + <object class="GtkDialog" id="AdvancedDocumentClassificationDialog"> + <property name="can_focus">False</property> + <property name="border_width">6</property> + <property name="title" translatable="yes">Classification Dialog</property> + <property name="type_hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox1"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="ok"> + <property name="label">gtk-ok</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="cancel"> + <property name="label">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="help"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + <property name="secondary">True</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkGrid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="row_spacing">12</property> + <property name="column_spacing">12</property> + <child> + <object class="svxlo-ClassificationEditView" id="classificationEditWindow"> + <property name="width_request">400</property> + <property name="height_request">400</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Content</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkGrid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="row_spacing">12</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Classification:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">International Classification:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="classificationCB"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="internationalClassificationCB"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="markingCB"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Marking:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">6</property> + <property name="homogeneous">True</property> + <child> + <object class="GtkButton" id="boldButton"> + <property name="label" translatable="yes">bold</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="image">bold</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button"> + <property name="label" translatable="yes">button</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + <property name="width">2</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="height">2</property> + </packing> + </child> + <child> + <object class="GtkExpander"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkGrid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">6</property> + <child> + <object class="GtkComboBoxText" id="intellectualPropertyPartNumberCB"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="active">0</property> + <items> + <item id="1">1</item> + <item id="2">2</item> + <item id="3">3</item> + <item id="4">4</item> + <item id="5">5</item> + <item id="6">6</item> + <item id="7">7</item> + <item id="8">8</item> + <item id="9">9</item> + </items> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Part Number:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkEntry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + <property name="width">2</property> + </packing> + </child> + <child> + <object class="GtkTreeView" id="intellectualPropertyPartLB"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="height">2</property> + </packing> + </child> + <child> + <object class="GtkButton" id="intellectualPropertyPartAddButton"> + <property name="label" translatable="yes" context="classificationdialog|add">Add</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Intellectual Property</property> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + <property name="width">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="0">ok</action-widget> + <action-widget response="0">cancel</action-widget> + <action-widget response="0">help</action-widget> + </action-widgets> + </object> +</interface> diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index 5cf87250b37f..dd837ca414ac 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -122,6 +122,7 @@ #include <officecfg/Office/Security.hxx> #include <sfx2/fcontnr.hxx> +#include <svx/ClassificationDialog.hxx> #include "swabstdlg.hxx" #include "watermarkdialog.hxx" @@ -1165,6 +1166,19 @@ void SwDocShell::Execute(SfxRequest& rReq) break; case SID_CLASSIFICATION_DIALOG: { + ScopedVclPtr<svx::ClassificationDialog> pDialog(VclPtr<svx::ClassificationDialog>::Create(nullptr)); + if (RET_OK == pDialog->Execute()) + { + SwDocShell* pDocShell = GetDoc()->GetDocShell(); + if (!pDocShell) + return; + + for (svx::ClassificationResult const & rResult : pDialog->getResult()) + { + + } + } + pDialog.disposeAndClear(); } break; case SID_WATERMARK: |