inline wostream& print_field_value(wostream &os, wchar_t tag, const CItemData &item, CItemData::FieldType ft) { StringX fieldValue; switch (ft) { case CItemData::DCA: case CItemData::SHIFTDCA: { int16 dca = -1; if (item.GetDCA(dca) != -1) { LoadAString(fieldValue, dca2str(dca)); } break; } case CItemData::PWHIST: { const StringX pwh_str = item.GetPWHistory(); if (!pwh_str.empty()) { StringXStream value_stream; size_t ignored; PWHistList pwhl; const bool save_pwhistory = CreatePWHistoryList(pwh_str, ignored, ignored, pwhl, PWSUtil::TMC_LOCALE); value_stream << L"Save: " << (save_pwhistory? L"Yes" : L"No"); if ( !pwhl.empty() ) value_stream << endl; for( const auto &pwh: pwhl) value_stream << pwh.changedate << L": " << pwh.password << endl; fieldValue = value_stream.str(); } break; } case CItemData::POLICY: { PWPolicy policy; item.GetPWPolicy(policy); fieldValue = policy.GetDisplayString(); break; } default: fieldValue = item.GetFieldValue(ft); break; } const StringX sep1{L' '}, sep2{L": "}; StringXStream tmpStream; tmpStream << tag << L' ' << item.FieldName(ft) << L": " << fieldValue; const auto offset = 1 /*tag*/ + sep1.size() + sep2.size() + item.FieldName(ft).size(); lines_vec lines{ stream2vec(tmpStream)}; if ( lines.size() > 1) { std::for_each( lines.begin()+1, lines.end(), [offset](StringX &line) { line.insert(0, offset, L' '); }); } for( const auto &line: lines ) os << line << endl; return os; }
wxString PWSGridTable::GetValue(int row, int col) { if (size_t(row) < m_pwsgrid->GetNumItems() && size_t(col) < NumberOf(PWSGridCellData)) { const CItemData *pItem = m_pwsgrid->GetItem(row); if (pItem != NULL) { if (PWSGridCellData[col].ft != CItemData::POLICY) { return towxstring(pItem->GetFieldValue(PWSGridCellData[col].ft)); } else { PWPolicy pwp; pItem->GetPWPolicy(pwp); return towxstring(pwp.GetDisplayString()); } } } return wxEmptyString; }