summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-04-03 12:02:13 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-04-04 10:31:58 +0200
commitb9c10ee923308f336a694bbc0212396ed5317b6a (patch)
tree72bf09a9eb69802a8e09227934bdb0b6c3150023 /svx
parentc8c0292c2152df8c353aeff32896f0cfa8a53a64 (diff)
weld ClassificationDialog
with the extra problem of hosting an EditView/EditEngine within a weld::DrawingArea Change-Id: Id48a57ed0dfd2d92217209c43f752edd9cf8e1bd Reviewed-on: https://gerrit.libreoffice.org/70219 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/dialog/ClassificationDialog.cxx243
-rw-r--r--svx/source/dialog/ClassificationEditView.cxx99
-rw-r--r--svx/source/svdraw/svdedxv.cxx9
-rw-r--r--svx/source/svdraw/svdoutl.cxx2
-rw-r--r--svx/uiconfig/ui/classificationdialog.ui187
5 files changed, 318 insertions, 222 deletions
diff --git a/svx/source/dialog/ClassificationDialog.cxx b/svx/source/dialog/ClassificationDialog.cxx
index 11349012361b..d83a6b044a54 100644
--- a/svx/source/dialog/ClassificationDialog.cxx
+++ b/svx/source/dialog/ClassificationDialog.cxx
@@ -24,36 +24,25 @@
#include <tools/XmlWriter.hxx>
#include <tools/XmlWalker.hxx>
#include <vcl/builderfactory.hxx>
+#include <vcl/event.hxx>
#include <sfx2/objsh.hxx>
#include <officecfg/Office/Common.hxx>
namespace svx {
-
-IntellectualPropertyPartEdit::IntellectualPropertyPartEdit(vcl::Window* pParent)
- : Edit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK|WB_TABSTOP)
-{
-}
-
-VCL_BUILDER_FACTORY(IntellectualPropertyPartEdit)
-
-void IntellectualPropertyPartEdit::KeyInput(const KeyEvent& rKeyEvent)
+IMPL_STATIC_LINK(ClassificationDialog, KeyInput, const KeyEvent&, rKeyEvent, bool)
{
bool bTextIsFreeForm = officecfg::Office::Common::Classification::IntellectualPropertyTextInputIsFreeForm::get();
- if (bTextIsFreeForm)
- {
- Edit::KeyInput(rKeyEvent);
- }
- else
+ if (!bTextIsFreeForm)
{
// Ignore key combination with modifier keys
if (rKeyEvent.GetKeyCode().IsMod3()
|| rKeyEvent.GetKeyCode().IsMod2()
|| rKeyEvent.GetKeyCode().IsMod1())
{
- return;
+ return true;
}
switch (rKeyEvent.GetKeyCode().GetCode())
@@ -64,13 +53,15 @@ void IntellectualPropertyPartEdit::KeyInput(const KeyEvent& rKeyEvent)
case KEY_DIVIDE:
case KEY_SEMICOLON:
case KEY_SPACE:
- Edit::KeyInput(rKeyEvent);
- return;
+ return false;
// Anything else is ignored
default:
+ return true;
break;
}
}
+
+ return false;
}
namespace {
@@ -161,117 +152,98 @@ void writeResultToXml(tools::XmlWriter & rXmlWriter,
} // end anonymous namespace
-ClassificationDialog::ClassificationDialog(vcl::Window* pParent, const bool bPerParagraph, const std::function<void()>& rParagraphSignHandler)
- : ModalDialog(pParent, "AdvancedDocumentClassificationDialog", "svx/ui/classificationdialog.ui")
+ClassificationDialog::ClassificationDialog(weld::Window* pParent, const bool bPerParagraph, const std::function<void()>& rParagraphSignHandler)
+ : GenericDialogController(pParent, "svx/ui/classificationdialog.ui", "AdvancedDocumentClassificationDialog")
, maHelper(SfxObjectShell::Current()->getDocProperties())
, maInternationalHelper(SfxObjectShell::Current()->getDocProperties(), /*bUseLocalizedPolicy*/ false)
, m_bPerParagraph(bPerParagraph)
, m_aParagraphSignHandler(rParagraphSignHandler)
, m_nCurrentSelectedCategory(-1)
+ , m_xOkButton(m_xBuilder->weld_button("ok"))
+ , m_xSignButton(m_xBuilder->weld_button("signButton"))
+ , m_xToolBox(m_xBuilder->weld_toggle_button("toolbox"))
+ , m_xRecentlyUsedListBox(m_xBuilder->weld_combo_box("recentlyUsedCB"))
+ , m_xClassificationListBox(m_xBuilder->weld_combo_box("classificationCB"))
+ , m_xInternationalClassificationListBox(m_xBuilder->weld_combo_box("internationalClassificationCB"))
+ , m_xMarkingLabel(m_xBuilder->weld_label("markingLabel"))
+ , m_xMarkingListBox(m_xBuilder->weld_tree_view("markingLB"))
+ , m_xIntellectualPropertyPartListBox(m_xBuilder->weld_tree_view("intellectualPropertyPartLB"))
+ , m_xIntellectualPropertyPartNumberListBox(m_xBuilder->weld_tree_view("intellectualPropertyPartNumberLB"))
+ , m_xIntellectualPropertyPartAddButton(m_xBuilder->weld_button("intellectualPropertyPartAddButton"))
+ , m_xIntellectualPropertyPartEdit(m_xBuilder->weld_entry("intellectualPropertyPartEntry"))
+ , m_xIntellectualPropertyExpander(m_xBuilder->weld_expander("intellectualPropertyExpander"))
+ , m_xEditWindow(new ClassificationEditView)
+ , m_xEditWindowWeld(new weld::CustomWeld(*m_xBuilder, "classificationEditWindow", *m_xEditWindow))
{
- get(m_pOkButton, "ok");
- get(m_pEditWindow, "classificationEditWindow");
- get(m_pSignButton, "signButton");
- get(m_pToolBox, "toolbox");
- get(m_pRecentlyUsedListBox, "recentlyUsedCB");
- get(m_pClassificationListBox, "classificationCB");
- get(m_pInternationalClassificationListBox, "internationalClassificationCB");
- get(m_pMarkingLabel, "markingLabel");
- get(m_pMarkingListBox, "markingLB");
- get(m_pIntellectualPropertyPartNumberListBox, "intellectualPropertyPartNumberLB");
- get(m_pIntellectualPropertyPartListBox, "intellectualPropertyPartLB");
- get(m_pIntellectualPropertyPartAddButton, "intellectualPropertyPartAddButton");
- get(m_pIntellectualPropertyPartEdit, "intellectualPropertyPartEntry");
- get(m_pIntellectualPropertyExpander, "intellectualPropertyExpander");
-
- m_pSignButton->SetClickHdl(LINK(this, ClassificationDialog, ButtonClicked));
- m_pSignButton->Show(m_bPerParagraph);
+ m_xSignButton->connect_clicked(LINK(this, ClassificationDialog, ButtonClicked));
+ m_xSignButton->set_visible(m_bPerParagraph);
+
+ m_xIntellectualPropertyPartEdit->connect_key_press(LINK(this, ClassificationDialog, KeyInput));
// no need for BOLD if we do paragraph classification
if (m_bPerParagraph)
{
- m_pToolBox->Show(false);
+ m_xToolBox->hide();
}
else
{
- m_pToolBox->SetSelectHdl(LINK(this, ClassificationDialog, SelectToolboxHdl));
+ m_xToolBox->connect_toggled(LINK(this, ClassificationDialog, SelectToolboxHdl));
}
- m_pIntellectualPropertyPartAddButton->SetClickHdl(LINK(this, ClassificationDialog, ButtonClicked));
+ m_xIntellectualPropertyPartAddButton->connect_clicked(LINK(this, ClassificationDialog, ButtonClicked));
- m_pClassificationListBox->setMaxWidthChars(20);
- m_pClassificationListBox->SetSelectHdl(LINK(this, ClassificationDialog, SelectClassificationHdl));
+ m_xClassificationListBox->set_size_request(m_xClassificationListBox->get_approximate_digit_width() * 20, -1);
+ m_xClassificationListBox->connect_changed(LINK(this, ClassificationDialog, SelectClassificationHdl));
for (const OUString& rName : maHelper.GetBACNames())
- m_pClassificationListBox->InsertEntry(rName);
+ m_xClassificationListBox->append_text(rName);
- m_pInternationalClassificationListBox->setMaxWidthChars(20);
- m_pInternationalClassificationListBox->SetSelectHdl(LINK(this, ClassificationDialog, SelectClassificationHdl));
+ m_xInternationalClassificationListBox->set_size_request(m_xInternationalClassificationListBox->get_approximate_digit_width() * 20, -1);
+ m_xInternationalClassificationListBox->connect_changed(LINK(this, ClassificationDialog, SelectClassificationHdl));
for (const OUString& rName : maInternationalHelper.GetBACNames())
- m_pInternationalClassificationListBox->InsertEntry(rName);
+ m_xInternationalClassificationListBox->append_text(rName);
if (!maHelper.GetMarkings().empty())
{
- m_pMarkingListBox->setMaxWidthChars(10);
- m_pMarkingListBox->SetDropDownLineCount(4);
- m_pMarkingListBox->SetDoubleClickHdl(LINK(this, ClassificationDialog, SelectMarkingHdl));
+ m_xMarkingListBox->set_size_request(m_xMarkingListBox->get_approximate_digit_width() * 10,
+ m_xMarkingListBox->get_height_rows(4));
+ m_xMarkingListBox->connect_row_activated(LINK(this, ClassificationDialog, SelectMarkingHdl));
for (const OUString& rName : maHelper.GetMarkings())
- m_pMarkingListBox->InsertEntry(rName);
+ m_xMarkingListBox->append_text(rName);
}
else
{
- m_pMarkingListBox->Show(false);
- m_pMarkingLabel->Show(false);
+ m_xMarkingListBox->hide();
+ m_xMarkingLabel->hide();
}
- m_pIntellectualPropertyPartNumberListBox->SetDropDownLineCount(5);
- m_pIntellectualPropertyPartNumberListBox->setMaxWidthChars(10);
- m_pIntellectualPropertyPartNumberListBox->SetDoubleClickHdl(LINK(this, ClassificationDialog, SelectIPPartNumbersHdl));
+ m_xIntellectualPropertyPartNumberListBox->set_size_request(m_xIntellectualPropertyPartNumberListBox->get_approximate_digit_width() * 10,
+ m_xIntellectualPropertyPartNumberListBox->get_height_rows(5));
+ m_xIntellectualPropertyPartNumberListBox->connect_row_activated(LINK(this, ClassificationDialog, SelectIPPartNumbersHdl));
for (const OUString& rName : maHelper.GetIntellectualPropertyPartNumbers())
- m_pIntellectualPropertyPartNumberListBox->InsertEntry(rName);
+ m_xIntellectualPropertyPartNumberListBox->append_text(rName);
- m_pIntellectualPropertyPartListBox->SetDropDownLineCount(5);
- m_pIntellectualPropertyPartNumberListBox->setMaxWidthChars(20);
- m_pIntellectualPropertyPartListBox->SetDoubleClickHdl(LINK(this, ClassificationDialog, SelectIPPartHdl));
+ m_xIntellectualPropertyPartNumberListBox->set_size_request(m_xIntellectualPropertyPartNumberListBox->get_approximate_digit_width() * 20,
+ m_xIntellectualPropertyPartListBox->get_height_rows(5));
+ m_xIntellectualPropertyPartListBox->connect_row_activated(LINK(this, ClassificationDialog, SelectIPPartHdl));
for (const OUString& rName : maHelper.GetIntellectualPropertyParts())
- m_pIntellectualPropertyPartListBox->InsertEntry(rName);
+ m_xIntellectualPropertyPartListBox->append_text(rName);
- m_pRecentlyUsedListBox->setMaxWidthChars(5);
- m_pRecentlyUsedListBox->SetSelectHdl(LINK(this, ClassificationDialog, SelectRecentlyUsedHdl));
+ m_xRecentlyUsedListBox->set_size_request(m_xRecentlyUsedListBox->get_approximate_digit_width() * 5, -1);
+ m_xRecentlyUsedListBox->connect_changed(LINK(this, ClassificationDialog, SelectRecentlyUsedHdl));
bool bExpand = officecfg::Office::Common::Classification::IntellectualPropertySectionExpanded::get();
- m_pIntellectualPropertyExpander->set_expanded(bExpand);
- m_pIntellectualPropertyExpander->SetExpandedHdl(LINK(this, ClassificationDialog, ExpandedHdl));
+ m_xIntellectualPropertyExpander->set_expanded(bExpand);
+ m_xIntellectualPropertyExpander->connect_expanded(LINK(this, ClassificationDialog, ExpandedHdl));
- m_pEditWindow->SetModifyHdl(LINK(this, ClassificationDialog, EditWindowModifiedHdl));
+ m_xEditWindow->SetModifyHdl(LINK(this, ClassificationDialog, EditWindowModifiedHdl));
}
ClassificationDialog::~ClassificationDialog()
{
- disposeOnce();
-}
-
-void ClassificationDialog::dispose()
-{
- m_pOkButton.clear();
- m_pEditWindow.clear();
- m_pSignButton.clear();
- m_pToolBox.clear();
- m_pRecentlyUsedListBox.clear();
- m_pClassificationListBox.clear();
- m_pInternationalClassificationListBox.clear();
- m_pMarkingLabel.clear();
- m_pMarkingListBox.clear();
- m_pIntellectualPropertyPartListBox.clear();
- m_pIntellectualPropertyPartNumberListBox.clear();
- m_pIntellectualPropertyPartAddButton.clear();
- m_pIntellectualPropertyPartEdit.clear();
- m_pIntellectualPropertyExpander.clear();
-
- ModalDialog::dispose();
}
-short ClassificationDialog::Execute()
+short ClassificationDialog::run()
{
readRecentlyUsed();
readIn(m_aInitialValues);
@@ -279,7 +251,7 @@ short ClassificationDialog::Execute()
int nNumber = 1;
if (m_aRecentlyUsedValuesCollection.empty())
{
- m_pRecentlyUsedListBox->Disable();
+ m_xRecentlyUsedListBox->set_sensitive(false);
}
else
{
@@ -289,11 +261,11 @@ short ClassificationDialog::Execute()
OUString rDescription = OUString::number(nNumber) + ": " + rContentRepresentation;
nNumber++;
- m_pRecentlyUsedListBox->InsertEntry(rDescription);
+ m_xRecentlyUsedListBox->append_text(rDescription);
}
}
- short nResult = ModalDialog::Execute();
+ short nResult = GenericDialogController::run();
if (nResult == RET_OK)
{
writeRecentlyUsed();
@@ -312,7 +284,7 @@ void ClassificationDialog::insertCategoryField(sal_Int32 nID)
void ClassificationDialog::insertField(ClassificationType eType, OUString const & rString, OUString const & rFullString, OUString const & rIdentifier)
{
ClassificationField aField(eType, rString, rFullString, rIdentifier);
- m_pEditWindow->InsertField(SvxFieldItem(aField, EE_FEATURE_FIELD));
+ m_xEditWindow->InsertField(SvxFieldItem(aField, EE_FEATURE_FIELD));
}
void ClassificationDialog::setupValues(std::vector<ClassificationResult> const & rInput)
@@ -441,7 +413,7 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp
{
case svx::ClassificationType::TEXT:
{
- m_pEditWindow->pEdView->InsertText(rClassificationResult.msName);
+ m_xEditWindow->pEdView->InsertText(rClassificationResult.msName);
}
break;
@@ -457,9 +429,9 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp
if (sAbbreviatedName.isEmpty())
sAbbreviatedName = maHelper.GetAbbreviatedBACName(sName);
- m_pClassificationListBox->SelectEntry(sName);
- m_nCurrentSelectedCategory = m_pClassificationListBox->GetSelectedEntryPos();
- m_pInternationalClassificationListBox->SelectEntryPos(m_pClassificationListBox->GetSelectedEntryPos());
+ m_xClassificationListBox->set_active_text(sName);
+ m_nCurrentSelectedCategory = m_xClassificationListBox->get_active();
+ m_xInternationalClassificationListBox->set_active(m_xClassificationListBox->get_active());
insertField(rClassificationResult.meType, sAbbreviatedName, sName, rClassificationResult.msIdentifier);
}
@@ -467,7 +439,7 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp
case svx::ClassificationType::MARKING:
{
- m_pMarkingListBox->SelectEntry(rClassificationResult.msName);
+ m_xMarkingListBox->select_text(rClassificationResult.msName);
insertField(rClassificationResult.meType, rClassificationResult.msName, rClassificationResult.msName, rClassificationResult.msIdentifier);
}
break;
@@ -483,13 +455,13 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp
nParagraph++;
if (nParagraph != 0)
- m_pEditWindow->pEdView->InsertParaBreak();
+ m_xEditWindow->pEdView->InsertParaBreak();
// Set paragraph font weight
FontWeight eWeight = (rClassificationResult.msName == "BOLD") ? WEIGHT_BOLD : WEIGHT_NORMAL;
- std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(m_pEditWindow->pEdEngine->GetParaAttribs(nParagraph)));
+ std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(m_xEditWindow->pEdEngine->GetParaAttribs(nParagraph)));
pSet->Put(SvxWeightItem(eWeight, EE_CHAR_WEIGHT));
- m_pEditWindow->pEdEngine->SetParaAttribs(nParagraph, *pSet);
+ m_xEditWindow->pEdEngine->SetParaAttribs(nParagraph, *pSet);
}
break;
@@ -502,7 +474,7 @@ void ClassificationDialog::readIn(std::vector<ClassificationResult> const & rInp
void ClassificationDialog::toggleWidgetsDependingOnCategory()
{
- const EditEngine& rEditEngine = m_pEditWindow->getEditEngine();
+ const EditEngine& rEditEngine = m_xEditWindow->getEditEngine();
for (sal_Int32 nParagraph = 0; nParagraph < rEditEngine.GetParagraphCount(); ++nParagraph)
{
@@ -515,7 +487,7 @@ void ClassificationDialog::toggleWidgetsDependingOnCategory()
const ClassificationField* pClassificationField = dynamic_cast<const ClassificationField*>(aFieldInfo.pFieldItem->GetField());
if (pClassificationField && pClassificationField->meType == ClassificationType::CATEGORY)
{
- m_pOkButton->Enable();
+ m_xOkButton->set_sensitive(true);
return;
}
}
@@ -523,16 +495,16 @@ void ClassificationDialog::toggleWidgetsDependingOnCategory()
}
// Category field in the text edit has been deleted, so reset the list boxes
- m_pOkButton->Disable();
- m_pClassificationListBox->SetNoSelection();
- m_pInternationalClassificationListBox->SetNoSelection();
+ m_xOkButton->set_sensitive(false);
+ m_xClassificationListBox->set_active(-1);
+ m_xInternationalClassificationListBox->set_active(-1);
}
std::vector<ClassificationResult> ClassificationDialog::getResult()
{
std::vector<ClassificationResult> aClassificationResults;
- std::unique_ptr<EditTextObject> pEditText(m_pEditWindow->pEdEngine->CreateTextObject());
+ std::unique_ptr<EditTextObject> pEditText(m_xEditWindow->pEdEngine->CreateTextObject());
sal_Int32 nCurrentParagraph = -1;
@@ -546,7 +518,7 @@ std::vector<ClassificationResult> ClassificationDialog::getResult()
// Get Weight of current paragraph
FontWeight eFontWeight = WEIGHT_NORMAL;
- SfxItemSet aItemSet(m_pEditWindow->pEdEngine->GetParaAttribs(nCurrentParagraph));
+ SfxItemSet aItemSet(m_xEditWindow->pEdEngine->GetParaAttribs(nCurrentParagraph));
if (const SfxPoolItem* pItem = aItemSet.GetItem(EE_CHAR_WEIGHT, false))
{
const SvxWeightItem* pWeightItem = dynamic_cast<const SvxWeightItem*>(pItem);
@@ -565,7 +537,7 @@ std::vector<ClassificationResult> ClassificationDialog::getResult()
const SvxFieldItem* pFieldItem = findField(rSection);
ESelection aSelection(rSection.mnParagraph, rSection.mnStart, rSection.mnParagraph, rSection.mnEnd);
- const OUString sDisplayString = m_pEditWindow->pEdEngine->GetText(aSelection);
+ const OUString sDisplayString = m_xEditWindow->pEdEngine->GetText(aSelection);
if (!sDisplayString.isEmpty())
{
const ClassificationField* pClassificationField = pFieldItem ? dynamic_cast<const ClassificationField*>(pFieldItem->GetField()) : nullptr;
@@ -585,13 +557,13 @@ std::vector<ClassificationResult> ClassificationDialog::getResult()
return aClassificationResults;
}
-IMPL_LINK(ClassificationDialog, SelectClassificationHdl, ListBox&, rBox, void)
+IMPL_LINK(ClassificationDialog, SelectClassificationHdl, weld::ComboBox&, rBox, void)
{
- const sal_Int32 nSelected = rBox.GetSelectedEntryPos();
+ const sal_Int32 nSelected = rBox.get_active();
if (nSelected < 0 || m_nCurrentSelectedCategory == nSelected)
return;
- std::unique_ptr<EditTextObject> pEditText(m_pEditWindow->pEdEngine->CreateTextObject());
+ std::unique_ptr<EditTextObject> pEditText(m_xEditWindow->pEdEngine->CreateTextObject());
std::vector<editeng::Section> aSections;
pEditText->GetAllSections(aSections);
@@ -616,19 +588,19 @@ IMPL_LINK(ClassificationDialog, SelectClassificationHdl, ListBox&, rBox, void)
}
if (bReplaceExisting)
- m_pEditWindow->pEdView->SetSelection(aExistingFieldSelection);
+ m_xEditWindow->pEdView->SetSelection(aExistingFieldSelection);
insertCategoryField(nSelected);
// Change category to the new selection
- m_pInternationalClassificationListBox->SelectEntryPos(nSelected);
- m_pClassificationListBox->SelectEntryPos(nSelected);
+ m_xInternationalClassificationListBox->set_active(nSelected);
+ m_xClassificationListBox->set_active(nSelected);
m_nCurrentSelectedCategory = nSelected;
}
-IMPL_LINK(ClassificationDialog, SelectMarkingHdl, ListBox&, rBox, void)
+IMPL_LINK(ClassificationDialog, SelectMarkingHdl, weld::TreeView&, rBox, void)
{
- sal_Int32 nSelected = rBox.GetSelectedEntryPos();
+ sal_Int32 nSelected = rBox.get_selected_index();
if (nSelected >= 0)
{
const OUString aString = maHelper.GetMarkings()[nSelected];
@@ -636,69 +608,62 @@ IMPL_LINK(ClassificationDialog, SelectMarkingHdl, ListBox&, rBox, void)
}
}
-IMPL_LINK(ClassificationDialog, SelectIPPartNumbersHdl, ListBox&, rBox, void)
+IMPL_LINK(ClassificationDialog, SelectIPPartNumbersHdl, weld::TreeView&, rBox, void)
{
- sal_Int32 nSelected = rBox.GetSelectedEntryPos();
+ sal_Int32 nSelected = rBox.get_selected_index();
if (nSelected >= 0)
{
OUString sString = maHelper.GetIntellectualPropertyPartNumbers()[nSelected];
- m_pIntellectualPropertyPartEdit->ReplaceSelected(sString);
- m_pIntellectualPropertyPartEdit->GrabFocus();
+ m_xIntellectualPropertyPartEdit->replace_selection(sString);
+ m_xIntellectualPropertyPartEdit->grab_focus();
}
}
-IMPL_LINK(ClassificationDialog, SelectRecentlyUsedHdl, ListBox&, rBox, void)
+IMPL_LINK(ClassificationDialog, SelectRecentlyUsedHdl, weld::ComboBox&, rBox, void)
{
- sal_Int32 nSelected = rBox.GetSelectedEntryPos();
+ sal_Int32 nSelected = rBox.get_active();
if (nSelected >= 0)
{
- m_pEditWindow->pEdEngine->Clear();
+ m_xEditWindow->pEdEngine->Clear();
readIn(m_aRecentlyUsedValuesCollection[nSelected]);
}
}
-IMPL_LINK(ClassificationDialog, SelectIPPartHdl, ListBox&, rBox, void)
+IMPL_LINK(ClassificationDialog, SelectIPPartHdl, weld::TreeView&, rBox, void)
{
- const sal_Int32 nSelected = rBox.GetSelectedEntryPos();
+ const sal_Int32 nSelected = rBox.get_selected_index();
if (nSelected >= 0)
{
const OUString sString = maHelper.GetIntellectualPropertyParts()[nSelected];
- m_pIntellectualPropertyPartEdit->ReplaceSelected(sString);
- m_pIntellectualPropertyPartEdit->GrabFocus();
+ m_xIntellectualPropertyPartEdit->replace_selection(sString);
+ m_xIntellectualPropertyPartEdit->grab_focus();
}
}
-IMPL_LINK(ClassificationDialog, ButtonClicked, Button*, pButton, void)
+IMPL_LINK(ClassificationDialog, ButtonClicked, weld::Button&, rButton, void)
{
- if (pButton == m_pSignButton)
+ if (&rButton == m_xSignButton.get())
{
m_aParagraphSignHandler();
}
- else if (pButton == m_pIntellectualPropertyPartAddButton)
+ else if (&rButton == m_xIntellectualPropertyPartAddButton.get())
{
- const OUString sString = m_pIntellectualPropertyPartEdit->GetText();
+ const OUString sString = m_xIntellectualPropertyPartEdit->get_text();
insertField(ClassificationType::INTELLECTUAL_PROPERTY_PART, sString, sString);
}
}
-
-IMPL_LINK_NOARG(ClassificationDialog, SelectToolboxHdl, ToolBox*, void)
+IMPL_LINK_NOARG(ClassificationDialog, SelectToolboxHdl, weld::ToggleButton&, void)
{
- sal_uInt16 nId = m_pToolBox->GetCurItemId();
- const OUString sCommand = m_pToolBox->GetItemCommand(nId);
- if (sCommand == "bold")
- {
- m_pEditWindow->InvertSelectionWeight();
- }
+ m_xEditWindow->InvertSelectionWeight();
}
-
IMPL_LINK_NOARG(ClassificationDialog, EditWindowModifiedHdl, LinkParamNone*, void)
{
toggleWidgetsDependingOnCategory();
}
-IMPL_STATIC_LINK(ClassificationDialog, ExpandedHdl, VclExpander&, rExpander, void)
+IMPL_STATIC_LINK(ClassificationDialog, ExpandedHdl, weld::Expander&, rExpander, void)
{
std::shared_ptr<comphelper::ConfigurationChanges> aConfigurationChanges(comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Classification::IntellectualPropertySectionExpanded::set(rExpander.get_expanded(), aConfigurationChanges);
diff --git a/svx/source/dialog/ClassificationEditView.cxx b/svx/source/dialog/ClassificationEditView.cxx
index 6ab21075b402..e428f02172b6 100644
--- a/svx/source/dialog/ClassificationEditView.cxx
+++ b/svx/source/dialog/ClassificationEditView.cxx
@@ -19,11 +19,8 @@
#include <svl/itemset.hxx>
#include <editeng/wghtitem.hxx>
#include <editeng/eeitem.hxx>
-
-extern "C" SAL_DLLPUBLIC_EXPORT void makeClassificationEditView(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap &)
-{
- rRet = VclPtr<svx::ClassificationEditView>::Create(pParent, WB_BORDER|WB_TABSTOP);
-}
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <svx/sdr/overlay/overlayselection.hxx>
namespace svx {
@@ -43,52 +40,61 @@ OUString ClassificationEditEngine::CalcFieldValue(const SvxFieldItem& rField, sa
return aString;
}
-ClassificationEditView::ClassificationEditView(vcl::Window* pParent, WinBits nBits)
- : Control(pParent, nBits)
+ClassificationEditView::ClassificationEditView()
+{
+}
+
+void ClassificationEditView::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
+ Size aSize(500, 100);
+ pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
+ SetOutputSizePixel(aSize);
+
+ weld::CustomWidgetController::SetDrawingArea(pDrawingArea);
+
EnableRTL(false);
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
Color aBgColor = rStyleSettings.GetWindowColor();
- float fScaleFactor = GetDPIScaleFactor();
- set_width_request(500 * fScaleFactor);
- set_height_request(100 * fScaleFactor);
+ OutputDevice& rDevice = pDrawingArea->get_ref_device();
- SetMapMode(MapMode(MapUnit::MapTwip));
- SetPointer(PointerStyle::Text);
- SetBackground(aBgColor);
+ rDevice.SetMapMode(MapMode(MapUnit::MapTwip));
+ rDevice.SetBackground(aBgColor);
- Size aOutputSize(GetOutputSize());
- Size aSize(aOutputSize);
+ Size aOutputSize(rDevice.PixelToLogic(aSize));
+ aSize = aOutputSize;
aSize.setHeight( aSize.Height() * 4 );
pEdEngine.reset(new ClassificationEditEngine(EditEngine::CreatePool()));
pEdEngine->SetPaperSize( aSize );
- pEdEngine->SetRefDevice( this );
+ pEdEngine->SetRefDevice( &rDevice );
pEdEngine->SetControlWord(pEdEngine->GetControlWord() | EEControlBits::MARKFIELDS);
- pEdView.reset(new EditView(pEdEngine.get(), this));
+ pEdView.reset(new EditView(pEdEngine.get(), nullptr));
+ pEdView->setEditViewCallbacks(this);
pEdView->SetOutputArea(tools::Rectangle(Point(0,0), aOutputSize));
pEdView->SetBackgroundColor(aBgColor);
pEdEngine->InsertView(pEdView.get());
+
+ pDrawingArea->set_text_cursor();
}
ClassificationEditView::~ClassificationEditView()
{
- disposeOnce();
}
void ClassificationEditView::Resize()
{
- Size aOutputSize(GetOutputSize());
+ OutputDevice& rDevice = GetDrawingArea()->get_ref_device();
+ Size aOutputSize(rDevice.PixelToLogic(GetOutputSizePixel()));
Size aSize(aOutputSize);
aSize.setHeight( aSize.Height() * 4 );
pEdEngine->SetPaperSize(aSize);
pEdView->SetOutputArea(tools::Rectangle(Point(0,0), aOutputSize));
- Control::Resize();
+ weld::CustomWidgetController::Resize();
}
void ClassificationEditView::InsertField(const SvxFieldItem& rFieldItem)
@@ -122,63 +128,80 @@ void ClassificationEditView::InvertSelectionWeight()
void ClassificationEditView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
{
+ rRenderContext.Push(PushFlags::ALL);
+ rRenderContext.SetClipRegion();
+
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
Color aBgColor = rStyleSettings.GetWindowColor();
pEdView->SetBackgroundColor(aBgColor);
- SetBackground(aBgColor);
+ rRenderContext.SetBackground(aBgColor);
- Control::Paint(rRenderContext, rRect);
-
- pEdView->Paint(rRect);
+ tools::Rectangle aLogicRect(rRenderContext.PixelToLogic(rRect));
+ pEdView->Paint(aLogicRect, &rRenderContext);
if (HasFocus())
+ {
pEdView->ShowCursor();
+ vcl::Cursor* pCursor = pEdView->GetCursor();
+ pCursor->DrawToDevice(rRenderContext);
+ }
+
+ std::vector<tools::Rectangle> aLogicRects;
+
+ // get logic selection
+ pEdView->GetSelectionRectangles(aLogicRects);
+
+ rRenderContext.SetLineColor();
+ rRenderContext.SetFillColor(COL_BLACK);
+ rRenderContext.SetRasterOp(RasterOp::Invert);
+
+ for (const auto &rSelectionRect : aLogicRects)
+ rRenderContext.DrawRect(rSelectionRect);
+
+ rRenderContext.Pop();
}
-void ClassificationEditView::MouseMove(const MouseEvent& rMEvt)
+bool ClassificationEditView::MouseMove(const MouseEvent& rMEvt)
{
- pEdView->MouseMove(rMEvt);
+ return pEdView->MouseMove(rMEvt);
}
-void ClassificationEditView::MouseButtonDown(const MouseEvent& rMEvt)
+bool ClassificationEditView::MouseButtonDown(const MouseEvent& rMEvt)
{
if (!HasFocus())
GrabFocus();
- pEdView->MouseButtonDown(rMEvt);
+ return pEdView->MouseButtonDown(rMEvt);
}
-void ClassificationEditView::MouseButtonUp(const MouseEvent& rMEvt)
+bool ClassificationEditView::MouseButtonUp(const MouseEvent& rMEvt)
{
- pEdView->MouseButtonUp(rMEvt);
+ return pEdView->MouseButtonUp(rMEvt);
}
-void ClassificationEditView::KeyInput(const KeyEvent& rKEvt)
+bool ClassificationEditView::KeyInput(const KeyEvent& rKEvt)
{
sal_uInt16 nKey = rKEvt.GetKeyCode().GetModifier() + rKEvt.GetKeyCode().GetCode();
if (nKey == KEY_TAB || nKey == KEY_TAB + KEY_SHIFT)
{
- Control::KeyInput( rKEvt );
+ return false;
}
else if (!pEdView->PostKeyEvent(rKEvt))
{
- Control::KeyInput(rKEvt);
+ return false;
}
-}
-void ClassificationEditView::Command(const CommandEvent& rCEvt)
-{
- pEdView->Command(rCEvt);
+ return true;
}
void ClassificationEditView::GetFocus()
{
pEdView->ShowCursor();
- Control::GetFocus();
+ weld::CustomWidgetController::GetFocus();
}
} // end sfx2
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 094bad2aa1cf..47cd3a0939be 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -623,7 +623,7 @@ namespace
// callback from the active EditView, forward to evtl. existing instances of the
// TextEditOverlayObject(s). This will additionally update the selection which
// is an integral part of the text visualization
-void SdrObjEditView::EditViewInvalidate() const
+void SdrObjEditView::EditViewInvalidate(const tools::Rectangle&) const
{
if (IsTextEdit())
{
@@ -663,6 +663,11 @@ void SdrObjEditView::EditViewSelectionChange() const
}
}
+OutputDevice& SdrObjEditView::EditViewOutputDevice() const
+{
+ return *pTextEditWin;
+}
+
void SdrObjEditView::TextEditDrawing(SdrPaintWindow& rPaintWindow) const
{
if (!comphelper::LibreOfficeKit::isActive())
@@ -670,7 +675,7 @@ void SdrObjEditView::TextEditDrawing(SdrPaintWindow& rPaintWindow) const
// adapt all TextEditOverlayObject(s), so call EditViewInvalidate()
// to update accordingly (will update selection, too). Suppress new
// stuff when LibreOfficeKit is active
- EditViewInvalidate();
+ EditViewInvalidate(tools::Rectangle());
}
else
{
diff --git a/svx/source/svdraw/svdoutl.cxx b/svx/source/svdraw/svdoutl.cxx
index c2befff17c15..0387afaa5ec9 100644
--- a/svx/source/svdraw/svdoutl.cxx
+++ b/svx/source/svdraw/svdoutl.cxx
@@ -97,7 +97,7 @@ bool SdrOutliner::hasEditViewCallbacks() const
{
OutlinerView* pOutlinerView = GetView(a);
- if (pOutlinerView && pOutlinerView->GetEditView().hasEditViewCallbacks())
+ if (pOutlinerView && pOutlinerView->GetEditView().getEditViewCallbacks())
{
return true;
}
diff --git a/svx/uiconfig/ui/classificationdialog.ui b/svx/uiconfig/ui/classificationdialog.ui
index 47c413093d85..fb381e5d227e 100644
--- a/svx/uiconfig/ui/classificationdialog.ui
+++ b/svx/uiconfig/ui/classificationdialog.ui
@@ -1,13 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.2 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="svx">
<requires lib="gtk+" version="3.18"/>
- <requires lib="LibreOffice" version="1.0"/>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">cmd/lc_bold.png</property>
+ </object>
+ <object class="GtkTreeStore" id="liststore1">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkTreeStore" id="liststore2">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkTreeStore" id="liststore3">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="AdvancedDocumentClassificationDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="classificationdialog|dialogname">Classification</property>
+ <property name="modal">True</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</property>
<property name="type_hint">dialog</property>
+ <child>
+ <placeholder/>
+ </child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
@@ -164,14 +198,36 @@
</packing>
</child>
<child>
- <object class="GtkTreeView" id="markingLB">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="show_expanders">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection"/>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="markingLB">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore1</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn3">
+ <property name="resizable">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderer1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
<packing>
@@ -192,6 +248,7 @@
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="row_spacing">3</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
@@ -210,24 +267,14 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkToolbar" id="toolbox">
+ <object class="GtkToggleButton" id="toolbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="show_arrow">False</property>
- <child>
- <object class="GtkToolButton" id="bold">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="action_name">bold</property>
- <property name="label" translatable="yes" context="classificationdialog|boldButton">Bold</property>
- <property name="use_underline">True</property>
- <property name="icon_name">cmd/lc_bold.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes" context="classificationdialog|boldButton">Bold</property>
+ <property name="image">image1</property>
+ <property name="use_underline">True</property>
+ <property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -255,10 +302,25 @@
</packing>
</child>
<child>
- <object class="svxlo-ClassificationEditView" id="classificationEditWindow">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hexpand">True</property>
+ <property name="border_width">0</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkViewport">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkDrawingArea" id="classificationEditWindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK</property>
+ <property name="hexpand">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="left_attach">0</property>
@@ -296,7 +358,7 @@
</packing>
</child>
<child>
- <object class="svxlo-IntellectualPropertyPartEdit" id="intellectualPropertyPartEntry">
+ <object class="GtkEntry" id="intellectualPropertyPartEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
@@ -333,14 +395,36 @@
</packing>
</child>
<child>
- <object class="GtkTreeView" id="intellectualPropertyPartNumberLB">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="show_expanders">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection"/>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="intellectualPropertyPartNumberLB">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore2</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn4">
+ <property name="resizable">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderer5"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
<packing>
@@ -349,14 +433,36 @@
</packing>
</child>
<child>
- <object class="GtkTreeView" id="intellectualPropertyPartLB">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="show_expanders">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection"/>
+ <property name="shadow_type">in</property>
+ <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>
+ <property name="model">liststore3</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn6">
+ <property name="resizable">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderer6"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
<packing>
@@ -397,8 +503,5 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
- <child>
- <placeholder/>
- </child>
</object>
</interface>