summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@collabora.com>2019-08-21 09:59:03 +0300
committerMuhammet Kara <muhammet.kara@collabora.com>2019-08-22 12:24:55 +0200
commitb4e0f730e274d634f6548a16ca1573a5b1f7f7a3 (patch)
treef4f2ee5df6daca416a00306a4d4711ca0ba03055
parentFix compilation error on Linux (diff)
downloadcore-b4e0f730e274d634f6548a16ca1573a5b1f7f7a3.tar.gz
core-b4e0f730e274d634f6548a16ca1573a5b1f7f7a3.zip
AutoRedaction: Adapt Targets Box
[NO-FORWARD-PORT] Change-Id: I574e3a332efe1af50bc590fd6f805cacc7667069 Reviewed-on: https://gerrit.libreoffice.org/77890 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com>
-rw-r--r--sfx2/inc/autoredactdialog.hxx14
-rw-r--r--sfx2/source/doc/autoredactdialog.cxx92
-rw-r--r--sfx2/uiconfig/ui/autoredactdialog.ui325
3 files changed, 184 insertions, 247 deletions
diff --git a/sfx2/inc/autoredactdialog.hxx b/sfx2/inc/autoredactdialog.hxx
index 7c9f35c11cf1..0011166e631a 100644
--- a/sfx2/inc/autoredactdialog.hxx
+++ b/sfx2/inc/autoredactdialog.hxx
@@ -41,7 +41,7 @@ struct RedactionTarget
};
/// Used to display the targets list
-/*class TargetsTable : public SvSimpleTable
+class TargetsTable : public SvSimpleTable
{
SvTreeListEntry* GetRowByTargetName(const OUString& sName);
@@ -51,13 +51,7 @@ public:
void SelectByName(const OUString& sName);
RedactionTarget* GetTargetByName(const OUString& sName);
OUString GetNameProposal();
-
- // Sync data on the targets box with the data on the target
- void setRowData(SvTreeListEntry* pRow, const RedactionTarget* pTarget);
-
- //void connect_changed(const Link<weld::TreeView&, void>& rLink) { m_xControl->connect_changed(rLink); }
- //void connect_row_activated(const Link<weld::TreeView&, void>& rLink) { m_xControl->connect_row_activated(rLink); }
-};*/
+};
namespace sfx2
{
@@ -78,8 +72,8 @@ class SFX2_DLLPUBLIC SfxAutoRedactDialog : public SfxModalDialog
bool m_bIsValidState;
bool m_bTargetsCopied;
- //VclPtr<SvSimpleTableContainer> m_pTargetsContainer;
- //VclPtr<TargetsTable> m_pTargetsBox;
+ VclPtr<SvSimpleTableContainer> m_pTargetsContainer;
+ VclPtr<TargetsTable> m_pTargetsBox;
VclPtr<FixedText> m_pRedactionTargetsLabel;
VclPtr<PushButton> m_pLoadBtn;
VclPtr<PushButton> m_pSaveBtn;
diff --git a/sfx2/source/doc/autoredactdialog.cxx b/sfx2/source/doc/autoredactdialog.cxx
index fdf7ee673c1d..bd8c4dfcd646 100644
--- a/sfx2/source/doc/autoredactdialog.cxx
+++ b/sfx2/source/doc/autoredactdialog.cxx
@@ -31,36 +31,41 @@
#include <tools/urlobj.hxx>
#include <unotools/viewoptions.hxx>
+#include <svtools/treelistentry.hxx>
+
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <boost/property_tree/json_parser.hpp>
-/*int TargetsTable::GetRowByTargetName(const OUString& sName)
+SvTreeListEntry* TargetsTable::GetRowByTargetName(const OUString& sName)
{
- for (int i = 0, nCount = m_xControl->n_children(); i < nCount; ++i)
+ SvTreeListEntry* pEntry = First();
+ while (pEntry)
{
- RedactionTarget* pTarget
- = reinterpret_cast<RedactionTarget*>(m_xControl->get_id(i).toInt64());
+ RedactionTarget* pTarget = static_cast<RedactionTarget*>(pEntry->GetUserData());
if (pTarget->sName == sName)
{
- return i;
+ return pEntry;
}
+ pEntry = Next(pEntry);
}
- return -1;
+ return nullptr;
}
-TargetsTable::TargetsTable(std::unique_ptr<weld::TreeView> xControl)
- : m_xControl(std::move(xControl))
-{
- m_xControl->set_size_request(555, 250);
- std::vector<int> aWidths;
- aWidths.push_back(100);
- aWidths.push_back(50);
- aWidths.push_back(200);
- aWidths.push_back(105);
- aWidths.push_back(105);
- m_xControl->set_column_fixed_widths(aWidths);
- m_xControl->set_selection_mode(SelectionMode::Multiple);
+TargetsTable::TargetsTable(SvSimpleTableContainer& rParent)
+ : SvSimpleTable(rParent, 0)
+{
+ static long nTabs[] = { 5, 0, 100, 150, 350, 455 };
+
+ SetTabs(nTabs, MapUnit::MapPixel);
+ SetSelectionMode(SelectionMode::Multiple);
+ InsertHeaderEntry("Target Name");
+ InsertHeaderEntry("Type");
+ InsertHeaderEntry("Content");
+ InsertHeaderEntry("Case Sensitive");
+ InsertHeaderEntry("Whole Words");
+
+ rParent.SetTable(this);
}
namespace
@@ -89,7 +94,7 @@ OUString getTypeName(RedactionTargetType nType)
}
/// Returns TypeID to be used in the add/edit target dialog
-OUString getTypeID(RedactionTargetType nType)
+/*OUString getTypeID(RedactionTargetType nType)
{
OUString sTypeID("unknown");
@@ -110,7 +115,7 @@ OUString getTypeID(RedactionTargetType nType)
}
return sTypeID;
-}
+}*/
}
void TargetsTable::InsertTarget(RedactionTarget* pTarget)
@@ -122,8 +127,9 @@ void TargetsTable::InsertTarget(RedactionTarget* pTarget)
}
// Check if the name is empty or invalid (clashing with another entry's name)
- if (pTarget->sName.isEmpty() || GetRowByTargetName(pTarget->sName) != -1)
+ if (pTarget->sName.isEmpty() || GetRowByTargetName(pTarget->sName) != nullptr)
{
+ SAL_WARN("sfx.doc", "Repetitive or empty target name in TargetsTable::InsertTarget()");
pTarget->sName = GetNameProposal();
}
@@ -135,30 +141,29 @@ void TargetsTable::InsertTarget(RedactionTarget* pTarget)
sContent = sContent.getToken(1, ';');
}
- // Add to the end
- int nRow = m_xControl->n_children();
- m_xControl->append(OUString::number(reinterpret_cast<sal_Int64>(pTarget)), pTarget->sName);
- m_xControl->set_text(nRow, getTypeName(pTarget->sType), 1);
- m_xControl->set_text(nRow, sContent, 2);
- m_xControl->set_text(nRow, pTarget->bCaseSensitive ? OUString("Yes") : OUString("No"), 3);
- m_xControl->set_text(nRow, pTarget->bWholeWords ? OUString("Yes") : OUString("No"), 4);
+ OUString sColumnData = pTarget->sName + "\t" + getTypeName(pTarget->sType) + "\t" + sContent
+ + "\t" + (pTarget->bCaseSensitive ? OUString("Yes") : OUString("No"))
+ + "\t" + (pTarget->bWholeWords ? OUString("Yes") : OUString("No"));
+
+ InsertEntryToColumn(sColumnData, TREELIST_APPEND, 0xffff, pTarget);
}
void TargetsTable::SelectByName(const OUString& sName)
{
- int nEntry = GetRowByTargetName(sName);
- if (nEntry == -1)
+ SvTreeListEntry* pEntry = GetRowByTargetName(sName);
+ if (!pEntry)
return;
- select(nEntry);
+
+ Select(pEntry);
}
RedactionTarget* TargetsTable::GetTargetByName(const OUString& sName)
{
- int nEntry = GetRowByTargetName(sName);
- if (nEntry == -1)
+ SvTreeListEntry* pEntry = GetRowByTargetName(sName);
+ if (!pEntry)
return nullptr;
- return reinterpret_cast<RedactionTarget*>(m_xControl->get_id(nEntry).toInt64());
+ return static_cast<RedactionTarget*>(pEntry->GetUserData());
}
OUString TargetsTable::GetNameProposal()
@@ -166,22 +171,25 @@ OUString TargetsTable::GetNameProposal()
//TODO: Define a translatable string
OUString sDefaultTargetName("Target");
sal_Int32 nHighestTargetId = 0;
- for (int i = 0, nCount = m_xControl->n_children(); i < nCount; ++i)
+ SvTreeListEntry* pEntry = First();
+
+ while (pEntry)
{
- RedactionTarget* pTarget
- = reinterpret_cast<RedactionTarget*>(m_xControl->get_id(i).toInt64());
- const OUString& sName = pTarget->sName;
+ RedactionTarget* pTarget = static_cast<RedactionTarget*>(pEntry->GetUserData());
+ OUString sName = pTarget->sName;
sal_Int32 nIndex = 0;
if (sName.getToken(0, ' ', nIndex) == sDefaultTargetName)
{
sal_Int32 nCurrTargetId = sName.getToken(0, ' ', nIndex).toInt32();
nHighestTargetId = std::max<sal_Int32>(nHighestTargetId, nCurrTargetId);
}
+ pEntry = Next(pEntry);
}
+
return sDefaultTargetName + " " + OUString::number(nHighestTargetId + 1);
}
-void TargetsTable::setRowData(const int& nRowIndex, const RedactionTarget* pTarget)
+/*void TargetsTable::setRowData(const int& nRowIndex, const RedactionTarget* pTarget)
{
OUString sContent = pTarget->sContent;
@@ -546,12 +554,16 @@ SfxAutoRedactDialog::SfxAutoRedactDialog(vcl::Window* pParent)
, m_bIsValidState(true)
, m_bTargetsCopied(false)
{
+ get(m_pTargetsContainer, "targets");
get(m_pRedactionTargetsLabel, "labelRedactionTargets");
get(m_pLoadBtn, "btnLoadTargets");
get(m_pSaveBtn, "btnSaveTargets");
get(m_pAddBtn, "add");
get(m_pEditBtn, "edit");
get(m_pDeleteBtn, "delete");
+
+ m_pTargetsBox = VclPtr<TargetsTable>::Create(*m_pTargetsContainer);
+
// Can be used to remmeber the last set of redaction targets?
/*OUString sExtraData;
SvtViewOptions aDlgOpt(EViewType::Dialog,
@@ -650,6 +662,8 @@ SfxAutoRedactDialog::~SfxAutoRedactDialog()
void SfxAutoRedactDialog::dispose()
{
+ m_pTargetsBox.disposeAndClear();
+ m_pTargetsContainer.clear();
m_pRedactionTargetsLabel.clear();
m_pLoadBtn.clear();
m_pSaveBtn.clear();
diff --git a/sfx2/uiconfig/ui/autoredactdialog.ui b/sfx2/uiconfig/ui/autoredactdialog.ui
index ce64d392fb9d..424ede336743 100644
--- a/sfx2/uiconfig/ui/autoredactdialog.ui
+++ b/sfx2/uiconfig/ui/autoredactdialog.ui
@@ -1,28 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
-<interface domain="sfx">
- <requires lib="gtk+" version="3.18"/>
- <object class="GtkTreeStore" id="liststore1">
- <columns>
- <!-- column-name sTargetName -->
- <column type="gchararray"/>
- <!-- column-name sType -->
- <column type="gchararray"/>
- <!-- column-name sContent -->
- <column type="gchararray"/>
- <!-- column-name bIsCaseSensitive -->
- <column type="gchararray"/>
- <!-- column-name bWholeWords -->
- <column type="gchararray"/>
- <!-- column-name id -->
- <column type="gchararray"/>
- </columns>
- </object>
+<interface domain="sw">
+ <requires lib="gtk+" version="3.0"/>
+ <requires lib="LibreOffice" version="1.0"/>
<object class="GtkDialog" id="AutoRedactDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="autoredactdialog|AutoRedactDialog">Automatic Redaction</property>
- <property name="modal">True</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
@@ -30,189 +14,76 @@
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
+ <property name="valign">start</property>
<property name="orientation">vertical</property>
- <property name="spacing">12</property>
+ <property name="spacing">6</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
<child>
- <object class="GtkButton" id="help">
- <property name="label">gtk-help</property>
+ <object class="GtkLabel" id="labelRedactionTargets">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
+ <property name="margin_bottom">1</property>
+ <property name="label" translatable="yes" context="autoredactdialog|labelRedactionTargets">_Redaction Targets</property>
+ <property name="use_underline">True</property>
+ <accessibility>
+ <relation type="label-for" target="targets"/>
+ </accessibility>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
- <property name="secondary">True</property>
- </packing>
- </child>
- <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">1</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">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">5</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkGrid">
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkScrolledWindow">
+ <object class="svtlo-SvSimpleTableContainer" id="targets">
+ <property name="width_request">555</property>
+ <property name="height_request">300</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTreeView" id="targets">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="margin_right">5</property>
- <property name="margin_bottom">5</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="model">liststore1</property>
- <property name="search_column">0</property>
- <property name="show_expanders">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="Macro Library List-selection2"/>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn0">
- <property name="resizable">True</property>
- <property name="spacing">6</property>
- <property name="title" translatable="yes" context="autoredactdialog|target">Target Name</property>
- <child>
- <object class="GtkCellRendererText" id="cellrenderer0"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn1">
- <property name="resizable">True</property>
- <property name="spacing">6</property>
- <property name="title" translatable="yes" context="autoredactdialog|description">Type</property>
- <child>
- <object class="GtkCellRendererText" id="cellrenderer1"/>
- <attributes>
- <attribute name="text">1</attribute>
- </attributes>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn2">
- <property name="resizable">True</property>
- <property name="spacing">6</property>
- <property name="title" translatable="yes" context="autoredactdialog|target">Content</property>
- <child>
- <object class="GtkCellRendererText" id="cellrenderer2"/>
- <attributes>
- <attribute name="text">2</attribute>
- </attributes>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn3">
- <property name="resizable">True</property>
- <property name="spacing">6</property>
- <property name="title" translatable="yes" context="autoredactdialog|target">Case Sensitive</property>
- <child>
- <object class="GtkCellRendererText" id="cellrenderer3"/>
- <attributes>
- <attribute name="text">3</attribute>
- </attributes>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn4">
- <property name="resizable">True</property>
- <property name="spacing">6</property>
- <property name="title" translatable="yes" context="autoredactdialog|target">Whole Words</property>
- <child>
- <object class="GtkCellRendererText" id="cellrenderer4"/>
- <attributes>
- <attribute name="text">4</attribute>
- </attributes>
- </child>
- </object>
- </child>
- <accessibility>
- <relation type="labelled-by" target="labelRedactionTargets"/>
- </accessibility>
- </object>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
</child>
</object>
<packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="labelRedactionTargets">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="valign">center</property>
- <property name="margin_right">1</property>
- <property name="margin_bottom">1</property>
- <property name="label" translatable="yes" context="menuassignpage|contentslabel">_Redaction Targets</property>
- <property name="use_underline">True</property>
- <accessibility>
- <relation type="label-for" target="targets"/>
- </accessibility>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkButtonBox">
+ <object class="GtkButtonBox" id="box5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<property name="layout_style">start</property>
<child>
<object class="GtkButton" id="btnLoadTargets">
@@ -246,25 +117,24 @@
</child>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">6</property>
+ <property name="position">1</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">3</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkBox" id="box2">
+ <object class="GtkButtonBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">6</property>
+ <property name="layout_style">start</property>
<child>
<object class="GtkButton" id="add">
<property name="label" translatable="yes" context="autoredactdialog|add">Add</property>
@@ -307,33 +177,92 @@
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkButtonBox" id="box4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkButton" id="help">
+ <property name="label">gtk-help</property>
+ <property name="width_request">75</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">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButtonBox" id="box3">
+ <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="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">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel">
+ <property name="label" context="insertbookmark|goto">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">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
- <action-widgets>
- <action-widget response="-11">help</action-widget>
- <action-widget response="-5">ok</action-widget>
- <action-widget response="-6">cancel</action-widget>
- </action-widgets>
- </object>
- <object class="GtkSizeGroup" id="TargetButtons">
- <property name="mode">both</property>
- <widgets>
- <widget name="btnLoadTargets"/>
- <widget name="btnSaveTargets"/>
- </widgets>
- </object>
- <object class="GtkSizeGroup" id="otherbuttons">
- <widgets>
- <widget name="add"/>
- <widget name="edit"/>
- <widget name="delete"/>
- <widget name="ok"/>
- <widget name="cancel"/>
- <widget name="help"/>
- </widgets>
</object>
</interface>