workaround segfault in compiler on macos-clang-intel
[LibreOffice.git] / include / svl / macitem.hxx
blob1c2a4cf301b7d57b780424095f4735f9bda3a7ae
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SVL_MACITEM_HXX
20 #define INCLUDED_SVL_MACITEM_HXX
22 // class SvxMacroItem ----------------------------------------------------
24 #include <rtl/ustring.hxx>
25 #include <svl/svldllapi.h>
26 #include <svl/poolitem.hxx>
27 #include <map>
28 #include <utility>
30 class SvStream;
31 enum class SvMacroItemId : sal_uInt16;
33 inline constexpr OUString SVX_MACRO_LANGUAGE_JAVASCRIPT = u"JavaScript"_ustr;
34 inline constexpr OUString SVX_MACRO_LANGUAGE_STARBASIC = u"StarBasic"_ustr;
35 inline constexpr OUString SVX_MACRO_LANGUAGE_SF = u"Script"_ustr;
37 enum ScriptType
39 STARBASIC,
40 JAVASCRIPT,
41 EXTENDED_STYPE
44 class SVL_DLLPUBLIC SvxMacro
46 OUString aMacName;
47 OUString aLibName;
48 ScriptType eType;
50 public:
52 SvxMacro( OUString aMacName, const OUString &rLanguage);
54 SvxMacro( OUString aMacName, OUString aLibName,
55 ScriptType eType); // = STARBASIC removes
57 const OUString &GetLibName() const { return aLibName; }
58 const OUString &GetMacName() const { return aMacName; }
59 OUString GetLanguage()const;
61 ScriptType GetScriptType() const { return eType; }
63 bool HasMacro() const { return !aMacName.isEmpty(); }
66 inline SvxMacro::SvxMacro( OUString _aMacName, OUString _aLibName,
67 ScriptType eTyp )
68 : aMacName(std::move( _aMacName )), aLibName(std::move( _aLibName )), eType( eTyp )
71 // Macro Table, destroys the pointers in the DTor!
72 typedef std::map<SvMacroItemId, SvxMacro> SvxMacroTable;
74 #define SVX_MACROTBL_VERSION31 0
75 #define SVX_MACROTBL_VERSION40 1
77 class SVL_DLLPUBLIC SvxMacroTableDtor
79 private:
80 SvxMacroTable aSvxMacroTable;
81 public:
82 SvxMacroTableDtor() {}
83 SvxMacroTableDtor( const SvxMacroTableDtor &rCpy ) : aSvxMacroTable(rCpy.aSvxMacroTable) { }
85 SvxMacroTableDtor& operator=( const SvxMacroTableDtor &rCpy );
86 bool operator==( const SvxMacroTableDtor& rOther ) const;
88 void Read( SvStream & );
89 SvStream& Write( SvStream & ) const;
91 bool empty() const { return aSvxMacroTable.empty(); }
93 // returns NULL if no entry exists, or a pointer to the internal value
94 const SvxMacro* Get(SvMacroItemId nEvent) const;
95 // returns NULL if no entry exists, or a pointer to the internal value
96 SvxMacro* Get(SvMacroItemId nEvent);
97 // return true if the key exists
98 bool IsKeyValid(SvMacroItemId nEvent) const;
99 // This stores a copy of the rMacro parameter
100 SvxMacro& Insert(SvMacroItemId nEvent, const SvxMacro& rMacro);
101 // If the entry exists, remove it from the map and release it's storage
102 void Erase(SvMacroItemId nEvent);
107 This item describes a Macro table.
110 class SVL_DLLPUBLIC SvxMacroItem final : public SfxPoolItem
112 public:
113 explicit inline SvxMacroItem ( const sal_uInt16 nId );
115 // "pure virtual methods" of SfxPoolItem
116 virtual bool operator==( const SfxPoolItem& ) const override;
117 virtual bool GetPresentation( SfxItemPresentation ePres,
118 MapUnit eCoreMetric,
119 MapUnit ePresMetric,
120 OUString &rText,
121 const IntlWrapper& ) const override;
122 virtual SvxMacroItem* Clone( SfxItemPool *pPool = nullptr ) const override;
124 const SvxMacroTableDtor& GetMacroTable() const { return aMacroTable;}
125 void SetMacroTable( const SvxMacroTableDtor& rTbl ) { aMacroTable = rTbl; }
127 inline const SvxMacro& GetMacro( SvMacroItemId nEvent ) const;
128 inline bool HasMacro( SvMacroItemId nEvent ) const;
129 void SetMacro( SvMacroItemId nEvent, const SvxMacro& );
131 private:
132 SvxMacroTableDtor aMacroTable;
134 SvxMacroItem( const SvxMacroItem& ) = default;
137 inline SvxMacroItem::SvxMacroItem( const sal_uInt16 nId )
138 : SfxPoolItem( nId )
141 inline bool SvxMacroItem::HasMacro( SvMacroItemId nEvent ) const
143 return aMacroTable.IsKeyValid( nEvent );
145 inline const SvxMacro& SvxMacroItem::GetMacro( SvMacroItemId nEvent ) const
147 return *(aMacroTable.Get(nEvent));
150 #endif
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */