[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sfx2/inc sfx2/source

Muhammet Kara (via logerrit) logerrit at kemper.freedesktop.org
Sat Aug 17 16:09:15 UTC 2019


 sfx2/inc/SfxRedactionHelper.hxx        |   12 ----
 sfx2/inc/autoredactdialog.hxx          |   86 +++++++++++----------------------
 sfx2/source/doc/SfxRedactionHelper.cxx |   15 +++++
 sfx2/source/doc/autoredactdialog.cxx   |   60 +++++++++++++----------
 sfx2/source/doc/objserv.cxx            |   16 ++++--
 5 files changed, 90 insertions(+), 99 deletions(-)

New commits:
commit c02978727b3827547dde9b4d7d5c1d08341f4034
Author:     Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Thu Aug 8 19:15:13 2019 +0300
Commit:     Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Sat Aug 17 18:08:28 2019 +0200

    Make AutoRedactDialog buildable again
    
    Change-Id: I3161df87dc35fb6677d9886f45b50ae98d6994a0
    Reviewed-on: https://gerrit.libreoffice.org/77171
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Muhammet Kara <muhammet.kara at collabora.com>

diff --git a/sfx2/inc/SfxRedactionHelper.hxx b/sfx2/inc/SfxRedactionHelper.hxx
index ae72c39f4886..61578438ae35 100644
--- a/sfx2/inc/SfxRedactionHelper.hxx
+++ b/sfx2/inc/SfxRedactionHelper.hxx
@@ -122,18 +122,6 @@ public:
                                   const RedactionTarget* pTarget);
 
 private:
-    static constexpr OUStringLiteral m_aPredefinedTargets[6] = {
-        "\\b(?:\\d[ -]*?){13,16}\\b", //Credit card numbers
-        "\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\\b", //Email addresses
-        "\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
-        "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
-        "\\b", //IP addresses
-        "([12]\\d{3}[./-](0[1-9]|1[0-2])[./"
-        "-](0[1-9]|[12]\\d|3[01]))|((0[1-9]|[12]\\d|3[01])[./-](0[1-9]|1[0-2])[./"
-        "-][12]\\d{3})", //Dates (numerical)
-        "\\s*[a-zA-Z]{2}(?:\\s*\\d\\s*){6}[a-zA-Z]?\\s*", //National Insurance Number (UK)
-        "([1-9])(?!\\1{2}-\\1{2}-\\1{4})[1-9]{2}-[1-9]{2}-[1-9]{4}" //Social Security Number (US)
-    };
 };
 
 #endif // INCLUDED_CUI_SOURCE_INC_SFXREDACTIONHELPER_HXX
diff --git a/sfx2/inc/autoredactdialog.hxx b/sfx2/inc/autoredactdialog.hxx
index 92010071b185..7c9f35c11cf1 100644
--- a/sfx2/inc/autoredactdialog.hxx
+++ b/sfx2/inc/autoredactdialog.hxx
@@ -19,26 +19,7 @@
 #include <vcl/idle.hxx>
 #include <o3tl/typed_flags_set.hxx>
 
-namespace weld
-{
-class Button;
-}
-namespace weld
-{
-class ComboBox;
-}
-namespace weld
-{
-class Label;
-}
-namespace weld
-{
-class Window;
-}
-namespace weld
-{
-class TreeView;
-}
+#include <svtools/simptabl.hxx>
 
 enum RedactionTargetType
 {
@@ -60,34 +41,23 @@ struct RedactionTarget
 };
 
 /// Used to display the targets list
