void CReportCtrl::RemoveEditOptions(CXTPReportRecordItem *pItem,DWORD_PTR dwData) { CXTPReportRecordItemEditOptions *pEditOptions = pItem->GetEditOptions(NULL); ASSERT(pEditOptions != NULL); CXTPReportRecordItemConstraints *pConstraints = pEditOptions->GetConstraints(); ASSERT(pConstraints != NULL); CXTPReportRecordItemConstraint *pConstraint = pEditOptions->FindConstraint(dwData); ASSERT (pConstraint != NULL); CDWordArray dwDatas; CStringArray strConstraints; for (int i=0; i<pConstraints->GetCount(); ++i) { CXTPReportRecordItemConstraint *pConstraint = pConstraints->GetAt(i); if (pConstraint->m_dwData != dwData) { dwDatas.Add(pConstraint->m_dwData); strConstraints.Add(pConstraint->m_strConstraint); } } pConstraints->RemoveAll(); for (int i=0; i<dwDatas.GetCount(); ++i) pEditOptions->AddConstraint(strConstraints[i],dwDatas[i]); }
//old code CString CXTPReportRecordItemVariant::GetCaption(CXTPReportColumn* pColumn) { if (!m_strCaption.IsEmpty()) return m_strCaption; COleVariant var(m_oleValue); CXTPReportRecordItemEditOptions* pEditOptions = NULL; if (m_pEditOptions) pEditOptions = m_pEditOptions; else if (pColumn) pEditOptions = pColumn->GetEditOptions(); BOOL bConstraintEdit = FALSE; if (pEditOptions) bConstraintEdit = pEditOptions->m_bConstraintEdit; TRY { if (var.vt == VT_DATE && !bConstraintEdit && m_strFormatString != _T("%s")) { COleDateTime dt(var); //return dt.Format(m_strFormatString); return CXTPReportControlLocale::FormatDateTime(dt, m_strFormatString); } if (var.vt == VT_NULL) { var.vt = VT_I4; var.lVal = 0; } else { if (bConstraintEdit) CXTPReportControlLocale::VariantChangeTypeEx(var, VT_I4); else CXTPReportControlLocale::VariantChangeTypeEx(var, VT_BSTR); } } CATCH_ALL(e) { } END_CATCH_ALL if (bConstraintEdit) { CXTPReportRecordItemConstraint* pConstraint = pEditOptions ? pEditOptions->FindConstraint(var.lVal) : NULL; return pConstraint ? pConstraint->m_strConstraint : _T(""); } if (var.vt != VT_BSTR) //this function expected VT_BSTR only !? return _T(""); CString strVariant(var.bstrVal); if (m_strFormatString == _T("%s")) return strVariant; CString strCaption; strCaption.Format(m_strFormatString, (LPCTSTR)strVariant); return strCaption; }
void CXTPReportInplaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { if (!pControl) return; if (nChar == VK_TAB) return; if (nChar == VK_ESCAPE) { pControl->EditItem(NULL); return; } if (nChar == VK_RETURN) { if ((GetStyle() & ES_WANTRETURN) == 0) { pControl->EditItem(NULL); } else { CEdit::OnChar(nChar, nRepCnt, nFlags); } return; } if (pItem && pColumn && pItem->GetEditOptions(pColumn)->m_bConstraintEdit) { CXTPReportRecordItemEditOptions* pEditOptions = pItem->GetEditOptions(pColumn); CXTPReportRecordItemConstraints* pConstraints = pEditOptions->GetConstraints(); int nCount = pConstraints->GetCount(); if (nCount > 0) { CString str, strActual; GetWindowText(str); strActual = str; CXTPReportRecordItemConstraint* pConstraint = (m_pSelectedConstraint == NULL) ? pEditOptions->FindConstraint(str): m_pSelectedConstraint; int nIndexStart, nIndex; nIndexStart = nIndex = (pConstraint == NULL ? nCount - 1 : pConstraint->GetIndex()); CString strSeach ((TCHAR)nChar); do { nIndex = nIndex < nCount - 1 ? nIndex + 1 : 0; pConstraint = pConstraints->GetAt(nIndex); str = pConstraint->m_strConstraint; if (strSeach.CompareNoCase(str.Left(1)) == 0) { m_pSelectedConstraint = pConstraint; SetWindowText(str); SetSel(0, -1); if (strActual.CompareNoCase(str) != 0) ((CXTPReportControl*)pControl)->OnConstraintSelecting(pRow, pItem, pColumn, pConstraint); return; } } while (nIndex != nIndexStart); return; } } if (nChar == 1 && nFlags == 30) //Ctrl+A case { SetSel(0, -1); } CEdit::OnChar(nChar, nRepCnt, nFlags); }