diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /include/svl | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'include/svl')
83 files changed, 9940 insertions, 0 deletions
diff --git a/include/svl/IndexedStyleSheets.hxx b/include/svl/IndexedStyleSheets.hxx new file mode 100644 index 000000000..72c87f0ba --- /dev/null +++ b/include/svl/IndexedStyleSheets.hxx @@ -0,0 +1,189 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SVL_INDEXEDSTYLESHEETS_HXX +#define INCLUDED_SVL_INDEXEDSTYLESHEETS_HXX + +#include <svl/style.hxx> +#include <rtl/ustring.hxx> +#include <rtl/ref.hxx> + +#include <svl/svldllapi.h> + +#include <unordered_map> +#include <vector> + +namespace svl { + +/** Function object to check whether a style sheet a fulfills specific criteria. + * Derive from this class and override the Check() method. + */ +struct StyleSheetPredicate { + virtual bool Check(const SfxStyleSheetBase& styleSheet) = 0; + virtual ~StyleSheetPredicate() {} +}; + +/** Function object for cleanup-Strategy for IndexedSfxStyleSheets::Clear(). + * Derive from it and do what is necessary to dispose of a style sheet in Dispose(). + */ +struct StyleSheetDisposer { + virtual void Dispose(rtl::Reference<SfxStyleSheetBase> styleSheet) = 0; + virtual ~StyleSheetDisposer() {} +}; + +/** Function object to apply a method on all style sheets. + * Derive from it and do whatever you want to with the style sheet in the DoIt() method. + */ +struct StyleSheetCallback { + virtual void DoIt(const SfxStyleSheetBase& styleSheet) = 0; + virtual ~StyleSheetCallback() {} +}; + +/** This class holds SfxStyleSheets and allows for access via an id and a name. + * + * @warning + * The identification of style sheets happens by their name. If the name of a sheet changes, + * it will not be found again! Please call Reindex() after changing a style sheet's name. + * + * @internal + * This class was implemented to mitigate solve #fdo 30770. + * The issue describes an Excel file which takes several hours to open. + * An analysis revealed that the time is spent searching for style sheets with linear scans in an array. + * This class implements access to the style sheets via their name in (usually) constant time. + * + * The return type for most methods is a vector of unsigned integers which denote the position + * of the style sheets in the vector, and not of pointers to style sheets. + * You will need a non-const StyleSheetPool to obtain the actual style sheets. + * + * + * Index-based access is required in several code portions. Hence we have to store the style sheets + * in a vector as well as in a map. + */ +class SVL_DLLPUBLIC IndexedStyleSheets final +{ +public: + IndexedStyleSheets(); + + /** Destructor. + * + * @internal + * Is explicit because it has to know how to dispose of SfxStyleSheetBase objects. + */ + ~IndexedStyleSheets(); + + /** Adds a style sheet. + * + * If the style sheet is already contained, this call has no effect. + */ + void + AddStyleSheet(const rtl::Reference< SfxStyleSheetBase >& style); + + /** Removes a style sheet. */ + bool + RemoveStyleSheet(const rtl::Reference< SfxStyleSheetBase >& style); + + /** Check whether a specified style sheet is stored. */ + bool + HasStyleSheet(const rtl::Reference< SfxStyleSheetBase >& style) const; + + /** Obtain the number of style sheets which are held */ + unsigned + GetNumberOfStyleSheets() const; + + /** Obtain the number of style sheets for which a certain condition holds */ + unsigned + GetNumberOfStyleSheetsWithPredicate(StyleSheetPredicate& predicate) const; + + /** Return the stylesheet by its position. + * You can obtain the position by, e.g., FindStyleSheetPosition() + * @internal + * Method is not const because the returned style sheet is not const + */ + SfxStyleSheetBase* + GetStyleSheetByPosition(unsigned pos); + + /** Find the position of a provided style. + * + * @throws std::runtime_error if the style has not been found. + */ + unsigned + FindStyleSheetPosition(const SfxStyleSheetBase& style) const; + + /** Obtain the positions of all styles which have a given name + */ + std::vector<unsigned> + FindPositionsByName(const OUString& name) const; + + enum class SearchBehavior { ReturnAll, ReturnFirst }; + /** Obtain the positions of all styles which have a certain name and fulfill a certain condition. + * + * This method is fast because it can use the name-based index + */ + std::vector<unsigned> + FindPositionsByNameAndPredicate(const OUString& name, StyleSheetPredicate& predicate, + SearchBehavior behavior = SearchBehavior::ReturnAll) const; + + /** Obtain the positions of all styles which fulfill a certain condition. + * + * This method is slow because it cannot use the name-based index + */ + std::vector<unsigned> + FindPositionsByPredicate(StyleSheetPredicate& predicate) const; + + /** Execute a callback on all style sheets */ + void + ApplyToAllStyleSheets(StyleSheetCallback& callback) const; + + /** Clear the contents of the index. + * The StyleSheetDisposer::Dispose() method is called on each style sheet, e.g., if you want to broadcast + * changes. + */ + void + Clear(StyleSheetDisposer& cleanup); + + void + Reindex(); + + /** Warning: counting for n starts at 0, i.e., the 0th style sheet is the first that is found. */ + SfxStyleSheetBase* + GetNthStyleSheetThatMatchesPredicate(unsigned n, StyleSheetPredicate& predicate, + unsigned startAt = 0); + + /** Get the positions of the style sheets which belong to a certain family. + */ + const std::vector<unsigned>& + GetStyleSheetPositionsByFamily(SfxStyleFamily) const; + +private: + /** Register the position of a styleName in the index */ + void + Register(const SfxStyleSheetBase& style, unsigned pos); + + typedef std::vector<rtl::Reference<SfxStyleSheetBase> > VectorType; + /** Vector with the stylesheets to allow for index-based access. + */ + VectorType mStyleSheets; + + /** The map type that is used to store the mapping from strings to ids in mStyleSheets + * + * @internal + * Must be an unordered map. A regular map is too slow for some files. */ + typedef std::unordered_multimap<OUString, unsigned> MapType; + + /** A map which stores the positions of style sheets by their name */ + MapType mPositionsByName; + + std::vector<std::vector<unsigned> > mStyleSheetPositionsByFamily; +}; + +} /* namespace svl */ + +#endif // INCLUDED_SVL_INDEXEDSTYLESHEETS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/PasswordHelper.hxx b/include/svl/PasswordHelper.hxx new file mode 100644 index 000000000..ef3dc2c21 --- /dev/null +++ b/include/svl/PasswordHelper.hxx @@ -0,0 +1,51 @@ +/* -*- 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_SVL_PASSWORDHELPER_HXX +#define INCLUDED_SVL_PASSWORDHELPER_HXX + +#include <svl/svldllapi.h> +#include <sal/types.h> +#include <com/sun/star/uno/Sequence.hxx> + +class SvPasswordHelper +{ + static void GetHashPasswordLittleEndian(css::uno::Sequence<sal_Int8>& rPassHash, const OUString& sPass); + static void GetHashPasswordBigEndian(css::uno::Sequence<sal_Int8>& rPassHash, const OUString& sPass); + +public: + SVL_DLLPUBLIC static void GetHashPassword(css::uno::Sequence <sal_Int8>& rPassHash, const char* pPass, sal_uInt32 nLen); + + SVL_DLLPUBLIC static void GetHashPassword(css::uno::Sequence<sal_Int8>& rPassHash, const OUString& sPass); + SVL_DLLPUBLIC static void GetHashPasswordSHA1UTF8(css::uno::Sequence<sal_Int8>& rPassHash, const OUString& sPass); + SVL_DLLPUBLIC static void GetHashPasswordSHA256(css::uno::Sequence<sal_Int8>& rPassHash, const OUString& sPass); + /** + Use this method to compare a given string with another given Hash value. + This is necessary, because in older versions exists different hashes of the same string. They were endian dependent. + We need this to handle old files. This method will compare against big and + little endian UTF-16. + tdf#115483: also check 2 different new ways of hashing that were added in + ODF 1.2, requiring UTF-8 encoding. + */ + SVL_DLLPUBLIC static bool CompareHashPassword(const css::uno::Sequence<sal_Int8>& rOldPassHash, const OUString& sNewPass); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/SfxBroadcaster.hxx b/include/svl/SfxBroadcaster.hxx new file mode 100644 index 000000000..bacef8d2d --- /dev/null +++ b/include/svl/SfxBroadcaster.hxx @@ -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/. + * + * 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_SVL_BRDCST_HXX +#define INCLUDED_SVL_BRDCST_HXX + +#include <svl/svldllapi.h> +#include <memory> + +class SfxListener; +class SfxHint; +class SfxBroadcasterTest; + +class SVL_DLLPUBLIC SfxBroadcaster +{ + struct Impl; + std::unique_ptr<Impl> mpImpl; + +private: + void AddListener( SfxListener& rListener ); + void RemoveListener( SfxListener& rListener ); + const SfxBroadcaster& operator=(const SfxBroadcaster &) = delete; + +protected: + void Forward(SfxBroadcaster& rBC, const SfxHint& rHint); + +public: + + SfxBroadcaster(); + SfxBroadcaster( const SfxBroadcaster &rBC ); + virtual ~SfxBroadcaster() COVERITY_NOEXCEPT_FALSE; + + void Broadcast( const SfxHint &rHint ); + bool HasListeners() const; + + /** Get the number of listeners which are registered at this broadcaster */ + size_t GetListenerCount() const; + + /** Get the size of the internally stored vector. + * Use it to iterate over all listeners. + */ + size_t GetSizeOfVector() const; + + /** Get a listener by its position in the internally stored vector. + * Note that this method may return NULL + */ + SfxListener* GetListener( size_t nNo ) const; + + friend class SfxListener; + friend class ::SfxBroadcasterTest; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/adrparse.hxx b/include/svl/adrparse.hxx new file mode 100644 index 000000000..f19fc7ef0 --- /dev/null +++ b/include/svl/adrparse.hxx @@ -0,0 +1,50 @@ +/* -*- 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_SVL_ADRPARSE_HXX +#define INCLUDED_SVL_ADRPARSE_HXX + +#include <rtl/ustring.hxx> +#include <svl/svldllapi.h> +#include <vector> + + +class SVL_DLLPUBLIC SvAddressParser +{ + friend class SvAddressParser_Impl; + + ::std::vector< OUString > + m_vAddresses; + +public: + SvAddressParser(const OUString& rInput); + + ~SvAddressParser(); + + sal_Int32 Count() const { return m_vAddresses.size(); } + + const OUString& GetEmailAddress(sal_Int32 nIndex) const + { + return m_vAddresses[nIndex]; + } +}; + +#endif // INCLUDED_SVL_ADRPARSE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/aeitem.hxx b/include/svl/aeitem.hxx new file mode 100644 index 000000000..550c88d57 --- /dev/null +++ b/include/svl/aeitem.hxx @@ -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/. + * + * 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_SVL_AEITEM_HXX +#define INCLUDED_SVL_AEITEM_HXX + +#include <config_options.h> +#include <svl/svldllapi.h> +#include <svl/eitem.hxx> + +#include <cstddef> +#include <memory> +#include <vector> + +class UNLESS_MERGELIBS(SVL_DLLPUBLIC) SfxAllEnumItem final : public SfxPoolItem +{ + std::vector<OUString> m_Values; + +public: + explicit SfxAllEnumItem( sal_uInt16 nWhich); + SfxAllEnumItem( const SfxAllEnumItem & ); + virtual ~SfxAllEnumItem() override; + + void SetTextByPos( sal_uInt16 nPos, const OUString &rText ); + OUString const & GetTextByPos( sal_uInt16 nPos ) const; + sal_Int32 GetTextCount() const; + virtual SfxAllEnumItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool operator==( SfxPoolItem const & ) const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/asiancfg.hxx b/include/svl/asiancfg.hxx new file mode 100644 index 000000000..6ee88fe35 --- /dev/null +++ b/include/svl/asiancfg.hxx @@ -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 . + */ + +#ifndef INCLUDED_SVL_ASIANCFG_HXX +#define INCLUDED_SVL_ASIANCFG_HXX + +#include <sal/config.h> + +#include <memory> +#include <com/sun/star/uno/Sequence.hxx> +#include <svl/svldllapi.h> + +namespace com::sun::star::lang { + struct Locale; +} + +/// These constants define character compression in Asian text. +/// Must match the values in com::sun::star::text::CharacterCompressionType. +/// For bonus points, also appears to be directly stored in the ww8 file format. +enum class CharCompressType { + NONE, /// No Compression + PunctuationOnly, /// Only punctuation is compressed + PunctuationAndKana, /// Punctuation and Japanese Kana are compressed. + Invalid = 0xff /// only used in SC +}; + +class SVL_DLLPUBLIC SvxAsianConfig { +public: + SvxAsianConfig(); + ~SvxAsianConfig(); + SvxAsianConfig(const SvxAsianConfig&) = delete; + SvxAsianConfig& operator=( const SvxAsianConfig& ) = delete; + + void Commit(); + + bool IsKerningWesternTextOnly() const; + + void SetKerningWesternTextOnly(bool value); + + CharCompressType GetCharDistanceCompression() const; + + void SetCharDistanceCompression(CharCompressType value); + + css::uno::Sequence< css::lang::Locale > GetStartEndCharLocales() const; + + bool GetStartEndChars( + css::lang::Locale const & locale, OUString & startChars, + OUString & endChars) const; + + void SetStartEndChars( + css::lang::Locale const & locale, + OUString const * startChars, OUString const * endChars); + +private: + struct Impl; + + std::unique_ptr< Impl > impl_; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/broadcast.hxx b/include/svl/broadcast.hxx new file mode 100644 index 000000000..69a7f4ad0 --- /dev/null +++ b/include/svl/broadcast.hxx @@ -0,0 +1,96 @@ +/* -*- 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_SVL_BROADCAST_HXX +#define INCLUDED_SVL_BROADCAST_HXX + +#include <svl/svldllapi.h> + +#include <vector> + +class SvtListener; +class SfxHint; + +class SVL_DLLPUBLIC SvtBroadcaster +{ +public: + friend class SvtListener; + + typedef std::vector<SvtListener*> ListenersType; + +private: + const SvtBroadcaster& operator=(const SvtBroadcaster &) = delete; + + /** + * Ensure that the container doesn't contain any duplicated listener + * entries. As a side effect, the listeners get sorted by pointer values + * after this call. + */ + void Normalize() const; + + void Add( SvtListener* p ); + void Remove( SvtListener* p ); + +protected: + virtual void ListenersGone(); + +public: + SvtBroadcaster(); + SvtBroadcaster( const SvtBroadcaster &rBC ); + virtual ~SvtBroadcaster(); + + void Broadcast( const SfxHint &rHint ); + + ListenersType& GetAllListeners(); + const ListenersType& GetAllListeners() const; + + bool HasListeners() const; + + /** + * Listeners and broadcasters are M:N relationship. If you want to + * destruct them, you easily end up in O(M*N) situation; where for every + * listener, you iterate all broadcasters, to remove that one listener. + * + * To avoid that, use this call to announce to the broadcaster it is going + * to die, and the listeners do not have to bother with removing + * themselves from the broadcaster - the broadcaster will not broadcast + * anything after the PrepareForDesctruction() call anyway. + */ + void PrepareForDestruction(); + +private: + /// contains only one of each listener, which is enforced by SvtListener + mutable ListenersType maListeners; + + /// When the broadcaster is about to die, collect listeners that asked for removal. + mutable ListenersType maDestructedListeners; + + mutable sal_Int32 mnEmptySlots; + // The first item in maListeners that is not sorted. The container can become large, so this optimizes sorting. + mutable sal_Int32 mnListenersFirstUnsorted; + /// Indicate that this broadcaster will be destructed (we indicate this on all ScColumn's broadcasters during the ScTable destruction, eg.) + bool mbAboutToDie:1; + bool mbDisposing:1; + // Whether maDestructedListeners is sorted or not. + mutable bool mbDestNormalized:1; +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/cenumitm.hxx b/include/svl/cenumitm.hxx new file mode 100644 index 000000000..9428e095c --- /dev/null +++ b/include/svl/cenumitm.hxx @@ -0,0 +1,60 @@ +/* -*- 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_SVL_CENUMITM_HXX +#define INCLUDED_SVL_CENUMITM_HXX + +#include <svl/svldllapi.h> +#include <svl/poolitem.hxx> + +class SVL_DLLPUBLIC SfxEnumItemInterface: public SfxPoolItem +{ +protected: + explicit SfxEnumItemInterface(sal_uInt16 which): SfxPoolItem(which) {} + + SfxEnumItemInterface(const SfxEnumItemInterface &) = default; + +public: + + virtual bool operator ==(const SfxPoolItem & rItem) const override; + + virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, + OUString & rText, + const IntlWrapper&) const override; + + virtual bool QueryValue(css::uno::Any & rVal, sal_uInt8 = 0) const override; + + virtual bool PutValue(const css::uno::Any & rVal, sal_uInt8 ) override; + + virtual sal_uInt16 GetValueCount() const = 0; + + virtual sal_uInt16 GetEnumValue() const = 0; + + virtual void SetEnumValue(sal_uInt16 nValue) = 0; + + virtual bool HasBoolValue() const; + + virtual bool GetBoolValue() const; + + virtual void SetBoolValue(bool bValue); +}; + +#endif // INCLUDED_SVL_CENUMITM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/cintitem.hxx b/include/svl/cintitem.hxx new file mode 100644 index 000000000..bde59c399 --- /dev/null +++ b/include/svl/cintitem.hxx @@ -0,0 +1,176 @@ +/* -*- 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_SVL_CINTITEM_HXX +#define INCLUDED_SVL_CINTITEM_HXX + +#include <svl/svldllapi.h> +#include <tools/debug.hxx> +#include <svl/poolitem.hxx> + +class SVL_DLLPUBLIC CntByteItem: public SfxPoolItem +{ + sal_uInt8 m_nValue; + +public: + + CntByteItem(sal_uInt16 which, sal_uInt8 nTheValue): + SfxPoolItem(which), m_nValue(nTheValue) {} + + virtual bool operator ==(const SfxPoolItem & rItem) const override; + + virtual bool GetPresentation(SfxItemPresentation, + MapUnit, MapUnit, + OUString & rText, + const IntlWrapper&) + const override; + + virtual bool QueryValue(css::uno::Any& rVal, + sal_uInt8 nMemberId = 0) const override; + + virtual bool PutValue(const css::uno::Any& rVal, + sal_uInt8 nMemberId) override; + + virtual CntByteItem* Clone(SfxItemPool * = nullptr) const override; + + sal_uInt8 GetValue() const { return m_nValue; } + + inline void SetValue(sal_uInt8 nTheValue); +}; + +inline void CntByteItem::SetValue(sal_uInt8 nTheValue) +{ + DBG_ASSERT(GetRefCount() == 0, "CntByteItem::SetValue(): Pooled item"); + m_nValue = nTheValue; +} + +class SVL_DLLPUBLIC CntUInt16Item: public SfxPoolItem +{ + sal_uInt16 m_nValue; + +public: + + CntUInt16Item(sal_uInt16 which, sal_uInt16 nTheValue): + SfxPoolItem(which), m_nValue(nTheValue) + {} + + virtual bool operator ==(const SfxPoolItem & rItem) const override; + + virtual bool GetPresentation(SfxItemPresentation, + MapUnit, MapUnit, + OUString & rText, + const IntlWrapper&) + const override; + + virtual bool QueryValue(css::uno::Any& rVal, + sal_uInt8 nMemberId = 0) const override; + + virtual bool PutValue(const css::uno::Any& rVal, + sal_uInt8 nMemberId) override; + + virtual CntUInt16Item* Clone(SfxItemPool * = nullptr) const override; + + sal_uInt16 GetValue() const { return m_nValue; } + + inline void SetValue(sal_uInt16 nTheValue); +}; + +inline void CntUInt16Item::SetValue(sal_uInt16 nTheValue) +{ + DBG_ASSERT(GetRefCount() == 0, "CntUInt16Item::SetValue(): Pooled item"); + m_nValue = nTheValue; +} + +class SVL_DLLPUBLIC CntInt32Item: public SfxPoolItem +{ + sal_Int32 m_nValue; + +public: + + CntInt32Item(sal_uInt16 which, sal_Int32 nTheValue): + SfxPoolItem(which), m_nValue(nTheValue) + {} + + virtual bool operator ==(const SfxPoolItem & rItem) const override; + + virtual bool GetPresentation(SfxItemPresentation, + MapUnit, MapUnit, + OUString & rText, + const IntlWrapper&) + const override; + + virtual bool QueryValue(css::uno::Any& rVal, + sal_uInt8 nMemberId = 0) const override; + + virtual bool PutValue(const css::uno::Any& rVal, + sal_uInt8 nMemberId) override; + + virtual CntInt32Item* Clone(SfxItemPool * = nullptr) const override; + + sal_Int32 GetValue() const { return m_nValue; } + + inline void SetValue(sal_Int32 nTheValue); +}; + +inline void CntInt32Item::SetValue(sal_Int32 nTheValue) +{ + DBG_ASSERT(GetRefCount() == 0, "CntInt32Item::SetValue(): Pooled item"); + m_nValue = nTheValue; +} + +class SVL_DLLPUBLIC CntUInt32Item: public SfxPoolItem +{ + sal_uInt32 m_nValue; + +public: + + CntUInt32Item(sal_uInt16 which, sal_uInt32 nTheValue): + SfxPoolItem(which), m_nValue(nTheValue) + {} + + virtual bool operator ==(const SfxPoolItem & rItem) const override; + + virtual bool GetPresentation(SfxItemPresentation, + MapUnit, MapUnit, + OUString & rText, + const IntlWrapper&) + const override; + + virtual bool QueryValue(css::uno::Any& rVal, + sal_uInt8 nMemberId = 0) const override; + + virtual bool PutValue(const css::uno::Any& rVal, + sal_uInt8 nMemberId) override; + + virtual CntUInt32Item* Clone(SfxItemPool * = nullptr) const override; + + sal_uInt32 GetValue() const { return m_nValue; } + + inline void SetValue(sal_uInt32 nTheValue); +}; + +inline void CntUInt32Item::SetValue(sal_uInt32 nTheValue) +{ + DBG_ASSERT(GetRefCount() == 0, "CntUInt32Item::SetValue(): Pooled item"); + m_nValue = nTheValue; +} + +#endif // INCLUDED_SVL_CINTITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/cjkoptions.hxx b/include/svl/cjkoptions.hxx new file mode 100644 index 000000000..7b646d118 --- /dev/null +++ b/include/svl/cjkoptions.hxx @@ -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/. + * + * 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_SVL_CJKOPTIONS_HXX +#define INCLUDED_SVL_CJKOPTIONS_HXX + +#include <svl/svldllapi.h> +#include <unotools/options.hxx> +#include <memory> + +class SvtCJKOptions_Impl; + +// class SvtCJKOptions -------------------------------------------------- + +class SVL_DLLPUBLIC SvtCJKOptions final : public utl::detail::Options +{ +private: + std::shared_ptr<SvtCJKOptions_Impl> pImpl; + +public: + + enum EOption + { + E_CJKFONT, + E_VERTICALTEXT, + E_ASIANTYPOGRAPHY, + E_JAPANESEFIND, + E_RUBY, + E_CHANGECASEMAP, + E_DOUBLELINES, + E_EMPHASISMARKS, + E_VERTICALCALLOUT, + E_ALL // special one for IsAnyEnabled()/SetAll() functionality + }; + + // bDontLoad is for referencing purposes only + SvtCJKOptions(bool bDontLoad = false); + virtual ~SvtCJKOptions() override; + + bool IsCJKFontEnabled() const; + bool IsVerticalTextEnabled() const; + bool IsAsianTypographyEnabled() const; + bool IsJapaneseFindEnabled() const; + bool IsRubyEnabled() const; + bool IsChangeCaseMapEnabled() const; + bool IsDoubleLinesEnabled() const; + + void SetAll(bool bSet); + bool IsAnyEnabled() const; + bool IsReadOnly(EOption eOption) const; +}; + +#endif // INCLUDED_SVL_CJKOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/converter.hxx b/include/svl/converter.hxx new file mode 100644 index 000000000..0aeceeac2 --- /dev/null +++ b/include/svl/converter.hxx @@ -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/. + * + * 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_SVL_CONVERTER_HXX +#define INCLUDED_SVL_CONVERTER_HXX + +#include <svl/svldllapi.h> + +class SvDbaseConverter +{ +public: + SVL_DLLPUBLIC static sal_Int32 ConvertPrecisionToDbase(sal_Int32 _nLen, sal_Int32 _nScale); + SVL_DLLPUBLIC static sal_Int32 ConvertPrecisionToOdbc(sal_Int32 _nLen, sal_Int32 _nScale); +}; + +#endif //_CONVERTER_HXX_ + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/cryptosign.hxx b/include/svl/cryptosign.hxx new file mode 100644 index 000000000..61905360a --- /dev/null +++ b/include/svl/cryptosign.hxx @@ -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 <sal/types.h> + +#include <vector> + +#include <rtl/strbuf.hxx> +#include <rtl/ustring.hxx> + +#include <com/sun/star/uno/Reference.hxx> + +#include <svl/svldllapi.h> + +namespace com { +namespace sun { +namespace star { +namespace security { + class XCertificate; } +}}} + +class SvStream; +struct SignatureInformation; + +namespace svl { + +namespace crypto { + +/// Converts a hex-encoded string into a byte array. +SVL_DLLPUBLIC std::vector<unsigned char> DecodeHexString(const OString& rHex); + +/// Helper to cryptographically sign and verify +/// arbitrary data blocks. +class SVL_DLLPUBLIC Signing +{ +public: + + Signing(const css::uno::Reference<css::security::XCertificate>& xCertificate) : + m_xCertificate(xCertificate) + { + } + + /// Add a range to sign. + /// Note: for efficiency this takes a naked pointer, which must remain valid + /// until this object is discarded. + void AddDataRange(const void* pData, sal_Int32 size) + { + m_dataBlocks.emplace_back(pData, size); + } + + void SetSignTSA(const OUString& tsa) { m_aSignTSA = tsa; } + void SetSignPassword(const OUString& password) { m_aSignPassword = password; } + + /// Signs one or more data blocks (as a single, contiguous, array). + /// Returns the signature (in PKCS#7 format) as string (hex). + bool Sign(OStringBuffer& rCMSHexBuffer); + + /// Verify and get Signature Information given a byte array. + static bool Verify(const std::vector<unsigned char>& aData, + const bool bNonDetached, + const std::vector<unsigned char>& aSignature, + SignatureInformation& rInformation); + + /// Verify and get Signature Information given a signature and stream. + static bool Verify(SvStream& rStream, + const std::vector<std::pair<size_t, size_t>>& aByteRanges, + const bool bNonDetached, + const std::vector<unsigned char>& aSignature, + SignatureInformation& rInformation); + +private: + /// The certificate to use for signing. + const css::uno::Reference<css::security::XCertificate> m_xCertificate; + + /// Data blocks (pointer-size pairs). + std::vector<std::pair<const void*, sal_Int32>> m_dataBlocks; + OUString m_aSignTSA; + OUString m_aSignPassword; +}; + +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + diff --git a/include/svl/ctloptions.hxx b/include/svl/ctloptions.hxx new file mode 100644 index 000000000..5140907dd --- /dev/null +++ b/include/svl/ctloptions.hxx @@ -0,0 +1,85 @@ +/* -*- 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_SVL_CTLOPTIONS_HXX +#define INCLUDED_SVL_CTLOPTIONS_HXX + +#include <svl/svldllapi.h> +#include <unotools/options.hxx> +#include <memory> + +class SvtCTLOptions_Impl; + +// class SvtCTLOptions -------------------------------------------------------- + +class SVL_DLLPUBLIC SvtCTLOptions final : public utl::detail::Options +{ +private: + std::shared_ptr<SvtCTLOptions_Impl> m_pImpl; + +public: + + // bDontLoad is for referencing purposes only + SvtCTLOptions( bool bDontLoad = false ); + virtual ~SvtCTLOptions() override; + + void SetCTLFontEnabled( bool _bEnabled ); + bool IsCTLFontEnabled() const; + + void SetCTLSequenceChecking( bool _bEnabled ); + bool IsCTLSequenceChecking() const; + + void SetCTLSequenceCheckingRestricted( bool _bEnable ); + bool IsCTLSequenceCheckingRestricted() const; + + void SetCTLSequenceCheckingTypeAndReplace( bool _bEnable ); + bool IsCTLSequenceCheckingTypeAndReplace() const; + + enum CursorMovement + { + MOVEMENT_LOGICAL = 0, + MOVEMENT_VISUAL + }; + void SetCTLCursorMovement( CursorMovement _eMovement ); + CursorMovement GetCTLCursorMovement() const; + + enum TextNumerals + { + NUMERALS_ARABIC = 0, + NUMERALS_HINDI, + NUMERALS_SYSTEM, + NUMERALS_CONTEXT + }; + void SetCTLTextNumerals( TextNumerals _eNumerals ); + TextNumerals GetCTLTextNumerals() const; + + enum EOption + { + E_CTLFONT, + E_CTLSEQUENCECHECKING, + E_CTLCURSORMOVEMENT, + E_CTLTEXTNUMERALS, + E_CTLSEQUENCECHECKINGRESTRICTED, + E_CTLSEQUENCECHECKINGTYPEANDREPLACE + }; + bool IsReadOnly(EOption eOption) const; +}; + +#endif // INCLUDED_SVL_CTLOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/currencytable.hxx b/include/svl/currencytable.hxx new file mode 100644 index 000000000..275391649 --- /dev/null +++ b/include/svl/currencytable.hxx @@ -0,0 +1,44 @@ +/* -*- 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/. +*/ + +#ifndef INCLUDED_SVL_CURRENCYTABLE_HXX +#define INCLUDED_SVL_CURRENCYTABLE_HXX + +#include <svl/svldllapi.h> +#include <svl/zforlist.hxx> + +#include <vector> +#include <memory> + +class SVL_DLLPUBLIC NfCurrencyTable +{ + typedef std::vector<std::unique_ptr<NfCurrencyEntry>> DataType; + DataType maData; + + NfCurrencyTable(NfCurrencyTable const&) = delete; + void operator=(NfCurrencyTable const&) = delete; + +public: + NfCurrencyTable() {} + typedef DataType::iterator iterator; + typedef DataType::const_iterator const_iterator; + + iterator begin(); + + NfCurrencyEntry& operator[] ( size_t i ); + const NfCurrencyEntry& operator[] ( size_t i ) const; + + size_t size() const; + + void insert(const iterator& it, std::unique_ptr<NfCurrencyEntry> p); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/custritm.hxx b/include/svl/custritm.hxx new file mode 100644 index 000000000..d46fe011a --- /dev/null +++ b/include/svl/custritm.hxx @@ -0,0 +1,69 @@ +/* -*- 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_SVL_CUSTRITM_HXX +#define INCLUDED_SVL_CUSTRITM_HXX + +#include <svl/svldllapi.h> +#include <svl/poolitem.hxx> +#include <cassert> + +class SVL_DLLPUBLIC CntUnencodedStringItem: public SfxPoolItem +{ + OUString m_aValue; + +public: + + CntUnencodedStringItem(sal_uInt16 which): SfxPoolItem(which) + {} + + CntUnencodedStringItem(sal_uInt16 which, const OUString & rTheValue): + SfxPoolItem(which), m_aValue(rTheValue) + {} + + virtual bool operator ==(const SfxPoolItem & rItem) const override; + virtual bool operator <(const SfxPoolItem & rItem) const override; + virtual bool IsSortable() const override { return true; } + + virtual bool GetPresentation(SfxItemPresentation, + MapUnit, MapUnit, + OUString & rText, + const IntlWrapper&) const override; + + virtual bool QueryValue(css::uno::Any& rVal, + sal_uInt8 nMemberId = 0) const override; + + virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override; + + virtual CntUnencodedStringItem* Clone(SfxItemPool * = nullptr) const override; + + const OUString & GetValue() const { return m_aValue; } + + inline void SetValue(const OUString & rTheValue); +}; + +inline void CntUnencodedStringItem::SetValue(const OUString & rTheValue) +{ + assert(GetRefCount() == 0 && "cannot modify name of pooled item"); + m_aValue = rTheValue; +} + +#endif // INCLUDED_SVL_CUSTRITM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/documentlockfile.hxx b/include/svl/documentlockfile.hxx new file mode 100644 index 000000000..f35e8a765 --- /dev/null +++ b/include/svl/documentlockfile.hxx @@ -0,0 +1,69 @@ +/* -*- 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_SVL_DOCUMENTLOCKFILE_HXX +#define INCLUDED_SVL_DOCUMENTLOCKFILE_HXX + +#include <svl/svldllapi.h> + +#include <svl/lockfilecommon.hxx> + +namespace com::sun::star::io { class XInputStream; } +namespace com::sun::star::io { class XOutputStream; } + +namespace svt { + +/// Generalized class for LO and MSO lockfile handling. +class SVL_DLLPUBLIC GenDocumentLockFile : public LockFileCommon +{ +public: + GenDocumentLockFile(const OUString& aLockFileURL); + virtual ~GenDocumentLockFile() override; + + bool CreateOwnLockFile(); + bool OverwriteOwnLockFile(); + /// Delete the Lockfile, if current user is the owner + virtual void RemoveFile(); + /// Only delete lockfile, disregarding ownership + void RemoveFileDirectly(); + + virtual LockFileEntry GetLockData() = 0; + +protected: + virtual void WriteEntryToStream( const LockFileEntry& aEntry, const css::uno::Reference< css::io::XOutputStream >& xStream ) = 0; + virtual css::uno::Reference< css::io::XInputStream > OpenStream(); +}; + +/// Class implementing reading and writing LO lockfiles. +class SVL_DLLPUBLIC DocumentLockFile final : public GenDocumentLockFile +{ + virtual void WriteEntryToStream( const LockFileEntry& aEntry, const css::uno::Reference< css::io::XOutputStream >& xStream ) override; + +public: + DocumentLockFile( const OUString& aOrigURL ); + virtual ~DocumentLockFile() override; + + virtual LockFileEntry GetLockData() override; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/eitem.hxx b/include/svl/eitem.hxx new file mode 100644 index 000000000..114e451c0 --- /dev/null +++ b/include/svl/eitem.hxx @@ -0,0 +1,107 @@ +/* -*- 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_SVL_EITEM_HXX +#define INCLUDED_SVL_EITEM_HXX + +#include <svl/svldllapi.h> +#include <svl/cenumitm.hxx> + + +template<typename EnumT> +class SAL_DLLPUBLIC_RTTI SfxEnumItem : public SfxEnumItemInterface +{ + EnumT m_nValue; + +protected: + explicit SfxEnumItem(sal_uInt16 const nWhich, EnumT const nValue) + : SfxEnumItemInterface(nWhich) + , m_nValue(nValue) + { } + + SfxEnumItem(const SfxEnumItem &) = default; + +public: + + EnumT GetValue() const { return m_nValue; } + + void SetValue(EnumT nTheValue) + { + assert(GetRefCount() == 0 && "SfxEnumItem::SetValue(): Pooled item"); + m_nValue = nTheValue; + } + + virtual sal_uInt16 GetEnumValue() const override + { + return static_cast<sal_uInt16>(GetValue()); + } + + virtual void SetEnumValue(sal_uInt16 nTheValue) override + { + SetValue(static_cast<EnumT>(nTheValue)); + } + + virtual bool operator==(SfxPoolItem const & other) const override + { + return SfxEnumItemInterface::operator==(other) && + m_nValue == static_cast<const SfxEnumItem<EnumT> &>(other).m_nValue; + } +}; + +class SVL_DLLPUBLIC SfxBoolItem + : public SfxPoolItem +{ + bool m_bValue; + +public: + static SfxPoolItem* CreateDefault(); + + explicit SfxBoolItem(sal_uInt16 const nWhich = 0, bool const bValue = false) + : SfxPoolItem(nWhich) + , m_bValue(bValue) + { } + + bool GetValue() const { return m_bValue; } + + void SetValue(bool const bTheValue) { m_bValue = bTheValue; } + + // SfxPoolItem + virtual bool operator ==(const SfxPoolItem & rItem) const override; + + virtual bool GetPresentation(SfxItemPresentation, + MapUnit, MapUnit, + OUString & rText, + const IntlWrapper&) + const override; + + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; + + virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 = 0) const override; + + virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8) override; + + + virtual SfxBoolItem* Clone(SfxItemPool * = nullptr) const override; + + virtual OUString GetValueTextByVal(bool bTheValue) const; +}; + +#endif // INCLUDED_SVL_EITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/filenotation.hxx b/include/svl/filenotation.hxx new file mode 100644 index 000000000..d33e442b9 --- /dev/null +++ b/include/svl/filenotation.hxx @@ -0,0 +1,62 @@ +/* -*- 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_SVL_FILENOTATION_HXX +#define INCLUDED_SVL_FILENOTATION_HXX + +#include <svl/svldllapi.h> +#include <rtl/ustring.hxx> + + +namespace svt +{ + + + //= OFileNotation + + class SVL_DLLPUBLIC OFileNotation final + { + public: + enum NOTATION + { + N_SYSTEM, + N_URL + }; + + OFileNotation( const OUString& _rUrlOrPath ); + OFileNotation( const OUString& _rUrlOrPath, NOTATION _eInputNotation ); + + OUString get(NOTATION _eOutputNotation) const; + + private: + SVL_DLLPRIVATE void construct( const OUString& _rUrlOrPath ); + SVL_DLLPRIVATE bool implInitWithSystemNotation( const OUString& _rSystemPath ); + SVL_DLLPRIVATE void implInitWithURLNotation( const OUString& _rURL ); + + OUString m_sSystem; + OUString m_sFileURL; + }; + + +} // namespace svt + + +#endif // INCLUDED_SVL_FILENOTATION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/flagitem.hxx b/include/svl/flagitem.hxx new file mode 100644 index 000000000..70b968f2c --- /dev/null +++ b/include/svl/flagitem.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 . + */ +#ifndef INCLUDED_SVL_FLAGITEM_HXX +#define INCLUDED_SVL_FLAGITEM_HXX + +#include <svl/poolitem.hxx> +#include <svl/svldllapi.h> +#include <tools/debug.hxx> + +class SvStream; + +class SVL_DLLPUBLIC SfxFlagItem: public SfxPoolItem +{ + sal_uInt16 nVal; + +public: + + explicit SfxFlagItem( sal_uInt16 nWhich = 0, sal_uInt16 nValue = 0 ); + + virtual sal_uInt8 GetFlagCount() const; + + virtual bool operator==( const SfxPoolItem& ) const override; + + virtual SfxFlagItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool GetPresentation( SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString & rText, + const IntlWrapper& ) const override; + sal_uInt16 GetValue() const { return nVal; } + void SetValue( sal_uInt16 nNewVal ) { + DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" ); + nVal = nNewVal; + } + bool GetFlag( sal_uInt8 nFlag ) const { return (nVal & ( 1<<nFlag)); } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/fstathelper.hxx b/include/svl/fstathelper.hxx new file mode 100644 index 000000000..f6e4343f4 --- /dev/null +++ b/include/svl/fstathelper.hxx @@ -0,0 +1,58 @@ +/* -*- 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_SVL_FSTATHELPER_HXX +#define INCLUDED_SVL_FSTATHELPER_HXX + +#include <rtl/ustring.hxx> +#include <svl/svldllapi.h> + +class Date; +namespace tools { class Time; } + +namespace FStatHelper { + +/** Return the modified time and date stamp for this URL. + + @param URL the asking URL + + @param pDate if unequal 0, the function set the date stamp + + @param pTime if unequal 0, the function set the time stamp + + @return it was be able to get the date/time stamp +*/ +SVL_DLLPUBLIC bool GetModifiedDateTimeOfFile( const OUString& rURL, + Date* pDate, tools::Time* pTime ); + +/** Return if under the URL a document exist. This is only a wrapper for the + UCB.IsContent. +*/ +SVL_DLLPUBLIC bool IsDocument( const OUString& rURL ); + +/** Return if under the URL a folder exist. This is only a wrapper for the + UCB.isFolder. +*/ +SVL_DLLPUBLIC bool IsFolder( const OUString& rURL ); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/globalnameitem.hxx b/include/svl/globalnameitem.hxx new file mode 100644 index 000000000..edbb56273 --- /dev/null +++ b/include/svl/globalnameitem.hxx @@ -0,0 +1,54 @@ +/* -*- 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_SVL_GLOBALNAMEITEM_HXX +#define INCLUDED_SVL_GLOBALNAMEITEM_HXX + +#include <svl/svldllapi.h> +#include <tools/globname.hxx> +#include <svl/poolitem.hxx> + +class SVL_DLLPUBLIC SfxGlobalNameItem final : public SfxPoolItem +{ + SvGlobalName m_aName; + +public: + static SfxPoolItem* CreateDefault(); + + SfxGlobalNameItem(); + SfxGlobalNameItem( sal_uInt16 nWhich, const SvGlobalName& ); + virtual ~SfxGlobalNameItem() override; + + SfxGlobalNameItem(SfxGlobalNameItem const &) = default; + SfxGlobalNameItem(SfxGlobalNameItem &&) = default; + SfxGlobalNameItem & operator =(SfxGlobalNameItem const &) = delete; // due to SfxPoolItem + SfxGlobalNameItem & operator =(SfxGlobalNameItem &&) = delete; // due to SfxPoolItem + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual SfxGlobalNameItem* Clone( SfxItemPool *pPool = nullptr ) const override; + const SvGlobalName& GetValue() const { return m_aName; } + + virtual bool PutValue ( const css::uno::Any& rVal, + sal_uInt8 nMemberId ) override; + virtual bool QueryValue( css::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/grabbagitem.hxx b/include/svl/grabbagitem.hxx new file mode 100644 index 000000000..77a619aec --- /dev/null +++ b/include/svl/grabbagitem.hxx @@ -0,0 +1,46 @@ +/* -*- 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/. + */ +#ifndef INCLUDED_SVL_GRABBAGITEM_HXX +#define INCLUDED_SVL_GRABBAGITEM_HXX + +#include <map> + +#include <svl/svldllapi.h> +#include <svl/poolitem.hxx> +#include <com/sun/star/uno/Any.hxx> + +/// Grab bag item provides a string-any map for keys with untyped values. +class SVL_DLLPUBLIC SfxGrabBagItem final : public SfxPoolItem +{ +private: + std::map<OUString, css::uno::Any> m_aMap; + +public: + SfxGrabBagItem(); + SfxGrabBagItem(sal_uInt16 nWhich); + ~SfxGrabBagItem() override; + + SfxGrabBagItem(SfxGrabBagItem const&) = default; + SfxGrabBagItem(SfxGrabBagItem&&) = default; + SfxGrabBagItem& operator=(SfxGrabBagItem const&) = delete; // due to SfxPoolItem + SfxGrabBagItem& operator=(SfxGrabBagItem&&) = delete; // due to SfxPoolItem + + const std::map<OUString, css::uno::Any>& GetGrabBag() const { return m_aMap; } + + std::map<OUString, css::uno::Any>& GetGrabBag() { return m_aMap; } + + bool operator==(const SfxPoolItem& rItem) const override; + SfxGrabBagItem* Clone(SfxItemPool* pPool = nullptr) const override; + + bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override; + bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override; +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/gridprinter.hxx b/include/svl/gridprinter.hxx new file mode 100644 index 000000000..52a01e33b --- /dev/null +++ b/include/svl/gridprinter.hxx @@ -0,0 +1,39 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SVL_GRIDPRINTER_HXX +#define INCLUDED_SVL_GRIDPRINTER_HXX + +#include <rtl/ustring.hxx> +#include <svl/svldllapi.h> +#include <memory> + +namespace svl { + +/** + * Print 2-dimensional data in a nice and pleasant fashion. Useful when + * debugging grid layout data. + */ +class SVL_DLLPUBLIC GridPrinter +{ + struct Impl; + std::unique_ptr<Impl> mpImpl; + +public: + GridPrinter( size_t nRows, size_t nCols, bool bPrint ); + ~GridPrinter(); + void set( size_t nRow, size_t nCol, const OUString& rStr ); + void print( const char* pHeader ) const; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx new file mode 100644 index 000000000..708986e31 --- /dev/null +++ b/include/svl/hint.hxx @@ -0,0 +1,219 @@ +/* -*- 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_SVL_HINT_HXX +#define INCLUDED_SVL_HINT_HXX + +#include <ostream> + +#include <sal/types.h> +#include <svl/svldllapi.h> + +enum class SfxHintId { + NONE, + Dying, + NameChanged, + TitleChanged, + DataChanged, + DocChanged, + UpdateDone, + Deinitializing, + ModeChanged, + ColorsChanged, + LanguageChanged, + RedlineChanged, + DocumentRepair, + +// VCL text hints + TextParaInserted, + TextParaRemoved, + TextParaContentChanged, + TextHeightChanged, + TextFormatPara, + TextFormatted, + TextModified, + TextProcessNotifications, + TextViewScrolled, + TextViewSelectionChanged, + TextViewCaretChanged, + +// BASIC hints + BasicDataWanted, + BasicDataChanged, + BasicInfoWanted, + BasicStart, + BasicStop, + +// SVX edit source + EditSourceParasMoved, + EditSourceSelectionChanged, + +// SC hints + ScDataChanged, + ScTableOpDirty, + ScCalcAll, + ScReference, + ScDrawLayerNew, + ScDbAreasChanged, + ScAreasChanged, + ScTablesChanged, + ScDrawChanged, + ScDocNameChanged, + ScAreaLinksChanged, + ScShowRangeFinder, + ScDocSaved, + ScForceSetTab, + ScNavigatorUpdateAll, + ScAnyDataChanged, + ScPrintOptions, + ScRefModeChanged, + ScKillEditView, + ScKillEditViewNoPaint, + ScHiddenRowsChanged, + ScSelectionChanged, + ScClearCache, + +// SC accessibility hints + ScAccTableChanged, + ScAccCursorChanged, + ScAccVisAreaChanged, + ScAccEnterEditMode, + ScAccLeaveEditMode, + ScAccMakeDrawLayer, + ScAccWindowResized, + + +// SFX stylesheet + StyleSheetCreated, // new + StyleSheetModified, // changed + StyleSheetChanged, // erased and re-created (replaced) + StyleSheetErased, // erased + StyleSheetInDestruction, // in the process of being destructed + +// STARMATH + MathFormatChanged, + +// Sw + SwDrawViewsCreated, + SwSplitNodeOperation, + SwSectionFrameMoveAndDelete, + + ThisIsAnSdrHint // used to avoid dynamic_cast +}; + +template< typename charT, typename traits > +inline std::basic_ostream<charT, traits> & operator <<( + std::basic_ostream<charT, traits> & stream, const SfxHintId& id ) +{ + switch(id) + { + case SfxHintId::NONE: return stream << "NONE"; + case SfxHintId::Dying: return stream << "Dying"; + case SfxHintId::NameChanged: return stream << "NameChanged"; + case SfxHintId::TitleChanged: return stream << "TitleChanged"; + case SfxHintId::DataChanged: return stream << "DataChanged"; + case SfxHintId::DocChanged: return stream << "DocChanged"; + case SfxHintId::UpdateDone: return stream << "UpdateDone"; + case SfxHintId::Deinitializing: return stream << "Deinitializing"; + case SfxHintId::ModeChanged: return stream << "ModeChanged"; + case SfxHintId::ColorsChanged: return stream << "ColorsChanged"; + case SfxHintId::LanguageChanged: return stream << "LanguageChanged"; + case SfxHintId::RedlineChanged: return stream << "RedlineChanged"; + case SfxHintId::DocumentRepair: return stream << "DocumentRepair"; + case SfxHintId::TextParaInserted: return stream << "TextParaInserted"; + case SfxHintId::TextParaRemoved: return stream << "TextParaRemoved"; + case SfxHintId::TextParaContentChanged: return stream << "TextParaContentChanged"; + case SfxHintId::TextHeightChanged: return stream << "TextHeightChanged"; + case SfxHintId::TextFormatPara: return stream << "TextFormatPara"; + case SfxHintId::TextFormatted: return stream << "TextFormatted"; + case SfxHintId::TextModified: return stream << "TextModified"; + case SfxHintId::TextProcessNotifications: return stream << "TextProcessNotifications"; + case SfxHintId::TextViewScrolled: return stream << "TextViewScrolled"; + case SfxHintId::TextViewSelectionChanged: return stream << "TextViewSelectionChanged"; + case SfxHintId::TextViewCaretChanged: return stream << "TextViewCaretChanged"; + case SfxHintId::BasicDataWanted: return stream << "BasicDataWanted"; + case SfxHintId::BasicDataChanged: return stream << "BasicDataChanged"; + case SfxHintId::BasicInfoWanted: return stream << "BasicInfoWanted"; + case SfxHintId::BasicStart: return stream << "BasicStart"; + case SfxHintId::BasicStop: return stream << "BasicStop"; + case SfxHintId::EditSourceParasMoved: return stream << "EditSourceParasMoved"; + case SfxHintId::EditSourceSelectionChanged: return stream << "EditSourceSelectionChanged"; + case SfxHintId::ScDataChanged: return stream << "ScDataChanged"; + case SfxHintId::ScTableOpDirty: return stream << "ScTableOpDirty"; + case SfxHintId::ScCalcAll: return stream << "ScCalcAll"; + case SfxHintId::ScReference: return stream << "ScReference"; + case SfxHintId::ScDrawLayerNew: return stream << "ScDrawLayerNew"; + case SfxHintId::ScDbAreasChanged: return stream << "ScDbAreasChanged"; + case SfxHintId::ScAreasChanged: return stream << "ScAreasChanged"; + case SfxHintId::ScTablesChanged: return stream << "ScTablesChanged"; + case SfxHintId::ScDrawChanged: return stream << "ScDrawChanged"; + case SfxHintId::ScDocNameChanged: return stream << "ScDocNameChanged"; + case SfxHintId::ScAreaLinksChanged: return stream << "ScAreaLinksChanged"; + case SfxHintId::ScShowRangeFinder: return stream << "ScShowRangeFinder"; + case SfxHintId::ScDocSaved: return stream << "ScDocSaved"; + case SfxHintId::ScForceSetTab: return stream << "ScForceSetTab"; + case SfxHintId::ScNavigatorUpdateAll: return stream << "ScNavigatorUpdateAll"; + case SfxHintId::ScAnyDataChanged: return stream << "ScAnyDataChanged"; + case SfxHintId::ScPrintOptions: return stream << "ScPrintOptions"; + case SfxHintId::ScRefModeChanged: return stream << "ScRefModeChanged"; + case SfxHintId::ScKillEditView: return stream << "ScKillEditView"; + case SfxHintId::ScKillEditViewNoPaint: return stream << "ScKillEditViewNoPaint"; + case SfxHintId::ScHiddenRowsChanged: return stream << "ScHiddenRowsChanged"; + case SfxHintId::ScSelectionChanged: return stream << "ScSelectionChanged"; + case SfxHintId::ScClearCache: return stream << "ScClearCache"; + case SfxHintId::ScAccTableChanged: return stream << "ScAccTableChanged"; + case SfxHintId::ScAccCursorChanged: return stream << "ScAccCursorChanged"; + case SfxHintId::ScAccVisAreaChanged: return stream << "ScAccVisAreaChanged"; + case SfxHintId::ScAccEnterEditMode: return stream << "ScAccEnterEditMode"; + case SfxHintId::ScAccLeaveEditMode: return stream << "ScAccLeaveEditMode"; + case SfxHintId::ScAccMakeDrawLayer: return stream << "ScAccMakeDrawLayer"; + case SfxHintId::ScAccWindowResized: return stream << "ScAccWindowResized"; + case SfxHintId::StyleSheetCreated: return stream << "StyleSheetCreated"; + case SfxHintId::StyleSheetModified: return stream << "StyleSheetModified"; + case SfxHintId::StyleSheetChanged: return stream << "StyleSheetChanged"; + case SfxHintId::StyleSheetErased: return stream << "StyleSheetErased"; + case SfxHintId::StyleSheetInDestruction: return stream << "StyleSheetInDestruction"; + case SfxHintId::MathFormatChanged: return stream << "MathFormatChanged"; + case SfxHintId::SwDrawViewsCreated: return stream << "SwDrawViewsCreated"; + case SfxHintId::SwSplitNodeOperation: return stream << "SwSplitNodeOperation"; + case SfxHintId::SwSectionFrameMoveAndDelete: return stream << "SwSectionFrameMoveAndDelete"; + case SfxHintId::ThisIsAnSdrHint: return stream << "SdrHint"; + default: return stream << "unk(" << std::to_string(int(id)) << ")"; + } +} + +class SVL_DLLPUBLIC SfxHint +{ +private: + SfxHintId mnId; +public: + SfxHint() : mnId(SfxHintId::NONE) {} + explicit SfxHint( SfxHintId nId ) : mnId(nId) {} + virtual ~SfxHint() COVERITY_NOEXCEPT_FALSE; + + SfxHint(SfxHint const &) = default; + SfxHint(SfxHint &&) = default; + SfxHint & operator =(SfxHint const &) = default; + SfxHint & operator =(SfxHint &&) = default; + + SfxHintId GetId() const { return mnId; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/ilstitem.hxx b/include/svl/ilstitem.hxx new file mode 100644 index 000000000..af4932999 --- /dev/null +++ b/include/svl/ilstitem.hxx @@ -0,0 +1,55 @@ +/* -*- 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_SVL_ILSTITEM_HXX +#define INCLUDED_SVL_ILSTITEM_HXX + +#include <svl/svldllapi.h> +#include <svl/poolitem.hxx> +#include <vector> + +namespace com::sun::star::uno { template <class E> class Sequence; } + +class SVL_DLLPUBLIC SfxIntegerListItem final : public SfxPoolItem +{ + std::vector < sal_Int32 > m_aList; + +public: + static SfxPoolItem* CreateDefault(); + SfxIntegerListItem(); + SfxIntegerListItem( sal_uInt16 nWhich, const ::std::vector < sal_Int32 >& rList ); + SfxIntegerListItem( sal_uInt16 nWhich, const css::uno::Sequence < sal_Int32 >& rList ); + virtual ~SfxIntegerListItem() override; + + SfxIntegerListItem(SfxIntegerListItem const &) = default; + SfxIntegerListItem(SfxIntegerListItem &&) = default; + SfxIntegerListItem & operator =(SfxIntegerListItem const &) = delete; // due to SfxPoolItem + SfxIntegerListItem & operator =(SfxIntegerListItem &&) = delete; // due to SfxPoolItem + + const std::vector< sal_Int32 >& GetList() const { return m_aList; } + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual SfxIntegerListItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool PutValue ( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; +}; + +#endif // INCLUDED_SVL_ILSTITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/imageitm.hxx b/include/svl/imageitm.hxx new file mode 100644 index 000000000..ccecc5356 --- /dev/null +++ b/include/svl/imageitm.hxx @@ -0,0 +1,50 @@ +/* -*- 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_SVL_IMAGEITM_HXX +#define INCLUDED_SVL_IMAGEITM_HXX + +#include <svl/svldllapi.h> +#include <svl/intitem.hxx> +#include <memory> + +struct SfxImageItem_Impl; +class SVL_DLLPUBLIC SfxImageItem final : public SfxInt16Item +{ + std::unique_ptr<SfxImageItem_Impl> pImpl; +public: + static SfxPoolItem* CreateDefault(); + SfxImageItem( sal_uInt16 nWhich = 0 ); + SfxImageItem( const SfxImageItem& ); + virtual ~SfxImageItem() override; + + virtual SfxImageItem* Clone( SfxItemPool* pPool = nullptr ) const override; + virtual bool operator==( const SfxPoolItem& ) const override; + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; + + void SetRotation( long nValue ); + long GetRotation() const; + void SetMirrored( bool bSet ); + bool IsMirrored() const; +}; + +#endif // _SFX_IMAGEITM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/inethist.hxx b/include/svl/inethist.hxx new file mode 100644 index 000000000..21f7b6e2f --- /dev/null +++ b/include/svl/inethist.hxx @@ -0,0 +1,107 @@ +/* -*- 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_SVL_INETHIST_HXX +#define INCLUDED_SVL_INETHIST_HXX + +#include <svl/SfxBroadcaster.hxx> +#include <svl/hint.hxx> +#include <svl/svldllapi.h> +#include <tools/urlobj.hxx> +#include <memory> + +class INetURLHistory_Impl; +class SVL_DLLPUBLIC INetURLHistory final : public SfxBroadcaster +{ + /** Representation. + */ + std::unique_ptr<INetURLHistory_Impl> m_pImpl; + + /** Construction/Destruction. + */ + SAL_DLLPRIVATE INetURLHistory(); + SAL_DLLPRIVATE virtual ~INetURLHistory() override; + + /** Implementation. + */ + SAL_DLLPRIVATE static void NormalizeUrl_Impl (INetURLObject &rUrl); + + void PutUrl_Impl (const INetURLObject &rUrl); + bool QueryUrl_Impl (const INetURLObject &rUrl); + + /** Not implemented. + */ + INetURLHistory (const INetURLHistory&) = delete; + INetURLHistory& operator= (const INetURLHistory&) = delete; + +public: + /** GetOrCreate. + */ + static INetURLHistory* GetOrCreate(); + + /** QueryProtocol. + */ + bool QueryProtocol (INetProtocol eProto) const + { + return ((eProto == INetProtocol::File ) || + (eProto == INetProtocol::Ftp ) || + (eProto == INetProtocol::Http ) || + (eProto == INetProtocol::Https) ); + } + + /** QueryUrl. + */ + bool QueryUrl (const INetURLObject &rUrl) + { + if (QueryProtocol (rUrl.GetProtocol())) + return QueryUrl_Impl (rUrl); + else + return false; + } + + bool QueryUrl (const OUString &rUrl) + { + INetProtocol eProto = + INetURLObject::CompareProtocolScheme (rUrl); + if (QueryProtocol (eProto)) + return QueryUrl_Impl (INetURLObject (rUrl)); + else + return false; + } + + /** PutUrl. + */ + void PutUrl (const INetURLObject &rUrl) + { + if (QueryProtocol (rUrl.GetProtocol())) + PutUrl_Impl (rUrl); + } +}; + +// broadcasted from PutUrl(). +class SVL_DLLPUBLIC INetURLHistoryHint final : public SfxHint +{ + const INetURLObject* pObj; +public: + explicit INetURLHistoryHint( const INetURLObject* Object ) : pObj(Object) {} + const INetURLObject* GetObject() const { return pObj; } +}; + +#endif // INCLUDED_SVL_INETHIST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/inettype.hxx b/include/svl/inettype.hxx new file mode 100644 index 000000000..6d5d01852 --- /dev/null +++ b/include/svl/inettype.hxx @@ -0,0 +1,236 @@ +/* -*- 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_SVL_INETTYPE_HXX +#define INCLUDED_SVL_INETTYPE_HXX + +#include <svl/svldllapi.h> +#include <tools/inetmime.hxx> + + +/** Definitions for frequently used media type names. + */ +#define CONTENT_TYPE_STR_APP_OCTSTREAM "application/octet-stream" +#define CONTENT_TYPE_STR_APP_PDF "application/pdf" +#define CONTENT_TYPE_STR_APP_RTF "application/rtf" +#define CONTENT_TYPE_STR_APP_VND_CALC "application/vnd.stardivision.calc" +#define CONTENT_TYPE_STR_APP_VND_CHART "application/vnd.stardivision.chart" +#define CONTENT_TYPE_STR_APP_VND_DRAW "application/vnd.stardivision.draw" +#define CONTENT_TYPE_STR_APP_VND_IMAGE "application/vnd.stardivision.image" +#define CONTENT_TYPE_STR_APP_VND_IMPRESSPACKED "application/vnd.stardivision.impress-packed" +#define CONTENT_TYPE_STR_APP_VND_IMPRESS "application/vnd.stardivision.impress" +#define CONTENT_TYPE_STR_APP_VND_MAIL "application/vnd.stardivision.mail" +#define CONTENT_TYPE_STR_APP_VND_MATH "application/vnd.stardivision.math" +#define CONTENT_TYPE_STR_APP_VND_NEWS "application/vnd.stardivision.news" +#define CONTENT_TYPE_STR_APP_VND_OUTTRAY "application/vnd.stardivision.outtray" +#define CONTENT_TYPE_STR_APP_VND_TEMPLATE "application/vnd.stardivision.template" +#define CONTENT_TYPE_STR_APP_VND_WRITER_GLOBAL "application/vnd.stardivision.writer-global" +#define CONTENT_TYPE_STR_APP_VND_WRITER_WEB "application/vnd.stardivision.writer-web" +#define CONTENT_TYPE_STR_APP_VND_WRITER "application/vnd.stardivision.writer" +#define CONTENT_TYPE_STR_APP_FRAMESET "application/x-frameset" +#define CONTENT_TYPE_STR_APP_GALLERY_THEME "application/x-gallery-theme" +#define CONTENT_TYPE_STR_APP_GALLERY "application/x-gallery" +#define CONTENT_TYPE_STR_APP_JAR "application/x-jar" +#define CONTENT_TYPE_STR_APP_MACRO "application/x-macro" +#define CONTENT_TYPE_STR_APP_MSEXCEL_TEMPL "application/x-msexcel-template" +#define CONTENT_TYPE_STR_APP_MSEXCEL "application/x-msexcel" +#define CONTENT_TYPE_STR_APP_MSPPOINT_TEMPL "application/x-mspowerpoint-template" +#define CONTENT_TYPE_STR_APP_MSPPOINT "application/x-mspowerpoint" +#define CONTENT_TYPE_STR_APP_MSWORD_TEMPL "application/x-msword-template" +#define CONTENT_TYPE_STR_APP_MSWORD "application/x-msword" +#define CONTENT_TYPE_STR_APP_STARCALC "application/x-starcalc" +#define CONTENT_TYPE_STR_APP_STARCHART "application/x-starchart" +#define CONTENT_TYPE_STR_APP_STARDRAW "application/x-stardraw" +#define CONTENT_TYPE_STR_APP_STARHELP "application/x-starhelp" +#define CONTENT_TYPE_STR_APP_STARIMAGE "application/x-starimage" +#define CONTENT_TYPE_STR_APP_STARIMPRESS "application/x-starimpress" +#define CONTENT_TYPE_STR_APP_STARMAIL_SDM "application/x-starmail-sdm" +#define CONTENT_TYPE_STR_APP_STARMAIL_SMD "application/x-starmail-smd" +#define CONTENT_TYPE_STR_APP_STARMATH "application/x-starmath" +#define CONTENT_TYPE_STR_APP_STARWRITER_GLOB "application/x-starwriter-global" +#define CONTENT_TYPE_STR_APP_STARWRITER "application/x-starwriter" +#define CONTENT_TYPE_STR_APP_CDE_CALENDAR_APP "application/x-sun-ae-file" +#define CONTENT_TYPE_STR_APP_ZIP "application/x-zip-compressed" +#define CONTENT_TYPE_STR_AUDIO_AIFF "audio/aiff" +#define CONTENT_TYPE_STR_AUDIO_BASIC "audio/basic" +#define CONTENT_TYPE_STR_AUDIO_MIDI "audio/midi" +#define CONTENT_TYPE_STR_AUDIO_VORBIS "audio/vorbis" +#define CONTENT_TYPE_STR_AUDIO_WAV "audio/wav" +#define CONTENT_TYPE_STR_AUDIO_WEBM "audio/webm" +#define CONTENT_TYPE_STR_X_CNT_FSYSBOX ".chaos/fsys-box" +#define CONTENT_TYPE_STR_X_CNT_FSYSFOLDER ".chaos/fsys-folder" +#define CONTENT_TYPE_STR_X_CNT_FSYSSPECIALFOLDER ".chaos/fsys-special-folder" +#define CONTENT_TYPE_STR_IMAGE_GENERIC "image/generic" +#define CONTENT_TYPE_STR_IMAGE_GIF "image/gif" +#define CONTENT_TYPE_STR_IMAGE_JPEG "image/jpeg" +#define CONTENT_TYPE_STR_IMAGE_PCX "image/pcx" +#define CONTENT_TYPE_STR_IMAGE_PNG "image/png" +#define CONTENT_TYPE_STR_IMAGE_TIFF "image/tiff" +#define CONTENT_TYPE_STR_IMAGE_BMP "image/x-MS-bmp" +#define CONTENT_TYPE_STR_INET_MSG_RFC822 "message/rfc822" +#define CONTENT_TYPE_STR_INET_MULTI_ALTERNATIVE "multipart/alternative" +#define CONTENT_TYPE_STR_INET_MULTI_DIGEST "multipart/digest" +#define CONTENT_TYPE_STR_INET_MULTI_MIXED "multipart/mixed" +#define CONTENT_TYPE_STR_INET_MULTI_PARALLEL "multipart/parallel" +#define CONTENT_TYPE_STR_INET_MULTI_RELATED "multipart/related" +#define CONTENT_TYPE_STR_TEXT_ICALENDAR "text/calendar" +#define CONTENT_TYPE_STR_TEXT_HTML "text/html" +#define CONTENT_TYPE_STR_TEXT_PLAIN "text/plain" +#define CONTENT_TYPE_STR_TEXT_XMLICALENDAR "text/x-icalxml" +#define CONTENT_TYPE_STR_TEXT_URL "text/x-url" +#define CONTENT_TYPE_STR_TEXT_VCALENDAR "text/x-vCalendar" +#define CONTENT_TYPE_STR_TEXT_VCARD "text/x-vCard" +#define CONTENT_TYPE_STR_VIDEO_MSVIDEO "video/x-msvideo" +#define CONTENT_TYPE_STR_VIDEO_THEORA "video/theora" +#define CONTENT_TYPE_STR_VIDEO_VDO "video/vdo" +#define CONTENT_TYPE_STR_VIDEO_WEBM "audio/webm" +#define CONTENT_TYPE_STR_X_STARMAIL "x-starmail" +#define CONTENT_TYPE_STR_X_VRML "x-world/x-vrml" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_WRITER "application/vnd.sun.xml.writer" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_CALC "application/vnd.sun.xml.calc" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_IMPRESS "application/vnd.sun.xml.impress" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_DRAW "application/vnd.sun.xml.draw" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_CHART "application/vnd.sun.xml.chart" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_MATH "application/vnd.sun.xml.math" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_WRITER_GLOBAL "application/vnd.sun.xml.writer-global" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_IMPRESSPACKED "application/vnd.sun.xml.impress-packed" + + +/** Definitions for matching parts of URIs. + */ +#define INETTYPE_URL_PROT_DATA "data" +#define INETTYPE_URL_PROT_FILE "file" +#define INETTYPE_URL_PROT_HTTP "http" +#define INETTYPE_URL_PROT_HTTPS "https" +#define INETTYPE_URL_PROT_MACRO "macro" +#define INETTYPE_URL_PROT_MAILTO "mailto" +#define INETTYPE_URL_PROT_PRIVATE "private" + +enum INetContentType +{ + CONTENT_TYPE_UNKNOWN, + CONTENT_TYPE_APP_OCTSTREAM, + CONTENT_TYPE_APP_PDF, + CONTENT_TYPE_APP_RTF, + CONTENT_TYPE_APP_MSWORD, + CONTENT_TYPE_APP_MSWORD_TEMPL, + CONTENT_TYPE_APP_STARCALC, + CONTENT_TYPE_APP_STARCHART, + CONTENT_TYPE_APP_STARDRAW, + CONTENT_TYPE_APP_STARHELP, + CONTENT_TYPE_APP_STARIMAGE, + CONTENT_TYPE_APP_STARIMPRESS, + CONTENT_TYPE_APP_STARMATH, + CONTENT_TYPE_APP_STARWRITER, + CONTENT_TYPE_APP_ZIP, + CONTENT_TYPE_AUDIO_AIFF, + CONTENT_TYPE_AUDIO_BASIC, + CONTENT_TYPE_AUDIO_MIDI, + CONTENT_TYPE_AUDIO_VORBIS, + CONTENT_TYPE_AUDIO_WAV, + CONTENT_TYPE_AUDIO_WEBM, + CONTENT_TYPE_IMAGE_GIF, + CONTENT_TYPE_IMAGE_JPEG, + CONTENT_TYPE_IMAGE_PCX, + CONTENT_TYPE_IMAGE_PNG, + CONTENT_TYPE_IMAGE_TIFF, + CONTENT_TYPE_IMAGE_BMP, + CONTENT_TYPE_TEXT_HTML, + CONTENT_TYPE_TEXT_PLAIN, + CONTENT_TYPE_TEXT_URL, + CONTENT_TYPE_TEXT_VCARD, + CONTENT_TYPE_VIDEO_MSVIDEO, + CONTENT_TYPE_VIDEO_THEORA, + CONTENT_TYPE_VIDEO_VDO, + CONTENT_TYPE_VIDEO_WEBM, + CONTENT_TYPE_X_CNT_FSYSBOX, + CONTENT_TYPE_X_CNT_FSYSFOLDER, + CONTENT_TYPE_X_STARMAIL, + CONTENT_TYPE_X_VRML, + CONTENT_TYPE_APP_GALLERY, + CONTENT_TYPE_APP_GALLERY_THEME, + CONTENT_TYPE_APP_STARWRITER_GLOB, + CONTENT_TYPE_APP_STARMAIL_SDM, + CONTENT_TYPE_APP_STARMAIL_SMD, + CONTENT_TYPE_APP_VND_CALC, + CONTENT_TYPE_APP_VND_CHART, + CONTENT_TYPE_APP_VND_DRAW, + CONTENT_TYPE_APP_VND_IMAGE, + CONTENT_TYPE_APP_VND_IMPRESS, + CONTENT_TYPE_APP_VND_MAIL, + CONTENT_TYPE_APP_VND_MATH, + CONTENT_TYPE_APP_VND_WRITER, + CONTENT_TYPE_APP_VND_WRITER_GLOBAL, + CONTENT_TYPE_APP_VND_WRITER_WEB, + CONTENT_TYPE_APP_FRAMESET, + CONTENT_TYPE_APP_MACRO, + CONTENT_TYPE_X_CNT_FSYSSPECIALFOLDER, + CONTENT_TYPE_APP_VND_TEMPLATE, + CONTENT_TYPE_IMAGE_GENERIC, + CONTENT_TYPE_APP_VND_NEWS, + CONTENT_TYPE_APP_VND_OUTTRAY, + CONTENT_TYPE_APP_MSEXCEL, + CONTENT_TYPE_APP_MSEXCEL_TEMPL, + CONTENT_TYPE_APP_MSPPOINT, + CONTENT_TYPE_APP_MSPPOINT_TEMPL, + CONTENT_TYPE_TEXT_VCALENDAR, + CONTENT_TYPE_TEXT_ICALENDAR, + CONTENT_TYPE_TEXT_XMLICALENDAR, + CONTENT_TYPE_APP_CDE_CALENDAR_APP, + CONTENT_TYPE_INET_MESSAGE_RFC822, + CONTENT_TYPE_INET_MULTIPART_ALTERNATIVE, + CONTENT_TYPE_INET_MULTIPART_DIGEST, + CONTENT_TYPE_INET_MULTIPART_PARALLEL, + CONTENT_TYPE_INET_MULTIPART_RELATED, + CONTENT_TYPE_INET_MULTIPART_MIXED, + CONTENT_TYPE_APP_VND_IMPRESSPACKED, + CONTENT_TYPE_APP_JAR, + CONTENT_TYPE_APP_VND_SUN_XML_WRITER, + CONTENT_TYPE_APP_VND_SUN_XML_CALC, + CONTENT_TYPE_APP_VND_SUN_XML_IMPRESS, + CONTENT_TYPE_APP_VND_SUN_XML_DRAW, + CONTENT_TYPE_APP_VND_SUN_XML_CHART, + CONTENT_TYPE_APP_VND_SUN_XML_MATH, + CONTENT_TYPE_APP_VND_SUN_XML_WRITER_GLOBAL, + CONTENT_TYPE_APP_VND_SUN_XML_IMPRESSPACKED, + CONTENT_TYPE_LAST = CONTENT_TYPE_APP_VND_SUN_XML_IMPRESSPACKED +}; + + +class SVL_DLLPUBLIC INetContentTypes +{ +public: + static INetContentType GetContentType(OUString const & rTypeName); + + static OUString GetContentType(INetContentType eTypeID); + + static INetContentType GetContentType4Extension(OUString const & rExtension); + + static INetContentType GetContentTypeFromURL(OUString const & rURL); + + static bool GetExtensionFromURL(OUString const & rURL, OUString & rExtension); + + static bool parse(OUString const & rMediaType, OUString & rType, + OUString & rSubType, + INetContentTypeParameterList * pParameters = nullptr); +}; + +#endif // INCLUDED_SVL_INETTYPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/instrm.hxx b/include/svl/instrm.hxx new file mode 100644 index 000000000..6ddccfeaf --- /dev/null +++ b/include/svl/instrm.hxx @@ -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/. + * + * 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_SVL_INSTRM_HXX +#define INCLUDED_SVL_INSTRM_HXX + +#include <svl/svldllapi.h> +#include <com/sun/star/uno/Reference.h> +#include <tools/stream.hxx> +#include <memory> + +namespace com::sun::star::io { + class XInputStream; + class XSeekable; +} + +class SvDataPipe_Impl; + + +class SVL_DLLPUBLIC SvInputStream final : public SvStream +{ + css::uno::Reference< css::io::XInputStream > m_xStream; + css::uno::Reference< css::io::XSeekable > m_xSeekable; + std::unique_ptr<SvDataPipe_Impl> m_pPipe; + sal_uInt64 m_nSeekedFrom; + + SVL_DLLPRIVATE bool open(); + + SVL_DLLPRIVATE virtual std::size_t GetData(void * pData, std::size_t nSize) override; + + SVL_DLLPRIVATE virtual std::size_t PutData(void const *, std::size_t) override; + + SVL_DLLPRIVATE virtual sal_uInt64 SeekPos(sal_uInt64 nPos) override; + + SVL_DLLPRIVATE virtual void FlushData() override; + + SVL_DLLPRIVATE virtual void SetSize(sal_uInt64) override; + +public: + SvInputStream( css::uno::Reference< css::io::XInputStream > const & rTheStream ); + + virtual ~SvInputStream() override; +}; + +#endif // INCLUDED_SVL_INSTRM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/int64item.hxx b/include/svl/int64item.hxx new file mode 100644 index 000000000..70a502c64 --- /dev/null +++ b/include/svl/int64item.hxx @@ -0,0 +1,51 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SVL_INT64ITEM_HXX +#define INCLUDED_SVL_INT64ITEM_HXX + +#include <svl/poolitem.hxx> +#include <svl/svldllapi.h> + +class SVL_DLLPUBLIC SfxInt64Item final : public SfxPoolItem +{ + sal_Int64 mnValue; + +public: + SfxInt64Item( sal_uInt16 nWhich, sal_Int64 nVal ); + + virtual ~SfxInt64Item() override; + + SfxInt64Item(SfxInt64Item const &) = default; + SfxInt64Item(SfxInt64Item &&) = default; + SfxInt64Item & operator =(SfxInt64Item const &) = delete; // due to SfxPoolItem; + SfxInt64Item & operator =(SfxInt64Item &&) = delete; // due to SfxPoolItem + + virtual bool operator== ( const SfxPoolItem& rItem ) const override; + + virtual bool GetPresentation( + SfxItemPresentation, MapUnit, MapUnit, + OUString& rText, const IntlWrapper& rIntlWrapper ) const override; + + virtual bool QueryValue( + css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + + virtual bool PutValue( + const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; + + virtual SfxInt64Item* Clone( SfxItemPool* pOther = nullptr ) const override; + + sal_Int64 GetValue() const { return mnValue;} + +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/intitem.hxx b/include/svl/intitem.hxx new file mode 100644 index 000000000..92999568b --- /dev/null +++ b/include/svl/intitem.hxx @@ -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/. + * + * 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_SVL_INTITEM_HXX +#define INCLUDED_SVL_INTITEM_HXX + +#include <svl/svldllapi.h> +#include <svl/cintitem.hxx> +#include <boost/property_tree/ptree_fwd.hpp> + + +class SVL_DLLPUBLIC SfxByteItem: public CntByteItem +{ +public: + static SfxPoolItem* CreateDefault(); + + explicit SfxByteItem(sal_uInt16 which = 0, sal_uInt8 nValue = 0): + CntByteItem(which, nValue) {} + + virtual SfxByteItem* Clone(SfxItemPool * = nullptr) const override + { return new SfxByteItem(*this); } +}; + +class SVL_DLLPUBLIC SfxInt16Item: public SfxPoolItem +{ + sal_Int16 m_nValue; + +public: + static SfxPoolItem* CreateDefault(); + + explicit SfxInt16Item(sal_uInt16 which = 0, sal_Int16 nTheValue = 0): + SfxPoolItem(which), m_nValue(nTheValue) + {} + + virtual bool operator ==(const SfxPoolItem & rItem) const override; + + virtual bool GetPresentation(SfxItemPresentation, + MapUnit, MapUnit, + OUString & rText, + const IntlWrapper&) + const override; + + virtual boost::property_tree::ptree dumpAsJSON() const override; + + virtual bool QueryValue( css::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const override; + + virtual bool PutValue( const css::uno::Any& rVal, + sal_uInt8 nMemberId ) override; + + virtual SfxInt16Item* Clone(SfxItemPool * = nullptr) const override; + + sal_Int16 GetValue() const { return m_nValue; } + + inline void SetValue(sal_Int16 nTheValue); +}; + +inline void SfxInt16Item::SetValue(sal_Int16 nTheValue) +{ + DBG_ASSERT(GetRefCount() == 0, "SfxInt16Item::SetValue(); Pooled item"); + m_nValue = nTheValue; +} + + +class SVL_DLLPUBLIC SfxUInt16Item: public CntUInt16Item +{ +public: + static SfxPoolItem* CreateDefault(); + + explicit SfxUInt16Item(sal_uInt16 which = 0, sal_uInt16 nValue = 0): + CntUInt16Item(which, nValue) {} + + virtual SfxUInt16Item* Clone(SfxItemPool * = nullptr) const override + { return new SfxUInt16Item(*this); } + + void dumpAsXml(xmlTextWriterPtr pWriter) const override; + virtual boost::property_tree::ptree dumpAsJSON() const override; +}; + + +class SVL_DLLPUBLIC SfxInt32Item: public CntInt32Item +{ +public: + static SfxPoolItem* CreateDefault(); + + explicit SfxInt32Item(sal_uInt16 which = 0, sal_Int32 nValue = 0): + CntInt32Item(which, nValue) {} + + virtual SfxInt32Item* Clone(SfxItemPool * = nullptr) const override + { return new SfxInt32Item(*this); } + + void dumpAsXml(xmlTextWriterPtr pWriter) const override; + virtual boost::property_tree::ptree dumpAsJSON() const override; +}; + + +class SVL_DLLPUBLIC SfxUInt32Item: public CntUInt32Item +{ +public: + static SfxPoolItem* CreateDefault(); + + explicit SfxUInt32Item(sal_uInt16 which = 0, sal_uInt32 nValue = 0): + CntUInt32Item(which, nValue) {} + + virtual SfxUInt32Item* Clone(SfxItemPool * = nullptr) const override + { return new SfxUInt32Item(*this); } + + void dumpAsXml(xmlTextWriterPtr pWriter) const override; + virtual boost::property_tree::ptree dumpAsJSON() const override; +}; + +#endif // INCLUDED_SVL_INTITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/isethint.hxx b/include/svl/isethint.hxx new file mode 100644 index 000000000..a96f993dc --- /dev/null +++ b/include/svl/isethint.hxx @@ -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/. + * + * 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_SVL_ISETHINT_HXX +#define INCLUDED_SVL_ISETHINT_HXX + +#include <svl/svldllapi.h> +#include <svl/hint.hxx> +#include <memory> + +class SfxItemSet; + + +class SVL_DLLPUBLIC SfxItemSetHint final : public SfxHint +{ + std::unique_ptr<SfxItemSet> _pItemSet; + +public: + SfxItemSetHint( const SfxItemSet &rItemSet ); + virtual ~SfxItemSetHint() override; + + const SfxItemSet& GetItemSet() const { return *_pItemSet; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/itemiter.hxx b/include/svl/itemiter.hxx new file mode 100644 index 000000000..3d690c988 --- /dev/null +++ b/include/svl/itemiter.hxx @@ -0,0 +1,58 @@ +/* -*- 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_SVL_ITEMITER_HXX +#define INCLUDED_SVL_ITEMITER_HXX + +#include <svl/svldllapi.h> +#include <svl/itemset.hxx> + +class SfxPoolItem; + +class SVL_DLLPUBLIC SfxItemIter +{ + const SfxItemSet& m_rSet; + sal_uInt16 m_nStart; + sal_uInt16 m_nEnd; + sal_uInt16 m_nCurrent; + +public: + SfxItemIter( const SfxItemSet& rSet ); + ~SfxItemIter(); + + /// get item, or null if no items + const SfxPoolItem* GetCurItem() const + { + return m_rSet.m_nCount ? *(m_rSet.m_pItems.get() + m_nCurrent) : nullptr; + } + const SfxPoolItem* NextItem() { return (m_nCurrent < m_nEnd) ? ImplNextItem() : nullptr; } + + bool IsAtEnd() const { return m_nCurrent == m_nEnd; } + + sal_uInt16 GetCurPos() const { return m_nCurrent; } + sal_uInt16 GetFirstPos() const { return m_nStart; } + sal_uInt16 GetLastPos() const { return m_nEnd; } + +private: + const SfxPoolItem* ImplNextItem(); + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx new file mode 100644 index 000000000..10dbd3252 --- /dev/null +++ b/include/svl/itempool.hxx @@ -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 . + */ + +#ifndef INCLUDED_SVL_ITEMPOOL_HXX +#define INCLUDED_SVL_ITEMPOOL_HXX + +#include <svl/poolitem.hxx> +#include <svl/svldllapi.h> +#include <svl/typedwhich.hxx> +#include <memory> +#include <vector> +#include <o3tl/sorted_vector.hxx> + +class SfxBroadcaster; +struct SfxItemPool_Impl; + +struct SfxItemInfo +{ + sal_uInt16 _nSID; + bool _bPoolable; +}; + +class SfxItemPool; + +class SVL_DLLPUBLIC SfxItemPoolUser +{ +public: + virtual void ObjectInDestruction(const SfxItemPool& rSfxItemPool) = 0; + +protected: + ~SfxItemPoolUser() {} +}; + +/** Base class for providers of defaults of SfxPoolItems. + * + * The derived classes hold the concrete (const) instances which are referenced in several places + * (usually within a single document). + * This helps to lower the amount of calls to lifecycle methods, speeds up comparisons within a document + * and facilitates loading and saving of attributes. + */ +class SVL_DLLPUBLIC SfxItemPool +{ + friend struct SfxItemPool_Impl; + friend class SfxItemSet; + friend class SfxAllItemSet; + + const SfxItemInfo* pItemInfos; + std::unique_ptr<SfxItemPool_Impl> pImpl; + +public: + void AddSfxItemPoolUser(SfxItemPoolUser& rNewUser); + void RemoveSfxItemPoolUser(SfxItemPoolUser& rOldUser); + +private: + sal_uInt16 GetIndex_Impl(sal_uInt16 nWhich) const; + sal_uInt16 GetSize_Impl() const; + + SVL_DLLPRIVATE bool IsItemPoolable_Impl( sal_uInt16 nWhich ) const; + +public: + // for default SfxItemSet::CTOR, set default WhichRanges + void FillItemIdRanges_Impl( std::unique_ptr<sal_uInt16[]>& pWhichRanges ) const; + const sal_uInt16* GetFrozenIdRanges() const; + +protected: + static inline void ClearRefCount(SfxPoolItem& rItem); + static inline void AddRef(const SfxPoolItem& rItem); + static inline sal_uInt32 ReleaseRef(const SfxPoolItem& rItem, sal_uInt32 n = 1); + +public: + SfxItemPool( const SfxItemPool &rPool, + bool bCloneStaticDefaults = false ); + SfxItemPool( const OUString &rName, + sal_uInt16 nStart, sal_uInt16 nEnd, + const SfxItemInfo *pItemInfos, + std::vector<SfxPoolItem*> *pDefaults = nullptr ); + +protected: + virtual ~SfxItemPool(); + +public: + static void Free(SfxItemPool* pPool); + + SfxBroadcaster& BC(); + + void SetPoolDefaultItem( const SfxPoolItem& ); + + const SfxPoolItem* GetPoolDefaultItem( sal_uInt16 nWhich ) const; + template<class T> const T* GetPoolDefaultItem( TypedWhichId<T> nWhich ) const + { return static_cast<const T*>(GetPoolDefaultItem(sal_uInt16(nWhich))); } + + void ResetPoolDefaultItem( sal_uInt16 nWhich ); + + void SetDefaults(std::vector<SfxPoolItem*>* pDefaults); + void ClearDefaults(); + void ReleaseDefaults( bool bDelete = false ); + static void ReleaseDefaults( std::vector<SfxPoolItem*> *pDefaults, bool bDelete = false ); + + virtual MapUnit GetMetric( sal_uInt16 nWhich ) const; + void SetDefaultMetric( MapUnit eNewMetric ); + + /** Request string representation of pool items. + + This virtual function produces a string representation + from the respective SfxItemPool subclass' known SfxPoolItems. + + Subclasses, please override this method, and handle + SfxPoolItems that don't return useful/complete information on + SfxPoolItem::GetPresentation() + + This baseclass yields the unmodified string representation of + rItem. + + @param[in] rItem + SfxPoolItem to query the string representation of + + @param[in] ePresent + requested kind of representation - see SfxItemPresentation + + @param[in] eMetric + requested unit of measure of the representation + + @param[out] rText + string representation of 'rItem' + + @return true if it has a valid string representation + */ + virtual bool GetPresentation( const SfxPoolItem& rItem, + MapUnit ePresentationMetric, + OUString& rText, + const IntlWrapper& rIntlWrapper ) const; + virtual SfxItemPool* Clone() const; + const OUString& GetName() const; + + template<class T> const T& Put( std::unique_ptr<T> xItem, sal_uInt16 nWhich = 0 ) + { return static_cast<const T&>(PutImpl( *xItem.release(), nWhich, /*bPassingOwnership*/true)); } + template<class T> const T& Put( const T& rItem, sal_uInt16 nWhich = 0 ) + { return static_cast<const T&>(PutImpl( rItem, nWhich, /*bPassingOwnership*/false)); } + void Remove( const SfxPoolItem& ); + + const SfxPoolItem& GetDefaultItem( sal_uInt16 nWhich ) const; + template<class T> const T& GetDefaultItem( TypedWhichId<T> nWhich ) const + { return static_cast<const T&>(GetDefaultItem(sal_uInt16(nWhich))); } + + bool CheckItemInPool(const SfxPoolItem *) const; + + struct Item2Range + { + o3tl::sorted_vector<SfxPoolItem*>::const_iterator m_begin; + o3tl::sorted_vector<SfxPoolItem*>::const_iterator m_end; + o3tl::sorted_vector<SfxPoolItem*>::const_iterator const & begin() const { return m_begin; } + o3tl::sorted_vector<SfxPoolItem*>::const_iterator const & end() const { return m_end; } + }; + const SfxPoolItem * GetItem2Default(sal_uInt16 nWhich) const; + template<class T> const T* GetItem2Default( TypedWhichId<T> nWhich ) const + { return static_cast<const T*>(GetItem2Default(sal_uInt16(nWhich))); } + + sal_uInt32 GetItemCount2(sal_uInt16 nWhich) const; + Item2Range GetItemSurrogates(sal_uInt16 nWhich) const; + /* + This is only valid for SfxPoolItem that override IsSortable and operator<. + Returns a range of items defined by using operator<. + @param rNeedle must be the same type or a supertype of the pool items for nWhich. + */ + std::vector<const SfxPoolItem*> FindItemSurrogate(sal_uInt16 nWhich, SfxPoolItem const & rNeedle) const; + + sal_uInt16 GetFirstWhich() const; + sal_uInt16 GetLastWhich() const; + bool IsInRange( sal_uInt16 nWhich ) const; + void SetSecondaryPool( SfxItemPool *pPool ); + SfxItemPool* GetSecondaryPool() const; + SfxItemPool* GetMasterPool() const; + void FreezeIdRanges(); + + void Delete(); + + bool IsItemPoolable( sal_uInt16 nWhich ) const; + bool IsItemPoolable( const SfxPoolItem &rItem ) const + { return IsItemPoolable( rItem.Which() ); } + void SetItemInfos( const SfxItemInfo *pInfos ); + sal_uInt16 GetWhich( sal_uInt16 nSlot, bool bDeep = true ) const; + sal_uInt16 GetSlotId( sal_uInt16 nWhich ) const; + sal_uInt16 GetTrueWhich( sal_uInt16 nSlot, bool bDeep = true ) const; + sal_uInt16 GetTrueSlotId( sal_uInt16 nWhich ) const; + + static bool IsWhich(sal_uInt16 nId) { + return nId && nId <= SFX_WHICH_MAX; } + static bool IsSlot(sal_uInt16 nId) { + return nId && nId > SFX_WHICH_MAX; } + + void dumpAsXml(xmlTextWriterPtr pWriter) const; + +protected: + virtual const SfxPoolItem& PutImpl( const SfxPoolItem&, sal_uInt16 nWhich = 0, bool bPassingOwnership = false ); +private: + const SfxItemPool& operator=(const SfxItemPool &) = delete; + + //IDs below or equal are Which IDs, IDs above slot IDs + static const sal_uInt16 SFX_WHICH_MAX = 4999; +}; + +// only the pool may manipulate the reference counts +inline void SfxItemPool::ClearRefCount(SfxPoolItem& rItem) +{ + rItem.SetRefCount(0); +} + +// only the pool may manipulate the reference counts +inline void SfxItemPool::AddRef(const SfxPoolItem& rItem) +{ + rItem.AddRef(); +} + +// only the pool may manipulate the reference counts +inline sal_uInt32 SfxItemPool::ReleaseRef(const SfxPoolItem& rItem, sal_uInt32 n) +{ + return rItem.ReleaseRef(n); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/itemprop.hxx b/include/svl/itemprop.hxx new file mode 100644 index 000000000..6892f7b19 --- /dev/null +++ b/include/svl/itemprop.hxx @@ -0,0 +1,233 @@ +/* -*- 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_SVL_ITEMPROP_HXX +#define INCLUDED_SVL_ITEMPROP_HXX + +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <com/sun/star/beans/PropertyState.hpp> +#include <comphelper/propertysetinfo.hxx> +#include <cppuhelper/implbase.hxx> +#include <svl/itemset.hxx> +#include <svl/svldllapi.h> +#include <vector> +#include <memory> + +// values from com/sun/star/beans/PropertyAttribute +#define PROPERTY_NONE 0 + +/// map a property between beans::XPropertySet and SfxPoolItem +struct SfxItemPropertyMapEntry +{ + OUString aName; ///< name of property + sal_uInt16 nWID; ///< WhichId of SfxPoolItem + css::uno::Type aType; ///< UNO type of property + /// flag bitmap, @see css::beans::PropertyAttribute + sal_Int16 nFlags; + /// "member ID" to tell QueryValue/PutValue which property it is + /// (when multiple properties map to the same nWID) + sal_uInt8 nMemberId; + PropertyMoreFlags nMoreFlags; + + SfxItemPropertyMapEntry(OUString _aName, sal_uInt16 _nWID, css::uno::Type const & _rType, + sal_Int16 _nFlags, sal_uInt8 const _nMemberId, PropertyMoreFlags _nMoreFlags = PropertyMoreFlags::NONE) + : aName( _aName ) + , nWID( _nWID ) + , aType( _rType ) + , nFlags( _nFlags ) + , nMemberId( _nMemberId ) + , nMoreFlags( _nMoreFlags ) + { + assert(_nFlags <= 0x1ff ); + assert( (_nMemberId & 0x40) == 0 ); + // Verify that if METRIC_ITEM is set, we are one of the types supported by + // SvxUnoConvertToMM. + assert(!(_nMoreFlags & PropertyMoreFlags::METRIC_ITEM) || + ( (aType.getTypeClass() == css::uno::TypeClass_BYTE) + || (aType.getTypeClass() == css::uno::TypeClass_SHORT) + || (aType.getTypeClass() == css::uno::TypeClass_UNSIGNED_SHORT) + || (aType.getTypeClass() == css::uno::TypeClass_LONG) + || (aType.getTypeClass() == css::uno::TypeClass_UNSIGNED_LONG) + ) ); + } +}; + +struct SfxItemPropertySimpleEntry +{ + sal_uInt16 nWID; + css::uno::Type aType; + /// flag bitmap, @see css::beans::PropertyAttribute + sal_Int16 nFlags; + sal_uInt8 nMemberId; + PropertyMoreFlags nMoreFlags = PropertyMoreFlags::NONE; + + SfxItemPropertySimpleEntry() + : nWID( 0 ) + , nFlags( 0 ) + , nMemberId( 0 ) + { + } + + SfxItemPropertySimpleEntry(sal_uInt16 _nWID, css::uno::Type const & _rType, + sal_Int16 _nFlags) + : nWID( _nWID ) + , aType( _rType ) + , nFlags( _nFlags ) + , nMemberId( 0 ) + { + assert(_nFlags <= 0x1ff ); + } + + SfxItemPropertySimpleEntry( const SfxItemPropertyMapEntry* pMapEntry ) + : nWID( pMapEntry->nWID ) + , aType( pMapEntry->aType ) + , nFlags( pMapEntry->nFlags ) + , nMemberId( pMapEntry->nMemberId ) + , nMoreFlags( pMapEntry->nMoreFlags ) + { + } + +}; +struct SfxItemPropertyNamedEntry : public SfxItemPropertySimpleEntry +{ + OUString sName; + SfxItemPropertyNamedEntry( const OUString& rName, const SfxItemPropertySimpleEntry& rSimpleEntry) + : SfxItemPropertySimpleEntry( rSimpleEntry ) + , sName( rName ) +{ +} + +}; +typedef std::vector< SfxItemPropertyNamedEntry > PropertyEntryVector_t; +class SfxItemPropertyMap_Impl; +class SVL_DLLPUBLIC SfxItemPropertyMap +{ + std::unique_ptr<SfxItemPropertyMap_Impl> m_pImpl; +public: + SfxItemPropertyMap( const SfxItemPropertyMapEntry* pEntries ); + SfxItemPropertyMap( const SfxItemPropertyMap& rSource ); + ~SfxItemPropertyMap(); + + const SfxItemPropertySimpleEntry* getByName( const OUString &rName ) const; + css::uno::Sequence< css::beans::Property > const & getProperties() const; + /// @throws css::beans::UnknownPropertyException + css::beans::Property getPropertyByName( const OUString & rName ) const; + bool hasPropertyByName( const OUString& rName ) const; + + void mergeProperties( const css::uno::Sequence< css::beans::Property >& rPropSeq ); + PropertyEntryVector_t getPropertyEntries() const; + sal_uInt32 getSize() const; + +}; + +class SVL_DLLPUBLIC SfxItemPropertySet final +{ + SfxItemPropertyMap m_aMap; + mutable css::uno::Reference<css::beans::XPropertySetInfo> m_xInfo; + +public: + SfxItemPropertySet( const SfxItemPropertyMapEntry *pMap ) : + m_aMap(pMap) {} + ~SfxItemPropertySet(); + + /// @throws css::uno::RuntimeException + void getPropertyValue( const SfxItemPropertySimpleEntry& rEntry, + const SfxItemSet& rSet, + css::uno::Any& rAny) const; + /// @throws css::uno::RuntimeException + /// @throws css::beans::UnknownPropertyException + void getPropertyValue( const OUString &rName, + const SfxItemSet& rSet, + css::uno::Any& rAny) const; + /// @throws css::uno::RuntimeException + /// @throws css::beans::UnknownPropertyException + css::uno::Any + getPropertyValue( const OUString &rName, + const SfxItemSet& rSet ) const; + /// @throws css::uno::RuntimeException + /// @throws css::lang::IllegalArgumentException + void setPropertyValue( const SfxItemPropertySimpleEntry& rEntry, + const css::uno::Any& aVal, + SfxItemSet& rSet ) const; + /// @throws css::uno::RuntimeException + /// @throws css::lang::IllegalArgumentException + /// @throws css::beans::UnknownPropertyException + void setPropertyValue( const OUString& rPropertyName, + const css::uno::Any& aVal, + SfxItemSet& rSet ) const; + + /// @throws css::beans::UnknownPropertyException + css::beans::PropertyState + getPropertyState(const OUString& rName, const SfxItemSet& rSet)const; + css::beans::PropertyState + getPropertyState(const SfxItemPropertySimpleEntry& rEntry, const SfxItemSet& rSet) const + throw(); + + css::uno::Reference<css::beans::XPropertySetInfo> const & + getPropertySetInfo() const; + const SfxItemPropertyMap& getPropertyMap() const {return m_aMap;} +}; + +// workaround for incremental linking bugs in MSVC2015 +class SAL_DLLPUBLIC_TEMPLATE SfxItemPropertySetInfo_Base : public cppu::WeakImplHelper< css::beans::XPropertySetInfo > {}; + +class SVL_DLLPUBLIC SfxItemPropertySetInfo final : public SfxItemPropertySetInfo_Base +{ + SfxItemPropertyMap m_aOwnMap; + +public: + SfxItemPropertySetInfo(const SfxItemPropertyMap &rMap ); + SfxItemPropertySetInfo(const SfxItemPropertyMapEntry *pEntries ); + virtual ~SfxItemPropertySetInfo() override; + + virtual css::uno::Sequence< css::beans::Property > SAL_CALL + getProperties( ) override; + + virtual css::beans::Property SAL_CALL + getPropertyByName( const OUString& aName ) override; + + virtual sal_Bool SAL_CALL + hasPropertyByName( const OUString& Name ) override; + +}; + +// workaround for incremental linking bugs in MSVC2015 +class SAL_DLLPUBLIC_TEMPLATE SfxExtItemPropertySetInfo_Base : public cppu::WeakImplHelper< css::beans::XPropertySetInfo > {}; + +class SVL_DLLPUBLIC SfxExtItemPropertySetInfo final : public SfxExtItemPropertySetInfo_Base +{ + SfxItemPropertyMap aExtMap; +public: + SfxExtItemPropertySetInfo( + const SfxItemPropertyMapEntry *pMap, + const css::uno::Sequence<css::beans::Property>& rPropSeq ); + virtual ~SfxExtItemPropertySetInfo() override; + + virtual css::uno::Sequence< css::beans::Property > SAL_CALL + getProperties( ) override; + + virtual css::beans::Property SAL_CALL + getPropertyByName( const OUString& aName ) override; + + virtual sal_Bool SAL_CALL + hasPropertyByName( const OUString& Name ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx new file mode 100644 index 000000000..94ee142a2 --- /dev/null +++ b/include/svl/itemset.hxx @@ -0,0 +1,265 @@ +/* -*- 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_SVL_ITEMSET_HXX +#define INCLUDED_SVL_ITEMSET_HXX + +#include <sal/config.h> + +#include <cassert> +#include <cstddef> +#include <initializer_list> +#include <type_traits> +#include <memory> + +#include <svl/svldllapi.h> +#include <svl/poolitem.hxx> +#include <svl/typedwhich.hxx> + +class SfxItemPool; + +namespace svl { + +namespace detail { + +constexpr bool validRange(sal_uInt16 wid1, sal_uInt16 wid2) +{ return wid1 != 0 && wid1 <= wid2; } + +constexpr bool validGap(sal_uInt16 wid1, sal_uInt16 wid2) +{ return wid2 > wid1 && wid2 - wid1 > 1; } + +template<sal_uInt16 WID1, sal_uInt16 WID2> constexpr bool validRanges() +{ return validRange(WID1, WID2); } + +template<sal_uInt16 WID1, sal_uInt16 WID2, sal_uInt16 WID3, sal_uInt16... WIDs> +constexpr bool validRanges() { + return validRange(WID1, WID2) && validGap(WID2, WID3) + && validRanges<WID3, WIDs...>(); +} + +// The calculations in rangeSize and rangesSize cannot overflow, assuming +// std::size_t is no smaller than sal_uInt16: + +constexpr std::size_t rangeSize(sal_uInt16 wid1, sal_uInt16 wid2) { + assert(validRange(wid1, wid2)); + return wid2 - wid1 + 1; +} + +template<sal_uInt16 WID1, sal_uInt16 WID2> constexpr std::size_t rangesSize() +{ return rangeSize(WID1, WID2); } + +template<sal_uInt16 WID1, sal_uInt16 WID2, sal_uInt16 WID3, sal_uInt16... WIDs> +constexpr std::size_t rangesSize() +{ return rangeSize(WID1, WID2) + rangesSize<WID3, WIDs...>(); } + +} + +template<sal_uInt16... WIDs> struct Items {}; + +} + +class SAL_WARN_UNUSED SVL_DLLPUBLIC SfxItemSet +{ + friend class SfxItemIter; + + SfxItemPool* m_pPool; ///< pool that stores the items + const SfxItemSet* m_pParent; ///< derivation + std::unique_ptr<SfxPoolItem const*[]> + m_pItems; ///< array of items + sal_uInt16* m_pWhichRanges; ///< array of Which Ranges + sal_uInt16 m_nCount; ///< number of items + +friend class SfxItemPoolCache; +friend class SfxAllItemSet; + +private: + SVL_DLLPRIVATE void InitRanges_Impl(const sal_uInt16 *nWhichPairTable); + + SfxItemSet( + SfxItemPool & pool, std::initializer_list<sal_uInt16> wids, + std::size_t items); + +public: + SfxPoolItem const** GetItems_Impl() const { return m_pItems.get(); } + +private: + const SfxItemSet& operator=(const SfxItemSet &) = delete; + +protected: + // Notification-Callback + virtual void Changed( const SfxPoolItem& rOld, const SfxPoolItem& rNew ); + + void PutDirect(const SfxPoolItem &rItem); + + virtual const SfxPoolItem* PutImpl( const SfxPoolItem&, sal_uInt16 nWhich, bool bPassingOwnership ); + +public: + struct Pair { sal_uInt16 wid1, wid2; }; + + SfxItemSet( const SfxItemSet& ); + SfxItemSet( SfxItemSet&& ) noexcept; + + SfxItemSet( SfxItemPool&); + template<sal_uInt16... WIDs> SfxItemSet( + typename std::enable_if< + svl::detail::validRanges<WIDs...>(), SfxItemPool &>::type pool, + svl::Items<WIDs...>): + SfxItemSet(pool, {WIDs...}, svl::detail::rangesSize<WIDs...>()) {} + SfxItemSet( SfxItemPool&, std::initializer_list<Pair> wids ); + SfxItemSet( SfxItemPool&, const sal_uInt16* nWhichPairTable ); + virtual ~SfxItemSet(); + + virtual std::unique_ptr<SfxItemSet> Clone(bool bItems = true, SfxItemPool *pToPool = nullptr) const; + + // Get number of items + sal_uInt16 Count() const { return m_nCount; } + sal_uInt16 TotalCount() const; + + const SfxPoolItem& Get( sal_uInt16 nWhich, bool bSrchInParent = true ) const; + template<class T> + const T& Get( TypedWhichId<T> nWhich, bool bSrchInParent = true ) const + { + return static_cast<const T&>(Get(sal_uInt16(nWhich), bSrchInParent)); + } + + /** This method eases accessing single Items in the SfxItemSet. + + @param nId SlotId or the Item's WhichId + @param bSearchInParent also search in parent ItemSets + @returns 0 if the ItemSet does not contain an Item with the Id 'nWhich' + */ + const SfxPoolItem* GetItem(sal_uInt16 nWhich, bool bSearchInParent = true) const; + + /// Templatized version of GetItem() to directly return the correct type. + template<class T> const T* GetItem(sal_uInt16 nWhich, bool bSearchInParent = true) const + { + const SfxPoolItem* pItem = GetItem(nWhich, bSearchInParent); + const T* pCastedItem = dynamic_cast<const T*>(pItem); + + assert(!pItem || pCastedItem); // if it exists, must have the correct type + return pCastedItem; + } + template<class T> const T* GetItem( TypedWhichId<T> nWhich, bool bSearchInParent = true ) const + { + return GetItem<T>(sal_uInt16(nWhich), bSearchInParent); + } + + + /// Templatized static version of GetItem() to directly return the correct type if the SfxItemSet is available. + template<class T> static const T* GetItem(const SfxItemSet* pItemSet, sal_uInt16 nWhich, bool bSearchInParent) + { + if (pItemSet) + return pItemSet->GetItem<T>(nWhich, bSearchInParent); + + return nullptr; + } + template <class T> + static const T* GetItem(const SfxItemSet* pItemSet, TypedWhichId<T> nWhich, + bool bSearchInParent) + { + return GetItem<T>(pItemSet, static_cast<sal_uInt16>(nWhich), bSearchInParent); + } + + sal_uInt16 GetWhichByPos(sal_uInt16 nPos) const; + + SfxItemState GetItemState( sal_uInt16 nWhich, + bool bSrchInParent = true, + const SfxPoolItem **ppItem = nullptr ) const; + + bool HasItem(sal_uInt16 nWhich, const SfxPoolItem** ppItem = nullptr) const; + + void DisableItem(sal_uInt16 nWhich); + void InvalidateItem( sal_uInt16 nWhich ); + sal_uInt16 ClearItem( sal_uInt16 nWhich = 0); + void ClearInvalidItems(); + void InvalidateAllItems(); // HACK(via nWhich = 0) ??? + + inline void SetParent( const SfxItemSet* pNew ); + + // add, delete items, work on items +public: + const SfxPoolItem* Put( const SfxPoolItem& rItem, sal_uInt16 nWhich ) + { return PutImpl(rItem, nWhich, /*bPassingOwnership*/false); } + const SfxPoolItem* Put( std::unique_ptr<SfxPoolItem> xItem, sal_uInt16 nWhich ) + { return PutImpl(*xItem.release(), nWhich, /*bPassingOwnership*/true); } + const SfxPoolItem* Put( const SfxPoolItem& rItem ) + { return Put(rItem, rItem.Which()); } + const SfxPoolItem* Put( std::unique_ptr<SfxPoolItem> xItem ) + { auto nWhich = xItem->Which(); return Put(std::move(xItem), nWhich); } + bool Put( const SfxItemSet&, + bool bInvalidAsDefault = true ); + void PutExtended( const SfxItemSet&, + SfxItemState eDontCareAs, + SfxItemState eDefaultAs ); + + bool Set( const SfxItemSet&, bool bDeep = true ); + + void Intersect( const SfxItemSet& rSet ); + void MergeValues( const SfxItemSet& rSet ); + void Differentiate( const SfxItemSet& rSet ); + void MergeValue( const SfxPoolItem& rItem, bool bOverwriteDefaults = false ); + + SfxItemPool* GetPool() const { return m_pPool; } + const sal_uInt16* GetRanges() const { return m_pWhichRanges; } + void SetRanges( const sal_uInt16 *pRanges ); + void MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo ); + const SfxItemSet* GetParent() const { return m_pParent; } + + bool operator==(const SfxItemSet &) const; + + /** Compare possibly ignoring SfxItemPool pointer. + + This can be used to compare the content of two SfxItemSet even if they + don't share the same pool. EditTextObject::Equals(...,false) uses this + which is needed in ScGlobal::EETextObjEqual() for + ScPageHFItem::operator==() + + @param bComparePool + if <FALSE/> ignore SfxItemPool pointer, + if <TRUE/> compare also SfxItemPool pointer (identical to operator==()) + */ + bool Equals(const SfxItemSet &, bool bComparePool) const; + + void dumpAsXml(xmlTextWriterPtr pWriter) const; +}; + +inline void SfxItemSet::SetParent( const SfxItemSet* pNew ) +{ + m_pParent = pNew; +} + +class SVL_DLLPUBLIC SfxAllItemSet: public SfxItemSet + +// Handles all Ranges. Ranges are automatically modified by putting items. + +{ + sal_uInt16 nFree; + +public: + SfxAllItemSet( SfxItemPool &rPool ); + SfxAllItemSet( const SfxItemSet & ); + SfxAllItemSet( const SfxAllItemSet & ); + + virtual std::unique_ptr<SfxItemSet> Clone( bool bItems = true, SfxItemPool *pToPool = nullptr ) const override; +protected: + virtual const SfxPoolItem* PutImpl( const SfxPoolItem&, sal_uInt16 nWhich, bool bPassingOwnership ) override; +}; + +#endif // INCLUDED_SVL_ITEMSET_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/languageoptions.hxx b/include/svl/languageoptions.hxx new file mode 100644 index 000000000..5fc9c8624 --- /dev/null +++ b/include/svl/languageoptions.hxx @@ -0,0 +1,137 @@ +/* -*- 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_SVL_LANGUAGEOPTIONS_HXX +#define INCLUDED_SVL_LANGUAGEOPTIONS_HXX + +#include <svl/svldllapi.h> +#include <sal/types.h> +#include <o3tl/typed_flags_set.hxx> +#include <unotools/configitem.hxx> +#include <unotools/options.hxx> +#include <i18nlangtag/lang.h> +#include <memory> + +// class SvtLanguageOptions ---------------------------------------------------- + +// these defines can be ORed +// note these values DO NOT match the values in css::i18n::ScriptType +enum class SvtScriptType +{ + NONE = 0x00, + LATIN = 0x01, + ASIAN = 0x02, + COMPLEX = 0x04, + UNKNOWN = 0x08 // (only used in SC) if type has not been determined yet +}; +namespace o3tl +{ + template<> struct typed_flags<SvtScriptType> : is_typed_flags<SvtScriptType, 0x0f> {}; +} + +class SvtCJKOptions; +class SvtCTLOptions; + +class SVL_DLLPUBLIC SvtLanguageOptions final : public ::utl::detail::Options +{ +private: + std::unique_ptr<SvtCJKOptions> m_pCJKOptions; + std::unique_ptr<SvtCTLOptions> m_pCTLOptions; + +public: + enum EOption + { + // cjk options + E_CJKFONT, + E_VERTICALTEXT, + E_ASIANTYPOGRAPHY, + E_JAPANESEFIND, + E_RUBY, + E_CHANGECASEMAP, + E_DOUBLELINES, + E_EMPHASISMARKS, + E_VERTICALCALLOUT, + E_ALLCJK, + // ctl options + E_CTLFONT, + E_CTLSEQUENCECHECKING, + E_CTLCURSORMOVEMENT, + E_CTLTEXTNUMERALS + }; + + // bDontLoad is for referencing purposes only + SvtLanguageOptions( bool _bDontLoad = false ); + virtual ~SvtLanguageOptions() override; + + // CJK options + bool IsCJKFontEnabled() const; + bool IsVerticalTextEnabled() const; + bool IsAsianTypographyEnabled() const; + bool IsJapaneseFindEnabled() const; + void SetAll( bool _bSet ); + bool IsAnyEnabled() const; + + // CTL options + void SetCTLFontEnabled( bool _bEnabled ); + bool IsCTLFontEnabled() const; + + void SetCTLSequenceChecking( bool _bEnabled ); + + void SetCTLSequenceCheckingRestricted( bool _bEnable ); + + void SetCTLSequenceCheckingTypeAndReplace( bool _bEnable ); + + bool IsReadOnly(EOption eOption) const; + + // returns for a language the scripttype + static SvtScriptType GetScriptTypeOfLanguage( LanguageType nLang ); + + // convert from css::i18n::ScriptType constants to SvtScriptType + static SvtScriptType FromI18NToSvtScriptType( sal_Int16 nI18NType ); + + static sal_Int16 FromSvtScriptTypeToI18N( SvtScriptType nI18NType ); + + static sal_Int16 GetI18NScriptTypeOfLanguage( LanguageType nLang ); + +}; + +/** #i42730# Gives access to the Windows 16bit system locale + */ +class SvtSystemLanguageOptions final : public utl::ConfigItem +{ +private: + OUString m_sWin16SystemLocale; + + bool isKeyboardLayoutTypeInstalled(sal_Int16 scriptType) const; + + virtual void ImplCommit() override; + +public: + SvtSystemLanguageOptions(); + virtual ~SvtSystemLanguageOptions() override; + + virtual void Notify( const css::uno::Sequence< OUString >& rPropertyNames ) override; + + LanguageType GetWin16SystemLanguage() const; + + bool isCJKKeyboardLayoutInstalled() const; +}; + +#endif // INCLUDED_SVL_LANGUAGEOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/lckbitem.hxx b/include/svl/lckbitem.hxx new file mode 100644 index 000000000..5625a7aac --- /dev/null +++ b/include/svl/lckbitem.hxx @@ -0,0 +1,53 @@ +/* -*- 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_SVL_LCKBITEM_HXX +#define INCLUDED_SVL_LCKBITEM_HXX + +#include <svl/poolitem.hxx> +#include <svl/svldllapi.h> +#include <tools/stream.hxx> + +class SVL_DLLPUBLIC SfxLockBytesItem final : public SfxPoolItem +{ + SvLockBytesRef _xVal; + +public: + static SfxPoolItem* CreateDefault(); + SfxLockBytesItem(); + virtual ~SfxLockBytesItem() override; + + SfxLockBytesItem(SfxLockBytesItem const &) = default; + SfxLockBytesItem(SfxLockBytesItem &&) = default; + SfxLockBytesItem & operator =(SfxLockBytesItem const &) = delete; // due to SfxPoolItem + SfxLockBytesItem & operator =(SfxLockBytesItem &&) = delete; // due to SfxPoolItem + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual SfxLockBytesItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + SvLockBytes* GetValue() const { return _xVal.get(); } + + virtual bool PutValue ( const css::uno::Any& rVal, + sal_uInt8 nMemberId ) override; + virtual bool QueryValue( css::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/legacyitem.hxx b/include/svl/legacyitem.hxx new file mode 100644 index 000000000..b2035aeca --- /dev/null +++ b/include/svl/legacyitem.hxx @@ -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/. + * + * 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_SVL_LEGACYITEM_HXX +#define INCLUDED_SVL_LEGACYITEM_HXX + +#include <svl/svldllapi.h> + +////////////////////////////////////////////////////////////////////////////// +// // svl +// SfxBoolItem aLinebreak; +// SfxInt32Item aRotateAngle; -> CntInt32Item +////////////////////////////////////////////////////////////////////////////// + +class SvStream; +class SfxBoolItem; +class CntInt32Item; + +namespace legacy +{ + namespace SfxBool + { + sal_uInt16 SVL_DLLPUBLIC GetVersion(sal_uInt16 nFileFormatVersion); + void SVL_DLLPUBLIC Create(SfxBoolItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion); + SVL_DLLPUBLIC SvStream& Store(const SfxBoolItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion); + } + namespace CntInt32 + { + sal_uInt16 SVL_DLLPUBLIC GetVersion(sal_uInt16 nFileFormatVersion); + void SVL_DLLPUBLIC Create(CntInt32Item& rItem, SvStream& rStrm, sal_uInt16 nItemVersion); + SVL_DLLPUBLIC SvStream& Store(const CntInt32Item& rItem, SvStream& rStrm, sal_uInt16 nItemVersion); + } +} + +#endif // INCLUDED_SVL_LEGACYITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/listener.hxx b/include/svl/listener.hxx new file mode 100644 index 000000000..38d725526 --- /dev/null +++ b/include/svl/listener.hxx @@ -0,0 +1,69 @@ +/* -*- 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_SVL_LISTENER_HXX +#define INCLUDED_SVL_LISTENER_HXX + +#include <svl/svldllapi.h> + +#include <o3tl/sorted_vector.hxx> + +class SvtBroadcaster; +class SfxHint; + +class SVL_DLLPUBLIC SvtListener +{ + friend class SvtBroadcaster; + typedef o3tl::sorted_vector<SvtBroadcaster*> BroadcastersType; + BroadcastersType maBroadcasters; + + const SvtListener& operator=(const SvtListener &) = delete; + // called from the SvtBroadcaster destructor + void BroadcasterDying( SvtBroadcaster& rBroadcaster ); + +public: + class SVL_DLLPUBLIC QueryBase + { + sal_uInt16 mnId; + public: + QueryBase( sal_uInt16 nId ); + virtual ~QueryBase(); + + sal_uInt16 getId() const; + }; + + SvtListener(); + SvtListener( const SvtListener &r ); + virtual ~SvtListener() COVERITY_NOEXCEPT_FALSE; + + bool StartListening( SvtBroadcaster& rBroadcaster ); + bool EndListening( SvtBroadcaster& rBroadcaster ); + void EndListeningAll(); + + /// Overwrites existing broadcasters with the ones from the specified listener + void CopyAllBroadcasters( const SvtListener& r ); + bool HasBroadcaster() const; + + virtual void Notify( const SfxHint& rHint ); + virtual void Query( QueryBase& rQuery ) const; +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/lngmisc.hxx b/include/svl/lngmisc.hxx new file mode 100644 index 000000000..7e5728d67 --- /dev/null +++ b/include/svl/lngmisc.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 . + */ + +#ifndef INCLUDED_SVL_LNGMISC_HXX +#define INCLUDED_SVL_LNGMISC_HXX + +#include <svl/svldllapi.h> + +#include <rtl/ustring.hxx> + +#define SVT_SOFT_HYPHEN u'\x00AD' +#define SVT_HARD_HYPHEN u'\x2011' + +// the non-breaking space +#define SVT_HARD_SPACE u'\x00A0' + +namespace linguistic +{ + inline bool IsHyphen(sal_Unicode cChar) + { + return cChar == SVT_SOFT_HYPHEN || cChar == SVT_HARD_HYPHEN; + } + + inline bool IsControlChar(sal_Unicode cChar) + { + // TODO: why doesn't this include 0x0F DEL? + return cChar < u' '; + } + + sal_Int32 GetNumControlChars( const OUString &rTxt ); + + SVL_DLLPUBLIC bool RemoveHyphens(OUString &rTxt); + SVL_DLLPUBLIC bool RemoveControlChars(OUString &rTxt); + SVL_DLLPUBLIC bool ReplaceControlChars(OUString &rTxt); + SVL_DLLPUBLIC OUString GetThesaurusReplaceText(const OUString &rText); +} // namespace linguistic + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/lockfilecommon.hxx b/include/svl/lockfilecommon.hxx new file mode 100644 index 000000000..77349c48a --- /dev/null +++ b/include/svl/lockfilecommon.hxx @@ -0,0 +1,75 @@ +/* -*- 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_SVL_LOCKFILECOMMON_HXX +#define INCLUDED_SVL_LOCKFILECOMMON_HXX + +#include <svl/svldllapi.h> + +#include <com/sun/star/uno/Sequence.hxx> + +#include <osl/mutex.hxx> +#include <tools/urlobj.hxx> +#include <o3tl/enumarray.hxx> +#include <vector> + +enum class LockFileComponent +{ + OOOUSERNAME, SYSUSERNAME, LOCALHOST, EDITTIME, USERURL, LAST=USERURL +}; + +typedef o3tl::enumarray<LockFileComponent,OUString> LockFileEntry; + +namespace svt { + +/// This is a general implementation that is used in document lock file implementation and in sharing control file implementation +class SVL_DLLPUBLIC LockFileCommon +{ +private: + OUString m_aURL; + +protected: + ::osl::Mutex m_aMutex; + + /// This method generates the URL of the lock file based on the document URL and the specified prefix. + static OUString GenerateOwnLockFileURL(const OUString& aOrigURL, const OUString& aPrefix); + +public: + LockFileCommon(const OUString& aLockFileURL); + virtual ~LockFileCommon(); + + const OUString& GetURL() const; + void SetURL(const OUString& aURL); + + static void ParseList( const css::uno::Sequence< sal_Int8 >& aBuffer, std::vector< LockFileEntry > &rOutput ); + static LockFileEntry ParseEntry( const css::uno::Sequence< sal_Int8 >& aBuffer, sal_Int32& o_nCurPos ); + static OUString ParseName( const css::uno::Sequence< sal_Int8 >& aBuffer, sal_Int32& o_nCurPos ); + static OUString EscapeCharacters( const OUString& aSource ); + static OUString GetOOOUserName(); + static OUString GetCurrentLocalTime(); + static LockFileEntry GenerateOwnEntry(); + + static INetURLObject ResolveLinks( const INetURLObject& aDocURL ); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/lstner.hxx b/include/svl/lstner.hxx new file mode 100644 index 000000000..1e3aa6bec --- /dev/null +++ b/include/svl/lstner.hxx @@ -0,0 +1,67 @@ +/* -*- 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_SVL_LSTNER_HXX +#define INCLUDED_SVL_LSTNER_HXX + +#include <svl/svldllapi.h> +#include <memory> + +class SfxBroadcaster; +class SfxHint; + +//StartListening duplicate handling options +//Prevent only adds the listener if it's not already added +//Allow allows duplicate listeners +//Unexpected, the default, is for the usual case where the +//listener should only be added once and duplicates are +//unexpected. In dbgutil mode this tracks where the original +//listener was added from and reports the duplicate addition +//as an error +enum class DuplicateHandling { Unexpected, Prevent, Allow }; + +class SVL_DLLPUBLIC SfxListener +{ + struct Impl; + std::unique_ptr<Impl> mpImpl; + +private: + const SfxListener& operator=(const SfxListener &) = delete; + +public: + + SfxListener(); + SfxListener( const SfxListener &rCopy ); + virtual ~SfxListener() COVERITY_NOEXCEPT_FALSE; + + void StartListening(SfxBroadcaster& rBroadcaster, DuplicateHandling eDuplicateHanding = DuplicateHandling::Unexpected); + void EndListening( SfxBroadcaster& rBroadcaster, bool bRemoveAllDuplicates = false ); + void EndListeningAll(); + bool IsListening( SfxBroadcaster& rBroadcaster ) const; + + sal_uInt16 GetBroadcasterCount() const; + SfxBroadcaster* GetBroadcasterJOE( sal_uInt16 nNo ) const; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + + void RemoveBroadcaster_Impl( SfxBroadcaster& rBC ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/macitem.hxx b/include/svl/macitem.hxx new file mode 100644 index 000000000..19a49dde9 --- /dev/null +++ b/include/svl/macitem.hxx @@ -0,0 +1,151 @@ +/* -*- 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_SVL_MACITEM_HXX +#define INCLUDED_SVL_MACITEM_HXX + +// class SvxMacroItem ---------------------------------------------------- + +#include <rtl/ustring.hxx> +#include <svl/svldllapi.h> +#include <svl/poolitem.hxx> +#include <map> + +class SvStream; +enum class SvMacroItemId : sal_uInt16; + +#define SVX_MACRO_LANGUAGE_JAVASCRIPT "JavaScript" +#define SVX_MACRO_LANGUAGE_STARBASIC "StarBasic" +#define SVX_MACRO_LANGUAGE_SF "Script" + +enum ScriptType +{ + STARBASIC, + JAVASCRIPT, + EXTENDED_STYPE +}; + +class SVL_DLLPUBLIC SvxMacro +{ + OUString aMacName; + OUString aLibName; + ScriptType eType; + +public: + + SvxMacro( const OUString &rMacName, const OUString &rLanguage); + + SvxMacro( const OUString &rMacName, const OUString &rLibName, + ScriptType eType); // = STARBASIC removes + + const OUString &GetLibName() const { return aLibName; } + const OUString &GetMacName() const { return aMacName; } + OUString GetLanguage()const; + + ScriptType GetScriptType() const { return eType; } + + bool HasMacro() const { return !aMacName.isEmpty(); } +}; + +inline SvxMacro::SvxMacro( const OUString &rMacName, const OUString &rLibName, + ScriptType eTyp ) + : aMacName( rMacName ), aLibName( rLibName ), eType( eTyp ) +{} + +// Macro Table, destroys the pointers in the DTor! +typedef std::map<SvMacroItemId, SvxMacro> SvxMacroTable; + +#define SVX_MACROTBL_VERSION31 0 +#define SVX_MACROTBL_VERSION40 1 + +class SVL_DLLPUBLIC SvxMacroTableDtor +{ +private: + SvxMacroTable aSvxMacroTable; +public: + SvxMacroTableDtor() {} + SvxMacroTableDtor( const SvxMacroTableDtor &rCpy ) : aSvxMacroTable(rCpy.aSvxMacroTable) { } + + SvxMacroTableDtor& operator=( const SvxMacroTableDtor &rCpy ); + bool operator==( const SvxMacroTableDtor& rOther ) const; + + void Read( SvStream & ); + SvStream& Write( SvStream & ) const; + + bool empty() const { return aSvxMacroTable.empty(); } + + // returns NULL if no entry exists, or a pointer to the internal value + const SvxMacro* Get(SvMacroItemId nEvent) const; + // returns NULL if no entry exists, or a pointer to the internal value + SvxMacro* Get(SvMacroItemId nEvent); + // return true if the key exists + bool IsKeyValid(SvMacroItemId nEvent) const; + // This stores a copy of the rMacro parameter + SvxMacro& Insert(SvMacroItemId nEvent, const SvxMacro& rMacro); + // If the entry exists, remove it from the map and release it's storage + void Erase(SvMacroItemId nEvent); +}; + + +/* +This item describes a Macro table. +*/ + +class SVL_DLLPUBLIC SvxMacroItem final : public SfxPoolItem +{ +public: + explicit inline SvxMacroItem ( const sal_uInt16 nId ); + + // "pure virtual methods" of SfxPoolItem + virtual bool operator==( const SfxPoolItem& ) const override; + virtual bool GetPresentation( SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString &rText, + const IntlWrapper& ) const override; + virtual SvxMacroItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const SvxMacroTableDtor& GetMacroTable() const { return aMacroTable;} + void SetMacroTable( const SvxMacroTableDtor& rTbl ) { aMacroTable = rTbl; } + + inline const SvxMacro& GetMacro( SvMacroItemId nEvent ) const; + inline bool HasMacro( SvMacroItemId nEvent ) const; + void SetMacro( SvMacroItemId nEvent, const SvxMacro& ); + +private: + SvxMacroTableDtor aMacroTable; + + SvxMacroItem( const SvxMacroItem& ) = default; +}; + +inline SvxMacroItem::SvxMacroItem( const sal_uInt16 nId ) + : SfxPoolItem( nId ) +{} + +inline bool SvxMacroItem::HasMacro( SvMacroItemId nEvent ) const +{ + return aMacroTable.IsKeyValid( nEvent ); +} +inline const SvxMacro& SvxMacroItem::GetMacro( SvMacroItemId nEvent ) const +{ + return *(aMacroTable.Get(nEvent)); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/memberid.h b/include/svl/memberid.h new file mode 100644 index 000000000..afe106d41 --- /dev/null +++ b/include/svl/memberid.h @@ -0,0 +1,85 @@ +/* -*- 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_SVL_MEMBERID_H +#define INCLUDED_SVL_MEMBERID_H + +#define MID_X 1 +#define MID_Y 2 +#define MID_RECT_LEFT 3 +#define MID_RECT_TOP 4 +#define MID_WIDTH 5 +#define MID_HEIGHT 6 +#define MID_RECT_RIGHT 7 + +// SvxSizeItem +#define MID_SIZE_SIZE 0 +#define MID_SIZE_WIDTH 1 +#define MID_SIZE_HEIGHT 2 + +// SvxSearchItem +// XXX When changing the MID count here, also increment the corresponding +// SvxSearchItem SFX_DECL_TYPE(n) value in include/sfx2/msg.hxx to match, and +// add a member to struct SvxSearch in sfx2/sdi/sfxitems.sdi so that dependent +// slot items get generated. +#define MID_SEARCH_STYLEFAMILY 1 +#define MID_SEARCH_CELLTYPE 2 +#define MID_SEARCH_ROWDIRECTION 3 +#define MID_SEARCH_ALLTABLES 4 +#define MID_SEARCH_SEARCHFILTERED 5 +#define MID_SEARCH_BACKWARD 6 +#define MID_SEARCH_PATTERN 7 +#define MID_SEARCH_CONTENT 8 +#define MID_SEARCH_ASIANOPTIONS 9 +#define MID_SEARCH_ALGORITHMTYPE 10 +#define MID_SEARCH_FLAGS 11 +#define MID_SEARCH_SEARCHSTRING 12 +#define MID_SEARCH_REPLACESTRING 13 +#define MID_SEARCH_LOCALE 14 +#define MID_SEARCH_CHANGEDCHARS 15 +#define MID_SEARCH_DELETEDCHARS 16 +#define MID_SEARCH_INSERTEDCHARS 17 +#define MID_SEARCH_TRANSLITERATEFLAGS 18 +#define MID_SEARCH_COMMAND 19 +#define MID_SEARCH_STARTPOINTX 20 +#define MID_SEARCH_STARTPOINTY 21 +#define MID_SEARCH_SEARCHFORMATTED 22 +#define MID_SEARCH_ALGORITHMTYPE2 23 + +// SfxDocumentInfoItem +#define MID_DOCINFO_DESCRIPTION 0x13 +#define MID_DOCINFO_KEYWORDS 0x17 +#define MID_DOCINFO_SUBJECT 0x1b +#define MID_DOCINFO_TITLE 0x1d +#define MID_DOCINFO_AUTOLOADENABLED 0x2d +#define MID_DOCINFO_AUTOLOADURL 0x2e +#define MID_DOCINFO_AUTOLOADSECS 0x2f +#define MID_DOCINFO_DEFAULTTARGET 0x30 +#define MID_DOCINFO_USEUSERDATA 0x31 +#define MID_DOCINFO_DELETEUSERDATA 0x32 +#define MID_DOCINFO_USETHUMBNAILSAVE 0x33 + +// only for FastPropertySet +#define MID_TYPE 0x38 +#define MID_VALUE 0x39 +#define MID_VALUESET 0x40 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/metitem.hxx b/include/svl/metitem.hxx new file mode 100644 index 000000000..be5b1b7ba --- /dev/null +++ b/include/svl/metitem.hxx @@ -0,0 +1,37 @@ +/* -*- 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_SVL_METITEM_HXX +#define INCLUDED_SVL_METITEM_HXX + +#include <svl/svldllapi.h> +#include <svl/intitem.hxx> + +class SVL_DLLPUBLIC SfxMetricItem: public SfxInt32Item +{ +public: + explicit SfxMetricItem( sal_uInt16 nWhich, sal_uInt32 nValue ); + + virtual void ScaleMetrics( long lMult, long lDiv ) override; + virtual bool HasMetrics() const override; + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/msodocumentlockfile.hxx b/include/svl/msodocumentlockfile.hxx new file mode 100644 index 000000000..904411cb0 --- /dev/null +++ b/include/svl/msodocumentlockfile.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SVL_MSODOCUMENTLOCKFILE_HXX +#define INCLUDED_SVL_MSODOCUMENTLOCKFILE_HXX + +#include <svl/svldllapi.h> +#include <svl/documentlockfile.hxx> + +#define MSO_WORD_LOCKFILE_SIZE 162 +#define MSO_EXCEL_AND_POWERPOINT_LOCKFILE_SIZE 165 +#define MSO_USERNAME_MAX_LENGTH 52 + +namespace svt +{ +/// Class implementing reading and writing MSO lockfiles. +class SVL_DLLPUBLIC MSODocumentLockFile final : public GenDocumentLockFile +{ +private: + enum class AppType + { + Word, + Excel, + PowerPoint + }; + static AppType getAppType(const OUString& sOrigURL); + AppType m_eAppType; + + virtual void + WriteEntryToStream(const LockFileEntry& aEntry, + const css::uno::Reference<css::io::XOutputStream>& xStream) override; + + virtual css::uno::Reference<css::io::XInputStream> OpenStream() override; + +public: + MSODocumentLockFile(const OUString& aOrigURL); + virtual ~MSODocumentLockFile() override; + + virtual LockFileEntry GetLockData() override; + + virtual void RemoveFile() override; + + static bool IsMSOSupportedFileFormat(const OUString& aURL); +}; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/svl/nfkeytab.hxx b/include/svl/nfkeytab.hxx new file mode 100644 index 000000000..fe1e3bb69 --- /dev/null +++ b/include/svl/nfkeytab.hxx @@ -0,0 +1,124 @@ +/* -*- 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_SVL_NFKEYTAB_HXX +#define INCLUDED_SVL_NFKEYTAB_HXX + +#include <vector> +#include <rtl/ustring.hxx> + +//! For ImpSvNumberformatScan: first the short symbols, then the long symbols! +//! e.g. first YY then YYYY +//! The internal order is essential for the format code string scanner. +// +// This table is externally only to be used with method +// OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable&, const LocaleDataWrapper& ); +// and method +// void SvNumberFormatter::FillKeywordTable( NfKeywordTable&, LanguageType ); +enum NfKeywordIndex +{ + NF_KEY_NONE = 0, + NF_KEY_E, // exponential symbol + NF_KEY_AMPM, // AM/PM + NF_KEY_AP, // a/p + NF_KEY_MI, // minute (!) + NF_KEY_MMI, // minute 02 (!) + NF_KEY_M, // month (!) + NF_KEY_MM, // month 02 (!) + NF_KEY_MMM, // month short name + NF_KEY_MMMM, // month long name + NF_KEY_MMMMM, // month narrow name, first letter + NF_KEY_H, // hour + NF_KEY_HH, // hour 02 + NF_KEY_S, // second + NF_KEY_SS, // second 02 + NF_KEY_Q, // quarter + NF_KEY_QQ, // quarter 02 + NF_KEY_D, // day of month + NF_KEY_DD, // day of month 02 + NF_KEY_DDD, // day of week short + NF_KEY_DDDD, // day of week long + NF_KEY_YY, // year two digits + NF_KEY_YYYY, // year four digits + NF_KEY_NN, // day of week short + NF_KEY_NNN, // day of week long without separator, as of version 6, 10.10.97 + NF_KEY_NNNN, // day of week long with separator + NF_KEY_AAA, // abbreviated day name from Japanese Xcl, same as DDD or NN English + NF_KEY_AAAA, // full day name from Japanese Xcl, same as DDDD or NNN English + NF_KEY_EC, // E non-gregorian calendar year without preceding 0 + NF_KEY_EEC, // EE non-gregorian calendar year with preceding 0 (two digit) + NF_KEY_G, // abbreviated era name, latin characters M T S or H for Gengou calendar + NF_KEY_GG, // abbreviated era name + NF_KEY_GGG, // full era name + NF_KEY_R, // acts as EE (Xcl) => GR==GEE, GGR==GGEE, GGGR==GGGEE + NF_KEY_RR, // acts as GGGEE (Xcl) + NF_KEY_WW, // week of year, as of version 8, 19.06.98 + NF_KEY_THAI_T, // Thai T modifier, speciality of Thai Excel, only used with Thai locale and converted to [NatNum1] + NF_KEY_CCC, // currency bank symbol (old version) + NF_KEY_GENERAL, // General / Standard + NF_KEY_LASTKEYWORD = NF_KEY_GENERAL, + + // Reserved words translated and color names follow: + NF_KEY_TRUE, // boolean true + NF_KEY_FALSE, // boolean false + NF_KEY_BOOLEAN, // boolean + NF_KEY_COLOR, // color + NF_KEY_FIRSTCOLOR, + NF_KEY_BLACK = NF_KEY_FIRSTCOLOR, // you do know colors, don't you? + NF_KEY_BLUE, + NF_KEY_GREEN, + NF_KEY_CYAN, + NF_KEY_RED, + NF_KEY_MAGENTA, + NF_KEY_BROWN, + NF_KEY_GREY, + NF_KEY_YELLOW, + NF_KEY_WHITE, + NF_KEY_LASTCOLOR = NF_KEY_WHITE, + + NF_KEYWORD_ENTRIES_COUNT +}; + +class NfKeywordTable final +{ + typedef ::std::vector<OUString> Keywords_t; + Keywords_t m_keywords; + +public: + NfKeywordTable() : m_keywords(NF_KEYWORD_ENTRIES_COUNT) {}; + NfKeywordTable( const std::initializer_list<OUString> & l ) : m_keywords(l) + { + assert(m_keywords.size() == NF_KEYWORD_ENTRIES_COUNT); + } + + OUString & operator[] (Keywords_t::size_type n) { return m_keywords[n]; } + const OUString & operator[] (Keywords_t::size_type n) const { return m_keywords[n]; } + + Keywords_t::size_type size() const { return m_keywords.size(); } + + NfKeywordTable& operator=( const NfKeywordTable& r ) + { + m_keywords = r.m_keywords; + return *this; + } +}; + +#endif // INCLUDED_SVL_NFKEYTAB_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/nfsymbol.hxx b/include/svl/nfsymbol.hxx new file mode 100644 index 000000000..8a659857e --- /dev/null +++ b/include/svl/nfsymbol.hxx @@ -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/. + * + * 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_SVL_NFSYMBOL_HXX +#define INCLUDED_SVL_NFSYMBOL_HXX + +/* ATTENTION! If new types arrive that had its content previously handled as + * SYMBOLTYPE_STRING, they have to be added at several places in zforscan.cxx + * and/or zformat.cxx, and in xmloff/source/style/xmlnumfe.cxx. Mostly these + * are places where already NF_SYMBOLTYPE_STRING together with + * NF_SYMBOLTYPE_CURRENCY or NF_SYMBOLTYPE_DATESEP are used in the same case of + * a switch respectively an if-condition. + */ + +namespace svt { + +/// Number formatter's symbol types of a token, if not key words, which are >0 +enum NfSymbolType +{ + NF_SYMBOLTYPE_STRING = -1, // literal string in output + NF_SYMBOLTYPE_DEL = -2, // special character + NF_SYMBOLTYPE_BLANK = -3, // blank for '_' + NF_SYMBOLTYPE_STAR = -4, // *-character + NF_SYMBOLTYPE_DIGIT = -5, // digit place holder + NF_SYMBOLTYPE_DECSEP = -6, // decimal separator + NF_SYMBOLTYPE_THSEP = -7, // group AKA thousand separator + NF_SYMBOLTYPE_EXP = -8, // exponent E + NF_SYMBOLTYPE_FRAC = -9, // fraction / + NF_SYMBOLTYPE_EMPTY = -10, // deleted symbols + NF_SYMBOLTYPE_FRACBLANK = -11, // delimiter between integer and fraction + NF_SYMBOLTYPE_CURRENCY = -12, // currency symbol + NF_SYMBOLTYPE_CURRDEL = -13, // currency symbol delimiter [$] + NF_SYMBOLTYPE_CURREXT = -14, // currency symbol extension -xxx + NF_SYMBOLTYPE_CALENDAR = -15, // calendar ID + NF_SYMBOLTYPE_CALDEL = -16, // calendar delimiter [~] + NF_SYMBOLTYPE_DATESEP = -17, // date separator + NF_SYMBOLTYPE_TIMESEP = -18, // time separator + NF_SYMBOLTYPE_TIME100SECSEP = -19, // time 100th seconds separator + NF_SYMBOLTYPE_PERCENT = -20, // percent % + NF_SYMBOLTYPE_FRAC_FDIV = -21 // forced divisors +}; + +} // namespace svt + +#endif // INCLUDED_SVL_NFSYMBOL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/numuno.hxx b/include/svl/numuno.hxx new file mode 100644 index 000000000..a439b9559 --- /dev/null +++ b/include/svl/numuno.hxx @@ -0,0 +1,71 @@ +/* -*- 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_SVL_NUMUNO_HXX +#define INCLUDED_SVL_NUMUNO_HXX + +#include <svl/svldllapi.h> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <comphelper/servicehelper.hxx> +#include <cppuhelper/implbase2.hxx> +#include <memory> + +class SvNumberFormatter; +class SvNumFmtSuppl_Impl; + +namespace comphelper +{ + class SharedMutex; +} + + +// SvNumberFormatsSupplierObj: aggregate to document, +// construct with SvNumberFormatter + +class SVL_DLLPUBLIC SvNumberFormatsSupplierObj : public cppu::WeakAggImplHelper2< + css::util::XNumberFormatsSupplier, + css::lang::XUnoTunnel> +{ +private: + std::unique_ptr<SvNumFmtSuppl_Impl> pImpl; + +public: + SvNumberFormatsSupplierObj(); + SvNumberFormatsSupplierObj(SvNumberFormatter* pForm); + virtual ~SvNumberFormatsSupplierObj() override; + + void SetNumberFormatter(SvNumberFormatter* pNew); + SvNumberFormatter* GetNumberFormatter() const; + + // XNumberFormatsSupplier + virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL + getNumberFormatSettings() override; + virtual css::uno::Reference< css::util::XNumberFormats > SAL_CALL + getNumberFormats() override; + + // XUnoTunnel + UNO3_GETIMPLEMENTATION_DECL(SvNumberFormatsSupplierObj) + + ::comphelper::SharedMutex& getSharedMutex() const; +}; + +#endif // INCLUDED_SVL_NUMUNO_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/ondemand.hxx b/include/svl/ondemand.hxx new file mode 100644 index 000000000..5ce944a96 --- /dev/null +++ b/include/svl/ondemand.hxx @@ -0,0 +1,288 @@ +/* -*- 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_SVL_ONDEMAND_HXX +#define INCLUDED_SVL_ONDEMAND_HXX + +#include <memory> +#include <unotools/syslocale.hxx> +#include <i18nlangtag/lang.h> +#include <unotools/localedatawrapper.hxx> +#include <unotools/calendarwrapper.hxx> +#include <unotools/transliterationwrapper.hxx> +#include <unotools/nativenumberwrapper.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <i18nutil/transliteration.hxx> + +/* + On demand instantiation and initialization of several i18n wrappers, + helping the number formatter to not perform worse than it already does. + */ + +/** @short + Switch between LANGUAGE_SYSTEM and LANGUAGE_ENGLISH_US and any other + LocaleDataWrapper. + SvNumberformatter uses it upon switching locales. + + @descr + Avoids reloading and analysing of locale data again and again. + + @ATTENTION + If the default ctor is used the init() method MUST be called before + accessing any locale data. The passed parameters Locale and LanguageType + must match each other. + */ + +class OnDemandLocaleDataWrapper +{ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + SvtSysLocale aSysLocale; + LanguageType eCurrentLanguage; + LanguageType eLastAnyLanguage; + const LocaleDataWrapper* pSystem; + std::unique_ptr<const LocaleDataWrapper> pEnglish; + std::unique_ptr< LocaleDataWrapper> pAny; + const LocaleDataWrapper* pCurrent; + bool bInitialized; + +public: + OnDemandLocaleDataWrapper() + : eLastAnyLanguage( LANGUAGE_DONTKNOW ) + , bInitialized(false) + { + pCurrent = pSystem = aSysLocale.GetLocaleDataPtr(); + eCurrentLanguage = LANGUAGE_SYSTEM; + } + + bool isInitialized() const { return bInitialized; } + + void init( + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const LanguageTag& rLanguageTag + ) + { + m_xContext = rxContext; + changeLocale( rLanguageTag ); + bInitialized = true; + } + + void changeLocale( const LanguageTag& rLanguageTag ) + { + LanguageType eLang = rLanguageTag.getLanguageType( false); + if ( eLang == LANGUAGE_SYSTEM ) + pCurrent = pSystem; + else if ( eLang == LANGUAGE_ENGLISH_US ) + { + if ( !pEnglish ) + pEnglish.reset( new LocaleDataWrapper( m_xContext, rLanguageTag ) ); + pCurrent = pEnglish.get(); + } + else + { + if ( !pAny ) + { + pAny.reset( new LocaleDataWrapper( m_xContext, rLanguageTag ) ); + eLastAnyLanguage = eLang; + } + else if ( eLastAnyLanguage != eLang ) + { + pAny->setLanguageTag( rLanguageTag ); + eLastAnyLanguage = eLang; + } + pCurrent = pAny.get(); + } + eCurrentLanguage = eLang; + } + + LanguageType getCurrentLanguage() const + { return eCurrentLanguage; } + + const LocaleDataWrapper* get() const { return pCurrent; } + const LocaleDataWrapper* operator->() const { return get(); } + const LocaleDataWrapper& operator*() const { return *pCurrent; } +}; + +/** Load a calendar only if it's needed. Keep calendar for "en-US" locale + separately, as there can be alternation between locale dependent and + locale independent formats. + SvNumberformatter uses it upon switching locales. + + @ATTENTION If the default ctor is used the init() method MUST be called + before accessing the calendar. + */ +class OnDemandCalendarWrapper +{ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::lang::Locale aEnglishLocale; + css::lang::Locale aLocale; + mutable css::lang::Locale aLastAnyLocale; + mutable std::unique_ptr<CalendarWrapper> pEnglishPtr; + mutable std::unique_ptr<CalendarWrapper> pAnyPtr; + +public: + OnDemandCalendarWrapper() + { + LanguageTag aEnglishLanguageTag(LANGUAGE_ENGLISH_US); + aEnglishLocale = aEnglishLanguageTag.getLocale(); + aLastAnyLocale = aEnglishLocale; + } + + void init( + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::lang::Locale& rLocale + ) + { + m_xContext = rxContext; + changeLocale( rLocale ); + pEnglishPtr.reset(); + pAnyPtr.reset(); + } + + void changeLocale( const css::lang::Locale& rLocale ) + { + aLocale = rLocale; + } + + CalendarWrapper* get() const + { + CalendarWrapper* pPtr; + if ( aLocale == aEnglishLocale ) + { + if (!pEnglishPtr) + { + pEnglishPtr.reset( new CalendarWrapper( m_xContext )); + pEnglishPtr->loadDefaultCalendar( aEnglishLocale ); + } + pPtr = pEnglishPtr.get(); + } + else + { + if ( !pAnyPtr ) + { + pAnyPtr.reset(new CalendarWrapper( m_xContext )); + pAnyPtr->loadDefaultCalendar(aLocale); + aLastAnyLocale = aLocale; + } + else if ( aLocale != aLastAnyLocale ) + { + pAnyPtr->loadDefaultCalendar( aLocale ); + aLastAnyLocale = aLocale; + } + pPtr = pAnyPtr.get(); + } + return pPtr; + } + +}; + +/** Load a transliteration only if it's needed. + SvNumberformatter uses it upon switching locales. + @ATTENTION If the default ctor is used the init() method MUST be called + before accessing the transliteration. + */ +class OnDemandTransliterationWrapper +{ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + LanguageType eLanguage; + TransliterationFlags nType; + mutable std::unique_ptr<::utl::TransliterationWrapper> + pPtr; + mutable bool bValid; + bool bInitialized; + +public: + OnDemandTransliterationWrapper() + : eLanguage( LANGUAGE_SYSTEM ) + , nType(TransliterationFlags::NONE) + , bValid(false) + , bInitialized(false) + {} + + bool isInitialized() const { return bInitialized; } + + void init( + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + LanguageType eLang + ) + { + m_xContext = rxContext; + nType = TransliterationFlags::IGNORE_CASE; + changeLocale( eLang ); + pPtr.reset(); + bInitialized = true; + } + + void changeLocale( LanguageType eLang ) + { + bValid = false; + eLanguage = eLang; + } + + const ::utl::TransliterationWrapper* get() const + { + if ( !bValid ) + { + if ( !pPtr ) + pPtr.reset( new ::utl::TransliterationWrapper( m_xContext, nType ) ); + pPtr->loadModuleIfNeeded( eLanguage ); + bValid = true; + } + return pPtr.get(); + } + + const ::utl::TransliterationWrapper* operator->() const { return get(); } +}; + +/** Load a native number service wrapper only if it's needed. + SvNumberformatter uses it. + + @ATTENTION + If the default ctor is used the init() method MUST be called + before accessing the native number supplier. + */ +class OnDemandNativeNumberWrapper +{ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + mutable std::unique_ptr<NativeNumberWrapper> + pPtr; + +public: + OnDemandNativeNumberWrapper() + {} + + void init( + const css::uno::Reference< css::uno::XComponentContext >& rxContext + ) + { + m_xContext = rxContext; + pPtr.reset(); + } + + NativeNumberWrapper* get() const + { + if ( !pPtr ) + pPtr.reset(new NativeNumberWrapper( m_xContext )); + return pPtr.get(); + } + +}; + +#endif // INCLUDED_SVL_ONDEMAND_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/outstrm.hxx b/include/svl/outstrm.hxx new file mode 100644 index 000000000..f4e736542 --- /dev/null +++ b/include/svl/outstrm.hxx @@ -0,0 +1,54 @@ +/* -*- 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_SVL_OUTSTRM_HXX +#define INCLUDED_SVL_OUTSTRM_HXX + +#include <svl/svldllapi.h> +#include <com/sun/star/uno/Reference.h> +#include <tools/stream.hxx> + +namespace com::sun::star::io { + class XOutputStream; +} + + +class SVL_DLLPUBLIC SvOutputStream final : public SvStream +{ + css::uno::Reference< css::io::XOutputStream > m_xStream; + + SVL_DLLPRIVATE virtual std::size_t GetData(void *, std::size_t) override; + + SVL_DLLPRIVATE virtual std::size_t PutData(void const * pData, std::size_t nSize) override; + + SVL_DLLPRIVATE virtual sal_uInt64 SeekPos(sal_uInt64) override; + + SVL_DLLPRIVATE virtual void FlushData() override; + + SVL_DLLPRIVATE virtual void SetSize(sal_uInt64) override; + +public: + SvOutputStream(css::uno::Reference< css::io::XOutputStream > const & rTheStream); + + virtual ~SvOutputStream() override; +}; + +#endif // INCLUDED_SVL_OUTSTRM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/ownlist.hxx b/include/svl/ownlist.hxx new file mode 100644 index 000000000..cd93e6436 --- /dev/null +++ b/include/svl/ownlist.hxx @@ -0,0 +1,75 @@ +/* -*- 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_SVL_OWNLIST_HXX +#define INCLUDED_SVL_OWNLIST_HXX + +#include <svl/svldllapi.h> +#include <rtl/ustring.hxx> +#include <vector> + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::uno { template <typename > class Sequence; } + +class SvCommand +/* + Contains a string that defines the command and another string for the + command arguments. If such a command were given in the command line, + it would look like this: command = argument +*/ +{ + OUString aCommand; + OUString aArgument; +public: + SvCommand( const OUString & rCommand, const OUString & rArg ) + { + aCommand = rCommand; + aArgument = rArg; + } + const OUString & GetCommand() const { return aCommand; } + const OUString & GetArgument() const { return aArgument; } +}; + +class SVL_DLLPUBLIC SvCommandList +/* + The list contains objects of type SvCommand. + If an object is inserted, it is copied and inserted at the end + of the list. + */ +{ +private: + ::std::vector< SvCommand > aCommandList; + +public: + void Append( const OUString & rCommand, const OUString & rArg ); + + void FillFromSequence( const css::uno::Sequence < css::beans::PropertyValue >& ); + void FillSequence( css::uno::Sequence < css::beans::PropertyValue >& ) const; + + size_t size() const { return aCommandList.size(); } + + SvCommand const & operator[]( size_t i) { + return aCommandList[ i ]; + } + +}; + +#endif // INCLUDED_SVL_OWNLIST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/pickerhistoryaccess.hxx b/include/svl/pickerhistoryaccess.hxx new file mode 100644 index 000000000..7e855f17a --- /dev/null +++ b/include/svl/pickerhistoryaccess.hxx @@ -0,0 +1,44 @@ +/* -*- 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_SVL_PICKERHISTORYACCESS_HXX +#define INCLUDED_SVL_PICKERHISTORYACCESS_HXX + +#include <svl/svldllapi.h> + +#include <com/sun/star/uno/Reference.hxx> + + +namespace svt +{ + + + SVL_DLLPUBLIC void addFolderPicker( + const css::uno::Reference< css::uno::XInterface >& _rxPicker ); + + SVL_DLLPUBLIC void addFilePicker( + const css::uno::Reference< css::uno::XInterface >& _rxPicker ); + + +} // namespace svt + + +#endif // INCLUDED_SVL_PICKERHISTORYACCESS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/poolcach.hxx b/include/svl/poolcach.hxx new file mode 100644 index 000000000..fe06ce416 --- /dev/null +++ b/include/svl/poolcach.hxx @@ -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/. + * + * 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_SVL_POOLCACH_HXX +#define INCLUDED_SVL_POOLCACH_HXX + +#include <svl/svldllapi.h> +#include <vector> + +class SfxItemPool; +class SfxItemSet; +class SfxPoolItem; +class SfxSetItem; + +class SVL_DLLPUBLIC SfxItemPoolCache +{ + struct SfxItemModifyImpl + { + const SfxSetItem *pOrigItem; + SfxSetItem *pPoolItem; + }; + + SfxItemPool *pPool; + std::vector<SfxItemModifyImpl> + m_aCache; + const SfxItemSet *pSetToPut; + const SfxPoolItem *pItemToPut; + +public: + SfxItemPoolCache( SfxItemPool *pPool, + const SfxPoolItem *pPutItem ); + SfxItemPoolCache( SfxItemPool *pPool, + const SfxItemSet *pPutSet ); + ~SfxItemPoolCache(); + + const SfxSetItem& ApplyTo( const SfxSetItem& rSetItem ); +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx new file mode 100644 index 000000000..f1bb0cfab --- /dev/null +++ b/include/svl/poolitem.hxx @@ -0,0 +1,316 @@ +/* -*- 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_SVL_POOLITEM_HXX +#define INCLUDED_SVL_POOLITEM_HXX + +#include <sal/config.h> + +#include <memory> + +#include <com/sun/star/uno/Any.hxx> +#include <svl/hint.hxx> +#include <svl/svldllapi.h> +#include <svl/typedwhich.hxx> +#include <tools/mapunit.hxx> +#include <boost/property_tree/ptree_fwd.hpp> + +class IntlWrapper; + +enum class SfxItemKind : sal_Int8 +{ + NONE, + DeleteOnIdle, + StaticDefault, + PoolDefault +}; + +#define SFX_ITEMS_OLD_MAXREF 0xffef +#define SFX_ITEMS_MAXREF 0xfffffffe +#define SFX_ITEMS_SPECIAL 0xffffffff + +#define CONVERT_TWIPS 0x80 // Uno conversion for measurement (for MemberId) + +// warning, if there is no boolean inside the any this will always return the value false +inline bool Any2Bool( const css::uno::Any&rValue ) +{ + bool bValue = false; + if( !(rValue >>= bValue) ) + { + sal_Int32 nNum = 0; + if( rValue >>= nNum ) + bValue = nNum != 0; + } + + return bValue; +} + +/* + * The values of this enum describe the degree of textual + * representation of an item after calling the virtual + * method <SfxPoolItem::GetPresentation()const>. + */ +enum class SfxItemPresentation +{ + Nameless, + Complete +}; + +/** + * These values have to match the values in the + * css::frame::status::ItemState IDL + * to be found at offapi/com/sun/star/frame/status/ItemState.idl +*/ +enum class SfxItemState { + + /** Specifies an unknown state. */ + UNKNOWN = 0, + + /** Specifies that the property is currently disabled. */ + DISABLED = 0x0001, + + /** Specifies that the property is currently read-only. */ + READONLY = 0x0002, + + /** Specifies that the property is currently in a don't care state. + * <br/> + * This is normally used if a selection provides more than one state + * for a property at the same time. + */ + DONTCARE = 0x0010, + + /** Specifies that the property is currently in a default state. */ + DEFAULT = 0x0020, + + /** The property has been explicitly set to a given value hence we know + * we are not taking the default value. + * <br/> + * For example, you may want to get the font color and it might either + * be the default one or one that has been explicitly set. + */ + SET = 0x0040 +}; + +#define INVALID_POOL_ITEM reinterpret_cast<SfxPoolItem*>(-1) + +class SfxItemPool; +class SfxItemSet; +typedef struct _xmlTextWriter* xmlTextWriterPtr; + +class SVL_DLLPUBLIC SfxPoolItem +{ +friend class SfxItemPool; +friend class SfxItemDisruptor_Impl; +friend class SfxItemPoolCache; +friend class SfxItemSet; +friend class SfxVoidItem; + + mutable sal_uInt32 m_nRefCount; + sal_uInt16 m_nWhich; + SfxItemKind m_nKind; + +private: + inline void SetRefCount(sal_uInt32 n); + inline void SetKind( SfxItemKind n ); +public: + inline void AddRef(sal_uInt32 n = 1) const; +private: + inline sal_uInt32 ReleaseRef(sal_uInt32 n = 1) const; + +protected: + explicit SfxPoolItem( sal_uInt16 nWhich = 0 ); + SfxPoolItem( const SfxPoolItem& rCopy) + : SfxPoolItem(rCopy.m_nWhich) {} + +public: + virtual ~SfxPoolItem(); + + void SetWhich( sal_uInt16 nId ) + { + // can only change the Which before we are in a set + assert(m_nRefCount==0); + m_nWhich = nId; + } + sal_uInt16 Which() const { return m_nWhich; } + virtual bool operator==( const SfxPoolItem& ) const = 0; + bool operator!=( const SfxPoolItem& rItem ) const + { return !(*this == rItem); } + + // Sorting is only used for faster searching in a pool which contains large quantities + // of a single kind of pool item. + virtual bool operator<( const SfxPoolItem& ) const { assert(false); return false; } + virtual bool IsSortable() const { return false; } + + /** @return true if it has a valid string representation */ + virtual bool GetPresentation( SfxItemPresentation ePresentation, + MapUnit eCoreMetric, + MapUnit ePresentationMetric, + OUString &rText, + const IntlWrapper& rIntlWrapper ) const; + + virtual void ScaleMetrics( long lMult, long lDiv ); + virtual bool HasMetrics() const; + + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ); + + virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const = 0; + // clone and call SetWhich + std::unique_ptr<SfxPoolItem> CloneSetWhich( sal_uInt16 nNewWhich ) const; + template<class T> std::unique_ptr<T> CloneSetWhich( TypedWhichId<T> nId ) const + { + return std::unique_ptr<T>(static_cast<T*>(CloneSetWhich(sal_uInt16(nId)).release())); + } + + sal_uInt32 GetRefCount() const { return m_nRefCount; } + SfxItemKind GetKind() const { return m_nKind; } + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; + virtual boost::property_tree::ptree dumpAsJSON() const; + + /** Only SfxVoidItem shall and must return true for this. + + This avoids costly calls to dynamic_cast<const SfxVoidItem*>() + specifically in SfxItemSet::GetItemState() + */ + virtual bool IsVoidItem() const; + +private: + SfxPoolItem& operator=( const SfxPoolItem& ) = delete; +}; + +inline void SfxPoolItem::SetRefCount(sal_uInt32 n) +{ + m_nRefCount = n; + m_nKind = SfxItemKind::NONE; +} + +inline void SfxPoolItem::SetKind( SfxItemKind n ) +{ + m_nRefCount = SFX_ITEMS_SPECIAL; + m_nKind = n; +} + +inline void SfxPoolItem::AddRef(sal_uInt32 n) const +{ + assert(m_nRefCount <= SFX_ITEMS_MAXREF && "AddRef with non-Pool-Item"); + assert(n <= SFX_ITEMS_MAXREF - m_nRefCount && "AddRef: refcount overflow"); + m_nRefCount += n; +} + +inline sal_uInt32 SfxPoolItem::ReleaseRef(sal_uInt32 n) const +{ + assert(m_nRefCount <= SFX_ITEMS_MAXREF && "ReleaseRef with non-Pool-Item"); + assert(n <= m_nRefCount); + m_nRefCount -= n; + return m_nRefCount; +} + +inline bool IsPoolDefaultItem(const SfxPoolItem *pItem ) +{ + return pItem && pItem->GetKind() == SfxItemKind::PoolDefault; +} + +inline bool IsStaticDefaultItem(const SfxPoolItem *pItem ) +{ + return pItem && pItem->GetKind() == SfxItemKind::StaticDefault; +} + +inline bool IsDefaultItem( const SfxPoolItem *pItem ) +{ + return pItem && (pItem->GetKind() == SfxItemKind::StaticDefault || pItem->GetKind() == SfxItemKind::PoolDefault); +} + +inline bool IsPooledItem( const SfxPoolItem *pItem ) +{ + return pItem && pItem->GetRefCount() > 0 && pItem->GetRefCount() <= SFX_ITEMS_MAXREF; +} + +inline bool IsInvalidItem(const SfxPoolItem *pItem) +{ + return pItem == INVALID_POOL_ITEM; +} + +class SVL_DLLPUBLIC SfxVoidItem final: public SfxPoolItem +{ +public: + static SfxPoolItem* CreateDefault(); + explicit SfxVoidItem( sal_uInt16 nWhich ); + virtual ~SfxVoidItem() override; + + SfxVoidItem(SfxVoidItem const &) = default; + SfxVoidItem(SfxVoidItem &&) = default; + SfxVoidItem & operator =(SfxVoidItem const &) = delete; // due to SfxPoolItem + SfxVoidItem & operator =(SfxVoidItem &&) = delete; // due to SfxPoolItem + + virtual bool operator==( const SfxPoolItem& ) const override; + + virtual bool GetPresentation( SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString &rText, + const IntlWrapper& ) const override; + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; + + // create a copy of itself + virtual SfxVoidItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + /** Always returns true as this is an SfxVoidItem. */ + virtual bool IsVoidItem() const override; +}; + +class SVL_DLLPUBLIC SfxSetItem: public SfxPoolItem +{ + std::unique_ptr<SfxItemSet> pSet; + + SfxSetItem & operator=( const SfxSetItem& ) = delete; + +public: + SfxSetItem( sal_uInt16 nWhich, std::unique_ptr<SfxItemSet> &&pSet ); + SfxSetItem( sal_uInt16 nWhich, const SfxItemSet &rSet ); + SfxSetItem( const SfxSetItem&, SfxItemPool *pPool = nullptr ); + virtual ~SfxSetItem() override; + + virtual bool operator==( const SfxPoolItem& ) const override; + + virtual bool GetPresentation( SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString &rText, + const IntlWrapper& ) const override; + + // create a copy of itself + virtual SfxSetItem* Clone( SfxItemPool *pPool = nullptr ) const override = 0; + + const SfxItemSet& GetItemSet() const + { return *pSet; } + SfxItemSet& GetItemSet() + { return *pSet; } +}; + +class SVL_DLLPUBLIC SfxPoolItemHint final : public SfxHint +{ + SfxPoolItem* pObj; +public: + explicit SfxPoolItemHint( SfxPoolItem* Object ) : pObj(Object) {} + SfxPoolItem* GetObject() const { return pObj; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/ptitem.hxx b/include/svl/ptitem.hxx new file mode 100644 index 000000000..2ceb39410 --- /dev/null +++ b/include/svl/ptitem.hxx @@ -0,0 +1,62 @@ +/* -*- 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_SVL_PTITEM_HXX +#define INCLUDED_SVL_PTITEM_HXX + +#include <svl/svldllapi.h> +#include <svl/poolitem.hxx> +#include <tools/gen.hxx> +#include <tools/debug.hxx> + +class SvStream; + +class SVL_DLLPUBLIC SfxPointItem final : public SfxPoolItem +{ + Point aVal; + +public: + static SfxPoolItem* CreateDefault(); + SfxPointItem(); + SfxPointItem( sal_uInt16 nWhich, const Point& rVal ); + + virtual bool GetPresentation( SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString &rText, + const IntlWrapper& ) const override; + + virtual bool operator==( const SfxPoolItem& ) const override; + + virtual SfxPointItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const Point& GetValue() const { return aVal; } + void SetValue( const Point& rNewVal ) { + DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" ); + aVal = rNewVal; + } + + virtual bool QueryValue( css::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, + sal_uInt8 nMemberId ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/rectitem.hxx b/include/svl/rectitem.hxx new file mode 100644 index 000000000..94465bad4 --- /dev/null +++ b/include/svl/rectitem.hxx @@ -0,0 +1,55 @@ +/* -*- 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_SVL_RECTITEM_HXX +#define INCLUDED_SVL_RECTITEM_HXX + +#include <svl/svldllapi.h> +#include <tools/gen.hxx> +#include <svl/poolitem.hxx> + +class SvStream; + +class SVL_DLLPUBLIC SfxRectangleItem final : public SfxPoolItem +{ + tools::Rectangle aVal; + +public: + static SfxPoolItem* CreateDefault(); + SfxRectangleItem(); + SfxRectangleItem( sal_uInt16 nWhich, const tools::Rectangle& rVal ); + + virtual bool GetPresentation( SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString &rText, + const IntlWrapper& ) const override; + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual SfxRectangleItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const tools::Rectangle& GetValue() const { return aVal; } + virtual bool QueryValue( css::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, + sal_uInt8 nMemberId ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/rngitem.hxx b/include/svl/rngitem.hxx new file mode 100644 index 000000000..7e8caf937 --- /dev/null +++ b/include/svl/rngitem.hxx @@ -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/. + * + * 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_SVL_RNGITEM_HXX +#define INCLUDED_SVL_RNGITEM_HXX + +#include <svl/svldllapi.h> +#include <svl/poolitem.hxx> + +class SvStream; + + +class SVL_DLLPUBLIC SfxRangeItem final : public SfxPoolItem +{ +private: + sal_uInt16 nFrom; + sal_uInt16 nTo; +public: + SfxRangeItem( sal_uInt16 nWID, sal_uInt16 nFrom, sal_uInt16 nTo ); + virtual bool operator==( const SfxPoolItem& ) const override; + virtual bool GetPresentation( SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString &rText, + const IntlWrapper& ) const override; + virtual SfxRangeItem* Clone( SfxItemPool *pPool = nullptr ) const override; +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/sharecontrolfile.hxx b/include/svl/sharecontrolfile.hxx new file mode 100644 index 000000000..ddd29717a --- /dev/null +++ b/include/svl/sharecontrolfile.hxx @@ -0,0 +1,71 @@ +/* -*- 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_SVL_SHARECONTROLFILE_HXX +#define INCLUDED_SVL_SHARECONTROLFILE_HXX + +#include <svl/svldllapi.h> + +#include <svl/lockfilecommon.hxx> +#include <vector> + +namespace com::sun::star::io { class XInputStream; } +namespace com::sun::star::io { class XOutputStream; } +namespace com::sun::star::io { class XSeekable; } +namespace com::sun::star::io { class XStream; } +namespace com::sun::star::io { class XTruncate; } + +namespace svt { + +class SVL_DLLPUBLIC ShareControlFile final : public LockFileCommon +{ + css::uno::Reference< css::io::XStream > m_xStream; + css::uno::Reference< css::io::XInputStream > m_xInputStream; + css::uno::Reference< css::io::XOutputStream > m_xOutputStream; + css::uno::Reference< css::io::XSeekable > m_xSeekable; + css::uno::Reference< css::io::XTruncate > m_xTruncate; + + std::vector< LockFileEntry > m_aUsersData; + + void Close(); + bool IsValid() const + { + return ( m_xStream.is() && m_xInputStream.is() && m_xOutputStream.is() && m_xSeekable.is() && m_xTruncate.is() ); + } + +public: + + // The constructor will throw exception in case the stream can not be opened + ShareControlFile( const OUString& aOrigURL ); + virtual ~ShareControlFile() override; + + std::vector< LockFileEntry > GetUsersData(); + void SetUsersDataAndStore( const std::vector< LockFileEntry >& aUserNames ); + LockFileEntry InsertOwnEntry(); + bool HasOwnEntry(); + void RemoveEntry( const LockFileEntry& aOptionalSpecification ); + void RemoveEntry(); + void RemoveFile(); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/sharedstring.hxx b/include/svl/sharedstring.hxx new file mode 100644 index 000000000..71aad67ba --- /dev/null +++ b/include/svl/sharedstring.hxx @@ -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/. + */ + +#ifndef INCLUDED_SVL_SHAREDSTRING_HXX +#define INCLUDED_SVL_SHAREDSTRING_HXX + +#include <svl/svldllapi.h> +#include <rtl/ustring.hxx> + +namespace svl { + +class SVL_DLLPUBLIC SharedString +{ + rtl_uString* mpData; + rtl_uString* mpDataIgnoreCase; +public: + + static SharedString getEmptyString(); + + SharedString(); + SharedString( rtl_uString* pData, rtl_uString* pDataIgnoreCase ); + explicit SharedString( const OUString& rStr ); + SharedString( const SharedString& r ); + SharedString(SharedString&& r) noexcept; + ~SharedString(); + + SharedString& operator= ( const SharedString& r ); + SharedString& operator=(SharedString&& r) noexcept; + + bool operator== ( const SharedString& r ) const; + bool operator!= ( const SharedString& r ) const; + + OUString getString() const; + + rtl_uString* getData(); + const rtl_uString* getData() const; + + rtl_uString* getDataIgnoreCase(); + const rtl_uString* getDataIgnoreCase() const; + + bool isValid() const; + bool isEmpty() const; + + sal_Int32 getLength() const; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/sharedstringpool.hxx b/include/svl/sharedstringpool.hxx new file mode 100644 index 000000000..a2cae3a9a --- /dev/null +++ b/include/svl/sharedstringpool.hxx @@ -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/. + */ + +#ifndef INCLUDED_SVL_SHAREDSTRINGPOOL_HXX +#define INCLUDED_SVL_SHAREDSTRINGPOOL_HXX + +#include <svl/svldllapi.h> +#include <rtl/ustring.hxx> +#include <memory> + +class CharClass; + +namespace svl { + +class SharedString; + +/** + * Storage for pool of shared strings. It also provides mapping from + * original-cased strings to upper-cased strings for case insensitive + * operations. + */ +class SVL_DLLPUBLIC SharedStringPool +{ + struct Impl; + std::unique_ptr<Impl> mpImpl; + + SharedStringPool( const SharedStringPool& ) = delete; + SharedStringPool& operator=( const SharedStringPool& ) = delete; + +public: + SharedStringPool( const CharClass& rCharClass ); + ~SharedStringPool(); + + /** + * Intern a string object into the shared string pool. + * + * @param rStr string object to intern. + * + * @return a pointer to the string object stored inside the pool, or NULL + * if the insertion fails. + */ + SharedString intern( const OUString& rStr ); + + /** + * Go through all string objects in the pool, and clear those that are no + * longer used outside of the pool. + */ + void purge(); + + size_t getCount() const; + + size_t getCountIgnoreCase() const; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/sigstruct.hxx b/include/svl/sigstruct.hxx new file mode 100644 index 000000000..38c1ee5ed --- /dev/null +++ b/include/svl/sigstruct.hxx @@ -0,0 +1,160 @@ +/* -*- 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_XMLSECURITY_INC_SIGSTRUCT_HXX +#define INCLUDED_XMLSECURITY_INC_SIGSTRUCT_HXX + +#include <rtl/ustring.hxx> +#include <com/sun/star/util/DateTime.hpp> +#include <com/sun/star/xml/crypto/SecurityOperationStatus.hpp> +#include <com/sun/star/xml/crypto/DigestID.hpp> +#include <com/sun/star/uno/Sequence.hxx> + +#include <set> +#include <vector> + +namespace com::sun::star::graphic { class XGraphic; } + +/* + * type of reference + */ +enum class SignatureReferenceType +{ + SAMEDOCUMENT = 1, + BINARYSTREAM = 2, + XMLSTREAM = 3 +}; + +struct SignatureReferenceInformation +{ + SignatureReferenceType nType; + OUString ouURI; + // For ODF: XAdES digests (SHA256) or the old SHA1, from css::xml::crypto::DigestID + sal_Int32 nDigestID; + OUString ouDigestValue; + /// Type of the reference: a URI (newer idSignedProperties references) or empty. + OUString ouType; + + SignatureReferenceInformation() : + nType(SignatureReferenceType::SAMEDOCUMENT), + ouURI(""), + nDigestID(css::xml::crypto::DigestID::SHA1), + ouDigestValue("") + { + } + + SignatureReferenceInformation( SignatureReferenceType type, sal_Int32 digestID, const OUString& uri, const OUString& rType ) : + SignatureReferenceInformation() + { + nType = type; + nDigestID = digestID; + ouURI = uri; + ouType = rType; + } +}; + +typedef ::std::vector< SignatureReferenceInformation > SignatureReferenceInformations; + +namespace svl +{ +namespace crypto +{ +/// Specifies the algorithm used for signature generation and validation. +enum class SignatureMethodAlgorithm +{ + RSA, + ECDSA +}; +} +} + +struct SignatureInformation +{ + sal_Int32 nSecurityId; + css::xml::crypto::SecurityOperationStatus nStatus; + SignatureReferenceInformations vSignatureReferenceInfors; + OUString ouX509IssuerName; + OUString ouX509SerialNumber; + OUString ouX509Certificate; + + OUString ouGpgKeyID; + OUString ouGpgCertificate; + OUString ouGpgOwner; + + OUString ouSignatureValue; + css::util::DateTime stDateTime; + + // XAdES EncapsulatedX509Certificate values + std::set<OUString> maEncapsulatedX509Certificates; + + //We also keep the date and time as string. This is done when this + //structure is created as a result of a XML signature being read. + //When then a signature is added or another removed, then the original + //XML signatures are written again (unless they have been removed). + //If the date time string is converted into the DateTime structure + //then information can be lost because it only holds a fractional + //of a second with an accuracy of one hundredth of second. + //If the string contains + //milliseconds (because the document was created by an application other than OOo) + //and the converted time is written back, then the string looks different + //and the signature is broken. + OUString ouDateTime; + OUString ouSignatureId; + OUString ouPropertyId; + /// Characters of the <dc:description> element inside the signature. + OUString ouDescription; + /// The Id attribute of the <SignatureProperty> element that contains the <dc:description>. + OUString ouDescriptionPropertyId; + /// OOXML certificate SHA-256 digest, empty for ODF except when doing XAdES signature. + OUString ouCertDigest; + /// Valid and invalid signature line images + css::uno::Reference<css::graphic::XGraphic> aValidSignatureImage; + css::uno::Reference<css::graphic::XGraphic> aInvalidSignatureImage; + /// Signature Line Id, used to map signatures to their respective signature line images. + OUString ouSignatureLineId; + /// A full OOXML signature for unchanged roundtrip, empty for ODF. + css::uno::Sequence<sal_Int8> aSignatureBytes; + /// For PDF: digest format, from css::xml::crypto::DigestID + sal_Int32 nDigestID; + /// For PDF: has id-aa-signingCertificateV2 as a signed attribute. + bool bHasSigningCertificate; + /// For PDF: the byte range doesn't cover the whole document. + bool bPartialDocumentSignature; + + /// The certificate owner (aka subject). + OUString ouSubject; + + svl::crypto::SignatureMethodAlgorithm eAlgorithmID; + + SignatureInformation( sal_Int32 nId ) + { + nSecurityId = nId; + nStatus = css::xml::crypto::SecurityOperationStatus_UNKNOWN; + nDigestID = 0; + bHasSigningCertificate = false; + bPartialDocumentSignature = false; + eAlgorithmID = svl::crypto::SignatureMethodAlgorithm::RSA; + } +}; + +typedef ::std::vector< SignatureInformation > SignatureInformations; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/slstitm.hxx b/include/svl/slstitm.hxx new file mode 100644 index 000000000..48e558149 --- /dev/null +++ b/include/svl/slstitm.hxx @@ -0,0 +1,72 @@ +/* -*- 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_SVL_SLSTITM_HXX +#define INCLUDED_SVL_SLSTITM_HXX + +#include <vector> + +#include <svl/svldllapi.h> +#include <svl/poolitem.hxx> +#include <memory> + +namespace com::sun::star::uno { template <class E> class Sequence; } + +class SVL_DLLPUBLIC SfxStringListItem final : public SfxPoolItem +{ + std::shared_ptr<std::vector<OUString>> mpList; + +public: + static SfxPoolItem* CreateDefault(); + + SfxStringListItem(); + SfxStringListItem( sal_uInt16 nWhich, const std::vector<OUString> *pList=nullptr ); + virtual ~SfxStringListItem() override; + + SfxStringListItem(SfxStringListItem const &) = default; + SfxStringListItem(SfxStringListItem &&) = default; + SfxStringListItem & operator =(SfxStringListItem const &) = delete; // due to SfxPoolItem + SfxStringListItem & operator =(SfxStringListItem &&) = delete; // due to SfxPoolItem + + std::vector<OUString>& GetList(); + + const std::vector<OUString>& GetList() const; + + // String-Separator: \n + void SetString( const OUString& ); + OUString GetString(); + + void SetStringList( const css::uno::Sequence< OUString >& rList ); + void GetStringList( css::uno::Sequence< OUString >& rList ) const; + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual bool GetPresentation( SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString &rText, + const IntlWrapper& ) const override; + virtual SfxStringListItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + virtual bool PutValue ( const css::uno::Any& rVal, + sal_uInt8 nMemberId ) override; + virtual bool QueryValue( css::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const override; +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/solar.hrc b/include/svl/solar.hrc new file mode 100644 index 000000000..317d45a84 --- /dev/null +++ b/include/svl/solar.hrc @@ -0,0 +1,96 @@ +/* -*- 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_SVL_SOLAR_HRC +#define INCLUDED_SVL_SOLAR_HRC + +// defines ------------------------------------------------------------------ + +#define OWN_ATTR_VALUE_START 3900 +#define OWN_ATTR_VALUE_END 4005 + +#define RID_LIB_START 10000 +#define RID_LIB_END 19999 + +#define RID_SVX_START (RID_LIB_START) +// RID_SVX_END (RID_LIB_START+499) + +#define RID_OFA_START (RID_LIB_START+6900) +// RID_OFA_END (RID_LIB_START+7399) + +// do *NOT* add more ranges here, RID_LIB_END is (RID_LIB_START + 10000) + +#define RID_APP_START 20000 +// RID_APP_END 31999 + +#define RID_SW_START (20000) +// RID_SW_END (25999) + +// free: 26000-28199 + +// Help-Ids -------------------------------------------------------------- + +#define HID_START 32768 + +#define HID_SC_START (HID_START+25000) +// HID_SC_END (HID_START+26999) + +#define HID_SD_START (HID_START+27000) +// HID_SD_END (HID_START+27999) + +// Slot Ids + +#define SID_SFX_START 5000 +// SID_SFX_END 8999 +#define SID_DOCKWIN_START 9800 +// SID_DOCKWIN_END 9999 + +#define SID_LIB_START 10000 +// SID_LIB_END 19999 +// free: 20000-29999 +#define SID_OBJ_START 30000 + +#define SID_SW_START 20000 +// SID_SW_END 25999 +#define SID_SC_START 26000 +// SID_SC_END 26999 +#define SID_SD_START 27000 +// SID_SD_END 27999 + +#define SID_SMA_START (SID_OBJ_START + 256) +// SID_SMA_END (SID_OBJ_START + 511) +#define SID_BASICIDE_START (SID_OBJ_START + 768) +// SID_BASICIDE_END (SID_BASICIDE_START + 255) + +#define SID_SVX_START SID_LIB_START // 10000 +#define SID_SVX_END (SID_SVX_START + 1499) +#define SID_EDIT_START (SID_SVX_END + 1) // 11500 +#define SID_EDIT_END (SID_EDIT_START + 499) +#define SID_OPTIONS_START (SID_EDIT_END + 1) // 12000 +#define SID_OPTIONS_END (SID_OPTIONS_START + 100) +#define SID_SBA_START (SID_OPTIONS_END + 1) // 12101 +#define SID_SBA_END (SID_SBA_START + 149) +#define SID_DBACCESS_START (SID_SBA_END + 1) // 12251 +#define SID_DBACCESS_END (SID_DBACCESS_START + 200) +#define SID_RPTUI_START (SID_DBACCESS_END + 1) // 12452 +// SID_RPTUI_END (SID_RPTUI_START + 199) + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/srchdefs.hxx b/include/svl/srchdefs.hxx new file mode 100644 index 000000000..d77341c36 --- /dev/null +++ b/include/svl/srchdefs.hxx @@ -0,0 +1,50 @@ +/* -*- 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_SVL_SRCHDEFS_HXX +#define INCLUDED_SVL_SRCHDEFS_HXX + +#include <o3tl/typed_flags_set.hxx> + +enum class SearchOptionFlags +{ + NONE = 0x0000, + SEARCH = 0x0001, + SEARCHALL = 0x0002, // named to this way to avoid conflict with macro on Windows. + REPLACE = 0x0004, + REPLACE_ALL = 0x0008, + WHOLE_WORDS = 0x0010, + BACKWARDS = 0x0020, + REG_EXP = 0x0040, + EXACT = 0x0080, + SELECTION = 0x0100, + FAMILIES = 0x0200, + FORMAT = 0x0400, + SIMILARITY = 0x0800, + WILDCARD = 0x1000, + ALL = 0x1fff +}; +namespace o3tl +{ + template<> struct typed_flags<SearchOptionFlags> : is_typed_flags<SearchOptionFlags, 0x1fff> {}; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/srchitem.hxx b/include/svl/srchitem.hxx new file mode 100644 index 000000000..c7f7381f7 --- /dev/null +++ b/include/svl/srchitem.hxx @@ -0,0 +1,323 @@ +/* -*- 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_SVL_SRCHITEM_HXX +#define INCLUDED_SVL_SRCHITEM_HXX + +#include <sal/config.h> +#include <svl/svldllapi.h> +#include <com/sun/star/util/SearchAlgorithms2.hpp> +#include <com/sun/star/util/SearchFlags.hpp> +#include <i18nutil/transliteration.hxx> +#include <i18nutil/searchopt.hxx> +#include <unotools/configitem.hxx> +#include <svl/style.hxx> +#include <svl/poolitem.hxx> + +// defines --------------------------------------------------------------- + +// commands +enum class SvxSearchCmd +{ + FIND = 0, + FIND_ALL = 1, + REPLACE = 2, + REPLACE_ALL = 3, +}; + +// search flags +enum class SvxSearchCellType +{ + FORMULA = 0, + VALUE = 1, + NOTE = 2, +}; + +enum class SvxSearchApp +{ + WRITER = 0, + CALC = 1, + DRAW = 2, +}; + +// class SvxSearchItem --------------------------------------------------- + +class SVL_DLLPUBLIC SvxSearchItem final : + public SfxPoolItem, + public utl::ConfigItem +{ + i18nutil::SearchOptions2 m_aSearchOpt; + + SfxStyleFamily m_eFamily; // style family + + SvxSearchCmd m_nCommand; // command (Search, Search all, Replace, Replace all) + + // Calc-specific + SvxSearchCellType m_nCellType; // Search in Formulas/Values/Notes + SvxSearchApp m_nAppFlag; // application which the dialog is for + bool m_bRowDirection; // search direction: row-wise/column-wise + bool m_bAllTables; // search in all sheets + bool m_bSearchFiltered; // search filtered cells. + bool m_bSearchFormatted; // search formatted display strings + + // Writer-specific + bool m_bNotes; + + bool m_bBackward; // search backwards + bool m_bPattern; // search for styles + bool m_bContent; // search in content + bool m_bAsianOptions; // use asian options? + + // Start search at this point (absolute twips). + sal_Int32 m_nStartPointX; + sal_Int32 m_nStartPointY; + + virtual void ImplCommit() override; + +public: + static SfxPoolItem* CreateDefault(); + + explicit SvxSearchItem( const sal_uInt16 nId ); + SvxSearchItem( const SvxSearchItem& rItem ); + virtual ~SvxSearchItem() override; + + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; + virtual bool operator == ( const SfxPoolItem& ) const override; + virtual SvxSearchItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool GetPresentation( SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString &rText, const IntlWrapper& ) const override; + + // ConfigItem + virtual void Notify( const css::uno::Sequence< OUString > &rPropertyNames ) override; + + SvxSearchCmd GetCommand() const { return m_nCommand; } + void SetCommand(SvxSearchCmd nNewCommand) { m_nCommand = nNewCommand; } + + inline const OUString& GetSearchString() const; + inline void SetSearchString(const OUString& rNewString); + + inline const OUString& GetReplaceString() const; + inline void SetReplaceString(const OUString& rNewString); + + inline bool GetWordOnly() const; + void SetWordOnly(bool bNewWordOnly); + + inline bool GetExact() const; + void SetExact(bool bNewExact); + + bool GetBackward() const { return m_bBackward; } + void SetBackward(bool bNewBackward) { m_bBackward = bNewBackward; } + + inline bool GetSelection() const; + void SetSelection(bool bNewSelection); + + inline bool GetRegExp() const; + void SetRegExp( bool bVal ); + + inline bool GetWildcard() const; + void SetWildcard( bool bVal ); + + bool GetPattern() const { return m_bPattern; } + void SetPattern(bool bNewPattern) { m_bPattern = bNewPattern; } + + SfxStyleFamily GetFamily() const { return m_eFamily; } + void SetFamily( SfxStyleFamily eNewFamily ) + { m_eFamily = eNewFamily; } + + bool GetRowDirection() const { return m_bRowDirection; } + void SetRowDirection(bool bNewRowDirection) { m_bRowDirection = bNewRowDirection; } + + bool IsAllTables() const { return m_bAllTables; } + void SetAllTables(bool bNew) { m_bAllTables = bNew; } + + bool IsSearchFiltered() const { return m_bSearchFiltered; } + void SetSearchFiltered(bool b) { m_bSearchFiltered = b; } + + bool IsSearchFormatted() const { return m_bSearchFormatted; } + void SetSearchFormatted(bool b) { m_bSearchFormatted = b; } + + SvxSearchCellType GetCellType() const { return m_nCellType; } + void SetCellType(SvxSearchCellType nNewCellType) { m_nCellType = nNewCellType; } + + bool GetNotes() const { return m_bNotes; } + void SetNotes(bool bNew) { m_bNotes = bNew; } + + SvxSearchApp GetAppFlag() const { return m_nAppFlag; } + void SetAppFlag(SvxSearchApp nNewAppFlag) { m_nAppFlag = nNewAppFlag; } + + inline bool IsLevenshtein() const; + void SetLevenshtein( bool bVal ); + + inline bool IsLEVRelaxed() const; + void SetLEVRelaxed(bool bSet); + + inline sal_uInt16 GetLEVOther() const; + inline void SetLEVOther(sal_uInt16 nSet); + + inline sal_uInt16 GetLEVShorter() const; + inline void SetLEVShorter(sal_uInt16 nSet); + + inline sal_uInt16 GetLEVLonger() const; + inline void SetLEVLonger(sal_uInt16 nSet); + + inline const i18nutil::SearchOptions2 & + GetSearchOptions() const; + inline void SetSearchOptions( const i18nutil::SearchOptions2 &rOpt ); + + inline TransliterationFlags + GetTransliterationFlags() const; + void SetTransliterationFlags( TransliterationFlags nFlags ); + + inline bool IsMatchFullHalfWidthForms() const; + void SetMatchFullHalfWidthForms( bool bVal ); + + bool IsUseAsianOptions() const { return m_bAsianOptions; } + void SetUseAsianOptions( bool bVal ) { m_bAsianOptions = bVal; } + + sal_Int32 GetStartPointX() const; + sal_Int32 GetStartPointY() const; + /// Either x or y start point is set. + bool HasStartPoint() const; +}; + +const OUString& SvxSearchItem::GetSearchString() const +{ + return m_aSearchOpt.searchString; +} + +void SvxSearchItem::SetSearchString(const OUString& rNewString) +{ + m_aSearchOpt.searchString = rNewString; +} + +const OUString& SvxSearchItem::GetReplaceString() const +{ + return m_aSearchOpt.replaceString; +} + +void SvxSearchItem::SetReplaceString(const OUString& rNewString) +{ + m_aSearchOpt.replaceString = rNewString; +} + +bool SvxSearchItem::GetWordOnly() const +{ + return 0 != (m_aSearchOpt.searchFlag & + css::util::SearchFlags::NORM_WORD_ONLY); +} + +bool SvxSearchItem::GetExact() const +{ + return !(m_aSearchOpt.transliterateFlags & TransliterationFlags::IGNORE_CASE); +} + +bool SvxSearchItem::GetSelection() const +{ + return 0 != (m_aSearchOpt.searchFlag & css::util::SearchFlags::REG_NOT_BEGINOFLINE); +} + +bool SvxSearchItem::GetRegExp() const +{ + // Ensure old and new algorithm types are in sync until all places are + // adapted to use only new types. + assert( (m_aSearchOpt.algorithmType == css::util::SearchAlgorithms_REGEXP) == + (m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::REGEXP)); + return m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::REGEXP ; +} + +bool SvxSearchItem::GetWildcard() const +{ + // Ensure old and new algorithm types are in sync, in this case old is not + // REGEXP or APPROXIMATE. + assert( m_aSearchOpt.AlgorithmType2 != css::util::SearchAlgorithms2::WILDCARD || + (m_aSearchOpt.algorithmType != css::util::SearchAlgorithms_REGEXP && + m_aSearchOpt.algorithmType != css::util::SearchAlgorithms_APPROXIMATE) ); + return m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::WILDCARD ; +} + +bool SvxSearchItem::IsLEVRelaxed() const +{ + return 0 != (m_aSearchOpt.searchFlag & css::util::SearchFlags::LEV_RELAXED); +} + +sal_uInt16 SvxSearchItem::GetLEVOther() const +{ + return static_cast<sal_Int16>(m_aSearchOpt.changedChars); +} + +void SvxSearchItem::SetLEVOther( sal_uInt16 nVal ) +{ + m_aSearchOpt.changedChars = nVal; +} + +sal_uInt16 SvxSearchItem::GetLEVShorter() const +{ + return static_cast<sal_Int16>(m_aSearchOpt.insertedChars); +} + +void SvxSearchItem::SetLEVShorter( sal_uInt16 nVal ) +{ + m_aSearchOpt.insertedChars = nVal; +} + +sal_uInt16 SvxSearchItem::GetLEVLonger() const +{ + return static_cast<sal_Int16>(m_aSearchOpt.deletedChars); +} + +void SvxSearchItem::SetLEVLonger( sal_uInt16 nVal ) +{ + m_aSearchOpt.deletedChars = nVal; +} + +bool SvxSearchItem::IsLevenshtein() const +{ + // Ensure old and new algorithm types are in sync until all places are + // adapted to use only new types. + assert( (m_aSearchOpt.algorithmType == css::util::SearchAlgorithms_APPROXIMATE) == + (m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::APPROXIMATE)); + return m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::APPROXIMATE; +} + +const i18nutil::SearchOptions2 & SvxSearchItem::GetSearchOptions() const +{ + return m_aSearchOpt; +} + +void SvxSearchItem::SetSearchOptions( const i18nutil::SearchOptions2 &rOpt ) +{ + m_aSearchOpt = rOpt; +} + +TransliterationFlags SvxSearchItem::GetTransliterationFlags() const +{ + return m_aSearchOpt.transliterateFlags; +} + +bool SvxSearchItem::IsMatchFullHalfWidthForms() const +{ + return bool(m_aSearchOpt.transliterateFlags & TransliterationFlags::IGNORE_WIDTH); +} + +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/stritem.hxx b/include/svl/stritem.hxx new file mode 100644 index 000000000..fe3695f79 --- /dev/null +++ b/include/svl/stritem.hxx @@ -0,0 +1,45 @@ +/* -*- 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_SVL_STRITEM_HXX +#define INCLUDED_SVL_STRITEM_HXX + +#include <svl/svldllapi.h> +#include <svl/custritm.hxx> + + +class SVL_DLLPUBLIC SfxStringItem: public CntUnencodedStringItem +{ +public: + static SfxPoolItem* CreateDefault(); + + SfxStringItem(sal_uInt16 which = 0): CntUnencodedStringItem(which) {} + + SfxStringItem(sal_uInt16 which, const OUString & rValue): + CntUnencodedStringItem(which, rValue) {} + + virtual SfxStringItem* Clone(SfxItemPool * = nullptr) const override; + + void dumpAsXml(xmlTextWriterPtr pWriter) const override; + +}; + +#endif // INCLUDED_SVL_STRITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/style.hxx b/include/svl/style.hxx new file mode 100644 index 000000000..ea2efab75 --- /dev/null +++ b/include/svl/style.hxx @@ -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 . + */ + +#ifndef INCLUDED_SVL_STYLE_HXX +#define INCLUDED_SVL_STYLE_HXX + +#include <config_options.h> +#include <com/sun/star/style/XStyle.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> + +#include <rtl/ref.hxx> +#include <comphelper/weak.hxx> +#include <cppuhelper/implbase.hxx> +#include <svl/svldllapi.h> +#include <svl/hint.hxx> +#include <svl/lstner.hxx> +#include <svl/SfxBroadcaster.hxx> +#include <svl/stylesheetuser.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <tools/mapunit.hxx> +#include <tools/solar.h> + +#include <memory> + +// This is used as a flags enum in sw/, but only there, +// so I don't pull in o3tl::typed_flags here +enum class SfxStyleFamily { + None = 0x00, + Char = 0x01, + Para = 0x02, + Frame = 0x04, + Page = 0x08, + Pseudo = 0x10, + Table = 0x20, + Cell = 0x40, + All = 0x7fff +}; + +enum class SfxStyleSearchBits { + // sc/calc styles + ScStandard = 0x0001, + + // sw/writer styles + SwText = 0x0001, + SwChapter = 0x0002, + SwList = 0x0004, + SwIndex = 0x0008, + SwExtra = 0x0010, + SwHtml = 0x0020, + SwCondColl = 0x0040, + + Auto = 0x0000, ///< automatic: flags from application + Hidden = 0x0200, ///< hidden styles (search mask) + ReadOnly = 0x2000, ///< readonly styles (search mask) + Used = 0x4000, ///< used styles (search mask) + UserDefined = 0x8000, ///< user defined styles (search mask) + AllVisible = 0xe07f, ///< all visible styles + All = 0xe27f, ///< all styles +}; +namespace o3tl { + template<> struct typed_flags<SfxStyleSearchBits> : is_typed_flags<SfxStyleSearchBits, 0xe27f> {}; +} + + +class SfxItemSet; +class SfxItemPool; +class SfxStyleSheetBasePool; +class SvStream; + +namespace svl { class IndexedStyleSheets; } +/* +Everyone changing instances of SfxStyleSheetBasePool or SfxStyleSheetBase +must broadcast this using <SfxStyleSheetBasePool::GetBroadcaster()> broadcasts. +The class <SfxStyleSheetHint> is used for this, it contains an Action-Id and a +pointer to the <SfxStyleSheetBase>. The actions are: + +#define SfxHintId::StyleSheetCreated // style is created +#define SfxHintId::StyleSheetModified // style is modified +#define SfxHintId::StyleSheetChanged // style is replaced +#define SfxHintId::StyleSheetErased // style is deleted + +The following methods already broadcast themself + +SfxSimpleHint(SfxHintId::Dying) from: + SfxStyleSheetBasePool::~SfxStyleSheetBasePool() + +SfxStyleSheetHint( SfxHintId::StyleSheetCreated, *p ) from: + SfxStyleSheetBasePool::Make( const String& rName, + SfxStyleFamily eFam, sal_uInt16 mask) + +SfxStyleSheetHint( SfxHintId::StyleSheetChanged, *pNew ) from: + SfxStyleSheetBasePool::Add( SfxStyleSheetBase& rSheet ) + +SfxStyleSheetHint( SfxHintId::StyleSheetErased, *p ) from: + SfxStyleSheetBasePool::Erase( SfxStyleSheetBase* p ) + SfxStyleSheetBasePool::Clear() +*/ + +class SVL_DLLPUBLIC SfxStyleSheetBase : public comphelper::OWeakTypeObject +{ +private: + friend class SfxStyleSheetBasePool; + +protected: + SfxStyleSheetBasePool* m_pPool; // related pool + SfxStyleFamily nFamily; + + OUString aName, aParent, aFollow; + OUString aHelpFile; // name of the help file + SfxItemSet* pSet; // ItemSet + SfxStyleSearchBits nMask; // Flags + + sal_uLong nHelpId; // help ID + + bool bMySet; // sal_True: delete Set in dtor + bool bHidden; + + SfxStyleSheetBase( const OUString&, SfxStyleSheetBasePool*, SfxStyleFamily eFam, SfxStyleSearchBits mask ); + SfxStyleSheetBase( const SfxStyleSheetBase& ); + virtual ~SfxStyleSheetBase() override; + +public: + + // returns the internal name of this style + const OUString& GetName() const; + + // sets the internal name of this style. + // + // If the name of a style is changed, then the styles container needs to be + // reindexed (see IndexedStyleSheets). If you set bReindexNow to false to + // defer that indexing, then you must call the Reindex manually on the + // SfxStyleSheetBasePool parent. + virtual bool SetName(const OUString& rNewName, bool bReindexNow = true); + + virtual const OUString& GetParent() const; + virtual bool SetParent( const OUString& ); + virtual const OUString& GetFollow() const; + virtual bool SetFollow( const OUString& ); + virtual bool HasFollowSupport() const; // Default true + virtual bool HasParentSupport() const; // Default true + virtual bool HasClearParentSupport() const; // Default false + virtual bool IsUsed() const; // Default true + virtual OUString GetDescription( MapUnit eMetric ); + + virtual OUString GetUsedBy() { return OUString(); } + + SfxStyleSheetBasePool* GetPool() { return m_pPool; } + SfxStyleFamily GetFamily() const { return nFamily; } + SfxStyleSearchBits GetMask() const { return nMask; } + void SetMask( SfxStyleSearchBits mask) { nMask = mask; } + bool IsUserDefined() const + { return bool( nMask & SfxStyleSearchBits::UserDefined); } + + virtual bool IsHidden() const { return bHidden; } + virtual void SetHidden( bool bValue ); + + virtual sal_uLong GetHelpId( OUString& rFile ); + virtual void SetHelpId( const OUString& r, sal_uLong nId ); + + virtual SfxItemSet& GetItemSet(); + /// Due to writer's usual lack of sanity this is a separate function for + /// preview only; it shall not create the style in case it does not exist. + /// If the style has parents, it is _not_ required that the returned item + /// set has parents (i.e. use it for display purposes only). + virtual std::unique_ptr<SfxItemSet> GetItemSetForPreview(); + + /// Fix for expensive dynamic_cast + virtual bool isScStyleSheet() const { return false; } +}; + +/* Class to iterate and search on a SfxStyleSheetBasePool */ +class SVL_DLLPUBLIC SfxStyleSheetIterator +{ +public: + /** Constructor. + * The iterator will only iterate over style sheets which have the family \p eFam + */ + SfxStyleSheetIterator(SfxStyleSheetBasePool *pBase, + SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All ); + SfxStyleSearchBits GetSearchMask() const; + SfxStyleFamily GetSearchFamily() const; + virtual sal_uInt16 Count(); + virtual SfxStyleSheetBase *operator[](sal_uInt16 nIdx); + virtual SfxStyleSheetBase* First(); + virtual SfxStyleSheetBase* Next(); + virtual SfxStyleSheetBase* Find(const OUString& rStr); + virtual ~SfxStyleSheetIterator(); + + bool SearchUsed() const { return bSearchUsed; } + +protected: + + SfxStyleSheetBasePool* pBasePool; + SfxStyleFamily nSearchFamily; + SfxStyleSearchBits nMask; + + +private: + SVL_DLLPRIVATE bool IsTrivialSearch() const; + + SfxStyleSheetBase* pCurrentStyle; + sal_uInt16 nCurrentPosition; + bool bSearchUsed; + +friend class SfxStyleSheetBasePool; +}; + +class SfxStyleSheetBasePool_Impl; + +class SVL_DLLPUBLIC SfxStyleSheetBasePool: public SfxBroadcaster, public comphelper::OWeakTypeObject +{ +friend class SfxStyleSheetIterator; +friend class SfxStyleSheetBase; + + std::unique_ptr<SfxStyleSheetBasePool_Impl> pImpl; + + SfxStyleSheetIterator& GetIterator_Impl(SfxStyleFamily eFamily, SfxStyleSearchBits eMask); +protected: + SfxStyleSheetIterator* GetCachedIterator(); + + SfxItemPool& rPool; + + void ChangeParent(const OUString& rOld, const OUString& rNew, SfxStyleFamily eFamily, bool bVirtual = true); + virtual SfxStyleSheetBase* Create( const OUString&, SfxStyleFamily, SfxStyleSearchBits ); + virtual SfxStyleSheetBase* Create( const SfxStyleSheetBase& ); + + virtual ~SfxStyleSheetBasePool() override; + + void StoreStyleSheet(const rtl::Reference< SfxStyleSheetBase >&); + + /** Obtain the indexed style sheets. + */ + const svl::IndexedStyleSheets& + GetIndexedStyleSheets() const; + SfxStyleSheetBase* GetStyleSheetByPositionInIndex(unsigned pos); + +public: + SfxStyleSheetBasePool( SfxItemPool& ); + SfxStyleSheetBasePool( const SfxStyleSheetBasePool& ); + + SfxItemPool& GetPool() { return rPool;} + const SfxItemPool& GetPool() const { return rPool;} + + virtual std::unique_ptr<SfxStyleSheetIterator> CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask = SfxStyleSearchBits::All); + + virtual SfxStyleSheetBase& Make(const OUString&, + SfxStyleFamily eFam, + SfxStyleSearchBits nMask = SfxStyleSearchBits::All); + + virtual void Remove( SfxStyleSheetBase* ); + void Insert( SfxStyleSheetBase* ); + + void Clear(); + + SfxStyleSheetBasePool& operator=( const SfxStyleSheetBasePool& ); + SfxStyleSheetBasePool& operator+=( const SfxStyleSheetBasePool& ); + + SfxStyleSheetBase* First(SfxStyleFamily eFamily, SfxStyleSearchBits eMask = SfxStyleSearchBits::All); + SfxStyleSheetBase* Next(); + virtual SfxStyleSheetBase* Find( const OUString&, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All ); + + virtual bool SetParent(SfxStyleFamily eFam, + const OUString &rStyle, + const OUString &rParent); + + void Reindex(); + /** Add a style sheet. + * Not an actual public function. Do not call it from non-subclasses. + */ + void Add( const SfxStyleSheetBase& ); +}; + +class SVL_DLLPUBLIC SfxStyleSheet: public SfxStyleSheetBase, + public SfxListener, public SfxBroadcaster, public svl::StyleSheetUser +{ +public: + + SfxStyleSheet( const OUString&, const SfxStyleSheetBasePool&, SfxStyleFamily, SfxStyleSearchBits ); + SfxStyleSheet( const SfxStyleSheet& ); + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + virtual bool isUsedByModel() const override; + + virtual bool SetParent( const OUString& ) override; + +protected: + virtual ~SfxStyleSheet() override; +}; + +class SVL_DLLPUBLIC SfxStyleSheetPool: public SfxStyleSheetBasePool +{ +protected: + using SfxStyleSheetBasePool::Create; + virtual SfxStyleSheetBase* Create(const OUString&, SfxStyleFamily, SfxStyleSearchBits mask) override; + +public: + SfxStyleSheetPool( SfxItemPool const& ); +}; + + +class SVL_DLLPUBLIC SfxStyleSheetPoolHint final : public SfxHint +{ +public: + SfxStyleSheetPoolHint() {} +}; + + +class SVL_DLLPUBLIC SfxStyleSheetHint: public SfxHint +{ + SfxStyleSheetBase* pStyleSh; +public: + SfxStyleSheetHint( SfxHintId, SfxStyleSheetBase& ); + SfxStyleSheetBase* GetStyleSheet() const + { return pStyleSh; } +}; + +class UNLESS_MERGELIBS(SVL_DLLPUBLIC) SfxStyleSheetModifiedHint final : public SfxStyleSheetHint +{ + OUString aName; + +public: + SfxStyleSheetModifiedHint( const OUString& rOld, + SfxStyleSheetBase& ); + const OUString& GetOldName() const { return aName; } +}; + +class SVL_DLLPUBLIC SfxUnoStyleSheet : public cppu::ImplInheritanceHelper<SfxStyleSheet, css::style::XStyle, css::lang::XUnoTunnel> +{ +public: + SfxUnoStyleSheet( const OUString& _rName, const SfxStyleSheetBasePool& _rPool, SfxStyleFamily _eFamily, SfxStyleSearchBits _nMask ); + + static SfxUnoStyleSheet* getUnoStyleSheet( const css::uno::Reference< css::style::XStyle >& xStyle ); + + // XUnoTunnel + static const css::uno::Sequence< ::sal_Int8 >& getUnoTunnelId(); + virtual ::sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< ::sal_Int8 >& aIdentifier ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/stylepool.hxx b/include/svl/stylepool.hxx new file mode 100644 index 000000000..0a22cb1f7 --- /dev/null +++ b/include/svl/stylepool.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 . + */ +#ifndef INCLUDED_SVL_STYLEPOOL_HXX +#define INCLUDED_SVL_STYLEPOOL_HXX + +#include <memory> +#include <rtl/ustring.hxx> +#include <svl/itemset.hxx> + +class StylePoolImpl; +class IStylePoolIteratorAccess; + +class SVL_DLLPUBLIC StylePool final +{ +private: + std::unique_ptr<StylePoolImpl> pImpl; +public: + explicit StylePool( SfxItemSet const * pIgnorableItems = nullptr ); + + /** Insert a SfxItemSet into the style pool. + + The pool makes a copy of the provided SfxItemSet. + + @param SfxItemSet + the SfxItemSet to insert + + @param pParentName + Name of the parent of rSet. If set, createIterator() can be more deterministic by iterating + over item sets ordered by parent names. + + @return a shared pointer to the SfxItemSet + */ + std::shared_ptr<SfxItemSet> insertItemSet( const SfxItemSet& rSet, const OUString* pParentName = nullptr ); + + /** Create an iterator + + The iterator walks through the StylePool + OD 2008-03-07 #i86923# + introduce optional parameter to control, if unused SfxItemsSet are skipped or not + introduce optional parameter to control, if ignorable items are skipped or not + + @attention every change, e.g. destruction, of the StylePool could cause undefined effects. + + @param bSkipUnusedItemSets + input parameter - boolean, indicating if unused SfxItemSets are skipped or not + + @param bSkipIgnorableItems + input parameter - boolean, indicating if ignorable items are skipped or not + + @postcond the iterator "points before the first" SfxItemSet of the pool. + The first StylePoolIterator::getNext() call will deliver the first SfxItemSet. + */ + std::unique_ptr<IStylePoolIteratorAccess> createIterator( const bool bSkipUnusedItemSets = false, + const bool bSkipIgnorableItems = false ); + + ~StylePool(); + + static OUString nameOf( const std::shared_ptr<SfxItemSet>& pSet ); +}; + +class SVL_DLLPUBLIC IStylePoolIteratorAccess +{ +public: + /** Delivers a shared pointer to the next SfxItemSet of the pool + If there is no more SfxItemSet, the delivered share_pointer is empty. + */ + virtual std::shared_ptr<SfxItemSet> getNext() = 0; + virtual ~IStylePoolIteratorAccess() {}; +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/stylesheetuser.hxx b/include/svl/stylesheetuser.hxx new file mode 100644 index 000000000..86975f6b2 --- /dev/null +++ b/include/svl/stylesheetuser.hxx @@ -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/. + */ + +#ifndef INCLUDED_SVL_STYLESHEETUSER_HXX +#define INCLUDED_SVL_STYLESHEETUSER_HXX + +#include <sal/config.h> + +#include <sal/types.h> + +namespace svl +{ + +/** Test whether object that uses a stylesheet is used itself. + + This interface should be implemented by all classes that use + a SfxStyleSheet (and listen on it). It can be queried by the stylesheet + to determine if it is really used. + */ +class SAL_DLLPUBLIC_RTTI StyleSheetUser +{ +public: + /** Test whether this object is used. + + @return true, if the object is used, false otherwise + */ + virtual bool isUsedByModel() const = 0; +protected: + ~StyleSheetUser() {} +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/svdde.hxx b/include/svl/svdde.hxx new file mode 100644 index 000000000..546b20710 --- /dev/null +++ b/include/svl/svdde.hxx @@ -0,0 +1,326 @@ +/* -*- 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_SVL_SVDDE_HXX +#define INCLUDED_SVL_SVDDE_HXX + +#include <sal/config.h> + +#include <svl/svldllapi.h> +#include <sot/formats.hxx> +#include <rtl/ustring.hxx> +#include <tools/solar.h> +#include <tools/link.hxx> +#include <memory> +#include <vector> + +class DdeString; +class DdeConnection; +class DdeTopic; +class DdeService; +struct DdeDataImp; +struct DdeImp; +struct DdeItemImpData; +struct Conversation; + +typedef ::std::vector< DdeService* > DdeServices; +typedef ::std::vector< long > DdeFormats; +typedef std::vector<std::unique_ptr<Conversation>> ConvList; + + +class SVL_DLLPUBLIC DdeData +{ + friend class DdeInternal; + friend class DdeService; + friend class DdeConnection; + friend class DdeTransaction; + std::unique_ptr<DdeDataImp> xImp; + + SVL_DLLPRIVATE void Lock(); + + void SetFormat( SotClipboardFormatId nFmt ); + +public: + DdeData(); + DdeData(SAL_UNUSED_PARAMETER const void*, SAL_UNUSED_PARAMETER long, SAL_UNUSED_PARAMETER SotClipboardFormatId = SotClipboardFormatId::STRING); + DdeData(SAL_UNUSED_PARAMETER const OUString&); + DdeData(const DdeData&); + DdeData(DdeData&&) noexcept; + ~DdeData(); + + void const * getData() const; + long getSize() const; + + SotClipboardFormatId GetFormat() const; + + DdeData& operator=(const DdeData&); + DdeData& operator=(DdeData&&) noexcept; + + static sal_uLong GetExternalFormat(SotClipboardFormatId nFmt); + static SotClipboardFormatId GetInternalFormat(sal_uLong nFmt); +}; + + +class SVL_DLLPUBLIC DdeTransaction +{ +public: + void Data( const DdeData* ); + void Done( bool bDataValid ); +protected: + DdeConnection& rDde; + DdeData aDdeData; + DdeString* pName; + short nType; + sal_IntPtr nId; + sal_IntPtr nTime; + Link<const DdeData*,void> aData; + Link<bool,void> aDone; + bool bBusy; + + DdeTransaction( DdeConnection&, SAL_UNUSED_PARAMETER const OUString&, SAL_UNUSED_PARAMETER long = 0 ); + +public: + virtual ~DdeTransaction(); + + bool IsBusy() const { return bBusy; } + OUString GetName() const; + + void Execute(); + + void SetDataHdl( const Link<const DdeData*,void>& rLink ) { aData = rLink; } + const Link<const DdeData*,void>& GetDataHdl() const { return aData; } + + void SetDoneHdl( const Link<bool,void>& rLink ) { aDone = rLink; } + const Link<bool,void>& GetDoneHdl() const { return aDone; } + + void SetFormat( SotClipboardFormatId nFmt ) { aDdeData.SetFormat( nFmt ); } + SotClipboardFormatId GetFormat() const { return aDdeData.GetFormat(); } + + long GetError() const; + +private: + friend class DdeInternal; + friend class DdeConnection; + + DdeTransaction( const DdeTransaction& ) = delete; + const DdeTransaction& operator= ( const DdeTransaction& ) = delete; + +}; + + +class SVL_DLLPUBLIC DdeLink : public DdeTransaction +{ + Link<void*,void> aNotify; + +public: + DdeLink( DdeConnection&, const OUString&, long = 0 ); + virtual ~DdeLink() override; + + void SetNotifyHdl( const Link<void*,void>& rLink ) { aNotify = rLink; } + const Link<void*,void>& GetNotifyHdl() const { return aNotify; } + void Notify(); +}; + + +class SVL_DLLPUBLIC DdeHotLink : public DdeLink +{ +public: + DdeHotLink( DdeConnection&, const OUString& ); +}; + + +class SVL_DLLPUBLIC DdeRequest : public DdeTransaction +{ +public: + DdeRequest( DdeConnection&, const OUString&, long = 0 ); +}; + + +class SVL_DLLPUBLIC DdePoke : public DdeTransaction +{ +public: + DdePoke( DdeConnection&, const OUString&, SAL_UNUSED_PARAMETER const DdeData&, long = 0 ); +}; + + +class SVL_DLLPUBLIC DdeExecute : public DdeTransaction +{ +public: + DdeExecute( DdeConnection&, const OUString&, long = 0 ); +}; + + +class SVL_DLLPUBLIC DdeConnection +{ + friend class DdeInternal; + friend class DdeTransaction; + std::vector<DdeTransaction*> aTransactions; + DdeString* pService; + DdeString* pTopic; + std::unique_ptr<DdeImp> pImp; + +public: + DdeConnection( SAL_UNUSED_PARAMETER const OUString&, SAL_UNUSED_PARAMETER const OUString& ); + ~DdeConnection(); + + long GetError() const; + + static const std::vector<DdeConnection*>& GetConnections(); + + bool IsConnected(); + + OUString GetServiceName() const; + OUString GetTopicName() const; + +private: + DdeConnection( const DdeConnection& ) = delete; + const DdeConnection& operator= ( const DdeConnection& ) = delete; +}; + + +class SVL_DLLPUBLIC DdeItem +{ + friend class DdeInternal; + friend class DdeTopic; + DdeString* pName; + DdeTopic* pMyTopic; + std::vector<DdeItemImpData>* pImpData; + +protected: + sal_uInt8 nType; + +public: + DdeItem( const sal_Unicode* ); + DdeItem( SAL_UNUSED_PARAMETER const OUString& ); + DdeItem( const DdeItem& ); + virtual ~DdeItem(); + + OUString GetName() const; + short GetLinks(); + void NotifyClient(); +}; + + +class SVL_DLLPUBLIC DdeGetPutItem : public DdeItem +{ +public: + DdeGetPutItem( const sal_Unicode* p ); + DdeGetPutItem( const OUString& rStr ); + DdeGetPutItem( const DdeItem& rItem ); + + virtual DdeData* Get( SotClipboardFormatId ); + virtual bool Put( const DdeData* ); + virtual void AdviseLoop( bool ); // Start / Stop AdviseLoop +}; + + +class SVL_DLLPUBLIC DdeTopic +{ + +public: + virtual DdeData* Get(SotClipboardFormatId); + virtual bool Put( const DdeData* ); + virtual bool Execute( const OUString* ); + // Eventually create a new item. return 0 -> Item creation failed + virtual bool MakeItem( const OUString& rItem ); + + // A Warm-/Hot-Link is created. Return true if successful + virtual bool StartAdviseLoop(); + +private: + friend class DdeInternal; + friend class DdeService; + friend class DdeItem; + +private: + DdeString* pName; + OUString aItem; + std::vector<DdeItem*> aItems; + +public: + DdeTopic( SAL_UNUSED_PARAMETER const OUString& ); + virtual ~DdeTopic(); + + OUString GetName() const; + + void NotifyClient( const OUString& ); + bool IsSystemTopic(); + + void InsertItem( DdeItem* ); // For own superclasses + DdeItem* AddItem( const DdeItem& ); // Will be cloned + void RemoveItem( const DdeItem& ); + const OUString& GetCurItem() const { return aItem; } + const std::vector<DdeItem*>& GetItems() const { return aItems; } + +private: + DdeTopic( const DdeTopic& ) = delete; + const DdeTopic& operator= ( const DdeTopic& ) = delete; +}; + + +class SVL_DLLPUBLIC DdeService +{ + friend class DdeInternal; + +protected: + OUString Topics(); + OUString Formats(); + OUString SysItems(); + OUString Status(); + + const DdeTopic* GetSysTopic() const { return pSysTopic; } +private: + std::vector<DdeTopic*> aTopics; + DdeFormats aFormats; + DdeTopic* pSysTopic; + DdeString* pName; + ConvList m_vConv; + short nStatus; + + SVL_DLLPRIVATE bool HasCbFormat( sal_uInt16 ); + +public: + DdeService( SAL_UNUSED_PARAMETER const OUString& ); + virtual ~DdeService(); + + DdeService( const DdeService& ) = delete; + DdeService& operator= ( const DdeService& ) = delete; + + OUString GetName() const; + short GetError() const { return nStatus; } + + static DdeServices& GetServices(); + std::vector<DdeTopic*>& GetTopics() { return aTopics; } + + void AddTopic( const DdeTopic& ); + void RemoveTopic( const DdeTopic& ); + + void AddFormat(SotClipboardFormatId); + void RemoveFormat(SotClipboardFormatId); + bool HasFormat(SotClipboardFormatId); +}; + + +inline long DdeTransaction::GetError() const +{ + return rDde.GetError(); +} +#endif // INCLUDED_SVL_SVDDE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/svl.hrc b/include/svl/svl.hrc new file mode 100644 index 000000000..231d26c0f --- /dev/null +++ b/include/svl/svl.hrc @@ -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/. + * + * 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_SVL_SVL_HRC +#define INCLUDED_SVL_SVL_HRC + +#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String) + +// Internet Media Type Presentations + +#define STR_SVT_MIMETYPE_CNT_FSYSBOX NC_("STR_SVT_MIMETYPE_CNT_FSYSBOX", "Workplace") +#define STR_FILECTRL_BUTTONTEXT NC_("STR_FILECTRL_BUTTONTEXT", "Browse...") + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/svldllapi.h b/include/svl/svldllapi.h new file mode 100644 index 000000000..0e62d3f3b --- /dev/null +++ b/include/svl/svldllapi.h @@ -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/. + * + * 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_SVL_SVLDLLAPI_H +#define INCLUDED_SVL_SVLDLLAPI_H + +#include <sal/types.h> + +#if defined(SVL_DLLIMPLEMENTATION) +#define SVL_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define SVL_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define SVL_DLLPRIVATE SAL_DLLPRIVATE + +#endif // INCLUDED_SVL_SVLDLLAPI_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/svlresid.hxx b/include/svl/svlresid.hxx new file mode 100644 index 000000000..4b568bb12 --- /dev/null +++ b/include/svl/svlresid.hxx @@ -0,0 +1,20 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SVL_SVTRESID_HXX +#define INCLUDED_SVL_SVTRESID_HXX + +#include <svl/svldllapi.h> +#include <rtl/ustring.hxx> + +SVL_DLLPUBLIC OUString SvlResId(const char* pId); + +#endif // INCLUDED_SVL_SVTRESID_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/typedwhich.hxx b/include/svl/typedwhich.hxx new file mode 100644 index 000000000..d3f2bedec --- /dev/null +++ b/include/svl/typedwhich.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef INCLUDED_SVL_TYPEDWHICH_HXX +#define INCLUDED_SVL_TYPEDWHICH_HXX + +#include <sal/config.h> +#include <sal/types.h> + +/** + * A very thin wrapper around the sal_uInt16 WhichId whose purpose is mostly to carry type information, + * so that we Put() and Get() the right subclasses of SfxPoolItem for each WhichId. + */ +template <class T> class TypedWhichId final +{ +public: + explicit constexpr TypedWhichId(sal_uInt16 nWhich) + : mnWhich(nWhich) + { + } + constexpr operator sal_uInt16() const { return mnWhich; } + +private: + sal_uInt16 const mnWhich; +}; + +template <class T> constexpr bool operator==(sal_uInt16 lhs, TypedWhichId<T> const& rhs) +{ + return lhs == sal_uInt16(rhs); +} +template <class T> constexpr bool operator!=(sal_uInt16 lhs, TypedWhichId<T> const& rhs) +{ + return lhs != sal_uInt16(rhs); +} +template <class T> constexpr bool operator==(TypedWhichId<T> const& lhs, sal_uInt16 rhs) +{ + return sal_uInt16(lhs) == rhs; +} +template <class T> constexpr bool operator!=(TypedWhichId<T> const& lhs, sal_uInt16 rhs) +{ + return sal_uInt16(lhs) != rhs; +} + +#endif // INCLUDED_SVL_TYPEDWHICH_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx new file mode 100644 index 000000000..8de6231c1 --- /dev/null +++ b/include/svl/undo.hxx @@ -0,0 +1,335 @@ +/* -*- 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_SVL_UNDO_HXX +#define INCLUDED_SVL_UNDO_HXX + +#include <svl/svldllapi.h> +#include <rtl/ustring.hxx> +#include <tools/datetime.hxx> +#include <o3tl/strong_int.hxx> + +#include <memory> +#include <vector> + +typedef o3tl::strong_int<sal_Int32, struct ViewShellIdTag> ViewShellId; +typedef struct _xmlTextWriter* xmlTextWriterPtr; + +class SVL_DLLPUBLIC SfxRepeatTarget +{ +public: + virtual ~SfxRepeatTarget() = 0; +}; + + +class SVL_DLLPUBLIC SfxUndoContext +{ +public: + virtual ~SfxUndoContext() = 0; +}; + + +class SVL_DLLPUBLIC SfxUndoAction +{ +public: + SfxUndoAction(); + virtual ~SfxUndoAction() COVERITY_NOEXCEPT_FALSE; + + virtual void Undo(); + virtual void UndoWithContext( SfxUndoContext& i_context ); + virtual void Redo(); + virtual void RedoWithContext( SfxUndoContext& i_context ); + virtual void Repeat(SfxRepeatTarget&); + virtual bool CanRepeat(SfxRepeatTarget&) const; + + virtual bool Merge( SfxUndoAction *pNextAction ); + + virtual OUString GetComment() const; + virtual OUString GetRepeatComment(SfxRepeatTarget&) const; + /// ID of the view shell that created this undo action. + virtual ViewShellId GetViewShellId() const; + /// Timestamp when this undo item was created. + const DateTime& GetDateTime() const; + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; + +private: + SfxUndoAction( const SfxUndoAction& ) = delete; + SfxUndoAction& operator=( const SfxUndoAction& ) = delete; + + DateTime m_aDateTime; +}; + + +/// is a mark on the Undo stack +typedef sal_Int32 UndoStackMark; +#define MARK_INVALID ::std::numeric_limits< UndoStackMark >::max() + +struct MarkedUndoAction +{ + std::unique_ptr<SfxUndoAction> pAction; + ::std::vector< UndoStackMark > aMarks; + + MarkedUndoAction(std::unique_ptr<SfxUndoAction> p) : pAction(std::move(p)) {} +}; + +/** do not make use of these implementation details, unless you + really really have to! */ +struct SVL_DLLPUBLIC SfxUndoArray +{ + std::vector<MarkedUndoAction> maUndoActions; + size_t nMaxUndoActions; + size_t nCurUndoAction; + SfxUndoArray *pFatherUndoArray; + + SfxUndoArray(size_t nMax=0) : + nMaxUndoActions(nMax), nCurUndoAction(0), pFatherUndoArray(nullptr) {} + virtual ~SfxUndoArray(); + + SfxUndoArray& operator=( SfxUndoArray const & ) = delete; // MSVC2017 workaround + SfxUndoArray( SfxUndoArray const & ) = delete; // MSVC2017 workaround + + SfxUndoAction* GetUndoAction(size_t idx) { return maUndoActions[idx].pAction.get(); } + std::unique_ptr<SfxUndoAction> Remove(int idx); + void Remove( size_t i_pos, size_t i_count ); + void Insert( std::unique_ptr<SfxUndoAction> i_action, size_t i_pos ); +}; + + +/** do not make use of these implementation details, unless you + really really have to! */ +class SVL_DLLPUBLIC SfxListUndoAction final : public SfxUndoAction, public SfxUndoArray + +/* [Explanation] + + UndoAction to composite multiple Undos in one UndoAction. + These actions are used by SfxUndomanager. With < SfxUndoManager::EnterListAction > + you can go one composite level down and with < SfxUndoManager::LeaveListAction > up again. + Redo and Undo work element wise on SfxListUndoActions. +*/ +{ + struct Impl; + std::unique_ptr<Impl> mpImpl; + +public: + + SfxListUndoAction( + const OUString &rComment, const OUString& rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId, SfxUndoArray *pFather ); + virtual ~SfxListUndoAction() override; + + virtual void Undo() override; + virtual void UndoWithContext( SfxUndoContext& i_context ) override; + virtual void Redo() override; + virtual void RedoWithContext( SfxUndoContext& i_context ) override; + virtual void Repeat(SfxRepeatTarget&) override; + virtual bool CanRepeat(SfxRepeatTarget&) const override; + + virtual bool Merge( SfxUndoAction *pNextAction ) override; + + virtual OUString GetComment() const override; + /// See SfxUndoAction::GetViewShellId(). + ViewShellId GetViewShellId() const override; + virtual OUString GetRepeatComment(SfxRepeatTarget&) const override; + sal_uInt16 GetId() const; + + void SetComment(const OUString& rComment); + void dumpAsXml(xmlTextWriterPtr pWriter) const override; +}; + + +/** is a callback interface for notifications about state changes of an SfxUndoManager +*/ +class SAL_NO_VTABLE SfxUndoListener +{ +public: + virtual void actionUndone( const OUString& i_actionComment ) = 0; + virtual void actionRedone( const OUString& i_actionComment ) = 0; + virtual void undoActionAdded( const OUString& i_actionComment ) = 0; + virtual void cleared() = 0; + virtual void clearedRedo() = 0; + virtual void resetAll() = 0; + virtual void listActionEntered( const OUString& i_comment ) = 0; + virtual void listActionLeft( const OUString& i_comment ) = 0; + virtual void listActionCancelled() = 0; + +protected: + ~SfxUndoListener() {} +}; + + +namespace svl::undo::impl +{ + class UndoManagerGuard; + class LockGuard; +} + +struct SfxUndoManager_Data; +class SVL_DLLPUBLIC SfxUndoManager +{ + std::unique_ptr< SfxUndoManager_Data > + m_xData; +public: + static bool const CurrentLevel = true; + static bool const TopLevel = false; + + SfxUndoManager( size_t nMaxUndoActionCount = 20 ); + virtual ~SfxUndoManager(); + + void SetMaxUndoActionCount( size_t nMaxUndoActionCount ); + virtual void AddUndoAction( std::unique_ptr<SfxUndoAction> pAction, bool bTryMerg=false ); + virtual size_t GetUndoActionCount( bool const i_currentLevel = CurrentLevel ) const; + OUString GetUndoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const; + SfxUndoAction* GetUndoAction( size_t nNo=0 ) const; + /// Get info about all undo actions (comment, view shell id, etc.) + OUString GetUndoActionsInfo() const; + virtual size_t GetRedoActionCount( bool const i_currentLevel = CurrentLevel ) const; + OUString GetRedoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const; + SfxUndoAction* GetRedoAction() const; + /// Get info about all redo actions (comment, view shell id, etc.) + OUString GetRedoActionsInfo() const; + virtual bool Undo(); + virtual bool Redo(); + /** Clears both the Redo and the Undo stack. + Will assert and bail out when called while within a list action (<member>IsInListAction</member>). + */ + virtual void Clear(); + /** Clears the Redo stack. + Will assert and bail out when called while within a list action (<member>IsInListAction</member>). + */ + virtual void ClearRedo(); + /** leaves any possible open list action (<member>IsInListAction</member>), and clears both the Undo and the + Redo stack. + + Effectively, calling this method is equivalent to <code>while ( IsInListAction() ) LeaveListAction();</code>, + followed by <code>Clear()</code>. The only difference to this calling sequence is that Reset is an + atomic operation, also resulting in only one notification. + */ + void Reset(); + /** determines whether an Undo or Redo is currently running + */ + bool IsDoing() const; + size_t GetRepeatActionCount() const; + OUString GetRepeatActionComment( SfxRepeatTarget &rTarget) const; + bool Repeat( SfxRepeatTarget &rTarget ); + bool CanRepeat( SfxRepeatTarget &rTarget ) const; + virtual void EnterListAction(const OUString &rComment, const OUString& rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId); + /** Leaves the list action entered with EnterListAction + @return the number of the sub actions in the list which has just been left. Note that in case no such + actions exist, the list action does not contribute to the Undo stack, but is silently removed. + */ + size_t LeaveListAction(); + + /** Leaves the list action entered with EnterListAction, and forcefully merges the previous + action on the stack into the newly created list action. + + Say you have an Undo action A on the stack, then call EnterListAction, followed by one or more calls to + AddUndoAction, followed by a call to LeaveAndMergeListAction. In opposite to LeaveListAction, your Undo + stack will now still contain one undo action: the newly created list action, whose first child is the + original A, whose other children are those you added via AddUndoAction, and whose comment is the same as + the comment of A. + + Effectively, this means that all actions added between EnterListAction and LeaveAndMergeListAction are + hidden from the user. + + @return the number of the sub actions in the list which has just been left. Note that in case no such + actions exist, the list action does not contribute to the Undo stack, but is silently removed. + */ + size_t LeaveAndMergeListAction(); + /// determines whether we're within a ListAction context, i.e. a LeaveListAction/LeaveAndMergeListAction call is pending + bool IsInListAction() const; + /// Determines how many nested list actions are currently open + size_t GetListActionDepth() const; + /** Clears the redo stack and removes the top undo action */ + void RemoveLastUndoAction(); + /** enables (true) or disables (false) recording of undo actions + + If undo actions are added while undo is disabled, they are deleted. + Disabling undo does not clear the current undo buffer! + + Multiple calls to <code>EnableUndo</code> are not cumulative. That is, calling <code>EnableUndo( false )</code> + twice, and then calling <code>EnableUndo( true )</code> means that Undo is enable afterwards. + */ + void EnableUndo( bool bEnable ); + /// returns true if undo is currently enabled. + /// This returns false if undo was disabled using EnableUndo( false ) and + /// also during the runtime of the Undo() and Redo() methods. + bool IsUndoEnabled() const; + /// Adds a new listener to be notified about changes in the UndoManager's state + void AddUndoListener( SfxUndoListener& i_listener ); + void RemoveUndoListener( SfxUndoListener& i_listener ); + bool IsEmptyActions() const; + + + /** marks the current top-level element of the Undo stack, and returns a unique ID for it + */ + UndoStackMark MarkTopUndoAction(); + + /** removes a mark given by its ID. + After the call, the mark ID is invalid. + */ + void RemoveMark( UndoStackMark const i_mark ); + + /** determines whether the top action on the Undo stack has a given mark + */ + bool HasTopUndoActionMark( UndoStackMark const i_mark ); + + /** removes the oldest Undo actions from the stack + */ + void RemoveOldestUndoAction(); + + void dumpAsXml(xmlTextWriterPtr pWriter) const; + +protected: + bool UndoWithContext( SfxUndoContext& i_context ); + bool RedoWithContext( SfxUndoContext& i_context ); + + void ImplClearRedo_NoLock( bool const i_currentLevel ); + + /** clears all undo actions on the current level, plus all undo actions on superordinate levels, + as soon as those levels are reached. + + If no list action is active currently, i.e. we're on the top level already, this method is equivalent to + ->Clear. + + Otherwise, the Undo actions on the current level are removed. Upon leaving the current list action, all + undo actions on the then-current level are removed, too. This is continued until the top level is reached. + */ + void ClearAllLevels(); + virtual void EmptyActionsChanged(); + +private: + size_t ImplLeaveListAction( const bool i_merge, ::svl::undo::impl::UndoManagerGuard& i_guard ); + bool ImplAddUndoAction_NoNotify( std::unique_ptr<SfxUndoAction> pAction, bool bTryMerge, bool bClearRedo, ::svl::undo::impl::UndoManagerGuard& i_guard ); + void ImplClearRedo( ::svl::undo::impl::UndoManagerGuard& i_guard, bool const i_currentLevel ); + void ImplClearUndo( ::svl::undo::impl::UndoManagerGuard& i_guard ); + void ImplClearCurrentLevel_NoNotify( ::svl::undo::impl::UndoManagerGuard& i_guard ); + size_t ImplGetRedoActionCount_Lock( bool const i_currentLevel = CurrentLevel ) const; + bool ImplIsUndoEnabled_Lock() const; + bool ImplIsInListAction_Lock() const; + void ImplEnableUndo_Lock( bool const i_enable ); + + bool ImplUndo( SfxUndoContext* i_contextOrNull ); + bool ImplRedo( SfxUndoContext* i_contextOrNull ); + void ImplCheckEmptyActions(); + inline bool ImplIsEmptyActions() const; + + friend class ::svl::undo::impl::LockGuard; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/urihelper.hxx b/include/svl/urihelper.hxx new file mode 100644 index 000000000..9f8588c97 --- /dev/null +++ b/include/svl/urihelper.hxx @@ -0,0 +1,173 @@ +/* -*- 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_SVL_URIHELPER_HXX +#define INCLUDED_SVL_URIHELPER_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <rtl/textenc.h> +#include <svl/svldllapi.h> +#include <tools/link.hxx> +#include <tools/urlobj.hxx> + +namespace com::sun::star { + namespace uno { class XComponentContext; } + namespace uri { class XUriReference; } +} + +class CharClass; + +namespace URIHelper { + +/** + @ATT + Calling this function with defaulted arguments rMaybeFileHdl = Link() and + bCheckFileExists = true often leads to results that are not intended: + Whenever the given rTheBaseURIRef is a file URL, the given rTheRelURIRef is + relative, and rTheRelURIRef could also be smart-parsed as a non-file URL + (e.g., the relative URL "foo/bar" can be smart-parsed as "http://foo/bar"), + then SmartRel2Abs called with rMaybeFileHdl = Link() and bCheckFileExists = + true returns the non-file URL interpretation. To avoid this, either pass + some non-null rMaybeFileHdl if you want to check generated file URLs for + existence (see URIHelper::GetMaybeFileHdl), or use bCheckFileExists = false + if you want to generate file URLs without checking for their existence. +*/ +SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const & rTheBaseURIRef, + OUString const & rTheRelURIRef, + Link<OUString *, bool> const & rMaybeFileHdl = Link<OUString *, bool>(), + bool bCheckFileExists = true, + bool bIgnoreFragment = false, + INetURLObject::EncodeMechanism eEncodeMechanism = INetURLObject::EncodeMechanism::WasEncoded, + INetURLObject::DecodeMechanism eDecodeMechanism = INetURLObject::DecodeMechanism::ToIUri, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, + FSysStyle eStyle = FSysStyle::Detect); + +SVL_DLLPUBLIC void SetMaybeFileHdl(Link<OUString *, bool> const & rTheMaybeFileHdl); + +SVL_DLLPUBLIC Link<OUString *, bool> const & GetMaybeFileHdl(); + +/** + Converts a URI reference to a relative one, ignoring certain differences (for + example, treating file URLs for case-ignoring file systems + case-insensitively). + + @param context a component context; must not be null + + @param baseUriReference a base URI reference + + @param uriReference a URI reference + + @return a URI reference representing the given uriReference relative to the + given baseUriReference; if the given baseUriReference is not an absolute, + hierarchical URI reference, or the given uriReference is not a valid URI + reference, null is returned + + @exception std::bad_alloc if an out-of-memory condition occurs + + @exception css::uno::RuntimeException if any error occurs + */ +SVL_DLLPUBLIC css::uno::Reference< css::uri::XUriReference > +normalizedMakeRelative( + css::uno::Reference< css::uno::XComponentContext > const & context, + OUString const & baseUriReference, + OUString const & uriReference); + +/** + A variant of normalizedMakeRelative with a simplified interface. + + Internally calls normalizedMakeRelative with the default component context. + + @param baseUriReference a base URI reference, passed to + normalizedMakeRelative + + @param uriReference a URI reference, passed to normalizedMakeRelative + + @return if the XUriReference returned by normalizedMakeRelative is empty, + uriReference is returned unmodified; otherwise, the result of calling + XUriReference::getUriReference on the XUriReference returned by + normalizedMakeRelative is returned + + @exception std::bad_alloc if an out-of-memory condition occurs + + @exception css::uno::RuntimeException if any error occurs + + @deprecated + No code should rely on the default component context. +*/ +SVL_DLLPUBLIC OUString simpleNormalizedMakeRelative( OUString const & baseUriReference, + OUString const & uriReference); + +SVL_DLLPUBLIC OUString FindFirstURLInText(OUString const & rText, + sal_Int32 & rBegin, + sal_Int32 & rEnd, + CharClass const & rCharClass, + INetURLObject::EncodeMechanism eMechanism = INetURLObject::EncodeMechanism::WasEncoded, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + +/** Remove any password component from both absolute and relative URLs. + + @ATT The current implementation will not remove a password from a + relative URL that has an authority component (e.g., the password is not + removed from the relative ftp URL <//user:password@domain/path>). But + since our functions to translate between absolute and relative URLs never + produce relative URLs with authority components, this is no real problem. + + @ATT For relative URLs (or anything not recognized as an absolute URI), + the current implementation will return the input unmodified, not applying + any translations implied by the encode/decode parameters. + + @param rURI An absolute or relative URI reference. + + @param eEncodeMechanism See the general discussion for INetURLObject set- + methods. + + @param eDecodeMechanism See the general discussion for INetURLObject get- + methods. + + @param eCharset See the general discussion for INetURLObject get- and + set-methods. + + @return The input URI with any password component removed. + */ +SVL_DLLPUBLIC OUString removePassword(OUString const & rURI, + INetURLObject::EncodeMechanism eEncodeMechanism, + INetURLObject::DecodeMechanism eDecodeMechanism = INetURLObject::DecodeMechanism::ToIUri, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + +/** Resolve a URL's host component domain name in IDNA syntax to plain DNS + syntax. + + For details, see RFC 5890 "Internationalized Domain Names for Applications + (IDNA): Definitions and Document Framework." + + @param: url An arbitrary string, should be a URI. + + @return If the input matches the syntax of a hierarchical URL, and it has + a host component that matches the IDNA2008 domain name syntax, and that + domain name contains any U-labels, return a version of the input URL with + the host component resolved to plain DNS syntax. Otherwise, return the + input unchanged. +*/ +SVL_DLLPUBLIC OUString resolveIdnaHost(OUString const & url); + +} + +#endif // INCLUDED_SVL_URIHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/urlbmk.hxx b/include/svl/urlbmk.hxx new file mode 100644 index 000000000..a0b97a2b0 --- /dev/null +++ b/include/svl/urlbmk.hxx @@ -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/. + * + * 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_SVL_URLBMK_HXX +#define INCLUDED_SVL_URLBMK_HXX + +#include <rtl/ustring.hxx> + + +/** + * This class represents a bookmark that consists of a URL and + * a corresponding description text. + * + * There is an own clipboard format and helper methods to copy + * to and from clipboard and DragServer. + */ +class INetBookmark +{ + OUString aUrl; + OUString aDescr; + +public: + INetBookmark( const OUString &rUrl, const OUString &rDescr ) + : aUrl( rUrl ), aDescr( rDescr ) + {} + INetBookmark() + {} + + const OUString& GetURL() const { return aUrl; } + const OUString& GetDescription() const { return aDescr; } +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/visitem.hxx b/include/svl/visitem.hxx new file mode 100644 index 000000000..4ae5cdd55 --- /dev/null +++ b/include/svl/visitem.hxx @@ -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 . + */ + +#ifndef INCLUDED_SVL_VISITEM_HXX +#define INCLUDED_SVL_VISITEM_HXX + +#include <svl/svldllapi.h> +#include <svl/poolitem.hxx> +#include <com/sun/star/frame/status/Visibility.hpp> + +class SVL_DLLPUBLIC SfxVisibilityItem final : public SfxPoolItem +{ + css::frame::status::Visibility m_nValue; + +public: + + explicit SfxVisibilityItem(sal_uInt16 which, bool bVisible): + SfxPoolItem(which) + { + m_nValue.bVisible = bVisible; + } + + virtual bool operator ==(const SfxPoolItem & rItem) const override; + + virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, + OUString & rText, + const IntlWrapper&) + const override; + + virtual bool QueryValue( css::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const override; + + virtual bool PutValue( const css::uno::Any& rVal, + sal_uInt8 nMemberId ) override; + + virtual SfxVisibilityItem* Clone(SfxItemPool * = nullptr) const override; + + bool GetValue() const { return m_nValue.bVisible; } +}; + +#endif // INCLUDED_SVL_VISITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/whiter.hxx b/include/svl/whiter.hxx new file mode 100644 index 000000000..db4f3ccda --- /dev/null +++ b/include/svl/whiter.hxx @@ -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/. + * + * 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_SVL_WHITER_HXX +#define INCLUDED_SVL_WHITER_HXX + +#include <svl/svldllapi.h> + +class SfxItemSet; + +class SVL_DLLPUBLIC SfxWhichIter +{ + const sal_uInt16* const pStart; + const sal_uInt16* pRanges; + sal_uInt16 nOffset; + +public: + SfxWhichIter( const SfxItemSet& rSet ); + + sal_uInt16 GetCurWhich() const { return pRanges[0] + nOffset; } + sal_uInt16 NextWhich(); + sal_uInt16 FirstWhich(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx new file mode 100644 index 000000000..2cc857b5e --- /dev/null +++ b/include/svl/zforlist.hxx @@ -0,0 +1,1098 @@ +/* -*- 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_SVL_ZFORLIST_HXX +#define INCLUDED_SVL_ZFORLIST_HXX + +#include <config_options.h> +#include <svl/svldllapi.h> +#include <rtl/ustrbuf.hxx> +#include <rtl/ustring.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <i18nlangtag/lang.h> +#include <com/sun/star/util/NumberFormat.hpp> +#include <unotools/localedatawrapper.hxx> +#include <tools/link.hxx> +#include <svl/ondemand.hxx> +#include <svl/nfkeytab.hxx> + +#include <map> +#include <memory> +#include <set> + +namespace com::sun::star::i18n { class XNumberFormatCode; } +namespace com::sun::star::i18n { struct Currency; } +namespace com::sun::star::i18n { struct NumberFormatCode; } + +class Date; +class Color; +class CharClass; +class CalendarWrapper; + +class ImpSvNumberformatScan; +class ImpSvNumberInputScan; +class SvNumberformat; +namespace com::sun::star::uno { class XComponentContext; } + +#define SV_COUNTRY_LANGUAGE_OFFSET 10000 // Max count of formats per country/language +#define SV_MAX_COUNT_STANDARD_FORMATS 100 // Max count of builtin default formats per CL + +constexpr size_t NF_MAX_FORMAT_SYMBOLS = 100; + +/// The built-in @ Text format, offset within a locale, key in the locale the +/// number formatter was constructed with. +constexpr sal_uInt32 NF_STANDARD_FORMAT_TEXT = SV_MAX_COUNT_STANDARD_FORMATS; + +constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND = 0xffffffff; /// MAX_ULONG + +enum class SvNumFormatType : sal_Int16 +{ + /** selects all number formats. + */ + ALL = css::util::NumberFormat::ALL, // 0 + /** selects only user-defined number formats. + */ + DEFINED = css::util::NumberFormat::DEFINED, // 1 + /** selects date formats. + */ + DATE = css::util::NumberFormat::DATE, // 2 + /** selects time formats. + */ + TIME = css::util::NumberFormat::TIME, // 4 + /** selects currency formats. + */ + CURRENCY = css::util::NumberFormat::CURRENCY, // 8 + /** selects decimal number formats. + */ + NUMBER = css::util::NumberFormat::NUMBER, // 16 + /** selects scientific number formats. + */ + SCIENTIFIC = css::util::NumberFormat::SCIENTIFIC, // 32 + /** selects number formats for fractions. + */ + FRACTION = css::util::NumberFormat::FRACTION, // 64 + /** selects percentage number formats. + */ + PERCENT = css::util::NumberFormat::PERCENT, // 128 + /** selects text number formats. + */ + TEXT = css::util::NumberFormat::TEXT, // 256 + /** selects number formats which contain date and time. + */ + DATETIME = DATE | TIME, // 6 + /** selects boolean number formats. + */ + LOGICAL = css::util::NumberFormat::LOGICAL, // 1024 + /** is used as a return value if no format exists. + */ + UNDEFINED = css::util::NumberFormat::UNDEFINED, // 2048 + /** @internal is used to flag an empty sub format. + @since LibreOffice 5.1 + */ + EMPTY = css::util::NumberFormat::EMPTY, // 4096 + /** @internal selects a time duration format. + 8192 + TIME (4) + @since LibreOffice 6.2 + */ + DURATION = css::util::NumberFormat::DURATION, // 8196 +}; +namespace o3tl { + template<> struct typed_flags<SvNumFormatType> : is_typed_flags<SvNumFormatType, 0x3dff> {}; +} + +/** enum values for <method>SvNumberFormatter::GetFormatIndex</method> + + <p> + Builtin standard formats, order should be also the arrangement in the + dialog list box representation.</p> + + <p> + Date specials:<ul> + <li>SYSTEM: As set in System Regional Settings. + <li>SYS: short/long defined, order and separators from System Regional Settings. + <li>DEF: short/long and order defined, separators from System Regional Settings. + <li>DIN: all settings hard coded as DIN (Deutsche Industrie Norm) and EN (European Norm) require. + <li>all other: hard coded + </ul> + + Do NOT insert any new values! + The values here correspond with those in offapi/com/sun/star/i18n/NumberFormatIndex.idl + You may append values though after NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS. + */ +enum NfIndexTableOffset +{ + NF_NUMERIC_START = 0, + + NF_NUMBER_START = NF_NUMERIC_START, + NF_NUMBER_STANDARD = NF_NUMBER_START, // Standard/General + NF_NUMBER_INT, // 0 + NF_NUMBER_DEC2, // 0.00 + NF_NUMBER_1000INT, // #,##0 + NF_NUMBER_1000DEC2, // #,##0.00 + NF_NUMBER_SYSTEM, // #,##0.00 or whatever is set in System Regional Settings + NF_NUMBER_END = NF_NUMBER_SYSTEM, + + NF_SCIENTIFIC_START, + NF_SCIENTIFIC_000E000 = NF_SCIENTIFIC_START, // 0.00E+000 + NF_SCIENTIFIC_000E00, // 0.00E+00 + NF_SCIENTIFIC_END = NF_SCIENTIFIC_000E00, + + NF_PERCENT_START, + NF_PERCENT_INT = NF_PERCENT_START, // 0% + NF_PERCENT_DEC2, // 0.00% + NF_PERCENT_END = NF_PERCENT_DEC2, + + NF_FRACTION_START, + NF_FRACTION_1D = NF_FRACTION_START, // # ?/? + NF_FRACTION_2D, // # ??/?? + NF_FRACTION_END = NF_FRACTION_2D, + + NF_NUMERIC_END = NF_FRACTION_END, + + NF_CURRENCY_START, + NF_CURRENCY_1000INT = NF_CURRENCY_START,// #,##0 DM + NF_CURRENCY_1000DEC2, // #,##0.00 DM + NF_CURRENCY_1000INT_RED, // #,##0 DM negative in red + NF_CURRENCY_1000DEC2_RED, // #,##0.00 DM negative in red + NF_CURRENCY_1000DEC2_CCC, // #,##0.00 DEM currency abbreviation + NF_CURRENCY_1000DEC2_DASHED, // #,##0.-- DM + NF_CURRENCY_END = NF_CURRENCY_1000DEC2_DASHED, + + NF_DATE_START, + NF_DATE_SYSTEM_SHORT = NF_DATE_START, // 08.10.97 + NF_DATE_SYSTEM_LONG, // Wednesday, 8. October 1997 + NF_DATE_SYS_DDMMYY, // 08.10.97 + NF_DATE_SYS_DDMMYYYY, // 08.10.1997 THE edit format, formatindex="21" + NF_DATE_SYS_DMMMYY, // 8. Oct 97 + NF_DATE_SYS_DMMMYYYY, // 8. Oct 1997 + NF_DATE_DIN_DMMMYYYY, // 8. Oct. 1997 DIN + NF_DATE_SYS_DMMMMYYYY, // 8. October 1997 + NF_DATE_DIN_DMMMMYYYY, // 8. October 1997 DIN + NF_DATE_SYS_NNDMMMYY, // Wed, 8. Okt 97 + NF_DATE_DEF_NNDDMMMYY, // Wed 08.Okt 97 + NF_DATE_SYS_NNDMMMMYYYY, // Wed, 8. Oktober 1997 + NF_DATE_SYS_NNNNDMMMMYYYY, // Wednesday, 8. Oktober 1997 + NF_DATE_DIN_MMDD, // 10-08 DIN + NF_DATE_DIN_YYMMDD, // 97-10-08 DIN + NF_DATE_DIN_YYYYMMDD, // 1997-10-08 DIN + NF_DATE_ISO_YYYYMMDD = NF_DATE_DIN_YYYYMMDD, // 1997-10-08 ISO clarify with name, formatindex="33" + NF_DATE_SYS_MMYY, // 10.97 + NF_DATE_SYS_DDMMM, // 08.Oct + NF_DATE_MMMM, // October + NF_DATE_QQJJ, // 4. Quarter 97 + NF_DATE_WW, // week of year + NF_DATE_END = NF_DATE_WW, + + NF_TIME_START, + NF_TIME_HHMM = NF_TIME_START, // HH:MM + NF_TIME_HHMMSS, // HH:MM:SS + NF_TIME_HHMMAMPM, // HH:MM AM/PM + NF_TIME_HHMMSSAMPM, // HH:MM:SS AM/PM + NF_TIME_HH_MMSS, // [HH]:MM:SS formatindex="43" + NF_TIME_MMSS00, // MM:SS,00 formatindex="44" + NF_TIME_HH_MMSS00, // [HH]:MM:SS,00 formatindex="45" + NF_TIME_END = NF_TIME_HH_MMSS00, + + NF_DATETIME_START, + NF_DATETIME_SYSTEM_SHORT_HHMM = NF_DATETIME_START, // 08.10.97 01:23 + NF_DATETIME_SYS_DDMMYYYY_HHMMSS, // 08.10.1997 01:23:45 THE edit format, formatindex="47" + NF_DATETIME_END = NF_DATETIME_SYS_DDMMYYYY_HHMMSS, + + NF_BOOLEAN, // BOOLEAN + NF_TEXT, // @ + + NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS, // == 50, old number of predefined entries, i18npool locale data additions start after this + + // From here on are values of new predefined and built-in formats that are + // not in the original NumberFormatIndex.idl + + // XXX Values appended here must also get a corresponding entry in + // svl/source/numbers/zforlist.cxx indexTable[] in the same order. + + // XXX The dialog's number format shell assumes start/end spans + // (NF_..._START and NF_..._END above) to fill its categories with builtin + // formats, make new formats known to svx/source/items/numfmtsh.cxx + // SvxNumberFormatShell::FillEListWithStd_Impl(), otherwise they will not + // be listed at all. Yes that is ugly. + // DATETIME formats need to be added to + // SvxNumberFormatShell::FillEListWithDateTime_Impl(). + + // New predefined format added to i18npool locale data. + NF_DATETIME_SYS_DDMMYYYY_HHMM = NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS, // 08.10.1997 01:23 formatindex="50" + + // No i18npool defined locale data between here and NF_INDEX_TABLE_ENTRIES. + NF_INDEX_TABLE_RESERVED_START, + + NF_FRACTION_3D = NF_INDEX_TABLE_RESERVED_START, // # ???/??? + NF_FRACTION_2, // # ?/2 + NF_FRACTION_4, // # ?/4 + NF_FRACTION_8, // # ?/8 + NF_FRACTION_16, // # ??/16 + NF_FRACTION_10, // # ??/10 + NF_FRACTION_100, // # ??/100 + + NF_DATETIME_ISO_YYYYMMDD_HHMMSS, // 1997-10-08 01:23:45 ISO (with blank instead of T) + NF_DATETIME_ISO_YYYYMMDDTHHMMSS, // 1997-10-08T01:23:45 ISO + + // XXX When adding values here, follow the comment above about + // svx/source/items/numfmtsh.cxx + + NF_INDEX_TABLE_ENTRIES // == 60, reserved to not be used in i18npool locale data. + + // XXX Adding values above may increment the reserved area that can't be + // used by i18npool's locale data FormatCode definitions, see the + // description at i18npool/source/localedata/data/locale.dtd for ELEMENT + // FormatCode what the current convention's value is. In that case, the + // used formatIndex values in i18npool/source/localedata/data/*.xml will + // have to be adjusted. + // Overlapping the area will bail out with a check in + // SvNumberFormatter::ImpInsertFormat() in debug builds. +}; + + +// #45717# IsNumberFormat( "98-10-24", 30, x ), YMD Format set with DMY +// International settings doesn't recognize the string as a date. +/** enum values for <method>SvNumberFormatter::SetEvalDateFormat</method> + + <p>How <method>ImpSvNumberInputScan::GetDateRef</method> shall take the + DateFormat order (YMD,DMY,MDY) into account, if called from IsNumberFormat + with a date format to match against. + */ +enum NfEvalDateFormat +{ + /** DateFormat only from International, default. */ + NF_EVALDATEFORMAT_INTL, + + /** DateFormat only from date format passed to function (if any). + If no date format is passed then the DateFormat is taken from International. */ + NF_EVALDATEFORMAT_FORMAT, + + /** First try the DateFormat from International. If it doesn't match a + valid date try the DateFormat from the date format passed. */ + NF_EVALDATEFORMAT_INTL_FORMAT, + + /** First try the DateFormat from the date format passed. If it doesn't + match a valid date try the DateFormat from International. */ + NF_EVALDATEFORMAT_FORMAT_INTL +}; + + +typedef std::map<sal_uInt32, SvNumberformat*> SvNumberFormatTable; +typedef std::map<sal_uInt16, sal_uInt32> SvNumberFormatterIndexTable; + +typedef ::std::map< sal_uInt32, sal_uInt32> SvNumberFormatterMergeMap; + +typedef ::std::set< LanguageType > NfInstalledLocales; + + +/** Language/country dependent currency entries + */ +class UNLESS_MERGELIBS(SVL_DLLPUBLIC) NfCurrencyEntry +{ + OUString aSymbol; /// currency symbol + OUString aBankSymbol; /// currency abbreviation + LanguageType eLanguage; /// language/country value + sal_uInt16 nPositiveFormat; /// position of symbol + sal_uInt16 nNegativeFormat; /// position of symbol and type and position of negative sign + sal_uInt16 nDigits; /// count of decimal digits + sal_Unicode cZeroChar; /// which character is used for zeros as last decimal digits + + NfCurrencyEntry( const NfCurrencyEntry& ) = delete; + NfCurrencyEntry& operator=( const NfCurrencyEntry& ) = delete; + +private: + + // nDecimalFormat := 0, 1, 2 + // #,##0 or #,##0.00 or #,##0.-- is returned + SVL_DLLPRIVATE OUString Impl_BuildFormatStringNumChars( const LocaleDataWrapper&, sal_uInt16 nDecimalFormat) const; + +public: + + NfCurrencyEntry( const LocaleDataWrapper& rLocaleData, + LanguageType eLang ); + NfCurrencyEntry( const css::i18n::Currency & rCurr, + const LocaleDataWrapper& rLocaleData, + LanguageType eLang ); + + /// Symbols and language identical + bool operator==( const NfCurrencyEntry& r ) const; + + const OUString& GetSymbol() const { return aSymbol; } + const OUString& GetBankSymbol() const { return aBankSymbol; } + LanguageType GetLanguage() const { return eLanguage; } + sal_uInt16 GetPositiveFormat() const { return nPositiveFormat; } + sal_uInt16 GetNegativeFormat() const { return nNegativeFormat; } + sal_uInt16 GetDigits() const { return nDigits; } + + /** [$DM-407] (bBank==false) or [$DEM] (bBank==true) + is returned. If bBank==false and + bWithoutExtension==true only [$DM] */ + OUString BuildSymbolString(bool bBank, bool bWithoutExtension = false) const; + + /** #,##0.00 [$DM-407] is returned, separators + from rLoc, incl. minus sign but without [RED] */ + OUString BuildPositiveFormatString(bool bBank, const LocaleDataWrapper&, + sal_uInt16 nDecimalFormat = 1) const; + OUString BuildNegativeFormatString(bool bBank, const LocaleDataWrapper&, + sal_uInt16 nDecimalFormat = 1) const; + + /** [$DM-407] (or [$DEM] if bBank==true) + is appended/prepended to rStr, incl. minus sign */ + void CompletePositiveFormatString(OUStringBuffer& rStr, bool bBank, + sal_uInt16 nPosiFormat) const; + void CompleteNegativeFormatString(OUStringBuffer& rStr, bool bBank, + sal_uInt16 nNegaFormat) const; + + /// rSymStr is appended/prepended to rStr, incl. minus sign + static void CompletePositiveFormatString(OUStringBuffer& rStr, + const OUString& rSymStr, sal_uInt16 nPosiFormat); + static void CompleteNegativeFormatString(OUStringBuffer& rStr, + const OUString& rSymStr, sal_uInt16 nNegaFormat); + + /** Representation of a currency (symbol position and + negative sign) in other language settings */ + static sal_uInt16 GetEffectivePositiveFormat( sal_uInt16 nIntlFormat, + sal_uInt16 nCurrFormat, bool bBank ); + static sal_uInt16 GetEffectiveNegativeFormat( sal_uInt16 nIntlFormat, + sal_uInt16 nCurrFormat, bool bBank ); + + /// General Unicode Euro symbol + static sal_Unicode GetEuroSymbol() { return u'\x20AC'; } +}; + +typedef std::vector< OUString > NfWSStringsDtor; + +/** Input options to be used with IsNumberFormat() */ +enum class SvNumInputOptions : sal_uInt16 +{ + NONE = 0, + LAX_TIME = 1 ///< allow input of minutes or seconds >59 +}; +namespace o3tl { + template<> struct typed_flags<SvNumInputOptions> : is_typed_flags<SvNumInputOptions, 0x0001> {}; +} + +class SvNumberFormatterRegistry_Impl; +class NfCurrencyTable; + +class SVL_DLLPUBLIC SvNumberFormatter +{ + friend class SvNumberFormatterRegistry_Impl; +public: + /** + * We can't technically have an "infinite" value, so we use an arbitrary + * upper precision threshold to represent the "unlimited" precision. + */ + static const sal_uInt16 UNLIMITED_PRECISION; + + /** + * Precision suitable for numbers displayed in input bar, for instance + * Calc's formula input bar. + */ + static const sal_uInt16 INPUTSTRING_PRECISION; + + /// Preferred ctor with service manager and language/country enum + SvNumberFormatter( + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + LanguageType eLang + ); + + ~SvNumberFormatter(); + + /// Set CallBack to ColorTable + void SetColorLink( const Link<sal_uInt16,Color*>& rColorTableCallBack ); + /// Do the CallBack to ColorTable + Color* GetUserDefColor(sal_uInt16 nIndex); + + /// Change language/country, also input and format scanner + void ChangeIntl( LanguageType eLnge ); + /// Change the reference null date + void ChangeNullDate(sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear); + /// Change standard precision + void ChangeStandardPrec(short nPrec); + /// Set zero value suppression + void SetNoZero(bool bNZ); + + /** The language with which the formatter was initialized (system setting), + NOT the current language after a ChangeIntl() */ + LanguageType GetLanguage() const; + + // Determine whether two format types are input compatible or not + static bool IsCompatible(SvNumFormatType eOldType, SvNumFormatType eNewType); + + /** Get table of formats of a specific type of a locale. A format FIndex is + tested whether it has the type and locale requested, if it doesn't + match FIndex returns the default format for the type/locale. If no + specific format is to be selected FIndex may be initialized to 0. */ + SvNumberFormatTable& GetEntryTable(SvNumFormatType eType, + sal_uInt32& FIndex, + LanguageType eLnge); + + /** Get table of formats of a specific type of a language/country. + FIndex returns the default format of that type. + If the language/country was never touched before new entries are generated */ + SvNumberFormatTable& ChangeCL(SvNumFormatType eType, + sal_uInt32& FIndex, + LanguageType eLnge); + + /** Get table of formats of the same type as FIndex; eType and rLnge are + set accordingly. An unknown format is set to Standard/General */ + SvNumberFormatTable& GetFirstEntryTable(SvNumFormatType& eType, + sal_uInt32& FIndex, + LanguageType& rLnge); + + /// Delete an entry including the format it is referring to + void DeleteEntry(sal_uInt32 nKey); + + /** Create new entry of a format code string for language/country. + @return + <TRUE/> if string new and ok and inserted. + <FALSE/> if string already exists or an unresolvable parse error + occurred, in which case nCheckPos is the error position within rString. + If the error occurs at position 0 or rString is empty nCheckPos + will be 1, so an error in the string is always indicated by + nCheckPos not being zero. + The content of the rString variable can be changed and corrected + by the method. + nType contains the type of the format. + nKey contains the index key of the format. + */ + bool PutEntry( OUString& rString, sal_Int32& nCheckPos, SvNumFormatType& nType, sal_uInt32& nKey, + LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /** Same as <method>PutEntry</method> but the format code string is + considered to be of language/country eLnge and is converted to + language/country eNewLnge */ + bool PutandConvertEntry( OUString& rString, sal_Int32& nCheckPos, + SvNumFormatType& nType, sal_uInt32& nKey, + LanguageType eLnge, LanguageType eNewLnge, + bool bConvertDateOrder ); + + /** Same as <method>PutandConvertEntry</method> but the format code string + is considered to be of the System language/country eLnge and is + converted to another System language/country eNewLnge. In this case + the automatic currency is converted too. */ + bool PutandConvertEntrySystem( OUString& rString, sal_Int32& nCheckPos, + SvNumFormatType& nType, sal_uInt32& nKey, + LanguageType eLnge, LanguageType eNewLnge ); + + /** Similar to <method>PutEntry</method> and + <method>PutandConvertEntry</method> or + <method>PutandConvertEntrySystem</method>, the format code string + passed is considered to be of language/country eLnge. If + eLnge==LANGUAGE_SYSTEM the format code has to match eSysLnge, and if + eSysLnge is not the current application locale the format code is + converted to the current locale. Additionally, if the format code + represents an old "automatic" currency format, it is converted to the + new default currency format of the eLnge locale. The rString format + code passed as an argument may get adapted in case eLnge was used (or + is LANGUAGE_SYSTEM and eSysLnge is identical); in case it wasn't the + method works on a copy instead, otherwise the resulting string would + not match eSysLnge anymore. + + <p> This method was introduced to handle the legacy currency formats of + the "autotbl.fmt" file used by Calc and Writer and convert them to + fixed currency codes of the actual currency. Note that in the case of + legacy currency formats no special attribution is converted, only the + default currency format of the locale is chosen, and that new fixed + currency codes are of course not converted to other currencies. The + method may also be used as a general method taking, converting and + inserting almost arbitrary format codes. To insert or use, for example, + the default currency format code matching the current locale, the + method could be called with<br/> + + <code> + GetIndexPuttingAndConverting( "0 $", LANGUAGE_SYSTEM, LANGUAGE_ENGLISH_US, ...); + </code> + + @return + The index key of the resulting number format. If the format code + was empty, could not be converted or has errors, the eLnge locale's + standard number format is chosen instead. The index key is + guaranteed to represent some valid number format. If + rNewInserted==false and rCheckPos>0 the format code has errors + and/or could not be converted. + */ + sal_uInt32 GetIndexPuttingAndConverting( OUString & rString, LanguageType eLnge, + LanguageType eSysLnge, SvNumFormatType & rType, + bool & rNewInserted, sal_Int32 & rCheckPos ); + + /** Create a format code string using format nIndex as a template and + applying other settings (passed from the dialog) */ + OUString GenerateFormat(sal_uInt32 nIndex, + LanguageType eLnge = LANGUAGE_DONTKNOW, + bool bThousand = false, bool IsRed = false, + sal_uInt16 nPrecision = 0, sal_uInt16 nLeadingCnt = 1); + + /** Analyze an input string + @return + <TRUE/> if input is a number or is matching a format F_Index + F_Index is set to a matching format if number, the value is + returned in fOutNumber + <FALSE/> if input is not a number + */ + bool IsNumberFormat( const OUString& sString, sal_uInt32& F_Index, double& fOutNumber, + SvNumInputOptions eInputOptions = SvNumInputOptions::NONE ); + + /// Format a number according to a format index, return string and color + void GetOutputString( const double& fOutNumber, sal_uInt32 nFIndex, + OUString& sOutString, Color** ppColor, bool bUseStarFormat = false ); + + /** Format a string according to a format index, return string and color. + Formats only if the format code is of type text or the 4th subcode + of a format code is specified, otherwise sOutString will be == "" */ + void GetOutputString( const OUString& sString, sal_uInt32 nFIndex, + OUString& sOutString, Color** ppColor, bool bUseStarFormat = false ); + + /** Format a number according to the standard default format matching + the given format index */ + void GetInputLineString( const double& fOutNumber, + sal_uInt32 nFIndex, OUString& rOutString ); + + /** Format a number according to a format code string to be scanned. + @return + <FALSE/> if format code contains an error + <TRUE/> else, in which case the string and color are returned. + */ + bool GetPreviewString(const OUString& sFormatString, + double fPreviewNumber, + OUString& sOutString, + Color** ppColor, + LanguageType eLnge, + bool bUseStarFormat = false ); + + /** Same as <method>GetPreviewString</method> but the format code string + may be either language/country eLnge or en_US english US */ + bool GetPreviewStringGuess( const OUString& sFormatString, double fPreviewNumber, + OUString& sOutString, Color** ppColor, + LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /** Format a string according to a format code string to be scanned. + @return + <FALSE/> if format code contains an error + <TRUE/> else, in which case the string and color are returned. + */ + bool GetPreviewString( const OUString& sFormatString, const OUString& sPreviewString, + OUString& sOutString, Color** ppColor, + LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /** Test whether the format code string is already present in container + @return + NUMBERFORMAT_ENTRY_NOT_FOUND if not found, else the format index. + */ + sal_uInt32 TestNewString( const OUString& sFormatString, + LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /// Whether format index nFIndex is of type text or not + bool IsTextFormat(sal_uInt32 nFIndex) const; + + /// Get additional info of a format index, e.g. for dialog box + void GetFormatSpecialInfo(sal_uInt32 nFormat, bool& bThousand, bool& IsRed, + sal_uInt16& nPrecision, sal_uInt16& nLeadingCnt); + + /// Count of decimals + sal_uInt16 GetFormatPrecision( sal_uInt32 nFormat ) const; + + /// Count of integer digits + sal_uInt16 GetFormatIntegerDigits( sal_uInt32 nFormat ) const; + + /** Get additional info of a format code string, e.g. for dialog box. + Uses a temporary parse, if possible use only if format code is not + present in container yet, otherwise ineffective. + @return + 0 if format code string parsed without errors, otherwise error + position (like nCheckPos on <method>PutEntry</method>) + */ + sal_uInt32 GetFormatSpecialInfo( const OUString&, bool& bThousand, bool& IsRed, + sal_uInt16& nPrecision, sal_uInt16& nLeadingCnt, + LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /// Get return string for Calc CELL() function, "G", "D1", ... + OUString GetCalcCellReturn( sal_uInt32 nFormat ) const; + + /// Check if format code string may be deleted by user + bool IsUserDefined( const OUString& sStr, LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /** Return the format index of the format code string for language/country, + or NUMBERFORMAT_ENTRY_NOT_FOUND */ + sal_uInt32 GetEntryKey( const OUString& sStr, LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /// Return the format for a format index + const SvNumberformat* GetEntry( sal_uInt32 nKey ) const; + + /// Obtain substituted GetFormatEntry(), i.e. system formats. + const SvNumberformat* GetSubstitutedEntry( sal_uInt32 nKey, sal_uInt32 & o_rNewKey ) const; + + /// Return the format index of the standard default number format for language/country + sal_uInt32 GetStandardIndex(LanguageType eLnge = LANGUAGE_DONTKNOW); + + /// Return the format index of the default format of a type for language/country + sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge = LANGUAGE_DONTKNOW); + + /** Return the format index of the default format of a type for language/country. + Maybe not the default format but a special builtin format, e.g. for + NF_TIME_HH_MMSS00, if that format is passed in nFIndex. */ + sal_uInt32 GetStandardFormat( sal_uInt32 nFIndex, SvNumFormatType eType, LanguageType eLnge ); + + /** Return the format index of the default format of a type for language/country. + Maybe not the default format but a special builtin format, e.g. for + NF_TIME_HH_MMSS00, or NF_TIME_HH_MMSS if fNumber >= 1.0 */ + sal_uInt32 GetStandardFormat( double fNumber, sal_uInt32 nFIndex, SvNumFormatType eType, + LanguageType eLnge ); + + /// Whether nFIndex is a special builtin format + bool IsSpecialStandardFormat( sal_uInt32 nFIndex, LanguageType eLnge ); + + /** Return a time format that best matches fNumber. */ + sal_uInt32 GetTimeFormat( double fNumber, LanguageType eLnge, bool bForceDuration ); + + /** Return a format and type that best matches the value of fNumber if + fNumber is assumed to be a date, time or datetime value, but unknown + which. Originally introduced for Chart databrowser editor, probably + should not be used otherwise. */ + sal_uInt32 GuessDateTimeFormat( SvNumFormatType& rType, double fNumber, LanguageType eLnge ); + + /** Return the corresponding edit format of a format. */ + sal_uInt32 GetEditFormat( double fNumber, sal_uInt32 nFIndex, SvNumFormatType eType, + LanguageType eLnge, SvNumberformat const * pFormat ); + + /// Return the reference date + const Date& GetNullDate() const; + /// Return the standard decimal precision + sal_uInt16 GetStandardPrec() const; + /// Return whether zero suppression is switched on + bool GetNoZero() const; + /** Get the type of a format (or css::util::NumberFormat::UNDEFINED if no entry), + but with css::util::NumberFormat::DEFINED masked out */ + SvNumFormatType GetType(sal_uInt32 nFIndex) const; + + /// As the name says + void ClearMergeTable(); + /// Merge in all new entries from rNewTable and return a table of resulting new format indices + SvNumberFormatterIndexTable* MergeFormatter(SvNumberFormatter& rNewTable); + + /// Whether a merge table is present or not + bool HasMergeFormatTable() const; + /// Return the new format index for an old format index, if a merge table exists + sal_uInt32 GetMergeFormatIndex( sal_uInt32 nOldFmt ) const; + + /** Convert the ugly old tools' Table type bloated with new'ed sal_uInt32 + entries merge table to ::std::map with old index key and new index key. + @ATTENTION! Also clears the old table using ClearMergeTable() */ + SvNumberFormatterMergeMap ConvertMergeTableToMap(); + + /** Return the format index of a builtin format for a specific language/country. + If nFormat is not a builtin format nFormat is returned. */ + sal_uInt32 GetFormatForLanguageIfBuiltIn( sal_uInt32 nFormat, + LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /** Return the format index for a builtin format of a specific language + @see NfIndexTableOffset + */ + sal_uInt32 GetFormatIndex( NfIndexTableOffset, LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /** Return enum index of a format index of a builtin format, + NF_INDEX_TABLE_ENTRIES if it's not a builtin format. + @see NfIndexTableOffset + */ + NfIndexTableOffset GetIndexTableOffset( sal_uInt32 nFormat ) const; + + /** Set evaluation type and order of input date strings + @see NfEvalDateFormat + */ + void SetEvalDateFormat( NfEvalDateFormat eEDF ); + NfEvalDateFormat GetEvalDateFormat() const; + + /** Set TwoDigitYearStart, how the input string scanner handles a two digit year. + Default from VCL: 1930, 30-99 19xx, 00-29 20xx + + <p> Historically (prior to src513e) it was a two digit number determining + until which number the string scanner recognizes a year to be 20xx, + default <= 29 is used by SFX/OfaMiscCfg. + The name Year2000 is kept although the actual functionality is now a + TwoDigitYearStart which might be in any century. + */ + void SetYear2000( sal_uInt16 nVal ); + sal_uInt16 GetYear2000() const; + static sal_uInt16 GetYear2000Default(); + + sal_uInt16 ExpandTwoDigitYear( sal_uInt16 nYear ) const; + static sal_uInt16 ExpandTwoDigitYear( sal_uInt16 nYear, sal_uInt16 nTwoDigitYearStart ); + + /// Return the decimal separator matching the locale of the given format + OUString GetFormatDecimalSep( sal_uInt32 nFormat ) const; + + /// Return the decimal separator matching the given locale / LanguageType. + OUString GetLangDecimalSep( LanguageType nLang ) const; + + static void resetTheCurrencyTable(); + + /// Return a NfCurrencyTable with pointers to <type>NfCurrencyEntry</type> entries + static const NfCurrencyTable& GetTheCurrencyTable(); + + /** Searches, according to the default locale currency, an entry of the + CurrencyTable which is <bold>not</bold> the first (LANGUAGE_SYSTEM) entry. + @return + <NULL/> if not found + else pointer to NfCurrencyEntry + */ + static const NfCurrencyEntry* MatchSystemCurrency(); + + /** Return a NfCurrencyEntry matching a language/country. + If language/country is LANGUAGE_SYSTEM a <method>MatchSystemCurrency</method> + call is tried to get an entry. If that fails or the corresponding + language/country is not present the entry for LANGUAGE_SYSTEM is returned. + */ + static const NfCurrencyEntry& GetCurrencyEntry( LanguageType ); + + /** Return a NfCurrencyEntry pointer matching a language/country + and currency abbreviation (AKA banking symbol). + This method is meant for the configuration of the default currency. + @return + <NULL/> if not found + else pointer to NfCurrencyEntry + */ + static const NfCurrencyEntry* GetCurrencyEntry( const OUString& rAbbrev, + LanguageType eLang ); + + /** Return a NfCurrencyEntry pointer matching the symbol + combination of a LegacyOnly currency. Note that this means only that + the currency matching both symbols was once used in the Office, but is + not offered in dialogs anymore. It doesn't even mean that the currency + symbol combination is valid, since the reason for removing it may have + been just that. #i61657# + @return + A matching entry, or else <NULL/>. + */ + static const NfCurrencyEntry* GetLegacyOnlyCurrencyEntry( const OUString& rSymbol, const OUString& rAbbrev ); + + /** Set the default system currency. The combination of abbreviation and + language must match an existent element of theCurrencyTable. If not, + the SYSTEM (current locale) entry becomes the default. + This method is meant for the configuration of the default currency. + */ + static void SetDefaultSystemCurrency( const OUString& rAbbrev, LanguageType eLang ); + + /** Get all standard formats for a specific currency, formats are + appended to the NfWSStringsDtor list. + @param bBank + <TRUE/>: generate only format strings with currency abbreviation + <FALSE/>: mixed format strings + @return + position of default format + */ + sal_uInt16 GetCurrencyFormatStrings( NfWSStringsDtor&, const NfCurrencyEntry&, + bool bBank ) const; + + /** Whether nFormat is of type css::util::NumberFormat::CURRENCY and the format code + contains a new SYMBOLTYPE_CURRENCY and if so which one [$xxx-nnn]. + If ppEntry is not NULL and exactly one entry is found, a [$xxx-nnn] is + returned, even if the format code only contains [$xxx] ! + */ + bool GetNewCurrencySymbolString( sal_uInt32 nFormat, OUString& rSymbol, + const NfCurrencyEntry** ppEntry, + bool* pBank = nullptr ) const; + + /** Look up the corresponding NfCurrencyEntry matching + rSymbol (may be CurrencySymbol or CurrencyAbbreviation) and possibly + a rExtension (being yyy of [$xxx-yyy]) or a given language/country + value. Tries to match a rSymbol with rExtension first, then with + eFormatLanguage, then rSymbol only. This is because a currency entry + might have been constructed using I18N locale data where a used locale + of a currency format code must not necessarily match the locale of + the locale data itself, e.g. [$HK$-40C] (being "zh_HK" locale) in + zh_CN locale data. Here the rExtension would have the value 0x40c but + eFormatLanguage of the number format would have the value of zh_CN + locale, the value with which the corresponding CurrencyEntry is + constructed. + + @param bFoundBank + Only used for output. + If the return value is not <NULL/> this value is set to <TRUE/> if + the matching entry was found by comparing rSymbol against the + CurrencyAbbreviation (AKA BankSymbol). + If the return value is <NULL/> the value of bFoundBank is undefined. + @param rSymbol + Currency symbol, preferably obtained of a format by a call to + <method>SvNumberformat::GetNewCurrencySymbol()</method> + @param rExtension + Currency extension, preferably obtained of a format by a call to + <method>SvNumberformat::GetNewCurrencySymbol()</method> + @param eFormatLanguage + The language/country value of the format of which rSymbol and + rExtension are obtained (<method>SvNumberformat::GetLanguage()</method>). + @param bOnlyStringLanguage + If <TRUE/> only entries with language/country of rExtension are + checked, no match on eFormatLanguage. If rExtension is empty all + entries are checked. + @return + The matching entry if unique (in which case bFoundBank is set), + else <NULL/>. + */ + static const NfCurrencyEntry* GetCurrencyEntry( bool & bFoundBank, + const OUString& rSymbol, + const OUString& rExtension, + LanguageType eFormatLanguage, + bool bOnlyStringLanguage = false ); + + /// Get compatibility ("automatic" old style) currency from I18N locale data + void GetCompatibilityCurrency( OUString& rSymbol, OUString& rAbbrev ) const; + + /// Fill rList with the language/country codes that have been allocated + void GetUsedLanguages( std::vector<LanguageType>& rList ); + + /// Fill a NfKeywordIndex table with keywords of a language/country + void FillKeywordTable( NfKeywordTable& rKeywords, LanguageType eLang ); + + /** Fill a NfKeywordIndex table with keywords usable in Excel export with + GetFormatStringForExcel() or SvNumberformat::GetMappedFormatstring() */ + void FillKeywordTableForExcel( NfKeywordTable& rKeywords ); + + /** Return a format code string suitable for Excel export. + + @param rTempFormatter + SvNumberFormatter to use if a non-en-US format code needs to be + converted and put, should not be the same formatter to not + pollute the entries of this one here. + */ + OUString GetFormatStringForExcel( sal_uInt32 nKey, const NfKeywordTable& rKeywords, + SvNumberFormatter& rTempFormatter ) const; + + /** Return a keyword for a language/country and NfKeywordIndex + for XML import, to generate number format strings. */ + OUString GetKeyword( LanguageType eLnge, sal_uInt16 nIndex ); + + /** Return the GENERAL keyword in proper case ("General") for a + language/country, used in XML import */ + OUString GetStandardName( LanguageType eLnge ); + + /** Check if a specific locale has supported locale data. */ + static bool IsLocaleInstalled( LanguageType eLang ); + + /** Obtain NfKeywordTable used with a format, possibly localized. + + XXX NOTE: the content (actual keywords) is only valid as long as the + locale context of the associated ImpSvNumberformatScan instance does + not change to a locale with different keywords, which may happen + anytime with a call (implicit or explicit) to + SvNumberFormatter::ChangeIntl(). If needed longer, copy-create another + NfKeywordTable instance or copy individual elements. + + If the format specified with nKey does not exist, the content of the + NfKeywordTable matches the locale with which the SvNumberFormatter + instance was created and initialized. + + This function preliminary exists for unit tests and otherwise is + pretty much useless. + */ + const NfKeywordTable & GetKeywords( sal_uInt32 nKey ); + + /** Access for unit tests. */ + const NfKeywordTable & GetEnglishKeywords() const; + + /** Access for unit tests. */ + const std::vector<Color> & GetStandardColors() const; + + /** Access for unit tests. */ + size_t GetMaxDefaultColors() const; + + struct InputScannerPrivateAccess { friend class ImpSvNumberInputScan; private: InputScannerPrivateAccess() {} }; + /** Access for input scanner to temporarily (!) switch locales. */ + OnDemandLocaleDataWrapper& GetOnDemandLocaleDataWrapper( const InputScannerPrivateAccess& ) { return xLocaleData; } + +private: + mutable ::osl::Mutex m_aMutex; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + LanguageTag maLanguageTag; + std::map<sal_uInt32, std::unique_ptr<SvNumberformat>> aFTable; // Table of format keys to format entries + typedef std::map<sal_uInt32, sal_uInt32> DefaultFormatKeysMap; + DefaultFormatKeysMap aDefaultFormatKeys; // Table of default standard to format keys + std::unique_ptr<SvNumberFormatTable> pFormatTable; // For the UI dialog + std::unique_ptr<SvNumberFormatterIndexTable> pMergeTable; // List of indices for merging two formatters + std::unique_ptr<CharClass> pCharClass; // CharacterClassification + OnDemandLocaleDataWrapper xLocaleData; // LocaleData switched between SYSTEM, ENGLISH and other + OnDemandTransliterationWrapper xTransliteration; // Transliteration loaded on demand + OnDemandCalendarWrapper xCalendar; // Calendar loaded on demand + OnDemandNativeNumberWrapper xNatNum; // Native number service loaded on demand + std::unique_ptr<ImpSvNumberInputScan> pStringScanner; // Input string scanner + std::unique_ptr<ImpSvNumberformatScan> pFormatScanner; // Format code string scanner + Link<sal_uInt16,Color*> aColorLink; // User defined color table CallBack + sal_uInt32 MaxCLOffset; // Max language/country offset used + sal_uInt32 nDefaultSystemCurrencyFormat; // NewCurrency matching SYSTEM locale + LanguageType IniLnge; // Initialized setting language/country + LanguageType ActLnge; // Current setting language/country + NfEvalDateFormat eEvalDateFormat; // DateFormat evaluation + bool bNoZero; // Zero value suppression + + // cached locale data items needed almost any time + OUString aDecimalSep; + OUString aDecimalSepAlt; + OUString aThousandSep; + OUString aDateSep; + + SVL_DLLPRIVATE static volatile bool bCurrencyTableInitialized; + SVL_DLLPRIVATE static sal_uInt16 nSystemCurrencyPosition; + SVL_DLLPRIVATE static SvNumberFormatterRegistry_Impl* pFormatterRegistry; + + // get the registry, create one if none exists + SVL_DLLPRIVATE static SvNumberFormatterRegistry_Impl& GetFormatterRegistry(); + + // called by ctors + SVL_DLLPRIVATE void ImpConstruct( LanguageType eLang ); + + // Generate builtin formats provided by i18n behind CLOffset, + // if bNoAdditionalFormats==false also generate additional i18n formats. + SVL_DLLPRIVATE void ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditionalFormats ); + + // Generate additional formats provided by i18n + SVL_DLLPRIVATE void ImpGenerateAdditionalFormats( sal_uInt32 CLOffset, + css::uno::Reference< css::i18n::XNumberFormatCode > const & rNumberFormatCode, + bool bAfterChangingSystemCL ); + + SVL_DLLPRIVATE SvNumberformat* ImpInsertFormat( const css::i18n::NumberFormatCode& rCode, + sal_uInt32 nPos, + bool bAfterChangingSystemCL = false, + sal_Int16 nOrgIndex = 0 ); + + // Return CLOffset or (MaxCLOffset + SV_COUNTRY_LANGUAGE_OFFSET) if new language/country + SVL_DLLPRIVATE sal_uInt32 ImpGetCLOffset(LanguageType eLnge) const; + + // Test whether format code already exists, then return index key, + // otherwise NUMBERFORMAT_ENTRY_NOT_FOUND + SVL_DLLPRIVATE sal_uInt32 ImpIsEntry( const OUString& rString, + sal_uInt32 CLOffset, + LanguageType eLnge ); + + // Create builtin formats for language/country if necessary, return CLOffset + SVL_DLLPRIVATE sal_uInt32 ImpGenerateCL( LanguageType eLnge ); + + // Create theCurrencyTable with all <type>NfCurrencyEntry</type> + SVL_DLLPRIVATE static void ImpInitCurrencyTable(); + + // Return the format index of the currency format of the system locale. + // Format is created if not already present. + SVL_DLLPRIVATE sal_uInt32 ImpGetDefaultSystemCurrencyFormat(); + + // Return the format index of the currency format of the current locale. + // Format is created if not already present. + SVL_DLLPRIVATE sal_uInt32 ImpGetDefaultCurrencyFormat(); + + // Return the default format for a given type and current locale. + // May ONLY be called from within GetStandardFormat(). + SVL_DLLPRIVATE sal_uInt32 ImpGetDefaultFormat( SvNumFormatType nType ); + + // Return the index in a sequence of format codes matching an enum of + // NfIndexTableOffset. If not found 0 is returned. If the sequence doesn't + // contain any format code elements a default element is created and inserted. + SVL_DLLPRIVATE sal_Int32 ImpGetFormatCodeIndex( css::uno::Sequence< css::i18n::NumberFormatCode >& rSeq, + const NfIndexTableOffset nTabOff ); + + // Adjust a sequence of format codes to contain only one (THE) default + // instead of multiple defaults for short/medium/long types. + // If there is no medium but a short and a long default the long is taken. + // Non-PRODUCT version may check locale data for matching defaults in one + // FormatElement group. + SVL_DLLPRIVATE void ImpAdjustFormatCodeDefault( css::i18n::NumberFormatCode * pFormatArr, + sal_Int32 nCount ); + + // Obtain the format entry for a given key index. + SVL_DLLPRIVATE SvNumberformat* GetFormatEntry( sal_uInt32 nKey ); + SVL_DLLPRIVATE const SvNumberformat* GetFormatEntry( sal_uInt32 nKey ) const; + + // used as a loop body inside of GetNewCurrencySymbolString() and GetCurrencyEntry() + static bool ImpLookupCurrencyEntryLoopBody( + const NfCurrencyEntry*& pFoundEntry, bool& bFoundBank, const NfCurrencyEntry* pData, + sal_uInt16 nPos, const OUString& rSymbol ); + + // link to be set at <method>SvtSysLocaleOptions::SetCurrencyChangeLink()</method> + DECL_DLLPRIVATE_STATIC_LINK( SvNumberFormatter, CurrencyChangeLink, LinkParamNone*, void ); + + // return position of a special character + sal_Int32 ImpPosToken ( const OUStringBuffer & sFormat, sal_Unicode token, sal_Int32 nStartPos = 0 ) const; + + // Substitute a format during GetFormatEntry(), i.e. system formats. + SvNumberformat* ImpSubstituteEntry( SvNumberformat* pFormat, sal_uInt32 * o_pRealKey = nullptr ); + + // own mutex, may also be used by internal class SvNumberFormatterRegistry_Impl + static ::osl::Mutex& GetGlobalMutex(); + ::osl::Mutex& GetInstanceMutex() const { return m_aMutex; } + +public: + + // called by SvNumberFormatterRegistry_Impl::Notify if the default system currency changes + void ResetDefaultSystemCurrency(); + + // Called by SvNumberFormatterRegistry_Impl::Notify if the system locale's + // date acceptance patterns change. + void InvalidateDateAcceptancePatterns(); + + // Replace the SYSTEM language/country format codes. Called upon change of + // the user configurable locale. + // Old compatibility codes are replaced, user defined are converted, and + // new format codes are appended. + void ReplaceSystemCL( LanguageType eOldLanguage ); + + const css::uno::Reference<css::uno::XComponentContext>& GetComponentContext() const; + + //! The following method is not to be used from outside but must be + //! public for the InputScanner. + // return the current FormatScanner + const ImpSvNumberformatScan* GetFormatScanner() const; + + //! The following methods are not to be used from outside but must be + //! public for the InputScanner and FormatScanner. + + // return current (!) Locale + const LanguageTag& GetLanguageTag() const; + + // return corresponding Transliteration wrapper + const ::utl::TransliterationWrapper* GetTransliteration() const; + + // return the corresponding CharacterClassification wrapper + const CharClass* GetCharClass() const; + + // return the corresponding LocaleData wrapper + const LocaleDataWrapper* GetLocaleData() const; + + // return the corresponding Calendar wrapper + CalendarWrapper* GetCalendar() const; + + // return the corresponding NativeNumberSupplier wrapper + const NativeNumberWrapper* GetNatNum() const; + + // cached locale data items + + // return the corresponding decimal separator + const OUString& GetNumDecimalSep() const; + + // return the corresponding decimal separator alternative + const OUString& GetNumDecimalSepAlt() const; + + // return the corresponding group (AKA thousand) separator + const OUString& GetNumThousandSep() const; + + // return the corresponding date separator + const OUString& GetDateSep() const; + + // checks for decimal separator and optional alternative + bool IsDecimalSep( const OUString& rStr ) const; +}; + +#endif // INCLUDED_SVL_ZFORLIST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx new file mode 100644 index 000000000..089a4b0e4 --- /dev/null +++ b/include/svl/zformat.hxx @@ -0,0 +1,749 @@ +/* -*- 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_SVL_ZFORMAT_HXX +#define INCLUDED_SVL_ZFORMAT_HXX + +#include <svl/svldllapi.h> +#include <svl/zforlist.hxx> +#include <svl/nfkeytab.hxx> +#include <vector> + +namespace utl { + class DigitGroupingIterator; +} + +namespace com::sun::star::i18n { struct NativeNumberXmlAttributes2; } + +class Color; + +class ImpSvNumberformatScan; // format code string scanner +class ImpSvNumberInputScan; // input string scanner + +enum SvNumberformatLimitOps +{ + NUMBERFORMAT_OP_NO = 0, // Undefined, no OP + NUMBERFORMAT_OP_EQ = 1, // Operator = + NUMBERFORMAT_OP_NE = 2, // Operator <> + NUMBERFORMAT_OP_LT = 3, // Operator < + NUMBERFORMAT_OP_LE = 4, // Operator <= + NUMBERFORMAT_OP_GT = 5, // Operator > + NUMBERFORMAT_OP_GE = 6 // Operator >= +}; + +struct ImpSvNumberformatInfo // Struct for FormatInfo +{ + std::vector<OUString> sStrArray; // Array of symbols + std::vector<short> nTypeArray; // Array of infos + sal_uInt16 nThousand; // Count of group separator sequences + sal_uInt16 nCntPre; // Count of digits before decimal point + sal_uInt16 nCntPost; // Count of digits after decimal point + sal_uInt16 nCntExp; // Count of exponent digits, or AM/PM + SvNumFormatType eScannedType; // Type determined by scan + bool bThousand; // Has group (AKA thousand) separator + + void Copy( const ImpSvNumberformatInfo& rNumFor, sal_uInt16 nCount ); +}; + +// NativeNumber, represent numbers using CJK or other digits if nNum>0, +// eLang specifies the Locale to use. +class SvNumberNatNum +{ + OUString sParams; // For [NatNum12 ordinal-number]-like syntax + LanguageType eLang; + sal_uInt8 nNum; + bool bDBNum :1; // DBNum, to be converted to NatNum + bool bDate :1; // Used in date? (needed for DBNum/NatNum mapping) + bool bSet :1; // If set, since NatNum0 is possible + +public: + + static sal_uInt8 MapDBNumToNatNum( sal_uInt8 nDBNum, LanguageType eLang, bool bDate ); + static sal_uInt8 MapNatNumToDBNum( sal_uInt8 nNatNum, LanguageType eLang, bool bDate ); + + SvNumberNatNum() : eLang( LANGUAGE_DONTKNOW ), nNum(0), + bDBNum(false), bDate(false), bSet(false) {} + bool IsComplete() const { return bSet && eLang != LANGUAGE_DONTKNOW; } + sal_uInt8 GetNatNum() const { return bDBNum ? MapDBNumToNatNum( nNum, eLang, bDate ) : nNum; } + sal_uInt8 GetDBNum() const { return bDBNum ? nNum : MapNatNumToDBNum( nNum, eLang, bDate ); } + LanguageType GetLang() const { return eLang; } + void SetLang( LanguageType e ) { eLang = e; } + void SetNum( sal_uInt8 nNumber, bool bDBNumber ) + { + nNum = nNumber; + bDBNum = bDBNumber; + bSet = true; + } + bool IsSet() const { return bSet; } + void SetDate( bool bDateP ) { bDate = bDateP; } + void SetParams(const OUString& s) { sParams = s; } + OUString const & GetParams() const { return sParams; } +}; + +class CharClass; + +class ImpSvNumFor // One of four subformats of the format code string +{ +public: + ImpSvNumFor(); // Ctor without filling the Info + ~ImpSvNumFor(); + + void Enlarge(sal_uInt16 nCount); // Init of arrays to the right size + + // if pSc is set, it is used to get the Color pointer + void Copy( const ImpSvNumFor& rNumFor, ImpSvNumberformatScan* pSc ); + + // Access to Info; call Enlarge before! + ImpSvNumberformatInfo& Info() { return aI;} + const ImpSvNumberformatInfo& Info() const { return aI; } + + // Get count of substrings (symbols) + sal_uInt16 GetCount() const { return nStringsCnt;} + + Color* GetColor() const { return pColor; } + void SetColor( Color* pCol, OUString const & rName ) + { pColor = pCol; sColorName = rName; } + const OUString& GetColorName() const { return sColorName; } + + // new SYMBOLTYPE_CURRENCY in subformat? + bool HasNewCurrency() const; + bool GetNewCurrencySymbol( OUString& rSymbol, OUString& rExtension ) const; + + // [NatNum1], [NatNum2], ... + void SetNatNumNum( sal_uInt8 nNum, bool bDBNum ) { aNatNum.SetNum( nNum, bDBNum ); } + void SetNatNumLang( LanguageType eLang ) { aNatNum.SetLang( eLang ); } + void SetNatNumDate( bool bDate ) { aNatNum.SetDate( bDate ); } + void SetNatNumParams(const OUString& sParams) { aNatNum.SetParams(sParams); } + const SvNumberNatNum& GetNatNum() const { return aNatNum; } + +private: + ImpSvNumberformatInfo aI; // helper struct for remaining information + OUString sColorName; // color name + Color* pColor; // pointer to color of subformat + sal_uInt16 nStringsCnt; // count of symbols + SvNumberNatNum aNatNum; // DoubleByteNumber + +}; + +class SVL_DLLPUBLIC SvNumberformat +{ + struct SAL_DLLPRIVATE LocaleType + { + enum class Substitute : sal_uInt8 + { + NONE, + TIME, + LONGDATE + }; + + LanguageType meLanguage; + LanguageType meLanguageWithoutLocaleData; + Substitute meSubstitute; + sal_uInt8 mnNumeralShape; + sal_uInt8 mnCalendarType; + + OUString generateCode() const; + + LocaleType(); + LocaleType(sal_uInt32 nRawCode); + + bool isPlainLocale() const; + }; + +public: + // Normal ctor + SvNumberformat( OUString& rString, + ImpSvNumberformatScan* pSc, + ImpSvNumberInputScan* pISc, + sal_Int32& nCheckPos, + LanguageType& eLan ); + + // Copy ctor + SvNumberformat( SvNumberformat const & rFormat ); + + // Copy ctor with exchange of format code string scanner (used in merge) + SvNumberformat( SvNumberformat const & rFormat, ImpSvNumberformatScan& rSc ); + + ~SvNumberformat(); + + /// Get type of format, may include css::util::NumberFormat::DEFINED bit + SvNumFormatType GetType() const { return eType; } + + /// Get type of format, does not include css::util::NumberFormat::DEFINED + SvNumFormatType GetMaskedType() const { return eType & ~SvNumFormatType::DEFINED; } + + void SetType(SvNumFormatType eSetType) { eType = eSetType; } + // Standard means the I18N defined standard format of this type + void SetStandard() { bStandard = true; } + bool IsStandard() const { return bStandard; } + + // If this format is an additional built-in format defined by i18n. + void SetAdditionalBuiltin() { bAdditionalBuiltin = true; } + bool IsAdditionalBuiltin() const { return bAdditionalBuiltin; } + + LanguageType GetLanguage() const { return maLocale.meLanguage;} + + /** If the format is a placeholder and needs to be substituted. */ + bool IsSubstituted() const + { + return maLocale.meSubstitute != LocaleType::Substitute::NONE; + } + + /** If the format is a placeholder for the system time format and needs to + be substituted during formatting time. + */ + bool IsSystemTimeFormat() const + { + return maLocale.meSubstitute == LocaleType::Substitute::TIME && maLocale.meLanguage == LANGUAGE_SYSTEM; + } + + /** If the format is a placeholder for the system long date format and needs + to be substituted during formatting time. + */ + bool IsSystemLongDateFormat() const + { + return maLocale.meSubstitute == LocaleType::Substitute::LONGDATE && maLocale.meLanguage == LANGUAGE_SYSTEM; + } + + /** If the format is a MM:SS or [MM]:SS format, or MM:[SS] (sic!) or even + MM:SS.00 or [MM]:SS.00 or MM:[SS].00 + */ + bool IsMinuteSecondFormat() const; + + const OUString& GetFormatstring() const { return sFormatstring; } + + // Build a format string of application defined keywords + OUString GetMappedFormatstring( const NfKeywordTable& rKeywords, + const LocaleDataWrapper& rLoc, + LanguageType nOriginalLang = LANGUAGE_DONTKNOW, + bool bSystemLanguage = false ) const; + + void SetStarFormatSupport( bool b ) { bStarFlag = b; } + + /** + * Get output string from a numeric value that fits the number of + * characters specified. + */ + bool GetOutputString( double fNumber, sal_uInt16 nCharCount, OUString& rOutString ) const; + + bool GetOutputString( double fNumber, OUString& OutString, Color** ppColor ); + void GetOutputString( const OUString& sString, OUString& OutString, Color** ppColor ); + + // True if type text + bool IsTextFormat() const { return bool(eType & SvNumFormatType::TEXT); } + // True if 4th subformat present + bool HasTextFormat() const + { + return (NumFor[3].GetCount() > 0) || + (NumFor[3].Info().eScannedType == SvNumFormatType::TEXT); + } + + void GetFormatSpecialInfo(bool& bThousand, + bool& IsRed, + sal_uInt16& nPrecision, + sal_uInt16& nLeadingCnt) const; + + /// Get index of subformat (0..3) according to conditions and fNumber value + sal_uInt16 GetSubformatIndex( double fNumber ) const; + + /// Count of decimal precision + sal_uInt16 GetFormatPrecision( sal_uInt16 nIx = 0 ) const + { return NumFor[nIx].Info().nCntPost; } + + /// Count of integer digits + sal_uInt16 GetFormatIntegerDigits( sal_uInt16 nIx = 0 ) const + { return NumFor[nIx].Info().nCntPre; } + + /** Count of hidden integer digits with thousands divisor: + * formats like "0," to show only thousands + */ + sal_uInt16 GetThousandDivisorPrecision( sal_uInt16 nIx = 0 ) const + { return NumFor[nIx].Info().nThousand * 3; } + + //! Read/write access on a special sal_uInt16 component, may only be used on the + //! standard format 0, 10000, ... and only by the number formatter! + struct FormatterPrivateAccess { friend SvNumberFormatter; private: FormatterPrivateAccess() {} }; + sal_uInt16 GetLastInsertKey( const FormatterPrivateAccess& ) const + { return NumFor[0].Info().nThousand; } + void SetLastInsertKey( sal_uInt16 nKey, const FormatterPrivateAccess& ) + { NumFor[0].Info().nThousand = nKey; } + + //! Only onLoad: convert from stored to current system language/country + void ConvertLanguage( SvNumberFormatter& rConverter, + LanguageType eConvertFrom, LanguageType eConvertTo ); + + // Substring of a subformat code nNumFor (0..3) + // nPos == 0xFFFF => last substring + // bString==true: first/last SYMBOLTYPE_STRING or SYMBOLTYPE_CURRENCY + const OUString* GetNumForString( sal_uInt16 nNumFor, sal_uInt16 nPos, + bool bString = false ) const; + + // Subtype of a subformat code nNumFor (0..3) + // nPos == 0xFFFF => last substring + short GetNumForType( sal_uInt16 nNumFor, sal_uInt16 nPos ) const; + + OUString GetPercentString( sal_uInt16 nNumFor = 0 ) const; + + OUString GetDenominatorString( sal_uInt16 nNumFor ) const; + OUString GetNumeratorString( sal_uInt16 nNumFor ) const; + OUString GetIntegerFractionDelimiterString( sal_uInt16 nNumFor ) const; + /// Round fNumber to its fraction representation + double GetRoundFractionValue ( double fNumber ) const; + + /// Create a format string for time with a new precision + OUString GetFormatStringForTimePrecision( int nPrecision ) const; + + + /** If the count of string elements (substrings, ignoring [modifiers] and + so on) in a subformat code nNumFor (0..3) is equal to the given number. + Used by ImpSvNumberInputScan::IsNumberFormatMain() to detect a matched + format. */ + bool IsNumForStringElementCountEqual( sal_uInt16 nNumFor, sal_uInt16 nAllCount, + sal_uInt16 nNumCount ) const + { + if ( nNumFor < 4 ) + { + // First try a simple approach. Note that this is called only + // if all MidStrings did match so far, to verify that all + // strings of the format were matched and not just the starting + // sequence, so we don't have to check if GetCount() includes + // [modifiers] or anything else if both counts are equal. + sal_uInt16 nCnt = NumFor[nNumFor].GetCount(); + if ( nAllCount == nCnt ) + return true; + if ( nAllCount < nCnt ) // check ignoring [modifiers] and so on + return ImpGetNumForStringElementCount( nNumFor ) == + (nAllCount - nNumCount); + } + return false; + } + /** Get the count of numbers among string elements **/ + sal_uInt16 GetNumForNumberElementCount( sal_uInt16 nNumFor ) const; + + /** Get the scanned type of the specified subformat. */ + SvNumFormatType GetNumForInfoScannedType( sal_uInt16 nNumFor ) const + { + return (nNumFor < 4) ? NumFor[nNumFor].Info().eScannedType : SvNumFormatType::UNDEFINED; + } + + // Whether the second subformat code is really for negative numbers + // or another limit set. + bool IsSecondSubformatRealNegative() const + { + return fLimit1 == 0.0 && fLimit2 == 0.0 && + ( (eOp1 == NUMBERFORMAT_OP_GE && eOp2 == NUMBERFORMAT_OP_NO) || + (eOp1 == NUMBERFORMAT_OP_GT && eOp2 == NUMBERFORMAT_OP_LT) || + (eOp1 == NUMBERFORMAT_OP_NO && eOp2 == NUMBERFORMAT_OP_NO) ); + } + + // Whether the first subformat code is really for negative numbers + // or another limit set. + bool IsFirstSubformatRealNegative() const + { + return fLimit1 == 0.0 && fLimit2 == 0.0 && + ((eOp1 == NUMBERFORMAT_OP_LT && + (eOp2 == NUMBERFORMAT_OP_GT || eOp2 == NUMBERFORMAT_OP_EQ || + eOp2 == NUMBERFORMAT_OP_GE || eOp2 == NUMBERFORMAT_OP_NO)) || + (eOp1 == NUMBERFORMAT_OP_LE && + (eOp2 == NUMBERFORMAT_OP_NO || eOp2 == NUMBERFORMAT_OP_GT))); + } + + // Whether the negative format is without a sign or not + bool IsNegativeWithoutSign() const; + + bool IsNegativeInBracket() const; + + bool HasPositiveBracketPlaceholder() const; + + // Whether a new SYMBOLTYPE_CURRENCY is contained in the format + bool HasNewCurrency() const; + + // strip [$-yyy] from all [$xxx-yyy] leaving only xxx's, + static OUString StripNewCurrencyDelimiters( const OUString& rStr ); + + // If a new SYMBOLTYPE_CURRENCY is contained if the format is of type + // css::util::NumberFormat::CURRENCY, and if so the symbol xxx and the extension nnn + // of [$xxx-nnn] are returned + bool GetNewCurrencySymbol( OUString& rSymbol, OUString& rExtension ) const; + + static bool HasStringNegativeSign( const OUString& rStr ); + + /** + Whether a character at position nPos is somewhere between two matching + cQuote or not. + If nPos points to a cQuote, a true is returned on an opening cQuote, + a false is returned on a closing cQuote. + A cQuote between quotes may be escaped by a cEscIn, a cQuote outside of + quotes may be escaped by a cEscOut. + The default '\0' results in no escapement possible. + Defaults are set right according to the "unlogic" of the Numberformatter + */ + static bool IsInQuote( const OUString& rString, sal_Int32 nPos, + sal_Unicode cQuote = '"', + sal_Unicode cEscIn = '\0', sal_Unicode cEscOut = '\\' ); + + /** + Return the position of a matching closing cQuote if the character at + position nPos is between two matching cQuote, otherwise return -1. + If nPos points to an opening cQuote the position of the matching + closing cQuote is returned. + If nPos points to a closing cQuote nPos is returned. + If nPos points into a part which starts with an opening cQuote but has + no closing cQuote, rString.Len() is returned. + Uses <method>IsInQuote</method> internally, so you don't have to call + that prior to a call of this method. + */ + static sal_Int32 GetQuoteEnd( const OUString& rString, sal_Int32 nPos, + sal_Unicode cQuote = '"', + sal_Unicode cEscIn = '\0' ); + + void SetComment( const OUString& rStr ) + { sComment = rStr; } + const OUString& GetComment() const { return sComment; } + + /** Insert the number of blanks into the string that is needed to simulate + the width of character c for underscore formats */ + static sal_Int32 InsertBlanks( OUString& r, sal_Int32 nPos, sal_Unicode c ) + { + sal_Int32 result; + OUStringBuffer sBuff(r); + + result = InsertBlanks(sBuff, nPos, c); + r = sBuff.makeStringAndClear(); + + return result; + } + + /** Insert the number of blanks into the string that is needed to simulate + the width of character c for underscore formats */ + static sal_Int32 InsertBlanks( OUStringBuffer& r, sal_Int32 nPos, sal_Unicode c ); + + /// One of YMD,DMY,MDY if date format + DateOrder GetDateOrder() const; + + /** A coded value of the exact YMD combination used, if date format. + For example: YYYY-MM-DD => ('Y' << 16) | ('M' << 8) | 'D' + or: MM/YY => ('M' << 8) | 'Y' */ + sal_uInt32 GetExactDateOrder() const; + + // used in XML export + void GetConditions( SvNumberformatLimitOps& rOper1, double& rVal1, + SvNumberformatLimitOps& rOper2, double& rVal2 ) const; + Color* GetColor( sal_uInt16 nNumFor ) const; + void GetNumForInfo( sal_uInt16 nNumFor, SvNumFormatType& rScannedType, + bool& bThousand, sal_uInt16& nPrecision, sal_uInt16& nLeadingCnt ) const; + + // rAttr.Number not empty if NatNum attributes are to be stored + void GetNatNumXml( + css::i18n::NativeNumberXmlAttributes2& rAttr, + sal_uInt16 nNumFor ) const; + + /** Switches to the first non-"gregorian" calendar, but only if the current + calendar is "gregorian"; original calendar name and date/time returned, + but only if calendar switched and rOrgCalendar was empty. */ + void SwitchToOtherCalendar( OUString& rOrgCalendar, double& fOrgDateTime ) const; + + /** Switches to the "gregorian" calendar, but only if the current calendar + is non-"gregorian" and rOrgCalendar is not empty. Thus a preceding + ImpSwitchToOtherCalendar() call should have been placed prior to + calling this method. */ + void SwitchToGregorianCalendar( const OUString& rOrgCalendar, double fOrgDateTime ) const; + +#ifdef THE_FUTURE + /** Switches to the first specified calendar, if any, in subformat nNumFor + (0..3). Original calendar name and date/time returned, but only if + calendar switched and rOrgCalendar was empty. + + @return + <TRUE/> if a calendar was specified and switched to, + <FALSE/> else. + */ + bool SwitchToSpecifiedCalendar( OUString& rOrgCalendar, double& fOrgDateTime, + sal_uInt16 nNumFor ) const + { + if ( nNumFor < 4 ) + return ImpSwitchToSpecifiedCalendar( rOrgCalendar, + fOrgDateTime, NumFor[nNumFor] ); + return false; + } +#endif + + /// Whether it's a (YY)YY-M(M)-D(D) format. + bool IsIso8601( sal_uInt16 nNumFor ) const + { + if ( nNumFor < 4 ) + return ImpIsIso8601( NumFor[nNumFor]); + return false; + } + +private: + ImpSvNumFor NumFor[4]; // Array for the 4 subformats + OUString sFormatstring; // The format code string + OUString sComment; // Comment, since number formatter version 6 + double fLimit1; // Value for first condition + double fLimit2; // Value for second condition + ImpSvNumberformatScan& rScan; // Format code scanner + LocaleType maLocale; // Language/country of the format, numeral shape and calendar type from Excel. + SvNumberformatLimitOps eOp1; // Operator for first condition + SvNumberformatLimitOps eOp2; // Operator for second condition + SvNumFormatType eType; // Type of format + bool bAdditionalBuiltin; // If this is an additional built-in format defined by i18n + bool bStarFlag; // Take *n format as ESC n + bool bStandard; // If this is a default standard format + bool bIsUsed; // Flag as used for storing + + SVL_DLLPRIVATE sal_uInt16 ImpGetNumForStringElementCount( sal_uInt16 nNumFor ) const; + + SVL_DLLPRIVATE bool ImpIsOtherCalendar( const ImpSvNumFor& rNumFor ) const; + +#ifdef THE_FUTURE + SVL_DLLPRIVATE bool ImpSwitchToSpecifiedCalendar( OUString& rOrgCalendar, + double& fOrgDateTime, + const ImpSvNumFor& rNumFor ) const; +#endif + + /** Whether to use possessive genitive case month name, or partitive case + month name, instead of nominative name (noun). + + @param io_nState + 0: execute check <br> + set to 1 if nominative case is returned, <br> + set to 2 if genitive case is returned, <br> + set to 3 if partitive case is returned <br> + 1: don't execute check, return nominative case <br> + 2: don't execute check, return genitive case <br> + 3: don't execute check, return partitive case <br> + + @param eCodeType + a NfKeywordIndex, must designate a month type code + + @returns one of css::i18n::CalendarDisplayCode values + according to eCodeType and the check executed (or passed). + */ + SVL_DLLPRIVATE static sal_Int32 ImpUseMonthCase( int & io_nState, const ImpSvNumFor& rNumFor, NfKeywordIndex eCodeType ); + + /// Whether it's a (YY)YY-M(M)-D(D) format. + SVL_DLLPRIVATE bool ImpIsIso8601( const ImpSvNumFor& rNumFor ) const; + + const CharClass& rChrCls() const; + const LocaleDataWrapper& rLoc() const; + CalendarWrapper& GetCal() const; + const SvNumberFormatter& GetFormatter() const; + + // divide in substrings and color conditions + SVL_DLLPRIVATE short ImpNextSymbol( OUStringBuffer& rString, + sal_Int32& nPos, + OUString& sSymbol ) const; + + // read string until ']' and strip blanks (after condition) + SVL_DLLPRIVATE static sal_Int32 ImpGetNumber( OUStringBuffer& rString, + sal_Int32& nPos, + OUString& sSymbol ); + + /** + * Parse the content of '[$-xxx] or '[$-xxxxxxxx]' and extract the locale + * type from it. Given the string, start parsing at position specified by + * nPos, and store the end position with nPos when the parsing is + * complete. The nPos should point to the '$' before the parsing, and to + * the closing bracket after the parsing. When the content is [$-xxx], + * the xxx part represents the language type (aka LCID) in hex numerals. + * When the content is [$-xxxxxxxx] the last 4 digits represent the LCID + * (again in hex), the next 2 digits represent the calendar type, and the + * 2 highest digits (if exists) is the numeral shape. + * + * @reference + * http://office.microsoft.com/en-us/excel-help/creating-international-number-formats-HA001034635.aspx + * + * @param rString input string + * @param nPos position (see above). + * + * @return struct containing numeral shape, calendar type, and LCID that + * specifies language type. See i18nlangtag/lang.h for a complete + * list of language types. These numbers also correspond with the + * numbers used by Microsoft Office. + */ + SVL_DLLPRIVATE static LocaleType ImpGetLocaleType( const OUString& rString, sal_Int32& nPos ); + + /** Obtain calendar and numerals from a LocaleType that was parsed from a + LCID with ImpGetLocaleType(). + + Inserts a NatNum modifier to rString at nPos if needed as determined + from the numeral code. + + @ATTENTION: may modify <member>maLocale</member> to make it follow + aTmpLocale, in which case also nLang is adapted. + + @returns a string with the calendar if one was determined from the + calendar code, else an empty string. The calendar string needs to be + inserted at a proper position to rString after all bracketed prefixes. + */ + SVL_DLLPRIVATE OUString ImpObtainCalendarAndNumerals( OUStringBuffer & rString, + sal_Int32 nPos, + LanguageType & nLang, + const LocaleType & aTmpLocale ); + + // standard number output + SVL_DLLPRIVATE void ImpGetOutputStandard( double& fNumber, OUString& OutString ) const; + SVL_DLLPRIVATE void ImpGetOutputStandard( double& fNumber, OUStringBuffer& OutString ) const; + SVL_DLLPRIVATE void ImpGetOutputStdToPrecision( double& rNumber, OUString& rOutString, sal_uInt16 nPrecision ) const; + // numbers in input line + SVL_DLLPRIVATE void ImpGetOutputInputLine( double fNumber, OUString& OutString ) const; + + // check subcondition + // OP undefined => -1 + // else 0 or 1 + SVL_DLLPRIVATE static short ImpCheckCondition(double fNumber, + double fLimit, + SvNumberformatLimitOps eOp); + + // Helper function for number strings + // append string symbols, insert leading 0 or ' ', or ... + SVL_DLLPRIVATE bool ImpNumberFill( OUStringBuffer& sStr, + double& rNumber, + sal_Int32& k, + sal_uInt16& j, + sal_uInt16 nIx, + short eSymbolType, + bool bInsertRightBlank = false ); + + // Helper function to fill in the integer part and the group (AKA thousand) separators + SVL_DLLPRIVATE bool ImpNumberFillWithThousands( OUStringBuffer& sStr, + double& rNumber, + sal_Int32 k, + sal_uInt16 j, + sal_uInt16 nIx, + sal_Int32 nDigCnt, + bool bAddDecSep = true ); + + // Helper function to fill in the group (AKA thousand) separators + // or to skip additional digits + SVL_DLLPRIVATE void ImpDigitFill( OUStringBuffer& sStr, + sal_Int32 nStart, + sal_Int32& k, + sal_uInt16 nIx, + sal_Int32 & nDigitCount, + utl::DigitGroupingIterator & ); + + SVL_DLLPRIVATE bool ImpDecimalFill( OUStringBuffer& sStr, + double& rNumber, + sal_Int32 nDecPos, + sal_uInt16 j, + sal_uInt16 nIx, + bool bInteger ); + + /** Calculate each element of fraction: + * integer part, numerator part, denominator part + * @param fNumber value to be represented as fraction. Will contain absolute fractional part + * @param nIx subformat number 0..3 + * @param fIntPart integral part of fraction + * @param nFrac numerator of fraction + * @param nDic denominator of fraction + */ + SVL_DLLPRIVATE void ImpGetFractionElements( double& fNumber, + sal_uInt16 nIx, + double& fIntPart, + sal_uInt64& nFrac, + sal_uInt64& nDiv ) const; + SVL_DLLPRIVATE bool ImpGetFractionOutput(double fNumber, + sal_uInt16 nIx, + OUStringBuffer& OutString); + SVL_DLLPRIVATE bool ImpGetScientificOutput(double fNumber, + sal_uInt16 nIx, + OUStringBuffer& OutString); + + SVL_DLLPRIVATE bool ImpGetDateOutput( double fNumber, + sal_uInt16 nIx, + OUStringBuffer& OutString ); + SVL_DLLPRIVATE bool ImpGetTimeOutput( double fNumber, + sal_uInt16 nIx, + OUStringBuffer& OutString ); + SVL_DLLPRIVATE bool ImpGetDateTimeOutput( double fNumber, + sal_uInt16 nIx, + OUStringBuffer& OutString ); + + // Switches to the "gregorian" calendar if the current calendar is + // non-"gregorian" and the era is a "Dummy" era of a calendar which doesn't + // know a "before" era (like zh_TW ROC or ja_JP Gengou). If switched and + // rOrgCalendar was "gregorian" the string is emptied. If rOrgCalendar was + // empty the previous calendar name and date/time are returned. + SVL_DLLPRIVATE bool ImpFallBackToGregorianCalendar( OUString& rOrgCalendar, double& fOrgDateTime ); + + // Append a "G" short era string of the given calendar. In the case of a + // Gengou calendar this is a one character abbreviation, for other + // calendars the XExtendedCalendar::getDisplayString() method is called. + SVL_DLLPRIVATE static void ImpAppendEraG( OUStringBuffer& OutStringBuffer, const CalendarWrapper& rCal, + sal_Int16 nNatNum ); + + SVL_DLLPRIVATE bool ImpGetNumberOutput( double fNumber, + sal_uInt16 nIx, + OUStringBuffer& OutString ); + + SVL_DLLPRIVATE void ImpCopyNumberformat( const SvNumberformat& rFormat ); + + // normal digits or other digits, depending on ImpSvNumFor.aNatNum, + // [NatNum1], [NatNum2], ... + SVL_DLLPRIVATE OUString ImpGetNatNumString( const SvNumberNatNum& rNum, sal_Int32 nVal, + sal_uInt16 nMinDigits ) const; + + OUString ImpIntToString( sal_uInt16 nIx, sal_Int32 nVal, sal_uInt16 nMinDigits = 0 ) const + { + const SvNumberNatNum& rNum = NumFor[nIx].GetNatNum(); + if ( nMinDigits || rNum.IsComplete() ) + { + return ImpGetNatNumString( rNum, nVal, nMinDigits ); + } + return OUString::number(nVal); + } + + // Obtain the string of the fraction of second, without leading "0.", + // rounded to nFractionDecimals (or nFractionDecimals+1 if + // bAddOneRoundingDecimal==true but then truncated at nFractionDecimals, + // for use with the result of tools::Time::GetClock()) with the length of + // nFractionDecimals, unless nMinimumInputLineDecimals>0 is given for input + // line string where extra trailing "0" are discarded. + SVL_DLLPRIVATE sal_uInt16 ImpGetFractionOfSecondString( OUStringBuffer& rBuf, double fFractionOfSecond, + int nFractionDecimals, bool bAddOneRoundingDecimal, sal_uInt16 nIx, sal_uInt16 nMinimumInputLineDecimals ); + + // transliterate according to NativeNumber + SVL_DLLPRIVATE OUString impTransliterateImpl(const OUString& rStr, const SvNumberNatNum& rNum) const; + SVL_DLLPRIVATE void impTransliterateImpl(OUStringBuffer& rStr, const SvNumberNatNum& rNum) const; + SVL_DLLPRIVATE OUString impTransliterateImpl(const OUString& rStr, const SvNumberNatNum& rNum, sal_uInt16 nDateKey) const; + + OUString impTransliterate(const OUString& rStr, const SvNumberNatNum& rNum) const + { + return rNum.IsComplete() ? impTransliterateImpl(rStr, rNum) : rStr; + } + + SVL_DLLPRIVATE void impTransliterate(OUStringBuffer& rStr, const SvNumberNatNum& rNum) const + { + if(rNum.IsComplete()) + { + impTransliterateImpl(rStr, rNum); + } + } + + OUString impTransliterate(const OUString& rStr, const SvNumberNatNum& rNum, sal_uInt16 nDateKey) const + { + return rNum.IsComplete() ? impTransliterateImpl(rStr, rNum, nDateKey) : rStr; + } + +}; + +#endif // INCLUDED_SVL_ZFORMAT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |