[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sfx2/inc sfx2/source
sfx2/inc/autoredactdialog.hxx| 14 +- sfx2/source/doc/autoredactdialog.cxx | 25 - sfx2/source/doc/objserv.cxx |2 +- 3 files changed, 14 insertions(+), 27 deletions(-) New commits: commit 1200845272cb1a92507cfe01c125c5aca2d5452f Author: Muhammet Kara AuthorDate: Tue Jun 18 21:04:26 2019 +0300 Commit: Muhammet Kara CommitDate: Tue Jun 18 22:20:31 2019 +0200 Copy targets instead of moving during redaction To allow properly remembering the last state. * And some clean-up. Change-Id: Id0b0f4251e3578b8baced1e6e6b1161f46e324dc Reviewed-on: https://gerrit.libreoffice.org/74302 Tested-by: Jenkins Reviewed-by: Muhammet Kara Reviewed-on: https://gerrit.libreoffice.org/74308 Tested-by: Muhammet Kara diff --git a/sfx2/inc/autoredactdialog.hxx b/sfx2/inc/autoredactdialog.hxx index 2cec20cc64c8..7082052d60a9 100644 --- a/sfx2/inc/autoredactdialog.hxx +++ b/sfx2/inc/autoredactdialog.hxx @@ -106,6 +106,7 @@ class SFX2_DLLPUBLIC SfxAutoRedactDialog : public SfxDialogController std::vector> m_aTableTargets; std::unique_ptr m_pFileDlg; bool m_bIsValidState; +bool m_bTargetsCopied; std::unique_ptr m_xRedactionTargetsLabel; std::unique_ptr m_xTargetsBox; @@ -138,16 +139,11 @@ public: bool hasTargets() const; /// Check if the dialog is in a valid state. bool isValidState() const { return m_bIsValidState; } -/** Literally moves targets into the given vector. - * At the end of the operation, m_aTableTargets vector becomes empty. - * The contents of the given vector will be erased before being filled in. - * Returns true if successfull. +/** Copies targets vector + * Does a shallow copy. + * Returns true if successful. */ -bool moveTargets(std::vector>& r_aTargets); - -// TODO: Some method(s) to check emptiness/validity -// TODO: Some method(s) to get the search params/objects -// TODO: Some method(s) to load/save redaction target sets +bool getTargets(std::vector>& r_aTargets); }; class SfxAddTargetDialog : public weld::GenericDialogController diff --git a/sfx2/source/doc/autoredactdialog.cxx b/sfx2/source/doc/autoredactdialog.cxx index c7248446f9f3..b1882f7b5717 100644 --- a/sfx2/source/doc/autoredactdialog.cxx +++ b/sfx2/source/doc/autoredactdialog.cxx @@ -545,6 +545,7 @@ void SfxAutoRedactDialog::clearTargets() SfxAutoRedactDialog::SfxAutoRedactDialog(weld::Window* pParent) : SfxDialogController(pParent, "sfx/ui/autoredactdialog.ui", "AutoRedactDialog") , 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")) @@ -636,7 +637,8 @@ SfxAutoRedactDialog::~SfxAutoRedactDialog() OStringToOUString(m_xDialog->get_help_id(), RTL_TEXTENCODING_UTF8)); aDlgOpt.SetUserItem("UserItem", css::uno::makeAny(sUserDataStr)); -clearTargets(); +if (!m_bTargetsCopied) +clearTargets(); } catch (css::uno::Exception& e) { @@ -656,24 +658,13 @@ bool SfxAutoRedactDialog::hasTargets() const return true; } -bool SfxAutoRedactDialog::moveTargets( -std::vector>& r_aTargets) +bool SfxAutoRedactDialog::getTargets(std::vector>& r_aTargets) { -try -{ -r_aTargets.clear(); -r_aTargets.insert(r_aTargets.end(), std::make_move_iterator(m_aTableTargets.begin()), - std::make_move_iterator(m_aTableTargets.end())); -m_aTableTargets.clear(); -m_bIsValidState = false; -} -catch (const css::uno::Exception& e) -{ -SAL_WARN("sfx.doc", "Exception caught while moving redaction targets: " << e.Message); -m_bIsValidState = false; -return false; -} +if (m_aTableTargets.empty()) +return true; +r_aTargets = m_aTableTargets; +m_bTargetsCopied = true; return true; } diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 9b9b3fc0f9dc..73bc90490f22 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -560,7 +560,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest ) // else continue with normal redaction bIsAutoRedact = true; -aDlg.moveTargets(aRedactionTargets); +aDlg.getTargets(aRedactionTargets); [[fallthrough]]; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sfx2/inc sfx2/source
sfx2/inc/SfxRedactionHelper.hxx| 14 +- sfx2/inc/autoredactdialog.hxx | 13 ++--- sfx2/source/doc/SfxRedactionHelper.cxx | 29 + sfx2/source/doc/autoredactdialog.cxx | 22 ++ sfx2/source/doc/objserv.cxx| 12 5 files changed, 70 insertions(+), 20 deletions(-) New commits: commit 85f00a0fed27b551290a51688f630587bb43fd98 Author: Muhammet Kara AuthorDate: Wed Jun 12 21:21:26 2019 +0300 Commit: Muhammet Kara CommitDate: Mon Jun 17 23:30:44 2019 +0200 Auto redaction dialog 6th iteration * Binds everything together. * The auto redaction process works end to end now. * Only for case sensitive text content (no regex support yet) Change-Id: I6edd67472d376e2c0d91ac4b1ff90d98c49b13ac Reviewed-on: https://gerrit.libreoffice.org/73908 Tested-by: Jenkins Reviewed-by: Muhammet Kara Reviewed-on: https://gerrit.libreoffice.org/74231 Tested-by: Muhammet Kara diff --git a/sfx2/inc/SfxRedactionHelper.hxx b/sfx2/inc/SfxRedactionHelper.hxx index 44a78ab9b877..9be54ca8ac22 100644 --- a/sfx2/inc/SfxRedactionHelper.hxx +++ b/sfx2/inc/SfxRedactionHelper.hxx @@ -31,6 +31,7 @@ class SfxStringItem; class GDIMetaFile; class DocumentToGraphicRenderer; class SfxViewFrame; +struct RedactionTarget; struct PageMargins { @@ -66,10 +67,12 @@ public: * Creates one shape and one draw page for each gdimetafile, * and inserts the shapes into the newly created draw pages. * */ -static void addPagesToDraw(uno::Reference& xComponent, const sal_Int32& nPages, - const std::vector& aMetaFiles, - const std::vector<::Size>& aPageSizes, - const PageMargins& aPageMargins); +static void +addPagesToDraw(uno::Reference& xComponent, const sal_Int32& nPages, + const std::vector& aMetaFiles, + const std::vector<::Size>& aPageSizes, const PageMargins& aPageMargins, + const std::vector>& r_aTableTargets, + const bool& bIsAutoRedact); /* * Makes the Redaction toolbar visible to the user. * Meant to be called after converting a document to a Draw doc @@ -104,7 +107,8 @@ public: * Search for the given term through the gdimetafile, which has the whole content of a draw page, * and draw redaction rectangles to the appropriate positions with suitable sizes. * */ -static void autoRedactPage(const OUString& sRedactionTerm, const GDIMetaFile& rGDIMetaFile, +static void autoRedactPage(const RedactionTarget* pRedactionTarget, + const GDIMetaFile& rGDIMetaFile, uno::Reference& xPage, uno::Reference& xComponent); }; diff --git a/sfx2/inc/autoredactdialog.hxx b/sfx2/inc/autoredactdialog.hxx index 2336d66c4063..bab00cf536a3 100644 --- a/sfx2/inc/autoredactdialog.hxx +++ b/sfx2/inc/autoredactdialog.hxx @@ -105,6 +105,7 @@ class SFX2_DLLPUBLIC SfxAutoRedactDialog : public SfxDialogController SfxObjectShellLock m_xDocShell; std::vector> m_aTableTargets; std::unique_ptr m_pFileDlg; +bool m_bIsValidState; std::unique_ptr m_xRedactionTargetsLabel; std::unique_ptr m_xTargetsBox; @@ -133,10 +134,16 @@ public: SfxAutoRedactDialog(weld::Window* pParent); virtual ~SfxAutoRedactDialog() override; -/* - * Check if the dialog has any valid redaction targets. - */ +/// Check if the dialog has any valid redaction targets. bool hasTargets() const; +/// Check if the dialog is in a valid state. +bool isValidState() const { return m_bIsValidState; } +/** Literally moves targets into the given vector. + * At the end of the operation, m_aTableTargets vector becomes empty. + * The contents of the given vector will be erased before being filled in. + * Returns true if successfull. + */ +bool moveTargets(std::vector>& r_aTargets); // TODO: Some method(s) to check emptiness/validity // TODO: Some method(s) to get the search params/objects diff --git a/sfx2/source/doc/SfxRedactionHelper.cxx b/sfx2/source/doc/SfxRedactionHelper.cxx index 35d3acdc0067..c5f015ea9d08 100644 --- a/sfx2/source/doc/SfxRedactionHelper.cxx +++ b/sfx2/source/doc/SfxRedactionHelper.cxx @@ -8,6 +8,7 @@ */ #include +#include #include #include @@ -204,11 +205,12 @@ void SfxRedactionHelper::getPageMetaFilesFromDoc(std::vector& aMeta } } -void SfxRedactionHelper::addPagesToDraw(uno::Reference& xComponent, -const sal_Int32& nPages, -const std::vector& aMetaFiles, -const std::vector<::Size>& aPageSizes, -const PageMargins&
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sfx2/inc sfx2/source
sfx2/inc/SfxRedactionHelper.hxx|6 -- sfx2/source/doc/SfxRedactionHelper.cxx | 10 +++--- sfx2/source/doc/objserv.cxx|5 +++-- 3 files changed, 14 insertions(+), 7 deletions(-) New commits: commit 26c1fd655ac8362d44caf8423df0429c0e9ce7f2 Author: Muhammet Kara AuthorDate: Wed May 1 18:46:47 2019 +0300 Commit: Muhammet Kara CommitDate: Mon Jun 17 22:53:48 2019 +0200 tdf#125063: Don't depend on content size for Page sizing During redaction of Calc sheets Change-Id: If2a4f71c77a687a74b8f823152b76d2a7e2e21da Reviewed-on: https://gerrit.libreoffice.org/71627 Tested-by: Jenkins Reviewed-by: Muhammet Kara Reviewed-on: https://gerrit.libreoffice.org/74222 Tested-by: Muhammet Kara diff --git a/sfx2/inc/SfxRedactionHelper.hxx b/sfx2/inc/SfxRedactionHelper.hxx index d338143c608e..1cd653650557 100644 --- a/sfx2/inc/SfxRedactionHelper.hxx +++ b/sfx2/inc/SfxRedactionHelper.hxx @@ -15,6 +15,7 @@ #include #include +#include #include @@ -47,7 +48,7 @@ public: * and pushes into the given vector. * */ static void getPageMetaFilesFromDoc(std::vector& aMetaFiles, -const sal_Int32& nPages, +std::vector<::Size>& aPageSizes, const sal_Int32& nPages, DocumentToGraphicRenderer& aRenderer, bool bIsWriter, bool bIsCalc); /* @@ -55,7 +56,8 @@ public: * and inserts the shapes into the newly created draw pages. * */ static void addPagesToDraw(uno::Reference& xComponent, const sal_Int32& nPages, - const std::vector& aMetaFiles, bool bIsCalc); + const std::vector& aMetaFiles, + const std::vector<::Size>& aPageSizes, bool bIsCalc); /* * Makes the Redaction toolbar visible to the user. * Meant to be called after converting a document to a Draw doc diff --git a/sfx2/source/doc/SfxRedactionHelper.cxx b/sfx2/source/doc/SfxRedactionHelper.cxx index 732b56092da2..b1743e5ba20b 100644 --- a/sfx2/source/doc/SfxRedactionHelper.cxx +++ b/sfx2/source/doc/SfxRedactionHelper.cxx @@ -61,6 +61,7 @@ OUString SfxRedactionHelper::getStringParam(const SfxRequest& rReq, const sal_uI } void SfxRedactionHelper::getPageMetaFilesFromDoc(std::vector& aMetaFiles, + std::vector<::Size>& aPageSizes, const sal_Int32& nPages, DocumentToGraphicRenderer& aRenderer, bool bIsWriter, bool bIsCalc) @@ -76,6 +77,8 @@ void SfxRedactionHelper::getPageMetaFilesFromDoc(std::vector& aMeta // FIXME: This is a temporary hack. Need to figure out a proper way to derive this scale factor. ::Size aTargetSize(aDocumentSizePixel.Width() * 1.23, aDocumentSizePixel.Height() * 1.23); +aPageSizes.push_back(aLogic); + Graphic aGraphic = aRenderer.renderToGraphic(nPage, aDocumentSizePixel, aTargetSize, COL_TRANSPARENT, true); auto& rGDIMetaFile = const_cast(aGraphic.GetGDIMetaFile()); @@ -109,7 +112,8 @@ void SfxRedactionHelper::getPageMetaFilesFromDoc(std::vector& aMeta void SfxRedactionHelper::addPagesToDraw(uno::Reference& xComponent, const sal_Int32& nPages, -const std::vector& aMetaFiles, bool bIsCalc) +const std::vector& aMetaFiles, +const std::vector<::Size>& aPageSizes, bool bIsCalc) { // Access the draw pages uno::Reference xDrawPagesSupplier(xComponent, uno::UNO_QUERY); @@ -122,8 +126,8 @@ void SfxRedactionHelper::addPagesToDraw(uno::Reference& xComponent, GDIMetaFile rGDIMetaFile = aMetaFiles[nPage]; Graphic aGraphic(rGDIMetaFile); -sal_Int32 nPageHeight(rGDIMetaFile.GetPrefSize().Height()); -sal_Int32 nPageWidth(rGDIMetaFile.GetPrefSize().Width()); +sal_Int32 nPageHeight(aPageSizes[nPage].Height()); +sal_Int32 nPageWidth(aPageSizes[nPage].Width()); uno::Reference xGraph = aGraphic.GetXGraphic(); uno::Reference xPage = xDrawPages->insertNewByIndex(nPage); diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index a34ad5c24113..72d46d50e217 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -558,9 +558,10 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest ) sal_Int32 nPages = aRenderer.getPageCount(); std::vector< GDIMetaFile > aMetaFiles; +std::vector< ::Size > aPageSizes; // Convert the pages of the document to