diff --git a/nvdaHelper/archBuild_sconscript b/nvdaHelper/archBuild_sconscript index f6dfc30ab24..c8599675cc4 100644 --- a/nvdaHelper/archBuild_sconscript +++ b/nvdaHelper/archBuild_sconscript @@ -92,7 +92,11 @@ env.Append( ('_WIN32_WINNT','_WIN32_WINNT_WIN7') ] ) -env.Append(CCFLAGS=['/W3','/WX']) +env.Append(CCFLAGS=[ + '/W3', + '/WX', + '/std:c++17' +]) if 'analyze' in debug: env.Append(CCFLAGS=['/analyze']) # Disable: Inconsistent annotation for 'x': this instance has no annotations. diff --git a/nvdaHelper/localWin10/oneCoreSpeech.cpp b/nvdaHelper/localWin10/oneCoreSpeech.cpp index a0600c20582..2421515d461 100644 --- a/nvdaHelper/localWin10/oneCoreSpeech.cpp +++ b/nvdaHelper/localWin10/oneCoreSpeech.cpp @@ -88,7 +88,7 @@ void __stdcall ocSpeech_speak(OcSpeech* instance, char16 *text) { }).then([instance, markersStr] (IBuffer^ buffer) { // Data has been read from the speech stream. // Pass it to the callback. - byte* bytes = getBytes(buffer); + BYTE* bytes = getBytes(buffer); instance->callback(bytes, buffer->Length, markersStr->c_str()); }).then([instance] (task previous) { // Catch any unhandled exceptions that occurred during these tasks. diff --git a/nvdaHelper/remote/COMProxyRegistration.cpp b/nvdaHelper/remote/COMProxyRegistration.cpp index d12f44602e4..7abfd6a32e4 100644 --- a/nvdaHelper/remote/COMProxyRegistration.cpp +++ b/nvdaHelper/remote/COMProxyRegistration.cpp @@ -16,7 +16,6 @@ This license can be found at: #include #include #include -#include #include #define WIN32_LEAN_AND_MEAN #define CINTERFACE @@ -140,8 +139,36 @@ COMProxyRegistration_t* registerCOMProxy(wchar_t* dllPath) { for(unsigned short idx=0;idxheader.piid); CLSID clsidBackup={0}; - wstring_convert> converter; - wstring name=converter.from_bytes(fileInfo.pNamesArray[idx]); + const auto pName = fileInfo.pNamesArray[idx]; + const int nameLength=MultiByteToWideChar( + CP_UTF8, // Code Page for conversion + 0, // DWFlags + pName, // lpMultiByteStr - string to convert + -1, // cbMultiByte - size (bytes of pName). -1 means process whole string and pName must be null terminated. + nullptr, // lpWideCharStr - don't fetch anything this time + 0 // cchWideChar - character count of lpWideCharStr. When 0, lpWideCharStr is not used, just return number of characters after conversion (including null character). + ); + if (0 == nameLength) { + LOG_ERROR(L"Unable to get name length for MultiByteToWideChar conversion for entry "< Fields::getEndOfPageNumberFieldAtIndex(const int index){ +std::optional Fields::getEndOfPageNumberFieldAtIndex(const int index){ for( auto&& pageNum : m_pageNumbers ){ if(inRange(index, pageNum.first, pageNum.second)){ return pageNum.second; } } - return std::experimental::optional(); + return std::optional(); } } // end namespace WinWord \ No newline at end of file diff --git a/nvdaHelper/remote/WinWord/Fields.h b/nvdaHelper/remote/WinWord/Fields.h index d0ef33c0163..dd870786674 100644 --- a/nvdaHelper/remote/WinWord/Fields.h +++ b/nvdaHelper/remote/WinWord/Fields.h @@ -16,7 +16,7 @@ This license can be found at: #define WIN32_LEAN_AND_MEAN #include -#include +#include struct IDispatch; namespace WinWord { @@ -49,7 +49,7 @@ namespace WinWord { * @param index Find a range that this index is part of. * @returns an optional value, if a range exists the end index is returned of visible text range. */ - std::experimental::optional getEndOfPageNumberFieldAtIndex(const int index); + std::optional getEndOfPageNumberFieldAtIndex(const int index); Fields(const Fields&) = delete; // Copy constructor disabled, no implementation. Fields& operator=(const Fields&) = delete; // Assignment disabled, no implementation. diff --git a/nvdaHelper/remote/winword.cpp b/nvdaHelper/remote/winword.cpp index 39bac18c944..add5eeb6695 100644 --- a/nvdaHelper/remote/winword.cpp +++ b/nvdaHelper/remote/winword.cpp @@ -21,7 +21,7 @@ This license can be found at: #include #include #include -#include +#include #include "nvdaHelperRemote.h" #include "nvdaInProcUtils.h" #include "nvdaInProcUtils.h" @@ -751,7 +751,7 @@ inline bool generateFootnoteEndnoteXML(IDispatch* pDispatchRange, wostringstream return true; } -std::experimental::optional getSectionBreakType(IDispatchPtr pDispatchRange ) { +std::optional getSectionBreakType(IDispatchPtr pDispatchRange ) { // The following case should handle where we have the page break character ('0x0c') shown with '|p|' // first section|p| // second section. @@ -817,7 +817,7 @@ std::experimental::optional getSectionBreakType(IDispatchPtr pDispatchRange return type; } -std::experimental::optional +std::optional getStartOfRangeDistanceFromEdgeOfDocument(IDispatchPtr pDispatchRange) { float rangePos = -1.0f; auto res = _com_dispatch_raw_method( pDispatchRange, wdDISPID_RANGE_INFORMATION, @@ -831,7 +831,7 @@ getStartOfRangeDistanceFromEdgeOfDocument(IDispatchPtr pDispatchRange) { return rangePos; } -std::experimental::optional< std::pair > +std::optional< std::pair > calculatePreAndPostColumnOffsets(IDispatchPtr pDispatchPageSetup) { float leftMargin = -1.0f; auto res = _com_dispatch_raw_propget( pDispatchPageSetup, wdDISPID_PAGESETUP_LEFTMARGIN, @@ -1182,8 +1182,8 @@ void winword_getTextInRange_helper(HWND hwnd, winword_getTextInRange_args* args) if(text) { int noteCharOffset=-1; bool isNoteChar=false; - std::experimental::optional pageBreakCharIndex; - std::experimental::optional columnBreakCharIndex; + std::optional pageBreakCharIndex; + std::optional columnBreakCharIndex; if(!isFormField) { //Force a new chunk before and after control+b (note characters) for(int i=0;text[i]!=L'\0';++i) { diff --git a/nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.cpp b/nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.cpp index 47fdfd22ae9..9d325843394 100755 --- a/nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.cpp +++ b/nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.cpp @@ -16,7 +16,7 @@ This license can be found at: #include #include #include -#include +#include #include #include #include @@ -287,13 +287,13 @@ void GeckoVBufBackend_t::versionSpecificInit(IAccessible2* pacc) { SysFreeString(toolkitVersion); } -experimental::optional +optional getIAccessible2UniqueID(IAccessible2* targetAcc) { int ID = 0; //Get ID -- IAccessible2 uniqueID if (targetAcc->get_uniqueID((long*)&ID) != S_OK) { LOG_DEBUG(L"pacc->get_uniqueID failed"); - return experimental::optional(); + return optional(); } return ID; } @@ -301,10 +301,10 @@ getIAccessible2UniqueID(IAccessible2* targetAcc) { class LabelInfo { public: bool isVisible; - std::experimental::optional ID; + optional ID; }; -using OptionalLabelInfo = std::experimental::optional< LabelInfo >; +using OptionalLabelInfo = optional< LabelInfo >; OptionalLabelInfo GeckoVBufBackend_t::getLabelInfo(IAccessible2* pacc2) { CComQIPtr pacc2_2=pacc2; if (!pacc2_2) return OptionalLabelInfo(); @@ -657,7 +657,7 @@ VBufStorage_fieldNode_t* GeckoVBufBackend_t::fillVBuf( // Whether the name of this node has been explicitly set (as opposed to calculated by descendant) const bool nameIsExplicit = IA2AttribsMapIt != IA2AttribsMap.end() && IA2AttribsMapIt->second == L"true"; // Whether the name is the content of this node. - std::experimental::optional labelInfo_; + optional labelInfo_; // A version of the getIdForVisibleLabel function that caches its result auto isLabelVisibleCached = [&]() { if (!labelInfo_) { @@ -673,7 +673,7 @@ VBufStorage_fieldNode_t* GeckoVBufBackend_t::fillVBuf( if (!labelInfo_) { labelInfo_ = getLabelInfo(pacc); } - experimental::optional id; + optional id; if (labelInfo_) { id = labelInfo_->ID; } diff --git a/nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.h b/nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.h index d59ed2bec4e..9537aa19565 100755 --- a/nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.h +++ b/nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.h @@ -16,7 +16,7 @@ This license can be found at: #define VIRTUALBUFFER_BACKENDS_EXAMPLE_H #include -#include +#include class LabelInfo; @@ -42,7 +42,7 @@ class GeckoVBufBackend_t: public VBufBackend_t { bool hasEncodedAccDescription; std::wstring toolkitName; - std::experimental::optional< LabelInfo > getLabelInfo(IAccessible2* pacc2); + std::optional< LabelInfo > getLabelInfo(IAccessible2* pacc2); CComPtr getLabelElement(IAccessible2_2* element); CComPtr getSelectedItem(IAccessible2* container, const std::map& attribs);