* chore: settle line endings in .gitattributes Nothing declared line endings, so each file kept whatever the contributor's core.autocrlf produced when it was added: 382 text files ended up LF and 50 CRLF. The CRLF ones are the hazard. Editing one on macOS or Linux writes LF lines into it, and clang-format rejects a file that mixes both -- which is how `quality / Workflow validation` went red on KeyStateCategory.h, where three lines out of a CRLF file had arrived as LF. #309 converted those three lines back and left the other 49 files loaded. The repository now declares LF and the working trees are renormalized to match, so the failure mode is gone rather than deferred to whichever of those files is edited next. The four binary types are declared rather than left to git's heuristic, which decides from the first 8000 bytes alone. user_dict.dat is caught by that sample today only because the 40-byte seed is almost entirely NUL. Verified: the 56 renormalized files are byte-identical to their old contents once CR is stripped, no text file in the index still carries CRLF, and scripts/format.sh --check passes. * chore: skip the line-ending renormalization in blame The commit before this one rewrote every line of 56 files without changing a character of them, which is what this file exists to hide.
219 lines
5.1 KiB
C++
219 lines
5.1 KiB
C++
#include "Private.h"
|
|
#include "Globals.h"
|
|
#include "MetasequoiaIME.h"
|
|
#include "DisplayAttributeInfo.h"
|
|
#include "EnumDisplayAttributeInfo.h"
|
|
|
|
//+---------------------------------------------------------------------------
|
|
//
|
|
// ctor
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
CEnumDisplayAttributeInfo::CEnumDisplayAttributeInfo()
|
|
{
|
|
DllAddRef();
|
|
|
|
_index = 0;
|
|
_refCount = 1;
|
|
}
|
|
|
|
//+---------------------------------------------------------------------------
|
|
//
|
|
// dtor
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
CEnumDisplayAttributeInfo::~CEnumDisplayAttributeInfo()
|
|
{
|
|
DllRelease();
|
|
}
|
|
|
|
//+---------------------------------------------------------------------------
|
|
//
|
|
// QueryInterface
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
STDAPI CEnumDisplayAttributeInfo::QueryInterface(REFIID riid, _Outptr_ void **ppvObj)
|
|
{
|
|
if (ppvObj == nullptr)
|
|
return E_INVALIDARG;
|
|
|
|
*ppvObj = nullptr;
|
|
|
|
if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IEnumTfDisplayAttributeInfo))
|
|
{
|
|
*ppvObj = (IEnumTfDisplayAttributeInfo *)this;
|
|
}
|
|
|
|
if (*ppvObj)
|
|
{
|
|
AddRef();
|
|
return S_OK;
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
}
|
|
|
|
//+---------------------------------------------------------------------------
|
|
//
|
|
// AddRef
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
STDAPI_(ULONG) CEnumDisplayAttributeInfo::AddRef()
|
|
{
|
|
return ++_refCount;
|
|
}
|
|
|
|
//+---------------------------------------------------------------------------
|
|
//
|
|
// Release
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
STDAPI_(ULONG) CEnumDisplayAttributeInfo::Release()
|
|
{
|
|
LONG cr = --_refCount;
|
|
|
|
assert(_refCount >= 0);
|
|
|
|
if (_refCount == 0)
|
|
{
|
|
delete this;
|
|
}
|
|
|
|
return cr;
|
|
}
|
|
|
|
//+---------------------------------------------------------------------------
|
|
//
|
|
// IEnumTfDisplayAttributeInfo::Clone
|
|
//
|
|
// Returns a copy of the object.
|
|
//----------------------------------------------------------------------------
|
|
|
|
STDAPI CEnumDisplayAttributeInfo::Clone(_Out_ IEnumTfDisplayAttributeInfo **ppEnum)
|
|
{
|
|
CEnumDisplayAttributeInfo *pClone = nullptr;
|
|
|
|
if (ppEnum == nullptr)
|
|
{
|
|
return E_INVALIDARG;
|
|
}
|
|
|
|
*ppEnum = nullptr;
|
|
|
|
pClone = new (std::nothrow) CEnumDisplayAttributeInfo();
|
|
if ((pClone) == nullptr)
|
|
{
|
|
return E_OUTOFMEMORY;
|
|
}
|
|
|
|
// the clone should match this object's state
|
|
pClone->_index = _index;
|
|
|
|
*ppEnum = pClone;
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
//+---------------------------------------------------------------------------
|
|
//
|
|
// IEnumTfDisplayAttributeInfo::Next
|
|
//
|
|
// Returns an array of display attribute info objects supported by this service.
|
|
//----------------------------------------------------------------------------
|
|
|
|
const int MAX_DISPLAY_ATTRIBUTE_INFO = 2;
|
|
|
|
STDAPI CEnumDisplayAttributeInfo::Next(ULONG ulCount,
|
|
__RPC__out_ecount_part(ulCount, *pcFetched) ITfDisplayAttributeInfo **rgInfo,
|
|
__RPC__out ULONG *pcFetched)
|
|
{
|
|
ULONG fetched;
|
|
|
|
fetched = 0;
|
|
|
|
if (ulCount == 0)
|
|
{
|
|
return S_OK;
|
|
}
|
|
if (rgInfo == nullptr)
|
|
{
|
|
return E_INVALIDARG;
|
|
}
|
|
*rgInfo = nullptr;
|
|
|
|
while (fetched < ulCount)
|
|
{
|
|
ITfDisplayAttributeInfo *pDisplayAttributeInfo = nullptr;
|
|
|
|
if (_index == 0)
|
|
{
|
|
pDisplayAttributeInfo = new (std::nothrow) CDisplayAttributeInfoInput();
|
|
if ((pDisplayAttributeInfo) == nullptr)
|
|
{
|
|
return E_OUTOFMEMORY;
|
|
}
|
|
}
|
|
else if (_index == 1)
|
|
{
|
|
pDisplayAttributeInfo = new (std::nothrow) CDisplayAttributeInfoConverted();
|
|
if ((pDisplayAttributeInfo) == nullptr)
|
|
{
|
|
return E_OUTOFMEMORY;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
|
|
*rgInfo = pDisplayAttributeInfo;
|
|
rgInfo++;
|
|
fetched++;
|
|
_index++;
|
|
}
|
|
|
|
if (pcFetched != nullptr)
|
|
{
|
|
// technically this is only legal if ulCount == 1, but we won't check
|
|
*pcFetched = fetched;
|
|
}
|
|
|
|
return (fetched == ulCount) ? S_OK : S_FALSE;
|
|
}
|
|
|
|
//+---------------------------------------------------------------------------
|
|
//
|
|
// IEnumTfDisplayAttributeInfo::Reset
|
|
//
|
|
// Resets the enumeration.
|
|
//----------------------------------------------------------------------------
|
|
|
|
STDAPI CEnumDisplayAttributeInfo::Reset()
|
|
{
|
|
_index = 0;
|
|
return S_OK;
|
|
}
|
|
|
|
//+---------------------------------------------------------------------------
|
|
//
|
|
// IEnumTfDisplayAttributeInfo::Skip
|
|
//
|
|
// Skips past objects in the enumeration.
|
|
//----------------------------------------------------------------------------
|
|
|
|
STDAPI CEnumDisplayAttributeInfo::Skip(ULONG ulCount)
|
|
{
|
|
if ((ulCount + _index) > MAX_DISPLAY_ATTRIBUTE_INFO || (ulCount + _index) < ulCount)
|
|
{
|
|
_index = MAX_DISPLAY_ATTRIBUTE_INFO;
|
|
return S_FALSE;
|
|
}
|
|
_index += ulCount;
|
|
return S_OK;
|
|
}
|