diff options
author | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-11-02 14:50:18 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-11-03 05:51:18 +0100 |
commit | d952c0b42a452c875bd9d78870fa9d925af9220e (patch) | |
tree | 1b67be7ac14e2ab1329146127fedc0d31f3c87d5 | |
parent | tdf#45904 Move Java _XSheetCellRanges tests to C++ (diff) | |
download | core-d952c0b42a452c875bd9d78870fa9d925af9220e.tar.gz core-d952c0b42a452c875bd9d78870fa9d925af9220e.zip |
vcl: remove sgf/sgv ancient gfx filters
Change-Id: Ib02986e5b3d54d65982836e22ebcb70eb7a0e7b3
Reviewed-on: https://gerrit.libreoffice.org/44216
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
32 files changed, 5 insertions, 4407 deletions
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk index 7b39020f8e7a..f7c531bccbfe 100644 --- a/filter/Configuration_filter.mk +++ b/filter/Configuration_filter.mk @@ -692,8 +692,6 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_drawgraphics_typ ppm_Portable_Pixelmap \ psd_Adobe_Photoshop \ ras_Sun_Rasterfile \ - sgf_StarOffice_Writer_SGF \ - sgv_StarDraw_20 \ svg_Scalable_Vector_Graphics \ svm_StarView_Metafile \ tga_Truevision_TARGA \ @@ -720,8 +718,6 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_drawgraphics_f PPM___Portable_Pixelmap \ PSD___Adobe_Photoshop \ RAS___Sun_Rasterfile \ - SGF___StarOffice_Writer_SGF \ - SGV___StarDraw_2_0 \ SVG___Scalable_Vector_Graphics \ SVM___StarView_Metafile \ TGA___Truevision_TARGA \ @@ -826,8 +822,6 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_internalgraphics ppm_Portable_Pixelmap \ psd_Adobe_Photoshop \ ras_Sun_Rasterfile \ - sgf_StarOffice_Writer_SGF \ - sgv_StarDraw_20 \ svg_Scalable_Vector_Graphics \ svm_StarView_Metafile \ tga_Truevision_TARGA \ @@ -864,8 +858,6 @@ $(eval $(call filter_Configuration_add_internal_filters,fcfg_langpack,fcfg_inter ppm_Import \ psd_Import \ ras_Import \ - sgf_Import \ - sgv_Import \ svg_Export \ svg_Import \ svm_Export \ diff --git a/filter/source/config/fragments/filters/SGF___StarOffice_Writer_SGF.xcu b/filter/source/config/fragments/filters/SGF___StarOffice_Writer_SGF.xcu deleted file mode 100644 index 739751fb0d1c..000000000000 --- a/filter/source/config/fragments/filters/SGF___StarOffice_Writer_SGF.xcu +++ /dev/null @@ -1,30 +0,0 @@ -<!-- - * 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="SGF - StarOffice Writer SGF" 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">SGF - StarWriter Graphics Format</value> - </prop> - <prop oor:name="FileFormatVersion"><value>0</value></prop> - <prop oor:name="Type"><value>sgf_StarOffice_Writer_SGF</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/SGV___StarDraw_2_0.xcu b/filter/source/config/fragments/filters/SGV___StarDraw_2_0.xcu deleted file mode 100644 index 547ee4163a32..000000000000 --- a/filter/source/config/fragments/filters/SGV___StarDraw_2_0.xcu +++ /dev/null @@ -1,30 +0,0 @@ -<!-- - * 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="SGV - StarDraw 2.0" 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">SGV - StarDraw 2.0</value> - </prop> - <prop oor:name="FileFormatVersion"><value>0</value></prop> - <prop oor:name="Type"><value>sgv_StarDraw_20</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/sgf_Import.xcu b/filter/source/config/fragments/internalgraphicfilters/sgf_Import.xcu deleted file mode 100644 index 242776b0730e..000000000000 --- a/filter/source/config/fragments/internalgraphicfilters/sgf_Import.xcu +++ /dev/null @@ -1,27 +0,0 @@ -<!-- - * 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="sgf_Import" oor:op="replace" > - <prop oor:name="Type"><value>sgf_StarOffice_Writer_SGF</value></prop> - <prop oor:name="FormatName"><value>SVSGF</value></prop> - <prop oor:name="RealFilterName"><value>SGF - StarOffice Writer SGF</value></prop> - <prop oor:name="UIComponent"/> - <prop oor:name="UIName"> - <value xml:lang="en-US">SGF - StarWriter Graphics Format</value> - </prop> - <prop oor:name="Flags"><value>IMPORT</value></prop> - </node> diff --git a/filter/source/config/fragments/internalgraphicfilters/sgv_Import.xcu b/filter/source/config/fragments/internalgraphicfilters/sgv_Import.xcu deleted file mode 100644 index 63d47ce5cf04..000000000000 --- a/filter/source/config/fragments/internalgraphicfilters/sgv_Import.xcu +++ /dev/null @@ -1,27 +0,0 @@ -<!-- - * 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="sgv_Import" oor:op="replace" > - <prop oor:name="Type"><value>sgv_StarDraw_20</value></prop> - <prop oor:name="FormatName"><value>SVSGV</value></prop> - <prop oor:name="RealFilterName"><value>SGV - StarDraw 2.0</value></prop> - <prop oor:name="UIComponent"/> - <prop oor:name="UIName"> - <value xml:lang="en-US">SGV - StarDraw 2.0</value> - </prop> - <prop oor:name="Flags"><value>IMPORT</value></prop> - </node> diff --git a/filter/source/config/fragments/types/sgf_StarOffice_Writer_SGF.xcu b/filter/source/config/fragments/types/sgf_StarOffice_Writer_SGF.xcu deleted file mode 100644 index ed2f380c86a8..000000000000 --- a/filter/source/config/fragments/types/sgf_StarOffice_Writer_SGF.xcu +++ /dev/null @@ -1,29 +0,0 @@ -<!-- - * 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="sgf_StarOffice_Writer_SGF" 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>sgf</value></prop> - <prop oor:name="MediaType"><value>image/x-sgf</value></prop> - <prop oor:name="Preferred"><value>false</value></prop> - <prop oor:name="PreferredFilter"><value>SGF - StarOffice Writer SGF</value></prop> - <prop oor:name="UIName"> - <value>SGF - StarWriter SGF</value> - </prop> - <prop oor:name="ClipboardFormat"/> - </node> diff --git a/filter/source/config/fragments/types/sgv_StarDraw_20.xcu b/filter/source/config/fragments/types/sgv_StarDraw_20.xcu deleted file mode 100644 index 1c0f3ec37174..000000000000 --- a/filter/source/config/fragments/types/sgv_StarDraw_20.xcu +++ /dev/null @@ -1,29 +0,0 @@ -<!-- - * 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="sgv_StarDraw_20" 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>sgv</value></prop> - <prop oor:name="MediaType"/> - <prop oor:name="Preferred"><value>false</value></prop> - <prop oor:name="PreferredFilter"><value>SGV - StarDraw 2.0</value></prop> - <prop oor:name="UIName"> - <value>SGV - StarDraw 2.0</value> - </prop> - <prop oor:name="ClipboardFormat"/> - </node> diff --git a/include/svtools/imagemgr.hxx b/include/svtools/imagemgr.hxx index e76077a35a64..47f3df355799 100644 --- a/include/svtools/imagemgr.hxx +++ b/include/svtools/imagemgr.hxx @@ -57,8 +57,8 @@ enum class SvImageId { DXF = START + 141, MET = START + 142, PNG = START + 143, - SGF = START + 144, - SGV = START + 145, + //retired SGF = START + 144, + //retired SGV = START + 145, SVM = START + 146, GlobalDoc = START + 150, Draw = START + 151, diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index fd6c3db22dc3..2c9ad85b96a0 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -70,8 +70,6 @@ namespace o3tl #define IMP_SVMETAFILE "SVMETAFILE" #define IMP_WMF "SVWMF" #define IMP_EMF "SVEMF" -#define IMP_SVSGF "SVSGF" -#define IMP_SVSGV "SVSGV" #define IMP_GIF "SVIGIF" #define IMP_PNG "SVIPNG" #define IMP_JPEG "SVIJPEG" @@ -124,10 +122,10 @@ enum class GraphicFileFormat DXF = 0x00f1, MET = 0x00f2, PCT = 0x00f3, - SGF = 0x00f4, + // retired SGF = 0x00f4, SVM = 0x00f5, WMF = 0x00f6, - SGV = 0x00f7, + // retired SGV = 0x00f7, EMF = 0x00f8, SVG = 0x00f9 }; @@ -166,10 +164,8 @@ class VCL_DLLPUBLIC GraphicDescriptor final bool ImpDetectDXF( SvStream& rStm, bool bExtendedInfo ); bool ImpDetectMET( SvStream& rStm, bool bExtendedInfo ); bool ImpDetectPCT( SvStream& rStm, bool bExtendedInfo ); - bool ImpDetectSGF( SvStream& rStm, bool bExtendedInfo ); bool ImpDetectSVM( SvStream& rStm, bool bExtendedInfo ); bool ImpDetectWMF( SvStream& rStm, bool bExtendedInfo ); - bool ImpDetectSGV( SvStream& rStm, bool bExtendedInfo ); bool ImpDetectEMF( SvStream& rStm, bool bExtendedInfo ); bool ImpDetectSVG( SvStream& rStm, bool bExtendedInfo ); GraphicDescriptor( const GraphicDescriptor& ) = delete; diff --git a/svtools/inc/bitmaps.hlst b/svtools/inc/bitmaps.hlst index b585e616ebbd..1f31a7f22a62 100644 --- a/svtools/inc/bitmaps.hlst +++ b/svtools/inc/bitmaps.hlst @@ -39,8 +39,6 @@ #define BMP_DXF_SC "res/sx03217.png" #define BMP_MET_SC "res/sx03218.png" #define BMP_PNG_SC "res/sx03219.png" -#define BMP_SGF_SC "res/sx03220.png" -#define BMP_SGV_SC "res/sx03221.png" #define BMP_SVM_SC "res/sx03222.png" #define BMP_GLOBAL_DOC_SC "res/sx03226.png" #define BMP_DRAW_SC "res/sx03227.png" @@ -87,8 +85,6 @@ #define BMP_DXF_LC "res/lx03217.png" #define BMP_MET_LC "res/lx03218.png" #define BMP_PNG_LC "res/lx03219.png" -#define BMP_SGF_LC "res/lx03220.png" -#define BMP_SGV_LC "res/lx03221.png" #define BMP_SVM_LC "res/lx03222.png" #define BMP_GLOBAL_DOC_LC "res/lx03226.png" #define BMP_DRAW_LC "res/lx03227.png" diff --git a/svtools/source/graphic/descriptor.cxx b/svtools/source/graphic/descriptor.cxx index 54254afe70b3..f89895826efd 100644 --- a/svtools/source/graphic/descriptor.cxx +++ b/svtools/source/graphic/descriptor.cxx @@ -128,10 +128,8 @@ void GraphicDescriptor::implCreate( SvStream& rIStm, const OUString* pURL ) case GraphicFileFormat::DXF: pMimeType = MIMETYPE_DXF; cType = graphic::GraphicType::VECTOR; break; case GraphicFileFormat::MET: pMimeType = MIMETYPE_MET; cType = graphic::GraphicType::VECTOR; break; case GraphicFileFormat::PCT: pMimeType = MIMETYPE_PCT; cType = graphic::GraphicType::VECTOR; break; - case GraphicFileFormat::SGF: pMimeType = MIMETYPE_SGF; cType = graphic::GraphicType::VECTOR; break; case GraphicFileFormat::SVM: pMimeType = MIMETYPE_SVM; cType = graphic::GraphicType::VECTOR; break; case GraphicFileFormat::WMF: pMimeType = MIMETYPE_WMF; cType = graphic::GraphicType::VECTOR; break; - case GraphicFileFormat::SGV: pMimeType = MIMETYPE_SGV; cType = graphic::GraphicType::VECTOR; break; case GraphicFileFormat::EMF: pMimeType = MIMETYPE_EMF; cType = graphic::GraphicType::VECTOR; break; case GraphicFileFormat::SVG: pMimeType = MIMETYPE_SVG; cType = graphic::GraphicType::VECTOR; break; diff --git a/svtools/source/graphic/descriptor.hxx b/svtools/source/graphic/descriptor.hxx index d831d17ab8d1..ba585702d205 100644 --- a/svtools/source/graphic/descriptor.hxx +++ b/svtools/source/graphic/descriptor.hxx @@ -45,10 +45,8 @@ #define MIMETYPE_DXF "image/vnd.dxf" #define MIMETYPE_MET "image/x-met" #define MIMETYPE_PCT "image/x-pict" -#define MIMETYPE_SGF "image/x-sgf" #define MIMETYPE_SVM "image/x-svm" #define MIMETYPE_WMF "image/x-wmf" -#define MIMETYPE_SGV "image/x-sgv" #define MIMETYPE_EMF "image/x-emf" #define MIMETYPE_SVG "image/svg+xml" #define MIMETYPE_PDF "application/pdf" diff --git a/svtools/source/misc/imagemgr.cxx b/svtools/source/misc/imagemgr.cxx index ad0522009475..908fb0f2d278 100644 --- a/svtools/source/misc/imagemgr.cxx +++ b/svtools/source/misc/imagemgr.cxx @@ -126,9 +126,7 @@ static SvtExtensionResIdMapping_Impl const ExtensionMap_Impl[] = { "sds", false, STR_DESCRIPTION_SCHART_DOC, SvImageId::NONE }, { "sdw", false, STR_DESCRIPTION_SWRITER_DOC, SvImageId::Writer }, { "sga", false, nullptr, SvImageId::NONE }, - { "sgf", true, STR_DESCRIPTION_GRAPHIC_DOC, SvImageId::SGF }, { "sgl", false, STR_DESCRIPTION_GLOBALDOC, SvImageId::GlobalDoc }, - { "sgv", true, STR_DESCRIPTION_GRAPHIC_DOC, SvImageId::SGV }, { "shtml", false, STR_DESCRIPTION_HTMLFILE, SvImageId::HTML }, { "sim", false, STR_DESCRIPTION_SIMAGE_DOC, SvImageId::SIM }, { "smf", false, STR_DESCRIPTION_SMATH_DOC, SvImageId::Math }, @@ -547,10 +545,6 @@ static Image GetImageFromList_Impl( SvImageId nImageId, bool bBig ) return Image(BitmapEx(BMP_MET_LC)); case SvImageId::PNG: return Image(BitmapEx(BMP_PNG_LC)); - case SvImageId::SGF: - return Image(BitmapEx(BMP_SGF_LC)); - case SvImageId::SGV: - return Image(BitmapEx(BMP_SGV_LC)); case SvImageId::SVM: return Image(BitmapEx(BMP_SVM_LC)); case SvImageId::GlobalDoc: @@ -651,10 +645,6 @@ static Image GetImageFromList_Impl( SvImageId nImageId, bool bBig ) return Image(BitmapEx(BMP_MET_SC)); case SvImageId::PNG: return Image(BitmapEx(BMP_PNG_SC)); - case SvImageId::SGF: - return Image(BitmapEx(BMP_SGF_SC)); - case SvImageId::SGV: - return Image(BitmapEx(BMP_SGV_SC)); case SvImageId::SVM: return Image(BitmapEx(BMP_SVM_SC)); case SvImageId::GlobalDoc: diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 7481e87ed705..eb6fe73f81f4 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -350,10 +350,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/filter/graphicfilter2 \ vcl/source/filter/GraphicNativeTransform \ vcl/source/filter/GraphicNativeMetadata \ - vcl/source/filter/sgfbram \ - vcl/source/filter/sgvmain \ - vcl/source/filter/sgvspln \ - vcl/source/filter/sgvtext \ vcl/source/filter/igif/decode \ vcl/source/filter/igif/gifread \ vcl/source/filter/ipdf/pdfread \ diff --git a/vcl/qa/cppunit/graphicfilter/data/sgv/fail/.gitignore b/vcl/qa/cppunit/graphicfilter/data/sgv/fail/.gitignore deleted file mode 100644 index e69de29bb2d1..000000000000 --- a/vcl/qa/cppunit/graphicfilter/data/sgv/fail/.gitignore +++ /dev/null diff --git a/vcl/qa/cppunit/graphicfilter/data/sgv/indeterminate/.gitignore b/vcl/qa/cppunit/graphicfilter/data/sgv/indeterminate/.gitignore deleted file mode 100644 index e69de29bb2d1..000000000000 --- a/vcl/qa/cppunit/graphicfilter/data/sgv/indeterminate/.gitignore +++ /dev/null diff --git a/vcl/qa/cppunit/graphicfilter/data/sgv/pass/.gitignore b/vcl/qa/cppunit/graphicfilter/data/sgv/pass/.gitignore deleted file mode 100644 index e69de29bb2d1..000000000000 --- a/vcl/qa/cppunit/graphicfilter/data/sgv/pass/.gitignore +++ /dev/null diff --git a/vcl/qa/cppunit/graphicfilter/data/sgv/pass/SaveAsPicture.sgv b/vcl/qa/cppunit/graphicfilter/data/sgv/pass/SaveAsPicture.sgv Binary files differdeleted file mode 100644 index 0fe908e91c98..000000000000 --- a/vcl/qa/cppunit/graphicfilter/data/sgv/pass/SaveAsPicture.sgv +++ /dev/null diff --git a/vcl/qa/cppunit/graphicfilter/data/sgv/pass/faxpfeil.sgv b/vcl/qa/cppunit/graphicfilter/data/sgv/pass/faxpfeil.sgv Binary files differdeleted file mode 100644 index c8317c62e152..000000000000 --- a/vcl/qa/cppunit/graphicfilter/data/sgv/pass/faxpfeil.sgv +++ /dev/null diff --git a/vcl/qa/cppunit/graphicfilter/filters-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-test.cxx index d6a32f2875d5..b6a36c141e63 100644 --- a/vcl/qa/cppunit/graphicfilter/filters-test.cxx +++ b/vcl/qa/cppunit/graphicfilter/filters-test.cxx @@ -151,9 +151,6 @@ void VclFiltersTest::testCVEs() m_directories.getURLFromSrc("/vcl/qa/cppunit/graphicfilter/data/emf/")); testDir(OUString(), - m_directories.getURLFromSrc("/vcl/qa/cppunit/graphicfilter/data/sgv/")); - - testDir(OUString(), m_directories.getURLFromSrc("/vcl/qa/cppunit/graphicfilter/data/png/")); testDir(OUString(), diff --git a/vcl/source/filter/FilterConfigCache.cxx b/vcl/source/filter/FilterConfigCache.cxx index 60a1a0e927cd..bde60c7d3ae6 100644 --- a/vcl/source/filter/FilterConfigCache.cxx +++ b/vcl/source/filter/FilterConfigCache.cxx @@ -43,7 +43,7 @@ const char* FilterConfigCache::FilterConfigCacheEntry::InternalPixelFilterNameLi const char* FilterConfigCache::FilterConfigCacheEntry::InternalVectorFilterNameList[] = { - IMP_SVMETAFILE, IMP_WMF, IMP_EMF, IMP_SVSGF, IMP_SVSGV, IMP_SVG, IMP_PDF, + IMP_SVMETAFILE, IMP_WMF, IMP_EMF, IMP_SVG, IMP_PDF, EXP_SVMETAFILE, EXP_WMF, EXP_EMF, EXP_SVG, EXP_PDF, nullptr }; @@ -234,8 +234,6 @@ const char* FilterConfigCache::InternalFilterListForSvxLight[] = "jpg","2","SVEJPEG", "mov","1","SVMOV", "mov","2","SVMOV", - "sgv","1","SVSGV", - "sgf","1","SVSGF", "met","1","ime", "png","1","SVIPNG", "png","2","SVEPNG", diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index c555ac89aa06..776ef710eee7 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -48,7 +48,6 @@ #include "jpeg/jpeg.hxx" #include "ixbm/xbmread.hxx" #include "ixpm/xpmread.hxx" -#include "sgffilt.hxx" #include <osl/module.hxx> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/awt/Size.hpp> @@ -725,27 +724,6 @@ static bool ImpPeekGraphicFormat( SvStream& rStream, OUString& rFormatExtension, return true; } - //--------------------------- SGV ------------------------------------ - if( !bTest || rFormatExtension.startsWith( "SGV" ) ) - { - bSomethingTested = true; - - // just a simple test for the extension - if( rFormatExtension.startsWith( "SGV" ) ) - return true; - } - - //--------------------------- SGF ------------------------------------ - if( !bTest || rFormatExtension.startsWith( "SGF" ) ) - { - bSomethingTested=true; - if( sFirstBytes[ 0 ] == 'J' && sFirstBytes[ 1 ] == 'J' ) - { - rFormatExtension = "SGF"; - return true; - } - } - if(!bTest || rFormatExtension.startsWith( "MOV" )) { if ((sFirstBytes[ 4 ] == 'f' && sFirstBytes[ 5 ] == 't' && sFirstBytes[ 6 ] == 'y' && @@ -1791,68 +1769,6 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath, nStatus = ERRCODE_GRFILTER_FILTERERROR; } } - else if( aFilterName.equalsIgnoreAsciiCase( IMP_SVSGF ) - || aFilterName.equalsIgnoreAsciiCase( IMP_SVSGV ) ) - { - sal_uInt16 nVersion; - unsigned char nTyp = CheckSgfTyp( rIStream, nVersion ); - - switch( nTyp ) - { - case SGF_BITIMAGE: - { - SvMemoryStream aTempStream; - if( aTempStream.GetError() ) - return ERRCODE_GRFILTER_OPENERROR; - - if( !SgfBMapFilter( rIStream, aTempStream ) ) - nStatus = ERRCODE_GRFILTER_FILTERERROR; - else - { - aTempStream.Seek( 0 ); - ReadGraphic( aTempStream, rGraphic ); - - if( aTempStream.GetError() ) - nStatus = ERRCODE_GRFILTER_FILTERERROR; - } - } - break; - - case SGF_SIMPVECT: - { - GDIMetaFile aMtf; - if( !SgfVectFilter( rIStream, aMtf ) ) - nStatus = ERRCODE_GRFILTER_FILTERERROR; - else - rGraphic = Graphic( aMtf ); - } - break; - - case SGF_STARDRAW: - { - if( nVersion != SGV_VERSION ) - nStatus = ERRCODE_GRFILTER_VERSIONERROR; - else - { - GDIMetaFile aMtf; - if( !SgfSDrwFilter( rIStream, aMtf, - INetURLObject(aFilterPath) ) ) - { - nStatus = ERRCODE_GRFILTER_FILTERERROR; - } - else - rGraphic = Graphic( aMtf ); - } - } - break; - - default: - { - nStatus = ERRCODE_GRFILTER_FORMATERROR; - } - break; - } - } else if (aFilterName == IMP_PDF) { if (!vcl::ImportPDF(rIStream, rGraphic)) diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index ba1d2180ab65..aa4925d81a81 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -70,8 +70,6 @@ bool GraphicDescriptor::Detect( bool bExtendedInfo ) else if ( ImpDetectPCX( rStm, bExtendedInfo ) ) bRet = true; else if ( ImpDetectDXF( rStm, bExtendedInfo ) ) bRet = true; else if ( ImpDetectMET( rStm, bExtendedInfo ) ) bRet = true; - else if ( ImpDetectSGF( rStm, bExtendedInfo ) ) bRet = true; - else if ( ImpDetectSGV( rStm, bExtendedInfo ) ) bRet = true; else if ( ImpDetectSVM( rStm, bExtendedInfo ) ) bRet = true; else if ( ImpDetectWMF( rStm, bExtendedInfo ) ) bRet = true; else if ( ImpDetectEMF( rStm, bExtendedInfo ) ) bRet = true; @@ -955,40 +953,6 @@ bool GraphicDescriptor::ImpDetectPCT( SvStream& rStm, bool ) return bRet; } -bool GraphicDescriptor::ImpDetectSGF( SvStream& rStm, bool ) -{ - bool bRet = false; - if( aPathExt.startsWith( "sgf" ) ) - bRet = true; - else - { - sal_Int32 nStmPos = rStm.Tell(); - - sal_uInt8 nFirst = 0, nSecond = 0; - - rStm.ReadUChar( nFirst ).ReadUChar( nSecond ); - - if( nFirst == 'J' && nSecond == 'J' ) - bRet = true; - - rStm.Seek( nStmPos ); - } - - if( bRet ) - nFormat = GraphicFileFormat::SGF; - - return bRet; -} - -bool GraphicDescriptor::ImpDetectSGV( SvStream&, bool ) -{ - bool bRet = aPathExt.startsWith( "sgv" ); - if (bRet) - nFormat = GraphicFileFormat::SGV; - - return bRet; -} - bool GraphicDescriptor::ImpDetectSVM( SvStream& rStm, bool bExtendedInfo ) { sal_uInt32 n32 = 0; @@ -1118,8 +1082,6 @@ OUString GraphicDescriptor::GetImportFormatShortName( GraphicFileFormat nFormat case GraphicFileFormat::DXF : pKeyName = "dxf"; break; case GraphicFileFormat::MET : pKeyName = "met"; break; case GraphicFileFormat::PCT : pKeyName = "pct"; break; - case GraphicFileFormat::SGF : pKeyName = "sgf"; break; - case GraphicFileFormat::SGV : pKeyName = "sgv"; break; case GraphicFileFormat::SVM : pKeyName = "svm"; break; case GraphicFileFormat::WMF : pKeyName = "wmf"; break; case GraphicFileFormat::EMF : pKeyName = "emf"; break; diff --git a/vcl/source/filter/sgf.ini b/vcl/source/filter/sgf.ini deleted file mode 100644 index 2068c5f46e5a..000000000000 --- a/vcl/source/filter/sgf.ini +++ /dev/null @@ -1,136 +0,0 @@ -# -# 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 . -# - -#Family : (Roman,Swiss,Modern,Script,Decora); -#CharSet : (Ansi,IBMPC,Mac,Symbol,System); Default is System -#Attribute: (Bold,Ital,Sans,Serf,Fixd); - -[SGV Fonts for StarView] -#IF-ID Fontname Attribute SV-Fam ChSet Width FontName - 3848=(ITC Zapf Dingbats) Decora () - 5720=(Symbol) Serf Decora Symbol () - 5721=(Symbol) Bold Serf Decora Symbol () - 5723=(Symbol Sans) Sans Decora Symbol () - 5724=(Symbol Sans) Bold Sans Decora Symbol () - 90133=(Dom Casual) Sans Script () - 90326=(Brush) Bold Ital Serf Script () - 90349=(Park Avenue) Ital Serf Script () - 90508=(Uncial) Sans Roman () - 91118=(Antique Olive) Bold Sans Swiss () - 91119=(Antique Olive) Sans Swiss () - 91120=(Antique Olive Compact) Bold Sans Swiss () - 91335=(ITC Benguiat) Bold Serf Roman () - 91336=(ITC Benguiat) Bold Ital Serf Roman () - 91846=(Antique Olive) Ital Sans Roman () -#92500=(CG Times) Serf Roman () -#92501=(CG Times) Ital Serf Roman () -#92504=(CG Times) Bold Serf Roman () -#92505=(CG Times) Bold Ital Serf Roman () -#93950=(Courier) Serf Fixd Modern () -#93951=(Courier) Ital Serf Fixd Modern () -#93952=(Courier) Bold Serf Fixd Modern () -#93953=(Courier) Bold Ital Serf Fixd Modern () -#94021=(Univers) Sans Swiss () -#94022=(Univers) Ital Sans Swiss () -#94023=(Univers) Bold Sans Swiss () -#94024=(Univers) Bold Ital Sans Swiss () -102004=(Avanti) Bold Ital Sans Swiss () -102005=(Avanti) Ital Sans Swiss () -102007=(Booklet) Bold Sans Roman () -102008=(Booklet) Bold Ital Sans Roman () -102009=(Booklet) Ital Sans Roman () -102010=(Centuri) Sans Roman () -102011=(Centuri) Bold Sans Roman () -102012=(Centuri) Bold Ital Sans Roman () -102013=(Centuri) Ital Sans Roman () -102014=(Paltus) Bold Sans Roman () -102015=(Paltus) Sans Roman () -102016=(Paltus) Bold Ital Sans Roman () -102017=(Paltus) Ital Sans Roman () -102018=(Sans) Sans Swiss () -102019=(Sans) Bold Sans Swiss () -102020=(Sans) Bold Ital Sans Swiss () -102021=(Sans) Ital Sans Swiss () -102022=(SansCondensed) Sans Swiss () -102023=(SansCondensed) Bold Sans Swiss () -102024=(SansCondensed) Bold Ital Sans Swiss () -102025=(SansCondensed) Ital Sans Swiss () -102026=(PS-Roman) Sans Roman () -102027=(PS-Roman) Bold Sans Roman () -102028=(PS-Roman) Bold Ital Sans Roman () -102029=(PS-Roman) Ital Sans Roman () -200111=(Chalenge) Sans () -200112=(Chalenge) Bold Sans () -200113=(Chalenge) Ital Sans () -200114=(Chalenge) Bold Ital Sans () -200121=(Office) Sans () -200122=(Office) Bold Sans () -200123=(Office) Ital Sans () -200124=(Office) Bold Ital Sans () -200131=(Milano) Sans () -200132=(Milano) Bold Sans () -200133=(Milano) Ital Sans () -200134=(Milano) Bold Ital Sans () -200141=(Atlantic) Sans Roman () -200142=(Atlantic) Bold Sans Roman () -200143=(Atlantic) Ital Sans Roman () -200144=(Atlantic) Bold Ital Sans Roman () -200151=(Pentagon) Sans () -200152=(Pentagon) Bold Sans () -200153=(Pentagon) Ital Sans () -200154=(Pentagon) Bold Ital Sans () -200161=(Classico) Sans () -200162=(Classico) Bold Sans () -200163=(Classico) Ital Sans () -200164=(Classico) Bold Ital Sans () -200211=(Westcost) Sans () -200212=(Westcost) Bold Sans () -200213=(Westcost) Ital Sans () -200214=(Westcost) Bold Ital Sans () -200221=(Finish) Sans () -200222=(Finish) Bold Sans () -200223=(Finish) Ital Sans () -200224=(Finish) Bold Ital Sans () -200231=(Classic) Sans () -200232=(Classic) Bold Sans () -200233=(Classic) Ital Sans () -200234=(Classic) Bold Ital Sans () -200241=(Hilton) Sans () -200242=(Hilton) Bold Sans () -200243=(Hilton) Ital Sans () -200244=(Hilton) Bold Ital Sans () -200251=(Progress) Sans () -200252=(Progress) Bold Sans () -200253=(Progress) Ital Sans () -200254=(Progress) Bold Ital Sans () -200261=(PrestigeElite) Sans () -200262=(PrestigeElite) Bold Sans () -200263=(PrestigeElite) Ital Sans () -200271=(Ovetti) Bold Sans () -200272=(Ovetti) Sans () -200301=(Cescendo) Sans () -200302=(Funky) Sans Decora () -200303=(Speed) Sans Decora () -200304=(Skyline) Sans Decora () -200305=(Calculator) Sans Decora () -200306=(Xpress) Sans Decora () -200307=(Console) Sans Decora () -200308=(Paisley) Sans () -200309=(Nova) Sans () -200310=(New York) Sans Decora () -200311=(Shanghai) Sans Decora () diff --git a/vcl/source/filter/sgfbram.cxx b/vcl/source/filter/sgfbram.cxx deleted file mode 100644 index e71fa944afeb..000000000000 --- a/vcl/source/filter/sgfbram.cxx +++ /dev/null @@ -1,519 +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 . - */ - -#include <string.h> -#include <osl/endian.h> -#include <tools/stream.hxx> -#include <tools/fract.hxx> -#include <vcl/gdimtf.hxx> -#include <tools/color.hxx> -#include <vcl/virdev.hxx> -#include "sgffilt.hxx" -#include "sgfbram.hxx" -#include <memory> - -SgfHeader::SgfHeader() -{ - memset( this, 0, sizeof( SgfHeader ) ); -} - -SvStream& ReadSgfHeader(SvStream& rIStream, SgfHeader& rHead) -{ -#if !defined NDEBUG - sal_uInt64 const nOldPos(rIStream.Tell()); -#endif - rIStream.ReadUInt16(rHead.Magic); - rIStream.ReadUInt16(rHead.Version); - rIStream.ReadUInt16(rHead.Typ); - rIStream.ReadUInt16(rHead.Xsize); - rIStream.ReadUInt16(rHead.Ysize); - rIStream.ReadInt16(rHead.Xoffs); - rIStream.ReadInt16(rHead.Yoffs); - rIStream.ReadUInt16(rHead.Planes); - rIStream.ReadUInt16(rHead.SwGrCol); - rIStream.ReadBytes(&rHead.Autor, 10); - rIStream.ReadBytes(&rHead.Programm, 10); - rIStream.ReadUInt16(rHead.OfsLo); - rIStream.ReadUInt16(rHead.OfsHi); - assert(rIStream.GetError() || rIStream.Tell() == nOldPos + SgfHeaderSize); - return rIStream; -} - -bool SgfHeader::ChkMagic() -{ return Magic=='J'*256+'J'; } - -sal_uInt32 SgfHeader::GetOffset() -{ return sal_uInt32(OfsLo)+0x00010000*sal_uInt32(OfsHi); } - -SgfEntry::SgfEntry() -{ - memset( this, 0, sizeof( SgfEntry ) ); -} - -SvStream& ReadSgfEntry(SvStream& rIStream, SgfEntry& rEntr) -{ -#if !defined NDEBUG - sal_uInt64 const nOldPos(rIStream.Tell()); -#endif - rIStream.ReadUInt16(rEntr.Typ); - rIStream.ReadUInt16(rEntr.iFrei); - rIStream.ReadUInt16(rEntr.lFreiLo); - rIStream.ReadUInt16(rEntr.lFreiHi); - rIStream.ReadBytes(&rEntr.cFrei, 10); - rIStream.ReadUInt16(rEntr.OfsLo); - rIStream.ReadUInt16(rEntr.OfsHi); - assert(rIStream.GetError() || rIStream.Tell() == nOldPos + SgfEntrySize); - return rIStream; -} - -sal_uInt32 SgfEntry::GetOffset() -{ return sal_uInt32(OfsLo)+0x00010000*sal_uInt32(OfsHi); } - -SvStream& ReadSgfVector(SvStream& rIStream, SgfVector& rVect) -{ -#if !defined NDEBUG - sal_uInt64 const nOldPos(rIStream.Tell()); -#endif - rIStream.ReadUInt16(rVect.Flag); - rIStream.ReadInt16(rVect.x); - rIStream.ReadInt16(rVect.y); - rIStream.ReadUInt16(rVect.OfsLo); - rIStream.ReadUInt16(rVect.OfsHi); - assert(rIStream.GetError() || rIStream.Tell() == nOldPos + SgfVectorSize); - return rIStream; -} - -SvStream& WriteBmpFileHeader(SvStream& rOStream, BmpFileHeader& rHead) -{ -#if !defined NDEBUG - sal_uInt64 const nOldPos(rOStream.Tell()); -#endif - rOStream.WriteUInt16(rHead.Typ); - rOStream.WriteUInt16(rHead.SizeLo); - rOStream.WriteUInt16(rHead.SizeHi); - rOStream.WriteUInt16(rHead.Reserve1); - rOStream.WriteUInt16(rHead.Reserve2); - rOStream.WriteUInt16(rHead.OfsLo); - rOStream.WriteUInt16(rHead.OfsHi); - assert(rOStream.GetError() || rOStream.Tell() == nOldPos + BmpFileHeaderSize); - return rOStream; -} - -void BmpFileHeader::SetSize(sal_uInt32 Size) -{ - SizeLo=sal_uInt16(Size & 0x0000FFFF); - SizeHi=sal_uInt16((Size & 0xFFFF0000)>>16); -} - -void BmpFileHeader::SetOfs(sal_uInt32 Ofs) -{ - OfsLo=sal_uInt16(Ofs & 0x0000FFFF); - OfsHi=sal_uInt16((Ofs & 0xFFFF0000)>>16); -} - -sal_uInt32 BmpFileHeader::GetOfs() -{ - return sal_uInt32(OfsLo)+0x00010000*sal_uInt32(OfsHi); -} - -SvStream& WriteBmpInfoHeader(SvStream& rOStream, BmpInfoHeader& rInfo) -{ -#if !defined NDEBUG - sal_uInt64 const nOldPos(rOStream.Tell()); -#endif - rOStream.WriteUInt32(rInfo.Size); - rOStream.WriteInt32(rInfo.Width); - rOStream.WriteInt32(rInfo.Hight); - rOStream.WriteUInt16(rInfo.Planes); - rOStream.WriteUInt16(rInfo.PixBits); - rOStream.WriteUInt32(rInfo.Compress); - rOStream.WriteUInt32(rInfo.ImgSize); - rOStream.WriteInt32(rInfo.xDpmm); - rOStream.WriteInt32(rInfo.yDpmm); - rOStream.WriteUInt32(rInfo.ColUsed); - rOStream.WriteUInt32(rInfo.ColMust); - assert(rOStream.GetError() || rOStream.Tell() == nOldPos + BmpInfoHeaderSize); - return rOStream; -} - -SvStream& WriteRGBQuad(SvStream& rOStream, const RGBQuad& rQuad) -{ - rOStream.WriteBytes(&rQuad, sizeof(rQuad)); - return rOStream; -} - -class PcxExpand -{ -private: - sal_uInt16 Count; - sal_uInt8 Data; -public: - PcxExpand() - : Count(0) - , Data(0) - {} - sal_uInt8 GetByte(SvStream& rInp); -}; - -sal_uInt8 PcxExpand::GetByte(SvStream& rInp) -{ - if (Count>0) { - Count--; - } else { - rInp.ReadBytes(&Data, 1); - if ((Data & 0xC0) == 0xC0) { - Count=(Data & 0x3F) -1; - rInp.ReadBytes(&Data, 1); - } - } - return Data; -} - -bool SgfFilterBMap(SvStream& rInp, SvStream& rOut, SgfHeader const & rHead) -{ - BmpFileHeader aBmpHead; - BmpInfoHeader aBmpInfo; - sal_uInt16 nWdtInp=(rHead.Xsize+7)/8; // width of input bitmap in bytes - sal_uInt16 nWdtOut; // width of output bitmap in bytes - sal_uInt16 nColors; // color count (1, 16, 256) - sal_uInt16 nColBits; // number of bits per pixel (2, 4, 8) - sal_uInt16 a,b; // helper variables - sal_uInt8 pl1 = 0; // masks for the planes - std::unique_ptr<sal_uInt8[]> pBuf; // buffer for a pixel row - PcxExpand aPcx; - sal_uLong nOfs; - sal_uInt8 cRGB[4]; - - if (rHead.Planes<=1) nColBits=1; else nColBits=4; if (rHead.Typ==4) nColBits=8; - nColors=1<<nColBits; - nWdtOut=((rHead.Xsize*nColBits+31)/32)*4; - aBmpHead.Typ='B'+'M'*256; - aBmpHead.SetOfs(sizeof(aBmpHead)+sizeof(aBmpInfo)+nColors*4); - aBmpHead.SetSize(aBmpHead.GetOfs()+nWdtOut*rHead.Ysize); - aBmpHead.Reserve1=0; - aBmpHead.Reserve2=0; - aBmpInfo.Size=sizeof(aBmpInfo); - aBmpInfo.Width=rHead.Xsize; - aBmpInfo.Hight=rHead.Ysize; - aBmpInfo.Planes=1; - aBmpInfo.PixBits=nColBits; - aBmpInfo.Compress=0; - aBmpInfo.ImgSize=0; - aBmpInfo.xDpmm=0; - aBmpInfo.yDpmm=0; - aBmpInfo.ColUsed=0; - aBmpInfo.ColMust=0; - pBuf.reset(new sal_uInt8[nWdtOut]); - if (!pBuf) return false; // error: no more memory available - WriteBmpFileHeader( rOut, aBmpHead ); - WriteBmpInfoHeader( rOut, aBmpInfo ); - memset(pBuf.get(),0,nWdtOut); // fill buffer with zeroes - - if (nColors==2) - { - - WriteRGBQuad( rOut, RGBQuad(0x00,0x00,0x00) ); // black - WriteRGBQuad( rOut, RGBQuad(0xFF,0xFF,0xFF) ); // white - nOfs=rOut.Tell(); - for (sal_uInt16 j=0;j<rHead.Ysize;j++) - rOut.WriteBytes(pBuf.get(), nWdtOut); // fill file with zeroes - for (sal_uInt16 j=0;j<rHead.Ysize;j++) { - for(sal_uInt16 i=0;i<nWdtInp;i++) { - pBuf[i]=aPcx.GetByte(rInp); - } - for(sal_uInt16 i=nWdtInp;i<nWdtOut;i++) pBuf[i]=0; // up to 3 bytes - rOut.Seek(nOfs+((sal_uLong)rHead.Ysize-j-1)*(sal_uLong)nWdtOut); // write backwards - rOut.WriteBytes(pBuf.get(), nWdtOut); - } - } else if (nColors==16) { - sal_uInt8 pl2= 0; // planes' masks - - WriteRGBQuad( rOut, RGBQuad(0x00,0x00,0x00) ); // black - WriteRGBQuad( rOut, RGBQuad(0x24,0x24,0x24) ); // gray 80% - WriteRGBQuad( rOut, RGBQuad(0x49,0x49,0x49) ); // gray 60% - WriteRGBQuad( rOut, RGBQuad(0x92,0x92,0x92) ); // gray 40% - WriteRGBQuad( rOut, RGBQuad(0x6D,0x6D,0x6D) ); // gray 30% - WriteRGBQuad( rOut, RGBQuad(0xB6,0xB6,0xB6) ); // gray 20% - WriteRGBQuad( rOut, RGBQuad(0xDA,0xDA,0xDA) ); // gray 10% - WriteRGBQuad( rOut, RGBQuad(0xFF,0xFF,0xFF) ); // white - WriteRGBQuad( rOut, RGBQuad(0x00,0x00,0x00) ); // black - WriteRGBQuad( rOut, RGBQuad(0xFF,0x00,0x00) ); // red - WriteRGBQuad( rOut, RGBQuad(0x00,0x00,0xFF) ); // blue - WriteRGBQuad( rOut, RGBQuad(0xFF,0x00,0xFF) ); // magenta - WriteRGBQuad( rOut, RGBQuad(0x00,0xFF,0x00) ); // green - WriteRGBQuad( rOut, RGBQuad(0xFF,0xFF,0x00) ); // yellow - WriteRGBQuad( rOut, RGBQuad(0x00,0xFF,0xFF) ); // cyan - WriteRGBQuad( rOut, RGBQuad(0xFF,0xFF,0xFF) ); // white - - nOfs=rOut.Tell(); - for (sal_uInt16 j=0;j<rHead.Ysize;j++) - rOut.WriteBytes(pBuf.get(), nWdtOut); // fill file with zeroes - for (sal_uInt16 j=0;j<rHead.Ysize;j++) { - memset(pBuf.get(),0,nWdtOut); - for(sal_uInt16 k=0;k<4;k++) { - if (k==0) { - pl1=0x10; pl2=0x01; - } else { - pl1<<=1; pl2<<=1; - } - for(sal_uInt16 i=0;i<nWdtInp;i++) { - a=i*4; - b=aPcx.GetByte(rInp); - if (b & 0x80) pBuf[a ]|=pl1; - if (b & 0x40) pBuf[a ]|=pl2; - if (b & 0x20) pBuf[a+1]|=pl1; - if (b & 0x10) pBuf[a+1]|=pl2; - if (b & 0x08) pBuf[a+2]|=pl1; - if (b & 0x04) pBuf[a+2]|=pl2; - if (b & 0x02) pBuf[a+3]|=pl1; - if (b & 0x01) pBuf[a+3]|=pl2; - } - } - for(sal_uInt16 i=nWdtInp*4;i<nWdtOut;i++) pBuf[i]=0; // up to 3 bytes - rOut.Seek(nOfs+((sal_uLong)rHead.Ysize-j-1)*(sal_uLong)nWdtOut); // write backwards - rOut.WriteBytes(pBuf.get(), nWdtOut); - } - } else if (nColors==256) { - - //we're going to loop Ysize * XSize on GetByte, max compression for GetByte is a run of 63 - //if we're less than that (and add a generous amount of wriggle room) then its not going - //to fly - sal_uInt64 nMinBytesPossiblyNeeded = rHead.Xsize; - nMinBytesPossiblyNeeded *= rHead.Ysize / 128; - if (rInp.remainingSize() < nMinBytesPossiblyNeeded) - return false; - - cRGB[3]=0; // fourth palette entry for BMP - for (sal_uInt16 i=0;i<256;i++) { // copy palette - rInp.ReadBytes(cRGB, 3); - pl1=cRGB[0]; // switch red and blue - cRGB[0]=cRGB[2]; - cRGB[2]=pl1; - rOut.WriteBytes(cRGB, 4); - } - - nOfs=rOut.Tell(); - for (sal_uInt16 j=0;j<rHead.Ysize;j++) - rOut.WriteBytes(pBuf.get(), nWdtOut); // fill file with zeroes - for (sal_uInt16 j=0;j<rHead.Ysize;j++) { - for(sal_uInt16 i=0;i<rHead.Xsize;i++) - pBuf[i]=aPcx.GetByte(rInp); - for(sal_uInt16 i=rHead.Xsize;i<nWdtOut;i++) pBuf[i]=0; // up to 3 bytes - rOut.Seek(nOfs+((sal_uLong)rHead.Ysize-j-1)*(sal_uLong)nWdtOut); // write backwards - rOut.WriteBytes(pBuf.get(), nWdtOut); - } - } - return true; -} - -bool SgfBMapFilter(SvStream& rInp, SvStream& rOut) -{ - sal_uLong nFileStart; // offset of SgfHeaders. Usually 0. - SgfHeader aHead; - SgfEntry aEntr; - sal_uLong nNext; - bool bRet=false; // return value - - nFileStart=rInp.Tell(); - ReadSgfHeader( rInp, aHead ); - if (!rInp.good()) - return false; - - if (aHead.ChkMagic() && (aHead.Typ==SgfBitImag0 || aHead.Typ==SgfBitImag1 || - aHead.Typ==SgfBitImag2 || aHead.Typ==SgfBitImgMo)) - { - bool bRdFlag = false; // read graphics entry? - nNext = aHead.GetOffset(); - while (nNext && !bRdFlag && !rInp.GetError() && !rOut.GetError()) { - rInp.Seek(nFileStart+nNext); - ReadSgfEntry( rInp, aEntr ); - nNext=aEntr.GetOffset(); - if (aEntr.Typ==aHead.Typ) { - bRdFlag=true; - switch(aEntr.Typ) { - case SgfBitImag0: - case SgfBitImag1: - case SgfBitImag2: - case SgfBitImgMo: bRet=SgfFilterBMap(rInp,rOut,aHead); break; - } - } - } // while(nNext) - } - if (rInp.GetError()) bRet=false; - return bRet; -} - -// for StarDraw embedded SGF vector -long SgfVectXofs=0; -long SgfVectYofs=0; -long SgfVectXmul=0; -long SgfVectYmul=0; -long SgfVectXdiv=0; -long SgfVectYdiv=0; -bool SgfVectScal=false; - -Color Hpgl2SvFarbe( sal_uInt8 nFarb ) -{ - sal_uLong nColor = COL_BLACK; - - switch (nFarb & 0x07) { - case 0: nColor=COL_WHITE; break; - case 1: nColor=COL_YELLOW; break; - case 2: nColor=COL_LIGHTMAGENTA; break; - case 3: nColor=COL_LIGHTRED; break; - case 4: nColor=COL_LIGHTCYAN; break; - case 5: nColor=COL_LIGHTGREEN; break; - case 6: nColor=COL_LIGHTBLUE; break; - case 7: nColor=COL_BLACK; break; - } - Color aColor( nColor ); - return aColor; -} - -bool SgfFilterVect(SvStream& rInp, SgfHeader& rHead, GDIMetaFile& rMtf) -{ - ScopedVclPtrInstance< VirtualDevice > aOutDev; - SgfVector aVect; - sal_uInt8 nFarb; - sal_uInt8 nFrb0=7; - sal_uInt8 nLTyp; - sal_uInt8 nOTyp; - bool bEoDt=false; - Point aP0(0,0); - Point aP1(0,0); - sal_uInt16 RecNr=0; - - rMtf.Record(aOutDev.get()); - aOutDev->SetLineColor(Color(COL_BLACK)); - aOutDev->SetFillColor(Color(COL_BLACK)); - - while (!bEoDt && !rInp.GetError()) { - ReadSgfVector( rInp, aVect ); RecNr++; - nFarb=(sal_uInt8) (aVect.Flag & 0x000F); - nLTyp=(sal_uInt8)((aVect.Flag & 0x00F0) >>4); - nOTyp=(sal_uInt8)((aVect.Flag & 0x0F00) >>8); - bEoDt=(aVect.Flag & 0x4000) !=0; - bool bPDwn=(aVect.Flag & 0x8000) !=0; - - long x=aVect.x-rHead.Xoffs; - long y=rHead.Ysize-(aVect.y-rHead.Yoffs); - if (SgfVectScal) { - if (SgfVectXdiv==0) SgfVectXdiv=rHead.Xsize; - if (SgfVectYdiv==0) SgfVectYdiv=rHead.Ysize; - if (SgfVectXdiv==0) SgfVectXdiv=1; - if (SgfVectYdiv==0) SgfVectYdiv=1; - x=SgfVectXofs+ x *SgfVectXmul /SgfVectXdiv; - y=SgfVectYofs+ y *SgfVectXmul /SgfVectYdiv; - } - aP1=Point(x,y); - if (!bEoDt && !rInp.GetError()) { - if (bPDwn && nLTyp<=6) { - switch(nOTyp) { - case 1: if (nFarb!=nFrb0) { - switch(rHead.SwGrCol) { - case SgfVectFarb: aOutDev->SetLineColor(Hpgl2SvFarbe(nFarb)); break; - case SgfVectGray: break; - case SgfVectWdth: break; - } - } - aOutDev->DrawLine(aP0,aP1); break; // line - case 2: break; // circle - case 3: break; // text - case 5: aOutDev->DrawRect(tools::Rectangle(aP0,aP1)); break; // rectangle (solid) - } - } - aP0=aP1; - nFrb0=nFarb; - } - } - rMtf.Stop(); - rMtf.WindStart(); - MapMode aMap( MapUnit::Map10thMM, Point(), - Fraction( 1, 4 ), Fraction( 1, 4 ) ); - rMtf.SetPrefMapMode( aMap ); - rMtf.SetPrefSize( Size( (short)rHead.Xsize, (short)rHead.Ysize ) ); - return true; -} - -bool SgfVectFilter(SvStream& rInp, GDIMetaFile& rMtf) -{ - sal_uLong nFileStart; // offset of SgfHeaders. Usually 0. - SgfHeader aHead; - SgfEntry aEntr; - sal_uLong nNext; - bool bRet=false; // return value - - nFileStart=rInp.Tell(); - ReadSgfHeader( rInp, aHead ); - if (aHead.ChkMagic() && aHead.Typ==SGF_SIMPVECT) { - nNext=aHead.GetOffset(); - while (nNext && !rInp.GetError()) { - rInp.Seek(nFileStart+nNext); - ReadSgfEntry( rInp, aEntr ); - nNext=aEntr.GetOffset(); - if (aEntr.Typ==aHead.Typ) { - bRet=SgfFilterVect(rInp,aHead,rMtf); - } - } // while(nNext) - } - return bRet; -} - -/************************************************************************* -|* -|* CheckSgfTyp() -|* -|* Description determine which kind of SGF/SGV it is -|* -*************************************************************************/ -sal_uInt8 CheckSgfTyp(SvStream& rInp, sal_uInt16& nVersion) -{ -#if OSL_DEBUG_LEVEL > 1 // check record size, new Compiler had different alignment! - if (sizeof(SgfHeader)!=SgfHeaderSize || - sizeof(SgfEntry) !=SgfEntrySize || - sizeof(SgfVector)!=SgfVectorSize || - sizeof(BmpFileHeader)!=BmpFileHeaderSize || - sizeof(BmpInfoHeader)!=BmpInfoHeaderSize || - sizeof(RGBQuad )!=RGBQuadSize ) return SGF_DONTKNOW; -#endif - - sal_uLong nPos; - SgfHeader aHead; - nVersion=0; - nPos=rInp.Tell(); - ReadSgfHeader( rInp, aHead ); - rInp.Seek(nPos); - if (aHead.ChkMagic()) { - nVersion=aHead.Version; - switch(aHead.Typ) { - case SgfBitImag0: - case SgfBitImag1: - case SgfBitImag2: - case SgfBitImgMo: return SGF_BITIMAGE; - case SgfSimpVect: return SGF_SIMPVECT; - case SgfPostScrp: return SGF_POSTSCRP; - case SgfStarDraw: return SGF_STARDRAW; - default : return SGF_DONTKNOW; - } - } else { - return SGF_DONTKNOW; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/filter/sgfbram.hxx b/vcl/source/filter/sgfbram.hxx deleted file mode 100644 index f714170f43b6..000000000000 --- a/vcl/source/filter/sgfbram.hxx +++ /dev/null @@ -1,142 +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_SOURCE_FILTER_SGFBRAM_HXX -#define INCLUDED_VCL_SOURCE_FILTER_SGFBRAM_HXX - -#define SgfBitImag0 1 /* Bitmap */ -#define SgfBitImag1 4 /* Bitmap */ -#define SgfBitImag2 5 /* Bitmap */ -#define SgfBitImgMo 6 /* Monochrome bitmap */ -#define SgfSimpVect 2 /* Simple vectorformat */ -#define SgfPostScrp 3 /* Postscript file */ -#define SgfStarDraw 7 /* StarDraw SGV-file */ - -// constants for SgfHeader.SwGrCol -#define SgfVectFarb 4 /* use colours in lines */ -#define SgfVectGray 5 /* use greyscale for lines only for */ -#define SgfVectWdth 6 /* use line widths for lines SimpVector */ - -#define SgfHeaderSize 42 -class SgfHeader -{ -public: - sal_uInt16 Magic; - sal_uInt16 Version; - sal_uInt16 Typ; - sal_uInt16 Xsize; - sal_uInt16 Ysize; - sal_Int16 Xoffs; - sal_Int16 Yoffs; - sal_uInt16 Planes; // Layer - sal_uInt16 SwGrCol; - char Autor[10]; - char Programm[10]; - sal_uInt16 OfsLo,OfsHi; // DWord allignment is necessary (38 mod 4 =2) ! - - sal_uInt32 GetOffset(); - friend SvStream& ReadSgfHeader(SvStream& rIStream, SgfHeader& rHead); - bool ChkMagic(); - SgfHeader(); -}; - -#define SgfEntrySize 22 -class SgfEntry -{ -public: - sal_uInt16 Typ; - sal_uInt16 iFrei; - sal_uInt16 lFreiLo,lFreiHi; - char cFrei[10]; - sal_uInt16 OfsLo,OfsHi; // DWord allignment is necessary (18 mod 4 =2) ! - - sal_uInt32 GetOffset(); - friend SvStream& ReadSgfEntry(SvStream& rIStream, SgfEntry& rEntr); - SgfEntry(); -}; - -#define SgfVectorSize 10 -class SgfVector -{ -public: - sal_uInt16 Flag; - sal_Int16 x; - sal_Int16 y; - sal_uInt16 OfsLo,OfsHi; // DWord allignment is necessary (6 mod 4 =2) ! - - friend SvStream& ReadSgfVector(SvStream& rIStream, SgfVector& rEntr); -}; - -extern long SgfVectXofs; -extern long SgfVectYofs; -extern long SgfVectXmul; -extern long SgfVectYmul; -extern long SgfVectXdiv; -extern long SgfVectYdiv; -extern bool SgfVectScal; - -#define BmpFileHeaderSize 14 -class BmpFileHeader -{ -public: - sal_uInt16 Typ; // = "BM" - sal_uInt16 SizeLo,SizeHi; // filesize in bytes - sal_uInt16 Reserve1; // reserved - sal_uInt16 Reserve2; // reserved - sal_uInt16 OfsLo,OfsHi; // Offset? - - void SetSize(sal_uInt32 Size); - void SetOfs(sal_uInt32 Size); - sal_uInt32 GetOfs(); - friend SvStream& WriteBmpFileHeader(SvStream& rOStream, BmpFileHeader& rHead); -}; - -#define BmpInfoHeaderSize 40 -class BmpInfoHeader -{ -public: - sal_uInt32 Size; // size of BmpInfoHeaders - sal_Int32 Width; // width in Pixel - sal_Int32 Hight; // height in Pixel - sal_uInt16 Planes; // number of planes (always 1) - sal_uInt16 PixBits; // number of bits per pixel (1,4,8 or 24) - sal_uInt32 Compress; // data compression - sal_uInt32 ImgSize; // size of image in bytes. Without compression also 0 is allowed. - sal_Int32 xDpmm; // Dot per Meter (0 is allowed) - sal_Int32 yDpmm; // Dot per Meter (0 is allowed) - sal_uInt32 ColUsed; // number of colours used (0=all - sal_uInt32 ColMust; // number of important colours (0=all) - - friend SvStream& WriteBmpInfoHeader(SvStream& rOStream, BmpInfoHeader& rHead); -}; - -#define RGBQuadSize 4 -class RGBQuad { -private: - sal_uInt8 Red; - sal_uInt8 Grn; - sal_uInt8 Blu; - sal_uInt8 Fil; -public: - RGBQuad(sal_uInt8 R, sal_uInt8 G, sal_uInt8 B) { Red=R; Grn=G; Blu=B; Fil=0; } -}; - -#endif // INCLUDED_VCL_SOURCE_FILTER_SGFBRAM_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/filter/sgffilt.hxx b/vcl/source/filter/sgffilt.hxx deleted file mode 100644 index 9256c61770fc..000000000000 --- a/vcl/source/filter/sgffilt.hxx +++ /dev/null @@ -1,40 +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_SOURCE_FILTER_SGFFILT_HXX -#define INCLUDED_VCL_SOURCE_FILTER_SGFFILT_HXX -#include <tools/urlobj.hxx> - -sal_uInt8 CheckSgfTyp(SvStream& rInp, sal_uInt16& nVersion); -bool SgfBMapFilter(SvStream& rInp, SvStream& rOut); -bool SgfVectFilter(SvStream& rInp, GDIMetaFile& rMtf); -bool SgfSDrwFilter(SvStream& rInp, GDIMetaFile& rMtf, const INetURLObject& aIniPath ); - -// constants for CheckSgfTyp() -#define SGF_BITIMAGE 1 /* Bitmap */ -#define SGF_SIMPVECT 2 /* simple vectorformat */ -#define SGF_POSTSCRP 3 /* Postscript file */ -#define SGF_STARDRAW 7 /* StarDraw SGV file */ -#define SGF_DONTKNOW 255 /* unknown or no SGF/SGV */ - -#define SGV_VERSION 3 /* reject SGV with other version */ - /* 3 matches StarDraw 2.00/2.01 march'93 */ -#endif // INCLUDED_VCL_SOURCE_FILTER_SGFFILT_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/filter/sgvmain.cxx b/vcl/source/filter/sgvmain.cxx deleted file mode 100644 index b26e120874f8..000000000000 --- a/vcl/source/filter/sgvmain.cxx +++ /dev/null @@ -1,947 +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 . - */ - -#include <rtl/math.hxx> -#include <osl/endian.h> -#include <vcl/graph.hxx> -#include <tools/poly.hxx> -#include <tools/fract.hxx> -#include <vcl/graphicfilter.hxx> -#include "sgffilt.hxx" -#include "sgfbram.hxx" -#include "sgvmain.hxx" -#include "sgvspln.hxx" -#include <unotools/ucbstreamhelper.hxx> - -// Restrictions: - -// - area patterns are matched to the available ones in Starview. -// - line ends are always rounded in StarView and continue past the end of line. -// - line patterns are matched to the available ones in Starview. -// transparency/opacity is not taken into account -// - no rotated ellipses - -// for font translation -SgfFontLst* pSgfFonts = nullptr; - -// for circle kinds, text and rotated rectangles -void RotatePoint(PointType& P, sal_Int16 cx, sal_Int16 cy, double sn, double cs) -{ - sal_Int16 dx,dy; - double x1,y1; - dx=P.x-cx; - dy=P.y-cy; - x1=dx*cs-dy*sn; - y1=dy*cs+dx*sn; - P.x=cx+sal_Int16(x1); - P.y=cy+sal_Int16(y1); -} - -void RotatePoint(Point& P, sal_Int16 cx, sal_Int16 cy, double sn, double cs) -{ - sal_Int16 dx,dy; - double x1,y1; - dx=(sal_Int16)(P.X()-cx); - dy=(sal_Int16)(P.Y()-cy); - x1=dx*cs-dy*sn; - y1=dy*cs+dx*sn; - P=Point(cx+sal_Int16(x1),cy+sal_Int16(y1)); -} - -sal_Int16 iMulDiv(sal_Int16 a, sal_Int16 Mul, sal_Int16 Div) -{ - sal_Int32 Temp; - Temp=sal_Int32(a)*sal_Int32(Mul)/sal_Int32(Div); - return sal_Int16(Temp); -} - -sal_uInt16 MulDiv(sal_uInt16 a, sal_uInt16 Mul, sal_uInt16 Div) -{ - sal_uInt32 Temp; - Temp=sal_uInt32(a)*sal_uInt32(Mul)/sal_uInt32(Div); - return sal_uInt16(Temp); -} - -// SgfFilterSDrw - -void DtHdOverSeek(SvStream& rInp) -{ - sal_uLong FPos=rInp.Tell(); - FPos+=(sal_uLong)DtHdSize; - rInp.Seek(FPos); -} - -PageType::PageType() -{ - memset( this, 0, sizeof( PageType ) ); -} - -SvStream& ReadPageType(SvStream& rIStream, PageType& rPage) -{ - sal_uInt64 const nOldPos(rIStream.Tell()); - rIStream.ReadUInt32(rPage.Next); - rIStream.ReadUInt32(rPage.nList); - rIStream.ReadUInt32(rPage.ListEnd); - rIStream.ReadInt16(rPage.Paper.Size.x); - rIStream.ReadInt16(rPage.Paper.Size.y); - rIStream.ReadInt16(rPage.Paper.RandL); - rIStream.ReadInt16(rPage.Paper.RandR); - rIStream.ReadInt16(rPage.Paper.RandO); - rIStream.ReadInt16(rPage.Paper.RandU); - rIStream.ReadUChar(rPage.Paper.PColor); - rIStream.ReadUChar(rPage.Paper.PIntens); - rIStream.ReadCharAsBool(rPage.BorderClip); - rIStream.ReadUChar(rPage.StdPg); - rIStream.ReadInt16(rPage.U.x); - rIStream.ReadInt16(rPage.U.y); - for (int i = 0; i < 20; ++i) - { - rIStream.ReadInt16(rPage.HlpLnH[i]); - } - for (int i = 0; i < 20; ++i) - { - rIStream.ReadInt16(rPage.HlpLnV[i]); - } - rIStream.ReadUChar(rPage.LnAnzH); - rIStream.ReadUChar(rPage.LnAnzV); - for (int i = 0; i < 32; ++i) - { - rIStream.ReadUChar(rPage.PgName[i]); - } - assert(rIStream.GetError() || rIStream.Tell() == nOldPos + PageSize); - (void) nOldPos; - return rIStream; -} - -void ReadObjLineType(SvStream & rInp, ObjLineType & rLine) -{ - // reads 8 bytes - rInp.ReadUChar(rLine.LFarbe); - rInp.ReadUChar(rLine.LBFarbe); - rInp.ReadUChar(rLine.LIntens); - rInp.ReadUChar(rLine.LMuster); - rInp.ReadInt16(rLine.LMSize); - rInp.ReadInt16(rLine.LDicke); -} - -void ReadObjAreaType(SvStream & rInp, ObjAreaType & rArea) -{ - // reads 8 bytes - rInp.ReadUChar(rArea.FFarbe); - rInp.ReadUChar(rArea.FBFarbe); - rInp.ReadUChar(rArea.FIntens); - rInp.ReadUChar(rArea.FDummy1); - rInp.ReadInt16(rArea.FDummy2); - rInp.ReadUInt16(rArea.FMuster); -} - -void ObjkOverSeek(SvStream& rInp, ObjkType const & rObjk) -{ - sal_uLong Siz; - Siz=(sal_uLong)rObjk.MemSize+rObjk.Last; // ObjSize+ObjAnhSize - rInp.Seek(rInp.Tell()+Siz); -} - -SvStream& ReadObjkType(SvStream& rInp, ObjkType& rObjk, bool const isRewind = true) -{ - // fileposition in stream is not changed! - sal_uInt64 const nOldPos = rInp.Tell(); - rInp.ReadUInt32(rObjk.Last); - rInp.ReadUInt32(rObjk.Next); - rInp.ReadUInt16(rObjk.MemSize); - rInp.ReadInt16(rObjk.ObjMin.x); - rInp.ReadInt16(rObjk.ObjMin.y); - rInp.ReadInt16(rObjk.ObjMax.x); - rInp.ReadInt16(rObjk.ObjMax.y); - rInp.ReadUChar(rObjk.Art); - rInp.ReadUChar(rObjk.Layer); - assert(rInp.GetError() || rInp.Tell() == nOldPos + ObjkSize); - if (isRewind) - rInp.Seek(nOldPos); - return rInp; -} -SvStream& ReadStrkType(SvStream& rInp, StrkType& rStrk) -{ - sal_uInt64 const nOldPos(rInp.Tell()); - ReadObjkType(rInp, rStrk, false); - rInp.ReadUChar(rStrk.Flags); - rInp.ReadUChar(rStrk.LEnden); - ReadObjLineType(rInp, rStrk.L); - rInp.ReadInt16(rStrk.Pos1.x); - rInp.ReadInt16(rStrk.Pos1.y); - rInp.ReadInt16(rStrk.Pos2.x); - rInp.ReadInt16(rStrk.Pos2.y); - assert(rInp.GetError() || rInp.Tell() == nOldPos + StrkSize); - (void) nOldPos; - return rInp; -} -SvStream& ReadRectType(SvStream& rInp, RectType& rRect) -{ - sal_uInt64 const nOldPos(rInp.Tell()); - ReadObjkType(rInp, rRect, false); - rInp.ReadUChar(rRect.Flags); - rInp.ReadUChar(rRect.Reserve); - ReadObjLineType(rInp, rRect.L); - ReadObjAreaType(rInp, rRect.F); - rInp.ReadInt16(rRect.Pos1.x); - rInp.ReadInt16(rRect.Pos1.y); - rInp.ReadInt16(rRect.Pos2.x); - rInp.ReadInt16(rRect.Pos2.y); - rInp.ReadInt16(rRect.Radius); - rInp.ReadUInt16(rRect.RotationAngle); - rInp.ReadUInt16(rRect.Slant); - assert(rInp.GetError() || rInp.Tell() == nOldPos + RectSize); - (void) nOldPos; - return rInp; -} -SvStream& ReadPolyType(SvStream& rInp, PolyType& rPoly) -{ - sal_uInt64 const nOldPos(rInp.Tell()); - ReadObjkType(rInp, rPoly, false); - rInp.ReadUChar(rPoly.Flags); - rInp.ReadUChar(rPoly.LEnden); - ReadObjLineType(rInp, rPoly.L); - ReadObjAreaType(rInp, rPoly.F); - rInp.ReadUChar(rPoly.nPoints); - rInp.ReadUChar(rPoly.Reserve); - rInp.ReadUInt32(rPoly.SD_EckP); - assert(rInp.GetError() || rInp.Tell() == nOldPos + PolySize); - (void) nOldPos; - return rInp; -} - -SvStream& ReadSplnType(SvStream& rInp, SplnType& rSpln) -{ - sal_uInt64 const nOldPos(rInp.Tell()); - ReadObjkType(rInp, rSpln, false); - rInp.ReadUChar(rSpln.Flags); - rInp.ReadUChar(rSpln.LEnden); - ReadObjLineType(rInp, rSpln.L); - ReadObjAreaType(rInp, rSpln.F); - rInp.ReadUChar(rSpln.nPoints); - rInp.ReadUChar(rSpln.Reserve); - rInp.ReadUInt32(rSpln.SD_EckP); - assert(rInp.GetError() || rInp.Tell() == nOldPos + SplnSize); - (void) nOldPos; - return rInp; -} -SvStream& ReadCircType(SvStream& rInp, CircType& rCirc) -{ - sal_uInt64 const nOldPos(rInp.Tell()); - ReadObjkType(rInp, rCirc, false); - rInp.ReadUChar(rCirc.Flags); - rInp.ReadUChar(rCirc.LEnden); - ReadObjLineType(rInp, rCirc.L); - ReadObjAreaType(rInp, rCirc.F); - rInp.ReadInt16(rCirc.Center.x); - rInp.ReadInt16(rCirc.Center.y); - rInp.ReadInt16(rCirc.Radius.x); - rInp.ReadInt16(rCirc.Radius.y); - rInp.ReadUInt16(rCirc.RotationAngle); - rInp.ReadUInt16(rCirc.StartAngle); - rInp.ReadUInt16(rCirc.RelAngle); - assert(rInp.GetError() || rInp.Tell() == nOldPos + CircSize); - (void) nOldPos; - return rInp; -} -SvStream& ReadTextType(SvStream& rInp, TextType& rText) -{ - sal_uInt64 const nOldPos(rInp.Tell()); - ReadObjkType(rInp, rText, false); - rInp.ReadUChar(rText.Flags); - rInp.ReadUChar(rText.Reserve); - ReadObjLineType(rInp, rText.T.L); - ReadObjAreaType(rInp, rText.T.F); - rInp.ReadUInt16(rText.T.FontLo); - rInp.ReadUInt16(rText.T.FontHi); - rInp.ReadUInt16(rText.T.Grad); - rInp.ReadUInt16(rText.T.Breite); - rInp.ReadUChar(rText.T.Justify); - rInp.ReadUChar(rText.T.Kapit); - rInp.ReadUInt16(rText.T.Schnitt); - rInp.ReadUInt16(rText.T.LnFeed); - rInp.ReadUInt16(rText.T.Slant); - rInp.ReadUChar(rText.T.ZAbst); - rInp.ReadSChar(rText.T.ChrVPos); - ReadObjLineType(rInp, rText.T.ShdL); - ReadObjAreaType(rInp, rText.T.ShdF); - rInp.ReadInt16(rText.T.ShdVers.x); - rInp.ReadInt16(rText.T.ShdVers.y); - rInp.ReadCharAsBool(rText.T.ShdAbs); - rInp.ReadCharAsBool(rText.T.NoSpc); - ReadObjAreaType(rInp, rText.T.BackF); - rInp.ReadInt16(rText.Pos1.x); - rInp.ReadInt16(rText.Pos1.y); - rInp.ReadInt16(rText.Pos2.x); - rInp.ReadInt16(rText.Pos2.y); - rInp.ReadInt16(rText.TopOfs); - rInp.ReadUInt16(rText.RotationAngle); - rInp.ReadUInt16(rText.BoxSlant); - rInp.ReadUInt16(rText.BufSize); - rInp.ReadUInt16(rText.BufLo); - rInp.ReadUInt16(rText.BufHi); - rInp.ReadUInt16(rText.ExtLo); - rInp.ReadUInt16(rText.ExtHi); - rInp.ReadInt16(rText.FitSize.x); - rInp.ReadInt16(rText.FitSize.y); - rInp.ReadInt16(rText.FitBreit); - assert(rInp.GetError() || rInp.Tell() == nOldPos + TextSize); - (void) nOldPos; - return rInp; -} -SvStream& ReadBmapType(SvStream& rInp, BmapType& rBmap) -{ - sal_uInt64 const nOldPos(rInp.Tell()); - ReadObjkType(rInp, rBmap, false); - rInp.ReadUChar(rBmap.Flags); - rInp.ReadUChar(rBmap.Reserve); - ReadObjAreaType(rInp, rBmap.F); - rInp.ReadInt16(rBmap.Pos1.x); - rInp.ReadInt16(rBmap.Pos1.y); - rInp.ReadInt16(rBmap.Pos2.x); - rInp.ReadInt16(rBmap.Pos2.y); - rInp.ReadUInt16(rBmap.RotationAngle); - rInp.ReadUInt16(rBmap.Slant); - for (int i = 0; i < 80; ++i) - { - rInp.ReadUChar(rBmap.Filename[i]); - } - rInp.ReadInt16(rBmap.PixSize.x); - rInp.ReadInt16(rBmap.PixSize.y); - static_assert(sizeof(enum GrafStat) == 4, "enum has unexpected size"); - sal_uInt32 nTemp(0); - rInp.ReadUInt32(nTemp); - rBmap.Format = static_cast<GrafStat>(nTemp); - rInp.ReadUChar(rBmap.nPlanes); - rInp.ReadCharAsBool(rBmap.RawOut); - rInp.ReadCharAsBool(rBmap.InvOut); - rInp.ReadCharAsBool(rBmap.LightOut); - rInp.ReadUChar(rBmap.GrfFlg); - assert(rInp.GetError() || rInp.Tell() == nOldPos + BmapSize); - (void) nOldPos; - return rInp; -} -SvStream& ReadGrupType(SvStream& rInp, GrupType& rGrup) -{ - sal_uInt64 const nOldPos(rInp.Tell()); - ReadObjkType(rInp, rGrup, false); - rInp.ReadUChar(rGrup.Flags); - for (int i = 0; i < 13; ++i) - { - rInp.ReadUChar(rGrup.Name[i]); - } - rInp.ReadUInt16(rGrup.SbLo); - rInp.ReadUInt16(rGrup.SbHi); - rInp.ReadUInt16(rGrup.UpLo); - rInp.ReadUInt16(rGrup.UpHi); - rInp.ReadUInt16(rGrup.ChartSize); - rInp.ReadUInt32(rGrup.ChartPtr); - assert(rInp.GetError() || rInp.Tell() == nOldPos + GrupSize); - (void) nOldPos; - return rInp; -} - -Color Sgv2SvFarbe(sal_uInt8 nFrb1, sal_uInt8 nFrb2, sal_uInt8 nInts) -{ - sal_uInt16 r1=0,g1=0,b1=0,r2=0,g2=0,b2=0; - sal_uInt8 nInt2=100-nInts; - switch(nFrb1 & 0x07) { - case 0: r1=0xFF; g1=0xFF; b1=0xFF; break; - case 1: r1=0xFF; g1=0xFF; break; - case 2: g1=0xFF; b1=0xFF; break; - case 3: g1=0xFF; break; - case 4: r1=0xFF; b1=0xFF; break; - case 5: r1=0xFF; break; - case 6: b1=0xFF; break; - case 7: break; - } - switch(nFrb2 & 0x07) { - case 0: r2=0xFF; g2=0xFF; b2=0xFF; break; - case 1: r2=0xFF; g2=0xFF; break; - case 2: g2=0xFF; b2=0xFF; break; - case 3: g2=0xFF; break; - case 4: r2=0xFF; b2=0xFF; break; - case 5: r2=0xFF; break; - case 6: b2=0xFF; break; - case 7: break; - } - r1=(sal_uInt16)((sal_uInt32)r1*nInts/100+(sal_uInt32)r2*nInt2/100); - g1=(sal_uInt16)((sal_uInt32)g1*nInts/100+(sal_uInt32)g2*nInt2/100); - b1=(sal_uInt16)((sal_uInt32)b1*nInts/100+(sal_uInt32)b2*nInt2/100); - Color aColor( (sal_uInt8)r1, (sal_uInt8)g1, (sal_uInt8)b1 ); - return aColor; -} - -void SetLine(ObjLineType& rLine, OutputDevice& rOut) -{ - if( 0 == ( rLine.LMuster & 0x07 ) ) - rOut.SetLineColor(); - else - rOut.SetLineColor( Sgv2SvFarbe(rLine.LFarbe,rLine.LBFarbe,rLine.LIntens) ); -} - -void SetArea(ObjAreaType& rArea, OutputDevice& rOut) -{ - if( 0 == ( rArea.FMuster & 0x00FF ) ) - rOut.SetFillColor(); - else - rOut.SetFillColor( Sgv2SvFarbe( rArea.FFarbe,rArea.FBFarbe,rArea.FIntens ) ); -} - -void ObjkType::Draw(OutputDevice&, UCHAR *) -{ -} - -void StrkType::Draw(OutputDevice& rOut, UCHAR *) -{ - SetLine(L,rOut); - rOut.DrawLine(Point(Pos1.x,Pos1.y),Point(Pos2.x,Pos2.y)); // !!! -} - -void SgfAreaColorIntens(sal_uInt16 Muster, sal_uInt8 Col1, sal_uInt8 Col2, sal_uInt8 Int, OutputDevice& rOut) -{ - ObjAreaType F; - F.FMuster=Muster; - F.FFarbe=Col2; - F.FBFarbe=Col1; - F.FIntens=Int; - SetArea(F,rOut); -} - -void DrawSlideRect(sal_Int16 x1, sal_Int16 y1, sal_Int16 x2, sal_Int16 y2, ObjAreaType& F, OutputDevice& rOut) -{ - sal_Int16 i,i0,b,b0; - sal_Int16 Int1,Int2; - sal_Int16 Col1,Col2; - // ClipMerk: HgdClipRec; - sal_Int16 cx,cy; - sal_Int16 MaxR; - sal_Int32 dx,dy; - - rOut.SetLineColor(); - if (x1>x2) { i=x1; x1=x2; x2=i; } - if (y1>y2) { i=y1; y1=y2; y2=i; } - Col1=F.FBFarbe & 0x87; Col2=F.FFarbe & 0x87; - Int1=100-F.FIntens; Int2=F.FIntens; - if (Int1==Int2) { - SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int2,rOut); - rOut.DrawRect(tools::Rectangle(x1,y1,x2,y2)); - } else { - b0=Int1; - switch (F.FBFarbe & 0x38) { - case 0x08: { // vertikal - i0=y1; - i=y1; - while (i<=y2) { - b=Int1+sal_Int16((sal_Int32)(Int2-Int1)*(sal_Int32)(i-y1) /(sal_Int32)(y2-y1+1)); - if (b!=b0) { - SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)b0,rOut); - rOut.DrawRect(tools::Rectangle(x1,i0,x2,i-1)); - i0=i; b0=b; - } - i++; - } - SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int2,rOut); - rOut.DrawRect(tools::Rectangle(x1,i0,x2,y2)); - } break; - case 0x28: { // horizontal - i0=x1; - i=x1; - while (i<=x2) { - b=Int1+sal_Int16((sal_Int32)(Int2-Int1)*(sal_Int32)(i-x1) /(sal_Int32)(x2-x1+1)); - if (b!=b0) { - SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)b0,rOut); - rOut.DrawRect(tools::Rectangle(i0,y1,i-1,y2)); - i0=i; b0=b; - } - i++; - } - SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int2,rOut); - rOut.DrawRect(tools::Rectangle(i0,y1,x2,y2)); - } break; - - case 0x18: case 0x38: { // circle - vcl::Region ClipMerk=rOut.GetClipRegion(); - double a; - - rOut.SetClipRegion(vcl::Region(tools::Rectangle(x1,y1,x2,y2))); - cx=(x1+x2) /2; - cy=(y1+y2) /2; - dx=x2-x1+1; - dy=y2-y1+1; - a=sqrt((double)(dx*dx+dy*dy)); - MaxR=sal_Int16(a) /2 +1; - b0=Int2; - i0=MaxR; if (MaxR<1) MaxR=1; - i=MaxR; - while (i>=0) { - b=Int1+sal_Int16((sal_Int32(Int2-Int1)*sal_Int32(i)) /sal_Int32(MaxR)); - if (b!=b0) { - SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)b0,rOut); - rOut.DrawEllipse(tools::Rectangle(cx-i0,cy-i0,cx+i0,cy+i0)); - i0=i; b0=b; - } - i--; - } - SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int1,rOut); - rOut.DrawEllipse(tools::Rectangle(cx-i0,cy-i0,cx+i0,cy+i0)); - rOut.SetClipRegion(ClipMerk); - } break; // circle - } - } -} - -void RectType::Draw(OutputDevice& rOut, UCHAR *) -{ - if (L.LMuster!=0) L.LMuster=1; // no line separator here, only on or off - SetArea(F,rOut); - if (RotationAngle==0) { - if ((F.FBFarbe & 0x38)==0 || Radius!=0) { - SetLine(L,rOut); - rOut.DrawRect(tools::Rectangle(Pos1.x,Pos1.y,Pos2.x,Pos2.y),Radius,Radius); - } else { - DrawSlideRect(Pos1.x,Pos1.y,Pos2.x,Pos2.y,F,rOut); - if (L.LMuster!=0) { - SetLine(L,rOut); - rOut.SetFillColor(); - rOut.DrawRect(tools::Rectangle(Pos1.x,Pos1.y,Pos2.x,Pos2.y)); - } - } - } else { - Point aPts[4]; - sal_uInt16 i; - double sn,cs; - sn=sin(double(RotationAngle)*3.14159265359/18000); - cs=cos(double(RotationAngle)*3.14159265359/18000); - aPts[0]=Point(Pos1.x,Pos1.y); - aPts[1]=Point(Pos2.x,Pos1.y); - aPts[2]=Point(Pos2.x,Pos2.y); - aPts[3]=Point(Pos1.x,Pos2.y); - for (i=0;i<4;i++) { - RotatePoint(aPts[i],Pos1.x,Pos1.y,sn,cs); - } - SetLine(L,rOut); - tools::Polygon aPoly(4,aPts); - rOut.DrawPolygon(aPoly); - } -} - -void PolyType::Draw(OutputDevice& rOut, UCHAR *) -{ - if ((Flags & PolyClosBit) !=0) SetArea(F,rOut); - SetLine(L,rOut); - tools::Polygon aPoly(nPoints); - sal_uInt16 i; - for(i=0;i<nPoints;i++) aPoly.SetPoint(Point(EckP[i].x,EckP[i].y),i); - if ((Flags & PolyClosBit) !=0) { - rOut.DrawPolygon(aPoly); - } else { - rOut.DrawPolyLine(aPoly); - } -} - -void SplnType::Draw(OutputDevice& rOut, UCHAR *) -{ - if ((Flags & PolyClosBit) !=0) SetArea(F,rOut); - SetLine(L,rOut); - tools::Polygon aPoly(0); - tools::Polygon aSpln(nPoints); - sal_uInt16 i; - for(i=0;i<nPoints;i++) aSpln.SetPoint(Point(EckP[i].x,EckP[i].y),i); - if ((Flags & PolyClosBit) !=0) { - Spline2Poly(aSpln,true,aPoly); - if (aPoly.GetSize()>0) rOut.DrawPolygon(aPoly); - } else { - Spline2Poly(aSpln,false,aPoly); - if (aPoly.GetSize()>0) rOut.DrawPolyLine(aPoly); - } -} - -void DrawSlideCirc(sal_Int16 cx, sal_Int16 cy, sal_Int16 rx, sal_Int16 ry, ObjAreaType& F, OutputDevice& rOut) -{ - sal_Int16 x1=cx-rx; - sal_Int16 y1=cy-ry; - sal_Int16 x2=cx+rx; - sal_Int16 y2=cy+ry; - - sal_Int16 i,i0,b,b0; - sal_Int16 Int1,Int2; - sal_Int16 Col1,Col2; - - rOut.SetLineColor(); - Col1=F.FBFarbe & 0x87; Col2=F.FFarbe & 0x87; - Int1=100-F.FIntens; Int2=F.FIntens; - if (Int1==Int2) { - SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int2,rOut); - rOut.DrawEllipse(tools::Rectangle(x1,y1,x2,y2)); - } else { - b0=Int1; - switch (F.FBFarbe & 0x38) { - case 0x08: { // vertical - vcl::Region ClipMerk=rOut.GetClipRegion(); - i0=y1; - i=y1; - while (i<=y2) { - b=Int1+sal_Int16((sal_Int32)(Int2-Int1)*(sal_Int32)(i-y1) /(sal_Int32)(y2-y1+1)); - if (b!=b0) { - SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)b0,rOut); - rOut.SetClipRegion(vcl::Region(tools::Rectangle(x1,i0,x2,i-1))); - rOut.DrawEllipse(tools::Rectangle(x1,y1,x2,y2)); - i0=i; b0=b; - } - i++; - } - SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int2,rOut); - rOut.SetClipRegion(vcl::Region(tools::Rectangle(x1,i0,x2,y2))); - rOut.DrawEllipse(tools::Rectangle(x1,y1,x2,y2)); - rOut.SetClipRegion(ClipMerk); - } break; - case 0x28: { // horizontal - vcl::Region ClipMerk=rOut.GetClipRegion(); - i0=x1; - i=x1; - while (i<=x2) { - b=Int1+sal_Int16((sal_Int32)(Int2-Int1)*(sal_Int32)(i-x1) /(sal_Int32)(x2-x1+1)); - if (b!=b0) { - SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)b0,rOut); - rOut.SetClipRegion(vcl::Region(tools::Rectangle(i0,y1,i-1,y2))); - rOut.DrawEllipse(tools::Rectangle(x1,y1,x2,y2)); - i0=i; b0=b; - } - i++; - } - SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int2,rOut); - rOut.SetClipRegion(vcl::Region(tools::Rectangle(i0,y1,x2,y2))); - rOut.DrawEllipse(tools::Rectangle(x1,y1,x2,y2)); - rOut.SetClipRegion(ClipMerk); - } break; - - case 0x18: case 0x38: { // circle - sal_Int16 MaxR; - - if (rx<1) rx=1; - if (ry<1) ry=1; - MaxR=rx; - b0=Int2; - i0=MaxR; - i=MaxR; - while (i>=0) { - b=Int1+sal_Int16((sal_Int32(Int2-Int1)*sal_Int32(i)) /sal_Int32(MaxR)); - if (b!=b0) { - sal_Int32 temp=sal_Int32(i0)*sal_Int32(ry)/sal_Int32(rx); - sal_Int16 j0=sal_Int16(temp); - SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)b0,rOut); - rOut.DrawEllipse(tools::Rectangle(cx-i0,cy-j0,cx+i0,cy+j0)); - i0=i; b0=b; - } - i--; - } - SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int1,rOut); - rOut.DrawEllipse(tools::Rectangle(cx-i0,cy-i0,cx+i0,cy+i0)); - } break; // circle - } - } -} - -void CircType::Draw(OutputDevice& rOut, UCHAR *) -{ - tools::Rectangle aRect(Center.x-Radius.x,Center.y-Radius.y,Center.x+Radius.x,Center.y+Radius.y); - - if (L.LMuster!=0) L.LMuster=1; // no line pattern here, only on or off - SetArea(F,rOut); - if ((Flags & 0x03)==CircFull) { - if ((F.FBFarbe & 0x38)==0) { - SetLine(L,rOut); - rOut.DrawEllipse(aRect); - } else { - DrawSlideCirc(Center.x,Center.y,Radius.x,Radius.y,F,rOut); - if (L.LMuster!=0) { - SetLine(L,rOut); - rOut.SetFillColor(); - rOut.DrawEllipse(aRect); - } - } - } else { - PointType a,b; - Point aStrt,aEnde; - double sn,cs; - - a.x=Center.x+Radius.x; a.y=Center.y; b=a; - sn=sin(double(StartAngle)*3.14159265359/18000); - cs=cos(double(StartAngle)*3.14159265359/18000); - RotatePoint(a,Center.x,Center.y,sn,cs); - sn=sin(double(StartAngle+RelAngle)*3.14159265359/18000); - cs=cos(double(StartAngle+RelAngle)*3.14159265359/18000); - RotatePoint(b,Center.x,Center.y,sn,cs); - if (Radius.x!=Radius.y) { - if (Radius.x<1) Radius.x=1; - if (Radius.y<1) Radius.y=1; - a.y = a.y - Center.y; - b.y = b.y - Center.y; - a.y=iMulDiv(a.y,Radius.y,Radius.x); - b.y=iMulDiv(b.y,Radius.y,Radius.x); - a.y = a.y + Center.y; - b.y = b.y + Center.y; - } - aStrt=Point(a.x,a.y); - aEnde=Point(b.x,b.y); - SetLine(L,rOut); - switch (Flags & 0x03) { - case CircArc : rOut.DrawArc(aRect,aEnde,aStrt); break; - case CircSect: - case CircAbsn: rOut.DrawPie(aRect,aEnde,aStrt); break; - } - } -} - -void BmapType::Draw(OutputDevice& rOut, UCHAR *) -{ - //ifstream aInp; - sal_uInt16 nVersion; - OUString aStr( - reinterpret_cast< char const * >(&Filename[ 1 ]), - (sal_Int32)Filename[ 0 ], RTL_TEXTENCODING_UTF8 ); - INetURLObject aFNam( aStr ); - - SvStream* pInp = ::utl::UcbStreamHelper::CreateStream( aFNam.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ); - if ( pInp ) - { - unsigned char nSgfTyp = CheckSgfTyp( *pInp,nVersion); - switch(nSgfTyp) { - case SGF_BITIMAGE: { - GraphicFilter aFlt; - Graphic aGrf; - aFlt.ImportGraphic(aGrf,aFNam); - aGrf.Draw(&rOut,Point(Pos1.x,Pos1.y),Size(Pos2.x-Pos1.x,Pos2.y-Pos1.y)); - } break; - case SGF_SIMPVECT: { - GDIMetaFile aMtf; - SgfVectXofs=Pos1.x; - SgfVectYofs=Pos1.y; - SgfVectXmul=Pos2.x-Pos1.x; - SgfVectYmul=Pos2.y-Pos1.y; - SgfVectXdiv=0; - SgfVectYdiv=0; - SgfVectScal=true; - SgfVectFilter(*pInp,aMtf); - SgfVectXofs=0; - SgfVectYofs=0; - SgfVectXmul=0; - SgfVectYmul=0; - SgfVectXdiv=0; - SgfVectYdiv=0; - SgfVectScal=false; - aMtf.Play(&rOut); - } break; - } - delete pInp; - } -} - -sal_uInt32 GrupType::GetSubPtr() -{ - return sal_uInt32(SbLo)+0x00010000*sal_uInt32(SbHi); -} - -void DrawObjkList( SvStream& rInp, OutputDevice& rOut ) -{ - ObjkType aObjk; - sal_uInt16 nGrpCnt=0; - bool bEnd=false; - do { - ReadObjkType( rInp, aObjk ); - if (!rInp.GetError()) { - switch(aObjk.Art) { - case ObjStrk: { StrkType aStrk; ReadStrkType( rInp, aStrk ); if (!rInp.GetError()) aStrk.Draw(rOut, nullptr); } break; - case ObjRect: { RectType aRect; ReadRectType( rInp, aRect ); if (!rInp.GetError()) aRect.Draw(rOut, nullptr); } break; - case ObjCirc: { CircType aCirc; ReadCircType( rInp, aCirc ); if (!rInp.GetError()) aCirc.Draw(rOut, nullptr); } break; - case ObjText: { - TextType aText; - ReadTextType( rInp, aText ); - if (!rInp.GetError()) { - const size_t nRemainingSize = rInp.remainingSize(); - size_t nSize = aText.BufSize; - if (nSize > nRemainingSize) - { - SAL_WARN("vcl", "file is shorter than requested len"); - nSize = nRemainingSize; - } - std::vector<UCHAR> aBuffer(nSize+1); // add one for LookAhead at CK-separation - size_t nReadSize = rInp.ReadBytes(aBuffer.data(), nSize); - aBuffer[nReadSize] = 0; - if (!rInp.GetError() && nReadSize == aText.BufSize) - aText.Draw(rOut, aBuffer.data()); - } - } break; - case ObjBmap: { - BmapType aBmap; - ReadBmapType( rInp, aBmap ); - if (!rInp.GetError()) { - aBmap.Draw(rOut, nullptr); - } - } break; - case ObjPoly: { - PolyType aPoly; - ReadPolyType( rInp, aPoly ); - if (!rInp.GetError()) { - aPoly.EckP=new PointType[aPoly.nPoints]; - for (int i = 0; i < aPoly.nPoints; ++i) - { - rInp.ReadInt16(aPoly.EckP[i].x); - rInp.ReadInt16(aPoly.EckP[i].y); - } - if (!rInp.GetError()) aPoly.Draw(rOut, nullptr); - delete[] aPoly.EckP; - } - } break; - case ObjSpln: { - SplnType aSpln; - ReadSplnType( rInp, aSpln ); - if (!rInp.GetError()) { - aSpln.EckP=new PointType[aSpln.nPoints]; - for (int i = 0; i < aSpln.nPoints; ++i) - { - rInp.ReadInt16(aSpln.EckP[i].x); - rInp.ReadInt16(aSpln.EckP[i].y); - } - if (!rInp.GetError()) aSpln.Draw(rOut, nullptr); - delete[] aSpln.EckP; - } - } break; - case ObjGrup: { - GrupType aGrup; - ReadGrupType( rInp, aGrup ); - if (!rInp.GetError()) { - rInp.Seek(rInp.Tell()+aGrup.Last); // object appendix - if(aGrup.GetSubPtr()!=0) nGrpCnt++; // DrawObjkList(rInp,rOut ); - } - } break; - default: { - aObjk.Draw(rOut, nullptr); // object name on 2. Screen - ObjkOverSeek(rInp,aObjk); // to next object - } - } - } // if rInp - if (!rInp.GetError()) { - if (aObjk.Next==0) { - if (nGrpCnt==0) bEnd=true; - else nGrpCnt--; - } - } else { - bEnd=true; // read error - } - } while (!bEnd); -} - -void SkipObjkList(SvStream& rInp) -{ - ObjkType aObjk; - do - { - ReadObjkType( rInp, aObjk ); - if(aObjk.Art==ObjGrup) { - GrupType aGrup; - ReadGrupType( rInp, aGrup ); - rInp.Seek(rInp.Tell()+aGrup.Last); // object appendix - if(aGrup.GetSubPtr()!=0) SkipObjkList(rInp); - } else { - ObjkOverSeek(rInp,aObjk); // to next object - } - } while (aObjk.Next!=0 && !rInp.GetError()); -} - -bool SgfFilterSDrw( SvStream& rInp, GDIMetaFile& rMtf ) -{ - bool bRet = false; - PageType aPage; - ScopedVclPtrInstance< VirtualDevice > aOutDev; - OutputDevice* pOutDev; - sal_uLong nStdPos; - sal_uLong nCharPos; - sal_uInt16 Num; - - pOutDev=aOutDev.get(); - DtHdOverSeek(rInp); // read dataheader - - nStdPos=rInp.Tell(); - do { // read standard page - ReadPageType( rInp, aPage ); - if (aPage.nList!=0) SkipObjkList(rInp); - } while (aPage.Next!=0 && !rInp.GetError()); - - nCharPos=rInp.Tell(); - ReadPageType( rInp, aPage ); - - rMtf.Record(pOutDev); - Num=aPage.StdPg; - if (Num!=0) { - rInp.Seek(nStdPos); - while(Num>1 && aPage.Next!=0 && !rInp.GetError()) { // search standard page - ReadPageType( rInp, aPage ); - if (aPage.nList!=0) SkipObjkList(rInp); - Num--; - } - ReadPageType( rInp, aPage ); - if(Num==1 && aPage.nList!=0) DrawObjkList( rInp,*pOutDev ); - rInp.Seek(nCharPos); - ReadPageType( rInp, aPage ); - } - if (aPage.nList!=0) DrawObjkList(rInp,*pOutDev ); - - rMtf.Stop(); - rMtf.WindStart(); - MapMode aMap(MapUnit::Map10thMM,Point(),Fraction(1,4),Fraction(1,4)); - rMtf.SetPrefMapMode(aMap); - rMtf.SetPrefSize(Size(aPage.Paper.Size.x, aPage.Paper.Size.y)); - bRet=true; - return bRet; -} - -bool SgfSDrwFilter(SvStream& rInp, GDIMetaFile& rMtf, const INetURLObject& _aIniPath ) -{ - sal_uLong nFileStart; // offset of SgfHeaders. In general 0. - SgfHeader aHead; - SgfEntry aEntr; - sal_uLong nNext; - bool bRet=false; // return value - - INetURLObject aIniPath = _aIniPath; - aIniPath.Append("sgf.ini"); - - pSgfFonts = new SgfFontLst; - - pSgfFonts->AssignFN( aIniPath.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); - nFileStart=rInp.Tell(); - ReadSgfHeader( rInp, aHead ); - if (aHead.ChkMagic() && aHead.Typ==SgfStarDraw && aHead.Version==SGV_VERSION) { - nNext=aHead.GetOffset(); - while (nNext && !rInp.GetError()) { - rInp.Seek(nFileStart+nNext); - ReadSgfEntry( rInp, aEntr ); - nNext=aEntr.GetOffset(); - if (aEntr.Typ==aHead.Typ) { - bRet=SgfFilterSDrw( rInp,rMtf ); - } - } // while(nNext) - } - delete pSgfFonts; - return bRet; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/filter/sgvmain.hxx b/vcl/source/filter/sgvmain.hxx deleted file mode 100644 index 398674f7f814..000000000000 --- a/vcl/source/filter/sgvmain.hxx +++ /dev/null @@ -1,363 +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_SOURCE_FILTER_SGVMAIN_HXX -#define INCLUDED_VCL_SOURCE_FILTER_SGVMAIN_HXX - -#include <vcl/font.hxx> -#include <vcl/outdev.hxx> -#include <vcl/virdev.hxx> - -#define UCHAR unsigned char - -struct PointType { - sal_Int16 x; - sal_Int16 y; - PointType() - : x(0) - , y(0) - { - } -}; - -#define SgfDpmm 40 - -#define DtHdSize 256 -class DtHdType { -public: - sal_uInt8 Reserved[256]; - friend void DtHdOverSeek(SvStream& rInp); -}; - -struct Seitenformat { - PointType Size; // 0.00mm...819.175mm (papersize) - sal_Int16 RandL; // left border on - sal_Int16 RandR; // right paper - sal_Int16 RandO; // upper border on - sal_Int16 RandU; // lower paper - sal_uInt8 PColor; // future use - sal_uInt8 PIntens; // future use -}; - -#define PageSize 146 -class PageType { -public: - sal_uInt32 Next; // next page - sal_uInt32 nList; // objectdata, first record - sal_uInt32 ListEnd; // objectdata, last record - Seitenformat Paper; // data of paper - bool BorderClip; // clip objects at border (cheat due to alignment in NT) - sal_uInt8 StdPg; // insert which standardpage ? - PointType U; // origin - sal_Int16 HlpLnH[20]; // guides - sal_Int16 HlpLnV[20]; - sal_uInt8 LnAnzH; - sal_uInt8 LnAnzV; - UCHAR PgName[32]; // page name - friend SvStream& ReadPageType(SvStream& rIStream, PageType& rPage); - PageType(); -}; - -enum ObjArtType {ObjStrk,ObjRect,ObjPoly,ObjCirc,ObjSpln, - ObjText,ObjGrup,ObjBmap,ObjVirt,ObjTxtX,ObjMaxi}; - -struct ObjLineType { - sal_uInt8 LFarbe; // [Index] - sal_uInt8 LBFarbe; // [Index] - sal_uInt8 LIntens; // [%] - sal_uInt8 LMuster; // [Index] including transparency - sal_Int16 LMSize; // [coefficient/100] - sal_Int16 LDicke; // line thickness -}; - -struct ObjAreaType { - sal_uInt8 FFarbe; // [Index] - sal_uInt8 FBFarbe; // [Index] - sal_uInt8 FIntens; // [%] - // Despite the "Dummy" in the name, and not being used anywhere in - // the code, these two fields are *essential*. These structs are - // 1:1 mappings of actual on-disk/wire file format structures... - // So don't clean the "unused dummy" fields away. (Actually it - // might well be that many other fields around here are never used - // in our code either.) - sal_uInt8 FDummy1; - sal_Int16 FDummy2; - sal_uInt16 FMuster; // [Index] incl. Invers, transparency - - ObjAreaType() - : FFarbe(0) - , FBFarbe(0) - , FIntens(0) - , FDummy1(0) - , FDummy2(0) - , FMuster(0) - { - } -}; - -#define ObjTextTypeSize 64 -class ObjTextType { -public: - ObjLineType L; // text outline (future) - ObjAreaType F; // inner text - sal_uInt16 FontLo,FontHi; // e.g. 92500 (CG Times), split due to DWord-Align in TextType. - sal_uInt16 Grad; // 0.5..32767.5 pt - we should stop at 1000 pt - sal_uInt16 Breite; // 1..65535% please not more as 500% - sal_uInt8 Justify; // 2 bit vertical (Hi), 3 bit horizontal (Lo) - sal_uInt8 Kapit; // 1..255% - sal_uInt16 Schnitt; // 8 flags - sal_uInt16 LnFeed; // 1..32767% of max font size of the line - sal_uInt16 Slant; // slant angle 0.00..89.99deg default 15.00deg - sal_uInt8 ZAbst; // character spacing 0..255% (0=on the line; 100=normal; 200=character is viewed as double width) - signed char ChrVPos; // vertical position of char. Default 0=on baseline, 10=5Pt below (-64..63") - ObjLineType ShdL; // shadow outline (new 2.0) - ObjAreaType ShdF; // shadow inside (new 2.0) - PointType ShdVers; // shadow offset max. 300.00% - bool ShdAbs; // True-> shadow offset is absolute instead of relative to font size - bool NoSpc; // True-> no space (for background area) - ObjAreaType BackF; // background area - sal_uInt32 GetFont(); - void SetFont(sal_uInt32 FontID); -}; - -#define ObjkSize 20 /* should be 21. due to alignment we shifted the flag */ -class ObjkType { // basic components of all Stardraw objects -public: - sal_uInt32 Last; - sal_uInt32 Next; - sal_uInt16 MemSize; // in bytes - PointType ObjMin; // XY minimum of the object - PointType ObjMax; // XY maximum of the object - sal_uInt8 Art; - sal_uInt8 Layer; - ObjkType() - : Last(0) - , Next(0) - , MemSize(0) - , Art(0) - , Layer(0) - { - } - virtual ~ObjkType() {} - virtual void Draw(OutputDevice& rOut, UCHAR *pBuffer); -}; - -#define StrkSize 38 -class StrkType: public ObjkType { -public: - sal_uInt8 Flags; // (cheat due to alignment in NT) - sal_uInt8 LEnden; // line ends - ObjLineType L; - PointType Pos1; // start point - PointType Pos2; // end point - friend SvStream& ReadStrkType(SvStream& rIStream, StrkType& rStrk); - virtual void Draw(OutputDevice& rOut, UCHAR *pBuffer) override; -}; - -#define RectSize 52 -class RectType: public ObjkType { -public: - sal_uInt8 Flags; // (cheat due to alignment in NT) - sal_uInt8 Reserve; - ObjLineType L; - ObjAreaType F; - PointType Pos1; // lower left corner = reference point - PointType Pos2; // right corner - sal_Int16 Radius; // radius of corner - sal_uInt16 RotationAngle; // 315...<45 - sal_uInt16 Slant; // >270...<90 - friend SvStream& ReadRectType(SvStream& rIStream, RectType& rRect); - virtual void Draw(OutputDevice& rOut, UCHAR *pBuffer) override; -}; - -#define PolySize 44 -class PolyType: public ObjkType { // identical to spline ! -public: - sal_uInt8 Flags; // (cheat due to alignment in NT) - sal_uInt8 LEnden; // only for polyline - ObjLineType L; - ObjAreaType F; // not for polyline - sal_uInt8 nPoints; - sal_uInt8 Reserve; - sal_uInt32 SD_EckP; // pointer to corner point (StarDraw) - PointType* EckP; // pointer to corner points (StarView (is not read from disk!)) - friend SvStream& ReadPolyType(SvStream& rIStream, PolyType& rPoly); - virtual void Draw(OutputDevice& rOut, UCHAR *pBuffer) override; -}; -#define PolyClosBit 0x01 // kinds of Poly: 0: polyLine 1: polygon - -#define SplnSize 44 -class SplnType: public ObjkType { // identical to Poly ! -public: - sal_uInt8 Flags; // (cheat due to alignment in NT) - sal_uInt8 LEnden; // only for nSpline - ObjLineType L; - ObjAreaType F; // not for nSpline - sal_uInt8 nPoints; - sal_uInt8 Reserve; - sal_uInt32 SD_EckP; // pointer to corner points (StarDraw) - PointType* EckP; // pointer to corner points (StarView (is not read from disk!)) - friend SvStream& ReadSplnType(SvStream& rIStream, SplnType& rSpln); - virtual void Draw(OutputDevice& rOut, UCHAR *pBuffer) override; -}; -// kinds of Spline: see Poly - -#define CircSize 52 -class CircType: public ObjkType { -public: - sal_uInt8 Flags; // (cheat due to alignment in NT) - sal_uInt8 LEnden; // only arcs (circle & ellips) - ObjLineType L; - ObjAreaType F; // not for arcs (circle & ellips) - PointType Center; // center - PointType Radius; // radius - sal_uInt16 RotationAngle; // only ellipses - sal_uInt16 StartAngle; // and not for full circles - sal_uInt16 RelAngle; // and full ellipses - friend SvStream& ReadCircType(SvStream& rIStream, CircType& rCirc); - virtual void Draw(OutputDevice& rOut, UCHAR *pBuffer) override; -}; -#define CircFull 0x00 /* kinds of circle: 0: full circle */ -#define CircSect 0x01 /* 1: circle sector */ -#define CircAbsn 0x02 /* 2: circle segment */ -#define CircArc 0x03 /* 3: circle arc */ - -#define TextSize 116 -class TextType: public ObjkType { -public: - sal_uInt8 Flags; // (cheat due to alignment in NT) - sal_uInt8 Reserve; // for Word Align - ObjTextType T; // 64 bytes << DWord-Align needed for FontID - PointType Pos1; // reference point (upper left) - PointType Pos2; // (lower right) - sal_Int16 TopOfs; // from upper side to start of text (future for vJustify) - sal_uInt16 RotationAngle; // 0...<360 - sal_uInt16 BoxSlant; // >270...<90 (only Box) - sal_uInt16 BufSize; // size of buffer for Load, Save, Copy etc. - sal_uInt16 BufLo,BufHi; // (UCHAR*) pointer to Textbuffer << ShortArr, otherwise DWord-Align needed - sal_uInt16 ExtLo,ExtHi; // (Ptr) text over more frames << ShortArr, otherwise DWord-Align needed - PointType FitSize; // size of origin for Fit2Size - sal_Int16 FitBreit; // width to format for Fit2Size - friend SvStream& ReadTextType(SvStream& rIStream, TextType& rText); - virtual void Draw(OutputDevice& rOut, UCHAR *pBuffer) override; -}; -#define TextOutlBit 0x01 /* 1=Sourcecode for outliner (ignored byDrawObject()) */ -#define TextFitSBit 0x02 /* Bit1: 1=Text-Fit2Size, also outliner (2.0) */ -#define TextFitZBit 0x08 /* Bit3: 1=Fit2Size line by line (2.0) */ -#define TextFitBits (TextFitSBit | TextFitZBit) - -enum GrafStat {NoGraf,Pic,Pcx,Hpgl,Img,Msp,Tiff,Dxf,Lot,Usr,Sgf}; - -#define BmapSize 132 -class BmapType: public ObjkType { -public: - sal_uInt8 Flags; // (cheat due to alignment in NT) - sal_uInt8 Reserve; - ObjAreaType F; // colour and pattern of first plane bitmap - PointType Pos1; - PointType Pos2; - sal_uInt16 RotationAngle;// 315...<45 (future) - sal_uInt16 Slant; // >270...<90 (future) - UCHAR Filename[80]; // path - PointType PixSize; // size in Pixel (0 for vector) - GrafStat Format; // see: GpmDef.Pas - sal_uInt8 nPlanes; // number of bitplanes (0 for vector) - bool RawOut; // output as raw ? - bool InvOut; // output inverted ? - bool LightOut; // brighten? (SD20) - sal_uInt8 GrfFlg; // (SD20) 0=nSGF 1=Pcx 2=HPGL 4=Raw $FF=Undef (to fix DrawBmp) - - BmapType() - : Flags(0) - , Reserve(0) - , RotationAngle(0) - , Slant(0) - , Format(NoGraf) - , nPlanes(0) - , RawOut(false) - , InvOut(false) - , LightOut(false) - , GrfFlg(0) - { - memset(Filename, 0, sizeof(Filename)); - } - - friend SvStream& ReadBmapType(SvStream& rIStream, BmapType& rBmap); - virtual void Draw(OutputDevice& rOut, UCHAR *pBuffer) override; -}; - -#define GrupSize 48 -class GrupType: public ObjkType { -public: - sal_uInt8 Flags; // (cheat due to alignment in NT) - UCHAR Name[13]; // name of group - sal_uInt16 SbLo,SbHi; // (Ptr) group list << ShortArr, as otherwise DWord alignment needed - sal_uInt16 UpLo,UpHi; // (Ptr) parent list << ShortArr, as otherwise DWord alignment needed - sal_uInt16 ChartSize; // required amount of memory for structure of diagram structure - sal_uInt32 ChartPtr; // diagram structure - sal_uInt32 GetSubPtr(); // only to check if Sublist is empty - friend SvStream& ReadGrupType(SvStream& rIStream, GrupType& rGrup); -}; - -void SetLine(ObjLineType& rLine, OutputDevice& rOut); -void SetArea(ObjAreaType& rArea, OutputDevice& rOut); -Color Sgv2SvFarbe(sal_uInt8 nFrb1, sal_uInt8 nFrb2, sal_uInt8 nInts); -void RotatePoint(PointType& P, sal_Int16 cx, sal_Int16 cy, double sn, double cs); -void RotatePoint(Point& P, sal_Int16 cx, sal_Int16 cy, double sn, double cs); -sal_Int16 iMulDiv(sal_Int16 a, sal_Int16 Mul, sal_Int16 Div); -sal_uInt16 MulDiv(sal_uInt16 a, sal_uInt16 Mul, sal_uInt16 Div); - -class SgfFontOne { -public: - SgfFontOne* Next; // pointer to list - sal_uInt32 IFID; - bool Bold; - bool Ital; - bool Sans; - bool Serf; - bool Fixd; - FontFamily SVFamil; - rtl_TextEncoding SVChSet; - OUString SVFName; // e.g. "Times New Roman" = 15 chars - sal_uInt16 SVWidth; // average character width in % - SgfFontOne(); - void ReadOne(const OString& rID, OString& rDsc); -}; - -class SgfFontLst { -public: - OUString FNam; // complete filename of the Ini-file - SgfFontOne* pList; // start of list - SgfFontOne* Last; // end of list - sal_uInt32 LastID; // for faster access during repeats - SgfFontOne* LastLn; // for faster access during repeats - bool Tried; - SgfFontLst(); - ~SgfFontLst(); - void AssignFN(const OUString& rFName); - void ReadList(); - void RausList(); - SgfFontOne* GetFontDesc(sal_uInt32 ID); -}; - -extern SgfFontLst* pSgfFonts; - -#endif // INCLUDED_VCL_SOURCE_FILTER_SGVMAIN_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/filter/sgvspln.cxx b/vcl/source/filter/sgvspln.cxx deleted file mode 100644 index 6efc9ce9d02d..000000000000 --- a/vcl/source/filter/sgvspln.cxx +++ /dev/null @@ -1,743 +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 . - */ - -#include <tools/poly.hxx> -#include <memory> -#include <rtl/math.hxx> - -#include "sgvspln.hxx" -#include <cmath> - -#include <android/compatibility.hxx> - -extern "C" { - -/*.pn 277 */ -/*.hlAppendix: C - programs*/ -/*.hrConstants- and macrodefinitions*/ -/*.fe The include file u_const.h should be stored in the directory, */ -/*.fe where the compiler searches for include files. */ - -/*----------------------- FILE u_const.h ---------------------------*/ - -#define IEEE - -/* IEEE - standard for representation of floating-point numbers: - - 8 byte long floating point numbers with - - 53 bit mantissa ==> mantissa range: 2^52 different numbers - with 0.1 <= number < 1.0, - 1 sign-bit - 11 bit exponent ==> exponent range: -1024...+1023 - - The first line (#define IEEE) should be deleted if the machine - or the compiler does not use floating-point numbers according - to the IEEE standard. In which case also MAXEXPON, MINEXPON (see - below) should be adapted. -*/ - -#ifdef IEEE /*-------------- if IEEE norm --------------------*/ - -#define MACH_EPS 2.220446049250313e-016 /* machine precision */ - /* IBM-AT: = 2^-52 */ -/* MACH_EPS is the smallest positive, by the machine representable - number x, which fulfills the equation: 1.0 + x > 1.0 */ - -#define MAXROOT 9.48075190810918e+153 - -#else /*------------------ otherwise--------------------*/ - -double exp (double); -double atan (double); -double pow (double,double); -double sqrt (double); - -double masch() /* calculate MACH_EPS machine independence */ -{ - double eps = 1.0, x = 2.0, y = 1.0; - while ( y < x ) - { eps *= 0.5; - x = 1.0 + eps; - } - eps *= 2.0; - return eps; -} - -short basis() /* calculate BASE machine independence */ -{ - double x = 1.0, one = 1.0, b = 1.0; - - while ( (x + one) - x == one ) x *= 2.0; - while ( (x + b) == x ) b *= 2.0; - - return (short) ((x + b) - x); -} - -#define BASIS basis() /* base of number representation */ - -/* If the machine (the compiler) does not use the IEEE-representation - for floating-point numbers, the next 2 constants should be adapted. - */ - -#define MAXEXPON 1023.0 /* largest exponent */ -#define MINEXPON -1024.0 /* smallest exponent */ - -#define MACH_EPS masch() - -#define POSMAX pow ((double) BASIS, MAXEXPON) -#define MAXROOT sqrt(POSMAX) - -#endif /*-------------- END of ifdef --------------------*/ - -/*-------------------- END of FILE u_const.h -----------------------*/ - -/*.HL appendix: C - programs*/ -/*.HR Systems of equations for tridiagonal matrices*/ - -/*.FE P 3.7 tridiagonal systems of equations */ - -/*---------------------- MODULE tridiagonal -----------------------*/ - -sal_uInt16 TriDiagGS(sal_uInt16 n, double* lower, - double* diag, const double* upper, double* b) - /*************************/ - /* Gaussian methods for */ - /* tridiagonal matrices */ - /*************************/ - -/*====================================================================*/ -/* */ -/* trdiag determines solution x of the system of linear equations */ -/* A * x = b with tridiagonal n x n coefficient matrix A, which is */ -/* stored in 3 vectors lower, upper and diag as per below: */ -/* */ -/* ( diag[0] upper[0] 0 0 . . . 0 ) */ -/* ( lower[1] diag[1] upper[1] 0 . . . ) */ -/* ( 0 lower[2] diag[2] upper[2] 0 . ) */ -/* A = ( . 0 lower[3] . . . ) */ -/* ( . . . . . 0 ) */ -/* ( . . . . . ) */ -/* ( . . . upper[n-2] ) */ -/* ( 0 . . . 0 lower[n-1] diag[n-1] ) */ -/* */ -/*====================================================================*/ -/* */ -/* Usage: */ -/* ====== */ -/* Mainly for diagonal determinant triangular matrix, as they */ -/* occur in Spline-interpolations. */ -/* For diagonal dominant matrices always a left-upper row */ -/* reduction exists; for non diagonal dominant triangular */ -/* matrices we should pull forward the function band, as this */ -/* works with row pivot searches, which is numerical more stable.*/ -/* */ -/*====================================================================*/ -/* */ -/* Input parameters: */ -/* ================ */ -/* n dimension of the matrix ( > 1 ) sal_uInt16 n */ -/* */ -/* lower lower antidiagonal double lower[n] */ -/* diag main diagonal double diag[n] */ -/* upper upper antidiagonal double upper[n] */ -/* */ -/* for rep = true lower, diag and upper contain the */ -/* triangulation of the start matrix. */ -/* */ -/* b right side of equation double b[n] */ -/* rep = false first call bool rep */ -/* = true next call */ -/* for the same matrix, */ -/* but different b. */ -/* */ -/* Output parameters: */ -/* ================= */ -/* b solution vector of the system; double b[n] */ -/* the original right side is overwritten */ -/* */ -/* lower ) contain for rep = false the decomposition of the */ -/* diag ) matrix; the original values of the lower and */ -/* upper ) diagonals are overwritten */ -/* */ -/* The determinant of the matrix is for rep = false defined by */ -/* determinant A = diag[0] * ... * diag[n-1] */ -/* */ -/* Return value: */ -/* ============= */ -/* = 0 all ok */ -/* = 1 n < 2 chosen */ -/* = 2 triangular decomposition of matrix does not exist */ -/* */ -/*====================================================================*/ -/* */ -/* Functions used: */ -/* =============== */ -/* */ -/* From the C library: fabs() */ -/* */ -/*====================================================================*/ - -/*.cp 5 */ -{ - sal_uInt16 i; - short j; - -// double fabs(double); - - if ( n < 2 ) return 1; /* n at least 2 */ - - /* determine the */ - /* triangular */ - /* decomposition of */ - /* matrix and determinant*/ - { - for (i = 1; i < n; i++) - { if ( fabs(diag[i-1]) < MACH_EPS ) /* do not decompose */ - return 2; /* if one diag[i] = 0 */ - lower[i] /= diag[i-1]; - diag[i] -= lower[i] * upper[i-1]; - } - } - - if ( fabs(diag[n-1]) < MACH_EPS ) return 2; - - for (i = 1; i < n; i++) /* forward elimination */ - b[i] -= lower[i] * b[i-1]; - - b[n-1] /= diag[n-1]; /* reverse elimination */ - for (j = n-2; j >= 0; j--) { - i=j; - b[i] = ( b[i] - upper[i] * b[i+1] ) / diag[i]; - } - return 0; -} - -/*----------------------- END OF TRIDIAGONAL ------------------------*/ - -/*.HL Appendix: C - Programs*/ -/*.HRSystems of equations with cyclic tridiagonal matrices*/ - -/*.FE P 3.8 Systems with cyclic tridiagonal matrices */ - -/*---------------- Module cyclic tridiagonal -----------------------*/ - -sal_uInt16 ZyklTriDiagGS(sal_uInt16 n, double* lower, double* diag, - double* upper, double* lowrow, double* ricol, double* b) - /******************************/ - /* Systems with cyclic */ - /* tridiagonal matrices */ - /******************************/ - -/*====================================================================*/ -/* */ -/* tzdiag determines the solution x of the linear equation system */ -/* A * x = b with cyclic tridiagonal n x n coefficient- */ -/* matrix A, which is stored in the 5 vectors: lower, upper, diag, */ -/* lowrow and ricol as per below: */ -/* */ -/* ( diag[0] upper[0] 0 0 . . 0 ricol[0] ) */ -/* ( lower[1] diag[1] upper[1] 0 . . 0 ) */ -/* ( 0 lower[2] diag[2] upper[2] 0 . ) */ -/* A = ( . 0 lower[3] . . . . ) */ -/* ( . . . . . 0 ) */ -/* ( . . . . . ) */ -/* ( 0 . . . upper[n-2] ) */ -/* ( lowrow[0] 0 . . 0 lower[n-1] diag[n-1] ) */ -/* */ -/* Memory for lowrow[1],..,lowrow[n-3] and ricol[1],...,ricol[n-3] */ -/* should be provided separately, as this should be available to */ -/* store the decomposition matrix, which is overwriting */ -/* the 5 vectors mentioned. */ -/* */ -/*====================================================================*/ -/* */ -/* Usage: */ -/* ====== */ -/* Predominantly for diagonal dominant cyclic tridiagonal- */ -/* matrices as they occur in spline-interpolations. */ -/* For diagonal dominant matrices only a LU-decomposition exists.*/ -/* */ -/*====================================================================*/ -/* */ -/* Input parameters: */ -/* ================= */ -/* n Dimension of the matrix ( > 2 ) sal_uInt16 n */ -/* lower lower antidiagonal double lower[n] */ -/* diag main diagonal double diag[n] */ -/* upper upper antidiagonal double upper[n] */ -/* b right side of the system double b[n] */ -/* rep = FALSE first call bool rep */ -/* = TRUE repeated call */ -/* for equal matrix, */ -/* but different b. */ -/* */ -/* Output parameters: */ -/* ================== */ -/* b solution vector of the system, double b[n] */ -/* the original right side is overwritten */ -/* */ -/* lower ) contain for rep = false the solution of the matrix;*/ -/* diag ) the original values of lower and diagonal will be */ -/* upper ) overwritten */ -/* lowrow ) double lowrow[n-2] */ -/* ricol ) double ricol[n-2] */ -/* */ -/* The determinant of the matrix is for rep = false */ -/* det A = diag[0] * ... * diag[n-1] defined . */ -/* */ -/* Return value: */ -/* ============= */ -/* = 0 all ok */ -/* = 1 n < 3 chosen */ -/* = 2 Decomposition matrix does not exist */ -/* */ -/*====================================================================*/ -/* */ -/* Used functions: */ -/* =============== */ -/* */ -/* from the C library: fabs() */ -/* */ -/*====================================================================*/ - -/*.cp 5 */ -{ - double temp; // fabs(double); - sal_uInt16 i; - short j; - - if ( n < 3 ) return 1; - - { /* calculate decomposition */ - lower[0] = upper[n-1] = 0.0; /* of the matrix. */ - - if ( fabs (diag[0]) < MACH_EPS ) return 2; - /* Do not decompose if the */ - temp = 1.0 / diag[0]; /* value of a diagonal */ - upper[0] *= temp; /* element is smaller then */ - ricol[0] *= temp; /* MACH_EPS */ - - for (i = 1; i < n-2; i++) - { diag[i] -= lower[i] * upper[i-1]; - if ( fabs(diag[i]) < MACH_EPS ) return 2; - temp = 1.0 / diag[i]; - upper[i] *= temp; - ricol[i] = -lower[i] * ricol[i-1] * temp; - } - - diag[n-2] -= lower[n-2] * upper[n-3]; - if ( fabs(diag[n-2]) < MACH_EPS ) return 2; - - for (i = 1; i < n-2; i++) - lowrow[i] = -lowrow[i-1] * upper[i-1]; - - lower[n-1] -= lowrow[n-3] * upper[n-3]; - upper[n-2] = ( upper[n-2] - lower[n-2] * ricol[n-3] ) / diag[n-2]; - - for (temp = 0.0, i = 0; i < n-2; i++) - temp -= lowrow[i] * ricol[i]; - diag[n-1] += temp - lower[n-1] * upper[n-2]; - - if ( fabs(diag[n-1]) < MACH_EPS ) return 2; - } - - b[0] /= diag[0]; /* forward elimination */ - for (i = 1; i < n-1; i++) - b[i] = ( b[i] - b[i-1] * lower[i] ) / diag[i]; - - for (temp = 0.0, i = 0; i < n-2; i++) - temp -= lowrow[i] * b[i]; - - b[n-1] = ( b[n-1] + temp - lower[n-1] * b[n-2] ) / diag[n-1]; - - b[n-2] -= b[n-1] * upper[n-2]; /* backward elimination */ - for (j = n-3; j >= 0; j--) { - i=j; - b[i] -= upper[i] * b[i+1] + ricol[i] * b[n-1]; - } - return 0; -} - -/*------------------ END of CYCLIC TRIDIAGONAL ---------------------*/ - -} // extern "C" - -// Calculates the coefficients of natural cubic splines with n intervals. -sal_uInt16 NaturalSpline(sal_uInt16 n, const double* x, const double* y, - double Marg0, double MargN, - sal_uInt8 MargCond, - double* b, double* c, double* d) -{ - sal_uInt16 i; - std::unique_ptr<double[]> a; - std::unique_ptr<double[]> h; - sal_uInt16 error; - - if (n<2) return 1; - if ( MargCond & ~3 ) return 2; - a.reset(new double[n+1]); - h.reset(new double[n+1]); - for (i=0;i<n;i++) { - h[i]=x[i+1]-x[i]; - if (h[i]<=0.0) return 1; - } - for (i=0;i<n-1;i++) { - a[i]=3.0*((y[i+2]-y[i+1])/h[i+1]-(y[i+1]-y[i])/h[i]); - b[i]=h[i]; - c[i]=h[i+1]; - d[i]=2.0*(h[i]+h[i+1]); - } - switch (MargCond) { - case 0: { - if (n==2) { - a[0]=a[0]/3.0; - d[0]=d[0]*0.5; - } else { - a[0] =a[0]*h[1]/(h[0]+h[1]); - a[n-2]=a[n-2]*h[n-2]/(h[n-1]+h[n-2]); - d[0] =d[0]-h[0]; - d[n-2]=d[n-2]-h[n-1]; - c[0] =c[0]-h[0]; - b[n-2]=b[n-2]-h[n-1]; - } - SAL_FALLTHROUGH; - } - case 1: { - a[0] =a[0]-1.5*((y[1]-y[0])/h[0]-Marg0); - a[n-2]=a[n-2]-1.5*(MargN-(y[n]-y[n-1])/h[n-1]); - d[0] =d[0]-h[0]*0.5; - d[n-2]=d[n-2]-h[n-1]*0.5; - SAL_FALLTHROUGH; - } - case 2: { - a[0] =a[0]-h[0]*Marg0*0.5; - a[n-2]=a[n-2]-h[n-1]*MargN*0.5; - SAL_FALLTHROUGH; - } - case 3: { - a[0] =a[0]+Marg0*h[0]*h[0]*0.5; - a[n-2]=a[n-2]-MargN*h[n-1]*h[n-1]*0.5; - d[0] =d[0]+h[0]; - d[n-2]=d[n-2]+h[n-1]; - } - } // switch MargCond - if (n==2) { - c[1]=a[0]/d[0]; - } else { - error=TriDiagGS(n-1,b,d,c,a.get()); - if (error!=0) return error+2; - for (i=0;i<n-1;i++) c[i+1]=a[i]; - } - switch (MargCond) { - case 0: { - if (n==2) { - c[2]=c[1]; - c[0]=c[1]; - } else { - c[0]=c[1]+h[0]*(c[1]-c[2])/h[1]; - c[n]=c[n-1]+h[n-1]*(c[n-1]-c[n-2])/h[n-2]; - } - SAL_FALLTHROUGH; - } - case 1: { - c[0]=1.5*((y[1]-y[0])/h[0]-Marg0); - c[0]=(c[0]-c[1]*h[0]*0.5)/h[0]; - c[n]=1.5*((y[n]-y[n-1])/h[n-1]-MargN); - c[n]=(c[n]-c[n-1]*h[n-1]*0.5)/h[n-1]; - SAL_FALLTHROUGH; - } - case 2: { - c[0]=Marg0*0.5; - c[n]=MargN*0.5; - SAL_FALLTHROUGH; - } - case 3: { - c[0]=c[1]-Marg0*h[0]*0.5; - c[n]=c[n-1]+MargN*h[n-1]*0.5; - } - } // switch MargCond - for (i=0;i<n;i++) { - b[i]=(y[i+1]-y[i])/h[i]-h[i]*(c[i+1]+2.0*c[i])/3.0; - d[i]=(c[i+1]-c[i])/(3.0*h[i]); - } - return 0; -} - -// calculates the coefficients of periodical cubic splines with n intervals. -sal_uInt16 PeriodicSpline(sal_uInt16 n, const double* x, double* y, - double* b, double* c, double* d) -{ // array dimensions should range from [0..n]! - sal_uInt16 Error; - sal_uInt16 i,im1,nm1; //integer - double hl; - std::unique_ptr<double[]> a; - std::unique_ptr<double[]> lowrow; - std::unique_ptr<double[]> ricol; - - if (n<2) return 4; - nm1=n-1; - for (i=0;i<=nm1;i++) if (x[i+1]<=x[i]) return 2; // should be strictly monotonically decreasing! - if (!rtl::math::approxEqual(y[n],y[0])) return 3; // begin and end should be equal! - - a.reset(new double[n+1]); - lowrow.reset(new double[n+1]); - ricol.reset(new double[n+1]); - - if (n==2) { - c[1]=3.0*((y[2]-y[1])/(x[2]-x[1])); - c[1]=c[1]-3.0*((y[i]-y[0])/(x[1]-x[0])); - c[1]=c[1]/(x[2]-x[0]); - c[2]=-c[1]; - } else { - double hr; - for (i=1;i<=nm1;i++) { - im1=i-1; - hl=x[i]-x[im1]; - hr=x[i+1]-x[i]; - b[im1]=hl; - d[im1]=2.0*(hl+hr); - c[im1]=hr; - a[im1]=3.0*((y[i+1]-y[i])/hr-(y[i]-y[im1])/hl); - } - hl=x[n]-x[nm1]; - hr=x[1]-x[0]; - b[nm1]=hl; - d[nm1]=2.0*(hl+hr); - lowrow[0]=hr; - ricol[0]=hr; - a[nm1]=3.0*((y[1]-y[0])/hr-(y[n]-y[nm1])/hl); - Error=ZyklTriDiagGS(n,b,d,c,lowrow.get(),ricol.get(),a.get()); - if ( Error != 0 ) - { - return Error+4; - } - for (i=0;i<=nm1;i++) c[i+1]=a[i]; - } - c[0]=c[n]; - for (i=0;i<=nm1;i++) { - hl=x[i+1]-x[i]; - b[i]=(y[i+1]-y[i])/hl; - b[i]=b[i]-hl*(c[i+1]+2.0*c[i])/3.0; - d[i]=(c[i+1]-c[i])/hl/3.0; - } - return 0; -} - -// calculate the coefficients of parametric natural of periodical cubic splines -// with n intervals -sal_uInt16 ParaSpline(sal_uInt16 n, double* x, double* y, sal_uInt8 MargCond, - double Marg01, double Marg02, - double MargN1, double MargN2, - double* T, - double* bx, double* cx, double* dx, - double* by, double* cy, double* dy) -{ - sal_uInt16 Error; - sal_uInt16 i; - double alphX = 0,alphY = 0, - betX = 0,betY = 0; - - if (n<2) return 1; - if ((MargCond & ~3) && (MargCond != 4)) return 2; // invalid boundary condition - T[0]=0.0; - for (i=0;i<n;i++) { - double deltX,deltY,delt; - deltX=x[i+1]-x[i]; deltY=y[i+1]-y[i]; - delt =deltX*deltX+deltY*deltY; - if (delt<=0.0) return 3; // two identical adjacent points! - T[i+1]=T[i]+sqrt(delt); - } - switch (MargCond) { - case 0: break; - case 1: case 2: { - alphX=Marg01; betX=MargN1; - alphY=Marg02; betY=MargN2; - } break; - case 3: { - if (!rtl::math::approxEqual(x[n],x[0])) return 3; - if (!rtl::math::approxEqual(y[n],y[0])) return 4; - } break; - case 4: { - if (std::abs(Marg01)>=MAXROOT) { - alphX=0.0; - alphY=std::copysign(1.0,y[1]-y[0]); - } else { - alphX=std::copysign(sqrt(1.0/(1.0+Marg01*Marg01)),x[1]-x[0]); - alphY=alphX*Marg01; - } - if (std::abs(MargN1)>=MAXROOT) { - betX=0.0; - betY=std::copysign(1.0,y[n]-y[n-1]); - } else { - betX=std::copysign(sqrt(1.0/(1.0+MargN1*MargN1)),x[n]-x[n-1]); - betY=betX*MargN1; - } - } - } // switch MargCond - if (MargCond==3) { - Error=PeriodicSpline(n,T,x,bx,cx,dx); - if (Error!=0) return Error+4; - Error=PeriodicSpline(n,T,y,by,cy,dy); - if (Error!=0) return Error+10; - } else { - Error=NaturalSpline(n,T,x,alphX,betX,MargCond,bx,cx,dx); - if (Error!=0) return Error+4; - Error=NaturalSpline(n,T,y,alphY,betY,MargCond,by,cy,dy); - if (Error!=0) return Error+9; - } - return 0; -} - -bool CalcSpline(tools::Polygon const & rPoly, bool Periodic, sal_uInt16& n, - double*& ax, double*& ay, double*& bx, double*& by, - double*& cx, double*& cy, double*& dx, double*& dy, double*& T) -{ - sal_uInt8 Marg; - double Marg01; - double MargN1,MargN2; - sal_uInt16 i; - Point P0(-32768,-32768); - Point Pt; - - n=rPoly.GetSize(); - ax=new double[rPoly.GetSize()+2]; - ay=new double[rPoly.GetSize()+2]; - - n=0; - for (i=0;i<rPoly.GetSize();i++) { - Pt=rPoly.GetPoint(i); - if (i==0 || Pt!=P0) { - ax[n]=Pt.X(); - ay[n]=Pt.Y(); - n++; - P0=Pt; - } - } - - if (Periodic) { - Marg=3; - ax[n]=ax[0]; - ay[n]=ay[0]; - n++; - } else { - Marg=2; - } - - bx=new double[n+1]; - by=new double[n+1]; - cx=new double[n+1]; - cy=new double[n+1]; - dx=new double[n+1]; - dy=new double[n+1]; - T =new double[n+1]; - - Marg01=0.0; - MargN1=0.0; - MargN2=0.0; - if (n>0) n--; // correct n (number of partial polynoms) - - bool bRet = false; - if ( ( Marg == 3 && n >= 3 ) || ( Marg == 2 && n >= 2 ) ) - { - bRet = ParaSpline(n,ax,ay,Marg,Marg01,Marg01,MargN1,MargN2,T,bx,cx,dx,by,cy,dy) == 0; - } - if ( !bRet ) - { - delete[] ax; - delete[] ay; - delete[] bx; - delete[] by; - delete[] cx; - delete[] cy; - delete[] dx; - delete[] dy; - delete[] T; - n=0; - } - return bRet; -} - -bool Spline2Poly(tools::Polygon const & rSpln, bool Periodic, tools::Polygon& rPoly) -{ - const short MinKoord = -32000; // to prevent - const short MaxKoord = 32000; // overflows - - double* ax; // coefficients of the polynoms - double* ay; - double* bx; - double* by; - double* cx; - double* cy; - double* dx; - double* dy; - double* tv; - - sal_uInt16 n; // number of partial polynoms to draw - sal_uInt16 i; // actual partial polynom - bool bOk; // all still ok? - const sal_uInt16 PolyMax=16380; // max number of polygon points - - bOk=CalcSpline(rSpln,Periodic,n,ax,ay,bx,by,cx,cy,dx,dy,tv); - if (bOk) { - const double Step = 10; // stepsize for t - - rPoly.SetSize(1); - rPoly.SetPoint(Point(short(ax[0]),short(ay[0])),0); // first point - i=0; - while (i<n) { // draw n partial polynoms - double t=tv[i]+Step; - bool bEnd=false; // partial polynom ended? - while (!bEnd) { // extrapolate one partial polynom - double dt1,dt2,dt3; // delta t, y, ^3 - bEnd=t>=tv[i+1]; - if (bEnd) t=tv[i+1]; - dt1=t-tv[i]; dt2=dt1*dt1; dt3=dt2*dt1; - long x=long(ax[i]+bx[i]*dt1+cx[i]*dt2+dx[i]*dt3); - long y=long(ay[i]+by[i]*dt1+cy[i]*dt2+dy[i]*dt3); - if (x<MinKoord) x=MinKoord; - if (x>MaxKoord) x=MaxKoord; - if (y<MinKoord) y=MinKoord; - if (y>MaxKoord) y=MaxKoord; - if (rPoly.GetSize()<PolyMax) { - rPoly.SetSize(rPoly.GetSize()+1); - rPoly.SetPoint(Point(short(x),short(y)),rPoly.GetSize()-1); - } else { - bOk=false; // error: polygon becomes to large - } - t=t+Step; - } // end of partial polynom - i++; // next partial polynom - } - delete[] ax; - delete[] ay; - delete[] bx; - delete[] by; - delete[] cx; - delete[] cy; - delete[] dx; - delete[] dy; - delete[] tv; - return bOk; - } // end of if (bOk) - rPoly.SetSize(0); - return false; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/filter/sgvspln.hxx b/vcl/source/filter/sgvspln.hxx deleted file mode 100644 index 6f4543292478..000000000000 --- a/vcl/source/filter/sgvspln.hxx +++ /dev/null @@ -1,46 +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_SOURCE_FILTER_SGVSPLN_HXX -#define INCLUDED_VCL_SOURCE_FILTER_SGVSPLN_HXX - -/* - * Calculates the coefficients of parametrised natural or periodic cubic - * polynom-splines. The corner points of the polygon passed are used as - * support points. n returns the number of partial polynoms. This function - * returns TRUE if no error occurred. Only in this case memory for the - * coefficient array has been allocated, which can be freed by the caller - * using a delete. - */ -bool CalcSpline(tools::Polygon const & rPoly, bool Periodic, sal_uInt16& n, - double*& ax, double*& ay, double*& bx, double*& by, - double*& cx, double*& cy, double*& dx, double*& dy, double*& T); - -/* - * Converts a parametrised cubic spline (natural or periodic) to an approximate - * polygon. The function returns false, if an error occurred during the - * calculation of the coefficients or the polygon became too large (>PolyMax=16380). - * In the first case the polygon has 0, in the second case PolyMax points. - * To prevent coordinate overflows we limit them to +/-32000. - */ -bool Spline2Poly(tools::Polygon const & rSpln, bool Periodic, tools::Polygon& rPoly); - -#endif // INCLUDED_VCL_SOURCE_FILTER_SGVSPLN_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/filter/sgvtext.cxx b/vcl/source/filter/sgvtext.cxx deleted file mode 100644 index 692a960aa559..000000000000 --- a/vcl/source/filter/sgvtext.cxx +++ /dev/null @@ -1,1133 +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 . - */ - -#include <sal/config.h> - -#include <osl/thread.h> -#include <rtl/math.h> -#include <comphelper/string.hxx> -#include <tools/config.hxx> -#include <tools/fract.hxx> -#include <vcl/graphicfilter.hxx> -#include "sgffilt.hxx" -#include "sgfbram.hxx" -#include "sgvmain.hxx" -#include <memory> -#include <cstdlib> - -// Limitations: only grey shadows, 2D and with fixed distance. -// Start of AbsBase.Pas - -// vvv special characters in text buffer vvv -#define TextEnd 0 /* ^@ end of character sequence */ -#define HardSpace 6 /* ^F non-breaking space,' ' */ -#define SoftTrennK 11 /* ^K character for k-c-switch for separation, 'k' */ -#define AbsatzEnd 13 /* ^M new paragraph=CR */ -#define HardTrenn 16 /* ^P hard separator (not wrapped), '-' */ -#define SoftTrennAdd 19 /* ^S extra-character, separates e.g. "schiff-fahrt" */ -#define Escape 27 /* ^[ start of escape sequence */ -#define SoftTrenn 31 /* ^_ soft separator, '-' only end of line */ -#define MaxEscValLen 8 -#define MaxEscLen (MaxEscValLen+3) - -// Escape sequences: [Esc]<Ident><Value>[Esc] at least 4 characters -// Max length of value should be: 8 chars (7+sign). Therefore max. length -// of a escape sequence: 11 chars. -// Identifier: - -#define EscFont 'F' /* fontID, e.g. 92500 for CG Times */ -#define EscGrad 'G' /* font angle 1..255 for <<Pt-127<<Pt */ -#define EscBreit 'B' /* width 1..255% of the font angle */ -#define EscKaptS 'K' /* uppercase size 1..255% of the text angle */ -#define EscLFeed 'L' /* character spacing 1..32767% of max. text angle of the line*/ - // or 1..32767 for 1..16383<<Pt absolute (if bit 15=1) -#define EscSlant 'S' /* italic (angle) 1..8999 for 0.01deg..89.99deg */ -#define EscVPos 'V' /* character vertical position 1..255 for <<Pt..127<<Pt */ -#define EscZAbst 'Z' /* character spacing -128..127% */ -#define EscHJust 'A' /* H-justify paragraph: left, cent, right, block, aligned, fixed (0..5)*/ - -#define EscFarbe 'C' /* colour 0..7 */ -#define EscBFarb 'U' /* background colour 0..7 */ -#define EscInts 'I' /* colour intensity 0..100% */ -#define EscMustr 'M' /* pattern 0..? incl. transp... */ -#define EscMFarb 'O' /* pattern colour 0..7 */ -#define EscMBFrb 'P' /* 2nd pattern colour 0..7 */ -#define EscMInts 'W' /* pattern intensity 0..7 */ - -#define EscSMstr 'E' /* shadow pattern 0..? inkl. Transp... */ -#define EscSFarb 'R' /* shadow colour 0..7 */ -#define EscSBFrb 'T' /* 2nd shadow colour 0..7 */ -#define EscSInts 'Q' /* shadow intensity 0..7 */ - -#define EscSXDst 'X' /* shadow offset X 0..100% */ -#define EscSYDst 'Y' /* shadow offset Y 0..100% */ -#define EscSDist 'D' /* shadow offset X-Y 0..100% */ - -#define EscBold 'f' /* bold */ -#define EscLSlnt 'l' /* L italic */ -#define EscRSlnt 'r' /* R italic */ -#define EscUndln 'u' /* underlined */ -#define EscDbUnd 'p' /* double underlined */ -#define EscKaptF 'k' /* uppercase flag */ -#define EscStrik 'd' /* strikethrough */ -#define EscDbStk 'e' /* double strikethrough */ -#define EscSupSc 'h' /* superscript */ -#define EscSubSc 't' /* subscript */ -#define Esc2DShd 's' /* 2D-shadow */ -#define Esc3DShd 'j' /* 3D-shadow */ -#define Esc4DShd 'i' /* 4D-shadow */ -#define EscEbShd 'b' /* embossed */ - -// AllEscIdent =[EscFont, EscGrad, EscBreit,EscKaptS,EscLFeed,EscSlant,EscVPos, EscZAbst,EscHJust, -// EscFarbe,EscBFarb,EscInts, EscMustr,EscMFarb,EscMBFrb,EscMInts, -// EscSMstr,EscSFarb,EscSBFrb,EscSInts,EscSXDst,EscSYDst,EscSDist, -// EscBold, EscLSlnt,EscRSlnt,EscUndln,EscDbUnd,EscKaptF,EscStrik,EscDbStk, -// EscSupSc,EscSubSc,Esc2DShd,Esc3DShd,Esc4DShd]; -// Justify must be set no later than at the beginning of the paragraph -#define EscSet '\x1e' /* set flag */ -#define EscReset '\x1f' /* reset flag */ -#define EscDeflt '\x11' /* set flag to default */ -#define EscToggl '\x1d' /* toggle flag */ -#define EscNoFlg 0 -#define EscNoVal -2147483647 /* -MaxLongInt */ - -#define NoTrenn 0xFFFF /* parameter value for 'Rest' of GetTextChar(), if separation should not occur */ -#define DoTrenn 0xFFFE /* parameter value for 'Rest' of GetTextChar(), if separation should occur */ - -#define MaxLineChars 1024 - -#define ChrXPosArrSize (MaxLineChars+1+1) /* 2k - start with 0 opposite to StarDraw */ -#define CharLineSize (MaxLineChars+1+1) - -#define MinChar 32 -#define MaxChar 255 - -#define CharTopToBase 100 /* due to quotes more as 75% */ -#define CharTopToBtm 120 /* line height larger as text angle */ - // for Avanti-Bold 'ue' actually even 130% - -// end of AbsBase.Pas - -// Start of DefBase.Pas - -#define TextBoldBit 0x0001 /* bold */ -#define TextRSlnBit 0x0002 /* italic */ -#define TextUndlBit 0x0004 /* underline */ -#define TextStrkBit 0x0008 /* strikethrough */ -#define TextSupSBit 0x0010 /* superscript */ -#define TextSubSBit 0x0020 /* subscript */ -#define TextKaptBit 0x0040 /* capital */ -#define TextLSlnBit 0x0080 /* left italic */ -#define TextDbUnBit 0x0100 /* double underline */ -#define TextDbStBit 0x0200 /* double strikethrough */ -#define TextSh2DBit 0x0400 /* 2D-shadow 2.0 */ -#define TextSh3DBit 0x0800 /* 3D-shadow 2.0 */ -#define TextSh4DBit 0x1000 /* 4D-shadow 2.0 */ -#define TextShEbBit 0x2000 /* embossed-shadow 2.0 */ - -#define THJustLeft 0x00 -#define THJustCenter 0x01 -#define THJustRight 0x02 -#define THJustBlock 0x03 -#define THJustDrvOut 0x04 /* Justified formatted */ -#define THJustLocked 0x05 /* J u s t l o c k e d */ - -#define MaxCharSlant 4200 /* maximum 42deg italic ! */ - -// end of DefBase.Pas - -bool CheckTextOutl(ObjAreaType const & F, ObjLineType const & L) -{ - return (F.FIntens!=L.LIntens) || - ((F.FFarbe!=L.LFarbe) && (F.FIntens>0)) || - ((F.FBFarbe!=L.LBFarbe) && (F.FIntens<100)); -} - -// Start of Misc.Pas - -short hPoint2Sgf(short a) -{ - long b; - b=long(a)*127*SgfDpmm/(144*5); - return short(b); -} - -// End of Misc.Pas - -// Start of AbsRead.Pas - -// Function GetTopToBaseLine() Function GetBaseLineToBtm() -// -// Calculate distance from ascender of line to baseline or from baseline to -// descender. All in SGF-units. - -sal_uInt16 GetTopToBaseLine(sal_uInt16 MaxGrad) -{ - long ret; - ret=long(MaxGrad)*long(CharTopToBase) /long(100); - return sal_uInt16(ret); -} - -// Function GetTextChar() Function GetTextCharConv() -// -// Reads a character from textbuffer, in doing so escape sequences -// are evaluated and accordingly the input/output parameter AktAtr is set. -// Index is incremented accordingly. -// Parameter Rest should always contain the number of characters, -// the number of remaining characters in that line. -// Otherwise the hyphenation does not work. If the constant NoTrenn -// is used instead, no hyphenation is done. To the contrary then -// constant DoTrenn triggers hyphenation where a soft-break is present. -// -// Soft separators are converted to a minus sign. -// On top GetTextCharConv() converts HardSpace and AbsatzEnde -// in spaces, including HardTrenner in minus signs. TextEnde is -// always returned as Char(0). - -UCHAR ConvertTextChar(UCHAR c) -{ - if (c<32) { - switch (c) { - case HardSpace : c=' '; break; - case AbsatzEnd : c=' '; break; - case SoftTrenn : c='-'; break; - case HardTrenn : c='-'; break; - case SoftTrennK : c='-'; break; - case SoftTrennAdd: c='-'; - } - } - return c; -} - -long ChgValue(long Def, long Min, long Max, UCHAR FlgVal, long NumVal) -{ - long r=0; - - if (FlgVal==EscDeflt) { - r=Def; // return to default - } else { - if (NumVal!=EscNoVal) r=NumVal; // set non-breaking - } - - if (Min!=0 || Max!=0) { - if (r>Max) r=Max; - if (r<Min) r=Min; - } - return r; -} - -void ChgSchnittBit(sal_uInt16 Bit, sal_uInt16 Radio1, sal_uInt16 Radio2, sal_uInt16 Radio3, - UCHAR FlgVal, sal_uInt16 Schnitt0, sal_uInt16& Schnitt) -{ - sal_uInt16 All,Rad; - - Rad=Radio1 | Radio2 | Radio3; - All=Bit | Rad; - - switch (FlgVal) { - case EscSet : Schnitt=(Schnitt & ~All) | Bit; break; - case EscReset: Schnitt=(Schnitt & ~All); break; - case EscDeflt: Schnitt=(Schnitt & ~All) | (Schnitt0 & All); break; - case EscToggl: Schnitt=(Schnitt & ~Rad) ^ Bit; - } -} - -UCHAR GetNextChar(UCHAR const * TBuf, sal_uInt16 Index) -{ - sal_uInt16 Cnt; - while (TBuf[Index]==Escape) { - Index++; - Cnt=0; - while (TBuf[Index]!=Escape && Cnt<=MaxEscLen) { - Index++; Cnt++; } - Index++; - } - return TBuf[Index]; -} - -UCHAR ProcessOne(const UCHAR* TBuf, sal_uInt16& Index, - ObjTextType& Atr0, ObjTextType& AktAtr, - bool ScanEsc) -{ - UCHAR c; - UCHAR Ident; - bool Ende; - bool q; - UCHAR FlgVal; - long NumVal; - long Sgn; - short i; - bool EoVal; - - do { - c=TBuf[Index]; Index++; - Ende=(c!=Escape); - if (!Ende) { - c=TBuf[Index]; Index++; - Ident=c; // remember identifier - FlgVal=EscNoFlg; - NumVal=EscNoVal; - c=TBuf[Index]; Index++; // value starts here - if (c==EscSet || c==EscReset || c==EscDeflt || c==EscToggl) FlgVal=c; else { - if (c=='-') Sgn=-1; else Sgn=1; - if (c=='+' || c=='-') { c=TBuf[Index]; Index++; } - i=MaxEscValLen; - NumVal=0; - do { - NumVal=10*NumVal+c-'0'; - EoVal=(TBuf[Index]<'0' || TBuf[Index]>'9'); - if (!EoVal) { c=TBuf[Index]; Index++; } - i--; - } while (i>0 && !EoVal); - NumVal=Sgn*NumVal; - } - q=!CheckTextOutl(AktAtr.F,AktAtr.L); - - switch (Ident) { - case EscFont : AktAtr.SetFont(sal_uLong (ChgValue(Atr0.GetFont(),0,0 ,FlgVal,NumVal)));break; - case EscGrad : AktAtr.Grad =sal_uInt16(ChgValue(Atr0.Grad, 2,2000 ,FlgVal,NumVal)); break; - case EscBreit: AktAtr.Breite =sal_uInt16(ChgValue(Atr0.Breite, 1,1000 ,FlgVal,NumVal)); break; - case EscKaptS: AktAtr.Kapit =(sal_uInt8)(ChgValue(Atr0.Kapit, 1,255 ,FlgVal,NumVal)); break; - case EscLFeed: AktAtr.LnFeed =sal_uInt16(ChgValue(Atr0.LnFeed, 1,65535 ,FlgVal,NumVal)); break; - case EscSlant: AktAtr.Slant =sal_uInt16(ChgValue(Atr0.Slant, 1,MaxCharSlant ,FlgVal,NumVal)); break; - case EscVPos : AktAtr.ChrVPos=char (ChgValue(Atr0.ChrVPos,-128,127 ,FlgVal,NumVal)); break; - case EscZAbst: AktAtr.ZAbst =(sal_uInt8)(ChgValue(Atr0.ZAbst, 1,255 ,FlgVal,NumVal)); break; - case EscHJust: AktAtr.Justify=(sal_uInt8)(ChgValue(Atr0.Justify & 0x0F,0,5 ,FlgVal,NumVal)); break; - case EscFarbe: { AktAtr.L.LFarbe =(sal_uInt8)(ChgValue(Atr0.L.LFarbe,0,7 ,FlgVal,NumVal)); if (q) AktAtr.F.FFarbe =AktAtr.L.LFarbe; } break; - case EscBFarb: { AktAtr.L.LBFarbe=(sal_uInt8)(ChgValue(Atr0.L.LBFarbe,0,255,FlgVal,NumVal)); if (q) AktAtr.F.FBFarbe=AktAtr.L.LBFarbe; } break; - case EscInts : { AktAtr.L.LIntens=(sal_uInt8)(ChgValue(Atr0.L.LIntens,0,100,FlgVal,NumVal)); if (q) AktAtr.F.FIntens=AktAtr.L.LIntens; } break; - - case EscMustr: { AktAtr.F.FMuster=sal_uInt16(ChgValue(Atr0.F.FMuster,0,65535,FlgVal,NumVal)); } break; - case EscMFarb: { AktAtr.F.FFarbe =(sal_uInt8)(ChgValue(Atr0.F.FFarbe,0,7 ,FlgVal,NumVal)); } break; - case EscMBFrb: { AktAtr.F.FBFarbe=(sal_uInt8)(ChgValue(Atr0.F.FBFarbe,0,255,FlgVal,NumVal)); } break; - case EscMInts: { AktAtr.F.FIntens=(sal_uInt8)(ChgValue(Atr0.F.FIntens,0,100,FlgVal,NumVal)); } break; - - case EscSMstr: { AktAtr.ShdF.FMuster=sal_uInt16(ChgValue(Atr0.ShdF.FMuster,0,65535,FlgVal,NumVal)); } break; - case EscSFarb: { AktAtr.ShdL.LFarbe =(sal_uInt8)(ChgValue(Atr0.ShdL.LFarbe,0,7 ,FlgVal,NumVal)); AktAtr.ShdF.FFarbe =AktAtr.ShdL.LFarbe; } break; - case EscSBFrb: { AktAtr.ShdL.LBFarbe=(sal_uInt8)(ChgValue(Atr0.ShdL.LBFarbe,0,255,FlgVal,NumVal)); AktAtr.ShdF.FBFarbe=AktAtr.ShdL.LBFarbe; } break; - case EscSInts: { AktAtr.ShdL.LIntens=(sal_uInt8)(ChgValue(Atr0.ShdL.LIntens,0,100,FlgVal,NumVal)); AktAtr.ShdF.FIntens=AktAtr.ShdL.LIntens; } break; - case EscSDist: { AktAtr.ShdVers.x=(short)ChgValue(Atr0.ShdVers.x,0,30000,FlgVal,NumVal); AktAtr.ShdVers.y=AktAtr.ShdVers.x; } break; - case EscSXDst: { AktAtr.ShdVers.x=(short)ChgValue(Atr0.ShdVers.x,0,30000,FlgVal,NumVal); } break; - case EscSYDst: { AktAtr.ShdVers.y=(short)ChgValue(Atr0.ShdVers.y,0,30000,FlgVal,NumVal); } break; - - case EscBold : ChgSchnittBit(TextBoldBit,0,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; - case EscRSlnt: ChgSchnittBit(TextRSlnBit,TextLSlnBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; - case EscUndln: ChgSchnittBit(TextUndlBit,TextDbUnBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; - case EscStrik: ChgSchnittBit(TextStrkBit,TextDbStBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; - case EscDbUnd: ChgSchnittBit(TextDbUnBit,TextUndlBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; - case EscDbStk: ChgSchnittBit(TextDbStBit,TextStrkBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; - case EscSupSc: ChgSchnittBit(TextSupSBit,TextSubSBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; - case EscSubSc: ChgSchnittBit(TextSubSBit,TextSupSBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; - case EscKaptF: ChgSchnittBit(TextKaptBit,0,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; - case EscLSlnt: ChgSchnittBit(TextLSlnBit,TextRSlnBit,0,0 ,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; - case Esc2DShd: ChgSchnittBit(TextSh2DBit,TextSh3DBit,TextSh4DBit,TextShEbBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; - case Esc3DShd: ChgSchnittBit(TextSh3DBit,TextSh2DBit,TextSh4DBit,TextShEbBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; - case Esc4DShd: ChgSchnittBit(TextSh4DBit,TextSh2DBit,TextSh3DBit,TextShEbBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; - case EscEbShd: ChgSchnittBit(TextShEbBit,TextSh2DBit,TextSh3DBit,TextSh4DBit,FlgVal,Atr0.Schnitt,AktAtr.Schnitt); break; - } //endcase - if (TBuf[Index]==Escape) Index++; // read 2nd escape } - } - } while (!Ende && !ScanEsc); - if (!Ende) c=Escape; - return c; -} // end of ProcessOne - -UCHAR GetTextChar(UCHAR const * TBuf, sal_uInt16& Index, - ObjTextType& Atr0, ObjTextType& AktAtr, - sal_uInt16 Rest, bool ScanEsc) -{ - UCHAR c=ProcessOne(TBuf,Index,Atr0,AktAtr,ScanEsc); - if (!ScanEsc) { - if (c==SoftTrennAdd || c==SoftTrennK || c==SoftTrenn) { - UCHAR nc=GetNextChar(TBuf,Index); - UCHAR c0=c; - if (Rest==0 || Rest==DoTrenn || - nc==' ' || nc==AbsatzEnd || nc==TextEnd) c='-'; - else { - c=ProcessOne(TBuf,Index,Atr0,AktAtr,ScanEsc); // skip separator - if (c0==SoftTrennAdd) { - if (c>=32) c=ProcessOne(TBuf,Index,Atr0,AktAtr,ScanEsc); // skip another letter - } - } - } - if ((Rest==1 || Rest==DoTrenn) && GetNextChar(TBuf,Index)==SoftTrennK) { - if (c=='c') c='k'; - else if (c=='C') c='K'; - } - } - return c; -} - - // HardSpace and HardTrenn should be converted explicitly ! } - // if AktAtr.Schnitt and TextKaptBit =TextKaptBit then c:=UpCase(c);(explizit) } - - // The separationmethod SoftTrennAdd assumes, the separating consonant } - // is 3x present in TextBuf, e.g.: "schiff-fahrt". } - // If not separated then, "-f" is removed. } - -UCHAR GetTextCharConv(UCHAR const * TBuf, sal_uInt16& Index, - ObjTextType& Atr0, ObjTextType& AktAtr, - sal_uInt16 Rest) -{ - UCHAR c; - - c=GetTextChar(TBuf,Index,Atr0,AktAtr,Rest,false/*ScanEsc*/); - if (c<32) { - switch (c) { - case HardSpace : c=' '; break; - case AbsatzEnd : c=' '; break; - case HardTrenn : c='-'; - } - } - return c; -} - -// Function GetLineFeed() -// -// Required line spacing in SGF-Units. ChrVPos is taken into account. -// ====================================================================== -sal_uInt16 GetLineFeed(UCHAR const * TBuf, sal_uInt16 Index, ObjTextType Atr0, ObjTextType AktAtr, - sal_uInt16 nChar, sal_uInt16& LF, sal_uInt16& MaxGrad) -{ - bool AbsEnd=false; - sal_uLong LF100=0; - sal_uLong MaxLF100=0; - bool LFauto=false; - bool First=true; - sal_uInt16 Grad; - sal_uInt16 i=0; - sal_uInt16 r=1; - - MaxGrad=0; - while (!AbsEnd && nChar>0) { - nChar--; - UCHAR c=GetTextChar(TBuf,Index,Atr0,AktAtr,nChar,false); - i++; - AbsEnd=(c==TextEnd || c==AbsatzEnd); - if (First || (!AbsEnd && c!=' ' && c!=HardTrenn)) { - LFauto=(AktAtr.LnFeed & 0x8000)==0; - LF100=AktAtr.LnFeed & 0x7FFF; - if (LFauto) LF100=LF100*AktAtr.Grad; else LF100*=LF100; - if (AktAtr.ChrVPos>0) LF100-=AktAtr.ChrVPos*100; - if (LF100>MaxLF100) MaxLF100=LF100; - Grad=AktAtr.Grad; - if (AktAtr.ChrVPos>0) Grad=Grad-AktAtr.ChrVPos; - if (Grad>MaxGrad) MaxGrad=Grad; - First=false; - } - if (!AbsEnd && c!=' ') r=i; - } - MaxGrad=hPoint2Sgf(MaxGrad); - if (MaxLF100<=4000) { // otherwise overflow could occur - LF=sal_uInt16(hPoint2Sgf(short(MaxLF100)) /100); - } else { - LF=sal_uInt16(hPoint2Sgf(short(MaxLF100) /100)); - } - - return r; -} - -// End of AbsRead.Pas - -// Start of iFont.Pas - -#define SuperSubFact 60 /* superscript/subscript: 60% of text angle */ -#define DefaultSpace 40 /* Default: space is 40% of text angle */ - -sal_uInt16 SetTextContext(OutputDevice& rOut, ObjTextType& Atr, bool Kapt, sal_uInt16 nRotation, - sal_uInt16 FitXMul, sal_uInt16 FitXDiv, sal_uInt16 FitYMul, sal_uInt16 FitYDiv) -{ - SgfFontOne* pSgfFont; // Font from the IniFile - vcl::Font aFont; - Color aColor; - sal_uLong Grad; - sal_uLong Brei; - OUString FNam; - sal_uInt16 StdBrei=50; // average line width in % of text angle - bool bFit=(FitXMul!=1 || FitXDiv!=1 || FitYMul!=1 || FitYDiv!=1); - - pSgfFont = pSgfFonts->GetFontDesc(Atr.GetFont()); - - if ( pSgfFont!=nullptr ) - { - FNam =pSgfFont->SVFName; - StdBrei=pSgfFont->SVWidth; - if (pSgfFont->Fixd) aFont.SetPitch(PITCH_FIXED); else aFont.SetPitch(PITCH_VARIABLE); - aFont.SetFamily(pSgfFont->SVFamil); - aFont.SetCharSet(pSgfFont->SVChSet); - aFont.SetFamilyName(FNam); - } - else - { // if not in Inifile, some fonts are hard coded here - aFont.SetPitch(PITCH_VARIABLE); - switch (Atr.GetFont()) { - case 92500: case 92501: case 92504: case 92505: - { -#if defined(_WIN32) - FNam = "Times New Roman"; // CG Times is Times New Roman in Windows -#else - FNam = "Times"; // otherwise just Times -#endif - StdBrei=40; - aFont.SetFamily(FAMILY_ROMAN); - } break; - case 94021: case 94022: case 94023: case 94024: { -#if defined(_WIN32) - FNam = "Arial"; // Univers is Arial in Windows -#else - FNam = "Helvetica"; // otherwise Helvetica -#endif - aFont.SetFamily(FAMILY_SWISS); - StdBrei=47; - } break; - case 93950: case 93951: case 93952: case 93953: { -#if defined(_WIN32) - FNam = "Courier New"; // The vector-Courierfont is called Courier New in Windows -#else - FNam = "Courier"; // otherwise Courier remains Courier -#endif - aFont.SetFamily(FAMILY_ROMAN); - aFont.SetPitch(PITCH_FIXED); - } break; - default: FNam = "Helvetica"; - } - aFont.SetFamilyName(FNam); - //aFont.SetCharSet(CHARSET_SYSTEM); - } - - Grad=sal_uLong(Atr.Grad); - if ((Atr.Schnitt & TextKaptBit) !=0 && Kapt) Grad=Grad*sal_uLong(Atr.Kapit)/100; - if ((Atr.Schnitt & TextSupSBit) !=0 || (Atr.Schnitt & TextSubSBit) !=0) Grad=Grad*SuperSubFact/100; - Brei=Grad; - if (Atr.Breite!=100 || bFit) { - if (bFit) { - Grad=Grad*sal_uLong(FitYMul)/sal_uLong(FitYDiv); - Brei=Brei*sal_uLong(FitXMul)/sal_uLong(FitXDiv); - } - Brei=Brei*sal_uLong(Atr.Breite)/100; - Brei=Brei*sal_uLong(StdBrei)/100; - aFont.SetFontSize(Size(hPoint2Sgf(sal_uInt16(Brei)),hPoint2Sgf(sal_uInt16(Grad)))); - } else { - aFont.SetFontSize(Size(0,hPoint2Sgf(sal_uInt16(Grad)))); - } - - aColor=Sgv2SvFarbe(Atr.L.LFarbe,Atr.L.LBFarbe,Atr.L.LIntens); aFont.SetColor(aColor); - aColor=Sgv2SvFarbe(Atr.F.FFarbe,Atr.F.FBFarbe,Atr.F.FIntens); aFont.SetFillColor(aColor); - aFont.SetTransparent(true); - aFont.SetAlignment(ALIGN_BASELINE); - - nRotation/=10; nRotation=3600-nRotation; if (nRotation==3600) nRotation=0; - aFont.SetOrientation(nRotation); - - if ((Atr.Schnitt & TextBoldBit) !=0) aFont.SetWeight(WEIGHT_BOLD); - if ((Atr.Schnitt & TextRSlnBit) !=0) aFont.SetItalic(ITALIC_NORMAL); - if ((Atr.Schnitt & TextUndlBit) !=0) aFont.SetUnderline(LINESTYLE_SINGLE); - if ((Atr.Schnitt & TextDbUnBit) !=0) aFont.SetUnderline(LINESTYLE_DOUBLE); - if ((Atr.Schnitt & TextStrkBit) !=0) aFont.SetStrikeout(STRIKEOUT_SINGLE); - if ((Atr.Schnitt & TextDbStBit) !=0) aFont.SetStrikeout(STRIKEOUT_DOUBLE); - if ((Atr.Schnitt & TextSh2DBit) !=0) aFont.SetShadow(true); - if ((Atr.Schnitt & TextSh3DBit) !=0) aFont.SetShadow(true); - if ((Atr.Schnitt & TextSh4DBit) !=0) aFont.SetShadow(true); - if ((Atr.Schnitt & TextShEbBit) !=0) aFont.SetShadow(true); - if (CheckTextOutl(Atr.F,Atr.L)) aFont.SetOutline(true); - - if (aFont!=rOut.GetFont()) rOut.SetFont(aFont); - - return 0; -} - -// iFont.Pas - -// Start of Absatz.Pas - -struct ProcChrSta { - sal_uInt16 Index; - sal_uInt16 ChrXP; - UCHAR OutCh; - bool Kapt; - ObjTextType Attrib; -}; - -void InitProcessCharState(ProcChrSta& State, ObjTextType const & AktAtr, sal_uInt16 IndexA) -{ - State.Attrib=AktAtr; - State.OutCh=0; - State.Index=IndexA; - State.ChrXP=0; - State.Kapt=false; -} - -bool UpcasePossible(UCHAR c) -{ - return ((c>='a' && c<='z') || c == 0xe4 || c == 0xf6 || c == 0xfc ); -} - -UCHAR Upcase(UCHAR c) -{ - if (c>=(UCHAR)'a' && c<=(UCHAR)'z') c=(c-(UCHAR)'a')+(UCHAR)'A'; - else if ( c == 0xe4 ) c = 0xc4; - else if ( c == 0xf6 ) c = 0xd6; - else if ( c == 0xfc ) c = 0xdc; - return c; -} - -sal_uInt16 GetCharWidth(OutputDevice const & rOut, UCHAR c) -{ - sal_uInt16 ChrWidth; - - if (c==' ') - { - ChrWidth=(sal_uInt16)rOut.GetTextWidth( OUString('A') ); - if (rOut.GetFont().GetPitch()!=PITCH_FIXED) { - ChrWidth=MulDiv(ChrWidth,DefaultSpace,100); - } - } - else - { - static_assert(MaxChar == 255, "with MaxChar == 255 c cannot be greater than MaxChar"); - static_assert(sizeof(UCHAR) == 1, "assert if MaxChar type is ever changed"); - if (c>=MinChar /*&& c<=MaxChar*/) - { - ChrWidth=(sal_uInt16)rOut.GetTextWidth(OUString(reinterpret_cast<sal_Char*>(&c), 1, RTL_TEXTENCODING_IBM_437)); - } - else - { - ChrWidth=(sal_uInt16)rOut.GetTextWidth(OUString(u'A')); - } - } - return ChrWidth; -} - -UCHAR ProcessChar(OutputDevice& rOut, UCHAR const * TBuf, ProcChrSta& R, ObjTextType& Atr0, - sal_uInt16& nChars, sal_uInt16 Rest, - short* Line, UCHAR* cLine) -{ - sal_uInt16 KernDist=0; // value for kerning - sal_uInt16 ChrWidth; - UCHAR c; - bool AbsEnd; - - c=GetTextChar(TBuf,R.Index,Atr0,R.Attrib,Rest,false); // tries to separate, if Rest contains appropriate value - - AbsEnd=(c==AbsatzEnd || c==TextEnd); - if (!AbsEnd) { - R.OutCh=ConvertTextChar(c); // from HardTrenn to '-', ... - R.Kapt=(R.Attrib.Schnitt & TextKaptBit) !=0 && UpcasePossible(R.OutCh); - if (R.Kapt) R.OutCh=Upcase(R.OutCh); - SetTextContext(rOut,R.Attrib,R.Kapt,0,1,1,1,1); - - UCHAR c1 = (R.Kapt)?Upcase(c):c; - ChrWidth=GetCharWidth(rOut,c1); - - if (R.Attrib.ZAbst!=100) { // special line distance ? - sal_uLong Temp; - Temp=sal_uLong(ChrWidth)*sal_uLong(R.Attrib.ZAbst)/100; - ChrWidth=sal_uInt16(Temp); - } - nChars++; - if (R.ChrXP>32000) R.ChrXP=32000; - Line[nChars]=R.ChrXP-KernDist; - cLine[nChars]=c; - R.ChrXP+=ChrWidth-KernDist; // position of next character - } - return c; -} - -void FormatLine(UCHAR const * TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType& AktAtr, - sal_uInt16 UmbWdt, sal_uInt16 AdjWdt, - short* Line, sal_uInt16& nChars, - UCHAR* cLine, bool TextFit) -{ - ScopedVclPtrInstance< VirtualDevice > vOut; - UCHAR c,c0; - bool First; // first char ? - sal_uInt8 Just = 0; // paragraph format - bool Border; // border of box reached ? - bool Border0; - bool AbsEnd; // end of paragraph reached ? - std::unique_ptr<ProcChrSta> R(new ProcChrSta); - std::unique_ptr<ProcChrSta> R0(new ProcChrSta); - std::unique_ptr<ProcChrSta> WErec(new ProcChrSta); - sal_uInt16 WEnChar; - std::unique_ptr<ProcChrSta> WErec0(new ProcChrSta); - sal_uInt16 WEnChar0; - std::unique_ptr<ProcChrSta> TRrec(new ProcChrSta); - sal_uInt16 TRnChar; - - sal_uInt16 WordEndCnt; // justify and separate - bool WordEnd; - bool Trenn; - - short BoxRest; // to crush and format - sal_uInt16 i,j,k,h; - sal_uInt16 re,li; - - vOut->SetMapMode(MapMode(MapUnit::Map10thMM,Point(),Fraction(1,4),Fraction(1,4))); - - nChars=0; - SetTextContext(*vOut.get(),AktAtr,false,0,1,1,1,1); - InitProcessCharState(*R,AktAtr,Index); - (*R0)=(*R); (*WErec)=(*R); WEnChar=0; c0=0; Border0=false; - Border=false; First=true; - WordEndCnt=0; - - do { // check how many words to on that line - if (Border) c=ProcessChar(*vOut.get(),TBuf,*R,Atr0,nChars,DoTrenn,Line,cLine); - else c=ProcessChar(*vOut.get(),TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine); - AbsEnd=(c==AbsatzEnd || c==TextEnd); - //if not AbsEnd then - { - if (First) { - Just=R->Attrib.Justify & 0x0F; // paragraph format remains, then at start - } - Border=R->ChrXP>UmbWdt; - WordEnd=(AbsEnd || (c==' ')) && (c0!=' ') && (c0!=0); - Trenn=c=='-'; - if (WordEnd && !Border0) { - WordEndCnt++; - (*WErec)=(*R0); - WEnChar=nChars-1; - } - if (Trenn && !Border) { - WordEndCnt++; - (*WErec)=(*R); - WEnChar=nChars; - } - } - (*R0)=(*R); c0=c; - Border0=Border; - First=false; - AbsEnd=AbsEnd || (nChars>=MaxLineChars); - } while (!(AbsEnd || (Border && ((WordEndCnt>0) || WordEnd || Trenn)))); - - if (Border) { // separate and crush - (*WErec0)=(*WErec); WEnChar0=WEnChar; - c0=0; - (*R)=(*WErec); nChars=WEnChar; - (*TRrec)=(*R); TRnChar=nChars; - Border0=false; - do { // first check how many syllables fit - UCHAR ct=ProcessChar(*vOut.get(),TBuf,*TRrec,Atr0,TRnChar,DoTrenn,Line,cLine); - c=ProcessChar(*vOut.get(),TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine); - AbsEnd=(ct==AbsatzEnd) || (ct==TextEnd) || (nChars>=MaxLineChars); - - Border=TRrec->ChrXP>UmbWdt; - WordEnd=AbsEnd || ((AbsEnd || (c==' ')) && (c0!=' ') && (c0!=0)); - Trenn=ct=='-'; - if (WordEnd && (!Border0 || (WordEndCnt==0))) { - WordEndCnt++; - (*WErec)=(*R0); - if (AbsEnd) WEnChar=nChars; else WEnChar=nChars-1; - (*TRrec)=(*R); TRnChar=nChars; // to continue searching - } - if (Trenn && (!Border || (WordEndCnt==0))) { - WordEndCnt++; // remember we can separate here - (*WErec)=(*TRrec); - WEnChar=TRnChar; - (*TRrec)=(*R); TRnChar=nChars; // continue searching - } - (*R0)=(*R); c0=c; - Border0=Border; - Border=R->ChrXP>UmbWdt; - } while (!(AbsEnd || (Border && ((WordEndCnt>0) || WordEnd || Trenn)))); - - while (WErec0->Index<WErec->Index) { // to assure Line[] matches } - (void)ProcessChar(*vOut.get(),TBuf,*WErec0,Atr0,WEnChar0,WEnChar-WEnChar0-1,Line,cLine); - } - - (*R)=(*WErec); nChars=WEnChar; - - if (UmbWdt<R->ChrXP) { - BoxRest=R->ChrXP-UmbWdt; // so much should be crushed - for (i=2;i<=nChars;i++) { // first character position remains! - Line[i]-=(i-1)*BoxRest /(nChars-1); - } - R->ChrXP=UmbWdt; - Line[nChars+1]=UmbWdt; - } - } - - if (!AbsEnd) { - do { // read empty characters - (*WErec)=(*R); - c=GetTextChar(TBuf,R->Index,Atr0,R->Attrib,NoTrenn,false); - nChars++; - Line[nChars]=R->ChrXP; - cLine[nChars]=c; - } while (c==' '); - if (c!=' ' && c!=AbsatzEnd && c!=TextEnd) { - nChars--; - (*R)=(*WErec); - } - } - - if (AbsEnd && nChars<MaxLineChars) { // align, left aligned instead of block - if (Just==3) Just=0; - nChars++; Line[nChars]=R->ChrXP; // to assure AbsatzEnde is read - Line[nChars+1]=R->ChrXP; // as the width of CR or #0 is very small - if (TBuf[R->Index-1]!=AbsatzEnd && TBuf[R->Index-1]!=TextEnd) { - GetTextChar(TBuf,R->Index,Atr0,R->Attrib,NoTrenn,false); // small correction needed, if 1st word read - } - } - - BoxRest=AdjWdt-R->ChrXP; - if (TextFit) Just=THJustLeft; - - switch (Just) { - case THJustLeft: break; // left - case THJustCenter: { - BoxRest=BoxRest /2; // middle - for (i=1;i<=nChars;i++) Line[i]=Line[i]+BoxRest; - } break; - case THJustRight: { // right - for (i=1;i<=nChars;i++) Line[i]=Line[i]+BoxRest; - } break; - case THJustDrvOut: - case THJustBlock: { // block and justified - re=nChars; - if (Just==THJustDrvOut) re--; - while (re>=1 && (cLine[re]==' ' || cLine[re]==TextEnd || cLine[re]==AbsatzEnd)) re--; - li=1; - while (li<=re && (cLine[li]==' ' || cLine[li]==TextEnd || cLine[li]==AbsatzEnd)) li++; - if (Just==THJustDrvOut) BoxRest=AdjWdt-Line[re+1]; - - j=0; // get number of spaces - for (i=li;i<=re;i++) { - if (cLine[i]==' ') { - j++; - } - } - - if (j==0) { // only one word ? -> stretch ! - for (i=li+1;i<=re;i++) { // from left to right - Line[i]=Line[i]+MulDiv(i-li,BoxRest,re-li+1-1); - } - } else { - k=0; h=0; - for (i=li;i<=re;i++) { // j drill spaces ! - if (cLine[i]==' ') { // space found ! - k++; - h=MulDiv(k,BoxRest,j); - } - Line[i]=Line[i]+h; - } - } - for (i=re+1;i<=nChars;i++) Line[i]=Line[i]+BoxRest; // adapt the rest - Line[nChars+1]=AdjWdt; - } break; - case THJustLocked: { // locked out - re=nChars-1; - while (re>=1 && (cLine[re]==' ' || cLine[re]==TextEnd || cLine[re]==AbsatzEnd)) re--; - li=1; - while (li<=re && (cLine[li]==' ' || cLine[li]==TextEnd || cLine[li]==AbsatzEnd)) li++; - BoxRest=AdjWdt-Line[re+1]; - for (i=li+1;i<=re;i++) { // stretch from left to right - Line[i]=Line[i]+MulDiv(i-li,BoxRest,re-li+1-1); - } - for (i=re+1;i<=nChars;i++) Line[i]=Line[i]+BoxRest; // adapt the rest - Line[nChars+1]=AdjWdt; - } break; - } - Index=R->Index; - AktAtr=R->Attrib; -} - -// End of Absatz.Pas - -// Start of DrawText.Pas - -void DrawChar(OutputDevice& rOut, UCHAR c, ObjTextType T, PointType Pos, sal_uInt16 RotationAngle, - sal_uInt16 FitXMul, sal_uInt16 FitXDiv, sal_uInt16 FitYMul, sal_uInt16 FitYDiv) -{ - SetTextContext(rOut,T,UpcasePossible(c),RotationAngle,FitXMul,FitXDiv,FitYMul,FitYDiv); - if ((T.Schnitt & TextKaptBit)!=0 && UpcasePossible(c)) c=Upcase(c); - OUString s(reinterpret_cast<const sal_Char*>(&c), 1, - RTL_TEXTENCODING_IBM_437); - rOut.DrawText( Point( Pos.x, Pos.y ), s ); -} - -void TextType::Draw(OutputDevice& rOut, UCHAR* pBuffer) -{ - if ((Flags & TextOutlBit)!=0) return; // source text for Outliner !! - - ObjTextType T1,T2; - sal_uInt16 Index1; - sal_uInt16 Index2; - UCHAR c = TextEnd; - sal_uInt16 l; // number of characters on the line - sal_uInt16 i; - short yPos0; - short xPos; - short yPos; - sal_uInt16 LF; - sal_uInt16 MaxGrad; - short xSize; - short xSAdj; - short ySize; - double sn,cs; - sal_uInt16 TopToBase; - bool Ende = false; - sal_uInt16 lc; - bool TextFit; - std::unique_ptr<short[]> xLine; - std::unique_ptr<UCHAR[]> cLine; // Buffer for FormatLine - sal_uInt16 FitXMul; - sal_uInt16 FitXDiv; - sal_uInt16 FitYMul; - sal_uInt16 FitYDiv; - bool Error; - UCHAR* Buf = pBuffer; // pointer to the letters - - pSgfFonts->ReadList(); - xLine.reset(new short[ChrXPosArrSize]); - cLine.reset(new UCHAR[CharLineSize]); - - TextFit=(Flags & TextFitBits)!=0; - bool LineFit=((Flags & TextFitZBit)!=0); // FitSize.x=0? or flags -> stretch each line - if (TextFit && FitSize.x==0) LineFit=true; - - if (RotationAngle==0) { - sn=0.0; - cs=1.0; - } else { - sn=sin(double(RotationAngle)*3.14159265359/18000); - cs=cos(double(RotationAngle)*3.14159265359/18000); - } - - T1=T; Index1=0; yPos=0; xPos=0; - if (TextFit) { - ySize=Pos2.y-Pos1.y; - xSize=32000 /2; // break - xSAdj=Pos2.x-Pos1.x; // to align for center/block - //if (xSize<=0) { xSize=32000 /2; LineFit=true; } - FitXMul=sal::static_int_cast< sal_uInt16 >(std::abs(Pos2.x-Pos1.x)); FitXDiv=FitSize.x; if (FitXDiv==0) FitXDiv=1; - FitYMul=sal::static_int_cast< sal_uInt16 >(std::abs(Pos2.y-Pos1.y)); FitYDiv=FitSize.y; if (FitYDiv==0) FitYDiv=1; - } else { - xSize=Pos2.x-Pos1.x; - xSAdj=xSize; - ySize=Pos2.y-Pos1.y; - FitXMul=1; FitXDiv=1; - FitYMul=1; FitYDiv=1; - } - if (xSize<0) xSize=0; - if (xSAdj<0) xSAdj=0; - - do { - T2=T1; Index2=Index1; - FormatLine(Buf,Index2,T,T2,xSize,xSAdj,xLine.get(),l,cLine.get(),LineFit); - Error=(Index2==Index1); - if (!Error) { - lc=GetLineFeed(Buf,Index1,T,T1,l,LF,MaxGrad); - if (TextFit) { - if (LineFit) FitXDiv=xLine[lc+1]; - if (FitXDiv>0) { - for (i=1;i<=l+1;i++) { - const long Temp=long(xLine[i])*long(FitXMul) /long(FitXDiv); - xLine[i]=short(Temp); - } - LF=MulDiv(LF,FitYMul,FitYDiv); - MaxGrad=MulDiv(MaxGrad,FitYMul,FitYDiv); - } else { - FitXDiv=1; // 0 does not exist - } - } - yPos0=yPos; - TopToBase=GetTopToBaseLine(MaxGrad); - yPos=yPos+TopToBase; - Ende=(yPos0+short(MulDiv(MaxGrad,CharTopToBtm,100))>ySize) && !TextFit; - if (!Ende) { - T2=T1; Index2=Index1; - i=1; - while (i<=l) { - c=GetTextCharConv(Buf,Index2,T,T2,l-i); - long xp1,yp1; // due to overflow danger - PointType Pos; - xp1=long(Pos1.x)+xPos+long(xLine[i]); - yp1=long(Pos1.y)+yPos; - if (xp1>32000) xp1=32000; - if (xp1<-12000) xp1=-12000; - if (yp1>32000) yp1=32000; - if (yp1<-12000) yp1=-12000; - Pos.x=short(xp1); - Pos.y=short(yp1); - - if (RotationAngle!=0) RotatePoint(Pos,Pos1.x,Pos1.y,sn,cs); - DrawChar(rOut,c,T2,Pos,RotationAngle,FitXMul,FitXDiv,FitYMul,FitYDiv); - i++; - } // while i<=l - yPos=yPos0+LF; - T1=T2; Index1=Index2; // for next line - } // if ObjMin.y+yPos<=Obj_Max.y - } // if !Error - } while (c!=TextEnd && !Ende && !Error); -} - -// End of DrawText.Pas - -sal_uInt32 ObjTextType::GetFont() -{ - return sal_uLong(FontLo)+0x00010000*sal_uLong(FontHi); -} - -void ObjTextType::SetFont(sal_uInt32 FontID) -{ - FontLo=sal_uInt16(FontID & 0x0000FFFF); - FontHi=sal_uInt16((FontID & 0xFFFF0000)>>16); -} - -// SGF.Ini lesen -SgfFontOne::SgfFontOne() -{ - Next=nullptr; - IFID=0; - Bold=false; - Ital=false; - Sans=false; - Serf=false; - Fixd=false; - SVFamil=FAMILY_DONTKNOW; - SVChSet=RTL_TEXTENCODING_DONTKNOW; - SVWidth=40; -} - -void SgfFontOne::ReadOne( const OString& rID, OString& Dsc ) -{ - if ( Dsc.getLength() < 4 || ( Dsc[0] != '(' ) ) - return; - sal_Int32 i=1; // first letter of IF fontname. In front is a '(' - while ( i < Dsc.getLength() && ( Dsc[i] !=')' ) ) - i++; - Dsc = Dsc.copy(i+1); // delete IF fontname incl. () - - if ( Dsc.getLength() < 2 || ( Dsc[Dsc.getLength() - 1] !=')' ) ) - return; - i = Dsc.getLength()-2; // here is the ')' of the SV fontname - sal_Int32 j=0; - while ( i > 0 && ( Dsc[i] != '(' ) ) - { - i--; - j++; - } - SVFName = OStringToOUString(Dsc.copy(i+1,j), RTL_TEXTENCODING_IBM_437); // retrieve SV fontname - Dsc = OStringBuffer(Dsc).remove(i,j).makeStringAndClear(); - - IFID = (sal_uInt32)rID.toInt32(); - sal_Int32 nTokenCount = comphelper::string::getTokenCount(Dsc, ' '); - for (sal_Int32 nIdx = 0; nIdx < nTokenCount; ++nIdx) - { - OString s(Dsc.getToken(nIdx, ' ')); - if (!s.isEmpty()) - { - s = s.toAsciiUpperCase(); - if (s.match("BOLD")) Bold=true; - else if (s.match("ITAL")) Ital=true; - else if (s.match("SERF")) Serf=true; - else if (s.match("SANS")) Sans=true; - else if (s.match("FIXD")) Fixd=true; - else if (s.match("ROMAN")) SVFamil=FAMILY_ROMAN; - else if (s.match("SWISS")) SVFamil=FAMILY_SWISS; - else if (s.match("MODERN")) SVFamil=FAMILY_MODERN; - else if (s.match("SCRIPT")) SVFamil=FAMILY_SCRIPT; - else if (s.match("DECORA")) SVFamil=FAMILY_DECORATIVE; - else if (s.match("ANSI")) SVChSet=RTL_TEXTENCODING_MS_1252; - else if (s.match("IBMPC")) SVChSet=RTL_TEXTENCODING_IBM_850; - else if (s.match("MAC")) SVChSet=RTL_TEXTENCODING_APPLE_ROMAN; - else if (s.match("SYMBOL")) SVChSet=RTL_TEXTENCODING_SYMBOL; - else if (s.match("SYSTEM")) SVChSet = osl_getThreadTextEncoding(); - else if (comphelper::string::isdigitAsciiString(s) ) SVWidth=sal::static_int_cast< sal_uInt16 >(s.toInt32()); - } - } -} - -SgfFontLst::SgfFontLst() -{ - pList=nullptr; - Last=nullptr; - LastID=0; - LastLn=nullptr; - Tried=false; -} - -SgfFontLst::~SgfFontLst() -{ - RausList(); -} - -void SgfFontLst::RausList() -{ - SgfFontOne* P; - SgfFontOne* P1; - P=pList; - while (P!=nullptr) { - P1=P->Next; - delete P; - P=P1; - } - pList=nullptr; - Last=nullptr; - Tried=false; - LastID=0; - LastLn=nullptr; -} - -void SgfFontLst::AssignFN(const OUString& rFName) -{ FNam=rFName; } - -void SgfFontLst::ReadList() -{ - if (!Tried) - { - Tried=true; - LastID=0; - LastLn=nullptr; - SgfFontOne* P,P1; - Config aCfg(FNam); - aCfg.SetGroup("SGV Fonts for StarView"); - sal_uInt16 Anz=aCfg.GetKeyCount(); - sal_uInt16 i; - OString FID; - OString Dsc; - - for (i=0;i<Anz;i++) - { - FID = aCfg.GetKeyName(i).replaceAll(" ", ""); - Dsc = aCfg.ReadKey( i ); - if (comphelper::string::isdigitAsciiString(FID)) - { - P=new SgfFontOne; // new entry - if (Last!=nullptr) Last->Next=P; else pList=P; Last=P; // link it - P->ReadOne(FID,Dsc); // interpret line - } - } - } -} - -SgfFontOne* SgfFontLst::GetFontDesc(sal_uInt32 ID) -{ - if (ID!=LastID) { - SgfFontOne* P; - P=pList; - while (P!=nullptr && P->IFID!=ID) P=P->Next; - LastID=ID; - LastLn=P; - } - return LastLn; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |