summaryrefslogtreecommitdiffstats
path: root/vcl/workben
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/workben')
-rw-r--r--vcl/workben/602fuzzer.cxx57
-rw-r--r--vcl/workben/602fuzzer.options2
-rw-r--r--vcl/workben/bmpfuzzer.cxx56
-rw-r--r--vcl/workben/bmpfuzzer.options2
-rw-r--r--vcl/workben/cgmfuzzer.cxx183
-rw-r--r--vcl/workben/cgmfuzzer.options2
-rw-r--r--vcl/workben/cnttype/makefile.mk44
-rw-r--r--vcl/workben/cnttype/testcnttype.cxx186
-rw-r--r--vcl/workben/commonfuzzer.hxx153
-rw-r--r--vcl/workben/dbffuzzer.cxx52
-rw-r--r--vcl/workben/dbffuzzer.options2
-rw-r--r--vcl/workben/diffuzzer.cxx89
-rw-r--r--vcl/workben/diffuzzer.options2
-rw-r--r--vcl/workben/docxfuzzer.cxx34
-rw-r--r--vcl/workben/docxfuzzer.options2
-rw-r--r--vcl/workben/dtrans/makefile.mk44
-rw-r--r--vcl/workben/dtrans/test_dtrans.cxx414
-rw-r--r--vcl/workben/dxffuzzer.cxx70
-rw-r--r--vcl/workben/dxffuzzer.options2
-rw-r--r--vcl/workben/epsfuzzer.cxx70
-rw-r--r--vcl/workben/epsfuzzer.options2
-rw-r--r--vcl/workben/fftester.cxx545
-rw-r--r--vcl/workben/fodpfuzzer.cxx64
-rw-r--r--vcl/workben/fodpfuzzer.options3
-rw-r--r--vcl/workben/fodsfuzzer.cxx34
-rw-r--r--vcl/workben/fodsfuzzer.options3
-rw-r--r--vcl/workben/fodtfuzzer.cxx34
-rw-r--r--vcl/workben/fodtfuzzer.options3
-rw-r--r--vcl/workben/giffuzzer.cxx56
-rw-r--r--vcl/workben/giffuzzer.options3
-rw-r--r--vcl/workben/htmlfuzzer.cxx31
-rw-r--r--vcl/workben/htmlfuzzer.options3
-rw-r--r--vcl/workben/hwpfuzzer.cxx57
-rw-r--r--vcl/workben/hwpfuzzer.options2
-rw-r--r--vcl/workben/icontest.cxx215
-rw-r--r--vcl/workben/jpgfuzzer.cxx56
-rw-r--r--vcl/workben/jpgfuzzer.options3
-rw-r--r--vcl/workben/listfonts.cxx541
-rw-r--r--vcl/workben/lwpfuzzer.cxx57
-rw-r--r--vcl/workben/lwpfuzzer.options2
-rw-r--r--vcl/workben/metfuzzer.cxx70
-rw-r--r--vcl/workben/metfuzzer.options2
-rw-r--r--vcl/workben/minvcl.cxx86
-rw-r--r--vcl/workben/mmlfuzzer.cxx29
-rw-r--r--vcl/workben/mmlfuzzer.options3
-rw-r--r--vcl/workben/mtfdemo.cxx246
-rw-r--r--vcl/workben/mtpfuzzer.cxx42
-rw-r--r--vcl/workben/mtpfuzzer.options2
-rw-r--r--vcl/workben/olefuzzer.cxx65
-rw-r--r--vcl/workben/olefuzzer.options2
-rw-r--r--vcl/workben/pasteboard.mm133
-rw-r--r--vcl/workben/pcdfuzzer.cxx57
-rw-r--r--vcl/workben/pcdfuzzer.options2
-rw-r--r--vcl/workben/pctfuzzer.cxx57
-rw-r--r--vcl/workben/pctfuzzer.options2
-rw-r--r--vcl/workben/pcxfuzzer.cxx57
-rw-r--r--vcl/workben/pcxfuzzer.options2
-rw-r--r--vcl/workben/pngfuzzer.cxx56
-rw-r--r--vcl/workben/pngfuzzer.options3
-rw-r--r--vcl/workben/ppmfuzzer.cxx57
-rw-r--r--vcl/workben/ppmfuzzer.options2
-rw-r--r--vcl/workben/pptfuzzer.cxx153
-rw-r--r--vcl/workben/pptfuzzer.options2
-rw-r--r--vcl/workben/pptxfuzzer.cxx43
-rw-r--r--vcl/workben/pptxfuzzer.options2
-rw-r--r--vcl/workben/psdfuzzer.cxx57
-rw-r--r--vcl/workben/psdfuzzer.options2
-rw-r--r--vcl/workben/qpwfuzzer.cxx91
-rw-r--r--vcl/workben/qpwfuzzer.options2
-rw-r--r--vcl/workben/rasfuzzer.cxx57
-rw-r--r--vcl/workben/rasfuzzer.options2
-rw-r--r--vcl/workben/rtffuzzer.cxx90
-rw-r--r--vcl/workben/rtffuzzer.options2
-rw-r--r--vcl/workben/scrtffuzzer.cxx86
-rw-r--r--vcl/workben/scrtffuzzer.options2
-rw-r--r--vcl/workben/sftfuzzer.cxx43
-rw-r--r--vcl/workben/sftfuzzer.options2
-rw-r--r--vcl/workben/slkfuzzer.cxx91
-rw-r--r--vcl/workben/slkfuzzer.options2
-rw-r--r--vcl/workben/svdem.cxx105
-rw-r--r--vcl/workben/svmfuzzer.cxx83
-rw-r--r--vcl/workben/svmfuzzer.options2
-rw-r--r--vcl/workben/svpclient.cxx284
-rw-r--r--vcl/workben/svptest.cxx327
-rw-r--r--vcl/workben/tgafuzzer.cxx57
-rw-r--r--vcl/workben/tgafuzzer.options2
-rw-r--r--vcl/workben/tiffuzzer.cxx63
-rw-r--r--vcl/workben/tiffuzzer.options3
-rw-r--r--vcl/workben/vcldemo.cxx2271
-rw-r--r--vcl/workben/webpfuzzer.cxx48
-rw-r--r--vcl/workben/webpfuzzer.options2
-rw-r--r--vcl/workben/win/dnd/atlwindow.cxx238
-rw-r--r--vcl/workben/win/dnd/atlwindow.hxx87
-rw-r--r--vcl/workben/win/dnd/dndTest.cxx177
-rw-r--r--vcl/workben/win/dnd/makefile.mk70
-rw-r--r--vcl/workben/win/dnd/sourcelistener.cxx59
-rw-r--r--vcl/workben/win/dnd/sourcelistener.hxx56
-rw-r--r--vcl/workben/win/dnd/targetlistener.cxx78
-rw-r--r--vcl/workben/win/dnd/targetlistener.hxx64
-rw-r--r--vcl/workben/win/dnd/transferable.cxx105
-rw-r--r--vcl/workben/win/dnd/transferable.hxx88
-rw-r--r--vcl/workben/win/dtrans/XTDo.cxx358
-rw-r--r--vcl/workben/win/dtrans/XTDo.hxx111
-rw-r--r--vcl/workben/win/dtrans/makefile.mk81
-rw-r--r--vcl/workben/win/dtrans/test_wincb.cxx287
-rw-r--r--vcl/workben/win/dtrans/testmarshal.cxx212
-rw-r--r--vcl/workben/wksfuzzer.cxx52
-rw-r--r--vcl/workben/wksfuzzer.options2
-rw-r--r--vcl/workben/wmffuzzer.cxx68
-rw-r--r--vcl/workben/wmffuzzer.options2
-rw-r--r--vcl/workben/ww2fuzzer.cxx130
-rw-r--r--vcl/workben/ww2fuzzer.options2
-rw-r--r--vcl/workben/ww6fuzzer.cxx132
-rw-r--r--vcl/workben/ww6fuzzer.options2
-rw-r--r--vcl/workben/ww8fuzzer.cxx132
-rw-r--r--vcl/workben/ww8fuzzer.options2
-rw-r--r--vcl/workben/xbmfuzzer.cxx56
-rw-r--r--vcl/workben/xbmfuzzer.options2
-rw-r--r--vcl/workben/xlsfuzzer.cxx52
-rw-r--r--vcl/workben/xlsfuzzer.options2
-rw-r--r--vcl/workben/xlsxfuzzer.cxx31
-rw-r--r--vcl/workben/xlsxfuzzer.options2
-rw-r--r--vcl/workben/xpmfuzzer.cxx56
-rw-r--r--vcl/workben/xpmfuzzer.options2
124 files changed, 10929 insertions, 0 deletions
diff --git a/vcl/workben/602fuzzer.cxx b/vcl/workben/602fuzzer.cxx
new file mode 100644
index 000000000..6fb96a4c7
--- /dev/null
+++ b/vcl/workben/602fuzzer.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" bool TestImport602(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImport602(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/602fuzzer.options b/vcl/workben/602fuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/602fuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/bmpfuzzer.cxx b/vcl/workben/bmpfuzzer.cxx
new file mode 100644
index 000000000..8e22aabaf
--- /dev/null
+++ b/vcl/workben/bmpfuzzer.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/dibtools.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Bitmap aTarget;
+ (void)ReadDIB(aTarget, aStream, true);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/bmpfuzzer.options b/vcl/workben/bmpfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/bmpfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/cgmfuzzer.cxx b/vcl/workben/cgmfuzzer.cxx
new file mode 100644
index 000000000..7d36f2acc
--- /dev/null
+++ b/vcl/workben/cgmfuzzer.cxx
@@ -0,0 +1,183 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" {
+void * i18npool_component_getFactory( const char* , void* , void* );
+
+void * com_sun_star_i18n_LocaleDataImpl_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_get_implementation( void *, void * );
+void * com_sun_star_comp_framework_Desktop_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_get_implementation( void *, void * );
+void * com_sun_star_i18n_NativeNumberSupplier_get_implementation( void *, void * );
+void * com_sun_star_i18n_NumberFormatCodeMapper_get_implementation( void *, void * );
+void * com_sun_star_i18n_Transliteration_get_implementation( void *, void * );
+void * com_sun_star_drawing_EnhancedCustomShapeEngine_get_implementation( void *, void * );
+void * com_sun_star_drawing_SvxShapeCollection_get_implementation( void *, void * );
+void * SfxDocumentMetaData_get_implementation( void *, void * );
+void * com_sun_star_animations_AnimateColor_get_implementation( void *, void * );
+void * com_sun_star_animations_AnimateMotion_get_implementation( void *, void * );
+void * com_sun_star_animations_AnimateSet_get_implementation( void *, void * );
+void * com_sun_star_animations_AnimateTransform_get_implementation( void *, void * );
+void * com_sun_star_animations_Animate_get_implementation( void *, void * );
+void * com_sun_star_animations_Audio_get_implementation( void *, void * );
+void * com_sun_star_animations_Command_get_implementation( void *, void * );
+void * com_sun_star_animations_IterateContainer_get_implementation( void *, void * );
+void * com_sun_star_animations_ParallelTimeContainer_get_implementation( void *, void * );
+void * com_sun_star_animations_SequenceTimeContainer_get_implementation( void *, void * );
+void * com_sun_star_animations_TransitionFilter_get_implementation( void *, void * );
+void * com_sun_star_comp_comphelper_OPropertyBag( void *, void * );
+void * com_sun_star_comp_uui_UUIInteractionHandler_get_implementation( void *, void * );
+void * emfio_emfreader_XEmfParser_get_implementation( void *, void * );
+void * unoxml_rdfRepository_get_implementation( void *, void * );
+void * unoxml_CURI_get_implementation( void *, void * );
+void * unoxml_CLiteral_get_implementation( void *, void * );
+void * unoxml_CBlankNode_get_implementation( void *, void * );
+void * unoxml_CXPathAPI_get_implementation( void *, void * );
+void * unoxml_CSAXDocumentBuilder_get_implementation( void *, void * );
+void * unoxml_CDocumentBuilder_get_implementation( void *, void * );
+void * linguistic_ConvDicList_get_implementation( void *, void * );
+void * linguistic_DicList_get_implementation( void *, void * );
+void * linguistic_LinguProps_get_implementation( void *, void * );
+void * linguistic_LngSvcMgr_get_implementation( void *, void * );
+void * linguistic_GrammarCheckingIterator_get_implementation( void *, void * );
+void * sd_DrawingDocument_get_implementation( void *, void * );
+void * com_sun_star_comp_Draw_DrawingModule_get_implementation( void *, void * );
+void * sd_PresentationDocument_get_implementation( void *, void * );
+void * com_sun_star_comp_Draw_PresenterHelper_get_implementation( void *, void * );
+void * com_sun_star_comp_Draw_PresenterPreviewCache_get_implementation( void *, void * );
+void * com_sun_star_comp_Draw_PresenterTextView_get_implementation( void *, void * );
+void * com_sun_star_comp_Draw_SlideRenderer_get_implementation( void *, void * );
+void * com_sun_star_comp_Draw_SlideSorter_get_implementation( void *, void * );
+void * com_sun_star_comp_Draw_framework_configuration_Configuration_get_implementation( void *, void * );
+void * com_sun_star_comp_draw_SdHtmlOptionsDialog_get_implementation( void *, void * );
+void * com_sun_star_comp_sd_InsertSlideController_get_implementation( void *, void * );
+void * com_sun_star_comp_sd_SlideLayoutController_get_implementation( void *, void * );
+void * com_sun_star_comp_sd_DisplayModeController_get_implementation( void *, void * );
+void * ucb_UcbCommandEnvironment_get_implementation( void *, void * );
+void * ucb_UcbContentProviderProxyFactory_get_implementation( void *, void * );
+void * ucb_UcbPropertiesManager_get_implementation( void *, void * );
+void * ucb_UcbStore_get_implementation( void *, void * );
+void * ucb_UniversalContentBroker_get_implementation( void *, void * );
+void * ucb_OFileAccess_get_implementation( void *, void * );
+}
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { "libi18npoollo.a", i18npool_component_getFactory },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { "com_sun_star_i18n_LocaleDataImpl_get_implementation", com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation", com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation", com_sun_star_i18n_BreakIterator_get_implementation },
+ { "com_sun_star_comp_framework_Desktop_get_implementation", com_sun_star_comp_framework_Desktop_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_Unicode_get_implementation", com_sun_star_i18n_CharacterClassification_Unicode_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_get_implementation", com_sun_star_i18n_CharacterClassification_get_implementation },
+ { "com_sun_star_i18n_NativeNumberSupplier_get_implementation", com_sun_star_i18n_NativeNumberSupplier_get_implementation },
+ { "com_sun_star_i18n_NumberFormatCodeMapper_get_implementation", com_sun_star_i18n_NumberFormatCodeMapper_get_implementation },
+ { "com_sun_star_i18n_Transliteration_get_implementation", com_sun_star_i18n_Transliteration_get_implementation },
+ { "com_sun_star_drawing_EnhancedCustomShapeEngine_get_implementation", com_sun_star_drawing_EnhancedCustomShapeEngine_get_implementation },
+ { "com_sun_star_drawing_SvxShapeCollection_get_implementation", com_sun_star_drawing_SvxShapeCollection_get_implementation },
+ { "SfxDocumentMetaData_get_implementation", SfxDocumentMetaData_get_implementation },
+ { "com_sun_star_animations_AnimateColor_get_implementation", com_sun_star_animations_AnimateColor_get_implementation },
+ { "com_sun_star_animations_AnimateMotion_get_implementation", com_sun_star_animations_AnimateMotion_get_implementation },
+ { "com_sun_star_animations_AnimateSet_get_implementation", com_sun_star_animations_AnimateSet_get_implementation },
+ { "com_sun_star_animations_AnimateTransform_get_implementation", com_sun_star_animations_AnimateTransform_get_implementation },
+ { "com_sun_star_animations_Animate_get_implementation", com_sun_star_animations_Animate_get_implementation },
+ { "com_sun_star_animations_Audio_get_implementation", com_sun_star_animations_Audio_get_implementation },
+ { "com_sun_star_animations_Command_get_implementation", com_sun_star_animations_Command_get_implementation },
+ { "com_sun_star_animations_IterateContainer_get_implementation", com_sun_star_animations_IterateContainer_get_implementation },
+ { "com_sun_star_animations_ParallelTimeContainer_get_implementation", com_sun_star_animations_ParallelTimeContainer_get_implementation },
+ { "com_sun_star_animations_SequenceTimeContainer_get_implementation", com_sun_star_animations_SequenceTimeContainer_get_implementation },
+ { "com_sun_star_animations_TransitionFilter_get_implementation", com_sun_star_animations_TransitionFilter_get_implementation },
+ { "com_sun_star_comp_comphelper_OPropertyBag", com_sun_star_comp_comphelper_OPropertyBag },
+ { "com_sun_star_comp_uui_UUIInteractionHandler_get_implementation", com_sun_star_comp_uui_UUIInteractionHandler_get_implementation },
+ { "emfio_emfreader_XEmfParser_get_implementation", emfio_emfreader_XEmfParser_get_implementation},
+ { "unoxml_rdfRepository_get_implementation", unoxml_rdfRepository_get_implementation },
+ { "unoxml_CURI_get_implementation", unoxml_CURI_get_implementation },
+ { "unoxml_CLiteral_get_implementation", unoxml_CLiteral_get_implementation },
+ { "unoxml_CBlankNode_get_implementation", unoxml_CBlankNode_get_implementation },
+ { "unoxml_CXPathAPI_get_implementation", unoxml_CXPathAPI_get_implementation },
+ { "unoxml_CSAXDocumentBuilder_get_implementation", unoxml_CSAXDocumentBuilder_get_implementation },
+ { "unoxml_CDocumentBuilder_get_implementation", unoxml_CDocumentBuilder_get_implementation },
+ { "linguistic_ConvDicList_get_implementation", linguistic_ConvDicList_get_implementation },
+ { "linguistic_DicList_get_implementation", linguistic_DicList_get_implementation },
+ { "linguistic_LinguProps_get_implementation", linguistic_LinguProps_get_implementation },
+ { "linguistic_LngSvcMgr_get_implementation", linguistic_LngSvcMgr_get_implementation },
+ { "linguistic_GrammarCheckingIterator_get_implementation", linguistic_GrammarCheckingIterator_get_implementation },
+ { "sd_DrawingDocument_get_implementation", sd_DrawingDocument_get_implementation },
+ { "com_sun_star_comp_Draw_DrawingModule_get_implementation", com_sun_star_comp_Draw_DrawingModule_get_implementation },
+ { "sd_PresentationDocument_get_implementation", sd_PresentationDocument_get_implementation },
+ { "com_sun_star_comp_Draw_PresenterHelper_get_implementation", com_sun_star_comp_Draw_PresenterHelper_get_implementation },
+ { "com_sun_star_comp_Draw_PresenterPreviewCache_get_implementation", com_sun_star_comp_Draw_PresenterPreviewCache_get_implementation },
+ { "com_sun_star_comp_Draw_PresenterTextView_get_implementation", com_sun_star_comp_Draw_PresenterTextView_get_implementation },
+ { "com_sun_star_comp_Draw_SlideRenderer_get_implementation", com_sun_star_comp_Draw_SlideRenderer_get_implementation },
+ { "com_sun_star_comp_Draw_SlideSorter_get_implementation", com_sun_star_comp_Draw_SlideSorter_get_implementation },
+ { "com_sun_star_comp_Draw_framework_configuration_Configuration_get_implementation", com_sun_star_comp_Draw_framework_configuration_Configuration_get_implementation },
+ { "com_sun_star_comp_draw_SdHtmlOptionsDialog_get_implementation", com_sun_star_comp_draw_SdHtmlOptionsDialog_get_implementation },
+ { "com_sun_star_comp_sd_InsertSlideController_get_implementation", com_sun_star_comp_sd_InsertSlideController_get_implementation },
+ { "com_sun_star_comp_sd_SlideLayoutController_get_implementation", com_sun_star_comp_sd_SlideLayoutController_get_implementation },
+ { "com_sun_star_comp_sd_DisplayModeController_get_implementation", com_sun_star_comp_sd_DisplayModeController_get_implementation },
+ { "ucb_UcbCommandEnvironment_get_implementation", ucb_UcbCommandEnvironment_get_implementation, },
+ { "ucb_UcbContentProviderProxyFactory_get_implementation", ucb_UcbContentProviderProxyFactory_get_implementation },
+ { "ucb_UcbPropertiesManager_get_implementation", ucb_UcbPropertiesManager_get_implementation },
+ { "ucb_UcbStore_get_implementation", ucb_UcbStore_get_implementation },
+ { "ucb_UniversalContentBroker_get_implementation", ucb_UniversalContentBroker_get_implementation },
+ { "ucb_OFileAccess_get_implementation", ucb_OFileAccess_get_implementation },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" void* SdCreateDialogFactory()
+{
+ return nullptr;
+}
+
+extern "C" bool TestImportCGM(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportCGM(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/cgmfuzzer.options b/vcl/workben/cgmfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/cgmfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/cnttype/makefile.mk b/vcl/workben/cnttype/makefile.mk
new file mode 100644
index 000000000..ad1e635eb
--- /dev/null
+++ b/vcl/workben/cnttype/makefile.mk
@@ -0,0 +1,44 @@
+#
+# 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 .
+#
+
+PRJ=..$/..$/..
+
+PRJNAME=dtrans
+TARGET=testcnttype
+LIBTARGET=NO
+TARGETTYPE=CUI
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGS+=-GX
+
+# --- Files --------------------------------------------------------
+
+OBJFILES= $(OBJ)$/testcnttype.obj
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJ)$/testcnttype.obj
+
+APP1STDLIBS= $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : target.mk
+
diff --git a/vcl/workben/cnttype/testcnttype.cxx b/vcl/workben/cnttype/testcnttype.cxx
new file mode 100644
index 000000000..a148348ff
--- /dev/null
+++ b/vcl/workben/cnttype/testcnttype.cxx
@@ -0,0 +1,186 @@
+/* -*- 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 <cppuhelper/servicefactory.hxx>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <com/sun/star/datatransfer/XMimeContentType.hpp>
+#include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <osl/diagnose.h>
+
+#include <stdio.h>
+
+#include <vector>
+
+// my defines
+
+#define TEST_CLIPBOARD
+#define RDB_SYSPATH "d:\\projects\\src621\\dtrans\\wntmsci7\\bin\\applicat.rdb"
+
+// namespaces
+
+using namespace ::std;
+using namespace ::cppu;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+
+void ShutdownServiceMgr( Reference< XMultiServiceFactory >& SrvMgr )
+{
+ // Cast factory to XComponent
+ Reference< XComponent > xComponent( SrvMgr, UNO_QUERY );
+
+ if ( !xComponent.is() )
+ OSL_FAIL("Error shutting down");
+
+ // Dispose and clear factory
+ xComponent->dispose();
+ SrvMgr.clear();
+}
+
+sal_Bool readCntTypesFromFileIntoVector( char* fname, vector< string >& vecData )
+{
+ FILE* fstream;
+
+ fstream = fopen( fname, "r+" );
+ if ( !fstream )
+ return sal_False;
+
+ // set pointer to file start
+ fseek( fstream, 0, SEEK_SET );
+
+ char line[1024];
+ while ( fscanf( fstream, "%1023[^\n]s", line ) != EOF )
+ {
+ vecData.push_back( line );
+ fgetc( fstream );
+ }
+
+ fclose( fstream );
+
+ return sal_True;
+}
+
+sal_Bool processCntTypesAndWriteResultIntoFile( char* fname, vector< string >& vecData, Reference< XMimeContentTypeFactory > cnttypeFactory )
+{
+ FILE* fstream;
+
+ fstream = fopen( fname, "w" );
+ if ( !fstream )
+ return sal_False;
+
+ // set pointer to file start
+ fseek( fstream, 0, SEEK_SET );
+
+ for ( const auto& rData : vecData )
+ {
+ try
+ {
+ fprintf( fstream, "Read: %s\n", rData.c_str( ) );
+
+ Reference< XMimeContentType > xMCntTyp = cnttypeFactory->createMimeContentType( OUString::createFromAscii( rData.c_str( ) ) );
+
+ fwprintf( fstream, OUString("Type: %s\n"), xMCntTyp->getMediaType( ).getStr( ) );
+ fwprintf( fstream, OUString("Subtype: %s\n"), xMCntTyp->getMediaSubtype( ).getStr( ) );
+
+ Sequence< OUString > seqParam = xMCntTyp->getParameters( );
+ sal_Int32 nParams = seqParam.getLength( );
+
+ for ( sal_Int32 i = 0; i < nParams; i++ )
+ {
+ fwprintf( fstream, OUString("PName: %s\n"), seqParam[i].getStr( ) );
+ fwprintf( fstream, OUString("PValue: %s\n"), xMCntTyp->getParameterValue( seqParam[i] ).getStr( ) );
+ }
+ }
+ catch( IllegalArgumentException& ex )
+ {
+ fwprintf( fstream, OUString("Read incorrect content type!\n\n") );
+ }
+ catch( NoSuchElementException& )
+ {
+ fwprintf( fstream, OUString("Value of parameter not available\n") );
+ }
+ catch( ... )
+ {
+ fwprintf( fstream, OUString("Unknown error!\n\n") );
+ }
+
+ fwprintf( fstream, OUString("\n#############################################\n\n") );
+ }
+
+ fclose( fstream );
+
+ return sal_True;
+}
+
+// main
+
+int SAL_CALL main( int nArgc, char* argv[] )
+{
+ if ( nArgc != 3 )
+ printf( "Start with: testcnttype input-file output-file\n" );
+
+ // get the global service-manager
+
+ Reference< XMultiServiceFactory > g_xFactory( createRegistryServiceFactory( RDB_SYSPATH ) );
+
+ // Print a message if an error occurred.
+ if ( !g_xFactory.is( ) )
+ {
+ OSL_FAIL("Can't create RegistryServiceFactory");
+ return(-1);
+ }
+
+ vector< string > vecCntTypes;
+
+ // open input-file and read the data
+ if ( !readCntTypesFromFileIntoVector( argv[1], vecCntTypes ) )
+ {
+ printf( "Can't open input file" );
+ ShutdownServiceMgr( g_xFactory );
+ }
+
+ Reference< XMimeContentTypeFactory >
+ xMCntTypeFactory( g_xFactory->createInstance("com.sun.star.datatransfer.MimeContentTypeFactory"), UNO_QUERY );
+
+ if ( !xMCntTypeFactory.is( ) )
+ {
+ OSL_FAIL( "Error creating MimeContentTypeFactory Service" );
+ return(-1);
+ }
+
+ if ( !processCntTypesAndWriteResultIntoFile( argv[2], vecCntTypes, xMCntTypeFactory ) )
+ {
+ printf( "Can't open output file" );
+ ShutdownServiceMgr( g_xFactory );
+ }
+
+ // shutdown the service manager
+
+ ShutdownServiceMgr( g_xFactory );
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/commonfuzzer.hxx b/vcl/workben/commonfuzzer.hxx
new file mode 100644
index 000000000..c9afd6555
--- /dev/null
+++ b/vcl/workben/commonfuzzer.hxx
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/main.h>
+#include <tools/extendapplicationenvironment.hxx>
+
+#include <cppuhelper/bootstrap.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <unotools/configmgr.hxx>
+#include <rtl/bootstrap.hxx>
+#include <rtl/strbuf.hxx>
+#include <osl/file.hxx>
+#include <osl/process.h>
+#include <vcl/graph.hxx>
+#include <vcl/print.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wmf.hxx>
+#include <unistd.h>
+#include <stdlib.h>
+#include "headless/svpgdi.hxx"
+#include "unx/fontmanager.hxx"
+#include "unx/glyphcache.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace cppu;
+
+namespace
+{
+ OUString getExecutableDir()
+ {
+ OUString uri;
+ if (osl_getExecutableFile(&uri.pData) != osl_Process_E_None) {
+ abort();
+ }
+ sal_Int32 lastDirSeparatorPos = uri.lastIndexOf('/');
+ if (lastDirSeparatorPos >= 0) {
+ uri = uri.copy(0, lastDirSeparatorPos + 1);
+ }
+ return uri;
+ }
+
+ OUString getExecutableName()
+ {
+ OUString uri;
+ if (osl_getExecutableFile(&uri.pData) != osl_Process_E_None) {
+ abort();
+ }
+ return uri.copy(uri.lastIndexOf('/') + 1);
+ }
+
+ void setFontConfigConf(const OUString &execdir)
+ {
+ osl::File aFontConfig("file:///tmp/wmffuzzerfonts.conf");
+ if (aFontConfig.open(osl_File_OpenFlag_Create | osl_File_OpenFlag_Write) == osl::File::E_None)
+ {
+ OUString sExecDir;
+ osl::FileBase::getSystemPathFromFileURL(execdir, sExecDir);
+
+ OStringBuffer aBuffer("<?xml version=\"1.0\"?>\n<fontconfig><dir>");
+ aBuffer.append(OUStringToOString(sExecDir, osl_getThreadTextEncoding()))
+ .append(OUStringToOString(getExecutableName(), osl_getThreadTextEncoding())).append(".fonts");
+ aBuffer.append("</dir><cachedir>/tmp/cache/fontconfig</cachedir></fontconfig>");
+ OString aConf = aBuffer.makeStringAndClear();
+ sal_uInt64 aBytesWritten;
+ aFontConfig.write(aConf.getStr(), aConf.getLength(), aBytesWritten);
+ assert(aBytesWritten == aConf.getLength());
+ }
+ setenv("FONTCONFIG_FILE", "/tmp/wmffuzzerfonts.conf", 0);
+ }
+}
+
+extern "C"
+{
+ __attribute__((weak)) void __lsan_disable();
+ __attribute__((weak)) void __lsan_enable();
+}
+
+void CommonInitialize(int *argc, char ***argv)
+{
+ setenv("SAL_USE_VCLPLUGIN", "svp", 1);
+ setenv("JPEGMEM", "768M", 1);
+ setenv("JSIMD_FORCENONE", "1", 1); // https://github.com/libjpeg-turbo/libjpeg-turbo/issues/253
+ setenv("SC_MAX_MATRIX_ELEMENTS", "60000000", 1);
+ setenv("SC_NO_THREADED_CALCULATION", "1", 1);
+ setenv("SAL_DISABLE_PRINTERLIST", "1", 1);
+ setenv("SAL_DISABLE_DEFAULTPRINTER", "1", 1);
+ setenv("SAL_NO_FONT_LOOKUP", "1", 1);
+ setenv("SAX_DISABLE_THREADS", "1", 1);
+
+ //allow bubbling of max input len to fuzzer targets
+ int nMaxLen = 0;
+ for (int i = 0; i < *argc; ++i)
+ {
+ if (strncmp((*argv)[i], "-max_len=", 9) == 0)
+ nMaxLen = atoi((*argv)[i] + 9);
+ }
+ setenv("FUZZ_MAX_INPUT_LEN", "1", nMaxLen);
+
+ osl_setCommandArgs(*argc, *argv);
+
+ OUString sExecDir = getExecutableDir();
+ rtl::Bootstrap::set("BRAND_BASE_DIR", sExecDir);
+ setFontConfigConf(sExecDir);
+
+ tools::extendApplicationEnvironment();
+
+ Reference< XComponentContext > xContext =
+ defaultBootstrap_InitialComponentContext(sExecDir + getExecutableName() + ".unorc");
+ Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY );
+ if( !xServiceManager.is() )
+ Application::Abort( "Failed to bootstrap" );
+ comphelper::setProcessServiceFactory( xServiceManager );
+ utl::ConfigManager::EnableFuzzing();
+ Application::EnableHeadlessMode(false);
+ InitVCL();
+
+ //we don't have a de-init, so inside this leak disabled region...
+ //get the font info
+ psp::PrintFontManager::get();
+ //get the printer info
+ Printer::GetPrinterQueues();
+
+ //https://github.com/google/oss-fuzz/issues/1449
+ //https://github.com/google/oss-fuzz/issues/5441
+ //release the solarmutex so a fork can acquire it which should
+ //allow these fuzzers to work without AFL_DRIVER_DONT_DEFER set
+ //removing the confusion of #5441 and the need for AFL_DRIVER_DONT_DEFER
+ //in .options files
+ Application::ReleaseSolarMutex();
+}
+
+void TypicalFuzzerInitialize(int *argc, char ***argv)
+{
+ if (__lsan_disable)
+ __lsan_disable();
+
+ CommonInitialize(argc, argv);
+
+ if (__lsan_enable)
+ __lsan_enable();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/dbffuzzer.cxx b/vcl/workben/dbffuzzer.cxx
new file mode 100644
index 000000000..089e1f397
--- /dev/null
+++ b/vcl/workben/dbffuzzer.cxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#include <com/sun/star/ucb/XUniversalContentBroker.hpp>
+#include "commonfuzzer.hxx"
+
+extern "C" void* ScCreateDialogFactory() { return nullptr; }
+
+extern "C" bool TestImportDBF(SvStream& rStream);
+
+extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
+{
+ if (__lsan_disable)
+ __lsan_disable();
+
+ CommonInitialize(argc, argv);
+
+ // initialise unconfigured UCB:
+ css::uno::Reference<css::ucb::XUniversalContentBroker> xUcb(
+ comphelper::getProcessServiceFactory()->createInstance(
+ "com.sun.star.ucb.UniversalContentBroker"),
+ css::uno::UNO_QUERY_THROW);
+ css::uno::Sequence<css::uno::Any> aArgs{ css::uno::Any(OUString("NoConfig")) };
+ css::uno::Reference<css::ucb::XContentProvider> xFileProvider(
+ comphelper::getProcessServiceFactory()->createInstanceWithArguments(
+ "com.sun.star.ucb.FileContentProvider", aArgs),
+ css::uno::UNO_QUERY_THROW);
+ xUcb->registerContentProvider(xFileProvider, "file", true);
+
+ if (__lsan_enable)
+ __lsan_enable();
+
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportDBF(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/dbffuzzer.options b/vcl/workben/dbffuzzer.options
new file mode 100644
index 000000000..f41b545a4
--- /dev/null
+++ b/vcl/workben/dbffuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 32768
diff --git a/vcl/workben/diffuzzer.cxx b/vcl/workben/diffuzzer.cxx
new file mode 100644
index 000000000..60d1190fc
--- /dev/null
+++ b/vcl/workben/diffuzzer.cxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" {
+void* i18npool_component_getFactory(const char*, void*, void*);
+
+void* com_sun_star_i18n_LocaleDataImpl_get_implementation(void*, void*);
+void* com_sun_star_i18n_BreakIterator_Unicode_get_implementation(void*, void*);
+void* com_sun_star_i18n_BreakIterator_get_implementation(void*, void*);
+void* com_sun_star_comp_framework_Desktop_get_implementation(void*, void*);
+void* com_sun_star_i18n_CharacterClassification_Unicode_get_implementation(void*, void*);
+void* com_sun_star_i18n_CharacterClassification_get_implementation(void*, void*);
+void* com_sun_star_i18n_Collator_get_implementation(void*, void*);
+void* com_sun_star_i18n_NativeNumberSupplier_get_implementation(void*, void*);
+void* com_sun_star_i18n_NumberFormatCodeMapper_get_implementation(void*, void*);
+void* com_sun_star_i18n_Transliteration_get_implementation(void*, void*);
+void* i18npool_CalendarImpl_get_implementation(void*, void*);
+}
+
+const lib_to_factory_mapping* lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[]
+ = { { "libi18npoollo.a", i18npool_component_getFactory }, { 0, 0 } };
+
+ return map;
+}
+
+const lib_to_constructor_mapping* lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[]
+ = { { "com_sun_star_i18n_LocaleDataImpl_get_implementation",
+ com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation",
+ com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation",
+ com_sun_star_i18n_BreakIterator_get_implementation },
+ { "com_sun_star_comp_framework_Desktop_get_implementation",
+ com_sun_star_comp_framework_Desktop_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_Unicode_get_implementation",
+ com_sun_star_i18n_CharacterClassification_Unicode_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_get_implementation",
+ com_sun_star_i18n_CharacterClassification_get_implementation },
+ { "com_sun_star_i18n_Collator_get_implementation",
+ com_sun_star_i18n_Collator_get_implementation },
+ { "com_sun_star_i18n_NativeNumberSupplier_get_implementation",
+ com_sun_star_i18n_NativeNumberSupplier_get_implementation },
+ { "com_sun_star_i18n_NumberFormatCodeMapper_get_implementation",
+ com_sun_star_i18n_NumberFormatCodeMapper_get_implementation },
+ { "com_sun_star_i18n_Transliteration_get_implementation",
+ com_sun_star_i18n_Transliteration_get_implementation },
+ { "i18npool_CalendarImpl_get_implementation",
+ i18npool_CalendarImpl_get_implementation },
+ { 0, 0 } };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*) { return nullptr; }
+
+extern "C" void* ScCreateDialogFactory() { return nullptr; }
+
+extern "C" bool TestImportDIF(SvStream& rStream);
+
+extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportDIF(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/diffuzzer.options b/vcl/workben/diffuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/diffuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/docxfuzzer.cxx b/vcl/workben/docxfuzzer.cxx
new file mode 100644
index 000000000..73fc198bd
--- /dev/null
+++ b/vcl/workben/docxfuzzer.cxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+extern "C" void* SwCreateDialogFactory()
+{
+ return nullptr;
+}
+
+extern "C" bool TestImportDOCX(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportDOCX(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/docxfuzzer.options b/vcl/workben/docxfuzzer.options
new file mode 100644
index 000000000..e8c2b812b
--- /dev/null
+++ b/vcl/workben/docxfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 98304
diff --git a/vcl/workben/dtrans/makefile.mk b/vcl/workben/dtrans/makefile.mk
new file mode 100644
index 000000000..588d4685a
--- /dev/null
+++ b/vcl/workben/dtrans/makefile.mk
@@ -0,0 +1,44 @@
+#
+# 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 .
+#
+
+PRJ=..$/..
+
+PRJNAME= dtrans
+TARGET= test_dtrans
+
+LIBTARGET=NO
+TARGETTYPE=CUI
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+APP1TARGET= $(TARGET)
+APP1OBJS= \
+ $(OBJ)$/test_dtrans.obj
+
+APP1STDLIBS= \
+ $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB)
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : target.mk
+
diff --git a/vcl/workben/dtrans/test_dtrans.cxx b/vcl/workben/dtrans/test_dtrans.cxx
new file mode 100644
index 000000000..f531f12fd
--- /dev/null
+++ b/vcl/workben/dtrans/test_dtrans.cxx
@@ -0,0 +1,414 @@
+/* -*- 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 <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardManager.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <rtl/ustring.hxx>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+// my defines
+
+#ifdef UNX
+#define PATH_SEPARATOR '/'
+#else
+#define PATH_SEPARATOR '\\'
+#endif
+
+#define ENSURE( a, b ) if( !a ) { fprintf( stderr, b "\n" ); exit( -1 ); }
+#define TEST( a, b ) fprintf( stderr, "Testing " a ); fprintf( stderr, b ? "passed\n" : "FAILED\n" )
+#define PERFORM( a, b ) fprintf( stderr, "Performing " a); b; fprintf( stderr, "done\n" )
+#define TRACE( a ) fprintf( stderr, a )
+
+// namespaces
+
+using namespace ::std;
+using namespace ::cppu;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::clipboard;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+
+// globals
+
+const char * app = NULL;
+
+// ClipboardOwner
+
+class ClipboardOwner : public WeakImplHelper< XClipboardOwner >
+{
+ Reference< XClipboard > m_xClipboard;
+ Reference< XTransferable > m_xTransferable;
+
+ sal_uInt32 m_nReceivedLostOwnerships;
+
+public:
+ ClipboardOwner();
+
+ // XClipboardOwner
+
+ virtual void SAL_CALL lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans ) throw(RuntimeException);
+
+ sal_uInt32 receivedLostOwnerships() { return m_nReceivedLostOwnerships; };
+ Reference< XClipboard > lostOwnershipClipboardValue() { return m_xClipboard; }
+ Reference< XTransferable > lostOwnershipTransferableValue() { return m_xTransferable; };
+};
+
+// ctor
+
+ClipboardOwner::ClipboardOwner():
+ m_nReceivedLostOwnerships( 0 )
+{
+}
+
+// lostOwnership
+
+void SAL_CALL ClipboardOwner::lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans )
+ throw(RuntimeException)
+{
+ m_nReceivedLostOwnerships++;
+ m_xClipboard = xClipboard;
+ m_xTransferable = xTrans;
+}
+
+// ClipboardListener
+
+class ClipboardListener : public WeakImplHelper< XClipboardListener >
+{
+ Reference< XClipboard > m_xClipboard;
+ Reference< XTransferable > m_xTransferable;
+
+ sal_uInt32 m_nReceivedChangedContentsEvents;
+
+public:
+ ClipboardListener();
+
+ // XClipboardOwner
+
+ virtual void SAL_CALL changedContents( const ClipboardEvent& event ) throw(RuntimeException);
+
+ // XEventListener
+
+ virtual void SAL_CALL disposing( const EventObject& event ) throw(RuntimeException);
+
+ sal_uInt32 receivedChangedContentsEvents() { return m_nReceivedChangedContentsEvents; };
+ Reference< XClipboard > changedContentsEventClipboardValue() { return m_xClipboard; }
+ Reference< XTransferable > changedContentsEventTransferableValue() { return m_xTransferable; };
+};
+
+// ctor
+
+ClipboardListener::ClipboardListener():
+ m_nReceivedChangedContentsEvents( 0 )
+{
+}
+
+// changedContents
+
+void SAL_CALL ClipboardListener::changedContents( const ClipboardEvent& event )
+ throw(RuntimeException)
+{
+ m_nReceivedChangedContentsEvents++;
+ m_xClipboard.set(event.Source, UNO_QUERY);
+ m_xTransferable = event.Contents;
+}
+
+// disposing
+
+void SAL_CALL ClipboardListener::disposing( const EventObject& event )
+ throw(RuntimeException)
+{
+}
+
+// StringTransferable
+
+class StringTransferable : public WeakImplHelper< XClipboardOwner, XTransferable >
+{
+public:
+ StringTransferable( );
+
+ // XTransferable
+
+ virtual Any SAL_CALL getTransferData( const DataFlavor& aFlavor ) throw(UnsupportedFlavorException, IOException, RuntimeException);
+ virtual Sequence< DataFlavor > SAL_CALL getTransferDataFlavors( ) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL isDataFlavorSupported( const DataFlavor& aFlavor ) throw(RuntimeException);
+
+ // XClipboardOwner
+
+ virtual void SAL_CALL lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans ) throw(RuntimeException);
+
+ sal_Bool receivedLostOwnership() { return m_receivedLostOwnership; };
+ void clearReceivedLostOwnership() { m_receivedLostOwnership = sal_False; };
+
+private:
+ Sequence< DataFlavor > m_seqDFlv;
+ OUString m_Data;
+ sal_Bool m_receivedLostOwnership;
+};
+
+// ctor
+
+StringTransferable::StringTransferable( ) :
+ m_seqDFlv( 1 ),
+ m_receivedLostOwnership( sal_False ),
+ m_Data( OUString("clipboard test content") )
+{
+ DataFlavor df;
+
+ /*
+ df.MimeType = L"text/plain; charset=unicode";
+ df.DataType = cppu::UnoType<OUString>::get();
+
+ m_seqDFlv[0] = df;
+ */
+
+ //df.MimeType = L"text/plain; charset=windows1252";
+ df.MimeType = "text/html";
+ df.DataType = cppu::UnoType<Sequence< sal_Int8 >>::get();
+
+ m_seqDFlv[0] = df;
+}
+
+// getTransferData
+
+Any SAL_CALL StringTransferable::getTransferData( const DataFlavor& aFlavor )
+ throw(UnsupportedFlavorException, IOException, RuntimeException)
+{
+ Any anyData;
+
+ /*if ( aFlavor == m_seqDFlv[0] )
+ {
+ anyData = makeAny( m_Data );
+ } */
+
+ return anyData;
+}
+
+// getTransferDataFlavors
+
+Sequence< DataFlavor > SAL_CALL StringTransferable::getTransferDataFlavors( )
+ throw(RuntimeException)
+{
+ return m_seqDFlv;
+}
+
+// isDataFlavorSupported
+
+sal_Bool SAL_CALL StringTransferable::isDataFlavorSupported( const DataFlavor& aFlavor )
+ throw(RuntimeException)
+{
+ sal_Int32 nLength = m_seqDFlv.getLength( );
+ sal_Bool bRet = sal_False;
+
+// for ( sal_Int32 i = 0; i < nLength; ++i )
+// {
+// if ( m_seqDFlv[i] == aFlavor )
+// {
+// bRet = sal_True;
+// break;
+// }
+// }
+
+ return bRet;
+}
+
+// lostOwnership
+
+void SAL_CALL StringTransferable::lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans )
+ throw(RuntimeException)
+{
+ m_receivedLostOwnership = sal_True;
+}
+
+// main
+
+int SAL_CALL main( int argc, const char* argv[] )
+{
+ OUString aRegistry;
+
+ // check command line parameters
+
+ if ( NULL == ( app = strrchr( argv[0], PATH_SEPARATOR ) ) )
+ app = argv[0];
+ else
+ app++;
+
+ for( int n = 1; n < argc; n++ )
+ {
+ if( strncmp( argv[n], "-r", 2 ) == 0 )
+ {
+ if( strlen( argv[n] ) > 2 )
+ aRegistry = OUString::createFromAscii( argv[n] + 2 );
+ else if ( n + 1 < argc )
+ aRegistry = OUString::createFromAscii( argv[++n] );
+ }
+ }
+
+ if( aRegistry.isEmpty( ) )
+ fprintf( stderr, "Usage: %s -r full-path-to-applicat.rdb\n", app );
+
+ // create service manager
+
+ Reference< XMultiServiceFactory > xServiceManager;
+
+ try
+ {
+ xServiceManager = createRegistryServiceFactory( aRegistry, sal_True );
+ ENSURE( xServiceManager.is(), "*** ERROR *** service manager could not be created." );
+
+ // create an instance of GenericClipboard service
+
+ Sequence< Any > arguments(1);
+ arguments[0] = makeAny( OUString("generic") );
+
+ Reference< XClipboard > xClipboard( xServiceManager->createInstanceWithArguments(
+ "com.sun.star.datatransfer.clipboard.GenericClipboard",
+ arguments ), UNO_QUERY );
+
+ ENSURE( xClipboard.is(), "*** ERROR *** generic clipboard service could not be created." );
+
+ Reference< XClipboardNotifier > xClipboardNotifier( xClipboard, UNO_QUERY );
+ Reference< XClipboardListener > xClipboardListener = new ClipboardListener();
+ ClipboardListener * pListener = (ClipboardListener *) xClipboardListener.get();
+
+ if( xClipboardNotifier.is() )
+ xClipboardNotifier->addClipboardListener( xClipboardListener );
+
+ // run various tests on clipboard implementation
+
+ TRACE( "\n*** testing generic clipboard service ***\n" );
+
+ Reference< XTransferable > xContents = new StringTransferable();
+ Reference< XClipboardOwner > xOwner = new ClipboardOwner();
+ ClipboardOwner *pOwner = (ClipboardOwner *) xOwner.get();
+
+ TEST( "initial contents (none): ", xClipboard->getContents().is() == sal_False );
+
+ PERFORM( "update on contents with clipboard owner: ", xClipboard->setContents( xContents, xOwner ) );
+ TEST( "current clipboard contents: ", xContents == xClipboard->getContents() );
+
+ if( xClipboardNotifier.is() )
+ {
+ TEST( "if received changedContents notifications: ", pListener->receivedChangedContentsEvents() > 0 );
+ TEST( "if received exactly 1 changedContents notification: ", pListener->receivedChangedContentsEvents() == 1 );
+ TEST( "if received changedContents notification for correct clipboard: ", pListener->changedContentsEventClipboardValue() == xClipboard );
+ TEST( "if received changedContents notification for correct clipboard: ", pListener->changedContentsEventTransferableValue() == xContents );
+ }
+
+ PERFORM( "update on contents without data (clear): ", xClipboard->setContents( Reference< XTransferable >(), Reference< XClipboardOwner >() ) );
+ TEST( "if received lostOwnership message(s): ", pOwner->receivedLostOwnerships() > 0 );
+ TEST( "if received exactly 1 lostOwnership message: ", pOwner->receivedLostOwnerships() == 1 );
+ TEST( "if received lostOwnership message for the correct clipboard: ", pOwner->lostOwnershipClipboardValue() == xClipboard );
+ TEST( "if received lostOwnership message for the correct transferable: ", pOwner->lostOwnershipTransferableValue() == xContents );
+ TEST( "current clipboard contents (none): ", xClipboard->getContents().is() == sal_False );
+
+ if( xClipboardNotifier.is() )
+ {
+ TEST( "if received changedContents notifications: ", pListener->receivedChangedContentsEvents() > 1 );
+ TEST( "if received exactly 1 changedContents notification: ", pListener->receivedChangedContentsEvents() == 2 );
+ TEST( "if received changedContents notification for correct clipboard: ", pListener->changedContentsEventClipboardValue() == xClipboard );
+ TEST( "if received changedContents notification for correct transferable: ", ! pListener->changedContentsEventTransferableValue().is() );
+ }
+
+ PERFORM( "update on contents without clipboard owner: ", xClipboard->setContents( xContents, Reference< XClipboardOwner >() ) );
+ TEST( "that no further lostOwnership messages were received: ", pOwner->receivedLostOwnerships() == 1 );
+ TEST( "current clipboard contents: ", xContents == xClipboard->getContents() );
+
+ if( xClipboardNotifier.is() )
+ {
+ TEST( "if received changedContents notifications: ", pListener->receivedChangedContentsEvents() > 2 );
+ TEST( "if received exactly 1 changedContents notification: ", pListener->receivedChangedContentsEvents() == 3 );
+ TEST( "if received changedContents notification for correct clipboard: ", pListener->changedContentsEventClipboardValue() == xClipboard );
+ TEST( "if received changedContents notification for correct transferable: ", pListener->changedContentsEventTransferableValue() == xContents );
+ }
+
+ PERFORM( "update on contents without data (clear): ", xClipboard->setContents( Reference< XTransferable >(), Reference< XClipboardOwner >() ) );
+ TEST( "that no further lostOwnership messages were received: ", pOwner->receivedLostOwnerships() == 1 );
+ TEST( "current clipboard contents (none): ", xClipboard->getContents().is() == sal_False );
+
+ if( xClipboardNotifier.is() )
+ {
+ TEST( "if received changedContents notifications: ", pListener->receivedChangedContentsEvents() > 3 );
+ TEST( "if received exactly 1 changedContents notification: ", pListener->receivedChangedContentsEvents() == 4 );
+ TEST( "if received changedContents notification for correct clipboard: ", pListener->changedContentsEventClipboardValue() == xClipboard );
+ TEST( "if received changedContents notification for correct transferable: ", ! pListener->changedContentsEventTransferableValue().is() );
+ }
+
+ // create an instance of ClipboardManager service
+
+ Reference< XClipboardManager > xClipboardManager( xServiceManager->createInstance(
+ "com.sun.star.datatransfer.clipboard.ClipboardManager" ), UNO_QUERY );
+
+ ENSURE( xClipboardManager.is(), "*** ERROR *** clipboard manager service could not be created." );
+
+ // run various tests on clipboard manager implementation
+
+ TRACE( "\n*** testing clipboard manager service ***\n" );
+
+ TEST( "initial number of clipboards (0): ", xClipboardManager->listClipboardNames().getLength() == 0 );
+ PERFORM( "insertion of generic clipboard: ", xClipboardManager->addClipboard( xClipboard ) );
+ TEST( "number of inserted clipboards (1): ", xClipboardManager->listClipboardNames().getLength() == 1 );
+ TEST( "name of inserted clipboard (generic): ", xClipboardManager->listClipboardNames()[0] == "generic" );
+ TEST( "inserted clipboard instance: ", xClipboardManager->getClipboard( OUString("generic") ) == xClipboard );
+ PERFORM( "removal of generic clipboard: ", xClipboardManager->removeClipboard( OUString("generic") ) );
+ TEST( "number of inserted clipboards (0): ", xClipboardManager->listClipboardNames().getLength() == 0 );
+ TRACE( "Testing inserted clipboard instance (none): " );
+ try
+ {
+ xClipboardManager->getClipboard( OUString("generic") );
+ TRACE( "FAILED\n" );
+ }
+ catch (const NoSuchElementException&)
+ {
+ TRACE( "passed\n" );
+ }
+ }
+
+ catch (const Exception&)
+ {
+ ENSURE( sal_False, "*** ERROR *** exception caught." );
+ }
+
+ // shutdown the service manager
+
+ // query XComponent interface
+ Reference< XComponent > xComponent( xServiceManager, UNO_QUERY );
+
+ ENSURE( xComponent.is(), "*** ERROR *** service manager does not support XComponent." );
+
+ // Dispose and clear factory
+ xComponent->dispose();
+ xServiceManager.clear();
+
+ fprintf( stderr, "Done.\n" );
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/dxffuzzer.cxx b/vcl/workben/dxffuzzer.cxx
new file mode 100644
index 000000000..89d6e19a6
--- /dev/null
+++ b/vcl/workben/dxffuzzer.cxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+#include <filter/DxfReader.hxx>
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" {
+void * com_sun_star_i18n_LocaleDataImpl_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_get_implementation( void *, void * );
+void * com_sun_star_i18n_NativeNumberSupplier_get_implementation( void *, void * );
+void * com_sun_star_i18n_NumberFormatCodeMapper_get_implementation( void *, void * );
+}
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { "com_sun_star_i18n_LocaleDataImpl_get_implementation", com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation", com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation", com_sun_star_i18n_BreakIterator_get_implementation },
+ { "com_sun_star_i18n_NativeNumberSupplier_get_implementation", com_sun_star_i18n_NativeNumberSupplier_get_implementation },
+ { "com_sun_star_i18n_NumberFormatCodeMapper_get_implementation", com_sun_star_i18n_NumberFormatCodeMapper_get_implementation },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportDxfGraphic(aStream, aGraphic);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/dxffuzzer.options b/vcl/workben/dxffuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/dxffuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/epsfuzzer.cxx b/vcl/workben/epsfuzzer.cxx
new file mode 100644
index 000000000..66e9e380e
--- /dev/null
+++ b/vcl/workben/epsfuzzer.cxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+#include <filter/EpsReader.hxx>
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" {
+void * com_sun_star_i18n_LocaleDataImpl_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_get_implementation( void *, void * );
+void * com_sun_star_i18n_NativeNumberSupplier_get_implementation( void *, void * );
+void * com_sun_star_i18n_NumberFormatCodeMapper_get_implementation( void *, void * );
+}
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { "com_sun_star_i18n_LocaleDataImpl_get_implementation", com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation", com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation", com_sun_star_i18n_BreakIterator_get_implementation },
+ { "com_sun_star_i18n_NativeNumberSupplier_get_implementation", com_sun_star_i18n_NativeNumberSupplier_get_implementation },
+ { "com_sun_star_i18n_NumberFormatCodeMapper_get_implementation", com_sun_star_i18n_NumberFormatCodeMapper_get_implementation },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportEpsGraphic(aStream, aGraphic);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/epsfuzzer.options b/vcl/workben/epsfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/epsfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx
new file mode 100644
index 000000000..495034146
--- /dev/null
+++ b/vcl/workben/fftester.cxx
@@ -0,0 +1,545 @@
+/* -*- 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 .
+ */
+
+ /* e.g.
+ make
+ cp workdir/LinkTarget/Executable/fftester instdir/program
+ LD_LIBRARY_PATH=`pwd`/instdir/program instdir/program/fftester <foo> png
+ or on macOS
+ make
+ cp workdir/LinkTarget/Executable/fftester instdir/LibreOfficeDev.app/Contents/MacOS/
+ DYLD_LIBRARY_PATH=`pwd`/instdir/LibreOfficeDev.app/Contents/Frameworks instdir/LibreOfficeDev.app/Contents/MacOS/fftester <foo> png
+ */
+
+#include <sal/config.h>
+
+#include <string_view>
+
+#include <sal/main.h>
+#include <tools/extendapplicationenvironment.hxx>
+
+#include <cppuhelper/bootstrap.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#include <com/sun/star/ucb/XUniversalContentBroker.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <unotools/configmgr.hxx>
+#include <vcl/dibtools.hxx>
+#include <vcl/event.hxx>
+#include <vcl/graphicfilter.hxx>
+#include <vcl/filter/PngImageReader.hxx>
+#include <vcl/filter/SvmReader.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/wmf.hxx>
+#include <vcl/wrkwin.hxx>
+#include <fltcall.hxx>
+#include <filter/TiffReader.hxx>
+#include <filter/TgaReader.hxx>
+#include <filter/PictReader.hxx>
+#include <filter/MetReader.hxx>
+#include <filter/RasReader.hxx>
+#include <filter/PcxReader.hxx>
+#include <filter/EpsReader.hxx>
+#include <filter/PsdReader.hxx>
+#include <filter/PcdReader.hxx>
+#include <filter/PbmReader.hxx>
+#include <filter/DxfReader.hxx>
+#include <filter/WebpReader.hxx>
+#include <filter/XpmReader.hxx>
+#include <osl/file.hxx>
+#include <osl/module.hxx>
+#include <rtl/bootstrap.hxx>
+#include <tools/stream.hxx>
+#include <vcl/gdimtf.hxx>
+#include <fontsubset.hxx>
+
+#include "../source/filter/igif/gifread.hxx"
+#include "../source/filter/ixbm/xbmread.hxx"
+#include "../source/filter/jpeg/jpeg.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace cppu;
+
+typedef bool (*FFilterCall)(SvStream &rStream);
+
+#ifndef DISABLE_DYNLOADING
+namespace {
+
+FFilterCall load(std::u16string_view library, char const * function) {
+ OUString path = OUString::Concat("$LO_LIB_DIR/") + library;
+ rtl::Bootstrap::expandMacros(path); //TODO: check for failure
+ osl::Module aLibrary(path, SAL_LOADMODULE_LAZY);
+ auto const fn = reinterpret_cast<FFilterCall>(aLibrary.getFunctionSymbol(function));
+ aLibrary.release();
+ return fn;
+}
+
+}
+#endif
+
+SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
+{
+ int ret = -1;
+ try
+ {
+ if (argc < 3)
+ {
+ fprintf(stderr, "Usage: fftester <filename> <wmf|jpg>\n");
+ return -1;
+ }
+
+ setenv("SAL_USE_VCLPLUGIN", "svp", 1);
+ setenv("JPEGMEM", "768M", 1);
+ setenv("SC_MAX_MATRIX_ELEMENTS", "60000000", 1);
+ setenv("SC_NO_THREADED_CALCULATION", "1", 1);
+ setenv("SAL_DISABLE_PRINTERLIST", "1", 1);
+ setenv("SAL_DISABLE_DEFAULTPRINTER", "1", 1);
+ setenv("SAL_NO_FONT_LOOKUP", "1", 1);
+
+ OUString in(argv[1], strlen(argv[1]), RTL_TEXTENCODING_UTF8);
+ OUString out;
+ osl::File::getFileURLFromSystemPath(in, out);
+
+ tools::extendApplicationEnvironment();
+
+ Reference< XComponentContext > xContext = defaultBootstrap_InitialComponentContext();
+ Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY );
+ if( !xServiceManager.is() )
+ Application::Abort( "Failed to bootstrap" );
+ comphelper::setProcessServiceFactory( xServiceManager );
+ utl::ConfigManager::EnableFuzzing();
+
+ // initialise unconfigured UCB:
+ css::uno::Reference<css::ucb::XUniversalContentBroker> xUcb(comphelper::getProcessServiceFactory()->
+ createInstance("com.sun.star.ucb.UniversalContentBroker"), css::uno::UNO_QUERY_THROW);
+ css::uno::Sequence<css::uno::Any> aArgs{ css::uno::Any(OUString("NoConfig")) };
+ css::uno::Reference<css::ucb::XContentProvider> xFileProvider(comphelper::getProcessServiceFactory()->
+ createInstanceWithArguments("com.sun.star.ucb.FileContentProvider", aArgs), css::uno::UNO_QUERY_THROW);
+ xUcb->registerContentProvider(xFileProvider, "file", true);
+
+ Application::EnableHeadlessMode(false);
+ InitVCL();
+
+ if (strcmp(argv[2], "wmf") == 0 || strcmp(argv[2], "emf") == 0)
+ {
+ GDIMetaFile aGDIMetaFile;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ReadWindowMetafile(aFileStream, aGDIMetaFile));
+ }
+ else if (strcmp(argv[2], "jpg") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportJPEG(aFileStream, aGraphic, GraphicFilterImportFlags::NONE, nullptr));
+ }
+ else if (strcmp(argv[2], "gif") == 0)
+ {
+ SvFileStream aFileStream(out, StreamMode::READ);
+ Graphic aGraphic;
+ ret = static_cast<int>(ImportGIF(aFileStream, aGraphic));
+ }
+ else if (strcmp(argv[2], "xbm") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportXBM(aFileStream, aGraphic));
+ }
+ else if (strcmp(argv[2], "xpm") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportXPM(aFileStream, aGraphic));
+ }
+ else if (strcmp(argv[2], "png") == 0)
+ {
+ SvFileStream aFileStream(out, StreamMode::READ);
+ vcl::PngImageReader aReader(aFileStream);
+ ret = static_cast<int>(!aReader.read().IsEmpty());
+ }
+ else if (strcmp(argv[2], "bmp") == 0)
+ {
+ Bitmap aTarget;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ReadDIB(aTarget, aFileStream, true));
+ }
+ else if (strcmp(argv[2], "pcd") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportPcdGraphic(aFileStream, aGraphic, nullptr));
+ }
+ else if (strcmp(argv[2], "dxf") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportDxfGraphic(aFileStream, aGraphic));
+ }
+ else if (strcmp(argv[2], "met") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportMetGraphic(aFileStream, aGraphic));
+ }
+ else if ((strcmp(argv[2], "pbm") == 0) || strcmp(argv[2], "ppm") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportPbmGraphic(aFileStream, aGraphic));
+ }
+ else if (strcmp(argv[2], "psd") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportPsdGraphic(aFileStream, aGraphic));
+ }
+ else if (strcmp(argv[2], "eps") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportEpsGraphic(aFileStream, aGraphic));
+ }
+ else if (strcmp(argv[2], "pct") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportPictGraphic(aFileStream, aGraphic));
+ }
+ else if (strcmp(argv[2], "pcx") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportPcxGraphic(aFileStream, aGraphic));
+ }
+ else if (strcmp(argv[2], "ras") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportRasGraphic(aFileStream, aGraphic));
+ }
+ else if (strcmp(argv[2], "tga") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportTgaGraphic(aFileStream, aGraphic));
+ }
+ else if (strcmp(argv[2], "tif") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportTiffGraphicImport(aFileStream, aGraphic));
+ }
+ else if (strcmp(argv[2], "webp") == 0)
+ {
+ Graphic aGraphic;
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>(ImportWebpGraphic(aFileStream, aGraphic));
+ }
+ else if (strcmp(argv[2], "sft") == 0)
+ {
+ SvFileStream aFileStream(out, StreamMode::READ);
+ std::vector<sal_uInt8> aData(aFileStream.remainingSize());
+ aFileStream.ReadBytes(aData.data(), aData.size());
+ ret = TestFontSubset(aData.data(), aData.size());
+ }
+#ifndef DISABLE_DYNLOADING
+ else if ((strcmp(argv[2], "doc") == 0) || (strcmp(argv[2], "ww8") == 0))
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libmswordlo.so", "TestImportWW8");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "ww6") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libmswordlo.so", "TestImportWW6");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "ww2") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libmswordlo.so", "TestImportWW2");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "rtf") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libmswordlo.so", "TestImportRTF");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "html") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libswlo.so", "TestImportHTML");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "fodt") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libswlo.so", "TestImportFODT");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "docx") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libswlo.so", "TestImportDOCX");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "fods") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libsclo.so", "TestImportFODS");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "xlsx") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libsclo.so", "TestImportXLSX");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "fodp") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libsdlo.so", "TestImportFODP");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "pptx") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libsdlo.so", "TestImportPPTX");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "xls") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libscfiltlo.so", "TestImportXLS");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "wks") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libscfiltlo.so", "TestImportWKS");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "hwp") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libhwplo.so", "TestImportHWP");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "602") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libt602filterlo.so", "TestImport602");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "lwp") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"liblwpftlo.so", "TestImportLWP");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "ppt") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libsdfiltlo.so", "TestImportPPT");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "cgm") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libsdlo.so", "TestImportCGM");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "qpw") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libscfiltlo.so", "TestImportQPW");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "dbf") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libsclo.so", "TestImportDBF");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "dif") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libscfiltlo.so", "TestImportDIF");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "sc-rtf") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libscfiltlo.so", "TestImportCalcRTF");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "slk") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libsclo.so", "TestImportSLK");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "ole") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libsotlo.so", "TestImportOLE2");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "mml") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libsmlo.so", "TestImportMML");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "mtp") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libsmlo.so", "TestImportMathType");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+ else if (strcmp(argv[2], "svm") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libvcllo.so", "TestImportSVM");
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = static_cast<int>((*pfnImport)(aFileStream));
+ }
+#endif
+ }
+ catch (...)
+ {
+ abort();
+ }
+
+ return ret;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/fodpfuzzer.cxx b/vcl/workben/fodpfuzzer.cxx
new file mode 100644
index 000000000..b51efac1c
--- /dev/null
+++ b/vcl/workben/fodpfuzzer.cxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+extern "C" bool TestImportFODP(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" void* SdCreateDialogFactory()
+{
+ return nullptr;
+}
+
+extern "C" void* com_sun_star_comp_Draw_VisioImportFilter_get_implementation()
+{
+ return nullptr;
+}
+
+extern "C" void* sdext_PDFIHybridAdaptor_get_implementation()
+{
+ return nullptr;
+}
+
+extern "C" void* sdext_PDFIRawAdaptor_Writer_get_implementation()
+{
+ return nullptr;
+}
+
+extern "C" void* sdext_PDFIRawAdaptor_Draw_get_implementation()
+{
+ return nullptr;
+}
+
+extern "C" void* sdext_PDFIRawAdaptor_Impress_get_implementation()
+{
+ return nullptr;
+}
+
+extern "C" void* sdext_PDFDetector_get_implementation()
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportFODP(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/fodpfuzzer.options b/vcl/workben/fodpfuzzer.options
new file mode 100644
index 000000000..76d308c39
--- /dev/null
+++ b/vcl/workben/fodpfuzzer.options
@@ -0,0 +1,3 @@
+[libfuzzer]
+max_len = 65536
+dict = xml.dict
diff --git a/vcl/workben/fodsfuzzer.cxx b/vcl/workben/fodsfuzzer.cxx
new file mode 100644
index 000000000..ed9efd6e3
--- /dev/null
+++ b/vcl/workben/fodsfuzzer.cxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+extern "C" void* ScCreateDialogFactory()
+{
+ return nullptr;
+}
+
+extern "C" bool TestImportFODS(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportFODS(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/fodsfuzzer.options b/vcl/workben/fodsfuzzer.options
new file mode 100644
index 000000000..76d308c39
--- /dev/null
+++ b/vcl/workben/fodsfuzzer.options
@@ -0,0 +1,3 @@
+[libfuzzer]
+max_len = 65536
+dict = xml.dict
diff --git a/vcl/workben/fodtfuzzer.cxx b/vcl/workben/fodtfuzzer.cxx
new file mode 100644
index 000000000..71c37aa7c
--- /dev/null
+++ b/vcl/workben/fodtfuzzer.cxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+extern "C" void* SwCreateDialogFactory()
+{
+ return nullptr;
+}
+
+extern "C" bool TestImportFODT(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportFODT(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/fodtfuzzer.options b/vcl/workben/fodtfuzzer.options
new file mode 100644
index 000000000..76d308c39
--- /dev/null
+++ b/vcl/workben/fodtfuzzer.options
@@ -0,0 +1,3 @@
+[libfuzzer]
+max_len = 65536
+dict = xml.dict
diff --git a/vcl/workben/giffuzzer.cxx b/vcl/workben/giffuzzer.cxx
new file mode 100644
index 000000000..7a2b9a9f0
--- /dev/null
+++ b/vcl/workben/giffuzzer.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <../source/filter/igif/gifread.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportGIF(aStream, aGraphic);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/giffuzzer.options b/vcl/workben/giffuzzer.options
new file mode 100644
index 000000000..57d53b24e
--- /dev/null
+++ b/vcl/workben/giffuzzer.options
@@ -0,0 +1,3 @@
+[libfuzzer]
+max_len = 65536
+dict = gif.dict
diff --git a/vcl/workben/htmlfuzzer.cxx b/vcl/workben/htmlfuzzer.cxx
new file mode 100644
index 000000000..b2e894420
--- /dev/null
+++ b/vcl/workben/htmlfuzzer.cxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+extern "C" void* SwCreateDialogFactory() { return nullptr; }
+
+extern "C" bool TestImportHTML(SvStream& rStream);
+
+extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportHTML(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/htmlfuzzer.options b/vcl/workben/htmlfuzzer.options
new file mode 100644
index 000000000..cd3dd2011
--- /dev/null
+++ b/vcl/workben/htmlfuzzer.options
@@ -0,0 +1,3 @@
+[libfuzzer]
+max_len = 65536
+dict = html_tags.dict
diff --git a/vcl/workben/hwpfuzzer.cxx b/vcl/workben/hwpfuzzer.cxx
new file mode 100644
index 000000000..430b1bdfc
--- /dev/null
+++ b/vcl/workben/hwpfuzzer.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" bool TestImportHWP(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportHWP(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/hwpfuzzer.options b/vcl/workben/hwpfuzzer.options
new file mode 100644
index 000000000..bf169a74b
--- /dev/null
+++ b/vcl/workben/hwpfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 49152
diff --git a/vcl/workben/icontest.cxx b/vcl/workben/icontest.cxx
new file mode 100644
index 000000000..86cf4da23
--- /dev/null
+++ b/vcl/workben/icontest.cxx
@@ -0,0 +1,215 @@
+/* -*- 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 is a quick hack to test some stuff. Work in progress. Don't touch
+ * and don't bother inspecting too closely.
+ *
+ * =======================================================================
+ */
+
+#include <iostream>
+
+#include <math.h>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ucb/UniversalContentBroker.hpp>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <osl/file.hxx>
+#include <sal/log.hxx>
+#include <tools/stream.hxx>
+#include <vcl/builder.hxx>
+#include <vcl/toolkit/button.hxx>
+#include <vcl/toolkit/dialog.hxx>
+#include <vcl/toolkit/fixed.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/graphicfilter.hxx>
+#include <vcl/image.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/vclmain.hxx>
+#include <vcl/wrkwin.hxx>
+
+using namespace com::sun::star;
+
+namespace {
+ const int WIDTH = 1000, HEIGHT = 800;
+
+ double getTimeNow()
+ {
+ TimeValue aValue;
+ osl_getSystemTime(&aValue);
+ return static_cast<double>(aValue.Seconds) +
+ static_cast<double>(aValue.Nanosec) / (1000*1000*1000);
+ }
+
+class MyWorkWindow : public WorkWindow
+{
+ double mnStartTime;
+ int mnPaintCount;
+
+public:
+ Graphic maGraphic;
+ BitmapEx *mpBitmap;
+ VclPtr<FixedBitmap> mpFixedBitmap;
+
+ MyWorkWindow( vcl::Window* pParent, WinBits nWinStyle );
+ virtual ~MyWorkWindow() override { disposeOnce(); }
+ virtual void dispose() override { mpFixedBitmap.clear(); WorkWindow::dispose(); }
+ void LoadGraphic( const OUString& sImageFile );
+
+ virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle& rRect ) override;
+ virtual void Resize() override;
+};
+
+}
+
+MyWorkWindow::MyWorkWindow( vcl::Window* pParent, WinBits nWinStyle )
+ : WorkWindow(pParent, nWinStyle)
+ , mpBitmap(nullptr)
+ , mpFixedBitmap(nullptr)
+{
+ mnPaintCount = 0;
+ mnStartTime = getTimeNow();
+ EnableInput();
+}
+
+void MyWorkWindow::LoadGraphic( const OUString& sImageFile )
+{
+ SvFileStream aFileStream( sImageFile, StreamMode::READ );
+ GraphicFilter aGraphicFilter(false);
+ if (aGraphicFilter.ImportGraphic(maGraphic, sImageFile, aFileStream) != ERRCODE_NONE)
+ {
+ SAL_WARN("vcl.icontest", "Could not import image '" << sImageFile << "'");
+ return;
+ }
+}
+
+void MyWorkWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
+{
+ std::cout << "==> Paint! " << mnPaintCount++ << " (vcl) " << GetSizePixel() << " " << getTimeNow() - mnStartTime << std::endl;
+
+ Size aGraphicSize( maGraphic.GetSizePixel() );
+ float aspect = static_cast<float>(aGraphicSize.Width()) / aGraphicSize.Height();
+ Size aSize;
+ if( aspect >= (float(WIDTH)) / HEIGHT )
+ aSize = Size( WIDTH, HEIGHT/aspect );
+ else
+ aSize = Size( WIDTH * aspect, HEIGHT );
+ aSize.setWidth( aSize.Width() * (1 + (0.1*sin(mnPaintCount/60.))) );
+ aSize.setHeight( aSize.Height() * (1 + (0.1*sin(mnPaintCount/50.))) );
+
+ BitmapEx aEmpty;
+ mpFixedBitmap->SetBitmap( aEmpty );
+ GraphicConversionParameters aConv( aSize );
+ mpBitmap = new BitmapEx(maGraphic.GetBitmapEx( aConv ));
+ mpFixedBitmap->SetBitmap( *mpBitmap );
+ mpFixedBitmap->SetSizePixel( aSize );
+
+ WorkWindow::Paint(rRenderContext, rRect);
+
+ if (mnPaintCount == 100)
+ Application::Quit();
+
+ Invalidate( InvalidateFlags::Children );
+}
+
+void MyWorkWindow::Resize()
+{
+ SAL_INFO("vcl.icontest", "Resize " << GetSizePixel());
+}
+
+namespace {
+
+class IconTestApp : public Application
+{
+public:
+ virtual void Init() override;
+ virtual int Main() override;
+
+ IconTestApp() : nRet(EXIT_SUCCESS) {};
+
+private:
+ int nRet;
+
+ void DoItWithVcl(const OUString& sImageFile);
+};
+
+}
+
+void IconTestApp::Init()
+{
+ nRet = EXIT_SUCCESS;
+
+ uno::Reference<uno::XComponentContext> xContext =
+ cppu::defaultBootstrap_InitialComponentContext();
+ uno::Reference<lang::XMultiComponentFactory> xFactory =
+ xContext->getServiceManager();
+ uno::Reference<lang::XMultiServiceFactory> xSFactory(xFactory, uno::UNO_QUERY_THROW);
+ comphelper::setProcessServiceFactory(xSFactory);
+
+ // Create UCB (for backwards compatibility, in case some code still uses
+ // plain createInstance w/o args directly to obtain an instance):
+ ::ucb::UniversalContentBroker::create(
+ comphelper::getProcessComponentContext() );
+}
+
+int IconTestApp::Main()
+{
+ if (GetCommandLineParamCount() != 1)
+ {
+ fprintf(stderr, "Usage: imagetest <image>\n");
+ return EXIT_FAILURE;
+ }
+ OUString sImageFile( GetCommandLineParam( 0 ) );
+ DoItWithVcl( sImageFile );
+
+ return nRet;
+}
+
+void IconTestApp::DoItWithVcl( const OUString& sImageFile)
+{
+ try
+ {
+ VclPtrInstance<MyWorkWindow> pWindow( nullptr, WB_APP | WB_STDWORK | WB_SIZEABLE | WB_CLOSEABLE | WB_CLIPCHILDREN );
+
+ pWindow->SetText("VCL Image Test");
+
+ pWindow->LoadGraphic( sImageFile );
+ pWindow->mpFixedBitmap = VclPtr<FixedBitmap>::Create( pWindow );
+ pWindow->mpFixedBitmap->SetPosPixel( Point( 0, 0 ) );
+ pWindow->mpFixedBitmap->Show();
+
+ pWindow->Hide();
+ pWindow->Show();
+
+ Execute();
+ }
+ catch (const uno::Exception &e)
+ {
+ fprintf(stderr, "fatal error: %s\n", OUStringToOString(e.Message, osl_getThreadTextEncoding()).getStr());
+ nRet = EXIT_FAILURE;
+ }
+ catch (const std::exception &e)
+ {
+ fprintf(stderr, "fatal error: %s\n", e.what());
+ nRet = EXIT_FAILURE;
+ }
+}
+
+void vclmain::createApplication()
+{
+ static IconTestApp aApp;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/jpgfuzzer.cxx b/vcl/workben/jpgfuzzer.cxx
new file mode 100644
index 000000000..5850deec5
--- /dev/null
+++ b/vcl/workben/jpgfuzzer.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <../source/filter/jpeg/jpeg.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportJPEG(aStream, aGraphic, GraphicFilterImportFlags::NONE, nullptr);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/jpgfuzzer.options b/vcl/workben/jpgfuzzer.options
new file mode 100644
index 000000000..dfcaf9cd9
--- /dev/null
+++ b/vcl/workben/jpgfuzzer.options
@@ -0,0 +1,3 @@
+[libfuzzer]
+max_len = 65536
+dict = jpeg.dict
diff --git a/vcl/workben/listfonts.cxx b/vcl/workben/listfonts.cxx
new file mode 100644
index 000000000..60b320968
--- /dev/null
+++ b/vcl/workben/listfonts.cxx
@@ -0,0 +1,541 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <osl/file.hxx>
+#include <osl/process.h>
+#include <rtl/textenc.h>
+#include <sal/main.h>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/degree.hxx>
+#include <i18nlangtag/languagetag.hxx>
+#include <i18nlangtag/mslangid.hxx>
+
+#include <vcl/font/Feature.hxx>
+#include <vcl/metric.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/vclmain.hxx>
+#include <vcl/wrkwin.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <string_view>
+
+namespace
+{
+OUString GetOctetTextEncodingName(sal_uInt16 encoding)
+{
+ switch (encoding)
+ {
+ case RTL_TEXTENCODING_APPLE_ARABIC:
+ return "Arabic (Apple Macintosh)";
+
+ case RTL_TEXTENCODING_IBM_864:
+ return "Arabic (DOS/OS2-864)";
+
+ case RTL_TEXTENCODING_ISO_8859_6:
+ return "Arabic (ISO-8859-6)";
+
+ case RTL_TEXTENCODING_MS_1256:
+ return "Arabic (Windows-1256)";
+
+ case RTL_TEXTENCODING_IBM_775:
+ return "Baltic (DOS/OS2-775)";
+
+ case RTL_TEXTENCODING_ISO_8859_4:
+ return "Baltic (ISO-8859-4)";
+
+ case RTL_TEXTENCODING_MS_1257:
+ return "Baltic (Windows-1257)";
+
+ case RTL_TEXTENCODING_APPLE_CENTEURO:
+ return "Central European (Apple Macintosh)";
+
+ case RTL_TEXTENCODING_APPLE_CROATIAN:
+ return "Central European (Apple Macintosh/Croatian)";
+
+ case RTL_TEXTENCODING_APPLE_ROMANIAN:
+ return "Central European (Apple Macintosh/Romanian)";
+
+ case RTL_TEXTENCODING_IBM_852:
+ return "Central European (DOS/OS2-852)";
+
+ case RTL_TEXTENCODING_ISO_8859_2:
+ return "Central European (ISO-8859-2)";
+
+ case RTL_TEXTENCODING_ISO_8859_10:
+ return "Central European (ISO-8859-10)";
+
+ case RTL_TEXTENCODING_ISO_8859_13:
+ return "Central European (ISO-8859-13)";
+
+ case RTL_TEXTENCODING_MS_1250:
+ return "Central European (Windows-1250/WinLatin 2)";
+
+ case RTL_TEXTENCODING_APPLE_CHINSIMP:
+ return "Chinese Simplified (Apple Macintosh)";
+
+ case RTL_TEXTENCODING_EUC_CN:
+ return "Chinese Simplified (EUC-CN)";
+
+ case RTL_TEXTENCODING_GB_2312:
+ return "Chinese Simplified (GB-2312)";
+
+ case RTL_TEXTENCODING_GBK:
+ return "Chinese Simplified (GBK/GB-2312-80)";
+
+ case RTL_TEXTENCODING_ISO_2022_CN:
+ return "Chinese Simplified (ISO-2022-CN)";
+
+ case RTL_TEXTENCODING_MS_936:
+ return "Chinese Simplified (Windows-936)";
+
+ case RTL_TEXTENCODING_GB_18030:
+ return "Chinese Simplified (GB-18030)";
+
+ case RTL_TEXTENCODING_APPLE_CHINTRAD:
+ return "Chinese Traditional (Apple Macintosh)";
+
+ case RTL_TEXTENCODING_BIG5:
+ return "Chinese Traditional (BIG5)";
+
+ case RTL_TEXTENCODING_EUC_TW:
+ return "Chinese Traditional (EUC-TW)";
+
+ case RTL_TEXTENCODING_GBT_12345:
+ return "Chinese Traditional (GBT-12345)";
+
+ case RTL_TEXTENCODING_MS_950:
+ return "Chinese Traditional (Windows-950)";
+
+ case RTL_TEXTENCODING_BIG5_HKSCS:
+ return "Chinese Traditional (BIG5-HKSCS)";
+
+ case RTL_TEXTENCODING_APPLE_CYRILLIC:
+ return "Cyrillic (Apple Macintosh)";
+
+ case RTL_TEXTENCODING_APPLE_UKRAINIAN:
+ return "Cyrillic (Apple Macintosh/Ukrainian)";
+
+ case RTL_TEXTENCODING_IBM_855:
+ return "Cyrillic (DOS/OS2-855)";
+
+ case RTL_TEXTENCODING_IBM_866:
+ return "Cyrillic (DOS/OS2-866/Russian)";
+
+ case RTL_TEXTENCODING_ISO_8859_5:
+ return "Cyrillic (ISO-8859-5)";
+
+ case RTL_TEXTENCODING_KOI8_R:
+ return "Cyrillic (KOI8-R)";
+
+ case RTL_TEXTENCODING_KOI8_U:
+ return "Cyrillic (KOI8-U)";
+
+ case RTL_TEXTENCODING_MS_1251:
+ return "Cyrillic (Windows-1251)";
+
+ case RTL_TEXTENCODING_APPLE_GREEK:
+ return "Greek (Apple Macintosh)";
+
+ case RTL_TEXTENCODING_IBM_737:
+ return "Greek (DOS/OS2-737)";
+
+ case RTL_TEXTENCODING_IBM_869:
+ return "Greek (DOS/OS2-869/Modern)";
+
+ case RTL_TEXTENCODING_ISO_8859_7:
+ return "Greek (ISO-8859-7)";
+
+ case RTL_TEXTENCODING_MS_1253:
+ return "Greek (Windows-1253)";
+
+ case RTL_TEXTENCODING_APPLE_HEBREW:
+ return "Hebrew (Apple Macintosh)";
+
+ case RTL_TEXTENCODING_IBM_862:
+ return "Hebrew (DOS/OS2-862)";
+
+ case RTL_TEXTENCODING_ISO_8859_8:
+ return "Hebrew (ISO-8859-8)";
+
+ case RTL_TEXTENCODING_MS_1255:
+ return "Hebrew (Windows-1255)";
+
+ case RTL_TEXTENCODING_APPLE_KOREAN:
+ return "Korean (Apple Macintosh)";
+
+ case RTL_TEXTENCODING_EUC_KR:
+ return "Korean (EUC-KR)";
+
+ case RTL_TEXTENCODING_ISO_2022_KR:
+ return "Korean (ISO-2022-KR)";
+
+ case RTL_TEXTENCODING_MS_949:
+ return "Korean (Windows-Wansung-949)";
+
+ case RTL_TEXTENCODING_MS_1361:
+ return "Korean (Windows-Johab-1361)";
+
+ case RTL_TEXTENCODING_ISO_8859_3:
+ return "Latin 3 (ISO-8859-3)";
+
+ case RTL_TEXTENCODING_ISCII_DEVANAGARI:
+ return "Indian (ISCII Devanagari)";
+
+ case RTL_TEXTENCODING_APPLE_JAPANESE:
+ return "Japanese (Apple Macintosh)";
+
+ case RTL_TEXTENCODING_EUC_JP:
+ return "Japanese (EUC-JP)";
+
+ case RTL_TEXTENCODING_ISO_2022_JP:
+ return "Japanese (ISO-2022-JP)";
+
+ case RTL_TEXTENCODING_SHIFT_JIS:
+ return "Japanese (Shift-JIS)";
+
+ case RTL_TEXTENCODING_MS_932:
+ return "Japanese (Windows-932)";
+
+ case RTL_TEXTENCODING_SYMBOL:
+ return "Symbol";
+
+ case RTL_TEXTENCODING_APPLE_THAI:
+ return "Thai (Apple Macintosh)";
+
+ case RTL_TEXTENCODING_MS_874:
+ return "Thai (Dos/Windows-874)";
+
+ case RTL_TEXTENCODING_TIS_620:
+ return "Thai (TIS 620)";
+
+ case RTL_TEXTENCODING_APPLE_TURKISH:
+ return "Turkish (Apple Macintosh)";
+
+ case RTL_TEXTENCODING_IBM_857:
+ return "Turkish (DOS/OS2-857)";
+
+ case RTL_TEXTENCODING_ISO_8859_9:
+ return "Turkish (ISO-8859-9)";
+
+ case RTL_TEXTENCODING_MS_1254:
+ return "Turkish (Windows-1254)";
+
+ case RTL_TEXTENCODING_UTF7:
+ return "Unicode (UTF-7)";
+
+ case RTL_TEXTENCODING_UTF8:
+ return "Unicode (UTF-8)";
+
+ case RTL_TEXTENCODING_JAVA_UTF8:
+ return "Unicode (Java's modified UTF-8)";
+
+ case RTL_TEXTENCODING_MS_1258:
+ return "Vietnamese (Windows-1258)";
+
+ case RTL_TEXTENCODING_APPLE_ROMAN:
+ return "Western (Apple Macintosh)";
+
+ case RTL_TEXTENCODING_APPLE_ICELAND:
+ return "Western (Apple Macintosh/Icelandic)";
+
+ case RTL_TEXTENCODING_ASCII_US:
+ return "Western (ASCII/US)";
+
+ case RTL_TEXTENCODING_IBM_437:
+ return "Western (DOS/OS2-437/US)";
+
+ case RTL_TEXTENCODING_IBM_850:
+ return "Western (DOS/OS2-850/International)";
+
+ case RTL_TEXTENCODING_IBM_860:
+ return "Western (DOS/OS2-860/Portuguese)";
+
+ case RTL_TEXTENCODING_IBM_861:
+ return "Western (DOS/OS2-861/Icelandic)";
+
+ case RTL_TEXTENCODING_IBM_863:
+ return "Western (DOS/OS2-863/Canadian-French)";
+
+ case RTL_TEXTENCODING_IBM_865:
+ return "Western (DOS/OS2-865/Nordic)";
+
+ case RTL_TEXTENCODING_ISO_8859_1:
+ return "Western (ISO-8859-1)";
+
+ case RTL_TEXTENCODING_ISO_8859_14:
+ return "Western (ISO-8859-14)";
+
+ case RTL_TEXTENCODING_ISO_8859_15:
+ return "Western (ISO-8859-15/EURO)";
+
+ case RTL_TEXTENCODING_MS_1252:
+ return "Western (Window-1252/WinLatin 1)";
+
+ case RTL_TEXTENCODING_UCS4:
+ return "UCS4";
+
+ case RTL_TEXTENCODING_UCS2:
+ return "UCS2 (aka Unicode)";
+
+ default:
+ {
+ OUString sUnknown = "Unknown (0x" + OUString::number(encoding, 16) + ")";
+ return sUnknown;
+ }
+ }
+}
+
+class ListFontsWin : public WorkWindow
+{
+public:
+ explicit ListFontsWin()
+ : WorkWindow(nullptr, WB_HIDE)
+ {
+ }
+};
+
+class ListFonts : public Application
+{
+public:
+ virtual int Main() override;
+
+private:
+ static void showHelp()
+ {
+ std::cerr << "Usage: listfonts --help | FILE | -v FILE\n";
+ std::cerr << "Lists the current fonts installed on the system.\n";
+ std::cerr << "To show the font features of each font, use -v before FILE.\n";
+ std::cerr << "If outputting to stdout, use -- for FILE.\n";
+ std::exit(0);
+ }
+
+ void Init() override;
+ void DeInit() override;
+
+ css::uno::Reference<css::lang::XMultiServiceFactory> xServiceManager;
+ bool mbStdOut = false;
+ bool mbShowFeatures = false;
+ OUString maFilename;
+};
+
+int ListFonts::Main()
+{
+ try
+ {
+ VclPtrInstance<ListFontsWin> pWin;
+ OutputDevice* pOutDev = pWin->GetOutDev();
+
+ std::streambuf* coutbuf = nullptr;
+ std::fstream out;
+
+ if (!mbStdOut)
+ {
+ std::u16string_view filenamev = maFilename;
+ std::string filename(filenamev.begin(), filenamev.end());
+
+ out.open(filename, std::ios::out | std::ios::trunc);
+
+ coutbuf = std::cout.rdbuf();
+ std::cout.rdbuf(out.rdbuf());
+ }
+
+ for (int i = 0; i < pOutDev->GetFontFaceCollectionCount(); i++)
+ {
+ // note: to get the correct font metrics, you actually have to get the font metric from the
+ // system, and *then* you must set it as the current font of OutputDevice... then you need
+ // to get the font metric (which corrects a variety of things like the orientation, line
+ // height, slant, etc. - including converting from logical coords to device coords)
+
+ FontMetric aSystemFont = pOutDev->GetFontMetricFromCollection(i);
+ pOutDev->SetFont(aSystemFont);
+
+ FontMetric aFont = pOutDev->GetFontMetric();
+
+ std::cout << aFont.GetFamilyName() << "\n\tFamily type: " << aFont.GetFamilyType()
+ << "\n\tStyle name: " << aFont.GetStyleName()
+ << "\n\tWeight: " << aFont.GetWeight() << "\n\tItalic: " << aFont.GetItalic()
+ << "\n\tPitch: " << aFont.GetPitch()
+ << "\n\tWidth type: " << aFont.GetWidthType()
+ << "\n\tAlignment: " << aFont.GetAlignment()
+ << "\n\tCharset: " << GetOctetTextEncodingName(aFont.GetCharSet())
+ << "\n\tSymbol font? " << (aFont.IsSymbolFont() ? "yes" : "no")
+ << "\n\tAscent: " << aFont.GetAscent()
+ << "\n\tDescent: " << aFont.GetDescent()
+ << "\n\tInternal leading: " << aFont.GetInternalLeading()
+ << "\n\tExternal leading: " << aFont.GetExternalLeading()
+ << "\n\tLine height: " << aFont.GetLineHeight()
+ << "\n\tSlant: " << aFont.GetSlant()
+ << "\n\tBullet offset: " << aFont.GetBulletOffset()
+ << "\n\tFullstop centered? " << (aFont.IsFullstopCentered() ? "yes" : "no")
+ << "\n\tOrientation: " << toDegrees(aFont.GetOrientation())
+ << " degrees\n\tQuality: " << aFont.GetQuality() << "\n";
+
+ if (mbShowFeatures)
+ {
+ std::vector<vcl::font::Feature> features;
+ pOutDev->GetFontFeatures(features);
+
+ for (auto const& feature : features)
+ {
+ std::ios init(nullptr);
+ init.copyfmt(std::cout);
+
+ std::cout << "\t"
+ << (feature.m_eType == vcl::font::FeatureType::OpenType ? "OpenType"
+ : "Graphite")
+ << " Feature:\n\t\tId = { feature code = "
+ << vcl::font::featureCodeAsString(feature.m_aID.m_aFeatureCode)
+ << ", script code = "
+ << vcl::font::featureCodeAsString(feature.m_aID.m_aScriptCode)
+ << ", language code = "
+ << vcl::font::featureCodeAsString(feature.m_aID.m_aLanguageCode)
+ << " }\n";
+
+ std::cout << "\t\tDescription: " << feature.m_aDefinition.getDescription()
+ << "\n";
+ std::cout << "\t\tType: "
+ << (feature.m_aDefinition.getType()
+ == vcl::font::FeatureParameterType::BOOL
+ ? "BOOL"
+ : "ENUM")
+ << "\n";
+
+ std::cout.copyfmt(init);
+
+ if (feature.m_aDefinition.getType() == vcl::font::FeatureParameterType::ENUM)
+ {
+ for (auto const& param : feature.m_aDefinition.getEnumParameters())
+ {
+ std::cout << "\t\t\t" << param.getDescription() << ": "
+ << param.getCode() << "\n";
+ }
+ }
+
+ std::cout << "\t\tDefault: 0x" << std::hex << feature.m_aDefinition.getDefault()
+ << "\n";
+
+ std::cout.copyfmt(init);
+ }
+ }
+ }
+
+ std::cout << std::flush;
+
+ if (!mbStdOut)
+ {
+ std::cout.rdbuf(coutbuf);
+ out.close();
+ }
+
+ std::exit(0);
+ }
+ catch (const css::uno::Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("vcl.app", "Fatal");
+ return 1;
+ }
+ catch (const std::exception& e)
+ {
+ SAL_WARN("vcl.app", "Fatal: " << e.what());
+ return 1;
+ }
+ return 0;
+}
+}
+
+void ListFonts::Init()
+{
+ const sal_uInt16 nCmdParams = GetCommandLineParamCount();
+ OUString aArg;
+
+ if (nCmdParams == 0)
+ {
+ showHelp();
+ std::exit(1);
+ }
+ else
+ {
+ aArg = GetCommandLineParam(0);
+
+ if (aArg == "--help" || aArg == "-h")
+ {
+ showHelp();
+ std::exit(0);
+ }
+ else if (nCmdParams == 2 && (aArg == "--verbose" || aArg == "-v"))
+ {
+ aArg = GetCommandLineParam(1);
+ mbShowFeatures = true;
+
+ if (aArg == "--")
+ mbStdOut = true;
+ }
+ else if (nCmdParams == 1)
+ {
+ if (aArg == "--")
+ mbStdOut = true;
+ }
+ else
+ {
+ std::cerr << "invalid arguments\n";
+ showHelp();
+ std::exit(1);
+ }
+ }
+
+ if (!mbStdOut)
+ {
+ maFilename = aArg;
+
+ osl::File aFile(maFilename);
+
+ if (!aFile.open(osl_File_OpenFlag_Create))
+ throw css::uno::RuntimeException("Can not create file: " + aArg);
+
+ aFile.close();
+ }
+
+ auto xContext = cppu::defaultBootstrap_InitialComponentContext();
+ xServiceManager.set(xContext->getServiceManager(), css::uno::UNO_QUERY);
+
+ if (!xServiceManager.is())
+ Application::Abort("Bootstrap failure - no service manager");
+
+ comphelper::setProcessServiceFactory(xServiceManager);
+
+ LanguageTag::setConfiguredSystemLanguage(MsLangId::getSystemLanguage());
+}
+
+void ListFonts::DeInit()
+{
+ auto xContext = css::uno::Reference<css::lang::XComponent>(
+ comphelper::getProcessComponentContext(), css::uno::UNO_QUERY_THROW);
+ xContext->dispose();
+ ::comphelper::setProcessServiceFactory(nullptr);
+}
+
+SAL_IMPLEMENT_MAIN()
+{
+ ListFonts aApp;
+ InitVCL();
+ int ret = aApp.Main();
+ DeInitVCL();
+
+ return ret;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/workben/lwpfuzzer.cxx b/vcl/workben/lwpfuzzer.cxx
new file mode 100644
index 000000000..fc0704542
--- /dev/null
+++ b/vcl/workben/lwpfuzzer.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" bool TestImportLWP(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportLWP(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/lwpfuzzer.options b/vcl/workben/lwpfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/lwpfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/metfuzzer.cxx b/vcl/workben/metfuzzer.cxx
new file mode 100644
index 000000000..9ca6fd35c
--- /dev/null
+++ b/vcl/workben/metfuzzer.cxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+#include <filter/MetReader.hxx>
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" {
+void * com_sun_star_i18n_LocaleDataImpl_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_get_implementation( void *, void * );
+void * com_sun_star_i18n_NativeNumberSupplier_get_implementation( void *, void * );
+void * com_sun_star_i18n_NumberFormatCodeMapper_get_implementation( void *, void * );
+}
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { "com_sun_star_i18n_LocaleDataImpl_get_implementation", com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation", com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation", com_sun_star_i18n_BreakIterator_get_implementation },
+ { "com_sun_star_i18n_NativeNumberSupplier_get_implementation", com_sun_star_i18n_NativeNumberSupplier_get_implementation },
+ { "com_sun_star_i18n_NumberFormatCodeMapper_get_implementation", com_sun_star_i18n_NumberFormatCodeMapper_get_implementation },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportMetGraphic(aStream, aGraphic);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/metfuzzer.options b/vcl/workben/metfuzzer.options
new file mode 100644
index 000000000..bf169a74b
--- /dev/null
+++ b/vcl/workben/metfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 49152
diff --git a/vcl/workben/minvcl.cxx b/vcl/workben/minvcl.cxx
new file mode 100644
index 000000000..e6beb2f95
--- /dev/null
+++ b/vcl/workben/minvcl.cxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <framework/desktop.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <i18nlangtag/languagetag.hxx>
+#include <i18nlangtag/mslangid.hxx>
+#include <o3tl/deleter.hxx>
+
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+
+namespace
+{
+class TheWindow : public WorkWindow
+{
+public:
+ TheWindow()
+ : WorkWindow(nullptr, WB_APP | WB_STDWORK)
+ {
+ }
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
+};
+
+class TheApplication : public Application
+{
+public:
+ virtual int Main();
+
+private:
+ VclPtr<TheWindow> mpWin;
+};
+}
+
+void TheWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
+{
+ rRenderContext.DrawText(Point(rRect.GetWidth() / 2, rRect.getHeight() / 2),
+ OUString(u"VCL module in LibreOffice"));
+}
+
+int TheApplication::Main()
+{
+ mpWin = VclPtr<TheWindow>::Create();
+ mpWin->SetText(u"VCL");
+ mpWin->Show();
+ Execute();
+ mpWin.disposeAndClear();
+ return 0;
+}
+
+static int main_impl()
+{
+ auto xContext = cppu::defaultBootstrap_InitialComponentContext();
+ css::uno::Reference<css::lang::XMultiServiceFactory> xServiceManager(
+ xContext->getServiceManager(), css::uno::UNO_QUERY);
+ comphelper::setProcessServiceFactory(xServiceManager);
+ LanguageTag::setConfiguredSystemLanguage(MsLangId::getSystemLanguage());
+
+ TheApplication aApp;
+ InitVCL();
+ int ret = aApp.Main();
+ framework::getDesktop(::comphelper::getProcessComponentContext())->terminate();
+ DeInitVCL();
+
+ comphelper::setProcessServiceFactory(nullptr);
+
+ return ret;
+}
+
+int main()
+{
+ int ret;
+ suppress_fun_call_w_exception(ret = main_impl());
+ return ret;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/workben/mmlfuzzer.cxx b/vcl/workben/mmlfuzzer.cxx
new file mode 100644
index 000000000..8811c2743
--- /dev/null
+++ b/vcl/workben/mmlfuzzer.cxx
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+extern "C" bool TestImportMML(SvStream& rStream);
+
+extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportMML(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/mmlfuzzer.options b/vcl/workben/mmlfuzzer.options
new file mode 100644
index 000000000..76d308c39
--- /dev/null
+++ b/vcl/workben/mmlfuzzer.options
@@ -0,0 +1,3 @@
+[libfuzzer]
+max_len = 65536
+dict = xml.dict
diff --git a/vcl/workben/mtfdemo.cxx b/vcl/workben/mtfdemo.cxx
new file mode 100644
index 000000000..9ed8a2404
--- /dev/null
+++ b/vcl/workben/mtfdemo.cxx
@@ -0,0 +1,246 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/ucb/UniversalContentBroker.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+
+#include <vcl/vclmain.hxx>
+#include <vcl/layout.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/wmf.hxx>
+
+#include <tools/diagnose_ex.h>
+#include <tools/urlobj.hxx>
+#include <tools/stream.hxx>
+#include <tools/vcompat.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/virdev.hxx>
+#include <sal/log.hxx>
+#include <osl/file.hxx>
+#include <osl/process.h>
+#include <framework/desktop.hxx>
+#include <i18nlangtag/languagetag.hxx>
+#include <i18nlangtag/mslangid.hxx>
+
+#include <iostream>
+
+using namespace css;
+
+namespace {
+
+class DemoMtfWin : public WorkWindow
+{
+ OUString maFileName;
+
+public:
+ explicit DemoMtfWin(const OUString& rFileName)
+ : WorkWindow(nullptr, WB_APP | WB_STDWORK)
+ {
+ maFileName = rFileName;
+ }
+
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
+};
+
+}
+
+void DemoMtfWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
+{
+ GDIMetaFile aMtf;
+ SvFileStream aFileStream(maFileName, StreamMode::READ);
+
+ if (aFileStream.IsOpen())
+ {
+ ReadWindowMetafile(aFileStream, aMtf);
+ }
+ else
+ {
+ Application::Abort("Can't read metafile " + aFileStream.GetFileName());
+ }
+
+ aMtf.Play(*GetOutDev(), aMtf.GetActionSize());
+ aMtf.Stop();
+ aFileStream.Close();
+
+ WorkWindow::Paint(rRenderContext, rRect);
+}
+
+namespace {
+
+class DemoMtfApp : public Application
+{
+ VclPtr<DemoMtfWin> mpWin;
+ OUString maFileName;
+
+ static void showHelp()
+ {
+ std::cerr << "Usage: mtfdemo --help | FILE | -d FILE" << std::endl;
+ std::cerr << "A VCL test app that displays Windows metafiles or dumps metaactions." << std::endl;
+ std::cerr << "If you want to dump as metadump.xml, use -d before FILE." << std::endl;
+ std::exit(0);
+ }
+
+public:
+
+ DemoMtfApp()
+ : mpWin(nullptr)
+ {
+ }
+
+ virtual int Main() override
+ {
+ try
+ {
+ mpWin = VclPtr<DemoMtfWin>::Create(maFileName);
+ mpWin->SetText("Display metafile");
+
+ mpWin->Show();
+
+ Application::Execute();
+ mpWin.disposeAndClear();
+ }
+ catch (const css::uno::Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("vcl.app", "Fatal");
+ return 1;
+ }
+ catch (const std::exception& e)
+ {
+ SAL_WARN("vcl.app", "Fatal: " << e.what());
+ return 1;
+ }
+ return 0;
+ }
+
+private:
+ uno::Reference<lang::XMultiServiceFactory> xMSF;
+ void Init() override
+ {
+ LanguageTag::setConfiguredSystemLanguage(MsLangId::getSystemLanguage());
+
+ try
+ {
+ const sal_uInt16 nCmdParams = GetCommandLineParamCount();
+ OUString aArg, aFilename;
+ bool bDumpXML = false;
+
+ if (nCmdParams == 0)
+ {
+ showHelp();
+ std::exit(1);
+ }
+ else
+ {
+ aArg = GetCommandLineParam(0);
+
+ if (aArg == "--help" || aArg == "-h")
+ {
+ showHelp();
+ std::exit(0);
+ }
+ else if (nCmdParams > 1 && (aArg == "--dump" || aArg == "-d"))
+ {
+ aFilename = GetCommandLineParam(1);
+ bDumpXML = true;
+ }
+ else
+ aFilename = aArg;
+ }
+
+ OUString sWorkingDir, sFileUrl;
+ osl_getProcessWorkingDir(&sWorkingDir.pData);
+ osl::FileBase::RC rc = osl::FileBase::getFileURLFromSystemPath(aFilename, sFileUrl);
+ if (rc == osl::FileBase::E_None)
+ {
+ rc = osl::FileBase::getAbsoluteFileURL(sWorkingDir, sFileUrl, maFileName);
+ if (rc != osl::FileBase::E_None)
+ {
+ throw css::uno::RuntimeException("Can not make absolute: " + aFilename);
+ }
+ }
+ else
+ {
+ throw css::uno::RuntimeException("Can not get file url from system path: " + aFilename);
+ }
+
+ uno::Reference<uno::XComponentContext> xComponentContext
+ = ::cppu::defaultBootstrap_InitialComponentContext();
+ xMSF.set(xComponentContext->getServiceManager(), uno::UNO_QUERY);
+ if(!xMSF.is())
+ Application::Abort("Bootstrap failure - no service manager");
+
+ ::comphelper::setProcessServiceFactory(xMSF);
+
+ if(bDumpXML)
+ {
+ GDIMetaFile aMtf;
+ SvFileStream aFileStream(maFileName, StreamMode::READ);
+
+ if (aFileStream.IsOpen())
+ {
+ ReadWindowMetafile(aFileStream, aMtf);
+ }
+ else
+ {
+ throw css::uno::RuntimeException("Can't read metafile " + aFileStream.GetFileName());
+ }
+
+ OUString sAbsoluteDumpUrl, sDumpUrl;
+ rc = osl::FileBase::getFileURLFromSystemPath("metadump.xml", sDumpUrl);
+ if (rc == osl::FileBase::E_None)
+ {
+ rc = osl::FileBase::getAbsoluteFileURL(sWorkingDir, sDumpUrl, sAbsoluteDumpUrl);
+ if (rc != osl::FileBase::E_None)
+ {
+ throw css::uno::RuntimeException("Can not make absolute: metadump.xml");
+ }
+ }
+ else
+ {
+ throw css::uno::RuntimeException("Can not get file url from system path: metadump.xml");
+ }
+
+ aMtf.dumpAsXml(rtl::OUStringToOString(sAbsoluteDumpUrl, RTL_TEXTENCODING_UTF8).getStr());
+ std::cout << "Dumped metaactions as metadump.xml" << std::endl;
+ framework::getDesktop(::comphelper::getProcessComponentContext())->terminate();
+ framework::getDesktop(::comphelper::getProcessComponentContext())->disposing();
+ std::exit(0);
+ }
+
+ }
+ catch (const uno::Exception &e)
+ {
+ Application::Abort("Bootstrap exception " + e.Message);
+ }
+ }
+
+ void DeInit() override
+ {
+ framework::getDesktop(::comphelper::getProcessComponentContext())->terminate();
+ framework::getDesktop(::comphelper::getProcessComponentContext())->disposing();
+
+ ::comphelper::setProcessServiceFactory(nullptr);
+ }
+
+};
+
+}
+
+void vclmain::createApplication()
+{
+ static DemoMtfApp aApp;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/mtpfuzzer.cxx b/vcl/workben/mtpfuzzer.cxx
new file mode 100644
index 000000000..8ed271ced
--- /dev/null
+++ b/vcl/workben/mtpfuzzer.cxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping* lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = { { 0, 0 } };
+
+ return map;
+}
+
+const lib_to_constructor_mapping* lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = { { 0, 0 } };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*) { return nullptr; }
+
+extern "C" bool TestImportMathType(SvStream& rStream);
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportMathType(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/mtpfuzzer.options b/vcl/workben/mtpfuzzer.options
new file mode 100644
index 000000000..9e9bf3455
--- /dev/null
+++ b/vcl/workben/mtpfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 16384
diff --git a/vcl/workben/olefuzzer.cxx b/vcl/workben/olefuzzer.cxx
new file mode 100644
index 000000000..4d67ab57e
--- /dev/null
+++ b/vcl/workben/olefuzzer.cxx
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" {
+void * com_sun_star_comp_uui_UUIInteractionHandler_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_get_implementation( void *, void * );
+}
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { "com_sun_star_comp_uui_UUIInteractionHandler_get_implementation", com_sun_star_comp_uui_UUIInteractionHandler_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_Unicode_get_implementation", com_sun_star_i18n_CharacterClassification_Unicode_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_get_implementation", com_sun_star_i18n_CharacterClassification_get_implementation },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" bool TestImportOLE2(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ TestImportOLE2(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/olefuzzer.options b/vcl/workben/olefuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/olefuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/pasteboard.mm b/vcl/workben/pasteboard.mm
new file mode 100644
index 000000000..4123f8eae
--- /dev/null
+++ b/vcl/workben/pasteboard.mm
@@ -0,0 +1,133 @@
+// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*-
+
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+// List the contents of the macOS pasteboard
+
+// Build with: clang++ -g -Wall -o pasteboard pasteboard.mm -framework AppKit -framework UniformTypeIdentifiers
+
+#import <unistd.h>
+
+#import <iostream>
+#import <AppKit/AppKit.h>
+#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
+
+static void usage()
+{
+ std::cout << "Usage: pasteboard\n"
+ " List the types on the pasteboard and in each pasteboard item.\n"
+ " pasteboard -a\n"
+ " Output the data for all types to stdout. Note: output will\n"
+ " in many cases be binary. The different types are separated by a textual header.\n"
+ " pasteboard -t type\n"
+ " Output the data for the type in question to stdout. Note: output will\n"
+ " in many cases be binary.\n";
+}
+
+int main(int argc, char** argv)
+{
+ NSString* requestedType = @"";
+
+ int ch;
+
+ while ((ch = getopt(argc, argv, "at:")) != -1)
+ {
+ switch (ch)
+ {
+ case 'a':
+ requestedType = @"*";
+ break;
+ case 't':
+ requestedType = [NSString stringWithUTF8String:optarg];
+ break;
+ case '?':
+ usage();
+ return 0;
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc > 0)
+ {
+ usage();
+ return 1;
+ }
+
+ NSPasteboard* pb = [NSPasteboard generalPasteboard];
+
+ if ([requestedType isEqualToString:@"*"])
+ {
+ NSArray<NSPasteboardType>* types = [pb types];
+ for (unsigned i = 0; i < [types count]; i++)
+ {
+ NSData* data = [pb dataForType:types[i]];
+ std::cout << i << ": " << [types[i] UTF8String] << ": " << std::to_string([data length]) << " bytes:\n";
+ if (data != nil)
+ {
+ std::cout.write((const char*)[data bytes], [data length]);
+ std::cout << "\n";
+ }
+ }
+ return 0;
+ }
+
+ if ([requestedType length] > 0)
+ {
+ NSData* data = [pb dataForType:requestedType];
+
+ if (data == nil)
+ std::cerr << "No data for " << [requestedType UTF8String] << std::endl;
+ else
+ std::cout.write((const char*)[data bytes], [data length]);
+
+ return 0;
+ }
+
+ {
+ NSArray<NSPasteboardType>* types = [pb types];
+ std::cout << "Types directly on pasteboard:\n";
+ for (unsigned i = 0; i < [types count]; i++)
+ {
+ std::cout << " " << i << ": " << [types[i] UTF8String] << "\n";
+ }
+ }
+
+ NSArray<NSPasteboardItem*>* items = [pb pasteboardItems];
+ std::cout << "New-style items on pasteboard:\n";
+
+ for (unsigned i = 0; i < [items count]; i++)
+ {
+ std::cout << " Item " << i << ", types:\n";
+ NSArray<NSPasteboardType>* types = [items[i] types];
+ for (unsigned j = 0; j < [types count]; j++)
+ {
+ std::cout << " " << j << ": " << [types[j] UTF8String] << std::flush;
+
+ if ([types[j] isEqualToString:[UTTypePlainText identifier]] ||
+ [types[j] isEqualToString:[UTTypeUTF8PlainText identifier]] ||
+ [types[j] isEqualToString:[UTTypeText identifier]] ||
+ [types[j] isEqualToString:[UTTypeHTML identifier]] ||
+ [types[j] isEqualToString:[UTTypeRTF identifier]] ||
+ [types[j] isEqualToString:[UTTypeUTF16ExternalPlainText identifier]])
+ {
+ NSString* string = [items[i] stringForType:NSPasteboardTypeString];
+ if ([string length] > 500)
+ string = [[string substringToIndex:501] stringByAppendingString:@"..."];
+ std::cout << ": '" << [string UTF8String] << "'";
+ }
+ std::cout << "\n";
+ }
+ }
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/workben/pcdfuzzer.cxx b/vcl/workben/pcdfuzzer.cxx
new file mode 100644
index 000000000..86df131da
--- /dev/null
+++ b/vcl/workben/pcdfuzzer.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+#include <filter/PcdReader.hxx>
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportPcdGraphic(aStream, aGraphic, nullptr);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/pcdfuzzer.options b/vcl/workben/pcdfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/pcdfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/pctfuzzer.cxx b/vcl/workben/pctfuzzer.cxx
new file mode 100644
index 000000000..db1ad0c90
--- /dev/null
+++ b/vcl/workben/pctfuzzer.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+#include <filter/PictReader.hxx>
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportPictGraphic(aStream, aGraphic);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/pctfuzzer.options b/vcl/workben/pctfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/pctfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/pcxfuzzer.cxx b/vcl/workben/pcxfuzzer.cxx
new file mode 100644
index 000000000..2785cf4c4
--- /dev/null
+++ b/vcl/workben/pcxfuzzer.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+#include <filter/PcxReader.hxx>
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportPcxGraphic(aStream, aGraphic);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/pcxfuzzer.options b/vcl/workben/pcxfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/pcxfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/pngfuzzer.cxx b/vcl/workben/pngfuzzer.cxx
new file mode 100644
index 000000000..e5e3c9e8a
--- /dev/null
+++ b/vcl/workben/pngfuzzer.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/filter/PngImageReader.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ vcl::PngImageReader aReader(aStream);
+ (void)aReader.read();
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/pngfuzzer.options b/vcl/workben/pngfuzzer.options
new file mode 100644
index 000000000..d62b77341
--- /dev/null
+++ b/vcl/workben/pngfuzzer.options
@@ -0,0 +1,3 @@
+[libfuzzer]
+max_len = 65536
+dict = png.dict
diff --git a/vcl/workben/ppmfuzzer.cxx b/vcl/workben/ppmfuzzer.cxx
new file mode 100644
index 000000000..9595fa3aa
--- /dev/null
+++ b/vcl/workben/ppmfuzzer.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+#include <filter/PbmReader.hxx>
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportPbmGraphic(aStream, aGraphic);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/ppmfuzzer.options b/vcl/workben/ppmfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/ppmfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/pptfuzzer.cxx b/vcl/workben/pptfuzzer.cxx
new file mode 100644
index 000000000..f36cd08d3
--- /dev/null
+++ b/vcl/workben/pptfuzzer.cxx
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+#include <svx/svdobj.hxx>
+
+extern "C" {
+void * i18npool_component_getFactory( const char* , void* , void* );
+
+void * com_sun_star_i18n_LocaleDataImpl_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_get_implementation( void *, void * );
+void * com_sun_star_comp_framework_Desktop_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_get_implementation( void *, void * );
+void * com_sun_star_i18n_NativeNumberSupplier_get_implementation( void *, void * );
+void * com_sun_star_i18n_NumberFormatCodeMapper_get_implementation( void *, void * );
+void * com_sun_star_i18n_Transliteration_get_implementation( void *, void * );
+void * com_sun_star_drawing_EnhancedCustomShapeEngine_get_implementation( void *, void * );
+void * com_sun_star_drawing_SvxShapeCollection_get_implementation( void *, void * );
+void * SfxDocumentMetaData_get_implementation( void *, void * );
+void * com_sun_star_animations_AnimateColor_get_implementation( void *, void * );
+void * com_sun_star_animations_AnimateMotion_get_implementation( void *, void * );
+void * com_sun_star_animations_AnimateSet_get_implementation( void *, void * );
+void * com_sun_star_animations_AnimateTransform_get_implementation( void *, void * );
+void * com_sun_star_animations_Animate_get_implementation( void *, void * );
+void * com_sun_star_animations_Audio_get_implementation( void *, void * );
+void * com_sun_star_animations_Command_get_implementation( void *, void * );
+void * com_sun_star_animations_IterateContainer_get_implementation( void *, void * );
+void * com_sun_star_animations_ParallelTimeContainer_get_implementation( void *, void * );
+void * com_sun_star_animations_SequenceTimeContainer_get_implementation( void *, void * );
+void * com_sun_star_animations_TransitionFilter_get_implementation( void *, void * );
+void * com_sun_star_comp_comphelper_OPropertyBag( void *, void * );
+void * com_sun_star_comp_uui_UUIInteractionHandler_get_implementation( void *, void * );
+void * emfio_emfreader_XEmfParser_get_implementation( void *, void * );
+void * i18npool_CalendarImpl_get_implementation( void *, void * );
+void * i18npool_Calendar_gregorian_get_implementation( void *, void * );
+void * unoxml_CXPathAPI_get_implementation( void *, void * );
+void * unoxml_CDocumentBuilder_get_implementation( void *, void * );
+void * sd_PresentationDocument_get_implementation( void *, void * );
+void * ucb_UcbCommandEnvironment_get_implementation( void *, void * );
+void * ucb_UcbContentProviderProxyFactory_get_implementation( void *, void * );
+void * ucb_UcbPropertiesManager_get_implementation( void *, void * );
+void * ucb_UcbStore_get_implementation( void *, void * );
+void * ucb_UniversalContentBroker_get_implementation( void *, void * );
+void * ucb_OFileAccess_get_implementation( void *, void * );
+}
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { "libi18npoollo.a", i18npool_component_getFactory },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { "com_sun_star_i18n_LocaleDataImpl_get_implementation", com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation", com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation", com_sun_star_i18n_BreakIterator_get_implementation },
+ { "com_sun_star_comp_framework_Desktop_get_implementation", com_sun_star_comp_framework_Desktop_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_Unicode_get_implementation", com_sun_star_i18n_CharacterClassification_Unicode_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_get_implementation", com_sun_star_i18n_CharacterClassification_get_implementation },
+ { "com_sun_star_i18n_NativeNumberSupplier_get_implementation", com_sun_star_i18n_NativeNumberSupplier_get_implementation },
+ { "com_sun_star_i18n_NumberFormatCodeMapper_get_implementation", com_sun_star_i18n_NumberFormatCodeMapper_get_implementation },
+ { "com_sun_star_i18n_Transliteration_get_implementation", com_sun_star_i18n_Transliteration_get_implementation },
+ { "com_sun_star_drawing_EnhancedCustomShapeEngine_get_implementation", com_sun_star_drawing_EnhancedCustomShapeEngine_get_implementation },
+ { "com_sun_star_drawing_SvxShapeCollection_get_implementation", com_sun_star_drawing_SvxShapeCollection_get_implementation },
+ { "SfxDocumentMetaData_get_implementation", SfxDocumentMetaData_get_implementation },
+ { "com_sun_star_animations_AnimateColor_get_implementation", com_sun_star_animations_AnimateColor_get_implementation },
+ { "com_sun_star_animations_AnimateMotion_get_implementation", com_sun_star_animations_AnimateMotion_get_implementation },
+ { "com_sun_star_animations_AnimateSet_get_implementation", com_sun_star_animations_AnimateSet_get_implementation },
+ { "com_sun_star_animations_AnimateTransform_get_implementation", com_sun_star_animations_AnimateTransform_get_implementation },
+ { "com_sun_star_animations_Animate_get_implementation", com_sun_star_animations_Animate_get_implementation },
+ { "com_sun_star_animations_Audio_get_implementation", com_sun_star_animations_Audio_get_implementation },
+ { "com_sun_star_animations_Command_get_implementation", com_sun_star_animations_Command_get_implementation },
+ { "com_sun_star_animations_IterateContainer_get_implementation", com_sun_star_animations_IterateContainer_get_implementation },
+ { "com_sun_star_animations_ParallelTimeContainer_get_implementation", com_sun_star_animations_ParallelTimeContainer_get_implementation },
+ { "com_sun_star_animations_SequenceTimeContainer_get_implementation", com_sun_star_animations_SequenceTimeContainer_get_implementation },
+ { "com_sun_star_animations_TransitionFilter_get_implementation", com_sun_star_animations_TransitionFilter_get_implementation },
+ { "com_sun_star_comp_comphelper_OPropertyBag", com_sun_star_comp_comphelper_OPropertyBag },
+ { "com_sun_star_comp_uui_UUIInteractionHandler_get_implementation", com_sun_star_comp_uui_UUIInteractionHandler_get_implementation },
+ { "emfio_emfreader_XEmfParser_get_implementation", emfio_emfreader_XEmfParser_get_implementation},
+ { "i18npool_CalendarImpl_get_implementation", i18npool_CalendarImpl_get_implementation},
+ { "i18npool_Calendar_gregorian_get_implementation", i18npool_Calendar_gregorian_get_implementation},
+ { "unoxml_CXPathAPI_get_implementation", unoxml_CXPathAPI_get_implementation },
+ { "unoxml_CDocumentBuilder_get_implementation", unoxml_CDocumentBuilder_get_implementation },
+ { "sd_PresentationDocument_get_implementation", sd_PresentationDocument_get_implementation },
+ { "ucb_UcbCommandEnvironment_get_implementation", ucb_UcbCommandEnvironment_get_implementation, },
+ { "ucb_UcbContentProviderProxyFactory_get_implementation", ucb_UcbContentProviderProxyFactory_get_implementation },
+ { "ucb_UcbPropertiesManager_get_implementation", ucb_UcbPropertiesManager_get_implementation },
+ { "ucb_UcbStore_get_implementation", ucb_UcbStore_get_implementation },
+ { "ucb_UniversalContentBroker_get_implementation", ucb_UniversalContentBroker_get_implementation },
+ { "ucb_OFileAccess_get_implementation", ucb_OFileAccess_get_implementation },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" void* SdCreateDialogFactory()
+{
+ return nullptr;
+}
+
+extern "C" bool TestImportPPT(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ if (__lsan_disable)
+ __lsan_disable();
+
+ CommonInitialize(argc, argv);
+ SdrObject::GetGlobalDrawObjectItemPool();
+
+ comphelper::getProcessServiceFactory()->createInstance("com.sun.star.comp.Draw.PresentationDocument");
+
+ if (__lsan_enable)
+ __lsan_enable();
+
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportPPT(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/pptfuzzer.options b/vcl/workben/pptfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/pptfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/pptxfuzzer.cxx b/vcl/workben/pptxfuzzer.cxx
new file mode 100644
index 000000000..33c6952ec
--- /dev/null
+++ b/vcl/workben/pptxfuzzer.cxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+extern "C" bool TestImportPPTX(SvStream& rStream);
+
+extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" void* SdCreateDialogFactory() { return nullptr; }
+
+extern "C" void* com_sun_star_comp_Draw_VisioImportFilter_get_implementation() { return nullptr; }
+
+extern "C" void* sdext_PDFIHybridAdaptor_get_implementation() { return nullptr; }
+
+extern "C" void* sdext_PDFIRawAdaptor_Writer_get_implementation() { return nullptr; }
+
+extern "C" void* sdext_PDFIRawAdaptor_Draw_get_implementation() { return nullptr; }
+
+extern "C" void* sdext_PDFIRawAdaptor_Impress_get_implementation() { return nullptr; }
+
+extern "C" void* sdext_PDFDetector_get_implementation() { return nullptr; }
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportPPTX(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/pptxfuzzer.options b/vcl/workben/pptxfuzzer.options
new file mode 100644
index 000000000..e8c2b812b
--- /dev/null
+++ b/vcl/workben/pptxfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 98304
diff --git a/vcl/workben/psdfuzzer.cxx b/vcl/workben/psdfuzzer.cxx
new file mode 100644
index 000000000..652fd1cd3
--- /dev/null
+++ b/vcl/workben/psdfuzzer.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+#include <filter/PsdReader.hxx>
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportPsdGraphic(aStream, aGraphic);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/psdfuzzer.options b/vcl/workben/psdfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/psdfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/qpwfuzzer.cxx b/vcl/workben/qpwfuzzer.cxx
new file mode 100644
index 000000000..0246f840d
--- /dev/null
+++ b/vcl/workben/qpwfuzzer.cxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" {
+void * i18npool_component_getFactory( const char* , void* , void* );
+
+void * com_sun_star_i18n_LocaleDataImpl_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_get_implementation( void *, void * );
+void * com_sun_star_comp_framework_Desktop_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_get_implementation( void *, void * );
+void * com_sun_star_i18n_Collator_get_implementation( void *, void * );
+void * com_sun_star_i18n_NativeNumberSupplier_get_implementation( void *, void * );
+void * com_sun_star_i18n_NumberFormatCodeMapper_get_implementation( void *, void * );
+void * com_sun_star_i18n_Transliteration_get_implementation( void *, void * );
+void * emfio_emfreader_XEmfParser_get_implementation( void *, void * );
+void * i18npool_CalendarImpl_get_implementation( void *, void * );
+}
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { "libi18npoollo.a", i18npool_component_getFactory },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { "com_sun_star_i18n_LocaleDataImpl_get_implementation", com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation", com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation", com_sun_star_i18n_BreakIterator_get_implementation },
+ { "com_sun_star_comp_framework_Desktop_get_implementation", com_sun_star_comp_framework_Desktop_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_Unicode_get_implementation", com_sun_star_i18n_CharacterClassification_Unicode_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_get_implementation", com_sun_star_i18n_CharacterClassification_get_implementation },
+ { "com_sun_star_i18n_Collator_get_implementation", com_sun_star_i18n_Collator_get_implementation },
+ { "com_sun_star_i18n_NativeNumberSupplier_get_implementation", com_sun_star_i18n_NativeNumberSupplier_get_implementation },
+ { "com_sun_star_i18n_NumberFormatCodeMapper_get_implementation", com_sun_star_i18n_NumberFormatCodeMapper_get_implementation },
+ { "com_sun_star_i18n_Transliteration_get_implementation", com_sun_star_i18n_Transliteration_get_implementation },
+ { "emfio_emfreader_XEmfParser_get_implementation", emfio_emfreader_XEmfParser_get_implementation},
+ { "i18npool_CalendarImpl_get_implementation", i18npool_CalendarImpl_get_implementation},
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" void* ScCreateDialogFactory()
+{
+ return nullptr;
+}
+
+extern "C" bool TestImportQPW(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportQPW(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/qpwfuzzer.options b/vcl/workben/qpwfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/qpwfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/rasfuzzer.cxx b/vcl/workben/rasfuzzer.cxx
new file mode 100644
index 000000000..84678eace
--- /dev/null
+++ b/vcl/workben/rasfuzzer.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+#include <filter/RasReader.hxx>
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportRasGraphic(aStream, aGraphic);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/rasfuzzer.options b/vcl/workben/rasfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/rasfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/rtffuzzer.cxx b/vcl/workben/rtffuzzer.cxx
new file mode 100644
index 000000000..cd68a84ed
--- /dev/null
+++ b/vcl/workben/rtffuzzer.cxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" {
+void * i18npool_component_getFactory( const char* , void* , void* );
+
+void * com_sun_star_i18n_LocaleDataImpl_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_get_implementation( void *, void * );
+void * com_sun_star_comp_framework_Desktop_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_get_implementation( void *, void * );
+void * com_sun_star_i18n_NativeNumberSupplier_get_implementation( void *, void * );
+void * com_sun_star_i18n_NumberFormatCodeMapper_get_implementation( void *, void * );
+void * com_sun_star_i18n_Transliteration_get_implementation( void *, void * );
+void * com_sun_star_comp_Writer_RtfFilter_get_implementation( void *, void * );
+void * emfio_emfreader_XEmfParser_get_implementation( void *, void * );
+}
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { "libi18npoollo.a", i18npool_component_getFactory },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { "com_sun_star_i18n_LocaleDataImpl_get_implementation", com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation", com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation", com_sun_star_i18n_BreakIterator_get_implementation },
+ { "com_sun_star_comp_framework_Desktop_get_implementation", com_sun_star_comp_framework_Desktop_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_Unicode_get_implementation", com_sun_star_i18n_CharacterClassification_Unicode_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_get_implementation", com_sun_star_i18n_CharacterClassification_get_implementation },
+ { "com_sun_star_i18n_NativeNumberSupplier_get_implementation", com_sun_star_i18n_NativeNumberSupplier_get_implementation },
+ { "com_sun_star_i18n_NumberFormatCodeMapper_get_implementation", com_sun_star_i18n_NumberFormatCodeMapper_get_implementation },
+ { "com_sun_star_i18n_Transliteration_get_implementation", com_sun_star_i18n_Transliteration_get_implementation },
+ { "com_sun_star_comp_Writer_RtfFilter_get_implementation", com_sun_star_comp_Writer_RtfFilter_get_implementation },
+ { "emfio_emfreader_XEmfParser_get_implementation", emfio_emfreader_XEmfParser_get_implementation},
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" void* SwCreateDialogFactory()
+{
+ return nullptr;
+}
+
+extern "C" bool TestImportRTF(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportRTF(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/rtffuzzer.options b/vcl/workben/rtffuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/rtffuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/scrtffuzzer.cxx b/vcl/workben/scrtffuzzer.cxx
new file mode 100644
index 000000000..56c0cddd7
--- /dev/null
+++ b/vcl/workben/scrtffuzzer.cxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" {
+void* i18npool_component_getFactory(const char*, void*, void*);
+
+void* com_sun_star_i18n_LocaleDataImpl_get_implementation(void*, void*);
+void* com_sun_star_i18n_BreakIterator_Unicode_get_implementation(void*, void*);
+void* com_sun_star_i18n_BreakIterator_get_implementation(void*, void*);
+void* com_sun_star_comp_framework_Desktop_get_implementation(void*, void*);
+void* com_sun_star_i18n_CharacterClassification_Unicode_get_implementation(void*, void*);
+void* com_sun_star_i18n_CharacterClassification_get_implementation(void*, void*);
+void* com_sun_star_i18n_NativeNumberSupplier_get_implementation(void*, void*);
+void* com_sun_star_i18n_NumberFormatCodeMapper_get_implementation(void*, void*);
+void* com_sun_star_i18n_Transliteration_get_implementation(void*, void*);
+void* i18npool_CalendarImpl_get_implementation(void*, void*);
+}
+
+const lib_to_factory_mapping* lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[]
+ = { { "libi18npoollo.a", i18npool_component_getFactory }, { 0, 0 } };
+
+ return map;
+}
+
+const lib_to_constructor_mapping* lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[]
+ = { { "com_sun_star_i18n_LocaleDataImpl_get_implementation",
+ com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation",
+ com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation",
+ com_sun_star_i18n_BreakIterator_get_implementation },
+ { "com_sun_star_comp_framework_Desktop_get_implementation",
+ com_sun_star_comp_framework_Desktop_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_Unicode_get_implementation",
+ com_sun_star_i18n_CharacterClassification_Unicode_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_get_implementation",
+ com_sun_star_i18n_CharacterClassification_get_implementation },
+ { "com_sun_star_i18n_NativeNumberSupplier_get_implementation",
+ com_sun_star_i18n_NativeNumberSupplier_get_implementation },
+ { "com_sun_star_i18n_NumberFormatCodeMapper_get_implementation",
+ com_sun_star_i18n_NumberFormatCodeMapper_get_implementation },
+ { "com_sun_star_i18n_Transliteration_get_implementation",
+ com_sun_star_i18n_Transliteration_get_implementation },
+ { "i18npool_CalendarImpl_get_implementation",
+ i18npool_CalendarImpl_get_implementation },
+ { 0, 0 } };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*) { return nullptr; }
+
+extern "C" void* ScCreateDialogFactory() { return nullptr; }
+
+extern "C" bool TestImportCalcRTF(SvStream& rStream);
+
+extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportCalcRTF(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/scrtffuzzer.options b/vcl/workben/scrtffuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/scrtffuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/sftfuzzer.cxx b/vcl/workben/sftfuzzer.cxx
new file mode 100644
index 000000000..f0a4a9a8c
--- /dev/null
+++ b/vcl/workben/sftfuzzer.cxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <fontsubset.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping* lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = { { 0, 0 } };
+
+ return map;
+}
+
+const lib_to_constructor_mapping* lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = { { 0, 0 } };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*) { return nullptr; }
+
+extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ return TestFontSubset(data, size);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/sftfuzzer.options b/vcl/workben/sftfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/sftfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/slkfuzzer.cxx b/vcl/workben/slkfuzzer.cxx
new file mode 100644
index 000000000..ddf048787
--- /dev/null
+++ b/vcl/workben/slkfuzzer.cxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" {
+void * i18npool_component_getFactory( const char* , void* , void* );
+
+void * com_sun_star_i18n_LocaleDataImpl_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_get_implementation( void *, void * );
+void * com_sun_star_comp_framework_Desktop_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_get_implementation( void *, void * );
+void * com_sun_star_i18n_Collator_get_implementation( void *, void * );
+void * com_sun_star_i18n_NativeNumberSupplier_get_implementation( void *, void * );
+void * com_sun_star_i18n_NumberFormatCodeMapper_get_implementation( void *, void * );
+void * com_sun_star_i18n_Transliteration_get_implementation( void *, void * );
+void * emfio_emfreader_XEmfParser_get_implementation( void *, void * );
+void * i18npool_CalendarImpl_get_implementation( void *, void * );
+}
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { "libi18npoollo.a", i18npool_component_getFactory },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { "com_sun_star_i18n_LocaleDataImpl_get_implementation", com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation", com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation", com_sun_star_i18n_BreakIterator_get_implementation },
+ { "com_sun_star_comp_framework_Desktop_get_implementation", com_sun_star_comp_framework_Desktop_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_Unicode_get_implementation", com_sun_star_i18n_CharacterClassification_Unicode_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_get_implementation", com_sun_star_i18n_CharacterClassification_get_implementation },
+ { "com_sun_star_i18n_Collator_get_implementation", com_sun_star_i18n_Collator_get_implementation },
+ { "com_sun_star_i18n_NativeNumberSupplier_get_implementation", com_sun_star_i18n_NativeNumberSupplier_get_implementation },
+ { "com_sun_star_i18n_NumberFormatCodeMapper_get_implementation", com_sun_star_i18n_NumberFormatCodeMapper_get_implementation },
+ { "com_sun_star_i18n_Transliteration_get_implementation", com_sun_star_i18n_Transliteration_get_implementation },
+ { "emfio_emfreader_XEmfParser_get_implementation", emfio_emfreader_XEmfParser_get_implementation},
+ { "i18npool_CalendarImpl_get_implementation", i18npool_CalendarImpl_get_implementation},
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" void* ScCreateDialogFactory()
+{
+ return nullptr;
+}
+
+extern "C" bool TestImportSLK(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportSLK(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/slkfuzzer.options b/vcl/workben/slkfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/slkfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/svdem.cxx b/vcl/workben/svdem.cxx
new file mode 100644
index 000000000..27245ac84
--- /dev/null
+++ b/vcl/workben/svdem.cxx
@@ -0,0 +1,105 @@
+/* -*- 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/main.h>
+#include <sal/log.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/extendapplicationenvironment.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <comphelper/processfactory.hxx>
+#include <i18nlangtag/languagetag.hxx>
+#include <i18nlangtag/mslangid.hxx>
+#include <framework/desktop.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <vcl/event.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace cppu;
+
+// Forward declaration
+static void Main();
+
+SAL_IMPLEMENT_MAIN()
+{
+ try
+ {
+ tools::extendApplicationEnvironment();
+
+ Reference< XComponentContext > xContext = defaultBootstrap_InitialComponentContext();
+ Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY );
+
+ if( !xServiceManager.is() )
+ Application::Abort( "Failed to bootstrap" );
+
+ comphelper::setProcessServiceFactory( xServiceManager );
+
+ LanguageTag::setConfiguredSystemLanguage(MsLangId::getSystemLanguage());
+
+ InitVCL();
+ ::Main();
+
+ framework::getDesktop(::comphelper::getProcessComponentContext())->terminate();
+
+ DeInitVCL();
+ }
+ catch (const Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("vcl.app", "Fatal");
+ return 1;
+ }
+ catch (const std::exception &e)
+ {
+ fprintf(stderr, "fatal error: %s\n", e.what());
+ return 1;
+ }
+
+ return 0;
+}
+
+namespace {
+
+class MyWin : public WorkWindow
+{
+public:
+ MyWin( vcl::Window* pParent, WinBits nWinStyle );
+};
+
+}
+
+void Main()
+{
+ ScopedVclPtrInstance< MyWin > aMainWin( nullptr, WB_APP | WB_STDWORK );
+ aMainWin->SetText("VCL - Workbench");
+ aMainWin->Show();
+
+ Application::Execute();
+}
+
+MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) :
+ WorkWindow( pParent, nWinStyle )
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/svmfuzzer.cxx b/vcl/workben/svmfuzzer.cxx
new file mode 100644
index 000000000..53757e319
--- /dev/null
+++ b/vcl/workben/svmfuzzer.cxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" bool TestImportSVM(SvStream &rStream);
+
+extern "C" {
+void * com_sun_star_i18n_LocaleDataImpl_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_get_implementation( void *, void * );
+void * com_sun_star_i18n_NativeNumberSupplier_get_implementation( void *, void * );
+void * com_sun_star_i18n_NumberFormatCodeMapper_get_implementation( void *, void * );
+void * com_sun_star_comp_rendering_CanvasFactory_get_implementation( void *, void * );
+void * com_sun_star_comp_rendering_Canvas_VCL_get_implementation( void *, void * );
+void * linguistic_ConvDicList_get_implementation( void *, void * );
+void * linguistic_DicList_get_implementation( void *, void * );
+void * linguistic_LinguProps_get_implementation( void *, void * );
+void * linguistic_LngSvcMgr_get_implementation( void *, void * );
+void * linguistic_GrammarCheckingIterator_get_implementation( void *, void * );
+}
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { "com_sun_star_i18n_LocaleDataImpl_get_implementation", com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation", com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation", com_sun_star_i18n_BreakIterator_get_implementation },
+ { "com_sun_star_i18n_NativeNumberSupplier_get_implementation", com_sun_star_i18n_NativeNumberSupplier_get_implementation },
+ { "com_sun_star_i18n_NumberFormatCodeMapper_get_implementation", com_sun_star_i18n_NumberFormatCodeMapper_get_implementation },
+ { "com_sun_star_comp_rendering_CanvasFactory_get_implementation", com_sun_star_comp_rendering_CanvasFactory_get_implementation },
+ { "com_sun_star_comp_rendering_Canvas_VCL_get_implementation", com_sun_star_comp_rendering_Canvas_VCL_get_implementation },
+ { "linguistic_ConvDicList_get_implementation", linguistic_ConvDicList_get_implementation },
+ { "linguistic_DicList_get_implementation", linguistic_DicList_get_implementation },
+ { "linguistic_LinguProps_get_implementation", linguistic_LinguProps_get_implementation },
+ { "linguistic_LngSvcMgr_get_implementation", linguistic_LngSvcMgr_get_implementation },
+ { "linguistic_GrammarCheckingIterator_get_implementation", linguistic_GrammarCheckingIterator_get_implementation },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportSVM(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/svmfuzzer.options b/vcl/workben/svmfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/svmfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/svpclient.cxx b/vcl/workben/svpclient.cxx
new file mode 100644
index 000000000..b87745485
--- /dev/null
+++ b/vcl/workben/svpclient.cxx
@@ -0,0 +1,284 @@
+/* -*- 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/main.h>
+#include <sal/log.hxx>
+
+#include <cppuhelper/bootstrap.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <vcl/event.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/toolkit/button.hxx>
+#include <vcl/toolkit/fixed.hxx>
+#include <vcl/toolkit/lstbox.hxx>
+#include <vcl/bitmapex.hxx>
+#include <vcl/graphicfilter.hxx>
+#include <vcl/graph.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/extendapplicationenvironment.hxx>
+#include <tools/stream.hxx>
+
+#include <rtl/strbuf.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <o3tl/string_view.hxx>
+
+#include <math.h>
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace cppu;
+
+// Forward declaration
+static void Main();
+
+SAL_IMPLEMENT_MAIN()
+{
+ try
+ {
+ tools::extendApplicationEnvironment();
+
+ // create the global service-manager
+ Reference< XComponentContext > xContext = defaultBootstrap_InitialComponentContext();
+ Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY );
+
+ if( !xServiceManager.is() )
+ Application::Abort( "Failed to bootstrap" );
+
+ comphelper::setProcessServiceFactory( xServiceManager );
+
+ InitVCL();
+ ::Main();
+ DeInitVCL();
+ }
+ catch (const Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("vcl", "Fatal");
+ return 1;
+ }
+ catch (const std::exception& e)
+ {
+ SAL_WARN("vcl", "Fatal: " << e.what());
+ return 1;
+ }
+
+ return 0;
+}
+
+namespace {
+
+class MyWin : public WorkWindow
+{
+ VclPtr<PushButton> m_aListButton;
+ VclPtr<ListBox> m_aSvpBitmaps;
+ VclPtr<FixedImage> m_aImage;
+ VclPtr<PushButton> m_aQuitButton;
+public:
+ MyWin( vcl::Window* pParent, WinBits nWinStyle );
+
+ virtual bool Close() override;
+ virtual ~MyWin() override { disposeOnce(); }
+ virtual void dispose() override;
+
+ void parseList( std::string_view rList );
+ static OString processCommand( const OString& rCommand );
+
+ DECL_LINK( ListHdl, Button*, void );
+ DECL_LINK( SelectHdl, ListBox&, void );
+ DECL_STATIC_LINK( MyWin, QuitHdl, Button*, void );
+};
+
+}
+
+void Main()
+{
+ ScopedVclPtrInstance< MyWin > aMainWin( nullptr, WB_STDWORK );
+ aMainWin->SetText( "SvpClient" );
+ aMainWin->Show();
+
+ Application::Execute();
+}
+
+MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) :
+ WorkWindow( pParent, nWinStyle ),
+ m_aListButton(VclPtr<PushButton>::Create(this, 0)),
+ m_aSvpBitmaps(VclPtr<ListBox>::Create(this, WB_BORDER)),
+ m_aImage(VclPtr<FixedImage>::Create(this, WB_BORDER)),
+ m_aQuitButton(VclPtr<PushButton>::Create(this, 0))
+{
+ m_aListButton->SetPosSizePixel( Point( 10, 10 ), Size( 120, 25 ) );
+ m_aListButton->SetText( "List Elements" );
+ m_aListButton->SetClickHdl( LINK( this, MyWin, ListHdl ) );
+ m_aListButton->Show();
+
+ m_aSvpBitmaps->SetPosSizePixel( Point( 10, 40 ), Size( 150, 150 ) );
+ m_aSvpBitmaps->SetSelectHdl( LINK( this, MyWin, SelectHdl ) );
+ m_aSvpBitmaps->Show();
+
+ m_aImage->SetPosSizePixel( Point( 170, 10 ), Size( 400, 400 ) );
+ m_aImage->Show();
+
+ m_aQuitButton->SetPosSizePixel( Point( 10, 300 ), Size( 120,25 ) );
+ m_aQuitButton->SetText( "Quit SVP server" );
+ m_aQuitButton->SetClickHdl( LINK( this, MyWin, QuitHdl ) );
+ m_aQuitButton->Show();
+}
+
+bool MyWin::Close()
+{
+ bool bRet = WorkWindow::Close();
+ if( bRet )
+ Application::Quit();
+ return bRet;
+}
+
+void MyWin::dispose()
+{
+ m_aListButton.disposeAndClear();
+ m_aSvpBitmaps.disposeAndClear();
+ m_aImage.disposeAndClear();
+ m_aQuitButton.disposeAndClear();
+ WorkWindow::dispose();
+}
+
+void MyWin::parseList( std::string_view rList )
+{
+ sal_Int32 nTokenPos = 0;
+ OUString aElementType;
+ m_aSvpBitmaps->Clear();
+ while( nTokenPos >= 0 )
+ {
+ std::string_view aLine = o3tl::getToken(rList, 0, '\n', nTokenPos );
+ if( aLine.empty() || aLine[0] == '#' )
+ continue;
+
+ if( o3tl::starts_with(aLine, "ElementType: " ) )
+ aElementType = OStringToOUString( aLine.substr( 13 ), RTL_TEXTENCODING_ASCII_US );
+ else
+ {
+ OUString aNewElement =
+ aElementType + ": " +
+ OStringToOUString( aLine, RTL_TEXTENCODING_ASCII_US );
+ m_aSvpBitmaps->InsertEntry( aNewElement );
+ }
+ }
+}
+
+OString MyWin::processCommand( const OString& rCommand )
+{
+ static const char* pEnv = getenv("SVP_LISTENER_PORT");
+ OStringBuffer aAnswer;
+ int nPort = (pEnv && *pEnv) ? atoi(pEnv) : 8000;
+ int nSocket = socket( PF_INET, SOCK_STREAM, 0 );
+ if( nSocket >= 0)
+ {
+ struct sockaddr_in addr;
+ memset(&addr, 0, sizeof(struct sockaddr_in));
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(nPort);
+ addr.sin_addr.s_addr = INADDR_ANY;
+ if( connect( nSocket, reinterpret_cast<sockaddr*>(&addr), sizeof(addr) ) )
+ {
+ perror( "SvpElementContainer: connect() failed" );
+ }
+ else
+ {
+ ssize_t nBytes = 0;
+ ssize_t fd = write( nSocket, rCommand.getStr(), rCommand.getLength() );
+
+ if (fd == 0)
+ SAL_WARN("vcl", "Connection closed on other end");
+ else if (fd < 0)
+ SAL_WARN("vcl", "Error writing to socket: " << strerror( errno ));
+
+ fd = write( nSocket, "\n", 1 );
+
+ if (fd == 0)
+ SAL_WARN("vcl", "Connection closed on other end");
+ else if (fd < 0)
+ SAL_WARN("vcl", "Error writing to socket: " << strerror( errno ));
+
+
+ char buf[256];
+ do
+ {
+ nBytes = read( nSocket, buf, sizeof(buf) );
+ aAnswer.append( buf, nBytes );
+ } while( nBytes == sizeof( buf ) );
+ }
+ close(nSocket);
+ }
+ else
+ perror( "SvpElementContainer: socket() failed\n" );
+ return aAnswer.makeStringAndClear();
+}
+
+IMPL_LINK_NOARG( MyWin, ListHdl, Button*, void)
+{
+ parseList( processCommand( "list" ) );
+}
+
+IMPL_STATIC_LINK_NOARG( MyWin, QuitHdl, Button*, void)
+{
+ processCommand( "quit" );
+}
+
+IMPL_LINK_NOARG( MyWin, SelectHdl, ListBox&, void)
+{
+ OUString aEntry = m_aSvpBitmaps->GetSelectedEntry();
+ sal_Int32 nPos = aEntry.indexOf( ": " );
+ if( nPos == -1 )
+ return;
+
+ OString aCommand =
+ "get " +
+ OUStringToOString( aEntry.subView( nPos+2 ), RTL_TEXTENCODING_ASCII_US );
+ OString aAnswer( processCommand( aCommand ) );
+ SvMemoryStream aStream( aAnswer.getLength() );
+ aStream.WriteBytes( aAnswer.getStr(), aAnswer.getLength() );
+ aStream.Seek( STREAM_SEEK_TO_BEGIN );
+
+ Graphic aGraphicResult;
+ GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
+ rFilter.ImportGraphic( aGraphicResult, u"import", aStream );
+
+ BitmapEx aBitmap = aGraphicResult.GetBitmapEx();
+
+ SAL_INFO("vcl", "got bitmap of size " << aBitmap.GetSizePixel().Width() << "x" << aBitmap.GetSizePixel().Height());
+ Size aFixedSize( aBitmap.GetSizePixel() );
+ aFixedSize.AdjustWidth(10 );
+ aFixedSize.AdjustHeight(10 );
+ m_aImage->SetSizePixel( aFixedSize );
+ m_aImage->SetImage( Image( aBitmap ) );
+
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/svptest.cxx b/vcl/workben/svptest.cxx
new file mode 100644
index 000000000..dde13e256
--- /dev/null
+++ b/vcl/workben/svptest.cxx
@@ -0,0 +1,327 @@
+/* -*- 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 <sal/main.h>
+#include <sal/log.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/extendapplicationenvironment.hxx>
+
+#include <cppuhelper/bootstrap.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <vcl/event.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/gradient.hxx>
+#include <vcl/lineinfo.hxx>
+#include <vcl/bitmap.hxx>
+#include <vcl/metric.hxx>
+#include <vcl/vclptr.hxx>
+#include <bitmap/BitmapWriteAccess.hxx>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <math.h>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace cppu;
+
+// Forward declaration
+static void Main();
+
+SAL_IMPLEMENT_MAIN()
+{
+ try
+ {
+ tools::extendApplicationEnvironment();
+
+ Reference< XComponentContext > xContext = defaultBootstrap_InitialComponentContext();
+ Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY );
+
+ if( !xServiceManager.is() )
+ Application::Abort( "Failed to bootstrap" );
+
+ comphelper::setProcessServiceFactory( xServiceManager );
+
+ InitVCL();
+ ::Main();
+ DeInitVCL();
+ }
+ catch (const Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("vcl.app", "Fatal");
+ return 1;
+ }
+ catch (const std::exception &e)
+ {
+ fprintf(stderr, "fatal error: %s\n", e.what());
+ return 1;
+ }
+
+ return 0;
+}
+
+namespace {
+
+class MyWin : public WorkWindow
+{
+ Bitmap m_aBitmap;
+public:
+ MyWin( vcl::Window* pParent, WinBits nWinStyle );
+
+ virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle& rRect ) override;
+};
+
+}
+
+void Main()
+{
+ ScopedVclPtrInstance< MyWin > aMainWin( nullptr, WB_APP | WB_STDWORK );
+ aMainWin->SetText( "VCL - Workbench" );
+ aMainWin->Show();
+
+ Application::Execute();
+}
+
+MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) :
+ WorkWindow( pParent, nWinStyle ),
+ m_aBitmap(Size(256, 256), vcl::PixelFormat::N32_BPP)
+{
+ // prepare an alpha mask
+ BitmapWriteAccess* pAcc = m_aBitmap.AcquireWriteAccess();
+ for( int nX = 0; nX < 256; nX++ )
+ {
+ for( int nY = 0; nY < 256; nY++ )
+ {
+ double fRed = 255.0-1.5*std::hypot(nX, nY);
+ if( fRed < 0.0 )
+ fRed = 0.0;
+ double fGreen = 255.0-1.5*std::hypot(255-nX, nY);
+ if( fGreen < 0.0 )
+ fGreen = 0.0;
+ double fBlue = 255.0-1.5*std::hypot(128-nX, 255-nY);
+ if( fBlue < 0.0 )
+ fBlue = 0.0;
+ pAcc->SetPixel( nY, nX, BitmapColor( sal_uInt8(fRed), sal_uInt8(fGreen), sal_uInt8(fBlue) ) );
+ }
+ }
+ Bitmap::ReleaseAccess( pAcc );
+}
+
+static Point project( const Point& rPoint )
+{
+ const double angle_x = M_PI / 6.0;
+ const double angle_z = M_PI / 6.0;
+
+ // transform planar coordinates to 3d
+ double x = rPoint.X();
+ double y = rPoint.Y();
+
+ // rotate around X axis
+ double x1 = x;
+ double y1 = y * cos( angle_x );
+ double z1 = y * sin( angle_x );
+
+ // rotate around Z axis
+ double x2 = x1 * cos( angle_z ) + y1 * sin( angle_z );
+ //double y2 = y1 * cos( angle_z ) - x1 * sin( angle_z );
+ double z2 = z1;
+
+ return Point( static_cast<sal_Int32>(x2), static_cast<sal_Int32>(z2) );
+}
+
+static Color approachColor( const Color& rFrom, const Color& rTo )
+{
+ Color aColor;
+ sal_uInt8 nDiff;
+ // approach red
+ if( rFrom.GetRed() < rTo.GetRed() )
+ {
+ nDiff = rTo.GetRed() - rFrom.GetRed();
+ aColor.SetRed( rFrom.GetRed() + std::min<sal_uInt8>( nDiff, 10 ) );
+ }
+ else if( rFrom.GetRed() > rTo.GetRed() )
+ {
+ nDiff = rFrom.GetRed() - rTo.GetRed();
+ aColor.SetRed( rFrom.GetRed() - std::min<sal_uInt8>( nDiff, 10 ) );
+ }
+ else
+ aColor.SetRed( rFrom.GetRed() );
+
+ // approach Green
+ if( rFrom.GetGreen() < rTo.GetGreen() )
+ {
+ nDiff = rTo.GetGreen() - rFrom.GetGreen();
+ aColor.SetGreen( rFrom.GetGreen() + std::min<sal_uInt8>( nDiff, 10 ) );
+ }
+ else if( rFrom.GetGreen() > rTo.GetGreen() )
+ {
+ nDiff = rFrom.GetGreen() - rTo.GetGreen();
+ aColor.SetGreen( rFrom.GetGreen() - std::min<sal_uInt8>( nDiff, 10 ) );
+ }
+ else
+ aColor.SetGreen( rFrom.GetGreen() );
+
+ // approach blue
+ if( rFrom.GetBlue() < rTo.GetBlue() )
+ {
+ nDiff = rTo.GetBlue() - rFrom.GetBlue();
+ aColor.SetBlue( rFrom.GetBlue() + std::min<sal_uInt8>( nDiff, 10 ) );
+ }
+ else if( rFrom.GetBlue() > rTo.GetBlue() )
+ {
+ nDiff = rFrom.GetBlue() - rTo.GetBlue();
+ aColor.SetBlue( rFrom.GetBlue() - std::min<sal_uInt8>( nDiff, 10 ) );
+ }
+ else
+ aColor.SetBlue( rFrom.GetBlue() );
+
+ return aColor;
+}
+
+#define DELTA 5.0
+void MyWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
+{
+ WorkWindow::Paint(rRenderContext, rRect);
+
+ rRenderContext.Push();
+ MapMode aMapMode(MapUnit::Map100thMM);
+
+ rRenderContext.SetMapMode(aMapMode);
+
+ Size aPaperSize = rRenderContext.GetOutputSize();
+ Point aCenter(aPaperSize.Width() / 2 - 300,
+ (aPaperSize.Height() - 8400) / 2 + 8400);
+ Point aP1(aPaperSize.Width() / 48, 0), aP2(aPaperSize.Width() / 40, 0);
+ Point aPoint;
+
+ rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), aPaperSize));
+ rRenderContext.DrawRect(tools::Rectangle(Point(100, 100),
+ Size(aPaperSize.Width() - 200,
+ aPaperSize.Height() - 200)));
+ rRenderContext.DrawRect(tools::Rectangle(Point(200, 200),
+ Size(aPaperSize.Width() - 400,
+ aPaperSize.Height() - 400)));
+ rRenderContext.DrawRect(tools::Rectangle(Point(300, 300),
+ Size(aPaperSize.Width() - 600,
+ aPaperSize.Height() - 600)));
+
+ const int nFontCount = rRenderContext.GetFontFaceCollectionCount();
+ const int nFontSamples = (nFontCount < 15) ? nFontCount : 15;
+ for (int i = 0; i < nFontSamples; ++i)
+ {
+
+ FontMetric aFont(rRenderContext.GetFontMetricFromCollection((i * nFontCount) / nFontSamples));
+ aFont.SetFontHeight(400 + (i % 7) * 100);
+ aFont.SetOrientation(Degree10(i * (3600 / nFontSamples)));
+ rRenderContext.SetFont(aFont);
+
+ sal_uInt8 nRed = (i << 6) & 0xC0;
+ sal_uInt8 nGreen = (i << 4) & 0xC0;
+ sal_uInt8 nBlue = (i << 2) & 0xC0;
+ rRenderContext.SetTextColor(Color(nRed, nGreen, nBlue));
+
+ rRenderContext.DrawText(tools::Rectangle(Point((aPaperSize.Width() - 4000) / 2, 2000),
+ Size(aPaperSize.Width() - 2100, aPaperSize.Height() - 4000)),
+ "SVP test program",
+ DrawTextFlags::MultiLine);
+ }
+
+ rRenderContext.SetFillColor();
+ rRenderContext.DrawRect(tools::Rectangle(Point(aPaperSize.Width() - 4000, 1000),
+ Size(3000, 3000)));
+ rRenderContext.DrawBitmap(Point(aPaperSize.Width() - 4000, 1000),
+ Size( 3000,3000 ),
+ m_aBitmap);
+
+ Color const aWhite(0xff, 0xff, 0xff);
+ Color const aBlack(0, 0, 0);
+ Color const aLightRed(0xff, 0, 0);
+ Color const aDarkRed(0x40, 0, 0);
+ Color const aLightBlue(0, 0, 0xff);
+ Color const aDarkBlue(0,0,0x40);
+ Color const aLightGreen(0, 0xff, 0);
+ Color const aDarkGreen(0, 0x40, 0);
+
+ Gradient aGradient(GradientStyle::Linear, aBlack, aWhite);
+ aGradient.SetAngle(900_deg10);
+ rRenderContext.DrawGradient(tools::Rectangle(Point(1000, 4500),
+ Size(aPaperSize.Width() - 2000, 500)),
+ aGradient);
+ aGradient.SetStartColor(aDarkRed);
+ aGradient.SetEndColor(aLightBlue);
+ rRenderContext.DrawGradient(tools::Rectangle(Point(1000, 5300),
+ Size(aPaperSize.Width() - 2000, 500)),
+ aGradient);
+ aGradient.SetStartColor(aDarkBlue);
+ aGradient.SetEndColor(aLightGreen);
+ rRenderContext.DrawGradient(tools::Rectangle(Point(1000, 6100),
+ Size(aPaperSize.Width() - 2000, 500)),
+ aGradient);
+ aGradient.SetStartColor(aDarkGreen);
+ aGradient.SetEndColor(aLightRed);
+ rRenderContext.DrawGradient(tools::Rectangle(Point(1000, 6900),
+ Size(aPaperSize.Width() - 2000, 500)),
+ aGradient);
+
+ LineInfo aLineInfo(LineStyle::Solid, 200);
+ const double sind = sin(basegfx::deg2rad(DELTA));
+ const double cosd = cos(basegfx::deg2rad(DELTA));
+ const double factor = 1 + (DELTA / 1000.0);
+ int n = 0;
+ Color aLineColor(0, 0, 0);
+ Color aApproachColor(0, 0, 200);
+
+ while (aP2.X() < aCenter.X() && n++ < 680)
+ {
+ aLineInfo.SetWidth(n / 3);
+ aLineColor = approachColor(aLineColor, aApproachColor);
+ rRenderContext.SetLineColor(aLineColor);
+
+ // switch approach color
+ if (aApproachColor.IsRGBEqual(aLineColor))
+ {
+ if (aApproachColor.GetRed())
+ aApproachColor = Color(0, 0, 200);
+ else if (aApproachColor.GetGreen())
+ aApproachColor = Color(200, 0, 0);
+ else
+ aApproachColor = Color(0, 200, 0);
+ }
+
+ rRenderContext.DrawLine(project(aP1) + aCenter,
+ project(aP2) + aCenter,
+ aLineInfo);
+ aPoint.setX( static_cast<int>((static_cast<double>(aP1.X())*cosd - static_cast<double>(aP1.Y())*sind)*factor) );
+ aPoint.setY( static_cast<int>((static_cast<double>(aP1.Y())*cosd + static_cast<double>(aP1.X())*sind)*factor) );
+ aP1 = aPoint;
+ aPoint.setX( static_cast<int>((static_cast<double>(aP2.X())*cosd - static_cast<double>(aP2.Y())*sind)*factor) );
+ aPoint.setY( static_cast<int>((static_cast<double>(aP2.Y())*cosd + static_cast<double>(aP2.X())*sind)*factor) );
+ aP2 = aPoint;
+ }
+ rRenderContext.Pop();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/tgafuzzer.cxx b/vcl/workben/tgafuzzer.cxx
new file mode 100644
index 000000000..32b7fcb3d
--- /dev/null
+++ b/vcl/workben/tgafuzzer.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+#include <filter/TgaReader.hxx>
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportTgaGraphic(aStream, aGraphic);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/tgafuzzer.options b/vcl/workben/tgafuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/tgafuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/tiffuzzer.cxx b/vcl/workben/tiffuzzer.cxx
new file mode 100644
index 000000000..14dcf42ec
--- /dev/null
+++ b/vcl/workben/tiffuzzer.cxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include <filter/TiffReader.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ try
+ {
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportTiffGraphicImport(aStream, aGraphic);
+ }
+ catch (...)
+ {
+ }
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/tiffuzzer.options b/vcl/workben/tiffuzzer.options
new file mode 100644
index 000000000..f0ed890b6
--- /dev/null
+++ b/vcl/workben/tiffuzzer.options
@@ -0,0 +1,3 @@
+[libfuzzer]
+max_len = 65536
+dict = tiff.dict
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
new file mode 100644
index 000000000..98a225b97
--- /dev/null
+++ b/vcl/workben/vcldemo.cxx
@@ -0,0 +1,2271 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/config.h>
+
+#include <memory>
+
+#include <config_features.h>
+
+#include <math.h>
+#include <rtl/math.hxx>
+#include <sal/log.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/random.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/ucb/UniversalContentBroker.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <o3tl/safeint.hxx>
+#include <osl/time.h>
+#include <vcl/gradient.hxx>
+#include <vcl/vclmain.hxx>
+#include <vcl/layout.hxx>
+#include <vcl/ptrstyle.hxx>
+#include <salhelper/thread.hxx>
+
+#include <tools/diagnose_ex.h>
+#include <tools/urlobj.hxx>
+#include <tools/stream.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/graphicfilter.hxx>
+#include <vcl/toolkit/button.hxx>
+#include <vcl/toolkit/combobox.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/pngwrite.hxx>
+#include <vcl/toolkit/floatwin.hxx>
+#include <vcl/help.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/ImageTree.hxx>
+#include <vcl/BitmapEmbossGreyFilter.hxx>
+
+#include <bitmap/BitmapWriteAccess.hxx>
+
+#include <basegfx/numeric/ftools.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+
+#include <framework/desktop.hxx>
+#include <i18nlangtag/languagetag.hxx>
+#include <i18nlangtag/mslangid.hxx>
+
+#define FIXME_SELF_INTERSECTING_WORKING 0
+#define FIXME_BOUNCE_BUTTON 0
+#define THUMB_REPEAT_FACTOR 10
+
+using namespace com::sun::star;
+
+namespace {
+ double getTimeNow()
+ {
+ TimeValue aValue;
+ osl_getSystemTime(&aValue);
+ return static_cast<double>(aValue.Seconds) * 1000 +
+ static_cast<double>(aValue.Nanosec) / (1000*1000);
+ }
+
+}
+
+namespace {
+
+enum RenderStyle {
+ RENDER_THUMB, // small view <n> to a page
+ RENDER_EXPANDED, // expanded view of this renderer
+};
+
+class DemoRenderer
+{
+ Bitmap maIntroBW;
+ BitmapEx maIntro;
+
+ int mnSegmentsX;
+ int mnSegmentsY;
+
+ struct RenderContext {
+ RenderStyle meStyle;
+ bool mbVDev;
+ DemoRenderer *mpDemoRenderer;
+ Size maSize;
+ };
+ struct RegionRenderer {
+ public:
+ RegionRenderer() :
+ sumTime(0),
+ countTime(0)
+ { }
+ virtual ~RegionRenderer() {}
+ virtual OUString getName() = 0;
+ virtual sal_uInt16 getAccelerator() = 0;
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &rCtx) = 0;
+ // repeating count for profiling (to exceed the poor time resolution on Windows)
+ virtual sal_uInt16 getTestRepeatCount() = 0;
+#define RENDER_DETAILS(name,key,repeat) \
+ virtual OUString getName() override \
+ { return SAL_STRINGIFY(name); } \
+ virtual sal_uInt16 getAccelerator() override \
+ { return key; } \
+ virtual sal_uInt16 getTestRepeatCount() override \
+ { return repeat; }
+
+ double sumTime;
+ int countTime;
+ };
+
+ std::vector< RegionRenderer * > maRenderers;
+ sal_Int32 mnSelectedRenderer;
+ sal_Int32 iterCount;
+
+ void InitRenderers();
+
+public:
+ DemoRenderer() : mnSegmentsX(0)
+ , mnSegmentsY(0)
+ , mnSelectedRenderer(-1)
+ , iterCount(0)
+#if FIXME_BOUNCE_BUTTON
+ , mpButton(NULL)
+ , mpButtonWin(NULL)
+ , mnBounceX(1)
+ , mnBounceY(1)
+#endif
+ {
+ if (!Application::LoadBrandBitmap("intro", maIntro))
+ Application::Abort("Failed to load intro image");
+
+ maIntroBW = maIntro.GetBitmap();
+
+ BitmapEx aTmpBmpEx(maIntroBW);
+ BitmapFilter::Filter(aTmpBmpEx, BitmapEmbossGreyFilter(0, 0));
+ maIntroBW = aTmpBmpEx.GetBitmap();
+
+ InitRenderers();
+ mnSegmentsY = rtl::math::round(std::sqrt(maRenderers.size()), 0,
+ rtl_math_RoundingMode_Down);
+ mnSegmentsX = (maRenderers.size() + mnSegmentsY - 1)/mnSegmentsY;
+ }
+
+ OUString getRendererList();
+ double getAndResetBenchmark(RenderStyle style);
+ void selectRenderer(std::u16string_view rName);
+ int selectNextRenderer();
+ void setIterCount(sal_Int32 iterCount);
+ sal_Int32 getIterCount() const;
+ void addTime(int i, double t);
+
+ Size maSize;
+ void SetSizePixel(const Size &rSize) { maSize = rSize; }
+ const Size& GetSizePixel() const { return maSize; }
+
+
+// more of a 'Window' concept - push upwards ?
+#if FIXME_BOUNCE_BUTTON
+ // Bouncing windows on click ...
+ PushButton *mpButton;
+ FloatingWindow *mpButtonWin;
+ AutoTimer maBounce;
+ int mnBounceX, mnBounceY;
+ DECL_LINK(BounceTimerCb, Timer*, void);
+#endif
+
+ bool MouseButtonDown(const MouseEvent& rMEvt);
+ void KeyInput(const KeyEvent& rKEvt);
+
+ static std::vector<tools::Rectangle> partition(const tools::Rectangle &rRect, int nX, int nY)
+ {
+ std::vector<tools::Rectangle> aRegions = partition(rRect.GetSize(), nX, nY);
+ for (auto & region : aRegions)
+ region.Move(rRect.Left(), rRect.Top());
+
+ return aRegions;
+ }
+
+ static std::vector<tools::Rectangle> partition(const RenderContext &rCtx, int nX, int nY)
+ {
+ return partition(rCtx.maSize, nX, nY);
+ }
+
+ static std::vector<tools::Rectangle> partition(Size aSize, int nX, int nY)
+ {
+ tools::Rectangle r;
+ std::vector<tools::Rectangle> aRegions;
+
+ // Make small cleared area for these guys
+ tools::Long nBorderSize = std::min(aSize.Height() / 32, aSize.Width() / 32);
+ tools::Long nBoxWidth = (aSize.Width() - nBorderSize*(nX+1)) / nX;
+ tools::Long nBoxHeight = (aSize.Height() - nBorderSize*(nY+1)) / nY;
+ for (int y = 0; y < nY; y++)
+ {
+ for (int x = 0; x < nX; x++)
+ {
+ r.SetPos(Point(nBorderSize + (nBorderSize + nBoxWidth) * x,
+ nBorderSize + (nBorderSize + nBoxHeight) * y));
+ r.SetSize(Size(nBoxWidth, nBoxHeight));
+ aRegions.push_back(r);
+ }
+ }
+
+ return aRegions;
+ }
+
+ static void clearRects(OutputDevice &rDev, std::vector<tools::Rectangle> &rRects)
+ {
+ for (size_t i = 0; i < rRects.size(); i++)
+ {
+ // knock up a nice little border
+ rDev.SetLineColor(COL_GRAY);
+ rDev.SetFillColor(COL_LIGHTGRAY);
+ if (i % 2)
+ {
+ int nBorderSize = rRects[i].GetWidth() / 5;
+ rDev.DrawRect(rRects[i], nBorderSize, nBorderSize);
+ }
+ else
+ rDev.DrawRect(rRects[i]);
+ }
+ }
+
+ static void drawBackground(OutputDevice &rDev, const tools::Rectangle& r)
+ {
+ rDev.Erase();
+ Gradient aGradient;
+ aGradient.SetStartColor(COL_BLUE);
+ aGradient.SetEndColor(COL_GREEN);
+ aGradient.SetStyle(GradientStyle::Linear);
+ rDev.DrawGradient(r, aGradient);
+ }
+
+ struct DrawLines : public RegionRenderer
+ {
+ RENDER_DETAILS(lines,KEY_L,100)
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &rCtx) override
+ {
+ if (rCtx.meStyle == RENDER_EXPANDED)
+ {
+ AntialiasingFlags nOldAA = rDev.GetAntialiasing();
+ rDev.SetAntialiasing(AntialiasingFlags::Enable);
+
+ std::vector<tools::Rectangle> aRegions(DemoRenderer::partition(rCtx, 4, 4));
+ DemoRenderer::clearRects(rDev, aRegions);
+
+#if 0 // FIXME: get this through to the backend ...
+ double nTransparency[] = {
+ 1.0, 1.0, 1.0, 1.0,
+ 0.8, 0.8, 0.8, 0.8,
+ 0.5, 0.5, 0.5, 0.5,
+ 0.1, 0.1, 0.1, 0.1
+ };
+#endif
+ drawing::LineCap const eLineCaps[] = {
+ drawing::LineCap_BUTT, drawing::LineCap_ROUND, drawing::LineCap_SQUARE, drawing::LineCap_BUTT,
+ drawing::LineCap_BUTT, drawing::LineCap_ROUND, drawing::LineCap_SQUARE, drawing::LineCap_BUTT,
+ drawing::LineCap_BUTT, drawing::LineCap_ROUND, drawing::LineCap_SQUARE, drawing::LineCap_BUTT,
+ drawing::LineCap_BUTT, drawing::LineCap_ROUND, drawing::LineCap_SQUARE, drawing::LineCap_BUTT
+ };
+ basegfx::B2DLineJoin const eJoins[] = {
+ basegfx::B2DLineJoin::NONE, basegfx::B2DLineJoin::Bevel, basegfx::B2DLineJoin::Miter, basegfx::B2DLineJoin::Round,
+ basegfx::B2DLineJoin::NONE, basegfx::B2DLineJoin::Bevel, basegfx::B2DLineJoin::Miter, basegfx::B2DLineJoin::Round,
+ basegfx::B2DLineJoin::NONE, basegfx::B2DLineJoin::Bevel, basegfx::B2DLineJoin::Miter, basegfx::B2DLineJoin::Round,
+ basegfx::B2DLineJoin::NONE, basegfx::B2DLineJoin::Bevel, basegfx::B2DLineJoin::Miter, basegfx::B2DLineJoin::Round
+ };
+ double const aLineWidths[] = {
+ 10.0, 15.0, 20.0, 10.0,
+ 10.0, 15.0, 20.0, 10.0,
+ 10.0, 15.0, 20.0, 10.0,
+ 0.1, 1.0, 10.0, 50.0
+ };
+ for (size_t i = 0; i < aRegions.size(); i++)
+ {
+ // Half of them not-anti-aliased ..
+ if (i >= aRegions.size()/2)
+ rDev.SetAntialiasing(nOldAA);
+
+ static const struct {
+ double nX, nY;
+ } aPoints[] = {
+ { 0.2, 0.2 }, { 0.8, 0.3 }, { 0.7, 0.8 }
+ };
+ rDev.SetLineColor(COL_BLACK);
+ basegfx::B2DPolygon aPoly;
+ tools::Rectangle aSub(aRegions[i]);
+ for (size_t j = 0; j < SAL_N_ELEMENTS(aPoints); j++)
+ {
+ aPoly.append(basegfx::B2DPoint(aSub.Left() + aSub.GetWidth() * aPoints[j].nX,
+ aSub.Top() + aSub.GetHeight() * aPoints[j].nY));
+ }
+ rDev.DrawPolyLine(aPoly, aLineWidths[i], eJoins[i], eLineCaps[i]);
+ }
+ }
+ else
+ {
+ rDev.SetFillColor(COL_LIGHTRED);
+ rDev.SetLineColor(COL_BLACK);
+ rDev.DrawRect(r);
+
+ for(tools::Long i=0; i<r.GetHeight(); i+=15)
+ rDev.DrawLine(Point(r.Left(), r.Top()+i), Point(r.Right(), r.Bottom()-i));
+ for(tools::Long i=0; i<r.GetWidth(); i+=15)
+ rDev.DrawLine(Point(r.Left()+i, r.Bottom()), Point(r.Right()-i, r.Top()));
+
+ // Should draw a white-line across the middle
+ Color aLastPixel(COL_WHITE);
+ Point aCenter((r.Left() + r.Right())/2 - 4,
+ (r.Top() + r.Bottom())/2 - 4);
+ for(int i=0; i<8; i++)
+ {
+ rDev.DrawPixel(aCenter, aLastPixel);
+ aLastPixel = rDev.GetPixel(aCenter);
+ aCenter.Move(1,1);
+ }
+ }
+ }
+ };
+
+ struct DrawText : public RegionRenderer
+ {
+ RENDER_DETAILS(text,KEY_T,1)
+
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &rCtx) override
+ {
+ if (rCtx.meStyle == RENDER_EXPANDED)
+ {
+ std::vector<tools::Rectangle> aToplevelRegions(
+ DemoRenderer::partition(rCtx, 1, 3));
+ std::vector<tools::Rectangle> aSubRegions(
+ DemoRenderer::partition(aToplevelRegions[0], 4, 2));
+ tools::Rectangle aBottom(aToplevelRegions[1].TopLeft(),
+ aToplevelRegions[2].BottomRight());
+ DemoRenderer::clearRects(rDev,aSubRegions);
+ static struct {
+ bool mbClip;
+ bool mbArabicText;
+ bool mbRotate;
+ } const aRenderData[] = {
+ { false, false, false },
+ { false, true, false },
+ { false, true, true },
+ { false, false, true },
+ { true, false, true },
+ { true, true, true },
+ { true, true, false },
+ { true, false, false },
+ };
+
+ size_t i = 0;
+ for (int y = 0; y < 2; y++)
+ {
+ for (int x = 0; x < 4; x++)
+ {
+ assert(i < SAL_N_ELEMENTS(aRenderData));
+ drawText(rDev, aSubRegions[i], aRenderData[i].mbClip,
+ aRenderData[i].mbArabicText, aRenderData[i].mbRotate);
+ i++;
+ }
+ }
+
+ drawComplex(rDev, aBottom);
+ }
+ else
+ {
+ drawText(rDev, r, false, false, false);
+ }
+ }
+
+ static void drawText (OutputDevice &rDev, tools::Rectangle r, bool bClip, bool bArabicText, bool bRotate)
+ {
+ rDev.SetClipRegion( vcl::Region(r) );
+
+ const unsigned char pTextUTF8[] = {
+ 0xd9, 0x88, 0xd8, 0xa7, 0xd8, 0xad, 0xd9, 0x90,
+ 0xd8, 0xaf, 0xd9, 0x92, 0x20, 0xd8, 0xa5, 0xd8,
+ 0xab, 0xd9, 0x8d, 0xd9, 0x86, 0xd9, 0x8a, 0xd9,
+ 0x86, 0x20, 0xd8, 0xab, 0xd9, 0x84, 0xd8, 0xa7,
+ 0xd8, 0xab, 0xd8, 0xa9, 0xd9, 0x8c, 0x00
+ };
+ OUString aArabicText( reinterpret_cast<char const *>(pTextUTF8),
+ SAL_N_ELEMENTS( pTextUTF8 ) - 1,
+ RTL_TEXTENCODING_UTF8 );
+
+ OUString aText;
+
+ // To have more text displayed one after the other (overlapping, and in different colours), then
+ // change this value
+ const int nPrintNumCopies=1;
+
+ if (bArabicText)
+ aText = aArabicText;
+ else
+ aText = "Click any rect to zoom!!!!";
+
+ std::vector<OUString> aFontNames;
+
+ static Color const nCols[] = {
+ COL_BLACK, COL_BLUE, COL_GREEN, COL_CYAN, COL_RED, COL_MAGENTA,
+ COL_BROWN, COL_GRAY, COL_LIGHTGRAY, COL_LIGHTBLUE, COL_LIGHTGREEN,
+ COL_LIGHTCYAN, COL_LIGHTRED, COL_LIGHTMAGENTA, COL_YELLOW, COL_WHITE
+ };
+
+ // a few fonts to start with
+ const char *pNames[] = {
+ "Times", "Liberation Sans", "Arial", "Linux Biolinum G", "Linux Libertine Display G"
+ };
+
+ for (size_t i = 0; i < SAL_N_ELEMENTS(pNames); i++)
+ aFontNames.push_back(OUString::createFromAscii(pNames[i]));
+
+ if (bClip && !bRotate)
+ {
+ // only show the first quarter of the text
+ tools::Rectangle aRect( r.TopLeft(), Size( r.GetWidth()/2, r.GetHeight()/2 ) );
+ rDev.SetClipRegion( vcl::Region( aRect ) );
+ }
+
+ for (int i = 1; i < nPrintNumCopies+1; i++)
+ {
+ int nFontHeight=0, nFontIndex=0, nFontColorIndex=0;
+
+ if (nPrintNumCopies == 1)
+ {
+ float const nFontMagnitude = 0.25f;
+ // random font size to avoid buffering
+ nFontHeight = 1 + nFontMagnitude * (0.9 + comphelper::rng::uniform_real_distribution(0.0, std::nextafter(0.1, DBL_MAX))) * (r.Bottom() - r.Top());
+ nFontIndex=0;
+ nFontColorIndex=0;
+ }
+ else
+ {
+ // random font size to avoid buffering
+ nFontHeight = 1 + i * (0.9 + comphelper::rng::uniform_real_distribution(0.0, std::nextafter(0.1, DBL_MAX))) * (r.Top() - r.Bottom()) / nPrintNumCopies;
+ nFontIndex = (i % aFontNames.size());
+ nFontColorIndex=(i % aFontNames.size());
+ }
+
+ rDev.SetTextColor(nCols[nFontColorIndex]);
+ vcl::Font aFont( aFontNames[nFontIndex], Size(0, nFontHeight ));
+
+ if (bRotate)
+ {
+ tools::Rectangle aFontRect = r;
+
+ int nHeight = r.GetHeight();
+
+ // move the text to the bottom of the bounding rect before rotating
+ aFontRect.AdjustTop(nHeight/2 );
+ aFontRect.AdjustBottom(nHeight );
+
+ aFont.SetOrientation(450_deg10); // 45 degrees
+
+ rDev.SetFont(aFont);
+ rDev.DrawText(aFontRect, aText);
+
+ if (bClip)
+ {
+ tools::Rectangle aClipRect( Point( r.Left(), r.Top() + ( r.GetHeight()/2 ) ) , Size( r.GetWidth()/2, r.GetHeight()/2 ) );
+ rDev.SetClipRegion( vcl::Region( aClipRect ) );
+ }
+ else
+ rDev.SetClipRegion( vcl::Region(r) );
+ }
+ else
+ {
+ rDev.SetFont(aFont);
+ rDev.DrawText(r, aText);
+ }
+ }
+
+ rDev.SetClipRegion();
+ }
+
+ static void drawComplex (OutputDevice &rDev, tools::Rectangle r)
+ {
+ const unsigned char pInvalid[] = { 0xfe, 0x1f, 0 };
+ const unsigned char pDiacritic1[] = { 0x61, 0xcc, 0x8a, 0xcc, 0x8c, 0 };
+ const unsigned char pDiacritic2[] = { 0x61, 0xcc, 0x88, 0xcc, 0x86, 0 };
+ const unsigned char pDiacritic3[] = { 0x61, 0xcc, 0x8b, 0xcc, 0x87, 0 };
+ const unsigned char pJustification[] = {
+ 0x64, 0x20, 0xc3, 0xa1, 0xc3, 0xa9, 0x77, 0xc4, 0x8d,
+ 0xc5, 0xa1, 0xc3, 0xbd, 0xc5, 0x99, 0x20, 0xc4, 0x9b, 0
+ };
+ const unsigned char pEmojis[] = {
+ 0xf0, 0x9f, 0x8d, 0x80, 0xf0, 0x9f, 0x91, 0x98,
+ 0xf0, 0x9f, 0x92, 0x8a, 0xf0, 0x9f, 0x92, 0x99,
+ 0xf0, 0x9f, 0x92, 0xa4, 0xf0, 0x9f, 0x94, 0x90, 0
+ };
+ const unsigned char pThreeBowlG[] = {
+ 0xe2, 0x9a, 0x82, 0xe2, 0x99, 0xa8, 0xc4, 0x9e, 0
+ };
+ const unsigned char pWavesAndDomino[] = {
+ 0xe2, 0x99, 0x92, 0xf0, 0x9f, 0x81, 0xa0,
+ 0xf0, 0x9f, 0x82, 0x93, 0
+ };
+ const unsigned char pSpadesAndBits[] = {
+ 0xf0, 0x9f, 0x82, 0xa1, 0xc2, 0xa2, 0xc2, 0xa2, 0
+ };
+
+ static struct {
+ const char *mpFont;
+ const char *mpString;
+ } const aRuns[] = {
+#define SET(font,string) { font, reinterpret_cast<const char *>(string) }
+ {"sans", "a"}, // logical font - no 'sans' font.
+ {"opensymbol", "#$%"}, // font fallback - $ is missing.
+ SET("sans", pInvalid), // unicode invalid character
+ // tdf#96266 - stacking diacritics
+ SET("carlito", pDiacritic1),
+ SET("carlito", pDiacritic2),
+ SET("carlito", pDiacritic3),
+ SET("liberation sans", pDiacritic1),
+ SET("liberation sans", pDiacritic2),
+ SET("liberation sans", pDiacritic3),
+ SET("liberation sans", pDiacritic3),
+
+ // tdf#95222 - justification issue
+ // - FIXME: replicate justification
+ SET("gentium basic", pJustification),
+
+ // tdf#97319 - Unicode beyond BMP; SMP & Plane 2
+ SET("symbola", pEmojis),
+ SET("symbola", pThreeBowlG),
+ SET("symbola", pWavesAndDomino),
+ SET("symbola", pSpadesAndBits),
+ };
+
+ // Nice clean white background
+ rDev.DrawWallpaper(r, Wallpaper(COL_WHITE));
+ rDev.SetClipRegion(vcl::Region(r));
+
+ Point aPos(r.Left(), r.Top()+20);
+
+ tools::Long nMaxTextHeight = 0;
+ for (size_t i = 0; i < SAL_N_ELEMENTS(aRuns); ++i)
+ {
+ // Legend
+ vcl::Font aIndexFont("sans", Size(0,20));
+ aIndexFont.SetColor( COL_BLACK);
+ tools::Rectangle aTextRect;
+ rDev.SetFont(aIndexFont);
+ OUString aText = OUString::number(i) + ".";
+ rDev.DrawText(aPos, aText);
+ if (rDev.GetTextBoundRect(aTextRect, aText))
+ aPos.Move(aTextRect.GetWidth() + 8, 0);
+
+ // Text
+ FontWeight aWeights[] = { WEIGHT_NORMAL,
+ WEIGHT_BOLD,
+ WEIGHT_NORMAL };
+ FontItalic const aItalics[] = { ITALIC_NONE,
+ ITALIC_NONE,
+ ITALIC_NORMAL };
+ vcl::Font aFont(OUString::createFromAscii(
+ aRuns[i].mpFont),
+ Size(0,42));
+ aFont.SetColor(COL_BLACK);
+ for (size_t j = 0; j < SAL_N_ELEMENTS(aWeights); ++j)
+ {
+ aFont.SetItalic(aItalics[j]);
+ aFont.SetWeight(aWeights[j]);
+ rDev.SetFont(aFont);
+
+ OUString aString(aRuns[i].mpString,
+ strlen(aRuns[i].mpString),
+ RTL_TEXTENCODING_UTF8);
+ tools::Long nNewX = drawStringBox(rDev, aPos, aString,
+ nMaxTextHeight);
+
+ aPos.setX( nNewX );
+
+ if (aPos.X() >= r.Right())
+ {
+ aPos = Point(r.Left(), aPos.Y() + nMaxTextHeight + 15);
+ nMaxTextHeight = 0;
+ if(j>0)
+ j--; // re-render the last point.
+ }
+ if (aPos.Y() > r.Bottom())
+ break;
+ }
+ if (aPos.Y() > r.Bottom())
+ break;
+ }
+
+ rDev.SetClipRegion();
+ }
+ // render text, bbox, DX arrays etc.
+ static tools::Long drawStringBox(OutputDevice &rDev, Point aPos,
+ const OUString &aText,
+ tools::Long &nMaxTextHeight)
+ {
+ rDev.Push();
+ {
+ tools::Rectangle aTextRect;
+
+ rDev.DrawText(aPos,aText);
+
+ if (rDev.GetTextBoundRect(aTextRect, aText))
+ {
+ aTextRect.Move(aPos.X(), aPos.Y());
+ rDev.SetFillColor();
+ rDev.SetLineColor(COL_BLACK);
+ rDev.DrawRect(aTextRect);
+ if (aTextRect.GetHeight() > nMaxTextHeight)
+ nMaxTextHeight = aTextRect.GetHeight();
+ // This should intersect with the text
+ tools::Rectangle aInnerRect(
+ aTextRect.Left()+1, aTextRect.Top()+1,
+ aTextRect.Right()-1, aTextRect.Bottom()-1);
+ rDev.SetLineColor(COL_WHITE);
+ rDev.SetRasterOp(RasterOp::Xor);
+ rDev.DrawRect(aInnerRect);
+ rDev.SetRasterOp(RasterOp::OverPaint);
+ }
+
+ // DX array rendering
+ std::vector<sal_Int32> aItems;
+ rDev.GetTextArray(aText, &aItems);
+ for (tools::Long j = 0; j < aText.getLength(); ++j)
+ {
+ Point aTop = aTextRect.TopLeft();
+ Point aBottom = aTop;
+ aTop.Move(aItems[j], 0);
+ aBottom.Move(aItems[j], aTextRect.GetHeight());
+ rDev.SetLineColor(COL_RED);
+ rDev.SetRasterOp(RasterOp::Xor);
+ rDev.DrawLine(aTop,aBottom);
+ rDev.SetRasterOp(RasterOp::OverPaint);
+ }
+
+ aPos.Move(aTextRect.GetWidth() + 16, 0);
+ }
+ rDev.Pop();
+ return aPos.X();
+ }
+ };
+
+ struct DrawCheckered : public RegionRenderer
+ {
+ RENDER_DETAILS(checks,KEY_C,20)
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &rCtx) override
+ {
+ if (rCtx.meStyle == RENDER_EXPANDED)
+ {
+ std::vector<tools::Rectangle> aRegions(DemoRenderer::partition(rCtx, 2, 2));
+ for (size_t i = 0; i < aRegions.size(); i++)
+ {
+ vcl::Region aRegion;
+ tools::Rectangle aSub(aRegions[i]);
+ tools::Rectangle aSmaller(aSub);
+ aSmaller.Move(10,10);
+ aSmaller.setWidth(aSmaller.getWidth()-20);
+ aSmaller.setHeight(aSmaller.getHeight()-24);
+ switch (i) {
+ case 0:
+ aRegion = vcl::Region(aSub);
+ break;
+ case 1:
+ aRegion = vcl::Region(aSmaller);
+ aRegion.XOr(aSub);
+ break;
+ case 2:
+ {
+ tools::Polygon aPoly(aSub);
+ aPoly.Rotate(aSub.Center(), 450_deg10);
+ aPoly.Clip(aSmaller);
+ aRegion = vcl::Region(aPoly);
+ break;
+ }
+ case 3:
+ {
+ tools::PolyPolygon aPolyPoly;
+ sal_Int32 nTW = aSub.GetWidth()/6;
+ sal_Int32 nTH = aSub.GetHeight()/6;
+ tools::Rectangle aTiny(Point(4, 4), Size(nTW*2, nTH*2));
+ aPolyPoly.Insert( tools::Polygon(aTiny));
+ aTiny.Move(nTW*3, nTH*3);
+ aPolyPoly.Insert( tools::Polygon(aTiny));
+ aTiny.Move(nTW, nTH);
+ aPolyPoly.Insert( tools::Polygon(aTiny));
+
+ aRegion = vcl::Region(aPolyPoly);
+ break;
+ }
+ } // switch
+ rDev.SetClipRegion(aRegion);
+ rDev.DrawCheckered(aSub.TopLeft(), aSub.GetSize());
+ rDev.SetClipRegion();
+ }
+ }
+ else
+ {
+ rDev.DrawCheckered(r.TopLeft(), r.GetSize());
+ }
+ }
+ };
+
+ struct DrawPoly : public RegionRenderer
+ {
+ RENDER_DETAILS(poly,KEY_P,20)
+ DrawCheckered maCheckered;
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &rCtx) override
+ {
+ maCheckered.RenderRegion(rDev, r, rCtx);
+
+ tools::Long nDx = r.GetWidth()/20;
+ tools::Long nDy = r.GetHeight()/20;
+ tools::Rectangle aShrunk(r);
+ aShrunk.Move(nDx, nDy);
+ aShrunk.SetSize(Size(r.GetWidth()-nDx*2,
+ r.GetHeight()-nDy*2));
+ tools::Polygon aPoly(aShrunk);
+ tools::PolyPolygon aPPoly(aPoly);
+ rDev.SetLineColor(COL_RED);
+ rDev.SetFillColor(COL_RED);
+ // This hits the optional 'drawPolyPolygon' code-path
+ rDev.DrawTransparent(aPPoly, 64);
+ }
+ };
+
+ struct DrawEllipse : public RegionRenderer
+ {
+ RENDER_DETAILS(ellipse,KEY_E,500)
+ static void doInvert(OutputDevice &rDev, const tools::Rectangle &r,
+ InvertFlags nFlags)
+ {
+ rDev.Invert(r, nFlags);
+ if (r.GetWidth() > 10 && r.GetHeight() > 10)
+ {
+ tools::Rectangle aSmall(r.Center()-Point(4,4), Size(8,8));
+ rDev.Invert(aSmall,nFlags);
+ }
+ }
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &rCtx) override
+ {
+ rDev.SetLineColor(COL_RED);
+ rDev.SetFillColor(COL_GREEN);
+ rDev.DrawEllipse(r);
+
+ if (rCtx.meStyle == RENDER_EXPANDED)
+ {
+ auto aRegions = partition(rCtx, 2, 2);
+ doInvert(rDev, aRegions[0], InvertFlags::NONE);
+ rDev.DrawText(aRegions[0], "InvertFlags::NONE");
+ doInvert(rDev, aRegions[1], InvertFlags::N50);
+ rDev.DrawText(aRegions[1], "InvertFlags::N50");
+ doInvert(rDev, aRegions[3], InvertFlags::TrackFrame);
+ rDev.DrawText(aRegions[3], "InvertFlags::TrackFrame");
+ }
+ }
+ };
+
+ struct DrawGradient : public RegionRenderer
+ {
+ RENDER_DETAILS(gradient,KEY_G,50)
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &rCtx) override
+ {
+ if (rCtx.meStyle == RENDER_EXPANDED)
+ {
+ std::vector<tools::Rectangle> aRegions(DemoRenderer::partition(rCtx,5, 4));
+ static Color const nStartCols[] = {
+ COL_RED, COL_RED, COL_RED, COL_GREEN, COL_GREEN,
+ COL_BLUE, COL_BLUE, COL_BLUE, COL_CYAN, COL_CYAN,
+ COL_BLACK, COL_LIGHTGRAY, COL_WHITE, COL_BLUE, COL_CYAN,
+ COL_WHITE, COL_WHITE, COL_WHITE, COL_BLACK, COL_BLACK
+ };
+ static Color const nEndCols[] = {
+ COL_WHITE, COL_WHITE, COL_WHITE, COL_BLACK, COL_BLACK,
+ COL_RED, COL_RED, COL_RED, COL_GREEN, COL_GREEN,
+ COL_GRAY, COL_GRAY, COL_LIGHTGRAY, COL_LIGHTBLUE, COL_LIGHTCYAN,
+ COL_BLUE, COL_BLUE, COL_BLUE, COL_CYAN, COL_CYAN
+ };
+ GradientStyle eStyles[] = {
+ GradientStyle::Linear, GradientStyle::Axial, GradientStyle::Radial, GradientStyle::Elliptical, GradientStyle::Square,
+ GradientStyle::Rect, GradientStyle::FORCE_EQUAL_SIZE, GradientStyle::Linear, GradientStyle::Radial, GradientStyle::Linear,
+ GradientStyle::Linear, GradientStyle::Axial, GradientStyle::Radial, GradientStyle::Elliptical, GradientStyle::Square,
+ GradientStyle::Rect, GradientStyle::FORCE_EQUAL_SIZE, GradientStyle::Linear, GradientStyle::Radial, GradientStyle::Linear
+ };
+ sal_uInt16 nAngles[] = {
+ 0, 0, 0, 0, 0,
+ 15, 30, 45, 60, 75,
+ 90, 120, 135, 160, 180,
+ 0, 0, 0, 0, 0
+ };
+ sal_uInt16 nBorders[] = {
+ 0, 0, 0, 0, 0,
+ 1, 10, 100, 10, 1,
+ 0, 0, 0, 0, 0,
+ 1, 10, 20, 10, 1,
+ 0, 0, 0, 0, 0
+ };
+ DemoRenderer::clearRects(rDev, aRegions);
+ assert(aRegions.size() <= SAL_N_ELEMENTS(nStartCols));
+ assert(aRegions.size() <= SAL_N_ELEMENTS(nEndCols));
+ assert(aRegions.size() <= SAL_N_ELEMENTS(eStyles));
+ assert(aRegions.size() <= SAL_N_ELEMENTS(nAngles));
+ assert(aRegions.size() <= SAL_N_ELEMENTS(nBorders));
+ for (size_t i = 0; i < aRegions.size(); i++)
+ {
+ tools::Rectangle aSub = aRegions[i];
+ Gradient aGradient;
+ aGradient.SetStartColor(nStartCols[i]);
+ aGradient.SetEndColor(nEndCols[i]);
+ aGradient.SetStyle(eStyles[i]);
+ aGradient.SetAngle(Degree10(nAngles[i]));
+ aGradient.SetBorder(nBorders[i]);
+ rDev.DrawGradient(aSub, aGradient);
+ }
+ }
+ else
+ {
+ Gradient aGradient;
+ aGradient.SetStartColor(COL_YELLOW);
+ aGradient.SetEndColor(COL_RED);
+ aGradient.SetStyle(GradientStyle::Rect);
+ aGradient.SetBorder(r.GetSize().Width()/20);
+ rDev.DrawGradient(r, aGradient);
+ }
+ }
+ };
+
+ struct DrawBitmap : public RegionRenderer
+ {
+ RENDER_DETAILS(bitmap,KEY_B,10)
+
+ // Simulate Page Borders rendering - which ultimately should
+ // be done with a shader / gradient
+ static void SimulateBorderStretch(OutputDevice &rDev, const tools::Rectangle& r)
+ {
+ BitmapEx aPageShadowMask("sw/res/page-shadow-mask.png");
+
+ BitmapEx aRight(aPageShadowMask);
+ sal_Int32 nSlice = (aPageShadowMask.GetSizePixel().Width() - 3) / 4;
+ // a width x 1 slice
+ aRight.Crop(tools::Rectangle(Point((nSlice * 3) + 3, (nSlice * 2) + 1),
+ Size(nSlice, 1)));
+ AlphaMask aAlphaMask(aRight.GetBitmap());
+ Bitmap aBlockColor(aAlphaMask.GetSizePixel(), vcl::PixelFormat::N24_BPP);
+ aBlockColor.Erase(COL_RED);
+ BitmapEx aShadowStretch(aBlockColor, aAlphaMask);
+
+ Point aRenderPt(r.TopLeft());
+
+ tools::Long aSizes[] = { 200, 100, 200, 100, 50, 5, 2 };
+
+ // and yes - we really do this in the page border rendering code ...
+ for (size_t i = 0; i < SAL_N_ELEMENTS(aSizes); i++)
+ {
+ aShadowStretch.Scale(Size(aShadowStretch.GetSizePixel().Width(), aSizes[i]),
+ BmpScaleFlag::Fast);
+
+ rDev.DrawBitmapEx(aRenderPt, aShadowStretch);
+ aRenderPt.Move(aShadowStretch.GetSizePixel().Width() + 4, 0);
+ }
+
+ AlphaMask aWholeMask(aPageShadowMask.GetBitmap());
+ aBlockColor = Bitmap(aPageShadowMask.GetSizePixel(), vcl::PixelFormat::N24_BPP);
+ aBlockColor.Erase(COL_GREEN);
+ BitmapEx aWhole(aBlockColor, aWholeMask);
+
+ aRenderPt = r.Center();
+ aRenderPt.Move(nSlice+1, 0);
+
+ // An offset background for alpha rendering
+ rDev.SetFillColor(COL_BLUE);
+ tools::Rectangle aSurround(r.Center(), aPageShadowMask.GetSizePixel());
+ rDev.DrawRect(aSurround);
+ rDev.DrawBitmapEx(aRenderPt, aWhole);
+ }
+
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &rCtx) override
+ {
+ Bitmap aBitmap(rCtx.mpDemoRenderer->maIntroBW);
+ aBitmap.Scale(r.GetSize(), BmpScaleFlag::BestQuality);
+ rDev.DrawBitmap(r.TopLeft(), aBitmap);
+
+ SimulateBorderStretch(rDev, r);
+ }
+ };
+
+ struct DrawBitmapEx : public RegionRenderer
+ {
+ RENDER_DETAILS(bitmapex,KEY_X,2)
+ DrawCheckered maCheckered;
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &rCtx) override
+ {
+ maCheckered.RenderRegion(rDev, r, rCtx);
+
+ BitmapEx aBitmap(rCtx.mpDemoRenderer->maIntro);
+ aBitmap.Scale(r.GetSize(), BmpScaleFlag::BestQuality);
+ AlphaMask aSemiTransp(aBitmap.GetSizePixel());
+ aSemiTransp.Erase(64);
+ rDev.DrawBitmapEx(r.TopLeft(), BitmapEx(aBitmap.GetBitmap(),
+ aSemiTransp));
+ }
+ };
+
+ struct DrawPolyPolygons : public RegionRenderer
+ {
+ RENDER_DETAILS(polypoly,KEY_N,100)
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &) override
+ {
+ static struct {
+ double nX, nY;
+ } const aPoints[] = { { 0.1, 0.1 }, { 0.9, 0.9 },
+#if FIXME_SELF_INTERSECTING_WORKING
+ { 0.9, 0.1 }, { 0.1, 0.9 },
+ { 0.1, 0.1 }
+#else
+ { 0.1, 0.9 }, { 0.5, 0.5 },
+ { 0.9, 0.1 }, { 0.1, 0.1 }
+#endif
+ };
+
+ tools::PolyPolygon aPolyPoly;
+ // Render 4x polygons & aggregate into another PolyPolygon
+ for (int x = 0; x < 2; x++)
+ {
+ for (int y = 0; y < 2; y++)
+ {
+ tools::Rectangle aSubRect(r);
+ aSubRect.Move(x * r.GetWidth()/3, y * r.GetHeight()/3);
+ aSubRect.SetSize(Size(r.GetWidth()/2, r.GetHeight()/4));
+ tools::Polygon aPoly(SAL_N_ELEMENTS(aPoints));
+ for (size_t v = 0; v < SAL_N_ELEMENTS(aPoints); v++)
+ {
+ aPoly.SetPoint(Point(aSubRect.Left() +
+ aSubRect.GetWidth() * aPoints[v].nX,
+ aSubRect.Top() +
+ aSubRect.GetHeight() * aPoints[v].nY),
+ v);
+ }
+ rDev.SetLineColor(COL_YELLOW);
+ rDev.SetFillColor(COL_BLACK);
+ rDev.DrawPolygon(aPoly);
+
+ // now move and add to the polypolygon
+ aPoly.Move(0, r.GetHeight()/2);
+ aPolyPoly.Insert(aPoly);
+ }
+ }
+ rDev.SetLineColor(COL_LIGHTRED);
+ rDev.SetFillColor(COL_GREEN);
+ rDev.DrawTransparent(aPolyPoly, 50);
+ }
+ };
+
+ struct DrawClipped : public RegionRenderer
+ {
+ RENDER_DETAILS(clip,KEY_D,10)
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &) override
+ {
+ std::vector<tools::Rectangle> aRegions(DemoRenderer::partition(r, 2, 2));
+ const int nLimits[] = { 4, -100 };
+ for (int i = 0; i < 2; ++i)
+ {
+ sal_uInt16 nHue = 0;
+ rDev.Push(vcl::PushFlags::CLIPREGION);
+ tools::Rectangle aOuter = aRegions[i];
+ tools::Rectangle aInner = aOuter;
+ while (aInner.GetWidth() > nLimits[i] && aInner.GetHeight() > nLimits[i])
+ {
+ aInner.expand(-1);
+ rDev.SetClipRegion(vcl::Region(aInner));
+ rDev.SetFillColor(Color::HSBtoRGB(nHue, 75, 100));
+ nHue = (nHue + 97) % 360;
+ rDev.DrawRect(aOuter);
+ }
+ rDev.Pop();
+ }
+
+ {
+ sal_uInt16 nHue = 0;
+ tools::Rectangle aOuter = aRegions[2];
+ std::vector<tools::Rectangle> aPieces(DemoRenderer::partition(aOuter, 2, 2));
+ for (int j = 0; j < std::min(aOuter.GetWidth(), aOuter.GetHeight())/5; ++j)
+ {
+ rDev.Push(vcl::PushFlags::CLIPREGION);
+
+ vcl::Region aClipRegion;
+ for (int i = 0; i < 4; ++i)
+ {
+ aPieces[i].expand(-1);
+ aPieces[i].Move(2 - i/2, 2 - i/2);
+ aClipRegion.Union(aPieces[i]);
+ }
+ assert (aClipRegion.getRegionBand());
+ rDev.SetClipRegion(aClipRegion);
+ rDev.SetFillColor(Color::HSBtoRGB(nHue, 75, 75));
+ nHue = (nHue + 97) % 360;
+ rDev.DrawRect(aOuter);
+
+ rDev.Pop();
+ }
+ }
+
+ {
+ sal_uInt16 nHue = 0;
+ tools::Rectangle aOuter = aRegions[3];
+ std::vector<tools::Rectangle> aPieces(DemoRenderer::partition(aOuter, 2, 2));
+ bool bDone = false;
+ while (!bDone)
+ {
+ rDev.Push(vcl::PushFlags::CLIPREGION);
+
+ for (int i = 0; i < 4; ++i)
+ {
+ vcl::Region aClipRegion;
+ tools::Polygon aPoly;
+ switch (i) {
+ case 3:
+ case 0: // 45degree rectangle.
+ aPoly = tools::Polygon(aPieces[i]);
+ aPoly.Rotate(aPieces[i].Center(), 450_deg10);
+ break;
+ case 1: // arc
+ aPoly = tools::Polygon(aPieces[i],
+ aPieces[i].TopLeft(),
+ aPieces[i].BottomRight());
+ break;
+ case 2:
+ aPoly = tools::Polygon(aPieces[i],
+ aPieces[i].GetWidth()/5,
+ aPieces[i].GetHeight()/5);
+ aPoly.Rotate(aPieces[i].Center(), 450_deg10);
+ break;
+ }
+ aClipRegion = vcl::Region(aPoly);
+ aPieces[i].expand(-1);
+ aPieces[i].Move(2 - i/2, 2 - i/2);
+
+ bDone = aPieces[i].GetWidth() < 4 ||
+ aPieces[i].GetHeight() < 4;
+
+ if (!bDone)
+ {
+ assert (!aClipRegion.getRegionBand());
+
+ rDev.SetClipRegion(aClipRegion);
+ rDev.SetFillColor(Color::HSBtoRGB(nHue, 50, 75));
+ nHue = (nHue + 97) % 360;
+ rDev.DrawRect(aOuter);
+ }
+ }
+
+ rDev.Pop();
+ }
+ }
+ }
+ };
+
+ struct DrawToVirtualDevice : public RegionRenderer
+ {
+ RENDER_DETAILS(vdev,KEY_V,1)
+ enum RenderType {
+ RENDER_AS_BITMAP,
+ RENDER_AS_OUTDEV,
+ RENDER_AS_BITMAPEX,
+ RENDER_AS_ALPHA_OUTDEV
+ };
+
+ static void SizeAndRender(OutputDevice &rDev, const tools::Rectangle& r, RenderType eType,
+ const RenderContext &rCtx)
+ {
+ ScopedVclPtr<VirtualDevice> pNested;
+
+ if (static_cast<int>(eType) < RENDER_AS_BITMAPEX)
+ pNested = VclPtr<VirtualDevice>::Create(rDev).get();
+ else
+ pNested = VclPtr<VirtualDevice>::Create(rDev,DeviceFormat::DEFAULT,DeviceFormat::DEFAULT).get();
+
+ pNested->SetOutputSizePixel(r.GetSize());
+ tools::Rectangle aWhole(Point(0,0), r.GetSize());
+
+ // mini me
+ rCtx.mpDemoRenderer->drawToDevice(*pNested, r.GetSize(), true);
+
+ if (eType == RENDER_AS_BITMAP)
+ {
+ Bitmap aBitmap(pNested->GetBitmap(Point(0,0),aWhole.GetSize()));
+ rDev.DrawBitmap(r.TopLeft(), aBitmap);
+ }
+ else if (eType == RENDER_AS_BITMAPEX)
+ {
+ BitmapEx aBitmapEx(pNested->GetBitmapEx(Point(0,0),aWhole.GetSize()));
+ rDev.DrawBitmapEx(r.TopLeft(), aBitmapEx);
+ }
+ else if (eType == RENDER_AS_OUTDEV ||
+ eType == RENDER_AS_ALPHA_OUTDEV)
+ {
+ rDev.DrawOutDev(r.TopLeft(), r.GetSize(),
+ aWhole.TopLeft(), aWhole.GetSize(),
+ *pNested);
+ }
+ }
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &rCtx) override
+ {
+ // avoid infinite recursion
+ if (rCtx.mbVDev)
+ return;
+
+ if (rCtx.meStyle == RENDER_EXPANDED)
+ {
+ std::vector<tools::Rectangle> aRegions(DemoRenderer::partition(rCtx,2, 2));
+ DemoRenderer::clearRects(rDev, aRegions);
+
+ RenderType const eRenderTypes[] { RENDER_AS_BITMAP, RENDER_AS_OUTDEV,
+ RENDER_AS_BITMAPEX, RENDER_AS_ALPHA_OUTDEV };
+ for (size_t i = 0; i < aRegions.size(); i++)
+ SizeAndRender(rDev, aRegions[i], eRenderTypes[i], rCtx);
+ }
+ else
+ SizeAndRender(rDev, r, RENDER_AS_BITMAP, rCtx);
+ }
+ };
+
+ struct DrawXOR : public RegionRenderer
+ {
+ RENDER_DETAILS(xor,KEY_X,1)
+
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &rCtx) override
+ {
+ // avoid infinite recursion
+ if (rCtx.mbVDev)
+ return;
+
+ rDev.Push();
+
+ AntialiasingFlags nFlags = rDev.GetAntialiasing();
+ rDev.SetAntialiasing(nFlags & ~AntialiasingFlags::Enable);
+ rDev.SetRasterOp( RasterOp::Xor );
+
+ rCtx.mpDemoRenderer->drawThumbs(rDev, r, true);
+
+ rDev.Pop();
+ }
+ };
+
+ struct DrawIcons : public RegionRenderer
+ {
+ RENDER_DETAILS(icons,KEY_I,1)
+
+ std::vector<OUString> maIconNames;
+ std::vector<BitmapEx> maIcons;
+ bool bHasLoadedAll;
+ DrawIcons() : bHasLoadedAll(false)
+ {
+ // a few icons to start with
+ const char *pNames[] = {
+ "cmd/lc_openurl.png",
+ "cmd/lc_newdoc.png",
+ "cmd/lc_choosemacro.png",
+ "cmd/lc_save.png",
+ "cmd/lc_saveas.png",
+ "cmd/lc_importdialog.png",
+ "cmd/lc_sendmail.png",
+ "cmd/lc_editdoc.png",
+ "cmd/lc_print.png",
+ "cmd/lc_combobox.png",
+ "cmd/lc_insertformcombo.png",
+ "cmd/lc_printpreview.png",
+ "cmd/lc_cut.png",
+ "cmd/lc_copy.png",
+ "cmd/lc_paste.png",
+ "cmd/sc_autopilotmenu.png",
+ "cmd/lc_formatpaintbrush.png",
+ "cmd/lc_undo.png",
+ "cmd/lc_redo.png",
+ "cmd/lc_marks.png",
+ "cmd/lc_fieldnames.png",
+ "cmd/lc_hyperlinkdialog.png",
+ "cmd/lc_basicshapes.rectangle.png",
+ "cmd/lc_basicshapes.round-rectangle.png"
+ };
+ for (size_t i = 0; i < SAL_N_ELEMENTS(pNames); i++)
+ {
+ maIconNames.push_back(OUString::createFromAscii(pNames[i]));
+ maIcons.emplace_back(maIconNames[i]);
+ }
+ }
+
+ void LoadAllImages()
+ {
+ if (bHasLoadedAll)
+ return;
+ bHasLoadedAll = true;
+
+ css::uno::Reference<css::container::XNameAccess> xRef(ImageTree::get().getNameAccess());
+ const css::uno::Sequence< OUString > aAllIcons = xRef->getElementNames();
+
+ for (const auto& rIcon : aAllIcons)
+ {
+ if (rIcon.endsWithIgnoreAsciiCase("svg"))
+ continue; // too slow to load.
+ maIconNames.push_back(rIcon);
+ maIcons.emplace_back(rIcon);
+ }
+ }
+
+ void doDrawIcons(OutputDevice &rDev, tools::Rectangle r, bool bExpanded)
+ {
+ tools::Long nMaxH = 0;
+ Point p(r.LeftCenter());
+ size_t nToRender = maIcons.size();
+
+ if (!bExpanded && maIcons.size() > 64)
+ nToRender = 64;
+ for (size_t i = 0; i < nToRender; i++)
+ {
+ Size aSize(maIcons[i].GetSizePixel());
+// sAL_DEBUG("Draw icon '" << maIconNames[i] << "'");
+
+ if (!(i % 4))
+ rDev.DrawBitmapEx(p, maIcons[i]);
+ else
+ {
+ basegfx::B2DHomMatrix aTransform;
+ aTransform.scale(aSize.Width(), aSize.Height());
+ switch (i % 4)
+ {
+ case 2:
+ aTransform.shearX(static_cast<double>((i >> 2) % 8) / 8);
+ aTransform.shearY(static_cast<double>((i >> 4) % 8) / 8);
+ break;
+ case 3:
+ aTransform.translate(-aSize.Width()/2, -aSize.Height()/2);
+ aTransform.rotate(i);
+ if (i & 0x100)
+ {
+ aTransform.shearX(static_cast<double>((i >> 2) % 8) / 8);
+ aTransform.shearY(static_cast<double>((i >> 4) % 8) / 8);
+ }
+ aTransform.translate(aSize.Width()/2, aSize.Height()/2);
+ break;
+ default:
+ aTransform.translate(-aSize.Width()/2, -aSize.Height()/2);
+ aTransform.rotate(2 * 2 * M_PI * i / nToRender);
+ aTransform.translate(aSize.Width()/2, aSize.Height()/2);
+ break;
+ }
+ aTransform.translate(p.X(), p.Y());
+ rDev.DrawTransformedBitmapEx(aTransform, maIcons[i]);
+ }
+
+ // next position
+ p.Move(aSize.Width(), 0);
+ if (aSize.Height() > nMaxH)
+ nMaxH = aSize.Height();
+ if (p.X() >= r.Right()) // wrap to next line
+ {
+ p = Point(r.Left(), p.Y() + nMaxH);
+ nMaxH = 0;
+ }
+ if (p.Y() >= r.Bottom()) // re-start at middle
+ p = r.LeftCenter();
+ }
+ }
+
+ static BitmapEx AlphaRecovery(OutputDevice &rDev, Point aPt, BitmapEx const &aSrc)
+ {
+ // Compositing onto 2x colors beyond our control
+ ScopedVclPtrInstance< VirtualDevice > aWhite;
+ ScopedVclPtrInstance< VirtualDevice > aBlack;
+ aWhite->SetOutputSizePixel(aSrc.GetSizePixel());
+ aWhite->SetBackground(Wallpaper(COL_WHITE));
+ aWhite->Erase();
+ aBlack->SetOutputSizePixel(aSrc.GetSizePixel());
+ aBlack->SetBackground(Wallpaper(COL_BLACK));
+ aBlack->Erase();
+ aWhite->DrawBitmapEx(Point(), aSrc);
+ aBlack->DrawBitmapEx(Point(), aSrc);
+
+ // Now recover that alpha...
+ Bitmap aWhiteBmp = aWhite->GetBitmap(Point(),aSrc.GetSizePixel());
+ Bitmap aBlackBmp = aBlack->GetBitmap(Point(),aSrc.GetSizePixel());
+ AlphaMask aMask(aSrc.GetSizePixel());
+ Bitmap aRecovered(aSrc.GetSizePixel(), vcl::PixelFormat::N24_BPP);
+ {
+ AlphaScopedWriteAccess pMaskAcc(aMask);
+ BitmapScopedWriteAccess pRecAcc(aRecovered);
+ Bitmap::ScopedReadAccess pAccW(aWhiteBmp); // a * pix + (1-a)
+ Bitmap::ScopedReadAccess pAccB(aBlackBmp); // a * pix + 0
+ int nSizeX = aSrc.GetSizePixel().Width();
+ int nSizeY = aSrc.GetSizePixel().Height();
+ for (int y = 0; y < nSizeY; y++)
+ {
+ Scanline pScanlineMask = pMaskAcc->GetScanline( y );
+ Scanline pScanlineRec = pRecAcc->GetScanline( y );
+ Scanline pScanlineW = pAccW->GetScanline( y );
+ Scanline pScanlineB = pAccB->GetScanline( y );
+ for (int x = 0; x < nSizeX; x++)
+ {
+ BitmapColor aColW = pAccW->GetPixelFromData(pScanlineW,x);
+ BitmapColor aColB = pAccB->GetPixelFromData(pScanlineB,x);
+ tools::Long nAR = static_cast<tools::Long>(aColW.GetRed() - aColB.GetRed()); // (1-a)
+ tools::Long nAG = static_cast<tools::Long>(aColW.GetGreen() - aColB.GetGreen()); // (1-a)
+ tools::Long nAB = static_cast<tools::Long>(aColW.GetBlue() - aColB.GetBlue()); // (1-a)
+
+#define CLAMP(a,b,c) (((a)<=(b))?(b):(((a)>=(c))?(c):(a)))
+
+ // we get the most precision from the largest delta
+ tools::Long nInverseAlpha = std::max(nAR, std::max(nAG, nAB)); // (1-a)
+ nInverseAlpha = CLAMP(nInverseAlpha, 0, 255);
+ tools::Long nAlpha = 255 - nInverseAlpha;
+
+ pMaskAcc->SetPixelOnData(pScanlineMask,x,BitmapColor(static_cast<sal_Int8>(CLAMP(nInverseAlpha,0,255))));
+ // now recover the pixels
+ tools::Long nR = (aColW.GetRed() + aColB.GetRed() - nInverseAlpha) * 128;
+ tools::Long nG = (aColW.GetGreen() + aColB.GetGreen() - nInverseAlpha) * 128;
+ tools::Long nB = (aColW.GetBlue() + aColB.GetBlue() - nInverseAlpha) * 128;
+ if (nAlpha == 0)
+ { // doesn't matter what's behind transparency
+ nR = nG = nB = 0;
+ }
+ else
+ {
+ nR /= nAlpha; nG /= nAlpha; nB /= nAlpha;
+ }
+ pRecAcc->SetPixelOnData(pScanlineRec,x,BitmapColor(
+ static_cast<sal_uInt8>(CLAMP(nR,0,255)),
+ static_cast<sal_uInt8>(CLAMP(nG,0,255)),
+ static_cast<sal_uInt8>(CLAMP(nB,0,255))));
+#undef CLAMP
+ }
+ }
+ }
+ rDev.DrawBitmap(aPt, aWhiteBmp);
+ aPt.Move(aSrc.GetSizePixel().Width(), 0);
+ rDev.DrawBitmap(aPt, aBlackBmp);
+ aPt.Move(aSrc.GetSizePixel().Width(), 0);
+ rDev.DrawBitmap(aPt, aRecovered);
+ aPt.Move(aSrc.GetSizePixel().Width(), 0);
+ rDev.DrawBitmap(aPt, aMask.GetBitmap());
+ aPt.Move(aSrc.GetSizePixel().Width(), 0);
+
+ return BitmapEx(aRecovered, aMask);
+ }
+
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &rCtx) override
+ {
+ if (rCtx.meStyle == RENDER_EXPANDED)
+ {
+ LoadAllImages();
+
+ Point aLocation(0,maIcons[0].GetSizePixel().Height() + 8);
+ for (size_t i = 0; i < maIcons.size(); i++)
+ {
+ BitmapEx aSrc = maIcons[i];
+
+ // original above
+ Point aAbove(aLocation);
+ aAbove.Move(0,-aSrc.GetSizePixel().Height() - 4);
+ rDev.DrawBitmapEx(aAbove, aSrc);
+ aAbove.Move(aSrc.GetSizePixel().Width(),0);
+ aAbove.Move(aSrc.GetSizePixel().Width(),0);
+ rDev.DrawBitmap(aAbove, aSrc.GetBitmap());
+ aAbove.Move(aSrc.GetSizePixel().Width(),0);
+ rDev.DrawBitmap(aAbove, aSrc.GetAlpha());
+
+ // intermediates middle
+ BitmapEx aResult = AlphaRecovery(rDev, aLocation, aSrc);
+
+ // result below
+ Point aBelow(aLocation);
+ aBelow.Move(0,aResult.GetSizePixel().Height());
+ rDev.DrawBitmapEx(aBelow, aResult);
+
+ // mini convert test.
+ aBelow.Move(aResult.GetSizePixel().Width()+4,0);
+ rDev.DrawBitmapEx(aBelow, aResult);
+
+ Bitmap aGrey = aSrc.GetBitmap();
+ aGrey.Convert(BmpConversion::N8BitGreys);
+ rDev.DrawBitmap(aBelow, aGrey);
+
+ aBelow.Move(aGrey.GetSizePixel().Width(),0);
+ BitmapEx aGreyMask(aSrc.GetBitmap(),
+ aSrc.GetAlpha());
+ rDev.DrawBitmapEx(aBelow, aGreyMask);
+
+ aLocation.Move(aSrc.GetSizePixel().Width()*6,0);
+ if (aLocation.X() > r.Right())
+ aLocation = Point(0,aLocation.Y()+aSrc.GetSizePixel().Height()*3+4);
+ }
+
+ // now go crazy with random foo
+ doDrawIcons(rDev, r, true);
+ }
+ else
+ {
+ doDrawIcons(rDev, r, false);
+ }
+ }
+ };
+
+ struct FetchDrawBitmap : public RegionRenderer
+ {
+ RENDER_DETAILS(fetchdraw,KEY_F,50)
+ virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r,
+ const RenderContext &) override
+ {
+ Bitmap aBitmap(rDev.GetBitmap(Point(0,0),rDev.GetOutputSizePixel()));
+ aBitmap.Scale(r.GetSize(), BmpScaleFlag::BestQuality);
+ rDev.DrawBitmap(r.TopLeft(), aBitmap);
+ }
+ };
+
+ void drawThumbs(vcl::RenderContext& rDev, tools::Rectangle aRect, bool bVDev)
+ {
+ RenderContext aCtx;
+ aCtx.meStyle = RENDER_THUMB;
+ aCtx.mbVDev = bVDev;
+ aCtx.mpDemoRenderer = this;
+ aCtx.maSize = aRect.GetSize();
+ std::vector<tools::Rectangle> aRegions(partition(aRect, mnSegmentsX, mnSegmentsY));
+ DemoRenderer::clearRects(rDev, aRegions);
+ for (size_t i = 0; i < maRenderers.size(); i++)
+ {
+ RegionRenderer * r = maRenderers[i];
+
+ rDev.SetClipRegion( vcl::Region( aRegions[i] ) );
+
+ // profiling?
+ if (getIterCount() > 0)
+ {
+ if (!bVDev)
+ {
+ double nStartTime = getTimeNow();
+ for (int j = 0; j < r->getTestRepeatCount() * THUMB_REPEAT_FACTOR; j++)
+ r->RenderRegion(rDev, aRegions[i], aCtx);
+ addTime(i, (getTimeNow() - nStartTime) / THUMB_REPEAT_FACTOR);
+ } else
+ for (int j = 0; j < r->getTestRepeatCount(); j++)
+ r->RenderRegion(rDev, aRegions[i], aCtx);
+ }
+ else
+ r->RenderRegion(rDev, aRegions[i], aCtx);
+
+ rDev.SetClipRegion();
+ }
+ }
+
+ void drawToDevice(vcl::RenderContext& rDev, Size aSize, bool bVDev)
+ {
+ RenderContext aCtx;
+ aCtx.mbVDev = bVDev;
+ aCtx.mpDemoRenderer = this;
+ aCtx.maSize = aSize;
+ tools::Rectangle aWholeWin(Point(0,0), rDev.GetOutputSizePixel());
+
+ drawBackground(rDev, aWholeWin);
+
+ if (!bVDev /* want everything in the vdev */ &&
+ mnSelectedRenderer >= 0 &&
+ o3tl::make_unsigned(mnSelectedRenderer) < maRenderers.size())
+ {
+ aCtx.meStyle = RENDER_EXPANDED;
+ RegionRenderer * r = maRenderers[mnSelectedRenderer];
+ // profiling?
+ if (getIterCount() > 0)
+ {
+ double nStartTime = getTimeNow();
+ for (int i = 0; i < r->getTestRepeatCount(); i++)
+ r->RenderRegion(rDev, aWholeWin, aCtx);
+ addTime(mnSelectedRenderer, getTimeNow() - nStartTime);
+ } else
+ r->RenderRegion(rDev, aWholeWin, aCtx);
+ }
+ else
+ drawThumbs(rDev, aWholeWin, bVDev);
+ }
+ std::vector<VclPtr<vcl::Window> > maInvalidates;
+ void addInvalidate(vcl::Window *pWindow) { maInvalidates.emplace_back(pWindow); };
+ void removeInvalidate(vcl::Window *pWindow)
+ {
+ auto aIt = std::find(maInvalidates.begin(), maInvalidates.end(), pWindow);
+ if (aIt != maInvalidates.end())
+ maInvalidates.erase(aIt);
+ }
+ void Invalidate()
+ {
+ for (auto const& invalidate : maInvalidates)
+ invalidate->Invalidate();
+ }
+};
+
+}
+
+#if FIXME_BOUNCE_BUTTON
+IMPL_LINK_NOARG(DemoRenderer,BounceTimerCb,Timer*,void)
+{
+ mpButton->Check(mnBounceX>0);
+ mpButton->SetPressed(mnBounceY>0);
+
+ Point aCur = mpButtonWin->GetPosPixel();
+ static const int nMovePix = 10;
+ aCur.Move(mnBounceX * nMovePix, mnBounceX * nMovePix);
+ Size aWinSize = GetSizePixel();
+ if (aCur.X() <= 0 || aCur.X() >= aWinSize.Width())
+ mnBounceX *= -1;
+ if (aCur.Y() <= 0 || aCur.Y() >= aWinSize.Height())
+ mnBounceX *= -1;
+ mpButtonWin->SetPosPixel(aCur);
+
+ // All smoke and mirrors to test sub-region invalidation underneath
+ Rectangle aRect(aCur, mpButtonWin->GetSizePixel());
+ Invalidate(aRect);
+}
+#endif
+
+void DemoRenderer::KeyInput(const KeyEvent &rKEvt)
+{
+ sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
+
+ // click to zoom out
+ if (mnSelectedRenderer >= 0)
+ {
+ if (nCode == KEY_ESCAPE || nCode == KEY_BACKSPACE)
+ {
+ mnSelectedRenderer = -1;
+ Invalidate();
+ return;
+ }
+ }
+ else
+ {
+ for (size_t i = 0; i < maRenderers.size(); i++)
+ {
+ if (nCode == maRenderers[i]->getAccelerator())
+ {
+ mnSelectedRenderer = i;
+ Invalidate();
+ return;
+ }
+ }
+ }
+}
+
+bool DemoRenderer::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ // click to zoom out
+ if (mnSelectedRenderer >= 0)
+ {
+ mnSelectedRenderer = -1;
+ Invalidate();
+ return true;
+ }
+
+ // click on a region to zoom into it
+ std::vector<tools::Rectangle> aRegions(partition(GetSizePixel(), mnSegmentsX, mnSegmentsY));
+ for (size_t i = 0; i < aRegions.size(); i++)
+ {
+ if (aRegions[i].Contains(rMEvt.GetPosPixel()))
+ {
+ mnSelectedRenderer = i;
+ Invalidate();
+ return true;
+ }
+ }
+
+#if FIXME_BOUNCE_BUTTON
+ // otherwise bounce floating windows
+ if (!mpButton)
+ {
+ mpButtonWin = VclPtr<FloatingWindow>::Create(this);
+ mpButton = VclPtr<PushButton>::Create(mpButtonWin);
+ mpButton->SetSymbol(SymbolType::HELP);
+ mpButton->SetText("PushButton demo");
+ mpButton->SetPosSizePixel(Point(0,0), mpButton->GetOptimalSize());
+ mpButton->Show();
+ mpButtonWin->SetPosSizePixel(Point(0,0), mpButton->GetOptimalSize());
+ mpButtonWin->Show();
+ mnBounceX = 1; mnBounceX = 1;
+ maBounce.SetInvokeHandler(LINK(this,DemoRenderer,BounceTimerCb));
+ maBounce.SetTimeout(55);
+ maBounce.Start();
+ }
+ else
+ {
+ maBounce.Stop();
+ delete mpButtonWin;
+ mpButtonWin = NULL;
+ mpButton = NULL;
+ }
+#endif
+ return false;
+}
+
+void DemoRenderer::InitRenderers()
+{
+ maRenderers.push_back(new DrawLines);
+ maRenderers.push_back(new DrawText);
+ maRenderers.push_back(new DrawPoly);
+ maRenderers.push_back(new DrawEllipse);
+ maRenderers.push_back(new DrawCheckered);
+ maRenderers.push_back(new DrawBitmapEx);
+ maRenderers.push_back(new DrawBitmap);
+ maRenderers.push_back(new DrawGradient);
+ maRenderers.push_back(new DrawPolyPolygons);
+ maRenderers.push_back(new DrawClipped);
+ maRenderers.push_back(new DrawToVirtualDevice);
+ maRenderers.push_back(new DrawXOR);
+ maRenderers.push_back(new DrawIcons());
+ maRenderers.push_back(new FetchDrawBitmap);
+}
+
+OUString DemoRenderer::getRendererList()
+{
+ OUStringBuffer aBuf;
+ for (size_t i = 0; i < maRenderers.size(); i++)
+ {
+ aBuf.append(maRenderers[i]->getName());
+ aBuf.append(' ');
+ }
+ return aBuf.makeStringAndClear();
+}
+
+double DemoRenderer::getAndResetBenchmark(const RenderStyle style)
+{
+ double geomean = 1.0;
+ fprintf(stderr, "Rendering: %s, Times (ms):\n", style == RENDER_THUMB ? "THUMB": "EXPANDED");
+ for (size_t i = 0; i < maRenderers.size(); i++)
+ {
+ double avgtime = maRenderers[i]->sumTime / maRenderers[i]->countTime;
+ geomean *= avgtime;
+ fprintf(stderr, "%s: %f (iteration: %d*%d*%d)\n",
+ OUStringToOString(maRenderers[i]->getName(),
+ RTL_TEXTENCODING_UTF8).getStr(), avgtime,
+ maRenderers[i]->countTime, maRenderers[i]->getTestRepeatCount(),
+ (style == RENDER_THUMB) ? THUMB_REPEAT_FACTOR : 1);
+ maRenderers[i]->sumTime = 0;
+ maRenderers[i]->countTime = 0;
+ }
+ geomean = pow(geomean, 1.0/maRenderers.size());
+ fprintf(stderr, "GEOMEAN_%s: %f\n", style == RENDER_THUMB ? "THUMB": "EXPANDED", geomean);
+ return geomean;
+}
+
+void DemoRenderer::setIterCount(sal_Int32 i)
+{
+ iterCount = i;
+}
+
+sal_Int32 DemoRenderer::getIterCount() const
+{
+ return iterCount;
+}
+
+void DemoRenderer::addTime(int i, double t)
+{
+ maRenderers[i]->sumTime += t / maRenderers[i]->getTestRepeatCount();
+ maRenderers[i]->countTime++;
+}
+
+void DemoRenderer::selectRenderer(std::u16string_view rName )
+{
+ for (size_t i = 0; i < maRenderers.size(); i++)
+ {
+ if (maRenderers[i]->getName() == rName)
+ {
+ mnSelectedRenderer = i;
+ Invalidate();
+ return;
+ }
+ }
+}
+
+int DemoRenderer::selectNextRenderer()
+{
+ mnSelectedRenderer++;
+ if (mnSelectedRenderer == static_cast<signed>(maRenderers.size()))
+ mnSelectedRenderer = -1;
+ Invalidate();
+ return mnSelectedRenderer;
+}
+
+namespace {
+
+class DemoWin : public WorkWindow
+{
+ DemoRenderer &mrRenderer;
+ bool underTesting;
+ bool testThreads;
+
+ class RenderThread final : public salhelper::Thread {
+ DemoWin &mrWin;
+ sal_uInt32 const mnDelaySecs = 0;
+ public:
+ RenderThread(DemoWin &rWin, sal_uInt32 nDelaySecs)
+ : Thread("vcldemo render thread")
+ , mrWin(rWin)
+ , mnDelaySecs(nDelaySecs)
+ {
+ launch();
+ }
+ virtual ~RenderThread() override
+ {
+ join();
+ }
+ virtual void execute() override
+ {
+ wait(std::chrono::seconds(mnDelaySecs));
+
+ SolarMutexGuard aGuard;
+ fprintf (stderr, "render from a different thread\n");
+ mrWin.Invalidate();
+ }
+ };
+ rtl::Reference<RenderThread> mxThread;
+
+public:
+ DemoWin(DemoRenderer &rRenderer, bool bThreads) :
+ WorkWindow(nullptr, WB_APP | WB_STDWORK),
+ mrRenderer(rRenderer),
+ testThreads(bThreads)
+ {
+ mrRenderer.addInvalidate(this);
+ underTesting = false;
+ }
+ virtual ~DemoWin() override
+ {
+ disposeOnce();
+ }
+ virtual void dispose() override
+ {
+ mxThread.clear();
+ mrRenderer.removeInvalidate(this);
+ WorkWindow::dispose();
+ }
+ virtual void MouseButtonDown(const MouseEvent& rMEvt) override
+ {
+ mrRenderer.SetSizePixel(GetSizePixel());
+ if (mrRenderer.MouseButtonDown(rMEvt))
+ return;
+
+ if (testThreads)
+ { // render this window asynchronously in a new thread
+ sal_uInt32 nDelaySecs = 0;
+ if (rMEvt.GetButtons() & MOUSE_RIGHT)
+ nDelaySecs = 5;
+ mxThread = new RenderThread(*this, nDelaySecs);
+ }
+ else
+ { // spawn another window
+ VclPtrInstance<DemoWin> pNewWin(mrRenderer, testThreads);
+ pNewWin->SetText("Another interactive VCL demo window");
+ pNewWin->Show();
+ }
+ }
+ virtual void KeyInput(const KeyEvent& rKEvt) override
+ {
+ mrRenderer.SetSizePixel(GetSizePixel());
+ mrRenderer.KeyInput(rKEvt);
+ }
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override
+ {
+ mrRenderer.SetSizePixel(GetSizePixel());
+ fprintf(stderr, "DemoWin::Paint(%" SAL_PRIdINT64 ",%" SAL_PRIdINT64 ",%" SAL_PRIdINT64 ",%" SAL_PRIdINT64 ")\n", sal_Int64(rRect.Left()), sal_Int64(rRect.Top()), sal_Int64(rRect.getWidth()), sal_Int64(rRect.getHeight()));
+ if (mrRenderer.getIterCount() == 0)
+ mrRenderer.drawToDevice(rRenderContext, GetSizePixel(), false);
+ else
+ TestAndQuit(rRenderContext);
+ }
+
+ void TestAndQuit(vcl::RenderContext& rRenderContext)
+ {
+ if (underTesting)
+ return;
+ underTesting = true;
+ for (sal_Int32 i = 0; i < mrRenderer.getIterCount(); i++)
+ {
+ while (mrRenderer.selectNextRenderer() > -1)
+ {
+ mrRenderer.drawToDevice(rRenderContext, GetSizePixel(), false);
+ }
+ }
+
+ double expandedGEOMEAN = mrRenderer.getAndResetBenchmark(RENDER_EXPANDED);
+
+ for (sal_Int32 i = 0; i < mrRenderer.getIterCount(); i++)
+ mrRenderer.drawToDevice(rRenderContext, GetSizePixel(), false);
+
+ double thumbGEOMEAN = mrRenderer.getAndResetBenchmark(RENDER_THUMB);
+
+ fprintf(stderr, "GEOMEAN_TOTAL: %f\n", pow(thumbGEOMEAN * expandedGEOMEAN, 0.5));
+ Application::Quit();
+ }
+};
+
+struct PointerData {
+ PointerStyle eStyle;
+ const char * name;
+};
+
+}
+
+const PointerData gvPointerData [] = {
+ { PointerStyle::Null, "Null" },
+ { PointerStyle::Magnify, "Magnify" },
+ { PointerStyle::Fill, "Fill" },
+ { PointerStyle::MoveData, "MoveData" },
+ { PointerStyle::CopyData, "CopyData" },
+ { PointerStyle::MoveFile, "MoveFile" },
+ { PointerStyle::CopyFile, "CopyFile" },
+ { PointerStyle::MoveFiles, "MoveFiles" },
+ { PointerStyle::CopyFiles, "CopyFiles" },
+ { PointerStyle::NotAllowed, "NotAllowed" },
+ { PointerStyle::Rotate, "Rotate" },
+ { PointerStyle::HShear, "HShear" },
+ { PointerStyle::VShear, "VShear" },
+ { PointerStyle::DrawLine, "DrawLine" },
+ { PointerStyle::DrawRect, "DrawRect" },
+ { PointerStyle::DrawPolygon, "DrawPolygon" },
+ { PointerStyle::DrawBezier, "DrawBezier" },
+ { PointerStyle::DrawArc, "DrawArc" },
+ { PointerStyle::DrawPie, "DrawPie" },
+ { PointerStyle::DrawCircleCut, "DrawCircleCut" },
+ { PointerStyle::DrawEllipse, "DrawEllipse" },
+ { PointerStyle::DrawConnect, "DrawConnect" },
+ { PointerStyle::DrawText, "DrawText" },
+ { PointerStyle::Mirror, "Mirror" },
+ { PointerStyle::Crook, "Crook" },
+ { PointerStyle::Crop, "Crop" },
+ { PointerStyle::MovePoint, "MovePoint" },
+ { PointerStyle::MoveBezierWeight, "MoveBezierWeight" },
+ { PointerStyle::DrawFreehand, "DrawFreehand" },
+ { PointerStyle::DrawCaption, "DrawCaption" },
+ { PointerStyle::LinkData, "LinkData" },
+ { PointerStyle::MoveDataLink, "MoveDataLink" },
+ { PointerStyle::CopyDataLink, "CopyDataLink" },
+ { PointerStyle::LinkFile, "LinkFile" },
+ { PointerStyle::MoveFileLink, "MoveFileLink" },
+ { PointerStyle::CopyFileLink, "CopyFileLink" },
+ { PointerStyle::Chart, "Chart" },
+ { PointerStyle::Detective, "Detective" },
+ { PointerStyle::PivotCol, "PivotCol" },
+ { PointerStyle::PivotRow, "PivotRow" },
+ { PointerStyle::PivotField, "PivotField" },
+ { PointerStyle::PivotDelete, "PivotDelete" },
+ { PointerStyle::Chain, "Chain" },
+ { PointerStyle::ChainNotAllowed, "ChainNotAllowed" },
+ { PointerStyle::AutoScrollN, "AutoScrollN" },
+ { PointerStyle::AutoScrollS, "AutoScrollS" },
+ { PointerStyle::AutoScrollW, "AutoScrollW" },
+ { PointerStyle::AutoScrollE, "AutoScrollE" },
+ { PointerStyle::AutoScrollNW, "AutoScrollNW" },
+ { PointerStyle::AutoScrollNE, "AutoScrollNE" },
+ { PointerStyle::AutoScrollSW, "AutoScrollSW" },
+ { PointerStyle::AutoScrollSE, "AutoScrollSE" },
+ { PointerStyle::AutoScrollNS, "AutoScrollNS" },
+ { PointerStyle::AutoScrollWE, "AutoScrollWE" },
+ { PointerStyle::AutoScrollNSWE, "AutoScrollNSWE" },
+ { PointerStyle::TextVertical, "TextVertical" },
+ { PointerStyle::TabSelectS, "TabSelectS" },
+ { PointerStyle::TabSelectE, "TabSelectE" },
+ { PointerStyle::TabSelectSE, "TabSelectSE" },
+ { PointerStyle::TabSelectW, "TabSelectW" },
+ { PointerStyle::TabSelectSW, "TabSelectSW" },
+ { PointerStyle::HideWhitespace, "HideWhitespace" },
+ { PointerStyle::ShowWhitespace, "ShowWhitespace" },
+ { PointerStyle::FatCross, "FatCross" },
+};
+
+namespace {
+
+class DemoWidgets : public WorkWindow
+{
+ VclPtr<MenuBar> mpBar;
+ VclPtr<VclBox> mpBox;
+ VclPtr<ToolBox> mpToolbox;
+ VclPtr<PushButton> mpButton;
+ std::vector<VclPtr<VclHBox>> mvCursorBoxes;
+ std::vector<VclPtr<PushButton>> mvCursorButtons;
+
+ DECL_LINK(CursorButtonClick, Button*, void);
+
+public:
+ DemoWidgets() :
+ WorkWindow(nullptr, WB_APP | WB_STDWORK),
+ mpBox(VclPtrInstance<VclVBox>(this, false, 3)),
+ mpToolbox(VclPtrInstance<ToolBox>(mpBox.get())),
+ mpButton(VclPtrInstance<PushButton>(mpBox.get()))
+ {
+ SetText("VCL widget demo");
+
+ Wallpaper aWallpaper(BitmapEx("sfx2/res/128x128_writer_doc-p.png"));
+ aWallpaper.SetStyle(WallpaperStyle::BottomRight);
+ aWallpaper.SetColor(COL_RED);
+
+ mpBox->SetBackground(aWallpaper);
+ mpBox->Show();
+
+ Help::EnableBalloonHelp();
+ mpToolbox->SetHelpText("Help text");
+ mpToolbox->InsertItem(ToolBoxItemId(0), "Toolbar item");
+ mpToolbox->SetQuickHelpText(ToolBoxItemId(0), "This is a tooltip popup");
+ mpToolbox->InsertSeparator();
+ mpToolbox->Show();
+
+ mpButton->SetText("Click me; go on");
+ mpButton->Show();
+
+ int i = 0;
+ VclHBox* pCurrentCursorHBox = nullptr;
+ constexpr int numButtonsPerRow = 9;
+ for (auto & rData : gvPointerData)
+ {
+ if (i % numButtonsPerRow == 0)
+ {
+ mvCursorBoxes.push_back(VclPtrInstance<VclHBox>(mpBox.get(), true, numButtonsPerRow));
+ pCurrentCursorHBox = mvCursorBoxes.back().get();
+ pCurrentCursorHBox->Show();
+ }
+ mvCursorButtons.emplace_back(VclPtrInstance<PushButton>(pCurrentCursorHBox));
+ PushButton& rButton = *mvCursorButtons.back();
+ rButton.SetText(OUString::createFromAscii(rData.name));
+ rButton.SetClickHdl(LINK(this,DemoWidgets,CursorButtonClick));
+ rButton.Show();
+ ++i;
+ }
+
+ mpBar = VclPtr<MenuBar>::Create();
+ mpBar->InsertItem(0,"File");
+ VclPtrInstance<PopupMenu> pPopup;
+ pPopup->InsertItem(0,"Item");
+ mpBar->SetPopupMenu(0, pPopup);
+ SetMenuBar(mpBar);
+
+ Show();
+ }
+ virtual ~DemoWidgets() override { disposeOnce(); }
+ virtual void dispose() override
+ {
+ for (auto & p : mvCursorButtons)
+ p.disposeAndClear();
+ mvCursorButtons.clear();
+ for (auto & p : mvCursorBoxes)
+ p.disposeAndClear();
+ mvCursorBoxes.clear();
+ mpToolbox.disposeAndClear();
+ mpButton.disposeAndClear();
+ mpBox.disposeAndClear();
+ mpBar.disposeAndClear();
+ WorkWindow::dispose();
+ }
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override
+ {
+ tools::Rectangle aWholeSize(Point(0, 0),GetOutputSizePixel());
+ vcl::Region aClip(aWholeSize);
+ tools::Rectangle aExclude(tools::Rectangle(Point(50,50),Size(100,100)));
+ aClip.Exclude(aExclude);
+
+ Wallpaper aWallpaper(COL_GREEN);
+
+ rRenderContext.Push(vcl::PushFlags::CLIPREGION);
+ rRenderContext.IntersectClipRegion(aClip);
+ rRenderContext.DrawWallpaper(aWholeSize, aWallpaper);
+ rRenderContext.Pop();
+
+ ScopedVclPtrInstance< VirtualDevice > pDev(*GetOutDev());
+ pDev->EnableRTL(IsRTLEnabled());
+ pDev->SetOutputSizePixel(aExclude.GetSize());
+
+ tools::Rectangle aSubRect(aWholeSize);
+ aSubRect.Move(-aExclude.Left(), -aExclude.Top());
+ pDev->DrawWallpaper(aSubRect, aWallpaper );
+
+ rRenderContext.DrawOutDev(aExclude.TopLeft(), aExclude.GetSize(),
+ Point( 0, 0 ), aExclude.GetSize(), *pDev );
+ }
+};
+
+}
+
+IMPL_LINK(DemoWidgets, CursorButtonClick, Button*, pButton, void)
+{
+ for (size_t i=0; i<SAL_N_ELEMENTS(gvPointerData); ++i)
+ {
+ if (mvCursorButtons[i].get() == pButton)
+ {
+ mpBox->SetPointer( gvPointerData[i].eStyle );
+ return;
+ }
+ }
+ assert(false);
+}
+
+namespace {
+
+class DemoPopup : public FloatingWindow
+{
+ public:
+ DemoPopup() : FloatingWindow( nullptr, WB_SYSTEMWINDOW|WB_TOOLTIPWIN)
+ {
+ SetType( WindowType::HELPTEXTWINDOW );
+
+ SetOutputSizePixel( Size( 300, 30 ) );
+ SetBackground(Wallpaper(COL_YELLOW));
+
+ Show( true, ShowFlags::NoActivate );
+ PaintImmediately();
+ }
+
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override
+ {
+ Size aSize = GetOutputSizePixel();
+ tools::Rectangle aTextRect(Point(6, 6), aSize);
+
+ SetTextColor(COL_BLACK);
+ SetTextAlign(ALIGN_TOP);
+ rRenderContext.DrawText(aTextRect, "This is a standalone help text test",
+ DrawTextFlags::MultiLine|DrawTextFlags::WordBreak|
+ DrawTextFlags::Left|DrawTextFlags::Top);
+
+ rRenderContext.SetLineColor(COL_BLACK);
+ rRenderContext.SetFillColor();
+ rRenderContext.DrawRect( tools::Rectangle( Point(), aSize ) );
+ aSize.AdjustWidth( -2 );
+ aSize.AdjustHeight( -2 );
+ Color aColor( rRenderContext.GetLineColor() );
+ rRenderContext.SetLineColor( COL_GRAY );
+ rRenderContext.DrawRect( tools::Rectangle( Point( 1, 1 ), aSize ) );
+ rRenderContext.SetLineColor( aColor );
+ }
+
+ virtual void MouseButtonDown( const MouseEvent & ) override
+ {
+ Application::Quit();
+ }
+};
+
+}
+
+namespace {
+ void renderFonts()
+ {
+ ScopedVclPtrInstance<VirtualDevice> xDevice;
+ Size aSize(1024, 1024);
+ xDevice->SetOutputSizePixel(aSize);
+
+#if 0
+ for (auto & aFontName : aFontNames)
+ {
+ vcl::Font aFont(aFontName, Size(0,96));
+
+ aFont.Set(COL_BLACK);
+ xDevice->SetFont(aFont);
+ xDevice->Erase();
+
+ FontMetric aMetric = xDevice->GetFontMetric(aFont);
+
+ FontCharMapRef xMap;
+ if (xDevice->GetFontCharMap(xMap))
+ {
+ ... iterate through glyphs ...
+ }
+
+
+ bool GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr, int nIndex,
+ int nLen, int nBase, MetricVector& rVector );
+
+include/vcl/outdev.hxx:typedef std::vector< Rectangle > MetricVector;
+include/vcl/outdev.hxx: MetricVector* pVector = nullptr, OUString* pDisplayText = nullptr );
+include/vcl/outdev.hxx: MetricVector* pVector = nullptr, OUString* pDisplayText = nullptr,
+include/vcl/outdev.hxx: MetricVector* pVector, OUString* pDisplayText, vcl::ITextLayout& _rLayout );
+include/vcl/outdev.hxx: DrawTextFlags nStyle = DrawTextFlags::Mnemonic, MetricVector* pVector = nullp
+
+ bool GetTextBoundRect( Rectangle& rRect,
+ const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
+ sal_uLong nLayoutWidth = 0, const long* pDXArray = nullptr ) const;
+
+
+ void DrawText( const Point& rStartPt, const OUString& rStr,
+ sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
+ MetricVector* pVector = nullptr, OUString* pDisplayText = nullptr );
+
+ void DrawText( const Rectangle& rRect,
+ const OUString& rStr, DrawTextFlags nStyle = DrawTextFlags::NONE,
+ MetricVector* pVector = nullptr, OUString* pDisplayText = nullptr,
+ vcl::ITextLayout* _pTextLayout = nullptr );
+
+ Rectangle GetTextRect( const Rectangle& rRect,
+ const OUString& rStr, DrawTextFlags nStyle = DrawTextFlags::WordBreak,
+ TextRectInfo* pInfo = nullptr,
+ const vcl::ITextLayout* _pTextLayout = nullptr ) const;
+
+ }
+#endif
+
+ }
+};
+
+namespace {
+
+class DemoApp : public Application
+{
+ static int showHelp(DemoRenderer &rRenderer)
+ {
+ fprintf(stderr,"vcldemo - a VCL test app\n");
+ fprintf(stderr," --help - print this text\n");
+ fprintf(stderr," --show <renderer> - start with a given renderer, options are:\n");
+ OUString aRenderers(rRenderer.getRendererList());
+ fprintf(stderr," %s\n",
+ OUStringToOString(aRenderers, RTL_TEXTENCODING_UTF8).getStr());
+ fprintf(stderr," --test <iterCount> - create benchmark data\n");
+ fprintf(stderr," --widgets - launch the widget test.\n");
+ fprintf(stderr," --popup - launch the popup test.\n");
+ fprintf(stderr," --threads - render from multiple threads.\n");
+ fprintf(stderr," --font <fontname> - run the font render test.\n");
+ fprintf(stderr, "\n");
+ return 0;
+ }
+
+public:
+ DemoApp() {}
+
+ virtual int Main() override
+ {
+ try
+ {
+ bool bWidgets = false;
+ bool bThreads = false;
+ bool bPopup = false;
+ DemoRenderer aRenderer;
+ std::vector<OUString> aFontNames;
+
+ for (sal_uInt16 i = 0; i < GetCommandLineParamCount(); ++i)
+ {
+ bool bLast = i == GetCommandLineParamCount() - 1;
+ OUString aArg = GetCommandLineParam(i);
+ if (aArg == "--help" || aArg == "-h")
+ return showHelp(aRenderer);
+ if (aArg == "--show")
+ {
+ if (bLast)
+ return showHelp(aRenderer);
+ else
+ aRenderer.selectRenderer(GetCommandLineParam(++i));
+ }
+ else if (aArg == "--test")
+ {
+ if (bLast)
+ return showHelp(aRenderer);
+ else
+ aRenderer.setIterCount(GetCommandLineParam(++i).toInt32());
+ }
+ else if (aArg == "--widgets")
+ bWidgets = true;
+ else if (aArg == "--popup")
+ bPopup = true;
+ else if (aArg == "--threads")
+ bThreads = true;
+ else if (aArg == "--font" && !bLast)
+ aFontNames.push_back(GetCommandLineParam(++i));
+ else if (aArg.startsWith("--"))
+ {
+ fprintf(stderr,"Unknown argument '%s'\n",
+ OUStringToOString(aArg, RTL_TEXTENCODING_UTF8).getStr());
+ return showHelp(aRenderer);
+ }
+ }
+
+ ScopedVclPtrInstance<DemoWin> aMainWin(aRenderer, bThreads);
+ VclPtr<DemoWidgets> xWidgets;
+ VclPtr<DemoPopup> xPopup;
+
+ aMainWin->SetText("Interactive VCL demo #1");
+ if (bWidgets)
+ xWidgets = VclPtr< DemoWidgets >::Create ();
+ else if (bPopup)
+ xPopup = VclPtrInstance< DemoPopup> ();
+ else if (!aFontNames.empty())
+ renderFonts();
+ else
+ aMainWin->Show();
+
+ Application::Execute();
+
+ xWidgets.disposeAndClear();
+ xPopup.disposeAndClear();
+ }
+ catch (const css::uno::Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("vcl.app", "Fatal");
+ return 1;
+ }
+ catch (const std::exception& e)
+ {
+ SAL_WARN("vcl.app", "Fatal: " << e.what());
+ return 1;
+ }
+ return 0;
+ }
+
+protected:
+ void Init() override
+ {
+ LanguageTag::setConfiguredSystemLanguage(MsLangId::getSystemLanguage());
+
+ try
+ {
+ uno::Reference<uno::XComponentContext> xComponentContext
+ = ::cppu::defaultBootstrap_InitialComponentContext();
+ uno::Reference<lang::XMultiServiceFactory> xMSF;
+ xMSF.set(xComponentContext->getServiceManager(), uno::UNO_QUERY);
+ if(!xMSF.is())
+ Application::Abort("Bootstrap failure - no service manager");
+
+ ::comphelper::setProcessServiceFactory(xMSF);
+ }
+ catch (const uno::Exception &e)
+ {
+ Application::Abort("Bootstrap exception " + e.Message);
+ }
+ }
+ void DeInit() override
+ {
+ framework::getDesktop(::comphelper::getProcessComponentContext())->terminate();
+ framework::getDesktop(::comphelper::getProcessComponentContext())->disposing();
+
+ uno::Reference< lang::XComponent >(
+ comphelper::getProcessComponentContext(),
+ uno::UNO_QUERY_THROW)-> dispose();
+ ::comphelper::setProcessServiceFactory(nullptr);
+ }
+};
+
+}
+
+void vclmain::createApplication()
+{
+#ifdef _WIN32
+ _putenv_s("LIBO_VCL_DEMO", "1");
+#else
+ setenv("LIBO_VCL_DEMO", "1", 0);
+#endif
+ static DemoApp aApp;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/webpfuzzer.cxx b/vcl/workben/webpfuzzer.cxx
new file mode 100644
index 000000000..b7ae8f741
--- /dev/null
+++ b/vcl/workben/webpfuzzer.cxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+#include <filter/WebpReader.hxx>
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping* lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = { { 0, 0 } };
+
+ return map;
+}
+
+const lib_to_constructor_mapping* lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = { { 0, 0 } };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*) { return nullptr; }
+
+extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportWebpGraphic(aStream, aGraphic);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/webpfuzzer.options b/vcl/workben/webpfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/webpfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/win/dnd/atlwindow.cxx b/vcl/workben/win/dnd/atlwindow.cxx
new file mode 100644
index 000000000..61781e18f
--- /dev/null
+++ b/vcl/workben/win/dnd/atlwindow.cxx
@@ -0,0 +1,238 @@
+/* -*- 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 <com/sun/star/uno/Reference.h>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
+#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
+
+#include <cppuhelper/servicefactory.hxx>
+#include <rtl/string.h>
+
+#include "atlwindow.hxx"
+#include "targetlistener.hxx"
+#include "sourcelistener.hxx"
+#include <map>
+
+#include <winbase.h>
+using namespace com::sun::star::lang;
+using namespace com::sun::star::datatransfer::dnd;
+using namespace com::sun::star::datatransfer::dnd::DNDConstants;
+using namespace cppu;
+
+LRESULT APIENTRY EditSubclassProc( HWND hwnd, UINT uMsg,WPARAM wParam, LPARAM lParam) ;
+
+extern Reference< XMultiServiceFactory > MultiServiceFactory;
+DWORD WINAPI MTAFunc(LPVOID pParams);
+
+char* szSTAWin= "XDragSource::executeDrag is called from the same "
+ "OLE STA thread that created the window.";
+char* szMTAWin= "XDragSource::executeDrag is called from an MTA thread "
+ "that did not create the window.";
+
+WNDPROC wpOrigEditProc;
+
+map<HWND, HWND> mapEditToMainWnd;
+
+LRESULT AWindow::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ Reference<XComponent> xcompSource( m_xDragSource, UNO_QUERY);
+
+ PostQuitMessage(0);
+
+ m_xDropTarget=0;
+ m_xDragSource=0;
+
+ // Remove the subclass from the edit control.
+ ::SetWindowLong(m_hwndEdit, GWL_WNDPROC,
+ (LONG) wpOrigEditProc);
+
+ return 0;
+}
+
+LRESULT AWindow::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ // Prepare the EDIT control
+ m_hwndEdit = CreateWindowA(
+ "EDIT", // predefined class
+ NULL, // no window title
+ WS_CHILD | WS_VISIBLE | WS_VSCROLL |
+ ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL,
+ 0, 0, 0, 0, // set size in WM_SIZE message
+ m_hWnd, // parent window
+ (HMENU) NULL, // edit control ID
+ (HINSTANCE) GetWindowLong( GWL_HINSTANCE),
+ NULL);
+
+ // the map is used in the window procedure for the edit window to associate the
+ // it to the right main window ( AWindow)
+ mapEditToMainWnd[m_hwndEdit]= m_hWnd;
+ // Superclass the edit window, because we want to process mouse messages
+ wpOrigEditProc = (WNDPROC) ::SetWindowLongA(m_hwndEdit,
+ GWL_WNDPROC, (LONG) EditSubclassProc);
+
+ // Add text to the window.
+ if( m_isMTA)
+ ::SendMessageA(m_hwndEdit, WM_SETTEXT, 0, (LPARAM) szMTAWin);
+ else
+ ::SendMessageA(m_hwndEdit, WM_SETTEXT, 0, (LPARAM) szSTAWin);
+
+ // create the DragSource
+ Reference< XInterface> xint= MultiServiceFactory->createInstance("com.sun.star.datatransfer.dnd.OleDragSource");
+ m_xDragSource.set( xint, UNO_QUERY );
+ Reference<XInitialization> xInit( xint, UNO_QUERY);
+
+ Any ar[2];
+ ar[1]<<= (sal_uInt32)m_hWnd;
+ xInit->initialize( Sequence<Any>( ar, 2) );
+
+ //create the DropTarget
+ Reference< XInterface> xintTarget= MultiServiceFactory->createInstance("com.sun.star.datatransfer.dnd.OleDropTarget");
+ m_xDropTarget.set( xintTarget, UNO_QUERY );
+ Reference<XInitialization> xInitTarget( xintTarget, UNO_QUERY);
+
+ Any any;
+ any <<= (sal_uInt32)m_hWnd;
+ xInitTarget->initialize( Sequence<Any>( &any, 1) );
+
+ m_xDropTarget->addDropTargetListener( static_cast<XDropTargetListener*>
+ ( new DropTargetListener( m_hwndEdit)) );
+// // make this window a drop target
+ m_xDropTarget->setActive(sal_True);
+
+ return 0;
+}
+
+// When the mouse is dragged for a second than a drag is initiated
+LRESULT AWindow::OnMouseAction(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ if( uMsg== WM_LBUTTONDOWN)
+ {
+ SetTimer( 1, 1000);
+ }
+
+ else if( uMsg == WM_LBUTTONUP)
+ {
+ KillTimer( 1);
+ }
+
+ return 0;
+}
+
+LRESULT AWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ USES_CONVERSION;
+ KillTimer( 1);
+ if(m_xDragSource.is())
+ {
+
+ //Get the Text out of the Edit window
+ int length= (int)::SendMessageA( m_hwndEdit, WM_GETTEXTLENGTH, 0, 0);
+ char * pBuffer= new char[length + 1];
+ ZeroMemory( pBuffer, length + 1);
+ ::SendMessageA( m_hwndEdit, WM_GETTEXT, length, (LPARAM) pBuffer);
+
+ IDataObject* pData= NULL;
+ HRESULT hr= CreateDataCache( NULL, CLSID_NULL, __uuidof(IDataObject),(void**) &pData);
+ if( pData)
+ {
+ FORMATETC format={ CF_TEXT, NULL, DVASPECT_CONTENT, -1, };
+
+ HGLOBAL mem= GlobalAlloc(GHND, length + 1 );
+ void* pMem= GlobalLock( mem);
+ memcpy( pMem, pBuffer, length+1);
+ GlobalUnlock( mem);
+
+ STGMEDIUM medium;
+ medium.tymed= TYMED_HGLOBAL;
+ medium.hGlobal= mem;
+ medium.pUnkForRelease= NULL;
+
+ pData->SetData( &format, &medium, TRUE); // releases HGLOBAL eventually
+
+ Reference<XTransferable> xTrans= CDOTransferable::create(
+ MultiServiceFactory, pData);
+
+ // call XDragSource::executeDrag from an MTA
+ if( m_isMTA )
+ {
+ DWORD mtaThreadId;
+ ThreadData data;
+ data.source= m_xDragSource;
+ data.transferable= xTrans;
+
+ data.evtThreadReady= CreateEvent( NULL, FALSE, FALSE, NULL);
+
+ CloseHandle(CreateThread(NULL, 0, MTAFunc, &data, 0, &mtaThreadId));
+ // We must wait until the thread copied the ThreadData structure
+ WaitForSingleObject( data.evtThreadReady, INFINITE);
+ CloseHandle( data.evtThreadReady);
+
+ }
+ else
+ {
+ m_xDragSource->startDrag( DragGestureEvent(),
+ ACTION_LINK|ACTION_MOVE|ACTION_COPY,
+ 0,
+ 0,
+ xTrans,
+ Reference<XDragSourceListener>( static_cast<XDragSourceListener*>(new DragSourceListener() ) ) );
+ }
+ }
+
+ delete[] pBuffer;
+ }
+
+ return 0;
+}
+
+LRESULT AWindow::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ // Make the edit control the size of the window's
+ // client area.
+ ::MoveWindow(m_hwndEdit,
+ 0, 0, // starting x- and y-coordinates
+ LOWORD(lParam), // width of client area
+ HIWORD(lParam), // height of client area
+ TRUE); // repaint window
+
+ return 0;
+}
+LRESULT AWindow::OnFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ ::SetFocus(m_hwndEdit);
+ return 0;
+}
+
+// Subclass procedure for EDIT window
+LRESULT APIENTRY EditSubclassProc( HWND hwnd, UINT uMsg,WPARAM wParam, LPARAM lParam)
+{
+
+ if( uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST)
+ {
+ HWND hAWindow= mapEditToMainWnd[hwnd];
+ ::SendMessage( hAWindow, uMsg, wParam, lParam);
+
+ }
+ return CallWindowProc( wpOrigEditProc, hwnd, uMsg,
+ wParam, lParam);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/win/dnd/atlwindow.hxx b/vcl/workben/win/dnd/atlwindow.hxx
new file mode 100644
index 000000000..047acf676
--- /dev/null
+++ b/vcl/workben/win/dnd/atlwindow.hxx
@@ -0,0 +1,87 @@
+/* -*- 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 .
+ */
+#pragma once
+#include <atlbase.h>
+extern CComModule _Module;
+#include <atlcom.h>
+#include <atlctl.h>
+#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
+#include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/uno/Reference.h>
+#include "../../source/inc/DtObjFactory.hxx"
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::datatransfer::dnd;
+using namespace com::sun::star::datatransfer;
+
+struct ThreadData
+{
+ Reference<XDragSource> source;
+ Reference<XTransferable> transferable;
+ HANDLE evtThreadReady;
+};
+
+class AWindow: public CWindowImpl<AWindow, CWindow,
+ CWinTraits<WS_CAPTION |WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0> >
+{
+ TCHAR m_strName[80];
+ Reference<XDropTarget> m_xDropTarget;
+ Reference<XDragSource> m_xDragSource;
+ BOOL m_isMTA;
+
+ HWND m_hwndEdit;
+
+public:
+ explicit AWindow(LPCTSTR strName)
+ {
+ RECT rcPos= {0,0,200,200};
+ Create(0, rcPos, strName);
+ }
+ AWindow(LPCTSTR strName, RECT pos, BOOL mta=FALSE): m_isMTA( mta)
+ {
+ Create(0, pos, strName);
+ }
+
+ ~AWindow()
+ {
+ if(m_hWnd)
+ DestroyWindow();
+ }
+
+ BEGIN_MSG_MAP(AWindow)
+ MESSAGE_HANDLER( WM_CLOSE, OnClose)
+ MESSAGE_HANDLER( WM_CREATE, OnCreate)
+ MESSAGE_RANGE_HANDLER( WM_MOUSEFIRST, WM_MOUSELAST, OnMouseAction)
+ MESSAGE_HANDLER( WM_TIMER, OnTimer)
+ MESSAGE_HANDLER( WM_SIZE, OnSize)
+ MESSAGE_HANDLER( WM_SETFOCUS, OnFocus)
+
+ END_MSG_MAP()
+
+ LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnMouseAction(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/win/dnd/dndTest.cxx b/vcl/workben/win/dnd/dndTest.cxx
new file mode 100644
index 000000000..2f2a7bccf
--- /dev/null
+++ b/vcl/workben/win/dnd/dndTest.cxx
@@ -0,0 +1,177 @@
+/* -*- 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 .
+ */
+
+#if defined _MSC_VER
+#pragma warning(push,1)
+#endif
+#include <windows.h>
+#include <comdef.h>
+#include <atlbase.h>
+CComModule _Module;
+#include <atlcom.h>
+#include <atlimpl.cpp>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
+#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <rtl/process.h>
+#include <cppuhelper/servicefactory.hxx>
+#include "sourcelistener.hxx"
+
+#include "atlwindow.hxx"
+BEGIN_OBJECT_MAP(ObjectMap)
+END_OBJECT_MAP()
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::datatransfer;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::datatransfer::dnd;
+using namespace com::sun::star::datatransfer::dnd::DNDConstants;
+
+HRESULT doTest();
+DWORD WINAPI MTAFunc( void* threadData);
+
+Reference< XMultiServiceFactory > MultiServiceFactory;
+
+int main( int argc, char *argv[ ], char *envp[ ] )
+{
+ HRESULT hr;
+ if( FAILED( hr=CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
+ {
+ printf("CoInitializeEx failed \n");
+ return -1;
+ }
+
+ _Module.Init( ObjectMap, GetModuleHandleA( NULL));
+
+ if( FAILED(hr=doTest()))
+ {
+ _com_error err( hr);
+ }
+
+ _Module.Term();
+ CoUninitialize();
+ return 0;
+}
+
+HRESULT doTest()
+{
+
+ MultiServiceFactory= createRegistryServiceFactory( OUString(L"types.rdb"), OUString( L"services.rdb") , sal_True);
+
+ // create the MTA thread that is used to realize MTA calls to the services
+ // We create the thread and wait until the thread has created its message queue
+ HANDLE evt= CreateEventA(NULL, FALSE, FALSE, NULL);
+ DWORD threadIdMTA=0;
+ HANDLE hMTAThread= CreateThread( NULL, 0, MTAFunc, &evt, 0, &threadIdMTA);
+ WaitForSingleObject( evt, INFINITE);
+ CloseHandle(evt);
+
+ HRESULT hr= S_OK;
+ RECT pos1={0,0,300,200};
+ AWindow win("DnD starting in Ole STA", threadIdMTA, pos1);
+
+ RECT pos2={ 0, 205, 300, 405};
+ AWindow win2("DnD starting in MTA", threadIdMTA, pos2, true);
+
+ // win3 and win4 call initialize from an MTA but they are created in an STA
+ RECT pos3={300,0,600,200};
+ AWindow win3("DnD starting in OLE STA", threadIdMTA, pos3, false, true);
+
+ RECT pos4={ 300, 205, 600, 405};
+ AWindow win24("DnD starting in Ole MTA", threadIdMTA, pos4, true, true);
+
+ MSG msg;
+ while( GetMessageA(&msg, (HWND)NULL, 0, 0) )
+ {
+ TranslateMessage( &msg);
+ DispatchMessageA( &msg);
+ }
+
+ // Shut down the MTA thread
+ PostThreadMessageA( threadIdMTA, WM_QUIT, 0, 0);
+ WaitForSingleObject(hMTAThread, INFINITE);
+ CloseHandle(hMTAThread);
+
+ return S_OK;
+}
+
+extern Reference<XMultiServiceFactory> MultiServiceFactory;
+DWORD WINAPI MTAFunc( void* threadData)
+{
+ HRESULT hr= CoInitializeEx( NULL, COINIT_MULTITHREADED);
+ ATLASSERT( FAILED(hr) );
+ MSG msg;
+ // force the creation of a message queue
+ PeekMessageA(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
+ SetEvent( *(HANDLE*)threadData );
+
+ RECT pos={0, 406, 300, 605};
+ AWindow win("DnD, full MTA", GetCurrentThreadId(), pos, false, true);
+
+ while( GetMessageA(&msg, (HWND)NULL, 0, 0) )
+ {
+ switch( msg.message)
+ {
+ case WM_SOURCE_INIT:
+ {
+ InitializationData* pData= (InitializationData*)msg.wParam;
+ Any any;
+ any <<= (sal_uInt32) pData->hWnd;
+ pData->xInit->initialize( Sequence<Any>( &any, 1));
+
+ CoTaskMemFree( pData);
+ break;
+ }
+ case WM_SOURCE_STARTDRAG:
+ {
+ // wParam contains necessary data
+ StartDragData* pData= (StartDragData*)msg.wParam;
+ Sequence<DataFlavor> seq= pData->transferable->getTransferDataFlavors();
+ // have a look what flavours are supported
+ for( int i=0; i<seq.(); i++)
+ {
+ DataFlavor d= seq[i];
+ }
+ pData->source->startDrag( DragGestureEvent(),
+ ACTION_LINK|ACTION_MOVE|ACTION_COPY,
+ 0,
+ 0,
+ pData->transferable,
+ Reference<XDragSourceListener>( static_cast<XDragSourceListener*>
+ ( new DragSourceListener())));
+ CoTaskMemFree( pData);
+ break;
+ }
+
+ } // end switch
+
+ TranslateMessage( &msg);
+ DispatchMessageA( &msg);
+ }
+
+ CoUninitialize();
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/win/dnd/makefile.mk b/vcl/workben/win/dnd/makefile.mk
new file mode 100644
index 000000000..e0d438418
--- /dev/null
+++ b/vcl/workben/win/dnd/makefile.mk
@@ -0,0 +1,70 @@
+#
+# 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 .
+#
+
+PRJ=..$/..$/..$/
+
+PRJNAME=dtrans
+TARGET=dndTest
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# --- Files ---
+
+CFLAGS+= -D_WIN32_DCOM
+
+INCPRE+= -I$(ATL_INCLUDE)
+
+OBJFILES= $(OBJ)$/dndTest.obj \
+ $(OBJ)$/atlwindow.obj \
+ $(OBJ)$/targetlistener.obj \
+ $(OBJ)$/sourcelistener.obj \
+ $(OBJ)$/dataobject.obj
+
+APP1NOSAL=TRUE
+
+APP1TARGET= $(TARGET)
+APP1OBJS=$(OBJFILES)
+
+APP1STDLIBS= \
+ $(SALLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(UWINAPILIB) \
+ $(USER32LIB) \
+ $(OLE32LIB) \
+ comsupp.lib \
+ $(OLEAUT32LIB) \
+ $(GDI32LIB) \
+ $(UUIDLIB)
+
+APP1LIBS= \
+ $(SLB)$/dtobjfact.lib \
+ $(SLB)$/dtutils.lib
+
+APP1DEF= $(MISC)\$(APP1TARGET).def
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+
diff --git a/vcl/workben/win/dnd/sourcelistener.cxx b/vcl/workben/win/dnd/sourcelistener.cxx
new file mode 100644
index 000000000..aa3366e79
--- /dev/null
+++ b/vcl/workben/win/dnd/sourcelistener.cxx
@@ -0,0 +1,59 @@
+/* -*- 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 "sourcelistener.hxx"
+
+DragSourceListener::DragSourceListener()
+{
+}
+DragSourceListener::~DragSourceListener()
+{
+}
+
+void SAL_CALL DragSourceListener::disposing( const EventObject& Source )
+ throw(RuntimeException)
+{
+}
+
+void SAL_CALL DragSourceListener::dragDropEnd( const DragSourceDropEvent& dsde )
+ throw(RuntimeException)
+{
+}
+
+void SAL_CALL DragSourceListener::dragEnter( const DragSourceDragEvent& dsde )
+ throw(RuntimeException)
+{
+}
+
+void SAL_CALL DragSourceListener::dragExit( const DragSourceEvent& dse )
+ throw(RuntimeException)
+{
+}
+
+void SAL_CALL DragSourceListener::dragOver( const DragSourceDragEvent& dsde )
+ throw(RuntimeException)
+{
+}
+
+void SAL_CALL DragSourceListener::dropActionChanged( const DragSourceDragEvent& dsde )
+ throw(RuntimeException)
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/win/dnd/sourcelistener.hxx b/vcl/workben/win/dnd/sourcelistener.hxx
new file mode 100644
index 000000000..0fc051399
--- /dev/null
+++ b/vcl/workben/win/dnd/sourcelistener.hxx
@@ -0,0 +1,56 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/datatransfer/dnd/XDragSourceListener.hpp>
+#include <com/sun/star/datatransfer/dnd/DragSourceDropEvent.hpp>
+#include <com/sun/star/datatransfer/dnd/DragSourceDragEvent.hpp>
+
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::dnd;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+class DragSourceListener: public WeakImplHelper<XDragSourceListener>
+{
+ // this is a window where dropped data are shown as text (only text)
+public:
+ DragSourceListener( );
+ ~DragSourceListener();
+
+ virtual void SAL_CALL disposing( const EventObject& Source )
+ throw(RuntimeException);
+
+ virtual void SAL_CALL dragDropEnd( const DragSourceDropEvent& dsde )
+ throw(RuntimeException);
+ virtual void SAL_CALL dragEnter( const DragSourceDragEvent& dsde )
+ throw(RuntimeException);
+ virtual void SAL_CALL dragExit( const DragSourceEvent& dse )
+ throw(RuntimeException);
+ virtual void SAL_CALL dragOver( const DragSourceDragEvent& dsde )
+ throw(RuntimeException);
+ virtual void SAL_CALL dropActionChanged( const DragSourceDragEvent& dsde )
+ throw(RuntimeException);
+
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/win/dnd/targetlistener.cxx b/vcl/workben/win/dnd/targetlistener.cxx
new file mode 100644
index 000000000..0a93d3945
--- /dev/null
+++ b/vcl/workben/win/dnd/targetlistener.cxx
@@ -0,0 +1,78 @@
+/* -*- 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 "targetlistener.hxx"
+#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
+#include <com/sun/star/datatransfer/DataFlavor.hpp>
+
+using namespace com::sun::star::datatransfer::dnd::DNDConstants;
+using namespace com::sun::star::datatransfer;
+
+DropTargetListener::DropTargetListener(HWND hEdit):m_hEdit( hEdit)
+{
+}
+DropTargetListener::~DropTargetListener()
+{
+}
+
+void SAL_CALL DropTargetListener::disposing( const EventObject& Source )
+ throw(RuntimeException)
+{
+
+}
+
+void SAL_CALL DropTargetListener::drop( const DropTargetDropEvent& e )
+ throw(RuntimeException)
+{
+ e.Context->rejectDrop();
+
+ DataFlavor flavor( OUString(OUString("text/plain;charset=windows-1252")),
+ OUString(L"Text plain"), cppu::UnoType<Sequence<sal_Int8>>::get() );
+
+ Any anyData= e.Transferable->getTransferData( flavor);
+ Sequence<sal_Int8> seq= *( Sequence<sal_Int8>*)anyData.getValue();
+ SendMessage( m_hEdit, WM_SETTEXT, 0, (LPARAM) seq.getConstArray() );
+}
+
+void SAL_CALL DropTargetListener::dragEnter( const DropTargetDragEnterEvent& dtde )
+ throw(RuntimeException)
+{
+ //If one drags something that is not moveable
+ if( !(dtde.SourceActions & dtde.DropAction) )
+ dtde.Context->acceptDrag( ACTION_COPY);
+}
+
+void SAL_CALL DropTargetListener::dragExit( const DropTargetEvent& dte )
+ throw(RuntimeException)
+{
+}
+
+void SAL_CALL DropTargetListener::dragOver( const DropTargetDragEvent& dtde )
+ throw(RuntimeException)
+{
+ if( !(dtde.SourceActions & dtde.DropAction) )
+ dtde.Context->acceptDrag( ACTION_COPY);
+}
+
+void SAL_CALL DropTargetListener::dropActionChanged( const DropTargetDragEvent& dtde )
+ throw(RuntimeException)
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/win/dnd/targetlistener.hxx b/vcl/workben/win/dnd/targetlistener.hxx
new file mode 100644
index 000000000..f42fac33a
--- /dev/null
+++ b/vcl/workben/win/dnd/targetlistener.hxx
@@ -0,0 +1,64 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#if defined _MSC_VER
+#pragma warning(push,1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
+#include <com/sun/star/datatransfer/dnd/DropTargetDropEvent.hpp>
+#include <com/sun/star/datatransfer/dnd/DropTargetDragEvent.hpp>
+#include <com/sun/star/datatransfer/dnd/DropTargetDragEnterEvent.hpp>
+
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::dnd;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+class DropTargetListener: public WeakImplHelper<XDropTargetListener>
+{
+ // this is a window where dropped data are shown as text (only text)
+ HWND m_hEdit;
+public:
+ explicit DropTargetListener(HWND hEdit);
+ ~DropTargetListener();
+
+ virtual void SAL_CALL disposing( const EventObject& Source )
+ throw(RuntimeException);
+
+ virtual void SAL_CALL drop( const DropTargetDropEvent& dtde )
+ throw(RuntimeException);
+ virtual void SAL_CALL dragEnter( const DropTargetDragEnterEvent& dtde )
+ throw(RuntimeException);
+ virtual void SAL_CALL dragExit( const DropTargetEvent& dte )
+ throw(RuntimeException);
+ virtual void SAL_CALL dragOver( const DropTargetDragEvent& dtde )
+ throw(RuntimeException);
+ virtual void SAL_CALL dropActionChanged( const DropTargetDragEvent& dtde )
+ throw(RuntimeException);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/win/dnd/transferable.cxx b/vcl/workben/win/dnd/transferable.cxx
new file mode 100644
index 000000000..924c03176
--- /dev/null
+++ b/vcl/workben/win/dnd/transferable.cxx
@@ -0,0 +1,105 @@
+/* -*- 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 "transferable.hxx"
+
+// ctor
+
+CTransferable::CTransferable( wchar_t* dataString ) :
+ m_seqDFlv( 1 ),
+ m_Data( dataString )
+{
+ DataFlavor df;
+
+ /*
+ df.MimeType = L"text/plain; charset=unicode";
+ df.DataType = cppu::UnoType<OUString>::get();
+
+ m_seqDFlv[0] = df;
+ */
+
+ //df.MimeType = L"text/plain; charset=windows1252";
+ df.MimeType = L"text/plain";
+ df.DataType = cppu::UnoType<Sequence< sal_Int8 >>::get();
+
+ m_seqDFlv[0] = df;
+}
+
+// getTransferData
+
+Any SAL_CALL CTransferable::getTransferData( const DataFlavor& aFlavor )
+ throw(UnsupportedFlavorException, IOException, RuntimeException)
+{
+ Any anyData;
+
+ /*if ( aFlavor == m_seqDFlv[0] )
+ {
+ anyData = makeAny( m_Data );
+ }
+ else*/ if ( aFlavor == m_seqDFlv[0] )
+ {
+ OString aStr( m_Data.getStr( ), m_Data.getLength( ), 1252 );
+ Sequence< sal_Int8 > sOfChars( aStr.getLength( ) );
+ sal_Int32 lenStr = aStr.getLength( );
+
+ for ( sal_Int32 i = 0; i < lenStr; ++i )
+ sOfChars[i] = aStr[i];
+
+ anyData = makeAny( sOfChars );
+ }
+
+ return anyData;
+}
+
+// getTransferDataFlavors
+
+Sequence< DataFlavor > SAL_CALL CTransferable::getTransferDataFlavors( )
+ throw(RuntimeException)
+{
+ return m_seqDFlv;
+}
+
+// isDataFlavorSupported
+
+sal_Bool SAL_CALL CTransferable::isDataFlavorSupported( const DataFlavor& aFlavor )
+ throw(RuntimeException)
+{
+ sal_Int32 nLength = m_seqDFlv.getLength( );
+ sal_Bool bRet = sal_False;
+
+ for ( sal_Int32 i = 0; i < nLength; ++i )
+ {
+ if ( m_seqDFlv[i] == aFlavor )
+ {
+ bRet = sal_True;
+ break;
+ }
+ }
+
+ return bRet;
+}
+
+// lostOwnership
+
+void SAL_CALL CTransferable::lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans )
+ throw(RuntimeException)
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/win/dnd/transferable.hxx b/vcl/workben/win/dnd/transferable.hxx
new file mode 100644
index 000000000..c1606cab8
--- /dev/null
+++ b/vcl/workben/win/dnd/transferable.hxx
@@ -0,0 +1,88 @@
+/* -*- 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 .
+ */
+#pragma once
+
+#include <cppuhelper/servicefactory.hxx>
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <cppuhelper/implbase.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <osl/diagnose.h>
+
+#include <stdio.h>
+#if defined _MSC_VER
+#pragma warning(push,1)
+#endif
+#include <windows.h>
+#include <objbase.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include <memory>
+
+#include <process.h>
+
+#include "../../source/win32/ImplHelper.hxx"
+
+// my defines
+
+#define TEST_CLIPBOARD
+#define RDB_SYSPATH "d:\\projects\\src616\\dtrans\\wntmsci7\\bin\\applicat.rdb"
+#define WINCLIPBOARD_SERVICE_NAME L"com.sun.star.datatransfer.clipboard.SystemClipboard"
+#define WRITE_CB
+#define EVT_MANUAL_RESET TRUE
+#define EVT_INIT_NONSIGNALED FALSE
+#define EVT_NONAME ""
+
+// namespaces
+
+using namespace ::cppu;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::clipboard;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+
+class CTransferable : public WeakImplHelper< XClipboardOwner, XTransferable >
+{
+public:
+ CTransferable( ){};
+ explicit CTransferable( wchar_t* dataString);
+
+ // XTransferable
+
+ virtual Any SAL_CALL getTransferData( const DataFlavor& aFlavor ) throw(UnsupportedFlavorException, IOException, RuntimeException);
+ virtual Sequence< DataFlavor > SAL_CALL getTransferDataFlavors( ) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL isDataFlavorSupported( const DataFlavor& aFlavor ) throw(RuntimeException);
+
+ // XClipboardOwner
+
+ virtual void SAL_CALL lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans ) throw(RuntimeException);
+
+private:
+ Sequence< DataFlavor > m_seqDFlv;
+ OUString m_Data;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/win/dtrans/XTDo.cxx b/vcl/workben/win/dtrans/XTDo.cxx
new file mode 100644
index 000000000..f8da707d9
--- /dev/null
+++ b/vcl/workben/win/dtrans/XTDo.cxx
@@ -0,0 +1,358 @@
+/* -*- 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 <osl/diagnose.h>
+
+#include "../DTransHelper.hxx"
+
+#include "XTDo.hxx"
+
+#if defined _MSC_VER
+#pragma warning(push,1)
+#endif
+#include <windows.h>
+#include <ole2.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <memory>
+
+using namespace ::std;
+
+// OTWrapperDataObject
+
+/*
+ in the constructor we enumerate all formats offered by the transferable
+ and convert the formats into formatetc structures
+ if the transferable supports text in different charsets we use either
+ the charset equal to the charset of the current thread or an arbitrary
+ charset supported by the transferable and the system
+ if the transferable supports only unicodetext we offer in addition to
+ this text in the charset of the current thread
+ in order to allow the consumer of the clipboard to query for the charset
+ of the text in the clipboard we offer a CF_LOCALE
+*/
+CXTDataObject::CXTDataObject( ) :
+ m_nRefCnt( 0 )
+{
+
+}
+
+// IUnknown->QueryInterface
+
+STDMETHODIMP CXTDataObject::QueryInterface( REFIID iid, LPVOID* ppvObject )
+{
+ OSL_ASSERT( NULL != ppvObject );
+
+ if ( NULL == ppvObject )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_NOINTERFACE;
+
+ *ppvObject = NULL;
+
+ if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IDataObject ) == iid ) )
+ {
+ *ppvObject = static_cast< IUnknown* >( this );
+ ( (LPUNKNOWN)*ppvObject )->AddRef( );
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+// IUnknown->AddRef
+
+STDMETHODIMP_(ULONG) CXTDataObject::AddRef( )
+{
+ return static_cast< ULONG >( InterlockedIncrement( &m_nRefCnt ) );
+}
+
+// IUnknown->Release
+
+STDMETHODIMP_(ULONG) CXTDataObject::Release( )
+{
+ // we need a helper variable because it's
+ // not allowed to access a member variable
+ // after an object is destroyed
+ ULONG nRefCnt = static_cast< ULONG >( InterlockedDecrement( &m_nRefCnt ) );
+
+ if ( 0 == nRefCnt )
+ {
+ delete this;
+ }
+
+ return nRefCnt;
+}
+
+/*------------------------------------------------------------------------
+
+ IDataObject->GetData
+ we deliver data only into global memory
+
+ algo:
+ 1. convert the given formatect struct into a valid dataflavor
+ 2. if the transferable directly supports the requested format
+ 2.1. if text data requested add a trailing '\0' in order to prevent
+ problems (windows needs '\0' terminated strings
+ 2.2. we expect unicode data as Sequence< sal_Unicode > and all other
+ text and raw data as Sequence< sal_Int8 >
+
+------------------------------------------------------------------------*/
+
+STDMETHODIMP CXTDataObject::GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium )
+{
+ if ( ( NULL == pFormatetc ) || ( NULL == pmedium ) )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_FAIL;
+
+ if ( CF_TEXT == pFormatetc->cfFormat )
+ {
+ CHGlobalHelper hGlobHlp( TRUE );
+
+ char pBuff[] = "Test OleClipboard";
+ hGlobHlp.Write( pBuff, sizeof( pBuff ), NULL );
+
+ pmedium->tymed = TYMED_HGLOBAL;
+ pmedium->hGlobal = hGlobHlp.GetHGlobal( );
+ pmedium->pUnkForRelease = NULL;
+
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+// IDataObject->EnumFormatEtc
+
+STDMETHODIMP CXTDataObject::EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc )
+{
+ if ( ( NULL == ppenumFormatetc ) || ( DATADIR_SET == dwDirection ) )
+ return E_INVALIDARG;
+
+ *ppenumFormatetc = NULL;
+
+ HRESULT hr = E_FAIL;
+
+ if ( DATADIR_GET == dwDirection )
+ {
+ *ppenumFormatetc = new CEnumFormatEtc( this );
+ static_cast< LPUNKNOWN >( *ppenumFormatetc )->AddRef( );
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+// IDataObject->QueryGetData
+
+STDMETHODIMP CXTDataObject::QueryGetData( LPFORMATETC pFormatetc )
+{
+ return E_NOTIMPL;
+}
+
+// IDataObject->GetDataHere
+
+STDMETHODIMP CXTDataObject::GetDataHere( LPFORMATETC, LPSTGMEDIUM )
+{
+ return E_NOTIMPL;
+}
+
+// IDataObject->GetCanonicalFormatEtc
+
+STDMETHODIMP CXTDataObject::GetCanonicalFormatEtc( LPFORMATETC, LPFORMATETC )
+{
+ return E_NOTIMPL;
+}
+
+// IDataObject->SetData
+
+STDMETHODIMP CXTDataObject::SetData( LPFORMATETC, LPSTGMEDIUM, BOOL )
+{
+ return E_NOTIMPL;
+}
+
+// IDataObject->DAdvise
+
+STDMETHODIMP CXTDataObject::DAdvise( LPFORMATETC, DWORD, LPADVISESINK, DWORD * )
+{
+ return E_NOTIMPL;
+}
+
+// IDataObject->DUnadvise
+
+STDMETHODIMP CXTDataObject::DUnadvise( DWORD )
+{
+ return E_NOTIMPL;
+}
+
+// IDataObject->EnumDAdvise
+
+STDMETHODIMP CXTDataObject::EnumDAdvise( LPENUMSTATDATA * )
+{
+ return E_NOTIMPL;
+}
+
+CXTDataObject::operator IDataObject*( )
+{
+ return static_cast< IDataObject* >( this );
+}
+
+CEnumFormatEtc::CEnumFormatEtc( LPUNKNOWN pUnkDataObj ) :
+ m_nRefCnt( 0 ),
+ m_pUnkDataObj( pUnkDataObj ),
+ m_nCurrPos( 0 )
+{
+}
+
+// IUnknown->QueryInterface
+
+STDMETHODIMP CEnumFormatEtc::QueryInterface( REFIID iid, LPVOID* ppvObject )
+{
+ if ( NULL == ppvObject )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_NOINTERFACE;
+
+ *ppvObject = NULL;
+
+ if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IEnumFORMATETC ) == iid ) )
+ {
+ *ppvObject = static_cast< IUnknown* >( this );
+ static_cast< LPUNKNOWN >( *ppvObject )->AddRef( );
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+// IUnknown->AddRef
+
+STDMETHODIMP_(ULONG) CEnumFormatEtc::AddRef( )
+{
+ // keep the dataobject alive
+ m_pUnkDataObj->AddRef( );
+ return InterlockedIncrement( &m_nRefCnt );
+}
+
+// IUnknown->Release
+
+STDMETHODIMP_(ULONG) CEnumFormatEtc::Release( )
+{
+ // release the outer dataobject
+ m_pUnkDataObj->Release( );
+
+ // we need a helper variable because it's
+ // not allowed to access a member variable
+ // after an object is destroyed
+ ULONG nRefCnt = InterlockedDecrement( &m_nRefCnt );
+ if ( 0 == nRefCnt )
+ delete this;
+
+ return nRefCnt;
+}
+
+// IEnumFORMATETC->Next
+
+STDMETHODIMP CEnumFormatEtc::Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched )
+{
+ if ( ( 0 != celt ) && ( NULL == rgelt ) )
+ return E_INVALIDARG;
+
+ ULONG ulFetched = 0;
+ ULONG ulToFetch = celt;
+ HRESULT hr = S_FALSE;
+
+ while( m_nCurrPos < 1 )
+ {
+ rgelt->cfFormat = CF_TEXT;
+ rgelt->ptd = NULL;
+ rgelt->dwAspect = DVASPECT_CONTENT;
+ rgelt->lindex = -1;
+ rgelt->tymed = TYMED_HGLOBAL;
+
+ ++m_nCurrPos;
+ ++rgelt;
+ --ulToFetch;
+ ++ulFetched;
+ }
+
+ if ( ulFetched == celt )
+ hr = S_OK;
+
+ if ( NULL != pceltFetched )
+ {
+ *pceltFetched = ulFetched;
+ }
+
+ return hr;
+}
+
+// IEnumFORMATETC->Skip
+
+STDMETHODIMP CEnumFormatEtc::Skip( ULONG celt )
+{
+ HRESULT hr = S_FALSE;
+
+ /*
+ if ( ( m_nCurrPos + celt ) < m_nClipFormats )
+ {
+ m_nCurrPos += celt;
+ hr = S_OK;
+ }
+ */
+
+ return hr;
+}
+
+// IEnumFORMATETC->Reset
+
+STDMETHODIMP CEnumFormatEtc::Reset( )
+{
+ m_nCurrPos = 0;
+ return S_OK;
+}
+
+// IEnumFORMATETC->Clone
+
+STDMETHODIMP CEnumFormatEtc::Clone( IEnumFORMATETC** ppenum )
+{
+ OSL_ASSERT( NULL != ppenum );
+
+ if ( NULL == ppenum )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_FAIL;
+
+ *ppenum = NULL;
+
+ CEnumFormatEtc* pCEnumFEtc = new CEnumFormatEtc( m_pUnkDataObj );
+ if ( NULL != pCEnumFEtc )
+ {
+ pCEnumFEtc->m_nCurrPos = m_nCurrPos;
+ *ppenum = static_cast< IEnumFORMATETC* >( pCEnumFEtc );
+ static_cast< LPUNKNOWN >( *ppenum )->AddRef( );
+ hr = NOERROR;
+ }
+
+ return hr;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/win/dtrans/XTDo.hxx b/vcl/workben/win/dtrans/XTDo.hxx
new file mode 100644
index 000000000..095987a49
--- /dev/null
+++ b/vcl/workben/win/dtrans/XTDo.hxx
@@ -0,0 +1,111 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#if defined _MSC_VER
+#pragma warning(push,1)
+#endif
+#include <windows.h>
+#include <ole2.h>
+#include <objidl.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include <vector>
+
+class EnumFormatEtc;
+
+/*--------------------------------------------------------------------------
+ - the function principle of the windows clipboard:
+ a data provider offers all formats he can deliver on the clipboard
+ a clipboard client ask for the available formats on the clipboard
+ and decides if there is a format he can use
+ if there is one, he requests the data in this format
+
+ - This class inherits from IDataObject and so can be placed on the
+ OleClipboard. The class wraps a transferable object which is the
+ original DataSource
+ - DataFlavors offered by this transferable will be translated into
+ appropriate clipboard formats
+ - if the transferable contains text data always text and unicodetext
+ will be offered or vice versa
+ - text data will be automatically converted between text and unicode text
+ - although the transferable may support text in different charsets
+ (codepages) only text in one codepage can be offered by the clipboard
+
+----------------------------------------------------------------------------*/
+
+class CXTDataObject : public IDataObject
+{
+public:
+ CXTDataObject( );
+
+ // ole interface implementation
+
+ //IUnknown interface methods
+ STDMETHODIMP QueryInterface(REFIID iid, LPVOID* ppvObject);
+ STDMETHODIMP_( ULONG ) AddRef( );
+ STDMETHODIMP_( ULONG ) Release( );
+
+ // IDataObject interface methods
+ STDMETHODIMP GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
+ STDMETHODIMP GetDataHere( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
+ STDMETHODIMP QueryGetData( LPFORMATETC pFormatetc );
+ STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pFormatectIn, LPFORMATETC pFormatetcOut );
+ STDMETHODIMP SetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease );
+ STDMETHODIMP EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc );
+ STDMETHODIMP DAdvise( LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD* pdwConnection );
+ STDMETHODIMP DUnadvise( DWORD dwConnection );
+ STDMETHODIMP EnumDAdvise( LPENUMSTATDATA* ppenumAdvise );
+
+ operator IDataObject*( );
+
+private:
+
+private:
+ LONG m_nRefCnt;
+};
+
+class CEnumFormatEtc : public IEnumFORMATETC
+{
+public:
+ explicit CEnumFormatEtc( LPUNKNOWN pUnkDataObj );
+
+ // IUnknown
+ STDMETHODIMP QueryInterface( REFIID iid, LPVOID* ppvObject );
+ STDMETHODIMP_( ULONG ) AddRef( );
+ STDMETHODIMP_( ULONG ) Release( );
+
+ //IEnumFORMATETC
+ STDMETHODIMP Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched );
+ STDMETHODIMP Skip( ULONG celt );
+ STDMETHODIMP Reset( );
+ STDMETHODIMP Clone( IEnumFORMATETC** ppenum );
+
+private:
+ LONG m_nRefCnt;
+ LPUNKNOWN m_pUnkDataObj;
+ ULONG m_nCurrPos;
+};
+
+typedef CEnumFormatEtc *PCEnumFormatEtc;
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/win/dtrans/makefile.mk b/vcl/workben/win/dtrans/makefile.mk
new file mode 100644
index 000000000..3c82289f8
--- /dev/null
+++ b/vcl/workben/win/dtrans/makefile.mk
@@ -0,0 +1,81 @@
+#
+# 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 .
+#
+
+PRJ=..$/..$/..
+
+PRJNAME= dtrans
+TARGET= testwincb
+TARGET1= testmshl
+LIBTARGET= NO
+TARGETTYPE= CUI
+USE_BOUNDCHK=
+TESTCB=TRUE
+
+.IF "$(USE_BOUNDCHK)"=="TR"
+bndchk=tr
+stoponerror=tr
+.ENDIF
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+.IF "$(TESTCB)"=="TRUE"
+
+CFLAGS+=-D_WIN32_DCOM -EHsc -Ob0
+
+# --- Files --------------------------------------------------------
+
+OBJFILES= $(OBJ)$/test_wincb.obj
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJ)$/test_wincb.obj
+
+APP1STDLIBS= $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(USER32LIB) \
+ $(OLE32LIB)\
+ $(COMDLG32LIB)
+
+APP1LIBS= $(SLB)$/dtutils.lib
+
+APP1NOSAL= TRUE
+
+.ENDIF
+
+.IF "$(TESTCB)"==""
+
+CFLAGS+=/D_WIN32_DCOM /EHsc /Ob0
+
+OBJFILES= $(OBJ)$/testmarshal.obj
+APP1TARGET= $(TARGET1)
+APP1OBJS= $(OBJ)$/testmarshal.obj
+
+APP1STDLIBS= $(SALLIB)\
+ $(USER32LIB)\
+ $(OLE32LIB)\
+ comsupp.lib\
+ $(OLEAUT32LIB)
+
+APP1LIBS=
+APP1NOSAL= TRUE
+
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : target.mk
diff --git a/vcl/workben/win/dtrans/test_wincb.cxx b/vcl/workben/win/dtrans/test_wincb.cxx
new file mode 100644
index 000000000..96839e22a
--- /dev/null
+++ b/vcl/workben/win/dtrans/test_wincb.cxx
@@ -0,0 +1,287 @@
+/* -*- 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 "../misc/ImplHelper.hxx"
+
+#include <cppuhelper/servicefactory.hxx>
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
+#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <cppuhelper/implbase.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <osl/diagnose.h>
+
+#include <stdio.h>
+#if defined _MSC_VER
+#pragma warning(push,1)
+#endif
+#include <windows.h>
+#include <objbase.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include <memory>
+
+#include <process.h>
+
+// my defines
+
+#define TEST_CLIPBOARD
+#define RDB_SYSPATH "d:\\projects\\src623\\dtrans\\wntmsci7\\bin\\applicat.rdb"
+#define WINCLIPBOARD_SERVICE_NAME L"com.sun.star.datatransfer.clipboard.SystemClipboard"
+#define WRITE_CB
+#define EVT_MANUAL_RESET TRUE
+#define EVT_INIT_NONSIGNALED FALSE
+#define EVT_NONAME ""
+
+// namespaces
+
+using namespace ::std;
+using namespace ::cppu;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::clipboard;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+
+// globales
+
+Reference< XTransferable > rXTransfRead;
+HANDLE g_hEvtThreadWakeup;
+
+class CClipboardListener : public WeakImplHelper < XClipboardListener >
+{
+public:
+ ~CClipboardListener( );
+
+ // XClipboardListener
+
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw(RuntimeException);
+ virtual void SAL_CALL changedContents( const ClipboardEvent& event ) throw( RuntimeException );
+};
+
+CClipboardListener::~CClipboardListener( )
+{
+}
+
+void SAL_CALL CClipboardListener::disposing( const EventObject& Source ) throw(RuntimeException)
+{
+
+}
+
+void SAL_CALL CClipboardListener::changedContents( const ClipboardEvent& event ) throw( RuntimeException )
+{
+ //MessageBox( NULL, TEXT("Clipboard content changed"), TEXT("Info"), MB_OK | MB_ICONINFORMATION );
+}
+
+class CTransferable : public WeakImplHelper< XClipboardOwner, XTransferable >
+{
+public:
+ CTransferable( );
+
+ // XTransferable
+
+ virtual Any SAL_CALL getTransferData( const DataFlavor& aFlavor )
+ throw(UnsupportedFlavorException, IOException, RuntimeException);
+
+ virtual Sequence< DataFlavor > SAL_CALL getTransferDataFlavors( ) throw(RuntimeException);
+
+ virtual sal_Bool SAL_CALL isDataFlavorSupported( const DataFlavor& aFlavor ) throw(RuntimeException);
+
+ // XClipboardOwner
+
+ virtual void SAL_CALL lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans )
+ throw(RuntimeException);
+
+private:
+ Sequence< DataFlavor > m_FlavorList;
+ OUString m_Data;
+};
+
+// ctor
+
+CTransferable::CTransferable( ) :
+ m_FlavorList( 1 ),
+ m_Data( OUString("I bought a new bike!") )
+{
+ DataFlavor df;
+
+ //df.MimeType = L"text/plain;charset=utf-16";
+ //df.DataType = cppu::UnoType<OUString>::get();
+
+ df.MimeType = L"text/plain;charset=Windows1252";
+ df.DataType = cppu::UnoType<Sequence< sal_Int8 >>::get();
+
+ m_FlavorList[0] = df;
+}
+
+// getTransferData
+
+Any SAL_CALL CTransferable::getTransferData( const DataFlavor& aFlavor )
+ throw(UnsupportedFlavorException, IOException, RuntimeException)
+{
+ Any anyData;
+
+ /*
+ if ( aFlavor.MimeType == m_FlavorList[0].MimeType )
+ anyData = makeAny( m_Data );
+ */
+ if ( aFlavor.MimeType.equalsIgnoreCase( m_FlavorList[0].MimeType ) )
+ {
+ OString text(
+ m_Data.getStr( ),
+ m_Data.getLength( ),
+ RTL_TEXTENCODING_ASCII_US );
+
+ Sequence< sal_Int8 > textStream( text.getLength( ) + 1 );
+
+ memcpy( textStream.getArray( ), text.getStr( ), textStream.getLength( ) );
+
+ anyData = makeAny( textStream );
+ }
+ else
+ throw UnsupportedFlavorException( );
+
+ return anyData;
+}
+
+// getTransferDataFlavors
+
+Sequence< DataFlavor > SAL_CALL CTransferable::getTransferDataFlavors( )
+ throw(RuntimeException)
+{
+ return m_FlavorList;
+}
+
+// isDataFlavorSupported
+
+sal_Bool SAL_CALL CTransferable::isDataFlavorSupported( const DataFlavor& aFlavor )
+ throw(RuntimeException)
+{
+ sal_Int32 nLength = m_FlavorList.getLength( );
+
+ for ( sal_Int32 i = 0; i < nLength; ++i )
+ if ( m_FlavorList[i].MimeType == aFlavor.MimeType )
+ return sal_True;
+
+ return sal_False;
+}
+
+// lostOwnership
+
+void SAL_CALL CTransferable::lostOwnership(
+ const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans )
+ throw(RuntimeException)
+{
+ //MessageBox( NULL, TEXT("No longer clipboard owner"), TEXT("Info"), MB_OK | MB_ICONINFORMATION );
+}
+
+// main
+
+int SAL_CALL main( int nArgc, char* Argv[] )
+{
+ // create a multi-threaded apartment; we can test only
+ // with a multithreaded apartment because for a single
+ // threaded apartment we need a message loop to deliver
+ // messages to our XTDataObject
+ //HRESULT hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
+ (void)CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
+
+ char buff[6];
+
+ LCID lcid = MAKELCID( MAKELANGID( LANG_GERMAN, SUBLANG_GERMAN ), SORT_DEFAULT );
+
+ BOOL bValid = IsValidLocale( lcid, LCID_SUPPORTED );
+ GetLocaleInfoA( lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof( buff ) );
+
+ // get the global service-manager
+
+ Reference< XMultiServiceFactory > g_xFactory( createRegistryServiceFactory( RDB_SYSPATH ) );
+
+ // Print a message if an error occurred.
+ if ( !g_xFactory.is( ) )
+ {
+ OSL_FAIL("Can't create RegistryServiceFactory");
+ return(-1);
+ }
+
+ // try to get an Interface to a XFilePicker Service
+
+ Reference< XTransferable > rXTransf( static_cast< XTransferable* >( new CTransferable ) );
+
+ Reference< XClipboard >xClipboard( g_xFactory->createInstance( WINCLIPBOARD_SERVICE_NAME ), UNO_QUERY );
+ if ( !xClipboard.is( ) )
+ {
+ OSL_FAIL( "Error creating Clipboard Service" );
+ return(-1);
+ }
+
+ Reference< XClipboardNotifier > xClipNotifier( xClipboard, UNO_QUERY );
+ Reference< XClipboardListener > rXClipListener( static_cast< XClipboardListener* >( new CClipboardListener() ) );
+ xClipNotifier->addClipboardListener( rXClipListener );
+
+ MessageBox( NULL, TEXT("Go"), TEXT("INFO"), MB_OK|MB_ICONINFORMATION);
+
+ // set new clipboard content
+ xClipboard->setContents( rXTransf, Reference< XClipboardOwner >( rXTransf, UNO_QUERY ) );
+
+ /*
+ MessageBox( NULL, TEXT("Clear content"), TEXT("INFO"), MB_OK|MB_ICONINFORMATION);
+
+ Reference< XClipboardOwner > rXClipOwner;
+ Reference< XTransferable > rXEmptyTransf;
+ xClipboard->setContents( rXEmptyTransf, rXClipOwner );
+ */
+
+ MessageBox( NULL, TEXT("Stop"), TEXT("INFO"), MB_OK|MB_ICONINFORMATION);
+
+ // flush the clipboard content
+ Reference< XFlushableClipboard > rXFlushableClip( xClipboard, UNO_QUERY );
+ rXFlushableClip->flushClipboard( );
+ rXFlushableClip.clear();
+
+ xClipNotifier->removeClipboardListener( rXClipListener );
+ rXClipListener.clear();
+ xClipNotifier.clear();
+
+ // shutdown the service manager
+
+ // Cast factory to XComponent
+ Reference< XComponent > xComponent( g_xFactory, UNO_QUERY );
+
+ if ( !xComponent.is() )
+ OSL_FAIL("Error shutting down");
+
+ // Dispose and clear factory
+ xComponent->dispose();
+ xComponent.clear();
+
+ g_xFactory.clear();
+
+ CoUninitialize( );
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/win/dtrans/testmarshal.cxx b/vcl/workben/win/dtrans/testmarshal.cxx
new file mode 100644
index 000000000..8ef53c0f4
--- /dev/null
+++ b/vcl/workben/win/dtrans/testmarshal.cxx
@@ -0,0 +1,212 @@
+/* -*- 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/ustring.hxx>
+#include <sal/types.h>
+
+#include <stdio.h>
+#if defined _MSC_VER
+#pragma warning(push,1)
+#endif
+#include <windows.h>
+#include <objbase.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include <memory>
+
+#include <process.h>
+#include "XTDo.hxx"
+
+// my defines
+
+#define WRITE_CB
+#define EVT_MANUAL_RESET TRUE
+#define EVT_INIT_NONSIGNALED FALSE
+#define EVT_NONAME ""
+#define WAIT_MSGLOOP
+#define RAW_MARSHALING
+
+// namespaces
+
+using namespace ::std;
+
+// globales
+
+HANDLE g_hEvtThreadWakeup;
+
+#ifdef RAW_MARSHALING
+ HGLOBAL g_hGlob;
+#else
+ IStream* g_pStm;
+#endif
+
+// a thread in another apartment to test apartment transparency
+
+DWORD WINAPI ThreadProc(_In_ LPVOID pParam)
+{
+ // setup another apartment
+ HRESULT hr = OleInitialize( NULL );
+
+ WaitForSingleObject( g_hEvtThreadWakeup, INFINITE );
+
+ IDataObject* pIDo = NULL;
+
+#ifdef RAW_MARSHALING
+
+ IStream* pStm = NULL;
+ hr = CreateStreamOnHGlobal( g_hGlob, FALSE, &pStm );
+ if ( SUCCEEDED( hr ) )
+ {
+ hr = CoUnmarshalInterface(
+ pStm,
+ __uuidof( IDataObject ),
+ (void**)&pIDo );
+
+ hr = pStm->Release( );
+ }
+
+#else
+
+ hr = CoGetInterfaceAndReleaseStream(
+ g_pStm,
+ __uuidof( IDataObject ),
+ (void**)&pIDo
+ );
+
+#endif
+
+ IEnumFORMATETC* pIEEtc;
+ hr = pIDo->EnumFormatEtc( DATADIR_GET, &pIEEtc );
+
+ hr = OleIsCurrentClipboard( pIDo );
+
+ hr = OleFlushClipboard( );
+
+ OleUninitialize( );
+
+ return 0;
+}
+
+// main
+
+int SAL_CALL main( int nArgc, char* Argv[] )
+{
+ HRESULT hr = OleInitialize( NULL );
+
+ g_hEvtThreadWakeup = CreateEvent( 0,
+ EVT_MANUAL_RESET,
+ EVT_INIT_NONSIGNALED,
+ EVT_NONAME );
+
+ DWORD uThreadId;
+
+ // create a thread in another apartment
+ HANDLE hThread = CreateThread( NULL, 0, ThreadProc, NULL, 0, &uThreadId );
+
+ IDataObject* pIDo = new CXTDataObject( );
+
+ hr = OleSetClipboard( pIDo );
+ hr = E_FAIL;
+
+ hr = OleIsCurrentClipboard( pIDo );
+
+ //hr = OleGetClipboard( &pIDo );
+ if ( SUCCEEDED( hr ) )
+ {
+#ifdef RAW_MARSHALING
+
+ IStream* pStm = NULL;
+
+ hr = CreateStreamOnHGlobal( 0, FALSE, &pStm );
+ if ( SUCCEEDED( hr ) )
+ {
+ hr = CoMarshalInterface(
+ pStm,
+ __uuidof( IDataObject ),
+ pIDo,
+ MSHCTX_INPROC,
+ 0,
+ MSHLFLAGS_NORMAL );
+ if ( SUCCEEDED( hr ) )
+ hr = GetHGlobalFromStream( pStm, &g_hGlob );
+
+ hr = pStm->Release( );
+ }
+
+#else
+
+ hr = CoMarshalInterThreadInterfaceInStream(
+ __uuidof( IDataObject ),
+ pIDo,
+ &g_pStm );
+
+#endif
+
+ if ( SUCCEEDED( hr ) )
+ {
+ // wakeup the thread and waiting util it ends
+ SetEvent( g_hEvtThreadWakeup );
+
+#ifdef WAIT_MSGLOOP
+
+ BOOL bContinue = TRUE;
+
+ while( bContinue )
+ {
+ DWORD dwResult = WaitForMultipleObjects(
+ 1,
+ &hThread,
+ TRUE,
+ 0 );
+
+ if ( WAIT_OBJECT_0 == dwResult )
+ {
+ bContinue = FALSE;
+ }
+ else
+ {
+ MSG msg;
+ while( PeekMessage(
+ &msg,
+ NULL,
+ 0,
+ 0,
+ PM_REMOVE ) )
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ } // while
+
+#endif
+
+ } // if
+ } // if
+
+ OleFlushClipboard( );
+
+ OleUninitialize( );
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/wksfuzzer.cxx b/vcl/workben/wksfuzzer.cxx
new file mode 100644
index 000000000..a12fe2f20
--- /dev/null
+++ b/vcl/workben/wksfuzzer.cxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#include <com/sun/star/ucb/XUniversalContentBroker.hpp>
+#include "commonfuzzer.hxx"
+
+extern "C" void* ScCreateDialogFactory() { return nullptr; }
+
+extern "C" bool TestImportWKS(SvStream& rStream);
+
+extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
+{
+ if (__lsan_disable)
+ __lsan_disable();
+
+ CommonInitialize(argc, argv);
+
+ // initialise unconfigured UCB:
+ css::uno::Reference<css::ucb::XUniversalContentBroker> xUcb(
+ comphelper::getProcessServiceFactory()->createInstance(
+ "com.sun.star.ucb.UniversalContentBroker"),
+ css::uno::UNO_QUERY_THROW);
+ css::uno::Sequence<css::uno::Any> aArgs{ css::uno::Any(OUString("NoConfig")) };
+ css::uno::Reference<css::ucb::XContentProvider> xFileProvider(
+ comphelper::getProcessServiceFactory()->createInstanceWithArguments(
+ "com.sun.star.ucb.FileContentProvider", aArgs),
+ css::uno::UNO_QUERY_THROW);
+ xUcb->registerContentProvider(xFileProvider, "file", true);
+
+ if (__lsan_enable)
+ __lsan_enable();
+
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportWKS(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/wksfuzzer.options b/vcl/workben/wksfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/wksfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/wmffuzzer.cxx b/vcl/workben/wmffuzzer.cxx
new file mode 100644
index 000000000..371798fc9
--- /dev/null
+++ b/vcl/workben/wmffuzzer.cxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/wmf.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" {
+void * com_sun_star_i18n_LocaleDataImpl_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_get_implementation( void *, void * );
+void * emfio_emfreader_XEmfParser_get_implementation( void *, void * );
+}
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { "com_sun_star_i18n_LocaleDataImpl_get_implementation", com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation", com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation", com_sun_star_i18n_BreakIterator_get_implementation },
+ { "emfio_emfreader_XEmfParser_get_implementation", emfio_emfreader_XEmfParser_get_implementation},
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ GDIMetaFile aGDIMetaFile;
+ (void)ReadWindowMetafile(aStream, aGDIMetaFile);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/wmffuzzer.options b/vcl/workben/wmffuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/wmffuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/ww2fuzzer.cxx b/vcl/workben/ww2fuzzer.cxx
new file mode 100644
index 000000000..5ffe0445c
--- /dev/null
+++ b/vcl/workben/ww2fuzzer.cxx
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" {
+void * i18npool_component_getFactory( const char* , void* , void* );
+
+void * com_sun_star_comp_framework_Desktop_get_implementation( void *, void * );
+void * com_sun_star_i18n_LocaleDataImpl_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_get_implementation( void *, void * );
+void * SfxDocumentMetaData_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_get_implementation( void *, void * );
+void * com_sun_star_i18n_NativeNumberSupplier_get_implementation( void *, void * );
+void * com_sun_star_i18n_NumberFormatCodeMapper_get_implementation( void *, void * );
+void * com_sun_star_comp_graphic_GraphicProvider_get_implementation( void *, void * );
+void * IndexedPropertyValuesContainer_get_implementation( void *, void * );
+void * com_sun_star_comp_uui_UUIInteractionHandler_get_implementation( void *, void * );
+void * com_sun_star_i18n_Transliteration_get_implementation( void *, void * );
+void * com_sun_star_text_DefaultNumberingProvider_get_implementation( void *, void * );
+void * com_sun_star_comp_uri_UriReferenceFactory_get_implementation( void *, void * );
+void * emfio_emfreader_XEmfParser_get_implementation( void *, void * );
+void * i18npool_CalendarImpl_get_implementation(void*, void*);
+void * i18npool_Calendar_gregorian_get_implementation( void *, void * );
+void * unoxml_rdfRepository_get_implementation( void *, void * );
+void * unoxml_CURI_get_implementation( void *, void * );
+void * unoxml_CLiteral_get_implementation( void *, void * );
+void * unoxml_CBlankNode_get_implementation( void *, void * );
+void * unoxml_CXPathAPI_get_implementation( void *, void * );
+void * unoxml_CSAXDocumentBuilder_get_implementation( void *, void * );
+void * unoxml_CDocumentBuilder_get_implementation( void *, void * );
+void * ucb_UcbCommandEnvironment_get_implementation( void *, void * );
+void * ucb_UcbContentProviderProxyFactory_get_implementation( void *, void * );
+void * ucb_UcbPropertiesManager_get_implementation( void *, void * );
+void * ucb_UcbStore_get_implementation( void *, void * );
+void * ucb_UniversalContentBroker_get_implementation( void *, void * );
+void * ucb_OFileAccess_get_implementation( void *, void * );
+}
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { "libi18npoollo.a", i18npool_component_getFactory },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { "com_sun_star_comp_framework_Desktop_get_implementation", com_sun_star_comp_framework_Desktop_get_implementation },
+ { "com_sun_star_i18n_LocaleDataImpl_get_implementation", com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation", com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation", com_sun_star_i18n_BreakIterator_get_implementation },
+ { "SfxDocumentMetaData_get_implementation", SfxDocumentMetaData_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_Unicode_get_implementation", com_sun_star_i18n_CharacterClassification_Unicode_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_get_implementation", com_sun_star_i18n_CharacterClassification_get_implementation },
+ { "com_sun_star_i18n_NativeNumberSupplier_get_implementation", com_sun_star_i18n_NativeNumberSupplier_get_implementation },
+ { "com_sun_star_i18n_NumberFormatCodeMapper_get_implementation", com_sun_star_i18n_NumberFormatCodeMapper_get_implementation },
+ { "com_sun_star_comp_graphic_GraphicProvider_get_implementation", com_sun_star_comp_graphic_GraphicProvider_get_implementation },
+ { "IndexedPropertyValuesContainer_get_implementation", IndexedPropertyValuesContainer_get_implementation },
+ { "com_sun_star_comp_uui_UUIInteractionHandler_get_implementation", com_sun_star_comp_uui_UUIInteractionHandler_get_implementation },
+ { "com_sun_star_i18n_Transliteration_get_implementation", com_sun_star_i18n_Transliteration_get_implementation },
+ { "com_sun_star_text_DefaultNumberingProvider_get_implementation", com_sun_star_text_DefaultNumberingProvider_get_implementation },
+ { "com_sun_star_comp_uri_UriReferenceFactory_get_implementation", com_sun_star_comp_uri_UriReferenceFactory_get_implementation},
+ { "emfio_emfreader_XEmfParser_get_implementation", emfio_emfreader_XEmfParser_get_implementation},
+ { "i18npool_CalendarImpl_get_implementation", i18npool_CalendarImpl_get_implementation},
+ { "i18npool_Calendar_gregorian_get_implementation", i18npool_Calendar_gregorian_get_implementation},
+ { "unoxml_rdfRepository_get_implementation", unoxml_rdfRepository_get_implementation },
+ { "unoxml_CURI_get_implementation", unoxml_CURI_get_implementation },
+ { "unoxml_CLiteral_get_implementation", unoxml_CLiteral_get_implementation },
+ { "unoxml_CBlankNode_get_implementation", unoxml_CBlankNode_get_implementation },
+ { "unoxml_CXPathAPI_get_implementation", unoxml_CXPathAPI_get_implementation },
+ { "unoxml_CSAXDocumentBuilder_get_implementation", unoxml_CSAXDocumentBuilder_get_implementation },
+ { "unoxml_CDocumentBuilder_get_implementation", unoxml_CDocumentBuilder_get_implementation },
+ { "ucb_UcbCommandEnvironment_get_implementation", ucb_UcbCommandEnvironment_get_implementation, },
+ { "ucb_UcbContentProviderProxyFactory_get_implementation", ucb_UcbContentProviderProxyFactory_get_implementation },
+ { "ucb_UcbPropertiesManager_get_implementation", ucb_UcbPropertiesManager_get_implementation },
+ { "ucb_UcbStore_get_implementation", ucb_UcbStore_get_implementation },
+ { "ucb_UniversalContentBroker_get_implementation", ucb_UniversalContentBroker_get_implementation },
+ { "ucb_OFileAccess_get_implementation", ucb_OFileAccess_get_implementation },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" void* SwCreateDialogFactory()
+{
+ return nullptr;
+}
+
+extern "C" bool TestImportWW2(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportWW2(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/ww2fuzzer.options b/vcl/workben/ww2fuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/ww2fuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/ww6fuzzer.cxx b/vcl/workben/ww6fuzzer.cxx
new file mode 100644
index 000000000..a17be9105
--- /dev/null
+++ b/vcl/workben/ww6fuzzer.cxx
@@ -0,0 +1,132 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" {
+void * i18npool_component_getFactory( const char* , void* , void* );
+
+void * com_sun_star_comp_framework_Desktop_get_implementation( void *, void * );
+void * com_sun_star_i18n_LocaleDataImpl_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_get_implementation( void *, void * );
+void * SfxDocumentMetaData_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_get_implementation( void *, void * );
+void * com_sun_star_i18n_NativeNumberSupplier_get_implementation( void *, void * );
+void * com_sun_star_i18n_NumberFormatCodeMapper_get_implementation( void *, void * );
+void * com_sun_star_comp_graphic_GraphicProvider_get_implementation( void *, void * );
+void * IndexedPropertyValuesContainer_get_implementation( void *, void * );
+void * com_sun_star_comp_uui_UUIInteractionHandler_get_implementation( void *, void * );
+void * com_sun_star_comp_comphelper_OPropertyBag( void *, void * );
+void * com_sun_star_i18n_Transliteration_get_implementation( void *, void * );
+void * com_sun_star_text_DefaultNumberingProvider_get_implementation( void *, void * );
+void * com_sun_star_comp_uri_UriReferenceFactory_get_implementation( void *, void * );
+void * emfio_emfreader_XEmfParser_get_implementation( void *, void * );
+void * i18npool_CalendarImpl_get_implementation(void*, void*);
+void * i18npool_Calendar_gregorian_get_implementation( void *, void * );
+void * unoxml_rdfRepository_get_implementation( void *, void * );
+void * unoxml_CURI_get_implementation( void *, void * );
+void * unoxml_CLiteral_get_implementation( void *, void * );
+void * unoxml_CBlankNode_get_implementation( void *, void * );
+void * unoxml_CXPathAPI_get_implementation( void *, void * );
+void * unoxml_CSAXDocumentBuilder_get_implementation( void *, void * );
+void * unoxml_CDocumentBuilder_get_implementation( void *, void * );
+void * ucb_UcbCommandEnvironment_get_implementation( void *, void * );
+void * ucb_UcbContentProviderProxyFactory_get_implementation( void *, void * );
+void * ucb_UcbPropertiesManager_get_implementation( void *, void * );
+void * ucb_UcbStore_get_implementation( void *, void * );
+void * ucb_UniversalContentBroker_get_implementation( void *, void * );
+void * ucb_OFileAccess_get_implementation( void *, void * );
+}
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { "libi18npoollo.a", i18npool_component_getFactory },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { "com_sun_star_comp_framework_Desktop_get_implementation", com_sun_star_comp_framework_Desktop_get_implementation },
+ { "com_sun_star_i18n_LocaleDataImpl_get_implementation", com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation", com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation", com_sun_star_i18n_BreakIterator_get_implementation },
+ { "SfxDocumentMetaData_get_implementation", SfxDocumentMetaData_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_Unicode_get_implementation", com_sun_star_i18n_CharacterClassification_Unicode_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_get_implementation", com_sun_star_i18n_CharacterClassification_get_implementation },
+ { "com_sun_star_i18n_NativeNumberSupplier_get_implementation", com_sun_star_i18n_NativeNumberSupplier_get_implementation },
+ { "com_sun_star_i18n_NumberFormatCodeMapper_get_implementation", com_sun_star_i18n_NumberFormatCodeMapper_get_implementation },
+ { "com_sun_star_comp_graphic_GraphicProvider_get_implementation", com_sun_star_comp_graphic_GraphicProvider_get_implementation },
+ { "IndexedPropertyValuesContainer_get_implementation", IndexedPropertyValuesContainer_get_implementation },
+ { "com_sun_star_comp_uui_UUIInteractionHandler_get_implementation", com_sun_star_comp_uui_UUIInteractionHandler_get_implementation },
+ { "com_sun_star_comp_comphelper_OPropertyBag", com_sun_star_comp_comphelper_OPropertyBag },
+ { "com_sun_star_i18n_Transliteration_get_implementation", com_sun_star_i18n_Transliteration_get_implementation },
+ { "com_sun_star_text_DefaultNumberingProvider_get_implementation", com_sun_star_text_DefaultNumberingProvider_get_implementation },
+ { "com_sun_star_comp_uri_UriReferenceFactory_get_implementation", com_sun_star_comp_uri_UriReferenceFactory_get_implementation},
+ { "emfio_emfreader_XEmfParser_get_implementation", emfio_emfreader_XEmfParser_get_implementation},
+ { "i18npool_CalendarImpl_get_implementation", i18npool_CalendarImpl_get_implementation },
+ { "i18npool_Calendar_gregorian_get_implementation", i18npool_Calendar_gregorian_get_implementation},
+ { "unoxml_rdfRepository_get_implementation", unoxml_rdfRepository_get_implementation },
+ { "unoxml_CURI_get_implementation", unoxml_CURI_get_implementation },
+ { "unoxml_CLiteral_get_implementation", unoxml_CLiteral_get_implementation },
+ { "unoxml_CBlankNode_get_implementation", unoxml_CBlankNode_get_implementation },
+ { "unoxml_CXPathAPI_get_implementation", unoxml_CXPathAPI_get_implementation },
+ { "unoxml_CSAXDocumentBuilder_get_implementation", unoxml_CSAXDocumentBuilder_get_implementation },
+ { "unoxml_CDocumentBuilder_get_implementation", unoxml_CDocumentBuilder_get_implementation },
+ { "ucb_UcbCommandEnvironment_get_implementation", ucb_UcbCommandEnvironment_get_implementation, },
+ { "ucb_UcbContentProviderProxyFactory_get_implementation", ucb_UcbContentProviderProxyFactory_get_implementation },
+ { "ucb_UcbPropertiesManager_get_implementation", ucb_UcbPropertiesManager_get_implementation },
+ { "ucb_UcbStore_get_implementation", ucb_UcbStore_get_implementation },
+ { "ucb_UniversalContentBroker_get_implementation", ucb_UniversalContentBroker_get_implementation },
+ { "ucb_OFileAccess_get_implementation", ucb_OFileAccess_get_implementation },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" void* SwCreateDialogFactory()
+{
+ return nullptr;
+}
+
+extern "C" bool TestImportWW6(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportWW6(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/ww6fuzzer.options b/vcl/workben/ww6fuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/ww6fuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/ww8fuzzer.cxx b/vcl/workben/ww8fuzzer.cxx
new file mode 100644
index 000000000..113e79861
--- /dev/null
+++ b/vcl/workben/ww8fuzzer.cxx
@@ -0,0 +1,132 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+extern "C" {
+void * i18npool_component_getFactory( const char* , void* , void* );
+
+void * com_sun_star_comp_framework_Desktop_get_implementation( void *, void * );
+void * com_sun_star_i18n_LocaleDataImpl_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_BreakIterator_get_implementation( void *, void * );
+void * SfxDocumentMetaData_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_Unicode_get_implementation( void *, void * );
+void * com_sun_star_i18n_CharacterClassification_get_implementation( void *, void * );
+void * com_sun_star_i18n_NativeNumberSupplier_get_implementation( void *, void * );
+void * com_sun_star_i18n_NumberFormatCodeMapper_get_implementation( void *, void * );
+void * com_sun_star_comp_graphic_GraphicProvider_get_implementation( void *, void * );
+void * IndexedPropertyValuesContainer_get_implementation( void *, void * );
+void * com_sun_star_comp_uui_UUIInteractionHandler_get_implementation( void *, void * );
+void * com_sun_star_comp_comphelper_OPropertyBag( void *, void * );
+void * com_sun_star_i18n_Transliteration_get_implementation( void *, void * );
+void * com_sun_star_text_DefaultNumberingProvider_get_implementation( void *, void * );
+void * com_sun_star_comp_uri_UriReferenceFactory_get_implementation( void *, void * );
+void * emfio_emfreader_XEmfParser_get_implementation( void *, void * );
+void * i18npool_CalendarImpl_get_implementation(void*, void*);
+void * i18npool_Calendar_gregorian_get_implementation( void *, void * );
+void * unoxml_rdfRepository_get_implementation( void *, void * );
+void * unoxml_CURI_get_implementation( void *, void * );
+void * unoxml_CLiteral_get_implementation( void *, void * );
+void * unoxml_CBlankNode_get_implementation( void *, void * );
+void * unoxml_CXPathAPI_get_implementation( void *, void * );
+void * unoxml_CSAXDocumentBuilder_get_implementation( void *, void * );
+void * unoxml_CDocumentBuilder_get_implementation( void *, void * );
+void * ucb_UcbCommandEnvironment_get_implementation( void *, void * );
+void * ucb_UcbContentProviderProxyFactory_get_implementation( void *, void * );
+void * ucb_UcbPropertiesManager_get_implementation( void *, void * );
+void * ucb_UcbStore_get_implementation( void *, void * );
+void * ucb_UniversalContentBroker_get_implementation( void *, void * );
+void * ucb_OFileAccess_get_implementation( void *, void * );
+}
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { "libi18npoollo.a", i18npool_component_getFactory },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { "com_sun_star_comp_framework_Desktop_get_implementation", com_sun_star_comp_framework_Desktop_get_implementation },
+ { "com_sun_star_i18n_LocaleDataImpl_get_implementation", com_sun_star_i18n_LocaleDataImpl_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_Unicode_get_implementation", com_sun_star_i18n_BreakIterator_Unicode_get_implementation },
+ { "com_sun_star_i18n_BreakIterator_get_implementation", com_sun_star_i18n_BreakIterator_get_implementation },
+ { "SfxDocumentMetaData_get_implementation", SfxDocumentMetaData_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_Unicode_get_implementation", com_sun_star_i18n_CharacterClassification_Unicode_get_implementation },
+ { "com_sun_star_i18n_CharacterClassification_get_implementation", com_sun_star_i18n_CharacterClassification_get_implementation },
+ { "com_sun_star_i18n_NativeNumberSupplier_get_implementation", com_sun_star_i18n_NativeNumberSupplier_get_implementation },
+ { "com_sun_star_i18n_NumberFormatCodeMapper_get_implementation", com_sun_star_i18n_NumberFormatCodeMapper_get_implementation },
+ { "com_sun_star_comp_graphic_GraphicProvider_get_implementation", com_sun_star_comp_graphic_GraphicProvider_get_implementation },
+ { "IndexedPropertyValuesContainer_get_implementation", IndexedPropertyValuesContainer_get_implementation },
+ { "com_sun_star_comp_uui_UUIInteractionHandler_get_implementation", com_sun_star_comp_uui_UUIInteractionHandler_get_implementation },
+ { "com_sun_star_comp_comphelper_OPropertyBag", com_sun_star_comp_comphelper_OPropertyBag },
+ { "com_sun_star_i18n_Transliteration_get_implementation", com_sun_star_i18n_Transliteration_get_implementation },
+ { "com_sun_star_text_DefaultNumberingProvider_get_implementation", com_sun_star_text_DefaultNumberingProvider_get_implementation },
+ { "com_sun_star_comp_uri_UriReferenceFactory_get_implementation", com_sun_star_comp_uri_UriReferenceFactory_get_implementation},
+ { "emfio_emfreader_XEmfParser_get_implementation", emfio_emfreader_XEmfParser_get_implementation},
+ { "i18npool_CalendarImpl_get_implementation", i18npool_CalendarImpl_get_implementation},
+ { "i18npool_Calendar_gregorian_get_implementation", i18npool_Calendar_gregorian_get_implementation},
+ { "unoxml_rdfRepository_get_implementation", unoxml_rdfRepository_get_implementation },
+ { "unoxml_CURI_get_implementation", unoxml_CURI_get_implementation },
+ { "unoxml_CLiteral_get_implementation", unoxml_CLiteral_get_implementation },
+ { "unoxml_CBlankNode_get_implementation", unoxml_CBlankNode_get_implementation },
+ { "unoxml_CXPathAPI_get_implementation", unoxml_CXPathAPI_get_implementation },
+ { "unoxml_CSAXDocumentBuilder_get_implementation", unoxml_CSAXDocumentBuilder_get_implementation },
+ { "unoxml_CDocumentBuilder_get_implementation", unoxml_CDocumentBuilder_get_implementation },
+ { "ucb_UcbCommandEnvironment_get_implementation", ucb_UcbCommandEnvironment_get_implementation, },
+ { "ucb_UcbContentProviderProxyFactory_get_implementation", ucb_UcbContentProviderProxyFactory_get_implementation },
+ { "ucb_UcbPropertiesManager_get_implementation", ucb_UcbPropertiesManager_get_implementation },
+ { "ucb_UcbStore_get_implementation", ucb_UcbStore_get_implementation },
+ { "ucb_UniversalContentBroker_get_implementation", ucb_UniversalContentBroker_get_implementation },
+ { "ucb_OFileAccess_get_implementation", ucb_OFileAccess_get_implementation },
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" void* SwCreateDialogFactory()
+{
+ return nullptr;
+}
+
+extern "C" bool TestImportWW8(SvStream &rStream);
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportWW8(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/ww8fuzzer.options b/vcl/workben/ww8fuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/ww8fuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/xbmfuzzer.cxx b/vcl/workben/xbmfuzzer.cxx
new file mode 100644
index 000000000..bb261f60a
--- /dev/null
+++ b/vcl/workben/xbmfuzzer.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <../source/filter/ixbm/xbmread.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportXBM(aStream, aGraphic);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/xbmfuzzer.options b/vcl/workben/xbmfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/xbmfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/xlsfuzzer.cxx b/vcl/workben/xlsfuzzer.cxx
new file mode 100644
index 000000000..4dd38ea22
--- /dev/null
+++ b/vcl/workben/xlsfuzzer.cxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#include <com/sun/star/ucb/XUniversalContentBroker.hpp>
+#include "commonfuzzer.hxx"
+
+extern "C" void* ScCreateDialogFactory() { return nullptr; }
+
+extern "C" bool TestImportXLS(SvStream& rStream);
+
+extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
+{
+ if (__lsan_disable)
+ __lsan_disable();
+
+ CommonInitialize(argc, argv);
+
+ // initialise unconfigured UCB:
+ css::uno::Reference<css::ucb::XUniversalContentBroker> xUcb(
+ comphelper::getProcessServiceFactory()->createInstance(
+ "com.sun.star.ucb.UniversalContentBroker"),
+ css::uno::UNO_QUERY_THROW);
+ css::uno::Sequence<css::uno::Any> aArgs{ css::uno::Any(OUString("NoConfig")) };
+ css::uno::Reference<css::ucb::XContentProvider> xFileProvider(
+ comphelper::getProcessServiceFactory()->createInstanceWithArguments(
+ "com.sun.star.ucb.FileContentProvider", aArgs),
+ css::uno::UNO_QUERY_THROW);
+ xUcb->registerContentProvider(xFileProvider, "file", true);
+
+ if (__lsan_enable)
+ __lsan_enable();
+
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportXLS(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/xlsfuzzer.options b/vcl/workben/xlsfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/xlsfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536
diff --git a/vcl/workben/xlsxfuzzer.cxx b/vcl/workben/xlsxfuzzer.cxx
new file mode 100644
index 000000000..a325bd69f
--- /dev/null
+++ b/vcl/workben/xlsxfuzzer.cxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <vcl/FilterConfigItem.hxx>
+#include "commonfuzzer.hxx"
+
+extern "C" void* ScCreateDialogFactory() { return nullptr; }
+
+extern "C" bool TestImportXLSX(SvStream& rStream);
+
+extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ (void)TestImportXLSX(aStream);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/xlsxfuzzer.options b/vcl/workben/xlsxfuzzer.options
new file mode 100644
index 000000000..e8c2b812b
--- /dev/null
+++ b/vcl/workben/xlsxfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 98304
diff --git a/vcl/workben/xpmfuzzer.cxx b/vcl/workben/xpmfuzzer.cxx
new file mode 100644
index 000000000..bd9413fb5
--- /dev/null
+++ b/vcl/workben/xpmfuzzer.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/stream.hxx>
+#include <filter/XpmReader.hxx>
+#include "commonfuzzer.hxx"
+
+#include <config_features.h>
+#include <osl/detail/component-mapping.h>
+
+const lib_to_factory_mapping *
+lo_get_factory_map(void)
+{
+ static lib_to_factory_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+const lib_to_constructor_mapping *
+lo_get_constructor_map(void)
+{
+ static lib_to_constructor_mapping map[] = {
+ { 0, 0 }
+ };
+
+ return map;
+}
+
+extern "C" void* lo_get_custom_widget_func(const char*)
+{
+ return nullptr;
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ TypicalFuzzerInitialize(argc, argv);
+ return 0;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
+ Graphic aGraphic;
+ (void)ImportXPM(aStream, aGraphic);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/xpmfuzzer.options b/vcl/workben/xpmfuzzer.options
new file mode 100644
index 000000000..678d526b1
--- /dev/null
+++ b/vcl/workben/xpmfuzzer.options
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 65536