[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sfx2/inc sfx2/source
Muhammet Kara (via logerrit)
logerrit at kemper.freedesktop.org
Fri Aug 23 19:34:15 UTC 2019
sfx2/inc/autoredactdialog.hxx | 14 +++---
sfx2/source/doc/autoredactdialog.cxx | 78 ++++++++++++++++++++++-------------
sfx2/source/doc/objserv.cxx | 2
3 files changed, 58 insertions(+), 36 deletions(-)
New commits:
commit 9b63b1a51e7cd11a7450f2dc4f70aa561a46b4da
Author: Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Wed Aug 21 22:22:15 2019 +0300
Commit: Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Fri Aug 23 21:33:20 2019 +0200
AutoRedaction: Adapt Load
And enable getTargets()
[NO-FORWARD-PORT]
Change-Id: I6f6fb690183e54bef8f4cb5b21c625ff757fd16e
Reviewed-on: https://gerrit.libreoffice.org/77935
Reviewed-by: Muhammet Kara <muhammet.kara at collabora.com>
Tested-by: Muhammet Kara <muhammet.kara at collabora.com>
diff --git a/sfx2/inc/autoredactdialog.hxx b/sfx2/inc/autoredactdialog.hxx
index 0011166e631a..b128e9d67634 100644
--- a/sfx2/inc/autoredactdialog.hxx
+++ b/sfx2/inc/autoredactdialog.hxx
@@ -67,7 +67,7 @@ enum class StartFileDialogType
class SFX2_DLLPUBLIC SfxAutoRedactDialog : public SfxModalDialog
{
SfxObjectShellLock m_xDocShell;
- std::vector<std::pair<RedactionTarget*, OUString>> m_aTableTargets;
+ //std::vector<std::pair<RedactionTarget*, OUString>> m_aTableTargets;
std::unique_ptr<sfx2::FileDialogHelper> m_pFileDlg;
bool m_bIsValidState;
bool m_bTargetsCopied;
@@ -81,20 +81,20 @@ class SFX2_DLLPUBLIC SfxAutoRedactDialog : public SfxModalDialog
VclPtr<PushButton> m_pEditBtn;
VclPtr<PushButton> m_pDeleteBtn;
- /*DECL_LINK(Load, Button*, void);
- DECL_LINK(Save, Button*, void);
+ DECL_LINK(Load, Button*, void);
+ /*DECL_LINK(Save, Button*, void);
DECL_LINK(AddHdl, Button*, void);
DECL_LINK(EditHdl, Button*, void);
- DECL_LINK(DeleteHdl, Button*, void);
+ DECL_LINK(DeleteHdl, Button*, void);*/
DECL_LINK(LoadHdl, sfx2::FileDialogHelper*, void);
DECL_LINK(SaveHdl, sfx2::FileDialogHelper*, void);
void StartFileDialog(StartFileDialogType nType, const OUString& rTitle);
/// Carry out proper addition both to the targets box, and to the tabletargets vector.
- void addTarget(RedactionTarget* pTarget);
+ /*void addTarget(RedactionTarget* pTarget);*/
/// Clear all targets both visually and from the targets vector
- void clearTargets();*/
+ void clearTargets();
public:
SfxAutoRedactDialog(vcl::Window* pParent);
@@ -110,7 +110,7 @@ public:
* Does a shallow copy.
* Returns true if successful.
*/
- //bool getTargets(std::vector<std::pair<RedactionTarget*, OUString>>& r_aTargets);
+ bool getTargets(std::vector<std::pair<RedactionTarget*, OUString>>& r_aTargets);
};
/*class SfxAddTargetDialog : public weld::GenericDialogController
diff --git a/sfx2/source/doc/autoredactdialog.cxx b/sfx2/source/doc/autoredactdialog.cxx
index bd8c4dfcd646..b62cb249b426 100644
--- a/sfx2/source/doc/autoredactdialog.cxx
+++ b/sfx2/source/doc/autoredactdialog.cxx
@@ -204,7 +204,7 @@ OUString TargetsTable::GetNameProposal()
m_xControl->set_text(nRowIndex, sContent, 2);
m_xControl->set_text(nRowIndex, pTarget->bCaseSensitive ? OUString("Yes") : OUString("No"), 3);
m_xControl->set_text(nRowIndex, pTarget->bWholeWords ? OUString("Yes") : OUString("No"), 4);
-}
+}*/
IMPL_LINK_NOARG(SfxAutoRedactDialog, Load, Button*, void)
{
@@ -213,7 +213,7 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, Load, Button*, void)
StartFileDialog(StartFileDialogType::Open, "Load Targets");
}
-IMPL_LINK_NOARG(SfxAutoRedactDialog, Save, Button*, void)
+/*IMPL_LINK_NOARG(SfxAutoRedactDialog, Save, Button*, void)
{
//Allow saving the targets into a file
StartFileDialog(StartFileDialogType::SaveAs, "Save Targets");
@@ -370,11 +370,11 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, DeleteHdl, Button*, void)
m_aTableTargets.erase(m_aTableTargets.begin() + (i - delta));
m_xTargetsBox->remove(i - delta++);
}
-}
+}*/
namespace
{
-boost::property_tree::ptree redactionTargetToJSON(RedactionTarget* pTarget)
+/*boost::property_tree::ptree redactionTargetToJSON(RedactionTarget* pTarget)
{
boost::property_tree::ptree aNode;
aNode.put("sName", pTarget->sName.toUtf8().getStr());
@@ -385,7 +385,7 @@ boost::property_tree::ptree redactionTargetToJSON(RedactionTarget* pTarget)
aNode.put("nID", pTarget->nID);
return aNode;
-}
+}*/
RedactionTarget* JSONtoRedactionTarget(const boost::property_tree::ptree::value_type& rValue)
{
@@ -421,7 +421,7 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, LoadHdl, sfx2::FileDialogHelper*, void)
osl::File::getSystemPathFromFileURL(sTargetsFile, sSysPath);
sTargetsFile = sSysPath;
- weld::WaitObject aWaitObject(getDialog());
+ EnterWait();
try
{
@@ -440,7 +440,7 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, LoadHdl, sfx2::FileDialogHelper*, void)
aTargetsJSON.get_child("RedactionTargets"))
{
RedactionTarget* pTarget = JSONtoRedactionTarget(rValue);
- addTarget(pTarget);
+ m_pTargetsBox->InsertTarget(pTarget);
}
}
catch (css::uno::Exception& e)
@@ -450,11 +450,13 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, LoadHdl, sfx2::FileDialogHelper*, void)
return;
//TODO: Warn the user with a message box
}
+
+ LeaveWait();
}
IMPL_LINK_NOARG(SfxAutoRedactDialog, SaveHdl, sfx2::FileDialogHelper*, void)
{
- assert(m_pFileDlg);
+ /*assert(m_pFileDlg);
OUString sTargetsFile;
if (ERRCODE_NONE == m_pFileDlg->GetError())
@@ -493,7 +495,7 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, SaveHdl, sfx2::FileDialogHelper*, void)
"Exception caught while trying to save the targets JSON to file: " << e.Message);
return;
//TODO: Warn the user with a message box
- }
+ }*/
}
void SfxAutoRedactDialog::StartFileDialog(StartFileDialogType nType, const OUString& rTitle)
@@ -504,7 +506,7 @@ void SfxAutoRedactDialog::StartFileDialog(StartFileDialogType nType, const OUStr
bool bSave = nType == StartFileDialogType::SaveAs;
short nDialogType = bSave ? css::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION
: css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE;
- m_pFileDlg.reset(new sfx2::FileDialogHelper(nDialogType, FileDialogFlags::NONE, getDialog()));
+ m_pFileDlg.reset(new sfx2::FileDialogHelper(nDialogType, FileDialogFlags::NONE, this));
m_pFileDlg->SetTitle(rTitle);
m_pFileDlg->AddFilter(aFilterAllStr, FILEDIALOG_FILTER_ALL);
@@ -517,7 +519,7 @@ void SfxAutoRedactDialog::StartFileDialog(StartFileDialogType nType, const OUStr
m_pFileDlg->StartExecuteModal(aDlgClosedLink);
}
-void SfxAutoRedactDialog::addTarget(RedactionTarget* pTarget)
+/*void SfxAutoRedactDialog::addTarget(RedactionTarget* pTarget)
{
// Only the visual/display part
m_xTargetsBox->InsertTarget(pTarget);
@@ -533,21 +535,23 @@ void SfxAutoRedactDialog::addTarget(RedactionTarget* pTarget)
xBox->run();
delete pTarget;
}
-}
+}*/
void SfxAutoRedactDialog::clearTargets()
{
- // Clear the targets box
- m_xTargetsBox->clear();
-
- // Clear the targets vector
- auto delTarget
- = [](const std::pair<RedactionTarget*, OUString>& targetPair) { delete targetPair.first; };
-
- std::for_each(m_aTableTargets.begin(), m_aTableTargets.end(), delTarget);
+ SvTreeListEntry* pEntry = m_pTargetsBox->First();
+ while (pEntry)
+ {
+ RedactionTarget* pTarget = static_cast<RedactionTarget*>(pEntry->GetUserData());
+ if (pTarget)
+ {
+ delete pTarget;
+ }
+ pEntry = m_pTargetsBox->Next(pEntry);
+ }
- m_aTableTargets.clear();
-}*/
+ m_pTargetsBox->Clear();
+}
SfxAutoRedactDialog::SfxAutoRedactDialog(vcl::Window* pParent)
: SfxModalDialog(pParent, "AutoRedactDialog", "sfx/ui/autoredactdialog.ui")
@@ -564,6 +568,8 @@ SfxAutoRedactDialog::SfxAutoRedactDialog(vcl::Window* pParent)
m_pTargetsBox = VclPtr<TargetsTable>::Create(*m_pTargetsContainer);
+ m_pLoadBtn->SetClickHdl(LINK(this, SfxAutoRedactDialog, Load));
+
// Can be used to remmeber the last set of redaction targets?
/*OUString sExtraData;
SvtViewOptions aDlgOpt(EViewType::Dialog,
@@ -615,6 +621,8 @@ SfxAutoRedactDialog::SfxAutoRedactDialog(vcl::Window* pParent)
SfxAutoRedactDialog::~SfxAutoRedactDialog()
{
+ if (!m_bTargetsCopied)
+ clearTargets();
/*if (m_aTableTargets.empty())
{
// Clear the dialog data
@@ -680,19 +688,33 @@ void SfxAutoRedactDialog::dispose()
return false;
return true;
-}
+}*/
bool SfxAutoRedactDialog::getTargets(std::vector<std::pair<RedactionTarget*, OUString>>& r_aTargets)
{
- if (m_aTableTargets.empty())
- return true;
+ SvTreeListEntry* pEntry = m_pTargetsBox->First();
+
+ if (!pEntry)
+ {
+ return false;
+ }
+
+ while (pEntry)
+ {
+ RedactionTarget* pTarget = static_cast<RedactionTarget*>(pEntry->GetUserData());
+ if (pTarget && !pTarget->sName.isEmpty())
+ {
+ r_aTargets.emplace_back(pTarget, pTarget->sName);
+ if (!m_bTargetsCopied)
+ m_bTargetsCopied = true;
+ }
+ pEntry = m_pTargetsBox->Next(pEntry);
+ }
- r_aTargets = m_aTableTargets;
- m_bTargetsCopied = true;
return true;
}
-IMPL_LINK_NOARG(SfxAddTargetDialog, SelectTypeHdl, weld::ComboBox&, void)
+/*IMPL_LINK_NOARG(SfxAddTargetDialog, SelectTypeHdl, weld::ComboBox&, void)
{
if (m_xType->get_active_id() == "predefined")
{
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 77cd8458bfc1..517d32e1b232 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -556,7 +556,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
// else continue with normal redaction
bIsAutoRedact = true;
- //aDlg.getTargets(aRedactionTargets);
+ aDlg.getTargets(aRedactionTargets);
SAL_FALLTHROUGH;
}
More information about the Libreoffice-commits
mailing list