/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #ifndef INCLUDED_SC_INC_AUTOFORM_HXX #define INCLUDED_SC_INC_AUTOFORM_HXX /************************************************************************* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! The structure of auto formatting should not be changed. It is used by various code of Writer and Calc. If a change is necessary, the source code of both applications must be changed! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! **************************************************************************/ #include #include #include "scdllapi.h" #include "zforauto.hxx" #include #include #include #include class ScDocument; /** A binary blob of writer-specific data. This data typically consists of types that are unavailable to Calc (e.g. SwFmtVertOrient), or that Calc doesn't care about. @remarks Note that in autoformat versions prior to AUTOFORMAT_DATA_ID_31005, Calc logic handled and stored several writer-specific items (such as ScAutoFormatDataField::aAdjust). That logic was preserved. From _31005 onward, writer-specific data should be handled by blobs to avoid needlessly complicating the Calc logic. */ struct AutoFormatSwBlob { std::unique_ptr pData; std::size_t size; AutoFormatSwBlob() : size(0) { } AutoFormatSwBlob(const AutoFormatSwBlob&) = delete; const AutoFormatSwBlob& operator=(const AutoFormatSwBlob&) = delete; void Reset() { pData.reset(); size = 0; } }; /// Struct with version numbers of the Items struct ScAfVersions : public AutoFormatVersions { public: AutoFormatSwBlob swVersions; ScAfVersions(); void Load( SvStream& rStream, sal_uInt16 nVer ); void Write(SvStream& rStream, sal_uInt16 fileVersion); }; /// Contains all items for one cell of a table autoformat. class ScAutoFormatDataField : public AutoFormatBase { private: AutoFormatSwBlob m_swFields; // number format ScNumFormatAbbrev aNumFormat; public: ScAutoFormatDataField(); ScAutoFormatDataField( const ScAutoFormatDataField& rCopy ); ~ScAutoFormatDataField(); // block assignment operator ScAutoFormatDataField& operator=(const ScAutoFormatDataField& rRef) = delete; // number format const ScNumFormatAbbrev& GetNumFormat() const { return aNumFormat; } // number format void SetNumFormat( const ScNumFormatAbbrev& rNumFormat ) { aNumFormat = rNumFormat; } bool Load( SvStream& rStream, const ScAfVersions& rVersions, sal_uInt16 nVer ); bool Save( SvStream& rStream, sal_uInt16 fileVersion ); }; class SC_DLLPUBLIC ScAutoFormatData { private: OUString aName; sal_uInt16 nStrResId; // common flags of Calc and Writer bool bIncludeFont : 1; bool bIncludeJustify : 1; bool bIncludeFrame : 1; bool bIncludeBackground : 1; // Calc specific flags bool bIncludeValueFormat : 1; bool bIncludeWidthHeight : 1; // Writer-specific data AutoFormatSwBlob m_swFields; std::array,16> ppDataField; SAL_DLLPRIVATE ScAutoFormatDataField& GetField( sal_uInt16 nIndex ); SAL_DLLPRIVATE const ScAutoFormatDataField& GetField( sal_uInt16 nIndex ) const; public: ScAutoFormatData(); ScAutoFormatData( const ScAutoFormatData& rData ); ~ScAutoFormatData(); void SetName( const OUString& rName ) { aName = rName; nStrResId = USHRT_MAX; } const OUString& GetName() const { return aName; } bool GetIncludeValueFormat() const { return bIncludeValueFormat; } bool GetIncludeFont() const { return bIncludeFont; } bool GetIncludeJustify() const { return bIncludeJustify; } bool GetIncludeFrame() const { return bIncludeFrame; } bool GetIncludeBackground() const { return bIncludeBackground; } bool GetIncludeWidthHeight() const { return bIncludeWidthHeight; } void SetIncludeValueFormat( bool bValueFormat ) { bIncludeValueFormat = bValueFormat; } void SetIncludeFont( bool bFont ) { bIncludeFont = bFont; } void SetIncludeJustify( bool bJustify ) { bIncludeJustify = bJustify; } void SetIncludeFrame( bool bFrame ) { bIncludeFrame = bFrame; } void SetIncludeBackground( bool bBackground ) { bIncludeBackground = bBackground; } void SetIncludeWidthHeight( bool bWidthHeight ) { bIncludeWidthHeight = bWidthHeight; } const SfxPoolItem* GetItem( sal_uInt16 nIndex, sal_uInt16 nWhich ) const; template const T* GetItem( sal_uInt16 nIndex, TypedWhichId nWhich ) const { return static_cast(GetItem(nIndex, sal_uInt16(nWhich))); } void PutItem( sal_uInt16 nIndex, const SfxPoolItem& rItem ); void CopyItem( sal_uInt16 nToIndex, sal_uInt16 nFromIndex, sal_uInt16 nWhich ); const ScNumFormatAbbrev& GetNumFormat( sal_uInt16 nIndex ) const; bool IsEqualData( sal_uInt16 nIndex1, sal_uInt16 nIndex2 ) const; void FillToItemSet( sal_uInt16 nIndex, SfxItemSet& rItemSet, const ScDocument& rDoc ) const; void GetFromItemSet( sal_uInt16 nIndex, const SfxItemSet& rItemSet, const ScNumFormatAbbrev& rNumFormat ); bool Load( SvStream& rStream, const ScAfVersions& rVersions ); bool Save( SvStream& rStream, sal_uInt16 fileVersion ); }; struct DefaultFirstEntry { bool operator() (const OUString& left, const OUString& right) const; }; class SC_DLLPUBLIC ScAutoFormat { typedef std::map, DefaultFirstEntry> MapType; MapType m_Data; bool mbSaveLater; ScAfVersions m_aVersions; ScAutoFormat(const ScAutoFormat&) = delete; const ScAutoFormat operator=(const ScAutoFormat&) = delete; public: typedef MapType::const_iterator const_iterator; typedef MapType::iterator iterator; ScAutoFormat(); void Load(); bool Save(); void SetSaveLater( bool bSet ); bool IsSaveLater() const { return mbSaveLater; } const ScAutoFormatData* findByIndex(size_t nIndex) const; ScAutoFormatData* findByIndex(size_t nIndex); iterator find(const OUString& rName); iterator insert(std::unique_ptr pNew); void erase(const iterator& it); size_t size() const; const_iterator begin() const; const_iterator end() const; iterator begin(); iterator end(); }; #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ ro/mimo/mimo-7-6'>distro/mimo/mimo-7-6 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-12-25oss-fuzz: use fuzzer_statics for default staticsJan-Marek Glogowski
Change-Id: I3616507127e0661635d87ba2b949ddaa13bc898d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127454 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2021-02-28Upgrade fuzzers to LIB_FUZZING_ENGINEAndrzej Hunt
And check that LIB_FUZZING_ENGINE is set during configure. Because: 1. It's easier to build locally this way (you don't need to build or hack a libFuzzingEngine.a - instead you can just specify LIB_FUZZING_ENGINE=-fsanitize=fuzzer to produce a valid build). 2. Using -lFuzzingEngine is deprecated [1] for various reasons [2]. The old behaviour can be emulated if desired by setting LIB_FUZZING_ENGINE=-lFuzzingEngine . This patch was tested as follows: - Building LO within oss-fuzz via: python infra/helper.py build_fuzzers --sanitizer address libreoffice </path/to/patched-libreoffice-core> python infra/helper.py check_build libreoffice - Building LO fuzzers standalone via: export CC="clang-11" export CXX="clang++-11 -stdlib=libc++" export CFLAGS="-fsanitize=address -fsanitize-address-use-after-scope -fsanitize=fuzzer-no-link -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" export CXXFLAGS="$CFLAGS -stdlib=libc++" export LDFLAGS="$CFLAGS -Wl,--compress-debug-sections,zlib -lpthread" export LIB_FUZZING_ENGINE=-fsanitize=fuzzer ./autogen.sh --with-distro=LibreOfficeOssFuzz --with-system-libxml make fuzzers (--with-system-libxml only appears to be needed because of issues specific to my build environment/Suse 15.2. I'm invoking clang-11 simply because that's the most modern clang I have installed, plain clang should also work on most sufficiently modern systems). [1] https://github.com/google/oss-fuzz/blob/481280c65048fd12fb2141b9225af511a9ef7ed2/infra/presubmit.py#L46 [2] https://github.com/google/oss-fuzz/issues/2164 Change-Id: Iddb577c30a39620e72372ef6c2d3fda67f8aabdf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111691 Tested-by: Jenkins Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>