-class TargetsTable
+/*class TargetsTable : public SvSimpleTable
 {
-    std::unique_ptr<weld::TreeView> m_xControl;
-    int GetRowByTargetName(const OUString& sName);
+    SvTreeListEntry* GetRowByTargetName(const OUString& sName);
 
 public:
-    TargetsTable(std::unique_ptr<weld::TreeView> xControl);
+    TargetsTable(SvSimpleTableContainer& rParent);
     void InsertTarget(RedactionTarget* pTarget);
     void SelectByName(const OUString& sName);
     RedactionTarget* GetTargetByName(const OUString& sName);
     OUString GetNameProposal();
 
-    void unselect_all() { m_xControl->unselect_all(); }
-    bool has_focus() const { return m_xControl->has_focus(); }
-    int n_children() const { return m_xControl->n_children(); }
-    int get_selected_index() const { return m_xControl->get_selected_index(); }
-    std::vector<int> get_selected_rows() const { return m_xControl->get_selected_rows(); }
-    void clear() { m_xControl->clear(); }
-    void remove(int nRow) { m_xControl->remove(nRow); }
-    void select(int nRow) { m_xControl->select(nRow); }
-    OUString get_id(int nRow) const { return m_xControl->get_id(nRow); }
-
     // Sync data on the targets box with the data on the target
-    void setRowData(const int& nRowIndex, const RedactionTarget* pTarget);
+    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
 {
@@ -100,7 +70,7 @@ enum class StartFileDialogType
     SaveAs
 };
 
-class SFX2_DLLPUBLIC SfxAutoRedactDialog : public SfxDialogController
+class SFX2_DLLPUBLIC SfxAutoRedactDialog : public SfxModalDialog
 {
     SfxObjectShellLock m_xDocShell;
     std::vector<std::pair<RedactionTarget*, OUString>> m_aTableTargets;
@@ -108,19 +78,20 @@ class SFX2_DLLPUBLIC SfxAutoRedactDialog : public SfxDialogController
     bool m_bIsValidState;
     bool m_bTargetsCopied;
 
-    std::unique_ptr<weld::Label> m_xRedactionTargetsLabel;
-    std::unique_ptr<TargetsTable> m_xTargetsBox;
-    std::unique_ptr<weld::Button> m_xLoadBtn;
-    std::unique_ptr<weld::Button> m_xSaveBtn;
-    std::unique_ptr<weld::Button> m_xAddBtn;
-    std::unique_ptr<weld::Button> m_xEditBtn;
-    std::unique_ptr<weld::Button> m_xDeleteBtn;
-
-    DECL_LINK(Load, weld::Button&, void);
-    DECL_LINK(Save, weld::Button&, void);
-    DECL_LINK(AddHdl, weld::Button&, void);
-    DECL_LINK(EditHdl, weld::Button&, void);
-    DECL_LINK(DeleteHdl, weld::Button&, void);
+    //VclPtr<SvSimpleTableContainer>      m_pTargetsContainer;
+    //VclPtr<TargetsTable>                m_pTargetsBox;
+    VclPtr<FixedText> m_pRedactionTargetsLabel;
+    VclPtr<PushButton> m_pLoadBtn;
+    VclPtr<PushButton> m_pSaveBtn;
+    VclPtr<PushButton> m_pAddBtn;
+    VclPtr<PushButton> m_pEditBtn;
+    VclPtr<PushButton> m_pDeleteBtn;
+
+    /*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(LoadHdl, sfx2::FileDialogHelper*, void);
     DECL_LINK(SaveHdl, sfx2::FileDialogHelper*, void);
@@ -129,25 +100,26 @@ class SFX2_DLLPUBLIC SfxAutoRedactDialog : public SfxDialogController
     /// Carry out proper addition both to the targets box, and to the tabletargets vector.
     void addTarget(RedactionTarget* pTarget);
     /// Clear all targets both visually and from the targets vector
-    void clearTargets();
+    void clearTargets();*/
 
 public:
-    SfxAutoRedactDialog(weld::Window* pParent);
+    SfxAutoRedactDialog(vcl::Window* pParent);
     virtual ~SfxAutoRedactDialog() override;
+    virtual void dispose() override;
 
     /// Check if the dialog has any valid redaction targets.
