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 <[email protected]> AuthorDate: Tue May 31 12:32:44 2022 +0300 Commit: Tomaž Vajngerl <[email protected]> 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 <[email protected]> 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 \ eps_Encapsulated_PostScript \ gif_Graphics_Interchange \ jpg_JPEG \ @@ -858,6 +867,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_internalgraphics tif_Tag_Image_File \ webp_WebP \ wmf_MS_Windows_Metafile \ + wmz_Compressed_MS_Windows_Metafile \ xbm_X_Consortium \ xpm_XPM \ )) @@ -867,7 +877,9 @@ $(eval $(call filter_Configuration_add_internal_filters,fcfg_langpack,fcfg_inter bmp_Import \ dxf_Import \ emf_Export \ + emz_Export \ emf_Import \ + emz_Import \ eps_Export \ eps_Import \ gif_Export \ @@ -899,7 +911,9 @@ $(eval $(call filter_Configuration_add_internal_filters,fcfg_langpack,fcfg_inter webp_Export \ webp_Import \ wmf_Export \ + wmz_Export \ wmf_Import \ + wmz_Import \ xbm_Import \ xpm_Import \ mov_Import \ diff --git a/filter/source/config/fragments/filters/EMZ___Compressed_MS_Windows_Metafile.xcu b/filter/source/config/fragments/filters/EMZ___Compressed_MS_Windows_Metafile.xcu new file mode 100644 index 000000000000..4d76ea375bad --- /dev/null +++ b/filter/source/config/fragments/filters/EMZ___Compressed_MS_Windows_Metafile.xcu @@ -0,0 +1,30 @@ +<!-- + * 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 . +--> + <node oor:name="EMZ - Compressed MS Windows Metafile" oor:op="replace"> + <prop oor:name="Flags"><value>IMPORT ALIEN</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="FilterService"/> + <prop oor:name="UserData"><value></value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">EMZ - Compressed Enhanced Metafile</value> + </prop> + <prop oor:name="FileFormatVersion"><value>0</value></prop> + <prop oor:name="Type"><value>emz_Compressed_MS_Windows_Metafile</value></prop> + <prop oor:name="TemplateName"/> + <prop oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop> + </node> diff --git a/filter/source/config/fragments/filters/WMZ___Compressed_MS_Windows_Metafile.xcu b/filter/source/config/fragments/filters/WMZ___Compressed_MS_Windows_Metafile.xcu new file mode 100644 index 000000000000..875dfb8ac295 --- /dev/null +++ b/filter/source/config/fragments/filters/WMZ___Compressed_MS_Windows_Metafile.xcu @@ -0,0 +1,30 @@ +<!-- + * 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 . +--> + <node oor:name="WMZ - Compressed MS Windows Metafile" oor:op="replace"> + <prop oor:name="Flags"><value>IMPORT ALIEN</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="FilterService"/> + <prop oor:name="UserData"><value></value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">WMZ - Compressed Windows Metafile</value> + </prop> + <prop oor:name="FileFormatVersion"><value>0</value></prop> + <prop oor:name="Type"><value>wmz_Compressed_MS_Windows_Metafile</value></prop> + <prop oor:name="TemplateName"/> + <prop oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop> + </node> diff --git a/filter/source/config/fragments/filters/draw_emz_Export.xcu b/filter/source/config/fragments/filters/draw_emz_Export.xcu new file mode 100644 index 000000000000..5c1aae3a761c --- /dev/null +++ b/filter/source/config/fragments/filters/draw_emz_Export.xcu @@ -0,0 +1,30 @@ +<!-- + * 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 . +--> + <node oor:name="draw_emz_Export" oor:op="replace"> + <prop oor:name="Flags"><value>EXPORT ALIEN SUPPORTSSELECTION</value></prop> + <prop oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop> + <prop oor:name="FilterService"/> + <prop oor:name="UserData"><value></value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">EMZ - Compressed Enhanced Metafile</value> + </prop> + <prop oor:name="FileFormatVersion"><value>0</value></prop> + <prop oor:name="Type"><value>emz_Compressed_MS_Windows_Metafile</value></prop> + <prop oor:name="TemplateName"/> + <prop oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop> + </node> diff --git a/filter/source/config/fragments/filters/draw_wmz_Export.xcu b/filter/source/config/fragments/filters/draw_wmz_Export.xcu new file mode 100644 index 000000000000..272880aa4b0a --- /dev/null +++ b/filter/source/config/fragments/filters/draw_wmz_Export.xcu @@ -0,0 +1,30 @@ +<!-- + * 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 . +--> + <node oor:name="draw_wmz_Export" oor:op="replace"> + <prop oor:name="Flags"><value>EXPORT ALIEN SUPPORTSSELECTION</value></prop> + <prop oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop> + <prop oor:name="FilterService"/> + <prop oor:name="UserData"><value></value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">WMZ - Compressed Windows Metafile</value> + </prop> + <prop oor:name="FileFormatVersion"><value>0</value></prop> + <prop oor:name="Type"><value>wmz_Compressed_MS_Windows_Metafile</value></prop> + <prop oor:name="TemplateName"/> + <prop oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop> + </node> diff --git a/filter/source/config/fragments/internalgraphicfilters/emz_Export.xcu b/filter/source/config/fragments/internalgraphicfilters/emz_Export.xcu new file mode 100644 index 000000000000..40ccb11105b3 --- /dev/null +++ b/filter/source/config/fragments/internalgraphicfilters/emz_Export.xcu @@ -0,0 +1,27 @@ +<!-- + * 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 . +--> + <node oor:name="emz_Export" oor:op="replace" > + <prop oor:name="Type"><value>emz_Compressed_MS_Windows_Metafile</value></prop> + <prop oor:name="FormatName"><value>SVEMZ</value></prop> + <prop oor:name="RealFilterName"/> + <prop oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">EMZ - Compressed Enhanced Metafile</value> + </prop> + <prop oor:name="Flags"><value>EXPORT</value></prop> + </node> diff --git a/filter/source/config/fragments/internalgraphicfilters/emz_Import.xcu b/filter/source/config/fragments/internalgraphicfilters/emz_Import.xcu new file mode 100644 index 000000000000..590ef29d567b --- /dev/null +++ b/filter/source/config/fragments/internalgraphicfilters/emz_Import.xcu @@ -0,0 +1,27 @@ +<!-- + * 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 . +--> + <node oor:name="emz_Import" oor:op="replace" > + <prop oor:name="Type"><value>emz_Compressed_MS_Windows_Metafile</value></prop> + <prop oor:name="FormatName"><value>SVEMZ</value></prop> + <prop oor:name="RealFilterName"><value>EMZ - Compressed MS Windows Metafile</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="UIName"> + <value xml:lang="en-US">EMZ - Compressed Enhanced Metafile</value> + </prop> + <prop oor:name="Flags"><value>IMPORT</value></prop> + </node> diff --git a/filter/source/config/fragments/internalgraphicfilters/wmz_Export.xcu b/filter/source/config/fragments/internalgraphicfilters/wmz_Export.xcu new file mode 100644 index 000000000000..69b9aec9e0e2 --- /dev/null +++ b/filter/source/config/fragments/internalgraphicfilters/wmz_Export.xcu @@ -0,0 +1,27 @@ +<!-- + * 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 . +--> + <node oor:name="wmz_Export" oor:op="replace" > + <prop oor:name="Type"><value>wmz_Compressed_MS_Windows_Metafile</value></prop> + <prop oor:name="FormatName"><value>SVWMZ</value></prop> + <prop oor:name="RealFilterName"/> + <prop oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">WMZ - Compressed Windows Metafile</value> + </prop> + <prop oor:name="Flags"><value>EXPORT</value></prop> + </node> diff --git a/filter/source/config/fragments/internalgraphicfilters/wmz_Import.xcu b/filter/source/config/fragments/internalgraphicfilters/wmz_Import.xcu new file mode 100644 index 000000000000..9f124f1a1817 --- /dev/null +++ b/filter/source/config/fragments/internalgraphicfilters/wmz_Import.xcu @@ -0,0 +1,27 @@ +<!-- + * 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 . +--> + <node oor:name="wmz_Import" oor:op="replace" > + <prop oor:name="Type"><value>wmz_Compressed_MS_Windows_Metafile</value></prop> + <prop oor:name="FormatName"><value>SVWMZ</value></prop> + <prop oor:name="RealFilterName"><value>WMZ - Compressed MS Windows Metafile</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="UIName"> + <value xml:lang="en-US">WMZ - Compressed Windows Metafile</value> + </prop> + <prop oor:name="Flags"><value>IMPORT</value></prop> + </node> 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 2003217aad30..6d1564bebd07 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 @@ <node oor:name="emf_MS_Windows_Metafile" oor:op="replace" > <prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop> <prop oor:name="URLPattern"/> - <prop oor:name="Extensions"><value>emf emz</value></prop> + <prop oor:name="Extensions"><value>emf</value></prop> <prop oor:name="MediaType"><value>image/x-emf</value></prop> <prop oor:name="Preferred"><value>false</value></prop> <prop oor:name="PreferredFilter"><value>EMF - MS Windows Metafile</value></prop> diff --git a/filter/source/config/fragments/types/emz_Compressed_MS_Windows_Metafile.xcu b/filter/source/config/fragments/types/emz_Compressed_MS_Windows_Metafile.xcu new file mode 100644 index 000000000000..b2dfeb3f9532 --- /dev/null +++ b/filter/source/config/fragments/types/emz_Compressed_MS_Windows_Metafile.xcu @@ -0,0 +1,29 @@ +<!-- + * 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 . +--> + <node oor:name="emz_Compressed_MS_Windows_Metafile" oor:op="replace" > + <prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop> + <prop oor:name="URLPattern"/> + <prop oor:name="Extensions"><value>emz</value></prop> + <prop oor:name="MediaType"><value>image/x-emf</value></prop> + <prop oor:name="Preferred"><value>false</value></prop> + <prop oor:name="PreferredFilter"><value>EMZ - Compressed MS Windows Metafile</value></prop> + <prop oor:name="UIName"> + <value>EMZ - Compressed Enhanced Meta File</value> + </prop> + <prop oor:name="ClipboardFormat"/> + </node> 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 7564dd057cf4..54c6bf54c33b 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 @@ <node oor:name="wmf_MS_Windows_Metafile" oor:op="replace" > <prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop> <prop oor:name="URLPattern"/> - <prop oor:name="Extensions"><value>wmf wmz</value></prop> + <prop oor:name="Extensions"><value>wmf</value></prop> <prop oor:name="MediaType"><value>image/x-wmf</value></prop> <prop oor:name="Preferred"><value>false</value></prop> <prop oor:name="PreferredFilter"><value>WMF - MS Windows Metafile</value></prop> diff --git a/filter/source/config/fragments/types/wmz_Compressed_MS_Windows_Metafile.xcu b/filter/source/config/fragments/types/wmz_Compressed_MS_Windows_Metafile.xcu new file mode 100644 index 000000000000..859c9d6d27bd --- /dev/null +++ b/filter/source/config/fragments/types/wmz_Compressed_MS_Windows_Metafile.xcu @@ -0,0 +1,29 @@ +<!-- + * 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 . +--> + <node oor:name="wmz_Compressed_MS_Windows_Metafile" oor:op="replace" > + <prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop> + <prop oor:name="URLPattern"/> + <prop oor:name="Extensions"><value>wmz</value></prop> + <prop oor:name="MediaType"><value>image/x-wmf</value></prop> + <prop oor:name="Preferred"><value>false</value></prop> + <prop oor:name="PreferredFilter"><value>WMZ - Compressed MS Windows Metafile</value></prop> + <prop oor:name="UIName"> + <value>WMZ - Compressed Windows Metafile</value> + </prop> + <prop oor:name="ClipboardFormat"/> + </node> diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index 0e0351dc4d50..27388da41c28 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -70,7 +70,9 @@ namespace o3tl #define IMP_MOV "SVMOV" #define IMP_SVMETAFILE "SVMETAFILE" #define IMP_WMF "SVWMF" +#define IMP_WMZ "SVWMZ" #define IMP_EMF "SVEMF" +#define IMP_EMZ "SVEMZ" #define IMP_GIF "SVIGIF" #define IMP_PNG "SVIPNG" #define IMP_JPEG "SVIJPEG" @@ -94,7 +96,9 @@ namespace o3tl #define EXP_BMP "SVBMP" #define EXP_SVMETAFILE "SVMETAFILE" #define EXP_WMF "SVWMF" +#define EXP_WMZ "SVWMZ" #define EXP_EMF "SVEMF" +#define EXP_EMZ "SVEMZ" #define EXP_JPEG "SVEJPEG" #define EXP_SVG "SVESVG" #define EXP_PDF "SVEPDF" diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index d208c7d81e72..bfe1d3b7d506 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -29,6 +29,7 @@ #include <tools/stream.hxx> #include <tools/urlobj.hxx> #include <tools/zcodec.hxx> +#include <rtl/crc.h> #include <fltcall.hxx> #include <vcl/salctype.hxx> #include <vcl/filter/PngImageReader.hxx> @@ -875,7 +876,9 @@ Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& rIStream, sal_uInt64 size eLinkType = GfxLinkType::NativeMov; } else if (aFilterName.equalsIgnoreAsciiCase(IMP_WMF) || - aFilterName.equalsIgnoreAsciiCase(IMP_EMF)) + aFilterName.equalsIgnoreAsciiCase(IMP_EMF) || + aFilterName.equalsIgnoreAsciiCase(IMP_WMZ) || + aFilterName.equalsIgnoreAsciiCase(IMP_EMZ)) { nGraphicContentSize = nStreamLength; pGraphicContent.reset(new sal_uInt8[nGraphicContentSize]); @@ -1449,11 +1452,11 @@ ErrCode GraphicFilter::ImportGraphic(Graphic& rGraphic, std::u16string_view rPat { nStatus = readWithTypeSerializer(rIStream, rGraphic, eLinkType, aFilterName); } - else if (aFilterName.equalsIgnoreAsciiCase(IMP_WMF)) + else if (aFilterName.equalsIgnoreAsciiCase(IMP_WMF) || aFilterName.equalsIgnoreAsciiCase(IMP_WMZ)) { nStatus = readWMF(rIStream, rGraphic, eLinkType); } - else if (aFilterName.equalsIgnoreAsciiCase(IMP_EMF)) + else if (aFilterName.equalsIgnoreAsciiCase(IMP_EMF) || aFilterName.equalsIgnoreAsciiCase(IMP_EMZ)) { nStatus = readEMF(rIStream, rGraphic, eLinkType); } @@ -1584,12 +1587,12 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, std::u16string_vi sal_uInt16 nFormatCount = GetExportFormatCount(); ResetLastError(); + bool bShouldCompress = false; + SvMemoryStream rCompressableStm; if( nFormat == GRFILTER_FORMAT_DONTKNOW ) { - INetURLObject aURL( rPath ); - OUString aExt( aURL.GetFileExtension().toAsciiUpperCase() ); - + OUString aExt = ImpGetExtension( rPath ); for( sal_uInt16 i = 0; i < nFormatCount; i++ ) { if ( pConfig->GetExportFormatExtension( i ).equalsIgnoreAsciiCase( aExt ) ) @@ -1685,10 +1688,17 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, std::u16string_vi if( rOStm.GetError() ) nStatus = ERRCODE_GRFILTER_IOERROR; } - else if ( aFilterName.equalsIgnoreAsciiCase( EXP_WMF ) ) + else if ( aFilterName.equalsIgnoreAsciiCase( EXP_WMF ) || aFilterName.equalsIgnoreAsciiCase( EXP_WMZ ) ) { bool bDone(false); - + SvStream* rTempStm = &rOStm; + if (aFilterName.equalsIgnoreAsciiCase(EXP_WMZ)) + { + // Write to a different stream so that we can compress to rOStm later + rCompressableStm.SetBufferSize( rOStm.GetBufferSize() ); + rTempStm = &rCompressableStm; + bShouldCompress = true; + } // do we have a native Vector Graphic Data RenderGraphic, whose data can be written directly? auto const & rVectorGraphicDataPtr(rGraphic.getVectorGraphicData()); @@ -1702,9 +1712,9 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, std::u16string_vi && !bIsEMF) { 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; } @@ -1717,17 +1727,24 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, std::u16string_vi if (!bDone) { // #i119735# just use GetGDIMetaFile, it will create a buffered version of contained bitmap now automatically - if (!ConvertGraphicToWMF(aGraphic, rOStm, &aConfigItem)) + if (!ConvertGraphicToWMF(aGraphic, *rTempStm, &aConfigItem)) nStatus = ERRCODE_GRFILTER_FORMATERROR; - if (rOStm.GetError()) + if (rTempStm->GetError()) nStatus = ERRCODE_GRFILTER_IOERROR; } } - else if ( aFilterName.equalsIgnoreAsciiCase( EXP_EMF ) ) + else if ( aFilterName.equalsIgnoreAsciiCase( EXP_EMF ) || aFilterName.equalsIgnoreAsciiCase( EXP_EMZ ) ) { bool bDone(false); - + SvStream* rTempStm = &rOStm; + if (aFilterName.equalsIgnoreAsciiCase(EXP_EMZ)) + { + // Write to a different stream so that we can compress to rOStm later + rCompressableStm.SetBufferSize( rOStm.GetBufferSize() ); + rTempStm = &rCompressableStm; + bShouldCompress = true; + } // do we have a native Vector Graphic Data RenderGraphic, whose data can be written directly? auto const & rVectorGraphicDataPtr(rGraphic.getVectorGraphicData()); @@ -1736,9 +1753,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; } @@ -1751,10 +1768,10 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, std::u16string_vi if (!bDone) { // #i119735# just use GetGDIMetaFile, it will create a buffered version of contained bitmap now automatically - if (!ConvertGDIMetaFileToEMF(aGraphic.GetGDIMetaFile(), rOStm)) + if (!ConvertGDIMetaFileToEMF(aGraphic.GetGDIMetaFile(), *rTempStm)) nStatus = ERRCODE_GRFILTER_FORMATERROR; - if (rOStm.GetError()) + if (rTempStm->GetError()) nStatus = ERRCODE_GRFILTER_IOERROR; } } @@ -1909,6 +1926,21 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, std::u16string_vi { ImplSetError( nStatus, &rOStm ); } + else if ( bShouldCompress ) + { + sal_uInt32 nUncompressedCRC32 + = rtl_crc32( 0, rCompressableStm.GetData(), rCompressableStm.GetSize() ); + ZCodec aCodec; + rCompressableStm.Seek( 0 ); + aCodec.BeginCompression( ZCODEC_DEFAULT_COMPRESSION, /*gzLib*/true ); + // the inner modify time/filename doesn't really matter in this context because + // compressed graphic formats are meant to be opened as is - not to be extracted + aCodec.SetCompressionMetadata( "inner", 0, nUncompressedCRC32 ); + aCodec.Compress( rCompressableStm, rOStm ); + tools::Long nCompressedLength = aCodec.EndCompression(); + if ( rOStm.GetError() || nCompressedLength <= 0 ) + nStatus = ERRCODE_GRFILTER_IOERROR; + } return nStatus; }
