LibreOffice Module svl (master) 1
macitem.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_SVL_MACITEM_HXX
20#define INCLUDED_SVL_MACITEM_HXX
21
22// class SvxMacroItem ----------------------------------------------------
23
24#include <rtl/ustring.hxx>
25#include <svl/svldllapi.h>
26#include <svl/poolitem.hxx>
27#include <map>
28#include <utility>
29
30class SvStream;
31enum class SvMacroItemId : sal_uInt16;
32
33inline constexpr OUStringLiteral SVX_MACRO_LANGUAGE_JAVASCRIPT = u"JavaScript";
34inline constexpr OUStringLiteral SVX_MACRO_LANGUAGE_STARBASIC = u"StarBasic";
35inline constexpr OUStringLiteral SVX_MACRO_LANGUAGE_SF = u"Script";
36
38{
42};
43
45{
46 OUString aMacName;
47 OUString aLibName;
49
50public:
51
52 SvxMacro( OUString aMacName, const OUString &rLanguage);
53
54 SvxMacro( OUString aMacName, OUString aLibName,
55 ScriptType eType); // = STARBASIC removes
56
57 const OUString &GetLibName() const { return aLibName; }
58 const OUString &GetMacName() const { return aMacName; }
59 OUString GetLanguage()const;
60
61 ScriptType GetScriptType() const { return eType; }
62
63 bool HasMacro() const { return !aMacName.isEmpty(); }
64};
65
66inline SvxMacro::SvxMacro( OUString _aMacName, OUString _aLibName,
67 ScriptType eTyp )
68 : aMacName(std::move( _aMacName )), aLibName(std::move( _aLibName )), eType( eTyp )
69{}
70
71// Macro Table, destroys the pointers in the DTor!
72typedef std::map<SvMacroItemId, SvxMacro> SvxMacroTable;
73
74#define SVX_MACROTBL_VERSION31 0
75#define SVX_MACROTBL_VERSION40 1
76
78{
79private:
81public:
83 SvxMacroTableDtor( const SvxMacroTableDtor &rCpy ) : aSvxMacroTable(rCpy.aSvxMacroTable) { }
84
85 SvxMacroTableDtor& operator=( const SvxMacroTableDtor &rCpy );
86 bool operator==( const SvxMacroTableDtor& rOther ) const;
87
88 void Read( SvStream & );
89 SvStream& Write( SvStream & ) const;
90
91 bool empty() const { return aSvxMacroTable.empty(); }
92
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);
103};
104
105
106/*
107This item describes a Macro table.
108*/
109
111{
112public:
113 explicit inline SvxMacroItem ( const sal_uInt16 nId );
114
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;
123
124 const SvxMacroTableDtor& GetMacroTable() const { return aMacroTable;}
125 void SetMacroTable( const SvxMacroTableDtor& rTbl ) { aMacroTable = rTbl; }
126
127 inline const SvxMacro& GetMacro( SvMacroItemId nEvent ) const;
128 inline bool HasMacro( SvMacroItemId nEvent ) const;
129 void SetMacro( SvMacroItemId nEvent, const SvxMacro& );
130
131private:
133
134 SvxMacroItem( const SvxMacroItem& ) = default;
135};
136
137inline SvxMacroItem::SvxMacroItem( const sal_uInt16 nId )
138 : SfxPoolItem( nId )
139{}
140
141inline bool SvxMacroItem::HasMacro( SvMacroItemId nEvent ) const
142{
143 return aMacroTable.IsKeyValid( nEvent );
144}
145inline const SvxMacro& SvxMacroItem::GetMacro( SvMacroItemId nEvent ) const
146{
147 return *(aMacroTable.Get(nEvent));
148}
149
150#endif
151
152/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class for providers of defaults of SfxPoolItems.
Definition: itempool.hxx:51
SvxMacroTableDtor aMacroTable
Definition: macitem.hxx:132
const SvxMacro & GetMacro(SvMacroItemId nEvent) const
Definition: macitem.hxx:145
const SvxMacroTableDtor & GetMacroTable() const
Definition: macitem.hxx:124
SvxMacroItem(const SvxMacroItem &)=default
bool HasMacro(SvMacroItemId nEvent) const
Definition: macitem.hxx:141
SvxMacroItem(const sal_uInt16 nId)
Definition: macitem.hxx:137
void SetMacroTable(const SvxMacroTableDtor &rTbl)
Definition: macitem.hxx:125
SvxMacroTable aSvxMacroTable
Definition: macitem.hxx:80
bool empty() const
Definition: macitem.hxx:91
SvxMacroTableDtor(const SvxMacroTableDtor &rCpy)
Definition: macitem.hxx:83
bool IsKeyValid(SvMacroItemId nEvent) const
Definition: macitem.cxx:169
const SvxMacro * Get(SvMacroItemId nEvent) const
Definition: macitem.cxx:155
SvxMacro(OUString aMacName, const OUString &rLanguage)
Definition: macitem.cxx:32
OUString aLibName
Definition: macitem.hxx:47
ScriptType eType
Definition: macitem.hxx:48
const OUString & GetMacName() const
Definition: macitem.hxx:58
ScriptType GetScriptType() const
Definition: macitem.hxx:61
OUString aMacName
Definition: macitem.hxx:46
const OUString & GetLibName() const
Definition: macitem.hxx:57
bool HasMacro() const
Definition: macitem.hxx:63
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName) override
float u
SvMacroItemId
DocumentType eType
ScriptType
Definition: macitem.hxx:38
@ EXTENDED_STYPE
Definition: macitem.hxx:41
@ JAVASCRIPT
Definition: macitem.hxx:40
@ STARBASIC
Definition: macitem.hxx:39
std::map< SvMacroItemId, SvxMacro > SvxMacroTable
Definition: macitem.hxx:72
constexpr OUStringLiteral SVX_MACRO_LANGUAGE_JAVASCRIPT
Definition: macitem.hxx:33
constexpr OUStringLiteral SVX_MACRO_LANGUAGE_STARBASIC
Definition: macitem.hxx:34
constexpr OUStringLiteral SVX_MACRO_LANGUAGE_SF
Definition: macitem.hxx:35
MapUnit
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
sal_Int16 nId
SfxItemPresentation
Definition: poolitem.hxx:72
#define SVL_DLLPUBLIC
Definition: svldllapi.h:28
constexpr bool operator==(TypedWhichId< T > const &lhs, TypedWhichId< T > rhs)
Definition: typedwhich.hxx:43