Skip to content

Commit

Permalink
Merge pull request #428 from stephenegriffin/listdata
Browse files Browse the repository at this point in the history
Listdata
  • Loading branch information
stephenegriffin authored Dec 20, 2020
2 parents 33c2de7 + 37c98eb commit 70b53e9
Show file tree
Hide file tree
Showing 36 changed files with 294 additions and 262 deletions.
62 changes: 25 additions & 37 deletions UI/Controls/SortList/ContentsTableListCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ namespace controls::sortlistctrl

SetRowStrings(iRow, lpsRowData);
// Do this last so that our row can't get sorted before we're done!
lpData->bItemFullyLoaded = true;
lpData->setFullyLoaded(true);
}
}

Expand Down Expand Up @@ -966,18 +966,9 @@ namespace controls::sortlistctrl
if (lpData)
{
const auto contents = lpData->cast<sortlistdata::contentsData>();
if (contents && contents->m_lpEntryID)
if (contents && contents->getEntryID())
{
lpTempList->lpbin[iArrayPos].cb = contents->m_lpEntryID->cb;
lpTempList->lpbin[iArrayPos].lpb =
mapi::allocate<LPBYTE>(contents->m_lpEntryID->cb, lpTempList);
if (lpTempList->lpbin[iArrayPos].lpb)
{
CopyMemory(
lpTempList->lpbin[iArrayPos].lpb,
contents->m_lpEntryID->lpb,
contents->m_lpEntryID->cb);
}
lpTempList->lpbin[iArrayPos] = mapi::CopySBinary(*contents->getEntryID(), lpTempList);
}
}
}
Expand Down Expand Up @@ -1099,7 +1090,7 @@ namespace controls::sortlistctrl
const auto contents = lpListData->cast<sortlistdata::contentsData>();
if (!contents) return nullptr;

const auto lpEID = contents->m_lpEntryID;
const auto lpEID = contents->getEntryID();
if (!lpEID || lpEID->cb == 0) return nullptr;

