Skip to content

Commit 431c162

Browse files
authored
Merge 6a790d8 into 396ca1f
2 parents 396ca1f + 6a790d8 commit 431c162

4 files changed

Lines changed: 34 additions & 8 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# A part of NonVisual Desktop Access (NVDA)
2+
# Copyright (C) 2024 NV Access Limited, Cyrille Bougot
3+
# This file is covered by the GNU General Public License.
4+
# See the file COPYING for more details.
5+
6+
from enum import IntEnum
7+
8+
9+
class MsoHyperlink(IntEnum):
10+
"""Enumeration of hyperlink types in the Microsoft Office object model.
11+
See https://learn.microsoft.com/en-us/office/vba/api/office.msohyperlinktype
12+
"""
13+
14+
RANGE = 0
15+
SHAPE = 1
16+
INLINE_SHAPE = 2

source/NVDAObjects/window/excel.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
from utils.displayString import DisplayStringIntEnum
5252
import NVDAState
5353
from globalCommands import SCRCAT_SYSTEMCARET
54+
from ._msOffice import MsoHyperlink
5455

5556
excel2010VersionMajor = 14
5657

@@ -1367,6 +1368,21 @@ def _getFormatFieldAndOffsets(self, offset, formatConfig, calculateOffsets=True)
13671368
def _get_locationText(self):
13681369
return self.obj.getCellPosition()
13691370

1371+
def _getLinkDataAtCaretPosition(self) -> textInfos._Link | None:
1372+
links = self.obj.excelCellObject.Hyperlinks
1373+
if links.count == 0:
1374+
return None
1375+
link = links(1)
1376+
if link.Type == MsoHyperlink.RANGE:
1377+
text = link.TextToDisplay
1378+
else:
1379+
log.debugWarning(f"No text to display for link type {link.Type}")
1380+
text = None
1381+
return textInfos._Link(
1382+
displayText=text,
1383+
destination=link.Address,
1384+
)
1385+
13701386

13711387
NVCELLINFOFLAG_ADDRESS = 0x1
13721388
NVCELLINFOFLAG_TEXT = 0x2

source/NVDAObjects/window/winword.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from . import Window
4242
from ..behaviors import EditableTextWithoutAutoSelectDetection
4343
from . import _msOfficeChart
44+
from ._msOffice import MsoHyperlink
4445
import locationHelper
4546
from enum import IntEnum
4647
import documentBase
@@ -82,13 +83,6 @@
8283
wdMaximumNumberOfColumns = 18
8384

8485

85-
class MsoHyperlink(IntEnum):
86-
# See https://learn.microsoft.com/en-us/office/vba/api/office.msohyperlinktype
87-
RANGE = 0
88-
SHAPE = 1
89-
INLINE_SHAPE = 2
90-
91-
9286
class WdUnderline(DisplayStringIntEnum):
9387
# Word underline styles
9488
# see https://docs.microsoft.com/en-us/office/vba/api/word.wdunderline

user_docs/en/changes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ To use this feature, "allow NVDA to control the volume of other applications" mu
5959
* When spelling, unicode normalization now works more appropriately:
6060
* After reporting a normalized character, NVDA no longer incorrectly reports subsequent characters as normalized. (#17286, @LeonarddeR)
6161
* Composite characters (such as é) are now reported correctly. (#17295, @LeonarddeR)
62-
* In Word or Outlook, when using legacy object model, the command to report the destination URL of a link does not report any longer "Not a link" when there is one to report. (#17292, @CyrilleB79)
62+
* The command to Report the destination URL of a link now works as expected when using the legacy object model in Microsoft Word, Outlook and Excel. (#17292, #17362, @CyrilleB79)
6363

6464
### Changes for Developers
6565

0 commit comments

Comments
 (0)