core.git: Branch 'distro/collabora/co-24.04' - chart2/source drawinglayer/source include/basegfx include/drawinglayer include/tools svx/source
chart2/source/model/main/PageBackground.cxx | 11 --- drawinglayer/source/geometry/viewinformation2d.cxx | 13 - drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |6 +- include/basegfx/color/bcolor.hxx|4 include/drawinglayer/geometry/viewinformation2d.hxx |4 include/tools/color.hxx |5 - svx/source/sdr/contact/objectcontactofpageview.cxx |4 7 files changed, 41 insertions(+), 6 deletions(-) New commits: commit 36529a48420f4e11a0d8865f326910a1abe98547 Author: offtkp AuthorDate: Wed Dec 13 03:39:14 2023 +0200 Commit: Andras Timar CommitDate: Tue Jan 16 22:56:24 2024 +0100 chart2: Make automatic area coloring for charts work for tiled rendering Charts now get a temporary colored applied to the area property set if their color was set to automatic, which is done by default in tiled rendering mode. Change-Id: Ic6bd19b97d2a0ffa2a1ad516cfa202e2f4921db7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160659 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/chart2/source/model/main/PageBackground.cxx b/chart2/source/model/main/PageBackground.cxx index c866bdbb3f4a..b4c21df55fb4 100644 --- a/chart2/source/model/main/PageBackground.cxx +++ b/chart2/source/model/main/PageBackground.cxx @@ -18,6 +18,7 @@ */ #include "PageBackground.hxx" +#include #include #include #include @@ -51,10 +52,14 @@ const ::chart::tPropertyValueMap& StaticPageBackgroundDefaults() // override other defaults Color aDocColor = COL_WHITE; -if (SfxViewShell::Current()) { -aDocColor = SfxViewShell::Current()->GetColorConfigColor(svtools::DOCCOLOR); +if (comphelper::LibreOfficeKit::isActive()) { +aDocColor = COL_AUTO; } else { -SAL_WARN("chart2", "SfxViewShell::Current() returned nullptr"); +if (SfxViewShell::Current()) { +aDocColor = SfxViewShell::Current()->GetColorConfigColor(svtools::DOCCOLOR); +} else { +SAL_WARN("chart2", "SfxViewShell::Current() returned nullptr"); +} } ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::FillProperties::PROP_FILL_COLOR, aDocColor ); ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE ); diff --git a/drawinglayer/source/geometry/viewinformation2d.cxx b/drawinglayer/source/geometry/viewinformation2d.cxx index 03089e41e36f..4a9805acf7c1 100644 --- a/drawinglayer/source/geometry/viewinformation2d.cxx +++ b/drawinglayer/source/geometry/viewinformation2d.cxx @@ -87,6 +87,9 @@ protected: // the point in time double mfViewTime; +// color to use for automatic color +Color maAutoColor; + // allow to reduce DisplayQuality (e.g. sw 3d fallback renderer for interactions) bool mbReducedDisplayQuality : 1; @@ -106,6 +109,7 @@ public: , maDiscreteViewport() , mxVisualizedPage() , mfViewTime(0.0) +, maAutoColor(COL_AUTO) , mbReducedDisplayQuality(false) , mbUseAntiAliasing(ViewInformation2D::getGlobalAntiAliasing()) , mbPixelSnapHairline(mbUseAntiAliasing && bForwardPixelSnapHairline) @@ -190,6 +194,9 @@ public: mxVisualizedPage = rNew; } +Color getAutoColor() const { return maAutoColor; } +void setAutoColor(Color aNew) { maAutoColor = aNew; } + bool getReducedDisplayQuality() const { return mbReducedDisplayQuality; } void setReducedDisplayQuality(bool bNew) { mbReducedDisplayQuality = bNew; } @@ -205,7 +212,7 @@ public: && maViewTransformation == rCandidate.maViewTransformation && maViewport == rCandidate.maViewport && mxVisualizedPage == rCandidate.mxVisualizedPage -&& mfViewTime == rCandidate.mfViewTime +&& mfViewTime == rCandidate.mfViewTime && maAutoColor == rCandidate.maAutoColor && mbReducedDisplayQuality == rCandidate.mbReducedDisplayQuality && mbUseAntiAliasing == rCandidate.mbUseAntiAliasing && mbPixelSnapHairline == rCandidate.mbPixelSnapHairline); @@ -342,6 +349,10 @@ void ViewInformation2D::setUseAntiAliasing(bool bNew) mpViewInformation2D->setUseAntiAliasing(bNew); } +Color ViewInformation2D::getAutoColor() const { return mpViewInformation2D->getAutoColor(); } + +void ViewInformation2D::setAutoColor(Color aNew) { mpViewInformation2D->setAutoColor(aNew); } + bool ViewInformation2D::getPixelSnapHairline() const { return mpViewInformation2D->getPixelSnapHairline(); diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
core.git: Branch 'distro/collabora/co-23.05' - chart2/source drawinglayer/source include/basegfx include/drawinglayer include/tools svx/source
chart2/source/model/main/PageBackground.cxx | 16 drawinglayer/source/geometry/viewinformation2d.cxx | 13 - drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |6 +- include/basegfx/color/bcolor.hxx|5 + include/drawinglayer/geometry/viewinformation2d.hxx |5 + include/tools/color.hxx |5 - svx/source/sdr/contact/objectcontactofpageview.cxx |4 7 files changed, 47 insertions(+), 7 deletions(-) New commits: commit 9d971b719b74013ff9d63044092fd832bfa8d7b0 Author: offtkp AuthorDate: Wed Dec 13 03:39:14 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Tue Jan 16 14:20:29 2024 +0100 chart2: Make automatic area coloring for charts work for tiled rendering Charts now get a temporary colored applied to the area property set if their color was set to automatic, which is done by default in tiled rendering mode. Change-Id: Ic6bd19b97d2a0ffa2a1ad516cfa202e2f4921db7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162174 Tested-by: Jenkins CollaboraOffice Reviewed-by: Tomaž Vajngerl diff --git a/chart2/source/model/main/PageBackground.cxx b/chart2/source/model/main/PageBackground.cxx index 776e751b2934..55cee4483a3c 100644 --- a/chart2/source/model/main/PageBackground.cxx +++ b/chart2/source/model/main/PageBackground.cxx @@ -18,6 +18,7 @@ */ #include "PageBackground.hxx" +#include #include #include #include @@ -57,10 +58,17 @@ private: // override other defaults Color aDocColor = COL_WHITE; -if (SfxViewShell::Current()) { -aDocColor = SfxViewShell::Current()->GetColorConfigColor(svtools::DOCCOLOR); -} else { -SAL_WARN("chart2", "SfxViewShell::Current() returned nullptr"); +if (comphelper::LibreOfficeKit::isActive()) +{ +aDocColor = COL_AUTO; +} +else +{ +if (SfxViewShell::Current()) { +aDocColor = SfxViewShell::Current()->GetColorConfigColor(svtools::DOCCOLOR); +} else { +SAL_WARN("chart2", "SfxViewShell::Current() returned nullptr"); +} } ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, aDocColor ); ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE ); diff --git a/drawinglayer/source/geometry/viewinformation2d.cxx b/drawinglayer/source/geometry/viewinformation2d.cxx index 7e0240690a68..3d61c538541c 100644 --- a/drawinglayer/source/geometry/viewinformation2d.cxx +++ b/drawinglayer/source/geometry/viewinformation2d.cxx @@ -85,6 +85,9 @@ protected: // the point in time double mfViewTime; +// color to use for automatic color +Color maAutoColor; + // allow to reduce DisplayQuality (e.g. sw 3d fallback renderer for interactions) bool mbReducedDisplayQuality : 1; @@ -104,6 +107,7 @@ public: , maDiscreteViewport() , mxVisualizedPage() , mfViewTime(0.0) +, maAutoColor(COL_AUTO) , mbReducedDisplayQuality(false) , mbUseAntiAliasing(bForwardedAntiAliasing) , mbPixelSnapHairline(bForwardedAntiAliasing && bForwardPixelSnapHairline) @@ -188,6 +192,9 @@ public: mxVisualizedPage = rNew; } +Color getAutoColor() const { return maAutoColor; } +void setAutoColor(Color aNew) { maAutoColor = aNew; } + bool getReducedDisplayQuality() const { return mbReducedDisplayQuality; } void setReducedDisplayQuality(bool bNew) { mbReducedDisplayQuality = bNew; } @@ -203,7 +210,7 @@ public: && maViewTransformation == rCandidate.maViewTransformation && maViewport == rCandidate.maViewport && mxVisualizedPage == rCandidate.mxVisualizedPage -&& mfViewTime == rCandidate.mfViewTime +&& mfViewTime == rCandidate.mfViewTime && maAutoColor == rCandidate.maAutoColor && mbReducedDisplayQuality == rCandidate.mbReducedDisplayQuality && mbUseAntiAliasing == rCandidate.mbUseAntiAliasing && mbPixelSnapHairline == rCandidate.mbPixelSnapHairline); @@ -341,6 +348,10 @@ void ViewInformation2D::setUseAntiAliasing(bool bNew) mpViewInformation2D->setUseAntiAliasing(bNew); } +Color ViewInformation2D::getAutoColor() const { return mpViewInformation2D->getAutoColor(); } + +void ViewInformation2D::setAutoColor(Color aNew) { mpViewInformation2D->setAutoColor(aNew); } + bool ViewInformation2D::getPixelSnapHairline() const { return mpViewInformation2D->getPixelSnapHairline(); diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index dd3ae6b6c8e9..43b8a4fa55bc 100644 ---
core.git: chart2/source drawinglayer/source include/basegfx include/drawinglayer include/tools svx/source
chart2/source/model/main/PageBackground.cxx | 11 --- drawinglayer/source/geometry/viewinformation2d.cxx | 13 - drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |6 +- include/basegfx/color/bcolor.hxx|4 include/drawinglayer/geometry/viewinformation2d.hxx |4 include/tools/color.hxx |5 - svx/source/sdr/contact/objectcontactofpageview.cxx |4 7 files changed, 41 insertions(+), 6 deletions(-) New commits: commit 925c05ee1a1259641a28fe43588f425aff06b95e Author: offtkp AuthorDate: Wed Dec 13 03:39:14 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Tue Jan 16 14:19:56 2024 +0100 chart2: Make automatic area coloring for charts work for tiled rendering Charts now get a temporary colored applied to the area property set if their color was set to automatic, which is done by default in tiled rendering mode. Change-Id: Ic6bd19b97d2a0ffa2a1ad516cfa202e2f4921db7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160659 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/chart2/source/model/main/PageBackground.cxx b/chart2/source/model/main/PageBackground.cxx index c866bdbb3f4a..b4c21df55fb4 100644 --- a/chart2/source/model/main/PageBackground.cxx +++ b/chart2/source/model/main/PageBackground.cxx @@ -18,6 +18,7 @@ */ #include "PageBackground.hxx" +#include #include #include #include @@ -51,10 +52,14 @@ const ::chart::tPropertyValueMap& StaticPageBackgroundDefaults() // override other defaults Color aDocColor = COL_WHITE; -if (SfxViewShell::Current()) { -aDocColor = SfxViewShell::Current()->GetColorConfigColor(svtools::DOCCOLOR); +if (comphelper::LibreOfficeKit::isActive()) { +aDocColor = COL_AUTO; } else { -SAL_WARN("chart2", "SfxViewShell::Current() returned nullptr"); +if (SfxViewShell::Current()) { +aDocColor = SfxViewShell::Current()->GetColorConfigColor(svtools::DOCCOLOR); +} else { +SAL_WARN("chart2", "SfxViewShell::Current() returned nullptr"); +} } ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::FillProperties::PROP_FILL_COLOR, aDocColor ); ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE ); diff --git a/drawinglayer/source/geometry/viewinformation2d.cxx b/drawinglayer/source/geometry/viewinformation2d.cxx index 67993d95544b..d238c9b893e0 100644 --- a/drawinglayer/source/geometry/viewinformation2d.cxx +++ b/drawinglayer/source/geometry/viewinformation2d.cxx @@ -87,6 +87,9 @@ protected: // the point in time double mfViewTime; +// color to use for automatic color +Color maAutoColor; + // allow to reduce DisplayQuality (e.g. sw 3d fallback renderer for interactions) bool mbReducedDisplayQuality : 1; @@ -106,6 +109,7 @@ public: , maDiscreteViewport() , mxVisualizedPage() , mfViewTime(0.0) +, maAutoColor(COL_AUTO) , mbReducedDisplayQuality(false) , mbUseAntiAliasing(ViewInformation2D::getGlobalAntiAliasing()) , mbPixelSnapHairline(mbUseAntiAliasing && bForwardPixelSnapHairline) @@ -190,6 +194,9 @@ public: mxVisualizedPage = rNew; } +Color getAutoColor() const { return maAutoColor; } +void setAutoColor(Color aNew) { maAutoColor = aNew; } + bool getReducedDisplayQuality() const { return mbReducedDisplayQuality; } void setReducedDisplayQuality(bool bNew) { mbReducedDisplayQuality = bNew; } @@ -205,7 +212,7 @@ public: && maViewTransformation == rCandidate.maViewTransformation && maViewport == rCandidate.maViewport && mxVisualizedPage == rCandidate.mxVisualizedPage -&& mfViewTime == rCandidate.mfViewTime +&& mfViewTime == rCandidate.mfViewTime && maAutoColor == rCandidate.maAutoColor && mbReducedDisplayQuality == rCandidate.mbReducedDisplayQuality && mbUseAntiAliasing == rCandidate.mbUseAntiAliasing && mbPixelSnapHairline == rCandidate.mbPixelSnapHairline); @@ -342,6 +349,10 @@ void ViewInformation2D::setUseAntiAliasing(bool bNew) mpViewInformation2D->setUseAntiAliasing(bNew); } +Color ViewInformation2D::getAutoColor() const { return mpViewInformation2D->getAutoColor(); } + +void ViewInformation2D::setAutoColor(Color aNew) { mpViewInformation2D->setAutoColor(aNew); } + bool ViewInformation2D::getPixelSnapHairline() const { return mpViewInformation2D->getPixelSnapHairline(); diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
[Libreoffice-commits] core.git: sc/source
sc/source/ui/app/inputhdl.cxx | 12 1 file changed, 12 insertions(+) New commits: commit 17e362e56f9e15d0214c441e632c91d22e58519d Author: offtkp AuthorDate: Wed Nov 22 17:00:53 2023 +0200 Commit: Paris Oplopoios CommitDate: Thu Nov 23 16:13:39 2023 +0100 tdf#158252 sc: Enable text wrapping when inputting line breaks in cell In Excel, when typing new lines in a cell or pasting text with new lines and then clicking out of the cell, wrap text is enabled, which actually shows the contents on the new line instead of on the same line Change-Id: I113aceab33380a5deb536f57969c3fc90825146b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159758 Tested-by: Paris Oplopoios Reviewed-by: Paris Oplopoios diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 344651136876..809ba8520e33 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -3142,6 +3143,17 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInL lcl_RemoveTabs(aString); lcl_RemoveTabs(aPreAutoCorrectString); +if (aString.indexOf('\n') != -1) +{ +// Cell contains line breaks, enable wrapping +ScLineBreakCell aBreakItem(true); +pActiveViewSh->ApplyAttr(aBreakItem); + +SfxViewFrame* pViewFrm = SfxViewFrame::Current(); +if (pViewFrm) +pViewFrm->GetBindings().Invalidate(SID_ATTR_ALIGN_LINEBREAK); +} + // Test if valid (always with simple string) if (bModified && nValidation) {
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/source
sc/source/ui/app/inputhdl.cxx | 12 1 file changed, 12 insertions(+) New commits: commit 1482ae614645599bebedec7c0467333bd324 Author: offtkp AuthorDate: Wed Nov 22 17:00:53 2023 +0200 Commit: Paris Oplopoios CommitDate: Wed Nov 22 17:05:46 2023 +0100 sc: Enable text wrapping when inputting line breaks in cell In Excel, when typing new lines in a cell or pasting text with new lines and then clicking out of the cell, wrap text is enabled, which actually shows the contents on the new line instead of on the same line Change-Id: I113aceab33380a5deb536f57969c3fc90825146b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159821 Tested-by: Paris Oplopoios Reviewed-by: Paris Oplopoios diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 7aa1ebf218be..1153a7dc03d4 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -3144,6 +3145,17 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInL lcl_RemoveTabs(aString); lcl_RemoveTabs(aPreAutoCorrectString); +if (aString.indexOf('\n') != -1) +{ +// Cell contains line breaks, enable wrapping +ScLineBreakCell aBreakItem(true); +pActiveViewSh->ApplyAttr(aBreakItem); + +SfxViewFrame* pViewFrm = SfxViewFrame::Current(); +if (pViewFrm) +pViewFrm->GetBindings().Invalidate(SID_ATTR_ALIGN_LINEBREAK); +} + // Test if valid (always with simple string) if (bModified && nValidation && pActiveViewSh) {
[Libreoffice-commits] core.git: chart2/source
chart2/source/model/main/PageBackground.cxx | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) New commits: commit b5a35f09b3c3ccac26b403e881c799e0d09bf42a Author: offtkp AuthorDate: Mon Nov 20 22:58:20 2023 +0200 Commit: Paris Oplopoios CommitDate: Tue Nov 21 14:24:42 2023 +0100 chart2: Match chart background color with DOCCOLOR in Calc Chart background color would be hardcoded to white which meant newly inserted charts would have a different background color in Calc (in other components, the background color is later set to transparent) Change-Id: I6ea55389f195155a96c4c8dcc94a902b2a862178 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159751 Tested-by: Jenkins Reviewed-by: Paris Oplopoios diff --git a/chart2/source/model/main/PageBackground.cxx b/chart2/source/model/main/PageBackground.cxx index 592c24d3e6a2..c866bdbb3f4a 100644 --- a/chart2/source/model/main/PageBackground.cxx +++ b/chart2/source/model/main/PageBackground.cxx @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include @@ -48,7 +50,13 @@ const ::chart::tPropertyValueMap& StaticPageBackgroundDefaults() ::chart::FillProperties::AddDefaultsToMap( aTmp ); // override other defaults -::chart::PropertyHelper::setPropertyValue< sal_Int32 >( aTmp, ::chart::FillProperties::PROP_FILL_COLOR, 0xff ); +Color aDocColor = COL_WHITE; +if (SfxViewShell::Current()) { +aDocColor = SfxViewShell::Current()->GetColorConfigColor(svtools::DOCCOLOR); +} else { +SAL_WARN("chart2", "SfxViewShell::Current() returned nullptr"); +} +::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::FillProperties::PROP_FILL_COLOR, aDocColor ); ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE ); return aTmp; }();
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - chart2/source
chart2/source/model/main/PageBackground.cxx | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) New commits: commit e8c50822c459504659bf6eb846364ec981e22e14 Author: offtkp AuthorDate: Mon Nov 20 22:58:20 2023 +0200 Commit: Andras Timar CommitDate: Tue Nov 21 13:50:50 2023 +0100 chart2: Match chart background color with DOCCOLOR in Calc Change-Id: I6ea55389f195155a96c4c8dcc94a902b2a862178 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159744 Tested-by: Jenkins CollaboraOffice Reviewed-by: Andras Timar diff --git a/chart2/source/model/main/PageBackground.cxx b/chart2/source/model/main/PageBackground.cxx index 561b297aba78..776e751b2934 100644 --- a/chart2/source/model/main/PageBackground.cxx +++ b/chart2/source/model/main/PageBackground.cxx @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include @@ -54,7 +56,13 @@ private: ::chart::FillProperties::AddDefaultsToMap( rOutMap ); // override other defaults -::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xff ); +Color aDocColor = COL_WHITE; +if (SfxViewShell::Current()) { +aDocColor = SfxViewShell::Current()->GetColorConfigColor(svtools::DOCCOLOR); +} else { +SAL_WARN("chart2", "SfxViewShell::Current() returned nullptr"); +} +::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, aDocColor ); ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE ); } };
[Libreoffice-commits] core.git: sc/source
sc/source/core/data/colorscale.cxx |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit ceef5a9c39be2b2b16c800f1d92a6b7bf968d8ed Author: offtkp AuthorDate: Wed Nov 1 19:14:44 2023 +0200 Commit: Paris Oplopoios CommitDate: Wed Nov 1 21:54:03 2023 +0100 sc: Fix conditional formatting icon set order for smilies The order of these icon sets was not consistent with other icon sets (traffic lights, flags, circles) and Excel Change-Id: I5cbc2ff96118530420341f6994310f946717e0d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158703 Reviewed-by: Paris Oplopoios Tested-by: Jenkins diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index b205d35adb6e..eff6d050b13b 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -1337,11 +1337,11 @@ constexpr OUString a3Flags[] = { }; constexpr OUString a3Smilies[] = { -BMP_ICON_SET_POSITIVE_YELLOW_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE +BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_POSITIVE_YELLOW_SMILIE }; constexpr OUString a3ColorSmilies[] = { -BMP_ICON_SET_POSITIVE_GREEN_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_RED_SMILIE +BMP_ICON_SET_NEGATIVE_RED_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_POSITIVE_GREEN_SMILIE }; constexpr OUString a3Stars[] = {
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/source
sc/source/core/data/fillinfo.cxx | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) New commits: commit cb53d9731a8dcb51596b4181b8fefd462854d984 Author: offtkp AuthorDate: Wed Nov 1 18:52:35 2023 +0200 Commit: Paris Oplopoios CommitDate: Wed Nov 1 20:28:46 2023 +0100 sc: Don't end handleConditionalFormat early handleConditionalFormat would exit the conditional format searching loop which meant that cells with overlapping conditional formatting rules would not get properly rendered Change-Id: I98664c758cc2c8f844994e6dcecdc57df2213a01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158767 Reviewed-by: Michael Meeks Tested-by: Jenkins CollaboraOffice diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 7c95701e9705..2dc9d5960128 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -287,7 +287,6 @@ bool handleConditionalFormat(ScConditionalFormatList& rCondFormList, const ScCon ScCellInfo* pInfo, ScTableInfo* pTableInfo, ScStyleSheetPool* pStlPool, const ScAddress& rAddr, bool& bHidden, bool& bHideFormula, bool bTabProtect) { -bool bFound = false; bool bAnyCondition = false; for(const auto& rCondFormat : rCondFormats) { @@ -317,33 +316,28 @@ bool handleConditionalFormat(ScConditionalFormatList& rCondFormList, const ScCon bHideFormula = pProtAttr->GetHideFormula(); } -bFound = true; - } // if style is not there, treat like no condition } -if(aData.mxColorScale) +if(aData.mxColorScale && !pInfo->mxColorScale) { pInfo->mxColorScale = aData.mxColorScale; -bFound = true; } -if(aData.pDataBar) +if(aData.pDataBar && !pInfo->pDataBar) { pInfo->pDataBar = aData.pDataBar.get(); pTableInfo->addDataBarInfo(std::move(aData.pDataBar)); -bFound = true; } -if(aData.pIconSet) +if(aData.pIconSet && !pInfo->pIconSet) { pInfo->pIconSet = aData.pIconSet.get(); pTableInfo->addIconSetInfo(std::move(aData.pIconSet)); -bFound = true; } -if (bFound) +if (pInfo->mxColorScale && pInfo->pIconSet && pInfo->pDataBar) break; }
[Libreoffice-commits] core.git: sc/source
sc/source/core/data/fillinfo.cxx | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) New commits: commit edbc3a09edcf58a4738b4648811a065f3f55bc7c Author: offtkp AuthorDate: Wed Nov 1 18:52:35 2023 +0200 Commit: Paris Oplopoios CommitDate: Wed Nov 1 20:17:01 2023 +0100 sc: Don't end handleConditionalFormat early handleConditionalFormat would exit the conditional format searching loop which meant that cells with overlapping conditional formatting rules would not get properly rendered Change-Id: I98664c758cc2c8f844994e6dcecdc57df2213a01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158702 Tested-by: Jenkins Reviewed-by: Paris Oplopoios diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 2e268239b048..9a8675fcd190 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -287,7 +287,6 @@ bool handleConditionalFormat(ScConditionalFormatList& rCondFormList, const ScCon ScCellInfo* pInfo, ScTableInfo* pTableInfo, ScStyleSheetPool* pStlPool, const ScAddress& rAddr, bool& bHidden, bool& bHideFormula, bool bTabProtect) { -bool bFound = false; bool bAnyCondition = false; for(const auto& rCondFormat : rCondFormats) { @@ -317,33 +316,28 @@ bool handleConditionalFormat(ScConditionalFormatList& rCondFormList, const ScCon bHideFormula = pProtAttr->GetHideFormula(); } -bFound = true; - } // if style is not there, treat like no condition } -if(aData.mxColorScale) +if(aData.mxColorScale && !pInfo->mxColorScale) { pInfo->mxColorScale = aData.mxColorScale; -bFound = true; } -if(aData.pDataBar) +if(aData.pDataBar && !pInfo->pDataBar) { pInfo->pDataBar = aData.pDataBar.get(); pTableInfo->addDataBarInfo(std::move(aData.pDataBar)); -bFound = true; } -if(aData.pIconSet) +if(aData.pIconSet && !pInfo->pIconSet) { pInfo->pIconSet = aData.pIconSet.get(); pTableInfo->addIconSetInfo(std::move(aData.pIconSet)); -bFound = true; } -if (bFound) +if (pInfo->mxColorScale && pInfo->pIconSet && pInfo->pDataBar) break; }
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/source
sc/source/core/data/colorscale.cxx |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit d66079dfec125e79d9c367cba90b04ee32c07cb3 Author: offtkp AuthorDate: Wed Nov 1 19:14:44 2023 +0200 Commit: Paris Oplopoios CommitDate: Wed Nov 1 19:43:56 2023 +0100 sc: Fix conditional formatting icon set order for smilies The order of these icon sets was not consistent with other icon sets (traffic lights, flags, circles) and Excel Change-Id: I5cbc2ff96118530420341f6994310f946717e0d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158771 Tested-by: Jenkins CollaboraOffice Reviewed-by: Paris Oplopoios diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 4e61dbdbc228..97cc50f73829 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -1337,11 +1337,11 @@ constexpr rtl::OUStringConstExpr a3Flags[] = { }; constexpr rtl::OUStringConstExpr a3Smilies[] = { -BMP_ICON_SET_POSITIVE_YELLOW_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE +BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_POSITIVE_YELLOW_SMILIE }; constexpr rtl::OUStringConstExpr a3ColorSmilies[] = { -BMP_ICON_SET_POSITIVE_GREEN_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_RED_SMILIE +BMP_ICON_SET_NEGATIVE_RED_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_POSITIVE_GREEN_SMILIE }; constexpr rtl::OUStringConstExpr a3Stars[] = {
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - officecfg/registry sc/source sc/uiconfig
officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu | 15 +- sc/source/ui/condformat/condformateasydlg.cxx | 24 -- sc/uiconfig/scalc/popupmenu/conditional_easy.xml |1 3 files changed, 35 insertions(+), 5 deletions(-) New commits: commit 894db9a211bee1aa68128eb3e2cc7b4b074f Author: offtkp AuthorDate: Mon Oct 30 14:28:12 2023 +0200 Commit: Paris Oplopoios CommitDate: Wed Nov 1 16:42:13 2023 +0100 tdf#157930 Add Contains Text rule to easy conditional format dialog Contains Text is another commonly used conditional formatting rule that could be of use here Change-Id: I67a3f711c57f9917be26fa21badd2f5a0d133747 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158657 Tested-by: Jenkins Reviewed-by: Paris Oplopoios (cherry picked from commit 4017a12c4b62dc0a97886bacfee11e5f28dde6cc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158692 Tested-by: Jenkins CollaboraOffice diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu index 815151845c14..044e1359ebe2 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu @@ -660,7 +660,7 @@ - Conditional Formatting: Condition Less Than + Conditional Formatting: Less Than Less than... @@ -671,7 +671,7 @@ - Conditional Formatting: Condition Equals + Conditional Formatting: Equals Equals... @@ -691,6 +691,17 @@ 1 + + + Conditional Formatting: Contains Text + + + Containing text... + + + 1 + + Conditional Formatting: More Rules diff --git a/sc/source/ui/condformat/condformateasydlg.cxx b/sc/source/ui/condformat/condformateasydlg.cxx index d707b7c9f88d..1fed832b9811 100644 --- a/sc/source/ui/condformat/condformateasydlg.cxx +++ b/sc/source/ui/condformat/condformateasydlg.cxx @@ -208,9 +208,27 @@ IMPL_LINK(ConditionalFormatEasyDialog, ButtonPressed, weld::Button&, rButton, vo if ( == mxButtonOk.get()) { std::unique_ptr pFormat(new ScConditionalFormat(0, mpDocument)); + +OUString sExpression1 = mxNumberEntry->get_text(); +OUString sExpression2 = mxNumberEntry2->get_text(); + +switch (meMode) +{ +case ScConditionMode::ContainsText: +case ScConditionMode::NotContainsText: +case ScConditionMode::BeginsWith: +case ScConditionMode::EndsWith: +sExpression1 = "\"" + sExpression1 + "\""; +sExpression2 = "\"" + sExpression2 + "\""; +break; +default: +break; +} + ScFormatEntry* pEntry -= new ScCondFormatEntry(meMode, mxNumberEntry->get_text(), mxNumberEntry2->get_text(), -*mpDocument, maPosition, mxStyles->get_active_text()); += new ScCondFormatEntry(meMode, sExpression1, sExpression2, *mpDocument, maPosition, +mxStyles->get_active_text()); + ScRangeList aRange; ScRefFlags nFlags = aRange.Parse(mxRangeEntry->GetText(), mpViewData->GetDocument(), @@ -229,4 +247,4 @@ IMPL_LINK(ConditionalFormatEasyDialog, ButtonPressed, weld::Button&, rButton, vo m_xDialog->response(RET_CANCEL); } -} // namespace sc \ No newline at end of file +} // namespace sc diff --git a/sc/uiconfig/scalc/popupmenu/conditional_easy.xml b/sc/uiconfig/scalc/popupmenu/conditional_easy.xml index 3346fa9441bb..70bd311d4480 100644 --- a/sc/uiconfig/scalc/popupmenu/conditional_easy.xml +++ b/sc/uiconfig/scalc/popupmenu/conditional_easy.xml @@ -12,6 +12,7 @@ +
[Libreoffice-commits] core.git: officecfg/registry sc/source sc/uiconfig
officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu | 15 +- sc/source/ui/condformat/condformateasydlg.cxx | 24 -- sc/uiconfig/scalc/popupmenu/conditional_easy.xml |1 3 files changed, 35 insertions(+), 5 deletions(-) New commits: commit c8da023efe26efcb166c3525ca73fe62f26e154c Author: offtkp AuthorDate: Mon Oct 30 14:28:12 2023 +0200 Commit: Paris Oplopoios CommitDate: Tue Oct 31 14:23:05 2023 +0100 tdf#157930 Add Contains Text rule to easy conditional format dialog Contains Text is another commonly used conditional formatting rule that could be of use here Change-Id: I67a3f711c57f9917be26fa21badd2f5a0d133747 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158657 Tested-by: Jenkins Reviewed-by: Paris Oplopoios diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu index 7bd5215d627e..fe726492ffb4 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu @@ -666,7 +666,7 @@ - Conditional Formatting: Condition Less Than + Conditional Formatting: Less Than Less than... @@ -677,7 +677,7 @@ - Conditional Formatting: Condition Equals + Conditional Formatting: Equals Equals... @@ -697,6 +697,17 @@ 1 + + + Conditional Formatting: Contains Text + + + Containing text... + + + 1 + + Conditional Formatting: More Rules diff --git a/sc/source/ui/condformat/condformateasydlg.cxx b/sc/source/ui/condformat/condformateasydlg.cxx index 0fee5ea15b36..6ecf98e87e21 100644 --- a/sc/source/ui/condformat/condformateasydlg.cxx +++ b/sc/source/ui/condformat/condformateasydlg.cxx @@ -208,9 +208,27 @@ IMPL_LINK(ConditionalFormatEasyDialog, ButtonPressed, weld::Button&, rButton, vo if ( == mxButtonOk.get()) { std::unique_ptr pFormat(new ScConditionalFormat(0, mpDocument)); + +OUString sExpression1 = mxNumberEntry->get_text(); +OUString sExpression2 = mxNumberEntry2->get_text(); + +switch (meMode) +{ +case ScConditionMode::ContainsText: +case ScConditionMode::NotContainsText: +case ScConditionMode::BeginsWith: +case ScConditionMode::EndsWith: +sExpression1 = "\"" + sExpression1 + "\""; +sExpression2 = "\"" + sExpression2 + "\""; +break; +default: +break; +} + ScFormatEntry* pEntry -= new ScCondFormatEntry(meMode, mxNumberEntry->get_text(), mxNumberEntry2->get_text(), -*mpDocument, maPosition, mxStyles->get_active_text()); += new ScCondFormatEntry(meMode, sExpression1, sExpression2, *mpDocument, maPosition, +mxStyles->get_active_text()); + ScRangeList aRange; ScRefFlags nFlags = aRange.Parse(mxRangeEntry->GetText(), mpViewData->GetDocument(), @@ -229,4 +247,4 @@ IMPL_LINK(ConditionalFormatEasyDialog, ButtonPressed, weld::Button&, rButton, vo m_xDialog->response(RET_CANCEL); } -} // namespace sc \ No newline at end of file +} // namespace sc diff --git a/sc/uiconfig/scalc/popupmenu/conditional_easy.xml b/sc/uiconfig/scalc/popupmenu/conditional_easy.xml index 3346fa9441bb..70bd311d4480 100644 --- a/sc/uiconfig/scalc/popupmenu/conditional_easy.xml +++ b/sc/uiconfig/scalc/popupmenu/conditional_easy.xml @@ -12,6 +12,7 @@ +
[Libreoffice-commits] core.git: vcl/qa
vcl/qa/cppunit/animationrenderer.cxx | 45 +++ 1 file changed, 15 insertions(+), 30 deletions(-) New commits: commit 6d423ed9bb89da15bfd9ac3555cb01696458fa71 Author: offtkp AuthorDate: Sun Oct 29 13:12:02 2023 +0200 Commit: Paris Oplopoios CommitDate: Sun Oct 29 22:18:05 2023 +0100 CppunitTest_vcl_animate: use CPPUNIT_TEST_FIXTURE CPPUNIT_TEST_FIXTURE is easier to write tests for and separate if needed Change-Id: I2c478205847e4d15c0f8d65d498dd8d82079fa5d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158616 Tested-by: Jenkins Reviewed-by: Paris Oplopoios diff --git a/vcl/qa/cppunit/animationrenderer.cxx b/vcl/qa/cppunit/animationrenderer.cxx index 86ad06c47941..93f80970f2ea 100644 --- a/vcl/qa/cppunit/animationrenderer.cxx +++ b/vcl/qa/cppunit/animationrenderer.cxx @@ -31,6 +31,18 @@ public: void ReleaseGraphics(bool) override {} bool UsePolyPolygonForComplexGradient() override { return false; } }; + +Animation createAnimation() +{ +Animation aAnimation; + +aAnimation.Insert( +AnimationFrame(BitmapEx(Size(3, 4), vcl::PixelFormat::N24_BPP), Point(0, 0), Size(10, 10))); +aAnimation.Insert( +AnimationFrame(BitmapEx(Size(3, 3), vcl::PixelFormat::N24_BPP), Point(0, 0), Size(10, 10))); + +return aAnimation; +} } class VclAnimationRendererTest : public test::BootstrapFixture @@ -40,22 +52,9 @@ public: : BootstrapFixture(true, false) { } - -void testMatching(); -void testDrawToPos(); -void testGetPosSizeWindow(); - -CPPUNIT_TEST_SUITE(VclAnimationRendererTest); -CPPUNIT_TEST(testMatching); -CPPUNIT_TEST(testDrawToPos); -CPPUNIT_TEST(testGetPosSizeWindow); -CPPUNIT_TEST_SUITE_END(); - -private: -Animation createAnimation(); }; -void VclAnimationRendererTest::testMatching() +CPPUNIT_TEST_FIXTURE(VclAnimationRendererTest, testMatching) { Animation aTestAnim = createAnimation(); ScopedVclPtrInstance pTestRC; @@ -69,7 +68,7 @@ void VclAnimationRendererTest::testMatching() CPPUNIT_ASSERT(pAnimationRenderer->matches(pTestRC, 0)); } -void VclAnimationRendererTest::testDrawToPos() +CPPUNIT_TEST_FIXTURE(VclAnimationRendererTest, testDrawToPos) { Animation aTestAnim = createAnimation(); ScopedVclPtrInstance pTestRC; @@ -84,7 +83,7 @@ void VclAnimationRendererTest::testDrawToPos() CPPUNIT_ASSERT_EQUAL(Size(1, 1), pTestRC->GetOutputSizePixel()); } -void VclAnimationRendererTest::testGetPosSizeWindow() +CPPUNIT_TEST_FIXTURE(VclAnimationRendererTest, testGetPosSizeWindow) { Animation aTestAnim = createAnimation(); ScopedVclPtrInstance pTestRC; @@ -102,20 +101,6 @@ void VclAnimationRendererTest::testGetPosSizeWindow() CPPUNIT_ASSERT_EQUAL(Size(10, 10), aSize); } -Animation VclAnimationRendererTest::createAnimation() -{ -Animation aAnimation; - -aAnimation.Insert( -AnimationFrame(BitmapEx(Size(3, 4), vcl::PixelFormat::N24_BPP), Point(0, 0), Size(10, 10))); -aAnimation.Insert( -AnimationFrame(BitmapEx(Size(3, 3), vcl::PixelFormat::N24_BPP), Point(0, 0), Size(10, 10))); - -return aAnimation; -} - -CPPUNIT_TEST_SUITE_REGISTRATION(VclAnimationRendererTest); - CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
[Libreoffice-commits] core.git: offapi/com
offapi/com/sun/star/text/ContentControl.idl |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 2dd45d5d81afdd5c550b9929dde42ac04d9dd176 Author: offtkp AuthorDate: Tue Jan 3 15:26:51 2023 +0200 Commit: Miklos Vajna CommitDate: Mon Jan 9 09:01:55 2023 + Fix wrong version in comment Change-Id: I4185b019b8dbce7de9bf853c0416fd43201b1f60 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144987 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/offapi/com/sun/star/text/ContentControl.idl b/offapi/com/sun/star/text/ContentControl.idl index c2fe46757656..34beff3cb127 100644 --- a/offapi/com/sun/star/text/ContentControl.idl +++ b/offapi/com/sun/star/text/ContentControl.idl @@ -94,7 +94,7 @@ service ContentControl /** The appearance: just remembered. -@since LibreOffice 7.5 +@since LibreOffice 7.6 */ [optional, property] string Appearance;
[Libreoffice-commits] core.git: sw/source
sw/source/ui/dialog/swdlgfact.hxx |1 + 1 file changed, 1 insertion(+) New commits: commit 5e5631a8f6a9b14ab7f088f61f4780948c41761d Author: offtkp AuthorDate: Fri Jan 6 22:59:35 2023 +0200 Commit: Miklos Vajna CommitDate: Mon Jan 9 09:01:33 2023 + Add comment for new class Change-Id: Icb20bfc68183bd22d1d83985bf3932fd2918b074 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145166 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 929063a2dab5..55aac3c8c858 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -153,6 +153,7 @@ public: virtual void FillOptions( SwAsciiOptions& rOptions ) override; }; +/// Interface implementation for the insert -> fields -> page number wizard dialog class AbstractSwPageNumberDlg_Impl : public AbstractSwPageNumberDlg { std::shared_ptr m_xDlg;
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - desktop/source officecfg/registry sfx2/source sw/inc sw/Library_swui.mk sw/sdi sw/source sw/uiconfig sw/UIConfig_swriter.mk vcl/inc
desktop/source/lib/init.cxx |1 officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu |5 sfx2/source/control/unoctitm.cxx|1 sw/Library_swui.mk |1 sw/UIConfig_swriter.mk |1 sw/inc/cmdid.h |1 sw/inc/strings.hrc |1 sw/inc/swabstdlg.hxx| 11 sw/inc/swundo.hxx |1 sw/sdi/_textsh.sdi |7 sw/sdi/swriter.sdi | 18 sw/source/core/undo/undobj.cxx |3 sw/source/ui/dialog/swdlgfact.cxx | 26 + sw/source/ui/dialog/swdlgfact.hxx | 16 sw/source/ui/misc/pagenumberdlg.cxx | 92 sw/source/uibase/inc/pagenumberdlg.hxx | 51 ++ sw/source/uibase/shells/textfld.cxx | 81 +++ sw/uiconfig/swriter/menubar/menubar.xml |2 sw/uiconfig/swriter/ui/pagenumberdlg.ui | 222 ++ vcl/inc/jsdialog/jsdialogbuilder.hxx|2 vcl/jsdialog/enabled.cxx|1 vcl/jsdialog/jsdialogbuilder.cxx| 12 22 files changed, 555 insertions(+), 1 deletion(-) New commits: commit 19820c3db7a704e22f5db72b91bf10d85cc48897 Author: offtkp AuthorDate: Wed Dec 21 14:29:59 2022 +0200 Commit: Miklos Vajna CommitDate: Mon Jan 9 08:59:01 2023 + tdf#86630 sw: Add one-step page number insertion wizard Add a one-step wizard for easy insertion of the page number to the header/footer. Change-Id: Idb33c92d594e04d9256460fe414e4b10e5166af5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144998 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 0c3be4b25743..edaf0ad75477 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3337,6 +3337,7 @@ static void doc_iniUnoCommands () OUString(".uno:InsertAuthoritiesEntry"), OUString(".uno:InsertMultiIndex"), OUString(".uno:InsertField"), +OUString(".uno:PageNumberWizard"), OUString(".uno:InsertPageNumberField"), OUString(".uno:InsertPageCountField"), OUString(".uno:InsertDateField"), diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu index 9247374da3f6..59a66a8382a8 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu @@ -1003,6 +1003,11 @@ 1 + + + ~Page Number... + + ~Page Number diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 868d7749f32b..30538c614772 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1091,6 +1091,7 @@ static void InterceptLOKStateChangeEvent(sal_uInt16 nSID, SfxViewFrame* pViewFra aEvent.FeatureURL.Path == "InsertAuthoritiesEntry" || aEvent.FeatureURL.Path == "InsertMultiIndex" || aEvent.FeatureURL.Path == "InsertField" || + aEvent.FeatureURL.Path == "PageNumberWizard" || aEvent.FeatureURL.Path == "InsertPageNumberField" || aEvent.FeatureURL.Path == "InsertPageCountField" || aEvent.FeatureURL.Path == "InsertDateField" || diff --git a/sw/Library_swui.mk b/sw/Library_swui.mk index 532617295808..c34451317dd7 100644 --- a/sw/Library_swui.mk +++ b/sw/Library_swui.mk @@ -141,6 +141,7 @@ $(eval $(call gb_Library_add_exception_objects,swui,\ sw/source/ui/misc/bookmark \ sw/source/ui/misc/contentcontroldlg \ sw/source/ui/misc/contentcontrollistitemdlg \ +sw/source/ui/misc/pagenumberdlg \ sw/source/ui/misc/docfnote \ sw/source/ui/misc/glosbib \ sw/source/ui/misc/glossary \ diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index 22b91c7f57c9..b5fab9613f66 100644 --- a/sw/UIConfig_swriter.mk +++ b/sw/UIConfig_swriter.mk @@ -243,6 +243,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\ sw/uiconfig/swriter/ui/notebookbar_online \ sw/uiconfig/swriter/ui/pagecolumncontrol \ sw/uiconfig/swriter/ui/pagemargincontrol \ +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/strings.hrc |1 sw/qa/extras/ooxmlexport/data/tdf125338.docm |binary sw/qa/extras/ooxmlexport/ooxmlexport9.cxx| 10 ++- sw/source/filter/ww8/docxexport.cxx |3 +- sw/source/filter/ww8/docxexportfilter.cxx| 35 +++ 5 files changed, 43 insertions(+), 6 deletions(-) New commits: commit 39a09050d309de7ebcf4630cc12cdffa2ca4a654 Author: offtkp AuthorDate: Wed Dec 14 22:21:34 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Sat Jan 7 16:05:58 2023 + tdf#125338 Do not export macros when saving as .docx Docx files that have macros should be saved as .docm. Now displays a warning that macros won't be saved if exporting a .docm as a .docx and doesn't export them. Change-Id: I178855baa6c0a7d32fd9b00c83a817230b33a1a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144197 Tested-by: Jenkins Reviewed-by: Justin Luth (cherry picked from commit cbca5617387aaa39c9ee86272166bb3df7874b25) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144811 Tested-by: Jenkins CollaboraOffice Reviewed-by: Tomaž Vajngerl diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index b4b03968a1eb..59fe112fecba 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -331,6 +331,7 @@ #define STR_SOUTH NC_("STR_SOUTH", "South") #define STR_SUM NC_("STR_SUM", "Sum") #define STR_INVALID_AUTOFORMAT_NAME NC_("STR_INVALID_AUTOFORMAT_NAME", "You have entered an invalid name.\nThe desired AutoFormat could not be created. \nTry again using a different name.") +#define STR_CANT_SAVE_MACROSNC_("STR_CANT_SAVE_MACROS", "This document has macros, but macros will not be saved in this file format.") #define STR_NUMERIC NC_("STR_NUMERIC", "Numeric") #define STR_ROW NC_("STR_ROW", "Rows") #define STR_COL NC_("STR_COL", "Column") diff --git a/sw/qa/extras/ooxmlexport/data/tdf125338.docm b/sw/qa/extras/ooxmlexport/data/tdf125338.docm new file mode 100644 index ..44e943531d30 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf125338.docm differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 99d4b0112a60..1b97e846f1ef 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -139,7 +139,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf109063, "tdf109063.docx") CPPUNIT_ASSERT_EQUAL(0, getShapes()); } -CPPUNIT_TEST_FIXTURE(Test, testTdf108269) +CPPUNIT_TEST_FIXTURE(DocmTest, testTdf108269) { loadAndReload("tdf108269.docm"); uno::Reference xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); @@ -149,6 +149,14 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf108269) CPPUNIT_ASSERT(xNameAccess->hasByName("word/vbaData.xml")); } +CPPUNIT_TEST_FIXTURE(Test, testTdf125338) +{ +loadAndSave("tdf125338.docm"); +uno::Reference xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); +// docm files should not retain macros when saved as docx +CPPUNIT_ASSERT(!xNameAccess->hasByName("word/vbaProject.bin")); +} + DECLARE_OOXMLEXPORT_TEST(testTdf92045, "tdf92045.docx") { // This was true, resulted in setting the blinking font effect. diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 74d081baf244..d5bc243d5c2e 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -538,7 +538,8 @@ ErrCode DocxExport::ExportDocument_Impl() WriteEmbeddings(); -WriteVBA(); +if (m_bDocm) +WriteVBA(); m_aLinkedTextboxesHelper.clear(); //final cleanup m_pStyles.reset(); diff --git a/sw/source/filter/ww8/docxexportfilter.cxx b/sw/source/filter/ww8/docxexportfilter.cxx index 08308ca9398c..5ffd32f4c25b 100644 --- a/sw/source/filter/ww8/docxexportfilter.cxx +++ b/sw/source/filter/ww8/docxexportfilter.cxx @@ -63,6 +63,37 @@ bool DocxExportFilter::exportDocument() pViewShell->GetPostItMgr()->UpdateDataOnActiveSidebarWin(); } +OUString aFilterName; +auto& rMediaDescriptor = getMediaDescriptor(); +rMediaDescriptor[utl::MediaDescriptor::PROP_FILTERNAME] >>= aFilterName; +bool bDocm = aFilterName.endsWith("VBA"); + +if (!bDocm) +{ +// Check whether application is in headless mode +if (!Application::IsHeadlessModeEnabled()) +{ +uno::Reference xStorageBasedDocument( +pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY); +if (xStorageBasedDocument.is()) +{ +uno::Reference xDocumentStorage = +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sc/source
sc/source/filter/excel/excrecds.cxx | 54 ++ sc/source/filter/inc/autofilterbuffer.hxx |1 sc/source/filter/inc/excrecds.hxx |5 ++ sc/source/filter/oox/autofilterbuffer.cxx | 18 +- 4 files changed, 70 insertions(+), 8 deletions(-) New commits: commit 12b76270cecfebe90eeb991f4046b2925236a4b5 Author: offtkp AuthorDate: Fri Nov 25 15:16:53 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Sat Jan 7 12:07:53 2023 + tdf#144786 Implement XML_hiddenButton functionality Now hides autofilter button when there's an XML_hiddenButton=true or a XML_showButton=false attribute Change-Id: I911ef23fb5e4feff8c7de0ec154bff871a29f2e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143300 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144328 Tested-by: Jenkins CollaboraOffice diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index 570167b8014b..14ff3aff85b7 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -48,6 +48,8 @@ #include #include +#include +#include using namespace ::oox; @@ -604,11 +606,12 @@ void ExcFilterCondition::SaveText( XclExpStream& rStrm ) } } -XclExpAutofilter::XclExpAutofilter( const XclExpRoot& rRoot, sal_uInt16 nC ) : +XclExpAutofilter::XclExpAutofilter( const XclExpRoot& rRoot, sal_uInt16 nC, bool bIsEmpty ) : XclExpRecord( EXC_ID_AUTOFILTER, 24 ), XclExpRoot( rRoot ), -meType(FilterCondition), +meType(bIsEmpty ? Empty : FilterCondition), nCol( nC ), +bIsButtonHidden( false ), nFlags( 0 ), bHasBlankValue( false ) { @@ -819,10 +822,13 @@ void XclExpAutofilter::SaveXml( XclExpXmlStream& rStrm ) sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); +std::optional sHiddenButtonValue; +if (bIsButtonHidden) +sHiddenButtonValue = "1"; + rWorksheet->startElement( XML_filterColumn, -XML_colId, OString::number(nCol) -// OOXTODO: XML_hiddenButton, AutoFilter12 fHideArrow? -// OOXTODO: XML_showButton +XML_colId, OString::number(nCol), +XML_hiddenButton, sHiddenButtonValue ); switch (meType) @@ -912,6 +918,8 @@ void XclExpAutofilter::SaveXml( XclExpXmlStream& rStrm ) rWorksheet->endElement(XML_filters); } break; +// Used for constructing an empty filterColumn element for exporting the XML_hiddenButton attribute +case Empty: break; } rWorksheet->endElement( XML_filterColumn ); } @@ -972,6 +980,8 @@ ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const boolbContLoop = true; boolbHasOr = false; SCCOLROW nFirstField = aParam.GetEntry( 0 ).nField; +ScDocument& rDoc = rRoot.GetDoc(); +SCROW nRow = aRange.aStart.Row(); // create AUTOFILTER records for filtered columns for( SCSIZE nEntry = 0; !bConflict && bContLoop && (nEntry < aParam.GetEntryCount()); nEntry++ ) @@ -981,7 +991,11 @@ ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const bContLoop = rEntry.bDoQuery; if( bContLoop ) { -XclExpAutofilter* pFilter = GetByCol( static_cast(rEntry.nField) - aRange.aStart.Col() ); +SCCOL nCol = static_cast( rEntry.nField ) - aRange.aStart.Col(); +auto nFlag = rDoc.GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG )->GetValue(); +bool bIsButtonHidden = !( nFlag & ScMF::Auto ); +XclExpAutofilter* pFilter = GetByCol( nCol ); +pFilter->SetButtonHidden( bIsButtonHidden ); if( nEntry > 0 ) bHasOr |= (rEntry.eConnect == SC_OR); @@ -995,6 +1009,34 @@ ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const } } +sal_uInt16 nColId = 0; +for ( auto nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); nCol++, nColId++ ) +{ +auto nFlag = rDoc.GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG )->GetValue(); +bool bIsButtonHidden = !( nFlag & ScMF::Auto ); +if ( bIsButtonHidden ) +{ +// Create filter column with hiddenButton=1 attribute if it doesn't exist +XclExpAutofilterRef xFilter; +bool bFilterFound = false; +for( size_t nPos = 0, nSize = maFilterList.GetSize(); nPos < nSize; ++nPos ) +{ +xFilter = maFilterList.GetRecord( nPos ); +if( xFilter->GetCol() == static_cast(nCol) ) +{ +bFilterFound = true; +break; +} +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/qa sw/source
sw/qa/uibase/wrtsh/wrtsh.cxx |7 +++ sw/source/core/txtnode/attrcontentcontrol.cxx |1 - sw/source/uibase/wrtsh/wrtsh1.cxx | 14 ++ sw/source/uibase/wrtsh/wrtsh3.cxx |4 4 files changed, 21 insertions(+), 5 deletions(-) New commits: commit 06ff1602842197f045f953fd49e441f8f058d094 Author: offtkp AuthorDate: Mon Dec 12 13:03:43 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Fri Jan 6 14:59:23 2023 + docx: Do not remove showingPlcHdr until edit When a placeholder has the showingPlcHdr attribute, the entire text is selected upon click. This is no longer removed by selecting it once but once the text has been edited. Change-Id: I9a4d68289c8b95ab0098e55a5fa6edb1606c7df2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143985 Tested-by: Jenkins Reviewed-by: Miklos Vajna (cherry picked from commit 618cef756b87f9816d0dcbe04af163ccd06a986e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144307 Tested-by: Jenkins CollaboraOffice Reviewed-by: Tomaž Vajngerl diff --git a/sw/qa/uibase/wrtsh/wrtsh.cxx b/sw/qa/uibase/wrtsh/wrtsh.cxx index cbc31237d893..43fb355fa59b 100644 --- a/sw/qa/uibase/wrtsh/wrtsh.cxx +++ b/sw/qa/uibase/wrtsh/wrtsh.cxx @@ -387,6 +387,13 @@ CPPUNIT_TEST_FIXTURE(Test, testInsertPlainTextContentControl) // Without the accompanying fix in place, this test would have failed, there was no special // handling for plain text content controls. CPPUNIT_ASSERT(pContentControl->GetPlainText()); + +CPPUNIT_ASSERT(pContentControl->GetShowingPlaceHolder()); +pWrtShell->GotoContentControl(rFormatContentControl); +CPPUNIT_ASSERT(pContentControl->GetShowingPlaceHolder()); +pWrtShell->Insert("Foo"); +// No longer showing placeholder text, as it has been changed +CPPUNIT_ASSERT(!pContentControl->GetShowingPlaceHolder()); } CPPUNIT_TEST_FIXTURE(Test, testInsertComboBoxContentControl) diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx index d324f52513a5..a54d4ef83429 100644 --- a/sw/source/core/txtnode/attrcontentcontrol.cxx +++ b/sw/source/core/txtnode/attrcontentcontrol.cxx @@ -754,7 +754,6 @@ void SwTextContentControl::Invalidate() pDocShell->GetWrtShell()->Push(); // visit the control in the text (which makes any necessary visual changes) -// NOTE: simply going to a control indicates cancelling ShowingPlaceHolder, unless bOnlyRefresh // NOTE: simply going to a checkbox causes a toggle, unless bOnlyRefresh auto& rFormatContentControl = static_cast(GetAttr()); pDocShell->GetWrtShell()->GotoContentControl(rFormatContentControl, /*bOnlyRefresh=*/true); diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index 4983bb3dc30f..c0112556e9d9 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -116,6 +116,7 @@ #include #include #include +#include using namespace sw::mark; using namespace com::sun::star; @@ -261,6 +262,19 @@ void SwWrtShell::Insert( const OUString ) bCallIns ? SwEditShell::Insert2( rStr, bDeleted ) : SwEditShell::Overwrite( rStr ); +// Check whether node is content control +SwTextContentControl* pTextContentControl = CursorInsideContentControl(); +if (pTextContentControl) +{ +std::shared_ptr pContentControl = +pTextContentControl->GetContentControl().GetContentControl(); +if (pContentControl) +{ +// Set showingPlcHdr to false as node has been edited +pContentControl->SetShowingPlaceHolder(false); +} +} + if( bStarted ) { EndUndo(); diff --git a/sw/source/uibase/wrtsh/wrtsh3.cxx b/sw/source/uibase/wrtsh/wrtsh3.cxx index aa170d1374a4..4e80bfc1e3d1 100644 --- a/sw/source/uibase/wrtsh/wrtsh3.cxx +++ b/sw/source/uibase/wrtsh/wrtsh3.cxx @@ -125,10 +125,6 @@ bool SwWrtShell::GotoContentControl(const SwFormatContentControl& rContentContro (this->*m_fnKillSel)(nullptr, false); bool bRet = SwCursorShell::GotoFormatContentControl(rContentControl); -// Assume that once the placeholder is selected, the content is no longer the placeholder. -if (!bOnlyRefresh && pContentControl) -pContentControl->SetShowingPlaceHolder(false); - if (bRet && pContentControl && pContentControl->GetCheckbox()) {
[Libreoffice-commits] core.git: desktop/source officecfg/registry sfx2/source sw/inc sw/Library_swui.mk sw/qa sw/sdi sw/source sw/uiconfig sw/UIConfig_swriter.mk vcl/inc vcl/jsdialog
desktop/source/lib/init.cxx |1 officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu |5 sfx2/source/control/unoctitm.cxx|1 sw/Library_swui.mk |1 sw/UIConfig_swriter.mk |1 sw/inc/cmdid.h |1 sw/inc/strings.hrc |1 sw/inc/swabstdlg.hxx| 11 sw/inc/swundo.hxx |1 sw/qa/extras/accessibility/basics.cxx |6 sw/sdi/_textsh.sdi |7 sw/sdi/swriter.sdi | 18 sw/source/core/undo/undobj.cxx |3 sw/source/ui/dialog/swdlgfact.cxx | 26 + sw/source/ui/dialog/swdlgfact.hxx | 16 sw/source/ui/misc/pagenumberdlg.cxx | 92 sw/source/uibase/inc/pagenumberdlg.hxx | 51 ++ sw/source/uibase/shells/textfld.cxx | 81 +++ sw/uiconfig/swriter/menubar/menubar.xml |2 sw/uiconfig/swriter/ui/pagenumberdlg.ui | 222 ++ vcl/inc/jsdialog/jsdialogbuilder.hxx|2 vcl/jsdialog/enabled.cxx|1 vcl/jsdialog/jsdialogbuilder.cxx| 12 23 files changed, 558 insertions(+), 4 deletions(-) New commits: commit c010b5d2b2cdb22f48ef9d2b9d1fdc6125e1fec2 Author: offtkp AuthorDate: Wed Dec 21 14:29:59 2022 +0200 Commit: Miklos Vajna CommitDate: Fri Jan 6 07:42:32 2023 + tdf#86630 sw: Add one-step page number insertion wizard Add a one-step wizard for easy insertion of the page number to the header/footer. Change-Id: Idb33c92d594e04d9256460fe414e4b10e5166af5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144683 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 8d191f7741da..133531034c15 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3336,6 +3336,7 @@ static void doc_iniUnoCommands () OUString(".uno:InsertAuthoritiesEntry"), OUString(".uno:InsertMultiIndex"), OUString(".uno:InsertField"), +OUString(".uno:PageNumberWizard"), OUString(".uno:InsertPageNumberField"), OUString(".uno:InsertPageCountField"), OUString(".uno:InsertDateField"), diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu index 2e234e51ecb3..5f9ca119eeba 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu @@ -1011,6 +1011,11 @@ 1 + + + ~Page Number... + + ~Page Number diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 76f4c9693dc0..20934ecf8f56 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1088,6 +1088,7 @@ static void InterceptLOKStateChangeEvent(sal_uInt16 nSID, SfxViewFrame* pViewFra aEvent.FeatureURL.Path == "InsertAuthoritiesEntry" || aEvent.FeatureURL.Path == "InsertMultiIndex" || aEvent.FeatureURL.Path == "InsertField" || + aEvent.FeatureURL.Path == "PageNumberWizard" || aEvent.FeatureURL.Path == "InsertPageNumberField" || aEvent.FeatureURL.Path == "InsertPageCountField" || aEvent.FeatureURL.Path == "InsertDateField" || diff --git a/sw/Library_swui.mk b/sw/Library_swui.mk index 7228dca1cd7e..81a21d003e19 100644 --- a/sw/Library_swui.mk +++ b/sw/Library_swui.mk @@ -143,6 +143,7 @@ $(eval $(call gb_Library_add_exception_objects,swui,\ sw/source/ui/misc/bookmark \ sw/source/ui/misc/contentcontroldlg \ sw/source/ui/misc/contentcontrollistitemdlg \ +sw/source/ui/misc/pagenumberdlg \ sw/source/ui/misc/docfnote \ sw/source/ui/misc/glosbib \ sw/source/ui/misc/glossary \ diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index d6e935e65c5b..867baf40ba88 100644 --- a/sw/UIConfig_swriter.mk +++ b/sw/UIConfig_swriter.mk @@ -253,6 +253,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\ sw/uiconfig/swriter/ui/notebookbar_online \ sw/uiconfig/swriter/ui/pagecolumncontrol \
[Libreoffice-commits] core.git: sc/source
sc/source/ui/unoobj/chart2uno.cxx |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit 9817a03e03988b86050c0fe0e4cd4cca476f172f Author: offtkp AuthorDate: Mon Dec 12 17:56:57 2022 +0200 Commit: Eike Rathke CommitDate: Thu Jan 5 22:12:15 2023 + Change variable name from rData to pData Change-Id: Ied27e34b35a22b1f2a7521fb58035170651b1ca3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144001 Tested-by: Jenkins Reviewed-by: Eike Rathke diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index e36fba94d71e..cc8f6a06dd31 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2583,14 +2583,14 @@ void ScChart2DataSequence::BuildDataCache() // Excel behavior: if the last row is the totals row, the data // is not added to the chart. If it's not the last row, the data // is added like normal. -const auto* rData = m_pDocument->GetDBAtCursor( +const auto* pData = m_pDocument->GetDBAtCursor( nCol, nRow, nTab, ScDBDataPortion::AREA ); -if (rData && rData->HasTotals()) +if (pData && pData->HasTotals()) { ScRange aTempRange; -rData->GetArea(aTempRange); +pData->GetArea(aTempRange); if (aTempRange.aEnd.Row() == nRow) { // Current row is totals row, skip
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - chart2/qa sc/source
chart2/qa/extras/chart2import.cxx | 29 + chart2/qa/extras/data/xlsx/barchart_totalsrow.xlsx |binary sc/source/ui/unoobj/chart2uno.cxx | 20 ++ 3 files changed, 49 insertions(+) New commits: commit 11e2dd533a6e6985ab1547630b62e772f6533946 Author: offtkp AuthorDate: Wed Nov 30 00:54:08 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Thu Jan 5 11:33:10 2023 + xlsx: Don't add cell data to chart data sequence if in totalsRow When importing data from a cell range to use in a chart, if a cell is in the totalsRow it is now ignored if it's the last row in the range. Change-Id: Ie8c79b995c4d46b361492e8f7687894e2640392f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143488 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit ad085990b8073a122ac5222e5220f8f1d6826dcf) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144306 Tested-by: Jenkins CollaboraOffice diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index f22f09a5d936..6710c86aba90 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -137,6 +137,7 @@ public: void testTdf121205(); void testFixedSizeBarChartVeryLongLabel(); void testAutomaticSizeBarChartVeryLongLabel(); +void testTotalsRowIgnored(); CPPUNIT_TEST_SUITE(Chart2ImportTest); CPPUNIT_TEST(Fdo60083); @@ -222,6 +223,7 @@ public: CPPUNIT_TEST(testTdf121205); CPPUNIT_TEST(testFixedSizeBarChartVeryLongLabel); CPPUNIT_TEST(testAutomaticSizeBarChartVeryLongLabel); +CPPUNIT_TEST(testTotalsRowIgnored); CPPUNIT_TEST_SUITE_END(); }; @@ -2254,6 +2256,33 @@ void Chart2ImportTest::testAutomaticSizeBarChartVeryLongLabel() CPPUNIT_ASSERT_EQUAL(sal_Int32(1192), xXAxis->getSize().Height); } +void Chart2ImportTest::testTotalsRowIgnored() +{ +load(u"/chart2/qa/extras/data/xlsx/", "barchart_totalsrow.xlsx"); +{ +uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); +CPPUNIT_ASSERT(xChartDoc.is()); + +Reference xDataSeq = +getDataSequenceFromDocByRole(xChartDoc, u"values-y"); +CPPUNIT_ASSERT(xDataSeq.is()); + +// Table data range is D2:D9 (8 rows) but because last row is totals row it is ignored +CPPUNIT_ASSERT_EQUAL(static_cast(7u), xDataSeq->getData().size()); +} +{ +uno::Reference xChartDoc = getChartDocFromSheet(1, mxComponent); +CPPUNIT_ASSERT(xChartDoc.is()); + +Reference xDataSeq = +getDataSequenceFromDocByRole(xChartDoc, u"values-y"); +CPPUNIT_ASSERT(xDataSeq.is()); + +// Table data range is D2:D10 (9 rows) and totals row isn't the last row so it's not ignored +CPPUNIT_ASSERT_EQUAL(static_cast(9u), xDataSeq->getData().size()); +} +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/data/xlsx/barchart_totalsrow.xlsx b/chart2/qa/extras/data/xlsx/barchart_totalsrow.xlsx new file mode 100644 index ..c87b2b3186ac Binary files /dev/null and b/chart2/qa/extras/data/xlsx/barchart_totalsrow.xlsx differ diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 54a88b749a77..797eb39b3bf8 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2521,6 +2521,26 @@ void ScChart2DataSequence::BuildDataCache() m_pDocument->InitColumnBlockPosition( hint, nTab, nCol ); for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow) { +if (nRow == aRange.aEnd.Row()) +{ +// Excel behavior: if the last row is the totals row, the data +// is not added to the chart. If it's not the last row, the data +// is added like normal. +const auto* rData = m_pDocument->GetDBAtCursor( +nCol, nRow, nTab, +ScDBDataPortion::AREA +); +if (rData && rData->HasTotals()) +{ +ScRange aTempRange; +rData->GetArea(aTempRange); +if (aTempRange.aEnd.Row() == nRow) +{ +// Current row is totals row, skip +break; +} +} +} bool bColHidden = m_pDocument->ColHidden(nCol, nTab, nullptr, ); bool bRowHidden = m_pDocument->RowHidden(nRow, nTab, nullptr, );
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - offapi/com oox/source sw/inc sw/qa sw/source writerfilter/source
offapi/com/sun/star/text/ContentControl.idl |6 oox/source/token/tokens.txt |1 sw/inc/formatcontentcontrol.hxx |7 + sw/inc/unoprnms.hxx |1 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|2 + sw/source/core/txtnode/attrcontentcontrol.cxx |2 + sw/source/core/unocore/unocontentcontrol.cxx | 28 ++ sw/source/core/unocore/unomap1.cxx|1 sw/source/filter/ww8/docxattributeoutput.cxx | 18 ++ sw/source/filter/ww8/docxattributeoutput.hxx |1 writerfilter/source/dmapper/DomainMapper.cxx | 16 writerfilter/source/dmapper/DomainMapper_Impl.cxx |6 writerfilter/source/dmapper/SdtHelper.cxx |4 +++ writerfilter/source/dmapper/SdtHelper.hxx |6 writerfilter/source/ooxml/model.xml | 12 + 15 files changed, 111 insertions(+) New commits: commit d20c11d4418053b1c5583255f626032a37a7e65e Author: offtkp AuthorDate: Wed Dec 28 00:10:34 2022 +0200 Commit: Miklos Vajna CommitDate: Wed Jan 4 08:58:23 2023 + docx: Preserve w15:appearance SdtPr attribute Now roundtrips the w15:appearance value which dictates whether there's an effect when hovering a placeholder. Change-Id: I3c911a0cfe31e235b9d981bbff0c1bb5827a85ef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144845 Tested-by: Jenkins Reviewed-by: Miklos Vajna (cherry picked from commit 2fe73bd2362287afc8242289a900821186b36137) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144994 Tested-by: Jenkins CollaboraOffice diff --git a/offapi/com/sun/star/text/ContentControl.idl b/offapi/com/sun/star/text/ContentControl.idl index cb980a24b0ff..34beff3cb127 100644 --- a/offapi/com/sun/star/text/ContentControl.idl +++ b/offapi/com/sun/star/text/ContentControl.idl @@ -92,6 +92,12 @@ service ContentControl */ [optional, property] string Color; +/** The appearance: just remembered. + +@since LibreOffice 7.6 +*/ +[optional, property] string Appearance; + /** Combo box that allows free-form text as well, i.e. not dropdown. @since LibreOffice 7.5 diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt index 1b634835254c..c68d10f7de1e 100644 --- a/oox/source/token/tokens.txt +++ b/oox/source/token/tokens.txt @@ -599,6 +599,7 @@ anyType anyURI appName appWorkspace +appearance apples applyAlignment applyAlignmentFormats diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index 9c142ed711f0..f65b67d37cc4 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -169,6 +169,9 @@ class SW_DLLPUBLIC SwContentControl : public sw::BroadcastingModify /// The color: just remembered. OUString m_aColor; +/// The appearance: just remembered. +OUString m_aAppearance; + /// The alias: just remembered. OUString m_aAlias; @@ -355,6 +358,10 @@ public: OUString GetColor() const { return m_aColor; } +void SetAppearance(const OUString& rAppearance) { m_aAppearance = rAppearance; } + +const OUString& GetAppearance() const { return m_aAppearance; } + void SetAlias(const OUString& rAlias) { m_aAlias = rAlias; } const OUString& GetAlias() const { return m_aAlias; } diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 3c6b5d8464ab..3a8df7c69182 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -889,6 +889,7 @@ #define UNO_NAME_DATA_BINDING_XPATH "DataBindingXpath" #define UNO_NAME_DATA_BINDING_STORE_ITEM_ID "DataBindingStoreItemID" #define UNO_NAME_COLOR "Color" +#define UNO_NAME_APPEARANCE "Appearance" #define UNO_NAME_ALIAS "Alias" #define UNO_NAME_TAG "Tag" #define UNO_NAME_ID "Id" diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index a9daa8042f15..395f0dbf03fc 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -298,6 +298,7 @@ CPPUNIT_TEST_FIXTURE(Test, testDateContentControlExport) xContentControlProps->setPropertyValue("DataBindingXpath", uno::Any(OUString("/ns0:employees[1]/ns0:employee[1]/ns0:hireDate[1]"))); xContentControlProps->setPropertyValue("DataBindingStoreItemID", uno::Any(OUString("{241A8A02-7FFD-488D-8827-63FBE74E8BC9}"))); xContentControlProps->setPropertyValue("Color", uno::Any(OUString("008000"))); +xContentControlProps->setPropertyValue("Appearance", uno::Any(OUString("hidden"))); xContentControlProps->setPropertyValue("Alias", uno::Any(OUString("myalias"))); xContentControlProps->setPropertyValue("Tag", uno::Any(OUString("mytag"))); xContentControlProps->setPropertyValue("Id", uno::Any(static_cast(123))); @@ -325,6 +326,7 @@ CPPUNIT_TEST_FIXTURE(Test, testDateContentControlExport)
[Libreoffice-commits] core.git: offapi/com oox/source sw/inc sw/qa sw/source writerfilter/source
offapi/com/sun/star/text/ContentControl.idl |6 oox/source/token/tokens.txt |1 sw/inc/formatcontentcontrol.hxx |7 + sw/inc/unoprnms.hxx |1 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx|2 + sw/source/core/txtnode/attrcontentcontrol.cxx |2 + sw/source/core/unocore/unocontentcontrol.cxx | 28 ++ sw/source/core/unocore/unomap1.cxx|1 sw/source/filter/ww8/docxattributeoutput.cxx | 18 ++ sw/source/filter/ww8/docxattributeoutput.hxx |1 writerfilter/source/dmapper/DomainMapper.cxx | 16 writerfilter/source/dmapper/DomainMapper_Impl.cxx |6 writerfilter/source/dmapper/SdtHelper.cxx |4 +++ writerfilter/source/dmapper/SdtHelper.hxx |6 writerfilter/source/ooxml/model.xml | 12 + 15 files changed, 111 insertions(+) New commits: commit a3d79543e0221ee810e0b2dd871d2afbf5ee198b Author: offtkp AuthorDate: Wed Dec 28 00:10:34 2022 +0200 Commit: Miklos Vajna CommitDate: Tue Jan 3 08:04:12 2023 + docx: Preserve w15:appearance SdtPr attribute Now roundtrips the w15:appearance value which dictates whether there's an effect when hovering a placeholder. Change-Id: I3c911a0cfe31e235b9d981bbff0c1bb5827a85ef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144845 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/offapi/com/sun/star/text/ContentControl.idl b/offapi/com/sun/star/text/ContentControl.idl index cb980a24b0ff..c2fe46757656 100644 --- a/offapi/com/sun/star/text/ContentControl.idl +++ b/offapi/com/sun/star/text/ContentControl.idl @@ -92,6 +92,12 @@ service ContentControl */ [optional, property] string Color; +/** The appearance: just remembered. + +@since LibreOffice 7.5 +*/ +[optional, property] string Appearance; + /** Combo box that allows free-form text as well, i.e. not dropdown. @since LibreOffice 7.5 diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt index b66321243320..25951891d2a7 100644 --- a/oox/source/token/tokens.txt +++ b/oox/source/token/tokens.txt @@ -600,6 +600,7 @@ anyType anyURI appName appWorkspace +appearance apples applyAlignment applyAlignmentFormats diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index 889faeb89a07..c27253a5aab8 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -170,6 +170,9 @@ class SW_DLLPUBLIC SwContentControl : public sw::BroadcastingModify /// The color: just remembered. OUString m_aColor; +/// The appearance: just remembered. +OUString m_aAppearance; + /// The alias: just remembered. OUString m_aAlias; @@ -353,6 +356,10 @@ public: const OUString& GetColor() const { return m_aColor; } +void SetAppearance(const OUString& rAppearance) { m_aAppearance = rAppearance; } + +const OUString& GetAppearance() const { return m_aAppearance; } + void SetAlias(const OUString& rAlias) { m_aAlias = rAlias; } const OUString& GetAlias() const { return m_aAlias; } diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 17b13d02dc8e..42a38fdef0aa 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -915,6 +915,7 @@ inline constexpr OUStringLiteral UNO_NAME_DATA_BINDING_PREFIX_MAPPINGS inline constexpr OUStringLiteral UNO_NAME_DATA_BINDING_XPATH = u"DataBindingXpath"; inline constexpr OUStringLiteral UNO_NAME_DATA_BINDING_STORE_ITEM_ID = u"DataBindingStoreItemID"; inline constexpr OUStringLiteral UNO_NAME_COLOR = u"Color"; +inline constexpr OUStringLiteral UNO_NAME_APPEARANCE = u"Appearance"; inline constexpr OUStringLiteral UNO_NAME_ALIAS = u"Alias"; inline constexpr OUStringLiteral UNO_NAME_TAG = u"Tag"; inline constexpr OUStringLiteral UNO_NAME_ID = u"Id"; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index f3188551362a..86673055a0cd 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -421,6 +421,7 @@ CPPUNIT_TEST_FIXTURE(Test, testDateContentControlExport) xContentControlProps->setPropertyValue("DataBindingXpath", uno::Any(OUString("/ns0:employees[1]/ns0:employee[1]/ns0:hireDate[1]"))); xContentControlProps->setPropertyValue("DataBindingStoreItemID", uno::Any(OUString("{241A8A02-7FFD-488D-8827-63FBE74E8BC9}"))); xContentControlProps->setPropertyValue("Color", uno::Any(OUString("008000"))); +xContentControlProps->setPropertyValue("Appearance", uno::Any(OUString("hidden"))); xContentControlProps->setPropertyValue("Alias", uno::Any(OUString("myalias"))); xContentControlProps->setPropertyValue("Tag", uno::Any(OUString("mytag"))); xContentControlProps->setPropertyValue("Id",
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/core/accessibilitycheck/data/HighlightTest.odt |binary sw/source/core/access/AccessibilityCheck.cxx |2 +- 2 files changed, 1 insertion(+), 1 deletion(-) New commits: commit be405c3f1843a381e951fcc63e4cc9d76002e73d Author: offtkp AuthorDate: Mon Dec 5 15:21:54 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Wed Dec 21 13:33:33 2022 + tdf#152378 a11y: Don't trigger check for empty highlighted text Do not trigger accessibility check test for empty highlighted text Also added an empty line in the test document to check that it's no longer detected after this patch Change-Id: I173a61fc25c0ea4cf81642a7ea37a762b3b583f4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143673 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sw/qa/core/accessibilitycheck/data/HighlightTest.odt b/sw/qa/core/accessibilitycheck/data/HighlightTest.odt index da4821681502..a8f13e142ce1 100644 Binary files a/sw/qa/core/accessibilitycheck/data/HighlightTest.odt and b/sw/qa/core/accessibilitycheck/data/HighlightTest.odt differ diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index ac558a44c69e..7a51b8edabc1 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -464,7 +464,7 @@ private: // If not character background color, try paragraph background color if (aBackgroundColor == COL_AUTO) aBackgroundColor = nParaBackColor; -else +else if (!xTextRange->getString().isEmpty()) { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_FORMATTING_CONVEYS_MEANING),
[Libreoffice-commits] core.git: sw/inc sw/qa sw/source
sw/inc/strings.hrc |1 sw/qa/extras/ooxmlexport/data/tdf125338.docm |binary sw/qa/extras/ooxmlexport/ooxmlexport9.cxx| 10 ++- sw/source/filter/ww8/docxexport.cxx |3 +- sw/source/filter/ww8/docxexportfilter.cxx| 35 +++ 5 files changed, 43 insertions(+), 6 deletions(-) New commits: commit cbca5617387aaa39c9ee86272166bb3df7874b25 Author: offtkp AuthorDate: Wed Dec 14 22:21:34 2022 +0200 Commit: Justin Luth CommitDate: Tue Dec 20 14:46:21 2022 + tdf#125338 Do not export macros when saving as .docx Docx files that have macros should be saved as .docm. Now displays a warning that macros won't be saved if exporting a .docm as a .docx and doesn't export them. Change-Id: I178855baa6c0a7d32fd9b00c83a817230b33a1a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144197 Tested-by: Jenkins Reviewed-by: Justin Luth diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index afd0c2873fad..425d31f88d30 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -331,6 +331,7 @@ #define STR_SOUTH NC_("STR_SOUTH", "South") #define STR_SUM NC_("STR_SUM", "Sum") #define STR_INVALID_AUTOFORMAT_NAME NC_("STR_INVALID_AUTOFORMAT_NAME", "You have entered an invalid name.\nThe desired AutoFormat could not be created. \nTry again using a different name.") +#define STR_CANT_SAVE_MACROSNC_("STR_CANT_SAVE_MACROS", "This document has macros, but macros will not be saved in this file format.") #define STR_NUMERIC NC_("STR_NUMERIC", "Numeric") #define STR_ROW NC_("STR_ROW", "Rows") #define STR_COL NC_("STR_COL", "Column") diff --git a/sw/qa/extras/ooxmlexport/data/tdf125338.docm b/sw/qa/extras/ooxmlexport/data/tdf125338.docm new file mode 100644 index ..44e943531d30 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf125338.docm differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 26a7e7167667..a066f88ba13b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -129,7 +129,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf109063, "tdf109063.docx") CPPUNIT_ASSERT_EQUAL(0, getShapes()); } -CPPUNIT_TEST_FIXTURE(Test, testTdf108269) +CPPUNIT_TEST_FIXTURE(DocmTest, testTdf108269) { loadAndReload("tdf108269.docm"); uno::Reference xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); @@ -139,6 +139,14 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf108269) CPPUNIT_ASSERT(xNameAccess->hasByName("word/vbaData.xml")); } +CPPUNIT_TEST_FIXTURE(Test, testTdf125338) +{ +loadAndSave("tdf125338.docm"); +uno::Reference xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); +// docm files should not retain macros when saved as docx +CPPUNIT_ASSERT(!xNameAccess->hasByName("word/vbaProject.bin")); +} + DECLARE_OOXMLEXPORT_TEST(testTdf92045, "tdf92045.docx") { // This was true, resulted in setting the blinking font effect. diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index ea59775eda15..f060773576eb 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -549,7 +549,8 @@ ErrCode DocxExport::ExportDocument_Impl() WriteEmbeddings(); -WriteVBA(); +if (m_bDocm) +WriteVBA(); m_aLinkedTextboxesHelper.clear(); //final cleanup m_pStyles.reset(); diff --git a/sw/source/filter/ww8/docxexportfilter.cxx b/sw/source/filter/ww8/docxexportfilter.cxx index 08308ca9398c..5ffd32f4c25b 100644 --- a/sw/source/filter/ww8/docxexportfilter.cxx +++ b/sw/source/filter/ww8/docxexportfilter.cxx @@ -63,6 +63,37 @@ bool DocxExportFilter::exportDocument() pViewShell->GetPostItMgr()->UpdateDataOnActiveSidebarWin(); } +OUString aFilterName; +auto& rMediaDescriptor = getMediaDescriptor(); +rMediaDescriptor[utl::MediaDescriptor::PROP_FILTERNAME] >>= aFilterName; +bool bDocm = aFilterName.endsWith("VBA"); + +if (!bDocm) +{ +// Check whether application is in headless mode +if (!Application::IsHeadlessModeEnabled()) +{ +uno::Reference xStorageBasedDocument( +pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY); +if (xStorageBasedDocument.is()) +{ +uno::Reference xDocumentStorage = +xStorageBasedDocument->getDocumentStorage(); +if (xDocumentStorage.is() && xDocumentStorage->hasByName(u"_MS_VBA_Macros")) +{ +// Let user know that
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - include/oox oox/source sc/inc sc/source
include/oox/helper/attributelist.hxx|3 +++ oox/source/helper/attributelist.cxx |8 sc/inc/dbdata.hxx | 10 +- sc/source/core/tool/dbdata.cxx | 17 ++--- sc/source/filter/excel/xedbdata.cxx |5 +++-- sc/source/filter/inc/tablecolumnsbuffer.hxx |4 sc/source/filter/oox/tablecolumnsbuffer.cxx | 11 ++- 7 files changed, 51 insertions(+), 7 deletions(-) New commits: commit 68c9499edfd6f8a101db2c9a721f20bf7652812f Author: offtkp AuthorDate: Thu Nov 17 16:41:42 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Tue Dec 13 09:10:52 2022 + xlsx: Import table column attribute XML_totalsRowFunction Import table column attribute totalsRowFunction and also export it, which fixes a warning when roundtripped on a different office suite. Change-Id: Icc76fc310aef3bd51bcefebece57f962a56b7cca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142843 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit e54b39c82e88a296af1d2c7ddbf6f20513ffacf5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143444 Tested-by: Jenkins CollaboraOffice diff --git a/include/oox/helper/attributelist.hxx b/include/oox/helper/attributelist.hxx index efb3de7779cf..8d00f614728d 100644 --- a/include/oox/helper/attributelist.hxx +++ b/include/oox/helper/attributelist.hxx @@ -103,6 +103,9 @@ public: /** Returns the string value of the specified attribute. */ OptValue< OUString > getString( sal_Int32 nAttrToken ) const; +/** Returns the string value of the specified attribute, returns an empty string if attribute not present. */ +OUString getStringDefaulted( sal_Int32 nAttrToken ) const; + /** Returns the string value of the specified attribute. All characters in the format '_x_' (H being a hexadecimal digit), will be decoded. */ OptValue< OUString > getXString( sal_Int32 nAttrToken ) const; diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx index 6ac3ea872eb4..b2090ee1473b 100644 --- a/oox/source/helper/attributelist.cxx +++ b/oox/source/helper/attributelist.cxx @@ -286,6 +286,14 @@ OUString AttributeList::getString( sal_Int32 nAttrToken, const OUString& rDefaul return rDefault; } +OUString AttributeList::getStringDefaulted( sal_Int32 nAttrToken ) const +{ +// check if the attribute exists (empty string may be different to missing attribute) +if( mxAttribs->hasAttribute( nAttrToken ) ) +return mxAttribs->getOptionalValue( nAttrToken ); +return OUString(); +} + OUString AttributeList::getXString( sal_Int32 nAttrToken, const OUString& rDefault ) const { return getXString( nAttrToken ).get( rDefault ); diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx index f12ba3fb976d..5f2f23335544 100644 --- a/sc/inc/dbdata.hxx +++ b/sc/inc/dbdata.hxx @@ -43,6 +43,11 @@ enum class ScDBDataPortion AREA///< entire area }; +struct TableColumnAttributes +{ +std::optional maTotalsFunction = std::nullopt; +}; + /** Container base class to provide selected access for ScDBData. */ class ScDBDataContainerBase { @@ -93,6 +98,7 @@ private: boolbModified; ///< is set/cleared for/by(?) UpdateReference ::std::vector< OUString > maTableColumnNames; ///< names of table columns +::std::vector< TableColumnAttributes > maTableColumnAttributes; ///< attributes of table columns boolmbTableColumnNamesDirty; SCSIZE nFilteredRowCount; @@ -147,6 +153,8 @@ public: voidEndTableColumnNamesListener(); SC_DLLPUBLIC void SetTableColumnNames( ::std::vector< OUString >&& rNames ); SC_DLLPUBLIC const ::std::vector< OUString >& GetTableColumnNames() const { return maTableColumnNames; } +SC_DLLPUBLIC void SetTableColumnAttributes( ::std::vector< TableColumnAttributes >&& rAttributes ); +SC_DLLPUBLIC const ::std::vector< TableColumnAttributes >& GetTableColumnAttributes() const { return maTableColumnAttributes; } boolAreTableColumnNamesDirty() const { return mbTableColumnNamesDirty; } /** Refresh/update the column names with the header row's cell contents. */ @@ -218,7 +226,7 @@ public: private: -void AdjustTableColumnNames( UpdateRefMode eUpdateRefMode, SCCOL nDx, SCCOL nCol1, +void AdjustTableColumnAttributes( UpdateRefMode eUpdateRefMode, SCCOL nDx, SCCOL nCol1, SCCOL nOldCol1, SCCOL nOldCol2, SCCOL nNewCol1, SCCOL nNewCol2 ); void InvalidateTableColumnNames( bool bSwapToEmptyNames ); }; diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index e441c7418796..b9febe2e5e24 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -610,7 +610,7 @@ bool ScDBData::UpdateReference(const ScDocument* pDoc, UpdateRefMode eUpdateRefM if
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/uibase/wrtsh/wrtsh.cxx |7 +++ sw/source/core/txtnode/attrcontentcontrol.cxx |1 - sw/source/uibase/wrtsh/wrtsh1.cxx | 14 ++ sw/source/uibase/wrtsh/wrtsh3.cxx |4 4 files changed, 21 insertions(+), 5 deletions(-) New commits: commit 618cef756b87f9816d0dcbe04af163ccd06a986e Author: offtkp AuthorDate: Mon Dec 12 13:03:43 2022 +0200 Commit: Miklos Vajna CommitDate: Tue Dec 13 06:44:03 2022 + docx: Do not remove showingPlcHdr until edit When a placeholder has the showingPlcHdr attribute, the entire text is selected upon click. This is no longer removed by selecting it once but once the text has been edited. Change-Id: I9a4d68289c8b95ab0098e55a5fa6edb1606c7df2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143985 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/sw/qa/uibase/wrtsh/wrtsh.cxx b/sw/qa/uibase/wrtsh/wrtsh.cxx index d2adde32a179..a2d9fdc37514 100644 --- a/sw/qa/uibase/wrtsh/wrtsh.cxx +++ b/sw/qa/uibase/wrtsh/wrtsh.cxx @@ -399,6 +399,13 @@ CPPUNIT_TEST_FIXTURE(Test, testInsertPlainTextContentControl) // Without the accompanying fix in place, this test would have failed, there was no special // handling for plain text content controls. CPPUNIT_ASSERT(pContentControl->GetPlainText()); + +CPPUNIT_ASSERT(pContentControl->GetShowingPlaceHolder()); +pWrtShell->GotoContentControl(rFormatContentControl); +CPPUNIT_ASSERT(pContentControl->GetShowingPlaceHolder()); +pWrtShell->Insert("Foo"); +// No longer showing placeholder text, as it has been changed +CPPUNIT_ASSERT(!pContentControl->GetShowingPlaceHolder()); } CPPUNIT_TEST_FIXTURE(Test, testInsertComboBoxContentControl) diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx index 890bf20c1376..1db39849fbe6 100644 --- a/sw/source/core/txtnode/attrcontentcontrol.cxx +++ b/sw/source/core/txtnode/attrcontentcontrol.cxx @@ -720,7 +720,6 @@ void SwTextContentControl::Invalidate() pDocShell->GetWrtShell()->Push(); // visit the control in the text (which makes any necessary visual changes) -// NOTE: simply going to a control indicates cancelling ShowingPlaceHolder, unless bOnlyRefresh // NOTE: simply going to a checkbox causes a toggle, unless bOnlyRefresh auto& rFormatContentControl = static_cast(GetAttr()); pDocShell->GetWrtShell()->GotoContentControl(rFormatContentControl, /*bOnlyRefresh=*/true); diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index adf96052e8fa..b989343266cb 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -117,6 +117,7 @@ #include #include #include +#include using namespace sw::mark; using namespace com::sun::star; @@ -262,6 +263,19 @@ void SwWrtShell::Insert( const OUString ) bCallIns ? SwEditShell::Insert2( rStr, bDeleted ) : SwEditShell::Overwrite( rStr ); +// Check whether node is content control +SwTextContentControl* pTextContentControl = CursorInsideContentControl(); +if (pTextContentControl) +{ +std::shared_ptr pContentControl = +pTextContentControl->GetContentControl().GetContentControl(); +if (pContentControl) +{ +// Set showingPlcHdr to false as node has been edited +pContentControl->SetShowingPlaceHolder(false); +} +} + if( bStarted ) { EndUndo(); diff --git a/sw/source/uibase/wrtsh/wrtsh3.cxx b/sw/source/uibase/wrtsh/wrtsh3.cxx index aa170d1374a4..4e80bfc1e3d1 100644 --- a/sw/source/uibase/wrtsh/wrtsh3.cxx +++ b/sw/source/uibase/wrtsh/wrtsh3.cxx @@ -125,10 +125,6 @@ bool SwWrtShell::GotoContentControl(const SwFormatContentControl& rContentContro (this->*m_fnKillSel)(nullptr, false); bool bRet = SwCursorShell::GotoFormatContentControl(rContentControl); -// Assume that once the placeholder is selected, the content is no longer the placeholder. -if (!bOnlyRefresh && pContentControl) -pContentControl->SetShowingPlaceHolder(false); - if (bRet && pContentControl && pContentControl->GetCheckbox()) {
[Libreoffice-commits] core.git: chart2/qa sc/source
chart2/qa/extras/chart2import.cxx | 29 + chart2/qa/extras/data/xlsx/barchart_totalsrow.xlsx |binary sc/source/ui/unoobj/chart2uno.cxx | 20 ++ 3 files changed, 49 insertions(+) New commits: commit ad085990b8073a122ac5222e5220f8f1d6826dcf Author: offtkp AuthorDate: Wed Nov 30 00:54:08 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Thu Dec 8 00:15:46 2022 + xlsx: Don't add cell data to chart data sequence if in totalsRow When importing data from a cell range to use in a chart, if a cell is in the totalsRow it is now ignored if it's the last row in the range. Change-Id: Ie8c79b995c4d46b361492e8f7687894e2640392f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143488 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 68791e3b2d21..a9c301a94b93 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -137,6 +137,7 @@ public: void testTdf121205(); void testFixedSizeBarChartVeryLongLabel(); void testAutomaticSizeBarChartVeryLongLabel(); +void testTotalsRowIgnored(); CPPUNIT_TEST_SUITE(Chart2ImportTest); CPPUNIT_TEST(Fdo60083); @@ -223,6 +224,7 @@ public: CPPUNIT_TEST(testTdf121205); CPPUNIT_TEST(testFixedSizeBarChartVeryLongLabel); CPPUNIT_TEST(testAutomaticSizeBarChartVeryLongLabel); +CPPUNIT_TEST(testTotalsRowIgnored); CPPUNIT_TEST_SUITE_END(); }; @@ -2274,6 +2276,33 @@ void Chart2ImportTest::testAutomaticSizeBarChartVeryLongLabel() CPPUNIT_ASSERT_DOUBLES_EQUAL(1192, xXAxis->getSize().Height, 100); } +void Chart2ImportTest::testTotalsRowIgnored() +{ +loadFromURL(u"xlsx/barchart_totalsrow.xlsx"); +{ +uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); +CPPUNIT_ASSERT(xChartDoc.is()); + +Reference xDataSeq = +getDataSequenceFromDocByRole(xChartDoc, u"values-y"); +CPPUNIT_ASSERT(xDataSeq.is()); + +// Table data range is D2:D9 (8 rows) but because last row is totals row it is ignored +CPPUNIT_ASSERT_EQUAL(static_cast(7u), xDataSeq->getData().size()); +} +{ +uno::Reference xChartDoc = getChartDocFromSheet(1, mxComponent); +CPPUNIT_ASSERT(xChartDoc.is()); + +Reference xDataSeq = +getDataSequenceFromDocByRole(xChartDoc, u"values-y"); +CPPUNIT_ASSERT(xDataSeq.is()); + +// Table data range is D2:D10 (9 rows) and totals row isn't the last row so it's not ignored +CPPUNIT_ASSERT_EQUAL(static_cast(9u), xDataSeq->getData().size()); +} +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/data/xlsx/barchart_totalsrow.xlsx b/chart2/qa/extras/data/xlsx/barchart_totalsrow.xlsx new file mode 100644 index ..c87b2b3186ac Binary files /dev/null and b/chart2/qa/extras/data/xlsx/barchart_totalsrow.xlsx differ diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index f92b1d4ec2ca..18378bdfedcd 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2571,6 +2571,26 @@ void ScChart2DataSequence::BuildDataCache() m_pDocument->InitColumnBlockPosition( hint, nTab, nCol ); for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow) { +if (nRow == aRange.aEnd.Row()) +{ +// Excel behavior: if the last row is the totals row, the data +// is not added to the chart. If it's not the last row, the data +// is added like normal. +const auto* rData = m_pDocument->GetDBAtCursor( +nCol, nRow, nTab, +ScDBDataPortion::AREA +); +if (rData && rData->HasTotals()) +{ +ScRange aTempRange; +rData->GetArea(aTempRange); +if (aTempRange.aEnd.Row() == nRow) +{ +// Current row is totals row, skip +break; +} +} +} bool bColHidden = m_pDocument->ColHidden(nCol, nTab, nullptr, ); bool bRowHidden = m_pDocument->RowHidden(nRow, nTab, nullptr, );
[Libreoffice-commits] core.git: sc/qa sc/source
sc/qa/unit/data/xlsx/hiddenButton.xlsx|binary sc/qa/unit/subsequent_export_test2.cxx| 15 sc/source/filter/excel/excrecds.cxx | 54 ++ sc/source/filter/inc/autofilterbuffer.hxx |1 sc/source/filter/inc/excrecds.hxx |5 ++ sc/source/filter/oox/autofilterbuffer.cxx | 18 +- 6 files changed, 85 insertions(+), 8 deletions(-) New commits: commit 2942fdc8dbda375622d0add8c36df2d6679e321a Author: offtkp AuthorDate: Fri Nov 25 15:16:53 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Thu Dec 1 13:05:54 2022 +0100 tdf#144786 Implement XML_hiddenButton functionality Now hides autofilter button when there's an XML_hiddenButton=true or a XML_showButton=false attribute Change-Id: I911ef23fb5e4feff8c7de0ec154bff871a29f2e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143300 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sc/qa/unit/data/xlsx/hiddenButton.xlsx b/sc/qa/unit/data/xlsx/hiddenButton.xlsx new file mode 100644 index ..20019f4d181b Binary files /dev/null and b/sc/qa/unit/data/xlsx/hiddenButton.xlsx differ diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 628401167d5a..77b033d042a3 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -189,6 +189,7 @@ public: void testTdf148820(); void testEmbeddedTextInDecimal(); void testTotalsRowFunction(); +void testAutofilterHiddenButton(); CPPUNIT_TEST_SUITE(ScExportTest2); @@ -315,6 +316,7 @@ public: CPPUNIT_TEST(testTdf148820); CPPUNIT_TEST(testEmbeddedTextInDecimal); CPPUNIT_TEST(testTotalsRowFunction); +CPPUNIT_TEST(testAutofilterHiddenButton); CPPUNIT_TEST_SUITE_END(); }; @@ -2849,6 +2851,19 @@ void ScExportTest2::testTotalsRowFunction() } } +void ScExportTest2::testAutofilterHiddenButton() +{ +createScDoc("xlsx/hiddenButton.xlsx"); +saveAndReload("Calc Office Open XML"); +xmlDocUniquePtr pDocXml = parseExport("xl/tables/table1.xml"); +CPPUNIT_ASSERT(pDocXml); +for (int i = 1; i <= 5; i++) +{ +auto sPath = "/x:table/x:autoFilter/x:filterColumn[" + std::to_string(i) + "]"; +assertXPath(pDocXml, sPath.c_str(), "hiddenButton", "1"); +} +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index b175445bc388..3feac86be5a2 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -47,6 +47,8 @@ #include #include +#include +#include using namespace ::oox; @@ -603,11 +605,12 @@ void ExcFilterCondition::SaveText( XclExpStream& rStrm ) } } -XclExpAutofilter::XclExpAutofilter( const XclExpRoot& rRoot, sal_uInt16 nC ) : +XclExpAutofilter::XclExpAutofilter( const XclExpRoot& rRoot, sal_uInt16 nC, bool bIsEmpty ) : XclExpRecord( EXC_ID_AUTOFILTER, 24 ), XclExpRoot( rRoot ), -meType(FilterCondition), +meType(bIsEmpty ? Empty : FilterCondition), nCol( nC ), +bIsButtonHidden( false ), nFlags( 0 ), bHasBlankValue( false ) { @@ -818,10 +821,13 @@ void XclExpAutofilter::SaveXml( XclExpXmlStream& rStrm ) sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); +std::optional sHiddenButtonValue; +if (bIsButtonHidden) +sHiddenButtonValue = "1"; + rWorksheet->startElement( XML_filterColumn, -XML_colId, OString::number(nCol) -// OOXTODO: XML_hiddenButton, AutoFilter12 fHideArrow? -// OOXTODO: XML_showButton +XML_colId, OString::number(nCol), +XML_hiddenButton, sHiddenButtonValue ); switch (meType) @@ -911,6 +917,8 @@ void XclExpAutofilter::SaveXml( XclExpXmlStream& rStrm ) rWorksheet->endElement(XML_filters); } break; +// Used for constructing an empty filterColumn element for exporting the XML_hiddenButton attribute +case Empty: break; } rWorksheet->endElement( XML_filterColumn ); } @@ -971,6 +979,8 @@ ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const boolbContLoop = true; boolbHasOr = false; SCCOLROW nFirstField = aParam.GetEntry( 0 ).nField; +ScDocument& rDoc = rRoot.GetDoc(); +SCROW nRow = aRange.aStart.Row(); // create AUTOFILTER records for filtered columns for( SCSIZE nEntry = 0; !bConflict && bContLoop && (nEntry < aParam.GetEntryCount()); nEntry++ ) @@ -980,7 +990,11 @@ ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const bContLoop = rEntry.bDoQuery; if( bContLoop ) { -XclExpAutofilter* pFilter = GetByCol( static_cast(rEntry.nField) -
[Libreoffice-commits] core.git: sc/qa
sc/qa/unit/data/xlsx/totalsRowFunction.xlsx |binary sc/qa/unit/subsequent_export_test2.cxx | 25 + 2 files changed, 25 insertions(+) New commits: commit 8b9e182f90c681d55848f08605470d2bff39078c Author: offtkp AuthorDate: Wed Nov 23 11:34:52 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Wed Nov 30 14:24:27 2022 +0100 xlsx: Add test for totalsRowFunction roundtrip Change-Id: I3b7539a88abbe2f9bab3331d8550c1050c52059a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143137 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sc/qa/unit/data/xlsx/totalsRowFunction.xlsx b/sc/qa/unit/data/xlsx/totalsRowFunction.xlsx new file mode 100644 index ..3731caf86491 Binary files /dev/null and b/sc/qa/unit/data/xlsx/totalsRowFunction.xlsx differ diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index b3d46d1cdd58..628401167d5a 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -188,6 +188,7 @@ public: void testTdf91286(); void testTdf148820(); void testEmbeddedTextInDecimal(); +void testTotalsRowFunction(); CPPUNIT_TEST_SUITE(ScExportTest2); @@ -313,6 +314,7 @@ public: CPPUNIT_TEST(testTdf91286); CPPUNIT_TEST(testTdf148820); CPPUNIT_TEST(testEmbeddedTextInDecimal); +CPPUNIT_TEST(testTotalsRowFunction); CPPUNIT_TEST_SUITE_END(); }; @@ -2824,6 +2826,29 @@ void ScExportTest2::testEmbeddedTextInDecimal() lcl_TestEmbeddedTextInDecimal(*getScDoc()); } +void ScExportTest2::testTotalsRowFunction() +{ +createScDoc("xlsx/totalsRowFunction.xlsx"); +saveAndReload("Calc Office Open XML"); +{ +xmlDocUniquePtr pDocXml = parseExport("xl/tables/table1.xml"); +CPPUNIT_ASSERT(pDocXml); +assertXPath(pDocXml, "/x:table/x:tableColumns/x:tableColumn[5]", "totalsRowFunction", +"sum"); +} +ScDocument* pDoc = getScDoc(); +pDoc->InsertCol(ScRange(3, 0, 0, 3, pDoc->MaxRow(), 0)); // Insert col 4 +saveAndReload("Calc Office Open XML"); +{ +xmlDocUniquePtr pDocXml = parseExport("xl/tables/table1.xml"); +CPPUNIT_ASSERT(pDocXml); +assertXPathNoAttribute(pDocXml, "/x:table/x:tableColumns/x:tableColumn[5]", + "totalsRowFunction"); +assertXPath(pDocXml, "/x:table/x:tableColumns/x:tableColumn[6]", "totalsRowFunction", +"sum"); +} +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest2); CPPUNIT_PLUGIN_IMPLEMENT();
[Libreoffice-commits] core.git: sc/inc sc/source
sc/inc/dbdata.hxx | 10 +- sc/source/core/tool/dbdata.cxx | 17 ++--- sc/source/filter/excel/xedbdata.cxx |5 +++-- sc/source/filter/inc/tablecolumnsbuffer.hxx |4 sc/source/filter/oox/tablecolumnsbuffer.cxx | 11 ++- 5 files changed, 40 insertions(+), 7 deletions(-) New commits: commit 933e045422957e15cad47ef925d4f9a852c826b1 Author: offtkp AuthorDate: Thu Nov 17 16:41:42 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Wed Nov 30 14:24:10 2022 +0100 xlsx: Import table column attribute XML_totalsRowFunction Import table column attribute totalsRowFunction and also export it, which fixes a warning when roundtripped on a different office suite. Change-Id: Icc76fc310aef3bd51bcefebece57f962a56b7cca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142843 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx index 0e8d53830e53..482c55bc6aa4 100644 --- a/sc/inc/dbdata.hxx +++ b/sc/inc/dbdata.hxx @@ -43,6 +43,11 @@ enum class ScDBDataPortion AREA///< entire area }; +struct TableColumnAttributes +{ +std::optional maTotalsFunction = std::nullopt; +}; + /** Container base class to provide selected access for ScDBData. */ class ScDBDataContainerBase { @@ -93,6 +98,7 @@ private: boolbModified; ///< is set/cleared for/by(?) UpdateReference ::std::vector< OUString > maTableColumnNames; ///< names of table columns +::std::vector< TableColumnAttributes > maTableColumnAttributes; ///< attributes of table columns boolmbTableColumnNamesDirty; SCSIZE nFilteredRowCount; @@ -147,6 +153,8 @@ public: voidEndTableColumnNamesListener(); SC_DLLPUBLIC void SetTableColumnNames( ::std::vector< OUString >&& rNames ); SC_DLLPUBLIC const ::std::vector< OUString >& GetTableColumnNames() const { return maTableColumnNames; } +SC_DLLPUBLIC void SetTableColumnAttributes( ::std::vector< TableColumnAttributes >&& rAttributes ); +SC_DLLPUBLIC const ::std::vector< TableColumnAttributes >& GetTableColumnAttributes() const { return maTableColumnAttributes; } boolAreTableColumnNamesDirty() const { return mbTableColumnNamesDirty; } /** Refresh/update the column names with the header row's cell contents. */ @@ -218,7 +226,7 @@ public: private: -void AdjustTableColumnNames( UpdateRefMode eUpdateRefMode, SCCOL nDx, SCCOL nCol1, +void AdjustTableColumnAttributes( UpdateRefMode eUpdateRefMode, SCCOL nDx, SCCOL nCol1, SCCOL nOldCol1, SCCOL nOldCol2, SCCOL nNewCol1, SCCOL nNewCol2 ); void InvalidateTableColumnNames( bool bSwapToEmptyNames ); }; diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index cf518d0e2890..dc10d6a0503e 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -609,7 +609,7 @@ bool ScDBData::UpdateReference(const ScDocument* pDoc, UpdateRefMode eUpdateRefM if (bDoUpdate && eRet != UR_INVALID) { // MoveTo() invalidates column names via SetArea(); adjust, remember and set new. -AdjustTableColumnNames( eUpdateRefMode, nDx, nCol1, nOldCol1, nOldCol2, theCol1, theCol2); +AdjustTableColumnAttributes( eUpdateRefMode, nDx, nCol1, nOldCol1, nOldCol2, theCol1, theCol2); ::std::vector aNames( maTableColumnNames); bool bTableColumnNamesDirty = mbTableColumnNamesDirty; // tdf#48025, tdf#141946: update the column index of the filter criteria, @@ -686,7 +686,12 @@ void ScDBData::SetTableColumnNames( ::std::vector< OUString >&& rNames ) mbTableColumnNamesDirty = false; } -void ScDBData::AdjustTableColumnNames( UpdateRefMode eUpdateRefMode, SCCOL nDx, SCCOL nCol1, +void ScDBData::SetTableColumnAttributes( ::std::vector< TableColumnAttributes >&& rAttributes ) +{ +maTableColumnAttributes = std::move(rAttributes); +} + +void ScDBData::AdjustTableColumnAttributes( UpdateRefMode eUpdateRefMode, SCCOL nDx, SCCOL nCol1, SCCOL nOldCol1, SCCOL nOldCol2, SCCOL nNewCol1, SCCOL nNewCol2 ) { if (maTableColumnNames.empty()) @@ -698,6 +703,7 @@ void ScDBData::AdjustTableColumnNames( UpdateRefMode eUpdateRefMode, SCCOL nDx, return; // not moved or entirely moved, nothing to do ::std::vector aNewNames; +::std::vector aNewAttributes; if (eUpdateRefMode == URM_INSDEL) { if (nDx > 0) @@ -714,22 +720,27 @@ void ScDBData::AdjustTableColumnNames( UpdateRefMode eUpdateRefMode, SCCOL nDx, if (nDx > 0) n += nDx; aNewNames.resize(n); +aNewAttributes.resize(n); +maTableColumnAttributes.resize(n); // Copy head. for (size_t i = 0; i < nHead; ++i) { aNewNames[i] = maTableColumnNames[i]; +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/AccessibilityCheckStrings.hrc |1 sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx | 11 +++ sw/qa/core/accessibilitycheck/data/SpaceTest.odt |binary sw/source/core/access/AccessibilityCheck.cxx | 49 +++ 4 files changed, 61 insertions(+) New commits: commit ef99eca8d474f42343803e7b3828b8ccfd49d9ca Author: offtkp AuthorDate: Wed Oct 12 19:29:28 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Nov 22 09:53:01 2022 +0100 a11y: Add check for spacing spaces Add accessibility check and relevant test for a document that uses multiple spaces for spacing Change-Id: Ib92471c50a25ead28f2b6c7d5e00ed222d4b429e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141267 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141792 Tested-by: Jenkins CollaboraOffice diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc index 4d65bd095f51..9c45cb84ecd9 100644 --- a/sw/inc/AccessibilityCheckStrings.hrc +++ b/sw/inc/AccessibilityCheckStrings.hrc @@ -23,6 +23,7 @@ #define STR_AVOID_ENDNOTES NC_("STR_AVOID_ENDNOTES", "Avoid endnotes.") #define STR_AVOID_BACKGROUND_IMAGES NC_("STR_AVOID_BACKGROUND_IMAGES", "Avoid background images.") #define STR_AVOID_NEWLINES_SPACENC_("STR_AVOID_NEWLINES_SPACE", "Avoid newlines to create space.") +#define STR_AVOID_SPACES_SPACE NC_("STR_AVOID_SPACES_SPACE", "Avoid spaces to create space.") #define STR_HEADINGS_NOT_IN_ORDER NC_("STR_HEADINGS_NOT_IN_ORDER", "Headings not in order.") #define STR_TEXT_FORMATTING_CONVEYS_MEANING NC_("STR_TEXT_FORMATTING_CONVEYS_MEANING", "The text formatting conveys additional meaning.") #define STR_NON_INTERACTIVE_FORMS NC_("STR_NON_INTERACTIVE_FORMS", "An input form is not interactive.") diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx index c04aadae4d94..46d23380b5df 100644 --- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx +++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx @@ -84,6 +84,17 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckNewlineSpace) CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[1]->m_eIssueID); } +CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckSpacebarSpace) +{ +SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "SpaceTest.odt"); +CPPUNIT_ASSERT(pDoc); +sw::AccessibilityCheck aCheck(pDoc); +aCheck.check(); +auto& aIssues = aCheck.getIssueCollection().getIssues(); +CPPUNIT_ASSERT_EQUAL(size_t(1), aIssues.size()); +CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[0]->m_eIssueID); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/accessibilitycheck/data/SpaceTest.odt b/sw/qa/core/accessibilitycheck/data/SpaceTest.odt new file mode 100644 index ..0f00f78f9698 Binary files /dev/null and b/sw/qa/core/accessibilitycheck/data/SpaceTest.odt differ diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index fdc849e518b6..9d5c1164ac63 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -670,6 +670,54 @@ public: } }; +class SpaceSpacingCheck : public NodeCheck +{ +public: +SpaceSpacingCheck(sfx::AccessibilityIssueCollection& rIssueCollection) +: NodeCheck(rIssueCollection) +{ +} +void check(SwNode* pCurrent) override +{ +if (!pCurrent->IsTextNode()) +return; +SwTextNode* pTextNode = pCurrent->GetTextNode(); +auto nParagraphLength = pTextNode->GetText().getLength(); +const OUString& sParagraphText = pTextNode->GetText(); +sal_Int32 nSpaceCount = 0; +sal_Int32 nSpaceStart = 0; +bool bNonSpaceFound = false; +for (sal_Int32 i = 0; i < nParagraphLength; i++) +{ +if (sParagraphText[i] == ' ') +{ +if (bNonSpaceFound) +{ +nSpaceCount++; +if (nSpaceCount == 2) +nSpaceStart = i; +} +} +else +{ +if (nSpaceCount >= 2) +{ +auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_SPACES_SPACE), + sfx::AccessibilityIssueID::TEXT_FORMATTING); +pIssue->setIssueObject(IssueObject::TEXT); +pIssue->setNode(pTextNode); +SwDoc& rDocument = pTextNode->GetDoc(); +pIssue->setDoc(rDocument); +pIssue->setStart(nSpaceStart); +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 2 commits - include/sfx2 sw/inc sw/qa sw/source
include/sfx2/AccessibilityIssue.hxx|1 sw/inc/AccessibilityCheckStrings.hrc |1 sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx | 24 sw/qa/core/accessibilitycheck/data/BackgroundImageTest.odt |binary sw/qa/core/accessibilitycheck/data/ParagraphTest.odt |binary sw/source/core/access/AccessibilityCheck.cxx | 71 + 6 files changed, 97 insertions(+) New commits: commit 4f1e82fdc5c6db8c6554f0cd9dcb2e413b3fd282 Author: offtkp AuthorDate: Tue Oct 11 19:02:39 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Nov 22 09:52:24 2022 +0100 a11y: Add check for background image Add accessibility check and relevant test for a document with a background image Change-Id: I7b97cff27af66c2614bfc535d369b17ec048e8d9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141232 Tested-by: Jenkins CollaboraOffice Reviewed-by: Tomaž Vajngerl diff --git a/include/sfx2/AccessibilityIssue.hxx b/include/sfx2/AccessibilityIssue.hxx index 32522ff63f47..5e0616a881ed 100644 --- a/include/sfx2/AccessibilityIssue.hxx +++ b/include/sfx2/AccessibilityIssue.hxx @@ -23,6 +23,7 @@ enum class AccessibilityIssueID UNSPECIFIED, // TODO: remove - temporary DOCUMENT_TITLE, DOCUMENT_LANGUAGE, +DOCUMENT_BACKGROUND, STYLE_LANGUAGE, NO_ALT_OLE, NO_ALT_GRAPHIC, diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc index 2c098e50edc8..858de1a47d93 100644 --- a/sw/inc/AccessibilityCheckStrings.hrc +++ b/sw/inc/AccessibilityCheckStrings.hrc @@ -21,6 +21,7 @@ #define STR_TEXT_BLINKING NC_("STR_TEXT_BLINKING", "Blinking text.") #define STR_AVOID_FOOTNOTES NC_("STR_AVOID_FOOTNOTES", "Avoid footnotes.") #define STR_AVOID_ENDNOTES NC_("STR_AVOID_ENDNOTES", "Avoid endnotes.") +#define STR_AVOID_BACKGROUND_IMAGES NC_("STR_AVOID_BACKGROUND_IMAGES", "Avoid background images.") #define STR_HEADINGS_NOT_IN_ORDER NC_("STR_HEADINGS_NOT_IN_ORDER", "Headings not in order.") #define STR_TEXT_FORMATTING_CONVEYS_MEANING NC_("STR_TEXT_FORMATTING_CONVEYS_MEANING", "The text formatting conveys additional meaning.") #define STR_NON_INTERACTIVE_FORMS NC_("STR_NON_INTERACTIVE_FORMS", "An input form is not interactive.") diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx index 94011d5f1109..92a5ea3929e1 100644 --- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx +++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx @@ -61,6 +61,17 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckParagraphIssues) CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[0]->m_eIssueID); } +CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckBackgroundImage) +{ +SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "BackgroundImageTest.odt"); +CPPUNIT_ASSERT(pDoc); +sw::AccessibilityCheck aCheck(pDoc); +aCheck.check(); +auto& aIssues = aCheck.getIssueCollection().getIssues(); +CPPUNIT_ASSERT_EQUAL(size_t(1), aIssues.size()); +CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DOCUMENT_BACKGROUND, aIssues[0]->m_eIssueID); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/accessibilitycheck/data/BackgroundImageTest.odt b/sw/qa/core/accessibilitycheck/data/BackgroundImageTest.odt new file mode 100644 index ..eff6f178394b Binary files /dev/null and b/sw/qa/core/accessibilitycheck/data/BackgroundImageTest.odt differ diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index de11995cdb27..0013f6b2eb0e 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -898,6 +899,46 @@ public: } }; +class BackgroundImageCheck : public DocumentCheck +{ +public: +BackgroundImageCheck(sfx::AccessibilityIssueCollection& rIssueCollection) +: DocumentCheck(rIssueCollection) +{ +} +void check(SwDoc* pDoc) override +{ +uno::Reference xDoc = pDoc->GetDocShell()->GetBaseModel(); +uno::Reference xStyleFamiliesSupplier(xDoc, uno::UNO_QUERY); +if (!xStyleFamiliesSupplier.is()) +return; +uno::Reference xStyleFamilies += xStyleFamiliesSupplier->getStyleFamilies(); +uno::Reference xStyleFamily(xStyleFamilies->getByName("PageStyles"), +uno::UNO_QUERY); +if (!xStyleFamily.is()) +return; +const uno::Sequence& xStyleFamilyNames = xStyleFamily->getElementNames(); +for (const OUString& rStyleFamilyName : xStyleFamilyNames) +
[Libreoffice-commits] core.git: include/sfx2 sw/inc sw/qa sw/source
include/sfx2/AccessibilityIssue.hxx |2 + sw/inc/AccessibilityCheckStrings.hrc |1 sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx | 12 sw/qa/core/accessibilitycheck/data/HyperlinkTest.odt |binary sw/source/core/access/AccessibilityCheck.cxx | 21 --- 5 files changed, 33 insertions(+), 3 deletions(-) New commits: commit de02e5560168060af0b0c9be847af01c4fadec0b Author: offtkp AuthorDate: Thu Oct 13 19:35:06 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Fri Oct 21 08:53:31 2022 +0200 a11y: Add check for short hyperlinks Add accessibility check and relevant test for a document that uses short hyperlinks Change-Id: I5d6bfe345b50d6d42dc04e9e2f7f853cf5f63a84 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141338 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/sfx2/AccessibilityIssue.hxx b/include/sfx2/AccessibilityIssue.hxx index 085863cbd405..60700bad8d35 100644 --- a/include/sfx2/AccessibilityIssue.hxx +++ b/include/sfx2/AccessibilityIssue.hxx @@ -29,6 +29,8 @@ enum class AccessibilityIssueID NO_ALT_SHAPE, TABLE_MERGE_SPLIT, TEXT_FORMATTING, +HYPERLINK_IS_TEXT, +HYPERLINK_SHORT, }; class SFX2_DLLPUBLIC AccessibilityIssue diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc index 9c45cb84ecd9..77b93378869f 100644 --- a/sw/inc/AccessibilityCheckStrings.hrc +++ b/sw/inc/AccessibilityCheckStrings.hrc @@ -17,6 +17,7 @@ #define STR_TABLE_MERGE_SPLIT NC_("STR_TABLE_MERGE_SPLIT", "Table '%OBJECT_NAME%' contains merges or splits") #define STR_FAKE_NUMBERING NC_("STR_FAKE_NUMBERING", "Fake numbering '%NUMBERING%'") #define STR_HYPERLINK_TEXT_IS_LINK NC_("STR_HYPERLINK_TEXT_IS_LINK", "Hyperlink text is the same as the link address '%LINK%'") +#define STR_HYPERLINK_TEXT_IS_SHORT NC_("STR_HYPERLINK_TEXT_IS_SHORT", "Hyperlink text is too short.") #define STR_TEXT_CONTRAST NC_("STR_TEXT_CONTRAST", "Text contrast is too low.") #define STR_TEXT_BLINKING NC_("STR_TEXT_BLINKING", "Blinking text.") #define STR_AVOID_FOOTNOTES NC_("STR_AVOID_FOOTNOTES", "Avoid footnotes.") diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx index 98b08b5a207c..75cf071c1e69 100644 --- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx +++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx @@ -93,6 +93,18 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckSpacebarSpace) CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[0]->m_eIssueID); } +CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testHyperlinks) +{ +SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "HyperlinkTest.odt"); +CPPUNIT_ASSERT(pDoc); +sw::AccessibilityCheck aCheck(pDoc); +aCheck.check(); +auto& aIssues = aCheck.getIssueCollection().getIssues(); +CPPUNIT_ASSERT_EQUAL(size_t(2), aIssues.size()); +CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::HYPERLINK_SHORT, aIssues[0]->m_eIssueID); +CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::HYPERLINK_IS_TEXT, aIssues[1]->m_eIssueID); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/accessibilitycheck/data/HyperlinkTest.odt b/sw/qa/core/accessibilitycheck/data/HyperlinkTest.odt new file mode 100644 index ..1eba1932ce21 Binary files /dev/null and b/sw/qa/core/accessibilitycheck/data/HyperlinkTest.odt differ diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index 9746e17c0794..9195fcfcbd52 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -254,7 +254,8 @@ public: class HyperlinkCheck : public NodeCheck { private: -void checkTextRange(uno::Reference const& xTextRange) +void checkTextRange(uno::Reference const& xTextRange, SwTextNode* pTextNode, +sal_Int32 nStart) { uno::Reference xProperties(xTextRange, uno::UNO_QUERY); if (!xProperties->getPropertySetInfo()->hasPropertyByName("HyperLinkURL")) @@ -269,7 +270,19 @@ private: { OUString sIssueText = SwResId(STR_HYPERLINK_TEXT_IS_LINK).replaceFirst("%LINK%", sHyperlink); -lclAddIssue(m_rIssueCollection, sIssueText); +lclAddIssue(m_rIssueCollection, sIssueText, +sfx::AccessibilityIssueID::HYPERLINK_IS_TEXT); +} +else if (sText.getLength() <= 5) +{ +auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_HYPERLINK_TEXT_IS_SHORT), +
[Libreoffice-commits] core.git: sw/inc sw/qa sw/source
sw/inc/AccessibilityCheckStrings.hrc |1 sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx | 11 +++ sw/qa/core/accessibilitycheck/data/SpaceTest.odt |binary sw/source/core/access/AccessibilityCheck.cxx | 49 +++ 4 files changed, 61 insertions(+) New commits: commit 2c44f57b3f59012057a7a0a4d912648d362cf6f3 Author: offtkp AuthorDate: Wed Oct 12 19:29:28 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Mon Oct 17 16:33:40 2022 +0200 a11y: Add check for spacing spaces Add accessibility check and relevant test for a document that uses multiple spaces for spacing Change-Id: Ib92471c50a25ead28f2b6c7d5e00ed222d4b429e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141267 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc index 4d65bd095f51..9c45cb84ecd9 100644 --- a/sw/inc/AccessibilityCheckStrings.hrc +++ b/sw/inc/AccessibilityCheckStrings.hrc @@ -23,6 +23,7 @@ #define STR_AVOID_ENDNOTES NC_("STR_AVOID_ENDNOTES", "Avoid endnotes.") #define STR_AVOID_BACKGROUND_IMAGES NC_("STR_AVOID_BACKGROUND_IMAGES", "Avoid background images.") #define STR_AVOID_NEWLINES_SPACENC_("STR_AVOID_NEWLINES_SPACE", "Avoid newlines to create space.") +#define STR_AVOID_SPACES_SPACE NC_("STR_AVOID_SPACES_SPACE", "Avoid spaces to create space.") #define STR_HEADINGS_NOT_IN_ORDER NC_("STR_HEADINGS_NOT_IN_ORDER", "Headings not in order.") #define STR_TEXT_FORMATTING_CONVEYS_MEANING NC_("STR_TEXT_FORMATTING_CONVEYS_MEANING", "The text formatting conveys additional meaning.") #define STR_NON_INTERACTIVE_FORMS NC_("STR_NON_INTERACTIVE_FORMS", "An input form is not interactive.") diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx index 7a60b1578e21..98b08b5a207c 100644 --- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx +++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx @@ -82,6 +82,17 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckNewlineSpace) CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[1]->m_eIssueID); } +CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckSpacebarSpace) +{ +SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "SpaceTest.odt"); +CPPUNIT_ASSERT(pDoc); +sw::AccessibilityCheck aCheck(pDoc); +aCheck.check(); +auto& aIssues = aCheck.getIssueCollection().getIssues(); +CPPUNIT_ASSERT_EQUAL(size_t(1), aIssues.size()); +CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[0]->m_eIssueID); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/accessibilitycheck/data/SpaceTest.odt b/sw/qa/core/accessibilitycheck/data/SpaceTest.odt new file mode 100644 index ..0f00f78f9698 Binary files /dev/null and b/sw/qa/core/accessibilitycheck/data/SpaceTest.odt differ diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index f56bdf3e0c7b..9746e17c0794 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -670,6 +670,54 @@ public: } }; +class SpaceSpacingCheck : public NodeCheck +{ +public: +SpaceSpacingCheck(sfx::AccessibilityIssueCollection& rIssueCollection) +: NodeCheck(rIssueCollection) +{ +} +void check(SwNode* pCurrent) override +{ +if (!pCurrent->IsTextNode()) +return; +SwTextNode* pTextNode = pCurrent->GetTextNode(); +auto nParagraphLength = pTextNode->GetText().getLength(); +const OUString& sParagraphText = pTextNode->GetText(); +sal_Int32 nSpaceCount = 0; +sal_Int32 nSpaceStart = 0; +bool bNonSpaceFound = false; +for (sal_Int32 i = 0; i < nParagraphLength; i++) +{ +if (sParagraphText[i] == ' ') +{ +if (bNonSpaceFound) +{ +nSpaceCount++; +if (nSpaceCount == 2) +nSpaceStart = i; +} +} +else +{ +if (nSpaceCount >= 2) +{ +auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_SPACES_SPACE), + sfx::AccessibilityIssueID::TEXT_FORMATTING); +pIssue->setIssueObject(IssueObject::TEXT); +pIssue->setNode(pTextNode); +SwDoc& rDocument = pTextNode->GetDoc(); +pIssue->setDoc(rDocument); +pIssue->setStart(nSpaceStart); +pIssue->setEnd(nSpaceStart + nSpaceCount - 1); +} +
[Libreoffice-commits] core.git: include/sfx2 sw/inc sw/qa sw/source
include/sfx2/AccessibilityIssue.hxx|1 sw/inc/AccessibilityCheckStrings.hrc |1 sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx | 11 +++ sw/qa/core/accessibilitycheck/data/BackgroundImageTest.odt |binary sw/source/core/access/AccessibilityCheck.cxx | 42 + 5 files changed, 55 insertions(+) New commits: commit f9eb59a59723275f7057419d2c05393ac2781972 Author: offtkp AuthorDate: Tue Oct 11 19:02:39 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Sat Oct 15 10:34:28 2022 +0200 a11y: Add check for background image Add accessibility check and relevant test for a document with a background image Change-Id: I7b97cff27af66c2614bfc535d369b17ec048e8d9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141230 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/sfx2/AccessibilityIssue.hxx b/include/sfx2/AccessibilityIssue.hxx index 4cc9a72e7c19..085863cbd405 100644 --- a/include/sfx2/AccessibilityIssue.hxx +++ b/include/sfx2/AccessibilityIssue.hxx @@ -22,6 +22,7 @@ enum class AccessibilityIssueID UNSPECIFIED, // TODO: remove - temporary DOCUMENT_TITLE, DOCUMENT_LANGUAGE, +DOCUMENT_BACKGROUND, STYLE_LANGUAGE, NO_ALT_OLE, NO_ALT_GRAPHIC, diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc index 2c098e50edc8..858de1a47d93 100644 --- a/sw/inc/AccessibilityCheckStrings.hrc +++ b/sw/inc/AccessibilityCheckStrings.hrc @@ -21,6 +21,7 @@ #define STR_TEXT_BLINKING NC_("STR_TEXT_BLINKING", "Blinking text.") #define STR_AVOID_FOOTNOTES NC_("STR_AVOID_FOOTNOTES", "Avoid footnotes.") #define STR_AVOID_ENDNOTES NC_("STR_AVOID_ENDNOTES", "Avoid endnotes.") +#define STR_AVOID_BACKGROUND_IMAGES NC_("STR_AVOID_BACKGROUND_IMAGES", "Avoid background images.") #define STR_HEADINGS_NOT_IN_ORDER NC_("STR_HEADINGS_NOT_IN_ORDER", "Headings not in order.") #define STR_TEXT_FORMATTING_CONVEYS_MEANING NC_("STR_TEXT_FORMATTING_CONVEYS_MEANING", "The text formatting conveys additional meaning.") #define STR_NON_INTERACTIVE_FORMS NC_("STR_NON_INTERACTIVE_FORMS", "An input form is not interactive.") diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx index d7ad7674c13b..2c36d2b5d4e7 100644 --- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx +++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx @@ -59,6 +59,17 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckParagraphIssues) CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[0]->m_eIssueID); } +CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckBackgroundImage) +{ +SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "BackgroundImageTest.odt"); +CPPUNIT_ASSERT(pDoc); +sw::AccessibilityCheck aCheck(pDoc); +aCheck.check(); +auto& aIssues = aCheck.getIssueCollection().getIssues(); +CPPUNIT_ASSERT_EQUAL(size_t(1), aIssues.size()); +CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DOCUMENT_BACKGROUND, aIssues[0]->m_eIssueID); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/accessibilitycheck/data/BackgroundImageTest.odt b/sw/qa/core/accessibilitycheck/data/BackgroundImageTest.odt new file mode 100644 index ..eff6f178394b Binary files /dev/null and b/sw/qa/core/accessibilitycheck/data/BackgroundImageTest.odt differ diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index f6c6ec7b43d5..de0a5bf63472 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -898,6 +899,46 @@ public: } }; +class BackgroundImageCheck : public DocumentCheck +{ +public: +BackgroundImageCheck(sfx::AccessibilityIssueCollection& rIssueCollection) +: DocumentCheck(rIssueCollection) +{ +} +void check(SwDoc* pDoc) override +{ +uno::Reference xDoc = pDoc->GetDocShell()->GetBaseModel(); +uno::Reference xStyleFamiliesSupplier(xDoc, uno::UNO_QUERY); +if (!xStyleFamiliesSupplier.is()) +return; +uno::Reference xStyleFamilies += xStyleFamiliesSupplier->getStyleFamilies(); +uno::Reference xStyleFamily(xStyleFamilies->getByName("PageStyles"), +uno::UNO_QUERY); +if (!xStyleFamily.is()) +return; +const uno::Sequence& xStyleFamilyNames = xStyleFamily->getElementNames(); +for (const OUString& rStyleFamilyName : xStyleFamilyNames) +{ +uno::Reference xPropertySet( +
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx | 13 ++ sw/qa/core/accessibilitycheck/data/ParagraphTest.odt |binary sw/source/core/access/AccessibilityCheck.cxx | 29 +++ 3 files changed, 42 insertions(+) New commits: commit b45867766184ad1200df4183dab537fac9e83ea2 Author: offtkp AuthorDate: Fri Oct 7 17:13:53 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Thu Oct 13 09:20:17 2022 +0200 a11y: Add char attr a11y check for entire paragraph Accessibility check would not work if the entire paragraph had character attributes, because then it wouldn't have individual text hints Now check if there's a SwAttrSet and if it has the a11y char attributes that an issue should be generated for Also add test for this specific case Change-Id: Iee035eecd25ed130e78ed27041c3e56ea988ecc5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141078 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx index 169a3fa03191..d7ad7674c13b 100644 --- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx +++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx @@ -46,6 +46,19 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testTableSplitMergeAndAltText) CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::NO_ALT_SHAPE, aIssues[6]->m_eIssueID); } +CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckParagraphIssues) +{ +// Tests whether formatting issues are detected when the whole paragraph has them instead of +// some text inside the paragraph +SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "ParagraphTest.odt"); +CPPUNIT_ASSERT(pDoc); +sw::AccessibilityCheck aCheck(pDoc); +aCheck.check(); +auto& aIssues = aCheck.getIssueCollection().getIssues(); +CPPUNIT_ASSERT_EQUAL(size_t(1), aIssues.size()); +CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[0]->m_eIssueID); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/accessibilitycheck/data/ParagraphTest.odt b/sw/qa/core/accessibilitycheck/data/ParagraphTest.odt new file mode 100644 index ..766ecd0b4e2e Binary files /dev/null and b/sw/qa/core/accessibilitycheck/data/ParagraphTest.odt differ diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index 50a37dc00bef..f6c6ec7b43d5 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -551,6 +551,35 @@ public: } } } +else if (pTextNode->HasSwAttrSet()) +{ +// Paragraph doesn't have hints but the entire paragraph might have char attributes +auto& aSwAttrSet = pTextNode->GetSwAttrSet(); +auto nParagraphLength = pTextNode->GetText().getLength(); +if (nParagraphLength == 0) +return; +if (aSwAttrSet.HasItem(RES_CHRATR_WEIGHT) || aSwAttrSet.HasItem(RES_CHRATR_CJK_WEIGHT) +|| aSwAttrSet.HasItem(RES_CHRATR_CTL_WEIGHT) +|| aSwAttrSet.HasItem(RES_CHRATR_POSTURE) +|| aSwAttrSet.HasItem(RES_CHRATR_CJK_POSTURE) +|| aSwAttrSet.HasItem(RES_CHRATR_CTL_POSTURE) +|| aSwAttrSet.HasItem(RES_CHRATR_SHADOWED) || aSwAttrSet.HasItem(RES_CHRATR_COLOR) +|| aSwAttrSet.HasItem(RES_CHRATR_EMPHASIS_MARK) +|| aSwAttrSet.HasItem(RES_CHRATR_UNDERLINE) +|| aSwAttrSet.HasItem(RES_CHRATR_OVERLINE) +|| aSwAttrSet.HasItem(RES_CHRATR_CROSSEDOUT) +|| aSwAttrSet.HasItem(RES_CHRATR_RELIEF) || aSwAttrSet.HasItem(RES_CHRATR_CONTOUR)) +{ +auto pIssue += lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_FORMATTING_CONVEYS_MEANING), + sfx::AccessibilityIssueID::TEXT_FORMATTING); +pIssue->setIssueObject(IssueObject::TEXT); +pIssue->setNode(pTextNode); +SwDoc& rDocument = pTextNode->GetDoc(); +pIssue->setDoc(rDocument); +pIssue->setEnd(nParagraphLength); +} +} } };
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/GraphicFormatDetector.cxx | 28 +++- 1 file changed, 15 insertions(+), 13 deletions(-) New commits: commit 8ad101aaca50001a825f89fb330f5474965aa1fd Author: offtkp AuthorDate: Wed Sep 14 23:34:01 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Thu Sep 15 12:41:23 2022 +0200 Revert removed lines and remove unused vars in GraphicFormatDetector Also removed now pointless line making stream seek back to start as a SeekGuard exists now Change-Id: I82e8e6852b47176fff8aae3e7d7b0e7d5c533b40 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139956 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index bfb3da3ac861..a0cdd2416c57 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -431,6 +431,7 @@ bool GraphicFormatDetector::checkMET() mrStream.Seek(mnStreamPosition); sal_uInt16 nFieldSize; sal_uInt8 nMagic; + mrStream.ReadUInt16(nFieldSize).ReadUChar(nMagic); for (int i = 0; i < 3; i++) { @@ -444,8 +445,10 @@ bool GraphicFormatDetector::checkMET() return false; } mrStream.SetEndian(SvStreamEndian::LITTLE); + if (mrStream.GetError()) return false; + maMetadata.mnFormat = GraphicFileFormat::MET; return true; } @@ -481,8 +484,10 @@ bool GraphicFormatDetector::checkBMP() sal_uInt32 nTemp32; sal_uInt16 nTemp16; sal_uInt32 nCompression; + mrStream.SetEndian(SvStreamEndian::LITTLE); mrStream.Seek(mnStreamPosition + nOffset + 2); + // up to first info mrStream.SeekRel(0x10); @@ -623,8 +628,7 @@ bool GraphicFormatDetector::checkPCX() // We must detect the whole header. bool bRet = false; sal_uInt8 cByte = 0; -auto nStmPos = mrStream.Tell(); -SeekGuard aGuard(mrStream, nStmPos); +SeekGuard aGuard(mrStream, mrStream.Tell()); mrStream.SetEndian(SvStreamEndian::LITTLE); mrStream.ReadUChar(cByte); if (cByte == 0x0a) @@ -686,8 +690,7 @@ bool GraphicFormatDetector::checkPCX() bool GraphicFormatDetector::checkTIF() { -auto nStmPos = mrStream.Tell(); -SeekGuard aGuard(mrStream, nStmPos); +SeekGuard aGuard(mrStream, mrStream.Tell()); mrStream.Seek(mnStreamPosition); bool bRet = false; sal_uInt8 cByte1 = 0; @@ -955,8 +958,7 @@ bool GraphicFormatDetector::checkSVM() { sal_uInt32 n32 = 0; bool bRet = false; -auto nStmPos = mrStream.Tell(); -SeekGuard aGuard(mrStream, nStmPos); +SeekGuard aGuard(mrStream, mrStream.Tell()); mrStream.SetEndian(SvStreamEndian::LITTLE); mrStream.ReadUInt32(n32); if (n32 == 0x44475653) @@ -1035,6 +1037,7 @@ bool GraphicFormatDetector::checkPCD() SeekGuard aGuard(mrStream, mnStreamPosition); mrStream.Seek(mnStreamPosition + 2048); sBuffer[mrStream.ReadBytes(sBuffer, 7)] = 0; + if (strncmp(sBuffer, "PCD_IPI", 7) == 0) { maMetadata.mnFormat = GraphicFileFormat::PCD; @@ -1158,8 +1161,7 @@ bool GraphicFormatDetector::checkPCT() bool GraphicFormatDetector::checkPBM() { -auto nStmPos = mrStream.Tell(); -SeekGuard aGuard(mrStream, nStmPos); +SeekGuard aGuard(mrStream, mrStream.Tell()); sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0; mrStream.ReadUChar(nFirst).ReadUChar(nSecond).ReadUChar(nThird); if (nFirst == 'P' && ((nSecond == '1') || (nSecond == '4')) && isspace(nThird)) @@ -1173,8 +1175,7 @@ bool GraphicFormatDetector::checkPBM() bool GraphicFormatDetector::checkPGM() { sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0; -auto nStmPos = mrStream.Tell(); -SeekGuard aGuard(mrStream, nStmPos); +SeekGuard aGuard(mrStream, mrStream.Tell()); mrStream.ReadUChar(nFirst).ReadUChar(nSecond).ReadUChar(nThird); if (nFirst == 'P' && ((nSecond == '2') || (nSecond == '5')) && isspace(nThird)) { @@ -1187,8 +1188,7 @@ bool GraphicFormatDetector::checkPGM() bool GraphicFormatDetector::checkPPM() { sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0; -auto nStmPos = mrStream.Tell(); -SeekGuard aGuard(mrStream, nStmPos); +SeekGuard aGuard(mrStream, mrStream.Tell()); mrStream.ReadUChar(nFirst).ReadUChar(nSecond).ReadUChar(nThird); if (nFirst == 'P' && ((nSecond == '3') || (nSecond == '6')) && isspace(nThird)) { @@ -1223,10 +1223,13 @@ bool GraphicFormatDetector::checkXBM() { sal_uInt64 nSize = std::min(mnStreamLength, 2048); std::unique_ptr pBuffer(new sal_uInt8[nSize]); + SeekGuard aGuard(mrStream, mnStreamPosition); mrStream.Seek(mnStreamPosition); nSize = mrStream.ReadBytes(pBuffer.get(), nSize); + const char* pBufferAsCharArray = reinterpret_cast(pBuffer.get()); + if (checkArrayForMatchingStrings(pBufferAsCharArray,
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/graphicfilter2.cxx | 69 +++ 1 file changed, 23 insertions(+), 46 deletions(-) New commits: commit a9b3f25aa6b8fced74f39416652c27284dd7681d Author: offtkp AuthorDate: Wed Sep 14 23:33:27 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Thu Sep 15 12:40:56 2022 +0200 Allow functions to short-circuit in graphicfilter2.cxx Change-Id: I5b86bd53d1fc68804970deba9d40f02861a1975b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139955 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 1146acb9d6c6..fa5c25e30c93 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -120,8 +120,7 @@ void GraphicDescriptor::ImpConstruct() bool GraphicDescriptor::ImpDetectBMP( SvStream& rStm, bool bExtendedInfo ) { vcl::GraphicFormatDetector aDetector( rStm, aPathExt, bExtendedInfo ); -bool bRet = aDetector.detect(); -bRet &= aDetector.checkBMP(); +bool bRet = aDetector.detect() && aDetector.checkBMP(); if ( bRet ) aMetadata = aDetector.getMetadata(); return bRet; @@ -130,8 +129,7 @@ bool GraphicDescriptor::ImpDetectBMP( SvStream& rStm, bool bExtendedInfo ) bool GraphicDescriptor::ImpDetectGIF( SvStream& rStm, bool bExtendedInfo ) { vcl::GraphicFormatDetector aDetector( rStm, aPathExt, bExtendedInfo ); -bool bRet = aDetector.detect(); -bRet &= aDetector.checkGIF(); +bool bRet = aDetector.detect() && aDetector.checkGIF(); if ( bRet ) aMetadata = aDetector.getMetadata(); return bRet; @@ -333,8 +331,7 @@ bool GraphicDescriptor::ImpDetectJPG( SvStream& rStm, bool bExtendedInfo ) bool GraphicDescriptor::ImpDetectPCD( SvStream& rStm, bool ) { vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /*bExtendedInfo*/ ); -bool bRet = aDetector.detect(); -bRet &= aDetector.checkPCD(); +bool bRet = aDetector.detect() && aDetector.checkPCD(); if ( bRet ) aMetadata = aDetector.getMetadata(); return bRet; @@ -343,8 +340,7 @@ bool GraphicDescriptor::ImpDetectPCD( SvStream& rStm, bool ) bool GraphicDescriptor::ImpDetectPCX( SvStream& rStm ) { vcl::GraphicFormatDetector aDetector( rStm, aPathExt, true /*bExtendedInfo*/ ); -bool bRet = aDetector.detect(); -bRet &= aDetector.checkPCX(); +bool bRet = aDetector.detect() && aDetector.checkPCX(); if ( bRet ) aMetadata = aDetector.getMetadata(); return bRet; @@ -353,8 +349,7 @@ bool GraphicDescriptor::ImpDetectPCX( SvStream& rStm ) bool GraphicDescriptor::ImpDetectPNG( SvStream& rStm, bool bExtendedInfo ) { vcl::GraphicFormatDetector aDetector( rStm, aPathExt, bExtendedInfo ); -bool bRet = aDetector.detect(); -bRet &= aDetector.checkPNG(); +bool bRet = aDetector.detect() && aDetector.checkPNG(); if ( bRet ) aMetadata = aDetector.getMetadata(); return bRet; @@ -363,8 +358,7 @@ bool GraphicDescriptor::ImpDetectPNG( SvStream& rStm, bool bExtendedInfo ) bool GraphicDescriptor::ImpDetectTIF( SvStream& rStm, bool bExtendedInfo ) { vcl::GraphicFormatDetector aDetector( rStm, aPathExt, bExtendedInfo ); -bool bRet = aDetector.detect(); -bRet &= aDetector.checkTIF(); +bool bRet = aDetector.detect() && aDetector.checkTIF(); if ( bRet ) aMetadata = aDetector.getMetadata(); return bRet; @@ -373,8 +367,7 @@ bool GraphicDescriptor::ImpDetectTIF( SvStream& rStm, bool bExtendedInfo ) bool GraphicDescriptor::ImpDetectXBM( SvStream& rStm, bool ) { vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /* bExtendedInfo */ ); -bool bRet = aDetector.detect(); -bRet &= aDetector.checkXBM(); +bool bRet = aDetector.detect() && aDetector.checkXBM(); if ( bRet ) aMetadata = aDetector.getMetadata(); return bRet; @@ -383,8 +376,7 @@ bool GraphicDescriptor::ImpDetectXBM( SvStream& rStm, bool ) bool GraphicDescriptor::ImpDetectXPM( SvStream& rStm, bool ) { vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /* bExtendedInfo */ ); -bool bRet = aDetector.detect(); -bRet &= aDetector.checkXPM(); +bool bRet = aDetector.detect() && aDetector.checkXPM(); if ( bRet ) aMetadata = aDetector.getMetadata(); return bRet; @@ -393,8 +385,7 @@ bool GraphicDescriptor::ImpDetectXPM( SvStream& rStm, bool ) bool GraphicDescriptor::ImpDetectPBM( SvStream& rStm, bool ) { vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /* bExtendedInfo */ ); -bool bRet = aDetector.detect(); -bRet &= aDetector.checkPBM(); +bool bRet = aDetector.detect() && aDetector.checkPBM(); if ( bRet ) aMetadata = aDetector.getMetadata(); return bRet; @@ -403,8 +394,7 @@ bool GraphicDescriptor::ImpDetectPBM( SvStream& rStm, bool ) bool GraphicDescriptor::ImpDetectPGM( SvStream& rStm, bool )
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/GraphicFormatDetector.cxx | 71 ++--- vcl/source/filter/graphicfilter2.cxx| 77 +--- 2 files changed, 67 insertions(+), 81 deletions(-) New commits: commit a809d89307ecfdc00fd6dcda96c53986189f35ef Author: offtkp AuthorDate: Fri Sep 2 22:40:09 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Thu Sep 15 08:46:52 2022 +0200 Remove code duplication in GraphicDescriptor for PCX GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for PCX files Change-Id: Ib4c9ca98c420b313fd3483272a7844d98ea227dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139274 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index 5ae7d5fb67d2..bfb3da3ac861 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -617,18 +617,71 @@ bool GraphicFormatDetector::checkEMF() bool GraphicFormatDetector::checkPCX() { -if (maFirstBytes[0] != 0x0a) -return false; - -sal_uInt8 nVersion = maFirstBytes[1]; -sal_uInt8 nEncoding = maFirstBytes[2]; -if ((nVersion == 0 || nVersion == 2 || nVersion == 3 || nVersion == 5) && nEncoding <= 1) +// ! Because 0x0a can be interpreted as LF too ... +// we can't be sure that this special sign represent a PCX file only. +// Every Ascii file is possible here :-( +// We must detect the whole header. +bool bRet = false; +sal_uInt8 cByte = 0; +auto nStmPos = mrStream.Tell(); +SeekGuard aGuard(mrStream, nStmPos); +mrStream.SetEndian(SvStreamEndian::LITTLE); +mrStream.ReadUChar(cByte); +if (cByte == 0x0a) { maMetadata.mnFormat = GraphicFileFormat::PCX; -return true; -} +mrStream.SeekRel(1); +// compression +mrStream.ReadUChar(cByte); +bRet = (cByte == 0 || cByte == 1); +if (bRet) +{ +sal_uInt16 nTemp16; +sal_uInt16 nXmin; +sal_uInt16 nXmax; +sal_uInt16 nYmin; +sal_uInt16 nYmax; +sal_uInt16 nDPIx; +sal_uInt16 nDPIy; + +// Bits/Pixel +mrStream.ReadUChar(cByte); +maMetadata.mnBitsPerPixel = cByte; + +// image dimensions +mrStream.ReadUInt16(nTemp16); +nXmin = nTemp16; +mrStream.ReadUInt16(nTemp16); +nYmin = nTemp16; +mrStream.ReadUInt16(nTemp16); +nXmax = nTemp16; +mrStream.ReadUInt16(nTemp16); +nYmax = nTemp16; -return false; +maMetadata.maPixSize.setWidth(nXmax - nXmin + 1); +maMetadata.maPixSize.setHeight(nYmax - nYmin + 1); + +// resolution +mrStream.ReadUInt16(nTemp16); +nDPIx = nTemp16; +mrStream.ReadUInt16(nTemp16); +nDPIy = nTemp16; + +// set logical size +MapMode aMap(MapUnit::MapInch, Point(), Fraction(1, nDPIx), Fraction(1, nDPIy)); +maMetadata.maLogSize = OutputDevice::LogicToLogic(maMetadata.maPixSize, aMap, + MapMode(MapUnit::Map100thMM)); + +// number of color planes +cByte = 5; // Illegal value in case of EOF. +mrStream.SeekRel(49); +mrStream.ReadUChar(cByte); +maMetadata.mnPlanes = cByte; + +bRet = (maMetadata.mnPlanes <= 4); +} +} +return bRet; } bool GraphicFormatDetector::checkTIF() diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 9cda65957aa2..1146acb9d6c6 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -342,78 +342,11 @@ bool GraphicDescriptor::ImpDetectPCD( SvStream& rStm, bool ) bool GraphicDescriptor::ImpDetectPCX( SvStream& rStm ) { -// ! Because 0x0a can be interpreted as LF too ... -// we can't be sure that this special sign represent a PCX file only. -// Every Ascii file is possible here :-( -// We must detect the whole header. - -boolbRet = false; -sal_uInt8 cByte = 0; - -sal_Int32 nStmPos = rStm.Tell(); -rStm.SetEndian( SvStreamEndian::LITTLE ); -rStm.ReadUChar( cByte ); - -if ( cByte == 0x0a ) -{ -aMetadata.mnFormat = GraphicFileFormat::PCX; - -rStm.SeekRel( 1 ); - -// compression -rStm.ReadUChar( cByte ); - -bRet = (cByte==0 || cByte ==1); -if (bRet) -{ -sal_uInt16 nTemp16; -sal_uInt16 nXmin; -sal_uInt16 nXmax; -sal_uInt16 nYmin; -sal_uInt16 nYmax; -sal_uInt16 nDPIx; -
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/GraphicFormatDetector.cxx | 84 +--- vcl/source/filter/graphicfilter2.cxx| 44 -- 2 files changed, 52 insertions(+), 76 deletions(-) New commits: commit 5510a77f2c926770dbc312db252a035c7afbe7b3 Author: offtkp AuthorDate: Sat Aug 27 22:27:35 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Wed Sep 14 13:26:08 2022 +0200 Return to starting stream position after checking format After checking a format now return to starting format position in GraphicFormatDetector. Change-Id: Iaaeb2590f3d4928fbfba3f5386cb53e87ca16905 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138936 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index 219915957101..5ae7d5fb67d2 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -35,6 +35,24 @@ constexpr sal_uInt32 SVG_CHECK_SIZE = 2048; constexpr sal_uInt32 WMF_EMF_CHECK_SIZE = 44; constexpr sal_uInt32 DATA_SIZE = 640; +namespace +{ +class SeekGuard +{ +public: +SeekGuard(SvStream& rStream, sal_uInt64 nStartPosition) +: mrStream(rStream) +, mnStartPosition(nStartPosition) +{ +} +~SeekGuard() { mrStream.Seek(mnStartPosition); } + +private: +SvStream& mrStream; +sal_uInt64 mnStartPosition; +}; +} + namespace vcl { bool peekGraphicFormat(SvStream& rStream, OUString& rFormatExtension, bool bTest) @@ -367,6 +385,7 @@ bool GraphicFormatDetector::detect() mnStreamPosition = mrStream.Tell(); mnStreamLength = mrStream.remainingSize(); +SeekGuard aGuard(mrStream, mnStreamPosition); if (!mnStreamLength) { @@ -407,11 +426,11 @@ bool GraphicFormatDetector::checkMET() { if (maFirstBytes[2] != 0xd3) return false; +SeekGuard aGuard(mrStream, mnStreamPosition); mrStream.SetEndian(SvStreamEndian::BIG); mrStream.Seek(mnStreamPosition); sal_uInt16 nFieldSize; sal_uInt8 nMagic; - mrStream.ReadUInt16(nFieldSize).ReadUChar(nMagic); for (int i = 0; i < 3; i++) { @@ -425,16 +444,15 @@ bool GraphicFormatDetector::checkMET() return false; } mrStream.SetEndian(SvStreamEndian::LITTLE); - if (mrStream.GetError()) return false; - maMetadata.mnFormat = GraphicFileFormat::MET; return true; } bool GraphicFormatDetector::checkBMP() { +SeekGuard aGuard(mrStream, mnStreamPosition); bool bRet = false; sal_uInt8 nOffset; @@ -463,10 +481,8 @@ bool GraphicFormatDetector::checkBMP() sal_uInt32 nTemp32; sal_uInt16 nTemp16; sal_uInt32 nCompression; - mrStream.SetEndian(SvStreamEndian::LITTLE); mrStream.Seek(mnStreamPosition + nOffset + 2); - // up to first info mrStream.SeekRel(0x10); @@ -617,12 +633,13 @@ bool GraphicFormatDetector::checkPCX() bool GraphicFormatDetector::checkTIF() { +auto nStmPos = mrStream.Tell(); +SeekGuard aGuard(mrStream, nStmPos); mrStream.Seek(mnStreamPosition); bool bRet = false; sal_uInt8 cByte1 = 0; sal_uInt8 cByte2 = 1; -sal_Int32 nStmPos = mrStream.Tell(); mrStream.ReadUChar(cByte1); mrStream.ReadUChar(cByte2); if (cByte1 == cByte2) @@ -741,7 +758,6 @@ bool GraphicFormatDetector::checkTIF() } } } -mrStream.Seek(nStmPos); return bRet; } @@ -765,6 +781,7 @@ bool GraphicFormatDetector::checkGIF() bool GraphicFormatDetector::checkPNG() { +SeekGuard aGuard(mrStream, mnStreamPosition); if (mnFirstLong == 0x89504e47 && mnSecondLong == 0x0d0a1a0a) { maMetadata.mnFormat = GraphicFileFormat::PNG; @@ -885,8 +902,8 @@ bool GraphicFormatDetector::checkSVM() { sal_uInt32 n32 = 0; bool bRet = false; - -sal_Int32 nStmPos = mrStream.Tell(); +auto nStmPos = mrStream.Tell(); +SeekGuard aGuard(mrStream, nStmPos); mrStream.SetEndian(SvStreamEndian::LITTLE); mrStream.ReadUInt32(n32); if (n32 == 0x44475653) @@ -954,7 +971,6 @@ bool GraphicFormatDetector::checkSVM() } } } -mrStream.Seek(nStmPos); return bRet; } @@ -963,9 +979,9 @@ bool GraphicFormatDetector::checkPCD() if (mnStreamLength < 2055) return false; char sBuffer[8]; +SeekGuard aGuard(mrStream, mnStreamPosition); mrStream.Seek(mnStreamPosition + 2048); sBuffer[mrStream.ReadBytes(sBuffer, 7)] = 0; - if (strncmp(sBuffer, "PCD_IPI", 7) == 0) { maMetadata.mnFormat = GraphicFileFormat::PCD; @@ -976,6 +992,7 @@ bool GraphicFormatDetector::checkPCD() bool GraphicFormatDetector::checkPSD() { +SeekGuard aGuard(mrStream, mnStreamPosition); bool bRet = false; if ((mnFirstLong == 0x38425053) && ((mnSecondLong >> 16) == 1))
[Libreoffice-commits] core.git: vcl/inc vcl/source
vcl/inc/graphic/GraphicFormatDetector.hxx |4 + vcl/source/filter/GraphicFormatDetector.cxx | 63 -- vcl/source/filter/graphicfilter2.cxx| 67 +++- 3 files changed, 61 insertions(+), 73 deletions(-) New commits: commit 868fb06a2ef8f915350c77f0d63c03844fc33f62 Author: offtkp AuthorDate: Thu Aug 25 22:33:04 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Wed Sep 14 13:25:26 2022 +0200 Remove code duplication in GraphicDescriptor for PBM/PGM/PPM GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for PBM/PGM/PPM files Change-Id: Ib239bb0aafcfa691d63025d5965f199bf11c7649 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138847 Reviewed-by: Tomaž Vajngerl Tested-by: Tomaž Vajngerl diff --git a/vcl/inc/graphic/GraphicFormatDetector.hxx b/vcl/inc/graphic/GraphicFormatDetector.hxx index 103519b6870c..64d1e74de80a 100644 --- a/vcl/inc/graphic/GraphicFormatDetector.hxx +++ b/vcl/inc/graphic/GraphicFormatDetector.hxx @@ -170,7 +170,9 @@ public: bool checkEPS(); bool checkDXF(); bool checkPCT(); -bool checkPBMorPGMorPPM(); +bool checkPBM(); +bool checkPGM(); +bool checkPPM(); bool checkRAS(); bool checkXPM(); bool checkXBM(); diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index 30573bf9b885..219915957101 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -199,7 +199,7 @@ bool peekGraphicFormat(SvStream& rStream, OUString& rFormatExtension, bool bTest || rFormatExtension.startsWith("PPM")) { bSomethingTested = true; -if (aDetector.checkPBMorPGMorPPM()) +if (aDetector.checkPBM() || aDetector.checkPGM() || aDetector.checkPPM()) { rFormatExtension = getImportFormatShortName(aDetector.getMetadata().mnFormat); return true; @@ -1085,29 +1085,46 @@ bool GraphicFormatDetector::checkPCT() return false; } -bool GraphicFormatDetector::checkPBMorPGMorPPM() +bool GraphicFormatDetector::checkPBM() { -if (maFirstBytes[0] == 'P') -{ -switch (maFirstBytes[1]) -{ -case '1': -case '4': -maMetadata.mnFormat = GraphicFileFormat::PBM; -return true; - -case '2': -case '5': -maMetadata.mnFormat = GraphicFileFormat::PGM; -return true; - -case '3': -case '6': -maMetadata.mnFormat = GraphicFileFormat::PPM; -return true; -} -} -return false; +bool bRet = false; +sal_Int32 nStmPos = mrStream.Tell(); +sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0; +mrStream.ReadUChar(nFirst).ReadUChar(nSecond).ReadUChar(nThird); +if (nFirst == 'P' && ((nSecond == '1') || (nSecond == '4')) && isspace(nThird)) +bRet = true; +mrStream.Seek(nStmPos); +if (bRet) +maMetadata.mnFormat = GraphicFileFormat::PBM; +return bRet; +} + +bool GraphicFormatDetector::checkPGM() +{ +bool bRet = false; +sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0; +sal_Int32 nStmPos = mrStream.Tell(); +mrStream.ReadUChar(nFirst).ReadUChar(nSecond).ReadUChar(nThird); +if (nFirst == 'P' && ((nSecond == '2') || (nSecond == '5')) && isspace(nThird)) +bRet = true; +mrStream.Seek(nStmPos); +if (bRet) +maMetadata.mnFormat = GraphicFileFormat::PGM; +return bRet; +} + +bool GraphicFormatDetector::checkPPM() +{ +bool bRet = false; +sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0; +sal_Int32 nStmPos = mrStream.Tell(); +mrStream.ReadUChar(nFirst).ReadUChar(nSecond).ReadUChar(nThird); +if (nFirst == 'P' && ((nSecond == '3') || (nSecond == '6')) && isspace(nThird)) +bRet = true; +mrStream.Seek(nStmPos); +if (bRet) +maMetadata.mnFormat = GraphicFileFormat::PPM; +return bRet; } bool GraphicFormatDetector::checkRAS() diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 6d051458ccbd..42dd8816563f 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -473,68 +473,37 @@ bool GraphicDescriptor::ImpDetectXPM( SvStream& rStm, bool ) bool GraphicDescriptor::ImpDetectPBM( SvStream& rStm, bool ) { -bool bRet = false; - -// check file extension first, as this trumps the 2 ID bytes -if ( aPathExt.startsWith( "pbm" ) ) -bRet = true; -else -{ -sal_Int32 nStmPos = rStm.Tell(); -sal_uInt8 nFirst = 0, nSecond = 0; -rStm.ReadUChar( nFirst ).ReadUChar( nSecond ); -if ( nFirst == 'P' && ( ( nSecond == '1' ) || ( nSecond == '4' ) ) ) -
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/GraphicFormatDetector.cxx | 79 +--- vcl/source/filter/graphicfilter2.cxx| 75 +- 2 files changed, 76 insertions(+), 78 deletions(-) New commits: commit f438fd7e25254db8f501b86cdf37970194897e8f Author: offtkp AuthorDate: Tue Aug 23 20:04:16 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Mon Sep 5 09:56:49 2022 +0200 Remove code duplication in GraphicDescriptor for SVM GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for SVM files Change-Id: I459ac1a3301ba8a4d423620c0c6977272fdbb384 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138740 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index 9c9529f261a9..30573bf9b885 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include constexpr sal_uInt32 SVG_CHECK_SIZE = 2048; @@ -881,18 +883,79 @@ bool GraphicFormatDetector::checkJPG() bool GraphicFormatDetector::checkSVM() { -if (mnFirstLong == 0x53564744 && maFirstBytes[4] == 0x49) +sal_uInt32 n32 = 0; +bool bRet = false; + +sal_Int32 nStmPos = mrStream.Tell(); +mrStream.SetEndian(SvStreamEndian::LITTLE); +mrStream.ReadUInt32(n32); +if (n32 == 0x44475653) { -maMetadata.mnFormat = GraphicFileFormat::SVM; -return true; +sal_uInt8 cByte = 0; +mrStream.ReadUChar(cByte); +if (cByte == 0x49) +{ +maMetadata.mnFormat = GraphicFileFormat::SVM; +bRet = true; + +if (mbExtendedInfo) +{ +sal_uInt32 nTemp32; +sal_uInt16 nTemp16; + +mrStream.SeekRel(0x04); + +// width +nTemp32 = 0; +mrStream.ReadUInt32(nTemp32); +maMetadata.maLogSize.setWidth(nTemp32); + +// height +nTemp32 = 0; +mrStream.ReadUInt32(nTemp32); +maMetadata.maLogSize.setHeight(nTemp32); + +// read MapUnit and determine PrefSize +nTemp16 = 0; +mrStream.ReadUInt16(nTemp16); +maMetadata.maLogSize = OutputDevice::LogicToLogic( +maMetadata.maLogSize, MapMode(static_cast(nTemp16)), +MapMode(MapUnit::Map100thMM)); +} +} } -else if (maFirstBytes[0] == 0x56 && maFirstBytes[1] == 0x43 && maFirstBytes[2] == 0x4C - && maFirstBytes[3] == 0x4D && maFirstBytes[4] == 0x54 && maFirstBytes[5] == 0x46) +else { -maMetadata.mnFormat = GraphicFileFormat::SVM; -return true; +mrStream.SeekRel(-4); +n32 = 0; +mrStream.ReadUInt32(n32); + +if (n32 == 0x4D4C4356) +{ +sal_uInt16 nTmp16 = 0; + +mrStream.ReadUInt16(nTmp16); + +if (nTmp16 == 0x4654) +{ +maMetadata.mnFormat = GraphicFileFormat::SVM; +bRet = true; + +if (mbExtendedInfo) +{ +MapMode aMapMode; +mrStream.SeekRel(0x06); +TypeSerializer aSerializer(mrStream); +aSerializer.readMapMode(aMapMode); +aSerializer.readSize(maMetadata.maLogSize); +maMetadata.maLogSize = OutputDevice::LogicToLogic( +maMetadata.maLogSize, aMapMode, MapMode(MapUnit::Map100thMM)); +} +} +} } -return false; +mrStream.Seek(nStmPos); +return bRet; } bool GraphicFormatDetector::checkPCD() diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index eb4f80d8a526..6d051458ccbd 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -625,76 +624,12 @@ bool GraphicDescriptor::ImpDetectPCT( SvStream& rStm, bool ) bool GraphicDescriptor::ImpDetectSVM( SvStream& rStm, bool bExtendedInfo ) { -sal_uInt32 n32 = 0; -boolbRet = false; - sal_Int32 nStmPos = rStm.Tell(); -rStm.SetEndian( SvStreamEndian::LITTLE ); -rStm.ReadUInt32( n32 ); -if ( n32 == 0x44475653 ) -{ -sal_uInt8 cByte = 0; -rStm.ReadUChar( cByte ); -if ( cByte == 0x49 ) -{ -aMetadata.mnFormat = GraphicFileFormat::SVM; -bRet = true; - -if ( bExtendedInfo ) -{ -sal_uInt32 nTemp32; -sal_uInt16
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/GraphicFormatDetector.cxx | 129 +++- vcl/source/filter/graphicfilter2.cxx| 128 +-- 2 files changed, 130 insertions(+), 127 deletions(-) New commits: commit 2d27ce875546f19054a8ba39a87fb07a5337216d Author: offtkp AuthorDate: Tue Aug 23 15:43:43 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Mon Sep 5 09:56:17 2022 +0200 Remove code duplication in GraphicDescriptor for TIF GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for TIF files Change-Id: Ia55b1606df5171dc41d94d19262a83910bd024a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138730 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index 8956c3cd9530..9c9529f261a9 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -31,6 +31,7 @@ constexpr sal_uInt32 SVG_CHECK_SIZE = 2048; constexpr sal_uInt32 WMF_EMF_CHECK_SIZE = 44; +constexpr sal_uInt32 DATA_SIZE = 640; namespace vcl { @@ -614,12 +615,132 @@ bool GraphicFormatDetector::checkPCX() bool GraphicFormatDetector::checkTIF() { -if (mnFirstLong == 0x49492a00 || mnFirstLong == 0x4d4d002a) +mrStream.Seek(mnStreamPosition); +bool bRet = false; +sal_uInt8 cByte1 = 0; +sal_uInt8 cByte2 = 1; + +sal_Int32 nStmPos = mrStream.Tell(); +mrStream.ReadUChar(cByte1); +mrStream.ReadUChar(cByte2); +if (cByte1 == cByte2) { -maMetadata.mnFormat = GraphicFileFormat::TIF; -return true; +bool bDetectOk = false; + +if (cByte1 == 0x49) +{ +mrStream.SetEndian(SvStreamEndian::LITTLE); +bDetectOk = true; +} +else if (cByte1 == 0x4d) +{ +mrStream.SetEndian(SvStreamEndian::BIG); +bDetectOk = true; +} + +if (bDetectOk) +{ +sal_uInt16 nTemp16 = 0; + +mrStream.ReadUInt16(nTemp16); +if (nTemp16 == 0x2a) +{ +maMetadata.mnFormat = GraphicFileFormat::TIF; +bRet = true; + +if (mbExtendedInfo) +{ +sal_uLong nCount; +sal_uLong nMax = DATA_SIZE - 48; +sal_uInt32 nTemp32 = 0; + +// Offset of the first IFD +mrStream.ReadUInt32(nTemp32); +nCount = nTemp32 + 2; +mrStream.SeekRel(nCount - 0x08); + +if (nCount < nMax) +{ +bool bOk = false; + +// read tags till we find Tag256 ( Width ) +// do not read more bytes than DATA_SIZE +mrStream.ReadUInt16(nTemp16); +while (nTemp16 != 256) +{ +bOk = nCount < nMax; +if (!bOk) +{ +break; +} +mrStream.SeekRel(10); +mrStream.ReadUInt16(nTemp16); +nCount += 12; +} + +if (bOk) +{ +// width +mrStream.ReadUInt16(nTemp16); +mrStream.SeekRel(4); +if (nTemp16 == 3) +{ +mrStream.ReadUInt16(nTemp16); +maMetadata.maPixSize.setWidth(nTemp16); +mrStream.SeekRel(2); +} +else +{ +mrStream.ReadUInt32(nTemp32); +maMetadata.maPixSize.setWidth(nTemp32); +} + +// height +mrStream.SeekRel(2); +mrStream.ReadUInt16(nTemp16); +mrStream.SeekRel(4); +if (nTemp16 == 3) +{ +mrStream.ReadUInt16(nTemp16); +maMetadata.maPixSize.setHeight(nTemp16); +mrStream.SeekRel(2); +} +else +{ +mrStream.ReadUInt32(nTemp32); +maMetadata.maPixSize.setHeight(nTemp32); +} + +
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/GraphicFormatDetector.cxx | 40 +- vcl/source/filter/graphicfilter2.cxx| 50 ++-- 2 files changed, 42 insertions(+), 48 deletions(-) New commits: commit 86d49f41d46519235b55918ac375bc1d2b99552b Author: offtkp AuthorDate: Sat Aug 13 12:52:26 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Mon Aug 22 18:05:29 2022 +0200 Remove code duplication in GraphicDescriptor for PSD GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for PSD files Change-Id: Icae532a7143477dada411224293250a26676c684 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138227 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index 5b5ccf33d004..8956c3cd9530 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -792,12 +792,48 @@ bool GraphicFormatDetector::checkPCD() bool GraphicFormatDetector::checkPSD() { +bool bRet = false; if ((mnFirstLong == 0x38425053) && ((mnSecondLong >> 16) == 1)) { maMetadata.mnFormat = GraphicFileFormat::PSD; -return true; +bRet = true; +if (mbExtendedInfo) +{ +sal_uInt16 nChannels = 0; +sal_uInt32 nRows = 0; +sal_uInt32 nColumns = 0; +sal_uInt16 nDepth = 0; +sal_uInt16 nMode = 0; +mrStream.Seek(mnStreamPosition + 6); +mrStream.SeekRel(6); // Pad +mrStream.ReadUInt16(nChannels) +.ReadUInt32(nRows) +.ReadUInt32(nColumns) +.ReadUInt16(nDepth) +.ReadUInt16(nMode); +if ((nDepth == 1) || (nDepth == 8) || (nDepth == 16)) +{ +maMetadata.mnBitsPerPixel = (nDepth == 16) ? 8 : nDepth; +switch (nChannels) +{ +case 4: +case 3: +maMetadata.mnBitsPerPixel = 24; +[[fallthrough]]; +case 2: +case 1: +maMetadata.maPixSize.setWidth(nColumns); +maMetadata.maPixSize.setHeight(nRows); +break; +default: +bRet = false; +} +} +else +bRet = false; +} } -return false; +return bRet; } bool GraphicFormatDetector::checkEPS() diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 4327ef5e2f59..1117b2cc9cbb 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -683,54 +683,12 @@ bool GraphicDescriptor::ImpDetectTGA( SvStream& rStm, bool ) bool GraphicDescriptor::ImpDetectPSD( SvStream& rStm, bool bExtendedInfo ) { -bool bRet = false; - -sal_uInt32 nMagicNumber = 0; sal_Int32 nStmPos = rStm.Tell(); -rStm.SetEndian( SvStreamEndian::BIG ); -rStm.ReadUInt32( nMagicNumber ); -if ( nMagicNumber == 0x38425053 ) -{ -sal_uInt16 nVersion = 0; -rStm.ReadUInt16( nVersion ); -if ( nVersion == 1 ) -{ -bRet = true; -if ( bExtendedInfo ) -{ -sal_uInt16 nChannels = 0; -sal_uInt32 nRows = 0; -sal_uInt32 nColumns = 0; -sal_uInt16 nDepth = 0; -sal_uInt16 nMode = 0; -rStm.SeekRel( 6 ); // Pad -rStm.ReadUInt16( nChannels ).ReadUInt32( nRows ).ReadUInt32( nColumns ).ReadUInt16( nDepth ).ReadUInt16( nMode ); -if ( ( nDepth == 1 ) || ( nDepth == 8 ) || ( nDepth == 16 ) ) -{ -aMetadata.mnBitsPerPixel = ( nDepth == 16 ) ? 8 : nDepth; -switch ( nChannels ) -{ -case 4 : -case 3 : -aMetadata.mnBitsPerPixel = 24; -[[fallthrough]]; -case 2 : -case 1 : -aMetadata.maPixSize.setWidth( nColumns ); -aMetadata.maPixSize.setHeight( nRows ); -break; -default: -bRet = false; -} -} -else -bRet = false; -} -} -} - +vcl::GraphicFormatDetector aDetector( rStm, aPathExt, bExtendedInfo ); +bool bRet = aDetector.detect(); +bRet &= aDetector.checkPSD(); if ( bRet ) -aMetadata.mnFormat =
[Libreoffice-commits] core.git: 2 commits - vcl/source
vcl/source/filter/GraphicFormatDetector.cxx | 172 +++- vcl/source/filter/graphicfilter2.cxx| 199 +--- 2 files changed, 180 insertions(+), 191 deletions(-) New commits: commit 6a2fd2d07ed1cb7713776b32ff175b300ee732e9 Author: offtkp AuthorDate: Sat Aug 13 12:02:01 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Mon Aug 22 18:04:54 2022 +0200 Remove code duplication in GraphicDescriptor for PNG GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for PNG files Change-Id: I8ce1c5eee44ff4122f4ecf1094d3d8b18379c6b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138226 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index 43e403e59936..5b5ccf33d004 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -645,6 +645,102 @@ bool GraphicFormatDetector::checkPNG() if (mnFirstLong == 0x89504e47 && mnSecondLong == 0x0d0a1a0a) { maMetadata.mnFormat = GraphicFileFormat::PNG; +if (mbExtendedInfo) +{ +sal_uInt32 nTemp32; +mrStream.Seek(mnStreamPosition + 8); +do +{ +sal_uInt8 cByte = 0; + +// IHDR-Chunk +mrStream.SeekRel(8); + +// width +mrStream.ReadUInt32(nTemp32); +if (!mrStream.good()) +break; +maMetadata.maPixSize.setWidth(nTemp32); + +// height +mrStream.ReadUInt32(nTemp32); +if (!mrStream.good()) +break; +maMetadata.maPixSize.setHeight(nTemp32); + +// Bits/Pixel +mrStream.ReadUChar(cByte); +if (!mrStream.good()) +break; +maMetadata.mnBitsPerPixel = cByte; + +// Colour type - check whether it supports alpha values +sal_uInt8 cColType = 0; +mrStream.ReadUChar(cColType); +if (!mrStream.good()) +break; +maMetadata.mbIsAlpha = maMetadata.mbIsTransparent += (cColType == 4 || cColType == 6); + +// Planes always 1; +// compression always +maMetadata.mnPlanes = 1; + +sal_uInt32 nLen32 = 0; +nTemp32 = 0; + +mrStream.SeekRel(7); + +// read up to the start of the image +mrStream.ReadUInt32(nLen32); +mrStream.ReadUInt32(nTemp32); +while (mrStream.good() && nTemp32 != 0x49444154) +{ +if (nTemp32 == 0x70485973) // physical pixel dimensions +{ +sal_uLong nXRes; +sal_uLong nYRes; + +// horizontal resolution +nTemp32 = 0; +mrStream.ReadUInt32(nTemp32); +nXRes = nTemp32; + +// vertical resolution +nTemp32 = 0; +mrStream.ReadUInt32(nTemp32); +nYRes = nTemp32; + +// unit +cByte = 0; +mrStream.ReadUChar(cByte); + +if (cByte) +{ +if (nXRes) +maMetadata.maLogSize.setWidth( +(maMetadata.maPixSize.Width() * 10) / nXRes); + +if (nYRes) +maMetadata.maLogSize.setHeight( +(maMetadata.maPixSize.Height() * 10) / nYRes); +} + +nLen32 -= 9; +} +else if (nTemp32 == 0x74524e53) // transparency +{ +maMetadata.mbIsTransparent = true; +maMetadata.mbIsAlpha = (cColType != 0 && cColType != 2); +} + +// skip forward to next chunk +mrStream.SeekRel(4 + nLen32); +mrStream.ReadUInt32(nLen32); +mrStream.ReadUInt32(nTemp32); +} +} while (false); +} return true; } return false; diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 0ef05ef1db9d..4327ef5e2f59 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -427,113 +427,12 @@
[Libreoffice-commits] core.git: 2 commits - vcl/source
vcl/source/filter/GraphicFormatDetector.cxx |8 + vcl/source/filter/graphicfilter2.cxx| 43 ++-- 2 files changed, 18 insertions(+), 33 deletions(-) New commits: commit c24b88efc4ac80d25d79b9764e6718d0392f718a Author: offtkp AuthorDate: Fri Aug 12 22:04:35 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Mon Aug 22 18:04:02 2022 +0200 Remove code duplication in GraphicDescriptor for RAS GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for RAS files Change-Id: I736c583a9cc974a9eb4151443295dbb4b1e71053 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138212 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 0706e1b2301c..e622901767e8 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -838,16 +838,12 @@ bool GraphicDescriptor::ImpDetectPPM( SvStream& rStm, bool ) bool GraphicDescriptor::ImpDetectRAS( SvStream& rStm, bool ) { -sal_uInt32 nMagicNumber = 0; -bool bRet = false; sal_Int32 nStmPos = rStm.Tell(); -rStm.SetEndian( SvStreamEndian::BIG ); -rStm.ReadUInt32( nMagicNumber ); -if ( nMagicNumber == 0x59a66a95 ) -{ -aMetadata.mnFormat = GraphicFileFormat::RAS; -bRet = true; -} +vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /* bExtendedInfo */ ); +bool bRet = aDetector.detect(); +bRet &= aDetector.checkRAS(); +if ( bRet ) +aMetadata = aDetector.getMetadata(); rStm.Seek( nStmPos ); return bRet; } commit 0853187cbc66f17620c2951d24d1f71c9ea9f81a Author: offtkp AuthorDate: Fri Aug 12 22:01:58 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Mon Aug 22 18:03:53 2022 +0200 Remove code duplication in GraphicDescriptor for WEBP GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for WEBP files Change-Id: Ib9d7169433b391e2520d6b9bca831fa964a8d136 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138211 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index 684298ac773a..0bd3394bc99d 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include constexpr sal_uInt32 SVG_CHECK_SIZE = 2048; @@ -884,6 +885,13 @@ bool GraphicFormatDetector::checkWEBP() && maFirstBytes[10] == 'B' && maFirstBytes[11] == 'P') { maMetadata.mnFormat = GraphicFileFormat::WEBP; +if (mbExtendedInfo) +{ +mrStream.Seek(mnStreamPosition); +ReadWebpInfo(mrStream, maMetadata.maPixSize, maMetadata.mnBitsPerPixel, + maMetadata.mbIsAlpha); +maMetadata.mbIsTransparent = maMetadata.mbIsAlpha; +} return true; } return false; diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 93588c40c229..0706e1b2301c 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "graphicfilter_internal.hxx" @@ -1081,30 +1080,12 @@ bool GraphicDescriptor::ImpDetectSVG( SvStream& rStm, bool /*bExtendedInfo*/ ) bool GraphicDescriptor::ImpDetectWEBP( SvStream& rStm, bool bExtendedInfo ) { -sal_uInt32 nTemp32 = 0; -boolbRet = false; - sal_Int32 nStmPos = rStm.Tell(); -rStm.SetEndian( SvStreamEndian::BIG ); -rStm.ReadUInt32( nTemp32 ); - -if ( nTemp32 == 0x52494646 ) -{ -rStm.ReadUInt32( nTemp32 ); // skip -rStm.ReadUInt32( nTemp32 ); -if ( nTemp32 == 0x57454250 ) -{ -aMetadata.mnFormat = GraphicFileFormat::WEBP; -bRet = true; - -if ( bExtendedInfo ) -{ -rStm.Seek(nStmPos); -ReadWebpInfo(rStm, aMetadata.maPixSize, aMetadata.mnBitsPerPixel, aMetadata.mbIsAlpha ); -aMetadata.mbIsTransparent = aMetadata.mbIsAlpha; -} -} -} +vcl::GraphicFormatDetector aDetector( rStm, aPathExt, bExtendedInfo ); +bool bRet = aDetector.detect(); +bRet &= aDetector.checkWEBP(); +if ( bRet ) +aMetadata = aDetector.getMetadata(); rStm.Seek( nStmPos ); return bRet; }
[Libreoffice-commits] core.git: 2 commits - vcl/source
vcl/source/filter/graphicfilter2.cxx | 26 -- 1 file changed, 16 insertions(+), 10 deletions(-) New commits: commit 3682ef9da1ba3b6479e6bd6bf6d9705c784b4fd4 Author: offtkp AuthorDate: Fri Aug 12 21:35:25 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Mon Aug 22 18:03:17 2022 +0200 Remove code duplication in GraphicDescriptor for MET GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for MET files Change-Id: I3188fe4bcdd5e0d9a942c6606d28a01c56319619 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138210 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 59b468a5317e..93588c40c229 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -943,12 +943,15 @@ bool GraphicDescriptor::ImpDetectDXF( SvStream& rStm, bool ) return bRet; } -bool GraphicDescriptor::ImpDetectMET( SvStream&, bool ) +bool GraphicDescriptor::ImpDetectMET( SvStream& rStm, bool ) { -bool bRet = aPathExt.startsWith( "met" ); -if (bRet) -aMetadata.mnFormat = GraphicFileFormat::MET; - +sal_Int32 nStmPos = rStm.Tell(); +vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /*bExtendedInfo*/ ); +bool bRet = aDetector.detect(); +bRet &= aDetector.checkMET(); +if ( bRet ) +aMetadata = aDetector.getMetadata(); +rStm.Seek( nStmPos ); return bRet; } commit a1b2a8370e61ada2690a29a623d55b38bd7a7cf3 Author: offtkp AuthorDate: Fri Aug 12 21:30:19 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Mon Aug 22 18:03:05 2022 +0200 Remove code duplication in GraphicDescriptor for TGA GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for TGA files Change-Id: I939426d3016c90500c2a250ef464213b0fd7d642 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138209 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 01741afa7ec2..59b468a5317e 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -853,12 +853,15 @@ bool GraphicDescriptor::ImpDetectRAS( SvStream& rStm, bool ) return bRet; } -bool GraphicDescriptor::ImpDetectTGA( SvStream&, bool ) +bool GraphicDescriptor::ImpDetectTGA( SvStream& rStm, bool ) { -bool bRet = aPathExt.startsWith( "tga" ); -if (bRet) -aMetadata.mnFormat = GraphicFileFormat::TGA; - +sal_Int32 nStmPos = rStm.Tell(); +vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /* bExtendedInfo */ ); +bool bRet = aDetector.detect(); +bRet &= aDetector.checkTGA(); +if ( bRet ) +aMetadata = aDetector.getMetadata(); +rStm.Seek( nStmPos ); return bRet; }
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/graphicfilter2.cxx | 22 +- 1 file changed, 5 insertions(+), 17 deletions(-) New commits: commit e956091ad8ebfa77294e130bf2b5cf0200578fdb Author: offtkp AuthorDate: Fri Aug 12 21:27:16 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Fri Aug 19 10:26:33 2022 +0200 Remove code duplication in GraphicDescriptor for EPS GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for EPS files Change-Id: I108aefc56a0e9215eaeef3ae2a7b4d884f0a5373 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138208 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 1d08776f0b83..01741afa7ec2 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -918,24 +918,12 @@ bool GraphicDescriptor::ImpDetectPSD( SvStream& rStm, bool bExtendedInfo ) bool GraphicDescriptor::ImpDetectEPS( SvStream& rStm, bool ) { -// check the EPS preview and the file extension -sal_uInt32 nFirstLong = 0; -sal_uInt8 nFirstBytes[20] = {}; -boolbRet = false; - sal_Int32 nStmPos = rStm.Tell(); -rStm.SetEndian( SvStreamEndian::BIG ); -rStm.ReadUInt32( nFirstLong ); -rStm.SeekRel( -4 ); -rStm.ReadBytes( , 20 ); - -if ( ( nFirstLong == 0xC5D0D3C6 ) || aPathExt.startsWith( "eps" ) || -( ImplSearchEntry( nFirstBytes, reinterpret_cast("%!PS-Adobe"), 10, 10 ) -&& ImplSearchEntry( [15], reinterpret_cast("EPS"), 3, 3 ) ) ) -{ -aMetadata.mnFormat = GraphicFileFormat::EPS; -bRet = true; -} +vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /*bExtendedInfo*/ ); +bool bRet = aDetector.detect(); +bRet &= aDetector.checkEPS(); +if ( bRet ) +aMetadata = aDetector.getMetadata(); rStm.Seek( nStmPos ); return bRet; }
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/graphicfilter2.cxx | 25 + 1 file changed, 5 insertions(+), 20 deletions(-) New commits: commit 416168c01097563fc1773b9f1986dee7e43e5d9c Author: offtkp AuthorDate: Fri Aug 12 18:48:45 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Fri Aug 19 10:26:04 2022 +0200 Remove code duplication in GraphicDescriptor for PCD GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for PCD files Change-Id: Ic49f9b7ebfbe4e756d7c4f1067958bd7a2ac0154 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138207 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 3ffe27991dd9..1d08776f0b83 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -417,27 +417,12 @@ bool GraphicDescriptor::ImpDetectJPG( SvStream& rStm, bool bExtendedInfo ) bool GraphicDescriptor::ImpDetectPCD( SvStream& rStm, bool ) { -boolbRet = false; - sal_Int32 nStmPos = rStm.Tell(); -rStm.SetEndian( SvStreamEndian::LITTLE ); - -sal_uInt32 nTemp32 = 0; -sal_uInt16 nTemp16 = 0; -sal_uInt8 cByte = 0; - -rStm.SeekRel( 2048 ); -rStm.ReadUInt32( nTemp32 ); -rStm.ReadUInt16( nTemp16 ); -rStm.ReadUChar( cByte ); - -if ( ( nTemp32 == 0x5f444350 ) && - ( nTemp16 == 0x5049 ) && - ( cByte == 0x49 ) ) -{ -aMetadata.mnFormat = GraphicFileFormat::PCD; -bRet = true; -} +vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /*bExtendedInfo*/ ); +bool bRet = aDetector.detect(); +bRet &= aDetector.checkPCD(); +if ( bRet ) +aMetadata = aDetector.getMetadata(); rStm.Seek( nStmPos ); return bRet; }
[Libreoffice-commits] core.git: 2 commits - vcl/source
vcl/source/filter/graphicfilter2.cxx| 35 vcl/source/graphic/UnoGraphicDescriptor.cxx |1 2 files changed, 16 insertions(+), 20 deletions(-) New commits: commit e2043fd557200efc71ac8f014b79a40be2eaef76 Author: offtkp AuthorDate: Fri Aug 12 12:34:09 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Fri Aug 19 10:25:55 2022 +0200 Remove code duplication in GraphicDescriptor for PCT GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for PCT files Change-Id: I67b9d2ada18d5c141dd108564a4e8b632fc7299a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138189 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 2061b1a5b531..3ffe27991dd9 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -978,21 +978,13 @@ bool GraphicDescriptor::ImpDetectMET( SvStream&, bool ) bool GraphicDescriptor::ImpDetectPCT( SvStream& rStm, bool ) { -bool bRet = aPathExt.startsWith( "pct" ); -if (bRet) -aMetadata.mnFormat = GraphicFileFormat::PCT; -else -{ -sal_uInt64 const nStreamPos = rStm.Tell(); -sal_uInt64 const nStreamLen = rStm.remainingSize(); -if (isPCT(rStm, nStreamPos, nStreamLen)) -{ -bRet = true; -aMetadata.mnFormat = GraphicFileFormat::PCT; -} -rStm.Seek(nStreamPos); -} - +sal_Int32 nStmPos = rStm.Tell(); +vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /*bExtendedInfo*/ ); +bool bRet = aDetector.detect(); +bRet &= aDetector.checkPCT(); +if ( bRet ) +aMetadata = aDetector.getMetadata(); +rStm.Seek( nStmPos ); return bRet; } commit ea75ae547eaf69f7b4063264fe4c811d044a5798 Author: offtkp AuthorDate: Thu Aug 11 01:57:21 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Fri Aug 19 10:25:39 2022 +0200 Remove code duplication in GraphicDescriptor for SVG GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for SVG files Change-Id: I5ababbd43ece4e8c08c5833895dc0b56ad467f77 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138102 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 5ad698169dad..2061b1a5b531 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -1096,12 +1096,15 @@ bool GraphicDescriptor::ImpDetectEMF(SvStream& rStm, bool bExtendedInfo) return bRet; } -bool GraphicDescriptor::ImpDetectSVG( SvStream& /*rStm*/, bool /*bExtendedInfo*/ ) +bool GraphicDescriptor::ImpDetectSVG( SvStream& rStm, bool /*bExtendedInfo*/ ) { -bool bRet = aPathExt.startsWith( "svg" ); -if (bRet) -aMetadata.mnFormat = GraphicFileFormat::SVG; - +sal_Int32 nStmPos = rStm.Tell(); +vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /*bExtendedInfo*/ ); +bool bRet = aDetector.detect(); +bRet &= aDetector.checkSVG(); +if ( bRet ) +aMetadata = aDetector.getMetadata(); +rStm.Seek( nStmPos ); return bRet; } diff --git a/vcl/source/graphic/UnoGraphicDescriptor.cxx b/vcl/source/graphic/UnoGraphicDescriptor.cxx index ca25e5c6d964..b9daeeab6b61 100644 --- a/vcl/source/graphic/UnoGraphicDescriptor.cxx +++ b/vcl/source/graphic/UnoGraphicDescriptor.cxx @@ -139,6 +139,7 @@ void GraphicDescriptor::implCreate( SvStream& rIStm, const OUString* pURL ) case GraphicFileFormat::EMF: pMimeType = MIMETYPE_EMF; cType = graphic::GraphicType::VECTOR; break; case GraphicFileFormat::EMZ: pMimeType = MIMETYPE_EMF; cType = graphic::GraphicType::VECTOR; break; case GraphicFileFormat::SVG: pMimeType = MIMETYPE_SVG; cType = graphic::GraphicType::VECTOR; break; +case GraphicFileFormat::SVGZ: pMimeType = MIMETYPE_SVG; cType = graphic::GraphicType::VECTOR; break; default: break;
[Libreoffice-commits] core.git: 2 commits - vcl/source
vcl/source/filter/graphicfilter2.cxx | 26 -- 1 file changed, 16 insertions(+), 10 deletions(-) New commits: commit 735c6412deb4934e28ded552466be034a7b7b3fe Author: offtkp AuthorDate: Wed Aug 10 01:01:45 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Fri Aug 19 10:25:29 2022 +0200 Remove code duplication in GraphicDescriptor for XPM GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for XPM files Change-Id: I9a5919cb4144edf70edc71ed89ab2cb0d605158a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138070 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 331cf12f0feb..5ad698169dad 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -773,12 +773,15 @@ bool GraphicDescriptor::ImpDetectXBM( SvStream& rStm, bool ) return bRet; } -bool GraphicDescriptor::ImpDetectXPM( SvStream&, bool ) +bool GraphicDescriptor::ImpDetectXPM( SvStream& rStm, bool ) { -bool bRet = aPathExt.startsWith( "xpm" ); -if (bRet) -aMetadata.mnFormat = GraphicFileFormat::XPM; - +sal_Int32 nStmPos = rStm.Tell(); +vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /* bExtendedInfo */ ); +bool bRet = aDetector.detect(); +bRet &= aDetector.checkXPM(); +if ( bRet ) +aMetadata = aDetector.getMetadata(); +rStm.Seek( nStmPos ); return bRet; } commit ca5e7672d6f0d149373aae00db082758bf3d1715 Author: offtkp AuthorDate: Wed Aug 10 00:34:06 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Fri Aug 19 10:25:18 2022 +0200 Remove code duplication in GraphicDescriptor for XBM GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for XBM files Change-Id: Id3cf1e573ec3125830299e49f0a99aab7b3fe77e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138069 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index ea9e5a9480d7..331cf12f0feb 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -761,12 +761,15 @@ bool GraphicDescriptor::ImpDetectTIF( SvStream& rStm, bool bExtendedInfo ) return bRet; } -bool GraphicDescriptor::ImpDetectXBM( SvStream&, bool ) +bool GraphicDescriptor::ImpDetectXBM( SvStream& rStm, bool ) { -bool bRet = aPathExt.startsWith( "xbm" ); -if (bRet) -aMetadata.mnFormat = GraphicFileFormat::XBM; - +sal_Int32 nStmPos = rStm.Tell(); +vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /* bExtendedInfo */ ); +bool bRet = aDetector.detect(); +bRet &= aDetector.checkXBM(); +if ( bRet ) +aMetadata = aDetector.getMetadata(); +rStm.Seek( nStmPos ); return bRet; }
[Libreoffice-commits] core.git: filter/source vcl/inc vcl/qa vcl/source
filter/source/msfilter/escherex.cxx |4 vcl/inc/graphic/GraphicFormatDetector.hxx|3 vcl/qa/cppunit/GraphicFormatDetectorTest.cxx | 12 +- vcl/qa/cppunit/GraphicTest.cxx |2 vcl/source/filter/GraphicFormatDetector.cxx | 52 ++-- vcl/source/filter/graphicfilter2.cxx | 116 +++ vcl/source/graphic/UnoGraphicDescriptor.cxx |2 7 files changed, 73 insertions(+), 118 deletions(-) New commits: commit d5472c797df5831bb95650ad8f3c0cf94512b819 Author: offtkp AuthorDate: Tue Aug 9 23:24:58 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Fri Aug 19 10:24:43 2022 +0200 Remove code duplication in GraphicDescriptor for WMF/EMF GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for WMF/EMF files and their Z compressed counterparts WMZ/EMZ Change-Id: Ia054c782320923aaa0c2c8bda2f33c27c3b123d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138067 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 17c93f611d77..52326112d994 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -1633,7 +1633,9 @@ bool EscherPropertyContainer::CreateGraphicProperties(const uno::Reference pIn(::utl::UcbStreamHelper::CreateStream( aTmp.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ )); diff --git a/vcl/inc/graphic/GraphicFormatDetector.hxx b/vcl/inc/graphic/GraphicFormatDetector.hxx index a9cb94320a0b..103519b6870c 100644 --- a/vcl/inc/graphic/GraphicFormatDetector.hxx +++ b/vcl/inc/graphic/GraphicFormatDetector.hxx @@ -157,7 +157,8 @@ public: bool checkMET(); bool checkBMP(); -bool checkWMForEMF(); +bool checkWMF(); +bool checkEMF(); bool checkPCX(); bool checkTIF(); bool checkGIF(); diff --git a/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx b/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx index df7f552b15af..30cd8f9ebe1e 100644 --- a/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx +++ b/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx @@ -117,7 +117,7 @@ void GraphicFormatDetectorTest::testDetectWMF() vcl::GraphicFormatDetector aDetector(aFileStream, "WMF"); CPPUNIT_ASSERT(aDetector.detect()); -CPPUNIT_ASSERT(aDetector.checkWMForEMF()); +CPPUNIT_ASSERT(aDetector.checkWMF()); aFileStream.Seek(aDetector.mnStreamPosition); @@ -129,10 +129,10 @@ void GraphicFormatDetectorTest::testDetectWMF() void GraphicFormatDetectorTest::testDetectWMZ() { SvFileStream aFileStream(getFullUrl(u"TypeDetectionExample.wmz"), StreamMode::READ); -vcl::GraphicFormatDetector aDetector(aFileStream, "WMF"); +vcl::GraphicFormatDetector aDetector(aFileStream, "WMZ"); CPPUNIT_ASSERT(aDetector.detect()); -CPPUNIT_ASSERT(aDetector.checkWMForEMF()); +CPPUNIT_ASSERT(aDetector.checkWMF()); aFileStream.Seek(aDetector.mnStreamPosition); @@ -357,7 +357,7 @@ void GraphicFormatDetectorTest::testDetectEMF() vcl::GraphicFormatDetector aDetector(aFileStream, "EMF"); CPPUNIT_ASSERT(aDetector.detect()); -CPPUNIT_ASSERT(aDetector.checkWMForEMF()); +CPPUNIT_ASSERT(aDetector.checkEMF()); aFileStream.Seek(aDetector.mnStreamPosition); @@ -369,10 +369,10 @@ void GraphicFormatDetectorTest::testDetectEMF() void GraphicFormatDetectorTest::testDetectEMZ() { SvFileStream aFileStream(getFullUrl(u"TypeDetectionExample.emz"), StreamMode::READ); -vcl::GraphicFormatDetector aDetector(aFileStream, "EMF"); +vcl::GraphicFormatDetector aDetector(aFileStream, "EMZ"); CPPUNIT_ASSERT(aDetector.detect()); -CPPUNIT_ASSERT(aDetector.checkWMForEMF()); +CPPUNIT_ASSERT(aDetector.checkEMF()); aFileStream.Seek(aDetector.mnStreamPosition); diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx index d5a38d70ccad..378bc7a7b55b 100644 --- a/vcl/qa/cppunit/GraphicTest.cxx +++ b/vcl/qa/cppunit/GraphicTest.cxx @@ -512,7 +512,7 @@ void GraphicTest::testEmfToWmfConversion() aGraphicStream.Seek(0); vcl::GraphicFormatDetector aDetector(aGraphicStream, OUString()); CPPUNIT_ASSERT(aDetector.detect()); -CPPUNIT_ASSERT(aDetector.checkWMForEMF()); +CPPUNIT_ASSERT(aDetector.checkWMF()); // Without the accompanying fix in place, this test would have failed with: // - Expected: WMF diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index e2345208d6f6..684298ac773a 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -74,7 +74,7 @@ bool peekGraphicFormat(SvStream& rStream, OUString& rFormatExtension, bool bTest || rFormatExtension.startsWith("EMF") ||
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/graphicfilter2.cxx | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) New commits: commit 45705461d4597b736c44e006360f9072eed3fe85 Author: offtkp AuthorDate: Sun Aug 7 22:24:39 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Fri Aug 19 10:23:47 2022 +0200 Remove code duplication in GraphicDescriptor for DXF GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for DXF files Change-Id: I13a3c40ee35259b6b61aa323f4fa5af73290e94b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137935 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 0a58f03a98ea..8ce85ee1f9df 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -954,12 +954,15 @@ bool GraphicDescriptor::ImpDetectEPS( SvStream& rStm, bool ) return bRet; } -bool GraphicDescriptor::ImpDetectDXF( SvStream&, bool ) +bool GraphicDescriptor::ImpDetectDXF( SvStream& rStm, bool ) { -bool bRet = aPathExt.startsWith( "dxf" ); -if (bRet) -aMetadata.mnFormat = GraphicFileFormat::DXF; - +sal_Int32 nStmPos = rStm.Tell(); +vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /*bExtendedInfo*/ ); +bool bRet = aDetector.detect(); +bRet &= aDetector.checkDXF(); +if ( bRet ) +aMetadata = aDetector.getMetadata(); +rStm.Seek( nStmPos ); return bRet; }
[Libreoffice-commits] core.git: vcl/inc vcl/source
vcl/inc/graphic/GraphicFormatDetector.hxx |2 - vcl/source/filter/GraphicFormatDetector.cxx | 11 ++- vcl/source/filter/graphicfilter2.cxx| 39 +++- 3 files changed, 15 insertions(+), 37 deletions(-) New commits: commit 100893da6f1db69f79d6c35b63df4053a9341784 Author: offtkp AuthorDate: Sun Aug 7 21:57:14 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Wed Aug 10 07:48:38 2022 +0200 Remove code duplication in GraphicDescriptor for GIF GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for GIF files Change-Id: Ieabacb302c9c712fc6f3da85eaccc07dca035eba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137934 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/inc/graphic/GraphicFormatDetector.hxx b/vcl/inc/graphic/GraphicFormatDetector.hxx index bb5ffa37361a..5d5ff7f9ece3 100644 --- a/vcl/inc/graphic/GraphicFormatDetector.hxx +++ b/vcl/inc/graphic/GraphicFormatDetector.hxx @@ -192,7 +192,7 @@ private: */ sal_uInt8* checkAndUncompressBuffer(sal_uInt8* aUncompressedBuffer, sal_uInt32 nSize, sal_uInt64& nDecompressedSize); -// bool mbExtendedInfo; +bool mbExtendedInfo; GraphicMetadata maMetadata; bool mbWasCompressed; }; diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index 4c3b6663d3b1..4cf30e6e8571 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -339,14 +339,14 @@ bool isPCT(SvStream& rStream, sal_uLong nStreamPos, sal_uLong nStreamLen) } // end anonymous namespace GraphicFormatDetector::GraphicFormatDetector(SvStream& rStream, OUString aFormatExtension, - bool /* bExtendedInfo */) + bool bExtendedInfo) : mrStream(rStream) , maExtension(std::move(aFormatExtension)) , mnFirstLong(0) , mnSecondLong(0) , mnStreamPosition(0) , mnStreamLength(0) -// , mbExtendedInfo(bExtendedInfo) +, mbExtendedInfo(bExtendedInfo) , maMetadata() { } @@ -516,6 +516,13 @@ bool GraphicFormatDetector::checkGIF() && maFirstBytes[5] == 0x61) { maMetadata.mnFormat = GraphicFileFormat::GIF; +if (mbExtendedInfo) +{ +sal_uInt16 nWidth = maFirstBytes[6] | (maFirstBytes[7] << 8); +sal_uInt16 nHeight = maFirstBytes[8] | (maFirstBytes[9] << 8); +maMetadata.maPixSize = Size(nWidth, nHeight); +maMetadata.mnBitsPerPixel = ((maFirstBytes[10] & 112) >> 4) + 1; +} return true; } return false; diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index f59beaeb93a2..0a58f03a98ea 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -217,41 +217,12 @@ bool GraphicDescriptor::ImpDetectBMP( SvStream& rStm, bool bExtendedInfo ) bool GraphicDescriptor::ImpDetectGIF( SvStream& rStm, bool bExtendedInfo ) { -sal_uInt32 n32 = 0; -boolbRet = false; - sal_Int32 nStmPos = rStm.Tell(); -rStm.SetEndian( SvStreamEndian::LITTLE ); -rStm.ReadUInt32( n32 ); - -if ( n32 == 0x38464947 ) -{ -sal_uInt16 n16 = 0; -rStm.ReadUInt16( n16 ); -if ( ( n16 == 0x6137 ) || ( n16 == 0x6139 ) ) -{ -aMetadata.mnFormat = GraphicFileFormat::GIF; -bRet = true; - -if ( bExtendedInfo ) -{ -sal_uInt16 nTemp16 = 0; -sal_uInt8 cByte = 0; - -// Pixel width -rStm.ReadUInt16( nTemp16 ); -aMetadata.maPixSize.setWidth( nTemp16 ); - -// Pixel height -rStm.ReadUInt16( nTemp16 ); -aMetadata.maPixSize.setHeight( nTemp16 ); - -// Bits/Pixel -rStm.ReadUChar( cByte ); -aMetadata.mnBitsPerPixel = ( ( cByte & 112 ) >> 4 ) + 1; -} -} -} +vcl::GraphicFormatDetector aDetector( rStm, aPathExt, bExtendedInfo ); +bool bRet = aDetector.detect(); +bRet &= aDetector.checkGIF(); +if ( bRet ) +aMetadata = aDetector.getMetadata(); rStm.Seek( nStmPos ); return bRet; }
[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/qa vcl/source
include/vcl/graphic/GraphicMetadata.hxx| 61 ++ include/vcl/graphicfilter.hxx | 72 +-- vcl/inc/graphic/GraphicFormatDetector.hxx | 112 ++- vcl/qa/cppunit/GraphicFormatDetectorTest.cxx |8 vcl/qa/cppunit/GraphicTest.cxx | 14 - vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx |3 vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx |3 vcl/source/filter/GraphicFormatDetector.cxx| 128 +++- vcl/source/filter/graphicfilter2.cxx | 212 + 9 files changed, 362 insertions(+), 251 deletions(-) New commits: commit 5e636747faf919e36bfd015c6dfcf0aea0c41938 Author: offtkp AuthorDate: Sat Jul 30 01:47:54 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Wed Aug 10 07:45:01 2022 +0200 Prepare GraphicDescriptor and GraphicFormatDetector for merging Make GraphicFormatDetector return GraphicFileFormat instead of a string and various variable changes so that the two can be combined in future patches. Change-Id: I6e184b3ba52289db02e0d4eebeeadde0ce0433b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137627 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/vcl/graphic/GraphicMetadata.hxx b/include/vcl/graphic/GraphicMetadata.hxx new file mode 100644 index ..da27fde01514 --- /dev/null +++ b/include/vcl/graphic/GraphicMetadata.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef INCLUDED_VCL_GRAPHIC_GRAPHICMETADATA_HXX +#define INCLUDED_VCL_GRAPHIC_GRAPHICMETADATA_HXX +// Info class for all supported file formats +enum class GraphicFileFormat +{ +NOT = 0x, +BMP = 0x0001, +GIF = 0x0002, +JPG = 0x0003, +PCD = 0x0004, +PCX = 0x0005, +PNG = 0x0006, +TIF = 0x0007, +XBM = 0x0008, +XPM = 0x0009, +PBM = 0x000a, +PGM = 0x000b, +PPM = 0x000c, +RAS = 0x000d, +TGA = 0x000e, +PSD = 0x000f, +EPS = 0x0010, +WEBP = 0x0011, +MOV = 0x00e0, +PDF = 0x00e1, +DXF = 0x00f1, +MET = 0x00f2, +PCT = 0x00f3, +// retired SGF = 0x00f4, +SVM = 0x00f5, +WMF = 0x00f6, +// retired SGV = 0x00f7, +EMF = 0x00f8, +SVG = 0x00f9, +WMZ = 0x00fa, +EMZ = 0x00fb, +SVGZ = 0x00fc +}; +struct GraphicMetadata +{ +Size maPixSize{}; +Size maLogSize{}; +std::optional maPreferredLogSize = std::nullopt; +std::optional maPreferredMapMode = std::nullopt; +sal_uInt16 mnBitsPerPixel = 0; +sal_uInt16 mnPlanes = 0; +GraphicFileFormat mnFormat = GraphicFileFormat::NOT; +sal_uInt8 mnNumberOfImageComponents = 0; +bool mbIsTransparent = false; +bool mbIsAlpha = false; +}; +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index fb237bc780a4..8985b09eab32 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -25,9 +25,9 @@ #include #include #include +#include #include -#include namespace com::sun::star::beans { struct PropertyValue; } namespace com::sun::star::uno { template class Sequence; } @@ -124,56 +124,12 @@ inline constexpr OUStringLiteral SVG_SHORTNAME = u"SVG"; inline constexpr OUStringLiteral PDF_SHORTNAME = u"PDF"; inline constexpr OUStringLiteral WEBP_SHORTNAME = u"WEBP"; -// Info class for all supported file formats - -enum class GraphicFileFormat -{ -NOT = 0x, -BMP = 0x0001, -GIF = 0x0002, -JPG = 0x0003, -PCD = 0x0004, -PCX = 0x0005, -PNG = 0x0006, -TIF = 0x0007, -XBM = 0x0008, -XPM = 0x0009, -PBM = 0x000a, -PGM = 0x000b, -PPM = 0x000c, -RAS = 0x000d, -TGA = 0x000e, -PSD = 0x000f, -EPS = 0x0010, -WEBP = 0x0011, -DXF = 0x00f1, -MET = 0x00f2, -PCT = 0x00f3, -// retired SGF = 0x00f4, -SVM = 0x00f5, -WMF = 0x00f6, -// retired SGV = 0x00f7, -EMF = 0x00f8, -SVG = 0x00f9 -}; - - class VCL_DLLPUBLIC GraphicDescriptor final { -SvStream* pFileStm; - -OUStringaPathExt; -SizeaPixSize; -SizeaLogSize; -std::optional maPreferredLogSize; -std::optional maPreferredMapMode; -sal_uInt16 nBitsPerPixel; -sal_uInt16 nPlanes; -GraphicFileFormat nFormat; -boolbOwnStream; -sal_uInt8 mnNumberOfImageComponents; -boolbIsTransparent; -boolbIsAlpha; +SvStream*pFileStm; +OUString
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/png/PngImageWriter.cxx | 32 +-- 1 file changed, 14 insertions(+), 18 deletions(-) New commits: commit a697296097a55a03189e97f93ce540819f42057a Author: offtkp AuthorDate: Thu Jul 21 02:19:33 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Thu Jul 28 16:25:49 2022 +0200 Use bitmap width instead of scanline size in combineScanlineChannels Change-Id: I9f5de7ed1bdcd39e5d6e580a2edbd5c0dd2027e0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137278 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/png/PngImageWriter.cxx b/vcl/source/filter/png/PngImageWriter.cxx index d18c410d1359..fd5ba3c84e8e 100644 --- a/vcl/source/filter/png/PngImageWriter.cxx +++ b/vcl/source/filter/png/PngImageWriter.cxx @@ -15,19 +15,16 @@ namespace { -void combineScanlineChannels(Scanline pRGBScanline, Scanline pAlphaScanline, Scanline pResult, - sal_uInt32 nSize) +void combineScanlineChannels(Scanline pRGBScanline, Scanline pAlphaScanline, + std::vector>& pResult, + sal_uInt32 nBitmapWidth) { -assert(pRGBScanline && "RGB scanline is null"); -assert(pAlphaScanline && "Alpha scanline is null"); - -auto const width = nSize / 3; -for (sal_uInt32 i = 0; i < width; ++i) +for (sal_uInt32 i = 0; i < nBitmapWidth; ++i) { -*pResult++ = *pRGBScanline++; // R -*pResult++ = *pRGBScanline++; // G -*pResult++ = *pRGBScanline++; // B -*pResult++ = *pAlphaScanline++; // A +pResult[i * 4] = *pRGBScanline++; // R +pResult[i * 4 + 1] = *pRGBScanline++; // G +pResult[i * 4 + 2] = *pRGBScanline++; // B +pResult[i * 4 + 3] = *pAlphaScanline++; // A } } } @@ -221,16 +218,15 @@ static bool pngWrite(SvStream& rStream, const BitmapEx& rBitmapEx, int nCompress std::vector> aCombinedChannels; if (bCombineChannels) { -// Check that there's at least an alpha channel per 3 color/RGB channels -assert(((pAlphaAccess->GetScanlineSize() * 3) >= pAccess->GetScanlineSize()) - && "RGB and alpha channel size mismatch"); +auto nBitmapWidth = pAccess->Width(); // Allocate enough size to fit all 4 channels -aCombinedChannels.resize(pAlphaAccess->GetScanlineSize() - + pAccess->GetScanlineSize()); +aCombinedChannels.resize(nBitmapWidth * 4); Scanline pAlphaPointer = pAlphaAccess->GetScanline(y); +if (!pSourcePointer || !pAlphaPointer) +return false; // Combine RGB and alpha channels -combineScanlineChannels(pSourcePointer, pAlphaPointer, aCombinedChannels.data(), -pAccess->GetScanlineSize()); +combineScanlineChannels(pSourcePointer, pAlphaPointer, aCombinedChannels, +nBitmapWidth); pFinalPointer = aCombinedChannels.data(); // Invert alpha channel (255 - a) png_set_invert_alpha(pPng);
[Libreoffice-commits] core.git: include/vcl vcl/IwyuFilter_vcl.yaml vcl/Library_vcl.mk vcl/source
include/vcl/pngwrite.hxx | 60 --- vcl/IwyuFilter_vcl.yaml|4 vcl/Library_vcl.mk |1 vcl/source/filter/png/pngwrite.cxx | 660 - 4 files changed, 725 deletions(-) New commits: commit 65f1903921c448da61733ca0d47c2ffc862b201d Author: offtkp AuthorDate: Sat Jul 16 21:13:10 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Wed Jul 20 08:13:27 2022 +0200 Remove pngwrite.hxx and .cxx as it is replaced by PngImageWriter pngwrite is now replaced by PngImageWriter which uses libpng so these old files are removed. Change-Id: Ie91c314f30b8f5668289b90009f408a79094 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137140 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/vcl/pngwrite.hxx b/include/vcl/pngwrite.hxx deleted file mode 100644 index de2b1c6e168d.. --- a/include/vcl/pngwrite.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_VCL_PNGWRITE_HXX -#define INCLUDED_VCL_PNGWRITE_HXX - -#include -#include -#include - -namespace com::sun::star::beans { struct PropertyValue; } -namespace com::sun::star::uno { template class Sequence; } - -class BitmapEx; -class SvStream; - -namespace vcl -{ -class PNGWriterImpl; - -class VCL_DLLPUBLIC PNGWriter -{ -const std::unique_ptr mpImpl; - -public: - -explicit PNGWriter(const BitmapEx&, const css::uno::Sequence* pFilterData = nullptr); -~PNGWriter(); - -bool Write(SvStream& rStream); - -// additional method to be able to modify all chunk before they are stored -struct ChunkData -{ -sal_uInt32 nType; -std::vectoraData; -}; -std::vector& GetChunks(); -}; -} - -#endif // INCLUDED_VCL_PNGWRITE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/IwyuFilter_vcl.yaml b/vcl/IwyuFilter_vcl.yaml index 150dc6519da4..f31df6e8c1f5 100644 --- a/vcl/IwyuFilter_vcl.yaml +++ b/vcl/IwyuFilter_vcl.yaml @@ -50,10 +50,6 @@ excludelist: vcl/source/filter/jpeg/JpegWriter.hxx: # Needed for direct member access - vcl/BitmapReadAccess.hxx -vcl/source/filter/png/pngwrite.cxx: -# Actually these are used -- com/sun/star/beans/PropertyValue.hpp -- com/sun/star/uno/Sequence.hxx vcl/source/filter/wmf/wmfexternal.cxx: # Actually these are used - com/sun/star/beans/PropertyValue.hpp diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index b265467d2696..cc5940cf61d0 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -473,7 +473,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/filter/wmf/wmfwr \ vcl/source/filter/png/PngImageReader \ vcl/source/filter/png/PngImageWriter \ -vcl/source/filter/png/pngwrite \ vcl/source/filter/webp/reader \ vcl/source/filter/webp/writer \ vcl/source/font/DirectFontSubstitution \ diff --git a/vcl/source/filter/png/pngwrite.cxx b/vcl/source/filter/png/pngwrite.cxx deleted file mode 100644 index 865fe38ebee7.. --- a/vcl/source/filter/png/pngwrite.cxx +++ /dev/null @@ -1,660 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at
[Libreoffice-commits] core.git: vcl/qa
vcl/qa/cppunit/png/PngFilterTest.cxx | 15 +-- 1 file changed, 5 insertions(+), 10 deletions(-) New commits: commit 65b29c5d38012f7c95ee0ee2070d11f679cbf3d3 Author: offtkp AuthorDate: Tue Jul 19 18:39:58 2022 +0300 Commit: Mike Kaganski CommitDate: Tue Jul 19 18:29:13 2022 +0200 Don't compare using long in PngFilterTest Change-Id: Ia6f0f7339e3e42acb2fe14eda914b21fc51b7d5f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137236 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/vcl/qa/cppunit/png/PngFilterTest.cxx b/vcl/qa/cppunit/png/PngFilterTest.cxx index 33af620eb08a..8635165ad705 100644 --- a/vcl/qa/cppunit/png/PngFilterTest.cxx +++ b/vcl/qa/cppunit/png/PngFilterTest.cxx @@ -1796,8 +1796,7 @@ void PngFilterTest::testPngRoundtrip8BitGrey() BitmapEx aBitmapEx; CPPUNIT_ASSERT_EQUAL(true, aPngReader.read(aBitmapEx)); -CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Width()); -CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Height()); +CPPUNIT_ASSERT_EQUAL(Size(16, 16), aBitmapEx.GetSizePixel()); CPPUNIT_ASSERT_EQUAL(COL_GRAY, aBitmapEx.GetPixelColor(0, 0)); CPPUNIT_ASSERT_EQUAL(COL_LIGHTGRAY, aBitmapEx.GetPixelColor(15, 15)); @@ -1845,8 +1844,7 @@ void PngFilterTest::testPngRoundtrip24() BitmapEx aBitmapEx; CPPUNIT_ASSERT_EQUAL(true, aPngReader.read(aBitmapEx)); -CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Width()); -CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Height()); +CPPUNIT_ASSERT_EQUAL(Size(16, 16), aBitmapEx.GetSizePixel()); CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, aBitmapEx.GetPixelColor(0, 0)); CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE, aBitmapEx.GetPixelColor(15, 15)); @@ -1900,8 +1898,7 @@ void PngFilterTest::testPngRoundtrip24_8() BitmapEx aBitmapEx; CPPUNIT_ASSERT_EQUAL(true, aPngReader.read(aBitmapEx)); -CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Width()); -CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Height()); +CPPUNIT_ASSERT_EQUAL(Size(16, 16), aBitmapEx.GetSizePixel()); CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0xBB, 0xFF, 0x00, 0x00), aBitmapEx.GetPixelColor(0, 0)); @@ -1970,8 +1967,7 @@ void PngFilterTest::testPngWrite1BitRGBPalette() BitmapEx aBitmapEx; CPPUNIT_ASSERT_EQUAL(true, aPngReader.read(aBitmapEx)); -CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Width()); -CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Height()); +CPPUNIT_ASSERT_EQUAL(Size(16, 16), aBitmapEx.GetSizePixel()); CPPUNIT_ASSERT_EQUAL(COL_RED, aBitmapEx.GetPixelColor(0, 0)); CPPUNIT_ASSERT_EQUAL(COL_RED, aBitmapEx.GetPixelColor(15, 15)); @@ -2013,8 +2009,7 @@ void PngFilterTest::testPngWrite8BitRGBPalette() BitmapEx aBitmapEx; CPPUNIT_ASSERT_EQUAL(true, aPngReader.read(aBitmapEx)); -CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Width()); -CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Height()); +CPPUNIT_ASSERT_EQUAL(Size(16, 16), aBitmapEx.GetSizePixel()); for (int i = 0; i < 16; i++) {
[Libreoffice-commits] core.git: xmlsecurity/workben
xmlsecurity/workben/pdfverify.cxx |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit 0ef286389e4f40fd59890937c6c6b1e7ce4a5064 Author: offtkp AuthorDate: Sat Jul 16 19:22:15 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 16:20:38 2022 +0200 Replace old png writer in pdfverify.cxx Change-Id: Iee38f9e86151717001ec4e4c083ec658603ad7c2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137139 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/xmlsecurity/workben/pdfverify.cxx b/xmlsecurity/workben/pdfverify.cxx index f04db1fa62cf..9a09a36088c6 100644 --- a/xmlsecurity/workben/pdfverify.cxx +++ b/xmlsecurity/workben/pdfverify.cxx @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -47,11 +47,11 @@ void generatePreview(std::string_view rPdfPath, std::string_view rPngPath) return; BitmapEx aBitmapEx = aGraphic.GetBitmapEx(); -vcl::PNGWriter aWriter(aBitmapEx); OUString aOutURL; osl::FileBase::getFileURLFromSystemPath(OUString::fromUtf8(rPngPath), aOutURL); SvFileStream aOutStream(aOutURL, StreamMode::WRITE); -aWriter.Write(aOutStream); +vcl::PngImageWriter aWriter(aOutStream); +aWriter.write(aBitmapEx); } int pdfVerify(int nArgc, char** pArgv)
[Libreoffice-commits] core.git: vcl/workben
vcl/workben/vcldemo.cxx |1 - 1 file changed, 1 deletion(-) New commits: commit 88e55fb61ef626099e2a43562d788cf75d86fdf2 Author: offtkp AuthorDate: Sat Jul 16 19:20:43 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 16:20:13 2022 +0200 Remove unused pngwrite.hxx include in vcldemo.cxx Change-Id: I8fe829eb34c07c2da47d93ef07f3dee098a9eed3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137138 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index e4f25210d2ee..379901c01398 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include
[Libreoffice-commits] core.git: vcl/unx
vcl/unx/gtk3/gtksalmenu.cxx | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) New commits: commit b8c0b8b06cd24480c66f3bf657576e3dde03a5a6 Author: offtkp AuthorDate: Sat Jul 16 19:20:02 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:25:41 2022 +0200 Replace old png writer in gtksalmenu.cxx Change-Id: I6851d7a6c8bbd1fbb02b3ba74f46d13e1fd80223 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137137 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/unx/gtk3/gtksalmenu.cxx b/vcl/unx/gtk3/gtksalmenu.cxx index 22261c62bbf4..53c1f66504cd 100644 --- a/vcl/unx/gtk3/gtksalmenu.cxx +++ b/vcl/unx/gtk3/gtksalmenu.cxx @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include // for escapeStringXML #include @@ -813,8 +813,9 @@ bool GtkSalMenu::AddMenuBarButton(const SalMenuButtonItem& rNewItem) if (!!rNewItem.maImage) { SvMemoryStream* pMemStm = new SvMemoryStream; -vcl::PNGWriter aWriter(rNewItem.maImage.GetBitmapEx()); -aWriter.Write(*pMemStm); +auto aBitmapEx = rNewItem.maImage.GetBitmapEx(); +vcl::PngImageWriter aWriter(*pMemStm); +aWriter.write(aBitmapEx); GBytes *pBytes = g_bytes_new_with_free_func(pMemStm->GetData(), pMemStm->TellEnd(), @@ -1071,11 +1072,11 @@ void GtkSalMenu::ApplyPersona() { if (maPersonaBitmap != rPersonaBitmap) { -vcl::PNGWriter aPNGWriter(rPersonaBitmap); mxPersonaImage.reset(new utl::TempFile); mxPersonaImage->EnableKillingFile(true); SvStream* pStream = mxPersonaImage->GetStream(StreamMode::WRITE); -aPNGWriter.Write(*pStream); +vcl::PngImageWriter aPNGWriter(*pStream); +aPNGWriter.write(rPersonaBitmap); mxPersonaImage->CloseStream(); } @@ -1260,8 +1261,9 @@ void GtkSalMenu::NativeSetItemIcon( unsigned nSection, unsigned nItemPos, const if (!!rImage) { SvMemoryStream* pMemStm = new SvMemoryStream; -vcl::PNGWriter aWriter(rImage.GetBitmapEx()); -aWriter.Write(*pMemStm); +auto aBitmapEx = rImage.GetBitmapEx(); +vcl::PngImageWriter aWriter(*pMemStm); +aWriter.write(aBitmapEx); GBytes *pBytes = g_bytes_new_with_free_func(pMemStm->GetData(), pMemStm->TellEnd(),
[Libreoffice-commits] core.git: 2 commits - vcl/source vcl/unx
vcl/source/treelist/transfer.cxx |8 vcl/unx/gtk3/gtkinst.cxx |9 + 2 files changed, 9 insertions(+), 8 deletions(-) New commits: commit 7785a62cd74e5924e4ade4d69519966c63a0decf Author: offtkp AuthorDate: Sat Jul 16 19:16:01 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:24:22 2022 +0200 Replace old png writer in transfer.cxx Change-Id: I1423bd4e7650da71f31de50df8a88ee3c09db33b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137135 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/treelist/transfer.cxx b/vcl/source/treelist/transfer.cxx index 4506fa2ffea7..f2c453792a6f 100644 --- a/vcl/source/treelist/transfer.cxx +++ b/vcl/source/treelist/transfer.cxx @@ -64,7 +64,7 @@ #include #include #include -#include +#include #include #include #include @@ -668,9 +668,9 @@ bool TransferableHelper::SetBitmapEx( const BitmapEx& rBitmapEx, const DataFlavo aFilterData.getArray()[aFilterData.getLength() - 1].Value <<= 1; #endif -vcl::PNGWriter aPNGWriter(rBitmapEx, ); - -aPNGWriter.Write(aMemStm); +vcl::PngImageWriter aPNGWriter(aMemStm); +aPNGWriter.setParameters(aFilterData); +aPNGWriter.write(rBitmapEx); } else { commit 20d0d2d2ff5ee0b8e1f40ca1adda115a82d974b6 Author: offtkp AuthorDate: Sat Jul 16 19:18:43 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:24:09 2022 +0200 Replace old png writer in gtkinst.cxx Change-Id: I5a9aefe1b957b800b5c56f3200d28ef727324cac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137136 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index c88c6886ee85..4aacd3979b4e 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -86,7 +86,7 @@ #include #include #include -#include +#include #include #include #include @@ -4814,9 +4814,10 @@ namespace // We "know" that this gets passed to zlib's deflateInit2_(). 1 means best speed. css::uno::Sequence aFilterData{ comphelper::makePropertyValue( "Compression", sal_Int32(1)) }; - -vcl::PNGWriter aWriter(aImage.GetBitmapEx(), ); -aWriter.Write(aMemStm); +auto aBitmapEx = aImage.GetBitmapEx(); +vcl::PngImageWriter aWriter(aMemStm); +aWriter.setParameters(aFilterData); +aWriter.write(aBitmapEx); return load_icon_from_stream(aMemStm); }
[Libreoffice-commits] core.git: 2 commits - vcl/source
vcl/source/image/ImplImageTree.cxx |6 +++--- vcl/source/opengl/OpenGLHelper.cxx |6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) New commits: commit f5371a2e5367ab4cb1cd62efb18e46872159a94e Author: offtkp AuthorDate: Sat Jul 16 19:13:13 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:22:20 2022 +0200 Replace old png writer in OpenGLHelper.cxx Change-Id: I028db48230fae64a539ee0a7964d73c039289740 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137134 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index a0dff4a5f567..b04afad288f3 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -531,9 +531,9 @@ void OpenGLHelper::renderToFile(tools::Long nWidth, tools::Long nHeight, const O glReadPixels(0, 0, nWidth, nHeight, OptimalBufferFormat(), GL_UNSIGNED_BYTE, pBuffer.get()); BitmapEx aBitmap = ConvertBufferToBitmapEx(pBuffer.get(), nWidth, nHeight); try { -vcl::PNGWriter aWriter( aBitmap ); SvFileStream sOutput( rFileName, StreamMode::WRITE ); -aWriter.Write( sOutput ); +vcl::PngImageWriter aWriter( sOutput ); +aWriter.write( aBitmap ); sOutput.Close(); } catch (...) { SAL_WARN("vcl.opengl", "Error writing png to " << rFileName); commit a91d5e5a69682ac857e39f6d015b6c8470273e96 Author: offtkp AuthorDate: Sat Jul 16 19:12:09 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:22:04 2022 +0200 Replace old png writer in ImplImageTree.cxx Change-Id: I26702462ec19056f33a582083e69630bec1fb3a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137133 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx index 94105a48545d..4489fe1d9e0f 100644 --- a/vcl/source/image/ImplImageTree.cxx +++ b/vcl/source/image/ImplImageTree.cxx @@ -55,7 +55,7 @@ #include #include #include -#include +#include #include #include @@ -381,11 +381,11 @@ bool loadDiskCachedVersion(std::u16string_view sVariant, ImageRequestParameters& void cacheBitmapToDisk(std::u16string_view sVariant, ImageRequestParameters const & rParameters) { OUString sUrl(createIconCacheUrl(sVariant, rParameters)); -vcl::PNGWriter aWriter(rParameters.mrBitmap); try { SvFileStream aStream(sUrl, StreamMode::WRITE); -aWriter.Write(aStream); +vcl::PngImageWriter aWriter(aStream); +aWriter.write(rParameters.mrBitmap); aStream.Close(); } catch (...)
[Libreoffice-commits] core.git: vcl/qt5
vcl/qt5/QtTools.cxx |7 --- 1 file changed, 4 insertions(+), 3 deletions(-) New commits: commit e50ff311ceda513fdcff4b73546d039bb847a0b9 Author: offtkp AuthorDate: Sat Jul 16 19:08:22 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:21:20 2022 +0200 Replace old png writer in QtTools.cxx Change-Id: I4f6438b811e7e97aedda90508423982cb82e0008 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137131 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/qt5/QtTools.cxx b/vcl/qt5/QtTools.cxx index f9a0a0e0e328..030b3af2b5a3 100644 --- a/vcl/qt5/QtTools.cxx +++ b/vcl/qt5/QtTools.cxx @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include @@ -111,8 +111,9 @@ QImage toQImage(const Image& rImage) if (!!rImage) { SvMemoryStream aMemStm; -vcl::PNGWriter aWriter(rImage.GetBitmapEx()); -aWriter.Write(aMemStm); +auto rBitmapEx = rImage.GetBitmapEx(); +vcl::PngImageWriter aWriter(aMemStm); +aWriter.write(rBitmapEx); aImage.loadFromData(static_cast(aMemStm.GetData()), aMemStm.TellEnd()); }
[Libreoffice-commits] core.git: vcl/qa
vcl/qa/cppunit/svm/svmtest.cxx | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) New commits: commit c6082fd9fe2b1f1c3af6c7086a436405ad4c92b6 Author: offtkp AuthorDate: Sat Jul 16 19:06:24 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:10:32 2022 +0200 Replace old png writer in svmtest.cxx Change-Id: Iebd1dbf56fe4305871b9a091488ee5acd4f58814 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137130 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx index e6fc36ba089a..3bf717d42296 100644 --- a/vcl/qa/cppunit/svm/svmtest.cxx +++ b/vcl/qa/cppunit/svm/svmtest.cxx @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -284,13 +284,13 @@ void SvmTest::checkRendering(ScopedVclPtrInstance const & pVirtua { SvFileStream aStream(aTempFile.GetURL() + ".source.png", StreamMode::WRITE | StreamMode::TRUNC); -vcl::PNGWriter aPNGWriter(aSourceBitmapEx); -aPNGWriter.Write(aStream); +vcl::PngImageWriter aPNGWriter(aStream); +aPNGWriter.write(aSourceBitmapEx); } { SvFileStream aStream(aTempFile.GetURL() + ".result.png", StreamMode::WRITE | StreamMode::TRUNC); -vcl::PNGWriter aPNGWriter(aResultBitmapEx); -aPNGWriter.Write(aStream); +vcl::PngImageWriter aPNGWriter(aStream); +aPNGWriter.write(aResultBitmapEx); } } CPPUNIT_ASSERT_EQUAL(aSourceBitmapEx.GetChecksum(), aResultBitmapEx.GetChecksum());
[Libreoffice-commits] core.git: 2 commits - test/source
test/source/screenshot_test.cxx |6 +++--- test/source/text/baseindex.cxx |6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) New commits: commit a4a0e7b24c34e67756668ae8381203b7cca3d6fe Author: offtkp AuthorDate: Sat Jul 16 14:54:31 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:10:17 2022 +0200 Replace old png writer in baseindex.cxx Change-Id: I660579ed6ea886f9ab3fc913b785f92740f48dc0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137125 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/test/source/text/baseindex.cxx b/test/source/text/baseindex.cxx index 683a24221bb8..56443dd1caab 100644 --- a/test/source/text/baseindex.cxx +++ b/test/source/text/baseindex.cxx @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include @@ -38,8 +38,8 @@ void writerFileWithBitmap(OUString const& rURL) { BitmapEx aBitmapEx = createExampleBitmap(); SvFileStream aFileStream(rURL, StreamMode::READ | StreamMode::WRITE); -vcl::PNGWriter aWriter(aBitmapEx); -aWriter.Write(aFileStream); +vcl::PngImageWriter aWriter(aFileStream); +aWriter.write(aBitmapEx); aFileStream.Seek(STREAM_SEEK_TO_BEGIN); aFileStream.Close(); } commit 2bd224ba3b42cdada2c35ca3a513f90e5cf6b69b Author: offtkp AuthorDate: Sat Jul 16 13:07:04 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:09:58 2022 +0200 Replace old png writer in screenshot_test.cxx Change-Id: I5271b56bcce32e1ce71544421b9581518b05455e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137124 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/test/source/screenshot_test.cxx b/test/source/screenshot_test.cxx index f8bd3c6d4068..fdd172f29a68 100644 --- a/test/source/screenshot_test.cxx +++ b/test/source/screenshot_test.cxx @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -92,8 +92,8 @@ void ScreenshotTest::implSaveScreenshot(const BitmapEx& rScreenshot, const OStri CPPUNIT_ASSERT_MESSAGE(OString("Failed to open <" + OUStringToOString(pngUrl, RTL_TEXTENCODING_UTF8) + ">: " + OString::number(sal_uInt32(aNew.GetErrorCode(.getStr(), aNew.IsOpen()); std::cout << "saving " << pngUrl << ":\n"; -vcl::PNGWriter aPNGWriter(rScreenshot); -aPNGWriter.Write(aNew); +vcl::PngImageWriter aPNGWriter(aNew); +aPNGWriter.write(rScreenshot); } void ScreenshotTest::saveScreenshot(VclAbstractDialog const & rDialog)
[Libreoffice-commits] core.git: sfx2/source
sfx2/source/appl/sfxpicklist.cxx |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit f5703b39898b737f9b4bf34f0abdd07f24f065e2 Author: offtkp AuthorDate: Sat Jul 16 13:05:37 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:09:15 2022 +0200 Replace old png writer in sfxpicklist.cxx Change-Id: I8dd9925ea07fa16cea6918eef0e6d468d7b743c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137123 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx index 22c364669e7e..fb676d981d35 100644 --- a/sfx2/source/appl/sfxpicklist.cxx +++ b/sfx2/source/appl/sfxpicklist.cxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include @@ -112,8 +112,8 @@ void SfxPickListImpl::AddDocumentToPickList( const SfxObjectShell* pDocSh ) if (!aResultBitmap.IsEmpty()) { SvMemoryStream aStream(65535, 65535); -vcl::PNGWriter aWriter(aResultBitmap); -if (aWriter.Write(aStream)) +vcl::PngImageWriter aWriter(aStream); +if (aWriter.write(aResultBitmap)) { Sequence aSequence(static_cast(aStream.GetData()), aStream.Tell()); OUStringBuffer aBuffer;
[Libreoffice-commits] core.git: sd/source
sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit 601ba8d8dfdc613ad801f1a7d66436d5e3c8fc4f Author: offtkp AuthorDate: Sat Jul 16 13:03:05 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:08:40 2022 +0200 Replace old png writer in SlsBitmapCompressor.cxx Change-Id: Idc8ddcce918c5258f623f3b9065cfb523cb23629 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137122 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx b/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx index d4da935ddd0c..2d63bd47493e 100644 --- a/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx +++ b/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx @@ -22,7 +22,7 @@ #include #include #include -#include +#include namespace sd::slidesorter::cache { @@ -160,9 +160,9 @@ public: std::shared_ptr PngCompression::Compress (const BitmapEx& rBitmap) const { -vcl::PNGWriter aWriter(rBitmap); SvMemoryStream aStream (32768, 32768); -aWriter.Write(aStream); +vcl::PngImageWriter aWriter(aStream); +aWriter.write(rBitmap); auto pResult = std::make_shared(); pResult->mnDataSize = aStream.Tell();
[Libreoffice-commits] core.git: framework/source
framework/source/uiconfiguration/imagemanagerimpl.cxx |7 --- 1 file changed, 4 insertions(+), 3 deletions(-) New commits: commit 21ad38b61618c7bc4daea4e0e7989d8b21bd1150 Author: offtkp AuthorDate: Sat Jul 9 20:48:32 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:08:02 2022 +0200 Replace old png writer in imagemanagerimpl.cxx Change-Id: I8bc30a218b67d165d1a8ae3d663e5482a8113aa8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137118 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx index 5211e79b96dc..26aa0f33400c 100644 --- a/framework/source/uiconfiguration/imagemanagerimpl.cxx +++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include using ::com::sun::star::uno::Sequence; @@ -395,8 +395,9 @@ bool ImageManagerImpl::implts_storeUserImages( { { std::unique_ptr pSvStream(utl::UcbStreamHelper::CreateStream( xBitmapStream )); -vcl::PNGWriter aPngWriter( pImageList->GetAsHorizontalStrip() ); -aPngWriter.Write( *pSvStream ); +vcl::PngImageWriter aPngWriter( *pSvStream ); +auto rBitmap = pImageList->GetAsHorizontalStrip(); +aPngWriter.write( rBitmap ); } // Commit user bitmaps storage
[Libreoffice-commits] core.git: emfio/source
emfio/source/reader/emfreader.cxx |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit d35ccaf7c3c6f5a8f4223de3c63de2d6f8f6324a Author: offtkp AuthorDate: Sat Jul 9 20:47:39 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:07:05 2022 +0200 Replace old png writer in emfreader.cxx Change-Id: Ibc3ed62d5d09d2da9d7866deb21f49340ba71eea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137117 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 1613fd859674..e4d33ff259af 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -31,7 +31,7 @@ #include #ifdef DBG_UTIL -#include +#include #endif // GDI-Array @@ -1502,8 +1502,8 @@ namespace emfio if(bDoSaveForVisualControl) { SvFileStream aNew("c:\\metafile_content.png", StreamMode::WRITE|StreamMode::TRUNC); -vcl::PNGWriter aPNGWriter(aBitmapEx); -aPNGWriter.Write(aNew); +vcl::PngImageWriter aPNGWriter(aNew); +aPNGWriter.write(aBitmapEx); } #endif maBmpSaveList.emplace_back(aBitmapEx, aRect, SRCAND|SRCINVERT);
[Libreoffice-commits] core.git: drawinglayer/source
drawinglayer/source/tools/converters.cxx | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) New commits: commit 6203edf731f4cd3e678691af05def22394db2a89 Author: offtkp AuthorDate: Sat Jul 9 20:43:44 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:06:47 2022 +0200 Replace old png writer in converters.cxx Change-Id: I360963c2ad36a7bce5a257c9740b1e5690efc8e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137116 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/drawinglayer/source/tools/converters.cxx b/drawinglayer/source/tools/converters.cxx index c0a92a8f479f..2ba781386e49 100644 --- a/drawinglayer/source/tools/converters.cxx +++ b/drawinglayer/source/tools/converters.cxx @@ -32,7 +32,7 @@ #ifdef DBG_UTIL #include -#include +#include #endif namespace drawinglayer @@ -111,8 +111,8 @@ namespace drawinglayer #endif , StreamMode::WRITE|StreamMode::TRUNC); BitmapEx aContentEx(aContent); -vcl::PNGWriter aPNGWriter(aContentEx); -aPNGWriter.Write(aNew); +vcl::PngImageWriter aPNGWriter(aNew); +aPNGWriter.write(aContentEx); } #endif // prepare for mask creation @@ -147,8 +147,8 @@ namespace drawinglayer #endif , StreamMode::WRITE|StreamMode::TRUNC); BitmapEx aAlphaEx(aAlpha); -vcl::PNGWriter aPNGWriter(aAlphaEx); -aPNGWriter.Write(aNew); +vcl::PngImageWriter aPNGWriter(aNew); +aPNGWriter.write(aAlphaEx); } #endif @@ -164,8 +164,8 @@ namespace drawinglayer "~/test_combined.png" #endif , StreamMode::WRITE|StreamMode::TRUNC); -vcl::PNGWriter aPNGWriter(aRetval); -aPNGWriter.Write(aNew); +vcl::PngImageWriter aPNGWriter(aNew); +aPNGWriter.write(aRetval); } #endif }
[Libreoffice-commits] core.git: desktop/qa
desktop/qa/desktop_lib/test_desktop_lib.cxx | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) New commits: commit 605e391874e08484111ac760d5b353b7d4db6517 Author: offtkp AuthorDate: Sat Jul 9 20:40:52 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:06:19 2022 +0200 Replace old png writer in test_desktop_lib.cxx Change-Id: I9f73b316521bcacb9042375adef3a3339ab2166f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137115 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 54440df9266b..0c5df69dba8b 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -62,7 +62,7 @@ #include #include -#include +#include #include #if USE_TLS_NSS @@ -3377,8 +3377,8 @@ void DesktopLOKTest::testRenderSearchResult_WriterNode() if (bDumpBitmap) { SvFileStream aStream("~/SearchResultBitmap.png", StreamMode::WRITE | StreamMode::TRUNC); -vcl::PNGWriter aPNGWriter(aBitmap); -aPNGWriter.Write(aStream); +vcl::PngImageWriter aPNGWriter(aStream); +aPNGWriter.write(aBitmap); } CPPUNIT_ASSERT_EQUAL(tools::Long(642), aBitmap.GetSizePixel().Width()); CPPUNIT_ASSERT_EQUAL(tools::Long(561), aBitmap.GetSizePixel().Height()); @@ -3422,8 +3422,8 @@ void DesktopLOKTest::testRenderSearchResult_CommonNode() if (bDumpBitmap) { SvFileStream aStream("~/SearchResultBitmap.png", StreamMode::WRITE | StreamMode::TRUNC); -vcl::PNGWriter aPNGWriter(aBitmap); -aPNGWriter.Write(aStream); +vcl::PngImageWriter aPNGWriter(aStream); +aPNGWriter.write(aBitmap); } CPPUNIT_ASSERT_EQUAL(tools::Long(192), aBitmap.GetSizePixel().Width()); CPPUNIT_ASSERT_EQUAL(tools::Long(96), aBitmap.GetSizePixel().Height());
[Libreoffice-commits] core.git: cui/source
cui/source/dialogs/screenshotannotationdlg.cxx |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit 4bd2aed3db9e71e756f9ae004d5fa6afd8cd Author: offtkp AuthorDate: Sat Jul 9 20:35:22 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:05:41 2022 +0200 Replace old png writer in screenshotannotationdlg.cxx Change-Id: I21fbd95db7f8a9f036c5ecfbd08d7a46a9683dd8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137114 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/cui/source/dialogs/screenshotannotationdlg.cxx b/cui/source/dialogs/screenshotannotationdlg.cxx index 1f21c5278f83..6994ce1ed7e8 100644 --- a/cui/source/dialogs/screenshotannotationdlg.cxx +++ b/cui/source/dialogs/screenshotannotationdlg.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -341,8 +341,8 @@ IMPL_LINK_NOARG(ScreenshotAnnotationDlg_Impl, saveButtonHandler, weld::Button&, mxVirtualBufferDevice->GetOutputSizePixel())); // write as PNG -vcl::PNGWriter aPNGWriter(aTargetBitmap); -aPNGWriter.Write(aNew); +vcl::PngImageWriter aPNGWriter(aNew); +aPNGWriter.write(aTargetBitmap); } weld::ScreenShotEntry* ScreenshotAnnotationDlg_Impl::CheckHit(const basegfx::B2IPoint& rPosition)
[Libreoffice-commits] core.git: cppcanvas/qa
cppcanvas/qa/extras/emfplus/emfplus.cxx |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit 48eb565e2e62951eba712c64989c33b87e60ccbd Author: offtkp AuthorDate: Sat Jul 9 17:17:02 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:05:23 2022 +0200 Replace old png writer in emfplus.cxx Change-Id: Ibdc550e55d73ed71def6e5aef129520ab2062eeb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136936 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/cppcanvas/qa/extras/emfplus/emfplus.cxx b/cppcanvas/qa/extras/emfplus/emfplus.cxx index 6866310b5508..e0d64487e105 100644 --- a/cppcanvas/qa/extras/emfplus/emfplus.cxx +++ b/cppcanvas/qa/extras/emfplus/emfplus.cxx @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include @@ -63,8 +63,8 @@ public: if (pEnv) { SvFileStream aStream(OUString::fromUtf8(pEnv), StreamMode::WRITE); -vcl::PNGWriter aWriter(aResultBitmap); -CPPUNIT_ASSERT(aWriter.Write(aStream)); +vcl::PngImageWriter aWriter(aStream); +CPPUNIT_ASSERT(aWriter.write(aResultBitmap)); } return aResultBitmap.GetBitmap();
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/graphicfilter.cxx | 51 +++- 1 file changed, 5 insertions(+), 46 deletions(-) New commits: commit 1d548a2bc70e0b38e32ccae8b15b04bda84f3576 Author: offtkp AuthorDate: Sat Jul 16 19:10:19 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 13:05:03 2022 +0200 Replace old png writer in graphicfilter.cxx Change-Id: I68b35e82fd5ca4de87b3b9c3c6be5cf802f071ed Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137132 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index f7e3765f4e94..6aa2af7d23aa 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -1794,52 +1794,11 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, std::u16string_vi } else if ( aFilterName.equalsIgnoreAsciiCase( EXP_PNG ) ) { -vcl::PNGWriter aPNGWriter( aGraphic.GetBitmapEx(), pFilterData ); +auto aBitmapEx = aGraphic.GetBitmapEx(); +vcl::PngImageWriter aPNGWriter( rOStm ); if ( pFilterData ) -{ -for ( const auto& rPropVal : *pFilterData ) -{ -if ( rPropVal.Name == "AdditionalChunks" ) -{ -css::uno::Sequence< css::beans::PropertyValue > aAdditionalChunkSequence; -if ( rPropVal.Value >>= aAdditionalChunkSequence ) -{ -for ( const auto& rAdditionalChunk : std::as_const(aAdditionalChunkSequence) ) -{ -if ( rAdditionalChunk.Name.getLength() == 4 ) -{ -sal_uInt32 nChunkType = 0; -for ( sal_Int32 k = 0; k < 4; k++ ) -{ -nChunkType <<= 8; -nChunkType |= static_cast(rAdditionalChunk.Name[ k ]); -} -css::uno::Sequence< sal_Int8 > aByteSeq; -if ( rAdditionalChunk.Value >>= aByteSeq ) -{ -std::vector< vcl::PNGWriter::ChunkData >& rChunkData = aPNGWriter.GetChunks(); -if ( !rChunkData.empty() ) -{ -sal_uInt32 nChunkLen = aByteSeq.getLength(); - -vcl::PNGWriter::ChunkData aChunkData; -aChunkData.nType = nChunkType; -if ( nChunkLen ) -{ -aChunkData.aData.resize( nChunkLen ); -memcpy( aChunkData.aData.data(), aByteSeq.getConstArray(), nChunkLen ); -} -std::vector< vcl::PNGWriter::ChunkData >::iterator aIter = rChunkData.end() - 1; -rChunkData.insert( aIter, aChunkData ); -} -} -} -} -} -} -} -} -aPNGWriter.Write( rOStm ); +aPNGWriter.setParameters( *pFilterData ); +aPNGWriter.write( aBitmapEx ); if( rOStm.GetError() ) nStatus = ERRCODE_GRFILTER_IOERROR;
[Libreoffice-commits] core.git: include/vcl vcl/source
include/vcl/filter/PngImageWriter.hxx|2 vcl/source/filter/png/PngImageWriter.cxx | 66 +-- 2 files changed, 55 insertions(+), 13 deletions(-) New commits: commit fac9dfa19b3853e4b1b6ec62baf1645a8b1194c9 Author: offtkp AuthorDate: Sun Jul 17 21:42:53 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 10:10:37 2022 +0200 Add 32bpp export support in PngImageWriter Also added support for "Translucent" property Change-Id: I45cc3cf82ecacac08c3852ca2ad09fb8137ffc44 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137154 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/vcl/filter/PngImageWriter.hxx b/include/vcl/filter/PngImageWriter.hxx index 4fb11b1ca48a..c788f19bf4db 100644 --- a/include/vcl/filter/PngImageWriter.hxx +++ b/include/vcl/filter/PngImageWriter.hxx @@ -32,7 +32,7 @@ class VCL_DLLPUBLIC PngImageWriter css::uno::Reference mxStatusIndicator; sal_Int32 mnCompressionLevel; -bool mbInterlaced; +bool mbInterlaced, mbTranslucent; std::vector maAdditionalChunks; public: diff --git a/vcl/source/filter/png/PngImageWriter.cxx b/vcl/source/filter/png/PngImageWriter.cxx index 516c21a555df..7d9221c75112 100644 --- a/vcl/source/filter/png/PngImageWriter.cxx +++ b/vcl/source/filter/png/PngImageWriter.cxx @@ -11,6 +11,7 @@ #include #include #include +#include namespace { @@ -20,7 +21,7 @@ void combineScanlineChannels(Scanline pRGBScanline, Scanline pAlphaScanline, Sca assert(pRGBScanline && "RGB scanline is null"); assert(pAlphaScanline && "Alpha scanline is null"); -for (sal_uInt32 i = 0; i < nSize; i++) +for (sal_uInt32 i = 0; i < nSize; i += 3) { *pResult++ = *pRGBScanline++; // R *pResult++ = *pRGBScanline++; // G @@ -48,8 +49,14 @@ static void lclWriteStream(png_structp pPng, png_bytep pData, png_size_t pDataSi } static bool pngWrite(SvStream& rStream, const BitmapEx& rBitmapEx, int nCompressionLevel, + bool bInterlaced, bool bTranslucent, const std::vector& aAdditionalChunks) { +if (rBitmapEx.IsAlpha() && !bTranslucent) +return false; +if (rBitmapEx.IsEmpty()) +return false; + png_structp pPng = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); if (!pPng) @@ -62,6 +69,17 @@ static bool pngWrite(SvStream& rStream, const BitmapEx& rBitmapEx, int nCompress return false; } +BitmapEx aBitmapEx; +if (rBitmapEx.GetBitmap().getPixelFormat() == vcl::PixelFormat::N32_BPP) +{ +if (!vcl::bitmap::convertBitmap32To24Plus8(rBitmapEx, aBitmapEx)) +return false; +} +else +{ +aBitmapEx = rBitmapEx; +} + Bitmap aBitmap; AlphaMask aAlphaMask; Bitmap::ScopedReadAccess pAccess; @@ -78,13 +96,14 @@ static bool pngWrite(SvStream& rStream, const BitmapEx& rBitmapEx, int nCompress // Set our custom stream writer png_set_write_fn(pPng, , lclWriteStream, nullptr); -aBitmap = rBitmapEx.GetBitmap(); -aAlphaMask = rBitmapEx.GetAlpha(); +aBitmap = aBitmapEx.GetBitmap(); +aAlphaMask = aBitmapEx.GetAlpha(); { +bool bCombineChannels = false; pAccess = Bitmap::ScopedReadAccess(aBitmap); pAlphaAccess = Bitmap::ScopedReadAccess(aAlphaMask); -Size aSize = rBitmapEx.GetSizePixel(); +Size aSize = aBitmapEx.GetSizePixel(); int bitDepth = -1; int colorType = -1; @@ -127,7 +146,21 @@ static bool pngWrite(SvStream& rStream, const BitmapEx& rBitmapEx, int nCompress colorType = PNG_COLOR_TYPE_RGB; bitDepth = 8; if (pAlphaAccess) +{ colorType = PNG_COLOR_TYPE_RGBA; +bCombineChannels = true; +} +break; +} +case ScanlineFormat::N32BitTcBgra: +{ +png_set_bgr(pPng); +[[fallthrough]]; +} +case ScanlineFormat::N32BitTcRgba: +{ +colorType = PNG_COLOR_TYPE_RGBA; +bitDepth = 8; break; } default: @@ -136,9 +169,9 @@ static bool pngWrite(SvStream& rStream, const BitmapEx& rBitmapEx, int nCompress } } -if (rBitmapEx.GetPrefMapMode().GetMapUnit() == MapUnit::Map100thMM) +if (aBitmapEx.GetPrefMapMode().GetMapUnit() == MapUnit::Map100thMM) { -Size aPrefSize(rBitmapEx.GetPrefSize()); +Size aPrefSize(aBitmapEx.GetPrefSize()); sal_uInt32 nPrefSizeX = o3tl::convert(aSize.Width(), 10, aPrefSize.Width()); sal_uInt32 nPrefSizeY = o3tl::convert(aSize.Height(), 10, aPrefSize.Height()); png_set_pHYs(pPng, pInfo, nPrefSizeX, nPrefSizeY, 1); @@ -146,7 +179,7
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/png/PngImageWriter.cxx |8 1 file changed, 8 insertions(+) New commits: commit 9e775a73240c6d73d679409d0753334f8494ed14 Author: offtkp AuthorDate: Sun Jul 17 13:26:22 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 10:00:30 2022 +0200 Add pHYs chunk export support in PngImageWriter Change-Id: Idbb9c8222cbfce9d908a0b17d082de291cd0e0d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137145 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/png/PngImageWriter.cxx b/vcl/source/filter/png/PngImageWriter.cxx index 7db4e4b6bc98..516c21a555df 100644 --- a/vcl/source/filter/png/PngImageWriter.cxx +++ b/vcl/source/filter/png/PngImageWriter.cxx @@ -136,6 +136,14 @@ static bool pngWrite(SvStream& rStream, const BitmapEx& rBitmapEx, int nCompress } } +if (rBitmapEx.GetPrefMapMode().GetMapUnit() == MapUnit::Map100thMM) +{ +Size aPrefSize(rBitmapEx.GetPrefSize()); +sal_uInt32 nPrefSizeX = o3tl::convert(aSize.Width(), 10, aPrefSize.Width()); +sal_uInt32 nPrefSizeY = o3tl::convert(aSize.Height(), 10, aPrefSize.Height()); +png_set_pHYs(pPng, pInfo, nPrefSizeX, nPrefSizeY, 1); +} + png_set_compression_level(pPng, nCompressionLevel); int interlaceType = PNG_INTERLACE_NONE;
[Libreoffice-commits] core.git: include/vcl vcl/qa vcl/source
include/vcl/filter/PngImageWriter.hxx| 26 ++-- vcl/qa/cppunit/png/PngFilterTest.cxx | 67 ++- vcl/qa/cppunit/png/data/dummy.gif|binary vcl/source/filter/png/PngImageWriter.cxx | 59 +-- 4 files changed, 127 insertions(+), 25 deletions(-) New commits: commit 089b101e5447aac42e6fc79345e60da3ec63893d Author: offtkp AuthorDate: Sat Jul 16 12:34:47 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 10:00:10 2022 +0200 Add ms-gif PNG chunk export support in PngImageWriter Added export support for msOG chunks in the new PngImageWriter and unit test Change-Id: I258c9ca23e41c1d5ce01fc6711bc55c13636db17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137093 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/vcl/filter/PngImageWriter.hxx b/include/vcl/filter/PngImageWriter.hxx index 667dd540e332..4fb11b1ca48a 100644 --- a/include/vcl/filter/PngImageWriter.hxx +++ b/include/vcl/filter/PngImageWriter.hxx @@ -13,11 +13,19 @@ #include #include #include +#include #pragma once namespace vcl { +// Similar to png_unknown_chunk +struct PngChunk +{ +std::array name; +std::vector data; +size_t size; +}; class VCL_DLLPUBLIC PngImageWriter { SvStream& mrStream; @@ -25,23 +33,15 @@ class VCL_DLLPUBLIC PngImageWriter sal_Int32 mnCompressionLevel; bool mbInterlaced; +std::vector maAdditionalChunks; public: PngImageWriter(SvStream& rStream); -virtual ~PngImageWriter() {} - -void setParameters(css::uno::Sequence const& rParameters) -{ -for (auto const& rValue : rParameters) -{ -if (rValue.Name == "Compression") -rValue.Value >>= mnCompressionLevel; -else if (rValue.Name == "Interlaced") -rValue.Value >>= mbInterlaced; -} -} -bool write(BitmapEx& rBitmap); +virtual ~PngImageWriter() = default; + +void setParameters(css::uno::Sequence const& rParameters); +bool write(const BitmapEx& rBitmap); }; } // namespace vcl diff --git a/vcl/qa/cppunit/png/PngFilterTest.cxx b/vcl/qa/cppunit/png/PngFilterTest.cxx index 64a99756aa89..33af620eb08a 100644 --- a/vcl/qa/cppunit/png/PngFilterTest.cxx +++ b/vcl/qa/cppunit/png/PngFilterTest.cxx @@ -1696,16 +1696,65 @@ void PngFilterTest::testPngSuite() void PngFilterTest::testMsGifInPng() { -Graphic aGraphic; -const OUString aURL(getFullUrl(u"ms-gif.png")); -SvFileStream aFileStream(aURL, StreamMode::READ); GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); -ErrCode aResult = rFilter.ImportGraphic(aGraphic, aURL, aFileStream); -CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, aResult); -CPPUNIT_ASSERT(aGraphic.IsGfxLink()); -// The image is technically a PNG, but it has an animated Gif as a chunk (Microsoft extension). -CPPUNIT_ASSERT_EQUAL(GfxLinkType::NativeGif, aGraphic.GetSharedGfxLink()->GetType()); -CPPUNIT_ASSERT(aGraphic.IsAnimated()); +{ +Graphic aGraphic; +const OUString aURL(getFullUrl(u"ms-gif.png")); +SvFileStream aFileStream(aURL, StreamMode::READ); +ErrCode aResult = rFilter.ImportGraphic(aGraphic, aURL, aFileStream); +CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, aResult); +CPPUNIT_ASSERT(aGraphic.IsGfxLink()); +// The image is technically a PNG, but it has an animated Gif as a chunk (Microsoft extension). +CPPUNIT_ASSERT_EQUAL(GfxLinkType::NativeGif, aGraphic.GetSharedGfxLink()->GetType()); +CPPUNIT_ASSERT(aGraphic.IsAnimated()); +} +{ +// Tests msOG chunk export support +const OUString aURL(getFullUrl(u"dummy.gif")); +SvFileStream aGIFStream(aURL, StreamMode::READ); +sal_uInt32 nGIFSize = aGIFStream.TellEnd(); +const char* const pHeader = "MSOFFICE9.0"; +auto nHeaderSize = strlen(pHeader); +uno::Sequence aGIFSequence(nHeaderSize + nGIFSize); +sal_Int8* pSequence = aGIFSequence.getArray(); +for (size_t i = 0; i < nHeaderSize; i++) +*pSequence++ = pHeader[i]; +aGIFStream.Seek(STREAM_SEEK_TO_BEGIN); +aGIFStream.ReadBytes(pSequence, nGIFSize); +// Create msOG chunk +beans::PropertyValue aChunkProperty, aFilterProperty; +aChunkProperty.Name = "msOG"; +aChunkProperty.Value <<= aGIFSequence; +uno::Sequence aAdditionalChunkSequence{ aChunkProperty }; +aFilterProperty.Name = "AdditionalChunks"; +aFilterProperty.Value <<= aAdditionalChunkSequence; +uno::Sequence aPNGParameters{ aFilterProperty }; +// Export the png with the chunk +OUString ext = u".png"; +utl::TempFile aTempFile(u"testPngExportMsGif", true, ); +if (!bKeepTemp) +aTempFile.EnableKillingFile(); +{ +SvStream& rStream =
[Libreoffice-commits] core.git: vcl/qa vcl/source
vcl/qa/cppunit/png/PngFilterTest.cxx | 49 +++ vcl/source/filter/png/PngImageWriter.cxx |5 +-- 2 files changed, 52 insertions(+), 2 deletions(-) New commits: commit 3d1032cf6b67f3f6fa539d1d42d681080517d38c Author: offtkp AuthorDate: Tue Jul 5 00:49:14 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 09:59:27 2022 +0200 Add PngImageWriter 8 bit palette export support Also add test that fills a 256 color palette, exports a 16x16 image and reimports it and checks each pixel color Change-Id: Id53f3116e42d669cd528edfd791a1a981551ae0f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136817 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/qa/cppunit/png/PngFilterTest.cxx b/vcl/qa/cppunit/png/PngFilterTest.cxx index 2eae9544ecbb..64a99756aa89 100644 --- a/vcl/qa/cppunit/png/PngFilterTest.cxx +++ b/vcl/qa/cppunit/png/PngFilterTest.cxx @@ -176,6 +176,7 @@ public: void testPngRoundtrip24_8(); void testPngRoundtrip32(); void testPngWrite1BitRGBPalette(); +void testPngWrite8BitRGBPalette(); CPPUNIT_TEST_SUITE(PngFilterTest); CPPUNIT_TEST(testPng); @@ -186,6 +187,7 @@ public: CPPUNIT_TEST(testPngRoundtrip24_8); CPPUNIT_TEST(testPngRoundtrip32); CPPUNIT_TEST(testPngWrite1BitRGBPalette); +CPPUNIT_TEST(testPngWrite8BitRGBPalette); CPPUNIT_TEST_SUITE_END(); }; @@ -1929,6 +1931,53 @@ void PngFilterTest::testPngWrite1BitRGBPalette() } } +void PngFilterTest::testPngWrite8BitRGBPalette() +{ +SvMemoryStream aExportStream; +BitmapPalette aRedPalette; +aRedPalette.SetEntryCount(256); +for (sal_uInt16 i = 0; i < 256; i++) +{ +aRedPalette[i].SetRed(i); +aRedPalette[i].SetGreen(0); +aRedPalette[i].SetBlue(0); +} +{ +Bitmap aBitmap(Size(16, 16), vcl::PixelFormat::N8_BPP, ); +{ +BitmapScopedWriteAccess pWriteAccessBitmap(aBitmap); +for (int i = 0; i < 16; i++) +{ +for (int j = 0; j < 16; j++) +{ +pWriteAccessBitmap->SetPixelIndex(i, j, i * 16 + j); +} +} +} +BitmapEx aBitmapEx(aBitmap); +vcl::PngImageWriter aPngWriter(aExportStream); +CPPUNIT_ASSERT_EQUAL(true, aPngWriter.write(aBitmapEx)); +} +aExportStream.Seek(0); +{ +vcl::PngImageReader aPngReader(aExportStream); +BitmapEx aBitmapEx; +CPPUNIT_ASSERT_EQUAL(true, aPngReader.read(aBitmapEx)); + +CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Width()); +CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Height()); + +for (int i = 0; i < 16; i++) +{ +for (int j = 0; j < 16; j++) +{ +CPPUNIT_ASSERT_EQUAL(aRedPalette[i * 16 + j].GetRGBColor(), + aBitmapEx.GetPixelColor(j, i)); +} +} +} +} + CPPUNIT_TEST_SUITE_REGISTRATION(PngFilterTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/vcl/source/filter/png/PngImageWriter.cxx b/vcl/source/filter/png/PngImageWriter.cxx index 48399ba05018..6a123e4eb547 100644 --- a/vcl/source/filter/png/PngImageWriter.cxx +++ b/vcl/source/filter/png/PngImageWriter.cxx @@ -110,8 +110,9 @@ static bool pngWrite(SvStream& rStream, BitmapEx& rBitmapEx, int nCompressionLev case ScanlineFormat::N8BitPal: { if (!aBitmap.HasGreyPalette8Bit()) -return false; -colorType = PNG_COLOR_TYPE_GRAY; +colorType = PNG_COLOR_TYPE_PALETTE; +else +colorType = PNG_COLOR_TYPE_GRAY; bitDepth = 8; break; }
[Libreoffice-commits] core.git: vcl/qa vcl/source
vcl/qa/cppunit/png/PngFilterTest.cxx | 66 +++ vcl/source/filter/png/PngImageWriter.cxx | 24 +++ 2 files changed, 90 insertions(+) New commits: commit 80395bf5f2bc7d48c690893abf8604540c24806f Author: offtkp AuthorDate: Mon Jul 4 22:07:28 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 09:59:03 2022 +0200 Add PngImageWriter 1 bit palette export support Added support for exporting 1 bit palette png for non grayscale images and unit test Change-Id: I0b4c63c922fad4e42c7db61e81c553c69dd6bff6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136813 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/qa/cppunit/png/PngFilterTest.cxx b/vcl/qa/cppunit/png/PngFilterTest.cxx index 81531f21b0e6..2eae9544ecbb 100644 --- a/vcl/qa/cppunit/png/PngFilterTest.cxx +++ b/vcl/qa/cppunit/png/PngFilterTest.cxx @@ -175,6 +175,7 @@ public: void testPngRoundtrip24(); void testPngRoundtrip24_8(); void testPngRoundtrip32(); +void testPngWrite1BitRGBPalette(); CPPUNIT_TEST_SUITE(PngFilterTest); CPPUNIT_TEST(testPng); @@ -184,6 +185,7 @@ public: CPPUNIT_TEST(testPngRoundtrip24); CPPUNIT_TEST(testPngRoundtrip24_8); CPPUNIT_TEST(testPngRoundtrip32); +CPPUNIT_TEST(testPngWrite1BitRGBPalette); CPPUNIT_TEST_SUITE_END(); }; @@ -1863,6 +1865,70 @@ void PngFilterTest::testPngRoundtrip24_8() void PngFilterTest::testPngRoundtrip32() {} +void PngFilterTest::testPngWrite1BitRGBPalette() +{ +SvMemoryStream aExportStream; +{ +BitmapPalette aPal; +aPal.SetEntryCount(2); +aPal[0] = COL_RED; +aPal[1] = COL_GREEN; +Bitmap aBitmap(Size(16, 16), vcl::PixelFormat::N1_BPP, ); +{ +BitmapScopedWriteAccess pWriteAccessBitmap(aBitmap); +// Top left +for (int i = 0; i < 8; i++) +{ +for (int j = 0; j < 8; j++) +{ +pWriteAccessBitmap->SetPixelIndex(i, j, 0); +} +} +// Top right +for (int i = 0; i < 8; i++) +{ +for (int j = 8; j < 16; j++) +{ +pWriteAccessBitmap->SetPixelIndex(i, j, 1); +} +} +// Bottom left +for (int i = 8; i < 16; i++) +{ +for (int j = 0; j < 8; j++) +{ +pWriteAccessBitmap->SetPixelIndex(i, j, 1); +} +} +// Bottom right +for (int i = 8; i < 16; i++) +{ +for (int j = 8; j < 16; j++) +{ +pWriteAccessBitmap->SetPixelIndex(i, j, 0); +} +} +} +BitmapEx aBitmapEx(aBitmap); +vcl::PngImageWriter aPngWriter(aExportStream); +CPPUNIT_ASSERT_EQUAL(true, aPngWriter.write(aBitmapEx)); +} +aExportStream.Seek(0); +{ +vcl::PngImageReader aPngReader(aExportStream); +BitmapEx aBitmapEx; +CPPUNIT_ASSERT_EQUAL(true, aPngReader.read(aBitmapEx)); + +CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Width()); +CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Height()); + +CPPUNIT_ASSERT_EQUAL(COL_RED, aBitmapEx.GetPixelColor(0, 0)); +CPPUNIT_ASSERT_EQUAL(COL_RED, aBitmapEx.GetPixelColor(15, 15)); +CPPUNIT_ASSERT_EQUAL(COL_GREEN, aBitmapEx.GetPixelColor(15, 0)); +CPPUNIT_ASSERT_EQUAL(COL_GREEN, aBitmapEx.GetPixelColor(0, 15)); +} +} + CPPUNIT_TEST_SUITE_REGISTRATION(PngFilterTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/vcl/source/filter/png/PngImageWriter.cxx b/vcl/source/filter/png/PngImageWriter.cxx index b83683b181da..48399ba05018 100644 --- a/vcl/source/filter/png/PngImageWriter.cxx +++ b/vcl/source/filter/png/PngImageWriter.cxx @@ -100,6 +100,13 @@ static bool pngWrite(SvStream& rStream, BitmapEx& rBitmapEx, int nCompressionLev auto eScanlineFormat = pAccess->GetScanlineFormat(); switch (eScanlineFormat) { +case ScanlineFormat::N1BitMsbPal: +case ScanlineFormat::N1BitLsbPal: +{ +colorType = PNG_COLOR_TYPE_PALETTE; +bitDepth = 1; +break; +} case ScanlineFormat::N8BitPal: { if (!aBitmap.HasGreyPalette8Bit()) @@ -133,6 +140,23 @@ static bool pngWrite(SvStream& rStream, BitmapEx& rBitmapEx, int nCompressionLev int compressionType = PNG_COMPRESSION_TYPE_DEFAULT; int filterMethod = PNG_FILTER_TYPE_DEFAULT; +// Convert BitmapPalette to png_color* +if (colorType == PNG_COLOR_TYPE_PALETTE) +{ +// Reserve enough space for 3 channels for each palette entry +auto aBitmapPalette = pAccess->GetPalette(); +
[Libreoffice-commits] core.git: vcl/qa
vcl/qa/cppunit/png/PngFilterTest.cxx | 1445 +++ vcl/qa/cppunit/png/data/basi0g01.png |binary vcl/qa/cppunit/png/data/basi0g02.png |binary vcl/qa/cppunit/png/data/basi0g04.png |binary vcl/qa/cppunit/png/data/basi0g08.png |binary vcl/qa/cppunit/png/data/basi0g16.png |binary vcl/qa/cppunit/png/data/basi2c08.png |binary vcl/qa/cppunit/png/data/basi2c16.png |binary vcl/qa/cppunit/png/data/basi3p01.png |binary vcl/qa/cppunit/png/data/basi3p02.png |binary vcl/qa/cppunit/png/data/basi3p04.png |binary vcl/qa/cppunit/png/data/basi3p08.png |binary vcl/qa/cppunit/png/data/basi4a08.png |binary vcl/qa/cppunit/png/data/basi4a16.png |binary vcl/qa/cppunit/png/data/basi6a08.png |binary vcl/qa/cppunit/png/data/basi6a16.png |binary vcl/qa/cppunit/png/data/basn0g01.png |binary vcl/qa/cppunit/png/data/basn0g02.png |binary vcl/qa/cppunit/png/data/basn0g04.png |binary vcl/qa/cppunit/png/data/basn0g08.png |binary vcl/qa/cppunit/png/data/basn0g16.png |binary vcl/qa/cppunit/png/data/basn2c08.png |binary vcl/qa/cppunit/png/data/basn2c16.png |binary vcl/qa/cppunit/png/data/basn3p01.png |binary vcl/qa/cppunit/png/data/basn3p02.png |binary vcl/qa/cppunit/png/data/basn3p04.png |binary vcl/qa/cppunit/png/data/basn3p08.png |binary vcl/qa/cppunit/png/data/basn4a08.png |binary vcl/qa/cppunit/png/data/basn4a16.png |binary vcl/qa/cppunit/png/data/basn6a08.png |binary vcl/qa/cppunit/png/data/basn6a16.png |binary vcl/qa/cppunit/png/data/bgai4a08.png |binary vcl/qa/cppunit/png/data/bgai4a16.png |binary vcl/qa/cppunit/png/data/bgan6a08.png |binary vcl/qa/cppunit/png/data/bgan6a16.png |binary vcl/qa/cppunit/png/data/bgbn4a08.png |binary vcl/qa/cppunit/png/data/bggn4a16.png |binary vcl/qa/cppunit/png/data/bgwn6a08.png |binary vcl/qa/cppunit/png/data/bgyn6a16.png |binary vcl/qa/cppunit/png/data/ccwn2c08.png |binary vcl/qa/cppunit/png/data/ccwn3p08.png |binary vcl/qa/cppunit/png/data/cdfn2c08.png |binary vcl/qa/cppunit/png/data/cdhn2c08.png |binary vcl/qa/cppunit/png/data/cdsn2c08.png |binary vcl/qa/cppunit/png/data/cdun2c08.png |binary vcl/qa/cppunit/png/data/ch1n3p04.png |binary vcl/qa/cppunit/png/data/ch2n3p08.png |binary vcl/qa/cppunit/png/data/cm0n0g04.png |binary vcl/qa/cppunit/png/data/cm7n0g04.png |binary vcl/qa/cppunit/png/data/cm9n0g04.png |binary vcl/qa/cppunit/png/data/cs3n2c16.png |binary vcl/qa/cppunit/png/data/cs3n3p08.png |binary vcl/qa/cppunit/png/data/cs5n2c08.png |binary vcl/qa/cppunit/png/data/cs5n3p08.png |binary vcl/qa/cppunit/png/data/cs8n2c08.png |binary vcl/qa/cppunit/png/data/cs8n3p08.png |binary vcl/qa/cppunit/png/data/ct0n0g04.png |binary vcl/qa/cppunit/png/data/ct1n0g04.png |binary vcl/qa/cppunit/png/data/cten0g04.png |binary vcl/qa/cppunit/png/data/ctfn0g04.png |binary vcl/qa/cppunit/png/data/ctgn0g04.png |binary vcl/qa/cppunit/png/data/cthn0g04.png |binary vcl/qa/cppunit/png/data/ctjn0g04.png |binary vcl/qa/cppunit/png/data/ctzn0g04.png |binary vcl/qa/cppunit/png/data/exif2c08.png |binary vcl/qa/cppunit/png/data/f00n0g08.png |binary vcl/qa/cppunit/png/data/f00n2c08.png |binary vcl/qa/cppunit/png/data/f01n0g08.png |binary vcl/qa/cppunit/png/data/f01n2c08.png |binary vcl/qa/cppunit/png/data/f02n0g08.png |binary vcl/qa/cppunit/png/data/f02n2c08.png |binary vcl/qa/cppunit/png/data/f03n0g08.png |binary vcl/qa/cppunit/png/data/f03n2c08.png |binary vcl/qa/cppunit/png/data/f04n0g08.png |binary vcl/qa/cppunit/png/data/f04n2c08.png |binary vcl/qa/cppunit/png/data/f99n0g04.png |binary vcl/qa/cppunit/png/data/g03n0g16.png |binary vcl/qa/cppunit/png/data/g03n2c08.png |binary vcl/qa/cppunit/png/data/g03n3p04.png |binary vcl/qa/cppunit/png/data/g04n0g16.png |binary vcl/qa/cppunit/png/data/g04n2c08.png |binary vcl/qa/cppunit/png/data/g04n3p04.png |binary vcl/qa/cppunit/png/data/g05n0g16.png |binary vcl/qa/cppunit/png/data/g05n2c08.png |binary vcl/qa/cppunit/png/data/g05n3p04.png |binary vcl/qa/cppunit/png/data/g07n0g16.png |binary vcl/qa/cppunit/png/data/g07n2c08.png |binary vcl/qa/cppunit/png/data/g07n3p04.png |binary vcl/qa/cppunit/png/data/g10n0g16.png |binary vcl/qa/cppunit/png/data/g10n2c08.png |binary vcl/qa/cppunit/png/data/g10n3p04.png |binary vcl/qa/cppunit/png/data/g25n0g16.png |binary vcl/qa/cppunit/png/data/g25n2c08.png |binary vcl/qa/cppunit/png/data/g25n3p04.png |binary vcl/qa/cppunit/png/data/oi1n0g16.png |binary vcl/qa/cppunit/png/data/oi1n2c16.png |binary vcl/qa/cppunit/png/data/oi2n0g16.png |binary vcl/qa/cppunit/png/data/oi2n2c16.png |binary vcl/qa/cppunit/png/data/oi4n0g16.png |binary vcl/qa/cppunit/png/data/oi4n2c16.png |binary vcl/qa/cppunit/png/data/oi9n0g16.png |binary vcl/qa/cppunit/png/data/oi9n2c16.png |binary vcl/qa/cppunit/png/data/pp0n2c16.png |binary vcl/qa/cppunit/png/data/pp0n6a08.png |binary vcl/qa/cppunit/png/data/ps1n0g08.png |binary vcl/qa/cppunit/png/data/ps1n2c16.png |binary vcl/qa/cppunit/png/data/ps2n0g08.png |binary vcl/qa/cppunit/png/data/ps2n2c16.png
[Libreoffice-commits] core.git: include/vcl vcl/Library_vcl.mk vcl/qa vcl/source
include/vcl/filter/PngImageWriter.hxx| 49 +++ vcl/Library_vcl.mk |1 vcl/qa/cppunit/png/PngFilterTest.cxx | 173 +++ vcl/source/filter/png/PngImageWriter.cxx | 196 +++ 4 files changed, 419 insertions(+) New commits: commit 6b4f4bdf9beb0c73fa8b8bc218cd206f2cd347fa Author: offtkp AuthorDate: Sun Mar 7 13:48:39 2021 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Jul 19 09:57:19 2022 +0200 vcl: add PNG writer based on libpng Add PngImageWriter, a new png writer that uses libpng to replace our own at pngwrite.cxx PS: most of the work on this commit is done by Tomaž Change-Id: I52ffd1b286162ee0dd9f694c4f3210385f71daf8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136008 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/vcl/filter/PngImageWriter.hxx b/include/vcl/filter/PngImageWriter.hxx new file mode 100644 index ..667dd540e332 --- /dev/null +++ b/include/vcl/filter/PngImageWriter.hxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include +#include +#include + +#pragma once + +namespace vcl +{ +class VCL_DLLPUBLIC PngImageWriter +{ +SvStream& mrStream; +css::uno::Reference mxStatusIndicator; + +sal_Int32 mnCompressionLevel; +bool mbInterlaced; + +public: +PngImageWriter(SvStream& rStream); + +virtual ~PngImageWriter() {} + +void setParameters(css::uno::Sequence const& rParameters) +{ +for (auto const& rValue : rParameters) +{ +if (rValue.Name == "Compression") +rValue.Value >>= mnCompressionLevel; +else if (rValue.Name == "Interlaced") +rValue.Value >>= mbInterlaced; +} +} +bool write(BitmapEx& rBitmap); +}; + +} // namespace vcl + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 5688f1f22ecc..b265467d2696 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -472,6 +472,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/filter/wmf/wmfexternal \ vcl/source/filter/wmf/wmfwr \ vcl/source/filter/png/PngImageReader \ +vcl/source/filter/png/PngImageWriter \ vcl/source/filter/png/pngwrite \ vcl/source/filter/webp/reader \ vcl/source/filter/webp/writer \ diff --git a/vcl/qa/cppunit/png/PngFilterTest.cxx b/vcl/qa/cppunit/png/PngFilterTest.cxx index c167c4c9c636..727f86c9476b 100644 --- a/vcl/qa/cppunit/png/PngFilterTest.cxx +++ b/vcl/qa/cppunit/png/PngFilterTest.cxx @@ -24,14 +24,20 @@ #include #include #include +#include #include +#include #include #include +#include using namespace css; class PngFilterTest : public test::BootstrapFixture { +// Should keep the temp files (should be false) +static constexpr bool bKeepTemp = true; + OUString maDataUrl; OUString getFullUrl(std::u16string_view sFileName) @@ -48,10 +54,18 @@ public: void testPng(); void testMsGifInPng(); +void testPngRoundtrip8BitGrey(); +void testPngRoundtrip24(); +void testPngRoundtrip24_8(); +void testPngRoundtrip32(); CPPUNIT_TEST_SUITE(PngFilterTest); CPPUNIT_TEST(testPng); CPPUNIT_TEST(testMsGifInPng); +CPPUNIT_TEST(testPngRoundtrip8BitGrey); +CPPUNIT_TEST(testPngRoundtrip24); +CPPUNIT_TEST(testPngRoundtrip24_8); +CPPUNIT_TEST(testPngRoundtrip32); CPPUNIT_TEST_SUITE_END(); }; @@ -245,6 +259,165 @@ void PngFilterTest::testMsGifInPng() CPPUNIT_ASSERT(aGraphic.IsAnimated()); } +void PngFilterTest::testPngRoundtrip8BitGrey() +{ +utl::TempFile aTempFile(u"testPngRoundtrip8BitGrey"); +if (!bKeepTemp) +aTempFile.EnableKillingFile(); +{ +SvStream& rStream = *aTempFile.GetStream(StreamMode::WRITE); +Bitmap aBitmap(Size(16, 16), vcl::PixelFormat::N8_BPP, ::GetGreyPalette(256)); +{ +BitmapScopedWriteAccess pWriteAccess(aBitmap); +pWriteAccess->Erase(COL_BLACK); +for (int i = 0; i < 8; ++i) +{ +for (int j = 0; j < 8; ++j) +{ +pWriteAccess->SetPixel(i, j, COL_GRAY); +} +} +for (int i = 8; i < 16; ++i) +{ +for (int j = 8; j < 16; ++j) +{ +pWriteAccess->SetPixel(i, j, COL_LIGHTGRAY); +} +} +} +BitmapEx aBitmapEx(aBitmap); + +vcl::PngImageWriter aPngWriter(rStream); +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - svgio/inc svgio/source
svgio/inc/svgstylenode.hxx |4 ++-- svgio/source/svgreader/svgstylenode.cxx | 31 ++- 2 files changed, 16 insertions(+), 19 deletions(-) New commits: commit c9f71c923f82cf430c3b67ee7af8ff9c681e7c0b Author: offtkp AuthorDate: Sun Jun 19 23:52:58 2022 +0300 Commit: Xisco Fauli CommitDate: Tue Jul 12 13:51:11 2022 +0200 tdf#149449 Don't ignore CSS class redefinition inside SVGs Previously if a css class was redefined like so: .cls2,.cls3{fill:#fff;}.cls-2{opacity:0.1;} the second definition of .cls-2 would get ignored and opacity would remain 1. This patch keeps track of the names of each previously defined class and makes sure to append the future redefinition instead of ignoring it. Change-Id: I20b55aea247d11774cd743505a90f1466f622b1e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136109 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 99f8e8aa0ccb741c2b5ede6cab75798c1793d899) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136244 Reviewed-by: Xisco Fauli (cherry picked from commit 34e08a82a317e06d2526f5a16a522323c3902bd7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136981 diff --git a/svgio/inc/svgstylenode.hxx b/svgio/inc/svgstylenode.hxx index 320b4fa17dcc..1a5a43ca858c 100644 --- a/svgio/inc/svgstylenode.hxx +++ b/svgio/inc/svgstylenode.hxx @@ -19,6 +19,7 @@ #pragma once +#include #include "svgnode.hxx" #include "svgstyleattributes.hxx" @@ -28,7 +29,7 @@ namespace svgio::svgreader { private: /// use styles -std::vector< SvgStyleAttributes* > maSvgStyleAttributes; +std::unordered_map< OUString, std::unique_ptr > maSvgStyleAttributes; boolmbTextCss : 1; // true == type is 'text/css' @@ -36,7 +37,6 @@ namespace svgio::svgreader SvgStyleNode( SvgDocument& rDocument, SvgNode* pParent); -virtual ~SvgStyleNode() override; /// #i125258# tell if this node is allowed to have a parent style (e.g. defs do not) virtual bool supportsParentStyle() const override; diff --git a/svgio/source/svgreader/svgstylenode.cxx b/svgio/source/svgreader/svgstylenode.cxx index 89f6200138bd..f9d33d61ced3 100644 --- a/svgio/source/svgreader/svgstylenode.cxx +++ b/svgio/source/svgreader/svgstylenode.cxx @@ -31,15 +31,6 @@ namespace svgio::svgreader { } -SvgStyleNode::~SvgStyleNode() -{ -while(!maSvgStyleAttributes.empty()) -{ -delete *(maSvgStyleAttributes.end() - 1); -maSvgStyleAttributes.pop_back(); -} -} - // #i125258# no parent when we are a CssStyle holder to break potential loops because // when using CssStyles we jump uncontrolled inside the node tree hierarchy bool SvgStyleNode::supportsParentStyle() const @@ -148,13 +139,6 @@ namespace svgio::svgreader if(aSelectors.isEmpty() || aContent.isEmpty()) return; -// create new style and add to local list (for ownership control) -SvgStyleAttributes* pNewStyle = new SvgStyleAttributes(*this); -maSvgStyleAttributes.push_back(pNewStyle); - -// fill with content -pNewStyle->readCssStyle(aContent); - // comma-separated split (Css abbreviation for same style for multiple selectors) const sal_Int32 nLen(aSelectors.getLength()); sal_Int32 nPos(0); @@ -168,9 +152,22 @@ namespace svgio::svgreader const OUString aSingleName(aToken.makeStringAndClear().trim()); +// add the current css class only if wasn't previously added +auto [aIterator, bIsNew] = maSvgStyleAttributes.try_emplace(aSingleName); +if (bIsNew) +{ +// create new style and add to local list (for ownership control) and +// in case it's written to again in future classes to prevent overwrites +aIterator->second = std::make_unique(*this); +} +const std::unique_ptr& pCurrentStyle = aIterator->second; + +// fill with content +pCurrentStyle->readCssStyle(aContent); + if(aSingleName.getLength()) { -addCssStyleSheet(aSingleName, *pNewStyle); +addCssStyleSheet(aSingleName, *pCurrentStyle); } if(nInitPos == nPos)
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - svgio/qa
svgio/qa/cppunit/SvgImportTest.cxx | 22 ++ svgio/qa/cppunit/data/CssClassRedefinition.svg | 13 + 2 files changed, 35 insertions(+) New commits: commit d931e8876cbaf8e409ebbba97d991d0099124de4 Author: offtkp AuthorDate: Mon Jun 20 15:23:14 2022 +0300 Commit: Stephan Bergmann CommitDate: Thu Jun 23 23:08:24 2022 +0200 tdf#149449 Add unit test for CSS class redefinition inside SVGs Tests what happens when a CSS class is redefined with new attributes and with already defined attributes Change-Id: I5996fa4dce6c98c1792001a11387bf570d159a8f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136151 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit eedc5b1c576fcaaea85a5278762efc8ba8c5a084) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136315 Reviewed-by: Stephan Bergmann diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 4f9ee58f68db..650dbdde67f6 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -70,6 +70,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools void testTdf94765(); void testBehaviourWhenWidthAndHeightIsOrIsNotSet(); void testTdf97663(); +void testCssClassRedefinition(); Primitive2DSequence parseSvg(std::u16string_view aSource); @@ -106,6 +107,7 @@ public: CPPUNIT_TEST(testTdf94765); CPPUNIT_TEST(testBehaviourWhenWidthAndHeightIsOrIsNotSet); CPPUNIT_TEST(testTdf97663); +CPPUNIT_TEST(testCssClassRedefinition); CPPUNIT_TEST_SUITE_END(); }; @@ -833,6 +835,26 @@ void Test::testTdf97663() assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", "236"); } +void Test::testCssClassRedefinition() +{ +// Tests for svg css class redefinition behavior +// Example: +// .c1 {fill:#00ff00} +// .c1 {font-family:Sans} +// .c1 {fill:#ff} +// Expected result is .c1 {font-family:Sans; fill:#ff} because +// the second redefinition appends attributes to the class and the +// third redefinition replaces the already existing +// attribute in the original definition +Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/CssClassRedefinition.svg"); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "test"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#ff"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Sans"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } diff --git a/svgio/qa/cppunit/data/CssClassRedefinition.svg b/svgio/qa/cppunit/data/CssClassRedefinition.svg new file mode 100644 index ..87eb2023384b --- /dev/null +++ b/svgio/qa/cppunit/data/CssClassRedefinition.svg @@ -0,0 +1,13 @@ +http://www.w3.org/2000/svg; width="50 px" height="100 px"> + +.c1 {fill:#00ff00} + +.c1 {font-family:Sans} + +.c1 {fill:#ff} + + + +test + +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - svgio/inc svgio/source
svgio/inc/svgstylenode.hxx |4 ++-- svgio/source/svgreader/svgstylenode.cxx | 31 ++- 2 files changed, 16 insertions(+), 19 deletions(-) New commits: commit 34e08a82a317e06d2526f5a16a522323c3902bd7 Author: offtkp AuthorDate: Sun Jun 19 23:52:58 2022 +0300 Commit: Xisco Fauli CommitDate: Thu Jun 23 11:11:21 2022 +0200 tdf#149449 Don't ignore CSS class redefinition inside SVGs Previously if a css class was redefined like so: .cls2,.cls3{fill:#fff;}.cls-2{opacity:0.1;} the second definition of .cls-2 would get ignored and opacity would remain 1. This patch keeps track of the names of each previously defined class and makes sure to append the future redefinition instead of ignoring it. Change-Id: I20b55aea247d11774cd743505a90f1466f622b1e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136109 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 99f8e8aa0ccb741c2b5ede6cab75798c1793d899) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136244 Reviewed-by: Xisco Fauli diff --git a/svgio/inc/svgstylenode.hxx b/svgio/inc/svgstylenode.hxx index 320b4fa17dcc..1a5a43ca858c 100644 --- a/svgio/inc/svgstylenode.hxx +++ b/svgio/inc/svgstylenode.hxx @@ -19,6 +19,7 @@ #pragma once +#include #include "svgnode.hxx" #include "svgstyleattributes.hxx" @@ -28,7 +29,7 @@ namespace svgio::svgreader { private: /// use styles -std::vector< SvgStyleAttributes* > maSvgStyleAttributes; +std::unordered_map< OUString, std::unique_ptr > maSvgStyleAttributes; boolmbTextCss : 1; // true == type is 'text/css' @@ -36,7 +37,6 @@ namespace svgio::svgreader SvgStyleNode( SvgDocument& rDocument, SvgNode* pParent); -virtual ~SvgStyleNode() override; /// #i125258# tell if this node is allowed to have a parent style (e.g. defs do not) virtual bool supportsParentStyle() const override; diff --git a/svgio/source/svgreader/svgstylenode.cxx b/svgio/source/svgreader/svgstylenode.cxx index 89f6200138bd..f9d33d61ced3 100644 --- a/svgio/source/svgreader/svgstylenode.cxx +++ b/svgio/source/svgreader/svgstylenode.cxx @@ -31,15 +31,6 @@ namespace svgio::svgreader { } -SvgStyleNode::~SvgStyleNode() -{ -while(!maSvgStyleAttributes.empty()) -{ -delete *(maSvgStyleAttributes.end() - 1); -maSvgStyleAttributes.pop_back(); -} -} - // #i125258# no parent when we are a CssStyle holder to break potential loops because // when using CssStyles we jump uncontrolled inside the node tree hierarchy bool SvgStyleNode::supportsParentStyle() const @@ -148,13 +139,6 @@ namespace svgio::svgreader if(aSelectors.isEmpty() || aContent.isEmpty()) return; -// create new style and add to local list (for ownership control) -SvgStyleAttributes* pNewStyle = new SvgStyleAttributes(*this); -maSvgStyleAttributes.push_back(pNewStyle); - -// fill with content -pNewStyle->readCssStyle(aContent); - // comma-separated split (Css abbreviation for same style for multiple selectors) const sal_Int32 nLen(aSelectors.getLength()); sal_Int32 nPos(0); @@ -168,9 +152,22 @@ namespace svgio::svgreader const OUString aSingleName(aToken.makeStringAndClear().trim()); +// add the current css class only if wasn't previously added +auto [aIterator, bIsNew] = maSvgStyleAttributes.try_emplace(aSingleName); +if (bIsNew) +{ +// create new style and add to local list (for ownership control) and +// in case it's written to again in future classes to prevent overwrites +aIterator->second = std::make_unique(*this); +} +const std::unique_ptr& pCurrentStyle = aIterator->second; + +// fill with content +pCurrentStyle->readCssStyle(aContent); + if(aSingleName.getLength()) { -addCssStyleSheet(aSingleName, *pNewStyle); +addCssStyleSheet(aSingleName, *pCurrentStyle); } if(nInitPos == nPos)
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/graphicfilter2.cxx | 64 +++ 1 file changed, 58 insertions(+), 6 deletions(-) New commits: commit 56bfb93d0028b735adaddd7d23be96145a7bd2ed Author: offtkp AuthorDate: Tue May 24 16:28:08 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Wed Jun 22 14:16:37 2022 +0200 Detect WMF from header instead of extension Change ImpDetectWMF function to detect a WMF file from its header instead of just comparing the extension. Change-Id: I5a31cfd52b5425ab94424c2edce842365db04e8c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134876 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index c02e9d557c44..fb001ee14a25 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -30,9 +30,24 @@ #include "graphicfilter_internal.hxx" #define DATA_SIZE 640 -constexpr sal_uInt32 EMF_CHECK_SIZE= 44; -constexpr sal_uInt32 EMR_HEADER= 0x0001; -constexpr sal_uInt32 ENHMETA_SIGNATURE = 0x464d4520; +constexpr sal_uInt32 EMF_CHECK_SIZE = 44; +constexpr sal_uInt32 WMF_CHECK_SIZE = 32; +constexpr sal_uInt32 EMR_HEADER = 0x0001; +constexpr sal_uInt32 ENHMETA_SIGNATURE = 0x464d4520; +constexpr sal_uInt32 PLACEABLE_SIGNATURE = 0xd7cdc69a; +namespace +{ +enum class MetafileType : sal_uInt16 +{ +Memory = 0x0001, +Disk = 0x0002, +}; +enum class MetafileVersion : sal_uInt16 +{ +Version100 = 0x0100, +Version300 = 0x0300, +}; +} GraphicDescriptor::GraphicDescriptor( const INetURLObject& rPath ) : pFileStm( ::utl::UcbStreamHelper::CreateStream( rPath.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ).release() ), @@ -1081,12 +1096,49 @@ bool GraphicDescriptor::ImpDetectSVM( SvStream& rStm, bool bExtendedInfo ) return bRet; } -bool GraphicDescriptor::ImpDetectWMF( SvStream&, bool ) +bool GraphicDescriptor::ImpDetectWMF(SvStream& rStm, bool) { -bool bRet = aPathExt.startsWith( "wmf" ) || aPathExt.startsWith( "wmz" ); -if (bRet) +bool bRet = false; +SvStream* aNewStream = +SvMemoryStream aMemStream; +sal_uInt8 aUncompressedBuffer[WMF_CHECK_SIZE]; +if (ZCodec::IsZCompressed(rStm)) +{ +ZCodec aCodec; +aCodec.BeginCompression(ZCODEC_DEFAULT_COMPRESSION, /*gzLib*/ true); +auto nDecompressLength = aCodec.Read(rStm, aUncompressedBuffer, WMF_CHECK_SIZE); +aCodec.EndCompression(); +if (nDecompressLength != WMF_CHECK_SIZE) +return false; +aMemStream.SetBuffer(aUncompressedBuffer, WMF_CHECK_SIZE, WMF_CHECK_SIZE); +aNewStream = +} +sal_uInt32 nKey = 0; +sal_Int32 nStmPos = rStm.Tell(); +aNewStream->SetEndian(SvStreamEndian::LITTLE); +aNewStream->ReadUInt32(nKey); +// Check if file is placeable WMF +if (nKey == PLACEABLE_SIGNATURE) +{ nFormat = GraphicFileFormat::WMF; +bRet = true; +} +else +{ +sal_uInt16 nKeyLSW = nKey & 0x; +sal_uInt16 nVersion = 0; +aNewStream->ReadUInt16(nVersion); +if ((nKeyLSW == static_cast(MetafileType::Memory) +|| nKeyLSW == static_cast(MetafileType::Disk)) +&& (nVersion == static_cast(MetafileVersion::Version100) +|| nVersion == static_cast(MetafileVersion::Version300))) +{ +nFormat = GraphicFileFormat::WMF; +bRet = true; +} +} +rStm.Seek(nStmPos); return bRet; }
[Libreoffice-commits] core.git: svgio/qa
svgio/qa/cppunit/SvgImportTest.cxx | 22 ++ svgio/qa/cppunit/data/CssClassRedefinition.svg | 13 + 2 files changed, 35 insertions(+) New commits: commit eedc5b1c576fcaaea85a5278762efc8ba8c5a084 Author: offtkp AuthorDate: Mon Jun 20 15:23:14 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Wed Jun 22 14:14:50 2022 +0200 tdf#149449 Add unit test for CSS class redefinition inside SVGs Tests what happens when a CSS class is redefined with new attributes and with already defined attributes Change-Id: I5996fa4dce6c98c1792001a11387bf570d159a8f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136151 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 4f9ee58f68db..650dbdde67f6 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -70,6 +70,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools void testTdf94765(); void testBehaviourWhenWidthAndHeightIsOrIsNotSet(); void testTdf97663(); +void testCssClassRedefinition(); Primitive2DSequence parseSvg(std::u16string_view aSource); @@ -106,6 +107,7 @@ public: CPPUNIT_TEST(testTdf94765); CPPUNIT_TEST(testBehaviourWhenWidthAndHeightIsOrIsNotSet); CPPUNIT_TEST(testTdf97663); +CPPUNIT_TEST(testCssClassRedefinition); CPPUNIT_TEST_SUITE_END(); }; @@ -833,6 +835,26 @@ void Test::testTdf97663() assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", "236"); } +void Test::testCssClassRedefinition() +{ +// Tests for svg css class redefinition behavior +// Example: +// .c1 {fill:#00ff00} +// .c1 {font-family:Sans} +// .c1 {fill:#ff} +// Expected result is .c1 {font-family:Sans; fill:#ff} because +// the second redefinition appends attributes to the class and the +// third redefinition replaces the already existing +// attribute in the original definition +Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/CssClassRedefinition.svg"); +drawinglayer::Primitive2dXmlDump dumper; +xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); +CPPUNIT_ASSERT (pDocument); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "test"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#ff"); +assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Sans"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } diff --git a/svgio/qa/cppunit/data/CssClassRedefinition.svg b/svgio/qa/cppunit/data/CssClassRedefinition.svg new file mode 100644 index ..87eb2023384b --- /dev/null +++ b/svgio/qa/cppunit/data/CssClassRedefinition.svg @@ -0,0 +1,13 @@ +http://www.w3.org/2000/svg; width="50 px" height="100 px"> + +.c1 {fill:#00ff00} + +.c1 {font-family:Sans} + +.c1 {fill:#ff} + + + +test + +
[Libreoffice-commits] core.git: svgio/inc svgio/source
svgio/inc/svgstylenode.hxx |4 ++-- svgio/source/svgreader/svgstylenode.cxx | 31 ++- 2 files changed, 16 insertions(+), 19 deletions(-) New commits: commit 99f8e8aa0ccb741c2b5ede6cab75798c1793d899 Author: offtkp AuthorDate: Sun Jun 19 23:52:58 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Wed Jun 22 14:14:27 2022 +0200 tdf#149449 Don't ignore CSS class redefinition inside SVGs Previously if a css class was redefined like so: .cls2,.cls3{fill:#fff;}.cls-2{opacity:0.1;} the second definition of .cls-2 would get ignored and opacity would remain 1. This patch keeps track of the names of each previously defined class and makes sure to append the future redefinition instead of ignoring it. Change-Id: I20b55aea247d11774cd743505a90f1466f622b1e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136109 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/svgio/inc/svgstylenode.hxx b/svgio/inc/svgstylenode.hxx index 320b4fa17dcc..1a5a43ca858c 100644 --- a/svgio/inc/svgstylenode.hxx +++ b/svgio/inc/svgstylenode.hxx @@ -19,6 +19,7 @@ #pragma once +#include #include "svgnode.hxx" #include "svgstyleattributes.hxx" @@ -28,7 +29,7 @@ namespace svgio::svgreader { private: /// use styles -std::vector< SvgStyleAttributes* > maSvgStyleAttributes; +std::unordered_map< OUString, std::unique_ptr > maSvgStyleAttributes; boolmbTextCss : 1; // true == type is 'text/css' @@ -36,7 +37,6 @@ namespace svgio::svgreader SvgStyleNode( SvgDocument& rDocument, SvgNode* pParent); -virtual ~SvgStyleNode() override; /// #i125258# tell if this node is allowed to have a parent style (e.g. defs do not) virtual bool supportsParentStyle() const override; diff --git a/svgio/source/svgreader/svgstylenode.cxx b/svgio/source/svgreader/svgstylenode.cxx index 89f6200138bd..f9d33d61ced3 100644 --- a/svgio/source/svgreader/svgstylenode.cxx +++ b/svgio/source/svgreader/svgstylenode.cxx @@ -31,15 +31,6 @@ namespace svgio::svgreader { } -SvgStyleNode::~SvgStyleNode() -{ -while(!maSvgStyleAttributes.empty()) -{ -delete *(maSvgStyleAttributes.end() - 1); -maSvgStyleAttributes.pop_back(); -} -} - // #i125258# no parent when we are a CssStyle holder to break potential loops because // when using CssStyles we jump uncontrolled inside the node tree hierarchy bool SvgStyleNode::supportsParentStyle() const @@ -148,13 +139,6 @@ namespace svgio::svgreader if(aSelectors.isEmpty() || aContent.isEmpty()) return; -// create new style and add to local list (for ownership control) -SvgStyleAttributes* pNewStyle = new SvgStyleAttributes(*this); -maSvgStyleAttributes.push_back(pNewStyle); - -// fill with content -pNewStyle->readCssStyle(aContent); - // comma-separated split (Css abbreviation for same style for multiple selectors) const sal_Int32 nLen(aSelectors.getLength()); sal_Int32 nPos(0); @@ -168,9 +152,22 @@ namespace svgio::svgreader const OUString aSingleName(aToken.makeStringAndClear().trim()); +// add the current css class only if wasn't previously added +auto [aIterator, bIsNew] = maSvgStyleAttributes.try_emplace(aSingleName); +if (bIsNew) +{ +// create new style and add to local list (for ownership control) and +// in case it's written to again in future classes to prevent overwrites +aIterator->second = std::make_unique(*this); +} +const std::unique_ptr& pCurrentStyle = aIterator->second; + +// fill with content +pCurrentStyle->readCssStyle(aContent); + if(aSingleName.getLength()) { -addCssStyleSheet(aSingleName, *pNewStyle); +addCssStyleSheet(aSingleName, *pCurrentStyle); } if(nInitPos == nPos)
[Libreoffice-commits] core.git: include/vcl vcl/source
include/vcl/graphicfilter.hxx |1 + vcl/source/filter/graphicfilter.cxx | 16 2 files changed, 13 insertions(+), 4 deletions(-) New commits: commit 29252e78627db79662d89919f77746824c6563c3 Author: offtkp AuthorDate: Sun Jun 19 00:42:44 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Wed Jun 22 14:12:23 2022 +0200 Add support for exporting SVGZ in Writer When exporting a graphic through Writer, graphicfilters ExportGraphic is called, which didn't have SVGZ exporting functionality before this commit. With this commit a valid Z compressed SVG file is exported, using the functionality that already exists in ExportGraphic. Change-Id: I6c7476ca78a8cb3719488ac4d8a5942e0557ed36 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136094 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index 27388da41c28..fb237bc780a4 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -101,6 +101,7 @@ namespace o3tl #define EXP_EMZ "SVEMZ" #define EXP_JPEG"SVEJPEG" #define EXP_SVG "SVESVG" +#define EXP_SVGZ"SVESVGZ" #define EXP_PDF "SVEPDF" #define EXP_PNG "SVEPNG" #define EXP_TIFF"SVTIFF" diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index bfe1d3b7d506..f7e3765f4e94 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -1844,9 +1844,17 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, std::u16string_vi if( rOStm.GetError() ) nStatus = ERRCODE_GRFILTER_IOERROR; } -else if( aFilterName.equalsIgnoreAsciiCase( EXP_SVG ) ) +else if( aFilterName.equalsIgnoreAsciiCase( EXP_SVG ) || aFilterName.equalsIgnoreAsciiCase( EXP_SVGZ ) ) { bool bDone(false); +SvStream* rTempStm = +if (aFilterName.equalsIgnoreAsciiCase(EXP_SVGZ)) +{ +// Write to a different stream so that we can compress to rOStm later +rCompressableStm.SetBufferSize(rOStm.GetBufferSize()); +rTempStm = +bShouldCompress = true; +} // do we have a native Vector Graphic Data RenderGraphic, whose data can be written directly? auto const & rVectorGraphicDataPtr(rGraphic.getVectorGraphicData()); @@ -1856,9 +1864,9 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, std::u16string_vi && !rVectorGraphicDataPtr->getBinaryDataContainer().isEmpty()) { auto & aDataContainer = rVectorGraphicDataPtr->getBinaryDataContainer(); -rOStm.WriteBytes(aDataContainer.getData(), aDataContainer.getSize()); +rTempStm->WriteBytes(aDataContainer.getData(), aDataContainer.getSize()); -if( rOStm.GetError() ) +if( rTempStm->GetError() ) { nStatus = ERRCODE_GRFILTER_IOERROR; } @@ -1890,7 +1898,7 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, std::u16string_vi if( xActiveDataSource.is() ) { const css::uno::Reference< css::uno::XInterface > xStmIf( -static_cast< ::cppu::OWeakObject* >( new ImpFilterOutputStream( rOStm ) ) ); +static_cast< ::cppu::OWeakObject* >( new ImpFilterOutputStream( *rTempStm ) ) ); SvMemoryStream aMemStm( 65535, 65535 );
[Libreoffice-commits] core.git: filter/Configuration_filter.mk filter/source
filter/Configuration_filter.mk |7 + filter/source/config/fragments/filters/SVGZ___Compressed_Scalable_Vector_Graphics.xcu | 30 +++ filter/source/config/fragments/filters/draw_svgz_Export.xcu | 30 +++ filter/source/config/fragments/internalgraphicfilters/svgz_Export.xcu | 27 ++ filter/source/config/fragments/internalgraphicfilters/svgz_Import.xcu | 27 ++ filter/source/config/fragments/types/svg_Scalable_Vector_Graphics.xcu |2 filter/source/config/fragments/types/svgz_Compressed_Scalable_Vector_Graphics.xcu | 29 +++ filter/source/svg/svgexport.cxx | 40 +- filter/source/svg/svgfilter.cxx |5 + filter/source/svg/svgfilter.hxx |1 10 files changed, 196 insertions(+), 2 deletions(-) New commits: commit 9a5d46070e70e8cf42bea0dad37063d9ed71e375 Author: offtkp AuthorDate: Thu Jun 9 16:22:32 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Wed Jun 22 14:11:14 2022 +0200 tdf#100522 Add support for exporting SVGZ in Draw Detect draw_svgz_Export and compress the SVG before exporting if needed Change-Id: I7c8463292ee845a3ce2f2a3c5aa876b25dcedb2e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135556 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk index 5c451319e95f..939234b1dc15 100644 --- a/filter/Configuration_filter.mk +++ b/filter/Configuration_filter.mk @@ -714,6 +714,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_drawgraphics_typ ras_Sun_Rasterfile \ svg_Scalable_Vector_Graphics_Draw \ svg_Scalable_Vector_Graphics \ + svgz_Compressed_Scalable_Vector_Graphics \ svm_StarView_Metafile \ tga_Truevision_TARGA \ tif_Tag_Image_File \ @@ -744,6 +745,7 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_drawgraphics_f RAS___Sun_Rasterfile \ SVG___Scalable_Vector_Graphics_Draw \ SVG___Scalable_Vector_Graphics \ + SVGZ___Compressed_Scalable_Vector_Graphics \ SVM___StarView_Metafile \ TGA___Truevision_TARGA \ TIF___Tag_Image_File \ @@ -764,6 +766,7 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_drawgraphics_f draw_jpg_Export \ draw_png_Export \ draw_svg_Export \ + draw_svgz_Export \ draw_tif_Export \ draw_webp_Export \ draw_wmf_Export \ @@ -789,6 +792,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_impressgraphics_ ras_Sun_Rasterfile \ svg_Scalable_Vector_Graphics_Draw \ svg_Scalable_Vector_Graphics \ + svgz_Compressed_Scalable_Vector_Graphics \ svm_StarView_Metafile \ tif_Tag_Image_File \ wmf_MS_Windows_Metafile \ @@ -862,6 +866,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_internalgraphics psd_Adobe_Photoshop \ ras_Sun_Rasterfile \ svg_Scalable_Vector_Graphics \ + svgz_Compressed_Scalable_Vector_Graphics \ svm_StarView_Metafile \ tga_Truevision_TARGA \ tif_Tag_Image_File \ @@ -903,6 +908,8 @@ $(eval $(call filter_Configuration_add_internal_filters,fcfg_langpack,fcfg_inter ras_Import \ svg_Export \ svg_Import \ + svgz_Export \ + svgz_Import \ svm_Export \ svm_Import \ tga_Import \ diff --git a/filter/source/config/fragments/filters/SVGZ___Compressed_Scalable_Vector_Graphics.xcu b/filter/source/config/fragments/filters/SVGZ___Compressed_Scalable_Vector_Graphics.xcu new file mode 100644 index ..35753a1f1a8b --- /dev/null +++ b/filter/source/config/fragments/filters/SVGZ___Compressed_Scalable_Vector_Graphics.xcu @@ -0,0 +1,30 @@ + + +IMPORT ALIEN 3RDPARTYFILTER PREFERRED + +com.sun.star.comp.Draw.SVGFilter + + +SVGZ - Compressed Scalable Vector Graphics + +0 +svgz_Compressed_Scalable_Vector_Graphics + +com.sun.star.presentation.PresentationDocument + diff --git a/filter/source/config/fragments/filters/draw_svgz_Export.xcu b/filter/source/config/fragments/filters/draw_svgz_Export.xcu new file mode 100644 index ..59af9fa1d5d4 --- /dev/null +++ b/filter/source/config/fragments/filters/draw_svgz_Export.xcu @@ -0,0 +1,30 @@ + + +EXPORT ALIEN 3RDPARTYFILTER + +com.sun.star.comp.Draw.SVGFilter + + +SVGZ - Compressed Scalable Vector Graphics + +0 +svgz_Compressed_Scalable_Vector_Graphics + +
[Libreoffice-commits] core.git: filter/Configuration_filter.mk filter/source include/vcl vcl/source
filter/Configuration_filter.mk | 14 ++ filter/source/config/fragments/filters/EMZ___Compressed_MS_Windows_Metafile.xcu | 30 filter/source/config/fragments/filters/WMZ___Compressed_MS_Windows_Metafile.xcu | 30 filter/source/config/fragments/filters/draw_emz_Export.xcu | 30 filter/source/config/fragments/filters/draw_wmz_Export.xcu | 30 filter/source/config/fragments/internalgraphicfilters/emz_Export.xcu | 27 +++ filter/source/config/fragments/internalgraphicfilters/emz_Import.xcu | 27 +++ filter/source/config/fragments/internalgraphicfilters/wmz_Export.xcu | 27 +++ filter/source/config/fragments/internalgraphicfilters/wmz_Import.xcu | 27 +++ filter/source/config/fragments/types/emf_MS_Windows_Metafile.xcu |2 filter/source/config/fragments/types/emz_Compressed_MS_Windows_Metafile.xcu | 29 filter/source/config/fragments/types/wmf_MS_Windows_Metafile.xcu |2 filter/source/config/fragments/types/wmz_Compressed_MS_Windows_Metafile.xcu | 29 include/vcl/graphicfilter.hxx |4 vcl/source/filter/graphicfilter.cxx | 68 +++--- 15 files changed, 356 insertions(+), 20 deletions(-) New commits: commit 376be26f4ebc5876ef93e7470ccbf85d21bf77cc Author: offtkp AuthorDate: Tue May 31 12:32:44 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Wed Jun 15 15:29:01 2022 +0200 Add support for exporting EMZ/WMZ Split xcu files for Z compressable graphic formats. This introduces a new option for exporting each Z compressed graphic format without needing to check for extension. Change type detection accordingly in graphicfilter. Change-Id: Iabb971123f5e394196716900796632cb8ed12ece Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135181 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk index a58b8396c551..5c451319e95f 100644 --- a/filter/Configuration_filter.mk +++ b/filter/Configuration_filter.mk @@ -694,6 +694,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_drawgraphics_typ bmp_MS_Windows \ dxf_AutoCAD_Interchange \ emf_MS_Windows_Metafile \ + emz_Compressed_MS_Windows_Metafile \ eps_Encapsulated_PostScript \ gif_Graphics_Interchange \ graphic_HTML \ @@ -718,6 +719,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_drawgraphics_typ tif_Tag_Image_File \ webp_WebP \ wmf_MS_Windows_Metafile \ + wmz_Compressed_MS_Windows_Metafile \ xbm_X_Consortium \ xpm_XPM \ )) @@ -726,6 +728,7 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_drawgraphics_f BMP___MS_Windows \ DXF___AutoCAD_Interchange \ EMF___MS_Windows_Metafile \ + EMZ___Compressed_MS_Windows_Metafile \ EPS___Encapsulated_PostScript \ GIF___Graphics_Interchange \ JPG___JPEG \ @@ -746,6 +749,7 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_drawgraphics_f TIF___Tag_Image_File \ WEBP___WebP \ WMF___MS_Windows_Metafile \ + WMZ___Compressed_MS_Windows_Metafile \ XBM___X_Consortium \ XPM \ draw_PCD_Photo_CD_Base \ @@ -753,6 +757,7 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_drawgraphics_f draw_PCD_Photo_CD_Base4 \ draw_bmp_Export \ draw_emf_Export \ + draw_emz_Export \ draw_eps_Export \ draw_gif_Export \ draw_html_Export \ @@ -762,12 +767,14 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_drawgraphics_f draw_tif_Export \ draw_webp_Export \ draw_wmf_Export \ + draw_wmz_Export \ )) # fcfg_impressgraphics $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_impressgraphics_types.xcu,filter/source/config/fragments/types,\ bmp_MS_Windows \ emf_MS_Windows_Metafile \ + emz_Compressed_MS_Windows_Metafile \ eps_Encapsulated_PostScript \ gif_Graphics_Interchange \ graphic_HTML \ @@ -785,6 +792,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_impressgraphics_ svm_StarView_Metafile \ tif_Tag_Image_File \ wmf_MS_Windows_Metafile \ + wmz_Compressed_MS_Windows_Metafile \ webp_WebP \ xpm_XPM \ )) @@ -836,6 +844,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_internalgraphics bmp_MS_Windows \ dxf_AutoCAD_Interchange \ emf_MS_Windows_Metafile \ + emz_Compressed_MS_Windows_Metafile \
[Libreoffice-commits] core.git: tools/CppunitTest_tools_test.mk tools/qa
tools/CppunitTest_tools_test.mk |1 tools/qa/cppunit/test_zcodec.cxx | 123 +++ 2 files changed, 124 insertions(+) New commits: commit de22386cec6e2613e034a56ffe4bd505b4534dd3 Author: offtkp AuthorDate: Wed Jun 1 13:38:19 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Wed Jun 15 10:21:36 2022 +0200 Add unit tests for ZCodec Add unit tests that check compressing->decompressing a file should result in the same file. This is done by comparing the CRC32 before and after. The same tests also implicitly test that compression/decompression works by checking the return value of ZCodec::EndCompression. Cases added for both mbGzLib=true/false. Change-Id: I5516760eba5f233c20331cef83fd0b1a1603373f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135233 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/tools/CppunitTest_tools_test.mk b/tools/CppunitTest_tools_test.mk index c36af07547c2..cfc2a0b875fc 100644 --- a/tools/CppunitTest_tools_test.mk +++ b/tools/CppunitTest_tools_test.mk @@ -39,6 +39,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,tools_test, \ tools/qa/cppunit/test_cpu_runtime_detection_SSE2 \ tools/qa/cppunit/test_cpu_runtime_detection_SSSE3 \ tools/qa/cppunit/test_Wildcard \ +tools/qa/cppunit/test_zcodec \ )) $(eval $(call gb_CppunitTest_add_exception_objects,tools_test,\ diff --git a/tools/qa/cppunit/test_zcodec.cxx b/tools/qa/cppunit/test_zcodec.cxx new file mode 100644 index ..69c4aeb2429c --- /dev/null +++ b/tools/qa/cppunit/test_zcodec.cxx @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +// Sample text for compression +constexpr const char* DUMMY_TEXT += "Lorem ipsum dolor sit amet, consectetur adipiscing elit,\n" + "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n" + "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea " + "commodo consequat.\n"; +constexpr auto DUMMY_SIZE = std::char_traits::length(DUMMY_TEXT); + +class ZCodecTest : public CppUnit::TestFixture +{ +private: +void testGzCompressDecompress(); +void testMakeDummyFile(); +void testZlibCompressDecompress(); + +CPPUNIT_TEST_SUITE(ZCodecTest); +CPPUNIT_TEST(testMakeDummyFile); +CPPUNIT_TEST(testGzCompressDecompress); +CPPUNIT_TEST(testZlibCompressDecompress); +CPPUNIT_TEST_SUITE_END(); +}; + +// Creates a stream from DUMMY_TEXT to compress and decompress +std::unique_ptr makeDummyFile() +{ +SvMemoryStream* pRet = new SvMemoryStream(); +pRet->WriteBytes(DUMMY_TEXT, DUMMY_SIZE); +return std::unique_ptr(pRet); +} + +// Test that the stream generated from makeDummyFile is valid +void ZCodecTest::testMakeDummyFile() +{ +auto pStream = makeDummyFile(); +// Check for null +CPPUNIT_ASSERT_MESSAGE("pStream is null", pStream); +decltype(DUMMY_SIZE) size = pStream->GetSize(); +// Check size +CPPUNIT_ASSERT_EQUAL(DUMMY_SIZE, size); +} + +// Test that ZCodec::Compress and ZCodec::Decompress work for gzlib = true +// Compares the CRC32 checksum of the initial stream and the compressed->decompressed stream +void ZCodecTest::testGzCompressDecompress() +{ +auto pInitialStream = makeDummyFile(); +SvMemoryStream pCompressedStream; +SvMemoryStream pDecompressedStream; +auto nInitialStreamCRC32 = rtl_crc32(0, pInitialStream->GetData(), pInitialStream->GetSize()); +ZCodec aCodec; +aCodec.BeginCompression(ZCODEC_DEFAULT_COMPRESSION, true); +// Set compression metadata for compressing a GZ file +aCodec.SetCompressionMetadata("dummy.txt", 0, nInitialStreamCRC32); +aCodec.Compress(*pInitialStream, pCompressedStream); +auto nCompressedSize += aCodec.EndCompression(); // returns compressed size or -1 if compression failed +// Check that the compression succeeded +CPPUNIT_ASSERT_GREATER(static_cast(0), nCompressedSize); +// No need to Seek(0) here because ZCodec::InitDecompress does that already for gz +aCodec.BeginCompression(ZCODEC_DEFAULT_COMPRESSION, true); +aCodec.Decompress(pCompressedStream, pDecompressedStream); +auto nDecompressedSize += aCodec.EndCompression(); // returns decompressed size or -1 if decompression failed +// Check that the decompressed text size is equal to the original +CPPUNIT_ASSERT_EQUAL(static_cast(DUMMY_SIZE), nDecompressedSize); +auto nCompressedDecompressedStreamCRC32 += rtl_crc32(0,
[Libreoffice-commits] core.git: include/tools tools/source
include/tools/zcodec.hxx | 14 +++ tools/source/zcodec/zcodec.cxx | 52 +++-- 2 files changed, 59 insertions(+), 7 deletions(-) New commits: commit 932257c50c1dc9302b14862424e24e975f88bcc2 Author: offtkp AuthorDate: Wed Jun 1 02:13:13 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Sun Jun 12 09:29:53 2022 +0200 Add compression support for GZ through ZCodec ZCodec uses zlib to deflate. That file has code to allow for compressing to GZ but it's wrapped in defines. There's places in code where there's need for zlib headers (ie. svx/source/gallery2/codec.cxx:71) and there will be need for gz header compression when EMZ/WMZ/SVGZ export support is added. Made compression functions care about mbGzLib bool. Also added a SetCompressionMetadata function to set metadata which are otherwise impossible to know (such as filename, which is needed in the header) Change-Id: Ic01050262b0b15e0632564b139c66656afac4611 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135213 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/tools/zcodec.hxx b/include/tools/zcodec.hxx index 745d44e9199e..a86dbec70b62 100644 --- a/include/tools/zcodec.hxx +++ b/include/tools/zcodec.hxx @@ -23,6 +23,7 @@ #include #include #include +#include #define ZCODEC_NO_COMPRESSION 0 #define ZCODEC_DEFAULT_COMPRESSION 6 @@ -31,6 +32,7 @@ class SvStream; // The overall client call protocol is one of: // * BeginCompression, Compress, EndCompression +// * BeginCompression, SetCompressionMetadata, Compress, EndCompression (for gz files) // * BeginCompression, Decompress, EndCompression // * BeginCompression, Write*, EndCompression // * BeginCompression, Read*, EndCompression @@ -47,6 +49,10 @@ class SAL_WARN_UNUSED TOOLS_DLLPUBLIC ZCodec SvStream* mpOStm; std::unique_ptr mpOutBuf; size_t mnOutBufSize; +sal_uInt32 mnUncompressedSize; +sal_uInt32 mnInBufCRC32; +sal_uInt32 mnLastModifiedTime; +OString msFilename; int mnCompressLevel; boolmbGzLib; @@ -69,6 +75,14 @@ public: voidBeginCompression( int nCompressLevel = ZCODEC_DEFAULT_COMPRESSION, bool gzLib = false ); tools::LongEndCompression(); +/** + * @brief Set metadata for gzlib compression + * + * @param sFilename the uncompressed file filename + * @param nLastModifiedTime the files last modified time in unix format + */ +voidSetCompressionMetadata( const OString& sFilename, +sal_uInt32 nLastModifiedTime, sal_uInt32 nInBufCRC32 ); voidCompress( SvStream& rIStm, SvStream& rOStm ); tools::LongDecompress( SvStream& rIStm, SvStream& rOStm ); boolAttemptDecompression( SvStream& rIStm, SvStream& rOStm ); diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx index 80daa1507a19..16248939f3d6 100644 --- a/tools/source/zcodec/zcodec.cxx +++ b/tools/source/zcodec/zcodec.cxx @@ -29,14 +29,15 @@ #include /* gzip flag byte */ -// GZ_ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ -#define GZ_HEAD_CRC 0x02 /* bit 1 set: header CRC present */ -#define GZ_EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ -#define GZ_ORIG_NAME0x08 /* bit 3 set: original file name present */ -#define GZ_COMMENT 0x10 /* bit 4 set: file comment present */ -#define GZ_RESERVED 0xE0 /* bits 5..7: reserved */ - +// GZ_ASCII_FLAG = 0x01; /* bit 0 set: file probably ascii text */ +constexpr sal_uInt8 GZ_HEAD_CRC = 0x02; /* bit 1 set: header CRC present */ +constexpr sal_uInt8 GZ_EXTRA_FIELD= 0x04; /* bit 2 set: extra field present */ +constexpr sal_uInt8 GZ_ORIG_NAME = 0x08; /* bit 3 set: original file name present */ +constexpr sal_uInt8 GZ_COMMENT= 0x10; /* bit 4 set: file comment present */ +constexpr sal_uInt8 GZ_RESERVED = 0xE0; /* bits 5..7: reserved */ constexpr sal_uInt16 GZ_MAGIC_BYTES_LE = 0x8B1F; /* gzip magic bytes, little endian */ +constexpr sal_uInt8 GZ_DEFLATE= 0x08; +constexpr sal_uInt8 GZ_FS_UNKNOWN = 0xFF; ZCodec::ZCodec( size_t nInBufSize, size_t nOutBufSize ) : meState(STATE_INIT) @@ -109,6 +110,25 @@ tools::Long ZCodec::EndCompression() retvalue = pStream->total_in; deflateEnd( pStream ); +if ( mbGzLib ) +{ +// metadata must be set to compress as gz format +assert(!msFilename.isEmpty()); +// overwrite zlib checksum +mpOStm->Seek(STREAM_SEEK_TO_END); +mpOStm->SeekRel(-4); +mpOStm->WriteUInt32( mnInBufCRC32 ); // Uncompressed buffer CRC32 +mpOStm->WriteUInt32(
[Libreoffice-commits] core.git: vcl/qa
vcl/qa/cppunit/GraphicDescriptorTest.cxx | 15 +++ 1 file changed, 15 insertions(+) New commits: commit 5f30b778bccbcc417e4ed1da5997650babb942a8 Author: offtkp AuthorDate: Tue May 24 00:03:04 2022 +0300 Commit: Bartosz Kosiorek CommitDate: Tue May 24 08:20:45 2022 +0200 tdf#149206: Add EMF test in GraphicDescriptorTest Add a testDetectEMF test case in GraphicDescriptorTest.cxx that tests GraphicDescriptor for EMF detection and that the size metadata were fetched. Change-Id: I6fbe082bea4d5f1e8660b43a923a09bfcdf466b3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134845 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/vcl/qa/cppunit/GraphicDescriptorTest.cxx b/vcl/qa/cppunit/GraphicDescriptorTest.cxx index ace1a6c90a28..c86d95edebdb 100644 --- a/vcl/qa/cppunit/GraphicDescriptorTest.cxx +++ b/vcl/qa/cppunit/GraphicDescriptorTest.cxx @@ -35,6 +35,7 @@ class GraphicDescriptorTest : public test::BootstrapFixtureBase void testDetectTIF(); void testDetectBMP(); void testDetectWEBP(); +void testDetectEMF(); CPPUNIT_TEST_SUITE(GraphicDescriptorTest); CPPUNIT_TEST(testDetectPNG); @@ -43,6 +44,7 @@ class GraphicDescriptorTest : public test::BootstrapFixtureBase CPPUNIT_TEST(testDetectTIF); CPPUNIT_TEST(testDetectBMP); CPPUNIT_TEST(testDetectWEBP); +CPPUNIT_TEST(testDetectEMF); CPPUNIT_TEST_SUITE_END(); }; @@ -154,6 +156,19 @@ void GraphicDescriptorTest::testDetectWEBP() CPPUNIT_ASSERT_EQUAL(tools::Long(100), aDescriptor.GetSizePixel().Height()); } +void GraphicDescriptorTest::testDetectEMF() +{ +SvFileStream aFileStream(getFullUrl(u"TypeDetectionExample.emf"), StreamMode::READ); +GraphicDescriptor aDescriptor(aFileStream, nullptr); +aDescriptor.Detect(true); +CPPUNIT_ASSERT_EQUAL(GraphicFileFormat::EMF, aDescriptor.GetFileFormat()); +// Test that Bounds/Frame values are fetched from header +CPPUNIT_ASSERT_EQUAL(tools::Long(142), aDescriptor.GetSizePixel().Width()); +CPPUNIT_ASSERT_EQUAL(tools::Long(142), aDescriptor.GetSizePixel().Height()); +CPPUNIT_ASSERT_EQUAL(tools::Long(300), aDescriptor.GetSize_100TH_MM().Width()); +CPPUNIT_ASSERT_EQUAL(tools::Long(300), aDescriptor.GetSize_100TH_MM().Height()); +} + } // namespace CPPUNIT_TEST_SUITE_REGISTRATION(GraphicDescriptorTest);
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/graphicfilter2.cxx | 64 --- 1 file changed, 60 insertions(+), 4 deletions(-) New commits: commit 063d641f023ac90f49116de105e32e38be72a1af Author: offtkp AuthorDate: Sat May 21 11:23:01 2022 +0300 Commit: Bartosz Kosiorek CommitDate: Tue May 24 08:19:41 2022 +0200 tdf#149206 Set size correctly when loading EMF Regression fixed, rolled back ImpDetectEMF function to version before https://gerrit.libreoffice.org/c/core/+/132456, changed type detection from extension checking back to magic number checking. Also added a small uncompression at the start to keep EMZ support. Change-Id: Id4489da399a571c4c72ce137f841614f5c0d7bdc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134703 Reviewed-by: Bartosz Kosiorek Tested-by: Jenkins diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index eaef61b1d1e1..c02e9d557c44 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,9 @@ #include "graphicfilter_internal.hxx" #define DATA_SIZE 640 +constexpr sal_uInt32 EMF_CHECK_SIZE= 44; +constexpr sal_uInt32 EMR_HEADER= 0x0001; +constexpr sal_uInt32 ENHMETA_SIGNATURE = 0x464d4520; GraphicDescriptor::GraphicDescriptor( const INetURLObject& rPath ) : pFileStm( ::utl::UcbStreamHelper::CreateStream( rPath.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ).release() ), @@ -1086,12 +1090,64 @@ bool GraphicDescriptor::ImpDetectWMF( SvStream&, bool ) return bRet; } -bool GraphicDescriptor::ImpDetectEMF( SvStream&, bool ) +bool GraphicDescriptor::ImpDetectEMF(SvStream& rStm, bool bExtendedInfo) { -bool bRet = aPathExt.startsWith( "emf" ) || aPathExt.startsWith( "emz" ); -if (bRet) -nFormat = GraphicFileFormat::EMF; +SvStream* aNewStream = +SvMemoryStream aMemStream; +sal_uInt8 aUncompressedBuffer[EMF_CHECK_SIZE]; +if (ZCodec::IsZCompressed(rStm)) +{ +ZCodec aCodec; +aCodec.BeginCompression(ZCODEC_DEFAULT_COMPRESSION, /*gzLib*/ true); +auto nDecompressLength = aCodec.Read(rStm, aUncompressedBuffer, EMF_CHECK_SIZE); +aCodec.EndCompression(); +if (nDecompressLength != EMF_CHECK_SIZE) +return false; +aMemStream.SetBuffer(aUncompressedBuffer, EMF_CHECK_SIZE, EMF_CHECK_SIZE); +aNewStream = +} + +sal_uInt32 nRecordType = 0; +bool bRet = false; +sal_Int32 nStmPos = aNewStream->Tell(); +aNewStream->SetEndian(SvStreamEndian::LITTLE); +aNewStream->ReadUInt32(nRecordType); +if (nRecordType == EMR_HEADER) +{ +sal_Int32 nBoundLeft = 0, nBoundTop = 0, nBoundRight = 0, nBoundBottom = 0; +sal_Int32 nFrameLeft = 0, nFrameTop = 0, nFrameRight = 0, nFrameBottom = 0; +sal_uInt32 nSignature = 0; + +aNewStream->SeekRel(4); +aNewStream->ReadInt32(nBoundLeft); +aNewStream->ReadInt32(nBoundTop); +aNewStream->ReadInt32(nBoundRight); +aNewStream->ReadInt32(nBoundBottom); +aNewStream->ReadInt32(nFrameLeft); +aNewStream->ReadInt32(nFrameTop); +aNewStream->ReadInt32(nFrameRight); +aNewStream->ReadInt32(nFrameBottom); +aNewStream->ReadUInt32(nSignature); + +if (nSignature == ENHMETA_SIGNATURE) +{ +nFormat = GraphicFileFormat::EMF; +bRet = true; + +if (bExtendedInfo) +{ +// size in pixels +aPixSize.setWidth(nBoundRight - nBoundLeft + 1); +aPixSize.setHeight(nBoundBottom - nBoundTop + 1); + +// size in 0.01mm units +aLogSize.setWidth(nFrameRight - nFrameLeft + 1); +aLogSize.setHeight(nFrameBottom - nFrameTop + 1); +} +} +} +rStm.Seek(nStmPos); return bRet; }
[Libreoffice-commits] core.git: sal/rtl sc/source
sal/rtl/math.cxx |2 +- sc/source/core/tool/interpr1.cxx |3 ++- sc/source/core/tool/interpr3.cxx |3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) New commits: commit 6f75ec6115f0152517be634070607bc61bf96dd0 Author: offtkp AuthorDate: Sat May 7 01:20:33 2022 +0300 Commit: Bartosz Kosiorek CommitDate: Wed May 11 10:32:30 2022 +0200 tdf#148430 Use atanh from instead of our own Change wrapper in rtl::math::atanh to use atanh from . Also changed all occurrences of rtl::math::atanh on files that use this function to directly use the standard atanh instead. Change-Id: Idc5c456f67291f5816756f023b61afde844b5ceb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133965 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx index a4775585ace4..b53cbec144b3 100644 --- a/sal/rtl/math.cxx +++ b/sal/rtl/math.cxx @@ -769,7 +769,7 @@ double SAL_CALL rtl_math_atanh(double fValue) SAL_THROW_EXTERN_C() __attribute__((no_sanitize("float-divide-by-zero"))) // atahn(1) -> inf #endif { - return 0.5 * rtl_math_log1p(2.0 * fValue / (1.0-fValue)); +return ::atanh(fValue); } /** Parent error function (erf) */ diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index f6dbbffa2d3f..f71c1941b1a2 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -75,6 +75,7 @@ #include #include #include +#include const sal_uInt64 n2power48 = SAL_CONST_UINT64( 281474976710656); // 2^48 @@ -1919,7 +1920,7 @@ void ScInterpreter::ScArcTanHyp() if (fabs(fVal) >= 1.0) PushIllegalArgument(); else -PushDouble( ::rtl::math::atanh( fVal)); +PushDouble(::atanh(fVal)); } void ScInterpreter::ScArcCotHyp() diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index 25b5f44038f2..e5ae61962014 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -1152,7 +1153,7 @@ void ScInterpreter::ScFisher() if (std::abs(fVal) >= 1.0) PushIllegalArgument(); else -PushDouble( ::rtl::math::atanh( fVal)); +PushDouble(::atanh(fVal)); } void ScInterpreter::ScFisherInv()
[Libreoffice-commits] core.git: filter/source include/tools tools/source vcl/inc vcl/qa vcl/source
filter/source/config/fragments/types/emf_MS_Windows_Metafile.xcu |2 filter/source/config/fragments/types/wmf_MS_Windows_Metafile.xcu |2 include/tools/zcodec.hxx |6 tools/source/zcodec/zcodec.cxx | 23 ++- vcl/inc/graphic/GraphicFormatDetector.hxx| 13 + vcl/qa/cppunit/GraphicFormatDetectorTest.cxx | 51 +++ vcl/qa/cppunit/data/TypeDetectionExample.emf |binary vcl/qa/cppunit/data/TypeDetectionExample.emz |binary vcl/qa/cppunit/data/TypeDetectionExample.wmz |binary vcl/source/filter/GraphicFormatDetector.cxx | 68 ++ vcl/source/filter/graphicfilter.cxx | 44 +- vcl/source/filter/graphicfilter2.cxx | 50 --- 12 files changed, 170 insertions(+), 89 deletions(-) New commits: commit e9c50fbbc3b07ef927d133da9cf2395c55611e0f Author: offtkp AuthorDate: Sat Apr 2 15:49:32 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Fri May 6 04:02:05 2022 +0200 tdf#103954: Z compressed graphic formats support for EMF/WMF - Added .emz and .wmz file opening support - Added a function to check for Z compression that all z comp. formats can use - Added 3 unit tests for emf/emz/wmz files and the example files have been checked with a different tool (File Viewer 4) - emf/emz file detection changed from magic byte checking to extension checking, like wmf/wmz does Change-Id: I3e433fd23d18482648a51cd04b8f467368e97b62 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132456 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/filter/source/config/fragments/types/emf_MS_Windows_Metafile.xcu b/filter/source/config/fragments/types/emf_MS_Windows_Metafile.xcu index 6d1564bebd07..2003217aad30 100644 --- a/filter/source/config/fragments/types/emf_MS_Windows_Metafile.xcu +++ b/filter/source/config/fragments/types/emf_MS_Windows_Metafile.xcu @@ -18,7 +18,7 @@ com.sun.star.comp.draw.FormatDetector -emf +emf emz image/x-emf false EMF - MS Windows Metafile diff --git a/filter/source/config/fragments/types/wmf_MS_Windows_Metafile.xcu b/filter/source/config/fragments/types/wmf_MS_Windows_Metafile.xcu index 54c6bf54c33b..7564dd057cf4 100644 --- a/filter/source/config/fragments/types/wmf_MS_Windows_Metafile.xcu +++ b/filter/source/config/fragments/types/wmf_MS_Windows_Metafile.xcu @@ -18,7 +18,7 @@ com.sun.star.comp.draw.FormatDetector -wmf +wmf wmz image/x-wmf false WMF - MS Windows Metafile diff --git a/include/tools/zcodec.hxx b/include/tools/zcodec.hxx index c9c71bf752b1..745d44e9199e 100644 --- a/include/tools/zcodec.hxx +++ b/include/tools/zcodec.hxx @@ -59,6 +59,12 @@ class SAL_WARN_UNUSED TOOLS_DLLPUBLIC ZCodec public: ZCodec( size_t nInBufSize = 32768, size_t nOutBufSize = 32768 ); ~ZCodec(); +/** + * @brief Checks whether a stream is Z compressed + * + * @param rIStm the stream to check + */ +static bool IsZCompressed( SvStream& rIStm ); voidBeginCompression( int nCompressLevel = ZCODEC_DEFAULT_COMPRESSION, bool gzLib = false ); tools::LongEndCompression(); diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx index 97a03a463021..80daa1507a19 100644 --- a/tools/source/zcodec/zcodec.cxx +++ b/tools/source/zcodec/zcodec.cxx @@ -36,7 +36,7 @@ #define GZ_COMMENT 0x10 /* bit 4 set: file comment present */ #define GZ_RESERVED 0xE0 /* bits 5..7: reserved */ -const int gz_magic[2] = { 0x1f, 0x8b }; /* gzip magic header */ +constexpr sal_uInt16 GZ_MAGIC_BYTES_LE = 0x8B1F; /* gzip magic bytes, little endian */ ZCodec::ZCodec( size_t nInBufSize, size_t nOutBufSize ) : meState(STATE_INIT) @@ -58,6 +58,16 @@ ZCodec::~ZCodec() delete pStream; } +bool ZCodec::IsZCompressed( SvStream& rIStm ) +{ +sal_uInt64 nCurPos = rIStm.Tell(); +rIStm.Seek( 0 ); +sal_uInt16 nFirstTwoBytes = 0; +rIStm.ReadUInt16( nFirstTwoBytes ); +rIStm.Seek( nCurPos ); +return nFirstTwoBytes == GZ_MAGIC_BYTES_LE; +} + void ZCodec::BeginCompression( int nCompressLevel, bool gzLib ) { assert(meState == STATE_INIT); @@ -272,12 +282,11 @@ void ZCodec::InitDecompress(SvStream & inStream) if ( mbStatus && mbGzLib ) { sal_uInt8 j, nMethod, nFlags; -for (int i : gz_magic) // gz - magic number -{ -inStream.ReadUChar( j ); -if ( j != i ) -mbStatus = false; -} +sal_uInt16 nFirstTwoBytes; +inStream.Seek( 0 ); +inStream.ReadUInt16( nFirstTwoBytes ); +if ( nFirstTwoBytes !=