output::DebugPrint(output::dbgLevel::Generic, L"Item being opened:\n");
Expand Down Expand Up @@ -1212,28 +1203,26 @@ namespace controls::sortlistctrl
{
// go get the original row for display in the prop list control
lpData = GetSortListData(pNMListView->iItem);
ULONG cValues = 0;
LPSPropValue lpProps = nullptr;
auto row = SRow{};
if (lpData)
{
cValues = lpData->cSourceProps;
lpProps = lpData->lpSourceProps;
row = lpData->getRow();
}

lpMAPIProp = m_lpHostDlg->OpenItemProp(pNMListView->iItem, modifyType::REQUEST_MODIFY);

szTitle = strings::loadstring(IDS_DISPLAYNAMENOTFOUND);

// try to use our rowset first
if (NODISPLAYNAME != m_ulDisplayNameColumn && lpProps && m_ulDisplayNameColumn < cValues)
if (NODISPLAYNAME != m_ulDisplayNameColumn && row.lpProps && m_ulDisplayNameColumn < row.cValues)
{
if (strings::CheckStringProp(&lpProps[m_ulDisplayNameColumn], PT_STRING8))
if (strings::CheckStringProp(&row.lpProps[m_ulDisplayNameColumn], PT_STRING8))
{
szTitle = strings::stringTowstring(lpProps[m_ulDisplayNameColumn].Value.lpszA);
szTitle = strings::stringTowstring(row.lpProps[m_ulDisplayNameColumn].Value.lpszA);
}
else if (strings::CheckStringProp(&lpProps[m_ulDisplayNameColumn], PT_UNICODE))
else if (strings::CheckStringProp(&row.lpProps[m_ulDisplayNameColumn], PT_UNICODE))
{
szTitle = lpProps[m_ulDisplayNameColumn].Value.lpszW;
szTitle = row.lpProps[m_ulDisplayNameColumn].Value.lpszW;
}
else
{
Expand Down Expand Up @@ -1358,27 +1347,28 @@ namespace controls::sortlistctrl
// No lpData or wrong type of row - no work done
if (!lpData) return S_FALSE;
const auto contents = lpData->cast<sortlistdata::contentsData>();
if (!contents || contents->m_ulRowType == TBL_LEAF_ROW || contents->m_ulRowType == TBL_EMPTY_CATEGORY)
if (!contents || contents->getRowType() == TBL_LEAF_ROW || contents->getRowType() == TBL_EMPTY_CATEGORY)
return S_FALSE;

auto bDidWork = false;
LVITEM lvItem = {};
lvItem.iItem = iItem;
lvItem.iSubItem = 0;
lvItem.mask = LVIF_IMAGE;
switch (contents->m_ulRowType)
switch (contents->getRowType())
{
default:
break;
case TBL_COLLAPSED_CATEGORY:
{
if (contents->m_lpInstanceKey)
if (contents->getInstanceKey())
{
auto instanceKey = contents->getInstanceKey();
LPSRowSet lpRowSet = nullptr;
ULONG ulRowsAdded = 0;

hRes = EC_MAPI(m_lpContentsTable->ExpandRow(
contents->m_lpInstanceKey->cb, contents->m_lpInstanceKey->lpb, 256, NULL, &lpRowSet, &ulRowsAdded));
instanceKey->cb, instanceKey->lpb, 256, NULL, &lpRowSet, &ulRowsAdded));
if (hRes == S_OK && lpRowSet)
{
for (ULONG i = 0; i < lpRowSet->cRows; i++)
Expand All @@ -1392,20 +1382,20 @@ namespace controls::sortlistctrl
}

FreeProws(lpRowSet);
contents->m_ulRowType = TBL_EXPANDED_CATEGORY;
contents->setRowType(TBL_EXPANDED_CATEGORY);
lvItem.iImage = static_cast<int>(sortIcon::nodeExpanded);
bDidWork = true;
}
}

break;
case TBL_EXPANDED_CATEGORY:
if (contents->m_lpInstanceKey)
if (contents->getInstanceKey())
{
auto instanceKey = contents->getInstanceKey();
ULONG ulRowsRemoved = 0;

hRes = EC_MAPI(m_lpContentsTable->CollapseRow(
contents->m_lpInstanceKey->cb, contents->m_lpInstanceKey->lpb, NULL, &ulRowsRemoved));
hRes = EC_MAPI(m_lpContentsTable->CollapseRow(instanceKey->cb, instanceKey->lpb, NULL, &ulRowsRemoved));
if (hRes == S_OK && ulRowsRemoved)
{
for (int i = iItem + ulRowsRemoved; i > iItem; i--)
Expand All @@ -1417,7 +1407,7 @@ namespace controls::sortlistctrl
}
}

contents->m_ulRowType = TBL_COLLAPSED_CATEGORY;
contents->setRowType(TBL_COLLAPSED_CATEGORY);
lvItem.iImage = static_cast<int>(sortIcon::nodeCollapsed);
bDidWork = true;
}
Expand All @@ -1430,15 +1420,13 @@ namespace controls::sortlistctrl
hRes = EC_B(SetItem(&lvItem)); // Set new image for the row

// Save the row type (header/leaf) into lpData
const auto lpProp = PpropFindProp(lpData->lpSourceProps, lpData->cSourceProps, PR_ROW_TYPE);
const auto lpProp = lpData->GetOneProp(PR_ROW_TYPE);
if (lpProp && PR_ROW_TYPE == lpProp->ulPropTag)
{
lpProp->Value.l = contents->m_ulRowType;
lpProp->Value.l = contents->getRowType();
}

SRow sRowData = {};
sRowData.cValues = lpData->cSourceProps;
sRowData.lpProps = lpData->lpSourceProps;
auto sRowData = lpData->getRow();
SetRowStrings(iItem, &sRowData);
}

Expand Down Expand Up @@ -1602,7 +1590,7 @@ namespace controls::sortlistctrl
const auto contents = lpListData->cast<sortlistdata::contentsData>();
if (contents)
{
const auto lpCurInstance = contents->m_lpInstanceKey;
const auto lpCurInstance = contents->getInstanceKey();
if (lpCurInstance)
{
if (!memcmp(lpCurInstance->lpb, instance.lpb, instance.cb))
Expand Down
6 changes: 3 additions & 3 deletions UI/Controls/SortList/SingleMAPIPropListCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ namespace controls::sortlistctrl
CLASS,
L"GetSelectedPropTag",
L"returning lpPropTag = 0x%X\n",
prop->m_ulPropTag);
return prop->m_ulPropTag;
prop->getPropTag());
return prop->getPropTag();
}
}
}
Expand Down Expand Up @@ -651,7 +651,7 @@ namespace controls::sortlistctrl
const auto prop = lpListData->cast<sortlistdata::propListData>();
if (prop)
{
ulPropType = PROP_TYPE(prop->m_ulPropTag);
ulPropType = PROP_TYPE(prop->getPropTag());
}
}

Expand Down
12 changes: 6 additions & 6 deletions UI/Controls/SortList/SortListCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ namespace controls::sortlistctrl
if (!lpData2) return sort1First; // sort null items to the end - this makes lParam1>lParam2

// Don't sort items which aren't fully loaded
if (!lpData1->bItemFullyLoaded) return sort2First;
if (!lpData2->bItemFullyLoaded) return sort1First;
if (!lpData1->getFullyLoaded()) return sort2First;
if (!lpData2->getFullyLoaded()) return sort1First;