-    bool hasTargets() const;
+    //bool hasTargets() const;
     /// Check if the dialog is in a valid state.
-    bool isValidState() const { return m_bIsValidState; }
+    //bool isValidState() const { return m_bIsValidState; }
 
     /** Copies targets vector
      *  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
+/*class SfxAddTargetDialog : public weld::GenericDialogController
 {
 private:
     std::unique_ptr<weld::Entry> m_xName;
@@ -175,7 +147,7 @@ public:
         return m_xCaseSensitive->get_state() == TriState::TRISTATE_TRUE;
     }
     bool isWholeWords() const { return m_xWholeWords->get_state() == TriState::TRISTATE_TRUE; }
-};
+};*/
 
 #endif
 
diff --git a/sfx2/source/doc/SfxRedactionHelper.cxx b/sfx2/source/doc/SfxRedactionHelper.cxx
index fb3181db898b..7d39746ac46b 100644
--- a/sfx2/source/doc/SfxRedactionHelper.cxx
+++ b/sfx2/source/doc/SfxRedactionHelper.cxx
@@ -60,7 +60,7 @@ using namespace ::com::sun::star;
 using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::uno;
 
-constexpr OUStringLiteral SfxRedactionHelper::m_aPredefinedTargets[6];
+//constexpr OUStringLiteral SfxRedactionHelper::m_aPredefinedTargets[6];
 
 bool SfxRedactionHelper::isRedactMode(const SfxRequest& rReq)
 {
@@ -526,6 +526,19 @@ const LanguageTag& GetAppLanguageTag() { return Application::GetSettings().GetLa
 void SfxRedactionHelper::fillSearchOptions(i18nutil::SearchOptions2& rSearchOpt,
                                            const RedactionTarget* pTarget)
 {
+    static const OUStringLiteral m_aPredefinedTargets[6] = {
+        "\\b(?:\\d[ -]*?){13,16}\\b", //Credit card numbers
+        "\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\\b", //Email addresses
+        "\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
+        "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
+        "\\b", //IP addresses
+        "([12]\\d{3}[./-](0[1-9]|1[0-2])[./"
+        "-](0[1-9]|[12]\\d|3[01]))|((0[1-9]|[12]\\d|3[01])[./-](0[1-9]|1[0-2])[./"
+        "-][12]\\d{3})", //Dates (numerical)
+        "\\s*[a-zA-Z]{2}(?:\\s*\\d\\s*){6}[a-zA-Z]?\\s*", //National Insurance Number (UK)
+        "([1-9])(?!\\1{2}-\\1{2}-\\1{4})[1-9]{2}-[1-9]{2}-[1-9]{4}" //Social Security Number (US)
+    };
+
     if (!pTarget)
     {
         SAL_WARN("sfx.doc",
diff --git a/sfx2/source/doc/autoredactdialog.cxx b/sfx2/source/doc/autoredactdialog.cxx
index 49f6812861c9..fdf7ee673c1d 100644
--- a/sfx2/source/doc/autoredactdialog.cxx
+++ b/sfx2/source/doc/autoredactdialog.cxx
@@ -27,7 +27,6 @@
 #include <vcl/idle.hxx>
 #include <vcl/layout.hxx>
 #include <vcl/waitobj.hxx>
-#include <vcl/weld.hxx>
 #include <tools/debug.hxx>
 #include <tools/urlobj.hxx>
 #include <unotools/viewoptions.hxx>
@@ -36,7 +35,7 @@
 
 #include <boost/property_tree/json_parser.hpp>
 
-int TargetsTable::GetRowByTargetName(const OUString& sName)
+/*int TargetsTable::GetRowByTargetName(const OUString& sName)
 {
     for (int i = 0, nCount = m_xControl->n_children(); i < nCount; ++i)
     {
@@ -199,20 +198,20 @@ void TargetsTable::setRowData(const int& nRowIndex, const RedactionTarget* pTarg
     m_xControl->set_text(nRowIndex, pTarget->bWholeWords ? OUString("Yes") : OUString("No"), 4);
 }
 
-IMPL_LINK_NOARG(SfxAutoRedactDialog, Load, weld::Button&, void)
+IMPL_LINK_NOARG(SfxAutoRedactDialog, Load, Button*, void)
 {
     //Load a targets list from a previously saved file (a json file?)
     // ask for filename, where we should load the new config data from
     StartFileDialog(StartFileDialogType::Open, "Load Targets");
 }
 
-IMPL_LINK_NOARG(SfxAutoRedactDialog, Save, weld::Button&, void)
+IMPL_LINK_NOARG(SfxAutoRedactDialog, Save, Button*, void)
 {
     //Allow saving the targets into a file
     StartFileDialog(StartFileDialogType::SaveAs, "Save Targets");
 }
 
-IMPL_LINK_NOARG(SfxAutoRedactDialog, AddHdl, weld::Button&, void)
+IMPL_LINK_NOARG(SfxAutoRedactDialog, AddHdl, Button*, void)
 {
     // Open the Add Target dialog, craete a new target and insert into the targets vector and the listbox
     SfxAddTargetDialog aAddTargetDialog(getDialog(), m_xTargetsBox->GetNameProposal());
@@ -267,7 +266,7 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, AddHdl, weld::Button&, void)
     }
 }
 
-IMPL_LINK_NOARG(SfxAutoRedactDialog, EditHdl, weld::Button&, void)
+IMPL_LINK_NOARG(SfxAutoRedactDialog, EditHdl, Button*, void)
 {
     sal_Int32 nSelectedRow = m_xTargetsBox->get_selected_index();
 
@@ -337,7 +336,7 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, EditHdl, weld::Button&, void)
     m_xTargetsBox->setRowData(nSelectedRow, pTarget);
 }
 
-IMPL_LINK_NOARG(SfxAutoRedactDialog, DeleteHdl, weld::Button&, void)
+IMPL_LINK_NOARG(SfxAutoRedactDialog, DeleteHdl, Button*, void)
 {
     std::vector<int> aSelectedRows = m_xTargetsBox->get_selected_rows();
 
@@ -540,22 +539,21 @@ void SfxAutoRedactDialog::clearTargets()
     std::for_each(m_aTableTargets.begin(), m_aTableTargets.end(), delTarget);
 
     m_aTableTargets.clear();
-}
+}*/
 
-SfxAutoRedactDialog::SfxAutoRedactDialog(weld::Window* pParent)
-    : SfxDialogController(pParent, "sfx/ui/autoredactdialog.ui", "AutoRedactDialog")
+SfxAutoRedactDialog::SfxAutoRedactDialog(vcl::Window* pParent)
+    : SfxModalDialog(pParent, "AutoRedactDialog", "sfx/ui/autoredactdialog.ui")
     , m_bIsValidState(true)
     , m_bTargetsCopied(false)
-    , m_xRedactionTargetsLabel(m_xBuilder->weld_label("labelRedactionTargets"))
-    , m_xTargetsBox(new TargetsTable(m_xBuilder->weld_tree_view("targets")))
-    , m_xLoadBtn(m_xBuilder->weld_button("btnLoadTargets"))
-    , m_xSaveBtn(m_xBuilder->weld_button("btnSaveTargets"))
-    , m_xAddBtn(m_xBuilder->weld_button("add"))
-    , m_xEditBtn(m_xBuilder->weld_button("edit"))
-    , m_xDeleteBtn(m_xBuilder->weld_button("delete"))
 {
+    get(m_pRedactionTargetsLabel, "labelRedactionTargets");
+    get(m_pLoadBtn, "btnLoadTargets");
+    get(m_pSaveBtn, "btnSaveTargets");
+    get(m_pAddBtn, "add");
+    get(m_pEditBtn, "edit");
+    get(m_pDeleteBtn, "delete");
     // Can be used to remmeber the last set of redaction targets?
-    OUString sExtraData;
+    /*OUString sExtraData;
     SvtViewOptions aDlgOpt(EViewType::Dialog,
                            OStringToOUString(m_xDialog->get_help_id(), RTL_TEXTENCODING_UTF8));
 
@@ -593,19 +591,19 @@ SfxAutoRedactDialog::SfxAutoRedactDialog(weld::Window* pParent)
             return;
             //TODO: Warn the user with a message box
         }
-    }
+    }*/
 
     // Handler connections
-    m_xLoadBtn->connect_clicked(LINK(this, SfxAutoRedactDialog, Load));
+    /*m_xLoadBtn->connect_clicked(LINK(this, SfxAutoRedactDialog, Load));
     m_xSaveBtn->connect_clicked(LINK(this, SfxAutoRedactDialog, Save));
     m_xAddBtn->connect_clicked(LINK(this, SfxAutoRedactDialog, AddHdl));
     m_xEditBtn->connect_clicked(LINK(this, SfxAutoRedactDialog, EditHdl));
-    m_xDeleteBtn->connect_clicked(LINK(this, SfxAutoRedactDialog, DeleteHdl));
+    m_xDeleteBtn->connect_clicked(LINK(this, SfxAutoRedactDialog, DeleteHdl));*/
 }
 
 SfxAutoRedactDialog::~SfxAutoRedactDialog()
 {
-    if (m_aTableTargets.empty())
+    /*if (m_aTableTargets.empty())
     {
         // Clear the dialog data
         SvtViewOptions aDlgOpt(EViewType::Dialog,
@@ -646,10 +644,22 @@ SfxAutoRedactDialog::~SfxAutoRedactDialog()
                  "Exception caught while trying to store the dialog state: " << e.Message);
         return;
         //TODO: Warn the user with a message box
-    }
+    }*/
+    disposeOnce();
 }
 
-bool SfxAutoRedactDialog::hasTargets() const
+void SfxAutoRedactDialog::dispose()
+{
+    m_pRedactionTargetsLabel.clear();
+    m_pLoadBtn.clear();
+    m_pSaveBtn.clear();
+    m_pAddBtn.clear();
+    m_pEditBtn.clear();
+    m_pDeleteBtn.clear();
+    SfxModalDialog::dispose();
+}
+
+/*bool SfxAutoRedactDialog::hasTargets() const
 {
     //TODO: Add also some validity checks?
     if (m_aTableTargets.empty())
@@ -783,6 +793,6 @@ OUString SfxAddTargetDialog::getContent() const
     }
 
     return m_xContent->get_text();
-}
+}*/
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 3c8fd76ce3b5..1f01253d742d 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -537,10 +537,18 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
 
         case SID_AUTOREDACTDOC:
         {
-            SfxAutoRedactDialog aDlg(pDialogParent);
-            sal_Int16 nResult = aDlg.run();
+            SfxViewFrame* pFrame = GetFrame();
+            if ( !pFrame )
+                pFrame = SfxViewFrame::GetFirst( this );
+            if ( !pFrame )
+                return;
+
+
+
+            SfxAutoRedactDialog aDlg(&pFrame->GetWindow());
+            sal_Int16 nResult = aDlg.Execute();
 
-            if (nResult != RET_OK || !aDlg.hasTargets() || !aDlg.isValidState())
+            if (nResult != RET_OK /*|| !aDlg.hasTargets() || !aDlg.isValidState()*/)
             {
                 //Do nothing
                 return;
@@ -548,7 +556,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
 
             // else continue with normal redaction
             bIsAutoRedact = true;
-            aDlg.getTargets(aRedactionTargets);
+            //aDlg.getTargets(aRedactionTargets);
 
             [[fallthrough]];
         }


More information about the Libreoffice-commits mailing list