Esempio n. 1
0
void wxSheetValueProviderSparseStringTest::SetValue( const wxSheetCoords& coords_,
                                                     const wxString& value )
{
    wxCHECK_RET(ContainsCell(coords_), wxT("Invalid coords"));
    wxSheetCoords coords(HasOption(wxSHEET_ValueProviderColPref) ? coords_ : coords_.GetSwapped());

    m_intArrayIntString.m_key = coords.m_row;
    const int rowPos = m_data.Index(&m_intArrayIntString);
    //const int rowPos = m_data.Index(wxSheetIntArrayIntString(coords.m_row));

    if (value.IsEmpty())
    {
        // remove the value if empty
        if (rowPos != wxNOT_FOUND)
        {
            m_data[rowPos].m_value->Remove(wxSheetIntString(coords.m_col));
            // remove this row if empty
            if (m_data[rowPos].m_value->GetCount() == 0)
                m_data.RemoveAt(rowPos);
        }
    }
    else
    {
        if (rowPos == wxNOT_FOUND)
        {
            //m_intArrayIntString.m_key = coords.m_row;
            //m_intArrayIntString.m_value = wxSheetIntStringSortedObjArray(wxSheetIntString(coords.m_col, value));
            //m_intArrayIntString.m_value.Add(new wxSheetIntString(coords.m_col, value));
            //m_data.Add(m_intArrayIntString);
            m_data.Add(new wxSheetIntArrayIntString(coords.m_row, new wxSheetIntStringSortedObjArray(new wxSheetIntString(coords.m_col, value))));
        }
        else
            m_data[rowPos].m_value->Add(new wxSheetIntString(coords.m_col, value));
    }
}
Esempio n. 2
0
void wxSheetValueProviderSparseString::SetValue( const wxSheetCoords& coords_,
                                                 const wxString& value )
{
    wxCHECK_RET(ContainsCell(coords_), wxT("Invalid coords"));
    wxSheetCoords coords(HasOption(wxSHEET_ValueProviderColPref) ? coords_ : coords_.GetSwapped());
    const int rowPos = m_data.Index(coords.m_row);

    if (!HasOption(wxSHEET_ValueProviderAllowEmpty) && value.IsEmpty())
    {
        // remove the value if empty
        if (rowPos != wxNOT_FOUND)
        {
            m_data.ItemValue(rowPos).Remove(coords.m_col);
            // remove this row if empty
            if (m_data.ItemValue(rowPos).GetCount() == 0)
                m_data.RemoveAt(rowPos);
        }
    }
    else
    {
        if (rowPos == wxNOT_FOUND)
            m_data.GetOrCreateValue(coords.m_row).Add(coords.m_col, value);
        else
            m_data.ItemValue(rowPos).Add(coords.m_col, value);
    }
}
Esempio n. 3
0
bool wxSheetValueProviderSparseStringTest::HasValue( const wxSheetCoords& coords_ ) const
{
    wxCHECK_MSG(ContainsCell(coords_), false, wxT("Invalid coords"));
    wxSheetCoords coords(HasOption(wxSHEET_ValueProviderColPref) ? coords_ : coords_.GetSwapped());
    const int rowPos = m_data.Index(wxSheetIntArrayIntString(coords.m_row));
    if (rowPos == wxNOT_FOUND)
        return false;

    return m_data[rowPos].m_value->Index(wxSheetIntString(coords.m_col)) != wxNOT_FOUND;
}
Esempio n. 4
0
wxString wxSheetValueProviderSparseString::GetValue( const wxSheetCoords& coords_ ) const
{
    wxCHECK_MSG(ContainsCell(coords_), wxEmptyString, wxT("Invalid coords"));
    wxSheetCoords coords(HasOption(wxSHEET_ValueProviderColPref) ? coords_ : coords_.GetSwapped());

    const int rowPos = m_data.Index(coords.m_row);
    if (rowPos != wxNOT_FOUND)
        return m_data.ItemValue(rowPos).GetValue(coords.m_col);

    return wxEmptyString;
}
Esempio n. 5
0
wxString wxSheetValueProviderString::GetValue( const wxSheetCoords& coords_ ) const
{
    wxCHECK_MSG(ContainsCell(coords_), wxEmptyString, wxT("Invalid coords"));
    wxSheetCoords coords(HasOption(wxSHEET_ValueProviderColPref) ? coords_ : coords_.GetSwapped());

    //wxPrintf(wxT("RC %d %d - NumRC %d %d DataRC %d %d '%s'\n"), coords_.m_row, coords_.m_col, m_numRows, m_numCols,
    //    m_data.GetCount(), int(m_data.GetCount()) > coords.m_col ? m_data[coords.m_col].GetCount() : 0,
    //    wxDateTime::Now().FormatISOTime().c_str());

    if ((int(m_data.GetCount()) > coords.m_row) &&
        (int(m_data[coords.m_row].GetCount()) > coords.m_col))
        return m_data[coords.m_row][coords.m_col];

    return wxEmptyString;
}
Esempio n. 6
0
wxString wxSheetValueProviderSparseStringTest::GetValue( const wxSheetCoords& coords_ ) const
{
    wxCHECK_MSG(ContainsCell(coords_), wxEmptyString, wxT("Invalid coords"));
    wxSheetCoords coords(HasOption(wxSHEET_ValueProviderColPref) ? coords_ : coords_.GetSwapped());

    ((wxSheetValueProviderSparseStringTest*)this)->m_intArrayIntString.m_key = coords.m_row;
    const int rowPos = m_data.Index((wxSheetIntArrayIntString*)&m_intArrayIntString);
//    const int rowPos = m_data.Index(wxSheetIntArrayIntString(coords.m_row));

    if (rowPos != wxNOT_FOUND)
    {
        ((wxSheetValueProviderSparseStringTest*)this)->m_intString.m_key = coords.m_col;
        const int colPos = m_data[rowPos].m_value->Index((wxSheetIntString*)&m_intString);
        //const int colPos = m_data[rowPos].m_value.Index(wxSheetIntString(coords.m_col));
        if (colPos != wxNOT_FOUND)
            return m_data[rowPos].m_value->Item(colPos).m_value;
    }

    return wxEmptyString;
}
Esempio n. 7
0
void wxSheetValueProviderString::SetValue( const wxSheetCoords& coords_, const wxString& value )
{
    wxCHECK_RET(ContainsCell(coords_), wxT("Invalid coords"));
    wxSheetCoords coords(HasOption(wxSHEET_ValueProviderColPref) ? coords_ : coords_.GetSwapped());

    // add "rows" as necessary to store value
    int count = m_data.GetCount();
    if (count <= coords.m_row)
    {
        wxArrayString sa;
        sa.Add( wxEmptyString, 1+coords.m_col );
        m_data.Insert( sa, count, 1+coords.m_row-count );
    }
    else // believe it or not - NOT having this else statement is 10% faster in gcc
    {
        // add "cols" as necessary to store value
        count = m_data[coords.m_row].GetCount();
        if (count <= coords.m_col)
        {
            m_data.Item(coords.m_row).Insert( wxEmptyString, count, 1+coords.m_col-count );
        }
    }
    m_data[coords.m_row][coords.m_col] = value;
}