switch (lpSortInfo->sortstyle)
{
Expand Down Expand Up @@ -480,13 +480,13 @@ namespace controls::sortlistctrl
auto lpData = reinterpret_cast<sortlistdata::sortListData*>(GetItemData(i));
if (lpData)
{
auto row = lpData->getRow();
lpData->clearSortValues();
if (ulSourceCol < lpData->cSourceProps &&
PROP_TYPE(lpData->lpSourceProps[ulSourceCol].ulPropTag) == PT_SYSTIME)
if (ulSourceCol < row.cValues && PROP_TYPE(row.lpProps[ulSourceCol].ulPropTag) == PT_SYSTIME)
{
lpData->setSortValue(
{lpData->lpSourceProps[ulSourceCol].Value.ft.dwLowDateTime,
lpData->lpSourceProps[ulSourceCol].Value.ft.dwHighDateTime});
{row.lpProps[ulSourceCol].Value.ft.dwLowDateTime,
row.lpProps[ulSourceCol].Value.ft.dwHighDateTime});
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions UI/Controls/StyleTree/HierarchyTableTreeCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,9 @@ namespace controls
}

LPCTSTR szName = nullptr;
if (PROP_TYPE(lpData->lpSourceProps[0].ulPropTag) == PT_TSTRING)
szName = lpData->lpSourceProps[0].Value.LPSZ;
auto row = lpData->getRow();
if (row.cValues > 0 && PROP_TYPE(row.lpProps[0].ulPropTag) == PT_TSTRING)
szName = row.lpProps[0].Value.LPSZ;
output::DebugPrintEx(
output::dbgLevel::Hierarchy,
CLASS,
Expand Down Expand Up @@ -473,8 +474,7 @@ namespace controls
auto lpMAPIContainer = GetContainer(hItem, modifyType::REQUEST_MODIFY);
if (!lpMAPIContainer) return;

SPropValue sDisplayName;
sDisplayName.ulPropTag = PR_DISPLAY_NAME;
auto sDisplayName = SPropValue{PR_DISPLAY_NAME, 0};
sDisplayName.Value.LPSZ = szText;

EC_MAPI_S(HrSetOneProp(lpMAPIContainer, &sDisplayName));
Expand Down
12 changes: 5 additions & 7 deletions UI/Dialogs/ContentsTable/AclDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ namespace dialog
const auto bin = MyData.GetBinary(0, false);

lpNewItem->aEntries[0].rgPropVals[0].ulPropTag = PR_MEMBER_ENTRYID;
mapi::setBin(lpNewItem->aEntries[0].rgPropVals[0]) = {static_cast<ULONG>(bin.size()),
const_cast<BYTE*>(bin.data())};
mapi::setBin(lpNewItem->aEntries[0].rgPropVals[0]) = {
static_cast<ULONG>(bin.size()), const_cast<BYTE*>(bin.data())};
lpNewItem->aEntries[0].rgPropVals[1].ulPropTag = PR_MEMBER_RIGHTS;
lpNewItem->aEntries[0].rgPropVals[1].Value.ul = MyData.GetHex(1);

Expand Down Expand Up @@ -219,22 +219,20 @@ namespace dialog
mapi::allocate<LPSPropValue>(2 * sizeof(SPropValue), lpTempList);
lpTempList->aEntries[iArrayPos].cValues = 2;

auto lpSPropValue =
PpropFindProp(lpData->lpSourceProps, lpData->cSourceProps, PR_MEMBER_ID);
auto lpSPropValue = lpData->GetOneProp(PR_MEMBER_ID);

lpTempList->aEntries[iArrayPos].rgPropVals[0].ulPropTag = lpSPropValue->ulPropTag;
lpTempList->aEntries[iArrayPos].rgPropVals[0].Value = lpSPropValue->Value;

lpSPropValue = PpropFindProp(lpData->lpSourceProps, lpData->cSourceProps, PR_MEMBER_RIGHTS);
lpSPropValue = lpData->GetOneProp(PR_MEMBER_RIGHTS);

lpTempList->aEntries[iArrayPos].rgPropVals[1].ulPropTag = lpSPropValue->ulPropTag;
lpTempList->aEntries[iArrayPos].rgPropVals[1].Value = lpSPropValue->Value;
}
else if (ulFlags & ACL_INCLUDE_ID)
{
lpTempList->aEntries[iArrayPos].cValues = 1;
lpTempList->aEntries[iArrayPos].rgPropVals =
PpropFindProp(lpData->lpSourceProps, lpData->cSourceProps, PR_MEMBER_ID);
lpTempList->aEntries[iArrayPos].rgPropVals = lpData->GetOneProp(PR_MEMBER_ID);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions UI/Dialogs/ContentsTable/AttachmentsDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace dialog
if (lpListData)
{
const auto contents = lpListData->cast<sortlistdata::contentsData>();
if (contents && ATTACH_EMBEDDED_MSG == contents->m_ulAttachMethod)
if (contents && contents->getAttachMethod() == ATTACH_EMBEDDED_MSG)
{
auto lpMessage = OpenEmbeddedMessage();
if (lpMessage)
Expand Down Expand Up @@ -170,8 +170,8 @@ namespace dialog
const auto contents = lpListData->cast<sortlistdata::contentsData>();
if (contents)
{
const auto ulAttachNum = contents->m_ulAttachNum;
const auto ulAttachMethod = contents->m_ulAttachMethod;
const auto ulAttachNum = contents->getAttachNum();
const auto ulAttachMethod = contents->getAttachMethod();

// Check for matching cached attachment to avoid reopen
if (ulAttachNum != m_ulAttachNum || !m_lpAttach)
Expand Down Expand Up @@ -226,7 +226,7 @@ namespace dialog
const auto contents = lpListData->cast<sortlistdata::contentsData>();
if (contents)
{
lpAttNumList.push_back(contents->m_ulAttachNum);
lpAttNumList.push_back(contents->getAttachNum());
}
}
}
Expand Down Expand Up @@ -324,7 +324,7 @@ namespace dialog
const auto contents = lpListData->cast<sortlistdata::contentsData>();
if (contents)
{
attachnums.push_back(contents->m_ulAttachNum);
attachnums.push_back(contents->getAttachNum());
}
}
}
Expand Down Expand Up @@ -390,7 +390,7 @@ namespace dialog
const auto contents = lpListData->cast<sortlistdata::contentsData>();
if (contents)
{
const auto ulAttachNum = contents->m_ulAttachNum;
const auto ulAttachNum = contents->getAttachNum();

EC_MAPI_S(m_lpMessage->OpenAttach(
ulAttachNum, nullptr, MAPI_BEST_ACCESS, static_cast<LPATTACH*>(&lpAttach)));
Expand Down
3 changes: 1 addition & 2 deletions UI/Dialogs/ContentsTable/ContentsTableDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,7 @@ namespace dialog
// If we have a row to give, give it - it's free
if (lpData)
{
MyRow.cValues = lpData->cSourceProps;
MyRow.lpProps = lpData->lpSourceProps;
MyRow = lpData->getRow();
MyAddInMenuParams.lpRow = &MyRow;
MyAddInMenuParams.ulCurrentFlags |= MENU_FLAGS_ROW;
}
Expand Down
13 changes: 6 additions & 7 deletions UI/Dialogs/ContentsTable/FolderDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ namespace dialog
const auto contents = lpListData->cast<sortlistdata::contentsData>();
if (contents)
{
const auto lpMessageEID = contents->m_lpLongtermID;
const auto lpMessageEID = contents->getLongTermID();
if (lpMessageEID)
{
LPMAPIPROP lpMAPIProp = nullptr;
Expand Down Expand Up @@ -1150,9 +1150,9 @@ namespace dialog
const auto contents = lpData->cast<sortlistdata::contentsData>();
if (!contents || !m_lpFolder) return MAPI_E_INVALID_PARAMETER;

if (contents->m_lpEntryID)
if (contents->getEntryID())
{
hRes = EC_H(mapi::ResendSingleMessage(m_lpFolder, contents->m_lpEntryID, m_hWnd));
hRes = EC_H(mapi::ResendSingleMessage(m_lpFolder, contents->getEntryID(), m_hWnd));
}

return hRes;
Expand Down Expand Up @@ -1738,7 +1738,7 @@ namespace dialog

ULONG ulMessageStatus = NULL;

const auto lpMessageEID = contents->m_lpEntryID;
const auto lpMessageEID = contents->getEntryID();
if (lpMessageEID)
{
const auto hRes = EC_MAPI(m_lpFolder->GetMessageStatus(
Expand Down Expand Up @@ -1785,8 +1785,7 @@ namespace dialog
const auto contents = lpListData->cast<sortlistdata::contentsData>();
if (contents)
{
const auto lpMessageEID = contents->m_lpEntryID;

const auto lpMessageEID = contents->getEntryID();
if (lpMessageEID)
{
ULONG ulOldStatus = NULL;
Expand Down Expand Up @@ -1845,7 +1844,7 @@ namespace dialog
if (!contents) return MAPI_E_INVALID_PARAMETER;

auto lpMDB = m_lpMapiObjects->GetMDB(); // do not release
const auto lpMessageEID = contents->m_lpEntryID;
const auto lpMessageEID = contents->getEntryID();
if (lpMDB && lpMessageEID)
{
hRes = EC_MAPI(lpMDB->AbortSubmit(lpMessageEID->cb, reinterpret_cast<LPENTRYID>(lpMessageEID->lpb), NULL));
Expand Down
Loading

0 comments on commit 70b53e9

Please sign in to comment.