Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / svx / hlnkitem.hxx
blob03eb8424561cb53baa5ab2942478f318289bbde4
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_SVX_HLNKITEM_HXX
20 #define INCLUDED_SVX_HLNKITEM_HXX
22 #include <rtl/ustring.hxx>
23 #include <svl/poolitem.hxx>
24 #include <sfx2/sfxsids.hrc>
25 #include <svl/macitem.hxx>
26 #include <svx/svxdllapi.h>
27 #include <o3tl/typed_flags_set.hxx>
28 #include <memory>
30 enum class HyperDialogEvent {
31 NONE = 0x0000,
32 MouseOverObject = 0x0001,
33 MouseClickObject = 0x0002,
34 MouseOutObject = 0x0004,
36 namespace o3tl {
37 template<> struct typed_flags<HyperDialogEvent> : is_typed_flags<HyperDialogEvent, 0x07> {};
40 enum SvxLinkInsertMode
42 HLINK_DEFAULT,
43 HLINK_FIELD,
44 HLINK_BUTTON,
45 HLINK_HTMLMODE = 0x0080
48 class SVX_DLLPUBLIC SvxHyperlinkItem final : public SfxPoolItem
50 OUString sName;
51 OUString sURL;
52 OUString sTarget;
53 SvxLinkInsertMode eType;
54 OUString sReplacementText;
56 OUString sIntName;
57 std::unique_ptr<SvxMacroTableDtor> pMacroTable;
59 HyperDialogEvent nMacroEvents;
61 public:
62 static SfxPoolItem* CreateDefault();
64 SvxHyperlinkItem( TypedWhichId<SvxHyperlinkItem> _nWhich = SID_HYPERLINK_GETLINK ):
65 SfxPoolItem(_nWhich) { eType = HLINK_DEFAULT; nMacroEvents=HyperDialogEvent::NONE; };
66 SvxHyperlinkItem( const SvxHyperlinkItem& rHyperlinkItem );
67 SvxHyperlinkItem( TypedWhichId<SvxHyperlinkItem> nWhich, OUString aName, OUString aURL,
68 OUString aTarget, OUString aIntName,
69 SvxLinkInsertMode eTyp,
70 HyperDialogEvent nEvents,
71 SvxMacroTableDtor const *pMacroTbl,
72 OUString aReplacementText = OUString());
74 virtual bool operator==( const SfxPoolItem& ) const override;
75 virtual SvxHyperlinkItem* Clone( SfxItemPool *pPool = nullptr ) const override;
76 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
77 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
79 const OUString& GetName() const { return sName; }
80 void SetName(const OUString& rName) { sName = rName; }
82 const OUString& GetURL() const { return sURL; }
83 void SetURL(const OUString& rURL) { sURL = rURL; }
85 const OUString& GetIntName () const { return sIntName; }
86 void SetIntName(const OUString& rIntName) { sIntName = rIntName; }
88 const OUString& GetTargetFrame() const { return sTarget; }
89 void SetTargetFrame(const OUString& rTarget) { sTarget = rTarget; }
91 SvxLinkInsertMode GetInsertMode() const { return eType; }
92 void SetInsertMode( SvxLinkInsertMode eNew ) { eType = eNew; }
94 void SetMacro( HyperDialogEvent nEvent, const SvxMacro& rMacro );
96 void SetMacroTable( const SvxMacroTableDtor& rTbl );
97 const SvxMacroTableDtor* GetMacroTable() const { return pMacroTable.get(); }
99 void SetMacroEvents (const HyperDialogEvent nEvents) { nMacroEvents = nEvents; }
100 HyperDialogEvent GetMacroEvents() const { return nMacroEvents; }
102 const OUString& GetReplacementText() const { return sReplacementText; }
103 void SetReplacementText(const OUString& rReplacementText) { sReplacementText = rReplacementText; }
107 #endif
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */