tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / vba / vbahyperlinks.hxx
blob7538fe50b0f97f60eb537fadff0a1fdae69e1d12
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 .
20 #pragma once
22 #include <ooo/vba/excel/XHyperlinks.hpp>
23 #include <rtl/ref.hxx>
24 #include <vbahelper/vbacollectionimpl.hxx>
26 class ScRangeList;
28 namespace detail {
30 class ScVbaHlinkContainer;
31 typedef ::rtl::Reference< ScVbaHlinkContainer > ScVbaHlinkContainerRef;
33 /** Base class for ScVbaHyperlinks to get an initialized ScVbaHlinkContainer
34 class member before the ScVbaHyperlinks_BASE base class will be constructed.
36 struct ScVbaHlinkContainerMember
38 ScVbaHlinkContainerRef mxContainer;
40 explicit ScVbaHlinkContainerMember( ScVbaHlinkContainer* pContainer );
41 ~ScVbaHlinkContainerMember();
44 } // namespace detail
46 class ScVbaHyperlinks;
47 typedef ::rtl::Reference< ScVbaHyperlinks > ScVbaHyperlinksRef;
49 typedef CollTestImplHelper< ov::excel::XHyperlinks > ScVbaHyperlinks_BASE;
51 /** Represents a collection of hyperlinks of a worksheet or of a range.
53 When a Hyperlinks collection object has been constructed from a VBA
54 Worksheet object, it will always represent the current set of all
55 hyperlinks existing in the sheet. Insertion and deletion of hyperlinks will
56 be reflected by the instance.
58 When a Hyperlinks collection object has been constructed from a VBA Range
59 object, it will represent the set of hyperlinks that have existed at its
60 construction time, and that are located completely inside the range(s)
61 represented by the Range object. Insertion and deletion of hyperlinks will
62 *not* be reflected by that instance. The instance will always offer all
63 hyperlinks it has been constructed with, even if they no longer exist.
64 Furthermore, the instance will not offer hyperlinks inserted later, even if
65 the instance itself has been used to insert the new hyperlinks.
67 VBA code example:
69 With ThisWorkbook.Worksheets(1)
71 Set hlinks = .Hyperlinks ' global Hyperlinks object
72 Set myrange = .Range("A1:C3")
73 Set rangelinks1 = myrange.Hyperlinks ' hyperlinks of range A1:C3
75 MsgBox hlinks.Count ' 0
76 MsgBox rangelinks1.Count ' 0
78 hlinks.Add .Range("A1"), "http://example.com"
79 ' a new hyperlink has been added in cell A1
81 MsgBox hlinks.Count ' 1
82 MsgBox rangelinks1.Count ' still 0!
83 Set rangelinks2 = myrange.Hyperlinks ' hyperlinks of range A1:C3
84 MsgBox rangelinks2.Count ' 1 (constructed after Add)
86 rangelinks1.Add .Range("A2"), "http://example.com"
87 ' a new hyperlink has been constructed via the rangelinks1 object
88 ' but this addition has been done by the worksheet Hyperlinks object
90 MsgBox hlinks.Count ' 2
91 MsgBox rangelinks1.Count ' still 0!!!
92 MsgBox rangelinks2.Count ' still 1!!!
93 MsgBox myrange.Hyperlinks.Count ' 2 (constructed after Add)
95 End With
97 class ScVbaHyperlinks : private detail::ScVbaHlinkContainerMember, public ScVbaHyperlinks_BASE
99 public:
100 /// @throws css::uno::RuntimeException
101 explicit ScVbaHyperlinks(
102 const css::uno::Reference< ov::XHelperInterface >& rxParent,
103 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
105 /// @throws css::uno::RuntimeException
106 explicit ScVbaHyperlinks(
107 const css::uno::Reference< ov::XHelperInterface >& rxParent,
108 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
109 const ScVbaHyperlinksRef& rxSheetHlinks, const ScRangeList& rScRanges );
111 virtual ~ScVbaHyperlinks() override;
113 // XHyperlinks
114 virtual css::uno::Reference< ov::excel::XHyperlink > SAL_CALL Add(
115 const css::uno::Any& rAnchor, const css::uno::Any& rAddress, const css::uno::Any& rSubAddress,
116 const css::uno::Any& rScreenTip, const css::uno::Any& rTextToDisplay ) override;
118 virtual void SAL_CALL Delete() override;
120 // XEnumerationAccess
121 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
123 // XElementAccess
124 virtual css::uno::Type SAL_CALL getElementType() override;
126 // ScVbaCollectionBase
127 virtual css::uno::Any createCollectionObject( const css::uno::Any& rSource ) override;
129 // XHelperInterface
130 VBAHELPER_DECL_XHELPERINTERFACE
132 private:
133 ScVbaHyperlinksRef mxSheetHlinks;
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */