Example #1
0
void CBibitemView::OnEndlabeleditListFields(NMHDR* pNMHDR, LRESULT* pResult) 
{
	if (!m_Updating) {
		LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
		if (pDispInfo->item.pszText != NULL) {
			int i = pDispInfo->item.iItem;
			CField* f = (CField*)m_ListFields.GetItemData(i);
			if (pDispInfo->item.iSubItem == 0) {
				// It's the field name
				f->SetName(pDispInfo->item.pszText);
				m_ListFields.SetItem(i, pDispInfo->item.iSubItem, LVIF_IMAGE, NULL, 
					m_BibDef->GetRequired(m_BibItem->GetType(), pDispInfo->item.pszText), 0, 0, 0);
			} else if (pDispInfo->item.iSubItem == 1) {
				// It's the field value
				f->SetValue(pDispInfo->item.pszText);
			}
			m_ListFields.SetItemText(i, pDispInfo->item.iSubItem, pDispInfo->item.pszText);
			UpdateMissing();
			*pResult = 1;
			SetModified(m_Modified || f->GetModified());
		} else
			*pResult = 0;
	} else
		*pResult = 0;
}
Example #2
0
/**
 * Add a filter item
 */
CField * CBibList::AddFilter(CString name, CString cond)
{
	CBibItem *filter = GetFilter();
	if (!filter)
		filter = New();
	CField *flt = filter->New();
	flt->SetName(name);
	flt->SetValue(cond);
	return flt;
}
Example #3
0
/**
 * Metodo para setar um valor tipo data no label _szLabel
 */ 
BOOL CTableBase::SetValue(LPCTSTR _szLabel, COleDateTime o)
{
	CField *pField;
	if(m_mapFields.Lookup(_szLabel, pField))
	{
		pField->SetValue(o);
		return TRUE;
	}

	return FALSE;
}
Example #4
0
/**
 * Metodo para setar um valor tipo long no label _szLabel
 */ 
BOOL CTableBase::SetValue(LPCTSTR _szLabel, long _l)
{
	CField *pField;
	if(m_mapFields.Lookup(_szLabel, pField))
	{
		pField->SetValue(_l);
		return TRUE;
	}

	return FALSE;
}
Example #5
0
void CBibitemView::OnFieldlistPopupEdit() 
{
	CSourceDialog dlg;
 	CField* fi = (CField*)m_ListFields.GetItemData(m_SelField);
	dlg.SetSource(fi->GetValue());
	if (dlg.DoModal() == IDOK) {
		fi->SetValue(dlg.GetSource());
		SetModified(m_Modified || fi->GetModified());
		m_ListFields.SetItemText(m_SelField, 1, dlg.GetSource());
	}
}
Example #6
0
void CBibitemView::OnPopupLocalurl() 
{
	CString f, fn;
	f.Format(_T("%s||"), AfxLoadString(IDS_STRING_ALLFILTER));
	CFileDialogEx dlg(TRUE, NULL, fn, OFN_HIDEREADONLY | OFN_ENABLESIZING, f, this);	
	if (dlg.DoModal() == IDOK) {
		CField *fi = m_TmpItem->Find(STR_LOCALURL);
		if (fi == NULL) {
			fi = m_TmpItem->New();
			fi->SetName(STR_LOCALURL);
			fi->SetValue(EncodeFilename(dlg.GetPathName()));
		} else {
			CString val = fi->GetValue();
			if (!val.IsEmpty())
				val += _T("; ") + EncodeFilename(dlg.GetPathName());
			else
				val = EncodeFilename(dlg.GetPathName());
			fi->SetValue(val);
		}
		SetModified();
		PopulateFields();
	}
}
Example #7
0
/**
 * Metodo para limpar todos os valores dos campos da tabela
 */
void CTableBase::Reset(BOOL bExcludeKeys)
{
	POSITION pos = m_mapFields.GetStartPosition();
	CString sKey;
	CField *pField;

	while(pos != NULL)
	{
		m_mapFields.GetNextAssoc( pos, sKey, pField );
		
		if(pField->IsKey() && bExcludeKeys)
			continue;

		pField->SetValue(_T(""));
	}
}
Example #8
0
/**
 * Metodo para zerar o valor dos campos da tabela
 */ 
void CTableBase::ResetFields(CStringList &sIgnoreList)
{
	CField *pField;
	POSITION p;
	CString sLabel;
	CString sTmp;

	p = m_mapFields.GetStartPosition();

	while(p)
	{
		m_mapFields.GetNextAssoc(p, sLabel, pField);
		if(sIgnoreList.Find(sLabel) == NULL)
		{
			pField->SetValue(L"");
		}
	}

}
Example #9
0
void CBibitemView::OnPopupBrowse() 
{
	CString f;
	CString fn;
 	CField* fi = (CField*)m_ListFields.GetItemData(m_SelField);
	fn = DecodeFilename(fi->GetValue());
	CFileFind finder;
	if (!finder.FindFile(fn))
		// Dialog will not show when file does not exist
		fn.Empty();
	finder.Close();
	f.Format(_T("%s||"), AfxLoadString(IDS_STRING_ALLFILTER));
	CFileDialogEx dlg(TRUE, NULL, fn, OFN_HIDEREADONLY | OFN_ENABLESIZING, f, this);	
	if (dlg.DoModal() == IDOK) {
		m_ListFields.SetItemText(m_SelField, 1, EncodeFilename(dlg.GetPathName()));
		fi->SetValue(EncodeFilename(dlg.GetPathName()));
		SetModified(fi->GetModified());
	}
}
Example #10
0
/**
 * Find a Field with name `Local-Url' and append the filename.
 * If no such field exists add one.
 */
void CBibitemView::AddLocalURL(CString url)
{
	CField *fi = m_TmpItem->Find(STR_LOCALURL);
	if (!fi)
		AddField(STR_LOCALURL, url, FALSE);
	else {
		CString val = fi->GetValue();
		if (!val.IsEmpty())
			val += _T("; ") + url;
		else
			val = url;
		fi->SetValue(val);
		for (int i = 0; i < m_ListFields.GetItemCount(); i++) {
			if (m_ListFields.GetItemData(i) == (DWORD)fi) {
				m_ListFields.SetItemText(i, 1, val);
				break;
			}
		}
	}
}
Example #11
0
void CBibitemView::OnPopupCrossref() 
{
	CKeysDialog dlg;
	dlg.SetBibList(GetDocument()->m_BibFile);
	if (dlg.DoModal() == IDOK) {
		CString key = dlg.m_SelKey;
		if (!key.IsEmpty()) {
			CField *cr = m_TmpItem->Find(STR_CROSSREF);
			if (cr) {
				// Has already crossref field
				cr->SetValue(key);
				int inx = GetItemIndex(cr);
				if (inx != -1)
					m_ListFields.SetItemText(inx, 1, key);
			} else {
				// Add the field
				AddField(STR_CROSSREF, key, FALSE);
			}
			SetModified(TRUE);
		}
	}
}
Example #12
0
int CBibitemView::AddField(CString name, CString value, BOOL edit)
{
	BeginUpdate();
	int i = m_ListFields.InsertItem(m_ListFields.GetItemCount(), name, R_UNKNOWN);
	CField *fi = new CField(m_TmpItem);

	fi->SetName(name);
	if (!value.IsEmpty()) {
		m_ListFields.SetItemText(i, 1, value);
		fi->SetValue(value);
	}
	m_TmpItem->AddTail((CObject*)fi);
	m_ListFields.SetItemData(i, (DWORD)fi);
	m_ListFields.EnsureVisible(i, FALSE);
	UINT is = m_ListFields.GetItemState(i, LVIF_STATE);
	m_ListFields.SetItemState(i, is | LVIS_SELECTED | LVIS_FOCUSED, LVIF_STATE);
	m_ListFields.SetFocus();

	EndUpdate();

	if (edit)
		CEdit* edt = m_ListFields.EditSubItem(i, 0);
	return i;
}
Example #13
0
CScriptObject::MEMBERRESULT CFieldScriptObject::ExecuteMemberFunction( char* pszName, Variant* pParameters, int nParameters, Variant& returnValue )
{
    //field value query/modification functions - only if field properties allow!
    if( stricmp( pszName, "getfieldvalue" ) == 0 )
    {
        if( nParameters == 1 )
        {
            //search the entire field list
            int iMax = m_FieldList.GetSize();
            for( int i = 0; i < iMax; i++ )
            {
                //get the next item and return the value if it's the one we're looking for
                CField* pField = m_FieldList[i];
                if( pField && pField->m_Code == pParameters[0] )
                {
                    if( pField->m_dwFlags & FIELD_SCRIPTREAD )
                    {
                        returnValue = pField->GetValue();
                        return OK;
                    }
                    else
                    {
                        AfxMessageBox( CString("Field is protected: ") + CString(LPCSTR(pParameters[0])) );
                        return UNKNOWN_ERROR;
                    }
                }
            };

            //couldn't find it...
            AfxMessageBox( CString("Field not found: ") + CString(LPCSTR(pParameters[0])) );
            return UNKNOWN_ERROR;
        }
        else
            return nParameters < 1 ? TOO_FEW_PARAMS : TOO_MANY_PARAMS;
    }

    if( stricmp( pszName, "setfieldvalue" ) == 0 )
    {
        if( nParameters == 2 )
        {
            //search the entire field list
            int iMax = m_FieldList.GetSize();
            for( int i = 0; i < iMax; i++ )
            {
                //get the next item and change the value if it's the one we're looking for
                CField* pField = m_FieldList[i];
                if( pField && pField->m_Code == pParameters[0] )
                {
                    if( pField->m_dwFlags & FIELD_SCRIPTWRITE )
                    {
                        pField->SetValue( pParameters[1] );
                        return OK;
                    }
                    else
                    {
                        AfxMessageBox( CString("Field is protected: ") + CString(LPCSTR(pParameters[0])) );
                        return UNKNOWN_ERROR;
                    }
                }
            };

            //couldn't find it...
            AfxMessageBox( CString("Field not found: ") + CString(LPCSTR(pParameters[0])) );
            return UNKNOWN_ERROR;
        }
        else
            return nParameters < 2 ? TOO_FEW_PARAMS : TOO_MANY_PARAMS;
    }

    return NOT_FOUND;
}