Skip to content

Commit

Permalink
Speed ups for navigating Microsoft Excel spreadsheets, especially for…
Browse files Browse the repository at this point in the history
… those containing comments / dropdowns (#9257)

* Initial stub for excel_getCellTextWidth in nvdaHelper

* Implement all of getCellTextWidth in-process and call it from the Excel cell NVDAObject.

* Excel: move all states calculation in-process.

* Excel: fetch text, address, states, input title, input message, row/column coordinates and outline level all via one in-process call.

* Excel: fix up handling of merged cells.

* Excel: no need to call cell.currentRegion in fetchAssociatedHeaderCells. It just slows things down and the variable was never used!

* Excel inProc: getCellInfo now uses a struct, rather than everything as separate arguments. Will be easier once eventually fetching multiple cells at once.

* Excel: If NvDA cannot inject in-process, such as when in Protected  View, fall back to fetching some very basic info for cells, such as address and text.

* Excel: move the fetching of comments and formulas for Elements list in-process.

* Excel: remove an unneeded method.

* Excel nvdaHelper: move constants into their own file.

* nvdaHelper: make use of InterfaceMarshaller in outlook.cpp.

* Excel: mark ExcelCellInfoQuicknavIterator as an abstract class requiring QuicknavItemClass and collectionFromWorksheet to be implemented.

* Excel: address review comments.

* Address review comments.

* Address review comments.

* Excel nvdaHelper support: check more errors and remove a redundant fetch of range.address.

* Excel nvdaHelper:: Excel's range.item is 1-based not 0-based. Listing formulas was 1 cell off.

* Excel NVDAHelper: fetching all cells from a filtered range must use IEnumVariant, not range.item otherwise cells in the gaps will also be fetched.

* Update what's new.
  • Loading branch information
michaelDCurran authored Feb 17, 2019
1 parent a6f7fb4 commit 4e89925
Show file tree
Hide file tree
Showing 10 changed files with 880 additions and 224 deletions.
54 changes: 54 additions & 0 deletions nvdaHelper/common/COMUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <comdef.h>
#include <common/log.h>

namespace nvCOMUtils {

class InterfaceMarshaller {
private:
DWORD cookie {(DWORD)(-1)};
IGlobalInterfaceTablePtr pGIT {nullptr};

public:
InterfaceMarshaller() {};

template<typename t> HRESULT marshal(t* p) {
if(cookie!=-1) {
LOG_ERROR(L"An interface is already marshalled");
return E_FAIL;
}
HRESULT res=pGIT.CreateInstance(CLSID_StdGlobalInterfaceTable);
if(res!=S_OK) {
LOG_ERROR(L"Could not create global interface table");
return res;
}
res=pGIT->RegisterInterfaceInGlobal(p,__uuidof(t),&cookie);
if(res!=S_OK) {
LOG_ERROR(L"Could not register object in global interface table");
return res;
}
return S_OK;
}

template<typename t> t* unmarshal() {
if(cookie==-1) {
LOG_ERROR(L"Nothing has been marshalled");
return nullptr;
}
t* p=nullptr;
HRESULT res=pGIT->GetInterfaceFromGlobal(cookie,__uuidof(t),reinterpret_cast<void**>(&p));
if(res!=S_OK) {
LOG_ERROR(L"Could not unmarshal object, code "<<res);
return nullptr;
}
return p;
}

~InterfaceMarshaller() {
if(cookie!=-1) {
pGIT->RevokeInterfaceFromGlobal(cookie);
}
}

};

};
2 changes: 2 additions & 0 deletions nvdaHelper/interfaces/nvdaInProcUtils/nvdaInProcUtils.acf
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ interface NvdaInProcUtils {
[fault_status,comm_status] dumpOnCrash();
[fault_status,comm_status] IA2Text_findContentDescendant();
[fault_status,comm_status] outlook_getMAPIProp();

[fault_status,comm_status] excel_getCellInfos();
}
17 changes: 17 additions & 0 deletions nvdaHelper/interfaces/nvdaInProcUtils/nvdaInProcUtils.idl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ cpp_quote("*/")
import "wtypes.idl";
import "oaidl.idl";

typedef struct {
BSTR text;
BSTR address;
BSTR inputTitle;
BSTR inputMessage;
hyper states;
long rowNumber;
long rowSpan;
long columnNumber;
long columnSpan;
long outlineLevel;
BSTR comments;
BSTR formula;
} EXCEL_CELLINFO;

/**
* Useful utlity methods that can be executed in-process from NVDA
*/
Expand Down Expand Up @@ -68,4 +83,6 @@ interface NvdaInProcUtils {
*/
error_status_t outlook_getMAPIProp(const long threadID, [in] IUnknown* mapiObject, const unsigned long mapiPropTag, [out] VARIANT* val);

error_status_t excel_getCellInfos([in] const unsigned long windowHandle,[in] IDispatch* rangeObj, [in] long cellInfoFlags, [in] long cellCount, [out,size_is(cellCount)] EXCEL_CELLINFO* cellInfos, [out] long* numCellsFetched);

}
1 change: 1 addition & 0 deletions nvdaHelper/local/nvdaHelperLocal.def
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ EXPORTS
nvdaInProcUtils_winword_getTextInRange
nvdaInProcUtils_winword_moveByLine
nvdaInProcUtils_outlook_getMAPIProp
nvdaInProcUtils_excel_getCellInfos
VBuf_createBuffer
VBuf_destroyBuffer
VBuf_findNodeByAttributes
Expand Down
Loading

0 comments on commit 4e89925

Please sign in to comment.